diff options
author | sam <sam@FreeBSD.org> | 2002-11-15 00:00:15 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2002-11-15 00:00:15 +0000 |
commit | 6a05792540ffa00713f4b3a1521864f7dddc1f39 (patch) | |
tree | 2a5611d45149f91e7ddfd0e32391f1ef7d8590e1 /sys/i386 | |
parent | 36661cddf10b1ee6cf5c6ca63413f6f860242c8e (diff) | |
download | FreeBSD-src-6a05792540ffa00713f4b3a1521864f7dddc1f39.zip FreeBSD-src-6a05792540ffa00713f4b3a1521864f7dddc1f39.tar.gz |
network interface and link layer changes:
o on input don't strip the Ethernet header from packets
o input packet handling is now done with if_input
o track changes to ether_ifattach/ether_ifdetach API
o track changes to bpf tapping
o call ether_ioctl for default handling of ioctl's
o use constants from net/ethernet.h where possible
Reviewed by: many
Approved by: re
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/isa/if_cx.c | 6 | ||||
-rw-r--r-- | sys/i386/isa/if_el.c | 26 | ||||
-rw-r--r-- | sys/i386/isa/if_le.c | 37 | ||||
-rw-r--r-- | sys/i386/isa/if_rdp.c | 35 |
4 files changed, 31 insertions, 73 deletions
diff --git a/sys/i386/isa/if_cx.c b/sys/i386/isa/if_cx.c index 392c9a2..b64f978 100644 --- a/sys/i386/isa/if_cx.c +++ b/sys/i386/isa/if_cx.c @@ -476,8 +476,7 @@ cxput (cx_chan_t *c, char b) return; } m_copydata (m, 0, len, buf); - if (c->ifp->if_bpf) - bpf_mtap (c->ifp, m); + BPF_MTAP (c->ifp, m); m_freem (m); /* Start transmitter. */ @@ -802,8 +801,7 @@ cxinput (cx_chan_t *c, void *buf, unsigned len) * Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ - if (c->ifp->if_bpf) - bpf_tap (c->ifp, buf, len); + BPF_TAP (c->ifp, buf, len); /* Count the received bytes to the subchannel, not the master. */ c->master->if_ibytes -= len + 3; diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c index b13f71a..6096549 100644 --- a/sys/i386/isa/if_el.c +++ b/sys/i386/isa/if_el.c @@ -265,7 +265,6 @@ el_attach(device_t dev) ifp->if_unit = device_get_unit(dev);; ifp->if_name = "el"; ifp->if_mtu = ETHERMTU; - ifp->if_output = ether_output; ifp->if_start = el_start; ifp->if_ioctl = el_ioctl; ifp->if_watchdog = el_watchdog; @@ -275,7 +274,7 @@ el_attach(device_t dev) /* Now we can attach the interface */ dprintf(("Attaching interface...\n")); - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, sc->arpcom.ac_enaddr); /* Print out some information for the user */ device_printf(dev, "3c501 address %6D\n", @@ -296,7 +295,7 @@ static int el_detach(dev) el_stop(sc); EL_LOCK(sc); - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); bus_teardown_intr(dev, sc->el_irq, sc->el_intrhand); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->el_irq); bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res); @@ -444,8 +443,7 @@ el_start(struct ifnet *ifp) len = max(len,ETHER_MIN_LEN); /* Give the packet to the bpf, if any */ - if(sc->arpcom.ac_if.if_bpf) - bpf_tap(&sc->arpcom.ac_if, sc->el_pktbuf, len); + BPF_TAP(&sc->arpcom.ac_if, sc->el_pktbuf, len); /* Transfer datagram to board */ dprintf(("el: xfr pkt length=%d...\n",len)); @@ -528,19 +526,17 @@ el_xmit(struct el_softc *sc,int len) static __inline void elread(struct el_softc *sc,caddr_t buf,int len) { - register struct ether_header *eh; + struct ifnet *ifp = &sc->arpcom.ac_if; struct mbuf *m; - eh = (struct ether_header *)buf; - /* * Put packet into an mbuf chain */ - m = elget(buf,len,&sc->arpcom.ac_if); + m = elget(buf,len,ifp); if(m == 0) return; - ether_input(&sc->arpcom.ac_if,eh,m); + (*ifp->if_input)(ifp,m); } /* controller interrupt */ @@ -638,7 +634,6 @@ elintr(void *xsc) dprintf(("%6D\n",sc->el_pktbuf,":")); /* Pass data up to upper levels */ - len -= sizeof(struct ether_header); elread(sc,(caddr_t)(sc->el_pktbuf),len); /* Is there another packet? */ @@ -739,12 +734,6 @@ el_ioctl(ifp, command, data) EL_LOCK(sc); switch (command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, command, data); - break; - case SIOCSIFFLAGS: /* * If interface is marked down and it is running, then stop it @@ -763,7 +752,8 @@ el_ioctl(ifp, command, data) } break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); + break; } EL_UNLOCK(sc); return (error); diff --git a/sys/i386/isa/if_le.c b/sys/i386/isa/if_le.c index ed4bdc9..3ed6a96 100644 --- a/sys/i386/isa/if_le.c +++ b/sys/i386/isa/if_le.c @@ -351,13 +351,12 @@ le_attach( sc->le_ac.ac_enaddr, ":"); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_output = ether_output; ifp->if_ioctl = le_ioctl; ifp->if_type = IFT_ETHER; ifp->if_addrlen = 6; ifp->if_hdrlen = 14; - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, sc->le_ac.ac_enaddr); return 1; } @@ -384,37 +383,28 @@ le_input( size_t len1, caddr_t seg2) { - struct ether_header eh; + struct ifnet *ifp = &sc->le_if; struct mbuf *m; - if (total_len - sizeof(eh) > ETHERMTU - || total_len - sizeof(eh) < ETHERMIN) { - sc->le_if.if_ierrors++; - return; - } - MEMCPY(&eh, seg1, sizeof(eh)); - - seg1 += sizeof(eh); total_len -= sizeof(eh); len1 -= sizeof(eh); - MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { - sc->le_if.if_ierrors++; + ifp->if_ierrors++; return; } m->m_pkthdr.len = total_len; - m->m_pkthdr.rcvif = &sc->le_if; + m->m_pkthdr.rcvif = ifp; if (total_len + LE_XTRA > MHLEN /* >= MINCLSIZE */) { MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_free(m); - sc->le_if.if_ierrors++; + ifp->if_ierrors++; return; } } else if (total_len + LE_XTRA > MHLEN && MINCLSIZE == (MHLEN+MLEN)) { MGET(m->m_next, M_DONTWAIT, MT_DATA); if (m->m_next == NULL) { m_free(m); - sc->le_if.if_ierrors++; + ifp->if_ierrors++; return; } m->m_next->m_len = total_len - MHLEN - LE_XTRA; @@ -428,7 +418,8 @@ le_input( MEMCPY(mtod(m, caddr_t), seg1, len1); if (seg2 != NULL) MEMCPY(mtod(m, caddr_t) + len1, seg2, total_len - len1); - ether_input(&sc->le_if, &eh, m); + + (*ifp->if_input)(ifp, m); } static int @@ -446,12 +437,6 @@ le_ioctl( s = splimp(); switch (cmd) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, cmd, data); - break; - case SIOCSIFFLAGS: { sc->if_init(sc); break; @@ -467,7 +452,8 @@ le_ioctl( break; default: { - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } } @@ -1016,8 +1002,7 @@ lemac_start( LE_OUTB(sc, LEMAC_REG_TQ, tx_pg); /* tell chip to transmit this packet */ - if (sc->le_if.if_bpf) - bpf_mtap(&sc->le_if, m); + BPF_MTAP(&sc->le_if, m); m_freem(m); /* free the mbuf */ } diff --git a/sys/i386/isa/if_rdp.c b/sys/i386/isa/if_rdp.c index 45eccf1..574d3e7 100644 --- a/sys/i386/isa/if_rdp.c +++ b/sys/i386/isa/if_rdp.c @@ -602,7 +602,6 @@ rdp_attach(struct isa_device *isa_dev) ifp->if_softc = sc; ifp->if_unit = unit; ifp->if_name = "rdp"; - ifp->if_output = ether_output; ifp->if_start = rdp_start; ifp->if_ioctl = rdp_ioctl; ifp->if_watchdog = rdp_watchdog; @@ -613,7 +612,7 @@ rdp_attach(struct isa_device *isa_dev) /* * Attach the interface */ - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, sc->arpcom.ac_enaddr); } /* @@ -807,9 +806,7 @@ outloop: /* * Tap off here if there is a bpf listener. */ - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - } + BPF_MTAP(ifp, m); m_freem(m); @@ -832,12 +829,6 @@ rdp_ioctl(struct ifnet *ifp, IOCTL_CMD_T command, caddr_t data) switch (command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, command, data); - break; - case SIOCSIFFLAGS: /* * If the interface is marked up and stopped, then start it. @@ -873,7 +864,8 @@ rdp_ioctl(struct ifnet *ifp, IOCTL_CMD_T command, caddr_t data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); + break; } (void) splx(s); return (error); @@ -1097,7 +1089,7 @@ rdp_rint(struct rdp_softc *sc) static void rdp_get_packet(struct rdp_softc *sc, unsigned len) { - struct ether_header *eh; + struct ifnet *ifp = &sc->arpcom.ac_if; struct mbuf *m; u_char *packet_ptr; size_t s; @@ -1106,7 +1098,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) return; - m->m_pkthdr.rcvif = &sc->arpcom.ac_if; + m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; /* @@ -1115,7 +1107,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len) * to the header. The +2 is to compensate for the alignment * fixup below. */ - if ((len + 2) > MHLEN) { + if ((len + ETHER_ALIGN) > MHLEN) { /* Attach an mbuf cluster */ MCLGET(m, M_DONTWAIT); @@ -1130,8 +1122,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len) * The +2 is to longword align the start of the real packet. * This is important for NFS. */ - m->m_data += 2; - eh = mtod(m, struct ether_header *); + m->m_data += ETHER_ALIGN; /* * Get packet, including link layer address, from interface. @@ -1139,7 +1130,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len) outb(sc->baseaddr + lpt_control, Ctrl_LNibRead); outb(sc->baseaddr + lpt_data, RdAddr + MAR); - packet_ptr = (u_char *)eh; + packet_ptr = mtod(m, u_char *); if (sc->slow) for (s = 0; s < len; s++, packet_ptr++) *packet_ptr = RdByteA2(sc); @@ -1151,13 +1142,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len) outb(sc->baseaddr + lpt_control, Ctrl_SelData); WrNib(sc, CMR1, CMR1_RDPAC); - /* - * Remove link layer address. - */ - m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); - m->m_data += sizeof(struct ether_header); - - ether_input(&sc->arpcom.ac_if, eh, m); + (*ifp->if_input)(ifp, m); } /* |