diff options
author | mdodd <mdodd@FreeBSD.org> | 2003-03-27 20:38:00 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2003-03-27 20:38:00 +0000 |
commit | 0d6bd6a1ee0bc3957f728462d4a25c1d3dd25968 (patch) | |
tree | bf8c4168bf43dec45f50910becf20534daa67b51 /sys/dev/ie/if_ie.c | |
parent | eba009d07f5e56ad873dfabf749a9b9a7bd2ee81 (diff) | |
download | FreeBSD-src-0d6bd6a1ee0bc3957f728462d4a25c1d3dd25968.zip FreeBSD-src-0d6bd6a1ee0bc3957f728462d4a25c1d3dd25968.tar.gz |
- Rely on ether_ifattach() to initialize part of our struct ifnet
rather than doing it ourself.
- Set ifq_maxlen.
- Include the size of the ethernet header when we allocate
our mbuf chain in ieget().
Diffstat (limited to 'sys/dev/ie/if_ie.c')
-rw-r--r-- | sys/dev/ie/if_ie.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index ea36ece..58dbd5f 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -784,13 +784,10 @@ ieattach(struct isa_device *dvp) ie->arpcom.ac_enaddr, ":"); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_output = ether_output; ifp->if_start = iestart; ifp->if_ioctl = ieioctl; ifp->if_init = ieinit; - ifp->if_type = IFT_ETHER; - ifp->if_addrlen = 6; - ifp->if_hdrlen = 14; + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; if (ie->hard_type == IE_EE16) EVENTHANDLER_REGISTER(shutdown_post_sync, ee16_shutdown, @@ -1124,6 +1121,7 @@ ie_packet_len(int unit, struct ie_softc * ie) static __inline int ieget(int unit, struct ie_softc *ie, struct mbuf **mp) { + struct ether_header eh; struct mbuf *m, *top, **mymp; int offset; int totlen, resid; @@ -1134,18 +1132,10 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp) if (totlen <= 0) return (-1); - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (!m) { - ie_drop_packet_buffer(unit, ie); - /* XXXX if_ierrors++; */ - return (-1); - } - /* * Snarf the Ethernet header. */ - bcopy((v_caddr_t) ie->cbuffs[ie->rbhead], mtod(m, caddr_t), - sizeof (struct ether_header)); + bcopy((caddr_t)ie->cbuffs[ie->rbhead], &eh, sizeof(struct ether_header)); /* ignore cast-qual warning here */ /* @@ -1154,7 +1144,7 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp) * This is only a consideration when FILTER is defined; i.e., when * we are either running BPF or doing multicasting. */ - if (!check_eh(ie, mtod(m, struct ether_header *))) { + if (!check_eh(ie, &eh)) { m_free(m); ie_drop_packet_buffer(unit, ie); ie->arpcom.ac_if.if_ierrors--; /* just this case, it's not an @@ -1163,16 +1153,19 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp) return (-1); } - /* XXX way too complicated, check carefully XXXX */ + MGETHDR(m, M_DONTWAIT, MT_DATA); + if (!m) { + ie_drop_packet_buffer(unit, ie); + /* XXXX if_ierrors++; */ + return (-1); + } *mp = m; m->m_pkthdr.rcvif = &ie->arpcom.ac_if; - /* deduct header just copied; m_len must reflect space avail below */ - m->m_len = MHLEN - sizeof (struct ether_header); - m->m_pkthdr.len = totlen; + m->m_len = MHLEN; + resid = m->m_pkthdr.len = totlen; + top = 0; - resid = totlen - sizeof (struct ether_header); /* remaining data */ - top = NULL; mymp = ⊤ /* @@ -1213,10 +1206,11 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp) mymp = &m->m_next; } while (resid > 0); - resid = totlen - sizeof (struct ether_header); /* remaining data */ - offset = sizeof (struct ether_header); /* packet offset */ + resid = totlen; /* remaining data */ + offset = 0; /* packet offset */ + thismboff = 0; /* offset in m */ + m = top; /* current mbuf */ - thismboff = sizeof (struct ether_header); /* offset in m */ head = ie->rbhead; /* current rx buffer */ /* |