diff options
author | sam <sam@FreeBSD.org> | 2002-11-14 23:49:09 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2002-11-14 23:49:09 +0000 |
commit | 10eb947d277840d02ef35d6c6303b64329d53806 (patch) | |
tree | 372bb632d763ce1dd7c8d223701c4caeb192eea9 /sys/dev | |
parent | ad30a004454fdbce77e4ea74fce4280cee5cf184 (diff) | |
download | FreeBSD-src-10eb947d277840d02ef35d6c6303b64329d53806.zip FreeBSD-src-10eb947d277840d02ef35d6c6303b64329d53806.tar.gz |
o track either_ifattach/ether_ifdetach API changes
o use if_input for input packet processing
o don't strip the Ethernet header for input packets
o use BPF_* macros bpf tapping
o call ether_ioctl to handle default ioctl case
o track vlan changes
Reviewed by: many
Approved by: re
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/dc/if_dc.c | 22 | ||||
-rw-r--r-- | sys/dev/de/if_de.c | 19 | ||||
-rw-r--r-- | sys/dev/sf/if_sf.c | 21 | ||||
-rw-r--r-- | sys/dev/sk/if_sk.c | 22 | ||||
-rw-r--r-- | sys/dev/ti/if_ti.c | 45 | ||||
-rw-r--r-- | sys/dev/vr/if_vr.c | 21 |
6 files changed, 43 insertions, 107 deletions
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 0617e47..7047261 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2262,12 +2262,13 @@ dc_attach(dev) /* * Call MI attach routine. */ - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, eaddr); /* * Tell the upper layer(s) we support long frames. */ ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); + ifp->if_capabilities |= IFCAP_VLAN_MTU; callout_init(&sc->dc_stat_ch, IS_MPSAFE); @@ -2322,7 +2323,7 @@ dc_detach(dev) ifp = &sc->arpcom.ac_if; dc_stop(sc); - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); bus_generic_detach(dev); device_delete_child(dev, sc->dc_miibus); @@ -2609,7 +2610,6 @@ static void dc_rxeof(sc) struct dc_softc *sc; { - struct ether_header *eh; struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; @@ -2708,11 +2708,7 @@ dc_rxeof(sc) } ifp->if_ipackets++; - eh = mtod(m, struct ether_header *); - - /* Remove header from mbuf and pass it on. */ - m_adj(m, sizeof(struct ether_header)); - ether_input(ifp, eh, m); + (*ifp->if_input)(ifp, m); } sc->dc_cdata.dc_rx_prod = i; @@ -3260,8 +3256,7 @@ dc_start(ifp) * If there's a BPF listener, bounce a copy of this frame * to him. */ - if (ifp->if_bpf) - bpf_mtap(ifp, m_head); + BPF_MTAP(ifp, m_head); if (sc->dc_flags & DC_TX_ONE) { ifp->if_flags |= IFF_OACTIVE; @@ -3542,11 +3537,6 @@ dc_ioctl(ifp, command, data) DC_LOCK(sc); switch(command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, command, data); - break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && @@ -3583,7 +3573,7 @@ dc_ioctl(ifp, command, data) #endif break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index dc10916..88280d1 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -3567,8 +3567,7 @@ tulip_rx_intr( #if !defined(TULIP_COPY_RXDATA) ms->m_pkthdr.len = total_len; ms->m_pkthdr.rcvif = ifp; - m_adj(ms, sizeof(struct ether_header)); - ether_input(ifp, &eh, ms); + (*ifp->if_input)(ifp, ms); #else #ifdef BIG_PACKET #error BIG_PACKET is incompatible with TULIP_COPY_RXDATA @@ -3577,8 +3576,7 @@ tulip_rx_intr( m_copydata(ms, 0, total_len, mtod(m0, caddr_t)); m0->m_len = m0->m_pkthdr.len = total_len; m0->m_pkthdr.rcvif = ifp; - m_adj(m0, sizeof(struct ether_header)); - ether_input(ifp, &eh, m0); + (*ifp->if_input)(ifp, m0); m0 = ms; #endif /* ! TULIP_COPY_RXDATA */ } @@ -4334,8 +4332,7 @@ tulip_txput( /* * bounce a copy to the bpf listener, if any. */ - if (sc->tulip_if.if_bpf != NULL) - bpf_mtap(&sc->tulip_if, m); + BPF_MTAP(&sc->tulip_if, m); /* * The descriptors have been filled in. Now get ready @@ -4558,12 +4555,6 @@ tulip_ifioctl( s = splimp(); #endif switch (cmd) { - case SIOCSIFADDR: - case SIOCGIFADDR: { - error = ether_ioctl(ifp, cmd, data); - break; - } - case SIOCSIFFLAGS: { tulip_addr_filter(sc); /* reinit multicast filter */ tulip_init(sc); @@ -4621,7 +4612,7 @@ tulip_ifioctl( } #endif default: { - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } } @@ -4813,7 +4804,7 @@ tulip_attach( tulip_reset(sc); - ether_ifattach(&(sc)->tulip_if, ETHER_BPF_SUPPORTED); + ether_ifattach(&(sc)->tulip_if, sc->tulip_enaddr); ifp->if_snd.ifq_maxlen = ifqmaxlen; } diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index 69e7c1a..a148ba5 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -541,11 +541,6 @@ sf_ioctl(ifp, command, data) SF_LOCK(sc); switch(command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, command, data); - break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && @@ -576,7 +571,7 @@ sf_ioctl(ifp, command, data) error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } @@ -834,7 +829,7 @@ sf_attach(dev) /* * Call MI attach routine. */ - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, sc->arpcom.ac_enaddr); SF_UNLOCK(sc); return(0); @@ -855,7 +850,7 @@ sf_detach(dev) SF_LOCK(sc); ifp = &sc->arpcom.ac_if; - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); sf_stop(sc); bus_generic_detach(dev); @@ -977,7 +972,6 @@ static void sf_rxeof(sc) struct sf_softc *sc; { - struct ether_header *eh; struct mbuf *m; struct ifnet *ifp; struct sf_rx_bufdesc_type0 *desc; @@ -1017,12 +1011,8 @@ sf_rxeof(sc) } m = m0; - eh = mtod(m, struct ether_header *); ifp->if_ipackets++; - - /* Remove header from mbuf and pass it on. */ - m_adj(m, sizeof(struct ether_header)); - ether_input(ifp, eh, m); + (*ifp->if_input)(ifp, m); } csr_write_4(sc, SF_CQ_CONSIDX, @@ -1404,8 +1394,7 @@ sf_start(ifp) * If there's a BPF listener, bounce a copy of this frame * to him. */ - if (ifp->if_bpf) - bpf_mtap(ifp, m_head); + BPF_MTAP(ifp, m_head); SF_INC(i, SF_TX_DLIST_CNT); sc->sf_tx_cnt++; diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 47f0caf..e58d1c4 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -899,10 +899,6 @@ sk_ioctl(ifp, command, data) SK_IF_LOCK(sc_if); switch(command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - error = ether_ioctl(ifp, command, data); - break; case SIOCSIFMTU: if (ifr->ifr_mtu > SK_JUMBO_MTU) error = EINVAL; @@ -945,7 +941,7 @@ sk_ioctl(ifp, command, data) error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } @@ -1174,7 +1170,7 @@ sk_attach_xmac(dev) /* * Call MI attach routine. */ - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, sc_if->arpcom.ac_enaddr); callout_handle_init(&sc_if->sk_tick_ch); /* @@ -1186,7 +1182,7 @@ sk_attach_xmac(dev) printf("skc%d: no PHY found!\n", sc_if->sk_unit); contigfree(sc_if->sk_rdata, sizeof(struct sk_ring_data), M_DEVBUF); - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); SK_UNLOCK(sc); return(ENXIO); } @@ -1398,7 +1394,7 @@ sk_detach_xmac(dev) ifp = &sc_if->arpcom.ac_if; sk_stop(sc_if); - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); bus_generic_detach(dev); if (sc_if->sk_miibus != NULL) device_delete_child(dev, sc_if->sk_miibus); @@ -1520,8 +1516,7 @@ sk_start(ifp) * If there's a BPF listener, bounce a copy of this frame * to him. */ - if (ifp->if_bpf) - bpf_mtap(ifp, m_head); + BPF_MTAP(ifp, m_head); } /* Transmit */ @@ -1576,7 +1571,6 @@ static void sk_rxeof(sc_if) struct sk_if_softc *sc_if; { - struct ether_header *eh; struct mbuf *m; struct ifnet *ifp; struct sk_chain *cur_rx; @@ -1629,11 +1623,7 @@ sk_rxeof(sc_if) } ifp->if_ipackets++; - eh = mtod(m, struct ether_header *); - - /* Remove header from mbuf and pass it on. */ - m_adj(m, sizeof(struct ether_header)); - ether_input(ifp, eh, m); + (*ifp->if_input)(ifp, m); } sc_if->sk_cdata.sk_rx_prod = i; diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index fdaebf0..a384322 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -2127,7 +2127,7 @@ ti_attach(dev) mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE); - sc->arpcom.ac_if.if_capabilities = IFCAP_HWCSUM; + sc->arpcom.ac_if.if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING; sc->arpcom.ac_if.if_capenable = sc->arpcom.ac_if.if_capabilities; /* @@ -2366,7 +2366,7 @@ ti_attach(dev) /* * Call MI attach routine. */ - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, sc->arpcom.ac_enaddr); return(0); fail: @@ -2416,7 +2416,7 @@ ti_detach(dev) TI_LOCK(sc); ifp = &sc->arpcom.ac_if; - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); ti_stop(sc); bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); @@ -2593,9 +2593,6 @@ ti_rxeof(sc) eh = mtod(m, struct ether_header *); m->m_pkthdr.rcvif = ifp; - /* Remove header from mbuf and pass it on. */ - m_adj(m, sizeof(struct ether_header)); - if (ifp->if_hwassist) { m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_DATA_VALID; @@ -2605,15 +2602,12 @@ ti_rxeof(sc) } /* - * If we received a packet with a vlan tag, pass it - * to vlan_input() instead of ether_input(). + * If we received a packet with a vlan tag, + * tag it before passing the packet upward. */ - if (have_tag) { - VLAN_INPUT_TAG(eh, m, vlan_tag); - have_tag = vlan_tag = 0; - continue; - } - ether_input(ifp, eh, m); + if (have_tag) + VLAN_INPUT_TAG(ifp, m, vlan_tag, continue); + (*ifp->if_input)(ifp, m); } /* Only necessary on the Tigon 1. */ @@ -2754,12 +2748,7 @@ ti_encap(sc, m_head, txidx) struct mbuf *m; u_int32_t frag, cur, cnt = 0; u_int16_t csum_flags = 0; - struct ifvlan *ifv = NULL; - - if ((m_head->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) && - m_head->m_pkthdr.rcvif != NULL && - m_head->m_pkthdr.rcvif->if_type == IFT_L2VLAN) - ifv = m_head->m_pkthdr.rcvif->if_softc; + struct m_tag *mtag; m = m_head; cur = frag = *txidx; @@ -2774,6 +2763,9 @@ ti_encap(sc, m_head, txidx) else if (m_head->m_flags & M_FRAG) csum_flags |= TI_BDFLAG_IP_FRAG; } + + mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m); + /* * Start packing the mbufs in this chain into * the fragment pointers. Stop when we run out @@ -2803,9 +2795,9 @@ ti_encap(sc, m_head, txidx) f->ti_len = m->m_len; f->ti_flags = csum_flags; - if (ifv != NULL) { + if (mtag != NULL) { f->ti_flags |= TI_BDFLAG_VLAN_TAG; - f->ti_vlan_tag = ifv->ifv_tag & 0xfff; + f->ti_vlan_tag = VLAN_TAG_VALUE(mtag) & 0xfff; } else { f->ti_vlan_tag = 0; } @@ -2896,8 +2888,7 @@ ti_start(ifp) * If there's a BPF listener, bounce a copy of this frame * to him. */ - if (ifp->if_bpf) - bpf_mtap(ifp, m_head); + BPF_MTAP(ifp, m_head); } /* Transmit */ @@ -3188,10 +3179,6 @@ ti_ioctl(ifp, command, data) TI_LOCK(sc); switch(command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - error = ether_ioctl(ifp, command, data); - break; case SIOCSIFMTU: if (ifr->ifr_mtu > TI_JUMBO_MTU) error = EINVAL; @@ -3254,7 +3241,7 @@ ti_ioctl(ifp, command, data) error = 0; break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 93fdae7..e82b6c7 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -815,7 +815,7 @@ vr_attach(dev) /* * Call MI attach routine. */ - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ether_ifattach(ifp, eaddr); VR_UNLOCK(sc); return(0); @@ -838,7 +838,7 @@ vr_detach(dev) ifp = &sc->arpcom.ac_if; vr_stop(sc); - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); + ether_ifdetach(ifp); bus_generic_detach(dev); device_delete_child(dev, sc->vr_miibus); @@ -974,7 +974,6 @@ static void vr_rxeof(sc) struct vr_softc *sc; { - struct ether_header *eh; struct mbuf *m; struct ifnet *ifp; struct vr_chain_onefrag *cur_rx; @@ -1052,11 +1051,7 @@ vr_rxeof(sc) m = m0; ifp->if_ipackets++; - eh = mtod(m, struct ether_header *); - - /* Remove header from mbuf and pass it on. */ - m_adj(m, sizeof(struct ether_header)); - ether_input(ifp, eh, m); + (*ifp->if_input)(ifp, m); } return; @@ -1390,8 +1385,7 @@ vr_start(ifp) * If there's a BPF listener, bounce a copy of this frame * to him. */ - if (ifp->if_bpf) - bpf_mtap(ifp, cur_tx->vr_mbuf); + BPF_MTAP(ifp, cur_tx->vr_mbuf); VR_TXOWN(cur_tx) = VR_TXSTAT_OWN; VR_SETBIT16(sc, VR_COMMAND, /*VR_CMD_TX_ON|*/VR_CMD_TX_GO); @@ -1576,11 +1570,6 @@ vr_ioctl(ifp, command, data) VR_LOCK(sc); switch(command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, command, data); - break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { vr_init(sc); @@ -1601,7 +1590,7 @@ vr_ioctl(ifp, command, data) error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } |