From nobody Tue Jan 31 21:53:56 2023 X-Original-To: dev-commits-src-main@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 4P5zMm2CSFz3cPtS; Tue, 31 Jan 2023 21:53:56 +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 4P5zMm1kGVz3msH; Tue, 31 Jan 2023 21:53:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675202036; 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=CopJjF9DebWClMhEOKIQEJjAVFhzUWdG4QsFwvgYBIw=; b=EAP/SZsmkaD8bkkE01D02uVCu9GmR4HkX8dNTTT1yR5TkHR/K2g1+dK43QBAaNQ9LZDqSZ MqddBvtZxwxDx9u/8hB/qkmc2mM6qZI12OVzVOa5IVGs5Dhwwoj99yEXmL59g+ptqpX0mP h/Un+YqZk2EZ12wXfFEnYGhCouP9nu5heM5S1wrdMtJeU/hie3w8MJXFH/Hi6x3DlOZsqI fuqGp9qp6A3fhtnQ25j23o36GjB3XqzeryyzOCRJZBPRziVbxs9e8jmdm2AqYDS5c8+99s quhQIRkD01ojkyR0nU6Q4kLV6GY1ojSzohJzi1QGE3qkjNL8Ndx7mN06TlabWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675202036; 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=CopJjF9DebWClMhEOKIQEJjAVFhzUWdG4QsFwvgYBIw=; b=H5bJteovihZn2LIGiKeqSuQECZNyktqXmp/VTUib+VqNQ/0CJ+Q7Zcdjkmf84TaK0hGG04 U7K5vVftxmGlrZfGF9g4PynoRpXo/q/94b/Ms2xJpadKAwtD+/C73RcqwTRctfa5qsynyX 2FGSe/cuxs9cR+seWJaU+J88nzPHC5YQBafN/LcJAuaWblFCNxB2CnDNZFEvaUGc27S7VM PTfyCcU6b9kCklOP6KahrgqbUp5mSehTLCAUOlZr2qfuVHNfYIVjt+l3wg/53IR3l0xH5g W3TEfbelkz4rw4Fes3JW06rk2wjDDXueIzv+cyy5jmno84M8wJZWN4bRSLR5Rw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675202036; a=rsa-sha256; cv=none; b=Xwwq3j9/iq+JAuPQmNGk6K2vnAcqhK3ENedZLrp6XXrQFyvHsGwoojo/bdwLhmyENH41bB guloegR3V+U3dCF9S7JMV7DXMQs30k/m5wCf4hbQC/9oEhrH8R2J+9VJNVWpYxWnVTGWe4 gA1Eisa68trL2ulBH4j2eQhgsg/o00unEEOWXBpt8Yv4kK2TlsQ6yYHM/VL1ovdG1Vlf7Q wWUR2YSo0nWrXn1X1ARok3ufjPCkHnzqIoLqimvovvSH47ca3i7QrT4stkZivtii/na9jv qpVhj0NvoExUXB0SCo4nSvbRlNEpPgq2zkTbYLifNqwxzpUxGglCvALV4oMQBA== 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 4P5zMm0lgrz14TT; Tue, 31 Jan 2023 21:53:56 +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 30VLruBh080878; Tue, 31 Jan 2023 21:53:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30VLruXL080877; Tue, 31 Jan 2023 21:53:56 GMT (envelope-from git) Date: Tue, 31 Jan 2023 21:53:56 GMT Message-Id: <202301312153.30VLruXL080877@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: dc57ec3ca0fb - main - Mechanically convert ffec(4) to IfAPI List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: dc57ec3ca0fbd11d351a4ca1e305a29dd1dc74f5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=dc57ec3ca0fbd11d351a4ca1e305a29dd1dc74f5 commit dc57ec3ca0fbd11d351a4ca1e305a29dd1dc74f5 Author: Justin Hibbits AuthorDate: 2022-08-19 16:07:08 +0000 Commit: Justin Hibbits CommitDate: 2023-01-31 21:26:36 +0000 Mechanically convert ffec(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37836 --- sys/dev/ffec/if_ffec.c | 101 ++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/sys/dev/ffec/if_ffec.c b/sys/dev/ffec/if_ffec.c index f98e408265fd..b6c5df376c46 100644 --- a/sys/dev/ffec/if_ffec.c +++ b/sys/dev/ffec/if_ffec.c @@ -152,7 +152,7 @@ struct ffec_softc { device_t dev; device_t miibus; struct mii_data * mii_softc; - struct ifnet *ifp; + if_t ifp; int if_flags; struct mtx mtx; struct resource *irq_res[MAX_IRQ_COUNT]; @@ -441,13 +441,13 @@ ffec_miibus_statchg(device_t dev) } static void -ffec_media_status(struct ifnet * ifp, struct ifmediareq *ifmr) +ffec_media_status(if_t ifp, struct ifmediareq *ifmr) { struct ffec_softc *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); mii = sc->mii_softc; FFEC_LOCK(sc); mii_pollstat(mii); @@ -464,12 +464,12 @@ ffec_media_change_locked(struct ffec_softc *sc) } static int -ffec_media_change(struct ifnet * ifp) +ffec_media_change(if_t ifp) { struct ffec_softc *sc; int error; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); FFEC_LOCK(sc); error = ffec_media_change_locked(sc); @@ -519,7 +519,7 @@ static void ffec_clear_stats(struct ffec_softc *sc) static void ffec_harvest_stats(struct ffec_softc *sc) { - struct ifnet *ifp; + if_t ifp; ifp = sc->ifp; @@ -553,7 +553,7 @@ static void ffec_tick(void *arg) { struct ffec_softc *sc; - struct ifnet *ifp; + if_t ifp; int link_was_up; sc = arg; @@ -562,7 +562,7 @@ ffec_tick(void *arg) ifp = sc->ifp; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) return; /* @@ -649,7 +649,7 @@ ffec_setup_txbuf(struct ffec_softc *sc, int idx, struct mbuf **mp) static void ffec_txstart_locked(struct ffec_softc *sc) { - struct ifnet *ifp; + if_t ifp; struct mbuf *m; int enqueued; @@ -660,21 +660,21 @@ ffec_txstart_locked(struct ffec_softc *sc) ifp = sc->ifp; - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) return; enqueued = 0; for (;;) { if (sc->txcount == (TX_DESC_COUNT-1)) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); break; } - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); if (m == NULL) break; if (ffec_setup_txbuf(sc, sc->tx_idx_head, &m) != 0) { - IFQ_DRV_PREPEND(&ifp->if_snd, m); + if_sendq_prepend(ifp, m); break; } BPF_MTAP(ifp, m); @@ -691,9 +691,9 @@ ffec_txstart_locked(struct ffec_softc *sc) } static void -ffec_txstart(struct ifnet *ifp) +ffec_txstart(if_t ifp) { - struct ffec_softc *sc = ifp->if_softc; + struct ffec_softc *sc = if_getsoftc(ifp); FFEC_LOCK(sc); ffec_txstart_locked(sc); @@ -703,7 +703,7 @@ ffec_txstart(struct ifnet *ifp) static void ffec_txfinish_locked(struct ffec_softc *sc) { - struct ifnet *ifp; + if_t ifp; struct ffec_hwdesc *desc; struct ffec_bufmap *bmap; boolean_t retired_buffer; @@ -735,7 +735,7 @@ ffec_txfinish_locked(struct ffec_softc *sc) * the descriptor ring, go try to start some new output. */ if (retired_buffer) { - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); ffec_txstart_locked(sc); } @@ -858,7 +858,7 @@ ffec_rxfinish_onebuf(struct ffec_softc *sc, int len) bcopy(src, dst, len); m->m_data = dst; } - sc->ifp->if_input(sc->ifp, m); + if_input(sc->ifp, m); FFEC_LOCK(sc); @@ -991,7 +991,7 @@ ffec_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) static void ffec_setup_rxfilter(struct ffec_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint8_t *eaddr; uint64_t ghash, ihash; @@ -1002,7 +1002,7 @@ ffec_setup_rxfilter(struct ffec_softc *sc) /* * Set the multicast (group) filter hash. */ - if ((ifp->if_flags & IFF_ALLMULTI)) + if ((if_getflags(ifp) & IFF_ALLMULTI)) ghash = 0xffffffffffffffffLLU; else { ghash = 0; @@ -1018,7 +1018,7 @@ ffec_setup_rxfilter(struct ffec_softc *sc) * seems to support the concept of MAC address aliases, does such a * thing even exist? */ - if ((ifp->if_flags & IFF_PROMISC)) + if ((if_getflags(ifp) & IFF_PROMISC)) ihash = 0xffffffffffffffffLLU; else { ihash = 0; @@ -1029,7 +1029,7 @@ ffec_setup_rxfilter(struct ffec_softc *sc) /* * Set the primary address. */ - eaddr = IF_LLADDR(ifp); + eaddr = if_getlladdr(ifp); WR4(sc, FEC_PALR_REG, (eaddr[0] << 24) | (eaddr[1] << 16) | (eaddr[2] << 8) | eaddr[3]); WR4(sc, FEC_PAUR_REG, (eaddr[4] << 24) | (eaddr[5] << 16)); @@ -1038,7 +1038,7 @@ ffec_setup_rxfilter(struct ffec_softc *sc) static void ffec_stop_locked(struct ffec_softc *sc) { - struct ifnet *ifp; + if_t ifp; struct ffec_hwdesc *desc; struct ffec_bufmap *bmap; int idx; @@ -1046,7 +1046,7 @@ ffec_stop_locked(struct ffec_softc *sc) FFEC_ASSERT_LOCKED(sc); ifp = sc->ifp; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); sc->tx_watchdog_count = 0; /* @@ -1101,7 +1101,7 @@ ffec_stop_locked(struct ffec_softc *sc) static void ffec_init_locked(struct ffec_softc *sc) { - struct ifnet *ifp = sc->ifp; + if_t ifp = sc->ifp; uint32_t maxbuf, maxfl, regval; FFEC_ASSERT_LOCKED(sc); @@ -1126,7 +1126,7 @@ ffec_init_locked(struct ffec_softc *sc) maxbuf = MCLBYTES - roundup(ETHER_ALIGN, sc->rxbuf_align); maxfl = min(maxbuf, 0x7ff); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) return; /* Mask all interrupts and clear all current interrupt status bits. */ @@ -1257,7 +1257,7 @@ ffec_init_locked(struct ffec_softc *sc) regval |= FEC_ECR_ETHEREN; WR4(sc, FEC_ECR_REG, regval); - ifp->if_drv_flags |= IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); /* * Call mii_mediachg() which will call back into ffec_miibus_statchg() to @@ -1326,23 +1326,23 @@ ffec_intr(void *arg) } static int -ffec_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +ffec_ioctl(if_t ifp, u_long cmd, caddr_t data) { struct ffec_softc *sc; struct mii_data *mii; struct ifreq *ifr; int mask, error; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); ifr = (struct ifreq *)data; error = 0; switch (cmd) { case SIOCSIFFLAGS: FFEC_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - if ((ifp->if_flags ^ sc->if_flags) & + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { + if ((if_getflags(ifp) ^ sc->if_flags) & (IFF_PROMISC | IFF_ALLMULTI)) ffec_setup_rxfilter(sc); } else { @@ -1350,16 +1350,16 @@ ffec_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ffec_init_locked(sc); } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) ffec_stop_locked(sc); } - sc->if_flags = ifp->if_flags; + sc->if_flags = if_getflags(ifp); FFEC_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { FFEC_LOCK(sc); ffec_setup_rxfilter(sc); FFEC_UNLOCK(sc); @@ -1373,10 +1373,10 @@ ffec_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCSIFCAP: - mask = ifp->if_capenable ^ ifr->ifr_reqcap; + mask = if_getcapenable(ifp) ^ ifr->ifr_reqcap; if (mask & IFCAP_VLAN_MTU) { /* No work to do except acknowledge the change took. */ - ifp->if_capenable ^= IFCAP_VLAN_MTU; + if_togglecapenable(ifp, IFCAP_VLAN_MTU); } break; @@ -1468,7 +1468,7 @@ static int ffec_attach(device_t dev) { struct ffec_softc *sc; - struct ifnet *ifp = NULL; + if_t ifp = NULL; struct mbuf *m; void *dummy; uintptr_t typeflags; @@ -1739,22 +1739,21 @@ ffec_attach(device_t dev) /* Set up the ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); - 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_capabilities = IFCAP_VLAN_MTU; - ifp->if_capenable = ifp->if_capabilities; - ifp->if_start = ffec_txstart; - ifp->if_ioctl = ffec_ioctl; - ifp->if_init = ffec_init; - IFQ_SET_MAXLEN(&ifp->if_snd, TX_DESC_COUNT - 1); - ifp->if_snd.ifq_drv_maxlen = TX_DESC_COUNT - 1; - IFQ_SET_READY(&ifp->if_snd); - ifp->if_hdrlen = sizeof(struct ether_vlan_header); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setcapabilities(ifp, IFCAP_VLAN_MTU); + if_setcapenable(ifp, if_getcapabilities(ifp)); + if_setstartfn(ifp, ffec_txstart); + if_setioctlfn(ifp, ffec_ioctl); + if_setinitfn(ifp, ffec_init); + if_setsendqlen(ifp, TX_DESC_COUNT - 1); + if_setsendqready(ifp); + if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); #if 0 /* XXX The hardware keeps stats we could use for these. */ - ifp->if_linkmib = &sc->mibdata; - ifp->if_linkmiblen = sizeof(sc->mibdata); + if_setlinkmib(ifp, &sc->mibdata); + if_setlinkmiblen(ifp, sizeof(sc->mibdata)); #endif /* Set up the miigasket hardware (if any). */