diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c --- a/sys/dev/lge/if_lge.c +++ b/sys/dev/lge/if_lge.c @@ -134,17 +134,17 @@ static void lge_txeof(struct lge_softc *); static void lge_intr(void *); static void lge_tick(void *); -static void lge_start(struct ifnet *); -static void lge_start_locked(struct ifnet *); -static int lge_ioctl(struct ifnet *, u_long, caddr_t); +static void lge_start(if_t); +static void lge_start_locked(if_t); +static int lge_ioctl(if_t, u_long, caddr_t); static void lge_init(void *); static void lge_init_locked(struct lge_softc *); static void lge_stop(struct lge_softc *); static void lge_watchdog(struct lge_softc *); static int lge_shutdown(device_t); -static int lge_ifmedia_upd(struct ifnet *); -static void lge_ifmedia_upd_locked(struct ifnet *); -static void lge_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int lge_ifmedia_upd(if_t); +static void lge_ifmedia_upd_locked(if_t); +static void lge_ifmedia_sts(if_t, struct ifmediareq *); static void lge_eeprom_getword(struct lge_softc *, int, u_int16_t *); static void lge_read_eeprom(struct lge_softc *, caddr_t, int, int, int); @@ -382,7 +382,7 @@ lge_setmulti(sc) struct lge_softc *sc; { - struct ifnet *ifp; + if_t ifp; uint32_t hashes[2] = { 0, 0 }; ifp = sc->lge_ifp; @@ -391,7 +391,7 @@ /* Make sure multicast hash table is enabled. */ CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_SETRST_CTL1|LGE_MODE1_RX_MCAST); - if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { + if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) { CSR_WRITE_4(sc, LGE_MAR0, 0xFFFFFFFF); CSR_WRITE_4(sc, LGE_MAR1, 0xFFFFFFFF); return; @@ -466,7 +466,7 @@ { u_char eaddr[ETHER_ADDR_LEN]; struct lge_softc *sc; - struct ifnet *ifp = NULL; + if_t ifp = NULL; int error = 0, rid; sc = device_get_softc(dev); @@ -536,15 +536,15 @@ error = ENOSPC; goto fail; } - ifp->if_softc = sc; + if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = lge_ioctl; - ifp->if_start = lge_start; - ifp->if_init = lge_init; - ifp->if_snd.ifq_maxlen = LGE_TX_LIST_CNT - 1; - ifp->if_capabilities = IFCAP_RXCSUM; - ifp->if_capenable = ifp->if_capabilities; + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setioctlfn(ifp, lge_ioctl); + if_setstartfn(ifp, lge_start); + if_setinitfn(ifp, lge_init); + if_setsendqlen(ifp, LGE_TX_LIST_CNT - 1); + if_setcapabilities(ifp, IFCAP_RXCSUM); + if_setcapenable(ifp, if_getcapabilities(ifp)); if (CSR_READ_4(sc, LGE_GMIIMODE) & LGE_GMIIMODE_PCSENH) sc->lge_pcs = 1; @@ -596,7 +596,7 @@ device_t dev; { struct lge_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); ifp = sc->lge_ifp; @@ -885,7 +885,7 @@ int cnt; { struct mbuf *m; - struct ifnet *ifp; + if_t ifp; struct lge_rx_desc *cur_rx; int c, i, total_len = 0; u_int32_t rxsts, rxctl; @@ -954,7 +954,7 @@ } LGE_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); LGE_LOCK(sc); } @@ -967,10 +967,10 @@ lge_rxeoc(sc) struct lge_softc *sc; { - struct ifnet *ifp; + if_t ifp; ifp = sc->lge_ifp; - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); lge_init_locked(sc); return; } @@ -985,7 +985,7 @@ struct lge_softc *sc; { struct lge_tx_desc *cur_tx = NULL; - struct ifnet *ifp; + if_t ifp; u_int32_t idx, txdone; ifp = sc->lge_ifp; @@ -1018,7 +1018,7 @@ sc->lge_cdata.lge_tx_cons = idx; if (cur_tx != NULL) - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); return; } @@ -1029,7 +1029,7 @@ { struct lge_softc *sc; struct mii_data *mii; - struct ifnet *ifp; + if_t ifp; sc = xsc; ifp = sc->lge_ifp; @@ -1050,7 +1050,7 @@ (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX|| IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T)) device_printf(sc->lge_dev, "gigabit link up\n"); - if (ifp->if_snd.ifq_head != NULL) + if (!if_sendq_empty(ifp)) lge_start_locked(ifp); } } @@ -1067,7 +1067,7 @@ void *arg; { struct lge_softc *sc; - struct ifnet *ifp; + if_t ifp; u_int32_t status; sc = arg; @@ -1075,7 +1075,7 @@ LGE_LOCK(sc); /* Suppress unwanted interrupts */ - if (!(ifp->if_flags & IFF_UP)) { + if (!(if_getflags(ifp) & IFF_UP)) { lge_stop(sc); LGE_UNLOCK(sc); return; @@ -1111,7 +1111,7 @@ /* Re-enable interrupts. */ CSR_WRITE_4(sc, LGE_IMR, LGE_IMR_SETRST_CTL0|LGE_IMR_INTR_ENB); - if (ifp->if_snd.ifq_head != NULL) + if (!if_sendq_empty(ifp)) lge_start_locked(ifp); LGE_UNLOCK(sc); @@ -1175,11 +1175,11 @@ static void lge_start(ifp) - struct ifnet *ifp; + if_t ifp; { struct lge_softc *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); LGE_LOCK(sc); lge_start_locked(ifp); LGE_UNLOCK(sc); @@ -1187,33 +1187,33 @@ static void lge_start_locked(ifp) - struct ifnet *ifp; + if_t ifp; { struct lge_softc *sc; struct mbuf *m_head = NULL; u_int32_t idx; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); if (!sc->lge_link) return; idx = sc->lge_cdata.lge_tx_prod; - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) return; while(sc->lge_ldata->lge_tx_list[idx].lge_mbuf == NULL) { if (CSR_READ_1(sc, LGE_TXCMDFREE_8BIT) == 0) break; - IF_DEQUEUE(&ifp->if_snd, m_head); + m_head = if_dequeue(ifp); if (m_head == NULL) break; if (lge_encap(sc, m_head, &idx)) { - IF_PREPEND(&ifp->if_snd, m_head); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_sendq_prepend(ifp, m_head); + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); break; } @@ -1249,10 +1249,10 @@ lge_init_locked(sc) struct lge_softc *sc; { - struct ifnet *ifp = sc->lge_ifp; + if_t ifp = sc->lge_ifp; LGE_LOCK_ASSERT(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) return; /* @@ -1262,8 +1262,8 @@ lge_reset(sc); /* Set MAC address */ - CSR_WRITE_4(sc, LGE_PAR0, *(u_int32_t *)(&IF_LLADDR(sc->lge_ifp)[0])); - CSR_WRITE_4(sc, LGE_PAR1, *(u_int32_t *)(&IF_LLADDR(sc->lge_ifp)[4])); + CSR_WRITE_4(sc, LGE_PAR0, *(u_int32_t *)(&if_getlladdr(sc->lge_ifp)[0])); + CSR_WRITE_4(sc, LGE_PAR1, *(u_int32_t *)(&if_getlladdr(sc->lge_ifp)[4])); /* Init circular RX list. */ if (lge_list_rx_init(sc) == ENOBUFS) { @@ -1285,7 +1285,7 @@ LGE_MODE1_SETRST_CTL1|LGE_MODE1_SETRST_CTL2); /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) { + if (if_getflags(ifp) & IFF_PROMISC) { CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_SETRST_CTL1|LGE_MODE1_RX_PROMISC); } else { @@ -1295,7 +1295,7 @@ /* * Set the capture broadcast bit to capture broadcast frames. */ - if (ifp->if_flags & IFF_BROADCAST) { + if (if_getflags(ifp) & IFF_BROADCAST) { CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_SETRST_CTL1|LGE_MODE1_RX_BCAST); } else { @@ -1363,8 +1363,8 @@ lge_ifmedia_upd_locked(ifp); - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); callout_reset(&sc->lge_stat_callout, hz, lge_tick, sc); @@ -1376,11 +1376,11 @@ */ static int lge_ifmedia_upd(ifp) - struct ifnet *ifp; + if_t ifp; { struct lge_softc *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); LGE_LOCK(sc); lge_ifmedia_upd_locked(ifp); LGE_UNLOCK(sc); @@ -1390,13 +1390,13 @@ static void lge_ifmedia_upd_locked(ifp) - struct ifnet *ifp; + if_t ifp; { struct lge_softc *sc; struct mii_data *mii; struct mii_softc *miisc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); LGE_LOCK_ASSERT(sc); mii = device_get_softc(sc->lge_miibus); @@ -1411,13 +1411,13 @@ */ static void lge_ifmedia_sts(ifp, ifmr) - struct ifnet *ifp; + if_t ifp; struct ifmediareq *ifmr; { struct lge_softc *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); LGE_LOCK(sc); mii = device_get_softc(sc->lge_miibus); @@ -1431,11 +1431,11 @@ static int lge_ioctl(ifp, command, data) - struct ifnet *ifp; + if_t ifp; u_long command; caddr_t data; { - struct lge_softc *sc = ifp->if_softc; + struct lge_softc *sc = if_getsoftc(ifp); struct ifreq *ifr = (struct ifreq *) data; struct mii_data *mii; int error = 0; @@ -1446,32 +1446,32 @@ if (ifr->ifr_mtu > LGE_JUMBO_MTU) error = EINVAL; else - ifp->if_mtu = ifr->ifr_mtu; + if_setmtu(ifp, ifr->ifr_mtu); LGE_UNLOCK(sc); break; case SIOCSIFFLAGS: LGE_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING && - ifp->if_flags & IFF_PROMISC && + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING && + if_getflags(ifp) & IFF_PROMISC && !(sc->lge_if_flags & IFF_PROMISC)) { CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_SETRST_CTL1| LGE_MODE1_RX_PROMISC); - } else if (ifp->if_drv_flags & IFF_DRV_RUNNING && - !(ifp->if_flags & IFF_PROMISC) && + } else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING && + !(if_getflags(ifp) & IFF_PROMISC) && sc->lge_if_flags & IFF_PROMISC) { CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_RX_PROMISC); } else { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); lge_init_locked(sc); } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) lge_stop(sc); } - sc->lge_if_flags = ifp->if_flags; + sc->lge_if_flags = if_getflags(ifp); LGE_UNLOCK(sc); error = 0; break; @@ -1499,7 +1499,7 @@ lge_watchdog(sc) struct lge_softc *sc; { - struct ifnet *ifp; + if_t ifp; LGE_LOCK_ASSERT(sc); ifp = sc->lge_ifp; @@ -1509,10 +1509,10 @@ lge_stop(sc); lge_reset(sc); - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); lge_init_locked(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!if_sendq_empty(ifp)) lge_start_locked(ifp); } @@ -1525,7 +1525,7 @@ struct lge_softc *sc; { int i; - struct ifnet *ifp; + if_t ifp; LGE_LOCK_ASSERT(sc); ifp = sc->lge_ifp; @@ -1562,7 +1562,7 @@ bzero((char *)&sc->lge_ldata->lge_tx_list, sizeof(sc->lge_ldata->lge_tx_list)); - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); return; } diff --git a/sys/dev/lge/if_lgereg.h b/sys/dev/lge/if_lgereg.h --- a/sys/dev/lge/if_lgereg.h +++ b/sys/dev/lge/if_lgereg.h @@ -507,7 +507,7 @@ }; struct lge_softc { - struct ifnet *lge_ifp; + if_t lge_ifp; device_t lge_dev; bus_space_handle_t lge_bhandle; bus_space_tag_t lge_btag;