Miniport Driver Buffer Management

Miniport drivers typically call NdisAllocateNetBufferListPool from MiniportInitializeEx to create a pool of NET_BUFFER_LIST structures. Miniport drivers use these structures to indicate received data.

Typically, a miniport driver that allocates a NET_BUFFER_LIST structure will allocate and queue one NET_BUFFER structure on that NET_BUFFER_LIST structure. It is more efficient to preallocate NET_BUFFER structures when you allocate a pool of NET_BUFFER_LIST structures than to allocate NET_BUFFER_LIST structures and NET_BUFFER structures separately.

Miniport drivers can call NdisAllocateNetBufferListPool and set the AllocateNetBuffer parameter to TRUE to indicate that NET_BUFFER structures are preallocated. In this case, a NET_BUFFER structure is preallocated with each NET_BUFFER_LIST structure that the driver allocates from the pool. Such drivers must call NdisAllocateNetBufferAndNetBufferList to allocate structures from this pool.

Typically, a miniport driver calls NdisAllocateNetBufferAndNetBufferList from MiniportInitializeEx to allocate as many buffers as it will require for subsequent receive operations. In this case, the driver manages an internal list of free buffers.

The MiniportReturnNetBufferLists function can prepare a returned NET_BUFFER_LIST structure for reuse in a subsequent receive indication. Although MiniportReturnNetBufferLists could return the NET_BUFFER_LIST structures to a pool (for example, it could call NdisFreeNetBufferList), it can be more efficient to reuse the structures without returning them to the pool.

A miniport driver should free all the NET_BUFFER_LIST structures and associated data when NDIS halts the adapter. A driver can call NdisFreeNetBufferList to free the structures and the NdisFreeNetBufferListPool function to free the NET_BUFFER_LIST pool.