git: df40efe17afb - main - Mechanically convert le(4) to IfAPI
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Feb 2023 17:54:17 UTC
The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=df40efe17afb82398621cc31b907432bb6668bce commit df40efe17afb82398621cc31b907432bb6668bce Author: Justin Hibbits <jhibbits@FreeBSD.org> AuthorDate: 2022-08-19 16:00:48 +0000 Commit: Justin Hibbits <jhibbits@FreeBSD.org> CommitDate: 2023-02-06 17:32:11 +0000 Mechanically convert le(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37831 --- sys/dev/le/am7990.c | 32 ++++++++--------- sys/dev/le/am79900.c | 32 ++++++++--------- sys/dev/le/lance.c | 99 +++++++++++++++++++++++++-------------------------- sys/dev/le/lancevar.h | 2 +- 4 files changed, 82 insertions(+), 83 deletions(-) diff --git a/sys/dev/le/am7990.c b/sys/dev/le/am7990.c index 66dce0e6ac1d..b3d81cf01420 100644 --- a/sys/dev/le/am7990.c +++ b/sys/dev/le/am7990.c @@ -147,7 +147,7 @@ am7990_detach(struct am7990_softc *sc) static void am7990_meminit(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct leinit init; struct lermd rmd; struct letmd tmd; @@ -156,7 +156,7 @@ am7990_meminit(struct lance_softc *sc) LE_LOCK_ASSERT(sc, MA_OWNED); - if (ifp->if_flags & IFF_PROMISC) + if (if_getflags(ifp) & IFF_PROMISC) init.init_mode = LE_MODE_NORMAL | LE_MODE_PROM; else init.init_mode = LE_MODE_NORMAL; @@ -211,7 +211,7 @@ am7990_meminit(struct lance_softc *sc) static void am7990_rint(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct mbuf *m; struct lermd rmd; int bix, rp; @@ -295,7 +295,7 @@ am7990_rint(struct lance_softc *sc) /* Pass the packet up. */ LE_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); LE_LOCK(sc); } else if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); @@ -307,7 +307,7 @@ am7990_rint(struct lance_softc *sc) static void am7990_tint(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct letmd tmd; int bix; @@ -332,7 +332,7 @@ am7990_tint(struct lance_softc *sc) if (tmd.tmd1_bits & LE_T1_OWN) break; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if (tmd.tmd1_bits & LE_T1_ERR) { if (tmd.tmd3 & LE_T3_BUFF) @@ -390,7 +390,7 @@ void am7990_intr(void *arg) { struct lance_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; uint16_t isr; LE_LOCK(sc); @@ -480,7 +480,7 @@ am7990_intr(void *arg) /* Enable interrupts again. */ (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA); - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) am7990_start_locked(sc); LE_UNLOCK(sc); @@ -494,14 +494,14 @@ am7990_intr(void *arg) static void am7990_start_locked(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct letmd tmd; struct mbuf *m; int bix, enq, len, rp; LE_LOCK_ASSERT(sc, MA_OWNED); - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return; @@ -509,18 +509,18 @@ am7990_start_locked(struct lance_softc *sc) enq = 0; for (; sc->sc_no_td < sc->sc_ntbuf && - !IFQ_DRV_IS_EMPTY(&ifp->if_snd);) { + !if_sendq_empty(ifp);) { rp = LE_TMDADDR(sc, bix); (*sc->sc_copyfromdesc)(sc, &tmd, rp, sizeof(tmd)); if (tmd.tmd1_bits & LE_T1_OWN) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); if_printf(ifp, "missing buffer, no_td = %d, last_td = %d\n", sc->sc_no_td, sc->sc_last_td); } - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); if (m == NULL) break; @@ -561,7 +561,7 @@ am7990_start_locked(struct lance_softc *sc) bix = 0; if (++sc->sc_no_td == sc->sc_ntbuf) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); break; } } @@ -576,7 +576,7 @@ am7990_start_locked(struct lance_softc *sc) static void am7990_recv_print(struct lance_softc *sc, int no) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct ether_header eh; struct lermd rmd; uint16_t len; @@ -599,7 +599,7 @@ am7990_recv_print(struct lance_softc *sc, int no) static void am7990_xmit_print(struct lance_softc *sc, int no) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct ether_header eh; struct letmd tmd; uint16_t len; diff --git a/sys/dev/le/am79900.c b/sys/dev/le/am79900.c index 316e12388ffd..a3b7a8245d05 100644 --- a/sys/dev/le/am79900.c +++ b/sys/dev/le/am79900.c @@ -185,7 +185,7 @@ am79900_detach(struct am79900_softc *sc) static void am79900_meminit(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct leinit init; struct lermd rmd; struct letmd tmd; @@ -194,7 +194,7 @@ am79900_meminit(struct lance_softc *sc) LE_LOCK_ASSERT(sc, MA_OWNED); - if (ifp->if_flags & IFF_PROMISC) + if (if_getflags(ifp) & IFF_PROMISC) init.init_mode = LE_HTOLE32(LE_MODE_NORMAL | LE_MODE_PROM); else init.init_mode = LE_HTOLE32(LE_MODE_NORMAL); @@ -251,7 +251,7 @@ am79900_meminit(struct lance_softc *sc) static inline void am79900_rint(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct mbuf *m; struct lermd rmd; uint32_t rmd1; @@ -332,7 +332,7 @@ am79900_rint(struct lance_softc *sc) /* Pass the packet up. */ LE_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); LE_LOCK(sc); } else if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); @@ -344,7 +344,7 @@ am79900_rint(struct lance_softc *sc) static inline void am79900_tint(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct letmd tmd; uint32_t tmd1, tmd2; int bix; @@ -370,7 +370,7 @@ am79900_tint(struct lance_softc *sc) if (tmd1 & LE_T1_OWN) break; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if (tmd1 & LE_T1_ERR) { tmd2 = LE_LE32TOH(tmd.tmd2); @@ -428,7 +428,7 @@ void am79900_intr(void *arg) { struct lance_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; uint16_t isr; LE_LOCK(sc); @@ -518,7 +518,7 @@ am79900_intr(void *arg) /* Enable interrupts again. */ (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA); - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) am79900_start_locked(sc); LE_UNLOCK(sc); @@ -532,14 +532,14 @@ am79900_intr(void *arg) static void am79900_start_locked(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct letmd tmd; struct mbuf *m; int bix, enq, len, rp; LE_LOCK_ASSERT(sc, MA_OWNED); - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return; @@ -547,18 +547,18 @@ am79900_start_locked(struct lance_softc *sc) enq = 0; for (; sc->sc_no_td < sc->sc_ntbuf && - !IFQ_DRV_IS_EMPTY(&ifp->if_snd);) { + !if_sendq_empty(ifp);) { rp = LE_TMDADDR(sc, bix); (*sc->sc_copyfromdesc)(sc, &tmd, rp, sizeof(tmd)); if (LE_LE32TOH(tmd.tmd1) & LE_T1_OWN) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); if_printf(ifp, "missing buffer, no_td = %d, last_td = %d\n", sc->sc_no_td, sc->sc_last_td); } - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); if (m == NULL) break; @@ -600,7 +600,7 @@ am79900_start_locked(struct lance_softc *sc) bix = 0; if (++sc->sc_no_td == sc->sc_ntbuf) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); break; } } @@ -615,7 +615,7 @@ am79900_start_locked(struct lance_softc *sc) static void am79900_recv_print(struct lance_softc *sc, int no) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct ether_header eh; struct lermd rmd; uint16_t len; @@ -637,7 +637,7 @@ am79900_recv_print(struct lance_softc *sc, int no) static void am79900_xmit_print(struct lance_softc *sc, int no) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct ether_header eh; struct letmd tmd; uint16_t len; diff --git a/sys/dev/le/lance.c b/sys/dev/le/lance.c index 65504bd8142a..050fcfe36184 100644 --- a/sys/dev/le/lance.c +++ b/sys/dev/le/lance.c @@ -94,18 +94,18 @@ __FBSDID("$FreeBSD$"); #include <dev/le/lancereg.h> #include <dev/le/lancevar.h> -static void lance_start(struct ifnet *); +static void lance_start(if_t); static void lance_stop(struct lance_softc *); static void lance_init(void *); static void lance_watchdog(void *s); -static int lance_mediachange(struct ifnet *); -static void lance_mediastatus(struct ifnet *, struct ifmediareq *); -static int lance_ioctl(struct ifnet *, u_long, caddr_t); +static int lance_mediachange(if_t); +static void lance_mediastatus(if_t, struct ifmediareq *); +static int lance_ioctl(if_t, u_long, caddr_t); int lance_config(struct lance_softc *sc, const char* name, int unit) { - struct ifnet *ifp; + if_t ifp; int i, nbuf; if (LE_LOCK_INITIALIZED(sc) == 0) @@ -118,19 +118,18 @@ lance_config(struct lance_softc *sc, const char* name, int unit) callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0); /* Initialize ifnet structure. */ - ifp->if_softc = sc; + if_setsoftc(ifp, sc); if_initname(ifp, name, unit); - ifp->if_start = lance_start; - ifp->if_ioctl = lance_ioctl; - ifp->if_init = lance_init; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + if_setstartfn(ifp, lance_start); + if_setioctlfn(ifp, lance_ioctl); + if_setinitfn(ifp, lance_init); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); #ifdef LANCE_REVC_BUG - ifp->if_flags &= ~IFF_MULTICAST; + if_setflagsbit(ifp, 0, IFF_MULTICAST); #endif - ifp->if_baudrate = IF_Mbps(10); - IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); - ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; - IFQ_SET_READY(&ifp->if_snd); + if_setbaudrate(ifp, IF_Mbps(10)); + if_setsendqlen(ifp, ifqmaxlen); + if_setsendqready(ifp); /* Initialize ifmedia structures. */ ifmedia_init(&sc->sc_media, 0, lance_mediachange, lance_mediastatus); @@ -191,21 +190,21 @@ lance_config(struct lance_softc *sc, const char* name, int unit) void lance_attach(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; /* Attach the interface. */ ether_ifattach(ifp, sc->sc_enaddr); /* Claim 802.1q capability. */ - ifp->if_hdrlen = sizeof(struct ether_vlan_header); - ifp->if_capabilities |= IFCAP_VLAN_MTU; - ifp->if_capenable |= IFCAP_VLAN_MTU; + if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); + if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0); + if_setcapenablebit(ifp, IFCAP_VLAN_MTU, 0); } void lance_detach(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; LE_LOCK(sc); lance_stop(sc); @@ -229,15 +228,15 @@ lance_resume(struct lance_softc *sc) { LE_LOCK(sc); - if (sc->sc_ifp->if_flags & IFF_UP) + if (if_getflags(sc->sc_ifp) & IFF_UP) lance_init_locked(sc); LE_UNLOCK(sc); } static void -lance_start(struct ifnet *ifp) +lance_start(if_t ifp) { - struct lance_softc *sc = ifp->if_softc; + struct lance_softc *sc = if_getsoftc(ifp); LE_LOCK(sc); (*sc->sc_start_locked)(sc); @@ -247,14 +246,14 @@ lance_start(struct ifnet *ifp) static void lance_stop(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; LE_LOCK_ASSERT(sc, MA_OWNED); /* * Mark the interface down and cancel the watchdog timer. */ - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); callout_stop(&sc->sc_wdog_ch); sc->sc_wdog_timer = 0; @@ -278,7 +277,7 @@ lance_init(void *xsc) void lance_init_locked(struct lance_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; u_long a; int timo; @@ -302,7 +301,7 @@ lance_init_locked(struct lance_softc *sc) * Update our private copy of the Ethernet address. * We NEED the copy so we can ensure its alignment! */ - memcpy(sc->sc_enaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN); + memcpy(sc->sc_enaddr, if_getlladdr(ifp), ETHER_ADDR_LEN); /* Set up LANCE init block. */ (*sc->sc_meminit)(sc); @@ -324,8 +323,8 @@ lance_init_locked(struct lance_softc *sc) if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON) { /* Start the LANCE. */ (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA | LE_C0_STRT); - 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); sc->sc_wdog_timer = 0; callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc); (*sc->sc_start_locked)(sc); @@ -377,7 +376,7 @@ lance_put(struct lance_softc *sc, int boff, struct mbuf *m) struct mbuf * lance_get(struct lance_softc *sc, int boff, int totlen) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct mbuf *m, *m0, *newm; caddr_t newdata; int len; @@ -436,7 +435,7 @@ static void lance_watchdog(void *xsc) { struct lance_softc *sc = (struct lance_softc *)xsc; - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; LE_LOCK_ASSERT(sc, MA_OWNED); @@ -451,9 +450,9 @@ lance_watchdog(void *xsc) } static int -lance_mediachange(struct ifnet *ifp) +lance_mediachange(if_t ifp) { - struct lance_softc *sc = ifp->if_softc; + struct lance_softc *sc = if_getsoftc(ifp); if (sc->sc_mediachange) { /* @@ -466,7 +465,7 @@ lance_mediachange(struct ifnet *ifp) LE_LOCK(sc); lance_stop(sc); lance_init_locked(sc); - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) (*sc->sc_start_locked)(sc); LE_UNLOCK(sc); } @@ -474,12 +473,12 @@ lance_mediachange(struct ifnet *ifp) } static void -lance_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) +lance_mediastatus(if_t ifp, struct ifmediareq *ifmr) { - struct lance_softc *sc = ifp->if_softc; + struct lance_softc *sc = if_getsoftc(ifp); LE_LOCK(sc); - if (!(ifp->if_flags & IFF_UP)) { + if (!(if_getflags(ifp) & IFF_UP)) { LE_UNLOCK(sc); return; } @@ -497,16 +496,16 @@ lance_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) * Process an ioctl request. */ static int -lance_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +lance_ioctl(if_t ifp, u_long cmd, caddr_t data) { - struct lance_softc *sc = ifp->if_softc; + struct lance_softc *sc = if_getsoftc(ifp); struct ifreq *ifr = (struct ifreq *)data; int error = 0; switch (cmd) { case SIOCSIFFLAGS: LE_LOCK(sc); - if (ifp->if_flags & IFF_PROMISC) { + if (if_getflags(ifp) & IFF_PROMISC) { if (!(sc->sc_flags & LE_PROMISC)) { sc->sc_flags |= LE_PROMISC; lance_init_locked(sc); @@ -516,25 +515,25 @@ lance_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) lance_init_locked(sc); } - if ((ifp->if_flags & IFF_ALLMULTI) && + if ((if_getflags(ifp) & IFF_ALLMULTI) && !(sc->sc_flags & LE_ALLMULTI)) { sc->sc_flags |= LE_ALLMULTI; lance_init_locked(sc); - } else if (!(ifp->if_flags & IFF_ALLMULTI) && + } else if (!(if_getflags(ifp) & IFF_ALLMULTI) && (sc->sc_flags & LE_ALLMULTI)) { sc->sc_flags &= ~LE_ALLMULTI; lance_init_locked(sc); } - if (!(ifp->if_flags & IFF_UP) && - ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (!(if_getflags(ifp) & IFF_UP) && + if_getdrvflags(ifp) & IFF_DRV_RUNNING) { /* * If interface is marked down and it is running, then * stop it. */ lance_stop(sc); - } else if (ifp->if_flags & IFF_UP && - !(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + } else if (if_getflags(ifp) & IFF_UP && + !(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { /* * If interface is marked up and it is stopped, then * start it. @@ -542,7 +541,7 @@ lance_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) lance_init_locked(sc); } #ifdef LEDEBUG - if (ifp->if_flags & IFF_DEBUG) + if (if_getflags(ifp) & IFF_DEBUG) sc->sc_flags |= LE_DEBUG; else sc->sc_flags &= ~LE_DEBUG; @@ -557,7 +556,7 @@ lance_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * accordingly. */ LE_LOCK(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) lance_init_locked(sc); LE_UNLOCK(sc); break; @@ -602,7 +601,7 @@ lance_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) void lance_setladrf(struct lance_softc *sc, uint16_t *af) { - struct ifnet *ifp = sc->sc_ifp; + if_t ifp = sc->sc_ifp; struct lance_hash_maddr_ctx ctx = { sc, af }; /* @@ -613,7 +612,7 @@ lance_setladrf(struct lance_softc *sc, uint16_t *af) * the word. */ - if (ifp->if_flags & IFF_PROMISC || sc->sc_flags & LE_ALLMULTI) { + if (if_getflags(ifp) & IFF_PROMISC || sc->sc_flags & LE_ALLMULTI) { af[0] = af[1] = af[2] = af[3] = 0xffff; return; } diff --git a/sys/dev/le/lancevar.h b/sys/dev/le/lancevar.h index 092f78668e0a..87b5f3c748f9 100644 --- a/sys/dev/le/lancevar.h +++ b/sys/dev/le/lancevar.h @@ -38,7 +38,7 @@ #define _DEV_LE_LANCEVAR_H_ struct lance_softc { - struct ifnet *sc_ifp; + if_t sc_ifp; struct ifmedia sc_media; struct mtx sc_mtx; struct callout sc_wdog_ch;