Handling OID_NIC_SWITCH_ALLOCATE_VF Requests

When the miniport driver for the PCI Express (PCIe) Physical Function (PF) on the network adapter handles the object identifier (OID) method request of OID_NIC_SWITCH_ALLOCATE_VF, it does the following:

  • The PF miniport driver allocates the software resources for a PCIe Virtual Function (VF) on the network adapter. These resources are configured based on the parameters that are specified in the NDIS_NIC_SWITCH_VF_PARAMETERS structure.

  • The PF miniport driver assigns the VF to a NIC switch on the network adapter. The NIC switch is identified by the SwitchId member of the NDIS_NIC_SWITCH_VF_PARAMETERS structure.

    For more information on a NIC switch, see NIC Switches.

  • The PF miniport driver updates the VFId member with a VF identifier. This identifier is a zero-based index and must be unique across all VFs that are allocated on the NIC switch by the PF miniport driver.

    The overlying driver uses the value of the VFId member in successive OID requests of OID_NIC_SWITCH_FREE_VF or OID_NIC_SWITCH_VF_PARAMETERS.

  • The PF miniport driver updates the RequestorId member with a PCIe Requestor Identifier (RID) for the VF.

    The miniport driver calls NdisMGetVirtualFunctionLocation to get the RID information that corresponds to the VF. The driver then creates the RID by using the NDIS_MAKE_RID macro based on the information returned by the call to NdisMGetVirtualFunctionLocation.

    The RID is used by the virtualization stack for remapping DMA and interrupts between the PF and VF. The RID also enables the hardware input/output memory management unit (IOMMU) to convert guest physical addresses to host physical addresses.

  • The PF miniport driver initializes and exposes the VF. This makes the VF ready for use by the virtualization stack.

If the PF miniport driver can successfully allocate the necessary software resources and initialize the VF, the driver completes the OID request with NDIS_STATUS_SUCCESS. The PF miniport driver must keep the VF IDs for each allocated VF. NDIS and the overlying drivers use the VF identifier in successive OID requests to the PF miniport driver for various actions, such as resetting or freeing the VF.

Note  When resources for the VF are allocated, the VF is in an unattached state because a virtual port (VPort) is not attached to the VF. The overlying driver can issue an OID request of OID_NIC_SWITCH_CREATE_VPORT to create and attach a VPort to the VF. For more information, see Creating a Virtual Port.