Make all Ethernet drivers attach using ether_ifattach() and detach using

ether_ifdetach().

The former consolidates the operations of if_attach(), ng_ether_attach(),
and bpfattach(). The latter consolidates the corresponding detach operations.

Reviewed by:	julian, freebsd-net
This commit is contained in:
Archie Cobbs 2000-07-13 22:54:34 +00:00
parent 4a19005c48
commit 21b8ebd926
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=63090
61 changed files with 143 additions and 282 deletions

View File

@ -221,10 +221,7 @@ am7990_config(sc)
printf("%s: address %s\n", device_get_nameunit(sc->sc_dev),
ether_sprintf(sc->sc_enaddr));
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
switch (sc->sc_memsize) {
case 8192:

View File

@ -369,12 +369,10 @@ int an_attach(sc, unit, flags)
bzero((char *)&sc->an_stats, sizeof(sc->an_stats));
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->an_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return(0);
}

View File

@ -131,7 +131,7 @@ an_detach_isa(device_t dev)
struct ifnet *ifp = &sc->arpcom.ac_if;
an_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);

View File

@ -105,7 +105,7 @@ an_pccard_detach(device_t dev)
}
an_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
sc->an_gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);

View File

@ -198,7 +198,7 @@ an_detach_pci(device_t dev)
struct ifnet *ifp = &sc->arpcom.ac_if;
an_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);

View File

@ -308,13 +308,10 @@ awi_attach(sc)
sc->sc_dev.dv_xname,
sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH ? "FH" : "DS",
sc->sc_tx_rate / 10, ether_sprintf(sc->sc_mib_addr.aMAC_Address));
if_attach(ifp);
#ifdef __FreeBSD__
ether_ifattach(ifp);
#if NBPFILTER > 0
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#else
if_attach(ifp);
ether_ifattach(ifp, sc->sc_mib_addr.aMAC_Address);
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));

View File

@ -198,7 +198,7 @@ awi_pccard_detach(device_t dev)
struct awi_softc *sc = &psc->sc_awi;
struct ifnet *ifp = &sc->sc_ec.ac_if;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
ifp->if_flags &= ~IFF_RUNNING;
if (psc->sc_intrhand) {
bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand);

View File

@ -796,15 +796,13 @@ cs_attach(struct cs_softc *sc, int unit, int flags)
ifmedia_set(&sc->media, media);
cs_mediaset(sc, media);
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
}
if (bootverbose)
printf(CS_NAME"%d: ethernet address %6D\n",
ifp->if_unit, sc->arpcom.ac_enaddr, ":");
bpfattach(ifp, DLT_EN10MB, sizeof (struct ether_header));
return (0);
}

View File

@ -1727,14 +1727,11 @@ static int dc_attach(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->dc_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
#ifdef __alpha__
sc->dc_srm_media = 0;
@ -1781,7 +1778,7 @@ static int dc_detach(dev)
ifp = &sc->arpcom.ac_if;
dc_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->dc_miibus);

View File

@ -4874,11 +4874,8 @@ tulip_attach(
tulip_reset(sc);
if_attach(ifp);
ether_ifattach(&(sc)->tulip_if, ETHER_BPF_SUPPORTED);
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ether_ifattach(&(sc)->tulip_if);
bpfattach(&sc->tulip_if, DLT_EN10MB, sizeof(struct ether_header));
}
#if defined(TULIP_BUS_DMA)

View File

@ -1642,8 +1642,7 @@ ed_attach(sc, unit, flags)
/*
* Attach the interface
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
}
/* device attach does transition from UNCONFIGURED to IDLE state */
@ -1669,10 +1668,6 @@ ed_attach(sc, unit, flags)
(sc->vendor == ED_VENDOR_HP)) &&
(ifp->if_flags & IFF_ALTPHYS)) ? " tranceiver disabled" : "");
/*
* If BPF is in the kernel, call the attach for it
*/
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return (0);
}

View File

@ -91,7 +91,7 @@ ed_pccard_detach(device_t dev)
}
ed_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
ed_release_resources(dev);

View File

@ -316,11 +316,8 @@ ep_attach(sc)
ep_ifmedia_upd(ifp);
}
if (!attached) {
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
}
if (!attached)
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#ifdef EP_LOCAL_STATS
sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =

View File

@ -48,6 +48,7 @@
#include <machine/resource.h>
#include <sys/rman.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
@ -227,7 +228,7 @@ ep_pccard_detach(device_t dev)
return (0);
}
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
if_detach(&sc->arpcom.ac_if);
ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq, sc->ep_intrhand);
ep_free(dev);

View File

@ -264,15 +264,10 @@ ex_attach(device_t dev)
/*
* Attach the interface.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
device_printf(sc->dev, "Ethernet address %6D\n",
sc->arpcom.ac_enaddr, ":");
/*
* If BPF is in the kernel, call the attach for it
*/
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return(0);
}

View File

@ -2849,14 +2849,13 @@ fe_attach ( struct isa_device * dev )
/* Attach and stop the interface. */
#if NCARD > 0
if (already_ifattach[dev->id_unit] != 1) {
if_attach(&sc->sc_if);
ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED);
already_ifattach[dev->id_unit] = 1;
}
#else
if_attach(&sc->sc_if);
ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED);
#endif
fe_stop(sc);
ether_ifattach(&sc->sc_if);
/* Print additional info when attached. */
printf("fe%d: address %6D, type %s%s\n", sc->sc_unit,
@ -2905,8 +2904,6 @@ fe_attach ( struct isa_device * dev )
sc->sc_unit);
}
/* If BPF is in the kernel, call the attach for it. */
bpfattach(&sc->sc_if, DLT_EN10MB, sizeof(struct ether_header));
return 1;
}

View File

@ -598,14 +598,12 @@ fxp_attach(device_t dev)
/*
* Attach the interface.
*/
if_attach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
/*
* Let the system queue as many packets as we have available
* TX descriptors.
*/
ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1;
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
splx(s);
return 0;
@ -629,7 +627,7 @@ fxp_detach(device_t dev)
/*
* Close down routes etc.
*/
if_detach(&sc->arpcom.ac_if);
ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
/*
* Stop DMA and drop transmit queue.

View File

@ -792,10 +792,7 @@ ieattach(struct isa_device *dvp)
EVENTHANDLER_REGISTER(shutdown_post_sync, ee16_shutdown,
ie, SHUTDOWN_PRI_DEFAULT);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
return (1);
}

View File

@ -895,12 +895,7 @@ lnc_attach_sc(lnc_softc_t *sc, int unit)
sc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN;
sc->arpcom.ac_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
/*
* XXX -- should check return status of if_attach
*/
if_attach(&sc->arpcom.ac_if);
ether_ifattach(&sc->arpcom.ac_if);
ether_ifattach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
printf("lnc%d: ", unit);
if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
@ -910,8 +905,6 @@ lnc_attach_sc(lnc_softc_t *sc, int unit)
printf("%s", ic_ident[sc->nic.ic]);
printf(" address %6D\n", sc->arpcom.ac_enaddr, ":");
bpfattach(&sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header));
return (1);
}

View File

@ -315,8 +315,8 @@ lnc_attach(struct isa_device * isa_dev)
#ifndef PC98
/*
* XXX - is it safe to call isa_dmacascade() after if_attach()
* and ether_ifattach() have been called in lnc_attach() ???
* XXX - is it safe to call isa_dmacascade() after
* ether_ifattach() has been called in lnc_attach() ???
*/
if ((sc->nic.mem_mode != SHMEM) &&
(sc->nic.ic < PCnet_32))

View File

@ -829,12 +829,9 @@ static int sf_attach(dev)
ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -853,7 +850,7 @@ static int sf_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
sf_stop(sc);
bus_generic_detach(dev);

View File

@ -1221,12 +1221,10 @@ static int sk_attach_xmac(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc_if->sk_tick_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return(0);
}
@ -1431,7 +1429,7 @@ static int sk_detach_xmac(dev)
sc_if = device_get_softc(dev);
ifp = &sc_if->arpcom.ac_if;
sk_stop(sc_if);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
if (sc_if->sk_miibus != NULL)
device_delete_child(dev, sc_if->sk_miibus);

View File

@ -222,8 +222,7 @@ sn_attach(device_t dev)
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_timer = 0;
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
/*
* Fill the hardware address into ifa_addr if we find an AF_LINK
@ -243,8 +242,6 @@ sn_attach(device_t dev)
bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN);
}
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return 0;
}

View File

@ -90,7 +90,7 @@ sn_pccard_detach(device_t dev)
struct sn_softc *sc = device_get_softc(dev);
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
if_detach(&sc->arpcom.ac_if);
ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
sn_deactivate(dev);
return 0;
}

View File

@ -1722,12 +1722,9 @@ static int ti_attach(dev)
ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO);
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -1747,7 +1744,7 @@ static int ti_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
ti_stop(sc);
bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);

View File

@ -550,12 +550,9 @@ epic_freebsd_attach(dev)
printf ("\n");
/* Attach to OS's managers */
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
fail:
splx(s);
@ -578,8 +575,7 @@ epic_freebsd_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
bpfdetach(ifp);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
epic_stop(sc);

View File

@ -736,12 +736,10 @@ USB_ATTACH(aue)
aue_qdat.if_rxstart = aue_rxstart;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->aue_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
usb_register_netisr();
sc->aue_gone = 0;
@ -763,8 +761,7 @@ Static int aue_detach(dev)
sc->aue_gone = 1;
untimeout(aue_tick, sc, sc->aue_stat_ch);
bpfdetach(ifp);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
if (sc->aue_ep[AUE_ENDPT_TX] != NULL)
usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);

View File

@ -555,12 +555,10 @@ USB_ATTACH(cue)
cue_qdat.if_rxstart = cue_rxstart;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->cue_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
usb_register_netisr();
sc->cue_gone = 0;
@ -582,8 +580,7 @@ Static int cue_detach(dev)
sc->cue_gone = 1;
untimeout(cue_tick, sc, sc->cue_stat_ch);
bpfdetach(ifp);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
if (sc->cue_ep[CUE_ENDPT_TX] != NULL)
usbd_abort_pipe(sc->cue_ep[CUE_ENDPT_TX]);

View File

@ -500,11 +500,9 @@ USB_ATTACH(kue)
kue_qdat.if_rxstart = kue_rxstart;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
usb_register_netisr();
sc->kue_gone = 0;
@ -526,10 +524,8 @@ Static int kue_detach(dev)
sc->kue_gone = 1;
if (ifp != NULL) {
bpfdetach(ifp);
if_detach(ifp);
}
if (ifp != NULL)
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
if (sc->kue_ep[KUE_ENDPT_TX] != NULL)
usbd_abort_pipe(sc->kue_ep[KUE_ENDPT_TX]);

View File

@ -800,12 +800,9 @@ static int vr_attach(dev)
callout_handle_init(&sc->vr_stat_ch);
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -825,7 +822,7 @@ static int vr_detach(dev)
ifp = &sc->arpcom.ac_if;
vr_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->vr_miibus);

View File

@ -210,10 +210,7 @@ vxattach(sc)
ifp->if_watchdog = vxwatchdog;
ifp->if_softc = sc;
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
sc->tx_start_thresh = 20; /* probably a good starting point. */

View File

@ -216,8 +216,7 @@ static int wi_pccard_detach(dev)
wi_stop(sc);
bpfdetach(ifp);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
wi_free(dev);
sc->wi_gone = 1;
@ -327,12 +326,10 @@ static int wi_pccard_attach(device_t dev)
wi_stop(sc);
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->wi_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return(0);
}

View File

@ -515,10 +515,7 @@ wlattach(struct isa_device *id)
ifp->if_done
ifp->if_reset
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
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,

View File

@ -479,7 +479,7 @@ xe_detach(device_t dev) {
struct xe_softc *sc = device_get_softc(dev);
sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
if_detach(&sc->arpcom.ac_if);
ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
xe_deactivate(dev);
return 0;
}
@ -578,14 +578,7 @@ xe_attach (device_t dev) {
device_printf(dev, "Ethernet address %6D\n", scp->arpcom.ac_enaddr, ":");
/* Attach the interface */
if_attach(scp->ifp);
ether_ifattach(scp->ifp);
/* BPF is in the kernel, call the attach for it */
#if XE_DEBUG > 1
device_printf(dev, "BPF listener attached\n");
#endif
bpfattach(scp->ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(scp->ifp, ETHER_BPF_SUPPORTED);
/* Done */
return 0;

View File

@ -202,17 +202,12 @@ el_attach(struct isa_device *idev)
/* Now we can attach the interface */
dprintf(("Attaching interface...\n"));
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
/* Print out some information for the user */
printf("el%d: 3c501 address %6D\n",idev->id_unit,
sc->arpcom.ac_enaddr, ":");
/* Finally, attach to bpf filter if it is present. */
dprintf(("Attaching to BPF...\n"));
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
dprintf(("el_attach() finished.\n"));
return(1);
}

View File

@ -2849,14 +2849,13 @@ fe_attach ( struct isa_device * dev )
/* Attach and stop the interface. */
#if NCARD > 0
if (already_ifattach[dev->id_unit] != 1) {
if_attach(&sc->sc_if);
ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED);
already_ifattach[dev->id_unit] = 1;
}
#else
if_attach(&sc->sc_if);
ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED);
#endif
fe_stop(sc);
ether_ifattach(&sc->sc_if);
/* Print additional info when attached. */
printf("fe%d: address %6D, type %s%s\n", sc->sc_unit,
@ -2905,8 +2904,6 @@ fe_attach ( struct isa_device * dev )
sc->sc_unit);
}
/* If BPF is in the kernel, call the attach for it. */
bpfattach(&sc->sc_if, DLT_EN10MB, sizeof(struct ether_header));
return 1;
}

View File

@ -361,10 +361,7 @@ le_attach(
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
return 1;
}

View File

@ -614,8 +614,7 @@ rdp_attach(struct isa_device *isa_dev)
/*
* Attach the interface
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
}
/*
@ -629,10 +628,6 @@ rdp_attach(struct isa_device *isa_dev)
printf("%s%d: address %6D\n", ifp->if_name, ifp->if_unit,
sc->arpcom.ac_enaddr, ":");
/*
* If BPF is in the kernel, call the attach for it
*/
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return 1;
}

View File

@ -216,8 +216,7 @@ static int wi_pccard_detach(dev)
wi_stop(sc);
bpfdetach(ifp);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
wi_free(dev);
sc->wi_gone = 1;
@ -327,12 +326,10 @@ static int wi_pccard_attach(device_t dev)
wi_stop(sc);
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->wi_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return(0);
}

View File

@ -515,10 +515,7 @@ wlattach(struct isa_device *id)
ifp->if_done
ifp->if_reset
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
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,

View File

@ -82,6 +82,12 @@ struct ether_addr {
#ifdef _KERNEL
/*
* For device drivers to specify whether they support BPF or not
*/
#define ETHER_BPF_UNSUPPORTED 0
#define ETHER_BPF_SUPPORTED 1
struct ifnet;
struct mbuf;

View File

@ -128,9 +128,7 @@ ef_attach(struct efnet *sc)
/*
* Attach the interface
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
ifp->if_resolvemulti = 0;
ifp->if_type = IFT_XETHER;

View File

@ -646,12 +646,14 @@ ether_demux(ifp, eh, m)
* Perform common duties while attaching to interface list
*/
void
ether_ifattach(ifp)
ether_ifattach(ifp, bpf)
register struct ifnet *ifp;
int bpf;
{
register struct ifaddr *ifa;
register struct sockaddr_dl *sdl;
if_attach(ifp);
ifp->if_type = IFT_ETHER;
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
@ -660,18 +662,32 @@ ether_ifattach(ifp)
if (ifp->if_baudrate == 0)
ifp->if_baudrate = 10000000;
ifa = ifnet_addrs[ifp->if_index - 1];
if (ifa == 0) {
printf("ether_ifattach: no lladdr!\n");
return;
}
KASSERT(ifa != NULL, ("%s: no lladdr!\n", __FUNCTION__));
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
sdl->sdl_type = IFT_ETHER;
sdl->sdl_alen = ifp->if_addrlen;
bcopy((IFP2AC(ifp))->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
if (bpf)
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
if (ng_ether_attach_p != NULL)
(*ng_ether_attach_p)(ifp);
}
/*
* Perform common duties while detaching an Ethernet interface
*/
void
ether_ifdetach(ifp, bpf)
struct ifnet *ifp;
int bpf;
{
if (ng_ether_detach_p != NULL)
(*ng_ether_detach_p)(ifp);
if (bpf)
bpfdetach(ifp);
if_detach(ifp);
}
SYSCTL_DECL(_net_link);
SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");

View File

@ -323,7 +323,8 @@ extern struct ifnet loif[];
extern int if_index;
extern struct ifaddr **ifnet_addrs;
void ether_ifattach __P((struct ifnet *));
void ether_ifattach __P((struct ifnet *, int));
void ether_ifdetach __P((struct ifnet *, int));
void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
void ether_demux __P((struct ifnet *, struct ether_header *, struct mbuf *));
int ether_output __P((struct ifnet *,

View File

@ -170,9 +170,7 @@ vlaninit(void *dummy)
ifp->if_ioctl = vlan_ioctl;
ifp->if_output = ether_output;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
/* Now undo some of the damage... */
ifp->if_data.ifi_type = IFT_8021_VLAN;
ifp->if_data.ifi_hdrlen = EVL_ENCAPLEN;

View File

@ -2477,8 +2477,7 @@ ed_attach(sc, unit, flags)
/*
* Attach the interface
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
}
/* device attach does transition from UNCONFIGURED to IDLE state */
@ -2504,10 +2503,6 @@ ed_attach(sc, unit, flags)
(sc->vendor == ED_VENDOR_HP)) &&
(ifp->if_flags & IFF_ALTPHYS)) ? " tranceiver disabled" : "");
/*
* If BPF is in the kernel, call the attach for it
*/
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return 1;
}

View File

@ -1727,14 +1727,11 @@ static int dc_attach(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->dc_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
#ifdef __alpha__
sc->dc_srm_media = 0;
@ -1781,7 +1778,7 @@ static int dc_detach(dev)
ifp = &sc->arpcom.ac_if;
dc_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->dc_miibus);

View File

@ -4874,11 +4874,8 @@ tulip_attach(
tulip_reset(sc);
if_attach(ifp);
ether_ifattach(&(sc)->tulip_if, ETHER_BPF_SUPPORTED);
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ether_ifattach(&(sc)->tulip_if);
bpfattach(&sc->tulip_if, DLT_EN10MB, sizeof(struct ether_header));
}
#if defined(TULIP_BUS_DMA)

View File

@ -598,14 +598,12 @@ fxp_attach(device_t dev)
/*
* Attach the interface.
*/
if_attach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
/*
* Let the system queue as many packets as we have available
* TX descriptors.
*/
ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1;
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
splx(s);
return 0;
@ -629,7 +627,7 @@ fxp_detach(device_t dev)
/*
* Close down routes etc.
*/
if_detach(&sc->arpcom.ac_if);
ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
/*
* Stop DMA and drop transmit queue.

View File

@ -956,12 +956,9 @@ static int rl_attach(dev)
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -980,7 +977,7 @@ static int rl_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
rl_stop(sc);
bus_generic_detach(dev);

View File

@ -829,12 +829,9 @@ static int sf_attach(dev)
ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -853,7 +850,7 @@ static int sf_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
sf_stop(sc);
bus_generic_detach(dev);

View File

@ -844,14 +844,11 @@ static int sis_attach(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->sis_stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
fail:
splx(s);
return(error);
@ -871,7 +868,7 @@ static int sis_detach(dev)
sis_reset(sc);
sis_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->sis_miibus);

View File

@ -1221,12 +1221,10 @@ static int sk_attach_xmac(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc_if->sk_tick_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
return(0);
}
@ -1431,7 +1429,7 @@ static int sk_detach_xmac(dev)
sc_if = device_get_softc(dev);
ifp = &sc_if->arpcom.ac_if;
sk_stop(sc_if);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
if (sc_if->sk_miibus != NULL)
device_delete_child(dev, sc_if->sk_miibus);

View File

@ -1068,13 +1068,9 @@ static int ste_attach(dev)
ifp->if_snd.ifq_maxlen = STE_TX_LIST_CNT - 1;
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -1094,7 +1090,7 @@ static int ste_detach(dev)
ifp = &sc->arpcom.ac_if;
ste_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->ste_miibus);

View File

@ -1722,12 +1722,9 @@ static int ti_attach(dev)
ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO);
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -1747,7 +1744,7 @@ static int ti_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
ti_stop(sc);
bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);

View File

@ -1335,12 +1335,9 @@ static int tl_attach(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -1360,7 +1357,7 @@ static int tl_detach(dev)
ifp = &sc->arpcom.ac_if;
tl_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->tl_miibus);

View File

@ -550,12 +550,9 @@ epic_freebsd_attach(dev)
printf ("\n");
/* Attach to OS's managers */
if_attach(ifp);
ether_ifattach(ifp);
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->stat_ch);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
fail:
splx(s);
@ -578,8 +575,7 @@ epic_freebsd_detach(dev)
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
bpfdetach(ifp);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
epic_stop(sc);

View File

@ -800,12 +800,9 @@ static int vr_attach(dev)
callout_handle_init(&sc->vr_stat_ch);
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -825,7 +822,7 @@ static int vr_detach(dev)
ifp = &sc->arpcom.ac_if;
vr_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
bus_generic_detach(dev);
device_delete_child(dev, sc->vr_miibus);

View File

@ -967,12 +967,9 @@ static int wb_attach(dev)
}
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
if (error)
@ -995,7 +992,7 @@ static int wb_detach(dev)
ifp = &sc->arpcom.ac_if;
wb_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
/* Delete any miibus and phy devices attached to this interface */
bus_generic_detach(dev);

View File

@ -629,10 +629,8 @@ wx_attach(device_t dev)
ifp->if_ioctl = wx_ioctl;
ifp->if_start = wx_start;
ifp->if_watchdog = wx_txwatchdog;
if_attach(ifp);
ifp->if_snd.ifq_maxlen = WX_MAX_TDESC - 1;
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
tmp = wxlist;
if (tmp) {
while (tmp->wx_next)
@ -651,7 +649,7 @@ wx_detach(device_t dev)
{
wx_softc_t *sc = device_get_softc(dev);
int s = splimp();
if_detach(&sc->w.arpcom.ac_if);
ether_ifdetach(&sc->w.arpcom.ac_if, ETHER_BPF_SUPPORTED);
wx_stop(sc);
bus_teardown_intr(dev, sc->w.irq, sc->w.ih);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->w.irq);

View File

@ -1491,12 +1491,9 @@ static int xl_attach(dev)
done:
/*
* Call MI attach routines.
* Call MI attach routine.
*/
if_attach(ifp);
ether_ifattach(ifp);
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
fail:
splx(s);
@ -1517,7 +1514,7 @@ static int xl_detach(dev)
xl_reset(sc);
xl_stop(sc);
if_detach(ifp);
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
/* Delete any miibus and phy devices attached to this interface */
if (sc->xl_miibus != NULL) {