summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
committerbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
commit567ba9b00a248431e7c1147c4e079fd7a11b9ecf (patch)
treef65b6d7834b40dfcd48534829a0a1e9529ab87ee /sys/dev
parent3eaa67c3ad947d85be5350e0e184cd6ee5b93a52 (diff)
downloadFreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.zip
FreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.tar.gz
Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/an/if_an.c40
-rw-r--r--sys/dev/an/if_anreg.h2
-rw-r--r--sys/dev/ar/if_ar.c67
-rw-r--r--sys/dev/arl/if_arl.c27
-rw-r--r--sys/dev/arl/if_arl_isa.c9
-rw-r--r--sys/dev/arl/if_arlreg.h2
-rw-r--r--sys/dev/ath/ath_rate/amrr/amrr.c4
-rw-r--r--sys/dev/ath/ath_rate/onoe/onoe.c4
-rw-r--r--sys/dev/ath/if_ath.c74
-rw-r--r--sys/dev/ath/if_athvar.h3
-rw-r--r--sys/dev/awi/awi.c40
-rw-r--r--sys/dev/awi/awivar.h1
-rw-r--r--sys/dev/bfe/if_bfe.c45
-rw-r--r--sys/dev/bfe/if_bfereg.h3
-rw-r--r--sys/dev/bge/if_bge.c69
-rw-r--r--sys/dev/bge/if_bgereg.h2
-rw-r--r--sys/dev/cm/if_cm_isa.c5
-rw-r--r--sys/dev/cm/smc90cx6.c29
-rw-r--r--sys/dev/cm/smc90cx6var.h2
-rw-r--r--sys/dev/cnw/if_cnw.c30
-rw-r--r--sys/dev/cp/if_cp.c138
-rw-r--r--sys/dev/cs/if_cs.c64
-rw-r--r--sys/dev/cs/if_csvar.h4
-rw-r--r--sys/dev/ctau/if_ct.c138
-rw-r--r--sys/dev/cx/if_cx.c138
-rw-r--r--sys/dev/dc/if_dc.c54
-rw-r--r--sys/dev/dc/if_dcreg.h2
-rw-r--r--sys/dev/de/if_de.c287
-rw-r--r--sys/dev/de/if_devar.h6
-rw-r--r--sys/dev/ed/if_ed.c24
-rw-r--r--sys/dev/ed/if_ed_3c503.c2
-rw-r--r--sys/dev/ed/if_ed_cbus.c19
-rw-r--r--sys/dev/ed/if_ed_hpp.c4
-rw-r--r--sys/dev/ed/if_ed_isa.c2
-rw-r--r--sys/dev/ed/if_ed_novell.c2
-rw-r--r--sys/dev/ed/if_ed_pccard.c16
-rw-r--r--sys/dev/ed/if_ed_sic.c7
-rw-r--r--sys/dev/ed/if_ed_wd80x3.c2
-rw-r--r--sys/dev/ed/if_edvar.h3
-rw-r--r--sys/dev/em/if_em.c46
-rw-r--r--sys/dev/em/if_em.h2
-rw-r--r--sys/dev/en/if_en_pci.c34
-rw-r--r--sys/dev/en/midway.c103
-rw-r--r--sys/dev/en/midwayvar.h3
-rw-r--r--sys/dev/ep/if_ep.c31
-rw-r--r--sys/dev/ep/if_ep_pccard.c2
-rw-r--r--sys/dev/ep/if_epvar.h2
-rw-r--r--sys/dev/ex/if_ex.c29
-rw-r--r--sys/dev/ex/if_ex_isa.c2
-rw-r--r--sys/dev/ex/if_ex_pccard.c2
-rw-r--r--sys/dev/ex/if_exvar.h3
-rw-r--r--sys/dev/fatm/if_fatm.c174
-rw-r--r--sys/dev/fatm/if_fatmvar.h2
-rw-r--r--sys/dev/fe/if_fe.c162
-rw-r--r--sys/dev/fe/if_fe_isa.c42
-rw-r--r--sys/dev/fe/if_fe_pccard.c11
-rw-r--r--sys/dev/fe/if_fevar.h8
-rw-r--r--sys/dev/firewire/if_fwe.c33
-rw-r--r--sys/dev/firewire/if_fwevar.h4
-rw-r--r--sys/dev/firewire/if_fwip.c22
-rw-r--r--sys/dev/firewire/if_fwipvar.h4
-rw-r--r--sys/dev/fxp/if_fxp.c52
-rw-r--r--sys/dev/fxp/if_fxpvar.h4
-rw-r--r--sys/dev/gem/if_gem.c34
-rw-r--r--sys/dev/gem/if_gem_pci.c2
-rw-r--r--sys/dev/gem/if_gemvar.h3
-rw-r--r--sys/dev/harp/if_harp.c10
-rw-r--r--sys/dev/hatm/if_hatm.c154
-rw-r--r--sys/dev/hatm/if_hatm_intr.c26
-rw-r--r--sys/dev/hatm/if_hatm_ioctl.c12
-rw-r--r--sys/dev/hatm/if_hatm_rx.c18
-rw-r--r--sys/dev/hatm/if_hatm_tx.c24
-rw-r--r--sys/dev/hatm/if_hatmvar.h2
-rw-r--r--sys/dev/hfa/fore_output.c6
-rw-r--r--sys/dev/hfa/fore_receive.c6
-rw-r--r--sys/dev/hfa/fore_transmit.c6
-rw-r--r--sys/dev/hme/if_hme.c39
-rw-r--r--sys/dev/hme/if_hme_pci.c4
-rw-r--r--sys/dev/hme/if_hme_sbus.c2
-rw-r--r--sys/dev/hme/if_hmevar.h3
-rw-r--r--sys/dev/idt/idt.c4
-rw-r--r--sys/dev/ie/if_ie.c79
-rw-r--r--sys/dev/ie/if_ie_isa.c16
-rw-r--r--sys/dev/ie/if_ievar.h3
-rw-r--r--sys/dev/if_ndis/if_ndis.c51
-rw-r--r--sys/dev/if_ndis/if_ndisvar.h5
-rw-r--r--sys/dev/iicbus/if_ic.c32
-rw-r--r--sys/dev/ipw/if_ipw.c13
-rw-r--r--sys/dev/ipw/if_ipwvar.h2
-rw-r--r--sys/dev/iwi/if_iwi.c13
-rw-r--r--sys/dev/iwi/if_iwivar.h2
-rw-r--r--sys/dev/ixgb/if_ixgb.c41
-rw-r--r--sys/dev/ixgb/if_ixgb.h3
-rw-r--r--sys/dev/lge/if_lge.c39
-rw-r--r--sys/dev/lge/if_lgereg.h2
-rw-r--r--sys/dev/lnc/if_lnc.c140
-rw-r--r--sys/dev/lnc/if_lnc_cbus.c23
-rw-r--r--sys/dev/lnc/if_lnc_isa.c17
-rw-r--r--sys/dev/lnc/if_lnc_pci.c23
-rw-r--r--sys/dev/lnc/if_lncvar.h3
-rw-r--r--sys/dev/my/if_my.c42
-rw-r--r--sys/dev/my/if_myreg.h2
-rw-r--r--sys/dev/nge/if_nge.c38
-rw-r--r--sys/dev/nge/if_ngereg.h2
-rw-r--r--sys/dev/nve/if_nve.c40
-rw-r--r--sys/dev/nve/if_nvereg.h5
-rw-r--r--sys/dev/owi/if_owi.c41
-rw-r--r--sys/dev/owi/if_wivar.h2
-rw-r--r--sys/dev/patm/if_patm.c10
-rw-r--r--sys/dev/patm/if_patm_attach.c79
-rw-r--r--sys/dev/patm/if_patm_intr.c2
-rw-r--r--sys/dev/patm/if_patm_ioctl.c10
-rw-r--r--sys/dev/patm/if_patm_rx.c22
-rw-r--r--sys/dev/patm/if_patm_tx.c42
-rw-r--r--sys/dev/patm/if_patmvar.h12
-rw-r--r--sys/dev/pdq/if_fea.c4
-rw-r--r--sys/dev/pdq/if_fpa.c4
-rw-r--r--sys/dev/pdq/pdq.c15
-rw-r--r--sys/dev/pdq/pdq_freebsd.h7
-rw-r--r--sys/dev/pdq/pdq_ifsubr.c72
-rw-r--r--sys/dev/pdq/pdqvar.h224
-rw-r--r--sys/dev/ppbus/if_plip.c46
-rw-r--r--sys/dev/ral/if_ral.c14
-rw-r--r--sys/dev/ral/if_ralvar.h2
-rw-r--r--sys/dev/ray/if_ray.c60
-rw-r--r--sys/dev/ray/if_rayvar.h6
-rw-r--r--sys/dev/re/if_re.c37
-rw-r--r--sys/dev/sbni/if_sbni.c49
-rw-r--r--sys/dev/sbni/if_sbni_isa.c2
-rw-r--r--sys/dev/sbni/if_sbnivar.h3
-rw-r--r--sys/dev/sbsh/if_sbsh.c59
-rw-r--r--sys/dev/sf/if_sf.c37
-rw-r--r--sys/dev/sf/if_sfreg.h2
-rw-r--r--sys/dev/sk/if_sk.c52
-rw-r--r--sys/dev/sk/if_skreg.h2
-rw-r--r--sys/dev/sn/if_sn.c109
-rw-r--r--sys/dev/sn/if_sn_pccard.c2
-rw-r--r--sys/dev/sn/if_snvar.h8
-rw-r--r--sys/dev/snc/dp83932.c42
-rw-r--r--sys/dev/snc/dp83932var.h3
-rw-r--r--sys/dev/sr/if_sr.c53
-rw-r--r--sys/dev/ti/if_ti.c64
-rw-r--r--sys/dev/ti/if_tireg.h2
-rw-r--r--sys/dev/tx/if_tx.c61
-rw-r--r--sys/dev/tx/if_txvar.h5
-rw-r--r--sys/dev/txp/if_txp.c64
-rw-r--r--sys/dev/txp/if_txpreg.h2
-rw-r--r--sys/dev/usb/if_aue.c30
-rw-r--r--sys/dev/usb/if_auereg.h2
-rw-r--r--sys/dev/usb/if_axe.c28
-rw-r--r--sys/dev/usb/if_axereg.h2
-rw-r--r--sys/dev/usb/if_cdce.c10
-rw-r--r--sys/dev/usb/if_cdcereg.h4
-rw-r--r--sys/dev/usb/if_cue.c28
-rw-r--r--sys/dev/usb/if_cuereg.h2
-rw-r--r--sys/dev/usb/if_kue.c27
-rw-r--r--sys/dev/usb/if_kuereg.h2
-rw-r--r--sys/dev/usb/if_rue.c34
-rw-r--r--sys/dev/usb/if_ruereg.h2
-rw-r--r--sys/dev/usb/if_udav.c19
-rw-r--r--sys/dev/usb/if_udavreg.h6
-rw-r--r--sys/dev/usb/if_ural.c5
-rw-r--r--sys/dev/usb/if_uralvar.h2
-rw-r--r--sys/dev/utopia/utopia.c6
-rw-r--r--sys/dev/vge/if_vge.c36
-rw-r--r--sys/dev/vge/if_vgevar.h2
-rw-r--r--sys/dev/vr/if_vr.c29
-rw-r--r--sys/dev/vr/if_vrreg.h2
-rw-r--r--sys/dev/vx/if_vx.c62
-rw-r--r--sys/dev/vx/if_vxvar.h2
-rw-r--r--sys/dev/wi/if_wi.c40
-rw-r--r--sys/dev/wi/if_wivar.h3
-rw-r--r--sys/dev/wl/if_wl.c113
-rw-r--r--sys/dev/xe/if_xe.c17
-rw-r--r--sys/dev/xe/if_xe_pccard.c15
-rw-r--r--sys/dev/xe/if_xevar.h2
176 files changed, 2581 insertions, 2421 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c
index e8fffbf..0aae094 100644
--- a/sys/dev/an/if_an.c
+++ b/sys/dev/an/if_an.c
@@ -669,14 +669,19 @@ an_attach(sc, unit, flags)
int unit;
int flags;
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
int error = EIO;
int i, nrate, mword;
u_int8_t r;
mtx_init(&sc->an_mtx, device_get_nameunit(sc->an_dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
-
+ ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("an%d: can not if_alloc()\n", sc->an_unit);
+ goto fail;
+ }
+
sc->an_gone = 0;
sc->an_associated = 0;
sc->an_monitor = 0;
@@ -746,9 +751,6 @@ an_attach(sc, unit, flags)
}
#endif
- bcopy((char *)&sc->an_caps.an_oemaddr,
- (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
ifp->if_softc = sc;
sc->an_unit = unit;
if_initname(ifp, device_get_name(sc->an_dev),
@@ -806,12 +808,15 @@ an_attach(sc, unit, flags)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+
+ ether_ifattach(ifp, sc->an_caps.an_oemaddr);
callout_handle_init(&sc->an_stat_ch);
return(0);
fail:;
mtx_destroy(&sc->an_mtx);
+ if (ifp != NULL)
+ if_free(ifp);
return(error);
}
@@ -819,7 +824,7 @@ int
an_detach(device_t dev)
{
struct an_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->an_ifp;
if (sc->an_gone) {
device_printf(dev,"already unloaded\n");
@@ -830,6 +835,7 @@ an_detach(device_t dev)
ifmedia_removeall(&sc->an_ifmedia);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
sc->an_gone = 1;
AN_UNLOCK(sc);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
@@ -857,7 +863,7 @@ an_rxeof(sc)
AN_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
if (!sc->mpi350) {
id = CSR_READ_2(sc, AN_RX_FID);
@@ -1109,7 +1115,7 @@ an_txeof(sc, status)
struct ifnet *ifp;
int id, i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
ifp->if_timer = 0;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -1162,7 +1168,7 @@ an_stats_update(xsc)
sc = xsc;
AN_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
sc->an_status.an_type = AN_RID_STATUS;
sc->an_status.an_len = sizeof(struct an_ltv_status);
@@ -1207,7 +1213,7 @@ an_intr(xsc)
return;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
/* Disable interrupts. */
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
@@ -1784,7 +1790,7 @@ an_setdef(sc, areq)
struct an_ltv_aplist *ap;
struct an_ltv_gen *sp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
switch (areq->an_type) {
case AN_RID_GENCONFIG:
@@ -1792,7 +1798,7 @@ an_setdef(sc, areq)
ifa = ifaddr_byindex(ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)&cfg->an_macaddr, (char *)&sc->arpcom.ac_enaddr,
+ bcopy((char *)&cfg->an_macaddr, IFP2ENADDR(sc->an_ifp),
ETHER_ADDR_LEN);
bcopy((char *)&cfg->an_macaddr, LLADDR(sdl), ETHER_ADDR_LEN);
@@ -2529,7 +2535,7 @@ an_init(xsc)
void *xsc;
{
struct an_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->an_ifp;
AN_LOCK(sc);
@@ -2557,7 +2563,7 @@ an_init(xsc)
}
/* Set our MAC address. */
- bcopy((char *)&sc->arpcom.ac_enaddr,
+ bcopy((char *)IFP2ENADDR(sc->an_ifp),
(char *)&sc->an_config.an_macaddr, ETHER_ADDR_LEN);
if (ifp->if_flags & IFF_BROADCAST)
@@ -2834,7 +2840,7 @@ an_stop(sc)
return;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0);
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
@@ -2907,7 +2913,7 @@ an_resume(dev)
sc = device_get_softc(dev);
AN_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->an_ifp;
sc->an_gone = 0;
an_reset(sc);
diff --git a/sys/dev/an/if_anreg.h b/sys/dev/an/if_anreg.h
index 12a03f0..44a702a 100644
--- a/sys/dev/an/if_anreg.h
+++ b/sys/dev/an/if_anreg.h
@@ -440,7 +440,7 @@ struct an_tx_ring_data {
};
struct an_softc {
- struct arpcom arpcom;
+ struct ifnet *an_ifp;
int an_unit;
diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c
index 70741c0..3c58969 100644
--- a/sys/dev/ar/if_ar.c
+++ b/sys/dev/ar/if_ar.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ar/if_ar.h>
#else /* NETGRAPH */
#include <net/if_sppp.h>
+#include <net/if_types.h>
#include <net/bpf.h>
#endif /* NETGRAPH */
@@ -90,7 +91,7 @@ devclass_t ar_devclass;
struct ar_softc {
#ifndef NETGRAPH
- struct sppp ifsppp;
+ struct ifnet *ifp;
#endif /* NETGRAPH */
int unit; /* With regards to all ar devices */
int subunit; /* With regards to this card */
@@ -144,6 +145,7 @@ struct ar_softc {
u_long opackets, ipackets;
#endif /* NETGRAPH */
};
+#define SC2IFP(sc) (sc)->ifp
static int next_ar_unit = 0;
@@ -281,7 +283,14 @@ ar_attach(device_t device)
ar_init_msci(sc);
#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
+ ifp = SC2IFP(sc) = if_alloc(IFT_PPP);
+ if (ifp == NULL) {
+ if (BUS_TEARDOWN_INTR(device_get_parent(device), device,
+ hc->res_irq, hc->intr_cookie) != 0) {
+ printf("intr teardown failed.. continuing\n");
+ }
+ return (1);
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(device),
@@ -293,7 +302,7 @@ ar_attach(device_t device)
ifp->if_start = arstart;
ifp->if_watchdog = arwatchdog;
- sc->ifsppp.pp_flags = PP_KEEPALIVE;
+ IFP2SP(sc->ifp)->pp_flags = PP_KEEPALIVE;
switch(hc->interface[unit]) {
default: iface = "UNKNOWN"; break;
@@ -310,7 +319,7 @@ ar_attach(device_t device)
sc->subunit,
iface);
- sppp_attach((struct ifnet *)&sc->ifsppp);
+ sppp_attach(SC2IFP(sc));
if_attach(ifp);
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
@@ -562,7 +571,7 @@ ar_xmit(struct ar_softc *sc)
dmac_channel *dmac;
#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
+ ifp = SC2IFP(sc);
#endif /* NETGRAPH */
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
@@ -695,7 +704,7 @@ top_arstart:
#ifndef NETGRAPH
BPF_MTAP(ifp, mtx);
m_freem(mtx);
- ++sc->ifsppp.pp_if.if_opackets;
+ ++SC2IFP(sc)->if_opackets;
#else /* NETGRAPH */
m_freem(mtx);
sc->outbytes += len;
@@ -822,7 +831,7 @@ arwatchdog(struct ar_softc *sc)
if(sc->hc->bustype == AR_BUS_ISA)
ARC_SET_SCA(sc->hc, sc->scano);
- /* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
+ /* XXX if(SC2IFP(sc)->if_flags & IFF_DEBUG) */
printf("ar%d: transmit failed, "
"ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
sc->unit,
@@ -1680,7 +1689,7 @@ ar_get_packets(struct ar_softc *sc)
continue;
}
#ifndef NETGRAPH
- m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
+ m->m_pkthdr.rcvif = SC2IFP(sc);
#else /* NETGRAPH */
m->m_pkthdr.rcvif = NULL;
sc->inbytes += len;
@@ -1697,9 +1706,9 @@ ar_get_packets(struct ar_softc *sc)
}
ar_copy_rxbuf(m, sc, len);
#ifndef NETGRAPH
- BPF_MTAP(&sc->ifsppp.pp_if, m);
- sppp_input(&sc->ifsppp.pp_if, m);
- sc->ifsppp.pp_if.if_ipackets++;
+ BPF_MTAP(SC2IFP(sc), m);
+ sppp_input(SC2IFP(sc), m);
+ SC2IFP(sc)->if_ipackets++;
#else /* NETGRAPH */
NG_SEND_DATA_ONLY(error, sc->hook, m);
sc->ipackets++;
@@ -1737,7 +1746,7 @@ ar_get_packets(struct ar_softc *sc)
ar_eat_packet(sc, 1);
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
+ SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ierrors[0]++;
#endif /* NETGRAPH */
@@ -1810,8 +1819,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"txpacket no %lu.\n",
sc->unit,
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_opackets);
- sc->ifsppp.pp_if.if_oerrors++;
+ SC2IFP(sc)->if_opackets);
+ SC2IFP(sc)->if_oerrors++;
#else /* NETGRAPH */
sc->opackets);
sc->oerrors++;
@@ -1825,7 +1834,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"cda %04x, eda %04x.\n",
sc->unit,
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_opackets,
+ SC2IFP(sc)->if_opackets,
#else /* NETGRAPH */
sc->opackets,
#endif /* NETGRAPH */
@@ -1833,7 +1842,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
dmac->cda,
dmac->eda);
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
#else /* NETGRAPH */
sc->oerrors++;
#endif /* NETGRAPH */
@@ -1851,10 +1860,10 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
*/
sc->xmit_busy = 0;
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
- sc->ifsppp.pp_if.if_timer = 0;
+ SC2IFP(sc)->if_flags &= ~IFF_OACTIVE;
+ SC2IFP(sc)->if_timer = 0;
#else /* NETGRAPH */
- /* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
+ /* XXX SC2IFP(sc)->if_flags &= ~IFF_OACTIVE; */
sc->out_dog = 0; /* XXX */
#endif /* NETGRAPH */
@@ -1879,12 +1888,12 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
/* End of frame */
if(dsr & SCA_DSR_EOM) {
- TRC(int tt = sc->ifsppp.pp_if.if_ipackets;)
+ TRC(int tt = SC2IFP(sc)->if_ipackets;)
TRC(int ind = sc->rxhind;)
ar_get_packets(sc);
#ifndef NETGRAPH
-#define IPACKETS sc->ifsppp.pp_if.if_ipackets
+#define IPACKETS SC2IFP(sc)->if_ipackets
#else /* NETGRAPH */
#define IPACKETS sc->ipackets
#endif /* NETGRAPH */
@@ -1933,8 +1942,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"rxpkts %lu.\n",
sc->unit,
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
+ SC2IFP(sc)->if_ipackets);
+ SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ipackets);
sc->ierrors[1]++;
@@ -1950,7 +1959,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"cda %x, eda %x, dsr %x.\n",
sc->unit,
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets,
+ SC2IFP(sc)->if_ipackets,
#else /* NETGRAPH */
sc->ipackets,
#endif /* NETGRAPH */
@@ -1964,7 +1973,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
*/
ar_eat_packet(sc, 0);
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
+ SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ierrors[2]++;
#endif /* NETGRAPH */
@@ -1977,7 +1986,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"rxpkts %lu, rxind %d, "
"cda %x, eda %x, dsr %x. After\n",
sc->unit,
- sc->ifsppp.pp_if.if_ipackets,
+ SC2IFP(sc)->if_ipackets,
sc->rxhind,
dmac->cda,
dmac->eda,
@@ -1996,8 +2005,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
printf("ar%d: RX End of transfer, rxpkts %lu.\n",
sc->unit,
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
+ SC2IFP(sc)->if_ipackets);
+ SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ipackets);
sc->ierrors[3]++;
@@ -2018,7 +2027,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
if(dotxstart & 0x0C) {
sc = &hc->sc[mch + (NCHAN * scano)];
#ifndef NETGRAPH
- arstart(&sc->ifsppp.pp_if);
+ arstart(SC2IFP(sc));
#else /* NETGRAPH */
arstart(sc);
#endif /* NETGRAPH */
diff --git a/sys/dev/arl/if_arl.c b/sys/dev/arl/if_arl.c
index 2d199e4..86b3108 100644
--- a/sys/dev/arl/if_arl.c
+++ b/sys/dev/arl/if_arl.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/ethernet.h>
#include <net80211/ieee80211_var.h>
@@ -109,7 +110,7 @@ __FBSDID("$FreeBSD$");
#define BROADCASTADDR (etherbroadcastaddr)
#define _ARL_CURPROC (curproc)
#else
-#define BROADCASTADDR (sc->arpcom.ac_if.if_broadcastaddr)
+#define BROADCASTADDR (sc->arl_ifp->if_broadcastaddr)
#define _ARL_CURPROC (curthread)
#endif
@@ -188,11 +189,15 @@ arl_attach(dev)
device_t dev;
{
struct arl_softc* sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
int attached, configured = 0;
D(("attach\n"));
+ ifp = sc->arl_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
+
configured = ar->configuredStatusFlag;
attached = (ifp->if_softc != 0);
@@ -248,7 +253,7 @@ arl_attach(dev)
#if __FreeBSD_version < 500100
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#else
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, ar->lanCardNodeId);
#endif
}
@@ -734,7 +739,7 @@ arl_init(xsc)
void *xsc;
{
struct arl_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->arl_ifp;
int s;
D(("init\n"));
@@ -768,7 +773,7 @@ arl_put(sc)
int i;
if (ARL_CHECKREG(sc))
- sc->arpcom.ac_if.if_oerrors++;
+ sc->arl_ifp->if_oerrors++;
/* copy dst adr */
for(i = 0; i < 6; i++)
@@ -802,7 +807,7 @@ arl_put(sc)
ar->commandByte = 0x85; /* send command */
ARL_CHANNEL(sc);
if (arl_command(sc))
- sc->arpcom.ac_if.if_oerrors++;
+ sc->arl_ifp->if_oerrors++;
}
/*
@@ -873,7 +878,7 @@ arl_stop(sc)
s = splimp();
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->arl_ifp;
ifp->if_timer = 0; /* disable timer */
ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
@@ -967,7 +972,7 @@ arl_read(sc, buf, len)
int len;
{
register struct ether_header *eh;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->arl_ifp;
struct mbuf *m;
eh = (struct ether_header *)buf;
@@ -984,7 +989,7 @@ arl_read(sc, buf, len)
* This test does not support multicasts.
*/
if ((ifp->if_flags & IFF_PROMISC)
- && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
+ && bcmp(eh->ether_dhost, IFP2ENADDR(sc->arl_ifp),
sizeof(eh->ether_dhost)) != 0
&& bcmp(eh->ether_dhost, BROADCASTADDR,
sizeof(eh->ether_dhost)) != 0)
@@ -1049,7 +1054,7 @@ arl_intr(arg)
void *arg;
{
register struct arl_softc *sc = (struct arl_softc *) arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->arl_ifp;
/* enable interrupt */
ar->controlRegister = (sc->arl_control & ~ARL_CLEAR_INTERRUPT);
@@ -1057,7 +1062,7 @@ arl_intr(arg)
if (ar->txStatusVector) {
if (ar->txStatusVector != 1)
- sc->arpcom.ac_if.if_collisions++;
+ sc->arl_ifp->if_collisions++;
ifp->if_timer = 0; /* disable timer */
ifp->if_flags &= ~IFF_OACTIVE;
arl_start(ifp);
diff --git a/sys/dev/arl/if_arl_isa.c b/sys/dev/arl/if_arl_isa.c
index 62ad3bd..e318adf 100644
--- a/sys/dev/arl/if_arl_isa.c
+++ b/sys/dev/arl/if_arl_isa.c
@@ -275,8 +275,6 @@ arl_isa_probe (device_t dev)
}
if (ar->diagnosticInfo == 0xFF) {
- /* Copy arp to arpcom struct */
- bcopy(ar->lanCardNodeId, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
device_set_desc_copy(dev, arl_make_desc(ar->hardwareType,
ar->radioModule));
error = 0;
@@ -313,7 +311,7 @@ arl_isa_attach (device_t dev)
}
#if __FreeBSD_version < 502108
- device_printf(dev, "Ethernet address %6D\n", sc->arpcom.ac_enaddr, ":");
+ device_printf(dev, "Ethernet address %6D\n", IFP2ENADDR(sc->arl_ifp), ":");
#endif
return arl_attach(dev);
@@ -327,9 +325,10 @@ arl_isa_detach(device_t dev)
arl_stop(sc);
ifmedia_removeall(&sc->arl_ifmedia);
#if __FreeBSD_version < 500100
- ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(sc->arl_ifp, ETHER_BPF_SUPPORTED);
#else
- ether_ifdetach(&sc->arpcom.ac_if);
+ ether_ifdetach(sc->arl_ifp);
+ if_free(sc->arl_ifp);
#endif
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
arl_release_resources(dev);
diff --git a/sys/dev/arl/if_arlreg.h b/sys/dev/arl/if_arlreg.h
index 137232f..49982cb 100644
--- a/sys/dev/arl/if_arlreg.h
+++ b/sys/dev/arl/if_arlreg.h
@@ -281,7 +281,7 @@ struct arl_sigcache {
#ifdef _KERNEL
struct arl_softc {
- struct arpcom arpcom; /* Ethernet common */
+ struct ifnet *arl_ifp;
int arl_unit;
struct arl_private * arl_mem; /* arlan data */
diff --git a/sys/dev/ath/ath_rate/amrr/amrr.c b/sys/dev/ath/ath_rate/amrr/amrr.c
index 705bd2a..5955e48 100644
--- a/sys/dev/ath/ath_rate/amrr/amrr.c
+++ b/sys/dev/ath/ath_rate/amrr/amrr.c
@@ -376,7 +376,7 @@ ath_rate_newstate(struct ath_softc *sc, enum ieee80211_state state)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&asc->timer, (interval * hz) / 1000,
- ath_ratectl, &sc->sc_if);
+ ath_ratectl, sc->sc_ifp);
}
}
@@ -475,7 +475,7 @@ ath_ratectl(void *arg)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&asc->timer, (interval * hz) / 1000,
- ath_ratectl, &sc->sc_if);
+ ath_ratectl, sc->sc_ifp);
}
static void
diff --git a/sys/dev/ath/ath_rate/onoe/onoe.c b/sys/dev/ath/ath_rate/onoe/onoe.c
index 478c014..a4f0094 100644
--- a/sys/dev/ath/ath_rate/onoe/onoe.c
+++ b/sys/dev/ath/ath_rate/onoe/onoe.c
@@ -360,7 +360,7 @@ ath_rate_newstate(struct ath_softc *sc, enum ieee80211_state state)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&osc->timer, (interval * hz) / 1000,
- ath_ratectl, &sc->sc_if);
+ ath_ratectl, sc->sc_ifp);
}
}
@@ -456,7 +456,7 @@ ath_ratectl(void *arg)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&osc->timer, (interval * hz) / 1000,
- ath_ratectl, &sc->sc_if);
+ ath_ratectl, sc->sc_ifp);
}
static void
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 38b3018..10adb9b 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_llc.h>
@@ -228,7 +229,7 @@ enum {
};
#define IFF_DUMPPKTS(sc, m) \
((sc->sc_debug & (m)) || \
- (sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
+ (sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
#define DPRINTF(sc, m, fmt, ...) do { \
if (sc->sc_debug & (m)) \
printf(fmt, __VA_ARGS__); \
@@ -241,7 +242,7 @@ static void ath_printrxbuf(struct ath_buf *bf, int);
static void ath_printtxbuf(struct ath_buf *bf, int);
#else
#define IFF_DUMPPKTS(sc, m) \
- ((sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
+ ((sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
#define DPRINTF(m, fmt, ...)
#define KEYPRINTF(sc, k, ix, mac)
#endif
@@ -251,14 +252,21 @@ MALLOC_DEFINE(M_ATHDEV, "athdev", "ath driver dma buffers");
int
ath_attach(u_int16_t devid, struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
- struct ath_hal *ah;
+ struct ath_hal *ah = NULL;
HAL_STATUS status;
int error = 0, i;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid);
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(sc->sc_dev, "can not if_alloc()\n");
+ error = ENOSPC;
+ goto bad;
+ }
+
/* set these up early for if_printf use */
if_initname(ifp, device_get_name(sc->sc_dev),
device_get_unit(sc->sc_dev));
@@ -591,6 +599,8 @@ bad2:
bad:
if (ah)
ath_hal_detach(ah);
+ if (ifp != NULL)
+ if_free(ifp);
sc->sc_invalid = 1;
return error;
}
@@ -598,7 +608,7 @@ bad:
int
ath_detach(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
@@ -629,7 +639,7 @@ ath_detach(struct ath_softc *sc)
void
ath_suspend(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
@@ -640,13 +650,13 @@ ath_suspend(struct ath_softc *sc)
void
ath_resume(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
if (ifp->if_flags & IFF_UP) {
- ath_init(ifp);
+ ath_init(sc);
if (ifp->if_flags & IFF_RUNNING)
ath_start(ifp);
}
@@ -659,7 +669,7 @@ ath_resume(struct ath_softc *sc)
void
ath_shutdown(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
@@ -674,7 +684,7 @@ void
ath_intr(void *arg)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
HAL_INT status;
@@ -772,7 +782,7 @@ static void
ath_fatal_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
if_printf(ifp, "hardware error; resetting\n");
ath_reset(ifp);
@@ -782,7 +792,7 @@ static void
ath_rxorn_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
if_printf(ifp, "rx FIFO overrun; resetting\n");
ath_reset(ifp);
@@ -836,7 +846,7 @@ ath_init(void *arg)
{
struct ath_softc *sc = (struct ath_softc *) arg;
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ieee80211_node *ni;
struct ath_hal *ah = sc->sc_ah;
HAL_STATUS status;
@@ -1199,7 +1209,7 @@ ath_media_change(struct ifnet *ifp)
error = ieee80211_media_change(ifp);
if (error == ENETRESET) {
if (IS_UP(ifp))
- ath_init(ifp); /* XXX lose error */
+ ath_init(ifp->if_softc); /* XXX lose error */
error = 0;
}
return error;
@@ -1604,7 +1614,7 @@ ath_calcrxfilter(struct ath_softc *sc, enum ieee80211_state state)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int32_t rfilt;
rfilt = (ath_hal_getrxfilter(ah) & HAL_RX_FILTER_PHYERR)
@@ -1626,7 +1636,7 @@ ath_mode_init(struct ath_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int32_t rfilt, mfilt[2], val;
u_int8_t pos;
struct ifmultiaddr *ifma;
@@ -1646,7 +1656,7 @@ ath_mode_init(struct ath_softc *sc)
*
* XXX should get from lladdr instead of arpcom but that's more work
*/
- IEEE80211_ADDR_COPY(ic->ic_myaddr, IFP2AC(ifp)->ac_enaddr);
+ IEEE80211_ADDR_COPY(ic->ic_myaddr, IFP2ENADDR(ifp));
ath_hal_setmac(ah, ic->ic_myaddr);
/* calculate and install multicast filter */
@@ -2016,7 +2026,7 @@ static void
ath_bstuck_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
if_printf(ifp, "stuck beacon; resetting (bmiss count %u)\n",
sc->sc_bmisscount);
@@ -2233,7 +2243,7 @@ ath_descdma_setup(struct ath_softc *sc,
{
#define DS2PHYS(_dd, _ds) \
((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ath_desc *ds;
struct ath_buf *bf;
int i, bsize, error;
@@ -2623,7 +2633,7 @@ ath_rx_proc(void *arg, int npending)
struct ath_softc *sc = arg;
struct ath_buf *bf;
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
struct ath_desc *ds;
struct mbuf *m;
@@ -3149,7 +3159,7 @@ ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf
txopLimit, CTS_DURATION)
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
const struct chanAccParams *cap = &ic->ic_wme.wme_chanParams;
int i, error, iswep, ismcast, keyix, hdrlen, pktlen, try0;
u_int8_t rix, txrate, ctsrate;
@@ -3730,7 +3740,7 @@ static void
ath_tx_proc_q0(void *arg, int npending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
ath_tx_processq(sc, &sc->sc_txq[0]);
ath_tx_processq(sc, sc->sc_cabq);
@@ -3751,7 +3761,7 @@ static void
ath_tx_proc_q0123(void *arg, int npending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
/*
* Process each active queue.
@@ -3778,7 +3788,7 @@ static void
ath_tx_proc(void *arg, int npending)
{
struct ath_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i;
/*
@@ -3860,7 +3870,7 @@ static void
ath_draintxq(struct ath_softc *sc)
{
struct ath_hal *ah = sc->sc_ah;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i;
/* XXX return value */
@@ -4084,7 +4094,7 @@ ath_calibrate(void *arg)
* to load new gain values.
*/
sc->sc_stats.ast_per_rfgain++;
- ath_reset(&sc->sc_if);
+ ath_reset(sc->sc_ifp);
}
if (!ath_hal_calibrate(ah, &sc->sc_curchan)) {
DPRINTF(sc, ATH_DEBUG_ANY,
@@ -4291,7 +4301,7 @@ ath_getchannels(struct ath_softc *sc, u_int cc,
HAL_BOOL outdoor, HAL_BOOL xchanmode)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
HAL_CHANNEL *chans;
int i, ix, nchan;
@@ -4680,7 +4690,7 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
* probably a better way to deal with this.
*/
if (!sc->sc_invalid && ic->ic_bss != NULL)
- ath_init(ifp); /* XXX lose error */
+ ath_init(sc); /* XXX lose error */
} else
ath_stop_locked(ifp);
break;
@@ -4716,7 +4726,7 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (error == ENETRESET) {
if (IS_RUNNING(ifp) &&
ic->ic_roaming != IEEE80211_ROAMING_MANUAL)
- ath_init(ifp); /* XXX lose error */
+ ath_init(sc); /* XXX lose error */
error = 0;
}
if (error == ERESTART)
@@ -4836,7 +4846,7 @@ static int
ath_sysctl_tpscale(SYSCTL_HANDLER_ARGS)
{
struct ath_softc *sc = arg1;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int32_t scale;
int error;
@@ -4929,7 +4939,7 @@ ath_sysctlattach(struct ath_softc *sc)
static void
ath_bpfattach(struct ath_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
bpfattach2(ifp, DLT_IEEE802_11_RADIO,
sizeof(struct ieee80211_frame) + sizeof(sc->sc_tx_th),
@@ -4959,7 +4969,7 @@ static void
ath_announce(struct ath_softc *sc)
{
#define HAL_MODE_DUALBAND (HAL_MODE_11A|HAL_MODE_11B)
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
u_int modes, cc;
diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h
index 6980291..543b249 100644
--- a/sys/dev/ath/if_athvar.h
+++ b/sys/dev/ath/if_athvar.h
@@ -172,7 +172,7 @@ struct ath_txq {
} while (0)
struct ath_softc {
- struct arpcom sc_arp; /* interface common */
+ struct ifnet *sc_ifp; /* interface common */
struct ath_stats sc_stats; /* interface statistics */
struct ieee80211com sc_ic; /* IEEE 802.11 common */
int sc_regdomain;
@@ -286,7 +286,6 @@ struct ath_softc {
struct callout sc_cal_ch; /* callout handle for cals */
struct callout sc_scan_ch; /* callout handle for scan */
};
-#define sc_if sc_arp.ac_if
#define sc_tx_th u_tx_rt.th
#define sc_rx_th u_rx_rt.th
diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c
index 84a3df3..0325995 100644
--- a/sys/dev/awi/awi.c
+++ b/sys/dev/awi/awi.c
@@ -258,7 +258,7 @@ int
awi_attach(struct awi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s, i, error, nrate;
int mword;
enum ieee80211_phymode mode;
@@ -372,7 +372,7 @@ awi_attach(struct awi_softc *sc)
int
awi_detach(struct awi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s;
if (!sc->sc_attached)
@@ -402,7 +402,7 @@ int
awi_activate(struct device *self, enum devact act)
{
struct awi_softc *sc = (struct awi_softc *)self;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s, error = 0;
s = splnet();
@@ -423,7 +423,7 @@ void
awi_power(int why, void *arg)
{
struct awi_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s;
int ocansleep;
@@ -456,7 +456,7 @@ void
awi_shutdown(void *arg)
{
struct awi_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
if (sc->sc_attached)
awi_stop(ifp, 1);
@@ -542,7 +542,7 @@ awi_init0(void *arg)
{
struct awi_softc *sc = arg;
- (void)awi_init(&sc->sc_if);
+ (void)awi_init(AC2IFP(&sc->sc_arp));
}
#endif
@@ -1125,7 +1125,7 @@ awi_media_status(struct ifnet *ifp, struct ifmediareq *imr)
static int
awi_mode_init(struct awi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int n, error;
#ifdef __FreeBSD__
struct ifmultiaddr *ifma;
@@ -1197,7 +1197,7 @@ static void
awi_rx_int(struct awi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
struct ieee80211_node *ni;
u_int8_t state, rate, rssi;
u_int16_t len;
@@ -1274,7 +1274,7 @@ awi_rx_int(struct awi_softc *sc)
static void
awi_tx_int(struct awi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
u_int8_t flags;
while (sc->sc_txdone != sc->sc_txnext) {
@@ -1296,7 +1296,7 @@ awi_tx_int(struct awi_softc *sc)
static struct mbuf *
awi_devget(struct awi_softc *sc, u_int32_t off, u_int16_t len)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = AC2IFP(&sc->sc_arp);
struct mbuf *m;
struct mbuf *top, **mp;
u_int tlen;
@@ -1397,7 +1397,7 @@ awi_hw_init(struct awi_softc *sc)
return ENXIO;
if (i >= AWI_SELFTEST_TIMEOUT*hz/1000) {
printf("%s: failed to complete selftest (timeout)\n",
- sc->sc_if.if_xname);
+ AC2IFP(&sc->sc_arp)->if_xname);
return ENXIO;
}
status = awi_read_1(sc, AWI_SELFTEST);
@@ -1413,7 +1413,7 @@ awi_hw_init(struct awi_softc *sc)
}
if (status != AWI_SELFTEST_PASSED) {
printf("%s: failed to complete selftest (code %x)\n",
- sc->sc_if.if_xname, status);
+ AC2IFP(&sc->sc_arp)->if_xname, status);
return ENXIO;
}
@@ -1421,7 +1421,7 @@ awi_hw_init(struct awi_softc *sc)
awi_read_bytes(sc, AWI_BANNER, sc->sc_banner, AWI_BANNER_LEN);
if (memcmp(sc->sc_banner, "PCnetMobile:", 12) != 0) {
printf("%s: failed to complete selftest (bad banner)\n",
- sc->sc_if.if_xname);
+ AC2IFP(&sc->sc_arp)->if_xname);
for (i = 0; i < AWI_BANNER_LEN; i++)
printf("%s%02x", i ? ":" : "\t", sc->sc_banner[i]);
printf("\n");
@@ -1446,7 +1446,7 @@ awi_hw_init(struct awi_softc *sc)
error = awi_cmd(sc, AWI_CMD_NOP, AWI_WAIT);
if (error) {
printf("%s: failed to complete selftest",
- sc->sc_if.if_xname);
+ AC2IFP(&sc->sc_arp)->if_xname);
if (error == ENXIO)
printf(" (no hardware)\n");
else if (error != EWOULDBLOCK)
@@ -1484,7 +1484,7 @@ awi_init_mibs(struct awi_softc *sc)
(error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_MGT, AWI_WAIT)) ||
(error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_PHY, AWI_WAIT))) {
printf("%s: failed to get default mib value (error %d)\n",
- sc->sc_if.if_xname, error);
+ AC2IFP(&sc->sc_arp)->if_xname, error);
return error;
}
@@ -1492,7 +1492,7 @@ awi_init_mibs(struct awi_softc *sc)
for (cs = awi_chanset; ; cs++) {
if (cs->cs_type == 0) {
printf("%s: failed to set available channel\n",
- sc->sc_if.if_xname);
+ AC2IFP(&sc->sc_arp)->if_xname);
return ENXIO;
}
if (cs->cs_type == sc->sc_mib_phy.IEEE_PHY_Type &&
@@ -1672,7 +1672,7 @@ awi_cmd(struct awi_softc *sc, u_int8_t cmd, int wflag)
return EINVAL;
default:
printf("%s: command %d failed %x\n",
- sc->sc_if.if_xname, cmd, status);
+ AC2IFP(&sc->sc_arp)->if_xname, cmd, status);
return ENXIO;
}
return 0;
@@ -1689,7 +1689,7 @@ awi_cmd_wait(struct awi_softc *sc)
return ENXIO;
if (awi_read_1(sc, AWI_CMD) != sc->sc_cmd_inprog) {
printf("%s: failed to access hardware\n",
- sc->sc_if.if_xname);
+ AC2IFP(&sc->sc_arp)->if_xname);
sc->sc_invalid = 1;
return ENXIO;
}
@@ -1734,7 +1734,7 @@ awi_cmd_done(struct awi_softc *sc)
if (status != AWI_STAT_OK) {
printf("%s: command %d failed %x\n",
- sc->sc_if.if_xname, cmd, status);
+ AC2IFP(&sc->sc_arp)->if_xname, cmd, status);
sc->sc_substate = AWI_ST_NONE;
return;
}
@@ -1849,7 +1849,7 @@ awi_intr_lock(struct awi_softc *sc)
}
if (status != 0) {
printf("%s: failed to lock interrupt\n",
- sc->sc_if.if_xname);
+ AC2IFP(&sc->sc_arp)->if_xname);
return ENXIO;
}
return 0;
diff --git a/sys/dev/awi/awivar.h b/sys/dev/awi/awivar.h
index 64da83d..25934ab 100644
--- a/sys/dev/awi/awivar.h
+++ b/sys/dev/awi/awivar.h
@@ -79,7 +79,6 @@ struct awi_softc {
#endif
#ifdef __FreeBSD__
struct arpcom sc_arp;
-#define sc_if sc_arp.ac_if
device_t sc_dev;
#endif
struct am79c930_softc sc_chip;
diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c
index dc609e6..1df3168 100644
--- a/sys/dev/bfe/if_bfe.c
+++ b/sys/dev/bfe/if_bfe.c
@@ -322,7 +322,7 @@ bfe_dma_alloc(device_t dev)
static int
bfe_attach(device_t dev)
{
- struct ifnet *ifp;
+ struct ifnet *ifp = NULL;
struct bfe_softc *sc;
int unit, error = 0, rid;
@@ -372,7 +372,12 @@ bfe_attach(device_t dev)
}
/* Set up ifnet structure */
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bfe_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("bfe%d: failed to if_alloc()\n", sc->bfe_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -400,7 +405,7 @@ bfe_attach(device_t dev)
goto fail;
}
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->bfe_enaddr);
callout_handle_init(&sc->bfe_stat_ch);
/*
@@ -422,8 +427,11 @@ bfe_attach(device_t dev)
goto fail;
}
fail:
- if(error)
+ if(error) {
bfe_release_resources(sc);
+ if (ifp != NULL)
+ if_free(ifp);
+ }
return (error);
}
@@ -438,11 +446,12 @@ bfe_detach(device_t dev)
KASSERT(mtx_initialized(&sc->bfe_mtx), ("bfe mutex not initialized"));
BFE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bfe_ifp;
if (device_is_attached(dev)) {
bfe_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
bfe_chip_reset(sc);
@@ -610,12 +619,12 @@ bfe_get_config(struct bfe_softc *sc)
bfe_read_eeprom(sc, eeprom);
- sc->arpcom.ac_enaddr[0] = eeprom[79];
- sc->arpcom.ac_enaddr[1] = eeprom[78];
- sc->arpcom.ac_enaddr[2] = eeprom[81];
- sc->arpcom.ac_enaddr[3] = eeprom[80];
- sc->arpcom.ac_enaddr[4] = eeprom[83];
- sc->arpcom.ac_enaddr[5] = eeprom[82];
+ sc->bfe_enaddr[0] = eeprom[79];
+ sc->bfe_enaddr[1] = eeprom[78];
+ sc->bfe_enaddr[2] = eeprom[81];
+ sc->bfe_enaddr[3] = eeprom[80];
+ sc->bfe_enaddr[4] = eeprom[83];
+ sc->bfe_enaddr[5] = eeprom[82];
sc->bfe_phyaddr = eeprom[90] & 0x1f;
sc->bfe_mdc_port = (eeprom[90] >> 14) & 0x1;
@@ -849,7 +858,7 @@ bfe_cam_write(struct bfe_softc *sc, u_char *data, int index)
static void
bfe_set_rx_mode(struct bfe_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->bfe_ifp;
struct ifmultiaddr *ifma;
u_int32_t val;
int i = 0;
@@ -868,7 +877,7 @@ bfe_set_rx_mode(struct bfe_softc *sc)
CSR_WRITE_4(sc, BFE_CAM_CTRL, 0);
- bfe_cam_write(sc, sc->arpcom.ac_enaddr, i++);
+ bfe_cam_write(sc, IFP2ENADDR(sc->bfe_ifp), i++);
if (ifp->if_flags & IFF_ALLMULTI)
val |= BFE_RXCONF_ALLMULTI;
@@ -1077,7 +1086,7 @@ bfe_txeof(struct bfe_softc *sc)
BFE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bfe_ifp;
chipidx = CSR_READ_4(sc, BFE_DMATX_STAT) & BFE_STAT_CDMASK;
chipidx /= sizeof(struct bfe_desc);
@@ -1123,7 +1132,7 @@ bfe_rxeof(struct bfe_softc *sc)
status = CSR_READ_4(sc, BFE_DMARX_STAT);
current = (status & BFE_STAT_CDMASK) / sizeof(struct bfe_desc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bfe_ifp;
while(current != cons) {
r = &sc->bfe_rx_ring[cons];
@@ -1177,7 +1186,7 @@ bfe_intr(void *xsc)
struct ifnet *ifp;
u_int32_t istat, imask, flag;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bfe_ifp;
BFE_LOCK(sc);
@@ -1395,7 +1404,7 @@ static void
bfe_init_locked(void *xsc)
{
struct bfe_softc *sc = (struct bfe_softc*)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->bfe_ifp;
BFE_LOCK_ASSERT(sc);
@@ -1567,7 +1576,7 @@ bfe_stop(struct bfe_softc *sc)
untimeout(bfe_tick, sc, sc->bfe_stat_ch);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bfe_ifp;
bfe_chip_halt(sc);
bfe_tx_ring_free(sc);
diff --git a/sys/dev/bfe/if_bfereg.h b/sys/dev/bfe/if_bfereg.h
index c76779a..da7cb4f 100644
--- a/sys/dev/bfe/if_bfereg.h
+++ b/sys/dev/bfe/if_bfereg.h
@@ -491,7 +491,7 @@ struct bfe_hw_stats {
struct bfe_softc
{
- struct arpcom arpcom; /* interface info */
+ struct ifnet *bfe_ifp; /* interface info */
device_t bfe_dev;
device_t bfe_miibus;
bus_space_handle_t bfe_bhandle;
@@ -522,6 +522,7 @@ struct bfe_softc
u_int8_t bfe_unit; /* interface number */
u_int8_t bfe_core_unit;
u_int8_t bfe_up;
+ u_char bfe_enaddr[6];
int bfe_if_flags;
char *bfe_vpd_prodname;
char *bfe_vpd_readonly;
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 62a2cf6..cad9143b 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -1156,7 +1156,7 @@ bge_setmulti(sc)
BGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
for (i = 0; i < 4; i++)
@@ -1544,9 +1544,9 @@ bge_blockinit(sc)
/* Set random backoff seed for TX */
CSR_WRITE_4(sc, BGE_TX_RANDOM_BACKOFF,
- sc->arpcom.ac_enaddr[0] + sc->arpcom.ac_enaddr[1] +
- sc->arpcom.ac_enaddr[2] + sc->arpcom.ac_enaddr[3] +
- sc->arpcom.ac_enaddr[4] + sc->arpcom.ac_enaddr[5] +
+ IFP2ENADDR(sc->bge_ifp)[0] + IFP2ENADDR(sc->bge_ifp)[1] +
+ IFP2ENADDR(sc->bge_ifp)[2] + IFP2ENADDR(sc->bge_ifp)[3] +
+ IFP2ENADDR(sc->bge_ifp)[4] + IFP2ENADDR(sc->bge_ifp)[5] +
BGE_TX_BACKOFF_SEED_MASK);
/* Set inter-packet gap */
@@ -2248,7 +2248,8 @@ bge_attach(dev)
struct ifnet *ifp;
struct bge_softc *sc;
u_int32_t hwcfg = 0;
- u_int32_t mac_addr = 0;
+ u_int32_t mac_tmp = 0;
+ u_char eaddr[6];
int unit, error = 0, rid;
sc = device_get_softc(dev);
@@ -2334,16 +2335,16 @@ bge_attach(dev)
/*
* Get station address from the EEPROM.
*/
- mac_addr = bge_readmem_ind(sc, 0x0c14);
- if ((mac_addr >> 16) == 0x484b) {
- sc->arpcom.ac_enaddr[0] = (u_char)(mac_addr >> 8);
- sc->arpcom.ac_enaddr[1] = (u_char)mac_addr;
- mac_addr = bge_readmem_ind(sc, 0x0c18);
- sc->arpcom.ac_enaddr[2] = (u_char)(mac_addr >> 24);
- sc->arpcom.ac_enaddr[3] = (u_char)(mac_addr >> 16);
- sc->arpcom.ac_enaddr[4] = (u_char)(mac_addr >> 8);
- sc->arpcom.ac_enaddr[5] = (u_char)mac_addr;
- } else if (bge_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
+ mac_tmp = bge_readmem_ind(sc, 0x0c14);
+ if ((mac_tmp >> 16) == 0x484b) {
+ eaddr[0] = (u_char)(mac_tmp >> 8);
+ eaddr[1] = (u_char)mac_tmp;
+ mac_tmp = bge_readmem_ind(sc, 0x0c18);
+ eaddr[2] = (u_char)(mac_tmp >> 24);
+ eaddr[3] = (u_char)(mac_tmp >> 16);
+ eaddr[4] = (u_char)(mac_tmp >> 8);
+ eaddr[5] = (u_char)mac_tmp;
+ } else if (bge_read_eeprom(sc, eaddr,
BGE_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) {
printf("bge%d: failed to read station address\n", unit);
bge_release_resources(sc);
@@ -2389,7 +2390,13 @@ bge_attach(dev)
sc->bge_tx_max_coal_bds = 128;
/* Set up ifnet structure */
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("bge%d: failed to if_alloc()\n", sc->bge_unit);
+ bge_release_resources(sc);
+ error = ENXIO;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -2449,6 +2456,7 @@ bge_attach(dev)
printf("bge%d: MII without any PHY!\n", sc->bge_unit);
bge_release_resources(sc);
bge_free_jumbo_mem(sc);
+ if_free(ifp);
error = ENXIO;
goto fail;
}
@@ -2478,7 +2486,7 @@ bge_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
callout_init(&sc->bge_stat_ch, CALLOUT_MPSAFE);
/*
@@ -2488,7 +2496,7 @@ bge_attach(dev)
bge_intr, sc, &sc->bge_intrhand);
if (error) {
- bge_release_resources(sc);
+ bge_detach(dev);
printf("bge%d: couldn't set up irq\n", unit);
}
@@ -2504,7 +2512,7 @@ bge_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
BGE_LOCK(sc);
bge_stop(sc);
@@ -2512,6 +2520,7 @@ bge_detach(dev)
BGE_UNLOCK(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
if (sc->bge_tbi) {
ifmedia_removeall(&sc->bge_ifmedia);
@@ -2708,7 +2717,7 @@ bge_rxeof(sc)
BGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
bus_dmamap_sync(sc->bge_cdata.bge_rx_return_ring_tag,
sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTWRITE);
@@ -2856,7 +2865,7 @@ bge_txeof(sc)
BGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
/*
* Go through our tx ring and free mbufs for those
@@ -2897,7 +2906,7 @@ bge_intr(xsc)
u_int32_t status, mimode;
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
BGE_LOCK(sc);
@@ -3014,7 +3023,7 @@ bge_tick_locked(sc)
struct ifmedia *ifm = NULL;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
BGE_LOCK_ASSERT(sc);
@@ -3084,7 +3093,7 @@ bge_stats_update_regs(sc)
u_int32_t *s;
int i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
s = (u_int32_t *)&stats;
for (i = 0; i < sizeof(struct bge_mac_stats_regs); i += 4) {
@@ -3109,7 +3118,7 @@ bge_stats_update(sc)
struct ifnet *ifp;
struct bge_stats *stats;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
stats = (struct bge_stats *)(sc->bge_vhandle +
BGE_MEMWIN_START + BGE_STATS_BLOCK);
@@ -3162,7 +3171,7 @@ bge_encap(sc, m_head, txidx)
csum_flags |= BGE_TXBDFLAG_IP_FRAG;
}
- mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m_head);
+ mtag = VLAN_OUTPUT_TAG(sc->bge_ifp, m_head);
ctx.sc = sc;
ctx.bge_idx = *txidx;
@@ -3317,7 +3326,7 @@ bge_init_locked(sc)
BGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
if (ifp->if_flags & IFF_RUNNING)
return;
@@ -3336,14 +3345,14 @@ bge_init_locked(sc)
return;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
/* Specify MTU. */
CSR_WRITE_4(sc, BGE_RX_MTU, ifp->if_mtu +
ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
/* Load our MAC address. */
- m = (u_int16_t *)&sc->arpcom.ac_enaddr[0];
+ m = (u_int16_t *)&IFP2ENADDR(sc->bge_ifp)[0];
CSR_WRITE_4(sc, BGE_MAC_ADDR1_LO, htons(m[0]));
CSR_WRITE_4(sc, BGE_MAC_ADDR1_HI, (htons(m[1]) << 16) | htons(m[2]));
@@ -3638,7 +3647,7 @@ bge_stop(sc)
BGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->bge_ifp;
if (!sc->bge_tbi)
mii = device_get_softc(sc->bge_miibus);
diff --git a/sys/dev/bge/if_bgereg.h b/sys/dev/bge/if_bgereg.h
index e621200..76664fc 100644
--- a/sys/dev/bge/if_bgereg.h
+++ b/sys/dev/bge/if_bgereg.h
@@ -2313,7 +2313,7 @@ struct bge_bcom_hack {
};
struct bge_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *bge_ifp; /* interface info */
device_t bge_dev;
struct mtx bge_mtx;
device_t bge_miibus;
diff --git a/sys/dev/cm/if_cm_isa.c b/sys/dev/cm/if_cm_isa.c
index 8f7732f..027d139 100644
--- a/sys/dev/cm/if_cm_isa.c
+++ b/sys/dev/cm/if_cm_isa.c
@@ -103,14 +103,15 @@ static int
cm_isa_detach(device_t dev)
{
struct cm_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_arccom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
int s;
cm_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
s = splimp();
- arc_ifdetach(&sc->sc_arccom.ac_if);
+ arc_ifdetach(ifp);
+ if_free(ifp);
splx(s);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
diff --git a/sys/dev/cm/smc90cx6.c b/sys/dev/cm/smc90cx6.c
index 4bfed97..b2316b0 100644
--- a/sys/dev/cm/smc90cx6.c
+++ b/sys/dev/cm/smc90cx6.c
@@ -277,10 +277,15 @@ cm_attach(dev)
device_t dev;
{
struct cm_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_arccom.ac_if;
+ struct ifnet *ifp;
int s;
u_int8_t linkaddress;
+ ifp = sc->sc_ifp = if_alloc(IFT_ARCNET);
+ if (ifp == NULL) {
+ return (ENOSPC);
+ }
+
s = splhigh();
/*
@@ -353,7 +358,7 @@ cm_init(xsc)
struct ifnet *ifp;
int s;
- ifp = &sc->sc_arccom.ac_if;
+ ifp = sc->sc_ifp;
if ((ifp->if_flags & IFF_RUNNING) == 0) {
s = splimp();
@@ -377,7 +382,7 @@ cm_reset(sc)
struct ifnet *ifp;
int linkaddress;
- ifp = &sc->sc_arccom.ac_if;
+ ifp = sc->sc_ifp;
#ifdef CM_DEBUG
if_printf(ifp, "reset\n");
@@ -456,7 +461,7 @@ cm_stop(sc)
GETREG(CMRESET);
/* Stop watchdog timer */
- sc->sc_arccom.ac_if.if_timer = 0;
+ sc->sc_ifp->if_timer = 0;
}
/*
@@ -589,7 +594,7 @@ cm_start(ifp)
PUTREG(CMCMD, CM_TX(buffer));
PUTREG(CMSTAT, sc->sc_intmask);
- sc->sc_arccom.ac_if.if_timer = ARCTIMEOUT;
+ ifp->if_timer = ARCTIMEOUT;
}
splx(s);
m_freem(m);
@@ -619,7 +624,7 @@ cm_srint(vsc)
struct arc_header *ah;
struct ifnet *ifp;
- ifp = &sc->sc_arccom.ac_if;
+ ifp = sc->sc_ifp;
s = splimp();
buffer = sc->sc_rx_act ^ 1;
@@ -733,7 +738,7 @@ cm_tint(sc, isr)
int clknow;
#endif
- ifp = &(sc->sc_arccom.ac_if);
+ ifp = sc->sc_ifp;
buffer = sc->sc_tx_act;
/*
@@ -744,7 +749,7 @@ cm_tint(sc, isr)
*/
if (isr & CM_TMA || sc->sc_broadcast[buffer])
- sc->sc_arccom.ac_if.if_opackets++;
+ ifp->if_opackets++;
#ifdef CMRETRANSMIT
else if (ifp->if_flags & IFF_LINK2 && ifp->if_timer > 0
&& --sc->sc_retransmits[buffer] > 0) {
@@ -814,7 +819,7 @@ cmintr(arg)
void *arg;
{
struct cm_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_arccom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_char isr, maskedisr;
int buffer;
@@ -835,7 +840,7 @@ cmintr(arg)
/*
* XXX We should never see this. Don't bother to store
* the address.
- * sc->sc_arccom.ac_anaddr = GETMEM(CMMACOFF);
+ * sc->sc_ifp->if_l2com->ac_anaddr = GETMEM(CMMACOFF);
*/
PUTREG(CMCMD, CM_CLR(CLR_POR));
log(LOG_WARNING,
@@ -849,7 +854,7 @@ cmintr(arg)
* PUTREG(CMCMD, CM_CONF(CONF_LONG));
*/
PUTREG(CMCMD, CM_CLR(CLR_RECONFIG));
- sc->sc_arccom.ac_if.if_collisions++;
+ ifp->if_collisions++;
/*
* If less than 2 seconds per reconfig:
@@ -952,7 +957,7 @@ cm_reconwatch(arg)
void *arg;
{
struct cm_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_arccom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
if (sc->sc_reconcount >= ARC_EXCESSIVE_RECONS) {
sc->sc_reconcount = 0;
diff --git a/sys/dev/cm/smc90cx6var.h b/sys/dev/cm/smc90cx6var.h
index 1703145..7130a8800 100644
--- a/sys/dev/cm/smc90cx6var.h
+++ b/sys/dev/cm/smc90cx6var.h
@@ -56,7 +56,7 @@
#include <sys/callout.h>
struct cm_softc {
- struct arccom sc_arccom; /* Common arcnet structures */
+ struct ifnet *sc_ifp; /* Common arcnet structures */
int port_rid; /* resource id for port range */
struct resource *port_res; /* resource for port range */
diff --git a/sys/dev/cnw/if_cnw.c b/sys/dev/cnw/if_cnw.c
index d1891c3..d4f98c7 100644
--- a/sys/dev/cnw/if_cnw.c
+++ b/sys/dev/cnw/if_cnw.c
@@ -288,7 +288,7 @@ int cnw_skey = CNW_SCRAMBLEKEY; /* Scramble key */
#endif
struct cnw_softc {
- struct arpcom arpcom;
+ struct ifnet *sc_ifp;
struct ifmedia ifmedia;
device_t dev;
struct cnwstats sc_stats;
@@ -510,7 +510,7 @@ cnw_init(sc)
#if !defined(__FreeBSD__)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else /* FreeBSD */
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
#endif
const u_int8_t rxmode =
CNW_RXCONF_RXENA | CNW_RXCONF_BCAST | CNW_RXCONF_AMP;
@@ -949,7 +949,7 @@ cnw_read(sc)
#if !defined(__FreeBSD__)
m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
#else /* FreeBSD */
- m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ m->m_pkthdr.rcvif = sc->sc_ifp;
#endif
m->m_pkthdr.len = totbytes;
mbytes = MHLEN;
@@ -1024,7 +1024,7 @@ cnw_recv(sc)
#if !defined(__FreeBSD__)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
#endif
struct mbuf *m;
@@ -1076,7 +1076,7 @@ cnw_intr(arg)
#if !defined(__FreeBSD__)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
#endif
int ret, status, rser, tser;
@@ -1498,7 +1498,7 @@ static void cnw_freebsd_init(xsc)
void *xsc;
{
struct cnw_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
int s;
if (sc->cnw_gone)
@@ -1534,7 +1534,7 @@ static void cnw_stop(sc)
cnw_reset(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sc_ifp;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
return;
@@ -1571,7 +1571,7 @@ static int cnw_pccard_detach(dev)
#endif
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sc_ifp;
if (sc->cnw_gone) {
device_printf(dev, "already unloaded\n");
@@ -1581,6 +1581,7 @@ static int cnw_pccard_detach(dev)
cnw_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
cnw_free(dev);
sc->cnw_gone = 1;
@@ -1595,9 +1596,15 @@ static int cnw_pccard_attach(device_t dev)
struct cnw_softc *sc;
struct ifnet *ifp;
int i, error;
+ u_char eaddr[6];
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "if_alloc() failed\n");
+ return (ENOSPC);
+ }
+
error = cnw_alloc(dev);
if (error) {
@@ -1623,8 +1630,7 @@ static int cnw_pccard_attach(device_t dev)
/* Get MAC address */
for (i=0; i< ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] =
- bus_space_read_1(sc->sc_memt, sc->sc_memh,
+ eaddr[i] = bus_space_read_1(sc->sc_memt, sc->sc_memh,
sc->sc_memoff + CNW_EREG_PA + i);
}
@@ -1647,7 +1653,7 @@ static int cnw_pccard_attach(device_t dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* callout_handle_init(&sc->cnw_stat_ch); */
return(0);
diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c
index df8f7ce..39990fe 100644
--- a/sys/dev/cp/if_cp.c
+++ b/sys/dev/cp/if_cp.c
@@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$");
# include <dev/cp/ng_cp.h>
#else
# include <net/if_sppp.h>
+# include <net/if_types.h>
+#include <dev/pci/pcivar.h>
# define PP_CISCO IFF_LINK2
# include <net/bpf.h>
#endif
@@ -135,7 +137,7 @@ typedef struct _drv_t {
struct callout timeout_handle;
#else
struct ifqueue queue;
- struct sppp pp;
+ struct ifnet *ifp;
#endif
struct cdev *devt;
} drv_t;
@@ -329,7 +331,7 @@ static void cp_intr (void *arg)
IF_DEQUEUE (&d->queue,m);
if (!m)
continue;
- sppp_input (&d->pp.pp_if, m);
+ sppp_input (d->ifp, m);
}
}
#endif
@@ -514,25 +516,30 @@ static int cp_attach (device_t dev)
callout_init (&d->timeout_handle,
cp_mpsafenet ? CALLOUT_MPSAFE : 0);
#else /*NETGRAPH*/
- d->pp.pp_if.if_softc = d;
- if_initname (&d->pp.pp_if, "cp", b->num * NCHAN + c->num);
- d->pp.pp_if.if_mtu = PP_MTU;
- d->pp.pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
+ d->ifp = if_alloc(IFT_PPP);
+ if (d->ifp == NULL) {
+ printf ("%s: cannot if_alloc() interface\n", d->name);
+ continue;
+ }
+ d->ifp->if_softc = d;
+ if_initname (d->ifp, "cp", b->num * NCHAN + c->num);
+ d->ifp->if_mtu = PP_MTU;
+ d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
if (!cp_mpsafenet)
- d->pp.pp_if.if_flags |= IFF_NEEDSGIANT;
- d->pp.pp_if.if_ioctl = cp_sioctl;
- d->pp.pp_if.if_start = cp_ifstart;
- d->pp.pp_if.if_watchdog = cp_ifwatchdog;
- d->pp.pp_if.if_init = cp_initialize;
+ d->ifp->if_flags |= IFF_NEEDSGIANT;
+ d->ifp->if_ioctl = cp_sioctl;
+ d->ifp->if_start = cp_ifstart;
+ d->ifp->if_watchdog = cp_ifwatchdog;
+ d->ifp->if_init = cp_initialize;
d->queue.ifq_maxlen = NRBUF;
mtx_init (&d->queue.ifq_mtx, "cp_queue", NULL, MTX_DEF);
- sppp_attach (&d->pp.pp_if);
- if_attach (&d->pp.pp_if);
- d->pp.pp_tlf = cp_tlf;
- d->pp.pp_tls = cp_tls;
+ sppp_attach (d->ifp);
+ if_attach (d->ifp);
+ IFP2SP(d->ifp)->pp_tlf = cp_tlf;
+ IFP2SP(d->ifp)->pp_tls = cp_tls;
/* If BPF is in the kernel, call the attach for it.
* The header size of PPP or Cisco/HDLC is 4 bytes. */
- bpfattach (&d->pp.pp_if, DLT_PPP, 4);
+ bpfattach (d->ifp, DLT_PPP, 4);
#endif /*NETGRAPH*/
cp_start_e1 (c);
cp_start_chan (c, 1, 1, d->dmamem.virt, d->dmamem.phys);
@@ -603,13 +610,14 @@ static int cp_detach (device_t dev)
continue;
#ifndef NETGRAPH
/* Detach from the packet filter list of interfaces. */
- bpfdetach (&d->pp.pp_if);
+ bpfdetach (d->ifp);
/* Detach from the sync PPP list. */
- sppp_detach (&d->pp.pp_if);
+ sppp_detach (d->ifp);
/* Detach from the system list of interfaces. */
- if_detach (&d->pp.pp_if);
+ if_detach (d->ifp);
+ if_free (d->ifp);
IF_DRAIN (&d->queue);
mtx_destroy (&d->queue.ifq_mtx);
#else
@@ -677,22 +685,22 @@ static void cp_ifwatchdog (struct ifnet *ifp)
static void cp_tlf (struct sppp *sp)
{
- drv_t *d = sp->pp_if.if_softc;
+ drv_t *d = SP2IFP(sp)->if_softc;
CP_DEBUG2 (d, ("cp_tlf\n"));
/* XXXRIK: Don't forget to protect them by LOCK, or kill them. */
/* cp_set_dtr (d->chan, 0);*/
/* cp_set_rts (d->chan, 0);*/
- if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
+ if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_down (sp);
}
static void cp_tls (struct sppp *sp)
{
- drv_t *d = sp->pp_if.if_softc;
+ drv_t *d = SP2IFP(sp)->if_softc;
CP_DEBUG2 (d, ("cp_tls\n"));
- if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
+ if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_up (sp);
}
@@ -734,7 +742,7 @@ static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
cp_start (d);
} else if (was_up && ! should_be_up) {
/* Interface is going down -- stop it. */
-/* if ((d->pp.pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
+/* if ((IFP2SP(ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
cp_down (d);
}
CP_DEBUG (d, ("ioctl 0x%lx p4\n", cmd));
@@ -807,13 +815,13 @@ static void cp_send (drv_t *d)
if (! m)
IF_DEQUEUE (&d->queue, m);
#else
- m = sppp_dequeue (&d->pp.pp_if);
+ m = sppp_dequeue (d->ifp);
#endif
if (! m)
return;
#ifndef NETGRAPH
- if (d->pp.pp_if.if_bpf)
- BPF_MTAP (&d->pp.pp_if, m);
+ if (d->ifp->if_bpf)
+ BPF_MTAP (d->ifp, m);
#endif
len = m->m_pkthdr.len;
if (len >= BUFSZ)
@@ -831,11 +839,11 @@ static void cp_send (drv_t *d)
#ifdef NETGRAPH
d->timeout = 10;
#else
- d->pp.pp_if.if_timer = 10;
+ d->ifp->if_timer = 10;
#endif
}
#ifndef NETGRAPH
- d->pp.pp_if.if_flags |= IFF_OACTIVE;
+ d->ifp->if_flags |= IFF_OACTIVE;
#endif
}
@@ -886,9 +894,9 @@ static void cp_transmit (cp_chan_t *c, void *attachment, int len)
#ifdef NETGRAPH
d->timeout = 0;
#else
- ++d->pp.pp_if.if_opackets;
- d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
- d->pp.pp_if.if_timer = 0;
+ ++d->ifp->if_opackets;
+ d->ifp->if_flags &= ~IFF_OACTIVE;
+ d->ifp->if_timer = 0;
#endif
cp_start (d);
}
@@ -908,7 +916,7 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
if (! m) {
CP_DEBUG (d, ("no memory for packet\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_iqdrops;
+ ++d->ifp->if_iqdrops;
#endif
return;
}
@@ -918,12 +926,12 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
m->m_pkthdr.rcvif = 0;
NG_SEND_DATA_ONLY (error, d->hook, m);
#else
- ++d->pp.pp_if.if_ipackets;
- m->m_pkthdr.rcvif = &d->pp.pp_if;
+ ++d->ifp->if_ipackets;
+ m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->pp.pp_if.if_bpf)
- BPF_TAP (&d->pp.pp_if, data, len);
+ if (d->ifp->if_bpf)
+ BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
@@ -936,26 +944,26 @@ static void cp_error (cp_chan_t *c, int data)
case CP_FRAME:
CP_DEBUG (d, ("frame error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CP_CRC:
CP_DEBUG (d, ("crc error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CP_OVERRUN:
CP_DEBUG (d, ("overrun error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_collisions;
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_collisions;
+ ++d->ifp->if_ierrors;
#endif
break;
case CP_OVERFLOW:
CP_DEBUG (d, ("overflow error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CP_UNDERRUN:
@@ -963,9 +971,9 @@ static void cp_error (cp_chan_t *c, int data)
#ifdef NETGRAPH
d->timeout = 0;
#else
- ++d->pp.pp_if.if_oerrors;
- d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
- d->pp.pp_if.if_timer = 0;
+ ++d->ifp->if_oerrors;
+ d->ifp->if_flags &= ~IFF_OACTIVE;
+ d->ifp->if_timer = 0;
#endif
cp_start (d);
break;
@@ -1044,8 +1052,8 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
#ifndef NETGRAPH
case SERIAL_GETPROTO:
CP_DEBUG2 (d, ("ioctl: getproto\n"));
- strcpy ((char*)data, (d->pp.pp_flags & PP_FR) ? "fr" :
- (d->pp.pp_if.if_flags & PP_CISCO) ? "cisco" : "ppp");
+ strcpy ((char*)data, (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" :
+ (d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp");
return 0;
case SERIAL_SETPROTO:
@@ -1054,29 +1062,29 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
- if (d->pp.pp_if.if_flags & IFF_RUNNING)
+ if (d->ifp->if_flags & IFF_RUNNING)
return EBUSY;
if (! strcmp ("cisco", (char*)data)) {
- d->pp.pp_flags &= ~(PP_FR);
- d->pp.pp_flags |= PP_KEEPALIVE;
- d->pp.pp_if.if_flags |= PP_CISCO;
+ IFP2SP(d->ifp)->pp_flags &= ~(PP_FR);
+ IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
+ d->ifp->if_flags |= PP_CISCO;
} else if (! strcmp ("fr", (char*)data) && PP_FR) {
- d->pp.pp_if.if_flags &= ~(PP_CISCO);
- d->pp.pp_flags |= PP_FR | PP_KEEPALIVE;
+ d->ifp->if_flags &= ~(PP_CISCO);
+ IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE;
} else if (! strcmp ("ppp", (char*)data)) {
- d->pp.pp_flags &= ~PP_FR;
- d->pp.pp_flags &= ~PP_KEEPALIVE;
- d->pp.pp_if.if_flags &= ~(PP_CISCO);
+ IFP2SP(d->ifp)->pp_flags &= ~PP_FR;
+ IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
+ d->ifp->if_flags &= ~(PP_CISCO);
} else
return EINVAL;
return 0;
case SERIAL_GETKEEPALIVE:
CP_DEBUG2 (d, ("ioctl: getkeepalive\n"));
- if ((d->pp.pp_flags & PP_FR) ||
- (d->pp.pp_if.if_flags & PP_CISCO))
+ if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
+ (d->ifp->if_flags & PP_CISCO))
return EINVAL;
- *(int*)data = (d->pp.pp_flags & PP_KEEPALIVE) ? 1 : 0;
+ *(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0;
return 0;
case SERIAL_SETKEEPALIVE:
@@ -1085,15 +1093,15 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
- if ((d->pp.pp_flags & PP_FR) ||
- (d->pp.pp_if.if_flags & PP_CISCO))
+ if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
+ (d->ifp->if_flags & PP_CISCO))
return EINVAL;
s = splimp ();
CP_LOCK (bd);
if (*(int*)data)
- d->pp.pp_flags |= PP_KEEPALIVE;
+ IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
else
- d->pp.pp_flags &= ~PP_KEEPALIVE;
+ IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
CP_UNLOCK (bd);
splx (s);
return 0;
@@ -1334,9 +1342,9 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
d->chan->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
- d->pp.pp_if.if_flags |= IFF_DEBUG;
+ d->ifp->if_flags |= IFF_DEBUG;
else
- d->pp.pp_if.if_flags &= ~IFF_DEBUG;
+ d->ifp->if_flags &= ~IFF_DEBUG;
#endif
return 0;
diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c
index eb93e54..293ae80 100644
--- a/sys/dev/cs/if_cs.c
+++ b/sys/dev/cs/if_cs.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/bpf.h>
@@ -196,7 +197,7 @@ cs_duplex_auto(struct cs_softc *sc)
RE_NEG_NOW | ALLOW_FDX | AUTO_NEG_ENABLE);
for (i=0; cs_readreg(sc, PP_AutoNegST) & AUTO_NEG_BUSY; i++) {
if (i > 40000) {
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->ifp,
"full/half duplex auto negotiation timeout\n");
error = ETIMEDOUT;
break;
@@ -216,7 +217,7 @@ enable_tp(struct cs_softc *sc)
DELAY( 150000 );
if ((cs_readreg(sc, PP_LineST) & LINK_OK)==0) {
- if_printf(&sc->arpcom.ac_if, "failed to enable TP\n");
+ if_printf(sc->ifp, "failed to enable TP\n");
return (EINVAL);
}
@@ -237,12 +238,12 @@ send_test_pkt(struct cs_softc *sc)
u_char ether_address_backup[ETHER_ADDR_LEN];
for (i = 0; i < ETHER_ADDR_LEN; i++)
- ether_address_backup[i] = sc->arpcom.ac_enaddr[i];
+ ether_address_backup[i] = sc->enaddr[i];
cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) | SERIAL_TX_ON);
- bcopy(test_packet, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(test_packet, sc->enaddr, ETHER_ADDR_LEN);
bcopy(test_packet+ETHER_ADDR_LEN,
- sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ sc->enaddr, ETHER_ADDR_LEN);
cs_outw(sc, TX_CMD_PORT, sc->send_cmd);
cs_outw(sc, TX_LEN_PORT, sizeof(test_packet));
@@ -250,7 +251,7 @@ send_test_pkt(struct cs_softc *sc)
DELAY(50000);
if (!(cs_readreg(sc, PP_BusST) & READY_FOR_TX_NOW)) {
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
+ sc->enaddr[i] = ether_address_backup[i];
return (0);
}
@@ -259,7 +260,7 @@ send_test_pkt(struct cs_softc *sc)
DELAY(30000);
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
+ sc->enaddr[i] = ether_address_backup[i];
if ((cs_readreg(sc, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK)
return (1);
return (0);
@@ -277,7 +278,7 @@ enable_aui(struct cs_softc *sc)
(sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
if (!send_test_pkt(sc)) {
- if_printf(&sc->arpcom.ac_if, "failed to enable AUI\n");
+ if_printf(sc->ifp, "failed to enable AUI\n");
return (EINVAL);
}
return (0);
@@ -295,7 +296,7 @@ enable_bnc(struct cs_softc *sc)
(sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
if (!send_test_pkt(sc)) {
- if_printf(&sc->arpcom.ac_if, "failed to enable BNC\n");
+ if_printf(sc->ifp, "failed to enable BNC\n");
return (EINVAL);
}
return (0);
@@ -390,9 +391,9 @@ cs_cs89x0_probe(device_t dev)
eeprom_buff[ISA_CNF_OFFSET/2];
for (i=0; i<ETHER_ADDR_LEN/2; i++) {
- sc->arpcom.ac_enaddr[i*2]=
+ sc->enaddr[i*2]=
eeprom_buff[i];
- sc->arpcom.ac_enaddr[i*2+1]=
+ sc->enaddr[i*2+1]=
eeprom_buff[i] >> 8;
}
@@ -582,7 +583,13 @@ cs_attach(device_t dev)
{
int media=0;
struct cs_softc *sc = device_get_softc(dev);;
- struct ifnet *ifp = &(sc->arpcom.ac_if);
+ struct ifnet *ifp;
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (0);
+ }
cs_stop( sc );
@@ -672,7 +679,7 @@ cs_attach(device_t dev)
ifmedia_set(&sc->media, media);
cs_mediaset(sc, media);
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
return (0);
}
@@ -684,11 +691,12 @@ cs_detach(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
cs_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
cs_release_resources(dev);
return (0);
}
@@ -700,7 +708,7 @@ static void
cs_init(void *xsc)
{
struct cs_softc *sc=(struct cs_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int i, s, rx_cfg;
/*
@@ -742,8 +750,8 @@ cs_init(void *xsc)
/* Write MAC address into IA filter */
for (i=0; i<ETHER_ADDR_LEN/2; i++)
cs_writereg(sc, PP_IA + i * 2,
- sc->arpcom.ac_enaddr[i * 2] |
- (sc->arpcom.ac_enaddr[i * 2 + 1] << 8) );
+ sc->enaddr[i * 2] |
+ (sc->enaddr[i * 2 + 1] << 8) );
/*
* Now enable everything
@@ -760,8 +768,8 @@ cs_init(void *xsc)
/*
* Set running and clear output active flags
*/
- sc->arpcom.ac_if.if_flags |= IFF_RUNNING;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags |= IFF_RUNNING;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
/*
* Start sending process
@@ -777,7 +785,7 @@ cs_init(void *xsc)
static int
cs_get_packet(struct cs_softc *sc)
{
- struct ifnet *ifp = &(sc->arpcom.ac_if);
+ struct ifnet *ifp = sc->ifp;
int iobase = sc->nic_addr, status, length;
struct ether_header *eh;
struct mbuf *m;
@@ -851,7 +859,7 @@ void
csintr(void *arg)
{
struct cs_softc *sc = (struct cs_softc*) arg;
- struct ifnet *ifp = &(sc->arpcom.ac_if);
+ struct ifnet *ifp = sc->ifp;
int status;
#ifdef CS_DEBUG
@@ -1027,8 +1035,8 @@ cs_stop(struct cs_softc *sc)
cs_writereg(sc, PP_BufCFG, 0);
cs_writereg(sc, PP_BusCTL, 0);
- sc->arpcom.ac_if.if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- sc->arpcom.ac_if.if_timer = 0;
+ sc->ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+ sc->ifp->if_timer = 0;
(void) splx(s);
}
@@ -1046,7 +1054,7 @@ cs_reset(struct cs_softc *sc)
static void
cs_setmode(struct cs_softc *sc)
{
- struct ifnet *ifp = &(sc->arpcom.ac_if);
+ struct ifnet *ifp = sc->ifp;
int rx_ctl;
/* Stop the receiver while changing filters */
@@ -1103,12 +1111,12 @@ cs_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
* Switch interface state between "running" and
* "stopped", reflecting the UP flag.
*/
- if (sc->arpcom.ac_if.if_flags & IFF_UP) {
- if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) {
+ if (sc->ifp->if_flags & IFF_UP) {
+ if ((sc->ifp->if_flags & IFF_RUNNING)==0) {
cs_init(sc);
}
} else {
- if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)!=0) {
+ if ((sc->ifp->if_flags & IFF_RUNNING)!=0) {
cs_stop(sc);
}
}
@@ -1220,7 +1228,7 @@ cs_mediaset(struct cs_softc *sc, int media)
~(SERIAL_RX_ON | SERIAL_TX_ON));
#ifdef CS_DEBUG
- if_printf(&sc->arpcom.ac_if, "cs_setmedia(%x)\n", media);
+ if_printf(sc->ifp, "cs_setmedia(%x)\n", media);
#endif
switch (IFM_SUBTYPE(media)) {
diff --git a/sys/dev/cs/if_csvar.h b/sys/dev/cs/if_csvar.h
index 58f8b6f..03c4d5d 100644
--- a/sys/dev/cs/if_csvar.h
+++ b/sys/dev/cs/if_csvar.h
@@ -36,7 +36,7 @@
*/
struct cs_softc {
/* Ethernet common code */
- struct arpcom arpcom;
+ struct ifnet *ifp;
/* Configuration words from EEPROM */
int auto_neg_cnf; /* AutoNegotitation configuration */
@@ -44,6 +44,8 @@ struct cs_softc {
int isa_config; /* ISA configuration */
int chip_type; /* Type of chip */
+ u_char enaddr[6];
+
struct ifmedia media; /* Media information */
int port_rid; /* resource id for port range */
diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c
index dafeb46..cedf3a9 100644
--- a/sys/dev/ctau/if_ct.c
+++ b/sys/dev/ctau/if_ct.c
@@ -137,7 +137,7 @@ typedef struct _drv_t {
struct callout timeout_handle;
#else
struct ifqueue queue;
- struct sppp pp;
+ struct ifnet *ifp;
#endif
struct cdev *devt;
} drv_t;
@@ -291,7 +291,7 @@ static void ct_intr (void *arg)
IF_DEQUEUE (&d->queue,m);
if (!m)
continue;
- sppp_input (&d->pp.pp_if, m);
+ sppp_input (d->ifp, m);
}
}
#endif
@@ -732,25 +732,34 @@ static int ct_attach (device_t dev)
callout_init (&d->timeout_handle,
ct_mpsafenet ? CALLOUT_MPSAFE : 0);
#else /*NETGRAPH*/
- d->pp.pp_if.if_softc = d;
- if_initname (&d->pp.pp_if, "ct", b->num * NCHAN + c->num);
- d->pp.pp_if.if_mtu = PP_MTU;
- d->pp.pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
+ d->ifp = if_alloc(IFT_PPP);
+ if (d->ifp == NULL) {
+ printf ("%s: cannot if_alloc common interface\n",
+ d->name);
+ channel [b->num*NCHAN + c->num] = 0;
+ c->sys = 0;
+ ct_bus_dma_mem_free (&d->dmamem);
+ continue;
+ }
+ d->ifp->if_softc = d;
+ if_initname (d->ifp, "ct", b->num * NCHAN + c->num);
+ d->ifp->if_mtu = PP_MTU;
+ d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
if (!ct_mpsafenet)
- d->pp.pp_if.if_flags |= IFF_NEEDSGIANT;
- d->pp.pp_if.if_ioctl = ct_sioctl;
- d->pp.pp_if.if_start = ct_ifstart;
- d->pp.pp_if.if_watchdog = ct_ifwatchdog;
- d->pp.pp_if.if_init = ct_initialize;
+ d->ifp->if_flags |= IFF_NEEDSGIANT;
+ d->ifp->if_ioctl = ct_sioctl;
+ d->ifp->if_start = ct_ifstart;
+ d->ifp->if_watchdog = ct_ifwatchdog;
+ d->ifp->if_init = ct_initialize;
d->queue.ifq_maxlen = NBUF;
mtx_init (&d->queue.ifq_mtx, "ct_queue", NULL, MTX_DEF);
- sppp_attach (&d->pp.pp_if);
- if_attach (&d->pp.pp_if);
- d->pp.pp_tlf = ct_tlf;
- d->pp.pp_tls = ct_tls;
+ sppp_attach (d->ifp);
+ if_attach (d->ifp);
+ IFP2SP(d->ifp)->pp_tlf = ct_tlf;
+ IFP2SP(d->ifp)->pp_tls = ct_tls;
/* If BPF is in the kernel, call the attach for it.
* Header size is 4 bytes. */
- bpfattach (&d->pp.pp_if, DLT_PPP, 4);
+ bpfattach (d->ifp, DLT_PPP, 4);
#endif /*NETGRAPH*/
CT_LOCK (bd);
ct_start_chan (c, d->dmamem.virt, d->dmamem.phys);
@@ -827,12 +836,13 @@ static int ct_detach (device_t dev)
mtx_destroy (&d->hi_queue.ifq_mtx);
#else
/* Detach from the packet filter list of interfaces. */
- bpfdetach (&d->pp.pp_if);
+ bpfdetach (d->ifp);
/* Detach from the sync PPP list. */
- sppp_detach (&d->pp.pp_if);
+ sppp_detach (d->ifp);
- if_detach (&d->pp.pp_if);
+ if_detach (d->ifp);
+ if_free (d->ifp);
IF_DRAIN (&d->queue);
mtx_destroy (&d->queue.ifq_mtx);
#endif
@@ -885,21 +895,21 @@ static void ct_ifwatchdog (struct ifnet *ifp)
static void ct_tlf (struct sppp *sp)
{
- drv_t *d = sp->pp_if.if_softc;
+ drv_t *d = SP2IFP(sp)->if_softc;
CT_DEBUG (d, ("ct_tlf\n"));
/* ct_set_dtr (d->chan, 0);*/
/* ct_set_rts (d->chan, 0);*/
- if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
+ if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_down (sp);
}
static void ct_tls (struct sppp *sp)
{
- drv_t *d = sp->pp_if.if_softc;
+ drv_t *d = SP2IFP(sp)->if_softc;
CT_DEBUG (d, ("ct_tls\n"));
- if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
+ if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_up (sp);
}
@@ -951,7 +961,7 @@ static int ct_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
ct_start (d);
} else if (was_up && ! should_be_up) {
/* Interface is going down -- stop it. */
- /* if ((d->pp.pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
+ /* if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
ct_down (d);
}
CT_UNLOCK (bd);
@@ -1013,13 +1023,13 @@ static void ct_send (drv_t *d)
if (! m)
IF_DEQUEUE (&d->queue, m);
#else
- m = sppp_dequeue (&d->pp.pp_if);
+ m = sppp_dequeue (d->ifp);
#endif
if (! m)
return;
#ifndef NETGRAPH
- if (d->pp.pp_if.if_bpf)
- BPF_MTAP (&d->pp.pp_if, m);
+ if (d->ifp->if_bpf)
+ BPF_MTAP (d->ifp, m);
#endif
len = m->m_pkthdr.len;
if (! m->m_next)
@@ -1037,11 +1047,11 @@ static void ct_send (drv_t *d)
#ifdef NETGRAPH
d->timeout = 10;
#else
- d->pp.pp_if.if_timer = 10;
+ d->ifp->if_timer = 10;
#endif
}
#ifndef NETGRAPH
- d->pp.pp_if.if_flags |= IFF_OACTIVE;
+ d->ifp->if_flags |= IFF_OACTIVE;
#endif
}
@@ -1100,9 +1110,9 @@ static void ct_transmit (ct_chan_t *c, void *attachment, int len)
#ifdef NETGRAPH
d->timeout = 0;
#else
- ++d->pp.pp_if.if_opackets;
- d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
- d->pp.pp_if.if_timer = 0;
+ ++d->ifp->if_opackets;
+ d->ifp->if_flags &= ~IFF_OACTIVE;
+ d->ifp->if_timer = 0;
#endif
ct_start (d);
}
@@ -1125,7 +1135,7 @@ static void ct_receive (ct_chan_t *c, char *data, int len)
if (! m) {
CT_DEBUG (d, ("no memory for packet\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_iqdrops;
+ ++d->ifp->if_iqdrops;
#endif
return;
}
@@ -1135,12 +1145,12 @@ static void ct_receive (ct_chan_t *c, char *data, int len)
m->m_pkthdr.rcvif = 0;
NG_SEND_DATA_ONLY (error, d->hook, m);
#else
- ++d->pp.pp_if.if_ipackets;
- m->m_pkthdr.rcvif = &d->pp.pp_if;
+ ++d->ifp->if_ipackets;
+ m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->pp.pp_if.if_bpf)
- BPF_TAP (&d->pp.pp_if, data, len);
+ if (d->ifp->if_bpf)
+ BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
@@ -1159,26 +1169,26 @@ static void ct_error (ct_chan_t *c, int data)
case CT_FRAME:
CT_DEBUG (d, ("frame error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CT_CRC:
CT_DEBUG (d, ("crc error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CT_OVERRUN:
CT_DEBUG (d, ("overrun error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_collisions;
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_collisions;
+ ++d->ifp->if_ierrors;
#endif
break;
case CT_OVERFLOW:
CT_DEBUG (d, ("overflow error\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CT_UNDERRUN:
@@ -1186,9 +1196,9 @@ static void ct_error (ct_chan_t *c, int data)
#ifdef NETGRAPH
d->timeout = 0;
#else
- ++d->pp.pp_if.if_oerrors;
- d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
- d->pp.pp_if.if_timer = 0;
+ ++d->ifp->if_oerrors;
+ d->ifp->if_flags &= ~IFF_OACTIVE;
+ d->ifp->if_timer = 0;
#endif
ct_start (d);
break;
@@ -1273,8 +1283,8 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
#ifndef NETGRAPH
case SERIAL_GETPROTO:
- strcpy ((char*)data, (d->pp.pp_flags & PP_FR) ? "fr" :
- (d->pp.pp_if.if_flags & PP_CISCO) ? "cisco" : "ppp");
+ strcpy ((char*)data, (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" :
+ (d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp");
return 0;
case SERIAL_SETPROTO:
@@ -1282,27 +1292,27 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
- if (d->pp.pp_if.if_flags & IFF_RUNNING)
+ if (d->ifp->if_flags & IFF_RUNNING)
return EBUSY;
if (! strcmp ("cisco", (char*)data)) {
- d->pp.pp_flags &= ~(PP_FR);
- d->pp.pp_flags |= PP_KEEPALIVE;
- d->pp.pp_if.if_flags |= PP_CISCO;
+ IFP2SP(d->ifp)->pp_flags &= ~(PP_FR);
+ IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
+ d->ifp->if_flags |= PP_CISCO;
} else if (! strcmp ("fr", (char*)data)) {
- d->pp.pp_if.if_flags &= ~(PP_CISCO);
- d->pp.pp_flags |= PP_FR | PP_KEEPALIVE;
+ d->ifp->if_flags &= ~(PP_CISCO);
+ IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE;
} else if (! strcmp ("ppp", (char*)data)) {
- d->pp.pp_flags &= ~(PP_FR | PP_KEEPALIVE);
- d->pp.pp_if.if_flags &= ~(PP_CISCO);
+ IFP2SP(d->ifp)->pp_flags &= ~(PP_FR | PP_KEEPALIVE);
+ d->ifp->if_flags &= ~(PP_CISCO);
} else
return EINVAL;
return 0;
case SERIAL_GETKEEPALIVE:
- if ((d->pp.pp_flags & PP_FR) ||
- (d->pp.pp_if.if_flags & PP_CISCO))
+ if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
+ (d->ifp->if_flags & PP_CISCO))
return EINVAL;
- *(int*)data = (d->pp.pp_flags & PP_KEEPALIVE) ? 1 : 0;
+ *(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0;
return 0;
case SERIAL_SETKEEPALIVE:
@@ -1310,13 +1320,13 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
- if ((d->pp.pp_flags & PP_FR) ||
- (d->pp.pp_if.if_flags & PP_CISCO))
+ if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
+ (d->ifp->if_flags & PP_CISCO))
return EINVAL;
if (*(int*)data)
- d->pp.pp_flags |= PP_KEEPALIVE;
+ IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
else
- d->pp.pp_flags &= ~PP_KEEPALIVE;
+ IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
return 0;
#endif /*NETGRAPH*/
@@ -1515,9 +1525,9 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
c->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
- d->pp.pp_if.if_flags |= IFF_DEBUG;
+ d->ifp->if_flags |= IFF_DEBUG;
else
- d->pp.pp_if.if_flags &= (~IFF_DEBUG);
+ d->ifp->if_flags &= (~IFF_DEBUG);
#endif
return 0;
diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c
index 8ff12c0..4c7152c 100644
--- a/sys/dev/cx/if_cx.c
+++ b/sys/dev/cx/if_cx.c
@@ -162,7 +162,7 @@ typedef struct _drv_t {
struct callout timeout_handle;
#else
struct ifqueue queue;
- struct sppp pp;
+ struct ifnet *ifp;
#endif
struct cdev *devt;
async_q aqueue;
@@ -378,7 +378,7 @@ static void cx_intr (void *arg)
IF_DEQUEUE (&d->queue,m);
if (!m)
continue;
- sppp_input (&d->pp.pp_if, m);
+ sppp_input (d->ifp, m);
}
}
#endif
@@ -839,24 +839,33 @@ static int cx_attach (device_t dev)
callout_init (&d->timeout_handle,
cx_mpsafenet ? CALLOUT_MPSAFE : 0);
#else /*NETGRAPH*/
- d->pp.pp_if.if_softc = d;
- if_initname (&d->pp.pp_if, "cx", b->num * NCHAN + c->num);
- d->pp.pp_if.if_mtu = PP_MTU;
- d->pp.pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST |
+ d->ifp = if_alloc(IFT_PPP);
+ if (d->ifp == NULL) {
+ printf ("%s: cannot if_alloc() common interface\n",
+ d->name);
+ channel [b->num*NCHAN + c->num] = 0;
+ c->sys = 0;
+ cx_bus_dma_mem_free (&d->dmamem);
+ continue;
+ }
+ d->ifp->if_softc = d;
+ if_initname (d->ifp, "cx", b->num * NCHAN + c->num);
+ d->ifp->if_mtu = PP_MTU;
+ d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST |
IFF_NEEDSGIANT;
- d->pp.pp_if.if_ioctl = cx_sioctl;
- d->pp.pp_if.if_start = cx_ifstart;
- d->pp.pp_if.if_watchdog = cx_ifwatchdog;
- d->pp.pp_if.if_init = cx_initialize;
+ d->ifp->if_ioctl = cx_sioctl;
+ d->ifp->if_start = cx_ifstart;
+ d->ifp->if_watchdog = cx_ifwatchdog;
+ d->ifp->if_init = cx_initialize;
d->queue.ifq_maxlen = 2;
mtx_init (&d->queue.ifq_mtx, "cx_queue", NULL, MTX_DEF);
- sppp_attach (&d->pp.pp_if);
- if_attach (&d->pp.pp_if);
- d->pp.pp_tlf = cx_tlf;
- d->pp.pp_tls = cx_tls;
+ sppp_attach (d->ifp);
+ if_attach (d->ifp);
+ IFP2SP(d->ifp)->pp_tlf = cx_tlf;
+ IFP2SP(d->ifp)->pp_tls = cx_tls;
/* If BPF is in the kernel, call the attach for it.
* Size of PPP header is 4 bytes. */
- bpfattach (&d->pp.pp_if, DLT_PPP, 4);
+ bpfattach (d->ifp, DLT_PPP, 4);
#endif /*NETGRAPH*/
}
d->tty = ttyalloc ();
@@ -968,11 +977,12 @@ static int cx_detach (device_t dev)
mtx_destroy (&d->hi_queue.ifq_mtx);
#else
/* Detach from the packet filter list of interfaces. */
- bpfdetach (&d->pp.pp_if);
+ bpfdetach (d->ifp);
/* Detach from the sync PPP list. */
- sppp_detach (&d->pp.pp_if);
+ sppp_detach (d->ifp);
- if_detach (&d->pp.pp_if);
+ if_detach (d->ifp);
+ if_free(d->ifp);
/* XXXRIK: check interconnection with irq handler */
IF_DRAIN (&d->queue);
mtx_destroy (&d->queue.ifq_mtx);
@@ -1033,21 +1043,21 @@ static void cx_ifwatchdog (struct ifnet *ifp)
static void cx_tlf (struct sppp *sp)
{
- drv_t *d = sp->pp_if.if_softc;
+ drv_t *d = SP2IFP(sp)->if_softc;
CX_DEBUG (d, ("cx_tlf\n"));
/* cx_set_dtr (d->chan, 0);*/
/* cx_set_rts (d->chan, 0);*/
- if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
+ if (!(IFP2SP(d->ifp)->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_down (sp);
}
static void cx_tls (struct sppp *sp)
{
- drv_t *d = sp->pp_if.if_softc;
+ drv_t *d = SP2IFP(sp)->if_softc;
CX_DEBUG (d, ("cx_tls\n"));
- if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
+ if (!(IFP2SP(d->ifp)->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_up (sp);
}
@@ -1104,7 +1114,7 @@ static int cx_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
cx_start (d);
} else if (was_up && !should_be_up) {
/* Interface is going down -- stop it. */
- /* if ((d->pp.pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
+ /* if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
cx_down (d);
}
CX_UNLOCK (bd);
@@ -1166,13 +1176,13 @@ static void cx_send (drv_t *d)
if (! m)
IF_DEQUEUE (&d->lo_queue, m);
#else
- m = sppp_dequeue (&d->pp.pp_if);
+ m = sppp_dequeue (d->ifp);
#endif
if (! m)
return;
#ifndef NETGRAPH
- if (d->pp.pp_if.if_bpf)
- BPF_MTAP (&d->pp.pp_if, m);
+ if (d->ifp->if_bpf)
+ BPF_MTAP (d->ifp, m);
#endif
len = m->m_pkthdr.len;
if (! m->m_next)
@@ -1189,11 +1199,11 @@ static void cx_send (drv_t *d)
#ifdef NETGRAPH
d->timeout = 10;
#else
- d->pp.pp_if.if_timer = 10;
+ d->ifp->if_timer = 10;
#endif
}
#ifndef NETGRAPH
- d->pp.pp_if.if_flags |= IFF_OACTIVE;
+ d->ifp->if_flags |= IFF_OACTIVE;
#endif
}
@@ -1260,9 +1270,9 @@ static void cx_transmit (cx_chan_t *c, void *attachment, int len)
#ifdef NETGRAPH
d->timeout = 0;
#else
- ++d->pp.pp_if.if_opackets;
- d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
- d->pp.pp_if.if_timer = 0;
+ ++d->ifp->if_opackets;
+ d->ifp->if_flags &= ~IFF_OACTIVE;
+ d->ifp->if_timer = 0;
#endif
cx_start (d);
}
@@ -1314,7 +1324,7 @@ static void cx_receive (cx_chan_t *c, char *data, int len)
if (! m) {
CX_DEBUG (d, ("no memory for packet\n"));
#ifndef NETGRAPH
- ++d->pp.pp_if.if_iqdrops;
+ ++d->ifp->if_iqdrops;
#endif
return;
}
@@ -1324,12 +1334,12 @@ static void cx_receive (cx_chan_t *c, char *data, int len)
m->m_pkthdr.rcvif = 0;
NG_SEND_DATA_ONLY (error, d->hook, m);
#else
- ++d->pp.pp_if.if_ipackets;
- m->m_pkthdr.rcvif = &d->pp.pp_if;
+ ++d->ifp->if_ipackets;
+ m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->pp.pp_if.if_bpf)
- BPF_TAP (&d->pp.pp_if, data, len);
+ if (d->ifp->if_bpf)
+ BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
@@ -1368,7 +1378,7 @@ static void cx_error (cx_chan_t *c, int data)
}
#ifndef NETGRAPH
else
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CX_CRC:
@@ -1385,7 +1395,7 @@ static void cx_error (cx_chan_t *c, int data)
}
#ifndef NETGRAPH
else
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CX_OVERRUN:
@@ -1402,8 +1412,8 @@ static void cx_error (cx_chan_t *c, int data)
#endif
#ifndef NETGRAPH
else {
- ++d->pp.pp_if.if_collisions;
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_collisions;
+ ++d->ifp->if_ierrors;
}
#endif
break;
@@ -1411,7 +1421,7 @@ static void cx_error (cx_chan_t *c, int data)
CX_DEBUG (d, ("overflow error\n"));
#ifndef NETGRAPH
if (c->mode != M_ASYNC)
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
case CX_UNDERRUN:
@@ -1420,9 +1430,9 @@ static void cx_error (cx_chan_t *c, int data)
#ifdef NETGRAPH
d->timeout = 0;
#else
- ++d->pp.pp_if.if_oerrors;
- d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
- d->pp.pp_if.if_timer = 0;
+ ++d->ifp->if_oerrors;
+ d->ifp->if_flags &= ~IFF_OACTIVE;
+ d->ifp->if_timer = 0;
cx_start (d);
#endif
}
@@ -1440,7 +1450,7 @@ static void cx_error (cx_chan_t *c, int data)
}
#ifndef NETGRAPH
else
- ++d->pp.pp_if.if_ierrors;
+ ++d->ifp->if_ierrors;
#endif
break;
default:
@@ -1625,8 +1635,8 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
s = splhigh ();
CX_LOCK (bd);
strcpy ((char*)data, (c->mode == M_ASYNC) ? "async" :
- (d->pp.pp_flags & PP_FR) ? "fr" :
- (d->pp.pp_if.if_flags & PP_CISCO) ? "cisco" : "ppp");
+ (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" :
+ (d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp");
CX_UNLOCK (bd);
splx (s);
return 0;
@@ -1639,31 +1649,31 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
return error;
if (c->mode == M_ASYNC)
return EBUSY;
- if (d->pp.pp_if.if_flags & IFF_RUNNING)
+ if (d->ifp->if_flags & IFF_RUNNING)
return EBUSY;
if (! strcmp ("cisco", (char*)data)) {
- d->pp.pp_flags &= ~(PP_FR);
- d->pp.pp_flags |= PP_KEEPALIVE;
- d->pp.pp_if.if_flags |= PP_CISCO;
+ IFP2SP(d->ifp)->pp_flags &= ~(PP_FR);
+ IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
+ d->ifp->if_flags |= PP_CISCO;
} else if (! strcmp ("fr", (char*)data)) {
- d->pp.pp_if.if_flags &= ~(PP_CISCO);
- d->pp.pp_flags |= PP_FR | PP_KEEPALIVE;
+ d->ifp->if_flags &= ~(PP_CISCO);
+ IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE;
} else if (! strcmp ("ppp", (char*)data)) {
- d->pp.pp_flags &= ~(PP_FR | PP_KEEPALIVE);
- d->pp.pp_if.if_flags &= ~(PP_CISCO);
+ IFP2SP(d->ifp)->pp_flags &= ~(PP_FR | PP_KEEPALIVE);
+ d->ifp->if_flags &= ~(PP_CISCO);
} else
return EINVAL;
return 0;
case SERIAL_GETKEEPALIVE:
CX_DEBUG2 (d, ("ioctl: getkeepalive\n"));
- if ((d->pp.pp_flags & PP_FR) ||
- (d->pp.pp_if.if_flags & PP_CISCO) ||
+ if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
+ (d->ifp->if_flags & PP_CISCO) ||
(c->mode == M_ASYNC))
return EINVAL;
s = splhigh ();
CX_LOCK (bd);
- *(int*)data = (d->pp.pp_flags & PP_KEEPALIVE) ? 1 : 0;
+ *(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0;
CX_UNLOCK (bd);
splx (s);
return 0;
@@ -1674,15 +1684,15 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
- if ((d->pp.pp_flags & PP_FR) ||
- (d->pp.pp_if.if_flags & PP_CISCO))
+ if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
+ (d->ifp->if_flags & PP_CISCO))
return EINVAL;
s = splhigh ();
CX_LOCK (bd);
if (*(int*)data)
- d->pp.pp_flags |= PP_KEEPALIVE;
+ IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
else
- d->pp.pp_flags &= ~PP_KEEPALIVE;
+ IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
CX_UNLOCK (bd);
splx (s);
return 0;
@@ -1898,9 +1908,9 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
splx (s);
#ifndef NETGRAPH
if (d->chan->debug)
- d->pp.pp_if.if_flags |= IFF_DEBUG;
+ d->ifp->if_flags |= IFF_DEBUG;
else
- d->pp.pp_if.if_flags &= (~IFF_DEBUG);
+ d->ifp->if_flags &= (~IFF_DEBUG);
#endif
return 0;
}
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
index ae92c8d..f86d4e4 100644
--- a/sys/dev/dc/if_dc.c
+++ b/sys/dev/dc/if_dc.c
@@ -1084,7 +1084,7 @@ dc_setfilt_21143(struct dc_softc *sc)
struct ifnet *ifp;
int i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
i = sc->dc_cdata.dc_tx_prod;
DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT);
@@ -1124,9 +1124,9 @@ dc_setfilt_21143(struct dc_softc *sc)
}
/* Set our MAC address */
- sp[39] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
- sp[40] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
- sp[41] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ sp[39] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[0]);
+ sp[40] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[1]);
+ sp[41] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[2]);
sframe->dc_status = htole32(DC_TXSTAT_OWN);
CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF);
@@ -1150,11 +1150,11 @@ dc_setfilt_admtek(struct dc_softc *sc)
int h = 0;
u_int32_t hashes[2] = { 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* Init our MAC address. */
- CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
+ CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[0]));
+ CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[4]));
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@@ -1206,15 +1206,15 @@ dc_setfilt_asix(struct dc_softc *sc)
int h = 0;
u_int32_t hashes[2] = { 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* Init our MAC address */
CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR0);
CSR_WRITE_4(sc, DC_AX_FILTDATA,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
+ *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[0]));
CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR1);
CSR_WRITE_4(sc, DC_AX_FILTDATA,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
+ *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[4]));
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@@ -1275,7 +1275,7 @@ dc_setfilt_xircom(struct dc_softc *sc)
u_int32_t h, *sp;
int i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON));
i = sc->dc_cdata.dc_tx_prod;
@@ -1316,9 +1316,9 @@ dc_setfilt_xircom(struct dc_softc *sc)
}
/* Set our MAC address */
- sp[0] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
- sp[1] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
- sp[2] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ sp[0] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[0]);
+ sp[1] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[1]);
+ sp[2] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[2]);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON);
@@ -2090,7 +2090,6 @@ dc_attach(device_t dev)
}
sc->dc_unit = unit;
- bcopy(eaddr, &sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */
error = bus_dma_tag_create(NULL, PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT,
@@ -2180,7 +2179,12 @@ dc_attach(device_t dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("dc%d: can not if_alloc()\n", unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
/* XXX: bleah, MTU gets overwritten in ether_ifattach() */
@@ -2309,6 +2313,7 @@ dc_attach(device_t dev)
if (error) {
printf("dc%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -2337,12 +2342,13 @@ dc_detach(device_t dev)
KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized"));
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
dc_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->dc_miibus)
device_delete_child(dev, sc->dc_miibus);
@@ -2687,7 +2693,7 @@ dc_rxeof(struct dc_softc *sc)
DC_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
i = sc->dc_cdata.dc_rx_prod;
bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD);
@@ -2801,7 +2807,7 @@ dc_txeof(struct dc_softc *sc)
int idx;
u_int32_t ctl, txstat;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/*
* Go through our tx list and free mbufs for those
@@ -2909,7 +2915,7 @@ dc_tick(void *xsc)
sc = xsc;
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
mii = device_get_softc(sc->dc_miibus);
if (sc->dc_flags & DC_REDUCED_MII_POLL) {
@@ -3100,7 +3106,7 @@ dc_intr(void *arg)
return;
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING)
goto done;
@@ -3377,7 +3383,7 @@ static void
dc_init(void *xsc)
{
struct dc_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->dc_ifp;
struct mii_data *mii;
DC_LOCK(sc);
@@ -3705,7 +3711,7 @@ dc_stop(struct dc_softc *sc)
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
ifp->if_timer = 0;
ld = sc->dc_ldata;
cd = &sc->dc_cdata;
@@ -3791,7 +3797,7 @@ dc_resume(device_t dev)
s = splimp();
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* reinitialize interface if necessary */
if (ifp->if_flags & IFF_UP)
diff --git a/sys/dev/dc/if_dcreg.h b/sys/dev/dc/if_dcreg.h
index 5cc5049..a851a72 100644
--- a/sys/dev/dc/if_dcreg.h
+++ b/sys/dev/dc/if_dcreg.h
@@ -716,7 +716,7 @@ struct dc_mii_frame {
struct dc_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *dc_ifp; /* interface info */
bus_space_handle_t dc_bhandle; /* bus space handle */
bus_space_tag_t dc_btag; /* bus space tag */
bus_dma_tag_t dc_ltag; /* tag for descriptor ring */
diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c
index da2310f..c8bf575 100644
--- a/sys/dev/de/if_de.c
+++ b/sys/dev/de/if_de.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_dl.h>
#ifdef TULIP_USE_SOFTINTR
#include <net/netisr.h>
@@ -207,8 +208,8 @@ tulip_txprobe(
/*
* Construct a LLC TEST message which will point to ourselves.
*/
- bcopy(sc->tulip_enaddr, mtod(m, struct ether_header *)->ether_dhost, 6);
- bcopy(sc->tulip_enaddr, mtod(m, struct ether_header *)->ether_shost, 6);
+ bcopy(IFP2ENADDR(sc->tulip_ifp), mtod(m, struct ether_header *)->ether_dhost, 6);
+ bcopy(IFP2ENADDR(sc->tulip_ifp), mtod(m, struct ether_header *)->ether_shost, 6);
mtod(m, struct ether_header *)->ether_type = htons(3);
mtod(m, unsigned char *)[14] = 0;
mtod(m, unsigned char *)[15] = 0;
@@ -229,7 +230,7 @@ tulip_txprobe(
}
#ifdef BIG_PACKET
-#define TULIP_SIAGEN_WATCHDOG (sc->tulip_if.if_mtu > ETHERMTU ? TULIP_WATCHDOG_RXDISABLE|TULIP_WATCHDOG_TXDISABLE : 0)
+#define TULIP_SIAGEN_WATCHDOG (sc->tulip_ifp->if_mtu > ETHERMTU ? TULIP_WATCHDOG_RXDISABLE|TULIP_WATCHDOG_TXDISABLE : 0)
#else
#define TULIP_SIAGEN_WATCHDOG 0
#endif
@@ -336,10 +337,10 @@ tulip_linkup(
if ((sc->tulip_flags & TULIP_LINKUP) == 0)
sc->tulip_flags |= TULIP_PRINTLINKUP;
sc->tulip_flags |= TULIP_LINKUP;
- sc->tulip_if.if_flags &= ~IFF_OACTIVE;
+ sc->tulip_ifp->if_flags &= ~IFF_OACTIVE;
#if 0 /* XXX how does with work with ifmedia? */
if ((sc->tulip_flags & TULIP_DIDNWAY) == 0) {
- if (sc->tulip_if.if_flags & IFF_FULLDUPLEX) {
+ if (sc->tulip_ifp->if_flags & IFF_FULLDUPLEX) {
if (TULIP_CAN_MEDIA_FD(media)
&& sc->tulip_mediums[TULIP_FD_MEDIA_OF(media)] != NULL)
media = TULIP_FD_MEDIA_OF(media);
@@ -386,15 +387,16 @@ static void
tulip_media_print(
tulip_softc_t * const sc)
{
+ struct ifnet *ifp = sc->tulip_ifp;
+
if ((sc->tulip_flags & TULIP_LINKUP) == 0)
return;
if (sc->tulip_flags & TULIP_PRINTMEDIA) {
- printf("%s: enabling %s port\n",
- sc->tulip_xname,
+ if_printf(ifp, "enabling %s port\n",
tulip_mediums[sc->tulip_media]);
sc->tulip_flags &= ~(TULIP_PRINTMEDIA|TULIP_PRINTLINKUP);
} else if (sc->tulip_flags & TULIP_PRINTLINKUP) {
- printf("%s: link up\n", sc->tulip_xname);
+ if_printf(ifp, "link up\n");
sc->tulip_flags &= ~TULIP_PRINTLINKUP;
}
}
@@ -404,6 +406,7 @@ static tulip_media_t
tulip_21140_gpr_media_sense(
tulip_softc_t * const sc)
{
+ struct ifnet *ifp sc->tulip_ifp;
tulip_media_t maybe_media = TULIP_MEDIA_UNKNOWN;
tulip_media_t last_media = TULIP_MEDIA_UNKNOWN;
tulip_media_t media;
@@ -441,8 +444,8 @@ tulip_21140_gpr_media_sense(
continue;
#if defined(TULIP_DEBUG)
- printf("%s: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
- sc->tulip_xname, tulip_mediums[media],
+ if_printf(ifp, "gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
+ tulip_mediums[media],
TULIP_CSR_READ(sc, csr_gp) & 0xFF,
mi->mi_actmask, mi->mi_actdata);
#endif
@@ -466,6 +469,7 @@ static tulip_link_status_t
tulip_media_link_monitor(
tulip_softc_t * const sc)
{
+ struct ifnet *ifp = sc->tulip_ifp;
const tulip_media_info_t * const mi = sc->tulip_mediums[sc->tulip_media];
tulip_link_status_t linkup = TULIP_LINK_DOWN;
@@ -506,7 +510,7 @@ tulip_media_link_monitor(
if (abilities != sc->tulip_abilities) {
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
- sc->tulip_xname, sc->tulip_phyaddr,
+ ifp->if_xname, sc->tulip_phyaddr,
sc->tulip_abilities, abilities);
#endif
if (tulip_mii_map_abilities(sc, abilities)) {
@@ -548,7 +552,7 @@ tulip_media_link_monitor(
linkup = TULIP_LINK_UP;
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_timeout <= 0)
- printf("%s: sia status = 0x%08x\n", sc->tulip_xname,
+ if_printf(ifp, "sia status = 0x%08x\n",
TULIP_CSR_READ(sc, csr_sia_status));
#endif
} else if (mi->mi_type == TULIP_MEDIAINFO_SYM) {
@@ -564,7 +568,7 @@ tulip_media_link_monitor(
return TULIP_LINK_UP;
sc->tulip_flags &= ~TULIP_LINKUP;
- printf("%s: link down: cable problem?\n", sc->tulip_xname);
+ if_printf(ifp, "link down: cable problem?\n");
}
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_link_downed++;
@@ -577,6 +581,8 @@ tulip_media_poll(
tulip_softc_t * const sc,
tulip_mediapoll_event_t event)
{
+ struct ifnet *ifp = sc->tulip_ifp;
+
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_events[event]++;
#endif
@@ -613,7 +619,7 @@ tulip_media_poll(
sc->tulip_dbg.dbg_link_failures++;
#endif
sc->tulip_media = TULIP_MEDIA_UNKNOWN;
- if (sc->tulip_if.if_flags & IFF_UP)
+ if (sc->tulip_ifp->if_flags & IFF_UP)
tulip_reset(sc); /* restart probe */
}
return;
@@ -624,7 +630,7 @@ tulip_media_poll(
}
if (event == TULIP_MEDIAPOLL_START) {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
+ sc->tulip_ifp->if_flags |= IFF_OACTIVE;
if (sc->tulip_probe_state != TULIP_PROBE_INACTIVE)
return;
sc->tulip_probe_mediamask = 0;
@@ -695,8 +701,8 @@ tulip_media_poll(
if (sc->tulip_probe_timeout > 0) {
tulip_media_t new_probe_media = tulip_21140_gpr_media_sense(sc);
#if defined(TULIP_DEBUG)
- printf("%s: media_poll: gpr sensing = %s\n",
- sc->tulip_xname, tulip_mediums[new_probe_media]);
+ if_printf(ifp, "media_poll: gpr sensing = %s\n",
+ tulip_mediums[new_probe_media]);
#endif
if (new_probe_media != TULIP_MEDIA_UNKNOWN) {
if (new_probe_media == sc->tulip_probe_media) {
@@ -782,8 +788,7 @@ tulip_media_poll(
if (/* event == TULIP_MEDIAPOLL_TXPROBE_FAILED || */ sc->tulip_probe_timeout <= 0) {
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
- printf("%s: poll media unknown!\n",
- sc->tulip_xname);
+ if_printf(ifp, "poll media unknown!\n");
sc->tulip_probe_media = TULIP_MEDIA_MAX;
}
#endif
@@ -795,10 +800,9 @@ tulip_media_poll(
sc->tulip_probe_media -= 1;
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
if (++sc->tulip_probe_passes == 3) {
- printf("%s: autosense failed: cable problem?\n",
- sc->tulip_xname);
- if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
- sc->tulip_if.if_flags &= ~IFF_RUNNING;
+ if_printf(ifp, "autosense failed: cable problem?\n");
+ if ((sc->tulip_ifp->if_flags & IFF_UP) == 0) {
+ sc->tulip_ifp->if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
return;
}
@@ -812,7 +816,7 @@ tulip_media_poll(
|| TULIP_IS_MEDIA_FD(sc->tulip_probe_media));
#if defined(TULIP_DEBUG)
- printf("%s: %s: probing %s\n", sc->tulip_xname,
+ if_printf(ifp, "%s: probing %s\n",
event == TULIP_MEDIAPOLL_TXPROBE_FAILED ? "txprobe failed" : "timeout",
tulip_mediums[sc->tulip_probe_media]);
#endif
@@ -892,7 +896,7 @@ tulip_21040_mediainfo_init(
{
sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_THRSHLD160
|TULIP_CMD_BACKOFFCTR;
- sc->tulip_if.if_baudrate = 10000000;
+ sc->tulip_ifp->if_baudrate = 10000000;
if (media == TULIP_MEDIA_10BASET || media == TULIP_MEDIA_UNKNOWN) {
TULIP_MEDIAINFO_SIA_INIT(sc, &sc->tulip_mediainfo[0], 21040, 10BASET);
@@ -1005,7 +1009,7 @@ static void
tulip_21041_media_probe(
tulip_softc_t * const sc)
{
- sc->tulip_if.if_baudrate = 10000000;
+ sc->tulip_ifp->if_baudrate = 10000000;
sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_ENHCAPTEFFCT
|TULIP_CMD_THRSHLD160|TULIP_CMD_BACKOFFCTR;
sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
@@ -1037,7 +1041,7 @@ tulip_21041_media_poll(
* restart the probe (and reset the tulip to a known state).
*/
if (event == TULIP_MEDIAPOLL_START) {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
+ sc->tulip_ifp->if_flags |= IFF_OACTIVE;
sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_RXRUN);
#ifdef notyet
if (sc->tulip_revinfo >= 0x20) {
@@ -1141,10 +1145,10 @@ tulip_21041_media_poll(
sc->tulip_flags &= ~TULIP_WANTRXACT;
sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
} else {
- printf("%s: autosense failed: cable problem?\n",
- sc->tulip_xname);
- if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
- sc->tulip_if.if_flags &= ~IFF_RUNNING;
+ if_printf(sc->tulip_ifp,
+ "autosense failed: cable problem?\n");
+ if ((sc->tulip_ifp->if_flags & IFF_UP) == 0) {
+ sc->tulip_ifp->if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
return;
}
@@ -1335,6 +1339,8 @@ tulip_mii_autonegotiate(
tulip_softc_t * const sc,
const unsigned phyaddr)
{
+ struct ifnet *ifp = sc->tulip_ifp;
+
switch (sc->tulip_probe_state) {
case TULIP_PROBE_MEDIATEST:
case TULIP_PROBE_INACTIVE: {
@@ -1354,17 +1360,17 @@ tulip_mii_autonegotiate(
return;
}
printf("%s(phy%d): error: reset of PHY never completed!\n",
- sc->tulip_xname, phyaddr);
+ ifp->if_xname, phyaddr);
sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
sc->tulip_probe_state = TULIP_PROBE_FAILED;
- sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
+ sc->tulip_ifp->if_flags &= ~(IFF_UP|IFF_RUNNING);
return;
}
status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
if ((status & PHYSTS_CAN_AUTONEG) == 0) {
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation disabled\n",
- sc->tulip_xname, phyaddr);
+ ifp->if_xname, phyaddr);
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
@@ -1377,10 +1383,10 @@ tulip_mii_autonegotiate(
#if defined(TULIP_DEBUG)
if ((data & PHYCTL_AUTONEG_ENABLE) == 0)
loudprintf("%s(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
- sc->tulip_xname, phyaddr, data);
+ ifp->if_xname, phyaddr, data);
else
loudprintf("%s(phy%d): autonegotiation restarted: 0x%04x\n",
- sc->tulip_xname, phyaddr, data);
+ ifp->if_xname, phyaddr, data);
sc->tulip_dbg.dbg_nway_starts++;
#endif
sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG;
@@ -1397,7 +1403,7 @@ tulip_mii_autonegotiate(
}
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
- sc->tulip_xname, phyaddr, status,
+ ifp->if_xname, phyaddr, status,
tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL));
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
@@ -1407,7 +1413,7 @@ tulip_mii_autonegotiate(
data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation complete: 0x%04x\n",
- sc->tulip_xname, phyaddr, data);
+ ifp->if_xname, phyaddr, data);
#endif
data = (data << 6) & status;
if (!tulip_mii_map_abilities(sc, data))
@@ -1423,7 +1429,7 @@ tulip_mii_autonegotiate(
}
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation failure: state = %d\n",
- sc->tulip_xname, phyaddr, sc->tulip_probe_state);
+ ifp->if_xname, phyaddr, sc->tulip_probe_state);
sc->tulip_dbg.dbg_nway_failures++;
#endif
}
@@ -1458,8 +1464,7 @@ tulip_2114x_media_preset(
}
#if defined(TULIP_DEBUG)
} else {
- printf("%s: preset: bad media %d!\n",
- sc->tulip_xname, media);
+ if_printf(sc->tulip_ifp, "preset: bad media %d!\n", media);
}
#endif
}
@@ -1469,13 +1474,13 @@ tulip_2114x_media_preset(
case TULIP_MEDIA_10BASET: {
sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL;
- sc->tulip_if.if_baudrate = 10000000;
+ sc->tulip_ifp->if_baudrate = 10000000;
sc->tulip_flags |= TULIP_SQETEST;
break;
}
case TULIP_MEDIA_10BASET_FD: {
sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL;
- sc->tulip_if.if_baudrate = 10000000;
+ sc->tulip_ifp->if_baudrate = 10000000;
break;
}
case TULIP_MEDIA_100BASEFX:
@@ -1483,14 +1488,14 @@ tulip_2114x_media_preset(
case TULIP_MEDIA_100BASETX: {
sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL);
sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT;
- sc->tulip_if.if_baudrate = 100000000;
+ sc->tulip_ifp->if_baudrate = 100000000;
break;
}
case TULIP_MEDIA_100BASEFX_FD:
case TULIP_MEDIA_100BASETX_FD: {
sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_PORTSELECT;
sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
- sc->tulip_if.if_baudrate = 100000000;
+ sc->tulip_ifp->if_baudrate = 100000000;
break;
}
default: {
@@ -1514,8 +1519,7 @@ tulip_null_media_poll(
sc->tulip_dbg.dbg_events[event]++;
#endif
#if defined(DIAGNOSTIC)
- printf("%s: botch(media_poll) at line %d\n",
- sc->tulip_xname, __LINE__);
+ if_printf(sc->tulip_ifp, "botch(media_poll) at line %d\n", __LINE__);
#endif
}
@@ -2261,7 +2265,7 @@ tulip_identify_asante_nic(
mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, 0);
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
- printf("%s: can't find phy 0\n", sc->tulip_xname);
+ if_printf(sc->tulip_ifp, "can't find phy 0\n");
return;
}
@@ -2312,7 +2316,7 @@ tulip_identify_compex_nic(
root_sc->tulip_slaves = sc;
} else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) {
printf("\nCannot find master device for %s interrupts",
- sc->tulip_xname);
+ sc->tulip_ifp->if_xname);
}
} else {
strcat(sc->tulip_boardid, "unknown ");
@@ -2514,8 +2518,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
- printf("%s: can't find phy %d\n",
- sc->tulip_xname, phyno);
+ if_printf(sc->tulip_ifp, "can't find phy %d\n",
+ phyno);
#endif
break;
}
@@ -2615,8 +2619,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
- printf("%s: can't find phy %d\n",
- sc->tulip_xname, phyno);
+ if_printf(sc->tulip_ifp, "can't find phy %d\n",
+ phyno);
#endif
break;
}
@@ -2994,18 +2998,18 @@ tulip_addr_filter(
sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
#if defined(IFF_ALLMULTI)
- if (sc->tulip_if.if_flags & IFF_ALLMULTI)
+ if (sc->tulip_ifp->if_flags & IFF_ALLMULTI)
sc->tulip_flags |= TULIP_ALLMULTI ;
#endif
multicnt = 0;
- TAILQ_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->tulip_ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family == AF_LINK)
multicnt++;
}
- sc->tulip_if.if_start = tulip_ifstart; /* so the setup packet gets queued */
+ sc->tulip_ifp->if_start = tulip_ifstart; /* so the setup packet gets queued */
if (multicnt > 14) {
u_int32_t *sp = sc->tulip_setupdata;
unsigned hash;
@@ -3027,7 +3031,7 @@ tulip_addr_filter(
*/
bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
- TAILQ_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->tulip_ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
@@ -3044,14 +3048,14 @@ tulip_addr_filter(
* receiving every multicast.
*/
if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) {
- hash = tulip_mchash(sc->tulip_if.if_broadcastaddr);
+ hash = tulip_mchash(sc->tulip_ifp->if_broadcastaddr);
#if BYTE_ORDER == BIG_ENDIAN
sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
#else
sp[hash >> 4] |= 1 << (hash & 0xF);
#endif
if (sc->tulip_flags & TULIP_WANTHASHONLY) {
- hash = tulip_mchash(sc->tulip_enaddr);
+ hash = tulip_mchash(IFP2ENADDR(sc->tulip_ifp));
#if BYTE_ORDER == BIG_ENDIAN
sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
#else
@@ -3059,13 +3063,13 @@ tulip_addr_filter(
#endif
} else {
#if BYTE_ORDER == BIG_ENDIAN
- sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
- sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
- sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
+ sp[39] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0] << 16;
+ sp[40] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1] << 16;
+ sp[41] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2] << 16;
#else
- sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0];
- sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1];
- sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2];
+ sp[39] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0];
+ sp[40] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1];
+ sp[41] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2];
#endif
}
}
@@ -3077,7 +3081,7 @@ tulip_addr_filter(
/*
* Else can get perfect filtering for 16 addresses.
*/
- TAILQ_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->tulip_ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
@@ -3111,19 +3115,19 @@ tulip_addr_filter(
*/
for (; idx < 16; idx++) {
#if BYTE_ORDER == BIG_ENDIAN
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
+ *sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0] << 16;
+ *sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1] << 16;
+ *sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2] << 16;
#else
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0];
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1];
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2];
+ *sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0];
+ *sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1];
+ *sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2];
#endif
}
}
#if defined(IFF_ALLMULTI)
if (sc->tulip_flags & TULIP_ALLMULTI)
- sc->tulip_if.if_flags |= IFF_ALLMULTI;
+ sc->tulip_ifp->if_flags |= IFF_ALLMULTI;
#endif
}
@@ -3154,8 +3158,8 @@ tulip_reset(
if (!inreset) {
sc->tulip_flags |= TULIP_INRESET;
sc->tulip_flags &= ~(TULIP_NEEDRESET|TULIP_RXBUFSLOW);
- sc->tulip_if.if_flags &= ~IFF_OACTIVE;
- sc->tulip_if.if_start = tulip_ifstart;
+ sc->tulip_ifp->if_flags &= ~IFF_OACTIVE;
+ sc->tulip_ifp->if_start = tulip_ifstart;
}
#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
@@ -3259,8 +3263,8 @@ tulip_reset(
(*sc->tulip_boardsw->bd_media_select)(sc);
#if defined(TULIP_DEBUG)
if ((sc->tulip_flags & TULIP_NEEDRESET) == TULIP_NEEDRESET)
- printf("%s: tulip_reset: additional reset needed?!?\n",
- sc->tulip_xname);
+ if_printf(sc->tulip_ifp,
+ "tulip_reset: additional reset needed?!?\n");
#endif
if (bootverbose)
tulip_media_print(sc);
@@ -3284,13 +3288,13 @@ static void
tulip_init(
tulip_softc_t * const sc)
{
- if (sc->tulip_if.if_flags & IFF_UP) {
- if ((sc->tulip_if.if_flags & IFF_RUNNING) == 0) {
+ if (sc->tulip_ifp->if_flags & IFF_UP) {
+ if ((sc->tulip_ifp->if_flags & IFF_RUNNING) == 0) {
/* initialize the media */
tulip_reset(sc);
}
- sc->tulip_if.if_flags |= IFF_RUNNING;
- if (sc->tulip_if.if_flags & IFF_PROMISC) {
+ sc->tulip_ifp->if_flags |= IFF_RUNNING;
+ if (sc->tulip_ifp->if_flags & IFF_PROMISC) {
sc->tulip_flags |= TULIP_PROMISC;
sc->tulip_cmdmode |= TULIP_CMD_PROMISCUOUS;
sc->tulip_intrmask |= TULIP_STS_TXINTR;
@@ -3309,7 +3313,7 @@ tulip_init(
sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
} else {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
+ sc->tulip_ifp->if_flags |= IFF_OACTIVE;
sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
}
@@ -3318,7 +3322,7 @@ tulip_init(
if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP)
tulip_txput_setup(sc);
} else {
- sc->tulip_if.if_flags &= ~IFF_RUNNING;
+ sc->tulip_ifp->if_flags &= ~IFF_RUNNING;
tulip_reset(sc);
}
}
@@ -3329,7 +3333,7 @@ tulip_rx_intr(
{
TULIP_PERFSTART(rxintr)
tulip_ringinfo_t * const ri = &sc->tulip_rxinfo;
- struct ifnet * const ifp = &sc->tulip_if;
+ struct ifnet * const ifp = sc->tulip_ifp;
int fillok = 1;
#if defined(TULIP_DEBUG)
int cnt = 0;
@@ -3431,7 +3435,7 @@ tulip_rx_intr(
if ((sc->tulip_flags & TULIP_RXIGNORE) == 0
&& ((eop->d_status & TULIP_DSTS_ERRSUM) == 0
#ifdef BIG_PACKET
- || (total_len <= sc->tulip_if.if_mtu + sizeof(struct ether_header) &&
+ || (total_len <= sc->tulip_ifp->if_mtu + sizeof(struct ether_header) &&
(eop->d_status & (TULIP_DSTS_RxBADLENGTH|TULIP_DSTS_RxRUNT|
TULIP_DSTS_RxCOLLSEEN|TULIP_DSTS_RxBADCRC|
TULIP_DSTS_RxOVERFLOW)) == 0)
@@ -3451,7 +3455,7 @@ tulip_rx_intr(
#endif /* TULIP_BUS_DMA */
#ifndef __FreeBSD__
- if (sc->tulip_if.if_bpf != NULL) {
+ if (sc->tulip_ifp->if_bpf != NULL) {
if (me == ms)
bpf_tap(&sc->tulip_if, mtod(ms, caddr_t), total_len);
else
@@ -3489,8 +3493,7 @@ tulip_rx_intr(
}
#if defined(TULIP_VERBOSE)
if (error != NULL && (sc->tulip_flags & TULIP_NOMESSAGES) == 0) {
- printf("%s: receive: %6D: %s\n",
- sc->tulip_xname,
+ if_printf(sc->tulip_ifp, "receive: %6D: %s\n",
mtod(ms, u_char *) + 6, ":",
error);
sc->tulip_flags |= TULIP_NOMESSAGES;
@@ -3601,8 +3604,8 @@ tulip_rx_intr(
error = bus_dmamap_load(sc->tulip_dmatag, map, mtod(ms, void *),
TULIP_RX_BUFLEN, NULL, BUS_DMA_NOWAIT);
if (error) {
- printf("%s: unable to load rx map, "
- "error = %d\n", sc->tulip_xname, error);
+ if_printf(sc->tulip_ifp,
+ "unable to load rx map, error = %d\n", error);
panic("tulip_rx_intr"); /* XXX */
}
nextout->d_addr1 = map->dm_segs[0].ds_addr;
@@ -3693,8 +3696,8 @@ tulip_tx_intr(
m_freem(m);
#if defined(TULIP_DEBUG)
} else {
- printf("%s: tx_intr: failed to dequeue mbuf?!?\n",
- sc->tulip_xname);
+ if_printf(sc->tulip_ifp,
+ "tx_intr: failed to dequeue mbuf?!?\n");
#endif
}
if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
@@ -3716,7 +3719,7 @@ tulip_tx_intr(
} else {
xmits++;
if (d_status & TULIP_DSTS_ERRSUM) {
- sc->tulip_if.if_oerrors++;
+ sc->tulip_ifp->if_oerrors++;
if (d_status & TULIP_DSTS_TxEXCCOLL)
sc->tulip_dot3stats.dot3StatsExcessiveCollisions++;
if (d_status & TULIP_DSTS_TxLATECOLL)
@@ -3733,7 +3736,7 @@ tulip_tx_intr(
u_int32_t collisions =
(d_status & TULIP_DSTS_TxCOLLMASK)
>> TULIP_DSTS_V_TxCOLLCNT;
- sc->tulip_if.if_collisions += collisions;
+ sc->tulip_ifp->if_collisions += collisions;
if (collisions == 1)
sc->tulip_dot3stats.dot3StatsSingleCollisionFrames++;
else if (collisions > 1)
@@ -3757,7 +3760,7 @@ tulip_tx_intr(
ri->ri_nextin = ri->ri_first;
if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0)
- sc->tulip_if.if_flags &= ~IFF_OACTIVE;
+ sc->tulip_ifp->if_flags &= ~IFF_OACTIVE;
}
/*
* If nothing left to transmit, disable the timer.
@@ -3767,7 +3770,7 @@ tulip_tx_intr(
sc->tulip_txtimer = 0;
else if (xmits > 0)
sc->tulip_txtimer = TULIP_TXTIMER;
- sc->tulip_if.if_opackets += xmits;
+ sc->tulip_ifp->if_opackets += xmits;
TULIP_PERFEND(txintr);
return descs;
}
@@ -3783,7 +3786,7 @@ tulip_print_abnormal_interrupt(
const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024";
csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1;
- printf("%s: abnormal interrupt:", sc->tulip_xname);
+ if_printf(sc->tulip_ifp, "abnormal interrupt:");
for (sep = " ", mask = 1; mask <= csr; mask <<= 1, msgp++) {
if ((csr & mask) && *msgp != NULL) {
printf("%s%s", sep, *msgp);
@@ -3819,8 +3822,7 @@ tulip_intr_handler(
if (sc->tulip_flags & TULIP_NOMESSAGES) {
sc->tulip_flags |= TULIP_SYSTEMERROR;
} else {
- printf("%s: system error: %s\n",
- sc->tulip_xname,
+ if_printf(sc->tulip_ifp, "system error: %s\n",
tulip_system_errors[sc->tulip_last_system_error]);
}
sc->tulip_flags |= TULIP_NEEDRESET;
@@ -3891,7 +3893,7 @@ tulip_intr_handler(
if (sc->tulip_flags & (TULIP_WANTTXSTART|TULIP_TXPROBE_ACTIVE|TULIP_DOINGSETUP|TULIP_PROMISC)) {
tulip_tx_intr(sc);
if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0)
- tulip_ifstart(&sc->tulip_if);
+ tulip_ifstart(sc->tulip_ifp);
}
}
if (sc->tulip_flags & TULIP_NEEDRESET) {
@@ -4116,8 +4118,7 @@ tulip_txput(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s: txput%s: tx not running\n",
- sc->tulip_xname,
+ if_printf(sc->tulip_ifp, "txput%s: tx not running\n",
(sc->tulip_flags & TULIP_TXPROBE_ACTIVE) ? "(probe)" : "");
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_dbg.dbg_txput_finishes[0]++;
@@ -4188,8 +4189,8 @@ tulip_txput(
error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT);
}
if (error != 0) {
- printf("%s: unable to load tx map, "
- "error = %d\n", sc->tulip_xname, error);
+ if_printf(sc->tulip_ifp,
+ "unable to load tx map, error = %d\n", error);
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_txput_finishes[3]++;
#endif
@@ -4317,7 +4318,7 @@ tulip_txput(
/*
* bounce a copy to the bpf listener, if any.
*/
- BPF_MTAP(&sc->tulip_if, m);
+ BPF_MTAP(sc->tulip_ifp, m);
/*
* The descriptors have been filled in. Now get ready
@@ -4381,8 +4382,8 @@ tulip_txput(
if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
TULIP_CSR_WRITE(sc, csr_txpoll, 1);
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- sc->tulip_if.if_start = tulip_ifstart;
+ sc->tulip_ifp->if_flags |= IFF_OACTIVE;
+ sc->tulip_ifp->if_start = tulip_ifstart;
TULIP_PERFEND(txput);
return NULL;
}
@@ -4411,8 +4412,8 @@ tulip_txput(
sc->tulip_dbg.dbg_txput_finishes[6]++;
#endif
if (sc->tulip_flags & (TULIP_WANTTXSTART|TULIP_DOINGSETUP)) {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- sc->tulip_if.if_start = tulip_ifstart;
+ sc->tulip_ifp->if_flags |= IFF_OACTIVE;
+ sc->tulip_ifp->if_start = tulip_ifstart;
if ((sc->tulip_intrmask & TULIP_STS_TXINTR) == 0) {
sc->tulip_intrmask |= TULIP_STS_TXINTR;
TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
@@ -4441,10 +4442,9 @@ tulip_txput_setup(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s: txput_setup: tx not running\n",
- sc->tulip_xname);
+ if_printf(sc->tulip_ifp, "txput_setup: tx not running\n");
sc->tulip_flags |= TULIP_WANTTXSTART;
- sc->tulip_if.if_start = tulip_ifstart;
+ sc->tulip_ifp->if_start = tulip_ifstart;
return;
}
#endif
@@ -4455,7 +4455,7 @@ tulip_txput_setup(
tulip_tx_intr(sc);
if ((sc->tulip_flags & TULIP_DOINGSETUP) || ri->ri_free == 1) {
sc->tulip_flags |= TULIP_WANTTXSTART;
- sc->tulip_if.if_start = tulip_ifstart;
+ sc->tulip_ifp->if_start = tulip_ifstart;
return;
}
bcopy(sc->tulip_setupdata, sc->tulip_setupbuf,
@@ -4620,18 +4620,18 @@ tulip_ifstart(
TULIP_PERFSTART(ifstart)
tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
- if (sc->tulip_if.if_flags & IFF_RUNNING) {
+ if (sc->tulip_ifp->if_flags & IFF_RUNNING) {
if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP)
tulip_txput_setup(sc);
- while (!IFQ_DRV_IS_EMPTY(&sc->tulip_if.if_snd)) {
+ while (!IFQ_DRV_IS_EMPTY(&sc->tulip_ifp->if_snd)) {
struct mbuf *m;
- IFQ_DRV_DEQUEUE(&sc->tulip_if.if_snd, m);
+ IFQ_DRV_DEQUEUE(&sc->tulip_ifp->if_snd, m);
if(m == NULL)
break;
if ((m = tulip_txput(sc, m)) != NULL) {
- IFQ_DRV_PREPEND(&sc->tulip_if.if_snd, m);
+ IFQ_DRV_PREPEND(&sc->tulip_ifp->if_snd, m);
break;
}
}
@@ -4661,7 +4661,7 @@ tulip_ifwatchdog(
sc->tulip_dbg.dbg_last_rxintrs = sc->tulip_dbg.dbg_rxintrs;
#endif /* TULIP_DEBUG */
- sc->tulip_if.if_timer = 1;
+ sc->tulip_ifp->if_timer = 1;
/*
* These should be rare so do a bulk test up front so we can just skip
* them if needed.
@@ -4674,8 +4674,8 @@ tulip_ifwatchdog(
tulip_rx_intr(sc);
if (sc->tulip_flags & TULIP_SYSTEMERROR) {
- printf("%s: %d system errors: last was %s\n",
- sc->tulip_xname, sc->tulip_system_errors,
+ if_printf(sc->tulip_ifp, "%d system errors: last was %s\n",
+ sc->tulip_system_errors,
tulip_system_errors[sc->tulip_last_system_error]);
}
if (sc->tulip_statusbits) {
@@ -4689,7 +4689,7 @@ tulip_ifwatchdog(
if (sc->tulip_txtimer)
tulip_tx_intr(sc);
if (sc->tulip_txtimer && --sc->tulip_txtimer == 0) {
- printf("%s: transmission timeout\n", sc->tulip_xname);
+ if_printf(sc->tulip_ifp, "transmission timeout\n");
if (TULIP_DO_AUTOSENSE(sc)) {
sc->tulip_media = TULIP_MEDIA_UNKNOWN;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@@ -4733,11 +4733,13 @@ static void
tulip_attach(
tulip_softc_t * const sc)
{
- struct ifnet * const ifp = &sc->tulip_if;
+ struct ifnet *ifp;
+
+ ifp = sc->tulip_ifp = if_alloc(IFT_ETHER);
/* XXX: driver name/unit should be set some other way */
- ifp->if_dname = "de";
- ifp->if_dunit = sc->tulip_unit;
+ if_initname(ifp, "de", sc->tulip_unit);
+ ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST|IFF_NEEDSGIANT;
ifp->if_ioctl = tulip_ifioctl;
ifp->if_start = tulip_ifstart;
@@ -4745,8 +4747,7 @@ tulip_attach(
ifp->if_timer = 1;
ifp->if_init = tulip_ifinit;
- printf("%s: %s%s pass %d.%d%s\n",
- sc->tulip_xname,
+ if_printf(ifp, "%s%s pass %d.%d%s\n",
sc->tulip_boardid,
tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4,
@@ -4754,8 +4755,7 @@ tulip_attach(
(sc->tulip_features & (TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM))
== TULIP_HAVE_ISVSROM ? " (invalid EESPROM checksum)" : "");
#ifndef __FreeBSD__
- printf("%s: address %6D\n",
- sc->tulip_xname, sc->tulip_enaddr, ":");
+ if_printf(ifp, "address %6D\n", sc->tulip_enaddr, ":");
#endif
#if defined(__alpha__)
@@ -4776,7 +4776,7 @@ tulip_attach(
tulip_reset(sc);
- ether_ifattach(&(sc)->tulip_if, sc->tulip_enaddr);
+ ether_ifattach(sc->tulip_ifp, sc->tulip_enaddr);
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
@@ -5029,8 +5029,7 @@ tulip_pci_attach(device_t dev)
unit = device_get_unit(dev);
if (unit >= TULIP_MAX_DEVICES) {
- printf("de%d", unit);
- printf(": not configured; limit of %d reached or exceeded\n",
+ device_printf(dev, "not configured; limit of %d reached or exceeded\n",
TULIP_MAX_DEVICES);
return ENXIO;
}
@@ -5059,13 +5058,14 @@ tulip_pci_attach(device_t dev)
return ENXIO;
if (chipid == TULIP_21040 && revinfo < 0x20) {
- printf("de%d", unit);
- printf(": not configured; 21040 pass 2.0 required (%d.%d found)\n",
- revinfo >> 4, revinfo & 0x0f);
+ device_printf(dev,
+ "not configured; 21040 pass 2.0 required (%d.%d found)\n",
+ revinfo >> 4, revinfo & 0x0f);
return ENXIO;
} else if (chipid == TULIP_21140 && revinfo < 0x11) {
- printf("de%d: not configured; 21140 pass 1.1 required (%d.%d found)\n",
- unit, revinfo >> 4, revinfo & 0x0f);
+ device_printf(dev,
+ "not configured; 21140 pass 1.1 required (%d.%d found)\n",
+ revinfo >> 4, revinfo & 0x0f);
return ENXIO;
}
@@ -5117,9 +5117,7 @@ tulip_pci_attach(device_t dev)
#endif
sc->tulip_unit = unit;
- snprintf(sc->tulip_xname, IFNAMSIZ, "de%d", sc->tulip_unit);
sc->tulip_revinfo = revinfo;
- sc->tulip_if.if_softc = sc;
#if defined(TULIP_IOMAPPED)
rid = PCI_CBIO;
res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
@@ -5146,7 +5144,7 @@ tulip_pci_attach(device_t dev)
sc->tulip_rxdescs = (tulip_desc_t *) malloc(sizeof(tulip_desc_t) * TULIP_RXDESCS, M_DEVBUF, M_NOWAIT);
sc->tulip_txdescs = (tulip_desc_t *) malloc(sizeof(tulip_desc_t) * TULIP_TXDESCS, M_DEVBUF, M_NOWAIT);
if (sc->tulip_rxdescs == NULL || sc->tulip_txdescs == NULL) {
- printf("malloc failed\n");
+ device_printf(dev, "malloc failed\n");
if (sc->tulip_rxdescs)
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
if (sc->tulip_txdescs)
@@ -5167,16 +5165,14 @@ tulip_pci_attach(device_t dev)
bit longer anyways) */
if ((retval = tulip_read_macaddr(sc)) < 0) {
- printf("%s", sc->tulip_xname);
- printf(": can't read ENET ROM (why=%d) (", retval);
+ device_printf(dev, "can't read ENET ROM (why=%d) (", retval);
for (idx = 0; idx < 32; idx++)
printf("%02x", sc->tulip_rombuf[idx]);
printf("\n");
- printf("%s: %s%s pass %d.%d\n",
- sc->tulip_xname,
+ device_printf(dev, "%s%s pass %d.%d\n",
sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F);
- printf("%s: address unknown\n", sc->tulip_xname);
+ device_printf(dev, "address unknown\n");
} else {
int s;
void (*intr_rtn)(void *) = tulip_intr_normal;
@@ -5192,8 +5188,7 @@ tulip_pci_attach(device_t dev)
RF_SHAREABLE | RF_ACTIVE);
if (res == 0 || bus_setup_intr(dev, res, INTR_TYPE_NET,
intr_rtn, sc, &ih)) {
- printf("%s: couldn't map interrupt\n",
- sc->tulip_xname);
+ device_printf(dev, "couldn't map interrupt\n");
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
return ENXIO;
diff --git a/sys/dev/de/if_devar.h b/sys/dev/de/if_devar.h
index ee02be5..54ed8d6 100644
--- a/sys/dev/de/if_devar.h
+++ b/sys/dev/de/if_devar.h
@@ -521,7 +521,8 @@ struct tulip_softc {
unsigned int tulip_rxmaps_free;
#endif
#endif
- struct arpcom tulip_ac; /* XXX should be at start */
+ struct ifnet *tulip_ifp;
+ u_char tulip_enaddr[6];
bus_space_tag_t tulip_csrs_bst;
bus_space_handle_t tulip_csrs_bsh;
tulip_regfile_t tulip_csrs;
@@ -584,9 +585,6 @@ struct tulip_softc {
tulip_desc_t *tulip_rxdescs;
tulip_desc_t *tulip_txdescs;
};
-#define tulip_if tulip_ac.ac_if
-#define tulip_xname tulip_if.if_xname
-#define tulip_enaddr tulip_ac.ac_enaddr
#define tulip_curperfstats tulip_perfstats[TULIP_PERF_CURRENT]
#define tulip_probe_count tulip_probe.probe_count
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 37f8eca..a58023b 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net/if_mib.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#ifndef ED_NO_MIIBUS
#include <dev/mii/mii.h>
@@ -254,7 +255,13 @@ int
ed_attach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
callout_handle_init(&sc->tick_ch);
/*
@@ -304,7 +311,7 @@ ed_attach(device_t dev)
/*
* Attach the interface
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
/* device attach does transition from UNCONFIGURED to IDLE state */
if (bootverbose || 1) {
@@ -341,13 +348,14 @@ int
ed_detach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
if (sc->gone)
return (0);
ed_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
ed_release_resources(dev);
@@ -451,7 +459,7 @@ static void
ed_init(void *xsc)
{
struct ed_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int i, s;
if (sc->gone)
@@ -547,7 +555,7 @@ ed_init(void *xsc)
* Copy out our station address
*/
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- ed_nic_outb(sc, ED_P1_PAR(i), sc->arpcom.ac_enaddr[i]);
+ ed_nic_outb(sc, ED_P1_PAR(i), IFP2ENADDR(sc->ifp)[i]);
/*
* Set Current Page pointer to next_packet (initialized above)
@@ -820,7 +828,7 @@ outloop:
static __inline void
ed_rint(struct ed_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
u_char boundry;
u_short len;
struct ed_ring packet_hdr;
@@ -1329,7 +1337,7 @@ ed_ring_copy(struct ed_softc *sc, char *src, char *dst, u_short amount)
static void
ed_get_packet(struct ed_softc *sc, char *buf, u_short len)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ether_header *eh;
struct mbuf *m;
@@ -1770,7 +1778,7 @@ ed_ds_getmcaf(struct ed_softc *sc, uint32_t *mcaf)
mcaf[0] = 0;
mcaf[1] = 0;
- TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
index = ether_crc32_be(LLADDR((struct sockaddr_dl *)
diff --git a/sys/dev/ed/if_ed_3c503.c b/sys/dev/ed/if_ed_3c503.c
index b46e107..160c112 100644
--- a/sys/dev/ed/if_ed_3c503.c
+++ b/sys/dev/ed/if_ed_3c503.c
@@ -198,7 +198,7 @@ ed_probe_3Com(device_t dev, int port_rid, int flags)
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->arpcom.ac_enaddr[i] = ed_nic_inb(sc, i);
+ sc->enaddr[i] = ed_nic_inb(sc, i);
/*
* Unmap PROM - select NIC registers. The proper setting of the
diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c
index 30d49c1..00b616f 100644
--- a/sys/dev/ed/if_ed_cbus.c
+++ b/sys/dev/ed/if_ed_cbus.c
@@ -774,15 +774,13 @@ ed98_probe_Novell(device_t dev, int port_rid, int flags)
switch (sc->type) {
case ED_TYPE98_NC5098:
for (n = 0; n < ETHER_ADDR_LEN; n++)
- sc->arpcom.ac_enaddr[n] =
- ed_asic_inb(sc, ED_NC5098_ENADDR + n);
+ sc->enaddr[n] = ed_asic_inb(sc, ED_NC5098_ENADDR + n);
break;
default:
ed_pio_readmem(sc, 0, romdata, sizeof(romdata));
for (n = 0; n < ETHER_ADDR_LEN; n++)
- sc->arpcom.ac_enaddr[n] =
- romdata[n * (sc->isa16bit + 1)];
+ sc->enaddr[n] = romdata[n * (sc->isa16bit + 1)];
break;
}
@@ -843,15 +841,14 @@ ed_probe_SIC98(device_t dev, int port_rid, int flags)
*/
sum = sc->mem_start[6 * 2];
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i * 2]);
+ sum ^= (sc->enaddr[i] = sc->mem_start[i * 2]);
#ifdef ED_DEBUG
device_printf(dev, "ed_probe_sic98: got address %6D\n",
- sc->arpcom.ac_enaddr, ":");
+ sc->enaddr, ":");
#endif
if (sum != 0)
return (ENXIO);
- if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] |
- sc->arpcom.ac_enaddr[2]) == 0)
+ if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
return (ENXIO);
sc->vendor = ED_VENDOR_SIC;
@@ -1067,7 +1064,7 @@ ed_probe_CNET98(device_t dev, int port_rid, int flags)
/*
* Get station address from on-board ROM
*/
- bcopy(sc->mem_start, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(sc->mem_start, sc->enaddr, ETHER_ADDR_LEN);
sc->vendor = ED_VENDOR_MISC;
sc->type_str = "CNET98";
@@ -1226,7 +1223,7 @@ ed_probe_CNET98EL(device_t dev, int port_rid, int flags)
/* Get station address from on-board ROM */
ed_pio_readmem(sc, 16384, romdata, sizeof(romdata));
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = romdata[i * 2];
+ sc->enaddr[i] = romdata[i * 2];
/* clear any pending interrupts that might have occurred above */
ed_nic_outb(sc, ED_P0_ISR, 0xff);
@@ -1391,7 +1388,7 @@ ed_get_SB98(struct ed_softc *sc)
val |= (ed_asic_inb(sc, ED_SB98_EEP) & ED_SB98_EEP_SDA);
DELAY(ED_SB98_EEP_DELAY);
}
- sc->arpcom.ac_enaddr[i] = val;
+ sc->enaddr[i] = val;
}
/* output Last ACK */
diff --git a/sys/dev/ed/if_ed_hpp.c b/sys/dev/ed/if_ed_hpp.c
index c993cc1..b7a8a86 100644
--- a/sys/dev/ed/if_ed_hpp.c
+++ b/sys/dev/ed/if_ed_hpp.c
@@ -149,7 +149,7 @@ ed_probe_HP_pclanp(device_t dev, int port_rid, int flags)
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_MAC);
for (n = 0, checksum = 0; n < ETHER_ADDR_LEN; n++)
- checksum += (sc->arpcom.ac_enaddr[n] =
+ checksum += (sc->enaddr[n] =
ed_asic_inb(sc, ED_HPP_MAC_ADDR + n));
checksum += ed_asic_inb(sc, ED_HPP_MAC_ADDR + ETHER_ADDR_LEN);
@@ -365,7 +365,7 @@ ed_probe_HP_pclanp(device_t dev, int port_rid, int flags)
void
ed_hpp_set_physical_link(struct ed_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int lan_page;
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_LAN);
diff --git a/sys/dev/ed/if_ed_isa.c b/sys/dev/ed/if_ed_isa.c
index af365f2..f5da28a 100644
--- a/sys/dev/ed/if_ed_isa.c
+++ b/sys/dev/ed/if_ed_isa.c
@@ -81,7 +81,7 @@ ed_isa_probe_Novell(device_t dev)
* believing that they really are Gateway AT.
*/
if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) &&
- (sc->arpcom.ac_enaddr[2] == 0x86)) {
+ (sc->enaddr[2] == 0x86)) {
sc->type_str = "Gateway AT";
}
diff --git a/sys/dev/ed/if_ed_novell.c b/sys/dev/ed/if_ed_novell.c
index ff55a28..09ac0cd 100644
--- a/sys/dev/ed/if_ed_novell.c
+++ b/sys/dev/ed/if_ed_novell.c
@@ -293,5 +293,5 @@ ed_Novell_read_mac(struct ed_softc *sc)
*/
ed_pio_readmem(sc, 0, romdata, 16);
for (n = 0; n < ETHER_ADDR_LEN; n++)
- sc->arpcom.ac_enaddr[n] = romdata[n * (sc->isa16bit + 1)];
+ sc->enaddr[n] = romdata[n * (sc->isa16bit + 1)];
}
diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c
index 29e962c..b39cb6f 100644
--- a/sys/dev/ed/if_ed_pccard.c
+++ b/sys/dev/ed/if_ed_pccard.c
@@ -337,7 +337,7 @@ ed_pccard_attach(device_t dev)
ed_release_resources(dev);
return (ENXIO);
}
- bcopy(enaddr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(enaddr, sc->enaddr, ETHER_ADDR_LEN);
}
error = ed_attach(dev);
@@ -392,12 +392,12 @@ ax88x90_geteprom(struct ed_softc *sc)
/* Get Data */
for (i = 0; i < 16; i++)
prom[i] = ed_asic_inb(sc, 0);
- sc->arpcom.ac_enaddr[0] = prom[0] & 0xff;
- sc->arpcom.ac_enaddr[1] = prom[0] >> 8;
- sc->arpcom.ac_enaddr[2] = prom[1] & 0xff;
- sc->arpcom.ac_enaddr[3] = prom[1] >> 8;
- sc->arpcom.ac_enaddr[4] = prom[2] & 0xff;
- sc->arpcom.ac_enaddr[5] = prom[2] >> 8;
+ sc->enaddr[0] = prom[0] & 0xff;
+ sc->enaddr[1] = prom[0] >> 8;
+ sc->enaddr[2] = prom[1] & 0xff;
+ sc->enaddr[3] = prom[1] >> 8;
+ sc->enaddr[4] = prom[2] & 0xff;
+ sc->enaddr[5] = prom[2] >> 8;
}
static int
@@ -474,7 +474,7 @@ ed_pccard_Linksys(device_t dev)
if (sum != 0xff)
return (ENXIO); /* invalid DL10019C */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, 0x04 + i);
+ sc->enaddr[i] = ed_asic_inb(sc, 0x04 + i);
ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
id = ed_asic_inb(sc, 0xf);
sc->isa16bit = 1;
diff --git a/sys/dev/ed/if_ed_sic.c b/sys/dev/ed/if_ed_sic.c
index 808745b..471065f 100644
--- a/sys/dev/ed/if_ed_sic.c
+++ b/sys/dev/ed/if_ed_sic.c
@@ -107,15 +107,14 @@ ed_probe_SIC(device_t dev, int port_rid, int flags)
sum = sc->mem_start[6];
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i]);
+ sum ^= (sc->enaddr[i] = sc->mem_start[i]);
#ifdef ED_DEBUG
device_printf(dev, "ed_probe_sic: got address %6D\n",
- sc->arpcom.ac_enaddr, ":");
+ sc->enaddr, ":");
#endif
if (sum != 0)
return (ENXIO);
- if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] |
- sc->arpcom.ac_enaddr[2]) == 0)
+ if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
return (ENXIO);
sc->vendor = ED_VENDOR_SIC;
diff --git a/sys/dev/ed/if_ed_wd80x3.c b/sys/dev/ed/if_ed_wd80x3.c
index fe23c87..dabd758 100644
--- a/sys/dev/ed/if_ed_wd80x3.c
+++ b/sys/dev/ed/if_ed_wd80x3.c
@@ -363,7 +363,7 @@ ed_probe_WD80x3_generic(device_t dev, int flags, uint16_t *intr_vals[])
* Get station address from on-board ROM
*/
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, ED_WD_PROM + i);
+ sc->enaddr[i] = ed_asic_inb(sc, ED_WD_PROM + i);
/*
* Set upper address bits and 8/16 bit access to shared memory.
diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h
index 07624b4..43bbb59 100644
--- a/sys/dev/ed/if_edvar.h
+++ b/sys/dev/ed/if_edvar.h
@@ -33,7 +33,7 @@
* ed_softc: per line info and status
*/
struct ed_softc {
- struct arpcom arpcom; /* ethernet common */
+ struct ifnet *ifp;
char *type_str; /* pointer to type string */
u_char vendor; /* interface vendor */
@@ -43,6 +43,7 @@ struct ed_softc {
u_char isa16bit; /* width of access to card 0=8 or 1=16 */
u_char mem_shared; /* NIC memory is shared with host */
u_char xmit_busy; /* transmitter is busy */
+ u_char enaddr[6];
int port_rid; /* resource id for port range */
int port_used; /* nonzero if ports used */
diff --git a/sys/dev/em/if_em.c b/sys/dev/em/if_em.c
index 4e9d282..5c6a796 100644
--- a/sys/dev/em/if_em.c
+++ b/sys/dev/em/if_em.c
@@ -464,9 +464,6 @@ em_attach(device_t dev)
goto err_mac_addr;
}
- bcopy(adapter->hw.mac_addr, adapter->interface_data.ac_enaddr,
- ETHER_ADDR_LEN);
-
/* Setup OS specific network interface */
em_setup_interface(dev, adapter);
@@ -525,7 +522,7 @@ static int
em_detach(device_t dev)
{
struct adapter * adapter = device_get_softc(dev);
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
INIT_DEBUGOUT("em_detach: begin");
@@ -535,9 +532,10 @@ em_detach(device_t dev)
em_phy_hw_reset(&adapter->hw);
EM_UNLOCK(adapter);
#if __FreeBSD_version < 500000
- ether_ifdetach(&adapter->interface_data.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(adapter->ifp, ETHER_BPF_SUPPORTED);
#else
- ether_ifdetach(&adapter->interface_data.ac_if);
+ ether_ifdetach(adapter->ifp);
+ if_free(ifp);
#endif
em_free_pci_resources(adapter);
bus_generic_detach(dev);
@@ -804,7 +802,7 @@ em_init_locked(struct adapter * adapter)
struct ifnet *ifp;
uint32_t pba;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
INIT_DEBUGOUT("em_init: begin");
@@ -843,7 +841,7 @@ em_init_locked(struct adapter * adapter)
E1000_WRITE_REG(&adapter->hw, PBA, pba);
/* Get the latest mac address, User can use a LAA */
- bcopy(adapter->interface_data.ac_enaddr, adapter->hw.mac_addr,
+ bcopy(IFP2ENADDR(adapter->ifp), adapter->hw.mac_addr,
ETHER_ADDR_LEN);
/* Initialize the hardware */
@@ -985,7 +983,7 @@ em_intr(void *arg)
EM_LOCK(adapter);
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING) {
@@ -1193,7 +1191,7 @@ em_encap(struct adapter *adapter, struct mbuf **m_headp)
int nsegs;
struct em_buffer *tx_buffer = NULL;
struct em_tx_desc *current_tx_desc = NULL;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
m_head = *m_headp;
@@ -1526,7 +1524,7 @@ em_set_promisc(struct adapter * adapter)
{
u_int32_t reg_rctl;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
reg_rctl = E1000_READ_REG(&adapter->hw, RCTL);
@@ -1555,7 +1553,7 @@ static void
em_disable_promisc(struct adapter * adapter)
{
u_int32_t reg_rctl;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
reg_rctl = E1000_READ_REG(&adapter->hw, RCTL);
@@ -1585,7 +1583,7 @@ em_set_multi(struct adapter * adapter)
u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * ETH_LENGTH_OF_ADDRESS];
struct ifmultiaddr *ifma;
int mcnt = 0;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
IOCTL_DEBUGOUT("em_set_multi: begin");
@@ -1647,7 +1645,7 @@ em_local_timer(void *arg)
{
struct ifnet *ifp;
struct adapter * adapter = arg;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
EM_LOCK(adapter);
@@ -1668,7 +1666,7 @@ em_local_timer(void *arg)
static void
em_print_link_status(struct adapter * adapter)
{
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) {
if (adapter->link_active == 0) {
@@ -1711,7 +1709,7 @@ em_stop(void *arg)
{
struct ifnet *ifp;
struct adapter * adapter = arg;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
mtx_assert(&adapter->mtx, MA_OWNED);
@@ -1931,7 +1929,9 @@ em_setup_interface(device_t dev, struct adapter * adapter)
struct ifnet *ifp;
INIT_DEBUGOUT("em_setup_interface: begin");
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ panic("%s: can not if_alloc()", device_get_nameunit(dev));
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_baudrate = 1000000000;
@@ -1948,7 +1948,7 @@ em_setup_interface(device_t dev, struct adapter * adapter)
#if __FreeBSD_version < 500000
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#else
- ether_ifattach(ifp, adapter->interface_data.ac_enaddr);
+ ether_ifattach(ifp, adapter->hw.mac_addr);
#endif
ifp->if_capabilities = ifp->if_capenable = 0;
@@ -2425,7 +2425,7 @@ em_clean_transmit_interrupts(struct adapter * adapter)
int i, num_avail;
struct em_buffer *tx_buffer;
struct em_tx_desc *tx_desc;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
mtx_assert(&adapter->mtx, MA_OWNED);
@@ -2497,7 +2497,7 @@ em_get_buf(int i, struct adapter *adapter,
bus_addr_t paddr;
int error;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
if (mp == NULL) {
mp = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
@@ -2648,7 +2648,7 @@ em_initialize_receive_unit(struct adapter * adapter)
u_int64_t bus_addr;
INIT_DEBUGOUT("em_initialize_receive_unit: begin");
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
/* Make sure receives are disabled while setting up the descriptor ring */
E1000_WRITE_REG(&adapter->hw, RCTL, 0);
@@ -2785,7 +2785,7 @@ em_process_receive_interrupts(struct adapter * adapter, int count)
mtx_assert(&adapter->mtx, MA_OWNED);
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
i = adapter->next_rx_desc_to_check;
current_desc = &adapter->rx_desc_base[i];
bus_dmamap_sync(adapter->rxdma.dma_tag, adapter->rxdma.dma_map,
@@ -3237,7 +3237,7 @@ em_update_stats_counters(struct adapter *adapter)
adapter->stats.tsctfc +=
E1000_READ_REG(&adapter->hw, TSCTFC);
}
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
/* Fill out the OS statistics structure */
ifp->if_ibytes = adapter->stats.gorcl;
diff --git a/sys/dev/em/if_em.h b/sys/dev/em/if_em.h
index 38399ea..8d46455 100644
--- a/sys/dev/em/if_em.h
+++ b/sys/dev/em/if_em.h
@@ -322,7 +322,7 @@ typedef struct _DESCRIPTOR_PAIR
/* Our adapter structure */
struct adapter {
- struct arpcom interface_data;
+ struct ifnet *ifp;
struct adapter *next;
struct adapter *prev;
struct em_hw hw;
diff --git a/sys/dev/en/if_en_pci.c b/sys/dev/en/if_en_pci.c
index 8409352..c167e2a 100644
--- a/sys/dev/en/if_en_pci.c
+++ b/sys/dev/en/if_en_pci.c
@@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_atm.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@@ -149,7 +150,7 @@ adp_busreset(void *v)
dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG);
if ((dummy & (ADP_PCIREG_SWAP_WORD | ADP_PCIREG_SWAP_DMA)) !=
ADP_PCIREG_SWAP_DMA)
- if_printf(&sc->ifatm.ifnet, "adp_busreset: Adaptec ATM did "
+ if_printf(sc->ifp, "adp_busreset: Adaptec ATM did "
"NOT reset!\n");
}
@@ -197,8 +198,11 @@ en_pci_attach(device_t dev)
sc = device_get_softc(dev);
scp = (struct en_pci_softc *)sc;
+ sc->ifp = if_alloc(IFT_ATM);
+ if (sc->ifp == NULL)
+ return (ENOSPC);
- if_initname(&(sc->ifatm.ifnet), device_get_name(dev),
+ if_initname(sc->ifp, device_get_name(dev),
device_get_unit(dev));
/*
@@ -273,7 +277,8 @@ en_pci_attach(device_t dev)
en_intr, sc, &scp->ih);
if (error) {
en_reset(sc);
- atm_ifdetach(&sc->ifatm.ifnet);
+ atm_ifdetach(sc->ifp);
+ if_free(sc->ifp);
device_printf(dev, "could not setup irq\n");
bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq);
bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res);
@@ -299,16 +304,17 @@ en_pci_detach(device_t dev)
/*
* Stop DMA and drop transmit queue.
*/
- if ((sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
- if_printf(&sc->ifatm.ifnet, "still running\n");
- sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
+ if ((sc->ifp->if_flags & IFF_RUNNING)) {
+ if_printf(sc->ifp, "still running\n");
+ sc->ifp->if_flags &= ~IFF_RUNNING;
}
/*
* Close down routes etc.
*/
en_reset(sc);
- atm_ifdetach(&sc->ifatm.ifnet);
+ atm_ifdetach(sc->ifp);
+ if_free(sc->ifp);
/*
* Deallocate resources.
@@ -347,8 +353,8 @@ adp_get_macaddr(struct en_pci_softc *scp)
struct en_softc * sc = (struct en_softc *)scp;
int lcv;
- for (lcv = 0; lcv < sizeof(sc->ifatm.mib.esi); lcv++)
- sc->ifatm.mib.esi[lcv] = bus_space_read_1(sc->en_memt,
+ for (lcv = 0; lcv < sizeof(IFP2IFATM(sc->ifp)->mib.esi); lcv++)
+ IFP2IFATM(sc->ifp)->mib.esi[lcv] = bus_space_read_1(sc->en_memt,
sc->en_base, MID_ADPMACOFF + lcv);
}
@@ -447,13 +453,13 @@ eni_get_macaddr(device_t dev, struct en_pci_softc *scp)
data = EN_PROM_MAGIC | EN_PROM_DATA | EN_PROM_CLK;
pci_write_config(dev, EN_TONGA, data, 4);
- for (i = 0; i < sizeof(sc->ifatm.mib.esi); i ++)
- sc->ifatm.mib.esi[i] = eni_get_byte(dev, &data, i + EN_ESI);
+ for (i = 0; i < sizeof(IFP2IFATM(sc->ifp)->mib.esi); i ++)
+ IFP2IFATM(sc->ifp)->mib.esi[i] = eni_get_byte(dev, &data, i + EN_ESI);
- sc->ifatm.mib.serial = 0;
+ IFP2IFATM(sc->ifp)->mib.serial = 0;
for (i = 0; i < 4; i++) {
- sc->ifatm.mib.serial <<= 8;
- sc->ifatm.mib.serial |= eni_get_byte(dev, &data, i + EN_SERIAL);
+ IFP2IFATM(sc->ifp)->mib.serial <<= 8;
+ IFP2IFATM(sc->ifp)->mib.serial |= eni_get_byte(dev, &data, i + EN_SERIAL);
}
/* stop operation */
data &= ~EN_PROM_DATA;
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c
index 265b60e..165655e 100644
--- a/sys/dev/en/midway.c
+++ b/sys/dev/en/midway.c
@@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$");
*/
#define DBG(SC, FL, PRINT) do { \
if ((SC)->debug & DBG_##FL) { \
- if_printf(&(SC)->ifatm.ifnet, "%s: "#FL": ", __func__); \
+ if_printf((SC)->ifp, "%s: "#FL": ", __func__); \
printf PRINT; \
printf("\n"); \
} \
@@ -395,7 +395,7 @@ en_dump_packet(struct en_softc *sc, struct mbuf *m)
int len;
u_char *ptr;
- if_printf(&sc->ifatm.ifnet, "packet len=%d", plen);
+ if_printf(sc->ifp, "packet len=%d", plen);
while (m != NULL) {
totlen += m->m_len;
ptr = mtod(m, u_char *);
@@ -445,7 +445,7 @@ en_map_ctor(void *mem, int size, void *arg, int flags)
err = bus_dmamap_create(sc->txtag, 0, &map->map);
if (err != 0) {
- if_printf(&sc->ifatm.ifnet, "cannot create DMA map %d\n", err);
+ if_printf(sc->ifp, "cannot create DMA map %d\n", err);
return (err);
}
map->flags = ENMAP_ALLOC;
@@ -754,7 +754,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
lastm->m_next = NULL;
if (error != 0) {
- if_printf(&sc->ifatm.ifnet, "loading TX map failed %d\n",
+ if_printf(sc->ifp, "loading TX map failed %d\n",
error);
goto dequeue_drop;
}
@@ -770,13 +770,13 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
}
EN_COUNT(sc->stats.launch);
- sc->ifatm.ifnet.if_opackets++;
+ sc->ifp->if_opackets++;
sc->vccs[tx.vci]->opackets++;
sc->vccs[tx.vci]->obytes += tx.datalen;
#ifdef ENABLE_BPF
- if (sc->ifatm.ifnet.if_bpf != NULL) {
+ if (sc->ifp->if_bpf != NULL) {
/*
* adjust the top of the mbuf to skip the TBD if present
* before passing the packet to bpf.
@@ -794,7 +794,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
tx.m->m_pkthdr.len = tx.datalen;
}
- BPF_MTAP(&sc->ifatm.ifnet, tx.m);
+ BPF_MTAP(sc->ifp, tx.m);
}
#endif
@@ -1314,12 +1314,12 @@ en_close_vcc(struct en_softc *sc, struct atmio_closevcc *cl)
goto done;
vc->vflags |= VCC_CLOSE_RX;
- while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
+ while ((sc->ifp->if_flags & IFF_RUNNING) &&
(vc->vflags & VCC_DRAIN))
cv_wait(&sc->cv_close, &sc->en_mtx);
en_close_finish(sc, vc);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@@ -1349,8 +1349,8 @@ en_reset_ul(struct en_softc *sc)
struct en_rxslot *rx;
int lcv;
- if_printf(&sc->ifatm.ifnet, "reset\n");
- sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
+ if_printf(sc->ifp, "reset\n");
+ sc->ifp->if_flags &= ~IFF_RUNNING;
if (sc->en_busreset)
sc->en_busreset(sc);
@@ -1439,14 +1439,14 @@ en_init(struct en_softc *sc)
int vc, slot;
uint32_t loc;
- if ((sc->ifatm.ifnet.if_flags & IFF_UP) == 0) {
+ if ((sc->ifp->if_flags & IFF_UP) == 0) {
DBG(sc, INIT, ("going down"));
en_reset(sc); /* to be safe */
return;
}
DBG(sc, INIT, ("going up"));
- sc->ifatm.ifnet.if_flags |= IFF_RUNNING; /* enable */
+ sc->ifp->if_flags |= IFF_RUNNING; /* enable */
if (sc->en_busreset)
sc->en_busreset(sc);
@@ -1820,7 +1820,7 @@ en_rx_drain(struct en_softc *sc, u_int drq)
if (EN_DQ_LEN(drq) != 0) {
_IF_DEQUEUE(&slot->indma, m);
KASSERT(m != NULL, ("drqsync: %s: lost mbuf in slot %zu!",
- sc->ifatm.ifnet.if_xname, slot - sc->rxslot));
+ sc->ifp->if_xname, slot - sc->rxslot));
uma_zfree(sc->map_zone, (struct en_map *)m->m_pkthdr.rcvif);
}
if ((vc = slot->vcc) == NULL) {
@@ -1856,8 +1856,8 @@ en_rx_drain(struct en_softc *sc, u_int drq)
"hand %p", slot - sc->rxslot, vc->vcc.vci, m,
EN_DQ_LEN(drq), vc->rxhand));
- m->m_pkthdr.rcvif = &sc->ifatm.ifnet;
- sc->ifatm.ifnet.if_ipackets++;
+ m->m_pkthdr.rcvif = sc->ifp;
+ sc->ifp->if_ipackets++;
vc->ipackets++;
vc->ibytes += m->m_pkthdr.len;
@@ -1867,9 +1867,9 @@ en_rx_drain(struct en_softc *sc, u_int drq)
en_dump_packet(sc, m);
#endif
#ifdef ENABLE_BPF
- BPF_MTAP(&sc->ifatm.ifnet, m);
+ BPF_MTAP(sc->ifp, m);
#endif
- atm_input(&sc->ifatm.ifnet, &ah, m, vc->rxhand);
+ atm_input(sc->ifp, &ah, m, vc->rxhand);
}
}
@@ -2250,16 +2250,16 @@ en_service(struct en_softc *sc)
if (MID_RBD_CNT(rbd) * MID_ATMDATASZ <
MID_PDU_LEN(pdu)) {
- if_printf(&sc->ifatm.ifnet, "invalid AAL5 length\n");
+ if_printf(sc->ifp, "invalid AAL5 length\n");
rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
mlen = 0;
- sc->ifatm.ifnet.if_ierrors++;
+ sc->ifp->if_ierrors++;
} else if (rbd & MID_RBD_CRCERR) {
- if_printf(&sc->ifatm.ifnet, "CRC error\n");
+ if_printf(sc->ifp, "CRC error\n");
rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
mlen = 0;
- sc->ifatm.ifnet.if_ierrors++;
+ sc->ifp->if_ierrors++;
} else {
mlen = MID_PDU_LEN(pdu);
@@ -2334,7 +2334,7 @@ en_service(struct en_softc *sc)
en_rxdma_load, &rx, BUS_DMA_NOWAIT);
if (error != 0) {
- if_printf(&sc->ifatm.ifnet, "loading RX map failed "
+ if_printf(sc->ifp, "loading RX map failed "
"%d\n", error);
uma_zfree(sc->map_zone, map);
m_freem(m);
@@ -2430,11 +2430,11 @@ en_intr(void *arg)
* unexpected errors that need a reset
*/
if ((reg & (MID_INT_IDENT | MID_INT_LERR | MID_INT_DMA_ERR)) != 0) {
- if_printf(&sc->ifatm.ifnet, "unexpected interrupt=0x%b, "
+ if_printf(sc->ifp, "unexpected interrupt=0x%b, "
"resetting\n", reg, MID_INTBITS);
#ifdef EN_DEBUG
kdb_enter("en: unexpected error");
- sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; /* FREEZE! */
+ sc->ifp->if_flags &= ~IFF_RUNNING; /* FREEZE! */
#else
en_reset_ul(sc);
en_init(sc);
@@ -2493,7 +2493,7 @@ en_intr(void *arg)
static int
en_utopia_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n)
{
- struct en_softc *sc = ifatm->ifnet.if_softc;
+ struct en_softc *sc = ifatm->ifp->if_softc;
u_int i;
EN_CHECKLOCK(sc);
@@ -2514,7 +2514,7 @@ en_utopia_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n)
static int
en_utopia_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val)
{
- struct en_softc *sc = ifatm->ifnet.if_softc;
+ struct en_softc *sc = ifatm->ifp->if_softc;
uint32_t regval;
EN_CHECKLOCK(sc);
@@ -2797,13 +2797,14 @@ en_dmaprobe(struct en_softc *sc)
int
en_attach(struct en_softc *sc)
{
- struct ifnet *ifp = &sc->ifatm.ifnet;
+ struct ifnet *ifp = sc->ifp;
int sz;
uint32_t reg, lcv, check, ptr, sav, midvloc;
#ifdef EN_DEBUG
sc->debug = EN_DEBUG;
#endif
+
/*
* Probe card to determine memory size.
*
@@ -2852,7 +2853,7 @@ en_attach(struct en_softc *sc)
reg = en_read(sc, MID_RESID);
- if_printf(&sc->ifatm.ifnet, "ATM midway v%d, board IDs %d.%d, %s%s%s, "
+ if_printf(sc->ifp, "ATM midway v%d, board IDs %d.%d, %s%s%s, "
"%ldKB on-board RAM\n", MID_VER(reg), MID_MID(reg), MID_DID(reg),
(MID_IS_SABRE(reg)) ? "sabre controller, " : "",
(MID_IS_SUNI(reg)) ? "SUNI" : "Utopia",
@@ -2862,31 +2863,31 @@ en_attach(struct en_softc *sc)
/*
* fill in common ATM interface stuff
*/
- sc->ifatm.mib.hw_version = (MID_VER(reg) << 16) |
+ IFP2IFATM(sc->ifp)->mib.hw_version = (MID_VER(reg) << 16) |
(MID_MID(reg) << 8) | MID_DID(reg);
if (MID_DID(reg) & 0x4)
- sc->ifatm.mib.media = IFM_ATM_UTP_155;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155;
else
- sc->ifatm.mib.media = IFM_ATM_MM_155;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
- sc->ifatm.mib.pcr = ATM_RATE_155M;
- sc->ifatm.mib.vpi_bits = 0;
- sc->ifatm.mib.vci_bits = MID_VCI_BITS;
- sc->ifatm.mib.max_vccs = MID_N_VC;
- sc->ifatm.mib.max_vpcs = 0;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
+ IFP2IFATM(sc->ifp)->mib.vpi_bits = 0;
+ IFP2IFATM(sc->ifp)->mib.vci_bits = MID_VCI_BITS;
+ IFP2IFATM(sc->ifp)->mib.max_vccs = MID_N_VC;
+ IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
if (sc->is_adaptec) {
- sc->ifatm.mib.device = ATM_DEVICE_ADP155P;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_ADP155P;
if (sc->bestburstlen == 64 && sc->alburst == 0)
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"passed 64 byte DMA test\n");
else
- if_printf(&sc->ifatm.ifnet, "FAILED DMA TEST: "
+ if_printf(sc->ifp, "FAILED DMA TEST: "
"burst=%d, alburst=%d\n", sc->bestburstlen,
sc->alburst);
} else {
- sc->ifatm.mib.device = ATM_DEVICE_ENI155P;
- if_printf(&sc->ifatm.ifnet, "maximum DMA burst length = %d "
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_ENI155P;
+ if_printf(sc->ifp, "maximum DMA burst length = %d "
"bytes%s\n", sc->bestburstlen, sc->alburst ?
sc->noalbursts ? " (no large bursts)" : " (must align)" :
"");
@@ -2895,7 +2896,7 @@ en_attach(struct en_softc *sc)
/*
* link into network subsystem and prepare card
*/
- sc->ifatm.ifnet.if_softc = sc;
+ sc->ifp->if_softc = sc;
ifp->if_flags = IFF_SIMPLEX;
ifp->if_ioctl = en_ioctl;
ifp->if_start = en_start;
@@ -2925,8 +2926,8 @@ en_attach(struct en_softc *sc)
goto fail;
#endif
- sc->ifatm.phy = &sc->utopia;
- utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->en_mtx,
+ IFP2IFATM(sc->ifp)->phy = &sc->utopia;
+ utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->en_mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&en_utopia_methods);
utopia_init_media(&sc->utopia);
@@ -2960,7 +2961,7 @@ en_attach(struct en_softc *sc)
ptr = roundup(ptr, EN_TXSZ * 1024); /* align */
sz = sz - (ptr - sav);
if (EN_TXSZ*1024 * EN_NTX > sz) {
- if_printf(&sc->ifatm.ifnet, "EN_NTX/EN_TXSZ too big\n");
+ if_printf(sc->ifp, "EN_NTX/EN_TXSZ too big\n");
goto fail;
}
for (lcv = 0 ;lcv < EN_NTX ;lcv++) {
@@ -2979,7 +2980,7 @@ en_attach(struct en_softc *sc)
sz = sz - (ptr - sav);
sc->en_nrx = sz / (EN_RXSZ * 1024);
if (sc->en_nrx <= 0) {
- if_printf(&sc->ifatm.ifnet, "EN_NTX/EN_TXSZ/EN_RXSZ too big\n");
+ if_printf(sc->ifp, "EN_NTX/EN_TXSZ/EN_RXSZ too big\n");
goto fail;
}
@@ -3010,10 +3011,10 @@ en_attach(struct en_softc *sc)
sc->rxslot[lcv].mode));
}
- if_printf(&sc->ifatm.ifnet, "%d %dKB receive buffers, %d %dKB transmit "
+ if_printf(sc->ifp, "%d %dKB receive buffers, %d %dKB transmit "
"buffers\n", sc->en_nrx, EN_RXSZ, EN_NTX, EN_TXSZ);
- if_printf(&sc->ifatm.ifnet, "end station identifier (mac address) "
- "%6D\n", sc->ifatm.mib.esi, ":");
+ if_printf(sc->ifp, "end station identifier (mac address) "
+ "%6D\n", IFP2IFATM(sc->ifp)->mib.esi, ":");
/*
* Start SUNI stuff. This will call our readregs/writeregs
@@ -3302,7 +3303,7 @@ en_dump(int unit, int level)
if (unit != -1 && unit != lcv)
continue;
- if_printf(&sc->ifatm.ifnet, "dumping device at level 0x%b\n",
+ if_printf(sc->ifp, "dumping device at level 0x%b\n",
level, END_BITS);
if (sc->dtq_us == 0) {
diff --git a/sys/dev/en/midwayvar.h b/sys/dev/en/midwayvar.h
index 27e047d..8c2a8c5 100644
--- a/sys/dev/en/midwayvar.h
+++ b/sys/dev/en/midwayvar.h
@@ -153,8 +153,7 @@ struct en_vcc {
* softc
*/
struct en_softc {
- /* bsd glue */
- struct ifatm ifatm; /* ATM network ifnet handle */
+ struct ifnet *ifp;
device_t dev;
/* bus glue */
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c
index 0505659..3fa7dc9 100644
--- a/sys/dev/ep/if_ep.c
+++ b/sys/dev/ep/if_ep.c
@@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/bpf.h>
@@ -262,14 +263,14 @@ ep_attach(struct ep_softc *sc)
{
struct ifnet *ifp = NULL;
struct ifmedia *ifm = NULL;
+ u_char eaddr[6];
u_short *p;
int i;
- int attached;
int error;
sc->gone = 0;
EP_LOCK_INIT(sc);
- error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
+ error = ep_get_macaddr(sc, eaddr);
if (error) {
device_printf(sc->dev, "Unable to get Ethernet address!\n");
EP_LOCK_DESTORY(sc);
@@ -278,13 +279,17 @@ ep_attach(struct ep_softc *sc)
/*
* Setup the station address
*/
- p = (u_short *)&sc->arpcom.ac_enaddr;
+ p = (u_short *)eaddr;
GO_WINDOW(sc, 2);
for (i = 0; i < 3; i++)
CSR_WRITE_2(sc, EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
- ifp = &sc->arpcom.ac_if;
- attached = (ifp->if_softc != 0);
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(sc->dev, "can not if_alloc()\n");
+ EP_LOCK_DESTORY(sc);
+ return (ENOSPC);
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
@@ -319,8 +324,7 @@ ep_attach(struct ep_softc *sc)
ifm->ifm_media = ifm->ifm_cur->ifm_media;
ep_ifmedia_upd(ifp);
}
- if (!attached)
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
#ifdef EP_LOCAL_STATS
sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =
@@ -342,7 +346,7 @@ ep_detach(device_t dev)
sc = device_get_softc(dev);
EP_ASSERT_UNLOCKED(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (sc->gone) {
device_printf(dev, "already unloaded\n");
@@ -353,6 +357,7 @@ ep_detach(device_t dev)
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
sc->gone = 1;
ep_free(dev);
@@ -377,7 +382,7 @@ epinit(void *xsc)
static void
epinit_locked(struct ep_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int i;
if (sc->gone)
@@ -402,7 +407,7 @@ epinit_locked(struct ep_softc *sc)
/* Reload the ether_addr. */
for (i = 0; i < 6; i++)
- CSR_WRITE_1(sc, EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, EP_W2_ADDR_0 + i, IFP2ENADDR(sc->ifp)[i]);
CSR_WRITE_2(sc, EP_COMMAND, RX_RESET);
CSR_WRITE_2(sc, EP_COMMAND, TX_RESET);
@@ -592,7 +597,7 @@ ep_intr(void *arg)
EP_UNLOCK(sc);
return;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
CSR_WRITE_2(sc, EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
@@ -710,7 +715,7 @@ epread(struct ep_softc *sc)
/* XXX Must be called with sc locked */
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
status = CSR_READ_2(sc, EP_W1_RX_STATUS);
read_again:
@@ -816,7 +821,7 @@ read_again:
CSR_WRITE_2(sc, EP_COMMAND, RX_DISCARD_TOP_PACK);
++ifp->if_ipackets;
EP_FSET(sc, F_RX_FIRST);
- top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ top->m_pkthdr.rcvif = sc->ifp;
top->m_pkthdr.len = sc->cur_len;
/*
diff --git a/sys/dev/ep/if_ep_pccard.c b/sys/dev/ep/if_ep_pccard.c
index de2382f..10da245 100644
--- a/sys/dev/ep/if_ep_pccard.c
+++ b/sys/dev/ep/if_ep_pccard.c
@@ -120,7 +120,7 @@ ep_pccard_probe(device_t dev)
* Newer cards supported by this device need to have their
* MAC address set.
*/
- error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
+ error = ep_get_macaddr(sc, (u_char *)&IFP2ENADDR(sc->ifp));
ep_free(dev);
return (0);
diff --git a/sys/dev/ep/if_epvar.h b/sys/dev/ep/if_epvar.h
index 14a0165..231d4ed 100644
--- a/sys/dev/ep/if_epvar.h
+++ b/sys/dev/ep/if_epvar.h
@@ -33,7 +33,7 @@ struct ep_board {
* Ethernet software status per interface.
*/
struct ep_softc {
- struct arpcom arpcom; /* Ethernet common part */
+ struct ifnet *ifp;
struct ifmedia ifmedia; /* media info */
device_t dev;
diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c
index 33598ba..300e433 100644
--- a/sys/dev/ex/if_ex.c
+++ b/sys/dev/ex/if_ex.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/bpf.h>
@@ -202,12 +203,17 @@ int
ex_attach(device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp;
struct ifmedia * ifm;
uint16_t temp;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
/* work out which set of irq <-> internal tables to use */
- if (ex_card_type(sc->arpcom.ac_enaddr) == CARD_TYPE_EX_10_PLUS) {
+ if (ex_card_type(sc->enaddr) == CARD_TYPE_EX_10_PLUS) {
sc->irq2ee = plus_irq2eemap;
sc->ee2irq = plus_ee2irqmap;
} else {
@@ -252,7 +258,7 @@ ex_attach(device_t dev)
/*
* Attach the interface.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
return(0);
}
@@ -264,12 +270,13 @@ ex_detach(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
ex_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
ex_release_resources(dev);
@@ -280,7 +287,7 @@ static void
ex_init(void *xsc)
{
struct ex_softc * sc = (struct ex_softc *) xsc;
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp = sc->ifp;
int s;
int i;
unsigned short temp_reg;
@@ -299,7 +306,7 @@ ex_init(void *xsc)
CSR_WRITE_1(sc, EEPROM_REG, temp_reg & ~Trnoff_Enable);
}
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- CSR_WRITE_1(sc, I_ADDR_REG0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, I_ADDR_REG0 + i, IFP2ENADDR(sc->ifp)[i]);
}
/*
* - Setup transmit chaining and discard bad received frames.
@@ -574,7 +581,7 @@ void
ex_intr(void *arg)
{
struct ex_softc *sc = (struct ex_softc *)arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int int_status, send_pkts;
int loops = 100;
@@ -613,7 +620,7 @@ ex_intr(void *arg)
static void
ex_tx_intr(struct ex_softc *sc)
{
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp = sc->ifp;
int tx_status;
DODEBUG(Start_End, printf("ex_tx_intr%d: start\n", unit););
@@ -660,7 +667,7 @@ ex_tx_intr(struct ex_softc *sc)
static void
ex_rx_intr(struct ex_softc *sc)
{
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp = sc->ifp;
int rx_status;
int pkt_len;
int QQQ;
@@ -830,7 +837,7 @@ ex_setmulti(struct ex_softc *sc)
int count;
int timeout, status;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
count = 0;
TAILQ_FOREACH(maddr, &ifp->if_multiaddrs, ifma_link) {
@@ -879,7 +886,7 @@ ex_setmulti(struct ex_softc *sc)
/* Program our MAC address as well */
/* XXX: Is this necessary? The Linux driver does this
* but the NetBSD driver does not */
- addr = (uint16_t*)(&sc->arpcom.ac_enaddr);
+ addr = (uint16_t*)(&IFP2ENADDR(sc->ifp));
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
diff --git a/sys/dev/ex/if_ex_isa.c b/sys/dev/ex/if_ex_isa.c
index 310f554..214a53e 100644
--- a/sys/dev/ex/if_ex_isa.c
+++ b/sys/dev/ex/if_ex_isa.c
@@ -296,7 +296,7 @@ ex_isa_attach(device_t dev)
*/
sc->irq_no = rman_get_start(sc->irq);
- ex_get_address(sc, sc->arpcom.ac_enaddr);
+ ex_get_address(sc, sc->enaddr);
temp = ex_eeprom_read(sc, EE_W0);
device_printf(sc->dev, "%s config, %s bus, ",
diff --git a/sys/dev/ex/if_ex_pccard.c b/sys/dev/ex/if_ex_pccard.c
index 16b9d20..8671e87 100644
--- a/sys/dev/ex/if_ex_pccard.c
+++ b/sys/dev/ex/if_ex_pccard.c
@@ -231,7 +231,7 @@ ex_pccard_attach(device_t dev)
error = ENXIO;
goto bad;
}
- bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(ether_addr, sc->enaddr, ETHER_ADDR_LEN);
if ((error = ex_attach(dev)) != 0) {
device_printf(dev, "ex_attach() failed!\n");
diff --git a/sys/dev/ex/if_exvar.h b/sys/dev/ex/if_exvar.h
index 6427f1f..5e2f001 100644
--- a/sys/dev/ex/if_exvar.h
+++ b/sys/dev/ex/if_exvar.h
@@ -30,8 +30,9 @@
*/
struct ex_softc {
- struct arpcom arpcom; /* Ethernet common data */
+ struct ifnet *ifp;
struct ifmedia ifmedia;
+ u_char enaddr[6];
device_t dev;
struct resource *ioport;
diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c
index e20ab08..bb9a34d 100644
--- a/sys/dev/fatm/if_fatm.c
+++ b/sys/dev/fatm/if_fatm.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_atm.h>
#include <net/route.h>
#ifdef INET
@@ -111,8 +112,8 @@ static const struct utopia_methods fatm_utopia_methods = {
};
#define VC_OK(SC, VPI, VCI) \
- (((VPI) & ~((1 << (SC)->ifatm.mib.vpi_bits) - 1)) == 0 && \
- (VCI) != 0 && ((VCI) & ~((1 << (SC)->ifatm.mib.vci_bits) - 1)) == 0)
+ (((VPI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vpi_bits) - 1)) == 0 && \
+ (VCI) != 0 && ((VCI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vci_bits) - 1)) == 0)
static int fatm_load_vc(struct fatm_softc *sc, struct card_vcc *vc);
@@ -165,9 +166,9 @@ fatm_utopia_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val)
struct cmdqueue *q;
struct fatm_softc *sc;
- sc = ifatm->ifnet.if_softc;
+ sc = ifatm->ifp->if_softc;
FATM_CHECKLOCK(sc);
- if (!(ifatm->ifnet.if_flags & IFF_RUNNING))
+ if (!(ifatm->ifp->if_flags & IFF_RUNNING))
return (EIO);
/* get queue element and fill it */
@@ -250,7 +251,7 @@ fatm_utopia_readregs_internal(struct fatm_softc *sc)
/* get the buffer */
for (;;) {
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
+ if (!(sc->ifp->if_flags & IFF_RUNNING))
return (EIO);
if (!(sc->flags & FATM_REGS_INUSE))
break;
@@ -334,7 +335,7 @@ fatm_utopia_readregs(struct ifatm *ifatm, u_int reg, uint8_t *valp, u_int *np)
return (EINVAL);
if (reg + *np > FATM_NREGS)
*np = FATM_NREGS - reg;
- sc = ifatm->ifnet.if_softc;
+ sc = ifatm->ifp->if_softc;
FATM_CHECKLOCK(sc);
err = fatm_utopia_readregs_internal(sc);
@@ -470,11 +471,11 @@ fatm_stop(struct fatm_softc *sc)
(void)fatm_reset(sc);
/* stop watchdog */
- sc->ifatm.ifnet.if_timer = 0;
+ sc->ifp->if_timer = 0;
- if (sc->ifatm.ifnet.if_flags & IFF_RUNNING) {
- sc->ifatm.ifnet.if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
+ if (sc->ifp->if_flags & IFF_RUNNING) {
+ sc->ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+ ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
/*
@@ -876,12 +877,12 @@ fatm_getprom(struct fatm_softc *sc)
DELAY(1000);
}
if (i == 1000) {
- if_printf(&sc->ifatm.ifnet, "getprom timeout\n");
+ if_printf(sc->ifp, "getprom timeout\n");
return (EIO);
}
H_SYNCSTAT_POSTREAD(sc, q->q.statp);
if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) {
- if_printf(&sc->ifatm.ifnet, "getprom error\n");
+ if_printf(sc->ifp, "getprom error\n");
return (EIO);
}
H_SETSTAT(q->q.statp, FATM_STAT_FREE);
@@ -906,16 +907,16 @@ fatm_getprom(struct fatm_softc *sc)
prom = (struct prom *)sc->prom_mem.mem;
- bcopy(prom->mac + 2, sc->ifatm.mib.esi, 6);
- sc->ifatm.mib.serial = le32toh(prom->serial);
- sc->ifatm.mib.hw_version = le32toh(prom->version);
- sc->ifatm.mib.sw_version = READ4(sc, FATMO_FIRMWARE_RELEASE);
+ bcopy(prom->mac + 2, IFP2IFATM(sc->ifp)->mib.esi, 6);
+ IFP2IFATM(sc->ifp)->mib.serial = le32toh(prom->serial);
+ IFP2IFATM(sc->ifp)->mib.hw_version = le32toh(prom->version);
+ IFP2IFATM(sc->ifp)->mib.sw_version = READ4(sc, FATMO_FIRMWARE_RELEASE);
- if_printf(&sc->ifatm.ifnet, "ESI=%02x:%02x:%02x:%02x:%02x:%02x "
- "serial=%u hw=0x%x sw=0x%x\n", sc->ifatm.mib.esi[0],
- sc->ifatm.mib.esi[1], sc->ifatm.mib.esi[2], sc->ifatm.mib.esi[3],
- sc->ifatm.mib.esi[4], sc->ifatm.mib.esi[5], sc->ifatm.mib.serial,
- sc->ifatm.mib.hw_version, sc->ifatm.mib.sw_version);
+ if_printf(sc->ifp, "ESI=%02x:%02x:%02x:%02x:%02x:%02x "
+ "serial=%u hw=0x%x sw=0x%x\n", IFP2IFATM(sc->ifp)->mib.esi[0],
+ IFP2IFATM(sc->ifp)->mib.esi[1], IFP2IFATM(sc->ifp)->mib.esi[2], IFP2IFATM(sc->ifp)->mib.esi[3],
+ IFP2IFATM(sc->ifp)->mib.esi[4], IFP2IFATM(sc->ifp)->mib.esi[5], IFP2IFATM(sc->ifp)->mib.serial,
+ IFP2IFATM(sc->ifp)->mib.hw_version, IFP2IFATM(sc->ifp)->mib.sw_version);
return (0);
}
@@ -954,14 +955,14 @@ alloc_dma_memory(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
NULL, NULL, mem->size, 1, BUS_SPACE_MAXSIZE_32BIT,
BUS_DMA_ALLOCNOW, NULL, NULL, &mem->dmat)) {
- if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA tag\n",
+ if_printf(sc->ifp, "could not allocate %s DMA tag\n",
nm);
return (ENOMEM);
}
error = bus_dmamem_alloc(mem->dmat, &mem->mem, 0, &mem->map);
if (error) {
- if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA memory: "
+ if_printf(sc->ifp, "could not allocate %s DMA memory: "
"%d\n", nm, error);
bus_dma_tag_destroy(mem->dmat);
mem->mem = NULL;
@@ -971,7 +972,7 @@ alloc_dma_memory(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
error = bus_dmamap_load(mem->dmat, mem->map, mem->mem, mem->size,
dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT);
if (error) {
- if_printf(&sc->ifatm.ifnet, "could not load %s DMA memory: "
+ if_printf(sc->ifp, "could not load %s DMA memory: "
"%d\n", nm, error);
bus_dmamem_free(mem->dmat, mem->mem, mem->map);
bus_dma_tag_destroy(mem->dmat);
@@ -997,7 +998,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
BUS_SPACE_MAXADDR_24BIT, BUS_SPACE_MAXADDR,
NULL, NULL, mem->size, 1, mem->size,
BUS_DMA_ALLOCNOW, NULL, NULL, &mem->dmat)) {
- if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA tag\n",
+ if_printf(sc->ifp, "could not allocate %s DMA tag\n",
nm);
return (ENOMEM);
}
@@ -1007,7 +1008,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
error = bus_dmamap_create(mem->dmat, 0, &mem->map);
if (error) {
- if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA map: "
+ if_printf(sc->ifp, "could not allocate %s DMA map: "
"%d\n", nm, error);
contigfree(mem->mem, mem->size, M_DEVBUF);
bus_dma_tag_destroy(mem->dmat);
@@ -1018,7 +1019,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
error = bus_dmamap_load(mem->dmat, mem->map, mem->mem, mem->size,
dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT);
if (error) {
- if_printf(&sc->ifatm.ifnet, "could not load %s DMA memory: "
+ if_printf(sc->ifp, "could not load %s DMA memory: "
"%d\n", nm, error);
bus_dmamap_destroy(mem->dmat, mem->map);
contigfree(mem->mem, mem->size, M_DEVBUF);
@@ -1094,7 +1095,7 @@ fatm_supply_small_buffers(struct fatm_softc *sc)
for (i = 0; i < SMALL_SUPPLY_BLKSIZE; i++) {
if ((rb = LIST_FIRST(&sc->rbuf_free)) == NULL) {
- if_printf(&sc->ifatm.ifnet, "out of rbufs\n");
+ if_printf(sc->ifp, "out of rbufs\n");
break;
}
MGETHDR(m, M_DONTWAIT, MT_DATA);
@@ -1107,7 +1108,7 @@ fatm_supply_small_buffers(struct fatm_softc *sc)
m->m_data, SMALL_BUFFER_LEN, dmaload_helper,
&phys, BUS_DMA_NOWAIT);
if (error) {
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"dmamap_load mbuf failed %d", error);
m_freem(m);
LIST_INSERT_HEAD(&sc->rbuf_free, rb, link);
@@ -1184,7 +1185,7 @@ fatm_supply_large_buffers(struct fatm_softc *sc)
for (i = 0; i < LARGE_SUPPLY_BLKSIZE; i++) {
if ((rb = LIST_FIRST(&sc->rbuf_free)) == NULL) {
- if_printf(&sc->ifatm.ifnet, "out of rbufs\n");
+ if_printf(sc->ifp, "out of rbufs\n");
break;
}
if ((m = m_getcl(M_DONTWAIT, MT_DATA,
@@ -1198,7 +1199,7 @@ fatm_supply_large_buffers(struct fatm_softc *sc)
m->m_data, LARGE_BUFFER_LEN, dmaload_helper,
&phys, BUS_DMA_NOWAIT);
if (error) {
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"dmamap_load mbuf failed %d", error);
m_freem(m);
LIST_INSERT_HEAD(&sc->rbuf_free, rb, link);
@@ -1256,7 +1257,7 @@ fatm_init_locked(struct fatm_softc *sc)
uint32_t start;
DBG(sc, INIT, ("initialize"));
- if (sc->ifatm.ifnet.if_flags & IFF_RUNNING)
+ if (sc->ifp->if_flags & IFF_RUNNING)
fatm_stop(sc);
/*
@@ -1279,39 +1280,39 @@ fatm_init_locked(struct fatm_softc *sc)
switch (c) {
case FORE_MT_TAXI_100:
- sc->ifatm.mib.media = IFM_ATM_TAXI_100;
- sc->ifatm.mib.pcr = 227273;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_TAXI_100;
+ IFP2IFATM(sc->ifp)->mib.pcr = 227273;
break;
case FORE_MT_TAXI_140:
- sc->ifatm.mib.media = IFM_ATM_TAXI_140;
- sc->ifatm.mib.pcr = 318181;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_TAXI_140;
+ IFP2IFATM(sc->ifp)->mib.pcr = 318181;
break;
case FORE_MT_UTP_SONET:
- sc->ifatm.mib.media = IFM_ATM_UTP_155;
- sc->ifatm.mib.pcr = 353207;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155;
+ IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
case FORE_MT_MM_OC3_ST:
case FORE_MT_MM_OC3_SC:
- sc->ifatm.mib.media = IFM_ATM_MM_155;
- sc->ifatm.mib.pcr = 353207;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
+ IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
case FORE_MT_SM_OC3_ST:
case FORE_MT_SM_OC3_SC:
- sc->ifatm.mib.media = IFM_ATM_SM_155;
- sc->ifatm.mib.pcr = 353207;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_155;
+ IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
default:
log(LOG_ERR, "fatm: unknown media type %d\n", c);
- sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
- sc->ifatm.mib.pcr = 353207;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
+ IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
}
- sc->ifatm.ifnet.if_baudrate = 53 * 8 * sc->ifatm.mib.pcr;
+ sc->ifp->if_baudrate = 53 * 8 * IFP2IFATM(sc->ifp)->mib.pcr;
utopia_init_media(&sc->utopia);
/*
@@ -1332,17 +1333,17 @@ fatm_init_locked(struct fatm_softc *sc)
/*
* Now set flags, that we are ready
*/
- sc->ifatm.ifnet.if_flags |= IFF_RUNNING;
+ sc->ifp->if_flags |= IFF_RUNNING;
/*
* Start the watchdog timer
*/
- sc->ifatm.ifnet.if_timer = 5;
+ sc->ifp->if_timer = 5;
/* start SUNI */
utopia_start(&sc->utopia);
- ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
+ ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
/* start all channels */
@@ -1351,7 +1352,7 @@ fatm_init_locked(struct fatm_softc *sc)
sc->vccs[i]->vflags |= FATM_VCC_REOPEN;
error = fatm_load_vc(sc, sc->vccs[i]);
if (error != 0) {
- if_printf(&sc->ifatm.ifnet, "reopening %u "
+ if_printf(sc->ifp, "reopening %u "
"failed: %d\n", i, error);
sc->vccs[i]->vflags &= ~FATM_VCC_REOPEN;
}
@@ -1525,7 +1526,7 @@ fatm_intr_drain_rx(struct fatm_softc *sc)
}
m0->m_pkthdr.len = mlen;
- m0->m_pkthdr.rcvif = &sc->ifatm.ifnet;
+ m0->m_pkthdr.rcvif = sc->ifp;
h = le32toh(rpd->atm_header);
vpi = (h >> 20) & 0xff;
@@ -1553,7 +1554,7 @@ fatm_intr_drain_rx(struct fatm_softc *sc)
ATM_PH_VPI(&aph) = vpi;
ATM_PH_SETVCI(&aph, vci);
- ifp = &sc->ifatm.ifnet;
+ ifp = sc->ifp;
ifp->if_ipackets++;
vc->ipackets++;
@@ -1624,7 +1625,7 @@ fatm_intr(void *p)
}
WRITE4(sc, FATMO_HCR, FATM_HCR_CLRIRQ);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
FATM_UNLOCK(sc);
return;
}
@@ -1638,8 +1639,8 @@ fatm_intr(void *p)
FATM_UNLOCK(sc);
- if (sc->retry_tx && _IF_QLEN(&sc->ifatm.ifnet.if_snd))
- (*sc->ifatm.ifnet.if_start)(&sc->ifatm.ifnet);
+ if (sc->retry_tx && _IF_QLEN(&sc->ifp->if_snd))
+ (*sc->ifp->if_start)(sc->ifp);
}
/*
@@ -1679,7 +1680,7 @@ fatm_getstat(struct fatm_softc *sc)
* statistics buffer
*/
for (;;) {
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
+ if (!(sc->ifp->if_flags & IFF_RUNNING))
return (EIO);
if (!(sc->flags & FATM_STAT_INUSE))
break;
@@ -1948,7 +1949,7 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen)
if (H_GETSTAT(q->q.statp) != FATM_STAT_FREE) {
if (sc->retry_tx) {
sc->istats.tx_retry++;
- IF_PREPEND(&sc->ifatm.ifnet.if_snd, m);
+ IF_PREPEND(&sc->ifp->if_snd, m);
return (1);
}
sc->istats.tx_queue_full++;
@@ -1967,8 +1968,8 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen)
error = bus_dmamap_load_mbuf(sc->tx_tag, q->map, m,
fatm_tpd_load, tpd, BUS_DMA_NOWAIT);
if(error) {
- sc->ifatm.ifnet.if_oerrors++;
- if_printf(&sc->ifatm.ifnet, "mbuf loaded error=%d\n", error);
+ sc->ifp->if_oerrors++;
+ if_printf(sc->ifp, "mbuf loaded error=%d\n", error);
m_freem(m);
return (0);
}
@@ -2018,7 +2019,7 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen)
BARRIER_W(sc);
sc->txcnt++;
- sc->ifatm.ifnet.if_opackets++;
+ sc->ifp->if_opackets++;
vc->obytes += m->m_pkthdr.len;
vc->opackets++;
@@ -2175,7 +2176,7 @@ fatm_open_finish(struct fatm_softc *sc, struct card_vcc *vc)
* VCC or it's an NG PVC. */
if (!(vc->param.flags & ATMIO_FLAG_NG) ||
(vc->param.flags & ATMIO_FLAG_PVC))
- ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vc->param.vci, 1);
+ ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), 0, vc->param.vci, 1);
}
/*
@@ -2194,7 +2195,7 @@ fatm_open_complete(struct fatm_softc *sc, struct cmdqueue *q)
sc->istats.get_stat_errors++;
sc->vccs[vci] = NULL;
uma_zfree(sc->vcc_zone, vc);
- if_printf(&sc->ifatm.ifnet, "opening VCI %u failed\n", vci);
+ if_printf(sc->ifp, "opening VCI %u failed\n", vci);
return;
}
fatm_open_finish(sc, vc);
@@ -2246,7 +2247,7 @@ fatm_open_vcc(struct fatm_softc *sc, struct atmio_openvcc *op)
error = 0;
FATM_LOCK(sc);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@@ -2264,7 +2265,7 @@ fatm_open_vcc(struct fatm_softc *sc, struct atmio_openvcc *op)
case ATMIO_TRAFFIC_CBR:
if (op->param.tparam.pcr == 0 ||
- op->param.tparam.pcr > sc->ifatm.mib.pcr) {
+ op->param.tparam.pcr > IFP2IFATM(sc->ifp)->mib.pcr) {
error = EINVAL;
goto done;
}
@@ -2340,7 +2341,7 @@ fatm_close_finish(struct fatm_softc *sc, struct card_vcc *vc)
* VCC or it's an NG PVC. */
if (!(vc->param.flags & ATMIO_FLAG_NG) ||
(vc->param.flags & ATMIO_FLAG_PVC))
- ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vc->param.vci, 0);
+ ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), 0, vc->param.vci, 0);
sc->vccs[vc->param.vci] = NULL;
sc->open_vccs--;
@@ -2363,7 +2364,7 @@ fatm_close_complete(struct fatm_softc *sc, struct cmdqueue *q)
if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) {
sc->istats.get_stat_errors++;
/* keep the VCC in that state */
- if_printf(&sc->ifatm.ifnet, "closing VCI %u failed\n", vci);
+ if_printf(sc->ifp, "closing VCI %u failed\n", vci);
return;
}
@@ -2386,7 +2387,7 @@ fatm_close_vcc(struct fatm_softc *sc, struct atmio_closevcc *cl)
error = 0;
FATM_LOCK(sc);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@@ -2533,14 +2534,14 @@ fatm_detach(device_t dev)
fatm_stop(sc);
utopia_detach(&sc->utopia);
FATM_UNLOCK(sc);
- atm_ifdetach(&sc->ifatm.ifnet); /* XXX race */
+ atm_ifdetach(sc->ifp); /* XXX race */
}
if (sc->ih != NULL)
bus_teardown_intr(dev, sc->irqres, sc->ih);
while ((rb = LIST_FIRST(&sc->rbuf_used)) != NULL) {
- if_printf(&sc->ifatm.ifnet, "rbuf %p still in use!\n", rb);
+ if_printf(sc->ifp, "rbuf %p still in use!\n", rb);
bus_dmamap_unload(sc->rbuf_tag, rb->map);
m_freem(rb->m);
LIST_REMOVE(rb, link);
@@ -2744,16 +2745,22 @@ fatm_attach(device_t dev)
sc = device_get_softc(dev);
unit = device_get_unit(dev);
- sc->ifatm.mib.device = ATM_DEVICE_PCA200E;
- sc->ifatm.mib.serial = 0;
- sc->ifatm.mib.hw_version = 0;
- sc->ifatm.mib.sw_version = 0;
- sc->ifatm.mib.vpi_bits = 0;
- sc->ifatm.mib.vci_bits = FORE_VCIBITS;
- sc->ifatm.mib.max_vpcs = 0;
- sc->ifatm.mib.max_vccs = FORE_MAX_VCC;
- sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
- sc->ifatm.phy = &sc->utopia;
+ ifp = sc->ifp = if_alloc(IFT_ATM);
+ if (ifp == NULL) {
+ error = ENOSPC;
+ goto fail;
+ }
+
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_PCA200E;
+ IFP2IFATM(sc->ifp)->mib.serial = 0;
+ IFP2IFATM(sc->ifp)->mib.hw_version = 0;
+ IFP2IFATM(sc->ifp)->mib.sw_version = 0;
+ IFP2IFATM(sc->ifp)->mib.vpi_bits = 0;
+ IFP2IFATM(sc->ifp)->mib.vci_bits = FORE_VCIBITS;
+ IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
+ IFP2IFATM(sc->ifp)->mib.max_vccs = FORE_MAX_VCC;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
+ IFP2IFATM(sc->ifp)->phy = &sc->utopia;
LIST_INIT(&sc->rbuf_free);
LIST_INIT(&sc->rbuf_used);
@@ -2803,7 +2810,6 @@ fatm_attach(device_t dev)
/*
* Network subsystem stuff
*/
- ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_SIMPLEX;
@@ -2811,8 +2817,8 @@ fatm_attach(device_t dev)
ifp->if_start = fatm_start;
ifp->if_watchdog = fatm_watchdog;
ifp->if_init = fatm_init;
- ifp->if_linkmib = &sc->ifatm.mib;
- ifp->if_linkmiblen = sizeof(sc->ifatm.mib);
+ ifp->if_linkmib = &IFP2IFATM(sc->ifp)->mib;
+ ifp->if_linkmiblen = sizeof(IFP2IFATM(sc->ifp)->mib);
/*
* Enable memory and bustmaster
@@ -2991,7 +2997,7 @@ fatm_attach(device_t dev)
*/
for (rb = sc->rbufs, i = 0; i < sc->rbuf_total; i++, rb++) {
if ((error = bus_dmamap_create(sc->rbuf_tag, 0, &rb->map))) {
- if_printf(&sc->ifatm.ifnet, "creating rx map: %d\n",
+ if_printf(sc->ifp, "creating rx map: %d\n",
error);
goto fail;
}
@@ -3007,7 +3013,7 @@ fatm_attach(device_t dev)
for (i = 0; i < FATM_TX_QLEN; i++) {
tx = GET_QUEUE(sc->txqueue, struct txqueue, i);
if ((error = bus_dmamap_create(sc->tx_tag, 0, &tx->map))) {
- if_printf(&sc->ifatm.ifnet, "creating tx map: %d\n",
+ if_printf(sc->ifp, "creating tx map: %d\n",
error);
while (i > 0) {
tx = GET_QUEUE(sc->txqueue, struct txqueue,
@@ -3019,7 +3025,7 @@ fatm_attach(device_t dev)
}
}
- utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx,
+ utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&fatm_utopia_methods);
sc->utopia.flags |= UTP_FL_NORESET | UTP_FL_POLL_CARRIER;
diff --git a/sys/dev/fatm/if_fatmvar.h b/sys/dev/fatm/if_fatmvar.h
index 8c550fe..697e915 100644
--- a/sys/dev/fatm/if_fatmvar.h
+++ b/sys/dev/fatm/if_fatmvar.h
@@ -185,7 +185,7 @@ struct card_vcc {
* Finally the softc structure
*/
struct fatm_softc {
- struct ifatm ifatm; /* common part */
+ struct ifnet *ifp; /* common part */
struct mtx mtx; /* lock this structure */
struct ifmedia media; /* media */
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
index 3e344cf..643f3e4 100644
--- a/sys/dev/fe/if_fe.c
+++ b/sys/dev/fe/if_fe.c
@@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net/if_mib.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
@@ -427,8 +428,8 @@ fe_read_eeprom_jli (struct fe_softc * sc, u_char * data)
int i;
data -= JLI_EEPROM_SIZE;
for (i = 0; i < JLI_EEPROM_SIZE; i += 16) {
- printf("%s: EEPROM(JLI):%3x: %16D\n",
- sc->sc_xname, i, data + i, " ");
+ if_printf(sc->ifp,
+ "EEPROM(JLI):%3x: %16D\n", i, data + i, " ");
}
}
#endif
@@ -543,8 +544,8 @@ fe_read_eeprom_ssi (struct fe_softc *sc, u_char *data)
int i;
data -= SSI_EEPROM_SIZE;
for (i = 0; i < SSI_EEPROM_SIZE; i += 16) {
- printf("%s: EEPROM(SSI):%3x: %16D\n",
- sc->sc_xname, i, data + i, " ");
+ if_printf(sc->ifp,
+ "EEPROM(SSI):%3x: %16D\n", i, data + i, " ");
}
}
#endif
@@ -645,8 +646,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
this board was not a TDK/LANX) or not working
properly. */
if (bootverbose) {
- printf("%s: no ACK received from EEPROM(LNX)\n",
- sc->sc_xname);
+ if_printf(sc->ifp,
+ "no ACK received from EEPROM(LNX)\n");
}
/* Clear the given buffer to indicate we could not get
any info. and return. */
@@ -684,8 +685,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
if (bootverbose) {
data -= LNX_EEPROM_SIZE;
for (i = 0; i < LNX_EEPROM_SIZE; i += 16) {
- printf("%s: EEPROM(LNX):%3x: %16D\n",
- sc->sc_xname, i, data + i, " ");
+ if_printf(sc->ifp,
+ "EEPROM(LNX):%3x: %16D\n", i, data + i, " ");
}
}
#endif
@@ -729,8 +730,15 @@ int
fe_attach (device_t dev)
{
struct fe_softc *sc = device_get_softc(dev);
+ struct ifnet *ifp;
int flags = device_get_flags(dev);
int b, error;
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not ifalloc\n");
+ return (ENOSPC);
+ }
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
fe_intr, sc, &sc->irq_handle);
@@ -742,14 +750,14 @@ fe_attach (device_t dev)
/*
* Initialize ifnet structure
*/
- sc->sc_if.if_softc = sc;
- if_initname(&sc->sc_if, device_get_name(dev), device_get_unit(dev));
- sc->sc_if.if_start = fe_start;
- sc->sc_if.if_ioctl = fe_ioctl;
- sc->sc_if.if_watchdog = fe_watchdog;
- sc->sc_if.if_init = fe_init;
- sc->sc_if.if_linkmib = &sc->mibdata;
- sc->sc_if.if_linkmiblen = sizeof (sc->mibdata);
+ ifp->if_softc = sc;
+ if_initname(sc->ifp, device_get_name(dev), device_get_unit(dev));
+ ifp->if_start = fe_start;
+ ifp->if_ioctl = fe_ioctl;
+ ifp->if_watchdog = fe_watchdog;
+ ifp->if_init = fe_init;
+ ifp->if_linkmib = &sc->mibdata;
+ ifp->if_linkmiblen = sizeof (sc->mibdata);
#if 0 /* I'm not sure... */
sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS;
@@ -758,7 +766,7 @@ fe_attach (device_t dev)
/*
* Set fixed interface flags.
*/
- sc->sc_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
IFF_NEEDSGIANT;
#if 1
@@ -772,8 +780,8 @@ fe_attach (device_t dev)
* since it must be a common workaround for all network drivers.
* FIXME.
*/
- if (sc->sc_if.if_snd.ifq_maxlen == 0)
- sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen;
+ if (ifp->if_snd.ifq_maxlen == 0)
+ ifp->if_snd.ifq_maxlen = ifqmaxlen;
#endif
#if FE_SINGLE_TRANSMISSION
@@ -794,8 +802,8 @@ fe_attach (device_t dev)
default:
/* Oops, we can't work with single buffer configuration. */
if (bootverbose) {
- printf("%s: strange TXBSIZ config; fixing\n",
- sc->sc_xname);
+ if_printf(sc->ifp,
+ "strange TXBSIZ config; fixing\n");
}
sc->proto_dlcr6 &= ~FE_D6_TXBSIZ;
sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB;
@@ -821,7 +829,7 @@ fe_attach (device_t dev)
#endif
/* Attach and stop the interface. */
- ether_ifattach(&sc->sc_if, sc->arpcom.ac_enaddr);
+ ether_ifattach(sc->ifp, sc->enaddr);
fe_stop(sc);
/* Print additional info when attached. */
@@ -927,12 +935,12 @@ static void
fe_reset (struct fe_softc *sc)
{
/* Record how many packets are lost by this accident. */
- sc->sc_if.if_oerrors += sc->txb_sched + sc->txb_count;
+ sc->ifp->if_oerrors += sc->txb_sched + sc->txb_count;
sc->mibdata.dot3StatsInternalMacTransmitErrors++;
/* Put the interface into known initial state. */
fe_stop(sc);
- if (sc->sc_if.if_flags & IFF_UP)
+ if (sc->ifp->if_flags & IFF_UP)
fe_init(sc);
}
@@ -968,8 +976,8 @@ fe_stop (struct fe_softc *sc)
DELAY(200);
/* Reset transmitter variables and interface flags. */
- sc->sc_if.if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
- sc->sc_if.if_timer = 0;
+ sc->ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
+ sc->ifp->if_timer = 0;
sc->txb_free = sc->txb_size;
sc->txb_count = 0;
sc->txb_sched = 0;
@@ -991,13 +999,13 @@ fe_stop (struct fe_softc *sc)
static void
fe_watchdog ( struct ifnet *ifp )
{
- struct fe_softc *sc = (struct fe_softc *)ifp;
+ struct fe_softc *sc = ifp->if_softc;
/* A "debug" message. */
if_printf(ifp, "transmission timeout (%d+%d)%s\n",
sc->txb_sched, sc->txb_count,
(ifp->if_flags & IFF_UP) ? "" : " when down");
- if (sc->sc_if.if_opackets == 0 && sc->sc_if.if_ipackets == 0)
+ if (sc->ifp->if_opackets == 0 && sc->ifp->if_ipackets == 0)
if_printf(ifp, "wrong IRQ setting in config?\n");
fe_reset(sc);
}
@@ -1034,7 +1042,7 @@ fe_init (void * xsc)
DELAY(200);
/* Feed the station address. */
- fe_outblk(sc, FE_DLCR8, sc->sc_enaddr, ETHER_ADDR_LEN);
+ fe_outblk(sc, FE_DLCR8, IFP2ENADDR(sc->ifp), ETHER_ADDR_LEN);
/* Clear multicast address filter to receive nothing. */
fe_outb(sc, FE_DLCR7,
@@ -1091,8 +1099,8 @@ fe_init (void * xsc)
* The following message helps discovering the fact. FIXME.
*/
if (!(fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP)) {
- printf("%s: receive buffer has some data after reset\n",
- sc->sc_xname);
+ if_printf(sc->ifp,
+ "receive buffer has some data after reset\n");
fe_emptybuffer(sc);
}
@@ -1102,7 +1110,7 @@ fe_init (void * xsc)
#endif
/* Set 'running' flag, because we are now running. */
- sc->sc_if.if_flags |= IFF_RUNNING;
+ sc->ifp->if_flags |= IFF_RUNNING;
/*
* At this point, the interface is running properly,
@@ -1119,7 +1127,7 @@ fe_init (void * xsc)
the interface keeping it idle. The upper layer will soon
start the interface anyway, and there are no significant
delay. */
- fe_start(&sc->sc_if);
+ fe_start(sc->ifp);
#endif
(void) splx(s);
@@ -1136,7 +1144,7 @@ fe_xmit (struct fe_softc *sc)
* We use longer timeout for multiple packet transmission.
* I'm not sure this timer value is appropriate. FIXME.
*/
- sc->sc_if.if_timer = 1 + sc->txb_count;
+ sc->ifp->if_timer = 1 + sc->txb_count;
/* Update txb variables. */
sc->txb_sched = sc->txb_count;
@@ -1253,7 +1261,7 @@ fe_start (struct ifnet *ifp)
/*
* Get the next mbuf chain for a packet to send.
*/
- IF_DEQUEUE(&sc->sc_if.if_snd, m);
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
if (m == NULL) {
/* No more packets to send. */
goto indicate_inactive;
@@ -1276,8 +1284,8 @@ fe_start (struct ifnet *ifp)
* and only if it is in "receive everything"
* mode.)
*/
- if (!(sc->sc_if.if_flags & IFF_PROMISC))
- BPF_MTAP(&sc->sc_if, m);
+ if (!(sc->ifp->if_flags & IFF_PROMISC))
+ BPF_MTAP(sc->ifp, m);
m_freem(m);
}
@@ -1292,7 +1300,7 @@ fe_start (struct ifnet *ifp)
* filled all the buffers with data then we still
* want to accept more.
*/
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
return;
indicate_active:
@@ -1300,7 +1308,7 @@ fe_start (struct ifnet *ifp)
* The transmitter is active, and there are no room for
* more outgoing packets in the transmission buffer.
*/
- sc->sc_if.if_flags |= IFF_OACTIVE;
+ sc->ifp->if_flags |= IFF_OACTIVE;
return;
}
@@ -1359,7 +1367,7 @@ fe_emptybuffer (struct fe_softc * sc)
u_char saved_dlcr5;
#ifdef FE_DEBUG
- printf("%s: emptying receive buffer\n", sc->sc_xname);
+ if_printf(sc->ifp, "emptying receive buffer\n");
#endif
/*
@@ -1395,7 +1403,8 @@ fe_emptybuffer (struct fe_softc * sc)
* Double check.
*/
if (fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP) {
- printf("%s: could not empty receive buffer\n", sc->sc_xname);
+ if_printf(sc->ifp,
+ "could not empty receive buffer\n");
/* Hmm. What should I do if this happens? FIXME. */
}
@@ -1426,8 +1435,8 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* are left unsent in transmission buffer.
*/
left = fe_inb(sc, FE_BMPR10);
- printf("%s: excessive collision (%d/%d)\n",
- sc->sc_xname, left, sc->txb_sched);
+ if_printf(sc->ifp, "excessive collision (%d/%d)\n",
+ left, sc->txb_sched);
/*
* Clear the collision flag (in 86960) here
@@ -1499,7 +1508,7 @@ fe_tint (struct fe_softc * sc, u_char tstat)
*/
col = 1;
}
- sc->sc_if.if_collisions += col;
+ sc->ifp->if_collisions += col;
if (col == 1)
sc->mibdata.dot3StatsSingleCollisionFrames++;
else
@@ -1512,9 +1521,9 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* Be sure to reflect number of excessive collisions.
*/
col = sc->tx_excolls;
- sc->sc_if.if_opackets += sc->txb_sched - col;
- sc->sc_if.if_oerrors += col;
- sc->sc_if.if_collisions += col * 16;
+ sc->ifp->if_opackets += sc->txb_sched - col;
+ sc->ifp->if_oerrors += col;
+ sc->ifp->if_collisions += col * 16;
sc->mibdata.dot3StatsExcessiveCollisions += col;
sc->mibdata.dot3StatsCollFrequencies[15] += col;
sc->txb_sched = 0;
@@ -1523,8 +1532,8 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* The transmitter is no more active.
* Reset output active flag and watchdog timer.
*/
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
- sc->sc_if.if_timer = 0;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_timer = 0;
/*
* If more data is ready to transmit in the buffer, start
@@ -1571,7 +1580,7 @@ fe_rint (struct fe_softc * sc, u_char rstat)
if (rstat & FE_D1_SRTPKT)
sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */
#endif
- sc->sc_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
}
/*
@@ -1629,8 +1638,9 @@ fe_rint (struct fe_softc * sc, u_char rstat)
if ((status & 0xF0) != 0x20 ||
len > ETHER_MAX_LEN - ETHER_CRC_LEN ||
len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
- printf("%s: RX buffer out-of-sync\n", sc->sc_xname);
- sc->sc_if.if_ierrors++;
+ if_printf(sc->ifp,
+ "RX buffer out-of-sync\n");
+ sc->ifp->if_ierrors++;
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
fe_reset(sc);
return;
@@ -1647,19 +1657,19 @@ fe_rint (struct fe_softc * sc, u_char rstat)
* in the buffer. We hope we can get more
* mbuf next time.
*/
- sc->sc_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
sc->mibdata.dot3StatsMissedFrames++;
fe_droppacket(sc, len);
return;
}
/* Successfully received a packet. Update stat. */
- sc->sc_if.if_ipackets++;
+ sc->ifp->if_ipackets++;
}
/* Maximum number of frames has been received. Something
strange is happening here... */
- printf("%s: unusual receive flood\n", sc->sc_xname);
+ if_printf(sc->ifp, "unusual receive flood\n");
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
fe_reset(sc);
}
@@ -1713,7 +1723,7 @@ fe_intr (void *arg)
if (sc->filter_change &&
sc->txb_count == 0 && sc->txb_sched == 0) {
fe_loadmar(sc);
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
}
/*
@@ -1729,11 +1739,11 @@ fe_intr (void *arg)
* receiver interrupts. 86960 can raise a receiver
* interrupt when the transmission buffer is full.
*/
- if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0)
- fe_start(&sc->sc_if);
+ if ((sc->ifp->if_flags & IFF_OACTIVE) == 0)
+ fe_start(sc->ifp);
}
- printf("%s: too many loops\n", sc->sc_xname);
+ if_printf(sc->ifp, "too many loops\n");
}
/*
@@ -1756,11 +1766,11 @@ fe_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
* Switch interface state between "running" and
* "stopped", reflecting the UP flag.
*/
- if (sc->sc_if.if_flags & IFF_UP) {
- if ((sc->sc_if.if_flags & IFF_RUNNING) == 0)
+ if (sc->ifp->if_flags & IFF_UP) {
+ if ((sc->ifp->if_flags & IFF_RUNNING) == 0)
fe_init(sc);
} else {
- if ((sc->sc_if.if_flags & IFF_RUNNING) != 0)
+ if ((sc->ifp->if_flags & IFF_RUNNING) != 0)
fe_stop(sc);
}
@@ -1806,7 +1816,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 ifnet *ifp = sc->ifp;
struct ether_header *eh;
struct mbuf *m;
@@ -1911,8 +1921,9 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
/* Check if this matches the one in the packet header. */
if (length != m->m_pkthdr.len) {
- printf("%s: packet length mismatch? (%d/%d)\n", sc->sc_xname,
- length, m->m_pkthdr.len);
+ if_printf(sc->ifp,
+ "packet length mismatch? (%d/%d)\n",
+ length, m->m_pkthdr.len);
}
#else
/* Just use the length value in the packet header. */
@@ -1927,9 +1938,9 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
*/
if (length < ETHER_HDR_LEN ||
length > ETHER_MAX_LEN - ETHER_CRC_LEN) {
- printf("%s: got an out-of-spec packet (%u bytes) to send\n",
- sc->sc_xname, length);
- sc->sc_if.if_oerrors++;
+ if_printf(sc->ifp,
+ "got an out-of-spec packet (%u bytes) to send\n", length);
+ sc->ifp->if_oerrors++;
sc->mibdata.dot3StatsInternalMacTransmitErrors++;
return;
}
@@ -2049,14 +2060,14 @@ fe_mcaf ( struct fe_softc *sc )
struct ifmultiaddr *ifma;
filter = fe_filter_nothing;
- TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
index = ether_crc32_le(LLADDR((struct sockaddr_dl *)
ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
#ifdef FE_DEBUG
- printf("%s: hash(%6D) == %d\n",
- sc->sc_xname, enm->enm_addrlo , ":", index);
+ if_printf(sc->ifp, "hash(%6D) == %d\n",
+ enm->enm_addrlo , ":", index);
#endif
filter.data[index >> 3] |= 1 << (index & 7);
@@ -2071,7 +2082,7 @@ fe_mcaf ( struct fe_softc *sc )
static void
fe_setmode (struct fe_softc *sc)
{
- int flags = sc->sc_if.if_flags;
+ int flags = sc->ifp->if_flags;
/*
* If the interface is not running, we postpone the update
@@ -2198,8 +2209,9 @@ fe_medchange (struct ifnet *ifp)
if (bit2media[b] == sc->media.ifm_media) break;
}
if (((1 << b) & sc->mbitmap) == 0) {
- printf("%s: got an unsupported media request (0x%x)\n",
- sc->sc_xname, sc->media.ifm_media);
+ if_printf(sc->ifp,
+ "got an unsupported media request (0x%x)\n",
+ sc->media.ifm_media);
return EINVAL;
}
#endif
@@ -2209,7 +2221,7 @@ fe_medchange (struct ifnet *ifp)
until the transmission buffer being empty? Changing the
media when we are sending a frame will cause two garbages
on wires, one on old media and another on new. FIXME */
- if (sc->sc_if.if_flags & IFF_UP) {
+ if (sc->ifp->if_flags & IFF_UP) {
if (sc->msel) sc->msel(sc);
}
diff --git a/sys/dev/fe/if_fe_isa.c b/sys/dev/fe/if_fe_isa.c
index 6372291..3c37575 100644
--- a/sys/dev/fe/if_fe_isa.c
+++ b/sys/dev/fe/if_fe_isa.c
@@ -251,8 +251,8 @@ fe_probe_fmv(device_t dev)
/* Get our station address from EEPROM, and make sure it is
Fujitsu's. */
- fe_inblk(sc, FE_FMV4, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0x00000E))
+ fe_inblk(sc, FE_FMV4, sc->enaddr, ETHER_ADDR_LEN);
+ if (!fe_valid_Ether_p(sc->enaddr, 0x00000E))
return ENXIO;
/* Find the supported media and "hardware revision" to know
@@ -386,8 +386,8 @@ fe_probe_jli_ati(struct fe_softc * sc, u_char const * eeprom)
/* Get our station address from EEPROM, and make sure the
EEPROM contains ATI's address. */
- bcopy(eeprom + 8, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0x0000F4))
+ bcopy(eeprom + 8, sc->enaddr, ETHER_ADDR_LEN);
+ if (!fe_valid_Ether_p(sc->enaddr, 0x0000F4))
return NULL;
/*
@@ -515,10 +515,10 @@ fe_probe_jli_icl(struct fe_softc * sc, u_char const * eeprom)
valid. Use it if it is, or use the "permanent" address instead. */
if (fe_valid_Ether_p(eeprom+4, 0x020000)) {
/* The configured address is valid. Use it. */
- bcopy(eeprom+4, sc->sc_enaddr, ETHER_ADDR_LEN);
+ bcopy(eeprom+4, sc->enaddr, ETHER_ADDR_LEN);
} else {
/* The configured address is invalid. Use permanent. */
- bcopy(eeprom+122, sc->sc_enaddr, ETHER_ADDR_LEN);
+ bcopy(eeprom+122, sc->enaddr, ETHER_ADDR_LEN);
}
/* Determine model and supported media. */
@@ -613,15 +613,15 @@ fe_probe_jli_rex(struct fe_softc * sc, u_char const * eeprom)
/* Get our station address from EEPROM. Note that RATOC
stores it "byte-swapped" in each word. (I don't know why.)
So, we just can't use bcopy().*/
- sc->sc_enaddr[0] = eeprom[3];
- sc->sc_enaddr[1] = eeprom[2];
- sc->sc_enaddr[2] = eeprom[5];
- sc->sc_enaddr[3] = eeprom[4];
- sc->sc_enaddr[4] = eeprom[7];
- sc->sc_enaddr[5] = eeprom[6];
+ sc->enaddr[0] = eeprom[3];
+ sc->enaddr[1] = eeprom[2];
+ sc->enaddr[2] = eeprom[5];
+ sc->enaddr[3] = eeprom[4];
+ sc->enaddr[4] = eeprom[7];
+ sc->enaddr[5] = eeprom[6];
/* Make sure the EEPROM contains RATOC's station address. */
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0x00C0D0))
+ if (!fe_valid_Ether_p(sc->enaddr, 0x00C0D0))
return NULL;
/* I don't know any sub-model identification. */
@@ -667,7 +667,7 @@ fe_probe_jli_unk(struct fe_softc * sc, u_char const * eeprom)
return NULL;
/* Extract our (guessed) station address. */
- bcopy(eeprom+n, sc->sc_enaddr, ETHER_ADDR_LEN);
+ bcopy(eeprom+n, sc->enaddr, ETHER_ADDR_LEN);
/* We are not sure what type of board it is... */
sc->type = FE_TYPE_JLI;
@@ -841,7 +841,7 @@ fe_probe_ssi(device_t dev)
/* Make sure the Ethernet (MAC) station address is of TDK's. */
if (!fe_valid_Ether_p(eeprom+FE_SSI_EEP_ADDR, 0x008098))
return ENXIO;
- bcopy(eeprom + FE_SSI_EEP_ADDR, sc->sc_enaddr, ETHER_ADDR_LEN);
+ bcopy(eeprom + FE_SSI_EEP_ADDR, sc->enaddr, ETHER_ADDR_LEN);
/* This looks like a TDK-AX031 board. It requires an explicit
IRQ setting in config, since we currently don't know how we
@@ -902,7 +902,7 @@ fe_probe_lnx(device_t dev)
/* Make sure the Ethernet (MAC) station address is of TDK/LANX's. */
if (!fe_valid_Ether_p(eeprom, 0x008098))
return ENXIO;
- bcopy(eeprom, sc->sc_enaddr, ETHER_ADDR_LEN);
+ bcopy(eeprom, sc->enaddr, ETHER_ADDR_LEN);
/* This looks like a TDK/LANX board. It requires an
explicit IRQ setting in config. Make sure we have one,
@@ -962,10 +962,10 @@ fe_probe_gwy(device_t dev)
return ENXIO;
/* Get our station address from EEPROM. */
- fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
+ fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN);
/* Make sure it is Gateway Communication's. */
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0x000061))
+ if (!fe_valid_Ether_p(sc->enaddr, 0x000061))
return ENXIO;
/* Gateway's board requires an explicit IRQ to work, since it
@@ -1016,14 +1016,14 @@ fe_probe_ubn(device_t dev)
return ENXIO;
/* Get our station address form ID ROM and make sure it is UBN's. */
- fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0x00DD01))
+ fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN);
+ if (!fe_valid_Ether_p(sc->enaddr, 0x00DD01))
return ENXIO;
#if 0
/* Calculate checksum. */
sum = fe_inb(sc, 0x1e);
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sum ^= sc->sc_enaddr[i];
+ sum ^= sc->enaddr[i];
}
if (sum != 0)
return ENXIO;
diff --git a/sys/dev/fe/if_fe_pccard.c b/sys/dev/fe/if_fe_pccard.c
index 9c2b1e2..5acff6a 100644
--- a/sys/dev/fe/if_fe_pccard.c
+++ b/sys/dev/fe/if_fe_pccard.c
@@ -183,10 +183,11 @@ static int
fe_pccard_detach(device_t dev)
{
struct fe_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
fe_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
fe_release_resource(dev);
@@ -241,10 +242,10 @@ fe_probe_mbh(device_t dev, const struct fe_pccard_product *pp)
return ENXIO;
/* Get our station address from EEPROM. */
- fe_inblk(sc, FE_MBH10, sc->sc_enaddr, ETHER_ADDR_LEN);
+ fe_inblk(sc, FE_MBH10, sc->enaddr, ETHER_ADDR_LEN);
/* Make sure we got a valid station address. */
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0))
+ if (!fe_valid_Ether_p(sc->enaddr, 0))
return ENXIO;
/* Determine the card type. */
@@ -299,10 +300,10 @@ fe_probe_tdk (device_t dev, const struct fe_pccard_product *pp)
sc->type = FE_TYPE_TDK;
sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)";
- pccard_get_ether(dev, sc->sc_enaddr);
+ pccard_get_ether(dev, sc->enaddr);
/* Make sure we got a valid station address. */
- if (!fe_valid_Ether_p(sc->sc_enaddr, 0))
+ if (!fe_valid_Ether_p(sc->enaddr, 0))
return ENXIO;
return 0;
diff --git a/sys/dev/fe/if_fevar.h b/sys/dev/fe/if_fevar.h
index bdf9637..e80c956 100644
--- a/sys/dev/fe/if_fevar.h
+++ b/sys/dev/fe/if_fevar.h
@@ -68,8 +68,9 @@ struct fe_filter {
struct fe_softc {
/* Used by "common" codes. */
- struct arpcom arpcom; /* Ethernet common */
+ struct ifnet *ifp;
int sc_unit;
+ u_char enaddr[6];
/* Used by config codes. */
int type;
@@ -118,11 +119,6 @@ struct fe_softc {
};
-#define sc_if arpcom.ac_if
-#define sc_xname arpcom.ac_if.if_xname
-#define sc_enaddr arpcom.ac_enaddr
-
-
struct fe_simple_probe_struct {
u_char port; /* Offset from the base I/O address. */
u_char mask; /* Bits to be checked. */
diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c
index 34e540b..df57f27 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -52,6 +52,7 @@
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
+#include <net/if_types.h>
#ifdef __DragonFly__
#include <net/vlan/if_vlan_var.h>
#include <bus/firewire/firewire.h>
@@ -159,7 +160,11 @@ fwe_attach(device_t dev)
struct fwe_softc *fwe;
struct ifnet *ifp;
int unit, s;
+#if defined(__DragonFly__) || __FreeBSD_version < 500000
u_char *eaddr;
+#else
+ u_char eaddr[6];
+#endif
struct fw_eui64 *eui;
fwe = ((struct fwe_softc *)device_get_softc(dev));
@@ -185,7 +190,10 @@ fwe_attach(device_t dev)
/* generate fake MAC address: first and last 3bytes from eui64 */
#define LOCAL (0x02)
#define GROUP (0x01)
- eaddr = &fwe->eth_softc.arpcom.ac_enaddr[0];
+#if defined(__DragonFly__) || __FreeBSD_version < 500000
+ eaddr = &IFP2ENADDR(fwe->eth_softc.ifp)[0];
+#endif
+
eui = &fwe->fd.fc->eui;
eaddr[0] = (FW_EUI64_BYTE(eui, 0) | LOCAL) & ~GROUP;
@@ -199,7 +207,11 @@ fwe_attach(device_t dev)
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
/* fill the rest and attach interface */
- ifp = &fwe->fwe_if;
+ ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
ifp->if_softc = &fwe->eth_softc;
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
@@ -244,7 +256,7 @@ fwe_stop(struct fwe_softc *fwe)
{
struct firewire_comm *fc;
struct fw_xferq *xferq;
- struct ifnet *ifp = &fwe->fwe_if;
+ struct ifnet *ifp = fwe->eth_softc.ifp;
struct fw_xfer *xfer, *next;
int i;
@@ -284,16 +296,19 @@ static int
fwe_detach(device_t dev)
{
struct fwe_softc *fwe;
+ struct ifnet *ifp;
int s;
- fwe = (struct fwe_softc *)device_get_softc(dev);
+ fwe = device_get_softc(dev);
+ ifp = fwe->eth_softc.ifp;
s = splimp();
fwe_stop(fwe);
#if defined(__DragonFly__) || __FreeBSD_version < 500000
- ether_ifdetach(&fwe->fwe_if, 1);
+ ether_ifdetach(ifp, 1);
#else
- ether_ifdetach(&fwe->fwe_if);
+ ether_ifdetach(ifp);
+ if_free(ifp);
#endif
splx(s);
@@ -305,7 +320,7 @@ fwe_init(void *arg)
{
struct fwe_softc *fwe = ((struct fwe_eth_softc *)arg)->fwe;
struct firewire_comm *fc;
- struct ifnet *ifp = &fwe->fwe_if;
+ struct ifnet *ifp = fwe->eth_softc.ifp;
struct fw_xferq *xferq;
struct fw_xfer *xfer;
struct mbuf *m;
@@ -464,7 +479,7 @@ fwe_output_callback(struct fw_xfer *xfer)
int s;
fwe = (struct fwe_softc *)xfer->sc;
- ifp = &fwe->fwe_if;
+ ifp = fwe->eth_softc.ifp;
/* XXX error check */
FWEDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
@@ -593,7 +608,7 @@ fwe_as_input(struct fw_xferq *xferq)
#endif
fwe = (struct fwe_softc *)xferq->sc;
- ifp = &fwe->fwe_if;
+ ifp = fwe->eth_softc.ifp;
#if 0
FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
#endif
diff --git a/sys/dev/firewire/if_fwevar.h b/sys/dev/firewire/if_fwevar.h
index 805301a..73fcb3d 100644
--- a/sys/dev/firewire/if_fwevar.h
+++ b/sys/dev/firewire/if_fwevar.h
@@ -45,9 +45,7 @@ struct fwe_softc {
struct fw_pkt pkt_hdr;
STAILQ_HEAD(, fw_xfer) xferlist;
struct fwe_eth_softc {
- /* XXX this must be the first for if_ethersub.c */
- struct arpcom arpcom; /* ethernet common data */
- #define fwe_if eth_softc.arpcom.ac_if
+ struct ifnet *ifp;
struct fwe_softc *fwe;
} eth_softc;
};
diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index 23e812a..3d12ad2 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -55,6 +55,7 @@
#include <net/if.h>
#include <net/firewire.h>
#include <net/if_arp.h>
+#include <net/if_types.h>
#ifdef __DragonFly__
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
@@ -170,6 +171,9 @@ fwip_attach(device_t dev)
fwip = ((struct fwip_softc *)device_get_softc(dev));
unit = device_get_unit(dev);
+ ifp = fwip->fw_softc.fwip_ifp = if_alloc(IFT_IEEE1394);
+ if (ifp == NULL)
+ return (ENOSPC);
bzero(fwip, sizeof(struct fwip_softc));
/* XXX */
@@ -188,7 +192,7 @@ fwip_attach(device_t dev)
/*
* Encode our hardware the way that arp likes it.
*/
- hwaddr = &fwip->fw_softc.fwcom.fc_hwaddr;
+ hwaddr = &IFP2FWC(fwip->fw_softc.fwip_ifp)->fc_hwaddr;
hwaddr->sender_unique_ID_hi = htonl(fwip->fd.fc->eui.hi);
hwaddr->sender_unique_ID_lo = htonl(fwip->fd.fc->eui.lo);
hwaddr->sender_max_rec = fwip->fd.fc->maxrec;
@@ -197,7 +201,6 @@ fwip_attach(device_t dev)
hwaddr->sender_unicast_FIFO_lo = htonl((uint32_t)INET_FIFO);
/* fill the rest and attach interface */
- ifp = &fwip->fwip_if;
ifp->if_softc = &fwip->fw_softc;
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
@@ -226,7 +229,7 @@ fwip_stop(struct fwip_softc *fwip)
{
struct firewire_comm *fc;
struct fw_xferq *xferq;
- struct ifnet *ifp = &fwip->fwip_if;
+ struct ifnet *ifp = fwip->fw_softc.fwip_ifp;
struct fw_xfer *xfer, *next;
int i;
@@ -279,7 +282,8 @@ fwip_detach(device_t dev)
s = splimp();
fwip_stop(fwip);
- firewire_ifdetach(&fwip->fwip_if);
+ firewire_ifdetach(fwip->fw_softc.fwip_ifp);
+ if_free(fwip->fw_softc.fwip_ifp);
splx(s);
return 0;
@@ -290,7 +294,7 @@ fwip_init(void *arg)
{
struct fwip_softc *fwip = ((struct fwip_eth_softc *)arg)->fwip;
struct firewire_comm *fc;
- struct ifnet *ifp = &fwip->fwip_if;
+ struct ifnet *ifp = fwip->fw_softc.fwip_ifp;
struct fw_xferq *xferq;
struct fw_xfer *xfer;
struct mbuf *m;
@@ -473,7 +477,7 @@ fwip_post_busreset(void *arg)
fwip->last_dest.hi = 0;
fwip->last_dest.lo = 0;
- firewire_busreset(&fwip->fwip_if);
+ firewire_busreset(fwip->fw_softc.fwip_ifp);
}
static void
@@ -486,7 +490,7 @@ fwip_output_callback(struct fw_xfer *xfer)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xfer->sc;
- ifp = &fwip->fwip_if;
+ ifp = fwip->fw_softc.fwip_ifp;
/* XXX error check */
FWIPDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
@@ -728,7 +732,7 @@ fwip_stream_input(struct fw_xferq *xferq)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xferq->sc;
- ifp = &fwip->fwip_if;
+ ifp = fwip->fw_softc.fwip_ifp;
#if 0
FWIP_POLL_REGISTER(fwip_poll, fwip, ifp);
#endif
@@ -858,7 +862,7 @@ fwip_unicast_input(struct fw_xfer *xfer)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xfer->sc;
- ifp = &fwip->fwip_if;
+ ifp = fwip->fw_softc.fwip_ifp;
m = xfer->mbuf;
xfer->mbuf = 0;
fp = &xfer->recv.hdr;
diff --git a/sys/dev/firewire/if_fwipvar.h b/sys/dev/firewire/if_fwipvar.h
index 0a9ef24..153ce94 100644
--- a/sys/dev/firewire/if_fwipvar.h
+++ b/sys/dev/firewire/if_fwipvar.h
@@ -55,9 +55,7 @@ struct fwip_softc {
struct crom_chunk spec6; /* specifier description IPv6 */
struct crom_chunk ver6; /* version description IPv6 */
struct fwip_eth_softc {
- /* XXX this must be the first for if_fwsubr.c */
- struct fw_com fwcom; /* firewire common data */
- #define fwip_if fw_softc.fwcom.fc_if
+ struct ifnet *fwip_ifp;
struct fwip_softc *fwip;
} fw_softc;
};
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
index 296bed4..23fff13 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -373,6 +373,7 @@ fxp_attach(device_t dev)
struct ifnet *ifp;
uint32_t val;
uint16_t data, myea[ETHER_ADDR_LEN / 2];
+ u_char eaddr[ETHER_ADDR_LEN];
int i, rid, m1, m2, prefer_iomap;
int error, s;
@@ -707,12 +708,12 @@ fxp_attach(device_t dev)
* Read MAC address.
*/
fxp_read_eeprom(sc, myea, 0, 3);
- sc->arpcom.ac_enaddr[0] = myea[0] & 0xff;
- sc->arpcom.ac_enaddr[1] = myea[0] >> 8;
- sc->arpcom.ac_enaddr[2] = myea[1] & 0xff;
- sc->arpcom.ac_enaddr[3] = myea[1] >> 8;
- sc->arpcom.ac_enaddr[4] = myea[2] & 0xff;
- sc->arpcom.ac_enaddr[5] = myea[2] >> 8;
+ eaddr[0] = myea[0] & 0xff;
+ eaddr[1] = myea[0] >> 8;
+ eaddr[2] = myea[1] & 0xff;
+ eaddr[3] = myea[1] >> 8;
+ eaddr[4] = myea[2] & 0xff;
+ eaddr[5] = myea[2] >> 8;
if (bootverbose) {
device_printf(dev, "PCI IDs: %04x %04x %04x %04x %04x\n",
pci_get_vendor(dev), pci_get_device(dev),
@@ -744,7 +745,12 @@ fxp_attach(device_t dev)
}
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ error = ENOSPC;
+ goto fail;
+ }
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_baudrate = 100000000;
ifp->if_init = fxp_init;
@@ -772,7 +778,7 @@ fxp_attach(device_t dev)
/*
* Attach the interface.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/*
* Tell the upper layer(s) we support long frames.
@@ -798,14 +804,15 @@ fxp_attach(device_t dev)
fxp_intr, sc, &sc->ih);
if (error) {
device_printf(dev, "could not setup irq\n");
- ether_ifdetach(&sc->arpcom.ac_if);
+ ether_ifdetach(sc->ifp);
goto fail;
}
fail:
splx(s);
- if (error)
+ if (error) {
fxp_release(sc);
+ }
return (error);
}
@@ -874,6 +881,8 @@ fxp_release(struct fxp_softc *sc)
bus_dma_tag_destroy(sc->cbl_tag);
if (sc->mcs_tag)
bus_dma_tag_destroy(sc->mcs_tag);
+ if (sc->ifp)
+ if_free(sc->ifp);
mtx_destroy(&sc->sc_mtx);
}
@@ -894,7 +903,8 @@ fxp_detach(device_t dev)
/*
* Close down routes etc.
*/
- ether_ifdetach(&sc->arpcom.ac_if);
+ ether_ifdetach(sc->ifp);
+ if_free(sc->ifp);
/*
* Stop DMA and drop transmit queue, but disable interrupts first.
@@ -965,7 +975,7 @@ static int
fxp_resume(device_t dev)
{
struct fxp_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
uint16_t pci_command;
int s;
@@ -1246,7 +1256,7 @@ fxp_encap(struct fxp_softc *sc, struct mbuf *m_head)
int chainlen, error, i, nseg;
FXP_LOCK_ASSERT(sc, MA_OWNED);
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
/*
* Get pointer to next available tx desc.
@@ -1492,7 +1502,7 @@ static void
fxp_intr(void *xsc)
{
struct fxp_softc *sc = xsc;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
uint8_t statack;
FXP_LOCK(sc);
@@ -1735,7 +1745,7 @@ static void
fxp_tick(void *xsc)
{
struct fxp_softc *sc = xsc;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
struct fxp_stats *sp = sc->fxp_stats;
int s;
@@ -1836,7 +1846,7 @@ fxp_tick(void *xsc)
static void
fxp_stop(struct fxp_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
struct fxp_tx *txp;
int i;
@@ -1920,7 +1930,7 @@ fxp_init(void *xsc)
static void
fxp_init_body(struct fxp_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
struct fxp_cb_config *cbp;
struct fxp_cb_ias *cb_ias;
struct fxp_cb_tx *tcbp;
@@ -2101,8 +2111,8 @@ fxp_init_body(struct fxp_softc *sc)
cb_ias->cb_status = 0;
cb_ias->cb_command = htole16(FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL);
cb_ias->link_addr = 0xffffffff;
- bcopy(sc->arpcom.ac_enaddr, cb_ias->macaddr,
- sizeof(sc->arpcom.ac_enaddr));
+ bcopy(IFP2ENADDR(sc->ifp), cb_ias->macaddr,
+ sizeof(IFP2ENADDR(sc->ifp)));
/*
* Start the IAS (Individual Address Setup) command/DMA.
@@ -2464,7 +2474,7 @@ static int
fxp_mc_addrs(struct fxp_softc *sc)
{
struct fxp_cb_mcs *mcsp = sc->mcsp;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
struct ifmultiaddr *ifma;
int nmcasts;
@@ -2509,7 +2519,7 @@ static void
fxp_mc_setup(struct fxp_softc *sc)
{
struct fxp_cb_mcs *mcsp = sc->mcsp;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
struct fxp_tx *txp;
int count;
diff --git a/sys/dev/fxp/if_fxpvar.h b/sys/dev/fxp/if_fxpvar.h
index d2cecea..15471ae 100644
--- a/sys/dev/fxp/if_fxpvar.h
+++ b/sys/dev/fxp/if_fxpvar.h
@@ -153,7 +153,7 @@ struct fxp_desc_list {
* for functional grouping.
*/
struct fxp_softc {
- struct arpcom arpcom; /* per-interface network data */
+ struct ifnet *ifp; /* per-interface network data */
struct resource *mem; /* resource descriptor for registers */
int rtp; /* register resource type */
int rgd; /* register descriptor in use */
@@ -222,5 +222,3 @@ struct fxp_softc {
bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
-
-#define sc_if arpcom.ac_if
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
index 6ec46bb..08a8b98 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <machine/bus.h>
@@ -124,11 +125,15 @@ int
gem_attach(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp;
struct mii_softc *child;
int i, error;
u_int32_t v;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
+
/* Make sure the chip is stopped. */
ifp->if_softc = sc;
gem_reset(sc);
@@ -137,7 +142,7 @@ gem_attach(sc)
BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, GEM_NSEGS,
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag);
if (error)
- return (error);
+ goto fail_ifnet;
error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXBSIZE,
@@ -301,7 +306,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, sc->sc_arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->sc_enaddr);
#if notyet
/*
@@ -346,6 +351,8 @@ fail_rtag:
bus_dma_tag_destroy(sc->sc_rdmatag);
fail_ptag:
bus_dma_tag_destroy(sc->sc_pdmatag);
+fail_ifnet:
+ if_free(ifp);
return (error);
}
@@ -353,10 +360,11 @@ void
gem_detach(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i;
ether_ifdetach(ifp);
+ if_free(ifp);
gem_stop(ifp, 1);
device_delete_child(sc->sc_dev, sc->sc_miibus);
@@ -385,7 +393,7 @@ void
gem_suspend(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
gem_stop(ifp, 0);
}
@@ -394,7 +402,7 @@ void
gem_resume(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
if (ifp->if_flags & IFF_UP)
gem_init(ifp);
@@ -847,7 +855,7 @@ gem_init(xsc)
void *xsc;
{
struct gem_softc *sc = (struct gem_softc *)xsc;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
int s;
@@ -866,7 +874,7 @@ gem_init(xsc)
*/
/* step 1 & 2. Reset the Ethernet Channel */
- gem_stop(&sc->sc_arpcom.ac_if, 0);
+ gem_stop(sc->sc_ifp, 0);
gem_reset(sc);
#ifdef GEM_DEBUG
CTR1(KTR_GEM, "%s: gem_init: restarting", device_get_name(sc->sc_dev));
@@ -1019,7 +1027,7 @@ gem_init_regs(sc)
{
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
- const u_char *laddr = sc->sc_arpcom.ac_enaddr;
+ const u_char *laddr = IFP2ENADDR(sc->sc_ifp);
u_int32_t v;
/* These regs are not cleared on reset */
@@ -1198,7 +1206,7 @@ static void
gem_tint(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t mac = sc->sc_h;
struct gem_txsoft *txs;
@@ -1342,7 +1350,7 @@ static void
gem_rint(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
struct gem_rxsoft *rxs;
@@ -1843,7 +1851,7 @@ static void
gem_setladrf(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ifmultiaddr *inm;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
@@ -1886,7 +1894,7 @@ gem_setladrf(sc)
/* Clear hash table */
memset(hash, 0, sizeof(hash));
- TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
if (inm->ifma_addr->sa_family != AF_LINK)
continue;
crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
diff --git a/sys/dev/gem/if_gem_pci.c b/sys/dev/gem/if_gem_pci.c
index 57c95c7..5347ee9 100644
--- a/sys/dev/gem/if_gem_pci.c
+++ b/sys/dev/gem/if_gem_pci.c
@@ -195,7 +195,7 @@ gem_pci_attach(dev)
sc->sc_h = rman_get_bushandle(gsc->gsc_sres);
/* All platform that this driver is used on must provide this. */
- OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
+ OF_getetheraddr(dev, sc->sc_enaddr);
/*
* call the main configure
diff --git a/sys/dev/gem/if_gemvar.h b/sys/dev/gem/if_gemvar.h
index 07d71e1..ed3eb7a 100644
--- a/sys/dev/gem/if_gemvar.h
+++ b/sys/dev/gem/if_gemvar.h
@@ -123,10 +123,11 @@ struct gem_rxsoft {
* Software state per device.
*/
struct gem_softc {
- struct arpcom sc_arpcom; /* arp common data */
+ struct ifnet *sc_ifp;
device_t sc_miibus;
struct mii_data *sc_mii; /* MII media control */
device_t sc_dev; /* generic device information */
+ u_char sc_enaddr[6];
struct callout sc_tick_ch; /* tick callout */
struct callout sc_rx_ch; /* delayed rx callout */
diff --git a/sys/dev/harp/if_harp.c b/sys/dev/harp/if_harp.c
index 7a03520..ca11138 100644
--- a/sys/dev/harp/if_harp.c
+++ b/sys/dev/harp/if_harp.c
@@ -354,7 +354,7 @@ harp_output(Cmn_unit *cu, Cmn_vcc *cv, KBuffer *m)
sc->cmn.cu_pif.pif_oerrors++;
cv->cv_connvc->cvc_vcc->vc_oerrors++;
if (cv->cv_connvc->cvc_vcc->vc_nif)
- cv->cv_connvc->cvc_vcc->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(cv->cv_connvc->cvc_vcc->vc_nif)->if_oerrors++;
return;
}
@@ -365,8 +365,8 @@ harp_output(Cmn_unit *cu, Cmn_vcc *cv, KBuffer *m)
cv->cv_connvc->cvc_vcc->vc_obytes += mlen;
if (cv->cv_connvc->cvc_vcc->vc_nif) {
cv->cv_connvc->cvc_vcc->vc_nif->nif_obytes += mlen;
- cv->cv_connvc->cvc_vcc->vc_nif->nif_if.if_obytes += mlen;
- cv->cv_connvc->cvc_vcc->vc_nif->nif_if.if_opackets++;
+ ANIF2IFP(cv->cv_connvc->cvc_vcc->vc_nif)->if_obytes += mlen;
+ ANIF2IFP(cv->cv_connvc->cvc_vcc->vc_nif)->if_opackets++;
}
}
@@ -592,8 +592,8 @@ harp_input(struct ifnet *ifp, struct mbuf **mp, struct atm_pseudohdr *ah,
vcc->cv_connvc->cvc_vcc->vc_ibytes += mlen;
if (vcc->cv_connvc->cvc_vcc->vc_nif) {
vcc->cv_connvc->cvc_vcc->vc_nif->nif_ibytes += mlen;
- vcc->cv_connvc->cvc_vcc->vc_nif->nif_if.if_ipackets++;
- vcc->cv_connvc->cvc_vcc->vc_nif->nif_if.if_ibytes += mlen;
+ ANIF2IFP(vcc->cv_connvc->cvc_vcc->vc_nif)->if_ipackets++;
+ ANIF2IFP(vcc->cv_connvc->cvc_vcc->vc_nif)->if_ibytes += mlen;
}
/* hand it off */
diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c
index e1f9128..8811b4e 100644
--- a/sys/dev/hatm/if_hatm.c
+++ b/sys/dev/hatm/if_hatm.c
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_media.h>
#include <net/if_atm.h>
+#include <net/if_types.h>
#include <net/route.h>
#ifdef ENABLE_BPF
#include <net/bpf.h>
@@ -217,13 +218,13 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem)
BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW,
NULL, NULL, &mem->tag);
if (error) {
- if_printf(&sc->ifatm.ifnet, "DMA tag create (%s)\n", what);
+ if_printf(sc->ifp, "DMA tag create (%s)\n", what);
return (error);
}
error = bus_dmamem_alloc(mem->tag, &mem->base, 0, &mem->map);
if (error) {
- if_printf(&sc->ifatm.ifnet, "DMA mem alloc (%s): %d\n",
+ if_printf(sc->ifp, "DMA mem alloc (%s): %d\n",
what, error);
bus_dma_tag_destroy(mem->tag);
mem->base = NULL;
@@ -233,7 +234,7 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem)
error = bus_dmamap_load(mem->tag, mem->map, mem->base, mem->size,
dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT);
if (error) {
- if_printf(&sc->ifatm.ifnet, "DMA map load (%s): %d\n",
+ if_printf(sc->ifp, "DMA map load (%s): %d\n",
what, error);
bus_dmamem_free(mem->tag, mem->base, mem->map);
bus_dma_tag_destroy(mem->tag);
@@ -316,11 +317,11 @@ hatm_destroy_smbufs(struct hatm_softc *sc)
h = (struct mbuf_chunk_hdr *) ((char *)pg +
b * pg->hdr.chunksize + pg->hdr.hdroff);
if (h->flags & MBUF_CARD)
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"%s -- mbuf page=%u card buf %u\n",
__func__, i, b);
if (h->flags & MBUF_USED)
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"%s -- mbuf page=%u used buf %u\n",
__func__, i, b);
}
@@ -353,7 +354,7 @@ hatm_destroy_tpds(struct hatm_softc *sc)
DBG(sc, ATTACH, ("releasing TPDs ..."));
if (sc->tpd_nfree != sc->tpd_total)
- if_printf(&sc->ifatm.ifnet, "%u tpds still in use from %u\n",
+ if_printf(sc->ifp, "%u tpds still in use from %u\n",
sc->tpd_total - sc->tpd_nfree, sc->tpd_total);
while ((t = SLIST_FIRST(&sc->tpd_free)) != NULL) {
SLIST_REMOVE_HEAD(&sc->tpd_free, link);
@@ -477,15 +478,15 @@ hatm_destroy(struct hatm_softc *sc)
if (sc->tx_tag != NULL)
if (bus_dma_tag_destroy(sc->tx_tag))
- if_printf(&sc->ifatm.ifnet, "mbuf DMA tag busy\n");
+ if_printf(sc->ifp, "mbuf DMA tag busy\n");
if (sc->mbuf_tag != NULL)
if (bus_dma_tag_destroy(sc->mbuf_tag))
- if_printf(&sc->ifatm.ifnet, "mbuf DMA tag busy\n");
+ if_printf(sc->ifp, "mbuf DMA tag busy\n");
if (sc->parent_tag != NULL)
if (bus_dma_tag_destroy(sc->parent_tag))
- if_printf(&sc->ifatm.ifnet, "parent DMA tag busy\n");
+ if_printf(sc->ifp, "parent DMA tag busy\n");
if (sc->memres != NULL)
bus_release_resource(sc->dev, SYS_RES_MEMORY,
@@ -514,7 +515,7 @@ hatm_reset(struct hatm_softc *sc)
while (((v = READ4(sc, HE_REGO_RESET_CNTL)) & HE_REGM_RESET_STATE) == 0) {
BARRIER_R(sc);
if (++count == 100) {
- if_printf(&sc->ifatm.ifnet, "reset failed\n");
+ if_printf(sc->ifp, "reset failed\n");
return (ENXIO);
}
DELAY(1000);
@@ -669,12 +670,12 @@ hatm_init_read_eeprom(struct hatm_softc *sc)
while (n > 0 && sc->rev[n-1] == ' ')
n--;
sc->rev[n] = '\0';
- sc->ifatm.mib.hw_version = sc->rev[0];
+ IFP2IFATM(sc->ifp)->mib.hw_version = sc->rev[0];
- sc->ifatm.mib.serial = hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 0) << 0;
- sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 1) << 8;
- sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 2) << 16;
- sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 3) << 24;
+ IFP2IFATM(sc->ifp)->mib.serial = hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 0) << 0;
+ IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 1) << 8;
+ IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 2) << 16;
+ IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 3) << 24;
v = hatm_read_prom_byte(sc, HE_EEPROM_MEDIA + 0) << 0;
v |= hatm_read_prom_byte(sc, HE_EEPROM_MEDIA + 1) << 8;
@@ -683,41 +684,41 @@ hatm_init_read_eeprom(struct hatm_softc *sc)
switch (v) {
case HE_MEDIA_UTP155:
- sc->ifatm.mib.media = IFM_ATM_UTP_155;
- sc->ifatm.mib.pcr = ATM_RATE_155M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
break;
case HE_MEDIA_MMF155:
- sc->ifatm.mib.media = IFM_ATM_MM_155;
- sc->ifatm.mib.pcr = ATM_RATE_155M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
break;
case HE_MEDIA_MMF622:
- sc->ifatm.mib.media = IFM_ATM_MM_622;
- sc->ifatm.mib.device = ATM_DEVICE_HE622;
- sc->ifatm.mib.pcr = ATM_RATE_622M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_622;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE622;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_622M;
sc->he622 = 1;
break;
case HE_MEDIA_SMF155:
- sc->ifatm.mib.media = IFM_ATM_SM_155;
- sc->ifatm.mib.pcr = ATM_RATE_155M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_155;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
break;
case HE_MEDIA_SMF622:
- sc->ifatm.mib.media = IFM_ATM_SM_622;
- sc->ifatm.mib.device = ATM_DEVICE_HE622;
- sc->ifatm.mib.pcr = ATM_RATE_622M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_622;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE622;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_622M;
sc->he622 = 1;
break;
}
- sc->ifatm.mib.esi[0] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 0);
- sc->ifatm.mib.esi[1] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 1);
- sc->ifatm.mib.esi[2] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 2);
- sc->ifatm.mib.esi[3] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 3);
- sc->ifatm.mib.esi[4] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 4);
- sc->ifatm.mib.esi[5] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 5);
+ IFP2IFATM(sc->ifp)->mib.esi[0] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 0);
+ IFP2IFATM(sc->ifp)->mib.esi[1] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 1);
+ IFP2IFATM(sc->ifp)->mib.esi[2] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 2);
+ IFP2IFATM(sc->ifp)->mib.esi[3] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 3);
+ IFP2IFATM(sc->ifp)->mib.esi[4] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 4);
+ IFP2IFATM(sc->ifp)->mib.esi[5] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 5);
}
/*
@@ -781,18 +782,18 @@ hatm_init_cm(struct hatm_softc *sc)
numbuffs = sc->r0_numbuffs + sc->r1_numbuffs + sc->tx_numbuffs;
rsra = 0;
- mlbm = ((rsra + sc->ifatm.mib.max_vccs * 8) + 0x7ff) & ~0x7ff;
+ mlbm = ((rsra + IFP2IFATM(sc->ifp)->mib.max_vccs * 8) + 0x7ff) & ~0x7ff;
rabr = ((mlbm + numbuffs * 2) + 0x7ff) & ~0x7ff;
- sc->rsrb = ((rabr + 2048) + (2 * sc->ifatm.mib.max_vccs - 1)) &
- ~(2 * sc->ifatm.mib.max_vccs - 1);
+ sc->rsrb = ((rabr + 2048) + (2 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1)) &
+ ~(2 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1);
tsra = 0;
- sc->tsrb = tsra + sc->ifatm.mib.max_vccs * 8;
- sc->tsrc = sc->tsrb + sc->ifatm.mib.max_vccs * 4;
- sc->tsrd = sc->tsrc + sc->ifatm.mib.max_vccs * 2;
- tabr = sc->tsrd + sc->ifatm.mib.max_vccs * 1;
- mtpd = ((tabr + 1024) + (16 * sc->ifatm.mib.max_vccs - 1)) &
- ~(16 * sc->ifatm.mib.max_vccs - 1);
+ sc->tsrb = tsra + IFP2IFATM(sc->ifp)->mib.max_vccs * 8;
+ sc->tsrc = sc->tsrb + IFP2IFATM(sc->ifp)->mib.max_vccs * 4;
+ sc->tsrd = sc->tsrc + IFP2IFATM(sc->ifp)->mib.max_vccs * 2;
+ tabr = sc->tsrd + IFP2IFATM(sc->ifp)->mib.max_vccs * 1;
+ mtpd = ((tabr + 1024) + (16 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1)) &
+ ~(16 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1);
DBG(sc, ATTACH, ("rsra=%x mlbm=%x rabr=%x rsrb=%x",
rsra, mlbm, rabr, sc->rsrb));
@@ -1322,7 +1323,7 @@ kenv_getuint(struct hatm_softc *sc, const char *var,
return (EINVAL);
}
if (bootverbose)
- if_printf(&sc->ifatm.ifnet, "%s=%u\n", full, u);
+ if_printf(sc->ifp, "%s=%u\n", full, u);
*ptr = u;
return (0);
}
@@ -1629,7 +1630,8 @@ hatm_detach(device_t dev)
}
mtx_unlock(&sc->mtx);
- atm_ifdetach(&sc->ifatm.ifnet);
+ atm_ifdetach(sc->ifp);
+ if_free(sc->ifp);
hatm_destroy(sc);
@@ -1650,18 +1652,25 @@ hatm_attach(device_t dev)
sc = device_get_softc(dev);
+ ifp = sc->ifp = if_alloc(IFT_ATM);
+ if (ifp == NULL) {
+ device_printf(dev, "could not if_alloc()\n");
+ error = ENOSPC;
+ goto failed;
+ }
+
sc->dev = dev;
- sc->ifatm.mib.device = ATM_DEVICE_HE155;
- sc->ifatm.mib.serial = 0;
- sc->ifatm.mib.hw_version = 0;
- sc->ifatm.mib.sw_version = 0;
- sc->ifatm.mib.vpi_bits = HE_CONFIG_VPI_BITS;
- sc->ifatm.mib.vci_bits = HE_CONFIG_VCI_BITS;
- sc->ifatm.mib.max_vpcs = 0;
- sc->ifatm.mib.max_vccs = HE_MAX_VCCS;
- sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE155;
+ IFP2IFATM(sc->ifp)->mib.serial = 0;
+ IFP2IFATM(sc->ifp)->mib.hw_version = 0;
+ IFP2IFATM(sc->ifp)->mib.sw_version = 0;
+ IFP2IFATM(sc->ifp)->mib.vpi_bits = HE_CONFIG_VPI_BITS;
+ IFP2IFATM(sc->ifp)->mib.vci_bits = HE_CONFIG_VCI_BITS;
+ IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
+ IFP2IFATM(sc->ifp)->mib.max_vccs = HE_MAX_VCCS;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
sc->he622 = 0;
- sc->ifatm.phy = &sc->utopia;
+ IFP2IFATM(sc->ifp)->phy = &sc->utopia;
SLIST_INIT(&sc->tpd_free);
@@ -1761,7 +1770,6 @@ hatm_attach(device_t dev)
goto failed;
}
- ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@@ -1922,7 +1930,7 @@ hatm_attach(device_t dev)
ifp->if_watchdog = NULL;
ifp->if_init = hatm_init;
- utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx,
+ utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&hatm_utopia_methods);
utopia_init_media(&sc->utopia);
@@ -1966,17 +1974,17 @@ hatm_initialize(struct hatm_softc *sc)
u_int cid;
static const u_int layout[2][7] = HE_CONFIG_MEM_LAYOUT;
- if (sc->ifatm.ifnet.if_flags & IFF_RUNNING)
+ if (sc->ifp->if_flags & IFF_RUNNING)
return;
hatm_init_bus_width(sc);
hatm_init_endianess(sc);
- if_printf(&sc->ifatm.ifnet, "%s, Rev. %s, S/N %u, "
+ if_printf(sc->ifp, "%s, Rev. %s, S/N %u, "
"MAC=%02x:%02x:%02x:%02x:%02x:%02x (%ubit PCI)\n",
- sc->prod_id, sc->rev, sc->ifatm.mib.serial,
- sc->ifatm.mib.esi[0], sc->ifatm.mib.esi[1], sc->ifatm.mib.esi[2],
- sc->ifatm.mib.esi[3], sc->ifatm.mib.esi[4], sc->ifatm.mib.esi[5],
+ sc->prod_id, sc->rev, IFP2IFATM(sc->ifp)->mib.serial,
+ IFP2IFATM(sc->ifp)->mib.esi[0], IFP2IFATM(sc->ifp)->mib.esi[1], IFP2IFATM(sc->ifp)->mib.esi[2],
+ IFP2IFATM(sc->ifp)->mib.esi[3], IFP2IFATM(sc->ifp)->mib.esi[4], IFP2IFATM(sc->ifp)->mib.esi[5],
sc->pci64 ? 64 : 32);
/*
@@ -2119,22 +2127,22 @@ hatm_initialize(struct hatm_softc *sc)
if (sc->he622) {
WRITE4(sc, HE_REGO_RCCONFIG,
(8 << HE_REGS_RCCONFIG_UTDELAY) |
- (sc->ifatm.mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
- (sc->ifatm.mib.vci_bits << HE_REGS_RCCONFIG_VC));
+ (IFP2IFATM(sc->ifp)->mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
+ (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_RCCONFIG_VC));
WRITE4(sc, HE_REGO_TXCONFIG,
(32 << HE_REGS_TXCONFIG_THRESH) |
- (sc->ifatm.mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
+ (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
(sc->tx_numbuffs << HE_REGS_TXCONFIG_LBFREE));
} else {
WRITE4(sc, HE_REGO_RCCONFIG,
(0 << HE_REGS_RCCONFIG_UTDELAY) |
HE_REGM_RCCONFIG_UT_MODE |
- (sc->ifatm.mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
- (sc->ifatm.mib.vci_bits << HE_REGS_RCCONFIG_VC));
+ (IFP2IFATM(sc->ifp)->mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
+ (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_RCCONFIG_VC));
WRITE4(sc, HE_REGO_TXCONFIG,
(32 << HE_REGS_TXCONFIG_THRESH) |
HE_REGM_TXCONFIG_UTMODE |
- (sc->ifatm.mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
+ (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
(sc->tx_numbuffs << HE_REGS_TXCONFIG_LBFREE));
}
@@ -2236,8 +2244,8 @@ hatm_initialize(struct hatm_softc *sc)
v |= HE_PCIM_CTL0_INIT_ENB | HE_PCIM_CTL0_INT_PROC_ENB;
pci_write_config(sc->dev, HE_PCIR_GEN_CNTL_0, v, 4);
- sc->ifatm.ifnet.if_flags |= IFF_RUNNING;
- sc->ifatm.ifnet.if_baudrate = 53 * 8 * sc->ifatm.mib.pcr;
+ sc->ifp->if_flags |= IFF_RUNNING;
+ sc->ifp->if_baudrate = 53 * 8 * IFP2IFATM(sc->ifp)->mib.pcr;
sc->utopia.flags &= ~UTP_FL_POLL_CARRIER;
@@ -2246,7 +2254,7 @@ hatm_initialize(struct hatm_softc *sc)
if (sc->vccs[cid] != NULL)
hatm_load_vc(sc, cid, 1);
- ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
+ ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
}
@@ -2264,11 +2272,11 @@ hatm_stop(struct hatm_softc *sc)
mtx_assert(&sc->mtx, MA_OWNED);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
+ if (!(sc->ifp->if_flags & IFF_RUNNING))
return;
- sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
+ sc->ifp->if_flags &= ~IFF_RUNNING;
- ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
+ ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
sc->utopia.flags |= UTP_FL_POLL_CARRIER;
diff --git a/sys/dev/hatm/if_hatm_intr.c b/sys/dev/hatm/if_hatm_intr.c
index 70bbde8..9ee64d7 100644
--- a/sys/dev/hatm/if_hatm_intr.c
+++ b/sys/dev/hatm/if_hatm_intr.c
@@ -203,7 +203,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group)
err = bus_dmamap_create(sc->mbuf_tag, 0, &pg->hdr.map);
if (err != 0) {
- if_printf(&sc->ifatm.ifnet, "%s -- bus_dmamap_create: %d\n",
+ if_printf(sc->ifp, "%s -- bus_dmamap_create: %d\n",
__func__, err);
free(pg, M_DEVBUF);
return;
@@ -211,7 +211,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group)
err = bus_dmamap_load(sc->mbuf_tag, pg->hdr.map, pg, MBUF_ALLOC_SIZE,
hatm_extbuf_helper, &pg->hdr.phys, BUS_DMA_NOWAIT);
if (err != 0) {
- if_printf(&sc->ifatm.ifnet, "%s -- mbuf mapping failed %d\n",
+ if_printf(sc->ifp, "%s -- mbuf mapping failed %d\n",
__func__, err);
bus_dmamap_destroy(sc->mbuf_tag, pg->hdr.map);
free(pg, M_DEVBUF);
@@ -329,7 +329,7 @@ he_intr_rbp(struct hatm_softc *sc, struct herbp *rbp, u_int large,
/* allocate the MBUF */
if ((m = m_getcl(M_DONTWAIT, MT_DATA,
M_PKTHDR)) == NULL) {
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"no mbuf clusters\n");
break;
}
@@ -534,7 +534,7 @@ hatm_intr(void *p)
/* if we have a stray interrupt with a non-initialized card,
* we cannot even lock before looking at the flag */
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
+ if (!(sc->ifp->if_flags & IFF_RUNNING))
return;
mtx_lock(&sc->mtx);
@@ -590,7 +590,7 @@ hatm_intr(void *p)
break;
default:
- if_printf(&sc->ifatm.ifnet, "bad INTR RBPS%u\n",
+ if_printf(sc->ifp, "bad INTR RBPS%u\n",
status & HE_REGM_IGROUP);
break;
}
@@ -605,7 +605,7 @@ hatm_intr(void *p)
break;
default:
- if_printf(&sc->ifatm.ifnet, "bad INTR RBPL%u\n",
+ if_printf(sc->ifp, "bad INTR RBPL%u\n",
status & HE_REGM_IGROUP);
break;
}
@@ -628,7 +628,7 @@ hatm_intr(void *p)
/* FALLTHRU */
default:
- if_printf(&sc->ifatm.ifnet, "bad INTR RBRQ%u\n",
+ if_printf(sc->ifp, "bad INTR RBRQ%u\n",
status & HE_REGM_IGROUP);
break;
}
@@ -651,7 +651,7 @@ hatm_intr(void *p)
/* FALLTHRU */
default:
- if_printf(&sc->ifatm.ifnet, "bad INTR RBRQT%u\n",
+ if_printf(sc->ifp, "bad INTR RBRQT%u\n",
status & HE_REGM_IGROUP);
break;
}
@@ -665,7 +665,7 @@ hatm_intr(void *p)
#if HE_REGM_ITYPE_UNKNOWN != HE_REGM_ITYPE_INVALID
case HE_REGM_ITYPE_UNKNOWN:
sc->istats.itype_unknown++;
- if_printf(&sc->ifatm.ifnet, "bad interrupt\n");
+ if_printf(sc->ifp, "bad interrupt\n");
break;
#endif
@@ -674,17 +674,17 @@ hatm_intr(void *p)
switch (status) {
case HE_REGM_ITYPE_PERR:
- if_printf(&sc->ifatm.ifnet, "parity error\n");
+ if_printf(sc->ifp, "parity error\n");
break;
case HE_REGM_ITYPE_ABORT:
- if_printf(&sc->ifatm.ifnet, "abort interrupt "
+ if_printf(sc->ifp, "abort interrupt "
"addr=0x%08x\n",
READ4(sc, HE_REGO_ABORT_ADDR));
break;
default:
- if_printf(&sc->ifatm.ifnet,
+ if_printf(sc->ifp,
"bad interrupt type %08x\n", status);
break;
}
@@ -706,7 +706,7 @@ hatm_intr(void *p)
break;
default:
- if_printf(&sc->ifatm.ifnet, "bad interrupt type %08x\n",
+ if_printf(sc->ifp, "bad interrupt type %08x\n",
status);
break;
}
diff --git a/sys/dev/hatm/if_hatm_ioctl.c b/sys/dev/hatm/if_hatm_ioctl.c
index c810279..cb8d652 100644
--- a/sys/dev/hatm/if_hatm_ioctl.c
+++ b/sys/dev/hatm/if_hatm_ioctl.c
@@ -116,7 +116,7 @@ hatm_open_vcc(struct hatm_softc *sc, struct atmio_openvcc *arg)
return (ENOMEM);
mtx_lock(&sc->mtx);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@@ -188,7 +188,7 @@ hatm_load_vc(struct hatm_softc *sc, u_int cid, int reopen)
/* inform management about non-NG and NG-PVCs */
if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
(vcc->param.flags & ATMIO_FLAG_PVC))
- ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->param.vpi,
+ ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->param.vpi,
vcc->param.vci, 1);
}
@@ -203,7 +203,7 @@ hatm_vcc_closed(struct hatm_softc *sc, u_int cid)
/* inform management about non-NG and NG-PVCs */
if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
(vcc->param.flags & ATMIO_FLAG_PVC))
- ATMEV_SEND_VCC_CHANGED(&sc->ifatm, HE_VPI(cid), HE_VCI(cid), 0);
+ ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), HE_VPI(cid), HE_VCI(cid), 0);
sc->open_vccs--;
uma_zfree(sc->vcc_zone, vcc);
@@ -230,7 +230,7 @@ hatm_close_vcc(struct hatm_softc *sc, struct atmio_closevcc *arg)
mtx_lock(&sc->mtx);
vcc = sc->vccs[cid];
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@@ -248,11 +248,11 @@ hatm_close_vcc(struct hatm_softc *sc, struct atmio_closevcc *arg)
if (vcc->param.flags & ATMIO_FLAG_ASYNC)
goto done;
- while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
+ while ((sc->ifp->if_flags & IFF_RUNNING) &&
(vcc->vflags & (HE_VCC_TX_CLOSING | HE_VCC_RX_CLOSING)))
cv_wait(&sc->vcc_cv, &sc->mtx);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
diff --git a/sys/dev/hatm/if_hatm_rx.c b/sys/dev/hatm/if_hatm_rx.c
index 1b3ee8d..bf6c7f7 100644
--- a/sys/dev/hatm/if_hatm_rx.c
+++ b/sys/dev/hatm/if_hatm_rx.c
@@ -130,7 +130,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
vcc->chain = vcc->last = m0;
vcc->last->m_next = NULL;
vcc->chain->m_pkthdr.len = m0->m_len;
- vcc->chain->m_pkthdr.rcvif = &sc->ifatm.ifnet;
+ vcc->chain->m_pkthdr.rcvif = sc->ifp;
} else {
sc->istats.rx_seg++;
@@ -148,7 +148,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
m_freem(vcc->chain);
vcc->chain = vcc->last = NULL;
sc->istats.crc_error++;
- sc->ifatm.ifnet.if_ierrors++;
+ sc->ifp->if_ierrors++;
return;
}
if (flags & HE_REGM_RBRQ_LEN_ERROR) {
@@ -156,7 +156,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
m_freem(vcc->chain);
vcc->chain = vcc->last = NULL;
sc->istats.len_error++;
- sc->ifatm.ifnet.if_ierrors++;
+ sc->ifp->if_ierrors++;
return;
}
@@ -229,7 +229,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
if (!(vcc->param.flags & ATMIO_FLAG_NG) &&
(vcc->param.aal == ATMIO_AAL_5) &&
(vcc->param.flags & ATM_PH_LLCSNAP))
- BPF_MTAP(&sc->ifatm.ifnet, m);
+ BPF_MTAP(sc->ifp, m);
#endif
vpi = HE_VPI(cid);
@@ -239,9 +239,9 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
ATM_PH_VPI(&aph) = vpi;
ATM_PH_SETVCI(&aph, vci);
- sc->ifatm.ifnet.if_ipackets++;
+ sc->ifp->if_ipackets++;
/* this is in if_atmsubr.c */
- /* sc->ifatm.ifnet.if_ibytes += len; */
+ /* sc->ifp->if_ibytes += len; */
vcc->ibytes += len;
vcc->ipackets++;
@@ -260,7 +260,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
}
#endif
- atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand);
+ atm_input(sc->ifp, &aph, m, vcc->rxhand);
return;
@@ -316,11 +316,11 @@ hatm_rx_vcc_close(struct hatm_softc *sc, u_int cid)
WRITE_RSR(sc, cid, 0, 0xf, 0);
v = READ4(sc, HE_REGO_RCCSTAT);
- while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
+ while ((sc->ifp->if_flags & IFF_RUNNING) &&
(READ4(sc, HE_REGO_RCCSTAT) & HE_REGM_RCCSTAT_PROG))
cv_timedwait(&sc->cv_rcclose, &sc->mtx, 1);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
+ if (!(sc->ifp->if_flags & IFF_RUNNING))
return;
WRITE_MBOX4(sc, HE_REGO_RCON_CLOSE, cid);
diff --git a/sys/dev/hatm/if_hatm_tx.c b/sys/dev/hatm/if_hatm_tx.c
index 3f0e66c..87baf09 100644
--- a/sys/dev/hatm/if_hatm_tx.c
+++ b/sys/dev/hatm/if_hatm_tx.c
@@ -193,7 +193,7 @@ hatm_queue_tpds(struct hatm_softc *sc, u_int count, struct tpd **list,
sc->tpdrq.size;
if (space <= count) {
- if_printf(&sc->ifatm.ifnet, "TPDRQ full\n");
+ if_printf(sc->ifp, "TPDRQ full\n");
sc->istats.tdprq_full++;
return (EBUSY);
}
@@ -262,7 +262,7 @@ hatm_load_txbuf(void *uarg, bus_dma_segment_t *segs, int nseg,
/* ensure, we have enough TPDs (remember, we already have one) */
tpds_needed = (nseg + 2) / 3;
if (HE_CONFIG_TPD_RESERVE + tpds_needed - 1 > arg->sc->tpd_nfree) {
- if_printf(&arg->sc->ifatm.ifnet, "%s -- out of TPDs (need %d, "
+ if_printf(arg->sc->ifp, "%s -- out of TPDs (need %d, "
"have %u)\n", __func__, tpds_needed - 1,
arg->sc->tpd_nfree + 1);
arg->error = 1;
@@ -277,7 +277,7 @@ hatm_load_txbuf(void *uarg, bus_dma_segment_t *segs, int nseg,
if (arg->vcc->ntpds + tpds_needed > arg->sc->max_tpd) {
arg->sc->istats.flow_closed++;
arg->vcc->vflags |= HE_VCC_FLOW_CTRL;
- ATMEV_SEND_FLOW_CONTROL(&arg->sc->ifatm,
+ ATMEV_SEND_FLOW_CONTROL(IFP2IFATM(arg->sc->ifp),
arg->vpi, arg->vci, 1);
arg->error = 1;
return;
@@ -451,7 +451,7 @@ hatm_start(struct ifnet *ifp)
if ((tpd = hatm_alloc_tpd(sc, M_NOWAIT)) == NULL) {
hatm_free_txmbuf(sc);
m_freem(m);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
tpd->cid = cid;
@@ -471,7 +471,7 @@ hatm_start(struct ifnet *ifp)
tpd->mbuf = NULL;
hatm_free_txmbuf(sc);
hatm_free_tpd(sc, tpd);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
arg.mbuf = m;
@@ -480,20 +480,20 @@ hatm_start(struct ifnet *ifp)
}
if (error != 0) {
- if_printf(&sc->ifatm.ifnet, "mbuf loaded error=%d\n",
+ if_printf(sc->ifp, "mbuf loaded error=%d\n",
error);
hatm_free_tpd(sc, tpd);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
if (arg.error) {
hatm_free_tpd(sc, tpd);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
arg.vcc->opackets++;
arg.vcc->obytes += len;
- sc->ifatm.ifnet.if_opackets++;
+ sc->ifp->if_opackets++;
}
mtx_unlock(&sc->mtx);
}
@@ -528,7 +528,7 @@ hatm_tx_complete(struct hatm_softc *sc, struct tpd *tpd, uint32_t flags)
if ((vcc->vflags & HE_VCC_FLOW_CTRL) &&
vcc->ntpds <= HE_CONFIG_TPD_FLOW_ENB) {
vcc->vflags &= ~HE_VCC_FLOW_CTRL;
- ATMEV_SEND_FLOW_CONTROL(&sc->ifatm,
+ ATMEV_SEND_FLOW_CONTROL(IFP2IFATM(sc->ifp),
HE_VPI(tpd->cid), HE_VCI(tpd->cid), 0);
}
}
@@ -569,13 +569,13 @@ hatm_tx_vcc_can_open(struct hatm_softc *sc, u_int cid, struct hevcc *vcc)
#if 0
v = READ_TSR(sc, cid, 4);
if(!(v & HE_REGM_TSR4_SESS_END)) {
- if_printf(&sc->ifatm.ifnet, "cid=%#x not closed (TSR4)\n", cid);
+ if_printf(sc->ifp, "cid=%#x not closed (TSR4)\n", cid);
return (EBUSY);
}
#endif
v = READ_TSR(sc, cid, 0);
if((v & HE_REGM_TSR0_CONN_STATE) != 0) {
- if_printf(&sc->ifatm.ifnet, "cid=%#x not closed (TSR0=%#x)\n",
+ if_printf(sc->ifp, "cid=%#x not closed (TSR0=%#x)\n",
cid, v);
return (EBUSY);
}
diff --git a/sys/dev/hatm/if_hatmvar.h b/sys/dev/hatm/if_hatmvar.h
index acddaa1..9edadc3 100644
--- a/sys/dev/hatm/if_hatmvar.h
+++ b/sys/dev/hatm/if_hatmvar.h
@@ -363,7 +363,7 @@ struct herg {
* Softc
*/
struct hatm_softc {
- struct ifatm ifatm; /* common ATM stuff */
+ struct ifnet *ifp;
struct mtx mtx; /* lock */
struct ifmedia media; /* media */
device_t dev; /* device */
diff --git a/sys/dev/hfa/fore_output.c b/sys/dev/hfa/fore_output.c
index d4ab4dd..3910186 100644
--- a/sys/dev/hfa/fore_output.c
+++ b/sys/dev/hfa/fore_output.c
@@ -131,7 +131,7 @@ fore_output(cup, cvp, m)
fup->fu_stats->st_drv.drv_xm_notact++;
vcp->vc_oerrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(vcp->vc_nif)->if_oerrors++;
KB_FREEALL(m);
return;
}
@@ -164,7 +164,7 @@ fore_output(cup, cvp, m)
fup->fu_pif.pif_oerrors++;
vcp->vc_oerrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(vcp->vc_nif)->if_oerrors++;
KB_FREEALL(m);
(void) splx(s);
return;
@@ -185,7 +185,7 @@ fore_output(cup, cvp, m)
*/
vcp->vc_oerrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(vcp->vc_nif)->if_oerrors++;
(void) splx(s);
return;
}
diff --git a/sys/dev/hfa/fore_receive.c b/sys/dev/hfa/fore_receive.c
index c07eee5..758f069 100644
--- a/sys/dev/hfa/fore_receive.c
+++ b/sys/dev/hfa/fore_receive.c
@@ -299,7 +299,7 @@ retry:
vcp = fvp->fv_connvc->cvc_vcc;
vcp->vc_ierrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_ierrors++;
+ ANIF2IFP(vcp->vc_nif)->if_ierrors++;
}
ATM_DEBUG1("fore receive error: hdr=0x%lx\n", hdr);
error = 1;
@@ -451,9 +451,9 @@ retry:
vcp->vc_ibytes += pdulen;
if (vcp->vc_nif) {
vcp->vc_nif->nif_ibytes += pdulen;
- vcp->vc_nif->nif_if.if_ipackets++;
+ ANIF2IFP(vcp->vc_nif)->if_ipackets++;
#if (defined(BSD) && (BSD >= 199103))
- vcp->vc_nif->nif_if.if_ibytes += pdulen;
+ ANIF2IFP(vcp->vc_nif)->if_ibytes += pdulen;
#endif
}
diff --git a/sys/dev/hfa/fore_transmit.c b/sys/dev/hfa/fore_transmit.c
index 84c9adf..e22f696 100644
--- a/sys/dev/hfa/fore_transmit.c
+++ b/sys/dev/hfa/fore_transmit.c
@@ -272,7 +272,7 @@ fore_xmit_drain(fup)
vcp = fvp->fv_connvc->cvc_vcc;
vcp->vc_oerrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(vcp->vc_nif)->if_oerrors++;
}
} else {
/*
@@ -288,9 +288,9 @@ fore_xmit_drain(fup)
vcp->vc_obytes += len;
if (vcp->vc_nif) {
vcp->vc_nif->nif_obytes += len;
- vcp->vc_nif->nif_if.if_opackets++;
+ ANIF2IFP(vcp->vc_nif)->if_opackets++;
#if (defined(BSD) && (BSD >= 199103))
- vcp->vc_nif->nif_if.if_obytes += len;
+ ANIF2IFP(vcp->vc_nif)->if_obytes += len;
#endif
}
}
diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c
index c5c66d5..d564bb4 100644
--- a/sys/dev/hme/if_hme.c
+++ b/sys/dev/hme/if_hme.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_vlan_var.h>
#include <netinet/in.h>
@@ -105,7 +106,7 @@ static int hme_ioctl(struct ifnet *, u_long, caddr_t);
static void hme_tick(void *);
static void hme_watchdog(struct ifnet *);
static void hme_init(void *);
-static void hme_init_locked(void *);
+static void hme_init_locked(struct hme_softc *);
static int hme_add_rxbuf(struct hme_softc *, unsigned int, int);
static int hme_meminit(struct hme_softc *);
static int hme_mac_bitflip(struct hme_softc *, u_int32_t, u_int32_t,
@@ -170,11 +171,15 @@ MODULE_DEPEND(hme, miibus, 1, 1, 1);
int
hme_config(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp;
struct mii_softc *child;
bus_size_t size;
int error, rdesc, tdesc, i;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
+
/*
* HME common initialization.
*
@@ -214,7 +219,7 @@ hme_config(struct hme_softc *sc)
BUS_SPACE_MAXADDR, NULL, NULL, size, HME_NTXDESC + HME_NRXDESC + 1,
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag);
if (error)
- return (error);
+ goto fail_ifnet;
error = bus_dma_tag_create(sc->sc_pdmatag, 2048, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
@@ -333,7 +338,7 @@ hme_config(struct hme_softc *sc)
}
/* Attach the interface. */
- ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->sc_enaddr);
/*
* Tell the upper layer(s) we support long frames/checksum offloads.
@@ -368,18 +373,21 @@ fail_ctag:
bus_dma_tag_destroy(sc->sc_cdmatag);
fail_ptag:
bus_dma_tag_destroy(sc->sc_pdmatag);
+fail_ifnet:
+ if_free(ifp);
return (error);
}
void
hme_detach(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i;
HME_LOCK_ASSERT(sc, MA_NOTOWNED);
ether_ifdetach(ifp);
+ if_free(ifp);
HME_LOCK(sc);
hme_stop(sc);
HME_UNLOCK(sc);
@@ -416,11 +424,11 @@ hme_suspend(struct hme_softc *sc)
void
hme_resume(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
HME_LOCK(sc);
if ((ifp->if_flags & IFF_UP) != 0)
- hme_init_locked(ifp);
+ hme_init_locked(sc);
HME_UNLOCK(sc);
}
@@ -682,10 +690,9 @@ hme_init(void *xsc)
}
static void
-hme_init_locked(void *xsc)
+hme_init_locked(struct hme_softc *sc)
{
- struct hme_softc *sc = (struct hme_softc *)xsc;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int8_t *ea;
u_int32_t n, v;
@@ -722,7 +729,7 @@ hme_init_locked(void *xsc)
HME_MAC_WRITE_4(sc, HME_MACI_TXSIZE, HME_MAX_FRAMESIZE);
/* Load station MAC address */
- ea = sc->sc_arpcom.ac_enaddr;
+ ea = IFP2ENADDR(sc->sc_ifp);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR0, (ea[0] << 8) | ea[1]);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR1, (ea[2] << 8) | ea[3]);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR2, (ea[4] << 8) | ea[5]);
@@ -1041,7 +1048,7 @@ fail:
static void
hme_read(struct hme_softc *sc, int ix, int len, u_int32_t flags)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct mbuf *m;
if (len <= sizeof(struct ether_header) ||
@@ -1139,7 +1146,7 @@ hme_start_locked(struct ifnet *ifp)
static void
hme_tint(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct hme_txdesc *htx;
unsigned int ri, txflags;
@@ -1282,7 +1289,7 @@ static void
hme_rint(struct hme_softc *sc)
{
caddr_t xdr = sc->sc_rb.rb_rxd;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
unsigned int ri, len;
int progress = 0;
u_int32_t flags;
@@ -1619,7 +1626,7 @@ hme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
static void
hme_setladrf(struct hme_softc *sc, int reenable)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ifmultiaddr *inm;
u_int32_t crc;
u_int32_t hash[4];
@@ -1672,7 +1679,7 @@ hme_setladrf(struct hme_softc *sc, int reenable)
* the word.
*/
- TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(inm, &sc->sc_ifp->if_multiaddrs, ifma_link) {
if (inm->ifma_addr->sa_family != AF_LINK)
continue;
crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
diff --git a/sys/dev/hme/if_hme_pci.c b/sys/dev/hme/if_hme_pci.c
index a2833f2..8d77846 100644
--- a/sys/dev/hme/if_hme_pci.c
+++ b/sys/dev/hme/if_hme_pci.c
@@ -222,7 +222,7 @@ hme_pci_attach(device_t dev)
&sc->sc_mifh);
#if defined(__powerpc__) || defined(__sparc64__)
- OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
+ OF_getetheraddr(dev, sc->sc_enaddr);
#else
/*
* Dig out VPD (vital product data) and read NA (network address).
@@ -329,7 +329,7 @@ hme_pci_attach(device_t dev)
error = ENXIO;
goto fail_rres;
}
- bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_arpcom.ac_enaddr,
+ bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_enaddr,
ETHER_ADDR_LEN);
fail_rres:
diff --git a/sys/dev/hme/if_hme_sbus.c b/sys/dev/hme/if_hme_sbus.c
index ff3bfe7..300abc1 100644
--- a/sys/dev/hme/if_hme_sbus.c
+++ b/sys/dev/hme/if_hme_sbus.c
@@ -247,7 +247,7 @@ hme_sbus_attach(device_t dev)
goto fail_mif_res;
}
- OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
+ OF_getetheraddr(dev, sc->sc_enaddr);
burst = sbus_get_burstsz(dev);
/* Translate into plain numerical format */
diff --git a/sys/dev/hme/if_hmevar.h b/sys/dev/hme/if_hmevar.h
index fe752b1..25b0552 100644
--- a/sys/dev/hme/if_hmevar.h
+++ b/sys/dev/hme/if_hmevar.h
@@ -108,11 +108,12 @@ struct hme_ring {
};
struct hme_softc {
- struct arpcom sc_arpcom;
+ struct ifnet *sc_ifp;
struct ifmedia sc_ifmedia;
device_t sc_dev;
device_t sc_miibus;
struct mii_data *sc_mii; /* MII media control */
+ u_char sc_enaddr[6];
struct callout sc_tick_ch; /* tick callout */
/* The following bus handles are to be provided by the bus front-end */
diff --git a/sys/dev/idt/idt.c b/sys/dev/idt/idt.c
index fbcd916..51b197b 100644
--- a/sys/dev/idt/idt.c
+++ b/sys/dev/idt/idt.c
@@ -1556,7 +1556,7 @@ idt_queue_put(CONNECTION * connection, struct mbuf * m)
return (1);
}
m->m_nextpkt = NULL;
- m->m_pkthdr.rcvif = (struct ifnet *) connection;
+ m->m_pkthdr.rcvif = (void *) connection;
s = splimp();
@@ -1599,7 +1599,7 @@ idt_queue_flush(CONNECTION * connection)
m0 = &txqueue->mget;
m1 = *m0;
while (m1 != NULL) {
- if (m1->m_pkthdr.rcvif == (struct ifnet *) connection) {
+ if (m1->m_pkthdr.rcvif == (void *) connection) {
*m0 = m1->m_nextpkt;
m_freem(m1);
m1 = *m0;
diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c
index 71845e9..febdc69 100644
--- a/sys/dev/ie/if_ie.c
+++ b/sys/dev/ie/if_ie.c
@@ -266,7 +266,11 @@ ie_attach(device_t dev)
int factor;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(sc->dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
sc->dev = dev;
sc->unit = device_get_unit(dev);
@@ -290,8 +294,10 @@ ie_attach(device_t dev)
sc->rframes = (volatile struct ie_recv_frame_desc **) malloc(allocsize,
M_DEVBUF,
M_NOWAIT);
- if (sc->rframes == NULL)
+ if (sc->rframes == NULL) {
+ if_free(ifp);
return (ENXIO);
+ }
sc->rbuffs =
(volatile struct ie_recv_buf_desc **)&sc->rframes[sc->nframes];
sc->cbuffs = (volatile u_char **)&sc->rbuffs[sc->nrxbufs];
@@ -319,7 +325,7 @@ ie_attach(device_t dev)
EVENTHANDLER_REGISTER(shutdown_post_sync, ee16_shutdown,
sc, SHUTDOWN_PRI_DEFAULT);
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
return (0);
}
@@ -417,9 +423,9 @@ ierint(struct ie_softc *sc)
status = sc->rframes[i]->ie_fd_status;
if ((status & IE_FD_COMPLETE) && (status & IE_FD_OK)) {
- sc->arpcom.ac_if.if_ipackets++;
+ sc->ifp->if_ipackets++;
if (!--timesthru) {
- sc->arpcom.ac_if.if_ierrors +=
+ sc->ifp->if_ierrors +=
sc->scb->ie_err_crc +
sc->scb->ie_err_align +
sc->scb->ie_err_resource +
@@ -459,32 +465,32 @@ ietint(struct ie_softc *sc)
int status;
int i;
- sc->arpcom.ac_if.if_timer = 0;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_timer = 0;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
for (i = 0; i < sc->xmit_count; i++) {
status = sc->xmit_cmds[i]->ie_xmit_status;
if (status & IE_XS_LATECOLL) {
printf("ie%d: late collision\n", sc->unit);
- sc->arpcom.ac_if.if_collisions++;
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_collisions++;
+ sc->ifp->if_oerrors++;
} else if (status & IE_XS_NOCARRIER) {
printf("ie%d: no carrier\n", sc->unit);
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
} else if (status & IE_XS_LOSTCTS) {
printf("ie%d: lost CTS\n", sc->unit);
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
} else if (status & IE_XS_UNDERRUN) {
printf("ie%d: DMA underrun\n", sc->unit);
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
} else if (status & IE_XS_EXCMAX) {
printf("ie%d: too many collisions\n", sc->unit);
- sc->arpcom.ac_if.if_collisions += 16;
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_collisions += 16;
+ sc->ifp->if_oerrors++;
} else {
- sc->arpcom.ac_if.if_opackets++;
- sc->arpcom.ac_if.if_collisions += status & IE_XS_MAXCOLL;
+ sc->ifp->if_opackets++;
+ sc->ifp->if_collisions += status & IE_XS_MAXCOLL;
}
}
sc->xmit_count = 0;
@@ -501,7 +507,7 @@ ietint(struct ie_softc *sc)
/* Wish I knew why this seems to be necessary... */
sc->xmit_cmds[0]->ie_xmit_status |= IE_STAT_COMPL;
- iestart(&sc->arpcom.ac_if);
+ iestart(sc->ifp);
return (0); /* shouldn't be necessary */
}
@@ -529,7 +535,7 @@ iernr(struct ie_softc *sc)
#endif
ie_ack(sc, IE_ST_WHENCE);
- sc->arpcom.ac_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
return (0);
}
@@ -593,7 +599,7 @@ check_eh(struct ie_softc *sc, struct ether_header *eh)
return (1);
/* Always accept packets directed at us */
- if (ether_equal(eh->ether_dhost, sc->arpcom.ac_enaddr))
+ if (ether_equal(eh->ether_dhost, IFP2ENADDR(sc->ifp)))
return (1);
/* Must have IFF_ALLMULTI but not IFF_PROMISC set. The chip is
@@ -678,7 +684,7 @@ ieget(struct ie_softc *sc, struct mbuf **mp)
*/
if (!check_eh(sc, &eh)) {
ie_drop_packet_buffer(sc);
- sc->arpcom.ac_if.if_ierrors--; /* just this case, it's not an
+ sc->ifp->if_ierrors--; /* just this case, it's not an
* error
*/
return (-1);
@@ -692,7 +698,7 @@ ieget(struct ie_softc *sc, struct mbuf **mp)
}
*mp = m;
- m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ m->m_pkthdr.rcvif = sc->ifp;
m->m_len = MHLEN;
resid = m->m_pkthdr.len = totlen;
top = 0;
@@ -827,7 +833,7 @@ nextbuf:
static void
ie_readframe(struct ie_softc *sc, int num/* frame number to read */)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ie_recv_frame_desc rfd;
struct mbuf *m = 0;
#ifdef DEBUG
@@ -849,7 +855,7 @@ ie_readframe(struct ie_softc *sc, int num/* frame number to read */)
if (rfd.ie_fd_status & IE_FD_OK) {
if (ieget(sc, &m)) {
- sc->arpcom.ac_if.if_ierrors++; /* this counts as an
+ sc->ifp->if_ierrors++; /* this counts as an
* error */
return;
}
@@ -927,7 +933,7 @@ iestart(struct ifnet *ifp)
return;
do {
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
if (!m)
break;
@@ -947,7 +953,7 @@ iestart(struct ifnet *ifp)
* See if bpf is listening on this interface, let it see the
* packet before we commit it to the wire.
*/
- BPF_TAP(&sc->arpcom.ac_if,
+ BPF_TAP(sc->ifp,
(void *)sc->xmit_cbuffs[sc->xmit_count], len);
sc->xmit_buffs[sc->xmit_count]->ie_xmit_flags =
@@ -1231,8 +1237,8 @@ iereset(struct ie_softc *sc)
int s = splimp();
printf("ie%d: reset\n", sc->unit);
- sc->arpcom.ac_if.if_flags &= ~IFF_UP;
- ieioctl(&sc->arpcom.ac_if, SIOCSIFFLAGS, 0);
+ sc->ifp->if_flags &= ~IFF_UP;
+ ieioctl(sc->ifp, SIOCSIFFLAGS, 0);
/*
* Stop i82586 dead in its tracks.
@@ -1248,8 +1254,8 @@ iereset(struct ie_softc *sc)
panic("ie disappeared!");
#endif
- sc->arpcom.ac_if.if_flags |= IFF_UP;
- ieioctl(&sc->arpcom.ac_if, SIOCSIFFLAGS, 0);
+ sc->ifp->if_flags |= IFF_UP;
+ ieioctl(sc->ifp, SIOCSIFFLAGS, 0);
splx(s);
return;
@@ -1524,7 +1530,7 @@ ieinit(xsc)
cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST;
cmd->com.ie_cmd_link = 0xffff;
- bcopy((volatile char *)sc->arpcom.ac_enaddr,
+ bcopy((volatile char *)IFP2ENADDR(sc->ifp),
(volatile char *)&cmd->ie_address, sizeof cmd->ie_address);
scb->ie_command_list = MK_16(MEM(sc), cmd);
if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL)
@@ -1595,9 +1601,9 @@ ieinit(xsc)
ee16_interrupt_enable(sc);
ee16_chan_attn(sc);
}
- sc->arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels
+ sc->ifp->if_flags |= IFF_RUNNING; /* tell higher levels
* we're here */
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
start_receiver(sc);
@@ -1670,14 +1676,14 @@ ie_mc_reset(struct ie_softc *sc)
* Step through the list of addresses.
*/
sc->mcast_count = 0;
- TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
/* XXX - this is broken... */
if (sc->mcast_count >= MAXMCAST) {
- sc->arpcom.ac_if.if_flags |= IFF_ALLMULTI;
- ieioctl(&sc->arpcom.ac_if, SIOCSIFFLAGS, (void *) 0);
+ sc->ifp->if_flags |= IFF_ALLMULTI;
+ ieioctl(sc->ifp, SIOCSIFFLAGS, (void *) 0);
goto setflag;
}
bcopy(LLADDR((struct sockaddr_dl *) ifma->ifma_addr),
@@ -1780,7 +1786,7 @@ ie_detach (device_t dev)
struct ifnet * ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (sc->hard_type == IE_EE16)
ee16_shutdown(sc, 0);
@@ -1788,6 +1794,7 @@ ie_detach (device_t dev)
ie_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
ie_release_resources(dev);
return (0);
diff --git a/sys/dev/ie/if_ie_isa.c b/sys/dev/ie/if_ie_isa.c
index 53ed256..564176f 100644
--- a/sys/dev/ie/if_ie_isa.c
+++ b/sys/dev/ie/if_ie_isa.c
@@ -259,7 +259,7 @@ ie_isa_3C507_attach (device_t dev)
goto bad;
}
- sl_read_ether(sc, sc->arpcom.ac_enaddr);
+ sl_read_ether(sc, sc->enaddr);
/* Clear the interrupt latch just in case. */
outb(PORT(sc) + IE507_ICTRL, 1);
@@ -526,14 +526,14 @@ ie_isa_ee16_attach (device_t dev)
* the softc for use by the 586 setup code.
*/
eaddrtemp = ie_ee16_hw_read_eeprom(PORT(sc), IEE16_EEPROM_ENET_HIGH);
- sc->arpcom.ac_enaddr[1] = eaddrtemp & 0xFF;
- sc->arpcom.ac_enaddr[0] = eaddrtemp >> 8;
+ sc->enaddr[1] = eaddrtemp & 0xFF;
+ sc->enaddr[0] = eaddrtemp >> 8;
eaddrtemp = ie_ee16_hw_read_eeprom(PORT(sc), IEE16_EEPROM_ENET_MID);
- sc->arpcom.ac_enaddr[3] = eaddrtemp & 0xFF;
- sc->arpcom.ac_enaddr[2] = eaddrtemp >> 8;
+ sc->enaddr[3] = eaddrtemp & 0xFF;
+ sc->enaddr[2] = eaddrtemp >> 8;
eaddrtemp = ie_ee16_hw_read_eeprom(PORT(sc), IEE16_EEPROM_ENET_LOW);
- sc->arpcom.ac_enaddr[5] = eaddrtemp & 0xFF;
- sc->arpcom.ac_enaddr[4] = eaddrtemp >> 8;
+ sc->enaddr[5] = eaddrtemp & 0xFF;
+ sc->enaddr[4] = eaddrtemp >> 8;
/* disable the board interrupts */
outb(PORT(sc) + IEE16_IRQ, sc->irq_encoded);
@@ -757,7 +757,7 @@ ie_isa_sl_attach (device_t dev)
case IE_STARLAN10:
case IE_SLFIBER:
case IE_NI5210:
- sl_read_ether(sc, sc->arpcom.ac_enaddr);
+ sl_read_ether(sc, sc->enaddr);
break;
default:
if (bootverbose)
diff --git a/sys/dev/ie/if_ievar.h b/sys/dev/ie/if_ievar.h
index a57b2d0..2d3851f 100644
--- a/sys/dev/ie/if_ievar.h
+++ b/sys/dev/ie/if_ievar.h
@@ -17,12 +17,13 @@ enum ie_hardware {
* Ethernet status, per interface.
*/
struct ie_softc {
- struct arpcom arpcom;
+ struct ifnet *ifp;
void (*ie_reset_586) (struct ie_softc *);
void (*ie_chan_attn) (struct ie_softc *);
enum ie_hardware hard_type;
int hard_vers;
int unit;
+ u_char enaddr[6];
device_t dev;
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 77eb9ee..a9e960c 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/route.h>
#include <net/bpf.h>
@@ -232,7 +233,7 @@ ndis_setmulti(sc)
int len, mclistsz, error;
uint8_t *mclist;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@@ -307,7 +308,7 @@ ndis_set_offload(sc)
struct ifnet *ifp;
int len, error;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return(EINVAL);
@@ -369,7 +370,7 @@ ndis_probe_offload(sc)
struct ifnet *ifp;
int len, error, dummy;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
len = sizeof(dummy);
error = ndis_get_info(sc, OID_TCP_TASK_OFFLOAD, &dummy, &len);
@@ -557,8 +558,6 @@ ndis_attach(dev)
len = sizeof(eaddr);
ndis_get_info(sc, OID_802_3_CURRENT_ADDRESS, &eaddr, &len);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
/*
* Figure out if we're allowed to use multipacket sends
* with this driver, and if so, how many.
@@ -613,7 +612,11 @@ ndis_attach(dev)
/* Check for task offload support. */
ndis_probe_offload(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -867,7 +870,7 @@ ndis_detach(dev)
KASSERT(mtx_initialized(&sc->ndis_mtx),
("ndis mutex not initialized"));
NDIS_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
ifp->if_flags &= ~IFF_UP;
if (device_is_attached(dev)) {
@@ -879,6 +882,8 @@ ndis_detach(dev)
ether_ifdetach(ifp);
} else
NDIS_UNLOCK(sc);
+ if (ifp != NULL)
+ if_free(ifp);
bus_generic_detach(dev);
@@ -945,7 +950,7 @@ ndis_suspend(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
#ifdef notdef
if (NDIS_INITIALIZED(sc))
@@ -963,7 +968,7 @@ ndis_resume(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (NDIS_INITIALIZED(sc))
ndis_init(sc);
@@ -1087,7 +1092,7 @@ ndis_rxeof_xfr(dpc, adapter, sysarg1, sysarg2)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
KeAcquireSpinLockAtDpcLevel(&block->nmb_lock);
@@ -1152,7 +1157,7 @@ ndis_rxeof_xfr_done(adapter, packet, status, len)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
m = packet->np_m0;
IoFreeMdl(packet->np_private.npp_head);
@@ -1205,7 +1210,7 @@ ndis_rxeof(adapter, packets, pktcnt)
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
for (i = 0; i < pktcnt; i++) {
p = packets[i];
@@ -1283,7 +1288,7 @@ ndis_txeof(adapter, packet, status)
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
m = packet->np_m0;
idx = packet->np_txidx;
@@ -1339,7 +1344,7 @@ ndis_linksts_done(adapter)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@@ -1372,7 +1377,7 @@ ndis_intr(arg)
ndis_miniport_interrupt *intr;
sc = arg;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
intr = sc->ndis_block->nmb_interrupt;
if (intr == NULL || sc->ndis_block->nmb_miniportadapterctx == NULL)
@@ -1450,8 +1455,8 @@ ndis_ticktask(w, xsc)
ndis_getstate_80211(sc);
NDIS_LOCK(sc);
#ifdef LINK_STATE_UP
- sc->arpcom.ac_if.if_link_state = LINK_STATE_UP;
- rt_ifmsg(&(sc->arpcom.ac_if));
+ sc->ifp->if_link_state = LINK_STATE_UP;
+ rt_ifmsg(sc->ifp);
#endif /* LINK_STATE_UP */
}
@@ -1459,8 +1464,8 @@ ndis_ticktask(w, xsc)
device_printf(sc->ndis_dev, "link down\n");
sc->ndis_link = 0;
#ifdef LINK_STATE_DOWN
- sc->arpcom.ac_if.if_link_state = LINK_STATE_DOWN;
- rt_ifmsg(&(sc->arpcom.ac_if));
+ sc->ifp->if_link_state = LINK_STATE_DOWN;
+ rt_ifmsg(sc->ifp);
#endif /* LINK_STATE_DOWN */
}
@@ -1665,7 +1670,7 @@ ndis_init(xsc)
void *xsc;
{
struct ndis_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int i, error;
/*
@@ -1824,7 +1829,7 @@ ndis_setstate_80211(sc)
struct ifnet *ifp;
ic = &sc->ic;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@@ -2125,7 +2130,7 @@ ndis_getstate_80211(sc)
struct ifnet *ifp;
ic = &sc->ic;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@@ -2986,7 +2991,7 @@ ndis_stop(sc)
{
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
untimeout(ndis_tick, sc, sc->ndis_stat_ch);
NDIS_LOCK(sc);
diff --git a/sys/dev/if_ndis/if_ndisvar.h b/sys/dev/if_ndis/if_ndisvar.h
index bcab175..5e28b7d 100644
--- a/sys/dev/if_ndis/if_ndisvar.h
+++ b/sys/dev/if_ndis/if_ndisvar.h
@@ -69,11 +69,8 @@ TAILQ_HEAD(nch, ndis_cfglist);
(x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
struct ndis_softc {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct ieee80211com ic; /* interface info */
-#ifdef notdef
- struct ieee80211com arpcom; /* interface info */
-#endif
struct ifmedia ifmedia; /* media info */
u_long ndis_hwassist;
uint32_t ndis_v4tx;
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c
index 1979cf1..d0068bb 100644
--- a/sys/dev/iicbus/if_ic.c
+++ b/sys/dev/iicbus/if_ic.c
@@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$");
#define ICMTU 1500 /* default mtu */
struct ic_softc {
- struct ifnet ic_if;
+ struct ifnet *ic_ifp;
u_char ic_addr; /* peer I2C address */
@@ -129,7 +129,12 @@ static int
icattach(device_t dev)
{
struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev);
- struct ifnet *ifp = &sc->ic_if;
+ struct ifnet *ifp;
+
+ ifp = sc->ic_ifp = if_alloc(IFT_PARA);
+ if (ifp == NULL) {
+ return (ENOSPC);
+ }
sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */
@@ -140,7 +145,6 @@ icattach(device_t dev)
IFF_NEEDSGIANT;
ifp->if_ioctl = icioctl;
ifp->if_output = icoutput;
- ifp->if_type = IFT_PARA;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
@@ -192,14 +196,14 @@ icioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if ((error = iicbus_request_bus(parent, icdev, IIC_WAIT|IIC_INTR)))
return (error);
- sc->ic_obuf = malloc(sc->ic_if.if_mtu + ICHDRLEN,
+ sc->ic_obuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN,
M_DEVBUF, M_WAITOK);
if (!sc->ic_obuf) {
iicbus_release_bus(parent, icdev);
return ENOBUFS;
}
- sc->ic_ifbuf = malloc(sc->ic_if.if_mtu + ICHDRLEN,
+ sc->ic_ifbuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN,
M_DEVBUF, M_WAITOK);
if (!sc->ic_ifbuf) {
iicbus_release_bus(parent, icdev);
@@ -245,11 +249,11 @@ icioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (optr)
free(optr,M_DEVBUF);
- sc->ic_if.if_mtu = ifr->ifr_mtu;
+ sc->ic_ifp->if_mtu = ifr->ifr_mtu;
break;
case SIOCGIFMTU:
- ifr->ifr_mtu = sc->ic_if.if_mtu;
+ ifr->ifr_mtu = sc->ic_ifp->if_mtu;
break;
case SIOCADDMULTI:
@@ -308,12 +312,12 @@ icintr (device_t dev, int event, char *ptr)
goto err;
len -= ICHDRLEN;
- sc->ic_if.if_ipackets ++;
- sc->ic_if.if_ibytes += len;
+ sc->ic_ifp->if_ipackets ++;
+ sc->ic_ifp->if_ibytes += len;
- BPF_TAP(&sc->ic_if, sc->ic_ifbuf, len + ICHDRLEN);
+ BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN);
- top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, &sc->ic_if, 0);
+ top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0);
if (top)
netisr_dispatch(NETISR_IP, top);
@@ -323,12 +327,12 @@ icintr (device_t dev, int event, char *ptr)
printf("ic%d: errors (%d)!\n", unit, sc->ic_iferrs);
sc->ic_iferrs = 0; /* reset error count */
- sc->ic_if.if_ierrors ++;
+ sc->ic_ifp->if_ierrors ++;
break;
case INTR_RECEIVE:
- if (sc->ic_xfercnt >= sc->ic_if.if_mtu+ICHDRLEN) {
+ if (sc->ic_xfercnt >= sc->ic_ifp->if_mtu+ICHDRLEN) {
sc->ic_iferrs ++;
} else {
@@ -389,7 +393,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m,
len = 0;
mm = m;
do {
- if (len + mm->m_len > sc->ic_if.if_mtu) {
+ if (len + mm->m_len > sc->ic_ifp->if_mtu) {
/* packet to large */
ifp->if_oerrors ++;
goto error;
diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c
index 37c1c97..11322af 100644
--- a/sys/dev/ipw/if_ipw.c
+++ b/sys/dev/ipw/if_ipw.c
@@ -214,7 +214,7 @@ static int
ipw_attach(device_t dev)
{
struct ipw_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_arp.ac_if;
+ struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
uint16_t val;
int error, i;
@@ -263,7 +263,11 @@ ipw_attach(device_t dev)
device_printf(dev, "could not allocate DMA resources\n");
goto fail;
}
-
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -387,8 +391,11 @@ ipw_detach(device_t dev)
IPW_UNLOCK(sc);
- bpfdetach(ifp);
+ if (ifp != NULL)
+ bpfdetach(ifp);
ieee80211_ifdetach(ic);
+ if (ifp != NULL)
+ if_free(ifp);
ipw_release(sc);
diff --git a/sys/dev/ipw/if_ipwvar.h b/sys/dev/ipw/if_ipwvar.h
index ae0e80a..e1f3ea1 100644
--- a/sys/dev/ipw/if_ipwvar.h
+++ b/sys/dev/ipw/if_ipwvar.h
@@ -84,7 +84,7 @@ struct ipw_tx_radiotap_header {
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct ipw_softc {
- struct arpcom sc_arp;
+ struct ifnet *sc_ifp;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c
index 8e219f5..d5a1bc4 100644
--- a/sys/dev/iwi/if_iwi.c
+++ b/sys/dev/iwi/if_iwi.c
@@ -229,7 +229,7 @@ static int
iwi_attach(device_t dev)
{
struct iwi_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_arp.ac_if;
+ struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
uint16_t val;
int error, i;
@@ -292,6 +292,12 @@ iwi_attach(device_t dev)
goto fail;
}
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ goto fail;
+ return (ENOSPC);
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -435,8 +441,11 @@ iwi_detach(device_t dev)
iwi_free_firmware(sc);
- bpfdetach(ifp);
+ if (ifp != NULL)
+ bpfdetach(ifp);
ieee80211_ifdetach(ic);
+ if (ifp != NULL)
+ if_free(ifp);
iwi_free_cmd_ring(sc, &sc->cmdq);
iwi_free_tx_ring(sc, &sc->txq);
diff --git a/sys/dev/iwi/if_iwivar.h b/sys/dev/iwi/if_iwivar.h
index 705aa1a..2e8bcab 100644
--- a/sys/dev/iwi/if_iwivar.h
+++ b/sys/dev/iwi/if_iwivar.h
@@ -109,7 +109,7 @@ struct iwi_rx_ring {
};
struct iwi_softc {
- struct arpcom sc_arp;
+ struct ifnet *sc_ifp;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
diff --git a/sys/dev/ixgb/if_ixgb.c b/sys/dev/ixgb/if_ixgb.c
index aa32d30..ec925b3 100644
--- a/sys/dev/ixgb/if_ixgb.c
+++ b/sys/dev/ixgb/if_ixgb.c
@@ -364,7 +364,7 @@ static int
ixgb_detach(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
INIT_DEBUGOUT("ixgb_detach: begin");
@@ -375,9 +375,10 @@ ixgb_detach(device_t dev)
IXGB_UNLOCK(adapter);
#if __FreeBSD_version < 500000
- ether_ifdetach(&adapter->interface_data.ac_if, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(adapter->ifp, ETHER_BPF_SUPPORTED);
#else
- ether_ifdetach(&adapter->interface_data.ac_if);
+ ether_ifdetach(adapter->ifp);
+ if_free(adapter->ifp);
#endif
ixgb_free_pci_resources(adapter);
@@ -631,7 +632,7 @@ ixgb_init_locked(struct adapter *adapter)
ixgb_stop(adapter);
/* Get the latest mac address, User can use a LAA */
- bcopy(adapter->interface_data.ac_enaddr, adapter->hw.curr_mac_addr,
+ bcopy(IFP2ENADDR(adapter->ifp), adapter->hw.curr_mac_addr,
IXGB_ETH_LENGTH_OF_ADDRESS);
/* Initialize the hardware */
@@ -666,7 +667,7 @@ ixgb_init_locked(struct adapter *adapter)
/* Don't loose promiscuous settings */
ixgb_set_promisc(adapter);
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -774,7 +775,7 @@ ixgb_intr(void *arg)
IXGB_LOCK(adapter);
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING) {
@@ -912,7 +913,7 @@ ixgb_encap(struct adapter * adapter, struct mbuf * m_head)
bus_dmamap_t map;
struct ixgb_buffer *tx_buffer = NULL;
struct ixgb_tx_desc *current_tx_desc = NULL;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
/*
* Force a cleanup if number of TX descriptors available hits the
@@ -1016,7 +1017,7 @@ ixgb_set_promisc(struct adapter * adapter)
{
u_int32_t reg_rctl;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
reg_rctl = IXGB_READ_REG(&adapter->hw, RCTL);
@@ -1060,7 +1061,7 @@ ixgb_set_multi(struct adapter * adapter)
u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * IXGB_ETH_LENGTH_OF_ADDRESS];
struct ifmultiaddr *ifma;
int mcnt = 0;
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
IOCTL_DEBUGOUT("ixgb_set_multi: begin");
@@ -1100,7 +1101,7 @@ ixgb_local_timer(void *arg)
{
struct ifnet *ifp;
struct adapter *adapter = arg;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
IXGB_LOCK(adapter);
@@ -1151,7 +1152,7 @@ ixgb_stop(void *arg)
{
struct ifnet *ifp;
struct adapter *adapter = arg;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
IXGB_LOCK_ASSERT(adapter);
@@ -1303,8 +1304,6 @@ ixgb_hardware_init(struct adapter * adapter)
adapter->unit);
return (EIO);
}
- bcopy(adapter->hw.curr_mac_addr, adapter->interface_data.ac_enaddr,
- IXGB_ETH_LENGTH_OF_ADDRESS);
return (0);
}
@@ -1320,7 +1319,9 @@ ixgb_setup_interface(device_t dev, struct adapter * adapter)
struct ifnet *ifp;
INIT_DEBUGOUT("ixgb_setup_interface: begin");
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ panic("%s: can not if_alloc()\n", device_get_nameunit(dev));
#if __FreeBSD_version >= 502000
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
#else
@@ -1340,7 +1341,7 @@ ixgb_setup_interface(device_t dev, struct adapter * adapter)
#if __FreeBSD_version < 500000
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#else
- ether_ifattach(ifp, adapter->interface_data.ac_enaddr);
+ ether_ifattach(ifp, adapter->hw.curr_mac_addr);
#endif
ifp->if_capabilities = IFCAP_HWCSUM;
@@ -1725,7 +1726,7 @@ ixgb_clean_transmit_interrupts(struct adapter * adapter)
* restart the timeout.
*/
if (num_avail > IXGB_TX_CLEANUP_THRESHOLD) {
- struct ifnet *ifp = &adapter->interface_data.ac_if;
+ struct ifnet *ifp = adapter->ifp;
ifp->if_flags &= ~IFF_OACTIVE;
if (num_avail == adapter->num_tx_desc)
@@ -1753,7 +1754,7 @@ ixgb_get_buf(int i, struct adapter * adapter,
bus_addr_t paddr;
int error;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
if (mp == NULL) {
@@ -1902,7 +1903,7 @@ ixgb_initialize_receive_unit(struct adapter * adapter)
struct ifnet *ifp;
u_int64_t rdba = adapter->rxdma.dma_paddr;
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
/*
* Make sure receives are disabled while setting up the descriptor
@@ -2054,7 +2055,7 @@ ixgb_process_receive_interrupts(struct adapter * adapter, int count)
IXGB_LOCK_ASSERT(adapter);
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
i = adapter->next_rx_desc_to_check;
next_to_use = adapter->next_rx_desc_to_use;
eop_desc = adapter->next_rx_desc_to_check;
@@ -2353,7 +2354,7 @@ ixgb_update_stats_counters(struct adapter * adapter)
adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
- ifp = &adapter->interface_data.ac_if;
+ ifp = adapter->ifp;
/* Fill out the OS statistics structure */
ifp->if_ipackets = adapter->stats.gprcl;
diff --git a/sys/dev/ixgb/if_ixgb.h b/sys/dev/ixgb/if_ixgb.h
index 0a8981b..5d7b4d9 100644
--- a/sys/dev/ixgb/if_ixgb.h
+++ b/sys/dev/ixgb/if_ixgb.h
@@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
#include <net/if_types.h>
@@ -270,7 +271,7 @@ typedef enum _XSUM_CONTEXT_T {
/* Our adapter structure */
struct adapter {
- struct arpcom interface_data;
+ struct ifnet *ifp;
struct adapter *next;
struct adapter *prev;
struct ixgb_hw hw;
diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c
index ace667d..9c7e65d 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -373,7 +374,7 @@ lge_setmulti(sc)
struct ifmultiaddr *ifma;
u_int32_t h = 0, hashes[2] = { 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
/* Make sure multicast hash table is enabled. */
CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_SETRST_CTL1|LGE_MODE1_RX_MCAST);
@@ -522,7 +523,6 @@ lge_attach(dev)
sc->lge_unit = unit;
callout_handle_init(&sc->lge_stat_ch);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
sc->lge_ldata = contigmalloc(sizeof(struct lge_list_data), M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
@@ -550,7 +550,18 @@ lge_attach(dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("lge%d: can not if_alloc()\n", sc->lge_unit);
+ contigfree(sc->lge_ldata,
+ sizeof(struct lge_list_data), M_DEVBUF);
+ lge_free_jumbo_mem(sc);
+ bus_teardown_intr(dev, sc->lge_irq, sc->lge_intrhand);
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->lge_irq);
+ bus_release_resource(dev, LGE_RES, LGE_RID, sc->lge_res);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -582,6 +593,7 @@ lge_attach(dev)
bus_teardown_intr(dev, sc->lge_irq, sc->lge_intrhand);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->lge_irq);
bus_release_resource(dev, LGE_RES, LGE_RID, sc->lge_res);
+ if_free(ifp);
error = ENXIO;
goto fail;
}
@@ -608,11 +620,12 @@ lge_detach(dev)
s = splimp();
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
lge_reset(sc);
lge_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
bus_generic_detach(dev);
device_delete_child(dev, sc->lge_miibus);
@@ -892,7 +905,7 @@ lge_rxeof(sc, cnt)
int c, i, total_len = 0;
u_int32_t rxsts, rxctl;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
/* Find out how many frames were processed. */
c = cnt;
@@ -970,7 +983,7 @@ lge_rxeoc(sc)
{
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
ifp->if_flags &= ~IFF_RUNNING;
lge_init(sc);
return;
@@ -989,7 +1002,7 @@ lge_txeof(sc)
struct ifnet *ifp;
u_int32_t idx, txdone;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
/* Clear the timeout timer. */
ifp->if_timer = 0;
@@ -1036,7 +1049,7 @@ lge_tick(xsc)
s = splimp();
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_SINGLE_COLL_PKTS);
ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL);
@@ -1075,7 +1088,7 @@ lge_intr(arg)
u_int32_t status;
sc = arg;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
/* Supress unwanted interrupts */
if (!(ifp->if_flags & IFF_UP)) {
@@ -1228,7 +1241,7 @@ lge_init(xsc)
void *xsc;
{
struct lge_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->lge_ifp;
struct mii_data *mii;
int s;
@@ -1246,8 +1259,8 @@ lge_init(xsc)
mii = device_get_softc(sc->lge_miibus);
/* Set MAC address */
- CSR_WRITE_4(sc, LGE_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- CSR_WRITE_4(sc, LGE_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
+ CSR_WRITE_4(sc, LGE_PAR0, *(u_int32_t *)(&IFP2ENADDR(sc->lge_ifp)[0]));
+ CSR_WRITE_4(sc, LGE_PAR1, *(u_int32_t *)(&IFP2ENADDR(sc->lge_ifp)[4]));
/* Init circular RX list. */
if (lge_list_rx_init(sc) == ENOBUFS) {
@@ -1501,7 +1514,7 @@ lge_stop(sc)
register int i;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->lge_ifp;
ifp->if_timer = 0;
untimeout(lge_tick, sc, sc->lge_stat_ch);
CSR_WRITE_4(sc, LGE_IMR, LGE_IMR_INTR_ENB);
diff --git a/sys/dev/lge/if_lgereg.h b/sys/dev/lge/if_lgereg.h
index 7c552b0..23f4da2 100644
--- a/sys/dev/lge/if_lgereg.h
+++ b/sys/dev/lge/if_lgereg.h
@@ -522,7 +522,7 @@ struct lge_ring_data {
};
struct lge_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *lge_ifp;
bus_space_handle_t lge_bhandle;
bus_space_tag_t lge_btag;
struct resource *lge_res;
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
index 111192d..7357c93 100644
--- a/sys/dev/lnc/if_lnc.c
+++ b/sys/dev/lnc/if_lnc.c
@@ -220,7 +220,7 @@ lnc_release_resources(device_t dev)
static __inline void
lnc_setladrf(struct lnc_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ifmultiaddr *ifma;
u_long index;
int i;
@@ -429,7 +429,7 @@ mbuf_packet(struct lnc_softc *sc, int start_of_packet, int pkt_len)
static void
lnc_rint(struct lnc_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct host_ring_entry *next, *start;
int start_of_packet;
struct mbuf *head;
@@ -578,7 +578,7 @@ lnc_rint(struct lnc_softc *sc)
* drop it if it is from myself.
*/
if (bcmp(eh->ether_shost,
- sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) == 0) {
+ IFP2ENADDR(sc->ifp), ETHER_ADDR_LEN) == 0) {
m_freem(head);
} else {
(*ifp->if_input)(ifp, head);
@@ -625,7 +625,7 @@ lnc_tint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if ((sc->trans_ring + sc->trans_next)->md->md1 & OWN) {
- log(LOG_ERR, "%s: Transmit interrupt with buffer still owned by controller -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Transmit interrupt with buffer still owned by controller -- Resetting\n", sc->ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -654,7 +654,7 @@ lnc_tint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if (!(next->md->md1 & STP)) {
- log(LOG_ERR, "%s: Transmit interrupt but not start of packet -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Transmit interrupt but not start of packet -- Resetting\n", sc->ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -671,7 +671,7 @@ lnc_tint(struct lnc_softc *sc)
} while (!(next->md->md1 & (STP | OWN | ENP | MDERR)));
if (next->md->md1 & STP) {
- log(LOG_ERR, "%s: Start of packet found before end of previous in transmit ring -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Start of packet found before end of previous in transmit ring -- Resetting\n", sc->ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -684,7 +684,7 @@ lnc_tint(struct lnc_softc *sc)
sc->trans_next = start_of_packet;
break;
} else {
- log(LOG_ERR, "%s: End of transmitted packet not found -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: End of transmitted packet not found -- Resetting\n", sc->ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -697,12 +697,12 @@ lnc_tint(struct lnc_softc *sc)
if (next->md->md1 & MDERR) {
LNCSTATS(terr)
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
if (next->md->md3 & LCOL) {
LNCSTATS(lcol)
- log(LOG_ERR, "%s: Transmit late collision -- Net error?\n", sc->arpcom.ac_if.if_xname);
- sc->arpcom.ac_if.if_collisions++;
+ log(LOG_ERR, "%s: Transmit late collision -- Net error?\n", sc->ifp->if_xname);
+ sc->ifp->if_collisions++;
/*
* Clear TBUFF since it's not valid when LCOL
* set
@@ -711,12 +711,12 @@ lnc_tint(struct lnc_softc *sc)
}
if (next->md->md3 & LCAR) {
LNCSTATS(lcar)
- log(LOG_ERR, "%s: Loss of carrier during transmit -- Net error?\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Loss of carrier during transmit -- Net error?\n", sc->ifp->if_xname);
}
if (next->md->md3 & RTRY) {
LNCSTATS(rtry)
- log(LOG_ERR, "%s: Transmit of packet failed after 16 attempts -- TDR = %d\n", sc->arpcom.ac_if.if_xname, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
- sc->arpcom.ac_if.if_collisions += 16;
+ log(LOG_ERR, "%s: Transmit of packet failed after 16 attempts -- TDR = %d\n", sc->ifp->if_xname, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
+ sc->ifp->if_collisions += 16;
/*
* Clear TBUFF since it's not valid when RTRY
* set
@@ -741,9 +741,9 @@ lnc_tint(struct lnc_softc *sc)
*/
if (next->md->md3 & TBUFF) {
LNCSTATS(tbuff)
- log(LOG_ERR, "%s: Transmit buffer error -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Transmit buffer error -- Resetting\n", sc->ifp->if_xname);
} else
- log(LOG_ERR, "%s: Transmit underflow error -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Transmit underflow error -- Resetting\n", sc->ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -760,11 +760,11 @@ lnc_tint(struct lnc_softc *sc)
* Don't bother checking for DEF, waste of time.
*/
- sc->arpcom.ac_if.if_opackets++;
+ sc->ifp->if_opackets++;
if (next->md->md1 & MORE) {
LNCSTATS(more)
- sc->arpcom.ac_if.if_collisions += 2;
+ sc->ifp->if_collisions += 2;
}
/*
@@ -777,7 +777,7 @@ lnc_tint(struct lnc_softc *sc)
if (next->md->md1 & ONE) {
LNCSTATS(one)
- sc->arpcom.ac_if.if_collisions++;
+ sc->ifp->if_collisions++;
}
INC_MD_PTR(sc->trans_next, sc->ntdre)
next = sc->trans_ring + sc->trans_next;
@@ -818,7 +818,7 @@ lnc_tint(struct lnc_softc *sc)
* more packets again.
*/
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
lookahead++;
@@ -838,6 +838,7 @@ lnc_attach_common(device_t dev)
lnc_softc_t *sc = device_get_softc(dev);
int i;
int skip;
+ u_char eaddr[6];
switch (sc->nic.ident) {
case BICC:
@@ -854,39 +855,54 @@ lnc_attach_common(device_t dev)
/* Fill in arpcom structure entries */
- sc->arpcom.ac_if.if_softc = sc;
- if_initname(&sc->arpcom.ac_if, device_get_name(dev),
+ sc->ifp = if_alloc(IFT_ETHER);
+ if (sc->ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (0);
+ }
+ sc->ifp->if_softc = sc;
+ if_initname(sc->ifp, device_get_name(dev),
device_get_unit(dev));
- sc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX |
+ sc->ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX |
IFF_MULTICAST | IFF_NEEDSGIANT;
- sc->arpcom.ac_if.if_timer = 0;
- sc->arpcom.ac_if.if_start = lnc_start;
- sc->arpcom.ac_if.if_ioctl = lnc_ioctl;
- sc->arpcom.ac_if.if_watchdog = lnc_watchdog;
- sc->arpcom.ac_if.if_init = lnc_init;
- IFQ_SET_MAXLEN(&sc->arpcom.ac_if.if_snd, IFQ_MAXLEN);
- sc->arpcom.ac_if.if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
- IFQ_SET_READY(&sc->arpcom.ac_if.if_snd);
+ sc->ifp->if_timer = 0;
+ sc->ifp->if_start = lnc_start;
+ sc->ifp->if_ioctl = lnc_ioctl;
+ sc->ifp->if_watchdog = lnc_watchdog;
+ sc->ifp->if_init = lnc_init;
+ IFQ_SET_MAXLEN(&sc->ifp->if_snd, IFQ_MAXLEN);
+ sc->ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
+ IFQ_SET_READY(&sc->ifp->if_snd);
/* Extract MAC address from PROM */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = lnc_inb(i * skip);
-
- /*
- * XXX -- should check return status of if_attach
- */
+ eaddr[i] = lnc_inb(i * skip);
- ether_ifattach(&sc->arpcom.ac_if, sc->arpcom.ac_enaddr);
+ ether_ifattach(sc->ifp, eaddr);
if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
- if_printf(&sc->arpcom.ac_if, "%s (%s)\n",
+ if_printf(sc->ifp, "%s (%s)\n",
nic_ident[sc->nic.ident], ic_ident[sc->nic.ic]);
else
- if_printf(&sc->arpcom.ac_if, "%s\n", ic_ident[sc->nic.ic]);
+ if_printf(sc->ifp, "%s\n", ic_ident[sc->nic.ic]);
return (1);
}
+int
+lnc_detach_common(device_t dev) {
+ lnc_softc_t *sc = device_get_softc(dev);
+ int s = splimp();
+
+ ether_ifdetach(sc->ifp);
+ if_free(sc->ifp);
+ lnc_stop(sc);
+ lnc_release_resources(dev);
+
+ splx(s);
+ return (0);
+}
+
static void
lnc_init(xsc)
void *xsc;
@@ -899,7 +915,7 @@ lnc_init(xsc)
s = splimp();
lnc_stop(sc);
- sc->arpcom.ac_if.if_flags |= IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; /* XXX??? */
+ sc->ifp->if_flags |= IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; /* XXX??? */
/*
* This sets up the memory area for the controller. Memory is set up for
@@ -988,7 +1004,7 @@ lnc_init(xsc)
sc->init_block->mode = sc->nic.mode;
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->init_block->padr[i] = sc->arpcom.ac_enaddr[i];
+ sc->init_block->padr[i] = IFP2ENADDR(sc->ifp)[i];
lnc_setladrf(sc);
@@ -1030,7 +1046,7 @@ lnc_init(xsc)
/* Let's see if it starts */
/*
printf("Enabling lnc interrupts\n");
- sc->arpcom.ac_if.if_timer = 10;
+ sc->ifp->if_timer = 10;
write_csr(sc, CSR0, INIT|INEA);
*/
@@ -1052,12 +1068,12 @@ printf("Enabling lnc interrupts\n");
* running and transmit any pending packets.
*/
write_csr(sc, CSR0, STRT | INEA);
- sc->arpcom.ac_if.if_flags |= IFF_RUNNING;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- lnc_start(&sc->arpcom.ac_if);
+ sc->ifp->if_flags |= IFF_RUNNING;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ lnc_start(sc->ifp);
} else
log(LOG_ERR, "%s: Initialisation failed\n",
- sc->arpcom.ac_if.if_xname);
+ sc->ifp->if_xname);
splx(s);
}
@@ -1110,32 +1126,32 @@ lncintr(void *arg)
#ifdef notyet
if (csr0 & IDON) {
printf("IDON\n");
- sc->arpcom.ac_if.if_timer = 0;
+ sc->ifp->if_timer = 0;
write_csr(sc, CSR0, STRT | INEA);
- sc->arpcom.ac_if.if_flags |= IFF_RUNNING;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- lnc_start(&sc->arpcom.ac_if);
+ sc->ifp->if_flags |= IFF_RUNNING;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ lnc_start(sc->ifp);
continue;
}
#endif
if (csr0 & ERR) {
if (csr0 & CERR) {
- log(LOG_ERR, "%s: Heartbeat error -- SQE test failed\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Heartbeat error -- SQE test failed\n", sc->ifp->if_xname);
LNCSTATS(cerr)
}
if (csr0 & BABL) {
- log(LOG_ERR, "%s: Babble error - more than 1519 bytes transmitted\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Babble error - more than 1519 bytes transmitted\n", sc->ifp->if_xname);
LNCSTATS(babl)
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
}
if (csr0 & MISS) {
- log(LOG_ERR, "%s: Missed packet -- no receive buffer\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Missed packet -- no receive buffer\n", sc->ifp->if_xname);
LNCSTATS(miss)
- sc->arpcom.ac_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
}
if (csr0 & MERR) {
- log(LOG_ERR, "%s: Memory error -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ log(LOG_ERR, "%s: Memory error -- Resetting\n", sc->ifp->if_xname);
LNCSTATS(merr)
lnc_reset(sc);
continue;
@@ -1147,7 +1163,7 @@ printf("IDON\n");
}
if (csr0 & TINT) {
LNCSTATS(tint)
- sc->arpcom.ac_if.if_timer = 0;
+ sc->ifp->if_timer = 0;
lnc_tint(sc);
}
@@ -1156,8 +1172,8 @@ printf("IDON\n");
* some more transmit packets.
*/
- if (!(sc->arpcom.ac_if.if_flags & IFF_OACTIVE))
- lnc_start(&sc->arpcom.ac_if);
+ if (!(sc->ifp->if_flags & IFF_OACTIVE))
+ lnc_start(sc->ifp);
}
}
@@ -1216,7 +1232,7 @@ lnc_start(struct ifnet *ifp)
do {
- IFQ_DRV_DEQUEUE(&sc->arpcom.ac_if.if_snd, head);
+ IFQ_DRV_DEQUEUE(&sc->ifp->if_snd, head);
if (!head)
return;
@@ -1340,7 +1356,7 @@ lnc_start(struct ifnet *ifp)
ifp->if_timer = 2;
- BPF_MTAP(&sc->arpcom.ac_if, head);
+ BPF_MTAP(sc->ifp, head);
if (sc->nic.mem_mode != DMA_MBUF)
m_freem(head);
@@ -1352,7 +1368,7 @@ lnc_start(struct ifnet *ifp)
* since we can't buffer any more packets.
*/
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
+ sc->ifp->if_flags |= IFF_OACTIVE;
LNCSTATS(trans_ring_full)
}
@@ -1437,7 +1453,7 @@ lnc_dump_state(struct lnc_softc *sc)
{
int i;
- printf("\nDriver/NIC [%s] state dump\n", sc->arpcom.ac_if.if_xname);
+ printf("\nDriver/NIC [%s] state dump\n", sc->ifp->if_xname);
printf("Memory access mode: %b\n", sc->nic.mem_mode, MEM_MODES);
printf("Host memory\n");
printf("-----------\n");
diff --git a/sys/dev/lnc/if_lnc_cbus.c b/sys/dev/lnc/if_lnc_cbus.c
index c52d56e..7132aff 100644
--- a/sys/dev/lnc/if_lnc_cbus.c
+++ b/sys/dev/lnc/if_lnc_cbus.c
@@ -261,9 +261,9 @@ lnc_isa_attach(device_t dev)
*
* Contec uses 00 80 4c ?? ?? ??
*/
- if (sc->arpcom.ac_enaddr[0] == (u_char)0x00 &&
- sc->arpcom.ac_enaddr[1] == (u_char)0x80 &&
- sc->arpcom.ac_enaddr[2] == (u_char)0x4c) {
+ if (IFP2ENADDR(sc->ifp)[0] == (u_char)0x00 &&
+ IFP2ENADDR(sc->ifp)[1] == (u_char)0x80 &&
+ IFP2ENADDR(sc->ifp)[2] == (u_char)0x4c) {
lnc_outw(sc->rap, MSRDA);
lnc_outw(CNET98S_IDP, 0x0006);
lnc_outw(sc->rap, MSWRA);
@@ -283,26 +283,11 @@ lnc_isa_attach(device_t dev)
return (0);
}
-static int
-lnc_isa_detach(device_t dev)
-{
- lnc_softc_t *sc = device_get_softc(dev);
- int s = splimp();
-
- ether_ifdetach(&sc->arpcom.ac_if);
- splx(s);
-
- lnc_stop(sc);
- lnc_release_resources(dev);
-
- return (0);
-}
-
static device_method_t lnc_isa_methods[] = {
/* DEVMETHOD(device_identify, lnc_isa_identify), */
DEVMETHOD(device_probe, lnc_isa_probe),
DEVMETHOD(device_attach, lnc_isa_attach),
- DEVMETHOD(device_detach, lnc_isa_detach),
+ DEVMETHOD(device_detach, lnc_detach_common),
#ifdef notyet
DEVMETHOD(device_suspend, lnc_isa_suspend),
DEVMETHOD(device_resume, lnc_isa_resume),
diff --git a/sys/dev/lnc/if_lnc_isa.c b/sys/dev/lnc/if_lnc_isa.c
index f53fd46..ac0cf97 100644
--- a/sys/dev/lnc/if_lnc_isa.c
+++ b/sys/dev/lnc/if_lnc_isa.c
@@ -254,26 +254,11 @@ lnc_isa_attach(device_t dev)
return (0);
}
-static int
-lnc_isa_detach(device_t dev)
-{
- lnc_softc_t *sc = device_get_softc(dev);
- int s = splimp();
-
- ether_ifdetach(&sc->arpcom.ac_if);
- splx(s);
-
- lnc_stop(sc);
- lnc_release_resources(dev);
-
- return (0);
-}
-
static device_method_t lnc_isa_methods[] = {
/* DEVMETHOD(device_identify, lnc_isa_identify), */
DEVMETHOD(device_probe, lnc_isa_probe),
DEVMETHOD(device_attach, lnc_isa_attach),
- DEVMETHOD(device_detach, lnc_isa_detach),
+ DEVMETHOD(device_detach, lnc_detach_common),
#ifdef notyet
DEVMETHOD(device_suspend, lnc_isa_suspend),
DEVMETHOD(device_resume, lnc_isa_resume),
diff --git a/sys/dev/lnc/if_lnc_pci.c b/sys/dev/lnc/if_lnc_pci.c
index 9de7c9e..f221d28 100644
--- a/sys/dev/lnc/if_lnc_pci.c
+++ b/sys/dev/lnc/if_lnc_pci.c
@@ -190,31 +190,10 @@ lnc_pci_attach(device_t dev)
return (0);
}
-static int
-lnc_pci_detach(device_t dev)
-{
- lnc_softc_t *sc = device_get_softc(dev);
- int s = splimp();
-
- ether_ifdetach(&sc->arpcom.ac_if);
-
- lnc_stop(sc);
- bus_teardown_intr(dev, sc->irqres, sc->intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irqres);
- bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(0), sc->portres);
-
- bus_dmamap_unload(sc->dmat, sc->dmamap);
- bus_dmamem_free(sc->dmat, sc->recv_ring, sc->dmamap);
- bus_dma_tag_destroy(sc->dmat);
-
- splx(s);
- return (0);
-}
-
static device_method_t lnc_pci_methods[] = {
DEVMETHOD(device_probe, lnc_pci_probe),
DEVMETHOD(device_attach, lnc_pci_attach),
- DEVMETHOD(device_detach, lnc_pci_detach),
+ DEVMETHOD(device_detach, lnc_detach_common),
#ifdef notyet
DEVMETHOD(device_suspend, lnc_pci_suspend),
DEVMETHOD(device_resume, lnc_pci_resume),
diff --git a/sys/dev/lnc/if_lncvar.h b/sys/dev/lnc/if_lncvar.h
index 8c76738..a34d83e 100644
--- a/sys/dev/lnc/if_lncvar.h
+++ b/sys/dev/lnc/if_lncvar.h
@@ -199,7 +199,7 @@ typedef struct lnc_softc {
void *intrhand;
bus_dma_tag_t dmat;
bus_dmamap_t dmamap;
- struct arpcom arpcom; /* see ../../net/if_arp.h */
+ struct ifnet *ifp;
struct nic_info nic; /* NIC specific info */
int nrdre;
struct host_ring_entry *recv_ring; /* start of alloc'd mem */
@@ -255,6 +255,7 @@ struct host_ring_entry {
extern int lance_probe(struct lnc_softc *);
extern void lnc_release_resources(device_t);
extern int lnc_attach_common(device_t);
+extern int lnc_detach_common(device_t);
extern void lnc_stop(struct lnc_softc *);
extern void write_csr(struct lnc_softc *, u_short, u_short);
diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c
index 20b57e8..d1a4f4c 100644
--- a/sys/dev/my/if_my.c
+++ b/sys/dev/my/if_my.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_dl.h>
#include <net/bpf.h>
@@ -326,7 +327,7 @@ my_setmulti(struct my_softc * sc)
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
rxfilt = CSR_READ_4(sc, MY_TCRRCR);
@@ -405,7 +406,7 @@ my_autoneg_mii(struct my_softc * sc, int flag, int verbose)
MY_LOCK(sc);
ifm = &sc->ifmedia;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
ifm->ifm_media = IFM_ETHER | IFM_AUTO;
@@ -570,7 +571,7 @@ my_getmode_mii(struct my_softc * sc)
struct ifnet *ifp;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
bmsr = my_phy_readreg(sc, PHY_BMSR);
if (bootverbose)
printf("my%d: PHY status word: %x\n", sc->my_unit, bmsr);
@@ -668,7 +669,7 @@ my_setmode_mii(struct my_softc * sc, int media)
struct ifnet *ifp;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
/*
* If an autoneg session is in progress, stop it.
*/
@@ -823,12 +824,6 @@ my_attach(device_t dev)
s = splimp();
sc = device_get_softc(dev);
unit = device_get_unit(dev);
- if (sc == NULL) {
- printf("my%d: no memory for softc struct!\n", unit);
- error = ENXIO;
- goto fail;
-
- }
bzero(sc, sizeof(struct my_softc));
mtx_init(&sc->my_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
@@ -931,7 +926,6 @@ my_attach(device_t dev)
eaddr[i] = CSR_READ_1(sc, MY_PAR0 + i);
sc->my_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
sc->my_ldata_ptr = malloc(sizeof(struct my_list_data) + 8,
M_DEVBUF, M_NOWAIT);
@@ -954,7 +948,12 @@ my_attach(device_t dev)
sc->my_ldata = (struct my_list_data *) roundptr;
bzero(sc->my_ldata, sizeof(struct my_list_data));
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1032,6 +1031,8 @@ my_attach(device_t dev)
fail:
MY_UNLOCK(sc);
mtx_destroy(&sc->my_mtx);
+ if (sc->my_ldata_ptr != NULL)
+ free(sc->my_ldata_ptr, M_DEVBUF);
splx(s);
return (error);
}
@@ -1046,8 +1047,9 @@ my_detach(device_t dev)
s = splimp();
sc = device_get_softc(dev);
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
ether_ifdetach(ifp);
+ if_free(ifp);
my_stop(sc);
#if 0
@@ -1180,7 +1182,7 @@ my_rxeof(struct my_softc * sc)
u_int32_t rxstat;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
while (!((rxstat = sc->my_cdata.my_rx_head->my_ptr->my_status)
& MY_OWNByNIC)) {
cur_rx = sc->my_cdata.my_rx_head;
@@ -1232,7 +1234,7 @@ my_rxeof(struct my_softc * sc)
if (ifp->if_bpf) {
BPF_MTAP(ifp, m);
if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
+ (bcmp(eh->ether_dhost, IFP2ENADDR(sc->my_ifp),
ETHER_ADDR_LEN) &&
(eh->ether_dhost[0] & 1) == 0)) {
m_freem(m);
@@ -1260,7 +1262,7 @@ my_txeof(struct my_softc * sc)
struct ifnet *ifp;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
/* Clear the timeout timer. */
ifp->if_timer = 0;
if (sc->my_cdata.my_tx_head == NULL) {
@@ -1315,7 +1317,7 @@ my_txeoc(struct my_softc * sc)
struct ifnet *ifp;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
ifp->if_timer = 0;
if (sc->my_cdata.my_tx_head == NULL) {
ifp->if_flags &= ~IFF_OACTIVE;
@@ -1342,7 +1344,7 @@ my_intr(void *arg)
sc = arg;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
if (!(ifp->if_flags & IFF_UP)) {
MY_UNLOCK(sc);
return;
@@ -1536,7 +1538,7 @@ static void
my_init(void *xsc)
{
struct my_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->my_ifp;
int s;
u_int16_t phy_bmcr = 0;
@@ -1788,7 +1790,7 @@ my_stop(struct my_softc * sc)
struct ifnet *ifp;
MY_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->my_ifp;
ifp->if_timer = 0;
MY_CLRBIT(sc, MY_TCRRCR, (MY_RE | MY_TE));
diff --git a/sys/dev/my/if_myreg.h b/sys/dev/my/if_myreg.h
index 9d889d1..9c39700 100644
--- a/sys/dev/my/if_myreg.h
+++ b/sys/dev/my/if_myreg.h
@@ -350,7 +350,7 @@ struct my_type {
#define MY_FLAG_DELAYTIMEO 3
struct my_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *my_ifp;
struct ifmedia ifmedia; /* media info */
bus_space_handle_t my_bhandle;
bus_space_tag_t my_btag;
diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c
index f480cb5..43cd378 100644
--- a/sys/dev/nge/if_nge.c
+++ b/sys/dev/nge/if_nge.c
@@ -672,7 +672,7 @@ nge_setmulti(sc)
int bit, index;
NGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
NGE_CLRBIT(sc, NGE_RXFILT_CTL,
@@ -834,8 +834,8 @@ nge_attach(dev)
nge_read_eeprom(sc, (caddr_t)&eaddr[0], NGE_EE_NODEADDR + 2, 1, 0);
sc->nge_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ /* XXX: leaked on error */
sc->nge_ldata = contigmalloc(sizeof(struct nge_list_data), M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
@@ -846,9 +846,15 @@ nge_attach(dev)
error = ENXIO;
goto fail;
}
- bzero(sc->nge_ldata, sizeof(struct nge_list_data));
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("nge%d: can not if_alloc()\n", unit);
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->nge_irq);
+ bus_release_resource(dev, NGE_RES, NGE_RID, sc->nge_res);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -924,6 +930,7 @@ nge_attach(dev)
error = bus_setup_intr(dev, sc->nge_irq, INTR_TYPE_NET | INTR_MPSAFE,
nge_intr, sc, &sc->nge_intrhand);
if (error) {
+ /* XXX: resource leaks */
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->nge_irq);
bus_release_resource(dev, NGE_RES, NGE_RID, sc->nge_res);
printf("nge%d: couldn't set up irq\n", unit);
@@ -944,13 +951,14 @@ nge_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
NGE_LOCK(sc);
nge_reset(sc);
nge_stop(sc);
NGE_UNLOCK(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
bus_generic_detach(dev);
if (!sc->nge_tbi) {
@@ -1106,7 +1114,7 @@ nge_rxeof(sc)
u_int32_t rxstat;
NGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
i = sc->nge_cdata.nge_rx_prod;
while(NGE_OWNDESC(&sc->nge_ldata->nge_rx_list[i])) {
@@ -1247,7 +1255,7 @@ nge_txeof(sc)
u_int32_t idx;
NGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
/*
* Go through our tx list and free mbufs for those
@@ -1317,7 +1325,7 @@ nge_tick_locked(sc)
struct ifnet *ifp;
NGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
if (sc->nge_tbi) {
if (!sc->nge_link) {
@@ -1416,7 +1424,7 @@ nge_intr(arg)
u_int32_t status;
sc = arg;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
NGE_LOCK(sc);
#ifdef DEVICE_POLLING
@@ -1563,7 +1571,7 @@ nge_encap(sc, m_head, txidx)
NGE_TXEXTSTS_UDPCSUM;
}
- mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m_head);
+ mtag = VLAN_OUTPUT_TAG(sc->nge_ifp, m_head);
if (mtag != NULL) {
sc->nge_ldata->nge_tx_list[cur].nge_extsts |=
(NGE_TXEXTSTS_VLANPKT|htons(VLAN_TAG_VALUE(mtag)));
@@ -1661,7 +1669,7 @@ static void
nge_init_locked(sc)
struct nge_softc *sc;
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->nge_ifp;
struct mii_data *mii;
NGE_LOCK_ASSERT(sc);
@@ -1683,13 +1691,13 @@ nge_init_locked(sc)
/* Set MAC address */
CSR_WRITE_4(sc, NGE_RXFILT_CTL, NGE_FILTADDR_PAR0);
CSR_WRITE_4(sc, NGE_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
+ ((u_int16_t *)IFP2ENADDR(sc->nge_ifp))[0]);
CSR_WRITE_4(sc, NGE_RXFILT_CTL, NGE_FILTADDR_PAR1);
CSR_WRITE_4(sc, NGE_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
+ ((u_int16_t *)IFP2ENADDR(sc->nge_ifp))[1]);
CSR_WRITE_4(sc, NGE_RXFILT_CTL, NGE_FILTADDR_PAR2);
CSR_WRITE_4(sc, NGE_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ ((u_int16_t *)IFP2ENADDR(sc->nge_ifp))[2]);
/* Init circular RX list. */
if (nge_list_rx_init(sc) == ENOBUFS) {
@@ -2083,7 +2091,7 @@ nge_stop(sc)
struct mii_data *mii;
NGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->nge_ifp;
ifp->if_timer = 0;
if (sc->nge_tbi) {
mii = NULL;
diff --git a/sys/dev/nge/if_ngereg.h b/sys/dev/nge/if_ngereg.h
index 5a46aa6..91b191f 100644
--- a/sys/dev/nge/if_ngereg.h
+++ b/sys/dev/nge/if_ngereg.h
@@ -648,7 +648,7 @@ struct nge_ring_data {
};
struct nge_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *nge_ifp;
bus_space_handle_t nge_bhandle;
bus_space_tag_t nge_btag;
struct resource *nge_res;
diff --git a/sys/dev/nve/if_nve.c b/sys/dev/nve/if_nve.c
index 0963a6b..131502d 100644
--- a/sys/dev/nve/if_nve.c
+++ b/sys/dev/nve/if_nve.c
@@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
#include <net/if_vlan_var.h>
@@ -487,10 +488,9 @@ nve_attach(device_t dev)
eaddr[i] = sc->original_mac_addr[5 - i];
}
sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, eaddr);
- bcopy(eaddr, (char *)&sc->sc_macaddr, ETHER_ADDR_LEN);
/* Display ethernet address ,... */
- device_printf(dev, "Ethernet address %6D\n", sc->sc_macaddr, ":");
+ device_printf(dev, "Ethernet address %6D\n", eaddr, ":");
DEBUGOUT(NVE_DEBUG_INIT, "nve: do mii_phy_probe\n");
@@ -501,7 +501,12 @@ nve_attach(device_t dev)
goto fail;
}
/* Setup interface parameters */
- ifp = &sc->sc_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, "nve", unit);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -517,7 +522,7 @@ nve_attach(device_t dev)
ifp->if_capabilities |= IFCAP_VLAN_MTU;
/* Attach to OS's managers. */
- ether_ifattach(ifp, sc->sc_macaddr);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->stat_ch);
/* Activate our interrupt handler. - attach last to avoid lock */
@@ -548,11 +553,12 @@ nve_detach(device_t dev)
DEBUGOUT(NVE_DEBUG_DEINIT, "nve: nve_detach - entry\n");
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (device_is_attached(dev)) {
nve_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->miibus)
@@ -610,7 +616,7 @@ nve_init(void *xsc)
NVE_LOCK(sc);
DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init - entry (%d)\n", sc->linkup);
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
/* Do nothing if already running */
if (ifp->if_flags & IFF_RUNNING)
@@ -633,7 +639,7 @@ nve_init(void *xsc)
goto fail;
}
/* Set the MAC address */
- sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, sc->sc_macaddr);
+ sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, IFP2ENADDR(sc->ifp));
sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
sc->hwapi->pfnStart(sc->hwapi->pADCX);
@@ -665,7 +671,7 @@ nve_stop(struct nve_softc *sc)
DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_stop - entry\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
ifp->if_timer = 0;
/* Cancel tick timer */
@@ -1010,7 +1016,7 @@ static void
nve_intr(void *arg)
{
struct nve_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
DEBUGOUT(NVE_DEBUG_INTERRUPT, "nve: nve_intr - entry\n");
@@ -1028,7 +1034,7 @@ nve_intr(void *arg)
/* If no pending packets we don't need a timeout */
if (sc->pending_txs == 0)
- sc->sc_if.if_timer = 0;
+ sc->ifp->if_timer = 0;
DEBUGOUT(NVE_DEBUG_INTERRUPT, "nve: nve_intr - exit\n");
@@ -1049,7 +1055,7 @@ nve_setmulti(struct nve_softc *sc)
DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_setmulti - entry\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
/* Initialize filter */
hwfilter.ulFilterFlags = 0;
@@ -1146,7 +1152,7 @@ nve_tick(void *xsc)
NVE_LOCK(sc);
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
nve_update_stats(sc);
mii = device_get_softc(sc->miibus);
@@ -1168,7 +1174,7 @@ nve_tick(void *xsc)
static void
nve_update_stats(struct nve_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
ADAPTER_STATS stats;
NVE_LOCK(sc);
@@ -1466,7 +1472,7 @@ nve_ospackettx(PNV_VOID ctx, PNV_VOID id, NV_UINT32 success)
DEBUGOUT(NVE_DEBUG_API, "nve: nve_ospackettx\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
buf = &desc->buf;
sc->pending_txs--;
@@ -1481,7 +1487,7 @@ nve_ospackettx(PNV_VOID ctx, PNV_VOID id, NV_UINT32 success)
/* Send more packets if we have them */
if (sc->pending_txs < TX_RING_SIZE)
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
if (ifp->if_snd.ifq_head != NULL && sc->pending_txs < TX_RING_SIZE)
nve_ifstart(ifp);
@@ -1508,7 +1514,7 @@ nve_ospacketrx(PNV_VOID ctx, PNV_VOID data, NV_UINT32 success, NV_UINT8 *newbuf,
DEBUGOUT(NVE_DEBUG_API, "nve: nve_ospacketrx\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
readdata = (ADAPTER_READ_DATA *) data;
desc = readdata->pvID;
@@ -1557,7 +1563,7 @@ nve_oslinkchg(PNV_VOID ctx, NV_SINT32 enabled)
DEBUGOUT(NVE_DEBUG_API, "nve: nve_oslinkchg\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
if (enabled)
ifp->if_flags |= IFF_UP;
diff --git a/sys/dev/nve/if_nvereg.h b/sys/dev/nve/if_nvereg.h
index 320e298..ae6303e 100644
--- a/sys/dev/nve/if_nvereg.h
+++ b/sys/dev/nve/if_nvereg.h
@@ -108,7 +108,7 @@ struct nve_tx_desc {
};
struct nve_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *ifp; /* interface info */
struct resource *res;
struct resource *irq;
@@ -165,9 +165,6 @@ struct nve_type {
char *name;
};
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-
#define NVE_LOCK(_sc) mtx_lock(&(_sc)->mtx)
#define NVE_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
#define NVE_OSLOCK(_sc) mtx_lock_spin(&(_sc)->osmtx)
diff --git a/sys/dev/owi/if_owi.c b/sys/dev/owi/if_owi.c
index b33da65..18a1e09 100644
--- a/sys/dev/owi/if_owi.c
+++ b/sys/dev/owi/if_owi.c
@@ -154,7 +154,7 @@ owi_generic_detach(dev)
sc = device_get_softc(dev);
WI_LOCK(sc, s);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (sc->wi_gone) {
device_printf(dev, "already unloaded\n");
@@ -191,7 +191,13 @@ owi_generic_attach(device_t dev)
/* XXX maybe we need the splimp stuff here XXX */
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ owi_free(dev);
+ return (ENOSPC);
+ }
error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
wi_intr, sc, &sc->wi_intrhand);
@@ -223,8 +229,6 @@ owi_generic_attach(device_t dev)
owi_free(dev);
return (error);
}
- bcopy((char *)&mac.wi_mac_addr,
- (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
owi_get_id(sc);
@@ -379,7 +383,7 @@ owi_generic_attach(device_t dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, mac.wi_mac_addr);
callout_handle_init(&sc->wi_stat_ch);
WI_UNLOCK(sc, s);
@@ -448,7 +452,7 @@ wi_rxeof(sc)
WI_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
id = CSR_READ_2(sc, WI_RX_FID);
@@ -662,7 +666,7 @@ wi_txeof(sc, status)
{
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
ifp->if_timer = 0;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -684,7 +688,7 @@ wi_inquire(xsc)
int s;
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
sc->wi_stat_ch = timeout(wi_inquire, sc, hz * 60);
@@ -710,7 +714,7 @@ wi_update_stats(sc)
int len, i;
u_int16_t t;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
id = CSR_READ_2(sc, WI_INFO_FID);
@@ -763,7 +767,7 @@ wi_intr(xsc)
WI_LOCK(sc, s);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (sc->wi_gone || !(ifp->if_flags & IFF_UP)) {
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
@@ -1197,7 +1201,7 @@ wi_setmulti(sc)
struct ifmultiaddr *ifma;
struct wi_ltv_mcast mcast;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
bzero((char *)&mcast, sizeof(mcast));
@@ -1237,13 +1241,13 @@ wi_setdef(sc, wreq)
struct ifaddr *ifa;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
switch(wreq->wi_type) {
case WI_RID_MAC_NODE:
ifa = ifaddr_byindex(ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)&wreq->wi_val, (char *)&sc->arpcom.ac_enaddr,
+ bcopy((char *)&wreq->wi_val, (char *)&IFP2ENADDR(sc->ifp),
ETHER_ADDR_LEN);
bcopy((char *)&wreq->wi_val, LLADDR(sdl), ETHER_ADDR_LEN);
break;
@@ -1686,7 +1690,7 @@ wi_init(xsc)
void *xsc;
{
struct wi_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct wi_ltv_macaddr mac;
int id = 0;
int s;
@@ -1748,7 +1752,7 @@ wi_init(xsc)
/* Set our MAC address. */
mac.wi_len = 4;
mac.wi_type = WI_RID_MAC_NODE;
- bcopy((char *)&sc->arpcom.ac_enaddr,
+ bcopy((char *)&IFP2ENADDR(sc->ifp),
(char *)&mac.wi_mac_addr, ETHER_ADDR_LEN);
wi_write_record(sc, (struct wi_ltv_gen *)&mac);
@@ -1909,7 +1913,7 @@ owi_stop(sc)
return;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
/*
* If the card is gone and the memory port isn't mapped, we will
@@ -2015,6 +2019,11 @@ owi_free(dev)
sc->mem = NULL;
}
+ if (sc->ifp != NULL) {
+ if_free(sc->ifp);
+ sc->ifp = NULL;
+ }
+
return;
}
diff --git a/sys/dev/owi/if_wivar.h b/sys/dev/owi/if_wivar.h
index a439949..dfdb6ea 100644
--- a/sys/dev/owi/if_wivar.h
+++ b/sys/dev/owi/if_wivar.h
@@ -58,7 +58,7 @@
#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */
struct wi_softc {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct ifmedia ifmedia;
device_t dev;
int wi_unit;
diff --git a/sys/dev/patm/if_patm.c b/sys/dev/patm/if_patm.c
index ac01b95..0c8cf46 100644
--- a/sys/dev/patm/if_patm.c
+++ b/sys/dev/patm/if_patm.c
@@ -204,7 +204,7 @@ patm_initialize(struct patm_softc *sc)
patm_debug(sc, ATTACH, "go...");
sc->utopia.flags &= ~UTP_FL_POLL_CARRIER;
- sc->ifatm.ifnet.if_flags |= IFF_RUNNING;
+ sc->ifp->if_flags |= IFF_RUNNING;
/* enable interrupts, Tx and Rx paths */
cfg |= IDT_CFG_RXPTH | IDT_CFG_RXIIMM | IDT_CFG_RAWIE | IDT_CFG_RQFIE |
@@ -216,7 +216,7 @@ patm_initialize(struct patm_softc *sc)
if (sc->vccs[i] != NULL)
patm_load_vc(sc, sc->vccs[i], 1);
- ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
+ ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
}
@@ -245,7 +245,7 @@ patm_stop(struct patm_softc *sc)
struct patm_txmap *map;
struct patm_scd *scd;
- sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
+ sc->ifp->if_flags &= ~IFF_RUNNING;
sc->utopia.flags |= UTP_FL_POLL_CARRIER;
patm_reset(sc);
@@ -335,7 +335,7 @@ patm_stop(struct patm_softc *sc)
/* reset raw cell queue */
sc->rawh = NULL;
- ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
+ ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
}
@@ -397,7 +397,7 @@ patm_tst_init(struct patm_softc *sc)
sc->tst_free = sc->mmap->tst_size - 1;
sc->tst_reserve = sc->tst_free * PATM_TST_RESERVE / 100;
- sc->bwrem = sc->ifatm.mib.pcr;
+ sc->bwrem = IFP2IFATM(sc->ifp)->mib.pcr;
}
/*
diff --git a/sys/dev/patm/if_patm_attach.c b/sys/dev/patm/if_patm_attach.c
index 283d18b..1b4e0c2 100644
--- a/sys/dev/patm/if_patm_attach.c
+++ b/sys/dev/patm/if_patm_attach.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_atm.h>
#include <net/route.h>
#ifdef ENABLE_BPF
@@ -177,18 +178,22 @@ patm_attach(device_t dev)
#ifdef IATM_DEBUG
sc->debug = IATM_DEBUG;
#endif
- sc->ifatm.mib.device = ATM_DEVICE_IDTABR25;
- sc->ifatm.mib.serial = 0;
- sc->ifatm.mib.hw_version = 0;
- sc->ifatm.mib.sw_version = 0;
- sc->ifatm.mib.vpi_bits = PATM_VPI_BITS;
- sc->ifatm.mib.vci_bits = 0; /* set below */;
- sc->ifatm.mib.max_vpcs = 0;
- sc->ifatm.mib.max_vccs = 0; /* set below */
- sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
- sc->ifatm.phy = &sc->utopia;
-
- ifp = &sc->ifatm.ifnet;
+ ifp = sc->ifp = if_alloc(IFT_ATM);
+ if (ifp == NULL) {
+ return (ENOSPC);
+ }
+
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_IDTABR25;
+ IFP2IFATM(sc->ifp)->mib.serial = 0;
+ IFP2IFATM(sc->ifp)->mib.hw_version = 0;
+ IFP2IFATM(sc->ifp)->mib.sw_version = 0;
+ IFP2IFATM(sc->ifp)->mib.vpi_bits = PATM_VPI_BITS;
+ IFP2IFATM(sc->ifp)->mib.vci_bits = 0; /* set below */;
+ IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
+ IFP2IFATM(sc->ifp)->mib.max_vccs = 0; /* set below */
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
+ IFP2IFATM(sc->ifp)->phy = &sc->utopia;
+
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_SIMPLEX;
@@ -297,8 +302,8 @@ patm_attach(device_t dev)
* Detect and attach the phy.
*/
patm_debug(sc, ATTACH, "attaching utopia");
- sc->ifatm.phy = &sc->utopia;
- utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx,
+ IFP2IFATM(sc->ifp)->phy = &sc->utopia;
+ utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&patm_utopia_methods);
@@ -318,41 +323,41 @@ patm_attach(device_t dev)
if (strncmp(sc->eeprom + PATM_PROATM_NAME_OFFSET, PATM_PROATM_NAME,
strlen(PATM_PROATM_NAME)) == 0) {
if (sc->utopia.chip->type == UTP_TYPE_IDT77105) {
- sc->ifatm.mib.device = ATM_DEVICE_PROATM25;
- sc->ifatm.mib.pcr = ATM_RATE_25_6M;
- sc->ifatm.mib.media = IFM_ATM_UTP_25;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_PROATM25;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_25_6M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_25;
sc->flags |= PATM_25M;
patm_printf(sc, "ProATM 25 interface; ");
} else {
/* cannot really know which media */
- sc->ifatm.mib.device = ATM_DEVICE_PROATM155;
- sc->ifatm.mib.pcr = ATM_RATE_155M;
- sc->ifatm.mib.media = IFM_ATM_MM_155;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_PROATM155;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
patm_printf(sc, "ProATM 155 interface; ");
}
- bcopy(sc->eeprom + PATM_PROATM_MAC_OFFSET, sc->ifatm.mib.esi,
- sizeof(sc->ifatm.mib.esi));
+ bcopy(sc->eeprom + PATM_PROATM_MAC_OFFSET, IFP2IFATM(sc->ifp)->mib.esi,
+ sizeof(IFP2IFATM(sc->ifp)->mib.esi));
} else {
if (sc->utopia.chip->type == UTP_TYPE_IDT77105) {
- sc->ifatm.mib.device = ATM_DEVICE_IDTABR25;
- sc->ifatm.mib.pcr = ATM_RATE_25_6M;
- sc->ifatm.mib.media = IFM_ATM_UTP_25;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_IDTABR25;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_25_6M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_25;
sc->flags |= PATM_25M;
patm_printf(sc, "IDT77252 25MBit interface; ");
} else {
/* cannot really know which media */
- sc->ifatm.mib.device = ATM_DEVICE_IDTABR155;
- sc->ifatm.mib.pcr = ATM_RATE_155M;
- sc->ifatm.mib.media = IFM_ATM_MM_155;
+ IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_IDTABR155;
+ IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
+ IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
patm_printf(sc, "IDT77252 155MBit interface; ");
}
- bcopy(sc->eeprom + PATM_IDT_MAC_OFFSET, sc->ifatm.mib.esi,
- sizeof(sc->ifatm.mib.esi));
+ bcopy(sc->eeprom + PATM_IDT_MAC_OFFSET, IFP2IFATM(sc->ifp)->mib.esi,
+ sizeof(IFP2IFATM(sc->ifp)->mib.esi));
}
printf("idt77252 Rev. %c; %s PHY\n", 'A' + sc->revision,
sc->utopia.chip->name);
@@ -375,8 +380,8 @@ patm_attach(device_t dev)
else
sc->mmap = &idt_mmap[3];
- sc->ifatm.mib.vci_bits = sc->mmap->vcbits - sc->ifatm.mib.vpi_bits;
- sc->ifatm.mib.max_vccs = sc->mmap->max_conn;
+ IFP2IFATM(sc->ifp)->mib.vci_bits = sc->mmap->vcbits - IFP2IFATM(sc->ifp)->mib.vpi_bits;
+ IFP2IFATM(sc->ifp)->mib.max_vccs = sc->mmap->max_conn;
patm_sram_write(sc, 0, 0);
patm_printf(sc, "%uK x 32 SRAM; %u connections\n", sc->mmap->sram,
sc->mmap->max_conn);
@@ -440,7 +445,8 @@ patm_attach(device_t dev)
sc, &sc->ih);
if (error != 0) {
patm_printf(sc, "could not setup interrupt\n");
- atm_ifdetach(&sc->ifatm.ifnet);
+ atm_ifdetach(sc->ifp);
+ if_free(sc->ifp);
goto fail;
}
@@ -470,7 +476,8 @@ patm_detach(device_t dev)
}
mtx_unlock(&sc->mtx);
- atm_ifdetach(&sc->ifatm.ifnet);
+ atm_ifdetach(sc->ifp);
+ if_free(sc->ifp);
patm_destroy(sc);
@@ -696,7 +703,7 @@ patm_read_eeprom(struct patm_softc *sc)
static int
patm_phy_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n)
{
- struct patm_softc *sc = ifatm->ifnet.if_softc;
+ struct patm_softc *sc = ifatm->ifp->if_softc;
u_int cnt = *n;
if (reg >= 0x100)
@@ -722,7 +729,7 @@ patm_phy_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n)
static int
patm_phy_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val)
{
- struct patm_softc *sc = ifatm->ifnet.if_softc;
+ struct patm_softc *sc = ifatm->ifp->if_softc;
u_int old, new;
if (reg >= 0x100)
diff --git a/sys/dev/patm/if_patm_intr.c b/sys/dev/patm/if_patm_intr.c
index f177253..b19dfc0 100644
--- a/sys/dev/patm/if_patm_intr.c
+++ b/sys/dev/patm/if_patm_intr.c
@@ -119,7 +119,7 @@ patm_intr(void *p)
stat = patm_nor_read(sc, IDT_NOR_STAT);
patm_nor_write(sc, IDT_NOR_STAT, stat & (ints | fbqa));
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
/* if we are stopped ack all interrupts and handle PHYI */
if (stat & IDT_STAT_PHYI) {
patm_debug(sc, INTR, "PHYI (stopped)");
diff --git a/sys/dev/patm/if_patm_ioctl.c b/sys/dev/patm/if_patm_ioctl.c
index 6dc669d..651bed6 100644
--- a/sys/dev/patm/if_patm_ioctl.c
+++ b/sys/dev/patm/if_patm_ioctl.c
@@ -107,7 +107,7 @@ patm_open_vcc(struct patm_softc *sc, struct atmio_openvcc *arg)
return (ENOMEM);
mtx_lock(&sc->mtx);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
/* stopped while we have analyzed the arguments */
error = EIO;
goto done;
@@ -200,7 +200,7 @@ patm_load_vc(struct patm_softc *sc, struct patm_vcc *vcc, int reload)
/* inform management about non-NG and NG-PVCs */
if (!(vcc->vcc.flags & ATMIO_FLAG_NG) ||
(vcc->vcc.flags & ATMIO_FLAG_PVC))
- ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->vcc.vpi,
+ ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->vcc.vpi,
vcc->vcc.vci, 1);
}
@@ -224,7 +224,7 @@ patm_close_vcc(struct patm_softc *sc, struct atmio_closevcc *arg)
cid = PATM_CID(sc, arg->vpi, arg->vci);
mtx_lock(&sc->mtx);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
/* stopped while we have analyzed the arguments */
error = EIO;
goto done;
@@ -246,7 +246,7 @@ patm_close_vcc(struct patm_softc *sc, struct atmio_closevcc *arg)
while (vcc->vflags & (PATM_VCC_TX_CLOSING | PATM_VCC_RX_CLOSING)) {
cv_wait(&sc->vcc_cv, &sc->mtx);
- if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
+ if (!(sc->ifp->if_flags & IFF_RUNNING)) {
/* ups, has been stopped */
error = EIO;
goto done;
@@ -276,7 +276,7 @@ patm_vcc_closed(struct patm_softc *sc, struct patm_vcc *vcc)
/* inform management about non-NG and NG-PVCs */
if (!(vcc->vcc.flags & ATMIO_FLAG_NG) ||
(vcc->vcc.flags & ATMIO_FLAG_PVC))
- ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->vcc.vpi,
+ ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->vcc.vpi,
vcc->vcc.vci, 0);
sc->vccs_open--;
diff --git a/sys/dev/patm/if_patm_rx.c b/sys/dev/patm/if_patm_rx.c
index 01c3243..1a012a9 100644
--- a/sys/dev/patm/if_patm_rx.c
+++ b/sys/dev/patm/if_patm_rx.c
@@ -244,7 +244,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe)
m->m_len = cells * 48;
m->m_pkthdr.len = m->m_len;
- m->m_pkthdr.rcvif = &sc->ifatm.ifnet;
+ m->m_pkthdr.rcvif = sc->ifp;
} else if (vcc->vcc.aal == ATMIO_AAL_34) {
/* XXX AAL3/4 */
@@ -253,7 +253,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe)
} else if (vcc->vcc.aal == ATMIO_AAL_5) {
if (stat & IDT_RSQE_CRC) {
- sc->ifatm.ifnet.if_ierrors++;
+ sc->ifp->if_ierrors++;
if (vcc->chain != NULL) {
m_freem(vcc->chain);
vcc->chain = vcc->last = NULL;
@@ -267,7 +267,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe)
return;
m->m_len = cells * 48;
m->m_pkthdr.len = m->m_len;
- m->m_pkthdr.rcvif = &sc->ifatm.ifnet;
+ m->m_pkthdr.rcvif = sc->ifp;
vcc->chain = vcc->last = m;
} else {
if ((m = patm_rcv_mbuf(sc, buf, h, 0)) == NULL)
@@ -311,9 +311,9 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe)
}
#endif
- sc->ifatm.ifnet.if_ipackets++;
+ sc->ifp->if_ipackets++;
/* this is in if_atmsubr.c */
- /* sc->ifatm.ifnet.if_ibytes += m->m_pkthdr.len; */
+ /* sc->ifp->if_ibytes += m->m_pkthdr.len; */
vcc->ibytes += m->m_pkthdr.len;
vcc->ipackets++;
@@ -326,10 +326,10 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe)
if (!(vcc->vcc.flags & ATMIO_FLAG_NG) &&
(vcc->vcc.aal == ATMIO_AAL_5) &&
(vcc->vcc.flags & ATM_PH_LLCSNAP))
- BPF_MTAP(&sc->ifatm.ifnet, m);
+ BPF_MTAP(sc->ifp, m);
#endif
- atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand);
+ atm_input(sc->ifp, &aph, m, vcc->rxhand);
}
/*
@@ -463,7 +463,7 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell)
sc->stats.raw_no_buf++;
return;
}
- m->m_pkthdr.rcvif = &sc->ifatm.ifnet;
+ m->m_pkthdr.rcvif = sc->ifp;
switch (vcc->vflags & PATM_RAW_FORMAT) {
@@ -510,9 +510,9 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell)
break;
}
- sc->ifatm.ifnet.if_ipackets++;
+ sc->ifp->if_ipackets++;
/* this is in if_atmsubr.c */
- /* sc->ifatm.ifnet.if_ibytes += m->m_pkthdr.len; */
+ /* sc->ifp->if_ibytes += m->m_pkthdr.len; */
vcc->ibytes += m->m_pkthdr.len;
vcc->ipackets++;
@@ -521,5 +521,5 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell)
ATM_PH_VPI(&aph) = vcc->vcc.vpi;
ATM_PH_SETVCI(&aph, vcc->vcc.vci);
- atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand);
+ atm_input(sc->ifp, &aph, m, vcc->rxhand);
}
diff --git a/sys/dev/patm/if_patm_tx.c b/sys/dev/patm/if_patm_tx.c
index 0c6a99e..975f56a 100644
--- a/sys/dev/patm/if_patm_tx.c
+++ b/sys/dev/patm/if_patm_tx.c
@@ -119,13 +119,13 @@ cbr2slots(struct patm_softc *sc, struct patm_vcc *vcc)
/* compute the number of slots we need, make sure to get at least
* the specified PCR */
return ((u_int)(((uint64_t)(sc->mmap->tst_size - 1) *
- vcc->vcc.tparam.pcr + sc->ifatm.mib.pcr - 1) / sc->ifatm.mib.pcr));
+ vcc->vcc.tparam.pcr + IFP2IFATM(sc->ifp)->mib.pcr - 1) / IFP2IFATM(sc->ifp)->mib.pcr));
}
static __inline u_int
slots2cr(struct patm_softc *sc, u_int slots)
{
- return ((slots * sc->ifatm.mib.pcr + sc->mmap->tst_size - 2) /
+ return ((slots * IFP2IFATM(sc->ifp)->mib.pcr + sc->mmap->tst_size - 2) /
(sc->mmap->tst_size - 1));
}
@@ -149,7 +149,7 @@ patm_tx_vcc_can_open(struct patm_softc *sc, struct patm_vcc *vcc)
case ATMIO_TRAFFIC_VBR:
if (vcc->vcc.tparam.scr > sc->bwrem)
return (EINVAL);
- if (vcc->vcc.tparam.pcr > sc->ifatm.mib.pcr)
+ if (vcc->vcc.tparam.pcr > IFP2IFATM(sc->ifp)->mib.pcr)
return (EINVAL);
if (vcc->vcc.tparam.scr > vcc->vcc.tparam.pcr ||
vcc->vcc.tparam.mbs == 0)
@@ -161,7 +161,7 @@ patm_tx_vcc_can_open(struct patm_softc *sc, struct patm_vcc *vcc)
vcc->vcc.tparam.nrm == 0)
/* needed to compute CRM */
return (EINVAL);
- if (vcc->vcc.tparam.pcr > sc->ifatm.mib.pcr ||
+ if (vcc->vcc.tparam.pcr > IFP2IFATM(sc->ifp)->mib.pcr ||
vcc->vcc.tparam.icr > vcc->vcc.tparam.pcr ||
vcc->vcc.tparam.mcr > vcc->vcc.tparam.icr)
return (EINVAL);
@@ -303,7 +303,7 @@ patm_start(struct ifnet *ifp)
/* split of pseudo header */
if (m->m_len < sizeof(*aph) &&
(m = m_pullup(m, sizeof(*aph))) == NULL) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
@@ -315,21 +315,21 @@ patm_start(struct ifnet *ifp)
/* reject empty packets */
if (m->m_pkthdr.len == 0) {
m_freem(m);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
/* check whether this is a legal vcc */
if (!LEGAL_VPI(sc, vpi) || !LEGAL_VCI(sc, vci) || vci == 0) {
m_freem(m);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
cid = PATM_CID(sc, vpi, vci);
vcc = sc->vccs[cid];
if (vcc == NULL) {
m_freem(m);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
@@ -339,7 +339,7 @@ patm_start(struct ifnet *ifp)
/* XXX AAL3/4 format? */
if (m->m_pkthdr.len % 48 != 0 &&
(m = patm_tx_pad(sc, m)) == NULL) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
} else if (vcc->vcc.aal == ATMIO_AAL_RAW) {
@@ -348,7 +348,7 @@ patm_start(struct ifnet *ifp)
default:
case PATM_RAW_CELL:
if (m->m_pkthdr.len != 53) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
m_freem(m);
continue;
}
@@ -356,7 +356,7 @@ patm_start(struct ifnet *ifp)
case PATM_RAW_NOHEC:
if (m->m_pkthdr.len != 52) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
m_freem(m);
continue;
}
@@ -364,7 +364,7 @@ patm_start(struct ifnet *ifp)
case PATM_RAW_CS:
if (m->m_pkthdr.len != 64) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
m_freem(m);
continue;
}
@@ -377,7 +377,7 @@ patm_start(struct ifnet *ifp)
/* try to put it on the channels queue */
if (_IF_QFULL(&vcc->scd->q)) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
sc->stats.tx_qfull++;
m_freem(m);
continue;
@@ -415,7 +415,7 @@ patm_tx_pad(struct patm_softc *sc, struct mbuf *m0)
m0->m_pkthdr.len = plen;
if (plen == 0) {
m_freem(m0);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
return (NULL);
}
if (plen % 48 == 0)
@@ -441,7 +441,7 @@ patm_tx_pad(struct patm_softc *sc, struct mbuf *m0)
MGET(m, M_DONTWAIT, MT_DATA);
if (m == 0) {
m_freem(m0);
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
return (NULL);
}
bzero(mtod(m, u_char *), pad);
@@ -533,7 +533,7 @@ patm_launch(struct patm_softc *sc, struct patm_scd *scd)
patm_load_txbuf, &a, BUS_DMA_NOWAIT);
if (error == EFBIG) {
if ((m = m_defrag(m, M_DONTWAIT)) == NULL) {
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
continue;
}
error = bus_dmamap_load_mbuf(sc->tx_tag, map->map, m,
@@ -541,13 +541,13 @@ patm_launch(struct patm_softc *sc, struct patm_scd *scd)
}
if (error != 0) {
sc->stats.tx_load_err++;
- sc->ifatm.ifnet.if_oerrors++;
+ sc->ifp->if_oerrors++;
SLIST_INSERT_HEAD(&sc->tx_maps_free, map, link);
m_freem(m);
continue;
}
- sc->ifatm.ifnet.if_opackets++;
+ sc->ifp->if_opackets++;
}
}
@@ -741,12 +741,12 @@ patm_tx(struct patm_softc *sc, u_int stamp, u_int status)
acri = (patm_sram_read(sc, 8 * cid + 2) >> IDT_TCT_ACRI_SHIFT)
& 0x3fff;
- cps = sc->ifatm.mib.pcr * 32 /
+ cps = IFP2IFATM(sc->ifp)->mib.pcr * 32 /
((1 << (acri >> 10)) * (acri & 0x3ff));
if (cps != vcc->cps) {
patm_debug(sc, VCC, "ACRI=%04x CPS=%u", acri, cps);
- ATMEV_SEND_ACR_CHANGED(&sc->ifatm, vcc->vcc.vpi,
+ ATMEV_SEND_ACR_CHANGED(IFP2IFATM(sc->ifp), vcc->vcc.vpi,
vcc->vcc.vci, cps);
vcc->cps = cps;
}
@@ -1126,7 +1126,7 @@ patm_tst_alloc(struct patm_softc *sc, struct patm_vcc *vcc)
sc->bwrem -= slots2cr(sc, slots);
patm_debug(sc, TST, "tst_alloc: cbr=%u link=%u tst=%u slots=%u",
- vcc->vcc.tparam.pcr, sc->ifatm.mib.pcr, sc->mmap->tst_size, slots);
+ vcc->vcc.tparam.pcr, IFP2IFATM(sc->ifp)->mib.pcr, sc->mmap->tst_size, slots);
qmax = sc->mmap->tst_size - 1;
pmax = qmax << 8;
diff --git a/sys/dev/patm/if_patmvar.h b/sys/dev/patm/if_patmvar.h
index 5cadbc3..e934784 100644
--- a/sys/dev/patm/if_patmvar.h
+++ b/sys/dev/patm/if_patmvar.h
@@ -149,7 +149,7 @@ struct lmbuf {
};
#define PATM_CID(SC, VPI, VCI) \
- (((VPI) << (SC)->ifatm.mib.vci_bits) | (VCI))
+ (((VPI) << IFP2IFATM((SC)->ifp)->mib.vci_bits) | (VCI))
/*
* Internal driver statistics
@@ -218,7 +218,7 @@ struct patm_vcc {
* Per adapter data
*/
struct patm_softc {
- struct ifatm ifatm; /* common ATM stuff */
+ struct ifnet *ifp; /* common ATM stuff */
struct mtx mtx; /* lock */
struct ifmedia media; /* media */
device_t dev; /* device */
@@ -325,7 +325,7 @@ struct patm_softc {
#define TST_PENDING 0x0002 /* need update */
#define TST_WAIT 0x0004 /* wait fo jump */
-#define patm_printf(SC, ...) if_printf(&(SC)->ifatm.ifnet, __VA_ARGS__);
+#define patm_printf(SC, ...) if_printf((SC)->ifp, __VA_ARGS__);
#ifdef PATM_DEBUG
/*
@@ -348,7 +348,7 @@ enum {
#define patm_debug(SC, FLAG, ...) do { \
if((SC)->debug & DBG_##FLAG) { \
- if_printf(&(SC)->ifatm.ifnet, "%s: ", __func__); \
+ if_printf((SC)->ifp, "%s: ", __func__); \
printf(__VA_ARGS__); \
printf("\n"); \
} \
@@ -510,9 +510,9 @@ patm_sram_write4(struct patm_softc *sc, u_int addr, uint32_t v0, uint32_t v1,
}
#define LEGAL_VPI(SC, VPI) \
- (((VPI) & ~((1 << (SC)->ifatm.mib.vpi_bits) - 1)) == 0)
+ (((VPI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vpi_bits) - 1)) == 0)
#define LEGAL_VCI(SC, VCI) \
- (((VCI) & ~((1 << (SC)->ifatm.mib.vci_bits) - 1)) == 0)
+ (((VCI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vci_bits) - 1)) == 0)
extern const uint32_t patm_rtables155[];
extern const uint32_t patm_rtables25[];
diff --git a/sys/dev/pdq/if_fea.c b/sys/dev/pdq/if_fea.c
index ea01423..68dbf13 100644
--- a/sys/dev/pdq/if_fea.c
+++ b/sys/dev/pdq/if_fea.c
@@ -186,7 +186,7 @@ pdq_eisa_attach (dev)
int error;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
sc->dev = dev;
@@ -244,7 +244,7 @@ pdq_eisa_attach (dev)
}
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes,
- (caddr_t) sc->arpcom.ac_enaddr, FDDI_ADDR_LEN);
+ (caddr_t) IFP2ENADDR(sc->ifp), FDDI_ADDR_LEN);
pdq_ifattach(sc);
return (0);
diff --git a/sys/dev/pdq/if_fpa.c b/sys/dev/pdq/if_fpa.c
index 6ed271a..1cca08e 100644
--- a/sys/dev/pdq/if_fpa.c
+++ b/sys/dev/pdq/if_fpa.c
@@ -111,7 +111,7 @@ pdq_pci_attach(device_t dev)
int error;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
sc->dev = dev;
@@ -167,7 +167,7 @@ pdq_pci_attach(device_t dev)
}
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes,
- (caddr_t) sc->arpcom.ac_enaddr, FDDI_ADDR_LEN);
+ (caddr_t) IFP2ENADDR(sc->ifp), FDDI_ADDR_LEN);
pdq_ifattach(sc);
return (0);
diff --git a/sys/dev/pdq/pdq.c b/sys/dev/pdq/pdq.c
index 9fb29ad..2f44439 100644
--- a/sys/dev/pdq/pdq.c
+++ b/sys/dev/pdq/pdq.c
@@ -42,23 +42,14 @@ __FBSDID("$FreeBSD$");
* flushing of the write buffers.
*/
-#ifdef __NetBSD__
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pdq.c,v 1.33 2001/11/13 13:14:43 lukem Exp $");
-#endif
#define PDQ_HWSUPPORT /* for pdq.h */
-#if defined(__FreeBSD__)
/*
* What a botch having to specific includes for FreeBSD!
*/
#include <dev/pdq/pdq_freebsd.h>
#include <dev/pdq/pdqreg.h>
-#else
-#include "pdqvar.h"
-#include "pdqreg.h"
-#endif
#define PDQ_ROUNDUP(n, x) (((n) + ((x) - 1)) & ~((x) - 1))
#define PDQ_CMD_RX_ALIGNMENT 16
@@ -186,15 +177,9 @@ pdq_print_fddi_chars(
const char hexchars[] = "0123456789abcdef";
printf(
-#if !defined(__bsdi__) && !defined(__NetBSD__)
PDQ_OS_PREFIX
-#else
- ": "
-#endif
"DEC %s FDDI %s Controller\n",
-#if !defined(__bsdi__) && !defined(__NetBSD__)
PDQ_OS_PREFIX_ARGS,
-#endif
pdq_descriptions[pdq->pdq_type],
pdq_station_types[rsp->status_chars_get.station_type]);
diff --git a/sys/dev/pdq/pdq_freebsd.h b/sys/dev/pdq/pdq_freebsd.h
index 6dc7c6c..ef38138 100644
--- a/sys/dev/pdq/pdq_freebsd.h
+++ b/sys/dev/pdq/pdq_freebsd.h
@@ -93,15 +93,13 @@ enum _pdq_type_t {
};
#define sc_ifmedia ifmedia
-#define sc_if arpcom.ac_if
-#define sc_bpf sc_if.if_bpf
#if 0 /* ALTQ */
#define IFQ_DEQUEUE IF_DEQUEUE
#define IFQ_IS_EMPTY(q) ((q)->ifq_len == 0)
#endif
typedef struct _pdq_os_ctx_t {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct ifmedia ifmedia;
device_t dev;
int debug;
@@ -152,7 +150,8 @@ typedef struct _pdq_os_ctx_t {
#define PDQ_OS_TX_TIMEOUT 5 /* seconds */
#define PDQ_OS_IFP_TO_SOFTC(ifp) ((pdq_softc_t *) (ifp)->if_softc)
-#define PDQ_BPF_MTAP(sc, m) BPF_MTAP(&(sc)->arpcom.ac_if, m)
+#define PDQ_BPF_MTAP(sc, m) BPF_MTAP((sc)->ifp, m)
+#define PDQ_IFNET(sc) ((sc)->ifp)
#endif /* PDQ_OSSUPPORT */
diff --git a/sys/dev/pdq/pdq_ifsubr.c b/sys/dev/pdq/pdq_ifsubr.c
index d3a64e2..fa48594 100644
--- a/sys/dev/pdq/pdq_ifsubr.c
+++ b/sys/dev/pdq/pdq_ifsubr.c
@@ -36,10 +36,6 @@ __FBSDID("$FreeBSD$");
* (ie. it provides an ifnet interface to the rest of the system)
*/
-#ifdef __NetBSD__
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.38 2001/12/21 23:21:47 matt Exp $");
-#endif
#define PDQ_OSSUPPORT
@@ -63,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.38 2001/12/21 23:21:47 matt Exp $")
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/fddi.h>
#include <net/bpf.h>
@@ -76,14 +73,14 @@ static void
pdq_ifinit(
pdq_softc_t *sc)
{
- if (sc->sc_if.if_flags & IFF_UP) {
- sc->sc_if.if_flags |= IFF_RUNNING;
- if (sc->sc_if.if_flags & IFF_PROMISC) {
+ if (PDQ_IFNET(sc)->if_flags & IFF_UP) {
+ PDQ_IFNET(sc)->if_flags |= IFF_RUNNING;
+ if (PDQ_IFNET(sc)->if_flags & IFF_PROMISC) {
sc->sc_pdq->pdq_flags |= PDQ_PROMISC;
} else {
sc->sc_pdq->pdq_flags &= ~PDQ_PROMISC;
}
- if (sc->sc_if.if_flags & IFF_LINK1) {
+ if (PDQ_IFNET(sc)->if_flags & IFF_LINK1) {
sc->sc_pdq->pdq_flags |= PDQ_PASS_SMT;
} else {
sc->sc_pdq->pdq_flags &= ~PDQ_PASS_SMT;
@@ -91,7 +88,7 @@ pdq_ifinit(
sc->sc_pdq->pdq_flags |= PDQ_RUNNING;
pdq_run(sc->sc_pdq);
} else {
- sc->sc_if.if_flags &= ~IFF_RUNNING;
+ PDQ_IFNET(sc)->if_flags &= ~IFF_RUNNING;
sc->sc_pdq->pdq_flags &= ~PDQ_RUNNING;
pdq_stop(sc->sc_pdq);
}
@@ -128,11 +125,11 @@ pdq_ifstart(
if ((ifp->if_flags & IFF_RUNNING) == 0)
return;
- if (sc->sc_if.if_timer == 0)
- sc->sc_if.if_timer = PDQ_OS_TX_TIMEOUT;
+ if (PDQ_IFNET(sc)->if_timer == 0)
+ PDQ_IFNET(sc)->if_timer = PDQ_OS_TX_TIMEOUT;
if ((sc->sc_pdq->pdq_flags & PDQ_TXOK) == 0) {
- sc->sc_if.if_flags |= IFF_OACTIVE;
+ PDQ_IFNET(sc)->if_flags |= IFF_OACTIVE;
return;
}
sc->sc_flags |= PDQIF_DOWNCALL;
@@ -189,7 +186,7 @@ pdq_os_receive_pdu(
int drop)
{
pdq_softc_t *sc = pdq->pdq_os_ctx;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = PDQ_IFNET(sc);
struct fddi_header *fh;
ifp->if_ipackets++;
@@ -212,10 +209,6 @@ pdq_os_receive_pdu(
}
#endif
m->m_pkthdr.len = pktlen;
-#if NBPFILTER > 0 && defined(__NetBSD__)
- if (sc->sc_bpf != NULL)
- PDQ_BPF_MTAP(sc, m);
-#endif
fh = mtod(m, struct fddi_header *);
if (drop || (fh->fddi_fc & (FDDIFC_L|FDDIFC_F)) != FDDIFC_LLC_ASYNC) {
ifp->if_iqdrops++;
@@ -233,13 +226,13 @@ pdq_os_restart_transmitter(
pdq_t *pdq)
{
pdq_softc_t *sc = pdq->pdq_os_ctx;
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
- if (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0) {
- sc->sc_if.if_timer = PDQ_OS_TX_TIMEOUT;
+ PDQ_IFNET(sc)->if_flags &= ~IFF_OACTIVE;
+ if (IFQ_IS_EMPTY(&PDQ_IFNET(sc)->if_snd) == 0) {
+ PDQ_IFNET(sc)->if_timer = PDQ_OS_TX_TIMEOUT;
if ((sc->sc_flags & PDQIF_DOWNCALL) == 0)
- pdq_ifstart(&sc->sc_if);
+ pdq_ifstart(PDQ_IFNET(sc));
} else {
- sc->sc_if.if_timer = 0;
+ PDQ_IFNET(sc)->if_timer = 0;
}
}
@@ -250,11 +243,11 @@ pdq_os_transmit_done(
{
pdq_softc_t *sc = pdq->pdq_os_ctx;
#if NBPFILTER > 0
- if (sc->sc_bpf != NULL)
+ if (PQD_IFNET(sc)->if_bpf != NULL)
PDQ_BPF_MTAP(sc, m);
#endif
PDQ_OS_DATABUF_FREE(pdq, m);
- sc->sc_if.if_opackets++;
+ PDQ_IFNET(sc)->if_opackets++;
}
void
@@ -267,7 +260,7 @@ pdq_os_addr_fill(
struct ifnet *ifp;
struct ifmultiaddr *ifma;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
/*
* ADDR_FILTER_SET is always issued before FILTER_SET so
@@ -277,10 +270,10 @@ pdq_os_addr_fill(
pdq->pdq_flags &= ~PDQ_ALLMULTI;
#if defined(IFF_ALLMULTI)
- sc->sc_if.if_flags &= ~IFF_ALLMULTI;
+ PDQ_IFNET(sc)->if_flags &= ~IFF_ALLMULTI;
#endif
- for (ifma = TAILQ_FIRST(&sc->sc_if.if_multiaddrs); ifma && num_addrs > 0;
+ for (ifma = TAILQ_FIRST(&PDQ_IFNET(sc)->if_multiaddrs); ifma && num_addrs > 0;
ifma = TAILQ_NEXT(ifma, ifma_link)) {
char *mcaddr;
if (ifma->ifma_addr->sa_family != AF_LINK)
@@ -298,7 +291,7 @@ pdq_os_addr_fill(
if (ifma != NULL) {
pdq->pdq_flags |= PDQ_ALLMULTI;
#if defined(IFF_ALLMULTI)
- sc->sc_if.if_flags |= IFF_ALLMULTI;
+ PDQ_IFNET(sc)->if_flags |= IFF_ALLMULTI;
#endif
}
}
@@ -384,7 +377,7 @@ pdq_ifioctl(
case SIOCADDMULTI:
case SIOCDELMULTI: {
- if (sc->sc_if.if_flags & IFF_RUNNING) {
+ if (PDQ_IFNET(sc)->if_flags & IFF_RUNNING) {
pdq_run(sc->sc_pdq);
error = 0;
}
@@ -417,7 +410,11 @@ pdq_ifioctl(
void
pdq_ifattach(pdq_softc_t *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp;
+
+ ifp = PDQ_IFNET(sc) = if_alloc(IFT_FDDI);
+ if (ifp == NULL)
+ panic("%s: can not if_alloc()", device_get_nameunit(sc->dev));
mtx_init(&sc->mtx, device_get_nameunit(sc->dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
@@ -427,16 +424,9 @@ pdq_ifattach(pdq_softc_t *sc)
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST;
-#if (defined(__FreeBSD__) && BSD >= 199506) || defined(__NetBSD__)
ifp->if_watchdog = pdq_ifwatchdog;
-#else
- ifp->if_watchdog = ifwatchdog;
-#endif
ifp->if_ioctl = pdq_ifioctl;
-#if !defined(__NetBSD__) && !defined(__FreeBSD__)
- ifp->if_output = fddi_output;
-#endif
ifp->if_start = pdq_ifstart;
#if defined(IFM_FDDI)
@@ -449,12 +439,7 @@ pdq_ifattach(pdq_softc_t *sc)
}
#endif
-#if defined(__NetBSD__)
- if_attach(ifp);
- fddi_ifattach(ifp, (caddr_t)&sc->sc_pdq->pdq_hwaddr);
-#else
fddi_ifattach(ifp, FDDI_BPF_SUPPORTED);
-#endif
}
void
@@ -462,9 +447,10 @@ pdq_ifdetach (pdq_softc_t *sc)
{
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
fddi_ifdetach(ifp, FDDI_BPF_SUPPORTED);
+ if_free(ifp);
pdq_stop(sc->sc_pdq);
pdq_free(sc->dev);
diff --git a/sys/dev/pdq/pdqvar.h b/sys/dev/pdq/pdqvar.h
index 282d79e..de576ba 100644
--- a/sys/dev/pdq/pdqvar.h
+++ b/sys/dev/pdq/pdqvar.h
@@ -61,7 +61,7 @@ enum _pdq_type_t {
#if defined(PDQTEST)
#include <pdq_os_test.h>
-#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__)
+#else
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,40 +72,19 @@ enum _pdq_type_t {
#include <vm/vm.h>
#include <vm/vm_kern.h>
-#define PDQ_USE_MBUFS
-#if defined(__NetBSD__) || defined(__FreeBSD__)
#define PDQ_OS_PREFIX "%s: "
#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name
-#else
-#define PDQ_OS_PREFIX "%s%d: "
-#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name, pdq->pdq_unit
-#endif
-#if defined(__FreeBSD__) && BSD >= 199506
#define PDQ_OS_PAGESIZE PAGE_SIZE
-#else
-#define PDQ_OS_PAGESIZE NBPG
-#endif
#define PDQ_OS_USEC_DELAY(n) DELAY(n)
#define PDQ_OS_MEMZERO(p, n) bzero((caddr_t)(p), (n))
-#if defined(__NetBSD__) && !defined(PDQ_NO_BUS_DMA)
-#define PDQ_BUS_DMA
-#endif
#if !defined(PDQ_BUS_DMA)
#define PDQ_OS_VA_TO_BUSPA(pdq, p) vtophys(p)
#endif
#define PDQ_OS_MEMALLOC(n) malloc(n, M_DEVBUF, M_NOWAIT)
#define PDQ_OS_MEMFREE(p, n) free((void *) p, M_DEVBUF)
-#ifdef __FreeBSD__
#define PDQ_OS_MEMALLOC_CONTIG(n) contigmalloc(n, M_DEVBUF, M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0)
#define PDQ_OS_MEMFREE_CONTIG(p, n) contigfree((void *) p, n, M_DEVBUF)
-#else
-#if !defined(PDQ_BUS_DMA)
-#define PDQ_OS_MEMALLOC_CONTIG(n) uvm_km_alloc(kernel_map, round_page(n))
-#define PDQ_OS_MEMFREE_CONTIG(p, n) uvm_km_free(kernel_map, (vaddr_t) p, n)
-#endif
-#endif /* __FreeBSD__ */
-#if defined(__FreeBSD__)
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <machine/cpufunc.h>
@@ -116,130 +95,8 @@ typedef enum { PDQ_BUS_EISA, PDQ_BUS_PCI } pdq_bus_t;
typedef u_int16_t pdq_bus_ioport_t;
typedef volatile pdq_uint32_t *pdq_bus_memaddr_t;
typedef pdq_bus_memaddr_t pdq_bus_memoffset_t;
-#if BSD >= 199506 /* __FreeBSD__ */
-#define PDQ_BPF_MTAP(sc, m) bpf_mtap(&(sc)->sc_if, m)
-#define PDQ_BPFATTACH(sc, t, s) bpfattach(&(sc)->sc_if, t, s)
-#endif
-
#define pdq_os_update_status(a, b) ((void) 0)
-#elif defined(__bsdi__)
-#if !defined(PDQ_HWSUPPORT) && (_BSDI_VERSION >= 199701)
-#include <net/if_media.h>
-#endif
-#include <machine/inline.h>
-#define ifnet_ret_t int
-typedef int ioctl_cmd_t;
-typedef enum { PDQ_BUS_EISA, PDQ_BUS_PCI } pdq_bus_t;
-typedef u_int16_t pdq_bus_ioport_t;
-typedef volatile pdq_uint32_t *pdq_bus_memaddr_t;
-typedef pdq_bus_memaddr_t pdq_bus_memoffset_t;
-
-
-#elif defined(__NetBSD__)
-#if !defined(PDQ_HWSUPPORT)
-#include <net/if_media.h>
-#endif
-#include <machine/bus.h>
-#include <machine/intr.h>
-#define PDQ_OS_HDR_OFFSET (PDQ_RX_FC_OFFSET-3)
-#define PDQ_OS_PTR_FMT "%p"
-#define PDQ_OS_CSR_FMT "0x%lx"
-#define ifnet_ret_t void
-typedef u_long ioctl_cmd_t;
-typedef bus_space_tag_t pdq_bus_t;
-typedef bus_space_handle_t pdq_bus_ioport_t;
-typedef bus_space_handle_t pdq_bus_memaddr_t;
-typedef bus_addr_t pdq_bus_memoffset_t;
-#define PDQ_OS_SPL_RAISE() splnet()
-#define PDQ_OS_IOMEM
-#define PDQ_OS_IORD_32(t, base, offset) bus_space_read_4 (t, base, offset)
-#define PDQ_OS_IOWR_32(t, base, offset, data) bus_space_write_4 (t, base, offset, data)
-#define PDQ_OS_IORD_8(t, base, offset) bus_space_read_1 (t, base, offset)
-#define PDQ_OS_IOWR_8(t, base, offset, data) bus_space_write_1 (t, base, offset, data)
-#define PDQ_CSR_OFFSET(base, offset) (0 + (offset)*sizeof(pdq_uint32_t))
-
-#ifdef PDQ_BUS_DMA
-#define PDQ_OS_UNSOL_EVENT_PRESYNC(pdq, event) \
- pdq_os_unsolicited_event_sync((pdq)->pdq_os_ctx, \
- (u_int8_t *) (event) - \
- (u_int8_t *) (pdq)->pdq_unsolicited_info.ui_events, \
- sizeof(*event), BUS_DMASYNC_PREREAD)
-#define PDQ_OS_UNSOL_EVENT_POSTSYNC(pdq, event) \
- pdq_os_unsolicited_event_sync((pdq)->pdq_os_ctx, \
- (u_int8_t *) (event) - \
- (u_int8_t *) (pdq)->pdq_unsolicited_info.ui_events, \
- sizeof(*event), BUS_DMASYNC_POSTREAD)
-#define PDQ_OS_DESCBLOCK_SYNC(pdq, what, length, why) \
- pdq_os_descriptor_block_sync((pdq)->pdq_os_ctx, \
- (u_int8_t *) (what) - (u_int8_t *) (pdq)->pdq_dbp, \
- (length), (why))
-#define PDQ_OS_CONSUMER_PRESYNC(pdq) \
- pdq_os_consumer_block_sync((pdq)->pdq_os_ctx, \
- BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
-#define PDQ_OS_CONSUMER_POSTSYNC(pdq) \
- pdq_os_consumer_block_sync((pdq)->pdq_os_ctx, \
- BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
-#define PDQ_OS_DESC_PRESYNC(pdq, d, s) \
- PDQ_OS_DESCBLOCK_SYNC((pdq), (d), (s), BUS_DMASYNC_PREWRITE)
-#define PDQ_OS_DESC_POSTSYNC(pdq, d, s) \
- PDQ_OS_DESCBLOCK_SYNC((pdq), (d), (s), BUS_DMASYNC_POSTWRITE)
-#define PDQ_OS_CMDRQST_PRESYNC(pdq, s) \
- PDQ_OS_DESCBLOCK_SYNC((pdq), \
- (pdq)->pdq_command_info.ci_request_bufstart, \
- (s), BUS_DMASYNC_PREWRITE)
-#define PDQ_OS_CMDRSP_PRESYNC(pdq, s) \
- PDQ_OS_DESCBLOCK_SYNC((pdq), \
- (pdq)->pdq_command_info.ci_response_bufstart, \
- (s), BUS_DMASYNC_PREREAD)
-#define PDQ_OS_CMDRQST_POSTSYNC(pdq, s) \
- PDQ_OS_DESCBLOCK_SYNC((pdq), \
- (pdq)->pdq_command_info.ci_request_bufstart, \
- (s), BUS_DMASYNC_POSTWRITE)
-#define PDQ_OS_CMDRSP_POSTSYNC(pdq, s) \
- PDQ_OS_DESCBLOCK_SYNC((pdq), \
- (pdq)->pdq_command_info.ci_response_bufstart, \
- (s), BUS_DMASYNC_POSTREAD)
-#define PDQ_OS_RXPDU_PRESYNC(pdq, b, o, l) \
- pdq_os_databuf_sync((pdq)->pdq_os_ctx, (b), (o), (l), \
- BUS_DMASYNC_PREREAD)
-#define PDQ_OS_RXPDU_POSTSYNC(pdq, b, o, l) \
- pdq_os_databuf_sync((pdq)->pdq_os_ctx, (b), (o), (l), \
- BUS_DMASYNC_POSTREAD)
-#define PDQ_OS_DATABUF_ALLOC(pdq, b) ((void)((b) = pdq_os_databuf_alloc((pdq)->pdq_os_ctx)))
-#define PDQ_OS_DATABUF_FREE(pdq, b) pdq_os_databuf_free((pdq)->pdq_os_ctx, (b))
-#define PDQ_OS_DATABUF_BUSPA(pdq, b) (M_GETCTX((b), bus_dmamap_t)->dm_segs[0].ds_addr + 0)
-struct _pdq_os_ctx_t;
-extern void pdq_os_descriptor_block_sync(struct _pdq_os_ctx_t *osctx, size_t offset,
- size_t length, int ops);
-extern void pdq_os_consumer_block_sync(struct _pdq_os_ctx_t *osctx, int ops);
-extern void pdq_os_unsolicited_event_sync(struct _pdq_os_ctx_t *osctx, size_t offset,
- size_t length, int ops);
-extern struct mbuf *pdq_os_databuf_alloc(struct _pdq_os_ctx_t *osctx);
-extern void pdq_os_databuf_sync(struct _pdq_os_ctx_t *osctx, struct mbuf *b,
- size_t offset, size_t length, int ops);
-extern void pdq_os_databuf_free(struct _pdq_os_ctx_t *osctx, struct mbuf *m);
-#define M_HASTXDMAMAP M_LINK1
-#define M_HASRXDMAMAP M_LINK2
-#endif
-
-#define PDQ_CSR_WRITE(csr, name, data) PDQ_OS_IOWR_32((csr)->csr_bus, (csr)->csr_base, (csr)->name, data)
-#define PDQ_CSR_READ(csr, name) PDQ_OS_IORD_32((csr)->csr_bus, (csr)->csr_base, (csr)->name)
-
-#define PDQ_OS_IFP_TO_SOFTC(ifp) ((pdq_softc_t *) (ifp)->if_softc)
-#define PDQ_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->sc_if, (ifa))
-#define PDQ_FDDICOM(sc) (&(sc)->sc_ec)
-#define PDQ_LANADDR(sc) LLADDR((sc)->sc_if.if_sadl)
-#define PDQ_LANADDR_SIZE(sc) ((sc)->sc_if.if_sadl->sdl_alen)
-#endif
-
-#if !defined(PDQ_BPF_MTAP)
-#define PDQ_BPF_MTAP(sc, m) bpf_mtap((sc)->sc_bpf, m)
-#endif
-
-#if !defined(PDQ_BPFATTACH)
-#define PDQ_BPFATTACH(sc, t, s) bpfattach(&(sc)->sc_bpf, &(sc)->sc_if, t, s)
-#endif
#if !defined(PDQ_OS_SPL_RAISE)
#define PDQ_OS_SPL_RAISE() splimp()
@@ -253,6 +110,13 @@ extern void pdq_os_databuf_free(struct _pdq_os_ctx_t *osctx, struct mbuf *m);
#define PDQ_FDDICOM(sc) (&(sc)->sc_ac)
#endif
+#if !defined(PDQ_IFNET)
+#define PDQ_IFNET(sc) (PDQ_FDDICOM((sc))->ac_ifp)
+#endif
+
+#define PDQ_BPF_MTAP(sc, m) bpf_mtap(PDQ_IFNET(sc), m)
+#define PDQ_BPFATTACH(sc, t, s) bpfattach(PDQ_IFNET(sc), t, s)
+
#if !defined(PDQ_ARP_IFINIT)
#define PDQ_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->sc_ac, (ifa))
#endif
@@ -295,25 +159,8 @@ extern void pdq_os_databuf_free(struct _pdq_os_ctx_t *osctx, struct mbuf *m);
#if !defined(PDQ_HWSUPPORT)
typedef struct _pdq_os_ctx_t {
-#if defined(__bsdi__)
- struct device sc_dev; /* base device */
- struct isadev sc_id; /* ISA device */
- struct intrhand sc_ih; /* interrupt vectoring */
- struct atshutdown sc_ats; /* shutdown routine */
- struct arpcom sc_ac;
-#define sc_if sc_ac.ac_if
-#elif defined(__NetBSD__)
- struct device sc_dev; /* base device */
- void *sc_ih; /* interrupt vectoring */
- void *sc_ats; /* shutdown hook */
- struct ethercom sc_ec;
- bus_dma_tag_t sc_dmatag;
-#define sc_if sc_ec.ec_if
-#elif defined(__FreeBSD__)
struct kern_devconf *sc_kdc; /* freebsd cruft */
struct arpcom sc_ac;
-#define sc_if sc_ac.ac_if
-#endif
#if defined(IFM_FDDI)
struct ifmedia sc_ifmedia;
#endif
@@ -321,22 +168,16 @@ typedef struct _pdq_os_ctx_t {
#if defined(__alpha__) || defined(__i386__)
pdq_bus_ioport_t sc_iobase;
#endif
-#if defined(PDQ_IOMAPPED) && !defined(__NetBSD__)
+#if defined(PDQ_IOMAPPED)
#define sc_membase sc_iobase
#else
pdq_bus_memaddr_t sc_membase;
#endif
pdq_bus_t sc_iotag;
pdq_bus_t sc_csrtag;
-#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
-#define sc_bpf sc_if.if_bpf
-#else
caddr_t sc_bpf;
-#endif
#if defined(PDQ_BUS_DMA)
-#if !defined(__NetBSD__)
bus_dma_tag_t sc_dmatag;
-#endif
bus_dmamap_t sc_dbmap; /* DMA map for descriptor block */
bus_dmamap_t sc_uimap; /* DMA map for unsolicited events */
bus_dmamap_t sc_cbmap; /* DMA map for consumer block */
@@ -353,36 +194,9 @@ extern void pdq_ifattach(pdq_softc_t *sc, ifnet_ret_t (*ifwatchdog)(int unit));
#endif /* !PDQ_HWSUPPORT */
-#elif defined(DLPI_PDQ)
-#include <sys/param.h>
-#include <sys/kmem.h>
-#include <sys/ddi.h>
-#include <sys/stream.h>
-
-#define PDQ_USE_STREAMS
-#define PDQ_OS_PREFIX "%s board %d "
-#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name, pdq->pdq_unit
-
-#define PDQ_OS_PAGESIZE PAGESIZE
-#define PDQ_OS_USEC_DELAY(n) drv_usecwait(n)
-#define PDQ_OS_MEMZERO(p, n) bzero((caddr_t)(p), (n))
-#define PDQ_OS_VA_TO_BUSPA(pdq, p) vtop((caddr_t)p, NULL)
-#define PDQ_OS_MEMALLOC(n) kmem_zalloc(n, KM_NOSLEEP)
-#define PDQ_OS_MEMFREE(p, n) kmem_free((caddr_t) p, n)
-#define PDQ_OS_MEMALLOC_CONTIG(n) kmem_zalloc_physreq(n, decfddiphysreq_db, KM_NOSLEEP)
-#define PDQ_OS_MEMFREE_CONTIG(p, n) PDQ_OS_MEMFREE(p, n)
-
-extern physreq_t *decfddiphysreq_db;
-extern physreq_t *decfddiphysreq_mblk;
-
-#define PDQ_OS_DATABUF_ALLOC(pdq, b) ((void) (((b) = allocb_physreq(PDQ_OS_DATABUF_SIZE, BPRI_MED, decfddiphysreq_mblk)) && ((b)->b_wptr = (b)->b_rptr + PDQ_OS_DATABUF_SIZE)))
-
-#define PDQ_OS_IORD_8(port) inb(port)
-#define PDQ_OS_IOWR_8(port, data) outb(port, data)
#endif
-#ifdef PDQ_USE_MBUFS
#define PDQ_OS_DATABUF_SIZE (MCLBYTES)
#ifndef PDQ_OS_DATABUF_FREE
#define PDQ_OS_DATABUF_FREE(pdq, b) (m_freem(b))
@@ -417,26 +231,6 @@ typedef struct mbuf PDQ_OS_DATABUF_T;
} while (0)
#endif
#define PDQ_OS_DATABUF_RESET(b) ((b)->m_data = (b)->m_ext.ext_buf, (b)->m_len = MCLBYTES)
-#endif /* PDQ_USE_MBUFS */
-
-#ifdef PDQ_USE_STREAMS
-#define PDQ_OS_DATABUF_SIZE (2048)
-#define PDQ_OS_DATABUF_FREE(pdq, b) (freemsg(b))
-#define PDQ_OS_DATABUF_NEXT(b) ((b)->b_cont)
-#define PDQ_OS_DATABUF_NEXT_SET(b, b1) ((b)->b_cont = (b1))
-#define PDQ_OS_DATABUF_NEXTPKT(b) ((b)->b_next)
-#define PDQ_OS_DATABUF_NEXTPKT_SET(b, b1) ((b)->b_next = (b1))
-#define PDQ_OS_DATABUF_LEN(b) ((b)->b_wptr - (b)->b_rptr)
-#define PDQ_OS_DATABUF_LEN_SET(b, n) ((b)->b_wptr = (b)->b_rptr + (n))
-/*#define PDQ_OS_DATABUF_LEN_ADJ(b, n) ((b)->b_wptr += (n))*/
-#define PDQ_OS_DATABUF_PTR(b) ((pdq_uint8_t *) (b)->b_rptr)
-#define PDQ_OS_DATABUF_ADJ(b, n) ((b)->b_rptr += (n))
-typedef mblk_t PDQ_OS_DATABUF_T;
-
-#ifndef PDQ_OS_DATABUF_ALLOC
-#define PDQ_OS_DATABUF_ALLOC(pdq, b) ((void) (((b) = allocb(PDQ_OS_DATABUF_SIZE, BPRI_MED)) && ((b)->b_wptr = (b)->b_rptr + PDQ_OS_DATABUF_SIZE)))
-#endif /* PDQ_OS_DATABUF_ALLOC */
-#endif /* PDQ_USE_STREAMS */
#define PDQ_OS_TX_TRANSMIT 5
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index 5b05812..59bb5d6 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -146,7 +146,7 @@ static int volatile lptflag = 0;
#endif
struct lp_data {
- struct ifnet sc_if;
+ struct ifnet *sc_ifp;
u_char *sc_ifbuf;
int sc_iferrs;
@@ -232,7 +232,12 @@ static int
lp_attach (device_t dev)
{
struct lp_data *lp = DEVTOSOFTC(dev);
- struct ifnet *ifp = &lp->sc_if;
+ struct ifnet *ifp;
+
+ ifp = lp->sc_ifp = if_alloc(IFT_PARA);
+ if (ifp == NULL) {
+ return (ENOSPC);
+ }
ifp->if_softc = lp;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@@ -241,7 +246,6 @@ lp_attach (device_t dev)
IFF_NEEDSGIANT;
ifp->if_ioctl = lpioctl;
ifp->if_output = lpoutput;
- ifp->if_type = IFT_PARA;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
@@ -343,7 +347,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
return ENOBUFS;
}
- sc->sc_ifbuf = malloc(sc->sc_if.if_mtu + MLPIPHDRLEN,
+ sc->sc_ifbuf = malloc(sc->sc_ifp->if_mtu + MLPIPHDRLEN,
M_DEVBUF, M_WAITOK);
if (!sc->sc_ifbuf) {
ppb_release_bus(ppbus, dev);
@@ -371,11 +375,11 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
}
if (ptr)
free(ptr,M_DEVBUF);
- sc->sc_if.if_mtu = ifr->ifr_mtu;
+ sc->sc_ifp->if_mtu = ifr->ifr_mtu;
break;
case SIOCGIFMTU:
- ifr->ifr_mtu = sc->sc_if.if_mtu;
+ ifr->ifr_mtu = sc->sc_ifp->if_mtu;
break;
case SIOCADDMULTI:
@@ -465,7 +469,7 @@ lp_intr (void *arg)
s = splhigh();
- if (sc->sc_if.if_flags & IFF_LINK0) {
+ if (sc->sc_ifp->if_flags & IFF_LINK0) {
/* Ack. the request */
ppb_wdtr(ppbus, 0x01);
@@ -479,7 +483,7 @@ lp_intr (void *arg)
if (j == -1)
goto err;
len = len + (j << 8);
- if (len > sc->sc_if.if_mtu + MLPIPHDRLEN)
+ if (len > sc->sc_ifp->if_mtu + MLPIPHDRLEN)
goto err;
bp = sc->sc_ifbuf;
@@ -504,18 +508,18 @@ lp_intr (void *arg)
sc->sc_iferrs = 0;
len -= CLPIPHDRLEN;
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += len;
- top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0);
+ sc->sc_ifp->if_ipackets++;
+ sc->sc_ifp->if_ibytes += len;
+ top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp, 0);
if (top) {
- if (sc->sc_if.if_bpf)
- lptap(&sc->sc_if, top);
+ if (sc->sc_ifp->if_bpf)
+ lptap(sc->sc_ifp, top);
netisr_queue(NETISR_IP, top); /* mbuf is free'd on failure. */
}
goto done;
}
while ((ppb_rstr(ppbus) & LPIP_SHAKE)) {
- len = sc->sc_if.if_mtu + LPIPHDRLEN;
+ len = sc->sc_ifp->if_mtu + LPIPHDRLEN;
bp = sc->sc_ifbuf;
while (len--) {
@@ -549,12 +553,12 @@ lp_intr (void *arg)
sc->sc_iferrs = 0;
len -= LPIPHDRLEN;
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += len;
- top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0);
+ sc->sc_ifp->if_ipackets++;
+ sc->sc_ifp->if_ibytes += len;
+ top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp, 0);
if (top) {
- if (sc->sc_if.if_bpf)
- lptap(&sc->sc_if, top);
+ if (sc->sc_ifp->if_bpf)
+ lptap(sc->sc_ifp, top);
netisr_queue(NETISR_IP, top); /* mbuf is free'd on failure. */
}
}
@@ -563,7 +567,7 @@ lp_intr (void *arg)
err:
ppb_wdtr(ppbus, 0);
lprintf("R");
- sc->sc_if.if_ierrors++;
+ sc->sc_ifp->if_ierrors++;
sc->sc_iferrs++;
/*
@@ -573,7 +577,7 @@ lp_intr (void *arg)
if (sc->sc_iferrs > LPMAXERRS) {
printf("lp%d: Too many errors, Going off-line.\n", device_get_unit(dev));
ppb_wctr(ppbus, 0x00);
- sc->sc_if.if_flags &= ~IFF_RUNNING;
+ sc->sc_ifp->if_flags &= ~IFF_RUNNING;
sc->sc_iferrs=0;
}
diff --git a/sys/dev/ral/if_ral.c b/sys/dev/ral/if_ral.c
index 770c18d..2a25f92 100644
--- a/sys/dev/ral/if_ral.c
+++ b/sys/dev/ral/if_ral.c
@@ -342,7 +342,7 @@ int
ral_attach(device_t dev)
{
struct ral_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_arp.ac_if;
+ struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
int error, i;
@@ -393,7 +393,11 @@ ral_attach(device_t dev)
device_printf(sc->sc_dev, "could not allocate Rx ring\n");
goto fail5;
}
-
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(sc->sc_dev, "can not if_alloc()\n");
+ goto fail6;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -497,7 +501,7 @@ ral_attach(device_t dev)
ral_intr, sc, &sc->sc_ih);
if (error != 0) {
device_printf(dev, "could not set up interrupt\n");
- goto fail6;
+ goto fail7;
}
if (bootverbose)
@@ -505,8 +509,9 @@ ral_attach(device_t dev)
return 0;
-fail6: bpfdetach(ifp);
+fail7: bpfdetach(ifp);
ieee80211_ifdetach(ic);
+fail6: if_free(ifp);
ral_free_rx_ring(sc, &sc->rxq);
fail5: ral_free_tx_ring(sc, &sc->bcnq);
@@ -530,6 +535,7 @@ ral_detach(device_t dev)
bpfdetach(ifp);
ieee80211_ifdetach(ic);
+ if_free(ifp);
ral_free_tx_ring(sc, &sc->txq);
ral_free_tx_ring(sc, &sc->atimq);
diff --git a/sys/dev/ral/if_ralvar.h b/sys/dev/ral/if_ralvar.h
index c05a8b4..9bf024c 100644
--- a/sys/dev/ral/if_ralvar.h
+++ b/sys/dev/ral/if_ralvar.h
@@ -96,7 +96,7 @@ struct ral_node {
};
struct ral_softc {
- struct arpcom sc_arp;
+ struct ifnet *sc_ifp;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c
index 1dc21f3..2417671 100644
--- a/sys/dev/ray/if_ray.c
+++ b/sys/dev/ray/if_ray.c
@@ -266,6 +266,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net80211/ieee80211.h>
#include <net/if_llc.h>
+#include <net/if_types.h>
#include <dev/pccard/pccardvar.h>
#include "card_if.h"
@@ -442,28 +443,38 @@ ray_attach(device_t dev)
{
struct ray_softc *sc = device_get_softc(dev);
struct ray_ecf_startup_v5 *ep = &sc->sc_ecf_startup;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
size_t ccs;
int i, error;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
+
RAY_DPRINTF(sc, RAY_DBG_SUBR, "");
- if ((sc == NULL) || (sc->sc_gone))
+ if ((sc == NULL) || (sc->sc_gone)) {
+ if_free(ifp);
return (ENXIO);
+ }
/*
* Grab the resources I need
*/
error = ray_res_alloc_cm(sc);
- if (error)
+ if (error) {
+ if_free(ifp);
return (error);
+ }
error = ray_res_alloc_am(sc);
if (error) {
+ if_free(ifp);
ray_res_release(sc);
return (error);
}
error = ray_res_alloc_irq(sc);
if (error) {
+ if_free(ifp);
ray_res_release(sc);
return (error);
}
@@ -502,8 +513,6 @@ ray_attach(device_t dev)
/*
* Initialise the network interface structure
*/
- bcopy((char *)&ep->e_station_addr,
- (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_timer = 0;
@@ -574,7 +583,7 @@ static int
ray_detach(device_t dev)
{
struct ray_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ray_comq_entry *com;
int s;
@@ -595,6 +604,7 @@ ray_detach(device_t dev)
sc->sc_c.np_havenet = 0;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
ether_ifdetach(ifp);
+ if_free(ifp);
/*
* Stop the runq and wake up anyone sleeping for us.
@@ -816,7 +826,7 @@ ray_init_user(struct ray_softc *sc)
static void
ray_init_download(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STARTJOIN, "");
@@ -1034,7 +1044,7 @@ ray_init_download_done(struct ray_softc *sc, u_int8_t status, size_t ccs)
static void
ray_init_mcast(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STARTJOIN, "");
RAY_MAP_CM(sc);
@@ -1057,7 +1067,7 @@ ray_init_mcast(struct ray_softc *sc, struct ray_comq_entry *com)
static void
ray_init_sj(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ray_net_params np;
int update;
@@ -1112,7 +1122,7 @@ ray_init_sj(struct ray_softc *sc, struct ray_comq_entry *com)
static void
ray_init_sj_done(struct ray_softc *sc, u_int8_t status, size_t ccs)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STARTJOIN, "");
RAY_MAP_CM(sc);
@@ -1166,7 +1176,7 @@ ray_init_sj_done(struct ray_softc *sc, u_int8_t status, size_t ccs)
static void
ray_init_auth(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STARTJOIN | RAY_DBG_AUTH, "");
@@ -1220,7 +1230,7 @@ ray_init_auth_send(struct ray_softc *sc, u_int8_t *dst, int sequence)
IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_AUTH,
IEEE80211_FC1_DIR_NODS,
dst,
- sc->arpcom.ac_enaddr,
+ IFP2ENADDR(sc->ifp),
sc->sc_c.np_bss_id);
/* Add algorithm number */
@@ -1265,7 +1275,7 @@ ray_init_auth_done(struct ray_softc *sc, u_int8_t status)
static void
ray_init_assoc(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STARTJOIN, "");
@@ -1293,7 +1303,7 @@ ray_init_assoc(struct ray_softc *sc, struct ray_comq_entry *com)
static void
ray_init_assoc_done(struct ray_softc *sc, u_int8_t status, size_t ccs)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STARTJOIN, "");
RAY_COM_CHECK(sc, ccs);
@@ -1353,7 +1363,7 @@ ray_stop_user(struct ray_softc *sc)
static void
ray_stop(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *m;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_STOP, "");
@@ -1613,7 +1623,7 @@ static void
ray_tx_timo(void *xsc)
{
struct ray_softc *sc = (struct ray_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int s;
RAY_DPRINTF(sc, RAY_DBG_SUBR, "");
@@ -1728,7 +1738,7 @@ found:
static void
ray_tx_done(struct ray_softc *sc, u_int8_t status, size_t ccs)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_TX, "");
@@ -1751,7 +1761,7 @@ static void
ray_rx(struct ray_softc *sc, size_t rcs)
{
struct ieee80211_frame *header;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *m0;
size_t pktlen, fraglen, readlen, tmplen;
size_t bufp, ebufp;
@@ -1901,7 +1911,7 @@ skip_read:
static void
ray_rx_data(struct ray_softc *sc, struct mbuf *m0, u_int8_t siglev, u_int8_t antenna)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ieee80211_frame *header = mtod(m0, struct ieee80211_frame *);
struct llc *llc;
u_int8_t *sa = NULL, *da = NULL, *ra = NULL, *ta = NULL;
@@ -2081,7 +2091,7 @@ ray_rx_data(struct ray_softc *sc, struct mbuf *m0, u_int8_t siglev, u_int8_t ant
static void
ray_rx_mgt(struct ray_softc *sc, struct mbuf *m0)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ieee80211_frame *header = mtod(m0, struct ieee80211_frame *);
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_MGT, "");
@@ -2206,7 +2216,7 @@ RAY_DPRINTF(sc, RAY_DBG_MGT, "capability\t0x%x", IEEE80211_BEACON_CAPABILITY(bea
static void
ray_rx_mgt_info(struct ray_softc *sc, struct mbuf *m0, union ieee80211_information *elements)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ieee80211_frame *header = mtod(m0, struct ieee80211_frame *);
ieee80211_mgt_beacon_t beacon = (u_int8_t *)(header+1);
ieee80211_mgt_beacon_t bp, be;
@@ -2346,7 +2356,7 @@ ray_rx_mgt_auth(struct ray_softc *sc, struct mbuf *m0)
static void
ray_rx_ctl(struct ray_softc *sc, struct mbuf *m0)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ieee80211_frame *header = mtod(m0, struct ieee80211_frame *);
RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_CTL, "");
@@ -2450,7 +2460,7 @@ static void
ray_intr(void *xsc)
{
struct ray_softc *sc = (struct ray_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
size_t ccs;
u_int8_t cmd, status;
int ccsi;
@@ -2673,7 +2683,7 @@ ray_mcast_user(struct ray_softc *sc)
static void
ray_mcast(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ifmultiaddr *ifma;
size_t bufp;
int count = 0;
@@ -2746,7 +2756,7 @@ ray_mcast_done(struct ray_softc *sc, u_int8_t status, size_t ccs)
static void
ray_promisc(struct ray_softc *sc, struct ray_comq_entry *com)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
RAY_DPRINTF(sc, RAY_DBG_SUBR, "");
RAY_MAP_CM(sc);
diff --git a/sys/dev/ray/if_rayvar.h b/sys/dev/ray/if_rayvar.h
index fc3aae2..b2eb2b8 100644
--- a/sys/dev/ray/if_rayvar.h
+++ b/sys/dev/ray/if_rayvar.h
@@ -65,7 +65,7 @@ struct ray_nw_param {
struct ray_softc {
device_t dev; /* Device */
- struct arpcom arpcom; /* Ethernet common */
+ struct ifnet *ifp; /* Ethernet common */
struct callout_handle
tx_timerh; /* Handle for tx timer */
struct callout_handle
@@ -298,7 +298,7 @@ static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO;
#ifndef RAY_RECERR
#define RAY_RECERR(sc, fmt, args...) do { \
- struct ifnet *ifp = &(sc)->arpcom.ac_if; \
+ struct ifnet *ifp = (sc)->ifp; \
if (ifp->if_flags & IFF_DEBUG) { \
device_printf((sc)->dev, "%s(%d) " fmt "\n", \
__func__ , __LINE__ , ##args); \
@@ -308,7 +308,7 @@ static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO;
/* XXX this should be in CCSERR but don't work - probably need to use ##ifp->(iferrcounter)++; \*/
#ifndef RAY_CCSERR
#define RAY_CCSERR(sc, status, iferrcounter) do { \
- struct ifnet *ifp = &(sc)->arpcom.ac_if; \
+ struct ifnet *ifp = (sc)->ifp; \
char *ss[] = RAY_CCS_STATUS_STRINGS; \
if ((status) != RAY_CCS_STATUS_COMPLETE) { \
if (ifp->if_flags & IFF_DEBUG) { \
diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c
index ea52ef3..fc84ea9 100644
--- a/sys/dev/re/if_re.c
+++ b/sys/dev/re/if_re.c
@@ -123,6 +123,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_vlan_var.h>
#include <net/bpf.h>
@@ -583,7 +584,7 @@ re_setmulti(sc)
RL_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
rxfilt = CSR_READ_4(sc, RL_RXCFG);
@@ -667,7 +668,7 @@ static int
re_diag(sc)
struct rl_softc *sc;
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
struct mbuf *m0;
struct ether_header *eh;
struct rl_desc *cur_rx;
@@ -1154,7 +1155,6 @@ re_attach(dev)
}
sc->rl_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/*
* Allocate the parent bus DMA tag appropriate for PCI.
@@ -1186,7 +1186,12 @@ re_attach(dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("re%d: can not if_alloc()\n", sc->rl_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1224,6 +1229,7 @@ re_attach(dev)
printf("re%d: attach aborted due to hardware diag failure\n",
unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -1233,6 +1239,7 @@ re_attach(dev)
if (error) {
printf("re%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
}
fail:
@@ -1259,13 +1266,15 @@ re_detach(dev)
int attached;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
KASSERT(mtx_initialized(&sc->rl_mtx), ("re mutex not initialized"));
attached = device_is_attached(dev);
/* These should only be active if attach succeeded */
if (attached)
ether_ifdetach(ifp);
+ if (ifp == NULL)
+ if_free(ifp);
RL_LOCK(sc);
#if 0
@@ -1501,7 +1510,7 @@ re_rxeof(sc)
RL_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
i = sc->rl_ldata.rl_rx_prodidx;
/* Invalidate the descriptor memory */
@@ -1674,7 +1683,7 @@ re_txeof(sc)
u_int32_t txstat;
int idx;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
idx = sc->rl_ldata.rl_tx_considx;
/* Invalidate the TX descriptor list */
@@ -1825,7 +1834,7 @@ re_intr(arg)
RL_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
if (sc->suspended || !(ifp->if_flags & IFF_UP))
goto done_locked;
@@ -1970,7 +1979,7 @@ re_encap(sc, m_head, idx)
* transmission attempt.
*/
- mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, *m_head);
+ mtag = VLAN_OUTPUT_TAG(sc->rl_ifp, *m_head);
if (mtag != NULL)
sc->rl_ldata.rl_tx_list[*idx].rl_vlanctl =
htole32(htons(VLAN_TAG_VALUE(mtag)) | RL_TDESC_VLANCTL_TAG);
@@ -2090,7 +2099,7 @@ static void
re_init_locked(sc)
struct rl_softc *sc;
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
struct mii_data *mii;
u_int32_t rxcfg = 0;
@@ -2121,9 +2130,9 @@ re_init_locked(sc)
*/
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_WRITECFG);
CSR_WRITE_STREAM_4(sc, RL_IDR0,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
+ *(u_int32_t *)(&IFP2ENADDR(sc->rl_ifp)[0]));
CSR_WRITE_STREAM_4(sc, RL_IDR4,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
+ *(u_int32_t *)(&IFP2ENADDR(sc->rl_ifp)[4]));
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
/*
@@ -2373,7 +2382,7 @@ re_stop(sc)
RL_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
ifp->if_timer = 0;
untimeout(re_tick, sc, sc->rl_stat_ch);
@@ -2450,7 +2459,7 @@ re_resume(dev)
RL_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
/* reinitialize interface if necessary */
if (ifp->if_flags & IFF_UP)
diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c
index c5228b3..8c40084 100644
--- a/sys/dev/sbni/if_sbni.c
+++ b/sys/dev/sbni/if_sbni.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_arp.h>
#include <net/bpf.h>
+#include <net/if_types.h>
#include <dev/sbni/if_sbnireg.h>
#include <dev/sbni/if_sbnivar.h>
@@ -221,7 +222,9 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
struct ifnet *ifp;
u_char csr0;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ panic("sbni%d: can not if_alloc()", unit);
sbni_outb(sc, CSR0, 0);
set_initial_values(sc, flags);
@@ -242,7 +245,7 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
IFF_NEEDSGIANT;
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
/* device attach does transition from UNCONFIGURED to IDLE state */
if_printf(ifp, "speed %ld, rxl ", ifp->if_baudrate);
@@ -262,7 +265,7 @@ sbni_init(void *xsc)
int s;
sc = (struct sbni_softc *)xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
/*
* kludge to avoid multiple initialization when more than once
@@ -556,7 +559,7 @@ upload_data(struct sbni_softc *sc, u_int framelen, u_int frameno,
} else if ((frame_ok = skip_tail(sc, framelen, crc)) != 0) {
sc->wait_frameno = 0;
sc->inppos = 0;
- sc->arpcom.ac_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
/* now skip all frames until is_first != 0 */
}
} else
@@ -568,7 +571,7 @@ upload_data(struct sbni_softc *sc, u_int framelen, u_int frameno,
* is_first already... Drop entire packet.
*/
sc->wait_frameno = 0;
- sc->arpcom.ac_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
}
return (frame_ok);
@@ -582,7 +585,7 @@ send_complete(struct sbni_softc *sc)
{
m_freem(sc->tx_buf_p);
sc->tx_buf_p = NULL;
- sc->arpcom.ac_if.if_opackets++;
+ sc->ifp->if_opackets++;
}
@@ -633,7 +636,7 @@ append_frame_to_pkt(struct sbni_softc *sc, u_int framelen, u_int32_t crc)
sc->inppos += framelen - 4;
if (--sc->wait_frameno == 0) { /* last frame received */
indicate_pkt(sc);
- sc->arpcom.ac_if.if_ipackets++;
+ sc->ifp->if_ipackets++;
}
return (1);
@@ -660,13 +663,13 @@ prepare_to_send(struct sbni_softc *sc)
sc->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND);
for (;;) {
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, sc->tx_buf_p);
+ IF_DEQUEUE(&sc->ifp->if_snd, sc->tx_buf_p);
if (!sc->tx_buf_p) {
/* nothing to transmit... */
sc->pktlen = 0;
sc->tx_frameno = 0;
sc->framelen = 0;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
return;
}
@@ -686,8 +689,8 @@ prepare_to_send(struct sbni_softc *sc)
sc->framelen = min(len, sc->maxframe);
sbni_outb(sc, CSR0, sbni_inb(sc, CSR0) | TR_REQ);
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
- BPF_MTAP(&sc->arpcom.ac_if, sc->tx_buf_p);
+ sc->ifp->if_flags |= IFF_OACTIVE;
+ BPF_MTAP(sc->ifp, sc->tx_buf_p);
}
@@ -699,22 +702,22 @@ drop_xmit_queue(struct sbni_softc *sc)
if (sc->tx_buf_p) {
m_freem(sc->tx_buf_p);
sc->tx_buf_p = NULL;
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
}
for (;;) {
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
if (m == NULL)
break;
m_freem(m);
- sc->arpcom.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
}
sc->tx_frameno = 0;
sc->framelen = 0;
sc->outpos = 0;
sc->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND);
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
}
@@ -810,7 +813,7 @@ get_rx_buf(struct sbni_softc *sc)
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
- if_printf(&sc->arpcom.ac_if, "cannot allocate header mbuf\n");
+ if_printf(sc->ifp, "cannot allocate header mbuf\n");
return (0);
}
@@ -844,7 +847,7 @@ get_rx_buf(struct sbni_softc *sc)
static void
indicate_pkt(struct sbni_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *m;
m = sc->rx_buf_p;
@@ -953,13 +956,13 @@ set_initial_values(struct sbni_softc *sc, struct sbni_flags flags)
/*
* generate Ethernet address (0x00ff01xxxxxx)
*/
- *(u_int16_t *) sc->arpcom.ac_enaddr = htons(0x00ff);
+ *(u_int16_t *) sc->enaddr = htons(0x00ff);
if (flags.mac_addr) {
- *(u_int32_t *) (sc->arpcom.ac_enaddr + 2) =
+ *(u_int32_t *) (sc->enaddr + 2) =
htonl(flags.mac_addr | 0x01000000);
} else {
- *(u_char *) (sc->arpcom.ac_enaddr + 2) = 0x01;
- read_random(sc->arpcom.ac_enaddr + 3, 3);
+ *(u_char *) (sc->enaddr + 2) = 0x01;
+ read_random(sc->enaddr + 3, 3);
}
}
@@ -1091,7 +1094,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
* SBNI specific ioctl
*/
case SIOCGHWFLAGS: /* get flags */
- bcopy((caddr_t) sc->arpcom.ac_enaddr+3, (caddr_t) &flags, 3);
+ bcopy((caddr_t)IFP2ENADDR(sc->ifp)+3, (caddr_t) &flags, 3);
flags.rxl = sc->cur_rxl_index;
flags.rate = sc->csr1.rate;
flags.fixed_rxl = (sc->delta_rxl == 0);
@@ -1122,7 +1125,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
sc->csr1.rate = flags.fixed_rate ? flags.rate : DEFAULT_RATE;
if (flags.mac_addr)
bcopy((caddr_t) &flags,
- (caddr_t) sc->arpcom.ac_enaddr+3, 3);
+ (caddr_t) IFP2ENADDR(sc->ifp)+3, 3);
/* Don't be afraid... */
sbni_outb(sc, CSR1, *(char*)(&sc->csr1) | PR_RES);
diff --git a/sys/dev/sbni/if_sbni_isa.c b/sys/dev/sbni/if_sbni_isa.c
index 956882a..3565829 100644
--- a/sys/dev/sbni/if_sbni_isa.c
+++ b/sys/dev/sbni/if_sbni_isa.c
@@ -157,7 +157,7 @@ sbni_attach_isa(device_t dev)
return (ENXIO);
} else {
printf(" shared irq with %s\n",
- master->arpcom.ac_if.if_xname);
+ master->ifp->if_xname);
}
}
#endif /* SBNI_DUAL_COMPOUND */
diff --git a/sys/dev/sbni/if_sbnivar.h b/sys/dev/sbni/if_sbnivar.h
index 0fe2f09..91fb363 100644
--- a/sys/dev/sbni/if_sbnivar.h
+++ b/sys/dev/sbni/if_sbnivar.h
@@ -67,7 +67,8 @@ struct sbni_flags {
#ifdef _KERNEL /* to avoid compile this decls with sbniconfig */
struct sbni_softc {
- struct arpcom arpcom; /* ethernet common */
+ struct ifnet *ifp;
+ u_char enaddr[6];
int io_rid;
struct resource *io_res;
diff --git a/sys/dev/sbsh/if_sbsh.c b/sys/dev/sbsh/if_sbsh.c
index cf82619..a2ecf93 100644
--- a/sys/dev/sbsh/if_sbsh.c
+++ b/sys/dev/sbsh/if_sbsh.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -96,7 +97,7 @@ struct cx28975_cmdarea {
#define RQLEN 8
struct sbsh_softc {
- struct arpcom arpcom; /* ethernet common */
+ struct ifnet *ifp;
struct resource *mem_res;
struct resource *irq_res;
@@ -222,6 +223,7 @@ sbsh_attach(device_t dev)
struct sbsh_softc *sc;
struct ifnet *ifp;
int unit, error = 0, rid, s;
+ u_char eaddr[6];
s = splimp();
@@ -264,10 +266,18 @@ sbsh_attach(device_t dev)
}
/* generate ethernet MAC address */
- *(u_int32_t *)sc->arpcom.ac_enaddr = htonl(0x00ff0192);
- read_random(sc->arpcom.ac_enaddr + 4, 2);
+ *(u_int32_t *)eaddr = htonl(0x00ff0192);
+ read_random(eaddr + 4, 2);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ PCIR_BAR(1), sc->mem_res);
+ bus_teardown_intr(dev, sc->irq_res, sc->intr_hand);
+ printf("sbsh%d: can not if_alloc()\n", unit);
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -279,7 +289,7 @@ sbsh_attach(device_t dev)
ifp->if_baudrate = 4600000;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
fail:
splx(s);
@@ -296,10 +306,11 @@ sbsh_detach(device_t dev)
s = splimp();
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
sbsh_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
bus_teardown_intr(dev, sc->irq_res, sc->intr_hand);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
@@ -329,7 +340,7 @@ static void
sbsh_init(void *xsc)
{
struct sbsh_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int s;
u_int8_t t;
@@ -421,11 +432,11 @@ sbsh_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (start_cx28975(sc, cfg) == 0) {
static char *modstr[] = {
"TCPAM32", "TCPAM16", "TCPAM8", "TCPAM4" };
- if_printf(&sc->arpcom.ac_if, "%s, rate %d, %s\n",
+ if_printf(sc->ifp, "%s, rate %d, %s\n",
cfg.master ? "master" : "slave",
cfg.lrate << 3, modstr[cfg.mod]);
} else {
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->ifp,
"unable to load firmware\n");
error = EIO;
}
@@ -535,7 +546,7 @@ sbsh_resume(device_t dev)
int s;
s = splimp();
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (ifp->if_flags & IFF_UP)
sbsh_init(sc);
@@ -579,7 +590,7 @@ sbsh_intr(void *arg)
resume_tx(sc);
sc->regs->SR = UFL;
++sc->in_stats.ufl_errs;
- ++sc->arpcom.ac_if.if_oerrors;
+ ++sc->ifp->if_oerrors;
}
if (status & RXS) {
@@ -595,13 +606,13 @@ sbsh_intr(void *arg)
if (status & CRC) {
++sc->in_stats.crc_errs;
- ++sc->arpcom.ac_if.if_ierrors;
+ ++sc->ifp->if_ierrors;
sc->regs->SR = CRC;
}
if (status & OFL) {
++sc->in_stats.ofl_errs;
- ++sc->arpcom.ac_if.if_ierrors;
+ ++sc->ifp->if_ierrors;
sc->regs->SR = OFL;
}
}
@@ -625,7 +636,7 @@ resume_tx(struct sbsh_softc *sc)
static void
start_xmit_frames(struct sbsh_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *m;
/*
@@ -697,7 +708,7 @@ look_for_nonzero:
sc->regs->LTDR = cur_tbd;
++sc->in_stats.sent_pkts;
- ++sc->arpcom.ac_if.if_opackets;
+ ++sc->ifp->if_opackets;
}
static struct mbuf *
@@ -707,7 +718,7 @@ repack(struct sbsh_softc *sc, struct mbuf *m)
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
if (!m_new) {
- if_printf (&sc->arpcom.ac_if,
+ if_printf (sc->ifp,
"unable to get mbuf.\n");
return (NULL);
}
@@ -716,7 +727,7 @@ repack(struct sbsh_softc *sc, struct mbuf *m)
MCLGET(m_new, M_DONTWAIT);
if (!(m_new->m_flags & M_EXT)) {
m_freem(m_new);
- if_printf (&sc->arpcom.ac_if,
+ if_printf (sc->ifp,
"unable to get mbuf cluster.\n");
return (NULL);
}
@@ -764,7 +775,7 @@ alloc_rx_buffers(struct sbsh_softc *sc)
while (sc->tail_rq != ((sc->head_rq - 1) & (RQLEN - 1))) {
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (!m) {
- if_printf (&sc->arpcom.ac_if,
+ if_printf (sc->ifp,
"unable to get mbuf.\n");
return;
}
@@ -773,7 +784,7 @@ alloc_rx_buffers(struct sbsh_softc *sc)
MCLGET(m, M_DONTWAIT);
if (!(m->m_flags & M_EXT)) {
m_freem(m);
- if_printf (&sc->arpcom.ac_if,
+ if_printf (sc->ifp,
"unable to get mbuf cluster.\n");
return;
}
@@ -802,11 +813,11 @@ indicate_frames(struct sbsh_softc *sc)
m->m_pkthdr.len = m->m_len =
sc->rbd[sc->head_rdesc].length & 0x7ff;
- m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ m->m_pkthdr.rcvif = sc->ifp;
- (*sc->arpcom.ac_if.if_input)(&sc->arpcom.ac_if, m);
+ (*sc->ifp->if_input)(sc->ifp, m);
++sc->in_stats.rcvd_pkts;
- ++sc->arpcom.ac_if.if_ipackets;
+ ++sc->ifp->if_ipackets;
sc->head_rdesc = (sc->head_rdesc + 1) & 0x7f;
}
@@ -879,11 +890,11 @@ cx28975_interrupt(struct sbsh_softc *sc)
if (sc->state != ACTIVE
&& (*((volatile u_int8_t *)p + 0x3c0) & 0xc0) == 0x40) {
activate(sc);
- if_printf(&sc->arpcom.ac_if, "connected to peer\n");
+ if_printf(sc->ifp, "connected to peer\n");
} else if (sc->state == ACTIVE
&& (*((volatile u_int8_t *)p + 0x3c0) & 0xc0) != 0x40) {
deactivate(sc);
- if_printf(&sc->arpcom.ac_if, "carrier lost\n");
+ if_printf(sc->ifp, "carrier lost\n");
}
}
diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c
index 5593d52..85d6819 100644
--- a/sys/dev/sf/if_sf.c
+++ b/sys/dev/sf/if_sf.c
@@ -93,6 +93,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -415,7 +416,7 @@ sf_setmulti(sc)
struct ifmultiaddr *ifma;
u_int8_t dummy[] = { 0, 0, 0, 0, 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
/* First zot all the existing filters. */
for (i = 1; i < SF_RXFILT_PERFECT_CNT; i++)
@@ -641,6 +642,7 @@ sf_attach(dev)
struct sf_softc *sc;
struct ifnet *ifp;
int unit, rid, error = 0;
+ u_char eaddr[6];
sc = device_get_softc(dev);
unit = device_get_unit(dev);
@@ -683,7 +685,7 @@ sf_attach(dev)
* Get station address from the EEPROM.
*/
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] =
+ eaddr[i] =
sf_read_eeprom(sc, SF_EE_NODEADDR + ETHER_ADDR_LEN - i);
sc->sf_unit = unit;
@@ -708,7 +710,12 @@ sf_attach(dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("sf%d: can not if_alloc()\n", sc->sf_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -730,7 +737,7 @@ sf_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* Hook interrupt last to avoid having to lock softc */
error = bus_setup_intr(dev, sc->sf_irq, INTR_TYPE_NET,
@@ -739,6 +746,7 @@ sf_attach(dev)
if (error) {
printf("sf%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -766,12 +774,13 @@ sf_detach(dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->sf_mtx), ("sf mutex not initialized"));
SF_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
sf_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->sf_miibus)
device_delete_child(dev, sc->sf_miibus);
@@ -904,7 +913,7 @@ sf_rxeof(sc)
SF_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
rxcons = csr_read_4(sc, SF_CQ_CONSIDX);
rxprod = csr_read_4(sc, SF_RXDQ_PTR_Q1);
@@ -973,7 +982,7 @@ sf_txeof(sc)
struct sf_tx_bufdesc_type0 *cur_tx;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
txcons = csr_read_4(sc, SF_CQ_CONSIDX);
cmpprodidx = SF_IDX_HI(csr_read_4(sc, SF_CQ_PRODIDX));
@@ -1098,7 +1107,7 @@ sf_intr(arg)
sc = arg;
SF_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING)
@@ -1173,7 +1182,7 @@ sf_init(xsc)
sc = xsc;
SF_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
mii = device_get_softc(sc->sf_miibus);
sf_stop(sc);
@@ -1190,9 +1199,9 @@ sf_init(xsc)
(i + sizeof(u_int32_t)), 0);
/* Init our MAC address */
- csr_write_4(sc, SF_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- csr_write_4(sc, SF_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
- sf_setperf(sc, 0, (caddr_t)&sc->arpcom.ac_enaddr);
+ csr_write_4(sc, SF_PAR0, *(u_int32_t *)(&IFP2ENADDR(sc->sf_ifp)[0]));
+ csr_write_4(sc, SF_PAR1, *(u_int32_t *)(&IFP2ENADDR(sc->sf_ifp)[4]));
+ sf_setperf(sc, 0, (caddr_t)&IFP2ENADDR(sc->sf_ifp));
if (sf_init_rx_ring(sc) == ENOBUFS) {
printf("sf%d: initialization failed: no "
@@ -1435,7 +1444,7 @@ sf_stop(sc)
SF_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
untimeout(sf_stats_update, sc, sc->sf_stat_ch);
@@ -1494,7 +1503,7 @@ sf_stats_update(xsc)
sc = xsc;
SF_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sf_ifp;
mii = device_get_softc(sc->sf_miibus);
ptr = (u_int32_t *)&stats;
diff --git a/sys/dev/sf/if_sfreg.h b/sys/dev/sf/if_sfreg.h
index 4738f46..bbd704c 100644
--- a/sys/dev/sf/if_sfreg.h
+++ b/sys/dev/sf/if_sfreg.h
@@ -1031,7 +1031,7 @@ struct sf_list_data {
};
struct sf_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *sf_ifp; /* interface info */
bus_space_handle_t sf_bhandle; /* bus space handle */
bus_space_tag_t sf_btag; /* bus space tag */
void *sf_intrhand; /* interrupt handler cookie */
diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c
index 1703e2f..bcc4b03 100644
--- a/sys/dev/sk/if_sk.c
+++ b/sys/dev/sk/if_sk.c
@@ -101,6 +101,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -790,7 +791,7 @@ sk_setmulti(sc_if)
struct sk_if_softc *sc_if;
{
struct sk_softc *sc = sc_if->sk_softc;
- struct ifnet *ifp = &sc_if->arpcom.ac_if;
+ struct ifnet *ifp = sc_if->sk_ifp;
u_int32_t hashes[2] = { 0, 0 };
int h = 0, i;
struct ifmultiaddr *ifma;
@@ -881,7 +882,7 @@ sk_setpromisc(sc_if)
struct sk_if_softc *sc_if;
{
struct sk_softc *sc = sc_if->sk_softc;
- struct ifnet *ifp = &sc_if->arpcom.ac_if;
+ struct ifnet *ifp = sc_if->sk_ifp;
switch(sc->sk_type) {
case SK_GENESIS:
@@ -1400,6 +1401,7 @@ sk_attach(dev)
struct sk_if_softc *sc_if;
struct ifnet *ifp;
int i, port, error;
+ u_char eaddr[6];
if (dev == NULL)
return(EINVAL);
@@ -1437,7 +1439,12 @@ sk_attach(dev)
goto fail;
}
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("sk%d: can not if_alloc()\n", sc_if->sk_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc_if;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1464,7 +1471,7 @@ sk_attach(dev)
*/
SK_LOCK(sc);
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc_if->arpcom.ac_enaddr[i] =
+ eaddr[i] =
sk_win_read_1(sc, SK_MAC0_0 + (port * 8) + i);
/*
@@ -1517,6 +1524,7 @@ sk_attach(dev)
sc->sk_unit, sc_if->sk_phytype);
error = ENODEV;
SK_UNLOCK(sc);
+ if_free(ifp);
goto fail;
}
@@ -1525,7 +1533,7 @@ sk_attach(dev)
* Call MI attach routine. Can't hold locks when calling into ether_*.
*/
SK_UNLOCK(sc);
- ether_ifattach(ifp, sc_if->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
SK_LOCK(sc);
/*
@@ -1547,6 +1555,7 @@ sk_attach(dev)
sk_ifmedia_upd, sk_ifmedia_sts)) {
printf("skc%d: no PHY found!\n", sc_if->sk_unit);
ether_ifdetach(ifp);
+ if_free(ifp);
error = ENXIO;
goto fail;
}
@@ -1892,13 +1901,14 @@ sk_detach(dev)
("sk mutex not initialized in sk_detach"));
SK_IF_LOCK(sc_if);
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
/* These should only be active if attach_xmac succeeded */
if (device_is_attached(dev)) {
sk_stop(sc_if);
/* Can't hold locks while calling detach */
SK_IF_UNLOCK(sc_if);
ether_ifdetach(ifp);
+ if_free(ifp);
SK_IF_LOCK(sc_if);
}
/*
@@ -2115,7 +2125,7 @@ sk_rxeof(sc_if)
u_int32_t rxstat;
sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
i = sc_if->sk_cdata.sk_rx_prod;
cur_rx = &sc_if->sk_cdata.sk_rx_chain[i];
@@ -2182,7 +2192,7 @@ sk_txeof(sc_if)
u_int32_t idx;
sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
/*
* Go through our tx ring and free mbufs for those
@@ -2225,7 +2235,7 @@ sk_tick(xsc_if)
sc_if = xsc_if;
SK_IF_LOCK(sc_if);
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
mii = device_get_softc(sc_if->sk_miibus);
if (!(ifp->if_flags & IFF_UP)) {
@@ -2275,7 +2285,7 @@ sk_intr_bcom(sc_if)
struct ifnet *ifp;
int status;
mii = device_get_softc(sc_if->sk_miibus);
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
SK_XM_CLRBIT_2(sc_if, XM_MMUCMD, XM_MMUCMD_TX_ENB|XM_MMUCMD_RX_ENB);
@@ -2383,9 +2393,9 @@ sk_intr(xsc)
sc_if1 = sc->sk_if[SK_PORT_B];
if (sc_if0 != NULL)
- ifp0 = &sc_if0->arpcom.ac_if;
+ ifp0 = sc_if0->sk_ifp;
if (sc_if1 != NULL)
- ifp1 = &sc_if1->arpcom.ac_if;
+ ifp1 = sc_if1->sk_ifp;
for (;;) {
status = CSR_READ_4(sc, SK_ISSR);
@@ -2466,7 +2476,7 @@ sk_init_xmac(sc_if)
{ 0, 0 } };
sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
/* Unreset the XMAC. */
SK_IF_WRITE_2(sc_if, 0, SK_TXF1_MACCTL, SK_TXMACCTL_XMAC_UNRESET);
@@ -2522,11 +2532,11 @@ sk_init_xmac(sc_if)
/* Set station address */
SK_XM_WRITE_2(sc_if, XM_PAR0,
- *(u_int16_t *)(&sc_if->arpcom.ac_enaddr[0]));
+ *(u_int16_t *)(&IFP2ENADDR(sc_if->sk_ifp)[0]));
SK_XM_WRITE_2(sc_if, XM_PAR1,
- *(u_int16_t *)(&sc_if->arpcom.ac_enaddr[2]));
+ *(u_int16_t *)(&IFP2ENADDR(sc_if->sk_ifp)[2]));
SK_XM_WRITE_2(sc_if, XM_PAR2,
- *(u_int16_t *)(&sc_if->arpcom.ac_enaddr[4]));
+ *(u_int16_t *)(&IFP2ENADDR(sc_if->sk_ifp)[4]));
SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_RX_USE_STATION);
if (ifp->if_flags & IFF_BROADCAST) {
@@ -2629,7 +2639,7 @@ sk_init_yukon(sc_if)
int i;
sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
if (sc->sk_type == SK_YUKON_LITE &&
sc->sk_rev == SK_YUKON_LITE_REV_A3) {
@@ -2697,8 +2707,8 @@ sk_init_yukon(sc_if)
for (i = 0; i < 3; i++) {
/* Write Source Address 1 (unicast filter) */
SK_YU_WRITE_2(sc_if, YUKON_SAL1 + i * 4,
- sc_if->arpcom.ac_enaddr[i * 2] |
- sc_if->arpcom.ac_enaddr[i * 2 + 1] << 8);
+ IFP2ENADDR(sc_if->sk_ifp)[i * 2] |
+ IFP2ENADDR(sc_if->sk_ifp)[i * 2 + 1] << 8);
}
for (i = 0; i < 3; i++) {
@@ -2744,7 +2754,7 @@ sk_init(xsc)
SK_IF_LOCK(sc_if);
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
sc = sc_if->sk_softc;
mii = device_get_softc(sc_if->sk_miibus);
@@ -2895,7 +2905,7 @@ sk_stop(sc_if)
SK_IF_LOCK(sc_if);
sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
+ ifp = sc_if->sk_ifp;
untimeout(sk_tick, sc_if, sc_if->sk_tick_ch);
diff --git a/sys/dev/sk/if_skreg.h b/sys/dev/sk/if_skreg.h
index 9b91625..e8b6b8a 100644
--- a/sys/dev/sk/if_skreg.h
+++ b/sys/dev/sk/if_skreg.h
@@ -1461,7 +1461,7 @@ struct sk_softc {
/* Softc for each logical interface */
struct sk_if_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *sk_ifp; /* interface info */
device_t sk_miibus;
u_int8_t sk_unit; /* interface number */
u_int8_t sk_port; /* port # on controller */
diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c
index 07cefd5..0411995 100644
--- a/sys/dev/sn/if_sn.c
+++ b/sys/dev/sn/if_sn.c
@@ -132,7 +132,7 @@ static void snstop(struct sn_softc *);
static void snwatchdog(struct ifnet *);
static void sn_setmcast(struct sn_softc *);
-static int sn_getmcf(struct arpcom *ac, u_char *mcf);
+static int sn_getmcf(struct ifnet *ifp, u_char *mcf);
/* I (GB) have been unlucky getting the hardware padding
* to work properly.
@@ -155,13 +155,20 @@ int
sn_attach(device_t dev)
{
struct sn_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
uint16_t i, w;
uint8_t *p;
int rev;
uint16_t address;
int j;
int err;
+ u_char eaddr[6];
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
sc->dev = dev;
sn_activate(dev);
@@ -182,8 +189,8 @@ sn_attach(device_t dev)
if (sc->pccard_enaddr)
for (j = 0; j < 3; j++) {
- w = (uint16_t)sc->arpcom.ac_enaddr[j * 2] |
- (((uint16_t)sc->arpcom.ac_enaddr[j * 2 + 1]) << 8);
+ w = (uint16_t)eaddr[j * 2] |
+ (((uint16_t)eaddr[j * 2 + 1]) << 8);
CSR_WRITE_2(sc, IAR_ADDR0_REG_W + j * 2, w);
}
@@ -192,7 +199,7 @@ sn_attach(device_t dev)
* regs 4 - 9
*/
SMC_SELECT_BANK(sc, 1);
- p = (uint8_t *) &sc->arpcom.ac_enaddr;
+ p = (uint8_t *) eaddr;
for (i = 0; i < 6; i += 2) {
address = CSR_READ_2(sc, IAR_ADDR0_REG_W + i);
p[i + 1] = address >> 8;
@@ -209,7 +216,7 @@ sn_attach(device_t dev)
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_timer = 0;
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/*
* Activate the interrupt so we can get card interrupts. This
@@ -228,11 +235,13 @@ sn_attach(device_t dev)
int
sn_detach(device_t dev)
{
- struct sn_softc *sc = device_get_softc(dev);
+ struct sn_softc *sc = device_get_softc(dev);
+ struct ifnet *ifp = sc->ifp;
snstop(sc);
- sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
- ether_ifdetach(&sc->arpcom.ac_if);
+ ifp->if_flags &= ~IFF_RUNNING;
+ ether_ifdetach(ifp);
+ if_free(ifp);
sn_deactivate(dev);
SN_LOCK_DESTORY(sc);
return 0;
@@ -254,7 +263,7 @@ static void
sninit_locked(void *xsc)
{
struct sn_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int flags;
int mask;
@@ -372,7 +381,7 @@ snstart_locked(struct ifnet *ifp)
SN_ASSERT_LOCKED(sc);
- if (sc->arpcom.ac_if.if_flags & IFF_OACTIVE)
+ if (sc->ifp->if_flags & IFF_OACTIVE)
return;
if (sc->pages_wanted != -1) {
if_printf(ifp, "snstart() while memory allocation pending\n");
@@ -383,7 +392,7 @@ startagain:
/*
* Sneak a peek at the next packet
*/
- m = sc->arpcom.ac_if.if_snd.ifq_head;
+ m = sc->ifp->if_snd.ifq_head;
if (m == 0)
return;
/*
@@ -401,8 +410,8 @@ startagain:
*/
if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) {
if_printf(ifp, "large packet discarded (A)\n");
- ++sc->arpcom.ac_if.if_oerrors;
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
+ ++sc->ifp->if_oerrors;
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
m_freem(m);
goto readcheck;
}
@@ -459,8 +468,8 @@ startagain:
CSR_WRITE_1(sc, INTR_MASK_REG_B, mask);
sc->intr_mask = mask;
- sc->arpcom.ac_if.if_timer = 1;
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
+ sc->ifp->if_timer = 1;
+ sc->ifp->if_flags |= IFF_OACTIVE;
sc->pages_wanted = numPages;
return;
}
@@ -495,7 +504,7 @@ startagain:
* Get the packet from the kernel. This will include the Ethernet
* frame header, MAC Addresses etc.
*/
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
/*
* Push out the data to the card.
@@ -543,12 +552,12 @@ startagain:
CSR_WRITE_2(sc, MMU_CMD_REG_W, MMUCR_ENQUEUE);
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
- sc->arpcom.ac_if.if_timer = 1;
+ sc->ifp->if_flags |= IFF_OACTIVE;
+ sc->ifp->if_timer = 1;
BPF_MTAP(ifp, top);
- sc->arpcom.ac_if.if_opackets++;
+ sc->ifp->if_opackets++;
m_freem(top);
@@ -597,7 +606,7 @@ snresume(struct ifnet *ifp)
/*
* Sneak a peek at the next packet
*/
- m = sc->arpcom.ac_if.if_snd.ifq_head;
+ m = sc->ifp->if_snd.ifq_head;
if (m == 0) {
if_printf(ifp, "snresume() with nothing to send\n");
return;
@@ -617,8 +626,8 @@ snresume(struct ifnet *ifp)
*/
if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) {
if_printf(ifp, "large packet discarded (B)\n");
- ++sc->arpcom.ac_if.if_oerrors;
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
+ ++sc->ifp->if_oerrors;
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
m_freem(m);
return;
}
@@ -653,7 +662,7 @@ snresume(struct ifnet *ifp)
packet_no = CSR_READ_1(sc, ALLOC_RESULT_REG_B);
if (packet_no & ARR_FAILED) {
if_printf(ifp, "Memory allocation failed. Weird.\n");
- sc->arpcom.ac_if.if_timer = 1;
+ sc->ifp->if_timer = 1;
goto try_start;
}
/*
@@ -694,7 +703,7 @@ snresume(struct ifnet *ifp)
* Get the packet from the kernel. This will include the Ethernet
* frame header, MAC Addresses etc.
*/
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
+ IF_DEQUEUE(&sc->ifp->if_snd, m);
/*
* Push out the data to the card.
@@ -742,7 +751,7 @@ snresume(struct ifnet *ifp)
BPF_MTAP(ifp, top);
- sc->arpcom.ac_if.if_opackets++;
+ sc->ifp->if_opackets++;
m_freem(top);
try_start:
@@ -750,15 +759,15 @@ try_start:
/*
* Now pass control to snstart() to queue any additional packets
*/
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
snstart(ifp);
/*
* We've sent something, so we're active. Set a watchdog in case the
* TX_EMPTY interrupt is lost.
*/
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
- sc->arpcom.ac_if.if_timer = 1;
+ sc->ifp->if_flags |= IFF_OACTIVE;
+ sc->ifp->if_timer = 1;
return;
}
@@ -769,7 +778,7 @@ sn_intr(void *arg)
{
int status, interrupts;
struct sn_softc *sc = (struct sn_softc *) arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
/*
* Chip state registers
@@ -816,7 +825,7 @@ sn_intr(void *arg)
SMC_SELECT_BANK(sc, 2);
CSR_WRITE_1(sc, INTR_ACK_REG_B, IM_RX_OVRN_INT);
- ++sc->arpcom.ac_if.if_ierrors;
+ ++sc->ifp->if_ierrors;
}
/*
* Got a packet.
@@ -844,8 +853,8 @@ sn_intr(void *arg)
* Disable this interrupt.
*/
mask &= ~IM_ALLOC_INT;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- snresume(&sc->arpcom.ac_if);
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ snresume(sc->ifp);
}
/*
* TX Completion. Handle a transmit error message. This will only be
@@ -882,11 +891,11 @@ sn_intr(void *arg)
device_printf(sc->dev,
"Successful packet caused interrupt\n");
} else {
- ++sc->arpcom.ac_if.if_oerrors;
+ ++sc->ifp->if_oerrors;
}
if (tx_status & EPHSR_LATCOL)
- ++sc->arpcom.ac_if.if_collisions;
+ ++sc->ifp->if_collisions;
/*
* Some of these errors will have disabled transmit.
@@ -911,8 +920,8 @@ sn_intr(void *arg)
/*
* Attempt to queue more transmits.
*/
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- snstart_locked(&sc->arpcom.ac_if);
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ snstart_locked(sc->ifp);
}
/*
* Transmit underrun. We use this opportunity to update transmit
@@ -937,20 +946,20 @@ sn_intr(void *arg)
/*
* Single collisions
*/
- sc->arpcom.ac_if.if_collisions += card_stats & ECR_COLN_MASK;
+ sc->ifp->if_collisions += card_stats & ECR_COLN_MASK;
/*
* Multiple collisions
*/
- sc->arpcom.ac_if.if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4;
+ sc->ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4;
SMC_SELECT_BANK(sc, 2);
/*
* Attempt to enqueue some more stuff.
*/
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- snstart_locked(&sc->arpcom.ac_if);
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ snstart_locked(sc->ifp);
}
/*
* Some other error. Try to fix it by resetting the adapter.
@@ -1028,7 +1037,7 @@ read_another:
* Account for receive errors and discard.
*/
if (status & RS_ERRORS) {
- ++sc->arpcom.ac_if.if_ierrors;
+ ++sc->ifp->if_ierrors;
goto out;
}
/*
@@ -1048,7 +1057,7 @@ read_another:
if (m == NULL)
goto out;
- m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ m->m_pkthdr.rcvif = sc->ifp;
m->m_pkthdr.len = m->m_len = packet_length;
/*
@@ -1061,7 +1070,7 @@ read_another:
*/
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
- ++sc->arpcom.ac_if.if_ierrors;
+ ++sc->ifp->if_ierrors;
printf("sn: snread() kernel memory allocation problem\n");
goto out;
}
@@ -1076,7 +1085,7 @@ read_another:
data += packet_length & ~1;
*data = CSR_READ_1(sc, DATA_REG_B);
}
- ++sc->arpcom.ac_if.if_ipackets;
+ ++sc->ifp->if_ipackets;
/*
* Remove link layer addresses and whatnot.
@@ -1184,7 +1193,7 @@ static void
snstop(struct sn_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
/*
* Clear interrupt mask; disable all interrupts.
@@ -1366,7 +1375,7 @@ sn_probe(device_t dev, int pccard)
static void
sn_setmcast(struct sn_softc *sc)
{
- struct ifnet *ifp = (struct ifnet *)sc;
+ struct ifnet *ifp = sc->ifp;
int flags;
uint8_t mcf[MCFSZ];
@@ -1384,7 +1393,7 @@ sn_setmcast(struct sn_softc *sc)
} else if (ifp->if_flags & IFF_ALLMULTI) {
flags |= RCR_ALMUL;
} else {
- if (sn_getmcf(&sc->arpcom, mcf)) {
+ if (sn_getmcf(ifp, mcf)) {
/* set filter */
SMC_SELECT_BANK(sc, 3);
CSR_WRITE_2(sc, MULTICAST1_REG_W,
@@ -1404,7 +1413,7 @@ sn_setmcast(struct sn_softc *sc)
}
static int
-sn_getmcf(struct arpcom *ac, uint8_t *mcf)
+sn_getmcf(struct ifnet *ifp, uint8_t *mcf)
{
int i;
uint32_t index, index2;
@@ -1413,7 +1422,7 @@ sn_getmcf(struct arpcom *ac, uint8_t *mcf)
bzero(mcf, MCFSZ);
- TAILQ_FOREACH(ifma, &ac->ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
return 0;
index = ether_crc32_le(LLADDR((struct sockaddr_dl *)
diff --git a/sys/dev/sn/if_sn_pccard.c b/sys/dev/sn/if_sn_pccard.c
index f1556c0..00a35d0 100644
--- a/sys/dev/sn/if_sn_pccard.c
+++ b/sys/dev/sn/if_sn_pccard.c
@@ -149,7 +149,7 @@ sn_pccard_attach(device_t dev)
}
if (sum) {
sc->pccard_enaddr = 1;
- bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(ether_addr, IFP2ENADDR(sc->ifp), ETHER_ADDR_LEN);
}
return (sn_attach(dev));
}
diff --git a/sys/dev/sn/if_snvar.h b/sys/dev/sn/if_snvar.h
index 91c6d8a..e7a5b4b 100644
--- a/sys/dev/sn/if_snvar.h
+++ b/sys/dev/sn/if_snvar.h
@@ -30,14 +30,8 @@
#include <net/if_arp.h>
-/*
- * Ethernet software status per interface. The first element MUST
- * be the arpcom struct since the address of the arpcom struct is
- * used as a backdoor to obtain the address of this whole structure
- * in many cases.
- */
struct sn_softc {
- struct arpcom arpcom; /* Ethernet common part */
+ struct ifnet *ifp;
bus_space_tag_t bst;
bus_space_handle_t bsh;
struct mtx sc_mtx;
diff --git a/sys/dev/snc/dp83932.c b/sys/dev/snc/dp83932.c
index 9080699..23fea5e 100644
--- a/sys/dev/snc/dp83932.c
+++ b/sys/dev/snc/dp83932.c
@@ -79,6 +79,7 @@
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -154,7 +155,7 @@ sncconfig(sc, media, nmedia, defmedia, myea)
int *media, nmedia, defmedia;
u_int8_t *myea;
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp;
int i;
#ifdef SNCDEBUG
@@ -163,6 +164,10 @@ sncconfig(sc, media, nmedia, defmedia, myea)
}
#endif
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ panic("%s: can not if_alloc()\n", device_get_nameunit(dev));
+
#ifdef SNCDEBUG
device_printf(sc->sc_dev,
"buffers: rra=0x%x cda=0x%x rda=0x%x tda=0x%x\n",
@@ -181,7 +186,6 @@ sncconfig(sc, media, nmedia, defmedia, myea)
ifp->if_init = sncinit;
ifp->if_mtu = ETHERMTU;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- bcopy(myea, sc->sc_ethercom.ac_enaddr, ETHER_ADDR_LEN);
/* Initialize media goo. */
ifmedia_init(&sc->sc_media, 0, snc_mediachange,
@@ -394,7 +398,7 @@ sncinit(xsc)
u_long s_rcr;
int s;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
/* already running */
return;
@@ -408,9 +412,9 @@ sncinit(xsc)
NIC_PUT(sc, SNCR_DCR2, sc->sncr_dcr2);
s_rcr = RCR_BRD | RCR_LBNONE;
- if (sc->sc_if.if_flags & IFF_PROMISC)
+ if (sc->sc_ifp->if_flags & IFF_PROMISC)
s_rcr |= RCR_PRO;
- if (sc->sc_if.if_flags & IFF_ALLMULTI)
+ if (sc->sc_ifp->if_flags & IFF_ALLMULTI)
s_rcr |= RCR_AMC;
NIC_PUT(sc, SNCR_RCR, s_rcr);
@@ -446,8 +450,8 @@ sncinit(xsc)
wbflush();
/* flag interface as "running" */
- sc->sc_if.if_flags |= IFF_RUNNING;
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->sc_ifp->if_flags |= IFF_RUNNING;
+ sc->sc_ifp->if_flags &= ~IFF_OACTIVE;
splx(s);
return;
@@ -479,8 +483,8 @@ sncstop(sc)
if (++sc->mtd_hw == NTDA) sc->mtd_hw = 0;
}
- sc->sc_if.if_timer = 0;
- sc->sc_if.if_flags &= ~(IFF_RUNNING | IFF_UP);
+ sc->sc_ifp->if_timer = 0;
+ sc->sc_ifp->if_flags &= ~(IFF_RUNNING | IFF_UP);
splx(s);
return (0);
@@ -596,7 +600,7 @@ sonicput(sc, m0, mtd_next)
wbflush();
NIC_PUT(sc, SNCR_CR, CR_TXP);
wbflush();
- sc->sc_if.if_timer = 5; /* 5 seconds to watch for failing to transmit */
+ sc->sc_ifp->if_timer = 5; /* 5 seconds to watch for failing to transmit */
return (totlen);
}
@@ -660,10 +664,10 @@ camprogram(sc)
caminitialise(sc);
- ifp = &sc->sc_if;
+ ifp = sc->sc_ifp;
/* Always load our own address first. */
- camentry (sc, mcount, sc->sc_ethercom.ac_enaddr);
+ camentry (sc, mcount, IFP2ENADDR(sc->sc_ifp));
mcount++;
/* Assume we won't need allmulti bit. */
@@ -879,7 +883,7 @@ sncintr(arg)
sc->sc_mptally++;
#endif
}
- sncstart(&sc->sc_if);
+ sncstart(sc->sc_ifp);
#if NRND > 0
if (isr)
@@ -900,7 +904,7 @@ sonictxint(sc)
u_int32_t txp;
unsigned short txp_status;
int mtd_hw;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
mtd_hw = sc->mtd_hw;
@@ -997,11 +1001,11 @@ sonicrxint(sc)
u_int32_t pkt =
sc->rbuf[orra & RBAMASK] + (rxpkt_ptr & PGOFSET);
if (sonic_read(sc, pkt, len))
- sc->sc_if.if_ipackets++;
+ sc->sc_ifp->if_ipackets++;
else
- sc->sc_if.if_ierrors++;
+ sc->sc_ifp->if_ierrors++;
} else
- sc->sc_if.if_ierrors++;
+ sc->sc_ifp->if_ierrors++;
/*
* give receive buffer area back to chip.
@@ -1069,7 +1073,7 @@ sonic_read(sc, pkt, len)
u_int32_t pkt;
int len;
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ether_header *et;
struct mbuf *m;
@@ -1124,7 +1128,7 @@ sonic_get(sc, pkt, datalen)
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == 0)
return (0);
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = sc->sc_ifp;
m->m_pkthdr.len = datalen;
len = MHLEN;
top = 0;
diff --git a/sys/dev/snc/dp83932var.h b/sys/dev/snc/dp83932var.h
index f621397..9570162 100644
--- a/sys/dev/snc/dp83932var.h
+++ b/sys/dev/snc/dp83932var.h
@@ -130,8 +130,7 @@ typedef struct mtd {
* The snc_softc for PC-98 if_snc.
*/
typedef struct snc_softc {
- struct arpcom sc_ethercom;
-#define sc_if sc_ethercom.ac_if /* network visible interface */
+ struct ifnet * sc_ifp;
device_t sc_dev;
diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c
index db4eafb..bd91382 100644
--- a/sys/dev/sr/if_sr.c
+++ b/sys/dev/sr/if_sr.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#else /* NETGRAPH */
#include <net/if_sppp.h>
+#include <net/if_types.h>
#include <net/bpf.h>
#endif /* NETGRAPH */
@@ -108,7 +109,7 @@ static int sr_watcher = 0;
*/
struct sr_softc {
#ifndef NETGRAPH
- struct sppp ifsppp; /* PPP service w/in system */
+ struct ifnet *ifp; /* PPP service w/in system */
#endif /* NETGRAPH */
struct sr_hardc *hc; /* card-level information */
@@ -163,6 +164,7 @@ struct sr_softc {
u_long opackets, ipackets;
#endif /* NETGRAPH */
};
+#define SC2IFP(sc) sc->ifp
#ifdef NETGRAPH
#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
@@ -409,7 +411,10 @@ sr_attach(device_t device)
sc->unit, hc->cunit, sc->subunit);
#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
+ ifp = SC2IFP(sc) = if_alloc(IFT_PPP);
+ if (ifp == NULL) {
+ goto errexit;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(device),
device_get_unit(device));
@@ -420,8 +425,8 @@ sr_attach(device_t device)
ifp->if_start = srstart;
ifp->if_watchdog = srwatchdog;
- sc->ifsppp.pp_flags = PP_KEEPALIVE;
- sppp_attach((struct ifnet *)&sc->ifsppp);
+ IFP2SP(sc->ifp)->pp_flags = PP_KEEPALIVE;
+ sppp_attach(sc->ifp);
if_attach(ifp);
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
@@ -681,7 +686,7 @@ sr_xmit(struct sr_softc *sc)
hc = sc->hc;
#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
+ ifp = SC2IFP(sc);
#endif /* NETGRAPH */
dmac = &hc->sca->dmac[DMAC_TXCH(sc->scachan)];
@@ -912,7 +917,7 @@ top_srstart:
*/
m_freem(mtx);
#ifndef NETGRAPH
- ++sc->ifsppp.pp_if.if_opackets;
+ ++SC2IFP(sc)->if_opackets;
#else /* NETGRAPH */
sc->opackets++;
#endif /* NETGRAPH */
@@ -2001,7 +2006,7 @@ sr_get_packets(struct sr_softc *sc)
hc = sc->hc;
#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
+ ifp = SC2IFP(sc);
#endif /* NETGRAPH */
if (hc->mempages) {
@@ -2241,8 +2246,8 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
printf("sr%d: TX DMA Counter overflow, "
"txpacket no %lu.\n",
#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_opackets);
- sc->ifsppp.pp_if.if_oerrors++;
+ sc->unit, SC2IFP(sc)->if_opackets);
+ SC2IFP(sc)->if_oerrors++;
#else
sc->unit, sc->opackets);
sc->oerrors++;
@@ -2256,7 +2261,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
"txpacket no %lu, dsr %02x, "
"cda %04x, eda %04x.\n",
#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_opackets,
+ sc->unit, SC2IFP(sc)->if_opackets,
#else
sc->unit, sc->opackets,
#endif /* NETGRAPH */
@@ -2264,7 +2269,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
SRC_GET16(hc, dmac->cda),
SRC_GET16(hc, dmac->eda));
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
#else
sc->oerrors++;
#endif /* NETGRAPH */
@@ -2286,8 +2291,8 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
#endif
sc->xmit_busy = 0;
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
- sc->ifsppp.pp_if.if_timer = 0;
+ SC2IFP(sc)->if_flags &= ~IFF_OACTIVE;
+ SC2IFP(sc)->if_timer = 0;
#else
/* XXX may need to mark tx inactive? */
sc->out_deficit++;
@@ -2315,7 +2320,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
int tt, ind;
#ifndef NETGRAPH
- tt = sc->ifsppp.pp_if.if_ipackets;
+ tt = SC2IFP(sc)->if_ipackets;
#else /* NETGRAPH */
tt = sc->ipackets;
#endif /* NETGRAPH */
@@ -2325,7 +2330,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
sr_get_packets(sc);
#if BUGGY > 0
#ifndef NETGRAPH
- if (tt == sc->ifsppp.pp_if.if_ipackets)
+ if (tt == SC2IFP(sc)->if_ipackets)
#else /* NETGRAPH */
if (tt == sc->ipackets)
#endif /* NETGRAPH */
@@ -2373,8 +2378,8 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
printf("sr%d: RX DMA Counter overflow, "
"rxpkts %lu.\n",
#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
+ sc->unit, SC2IFP(sc)->if_ipackets);
+ SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->unit, sc->ipackets);
sc->ierrors[1]++;
@@ -2388,7 +2393,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
"rxpkts %lu, rxind %d, "
"cda %x, eda %x, dsr %x.\n",
#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_ipackets,
+ sc->unit, SC2IFP(sc)->if_ipackets,
#else /* NETGRAPH */
sc->unit, sc->ipackets,
#endif /* NETGRAPH */
@@ -2406,7 +2411,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
sr_eat_packet(sc, 0);
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
+ SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ierrors[2]++;
#endif /* NETGRAPH */
@@ -2424,7 +2429,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
#ifndef NETGRAPH
sc->ipackets,
#else /* NETGRAPH */
- sc->ifsppp.pp_if.if_ipackets,
+ SC2IFP(sc)->if_ipackets,
#endif /* NETGRAPH */
sc->rxhind,
SRC_GET16(hc, dmac->cda),
@@ -2449,8 +2454,8 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
printf("sr%d: RX End of xfer, rxpkts %lu.\n",
sc->unit,
#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
+ SC2IFP(sc)->if_ipackets);
+ SC2IFP(sc)->if_ierrors++;
#else
sc->ipackets);
sc->ierrors[3]++;
@@ -2469,7 +2474,7 @@ sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
if (dotxstart & 0x0C) { /* TX initiation enabled? */
sc = &hc->sc[mch];
#ifndef NETGRAPH
- srstart(&sc->ifsppp.pp_if);
+ srstart(SC2IFP(sc));
#else
srstart(sc);
#endif /* NETGRAPH */
@@ -2551,7 +2556,7 @@ sr_modemck(void *arg)
for (mch = 0; mch < hc->numports; mch++) {
sc = &hc->sc[mch];
- ifp = &sc->ifsppp.pp_if;
+ ifp = SC2IFP(sc);
/*
* if this channel isn't "up", skip it
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index 4af3b29..b6a3a7f 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -1111,7 +1111,7 @@ ti_newbuf_std(sc, i, m)
TI_HOSTADDR(r->ti_addr) = vtophys(mtod(m_new, caddr_t));
r->ti_type = TI_BDTYPE_RECV_BD;
r->ti_flags = 0;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM;
r->ti_len = m_new->m_len;
r->ti_idx = i;
@@ -1150,7 +1150,7 @@ ti_newbuf_mini(sc, i, m)
TI_HOSTADDR(r->ti_addr) = vtophys(mtod(m_new, caddr_t));
r->ti_type = TI_BDTYPE_RECV_BD;
r->ti_flags = TI_BDFLAG_MINI_RING;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM;
r->ti_len = m_new->m_len;
r->ti_idx = i;
@@ -1209,7 +1209,7 @@ ti_newbuf_jumbo(sc, i, m)
TI_HOSTADDR(r->ti_addr) = vtophys(mtod(m_new, caddr_t));
r->ti_type = TI_BDTYPE_RECV_JUMBO_BD;
r->ti_flags = TI_BDFLAG_JUMBO_RING;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM;
r->ti_len = m_new->m_len;
r->ti_idx = i;
@@ -1348,7 +1348,7 @@ ti_newbuf_jumbo(sc, idx, m_old)
r->ti_flags = TI_BDFLAG_JUMBO_RING|TI_RCB_FLAG_USE_EXT_RX_BD;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM|TI_BDFLAG_IP_CKSUM;
r->ti_idx = idx;
@@ -1599,7 +1599,7 @@ ti_setmulti(sc)
struct ti_mc_entry *mc;
u_int32_t intrs;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
if (ifp->if_flags & IFF_ALLMULTI) {
TI_DO_CMD(TI_CMD_SET_ALLMULTI, TI_CMD_CODE_ALLMULTI_ENB, 0);
@@ -1681,10 +1681,10 @@ ti_chipinit(sc)
/* Initialize link to down state. */
sc->ti_linkstat = TI_EV_CODE_LINK_DOWN;
- if (sc->arpcom.ac_if.if_capenable & IFCAP_HWCSUM)
- sc->arpcom.ac_if.if_hwassist = TI_CSUM_FEATURES;
+ if (sc->ti_ifp->if_capenable & IFCAP_HWCSUM)
+ sc->ti_ifp->if_hwassist = TI_CSUM_FEATURES;
else
- sc->arpcom.ac_if.if_hwassist = 0;
+ sc->ti_ifp->if_hwassist = 0;
/* Set endianness before we access any non-PCI registers. */
#if BYTE_ORDER == BIG_ENDIAN
@@ -1815,7 +1815,7 @@ ti_chipinit(sc)
* the firmware racks up lots of nicDmaReadRingFull
* errors. This is not compatible with hardware checksums.
*/
- if (sc->arpcom.ac_if.if_hwassist == 0)
+ if (sc->ti_ifp->if_hwassist == 0)
TI_SETBIT(sc, TI_GCR_OPMODE, TI_OPMODE_1_DMA_ACTIVE);
/* Recommended settings from Tigon manual. */
@@ -1846,7 +1846,7 @@ ti_gibinit(sc)
struct ifnet *ifp;
uint32_t rdphys;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
rdphys = sc->ti_rdata_phys;
/* Disable interrupts for now. */
@@ -1905,7 +1905,7 @@ ti_gibinit(sc)
TI_HOSTADDR(rcb->ti_hostaddr) = rdphys + TI_RD_OFF(ti_rx_std_ring);
rcb->ti_max_len = TI_FRAMELEN;
rcb->ti_flags = 0;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
@@ -1921,7 +1921,7 @@ ti_gibinit(sc)
rcb->ti_max_len = PAGE_SIZE;
rcb->ti_flags = TI_RCB_FLAG_USE_EXT_RX_BD;
#endif
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
@@ -1938,7 +1938,7 @@ ti_gibinit(sc)
rcb->ti_flags = TI_RCB_FLAG_RING_DISABLED;
else
rcb->ti_flags = 0;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
@@ -1975,7 +1975,7 @@ ti_gibinit(sc)
else
rcb->ti_flags = TI_RCB_FLAG_HOST_RING;
rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
- if (sc->arpcom.ac_if.if_hwassist)
+ if (sc->ti_ifp->if_hwassist)
rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
rcb->ti_max_len = TI_TX_RING_CNT;
@@ -2058,6 +2058,7 @@ ti_attach(dev)
struct ifnet *ifp;
struct ti_softc *sc;
int unit, error = 0, rid;
+ u_char eaddr[6];
sc = device_get_softc(dev);
unit = device_get_unit(dev);
@@ -2065,9 +2066,9 @@ ti_attach(dev)
mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts);
- sc->arpcom.ac_if.if_capabilities = IFCAP_HWCSUM |
+ sc->ti_ifp->if_capabilities = IFCAP_HWCSUM |
IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
- sc->arpcom.ac_if.if_capenable = sc->arpcom.ac_if.if_capabilities;
+ sc->ti_ifp->if_capenable = sc->ti_ifp->if_capabilities;
/*
* Map control/status registers.
@@ -2125,7 +2126,7 @@ ti_attach(dev)
* the NIC). This means the MAC address is actually preceded
* by two zero bytes. We need to skip over those.
*/
- if (ti_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
+ if (ti_read_eeprom(sc, eaddr,
TI_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) {
printf("ti%d: failed to read station address\n", unit);
error = ENXIO;
@@ -2221,7 +2222,12 @@ ti_attach(dev)
sc->ti_tx_buf_ratio = 21;
/* Set up ifnet structure */
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("ti%d: can not if_alloc()\n", sc->ti_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
@@ -2276,7 +2282,7 @@ ti_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* Hook interrupt last to avoid having to lock softc */
error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET,
@@ -2285,6 +2291,7 @@ ti_attach(dev)
if (error) {
printf("ti%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -2314,12 +2321,13 @@ ti_detach(dev)
destroy_dev(sc->dev);
KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized"));
TI_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
ti_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
bus_generic_detach(dev);
}
ifmedia_removeall(&sc->ifmedia);
@@ -2430,7 +2438,7 @@ ti_rxeof(sc)
TI_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
while (sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) {
struct ti_rx_desc *cur_rx;
@@ -2547,7 +2555,7 @@ ti_txeof(sc)
struct ti_tx_desc *cur_tx = NULL;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
/*
* Go through our tx ring and free mbufs for those
@@ -2597,7 +2605,7 @@ ti_intr(xsc)
sc = xsc;
TI_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
/*#ifdef notdef*/
/* Avoid this for now -- checking this register is expensive. */
@@ -2636,7 +2644,7 @@ ti_stats_update(sc)
{
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
ifp->if_collisions +=
(sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames +
@@ -2676,7 +2684,7 @@ ti_encap(sc, m_head, txidx)
csum_flags |= TI_BDFLAG_IP_FRAG;
}
- mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m);
+ mtag = VLAN_OUTPUT_TAG(sc->ti_ifp, m);
/*
* Start packing the mbufs in this chain into
@@ -2842,7 +2850,7 @@ static void ti_init2(sc)
struct ifmedia *ifm;
int tmp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
/* Specify MTU and interface index. */
CSR_WRITE_4(sc, TI_GCR_IFINDEX, sc->ti_unit);
@@ -2851,7 +2859,7 @@ static void ti_init2(sc)
TI_DO_CMD(TI_CMD_UPDATE_GENCOM, 0, 0);
/* Load our MAC address. */
- m = (u_int16_t *)&sc->arpcom.ac_enaddr[0];
+ m = (u_int16_t *)&IFP2ENADDR(sc->ti_ifp)[0];
CSR_WRITE_4(sc, TI_GCR_PAR0, htons(m[0]));
CSR_WRITE_4(sc, TI_GCR_PAR1, (htons(m[1]) << 16) | htons(m[2]));
TI_DO_CMD(TI_CMD_SET_MAC_ADDR, 0, 0);
@@ -3489,7 +3497,7 @@ ti_stop(sc)
TI_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ti_ifp;
/* Disable host interrupts. */
CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
diff --git a/sys/dev/ti/if_tireg.h b/sys/dev/ti/if_tireg.h
index 6e438d4..1bcdfbc 100644
--- a/sys/dev/ti/if_tireg.h
+++ b/sys/dev/ti/if_tireg.h
@@ -987,7 +987,7 @@ typedef enum {
struct ti_softc {
STAILQ_ENTRY(ti_softc) ti_links;
- struct arpcom arpcom; /* interface info */
+ struct ifnet *ti_ifp;
bus_space_handle_t ti_bhandle;
vm_offset_t ti_vhandle;
bus_space_tag_t ti_btag;
diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c
index 18fe63f..f059887 100644
--- a/sys/dev/tx/if_tx.c
+++ b/sys/dev/tx/if_tx.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -224,6 +225,7 @@ epic_attach(dev)
epic_softc_t *sc;
int unit, error;
int i, s, rid, tmp;
+ u_char eaddr[6];
s = splimp();
@@ -235,7 +237,12 @@ epic_attach(dev)
sc->dev = dev;
/* Fill ifnet structure. */
- ifp = &sc->sc_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ error = ENOSPC;
+ goto fail;
+ }
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST|IFF_NEEDSGIANT;
@@ -361,7 +368,7 @@ epic_attach(dev)
/* Read MAC address from EEPROM. */
for (i = 0; i < ETHER_ADDR_LEN / sizeof(u_int16_t); i++)
- ((u_int16_t *)sc->sc_macaddr)[i] = epic_read_eeprom(sc,i);
+ ((u_int16_t *)eaddr)[i] = epic_read_eeprom(sc,i);
/* Set Non-Volatile Control Register from EEPROM. */
CSR_WRITE_4(sc, NVCTL, epic_read_eeprom(sc, EEPROM_NVCTL) & 0x1F);
@@ -423,7 +430,7 @@ epic_attach(dev)
}
/* Attach to OS's managers. */
- ether_ifattach(ifp, sc->sc_macaddr);
+ ether_ifattach(ifp, eaddr);
splx(s);
return (0);
@@ -440,6 +447,8 @@ static void
epic_release(epic_softc_t *sc)
{
+ if (sc->ifp != NULL)
+ if_free(sc->ifp);
if (sc->irq)
bus_release_resource(sc->dev, SYS_RES_IRQ, 0, sc->irq);
if (sc->res)
@@ -484,7 +493,7 @@ epic_detach(dev)
s = splimp();
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
ether_ifdetach(ifp);
@@ -720,7 +729,7 @@ static void
epic_rx_done(sc)
epic_softc_t *sc;
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
u_int16_t len;
struct epic_rx_buffer *buf;
struct epic_rx_desc *desc;
@@ -831,10 +840,10 @@ epic_tx_done(sc)
/* Check for errors and collisions. */
if (status & 0x0001)
- sc->sc_if.if_opackets++;
+ sc->ifp->if_opackets++;
else
- sc->sc_if.if_oerrors++;
- sc->sc_if.if_collisions += (status >> 8) & 0x1F;
+ sc->ifp->if_oerrors++;
+ sc->ifp->if_collisions += (status >> 8) & 0x1F;
#ifdef EPIC_DIAG
if ((status & 0x1001) == 0x1001)
device_printf(sc->dev,
@@ -843,7 +852,7 @@ epic_tx_done(sc)
}
if (sc->pending_txs < TX_RING_SIZE)
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
bus_dmamap_sync(sc->ttag, sc->tmap,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
}
@@ -874,14 +883,14 @@ epic_intr(arg)
#endif
if ((CSR_READ_4(sc, COMMAND) & COMMAND_RXQUEUED) == 0)
CSR_WRITE_4(sc, COMMAND, COMMAND_RXQUEUED);
- sc->sc_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
}
}
if (status & (INTSTAT_TXC|INTSTAT_TCC|INTSTAT_TQE)) {
epic_tx_done(sc);
- if (sc->sc_if.if_snd.ifq_head != NULL)
- epic_ifstart(&sc->sc_if);
+ if (sc->ifp->if_snd.ifq_head != NULL)
+ epic_ifstart(sc->ifp);
}
/* Check for rare errors */
@@ -904,19 +913,19 @@ epic_intr(arg)
#ifdef EPIC_DIAG
device_printf(sc->dev, "CRC/Alignment error\n");
#endif
- sc->sc_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
}
if (status & INTSTAT_TXU) {
epic_tx_underrun(sc);
- sc->sc_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
}
}
}
/* If no packets are pending, then no timeouts. */
if (sc->pending_txs == 0)
- sc->sc_if.if_timer = 0;
+ sc->ifp->if_timer = 0;
}
/*
@@ -1205,9 +1214,9 @@ epic_miibus_statchg(dev)
/* Update baudrate. */
if (IFM_SUBTYPE(media) == IFM_100_TX ||
IFM_SUBTYPE(media) == IFM_100_FX)
- sc->sc_if.if_baudrate = 100000000;
+ sc->ifp->if_baudrate = 100000000;
else
- sc->sc_if.if_baudrate = 10000000;
+ sc->ifp->if_baudrate = 10000000;
epic_stop_activity(sc);
epic_set_tx_mode(sc);
@@ -1252,7 +1261,7 @@ epic_init(xsc)
void *xsc;
{
epic_softc_t *sc = xsc;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
int s, i;
s = splimp();
@@ -1285,9 +1294,9 @@ epic_init(xsc)
CSR_WRITE_4(sc, PTCDAR, sc->tx_addr);
/* Put node address to EPIC. */
- CSR_WRITE_4(sc, LAN0, ((u_int16_t *)sc->sc_macaddr)[0]);
- CSR_WRITE_4(sc, LAN1, ((u_int16_t *)sc->sc_macaddr)[1]);
- CSR_WRITE_4(sc, LAN2, ((u_int16_t *)sc->sc_macaddr)[2]);
+ CSR_WRITE_4(sc, LAN0, ((u_int16_t *)IFP2ENADDR(sc->ifp))[0]);
+ CSR_WRITE_4(sc, LAN1, ((u_int16_t *)IFP2ENADDR(sc->ifp))[1]);
+ CSR_WRITE_4(sc, LAN2, ((u_int16_t *)IFP2ENADDR(sc->ifp))[2]);
/* Set tx mode, includeing transmit threshold. */
epic_set_tx_mode(sc);
@@ -1343,7 +1352,7 @@ epic_set_rx_mode(sc)
u_int32_t flags;
u_int32_t rxcon;
- flags = sc->sc_if.if_flags;
+ flags = sc->ifp->if_flags;
rxcon = RXCON_DEFAULT;
#ifdef EPIC_EARLY_RX
@@ -1386,7 +1395,7 @@ epic_set_mc_table(sc)
u_int16_t filter[4];
u_int8_t h;
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
CSR_WRITE_4(sc, MC0, 0xFFFF);
CSR_WRITE_4(sc, MC1, 0xFFFF);
@@ -1508,7 +1517,7 @@ epic_queue_last_packet(sc)
/* Prepare mbuf. */
m0->m_len = min(MHLEN, ETHER_MIN_LEN - ETHER_CRC_LEN);
m0->m_pkthdr.len = m0->m_len;
- m0->m_pkthdr.rcvif = &sc->sc_if;
+ m0->m_pkthdr.rcvif = sc->ifp;
bzero(mtod(m0, caddr_t), m0->m_len);
/* Fill fragments list. */
@@ -1560,7 +1569,7 @@ epic_stop(sc)
s = splimp();
- sc->sc_if.if_timer = 0;
+ sc->ifp->if_timer = 0;
untimeout((timeout_t *)epic_stats_update, sc, sc->stat_ch);
@@ -1579,7 +1588,7 @@ epic_stop(sc)
CSR_WRITE_4(sc, GENCTL, GENCTL_POWER_DOWN);
/* Mark as stoped */
- sc->sc_if.if_flags &= ~IFF_RUNNING;
+ sc->ifp->if_flags &= ~IFF_RUNNING;
splx(s);
}
diff --git a/sys/dev/tx/if_txvar.h b/sys/dev/tx/if_txvar.h
index 1277244..a1322c9 100644
--- a/sys/dev/tx/if_txvar.h
+++ b/sys/dev/tx/if_txvar.h
@@ -70,7 +70,7 @@ struct epic_tx_buffer {
/* Driver status structure */
typedef struct {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct resource *res;
struct resource *irq;
@@ -124,9 +124,6 @@ struct epic_type {
char *name;
};
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define CSR_WRITE_2(sc, reg, val) \
diff --git a/sys/dev/txp/if_txp.c b/sys/dev/txp/if_txp.c
index 749ea44..425bbe5 100644
--- a/sys/dev/txp/if_txp.c
+++ b/sys/dev/txp/if_txp.c
@@ -217,6 +217,7 @@ txp_attach(dev)
u_int16_t p1;
u_int32_t p2;
int unit, error = 0, rid;
+ u_char eaddr[6];
sc = device_get_softc(dev);
unit = device_get_unit(dev);
@@ -266,6 +267,7 @@ txp_attach(dev)
if (txp_chip_init(sc)) {
txp_release_resources(sc);
+ /* XXX: set error to ??? */
goto fail;
}
@@ -286,29 +288,32 @@ txp_attach(dev)
if (txp_alloc_rings(sc)) {
txp_release_resources(sc);
+ /* XXX: set error to ??? */
goto fail;
}
if (txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0,
NULL, NULL, NULL, 1)) {
txp_release_resources(sc);
+ /* XXX: set error to ??? */
goto fail;
}
if (txp_command(sc, TXP_CMD_STATION_ADDRESS_READ, 0, 0, 0,
&p1, &p2, NULL, 1)) {
txp_release_resources(sc);
+ /* XXX: set error to ??? */
goto fail;
}
txp_set_filter(sc);
- sc->sc_arpcom.ac_enaddr[0] = ((u_int8_t *)&p1)[1];
- sc->sc_arpcom.ac_enaddr[1] = ((u_int8_t *)&p1)[0];
- sc->sc_arpcom.ac_enaddr[2] = ((u_int8_t *)&p2)[3];
- sc->sc_arpcom.ac_enaddr[3] = ((u_int8_t *)&p2)[2];
- sc->sc_arpcom.ac_enaddr[4] = ((u_int8_t *)&p2)[1];
- sc->sc_arpcom.ac_enaddr[5] = ((u_int8_t *)&p2)[0];
+ eaddr[0] = ((u_int8_t *)&p1)[1];
+ eaddr[1] = ((u_int8_t *)&p1)[0];
+ eaddr[2] = ((u_int8_t *)&p2)[3];
+ eaddr[3] = ((u_int8_t *)&p2)[2];
+ eaddr[4] = ((u_int8_t *)&p2)[1];
+ eaddr[5] = ((u_int8_t *)&p2)[0];
sc->sc_cold = 0;
@@ -326,7 +331,13 @@ txp_attach(dev)
NULL, NULL, NULL, 0);
ifmedia_set(&sc->sc_ifmedia, IFM_ETHER|IFM_AUTO);
- ifp = &sc->sc_arpcom.ac_if;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ txp_release_resources(sc);
+ device_printf(dev, "couldn't set up irq\n");
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -344,7 +355,7 @@ txp_attach(dev)
/*
* Attach us everywhere
*/
- ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->sc_tick);
return(0);
@@ -363,7 +374,7 @@ txp_detach(dev)
int i;
sc = device_get_softc(dev);
- ifp = &sc->sc_arpcom.ac_if;
+ ifp = sc->sc_ifp;
txp_stop(sc);
txp_shutdown(dev);
@@ -388,6 +399,9 @@ txp_release_resources(sc)
dev = sc->sc_dev;
+ if (sc->sc_ifp)
+ if_free(sc->sc_ifp);
+
if (sc->sc_intrhand != NULL)
bus_teardown_intr(dev, sc->sc_irq, sc->sc_intrhand);
@@ -682,7 +696,7 @@ txp_intr(vsc)
/* unmask all interrupts */
WRITE_REG(sc, TXP_IMR, TXP_INT_A2H_3);
- txp_start(&sc->sc_arpcom.ac_if);
+ txp_start(sc->sc_ifp);
return;
}
@@ -692,7 +706,7 @@ txp_rx_reclaim(sc, r)
struct txp_softc *sc;
struct txp_rx_ring *r;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct txp_rx_desc *rxd;
struct mbuf *m;
struct txp_swdesc *sd = NULL;
@@ -791,7 +805,7 @@ static void
txp_rxbuf_reclaim(sc)
struct txp_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct txp_hostvar *hv = sc->sc_hostvar;
struct txp_rxbuf_desc *rbd;
struct txp_swdesc *sd;
@@ -849,7 +863,7 @@ txp_tx_reclaim(sc, r)
struct txp_softc *sc;
struct txp_tx_ring *r;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int32_t idx = TXP_OFFSET2IDX(*(r->r_off));
u_int32_t cons = r->r_cons, cnt = r->r_cnt;
struct txp_tx_desc *txd = r->r_desc + cons;
@@ -1099,7 +1113,7 @@ txp_rxring_fill(sc)
struct ifnet *ifp;
struct txp_swdesc *sd;
- ifp = &sc->sc_arpcom.ac_if;
+ ifp = sc->sc_ifp;
for (i = 0; i < RXBUF_ENTRIES; i++) {
sd = sc->sc_rxbufs[i].rb_sd;
@@ -1162,7 +1176,7 @@ txp_init(xsc)
int s;
sc = xsc;
- ifp = &sc->sc_arpcom.ac_if;
+ ifp = sc->sc_ifp;
if (ifp->if_flags & IFF_RUNNING)
return;
@@ -1175,12 +1189,12 @@ txp_init(xsc)
NULL, NULL, NULL, 1);
/* Set station address. */
- ((u_int8_t *)&p1)[1] = sc->sc_arpcom.ac_enaddr[0];
- ((u_int8_t *)&p1)[0] = sc->sc_arpcom.ac_enaddr[1];
- ((u_int8_t *)&p2)[3] = sc->sc_arpcom.ac_enaddr[2];
- ((u_int8_t *)&p2)[2] = sc->sc_arpcom.ac_enaddr[3];
- ((u_int8_t *)&p2)[1] = sc->sc_arpcom.ac_enaddr[4];
- ((u_int8_t *)&p2)[0] = sc->sc_arpcom.ac_enaddr[5];
+ ((u_int8_t *)&p1)[1] = IFP2ENADDR(sc->sc_ifp)[0];
+ ((u_int8_t *)&p1)[0] = IFP2ENADDR(sc->sc_ifp)[1];
+ ((u_int8_t *)&p2)[3] = IFP2ENADDR(sc->sc_ifp)[2];
+ ((u_int8_t *)&p2)[2] = IFP2ENADDR(sc->sc_ifp)[3];
+ ((u_int8_t *)&p2)[1] = IFP2ENADDR(sc->sc_ifp)[4];
+ ((u_int8_t *)&p2)[0] = IFP2ENADDR(sc->sc_ifp)[5];
txp_command(sc, TXP_CMD_STATION_ADDRESS_WRITE, p1, p2, 0,
NULL, NULL, NULL, 1);
@@ -1212,7 +1226,7 @@ txp_tick(vsc)
void *vsc;
{
struct txp_softc *sc = vsc;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct txp_rsp_desc *rsp = NULL;
struct txp_ext_desc *ext;
int s;
@@ -1564,7 +1578,7 @@ txp_stop(sc)
{
struct ifnet *ifp;
- ifp = &sc->sc_arpcom.ac_if;
+ ifp = sc->sc_ifp;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
@@ -1737,7 +1751,7 @@ static void
txp_set_filter(sc)
struct txp_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int32_t crc, carry, hashbit, hash[2];
u_int16_t filter;
u_int8_t octet;
@@ -1803,7 +1817,7 @@ static void
txp_capabilities(sc)
struct txp_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct txp_rsp_desc *rsp = NULL;
struct txp_ext_desc *ext;
diff --git a/sys/dev/txp/if_txpreg.h b/sys/dev/txp/if_txpreg.h
index 2d88fc9..df37b51 100644
--- a/sys/dev/txp/if_txpreg.h
+++ b/sys/dev/txp/if_txpreg.h
@@ -591,7 +591,7 @@ struct txp_ldata {
};
struct txp_softc {
- struct arpcom sc_arpcom; /* ethernet common */
+ struct ifnet *sc_ifp;
device_t sc_dev;
struct txp_hostvar *sc_hostvar;
struct txp_boot_record *sc_boot;
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c
index 501d94f..3118baa 100644
--- a/sys/dev/usb/if_aue.c
+++ b/sys/dev/usb/if_aue.c
@@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -524,7 +525,7 @@ aue_setmulti(struct aue_softc *sc)
struct ifmultiaddr *ifma;
u_int32_t h = 0, i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
@@ -709,9 +710,11 @@ USB_ATTACH(aue)
*/
aue_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 0);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("aue%d: can not if_alloc()\n", sc->aue_unit);
+ USB_ATTACH_ERROR_RETURN;
+ }
ifp->if_softc = sc;
if_initname(ifp, "aue", sc->aue_unit);
ifp->if_mtu = ETHERMTU;
@@ -774,7 +777,7 @@ aue_detach(device_ptr_t dev)
sc = device_get_softc(dev);
AUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
sc->aue_dying = 1;
untimeout(aue_tick, sc, sc->aue_stat_ch);
@@ -782,6 +785,7 @@ aue_detach(device_ptr_t dev)
ether_ifdetach(ifp);
#else
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ if_free(ifp);
#endif
if (sc->aue_ep[AUE_ENDPT_TX] != NULL)
@@ -810,7 +814,7 @@ aue_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
struct aue_intrpkt *p;
AUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
AUE_UNLOCK(sc);
@@ -889,7 +893,7 @@ aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
if (sc->aue_dying)
return;
AUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
AUE_UNLOCK(sc);
@@ -931,7 +935,7 @@ aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
total_len -= (4 + ETHER_CRC_LEN);
ifp->if_ipackets++;
- m->m_pkthdr.rcvif = (struct ifnet *)&sc->aue_qdat;
+ m->m_pkthdr.rcvif = (void *)&sc->aue_qdat;
m->m_pkthdr.len = m->m_len = total_len;
/* Put the packet on the special USB input queue. */
@@ -964,7 +968,7 @@ aue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
usbd_status err;
AUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
@@ -1011,7 +1015,7 @@ aue_tick(void *xsc)
AUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
mii = GET_MII(sc);
if (mii == NULL) {
AUE_UNLOCK(sc);
@@ -1128,7 +1132,7 @@ Static void
aue_init(void *xsc)
{
struct aue_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->aue_ifp;
struct mii_data *mii = GET_MII(sc);
struct ue_chain *c;
usbd_status err;
@@ -1148,7 +1152,7 @@ aue_init(void *xsc)
/* Set MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- aue_csr_write_1(sc, AUE_PAR0 + i, sc->arpcom.ac_enaddr[i]);
+ aue_csr_write_1(sc, AUE_PAR0 + i, IFP2ENADDR(sc->aue_ifp)[i]);
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@@ -1355,7 +1359,7 @@ aue_stop(struct aue_softc *sc)
struct ifnet *ifp;
AUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->aue_ifp;
ifp->if_timer = 0;
aue_csr_write_1(sc, AUE_CTL0, 0);
diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h
index b9e4dd7..d161acd 100644
--- a/sys/dev/usb/if_auereg.h
+++ b/sys/dev/usb/if_auereg.h
@@ -206,7 +206,7 @@ struct aue_softc {
#elif defined(__OpenBSD__)
#define GET_MII(sc) (&(sc)->aue_mii)
#endif
- struct arpcom arpcom;
+ struct ifnet *aue_ifp;
device_t aue_dev;
device_t aue_miibus;
usbd_device_handle aue_udev;
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index f4bb89f..9551649 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -324,7 +325,7 @@ axe_setmulti(struct axe_softc *sc)
u_int16_t rxmode;
u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
AXE_LOCK(sc);
axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, (void *)&rxmode);
@@ -479,9 +480,11 @@ USB_ATTACH(axe)
*/
sc->axe_phyaddrs[0] = sc->axe_phyaddrs[1] = 0xFF;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("axe%d: can not if_alloc()\n", sc->axe_unit);
+ USB_ATTACH_ERROR_RETURN;
+ }
ifp->if_softc = sc;
if_initname(ifp, "axe", sc->axe_unit);
ifp->if_mtu = ETHERMTU;
@@ -534,7 +537,7 @@ axe_detach(device_ptr_t dev)
sc = device_get_softc(dev);
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
sc->axe_dying = 1;
untimeout(axe_tick, sc, sc->axe_stat_ch);
@@ -542,6 +545,7 @@ axe_detach(device_ptr_t dev)
ether_ifdetach(ifp);
#else
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ if_free(ifp);
#endif
if (sc->axe_ep[AXE_ENDPT_TX] != NULL)
@@ -604,7 +608,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
c = priv;
sc = c->ue_sc;
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
AXE_UNLOCK(sc);
@@ -634,7 +638,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
}
ifp->if_ipackets++;
- m->m_pkthdr.rcvif = (struct ifnet *)&sc->axe_qdat;
+ m->m_pkthdr.rcvif = (void *)&sc->axe_qdat;
m->m_pkthdr.len = m->m_len = total_len;
/* Put the packet on the special USB input queue. */
@@ -669,7 +673,7 @@ axe_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
c = priv;
sc = c->ue_sc;
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
@@ -718,7 +722,7 @@ axe_tick(void *xsc)
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
mii = GET_MII(sc);
if (mii == NULL) {
AXE_UNLOCK(sc);
@@ -824,7 +828,7 @@ Static void
axe_init(void *xsc)
{
struct axe_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->axe_ifp;
struct ue_chain *c;
usbd_status err;
int i;
@@ -843,7 +847,7 @@ axe_init(void *xsc)
#ifdef notdef
/* Set MAC address */
- axe_mac(sc, sc->arpcom.ac_enaddr, 1);
+ axe_mac(sc, IFP2ENADDR(sc->axe_ifp), 1);
#endif
/* Enable RX logic. */
@@ -1023,7 +1027,7 @@ axe_stop(struct axe_softc *sc)
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
ifp->if_timer = 0;
untimeout(axe_tick, sc, sc->axe_stat_ch);
diff --git a/sys/dev/usb/if_axereg.h b/sys/dev/usb/if_axereg.h
index d825d79..c89ac27 100644
--- a/sys/dev/usb/if_axereg.h
+++ b/sys/dev/usb/if_axereg.h
@@ -127,7 +127,7 @@ struct axe_softc {
#elif defined(__OpenBSD__)
#define GET_MII(sc) (&(sc)->axe_mii)
#endif
- struct arpcom arpcom;
+ struct ifnet *axe_ifp;
device_t axe_miibus;
device_t axe_dev;
usbd_device_handle axe_udev;
diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c
index af2d1da..fabbbbe 100644
--- a/sys/dev/usb/if_cdce.c
+++ b/sys/dev/usb/if_cdce.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -282,9 +283,11 @@ USB_ATTACH(cdce)
}
}
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = GET_IFP(sc);
+ ifp = GET_IFP(sc) = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("%s: can not if_alloc()\n", USBDEVNAME(sc->cdce_dev));
+ USB_ATTACH_ERROR_RETURN;
+ }
ifp->if_softc = sc;
if_initname(ifp, "cdce", sc->cdce_unit);
ifp->if_mtu = ETHERMTU;
@@ -323,6 +326,7 @@ USB_DETACH(cdce)
cdce_shutdown(sc->cdce_dev);
ether_ifdetach(ifp);
+ if_free(ifp);
CDCE_UNLOCK(sc);
mtx_destroy(&sc->cdce_mtx);
diff --git a/sys/dev/usb/if_cdcereg.h b/sys/dev/usb/if_cdcereg.h
index 6ac8c21..7343315 100644
--- a/sys/dev/usb/if_cdcereg.h
+++ b/sys/dev/usb/if_cdcereg.h
@@ -43,8 +43,8 @@ struct cdce_type {
};
struct cdce_softc {
- struct arpcom arpcom;
-#define GET_IFP(sc) (&(sc)->arpcom.ac_if)
+ struct ifnet *cdce_ifp;
+#define GET_IFP(sc) ((sc)->cdce_ifp)
usbd_device_handle cdce_udev;
usbd_interface_handle cdce_data_iface;
diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c
index b0ef7e6..604f9c5 100644
--- a/sys/dev/usb/if_cue.c
+++ b/sys/dev/usb/if_cue.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -340,7 +341,7 @@ cue_setmulti(struct cue_softc *sc)
struct ifmultiaddr *ifma;
u_int32_t h = 0, i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
for (i = 0; i < CUE_MCAST_TABLE_LEN; i++)
@@ -499,9 +500,11 @@ USB_ATTACH(cue)
*/
cue_getmac(sc, &eaddr);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("cue%d: can not if_alloc()\n", sc->cue_unit);
+ USB_ATTACH_ERROR_RETURN;
+ }
ifp->if_softc = sc;
if_initname(ifp, "cue", sc->cue_unit);
ifp->if_mtu = ETHERMTU;
@@ -541,7 +544,7 @@ cue_detach(device_ptr_t dev)
sc = device_get_softc(dev);
CUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp;
sc->cue_dying = 1;
untimeout(cue_tick, sc, sc->cue_stat_ch);
@@ -549,6 +552,7 @@ cue_detach(device_ptr_t dev)
ether_ifdetach(ifp);
#else
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ if_free(ifp);
#endif
if (sc->cue_ep[CUE_ENDPT_TX] != NULL)
@@ -612,7 +616,7 @@ cue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
c = priv;
sc = c->ue_sc;
CUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
CUE_UNLOCK(sc);
@@ -647,7 +651,7 @@ cue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
ifp->if_ipackets++;
m_adj(m, sizeof(u_int16_t));
- m->m_pkthdr.rcvif = (struct ifnet *)&sc->cue_qdat;
+ m->m_pkthdr.rcvif = (void *)&sc->cue_qdat;
m->m_pkthdr.len = m->m_len = total_len;
/* Put the packet on the special USB input queue. */
@@ -682,7 +686,7 @@ cue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
c = priv;
sc = c->ue_sc;
CUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp;
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
@@ -730,7 +734,7 @@ cue_tick(void *xsc)
CUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp;
ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_SINGLECOLL);
ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_MULTICOLL);
@@ -831,7 +835,7 @@ Static void
cue_init(void *xsc)
{
struct cue_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->cue_ifp;
struct ue_chain *c;
usbd_status err;
int i;
@@ -850,7 +854,7 @@ cue_init(void *xsc)
/* Set MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- cue_csr_write_1(sc, CUE_PAR0 - i, sc->arpcom.ac_enaddr[i]);
+ cue_csr_write_1(sc, CUE_PAR0 - i, IFP2ENADDR(sc->cue_ifp)[i]);
/* Enable RX logic. */
cue_csr_write_1(sc, CUE_ETHCTL, CUE_ETHCTL_RX_ON|CUE_ETHCTL_MCAST_ON);
@@ -1013,7 +1017,7 @@ cue_stop(struct cue_softc *sc)
CUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->cue_ifp;
ifp->if_timer = 0;
cue_csr_write_1(sc, CUE_ETHCTL, 0);
diff --git a/sys/dev/usb/if_cuereg.h b/sys/dev/usb/if_cuereg.h
index a3a861d..f20aeed 100644
--- a/sys/dev/usb/if_cuereg.h
+++ b/sys/dev/usb/if_cuereg.h
@@ -142,7 +142,7 @@ struct cue_type {
#define CUE_INC(x, y) (x) = (x + 1) % y
struct cue_softc {
- struct arpcom arpcom;
+ struct ifnet *cue_ifp;
device_t cue_dev;
usbd_device_handle cue_udev;
usbd_interface_handle cue_iface;
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 7401eb1..b4c65e4 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -315,7 +316,7 @@ kue_setmulti(struct kue_softc *sc)
struct ifmultiaddr *ifma;
int i = 0;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->kue_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
sc->kue_rxfilt |= KUE_RXFILT_ALLMULTI;
@@ -472,10 +473,11 @@ USB_ATTACH(kue)
sc->kue_mcfilters = malloc(KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN,
M_USBDEV, M_NOWAIT);
- bcopy(sc->kue_desc.kue_macaddr,
- (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->kue_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("kue%d: can not if_alloc()\n", sc->kue_unit);
+ USB_ATTACH_ERROR_RETURN;
+ }
ifp->if_softc = sc;
if_initname(ifp, "kue", sc->kue_unit);
ifp->if_mtu = ETHERMTU;
@@ -515,7 +517,7 @@ kue_detach(device_ptr_t dev)
sc = device_get_softc(dev);
KUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->kue_ifp;
sc->kue_dying = 1;
@@ -524,6 +526,7 @@ kue_detach(device_ptr_t dev)
ether_ifdetach(ifp);
#else
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ if_free(ifp);
#endif
if (sc->kue_ep[KUE_ENDPT_TX] != NULL)
@@ -591,7 +594,7 @@ Static void kue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv,
c = priv;
sc = c->ue_sc;
KUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->kue_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
KUE_UNLOCK(sc);
@@ -628,7 +631,7 @@ Static void kue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv,
}
ifp->if_ipackets++;
- m->m_pkthdr.rcvif = (struct ifnet *)&sc->kue_qdat;
+ m->m_pkthdr.rcvif = (void *)&sc->kue_qdat;
m->m_pkthdr.len = m->m_len = total_len;
/* Put the packet on the special USB input queue. */
@@ -665,7 +668,7 @@ kue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
sc = c->ue_sc;
KUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->kue_ifp;
ifp->if_timer = 0;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -786,7 +789,7 @@ Static void
kue_init(void *xsc)
{
struct kue_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->kue_ifp;
struct ue_chain *c;
usbd_status err;
int i;
@@ -800,7 +803,7 @@ kue_init(void *xsc)
/* Set MAC address */
kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MAC,
- 0, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ 0, IFP2ENADDR(sc->kue_ifp), ETHER_ADDR_LEN);
sc->kue_rxfilt = KUE_RXFILT_UNICAST|KUE_RXFILT_BROADCAST;
@@ -956,7 +959,7 @@ kue_stop(struct kue_softc *sc)
struct ifnet *ifp;
KUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->kue_ifp;
ifp->if_timer = 0;
/* Stop transfers. */
diff --git a/sys/dev/usb/if_kuereg.h b/sys/dev/usb/if_kuereg.h
index 298526d..904ef12 100644
--- a/sys/dev/usb/if_kuereg.h
+++ b/sys/dev/usb/if_kuereg.h
@@ -135,7 +135,7 @@ struct kue_type {
#define KUE_INC(x, y) (x) = (x + 1) % y
struct kue_softc {
- struct arpcom arpcom;
+ struct ifnet *kue_ifp;
device_t kue_dev;
usbd_device_handle kue_udev;
usbd_interface_handle kue_iface;
diff --git a/sys/dev/usb/if_rue.c b/sys/dev/usb/if_rue.c
index d5d3a89..9990da1 100644
--- a/sys/dev/usb/if_rue.c
+++ b/sys/dev/usb/if_rue.c
@@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -481,7 +482,7 @@ rue_setmulti(struct rue_softc *sc)
u_int32_t rxcfg;
int mcnt = 0;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
rxcfg = rue_csr_read_2(sc, RUE_RCR);
@@ -664,9 +665,11 @@ USB_ATTACH(rue)
goto error1;
}
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("rue%d: can not if_alloc()\n", sc->rue_unit);
+ goto error1;
+ }
ifp->if_softc = sc;
if_initname(ifp, "rue", sc->rue_unit);
ifp->if_mtu = ETHERMTU;
@@ -683,7 +686,7 @@ USB_ATTACH(rue)
if (mii_phy_probe(self, &sc->rue_miibus,
rue_ifmedia_upd, rue_ifmedia_sts)) {
printf("rue%d: MII without any PHY!\n", sc->rue_unit);
- goto error1;
+ goto error2;
}
sc->rue_qdat.ifp = ifp;
@@ -703,6 +706,8 @@ USB_ATTACH(rue)
free(devinfo, M_USBDEV);
USB_ATTACH_SUCCESS_RETURN;
+ error2:
+ if_free(ifp);
error1:
RUE_UNLOCK(sc);
#if __FreeBSD_version >= 500000
@@ -721,7 +726,7 @@ rue_detach(device_ptr_t dev)
sc = device_get_softc(dev);
RUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
sc->rue_dying = 1;
untimeout(rue_tick, sc, sc->rue_stat_ch);
@@ -757,7 +762,7 @@ rue_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
struct rue_intrpkt *p;
RUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
RUE_UNLOCK(sc);
@@ -833,7 +838,7 @@ rue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
if (sc->rue_dying)
return;
RUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
RUE_UNLOCK(sc);
@@ -873,7 +878,7 @@ rue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
total_len -= ETHER_CRC_LEN;
ifp->if_ipackets++;
- m->m_pkthdr.rcvif = (struct ifnet *)&sc->rue_qdat;
+ m->m_pkthdr.rcvif = (void *)&sc->rue_qdat;
m->m_pkthdr.len = m->m_len = total_len;
/* Put the packet on the special USB input queue. */
@@ -906,7 +911,7 @@ rue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
RUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
@@ -951,7 +956,7 @@ rue_tick(void *xsc)
RUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
mii = GET_MII(sc);
if (mii == NULL) {
RUE_UNLOCK(sc);
@@ -1063,7 +1068,7 @@ Static void
rue_init(void *xsc)
{
struct rue_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rue_ifp;
struct mii_data *mii = GET_MII(sc);
struct ue_chain *c;
usbd_status err;
@@ -1083,7 +1088,8 @@ rue_init(void *xsc)
rue_reset(sc);
/* Set MAC address */
- rue_write_mem(sc, RUE_IDR0, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ rue_write_mem(sc, RUE_IDR0, IFP2ENADDR(sc->rue_ifp),
+ ETHER_ADDR_LEN);
/* Init TX ring. */
if (usb_ether_tx_list_init(sc, &sc->rue_cdata,
@@ -1308,7 +1314,7 @@ rue_stop(struct rue_softc *sc)
RUE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rue_ifp;
ifp->if_timer = 0;
rue_csr_write_1(sc, RUE_CR, 0x00);
diff --git a/sys/dev/usb/if_ruereg.h b/sys/dev/usb/if_ruereg.h
index 206cc7e..5a1b5f7 100644
--- a/sys/dev/usb/if_ruereg.h
+++ b/sys/dev/usb/if_ruereg.h
@@ -187,7 +187,7 @@ struct rue_type {
};
struct rue_softc {
- struct arpcom arpcom;
+ struct ifnet *rue_ifp;
device_t rue_dev;
device_t rue_miibus;
usbd_device_handle rue_udev;
diff --git a/sys/dev/usb/if_udav.c b/sys/dev/usb/if_udav.c
index 8d744ee..daa426d 100644
--- a/sys/dev/usb/if_udav.c
+++ b/sys/dev/usb/if_udav.c
@@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/ethernet.h>
+#include <net/if_types.h>
#if NBPFILTER > 0
#include <net/bpf.h>
@@ -384,12 +385,17 @@ USB_ATTACH(udav)
/* Print Ethernet Address */
printf("%s: Ethernet address %s\n", devname, ether_sprintf(eaddr));
-#if defined(__FreeBSD__)
- bcopy(eaddr, (char *)&sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN);
-#endif
-
/* initialize interface infomation */
+#if defined(__FreeBSD__)
+ ifp = GET_IFP(sc) = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("%s: can not if_alloc\n", devname);
+ UDAV_UNLOCK(sc);
+ goto bad;
+ }
+#else
ifp = GET_IFP(sc);
+#endif
ifp->if_softc = sc;
ifp->if_mtu = ETHERMTU;
#if defined(__NetBSD__)
@@ -527,6 +533,9 @@ USB_DETACH(udav)
#if defined(__NetBSD__)
if_detach(ifp);
#endif
+#if defined(__FreeBSD__)
+ if_free(ifp);
+#endif
#ifdef DIAGNOSTIC
if (sc->sc_pipe_tx != NULL)
@@ -836,7 +845,7 @@ udav_init(void *xsc)
#if defined(__NetBSD__)
eaddr = LLADDR(ifp->if_sadl);
#elif defined(__FreeBSD__)
- eaddr = sc->sc_ac.ac_enaddr ;
+ eaddr = IFP2ENADDR(ifp);
#endif
udav_csr_write(sc, UDAV_PAR, eaddr, ETHER_ADDR_LEN);
diff --git a/sys/dev/usb/if_udavreg.h b/sys/dev/usb/if_udavreg.h
index 404c9cb..5982857 100644
--- a/sys/dev/usb/if_udavreg.h
+++ b/sys/dev/usb/if_udavreg.h
@@ -137,7 +137,9 @@
#define UDAV_GPR_GEPIO1 (1<<1) /* General purpose 1 */
#define UDAV_GPR_GEPIO0 (1<<0) /* General purpose 0 */
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__)
+#define GET_IFP(sc) ((sc)->sc_ifp)
+#elif defined(__OpenBSD__)
#define GET_IFP(sc) (&(sc)->sc_ac.ac_if)
#elif defined(__NetBSD__)
#define GET_IFP(sc) (&(sc)->sc_ec.ec_if)
@@ -160,7 +162,7 @@
struct udav_softc {
#if defined(__FreeBSD__)
- struct arpcom sc_ac ; /* struct ifnet must be top of softc */
+ struct ifnet *sc_ifp;
#endif
USBBASEDEVICE sc_dev; /* base device */
usbd_device_handle sc_udev;
diff --git a/sys/dev/usb/if_ural.c b/sys/dev/usb/if_ural.c
index bf220cd..ea8f6ba 100644
--- a/sys/dev/usb/if_ural.c
+++ b/sys/dev/usb/if_ural.c
@@ -345,7 +345,7 @@ USB_MATCH(ural)
USB_ATTACH(ural)
{
USB_ATTACH_START(ural, sc, uaa);
- struct ifnet *ifp = &sc->sc_arp.ac_if;
+ struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed;
@@ -408,7 +408,8 @@ USB_ATTACH(ural)
printf("%s: MAC/BBP RT2570 (rev 0x%02x), RF %s\n",
USBDEVNAME(sc->sc_dev), sc->asic_rev, ural_get_rf(sc->rf_rev));
-
+
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
ifp->if_softc = sc;
if_initname(ifp, "ural", USBDEVUNIT(sc->sc_dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
diff --git a/sys/dev/usb/if_uralvar.h b/sys/dev/usb/if_uralvar.h
index 225a43a..634c3db 100644
--- a/sys/dev/usb/if_uralvar.h
+++ b/sys/dev/usb/if_uralvar.h
@@ -68,7 +68,7 @@ struct ural_rx_data {
};
struct ural_softc {
- struct arpcom sc_arp;
+ struct ifnet *sc_ifp;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
diff --git a/sys/dev/utopia/utopia.c b/sys/dev/utopia/utopia.c
index 1a9f353..c4416a0 100644
--- a/sys/dev/utopia/utopia.c
+++ b/sys/dev/utopia/utopia.c
@@ -154,14 +154,14 @@ utopia_check_carrier(struct utopia *utp, u_int carr_ok)
/* carrier */
utp->carrier = UTP_CARR_OK;
if (old != UTP_CARR_OK) {
- if_printf(&utp->ifatm->ifnet, "carrier detected\n");
+ if_printf(utp->ifatm->ifp, "carrier detected\n");
ATMEV_SEND_IFSTATE_CHANGED(utp->ifatm, 1);
}
} else {
/* no carrier */
utp->carrier = UTP_CARR_LOST;
if (old == UTP_CARR_OK) {
- if_printf(&utp->ifatm->ifnet, "carrier lost\n");
+ if_printf(utp->ifatm->ifp, "carrier lost\n");
ATMEV_SEND_IFSTATE_CHANGED(utp->ifatm, 0);
}
}
@@ -367,7 +367,7 @@ utopia_start(struct utopia *utp)
if (reg == (IDTPHY_REGM_MCR_DRIC | IDTPHY_REGM_MCR_EI))
utp->chip = &utopia_chip_idt77105;
else {
- if_printf(&utp->ifatm->ifnet,
+ if_printf(utp->ifatm->ifp,
"unknown ATM-PHY chip %#x\n", reg);
utp->chip = &utopia_chip_unknown;
}
diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c
index 470751f..4d5bda9 100644
--- a/sys/dev/vge/if_vge.c
+++ b/sys/dev/vge/if_vge.c
@@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_vlan_var.h>
#include <net/bpf.h>
@@ -575,7 +576,7 @@ vge_setmulti(sc)
struct ifmultiaddr *ifma;
u_int32_t h, hashes[2] = { 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
/* First, zot all the multicast entries. */
vge_cam_clear(sc);
@@ -997,7 +998,6 @@ vge_attach(dev)
vge_read_eeprom(sc, (caddr_t)eaddr, VGE_EE_EADDR, 3, 0);
sc->vge_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
#if __FreeBSD_version < 502113
printf("vge%d: Ethernet address: %6D\n", unit, eaddr, ":");
@@ -1033,7 +1033,12 @@ vge_attach(dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("vge%d: can not if_alloc()\n", sc->vge_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1095,7 +1100,7 @@ vge_detach(dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->vge_mtx), ("vge mutex not initialized"));
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
@@ -1114,6 +1119,7 @@ vge_detach(dev)
*/
ifp->if_flags &= ~IFF_UP;
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->vge_miibus)
device_delete_child(dev, sc->vge_miibus);
@@ -1329,7 +1335,7 @@ vge_rxeof(sc)
u_int32_t rxstat, rxctl;
VGE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
i = sc->vge_ldata.vge_rx_prodidx;
/* Invalidate the descriptor memory */
@@ -1508,7 +1514,7 @@ vge_txeof(sc)
u_int32_t txstat;
int idx;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
idx = sc->vge_ldata.vge_tx_considx;
/* Invalidate the TX descriptor list */
@@ -1568,7 +1574,7 @@ vge_tick(xsc)
struct mii_data *mii;
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
VGE_LOCK(sc);
mii = device_get_softc(sc->vge_miibus);
@@ -1576,14 +1582,14 @@ vge_tick(xsc)
if (sc->vge_link) {
if (!(mii->mii_media_status & IFM_ACTIVE)) {
sc->vge_link = 0;
- if_link_state_change(&sc->arpcom.ac_if,
+ if_link_state_change(sc->vge_ifp,
LINK_STATE_DOWN);
}
} else {
if (mii->mii_media_status & IFM_ACTIVE &&
IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
sc->vge_link = 1;
- if_link_state_change(&sc->arpcom.ac_if,
+ if_link_state_change(sc->vge_ifp,
LINK_STATE_UP);
#if __FreeBSD_version < 502114
if (ifp->if_snd.ifq_head != NULL)
@@ -1674,7 +1680,7 @@ vge_intr(arg)
}
VGE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
if (!(ifp->if_flags & IFF_UP)) {
VGE_UNLOCK(sc);
@@ -1819,7 +1825,7 @@ vge_encap(sc, m_head, idx)
* Set up hardware VLAN tagging.
*/
- mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m_head);
+ mtag = VLAN_OUTPUT_TAG(sc->vge_ifp, m_head);
if (mtag != NULL)
sc->vge_ldata.vge_tx_list[idx].vge_ctl |=
htole32(htons(VLAN_TAG_VALUE(mtag)) | VGE_TDCTL_VTAG);
@@ -1952,7 +1958,7 @@ vge_init(xsc)
void *xsc;
{
struct vge_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vge_ifp;
struct mii_data *mii;
int i;
@@ -1974,7 +1980,7 @@ vge_init(xsc)
/* Set our station address */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- CSR_WRITE_1(sc, VGE_PAR0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, VGE_PAR0 + i, IFP2ENADDR(sc->vge_ifp)[i]);
/*
* Set receive FIFO threshold. Also allow transmission and
@@ -2317,7 +2323,7 @@ vge_stop(sc)
struct ifnet *ifp;
VGE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
ifp->if_timer = 0;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
@@ -2397,7 +2403,7 @@ vge_resume(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vge_ifp;
/* reenable busmastering */
pci_enable_busmaster(dev);
diff --git a/sys/dev/vge/if_vgevar.h b/sys/dev/vge/if_vgevar.h
index c02676c..5d240a3 100644
--- a/sys/dev/vge/if_vgevar.h
+++ b/sys/dev/vge/if_vgevar.h
@@ -98,7 +98,7 @@ struct vge_list_data {
};
struct vge_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *vge_ifp; /* interface info */
device_t vge_dev;
bus_space_handle_t vge_bhandle; /* bus space handle */
bus_space_tag_t vge_btag; /* bus space tag */
diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c
index 502deb1..23194f7 100644
--- a/sys/dev/vr/if_vr.c
+++ b/sys/dev/vr/if_vr.c
@@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
@@ -508,7 +509,7 @@ vr_miibus_statchg(device_t dev)
static void
vr_setmulti(struct vr_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vr_ifp;
int h = 0;
uint32_t hashes[2] = { 0, 0 };
struct ifmultiaddr *ifma;
@@ -709,7 +710,6 @@ vr_attach(dev)
eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i);
sc->vr_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
sc->vr_ldata = contigmalloc(sizeof(struct vr_list_data), M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
@@ -722,7 +722,12 @@ vr_attach(dev)
bzero(sc->vr_ldata, sizeof(struct vr_list_data));
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vr_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("vr%d: can not if_alloc()\n", unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -762,6 +767,7 @@ vr_attach(dev)
if (error) {
printf("vr%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -783,7 +789,7 @@ static int
vr_detach(device_t dev)
{
struct vr_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vr_ifp;
KASSERT(mtx_initialized(&sc->vr_mtx), ("vr mutex not initialized"));
@@ -796,6 +802,7 @@ vr_detach(device_t dev)
vr_stop(sc);
VR_UNLOCK(sc); /* XXX: Avoid recursive acquire. */
ether_ifdetach(ifp);
+ if_free(ifp);
VR_LOCK(sc);
}
if (sc->vr_miibus)
@@ -938,7 +945,7 @@ vr_rxeof(struct vr_softc *sc)
uint32_t rxstat;
VR_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vr_ifp;
while (!((rxstat = sc->vr_cdata.vr_rx_head->vr_ptr->vr_status) &
VR_RXSTAT_OWN)) {
@@ -1014,7 +1021,7 @@ vr_rxeof(struct vr_softc *sc)
static void
vr_rxeoc(struct vr_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vr_ifp;
int i;
VR_LOCK_ASSERT(sc);
@@ -1052,7 +1059,7 @@ static void
vr_txeof(struct vr_softc *sc)
{
struct vr_chain *cur_tx;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vr_ifp;
VR_LOCK_ASSERT(sc);
@@ -1224,7 +1231,7 @@ static void
vr_intr(void *arg)
{
struct vr_softc *sc = arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vr_ifp;
uint16_t status;
VR_LOCK(sc);
@@ -1444,7 +1451,7 @@ vr_init(void *xsc)
static void
vr_init_locked(struct vr_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->vr_ifp;
struct mii_data *mii;
int i;
@@ -1458,7 +1465,7 @@ vr_init_locked(struct vr_softc *sc)
/* Set our station address. */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- CSR_WRITE_1(sc, VR_PAR0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, VR_PAR0 + i, IFP2ENADDR(sc->vr_ifp)[i]);
/* Set DMA size. */
VR_CLRBIT(sc, VR_BCR0, VR_BCR0_DMA_LENGTH);
@@ -1648,7 +1655,7 @@ vr_stop(struct vr_softc *sc)
VR_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->vr_ifp;
ifp->if_timer = 0;
untimeout(vr_tick, sc, sc->vr_stat_ch);
diff --git a/sys/dev/vr/if_vrreg.h b/sys/dev/vr/if_vrreg.h
index cbf4147..7d42656 100644
--- a/sys/dev/vr/if_vrreg.h
+++ b/sys/dev/vr/if_vrreg.h
@@ -452,7 +452,7 @@ struct vr_mii_frame {
#define VR_FLAG_DELAYTIMEO 3
struct vr_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *vr_ifp; /* interface info */
bus_space_handle_t vr_bhandle; /* bus space handle */
bus_space_tag_t vr_btag; /* bus space tag */
struct resource *vr_res;
diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c
index e526567..468fc4e 100644
--- a/sys/dev/vx/if_vx.c
+++ b/sys/dev/vx/if_vx.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_arp.h>
+#include <net/if_types.h>
#include <machine/bus.h>
@@ -140,8 +141,15 @@ int
vxattach(device_t dev)
{
struct vx_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
int i;
+ u_char eaddr[6];
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return 0;
+ }
callout_handle_init(&sc->ch);
GO_WINDOW(0);
@@ -164,8 +172,8 @@ vxattach(device_t dev)
if (vxbusyeeprom(sc))
return 0;
x = CSR_READ_2(sc, VX_W0_EEPROM_DATA);
- sc->arpcom.ac_enaddr[(i << 1)] = x >> 8;
- sc->arpcom.ac_enaddr[(i << 1) + 1] = x;
+ eaddr[(i << 1)] = x >> 8;
+ eaddr[(i << 1) + 1] = x;
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@@ -179,7 +187,7 @@ vxattach(device_t dev)
ifp->if_watchdog = vxwatchdog;
ifp->if_softc = sc;
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
sc->tx_start_thresh = 20; /* probably a good starting point. */
@@ -196,7 +204,7 @@ static void
vxinit(void *xsc)
{
struct vx_softc *sc = (struct vx_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int i;
VX_BUSY_WAIT;
@@ -204,7 +212,7 @@ vxinit(void *xsc)
GO_WINDOW(2);
for (i = 0; i < 6; i++) /* Reload the ether_addr. */
- CSR_WRITE_1(sc, VX_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, VX_W2_ADDR_0 + i, IFP2ENADDR(sc->ifp)[i]);
CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
VX_BUSY_WAIT;
@@ -247,7 +255,7 @@ vxinit(void *xsc)
static void
vxsetfilter(struct vx_softc *sc)
{
- register struct ifnet *ifp = &sc->arpcom.ac_if;
+ register struct ifnet *ifp = sc->ifp;
GO_WINDOW(1); /* Window 1 is operating window */
CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER |
@@ -290,7 +298,7 @@ vxgetlink(struct vx_softc *sc)
static void
vxsetlink(struct vx_softc *sc)
{
- register struct ifnet *ifp = &sc->arpcom.ac_if;
+ register struct ifnet *ifp = sc->ifp;
int i, j, k;
char *reason, *warning;
static int prev_flags;
@@ -397,7 +405,7 @@ vxstart(struct ifnet *ifp)
int sh, len, pad;
/* Don't transmit if interface is busy or not running */
- if ((sc->arpcom.ac_if.if_flags &
+ if ((sc->ifp->if_flags &
(IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
return;
@@ -445,7 +453,7 @@ startagain:
CSR_WRITE_2(sc, VX_COMMAND, SET_TX_START_THRESH |
((len / 4 + sc->tx_start_thresh) >> 2));
- BPF_MTAP(&sc->arpcom.ac_if, m);
+ BPF_MTAP(sc->ifp, m);
/*
* Do the output at splhigh() so that an interrupt from another device
@@ -523,23 +531,23 @@ vxstatus(struct vx_softc *sc)
GO_WINDOW(1);
if (fifost & FIFOS_RX_UNDERRUN) {
- if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("vx%d: RX underrun\n", sc->unit);
vxreset(sc);
return 0;
}
if (fifost & FIFOS_RX_STATUS_OVERRUN) {
- if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("vx%d: RX Status overrun\n", sc->unit);
return 1;
}
if (fifost & FIFOS_RX_OVERRUN) {
- if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("vx%d: RX overrun\n", sc->unit);
return 1;
}
if (fifost & FIFOS_TX_OVERRUN) {
- if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("vx%d: TX overrun\n", sc->unit);
vxreset(sc);
return 0;
@@ -560,13 +568,13 @@ vxtxstat(struct vx_softc *sc)
CSR_WRITE_1(sc, VX_W1_TX_STATUS, 0x0);
if (i & TXS_JABBER) {
- ++sc->arpcom.ac_if.if_oerrors;
- if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
+ ++sc->ifp->if_oerrors;
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("vx%d: jabber (%x)\n", sc->unit, i);
vxreset(sc);
} else if (i & TXS_UNDERRUN) {
- ++sc->arpcom.ac_if.if_oerrors;
- if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
+ ++sc->ifp->if_oerrors;
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("vx%d: fifo underrun (%x) @%d\n",
sc->unit, i, sc->tx_start_thresh);
if (sc->tx_succ_ok < 100)
@@ -575,9 +583,9 @@ vxtxstat(struct vx_softc *sc)
sc->tx_succ_ok = 0;
vxreset(sc);
} else if (i & TXS_MAX_COLLISION) {
- ++sc->arpcom.ac_if.if_collisions;
+ ++sc->ifp->if_collisions;
CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
} else
sc->tx_succ_ok = (sc->tx_succ_ok + 1) & 127;
}
@@ -588,7 +596,7 @@ vxintr(void *voidsc)
{
register short status;
struct vx_softc *sc = voidsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
for (;;) {
CSR_WRITE_2(sc, VX_COMMAND, C_INTR_LATCH);
@@ -611,8 +619,8 @@ vxintr(void *voidsc)
vxread(sc);
if (status & S_TX_AVAIL) {
ifp->if_timer = 0;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- vxstart(&sc->arpcom.ac_if);
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ vxstart(sc->ifp);
}
if (status & S_CARD_FAILURE) {
printf("vx%d: adapter failure (%x)\n",
@@ -635,7 +643,7 @@ vxintr(void *voidsc)
static void
vxread(struct vx_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *m;
struct ether_header *eh;
u_int len;
@@ -705,7 +713,7 @@ again:
*/
if ((eh->ether_dhost[0] & 1) == 0 /* !mcast and !bcast */
- && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN)!=0) {
+ && bcmp(eh->ether_dhost, IFP2ENADDR(sc->ifp), ETHER_ADDR_LEN)!=0) {
m_freem(m);
return;
}
@@ -747,7 +755,7 @@ abort:
static struct mbuf *
vxget(struct vx_softc *sc, u_int totlen)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *top, **mp, *m;
int len;
int sh;
@@ -929,7 +937,7 @@ vxwatchdog(struct ifnet *ifp)
void
vxstop(struct vx_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
ifp->if_timer = 0;
diff --git a/sys/dev/vx/if_vxvar.h b/sys/dev/vx/if_vxvar.h
index 8b3a27c..014d058 100644
--- a/sys/dev/vx/if_vxvar.h
+++ b/sys/dev/vx/if_vxvar.h
@@ -35,7 +35,7 @@
* Ethernet software status per interface.
*/
struct vx_softc {
- struct arpcom arpcom; /* Ethernet common part */
+ struct ifnet *ifp;
int unit; /* unit number */
bus_space_tag_t bst;
bus_space_handle_t bsh;
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index c3ace2d..1cd2b9f 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -238,7 +238,7 @@ wi_attach(device_t dev)
{
struct wi_softc *sc = device_get_softc(dev);
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp;
int i, nrates, buflen;
u_int16_t val;
u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
@@ -248,6 +248,13 @@ wi_attach(device_t dev)
};
int error;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc\n");
+ wi_free(dev);
+ return (ENOSPC);
+ }
+
/*
* NB: no locking is needed here; don't put it here
* unless you can prove it!
@@ -511,7 +518,7 @@ int
wi_detach(device_t dev)
{
struct wi_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
WI_LOCK_DECL();
WI_LOCK(sc);
@@ -525,6 +532,7 @@ wi_detach(device_t dev)
bpfdetach(ifp);
#endif
ieee80211_ifdetach(&sc->sc_ic);
+ if_free(sc->sc_ifp);
WI_UNLOCK(sc);
bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
wi_free(dev);
@@ -548,7 +556,7 @@ wi_activate(struct device *self, enum devact act)
break;
case DVACT_DEACTIVATE:
- if_deactivate(&sc->sc_if);
+ if_deactivate(sc->sc_ifp);
break;
}
splx(s);
@@ -558,7 +566,7 @@ wi_activate(struct device *self, enum devact act)
void
wi_power(struct wi_softc *sc, int why)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
int s;
s = splnet();
@@ -587,14 +595,14 @@ wi_shutdown(device_t dev)
{
struct wi_softc *sc = device_get_softc(dev);
- wi_stop(&sc->sc_if, 1);
+ wi_stop(sc->sc_ifp, 1);
}
void
wi_intr(void *arg)
{
struct wi_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int16_t status;
WI_LOCK_DECL();
@@ -636,7 +644,7 @@ void
wi_init(void *arg)
{
struct wi_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = &sc->sc_ic;
struct wi_joinreq join;
int i;
@@ -1012,7 +1020,7 @@ wi_start(struct ifnet *ifp)
static int
wi_reset(struct wi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
#define WI_INIT_TRIES 3
int i;
int error = 0;
@@ -1301,7 +1309,7 @@ wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[IEEE80211_ADDR_LEN])
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211_node *ni = ic->ic_bss;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
if (IEEE80211_ADDR_EQ(new_bssid, ni->ni_bssid))
return;
@@ -1332,7 +1340,7 @@ wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[IEEE80211_ADDR_LEN])
static void
wi_rx_monitor(struct wi_softc *sc, int fid)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct wi_frame *rx_frame;
struct mbuf *m;
int datlen, hdrlen;
@@ -1415,7 +1423,7 @@ static void
wi_rx_intr(struct wi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct wi_frame frmhdr;
struct mbuf *m;
struct ieee80211_frame *wh;
@@ -1558,7 +1566,7 @@ wi_rx_intr(struct wi_softc *sc)
static void
wi_tx_ex_intr(struct wi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct wi_frame frmhdr;
int fid;
@@ -1602,7 +1610,7 @@ wi_tx_ex_intr(struct wi_softc *sc)
static void
wi_tx_intr(struct wi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
int fid, cur;
if (sc->wi_gone)
@@ -1638,7 +1646,7 @@ static void
wi_info_intr(struct wi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i, fid, len, off;
u_int16_t ltbuf[2];
u_int16_t stat;
@@ -1718,7 +1726,7 @@ wi_info_intr(struct wi_softc *sc)
static int
wi_write_multi(struct wi_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
int n;
struct ifmultiaddr *ifma;
struct wi_mcast mlist;
@@ -2785,7 +2793,7 @@ wi_scan_ap(struct wi_softc *sc, u_int16_t chanmask, u_int16_t txrate)
}
if (error == 0) {
sc->sc_scan_timer = WI_SCAN_WAIT;
- sc->sc_if.if_timer = 1;
+ sc->sc_ifp->if_timer = 1;
DPRINTF(("wi_scan_ap: start scanning, "
"chamask 0x%x txrate 0x%x\n", chanmask, txrate));
}
diff --git a/sys/dev/wi/if_wivar.h b/sys/dev/wi/if_wivar.h
index 0cb26e9..f1fda24 100644
--- a/sys/dev/wi/if_wivar.h
+++ b/sys/dev/wi/if_wivar.h
@@ -62,7 +62,7 @@
#define WI_MAX_AID 256 /* max stations for ap operation */
struct wi_softc {
- struct arpcom sc_arp;
+ struct ifnet *sc_ifp;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
@@ -178,7 +178,6 @@ struct wi_softc {
} u_rx_rt;
int sc_rx_th_len;
};
-#define sc_if sc_arp.ac_if
#define sc_tx_th u_tx_rt.th
#define sc_rx_th u_rx_rt.th
diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c
index 44a7d4c..562baf4 100644
--- a/sys/dev/wl/if_wl.c
+++ b/sys/dev/wl/if_wl.c
@@ -211,6 +211,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
+#include <net/if_types.h>
#ifdef INET
#include <netinet/in.h>
@@ -231,9 +232,7 @@ __FBSDID("$FreeBSD$");
static char t_packet[ETHERMTU + sizeof(struct ether_header) + sizeof(long)];
struct wl_softc{
- struct arpcom wl_ac; /* Ethernet common part */
-#define wl_if wl_ac.ac_if /* network visible interface */
-#define wl_addr wl_ac.ac_enaddr /* hardware address */
+ struct ifnet *ifp;
u_char psa[0x40];
u_char nwid[2]; /* current radio modem nwid */
short base;
@@ -484,9 +483,14 @@ wlattach(device_t device)
int error, i, j;
int unit;
struct ifnet *ifp;
+ u_char eaddr[6];
sc = device_get_softc(device);
- ifp = &sc->wl_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(device, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
mtx_init(&sc->wl_mtx, device_get_nameunit(device), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
@@ -530,7 +534,7 @@ wlattach(device_t device)
else
j = WLPSA_UNIMAC;
for (i=0; i < WAVELAN_ADDR_SIZE; ++i)
- sc->wl_addr[i] = sc->psa[j + i];
+ eaddr[i] = sc->psa[j + i];
/* enter normal 16 bit mode operation */
sc->hacr = HACR_DEFAULT;
@@ -543,7 +547,6 @@ wlattach(device_t device)
outw(PIOP1(base), 0); /* clear scb_rscerrs */
outw(PIOP1(base), 0); /* clear scb_ovrnerrs */
- bzero(ifp, sizeof(ifp));
ifp->if_softc = sc;
ifp->if_mtu = WAVELAN_MTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
@@ -564,9 +567,8 @@ wlattach(device_t device)
ifp->if_done
ifp->if_reset
*/
- ether_ifattach(ifp, &sc->wl_addr[0]);
+ ether_ifattach(ifp, eaddr);
- bcopy(&sc->wl_addr[0], sc->wl_ac.ac_enaddr, WAVELAN_ADDR_SIZE);
if_printf(ifp, "NWID 0x%02x%02x", sc->nwid[0], sc->nwid[1]);
if (sc->freq24)
printf(", Freq %d MHz",sc->freq24); /* 2.4 Gz */
@@ -586,8 +588,9 @@ wldetach(device_t device)
device_t parent = device_get_parent(device);
struct ifnet *ifp;
- ifp = &sc->wl_if;
+ ifp = sc->ifp;
ether_ifdetach(ifp);
+ if_free(ifp);
WL_LOCK(sc);
@@ -796,23 +799,23 @@ static void
wlinit(void *xsc)
{
struct wl_softc *sc = xsc;
- struct ifnet *ifp = &sc->wl_if;
+ struct ifnet *ifp = sc->ifp;
int stat;
u_long oldpri;
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wlinit()\n",sc->unit);
#endif
WL_LOCK(sc);
oldpri = splimp();
if ((stat = wlhwrst(sc)) == TRUE) {
- sc->wl_if.if_flags |= IFF_RUNNING; /* same as DSF_RUNNING */
+ sc->ifp->if_flags |= IFF_RUNNING; /* same as DSF_RUNNING */
/*
* OACTIVE is used by upper-level routines
* and must be set
*/
- sc->wl_if.if_flags &= ~IFF_OACTIVE; /* same as tbusy below */
+ sc->ifp->if_flags &= ~IFF_OACTIVE; /* same as tbusy below */
sc->flags |= DSF_RUNNING;
sc->tbusy = 0;
@@ -841,7 +844,7 @@ wlhwrst(struct wl_softc *sc)
{
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wlhwrst()\n", sc->unit);
#endif
sc->hacr = HACR_RESET;
@@ -852,7 +855,7 @@ wlhwrst(struct wl_softc *sc)
CMD(sc);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
wlmmcstat(sc); /* Display MMC registers */
#endif /* WLDEBUG */
wlbldcu(sc); /* set up command unit structures */
@@ -967,7 +970,7 @@ wlstart(struct ifnet *ifp)
WL_LOCK(sc);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("%s: entered wlstart()\n", ifp->if_xname);
#endif
@@ -987,7 +990,7 @@ wlstart(struct ifnet *ifp)
(cu_status & AC_SW_B) == 0){
sc->tbusy = 0;
untimeout(wlwatchdog, sc, sc->watchdog_ch);
- sc->wl_ac.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
/*
* This is probably just a race. The xmt'r is just
* became idle but WE have masked interrupts so ...
@@ -1013,7 +1016,7 @@ wlstart(struct ifnet *ifp)
}
/* get ourselves some data */
- ifp = &(sc->wl_if);
+ ifp = sc->ifp;
IF_DEQUEUE(&ifp->if_snd, m);
if (m != (struct mbuf *)0) {
/* let BPF see it before we commit it */
@@ -1024,11 +1027,11 @@ wlstart(struct ifnet *ifp)
*/
/* try 10 ticks, not very long */
sc->watchdog_ch = timeout(wlwatchdog, sc, 10);
- sc->wl_ac.ac_if.if_flags |= IFF_OACTIVE;
- sc->wl_if.if_opackets++;
+ sc->ifp->if_flags |= IFF_OACTIVE;
+ sc->ifp->if_opackets++;
wlxmt(sc, m);
} else {
- sc->wl_ac.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
}
WL_UNLOCK(sc);
return;
@@ -1055,7 +1058,7 @@ wlstart(struct ifnet *ifp)
static int
wlread(struct wl_softc *sc, u_short fd_p)
{
- struct ifnet *ifp = &sc->wl_if;
+ struct ifnet *ifp = sc->ifp;
short base = sc->base;
fd_t fd;
struct ether_header *eh;
@@ -1068,7 +1071,7 @@ wlread(struct wl_softc *sc, u_short fd_p)
WL_LOCK_ASSERT(sc);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wlread()\n", sc->unit);
#endif
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
@@ -1183,21 +1186,21 @@ wlread(struct wl_softc *sc, u_short fd_p)
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))
+ (sc->ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI))
#else
/* hw is in promisc mode if this is true */
(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,
+ bcmp(eh->ether_dhost, &IFP2ENADDR(sc->ifp),
sizeof(eh->ether_dhost)) != 0 ) {
m_freem(m);
return 1;
}
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: wlrecv %u bytes\n", sc->unit, mlen);
#endif
@@ -1245,7 +1248,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
WL_LOCK(sc);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("%s: entered wlioctl()\n", ifp->if_xname);
#endif
opri = splimp();
@@ -1481,7 +1484,7 @@ wlwatchdog(void *vsc)
log(LOG_ERR, "wl%d: wavelan device timeout on xmit\n", unit);
WL_LOCK(sc);
- sc->wl_ac.ac_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
wlinit(sc);
WL_UNLOCK(sc);
}
@@ -1508,7 +1511,7 @@ wlintr(void *arg)
WL_LOCK(sc);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: wlintr() called\n", sc->unit);
#endif
@@ -1545,16 +1548,16 @@ wlintr(void *arg)
* incoming packet
*/
if (int_type & SCB_SW_FR) {
- sc->wl_if.if_ipackets++;
+ sc->ifp->if_ipackets++;
wlrcv(sc);
}
/*
* receiver not ready
*/
if (int_type & SCB_SW_RNR) {
- sc->wl_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d intr(): receiver overrun! begin_fd = %x\n",
sc->unit, sc->begin_fd);
#endif
@@ -1613,19 +1616,19 @@ wlintr(void *arg)
/* if the transmit actually failed, or returned some status */
if ((!(ac_status & AC_SW_OK)) || (ac_status & 0xfff)) {
if (ac_status & (TC_COLLISION | TC_CLS | TC_DMA)) {
- sc->wl_if.if_oerrors++;
+ sc->ifp->if_oerrors++;
}
/* count collisions */
- sc->wl_if.if_collisions += (ac_status & 0xf);
+ sc->ifp->if_collisions += (ac_status & 0xf);
/* if TC_COLLISION set and collision count zero, 16 collisions */
if ((ac_status & 0x20) == 0x20) {
- sc->wl_if.if_collisions += 0x10;
+ sc->ifp->if_collisions += 0x10;
}
}
sc->tbusy = 0;
untimeout(wlwatchdog, sc, sc->watchdog_ch);
- sc->wl_ac.ac_if.if_flags &= ~IFF_OACTIVE;
- wlstart(&(sc->wl_if));
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
+ wlstart(sc->ifp);
}
}
WL_UNLOCK(sc);
@@ -1653,7 +1656,7 @@ wlrcv(struct wl_softc *sc)
u_short fd_p, status, offset, link_offset;
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wlrcv()\n", sc->unit);
#endif
for (fd_p = sc->begin_fd; fd_p != I82586NULL; fd_p = sc->begin_fd) {
@@ -1671,16 +1674,16 @@ wlrcv(struct wl_softc *sc)
if (status == (RFD_DONE|RFD_RSC)) {
/* lost one */
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d RCV: RSC %x\n", sc->unit, status);
#endif
- sc->wl_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
} else if (!(status & RFD_OK)) {
printf("wl%d RCV: !OK %x\n", sc->unit, status);
- sc->wl_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
} else if (status & 0xfff) { /* can't happen */
printf("wl%d RCV: ERRs %x\n", sc->unit, status);
- sc->wl_if.if_ierrors++;
+ sc->ifp->if_ierrors++;
} else if (!wlread(sc, fd_p))
return;
@@ -1783,8 +1786,8 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
int spin;
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("%s: entered wlxmt()\n", sc->wl_if.if_xname);
+ if (sc->ifp->if_flags & IFF_DEBUG)
+ printf("%s: entered wlxmt()\n", sc->ifp->if_xname);
#endif
cb.ac_status = 0;
@@ -1797,7 +1800,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
outw(PIOP1(base), eh_p->ether_type);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG) {
+ if (sc->ifp->if_flags & IFF_DEBUG) {
if (xmt_debug) {
printf("XMT mbuf: L%d @%p ", count, (void *)mb_p);
printf("ether type %x\n", eh_p->ether_type);
@@ -1855,13 +1858,13 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
count = tm_p->m_len;
mb_p = mtod(tm_p, u_char *);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
if (xmt_debug)
printf("mbuf+ L%d @%p ", count, (void *)mb_p);
#endif /* WLDEBUG */
}
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
if (xmt_debug)
printf("CLEN = %d\n", clen);
#endif /* WLDEBUG */
@@ -1876,7 +1879,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
outw(PIOR0(base), tbd_p + 2);
outw(PIOP0(base), I82586NULL);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG) {
+ if (sc->ifp->if_flags & IFF_DEBUG) {
if (xmt_debug) {
wltbd(sc);
printf("\n");
@@ -1894,7 +1897,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m)
break;
}
if ((spin == 0) && xmt_watch) { /* not waking up, and we care */
- printf("%s: slow accepting xmit\n", sc->wl_if.if_xname);
+ printf("%s: slow accepting xmit\n", sc->ifp->if_xname);
}
}
outw(PIOP0(base), SCB_CU_STRT); /* new command */
@@ -1984,7 +1987,7 @@ wlrustrt(struct wl_softc *sc)
u_short rfa;
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wlrustrt()\n", sc->unit);
#endif
outw(PIOR0(base), OFFSET_SCB);
@@ -2017,7 +2020,7 @@ wldiag(struct wl_softc *sc)
short status;
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wldiag()\n", sc->unit);
#endif
outw(PIOR0(base), OFFSET_SCB);
@@ -2061,7 +2064,7 @@ wlconfig(struct wl_softc *sc)
#endif /* MULTICAST */
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: entered wlconfig()\n", sc->unit);
#endif
outw(PIOR0(base), OFFSET_SCB);
@@ -2118,7 +2121,7 @@ wlconfig(struct wl_softc *sc)
outw(PIOP1(base), 0); /* ac_status */
outw(PIOP1(base), AC_MCSETUP|AC_CW_EL); /* ac_command */
outw(PIOR1(base), OFFSET_CU + 8);
- TAILQ_FOREACH(ifma, &sc->wl_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
@@ -2138,7 +2141,7 @@ wlconfig(struct wl_softc *sc)
outw(PIOP1(base), 0); /* ac_status */
outw(PIOP1(base), AC_IASETUP|AC_CW_EL); /* ac_command */
outw(PIOR1(base), OFFSET_CU + 6);
- outsw(PIOP1(base), sc->wl_addr, WAVELAN_ADDR_SIZE/2);
+ outsw(PIOP1(base), IFP2ENADDR(sc->ifp), WAVELAN_ADDR_SIZE/2);
if (wlcmd(sc, "config()-address") == 0)
return(0);
@@ -2212,7 +2215,7 @@ wlack(struct wl_softc *sc)
if (!(cmd = (inw(PIOP1(base)) & SCB_SW_INT)))
return(0);
#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
+ if (sc->ifp->if_flags & IFF_DEBUG)
printf("wl%d: doing a wlack()\n", sc->unit);
#endif
outw(PIOP1(base), cmd);
diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c
index a1db102..38ec6de 100644
--- a/sys/dev/xe/if_xe.c
+++ b/sys/dev/xe/if_xe.c
@@ -117,6 +117,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_media.h>
#include <net/if_mib.h>
#include <net/bpf.h>
+#include <net/if_types.h>
#include <dev/xe/if_xereg.h>
#include <dev/xe/if_xevar.h>
@@ -225,7 +226,9 @@ xe_attach (device_t dev)
/* Initialise stuff... */
scp->dev = dev;
- scp->ifp = &scp->arpcom.ac_if;
+ scp->ifp = scp->ifp = if_alloc(IFT_ETHER);
+ if (scp->ifp == NULL)
+ return ENOSPC;
scp->ifm = &scp->ifmedia;
scp->autoneg_status = XE_AUTONEG_NONE;
@@ -294,7 +297,7 @@ xe_attach (device_t dev)
}
/* Attach the interface */
- ether_ifattach(scp->ifp, scp->arpcom.ac_enaddr);
+ ether_ifattach(scp->ifp, scp->enaddr);
/* Done */
return 0;
@@ -374,7 +377,7 @@ xe_init(void *xscp) {
/* Put MAC address in first 'individual address' register */
XE_SELECT_PAGE(0x50);
for (i = 0; i < 6; i++)
- XE_OUTB(0x08 + i, scp->arpcom.ac_enaddr[scp->mohawk ? 5 - i : i]);
+ XE_OUTB(0x08 + i, IFP2ENADDR(scp->ifp)[scp->mohawk ? 5 - i : i]);
/* Set up multicast addresses */
xe_set_multicast(scp);
@@ -564,7 +567,7 @@ xe_intr(void *xscp)
struct ifnet *ifp;
u_int8_t psr, isr, esr, rsr, rst0, txst0, txst1, coll;
- ifp = &scp->arpcom.ac_if;
+ ifp = scp->ifp;
/* Disable interrupts */
if (scp->mohawk)
@@ -936,7 +939,7 @@ static void xe_setmedia(void *xscp) {
case XE_AUTONEG_NONE:
DEVPRINTF(2, (scp->dev, "Waiting for idle transmitter\n"));
- scp->arpcom.ac_if.if_flags |= IFF_OACTIVE;
+ scp->ifp->if_flags |= IFF_OACTIVE;
scp->autoneg_status = XE_AUTONEG_WAITING;
/* FALL THROUGH */
@@ -1254,7 +1257,7 @@ xe_set_multicast(struct xe_softc *scp) {
DEVPRINTF(2, (scp->dev, "set_multicast\n"));
- ifp = &scp->arpcom.ac_if;
+ ifp = scp->ifp;
XE_SELECT_PAGE(0x42);
/* Handle PROMISC flag */
@@ -1312,7 +1315,7 @@ xe_set_multicast(struct xe_softc *scp) {
else if (count < 10) {
/* Full in any unused Individual Addresses with our MAC address */
for (i = count + 1; i < 10; i++)
- xe_set_addr(scp, (u_int8_t *)(&scp->arpcom.ac_enaddr), i);
+ xe_set_addr(scp, (u_int8_t *)(&IFP2ENADDR(scp->ifp)), i);
/* Enable Individual Address matching only */
XE_SELECT_PAGE(0x42);
XE_OUTB(XE_SWC1, (XE_INB(XE_SWC1) & ~XE_SWC1_ALLMULTI) | XE_SWC1_IA_ENABLE);
diff --git a/sys/dev/xe/if_xe_pccard.c b/sys/dev/xe/if_xe_pccard.c
index 266f11d..a5c4bde 100644
--- a/sys/dev/xe/if_xe_pccard.c
+++ b/sys/dev/xe/if_xe_pccard.c
@@ -243,7 +243,7 @@ xe_macfix(device_t dev, int offset)
}
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] = cisdata[i + 3];
+ sc->enaddr[i] = cisdata[i + 3];
}
bus_release_resource(dev, SYS_RES_MEMORY, rid, r);
@@ -331,14 +331,14 @@ xe_pccard_probe(device_t dev)
scp->modem = 1;
/* Get MAC address */
- pccard_get_ether(dev, scp->arpcom.ac_enaddr);
+ pccard_get_ether(dev, scp->enaddr);
/* Deal with bogus MAC address */
if (xpp->product.pp_vendor == PCMCIA_VENDOR_XIRCOM
&& scp->ce2
- && (scp->arpcom.ac_enaddr[0] != XE_MAC_ADDR_0
- || scp->arpcom.ac_enaddr[1] != XE_MAC_ADDR_1
- || scp->arpcom.ac_enaddr[2] != XE_MAC_ADDR_2)
+ && (scp->enaddr[0] != XE_MAC_ADDR_0
+ || scp->enaddr[1] != XE_MAC_ADDR_1
+ || scp->enaddr[2] != XE_MAC_ADDR_2)
&& xe_macfix(dev, XE_BOGUS_MAC_OFFSET) < 0) {
device_printf(dev,
"Unable to find MAC address for your %s card\n",
@@ -391,8 +391,9 @@ xe_pccard_detach(device_t dev)
DEVPRINTF(2, (dev, "pccard_detach\n"));
- sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
- ether_ifdetach(&sc->arpcom.ac_if);
+ sc->ifp->if_flags &= ~IFF_RUNNING;
+ ether_ifdetach(sc->ifp);
+ if_free(sc->ifp);
xe_deactivate(dev);
return (0);
}
diff --git a/sys/dev/xe/if_xevar.h b/sys/dev/xe/if_xevar.h
index 0415881..0e66102 100644
--- a/sys/dev/xe/if_xevar.h
+++ b/sys/dev/xe/if_xevar.h
@@ -33,12 +33,12 @@
* One of these structures per allocated device
*/
struct xe_softc {
- struct arpcom arpcom;
struct ifmedia ifmedia;
struct ifmib_iso_8802_3 mibdata;
struct callout_handle chand;
struct ifnet *ifp;
struct ifmedia *ifm;
+ u_char enaddr[6];
const char *card_type;/* Card model name */
const char *vendor; /* Card manufacturer */
device_t dev; /* Device */
OpenPOWER on IntegriCloud