Enumerating Virtual Functions on a Network Adapter
An overlying driver or user application can obtain a list of all PCI Express (PCIe) Virtual Functions (VFs) on a network adapter that supports single root I/O virtualization (SR-IOV). The driver or application issues an object identifier (OID) method request of OID_NIC_SWITCH_ENUM_VFS to obtain this list.
Before the driver or application issues the OID request, it must initialize an NDIS_NIC_SWITCH_VF_INFO_ARRAY structure that is passed along with the request. The driver or application must follow these guidelines when initializing the NDIS_NIC_SWITCH_VF_INFO_ARRAY structure:
If the NDIS_NIC_SWITCH_VF_INFO_ARRAY_ENUM_ON_SPECIFIC_SWITCH flag is set in the Flags member, the overlying driver or application must set the SwitchId member to the identifier of a NIC switch on the SR-IOV network adapter. By setting these members in this manner, VF information is returned only for the specified NIC switch on the SR-IOV network adapter.
Note The overlying driver and user-mode application can obtain the NIC switch identifiers by issuing an OID query request of OID_NIC_SWITCH_ENUM_SWITCHES.
If the Flags member is set to zero, the driver or application must set the SwitchId member to zero. By setting these members in this manner, VF information is returned for all NIC switches on the SR-IOV network adapter.
Note Starting with Windows Server 2012, Windows supports only the default NIC switch on the network adapter. Regardless of the flags set in the Flags member, the SwitchId member must be set to NDIS_DEFAULT_SWITCH_ID.
After a successful return from this OID query request, the InformationBuffer member of the NDIS_OID_REQUEST structure contains a pointer to a buffer that contains the following:
An NDIS_NIC_SWITCH_VF_INFO_ARRAY structure that defines the number of elements within the array.
An array of NDIS_NIC_SWITCH_VF_INFO structures. Each of these structures contains information about a single VF on a NIC switch of the network adapter. A VF is attached to a NIC switch through OID method requests of OID_NIC_SWITCH_ALLOCATE_VF.
Note If no VFs are attached to a NIC switch on the network adapter, the NumElements member of the NDIS_NIC_SWITCH_VF_INFO_ARRAY structure is set to zero and no NDIS_NIC_SWITCH_VF_INFO structures are returned.
For more information on NIC switches, see NIC Switches.
NDIS handles the OID_NIC_SWITCH_ENUM_VFS request for miniport drivers. NDIS returns the information from an internal cache of the data that it maintains from inspecting the following sources:
OID method requests of OID_NIC_SWITCH_ALLOCATE_VF.
OID set requests of OID_NIC_SWITCH_VF_PARAMETERS.