2

3

4

5

6

7

8

9

Looks for errors.

Processes the error.

Processes the overrun error case.

Processes the runt and oversized error cases.

Processes the CRC error case.

Processes the alignment error case.

Discards the packet if none of the previous cases apply. This indicates a size error.

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->m_data +=

2;

 

3

 

 

dat = mtod(m, unsigned char *); 4 len = (len + 3) & ~3;

if ((ifp->if_flags & (IFF_PROMISCIFF_ALLMULTI)) == 0) { 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

5

Implementing the Interrupt Section 13–7

Page 145
Image 145
Compaq AA-RNG2A-TE manual Examining the First Part of the Packet