diff -ruN --exclude=compile freebsd/sys/compat/ndis/kern_ndis.c ifnet/sys/compat/ndis/kern_ndis.c --- freebsd/sys/compat/ndis/kern_ndis.c Tue May 24 17:11:24 2005 +++ ifnet/sys/compat/ndis/kern_ndis.c Sat Jun 4 11:15:34 2005 @@ -231,7 +231,7 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/compat/ndis/subr_ndis.c ifnet/sys/compat/ndis/subr_ndis.c --- freebsd/sys/compat/ndis/subr_ndis.c Sun Jun 5 06:11:00 2005 +++ ifnet/sys/compat/ndis/subr_ndis.c Tue Jun 7 16:40:02 2005 @@ -1058,7 +1058,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/contrib/altq/altq/altq_rio.c ifnet/sys/contrib/altq/altq/altq_rio.c --- freebsd/sys/contrib/altq/altq/altq_rio.c Mon Jun 14 22:09:08 2004 +++ ifnet/sys/contrib/altq/altq/altq_rio.c Tue Apr 5 22:52:08 2005 @@ -331,7 +331,7 @@ * 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 -ruN --exclude=compile freebsd/sys/contrib/dev/oltr/if_oltr.c ifnet/sys/contrib/dev/oltr/if_oltr.c --- freebsd/sys/contrib/dev/oltr/if_oltr.c Fri Feb 4 22:42:35 2005 +++ ifnet/sys/contrib/dev/oltr/if_oltr.c Tue Jun 7 16:40:03 2005 @@ -44,6 +44,7 @@ #include #include #include +#include #include #ifndef BPF_MTAP @@ -131,9 +132,15 @@ { 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/contrib/dev/oltr/if_oltr_pci.c ifnet/sys/contrib/dev/oltr/if_oltr_pci.c --- freebsd/sys/contrib/dev/oltr/if_oltr_pci.c Fri Feb 4 22:42:35 2005 +++ ifnet/sys/contrib/dev/oltr/if_oltr_pci.c Fri Jun 3 19:40:47 2005 @@ -233,7 +233,7 @@ 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 @@ s = splimp(); iso88025_ifdetach(ifp, ISO88025_BPF_SUPPORTED); + if_free(ifp); if (sc->state > OL_CLOSED) oltr_stop(sc); diff -ruN --exclude=compile freebsd/sys/contrib/dev/oltr/if_oltrvar.h ifnet/sys/contrib/dev/oltr/if_oltrvar.h --- freebsd/sys/contrib/dev/oltr/if_oltrvar.h Fri Feb 4 22:42:35 2005 +++ ifnet/sys/contrib/dev/oltr/if_oltrvar.h Fri Jun 3 19:40:47 2005 @@ -68,7 +68,7 @@ #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 -ruN --exclude=compile freebsd/sys/contrib/pf/net/if_pflog.c ifnet/sys/contrib/pf/net/if_pflog.c --- freebsd/sys/contrib/pf/net/if_pflog.c Tue May 24 17:11:35 2005 +++ ifnet/sys/contrib/pf/net/if_pflog.c Tue May 24 17:15:30 2005 @@ -127,7 +127,7 @@ #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 @@ bpfdetach(ifp); if_detach(ifp); + if_free(ifp); LIST_REMOVE(sc, sc_next); free(sc, M_PFLOG); } @@ -155,14 +156,17 @@ 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 -ruN --exclude=compile freebsd/sys/contrib/pf/net/if_pflog.h ifnet/sys/contrib/pf/net/if_pflog.h --- freebsd/sys/contrib/pf/net/if_pflog.h Tue May 24 17:11:35 2005 +++ ifnet/sys/contrib/pf/net/if_pflog.h Tue May 24 17:15:30 2005 @@ -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 -ruN --exclude=compile freebsd/sys/contrib/pf/net/if_pfsync.c ifnet/sys/contrib/pf/net/if_pfsync.c --- freebsd/sys/contrib/pf/net/if_pfsync.c Tue May 24 17:11:36 2005 +++ ifnet/sys/contrib/pf/net/if_pfsync.c Tue May 24 17:15:30 2005 @@ -161,7 +161,7 @@ #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 @@ bpfdetach(ifp); #endif if_detach(ifp); + if_free(ifp); LIST_REMOVE(sc, sc_next); free(sc, M_PFSYNC); } @@ -190,6 +191,11 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/contrib/pf/net/if_pfsync.h ifnet/sys/contrib/pf/net/if_pfsync.h --- freebsd/sys/contrib/pf/net/if_pfsync.h Tue May 24 17:11:36 2005 +++ ifnet/sys/contrib/pf/net/if_pfsync.h Tue May 24 17:15:31 2005 @@ -147,7 +147,11 @@ 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 -ruN --exclude=compile freebsd/sys/dev/acpica/acpivar.h ifnet/sys/dev/acpica/acpivar.h diff -ruN --exclude=compile freebsd/sys/dev/an/if_an.c ifnet/sys/dev/an/if_an.c --- freebsd/sys/dev/an/if_an.c Sat Apr 2 19:30:19 2005 +++ ifnet/sys/dev/an/if_an.c Tue Jun 7 16:40:05 2005 @@ -669,14 +669,19 @@ 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 @@ } #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 @@ /* * 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/an/if_anreg.h ifnet/sys/dev/an/if_anreg.h --- freebsd/sys/dev/an/if_anreg.h Thu Jan 6 22:23:52 2005 +++ ifnet/sys/dev/an/if_anreg.h Tue May 24 17:15:41 2005 @@ -440,7 +440,7 @@ }; struct an_softc { - struct arpcom arpcom; + struct ifnet *an_ifp; int an_unit; diff -ruN --exclude=compile freebsd/sys/dev/ar/if_ar.c ifnet/sys/dev/ar/if_ar.c --- freebsd/sys/dev/ar/if_ar.c Sun Jun 5 06:11:15 2005 +++ ifnet/sys/dev/ar/if_ar.c Sat Jun 4 11:15:37 2005 @@ -68,6 +68,7 @@ #include #else /* NETGRAPH */ #include +#include #include #endif /* NETGRAPH */ @@ -90,7 +91,7 @@ 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 @@ u_long opackets, ipackets; #endif /* NETGRAPH */ }; +#define SC2IFP(sc) (sc)->ifp static int next_ar_unit = 0; @@ -281,7 +283,14 @@ 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 @@ 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 @@ 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 @@ 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 @@ #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 @@ 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 @@ 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_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_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 @@ "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 @@ "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 @@ 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 @@ */ 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 @@ /* 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 @@ "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 @@ "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_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 @@ "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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/arl/if_arl.c ifnet/sys/dev/arl/if_arl.c --- freebsd/sys/dev/arl/if_arl.c Wed Aug 25 12:11:04 2004 +++ ifnet/sys/dev/arl/if_arl.c Tue Jun 7 16:40:05 2005 @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -109,7 +110,7 @@ #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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/arl/if_arl_isa.c ifnet/sys/dev/arl/if_arl_isa.c --- freebsd/sys/dev/arl/if_arl_isa.c Wed Aug 25 12:11:04 2004 +++ ifnet/sys/dev/arl/if_arl_isa.c Tue Jun 7 16:40:06 2005 @@ -275,8 +275,6 @@ } 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 @@ } #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_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 -ruN --exclude=compile freebsd/sys/dev/arl/if_arlreg.h ifnet/sys/dev/arl/if_arlreg.h --- freebsd/sys/dev/arl/if_arlreg.h Wed Aug 25 12:11:04 2004 +++ ifnet/sys/dev/arl/if_arlreg.h Fri Jun 3 19:40:49 2005 @@ -281,7 +281,7 @@ #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 -ruN --exclude=compile freebsd/sys/dev/ath/ath_rate/amrr/amrr.c ifnet/sys/dev/ath/ath_rate/amrr/amrr.c --- freebsd/sys/dev/ath/ath_rate/amrr/amrr.c Sat Apr 2 19:30:32 2005 +++ ifnet/sys/dev/ath/ath_rate/amrr/amrr.c Tue May 24 17:16:16 2005 @@ -376,7 +376,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ath/ath_rate/onoe/onoe.c ifnet/sys/dev/ath/ath_rate/onoe/onoe.c --- freebsd/sys/dev/ath/ath_rate/onoe/onoe.c Sat Apr 2 19:30:32 2005 +++ ifnet/sys/dev/ath/ath_rate/onoe/onoe.c Tue May 24 17:16:16 2005 @@ -360,7 +360,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ath/if_ath.c ifnet/sys/dev/ath/if_ath.c --- freebsd/sys/dev/ath/if_ath.c Tue Jun 7 22:46:02 2005 +++ ifnet/sys/dev/ath/if_ath.c Tue Jun 7 22:47:11 2005 @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -228,7 +229,7 @@ }; #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_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 @@ 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 @@ bad: if (ah) ath_hal_detach(ah); + if (ifp != NULL) + if_free(ifp); sc->sc_invalid = 1; return error; } @@ -598,7 +608,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ { 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 @@ { 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 @@ * * 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 @@ 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); @@ -2190,7 +2200,7 @@ { #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; @@ -2580,7 +2590,7 @@ 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; @@ -3106,7 +3116,7 @@ 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; @@ -3687,7 +3697,7 @@ 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); @@ -3708,7 +3718,7 @@ 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. @@ -3735,7 +3745,7 @@ 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; /* @@ -3817,7 +3827,7 @@ 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 */ @@ -4041,7 +4051,7 @@ * 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, @@ -4248,7 +4258,7 @@ 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; @@ -4637,7 +4647,7 @@ * 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; @@ -4673,7 +4683,7 @@ 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) @@ -4793,7 +4803,7 @@ 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; @@ -4886,7 +4896,7 @@ 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), @@ -4916,7 +4926,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ath/if_athvar.h ifnet/sys/dev/ath/if_athvar.h --- freebsd/sys/dev/ath/if_athvar.h Tue Jun 7 22:46:02 2005 +++ ifnet/sys/dev/ath/if_athvar.h Tue Jun 7 22:47:11 2005 @@ -172,7 +172,7 @@ } 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 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 -ruN --exclude=compile freebsd/sys/dev/awi/awi.c ifnet/sys/dev/awi/awi.c --- freebsd/sys/dev/awi/awi.c Thu Mar 17 10:54:52 2005 +++ ifnet/sys/dev/awi/awi.c Tue May 24 17:16:20 2005 @@ -258,7 +258,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { struct awi_softc *sc = arg; - (void)awi_init(&sc->sc_if); + (void)awi_init(AC2IFP(&sc->sc_arp)); } #endif @@ -1125,7 +1125,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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_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 @@ 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 @@ (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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/awi/awivar.h ifnet/sys/dev/awi/awivar.h --- freebsd/sys/dev/awi/awivar.h Wed Jan 5 00:00:32 2005 +++ ifnet/sys/dev/awi/awivar.h Thu Feb 3 22:22:19 2005 @@ -79,7 +79,6 @@ #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 -ruN --exclude=compile freebsd/sys/dev/bfe/if_bfe.c ifnet/sys/dev/bfe/if_bfe.c --- freebsd/sys/dev/bfe/if_bfe.c Sun Jun 5 13:33:11 2005 +++ ifnet/sys/dev/bfe/if_bfe.c Tue Jun 7 16:40:11 2005 @@ -322,7 +322,7 @@ 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 @@ } /* 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 @@ 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 @@ goto fail; } fail: - if(error) + if(error) { bfe_release_resources(sc); + if (ifp != NULL) + if_free(ifp); + } return (error); } @@ -438,11 +446,12 @@ 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_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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/bfe/if_bfereg.h ifnet/sys/dev/bfe/if_bfereg.h --- freebsd/sys/dev/bfe/if_bfereg.h Thu Jan 6 22:24:00 2005 +++ ifnet/sys/dev/bfe/if_bfereg.h Tue Jun 7 16:40:11 2005 @@ -491,7 +491,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/bge/if_bge.c ifnet/sys/dev/bge/if_bge.c --- freebsd/sys/dev/bge/if_bge.c Sun Jun 5 06:11:21 2005 +++ ifnet/sys/dev/bge/if_bge.c Tue Jun 7 16:40:14 2005 @@ -1156,7 +1156,7 @@ 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 @@ /* 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 @@ 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 @@ /* * 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 @@ 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 @@ 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 @@ /* * 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_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 @@ 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_UNLOCK(sc); ether_ifdetach(ifp); + if_free(ifp); if (sc->bge_tbi) { ifmedia_removeall(&sc->bge_ifmedia); @@ -2708,7 +2717,7 @@ 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_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 @@ u_int32_t status, mimode; sc = xsc; - ifp = &sc->arpcom.ac_if; + ifp = sc->bge_ifp; BGE_LOCK(sc); @@ -3014,7 +3023,7 @@ struct ifmedia *ifm = NULL; struct ifnet *ifp; - ifp = &sc->arpcom.ac_if; + ifp = sc->bge_ifp; BGE_LOCK_ASSERT(sc); @@ -3084,7 +3093,7 @@ 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 @@ 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 @@ 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_LOCK_ASSERT(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->bge_ifp; if (ifp->if_flags & IFF_RUNNING) return; @@ -3336,14 +3345,14 @@ 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_LOCK_ASSERT(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->bge_ifp; if (!sc->bge_tbi) mii = device_get_softc(sc->bge_miibus); diff -ruN --exclude=compile freebsd/sys/dev/bge/if_bgereg.h ifnet/sys/dev/bge/if_bgereg.h --- freebsd/sys/dev/bge/if_bgereg.h Tue May 24 17:11:56 2005 +++ ifnet/sys/dev/bge/if_bgereg.h Tue Jun 7 12:18:49 2005 @@ -2313,7 +2313,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/cm/if_cm_isa.c ifnet/sys/dev/cm/if_cm_isa.c --- freebsd/sys/dev/cm/if_cm_isa.c Tue Nov 4 13:44:57 2003 +++ ifnet/sys/dev/cm/if_cm_isa.c Tue May 24 17:16:23 2005 @@ -103,14 +103,15 @@ 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 -ruN --exclude=compile freebsd/sys/dev/cm/smc90cx6.c ifnet/sys/dev/cm/smc90cx6.c --- freebsd/sys/dev/cm/smc90cx6.c Wed Aug 25 12:11:19 2004 +++ ifnet/sys/dev/cm/smc90cx6.c Tue May 24 17:16:24 2005 @@ -277,10 +277,15 @@ 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 @@ 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 @@ 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 @@ GETREG(CMRESET); /* Stop watchdog timer */ - sc->sc_arccom.ac_if.if_timer = 0; + sc->sc_ifp->if_timer = 0; } /* @@ -589,7 +594,7 @@ 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 @@ 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 @@ int clknow; #endif - ifp = &(sc->sc_arccom.ac_if); + ifp = sc->sc_ifp; buffer = sc->sc_tx_act; /* @@ -744,7 +749,7 @@ */ 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 @@ 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 @@ /* * 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 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/cm/smc90cx6var.h ifnet/sys/dev/cm/smc90cx6var.h --- freebsd/sys/dev/cm/smc90cx6var.h Tue Nov 4 13:44:57 2003 +++ ifnet/sys/dev/cm/smc90cx6var.h Tue May 24 17:16:24 2005 @@ -56,7 +56,7 @@ #include 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 -ruN --exclude=compile freebsd/sys/dev/cnw/if_cnw.c ifnet/sys/dev/cnw/if_cnw.c --- freebsd/sys/dev/cnw/if_cnw.c Sun Jun 5 06:11:29 2005 +++ ifnet/sys/dev/cnw/if_cnw.c Tue Jun 7 16:40:16 2005 @@ -288,7 +288,7 @@ #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 @@ #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 @@ #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 @@ #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 @@ #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 @@ 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 @@ cnw_reset(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->sc_ifp; ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); return; @@ -1571,7 +1571,7 @@ #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 @@ cnw_stop(sc); ether_ifdetach(ifp); + if_free(ifp); cnw_free(dev); sc->cnw_gone = 1; @@ -1595,9 +1596,15 @@ 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 @@ /* 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 @@ /* * 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 -ruN --exclude=compile freebsd/sys/dev/cp/if_cp.c ifnet/sys/dev/cp/if_cp.c --- freebsd/sys/dev/cp/if_cp.c Thu Mar 17 10:56:02 2005 +++ ifnet/sys/dev/cp/if_cp.c Fri Jun 3 19:40:50 2005 @@ -56,6 +56,8 @@ # include #else # include +# include +#include # define PP_CISCO IFF_LINK2 # include #endif @@ -135,7 +137,7 @@ struct callout timeout_handle; #else struct ifqueue queue; - struct sppp pp; + struct ifnet *ifp; #endif struct cdev *devt; } drv_t; @@ -329,7 +331,7 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ #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 @@ #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 @@ 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 @@ 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 @@ 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 @@ #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 @@ #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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/cs/if_cs.c ifnet/sys/dev/cs/if_cs.c --- freebsd/sys/dev/cs/if_cs.c Fri Jan 28 11:39:37 2005 +++ ifnet/sys/dev/cs/if_cs.c Tue Jun 7 16:40:17 2005 @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -196,7 +197,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ (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 @@ (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 @@ eeprom_buff[ISA_CNF_OFFSET/2]; for (i=0; iarpcom.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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ /* Write MAC address into IA filter */ for (i=0; iarpcom.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 @@ /* * 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 @@ 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 @@ 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_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 @@ 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 @@ * 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 @@ ~(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 -ruN --exclude=compile freebsd/sys/dev/cs/if_csvar.h ifnet/sys/dev/cs/if_csvar.h --- freebsd/sys/dev/cs/if_csvar.h Fri Jan 28 11:39:37 2005 +++ ifnet/sys/dev/cs/if_csvar.h Tue Jun 7 16:40:17 2005 @@ -36,13 +36,15 @@ */ struct cs_softc { /* Ethernet common code */ - struct arpcom arpcom; + struct ifnet *ifp; /* Configuration words from EEPROM */ int auto_neg_cnf; /* AutoNegotitation configuration */ int adapter_cnf; /* Adapter configuration */ int isa_config; /* ISA configuration */ int chip_type; /* Type of chip */ + + u_char enaddr[6]; struct ifmedia media; /* Media information */ diff -ruN --exclude=compile freebsd/sys/dev/ctau/if_ct.c ifnet/sys/dev/ctau/if_ct.c --- freebsd/sys/dev/ctau/if_ct.c Thu Mar 17 10:56:10 2005 +++ ifnet/sys/dev/ctau/if_ct.c Fri Jun 3 19:40:51 2005 @@ -137,7 +137,7 @@ struct callout timeout_handle; #else struct ifqueue queue; - struct sppp pp; + struct ifnet *ifp; #endif struct cdev *devt; } drv_t; @@ -291,7 +291,7 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ #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 @@ #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 @@ 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 @@ 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 @@ 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 @@ #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 @@ #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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/cx/if_cx.c ifnet/sys/dev/cx/if_cx.c --- freebsd/sys/dev/cx/if_cx.c Thu Jan 6 22:24:21 2005 +++ ifnet/sys/dev/cx/if_cx.c Fri Jun 3 19:40:52 2005 @@ -162,7 +162,7 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ #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 @@ #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 @@ 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 @@ 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 @@ } #ifndef NETGRAPH else - ++d->pp.pp_if.if_ierrors; + ++d->ifp->if_ierrors; #endif break; case CX_CRC: @@ -1385,7 +1395,7 @@ } #ifndef NETGRAPH else - ++d->pp.pp_if.if_ierrors; + ++d->ifp->if_ierrors; #endif break; case CX_OVERRUN: @@ -1402,8 +1412,8 @@ #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 @@ 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 @@ #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 @@ } #ifndef NETGRAPH else - ++d->pp.pp_if.if_ierrors; + ++d->ifp->if_ierrors; #endif break; default: @@ -1625,8 +1635,8 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed.c ifnet/sys/dev/ed/if_ed.c --- freebsd/sys/dev/ed/if_ed.c Thu Mar 17 10:56:16 2005 +++ ifnet/sys/dev/ed/if_ed.c Tue Jun 7 16:40:18 2005 @@ -60,6 +60,7 @@ #include #include #include +#include #ifndef ED_NO_MIIBUS #include @@ -254,7 +255,13 @@ 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 @@ /* * 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_3c503.c ifnet/sys/dev/ed/if_ed_3c503.c --- freebsd/sys/dev/ed/if_ed_3c503.c Thu Mar 17 10:56:16 2005 +++ ifnet/sys/dev/ed/if_ed_3c503.c Tue Jun 7 16:40:18 2005 @@ -198,7 +198,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_cbus.c ifnet/sys/dev/ed/if_ed_cbus.c --- freebsd/sys/dev/ed/if_ed_cbus.c Thu Mar 17 10:56:17 2005 +++ ifnet/sys/dev/ed/if_ed_cbus.c Tue Jun 7 16:40:18 2005 @@ -774,15 +774,13 @@ 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 @@ */ 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 @@ /* * 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_hpp.c ifnet/sys/dev/ed/if_ed_hpp.c --- freebsd/sys/dev/ed/if_ed_hpp.c Thu Mar 17 10:56:17 2005 +++ ifnet/sys/dev/ed/if_ed_hpp.c Tue Jun 7 16:40:19 2005 @@ -149,7 +149,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_isa.c ifnet/sys/dev/ed/if_ed_isa.c --- freebsd/sys/dev/ed/if_ed_isa.c Thu Mar 17 10:56:18 2005 +++ ifnet/sys/dev/ed/if_ed_isa.c Tue Jun 7 16:40:19 2005 @@ -81,7 +81,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_novell.c ifnet/sys/dev/ed/if_ed_novell.c --- freebsd/sys/dev/ed/if_ed_novell.c Thu Mar 17 10:56:18 2005 +++ ifnet/sys/dev/ed/if_ed_novell.c Tue Jun 7 16:40:19 2005 @@ -293,5 +293,5 @@ */ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_pccard.c ifnet/sys/dev/ed/if_ed_pccard.c --- freebsd/sys/dev/ed/if_ed_pccard.c Thu Mar 17 10:56:19 2005 +++ ifnet/sys/dev/ed/if_ed_pccard.c Tue Jun 7 16:40:19 2005 @@ -337,7 +337,7 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_sic.c ifnet/sys/dev/ed/if_ed_sic.c --- freebsd/sys/dev/ed/if_ed_sic.c Thu Mar 17 10:56:19 2005 +++ ifnet/sys/dev/ed/if_ed_sic.c Tue Jun 7 16:40:19 2005 @@ -107,15 +107,14 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_ed_wd80x3.c ifnet/sys/dev/ed/if_ed_wd80x3.c --- freebsd/sys/dev/ed/if_ed_wd80x3.c Thu Mar 17 10:56:19 2005 +++ ifnet/sys/dev/ed/if_ed_wd80x3.c Tue Jun 7 16:40:19 2005 @@ -363,7 +363,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/ed/if_edvar.h ifnet/sys/dev/ed/if_edvar.h --- freebsd/sys/dev/ed/if_edvar.h Thu Mar 17 10:56:20 2005 +++ ifnet/sys/dev/ed/if_edvar.h Tue Jun 7 16:40:20 2005 @@ -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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/em/if_em.c ifnet/sys/dev/em/if_em.c --- freebsd/sys/dev/em/if_em.c Sun Jun 5 06:11:32 2005 +++ ifnet/sys/dev/em/if_em.c Tue Jun 7 16:40:22 2005 @@ -464,9 +464,6 @@ 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 @@ 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_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 @@ struct ifnet *ifp; uint32_t pba; - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; INIT_DEBUGOUT("em_init: begin"); @@ -843,7 +841,7 @@ 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_LOCK(adapter); - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; #ifdef DEVICE_POLLING if (ifp->if_flags & IFF_POLLING) { @@ -1193,7 +1191,7 @@ 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 @@ { 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 @@ 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 @@ 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 @@ { struct ifnet *ifp; struct adapter * adapter = arg; - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; EM_LOCK(adapter); @@ -1668,7 +1666,7 @@ 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 @@ { 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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/em/if_em.h ifnet/sys/dev/em/if_em.h --- freebsd/sys/dev/em/if_em.h Sun Jun 5 06:11:32 2005 +++ ifnet/sys/dev/em/if_em.h Fri Jun 3 19:46:42 2005 @@ -322,7 +322,7 @@ /* Our adapter structure */ struct adapter { - struct arpcom interface_data; + struct ifnet *ifp; struct adapter *next; struct adapter *prev; struct em_hw hw; diff -ruN --exclude=compile freebsd/sys/dev/en/if_en_pci.c ifnet/sys/dev/en/if_en_pci.c --- freebsd/sys/dev/en/if_en_pci.c Thu Mar 17 10:56:23 2005 +++ ifnet/sys/dev/en/if_en_pci.c Tue May 24 17:16:48 2005 @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -149,7 +150,7 @@ 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 @@ 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_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 @@ /* * 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/en/midway.c ifnet/sys/dev/en/midway.c --- freebsd/sys/dev/en/midway.c Thu Jan 6 22:24:39 2005 +++ ifnet/sys/dev/en/midway.c Tue May 24 17:16:49 2005 @@ -90,7 +90,7 @@ */ #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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ "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_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 @@ 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_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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ /* * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/en/midwayvar.h ifnet/sys/dev/en/midwayvar.h --- freebsd/sys/dev/en/midwayvar.h Thu Jan 6 22:24:39 2005 +++ ifnet/sys/dev/en/midwayvar.h Tue May 24 17:16:49 2005 @@ -153,8 +153,7 @@ * softc */ struct en_softc { - /* bsd glue */ - struct ifatm ifatm; /* ATM network ifnet handle */ + struct ifnet *ifp; device_t dev; /* bus glue */ diff -ruN --exclude=compile freebsd/sys/dev/ep/if_ep.c ifnet/sys/dev/ep/if_ep.c --- freebsd/sys/dev/ep/if_ep.c Thu Apr 14 06:17:58 2005 +++ ifnet/sys/dev/ep/if_ep.c Tue Jun 7 16:40:22 2005 @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -262,14 +263,14 @@ { 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 @@ /* * 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 @@ 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 @@ 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 @@ ifp->if_flags &= ~IFF_RUNNING; ether_ifdetach(ifp); + if_free(ifp); sc->gone = 1; ep_free(dev); @@ -377,7 +382,7 @@ 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 @@ /* 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_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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ep/if_ep_pccard.c ifnet/sys/dev/ep/if_ep_pccard.c --- freebsd/sys/dev/ep/if_ep_pccard.c Tue Jan 25 21:39:58 2005 +++ ifnet/sys/dev/ep/if_ep_pccard.c Tue Jun 7 16:40:22 2005 @@ -120,7 +120,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/ep/if_epvar.h ifnet/sys/dev/ep/if_epvar.h --- freebsd/sys/dev/ep/if_epvar.h Tue Jan 25 21:39:58 2005 +++ ifnet/sys/dev/ep/if_epvar.h Tue May 24 17:16:50 2005 @@ -33,7 +33,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/ex/if_ex.c ifnet/sys/dev/ex/if_ex.c --- freebsd/sys/dev/ex/if_ex.c Thu Jan 6 22:24:43 2005 +++ ifnet/sys/dev/ex/if_ex.c Tue Jun 7 16:40:23 2005 @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -202,12 +203,17 @@ 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 @@ /* * Attach the interface. */ - ether_ifattach(ifp, sc->arpcom.ac_enaddr); + ether_ifattach(ifp, sc->enaddr); return(0); } @@ -264,12 +270,13 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 -ruN --exclude=compile freebsd/sys/dev/ex/if_ex_isa.c ifnet/sys/dev/ex/if_ex_isa.c --- freebsd/sys/dev/ex/if_ex_isa.c Mon Jun 28 20:25:59 2004 +++ ifnet/sys/dev/ex/if_ex_isa.c Tue Jun 7 16:40:23 2005 @@ -296,7 +296,7 @@ */ 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 -ruN --exclude=compile freebsd/sys/dev/ex/if_ex_pccard.c ifnet/sys/dev/ex/if_ex_pccard.c --- freebsd/sys/dev/ex/if_ex_pccard.c Tue Jan 25 21:39:58 2005 +++ ifnet/sys/dev/ex/if_ex_pccard.c Tue Jun 7 16:40:23 2005 @@ -231,7 +231,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ex/if_exvar.h ifnet/sys/dev/ex/if_exvar.h --- freebsd/sys/dev/ex/if_exvar.h Mon Jun 28 20:25:59 2004 +++ ifnet/sys/dev/ex/if_exvar.h Tue Jun 7 16:40:23 2005 @@ -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 -ruN --exclude=compile freebsd/sys/dev/fatm/if_fatm.c ifnet/sys/dev/fatm/if_fatm.c --- freebsd/sys/dev/fatm/if_fatm.c Thu Mar 17 10:56:30 2005 +++ ifnet/sys/dev/fatm/if_fatm.c Tue Jun 7 16:40:25 2005 @@ -57,6 +57,7 @@ #include #include +#include #include #include #ifdef INET @@ -111,8 +112,8 @@ }; #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 @@ 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 @@ /* 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 @@ 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 @@ (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 @@ 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 @@ 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); - - 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); + 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->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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ 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 @@ } 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 @@ 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 @@ } 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_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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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_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 @@ 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 @@ /* * 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 @@ 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 @@ */ 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 @@ 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 @@ } } - 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 -ruN --exclude=compile freebsd/sys/dev/fatm/if_fatmvar.h ifnet/sys/dev/fatm/if_fatmvar.h --- freebsd/sys/dev/fatm/if_fatmvar.h Thu Jan 6 22:24:46 2005 +++ ifnet/sys/dev/fatm/if_fatmvar.h Tue May 24 17:16:52 2005 @@ -185,7 +185,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/fe/if_fe.c ifnet/sys/dev/fe/if_fe.c --- freebsd/sys/dev/fe/if_fe.c Thu Mar 17 10:56:35 2005 +++ ifnet/sys/dev/fe/if_fe.c Tue Jun 7 16:40:26 2005 @@ -86,6 +86,7 @@ #include #include #include +#include #include #include @@ -427,8 +428,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ /* * 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 @@ * 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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ #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 @@ 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 @@ * 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 @@ /* * 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 @@ * 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 @@ * 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 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ */ col = 1; } - sc->sc_if.if_collisions += col; + sc->ifp->if_collisions += col; if (col == 1) sc->mibdata.dot3StatsSingleCollisionFrames++; else @@ -1512,9 +1521,9 @@ * 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 @@ * 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 @@ if (rstat & FE_D1_SRTPKT) sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */ #endif - sc->sc_if.if_ierrors++; + sc->ifp->if_ierrors++; } /* @@ -1629,8 +1638,9 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ 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 @@ /* 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/fe/if_fe_isa.c ifnet/sys/dev/fe/if_fe_isa.c --- freebsd/sys/dev/fe/if_fe_isa.c Thu Mar 17 10:56:36 2005 +++ ifnet/sys/dev/fe/if_fe_isa.c Tue Jun 7 16:40:26 2005 @@ -251,8 +251,8 @@ /* 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 @@ /* 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 @@ 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 @@ /* 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 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/fe/if_fe_pccard.c ifnet/sys/dev/fe/if_fe_pccard.c --- freebsd/sys/dev/fe/if_fe_pccard.c Thu Mar 17 10:56:37 2005 +++ ifnet/sys/dev/fe/if_fe_pccard.c Tue Jun 7 16:40:26 2005 @@ -183,10 +183,11 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/fe/if_fevar.h ifnet/sys/dev/fe/if_fevar.h --- freebsd/sys/dev/fe/if_fevar.h Thu Mar 17 10:56:37 2005 +++ ifnet/sys/dev/fe/if_fevar.h Tue Jun 7 16:40:27 2005 @@ -68,8 +68,9 @@ 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; @@ -117,11 +118,6 @@ void (* msel)(struct fe_softc *); /* media selector. */ }; - -#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. */ diff -ruN --exclude=compile freebsd/sys/dev/firewire/if_fwe.c ifnet/sys/dev/firewire/if_fwe.c --- freebsd/sys/dev/firewire/if_fwe.c Thu Jan 6 22:24:54 2005 +++ ifnet/sys/dev/firewire/if_fwe.c Tue Jun 7 16:40:27 2005 @@ -52,6 +52,7 @@ #include #include #include +#include #ifdef __DragonFly__ #include #include @@ -159,7 +160,11 @@ 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 @@ /* 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 @@ 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 @@ { 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 @@ 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 @@ { 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 @@ 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 @@ #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 -ruN --exclude=compile freebsd/sys/dev/firewire/if_fwevar.h ifnet/sys/dev/firewire/if_fwevar.h --- freebsd/sys/dev/firewire/if_fwevar.h Thu Jan 6 22:24:54 2005 +++ ifnet/sys/dev/firewire/if_fwevar.h Tue May 24 17:16:54 2005 @@ -45,9 +45,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/firewire/if_fwip.c ifnet/sys/dev/firewire/if_fwip.c --- freebsd/sys/dev/firewire/if_fwip.c Thu Jan 6 22:24:54 2005 +++ ifnet/sys/dev/firewire/if_fwip.c Tue May 24 17:16:54 2005 @@ -55,6 +55,7 @@ #include #include #include +#include #ifdef __DragonFly__ #include #include @@ -170,6 +171,9 @@ 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 @@ /* * 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 @@ 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 @@ { 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 @@ 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 @@ { 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->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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/firewire/if_fwipvar.h ifnet/sys/dev/firewire/if_fwipvar.h --- freebsd/sys/dev/firewire/if_fwipvar.h Thu Jan 6 22:24:54 2005 +++ ifnet/sys/dev/firewire/if_fwipvar.h Tue May 24 17:16:54 2005 @@ -55,9 +55,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/fxp/if_fxp.c ifnet/sys/dev/fxp/if_fxp.c --- freebsd/sys/dev/fxp/if_fxp.c Tue Jun 7 22:46:02 2005 +++ ifnet/sys/dev/fxp/if_fxp.c Tue Jun 7 22:47:11 2005 @@ -373,6 +373,7 @@ 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 @@ * 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 @@ } } - 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 @@ /* * 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_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 @@ 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 @@ /* * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/fxp/if_fxpvar.h ifnet/sys/dev/fxp/if_fxpvar.h --- freebsd/sys/dev/fxp/if_fxpvar.h Sun Jun 5 13:33:12 2005 +++ ifnet/sys/dev/fxp/if_fxpvar.h Sun Jun 5 13:34:41 2005 @@ -153,7 +153,7 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/gem/if_gem.c ifnet/sys/dev/gem/if_gem.c --- freebsd/sys/dev/gem/if_gem.c Wed Aug 25 12:11:47 2004 +++ ifnet/sys/dev/gem/if_gem.c Tue Jun 7 16:40:29 2005 @@ -56,6 +56,7 @@ #include #include #include +#include #include @@ -124,11 +125,15 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ /* 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ /* Clear hash table */ memset(hash, 0, sizeof(hash)); - 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 -ruN --exclude=compile freebsd/sys/dev/gem/if_gem_pci.c ifnet/sys/dev/gem/if_gem_pci.c --- freebsd/sys/dev/gem/if_gem_pci.c Thu Mar 17 10:56:40 2005 +++ ifnet/sys/dev/gem/if_gem_pci.c Tue Jun 7 16:40:29 2005 @@ -195,7 +195,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/gem/if_gemvar.h ifnet/sys/dev/gem/if_gemvar.h --- freebsd/sys/dev/gem/if_gemvar.h Thu Jan 6 22:24:58 2005 +++ ifnet/sys/dev/gem/if_gemvar.h Tue Jun 7 16:40:29 2005 @@ -123,10 +123,11 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/harp/if_harp.c ifnet/sys/dev/harp/if_harp.c --- freebsd/sys/dev/harp/if_harp.c Thu Jan 6 22:24:59 2005 +++ ifnet/sys/dev/harp/if_harp.c Tue May 24 17:16:57 2005 @@ -354,7 +354,7 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hatm/if_hatm.c ifnet/sys/dev/hatm/if_hatm.c --- freebsd/sys/dev/hatm/if_hatm.c Thu Mar 17 10:56:41 2005 +++ ifnet/sys/dev/hatm/if_hatm.c Tue Jun 7 16:40:31 2005 @@ -62,6 +62,7 @@ #include #include #include +#include #include #ifdef ENABLE_BPF #include @@ -217,13 +218,13 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } mtx_unlock(&sc->mtx); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); hatm_destroy(sc); @@ -1650,18 +1652,25 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hatm/if_hatm_intr.c ifnet/sys/dev/hatm/if_hatm_intr.c --- freebsd/sys/dev/hatm/if_hatm_intr.c Thu Jan 6 22:25:00 2005 +++ ifnet/sys/dev/hatm/if_hatm_intr.c Fri Jun 3 15:58:30 2005 @@ -203,7 +203,7 @@ 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 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ /* 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 @@ /* 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 @@ #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 @@ 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 @@ break; default: - if_printf(&sc->ifatm.ifnet, "bad interrupt type %08x\n", + if_printf(sc->ifp, "bad interrupt type %08x\n", status); break; } diff -ruN --exclude=compile freebsd/sys/dev/hatm/if_hatm_ioctl.c ifnet/sys/dev/hatm/if_hatm_ioctl.c --- freebsd/sys/dev/hatm/if_hatm_ioctl.c Thu Jan 6 22:25:00 2005 +++ ifnet/sys/dev/hatm/if_hatm_ioctl.c Fri Jun 3 15:58:31 2005 @@ -116,7 +116,7 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hatm/if_hatm_rx.c ifnet/sys/dev/hatm/if_hatm_rx.c --- freebsd/sys/dev/hatm/if_hatm_rx.c Thu Jan 6 22:25:00 2005 +++ ifnet/sys/dev/hatm/if_hatm_rx.c Fri Jun 3 15:58:31 2005 @@ -130,7 +130,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } #endif - atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand); + atm_input(sc->ifp, &aph, m, vcc->rxhand); return; @@ -316,11 +316,11 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hatm/if_hatm_tx.c ifnet/sys/dev/hatm/if_hatm_tx.c --- freebsd/sys/dev/hatm/if_hatm_tx.c Sun Jun 5 06:11:39 2005 +++ ifnet/sys/dev/hatm/if_hatm_tx.c Fri Jun 3 19:46:51 2005 @@ -193,7 +193,7 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ #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 -ruN --exclude=compile freebsd/sys/dev/hatm/if_hatmvar.h ifnet/sys/dev/hatm/if_hatmvar.h --- freebsd/sys/dev/hatm/if_hatmvar.h Thu Jan 6 22:25:01 2005 +++ ifnet/sys/dev/hatm/if_hatmvar.h Fri Jun 3 15:58:31 2005 @@ -363,7 +363,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/hfa/fore_output.c ifnet/sys/dev/hfa/fore_output.c --- freebsd/sys/dev/hfa/fore_output.c Thu Jan 6 22:25:02 2005 +++ ifnet/sys/dev/hfa/fore_output.c Tue May 24 17:17:00 2005 @@ -131,7 +131,7 @@ 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 @@ 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 @@ */ 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 -ruN --exclude=compile freebsd/sys/dev/hfa/fore_receive.c ifnet/sys/dev/hfa/fore_receive.c --- freebsd/sys/dev/hfa/fore_receive.c Fri Aug 27 13:12:56 2004 +++ ifnet/sys/dev/hfa/fore_receive.c Thu Feb 3 22:24:21 2005 @@ -299,7 +299,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hfa/fore_transmit.c ifnet/sys/dev/hfa/fore_transmit.c --- freebsd/sys/dev/hfa/fore_transmit.c Thu Feb 26 17:14:02 2004 +++ ifnet/sys/dev/hfa/fore_transmit.c Thu Feb 3 22:24:21 2005 @@ -272,7 +272,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hme/if_hme.c ifnet/sys/dev/hme/if_hme.c --- freebsd/sys/dev/hme/if_hme.c Tue May 24 17:12:20 2005 +++ ifnet/sys/dev/hme/if_hme.c Tue Jun 7 16:40:31 2005 @@ -82,6 +82,7 @@ #include #include #include +#include #include #include @@ -105,7 +106,7 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ 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 @@ 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 @@ } 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/hme/if_hme_pci.c ifnet/sys/dev/hme/if_hme_pci.c --- freebsd/sys/dev/hme/if_hme_pci.c Thu Mar 17 10:56:44 2005 +++ ifnet/sys/dev/hme/if_hme_pci.c Tue Jun 7 16:40:31 2005 @@ -222,7 +222,7 @@ &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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hme/if_hme_sbus.c ifnet/sys/dev/hme/if_hme_sbus.c --- freebsd/sys/dev/hme/if_hme_sbus.c Tue Apr 5 22:51:52 2005 +++ ifnet/sys/dev/hme/if_hme_sbus.c Tue Jun 7 16:40:32 2005 @@ -247,7 +247,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/hme/if_hmevar.h ifnet/sys/dev/hme/if_hmevar.h --- freebsd/sys/dev/hme/if_hmevar.h Mon Nov 22 16:19:38 2004 +++ ifnet/sys/dev/hme/if_hmevar.h Tue Jun 7 16:40:33 2005 @@ -108,11 +108,12 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/idt/idt.c ifnet/sys/dev/idt/idt.c --- freebsd/sys/dev/idt/idt.c Thu Jan 6 22:25:09 2005 +++ ifnet/sys/dev/idt/idt.c Tue Apr 5 22:52:45 2005 @@ -1556,7 +1556,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ie/if_ie.c ifnet/sys/dev/ie/if_ie.c --- freebsd/sys/dev/ie/if_ie.c Sun Jun 5 06:11:42 2005 +++ ifnet/sys/dev/ie/if_ie.c Tue Jun 7 16:40:34 2005 @@ -266,7 +266,11 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ #endif ie_ack(sc, IE_ST_WHENCE); - sc->arpcom.ac_if.if_ierrors++; + sc->ifp->if_ierrors++; return (0); } @@ -593,7 +599,7 @@ 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 @@ */ 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 @@ } *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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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_stop(sc); ifp->if_flags &= ~IFF_RUNNING; ether_ifdetach(ifp); + if_free(ifp); ie_release_resources(dev); return (0); diff -ruN --exclude=compile freebsd/sys/dev/ie/if_ie_isa.c ifnet/sys/dev/ie/if_ie_isa.c --- freebsd/sys/dev/ie/if_ie_isa.c Sun Jun 5 06:11:43 2005 +++ ifnet/sys/dev/ie/if_ie_isa.c Tue Jun 7 16:40:34 2005 @@ -259,7 +259,7 @@ 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 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ie/if_ievar.h ifnet/sys/dev/ie/if_ievar.h --- freebsd/sys/dev/ie/if_ievar.h Tue Nov 4 13:46:42 2003 +++ ifnet/sys/dev/ie/if_ievar.h Tue Jun 7 16:40:34 2005 @@ -17,12 +17,13 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/if_ndis/if_ndis.c ifnet/sys/dev/if_ndis/if_ndis.c --- freebsd/sys/dev/if_ndis/if_ndis.c Sun Jun 5 06:11:44 2005 +++ ifnet/sys/dev/if_ndis/if_ndis.c Tue Jun 7 16:40:35 2005 @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -232,7 +233,7 @@ int len, mclistsz, error; uint8_t *mclist; - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; if (!NDIS_INITIALIZED(sc)) return; @@ -307,7 +308,7 @@ struct ifnet *ifp; int len, error; - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; if (!NDIS_INITIALIZED(sc)) return(EINVAL); @@ -369,7 +370,7 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ ether_ifdetach(ifp); } else NDIS_UNLOCK(sc); + if (ifp != NULL) + if_free(ifp); bus_generic_detach(dev); @@ -945,7 +950,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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_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 @@ 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 @@ 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 @@ struct ifnet *ifp; ic = &sc->ic; - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; if (!NDIS_INITIALIZED(sc)) return; @@ -2125,7 +2130,7 @@ struct ifnet *ifp; ic = &sc->ic; - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; if (!NDIS_INITIALIZED(sc)) return; @@ -2986,7 +2991,7 @@ { struct ifnet *ifp; - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; untimeout(ndis_tick, sc, sc->ndis_stat_ch); NDIS_LOCK(sc); diff -ruN --exclude=compile freebsd/sys/dev/if_ndis/if_ndisvar.h ifnet/sys/dev/if_ndis/if_ndisvar.h --- freebsd/sys/dev/if_ndis/if_ndisvar.h Tue May 24 17:12:25 2005 +++ ifnet/sys/dev/if_ndis/if_ndisvar.h Fri Jun 3 19:46:58 2005 @@ -69,11 +69,8 @@ (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 -ruN --exclude=compile freebsd/sys/dev/iicbus/if_ic.c ifnet/sys/dev/iicbus/if_ic.c --- freebsd/sys/dev/iicbus/if_ic.c Wed Aug 25 12:11:51 2004 +++ ifnet/sys/dev/iicbus/if_ic.c Fri Jun 3 15:58:34 2005 @@ -70,7 +70,7 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ipw/if_ipw.c ifnet/sys/dev/ipw/if_ipw.c --- freebsd/sys/dev/ipw/if_ipw.c Sun Jun 5 06:11:46 2005 +++ ifnet/sys/dev/ipw/if_ipw.c Fri Jun 3 19:47:00 2005 @@ -214,7 +214,7 @@ 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 @@ 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_UNLOCK(sc); - bpfdetach(ifp); + if (ifp != NULL) + bpfdetach(ifp); ieee80211_ifdetach(ic); + if (ifp != NULL) + if_free(ifp); ipw_release(sc); diff -ruN --exclude=compile freebsd/sys/dev/ipw/if_ipwvar.h ifnet/sys/dev/ipw/if_ipwvar.h --- freebsd/sys/dev/ipw/if_ipwvar.h Sun Jun 5 06:11:46 2005 +++ ifnet/sys/dev/ipw/if_ipwvar.h Fri Jun 3 19:47:00 2005 @@ -84,7 +84,7 @@ (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 -ruN --exclude=compile freebsd/sys/dev/iwi/if_iwi.c ifnet/sys/dev/iwi/if_iwi.c --- freebsd/sys/dev/iwi/if_iwi.c Tue May 24 17:12:29 2005 +++ ifnet/sys/dev/iwi/if_iwi.c Fri Jun 3 19:47:02 2005 @@ -229,7 +229,7 @@ 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 @@ 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_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 -ruN --exclude=compile freebsd/sys/dev/iwi/if_iwivar.h ifnet/sys/dev/iwi/if_iwivar.h --- freebsd/sys/dev/iwi/if_iwivar.h Tue May 24 17:12:29 2005 +++ ifnet/sys/dev/iwi/if_iwivar.h Fri Jun 3 19:47:02 2005 @@ -109,7 +109,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/ixgb/if_ixgb.c ifnet/sys/dev/ixgb/if_ixgb.c --- freebsd/sys/dev/ixgb/if_ixgb.c Tue May 24 17:12:30 2005 +++ ifnet/sys/dev/ixgb/if_ixgb.c Tue Jun 7 16:40:36 2005 @@ -364,7 +364,7 @@ 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_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_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 @@ /* 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_LOCK(adapter); - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; #ifdef DEVICE_POLLING if (ifp->if_flags & IFF_POLLING) { @@ -912,7 +913,7 @@ 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 @@ { 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 @@ 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 @@ { struct ifnet *ifp; struct adapter *adapter = arg; - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; IXGB_LOCK(adapter); @@ -1151,7 +1152,7 @@ { struct ifnet *ifp; struct adapter *adapter = arg; - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; IXGB_LOCK_ASSERT(adapter); @@ -1303,8 +1304,6 @@ 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 @@ 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 @@ #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 @@ * 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 @@ bus_addr_t paddr; int error; - ifp = &adapter->interface_data.ac_if; + ifp = adapter->ifp; if (mp == NULL) { @@ -1902,7 +1903,7 @@ 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_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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ixgb/if_ixgb.h ifnet/sys/dev/ixgb/if_ixgb.h --- freebsd/sys/dev/ixgb/if_ixgb.h Tue May 24 17:12:30 2005 +++ ifnet/sys/dev/ixgb/if_ixgb.h Fri Jun 3 19:47:03 2005 @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -270,7 +271,7 @@ /* Our adapter structure */ struct adapter { - struct arpcom interface_data; + struct ifnet *ifp; struct adapter *next; struct adapter *prev; struct ixgb_hw hw; diff -ruN --exclude=compile freebsd/sys/dev/lge/if_lge.c ifnet/sys/dev/lge/if_lge.c --- freebsd/sys/dev/lge/if_lge.c Sun Jun 5 06:11:48 2005 +++ ifnet/sys/dev/lge/if_lge.c Tue Jun 7 16:40:37 2005 @@ -83,6 +83,7 @@ #include #include #include +#include #include @@ -373,7 +374,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/lge/if_lgereg.h ifnet/sys/dev/lge/if_lgereg.h --- freebsd/sys/dev/lge/if_lgereg.h Thu Jan 6 22:25:57 2005 +++ ifnet/sys/dev/lge/if_lgereg.h Fri Jun 3 15:58:35 2005 @@ -522,7 +522,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/lnc/if_lnc.c ifnet/sys/dev/lnc/if_lnc.c --- freebsd/sys/dev/lnc/if_lnc.c Wed Aug 25 12:11:55 2004 +++ ifnet/sys/dev/lnc/if_lnc.c Tue Jun 7 16:40:39 2005 @@ -220,7 +220,7 @@ 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 @@ 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 @@ * 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 @@ #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 @@ #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 @@ } 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 @@ 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 @@ 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 @@ } 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 @@ */ 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 @@ * 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 @@ 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 @@ * more packets again. */ - sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; + sc->ifp->if_flags &= ~IFF_OACTIVE; lookahead++; @@ -838,6 +838,7 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ /* 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 @@ * 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 @@ #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 @@ } if (csr0 & TINT) { LNCSTATS(tint) - sc->arpcom.ac_if.if_timer = 0; + sc->ifp->if_timer = 0; lnc_tint(sc); } @@ -1156,8 +1172,8 @@ * 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 @@ 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 @@ 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 @@ * 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 @@ { 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 -ruN --exclude=compile freebsd/sys/dev/lnc/if_lnc_cbus.c ifnet/sys/dev/lnc/if_lnc_cbus.c --- freebsd/sys/dev/lnc/if_lnc_cbus.c Thu Jan 6 22:25:57 2005 +++ ifnet/sys/dev/lnc/if_lnc_cbus.c Tue May 24 17:17:14 2005 @@ -283,26 +283,11 @@ 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 -ruN --exclude=compile freebsd/sys/dev/lnc/if_lnc_isa.c ifnet/sys/dev/lnc/if_lnc_isa.c --- freebsd/sys/dev/lnc/if_lnc_isa.c Thu Jan 6 22:25:57 2005 +++ ifnet/sys/dev/lnc/if_lnc_isa.c Tue May 24 17:17:14 2005 @@ -254,26 +254,11 @@ 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 -ruN --exclude=compile freebsd/sys/dev/lnc/if_lnc_pci.c ifnet/sys/dev/lnc/if_lnc_pci.c --- freebsd/sys/dev/lnc/if_lnc_pci.c Thu Mar 17 10:56:58 2005 +++ ifnet/sys/dev/lnc/if_lnc_pci.c Tue May 24 17:17:14 2005 @@ -190,31 +190,10 @@ 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 -ruN --exclude=compile freebsd/sys/dev/lnc/if_lncvar.h ifnet/sys/dev/lnc/if_lncvar.h --- freebsd/sys/dev/lnc/if_lncvar.h Fri Mar 5 09:33:27 2004 +++ ifnet/sys/dev/lnc/if_lncvar.h Fri Jun 3 15:58:35 2005 @@ -199,7 +199,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/my/if_my.c ifnet/sys/dev/my/if_my.c --- freebsd/sys/dev/my/if_my.c Sun Jun 5 06:11:53 2005 +++ ifnet/sys/dev/my/if_my.c Tue Jun 7 16:40:40 2005 @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -326,7 +327,7 @@ MY_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->my_ifp; rxfilt = CSR_READ_4(sc, MY_TCRRCR); @@ -405,7 +406,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/my/if_myreg.h ifnet/sys/dev/my/if_myreg.h --- freebsd/sys/dev/my/if_myreg.h Thu Jan 6 22:26:10 2005 +++ ifnet/sys/dev/my/if_myreg.h Fri Jun 3 15:58:36 2005 @@ -350,7 +350,7 @@ #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 -ruN --exclude=compile freebsd/sys/dev/nge/if_nge.c ifnet/sys/dev/nge/if_nge.c --- freebsd/sys/dev/nge/if_nge.c Sun Jun 5 06:11:54 2005 +++ ifnet/sys/dev/nge/if_nge.c Tue Jun 7 16:40:41 2005 @@ -672,7 +672,7 @@ 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,10 +834,10 @@ 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); + M_ZERO, 0, 0xffffffff, PAGE_SIZE, 0); if (sc->nge_ldata == NULL) { printf("nge%d: no memory for list buffers!\n", unit); @@ -846,9 +846,15 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/nge/if_ngereg.h ifnet/sys/dev/nge/if_ngereg.h --- freebsd/sys/dev/nge/if_ngereg.h Thu Jan 6 22:26:12 2005 +++ ifnet/sys/dev/nge/if_ngereg.h Fri Jun 3 15:58:38 2005 @@ -648,7 +648,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/nve/if_nve.c ifnet/sys/dev/nve/if_nve.c --- freebsd/sys/dev/nve/if_nve.c Sun Jun 5 06:12:16 2005 +++ ifnet/sys/dev/nve/if_nve.c Tue Jun 7 16:40:41 2005 @@ -92,6 +92,7 @@ #include #include #include +#include #include #include @@ -487,10 +488,9 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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_LOCK(sc); - ifp = &sc->sc_if; + ifp = sc->ifp; nve_update_stats(sc); mii = device_get_softc(sc->miibus); @@ -1168,7 +1174,7 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ DEBUGOUT(NVE_DEBUG_API, "nve: nve_oslinkchg\n"); - ifp = &sc->sc_if; + ifp = sc->ifp; if (enabled) ifp->if_flags |= IFF_UP; diff -ruN --exclude=compile freebsd/sys/dev/nve/if_nvereg.h ifnet/sys/dev/nve/if_nvereg.h --- freebsd/sys/dev/nve/if_nvereg.h Thu Mar 24 21:05:45 2005 +++ ifnet/sys/dev/nve/if_nvereg.h Sat Jun 4 11:15:38 2005 @@ -108,7 +108,7 @@ }; struct nve_softc { - struct arpcom arpcom; /* interface info */ + struct ifnet *ifp; /* interface info */ struct resource *res; struct resource *irq; @@ -164,9 +164,6 @@ u_int16_t dev_id; 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) diff -ruN --exclude=compile freebsd/sys/dev/owi/if_owi.c ifnet/sys/dev/owi/if_owi.c --- freebsd/sys/dev/owi/if_owi.c Thu Jan 6 22:26:15 2005 +++ ifnet/sys/dev/owi/if_owi.c Tue Jun 7 16:40:43 2005 @@ -154,7 +154,7 @@ 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 @@ /* 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_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 @@ /* * 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_LOCK_ASSERT(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; id = CSR_READ_2(sc, WI_RX_FID); @@ -662,7 +666,7 @@ { struct ifnet *ifp; - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; ifp->if_timer = 0; ifp->if_flags &= ~IFF_OACTIVE; @@ -684,7 +688,7 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ return; } - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; /* * If the card is gone and the memory port isn't mapped, we will @@ -2013,6 +2017,11 @@ if (sc->mem != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); sc->mem = NULL; + } + + if (sc->ifp != NULL) { + if_free(sc->ifp); + sc->ifp = NULL; } return; diff -ruN --exclude=compile freebsd/sys/dev/owi/if_wivar.h ifnet/sys/dev/owi/if_wivar.h --- freebsd/sys/dev/owi/if_wivar.h Thu Jan 6 22:26:15 2005 +++ ifnet/sys/dev/owi/if_wivar.h Fri Jun 3 19:41:01 2005 @@ -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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patm.c ifnet/sys/dev/patm/if_patm.c --- freebsd/sys/dev/patm/if_patm.c Thu Jan 6 22:26:16 2005 +++ ifnet/sys/dev/patm/if_patm.c Fri Jun 3 15:58:38 2005 @@ -204,7 +204,7 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patm_attach.c ifnet/sys/dev/patm/if_patm_attach.c --- freebsd/sys/dev/patm/if_patm_attach.c Thu Mar 17 10:57:04 2005 +++ ifnet/sys/dev/patm/if_patm_attach.c Tue Jun 7 16:40:43 2005 @@ -57,6 +57,7 @@ #include #include +#include #include #include #ifdef ENABLE_BPF @@ -177,18 +178,22 @@ #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->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 = &sc->ifatm.ifnet; ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_SIMPLEX; @@ -297,8 +302,8 @@ * 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 @@ 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 @@ 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 @@ 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 @@ } mtx_unlock(&sc->mtx); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); patm_destroy(sc); @@ -696,7 +703,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patm_intr.c ifnet/sys/dev/patm/if_patm_intr.c --- freebsd/sys/dev/patm/if_patm_intr.c Thu Jan 6 22:26:17 2005 +++ ifnet/sys/dev/patm/if_patm_intr.c Fri Jun 3 15:58:38 2005 @@ -119,7 +119,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patm_ioctl.c ifnet/sys/dev/patm/if_patm_ioctl.c --- freebsd/sys/dev/patm/if_patm_ioctl.c Thu Jan 6 22:26:17 2005 +++ ifnet/sys/dev/patm/if_patm_ioctl.c Fri Jun 3 15:58:38 2005 @@ -107,7 +107,7 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ /* 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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patm_rx.c ifnet/sys/dev/patm/if_patm_rx.c --- freebsd/sys/dev/patm/if_patm_rx.c Thu Jan 6 22:26:17 2005 +++ ifnet/sys/dev/patm/if_patm_rx.c Fri Jun 3 15:58:39 2005 @@ -244,7 +244,7 @@ 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 @@ } 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 @@ 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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patm_tx.c ifnet/sys/dev/patm/if_patm_tx.c --- freebsd/sys/dev/patm/if_patm_tx.c Thu Jan 6 22:26:18 2005 +++ ifnet/sys/dev/patm/if_patm_tx.c Fri Jun 3 15:58:39 2005 @@ -119,13 +119,13 @@ /* 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 @@ 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 @@ 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 @@ /* 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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_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 @@ } 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/patm/if_patmvar.h ifnet/sys/dev/patm/if_patmvar.h --- freebsd/sys/dev/patm/if_patmvar.h Thu Jan 6 22:26:18 2005 +++ ifnet/sys/dev/patm/if_patmvar.h Fri Jun 3 15:58:39 2005 @@ -149,7 +149,7 @@ }; #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 @@ * 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 @@ #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 @@ #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 @@ } #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 -ruN --exclude=compile freebsd/sys/dev/pdq/if_fea.c ifnet/sys/dev/pdq/if_fea.c --- freebsd/sys/dev/pdq/if_fea.c Wed Mar 17 11:34:52 2004 +++ ifnet/sys/dev/pdq/if_fea.c Tue Jun 7 16:40:43 2005 @@ -186,7 +186,7 @@ int error; sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; sc->dev = dev; @@ -244,7 +244,7 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/pdq/if_fpa.c ifnet/sys/dev/pdq/if_fpa.c --- freebsd/sys/dev/pdq/if_fpa.c Sun Jun 5 06:12:18 2005 +++ ifnet/sys/dev/pdq/if_fpa.c Tue Jun 7 16:40:43 2005 @@ -111,7 +111,7 @@ int error; sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; sc->dev = dev; @@ -167,7 +167,7 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/pdq/pdq.c ifnet/sys/dev/pdq/pdq.c --- freebsd/sys/dev/pdq/pdq.c Thu Sep 30 12:34:16 2004 +++ ifnet/sys/dev/pdq/pdq.c Tue May 24 17:17:21 2005 @@ -42,23 +42,14 @@ * flushing of the write buffers. */ -#ifdef __NetBSD__ -#include -__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 #include -#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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/pdq/pdq_freebsd.h ifnet/sys/dev/pdq/pdq_freebsd.h --- freebsd/sys/dev/pdq/pdq_freebsd.h Sun Jun 5 06:12:18 2005 +++ ifnet/sys/dev/pdq/pdq_freebsd.h Fri Jun 3 19:47:14 2005 @@ -93,15 +93,13 @@ }; #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 @@ #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 -ruN --exclude=compile freebsd/sys/dev/pdq/pdq_ifsubr.c ifnet/sys/dev/pdq/pdq_ifsubr.c --- freebsd/sys/dev/pdq/pdq_ifsubr.c Sun Jun 5 06:12:18 2005 +++ ifnet/sys/dev/pdq/pdq_ifsubr.c Fri Jun 3 19:47:15 2005 @@ -36,10 +36,6 @@ * (ie. it provides an ifnet interface to the rest of the system) */ -#ifdef __NetBSD__ -#include -__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 @@ #include #include #include +#include #include #include @@ -76,14 +73,14 @@ 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 @@ 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 @@ 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 @@ 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 @@ } #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_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_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 @@ 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->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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } #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 @@ { 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 -ruN --exclude=compile freebsd/sys/dev/pdq/pdqvar.h ifnet/sys/dev/pdq/pdqvar.h --- freebsd/sys/dev/pdq/pdqvar.h Wed Jan 14 14:45:09 2004 +++ ifnet/sys/dev/pdq/pdqvar.h Tue May 24 17:17:22 2005 @@ -61,7 +61,7 @@ #if defined(PDQTEST) #include -#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__) +#else #include #include @@ -72,40 +72,19 @@ #include #include -#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 #include #include @@ -116,130 +95,8 @@ 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 -#endif -#include -#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 -#endif -#include -#include -#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 @@ #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 @@ #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 @@ #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 @@ #endif /* !PDQ_HWSUPPORT */ -#elif defined(DLPI_PDQ) -#include -#include -#include -#include - -#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 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/ppbus/if_plip.c ifnet/sys/dev/ppbus/if_plip.c --- freebsd/sys/dev/ppbus/if_plip.c Fri Aug 27 13:12:57 2004 +++ ifnet/sys/dev/ppbus/if_plip.c Fri Jun 3 15:58:40 2005 @@ -146,7 +146,7 @@ #endif struct lp_data { - struct ifnet sc_if; + struct ifnet *sc_ifp; u_char *sc_ifbuf; int sc_iferrs; @@ -232,7 +232,12 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ err: ppb_wdtr(ppbus, 0); lprintf("R"); - sc->sc_if.if_ierrors++; + sc->sc_ifp->if_ierrors++; sc->sc_iferrs++; /* @@ -573,7 +577,7 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ral/if_ral.c ifnet/sys/dev/ral/if_ral.c --- freebsd/sys/dev/ral/if_ral.c Tue May 24 17:12:33 2005 +++ ifnet/sys/dev/ral/if_ral.c Fri Jun 3 19:47:15 2005 @@ -342,7 +342,7 @@ 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 @@ 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_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 @@ 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 @@ bpfdetach(ifp); ieee80211_ifdetach(ic); + if_free(ifp); ral_free_tx_ring(sc, &sc->txq); ral_free_tx_ring(sc, &sc->atimq); diff -ruN --exclude=compile freebsd/sys/dev/ral/if_ralvar.h ifnet/sys/dev/ral/if_ralvar.h --- freebsd/sys/dev/ral/if_ralvar.h Fri Apr 29 17:37:14 2005 +++ ifnet/sys/dev/ral/if_ralvar.h Fri Jun 3 19:41:02 2005 @@ -96,7 +96,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/ray/if_ray.c ifnet/sys/dev/ray/if_ray.c --- freebsd/sys/dev/ray/if_ray.c Thu Mar 17 10:57:12 2005 +++ ifnet/sys/dev/ray/if_ray.c Tue Jun 7 16:40:46 2005 @@ -266,6 +266,7 @@ #include #include #include +#include #include #include "card_if.h" @@ -442,28 +443,38 @@ { 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 @@ /* * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/ray/if_rayvar.h ifnet/sys/dev/ray/if_rayvar.h --- freebsd/sys/dev/ray/if_rayvar.h Thu Mar 17 10:57:12 2005 +++ ifnet/sys/dev/ray/if_rayvar.h Sat Jun 4 11:15:38 2005 @@ -65,7 +65,7 @@ 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 @@ #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 @@ /* 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 -ruN --exclude=compile freebsd/sys/dev/re/if_re.c ifnet/sys/dev/re/if_re.c --- freebsd/sys/dev/re/if_re.c Sun Jun 5 06:12:19 2005 +++ ifnet/sys/dev/re/if_re.c Tue Jun 7 16:40:47 2005 @@ -123,6 +123,7 @@ #include #include #include +#include #include #include @@ -583,7 +584,7 @@ RL_LOCK_ASSERT(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->rl_ifp; rxfilt = CSR_READ_4(sc, RL_RXCFG); @@ -667,7 +668,7 @@ 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 @@ } 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 @@ 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 @@ printf("re%d: attach aborted due to hardware diag failure\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -1233,6 +1239,7 @@ if (error) { printf("re%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); } fail: @@ -1259,13 +1266,15 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ */ 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 @@ 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 @@ RL_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->rl_ifp; /* reinitialize interface if necessary */ if (ifp->if_flags & IFF_UP) diff -ruN --exclude=compile freebsd/sys/dev/sbni/if_sbni.c ifnet/sys/dev/sbni/if_sbni.c --- freebsd/sys/dev/sbni/if_sbni.c Thu Jan 6 22:26:40 2005 +++ ifnet/sys/dev/sbni/if_sbni.c Tue Jun 7 16:40:48 2005 @@ -80,6 +80,7 @@ #include #include #include +#include #include #include @@ -221,7 +222,9 @@ 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 @@ 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 @@ 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 @@ } 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 @@ * 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/sbni/if_sbni_isa.c ifnet/sys/dev/sbni/if_sbni_isa.c --- freebsd/sys/dev/sbni/if_sbni_isa.c Thu Jan 6 22:26:40 2005 +++ ifnet/sys/dev/sbni/if_sbni_isa.c Fri Jun 3 19:41:05 2005 @@ -157,7 +157,7 @@ return (ENXIO); } else { printf(" shared irq with %s\n", - master->arpcom.ac_if.if_xname); + master->ifp->if_xname); } } #endif /* SBNI_DUAL_COMPOUND */ diff -ruN --exclude=compile freebsd/sys/dev/sbni/if_sbnivar.h ifnet/sys/dev/sbni/if_sbnivar.h --- freebsd/sys/dev/sbni/if_sbnivar.h Thu Jan 6 22:26:40 2005 +++ ifnet/sys/dev/sbni/if_sbnivar.h Tue Jun 7 16:40:48 2005 @@ -67,7 +67,8 @@ #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 -ruN --exclude=compile freebsd/sys/dev/sbsh/if_sbsh.c ifnet/sys/dev/sbsh/if_sbsh.c --- freebsd/sys/dev/sbsh/if_sbsh.c Thu Mar 17 10:57:15 2005 +++ ifnet/sys/dev/sbsh/if_sbsh.c Tue Jun 7 16:40:48 2005 @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -96,7 +97,7 @@ #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 @@ struct sbsh_softc *sc; struct ifnet *ifp; int unit, error = 0, rid, s; + u_char eaddr[6]; s = splimp(); @@ -264,10 +266,18 @@ } /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/sn/if_sn.c ifnet/sys/dev/sn/if_sn.c --- freebsd/sys/dev/sn/if_sn.c Thu Jan 6 22:26:48 2005 +++ ifnet/sys/dev/sn/if_sn.c Tue Jun 7 16:40:49 2005 @@ -132,7 +132,7 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ */ 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 @@ 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 @@ * 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 @@ 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 @@ /* * 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 @@ */ 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 @@ 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 @@ * 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 @@ BPF_MTAP(ifp, top); - sc->arpcom.ac_if.if_opackets++; + sc->ifp->if_opackets++; m_freem(top); try_start: @@ -750,15 +759,15 @@ /* * 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 @@ { 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 @@ 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 @@ * 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 @@ 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 @@ /* * 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 @@ /* * 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 @@ * 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 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/sn/if_sn_pccard.c ifnet/sys/dev/sn/if_sn_pccard.c --- freebsd/sys/dev/sn/if_sn_pccard.c Tue Jan 25 21:40:18 2005 +++ ifnet/sys/dev/sn/if_sn_pccard.c Tue Jun 7 16:40:49 2005 @@ -149,7 +149,7 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/sn/if_snvar.h ifnet/sys/dev/sn/if_snvar.h --- freebsd/sys/dev/sn/if_snvar.h Thu Jan 6 22:26:48 2005 +++ ifnet/sys/dev/sn/if_snvar.h Fri Jun 3 15:58:41 2005 @@ -30,14 +30,8 @@ #include -/* - * 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 -ruN --exclude=compile freebsd/sys/dev/snc/dp83932.c ifnet/sys/dev/snc/dp83932.c --- freebsd/sys/dev/snc/dp83932.c Thu Mar 17 10:57:17 2005 +++ ifnet/sys/dev/snc/dp83932.c Tue Jun 7 16:40:49 2005 @@ -79,6 +79,7 @@ #include #include #include +#include #include @@ -154,7 +155,7 @@ 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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ sc->sc_mptally++; #endif } - sncstart(&sc->sc_if); + sncstart(sc->sc_ifp); #if NRND > 0 if (isr) @@ -900,7 +904,7 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/snc/dp83932var.h ifnet/sys/dev/snc/dp83932var.h --- freebsd/sys/dev/snc/dp83932var.h Thu Jan 6 22:26:49 2005 +++ ifnet/sys/dev/snc/dp83932var.h Fri Jun 3 19:41:06 2005 @@ -130,8 +130,7 @@ * 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 -ruN --exclude=compile freebsd/sys/dev/sr/if_sr.c ifnet/sys/dev/sr/if_sr.c --- freebsd/sys/dev/sr/if_sr.c Sun Jun 5 06:12:24 2005 +++ ifnet/sys/dev/sr/if_sr.c Fri Jun 3 19:47:22 2005 @@ -72,6 +72,7 @@ #include #else /* NETGRAPH */ #include +#include #include #endif /* NETGRAPH */ @@ -108,7 +109,7 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ hc = sc->hc; #ifndef NETGRAPH - ifp = &sc->ifsppp.pp_if; + ifp = SC2IFP(sc); #endif /* NETGRAPH */ if (hc->mempages) { @@ -2241,8 +2246,8 @@ 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 @@ "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 @@ 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 @@ #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 @@ 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_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 @@ 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 @@ "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_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 @@ #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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/tx/if_tx.c ifnet/sys/dev/tx/if_tx.c --- freebsd/sys/dev/tx/if_tx.c Sun Jun 5 06:12:34 2005 +++ ifnet/sys/dev/tx/if_tx.c Tue Jun 7 16:40:50 2005 @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -224,6 +225,7 @@ epic_softc_t *sc; int unit, error; int i, s, rid, tmp; + u_char eaddr[6]; s = splimp(); @@ -235,7 +237,12 @@ 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 @@ /* 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 @@ } /* Attach to OS's managers. */ - ether_ifattach(ifp, sc->sc_macaddr); + ether_ifattach(ifp, eaddr); splx(s); return (0); @@ -440,6 +447,8 @@ 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 @@ s = splimp(); sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->ifp; ether_ifdetach(ifp); @@ -720,7 +729,7 @@ 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 @@ /* 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 @@ } 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 @@ #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 @@ #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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/tx/if_txvar.h ifnet/sys/dev/tx/if_txvar.h --- freebsd/sys/dev/tx/if_txvar.h Tue Nov 4 13:50:02 2003 +++ ifnet/sys/dev/tx/if_txvar.h Fri Jun 3 15:58:42 2005 @@ -70,7 +70,7 @@ /* Driver status structure */ typedef struct { - struct arpcom arpcom; + struct ifnet *ifp; struct resource *res; struct resource *irq; @@ -123,9 +123,6 @@ u_int16_t dev_id; 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)) diff -ruN --exclude=compile freebsd/sys/dev/txp/if_txp.c ifnet/sys/dev/txp/if_txp.c --- freebsd/sys/dev/txp/if_txp.c Sun Jun 5 06:12:35 2005 +++ ifnet/sys/dev/txp/if_txp.c Tue Jun 7 16:40:51 2005 @@ -217,6 +217,7 @@ 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 @@ if (txp_chip_init(sc)) { txp_release_resources(sc); + /* XXX: set error to ??? */ goto fail; } @@ -286,29 +288,32 @@ 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 @@ 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 @@ /* * 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { struct ifnet *ifp; - ifp = &sc->sc_arpcom.ac_if; + ifp = sc->sc_ifp; ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); @@ -1737,7 +1751,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/txp/if_txpreg.h ifnet/sys/dev/txp/if_txpreg.h --- freebsd/sys/dev/txp/if_txpreg.h Thu Jan 6 22:28:09 2005 +++ ifnet/sys/dev/txp/if_txpreg.h Fri Jun 3 15:58:43 2005 @@ -591,7 +591,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/usb/if_aue.c ifnet/sys/dev/usb/if_aue.c --- freebsd/sys/dev/usb/if_aue.c Sat Apr 2 19:30:55 2005 +++ ifnet/sys/dev/usb/if_aue.c Tue Jun 7 16:40:51 2005 @@ -76,6 +76,7 @@ #include #include #include +#include #include @@ -524,7 +525,7 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/usb/if_auereg.h ifnet/sys/dev/usb/if_auereg.h --- freebsd/sys/dev/usb/if_auereg.h Sat Apr 2 19:30:55 2005 +++ ifnet/sys/dev/usb/if_auereg.h Fri Jun 3 15:58:44 2005 @@ -206,7 +206,7 @@ #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 -ruN --exclude=compile freebsd/sys/dev/usb/if_axe.c ifnet/sys/dev/usb/if_axe.c --- freebsd/sys/dev/usb/if_axe.c Sat Apr 2 19:30:55 2005 +++ ifnet/sys/dev/usb/if_axe.c Tue Jun 7 16:40:51 2005 @@ -81,6 +81,7 @@ #include #include #include +#include #include @@ -324,7 +325,7 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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_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 @@ 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 @@ #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_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->axe_ifp; ifp->if_timer = 0; untimeout(axe_tick, sc, sc->axe_stat_ch); diff -ruN --exclude=compile freebsd/sys/dev/usb/if_axereg.h ifnet/sys/dev/usb/if_axereg.h --- freebsd/sys/dev/usb/if_axereg.h Sat Apr 2 19:30:55 2005 +++ ifnet/sys/dev/usb/if_axereg.h Fri Jun 3 15:58:44 2005 @@ -127,7 +127,7 @@ #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 -ruN --exclude=compile freebsd/sys/dev/usb/if_cdce.c ifnet/sys/dev/usb/if_cdce.c --- freebsd/sys/dev/usb/if_cdce.c Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_cdce.c Fri Jun 3 15:58:44 2005 @@ -55,6 +55,7 @@ #include #include #include +#include #include @@ -282,9 +283,13 @@ } } - bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); + bcopy(eaddr, (char *)&GET_ARPCOM(sc)->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 +328,7 @@ cdce_shutdown(sc->cdce_dev); ether_ifdetach(ifp); + if_free(ifp); CDCE_UNLOCK(sc); mtx_destroy(&sc->cdce_mtx); diff -ruN --exclude=compile freebsd/sys/dev/usb/if_cdcereg.h ifnet/sys/dev/usb/if_cdcereg.h --- freebsd/sys/dev/usb/if_cdcereg.h Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_cdcereg.h Tue Jun 7 11:34:57 2005 @@ -43,8 +43,9 @@ }; 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) +#define GET_ARPCOM(sc) (IFP2AC((sc)->cdce_ifp)) usbd_device_handle cdce_udev; usbd_interface_handle cdce_data_iface; diff -ruN --exclude=compile freebsd/sys/dev/usb/if_cue.c ifnet/sys/dev/usb/if_cue.c --- freebsd/sys/dev/usb/if_cue.c Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_cue.c Tue Jun 7 16:40:52 2005 @@ -64,6 +64,7 @@ #include #include #include +#include #include @@ -340,7 +341,7 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ /* 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_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->cue_ifp; ifp->if_timer = 0; cue_csr_write_1(sc, CUE_ETHCTL, 0); diff -ruN --exclude=compile freebsd/sys/dev/usb/if_cuereg.h ifnet/sys/dev/usb/if_cuereg.h --- freebsd/sys/dev/usb/if_cuereg.h Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_cuereg.h Fri Jun 3 15:58:45 2005 @@ -142,7 +142,7 @@ #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 -ruN --exclude=compile freebsd/sys/dev/usb/if_kue.c ifnet/sys/dev/usb/if_kue.c --- freebsd/sys/dev/usb/if_kue.c Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_kue.c Tue Jun 7 16:40:52 2005 @@ -79,6 +79,7 @@ #include #include #include +#include #include @@ -315,7 +316,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ /* 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 @@ struct ifnet *ifp; KUE_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->kue_ifp; ifp->if_timer = 0; /* Stop transfers. */ diff -ruN --exclude=compile freebsd/sys/dev/usb/if_kuereg.h ifnet/sys/dev/usb/if_kuereg.h --- freebsd/sys/dev/usb/if_kuereg.h Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_kuereg.h Fri Jun 3 15:58:45 2005 @@ -135,7 +135,7 @@ #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 -ruN --exclude=compile freebsd/sys/dev/usb/if_rue.c ifnet/sys/dev/usb/if_rue.c --- freebsd/sys/dev/usb/if_rue.c Sat Apr 2 19:30:56 2005 +++ ifnet/sys/dev/usb/if_rue.c Tue Jun 7 16:40:52 2005 @@ -79,6 +79,7 @@ #include #include #include +#include #include @@ -481,7 +482,7 @@ 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 @@ 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 @@ 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 @@ free(devinfo, M_USBDEV); USB_ATTACH_SUCCESS_RETURN; + error2: + if_free(ifp); error1: RUE_UNLOCK(sc); #if __FreeBSD_version >= 500000 @@ -721,7 +726,7 @@ 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 @@ 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 @@ 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 @@ 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_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_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 @@ 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_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_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->rue_ifp; ifp->if_timer = 0; rue_csr_write_1(sc, RUE_CR, 0x00); diff -ruN --exclude=compile freebsd/sys/dev/usb/if_ruereg.h ifnet/sys/dev/usb/if_ruereg.h --- freebsd/sys/dev/usb/if_ruereg.h Sat Apr 2 19:30:57 2005 +++ ifnet/sys/dev/usb/if_ruereg.h Fri Jun 3 15:58:45 2005 @@ -187,7 +187,7 @@ }; struct rue_softc { - struct arpcom arpcom; + struct ifnet *rue_ifp; device_t rue_dev; device_t rue_miibus; usbd_device_handle rue_udev; diff -ruN --exclude=compile freebsd/sys/dev/usb/if_udav.c ifnet/sys/dev/usb/if_udav.c --- freebsd/sys/dev/usb/if_udav.c Sat Apr 2 19:30:58 2005 +++ ifnet/sys/dev/usb/if_udav.c Fri Jun 3 15:58:46 2005 @@ -87,6 +87,7 @@ #include #include #include +#include #if NBPFILTER > 0 #include @@ -385,11 +386,20 @@ printf("%s: Ethernet address %s\n", devname, ether_sprintf(eaddr)); #if defined(__FreeBSD__) - bcopy(eaddr, (char *)&sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN); + bcopy(eaddr, (char *)&GET_AC(sc)->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 +537,9 @@ #if defined(__NetBSD__) if_detach(ifp); #endif +#if defined(__FreeBSD__) + if_free(ifp); +#endif #ifdef DIAGNOSTIC if (sc->sc_pipe_tx != NULL) @@ -836,7 +849,7 @@ #if defined(__NetBSD__) eaddr = LLADDR(ifp->if_sadl); #elif defined(__FreeBSD__) - eaddr = sc->sc_ac.ac_enaddr ; + eaddr = GET_AC(sc)->ac_enaddr ; #endif udav_csr_write(sc, UDAV_PAR, eaddr, ETHER_ADDR_LEN); diff -ruN --exclude=compile freebsd/sys/dev/usb/if_udavreg.h ifnet/sys/dev/usb/if_udavreg.h --- freebsd/sys/dev/usb/if_udavreg.h Sat Apr 2 19:30:58 2005 +++ ifnet/sys/dev/usb/if_udavreg.h Tue Jun 7 11:34:57 2005 @@ -137,12 +137,17 @@ #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) #endif #if defined(__FreeBSD__) +#define GET_AC(sc) (IFP2AC((sc)->sc_ifp)) +#endif +#if defined(__FreeBSD__) #define GET_MII(sc) (device_get_softc((sc)->sc_miibus)) #else #define GET_MII(sc) (&(sc)->sc_mii) @@ -160,7 +165,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 -ruN --exclude=compile freebsd/sys/dev/usb/if_ural.c ifnet/sys/dev/usb/if_ural.c --- freebsd/sys/dev/usb/if_ural.c Tue May 24 17:12:40 2005 +++ ifnet/sys/dev/usb/if_ural.c Fri Jun 3 19:47:36 2005 @@ -345,7 +345,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/usb/if_uralvar.h ifnet/sys/dev/usb/if_uralvar.h --- freebsd/sys/dev/usb/if_uralvar.h Fri Apr 29 17:37:18 2005 +++ ifnet/sys/dev/usb/if_uralvar.h Fri Jun 3 19:41:08 2005 @@ -68,7 +68,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/utopia/utopia.c ifnet/sys/dev/utopia/utopia.c --- freebsd/sys/dev/utopia/utopia.c Thu Mar 17 10:57:50 2005 +++ ifnet/sys/dev/utopia/utopia.c Tue May 24 17:17:37 2005 @@ -154,14 +154,14 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/vge/if_vge.c ifnet/sys/dev/vge/if_vge.c --- freebsd/sys/dev/vge/if_vge.c Tue Jun 7 22:46:03 2005 +++ ifnet/sys/dev/vge/if_vge.c Tue Jun 7 22:47:11 2005 @@ -96,6 +96,7 @@ #include #include #include +#include #include #include @@ -575,7 +576,7 @@ 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_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 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->vge_ifp; if (!(ifp->if_flags & IFF_UP)) { VGE_UNLOCK(sc); @@ -1819,7 +1825,7 @@ * 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 @@ 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 @@ /* 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 @@ 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 @@ struct ifnet *ifp; sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->vge_ifp; /* reenable busmastering */ pci_enable_busmaster(dev); diff -ruN --exclude=compile freebsd/sys/dev/vge/if_vgevar.h ifnet/sys/dev/vge/if_vgevar.h --- freebsd/sys/dev/vge/if_vgevar.h Sun Jun 5 13:33:15 2005 +++ ifnet/sys/dev/vge/if_vgevar.h Sun Jun 5 13:34:43 2005 @@ -98,7 +98,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/dev/vx/if_vx.c ifnet/sys/dev/vx/if_vx.c --- freebsd/sys/dev/vx/if_vx.c Sun Jun 5 06:12:41 2005 +++ ifnet/sys/dev/vx/if_vx.c Tue Jun 7 16:40:54 2005 @@ -68,6 +68,7 @@ #include #include +#include #include @@ -140,8 +141,15 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ void vxstop(struct vx_softc *sc) { - struct ifnet *ifp = &sc->arpcom.ac_if; + struct ifnet *ifp = sc->ifp; ifp->if_timer = 0; diff -ruN --exclude=compile freebsd/sys/dev/vx/if_vxvar.h ifnet/sys/dev/vx/if_vxvar.h --- freebsd/sys/dev/vx/if_vxvar.h Thu Jan 6 22:28:37 2005 +++ ifnet/sys/dev/vx/if_vxvar.h Fri Jun 3 15:58:46 2005 @@ -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 -ruN --exclude=compile freebsd/sys/dev/wi/if_wi.c ifnet/sys/dev/wi/if_wi.c --- freebsd/sys/dev/wi/if_wi.c Sun Jun 5 06:12:41 2005 +++ ifnet/sys/dev/wi/if_wi.c Fri Jun 3 19:47:43 2005 @@ -238,7 +238,7 @@ { 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 @@ }; 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 @@ 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 @@ 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 @@ break; case DVACT_DEACTIVATE: - if_deactivate(&sc->sc_if); + if_deactivate(sc->sc_ifp); break; } splx(s); @@ -558,7 +566,7 @@ 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 @@ { 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/wi/if_wivar.h ifnet/sys/dev/wi/if_wivar.h --- freebsd/sys/dev/wi/if_wivar.h Thu Jan 6 22:28:41 2005 +++ ifnet/sys/dev/wi/if_wivar.h Fri Jun 3 15:58:48 2005 @@ -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 @@ } 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 -ruN --exclude=compile freebsd/sys/dev/wl/if_wl.c ifnet/sys/dev/wl/if_wl.c --- freebsd/sys/dev/wl/if_wl.c Tue May 24 17:12:46 2005 +++ ifnet/sys/dev/wl/if_wl.c Tue Jun 7 16:40:58 2005 @@ -211,6 +211,7 @@ #include #include #include +#include #ifdef INET #include @@ -231,9 +232,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { #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 @@ 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 @@ 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 @@ (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 @@ } /* 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 @@ */ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/xe/if_xe.c ifnet/sys/dev/xe/if_xe.c --- freebsd/sys/dev/xe/if_xe.c Thu Jan 6 22:28:47 2005 +++ ifnet/sys/dev/xe/if_xe.c Tue Jun 7 16:40:58 2005 @@ -117,6 +117,7 @@ #include #include #include +#include #include #include @@ -225,7 +226,9 @@ /* 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 @@ } /* Attach the interface */ - ether_ifattach(scp->ifp, scp->arpcom.ac_enaddr); + ether_ifattach(scp->ifp, scp->enaddr); /* Done */ return 0; @@ -374,7 +377,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/xe/if_xe_pccard.c ifnet/sys/dev/xe/if_xe_pccard.c --- freebsd/sys/dev/xe/if_xe_pccard.c Tue Jan 25 21:40:21 2005 +++ ifnet/sys/dev/xe/if_xe_pccard.c Tue Jun 7 16:40:58 2005 @@ -243,7 +243,7 @@ } 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/dev/xe/if_xevar.h ifnet/sys/dev/xe/if_xevar.h --- freebsd/sys/dev/xe/if_xevar.h Fri Apr 9 14:11:10 2004 +++ ifnet/sys/dev/xe/if_xevar.h Tue Jun 7 16:40:58 2005 @@ -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 -ruN --exclude=compile freebsd/sys/i386/isa/if_el.c ifnet/sys/i386/isa/if_el.c --- freebsd/sys/i386/isa/if_el.c Sun Jun 5 06:12:45 2005 +++ ifnet/sys/i386/isa/if_el.c Tue Jun 7 16:40:59 2005 @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -61,7 +62,8 @@ /* 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 @@ { 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 @@ /* Now read the address */ for(i=0;iel_enaddr[i] = CSR_READ_1(sc,EL_EAW); } /* Now release resources */ @@ -177,19 +178,17 @@ 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 @@ * source code for this undocumented goodie... */ for(j=0;jarpcom.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 @@ /* 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 @@ 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 @@ /* 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ done = 1; } else { - sc->arpcom.ac_if.if_opackets++; + sc->el_ifp->if_opackets++; done = 1; } } @@ -513,7 +520,7 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/i4b/driver/i4b_ipr.c ifnet/sys/i4b/driver/i4b_ipr.c --- freebsd/sys/i4b/driver/i4b_ipr.c Thu Jan 6 22:29:43 2005 +++ ifnet/sys/i4b/driver/i4b_ipr.c Fri Jun 3 15:58:50 2005 @@ -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 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ { 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } #if I4BIPRACCT - sc->sc_if.if_timer = 0; + sc->sc_ifp->if_timer = 0; #endif #if IPR_LOG @@ -676,7 +679,7 @@ 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 @@ 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 @@ } #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 @@ * 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 @@ 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 @@ goto error; } - sc->sc_if.if_flags |= IPR_COMPRESS; + sc->sc_ifp->if_flags |= IPR_COMPRESS; } else { @@ -845,8 +848,8 @@ #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 @@ } #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 @@ mm.m_next = m; mm.m_len = 4; mm.m_data = (char *)⁡ - 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 @@ 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 @@ mm.m_next = m; mm.m_len = 4; mm.m_data = (char *)⁡ - BPF_MTAP(&sc->sc_if, &mm); + BPF_MTAP(sc->sc_ifp, &mm); } #if I4BIPRACCT @@ -943,7 +946,7 @@ #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 @@ } 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 -ruN --exclude=compile freebsd/sys/i4b/driver/i4b_isppp.c ifnet/sys/i4b/driver/i4b_isppp.c --- freebsd/sys/i4b/driver/i4b_isppp.c Thu Jan 6 22:29:43 2005 +++ ifnet/sys/i4b/driver/i4b_isppp.c Fri Jun 3 15:58:51 2005 @@ -71,7 +71,7 @@ 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 @@ #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 @@ i4bispppattach(void *dummy) { struct i4bisppp_softc *sc = i4bisppp_softc; + struct ifnet *ifp; int i; #ifdef SPPP_VJ @@ -171,40 +161,49 @@ 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; */ + /* ifp->if_output = sppp_output; */ - sc->sc_if.if_start = i4bisppp_start; + ifp->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_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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ { 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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ static void i4bisppp_tx_queue_empty(int unit) { - i4bisppp_start(&i4bisppp_softc[unit].sc_if); + i4bisppp_start((&i4bisppp_softc[unit])->sc_ifp); } /*---------------------------------------------------------------------------* diff -ruN --exclude=compile freebsd/sys/kern/uipc_socket.c ifnet/sys/kern/uipc_socket.c --- freebsd/sys/kern/uipc_socket.c Sun Jun 5 13:33:17 2005 +++ ifnet/sys/kern/uipc_socket.c Sun Jun 5 13:34:47 2005 @@ -728,7 +728,7 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/bpf.c ifnet/sys/net/bpf.c --- freebsd/sys/net/bpf.c Tue Jun 7 22:46:04 2005 +++ ifnet/sys/net/bpf.c Tue Jun 7 22:47:12 2005 @@ -1018,7 +1018,7 @@ 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 -ruN --exclude=compile freebsd/sys/net/bridge.c ifnet/sys/net/bridge.c --- freebsd/sys/net/bridge.c Sun Jun 5 06:13:02 2005 +++ ifnet/sys/net/bridge.c Tue Jun 7 16:40:59 2005 @@ -352,7 +352,7 @@ 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 -ruN --exclude=compile freebsd/sys/net/bridge.h ifnet/sys/net/bridge.h --- freebsd/sys/net/bridge.h Thu Jan 6 22:30:47 2005 +++ ifnet/sys/net/bridge.h Tue Apr 5 22:53:18 2005 @@ -42,7 +42,6 @@ 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 -ruN --exclude=compile freebsd/sys/net/bridgestp.c ifnet/sys/net/bridgestp.c --- freebsd/sys/net/bridgestp.c Sun Jun 5 13:33:19 2005 +++ ifnet/sys/net/bridgestp.c Sun Jun 5 20:19:00 2005 @@ -66,8 +66,6 @@ #include #include -#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_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 -ruN --exclude=compile freebsd/sys/net/firewire.h ifnet/sys/net/firewire.h --- freebsd/sys/net/firewire.h Mon Jun 14 22:11:03 2004 +++ ifnet/sys/net/firewire.h Tue May 24 17:18:10 2005 @@ -121,7 +121,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if.c ifnet/sys/net/if.c --- freebsd/sys/net/if.c Tue Jun 7 22:46:04 2005 +++ ifnet/sys/net/if.c Tue Jun 7 22:47:12 2005 @@ -127,6 +127,8 @@ 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 @@ 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_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; } @@ -339,7 +342,7 @@ 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 +379,59 @@ } /* + * 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 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 +443,10 @@ 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 +467,13 @@ 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 +625,7 @@ /* * 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 +1995,7 @@ 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 +2119,7 @@ KASSERT(debug_mpsafenet != 0, ("if_start_deferred: debug.mpsafenet")); GIANT_REQUIRED; - ifp = (struct ifnet *)context; + ifp = context; (ifp->if_start)(ifp); } @@ -2093,4 +2146,30 @@ if (ifp != NULL && !active) 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 -ruN --exclude=compile freebsd/sys/net/if_arc.h ifnet/sys/net/if_arc.h --- freebsd/sys/net/if_arc.h Thu Jan 6 22:30:48 2005 +++ ifnet/sys/net/if_arc.h Tue May 24 17:18:11 2005 @@ -102,7 +102,7 @@ #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 -ruN --exclude=compile freebsd/sys/net/if_arcsubr.c ifnet/sys/net/if_arcsubr.c --- freebsd/sys/net/if_arcsubr.c Thu Jan 6 22:30:49 2005 +++ ifnet/sys/net/if_arcsubr.c Tue Jun 7 16:41:01 2005 @@ -80,8 +80,6 @@ #include #endif -MODULE_VERSION(arcnet, 1); - #define ARCNET_ALLOW_BROKEN_ARP static struct mbuf *arc_defrag(struct ifnet *, struct mbuf *); @@ -254,7 +252,7 @@ { struct arccom *ac; - ac = (struct arccom *)ifp; + ac = (struct arccom *)ifp->if_l2com; ac->curr_frag = 0; } @@ -266,7 +264,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_arp.h ifnet/sys/net/if_arp.h --- freebsd/sys/net/if_arp.h Thu Jan 6 22:30:49 2005 +++ ifnet/sys/net/if_arp.h Tue Jun 7 16:41:01 2005 @@ -102,18 +102,19 @@ * 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. + * struct arpcom. */ struct arpcom { /* * The ifnet struct _must_ be at the head of this structure. */ - struct ifnet ac_if; /* network-visible interface */ + struct ifnet *ac_ifp; /* network-visible interface */ u_char ac_enaddr[6]; /* ethernet hardware address */ - int now_unused; /* XXX was length of ac_multiaddrs list */ 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 -ruN --exclude=compile freebsd/sys/net/if_atm.h ifnet/sys/net/if_atm.h --- freebsd/sys/net/if_atm.h Thu Jan 6 22:30:49 2005 +++ ifnet/sys/net/if_atm.h Tue May 24 17:18:11 2005 @@ -176,11 +176,12 @@ * 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 @@ _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 @@ _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 @@ _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 -ruN --exclude=compile freebsd/sys/net/if_atmsubr.c ifnet/sys/net/if_atmsubr.c --- freebsd/sys/net/if_atmsubr.c Thu Jan 6 22:30:49 2005 +++ ifnet/sys/net/if_atmsubr.c Tue Jun 7 16:41:01 2005 @@ -98,6 +98,8 @@ 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 @@ { 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_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 -ruN --exclude=compile freebsd/sys/net/if_bridge.c ifnet/sys/net/if_bridge.c --- freebsd/sys/net/if_bridge.c Tue Jun 7 22:46:04 2005 +++ ifnet/sys/net/if_bridge.c Tue Jun 7 22:47:13 2005 @@ -131,7 +131,6 @@ #include #include -#define sc_if ifb_ac.ac_if /* * Size of the route hash table. Must be a power of two. */ @@ -356,7 +355,7 @@ 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; @@ -417,10 +416,11 @@ { 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; @@ -455,12 +455,12 @@ * 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; @@ -691,7 +691,7 @@ free(bif, M_DEVBUF); - if (sc->sc_if.if_flags & IFF_RUNNING) + if (sc->sc_ifp->if_flags & IFF_RUNNING) bstp_initialization(sc); } @@ -709,7 +709,7 @@ 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) @@ -751,7 +751,7 @@ */ 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); @@ -828,7 +828,7 @@ 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); @@ -1029,7 +1029,7 @@ 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); @@ -1058,7 +1058,7 @@ 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); @@ -1087,7 +1087,7 @@ 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); @@ -1116,7 +1116,7 @@ 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); @@ -1136,7 +1136,7 @@ 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); @@ -1156,7 +1156,7 @@ 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); @@ -1191,7 +1191,7 @@ 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; @@ -1244,7 +1244,7 @@ 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) @@ -1255,13 +1255,13 @@ 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++; } } @@ -1304,7 +1304,7 @@ * 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; } @@ -1354,7 +1354,7 @@ } else { mc = m_copym(m, 0, M_COPYALL, M_DONTWAIT); if (mc == NULL) { - sc->sc_if.if_oerrors++; + sc->sc_ifp->if_oerrors++; continue; } } @@ -1442,10 +1442,10 @@ 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. @@ -1513,7 +1513,7 @@ } } else { /* ...forward it to all interfaces. */ - sc->sc_if.if_imcasts++; + sc->sc_ifp->if_imcasts++; dst_if = NULL; } @@ -1585,7 +1585,7 @@ 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); @@ -1597,7 +1597,7 @@ 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 @@ -1610,9 +1610,9 @@ */ /* 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); @@ -1748,7 +1748,7 @@ } else { mc = m_copym(m, 0, M_COPYALL, M_DONTWAIT); if (mc == NULL) { - sc->sc_if.if_oerrors++; + sc->sc_ifp->if_oerrors++; continue; } } @@ -1879,7 +1879,7 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_bridgevar.h ifnet/sys/net/if_bridgevar.h --- freebsd/sys/net/if_bridgevar.h Sun Jun 5 13:33:21 2005 +++ ifnet/sys/net/if_bridgevar.h Sun Jun 5 20:19:01 2005 @@ -262,7 +262,7 @@ * 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 -ruN --exclude=compile freebsd/sys/net/if_disc.c ifnet/sys/net/if_disc.c --- freebsd/sys/net/if_disc.c Thu Mar 17 10:59:14 2005 +++ ifnet/sys/net/if_disc.c Fri Jun 3 15:58:51 2005 @@ -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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_ef.c ifnet/sys/net/if_ef.c --- freebsd/sys/net/if_ef.c Thu Mar 17 10:59:15 2005 +++ ifnet/sys/net/if_ef.c Tue Jun 7 16:41:02 2005 @@ -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_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 @@ /* * 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 @@ 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 @@ 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 @@ int error; ifp->if_flags |= IFF_OACTIVE; - p = sc->ef_ifp; + p = sc->ef_pifp; EFDEBUG("\n"); for (;;) { @@ -377,7 +365,7 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_ethersubr.c ifnet/sys/net/if_ethersubr.c --- freebsd/sys/net/if_ethersubr.c Sun Jun 5 13:33:21 2005 +++ ifnet/sys/net/if_ethersubr.c Tue Jun 7 16:41:03 2005 @@ -124,6 +124,9 @@ 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) @@ -284,7 +287,7 @@ (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)); /* @@ -693,7 +696,7 @@ 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; @@ -890,7 +893,6 @@ 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); @@ -912,8 +914,8 @@ * 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) @@ -1050,16 +1052,15 @@ 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); } /* @@ -1080,7 +1081,7 @@ 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; @@ -1181,11 +1182,47 @@ } } +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 -ruN --exclude=compile freebsd/sys/net/if_faith.c ifnet/sys/net/if_faith.c --- freebsd/sys/net/if_faith.c Thu Mar 17 10:59:15 2005 +++ ifnet/sys/net/if_faith.c Fri Jun 3 15:58:52 2005 @@ -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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_fddisubr.c ifnet/sys/net/if_fddisubr.c --- freebsd/sys/net/if_fddisubr.c Thu Mar 24 21:06:24 2005 +++ ifnet/sys/net/if_fddisubr.c Tue Jun 7 16:41:03 2005 @@ -308,7 +308,7 @@ 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 @@ * 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 @@ 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); @@ -668,7 +668,7 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_fwsubr.c ifnet/sys/net/if_fwsubr.c --- freebsd/sys/net/if_fwsubr.c Sat Apr 2 19:31:26 2005 +++ ifnet/sys/net/if_fwsubr.c Sun Jun 5 12:25:24 2005 @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_gif.c ifnet/sys/net/if_gif.c --- freebsd/sys/net/if_gif.c Thu Jan 6 22:30:51 2005 +++ ifnet/sys/net/if_gif.c Fri Jun 3 15:58:52 2005 @@ -144,9 +144,14 @@ 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 @@ 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; + GIF2IFP(sc)->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_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 @@ (*ng_gif_detach_p)(ifp); bpfdetach(ifp); if_detach(ifp); + if_free(ifp); free(sc, M_GIF); } @@ -284,7 +289,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_gif.h ifnet/sys/net/if_gif.h --- freebsd/sys/net/if_gif.h Thu Jan 6 22:30:51 2005 +++ ifnet/sys/net/if_gif.h Tue May 24 17:18:13 2005 @@ -56,7 +56,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_gre.c ifnet/sys/net/if_gre.c --- freebsd/sys/net/if_gre.c Thu Jan 6 22:30:51 2005 +++ ifnet/sys/net/if_gre.c Tue May 24 17:18:14 2005 @@ -169,24 +169,24 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ &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 @@ * 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 @@ } #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 @@ * 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 -ruN --exclude=compile freebsd/sys/net/if_gre.h ifnet/sys/net/if_gre.h --- freebsd/sys/net/if_gre.h Thu Jan 6 22:30:52 2005 +++ ifnet/sys/net/if_gre.h Tue May 24 17:18:14 2005 @@ -55,7 +55,7 @@ } 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 @@ wccp_ver_t wccp_ver; /* version of the WCCP */ }; +#define GRE2IFP(sc) ((sc)->sc_ifp) struct gre_h { diff -ruN --exclude=compile freebsd/sys/net/if_iso88025subr.c ifnet/sys/net/if_iso88025subr.c --- freebsd/sys/net/if_iso88025subr.c Thu Jan 6 22:30:52 2005 +++ ifnet/sys/net/if_iso88025subr.c Tue Jun 7 16:41:03 2005 @@ -123,7 +123,7 @@ 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); @@ -206,7 +206,7 @@ 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 +272,7 @@ /* 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 +517,7 @@ */ 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; @@ -774,9 +774,48 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_loop.c ifnet/sys/net/if_loop.c --- freebsd/sys/net/if_loop.c Thu Mar 17 10:59:15 2005 +++ ifnet/sys/net/if_loop.c Fri Jun 3 15:58:52 2005 @@ -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 @@ mtx_unlock(&lo_mtx); bpfdetach(ifp); if_detach(ifp); + if_free(ifp); free(sc, M_LO); } @@ -137,25 +138,30 @@ 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); - - 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)); + ifp = sc->sc_ifp = if_alloc(IFT_LOOP); + if (ifp == NULL) { + free(sc, M_LO); + return (ENOSPC); + } + + 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 -ruN --exclude=compile freebsd/sys/net/if_ppp.c ifnet/sys/net/if_ppp.c --- freebsd/sys/net/if_ppp.c Thu Jan 6 22:30:54 2005 +++ ifnet/sys/net/if_ppp.c Fri Jun 3 15:58:53 2005 @@ -223,26 +223,32 @@ 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 @@ { 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 @@ { 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 @@ break; case PPPIOCGUNIT: - *(int *)data = sc->sc_if.if_dunit; + *(int *)data = PPP2IFP(sc)->if_dunit; break; case PPPIOCGFLAGS: @@ -547,7 +554,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ *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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ /* * 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 @@ bad: if (m) m_freem(m); - sc->sc_if.if_ierrors++; + PPP2IFP(sc)->if_ierrors++; sc->sc_stats.ppp_ierrors++; } diff -ruN --exclude=compile freebsd/sys/net/if_pppvar.h ifnet/sys/net/if_pppvar.h --- freebsd/sys/net/if_pppvar.h Thu Jan 6 22:30:54 2005 +++ ifnet/sys/net/if_pppvar.h Tue May 24 17:18:15 2005 @@ -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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_sl.c ifnet/sys/net/if_sl.c --- freebsd/sys/net/if_sl.c Thu Jan 6 22:30:54 2005 +++ ifnet/sys/net/if_sl.c Fri Jun 3 15:58:53 2005 @@ -231,10 +231,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ } 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 @@ */ 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 @@ */ if (cfreecount < CLISTRESERVE + SLTMAX) { m_freem(m); - sc->sc_if.if_collisions++; + SL2IFP(sc)->if_collisions++; continue; } @@ -723,7 +728,7 @@ * 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 @@ 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 @@ (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 @@ */ (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 @@ 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 @@ } 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 @@ /* 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 @@ * 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_slvar.h ifnet/sys/net/if_slvar.h --- freebsd/sys/net/if_slvar.h Fri Apr 9 14:12:19 2004 +++ ifnet/sys/net/if_slvar.h Tue May 24 17:18:16 2005 @@ -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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_sppp.h ifnet/sys/net/if_sppp.h --- freebsd/sys/net/if_sppp.h Thu Jan 6 22:30:55 2005 +++ ifnet/sys/net/if_sppp.h Fri Jun 3 15:58:54 2005 @@ -136,8 +136,7 @@ #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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_spppfr.c ifnet/sys/net/if_spppfr.c --- freebsd/sys/net/if_spppfr.c Thu Jan 6 22:30:55 2005 +++ ifnet/sys/net/if_spppfr.c Tue Apr 5 22:53:26 2005 @@ -159,7 +159,7 @@ /* 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 -ruN --exclude=compile freebsd/sys/net/if_spppsubr.c ifnet/sys/net/if_spppsubr.c --- freebsd/sys/net/if_spppsubr.c Thu Jan 6 22:30:57 2005 +++ ifnet/sys/net/if_spppsubr.c Sun Jun 5 12:25:26 2005 @@ -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 @@ #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 @@ /* 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 @@ &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 @@ { 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 @@ ++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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_stf.c ifnet/sys/net/if_stf.c --- freebsd/sys/net/if_stf.c Thu Mar 17 10:59:16 2005 +++ ifnet/sys/net/if_stf.c Fri Jun 3 15:58:56 2005 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } #endif - sc = (struct stf_softc*)ifp; + sc = ifp->if_softc; dst6 = (struct sockaddr_in6 *)dst; /* just in case */ @@ -609,7 +615,7 @@ /* * 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_tap.c ifnet/sys/net/if_tap.c --- freebsd/sys/net/if_tap.c Sun Jun 5 06:13:03 2005 +++ ifnet/sys/net/if_tap.c Tue Jun 7 16:41:04 2005 @@ -62,6 +62,7 @@ #include #include #include +#include #include @@ -191,7 +192,7 @@ 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 @@ 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 @@ unsigned short macaddr_hi; int unit, s; char *name = NULL; + u_char eaddr[6]; dev->si_flags &= ~SI_CHEAPCLONE; @@ -309,12 +312,14 @@ /* 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_tapvar.h ifnet/sys/net/if_tapvar.h --- freebsd/sys/net/if_tapvar.h Thu Jan 6 22:30:57 2005 +++ ifnet/sys/net/if_tapvar.h Fri Jun 3 15:58:56 2005 @@ -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 -ruN --exclude=compile freebsd/sys/net/if_tun.c ifnet/sys/net/if_tun.c --- freebsd/sys/net/if_tun.c Tue May 24 17:13:22 2005 +++ ifnet/sys/net/if_tun.c Fri Jun 3 15:58:57 2005 @@ -85,11 +85,12 @@ * 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 -ruN --exclude=compile freebsd/sys/net/if_types.h ifnet/sys/net/if_types.h --- freebsd/sys/net/if_types.h Sun Jun 5 13:33:22 2005 +++ ifnet/sys/net/if_types.h Sun Jun 5 13:34:51 2005 @@ -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 -ruN --exclude=compile freebsd/sys/net/if_var.h ifnet/sys/net/if_var.h --- freebsd/sys/net/if_var.h Sun Jun 5 13:33:22 2005 +++ ifnet/sys/net/if_var.h Sun Jun 5 13:34:52 2005 @@ -109,27 +109,9 @@ * (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 _softc { - * struct arpcom { - * struct ifnet ac_if; - * ... - * } ; - * ... - * }; - * - * 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 @@ 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); @@ -651,6 +636,11 @@ 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 -ruN --exclude=compile freebsd/sys/net/if_vlan.c ifnet/sys/net/if_vlan.c --- freebsd/sys/net/if_vlan.c Fri Apr 29 17:37:49 2005 +++ ifnet/sys/net/if_vlan.c Tue Jun 7 16:41:04 2005 @@ -76,7 +76,7 @@ }; 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 @@ 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_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 @@ 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 @@ } 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 @@ 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_unconfig(ifp); VLAN_UNLOCK(); ether_ifdetach(ifp); + if_free_type(ifp, IFT_ETHER); free(ifv, M_VLAN); return (error); @@ -431,6 +437,7 @@ VLAN_UNLOCK(); ether_ifdetach(ifp); + if_free(ifp); free(ifv, M_VLAN); @@ -600,7 +607,7 @@ 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 @@ 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 @@ } 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 @@ * 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 @@ /* 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_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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net/ppp_tty.c ifnet/sys/net/ppp_tty.c --- freebsd/sys/net/ppp_tty.c Thu Jan 6 22:31:01 2005 +++ ifnet/sys/net/ppp_tty.c Tue May 24 17:18:18 2005 @@ -207,9 +207,9 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } 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 @@ /* 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/net80211/ieee80211_ioctl.c ifnet/sys/net80211/ieee80211_ioctl.c --- freebsd/sys/net80211/ieee80211_ioctl.c Tue Jun 7 22:46:05 2005 +++ ifnet/sys/net80211/ieee80211_ioctl.c Tue Jun 7 22:47:13 2005 @@ -2387,7 +2387,7 @@ */ case AF_IPX: { struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); - struct arpcom *ac = (struct arpcom *)ifp; + struct arpcom *ac = IFP2AC(ifp); if (ipx_nullhost(*ina)) ina->x_host = *(union ipx_host *) ac->ac_enaddr; diff -ruN --exclude=compile freebsd/sys/netatalk/aarp.c ifnet/sys/netatalk/aarp.c --- freebsd/sys/netatalk/aarp.c Thu Mar 17 10:59:22 2005 +++ ifnet/sys/netatalk/aarp.c Tue Jun 7 16:41:04 2005 @@ -196,7 +196,7 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/atm_if.c ifnet/sys/netatm/atm_if.c --- freebsd/sys/netatm/atm_if.c Thu Jan 6 22:31:11 2005 +++ ifnet/sys/netatm/atm_if.c Fri Jun 3 15:58:57 2005 @@ -341,7 +341,7 @@ "%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 @@ */ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ { struct atm_ncm *ncp; int s; - struct ifnet *ifp = &nip->nif_if; + struct ifnet *ifp = nip->nif_ifp; s = splimp(); @@ -853,6 +860,7 @@ * then remove from the system interface list */ if_detach(ifp); + if_free(ifp); /* * Remove from physical interface list @@ -970,7 +978,7 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/atm_if.h ifnet/sys/netatm/atm_if.h --- freebsd/sys/netatm/atm_if.h Thu Jan 6 22:31:11 2005 +++ ifnet/sys/netatm/atm_if.h Tue May 24 17:18:19 2005 @@ -224,7 +224,7 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/atm_socket.c ifnet/sys/netatm/atm_socket.c --- freebsd/sys/netatm/atm_socket.c Thu Mar 17 10:59:23 2005 +++ ifnet/sys/netatm/atm_socket.c Tue May 24 17:18:19 2005 @@ -1218,7 +1218,7 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/atm_usrreq.c ifnet/sys/netatm/atm_usrreq.c --- freebsd/sys/netatm/atm_usrreq.c Thu Jan 6 22:31:13 2005 +++ ifnet/sys/netatm/atm_usrreq.c Tue May 24 17:18:19 2005 @@ -393,7 +393,7 @@ */ for (nip = pip->pif_nif; nip; nip = nip->nif_pnext) { - if (&nip->nif_if == ifp2) + if (ANIF2IFP(nip) == ifp2) break; } if (nip) diff -ruN --exclude=compile freebsd/sys/netatm/ipatm/ipatm_input.c ifnet/sys/netatm/ipatm/ipatm_input.c --- freebsd/sys/netatm/ipatm/ipatm_input.c Thu Jan 6 22:31:13 2005 +++ ifnet/sys/netatm/ipatm/ipatm_input.c Thu Feb 3 22:32:13 2005 @@ -142,7 +142,7 @@ /* * 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 -ruN --exclude=compile freebsd/sys/netatm/ipatm/ipatm_load.c ifnet/sys/netatm/ipatm/ipatm_load.c --- freebsd/sys/netatm/ipatm/ipatm_load.c Thu Mar 17 10:59:24 2005 +++ ifnet/sys/netatm/ipatm/ipatm_load.c Tue Apr 5 22:53:41 2005 @@ -438,7 +438,7 @@ * 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 -ruN --exclude=compile freebsd/sys/netatm/ipatm/ipatm_output.c ifnet/sys/netatm/ipatm/ipatm_output.c --- freebsd/sys/netatm/ipatm/ipatm_output.c Thu Jan 6 22:31:13 2005 +++ ifnet/sys/netatm/ipatm/ipatm_output.c Tue Apr 5 22:53:42 2005 @@ -92,7 +92,7 @@ /* * 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 @@ */ 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 -ruN --exclude=compile freebsd/sys/netatm/ipatm/ipatm_usrreq.c ifnet/sys/netatm/ipatm/ipatm_usrreq.c --- freebsd/sys/netatm/ipatm/ipatm_usrreq.c Thu Jan 6 22:31:14 2005 +++ ifnet/sys/netatm/ipatm/ipatm_usrreq.c Tue May 24 17:18:19 2005 @@ -325,7 +325,7 @@ } 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 @@ } 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 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/ipatm/ipatm_vcm.c ifnet/sys/netatm/ipatm/ipatm_vcm.c --- freebsd/sys/netatm/ipatm/ipatm_vcm.c Thu Jan 6 22:31:14 2005 +++ ifnet/sys/netatm/ipatm/ipatm_vcm.c Tue Apr 5 22:53:42 2005 @@ -367,7 +367,7 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/spans/spans_arp.c ifnet/sys/netatm/spans/spans_arp.c --- freebsd/sys/netatm/spans/spans_arp.c Thu Jan 6 22:31:15 2005 +++ ifnet/sys/netatm/spans/spans_arp.c Thu Feb 3 22:32:15 2005 @@ -665,7 +665,7 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/netatm/uni/uniarp.c ifnet/sys/netatm/uni/uniarp.c --- freebsd/sys/netatm/uni/uniarp.c Thu Jan 6 22:31:22 2005 +++ ifnet/sys/netatm/uni/uniarp.c Thu Feb 3 22:32:22 2005 @@ -722,7 +722,7 @@ /* * 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 @@ 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 @@ */ 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 @@ /* * 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 -ruN --exclude=compile freebsd/sys/netatm/uni/uniarp_cache.c ifnet/sys/netatm/uni/uniarp_cache.c --- freebsd/sys/netatm/uni/uniarp_cache.c Thu Jan 6 22:31:22 2005 +++ ifnet/sys/netatm/uni/uniarp_cache.c Thu Feb 3 22:32:22 2005 @@ -413,7 +413,7 @@ * 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 -ruN --exclude=compile freebsd/sys/netgraph/atm/atmpif/ng_atmpif_harp.c ifnet/sys/netgraph/atm/atmpif/ng_atmpif_harp.c --- freebsd/sys/netgraph/atm/atmpif/ng_atmpif_harp.c Thu Jan 6 22:31:27 2005 +++ ifnet/sys/netgraph/atm/atmpif/ng_atmpif_harp.c Thu Feb 3 22:32:28 2005 @@ -677,7 +677,7 @@ 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 @@ 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 @@ */ 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 -ruN --exclude=compile freebsd/sys/netgraph/atm/ng_atm.c ifnet/sys/netgraph/atm/ng_atm.c --- freebsd/sys/netgraph/atm/ng_atm.c Fri Feb 4 22:43:43 2005 +++ ifnet/sys/netgraph/atm/ng_atm.c Tue Apr 5 22:53:43 2005 @@ -346,8 +346,8 @@ } 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 -ruN --exclude=compile freebsd/sys/netgraph/ng_eiface.c ifnet/sys/netgraph/ng_eiface.c --- freebsd/sys/netgraph/ng_eiface.c Fri Apr 29 17:37:49 2005 +++ ifnet/sys/netgraph/ng_eiface.c Tue Jun 7 16:41:05 2005 @@ -73,8 +73,7 @@ /* 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 @@ 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 @@ { 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 @@ #endif /* Attach the interface */ - ether_ifattach(ifp, priv->arpcom.ac_enaddr); + ether_ifattach(ifp, eaddr); /* Done */ return (0); @@ -378,7 +382,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netgraph/ng_ether.c ifnet/sys/netgraph/ng_ether.c --- freebsd/sys/netgraph/ng_ether.c Thu Mar 17 10:59:30 2005 +++ ifnet/sys/netgraph/ng_ether.c Tue Jun 7 16:41:05 2005 @@ -68,8 +68,8 @@ #include #include -#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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netgraph/ng_fec.c ifnet/sys/netgraph/ng_fec.c --- freebsd/sys/netgraph/ng_fec.c Thu Mar 17 10:59:31 2005 +++ ifnet/sys/netgraph/ng_fec.c Tue Jun 7 16:41:05 2005 @@ -171,7 +171,7 @@ /* 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 @@ { 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 @@ return(EINVAL); b = &priv->fec_bundle; - ifp = &priv->arpcom.ac_if; + ifp = priv->ifp; /* Find the interface */ bifp = ifunit(iface); @@ -400,8 +399,6 @@ 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 @@ 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 @@ 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 @@ { 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 @@ return(EINVAL); b = &priv->fec_bundle; - ifp = &priv->arpcom.ac_if; + ifp = priv->ifp; /* Find the interface */ bifp = ifunit(iface); @@ -491,10 +487,9 @@ (*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 @@ } } - 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netgraph/ng_gif.c ifnet/sys/netgraph/ng_gif.c --- freebsd/sys/netgraph/ng_gif.c Thu Mar 17 10:59:31 2005 +++ ifnet/sys/netgraph/ng_gif.c Tue Apr 5 22:53:49 2005 @@ -89,8 +89,8 @@ #include #include -#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 -ruN --exclude=compile freebsd/sys/netgraph/ng_iface.c ifnet/sys/netgraph/ng_iface.c --- freebsd/sys/netgraph/ng_iface.c Sat Apr 2 19:31:29 2005 +++ ifnet/sys/netgraph/ng_iface.c Fri Jun 3 15:58:58 2005 @@ -470,7 +470,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netgraph/ng_sppp.c ifnet/sys/netgraph/ng_sppp.c --- freebsd/sys/netgraph/ng_sppp.c Fri Feb 4 22:43:45 2005 +++ ifnet/sys/netgraph/ng_sppp.c Fri Jun 3 15:58:59 2005 @@ -51,7 +51,7 @@ /* 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 @@ ng_sppp_constructor (node_p node) { struct sppp *pp; + struct ifnet *ifp; priv_p priv; int error = 0; @@ -250,15 +251,16 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ { 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 -ruN --exclude=compile freebsd/sys/netinet/in_gif.c ifnet/sys/netinet/in_gif.c --- freebsd/sys/netinet/in_gif.c Thu Jan 6 22:31:59 2005 +++ ifnet/sys/netinet/in_gif.c Tue May 24 17:18:22 2005 @@ -92,7 +92,7 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/netinet/ip_carp.c ifnet/sys/netinet/ip_carp.c --- freebsd/sys/netinet/ip_carp.c Tue May 24 17:13:29 2005 +++ ifnet/sys/netinet/ip_carp.c Tue Jun 7 16:41:06 2005 @@ -88,8 +88,7 @@ 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 @@ 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 @@ 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 @@ } #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_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 @@ 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 @@ 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 @@ 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 @@ mtx_unlock(&carp_mtx); bpfdetach(ifp); if_detach(ifp); + if_free_type(ifp, IFT_ETHER); free(sc, M_CARP); } @@ -623,7 +628,7 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } 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_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_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_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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ } 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_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 @@ 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 @@ 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 @@ } 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_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 @@ 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 @@ #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 @@ 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 @@ #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_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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 -ruN --exclude=compile freebsd/sys/netinet/ip_gre.c ifnet/sys/netinet/ip_gre.c --- freebsd/sys/netinet/ip_gre.c Thu Jan 6 22:32:06 2005 +++ ifnet/sys/netinet/ip_gre.c Tue May 24 17:18:27 2005 @@ -155,8 +155,8 @@ } 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 @@ /* 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netinet/ip_output.c ifnet/sys/netinet/ip_output.c --- freebsd/sys/netinet/ip_output.c Thu Mar 17 10:59:45 2005 +++ ifnet/sys/netinet/ip_output.c Tue Apr 5 22:54:01 2005 @@ -974,7 +974,7 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/netinet6/in6_gif.c ifnet/sys/netinet6/in6_gif.c --- freebsd/sys/netinet6/in6_gif.c Thu Jan 6 22:32:21 2005 +++ ifnet/sys/netinet6/in6_gif.c Tue May 24 17:18:38 2005 @@ -88,7 +88,7 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/netinet6/ip6_output.c ifnet/sys/netinet6/ip6_output.c --- freebsd/sys/netinet6/ip6_output.c Tue May 24 17:13:49 2005 +++ ifnet/sys/netinet6/ip6_output.c Fri Jun 3 19:48:37 2005 @@ -1173,7 +1173,7 @@ } 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 -ruN --exclude=compile freebsd/sys/netipx/ipx_ip.c ifnet/sys/netipx/ipx_ip.c --- freebsd/sys/netipx/ipx_ip.c Thu Jan 6 22:32:41 2005 +++ ifnet/sys/netipx/ipx_ip.c Fri Jun 3 15:59:00 2005 @@ -59,6 +59,7 @@ #include #include +#include #include #include @@ -108,7 +109,11 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ * 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 @@ 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 -ruN --exclude=compile freebsd/sys/netipx/ipx_ip.h ifnet/sys/netipx/ipx_ip.h --- freebsd/sys/netipx/ipx_ip.h Thu Jan 6 22:32:41 2005 +++ ifnet/sys/netipx/ipx_ip.h Tue May 24 17:18:39 2005 @@ -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 -ruN --exclude=compile freebsd/sys/pci/if_dc.c ifnet/sys/pci/if_dc.c --- freebsd/sys/pci/if_dc.c Sun Jun 5 06:13:19 2005 +++ ifnet/sys/pci/if_dc.c Tue Jun 7 16:41:08 2005 @@ -1084,7 +1084,7 @@ 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 @@ } /* 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 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ } 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 @@ 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 @@ if (error) { printf("dc%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -2337,12 +2342,13 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_dcreg.h ifnet/sys/pci/if_dcreg.h --- freebsd/sys/pci/if_dcreg.h Thu Jan 6 22:33:19 2005 +++ ifnet/sys/pci/if_dcreg.h Fri Jun 3 15:59:02 2005 @@ -716,7 +716,7 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_de.c ifnet/sys/pci/if_de.c --- freebsd/sys/pci/if_de.c Thu Mar 17 11:00:16 2005 +++ ifnet/sys/pci/if_de.c Tue Jun 7 16:41:11 2005 @@ -59,6 +59,7 @@ #include #include #include +#include #include #ifdef TULIP_USE_SOFTINTR #include @@ -207,8 +208,8 @@ /* * 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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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_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 @@ { 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 @@ 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 @@ * 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 @@ 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_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 @@ 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 @@ #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 @@ } #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 @@ 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 @@ } #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 @@ } #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } 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 @@ 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 @@ */ 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 @@ * 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 @@ #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 @@ /* * 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 @@ */ 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 @@ 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 @@ (*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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ #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 @@ } #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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ #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 @@ 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 @@ /* * 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 @@ 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 @@ 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 @@ #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_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_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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ (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_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 @@ 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 @@ 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 @@ #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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_devar.h ifnet/sys/pci/if_devar.h --- freebsd/sys/pci/if_devar.h Mon Jul 19 15:12:33 2004 +++ ifnet/sys/pci/if_devar.h Tue Jun 7 16:41:11 2005 @@ -521,7 +521,8 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_mn.c ifnet/sys/pci/if_mn.c --- freebsd/sys/pci/if_mn.c Thu Mar 17 11:00:17 2005 +++ ifnet/sys/pci/if_mn.c Thu Mar 24 21:12:36 2005 @@ -1060,7 +1060,7 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_pcn.c ifnet/sys/pci/if_pcn.c --- freebsd/sys/pci/if_pcn.c Sun Jun 5 06:13:19 2005 +++ ifnet/sys/pci/if_pcn.c Tue Jun 7 16:41:12 2005 @@ -66,6 +66,7 @@ #include #include #include +#include #include @@ -334,7 +335,7 @@ 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 @@ */ 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 @@ } 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 @@ 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 @@ 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_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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ register int i; struct ifnet *ifp; - ifp = &sc->arpcom.ac_if; + ifp = sc->pcn_ifp; PCN_LOCK(sc); ifp->if_timer = 0; diff -ruN --exclude=compile freebsd/sys/pci/if_pcnreg.h ifnet/sys/pci/if_pcnreg.h --- freebsd/sys/pci/if_pcnreg.h Thu Jan 6 22:33:19 2005 +++ ifnet/sys/pci/if_pcnreg.h Fri Jun 3 15:59:03 2005 @@ -451,7 +451,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/pci/if_rl.c ifnet/sys/pci/if_rl.c --- freebsd/sys/pci/if_rl.c Sun Jun 5 06:13:19 2005 +++ ifnet/sys/pci/if_rl.c Tue Jun 7 16:41:13 2005 @@ -98,6 +98,7 @@ #include #include #include +#include #include @@ -583,7 +584,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ if (error) { if_printf(ifp, "couldn't set up irq\n"); ether_ifdetach(ifp); + if_free(ifp); } fail: @@ -1002,13 +1008,15 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ struct ifnet *ifp; sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->rl_ifp; RL_LOCK(sc); diff -ruN --exclude=compile freebsd/sys/pci/if_rlreg.h ifnet/sys/pci/if_rlreg.h --- freebsd/sys/pci/if_rlreg.h Tue Jan 25 21:41:40 2005 +++ ifnet/sys/pci/if_rlreg.h Fri Jun 3 15:59:04 2005 @@ -678,7 +678,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/pci/if_sf.c ifnet/sys/pci/if_sf.c --- freebsd/sys/pci/if_sf.c Sun Jun 5 06:13:20 2005 +++ ifnet/sys/pci/if_sf.c Tue Jun 7 16:41:14 2005 @@ -93,6 +93,7 @@ #include #include #include +#include #include @@ -415,7 +416,7 @@ 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 @@ 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 @@ * 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 @@ 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 @@ /* * 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 @@ if (error) { printf("sf%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -766,12 +774,13 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ (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_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->sf_ifp; untimeout(sf_stats_update, sc, sc->sf_stat_ch); @@ -1494,7 +1503,7 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_sfreg.h ifnet/sys/pci/if_sfreg.h --- freebsd/sys/pci/if_sfreg.h Thu Jan 6 22:33:22 2005 +++ ifnet/sys/pci/if_sfreg.h Fri Jun 3 15:59:04 2005 @@ -1031,7 +1031,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/pci/if_sis.c ifnet/sys/pci/if_sis.c --- freebsd/sys/pci/if_sis.c Sun Jun 5 06:13:21 2005 +++ ifnet/sys/pci/if_sis.c Tue Jun 7 16:41:14 2005 @@ -740,7 +740,7 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ if (error) { printf("sis%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -1265,13 +1271,14 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_sisreg.h ifnet/sys/pci/if_sisreg.h --- freebsd/sys/pci/if_sisreg.h Tue Jan 25 21:41:41 2005 +++ ifnet/sys/pci/if_sisreg.h Fri Jun 3 15:59:06 2005 @@ -430,7 +430,7 @@ #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 -ruN --exclude=compile freebsd/sys/pci/if_sk.c ifnet/sys/pci/if_sk.c --- freebsd/sys/pci/if_sk.c Sun Jun 5 06:13:22 2005 +++ ifnet/sys/pci/if_sk.c Tue Jun 7 16:41:17 2005 @@ -101,6 +101,7 @@ #include #include #include +#include #include @@ -790,7 +791,7 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ sc->sk_unit, sc_if->sk_phytype); error = ENODEV; SK_UNLOCK(sc); + if_free(ifp); goto fail; } @@ -1525,7 +1533,7 @@ * 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_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 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ /* 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 @@ 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 @@ 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_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_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 -ruN --exclude=compile freebsd/sys/pci/if_skreg.h ifnet/sys/pci/if_skreg.h --- freebsd/sys/pci/if_skreg.h Thu Mar 17 11:00:22 2005 +++ ifnet/sys/pci/if_skreg.h Fri Jun 3 15:59:07 2005 @@ -1461,7 +1461,7 @@ /* 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 -ruN --exclude=compile freebsd/sys/pci/if_ste.c ifnet/sys/pci/if_ste.c --- freebsd/sys/pci/if_ste.c Sun Jun 5 06:13:23 2005 +++ ifnet/sys/pci/if_ste.c Tue Jun 7 16:41:17 2005 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -564,7 +565,7 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* * 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 @@ 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 @@ /* * 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 @@ if (error) { printf("ste%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -1130,12 +1138,13 @@ 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 @@ 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 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_stereg.h ifnet/sys/pci/if_stereg.h --- freebsd/sys/pci/if_stereg.h Thu Jan 6 22:33:27 2005 +++ ifnet/sys/pci/if_stereg.h Fri Jun 3 19:41:14 2005 @@ -504,7 +504,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/pci/if_ti.c ifnet/sys/pci/if_ti.c --- freebsd/sys/pci/if_ti.c Sun Jun 5 06:13:24 2005 +++ ifnet/sys/pci/if_ti.c Tue Jun 7 16:41:19 2005 @@ -1111,7 +1111,7 @@ 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_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_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 @@ 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 @@ 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 @@ /* 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 @@ * 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ /* * 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 @@ if (error) { printf("ti%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -2314,12 +2321,13 @@ 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_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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->ti_ifp; /* Disable host interrupts. */ CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1); diff -ruN --exclude=compile freebsd/sys/pci/if_tireg.h ifnet/sys/pci/if_tireg.h --- freebsd/sys/pci/if_tireg.h Thu Mar 24 21:06:33 2005 +++ ifnet/sys/pci/if_tireg.h Fri Jun 3 19:41:16 2005 @@ -987,7 +987,7 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_tl.c ifnet/sys/pci/if_tl.c --- freebsd/sys/pci/if_tl.c Sun Jun 5 06:13:25 2005 +++ ifnet/sys/pci/if_tl.c Tue Jun 7 16:41:20 2005 @@ -191,6 +191,7 @@ #include #include #include +#include #include @@ -523,7 +524,7 @@ { 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 @@ 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 @@ 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 @@ /* * 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 @@ 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 @@ /* * 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 @@ if (error) { device_printf(dev, "couldn't set up irq\n"); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -1335,12 +1342,13 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ sc = xsc; TL_LOCK(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->tl_ifp; p = (u_int32_t *)&tl_stats; @@ -1854,7 +1862,7 @@ 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 @@ 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_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_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 -ruN --exclude=compile freebsd/sys/pci/if_tlreg.h ifnet/sys/pci/if_tlreg.h --- freebsd/sys/pci/if_tlreg.h Thu Jan 6 22:33:29 2005 +++ ifnet/sys/pci/if_tlreg.h Fri Jun 3 19:41:17 2005 @@ -109,7 +109,7 @@ }; 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 -ruN --exclude=compile freebsd/sys/pci/if_vr.c ifnet/sys/pci/if_vr.c --- freebsd/sys/pci/if_vr.c Sun Jun 5 06:13:26 2005 +++ ifnet/sys/pci/if_vr.c Tue Jun 7 16:41:21 2005 @@ -74,6 +74,7 @@ #include #include #include +#include #include @@ -508,7 +509,7 @@ 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 @@ 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 @@ 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 @@ if (error) { printf("vr%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -783,7 +789,7 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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_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 -ruN --exclude=compile freebsd/sys/pci/if_vrreg.h ifnet/sys/pci/if_vrreg.h --- freebsd/sys/pci/if_vrreg.h Thu Jan 6 22:33:30 2005 +++ ifnet/sys/pci/if_vrreg.h Fri Jun 3 19:41:18 2005 @@ -452,7 +452,7 @@ #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 -ruN --exclude=compile freebsd/sys/pci/if_wb.c ifnet/sys/pci/if_wb.c --- freebsd/sys/pci/if_wb.c Sun Jun 5 06:13:27 2005 +++ ifnet/sys/pci/if_wb.c Tue Jun 7 16:41:22 2005 @@ -100,6 +100,7 @@ #include #include #include +#include #include @@ -596,7 +597,7 @@ 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 @@ 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_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 @@ 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 @@ if (error) { printf("wb%d: couldn't set up irq\n", unit); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -908,7 +914,7 @@ 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 @@ 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_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 @@ 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 @@ { struct ifnet *ifp; - ifp = &sc->arpcom.ac_if; + ifp = sc->wb_ifp; ifp->if_timer = 0; @@ -1240,7 +1247,7 @@ 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 @@ 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 @@ /* 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 @@ 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 -ruN --exclude=compile freebsd/sys/pci/if_wbreg.h ifnet/sys/pci/if_wbreg.h --- freebsd/sys/pci/if_wbreg.h Thu Jan 6 22:33:31 2005 +++ ifnet/sys/pci/if_wbreg.h Fri Jun 3 19:41:19 2005 @@ -362,7 +362,7 @@ #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 -ruN --exclude=compile freebsd/sys/pci/if_xl.c ifnet/sys/pci/if_xl.c --- freebsd/sys/pci/if_xl.c Sun Jun 5 06:13:28 2005 +++ ifnet/sys/pci/if_xl.c Tue Jun 7 16:41:23 2005 @@ -116,6 +116,7 @@ #include #include #include +#include #include @@ -386,7 +387,7 @@ } 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ 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 @@ if (error) { device_printf(dev, "couldn't set up irq\n"); ether_ifdetach(ifp); + if_free(ifp); goto fail; } @@ -1669,7 +1675,7 @@ *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 @@ 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_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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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_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 @@ 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 @@ struct ifnet *ifp; sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->xl_ifp; XL_LOCK(sc); diff -ruN --exclude=compile freebsd/sys/pci/if_xlreg.h ifnet/sys/pci/if_xlreg.h --- freebsd/sys/pci/if_xlreg.h Tue May 24 17:14:05 2005 +++ ifnet/sys/pci/if_xlreg.h Fri Jun 3 19:48:54 2005 @@ -580,7 +580,7 @@ #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 -ruN --exclude=compile freebsd/usr.sbin/slstat/slstat.c ifnet/usr.sbin/slstat/slstat.c --- freebsd/usr.sbin/slstat/slstat.c Tue Nov 4 14:08:41 2003 +++ ifnet/usr.sbin/slstat/slstat.c Sat Jun 4 18:07:28 2005 @@ -192,31 +192,31 @@ putchar('\n'); } printf("%8lu %6ld %6u %6u %6u", - V(sc_if.if_ibytes), - V(sc_if.if_ipackets), + V(sc_ifp->if_ibytes), + V(sc_ifp->if_ipackets), V(sc_comp.sls_compressedin), V(sc_comp.sls_uncompressedin), V(sc_comp.sls_errorin)); if (vflag) printf(" %6u %6lu %6lu", V(sc_comp.sls_tossed), - V(sc_if.if_ipackets) - + V(sc_ifp->if_ipackets) - V(sc_comp.sls_compressedin) - V(sc_comp.sls_uncompressedin) - V(sc_comp.sls_errorin), - V(sc_if.if_ierrors)); + V(sc_ifp->if_ierrors)); printf(" | %8lu %6ld %6u %6u %6lu", - V(sc_if.if_obytes) / (rflag ? interval : 1), - V(sc_if.if_opackets), + V(sc_ifp->if_obytes) / (rflag ? interval : 1), + V(sc_ifp->if_opackets), V(sc_comp.sls_compressed), V(sc_comp.sls_packets) - V(sc_comp.sls_compressed), - V(sc_if.if_opackets) - V(sc_comp.sls_packets)); + V(sc_ifp->if_opackets) - V(sc_comp.sls_packets)); if (vflag) printf(" %6u %6u %6lu %6lu", V(sc_comp.sls_searches), V(sc_comp.sls_misses), - V(sc_if.if_oerrors), - V(sc_if.if_collisions)); + V(sc_ifp->if_oerrors), + V(sc_ifp->if_collisions)); putchar('\n'); fflush(stdout); line++;