Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:


ajitabhsajitabhs Member Posts: 94
edited June 2022 in NTDEV

Hi Guys,

I am trying to implement SRIOV_DEVICE_INTERFACE_STANDARD_2 for my SRIOV physical function and need some clarification. There is a function called SRIOV_GET_RESOURCE_FOR_BAR which I am not sure how it could work. The function needs the PF function driver to return the CM_PARTIAL_RESOURCE_DESCRIPTOR for the specified VFs and specified BarIndex. Here is how the function looks like:-

                       SRIOV_GET_RESOURCE_FOR_BAR SriovGetResourceForBar;

                       NTSTATUS SriovGetResourceForBar(
                                                 [in]  PVOID Context,
                                                 [in]  USHORT VfIndex,
                                                 [in]  USHORT BarIndex,
                                                [out] PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource

My question is very basic. How does the PF function driver get the resource list for the VFs? The PF and VF function drivers would not have access to each other's PARTIAL_RESOURCE_DESCRIPTOR that comes in "PrepareHardware" for each driver.

Are the calls different in HyperV environment or something?

How does this work?



  • Calvin_Guan-2Calvin_Guan-2 Member Posts: 315


    VF bars are within PF's PCI config space. It's specified in SRIOV spec. I have a non-KDMF driver (Peter_V et al, please don't blame me-:)) that receives all PF and VF bars resources from PrepareHw equivalent. I would be surprised if kmdf::PrepareHareware wouldn't feed you that info if SRIOV is working correctly at system, OS and driver levels. I would double check if SRIOV is properly enabled on your PF instance.

    Of course you will have the knowledge of your specific HW on size of each VF bar so that you can partition them correctly base on VF ID being queried.

    I'm curious what type of device you are working on? Is it networking or something else? I worked on both intensively but the non-networking one is an extremely rare case.

    Anyway, hope that helps, at least partially.


  • ajitabhsajitabhs Member Posts: 94

    Hi Calvin,
    This is what I was able to figure out. In an Hypervisor environment, the PCI.sys (on the host OS) allocates the resources for the PF (obviously) and then all the BAR resources needed for TotalVFs (as advertised by the hardware). The resources for the PF are in CmResTypeMemory (first <= 6 resources are dedicated for this) and then you also get CmResTypePrivate (another <= 6 resources). These are the resources for the PF.

        I am working on a controller which has the NVME programming interface but is not a storage controller. It exposes a set of VFs which are then used by the Guest OS (es) to talk to perform custom processing in a secure way. 

    Thanks for the help.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 16-20 October 2023 Live, Online
Developing Minifilters 13-17 November 2023 Live, Online
Internals & Software Drivers 4-8 Dec 2023 Live, Online
Writing WDF Drivers 10-14 July 2023 Live, Online