Function Level Reset (FLR) from user space

Hello NTDEV community members,
May I ask your opinion/help on below query -
**
In short** - Is it possible to issue FLR from user application?

In Details - A multi function NVMe drive has changed one of its function IOQ pair and/or Interrupt vector. To get this effected on host the BAR register need to be re-read by host OS. The best way to achieve this is to use FLR on the device.
On Linux I can use ‘echo 1 > /sys/bus/pci/devices/BDF…’ and rescan to achieve it.
On Windows, I tried to search the same. I could find the below link -
https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/resetting-and-recovering-a-device
It specifically calls out that FLR can be implemented either by bus driver or by ACPI firmware.

I was giving up the hope that I can do FLR on windows from user space.
But then I came across Discrete Device Assignment (DDA) on Windows -
https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/deploy/deploying-storage-devices-using-dda#dismount-the-device
If I follow below steps -
1. Disable (Disable-PnpDevice -InstanceId -Confirm:$false)
2. Unmount (Dismount-VMHostAssignableDevice -LocationPath $locationPath)
3. mount (Mount-VMHostAssignableDevice -LocationPath $locationPath)
4. Enable (Enble-PnpDevice -InstanceId -Confirm:$false)

The device BAR is reread – essentially FLR is achieved in different way from user space.

Based on above finding I was trying to achieve above effect of steps (1 to 4 above) without having hyper-V services.
My understanding is - if FLR can be achieved by above steps with hyper-V services enabled, there must be a way to achieve FLR by using either devcon.exe or SetupDI* calls without hyper-V.

But my search for this effect has not yielded any result so far.
Does anyone from this group provide some hints on it.

Note: Sorry to posting here though it is not related to driver development directly. But I am not able to find more suitable group for this question.

What do you mean?

A multi function NVMe drive has changed one of its function IOQ pair and/or Interrupt vector.
The PnP manager assigns PCI resources not a device itself. In general, a PCI device should not care about exact numbers of assigned resources, which controlled by the PnP manager. Could you give more details what your device exactly do?
Igor Sharovar

Sorry Igor Sharovar, I was not very specific.
Yes, PnP manager assigns PCI resources. But drive advertise what max it supports. Relevant section in NVme 1.3 spec -
section 8.5 - Virtualization Enhancements (Optional)

  • Virtual Queue Resource (VQ Resource): a type of controller resource that manages one Submission Queue (SQ) and one Completion Queue (CQ) (refer to section 8.5.1); and
  • Virtual Interrupt Resource (VI Resource): a type of controller resource that manages one interrupt vector (refer to section 8.5.2).
    Please let me know if I can explain more. Sorry for the confusion.

Thanks,
Rajeev

OK,it is more clear. I don’t have a real NVMe experience but undrstand it should be allocated through BAR registers as PCI resources. As soon as it allocated you could not change exact numbers, for example interrupt number which you want. But why do you want to change assigned PCI resourses? Applications and drivers must not care about it. It is not their business.
Igor Sharovar

As per NVMe spec the firmware/drive wanted to change the interrupt number. To get this effected, one way to reboot the server so that PCI config space will be re-created by bus driver and drivers stack will be loaded with updated interrupt vector by PnP manager. Reboot can be avoided if a FLR can be issued to the function/drive so that bus driver will re-create the config space for that function/drive. This is what I intended to do from application - FLR to particular function/drive (BDF) from user space.