From 567ba9b00a248431e7c1147c4e079fd7a11b9ecf Mon Sep 17 00:00:00 2001 From: brooks Date: Fri, 10 Jun 2005 16:49:24 +0000 Subject: Stop embedding struct ifnet at the top of driver softcs. Instead the struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam --- sys/dev/patm/if_patm.c | 10 +++--- sys/dev/patm/if_patm_attach.c | 79 +++++++++++++++++++++++-------------------- sys/dev/patm/if_patm_intr.c | 2 +- sys/dev/patm/if_patm_ioctl.c | 10 +++--- sys/dev/patm/if_patm_rx.c | 22 ++++++------ sys/dev/patm/if_patm_tx.c | 42 +++++++++++------------ sys/dev/patm/if_patmvar.h | 12 +++---- 7 files changed, 92 insertions(+), 85 deletions(-) (limited to 'sys/dev/patm') diff --git a/sys/dev/patm/if_patm.c b/sys/dev/patm/if_patm.c index ac01b95..0c8cf46 100644 --- a/sys/dev/patm/if_patm.c +++ b/sys/dev/patm/if_patm.c @@ -204,7 +204,7 @@ patm_initialize(struct patm_softc *sc) patm_debug(sc, ATTACH, "go..."); sc->utopia.flags &= ~UTP_FL_POLL_CARRIER; - sc->ifatm.ifnet.if_flags |= IFF_RUNNING; + sc->ifp->if_flags |= IFF_RUNNING; /* enable interrupts, Tx and Rx paths */ cfg |= IDT_CFG_RXPTH | IDT_CFG_RXIIMM | IDT_CFG_RAWIE | IDT_CFG_RQFIE | @@ -216,7 +216,7 @@ patm_initialize(struct patm_softc *sc) if (sc->vccs[i] != NULL) patm_load_vc(sc, sc->vccs[i], 1); - ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm, + ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), sc->utopia.carrier == UTP_CARR_OK); } @@ -245,7 +245,7 @@ patm_stop(struct patm_softc *sc) struct patm_txmap *map; struct patm_scd *scd; - sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; + sc->ifp->if_flags &= ~IFF_RUNNING; sc->utopia.flags |= UTP_FL_POLL_CARRIER; patm_reset(sc); @@ -335,7 +335,7 @@ patm_stop(struct patm_softc *sc) /* reset raw cell queue */ sc->rawh = NULL; - ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm, + ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), sc->utopia.carrier == UTP_CARR_OK); } @@ -397,7 +397,7 @@ patm_tst_init(struct patm_softc *sc) sc->tst_free = sc->mmap->tst_size - 1; sc->tst_reserve = sc->tst_free * PATM_TST_RESERVE / 100; - sc->bwrem = sc->ifatm.mib.pcr; + sc->bwrem = IFP2IFATM(sc->ifp)->mib.pcr; } /* diff --git a/sys/dev/patm/if_patm_attach.c b/sys/dev/patm/if_patm_attach.c index 283d18b..1b4e0c2 100644 --- a/sys/dev/patm/if_patm_attach.c +++ b/sys/dev/patm/if_patm_attach.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #ifdef ENABLE_BPF @@ -177,18 +178,22 @@ patm_attach(device_t dev) #ifdef IATM_DEBUG sc->debug = IATM_DEBUG; #endif - sc->ifatm.mib.device = ATM_DEVICE_IDTABR25; - sc->ifatm.mib.serial = 0; - sc->ifatm.mib.hw_version = 0; - sc->ifatm.mib.sw_version = 0; - sc->ifatm.mib.vpi_bits = PATM_VPI_BITS; - sc->ifatm.mib.vci_bits = 0; /* set below */; - sc->ifatm.mib.max_vpcs = 0; - sc->ifatm.mib.max_vccs = 0; /* set below */ - sc->ifatm.mib.media = IFM_ATM_UNKNOWN; - sc->ifatm.phy = &sc->utopia; - - ifp = &sc->ifatm.ifnet; + ifp = sc->ifp = if_alloc(IFT_ATM); + if (ifp == NULL) { + return (ENOSPC); + } + + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_IDTABR25; + IFP2IFATM(sc->ifp)->mib.serial = 0; + IFP2IFATM(sc->ifp)->mib.hw_version = 0; + IFP2IFATM(sc->ifp)->mib.sw_version = 0; + IFP2IFATM(sc->ifp)->mib.vpi_bits = PATM_VPI_BITS; + IFP2IFATM(sc->ifp)->mib.vci_bits = 0; /* set below */; + IFP2IFATM(sc->ifp)->mib.max_vpcs = 0; + IFP2IFATM(sc->ifp)->mib.max_vccs = 0; /* set below */ + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN; + IFP2IFATM(sc->ifp)->phy = &sc->utopia; + ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_SIMPLEX; @@ -297,8 +302,8 @@ patm_attach(device_t dev) * Detect and attach the phy. */ patm_debug(sc, ATTACH, "attaching utopia"); - sc->ifatm.phy = &sc->utopia; - utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx, + IFP2IFATM(sc->ifp)->phy = &sc->utopia; + utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx, &sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), &patm_utopia_methods); @@ -318,41 +323,41 @@ patm_attach(device_t dev) if (strncmp(sc->eeprom + PATM_PROATM_NAME_OFFSET, PATM_PROATM_NAME, strlen(PATM_PROATM_NAME)) == 0) { if (sc->utopia.chip->type == UTP_TYPE_IDT77105) { - sc->ifatm.mib.device = ATM_DEVICE_PROATM25; - sc->ifatm.mib.pcr = ATM_RATE_25_6M; - sc->ifatm.mib.media = IFM_ATM_UTP_25; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_PROATM25; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_25_6M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_25; sc->flags |= PATM_25M; patm_printf(sc, "ProATM 25 interface; "); } else { /* cannot really know which media */ - sc->ifatm.mib.device = ATM_DEVICE_PROATM155; - sc->ifatm.mib.pcr = ATM_RATE_155M; - sc->ifatm.mib.media = IFM_ATM_MM_155; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_PROATM155; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155; patm_printf(sc, "ProATM 155 interface; "); } - bcopy(sc->eeprom + PATM_PROATM_MAC_OFFSET, sc->ifatm.mib.esi, - sizeof(sc->ifatm.mib.esi)); + bcopy(sc->eeprom + PATM_PROATM_MAC_OFFSET, IFP2IFATM(sc->ifp)->mib.esi, + sizeof(IFP2IFATM(sc->ifp)->mib.esi)); } else { if (sc->utopia.chip->type == UTP_TYPE_IDT77105) { - sc->ifatm.mib.device = ATM_DEVICE_IDTABR25; - sc->ifatm.mib.pcr = ATM_RATE_25_6M; - sc->ifatm.mib.media = IFM_ATM_UTP_25; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_IDTABR25; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_25_6M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_25; sc->flags |= PATM_25M; patm_printf(sc, "IDT77252 25MBit interface; "); } else { /* cannot really know which media */ - sc->ifatm.mib.device = ATM_DEVICE_IDTABR155; - sc->ifatm.mib.pcr = ATM_RATE_155M; - sc->ifatm.mib.media = IFM_ATM_MM_155; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_IDTABR155; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155; patm_printf(sc, "IDT77252 155MBit interface; "); } - bcopy(sc->eeprom + PATM_IDT_MAC_OFFSET, sc->ifatm.mib.esi, - sizeof(sc->ifatm.mib.esi)); + bcopy(sc->eeprom + PATM_IDT_MAC_OFFSET, IFP2IFATM(sc->ifp)->mib.esi, + sizeof(IFP2IFATM(sc->ifp)->mib.esi)); } printf("idt77252 Rev. %c; %s PHY\n", 'A' + sc->revision, sc->utopia.chip->name); @@ -375,8 +380,8 @@ patm_attach(device_t dev) else sc->mmap = &idt_mmap[3]; - sc->ifatm.mib.vci_bits = sc->mmap->vcbits - sc->ifatm.mib.vpi_bits; - sc->ifatm.mib.max_vccs = sc->mmap->max_conn; + IFP2IFATM(sc->ifp)->mib.vci_bits = sc->mmap->vcbits - IFP2IFATM(sc->ifp)->mib.vpi_bits; + IFP2IFATM(sc->ifp)->mib.max_vccs = sc->mmap->max_conn; patm_sram_write(sc, 0, 0); patm_printf(sc, "%uK x 32 SRAM; %u connections\n", sc->mmap->sram, sc->mmap->max_conn); @@ -440,7 +445,8 @@ patm_attach(device_t dev) sc, &sc->ih); if (error != 0) { patm_printf(sc, "could not setup interrupt\n"); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); goto fail; } @@ -470,7 +476,8 @@ patm_detach(device_t dev) } mtx_unlock(&sc->mtx); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); patm_destroy(sc); @@ -696,7 +703,7 @@ patm_read_eeprom(struct patm_softc *sc) static int patm_phy_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n) { - struct patm_softc *sc = ifatm->ifnet.if_softc; + struct patm_softc *sc = ifatm->ifp->if_softc; u_int cnt = *n; if (reg >= 0x100) @@ -722,7 +729,7 @@ patm_phy_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n) static int patm_phy_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val) { - struct patm_softc *sc = ifatm->ifnet.if_softc; + struct patm_softc *sc = ifatm->ifp->if_softc; u_int old, new; if (reg >= 0x100) diff --git a/sys/dev/patm/if_patm_intr.c b/sys/dev/patm/if_patm_intr.c index f177253..b19dfc0 100644 --- a/sys/dev/patm/if_patm_intr.c +++ b/sys/dev/patm/if_patm_intr.c @@ -119,7 +119,7 @@ patm_intr(void *p) stat = patm_nor_read(sc, IDT_NOR_STAT); patm_nor_write(sc, IDT_NOR_STAT, stat & (ints | fbqa)); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { /* if we are stopped ack all interrupts and handle PHYI */ if (stat & IDT_STAT_PHYI) { patm_debug(sc, INTR, "PHYI (stopped)"); diff --git a/sys/dev/patm/if_patm_ioctl.c b/sys/dev/patm/if_patm_ioctl.c index 6dc669d..651bed6 100644 --- a/sys/dev/patm/if_patm_ioctl.c +++ b/sys/dev/patm/if_patm_ioctl.c @@ -107,7 +107,7 @@ patm_open_vcc(struct patm_softc *sc, struct atmio_openvcc *arg) return (ENOMEM); mtx_lock(&sc->mtx); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { /* stopped while we have analyzed the arguments */ error = EIO; goto done; @@ -200,7 +200,7 @@ patm_load_vc(struct patm_softc *sc, struct patm_vcc *vcc, int reload) /* inform management about non-NG and NG-PVCs */ if (!(vcc->vcc.flags & ATMIO_FLAG_NG) || (vcc->vcc.flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->vcc.vpi, + ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->vcc.vpi, vcc->vcc.vci, 1); } @@ -224,7 +224,7 @@ patm_close_vcc(struct patm_softc *sc, struct atmio_closevcc *arg) cid = PATM_CID(sc, arg->vpi, arg->vci); mtx_lock(&sc->mtx); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { /* stopped while we have analyzed the arguments */ error = EIO; goto done; @@ -246,7 +246,7 @@ patm_close_vcc(struct patm_softc *sc, struct atmio_closevcc *arg) while (vcc->vflags & (PATM_VCC_TX_CLOSING | PATM_VCC_RX_CLOSING)) { cv_wait(&sc->vcc_cv, &sc->mtx); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { /* ups, has been stopped */ error = EIO; goto done; @@ -276,7 +276,7 @@ patm_vcc_closed(struct patm_softc *sc, struct patm_vcc *vcc) /* inform management about non-NG and NG-PVCs */ if (!(vcc->vcc.flags & ATMIO_FLAG_NG) || (vcc->vcc.flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->vcc.vpi, + ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->vcc.vpi, vcc->vcc.vci, 0); sc->vccs_open--; diff --git a/sys/dev/patm/if_patm_rx.c b/sys/dev/patm/if_patm_rx.c index 01c3243..1a012a9 100644 --- a/sys/dev/patm/if_patm_rx.c +++ b/sys/dev/patm/if_patm_rx.c @@ -244,7 +244,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) m->m_len = cells * 48; m->m_pkthdr.len = m->m_len; - m->m_pkthdr.rcvif = &sc->ifatm.ifnet; + m->m_pkthdr.rcvif = sc->ifp; } else if (vcc->vcc.aal == ATMIO_AAL_34) { /* XXX AAL3/4 */ @@ -253,7 +253,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) } else if (vcc->vcc.aal == ATMIO_AAL_5) { if (stat & IDT_RSQE_CRC) { - sc->ifatm.ifnet.if_ierrors++; + sc->ifp->if_ierrors++; if (vcc->chain != NULL) { m_freem(vcc->chain); vcc->chain = vcc->last = NULL; @@ -267,7 +267,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) return; m->m_len = cells * 48; m->m_pkthdr.len = m->m_len; - m->m_pkthdr.rcvif = &sc->ifatm.ifnet; + m->m_pkthdr.rcvif = sc->ifp; vcc->chain = vcc->last = m; } else { if ((m = patm_rcv_mbuf(sc, buf, h, 0)) == NULL) @@ -311,9 +311,9 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) } #endif - sc->ifatm.ifnet.if_ipackets++; + sc->ifp->if_ipackets++; /* this is in if_atmsubr.c */ - /* sc->ifatm.ifnet.if_ibytes += m->m_pkthdr.len; */ + /* sc->ifp->if_ibytes += m->m_pkthdr.len; */ vcc->ibytes += m->m_pkthdr.len; vcc->ipackets++; @@ -326,10 +326,10 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) if (!(vcc->vcc.flags & ATMIO_FLAG_NG) && (vcc->vcc.aal == ATMIO_AAL_5) && (vcc->vcc.flags & ATM_PH_LLCSNAP)) - BPF_MTAP(&sc->ifatm.ifnet, m); + BPF_MTAP(sc->ifp, m); #endif - atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand); + atm_input(sc->ifp, &aph, m, vcc->rxhand); } /* @@ -463,7 +463,7 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell) sc->stats.raw_no_buf++; return; } - m->m_pkthdr.rcvif = &sc->ifatm.ifnet; + m->m_pkthdr.rcvif = sc->ifp; switch (vcc->vflags & PATM_RAW_FORMAT) { @@ -510,9 +510,9 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell) break; } - sc->ifatm.ifnet.if_ipackets++; + sc->ifp->if_ipackets++; /* this is in if_atmsubr.c */ - /* sc->ifatm.ifnet.if_ibytes += m->m_pkthdr.len; */ + /* sc->ifp->if_ibytes += m->m_pkthdr.len; */ vcc->ibytes += m->m_pkthdr.len; vcc->ipackets++; @@ -521,5 +521,5 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell) ATM_PH_VPI(&aph) = vcc->vcc.vpi; ATM_PH_SETVCI(&aph, vcc->vcc.vci); - atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand); + atm_input(sc->ifp, &aph, m, vcc->rxhand); } diff --git a/sys/dev/patm/if_patm_tx.c b/sys/dev/patm/if_patm_tx.c index 0c6a99e..975f56a 100644 --- a/sys/dev/patm/if_patm_tx.c +++ b/sys/dev/patm/if_patm_tx.c @@ -119,13 +119,13 @@ cbr2slots(struct patm_softc *sc, struct patm_vcc *vcc) /* compute the number of slots we need, make sure to get at least * the specified PCR */ return ((u_int)(((uint64_t)(sc->mmap->tst_size - 1) * - vcc->vcc.tparam.pcr + sc->ifatm.mib.pcr - 1) / sc->ifatm.mib.pcr)); + vcc->vcc.tparam.pcr + IFP2IFATM(sc->ifp)->mib.pcr - 1) / IFP2IFATM(sc->ifp)->mib.pcr)); } static __inline u_int slots2cr(struct patm_softc *sc, u_int slots) { - return ((slots * sc->ifatm.mib.pcr + sc->mmap->tst_size - 2) / + return ((slots * IFP2IFATM(sc->ifp)->mib.pcr + sc->mmap->tst_size - 2) / (sc->mmap->tst_size - 1)); } @@ -149,7 +149,7 @@ patm_tx_vcc_can_open(struct patm_softc *sc, struct patm_vcc *vcc) case ATMIO_TRAFFIC_VBR: if (vcc->vcc.tparam.scr > sc->bwrem) return (EINVAL); - if (vcc->vcc.tparam.pcr > sc->ifatm.mib.pcr) + if (vcc->vcc.tparam.pcr > IFP2IFATM(sc->ifp)->mib.pcr) return (EINVAL); if (vcc->vcc.tparam.scr > vcc->vcc.tparam.pcr || vcc->vcc.tparam.mbs == 0) @@ -161,7 +161,7 @@ patm_tx_vcc_can_open(struct patm_softc *sc, struct patm_vcc *vcc) vcc->vcc.tparam.nrm == 0) /* needed to compute CRM */ return (EINVAL); - if (vcc->vcc.tparam.pcr > sc->ifatm.mib.pcr || + if (vcc->vcc.tparam.pcr > IFP2IFATM(sc->ifp)->mib.pcr || vcc->vcc.tparam.icr > vcc->vcc.tparam.pcr || vcc->vcc.tparam.mcr > vcc->vcc.tparam.icr) return (EINVAL); @@ -303,7 +303,7 @@ patm_start(struct ifnet *ifp) /* split of pseudo header */ if (m->m_len < sizeof(*aph) && (m = m_pullup(m, sizeof(*aph))) == NULL) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } @@ -315,21 +315,21 @@ patm_start(struct ifnet *ifp) /* reject empty packets */ if (m->m_pkthdr.len == 0) { m_freem(m); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } /* check whether this is a legal vcc */ if (!LEGAL_VPI(sc, vpi) || !LEGAL_VCI(sc, vci) || vci == 0) { m_freem(m); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } cid = PATM_CID(sc, vpi, vci); vcc = sc->vccs[cid]; if (vcc == NULL) { m_freem(m); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } @@ -339,7 +339,7 @@ patm_start(struct ifnet *ifp) /* XXX AAL3/4 format? */ if (m->m_pkthdr.len % 48 != 0 && (m = patm_tx_pad(sc, m)) == NULL) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } } else if (vcc->vcc.aal == ATMIO_AAL_RAW) { @@ -348,7 +348,7 @@ patm_start(struct ifnet *ifp) default: case PATM_RAW_CELL: if (m->m_pkthdr.len != 53) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; m_freem(m); continue; } @@ -356,7 +356,7 @@ patm_start(struct ifnet *ifp) case PATM_RAW_NOHEC: if (m->m_pkthdr.len != 52) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; m_freem(m); continue; } @@ -364,7 +364,7 @@ patm_start(struct ifnet *ifp) case PATM_RAW_CS: if (m->m_pkthdr.len != 64) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; m_freem(m); continue; } @@ -377,7 +377,7 @@ patm_start(struct ifnet *ifp) /* try to put it on the channels queue */ if (_IF_QFULL(&vcc->scd->q)) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; sc->stats.tx_qfull++; m_freem(m); continue; @@ -415,7 +415,7 @@ patm_tx_pad(struct patm_softc *sc, struct mbuf *m0) m0->m_pkthdr.len = plen; if (plen == 0) { m_freem(m0); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; return (NULL); } if (plen % 48 == 0) @@ -441,7 +441,7 @@ patm_tx_pad(struct patm_softc *sc, struct mbuf *m0) MGET(m, M_DONTWAIT, MT_DATA); if (m == 0) { m_freem(m0); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; return (NULL); } bzero(mtod(m, u_char *), pad); @@ -533,7 +533,7 @@ patm_launch(struct patm_softc *sc, struct patm_scd *scd) patm_load_txbuf, &a, BUS_DMA_NOWAIT); if (error == EFBIG) { if ((m = m_defrag(m, M_DONTWAIT)) == NULL) { - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } error = bus_dmamap_load_mbuf(sc->tx_tag, map->map, m, @@ -541,13 +541,13 @@ patm_launch(struct patm_softc *sc, struct patm_scd *scd) } if (error != 0) { sc->stats.tx_load_err++; - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; SLIST_INSERT_HEAD(&sc->tx_maps_free, map, link); m_freem(m); continue; } - sc->ifatm.ifnet.if_opackets++; + sc->ifp->if_opackets++; } } @@ -741,12 +741,12 @@ patm_tx(struct patm_softc *sc, u_int stamp, u_int status) acri = (patm_sram_read(sc, 8 * cid + 2) >> IDT_TCT_ACRI_SHIFT) & 0x3fff; - cps = sc->ifatm.mib.pcr * 32 / + cps = IFP2IFATM(sc->ifp)->mib.pcr * 32 / ((1 << (acri >> 10)) * (acri & 0x3ff)); if (cps != vcc->cps) { patm_debug(sc, VCC, "ACRI=%04x CPS=%u", acri, cps); - ATMEV_SEND_ACR_CHANGED(&sc->ifatm, vcc->vcc.vpi, + ATMEV_SEND_ACR_CHANGED(IFP2IFATM(sc->ifp), vcc->vcc.vpi, vcc->vcc.vci, cps); vcc->cps = cps; } @@ -1126,7 +1126,7 @@ patm_tst_alloc(struct patm_softc *sc, struct patm_vcc *vcc) sc->bwrem -= slots2cr(sc, slots); patm_debug(sc, TST, "tst_alloc: cbr=%u link=%u tst=%u slots=%u", - vcc->vcc.tparam.pcr, sc->ifatm.mib.pcr, sc->mmap->tst_size, slots); + vcc->vcc.tparam.pcr, IFP2IFATM(sc->ifp)->mib.pcr, sc->mmap->tst_size, slots); qmax = sc->mmap->tst_size - 1; pmax = qmax << 8; diff --git a/sys/dev/patm/if_patmvar.h b/sys/dev/patm/if_patmvar.h index 5cadbc3..e934784 100644 --- a/sys/dev/patm/if_patmvar.h +++ b/sys/dev/patm/if_patmvar.h @@ -149,7 +149,7 @@ struct lmbuf { }; #define PATM_CID(SC, VPI, VCI) \ - (((VPI) << (SC)->ifatm.mib.vci_bits) | (VCI)) + (((VPI) << IFP2IFATM((SC)->ifp)->mib.vci_bits) | (VCI)) /* * Internal driver statistics @@ -218,7 +218,7 @@ struct patm_vcc { * Per adapter data */ struct patm_softc { - struct ifatm ifatm; /* common ATM stuff */ + struct ifnet *ifp; /* common ATM stuff */ struct mtx mtx; /* lock */ struct ifmedia media; /* media */ device_t dev; /* device */ @@ -325,7 +325,7 @@ struct patm_softc { #define TST_PENDING 0x0002 /* need update */ #define TST_WAIT 0x0004 /* wait fo jump */ -#define patm_printf(SC, ...) if_printf(&(SC)->ifatm.ifnet, __VA_ARGS__); +#define patm_printf(SC, ...) if_printf((SC)->ifp, __VA_ARGS__); #ifdef PATM_DEBUG /* @@ -348,7 +348,7 @@ enum { #define patm_debug(SC, FLAG, ...) do { \ if((SC)->debug & DBG_##FLAG) { \ - if_printf(&(SC)->ifatm.ifnet, "%s: ", __func__); \ + if_printf((SC)->ifp, "%s: ", __func__); \ printf(__VA_ARGS__); \ printf("\n"); \ } \ @@ -510,9 +510,9 @@ patm_sram_write4(struct patm_softc *sc, u_int addr, uint32_t v0, uint32_t v1, } #define LEGAL_VPI(SC, VPI) \ - (((VPI) & ~((1 << (SC)->ifatm.mib.vpi_bits) - 1)) == 0) + (((VPI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vpi_bits) - 1)) == 0) #define LEGAL_VCI(SC, VCI) \ - (((VCI) & ~((1 << (SC)->ifatm.mib.vci_bits) - 1)) == 0) + (((VCI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vci_bits) - 1)) == 0) extern const uint32_t patm_rtables155[]; extern const uint32_t patm_rtables25[]; -- cgit v1.1