NDIS packets are allocated by a protocol driver, filled with data, and passed to the next lower NDIS driver so that the data can be sent on the network. Some lowest level NIC drivers allocate packets to hold received data and pass the packet up to interested higher-layer drivers. Sometimes, a protocol driver allocates a packet and passes it to a NIC driver with a request that the NIC driver copy received data into the provided packet. NDIS provides functions for allocating and manipulating the substructures that make up a packet.
A packet is composed of the following:
·A packet descriptor that contains private areas for the miniport NIC driver and a protocol driver, a set of flags associated with the packet and whose meaning is defined by a cooperating miniport(s) and protocol driver(s), the number of physical pages that contain the packet, the total length of the packet, and a pointer to the first buffer descriptor that maps the first buffer in the packet.
·A set of buffer descriptors. A buffer descriptor describes the starting virtual address of each buffer, the buffer's byte offset into the page pointed to by the virtual address, the total number of bytes in the buffer and a pointer to the next buffer descriptor, if any.
·The virtual range, possibly spanning more than one page, that makes up the buffer described by the buffer descriptor. These virtual pages map to physical memory.
A busmaster NIC driver that allocates shared memory for receiving incoming packets or a protocol driver that allocates memory for sending a packet must insure that any buffer used to contain incoming or outgoing data is cache-aligned. This is necessary so that the miniport can flush the buffer to assure coherency before sending a packet and to flush a received buffer before indicating the data to an upper layer.