Register the Context Area and Miniport Adapter Attributes with NDIS (Compact 2013)
3/26/2014
Your miniport driver specifies adapter attributes in the NDIS_MINIPORT_ADAPTER_ATTRIBUTES structure that your MiniportInitializeEx entry point passes to NdisMSetMiniportAttributes. The NDIS 6.0 NdisMSetMiniportAttributes function replaces the NDIS 5.x NdisMSetAttributes and NdisMSetAttributesEx functions.
The following table shows which API elements have been renamed and/or changed for NDIS 6.0.
NDIS 5.x |
NDIS 6.0 |
---|---|
NdisMSetAttributes |
NdisMSetMiniportAttributes |
To register the context area and miniport adapter attributes with NDIS
Remove calls to NdisMSetAttributes and NdisMSetAttributesEx in your driver.
Call NdisMSetMiniportAttributes to register adapter attributes with NDIS.
Your driver passes miniport adapter configuration attributes to NdisMSetMiniportAttributes, including the medium type, flags, check-for-hang time, and interface type. The NDIS_MINIPORT_ADAPTER_ATTRIBUTES structure that you pass to NdisMSetMiniportAttributes is actually a pointer to one of the following structures:
- NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES
- NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES
- NDIS_MINIPORT_ADAPTER_OFFLOAD_ATTRIBUTES
The miniport adapter registration attributes structure has been updated for NDIS 6.0. For example, because all NDIS 6.0 miniport drivers are deserialized, this structure does not contain the NDIS_ATTRIBUTE_DESERIALIZE attribute flag that was present in the NDIS 5.x miniport adapter registration attributes structure.
The following code example shows how to pass registration attributes to NdisMSetMiniportAttributes for a Peripheral Component Interface (PCI) bus network adapter that supports bus-master direct memory access (DMA) operations.
Important
For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.
NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES RegistrationAttributes;
// Set the adapter context:
RegistrationAttributes.MiniportAdapterContext = (NDIS_HANDLE)pMyAdapter;
// Set registration attributes:
RegistrationAttributes.Header.Type =
NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES;
RegistrationAttributes.Header.Revision =
NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1;
RegistrationAttributes.Header.Size =
sizeof(NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES);
RegistrationAttributes.AttributeFlags =
NDIS_MINIPORT_ATTRIBUTES_HARDWARE_DEVICE |
NDIS_MINIPORT_ATTRIBUTES_BUS_MASTER;
RegistrationAttributes.CheckForHangTimeInSeconds = 2;
RegistrationAttributes.InterfaceType = NdisInterfacePci;
// Register the network adapter:
Status = NdisMSetMiniportAttributes(pMyAdapter->MiniportAdapterHandle,
(PNDIS_MINIPORT_ADAPTER_ATTRIBUTES)&RegistrationAttributes);
The preceding code example sets MiniportAdapterContext to the handle of the context area that the miniport driver allocated in its MiniportInitializeEx function. Next, the AttributeFlags member is set to NDIS_MINIPORT_ATTRIBUTES_HARDWARE_DEVICE to indicate that the miniport driver directly controls a physical device. The NDIS_MINIPORT_ATTRIBUTES_BUS_MASTER flag is enabled to indicate that the network adapter is a bus-master DMA device. Because this adapter resides on a PCI bus, InterfaceType is set to NdisInterfacePci. In this example, the adapter handle was saved in the adapter context area (the MiniportAdapterHandle member of pMyAdapter
) during the previous call to MiniportInitializeEx.