Implementing SRIOV_DEVICE_INTERFACE_STANDARD_2 + SRIOV_GET_RESOURCE_FOR_BAR

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?

Thanks,
Aj

Ajit,

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.

Regards,
Calvin

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.

Aj.