diff options
author | sam <sam@FreeBSD.org> | 2002-10-25 22:06:03 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2002-10-25 22:06:03 +0000 |
commit | 3859ed12306dd5df0c5c814edb5ea320cec2ab8f (patch) | |
tree | 1daaf82fce2cd43746b8c1039824571768f8c957 /sys/dev/tx | |
parent | afbee5cba8577fcdf8724b27f30670c1d4f8ff2d (diff) | |
download | FreeBSD-src-3859ed12306dd5df0c5c814edb5ea320cec2ab8f.zip FreeBSD-src-3859ed12306dd5df0c5c814edb5ea320cec2ab8f.tar.gz |
o m_adj rx buffer so IP header is 32-bit aligned
o replace EPIC_MGETCLUSER with m_getcl
MFC after: 1 week
Diffstat (limited to 'sys/dev/tx')
-rw-r--r-- | sys/dev/tx/if_tx.c | 38 | ||||
-rw-r--r-- | sys/dev/tx/if_txvar.h | 1 |
2 files changed, 21 insertions, 18 deletions
diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index 1c18cec..dd94f6e 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -578,9 +578,9 @@ epic_ifstart(ifp) /* If packet was more than EPIC_MAX_FRAGS parts, */ /* recopy packet to new allocated mbuf cluster */ - if (NULL != m) { - EPIC_MGETCLUSTER(m); - if (NULL == m) { + if( NULL != m ){ + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if( NULL == m ){ m_freem(m0); ifp->if_oerrors++; continue; @@ -626,6 +626,7 @@ static void epic_rx_done(sc) epic_softc_t *sc; { + struct ifnet *ifp = &sc->sc_if; u_int16_t len; struct epic_rx_buffer *buf; struct epic_rx_desc *desc; @@ -645,7 +646,7 @@ epic_rx_done(sc) * RXE interrupt usually. */ if ((desc->status & 1) == 0) { - sc->sc_if.if_ierrors++; + ifp->if_ierrors++; desc->status = 0x8000; continue; } @@ -655,13 +656,15 @@ epic_rx_done(sc) m = buf->mbuf; /* Try to get mbuf cluster */ - EPIC_MGETCLUSTER(buf->mbuf); - if (NULL == buf->mbuf) { + buf->mbuf = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if( NULL == buf->mbuf ) { buf->mbuf = m; desc->status = 0x8000; - sc->sc_if.if_ierrors++; + ifp->if_ierrors++; continue; } + buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES; + m_adj(buf->mbuf, ETHER_ALIGN); /* Point to new mbuf, and give descriptor to chip */ desc->bufaddr = vtophys(mtod(buf->mbuf, caddr_t)); @@ -669,19 +672,16 @@ epic_rx_done(sc) /* First mbuf in packet holds the ethernet and packet headers */ eh = mtod(m, struct ether_header *); - m->m_pkthdr.rcvif = &(sc->sc_if); - m->m_pkthdr.len = m->m_len = len; - - /* Second mbuf holds packet ifself */ m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); m->m_data += sizeof(struct ether_header); + m->m_pkthdr.rcvif = ifp; /* Give mbuf to OS */ - ether_input(&sc->sc_if, eh, m); + ether_input(ifp, eh, m); /* Successfuly received frame */ - sc->sc_if.if_ipackets++; - } + ifp->if_ipackets++; + } return; } @@ -1562,14 +1562,16 @@ epic_init_rings(sc) return EFAULT; } - EPIC_MGETCLUSTER(buf->mbuf); - if (NULL == buf->mbuf) { + buf->mbuf = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if( NULL == buf->mbuf ) { epic_free_rings(sc); return ENOBUFS; } - desc->bufaddr = vtophys(mtod(buf->mbuf, caddr_t)); + buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES; + m_adj(buf->mbuf, ETHER_ALIGN); - desc->buflength = MCLBYTES; /* Max RX buffer length */ + desc->bufaddr = vtophys( mtod(buf->mbuf,caddr_t) ); + desc->buflength = buf->mbuf->m_len;/* Max RX buffer length */ desc->status = 0x8000; /* Set owner bit to NIC */ } diff --git a/sys/dev/tx/if_txvar.h b/sys/dev/tx/if_txvar.h index 922eaf2..16dc36d 100644 --- a/sys/dev/tx/if_txvar.h +++ b/sys/dev/tx/if_txvar.h @@ -48,6 +48,7 @@ #define TX_RING_MASK (TX_RING_SIZE - 1) #define RX_RING_MASK (RX_RING_SIZE - 1) #define ETHER_MAX_FRAME_LEN (ETHER_MAX_LEN + ETHER_CRC_LEN) +#define ETHER_ALIGN 2 /* This is driver's structure to define EPIC descriptors */ struct epic_rx_buffer { |