MSI-X Pre-Registration
To support changing interrupt affinities for MSI-X or to remove message interrupt resources, a miniport driver must establish a resource-requirements filter function. This pre-registration step occurs before NDIS calls the MiniportInitializeEx function.
To establish a resource-requirements filter function, the miniport driver must provide a MiniportSetOptions function. When the miniport driver calls the NdisMRegisterMiniportDriver function from the DriverEntry routine, the driver passes the entry point for MiniportSetOptions in the NDIS_MINIPORT_DRIVER_CHARACTERISTICS structure. NDIS calls the MiniportSetOptions function in the context of NdisMRegisterMiniportDriver.
From MiniportSetOptions, the miniport driver calls the NdisSetOptionalHandlers function and specifies an NDIS_MINIPORT_PNP_CHARACTERISTICS structure. This structure defines the entry points for the MiniportAddDevice, MiniportRemoveDevice, MiniportStartDevice, and MiniportFilterResourceRequirements functions.
When NDIS receives an add-device request from the Plug and Play (PnP) manager, NDIS calls the miniport driver's MiniportAddDevice function. The handle that NDIS passes to MiniportAddDevice in the MiniportAdapterHandle parameter is the handle that NDIS later passes to the MiniportInitializeEx function.
In MiniportAddDevice, the driver initializes an NDIS_MINIPORT_ADD_DEVICE_REGISTRATION_ATTRIBUTES structure and passes this structure to the NdisMSetMiniportAttributes function. The NDIS_MINIPORT_ADD_DEVICE_REGISTRATION_ATTRIBUTES structure contains the MiniportAddDeviceContext member that is a handle to a miniport driver-allocated context area for the device. NDIS later provides this context handle to the MiniportRemoveDevice, MiniportFilterResourceRequirements, MiniportStartDevice, and MiniportInitializeEx functions. For MiniportInitializeEx, the context handle is passed in the MiniportAddDeviceContext member of the NDIS_MINIPORT_INIT_PARAMETERS structure that the MiniportInitParameters parameter points to.
After NDIS calls MiniportAddDevice and MiniportAddDevice returns NDIS_STATUS_SUCCESS, NDIS calls the MiniportFilterResourceRequirements function every time that it receives the IRP_MN_FILTER_RESOURCE_REQUIREMENTS I/O request packet (IRP). MiniportFilterResourceRequirements can change the interrupt affinity for each MSI-X message, add message interrupt resources, or remove message interrupt resources if the driver will register for line-based interrupts in the MiniportInitializeEx function. For more information about establishing an interrupt affinity policy, see MSI-X Resource Filtering.
When NDIS receives a remove-device request from the PnP manager, NDIS calls the miniport driver's MiniportRemoveDevice function. The MiniportRemoveDevice function should undo the operations that the MiniportAddDevice function performed.