Writing Device Drivers

gldm_send() Entry Point

int prefix_send(gld_mac_info_t *macinfo, mblk_t *mp);

gldm_send() queues a packet to the device for transmission. This routine is passed a STREAMS message containing the packet to be sent. The message might include multiple message blocks. The send() routine must traverse all the message blocks in the message to access the entire packet to be sent. The driver should be prepared to handle and skip over any zero-length message continuation blocks in the chain. The driver should also check that the packet does not exceed the maximum allowable packet size. The driver must pad the packet, if necessary, to the minimum allowable packet size. If the send routine successfully transmits or queues the packet, GLD_SUCCESS should be returned.

The send routine should return GLD_NORESOURCES if the packet for transmission cannot be immediately accepted. In this case, GLDv2 retries later. If gldm_send() ever returns GLD_NORESOURCES, the driver must call gld_sched() at a later time when resources have become available. This call to gld_sched() informs GLDv2 to retry packets that the driver previously failed to queue for transmission. (If the driver's gldm_stop() routine is called, the driver is absolved from this obligation until the driver returns GLD_NORESOURCES from the gldm_send() routine. However, extra calls to gld_sched() do not cause incorrect operation.)

If the driver's send routine returns GLD_SUCCESS, then the driver is responsible for freeing the message when the message is no longer needed. If the hardware uses DMA to read the data directly, the driver must not free the message until the hardware has completely read the data. In this case, the driver can free the message in the interrupt routine. Alternatively, the driver can reclaim the buffer at the start of a future send operation. If the send routine returns anything other than GLD_SUCCESS, then the driver must not free the message. Return GLD_NOLINK if gldm_send() is called when there is no physical connection to the network or link partner.