summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2002-11-14 23:54:55 +0000
committersam <sam@FreeBSD.org>2002-11-14 23:54:55 +0000
commit14c32b5f40c5ee3bd5649c3737f359f7e65e6944 (patch)
tree84eb7252cc6a518796c6bf88903ed6e2d12e7b91
parent10eb947d277840d02ef35d6c6303b64329d53806 (diff)
downloadFreeBSD-src-14c32b5f40c5ee3bd5649c3737f359f7e65e6944.zip
FreeBSD-src-14c32b5f40c5ee3bd5649c3737f359f7e65e6944.tar.gz
network interface driver changes:
o don't strip the Ethernet header from inbound packets; pass packets up the stack intact (required significant changes to some drivers) o reference common definitions in net/ethernet.h (e.g. ETHER_ALIGN) o track ether_ifattach/ether_ifdetach API changes o track bpf changes (use BPF_TAP and BPF_MTAP) o track vlan changes (ifnet capabilities, revised processing scheme, etc.) o use if_input to pass packets "up" o call ether_ioctl for default handling of ioctls Reviewed by: many Approved by: re
-rw-r--r--sys/dev/an/if_an.c23
-rw-r--r--sys/dev/an/if_an_isa.c2
-rw-r--r--sys/dev/an/if_an_pccard.c2
-rw-r--r--sys/dev/an/if_an_pci.c2
-rw-r--r--sys/dev/ar/if_ar.c6
-rw-r--r--sys/dev/awi/awi.c17
-rw-r--r--sys/dev/awi/if_awi_pccard.c2
-rw-r--r--sys/dev/bge/if_bge.c44
-rw-r--r--sys/dev/bge/if_bgereg.h11
-rw-r--r--sys/dev/cm/smc90cx6.c3
-rw-r--r--sys/dev/cnw/if_cnw.c15
-rw-r--r--sys/dev/cs/if_cs.c24
-rw-r--r--sys/dev/ed/if_ed.c30
-rw-r--r--sys/dev/ed/if_ed_pccard.c2
-rw-r--r--sys/dev/em/if_em.c35
-rw-r--r--sys/dev/em/if_em.h2
-rw-r--r--sys/dev/en/midway.c1
-rw-r--r--sys/dev/ep/if_ep.c19
-rw-r--r--sys/dev/ep/if_ep_pccard.c2
-rw-r--r--sys/dev/ex/if_ex.c9
-rw-r--r--sys/dev/fe/if_fe.c26
-rw-r--r--sys/dev/fe/if_fe_pccard.c2
-rw-r--r--sys/dev/firewire/if_fwe.c26
-rw-r--r--sys/dev/fxp/if_fxp.c20
-rw-r--r--sys/dev/gem/if_gem.c8
-rw-r--r--sys/dev/gx/if_gx.c41
-rw-r--r--sys/dev/gx/if_gxvar.h2
-rw-r--r--sys/dev/hme/if_hme.c17
-rw-r--r--sys/dev/ie/if_ie.c81
-rw-r--r--sys/dev/iicbus/if_ic.c5
-rw-r--r--sys/dev/lge/if_lge.c20
-rw-r--r--sys/dev/lge/if_lgereg.h1
-rw-r--r--sys/dev/lnc/if_lnc.c42
-rw-r--r--sys/dev/lnc/if_lnc_cbus.c2
-rw-r--r--sys/dev/lnc/if_lnc_isa.c2
-rw-r--r--sys/dev/lnc/if_lnc_pci.c2
-rw-r--r--sys/dev/my/if_my.c20
-rw-r--r--sys/dev/nge/if_nge.c40
-rw-r--r--sys/dev/nge/if_ngereg.h1
-rw-r--r--sys/dev/pdq/pdq_ifsubr.c12
-rw-r--r--sys/dev/ppbus/if_plip.c2
-rw-r--r--sys/dev/ray/if_ray.c23
-rw-r--r--sys/dev/sbni/if_sbni.c22
-rw-r--r--sys/dev/sn/if_sn.c25
-rw-r--r--sys/dev/snc/dp83932.c19
-rw-r--r--sys/dev/sr/if_sr.c6
-rw-r--r--sys/dev/tx/if_tx.c22
-rw-r--r--sys/dev/txp/if_txp.c40
-rw-r--r--sys/dev/usb/if_aue.c14
-rw-r--r--sys/dev/usb/if_auereg.h1
-rw-r--r--sys/dev/usb/if_cue.c14
-rw-r--r--sys/dev/usb/if_cuereg.h1
-rw-r--r--sys/dev/usb/if_kue.c14
-rw-r--r--sys/dev/usb/if_kuereg.h1
-rw-r--r--sys/dev/usb/usb_ethersubr.c5
-rw-r--r--sys/dev/vx/if_vx.c17
-rw-r--r--sys/dev/wi/if_wi.c21
-rw-r--r--sys/dev/wl/if_wl.c154
-rw-r--r--sys/dev/xe/if_xe.c22
-rw-r--r--sys/dev/xe/if_xe_pccard.c2
60 files changed, 352 insertions, 694 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c
index caecdbf..cada570 100644
--- a/sys/dev/an/if_an.c
+++ b/sys/dev/an/if_an.c
@@ -190,6 +190,10 @@ static char an_conf[256];
/* sysctl vars */
SYSCTL_NODE(_machdep, OID_AUTO, an, CTLFLAG_RD, 0, "dump RID");
+/* XXX violate ethernet/netgraph callback hooks */
+extern void (*ng_ether_attach_p)(struct ifnet *ifp);
+extern void (*ng_ether_detach_p)(struct ifnet *ifp);
+
static int
sysctl_an_dump(SYSCTL_HANDLER_ARGS)
{
@@ -499,7 +503,7 @@ an_attach(sc, unit, flags)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
callout_handle_init(&sc->an_stat_ch);
AN_UNLOCK(sc);
@@ -592,9 +596,7 @@ an_rxeof(sc)
rx_frame.an_rx_payload_len);
}
/* dump raw 802.11 packet to bpf and skip ip stack */
- if (ifp->if_bpf != NULL) {
- bpf_tap(ifp, bpf_buf, len);
- }
+ BPF_TAP(ifp, bpf_buf, len);
} else {
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
@@ -654,11 +656,10 @@ an_rxeof(sc)
ifp->if_ipackets++;
/* Receive packet. */
- m_adj(m, sizeof(struct ether_header));
#ifdef ANCACHE
an_cache_store(sc, eh, m, rx_frame.an_rx_signal_strength);
#endif
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
}
@@ -1293,11 +1294,6 @@ an_ioctl(ifp, command, data)
}
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 &&
@@ -1809,7 +1805,7 @@ an_ioctl(ifp, command, data)
an_setdef(sc, &sc->areq);
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
out:
@@ -2021,8 +2017,7 @@ an_start(ifp)
* If there's a BPF listner, bounce a copy of
* this frame to him.
*/
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ BPF_MTAP(ifp, m0);
m_freem(m0);
m0 = NULL;
diff --git a/sys/dev/an/if_an_isa.c b/sys/dev/an/if_an_isa.c
index db879a5..45fc3b5 100644
--- a/sys/dev/an/if_an_isa.c
+++ b/sys/dev/an/if_an_isa.c
@@ -140,7 +140,7 @@ an_detach_isa(device_t dev)
an_stop(sc);
ifmedia_removeall(&sc->an_ifmedia);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);
diff --git a/sys/dev/an/if_an_pccard.c b/sys/dev/an/if_an_pccard.c
index 3cd9223..ddc827a 100644
--- a/sys/dev/an/if_an_pccard.c
+++ b/sys/dev/an/if_an_pccard.c
@@ -144,7 +144,7 @@ an_pccard_detach(device_t dev)
an_stop(sc);
ifmedia_removeall(&sc->an_ifmedia);
ifp->if_flags &= ~IFF_RUNNING;
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
sc->an_gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);
diff --git a/sys/dev/an/if_an_pci.c b/sys/dev/an/if_an_pci.c
index f1e320a..b1aa0f3 100644
--- a/sys/dev/an/if_an_pci.c
+++ b/sys/dev/an/if_an_pci.c
@@ -202,7 +202,7 @@ an_detach_pci(device_t dev)
an_stop(sc);
ifmedia_removeall(&sc->an_ifmedia);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);
diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c
index 31ddf03..0c09885 100644
--- a/sys/dev/ar/if_ar.c
+++ b/sys/dev/ar/if_ar.c
@@ -700,8 +700,7 @@ top_arstart:
i++;
#ifndef NETGRAPH
- if(ifp->if_bpf)
- bpf_mtap(ifp, mtx);
+ BPF_MTAP(ifp, mtx);
m_freem(mtx);
++sc->ifsppp.pp_if.if_opackets;
#else /* NETGRAPH */
@@ -1703,8 +1702,7 @@ ar_get_packets(struct ar_softc *sc)
}
ar_copy_rxbuf(m, sc, len);
#ifndef NETGRAPH
- if(sc->ifsppp.pp_if.if_bpf)
- bpf_mtap(&sc->ifsppp.pp_if, m);
+ BPF_MTAP(&sc->ifsppp.pp_if, m);
sppp_input(&sc->ifsppp.pp_if, m);
sc->ifsppp.pp_if.if_ipackets++;
#else /* NETGRAPH */
diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c
index ca4de35..3718198 100644
--- a/sys/dev/awi/awi.c
+++ b/sys/dev/awi/awi.c
@@ -217,8 +217,8 @@ int awi_dump_len = 28;
#define AWI_BPF_RAW 1
#ifdef __FreeBSD__
#define AWI_BPF_MTAP(sc, m, raw) do { \
- if ((sc)->sc_ifp->if_bpf && (sc)->sc_rawbpf == (raw)) \
- bpf_mtap((sc)->sc_ifp, (m)); \
+ if ((sc)->sc_rawbpf == (raw)) \
+ BPF_MTAP((sc)->sc_ifp, (m)); \
} while (0);
#else
#define AWI_BPF_MTAP(sc, m, raw) do { \
@@ -239,6 +239,7 @@ int awi_dump_len = 28;
devclass_t awi_devclass;
#endif
+#if __FreeBSD_version < 500043
/* NetBSD compatible functions */
static char * ether_sprintf(u_int8_t *);
@@ -252,6 +253,7 @@ ether_sprintf(enaddr)
return strbuf;
}
#endif
+#endif
int
awi_attach(sc)
@@ -317,7 +319,7 @@ awi_attach(sc)
printf("%s: address %s\n",
sc->sc_dev.dv_xname, ether_sprintf(sc->sc_mib_addr.aMAC_Address));
#ifdef __FreeBSD__
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->sc_mib_addr.aMAC_Address);
#else
if_attach(ifp);
ether_ifattach(ifp, sc->sc_mib_addr.aMAC_Address);
@@ -1370,9 +1372,6 @@ awi_input(sc, m, rxts, rssi)
{
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211_frame *wh;
-#ifndef __NetBSD__
- struct ether_header *eh;
-#endif
/* trim CRC here for WEP can find its own CRC at the end of packet. */
m_adj(m, -ETHER_CRC_LEN);
@@ -1430,13 +1429,7 @@ awi_input(sc, m, rxts, rssi)
#if !(defined(__FreeBSD__) && __FreeBSD_version >= 400000)
AWI_BPF_MTAP(sc, m, AWI_BPF_NORM);
#endif
-#ifdef __NetBSD__
(*ifp->if_input)(ifp, m);
-#else
- eh = mtod(m, struct ether_header *);
- m_adj(m, sizeof(*eh));
- ether_input(ifp, eh, m);
-#endif
break;
case IEEE80211_FC0_TYPE_MGT:
if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) !=
diff --git a/sys/dev/awi/if_awi_pccard.c b/sys/dev/awi/if_awi_pccard.c
index d39b613..08749f5 100644
--- a/sys/dev/awi/if_awi_pccard.c
+++ b/sys/dev/awi/if_awi_pccard.c
@@ -234,7 +234,7 @@ awi_pccard_detach(device_t dev)
struct awi_softc *sc = &psc->sc_awi;
struct ifnet *ifp = &sc->sc_ec.ac_if;
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
ifp->if_flags &= ~IFF_RUNNING;
if (psc->sc_intrhand) {
bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand);
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 3c50cc5..62e24ab 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -1594,7 +1594,7 @@ bge_attach(dev)
ifp->if_mtu = ETHERMTU;
ifp->if_snd.ifq_maxlen = BGE_TX_RING_CNT - 1;
ifp->if_hwassist = BGE_CSUM_FEATURES;
- ifp->if_capabilities = IFCAP_HWCSUM;
+ ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
ifp->if_capenable = ifp->if_capabilities;
/* Save ASIC rev. */
@@ -1669,7 +1669,7 @@ bge_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
callout_handle_init(&sc->bge_stat_ch);
fail:
@@ -1691,7 +1691,7 @@ bge_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bge_stop(sc);
bge_reset(sc);
@@ -1913,9 +1913,6 @@ bge_rxeof(sc)
m->m_pkthdr.len = m->m_len = cur_rx->bge_len;
m->m_pkthdr.rcvif = ifp;
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
-
#if 0 /* currently broken for some packets, possibly related to TCP options */
if (ifp->if_hwassist) {
m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
@@ -1930,16 +1927,13 @@ bge_rxeof(sc)
#endif
/*
- * 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,
+ * attach that information to the packet.
*/
- if (have_tag) {
- VLAN_INPUT_TAG(eh, m, vlan_tag);
- have_tag = vlan_tag = 0;
- continue;
- }
+ if (have_tag)
+ VLAN_INPUT_TAG(ifp, m, vlan_tag, continue);
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
CSR_WRITE_4(sc, BGE_MBX_RX_CONS0_LO, sc->bge_rx_saved_considx);
@@ -2164,12 +2158,7 @@ bge_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;
@@ -2185,6 +2174,8 @@ bge_encap(sc, m_head, txidx)
csum_flags |= BGE_TXBDFLAG_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
@@ -2199,9 +2190,9 @@ bge_encap(sc, m_head, txidx)
vtophys(mtod(m, vm_offset_t));
f->bge_len = m->m_len;
f->bge_flags = csum_flags;
- if (ifv != NULL) {
+ if (mtag != NULL) {
f->bge_flags |= BGE_TXBDFLAG_VLAN_TAG;
- f->bge_vlan_tag = ifv->ifv_tag;
+ f->bge_vlan_tag = VLAN_TAG_VALUE(mtag);
} else {
f->bge_vlan_tag = 0;
}
@@ -2289,8 +2280,7 @@ bge_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 */
@@ -2538,10 +2528,6 @@ bge_ioctl(ifp, command, data)
s = splimp();
switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFMTU:
if (ifr->ifr_mtu > BGE_JUMBO_MTU)
error = EINVAL;
@@ -2610,7 +2596,7 @@ bge_ioctl(ifp, command, data)
error = 0;
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
diff --git a/sys/dev/bge/if_bgereg.h b/sys/dev/bge/if_bgereg.h
index 3dca979..6c35574 100644
--- a/sys/dev/bge/if_bgereg.h
+++ b/sys/dev/bge/if_bgereg.h
@@ -1986,17 +1986,6 @@ struct bge_gib {
struct bge_rcb bge_return_rcb;
};
-/*
- * NOTE! On the Alpha, we have an alignment constraint.
- * The first thing in the packet is a 14-byte Ethernet header.
- * This means that the packet is misaligned. To compensate,
- * we actually offset the data 2 bytes into the cluster. This
- * alignes the packet after the Ethernet header at a 32-bit
- * boundary.
- */
-
-#define ETHER_ALIGN 2
-
#define BGE_FRAMELEN 1518
#define BGE_MAX_FRAMELEN 1536
#define BGE_JUMBO_FRAMELEN 9018
diff --git a/sys/dev/cm/smc90cx6.c b/sys/dev/cm/smc90cx6.c
index 5cf3ea9..c12b016 100644
--- a/sys/dev/cm/smc90cx6.c
+++ b/sys/dev/cm/smc90cx6.c
@@ -519,8 +519,7 @@ cm_start(ifp)
* (can't give the copy in A2060 card RAM to bpf, because
* that RAM is just accessed as on every other byte)
*/
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
#ifdef CM_DEBUG
if (m->m_len < ARC_HDRLEN)
diff --git a/sys/dev/cnw/if_cnw.c b/sys/dev/cnw/if_cnw.c
index 80ebef5..84bdced 100644
--- a/sys/dev/cnw/if_cnw.c
+++ b/sys/dev/cnw/if_cnw.c
@@ -850,8 +850,7 @@ cnw_start(ifp)
bpf_mtap(ifp->if_bpf, m0);
#endif
#else /* FreeBSD */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ BPF_MTAP(ifp, m0);
#endif
cnw_transmit(sc, m0);
@@ -1024,7 +1023,6 @@ cnw_recv(sc)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else
struct ifnet *ifp = &sc->arpcom.ac_if;
- struct ether_header *eh;
#endif
struct mbuf *m;
@@ -1053,19 +1051,10 @@ cnw_recv(sc)
if (ifp->if_bpf)
bpf_mtap(ifp->if_bpf, m);
#endif
-#else /* FreeBSD */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
#endif
/* Pass the packet up. */
-#if !defined(__FreeBSD__)
(*ifp->if_input)(ifp, m);
-#else
- eh = mtod(m, struct ether_header *);
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m) ;
-#endif
}
}
@@ -1660,7 +1649,7 @@ static int cnw_pccard_attach(device_t dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/* callout_handle_init(&sc->cnw_stat_ch); */
return(0);
diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c
index b1508e5..bffccf9 100644
--- a/sys/dev/cs/if_cs.c
+++ b/sys/dev/cs/if_cs.c
@@ -657,7 +657,7 @@ cs_attach(struct cs_softc *sc, int unit, int flags)
ifmedia_set(&sc->media, media);
cs_mediaset(sc, media);
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
if (bootverbose)
@@ -750,8 +750,7 @@ cs_init(void *xsc)
}
/*
- * Get the packet from the board and send it to the upper layer
- * via ether_input().
+ * Get the packet from the board and send it to the upper layer.
*/
static int
cs_get_packet(struct cs_softc *sc)
@@ -811,12 +810,8 @@ cs_get_packet(struct cs_softc *sc)
if (status & (RX_IA | RX_BROADCAST) ||
(ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) {
- m->m_pkthdr.len -= sizeof(struct ether_header);
- m->m_len -= sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
-
/* Feed the packet to the upper layer */
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
ifp->if_ipackets++;
@@ -961,9 +956,7 @@ cs_start(struct ifnet *ifp)
cs_write_mbufs(sc, m);
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- }
+ BPF_MTAP(ifp, m);
m_freem(m);
}
@@ -1085,12 +1078,6 @@ cs_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
s=splimp();
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
* Switch interface state between "running" and
@@ -1132,7 +1119,8 @@ cs_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
break;
default:
- error = EINVAL;
+ ether_ioctl(ifp, command, data);
+ break;
}
(void) splx(s);
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 118ff28..5ad04e3 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -1642,7 +1642,7 @@ ed_attach(sc, unit, flags)
/*
* Attach the interface
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
/* device attach does transition from UNCONFIGURED to IDLE state */
@@ -2127,9 +2127,7 @@ outloop:
/*
* Tap off here if there is a bpf listener.
*/
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m0);
- }
+ BPF_MTAP(ifp, m0);
m_freem(m0);
@@ -2565,13 +2563,6 @@ ed_ioctl(ifp, command, data)
s = splimp();
switch (command) {
-
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
@@ -2631,7 +2622,7 @@ ed_ioctl(ifp, command, data)
#endif
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
}
(void) splx(s);
return (error);
@@ -2683,6 +2674,7 @@ ed_get_packet(sc, buf, len)
char *buf;
u_short len;
{
+ struct ifnet *ifp = &sc->arpcom.ac_if;
struct ether_header *eh;
struct mbuf *m;
@@ -2690,7 +2682,7 @@ ed_get_packet(sc, buf, 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;
/*
@@ -2721,11 +2713,11 @@ ed_get_packet(sc, buf, len)
* Don't read in the entire packet if we know we're going to drop it
* and no bpf is active.
*/
- if (!sc->arpcom.ac_if.if_bpf && BDG_ACTIVE( (&sc->arpcom.ac_if) ) ) {
+ if (!ifp->if_bpf && BDG_ACTIVE( (ifp) ) ) {
struct ifnet *bif;
ed_ring_copy(sc, buf, (char *)eh, ETHER_HDR_LEN);
- bif = bridge_in_ptr(&sc->arpcom.ac_if, eh) ;
+ bif = bridge_in_ptr(ifp, eh) ;
if (bif == BDG_DROP) {
m_freem(m);
return;
@@ -2739,13 +2731,9 @@ ed_get_packet(sc, buf, len)
*/
ed_ring_copy(sc, buf, (char *)eh, len);
- /*
- * Remove link layer address.
- */
- m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
+ m->m_pkthdr.len = m->m_len = len;
- ether_input(&sc->arpcom.ac_if, eh, m);
+ (*ifp->if_input)(ifp, m);
}
/*
diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c
index 4f915ee..06737af 100644
--- a/sys/dev/ed/if_ed_pccard.c
+++ b/sys/dev/ed/if_ed_pccard.c
@@ -106,7 +106,7 @@ ed_pccard_detach(device_t dev)
}
ed_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
ed_release_resources(dev);
diff --git a/sys/dev/em/if_em.c b/sys/dev/em/if_em.c
index 1915e91..ecbea9a 100644
--- a/sys/dev/em/if_em.c
+++ b/sys/dev/em/if_em.c
@@ -398,7 +398,7 @@ em_detach(device_t dev)
em_stop(adapter);
em_phy_hw_reset(&adapter->hw);
- ether_ifdetach(&adapter->interface_data.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&adapter->interface_data.ac_if);
em_free_pci_resources(adapter);
size = EM_ROUNDUP(adapter->num_tx_desc *
@@ -482,8 +482,7 @@ em_start(struct ifnet *ifp)
}
/* Send a copy of the frame to the BPF listener */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m_head);
+ BPF_MTAP(ifp, m_head);
/* Set timeout in case hardware has problems transmitting */
ifp->if_timer = EM_TX_TIMEOUT;
@@ -876,11 +875,11 @@ em_encap(struct adapter *adapter, struct mbuf *m_head)
u_int16_t txd_used, count;
struct mbuf *mp;
- struct ifvlan *ifv = NULL;
struct em_tx_buffer *tx_buffer;
struct em_tx_desc *saved_tx_desc = NULL;
struct em_tx_desc *current_tx_desc = NULL;
struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct m_tag *mtag;
/* Force a cleanup if number of descriptors available hit the threshold */
if (adapter->num_tx_desc_avail <= EM_TX_CLEANUP_THRESHOLD)
@@ -922,11 +921,7 @@ em_encap(struct adapter *adapter, struct mbuf *m_head)
}
/* Find out if we are in vlan mode */
- 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;
-
+ mtag = VLAN_OUTPUT_TAG(ifp, m_head);
txd_used = 0;
saved_tx_desc = adapter->next_avail_tx_desc;
@@ -964,12 +959,12 @@ em_encap(struct adapter *adapter, struct mbuf *m_head)
}
adapter->num_tx_desc_avail-= txd_used;
- if (ifv != NULL) {
+ if (mtag != NULL) {
/* Tell hardware to add tag */
current_tx_desc->lower.data |= E1000_TXD_CMD_VLE;
/* Set the vlan id */
- current_tx_desc->upper.fields.special = ifv->ifv_tag;
+ current_tx_desc->upper.fields.special = VLAN_TAG_VALUE(mtag);
}
/* Last Descriptor of Packet needs End Of Packet (EOP) bit set. */
@@ -1376,12 +1371,13 @@ em_setup_interface(device_t dev, struct adapter * adapter)
ifp->if_start = em_start;
ifp->if_watchdog = em_watchdog;
ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1;
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, adapter->interface_data.ac_enaddr);
if (adapter->hw.mac_type >= em_82543) {
ifp->if_capabilities = IFCAP_HWCSUM;
ifp->if_capenable = ifp->if_capabilities;
}
+ ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
/*
* Specify the media types supported by this adapter and register
@@ -2001,7 +1997,6 @@ em_process_receive_interrupts(struct adapter * adapter)
{
struct mbuf *mp;
struct ifnet *ifp;
- struct ether_header *eh;
u_int16_t len;
u_int8_t last_byte;
u_int8_t accept_frame = 0;
@@ -2096,18 +2091,14 @@ em_process_receive_interrupts(struct adapter * adapter)
if (eop) {
adapter->fmp->m_pkthdr.rcvif = ifp;
-
- eh = mtod(adapter->fmp, struct ether_header *);
-
- /* Remove ethernet header from mbuf */
- m_adj(adapter->fmp, sizeof(struct ether_header));
em_receive_checksum(adapter, current_desc,
adapter->fmp);
if (current_desc->status & E1000_RXD_STAT_VP)
- VLAN_INPUT_TAG(eh, adapter->fmp,
- current_desc->special);
- else
- ether_input(ifp, eh, adapter->fmp);
+ VLAN_INPUT_TAG(ifp, adapter->fmp,
+ current_desc->special,
+ adapter->fmp = NULL);
+ if (adapter->fmp != NULL)
+ (*ifp->if_input)(ifp, adapter->fmp);
adapter->fmp = NULL;
adapter->lmp = NULL;
diff --git a/sys/dev/em/if_em.h b/sys/dev/em/if_em.h
index d280837..370e891 100644
--- a/sys/dev/em/if_em.h
+++ b/sys/dev/em/if_em.h
@@ -207,7 +207,9 @@ POSSIBILITY OF SUCH DAMAGE.
#define IOCTL_CMD_TYPE u_long
#define MAX_NUM_MULTICAST_ADDRESSES 128
#define PCI_ANY_ID (~0U)
+#ifndef ETHER_ALIGN
#define ETHER_ALIGN 2
+#endif
#define QTAG_TYPE 0x8100
/* Defines for printing debug information */
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c
index 606d971..915fd14 100644
--- a/sys/dev/en/midway.c
+++ b/sys/dev/en/midway.c
@@ -176,7 +176,6 @@
#include <net/bpf.h>
#ifdef __FreeBSD__
#define BPFATTACH(ifp, dlt, hlen) bpfattach((ifp), (dlt), (hlen))
-#define BPF_MTAP(ifp, m) bpf_mtap((ifp), (m))
#else
#define BPFATTACH(ifp, dlt, hlen) bpfattach(&(ifp)->if_bpf, (ifp), (dlt), (hlen))
#define BPF_MTAP(ifp, m) bpf_mtap((ifp)->if_bpf, (m))
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c
index e0a6795..749fa58 100644
--- a/sys/dev/ep/if_ep.c
+++ b/sys/dev/ep/if_ep.c
@@ -311,7 +311,7 @@ ep_attach(sc)
}
if (!attached)
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
#ifdef EP_LOCAL_STATS
sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =
@@ -509,9 +509,7 @@ startagain:
splx(s);
- if (ifp->if_bpf) {
- bpf_mtap(ifp, top);
- }
+ BPF_MTAP(ifp, top);
ifp->if_timer = 2;
ifp->if_opackets++;
@@ -657,7 +655,6 @@ static void
epread(sc)
register struct ep_softc *sc;
{
- struct ether_header *eh;
struct mbuf *top, *mcur, *m;
struct ifnet *ifp;
int lenthisone;
@@ -765,9 +762,7 @@ read_again:
top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
top->m_pkthdr.len = sc->cur_len;
- eh = mtod(top, struct ether_header *);
- m_adj(top, sizeof(struct ether_header));
- ether_input(ifp, eh, top);
+ (*ifp->if_input)(ifp, top);
sc->top = 0;
while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
@@ -857,12 +852,6 @@ ep_if_ioctl(ifp, cmd, data)
s = splimp();
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
-
case SIOCSIFFLAGS:
if (((ifp->if_flags & IFF_UP) == 0) &&
(ifp->if_flags & IFF_RUNNING)) {
@@ -899,7 +888,7 @@ ep_if_ioctl(ifp, cmd, data)
}
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, cmd, data);
break;
}
diff --git a/sys/dev/ep/if_ep_pccard.c b/sys/dev/ep/if_ep_pccard.c
index 997f4a7..8406f16 100644
--- a/sys/dev/ep/if_ep_pccard.c
+++ b/sys/dev/ep/if_ep_pccard.c
@@ -233,7 +233,7 @@ ep_pccard_detach(device_t dev)
return (0);
}
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq, sc->ep_intrhand);
ep_free(dev);
diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c
index f457a40..f7458af 100644
--- a/sys/dev/ex/if_ex.c
+++ b/sys/dev/ex/if_ex.c
@@ -262,7 +262,7 @@ ex_attach(device_t dev)
/*
* Attach the interface.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
device_printf(sc->dev, "Ethernet address %6D\n",
sc->arpcom.ac_enaddr, ":");
@@ -523,9 +523,7 @@ ex_start(struct ifnet *ifp)
sc->tx_last = dest;
sc->tx_tail = next;
- if (ifp->if_bpf != NULL) {
- bpf_mtap(ifp, opkt);
- }
+ BPF_MTAP(ifp, opkt);
ifp->if_timer = 2;
ifp->if_opackets++;
@@ -752,8 +750,7 @@ ex_rx_intr(struct ex_softc *sc)
} /* QQQ */
}
#endif
- m_adj(ipkt, sizeof(struct ether_header));
- ether_input(ifp, eh, ipkt);
+ (*ifp->if_input)(ifp, ipkt);
ifp->if_ipackets++;
}
} else {
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
index 1cbce78..b6ad14c 100644
--- a/sys/dev/fe/if_fe.c
+++ b/sys/dev/fe/if_fe.c
@@ -816,7 +816,7 @@ fe_attach (device_t dev)
#endif
/* Attach and stop the interface. */
- ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED);
+ ether_ifattach(&sc->sc_if, sc->arpcom.ac_enaddr);
fe_stop(sc);
/* Print additional info when attached. */
@@ -1281,9 +1281,8 @@ fe_start (struct ifnet *ifp)
* and only if it is in "receive everything"
* mode.)
*/
- if (sc->sc_if.if_bpf &&
- !(sc->sc_if.if_flags & IFF_PROMISC))
- bpf_mtap(&sc->sc_if, m);
+ if (!(sc->sc_if.if_flags & IFF_PROMISC))
+ BPF_MTAP(&sc->sc_if, m);
m_freem(m);
}
@@ -1757,13 +1756,6 @@ fe_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- /* Just an ordinary action. */
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
* Switch interface state between "running" and
@@ -1803,7 +1795,7 @@ fe_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
@@ -1819,6 +1811,7 @@ fe_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
static int
fe_get_packet (struct fe_softc * sc, u_short len)
{
+ struct ifnet *ifp = &sc->sc_if;
struct ether_header *eh;
struct mbuf *m;
@@ -1868,7 +1861,7 @@ fe_get_packet (struct fe_softc * sc, u_short len)
}
/* Initialize packet header info. */
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = len;
/* Set the length of this packet. */
@@ -1890,13 +1883,8 @@ fe_get_packet (struct fe_softc * sc, u_short len)
fe_insw(sc, FE_BMPR8, (u_int16_t *)eh, (len + 1) >> 1);
}
- /* Strip off the Ethernet header. */
- m->m_pkthdr.len -= sizeof (struct ether_header);
- m->m_len -= sizeof (struct ether_header);
- m->m_data += sizeof (struct ether_header);
-
/* Feed the packet to upper layer. */
- ether_input(&sc->sc_if, eh, m);
+ (*ifp->if_input)(ifp, m);
return 0;
}
diff --git a/sys/dev/fe/if_fe_pccard.c b/sys/dev/fe/if_fe_pccard.c
index 0fc1f8d..f4f1ada 100644
--- a/sys/dev/fe/if_fe_pccard.c
+++ b/sys/dev/fe/if_fe_pccard.c
@@ -174,7 +174,7 @@ fe_pccard_detach(device_t dev)
struct ifnet *ifp = &sc->arpcom.ac_if;
fe_stop(sc);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
fe_release_resource(dev);
diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c
index 2561a40..5433bb9 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -192,11 +192,12 @@ fwe_attach(device_t dev)
ifp->if_snd.ifq_maxlen = FWMAXQUEUE - 1;
s = splimp();
- ether_ifattach(ifp, 1);
+ ether_ifattach(ifp, eaddr);
splx(s);
/* 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;
ifp->if_snd.ifq_maxlen = MAX_QUEUED - 1;
@@ -239,7 +240,7 @@ fwe_detach(device_t dev)
s = splimp();
fwe_stop(fwe);
- ether_ifdetach(&fwe->fwe_if, 1);
+ ether_ifdetach(&fwe->fwe_if);
splx(s);
return 0;
@@ -311,13 +312,6 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
int s, error, len;
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- s = splimp();
- error = ether_ioctl(ifp, cmd, data);
- splx(s);
- return (error);
case SIOCSIFFLAGS:
s = splimp();
if (ifp->if_flags & IFF_UP) {
@@ -348,7 +342,10 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
default:
- return (EINVAL);
+ s = splimp();
+ error = ether_ioctl(ifp, cmd, data);
+ splx(s);
+ return (error);
}
return (0);
@@ -434,8 +431,7 @@ fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp)
if (xfer == NULL) {
return;
}
- if (ifp->if_bpf != NULL)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
xfer->send.off = 0;
xfer->spd = 2;
@@ -543,9 +539,7 @@ fwe_as_input(struct fw_xferq *xferq)
#endif
p = xfer->recv.buf + xfer->recv.off + HDR_LEN + ALIGN_PAD;
eh = (struct ether_header *)p;
- p += sizeof(struct ether_header);
- len -= xfer->recv.off + HDR_LEN + ALIGN_PAD
- + sizeof(struct ether_header);
+ len -= xfer->recv.off + HDR_LEN + ALIGN_PAD;
m->m_data = p;
m->m_len = m->m_pkthdr.len = len;
m->m_pkthdr.rcvif = ifp;
@@ -565,7 +559,7 @@ fwe_as_input(struct fw_xferq *xferq)
c[20], c[21], c[22], c[23]
);
#endif
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
ifp->if_ipackets ++;
xfer->recv.buf = NULL;
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
index 9befadb..5b7e249 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -646,12 +646,13 @@ fxp_attach(device_t dev)
/*
* Attach the interface.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/*
* 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;
/*
* Let the system queue as many packets as we have available
@@ -725,7 +726,7 @@ fxp_detach(device_t dev)
/*
* Close down routes etc.
*/
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
/*
* Free all media structures.
@@ -1138,8 +1139,7 @@ tbdinit:
/*
* Pass packet to bpf if there is a listener.
*/
- if (ifp->if_bpf)
- bpf_mtap(ifp, mb_head);
+ BPF_MTAP(ifp, mb_head);
}
/*
@@ -1352,7 +1352,9 @@ fxp_intr_body(struct fxp_softc *sc, u_int8_t statack, int count)
}
m->m_pkthdr.len = m->m_len = total_len;
- ether_input(ifp, NULL, m);
+ m->m_pkthdr.rcvif = ifp;
+
+ (*ifp->if_input)(ifp, m);
}
}
if (rnr) {
@@ -1974,12 +1976,6 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
s = splimp();
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_ALLMULTI)
sc->flags |= FXP_FLAG_ALL_MCAST;
@@ -2033,7 +2029,7 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
}
splx(s);
return (error);
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
index c702ed6..3ed01dc 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -299,7 +299,7 @@ gem_attach(sc)
bus_space_write_4(sc->sc_bustag, sc->sc_h, GEM_MIF_CONFIG,
sc->sc_mif_config);
/* Attach the interface. */
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
#if notyet
/*
@@ -1546,13 +1546,11 @@ gem_rint(sc)
}
m->m_data += 2; /* We're already off by two */
- eh = mtod(m, struct ether_header *);
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = len - ETHER_CRC_LEN;
- m_adj(m, sizeof(struct ether_header));
/* Pass it on. */
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
if (progress) {
@@ -1952,7 +1950,7 @@ gem_ioctl(ifp, cmd, data)
error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii->mii_media, cmd);
break;
default:
- error = ENOTTY;
+ error = ENOTTY; /* XXX EINVAL??? */
break;
}
diff --git a/sys/dev/gx/if_gx.c b/sys/dev/gx/if_gx.c
index e6e00b9..8d59cd6 100644
--- a/sys/dev/gx/if_gx.c
+++ b/sys/dev/gx/if_gx.c
@@ -348,6 +348,7 @@ gx_attach(device_t dev)
ifp->if_init = gx_init;
ifp->if_mtu = ETHERMTU;
ifp->if_snd.ifq_maxlen = GX_TX_RING_CNT - 1;
+ ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
/* see if we can enable hardware checksumming */
if (gx->gx_vflags & GXF_CSUM) {
@@ -382,7 +383,7 @@ gx_attach(device_t dev)
/*
* Call MI attach routines.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, gx->arpcom.ac_enaddr);
GX_UNLOCK(gx);
splx(s);
@@ -611,7 +612,7 @@ gx_detach(device_t dev)
ifp = &gx->arpcom.ac_if;
GX_LOCK(gx);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
gx_reset(gx);
gx_stop(gx);
ifmedia_removeall(&gx->gx_media);
@@ -917,10 +918,6 @@ gx_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
GX_LOCK(gx);
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFMTU:
if (ifr->ifr_mtu > GX_MAX_MTU) {
error = EINVAL;
@@ -971,7 +968,7 @@ gx_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
}
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
@@ -1220,7 +1217,6 @@ gx_setmulti(struct gx_softc *gx)
static void
gx_rxeof(struct gx_softc *gx)
{
- struct ether_header *eh;
struct gx_rx_desc *rx;
struct ifnet *ifp;
int idx, staterr, len;
@@ -1286,12 +1282,8 @@ gx_rxeof(struct gx_softc *gx)
}
ifp->if_ipackets++;
- 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));
-
#define IP_CSMASK (GX_RXSTAT_IGNORE_CSUM | GX_RXSTAT_HAS_IP_CSUM)
#define TCP_CSMASK \
(GX_RXSTAT_IGNORE_CSUM | GX_RXSTAT_HAS_TCP_CSUM | GX_RXERR_TCP_CSUM)
@@ -1315,14 +1307,13 @@ gx_rxeof(struct gx_softc *gx)
}
}
/*
- * 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,
+ * mark the packet before it's passed up.
*/
if (staterr & GX_RXSTAT_VLAN_PKT) {
- VLAN_INPUT_TAG(eh, m, rx->rx_special);
- continue;
+ VLAN_INPUT_TAG(ifp, m, rx->rx_special, continue);
}
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
continue;
ierror:
@@ -1471,12 +1462,7 @@ gx_encap(struct gx_softc *gx, struct mbuf *m_head)
struct gx_tx_desc_ctx *tctx;
struct mbuf *m;
int idx, cnt, csumopts, txcontext;
- 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;
cnt = gx->gx_txcnt;
idx = gx->gx_tx_tail_idx;
@@ -1526,7 +1512,6 @@ gx_encap(struct gx_softc *gx, struct mbuf *m_head)
cnt++;
}
context_done:
-
/*
* Start packing the mbufs in this chain into the transmit
* descriptors. Stop when we run out of descriptors or hit
@@ -1562,9 +1547,10 @@ printf("overflow(2): %d, %d\n", cnt, GX_TX_RING_CNT);
if (tx != NULL) {
tx->tx_command |= GX_TXTCP_REPORT_STATUS | GX_TXTCP_INT_DELAY |
GX_TXTCP_ETHER_CRC | GX_TXTCP_END_OF_PKT;
- if (ifv != NULL) {
+ mtag = VLAN_OUTPUT_TAG(&gx->arpcom.ac_if, m);
+ if (mtag != NULL) {
tx->tx_command |= GX_TXTCP_VLAN_ENABLE;
- tx->tx_vlan = ifv->ifv_tag;
+ tx->tx_vlan = VLAN_TAG_VALUE(mtag);
}
gx->gx_txcnt = cnt;
gx->gx_tx_tail_idx = idx;
@@ -1613,8 +1599,7 @@ gx_start(struct ifnet *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);
/*
* Set a timeout in case the chip goes out to lunch.
diff --git a/sys/dev/gx/if_gxvar.h b/sys/dev/gx/if_gxvar.h
index c70aa0c..8570a50 100644
--- a/sys/dev/gx/if_gxvar.h
+++ b/sys/dev/gx/if_gxvar.h
@@ -49,8 +49,6 @@ struct mtx { int filler; };
#define PCIM_CMD_MWIEN 0x0010
#endif
-#define ETHER_ALIGN 2
-
/* CSR_WRITE_8 assumes the register is in low/high order */
#define CSR_WRITE_8(gx, reg, val) do { \
bus_space_write_4((gx)->gx_btag, (gx)->gx_bhandle, \
diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c
index e495795..11b7878 100644
--- a/sys/dev/hme/if_hme.c
+++ b/sys/dev/hme/if_hme.c
@@ -314,7 +314,7 @@ hme_config(struct hme_softc *sc)
}
/* Attach the interface. */
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
callout_init(&sc->sc_tick_ch, 0);
return (0);
@@ -987,7 +987,6 @@ static void
hme_read(struct hme_softc *sc, int ix, int len)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- struct ether_header *eh;
struct mbuf *m;
int offs;
@@ -1026,10 +1025,8 @@ hme_read(struct hme_softc *sc, int ix, int len)
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = len + offs;
m_adj(m, offs);
- eh = mtod(m, struct ether_header *);
- m_adj(m, sizeof(struct ether_header));
/* Pass the packet up. */
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
static void
@@ -1055,8 +1052,7 @@ hme_start(struct ifnet *ifp)
break;
} else {
enq = 1;
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
}
}
@@ -1376,11 +1372,6 @@ hme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
s = splnet();
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
case SIOCSIFFLAGS:
if ((ifp->if_flags & IFF_UP) == 0 &&
(ifp->if_flags & IFF_RUNNING) != 0) {
@@ -1420,7 +1411,7 @@ hme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii->mii_media, cmd);
break;
default:
- error = ENOTTY;
+ error = ether_ioctl(ifp, cmd, data);
break;
}
diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c
index b578b45..b3e844c6 100644
--- a/sys/dev/ie/if_ie.c
+++ b/sys/dev/ie/if_ie.c
@@ -202,8 +202,7 @@ static int ierint(int unit, struct ie_softc * ie);
static int ietint(int unit, struct ie_softc * ie);
static int iernr(int unit, struct ie_softc * ie);
static void start_receiver(int unit);
-static __inline int ieget(int, struct ie_softc *, struct mbuf **,
- struct ether_header *);
+static __inline int ieget(int, struct ie_softc *, struct mbuf **);
static v_caddr_t setup_rfa(v_caddr_t ptr, struct ie_softc * ie);
static int mc_setup(int, v_caddr_t, volatile struct ie_sys_ctl_block *);
static void ie_mc_reset(int unit);
@@ -796,7 +795,7 @@ ieattach(struct isa_device *dvp)
EVENTHANDLER_REGISTER(shutdown_post_sync, ee16_shutdown,
ie, SHUTDOWN_PRI_DEFAULT);
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, ie->arpcom.ac_enaddr);
return (1);
}
@@ -1122,10 +1121,9 @@ ie_packet_len(int unit, struct ie_softc * ie)
* operation considerably. (Provided that it works, of course.)
*/
static __inline int
-ieget(int unit, struct ie_softc *ie, struct mbuf **mp, struct ether_header *ehp)
+ieget(int unit, struct ie_softc *ie, struct mbuf **mp)
{
struct mbuf *m, *top, **mymp;
- int i;
int offset;
int totlen, resid;
int thismboff;
@@ -1135,12 +1133,18 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp, struct ether_header *ehp)
if (totlen <= 0)
return (-1);
- i = ie->rbhead;
+ 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[i], (caddr_t) ehp, sizeof *ehp);
+ bcopy((v_caddr_t) ie->cbuffs[ie->rbhead], mtod(m, caddr_t),
+ sizeof (struct ether_header));
/* ignore cast-qual warning here */
/*
@@ -1149,25 +1153,25 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp, struct ether_header *ehp)
* This is only a consideration when FILTER is defined; i.e., when
* we are either running BPF or doing multicasting.
*/
- if (!check_eh(ie, ehp)) {
+ if (!check_eh(ie, mtod(m, struct ether_header *))) {
+ m_free(m);
ie_drop_packet_buffer(unit, ie);
ie->arpcom.ac_if.if_ierrors--; /* just this case, it's not an
* error
*/
return (-1);
}
- totlen -= (offset = sizeof *ehp);
- MGETHDR(*mp, M_DONTWAIT, MT_DATA);
- if (!*mp) {
- ie_drop_packet_buffer(unit, ie);
- return (-1);
- }
- m = *mp;
+ /* XXX way too complicated, check carefully XXXX */
+
+ *mp = m;
m->m_pkthdr.rcvif = &ie->arpcom.ac_if;
- m->m_len = MHLEN;
- resid = m->m_pkthdr.len = totlen;
- top = 0;
+ /* deduct header just copied; m_len must reflect space avail below */
+ m->m_len = MHLEN - sizeof (struct ether_header);
+ m->m_pkthdr.len = totlen;
+
+ resid = totlen - sizeof (struct ether_header); /* remaining data */
+ top = NULL;
mymp = &top;
/*
@@ -1208,10 +1212,11 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp, struct ether_header *ehp)
mymp = &m->m_next;
} while (resid > 0);
- resid = totlen;
- m = top;
- thismboff = 0;
- head = ie->rbhead;
+ resid = totlen - sizeof (struct ether_header); /* remaining data */
+ offset = sizeof (struct ether_header); /* packet offset */
+ m = top; /* current mbuf */
+ thismboff = sizeof (struct ether_header); /* offset in m */
+ head = ie->rbhead; /* current rx buffer */
/*
* Now we take the mbuf chain (hopefully only one mbuf most of the
@@ -1232,7 +1237,7 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp, struct ether_header *ehp)
mtod(m, v_caddr_t) +thismboff, (unsigned) newlen);
/* ignore cast-qual warning */
m = m->m_next;
- thismboff = 0; /* new mbuf, so no offset */
+ thismboff = 0; /* new mbuf, so no offset */
offset += newlen; /* we are now this far into
* the packet */
resid -= newlen; /* so there is this much left
@@ -1296,9 +1301,12 @@ nextbuf:
static void
ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */)
{
+ struct ifnet *ifp = &ie->arpcom.ac_if;
struct ie_recv_frame_desc rfd;
struct mbuf *m = 0;
- struct ether_header eh;
+#ifdef DEBUG
+ struct ether_header *eh;
+#endif
bcopy((v_caddr_t) (ie->rframes[num]), &rfd,
sizeof(struct ie_recv_frame_desc));
@@ -1314,19 +1322,20 @@ ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */)
ie->rfhead = (ie->rfhead + 1) % ie->nframes;
if (rfd.ie_fd_status & IE_FD_OK) {
- if (ieget(unit, ie, &m, &eh)) {
+ if (ieget(unit, ie, &m)) {
ie->arpcom.ac_if.if_ierrors++; /* this counts as an
* error */
return;
}
}
#ifdef DEBUG
+ eh = mtod(m, struct ether_header *);
if (ie_debug & IED_READFRAME) {
printf("ie%d: frame from ether %6D type %x\n", unit,
- eh.ether_shost, ":", (unsigned) eh.ether_type);
+ eh->ether_shost, ":", (unsigned) eh->ether_type);
}
- if (ntohs(eh.ether_type) > ETHERTYPE_TRAIL
- && ntohs(eh.ether_type) < (ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER))
+ if (ntohs(eh->ether_type) > ETHERTYPE_TRAIL
+ && ntohs(eh->ether_type) < (ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER))
printf("received trailer!\n");
#endif
@@ -1336,7 +1345,7 @@ ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */)
/*
* Finally pass this packet up to higher layers.
*/
- ether_input(&ie->arpcom.ac_if, &eh, m);
+ (*ifp->if_input)(ifp, m);
}
static void
@@ -1412,9 +1421,8 @@ iestart(struct ifnet *ifp)
* See if bpf is listening on this interface, let it see the
* packet before we commit it to the wire.
*/
- if (ie->arpcom.ac_if.if_bpf)
- bpf_tap(&ie->arpcom.ac_if,
- (void *)ie->xmit_cbuffs[ie->xmit_count], len);
+ BPF_TAP(&ie->arpcom.ac_if,
+ (void *)ie->xmit_cbuffs[ie->xmit_count], len);
ie->xmit_buffs[ie->xmit_count]->ie_xmit_flags =
IE_XMIT_LAST|len;
@@ -2093,12 +2101,6 @@ ieioctl(struct ifnet *ifp, u_long command, caddr_t data)
s = splimp();
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
* Note that this device doesn't have an "all multicast"
@@ -2133,7 +2135,8 @@ ieioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
+ break;
}
splx(s);
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c
index 5453e82..a6660b7 100644
--- a/sys/dev/iicbus/if_ic.c
+++ b/sys/dev/iicbus/if_ic.c
@@ -310,8 +310,7 @@ icintr (device_t dev, int event, char *ptr)
sc->ic_if.if_ipackets ++;
sc->ic_if.if_ibytes += len;
- if (sc->ic_if.if_bpf)
- bpf_tap(&sc->ic_if, sc->ic_ifbuf, len + ICHDRLEN);
+ BPF_TAP(&sc->ic_if, sc->ic_ifbuf, len + ICHDRLEN);
top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, &sc->ic_if, 0);
@@ -418,7 +417,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m,
m0.m_data = (char *)&hdr;
n = &m0;
- bpf_mtap(ifp, n);
+ BPF_MTAP(ifp, n);
}
sc->ic_sending = 1;
diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c
index 30feaf9..9efa94da 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -674,7 +674,7 @@ lge_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->lge_stat_ch);
fail:
@@ -697,7 +697,7 @@ lge_detach(dev)
lge_reset(sc);
lge_stop(sc);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_generic_detach(dev);
device_delete_child(dev, sc->lge_miibus);
@@ -971,7 +971,6 @@ lge_rxeof(sc, cnt)
struct lge_softc *sc;
int cnt;
{
- struct ether_header *eh;
struct mbuf *m;
struct ifnet *ifp;
struct lge_rx_desc *cur_rx;
@@ -1027,10 +1026,6 @@ lge_rxeof(sc, cnt)
}
ifp->if_ipackets++;
- eh = mtod(m, struct ether_header *);
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
/* Do IP checksum checking. */
if (rxsts & LGE_RXSTS_ISIP)
@@ -1046,7 +1041,7 @@ lge_rxeof(sc, cnt)
m->m_pkthdr.csum_data = 0xffff;
}
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
sc->lge_cdata.lge_rx_cons = i;
@@ -1299,8 +1294,7 @@ lge_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);
}
sc->lge_cdata.lge_tx_prod = idx;
@@ -1508,10 +1502,6 @@ lge_ioctl(ifp, command, data)
s = splimp();
switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFMTU:
if (ifr->ifr_mtu > LGE_JUMBO_MTU)
error = EINVAL;
@@ -1553,7 +1543,7 @@ lge_ioctl(ifp, command, data)
error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
diff --git a/sys/dev/lge/if_lgereg.h b/sys/dev/lge/if_lgereg.h
index f0254b1..28a6aec 100644
--- a/sys/dev/lge/if_lgereg.h
+++ b/sys/dev/lge/if_lgereg.h
@@ -563,7 +563,6 @@ struct lge_softc {
bus_space_read_1(sc->lge_btag, sc->lge_bhandle, reg)
#define LGE_TIMEOUT 1000
-#define ETHER_ALIGN 2
#define LGE_RXLEN 1536
#define LGE_MIN_FRAMELEN 60
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
index 73f8d4d..eeb678a 100644
--- a/sys/dev/lnc/if_lnc.c
+++ b/sys/dev/lnc/if_lnc.c
@@ -446,6 +446,7 @@ mbuf_packet(struct lnc_softc *sc, int start_of_packet, int pkt_len)
static __inline void
lnc_rint(struct lnc_softc *sc)
{
+ struct ifnet *ifp = &sc->arpcom.ac_if;
struct host_ring_entry *next, *start;
int start_of_packet;
struct mbuf *head;
@@ -465,13 +466,13 @@ lnc_rint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if ((sc->recv_ring + sc->recv_next)->md->md1 & OWN) {
- int unit = sc->arpcom.ac_if.if_unit;
+ int unit = ifp->if_unit;
log(LOG_ERR, "lnc%d: Receive interrupt with buffer still owned by controller -- Resetting\n", unit);
lnc_reset(sc);
return;
}
if (!((sc->recv_ring + sc->recv_next)->md->md1 & STP)) {
- int unit = sc->arpcom.ac_if.if_unit;
+ int unit = ifp->if_unit;
log(LOG_ERR, "lnc%d: Receive interrupt but not start of packet -- Resetting\n", unit);
lnc_reset(sc);
return;
@@ -503,7 +504,7 @@ lnc_rint(struct lnc_softc *sc)
} while (!(flags & (STP | OWN | ENP | MDERR)));
if (flags & STP) {
- int unit = sc->arpcom.ac_if.if_unit;
+ int unit = ifp->if_unit;
log(LOG_ERR, "lnc%d: Start of packet found before end of previous in receive ring -- Resetting\n", unit);
lnc_reset(sc);
return;
@@ -517,7 +518,7 @@ lnc_rint(struct lnc_softc *sc)
sc->recv_next = start_of_packet;
break;
} else {
- int unit = sc->arpcom.ac_if.if_unit;
+ int unit = ifp->if_unit;
log(LOG_ERR, "lnc%d: End of received packet not found-- Resetting\n", unit);
lnc_reset(sc);
return;
@@ -532,7 +533,7 @@ lnc_rint(struct lnc_softc *sc)
next = sc->recv_ring + sc->recv_next;
if (flags & MDERR) {
- int unit = sc->arpcom.ac_if.if_unit;
+ int unit = ifp->if_unit;
if (flags & RBUFF) {
LNCSTATS(rbuff)
log(LOG_ERR, "lnc%d: Receive buffer error\n", unit);
@@ -544,7 +545,7 @@ lnc_rint(struct lnc_softc *sc)
log(LOG_ERR, "lnc%d: Receive overflow error \n", unit);
}
} else if (flags & ENP) {
- if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC)==0) {
+ if ((ifp->if_flags & IFF_PROMISC)==0) {
/*
* FRAM and CRC are valid only if ENP
* is set and OFLO is not.
@@ -565,7 +566,7 @@ lnc_rint(struct lnc_softc *sc)
/* Drop packet */
LNCSTATS(rerr)
- sc->arpcom.ac_if.if_ierrors++;
+ ifp->if_ierrors++;
while (start_of_packet != sc->recv_next) {
start = sc->recv_ring + start_of_packet;
start->md->md2 = -RECVBUFSIZE; /* XXX - shouldn't be necessary */
@@ -575,7 +576,7 @@ lnc_rint(struct lnc_softc *sc)
}
} else { /* Valid packet */
- sc->arpcom.ac_if.if_ipackets++;
+ ifp->if_ipackets++;
if (sc->nic.mem_mode == DMA_MBUF)
@@ -588,7 +589,7 @@ lnc_rint(struct lnc_softc *sc)
* First mbuf in packet holds the
* ethernet and packet headers
*/
- head->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ head->m_pkthdr.rcvif = ifp;
head->m_pkthdr.len = pkt_len ;
eh = (struct ether_header *) head->m_data;
@@ -601,15 +602,10 @@ lnc_rint(struct lnc_softc *sc)
sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) == 0) {
m_freem(head);
} else {
- /* Skip over the ether header */
- head->m_data += sizeof *eh;
- head->m_len -= sizeof *eh;
- head->m_pkthdr.len -= sizeof *eh;
-
- ether_input(&sc->arpcom.ac_if, eh, head);
+ (*ifp->if_input)(ifp, head);
}
} else {
- int unit = sc->arpcom.ac_if.if_unit;
+ int unit = ifp->if_unit;
log(LOG_ERR,"lnc%d: Packet dropped, no mbufs\n",unit);
LNCSTATS(drop_packet)
}
@@ -907,7 +903,7 @@ lnc_attach_common(device_t dev)
* XXX -- should check return status of if_attach
*/
- ether_ifattach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifattach(&sc->arpcom.ac_if, sc->arpcom.ac_enaddr);
printf("lnc%d: ", unit);
if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
@@ -1381,8 +1377,7 @@ lnc_start(struct ifnet *ifp)
ifp->if_timer = 2;
- if (sc->arpcom.ac_if.if_bpf)
- bpf_mtap(&sc->arpcom.ac_if, head);
+ BPF_MTAP(&sc->arpcom.ac_if, head);
if (sc->nic.mem_mode != DMA_MBUF)
m_freem(head);
@@ -1408,12 +1403,6 @@ lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
s = splimp();
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
#ifdef DEBUG
if (ifp->if_flags & IFF_DEBUG)
@@ -1464,7 +1453,8 @@ lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
error = 0;
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
+ break;
}
(void) splx(s);
return error;
diff --git a/sys/dev/lnc/if_lnc_cbus.c b/sys/dev/lnc/if_lnc_cbus.c
index 85be471..571407e 100644
--- a/sys/dev/lnc/if_lnc_cbus.c
+++ b/sys/dev/lnc/if_lnc_cbus.c
@@ -284,7 +284,7 @@ lnc_isa_detach(device_t dev)
lnc_softc_t *sc = device_get_softc(dev);
int s = splimp();
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
splx(s);
lnc_stop(sc);
diff --git a/sys/dev/lnc/if_lnc_isa.c b/sys/dev/lnc/if_lnc_isa.c
index c973494..949ea7d 100644
--- a/sys/dev/lnc/if_lnc_isa.c
+++ b/sys/dev/lnc/if_lnc_isa.c
@@ -255,7 +255,7 @@ lnc_isa_detach(device_t dev)
lnc_softc_t *sc = device_get_softc(dev);
int s = splimp();
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
splx(s);
lnc_stop(sc);
diff --git a/sys/dev/lnc/if_lnc_pci.c b/sys/dev/lnc/if_lnc_pci.c
index 00d7ab8..5a6bd8d 100644
--- a/sys/dev/lnc/if_lnc_pci.c
+++ b/sys/dev/lnc/if_lnc_pci.c
@@ -187,7 +187,7 @@ lnc_pci_detach(device_t dev)
lnc_softc_t *sc = device_get_softc(dev);
int s = splimp();
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
lnc_stop(sc);
bus_teardown_intr(dev, sc->irqres, sc->intrhand);
diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c
index 5f10be7..9f7a930 100644
--- a/sys/dev/my/if_my.c
+++ b/sys/dev/my/if_my.c
@@ -1056,7 +1056,7 @@ my_attach(device_t dev)
my_stop(sc);
ifmedia_set(&sc->ifmedia, media);
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, eaddr);
#if 0
at_shutdown(my_shutdown, sc, SHUTDOWN_POST_SYNC);
@@ -1084,7 +1084,7 @@ my_detach(device_t dev)
sc = device_get_softc(dev);
MY_LOCK(sc);
ifp = &sc->arpcom.ac_if;
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
my_stop(sc);
#if 0
@@ -1267,7 +1267,7 @@ my_rxeof(struct my_softc * sc)
* address or the interface is in promiscuous mode.
*/
if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
if (ifp->if_flags & IFF_PROMISC &&
(bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
ETHER_ADDR_LEN) &&
@@ -1277,9 +1277,7 @@ my_rxeof(struct my_softc * sc)
}
}
#endif
- /* 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);
}
MY_UNLOCK(sc);
return;
@@ -1537,8 +1535,7 @@ my_start(struct ifnet * ifp)
* If there's a BPF listener, bounce a copy of this frame to
* him.
*/
- if (ifp->if_bpf)
- bpf_mtap(ifp, cur_tx->my_mbuf);
+ BPF_MTAP(ifp, cur_tx->my_mbuf);
#endif
}
/*
@@ -1764,11 +1761,6 @@ my_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
s = splimp();
MY_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)
my_init(sc);
@@ -1786,7 +1778,7 @@ my_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command);
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
MY_UNLOCK(sc);
diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c
index b7af59a..c95aeee 100644
--- a/sys/dev/nge/if_nge.c
+++ b/sys/dev/nge/if_nge.c
@@ -977,7 +977,7 @@ nge_attach(dev)
ifp->if_baudrate = 1000000000;
ifp->if_snd.ifq_maxlen = NGE_TX_LIST_CNT - 1;
ifp->if_hwassist = NGE_CSUM_FEATURES;
- ifp->if_capabilities = IFCAP_HWCSUM;
+ ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING;
ifp->if_capenable = ifp->if_capabilities;
/*
@@ -1031,7 +1031,7 @@ nge_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->nge_stat_ch);
fail:
@@ -1056,7 +1056,7 @@ nge_detach(dev)
nge_reset(sc);
nge_stop(sc);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_generic_detach(dev);
if (!sc->nge_tbi) {
@@ -1326,7 +1326,6 @@ static void
nge_rxeof(sc)
struct nge_softc *sc;
{
- struct ether_header *eh;
struct mbuf *m;
struct ifnet *ifp;
struct nge_desc *cur_rx;
@@ -1402,10 +1401,6 @@ nge_rxeof(sc)
#endif
ifp->if_ipackets++;
- eh = mtod(m, struct ether_header *);
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
/* Do IP checksum checking. */
if (extsts & NGE_RXEXTSTS_IPPKT)
@@ -1426,11 +1421,11 @@ nge_rxeof(sc)
* to vlan_input() instead of ether_input().
*/
if (extsts & NGE_RXEXTSTS_VLANPKT) {
- VLAN_INPUT_TAG(eh, m, extsts & NGE_RXEXTSTS_VTCI);
- continue;
- }
+ VLAN_INPUT_TAG(ifp, m,
+ extsts & NGE_RXEXTSTS_VTCI, continue);
+ }
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
sc->nge_cdata.nge_rx_prod = i;
@@ -1705,12 +1700,7 @@ nge_encap(sc, m_head, txidx)
struct nge_desc *f = NULL;
struct mbuf *m;
int frag, cur, cnt = 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;
/*
* Start packing the mbufs in this chain into
@@ -1752,9 +1742,10 @@ nge_encap(sc, m_head, txidx)
NGE_TXEXTSTS_UDPCSUM;
}
- if (ifv != NULL) {
+ mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m);
+ if (mtag != NULL) {
sc->nge_ldata->nge_tx_list[cur].nge_extsts |=
- (NGE_TXEXTSTS_VLANPKT|ifv->ifv_tag);
+ (NGE_TXEXTSTS_VLANPKT|VLAN_TAG_VALUE(mtag));
}
sc->nge_ldata->nge_tx_list[cur].nge_mbuf = m_head;
@@ -1806,8 +1797,7 @@ nge_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);
}
@@ -2140,10 +2130,6 @@ nge_ioctl(ifp, command, data)
s = splimp();
switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFMTU:
if (ifr->ifr_mtu > NGE_JUMBO_MTU)
error = EINVAL;
@@ -2204,7 +2190,7 @@ nge_ioctl(ifp, command, data)
}
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
diff --git a/sys/dev/nge/if_ngereg.h b/sys/dev/nge/if_ngereg.h
index 27ea49a..a5dc721 100644
--- a/sys/dev/nge/if_ngereg.h
+++ b/sys/dev/nge/if_ngereg.h
@@ -674,7 +674,6 @@ struct nge_softc {
bus_space_read_4(sc->nge_btag, sc->nge_bhandle, reg)
#define NGE_TIMEOUT 1000
-#define ETHER_ALIGN 2
#define NGE_RXLEN 1536
#define NGE_MIN_FRAMELEN 60
diff --git a/sys/dev/pdq/pdq_ifsubr.c b/sys/dev/pdq/pdq_ifsubr.c
index 6510e74..064bb68 100644
--- a/sys/dev/pdq/pdq_ifsubr.c
+++ b/sys/dev/pdq/pdq_ifsubr.c
@@ -189,9 +189,10 @@ pdq_os_receive_pdu(
int drop)
{
pdq_softc_t *sc = pdq->pdq_os_ctx;
+ struct ifnet *ifp = &sc->sc_if;
struct fddi_header *fh;
- sc->sc_if.if_ipackets++;
+ ifp->if_ipackets++;
#if defined(PDQ_BUS_DMA)
{
/*
@@ -217,15 +218,14 @@ pdq_os_receive_pdu(
#endif
fh = mtod(m, struct fddi_header *);
if (drop || (fh->fddi_fc & (FDDIFC_L|FDDIFC_F)) != FDDIFC_LLC_ASYNC) {
- sc->sc_if.if_iqdrops++;
- sc->sc_if.if_ierrors++;
+ ifp->if_iqdrops++;
+ ifp->if_ierrors++;
PDQ_OS_DATABUF_FREE(pdq, m);
return;
}
- m_adj(m, FDDI_HDR_LEN);
- m->m_pkthdr.rcvif = &sc->sc_if;
- fddi_input(&sc->sc_if, fh, m);
+ m->m_pkthdr.rcvif = ifp;
+ (*ifp->if_input)(ifp, m);
}
void
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index 0766698..6f72096 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -459,7 +459,7 @@ lptap(struct ifnet *ifp, struct mbuf *m)
m0.m_next = m;
m0.m_len = sizeof(u_int32_t);
m0.m_data = (char *)&af;
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
}
static void
diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c
index 605c33f..fd4731f74 100644
--- a/sys/dev/ray/if_ray.c
+++ b/sys/dev/ray/if_ray.c
@@ -517,7 +517,7 @@ ray_attach(device_t dev)
ifp->if_init = ray_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, ep->e_station_addr);
/*
* Initialise the timers and driver
@@ -593,7 +593,7 @@ ray_detach(device_t dev)
sc->sc_gone = 1;
sc->sc_c.np_havenet = 0;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
/*
* Stop the runq and wake up anyone sleeping for us.
@@ -644,15 +644,6 @@ ray_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
s = splimp();
switch (command) {
-
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- case SIOCSIFADDR:
- RAY_DPRINTF(sc, RAY_DBG_IOCTL, "GIFADDR/SIFMTU");
- error = ether_ioctl(ifp, command, data);
-/* XXX SIFADDR used to fall through to SIOCSIFFLAGS */
- break;
-
case SIOCSIFFLAGS:
RAY_DPRINTF(sc, RAY_DBG_IOCTL, "SIFFLAGS 0x%0x", ifp->if_flags);
/*
@@ -734,7 +725,9 @@ ray_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
break;
default:
- error = EINVAL;
+ RAY_DPRINTF(sc, RAY_DBG_IOCTL, "OTHER (pass to ether)");
+ error = ether_ioctl(ifp, command, data);
+ break;
}
@@ -1910,7 +1903,6 @@ ray_rx_data(struct ray_softc *sc, struct mbuf *m0, u_int8_t siglev, u_int8_t ant
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ieee80211_frame *header = mtod(m0, struct ieee80211_frame *);
- struct ether_header *eh;
struct llc *llc;
u_int8_t *sa = NULL, *da = NULL, *ra = NULL, *ta = NULL;
int trim = 0;
@@ -2024,6 +2016,7 @@ ray_rx_data(struct ray_softc *sc, struct mbuf *m0, u_int8_t siglev, u_int8_t ant
llc->llc_un.type_snap.org_code[0] == 0 &&
llc->llc_un.type_snap.org_code[1] == 0 &&
llc->llc_un.type_snap.org_code[2] == 0) {
+ struct ether_header *eh;
/*
* This is not magic. RFC1042 header is 8
* bytes, with the last two bytes being the
@@ -2079,9 +2072,7 @@ ray_rx_data(struct ray_softc *sc, struct mbuf *m0, u_int8_t siglev, u_int8_t ant
RAY_MBUF_DUMP(sc, RAY_DBG_RX, m0, "(3) packet after trimming");
ifp->if_ipackets++;
ray_rx_update_cache(sc, header->i_addr2, siglev, antenna);
- eh = mtod(m0, struct ether_header *);
- m_adj(m0, sizeof(struct ether_header));
- ether_input(ifp, eh, m0);
+ (*ifp->if_input)(ifp, m0);
}
/*
diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c
index 3554cc6..e5d5417 100644
--- a/sys/dev/sbni/if_sbni.c
+++ b/sys/dev/sbni/if_sbni.c
@@ -242,7 +242,7 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
(csr0 & 0x01 ? 500000 : 2000000) / (1 << flags.rate);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
/* device attach does transition from UNCONFIGURED to IDLE state */
@@ -693,8 +693,7 @@ prepare_to_send(struct sbni_softc *sc)
sbni_outb(sc, CSR0, sbni_inb(sc, CSR0) | TR_REQ);
sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
- if (sc->arpcom.ac_if.if_bpf)
- bpf_mtap(&sc->arpcom.ac_if, sc->tx_buf_p);
+ BPF_MTAP(&sc->arpcom.ac_if, sc->tx_buf_p);
}
@@ -851,17 +850,14 @@ get_rx_buf(struct sbni_softc *sc)
static void
indicate_pkt(struct sbni_softc *sc)
{
+ struct ifnet *ifp = &sc->arpcom.ac_if;
struct mbuf *m;
- struct ether_header *eh;
m = sc->rx_buf_p;
- m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = sc->inppos;
- eh = mtod(m, struct ether_header *);
- /* Remove link layer address and indicate packet */
- m_adj(m, sizeof(struct ether_header));
- ether_input(&sc->arpcom.ac_if, eh, m);
+ (*ifp->if_input)(ifp, m);
sc->rx_buf_p = NULL;
}
@@ -1063,11 +1059,6 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
s = splimp();
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
* If the interface is marked up and stopped, then start it.
@@ -1149,7 +1140,8 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
+ break;
}
splx(s);
diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c
index 9058bfd..46011cb 100644
--- a/sys/dev/sn/if_sn.c
+++ b/sys/dev/sn/if_sn.c
@@ -220,7 +220,7 @@ sn_attach(device_t dev)
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_timer = 0;
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/*
* Fill the hardware address into ifa_addr if we find an AF_LINK
@@ -250,7 +250,7 @@ sn_detach(device_t dev)
struct sn_softc *sc = device_get_softc(dev);
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
sn_deactivate(dev);
return 0;
}
@@ -553,9 +553,7 @@ startagain:
sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
sc->arpcom.ac_if.if_timer = 1;
- if (ifp->if_bpf) {
- bpf_mtap(ifp, top);
- }
+ BPF_MTAP(ifp, top);
sc->arpcom.ac_if.if_opackets++;
m_freem(top);
@@ -750,9 +748,7 @@ snresume(struct ifnet *ifp)
sc->intr_mask = mask;
outw(BASE + MMU_CMD_REG_W, MMUCR_ENQUEUE);
- if (ifp->if_bpf) {
- bpf_mtap(ifp, top);
- }
+ BPF_MTAP(ifp, top);
sc->arpcom.ac_if.if_opackets++;
m_freem(top);
@@ -1099,10 +1095,9 @@ read_another:
/*
* Remove link layer addresses and whatnot.
*/
- m->m_pkthdr.len = m->m_len = packet_length - sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
+ m->m_pkthdr.len = m->m_len = packet_length;
- ether_input(&sc->arpcom.ac_if, eh, m);
+ (*ifp->if_input)(ifp, m);
out:
@@ -1140,12 +1135,6 @@ snioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
s = splimp();
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
-
case SIOCSIFFLAGS:
if ((ifp->if_flags & IFF_UP) == 0 && ifp->if_flags & IFF_RUNNING) {
ifp->if_flags &= ~IFF_RUNNING;
@@ -1177,6 +1166,8 @@ snioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
break;
default:
error = EINVAL;
+ error = ether_ioctl(ifp, cmd, data);
+ break;
}
splx(s);
diff --git a/sys/dev/snc/dp83932.c b/sys/dev/snc/dp83932.c
index fc6a9d6..991bb99 100644
--- a/sys/dev/snc/dp83932.c
+++ b/sys/dev/snc/dp83932.c
@@ -197,7 +197,7 @@ sncconfig(sc, media, nmedia, defmedia, myea)
ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL);
}
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, myea);
#if NRND > 0
rnd_attach_source(&sc->rnd_source, device_get_nameunit(sc->sc_dev),
@@ -261,12 +261,6 @@ sncioctl(ifp, cmd, data)
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- err = ether_ioctl(ifp, cmd, data);
- break;
-
case SIOCSIFFLAGS:
if ((ifp->if_flags & IFF_UP) == 0 &&
(ifp->if_flags & IFF_RUNNING) != 0) {
@@ -315,7 +309,8 @@ sncioctl(ifp, cmd, data)
err = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
- err = EINVAL;
+ err = ether_ioctl(ifp, cmd, data);
+ break;
}
splx(s);
return (err);
@@ -358,8 +353,7 @@ outloop:
* If bpf is listening on this interface, let it
* see the packet before we commit it to the wire.
*/
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
/*
* If there is nothing in the o/p queue, and there is room in
@@ -1105,9 +1099,8 @@ sonic_read(sc, pkt, len)
}
#endif /* SNCDEBUG */
- /* Pass the packet up, with the ether header sort-of removed. */
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, et, m);
+ /* Pass the packet up. */
+ (*ifp->if_input)(ifp, m);
return (1);
}
diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c
index 0552b5a..18b5511 100644
--- a/sys/dev/sr/if_sr.c
+++ b/sys/dev/sr/if_sr.c
@@ -868,8 +868,7 @@ top_srstart:
#endif
#ifndef NETGRAPH
- if (ifp->if_bpf)
- bpf_mtap(ifp, mtx);
+ BPF_MTAP(ifp, mtx);
#else /* NETGRAPH */
sc->outbytes += len;
#endif /* NETGRAPH */
@@ -2126,8 +2125,7 @@ sr_get_packets(struct sr_softc *sc)
sr_copy_rxbuf(m, sc, len); /* copy from DPRAM */
#ifndef NETGRAPH
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
#if BUGGY > 3
{
diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c
index dd94f6e..51690e4 100644
--- a/sys/dev/tx/if_tx.c
+++ b/sys/dev/tx/if_tx.c
@@ -333,8 +333,9 @@ epic_attach(dev)
printf("\n");
/* Attach to OS's managers */
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->sc_macaddr);
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
+ ifp->if_capabilities |= IFCAP_VLAN_MTU;
callout_handle_init(&sc->stat_ch);
fail:
@@ -359,7 +360,7 @@ epic_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
epic_stop(sc);
@@ -416,10 +417,6 @@ epic_ifioctl(ifp, command, data)
x = splimp();
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFMTU:
if (ifp->if_mtu == ifr->ifr_mtu)
break;
@@ -475,7 +472,8 @@ epic_ifioctl(ifp, command, data)
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
+ break;
}
splx(x);
@@ -609,8 +607,7 @@ epic_ifstart(ifp)
/* Set watchdog timer */
ifp->if_timer = 8;
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ BPF_MTAP(ifp, m0);
}
ifp->if_flags |= IFF_OACTIVE;
@@ -631,7 +628,6 @@ epic_rx_done(sc)
struct epic_rx_buffer *buf;
struct epic_rx_desc *desc;
struct mbuf *m;
- struct ether_header *eh;
while ((sc->rx_desc[sc->cur_rx].status & 0x8000) == 0) {
buf = sc->rx_buffer + sc->cur_rx;
@@ -671,13 +667,11 @@ epic_rx_done(sc)
desc->status = 0x8000;
/* First mbuf in packet holds the ethernet and packet headers */
- eh = mtod(m, struct ether_header *);
- m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
m->m_pkthdr.rcvif = ifp;
+ m->m_pkthdr.len = m->m_len = len;
/* Give mbuf to OS */
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
/* Successfuly received frame */
ifp->if_ipackets++;
diff --git a/sys/dev/txp/if_txp.c b/sys/dev/txp/if_txp.c
index 1ac9a67..7c4d74d 100644
--- a/sys/dev/txp/if_txp.c
+++ b/sys/dev/txp/if_txp.c
@@ -383,7 +383,7 @@ txp_attach(dev)
/*
* Attach us everywhere
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
callout_handle_init(&sc->sc_tick);
return(0);
@@ -408,7 +408,7 @@ txp_detach(dev)
txp_shutdown(dev);
ifmedia_removeall(&sc->sc_ifmedia);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
for (i = 0; i < RXBUF_ENTRIES; i++)
free(sc->sc_rxbufs[i].rb_sd, M_DEVBUF);
@@ -736,7 +736,6 @@ txp_rx_reclaim(sc, r)
struct mbuf *m;
struct txp_swdesc *sd = NULL;
u_int32_t roff, woff;
- struct ether_header *eh = NULL;
roff = *r->r_roff;
woff = *r->r_woff;
@@ -804,16 +803,12 @@ txp_rx_reclaim(sc, r)
m->m_pkthdr.csum_data = 0xffff;
}
- eh = mtod(m, struct ether_header *);
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
-
if (rxd->rx_stat & RX_STAT_VLAN) {
- VLAN_INPUT_TAG(eh, m, htons(rxd->rx_vlan >> 16));
- goto next;
+ VLAN_INPUT_TAG(ifp,
+ m, htons(rxd->rx_vlan >> 16), goto next);
}
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
next:
@@ -1103,17 +1098,7 @@ txp_ioctl(ifp, command, data)
s = splnet();
- if ((error = ether_ioctl(ifp, command, data)) > 0) {
- splx(s);
- return error;
- }
-
switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_UP) {
txp_init(sc);
@@ -1136,7 +1121,7 @@ txp_ioctl(ifp, command, data)
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, command);
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
@@ -1314,7 +1299,7 @@ txp_start(ifp)
struct mbuf *m, *m0;
struct txp_swdesc *sd;
u_int32_t firstprod, firstcnt, prod, cnt;
- struct ifvlan *ifv;
+ struct m_tag *mtag;
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
return;
@@ -1351,11 +1336,10 @@ txp_start(ifp)
if (++cnt >= (TX_ENTRIES - 4))
goto oactive;
- if ((m->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) &&
- m->m_pkthdr.rcvif != NULL) {
- ifv = m->m_pkthdr.rcvif->if_softc;
+ mtag = VLAN_OUTPUT_TAG(ifp, m);
+ if (mtag != NULL) {
txd->tx_pflags = TX_PFLAGS_VLAN |
- (htons(ifv->ifv_tag) << TX_PFLAGS_VLANTAG_S);
+ (htons(VLAN_TAG_VALUE(mtag)) << TX_PFLAGS_VLANTAG_S);
}
if (m->m_pkthdr.csum_flags & CSUM_IP)
@@ -1394,8 +1378,7 @@ txp_start(ifp)
ifp->if_timer = 5;
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
WRITE_REG(sc, r->r_reg, TXP_IDX2OFFSET(prod));
}
@@ -1877,6 +1860,7 @@ txp_capabilities(sc)
if (rsp->rsp_par2 & rsp->rsp_par3 & OFFLOAD_VLAN) {
sc->sc_tx_capability |= OFFLOAD_VLAN;
sc->sc_rx_capability |= OFFLOAD_VLAN;
+ ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
}
#if 0
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c
index a2bf54a..fa80dd6 100644
--- a/sys/dev/usb/if_aue.c
+++ b/sys/dev/usb/if_aue.c
@@ -765,7 +765,7 @@ USB_ATTACH(aue)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->aue_stat_ch);
usb_register_netisr();
sc->aue_dying = 0;
@@ -786,7 +786,7 @@ aue_detach(device_ptr_t dev)
sc->aue_dying = 1;
untimeout(aue_tick, sc, sc->aue_stat_ch);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
if (sc->aue_ep[AUE_ENDPT_TX] != NULL)
usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);
@@ -1196,8 +1196,7 @@ aue_start(struct ifnet *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);
ifp->if_flags |= IFF_OACTIVE;
@@ -1367,11 +1366,6 @@ aue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
AUE_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 &&
@@ -1402,7 +1396,7 @@ aue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h
index 57ad525..97480e5 100644
--- a/sys/dev/usb/if_auereg.h
+++ b/sys/dev/usb/if_auereg.h
@@ -257,7 +257,6 @@ struct aue_softc {
#endif
#define AUE_TIMEOUT 1000
-#define ETHER_ALIGN 2
#define AUE_BUFSZ 1536
#define AUE_MIN_FRAMELEN 60
#define AUE_INTR_INTERVAL 100 /* ms */
diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c
index ab150df..8748a83 100644
--- a/sys/dev/usb/if_cue.c
+++ b/sys/dev/usb/if_cue.c
@@ -523,7 +523,7 @@ USB_ATTACH(cue)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->cue_stat_ch);
usb_register_netisr();
sc->cue_dying = 0;
@@ -544,7 +544,7 @@ cue_detach(device_ptr_t dev)
sc->cue_dying = 1;
untimeout(cue_tick, sc, sc->cue_stat_ch);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
if (sc->cue_ep[CUE_ENDPT_TX] != NULL)
usbd_abort_pipe(sc->cue_ep[CUE_ENDPT_TX]);
@@ -890,8 +890,7 @@ cue_start(struct ifnet *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);
ifp->if_flags |= IFF_OACTIVE;
@@ -1016,11 +1015,6 @@ cue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
CUE_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 &&
@@ -1048,7 +1042,7 @@ cue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
error = 0;
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
diff --git a/sys/dev/usb/if_cuereg.h b/sys/dev/usb/if_cuereg.h
index b875983..ae72d4f 100644
--- a/sys/dev/usb/if_cuereg.h
+++ b/sys/dev/usb/if_cuereg.h
@@ -116,7 +116,6 @@
#define CUE_MCAST_TABLE_LEN 64
#define CUE_TIMEOUT 1000
-#define ETHER_ALIGN 2
#define CUE_BUFSZ 1536
#define CUE_MIN_FRAMELEN 60
#define CUE_RX_FRAMES 1
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 8c50cf5..767d6fa 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -493,7 +493,7 @@ USB_ATTACH(kue)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->kue_desc.kue_macaddr);
usb_register_netisr();
sc->kue_dying = 0;
@@ -515,7 +515,7 @@ kue_detach(device_ptr_t dev)
sc->kue_dying = 1;
if (ifp != NULL)
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
if (sc->kue_ep[KUE_ENDPT_TX] != NULL)
usbd_abort_pipe(sc->kue_ep[KUE_ENDPT_TX]);
@@ -839,8 +839,7 @@ kue_start(struct ifnet *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);
ifp->if_flags |= IFF_OACTIVE;
@@ -953,11 +952,6 @@ kue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
KUE_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 &&
@@ -987,7 +981,7 @@ kue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
error = 0;
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
diff --git a/sys/dev/usb/if_kuereg.h b/sys/dev/usb/if_kuereg.h
index a72faad..1755e5c 100644
--- a/sys/dev/usb/if_kuereg.h
+++ b/sys/dev/usb/if_kuereg.h
@@ -110,7 +110,6 @@ struct kue_ether_desc {
#define KUE_RXFILT_MULTICAST 0x0010
#define KUE_TIMEOUT 1000
-#define ETHER_ALIGN 2
#define KUE_BUFSZ 1536
#define KUE_MIN_FRAMELEN 60
diff --git a/sys/dev/usb/usb_ethersubr.c b/sys/dev/usb/usb_ethersubr.c
index 100d93a..4e8daf3 100644
--- a/sys/dev/usb/usb_ethersubr.c
+++ b/sys/dev/usb/usb_ethersubr.c
@@ -80,7 +80,6 @@ Static void usbintr (void);
Static void usbintr()
{
- struct ether_header *eh;
struct mbuf *m;
struct usb_qdat *q;
struct ifnet *ifp;
@@ -90,12 +89,10 @@ Static void usbintr()
IF_DEQUEUE(&usbq_rx, m);
if (m == NULL)
break;
- eh = mtod(m, struct ether_header *);
q = (struct usb_qdat *)m->m_pkthdr.rcvif;
ifp = q->ifp;
m->m_pkthdr.rcvif = ifp;
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
/* Re-arm the receiver */
(*q->if_rxstart)(ifp);
diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c
index 2062cda..143a821 100644
--- a/sys/dev/vx/if_vx.c
+++ b/sys/dev/vx/if_vx.c
@@ -164,7 +164,7 @@ vxattach(sc)
ifp->if_watchdog = vxwatchdog;
ifp->if_softc = sc;
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
sc->tx_start_thresh = 20; /* probably a good starting point. */
@@ -441,9 +441,7 @@ startagain:
CSR_WRITE_2(sc, VX_COMMAND, SET_TX_START_THRESH |
((len / 4 + sc->tx_start_thresh) >> 2));
- if (sc->arpcom.ac_if.if_bpf) {
- bpf_mtap(&sc->arpcom.ac_if, m);
- }
+ BPF_MTAP(&sc->arpcom.ac_if, m);
/*
* Do the output at splhigh() so that an interrupt from another device
@@ -714,8 +712,7 @@ again:
return;
}
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
/*
* In periods of high traffic we can actually receive enough
@@ -855,11 +852,6 @@ vxioctl(ifp, cmd, data)
s = splimp();
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- ether_ioctl(ifp, cmd, data);
- break;
-
case SIOCSIFFLAGS:
if ((ifp->if_flags & IFF_UP) == 0 &&
(ifp->if_flags & IFF_RUNNING) != 0) {
@@ -910,7 +902,8 @@ vxioctl(ifp, cmd, data)
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, cmd, data);
+ break;
}
splx(s);
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index 2ffe11f..2ed6cc2 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -211,7 +211,7 @@ wi_generic_detach(dev)
/* Delete all remaining media. */
ifmedia_removeall(&sc->ifmedia);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
wi_free(dev);
sc->wi_gone = 1;
@@ -469,7 +469,7 @@ wi_generic_attach(device_t dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
callout_handle_init(&sc->wi_stat_ch);
WI_UNLOCK(sc, s);
@@ -675,8 +675,7 @@ wi_rxeof(sc)
ifp->if_ipackets++;
/* Handle BPF listeners. */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
m_freem(m);
} else {
@@ -816,11 +815,10 @@ wi_rxeof(sc)
return;
}
/* Receive packet. */
- m_adj(m, sizeof(struct ether_header));
#ifdef WICACHE
wi_cache_store(sc, eh, m, rx_frame.wi_q_info);
#endif
- ether_input(ifp, eh, m);
+ (*ifp->if_input)(ifp, m);
}
}
@@ -1679,11 +1677,6 @@ wi_ioctl(ifp, command, data)
}
switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
case SIOCSIFFLAGS:
/*
* Can't do promisc and hostap at the same time. If all that's
@@ -2047,7 +2040,7 @@ wi_ioctl(ifp, command, data)
error = wihap_ioctl(sc, command, data);
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
break;
}
out:
@@ -2405,8 +2398,8 @@ nextpkt:
* this frame to him. Also, don't send this to the bpf sniffer
* if we're in procframe or monitor sniffing mode.
*/
- if (!(sc->wi_procframe || sc->wi_debug.wi_monitor) && ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ if (!(sc->wi_procframe || sc->wi_debug.wi_monitor))
+ BPF_MTAP(ifp, m0);
m_freem(m0);
diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c
index dbd449b..925d64d 100644
--- a/sys/dev/wl/if_wl.c
+++ b/sys/dev/wl/if_wl.c
@@ -505,7 +505,7 @@ wlattach(struct isa_device *id)
ifp->if_done
ifp->if_reset
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, &sc->wl_addr[0]);
bcopy(&sc->wl_addr[0], sc->wl_ac.ac_enaddr, WAVELAN_ADDR_SIZE);
printf("%s%d: address %6D, NWID 0x%02x%02x", ifp->if_name, ifp->if_unit,
@@ -886,9 +886,7 @@ wlstart(struct ifnet *ifp)
IF_DEQUEUE(&ifp->if_snd, m);
if (m != (struct mbuf *)0) {
/* let BPF see it before we commit it */
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- }
+ BPF_MTAP(ifp, m);
sc->tbusy++;
/* set the watchdog timer so that if the board
* fails to interrupt we will restart
@@ -929,45 +927,33 @@ wlread(int unit, u_short fd_p)
register struct ifnet *ifp = &sc->wl_if;
short base = sc->base;
fd_t fd;
- struct ether_header eh;
- struct mbuf *m, *tm;
+ struct ether_header *eh;
+ struct mbuf *m;
rbd_t rbd;
u_char *mb_p;
- u_short mlen, len, clen;
+ u_short mlen, len;
u_short bytes_in_msg, bytes_in_mbuf, bytes;
#ifdef WLDEBUG
if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlread()\n",unit);
+ printf("wl%d: entered wlread()\n", unit);
#endif
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
- printf("wl%d read(): board is not running.\n", ifp->if_unit);
+ printf("wl%d read(): board is not running.\n", unit);
sc->hacr &= ~HACR_INTRON;
CMD(unit); /* turn off interrupts */
}
- /* read ether_header info out of device memory. doesn't
- * go into mbuf. goes directly into eh structure
- */
- len = sizeof(struct ether_header); /* 14 bytes */
- outw(PIOR1(base), fd_p);
- insw(PIOP1(base), &fd, (sizeof(fd_t) - len)/2);
- insw(PIOP1(base), &eh, (len-2)/2);
- eh.ether_type = ntohs(inw(PIOP1(base)));
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG) {
- printf("wlread: rcv packet, type is %x\n", eh.ether_type);
- }
-#endif
+
/*
- * WARNING. above is done now in ether_input, above may be
- * useful for debug. jrb
+ * Collect message size.
*/
- eh.ether_type = htons(eh.ether_type);
-
+ outw(PIOR1(base), fd_p);
+ insw(PIOP1(base), &fd, sizeof(fd_t)/2);
if (fd.rbd_offset == I82586NULL) {
- printf("wl%d read(): Invalid buffer\n", unit);
if (wlhwrst(unit) != TRUE) {
+ sc->hacr &= ~HACR_INTRON;
+ CMD(unit); /* turn off interrupts */
printf("wl%d read(): hwrst trouble.\n", unit);
}
return 0;
@@ -976,14 +962,12 @@ wlread(int unit, u_short fd_p)
outw(PIOR1(base), fd.rbd_offset);
insw(PIOP1(base), &rbd, sizeof(rbd_t)/2);
bytes_in_msg = rbd.status & RBD_SW_COUNT;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- tm = m;
- if (m == (struct mbuf *)0) {
- /*
- * not only do we want to return, we need to drop the packet on
- * the floor to clear the interrupt.
- *
- */
+
+ /*
+ * Allocate a cluster'd mbuf to receive the packet.
+ */
+ m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+ if (m == NULL) {
if (wlhwrst(unit) != TRUE) {
sc->hacr &= ~HACR_INTRON;
CMD(unit); /* turn off interrupts */
@@ -991,31 +975,15 @@ wlread(int unit, u_short fd_p)
}
return 0;
}
- m->m_next = (struct mbuf *) 0;
- m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = 0; /* don't know this yet */
- m->m_len = MHLEN;
+ m->m_pkthdr.len = m->m_len = MCLBYTES;
+ m_adj(m, ETHER_ALIGN); /* align IP header */
- /* always use a cluster. jrb
+ /*
+ * Collect the message data.
*/
- MCLGET(m, M_DONTWAIT);
- if (m->m_flags & M_EXT) {
- m->m_len = MCLBYTES;
- }
- else {
- m_freem(m);
- if (wlhwrst(unit) != TRUE) {
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- printf("wl%d read(): hwrst trouble.\n", unit);
- }
- return 0;
- }
-
mlen = 0;
- clen = mlen;
- bytes_in_mbuf = m->m_len;
- mb_p = mtod(tm, u_char *);
+ mb_p = mtod(m, u_char *);
+ bytes_in_mbuf = MCLBYTES;
bytes = min(bytes_in_mbuf, bytes_in_msg);
for (;;) {
if (bytes & 1) {
@@ -1025,40 +993,29 @@ wlread(int unit, u_short fd_p)
}
outw(PIOR1(base), rbd.buffer_addr);
insw(PIOP1(base), mb_p, len/2);
- clen += bytes;
mlen += bytes;
- if (!(bytes_in_mbuf -= bytes)) {
- MGET(tm->m_next, M_DONTWAIT, MT_DATA);
- tm = tm->m_next;
- if (tm == (struct mbuf *)0) {
- m_freem(m);
- printf("wl%d read(): No mbuf nth\n", unit);
- if (wlhwrst(unit) != TRUE) {
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- printf("wl%d read(): hwrst trouble.\n", unit);
- }
- return 0;
+ if (bytes > bytes_in_mbuf) {
+ /* XXX something wrong, a packet should fit in 1 cluster */
+ m_freem(m);
+ printf("wl%d read(): packet too large (%u > %u)\n",
+ unit, bytes, bytes_in_mbuf);
+ if (wlhwrst(unit) != TRUE) {
+ sc->hacr &= ~HACR_INTRON;
+ CMD(unit); /* turn off interrupts */
+ printf("wl%d read(): hwrst trouble.\n", unit);
}
- mlen = 0;
- tm->m_len = MLEN;
- bytes_in_mbuf = MLEN;
- mb_p = mtod(tm, u_char *);
- } else {
- mb_p += bytes;
+ return 0;
}
-
- if (!(bytes_in_msg -= bytes)) {
- if (rbd.status & RBD_SW_EOF ||
- rbd.next_rbd_offset == I82586NULL) {
- tm->m_len = mlen;
+ mb_p += bytes;
+ bytes_in_msg -= bytes;
+ if (bytes_in_msg == 0) {
+ if (rbd.status & RBD_SW_EOF || rbd.next_rbd_offset == I82586NULL) {
break;
- } else {
- outw(PIOR1(base), rbd.next_rbd_offset);
- insw(PIOP1(base), &rbd, sizeof(rbd_t)/2);
- bytes_in_msg = rbd.status & RBD_SW_COUNT;
}
+ outw(PIOR1(base), rbd.next_rbd_offset);
+ insw(PIOP1(base), &rbd, sizeof(rbd_t)/2);
+ bytes_in_msg = rbd.status & RBD_SW_COUNT;
} else {
rbd.buffer_addr += bytes;
}
@@ -1066,7 +1023,8 @@ wlread(int unit, u_short fd_p)
bytes = min(bytes_in_mbuf, bytes_in_msg);
}
- m->m_pkthdr.len = clen;
+ m->m_pkthdr.len = m->m_len = mlen;
+ m->m_pkthdr.rcvif = ifp;
/*
* If hw is in promiscuous mode (note that I said hardware, not if
@@ -1081,6 +1039,8 @@ wlread(int unit, u_short fd_p)
* However, there does not appear to be a way to read the nwid
* for a received packet. -gdt 1998-08-07
*/
+ /* XXX verify mbuf length */
+ eh = mtod(m, struct ether_header *);
if (
#ifdef WL_USE_IFNET_PROMISC_CHECK /* not defined */
(sc->wl_ac.ac_if.if_flags & (IFF_PROMISC|IFF_ALLMULTI))
@@ -1089,28 +1049,27 @@ wlread(int unit, u_short fd_p)
(sc->mode & (MOD_PROM | MOD_ENAL))
#endif
&&
- (eh.ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
- bcmp(eh.ether_dhost, sc->wl_ac.ac_enaddr,
- sizeof(eh.ether_dhost)) != 0 ) {
+ (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
+ bcmp(eh->ether_dhost, sc->wl_ac.ac_enaddr,
+ sizeof(eh->ether_dhost)) != 0 ) {
m_freem(m);
return 1;
}
#ifdef WLDEBUG
if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: wlrecv %d bytes\n", unit, clen);
+ printf("wl%d: wlrecv %u bytes\n", unit, mlen);
#endif
#ifdef WLCACHE
- wl_cache_store(unit, base, &eh, m);
+ wl_cache_store(unit, base, eh, m);
#endif
/*
* received packet is now in a chain of mbuf's. next step is
* to pass the packet upwards.
- *
*/
- ether_input(&sc->wl_if, &eh, m);
+ (*ifp->if_input)(ifp, m);
return 1;
}
@@ -1149,12 +1108,6 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
#endif
opri = splimp();
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
-
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_ALLMULTI) {
mode |= MOD_ENAL;
@@ -1349,7 +1302,8 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
#endif
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, cmd, data);
+ break;
}
splx(opri);
return (error);
diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c
index df5262e..bbbf095 100644
--- a/sys/dev/xe/if_xe.c
+++ b/sys/dev/xe/if_xe.c
@@ -289,7 +289,7 @@ xe_attach (device_t dev)
device_printf(dev, "Ethernet address %6D\n", scp->arpcom.ac_enaddr, ":");
/* Attach the interface */
- ether_ifattach(scp->ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(scp->ifp, scp->arpcom.ac_enaddr);
/* Done */
return 0;
@@ -416,12 +416,7 @@ xe_start(struct ifnet *ifp) {
}
/* Tap off here if there is a bpf listener */
- if (ifp->if_bpf) {
-#if XE_DEBUG > 1
- device_printf(scp->dev, "sending output packet to BPF\n");
-#endif
- bpf_mtap(ifp, mbp);
- }
+ BPF_MTAP(ifp, mbp);
ifp->if_timer = 5; /* In case we don't hear from the card again */
scp->tx_queued++;
@@ -446,12 +441,6 @@ xe_ioctl (register struct ifnet *ifp, u_long 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. If it is
@@ -489,7 +478,7 @@ xe_ioctl (register struct ifnet *ifp, u_long command, caddr_t data) {
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
}
(void)splx(s);
@@ -729,9 +718,8 @@ xe_intr(void *xscp)
/* Deliver packet to upper layers */
if (mbp != NULL) {
- mbp->m_pkthdr.len = mbp->m_len = len - ETHER_HDR_LEN;
- mbp->m_data += ETHER_HDR_LEN; /* Strip off Ethernet header */
- ether_input(ifp, ehp, mbp); /* Send the packet on its way */
+ mbp->m_pkthdr.len = mbp->m_len = len;
+ (*ifp->if_input)(ifp, mbp); /* Send the packet on its way */
ifp->if_ipackets++; /* Success! */
}
XE_OUTW(XE_DO, 0x8000); /* skip_rx_packet command */
diff --git a/sys/dev/xe/if_xe_pccard.c b/sys/dev/xe/if_xe_pccard.c
index e86ee32..bd1fe61 100644
--- a/sys/dev/xe/if_xe_pccard.c
+++ b/sys/dev/xe/if_xe_pccard.c
@@ -301,7 +301,7 @@ xe_pccard_detach(device_t dev)
struct xe_softc *sc = device_get_softc(dev);
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(&sc->arpcom.ac_if);
xe_deactivate(dev);
return (0);
}
OpenPOWER on IntegriCloud