2
Looks for errors.
3
Processes the error.
4
Processes the overrun error case.
5
Processes the runt and oversized error cases.
6
Processes the CRC error case.
7
Processes the alignment error case.
8
Discards the packet if none of the previous cases apply. This indicates a
size error.
9
Allocates a buffer for the received data. If the length of the received
data is less than a small
mbuf
, allocates a small
mbuf
. Otherwise, a 2K
cluster
mbuf
is allocated. This code is an optimization. In most cases,
a driver does not know the size of a receive packet when the buffer
resource is allocated.
13.2.3 Examining the First Part of the Packet
The following code shows how the
el_rint( )
routine examines the first
part of the received packet:
if (m != NULL) {
1
m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header);
2
m->m_pkthdr.rcvif = ifp;
m->= 2;
3
dat = mtod(m, unsigned char *);
4
len = (len + 3) & ~3;
if ((ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI)) == 0) {
5
io_blockread(sc->data,
(vm_offset_t)dat,
2UL*4UL,
HANDLE_LONGWORD);
6
len -= (2*4);
dat += (2*4);
if (*mtod(m, unsigned char *) & 0x01) {
7
Implementing the Interrupt Section 13–7