次の方法で共有


Allocating Packet Pools and Buffer Pools in a Protocol Driver (NDIS 5.1)

Note   NDIS 5. x has been deprecated and is superseded by NDIS 6. x. For new NDIS driver development, see Network Drivers Starting with Windows Vista. For information about porting NDIS 5. x drivers to NDIS 6. x, see Porting NDIS 5.x Drivers to NDIS 6.0.

A protocol driver receives one or more buffers of data from a client to transmit over the network. A protocol driver must, at a minimum, allocate and initialize a packet descriptor to which the client's data buffers are chained. Packet descriptors must be allocated from a packet pool, as follows:

  1. Call NdisAllocatePacketPool or NdisAllocatePacketPoolEx to allocate and initialize a block of nonpaged storage for a packet pool. The packet pool is a caller-specified number of fixed-size packet descriptors. This can be done during driver initialization or when each binding is first established.

  2. Call NdisAllocatePacket to allocate a packet descriptor from the packet pool.

To chain buffer descriptors that map such buffers to a packet descriptor, protocol drivers call NdisChainBufferAtBackor NdisChainBufferAtFront. If a protocol driver receives a data buffer from a client that must be sent in several smaller buffers, the protocol driver can copy the data into protocol-allocated buffers, map its buffers with previously-allocated buffer descriptors, and chain these buffer descriptors to protocol-allocated packet descriptors. Such buffers can be allocated by calling a kernel-mode support routine, NdisAllocateMemoryWithTagand can be mapped with protocol-allocated buffer descriptors as follows:

  1. Call NdisAllocateBufferPool to obtain a handle. Use this handle to allocate buffer descriptors during driver initialization or when each binding is first established.

  2. Call NdisAllocateMemoryWithTag to allocate a buffer to chain to a packet descriptor allocated with NdisAllocatePacket.

  3. Call NdisAllocateBuffer to allocate and set up a buffer descriptor that maps the buffer allocated with NdisAllocateMemoryWithTag.

The base virtual address and the length returned by NdisAllocateMemoryWithTagare passed in the call to NdisAllocateBufferto initialize a buffer descriptor.

 

 

Send comments about this topic to Microsoft