diff options
Diffstat (limited to 'sys/dev/hatm')
-rw-r--r-- | sys/dev/hatm/if_hatm.c | 154 | ||||
-rw-r--r-- | sys/dev/hatm/if_hatm_intr.c | 26 | ||||
-rw-r--r-- | sys/dev/hatm/if_hatm_ioctl.c | 12 | ||||
-rw-r--r-- | sys/dev/hatm/if_hatm_rx.c | 18 | ||||
-rw-r--r-- | sys/dev/hatm/if_hatm_tx.c | 24 | ||||
-rw-r--r-- | sys/dev/hatm/if_hatmvar.h | 2 |
6 files changed, 122 insertions, 114 deletions
diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c index e1f9128..8811b4e 100644 --- a/sys/dev/hatm/if_hatm.c +++ b/sys/dev/hatm/if_hatm.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_media.h> #include <net/if_atm.h> +#include <net/if_types.h> #include <net/route.h> #ifdef ENABLE_BPF #include <net/bpf.h> @@ -217,13 +218,13 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem) BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, NULL, NULL, &mem->tag); if (error) { - if_printf(&sc->ifatm.ifnet, "DMA tag create (%s)\n", what); + if_printf(sc->ifp, "DMA tag create (%s)\n", what); return (error); } error = bus_dmamem_alloc(mem->tag, &mem->base, 0, &mem->map); if (error) { - if_printf(&sc->ifatm.ifnet, "DMA mem alloc (%s): %d\n", + if_printf(sc->ifp, "DMA mem alloc (%s): %d\n", what, error); bus_dma_tag_destroy(mem->tag); mem->base = NULL; @@ -233,7 +234,7 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem) error = bus_dmamap_load(mem->tag, mem->map, mem->base, mem->size, dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT); if (error) { - if_printf(&sc->ifatm.ifnet, "DMA map load (%s): %d\n", + if_printf(sc->ifp, "DMA map load (%s): %d\n", what, error); bus_dmamem_free(mem->tag, mem->base, mem->map); bus_dma_tag_destroy(mem->tag); @@ -316,11 +317,11 @@ hatm_destroy_smbufs(struct hatm_softc *sc) h = (struct mbuf_chunk_hdr *) ((char *)pg + b * pg->hdr.chunksize + pg->hdr.hdroff); if (h->flags & MBUF_CARD) - if_printf(&sc->ifatm.ifnet, + if_printf(sc->ifp, "%s -- mbuf page=%u card buf %u\n", __func__, i, b); if (h->flags & MBUF_USED) - if_printf(&sc->ifatm.ifnet, + if_printf(sc->ifp, "%s -- mbuf page=%u used buf %u\n", __func__, i, b); } @@ -353,7 +354,7 @@ hatm_destroy_tpds(struct hatm_softc *sc) DBG(sc, ATTACH, ("releasing TPDs ...")); if (sc->tpd_nfree != sc->tpd_total) - if_printf(&sc->ifatm.ifnet, "%u tpds still in use from %u\n", + if_printf(sc->ifp, "%u tpds still in use from %u\n", sc->tpd_total - sc->tpd_nfree, sc->tpd_total); while ((t = SLIST_FIRST(&sc->tpd_free)) != NULL) { SLIST_REMOVE_HEAD(&sc->tpd_free, link); @@ -477,15 +478,15 @@ hatm_destroy(struct hatm_softc *sc) if (sc->tx_tag != NULL) if (bus_dma_tag_destroy(sc->tx_tag)) - if_printf(&sc->ifatm.ifnet, "mbuf DMA tag busy\n"); + if_printf(sc->ifp, "mbuf DMA tag busy\n"); if (sc->mbuf_tag != NULL) if (bus_dma_tag_destroy(sc->mbuf_tag)) - if_printf(&sc->ifatm.ifnet, "mbuf DMA tag busy\n"); + if_printf(sc->ifp, "mbuf DMA tag busy\n"); if (sc->parent_tag != NULL) if (bus_dma_tag_destroy(sc->parent_tag)) - if_printf(&sc->ifatm.ifnet, "parent DMA tag busy\n"); + if_printf(sc->ifp, "parent DMA tag busy\n"); if (sc->memres != NULL) bus_release_resource(sc->dev, SYS_RES_MEMORY, @@ -514,7 +515,7 @@ hatm_reset(struct hatm_softc *sc) while (((v = READ4(sc, HE_REGO_RESET_CNTL)) & HE_REGM_RESET_STATE) == 0) { BARRIER_R(sc); if (++count == 100) { - if_printf(&sc->ifatm.ifnet, "reset failed\n"); + if_printf(sc->ifp, "reset failed\n"); return (ENXIO); } DELAY(1000); @@ -669,12 +670,12 @@ hatm_init_read_eeprom(struct hatm_softc *sc) while (n > 0 && sc->rev[n-1] == ' ') n--; sc->rev[n] = '\0'; - sc->ifatm.mib.hw_version = sc->rev[0]; + IFP2IFATM(sc->ifp)->mib.hw_version = sc->rev[0]; - sc->ifatm.mib.serial = hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 0) << 0; - sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 1) << 8; - sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 2) << 16; - sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 3) << 24; + IFP2IFATM(sc->ifp)->mib.serial = hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 0) << 0; + IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 1) << 8; + IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 2) << 16; + IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 3) << 24; v = hatm_read_prom_byte(sc, HE_EEPROM_MEDIA + 0) << 0; v |= hatm_read_prom_byte(sc, HE_EEPROM_MEDIA + 1) << 8; @@ -683,41 +684,41 @@ hatm_init_read_eeprom(struct hatm_softc *sc) switch (v) { case HE_MEDIA_UTP155: - sc->ifatm.mib.media = IFM_ATM_UTP_155; - sc->ifatm.mib.pcr = ATM_RATE_155M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M; break; case HE_MEDIA_MMF155: - sc->ifatm.mib.media = IFM_ATM_MM_155; - sc->ifatm.mib.pcr = ATM_RATE_155M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M; break; case HE_MEDIA_MMF622: - sc->ifatm.mib.media = IFM_ATM_MM_622; - sc->ifatm.mib.device = ATM_DEVICE_HE622; - sc->ifatm.mib.pcr = ATM_RATE_622M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_622; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE622; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_622M; sc->he622 = 1; break; case HE_MEDIA_SMF155: - sc->ifatm.mib.media = IFM_ATM_SM_155; - sc->ifatm.mib.pcr = ATM_RATE_155M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_155; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M; break; case HE_MEDIA_SMF622: - sc->ifatm.mib.media = IFM_ATM_SM_622; - sc->ifatm.mib.device = ATM_DEVICE_HE622; - sc->ifatm.mib.pcr = ATM_RATE_622M; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_622; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE622; + IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_622M; sc->he622 = 1; break; } - sc->ifatm.mib.esi[0] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 0); - sc->ifatm.mib.esi[1] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 1); - sc->ifatm.mib.esi[2] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 2); - sc->ifatm.mib.esi[3] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 3); - sc->ifatm.mib.esi[4] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 4); - sc->ifatm.mib.esi[5] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 5); + IFP2IFATM(sc->ifp)->mib.esi[0] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 0); + IFP2IFATM(sc->ifp)->mib.esi[1] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 1); + IFP2IFATM(sc->ifp)->mib.esi[2] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 2); + IFP2IFATM(sc->ifp)->mib.esi[3] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 3); + IFP2IFATM(sc->ifp)->mib.esi[4] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 4); + IFP2IFATM(sc->ifp)->mib.esi[5] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 5); } /* @@ -781,18 +782,18 @@ hatm_init_cm(struct hatm_softc *sc) numbuffs = sc->r0_numbuffs + sc->r1_numbuffs + sc->tx_numbuffs; rsra = 0; - mlbm = ((rsra + sc->ifatm.mib.max_vccs * 8) + 0x7ff) & ~0x7ff; + mlbm = ((rsra + IFP2IFATM(sc->ifp)->mib.max_vccs * 8) + 0x7ff) & ~0x7ff; rabr = ((mlbm + numbuffs * 2) + 0x7ff) & ~0x7ff; - sc->rsrb = ((rabr + 2048) + (2 * sc->ifatm.mib.max_vccs - 1)) & - ~(2 * sc->ifatm.mib.max_vccs - 1); + sc->rsrb = ((rabr + 2048) + (2 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1)) & + ~(2 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1); tsra = 0; - sc->tsrb = tsra + sc->ifatm.mib.max_vccs * 8; - sc->tsrc = sc->tsrb + sc->ifatm.mib.max_vccs * 4; - sc->tsrd = sc->tsrc + sc->ifatm.mib.max_vccs * 2; - tabr = sc->tsrd + sc->ifatm.mib.max_vccs * 1; - mtpd = ((tabr + 1024) + (16 * sc->ifatm.mib.max_vccs - 1)) & - ~(16 * sc->ifatm.mib.max_vccs - 1); + sc->tsrb = tsra + IFP2IFATM(sc->ifp)->mib.max_vccs * 8; + sc->tsrc = sc->tsrb + IFP2IFATM(sc->ifp)->mib.max_vccs * 4; + sc->tsrd = sc->tsrc + IFP2IFATM(sc->ifp)->mib.max_vccs * 2; + tabr = sc->tsrd + IFP2IFATM(sc->ifp)->mib.max_vccs * 1; + mtpd = ((tabr + 1024) + (16 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1)) & + ~(16 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1); DBG(sc, ATTACH, ("rsra=%x mlbm=%x rabr=%x rsrb=%x", rsra, mlbm, rabr, sc->rsrb)); @@ -1322,7 +1323,7 @@ kenv_getuint(struct hatm_softc *sc, const char *var, return (EINVAL); } if (bootverbose) - if_printf(&sc->ifatm.ifnet, "%s=%u\n", full, u); + if_printf(sc->ifp, "%s=%u\n", full, u); *ptr = u; return (0); } @@ -1629,7 +1630,8 @@ hatm_detach(device_t dev) } mtx_unlock(&sc->mtx); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); hatm_destroy(sc); @@ -1650,18 +1652,25 @@ hatm_attach(device_t dev) sc = device_get_softc(dev); + ifp = sc->ifp = if_alloc(IFT_ATM); + if (ifp == NULL) { + device_printf(dev, "could not if_alloc()\n"); + error = ENOSPC; + goto failed; + } + sc->dev = dev; - sc->ifatm.mib.device = ATM_DEVICE_HE155; - sc->ifatm.mib.serial = 0; - sc->ifatm.mib.hw_version = 0; - sc->ifatm.mib.sw_version = 0; - sc->ifatm.mib.vpi_bits = HE_CONFIG_VPI_BITS; - sc->ifatm.mib.vci_bits = HE_CONFIG_VCI_BITS; - sc->ifatm.mib.max_vpcs = 0; - sc->ifatm.mib.max_vccs = HE_MAX_VCCS; - sc->ifatm.mib.media = IFM_ATM_UNKNOWN; + IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE155; + IFP2IFATM(sc->ifp)->mib.serial = 0; + IFP2IFATM(sc->ifp)->mib.hw_version = 0; + IFP2IFATM(sc->ifp)->mib.sw_version = 0; + IFP2IFATM(sc->ifp)->mib.vpi_bits = HE_CONFIG_VPI_BITS; + IFP2IFATM(sc->ifp)->mib.vci_bits = HE_CONFIG_VCI_BITS; + IFP2IFATM(sc->ifp)->mib.max_vpcs = 0; + IFP2IFATM(sc->ifp)->mib.max_vccs = HE_MAX_VCCS; + IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN; sc->he622 = 0; - sc->ifatm.phy = &sc->utopia; + IFP2IFATM(sc->ifp)->phy = &sc->utopia; SLIST_INIT(&sc->tpd_free); @@ -1761,7 +1770,6 @@ hatm_attach(device_t dev) goto failed; } - ifp = &sc->ifatm.ifnet; ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -1922,7 +1930,7 @@ hatm_attach(device_t dev) ifp->if_watchdog = NULL; ifp->if_init = hatm_init; - utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx, + utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx, &sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), &hatm_utopia_methods); utopia_init_media(&sc->utopia); @@ -1966,17 +1974,17 @@ hatm_initialize(struct hatm_softc *sc) u_int cid; static const u_int layout[2][7] = HE_CONFIG_MEM_LAYOUT; - if (sc->ifatm.ifnet.if_flags & IFF_RUNNING) + if (sc->ifp->if_flags & IFF_RUNNING) return; hatm_init_bus_width(sc); hatm_init_endianess(sc); - if_printf(&sc->ifatm.ifnet, "%s, Rev. %s, S/N %u, " + if_printf(sc->ifp, "%s, Rev. %s, S/N %u, " "MAC=%02x:%02x:%02x:%02x:%02x:%02x (%ubit PCI)\n", - sc->prod_id, sc->rev, sc->ifatm.mib.serial, - sc->ifatm.mib.esi[0], sc->ifatm.mib.esi[1], sc->ifatm.mib.esi[2], - sc->ifatm.mib.esi[3], sc->ifatm.mib.esi[4], sc->ifatm.mib.esi[5], + sc->prod_id, sc->rev, IFP2IFATM(sc->ifp)->mib.serial, + IFP2IFATM(sc->ifp)->mib.esi[0], IFP2IFATM(sc->ifp)->mib.esi[1], IFP2IFATM(sc->ifp)->mib.esi[2], + IFP2IFATM(sc->ifp)->mib.esi[3], IFP2IFATM(sc->ifp)->mib.esi[4], IFP2IFATM(sc->ifp)->mib.esi[5], sc->pci64 ? 64 : 32); /* @@ -2119,22 +2127,22 @@ hatm_initialize(struct hatm_softc *sc) if (sc->he622) { WRITE4(sc, HE_REGO_RCCONFIG, (8 << HE_REGS_RCCONFIG_UTDELAY) | - (sc->ifatm.mib.vpi_bits << HE_REGS_RCCONFIG_VP) | - (sc->ifatm.mib.vci_bits << HE_REGS_RCCONFIG_VC)); + (IFP2IFATM(sc->ifp)->mib.vpi_bits << HE_REGS_RCCONFIG_VP) | + (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_RCCONFIG_VC)); WRITE4(sc, HE_REGO_TXCONFIG, (32 << HE_REGS_TXCONFIG_THRESH) | - (sc->ifatm.mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) | + (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) | (sc->tx_numbuffs << HE_REGS_TXCONFIG_LBFREE)); } else { WRITE4(sc, HE_REGO_RCCONFIG, (0 << HE_REGS_RCCONFIG_UTDELAY) | HE_REGM_RCCONFIG_UT_MODE | - (sc->ifatm.mib.vpi_bits << HE_REGS_RCCONFIG_VP) | - (sc->ifatm.mib.vci_bits << HE_REGS_RCCONFIG_VC)); + (IFP2IFATM(sc->ifp)->mib.vpi_bits << HE_REGS_RCCONFIG_VP) | + (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_RCCONFIG_VC)); WRITE4(sc, HE_REGO_TXCONFIG, (32 << HE_REGS_TXCONFIG_THRESH) | HE_REGM_TXCONFIG_UTMODE | - (sc->ifatm.mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) | + (IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) | (sc->tx_numbuffs << HE_REGS_TXCONFIG_LBFREE)); } @@ -2236,8 +2244,8 @@ hatm_initialize(struct hatm_softc *sc) v |= HE_PCIM_CTL0_INIT_ENB | HE_PCIM_CTL0_INT_PROC_ENB; pci_write_config(sc->dev, HE_PCIR_GEN_CNTL_0, v, 4); - sc->ifatm.ifnet.if_flags |= IFF_RUNNING; - sc->ifatm.ifnet.if_baudrate = 53 * 8 * sc->ifatm.mib.pcr; + sc->ifp->if_flags |= IFF_RUNNING; + sc->ifp->if_baudrate = 53 * 8 * IFP2IFATM(sc->ifp)->mib.pcr; sc->utopia.flags &= ~UTP_FL_POLL_CARRIER; @@ -2246,7 +2254,7 @@ hatm_initialize(struct hatm_softc *sc) if (sc->vccs[cid] != NULL) hatm_load_vc(sc, cid, 1); - ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm, + ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), sc->utopia.carrier == UTP_CARR_OK); } @@ -2264,11 +2272,11 @@ hatm_stop(struct hatm_softc *sc) mtx_assert(&sc->mtx, MA_OWNED); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) + if (!(sc->ifp->if_flags & IFF_RUNNING)) return; - sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; + sc->ifp->if_flags &= ~IFF_RUNNING; - ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm, + ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), sc->utopia.carrier == UTP_CARR_OK); sc->utopia.flags |= UTP_FL_POLL_CARRIER; diff --git a/sys/dev/hatm/if_hatm_intr.c b/sys/dev/hatm/if_hatm_intr.c index 70bbde8..9ee64d7 100644 --- a/sys/dev/hatm/if_hatm_intr.c +++ b/sys/dev/hatm/if_hatm_intr.c @@ -203,7 +203,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group) err = bus_dmamap_create(sc->mbuf_tag, 0, &pg->hdr.map); if (err != 0) { - if_printf(&sc->ifatm.ifnet, "%s -- bus_dmamap_create: %d\n", + if_printf(sc->ifp, "%s -- bus_dmamap_create: %d\n", __func__, err); free(pg, M_DEVBUF); return; @@ -211,7 +211,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group) err = bus_dmamap_load(sc->mbuf_tag, pg->hdr.map, pg, MBUF_ALLOC_SIZE, hatm_extbuf_helper, &pg->hdr.phys, BUS_DMA_NOWAIT); if (err != 0) { - if_printf(&sc->ifatm.ifnet, "%s -- mbuf mapping failed %d\n", + if_printf(sc->ifp, "%s -- mbuf mapping failed %d\n", __func__, err); bus_dmamap_destroy(sc->mbuf_tag, pg->hdr.map); free(pg, M_DEVBUF); @@ -329,7 +329,7 @@ he_intr_rbp(struct hatm_softc *sc, struct herbp *rbp, u_int large, /* allocate the MBUF */ if ((m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL) { - if_printf(&sc->ifatm.ifnet, + if_printf(sc->ifp, "no mbuf clusters\n"); break; } @@ -534,7 +534,7 @@ hatm_intr(void *p) /* if we have a stray interrupt with a non-initialized card, * we cannot even lock before looking at the flag */ - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) + if (!(sc->ifp->if_flags & IFF_RUNNING)) return; mtx_lock(&sc->mtx); @@ -590,7 +590,7 @@ hatm_intr(void *p) break; default: - if_printf(&sc->ifatm.ifnet, "bad INTR RBPS%u\n", + if_printf(sc->ifp, "bad INTR RBPS%u\n", status & HE_REGM_IGROUP); break; } @@ -605,7 +605,7 @@ hatm_intr(void *p) break; default: - if_printf(&sc->ifatm.ifnet, "bad INTR RBPL%u\n", + if_printf(sc->ifp, "bad INTR RBPL%u\n", status & HE_REGM_IGROUP); break; } @@ -628,7 +628,7 @@ hatm_intr(void *p) /* FALLTHRU */ default: - if_printf(&sc->ifatm.ifnet, "bad INTR RBRQ%u\n", + if_printf(sc->ifp, "bad INTR RBRQ%u\n", status & HE_REGM_IGROUP); break; } @@ -651,7 +651,7 @@ hatm_intr(void *p) /* FALLTHRU */ default: - if_printf(&sc->ifatm.ifnet, "bad INTR RBRQT%u\n", + if_printf(sc->ifp, "bad INTR RBRQT%u\n", status & HE_REGM_IGROUP); break; } @@ -665,7 +665,7 @@ hatm_intr(void *p) #if HE_REGM_ITYPE_UNKNOWN != HE_REGM_ITYPE_INVALID case HE_REGM_ITYPE_UNKNOWN: sc->istats.itype_unknown++; - if_printf(&sc->ifatm.ifnet, "bad interrupt\n"); + if_printf(sc->ifp, "bad interrupt\n"); break; #endif @@ -674,17 +674,17 @@ hatm_intr(void *p) switch (status) { case HE_REGM_ITYPE_PERR: - if_printf(&sc->ifatm.ifnet, "parity error\n"); + if_printf(sc->ifp, "parity error\n"); break; case HE_REGM_ITYPE_ABORT: - if_printf(&sc->ifatm.ifnet, "abort interrupt " + if_printf(sc->ifp, "abort interrupt " "addr=0x%08x\n", READ4(sc, HE_REGO_ABORT_ADDR)); break; default: - if_printf(&sc->ifatm.ifnet, + if_printf(sc->ifp, "bad interrupt type %08x\n", status); break; } @@ -706,7 +706,7 @@ hatm_intr(void *p) break; default: - if_printf(&sc->ifatm.ifnet, "bad interrupt type %08x\n", + if_printf(sc->ifp, "bad interrupt type %08x\n", status); break; } diff --git a/sys/dev/hatm/if_hatm_ioctl.c b/sys/dev/hatm/if_hatm_ioctl.c index c810279..cb8d652 100644 --- a/sys/dev/hatm/if_hatm_ioctl.c +++ b/sys/dev/hatm/if_hatm_ioctl.c @@ -116,7 +116,7 @@ hatm_open_vcc(struct hatm_softc *sc, struct atmio_openvcc *arg) return (ENOMEM); mtx_lock(&sc->mtx); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { error = EIO; goto done; } @@ -188,7 +188,7 @@ hatm_load_vc(struct hatm_softc *sc, u_int cid, int reopen) /* inform management about non-NG and NG-PVCs */ if (!(vcc->param.flags & ATMIO_FLAG_NG) || (vcc->param.flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->param.vpi, + ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->param.vpi, vcc->param.vci, 1); } @@ -203,7 +203,7 @@ hatm_vcc_closed(struct hatm_softc *sc, u_int cid) /* inform management about non-NG and NG-PVCs */ if (!(vcc->param.flags & ATMIO_FLAG_NG) || (vcc->param.flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, HE_VPI(cid), HE_VCI(cid), 0); + ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), HE_VPI(cid), HE_VCI(cid), 0); sc->open_vccs--; uma_zfree(sc->vcc_zone, vcc); @@ -230,7 +230,7 @@ hatm_close_vcc(struct hatm_softc *sc, struct atmio_closevcc *arg) mtx_lock(&sc->mtx); vcc = sc->vccs[cid]; - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { error = EIO; goto done; } @@ -248,11 +248,11 @@ hatm_close_vcc(struct hatm_softc *sc, struct atmio_closevcc *arg) if (vcc->param.flags & ATMIO_FLAG_ASYNC) goto done; - while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) && + while ((sc->ifp->if_flags & IFF_RUNNING) && (vcc->vflags & (HE_VCC_TX_CLOSING | HE_VCC_RX_CLOSING))) cv_wait(&sc->vcc_cv, &sc->mtx); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + if (!(sc->ifp->if_flags & IFF_RUNNING)) { error = EIO; goto done; } diff --git a/sys/dev/hatm/if_hatm_rx.c b/sys/dev/hatm/if_hatm_rx.c index 1b3ee8d..bf6c7f7 100644 --- a/sys/dev/hatm/if_hatm_rx.c +++ b/sys/dev/hatm/if_hatm_rx.c @@ -130,7 +130,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, vcc->chain = vcc->last = m0; vcc->last->m_next = NULL; vcc->chain->m_pkthdr.len = m0->m_len; - vcc->chain->m_pkthdr.rcvif = &sc->ifatm.ifnet; + vcc->chain->m_pkthdr.rcvif = sc->ifp; } else { sc->istats.rx_seg++; @@ -148,7 +148,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, m_freem(vcc->chain); vcc->chain = vcc->last = NULL; sc->istats.crc_error++; - sc->ifatm.ifnet.if_ierrors++; + sc->ifp->if_ierrors++; return; } if (flags & HE_REGM_RBRQ_LEN_ERROR) { @@ -156,7 +156,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, m_freem(vcc->chain); vcc->chain = vcc->last = NULL; sc->istats.len_error++; - sc->ifatm.ifnet.if_ierrors++; + sc->ifp->if_ierrors++; return; } @@ -229,7 +229,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, if (!(vcc->param.flags & ATMIO_FLAG_NG) && (vcc->param.aal == ATMIO_AAL_5) && (vcc->param.flags & ATM_PH_LLCSNAP)) - BPF_MTAP(&sc->ifatm.ifnet, m); + BPF_MTAP(sc->ifp, m); #endif vpi = HE_VPI(cid); @@ -239,9 +239,9 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, ATM_PH_VPI(&aph) = vpi; ATM_PH_SETVCI(&aph, vci); - sc->ifatm.ifnet.if_ipackets++; + sc->ifp->if_ipackets++; /* this is in if_atmsubr.c */ - /* sc->ifatm.ifnet.if_ibytes += len; */ + /* sc->ifp->if_ibytes += len; */ vcc->ibytes += len; vcc->ipackets++; @@ -260,7 +260,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, } #endif - atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand); + atm_input(sc->ifp, &aph, m, vcc->rxhand); return; @@ -316,11 +316,11 @@ hatm_rx_vcc_close(struct hatm_softc *sc, u_int cid) WRITE_RSR(sc, cid, 0, 0xf, 0); v = READ4(sc, HE_REGO_RCCSTAT); - while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) && + while ((sc->ifp->if_flags & IFF_RUNNING) && (READ4(sc, HE_REGO_RCCSTAT) & HE_REGM_RCCSTAT_PROG)) cv_timedwait(&sc->cv_rcclose, &sc->mtx, 1); - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) + if (!(sc->ifp->if_flags & IFF_RUNNING)) return; WRITE_MBOX4(sc, HE_REGO_RCON_CLOSE, cid); diff --git a/sys/dev/hatm/if_hatm_tx.c b/sys/dev/hatm/if_hatm_tx.c index 3f0e66c..87baf09 100644 --- a/sys/dev/hatm/if_hatm_tx.c +++ b/sys/dev/hatm/if_hatm_tx.c @@ -193,7 +193,7 @@ hatm_queue_tpds(struct hatm_softc *sc, u_int count, struct tpd **list, sc->tpdrq.size; if (space <= count) { - if_printf(&sc->ifatm.ifnet, "TPDRQ full\n"); + if_printf(sc->ifp, "TPDRQ full\n"); sc->istats.tdprq_full++; return (EBUSY); } @@ -262,7 +262,7 @@ hatm_load_txbuf(void *uarg, bus_dma_segment_t *segs, int nseg, /* ensure, we have enough TPDs (remember, we already have one) */ tpds_needed = (nseg + 2) / 3; if (HE_CONFIG_TPD_RESERVE + tpds_needed - 1 > arg->sc->tpd_nfree) { - if_printf(&arg->sc->ifatm.ifnet, "%s -- out of TPDs (need %d, " + if_printf(arg->sc->ifp, "%s -- out of TPDs (need %d, " "have %u)\n", __func__, tpds_needed - 1, arg->sc->tpd_nfree + 1); arg->error = 1; @@ -277,7 +277,7 @@ hatm_load_txbuf(void *uarg, bus_dma_segment_t *segs, int nseg, if (arg->vcc->ntpds + tpds_needed > arg->sc->max_tpd) { arg->sc->istats.flow_closed++; arg->vcc->vflags |= HE_VCC_FLOW_CTRL; - ATMEV_SEND_FLOW_CONTROL(&arg->sc->ifatm, + ATMEV_SEND_FLOW_CONTROL(IFP2IFATM(arg->sc->ifp), arg->vpi, arg->vci, 1); arg->error = 1; return; @@ -451,7 +451,7 @@ hatm_start(struct ifnet *ifp) if ((tpd = hatm_alloc_tpd(sc, M_NOWAIT)) == NULL) { hatm_free_txmbuf(sc); m_freem(m); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } tpd->cid = cid; @@ -471,7 +471,7 @@ hatm_start(struct ifnet *ifp) tpd->mbuf = NULL; hatm_free_txmbuf(sc); hatm_free_tpd(sc, tpd); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } arg.mbuf = m; @@ -480,20 +480,20 @@ hatm_start(struct ifnet *ifp) } if (error != 0) { - if_printf(&sc->ifatm.ifnet, "mbuf loaded error=%d\n", + if_printf(sc->ifp, "mbuf loaded error=%d\n", error); hatm_free_tpd(sc, tpd); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } if (arg.error) { hatm_free_tpd(sc, tpd); - sc->ifatm.ifnet.if_oerrors++; + sc->ifp->if_oerrors++; continue; } arg.vcc->opackets++; arg.vcc->obytes += len; - sc->ifatm.ifnet.if_opackets++; + sc->ifp->if_opackets++; } mtx_unlock(&sc->mtx); } @@ -528,7 +528,7 @@ hatm_tx_complete(struct hatm_softc *sc, struct tpd *tpd, uint32_t flags) if ((vcc->vflags & HE_VCC_FLOW_CTRL) && vcc->ntpds <= HE_CONFIG_TPD_FLOW_ENB) { vcc->vflags &= ~HE_VCC_FLOW_CTRL; - ATMEV_SEND_FLOW_CONTROL(&sc->ifatm, + ATMEV_SEND_FLOW_CONTROL(IFP2IFATM(sc->ifp), HE_VPI(tpd->cid), HE_VCI(tpd->cid), 0); } } @@ -569,13 +569,13 @@ hatm_tx_vcc_can_open(struct hatm_softc *sc, u_int cid, struct hevcc *vcc) #if 0 v = READ_TSR(sc, cid, 4); if(!(v & HE_REGM_TSR4_SESS_END)) { - if_printf(&sc->ifatm.ifnet, "cid=%#x not closed (TSR4)\n", cid); + if_printf(sc->ifp, "cid=%#x not closed (TSR4)\n", cid); return (EBUSY); } #endif v = READ_TSR(sc, cid, 0); if((v & HE_REGM_TSR0_CONN_STATE) != 0) { - if_printf(&sc->ifatm.ifnet, "cid=%#x not closed (TSR0=%#x)\n", + if_printf(sc->ifp, "cid=%#x not closed (TSR0=%#x)\n", cid, v); return (EBUSY); } diff --git a/sys/dev/hatm/if_hatmvar.h b/sys/dev/hatm/if_hatmvar.h index acddaa1..9edadc3 100644 --- a/sys/dev/hatm/if_hatmvar.h +++ b/sys/dev/hatm/if_hatmvar.h @@ -363,7 +363,7 @@ struct herg { * Softc */ struct hatm_softc { - struct ifatm ifatm; /* common ATM stuff */ + struct ifnet *ifp; struct mtx mtx; /* lock */ struct ifmedia media; /* media */ device_t dev; /* device */ |