4.6  Receiving Data

Miniports choose between two methods of passing incoming data to upper layers.

·Miniports call NdisMIndicateReceivePacket with a pointer to an array of pointers to one or more packets containing the received data. When a miniport indicates received data by calling NdisMIndicateReceivePacket, each entire packet is passed up to the receiving layer. When NdisMIndicateReceivePacket returns, the miniport relinquishes ownership of any packets for which the returned status is NDIS_STATUS_PENDING. The miniport does, however, retain ownership of the array containing the pointers. This means that when NdisMIndicateReceivePacket returns, the miniport must read the Status member of the OOB block for each packet descriptor, and must not reference any resources specified by a packet descriptor if the Status member is set to NDIS_STATUS_PENDING. Pending packets will be returned to the MiniportReturnPacket function when interested protocol driver(s) have consumed the received data. If the Status member is NDIS_STATUS_SUCCESS, the packet descriptor and all the resources it specifies have been returned to the miniport. Any packets for which the miniport set the Status to NDIS_STATUS_RESOURCES before calling NdisMIndicateReceivePacket, will be returned to the miniport when NdisMIndicateReceivePacket returns.

·Miniports call NdisMXxxIndicateReceive with a pointer to a lookahead buffer. Interested protocol drivers copy the data in the buffer. If the packet is small and the entire packet is indicated up in the lookahead buffer, the receive is complete when NdisMXxxIndicateReceive returns. If there is more received data for the protocol, it will call NdisTransferData from within the protocol driver’s ReceivePacket handler causing the miniport to be called at its MiniportTransferData function to transfer the remainder of the received data.

Miniports that indicate receives by calling NdisMIndicateReceivePacket do not need a TransferData handler. Miniports that indicate receives by calling NdisMXxxReceive do not need a ReturnPacket handler.