MiniportReturnPacket

VOID
MiniportReturnPacket(
IN NDIS_HANDLE MiniportAdapterContext,
IN PNDIS_PACKET Packet
);

MiniportReturnPacket is a required function in drivers that indicate receives with NdisMIndicateReceivePacket.

Parameters

MiniportAdapterContext

Specifies the handle to a miniport-allocated context area in which the driver maintains per-NIC state, set up by MiniportInitialize.

Packet

Points to a packet descriptor being returned to the miniport, which previously indicated a packet array that contained this pointer.

Comments

Drivers of busmaster DMA NICs that support multipacket receives and NIC drivers that supply media-specific information, such as packet priorities, with their indications must have MiniportReturnPacket functions. NDIS intermediate drivers that bind themselves to such a NIC driver also must have MiniportReturnPacket functions.

Any packet with associated NDIS_PACKET_OOB_DATA in which the Status is set to NDIS_STATUS_PENDING on return from NdisMIndicateReceivePacket will be returned to MiniportReturnPacket. When all bound protocols have called NdisReturnPackets as many times as necessary to release their references to the originally indicated packet array, NDIS returns pended packets from the array to the MiniportReturnPacket function of the driver that originally allocated the packet array.

Usually, MiniportReturnPacket prepares such a returned packet to be used in a subsequent receive indication. Although MiniportReturnPacket could return the buffer descriptors chained to the packet to buffer pool and the packet descriptor itself to packet pool, it is far more efficient to reuse returned descriptors.

MiniportReturnPacket must call NdisUnchainBufferAtXxx as many times as necessary to save the pointers to all chained buffer descriptors before it calls NdisReinitializePacket. Otherwise, MiniportReturnPacket cannot recover the buffer descriptors the driver originally chained to the packet for the indication.

MiniportReturnPacket also can call NdisZeroMemory with the pointer returned by NDIS_OOB_DATA_FROM_PACKET to prepare the packet's associated out-of-band block for reuse.

If a particular buffer descriptor was shortened to match the size of an indicated range of data, MiniportReturnPacket should call NdisAdjustBufferLength with that buffer descriptor to restore its mapping of the NIC's receive buffer range.

By default, MiniportReturnPacket runs at IRQL DISPATCH_LEVEL.

See Also

NdisAdjustBufferLength, NdisAllocateBuffer, NdisAllocatePacket, NdisMIndicateReceivePacket, NDIS_OOB_DATA_FROM_PACKET, NDIS_PACKET, NDIS_PACKET_OOB_DATA, NdisReinitializePacket, NdisReturnPackets, NdisUnchainBufferAtBack, NdisUnchainBufferAtFront, NdisZeroMemory