2

3

Copies transmit data from memory to the card using 32-bit writes. Only a multiple of 4 bytes can be copied this way.

If some number of bytes (fewer than 4) remain in the current memory buffer, the driver either copies those bytes directly to the card (if they were the last bytes for the entire frame), or combines those bytes with bytes from the next memory buffer (if there is more data for this frame).

9.2.4 Accounting for Outgoing Bytes

The following code shows how the el_start_locked( ) routine accounts for the outgoing bytes:

sc->txfree -= ((m->m_pkthdr.len + 3) & ~ 0x3); sc->txfree -= 4;

1

1

Maintains the number of bytes free in the transmit FIFO.

9.2.5Updating Counters, Freeing the Transmit Buffer, and Marking the Output Process as Active

The following code shows how the el_start_locked( ) routine updates counters, frees the transmit buffer, and marks the output process as active:

ADD_XMIT_PACKET(ifp, sc, m->m_pkthdr.len); 1 eh = mtod(m, struct ether_header *);

if (eh->ether_dhost[0] & 0x1) { ADD_XMIT_MPACKET(ifp, sc, m->m_pkthdr.len);

}

m_freem(m);

2

ifp->if_flags = IFF_OACTIVE;

} else if (m) { 3 IF_PREPEND(&ifp->if_snd, m); break;

}else break;

}

1

2

3

Updates the counters using the ADD_XMIT_PACKET and possibly the ADD_XMIT_MPACKET (for multicast packets) macros. These macros are defined in the lan_common.h file. Most network drivers perform this task in the transmit complete interface.

Calls the m_freem( ) routine to free the mbuf buffer. Network drivers must free the buffer after the transmit operation is complete.

If there is no room for this transmit, puts the mbuf back on the queue.

Implementing the Start Section 9–7

Page 119
Image 119
Compaq AA-RNG2A-TE manual Accounting for Outgoing Bytes