2.4.3  Sending Data

MiniportSendPackets receives a pointer to an array of pointer(s) to one or more packets to be sent on the network. When MiniportSendPackets returns, ownership of the array that holds the pointers to the passed packets reverts to the caller.

The NIC driver can extract the OOB media-specific and priority information from the packet descriptor using NDIS macros supplied for this purpose.

The miniport NIC driver must set the send-completion status in each packet before returning from MiniportSendPackets. That is, the NIC driver can complete a packet synchronously and set the status to NDIS_STATUS_SUCCESS or NDIS_STATUS_FAILURE, (or a driver-determined status other than NDIS_STATUS_PENDING) for that packet. Any such status indicates that the miniport is done with the packet and is returning ownership of the packet to the caller for reuse or to be freed.

If it returns NDIS_STATUS_PENDING in a packet, the driver retains ownership of that packet, and must later call NdisMSendComplete when it is done with the packet. Unless the NIC driver sets the status to other than NDIS_STATUS_PENDING before returning from MiniportSendPackets or calls NdisMSendComplete for those packets for which it returned NDIS_STATUS_PENDING, the driver owns the packet. The miniport calls NdisMSendComplete when it is finished with the packet, meaning it is returning the packet to the caller for reuse or to be freed.

A driver can indicate that it does not have any available send resources for a packet by returning NDIS_STATUS_RESOURCES for that packet. In this case NDIS will queue and then resubmit the packet later when the miniport NIC driver calls either NdisMSendComplete or NdisMSendResourcesAvailable. Once a miniport specifies the return status of NDIS_STATUS_RESOURCES for a packet that is a member of a packet array, NDIS assumes this same status for any subsequent packets in that array.

Sending data synchronously

MiniportSend transmits a single packet through the network interface card onto the network. MiniportSend translates the packet into a data frame and carries out the send operation. Before the miniport actually sends the packet, it can optionally query the packet by calling NdisGetPacketFlags to read information in the Flags member of the packet header structure that a protocol driver passes to the NIC driver. This Flags member contains information about the send that is not included in the packet data. The Flags are used to communicate information between a cooperating protocol and miniport driver that have defined the flags. The driver can also query the media-specific and priority in the OOB data substructure of the packet descriptor, if the driver supports such features.

If MiniportSend completes synchronously, completing the send operation before it returns, a status code other than NDIS_STATUS_PENDING or NDIS_STATUS_RESOURCES is returned. Completing the send means the miniport driver is finished with the packet and is returning it to the caller for reuse or to be freed.

In the asynchronous case, the miniport returns NDIS_STATUS_PENDING and must call NdisMSendComplete when it is done with the packet to indicate that it is relinquishing the packet for reuse or to be freed.

When the miniport calls NdisMSendComplete or NdisMSendResourcesAvailable, it indicates to NDIS that send resources are now available and the miniport is ready to accept a new packet.

The miniport NIC driver returns NDIS_STATUS_RESOURCES to indicate that it does not have enough internal resources to send a packet. In this case, NDIS queues the packet internally and resubmits it to the NIC driver at a later time when more resources are available, either when the miniport calls NdisMSendComplete or NdisMSendResourcesAvailable, whichever occurs first.