From nobody Tue Jan 24 20:48:13 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1fFB2JbJz3bSnq; Tue, 24 Jan 2023 20:48:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1fFB0yjtz41fT; Tue, 24 Jan 2023 20:48:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674593294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5ysJmqWKrMdbuzTU7oqbS8UEKFFHL0fnatOx5T3KDoA=; b=NMtFKv3UyNfY1XWYo4A2115uOUyYj7lzQI2sm68Muhbsezsorloxv+GjcK3CpU3woNmVwb zQFMyQZuV+fRli7Hehi9eynVGRHYO/AVsN/01NDI+QIGasB4lyUD+N97pZ3ufUDRmgM2yV rrA8BHpm1hbmatwHshx7xGD39dAhai+h94MCTEWTlhrtHZTHbg7S/8SEbX8ecWrZLEB1bp U2W1NVCykRhiLSKAEjCx6xtlylex98wByMWY6BgK2EzzbJEaHJsM/6K4UidIYOBKdmbYDh bHjHWzj73HRiG6dRg0llSIUcDXDAChBzYQMKplizrq6D6rbdgzJ06VVf7RxQbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674593294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5ysJmqWKrMdbuzTU7oqbS8UEKFFHL0fnatOx5T3KDoA=; b=OHfQezW1v07padCyNBSxd7mjX9PACTqDrA406JLf083zfFVO0noIBJ4k62TdxWQxIixUyK +0v7F4vL0PHN1tgINsaI47xp/qnJuxyeACwhpESJey9utQx0X1d9lvg/yr7KvcSHLE5Aif xlur8thkxyUysjskNCVl2YiCeQ5NjIWqn7WHftbi8mhgRwSNg6aOiEGm43+5DYa76X/5Pm OR3AneND7f+2KLCtGO10GQ8vfuyrAE/ycTTjTl0L3hRjldPY9+c7h2ItYBoHtMXdDaSm4d OLMFqhmi9JAWBH/AFlKNibmnhbYxdmG8N8cBMCysdWYU+diUIGydxvf7f9MRsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674593294; a=rsa-sha256; cv=none; b=sJcJd6DCKheHtUKQ9J1G0rmrFQXFzdEk0zwWNb2R+k0IB7MsR71TZ0NG570Pbc70NQSpZq eRKqnWx8cPEfg1Zenh5eQYfXoF2CNqp3X6kQZGFOSVOEa2jeLjCxxmRzlzz6OnLOHxVRK8 nmzHZj0TrsHpB/Dj2jaDmQ03yd1jBKUWw/gVaeO1n2cK93bFUXbD1Qda2sWonXtZBi5ZYa SdqsPeUQ+WPigprpmAkb6a39O7gfDM5FIuIyW27H6EYyMT/J9K7sUdoBVUiItd7wVNHez3 ePhQ2BqvSGb9xHiYqhcCtZYcopAOsGm1o6ZOz37HfHoMLTRfXNoOj7yDwLInrw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P1fF971y2zN8C; Tue, 24 Jan 2023 20:48:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30OKmDlm053658; Tue, 24 Jan 2023 20:48:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OKmDLZ053657; Tue, 24 Jan 2023 20:48:13 GMT (envelope-from git) Date: Tue, 24 Jan 2023 20:48:13 GMT Message-Id: <202301242048.30OKmDLZ053657@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: c2a4666cd319 - main - Mechanically convert if_emac(4) to IfAPI List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c2a4666cd3199e38e6c3afa60e2e983d810e4542 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=c2a4666cd3199e38e6c3afa60e2e983d810e4542 commit c2a4666cd3199e38e6c3afa60e2e983d810e4542 Author: Justin Hibbits AuthorDate: 2022-02-25 17:58:14 +0000 Commit: Justin Hibbits CommitDate: 2023-01-24 19:35:33 +0000 Mechanically convert if_emac(4) to IfAPI Reviewed by: manu Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37788 --- sys/arm/allwinner/if_emac.c | 126 ++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index 8f2bd7222a6a..3db0c6e95bc0 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -89,7 +89,7 @@ __FBSDID("$FreeBSD$"); #include "a10_sramc.h" struct emac_softc { - struct ifnet *emac_ifp; + if_t emac_ifp; device_t emac_dev; device_t emac_miibus; bus_space_handle_t emac_handle; @@ -118,11 +118,11 @@ static int emac_sys_setup(struct emac_softc *); static void emac_reset(struct emac_softc *); static void emac_init_locked(struct emac_softc *); -static void emac_start_locked(struct ifnet *); +static void emac_start_locked(if_t); static void emac_init(void *); static void emac_stop_locked(struct emac_softc *); static void emac_intr(void *); -static int emac_ioctl(struct ifnet *, u_long, caddr_t); +static int emac_ioctl(if_t, u_long, caddr_t); static void emac_rxeof(struct emac_softc *, int); static void emac_txeof(struct emac_softc *, uint32_t); @@ -131,8 +131,8 @@ static int emac_miibus_readreg(device_t, int, int); static int emac_miibus_writereg(device_t, int, int, int); static void emac_miibus_statchg(device_t); -static int emac_ifmedia_upd(struct ifnet *); -static void emac_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int emac_ifmedia_upd(if_t); +static void emac_ifmedia_sts(if_t, struct ifmediareq *); static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); static int sysctl_hw_emac_proc_limit(SYSCTL_HANDLER_ARGS); @@ -232,7 +232,7 @@ emac_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) static void emac_set_rx_mode(struct emac_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t hashes[2]; uint32_t rcr = 0; @@ -248,7 +248,7 @@ emac_set_rx_mode(struct emac_softc *sc) hashes[0] = 0; hashes[1] = 0; - if (ifp->if_flags & IFF_ALLMULTI) { + if (if_getflags(ifp) & IFF_ALLMULTI) { hashes[0] = 0xffffffff; hashes[1] = 0xffffffff; } else @@ -258,12 +258,12 @@ emac_set_rx_mode(struct emac_softc *sc) EMAC_WRITE_REG(sc, EMAC_RX_HASH0, hashes[0]); EMAC_WRITE_REG(sc, EMAC_RX_HASH1, hashes[1]); - if (ifp->if_flags & IFF_BROADCAST) { + if (if_getflags(ifp) & IFF_BROADCAST) { rcr |= EMAC_RX_BCO; rcr |= EMAC_RX_MCO; } - if (ifp->if_flags & IFF_PROMISC) + if (if_getflags(ifp) & IFF_PROMISC) rcr |= EMAC_RX_PA; else rcr |= EMAC_RX_UCAD; @@ -292,7 +292,7 @@ emac_drain_rxfifo(struct emac_softc *sc) static void emac_txeof(struct emac_softc *sc, uint32_t status) { - struct ifnet *ifp; + if_t ifp; EMAC_ASSERT_LOCKED(sc); @@ -303,7 +303,7 @@ emac_txeof(struct emac_softc *sc, uint32_t status) if_inc_counter(ifp, IFCOUNTER_OPACKETS, 2); else if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); /* Unarm watchdog timer if no TX */ sc->emac_watchdog_timer = 0; @@ -312,7 +312,7 @@ emac_txeof(struct emac_softc *sc, uint32_t status) static void emac_rxeof(struct emac_softc *sc, int count) { - struct ifnet *ifp; + if_t ifp; struct mbuf *m, *m0; uint32_t reg_val, rxcount; int16_t len; @@ -321,7 +321,7 @@ emac_rxeof(struct emac_softc *sc, int count) ifp = sc->emac_ifp; for (; count > 0 && - (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; count--) { + (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0; count--) { /* * Race warning: The first packet might arrive with * the interrupts disabled, but the second will fix @@ -443,7 +443,7 @@ emac_rxeof(struct emac_softc *sc, int count) } if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); EMAC_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); EMAC_LOCK(sc); } } @@ -451,7 +451,7 @@ emac_rxeof(struct emac_softc *sc, int count) static void emac_watchdog(struct emac_softc *sc) { - struct ifnet *ifp; + if_t ifp; EMAC_ASSERT_LOCKED(sc); @@ -468,9 +468,9 @@ emac_watchdog(struct emac_softc *sc) if_printf(sc->emac_ifp, "watchdog timeout -- resetting\n"); if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); emac_init_locked(sc); - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) emac_start_locked(ifp); } @@ -502,7 +502,7 @@ emac_init(void *xcs) static void emac_init_locked(struct emac_softc *sc) { - struct ifnet *ifp; + if_t ifp; struct mii_data *mii; uint32_t reg_val; uint8_t *eaddr; @@ -510,7 +510,7 @@ emac_init_locked(struct emac_softc *sc) EMAC_ASSERT_LOCKED(sc); ifp = sc->emac_ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) return; /* Flush RX FIFO */ @@ -575,7 +575,7 @@ emac_init_locked(struct emac_softc *sc) EMAC_WRITE_REG(sc, EMAC_MAC_MAXF, EMAC_MAC_MFL); /* Setup ethernet address */ - eaddr = IF_LLADDR(ifp); + eaddr = if_getlladdr(ifp); EMAC_WRITE_REG(sc, EMAC_MAC_A1, eaddr[0] << 16 | eaddr[1] << 8 | eaddr[2]); EMAC_WRITE_REG(sc, EMAC_MAC_A0, eaddr[3] << 16 | @@ -589,8 +589,8 @@ emac_init_locked(struct emac_softc *sc) reg_val |= EMAC_INT_EN; EMAC_WRITE_REG(sc, EMAC_INT_CTL, reg_val); - 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->emac_link = 0; @@ -602,31 +602,31 @@ emac_init_locked(struct emac_softc *sc) } static void -emac_start(struct ifnet *ifp) +emac_start(if_t ifp) { struct emac_softc *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); EMAC_LOCK(sc); emac_start_locked(ifp); EMAC_UNLOCK(sc); } static void -emac_start_locked(struct ifnet *ifp) +emac_start_locked(if_t ifp) { struct emac_softc *sc; struct mbuf *m, *m0; uint32_t fifo, reg; - sc = ifp->if_softc; - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + sc = if_getsoftc(ifp); + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) return; if (sc->emac_fifo_mask == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1)) return; if (sc->emac_link == 0) return; - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); if (m == NULL) return; @@ -637,7 +637,7 @@ emac_start_locked(struct ifnet *ifp) fifo = 0; sc->emac_fifo_mask |= (1 << fifo); if (sc->emac_fifo_mask == (EMAC_TX_FIFO0 | EMAC_TX_FIFO1)) - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); EMAC_WRITE_REG(sc, EMAC_TX_INS, fifo); /* @@ -677,13 +677,13 @@ emac_start_locked(struct ifnet *ifp) static void emac_stop_locked(struct emac_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t reg_val; EMAC_ASSERT_LOCKED(sc); ifp = sc->emac_ifp; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); sc->emac_link = 0; /* Disable all interrupt and clear interrupt status */ @@ -703,7 +703,7 @@ static void emac_intr(void *arg) { struct emac_softc *sc; - struct ifnet *ifp; + if_t ifp; uint32_t reg_val; sc = (struct emac_softc *)arg; @@ -724,7 +724,7 @@ emac_intr(void *arg) if (reg_val & EMAC_INT_STA_TX) { emac_txeof(sc, reg_val); ifp = sc->emac_ifp; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) emac_start_locked(ifp); } @@ -736,37 +736,37 @@ emac_intr(void *arg) } static int -emac_ioctl(struct ifnet *ifp, u_long command, caddr_t data) +emac_ioctl(if_t ifp, u_long command, caddr_t data) { struct emac_softc *sc; struct mii_data *mii; struct ifreq *ifr; int error = 0; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); ifr = (struct ifreq *)data; switch (command) { case SIOCSIFFLAGS: EMAC_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - if ((ifp->if_flags ^ sc->emac_if_flags) & + if (if_getflags(ifp) & IFF_UP) { + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { + if ((if_getflags(ifp) ^ sc->emac_if_flags) & (IFF_PROMISC | IFF_ALLMULTI)) emac_set_rx_mode(sc); } else emac_init_locked(sc); } else { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) emac_stop_locked(sc); } - sc->emac_if_flags = ifp->if_flags; + sc->emac_if_flags = if_getflags(ifp); EMAC_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: EMAC_LOCK(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { emac_set_rx_mode(sc); } EMAC_UNLOCK(sc); @@ -803,7 +803,7 @@ emac_detach(device_t dev) struct emac_softc *sc; sc = device_get_softc(dev); - sc->emac_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(sc->emac_ifp, 0, IFF_DRV_RUNNING); if (device_is_attached(dev)) { ether_ifdetach(sc->emac_ifp); EMAC_LOCK(sc); @@ -850,13 +850,13 @@ static int emac_suspend(device_t dev) { struct emac_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); EMAC_LOCK(sc); ifp = sc->emac_ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) emac_stop_locked(sc); EMAC_UNLOCK(sc); @@ -867,14 +867,14 @@ static int emac_resume(device_t dev) { struct emac_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); EMAC_LOCK(sc); ifp = sc->emac_ifp; - if ((ifp->if_flags & IFF_UP) != 0) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if ((if_getflags(ifp) & IFF_UP) != 0) { + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); emac_init_locked(sc); } EMAC_UNLOCK(sc); @@ -886,7 +886,7 @@ static int emac_attach(device_t dev) { struct emac_softc *sc; - struct ifnet *ifp; + if_t ifp; int error, rid; uint8_t eaddr[ETHER_ADDR_LEN]; @@ -950,7 +950,7 @@ emac_attach(device_t dev) error = ENOSPC; goto fail; } - ifp->if_softc = sc; + if_setsoftc(ifp, sc); /* Setup MII */ error = mii_attach(dev, &sc->emac_miibus, ifp, emac_ifmedia_upd, @@ -961,21 +961,21 @@ emac_attach(device_t dev) } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_start = emac_start; - ifp->if_ioctl = emac_ioctl; - ifp->if_init = emac_init; - IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setstartfn(ifp, emac_start); + if_setioctlfn(ifp, emac_ioctl); + if_setinitfn(ifp, emac_init); + if_setsendqlen(ifp, IFQ_MAXLEN); /* Get MAC address */ emac_get_hwaddr(sc, eaddr); ether_ifattach(ifp, eaddr); /* VLAN capability setup. */ - ifp->if_capabilities |= IFCAP_VLAN_MTU; - ifp->if_capenable = ifp->if_capabilities; + if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0); + if_setcapenable(ifp, if_getcapabilities(ifp)); /* Tell the upper layer we support VLAN over-sized frames. */ - ifp->if_hdrlen = sizeof(struct ether_vlan_header); + if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); error = bus_setup_intr(dev, sc->emac_irq, INTR_TYPE_NET | INTR_MPSAFE, NULL, emac_intr, sc, &sc->emac_intrhand); @@ -1060,7 +1060,7 @@ emac_miibus_statchg(device_t dev) { struct emac_softc *sc; struct mii_data *mii; - struct ifnet *ifp; + if_t ifp; uint32_t reg_val; sc = device_get_softc(dev); @@ -1068,7 +1068,7 @@ emac_miibus_statchg(device_t dev) mii = device_get_softc(sc->emac_miibus); ifp = sc->emac_ifp; if (mii == NULL || ifp == NULL || - (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) return; sc->emac_link = 0; @@ -1107,14 +1107,14 @@ emac_miibus_statchg(device_t dev) } static int -emac_ifmedia_upd(struct ifnet *ifp) +emac_ifmedia_upd(if_t ifp) { struct emac_softc *sc; struct mii_data *mii; struct mii_softc *miisc; int error; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); mii = device_get_softc(sc->emac_miibus); EMAC_LOCK(sc); LIST_FOREACH(miisc, &mii->mii_phys, mii_list) @@ -1126,12 +1126,12 @@ emac_ifmedia_upd(struct ifnet *ifp) } static void -emac_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) +emac_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr) { struct emac_softc *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); mii = device_get_softc(sc->emac_miibus); EMAC_LOCK(sc);