summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/ndis/kern_ndis.c6
-rw-r--r--sys/compat/ndis/subr_ndis.c6
-rw-r--r--sys/contrib/altq/altq/altq_rio.c2
-rw-r--r--sys/contrib/dev/oltr/if_oltr.c23
-rw-r--r--sys/contrib/dev/oltr/if_oltr_pci.c3
-rw-r--r--sys/contrib/dev/oltr/if_oltrvar.h2
-rw-r--r--sys/contrib/pf/net/if_pflog.c10
-rw-r--r--sys/contrib/pf/net/if_pflog.h4
-rw-r--r--sys/contrib/pf/net/if_pfsync.c9
-rw-r--r--sys/contrib/pf/net/if_pfsync.h4
-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
-rw-r--r--sys/i386/isa/if_el.c67
-rw-r--r--sys/i4b/driver/i4b_ipr.c161
-rw-r--r--sys/i4b/driver/i4b_isppp.c139
-rw-r--r--sys/kern/uipc_socket.c6
-rw-r--r--sys/net/bpf.c2
-rw-r--r--sys/net/bridge.c2
-rw-r--r--sys/net/bridge.h1
-rw-r--r--sys/net/bridgestp.c4
-rw-r--r--sys/net/firewire.h3
-rw-r--r--sys/net/if.c108
-rw-r--r--sys/net/if_arc.h2
-rw-r--r--sys/net/if_arcsubr.c58
-rw-r--r--sys/net/if_arp.h17
-rw-r--r--sys/net/if_atm.h13
-rw-r--r--sys/net/if_atmsubr.c44
-rw-r--r--sys/net/if_bridge.c72
-rw-r--r--sys/net/if_bridgevar.h2
-rw-r--r--sys/net/if_disc.c15
-rw-r--r--sys/net/if_ef.c43
-rw-r--r--sys/net/if_ethersubr.c63
-rw-r--r--sys/net/if_faith.c38
-rw-r--r--sys/net/if_fddisubr.c16
-rw-r--r--sys/net/if_fwsubr.c60
-rw-r--r--sys/net/if_gif.c49
-rw-r--r--sys/net/if_gif.h3
-rw-r--r--sys/net/if_gre.c43
-rw-r--r--sys/net/if_gre.h3
-rw-r--r--sys/net/if_iso88025subr.c58
-rw-r--r--sys/net/if_loop.c30
-rw-r--r--sys/net/if_ppp.c75
-rw-r--r--sys/net/if_pppvar.h3
-rw-r--r--sys/net/if_sl.c143
-rw-r--r--sys/net/if_slvar.h3
-rw-r--r--sys/net/if_sppp.h5
-rw-r--r--sys/net/if_spppfr.c2
-rw-r--r--sys/net/if_spppsubr.c115
-rw-r--r--sys/net/if_stf.c34
-rw-r--r--sys/net/if_tap.c33
-rw-r--r--sys/net/if_tapvar.h3
-rw-r--r--sys/net/if_tun.c55
-rw-r--r--sys/net/if_types.h1
-rw-r--r--sys/net/if_var.h28
-rw-r--r--sys/net/if_vlan.c53
-rw-r--r--sys/net/ppp_tty.c48
-rw-r--r--sys/net80211/ieee80211_ioctl.c8
-rw-r--r--sys/netatalk/aarp.c10
-rw-r--r--sys/netatm/atm_if.c28
-rw-r--r--sys/netatm/atm_if.h5
-rw-r--r--sys/netatm/atm_socket.c2
-rw-r--r--sys/netatm/atm_usrreq.c2
-rw-r--r--sys/netatm/ipatm/ipatm_input.c2
-rw-r--r--sys/netatm/ipatm/ipatm_load.c2
-rw-r--r--sys/netatm/ipatm/ipatm_output.c4
-rw-r--r--sys/netatm/ipatm/ipatm_usrreq.c6
-rw-r--r--sys/netatm/ipatm/ipatm_vcm.c4
-rw-r--r--sys/netatm/spans/spans_arp.c4
-rw-r--r--sys/netatm/uni/uniarp.c8
-rw-r--r--sys/netatm/uni/uniarp_cache.c2
-rw-r--r--sys/netgraph/atm/atmpif/ng_atmpif_harp.c10
-rw-r--r--sys/netgraph/atm/ng_atm.c4
-rw-r--r--sys/netgraph/ng_eiface.c28
-rw-r--r--sys/netgraph/ng_ether.c8
-rw-r--r--sys/netgraph/ng_fec.c44
-rw-r--r--sys/netgraph/ng_gif.c4
-rw-r--r--sys/netgraph/ng_iface.c4
-rw-r--r--sys/netgraph/ng_sppp.c61
-rw-r--r--sys/netinet/in_gif.c10
-rw-r--r--sys/netinet/ip_carp.c193
-rw-r--r--sys/netinet/ip_gre.c22
-rw-r--r--sys/netinet/ip_output.c4
-rw-r--r--sys/netinet6/in6_gif.c10
-rw-r--r--sys/netinet6/ip6_output.c2
-rw-r--r--sys/netipx/ipx_ip.c20
-rw-r--r--sys/netipx/ipx_ip.h2
-rw-r--r--sys/pci/if_dc.c54
-rw-r--r--sys/pci/if_dcreg.h2
-rw-r--r--sys/pci/if_de.c287
-rw-r--r--sys/pci/if_devar.h6
-rw-r--r--sys/pci/if_mn.c2
-rw-r--r--sys/pci/if_pcn.c33
-rw-r--r--sys/pci/if_pcnreg.h2
-rw-r--r--sys/pci/if_rl.c40
-rw-r--r--sys/pci/if_rlreg.h2
-rw-r--r--sys/pci/if_sf.c37
-rw-r--r--sys/pci/if_sfreg.h2
-rw-r--r--sys/pci/if_sis.c41
-rw-r--r--sys/pci/if_sisreg.h2
-rw-r--r--sys/pci/if_sk.c52
-rw-r--r--sys/pci/if_skreg.h2
-rw-r--r--sys/pci/if_ste.c35
-rw-r--r--sys/pci/if_stereg.h2
-rw-r--r--sys/pci/if_ti.c64
-rw-r--r--sys/pci/if_tireg.h2
-rw-r--r--sys/pci/if_tl.c48
-rw-r--r--sys/pci/if_tlreg.h2
-rw-r--r--sys/pci/if_vr.c29
-rw-r--r--sys/pci/if_vrreg.h2
-rw-r--r--sys/pci/if_wb.c31
-rw-r--r--sys/pci/if_wbreg.h2
-rw-r--r--sys/pci/if_xl.c93
-rw-r--r--sys/pci/if_xlreg.h2
-rw-r--r--sys/sys/param.h2
288 files changed, 4415 insertions, 3770 deletions
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 1829330..62d42cb 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -231,7 +231,7 @@ ndis_status_func(adapter, status, sbuf, slen)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (ifp->if_flags & IFF_DEBUG)
device_printf (sc->ndis_dev, "status: %x\n", status);
return;
@@ -247,7 +247,7 @@ ndis_statusdone_func(adapter)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (ifp->if_flags & IFF_DEBUG)
device_printf (sc->ndis_dev, "status complete\n");
return;
@@ -291,7 +291,7 @@ ndis_resetdone_func(adapter, status, addressingreset)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (ifp->if_flags & IFF_DEBUG)
device_printf (sc->ndis_dev, "reset done...\n");
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index c1418a4..5dfe8e5 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -1058,7 +1058,7 @@ NdisWriteErrorLogEntry(ndis_handle adapter, ndis_error_code code,
dev = block->nmb_physdeviceobj->do_devext;
drv = block->nmb_deviceobj->do_drvobj;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
error = pe_get_message((vm_offset_t)drv->dro_driverstart,
code, &str, &i, &flags);
@@ -1404,10 +1404,10 @@ NdisReadNetworkAddress(status, addr, addrlen, adapter)
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
- if (bcmp(sc->arpcom.ac_enaddr, empty, ETHER_ADDR_LEN) == 0)
+ if (bcmp(IFP2ENADDR(sc->ifp), empty, ETHER_ADDR_LEN) == 0)
*status = NDIS_STATUS_FAILURE;
else {
- *addr = sc->arpcom.ac_enaddr;
+ *addr = IFP2ENADDR(sc->ifp);
*addrlen = ETHER_ADDR_LEN;
*status = NDIS_STATUS_SUCCESS;
}
diff --git a/sys/contrib/altq/altq/altq_rio.c b/sys/contrib/altq/altq/altq_rio.c
index 6bc4a95..2acf87e 100644
--- a/sys/contrib/altq/altq/altq_rio.c
+++ b/sys/contrib/altq/altq/altq_rio.c
@@ -331,7 +331,7 @@ dscp2index(u_int8_t dscp)
* use m_pkthdr.rcvif to pass this info.
*/
#define RIOM_SET_PRECINDEX(m, idx) \
- do { (m)->m_pkthdr.rcvif = (struct ifnet *)((long)(idx)); } while (0)
+ do { (m)->m_pkthdr.rcvif = (void *)((long)(idx)); } while (0)
#define RIOM_GET_PRECINDEX(m) \
({ long idx; idx = (long)((m)->m_pkthdr.rcvif); \
(m)->m_pkthdr.rcvif = NULL; idx; })
diff --git a/sys/contrib/dev/oltr/if_oltr.c b/sys/contrib/dev/oltr/if_oltr.c
index a65a092..82d76c4 100644
--- a/sys/contrib/dev/oltr/if_oltr.c
+++ b/sys/contrib/dev/oltr/if_oltr.c
@@ -44,6 +44,7 @@
#include <net/if_arp.h>
#include <net/iso88025.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
#ifndef BPF_MTAP
@@ -131,9 +132,15 @@ oltr_attach(device_t dev)
{
struct oltr_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
int rc = 0;
int media = IFM_TOKEN|IFM_TOK_UTP16;
+
+ ifp = sc->ifp = if_alloc(IFT_ISO88025);
+ if (ifp == NULL) {
+ device_printf(dev, "couldn't if_alloc()");
+ return (-1);
+ }
/*
* Allocate interrupt and DMA channel
@@ -164,7 +171,7 @@ oltr_attach(device_t dev)
ifp->if_ioctl = oltr_ioctl;
ifp->if_flags = IFF_BROADCAST | IFF_NEEDSGIANT;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- bcopy(sc->config.macaddress, sc->arpcom.ac_enaddr, sizeof(sc->config.macaddress));
+ bcopy(sc->config.macaddress, IFP2ENADDR(sc->ifp), sizeof(sc->config.macaddress));
/*
* Do ifmedia setup.
@@ -312,7 +319,7 @@ oltr_close(struct oltr_softc *sc)
void
oltr_stop(struct oltr_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
/*printf("oltr%d: oltr_stop\n", sc->unit);*/
@@ -325,7 +332,7 @@ static void
oltr_init(void * xsc)
{
struct oltr_softc *sc = (struct oltr_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ifmedia *ifm = &sc->ifmedia;
int poll = 0, i, rc = 0, s;
int work_size;
@@ -480,7 +487,7 @@ oltr_init(void * xsc)
/*
* Open the adapter
*/
- rc = TRlldOpen(sc->TRlldAdapter, sc->arpcom.ac_enaddr, sc->GroupAddress,
+ rc = TRlldOpen(sc->TRlldAdapter, IFP2ENADDR(sc->ifp), sc->GroupAddress,
sc->FunctionalAddress, 1552, sc->AdapterMode);
switch(rc) {
case TRLLD_OPEN_OK:
@@ -739,7 +746,7 @@ static void
DriverStatus(void *DriverHandle, TRlldStatus_t *Status)
{
struct oltr_softc *sc = (struct oltr_softc *)DriverHandle;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
char *Protocol[] = { /* 0 */ "Unknown",
/* 1 */ "TKP",
@@ -881,7 +888,7 @@ static void
DriverTransmitFrameCompleted(void *DriverHandle, void *FrameHandle, int TransmitStatus)
{
struct oltr_softc *sc = (struct oltr_softc *)DriverHandle;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
TRlldTransmit_t *frame = (TRlldTransmit_t *)FrameHandle;
/*printf("oltr%d: DriverTransmitFrameCompleted\n", sc->unit);*/
@@ -908,7 +915,7 @@ static void
DriverReceiveFrameCompleted(void *DriverHandle, int ByteCount, int FragmentCount, void *FragmentHandle, int ReceiveStatus)
{
struct oltr_softc *sc = (struct oltr_softc *)DriverHandle;
- struct ifnet *ifp = (struct ifnet *)&sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct mbuf *m0, *m1, *m;
int frame_len = ByteCount, i = (int)FragmentHandle, rc, s;
int mbuf_offset, mbuf_size, frag_offset, copy_length;
diff --git a/sys/contrib/dev/oltr/if_oltr_pci.c b/sys/contrib/dev/oltr/if_oltr_pci.c
index 602a3b2..8c7be2e 100644
--- a/sys/contrib/dev/oltr/if_oltr_pci.c
+++ b/sys/contrib/dev/oltr/if_oltr_pci.c
@@ -233,7 +233,7 @@ static int
oltr_pci_detach(device_t dev)
{
struct oltr_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int s, i;
device_printf(dev, "driver unloading\n");
@@ -241,6 +241,7 @@ oltr_pci_detach(device_t dev)
s = splimp();
iso88025_ifdetach(ifp, ISO88025_BPF_SUPPORTED);
+ if_free(ifp);
if (sc->state > OL_CLOSED)
oltr_stop(sc);
diff --git a/sys/contrib/dev/oltr/if_oltrvar.h b/sys/contrib/dev/oltr/if_oltrvar.h
index fd8d3de..7b9994d 100644
--- a/sys/contrib/dev/oltr/if_oltrvar.h
+++ b/sys/contrib/dev/oltr/if_oltrvar.h
@@ -68,7 +68,7 @@ struct oltr_tx_buf {
#define TX_BUFFER_LEN 2048
struct oltr_softc {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct ifmedia ifmedia;
bus_space_handle_t oltr_bhandle;
bus_space_tag_t oltr_btag;
diff --git a/sys/contrib/pf/net/if_pflog.c b/sys/contrib/pf/net/if_pflog.c
index 77b0794..ed5cf13 100644
--- a/sys/contrib/pf/net/if_pflog.c
+++ b/sys/contrib/pf/net/if_pflog.c
@@ -127,7 +127,7 @@ extern int ifqmaxlen;
#ifdef __FreeBSD__
static MALLOC_DEFINE(M_PFLOG, PFLOGNAME, "Packet Filter Logging Interface");
static LIST_HEAD(pflog_list, pflog_softc) pflog_list;
-#define SCP2IFP(sc) (&(sc)->sc_if)
+#define SCP2IFP(sc) ((sc)->sc_ifp)
IFC_SIMPLE_DECLARE(pflog, 1);
static void
@@ -144,6 +144,7 @@ pflog_clone_destroy(struct ifnet *ifp)
bpfdetach(ifp);
if_detach(ifp);
+ if_free(ifp);
LIST_REMOVE(sc, sc_next);
free(sc, M_PFLOG);
}
@@ -155,14 +156,17 @@ pflog_clone_create(struct if_clone *ifc, int unit)
struct ifnet *ifp;
MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO);
+ ifp = sc->sc_ifp = if_alloc(IFT_PFLOG);
+ if (ifp == NULL) {
+ free(sc, M_PFLOG);
+ return (ENOSPC);
+ }
- ifp = SCP2IFP(sc);
if_initname(ifp, ifc->ifc_name, unit);
ifp->if_mtu = PFLOGMTU;
ifp->if_ioctl = pflogioctl;
ifp->if_output = pflogoutput;
ifp->if_start = pflogstart;
- ifp->if_type = IFT_PFLOG;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_hdrlen = PFLOG_HDRLEN;
ifp->if_softc = sc;
diff --git a/sys/contrib/pf/net/if_pflog.h b/sys/contrib/pf/net/if_pflog.h
index 157dd35..68560e4 100644
--- a/sys/contrib/pf/net/if_pflog.h
+++ b/sys/contrib/pf/net/if_pflog.h
@@ -30,9 +30,11 @@
#define _NET_IF_PFLOG_H_
struct pflog_softc {
- struct ifnet sc_if; /* the interface */
#ifdef __FreeBSD__
+ struct ifnet *sc_ifp; /* the interface */
LIST_ENTRY(pflog_softc) sc_next;
+#else
+ struct ifnet sc_if; /* the interface */
#endif
};
diff --git a/sys/contrib/pf/net/if_pfsync.c b/sys/contrib/pf/net/if_pfsync.c
index c40e564..746a6ea 100644
--- a/sys/contrib/pf/net/if_pfsync.c
+++ b/sys/contrib/pf/net/if_pfsync.c
@@ -161,7 +161,7 @@ extern int hz;
#ifdef __FreeBSD__
static MALLOC_DEFINE(M_PFSYNC, PFSYNCNAME, "Packet Filter State Sync. Interface");
static LIST_HEAD(pfsync_list, pfsync_softc) pfsync_list;
-#define SCP2IFP(sc) (&(sc)->sc_if)
+#define SCP2IFP(sc) ((sc)->sc_ifp)
IFC_SIMPLE_DECLARE(pfsync, 1);
static void
@@ -178,6 +178,7 @@ pfsync_clone_destroy(struct ifnet *ifp)
bpfdetach(ifp);
#endif
if_detach(ifp);
+ if_free(ifp);
LIST_REMOVE(sc, sc_next);
free(sc, M_PFSYNC);
}
@@ -190,6 +191,11 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
MALLOC(sc, struct pfsync_softc *, sizeof(*sc), M_PFSYNC,
M_WAITOK|M_ZERO);
+ ifp = sc->sc_ifp = if_alloc(IFT_PFSYNC);
+ if (ifp == NULL) {
+ free(sc, M_PFSYNC);
+ return (ENOSPC);
+ }
pfsync_sync_ok = 1;
sc->sc_mbuf = NULL;
@@ -206,7 +212,6 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
ifp->if_ioctl = pfsyncioctl;
ifp->if_output = pfsyncoutput;
ifp->if_start = pfsyncstart;
- ifp->if_type = IFT_PFSYNC;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_hdrlen = PFSYNC_HDRLEN;
ifp->if_baudrate = IF_Mbps(100);
diff --git a/sys/contrib/pf/net/if_pfsync.h b/sys/contrib/pf/net/if_pfsync.h
index e54696b..4a52195 100644
--- a/sys/contrib/pf/net/if_pfsync.h
+++ b/sys/contrib/pf/net/if_pfsync.h
@@ -147,7 +147,11 @@ union sc_statep {
extern int pfsync_sync_ok;
struct pfsync_softc {
+#ifdef __FreeBSD__
+ struct ifnet *sc_ifp;
+#else
struct ifnet sc_if;
+#endif
struct ifnet *sc_sync_ifp;
struct ip_moptions sc_imo;
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 */
diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c
index cea72ab..6ba3c0c 100644
--- a/sys/i386/isa/if_el.c
+++ b/sys/i386/isa/if_el.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_types.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
@@ -61,7 +62,8 @@ __FBSDID("$FreeBSD$");
/* el_softc: per line info and status */
struct el_softc {
- struct arpcom arpcom; /* Ethernet common */
+ struct ifnet *el_ifp;
+ u_char el_enaddr[6];
bus_space_handle_t el_bhandle;
bus_space_tag_t el_btag;
void *el_intrhand;
@@ -122,7 +124,6 @@ el_probe(device_t dev)
{
struct el_softc *sc;
u_short base; /* Just for convenience */
- u_char station_addr[ETHER_ADDR_LEN];
int i, rid;
/* Grab some info for our structure */
@@ -169,7 +170,7 @@ el_probe(device_t dev)
/* Now read the address */
for(i=0;i<ETHER_ADDR_LEN;i++) {
CSR_WRITE_1(sc,EL_GPBL,i);
- station_addr[i] = CSR_READ_1(sc,EL_EAW);
+ sc->el_enaddr[i] = CSR_READ_1(sc,EL_EAW);
}
/* Now release resources */
@@ -177,19 +178,17 @@ el_probe(device_t dev)
EL_UNLOCK(sc);
mtx_destroy(&sc->el_mtx);
- dprintf(("Address is %6D\n",station_addr, ":"));
+ dprintf(("Address is %6D\n",sc->el_enaddr, ":"));
/* If the vendor code is ok, return a 1. We'll assume that
* whoever configured this system is right about the IRQ.
*/
- if((station_addr[0] != 0x02) || (station_addr[1] != 0x60)
- || (station_addr[2] != 0x8c)) {
+ if((sc->el_enaddr[0] != 0x02) || (sc->el_enaddr[1] != 0x60)
+ || (sc->el_enaddr[2] != 0x8c)) {
dprintf(("Bad vendor code.\n"));
return(ENXIO);
} else {
dprintf(("Vendor code ok.\n"));
- /* Copy the station address into the arpcom structure */
- bcopy(station_addr,sc->arpcom.ac_enaddr,ETHER_ADDR_LEN);
}
device_set_desc(dev, "3Com 3c501 Ethernet");
@@ -214,7 +213,7 @@ el_hardreset(xsc)
* source code for this undocumented goodie...
*/
for(j=0;j<ETHER_ADDR_LEN;j++)
- CSR_WRITE_1(sc,j,sc->arpcom.ac_enaddr[j]);
+ CSR_WRITE_1(sc,j,IFP2ENADDR(sc->el_ifp)[j]);
}
/* Attach the interface to the kernel data structures. By the time
@@ -232,20 +231,26 @@ el_attach(device_t dev)
/* Get things pointing to the right places. */
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->el_ifp = if_alloc(IFT_ETHER);
+
+ if (ifp == NULL)
+ return (ENOSPC);
rid = 0;
sc->el_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, EL_IOSIZ, RF_ACTIVE);
- if (sc->el_res == NULL)
+ if (sc->el_res == NULL) {
+ if_free(ifp);
return(ENXIO);
+ }
rid = 0;
sc->el_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_SHAREABLE | RF_ACTIVE);
if (sc->el_irq == NULL) {
+ if_free(ifp);
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
return(ENXIO);
}
@@ -254,15 +259,12 @@ el_attach(device_t dev)
elintr, sc, &sc->el_intrhand);
if (error) {
+ if_free(ifp);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->el_irq);
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
return(ENXIO);
}
- /* Now reset the board */
- dprintf(("Resetting board...\n"));
- el_hardreset(sc);
-
/* Initialize ifnet structure */
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@@ -276,7 +278,11 @@ el_attach(device_t dev)
/* Now we can attach the interface */
dprintf(("Attaching interface...\n"));
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->el_enaddr);
+
+ /* Now reset the board */
+ dprintf(("Resetting board...\n"));
+ el_hardreset(sc);
dprintf(("el_attach() finished.\n"));
return(0);
@@ -289,11 +295,12 @@ static int el_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->el_ifp;
el_stop(sc);
EL_LOCK(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
bus_teardown_intr(dev, sc->el_irq, sc->el_intrhand);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->el_irq);
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
@@ -346,7 +353,7 @@ el_init(xsc)
struct ifnet *ifp;
/* Set up pointers */
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->el_ifp;
/* If address not known, do nothing. */
if(TAILQ_EMPTY(&ifp->if_addrhead)) /* XXX unlikely */
@@ -406,20 +413,20 @@ el_start(struct ifnet *ifp)
EL_LOCK(sc);
/* Don't do anything if output is active */
- if(sc->arpcom.ac_if.if_flags & IFF_OACTIVE)
+ if(sc->el_ifp->if_flags & IFF_OACTIVE)
return;
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
+ sc->el_ifp->if_flags |= IFF_OACTIVE;
/* The main loop. They warned me against endless loops, but
* would I listen? NOOO....
*/
while(1) {
/* Dequeue the next datagram */
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd,m0);
+ IF_DEQUEUE(&sc->el_ifp->if_snd,m0);
/* If there's nothing to send, return. */
if(m0 == NULL) {
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
+ sc->el_ifp->if_flags &= ~IFF_OACTIVE;
EL_UNLOCK(sc);
return;
}
@@ -441,7 +448,7 @@ el_start(struct ifnet *ifp)
len = max(len,ETHER_MIN_LEN);
/* Give the packet to the bpf, if any */
- BPF_TAP(&sc->arpcom.ac_if, sc->el_pktbuf, len);
+ BPF_TAP(sc->el_ifp, sc->el_pktbuf, len);
/* Transfer datagram to board */
dprintf(("el: xfr pkt length=%d...\n",len));
@@ -464,7 +471,7 @@ el_start(struct ifnet *ifp)
dprintf(("tx status=0x%x\n",i));
if(!(i & EL_TXS_READY)) {
dprintf(("el: err txs=%x\n",i));
- sc->arpcom.ac_if.if_oerrors++;
+ sc->el_ifp->if_oerrors++;
if(i & (EL_TXS_COLL|EL_TXS_COLL16)) {
if((!(i & EL_TXC_DCOLL16)) && retries < 15) {
retries++;
@@ -475,7 +482,7 @@ el_start(struct ifnet *ifp)
done = 1;
}
else {
- sc->arpcom.ac_if.if_opackets++;
+ sc->el_ifp->if_opackets++;
done = 1;
}
}
@@ -513,7 +520,7 @@ el_xmit(struct el_softc *sc,int len)
i--;
if(i == 0) {
dprintf(("tx not ready\n"));
- sc->arpcom.ac_if.if_oerrors++;
+ sc->el_ifp->if_oerrors++;
return(-1);
}
dprintf(("%d cycles.\n",(20000-i)));
@@ -524,7 +531,7 @@ el_xmit(struct el_softc *sc,int len)
static __inline void
elread(struct el_softc *sc,caddr_t buf,int len)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->el_ifp;
struct mbuf *m;
/*
@@ -574,7 +581,7 @@ elintr(void *xsc)
dprintf(("overflow.\n"));
el_hardreset(sc);
/* Put board back into receive mode */
- if(sc->arpcom.ac_if.if_flags & IFF_PROMISC)
+ if(sc->el_ifp->if_flags & IFF_PROMISC)
CSR_WRITE_1(sc,EL_RXC,
(EL_RXC_PROMISC|EL_RXC_ABROAD|
EL_RXC_AMULTI|EL_RXC_AGF|EL_RXC_DSHORT|
@@ -601,7 +608,7 @@ elintr(void *xsc)
/* If packet too short or too long, restore rx mode and return
*/
if((len <= sizeof(struct ether_header)) || (len > ETHER_MAX_LEN)) {
- if(sc->arpcom.ac_if.if_flags & IFF_PROMISC)
+ if(sc->el_ifp->if_flags & IFF_PROMISC)
CSR_WRITE_1(sc,EL_RXC,
(EL_RXC_PROMISC|EL_RXC_ABROAD|
EL_RXC_AMULTI|EL_RXC_AGF|EL_RXC_DSHORT|
@@ -619,7 +626,7 @@ elintr(void *xsc)
return;
}
- sc->arpcom.ac_if.if_ipackets++;
+ sc->el_ifp->if_ipackets++;
/* Copy the data into our buffer */
CSR_WRITE_1(sc,EL_GPBL,0);
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index 7f8adbd..bf8ee2c 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -33,17 +33,17 @@
*
* statistics counter usage (interface lifetime):
* ----------------------------------------------
- * sc->sc_if.if_ipackets # of received packets
- * sc->sc_if.if_ierrors # of error packets not going to upper layers
- * sc->sc_if.if_opackets # of transmitted packets
- * sc->sc_if.if_oerrors # of error packets not being transmitted
- * sc->sc_if.if_collisions # of invalid ip packets after VJ decompression
- * sc->sc_if.if_ibytes # of bytes coming in from the line (before VJ)
- * sc->sc_if.if_obytes # of bytes going out to the line (after VJ)
- * sc->sc_if.if_imcasts (currently unused)
- * sc->sc_if.if_omcasts # of frames sent out of the fastqueue
- * sc->sc_if.if_iqdrops # of frames dropped on input because queue full
- * sc->sc_if.if_noproto # of frames dropped on output because !AF_INET
+ * sc->sc_ifp->if_ipackets # of received packets
+ * sc->sc_ifp->if_ierrors # of error packets not going to upper layers
+ * sc->sc_ifp->if_opackets # of transmitted packets
+ * sc->sc_ifp->if_oerrors # of error packets not being transmitted
+ * sc->sc_ifp->if_collisions # of invalid ip packets after VJ decompression
+ * sc->sc_ifp->if_ibytes # of bytes coming in from the line (before VJ)
+ * sc->sc_ifp->if_obytes # of bytes going out to the line (after VJ)
+ * sc->sc_ifp->if_imcasts (currently unused)
+ * sc->sc_ifp->if_omcasts # of frames sent out of the fastqueue
+ * sc->sc_ifp->if_iqdrops # of frames dropped on input because queue full
+ * sc->sc_ifp->if_noproto # of frames dropped on output because !AF_INET
*
* statistics counter usage (connection lifetime):
* -----------------------------------------------
@@ -124,7 +124,7 @@ static drvr_link_t ipr_drvr_linktab[NI4BIPR];
static isdn_link_t *isdn_linktab[NI4BIPR];
struct ipr_softc {
- struct ifnet sc_if; /* network-visible interface */
+ struct ifnet *sc_ifp; /* network-visible interface */
int sc_state; /* state of the interface */
call_desc_t *sc_cdp; /* ptr to call descriptor */
int sc_updown; /* soft state of interface */
@@ -202,43 +202,46 @@ i4biprattach(void *dummy)
NDBGL4(L4_DIALST, "setting dial state to ST_IDLE");
- sc->sc_if.if_softc = sc;
+ sc->sc_ifp = if_alloc(IFT_ISDNBASIC);
+ if (sc->sc_ifp == NULL)
+ panic("if_ipr.c, ipr_attach: cannot if_alloc()");
+
+ sc->sc_ifp->if_softc = sc;
sc->sc_state = ST_IDLE;
- if_initname(&sc->sc_if, "ipr", i);
+ if_initname(sc->sc_ifp, "ipr", i);
#ifdef IPR_VJ
- sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_SIMPLEX | IPR_AUTOCOMP;
+ sc->sc_ifp->if_flags = IFF_POINTOPOINT | IFF_SIMPLEX | IPR_AUTOCOMP;
#else
- sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_SIMPLEX;
+ sc->sc_ifp->if_flags = IFF_POINTOPOINT | IFF_SIMPLEX;
#endif
- sc->sc_if.if_mtu = I4BIPRMTU;
- sc->sc_if.if_type = IFT_ISDNBASIC;
- sc->sc_if.if_ioctl = i4biprioctl;
- sc->sc_if.if_output = i4biproutput;
+ sc->sc_ifp->if_mtu = I4BIPRMTU;
+ sc->sc_ifp->if_ioctl = i4biprioctl;
+ sc->sc_ifp->if_output = i4biproutput;
- sc->sc_if.if_snd.ifq_maxlen = I4BIPRMAXQLEN;
+ sc->sc_ifp->if_snd.ifq_maxlen = I4BIPRMAXQLEN;
sc->sc_fastq.ifq_maxlen = I4BIPRMAXQLEN;
if(!mtx_initialized(&sc->sc_fastq.ifq_mtx))
mtx_init(&sc->sc_fastq.ifq_mtx, "i4b_ipr_fastq", NULL, MTX_DEF);
- sc->sc_if.if_ipackets = 0;
- sc->sc_if.if_ierrors = 0;
- sc->sc_if.if_opackets = 0;
- sc->sc_if.if_oerrors = 0;
- sc->sc_if.if_collisions = 0;
- sc->sc_if.if_ibytes = 0;
- sc->sc_if.if_obytes = 0;
- sc->sc_if.if_imcasts = 0;
- sc->sc_if.if_omcasts = 0;
- sc->sc_if.if_iqdrops = 0;
- sc->sc_if.if_noproto = 0;
+ sc->sc_ifp->if_ipackets = 0;
+ sc->sc_ifp->if_ierrors = 0;
+ sc->sc_ifp->if_opackets = 0;
+ sc->sc_ifp->if_oerrors = 0;
+ sc->sc_ifp->if_collisions = 0;
+ sc->sc_ifp->if_ibytes = 0;
+ sc->sc_ifp->if_obytes = 0;
+ sc->sc_ifp->if_imcasts = 0;
+ sc->sc_ifp->if_omcasts = 0;
+ sc->sc_ifp->if_iqdrops = 0;
+ sc->sc_ifp->if_noproto = 0;
#if I4BIPRACCT
- sc->sc_if.if_timer = 0;
- sc->sc_if.if_watchdog = iprwatchdog;
+ sc->sc_ifp->if_timer = 0;
+ sc->sc_ifp->if_watchdog = iprwatchdog;
sc->sc_iinb = 0;
sc->sc_ioutb = 0;
sc->sc_inb = 0;
@@ -267,9 +270,9 @@ i4biprattach(void *dummy)
sc->sc_dialresp = DSTAT_NONE; /* no response */
sc->sc_lastdialresp = DSTAT_NONE;
- if_attach(&sc->sc_if);
+ if_attach(sc->sc_ifp);
- bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
+ bpfattach(sc->sc_ifp, DLT_NULL, sizeof(u_int));
}
}
@@ -298,8 +301,8 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
if_printf(ifp, "af%d not supported\n", dst->sa_family);
m_freem(m);
splx(s);
- sc->sc_if.if_noproto++;
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_noproto++;
+ sc->sc_ifp->if_oerrors++;
return(EAFNOSUPPORT);
}
@@ -310,7 +313,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
NDBGL4(L4_IPRDBG, "ipr%d: interface is DOWN!", unit);
m_freem(m);
splx(s);
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
return(ENETDOWN);
}
@@ -328,7 +331,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
iprclearqueues(sc);
sc->sc_dialresp = DSTAT_NONE;
splx(s);
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
return(ENETUNREACH);
break;
@@ -338,7 +341,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
iprclearqueues(sc);
sc->sc_dialresp = DSTAT_NONE;
splx(s);
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
return(EHOSTUNREACH);
break;
@@ -348,7 +351,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
iprclearqueues(sc);
sc->sc_dialresp = DSTAT_NONE;
splx(s);
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
return(EHOSTUNREACH);
break;
}
@@ -370,7 +373,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
/* update access time */
- microtime(&sc->sc_if.if_lastchange);
+ microtime(&sc->sc_ifp->if_lastchange);
/*
* check, if type of service indicates interactive, i.e. telnet,
@@ -383,7 +386,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
if(ip->ip_tos & IPTOS_LOWDELAY)
ifq = &sc->sc_fastq;
else
- ifq = (struct ifqueue *)&sc->sc_if.if_snd;
+ ifq = (struct ifqueue *)&sc->sc_ifp->if_snd;
/* check for space in choosen send queue */
@@ -391,7 +394,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
{
NDBGL4(L4_IPRDBG, "ipr%d: send queue full!", unit);
splx(s);
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
return(ENOBUFS);
}
@@ -426,19 +429,19 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if(ifa->ifa_addr->sa_family != AF_INET)
error = EAFNOSUPPORT;
else
- sc->sc_if.if_flags |= IFF_UP;
- microtime(&sc->sc_if.if_lastchange);
+ sc->sc_ifp->if_flags |= IFF_UP;
+ microtime(&sc->sc_ifp->if_lastchange);
break;
case SIOCSIFFLAGS: /* set interface flags */
if(!(ifr->ifr_flags & IFF_UP))
{
- if(sc->sc_if.if_flags & IFF_RUNNING)
+ if(sc->sc_ifp->if_flags & IFF_RUNNING)
{
/* disconnect ISDN line */
i4b_l4_drvrdisc(BDRV_IPR,
ifp->if_dunit);
- sc->sc_if.if_flags &= ~IFF_RUNNING;
+ sc->sc_ifp->if_flags &= ~IFF_RUNNING;
}
sc->sc_state = ST_IDLE;
@@ -453,7 +456,7 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
/* enable debug messages */
}
- microtime(&sc->sc_if.if_lastchange);
+ microtime(&sc->sc_ifp->if_lastchange);
break;
case SIOCSIFMTU: /* set interface MTU */
@@ -464,7 +467,7 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
else
{
ifp->if_mtu = ifr->ifr_mtu;
- microtime(&sc->sc_if.if_lastchange);
+ microtime(&sc->sc_ifp->if_lastchange);
}
break;
#if 0
@@ -504,7 +507,7 @@ iprclearqueues(struct ipr_softc *sc)
x = splimp();
IF_DRAIN(&sc->sc_fastq);
- IF_DRAIN(&sc->sc_if.if_snd);
+ IF_DRAIN(&sc->sc_ifp->if_snd);
splx(x);
}
@@ -543,7 +546,7 @@ iprwatchdog(struct ifnet *ifp)
i4b_l4_accounting(BDRV_IPR, unit, ACCT_DURING,
sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
}
- sc->sc_if.if_timer = I4BIPRACCTINTVL;
+ sc->sc_ifp->if_timer = I4BIPRACCTINTVL;
}
#endif /* I4BIPRACCT */
@@ -562,7 +565,7 @@ i4bipr_connect_startio(struct ipr_softc *sc)
if(sc->sc_state == ST_CONNECTED_W)
{
sc->sc_state = ST_CONNECTED_A;
- ipr_tx_queue_empty(sc->sc_if.if_dunit);
+ ipr_tx_queue_empty(sc->sc_ifp->if_dunit);
}
splx(s);
@@ -583,7 +586,7 @@ ipr_connect(int unit, void *cdp)
NDBGL4(L4_DIALST, "ipr%d: setting dial state to ST_CONNECTED", unit);
- sc->sc_if.if_flags |= IFF_RUNNING;
+ sc->sc_ifp->if_flags |= IFF_RUNNING;
sc->sc_state = ST_CONNECTED_W;
sc->sc_dialresp = DSTAT_NONE;
@@ -596,7 +599,7 @@ ipr_connect(int unit, void *cdp)
sc->sc_outb = 0;
sc->sc_linb = 0;
sc->sc_loutb = 0;
- sc->sc_if.if_timer = I4BIPRACCTINTVL;
+ sc->sc_ifp->if_timer = I4BIPRACCTINTVL;
#endif
#ifdef I4BIPRADJFRXP
@@ -658,7 +661,7 @@ ipr_disconnect(int unit, void *cdp)
}
#if I4BIPRACCT
- sc->sc_if.if_timer = 0;
+ sc->sc_ifp->if_timer = 0;
#endif
#if IPR_LOG
@@ -676,7 +679,7 @@ ipr_disconnect(int unit, void *cdp)
sc->sc_dialresp = DSTAT_NONE;
sc->sc_lastdialresp = DSTAT_NONE;
- sc->sc_if.if_flags &= ~IFF_RUNNING;
+ sc->sc_ifp->if_flags &= ~IFF_RUNNING;
sc->sc_state = ST_IDLE;
}
@@ -732,11 +735,11 @@ ipr_rx_data_rdy(int unit)
if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
return;
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = sc->sc_ifp;
m->m_pkthdr.len = m->m_len;
- microtime(&sc->sc_if.if_lastchange);
+ microtime(&sc->sc_ifp->if_lastchange);
#ifdef I4BIPRADJFRXP
@@ -767,8 +770,8 @@ ipr_rx_data_rdy(int unit)
}
#endif
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ sc->sc_ifp->if_ipackets++;
+ sc->sc_ifp->if_ibytes += m->m_pkthdr.len;
#ifdef IPR_VJ
if((c = (*(mtod(m, u_char *)) & 0xf0)) != (IPVERSION << 4))
@@ -801,7 +804,7 @@ ipr_rx_data_rdy(int unit)
* it's a reasonable packet, decompress it and then
* enable compression. Otherwise, drop it.
*/
- if(sc->sc_if.if_flags & IPR_COMPRESS)
+ if(sc->sc_ifp->if_flags & IPR_COMPRESS)
{
#ifdef IPR_VJ_USEBUFFER
len = sl_uncompress_tcp(&cp,len,(u_int)c,&sc->sc_compr);
@@ -818,7 +821,7 @@ ipr_rx_data_rdy(int unit)
goto error;
}
}
- else if((sc->sc_if.if_flags & IPR_AUTOCOMP) &&
+ else if((sc->sc_ifp->if_flags & IPR_AUTOCOMP) &&
(c == TYPE_UNCOMPRESSED_TCP) && (len >= 40))
{
#ifdef IPR_VJ_USEBUFFER
@@ -836,7 +839,7 @@ ipr_rx_data_rdy(int unit)
goto error;
}
- sc->sc_if.if_flags |= IPR_COMPRESS;
+ sc->sc_ifp->if_flags |= IPR_COMPRESS;
}
else
{
@@ -845,8 +848,8 @@ ipr_rx_data_rdy(int unit)
#endif
error:
- sc->sc_if.if_ierrors++;
- sc->sc_if.if_collisions++;
+ sc->sc_ifp->if_ierrors++;
+ sc->sc_ifp->if_collisions++;
m_freem(m);
return;
}
@@ -871,7 +874,7 @@ error:
}
#endif
- if(sc->sc_if.if_bpf)
+ if(sc->sc_ifp->if_bpf)
{
/* prepend the address family as a four byte field */
struct mbuf mm;
@@ -879,14 +882,14 @@ error:
mm.m_next = m;
mm.m_len = 4;
mm.m_data = (char *)&af;
- BPF_MTAP(&sc->sc_if, &mm);
+ BPF_MTAP(sc->sc_ifp, &mm);
}
if(netisr_queue(NETISR_IP, m)) /* (0) on success. */
{
NDBGL4(L4_IPRDBG, "ipr%d: ipintrq full!", unit);
- sc->sc_if.if_ierrors++;
- sc->sc_if.if_iqdrops++;
+ sc->sc_ifp->if_ierrors++;
+ sc->sc_ifp->if_iqdrops++;
}
}
@@ -913,18 +916,18 @@ ipr_tx_queue_empty(int unit)
IF_DEQUEUE(&sc->sc_fastq, m);
if(m)
{
- sc->sc_if.if_omcasts++;
+ sc->sc_ifp->if_omcasts++;
}
else
{
- IF_DEQUEUE(&sc->sc_if.if_snd, m);
+ IF_DEQUEUE(&sc->sc_ifp->if_snd, m);
if(m == NULL)
break;
}
- microtime(&sc->sc_if.if_lastchange);
+ microtime(&sc->sc_ifp->if_lastchange);
- if(sc->sc_if.if_bpf)
+ if(sc->sc_ifp->if_bpf)
{
/* prepend the address family as a four byte field */
@@ -933,7 +936,7 @@ ipr_tx_queue_empty(int unit)
mm.m_next = m;
mm.m_len = 4;
mm.m_data = (char *)&af;
- BPF_MTAP(&sc->sc_if, &mm);
+ BPF_MTAP(sc->sc_ifp, &mm);
}
#if I4BIPRACCT
@@ -943,7 +946,7 @@ ipr_tx_queue_empty(int unit)
#ifdef IPR_VJ
if((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP)
{
- if(sc->sc_if.if_flags & IPR_COMPRESS)
+ if(sc->sc_ifp->if_flags & IPR_COMPRESS)
{
*mtod(m, u_char *) |= sl_compress_tcp(m, ip,
&sc->sc_compr, 1);
@@ -960,9 +963,9 @@ ipr_tx_queue_empty(int unit)
}
else
{
- sc->sc_if.if_obytes += m->m_pkthdr.len;
+ sc->sc_ifp->if_obytes += m->m_pkthdr.len;
- sc->sc_if.if_opackets++;
+ sc->sc_ifp->if_opackets++;
_IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
diff --git a/sys/i4b/driver/i4b_isppp.c b/sys/i4b/driver/i4b_isppp.c
index f8d6fce..a7e2f0e 100644
--- a/sys/i4b/driver/i4b_isppp.c
+++ b/sys/i4b/driver/i4b_isppp.c
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
NET_NEEDS_GIANT("i4b_isppp");
#define ISPPP_FMT "isp%d: "
-#define ISPPP_ARG(sc) ((sc)->sc_if.if_dunit)
+#define ISPPP_ARG(sc) (sc->sc_ifp->if_dunit)
#define PDEVSTATIC static
#define IFP2UNIT(ifp) (ifp)->if_dunit
@@ -90,18 +90,7 @@ PSEUDO_SET(i4bispppattach, i4b_isppp);
#define PPP_HDRLEN 4 /* 4 octetts PPP header length */
struct i4bisppp_softc {
- /*
- * struct sppp starts with a struct ifnet, but we gotta allocate
- * more space for it. NB: do not relocate this union, it must
- * be first in isppp_softc. The tls and tlf hooks below want to
- * convert a ``struct sppp *'' into a ``struct isppp_softc *''.
- */
- union {
- struct ifnet scu_if;
- struct sppp scu_sp;
- } sc_if_un;
-
-#define sc_if sc_if_un.scu_if
+ struct ifnet *sc_ifp;
int sc_state; /* state of the interface */
call_desc_t *sc_cdp; /* ptr to call descriptor */
@@ -161,6 +150,7 @@ PDEVSTATIC void
i4bispppattach(void *dummy)
{
struct i4bisppp_softc *sc = i4bisppp_softc;
+ struct ifnet *ifp;
int i;
#ifdef SPPP_VJ
@@ -171,40 +161,49 @@ i4bispppattach(void *dummy)
for(i = 0; i < NI4BISPPP; sc++, i++) {
i4bisppp_init_linktab(i);
+ ifp = sc->sc_ifp = if_alloc(IFT_PPP);
+ if (ifp == NULL) {
+ panic("isp%d: cannot if_alloc()", i);
+ }
- sc->sc_if.if_softc = sc;
- if_initname(&sc->sc_if, "isp", i);
- sc->sc_if.if_mtu = PP_MTU;
- sc->sc_if.if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
- sc->sc_if.if_type = IFT_ISDNBASIC;
+ ifp->if_softc = sc;
+ if_initname(sc->sc_ifp, "isp", i);
+ ifp->if_mtu = PP_MTU;
+ ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
+ /*
+ * XXX: If there were a detach function this would
+ * require that it use if_free_type(). Not sure if this
+ * type makes sense.
+ */
+ ifp->if_type = IFT_ISDNBASIC;
sc->sc_state = ST_IDLE;
- sc->sc_if.if_ioctl = i4bisppp_ioctl;
+ ifp->if_ioctl = i4bisppp_ioctl;
/* actually initialized by sppp_attach() */
- /* sc->sc_if.if_output = sppp_output; */
-
- sc->sc_if.if_start = i4bisppp_start;
-
- sc->sc_if.if_hdrlen = 0;
- sc->sc_if.if_addrlen = 0;
- sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
-
- sc->sc_if.if_ipackets = 0;
- sc->sc_if.if_ierrors = 0;
- sc->sc_if.if_opackets = 0;
- sc->sc_if.if_oerrors = 0;
- sc->sc_if.if_collisions = 0;
- sc->sc_if.if_ibytes = 0;
- sc->sc_if.if_obytes = 0;
- sc->sc_if.if_imcasts = 0;
- sc->sc_if.if_omcasts = 0;
- sc->sc_if.if_iqdrops = 0;
- sc->sc_if.if_noproto = 0;
+ /* ifp->if_output = sppp_output; */
+
+ ifp->if_start = i4bisppp_start;
+
+ ifp->if_hdrlen = 0;
+ ifp->if_addrlen = 0;
+ ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
+
+ ifp->if_ipackets = 0;
+ ifp->if_ierrors = 0;
+ ifp->if_opackets = 0;
+ ifp->if_oerrors = 0;
+ ifp->if_collisions = 0;
+ ifp->if_ibytes = 0;
+ ifp->if_obytes = 0;
+ ifp->if_imcasts = 0;
+ ifp->if_omcasts = 0;
+ ifp->if_iqdrops = 0;
+ ifp->if_noproto = 0;
#if I4BISPPPACCT
- sc->sc_if.if_timer = 0;
- sc->sc_if.if_watchdog = i4bisppp_watchdog;
+ ifp->if_timer = 0;
+ ifp->if_watchdog = i4bisppp_watchdog;
sc->sc_iinb = 0;
sc->sc_ioutb = 0;
sc->sc_inb = 0;
@@ -214,22 +213,18 @@ i4bispppattach(void *dummy)
sc->sc_fn = 1;
#endif
- sc->sc_if_un.scu_sp.pp_tls = i4bisppp_tls;
- sc->sc_if_un.scu_sp.pp_tlf = i4bisppp_tlf;
- sc->sc_if_un.scu_sp.pp_con = i4bisppp_negotiation_complete;
- sc->sc_if_un.scu_sp.pp_chg = i4bisppp_state_changed;
+ IFP2SP(sc->sc_ifp)->pp_tls = i4bisppp_tls;
+ IFP2SP(sc->sc_ifp)->pp_tlf = i4bisppp_tlf;
+ IFP2SP(sc->sc_ifp)->pp_con = i4bisppp_negotiation_complete;
+ IFP2SP(sc->sc_ifp)->pp_chg = i4bisppp_state_changed;
- sppp_attach(&sc->sc_if);
+ sppp_attach(sc->sc_ifp);
-#if 0 /* ??? -hm */
- ether_ifattach(&sc->sc_if, 0);
-#else
- if_attach(&sc->sc_if);
-#endif
+ if_attach(sc->sc_ifp);
CALLOUT_INIT(&sc->sc_ch);
- bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN);
+ bpfattach(sc->sc_ifp, DLT_PPP, PPP_HDRLEN);
}
}
@@ -248,7 +243,7 @@ i4bisppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data)
int error;
- error = sppp_ioctl(&sc->sc_if, cmd, data);
+ error = sppp_ioctl(sc->sc_ifp, cmd, data);
if (error)
return error;
@@ -289,7 +284,7 @@ i4bisppp_start(struct ifnet *ifp)
* splx(s);
*/
- while ((m = sppp_dequeue(&sc->sc_if)) != NULL)
+ while ((m = sppp_dequeue(sc->sc_ifp)) != NULL)
{
BPF_MTAP(ifp, m);
@@ -305,10 +300,10 @@ i4bisppp_start(struct ifnet *ifp)
else
{
#if 0
- sc->sc_if.if_obytes += m->m_pkthdr.len;
+ sc->sc_ifp->if_obytes += m->m_pkthdr.len;
#endif
sc->sc_outb += m->m_pkthdr.len;
- sc->sc_if.if_opackets++;
+ sc->sc_ifp->if_opackets++;
_IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
}
@@ -351,7 +346,7 @@ i4bisppp_watchdog(struct ifnet *ifp)
i4b_l4_accounting(BDRV_ISPPP, unit, ACCT_DURING,
sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
}
- sc->sc_if.if_timer = I4BISPPPACCTINTVL;
+ sc->sc_ifp->if_timer = I4BISPPPACCTINTVL;
#if 0 /* old stuff, keep it around */
printf(ISPPP_FMT "transmit timeout\n", ISPPP_ARG(sc));
@@ -385,7 +380,7 @@ static void
i4bisppp_tls(struct sppp *sp)
{
struct i4bisppp_softc *sc = (struct i4bisppp_softc *)sp;
- struct ifnet *ifp = (struct ifnet *)sp;
+ struct ifnet *ifp = SP2IFP(sp);
if(sc->sc_state == ST_CONNECTED)
return;
@@ -402,7 +397,7 @@ i4bisppp_tlf(struct sppp *sp)
{
struct i4bisppp_softc *sc = (struct i4bisppp_softc *)sp;
/* call_desc_t *cd = sc->sc_cdp; */
- struct ifnet *ifp = (struct ifnet *)sp;
+ struct ifnet *ifp = SP2IFP(sp);
if(sc->sc_state != ST_CONNECTED)
return;
@@ -448,7 +443,7 @@ static void
i4bisppp_connect(int unit, void *cdp)
{
struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
- struct sppp *sp = &sc->sc_if_un.scu_sp;
+ struct sppp *sp = IFP2SP(sc->sc_ifp);
int s = splimp();
sc->sc_cdp = (call_desc_t *)cdp;
@@ -461,7 +456,7 @@ i4bisppp_connect(int unit, void *cdp)
sc->sc_outb = 0;
sc->sc_linb = 0;
sc->sc_loutb = 0;
- sc->sc_if.if_timer = I4BISPPPACCTINTVL;
+ sc->sc_ifp->if_timer = I4BISPPPACCTINTVL;
#endif
#if 0 /* never used ??? */
@@ -483,7 +478,7 @@ i4bisppp_disconnect(int unit, void *cdp)
{
call_desc_t *cd = (call_desc_t *)cdp;
struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
- struct sppp *sp = &sc->sc_if_un.scu_sp;
+ struct sppp *sp = IFP2SP(sc->sc_ifp);
int s = splimp();
@@ -496,7 +491,7 @@ i4bisppp_disconnect(int unit, void *cdp)
}
#if I4BISPPPACCT
- sc->sc_if.if_timer = 0;
+ sc->sc_ifp->if_timer = 0;
#endif
i4b_l4_accounting(BDRV_ISPPP, unit, ACCT_FINAL,
@@ -524,7 +519,7 @@ static void
i4bisppp_dialresponse(int unit, int status, cause_t cause)
{
struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
- struct sppp *sp = &sc->sc_if_un.scu_sp;
+ struct sppp *sp = IFP2SP(sc->sc_ifp);
NDBGL4(L4_ISPDBG, "isp%d: status=%d, cause=%d", unit, status, cause);
@@ -534,9 +529,9 @@ i4bisppp_dialresponse(int unit, int status, cause_t cause)
NDBGL4(L4_ISPDBG, "isp%d: clearing queues", unit);
- if(!(sppp_isempty(&sc->sc_if)))
+ if(!(sppp_isempty(sc->sc_ifp)))
{
- while((m = sppp_dequeue(&sc->sc_if)) != NULL)
+ while((m = sppp_dequeue(sc->sc_ifp)) != NULL)
m_freem(m);
}
@@ -579,14 +574,14 @@ i4bisppp_rx_data_rdy(int unit)
if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
return;
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = sc->sc_ifp;
m->m_pkthdr.len = m->m_len;
- microtime(&sc->sc_if.if_lastchange);
+ microtime(&sc->sc_ifp->if_lastchange);
- sc->sc_if.if_ipackets++;
+ sc->sc_ifp->if_ipackets++;
#if 0
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ sc->sc_ifp->if_ibytes += m->m_pkthdr.len;
#endif
#if I4BISPPPACCT
@@ -597,11 +592,11 @@ i4bisppp_rx_data_rdy(int unit)
printf("i4bisppp_rx_data_ready: received packet!\n");
#endif
- BPF_MTAP(&sc->sc_if, m);
+ BPF_MTAP(sc->sc_ifp, m);
s = splimp();
- sppp_input(&sc->sc_if, m);
+ sppp_input(sc->sc_ifp, m);
splx(s);
}
@@ -614,7 +609,7 @@ i4bisppp_rx_data_rdy(int unit)
static void
i4bisppp_tx_queue_empty(int unit)
{
- i4bisppp_start(&i4bisppp_softc[unit].sc_if);
+ i4bisppp_start((&i4bisppp_softc[unit])->sc_ifp);
}
/*---------------------------------------------------------------------------*
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 4c6f8bf..7ffc1c4 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -728,7 +728,7 @@ restart:
goto release;
}
m->m_pkthdr.len = 0;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
+ m->m_pkthdr.rcvif = NULL;
} else {
MGET(m, M_TRYWAIT, MT_DATA);
if (m == NULL) {
@@ -759,7 +759,7 @@ restart:
if (top == NULL) {
m = m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);
m->m_pkthdr.len = 0;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
+ m->m_pkthdr.rcvif = NULL;
} else
m = m_getcl(M_TRYWAIT, MT_DATA, 0);
len = min(min(MCLBYTES, resid), space);
@@ -768,7 +768,7 @@ restart:
if (top == NULL) {
m = m_gethdr(M_TRYWAIT, MT_DATA);
m->m_pkthdr.len = 0;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
+ m->m_pkthdr.rcvif = NULL;
len = min(min(MHLEN, resid), space);
/*
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 9c9ca7e..ac81ff1 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1018,7 +1018,7 @@ bpf_setif(d, ifr)
if (ifp == NULL || ifp != theywant)
continue;
/* skip additional entry */
- if (bp->bif_driverp != (struct bpf_if **)&ifp->if_bpf)
+ if (bp->bif_driverp != &ifp->if_bpf)
continue;
mtx_unlock(&bpf_mtx);
diff --git a/sys/net/bridge.c b/sys/net/bridge.c
index 1011f10..82a24fa 100644
--- a/sys/net/bridge.c
+++ b/sys/net/bridge.c
@@ -352,7 +352,7 @@ add_cluster(u_int16_t cluster_id, struct ifnet *ifp)
n_clusters++;
found:
c = clusters + i; /* the right cluster ... */
- ETHER_ADDR_COPY(c->my_macs[c->ports].etheraddr, IFP2AC(ifp)->ac_enaddr);
+ ETHER_ADDR_COPY(c->my_macs[c->ports].etheraddr, IFP2ENADDR(ifp));
c->ports++;
return c;
bad:
diff --git a/sys/net/bridge.h b/sys/net/bridge.h
index 7eb3b2d..76594f5 100644
--- a/sys/net/bridge.h
+++ b/sys/net/bridge.h
@@ -42,7 +42,6 @@ struct cluster_softc; /* opaque here, defined in bridge.c */
struct bdg_softc {
struct ifnet *ifp ;
- /* also ((struct arpcom *)ifp)->ac_enaddr is the eth. addr */
int flags ;
#define IFF_BDG_PROMISC 0x0001 /* set promisc mode on this if. */
#define IFF_MUTE 0x0002 /* mute this if for bridging. */
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index a1a487b..476e026 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -66,8 +66,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/if_ether.h>
#include <net/if_bridgevar.h>
-#define sc_if ifb_ac.ac_if
-
/* BPDU message types */
#define BSTP_MSGTYPE_CFG 0x00 /* Configuration */
#define BSTP_MSGTYPE_TCN 0x80 /* Topology chg notification */
@@ -1139,7 +1137,7 @@ bstp_tick(void *arg)
bstp_hold_timer_expiry(sc, bif);
}
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
callout_reset(&sc->sc_bstpcallout, hz, bstp_tick, sc);
BRIDGE_UNLOCK(sc);
diff --git a/sys/net/firewire.h b/sys/net/firewire.h
index 5c63a05..d47b822 100644
--- a/sys/net/firewire.h
+++ b/sys/net/firewire.h
@@ -121,7 +121,7 @@ struct fw_reass {
STAILQ_HEAD(fw_reass_list, fw_reass);
struct fw_com {
- struct ifnet fc_if;
+ struct ifnet *fc_ifp;
struct fw_hwaddr fc_hwaddr;
struct firewire_comm *fc_fc;
uint8_t fc_broadcast_channel;
@@ -129,6 +129,7 @@ struct fw_com {
uint16_t fc_node; /* our nodeid */
struct fw_reass_list fc_frags; /* partial datagrams */
};
+#define IFP2FWC(ifp) ((struct fw_com *)(ifp)->if_l2com)
extern void firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src);
extern void firewire_ifattach(struct ifnet *, struct fw_hwaddr *);
diff --git a/sys/net/if.c b/sys/net/if.c
index d2d179f..4f3082a 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -127,6 +127,8 @@ struct ifindex_entry *ifindex_table = NULL;
int ifqmaxlen = IFQ_MAXLEN;
struct ifnethead ifnet; /* depend on static init XXX */
struct mtx ifnet_lock;
+static if_com_alloc_t *if_com_alloc[256];
+static if_com_free_t *if_com_free[256];
static int if_indexlim = 8;
static struct knlist ifklist;
@@ -143,6 +145,7 @@ static struct filterops netdev_filtops =
SYSINIT(interfaces, SI_SUB_INIT_IF, SI_ORDER_FIRST, if_init, NULL)
SYSINIT(interface_check, SI_SUB_PROTO_IF, SI_ORDER_FIRST, if_check, NULL)
+MALLOC_DEFINE(M_IFNET, "ifnet", "interface internals");
MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address");
MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address");
@@ -291,10 +294,10 @@ if_grow(void)
if_indexlim <<= 1;
n = if_indexlim * sizeof(*e);
- e = malloc(n, M_IFADDR, M_WAITOK | M_ZERO);
+ e = malloc(n, M_IFNET, M_WAITOK | M_ZERO);
if (ifindex_table != NULL) {
memcpy((caddr_t)e, (caddr_t)ifindex_table, n/2);
- free((caddr_t)ifindex_table, M_IFADDR);
+ free((caddr_t)ifindex_table, M_IFNET);
}
ifindex_table = e;
}
@@ -325,6 +328,7 @@ if_check(void *dummy __unused)
if_slowtimo(0);
}
+/* XXX: should be locked. */
static int
if_findindex(struct ifnet *ifp)
{
@@ -339,7 +343,7 @@ if_findindex(struct ifnet *ifp)
case IFT_ISO88025:
case IFT_L2VLAN:
case IFT_BRIDGE:
- snprintf(eaddr, 18, "%6D", IFP2AC(ifp)->ac_enaddr, ":");
+ snprintf(eaddr, 18, "%6D", IFP2ENADDR(ifp), ":");
break;
default:
eaddr[0] = '\0';
@@ -376,6 +380,59 @@ found:
}
/*
+ * Allocate a struct ifnet and in index for an interface.
+ */
+struct ifnet*
+if_alloc(u_char type)
+{
+ struct ifnet *ifp;
+
+ ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO);
+
+ /* XXX: This should fail it index it is too big */
+ ifp->if_index = if_findindex(ifp);
+ if (ifp->if_index > if_index)
+ if_index = ifp->if_index;
+ if (if_index >= if_indexlim)
+ if_grow();
+
+ ifnet_byindex(ifp->if_index) = ifp;
+
+ ifp->if_type = type;
+
+ if (if_com_alloc[type] != NULL) {
+ ifp->if_l2com = if_com_alloc[type](type, ifp);
+ if (ifp->if_l2com == NULL)
+ free(ifp, M_IFNET);
+ }
+
+ return (ifp);
+}
+
+void
+if_free(struct ifnet *ifp)
+{
+
+ if_free_type(ifp, ifp->if_type);
+}
+
+void
+if_free_type(struct ifnet *ifp, u_char type)
+{
+
+ if (ifp != ifnet_byindex(ifp->if_index)) {
+ if_printf(ifp, "%s: value was not if_alloced, skipping\n",
+ __func__);
+ return;
+ }
+
+ if (if_com_free[type] != NULL)
+ if_com_free[type](ifp->if_l2com, type);
+
+ free(ifp, M_IFNET);
+};
+
+/*
* Attach an interface to the
* list of "active" interfaces.
*/
@@ -387,6 +444,10 @@ if_attach(struct ifnet *ifp)
struct sockaddr_dl *sdl;
struct ifaddr *ifa;
+ if (ifp->if_index == 0 || ifp != ifnet_byindex(ifp->if_index))
+ panic ("%s: BUG: if_attach called without if_alloc'd input()\n",
+ ifp->if_xname);
+
TASK_INIT(&ifp->if_starttask, 0, if_start_deferred, ifp);
TASK_INIT(&ifp->if_linktask, 0, do_link_state_change, ifp);
IF_AFDATA_LOCK_INIT(ifp);
@@ -407,20 +468,13 @@ if_attach(struct ifnet *ifp)
knlist_init(&ifp->if_klist, NULL);
getmicrotime(&ifp->if_lastchange);
ifp->if_data.ifi_epoch = time_uptime;
+ ifp->if_data.ifi_datalen = sizeof(struct if_data);
#ifdef MAC
mac_init_ifnet(ifp);
mac_create_ifnet(ifp);
#endif
- ifp->if_index = if_findindex(ifp);
- if (ifp->if_index > if_index)
- if_index = ifp->if_index;
- if (if_index >= if_indexlim)
- if_grow();
- ifp->if_data.ifi_datalen = sizeof(struct if_data);
-
- ifnet_byindex(ifp->if_index) = ifp;
ifdev_byindex(ifp->if_index) = make_dev(&net_cdevsw,
unit2minor(ifp->if_index),
UID_ROOT, GID_WHEEL, 0600, "%s/%s",
@@ -572,7 +626,7 @@ if_purgeaddrs(struct ifnet *ifp)
/*
* Detach an interface, removing it from the
- * list of "active" interfaces.
+ * list of "active" interfaces and freeing the struct ifnet.
*/
void
if_detach(struct ifnet *ifp)
@@ -1942,7 +1996,7 @@ if_setlladdr(struct ifnet *ifp, const u_char *lladdr, int len)
case IFT_ISO88025:
case IFT_L2VLAN:
case IFT_BRIDGE:
- bcopy(lladdr, IFP2AC(ifp)->ac_enaddr, len);
+ bcopy(lladdr, IFP2ENADDR(ifp), len);
/*
* XXX We also need to store the lladdr in LLADDR(sdl),
* which is done below. This is a pain because we must
@@ -2066,7 +2120,7 @@ if_start_deferred(void *context, int pending)
KASSERT(debug_mpsafenet != 0, ("if_start_deferred: debug.mpsafenet"));
GIANT_REQUIRED;
- ifp = (struct ifnet *)context;
+ ifp = context;
(ifp->if_start)(ifp);
}
@@ -2094,3 +2148,29 @@ if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
if_start(ifp);
return (1);
}
+
+void
+if_register_com_alloc(u_char type,
+ if_com_alloc_t *a, if_com_free_t *f)
+{
+
+ KASSERT(if_com_alloc[type] == NULL,
+ ("if_register_com_alloc: %d already registered", type));
+ KASSERT(if_com_free[type] == NULL,
+ ("if_register_com_alloc: %d free already registered", type));
+
+ if_com_alloc[type] = a;
+ if_com_free[type] = f;
+}
+
+void
+if_deregister_com_alloc(u_char type)
+{
+
+ KASSERT(if_com_alloc[type] == NULL,
+ ("if_deregister_com_alloc: %d not registered", type));
+ KASSERT(if_com_free[type] == NULL,
+ ("if_deregister_com_alloc: %d free not registered", type));
+ if_com_alloc[type] = NULL;
+ if_com_free[type] = NULL;
+}
diff --git a/sys/net/if_arc.h b/sys/net/if_arc.h
index 461f1b4..7274829 100644
--- a/sys/net/if_arc.h
+++ b/sys/net/if_arc.h
@@ -102,7 +102,7 @@ struct arc_header {
#define ARC_PHDS_MAXMTU 60480
struct arccom {
- struct ifnet ac_if; /* network-visible interface */
+ struct ifnet *ac_ifp; /* network-visible interface */
u_int16_t ac_seqid; /* seq. id used by PHDS encap. */
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index 39022ef..e944f49 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -80,8 +80,6 @@
#include <netipx/ipx_if.h>
#endif
-MODULE_VERSION(arcnet, 1);
-
#define ARCNET_ALLOW_BROKEN_ARP
static struct mbuf *arc_defrag(struct ifnet *, struct mbuf *);
@@ -254,7 +252,7 @@ arc_frag_init(ifp)
{
struct arccom *ac;
- ac = (struct arccom *)ifp;
+ ac = (struct arccom *)ifp->if_l2com;
ac->curr_frag = 0;
}
@@ -266,7 +264,7 @@ arc_frag_next(ifp)
struct mbuf *m;
struct arc_header *ah;
- ac = (struct arccom *)ifp;
+ ac = (struct arccom *)ifp->if_l2com;
if ((m = ac->curr_frag) == 0) {
int tfrags;
@@ -367,7 +365,7 @@ arc_defrag(ifp, m)
int newflen;
u_char src,dst,typ;
- ac = (struct arccom *)ifp;
+ ac = (struct arccom *)ifp->if_l2com;
if (m->m_len < ARC_HDRNEWLEN) {
m = m_pullup(m, ARC_HDRNEWLEN);
@@ -641,7 +639,6 @@ arc_ifattach(ifp, lla)
struct arccom *ac;
if_attach(ifp);
- ifp->if_type = IFT_ARCNET;
ifp->if_addrlen = 1;
ifp->if_hdrlen = ARC_HDRLEN;
ifp->if_mtu = 1500;
@@ -661,7 +658,7 @@ arc_ifattach(ifp, lla)
if (ifp->if_flags & IFF_BROADCAST)
ifp->if_flags |= IFF_MULTICAST|IFF_ALLMULTI;
- ac = (struct arccom *)ifp;
+ ac = (struct arccom *)ifp->if_l2com;
ac->ac_seqid = (time_second) & 0xFFFF; /* try to make seqid unique */
if (lla == 0) {
/* XXX this message isn't entirely clear, to me -- cgd */
@@ -846,3 +843,50 @@ arc_resolvemulti(ifp, llsa, sa)
return EAFNOSUPPORT;
}
}
+
+MALLOC_DEFINE(M_ARCCOM, "arccom", "ARCNET interface internals");
+
+static void*
+arc_alloc(u_char type, struct ifnet *ifp)
+{
+ struct arccom *ac;
+
+ ac = malloc(sizeof(struct arccom), M_ARCCOM, M_WAITOK | M_ZERO);
+ ac->ac_ifp = ifp;
+
+ return (ac);
+}
+
+static void
+arc_free(void *com, u_char type)
+{
+
+ free(com, M_ARCCOM);
+}
+
+static int
+arc_modevent(module_t mod, int type, void *data)
+{
+
+ switch (type) {
+ case MOD_LOAD:
+ if_register_com_alloc(IFT_ARCNET, arc_alloc, arc_free);
+ break;
+ case MOD_UNLOAD:
+ if_deregister_com_alloc(IFT_ARCNET);
+ break;
+ default:
+ return EOPNOTSUPP;
+ }
+
+ return (0);
+}
+
+static moduledata_t arc_mod = {
+ "arcnet",
+ arc_modevent,
+ 0
+};
+
+DECLARE_MODULE(arcnet, arc_mod, SI_SUB_INIT_IF, SI_ORDER_ANY);
+MODULE_VERSION(arcnet, 1);
diff --git a/sys/net/if_arp.h b/sys/net/if_arp.h
index 71f078b..9aa63c6 100644
--- a/sys/net/if_arp.h
+++ b/sys/net/if_arp.h
@@ -99,21 +99,16 @@ struct arpreq {
#ifdef _KERNEL
/*
* Structure shared between the ethernet driver modules and
- * the address resolution code. For example, each ec_softc or il_softc
- * begins with this structure.
- * The code is written so that each *_softc _must_ begin with a
- * struct arpcom, which in turn _must_ begin with a struct ifnet.
+ * the address resolution code.
*/
struct arpcom {
- /*
- * The ifnet struct _must_ be at the head of this structure.
- */
- struct ifnet ac_if; /* network-visible interface */
- u_char ac_enaddr[6]; /* ethernet hardware address */
- int now_unused; /* XXX was length of ac_multiaddrs list */
+ struct ifnet *ac_ifp; /* network-visible interface */
+ u_char _ac_enaddr[6]; /* ethernet hardware address */
void *ac_netgraph; /* ng_ether(4) netgraph node info */
};
-#define IFP2AC(ifp) ((struct arpcom *)(ifp))
+#define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com))
+#define IFP2ENADDR(ifp) (IFP2AC(ifp)->_ac_enaddr)
+#define AC2IFP(ac) ((ac)->ac_ifp)
#endif
diff --git a/sys/net/if_atm.h b/sys/net/if_atm.h
index 4084569..4b07f36 100644
--- a/sys/net/if_atm.h
+++ b/sys/net/if_atm.h
@@ -176,11 +176,12 @@ struct atmio_vcctable {
* this structure.
*/
struct ifatm {
- struct ifnet ifnet; /* required by if_var.h */
+ struct ifnet *ifp;
struct ifatm_mib mib; /* exported data */
void *phy; /* usually SUNI */
void *ngpriv; /* netgraph link */
};
+#define IFP2IFATM(ifp) ((struct ifatm *)(ifp)->if_l2com)
#endif
/*
@@ -304,7 +305,7 @@ void atm_event(struct ifnet *, u_int, void *);
_arg.vpi = (VPI); \
_arg.vci = (VCI); \
_arg.busy = (BUSY); \
- atm_event(&(ATMIF)->ifnet, ATMEV_FLOW_CONTROL, &_arg); \
+ atm_event((ATMIF)->ifp, ATMEV_FLOW_CONTROL, &_arg); \
} while (0)
#define ATMEV_SEND_VCC_CHANGED(ATMIF, VPI, VCI, UP) \
@@ -313,16 +314,16 @@ void atm_event(struct ifnet *, u_int, void *);
_arg.vpi = (VPI); \
_arg.vci = (VCI); \
_arg.up = (UP); \
- atm_event(&(ATMIF)->ifnet, ATMEV_VCC_CHANGED, &_arg); \
+ atm_event((ATMIF)->ifp, ATMEV_VCC_CHANGED, &_arg); \
} while (0)
#define ATMEV_SEND_IFSTATE_CHANGED(ATMIF, CARRIER) \
do { \
struct atmev_ifstate_changed _arg; \
- _arg.running = (((ATMIF)->ifnet.if_flags & \
+ _arg.running = (((ATMIF)->ifp->if_flags & \
IFF_RUNNING) != 0); \
_arg.carrier = ((CARRIER) != 0); \
- atm_event(&(ATMIF)->ifnet, ATMEV_IFSTATE_CHANGED, &_arg); \
+ atm_event((ATMIF)->ifp, ATMEV_IFSTATE_CHANGED, &_arg); \
} while (0)
#define ATMEV_SEND_ACR_CHANGED(ATMIF, VPI, VCI, ACR) \
@@ -331,6 +332,6 @@ void atm_event(struct ifnet *, u_int, void *);
_arg.vpi = (VPI); \
_arg.vci = (VCI); \
_arg.acr= (ACR); \
- atm_event(&(ATMIF)->ifnet, ATMEV_ACR_CHANGED, &_arg); \
+ atm_event((ATMIF)->ifp, ATMEV_ACR_CHANGED, &_arg); \
} while (0)
#endif
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index a5f7b11..1350f5a 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -98,6 +98,8 @@ void (*atm_harp_event_p)(struct ifnet *, uint32_t, void *);
SYSCTL_NODE(_hw, OID_AUTO, atm, CTLFLAG_RW, 0, "ATM hardware");
+MALLOC_DEFINE(M_IFATM, "ifatm", "atm interface internals");
+
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
#endif
@@ -359,9 +361,8 @@ atm_ifattach(struct ifnet *ifp)
{
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
- struct ifatm *ifatm = ifp->if_softc;
+ struct ifatm *ifatm = ifp->if_l2com;
- ifp->if_type = IFT_ATM;
ifp->if_addrlen = 0;
ifp->if_hdrlen = 0;
if_attach(ifp);
@@ -481,11 +482,46 @@ atm_event(struct ifnet *ifp, u_int event, void *arg)
(*atm_harp_event_p)(ifp, event, arg);
}
+static void *
+atm_alloc(u_char type, struct ifnet *ifp)
+{
+ struct ifatm *ifatm;
+
+ ifatm = malloc(sizeof(struct ifatm), M_IFATM, M_WAITOK | M_ZERO);
+ ifatm->ifp = ifp;
+
+ return (ifatm);
+}
+
+static void
+atm_free(void *com, u_char type)
+{
+
+ free(com, M_IFATM);
+}
+
+static int
+atm_modevent(module_t mod, int type, void *data)
+{
+ switch (type) {
+ case MOD_LOAD:
+ if_register_com_alloc(IFT_ATM, atm_alloc, atm_free);
+ break;
+ case MOD_UNLOAD:
+ if_deregister_com_alloc(IFT_ATM);
+ break;
+ default:
+ return (EOPNOTSUPP);
+ }
+
+ return (0);
+}
+
static moduledata_t atm_mod = {
"atm",
- NULL,
+ atm_modevent,
0
};
-DECLARE_MODULE(atm, atm_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(atm, atm_mod, SI_SUB_INIT_IF, SI_ORDER_ANY);
MODULE_VERSION(atm, 1);
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index df52232..0b4fa9d 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -130,7 +130,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_fw.h>
#include <netinet/ip_dummynet.h>
-#define sc_if ifb_ac.ac_if
/*
* Size of the route hash table. Must be a power of two.
*/
@@ -357,7 +356,7 @@ bridge_modevent(module_t mod, int type, void *data)
case MOD_UNLOAD:
if_clone_detach(&bridge_cloner);
while (!LIST_EMPTY(&bridge_list))
- bridge_clone_destroy(&LIST_FIRST(&bridge_list)->sc_if);
+ bridge_clone_destroy(LIST_FIRST(&bridge_list)->sc_ifp);
uma_zdestroy(bridge_rtnode_zone);
bridge_input_p = NULL;
bridge_output_p = NULL;
@@ -419,10 +418,11 @@ bridge_clone_create(struct if_clone *ifc, int unit)
{
struct bridge_softc *sc;
struct ifnet *ifp;
+ u_char eaddr[6];
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
BRIDGE_LOCK_INIT(sc);
- ifp = &sc->sc_if;
+ ifp = sc->sc_ifp;
sc->sc_brtmax = BRIDGE_RTABLE_MAX;
sc->sc_brttimeout = BRIDGE_RTABLE_TIMEOUT;
@@ -457,12 +457,12 @@ bridge_clone_create(struct if_clone *ifc, int unit)
* Generate a random ethernet address and use the private AC:DE:48
* OUI code.
*/
- arc4rand( &sc->ifb_ac.ac_enaddr, ETHER_ADDR_LEN, 1);
- sc->ifb_ac.ac_enaddr[0] = 0xAC;
- sc->ifb_ac.ac_enaddr[1] = 0xDE;
- sc->ifb_ac.ac_enaddr[2] = 0x48;
+ arc4rand(eaddr, ETHER_ADDR_LEN, 1);
+ eaddr[0] = 0xAC;
+ eaddr[1] = 0xDE;
+ eaddr[2] = 0x48;
- ether_ifattach(ifp, sc->ifb_ac.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* Now undo some of the damage... */
ifp->if_baudrate = 0;
ifp->if_type = IFT_BRIDGE;
@@ -693,7 +693,7 @@ bridge_delete_member(struct bridge_softc *sc, struct bridge_iflist *bif)
free(bif, M_DEVBUF);
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
}
@@ -711,7 +711,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg)
if (ifs == NULL)
return (ENOENT);
- if (sc->sc_if.if_mtu != ifs->if_mtu)
+ if (sc->sc_ifp->if_mtu != ifs->if_mtu)
return (EINVAL);
if (ifs->if_bridge == sc)
@@ -753,7 +753,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg)
*/
LIST_INSERT_HEAD(&sc->sc_iflist, bif, bif_next);
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
else
bstp_stop(sc);
@@ -830,7 +830,7 @@ bridge_ioctl_sifflags(struct bridge_softc *sc, void *arg)
bif->bif_flags = req->ifbr_ifsflags;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1031,7 +1031,7 @@ bridge_ioctl_spri(struct bridge_softc *sc, void *arg)
sc->sc_bridge_priority = param->ifbrp_prio;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1060,7 +1060,7 @@ bridge_ioctl_sht(struct bridge_softc *sc, void *arg)
return (EINVAL);
sc->sc_bridge_hello_time = param->ifbrp_hellotime << 8;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1089,7 +1089,7 @@ bridge_ioctl_sfd(struct bridge_softc *sc, void *arg)
return (EINVAL);
sc->sc_bridge_forward_delay = param->ifbrp_fwddelay << 8;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1118,7 +1118,7 @@ bridge_ioctl_sma(struct bridge_softc *sc, void *arg)
return (EINVAL);
sc->sc_bridge_max_age = param->ifbrp_maxage << 8;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1138,7 +1138,7 @@ bridge_ioctl_sifprio(struct bridge_softc *sc, void *arg)
bif->bif_priority = req->ifbr_priority;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1158,7 +1158,7 @@ bridge_ioctl_sifcost(struct bridge_softc *sc, void *arg)
bif->bif_path_cost = req->ifbr_path_cost;
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
bstp_initialization(sc);
return (0);
@@ -1193,7 +1193,7 @@ static void
bridge_init(void *xsc)
{
struct bridge_softc *sc = (struct bridge_softc *)xsc;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->sc_ifp;
if (ifp->if_flags & IFF_RUNNING)
return;
@@ -1246,7 +1246,7 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m,
m->m_pkthdr.csum_flags = 0;
if (runfilt && inet_pfil_hook.ph_busy_count >= 0) {
- if (bridge_pfil(&m, &sc->sc_if, dst_ifp, PFIL_OUT) != 0)
+ if (bridge_pfil(&m, sc->sc_ifp, dst_ifp, PFIL_OUT) != 0)
return;
}
if (m == NULL)
@@ -1257,13 +1257,13 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m,
IFQ_ENQUEUE(&dst_ifp->if_snd, m, err);
if (err == 0) {
- sc->sc_if.if_opackets++;
- sc->sc_if.if_obytes += len;
+ sc->sc_ifp->if_opackets++;
+ sc->sc_ifp->if_obytes += len;
dst_ifp->if_obytes += len;
if (mflags & M_MCAST) {
- sc->sc_if.if_omcasts++;
+ sc->sc_ifp->if_omcasts++;
dst_ifp->if_omcasts++;
}
}
@@ -1334,7 +1334,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa,
* go ahead and send out that interface. Otherwise, the packet
* is dropped below.
*/
- if ((sc->sc_if.if_flags & IFF_RUNNING) == 0) {
+ if ((sc->sc_ifp->if_flags & IFF_RUNNING) == 0) {
dst_if = ifp;
goto sendunicast;
}
@@ -1384,7 +1384,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa,
} else {
mc = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
if (mc == NULL) {
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
continue;
}
}
@@ -1472,10 +1472,10 @@ bridge_forward(struct bridge_softc *sc, struct mbuf *m)
src_if = m->m_pkthdr.rcvif;
BRIDGE_LOCK_ASSERT(sc);
- ifp = &sc->sc_if;
+ ifp = sc->sc_ifp;
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ sc->sc_ifp->if_ipackets++;
+ sc->sc_ifp->if_ibytes += m->m_pkthdr.len;
/*
* Look up the bridge_iflist.
@@ -1543,7 +1543,7 @@ bridge_forward(struct bridge_softc *sc, struct mbuf *m)
}
} else {
/* ...forward it to all interfaces. */
- sc->sc_if.if_imcasts++;
+ sc->sc_ifp->if_imcasts++;
dst_if = NULL;
}
@@ -1615,7 +1615,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
struct ether_header *eh;
struct mbuf *mc;
- if ((sc->sc_if.if_flags & IFF_RUNNING) == 0)
+ if ((sc->sc_ifp->if_flags & IFF_RUNNING) == 0)
return (m);
BRIDGE_LOCK(sc);
@@ -1627,7 +1627,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
eh = mtod(m, struct ether_header *);
- if (memcmp(eh->ether_dhost, sc->ifb_ac.ac_enaddr,
+ if (memcmp(eh->ether_dhost, IFP2ENADDR(sc->sc_ifp),
ETHER_ADDR_LEN) == 0) {
/*
* If the packet is for us, set the packets source as the
@@ -1640,9 +1640,9 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
*/
/* Mark the packet as arriving on the bridge interface */
- m->m_pkthdr.rcvif = &sc->sc_if;
- BPF_MTAP(&sc->sc_if, m);
- sc->sc_if.if_ipackets++;
+ m->m_pkthdr.rcvif = sc->sc_ifp;
+ BPF_MTAP(sc->sc_ifp, m);
+ sc->sc_ifp->if_ipackets++;
BRIDGE_UNLOCK(sc);
return (m);
@@ -1778,7 +1778,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if,
} else {
mc = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
if (mc == NULL) {
- sc->sc_if.if_oerrors++;
+ sc->sc_ifp->if_oerrors++;
continue;
}
}
@@ -1909,7 +1909,7 @@ bridge_timer(void *arg)
bridge_rtage(sc);
BRIDGE_UNLOCK(sc);
- if (sc->sc_if.if_flags & IFF_RUNNING)
+ if (sc->sc_ifp->if_flags & IFF_RUNNING)
callout_reset(&sc->sc_brcallout,
bridge_rtable_prune_period * hz, bridge_timer, sc);
}
diff --git a/sys/net/if_bridgevar.h b/sys/net/if_bridgevar.h
index 705ed85..1bc948b 100644
--- a/sys/net/if_bridgevar.h
+++ b/sys/net/if_bridgevar.h
@@ -262,7 +262,7 @@ struct bridge_rtnode {
* Software state for each bridge.
*/
struct bridge_softc {
- struct arpcom ifb_ac; /* make this an interface */
+ struct ifnet *sc_ifp; /* make this an interface */
LIST_ENTRY(bridge_softc) sc_list;
struct mtx sc_mtx;
struct cv sc_cv;
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 3068b44..7789b29 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -62,7 +62,7 @@
#define DISCNAME "disc"
struct disc_softc {
- struct ifnet sc_if; /* must be first */
+ struct ifnet *sc_ifp; /* must be first */
LIST_ENTRY(disc_softc) sc_list;
};
@@ -86,8 +86,11 @@ disc_clone_create(struct if_clone *ifc, int unit)
struct disc_softc *sc;
sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO);
-
- ifp = &sc->sc_if;
+ ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
+ if (ifp == NULL) {
+ free(sc, M_DISC);
+ return (ENOSPC);
+ }
ifp->if_softc = sc;
if_initname(ifp, ifc->ifc_name, unit);
@@ -95,7 +98,6 @@ disc_clone_create(struct if_clone *ifc, int unit)
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
ifp->if_ioctl = discioctl;
ifp->if_output = discoutput;
- ifp->if_type = IFT_LOOP;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
ifp->if_snd.ifq_maxlen = 20;
@@ -112,8 +114,9 @@ static void
disc_destroy(struct disc_softc *sc)
{
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ bpfdetach(sc->sc_ifp);
+ if_detach(sc->sc_ifp);
+ if_free(sc->sc_ifp);
free(sc, M_DISC);
}
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c
index fa8ac6e..f615485 100644
--- a/sys/net/if_ef.c
+++ b/sys/net/if_ef.c
@@ -86,8 +86,8 @@
#define EFERROR(format, args...) printf("%s: "format, __func__ ,## args)
struct efnet {
- struct arpcom ef_ac;
- struct ifnet * ef_ifp;
+ struct ifnet *ef_ifp;
+ struct ifnet *ef_pifp;
int ef_frametype;
};
@@ -125,7 +125,7 @@ static int ef_unload(void);
static int
ef_attach(struct efnet *sc)
{
- struct ifnet *ifp = (struct ifnet*)&sc->ef_ac.ac_if;
+ struct ifnet *ifp = sc->ef_ifp;
struct ifaddr *ifa2;
struct sockaddr_dl *sdl2;
@@ -137,7 +137,7 @@ ef_attach(struct efnet *sc)
/*
* Attach the interface
*/
- ifa2 = ifaddr_byindex(sc->ef_ifp->if_index);
+ ifa2 = ifaddr_byindex(sc->ef_pifp->if_index);
sdl2 = (struct sockaddr_dl *)ifa2->ifa_addr;
ether_ifattach(ifp, LLADDR(sdl2));
@@ -145,8 +145,6 @@ ef_attach(struct efnet *sc)
ifp->if_type = IFT_XETHER;
ifp->if_flags |= IFF_RUNNING;
- bcopy(LLADDR(sdl2), sc->ef_ac.ac_enaddr, ETHER_ADDR_LEN);
-
EFDEBUG("%s: attached\n", ifp->if_xname);
return 1;
}
@@ -157,24 +155,14 @@ ef_attach(struct efnet *sc)
static int
ef_detach(struct efnet *sc)
{
- struct ifnet *ifp = (struct ifnet*)&sc->ef_ac.ac_if;
+ struct ifnet *ifp = sc->ef_ifp;
int s;
s = splimp();
- if (ifp->if_flags & IFF_UP) {
- if_down(ifp);
- if (ifp->if_flags & IFF_RUNNING) {
- /* find internet addresses and delete routes */
- register struct ifaddr *ifa;
- TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
- rtinit(ifa, (int)RTM_DELETE, 0);
- }
- }
- }
- IFNET_WLOCK();
- TAILQ_REMOVE(&ifnet, ifp, if_link);
- IFNET_WUNLOCK();
+ ether_ifdetach(ifp);
+ if_free(ifp);
+
splx(s);
return 0;
}
@@ -227,7 +215,7 @@ ef_start(struct ifnet *ifp)
int error;
ifp->if_flags |= IFF_OACTIVE;
- p = sc->ef_ifp;
+ p = sc->ef_pifp;
EFDEBUG("\n");
for (;;) {
@@ -377,7 +365,7 @@ ef_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m)
EFDEBUG("Can't find if for %d\n", ft);
return EPROTONOSUPPORT;
}
- eifp = &efp->ef_ac.ac_if;
+ eifp = efp->ef_ifp;
if ((eifp->if_flags & IFF_UP) == 0)
return EPROTONOSUPPORT;
eifp->if_ibytes += m->m_pkthdr.len + sizeof (*eh);
@@ -486,9 +474,11 @@ ef_clone(struct ef_link *efl, int ft)
M_WAITOK | M_ZERO);
if (efp == NULL)
return ENOMEM;
- efp->ef_ifp = ifp;
+ efp->ef_pifp = ifp;
efp->ef_frametype = ft;
- eifp = &efp->ef_ac.ac_if;
+ eifp = efp->ef_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
snprintf(eifp->if_xname, IFNAMSIZ,
"%sf%d", ifp->if_xname, efp->ef_frametype);
eifp->if_dname = "ef";
@@ -545,8 +535,11 @@ ef_load(void)
SLIST_INSERT_HEAD(&efdev, efl, el_next);
SLIST_FOREACH(efl, &efdev, el_next) {
for (d = 0; d < EF_NFT; d++)
- if (efl->el_units[d])
+ if (efl->el_units[d]) {
+ if (efl->el_units[d]->ef_pifp != NULL)
+ if_free(efl->el_units[d]->ef_pifp);
free(efl->el_units[d], M_IFADDR);
+ }
free(efl, M_IFADDR);
}
return error;
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 6082624..cf0b299 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -125,6 +125,9 @@ static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
static int ether_resolvemulti(struct ifnet *, struct sockaddr **,
struct sockaddr *);
+/* XXX: should be in an arp support file, not here */
+MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals");
+
#define senderr(e) do { error = (e); goto bad;} while (0)
#if defined(INET) || defined(INET6)
@@ -285,7 +288,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
(void)memcpy(eh->ether_shost, esrc,
sizeof(eh->ether_shost));
else
- (void)memcpy(eh->ether_shost, IFP2AC(ifp)->ac_enaddr,
+ (void)memcpy(eh->ether_shost, IFP2ENADDR(ifp),
sizeof(eh->ether_shost));
/*
@@ -670,7 +673,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
/*
* XXX: Okay, we need to call carp_forus() and - if it is for
* us jump over code that does the normal check
- * "ac_enaddr == ether_dhost". The check sequence is a bit
+ * "IFP2ENADDR(ifp) == ether_dhost". The check sequence is a bit
* different from OpenBSD, so we jump over as few code as
* possible, to catch _all_ sanity checks. This needs
* evaluation, to see if the carp ether_dhost values break any
@@ -694,7 +697,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
if ((ifp->if_flags & IFF_PROMISC) != 0
&& !ETHER_IS_MULTICAST(eh->ether_dhost)
&& bcmp(eh->ether_dhost,
- IFP2AC(ifp)->ac_enaddr, ETHER_ADDR_LEN) != 0
+ IFP2ENADDR(ifp), ETHER_ADDR_LEN) != 0
&& (ifp->if_flags & IFF_PPROMISC) == 0) {
m_freem(m);
return;
@@ -891,7 +894,6 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *llc)
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
- ifp->if_type = IFT_ETHER;
ifp->if_addrlen = ETHER_ADDR_LEN;
ifp->if_hdrlen = ETHER_HDR_LEN;
if_attach(ifp);
@@ -913,8 +915,8 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *llc)
* XXX: This doesn't belong here; we do it until
* XXX: all drivers are cleaned up
*/
- if (llc != IFP2AC(ifp)->ac_enaddr)
- bcopy(llc, IFP2AC(ifp)->ac_enaddr, ifp->if_addrlen);
+ if (llc != IFP2ENADDR(ifp))
+ bcopy(llc, IFP2ENADDR(ifp), ifp->if_addrlen);
bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
if (ng_ether_attach_p != NULL)
@@ -1051,16 +1053,15 @@ ether_ioctl(struct ifnet *ifp, int command, caddr_t data)
case AF_IPX:
{
struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
- struct arpcom *ac = IFP2AC(ifp);
if (ipx_nullhost(*ina))
ina->x_host =
*(union ipx_host *)
- ac->ac_enaddr;
+ IFP2ENADDR(ifp);
else {
bcopy((caddr_t) ina->x_host.c_host,
- (caddr_t) ac->ac_enaddr,
- sizeof(ac->ac_enaddr));
+ (caddr_t) IFP2ENADDR(ifp),
+ ETHER_ADDR_LEN);
}
/*
@@ -1081,7 +1082,7 @@ ether_ioctl(struct ifnet *ifp, int command, caddr_t data)
struct sockaddr *sa;
sa = (struct sockaddr *) & ifr->ifr_data;
- bcopy(IFP2AC(ifp)->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
(caddr_t) sa->sa_data, ETHER_ADDR_LEN);
}
break;
@@ -1182,11 +1183,47 @@ ether_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
}
}
+static void*
+ether_alloc(u_char type, struct ifnet *ifp)
+{
+ struct arpcom *ac;
+
+ ac = malloc(sizeof(struct arpcom), M_ARPCOM, M_WAITOK | M_ZERO);
+ ac->ac_ifp = ifp;
+
+ return (ac);
+}
+
+static void
+ether_free(void *com, u_char type)
+{
+
+ free(com, M_ARPCOM);
+}
+
+static int
+ether_modevent(module_t mod, int type, void *data)
+{
+
+ switch (type) {
+ case MOD_LOAD:
+ if_register_com_alloc(IFT_ETHER, ether_alloc, ether_free);
+ break;
+ case MOD_UNLOAD:
+ if_deregister_com_alloc(IFT_ETHER);
+ break;
+ default:
+ return EOPNOTSUPP;
+ }
+
+ return (0);
+}
+
static moduledata_t ether_mod = {
"ether",
- NULL,
+ ether_modevent,
0
};
-DECLARE_MODULE(ether, ether_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(ether, ether_mod, SI_SUB_INIT_IF, SI_ORDER_ANY);
MODULE_VERSION(ether, 1);
diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c
index 392ff0d..5835811 100644
--- a/sys/net/if_faith.c
+++ b/sys/net/if_faith.c
@@ -83,7 +83,7 @@
#define FAITHNAME "faith"
struct faith_softc {
- struct ifnet sc_if; /* must be first */
+ struct ifnet *sc_ifp;
LIST_ENTRY(faith_softc) sc_list;
};
@@ -165,24 +165,29 @@ faith_clone_create(ifc, unit)
struct if_clone *ifc;
int unit;
{
+ struct ifnet *ifp;
struct faith_softc *sc;
sc = malloc(sizeof(struct faith_softc), M_FAITH, M_WAITOK | M_ZERO);
+ ifp = sc->sc_ifp = if_alloc(IFT_FAITH);
+ if (ifp == NULL) {
+ free(sc, M_FAITH);
+ return (ENOSPC);
+ }
- sc->sc_if.if_softc = sc;
- if_initname(&sc->sc_if, ifc->ifc_name, unit);
+ ifp->if_softc = sc;
+ if_initname(sc->sc_ifp, ifc->ifc_name, unit);
- sc->sc_if.if_mtu = FAITHMTU;
+ ifp->if_mtu = FAITHMTU;
/* Change to BROADCAST experimentaly to announce its prefix. */
- sc->sc_if.if_flags = /* IFF_LOOPBACK */ IFF_BROADCAST | IFF_MULTICAST;
- sc->sc_if.if_ioctl = faithioctl;
- sc->sc_if.if_output = faithoutput;
- sc->sc_if.if_type = IFT_FAITH;
- sc->sc_if.if_hdrlen = 0;
- sc->sc_if.if_addrlen = 0;
- sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen;
- if_attach(&sc->sc_if);
- bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
+ ifp->if_flags = /* IFF_LOOPBACK */ IFF_BROADCAST | IFF_MULTICAST;
+ ifp->if_ioctl = faithioctl;
+ ifp->if_output = faithoutput;
+ ifp->if_hdrlen = 0;
+ ifp->if_addrlen = 0;
+ ifp->if_snd.ifq_maxlen = ifqmaxlen;
+ if_attach(ifp);
+ bpfattach(ifp, DLT_NULL, sizeof(u_int));
mtx_lock(&faith_mtx);
LIST_INSERT_HEAD(&faith_softc_list, sc, sc_list);
mtx_unlock(&faith_mtx);
@@ -193,8 +198,9 @@ static void
faith_destroy(struct faith_softc *sc)
{
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ bpfdetach(sc->sc_ifp);
+ if_detach(sc->sc_ifp);
+ if_free(sc->sc_ifp);
free(sc, M_FAITH);
}
@@ -202,7 +208,7 @@ static void
faith_clone_destroy(ifp)
struct ifnet *ifp;
{
- struct faith_softc *sc = (void *) ifp;
+ struct faith_softc *sc = ifp->if_softc;
mtx_lock(&faith_mtx);
LIST_REMOVE(sc, sc_list);
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 6cc8e20..dd6b451 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -308,7 +308,7 @@ fddi_output(ifp, m, dst, rt0)
if (hdrcmplt)
bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost, FDDI_ADDR_LEN);
else
- bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_shost,
+ bcopy(IFP2ENADDR(ifp), (caddr_t)fh->fddi_shost,
FDDI_ADDR_LEN);
/*
@@ -418,7 +418,7 @@ fddi_input(ifp, m)
* is in promiscuous mode.
*/
if ((ifp->if_flags & IFF_PROMISC) && ((fh->fddi_dhost[0] & 1) == 0) &&
- (bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t)fh->fddi_dhost,
+ (bcmp(IFP2ENADDR(ifp), (caddr_t)fh->fddi_dhost,
FDDI_ADDR_LEN) != 0))
goto dropanyway;
@@ -585,7 +585,7 @@ fddi_ifattach(ifp, bpf)
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
sdl->sdl_type = IFT_FDDI;
sdl->sdl_alen = ifp->if_addrlen;
- bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
+ bcopy(IFP2ENADDR(ifp), LLADDR(sdl), ifp->if_addrlen);
if (bpf)
bpfattach(ifp, DLT_FDDI, FDDI_HDR_LEN);
@@ -638,18 +638,16 @@ fddi_ioctl (ifp, command, data)
*/
case AF_IPX: {
struct ipx_addr *ina;
- struct arpcom *ac;
ina = &(IA_SIPX(ifa)->sipx_addr);
- ac = IFP2AC(ifp);
if (ipx_nullhost(*ina)) {
ina->x_host = *(union ipx_host *)
- ac->ac_enaddr;
+ IFP2ENADDR(ifp);
} else {
bcopy((caddr_t) ina->x_host.c_host,
- (caddr_t) ac->ac_enaddr,
- sizeof(ac->ac_enaddr));
+ (caddr_t) IFP2ENADDR(ifp),
+ ETHER_ADDR_LEN);
}
/*
@@ -668,7 +666,7 @@ fddi_ioctl (ifp, command, data)
struct sockaddr *sa;
sa = (struct sockaddr *) & ifr->ifr_data;
- bcopy(IFP2AC(ifp)->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
(caddr_t) sa->sa_data, FDDI_ADDR_LEN);
}
diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c
index 7cbd7ac..b3884b5 100644
--- a/sys/net/if_fwsubr.c
+++ b/sys/net/if_fwsubr.c
@@ -40,6 +40,7 @@
#include <sys/mac.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
+#include <sys/module.h>
#include <sys/socket.h>
#include <sys/sockio.h>
@@ -63,6 +64,8 @@
#define IFP2FC(IFP) ((struct fw_com *)IFP)
+MALLOC_DEFINE(M_FWCOM, "fw_com", "firewire interface internals");
+
struct fw_hwaddr firewire_broadcastaddr = {
0xffffffff,
0xffffffff,
@@ -76,7 +79,7 @@ static int
firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct rtentry *rt0)
{
- struct fw_com *fc = (struct fw_com *) ifp;
+ struct fw_com *fc = IFP2FC(ifp);
int error, type;
struct rtentry *rt;
struct m_tag *mtag;
@@ -167,7 +170,7 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
#ifdef INET6
case AF_INET6:
if (unicast) {
- error = nd6_storelladdr(&fc->fc_if, rt, m, dst,
+ error = nd6_storelladdr(fc->fc_ifp, rt, m, dst,
(u_char *) destfw);
if (error)
return (error);
@@ -492,7 +495,7 @@ bad:
void
firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src)
{
- struct fw_com *fc = (struct fw_com *) ifp;
+ struct fw_com *fc = IFP2FC(ifp);
union fw_encap *enc;
int type, isr;
@@ -740,7 +743,7 @@ firewire_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
void
firewire_ifattach(struct ifnet *ifp, struct fw_hwaddr *llc)
{
- struct fw_com *fc = (struct fw_com *) ifp;
+ struct fw_com *fc = IFP2FC(ifp);
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
static const char* speeds[] = {
@@ -751,7 +754,6 @@ firewire_ifattach(struct ifnet *ifp, struct fw_hwaddr *llc)
fc->fc_speed = llc->sspd;
STAILQ_INIT(&fc->fc_frags);
- ifp->if_type = IFT_IEEE1394;
ifp->if_addrlen = sizeof(struct fw_hwaddr);
ifp->if_hdrlen = 0;
if_attach(ifp);
@@ -788,7 +790,7 @@ firewire_ifdetach(struct ifnet *ifp)
void
firewire_busreset(struct ifnet *ifp)
{
- struct fw_com *fc = (struct fw_com *) ifp;
+ struct fw_com *fc = IFP2FC(ifp);
struct fw_reass *r;
struct mbuf *m;
@@ -805,3 +807,49 @@ firewire_busreset(struct ifnet *ifp)
free(r, M_TEMP);
}
}
+
+static void *
+firewire_alloc(u_char type, struct ifnet *ifp)
+{
+ struct fw_com *fc;
+
+ fc = malloc(sizeof(struct fw_com), M_FWCOM, M_WAITOK | M_ZERO);
+ fc->fc_ifp = ifp;
+
+ return (fc);
+}
+
+static void
+firewire_free(void *com, u_char type)
+{
+
+ free(com, M_FWCOM);
+}
+
+static int
+firewire_modevent(module_t mod, int type, void *data)
+{
+
+ switch (type) {
+ case MOD_LOAD:
+ if_register_com_alloc(IFT_IEEE1394,
+ firewire_alloc, firewire_free);
+ break;
+ case MOD_UNLOAD:
+ if_deregister_com_alloc(IFT_IEEE1394);
+ break;
+ default:
+ return (EOPNOTSUPP);
+ }
+
+ return (0);
+}
+
+static moduledata_t firewire_mod = {
+ "firewire",
+ firewire_modevent,
+ 0
+};
+
+DECLARE_MODULE(firewire, firewire_mod, SI_SUB_INIT_IF, SI_ORDER_ANY);
+MODULE_VERSION(firewire, 1);
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 6d00fd8..4c243b6 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -144,9 +144,14 @@ gif_clone_create(ifc, unit)
struct gif_softc *sc;
sc = malloc(sizeof(struct gif_softc), M_GIF, M_WAITOK | M_ZERO);
+ GIF2IFP(sc) = if_alloc(IFT_GIF);
+ if (GIF2IFP(sc) == NULL) {
+ free(sc, M_GIF);
+ return (ENOSPC);
+ }
- sc->gif_if.if_softc = sc;
- if_initname(&sc->gif_if, ifc->ifc_name, unit);
+ GIF2IFP(sc)->if_softc = sc;
+ if_initname(GIF2IFP(sc), ifc->ifc_name, unit);
gifattach0(sc);
@@ -163,27 +168,26 @@ gifattach0(sc)
sc->encap_cookie4 = sc->encap_cookie6 = NULL;
- sc->gif_if.if_addrlen = 0;
- sc->gif_if.if_mtu = GIF_MTU;
- sc->gif_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
+ GIF2IFP(sc)->if_addrlen = 0;
+ GIF2IFP(sc)->if_mtu = GIF_MTU;
+ GIF2IFP(sc)->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
#if 0
/* turn off ingress filter */
- sc->gif_if.if_flags |= IFF_LINK2;
-#endif
- sc->gif_if.if_ioctl = gif_ioctl;
- sc->gif_if.if_output = gif_output;
- sc->gif_if.if_type = IFT_GIF;
- sc->gif_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
- if_attach(&sc->gif_if);
- bpfattach(&sc->gif_if, DLT_NULL, sizeof(u_int));
+ GIF2IFP(sc)->if_flags |= IFF_LINK2;
+#endif
+ GIF2IFP(sc)->if_ioctl = gif_ioctl;
+ GIF2IFP(sc)->if_output = gif_output;
+ GIF2IFP(sc)->if_snd.ifq_maxlen = IFQ_MAXLEN;
+ if_attach(GIF2IFP(sc));
+ bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int));
if (ng_gif_attach_p != NULL)
- (*ng_gif_attach_p)(&sc->gif_if);
+ (*ng_gif_attach_p)(GIF2IFP(sc));
}
static void
gif_destroy(struct gif_softc *sc)
{
- struct ifnet *ifp = &sc->gif_if;
+ struct ifnet *ifp = GIF2IFP(sc);
int err;
gif_delete_tunnel(ifp);
@@ -204,6 +208,7 @@ gif_destroy(struct gif_softc *sc)
(*ng_gif_detach_p)(ifp);
bpfdetach(ifp);
if_detach(ifp);
+ if_free(ifp);
free(sc, M_GIF);
}
@@ -284,7 +289,7 @@ gif_encapcheck(m, off, proto, arg)
if (sc == NULL)
return 0;
- if ((sc->gif_if.if_flags & IFF_UP) == 0)
+ if ((GIF2IFP(sc)->if_flags & IFF_UP) == 0)
return 0;
/* no physical address */
@@ -339,7 +344,7 @@ gif_output(ifp, m, dst, rt)
struct sockaddr *dst;
struct rtentry *rt; /* added in net2 */
{
- struct gif_softc *sc = (struct gif_softc*)ifp;
+ struct gif_softc *sc = ifp->if_softc;
struct m_tag *mtag;
int error = 0;
int gif_called;
@@ -507,7 +512,7 @@ gif_ioctl(ifp, cmd, data)
u_long cmd;
caddr_t data;
{
- struct gif_softc *sc = (struct gif_softc*)ifp;
+ struct gif_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq*)data;
int error = 0, size;
struct sockaddr *dst, *src;
@@ -628,12 +633,12 @@ gif_ioctl(ifp, cmd, data)
break;
}
- error = gif_set_tunnel(&sc->gif_if, src, dst);
+ error = gif_set_tunnel(GIF2IFP(sc), src, dst);
break;
#ifdef SIOCDIFPHYADDR
case SIOCDIFPHYADDR:
- gif_delete_tunnel(&sc->gif_if);
+ gif_delete_tunnel(GIF2IFP(sc));
break;
#endif
@@ -751,7 +756,7 @@ gif_set_tunnel(ifp, src, dst)
struct sockaddr *src;
struct sockaddr *dst;
{
- struct gif_softc *sc = (struct gif_softc *)ifp;
+ struct gif_softc *sc = ifp->if_softc;
struct gif_softc *sc2;
struct sockaddr *osrc, *odst, *sa;
int s;
@@ -860,7 +865,7 @@ void
gif_delete_tunnel(ifp)
struct ifnet *ifp;
{
- struct gif_softc *sc = (struct gif_softc *)ifp;
+ struct gif_softc *sc = ifp->if_softc;
int s;
s = splnet();
diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h
index dc92ae1..831c7f7 100644
--- a/sys/net/if_gif.h
+++ b/sys/net/if_gif.h
@@ -56,7 +56,7 @@ extern void (*ng_gif_attach_p)(struct ifnet *ifp);
extern void (*ng_gif_detach_p)(struct ifnet *ifp);
struct gif_softc {
- struct ifnet gif_if; /* common area - must be at the top */
+ struct ifnet *gif_ifp;
struct sockaddr *gif_psrc; /* Physical src addr */
struct sockaddr *gif_pdst; /* Physical dst addr */
union {
@@ -71,6 +71,7 @@ struct gif_softc {
void *gif_netgraph; /* ng_gif(4) netgraph node info */
LIST_ENTRY(gif_softc) gif_list; /* all gif's are linked */
};
+#define GIF2IFP(sc) ((sc)->gif_ifp)
#define gif_ro gifsc_gifscr.gifscr_ro
#ifdef INET6
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index a2a7831..407784d 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -169,24 +169,24 @@ gre_clone_create(ifc, unit)
sc = malloc(sizeof(struct gre_softc), M_GRE, M_WAITOK | M_ZERO);
- if_initname(&sc->sc_if, ifc->ifc_name, unit);
- sc->sc_if.if_softc = sc;
- sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
- sc->sc_if.if_type = IFT_TUNNEL;
- sc->sc_if.if_addrlen = 0;
- sc->sc_if.if_hdrlen = 24; /* IP + GRE */
- sc->sc_if.if_mtu = GREMTU;
- sc->sc_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST;
- sc->sc_if.if_output = gre_output;
- sc->sc_if.if_ioctl = gre_ioctl;
+ if_initname(GRE2IFP(sc), ifc->ifc_name, unit);
+ GRE2IFP(sc)->if_softc = sc;
+ GRE2IFP(sc)->if_snd.ifq_maxlen = IFQ_MAXLEN;
+ GRE2IFP(sc)->if_type = IFT_TUNNEL;
+ GRE2IFP(sc)->if_addrlen = 0;
+ GRE2IFP(sc)->if_hdrlen = 24; /* IP + GRE */
+ GRE2IFP(sc)->if_mtu = GREMTU;
+ GRE2IFP(sc)->if_flags = IFF_POINTOPOINT|IFF_MULTICAST;
+ GRE2IFP(sc)->if_output = gre_output;
+ GRE2IFP(sc)->if_ioctl = gre_ioctl;
sc->g_dst.s_addr = sc->g_src.s_addr = INADDR_ANY;
sc->g_proto = IPPROTO_GRE;
- sc->sc_if.if_flags |= IFF_LINK0;
+ GRE2IFP(sc)->if_flags |= IFF_LINK0;
sc->encap = NULL;
sc->called = 0;
sc->wccp_ver = WCCP_V1;
- if_attach(&sc->sc_if);
- bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int32_t));
+ if_attach(GRE2IFP(sc));
+ bpfattach(GRE2IFP(sc), DLT_NULL, sizeof(u_int32_t));
mtx_lock(&gre_mtx);
LIST_INSERT_HEAD(&gre_softc_list, sc, sc_list);
mtx_unlock(&gre_mtx);
@@ -201,8 +201,9 @@ gre_destroy(struct gre_softc *sc)
if (sc->encap != NULL)
encap_detach(sc->encap);
#endif
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ bpfdetach(GRE2IFP(sc));
+ if_detach(GRE2IFP(sc));
+ if_free(GRE2IFP(sc));
free(sc, M_GRE);
}
@@ -239,7 +240,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
*/
if (++(sc->called) > max_gre_nesting) {
printf("%s: gre_output: recursively called too many "
- "times(%d)\n", if_name(&sc->sc_if), sc->called);
+ "times(%d)\n", if_name(GRE2IFP(sc)), sc->called);
m_freem(m);
error = EIO; /* is there better errno? */
goto end;
@@ -444,7 +445,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ifp->if_mtu = ifr->ifr_mtu;
break;
case SIOCGIFMTU:
- ifr->ifr_mtu = sc->sc_if.if_mtu;
+ ifr->ifr_mtu = GRE2IFP(sc)->if_mtu;
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -524,7 +525,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
&in_gre_protosw : &in_mobile_protosw, sc);
if (sc->encap == NULL)
printf("%s: unable to attach encap\n",
- if_name(&sc->sc_if));
+ if_name(GRE2IFP(sc)));
#endif
if (sc->route.ro_rt != 0) /* free old route */
RTFREE(sc->route.ro_rt);
@@ -670,7 +671,7 @@ gre_compute_route(struct gre_softc *sc)
* but this is not possible. Should work though. XXX
* there is a simpler way ...
*/
- if ((sc->sc_if.if_flags & IFF_LINK1) == 0) {
+ if ((GRE2IFP(sc)->if_flags & IFF_LINK1) == 0) {
a = ntohl(sc->g_dst.s_addr);
b = a & 0x01;
c = a & 0xfffffffe;
@@ -681,7 +682,7 @@ gre_compute_route(struct gre_softc *sc)
}
#ifdef DIAGNOSTIC
- printf("%s: searching for a route to %s", if_name(&sc->sc_if),
+ printf("%s: searching for a route to %s", if_name(GRE2IFP(sc)),
inet_ntoa(((struct sockaddr_in *)&ro->ro_dst)->sin_addr));
#endif
@@ -705,7 +706,7 @@ gre_compute_route(struct gre_softc *sc)
* now change it back - else ip_output will just drop
* the route and search one to this interface ...
*/
- if ((sc->sc_if.if_flags & IFF_LINK1) == 0)
+ if ((GRE2IFP(sc)->if_flags & IFF_LINK1) == 0)
((struct sockaddr_in *)&ro->ro_dst)->sin_addr = sc->g_dst;
#ifdef DIAGNOSTIC
diff --git a/sys/net/if_gre.h b/sys/net/if_gre.h
index ef9fa4e..6c8e853 100644
--- a/sys/net/if_gre.h
+++ b/sys/net/if_gre.h
@@ -55,7 +55,7 @@ typedef enum {
} wccp_ver_t;
struct gre_softc {
- struct ifnet sc_if;
+ struct ifnet *sc_ifp;
LIST_ENTRY(gre_softc) sc_list;
int gre_unit;
int gre_flags;
@@ -71,6 +71,7 @@ struct gre_softc {
wccp_ver_t wccp_ver; /* version of the WCCP */
};
+#define GRE2IFP(sc) ((sc)->sc_ifp)
struct gre_h {
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index ff88371..d497143 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -123,7 +123,7 @@ iso88025_ifattach(struct ifnet *ifp, int bpf)
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
sdl->sdl_type = IFT_ISO88025;
sdl->sdl_alen = ifp->if_addrlen;
- bcopy(IFP2AC(ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
+ bcopy(IFP2ENADDR(ifp), LLADDR(sdl), ifp->if_addrlen);
if (bpf)
bpfattach(ifp, DLT_IEEE802, ISO88025_HDR_LEN);
@@ -176,17 +176,15 @@ iso88025_ioctl(struct ifnet *ifp, int command, caddr_t data)
*/
case AF_IPX: {
struct ipx_addr *ina;
- struct arpcom *ac;
ina = &(IA_SIPX(ifa)->sipx_addr);
- ac = IFP2AC(ifp);
if (ipx_nullhost(*ina))
ina->x_host = *(union ipx_host *)
- ac->ac_enaddr;
+ IFP2ENADDR(ifp);
else
bcopy((caddr_t) ina->x_host.c_host,
- (caddr_t) ac->ac_enaddr,
+ (caddr_t) IFP2ENADDR(ifp),
ISO88025_ADDR_LEN);
/*
@@ -206,7 +204,7 @@ iso88025_ioctl(struct ifnet *ifp, int command, caddr_t data)
struct sockaddr *sa;
sa = (struct sockaddr *) & ifr->ifr_data;
- bcopy(IFP2AC(ifp)->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
(caddr_t) sa->sa_data, ISO88025_ADDR_LEN);
}
break;
@@ -272,7 +270,7 @@ iso88025_output(ifp, m, dst, rt0)
/* Generate a generic 802.5 header for the packet */
gen_th.ac = TR_AC;
gen_th.fc = TR_LLC_FRAME;
- (void)memcpy((caddr_t)gen_th.iso88025_shost, IFP2AC(ifp)->ac_enaddr,
+ (void)memcpy((caddr_t)gen_th.iso88025_shost, IFP2ENADDR(ifp),
ISO88025_ADDR_LEN);
if (rif_len) {
gen_th.iso88025_shost[0] |= TR_RII;
@@ -517,7 +515,7 @@ iso88025_input(ifp, m)
*/
if ((ifp->if_flags & IFF_PROMISC) &&
((th->iso88025_dhost[0] & 1) == 0) &&
- (bcmp(IFP2AC(ifp)->ac_enaddr, (caddr_t) th->iso88025_dhost,
+ (bcmp(IFP2ENADDR(ifp), (caddr_t) th->iso88025_dhost,
ISO88025_ADDR_LEN) != 0))
goto dropanyway;
@@ -638,7 +636,6 @@ iso88025_input(ifp, m)
int i;
u_char c;
- ac = IFP2AC(ifp);
c = l->llc_dsap;
if (th->iso88025_shost[0] & TR_RII) { /* XXX */
@@ -648,7 +645,7 @@ iso88025_input(ifp, m)
l->llc_dsap = l->llc_ssap;
l->llc_ssap = c;
if (m->m_flags & (M_BCAST | M_MCAST))
- bcopy((caddr_t)ac->ac_enaddr,
+ bcopy((caddr_t)IFP2ENADDR(ifp),
(caddr_t)th->iso88025_dhost,
ISO88025_ADDR_LEN);
sa.sa_family = AF_UNSPEC;
@@ -774,9 +771,48 @@ iso88025_resolvemulti (ifp, llsa, sa)
return (0);
}
+MALLOC_DEFINE(M_ISO88025, "arpcom", "802.5 interface internals");
+
+static void*
+iso88025_alloc(u_char type, struct ifnet *ifp)
+{
+ struct arpcom *ac;
+
+ ac = malloc(sizeof(struct arpcom), M_ISO88025, M_WAITOK | M_ZERO);
+ ac->ac_ifp = ifp;
+
+ return (ac);
+}
+
+static void
+iso88025_free(void *com, u_char type)
+{
+
+ free(com, M_ISO88025);
+}
+
+static int
+iso88025_modevent(module_t mod, int type, void *data)
+{
+
+ switch (type) {
+ case MOD_LOAD:
+ if_register_com_alloc(IFT_ISO88025, iso88025_alloc,
+ iso88025_free);
+ break;
+ case MOD_UNLOAD:
+ if_deregister_com_alloc(IFT_ISO88025);
+ break;
+ default:
+ return EOPNOTSUPP;
+ }
+
+ return (0);
+}
+
static moduledata_t iso88025_mod = {
"iso88025",
- NULL,
+ iso88025_modevent,
0
};
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index a48ab8c..d10d859 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -93,7 +93,7 @@
#define LONAME "lo"
struct lo_softc {
- struct ifnet sc_if; /* network-visible interface */
+ struct ifnet *sc_ifp;
LIST_ENTRY(lo_softc) sc_next;
};
@@ -129,6 +129,7 @@ lo_clone_destroy(ifp)
mtx_unlock(&lo_mtx);
bpfdetach(ifp);
if_detach(ifp);
+ if_free(ifp);
free(sc, M_LO);
}
@@ -137,25 +138,30 @@ lo_clone_create(ifc, unit)
struct if_clone *ifc;
int unit;
{
+ struct ifnet *ifp;
struct lo_softc *sc;
MALLOC(sc, struct lo_softc *, sizeof(*sc), M_LO, M_WAITOK | M_ZERO);
+ ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
+ if (ifp == NULL) {
+ free(sc, M_LO);
+ return (ENOSPC);
+ }
- if_initname(&sc->sc_if, ifc->ifc_name, unit);
- sc->sc_if.if_mtu = LOMTU;
- sc->sc_if.if_flags = IFF_LOOPBACK | IFF_MULTICAST;
- sc->sc_if.if_ioctl = loioctl;
- sc->sc_if.if_output = looutput;
- sc->sc_if.if_type = IFT_LOOP;
- sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen;
- sc->sc_if.if_softc = sc;
- if_attach(&sc->sc_if);
- bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
+ if_initname(ifp, ifc->ifc_name, unit);
+ ifp->if_mtu = LOMTU;
+ ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
+ ifp->if_ioctl = loioctl;
+ ifp->if_output = looutput;
+ ifp->if_snd.ifq_maxlen = ifqmaxlen;
+ ifp->if_softc = sc;
+ if_attach(ifp);
+ bpfattach(ifp, DLT_NULL, sizeof(u_int));
mtx_lock(&lo_mtx);
LIST_INSERT_HEAD(&lo_list, sc, sc_next);
mtx_unlock(&lo_mtx);
if (loif == NULL)
- loif = &sc->sc_if;
+ loif = ifp;
return (0);
}
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index cece192..b59ed39 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -223,26 +223,32 @@ static struct compressor *ppp_compressors[8] = {
static int
ppp_clone_create(struct if_clone *ifc, int unit)
{
+ struct ifnet *ifp;
struct ppp_softc *sc;
sc = malloc(sizeof(struct ppp_softc), M_PPP, M_WAITOK | M_ZERO);
- sc->sc_if.if_softc = sc;
- if_initname(&sc->sc_if, ifc->ifc_name, unit);
- sc->sc_if.if_mtu = PPP_MTU;
- sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- sc->sc_if.if_type = IFT_PPP;
- sc->sc_if.if_hdrlen = PPP_HDRLEN;
- sc->sc_if.if_ioctl = pppsioctl;
- sc->sc_if.if_output = pppoutput;
- sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
+ ifp = sc->sc_ifp = if_alloc(IFT_PPP);
+ if (ifp == NULL) {
+ free(sc, M_PPP);
+ return (ENOSPC);
+ }
+
+ ifp->if_softc = sc;
+ if_initname(ifp, ifc->ifc_name, unit);
+ ifp->if_mtu = PPP_MTU;
+ ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
+ ifp->if_hdrlen = PPP_HDRLEN;
+ ifp->if_ioctl = pppsioctl;
+ ifp->if_output = pppoutput;
+ ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
mtx_init(&sc->sc_inq.ifq_mtx, "ppp_inq", NULL, MTX_DEF);
mtx_init(&sc->sc_fastq.ifq_mtx, "ppp_fastq", NULL, MTX_DEF);
mtx_init(&sc->sc_rawq.ifq_mtx, "ppp_rawq", NULL, MTX_DEF);
- if_attach(&sc->sc_if);
- bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN);
+ if_attach(ifp);
+ bpfattach(ifp, DLT_PPP, PPP_HDRLEN);
PPP_LIST_LOCK();
LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
@@ -256,9 +262,10 @@ ppp_destroy(struct ppp_softc *sc)
{
struct ifnet *ifp;
- ifp = &sc->sc_if;
+ ifp = PPP2IFP(sc);
bpfdetach(ifp);
if_detach(ifp);
+ if_free(ifp);
mtx_destroy(&sc->sc_rawq.ifq_mtx);
mtx_destroy(&sc->sc_fastq.ifq_mtx);
mtx_destroy(&sc->sc_inq.ifq_mtx);
@@ -396,9 +403,9 @@ pppdealloc(sc)
{
struct mbuf *m;
- if_down(&sc->sc_if);
- sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
- getmicrotime(&sc->sc_if.if_lastchange);
+ if_down(PPP2IFP(sc));
+ PPP2IFP(sc)->if_flags &= ~(IFF_UP|IFF_RUNNING);
+ getmicrotime(&PPP2IFP(sc)->if_lastchange);
sc->sc_devp = NULL;
sc->sc_xfer = 0;
IF_DRAIN(&sc->sc_rawq);
@@ -467,7 +474,7 @@ pppioctl(sc, cmd, data, flag, td)
break;
case PPPIOCGUNIT:
- *(int *)data = sc->sc_if.if_dunit;
+ *(int *)data = PPP2IFP(sc)->if_dunit;
break;
case PPPIOCGFLAGS:
@@ -547,7 +554,7 @@ pppioctl(sc, cmd, data, flag, td)
sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
if (sc->sc_xc_state == NULL) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "comp_alloc failed\n");
+ if_printf(PPP2IFP(sc), "comp_alloc failed\n");
error = ENOBUFS;
}
splimp();
@@ -561,7 +568,7 @@ pppioctl(sc, cmd, data, flag, td)
sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
if (sc->sc_rc_state == NULL) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "decomp_alloc failed\n");
+ if_printf(PPP2IFP(sc), "decomp_alloc failed\n");
error = ENOBUFS;
}
splimp();
@@ -571,7 +578,7 @@ pppioctl(sc, cmd, data, flag, td)
break;
}
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "no compressor for [%x %x %x], %x\n",
+ if_printf(PPP2IFP(sc), "no compressor for [%x %x %x], %x\n",
ccp_option[0], ccp_option[1], ccp_option[2], nb);
error = EINVAL; /* no handler found */
break;
@@ -724,14 +731,14 @@ pppsioctl(ifp, cmd, data)
if (ifr->ifr_mtu > PPP_MAXMTU)
error = EINVAL;
else {
- sc->sc_if.if_mtu = ifr->ifr_mtu;
+ PPP2IFP(sc)->if_mtu = ifr->ifr_mtu;
if (sc->sc_setmtu)
(*sc->sc_setmtu)(sc);
}
break;
case SIOCGIFMTU:
- ifr->ifr_mtu = sc->sc_if.if_mtu;
+ ifr->ifr_mtu = PPP2IFP(sc)->if_mtu;
break;
case SIOCADDMULTI:
@@ -959,7 +966,7 @@ pppoutput(ifp, m0, dst, rtp)
if (_IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
_IF_DROP(ifq);
IF_UNLOCK(ifq);
- sc->sc_if.if_oerrors++;
+ PPP2IFP(sc)->if_oerrors++;
sc->sc_stats.ppp_oerrors++;
error = ENOBUFS;
goto bad;
@@ -1010,9 +1017,9 @@ ppp_requeue(sc)
*mpp = m->m_nextpkt;
m->m_nextpkt = NULL;
ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq:
- (struct ifqueue *)&sc->sc_if.if_snd;
+ (struct ifqueue *)&PPP2IFP(sc)->if_snd;
if (! IF_HANDOFF(ifq, m, NULL)) {
- sc->sc_if.if_oerrors++;
+ PPP2IFP(sc)->if_oerrors++;
sc->sc_stats.ppp_oerrors++;
}
break;
@@ -1067,7 +1074,7 @@ ppp_dequeue(sc)
*/
IF_DEQUEUE(&sc->sc_fastq, m);
if (m == NULL)
- IF_DEQUEUE(&sc->sc_if.if_snd, m);
+ IF_DEQUEUE(&PPP2IFP(sc)->if_snd, m);
if (m == NULL)
return NULL;
@@ -1137,7 +1144,7 @@ ppp_dequeue(sc)
slen = m_length(m, NULL);
clen = (*sc->sc_xcomp->compress)
- (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
+ (sc->sc_xc_state, &mcomp, m, slen, PPP2IFP(sc)->if_mtu + PPP_HDRLEN);
if (mcomp != NULL) {
if (sc->sc_flags & SC_CCP_UP) {
/* Send the compressed packet instead of the original. */
@@ -1192,7 +1199,7 @@ pppintr()
LIST_FOREACH(sc, &ppp_softc_list, sc_list) {
s = splimp();
if (!(sc->sc_flags & SC_TBUSY)
- && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
+ && (PPP2IFP(sc)->if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
sc->sc_flags |= SC_TBUSY;
splx(s);
(*sc->sc_start)(sc);
@@ -1205,7 +1212,7 @@ pppintr()
if (m == NULL)
break;
#ifdef MAC
- mac_create_mbuf_from_ifnet(&sc->sc_if, m);
+ mac_create_mbuf_from_ifnet(PPP2IFP(sc), m);
#endif
ppp_inproc(sc, m);
}
@@ -1273,7 +1280,7 @@ ppp_ccp(sc, m, rcvd)
if (sc->sc_xc_state != NULL
&& (*sc->sc_xcomp->comp_init)
(sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
- sc->sc_if.if_dunit, 0, sc->sc_flags & SC_DEBUG)) {
+ PPP2IFP(sc)->if_dunit, 0, sc->sc_flags & SC_DEBUG)) {
s = splimp();
sc->sc_flags |= SC_COMP_RUN;
splx(s);
@@ -1283,7 +1290,7 @@ ppp_ccp(sc, m, rcvd)
if (sc->sc_rc_state != NULL
&& (*sc->sc_rcomp->decomp_init)
(sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
- sc->sc_if.if_dunit, 0, sc->sc_mru,
+ PPP2IFP(sc)->if_dunit, 0, sc->sc_mru,
sc->sc_flags & SC_DEBUG)) {
s = splimp();
sc->sc_flags |= SC_DECOMP_RUN;
@@ -1363,7 +1370,7 @@ ppp_inproc(sc, m)
struct ppp_softc *sc;
struct mbuf *m;
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = PPP2IFP(sc);
int isr;
int s, ilen = 0, xlen, proto, rv;
u_char *cp, adrs, ctrl;
@@ -1577,7 +1584,7 @@ ppp_inproc(sc, m)
}
/* See if bpf wants to look at the packet. */
- BPF_MTAP(&sc->sc_if, m);
+ BPF_MTAP(PPP2IFP(sc), m);
isr = -1;
switch (proto) {
@@ -1605,7 +1612,7 @@ ppp_inproc(sc, m)
/*
* IPX packet - take off the ppp header and pass it up to IPX.
*/
- if ((sc->sc_if.if_flags & IFF_UP) == 0
+ if ((PPP2IFP(sc)->if_flags & IFF_UP) == 0
/* XXX: || sc->sc_npmode[NP_IPX] != NPMODE_PASS*/) {
/* interface is down - drop the packet. */
m_freem(m);
@@ -1649,7 +1656,7 @@ ppp_inproc(sc, m)
bad:
if (m)
m_freem(m);
- sc->sc_if.if_ierrors++;
+ PPP2IFP(sc)->if_ierrors++;
sc->sc_stats.ppp_ierrors++;
}
diff --git a/sys/net/if_pppvar.h b/sys/net/if_pppvar.h
index daa263c..f103df5 100644
--- a/sys/net/if_pppvar.h
+++ b/sys/net/if_pppvar.h
@@ -54,7 +54,7 @@
* Structure describing each ppp unit.
*/
struct ppp_softc {
- struct ifnet sc_if; /* network-visible interface */
+ struct ifnet *sc_ifp; /* network-visible interface */
/*hi*/ u_int sc_flags; /* control/status bits; see if_ppp.h */
struct callout_handle sc_ch; /* Used for scheduling timeouts */
void *sc_devp; /* pointer to device-dep structure */
@@ -99,6 +99,7 @@ struct ppp_softc {
int sc_rawin_count; /* # in sc_rawin */
LIST_ENTRY(ppp_softc) sc_list;
};
+#define PPP2IFP(sc) ((sc)->sc_ifp)
struct ppp_softc *pppalloc(pid_t pid);
void pppdealloc(struct ppp_softc *sc);
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 0617037..a03ba1c 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -231,10 +231,10 @@ static size_t st_unit_max = 0;
static int
slisunitfree(int unit)
{
- struct sl_softc *nc;
+ struct sl_softc *sc;
- LIST_FOREACH(nc, &sl_list, sl_next) {
- if (nc->sc_if.if_dunit == unit)
+ LIST_FOREACH(sc, &sl_list, sl_next) {
+ if (SL2IFP(sc)->if_dunit == unit)
return (0);
}
return (1);
@@ -291,6 +291,11 @@ slcreate(void)
struct mbuf *m;
MALLOC(sc, struct sl_softc *, sizeof(*sc), M_SL, M_WAITOK | M_ZERO);
+ sc->sc_ifp = if_alloc(IFT_SLIP);
+ if (sc->sc_ifp == NULL) {
+ free(sc, M_SL);
+ return (NULL);
+ }
m = m_gethdr(M_TRYWAIT, MT_DATA);
if (m != NULL) {
@@ -313,22 +318,21 @@ slcreate(void)
sc->sc_mp = sc->sc_buf;
sl_compress_init(&sc->sc_comp, -1);
- sc->sc_if.if_softc = sc;
- sc->sc_if.if_mtu = SLMTU;
- sc->sc_if.if_flags =
+ SL2IFP(sc)->if_softc = sc;
+ SL2IFP(sc)->if_mtu = SLMTU;
+ SL2IFP(sc)->if_flags =
#ifdef SLIP_IFF_OPTS
SLIP_IFF_OPTS;
#else
IFF_POINTOPOINT | SC_AUTOCOMP | IFF_MULTICAST | IFF_NEEDSGIANT;
#endif
- sc->sc_if.if_type = IFT_SLIP;
- sc->sc_if.if_ioctl = slioctl;
- sc->sc_if.if_output = sloutput;
- sc->sc_if.if_start = slstart;
- sc->sc_if.if_snd.ifq_maxlen = 50;
+ SL2IFP(sc)->if_ioctl = slioctl;
+ SL2IFP(sc)->if_output = sloutput;
+ SL2IFP(sc)->if_start = slstart;
+ SL2IFP(sc)->if_snd.ifq_maxlen = 50;
sc->sc_fastq.ifq_maxlen = 32;
- sc->sc_if.if_linkmib = sc;
- sc->sc_if.if_linkmiblen = sizeof *sc;
+ SL2IFP(sc)->if_linkmib = sc;
+ SL2IFP(sc)->if_linkmiblen = sizeof *sc;
mtx_init(&sc->sc_fastq.ifq_mtx, "sl_fastq", NULL, MTX_DEF);
/*
@@ -341,11 +345,11 @@ slcreate(void)
continue;
break;
}
- if_initname(&sc->sc_if, "sl", unit);
+ if_initname(SL2IFP(sc), "sl", unit);
LIST_INSERT_HEAD(&sl_list, sc, sl_next);
- if_attach(&sc->sc_if);
- bpfattach(&sc->sc_if, DLT_SLIP, SLIP_HDRLEN);
+ if_attach(SL2IFP(sc));
+ bpfattach(SL2IFP(sc), DLT_SLIP, SLIP_HDRLEN);
return sc;
}
@@ -371,7 +375,7 @@ slopen(struct cdev *dev, register struct tty *tp)
tp->t_hotchar = FRAME_END;
sc->sc_ttyp = tp;
- sc->sc_if.if_baudrate = tp->t_ospeed;
+ SL2IFP(sc)->if_baudrate = tp->t_ospeed;
ttyflush(tp, FREAD | FWRITE);
/*
@@ -386,12 +390,12 @@ slopen(struct cdev *dev, register struct tty *tp)
*/
clist_alloc_cblocks(&tp->t_canq, 0, 0);
clist_alloc_cblocks(&tp->t_outq,
- SLIP_HIWAT + 2 * sc->sc_if.if_mtu + 1,
- SLIP_HIWAT + 2 * sc->sc_if.if_mtu + 1);
+ SLIP_HIWAT + 2 * SL2IFP(sc)->if_mtu + 1,
+ SLIP_HIWAT + 2 * SL2IFP(sc)->if_mtu + 1);
clist_alloc_cblocks(&tp->t_rawq, 0, 0);
s = splnet();
- if_up(&sc->sc_if);
+ if_up(SL2IFP(sc));
splx(s);
return (0);
}
@@ -399,8 +403,9 @@ slopen(struct cdev *dev, register struct tty *tp)
static void
sldestroy(struct sl_softc *sc)
{
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ bpfdetach(SL2IFP(sc));
+ if_detach(SL2IFP(sc));
+ if_free(SL2IFP(sc));
LIST_REMOVE(sc, sl_next);
m_free(sc->sc_mbuf);
mtx_destroy(&sc->sc_fastq.ifq_mtx);
@@ -437,7 +442,7 @@ slclose(struct tty *tp, int flag)
sc->sc_keepalive = 0;
untimeout(sl_keepalive, sc, sc->sc_kahandle);
}
- if_down(&sc->sc_if);
+ if_down(SL2IFP(sc));
sc->sc_ttyp = NULL;
sldestroy(sc);
}
@@ -460,7 +465,7 @@ sltioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
s = splimp();
switch (cmd) {
case SLIOCGUNIT:
- *(int *)data = sc->sc_if.if_dunit;
+ *(int *)data = SL2IFP(sc)->if_dunit;
break;
case SLIOCSUNIT:
@@ -469,27 +474,27 @@ sltioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
splx(s);
return (ENXIO);
}
- if (sc->sc_if.if_dunit != unit) {
+ if (SL2IFP(sc)->if_dunit != unit) {
if (!slisunitfree(unit)) {
splx(s);
return (ENXIO);
}
- wasup = sc->sc_if.if_flags & IFF_UP;
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ wasup = SL2IFP(sc)->if_flags & IFF_UP;
+ bpfdetach(SL2IFP(sc));
+ if_detach(SL2IFP(sc));
LIST_REMOVE(sc, sl_next);
- if_initname(&sc->sc_if, "sl", unit);
+ if_initname(SL2IFP(sc), "sl", unit);
LIST_INSERT_HEAD(&sl_list, sc, sl_next);
- if_attach(&sc->sc_if);
- bpfattach(&sc->sc_if, DLT_SLIP, SLIP_HDRLEN);
+ if_attach(SL2IFP(sc));
+ bpfattach(SL2IFP(sc), DLT_SLIP, SLIP_HDRLEN);
if (wasup)
- if_up(&sc->sc_if);
+ if_up(SL2IFP(sc));
else
- if_down(&sc->sc_if);
+ if_down(SL2IFP(sc));
clist_alloc_cblocks(&tp->t_outq,
- SLIP_HIWAT + 2 * sc->sc_if.if_mtu + 1,
- SLIP_HIWAT + 2 * sc->sc_if.if_mtu + 1);
+ SLIP_HIWAT + 2 * SL2IFP(sc)->if_mtu + 1,
+ SLIP_HIWAT + 2 * SL2IFP(sc)->if_mtu + 1);
}
slmarkstatic(unit);
break;
@@ -559,7 +564,7 @@ sloutput(struct ifnet *ifp, register struct mbuf *m, struct sockaddr *dst,
if (dst->sa_family != AF_INET) {
if_printf(ifp, "af%d not supported\n", dst->sa_family);
m_freem(m);
- sc->sc_if.if_noproto++;
+ SL2IFP(sc)->if_noproto++;
return (EAFNOSUPPORT);
}
@@ -572,17 +577,17 @@ sloutput(struct ifnet *ifp, register struct mbuf *m, struct sockaddr *dst,
return (EHOSTUNREACH);
}
ip = mtod(m, struct ip *);
- if (sc->sc_if.if_flags & SC_NOICMP && ip->ip_p == IPPROTO_ICMP) {
+ if (SL2IFP(sc)->if_flags & SC_NOICMP && ip->ip_p == IPPROTO_ICMP) {
m_freem(m);
return (ENETRESET); /* XXX ? */
}
if (ip->ip_tos & IPTOS_LOWDELAY &&
- !ALTQ_IS_ENABLED(&sc->sc_if.if_snd))
- error = !(IF_HANDOFF(&sc->sc_fastq, m, &sc->sc_if));
+ !ALTQ_IS_ENABLED(&SL2IFP(sc)->if_snd))
+ error = !(IF_HANDOFF(&sc->sc_fastq, m, SL2IFP(sc)));
else
- IFQ_HANDOFF(&sc->sc_if, m, error);
+ IFQ_HANDOFF(SL2IFP(sc), m, error);
if (error) {
- sc->sc_if.if_oerrors++;
+ SL2IFP(sc)->if_oerrors++;
return (ENOBUFS);
}
return (0);
@@ -644,9 +649,9 @@ sltstart(struct tty *tp)
s = splimp();
IF_DEQUEUE(&sc->sc_fastq, m);
if (m)
- sc->sc_if.if_omcasts++; /* XXX */
+ SL2IFP(sc)->if_omcasts++; /* XXX */
else
- IF_DEQUEUE(&sc->sc_if.if_snd, m);
+ IF_DEQUEUE(&SL2IFP(sc)->if_snd, m);
splx(s);
if (m == NULL)
return 0;
@@ -657,7 +662,7 @@ sltstart(struct tty *tp)
* queueing, and the connection id compression will get
* munged when this happens.
*/
- if (sc->sc_if.if_bpf) {
+ if (SL2IFP(sc)->if_bpf) {
/*
* We need to save the TCP/IP header before it's
* compressed. To avoid complicated code, we just
@@ -687,11 +692,11 @@ sltstart(struct tty *tp)
}
ip = mtod(m, struct ip *);
if (ip->ip_v == IPVERSION && ip->ip_p == IPPROTO_TCP) {
- if (sc->sc_if.if_flags & SC_COMPRESS)
+ if (SL2IFP(sc)->if_flags & SC_COMPRESS)
*mtod(m, u_char *) |= sl_compress_tcp(m, ip,
&sc->sc_comp, 1);
}
- if (sc->sc_if.if_bpf && sc->bpfbuf) {
+ if (SL2IFP(sc)->if_bpf && sc->bpfbuf) {
/*
* Put the SLIP pseudo-"link header" in place. The
* compressed header is now at the beginning of the
@@ -699,7 +704,7 @@ sltstart(struct tty *tp)
*/
sc->bpfbuf[SLX_DIR] = SLIPDIR_OUT;
bcopy(mtod(m, caddr_t), &sc->bpfbuf[SLX_CHDR], CHDR_LEN);
- BPF_TAP(&sc->sc_if, sc->bpfbuf, len + SLIP_HDRLEN);
+ BPF_TAP(SL2IFP(sc), sc->bpfbuf, len + SLIP_HDRLEN);
}
/*
@@ -712,7 +717,7 @@ sltstart(struct tty *tp)
*/
if (cfreecount < CLISTRESERVE + SLTMAX) {
m_freem(m);
- sc->sc_if.if_collisions++;
+ SL2IFP(sc)->if_collisions++;
continue;
}
@@ -723,7 +728,7 @@ sltstart(struct tty *tp)
* the line may have been idle for some time.
*/
if (tp->t_outq.c_cc == 0) {
- ++sc->sc_if.if_obytes;
+ ++SL2IFP(sc)->if_obytes;
(void) putc(FRAME_END, &tp->t_outq);
}
@@ -755,7 +760,7 @@ sltstart(struct tty *tp)
if (b_to_q((char *)bp, cp - bp,
&tp->t_outq))
break;
- sc->sc_if.if_obytes += cp - bp;
+ SL2IFP(sc)->if_obytes += cp - bp;
}
/*
* If there are characters left in the mbuf,
@@ -771,7 +776,7 @@ sltstart(struct tty *tp)
(void) unputc(&tp->t_outq);
break;
}
- sc->sc_if.if_obytes += 2;
+ SL2IFP(sc)->if_obytes += 2;
}
}
m = m_free(m);
@@ -787,10 +792,10 @@ sltstart(struct tty *tp)
*/
(void) unputc(&tp->t_outq);
(void) putc(FRAME_END, &tp->t_outq);
- sc->sc_if.if_collisions++;
+ SL2IFP(sc)->if_collisions++;
} else {
- ++sc->sc_if.if_obytes;
- sc->sc_if.if_opackets++;
+ ++SL2IFP(sc)->if_obytes;
+ SL2IFP(sc)->if_opackets++;
}
}
return 0;
@@ -837,7 +842,7 @@ sl_btom(struct sl_softc *sc, register int len)
m->m_len = len;
m->m_pkthdr.len = len;
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = SL2IFP(sc);
return (m);
}
@@ -862,9 +867,9 @@ slinput(int c, struct tty *tp)
}
c &= TTY_CHARMASK;
- ++sc->sc_if.if_ibytes;
+ ++SL2IFP(sc)->if_ibytes;
- if (sc->sc_if.if_flags & IFF_DEBUG) {
+ if (SL2IFP(sc)->if_flags & IFF_DEBUG) {
if (c == ABT_ESC) {
/*
* If we have a previous abort, see whether
@@ -917,7 +922,7 @@ slinput(int c, struct tty *tp)
/* less than min length packet - ignore */
goto newpack;
- if (sc->sc_if.if_bpf) {
+ if (SL2IFP(sc)->if_bpf) {
/*
* Save the compressed header, so we
* can tack it on later. Note that we
@@ -941,22 +946,22 @@ slinput(int c, struct tty *tp)
* it's a reasonable packet, decompress it and then
* enable compression. Otherwise, drop it.
*/
- if (sc->sc_if.if_flags & SC_COMPRESS) {
+ if (SL2IFP(sc)->if_flags & SC_COMPRESS) {
len = sl_uncompress_tcp(&sc->sc_buf, len,
(u_int)c, &sc->sc_comp);
if (len <= 0)
goto error;
- } else if ((sc->sc_if.if_flags & SC_AUTOCOMP) &&
+ } else if ((SL2IFP(sc)->if_flags & SC_AUTOCOMP) &&
c == TYPE_UNCOMPRESSED_TCP && len >= 40) {
len = sl_uncompress_tcp(&sc->sc_buf, len,
(u_int)c, &sc->sc_comp);
if (len <= 0)
goto error;
- sc->sc_if.if_flags |= SC_COMPRESS;
+ SL2IFP(sc)->if_flags |= SC_COMPRESS;
} else
goto error;
}
- if (sc->sc_if.if_bpf) {
+ if (SL2IFP(sc)->if_bpf) {
/*
* Put the SLIP pseudo-"link header" in place.
* We couldn't do this any earlier since
@@ -967,21 +972,21 @@ slinput(int c, struct tty *tp)
hp[SLX_DIR] = SLIPDIR_IN;
bcopy(chdr, &hp[SLX_CHDR], CHDR_LEN);
- BPF_TAP(&sc->sc_if, hp, len + SLIP_HDRLEN);
+ BPF_TAP(SL2IFP(sc), hp, len + SLIP_HDRLEN);
}
m = sl_btom(sc, len);
if (m == NULL)
goto error;
- sc->sc_if.if_ipackets++;
+ SL2IFP(sc)->if_ipackets++;
- if ((sc->sc_if.if_flags & IFF_UP) == 0) {
+ if ((SL2IFP(sc)->if_flags & IFF_UP) == 0) {
m_freem(m);
goto newpack;
}
if (netisr_queue(NETISR_IP, m)) { /* (0) on success. */
- sc->sc_if.if_ierrors++;
- sc->sc_if.if_iqdrops++;
+ SL2IFP(sc)->if_ierrors++;
+ SL2IFP(sc)->if_iqdrops++;
}
goto newpack;
}
@@ -995,7 +1000,7 @@ slinput(int c, struct tty *tp)
sc->sc_flags |= SC_ERROR;
error:
- sc->sc_if.if_ierrors++;
+ SL2IFP(sc)->if_ierrors++;
newpack:
sc->sc_mp = sc->sc_buf = sc->sc_ep - SLRMAX;
sc->sc_escape = 0;
@@ -1103,7 +1108,7 @@ sl_outfill(void *chan)
if (sc->sc_outfill && tp != NULL) {
if (sc->sc_flags & SC_OUTWAIT) {
s = splimp ();
- ++sc->sc_if.if_obytes;
+ ++SL2IFP(sc)->if_obytes;
(void) putc(FRAME_END, &tp->t_outq);
(*tp->t_oproc)(tp);
splx (s);
diff --git a/sys/net/if_slvar.h b/sys/net/if_slvar.h
index 2de9533..e6b6d2c 100644
--- a/sys/net/if_slvar.h
+++ b/sys/net/if_slvar.h
@@ -43,7 +43,7 @@
* of sl_softc.)
*/
struct sl_softc {
- struct ifnet sc_if; /* network-visible interface */
+ struct ifnet *sc_ifp; /* network-visible interface */
struct ifqueue sc_fastq; /* interactive output queue */
struct tty *sc_ttyp; /* pointer to tty structure */
struct mbuf *sc_mbuf; /* pointer to mbuf containing buffer */
@@ -67,6 +67,7 @@ struct sl_softc {
LIST_ENTRY(sl_softc) sl_next;
u_char *bpfbuf; /* hang buffer for bpf here */
};
+#define SL2IFP(sc) ((sc)->sc_ifp)
/* internal flags */
#define SC_ERROR 0x0001 /* had an input error */
diff --git a/sys/net/if_sppp.h b/sys/net/if_sppp.h
index 39267ae..97f94b3 100644
--- a/sys/net/if_sppp.h
+++ b/sys/net/if_sppp.h
@@ -136,8 +136,7 @@ struct spppreq {
#ifdef _KERNEL
struct sppp {
- /* NB: pp_if _must_ be first */
- struct ifnet pp_if; /* network interface data */
+ struct ifnet *pp_ifp; /* network interface data */
struct ifqueue pp_fastq; /* fast output queue */
struct ifqueue pp_cpq; /* PPP control protocol queue */
struct sppp *pp_next; /* next interface in keepalive list */
@@ -204,6 +203,8 @@ struct sppp {
void (*if_start) (struct ifnet *);
struct callout ifstart_callout; /* if_start () scheduler */
};
+#define IFP2SP(ifp) ((struct sppp *)(ifp)->if_l2com)
+#define SP2IFP(sp) ((sp)->pp_ifp)
/* bits for pp_flags */
#define PP_KEEPALIVE 0x01 /* use keepalive protocol */
diff --git a/sys/net/if_spppfr.c b/sys/net/if_spppfr.c
index 7989df9..ae4f959 100644
--- a/sys/net/if_spppfr.c
+++ b/sys/net/if_spppfr.c
@@ -159,7 +159,7 @@ struct arp_req {
/* almost every function needs these */
#define STDDCL \
- struct ifnet *ifp = &sp->pp_if; \
+ struct ifnet *ifp = SP2IFP(sp); \
int debug = ifp->if_flags & IFF_DEBUG
static void sppp_fr_arp (struct sppp *sp, struct arp_req *req, u_short addr);
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index d7cf484..b1cd8fe 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -198,6 +198,8 @@
#define STATE_ACK_SENT 8
#define STATE_OPENED 9
+MALLOC_DEFINE(M_SPPP, "sppp", "synchronous PPP interface internals");
+
struct ppp_header {
u_char address;
u_char control;
@@ -264,22 +266,22 @@ struct cp {
#define SPPP_LOCK(sp) \
do { \
- if (!((sp)->pp_if.if_flags & IFF_NEEDSGIANT)) \
+ if (!(SP2IFP(sp)->if_flags & IFF_NEEDSGIANT)) \
mtx_lock (&(sp)->mtx); \
} while (0)
#define SPPP_UNLOCK(sp) \
do { \
- if (!((sp)->pp_if.if_flags & IFF_NEEDSGIANT)) \
+ if (!(SP2IFP(sp)->if_flags & IFF_NEEDSGIANT)) \
mtx_unlock (&(sp)->mtx); \
} while (0)
#define SPPP_LOCK_ASSERT(sp) \
do { \
- if (!((sp)->pp_if.if_flags & IFF_NEEDSGIANT)) \
+ if (!(SP2IFP(sp)->if_flags & IFF_NEEDSGIANT)) \
mtx_assert (&(sp)->mtx, MA_OWNED); \
} while (0)
#define SPPP_LOCK_OWNED(sp) \
- (!((sp)->pp_if.if_flags & IFF_NEEDSGIANT) && \
+ (!(SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) && \
mtx_owned (&sp->mtx))
#ifdef INET
@@ -300,7 +302,7 @@ static const u_short interactive_ports[8] = {
/* almost every function needs these */
#define STDDCL \
- struct ifnet *ifp = &sp->pp_if; \
+ struct ifnet *ifp = SP2IFP(sp); \
int debug = ifp->if_flags & IFF_DEBUG
static int sppp_output(struct ifnet *ifp, struct mbuf *m,
@@ -490,13 +492,39 @@ static const struct cp *cps[IDX_COUNT] = {
&chap, /* IDX_CHAP */
};
+static void*
+sppp_alloc(u_char type, struct ifnet *ifp)
+{
+ struct sppp *sp;
+
+ sp = malloc(sizeof(struct sppp), M_SPPP, M_WAITOK | M_ZERO);
+ sp->pp_ifp = ifp;
+
+ return (sp);
+}
+
+static void
+sppp_free(void *com, u_char type)
+{
+
+ free(com, M_SPPP);
+}
+
static int
sppp_modevent(module_t mod, int type, void *unused)
{
switch (type) {
case MOD_LOAD:
+ /*
+ * XXX: should probably be IFT_SPPP, but it's fairly
+ * harmless to allocate struct sppp's for non-sppp
+ * interfaces.
+ */
+
+ if_register_com_alloc(IFT_PPP, sppp_alloc, sppp_free);
break;
case MOD_UNLOAD:
+ /* if_deregister_com_alloc(IFT_PPP); */
return EACCES;
default:
return EOPNOTSUPP;
@@ -523,7 +551,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
{
struct ppp_header *h;
int isr = -1;
- struct sppp *sp = (struct sppp *)ifp;
+ struct sppp *sp = IFP2SP(ifp);
u_char *iphdr;
int hlen, vjlen, do_account = 0;
int debug;
@@ -708,7 +736,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
++ifp->if_noproto;
goto invalid;
case CISCO_KEEPALIVE:
- sppp_cisco_input ((struct sppp*) ifp, m);
+ sppp_cisco_input (sp, m);
m_freem (m);
SPPP_UNLOCK(sp);
return;
@@ -769,7 +797,7 @@ sppp_ifstart_sched(void *dummy)
{
struct sppp *sp = dummy;
- sp->if_start(&sp->pp_if);
+ sp->if_start(SP2IFP(sp));
}
/* if_start () wrapper function. We use it to schedule real if_start () for
@@ -778,7 +806,7 @@ sppp_ifstart_sched(void *dummy)
static void
sppp_ifstart(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
if (SPPP_LOCK_OWNED(sp)) {
if (callout_pending(&sp->ifstart_callout))
@@ -797,7 +825,7 @@ static int
sppp_output(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
struct ppp_header *h;
struct ifqueue *ifq = NULL;
int s, error, rv = 0;
@@ -1039,7 +1067,7 @@ out:
void
sppp_attach(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
/* Initialize mtx lock */
mtx_init(&sp->mtx, "sppp", MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);
@@ -1050,14 +1078,13 @@ sppp_attach(struct ifnet *ifp)
callout_reset(&sp->keepalive_callout, hz * 10, sppp_keepalive,
(void *)sp);
- sp->pp_if.if_mtu = PP_MTU;
- sp->pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- sp->pp_if.if_type = IFT_PPP;
- sp->pp_if.if_output = sppp_output;
+ ifp->if_mtu = PP_MTU;
+ ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
+ ifp->if_output = sppp_output;
#if 0
sp->pp_flags = PP_KEEPALIVE;
#endif
- sp->pp_if.if_snd.ifq_maxlen = 32;
+ ifp->if_snd.ifq_maxlen = 32;
sp->pp_fastq.ifq_maxlen = 32;
sp->pp_cpq.ifq_maxlen = 20;
sp->pp_loopcnt = 0;
@@ -1095,7 +1122,7 @@ sppp_attach(struct ifnet *ifp)
void
sppp_detach(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
int i;
KASSERT(mtx_initialized(&sp->mtx), ("sppp mutex is not initialized"));
@@ -1121,9 +1148,9 @@ sppp_detach(struct ifnet *ifp)
static void
sppp_flush_unlocked(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
- sppp_qflush ((struct ifqueue *)&sp->pp_if.if_snd);
+ sppp_qflush ((struct ifqueue *)&SP2IFP(sp)->if_snd);
sppp_qflush (&sp->pp_fastq);
sppp_qflush (&sp->pp_cpq);
}
@@ -1131,7 +1158,7 @@ sppp_flush_unlocked(struct ifnet *ifp)
void
sppp_flush(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
SPPP_LOCK(sp);
sppp_flush_unlocked (ifp);
@@ -1144,13 +1171,13 @@ sppp_flush(struct ifnet *ifp)
int
sppp_isempty(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
int empty, s;
s = splimp();
SPPP_LOCK(sp);
empty = !sp->pp_fastq.ifq_head && !sp->pp_cpq.ifq_head &&
- !sp->pp_if.if_snd.ifq_head;
+ !SP2IFP(sp)->if_snd.ifq_head;
SPPP_UNLOCK(sp);
splx(s);
return (empty);
@@ -1162,7 +1189,7 @@ sppp_isempty(struct ifnet *ifp)
struct mbuf *
sppp_dequeue(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
struct mbuf *m;
int s;
@@ -1180,7 +1207,7 @@ sppp_dequeue(struct ifnet *ifp)
sp->pp_mode == PP_FR)) {
IF_DEQUEUE(&sp->pp_fastq, m);
if (m == NULL)
- IF_DEQUEUE (&sp->pp_if.if_snd, m);
+ IF_DEQUEUE (&SP2IFP(sp)->if_snd, m);
}
SPPP_UNLOCK(sp);
splx(s);
@@ -1193,7 +1220,7 @@ sppp_dequeue(struct ifnet *ifp)
struct mbuf *
sppp_pick(struct ifnet *ifp)
{
- struct sppp *sp = (struct sppp*)ifp;
+ struct sppp *sp = IFP2SP(ifp);
struct mbuf *m;
int s;
@@ -1206,7 +1233,7 @@ sppp_pick(struct ifnet *ifp)
sp->pp_mode == IFF_CISCO ||
sp->pp_mode == PP_FR))
if ((m = sp->pp_fastq.ifq_head) == NULL)
- m = sp->pp_if.if_snd.ifq_head;
+ m = SP2IFP(sp)->if_snd.ifq_head;
SPPP_UNLOCK(sp);
splx (s);
return (m);
@@ -1219,7 +1246,7 @@ int
sppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data)
{
struct ifreq *ifr = (struct ifreq*) data;
- struct sppp *sp = (struct sppp*) ifp;
+ struct sppp *sp = IFP2SP(ifp);
int s, rv, going_up, going_down, newmode;
s = splimp();
@@ -2207,7 +2234,7 @@ sppp_lcp_init(struct sppp *sp)
sp->lcp.max_configure = 10;
sp->lcp.max_failure = 10;
callout_init(&sp->ch[IDX_LCP],
- (sp->pp_if.if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
+ (SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
}
static void
@@ -2902,7 +2929,7 @@ sppp_ipcp_init(struct sppp *sp)
sp->pp_seq[IDX_IPCP] = 0;
sp->pp_rseq[IDX_IPCP] = 0;
callout_init(&sp->ch[IDX_IPCP],
- (sp->pp_if.if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
+ (SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
}
static void
@@ -2985,7 +3012,7 @@ static int
sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len)
{
u_char *buf, *r, *p;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG;
u_long hisaddr, desiredaddr;
int gotmyaddr = 0;
@@ -3193,7 +3220,7 @@ static void
sppp_ipcp_RCN_rej(struct sppp *sp, struct lcp_header *h, int len)
{
u_char *buf, *p;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int debug = ifp->if_flags & IFF_DEBUG;
len -= 4;
@@ -3237,7 +3264,7 @@ static void
sppp_ipcp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len)
{
u_char *buf, *p;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int debug = ifp->if_flags & IFF_DEBUG;
int desiredcomp;
u_long wantaddr;
@@ -3386,7 +3413,7 @@ sppp_ipv6cp_init(struct sppp *sp)
sp->pp_seq[IDX_IPV6CP] = 0;
sp->pp_rseq[IDX_IPV6CP] = 0;
callout_init(&sp->ch[IDX_IPV6CP],
- (sp->pp_if.if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
+ (SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
}
static void
@@ -3455,7 +3482,7 @@ static int
sppp_ipv6cp_RCR(struct sppp *sp, struct lcp_header *h, int len)
{
u_char *buf, *r, *p;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG;
struct in6_addr myaddr, desiredaddr, suggestaddr;
int ifidcount;
@@ -3544,7 +3571,7 @@ sppp_ipv6cp_RCR(struct sppp *sp, struct lcp_header *h, int len)
nohisaddr = IN6_IS_ADDR_UNSPECIFIED(&desiredaddr);
desiredaddr.s6_addr16[0] = htons(0xfe80);
- desiredaddr.s6_addr16[1] = htons(sp->pp_if.if_index);
+ desiredaddr.s6_addr16[1] = htons(SP2IFP(sp)->if_index);
if (!collision && !nohisaddr) {
/* no collision, hisaddr known - Conf-Ack */
@@ -3614,7 +3641,7 @@ static void
sppp_ipv6cp_RCN_rej(struct sppp *sp, struct lcp_header *h, int len)
{
u_char *buf, *p;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int debug = ifp->if_flags & IFF_DEBUG;
len -= 4;
@@ -3659,7 +3686,7 @@ static void
sppp_ipv6cp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len)
{
u_char *buf, *p;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int debug = ifp->if_flags & IFF_DEBUG;
struct in6_addr suggestaddr;
@@ -3687,7 +3714,7 @@ sppp_ipv6cp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len)
break;
bzero(&suggestaddr, sizeof(suggestaddr));
suggestaddr.s6_addr16[0] = htons(0xfe80);
- suggestaddr.s6_addr16[1] = htons(sp->pp_if.if_index);
+ suggestaddr.s6_addr16[1] = htons(SP2IFP(sp)->if_index);
bcopy(&p[2], &suggestaddr.s6_addr[8], 8);
sp->ipv6cp.opts |= (1 << IPV6CP_OPT_IFID);
@@ -4187,7 +4214,7 @@ sppp_chap_init(struct sppp *sp)
sp->pp_seq[IDX_CHAP] = 0;
sp->pp_rseq[IDX_CHAP] = 0;
callout_init(&sp->ch[IDX_CHAP],
- (sp->pp_if.if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
+ (SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
}
static void
@@ -4527,9 +4554,9 @@ sppp_pap_init(struct sppp *sp)
sp->pp_seq[IDX_PAP] = 0;
sp->pp_rseq[IDX_PAP] = 0;
callout_init(&sp->ch[IDX_PAP],
- (sp->pp_if.if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
+ (SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
callout_init(&sp->pap_my_to_ch,
- (sp->pp_if.if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
+ (SP2IFP(sp)->if_flags & IFF_NEEDSGIANT) ? 0 : CALLOUT_MPSAFE);
}
static void
@@ -4781,7 +4808,7 @@ static void
sppp_keepalive(void *dummy)
{
struct sppp *sp = (struct sppp*)dummy;
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
int s;
s = splimp();
@@ -4838,7 +4865,7 @@ out:
void
sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask)
{
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
struct ifaddr *ifa;
struct sockaddr_in *si, *sm;
u_long ssrc, ddst;
@@ -4966,7 +4993,7 @@ static void
sppp_get_ip6_addrs(struct sppp *sp, struct in6_addr *src, struct in6_addr *dst,
struct in6_addr *srcmask)
{
- struct ifnet *ifp = &sp->pp_if;
+ struct ifnet *ifp = SP2IFP(sp);
struct ifaddr *ifa;
struct sockaddr_in6 *si, *sm;
struct in6_addr ssrc, ddst;
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 6c9c468..072c505 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -131,7 +131,7 @@
#define GET_V4(x) ((caddr_t)(&(x)->s6_addr16[1]))
struct stf_softc {
- struct ifnet sc_if; /* common area */
+ struct ifnet *sc_ifp;
union {
struct route __sc_ro4;
struct route_in6 __sc_ro6; /* just for safety */
@@ -140,6 +140,7 @@ struct stf_softc {
const struct encaptab *encap_cookie;
LIST_ENTRY(stf_softc) sc_list; /* all stf's are linked */
};
+#define STF2IFP(sc) ((sc)->sc_ifp)
/*
* All mutable global variables in if_stf.c are protected by stf_mtx.
@@ -214,7 +215,12 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len)
return (err);
sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO);
- ifp = &sc->sc_if;
+ ifp = sc->sc_ifp = if_alloc(IFT_STF);
+ if (ifp == NULL) {
+ free(sc, M_STF);
+ ifc_free_unit(ifc, unit);
+ return (ENOSPC);
+ }
/*
* Set the name manually rather then using if_initname because
* we don't conform to the default naming convention for interfaces.
@@ -235,7 +241,6 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len)
ifp->if_mtu = IPV6_MMTU;
ifp->if_ioctl = stf_ioctl;
ifp->if_output = stf_output;
- ifp->if_type = IFT_STF;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
if_attach(ifp);
bpfattach(ifp, DLT_NULL, sizeof(u_int));
@@ -252,8 +257,9 @@ stf_destroy(struct stf_softc *sc)
err = encap_detach(sc->encap_cookie);
KASSERT(err == 0, ("Unexpected error detaching encap_cookie"));
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ bpfdetach(STF2IFP(sc));
+ if_detach(STF2IFP(sc));
+ if_free(STF2IFP(sc));
free(sc, M_STF);
}
@@ -261,7 +267,7 @@ stf_destroy(struct stf_softc *sc)
static int
stf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
{
- struct stf_softc *sc = (void *) ifp;
+ struct stf_softc *sc = ifp->if_softc;
mtx_lock(&stf_mtx);
LIST_REMOVE(sc, sc_list);
@@ -332,11 +338,11 @@ stf_encapcheck(m, off, proto, arg)
if (sc == NULL)
return 0;
- if ((sc->sc_if.if_flags & IFF_UP) == 0)
+ if ((STF2IFP(sc)->if_flags & IFF_UP) == 0)
return 0;
/* IFF_LINK0 means "no decapsulation" */
- if ((sc->sc_if.if_flags & IFF_LINK0) != 0)
+ if ((STF2IFP(sc)->if_flags & IFF_LINK0) != 0)
return 0;
if (proto != IPPROTO_IPV6)
@@ -348,7 +354,7 @@ stf_encapcheck(m, off, proto, arg)
if (ip.ip_v != 4)
return 0;
- ia6 = stf_getsrcifa6(&sc->sc_if);
+ ia6 = stf_getsrcifa6(STF2IFP(sc));
if (ia6 == NULL)
return 0;
@@ -440,7 +446,7 @@ stf_output(ifp, m, dst, rt)
}
#endif
- sc = (struct stf_softc*)ifp;
+ sc = ifp->if_softc;
dst6 = (struct sockaddr_in6 *)dst;
/* just in case */
@@ -609,7 +615,7 @@ stf_checkaddr4(sc, in, inifp)
/*
* perform ingress filter
*/
- if (sc && (sc->sc_if.if_flags & IFF_LINK2) == 0 && inifp) {
+ if (sc && (STF2IFP(sc)->if_flags & IFF_LINK2) == 0 && inifp) {
struct sockaddr_in sin;
struct rtentry *rt;
@@ -621,7 +627,7 @@ stf_checkaddr4(sc, in, inifp)
if (!rt || rt->rt_ifp != inifp) {
#if 0
log(LOG_WARNING, "%s: packet from 0x%x dropped "
- "due to ingress filter\n", if_name(&sc->sc_if),
+ "due to ingress filter\n", if_name(STF2IFP(sc)),
(u_int32_t)ntohl(sin.sin_addr.s_addr));
#endif
if (rt)
@@ -684,12 +690,12 @@ in_stf_input(m, off)
sc = (struct stf_softc *)encap_getarg(m);
- if (sc == NULL || (sc->sc_if.if_flags & IFF_UP) == 0) {
+ if (sc == NULL || (STF2IFP(sc)->if_flags & IFF_UP) == 0) {
m_freem(m);
return;
}
- ifp = &sc->sc_if;
+ ifp = STF2IFP(sc);
#ifdef MAC
mac_create_mbuf_from_ifnet(ifp, m);
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index dc76f44..f6ee9b0 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -62,6 +62,7 @@
#include <net/if.h>
#include <net/if_arp.h>
#include <net/route.h>
+#include <net/if_types.h>
#include <netinet/in.h>
@@ -191,7 +192,7 @@ tapmodevent(mod, type, data)
SLIST_REMOVE_HEAD(&taphead, tap_next);
mtx_unlock(&tapmtx);
- ifp = &tp->tap_if;
+ ifp = tp->tap_ifp;
TAPDEBUG("detaching %s\n", ifp->if_xname);
@@ -202,6 +203,7 @@ tapmodevent(mod, type, data)
destroy_dev(tp->tap_dev);
s = splimp();
ether_ifdetach(ifp);
+ if_free_type(ifp, IFT_ETHER);
splx(s);
mtx_destroy(&tp->tap_mtx);
@@ -284,6 +286,7 @@ tapcreate(dev)
unsigned short macaddr_hi;
int unit, s;
char *name = NULL;
+ u_char eaddr[6];
dev->si_flags &= ~SI_CHEAPCLONE;
@@ -309,12 +312,14 @@ tapcreate(dev)
/* generate fake MAC address: 00 bd xx xx xx unit_no */
macaddr_hi = htons(0x00bd);
- bcopy(&macaddr_hi, &tp->arpcom.ac_enaddr[0], sizeof(short));
- bcopy(&ticks, &tp->arpcom.ac_enaddr[2], sizeof(long));
- tp->arpcom.ac_enaddr[5] = (u_char)unit;
+ bcopy(&macaddr_hi, eaddr, sizeof(short));
+ bcopy(&ticks, &eaddr[2], sizeof(long));
+ eaddr[5] = (u_char)unit;
/* fill the rest and attach interface */
- ifp = &tp->tap_if;
+ ifp = tp->tap_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ panic("%s%d: can not if_alloc()", name, unit);
ifp->if_softc = tp;
if_initname(ifp, name, unit);
ifp->if_init = tapifinit;
@@ -328,7 +333,7 @@ tapcreate(dev)
tp->tap_dev = dev;
s = splimp();
- ether_ifattach(ifp, tp->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
splx(s);
mtx_lock(&tp->tap_mtx);
@@ -379,10 +384,10 @@ tapopen(dev, flag, mode, td)
return (EBUSY);
}
- bcopy(tp->arpcom.ac_enaddr, tp->ether_addr, sizeof(tp->ether_addr));
+ bcopy(IFP2ENADDR(tp->tap_ifp), tp->ether_addr, sizeof(tp->ether_addr));
tp->tap_pid = td->td_proc->p_pid;
tp->tap_flags |= TAP_OPEN;
- ifp = &tp->tap_if;
+ ifp = tp->tap_ifp;
mtx_unlock(&tp->tap_mtx);
s = splimp();
@@ -410,7 +415,7 @@ tapclose(dev, foo, bar, td)
{
struct ifaddr *ifa;
struct tap_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tap_if;
+ struct ifnet *ifp = tp->tap_ifp;
int s;
/* junk all pending output */
@@ -462,7 +467,7 @@ tapifinit(xtp)
void *xtp;
{
struct tap_softc *tp = (struct tap_softc *)xtp;
- struct ifnet *ifp = &tp->tap_if;
+ struct ifnet *ifp = tp->tap_ifp;
TAPDEBUG("initializing %s\n", ifp->if_xname);
@@ -601,7 +606,7 @@ tapioctl(dev, cmd, data, flag, td)
struct thread *td;
{
struct tap_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tap_if;
+ struct ifnet *ifp = tp->tap_ifp;
struct tapinfo *tapp = NULL;
int s;
int f;
@@ -723,7 +728,7 @@ tapread(dev, uio, flag)
int flag;
{
struct tap_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tap_if;
+ struct ifnet *ifp = tp->tap_ifp;
struct mbuf *m = NULL;
int error = 0, len, s;
@@ -797,7 +802,7 @@ tapwrite(dev, uio, flag)
int flag;
{
struct tap_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tap_if;
+ struct ifnet *ifp = tp->tap_ifp;
struct mbuf *m;
int error = 0;
@@ -843,7 +848,7 @@ tappoll(dev, events, td)
struct thread *td;
{
struct tap_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tap_if;
+ struct ifnet *ifp = tp->tap_ifp;
int s, revents = 0;
TAPDEBUG("%s polling, minor = %#x\n",
diff --git a/sys/net/if_tapvar.h b/sys/net/if_tapvar.h
index 1017bae..21bac50 100644
--- a/sys/net/if_tapvar.h
+++ b/sys/net/if_tapvar.h
@@ -46,8 +46,7 @@
* Other fields locked by owning subsystems.
*/
struct tap_softc {
- struct arpcom arpcom; /* ethernet common data */
-#define tap_if arpcom.ac_if
+ struct ifnet *tap_ifp;
u_short tap_flags; /* misc flags */
#define TAP_OPEN (1 << 0)
#define TAP_INITED (1 << 1)
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index cd209cb..310ff49 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -85,11 +85,12 @@ struct tun_softc {
* being slightly stale informationally.
*/
pid_t tun_pid; /* owning pid */
- struct ifnet tun_if; /* the interface */
+ struct ifnet *tun_ifp; /* the interface */
struct sigio *tun_sigio; /* information for async I/O */
struct selinfo tun_rsel; /* read select */
struct mtx tun_mtx; /* protect mutable softc fields */
};
+#define TUN2IFP(sc) ((sc)->tun_ifp)
#define TUNDEBUG if (tundebug) if_printf
#define TUNNAME "tun"
@@ -169,11 +170,12 @@ tun_destroy(struct tun_softc *tp)
/* Unlocked read. */
KASSERT((tp->tun_flags & TUN_OPEN) == 0,
- ("tununits is out of sync - unit %d", tp->tun_if.if_dunit));
+ ("tununits is out of sync - unit %d", TUN2IFP(tp)->if_dunit));
dev = tp->tun_dev;
- bpfdetach(&tp->tun_if);
- if_detach(&tp->tun_if);
+ bpfdetach(TUN2IFP(tp));
+ if_detach(TUN2IFP(tp));
+ if_free(TUN2IFP(tp));
destroy_dev(dev);
mtx_destroy(&tp->tun_mtx);
free(tp, M_TUN);
@@ -250,6 +252,7 @@ tunstart(struct ifnet *ifp)
selwakeuppri(&tp->tun_rsel, PZERO + 1);
}
+/* XXX: should return an error code so it can fail. */
static void
tuncreate(struct cdev *dev)
{
@@ -266,14 +269,16 @@ tuncreate(struct cdev *dev)
TAILQ_INSERT_TAIL(&tunhead, sc, tun_list);
mtx_unlock(&tunmtx);
- ifp = &sc->tun_if;
+ ifp = sc->tun_ifp = if_alloc(IFT_PPP);
+ if (ifp == NULL)
+ panic("%s%d: failed to if_alloc() interface.\n",
+ TUNNAME, dev2unit(dev));
if_initname(ifp, TUNNAME, dev2unit(dev));
ifp->if_mtu = TUNMTU;
ifp->if_ioctl = tunifioctl;
ifp->if_output = tunoutput;
ifp->if_start = tunstart;
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- ifp->if_type = IFT_PPP;
ifp->if_softc = sc;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = 0;
@@ -315,7 +320,7 @@ tunopen(struct cdev *dev, int flag, int mode, struct thread *td)
tp->tun_flags |= TUN_OPEN;
mtx_unlock(&tp->tun_mtx);
- ifp = &tp->tun_if;
+ ifp = TUN2IFP(tp);
TUNDEBUG(ifp, "open\n");
return (0);
@@ -333,7 +338,7 @@ tunclose(struct cdev *dev, int foo, int bar, struct thread *td)
int s;
tp = dev->si_drv1;
- ifp = &tp->tun_if;
+ ifp = TUN2IFP(tp);
mtx_lock(&tp->tun_mtx);
tp->tun_flags &= ~TUN_OPEN;
@@ -568,18 +573,18 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
tunp = (struct tuninfo *)data;
if (tunp->mtu < IF_MINMTU)
return (EINVAL);
- if (tp->tun_if.if_mtu != tunp->mtu
+ if (TUN2IFP(tp)->if_mtu != tunp->mtu
&& (error = suser(td)) != 0)
return (error);
- tp->tun_if.if_mtu = tunp->mtu;
- tp->tun_if.if_type = tunp->type;
- tp->tun_if.if_baudrate = tunp->baudrate;
+ TUN2IFP(tp)->if_mtu = tunp->mtu;
+ TUN2IFP(tp)->if_type = tunp->type;
+ TUN2IFP(tp)->if_baudrate = tunp->baudrate;
break;
case TUNGIFINFO:
tunp = (struct tuninfo *)data;
- tunp->mtu = tp->tun_if.if_mtu;
- tunp->type = tp->tun_if.if_type;
- tunp->baudrate = tp->tun_if.if_baudrate;
+ tunp->mtu = TUN2IFP(tp)->if_mtu;
+ tunp->type = TUN2IFP(tp)->if_type;
+ tunp->baudrate = TUN2IFP(tp)->if_baudrate;
break;
case TUNSDEBUG:
tundebug = *(int *)data;
@@ -613,15 +618,15 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
break;
case TUNSIFMODE:
/* deny this if UP */
- if (tp->tun_if.if_flags & IFF_UP)
+ if (TUN2IFP(tp)->if_flags & IFF_UP)
return(EBUSY);
switch (*(int *)data & ~IFF_MULTICAST) {
case IFF_POINTOPOINT:
case IFF_BROADCAST:
- tp->tun_if.if_flags &=
+ TUN2IFP(tp)->if_flags &=
~(IFF_BROADCAST|IFF_POINTOPOINT|IFF_MULTICAST);
- tp->tun_if.if_flags |= *(int *)data;
+ TUN2IFP(tp)->if_flags |= *(int *)data;
break;
default:
return(EINVAL);
@@ -644,13 +649,13 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
break;
case FIONREAD:
s = splimp();
- if (!IFQ_IS_EMPTY(&tp->tun_if.if_snd)) {
+ if (!IFQ_IS_EMPTY(&TUN2IFP(tp)->if_snd)) {
struct mbuf *mb;
- IFQ_LOCK(&tp->tun_if.if_snd);
- IFQ_POLL_NOLOCK(&tp->tun_if.if_snd, mb);
+ IFQ_LOCK(&TUN2IFP(tp)->if_snd);
+ IFQ_POLL_NOLOCK(&TUN2IFP(tp)->if_snd, mb);
for( *(int *)data = 0; mb != 0; mb = mb->m_next)
*(int *)data += mb->m_len;
- IFQ_UNLOCK(&tp->tun_if.if_snd);
+ IFQ_UNLOCK(&TUN2IFP(tp)->if_snd);
} else
*(int *)data = 0;
splx(s);
@@ -685,7 +690,7 @@ static int
tunread(struct cdev *dev, struct uio *uio, int flag)
{
struct tun_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tun_if;
+ struct ifnet *ifp = TUN2IFP(tp);
struct mbuf *m;
int error=0, len, s;
@@ -741,7 +746,7 @@ static int
tunwrite(struct cdev *dev, struct uio *uio, int flag)
{
struct tun_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tun_if;
+ struct ifnet *ifp = TUN2IFP(tp);
struct mbuf *m;
int error = 0;
uint32_t family;
@@ -831,7 +836,7 @@ tunpoll(struct cdev *dev, int events, struct thread *td)
{
int s;
struct tun_softc *tp = dev->si_drv1;
- struct ifnet *ifp = &tp->tun_if;
+ struct ifnet *ifp = TUN2IFP(tp);
int revents = 0;
struct mbuf *m;
diff --git a/sys/net/if_types.h b/sys/net/if_types.h
index 1dff5c2..2d25b69 100644
--- a/sys/net/if_types.h
+++ b/sys/net/if_types.h
@@ -249,4 +249,5 @@
#define IFT_PFLOG 0xf6
#define IFT_PFSYNC 0xf7
#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */
+#define IFT_IPXIP 0xf9
#endif /* !_NET_IF_TYPES_H_ */
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index b189a70..4b0f421 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -109,27 +109,9 @@ struct ifqueue {
* (Would like to call this struct ``if'', but C isn't PL/1.)
*/
-/*
- * NB: For FreeBSD, it is assumed that each NIC driver's softc starts with
- * one of these structures, typically held within an arpcom structure.
- *
- * struct <foo>_softc {
- * struct arpcom {
- * struct ifnet ac_if;
- * ...
- * } <arpcom> ;
- * ...
- * };
- *
- * The assumption is used in a number of places, including many
- * files in sys/net, device drivers, and sys/dev/mii.c:miibus_attach().
- *
- * Unfortunately devices' softc are opaque, so we depend on this layout
- * to locate the struct ifnet from the softc in the generic code.
- *
- */
struct ifnet {
void *if_softc; /* pointer to driver state */
+ void *if_l2com; /* pointer to protocol bits */
TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */
char if_xname[IFNAMSIZ]; /* external name (name + unit) */
const char *if_dname; /* driver name */
@@ -628,11 +610,14 @@ extern int if_index;
int if_addmulti(struct ifnet *, struct sockaddr *, struct ifmultiaddr **);
int if_allmulti(struct ifnet *, int);
+struct ifnet* if_alloc(u_char);
void if_attach(struct ifnet *);
int if_delmulti(struct ifnet *, struct sockaddr *);
void if_detach(struct ifnet *);
void if_purgeaddrs(struct ifnet *);
void if_down(struct ifnet *);
+void if_free(struct ifnet *);
+void if_free_type(struct ifnet *, u_char);
void if_initname(struct ifnet *, const char *, int);
void if_link_state_change(struct ifnet *, int);
int if_printf(struct ifnet *, const char *, ...) __printflike(2, 3);
@@ -652,6 +637,11 @@ struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *);
struct ifmultiaddr *ifmaof_ifpforaddr(struct sockaddr *, struct ifnet *);
int if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen);
+typedef void *if_com_alloc_t(u_char type, struct ifnet *ifp);
+typedef void if_com_free_t(void *com, u_char type);
+void if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f);
+void if_deregister_com_alloc(u_char type);
+
#define IF_LLADDR(ifp) \
LLADDR((struct sockaddr_dl *) ifaddr_byindex((ifp)->if_index)->ifa_addr)
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 77cc178..f909dbe 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -76,7 +76,7 @@ struct vlan_mc_entry {
};
struct ifvlan {
- struct arpcom ifv_ac; /* make this an interface */
+ struct ifnet *ifv_ifp;
struct ifnet *ifv_p; /* parent inteface of this vlan */
struct ifv_linkmib {
int ifvm_parent;
@@ -90,7 +90,6 @@ struct ifvlan {
LIST_ENTRY(ifvlan) ifv_list;
int ifv_flags;
};
-#define ifv_if ifv_ac.ac_if
#define ifv_tag ifv_mib.ifvm_tag
#define ifv_encaplen ifv_mib.ifvm_encaplen
#define ifv_mtufudge ifv_mib.ifvm_mtufudge
@@ -244,7 +243,7 @@ vlan_modevent(module_t mod, int type, void *data)
vlan_link_state_p = NULL;
while (!LIST_EMPTY(&ifv_list))
vlan_clone_destroy(&vlan_cloner,
- &LIST_FIRST(&ifv_list)->ifv_if);
+ LIST_FIRST(&ifv_list)->ifv_ifp);
VLAN_LOCK_DESTROY();
break;
default:
@@ -323,6 +322,7 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len)
struct ifvlan *ifv;
struct ifnet *ifp;
struct ifnet *p;
+ u_char eaddr[6] = {0,0,0,0,0,0};
if ((p = vlan_clone_match_ethertag(ifc, name, &tag)) != NULL) {
ethertag = 1;
@@ -359,7 +359,12 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len)
}
ifv = malloc(sizeof(struct ifvlan), M_VLAN, M_WAITOK | M_ZERO);
- ifp = &ifv->ifv_if;
+ ifp = ifv->ifv_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ ifc_free_unit(ifc, unit);
+ free(ifv, M_VLAN);
+ return (ENOSPC);
+ }
SLIST_INIT(&ifv->vlan_mc_listhead);
ifp->if_softc = ifv;
@@ -379,7 +384,7 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len)
ifp->if_start = vlan_start;
ifp->if_ioctl = vlan_ioctl;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
- ether_ifattach(ifp, ifv->ifv_ac.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* Now undo some of the damage... */
ifp->if_baudrate = 0;
ifp->if_type = IFT_L2VLAN;
@@ -402,6 +407,7 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len)
vlan_unconfig(ifp);
VLAN_UNLOCK();
ether_ifdetach(ifp);
+ if_free_type(ifp, IFT_ETHER);
free(ifv, M_VLAN);
return (error);
@@ -431,6 +437,7 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
VLAN_UNLOCK();
ether_ifdetach(ifp);
+ if_free(ifp);
free(ifv, M_VLAN);
@@ -600,7 +607,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
if (ifp == ifv->ifv_p && tag == ifv->ifv_tag)
break;
- if (ifv == NULL || (ifv->ifv_if.if_flags & IFF_UP) == 0) {
+ if (ifv == NULL || (ifv->ifv_ifp->if_flags & IFF_UP) == 0) {
VLAN_UNLOCK();
m_freem(m);
ifp->if_noproto++;
@@ -626,11 +633,11 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
m_adj(m, ETHER_VLAN_ENCAP_LEN);
}
- m->m_pkthdr.rcvif = &ifv->ifv_if;
- ifv->ifv_if.if_ipackets++;
+ m->m_pkthdr.rcvif = ifv->ifv_ifp;
+ ifv->ifv_ifp->if_ipackets++;
/* Pass it back through the parent's input routine. */
- (*ifp->if_input)(&ifv->ifv_if, m);
+ (*ifp->if_input)(ifv->ifv_ifp, m);
}
static int
@@ -680,14 +687,14 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p)
}
ifv->ifv_p = p;
- ifv->ifv_if.if_mtu = p->if_mtu - ifv->ifv_mtufudge;
+ ifv->ifv_ifp->if_mtu = p->if_mtu - ifv->ifv_mtufudge;
/*
* Copy only a selected subset of flags from the parent.
* Other flags are none of our business.
*/
- ifv->ifv_if.if_flags = (p->if_flags &
+ ifv->ifv_ifp->if_flags = (p->if_flags &
(IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX | IFF_POINTOPOINT));
- ifv->ifv_if.if_link_state = p->if_link_state;
+ ifv->ifv_ifp->if_link_state = p->if_link_state;
#if 0
/*
@@ -701,27 +708,27 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p)
* assisted checksumming flags.
*/
if (p->if_capabilities & IFCAP_VLAN_HWTAGGING)
- ifv->ifv_if.if_capabilities |= p->if_capabilities & IFCAP_HWCSUM;
+ ifv->ifv_ifpif_capabilities |= p->if_capabilities & IFCAP_HWCSUM;
#endif
/*
* Set up our ``Ethernet address'' to reflect the underlying
* physical interface's.
*/
- ifa1 = ifaddr_byindex(ifv->ifv_if.if_index);
+ ifa1 = ifaddr_byindex(ifv->ifv_ifp->if_index);
ifa2 = ifaddr_byindex(p->if_index);
sdl1 = (struct sockaddr_dl *)ifa1->ifa_addr;
sdl2 = (struct sockaddr_dl *)ifa2->ifa_addr;
sdl1->sdl_type = IFT_ETHER;
sdl1->sdl_alen = ETHER_ADDR_LEN;
bcopy(LLADDR(sdl2), LLADDR(sdl1), ETHER_ADDR_LEN);
- bcopy(LLADDR(sdl2), ifv->ifv_ac.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(LLADDR(sdl2), IFP2ENADDR(ifv->ifv_ifp), ETHER_ADDR_LEN);
/*
* Configure multicast addresses that may already be
* joined on the vlan device.
*/
- (void)vlan_setmulti(&ifv->ifv_if); /* XXX: VLAN lock held */
+ (void)vlan_setmulti(ifv->ifv_ifp); /* XXX: VLAN lock held */
return (0);
}
@@ -772,17 +779,17 @@ vlan_unconfig(struct ifnet *ifp)
/* Disconnect from parent. */
ifv->ifv_p = NULL;
- ifv->ifv_if.if_mtu = ETHERMTU; /* XXX why not 0? */
+ ifv->ifv_ifp->if_mtu = ETHERMTU; /* XXX why not 0? */
ifv->ifv_flags = 0;
- ifv->ifv_if.if_link_state = LINK_STATE_UNKNOWN;
+ ifv->ifv_ifp->if_link_state = LINK_STATE_UNKNOWN;
/* Clear our MAC address. */
- ifa = ifaddr_byindex(ifv->ifv_if.if_index);
+ ifa = ifaddr_byindex(ifv->ifv_ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
sdl->sdl_type = IFT_ETHER;
sdl->sdl_alen = ETHER_ADDR_LEN;
bzero(LLADDR(sdl), ETHER_ADDR_LEN);
- bzero(ifv->ifv_ac.ac_enaddr, ETHER_ADDR_LEN);
+ bzero(IFP2ENADDR(ifv->ifv_ifp), ETHER_ADDR_LEN);
return (0);
}
@@ -819,7 +826,7 @@ vlan_link_state(struct ifnet *ifp, int link)
VLAN_LOCK();
LIST_FOREACH(ifv, &ifv_list, ifv_list) {
if (ifv->ifv_p == ifp)
- if_link_state_change(&ifv->ifv_if,
+ if_link_state_change(ifv->ifv_ifp,
ifv->ifv_p->if_link_state);
}
VLAN_UNLOCK();
@@ -846,7 +853,7 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- arp_ifinit(&ifv->ifv_if, ifa);
+ arp_ifinit(ifv->ifv_ifp, ifa);
break;
#endif
default:
@@ -859,7 +866,7 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
struct sockaddr *sa;
sa = (struct sockaddr *) &ifr->ifr_data;
- bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)sa->sa_data,
+ bcopy(IFP2ENADDR(ifp), (caddr_t)sa->sa_data,
ETHER_ADDR_LEN);
}
break;
diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c
index 3c25bab..38647f2 100644
--- a/sys/net/ppp_tty.c
+++ b/sys/net/ppp_tty.c
@@ -207,9 +207,9 @@ pppopen(dev, tp)
sc->sc_setmtu = pppasyncsetmtu;
sc->sc_outm = NULL;
pppgetm(sc);
- sc->sc_if.if_flags |= IFF_RUNNING;
- getmicrotime(&sc->sc_if.if_lastchange);
- sc->sc_if.if_baudrate = tp->t_ospeed;
+ PPP2IFP(sc)->if_flags |= IFF_RUNNING;
+ getmicrotime(&PPP2IFP(sc)->if_lastchange);
+ PPP2IFP(sc)->if_baudrate = tp->t_ospeed;
tp->t_hotchar = PPP_FLAG;
ttyflush(tp, FREAD | FWRITE);
@@ -220,8 +220,8 @@ pppopen(dev, tp)
* We also pass 1 byte tokens through t_canq...
*/
clist_alloc_cblocks(&tp->t_canq, 1, 1);
- clist_alloc_cblocks(&tp->t_outq, sc->sc_if.if_mtu + PPP_HIWAT,
- sc->sc_if.if_mtu + PPP_HIWAT);
+ clist_alloc_cblocks(&tp->t_outq, PPP2IFP(sc)->if_mtu + PPP_HIWAT,
+ PPP2IFP(sc)->if_mtu + PPP_HIWAT);
clist_alloc_cblocks(&tp->t_rawq, 0, 0);
splx(s);
@@ -293,8 +293,8 @@ register struct ppp_softc *sc;
s = spltty();
if (tp != NULL)
- clist_alloc_cblocks(&tp->t_outq, sc->sc_if.if_mtu + PPP_HIWAT,
- sc->sc_if.if_mtu + PPP_HIWAT);
+ clist_alloc_cblocks(&tp->t_outq, PPP2IFP(sc)->if_mtu + PPP_HIWAT,
+ PPP2IFP(sc)->if_mtu + PPP_HIWAT);
splx(s);
}
@@ -379,7 +379,7 @@ pppwrite(tp, uio, flag)
return (EINVAL);
if (sc == NULL)
return EIO;
- if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HDRLEN ||
+ if (uio->uio_resid > PPP2IFP(sc)->if_mtu + PPP_HDRLEN ||
uio->uio_resid < PPP_HDRLEN)
return (EMSGSIZE);
@@ -410,7 +410,7 @@ pppwrite(tp, uio, flag)
m0->m_len -= PPP_HDRLEN;
/* call the upper layer to "transmit" it... */
- error = pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0);
+ error = pppoutput(PPP2IFP(sc), m0, &dst, (struct rtentry *)0);
splx(s);
return (error);
}
@@ -576,7 +576,7 @@ pppasyncstart(sc)
/* Calculate the FCS for the first mbuf's worth. */
sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
- getmicrotime(&sc->sc_if.if_lastchange);
+ getmicrotime(&PPP2IFP(sc)->if_lastchange);
}
for (;;) {
@@ -839,14 +839,14 @@ pppinput(c, tp)
if ((tp->t_state & TS_CONNECTED) == 0) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "no carrier\n");
+ if_printf(PPP2IFP(sc), "no carrier\n");
goto flush;
}
if (c & TTY_ERRORMASK) {
/* framing error or overrun on this char - abort packet */
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "line error %x\n", c & TTY_ERRORMASK);
+ if_printf(PPP2IFP(sc), "line error %x\n", c & TTY_ERRORMASK);
goto flush;
}
@@ -902,9 +902,9 @@ pppinput(c, tp)
sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "bad fcs %x, pkt len %d\n",
+ if_printf(PPP2IFP(sc), "bad fcs %x, pkt len %d\n",
sc->sc_fcs, ilen);
- sc->sc_if.if_ierrors++;
+ PPP2IFP(sc)->if_ierrors++;
sc->sc_stats.ppp_ierrors++;
} else
sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
@@ -915,9 +915,9 @@ pppinput(c, tp)
if (ilen < PPP_HDRLEN + PPP_FCSLEN) {
if (ilen) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "too short (%d)\n", ilen);
+ if_printf(PPP2IFP(sc), "too short (%d)\n", ilen);
s = spltty();
- sc->sc_if.if_ierrors++;
+ PPP2IFP(sc)->if_ierrors++;
sc->sc_stats.ppp_ierrors++;
sc->sc_flags |= SC_PKTLOST;
splx(s);
@@ -987,7 +987,7 @@ pppinput(c, tp)
pppgetm(sc);
if (sc->sc_m == NULL) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "no input mbufs!\n");
+ if_printf(PPP2IFP(sc), "no input mbufs!\n");
goto flush;
}
}
@@ -1000,7 +1000,7 @@ pppinput(c, tp)
if (c != PPP_ALLSTATIONS) {
if (sc->sc_flags & SC_REJ_COMP_AC) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if,
+ if_printf(PPP2IFP(sc),
"garbage received: 0x%x (need 0xFF)\n", c);
goto flush;
}
@@ -1012,7 +1012,7 @@ pppinput(c, tp)
}
if (sc->sc_ilen == 1 && c != PPP_UI) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "missing UI (0x3), got 0x%x\n", c);
+ if_printf(PPP2IFP(sc), "missing UI (0x3), got 0x%x\n", c);
goto flush;
}
if (sc->sc_ilen == 2 && (c & 1) == 1) {
@@ -1023,7 +1023,7 @@ pppinput(c, tp)
}
if (sc->sc_ilen == 3 && (c & 1) == 0) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "bad protocol %x\n",
+ if_printf(PPP2IFP(sc), "bad protocol %x\n",
(sc->sc_mp[-1] << 8) + c);
goto flush;
}
@@ -1031,7 +1031,7 @@ pppinput(c, tp)
/* packet beyond configured mru? */
if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "packet too big\n");
+ if_printf(PPP2IFP(sc), "packet too big\n");
goto flush;
}
@@ -1042,7 +1042,7 @@ pppinput(c, tp)
pppgetm(sc);
if (m->m_next == NULL) {
if (sc->sc_flags & SC_DEBUG)
- if_printf(&sc->sc_if, "too few input mbufs!\n");
+ if_printf(PPP2IFP(sc), "too few input mbufs!\n");
goto flush;
}
}
@@ -1060,7 +1060,7 @@ pppinput(c, tp)
flush:
if (!(sc->sc_flags & SC_FLUSH)) {
s = spltty();
- sc->sc_if.if_ierrors++;
+ PPP2IFP(sc)->if_ierrors++;
sc->sc_stats.ppp_ierrors++;
sc->sc_flags |= SC_FLUSH;
splx(s);
@@ -1081,7 +1081,7 @@ ppplogchar(sc, c)
sc->sc_rawin[sc->sc_rawin_count++] = c;
if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
|| (c < 0 && sc->sc_rawin_count > 0)) {
- printf("%s input: %*D", sc->sc_if.if_xname,
+ printf("%s input: %*D", PPP2IFP(sc)->if_xname,
sc->sc_rawin_count, sc->sc_rawin, " ");
sc->sc_rawin_count = 0;
}
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index e716818..64a8532 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -2387,14 +2387,14 @@ ieee80211_ioctl(struct ieee80211com *ic, u_long cmd, caddr_t data)
*/
case AF_IPX: {
struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
- struct arpcom *ac = (struct arpcom *)ifp;
if (ipx_nullhost(*ina))
- ina->x_host = *(union ipx_host *) ac->ac_enaddr;
+ ina->x_host = *(union ipx_host *)
+ IFP2ENADDR(ifp);
else
bcopy((caddr_t) ina->x_host.c_host,
- (caddr_t) ac->ac_enaddr,
- sizeof(ac->ac_enaddr));
+ (caddr_t) IFP2ENADDR(ifp),
+ ETHER_ADDR_LEN);
/* fall thru... */
}
#endif
diff --git a/sys/netatalk/aarp.c b/sys/netatalk/aarp.c
index 4d2a4e1..6806491 100644
--- a/sys/netatalk/aarp.c
+++ b/sys/netatalk/aarp.c
@@ -196,7 +196,7 @@ aarpwhohas(struct ifnet *ifp, struct sockaddr_at *sat)
ea->aarp_hln = sizeof(ea->aarp_sha);
ea->aarp_pln = sizeof(ea->aarp_spu);
ea->aarp_op = htons(AARPOP_REQUEST);
- bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha,
+ bcopy(IFP2ENADDR(ifp), (caddr_t)ea->aarp_sha,
sizeof(ea->aarp_sha));
/*
@@ -360,8 +360,8 @@ at_aarpinput(struct ifnet *ifp, struct mbuf *m)
ea = mtod(m, struct ether_aarp *);
/* Check to see if from my hardware address */
- if (!bcmp((caddr_t)ea->aarp_sha, IFP2AC(ifp)->ac_enaddr,
- sizeof(IFP2AC(ifp)->ac_enaddr))) {
+ if (!bcmp((caddr_t)ea->aarp_sha, IFP2ENADDR(ifp),
+ sizeof(IFP2ENADDR(ifp)))) {
m_freem(m);
return;
}
@@ -484,7 +484,7 @@ at_aarpinput(struct ifnet *ifp, struct mbuf *m)
bcopy((caddr_t)ea->aarp_sha, (caddr_t)ea->aarp_tha,
sizeof(ea->aarp_sha));
- bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha,
+ bcopy(IFP2ENADDR(ifp), (caddr_t)ea->aarp_sha,
sizeof(ea->aarp_sha));
/* XXX */
@@ -630,7 +630,7 @@ aarpprobe(void *arg)
ea->aarp_hln = sizeof(ea->aarp_sha);
ea->aarp_pln = sizeof(ea->aarp_spu);
ea->aarp_op = htons(AARPOP_PROBE);
- bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha,
+ bcopy(IFP2ENADDR(ifp), (caddr_t)ea->aarp_sha,
sizeof(ea->aarp_sha));
eh = (struct ether_header *)sa.sa_data;
diff --git a/sys/netatm/atm_if.c b/sys/netatm/atm_if.c
index 49c1867..f6f78b9 100644
--- a/sys/netatm/atm_if.c
+++ b/sys/netatm/atm_if.c
@@ -341,7 +341,7 @@ atm_physif_ioctl(code, data, arg)
"%s%d", pip->pif_name, pip->pif_unit );
if ( pip->pif_nif )
{
- strcpy(apr.anp_nif_pref, pip->pif_nif->nif_if.if_dname);
+ strcpy(apr.anp_nif_pref, pip->pif_nif->nif_ifp->if_dname);
nip = pip->pif_nif;
while ( nip ) {
@@ -376,7 +376,7 @@ atm_physif_ioctl(code, data, arg)
*/
aip = (struct atminfreq *)data;
nip = (struct atm_nif *)arg;
- ifp = &nip->nif_if;
+ ifp = nip->nif_ifp;
pip = nip->nif_pif;
/*
@@ -503,7 +503,15 @@ atm_physif_ioctl(code, data, arg)
}
nip->nif_pif = pip;
- ifp = &nip->nif_if;
+ ifp = nip->nif_ifp = if_alloc(IFT_IPOVERATM);
+ if (ifp == NULL) {
+ uma_zfree(cup->cu_nif_zone, nip);
+ /*
+ * Destroy any successful nifs
+ */
+ atm_physif_freenifs(pip, cup->cu_nif_zone);
+ break;
+ }
strcpy ( nip->nif_name, asr->asr_nif_pref );
nip->nif_sel = count;
@@ -514,10 +522,6 @@ atm_physif_ioctl(code, data, arg)
ifp->if_output = atm_ifoutput;
ifp->if_ioctl = atm_if_ioctl;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
- /*
- * Set if_type and if_baudrate
- */
- ifp->if_type = IFT_IPOVERATM;
switch ( cup->cu_config.ac_media ) {
case MEDIA_TAXI_100:
ifp->if_baudrate = 100000000;
@@ -544,6 +548,7 @@ atm_physif_ioctl(code, data, arg)
break;
}
if ((err = atm_nif_attach(nip)) != 0) {
+ if_free(nip->nif_ifp);
uma_zfree(cup->cu_nif_zone, nip);
/*
* Destroy any successful nifs
@@ -755,7 +760,9 @@ atm_nif_attach(nip)
struct atm_ncm *ncp;
int s;
- ifp = &nip->nif_if;
+ ifp = nip->nif_ifp;
+ if (ifp == NULL)
+ return (ENOSPC);
pip = nip->nif_pif;
s = splimp();
@@ -831,7 +838,7 @@ atm_nif_detach(nip)
{
struct atm_ncm *ncp;
int s;
- struct ifnet *ifp = &nip->nif_if;
+ struct ifnet *ifp = nip->nif_ifp;
s = splimp();
@@ -853,6 +860,7 @@ atm_nif_detach(nip)
* then remove from the system interface list
*/
if_detach(ifp);
+ if_free(ifp);
/*
* Remove from physical interface list
@@ -970,7 +978,7 @@ atm_if_ioctl(ifp, cmd, data)
caddr_t data;
{
register struct ifreq *ifr = (struct ifreq *)data;
- struct atm_nif *nip = (struct atm_nif *)ifp;
+ struct atm_nif *nip = IFP2ANIF(ifp);
int error = 0;
int s = splnet();
diff --git a/sys/netatm/atm_if.h b/sys/netatm/atm_if.h
index 6cadb75..c9ea43a 100644
--- a/sys/netatm/atm_if.h
+++ b/sys/netatm/atm_if.h
@@ -224,7 +224,7 @@ struct atm_pif {
* each physical ATM interface.
*/
struct atm_nif {
- struct ifnet nif_if; /* Network interface */
+ struct ifnet *nif_ifp; /* Network interface */
struct atm_pif *nif_pif; /* Our physical interface */
char nif_name[IFNAMSIZ];/* Network interface name */
u_char nif_sel; /* Interface's address selector */
@@ -234,7 +234,8 @@ struct atm_nif {
long nif_ibytes; /* Bytes received from interface */
long nif_obytes; /* Bytes sent to interface */
};
-
+#define ANIF2IFP(an) ((an)->nif_ifp)
+#define IFP2ANIF(ifp) ((struct atm_nif *)(ifp)->if_softc)
/*
* Common Device VCC Entry
diff --git a/sys/netatm/atm_socket.c b/sys/netatm/atm_socket.c
index 37ea86d..7da8f3e 100644
--- a/sys/netatm/atm_socket.c
+++ b/sys/netatm/atm_socket.c
@@ -1218,7 +1218,7 @@ atm_sock_getopt(so, sopt, atp)
struct t_atm_net_intf netif;
struct ifnet *ifp;
- ifp = &ap->nif->nif_if;
+ ifp = ANIF2IFP(ap->nif);
(void) snprintf(netif.net_intf, sizeof(netif.net_intf),
"%s", ifp->if_xname);
return (sooptcopyout(sopt, &netif,
diff --git a/sys/netatm/atm_usrreq.c b/sys/netatm/atm_usrreq.c
index 67cc6a9..8baec6a 100644
--- a/sys/netatm/atm_usrreq.c
+++ b/sys/netatm/atm_usrreq.c
@@ -393,7 +393,7 @@ atm_dgram_control(so, cmd, data, ifp, td)
*/
for (nip = pip->pif_nif; nip;
nip = nip->nif_pnext) {
- if (&nip->nif_if == ifp2)
+ if (ANIF2IFP(nip) == ifp2)
break;
}
if (nip)
diff --git a/sys/netatm/ipatm/ipatm_input.c b/sys/netatm/ipatm/ipatm_input.c
index 3899d23..1bdadd2 100644
--- a/sys/netatm/ipatm/ipatm_input.c
+++ b/sys/netatm/ipatm/ipatm_input.c
@@ -142,7 +142,7 @@ ipatm_ipinput(inp, m)
/*
* Save the input ifnet pointer in the packet header
*/
- m->m_pkthdr.rcvif = (struct ifnet *)inp->inf_nif;
+ m->m_pkthdr.rcvif = ANIF2IFP(inp->inf_nif);
/*
* Finally, hand packet off to IP.
diff --git a/sys/netatm/ipatm/ipatm_load.c b/sys/netatm/ipatm/ipatm_load.c
index 638c0ce..2e931cd 100644
--- a/sys/netatm/ipatm/ipatm_load.c
+++ b/sys/netatm/ipatm/ipatm_load.c
@@ -438,7 +438,7 @@ ipatm_start()
* Process each network interface
*/
for (nip = pip->pif_nif; nip; nip = nip->nif_pnext) {
- struct ifnet *ifp = (struct ifnet *)nip;
+ struct ifnet *ifp = ANIF2IFP(nip);
struct in_ifaddr *ia;
/*
diff --git a/sys/netatm/ipatm/ipatm_output.c b/sys/netatm/ipatm/ipatm_output.c
index 11ac8c0..45559f0 100644
--- a/sys/netatm/ipatm/ipatm_output.c
+++ b/sys/netatm/ipatm/ipatm_output.c
@@ -92,7 +92,7 @@ ipatm_ifoutput(ifp, m, dst)
/*
* See if we've already got an appropriate VCC
*/
- ivp = ipatm_iptovc((struct sockaddr_in *)dst, (struct atm_nif *)ifp);
+ ivp = ipatm_iptovc((struct sockaddr_in *)dst, IFP2ANIF(ifp));
if (ivp) {
/*
@@ -164,7 +164,7 @@ ipatm_ifoutput(ifp, m, dst)
*/
s = splnet();
for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
- if (inp->inf_nif == (struct atm_nif *)ifp)
+ if (inp->inf_nif == IFP2ANIF(ifp))
break;
}
(void) splx(s);
diff --git a/sys/netatm/ipatm/ipatm_usrreq.c b/sys/netatm/ipatm/ipatm_usrreq.c
index 9fcc20c..19c02b3 100644
--- a/sys/netatm/ipatm/ipatm_usrreq.c
+++ b/sys/netatm/ipatm/ipatm_usrreq.c
@@ -325,7 +325,7 @@ ipatm_ioctl(code, data, arg1)
}
if ((ip.s_addr == INADDR_ANY) ||
- in_broadcast(ip, &inp->inf_nif->nif_if) ||
+ in_broadcast(ip, ANIF2IFP(inp->inf_nif)) ||
IN_MULTICAST(ntohl(ip.s_addr))) {
err = EADDRNOTAVAIL;
break;
@@ -391,7 +391,7 @@ ipatm_ioctl(code, data, arg1)
}
if ((ip.s_addr == INADDR_ANY) ||
- in_broadcast(ip, &inp->inf_nif->nif_if) ||
+ in_broadcast(ip, ANIF2IFP(inp->inf_nif)) ||
IN_MULTICAST(ntohl(ip.s_addr))) {
err = EADDRNOTAVAIL;
break;
@@ -447,7 +447,7 @@ ipatm_ioctl(code, data, arg1)
SATOSIN(&aivr.aip_dst_addr)->sin_addr.s_addr =
ivp->iv_dst.s_addr;
strlcpy(aivr.aip_intf,
- inp->inf_nif->nif_if.if_xname,
+ ANIF2IFP(inp->inf_nif)->if_xname,
sizeof(aivr.aip_intf));
if ((ivp->iv_conn) &&
(ivp->iv_conn->co_connvc) &&
diff --git a/sys/netatm/ipatm/ipatm_vcm.c b/sys/netatm/ipatm/ipatm_vcm.c
index 7f7cdf7..f06348e 100644
--- a/sys/netatm/ipatm/ipatm_vcm.c
+++ b/sys/netatm/ipatm/ipatm_vcm.c
@@ -367,7 +367,7 @@ ipatm_openpvc(pvp, sivp)
* Validate fixed destination IP address
*/
if (pvp->ipp_dst.sin_addr.s_addr != INADDR_ANY) {
- if (in_broadcast(pvp->ipp_dst.sin_addr, &nip->nif_if) ||
+ if (in_broadcast(pvp->ipp_dst.sin_addr, ANIF2IFP(nip)) ||
IN_MULTICAST(ntohl(pvp->ipp_dst.sin_addr.s_addr)) ||
ipatm_chknif(pvp->ipp_dst.sin_addr, inp)) {
err = EINVAL;
@@ -606,7 +606,7 @@ ipatm_createsvc(ifp, daf, dst, sivp)
caddr_t dst;
struct ipvcc **sivp;
{
- struct atm_nif *nip = (struct atm_nif *)ifp;
+ struct atm_nif *nip = IFP2ANIF(ifp);
struct ip_nif *inp;
struct ipvcc *ivp = NULL; /* XXX pacify gcc-3.1 */
struct in_addr *ip;
diff --git a/sys/netatm/spans/spans_arp.c b/sys/netatm/spans/spans_arp.c
index 507562b..eefdb3e 100644
--- a/sys/netatm/spans/spans_arp.c
+++ b/sys/netatm/spans/spans_arp.c
@@ -665,7 +665,7 @@ spansarp_input(clp, m)
* If source IP address is from unspecified or broadcast addresses,
* don't bother updating arp table, but answer possible requests
*/
- if (in_broadcast(in_src, &inp->inf_nif->nif_if))
+ if (in_broadcast(in_src, ANIF2IFP(inp->inf_nif)))
goto chkop;
/*
@@ -1118,7 +1118,7 @@ spansarp_ioctl(code, data, arg1)
SATOSIN(&aar.aap_arp_addr)->sin_addr.s_addr =
sap->sa_dstip.s_addr;
strlcpy(aar.aap_intf,
- clp->cls_ipnif->inf_nif->nif_if.if_xname,
+ ANIF2IFP(clp->cls_ipnif->inf_nif)->if_xname,
sizeof(aar.aap_intf));
aar.aap_flags = sap->sa_flags;
aar.aap_origin = sap->sa_origin;
diff --git a/sys/netatm/uni/uniarp.c b/sys/netatm/uni/uniarp.c
index bcd0967..c23a905 100644
--- a/sys/netatm/uni/uniarp.c
+++ b/sys/netatm/uni/uniarp.c
@@ -722,7 +722,7 @@ uniarp_client_mode(uip, aap)
/*
* Next, initiate an SVC to the server
*/
- if ((*inp->inf_createsvc)(&inp->inf_nif->nif_if, AF_ATM,
+ if ((*inp->inf_createsvc)(ANIF2IFP(inp->inf_nif), AF_ATM,
(caddr_t)&uip->uip_arpsvratm, &ivp)) {
uma_zfree(uniarp_zone, uap);
UNIIP_ARP_TIMER(uip, 1 * ATM_HZ);
@@ -1054,7 +1054,7 @@ uniarp_ioctl(code, data, arg1)
AF_INET;
SATOSIN(&aar.aap_arp_addr)->sin_addr.s_addr =
uap->ua_dstip.s_addr;
- strlcpy(aar.aap_intf, nip->nif_if.if_xname,
+ strlcpy(aar.aap_intf, ANIF2IFP(nip)->if_xname,
sizeof(aar.aap_intf));
aar.aap_flags = uap->ua_flags;
aar.aap_origin = uap->ua_origin;
@@ -1107,7 +1107,7 @@ uniarp_ioctl(code, data, arg1)
*/
SATOSIN(&aar.aap_arp_addr)->sin_family = AF_INET;
SATOSIN(&aar.aap_arp_addr)->sin_addr.s_addr = 0;
- strlcpy(aar.aap_intf, nip->nif_if.if_xname,
+ strlcpy(aar.aap_intf, ANIF2IFP(nip)->if_xname,
sizeof(aar.aap_intf));
aar.aap_flags = 0;
aar.aap_origin = uap->ua_origin;
@@ -1187,7 +1187,7 @@ updbuf:
/*
* Fill in info to be returned
*/
- strlcpy(asr.asp_intf, nip->nif_if.if_xname,
+ strlcpy(asr.asp_intf, ANIF2IFP(nip)->if_xname,
sizeof(asr.asp_intf));
asr.asp_state = uip->uip_arpstate;
if (uip->uip_arpstate == UIAS_SERVER_ACTIVE) {
diff --git a/sys/netatm/uni/uniarp_cache.c b/sys/netatm/uni/uniarp_cache.c
index 946fee8..074b8c7 100644
--- a/sys/netatm/uni/uniarp_cache.c
+++ b/sys/netatm/uni/uniarp_cache.c
@@ -413,7 +413,7 @@ uniarp_validate_ip(uip, ip, origin)
* Can't be multicast or broadcast address
*/
if (IN_MULTICAST(ntohl(ip->s_addr)) ||
- in_broadcast(*ip, &uip->uip_ipnif->inf_nif->nif_if))
+ in_broadcast(*ip, ANIF2IFP(uip->uip_ipnif->inf_nif)))
return (1);
/*
diff --git a/sys/netgraph/atm/atmpif/ng_atmpif_harp.c b/sys/netgraph/atm/atmpif/ng_atmpif_harp.c
index 793d9a4..aa31365 100644
--- a/sys/netgraph/atm/atmpif/ng_atmpif_harp.c
+++ b/sys/netgraph/atm/atmpif/ng_atmpif_harp.c
@@ -677,7 +677,7 @@ vatmpif_harp_output(Cmn_unit *cup, Cmn_vcc *cvp, KBuffer *m)
vup->vu_pif.pif_oerrors++;
vcp->vc_oerrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(vcp->vc_nif)->if_oerrors++;
} else {
/*
* Good transmission
@@ -709,8 +709,8 @@ vatmpif_harp_output(Cmn_unit *cup, Cmn_vcc *cvp, KBuffer *m)
vcp->vc_obytes += pdulen;
if (vcp->vc_nif) {
vcp->vc_nif->nif_obytes += pdulen;
- vcp->vc_nif->nif_if.if_opackets++;
- vcp->vc_nif->nif_if.if_obytes += pdulen;
+ ANIF2IFP(vcp->vc_nif)->if_opackets++;
+ ANIF2IFP(vcp->vc_nif)->if_obytes += pdulen;
}
}
}
@@ -888,8 +888,8 @@ vatmpif_harp_recv_drain(Vatmpif_unit *vup, KBuffer *m,
*/
if (vcp->vc_nif) {
vcp->vc_nif->nif_ibytes += pdulen;
- vcp->vc_nif->nif_if.if_ipackets++;
- vcp->vc_nif->nif_if.if_ibytes += pdulen;
+ ANIF2IFP(vcp->vc_nif)->if_ipackets++;
+ ANIF2IFP(vcp->vc_nif)->if_ibytes += pdulen;
}
}
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c
index 4f11ef2..65364cc 100644
--- a/sys/netgraph/atm/ng_atm.c
+++ b/sys/netgraph/atm/ng_atm.c
@@ -346,8 +346,8 @@ static const struct {
} atmmedia[] = IFM_SUBTYPE_ATM_DESCRIPTIONS;
-#define IFP2NG(IFP) ((node_p)((struct ifatm *)(IFP))->ngpriv)
-#define IFP2NG_SET(IFP, val) (((struct ifatm *)(IFP))->ngpriv = (val))
+#define IFP2NG(IFP) ((node_p)((struct ifatm *)(IFP)->if_softc)->ngpriv)
+#define IFP2NG_SET(IFP, val) (((struct ifatm *)(IFP)->if_softc)->ngpriv = (val))
#define IFFLAGS "\020\001UP\002BROADCAST\003DEBUG\004LOOPBACK" \
"\005POINTOPOINT\006SMART\007RUNNING\010NOARP" \
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index 0a0aad1..7ca104f 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -73,8 +73,7 @@ static const struct ng_cmdlist ng_eiface_cmdlist[] = {
/* Node private data */
struct ng_eiface_private {
- struct arpcom arpcom; /* per-interface network data */
-#define sc_ifp arpcom.ac_if
+ struct ifnet *ifp; /* per-interface network data */
int unit; /* Interface unit number */
node_p node; /* Our netgraph node */
hook_p ether; /* Hook for ethernet stream */
@@ -188,7 +187,7 @@ static void
ng_eiface_init(void *xsc)
{
priv_p sc = xsc;
- struct ifnet *ifp = &sc->sc_ifp;
+ struct ifnet *ifp = sc->ifp;
int s;
s = splimp();
@@ -329,13 +328,18 @@ ng_eiface_constructor(node_p node)
{
struct ifnet *ifp;
priv_p priv;
+ u_char eaddr[6] = {0,0,0,0,0,0};
/* Allocate node and interface private structures */
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT | M_ZERO);
if (priv == NULL)
return (ENOMEM);
- ifp = &(priv->arpcom.ac_if);
+ ifp = priv->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ free(priv, M_NETGRAPH);
+ return (ENOSPC);
+ }
/* Link them together */
ifp->if_softc = priv;
@@ -365,7 +369,7 @@ ng_eiface_constructor(node_p node)
#endif
/* Attach the interface */
- ether_ifattach(ifp, priv->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* Done */
return (0);
@@ -378,7 +382,7 @@ static int
ng_eiface_newhook(node_p node, hook_p hook, const char *name)
{
priv_p priv = NG_NODE_PRIVATE(node);
- struct ifnet *ifp = &priv->sc_ifp;
+ struct ifnet *ifp = priv->ifp;
if (strcmp(name, NG_EIFACE_HOOK_ETHER))
return (EPFNOSUPPORT);
@@ -399,7 +403,7 @@ static int
ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
const priv_p priv = NG_NODE_PRIVATE(node);
- struct ifnet *const ifp = &priv->sc_ifp;
+ struct ifnet *const ifp = priv->ifp;
struct ng_mesg *resp = NULL;
int error = 0;
struct ng_mesg *msg;
@@ -420,13 +424,14 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
break;
}
eaddr = (struct ether_addr *)(msg->data);
- bcopy(eaddr, priv->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(eaddr, IFP2ENADDR(priv->ifp),
+ ETHER_ADDR_LEN);
/* And put it in the ifaddr list */
TAILQ_FOREACH(ifa, &(ifp->if_addrhead), ifa_link) {
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
if (sdl->sdl_type == IFT_ETHER) {
- bcopy((IFP2AC(ifp))->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
LLADDR(sdl), ifp->if_addrlen);
break;
}
@@ -512,7 +517,7 @@ static int
ng_eiface_rcvdata(hook_p hook, item_p item)
{
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
- struct ifnet *const ifp = &priv->sc_ifp;
+ struct ifnet *const ifp = priv->ifp;
struct mbuf *m;
NGI_GET_M(item, m);
@@ -549,9 +554,10 @@ static int
ng_eiface_rmnode(node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
- struct ifnet *const ifp = &priv->sc_ifp;
+ struct ifnet *const ifp = priv->ifp;
ether_ifdetach(ifp);
+ if_free(ifp);
free_unr(ng_eiface_unit, priv->unit);
FREE(priv, M_NETGRAPH);
NG_NODE_SET_PRIVATE(node, NULL);
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
index f5dc793..21eb2d4 100644
--- a/sys/netgraph/ng_ether.c
+++ b/sys/netgraph/ng_ether.c
@@ -68,8 +68,8 @@
#include <netgraph/ng_parse.h>
#include <netgraph/ng_ether.h>
-#define IFP2NG(ifp) ((struct ng_node *)((struct arpcom *)(ifp))->ac_netgraph)
-#define IFP2NG_SET(ifp, val) (((struct arpcom *)(ifp))->ac_netgraph = (val))
+#define IFP2NG(ifp) ((struct ng_node *)IFP2AC((ifp))->ac_netgraph)
+#define IFP2NG_SET(ifp, val) (IFP2AC((ifp))->ac_netgraph = (val))
/* Per-node private data */
struct private {
@@ -462,7 +462,7 @@ ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook)
error = ENOMEM;
break;
}
- bcopy((IFP2AC(priv->ifp))->ac_enaddr,
+ bcopy(IFP2ENADDR(priv->ifp),
resp->data, ETHER_ADDR_LEN);
break;
case NGM_ETHER_SET_ENADDR:
@@ -624,7 +624,7 @@ ng_ether_rcv_lower(node_p node, struct mbuf *m)
return (ENOBUFS);
/* Overwrite source MAC address */
- bcopy((IFP2AC(ifp))->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
mtod(m, struct ether_header *)->ether_shost,
ETHER_ADDR_LEN);
}
diff --git a/sys/netgraph/ng_fec.c b/sys/netgraph/ng_fec.c
index 0603f36..84b3e8f 100644
--- a/sys/netgraph/ng_fec.c
+++ b/sys/netgraph/ng_fec.c
@@ -171,7 +171,7 @@ struct ng_fec_bundle {
/* Node private data */
struct ng_fec_private {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct ifmedia ifmedia;
int if_flags;
int if_error; /* XXX */
@@ -345,7 +345,6 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
{
struct ng_fec_bundle *b;
struct ifnet *ifp, *bifp;
- struct arpcom *ac;
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
struct ng_fec_portlist *p, *new;
@@ -354,7 +353,7 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
return(EINVAL);
b = &priv->fec_bundle;
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp;
/* Find the interface */
bifp = ifunit(iface);
@@ -400,8 +399,6 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
if (new == NULL)
return(ENOMEM);
- ac = (struct arpcom *)bifp;
-
IF_AFDATA_LOCK(bifp);
bifp->if_afdata[AF_NETGRAPH] = priv->node;
IF_AFDATA_UNLOCK(bifp);
@@ -414,9 +411,9 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
if (b->fec_ifcnt == 0) {
ifa = ifaddr_byindex(ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)ac->ac_enaddr,
- priv->arpcom.ac_enaddr, ETHER_ADDR_LEN);
- bcopy((char *)ac->ac_enaddr,
+ bcopy(IFP2ENADDR(bifp),
+ IFP2ENADDR(priv->ifp), ETHER_ADDR_LEN);
+ bcopy(IFP2ENADDR(bifp),
LLADDR(sdl), ETHER_ADDR_LEN);
}
@@ -425,14 +422,14 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
b->fec_ifcnt++;
/* Save the real MAC address. */
- bcopy((char *)ac->ac_enaddr,
+ bcopy(IFP2ENADDR(bifp),
(char *)&new->fec_mac, ETHER_ADDR_LEN);
/* Set up phony MAC address. */
ifa = ifaddr_byindex(bifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy(priv->arpcom.ac_enaddr, ac->ac_enaddr, ETHER_ADDR_LEN);
- bcopy(priv->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN);
+ bcopy(IFP2ENADDR(priv->ifp), IFP2ENADDR(bifp), ETHER_ADDR_LEN);
+ bcopy(IFP2ENADDR(priv->ifp), LLADDR(sdl), ETHER_ADDR_LEN);
/* Save original input vector */
new->fec_if_input = bifp->if_input;
@@ -456,7 +453,6 @@ ng_fec_delport(struct ng_fec_private *priv, char *iface)
{
struct ng_fec_bundle *b;
struct ifnet *ifp, *bifp;
- struct arpcom *ac;
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
struct ng_fec_portlist *p;
@@ -465,7 +461,7 @@ ng_fec_delport(struct ng_fec_private *priv, char *iface)
return(EINVAL);
b = &priv->fec_bundle;
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp;
/* Find the interface */
bifp = ifunit(iface);
@@ -491,10 +487,9 @@ ng_fec_delport(struct ng_fec_private *priv, char *iface)
(*bifp->if_ioctl)(bifp, SIOCSIFFLAGS, NULL);
/* Restore MAC address. */
- ac = (struct arpcom *)bifp;
ifa = ifaddr_byindex(bifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)&p->fec_mac, ac->ac_enaddr, ETHER_ADDR_LEN);
+ bcopy((char *)&p->fec_mac, IFP2ENADDR(bifp), ETHER_ADDR_LEN);
bcopy((char *)&p->fec_mac, LLADDR(sdl), ETHER_ADDR_LEN);
/* Restore input vector */
@@ -641,7 +636,7 @@ ng_fec_tick(void *arg)
}
}
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp;
if (ifp->if_flags & IFF_RUNNING)
priv->fec_ch = timeout(ng_fec_tick, priv, hz);
@@ -792,7 +787,7 @@ ng_fec_input(struct ifnet *ifp, struct mbuf *m0)
priv = NG_NODE_PRIVATE(node);
b = &priv->fec_bundle;
- bifp = &priv->arpcom.ac_if;
+ bifp = priv->ifp;
TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) {
if (p->fec_if == m0->m_pkthdr.rcvif)
@@ -1106,7 +1101,11 @@ ng_fec_constructor(node_p node)
if (priv == NULL)
return (ENOMEM);
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ FREE(priv, M_NETGRAPH);
+ return (ENOSPC);
+ }
b = &priv->fec_bundle;
/* Link them together */
@@ -1114,7 +1113,7 @@ ng_fec_constructor(node_p node)
/* Get an interface unit number */
if ((error = ng_fec_get_unit(&priv->unit)) != 0) {
- FREE(ifp, M_NETGRAPH);
+ if_free(ifp);
FREE(priv, M_NETGRAPH);
return (error);
}
@@ -1145,7 +1144,7 @@ ng_fec_constructor(node_p node)
log(LOG_WARNING, "%s: can't acquire netgraph name\n", ifname);
/* Attach the interface */
- ether_ifattach(ifp, priv->arpcom.ac_enaddr);
+ ether_ifattach(ifp, IFP2ENADDR(priv->ifp));
callout_handle_init(&priv->fec_ch);
/* Override output method with our own */
@@ -1228,14 +1227,15 @@ ng_fec_shutdown(node_p node)
struct ng_fec_portlist *p;
b = &priv->fec_bundle;
- ng_fec_stop(&priv->arpcom.ac_if);
+ ng_fec_stop(priv->ifp);
while (!TAILQ_EMPTY(&b->ng_fec_ports)) {
p = TAILQ_FIRST(&b->ng_fec_ports);
ng_fec_delport(priv, p->fec_if->if_xname);
}
- ether_ifdetach(&priv->arpcom.ac_if);
+ ether_ifdetach(priv->ifp);
+ if_free_type(priv->ifp, IFT_ETHER);
ifmedia_removeall(&priv->ifmedia);
ng_fec_free_unit(priv->unit);
FREE(priv, M_NETGRAPH);
diff --git a/sys/netgraph/ng_gif.c b/sys/netgraph/ng_gif.c
index 135d66c..5d948bd 100644
--- a/sys/netgraph/ng_gif.c
+++ b/sys/netgraph/ng_gif.c
@@ -89,8 +89,8 @@
#include <netgraph/ng_parse.h>
#include <netgraph/ng_gif.h>
-#define IFP2NG(ifp) ((struct ng_node *)((struct gif_softc *)(ifp))->gif_netgraph)
-#define IFP2NG_SET(ifp, val) (((struct gif_softc *)(ifp))->gif_netgraph = (val))
+#define IFP2NG(ifp) ((struct ng_node *)((struct gif_softc *)(ifp->if_softc))->gif_netgraph)
+#define IFP2NG_SET(ifp, val) (((struct gif_softc *)(ifp->if_softc))->gif_netgraph = (val))
/* Per-node private data */
struct private {
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index 21b0289..91b6a3d 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -470,7 +470,7 @@ ng_iface_constructor(node_p node)
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH_IFACE, M_NOWAIT|M_ZERO);
if (priv == NULL)
return (ENOMEM);
- MALLOC(ifp, struct ifnet *, sizeof(*ifp), M_NETGRAPH_IFACE, M_NOWAIT|M_ZERO);
+ ifp = if_alloc(IFT_PROPVIRTUAL);
if (ifp == NULL) {
FREE(priv, M_NETGRAPH_IFACE);
return (ENOMEM);
@@ -724,7 +724,7 @@ ng_iface_shutdown(node_p node)
bpfdetach(priv->ifp);
if_detach(priv->ifp);
- FREE(priv->ifp, M_NETGRAPH_IFACE);
+ if_free(priv->ifp);
priv->ifp = NULL;
free_unr(ng_iface_unit, priv->unit);
FREE(priv, M_NETGRAPH_IFACE);
diff --git a/sys/netgraph/ng_sppp.c b/sys/netgraph/ng_sppp.c
index a53c956..b46acbb 100644
--- a/sys/netgraph/ng_sppp.c
+++ b/sys/netgraph/ng_sppp.c
@@ -51,7 +51,7 @@ MALLOC_DEFINE(M_NETGRAPH_SPPP, "netgraph_sppp", "netgraph sppp node ");
/* Node private data */
struct ng_sppp_private {
- struct sppp *pp; /* Our interface */
+ struct ifnet *ifp; /* Our interface */
int unit; /* Interface unit number */
node_p node; /* Our netgraph node */
hook_p hook; /* Hook */
@@ -243,6 +243,7 @@ static int
ng_sppp_constructor (node_p node)
{
struct sppp *pp;
+ struct ifnet *ifp;
priv_p priv;
int error = 0;
@@ -250,15 +251,16 @@ ng_sppp_constructor (node_p node)
MALLOC (priv, priv_p, sizeof(*priv), M_NETGRAPH_SPPP, M_NOWAIT|M_ZERO);
if (priv == NULL)
return (ENOMEM);
- MALLOC (pp, struct sppp *, sizeof(*pp), M_NETGRAPH_SPPP, M_NOWAIT|M_ZERO);
- if (pp == NULL) {
+
+ ifp = if_alloc(IFT_PPP);
+ if (ifp == NULL) {
FREE (priv, M_NETGRAPH_SPPP);
- return (ENOMEM);
+ return (ENOSPC);
}
+ pp = IFP2SP(ifp);
/* Link them together */
- pp->pp_if.if_softc = priv;
- priv->pp = pp;
+ ifp->if_softc = priv;
/* Get an interface unit number */
if ((error = ng_sppp_get_unit(&priv->unit)) != 0) {
@@ -273,21 +275,21 @@ ng_sppp_constructor (node_p node)
priv->node = node;
/* Initialize interface structure */
- if_initname (&pp->pp_if, NG_SPPP_IFACE_NAME, priv->unit);
- pp->pp_if.if_start = ng_sppp_start;
- pp->pp_if.if_ioctl = ng_sppp_ioctl;
- pp->pp_if.if_watchdog = NULL;
- pp->pp_if.if_flags = (IFF_POINTOPOINT|IFF_MULTICAST);
+ if_initname (SP2IFP(pp), NG_SPPP_IFACE_NAME, priv->unit);
+ ifp->if_start = ng_sppp_start;
+ ifp->if_ioctl = ng_sppp_ioctl;
+ ifp->if_watchdog = NULL;
+ ifp->if_flags = (IFF_POINTOPOINT|IFF_MULTICAST);
/* Give this node the same name as the interface (if possible) */
- if (ng_name_node(node, pp->pp_if.if_xname) != 0)
+ if (ng_name_node(node, SP2IFP(pp)->if_xname) != 0)
log (LOG_WARNING, "%s: can't acquire netgraph name\n",
- pp->pp_if.if_xname);
+ SP2IFP(pp)->if_xname);
/* Attach the interface */
- sppp_attach (&pp->pp_if);
- if_attach (&pp->pp_if);
- bpfattach (&pp->pp_if, DLT_NULL, sizeof(u_int));
+ sppp_attach (ifp);
+ if_attach (ifp);
+ bpfattach (ifp, DLT_NULL, sizeof(u_int));
/* Done */
return (0);
@@ -322,7 +324,7 @@ ng_sppp_rcvmsg (node_p node, item_p item, hook_p lasthook)
const priv_p priv = NG_NODE_PRIVATE (node);
struct ng_mesg *msg = NULL;
struct ng_mesg *resp = NULL;
- struct sppp *const pp = priv->pp;
+ struct sppp *const pp = IFP2SP(priv->ifp);
int error = 0;
NGI_GET_MSG (item, msg);
@@ -335,7 +337,7 @@ ng_sppp_rcvmsg (node_p node, item_p item, hook_p lasthook)
error = ENOMEM;
break;
}
- strlcpy(resp->data, pp->pp_if.if_xname, IFNAMSIZ);
+ strlcpy(resp->data, SP2IFP(pp)->if_xname, IFNAMSIZ);
break;
default:
@@ -360,29 +362,29 @@ ng_sppp_rcvdata (hook_p hook, item_p item)
{
struct mbuf *m;
const priv_p priv = NG_NODE_PRIVATE (NG_HOOK_NODE (hook));
- struct sppp *const pp = priv->pp;
+ struct sppp *const pp = IFP2SP(priv->ifp);
NGI_GET_M (item, m);
NG_FREE_ITEM (item);
/* Sanity checks */
KASSERT (m->m_flags & M_PKTHDR, ("%s: not pkthdr", __func__));
- if ((pp->pp_if.if_flags & IFF_UP) == 0) {
+ if ((SP2IFP(pp)->if_flags & IFF_UP) == 0) {
NG_FREE_M (m);
return (ENETDOWN);
}
/* Update interface stats */
- pp->pp_if.if_ipackets++;
+ SP2IFP(pp)->if_ipackets++;
/* Note receiving interface */
- m->m_pkthdr.rcvif = &pp->pp_if;
+ m->m_pkthdr.rcvif = SP2IFP(pp);
/* Berkeley packet filter */
- if (pp->pp_if.if_bpf)
- BPF_MTAP (&pp->pp_if, m);
+ if (SP2IFP(pp)->if_bpf)
+ BPF_MTAP (SP2IFP(pp), m);
/* Send packet */
- sppp_input (&pp->pp_if, m);
+ sppp_input (SP2IFP(pp), m);
return 0;
}
@@ -394,11 +396,10 @@ ng_sppp_shutdown (node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
/* Detach from the packet filter list of interfaces. */
- bpfdetach (&priv->pp->pp_if);
- sppp_detach (&priv->pp->pp_if);
- if_detach (&priv->pp->pp_if);
- FREE (priv->pp, M_NETGRAPH_SPPP);
- priv->pp = NULL;
+ bpfdetach (priv->ifp);
+ sppp_detach (priv->ifp);
+ if_detach (priv->ifp);
+ if_free(priv->ifp);
ng_sppp_free_unit (priv->unit);
FREE (priv, M_NETGRAPH_SPPP);
NG_NODE_SET_PRIVATE (node, NULL);
diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c
index d6360b6..aeed444 100644
--- a/sys/netinet/in_gif.c
+++ b/sys/netinet/in_gif.c
@@ -92,7 +92,7 @@ in_gif_output(ifp, family, m)
int family;
struct mbuf *m;
{
- struct gif_softc *sc = (struct gif_softc*)ifp;
+ struct gif_softc *sc = ifp->if_softc;
struct sockaddr_in *dst = (struct sockaddr_in *)&sc->gif_ro.ro_dst;
struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc;
struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst;
@@ -186,7 +186,7 @@ in_gif_output(ifp, family, m)
sc->gif_ro.ro_rt = NULL;
}
#if 0
- sc->gif_if.if_mtu = GIF_MTU;
+ GIF2IFP(sc)->if_mtu = GIF_MTU;
#endif
}
@@ -210,7 +210,7 @@ in_gif_output(ifp, family, m)
error = ip_output(m, NULL, &sc->gif_ro, 0, NULL, NULL);
- if (!(sc->gif_if.if_flags & IFF_LINK0) &&
+ if (!(GIF2IFP(sc)->if_flags & IFF_LINK0) &&
sc->gif_ro.ro_rt != NULL) {
RTFREE(sc->gif_ro.ro_rt);
sc->gif_ro.ro_rt = NULL;
@@ -337,7 +337,7 @@ gif_validate4(ip, sc, ifp)
}
/* ingress filters on outer source */
- if ((sc->gif_if.if_flags & IFF_LINK2) == 0 && ifp) {
+ if ((GIF2IFP(sc)->if_flags & IFF_LINK2) == 0 && ifp) {
struct sockaddr_in sin;
struct rtentry *rt;
@@ -349,7 +349,7 @@ gif_validate4(ip, sc, ifp)
if (!rt || rt->rt_ifp != ifp) {
#if 0
log(LOG_WARNING, "%s: packet from 0x%x dropped "
- "due to ingress filter\n", if_name(&sc->gif_if),
+ "due to ingress filter\n", if_name(GIF2IFP(sc)),
(u_int32_t)ntohl(sin.sin_addr.s_addr));
#endif
if (rt)
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index f84b9bd..54107f0 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -88,8 +88,7 @@ static MALLOC_DEFINE(M_CARP, "CARP", "CARP interfaces");
SYSCTL_DECL(_net_inet_carp);
struct carp_softc {
- struct arpcom sc_ac; /* Interface clue */
-#define sc_if sc_ac.ac_if
+ struct ifnet *sc_ifp; /* Interface clue */
struct ifnet *sc_carpdev; /* Pointer to parent interface */
struct in_ifaddr *sc_ia; /* primary iface address */
struct ip_moptions sc_imo;
@@ -129,6 +128,7 @@ struct carp_softc {
LIST_ENTRY(carp_softc) sc_next; /* Interface clue */
};
+#define SC2IFP(sc) ((sc)->sc_ifp)
int carp_suppress_preempt = 0;
int carp_opts[CARPCTL_MAXID] = { 0, 1, 0, 1, 0, 0 }; /* XXX for now */
@@ -257,7 +257,7 @@ carp_hmac_prepare(struct carp_softc *sc)
SHA1Update(&sc->sc_sha1, (void *)&type, sizeof(type));
SHA1Update(&sc->sc_sha1, (void *)&vhid, sizeof(vhid));
#ifdef INET
- TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family == AF_INET)
SHA1Update(&sc->sc_sha1,
(void *)&ifatoia(ifa)->ia_addr.sin_addr.s_addr,
@@ -265,7 +265,7 @@ carp_hmac_prepare(struct carp_softc *sc)
}
#endif /* INET */
#ifdef INET6
- TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family == AF_INET6) {
in6 = ifatoia6(ifa)->ia_addr.sin6_addr;
if (IN6_IS_ADDR_LINKLOCAL(&in6))
@@ -325,7 +325,7 @@ carp_setroute(struct carp_softc *sc, int cmd)
CARP_SCLOCK_ASSERT(sc);
s = splnet();
- TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family == AF_INET &&
sc->sc_carpdev != NULL) {
int count = carp_addrcount(
@@ -356,6 +356,11 @@ carp_clone_create(struct if_clone *ifc, int unit)
struct ifnet *ifp;
MALLOC(sc, struct carp_softc *, sizeof(*sc), M_CARP, M_WAITOK|M_ZERO);
+ ifp = SC2IFP(sc) = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ FREE(sc, M_CARP);
+ return (ENOSPC);
+ }
sc->sc_flags_backup = 0;
sc->sc_suppress = 0;
@@ -372,7 +377,6 @@ carp_clone_create(struct if_clone *ifc, int unit)
callout_init(&sc->sc_md_tmo, NET_CALLOUT_MPSAFE);
callout_init(&sc->sc_md6_tmo, NET_CALLOUT_MPSAFE);
- ifp = &sc->sc_if;
ifp->if_softc = sc;
if_initname(ifp, CARP_IFNAME, unit);
ifp->if_mtu = ETHERMTU;
@@ -384,7 +388,7 @@ carp_clone_create(struct if_clone *ifc, int unit)
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_hdrlen = 0;
if_attach(ifp);
- bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int32_t));
+ bpfattach(SC2IFP(sc), DLT_NULL, sizeof(u_int32_t));
mtx_lock(&carp_mtx);
LIST_INSERT_HEAD(&carpif_list, sc, sc_next);
mtx_unlock(&carp_mtx);
@@ -449,6 +453,7 @@ carp_clone_destroy(struct ifnet *ifp)
mtx_unlock(&carp_mtx);
bpfdetach(ifp);
if_detach(ifp);
+ if_free_type(ifp, IFT_ETHER);
free(sc, M_CARP);
}
@@ -623,7 +628,7 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
if (sc->sc_vhid == ch->carp_vhid)
break;
- if (!sc || (sc->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) !=
+ if (!sc || (SC2IFP(sc)->if_flags & (IFF_UP|IFF_RUNNING)) !=
(IFF_UP|IFF_RUNNING)) {
carpstats.carps_badvhid++;
CARP_UNLOCK(ifp->if_carp);
@@ -631,27 +636,27 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
return;
}
- getmicrotime(&sc->sc_if.if_lastchange);
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ getmicrotime(&SC2IFP(sc)->if_lastchange);
+ SC2IFP(sc)->if_ipackets++;
+ SC2IFP(sc)->if_ibytes += m->m_pkthdr.len;
- if (sc->sc_if.if_bpf) {
+ if (SC2IFP(sc)->if_bpf) {
struct ip *ip = mtod(m, struct ip *);
uint32_t af1 = af;
/* BPF wants net byte order */
ip->ip_len = htons(ip->ip_len + (ip->ip_hl << 2));
ip->ip_off = htons(ip->ip_off);
- bpf_mtap2(sc->sc_if.if_bpf, &af1, sizeof(af1), m);
+ bpf_mtap2(SC2IFP(sc)->if_bpf, &af1, sizeof(af1), m);
}
/* verify the CARP version. */
if (ch->carp_version != CARP_VERSION) {
carpstats.carps_badver++;
- sc->sc_if.if_ierrors++;
+ SC2IFP(sc)->if_ierrors++;
CARP_UNLOCK(ifp->if_carp);
CARP_LOG("%s; invalid version %d\n",
- sc->sc_if.if_xname,
+ SC2IFP(sc)->if_xname,
ch->carp_version);
m_freem(m);
return;
@@ -660,9 +665,9 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
/* verify the hash */
if (carp_hmac_verify(sc, ch->carp_counter, ch->carp_md)) {
carpstats.carps_badauth++;
- sc->sc_if.if_ierrors++;
+ SC2IFP(sc)->if_ierrors++;
CARP_UNLOCK(ifp->if_carp);
- CARP_LOG("%s: incorrect hash\n", sc->sc_if.if_xname);
+ CARP_LOG("%s: incorrect hash\n", SC2IFP(sc)->if_xname);
m_freem(m);
return;
}
@@ -697,7 +702,7 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
callout_stop(&sc->sc_ad_tmo);
CARP_DEBUG("%s: MASTER -> BACKUP "
"(more frequent advertisement received)\n",
- sc->sc_if.if_xname);
+ SC2IFP(sc)->if_xname);
carp_set_state(sc, BACKUP);
carp_setrun(sc, 0);
carp_setroute(sc, RTM_DELETE);
@@ -712,7 +717,7 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
timevalcmp(&sc_tv, &ch_tv, <)) {
CARP_DEBUG("%s: BACKUP -> MASTER "
"(preempting a slower master)\n",
- sc->sc_if.if_xname);
+ SC2IFP(sc)->if_xname);
carp_master_down_locked(sc);
break;
}
@@ -726,7 +731,7 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
if (timevalcmp(&sc_tv, &ch_tv, <)) {
CARP_DEBUG("%s: BACKUP -> MASTER "
"(master timed out)\n",
- sc->sc_if.if_xname);
+ SC2IFP(sc)->if_xname);
carp_master_down_locked(sc);
break;
}
@@ -754,15 +759,15 @@ carpdetach(struct carp_softc *sc)
callout_stop(&sc->sc_md_tmo);
callout_stop(&sc->sc_md6_tmo);
- while ((ifa = TAILQ_FIRST(&sc->sc_if.if_addrlist)) != NULL)
+ while ((ifa = TAILQ_FIRST(&SC2IFP(sc)->if_addrlist)) != NULL)
if (ifa->ifa_addr->sa_family == AF_INET) {
struct in_ifaddr *ia = ifatoia(ifa);
carp_del_addr(sc, &ia->ia_addr);
/* ripped screaming from in_control(SIOCDIFADDR) */
- in_ifscrub(&sc->sc_if, ia);
- TAILQ_REMOVE(&sc->sc_if.if_addrlist, ifa, ifa_link);
+ in_ifscrub(SC2IFP(sc), ia);
+ TAILQ_REMOVE(&SC2IFP(sc)->if_addrlist, ifa, ifa_link);
TAILQ_REMOVE(&in_ifaddrhead, ia, ia_link);
IFAFREE((&ia->ia_ifa));
}
@@ -785,7 +790,7 @@ static int
carp_prepare_ad(struct mbuf *m, struct carp_softc *sc, struct carp_header *ch)
{
struct m_tag *mtag;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = SC2IFP(sc);
if (sc->sc_init_counter) {
/* this could also be seconds since unix epoch */
@@ -804,7 +809,7 @@ carp_prepare_ad(struct mbuf *m, struct carp_softc *sc, struct carp_header *ch)
mtag = m_tag_get(PACKET_TAG_CARP, sizeof(struct ifnet *), M_NOWAIT);
if (mtag == NULL) {
m_freem(m);
- sc->sc_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
return (ENOMEM);
}
bcopy(&ifp, (caddr_t)(mtag + 1), sizeof(struct ifnet *));
@@ -823,7 +828,7 @@ carp_send_ad_all(void)
if (sc->sc_carpdev == NULL)
continue;
CARP_SCLOCK(sc);
- if ((sc->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) &&
+ if ((SC2IFP(sc)->if_flags & (IFF_UP|IFF_RUNNING)) &&
sc->sc_state == MASTER)
carp_send_ad_locked(sc);
CARP_SCUNLOCK(sc);
@@ -853,7 +858,7 @@ carp_send_ad_locked(struct carp_softc *sc)
CARP_SCLOCK_ASSERT(sc);
/* bow out if we've lost our UPness or RUNNINGuiness */
- if ((sc->sc_if.if_flags &
+ if ((SC2IFP(sc)->if_flags &
(IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
advbase = 255;
advskew = 255;
@@ -882,7 +887,7 @@ carp_send_ad_locked(struct carp_softc *sc)
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (m == NULL) {
- sc->sc_ac.ac_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
carpstats.carps_onomem++;
/* XXX maybe less ? */
if (advbase != 255 || advskew != 255)
@@ -918,13 +923,13 @@ carp_send_ad_locked(struct carp_softc *sc)
ch_ptr->carp_cksum = carp_cksum(m, len - sizeof(*ip));
m->m_data -= sizeof(*ip);
- getmicrotime(&sc->sc_if.if_lastchange);
- sc->sc_ac.ac_if.if_opackets++;
- sc->sc_ac.ac_if.if_obytes += len;
+ getmicrotime(&SC2IFP(sc)->if_lastchange);
+ SC2IFP(sc)->if_opackets++;
+ SC2IFP(sc)->if_obytes += len;
carpstats.carps_opackets++;
if (ip_output(m, NULL, NULL, IP_RAWOUTPUT, &sc->sc_imo, NULL)) {
- sc->sc_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
if (sc->sc_sendad_errors < INT_MAX)
sc->sc_sendad_errors++;
if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) {
@@ -954,7 +959,7 @@ carp_send_ad_locked(struct carp_softc *sc)
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (m == NULL) {
- sc->sc_ac.ac_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
carpstats.carps_onomem++;
/* XXX maybe less ? */
if (advbase != 255 || advskew != 255)
@@ -990,13 +995,13 @@ carp_send_ad_locked(struct carp_softc *sc)
ch_ptr->carp_cksum = carp_cksum(m, len - sizeof(*ip6));
m->m_data -= sizeof(*ip6);
- getmicrotime(&sc->sc_if.if_lastchange);
- sc->sc_if.if_opackets++;
- sc->sc_if.if_obytes += len;
+ getmicrotime(&SC2IFP(sc)->if_lastchange);
+ SC2IFP(sc)->if_opackets++;
+ SC2IFP(sc)->if_obytes += len;
carpstats.carps_opackets6++;
if (ip6_output(m, NULL, NULL, 0, &sc->sc_im6o, NULL, NULL)) {
- sc->sc_if.if_oerrors++;
+ SC2IFP(sc)->if_oerrors++;
if (sc->sc_sendad_errors < INT_MAX)
sc->sc_sendad_errors++;
if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) {
@@ -1037,13 +1042,13 @@ carp_send_arp(struct carp_softc *sc)
{
struct ifaddr *ifa;
- TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
-/* arprequest(sc->sc_carpdev, &in, &in, sc->sc_ac.ac_enaddr); */
- arp_ifinit2(sc->sc_carpdev, ifa, sc->sc_ac.ac_enaddr);
+/* arprequest(sc->sc_carpdev, &in, &in, IFP2ENADDR(sc->sc_ifp)); */
+ arp_ifinit2(sc->sc_carpdev, ifa, IFP2ENADDR(sc->sc_ifp));
DELAY(1000); /* XXX */
}
@@ -1057,7 +1062,7 @@ carp_send_na(struct carp_softc *sc)
struct in6_addr *in6;
static struct in6_addr mcast = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
- TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
@@ -1081,10 +1086,10 @@ carp_addrcount(struct carp_if *cif, struct in_ifaddr *ia, int type)
TAILQ_FOREACH(vh, &cif->vhif_vrs, sc_list) {
if ((type == CARP_COUNT_RUNNING &&
- (vh->sc_ac.ac_if.if_flags & (IFF_UP|IFF_RUNNING)) ==
+ (SC2IFP(vh)->if_flags & (IFF_UP|IFF_RUNNING)) ==
(IFF_UP|IFF_RUNNING)) ||
(type == CARP_COUNT_MASTER && vh->sc_state == MASTER)) {
- TAILQ_FOREACH(ifa, &vh->sc_ac.ac_if.if_addrlist,
+ TAILQ_FOREACH(ifa, &SC2IFP(vh)->if_addrlist,
ifa_list) {
if (ifa->ifa_addr->sa_family == AF_INET &&
ia->ia_addr.sin_addr.s_addr ==
@@ -1127,9 +1132,9 @@ carp_iamatch(void *v, struct in_ifaddr *ia,
count = 0;
TAILQ_FOREACH(vh, &cif->vhif_vrs, sc_list) {
- if ((vh->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) ==
+ if ((SC2IFP(vh)->if_flags & (IFF_UP|IFF_RUNNING)) ==
(IFF_UP|IFF_RUNNING)) {
- TAILQ_FOREACH(ifa, &vh->sc_if.if_addrlist,
+ TAILQ_FOREACH(ifa, &SC2IFP(vh)->if_addrlist,
ifa_list) {
if (ifa->ifa_addr->sa_family ==
AF_INET &&
@@ -1138,7 +1143,7 @@ carp_iamatch(void *v, struct in_ifaddr *ia,
if (count == index) {
if (vh->sc_state ==
MASTER) {
- *enaddr = vh->sc_ac.ac_enaddr;
+ *enaddr = IFP2ENADDR(vh->sc_ifp);
CARP_UNLOCK(cif);
return (1);
} else {
@@ -1153,10 +1158,10 @@ carp_iamatch(void *v, struct in_ifaddr *ia,
}
} else {
TAILQ_FOREACH(vh, &cif->vhif_vrs, sc_list) {
- if ((vh->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) ==
+ if ((SC2IFP(vh)->if_flags & (IFF_UP|IFF_RUNNING)) ==
(IFF_UP|IFF_RUNNING) && ia->ia_ifp ==
- &vh->sc_if) {
- *enaddr = vh->sc_ac.ac_enaddr;
+ SC2IFP(vh)) {
+ *enaddr = IFP2ENADDR(vh->sc_ifp);
CARP_UNLOCK(cif);
return (1);
}
@@ -1176,10 +1181,10 @@ carp_iamatch6(void *v, struct in6_addr *taddr)
CARP_LOCK(cif);
TAILQ_FOREACH(vh, &cif->vhif_vrs, sc_list) {
- TAILQ_FOREACH(ifa, &vh->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(vh)->if_addrlist, ifa_list) {
if (IN6_ARE_ADDR_EQUAL(taddr,
&ifatoia6(ifa)->ia_addr.sin6_addr) &&
- ((vh->sc_if.if_flags &
+ ((SC2IFP(vh)->if_flags &
(IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING))) {
CARP_UNLOCK(cif);
return (ifa);
@@ -1201,25 +1206,25 @@ carp_macmatch6(void *v, struct mbuf *m, const struct in6_addr *taddr)
CARP_LOCK(cif);
TAILQ_FOREACH(sc, &cif->vhif_vrs, sc_list) {
- TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {
+ TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) {
if (IN6_ARE_ADDR_EQUAL(taddr,
&ifatoia6(ifa)->ia_addr.sin6_addr) &&
- ((sc->sc_if.if_flags &
+ ((SC2IFP(sc)->if_flags &
(IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING))) {
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = SC2IFP(sc);
mtag = m_tag_get(PACKET_TAG_CARP,
sizeof(struct ifnet *), M_NOWAIT);
if (mtag == NULL) {
/* better a bit than nothing */
CARP_UNLOCK(cif);
- return (sc->sc_ac.ac_enaddr);
+ return (IFP2ENADDR(sc->sc_ifp));
}
bcopy(&ifp, (caddr_t)(mtag + 1),
sizeof(struct ifnet *));
m_tag_prepend(m, mtag);
CARP_UNLOCK(cif);
- return (sc->sc_ac.ac_enaddr);
+ return (IFP2ENADDR(sc->sc_ifp));
}
}
}
@@ -1241,11 +1246,11 @@ carp_forus(void *v, void *dhost)
CARP_LOCK(cif);
TAILQ_FOREACH(vh, &cif->vhif_vrs, sc_list)
- if ((vh->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) ==
+ if ((SC2IFP(vh)->if_flags & (IFF_UP|IFF_RUNNING)) ==
(IFF_UP|IFF_RUNNING) && vh->sc_state == MASTER &&
- !bcmp(dhost, vh->sc_ac.ac_enaddr, ETHER_ADDR_LEN)) {
+ !bcmp(dhost, IFP2ENADDR(vh->sc_ifp), ETHER_ADDR_LEN)) {
CARP_UNLOCK(cif);
- return (&vh->sc_if);
+ return (SC2IFP(vh));
}
CARP_UNLOCK(cif);
@@ -1271,7 +1276,7 @@ carp_master_down_locked(struct carp_softc *sc)
switch (sc->sc_state) {
case INIT:
printf("%s: master_down event in INIT state\n",
- sc->sc_if.if_xname);
+ SC2IFP(sc)->if_xname);
break;
case MASTER:
break;
@@ -1300,11 +1305,11 @@ carp_setrun(struct carp_softc *sc, sa_family_t af)
if (sc->sc_carpdev)
CARP_SCLOCK_ASSERT(sc);
- if (sc->sc_if.if_flags & IFF_UP &&
+ if (SC2IFP(sc)->if_flags & IFF_UP &&
sc->sc_vhid > 0 && (sc->sc_naddrs || sc->sc_naddrs6))
- sc->sc_if.if_flags |= IFF_RUNNING;
+ SC2IFP(sc)->if_flags |= IFF_RUNNING;
else {
- sc->sc_if.if_flags &= ~IFF_RUNNING;
+ SC2IFP(sc)->if_flags &= ~IFF_RUNNING;
carp_setroute(sc, RTM_DELETE);
return;
}
@@ -1318,11 +1323,11 @@ carp_setrun(struct carp_softc *sc, sa_family_t af)
carp_send_na(sc);
#endif /* INET6 */
CARP_DEBUG("%s: INIT -> MASTER (preempting)\n",
- sc->sc_if.if_xname);
+ SC2IFP(sc)->if_xname);
carp_set_state(sc, MASTER);
carp_setroute(sc, RTM_ADD);
} else {
- CARP_DEBUG("%s: INIT -> BACKUP\n", sc->sc_if.if_xname);
+ CARP_DEBUG("%s: INIT -> BACKUP\n", SC2IFP(sc)->if_xname);
carp_set_state(sc, BACKUP);
carp_setroute(sc, RTM_DELETE);
carp_setrun(sc, 0);
@@ -1376,10 +1381,10 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
int own, error;
if (sin->sin_addr.s_addr == 0) {
- if (!(sc->sc_if.if_flags & IFF_UP))
+ if (!(SC2IFP(sc)->if_flags & IFF_UP))
carp_set_state(sc, INIT);
if (sc->sc_naddrs)
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
carp_setrun(sc, 0);
return (0);
}
@@ -1388,7 +1393,7 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
ia_if = NULL; own = 0;
TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
/* and, yeah, we need a multicast-capable iface too */
- if (ia->ia_ifp != &sc->sc_if &&
+ if (ia->ia_ifp != SC2IFP(sc) &&
(ia->ia_ifp->if_flags & IFF_MULTICAST) &&
(iaddr & ia->ia_subnetmask) == ia->ia_subnet) {
if (!ia_if)
@@ -1480,7 +1485,7 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
}
sc->sc_naddrs++;
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
if (own)
sc->sc_advskew = 0;
carp_sc_state_locked(sc);
@@ -1506,7 +1511,7 @@ carp_del_addr(struct carp_softc *sc, struct sockaddr_in *sin)
CARP_LOCK(cif);
callout_stop(&sc->sc_ad_tmo);
- sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
+ SC2IFP(sc)->if_flags &= ~(IFF_UP|IFF_RUNNING);
sc->sc_vhid = -1;
in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
imo->imo_multicast_ifp = NULL;
@@ -1536,10 +1541,10 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
int own, error;
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
- if (!(sc->sc_if.if_flags & IFF_UP))
+ if (!(SC2IFP(sc)->if_flags & IFF_UP))
carp_set_state(sc, INIT);
if (sc->sc_naddrs6)
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
carp_setrun(sc, 0);
return (0);
}
@@ -1557,7 +1562,7 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
break;
}
/* and, yeah, we need a multicast-capable iface too */
- if (ia->ia_ifp != &sc->sc_ac.ac_if &&
+ if (ia->ia_ifp != SC2IFP(sc) &&
(ia->ia_ifp->if_flags & IFF_MULTICAST) &&
(i == 4)) {
if (!ia_if)
@@ -1662,7 +1667,7 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
}
sc->sc_naddrs6++;
- sc->sc_ac.ac_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
if (own)
sc->sc_advskew = 0;
carp_sc_state_locked(sc);
@@ -1695,7 +1700,7 @@ carp_del_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
CARP_LOCK(cif);
callout_stop(&sc->sc_ad_tmo);
- sc->sc_ac.ac_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
+ SC2IFP(sc)->if_flags &= ~(IFF_UP|IFF_RUNNING);
sc->sc_vhid = -1;
while (!LIST_EMPTY(&im6o->im6o_memberships)) {
struct in6_multi_mship *imm =
@@ -1737,7 +1742,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
bcopy(ifa->ifa_addr, ifa->ifa_dstaddr,
sizeof(struct sockaddr));
error = carp_set_addr(sc, satosin(ifa->ifa_addr));
@@ -1745,7 +1750,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
#endif /* INET */
#ifdef INET6
case AF_INET6:
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
error = carp_set_addr6(sc, satosin6(ifa->ifa_addr));
break;
#endif /* INET6 */
@@ -1759,7 +1764,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
bcopy(ifa->ifa_addr, ifa->ifa_dstaddr,
sizeof(struct sockaddr));
error = carp_set_addr(sc, satosin(&ifra->ifra_addr));
@@ -1767,7 +1772,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
#endif /* INET */
#ifdef INET6
case AF_INET6:
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
error = carp_set_addr6(sc, satosin6(&ifra->ifra_addr));
break;
#endif /* INET6 */
@@ -1809,7 +1814,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
carp_set_state(sc, INIT);
carp_setrun(sc, 0);
} else if (sc->sc_state == INIT && (ifr->ifr_flags & IFF_UP)) {
- sc->sc_if.if_flags |= IFF_UP;
+ SC2IFP(sc)->if_flags |= IFF_UP;
carp_setrun(sc, 0);
}
break;
@@ -1853,12 +1858,12 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr)
return EEXIST;
}
sc->sc_vhid = carpr.carpr_vhid;
- sc->sc_ac.ac_enaddr[0] = 0;
- sc->sc_ac.ac_enaddr[1] = 0;
- sc->sc_ac.ac_enaddr[2] = 0x5e;
- sc->sc_ac.ac_enaddr[3] = 0;
- sc->sc_ac.ac_enaddr[4] = 1;
- sc->sc_ac.ac_enaddr[5] = sc->sc_vhid;
+ IFP2ENADDR(sc->sc_ifp)[0] = 0;
+ IFP2ENADDR(sc->sc_ifp)[1] = 0;
+ IFP2ENADDR(sc->sc_ifp)[2] = 0x5e;
+ IFP2ENADDR(sc->sc_ifp)[3] = 0;
+ IFP2ENADDR(sc->sc_ifp)[4] = 1;
+ IFP2ENADDR(sc->sc_ifp)[5] = sc->sc_vhid;
error--;
}
if (carpr.carpr_advbase > 0 || carpr.carpr_advskew > 0) {
@@ -2043,16 +2048,16 @@ carp_set_state(struct carp_softc *sc, int state)
sc->sc_state = state;
switch (state) {
case BACKUP:
- sc->sc_ac.ac_if.if_link_state = LINK_STATE_DOWN;
+ SC2IFP(sc)->if_link_state = LINK_STATE_DOWN;
break;
case MASTER:
- sc->sc_ac.ac_if.if_link_state = LINK_STATE_UP;
+ SC2IFP(sc)->if_link_state = LINK_STATE_UP;
break;
default:
- sc->sc_ac.ac_if.if_link_state = LINK_STATE_UNKNOWN;
+ SC2IFP(sc)->if_link_state = LINK_STATE_UNKNOWN;
break;
}
- rt_ifmsg(&sc->sc_ac.ac_if);
+ rt_ifmsg(SC2IFP(sc));
}
void
@@ -2081,8 +2086,8 @@ carp_sc_state_locked(struct carp_softc *sc)
if (sc->sc_carpdev->if_link_state != LINK_STATE_UP ||
!(sc->sc_carpdev->if_flags & IFF_UP)) {
- sc->sc_flags_backup = sc->sc_if.if_flags;
- sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
+ sc->sc_flags_backup = SC2IFP(sc)->if_flags;
+ SC2IFP(sc)->if_flags &= ~(IFF_UP|IFF_RUNNING);
callout_stop(&sc->sc_ad_tmo);
callout_stop(&sc->sc_md_tmo);
callout_stop(&sc->sc_md6_tmo);
@@ -2098,7 +2103,7 @@ carp_sc_state_locked(struct carp_softc *sc)
}
sc->sc_suppress = 1;
} else {
- sc->sc_if.if_flags |= sc->sc_flags_backup;
+ SC2IFP(sc)->if_flags |= sc->sc_flags_backup;
carp_set_state(sc, INIT);
carp_setrun(sc, 0);
if (sc->sc_suppress)
@@ -2124,7 +2129,7 @@ carp_modevent(module_t mod, int type, void *data)
case MOD_UNLOAD:
if_clone_detach(&carp_cloner);
while (!LIST_EMPTY(&carpif_list))
- carp_clone_destroy(&LIST_FIRST(&carpif_list)->sc_if);
+ carp_clone_destroy(SC2IFP(LIST_FIRST(&carpif_list)));
mtx_destroy(&carp_mtx);
break;
diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c
index e8201ed..2304722 100644
--- a/sys/netinet/ip_gre.c
+++ b/sys/netinet/ip_gre.c
@@ -155,8 +155,8 @@ gre_input2(struct mbuf *m ,int hlen, u_char proto)
}
gip = mtod(m, struct greip *);
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ GRE2IFP(sc)->if_ipackets++;
+ GRE2IFP(sc)->if_ibytes += m->m_pkthdr.len;
switch (proto) {
case IPPROTO_GRE:
@@ -207,12 +207,12 @@ gre_input2(struct mbuf *m ,int hlen, u_char proto)
/* Unlike NetBSD, in FreeBSD m_adj() adjusts m->m_pkthdr.len as well */
m_adj(m, hlen);
- if (sc->sc_if.if_bpf) {
+ if (GRE2IFP(sc)->if_bpf) {
u_int32_t af = AF_INET;
- bpf_mtap2(sc->sc_if.if_bpf, &af, sizeof(af), m);
+ bpf_mtap2(GRE2IFP(sc)->if_bpf, &af, sizeof(af), m);
}
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = GRE2IFP(sc);
netisr_dispatch(isr, m);
@@ -260,8 +260,8 @@ gre_mobile_input(m, va_alist)
ip = mtod(m, struct ip *);
mip = mtod(m, struct mobip_h *);
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += m->m_pkthdr.len;
+ GRE2IFP(sc)->if_ipackets++;
+ GRE2IFP(sc)->if_ibytes += m->m_pkthdr.len;
if (ntohs(mip->mh.proto) & MOB_H_SBIT) {
msiz = MOB_H_SIZ_L;
@@ -302,12 +302,12 @@ gre_mobile_input(m, va_alist)
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, (ip->ip_hl << 2));
- if (sc->sc_if.if_bpf) {
+ if (GRE2IFP(sc)->if_bpf) {
u_int32_t af = AF_INET;
- bpf_mtap2(sc->sc_if.if_bpf, &af, sizeof(af), m);
+ bpf_mtap2(GRE2IFP(sc)->if_bpf, &af, sizeof(af), m);
}
- m->m_pkthdr.rcvif = &sc->sc_if;
+ m->m_pkthdr.rcvif = GRE2IFP(sc);
netisr_dispatch(NETISR_IP, m);
}
@@ -336,7 +336,7 @@ gre_lookup(m, proto)
if ((sc->g_dst.s_addr == ip->ip_src.s_addr) &&
(sc->g_src.s_addr == ip->ip_dst.s_addr) &&
(sc->g_proto == proto) &&
- ((sc->sc_if.if_flags & IFF_UP) != 0)) {
+ ((GRE2IFP(sc)->if_flags & IFF_UP) != 0)) {
mtx_unlock(&gre_mtx);
return (sc);
}
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 056ffb6..ce3a217 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -974,7 +974,7 @@ smart_frag_failure:
goto done;
}
m->m_pkthdr.len = mhlen + len;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
+ m->m_pkthdr.rcvif = NULL;
#ifdef MAC
mac_create_fragment(m0, m);
#endif
@@ -1069,7 +1069,7 @@ ip_insertoptions(m, opt, phlen)
return (m);
}
M_MOVE_PKTHDR(n, m);
- n->m_pkthdr.rcvif = (struct ifnet *)0;
+ n->m_pkthdr.rcvif = NULL;
#ifdef MAC
mac_create_mbuf_from_mbuf(m, n);
#endif
diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c
index 0befec2..c9123d7 100644
--- a/sys/netinet6/in6_gif.c
+++ b/sys/netinet6/in6_gif.c
@@ -88,7 +88,7 @@ in6_gif_output(ifp, family, m)
int family; /* family of the packet to be encapsulate. */
struct mbuf *m;
{
- struct gif_softc *sc = (struct gif_softc*)ifp;
+ struct gif_softc *sc = ifp->if_softc;
struct sockaddr_in6 *dst = (struct sockaddr_in6 *)&sc->gif_ro6.ro_dst;
struct sockaddr_in6 *sin6_src = (struct sockaddr_in6 *)sc->gif_psrc;
struct sockaddr_in6 *sin6_dst = (struct sockaddr_in6 *)sc->gif_pdst;
@@ -185,7 +185,7 @@ in6_gif_output(ifp, family, m)
sc->gif_ro6.ro_rt = NULL;
}
#if 0
- sc->gif_if.if_mtu = GIF_MTU;
+ GIF2IFP(sc)->if_mtu = GIF_MTU;
#endif
}
@@ -218,7 +218,7 @@ in6_gif_output(ifp, family, m)
error = ip6_output(m, 0, &sc->gif_ro6, 0, 0, NULL, NULL);
#endif
- if (!(sc->gif_if.if_flags & IFF_LINK0) &&
+ if (!(GIF2IFP(sc)->if_flags & IFF_LINK0) &&
sc->gif_ro6.ro_rt != NULL) {
RTFREE(sc->gif_ro6.ro_rt);
sc->gif_ro6.ro_rt = NULL;
@@ -330,7 +330,7 @@ gif_validate6(ip6, sc, ifp)
/* martian filters on outer source - done in ip6_input */
/* ingress filters on outer source */
- if ((sc->gif_if.if_flags & IFF_LINK2) == 0 && ifp) {
+ if ((GIF2IFP(sc)->if_flags & IFF_LINK2) == 0 && ifp) {
struct sockaddr_in6 sin6;
struct rtentry *rt;
@@ -344,7 +344,7 @@ gif_validate6(ip6, sc, ifp)
if (!rt || rt->rt_ifp != ifp) {
#if 0
log(LOG_WARNING, "%s: packet from %s dropped "
- "due to ingress filter\n", if_name(&sc->gif_if),
+ "due to ingress filter\n", if_name(GIF2IFP(sc)),
ip6_sprintf(&sin6.sin6_addr));
#endif
if (rt)
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 265bd9e..1d8459b 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1173,7 +1173,7 @@ passout:
}
m_cat(m, m_frgpart);
m->m_pkthdr.len = len + hlen + sizeof(*ip6f);
- m->m_pkthdr.rcvif = (struct ifnet *)0;
+ m->m_pkthdr.rcvif = NULL;
ip6f->ip6f_reserved = 0;
ip6f->ip6f_ident = id;
ip6f->ip6f_nxt = nextproto;
diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c
index 4aa432b..e100e51 100644
--- a/sys/netipx/ipx_ip.c
+++ b/sys/netipx/ipx_ip.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sockio.h>
#include <net/if.h>
+#include <net/if_types.h>
#include <net/netisr.h>
#include <net/route.h>
@@ -108,7 +109,11 @@ ipxipattach()
return (NULL);
m->ifen_next = ipxip_list;
ipxip_list = m;
- ifp = &m->ifen_ifnet;
+ ifp = m->ifen_ifp = if_alloc(IFT_IPXIP);
+ if (ifp == NULL) {
+ FREE(m, M_PCB);
+ return (NULL);
+ }
if_initname(ifp, "ipxip", ipxipif_units++);
ifp->if_mtu = LOMTU;
@@ -116,6 +121,7 @@ ipxipattach()
ifp->if_output = ipxipoutput;
ifp->if_start = ipxipstart;
ifp->if_flags = IFF_POINTOPOINT;
+ ifp->if_softc = m;
if_attach(ifp);
return (m);
@@ -234,14 +240,14 @@ ipxipoutput(ifp, m, dst, rt)
struct sockaddr *dst;
struct rtentry *rt;
{
- register struct ifnet_en *ifn = (struct ifnet_en *)ifp;
+ register struct ifnet_en *ifn = (struct ifnet_en *)ifp->if_softc;
register struct ip *ip;
register struct route *ro = &(ifn->ifen_route);
register int len = 0;
register struct ipx *ipx = mtod(m, struct ipx *);
int error;
- ifn->ifen_ifnet.if_opackets++;
+ ifn->ifen_ifp->if_opackets++;
ipxipif.if_opackets++;
/*
@@ -287,8 +293,8 @@ ipxipoutput(ifp, m, dst, rt)
*/
error = (ip_output(m, (struct mbuf *)NULL, ro, SO_BROADCAST, NULL, NULL));
if (error) {
- ifn->ifen_ifnet.if_oerrors++;
- ifn->ifen_ifnet.if_ierrors = error;
+ ifn->ifen_ifp->if_oerrors++;
+ ifn->ifen_ifp->if_ierrors = error;
}
return (error);
m_freem(m);
@@ -363,7 +369,7 @@ ipxip_route(so, sopt)
* Is there a free (pseudo-)interface or space?
*/
for (ifn = ipxip_list; ifn != NULL; ifn = ifn->ifen_next) {
- if ((ifn->ifen_ifnet.if_flags & IFF_UP) == 0)
+ if ((ifn->ifen_ifp->if_flags & IFF_UP) == 0)
break;
}
if (ifn == NULL)
@@ -396,7 +402,7 @@ static int
ipxip_free(ifp)
struct ifnet *ifp;
{
- register struct ifnet_en *ifn = (struct ifnet_en *)ifp;
+ register struct ifnet_en *ifn = (struct ifnet_en *)ifp->if_softc;
struct route *ro = & ifn->ifen_route;
if (ro->ro_rt != NULL) {
diff --git a/sys/netipx/ipx_ip.h b/sys/netipx/ipx_ip.h
index 23e4470..150b1ff 100644
--- a/sys/netipx/ipx_ip.h
+++ b/sys/netipx/ipx_ip.h
@@ -40,7 +40,7 @@
#define _NETIPX_IPXIP_H_
struct ifnet_en {
- struct ifnet ifen_ifnet;
+ struct ifnet *ifen_ifp;
struct route ifen_route;
struct in_addr ifen_src;
struct in_addr ifen_dst;
diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c
index ae92c8d..f86d4e4 100644
--- a/sys/pci/if_dc.c
+++ b/sys/pci/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/pci/if_dcreg.h b/sys/pci/if_dcreg.h
index 5cc5049..a851a72 100644
--- a/sys/pci/if_dcreg.h
+++ b/sys/pci/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/pci/if_de.c b/sys/pci/if_de.c
index da2310f..c8bf575 100644
--- a/sys/pci/if_de.c
+++ b/sys/pci/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/pci/if_devar.h b/sys/pci/if_devar.h
index ee02be5..54ed8d6 100644
--- a/sys/pci/if_devar.h
+++ b/sys/pci/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/pci/if_mn.c b/sys/pci/if_mn.c
index aa8ef46..3a10bb1 100644
--- a/sys/pci/if_mn.c
+++ b/sys/pci/if_mn.c
@@ -1060,7 +1060,7 @@ f54_intr(struct mn_softc *sc)
if (!sc->ch[i])
continue;
sp = &sc->ch[i]->ifsppp;
- if (!(sp->pp_if.if_flags & IFF_UP))
+ if (!(SP2IFP(sp)->if_flags & IFF_UP))
continue;
if (s)
timeout((timeout_t *)sp->pp_down, sp, 1 * hz);
diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c
index 640c827..7dec359 100644
--- a/sys/pci/if_pcn.c
+++ b/sys/pci/if_pcn.c
@@ -66,6 +66,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>
@@ -334,7 +335,7 @@ pcn_setmulti(sc)
u_int32_t h, i;
u_int16_t hashes[4] = { 0, 0, 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND);
@@ -581,7 +582,6 @@ pcn_attach(dev)
*/
eaddr[0] = CSR_READ_4(sc, PCN_IO32_APROM00);
eaddr[1] = CSR_READ_4(sc, PCN_IO32_APROM01);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
sc->pcn_unit = unit;
callout_handle_init(&sc->pcn_stat_ch);
@@ -596,7 +596,12 @@ pcn_attach(dev)
}
bzero(sc->pcn_ldata, sizeof(struct pcn_list_data));
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("pcn%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;
@@ -615,6 +620,7 @@ pcn_attach(dev)
if (mii_phy_probe(dev, &sc->pcn_miibus,
pcn_ifmedia_upd, pcn_ifmedia_sts)) {
printf("pcn%d: MII without any PHY!\n", sc->pcn_unit);
+ if_free(ifp);
error = ENXIO;
goto fail;
}
@@ -656,7 +662,7 @@ pcn_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
KASSERT(mtx_initialized(&sc->pcn_mtx), ("pcn mutex not initialized"));
PCN_LOCK(sc);
@@ -666,6 +672,7 @@ pcn_detach(dev)
pcn_reset(sc);
pcn_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->pcn_miibus)
device_delete_child(dev, sc->pcn_miibus);
@@ -795,7 +802,7 @@ pcn_rxeof(sc)
PCN_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
i = sc->pcn_cdata.pcn_rx_prod;
while(PCN_OWN_RXDESC(&sc->pcn_ldata->pcn_rx_list[i])) {
@@ -855,7 +862,7 @@ pcn_txeof(sc)
struct ifnet *ifp;
u_int32_t idx;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
/*
* Go through our tx list and free mbufs for those
@@ -914,7 +921,7 @@ pcn_tick(xsc)
struct ifnet *ifp;
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
PCN_LOCK(sc);
mii = device_get_softc(sc->pcn_miibus);
@@ -948,7 +955,7 @@ pcn_intr(arg)
u_int32_t status;
sc = arg;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
/* Suppress unwanted interrupts */
if (!(ifp->if_flags & IFF_UP)) {
@@ -1129,7 +1136,7 @@ pcn_init(xsc)
void *xsc;
{
struct pcn_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->pcn_ifp;
struct mii_data *mii = NULL;
PCN_LOCK(sc);
@@ -1144,11 +1151,11 @@ pcn_init(xsc)
/* Set MAC address */
pcn_csr_write(sc, PCN_CSR_PAR0,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
+ ((u_int16_t *)IFP2ENADDR(sc->pcn_ifp))[0]);
pcn_csr_write(sc, PCN_CSR_PAR1,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
+ ((u_int16_t *)IFP2ENADDR(sc->pcn_ifp))[1]);
pcn_csr_write(sc, PCN_CSR_PAR2,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ ((u_int16_t *)IFP2ENADDR(sc->pcn_ifp))[2]);
/* Init circular RX list. */
if (pcn_list_rx_init(sc) == ENOBUFS) {
@@ -1378,7 +1385,7 @@ pcn_stop(sc)
register int i;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->pcn_ifp;
PCN_LOCK(sc);
ifp->if_timer = 0;
diff --git a/sys/pci/if_pcnreg.h b/sys/pci/if_pcnreg.h
index 220629c..2294854 100644
--- a/sys/pci/if_pcnreg.h
+++ b/sys/pci/if_pcnreg.h
@@ -451,7 +451,7 @@ struct pcn_type {
};
struct pcn_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *pcn_ifp;
bus_space_handle_t pcn_bhandle;
bus_space_tag_t pcn_btag;
struct resource *pcn_res;
diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c
index 4f2fd9b..63a661c 100644
--- a/sys/pci/if_rl.c
+++ b/sys/pci/if_rl.c
@@ -98,6 +98,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>
@@ -583,7 +584,7 @@ rl_miibus_readreg(device_t dev, int phy, int reg)
rval = CSR_READ_1(sc, RL_MEDIASTAT);
return (rval);
default:
- if_printf(&sc->arpcom.ac_if, "bad phy register\n");
+ if_printf(sc->rl_ifp, "bad phy register\n");
return (0);
}
rval = CSR_READ_2(sc, rl8139_reg);
@@ -633,7 +634,7 @@ rl_miibus_writereg(device_t dev, int phy, int reg, int data)
return (0);
break;
default:
- if_printf(&sc->arpcom.ac_if, "bad phy register\n");
+ if_printf(sc->rl_ifp, "bad phy register\n");
return (0);
}
CSR_WRITE_2(sc, rl8139_reg, data);
@@ -660,7 +661,7 @@ rl_miibus_statchg(device_t dev)
static void
rl_setmulti(struct rl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
int h = 0;
uint32_t hashes[2] = { 0, 0 };
struct ifmultiaddr *ifma;
@@ -721,7 +722,7 @@ rl_reset(struct rl_softc *sc)
break;
}
if (i == RL_TIMEOUT)
- if_printf(&sc->arpcom.ac_if, "reset never completed!\n");
+ if_printf(sc->rl_ifp, "reset never completed!\n");
}
/*
@@ -861,7 +862,6 @@ rl_attach(device_t dev)
}
sc->rl_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/*
* Now read the exact device type from the EEPROM to find
@@ -946,7 +946,12 @@ rl_attach(device_t dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_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;
@@ -978,6 +983,7 @@ rl_attach(device_t dev)
if (error) {
if_printf(ifp, "couldn't set up irq\n");
ether_ifdetach(ifp);
+ if_free(ifp);
}
fail:
@@ -1002,13 +1008,15 @@ rl_detach(device_t dev)
int attached;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
KASSERT(mtx_initialized(&sc->rl_mtx), ("rl mutex not initialized"));
attached = device_is_attached(dev);
/* These should only be active if attach succeeded */
- if (attached)
+ if (attached) {
ether_ifdetach(ifp);
+ if_free(ifp);
+ }
RL_LOCK(sc);
#if 0
sc->suspended = 1;
@@ -1090,7 +1098,7 @@ static void
rl_rxeof(struct rl_softc *sc)
{
struct mbuf *m;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
uint8_t *rxbufpos;
int total_len = 0;
int wrap = 0;
@@ -1207,7 +1215,7 @@ rl_rxeof(struct rl_softc *sc)
static void
rl_txeof(struct rl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
uint32_t txstat;
RL_LOCK_ASSERT(sc);
@@ -1338,7 +1346,7 @@ static void
rl_intr(void *arg)
{
struct rl_softc *sc = arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
uint16_t status;
RL_LOCK(sc);
@@ -1504,7 +1512,7 @@ rl_init(void *xsc)
static void
rl_init_locked(struct rl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
struct mii_data *mii;
uint32_t rxcfg = 0;
@@ -1524,9 +1532,9 @@ rl_init_locked(struct rl_softc *sc)
*/
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_WRITECFG);
CSR_WRITE_STREAM_4(sc, RL_IDR0,
- *(uint32_t *)(&sc->arpcom.ac_enaddr[0]));
+ *(uint32_t *)(&IFP2ENADDR(sc->rl_ifp)[0]));
CSR_WRITE_STREAM_4(sc, RL_IDR4,
- *(uint32_t *)(&sc->arpcom.ac_enaddr[4]));
+ *(uint32_t *)(&IFP2ENADDR(sc->rl_ifp)[4]));
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
/* Init the RX buffer pointer register. */
@@ -1703,7 +1711,7 @@ static void
rl_stop(struct rl_softc *sc)
{
register int i;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->rl_ifp;
RL_LOCK_ASSERT(sc);
@@ -1767,7 +1775,7 @@ rl_resume(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->rl_ifp;
RL_LOCK(sc);
diff --git a/sys/pci/if_rlreg.h b/sys/pci/if_rlreg.h
index 29c7baf..ba571c5 100644
--- a/sys/pci/if_rlreg.h
+++ b/sys/pci/if_rlreg.h
@@ -678,7 +678,7 @@ struct rl_list_data {
};
struct rl_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *rl_ifp; /* interface info */
bus_space_handle_t rl_bhandle; /* bus space handle */
bus_space_tag_t rl_btag; /* bus space tag */
struct resource *rl_res;
diff --git a/sys/pci/if_sf.c b/sys/pci/if_sf.c
index 5593d52..85d6819 100644
--- a/sys/pci/if_sf.c
+++ b/sys/pci/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/pci/if_sfreg.h b/sys/pci/if_sfreg.h
index 4738f46..bbd704c 100644
--- a/sys/pci/if_sfreg.h
+++ b/sys/pci/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/pci/if_sis.c b/sys/pci/if_sis.c
index ad7e1b3..19a9f92 100644
--- a/sys/pci/if_sis.c
+++ b/sys/pci/if_sis.c
@@ -740,7 +740,7 @@ sis_setmulti_ns(struct sis_softc *sc)
u_int32_t h = 0, i, filtsave;
int bit, index;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
SIS_CLRBIT(sc, SIS_RXFILT_CTL, NS_RXFILTCTL_MCHASH);
@@ -789,7 +789,7 @@ sis_setmulti_sis(struct sis_softc *sc)
u_int32_t h, i, n, ctl;
u_int16_t hashes[16];
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
/* hash table size */
if (sc->sis_rev >= SIS_REV_635 ||
@@ -1069,7 +1069,6 @@ sis_attach(device_t dev)
callout_init(&sc->sis_stat_ch, CALLOUT_MPSAFE);
else
callout_init(&sc->sis_stat_ch, 0);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/*
* Allocate the parent bus DMA tag appropriate for PCI.
@@ -1192,7 +1191,12 @@ sis_attach(device_t dev)
* rings which we'll need later in the init routine.
*/
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("sis%d: can not if_alloc()\n", sc->sis_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1212,6 +1216,7 @@ sis_attach(device_t dev)
if (mii_phy_probe(dev, &sc->sis_miibus,
sis_ifmedia_upd, sis_ifmedia_sts)) {
printf("sis%d: MII without any PHY!\n", sc->sis_unit);
+ if_free(ifp);
error = ENXIO;
goto fail;
}
@@ -1239,6 +1244,7 @@ sis_attach(device_t dev)
if (error) {
printf("sis%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -1265,13 +1271,14 @@ sis_detach(device_t dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->sis_mtx), ("sis mutex not initialized"));
SIS_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
/* These should only be active if attach succeeded. */
if (device_is_attached(dev)) {
sis_reset(sc);
sis_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->sis_miibus)
device_delete_child(dev, sc->sis_miibus);
@@ -1407,7 +1414,7 @@ sis_rxeof(struct sis_softc *sc)
SIS_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
for(cur_rx = sc->sis_rx_pdsc; SIS_OWNDESC(cur_rx);
cur_rx = cur_rx->sis_nextdesc) {
@@ -1501,7 +1508,7 @@ sis_txeof(struct sis_softc *sc)
u_int32_t idx;
SIS_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
/*
* Go through our tx list and free mbufs for those
@@ -1558,7 +1565,7 @@ sis_tick(void *xsc)
sc = xsc;
SIS_LOCK(sc);
sc->in_tick = 1;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
mii = device_get_softc(sc->sis_miibus);
mii_tick(mii);
@@ -1636,7 +1643,7 @@ sis_intr(void *arg)
u_int32_t status;
sc = arg;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
if (sc->sis_stopped) /* Most likely shared interrupt */
return;
@@ -1853,7 +1860,7 @@ sis_init(void *xsc)
static void
sis_initl(struct sis_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->sis_ifp;
struct mii_data *mii;
SIS_LOCK_ASSERT(sc);
@@ -1880,23 +1887,23 @@ sis_initl(struct sis_softc *sc)
if (sc->sis_type == SIS_TYPE_83815) {
CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR0);
CSR_WRITE_4(sc, SIS_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
+ ((u_int16_t *)IFP2ENADDR(sc->sis_ifp))[0]);
CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR1);
CSR_WRITE_4(sc, SIS_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
+ ((u_int16_t *)IFP2ENADDR(sc->sis_ifp))[1]);
CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR2);
CSR_WRITE_4(sc, SIS_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ ((u_int16_t *)IFP2ENADDR(sc->sis_ifp))[2]);
} else {
CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0);
CSR_WRITE_4(sc, SIS_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
+ ((u_int16_t *)IFP2ENADDR(sc->sis_ifp))[0]);
CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR1);
CSR_WRITE_4(sc, SIS_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
+ ((u_int16_t *)IFP2ENADDR(sc->sis_ifp))[1]);
CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR2);
CSR_WRITE_4(sc, SIS_RXFILT_DATA,
- ((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ ((u_int16_t *)IFP2ENADDR(sc->sis_ifp))[2]);
}
/* Init circular TX/RX lists. */
@@ -2192,7 +2199,7 @@ sis_stop(struct sis_softc *sc)
if (sc->sis_stopped)
return;
SIS_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->sis_ifp;
ifp->if_timer = 0;
callout_stop(&sc->sis_stat_ch);
diff --git a/sys/pci/if_sisreg.h b/sys/pci/if_sisreg.h
index b820924..03ac3cc 100644
--- a/sys/pci/if_sisreg.h
+++ b/sys/pci/if_sisreg.h
@@ -430,7 +430,7 @@ struct sis_mii_frame {
#define SIS_TYPE_83816 4
struct sis_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *sis_ifp; /* interface info */
bus_space_handle_t sis_bhandle;
bus_space_tag_t sis_btag;
struct resource *sis_res;
diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c
index 1703e2f..bcc4b03 100644
--- a/sys/pci/if_sk.c
+++ b/sys/pci/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/pci/if_skreg.h b/sys/pci/if_skreg.h
index 9b91625..e8b6b8a 100644
--- a/sys/pci/if_skreg.h
+++ b/sys/pci/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/pci/if_ste.c b/sys/pci/if_ste.c
index 7c51421..7088ba6 100644
--- a/sys/pci/if_ste.c
+++ b/sys/pci/if_ste.c
@@ -48,6 +48,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>
@@ -564,7 +565,7 @@ ste_setmulti(sc)
u_int32_t hashes[2] = { 0, 0 };
struct ifmultiaddr *ifma;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
STE_SETBIT1(sc, STE_RX_MODE, STE_RXMODE_ALLMULTI);
STE_CLRBIT1(sc, STE_RX_MODE, STE_RXMODE_MULTIHASH);
@@ -661,7 +662,7 @@ ste_intr(xsc)
sc = xsc;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING)
@@ -765,7 +766,7 @@ ste_rxeof(sc)
STE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
while((rxstat = sc->ste_cdata.ste_rx_head->ste_ptr->ste_status)
& STE_RXSTAT_DMADONE) {
@@ -847,7 +848,7 @@ ste_txeoc(sc)
u_int8_t txstat;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
while ((txstat = CSR_READ_1(sc, STE_TX_STATUS)) &
STE_TXSTATUS_TXDONE) {
@@ -887,7 +888,7 @@ ste_txeof(sc)
struct ifnet *ifp;
int idx;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
idx = sc->ste_cdata.ste_tx_cons;
while(idx != sc->ste_cdata.ste_tx_prod) {
@@ -920,7 +921,7 @@ ste_stats_update(xsc)
sc = xsc;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
mii = device_get_softc(sc->ste_miibus);
ifp->if_collisions += CSR_READ_1(sc, STE_LATE_COLLS)
@@ -984,6 +985,7 @@ ste_attach(dev)
struct ste_softc *sc;
struct ifnet *ifp;
int unit, error = 0, rid;
+ u_char eaddr[6];
sc = device_get_softc(dev);
unit = device_get_unit(dev);
@@ -1037,7 +1039,7 @@ ste_attach(dev)
/*
* Get station address from the EEPROM.
*/
- if (ste_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
+ if (ste_read_eeprom(sc, eaddr,
STE_EEADDR_NODE0, 3, 0)) {
printf("ste%d: failed to read station address\n", unit);
error = ENXIO;;
@@ -1066,7 +1068,12 @@ ste_attach(dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("ste%d: can not if_alloc()\n", sc->ste_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1084,7 +1091,7 @@ ste_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/*
* Tell the upper layer(s) we support long frames.
@@ -1103,6 +1110,7 @@ ste_attach(dev)
if (error) {
printf("ste%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -1130,12 +1138,13 @@ ste_detach(dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->ste_mtx), ("ste mutex not initialized"));
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
ste_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->ste_miibus)
device_delete_child(dev, sc->ste_miibus);
@@ -1266,13 +1275,13 @@ ste_init(xsc)
sc = xsc;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
ste_stop(sc);
/* Init our MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- CSR_WRITE_1(sc, STE_PAR0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, STE_PAR0 + i, IFP2ENADDR(sc->ste_ifp)[i]);
}
/* Init RX list */
@@ -1379,7 +1388,7 @@ ste_stop(sc)
struct ifnet *ifp;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
untimeout(ste_stats_update, sc, sc->ste_stat_ch);
ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
diff --git a/sys/pci/if_stereg.h b/sys/pci/if_stereg.h
index 80e8b3d..25bd6ad 100644
--- a/sys/pci/if_stereg.h
+++ b/sys/pci/if_stereg.h
@@ -504,7 +504,7 @@ struct ste_chain_data {
};
struct ste_softc {
- struct arpcom arpcom;
+ struct ifnet *ste_ifp;
bus_space_tag_t ste_btag;
bus_space_handle_t ste_bhandle;
struct resource *ste_res;
diff --git a/sys/pci/if_ti.c b/sys/pci/if_ti.c
index 4af3b29..b6a3a7f 100644
--- a/sys/pci/if_ti.c
+++ b/sys/pci/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/pci/if_tireg.h b/sys/pci/if_tireg.h
index 6e438d4..1bcdfbc 100644
--- a/sys/pci/if_tireg.h
+++ b/sys/pci/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/pci/if_tl.c b/sys/pci/if_tl.c
index 0f70a32..3dde56a 100644
--- a/sys/pci/if_tl.c
+++ b/sys/pci/if_tl.c
@@ -191,6 +191,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>
@@ -523,7 +524,7 @@ static u_int8_t tl_eeprom_getbyte(sc, addr, dest)
{
register int i;
u_int8_t byte = 0;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->tl_ifp;
tl_dio_write8(sc, TL_NETSIO, 0);
@@ -945,7 +946,7 @@ tl_setmulti(sc)
int h, i;
struct ifmultiaddr *ifma;
u_int8_t dummy[] = { 0, 0, 0, 0, 0 ,0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
/* First, zot all the existing filters. */
for (i = 1; i < 4; i++)
@@ -1115,6 +1116,7 @@ tl_attach(dev)
struct ifnet *ifp;
struct tl_softc *sc;
int unit, error = 0, rid;
+ u_char eaddr[6];
vid = pci_get_vendor(dev);
did = pci_get_device(dev);
@@ -1227,8 +1229,7 @@ tl_attach(dev)
/*
* Get station address from the EEPROM.
*/
- if (tl_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
- sc->tl_eeaddr, ETHER_ADDR_LEN)) {
+ if (tl_read_eeprom(sc, eaddr, sc->tl_eeaddr, ETHER_ADDR_LEN)) {
device_printf(dev, "failed to read station address\n");
error = ENXIO;
goto fail;
@@ -1251,12 +1252,17 @@ tl_attach(dev)
if (sc->tl_dinfo->tl_vid == OLICOM_VENDORID) {
for (i = 0; i < ETHER_ADDR_LEN; i += 2) {
u_int16_t *p;
- p = (u_int16_t *)&sc->arpcom.ac_enaddr[i];
+ p = (u_int16_t *)&eaddr[i];
*p = ntohs(*p);
}
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_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_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
@@ -1299,7 +1305,7 @@ tl_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->tl_irq, INTR_TYPE_NET,
@@ -1308,6 +1314,7 @@ tl_attach(dev)
if (error) {
device_printf(dev, "couldn't set up irq\n");
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -1335,12 +1342,13 @@ tl_detach(dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->tl_mtx), ("tl mutex not initialized"));
TL_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
tl_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->tl_miibus)
device_delete_child(dev, sc->tl_miibus);
@@ -1494,7 +1502,7 @@ tl_intvec_rxeof(xsc, type)
struct tl_chain_onefrag *cur_rx;
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
TL_LOCK_ASSERT(sc);
@@ -1528,7 +1536,7 @@ tl_intvec_rxeof(xsc, type)
*/
eh = mtod(m, struct ether_header *);
/*if (ifp->if_flags & IFF_PROMISC && */
- if (!bcmp(eh->ether_shost, sc->arpcom.ac_enaddr,
+ if (!bcmp(eh->ether_shost, IFP2ENADDR(sc->tl_ifp),
ETHER_ADDR_LEN)) {
m_freem(m);
continue;
@@ -1639,7 +1647,7 @@ tl_intvec_txeoc(xsc, type)
u_int32_t cmd;
sc = xsc;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
/* Clear the timeout timer. */
ifp->if_timer = 0;
@@ -1676,7 +1684,7 @@ tl_intvec_adchk(xsc, type)
sc = xsc;
if (type)
- if_printf(&sc->arpcom.ac_if, "adapter check: %x\n",
+ if_printf(sc->tl_ifp, "adapter check: %x\n",
(unsigned int)CSR_READ_4(sc, TL_CH_PARM));
tl_softreset(sc, 1);
@@ -1700,7 +1708,7 @@ tl_intvec_netsts(xsc, type)
netsts = tl_dio_read16(sc, TL_NETSTS);
tl_dio_write16(sc, TL_NETSTS, netsts);
- if_printf(&sc->arpcom.ac_if, "network status: %x\n", netsts);
+ if_printf(sc->tl_ifp, "network status: %x\n", netsts);
return(1);
}
@@ -1726,7 +1734,7 @@ tl_intr(xsc)
ivec = (ints & TL_VEC_MASK) >> 5;
ints = (ints & TL_INT_MASK) >> 2;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
switch(ints) {
case (TL_INTR_INVALID):
@@ -1795,7 +1803,7 @@ tl_stats_update(xsc)
sc = xsc;
TL_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
p = (u_int32_t *)&tl_stats;
@@ -1854,7 +1862,7 @@ tl_encap(sc, c, m_head)
struct tl_frag *f = NULL;
int total_len;
struct mbuf *m;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->tl_ifp;
/*
* Start packing the mbufs in this chain into
@@ -2040,12 +2048,12 @@ tl_init(xsc)
void *xsc;
{
struct tl_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->tl_ifp;
struct mii_data *mii;
TL_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
/*
* Cancel pending I/O.
@@ -2078,7 +2086,7 @@ tl_init(xsc)
tl_dio_write16(sc, TL_MAXRX, MCLBYTES);
/* Init our MAC address */
- tl_setfilt(sc, (caddr_t)&sc->arpcom.ac_enaddr, 0);
+ tl_setfilt(sc, (caddr_t)&IFP2ENADDR(sc->tl_ifp), 0);
/* Init multicast filter, if needed. */
tl_setmulti(sc);
@@ -2273,7 +2281,7 @@ tl_stop(sc)
TL_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->tl_ifp;
/* Stop the stats updater. */
untimeout(tl_stats_update, sc, sc->tl_stat_ch);
diff --git a/sys/pci/if_tlreg.h b/sys/pci/if_tlreg.h
index a8d3128..792ba70 100644
--- a/sys/pci/if_tlreg.h
+++ b/sys/pci/if_tlreg.h
@@ -109,7 +109,7 @@ struct tl_chain_data {
};
struct tl_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *tl_ifp;
struct ifmedia ifmedia; /* media info */
bus_space_handle_t tl_bhandle;
bus_space_tag_t tl_btag;
diff --git a/sys/pci/if_vr.c b/sys/pci/if_vr.c
index 502deb1..23194f7 100644
--- a/sys/pci/if_vr.c
+++ b/sys/pci/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/pci/if_vrreg.h b/sys/pci/if_vrreg.h
index cbf4147..7d42656 100644
--- a/sys/pci/if_vrreg.h
+++ b/sys/pci/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/pci/if_wb.c b/sys/pci/if_wb.c
index 8b460ec..0677fca 100644
--- a/sys/pci/if_wb.c
+++ b/sys/pci/if_wb.c
@@ -100,6 +100,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>
@@ -596,7 +597,7 @@ wb_setmulti(sc)
u_int32_t rxfilt;
int mcnt = 0;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
rxfilt = CSR_READ_4(sc, WB_NETCFG);
@@ -735,7 +736,7 @@ wb_fixmedia(sc)
return;
mii = device_get_softc(sc->wb_miibus);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
mii_pollstat(mii);
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T) {
@@ -834,7 +835,6 @@ wb_attach(dev)
wb_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 0);
sc->wb_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
sc->wb_ldata = contigmalloc(sizeof(struct wb_list_data) + 8, M_DEVBUF,
M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
@@ -847,7 +847,12 @@ wb_attach(dev)
bzero(sc->wb_ldata, sizeof(struct wb_list_data));
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("wb%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;
@@ -881,6 +886,7 @@ wb_attach(dev)
if (error) {
printf("wb%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -908,7 +914,7 @@ wb_detach(dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->wb_mtx), ("wb mutex not initialized"));
WB_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
/*
* Delete any miibus and phy devices attached to this interface.
@@ -917,6 +923,7 @@ wb_detach(dev)
if (device_is_attached(dev)) {
wb_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->wb_miibus)
device_delete_child(dev, sc->wb_miibus);
@@ -1070,7 +1077,7 @@ wb_rxeof(sc)
WB_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
while(!((rxstat = sc->wb_cdata.wb_rx_head->wb_ptr->wb_status) &
WB_RXSTAT_OWN)) {
@@ -1156,7 +1163,7 @@ wb_txeof(sc)
struct wb_chain *cur_tx;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
/* Clear the timeout timer. */
ifp->if_timer = 0;
@@ -1212,7 +1219,7 @@ wb_txeoc(sc)
{
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
ifp->if_timer = 0;
@@ -1240,7 +1247,7 @@ wb_intr(arg)
sc = arg;
WB_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
if (!(ifp->if_flags & IFF_UP)) {
WB_UNLOCK(sc);
@@ -1535,7 +1542,7 @@ wb_init(xsc)
void *xsc;
{
struct wb_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->wb_ifp;
int i;
struct mii_data *mii;
@@ -1582,7 +1589,7 @@ wb_init(xsc)
/* Init our MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- CSR_WRITE_1(sc, WB_NODE0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, WB_NODE0 + i, IFP2ENADDR(sc->wb_ifp)[i]);
}
/* Init circular RX list. */
@@ -1770,7 +1777,7 @@ wb_stop(sc)
struct ifnet *ifp;
WB_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->wb_ifp;
ifp->if_timer = 0;
untimeout(wb_tick, sc, sc->wb_stat_ch);
diff --git a/sys/pci/if_wbreg.h b/sys/pci/if_wbreg.h
index 82bd081..3f640a2 100644
--- a/sys/pci/if_wbreg.h
+++ b/sys/pci/if_wbreg.h
@@ -362,7 +362,7 @@ struct wb_mii_frame {
#define WB_MII_TURNAROUND 0x02
struct wb_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *wb_ifp; /* interface info */
device_t wb_miibus;
bus_space_handle_t wb_bhandle;
bus_space_tag_t wb_btag;
diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c
index 272b70b..f869af2 100644
--- a/sys/pci/if_xl.c
+++ b/sys/pci/if_xl.c
@@ -116,6 +116,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>
@@ -386,7 +387,7 @@ xl_wait(struct xl_softc *sc)
}
if (i == XL_TIMEOUT)
- if_printf(&sc->arpcom.ac_if, "command never completed!\n");
+ if_printf(sc->xl_ifp, "command never completed!\n");
}
/*
@@ -659,7 +660,7 @@ xl_miibus_mediainit(device_t dev)
if (sc->xl_type == XL_TYPE_905B &&
sc->xl_media == XL_MEDIAOPT_10FL) {
if (bootverbose)
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"found 10baseFL\n");
ifmedia_add(ifm, IFM_ETHER | IFM_10_FL, 0, NULL);
ifmedia_add(ifm, IFM_ETHER | IFM_10_FL|IFM_HDX, 0,
@@ -669,14 +670,14 @@ xl_miibus_mediainit(device_t dev)
IFM_ETHER | IFM_10_FL | IFM_FDX, 0, NULL);
} else {
if (bootverbose)
- if_printf(&sc->arpcom.ac_if, "found AUI\n");
+ if_printf(sc->xl_ifp, "found AUI\n");
ifmedia_add(ifm, IFM_ETHER | IFM_10_5, 0, NULL);
}
}
if (sc->xl_media & XL_MEDIAOPT_BNC) {
if (bootverbose)
- if_printf(&sc->arpcom.ac_if, "found BNC\n");
+ if_printf(sc->xl_ifp, "found BNC\n");
ifmedia_add(ifm, IFM_ETHER | IFM_10_2, 0, NULL);
}
}
@@ -698,7 +699,7 @@ xl_eeprom_wait(struct xl_softc *sc)
}
if (i == 100) {
- if_printf(&sc->arpcom.ac_if, "eeprom failed to come ready\n");
+ if_printf(sc->xl_ifp, "eeprom failed to come ready\n");
return (1);
}
@@ -760,7 +761,7 @@ xl_read_eeprom(struct xl_softc *sc, caddr_t dest, int off, int cnt, int swap)
static void
xl_setmulti(struct xl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
struct ifmultiaddr *ifma;
u_int8_t rxfilt;
int mcnt = 0;
@@ -793,7 +794,7 @@ xl_setmulti(struct xl_softc *sc)
static void
xl_setmulti_hash(struct xl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
int h = 0, i;
struct ifmultiaddr *ifma;
u_int8_t rxfilt;
@@ -851,16 +852,16 @@ static void
xl_testpacket(struct xl_softc *sc)
{
struct mbuf *m;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return;
- bcopy(&sc->arpcom.ac_enaddr,
+ bcopy(&IFP2ENADDR(sc->xl_ifp),
mtod(m, struct ether_header *)->ether_dhost, ETHER_ADDR_LEN);
- bcopy(&sc->arpcom.ac_enaddr,
+ bcopy(&IFP2ENADDR(sc->xl_ifp),
mtod(m, struct ether_header *)->ether_shost, ETHER_ADDR_LEN);
mtod(m, struct ether_header *)->ether_type = htons(3);
mtod(m, unsigned char *)[14] = 0;
@@ -985,7 +986,7 @@ xl_setmode(struct xl_softc *sc, int media)
DELAY(800);
XL_SEL_WIN(7);
- if_printf(&sc->arpcom.ac_if, "selecting %s, %s duplex\n", pmsg, dmsg);
+ if_printf(sc->xl_ifp, "selecting %s, %s duplex\n", pmsg, dmsg);
}
static void
@@ -1017,7 +1018,7 @@ xl_reset(struct xl_softc *sc)
}
if (i == XL_TIMEOUT)
- if_printf(&sc->arpcom.ac_if, "reset didn't complete\n");
+ if_printf(sc->xl_ifp, "reset didn't complete\n");
/* Reset TX and RX. */
/* Note: the RX reset takes an absurd amount of time
@@ -1102,20 +1103,20 @@ xl_mediacheck(struct xl_softc *sc)
if (sc->xl_xcvr <= XL_XCVR_AUTO)
return;
else {
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"bogus xcvr value in EEPROM (%x)\n", sc->xl_xcvr);
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"choosing new default based on card type\n");
}
} else {
if (sc->xl_type == XL_TYPE_905B &&
sc->xl_media & XL_MEDIAOPT_10FL)
return;
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"WARNING: no media options bits set in the media options register!!\n");
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"this could be a manufacturing defect in your adapter or system\n");
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"attempting to guess media type; you should probably consult your vendor\n");
}
@@ -1140,7 +1141,7 @@ xl_choose_xcvr(struct xl_softc *sc, int verbose)
sc->xl_media = XL_MEDIAOPT_BT;
sc->xl_xcvr = XL_XCVR_10BT;
if (verbose)
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"guessing 10BaseT transceiver\n");
break;
case TC_DEVICEID_BOOMERANG_10BT_COMBO: /* 3c900-COMBO */
@@ -1148,20 +1149,20 @@ xl_choose_xcvr(struct xl_softc *sc, int verbose)
sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
sc->xl_xcvr = XL_XCVR_10BT;
if (verbose)
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"guessing COMBO (AUI/BNC/TP)\n");
break;
case TC_DEVICEID_KRAKATOA_10BT_TPC: /* 3c900B-TPC */
sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC;
sc->xl_xcvr = XL_XCVR_10BT;
if (verbose)
- if_printf(&sc->arpcom.ac_if, "guessing TPC (BNC/TP)\n");
+ if_printf(sc->xl_ifp, "guessing TPC (BNC/TP)\n");
break;
case TC_DEVICEID_CYCLONE_10FL: /* 3c900B-FL */
sc->xl_media = XL_MEDIAOPT_10FL;
sc->xl_xcvr = XL_XCVR_AUI;
if (verbose)
- if_printf(&sc->arpcom.ac_if, "guessing 10baseFL\n");
+ if_printf(sc->xl_ifp, "guessing 10baseFL\n");
break;
case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */
case TC_DEVICEID_HURRICANE_555: /* 3c555 */
@@ -1178,14 +1179,14 @@ xl_choose_xcvr(struct xl_softc *sc, int verbose)
sc->xl_media = XL_MEDIAOPT_MII;
sc->xl_xcvr = XL_XCVR_MII;
if (verbose)
- if_printf(&sc->arpcom.ac_if, "guessing MII\n");
+ if_printf(sc->xl_ifp, "guessing MII\n");
break;
case TC_DEVICEID_BOOMERANG_100BT4: /* 3c905-T4 */
case TC_DEVICEID_CYCLONE_10_100BT4: /* 3c905B-T4 */
sc->xl_media = XL_MEDIAOPT_BT4;
sc->xl_xcvr = XL_XCVR_MII;
if (verbose)
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"guessing 100baseT4/MII\n");
break;
case TC_DEVICEID_HURRICANE_10_100BT: /* 3c905B-TX */
@@ -1197,18 +1198,18 @@ xl_choose_xcvr(struct xl_softc *sc, int verbose)
sc->xl_media = XL_MEDIAOPT_BTX;
sc->xl_xcvr = XL_XCVR_AUTO;
if (verbose)
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"guessing 10/100 internal\n");
break;
case TC_DEVICEID_CYCLONE_10_100_COMBO: /* 3c905B-COMBO */
sc->xl_media = XL_MEDIAOPT_BTX|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
sc->xl_xcvr = XL_XCVR_AUTO;
if (verbose)
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"guessing 10/100 plus BNC/AUI\n");
break;
default:
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"unknown device ID: %x -- defaulting to 10baseT\n", devid);
sc->xl_media = XL_MEDIAOPT_BT;
break;
@@ -1345,7 +1346,12 @@ xl_attach(device_t dev)
}
/* Initialize interface name. */
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->xl_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));
@@ -1369,7 +1375,6 @@ xl_attach(device_t dev)
sc->xl_unit = unit;
callout_handle_init(&sc->xl_stat_ch);
TASK_INIT(&sc->xl_task, 0, xl_rxeof_task, sc);
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/*
* Now allocate a tag for the DMA descriptor lists and a chunk
@@ -1620,6 +1625,7 @@ done:
if (error) {
device_printf(dev, "couldn't set up irq\n");
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -1669,7 +1675,7 @@ xl_choose_media(struct xl_softc *sc, int *media)
*media = IFM_ETHER|IFM_100_FX;
break;
default:
- if_printf(&sc->arpcom.ac_if, "unknown XCVR type: %d\n",
+ if_printf(sc->xl_ifp, "unknown XCVR type: %d\n",
sc->xl_xcvr);
/*
* This will probably be wrong, but it prevents
@@ -1697,7 +1703,7 @@ xl_detach(device_t dev)
int rid, res;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->xl_ifp;
KASSERT(mtx_initialized(&sc->xl_mtx), ("xl mutex not initialized"));
XL_LOCK(sc);
@@ -1715,6 +1721,7 @@ xl_detach(device_t dev)
xl_reset(sc);
xl_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->xl_miibus)
device_delete_child(dev, sc->xl_miibus);
@@ -1907,7 +1914,7 @@ xl_newbuf(struct xl_softc *sc, struct xl_chain_onefrag *c)
xl_dma_map_rxbuf, &baddr, BUS_DMA_NOWAIT);
if (error) {
m_freem(m_new);
- if_printf(&sc->arpcom.ac_if, "can't map mbuf (error %d)\n",
+ if_printf(sc->xl_ifp, "can't map mbuf (error %d)\n",
error);
return (error);
}
@@ -1956,7 +1963,7 @@ static void
xl_rxeof(struct xl_softc *sc)
{
struct mbuf *m;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
struct xl_chain_onefrag *cur_rx;
int total_len = 0;
u_int32_t rxstat;
@@ -2106,7 +2113,7 @@ static void
xl_txeof(struct xl_softc *sc)
{
struct xl_chain *cur_tx;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
XL_LOCK_ASSERT(sc);
@@ -2157,7 +2164,7 @@ static void
xl_txeof_90xB(struct xl_softc *sc)
{
struct xl_chain *cur_tx = NULL;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
int idx;
XL_LOCK_ASSERT(sc);
@@ -2210,7 +2217,7 @@ xl_txeoc(struct xl_softc *sc)
if (txstat & XL_TXSTATUS_UNDERRUN ||
txstat & XL_TXSTATUS_JABBER ||
txstat & XL_TXSTATUS_RECLAIM) {
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"transmission error: %x\n", txstat);
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET);
xl_wait(sc);
@@ -2238,7 +2245,7 @@ xl_txeoc(struct xl_softc *sc)
if (txstat & XL_TXSTATUS_UNDERRUN &&
sc->xl_tx_thresh < XL_PACKET_SIZE) {
sc->xl_tx_thresh += XL_MIN_FRAMELEN;
- if_printf(&sc->arpcom.ac_if,
+ if_printf(sc->xl_ifp,
"tx underrun, increasing tx start threshold to %d bytes\n", sc->xl_tx_thresh);
}
CSR_WRITE_2(sc, XL_COMMAND,
@@ -2265,7 +2272,7 @@ static void
xl_intr(void *arg)
{
struct xl_softc *sc = arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
u_int16_t status;
XL_LOCK(sc);
@@ -2431,7 +2438,7 @@ xl_stats_update(void *xsc)
static void
xl_stats_update_locked(struct xl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
struct xl_stats xl_stats;
u_int8_t *p;
int i;
@@ -2484,7 +2491,7 @@ xl_encap(struct xl_softc *sc, struct xl_chain *c, struct mbuf *m_head)
{
int error;
u_int32_t status;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
XL_LOCK_ASSERT(sc);
@@ -2794,7 +2801,7 @@ xl_init(void *xsc)
static void
xl_init_locked(struct xl_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
int error, i;
u_int16_t rxfilt = 0;
struct mii_data *mii = NULL;
@@ -2821,7 +2828,7 @@ xl_init_locked(struct xl_softc *sc)
XL_SEL_WIN(2);
for (i = 0; i < ETHER_ADDR_LEN; i++) {
CSR_WRITE_1(sc, XL_W2_STATION_ADDR_LO + i,
- sc->arpcom.ac_enaddr[i]);
+ IFP2ENADDR(sc->xl_ifp)[i]);
}
/* Clear the station mask. */
@@ -3259,7 +3266,7 @@ static void
xl_stop(struct xl_softc *sc)
{
register int i;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->xl_ifp;
XL_LOCK_ASSERT(sc);
@@ -3367,7 +3374,7 @@ xl_resume(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->xl_ifp;
XL_LOCK(sc);
diff --git a/sys/pci/if_xlreg.h b/sys/pci/if_xlreg.h
index 6b2829f..d1d2e8f 100644
--- a/sys/pci/if_xlreg.h
+++ b/sys/pci/if_xlreg.h
@@ -580,7 +580,7 @@ struct xl_mii_frame {
#define XL_NO_XCVR_PWR_MAGICBITS 0x0900
struct xl_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *xl_ifp; /* interface info */
struct ifmedia ifmedia; /* media info */
bus_space_handle_t xl_bhandle;
bus_space_tag_t xl_btag;
diff --git a/sys/sys/param.h b/sys/sys/param.h
index fbf49d4..a3853cd 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -57,7 +57,7 @@
* is created, otherwise 1.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 600030 /* Master, propagated to newvers */
+#define __FreeBSD_version 600031 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>
OpenPOWER on IntegriCloud