Simplify the code dealing with the mbuf chain in dp8390_get().
This commit is contained in:
parent
09dd50c412
commit
fe3ce4e89a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dp8390.c,v 1.17 1998/12/11 16:01:16 bad Exp $ */
|
||||
/* $NetBSD: dp8390.c,v 1.18 1998/12/11 18:03:55 bad Exp $ */
|
||||
|
||||
/*
|
||||
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
|
||||
@ -1061,7 +1061,7 @@ dp8390_get(sc, src, total_len)
|
||||
u_short total_len;
|
||||
{
|
||||
struct ifnet *ifp = &sc->sc_ec.ec_if;
|
||||
struct mbuf *top, **mp, *m;
|
||||
struct mbuf *m, *m0, *newm;
|
||||
u_short len;
|
||||
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
@ -1070,23 +1070,13 @@ dp8390_get(sc, src, total_len)
|
||||
m->m_pkthdr.rcvif = ifp;
|
||||
m->m_pkthdr.len = total_len;
|
||||
len = MHLEN;
|
||||
top = 0;
|
||||
mp = ⊤
|
||||
|
||||
m0 = m;
|
||||
while (total_len > 0) {
|
||||
if (top) {
|
||||
MGET(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == 0) {
|
||||
m_freem(top);
|
||||
return 0;
|
||||
}
|
||||
len = MLEN;
|
||||
}
|
||||
if (total_len >= MINCLSIZE) {
|
||||
MCLGET(m, M_DONTWAIT);
|
||||
if ((m->m_flags & M_EXT) == 0) {
|
||||
m_freem(m);
|
||||
m_freem(top);
|
||||
m_freem(m0);
|
||||
return 0;
|
||||
}
|
||||
len = MCLBYTES;
|
||||
@ -1095,7 +1085,7 @@ dp8390_get(sc, src, total_len)
|
||||
/*
|
||||
* Make sure the data after the Ethernet header is aligned.
|
||||
*/
|
||||
if (top == NULL) {
|
||||
if (m == m0) {
|
||||
caddr_t newdata = (caddr_t)
|
||||
ALIGN(m->m_data + sizeof(struct ether_header)) -
|
||||
sizeof(struct ether_header);
|
||||
@ -1109,11 +1099,19 @@ dp8390_get(sc, src, total_len)
|
||||
else
|
||||
src = dp8390_ring_copy(sc, src, mtod(m, caddr_t), len);
|
||||
total_len -= len;
|
||||
*mp = m;
|
||||
mp = &m->m_next;
|
||||
if (total_len > 0) {
|
||||
MGET(newm, M_DONTWAIT, MT_DATA);
|
||||
if (newm == 0) {
|
||||
m_freem(m0);
|
||||
return 0;
|
||||
}
|
||||
m->m_next = newm;
|
||||
m = newm;
|
||||
len = MLEN;
|
||||
}
|
||||
}
|
||||
|
||||
return top;
|
||||
return m0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user