Receiving Data in Protocol Drivers

The following figure illustrates a basic receive operation, which involves a protocol driver, NDIS, and underlying drivers in a driver stack.

Diagram illustrating a basic receive operation involving a protocol driver, NDIS, and underlying drivers in a driver stack.

NDIS calls a protocol driver's ProtocolReceiveNetBufferLists function to process receive indications that come from underlying drivers. NDIS calls ProtocolReceiveNetBufferLists after an underlying driver calls a receive indication function (for example, NdisMIndicateReceiveNetBufferLists) to indicate received network data or loop-back data.

If the NDIS_RECEIVE_FLAGS_RESOURCES flag in the ReceiveFlags parameter of ProtocolReceiveNetBufferLists is not set, the protocol driver retains ownership of the NET_BUFFER_LIST structures until it calls the NdisReturnNetBufferLists function. If NDIS sets the NDIS_RECEIVE_FLAGS_RESOURCES flag, the protocol driver cannot retain the NET_BUFFER_LIST structure and the associated resources. The set NDIS_RECEIVE_FLAGS_RESOURCES flag indicates that an underlying driver is running low on receive resources. In this case, the ProtocolReceiveNetBufferLists function should copy the received data into protocol-allocated storage and return as quickly as possible.

Note  NDIS can change the flags that an underlying driver indicates. For example, if a miniport driver sets the NDIS_RECEIVE_FLAGS_RESOURCES flag in the ReceiveFlags parameter of the NdisMIndicateReceiveNetBufferLists function, NDIS can copy the indicated data and pass the copy to ProtocolReceiveNetBufferLists with the NDIS_RECEIVE_FLAGS_RESOURCES flag cleared.

Note  If the NDIS_RECEIVE_FLAGS_RESOURCES flag is set, the protocol driver must retain the original set of NET_BUFFER_LIST structures in the linked list. For example, when this flag is set the driver might process the structures and indicate them up the stack one at a time but before the function returns it must restore the original linked list.

Protocol drivers call the NdisReturnNetBufferLists function to release ownership of a list of NET_BUFFER_LIST structures, along with the associated NET_BUFFER structures, and network data.