git: ac8e2243b88c - main - Mechanically convert if_rl(4) to IfAPI
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Feb 2023 17:54:06 UTC
The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=ac8e2243b88c95642a5e3f409edc52a859938c00 commit ac8e2243b88c95642a5e3f409edc52a859938c00 Author: Justin Hibbits <jhibbits@FreeBSD.org> AuthorDate: 2022-03-01 19:21:11 +0000 Commit: Justin Hibbits <jhibbits@FreeBSD.org> CommitDate: 2023-02-06 17:32:08 +0000 Mechanically convert if_rl(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37803 --- sys/dev/rl/if_rl.c | 205 +++++++++++++++++++++++++------------------------- sys/dev/rl/if_rlreg.h | 2 +- 2 files changed, 103 insertions(+), 104 deletions(-) diff --git a/sys/dev/rl/if_rl.c b/sys/dev/rl/if_rl.c index a53bc7d6eb1a..ec680b632995 100644 --- a/sys/dev/rl/if_rl.c +++ b/sys/dev/rl/if_rl.c @@ -185,9 +185,9 @@ static void rl_eeprom_getword(struct rl_softc *, int, uint16_t *); static int rl_encap(struct rl_softc *, struct mbuf **); static int rl_list_tx_init(struct rl_softc *); static int rl_list_rx_init(struct rl_softc *); -static int rl_ifmedia_upd(struct ifnet *); -static void rl_ifmedia_sts(struct ifnet *, struct ifmediareq *); -static int rl_ioctl(struct ifnet *, u_long, caddr_t); +static int rl_ifmedia_upd(if_t); +static void rl_ifmedia_sts(if_t, struct ifmediareq *); +static int rl_ioctl(if_t, u_long, caddr_t); static void rl_intr(void *); static void rl_init(void *); static void rl_init_locked(struct rl_softc *sc); @@ -195,8 +195,8 @@ static int rl_miibus_readreg(device_t, int, int); static void rl_miibus_statchg(device_t); static int rl_miibus_writereg(device_t, int, int, int); #ifdef DEVICE_POLLING -static int rl_poll(struct ifnet *ifp, enum poll_cmd cmd, int count); -static int rl_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count); +static int rl_poll(if_t ifp, enum poll_cmd cmd, int count); +static int rl_poll_locked(if_t ifp, enum poll_cmd cmd, int count); #endif static int rl_probe(device_t); static void rl_read_eeprom(struct rl_softc *, uint8_t *, int, int, int); @@ -205,8 +205,8 @@ static int rl_resume(device_t); static int rl_rxeof(struct rl_softc *); static void rl_rxfilter(struct rl_softc *); static int rl_shutdown(device_t); -static void rl_start(struct ifnet *); -static void rl_start_locked(struct ifnet *); +static void rl_start(if_t); +static void rl_start_locked(if_t); static void rl_stop(struct rl_softc *); static int rl_suspend(device_t); static void rl_tick(void *); @@ -478,14 +478,14 @@ static void rl_miibus_statchg(device_t dev) { struct rl_softc *sc; - struct ifnet *ifp; + if_t ifp; struct mii_data *mii; sc = device_get_softc(dev); mii = device_get_softc(sc->rl_miibus); ifp = sc->rl_ifp; if (mii == NULL || ifp == NULL || - (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) return; sc->rl_flags &= ~RL_FLAG_LINK; @@ -528,7 +528,7 @@ rl_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) static void rl_rxfilter(struct rl_softc *sc) { - struct ifnet *ifp = sc->rl_ifp; + if_t ifp = sc->rl_ifp; uint32_t hashes[2] = { 0, 0 }; uint32_t rxfilt; @@ -540,11 +540,11 @@ rl_rxfilter(struct rl_softc *sc) /* Always accept frames destined for this host. */ rxfilt |= RL_RXCFG_RX_INDIV; /* Set capture broadcast bit to capture broadcast frames. */ - if (ifp->if_flags & IFF_BROADCAST) + if (if_getflags(ifp) & IFF_BROADCAST) rxfilt |= RL_RXCFG_RX_BROAD; - if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { + if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) { rxfilt |= RL_RXCFG_RX_MULTI; - if (ifp->if_flags & IFF_PROMISC) + if (if_getflags(ifp) & IFF_PROMISC) rxfilt |= RL_RXCFG_RX_ALLPHYS; hashes[0] = 0xFFFFFFFF; hashes[1] = 0xFFFFFFFF; @@ -637,7 +637,7 @@ rl_attach(device_t dev) { uint8_t eaddr[ETHER_ADDR_LEN]; uint16_t as[3]; - struct ifnet *ifp; + if_t ifp; struct rl_softc *sc; const struct rl_type *t; struct sysctl_ctx_list *ctx; @@ -801,14 +801,14 @@ rl_attach(device_t dev) goto fail; } - ifp->if_softc = sc; + if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_mtu = ETHERMTU; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = rl_ioctl; - ifp->if_start = rl_start; - ifp->if_init = rl_init; - ifp->if_capabilities = IFCAP_VLAN_MTU; + if_setmtu(ifp, ETHERMTU); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setioctlfn(ifp, rl_ioctl); + if_setstartfn(ifp, rl_start); + if_setinitfn(ifp, rl_init); + if_setcapabilities(ifp, IFCAP_VLAN_MTU); /* Check WOL for RTL8139B or newer controllers. */ if (sc->rl_type == RL_8139 && pci_find_cap(sc->rl_dev, PCIY_PMG, &pmc) == 0) { @@ -820,7 +820,7 @@ rl_attach(device_t dev) case RL_HWREV_8139D: case RL_HWREV_8101: case RL_HWREV_8100: - ifp->if_capabilities |= IFCAP_WOL; + if_setcapabilitiesbit(ifp, IFCAP_WOL, 0); /* Disable WOL. */ rl_clrwol(sc); break; @@ -828,14 +828,13 @@ rl_attach(device_t dev) break; } } - ifp->if_capenable = ifp->if_capabilities; - ifp->if_capenable &= ~(IFCAP_WOL_UCAST | IFCAP_WOL_MCAST); + if_setcapenable(ifp, if_getcapabilities(ifp)); + if_setcapenablebit(ifp, 0, (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST)); #ifdef DEVICE_POLLING - ifp->if_capabilities |= IFCAP_POLLING; + if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0); #endif - IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); - ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; - IFQ_SET_READY(&ifp->if_snd); + if_setsendqlen(ifp, ifqmaxlen); + if_setsendqready(ifp); /* * Call MI attach routine. @@ -868,7 +867,7 @@ static int rl_detach(device_t dev) { struct rl_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); ifp = sc->rl_ifp; @@ -876,7 +875,7 @@ rl_detach(device_t dev) KASSERT(mtx_initialized(&sc->rl_mtx), ("rl mutex not initialized")); #ifdef DEVICE_POLLING - if (ifp->if_capenable & IFCAP_POLLING) + if (if_getcapenable(ifp) & IFCAP_POLLING) ether_poll_deregister(ifp); #endif /* These should only be active if attach succeeded */ @@ -1116,7 +1115,7 @@ static int rl_rxeof(struct rl_softc *sc) { struct mbuf *m; - struct ifnet *ifp = sc->rl_ifp; + if_t ifp = sc->rl_ifp; uint8_t *rxbufpos; int total_len = 0; int wrap = 0; @@ -1143,7 +1142,7 @@ rl_rxeof(struct rl_softc *sc) while((CSR_READ_1(sc, RL_COMMAND) & RL_CMD_EMPTY_RXBUF) == 0) { #ifdef DEVICE_POLLING - if (ifp->if_capenable & IFCAP_POLLING) { + if (if_getcapenable(ifp) & IFCAP_POLLING) { if (sc->rxcycles <= 0) break; sc->rxcycles--; @@ -1168,7 +1167,7 @@ rl_rxeof(struct rl_softc *sc) total_len < ETHER_MIN_LEN || total_len > ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) { if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); rl_init_locked(sc); return (rx_npkts); } @@ -1222,7 +1221,7 @@ rl_rxeof(struct rl_softc *sc) if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); RL_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); RL_LOCK(sc); rx_npkts++; } @@ -1238,7 +1237,7 @@ rl_rxeof(struct rl_softc *sc) static void rl_txeof(struct rl_softc *sc) { - struct ifnet *ifp = sc->rl_ifp; + if_t ifp = sc->rl_ifp; uint32_t txstat; RL_LOCK_ASSERT(sc); @@ -1280,14 +1279,14 @@ rl_txeof(struct rl_softc *sc) CSR_WRITE_4(sc, RL_TXCFG, RL_TXCFG_CONFIG); oldthresh = sc->rl_txthresh; /* error recovery */ - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); rl_init_locked(sc); /* restore original threshold */ sc->rl_txthresh = oldthresh; return; } RL_INC(sc->rl_cdata.last_tx); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); } while (sc->rl_cdata.last_tx != sc->rl_cdata.cur_tx); if (RL_LAST_TXMBUF(sc) == NULL) @@ -1435,22 +1434,22 @@ rl_tick(void *xsc) #ifdef DEVICE_POLLING static int -rl_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +rl_poll(if_t ifp, enum poll_cmd cmd, int count) { - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); int rx_npkts = 0; RL_LOCK(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) rx_npkts = rl_poll_locked(ifp, cmd, count); RL_UNLOCK(sc); return (rx_npkts); } static int -rl_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count) +rl_poll_locked(if_t ifp, enum poll_cmd cmd, int count) { - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); int rx_npkts; RL_LOCK_ASSERT(sc); @@ -1459,7 +1458,7 @@ rl_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count) rx_npkts = rl_rxeof(sc); rl_txeof(sc); - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) rl_start_locked(ifp); if (cmd == POLL_AND_CHECK_STATUS) { @@ -1475,7 +1474,7 @@ rl_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count) /* XXX We should check behaviour on receiver stalls. */ if (status & RL_ISR_SYSTEM_ERR) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); rl_init_locked(sc); } } @@ -1487,7 +1486,7 @@ static void rl_intr(void *arg) { struct rl_softc *sc = arg; - struct ifnet *ifp = sc->rl_ifp; + if_t ifp = sc->rl_ifp; uint16_t status; int count; @@ -1497,11 +1496,11 @@ rl_intr(void *arg) goto done_locked; #ifdef DEVICE_POLLING - if (ifp->if_capenable & IFCAP_POLLING) + if (if_getcapenable(ifp) & IFCAP_POLLING) goto done_locked; #endif - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) goto done_locked2; status = CSR_READ_2(sc, RL_ISR); if (status == 0xffff || (status & RL_INTRS) == 0) @@ -1512,13 +1511,13 @@ rl_intr(void *arg) CSR_WRITE_2(sc, RL_IMR, 0); for (count = 16; count > 0; count--) { CSR_WRITE_2(sc, RL_ISR, status); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { if (status & (RL_ISR_RX_OK | RL_ISR_RX_ERR)) rl_rxeof(sc); if (status & (RL_ISR_TX_OK | RL_ISR_TX_ERR)) rl_txeof(sc); if (status & RL_ISR_SYSTEM_ERR) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); rl_init_locked(sc); RL_UNLOCK(sc); return; @@ -1530,11 +1529,11 @@ rl_intr(void *arg) break; } - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) rl_start_locked(ifp); done_locked2: - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) CSR_WRITE_2(sc, RL_IMR, RL_INTRS); done_locked: RL_UNLOCK(sc); @@ -1611,9 +1610,9 @@ rl_encap(struct rl_softc *sc, struct mbuf **m_head) * Main transmit routine. */ static void -rl_start(struct ifnet *ifp) +rl_start(if_t ifp) { - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); RL_LOCK(sc); rl_start_locked(ifp); @@ -1621,19 +1620,19 @@ rl_start(struct ifnet *ifp) } static void -rl_start_locked(struct ifnet *ifp) +rl_start_locked(if_t ifp) { - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); struct mbuf *m_head = NULL; RL_LOCK_ASSERT(sc); - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0) return; while (RL_CUR_TXMBUF(sc) == NULL) { - IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); + m_head = if_dequeue(ifp); if (m_head == NULL) break; @@ -1641,8 +1640,8 @@ rl_start_locked(struct ifnet *ifp) if (rl_encap(sc, &m_head)) { if (m_head == NULL) break; - IFQ_DRV_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; } @@ -1666,7 +1665,7 @@ rl_start_locked(struct ifnet *ifp) * packets from the queue. */ if (RL_CUR_TXMBUF(sc) != NULL) - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); } static void @@ -1682,7 +1681,7 @@ rl_init(void *xsc) static void rl_init_locked(struct rl_softc *sc) { - struct ifnet *ifp = sc->rl_ifp; + if_t ifp = sc->rl_ifp; struct mii_data *mii; uint32_t eaddr[2]; @@ -1690,7 +1689,7 @@ rl_init_locked(struct rl_softc *sc) mii = device_get_softc(sc->rl_miibus); - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) return; /* @@ -1716,7 +1715,7 @@ rl_init_locked(struct rl_softc *sc) */ CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_WRITECFG); bzero(eaddr, sizeof(eaddr)); - bcopy(IF_LLADDR(sc->rl_ifp), eaddr, ETHER_ADDR_LEN); + bcopy(if_getlladdr(sc->rl_ifp), eaddr, ETHER_ADDR_LEN); CSR_WRITE_STREAM_4(sc, RL_IDR0, eaddr[0]); CSR_WRITE_STREAM_4(sc, RL_IDR4, eaddr[1]); CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF); @@ -1745,7 +1744,7 @@ rl_init_locked(struct rl_softc *sc) #ifdef DEVICE_POLLING /* Disable interrupts if we are polling. */ - if (ifp->if_capenable & IFCAP_POLLING) + if (if_getcapenable(ifp) & IFCAP_POLLING) CSR_WRITE_2(sc, RL_IMR, 0); else #endif @@ -1766,8 +1765,8 @@ rl_init_locked(struct rl_softc *sc) CSR_WRITE_1(sc, sc->rl_cfg1, RL_CFG1_DRVLOAD|RL_CFG1_FULLDUPLEX); - 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->rl_stat_callout, hz, rl_tick, sc); } @@ -1776,9 +1775,9 @@ rl_init_locked(struct rl_softc *sc) * Set media options. */ static int -rl_ifmedia_upd(struct ifnet *ifp) +rl_ifmedia_upd(if_t ifp) { - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); struct mii_data *mii; mii = device_get_softc(sc->rl_miibus); @@ -1794,9 +1793,9 @@ rl_ifmedia_upd(struct ifnet *ifp) * Report current media status. */ static void -rl_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) +rl_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr) { - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); struct mii_data *mii; mii = device_get_softc(sc->rl_miibus); @@ -1809,26 +1808,26 @@ rl_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) } static int -rl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) +rl_ioctl(if_t ifp, u_long command, caddr_t data) { struct ifreq *ifr = (struct ifreq *)data; struct mii_data *mii; - struct rl_softc *sc = ifp->if_softc; + struct rl_softc *sc = if_getsoftc(ifp); int error = 0, mask; switch (command) { case SIOCSIFFLAGS: RL_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING && - ((ifp->if_flags ^ sc->rl_if_flags) & + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING && + ((if_getflags(ifp) ^ sc->rl_if_flags) & (IFF_PROMISC | IFF_ALLMULTI))) rl_rxfilter(sc); else rl_init_locked(sc); - } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) + } else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) rl_stop(sc); - sc->rl_if_flags = ifp->if_flags; + sc->rl_if_flags = if_getflags(ifp); RL_UNLOCK(sc); break; case SIOCADDMULTI: @@ -1843,40 +1842,40 @@ rl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); break; case SIOCSIFCAP: - mask = ifr->ifr_reqcap ^ ifp->if_capenable; + mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); #ifdef DEVICE_POLLING if (ifr->ifr_reqcap & IFCAP_POLLING && - !(ifp->if_capenable & IFCAP_POLLING)) { + !(if_getcapenable(ifp) & IFCAP_POLLING)) { error = ether_poll_register(rl_poll, ifp); if (error) return(error); RL_LOCK(sc); /* Disable interrupts */ CSR_WRITE_2(sc, RL_IMR, 0x0000); - ifp->if_capenable |= IFCAP_POLLING; + if_setcapenablebit(ifp, IFCAP_POLLING, 0); RL_UNLOCK(sc); return (error); } if (!(ifr->ifr_reqcap & IFCAP_POLLING) && - ifp->if_capenable & IFCAP_POLLING) { + if_getcapenable(ifp) & IFCAP_POLLING) { error = ether_poll_deregister(ifp); /* Enable interrupts. */ RL_LOCK(sc); CSR_WRITE_2(sc, RL_IMR, RL_INTRS); - ifp->if_capenable &= ~IFCAP_POLLING; + if_setcapenablebit(ifp, 0, IFCAP_POLLING); RL_UNLOCK(sc); return (error); } #endif /* DEVICE_POLLING */ if ((mask & IFCAP_WOL) != 0 && - (ifp->if_capabilities & IFCAP_WOL) != 0) { + (if_getcapabilities(ifp) & IFCAP_WOL) != 0) { if ((mask & IFCAP_WOL_UCAST) != 0) - ifp->if_capenable ^= IFCAP_WOL_UCAST; + if_togglecapenable(ifp, IFCAP_WOL_UCAST); if ((mask & IFCAP_WOL_MCAST) != 0) - ifp->if_capenable ^= IFCAP_WOL_MCAST; + if_togglecapenable(ifp, IFCAP_WOL_MCAST); if ((mask & IFCAP_WOL_MAGIC) != 0) - ifp->if_capenable ^= IFCAP_WOL_MAGIC; + if_togglecapenable(ifp, IFCAP_WOL_MAGIC); } break; default: @@ -1901,7 +1900,7 @@ rl_watchdog(struct rl_softc *sc) rl_txeof(sc); rl_rxeof(sc); - sc->rl_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(sc->rl_ifp, 0, IFF_DRV_RUNNING); rl_init_locked(sc); } @@ -1913,13 +1912,13 @@ static void rl_stop(struct rl_softc *sc) { int i; - struct ifnet *ifp = sc->rl_ifp; + if_t ifp = sc->rl_ifp; RL_LOCK_ASSERT(sc); sc->rl_watchdog_timer = 0; callout_stop(&sc->rl_stat_callout); - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); sc->rl_flags &= ~RL_FLAG_LINK; CSR_WRITE_1(sc, RL_COMMAND, 0x00); @@ -1981,7 +1980,7 @@ static int rl_resume(device_t dev) { struct rl_softc *sc; - struct ifnet *ifp; + if_t ifp; int pmc; uint16_t pmstat; @@ -1990,7 +1989,7 @@ rl_resume(device_t dev) RL_LOCK(sc); - if ((ifp->if_capabilities & IFCAP_WOL) != 0 && + if ((if_getcapabilities(ifp) & IFCAP_WOL) != 0 && pci_find_cap(sc->rl_dev, PCIY_PMG, &pmc) == 0) { /* Disable PME and clear PME status. */ pmstat = pci_read_config(sc->rl_dev, @@ -2008,7 +2007,7 @@ rl_resume(device_t dev) } /* reinitialize interface if necessary */ - if (ifp->if_flags & IFF_UP) + if (if_getflags(ifp) & IFF_UP) rl_init_locked(sc); sc->suspended = 0; @@ -2036,7 +2035,7 @@ rl_shutdown(device_t dev) * interrupt comes in later on, which can happen in some * cases. */ - sc->rl_ifp->if_flags &= ~IFF_UP; + if_setflagbits(sc->rl_ifp, 0, IFF_UP); rl_setwol(sc); RL_UNLOCK(sc); @@ -2046,7 +2045,7 @@ rl_shutdown(device_t dev) static void rl_setwol(struct rl_softc *sc) { - struct ifnet *ifp; + if_t ifp; int pmc; uint16_t pmstat; uint8_t v; @@ -2054,7 +2053,7 @@ rl_setwol(struct rl_softc *sc) RL_LOCK_ASSERT(sc); ifp = sc->rl_ifp; - if ((ifp->if_capabilities & IFCAP_WOL) == 0) + if ((if_getcapabilities(ifp) & IFCAP_WOL) == 0) return; if (pci_find_cap(sc->rl_dev, PCIY_PMG, &pmc) != 0) return; @@ -2065,24 +2064,24 @@ rl_setwol(struct rl_softc *sc) /* Enable PME. */ v = CSR_READ_1(sc, sc->rl_cfg1); v &= ~RL_CFG1_PME; - if ((ifp->if_capenable & IFCAP_WOL) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) v |= RL_CFG1_PME; CSR_WRITE_1(sc, sc->rl_cfg1, v); v = CSR_READ_1(sc, sc->rl_cfg3); v &= ~(RL_CFG3_WOL_LINK | RL_CFG3_WOL_MAGIC); - if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0) v |= RL_CFG3_WOL_MAGIC; CSR_WRITE_1(sc, sc->rl_cfg3, v); v = CSR_READ_1(sc, sc->rl_cfg5); v &= ~(RL_CFG5_WOL_BCAST | RL_CFG5_WOL_MCAST | RL_CFG5_WOL_UCAST); v &= ~RL_CFG5_WOL_LANWAKE; - if ((ifp->if_capenable & IFCAP_WOL_UCAST) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL_UCAST) != 0) v |= RL_CFG5_WOL_UCAST; - if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) != 0) v |= RL_CFG5_WOL_MCAST | RL_CFG5_WOL_BCAST; - if ((ifp->if_capenable & IFCAP_WOL) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) v |= RL_CFG5_WOL_LANWAKE; CSR_WRITE_1(sc, sc->rl_cfg5, v); @@ -2092,7 +2091,7 @@ rl_setwol(struct rl_softc *sc) /* Request PME if WOL is requested. */ pmstat = pci_read_config(sc->rl_dev, pmc + PCIR_POWER_STATUS, 2); pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); - if ((ifp->if_capenable & IFCAP_WOL) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; pci_write_config(sc->rl_dev, pmc + PCIR_POWER_STATUS, pmstat, 2); } @@ -2100,11 +2099,11 @@ rl_setwol(struct rl_softc *sc) static void rl_clrwol(struct rl_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint8_t v; ifp = sc->rl_ifp; - if ((ifp->if_capabilities & IFCAP_WOL) == 0) + if ((if_getcapabilities(ifp) & IFCAP_WOL) == 0) return; /* Enable config register write. */ diff --git a/sys/dev/rl/if_rlreg.h b/sys/dev/rl/if_rlreg.h index 8bb8822d0a7d..71db25e765ee 100644 --- a/sys/dev/rl/if_rlreg.h +++ b/sys/dev/rl/if_rlreg.h @@ -863,7 +863,7 @@ struct rl_list_data { enum rl_twist { DONE, CHK_LINK, FIND_ROW, SET_PARAM, RECHK_LONG, RETUNE }; struct rl_softc { - struct ifnet *rl_ifp; /* interface info */ + if_t rl_ifp; /* interface info */ bus_space_handle_t rl_bhandle; /* bus space handle */ bus_space_tag_t rl_btag; /* bus space tag */ device_t rl_dev;