From nobody Mon Feb 06 17:54:15 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 4P9YmR4C5cz3n0Jp; Mon, 6 Feb 2023 17:54:15 +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 4P9YmR35W7z4Y0s; Mon, 6 Feb 2023 17:54:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706055; 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=oM7UVOs35tgiZ3tYOrtEqLV76qGi7JY/iHj7HSVdneU=; b=tHSncFwI1YWF8wtjulGfcCDKvTzGMoFmeIxDUKj67ibJzg3mPIB9coJMU+19I6f/E0l1Gy jOvv4Js0wapFmat0L1HcUg1R+bewLx086A8VhraHreXkMjPznjTy2t/z4qT7s0C2DSt0o2 parqSBUMjdtoHGCut/KgXgpfXA78iO8k3cQBj2Vuc+/bsKKwNaKN1VQUc5Or2sQorHM0hS aRVFQz3y7oaXAf6Qx8QMfo7oJKTomwcYHwq+vqgFEc/bUy/axu009o6s+DgBBHXH1ly9+N tw8z/x82Hsw2UHq/YuHOC1f5zn0dcamqwJoyVz/fDyCqhZOOrpveCFmn9/It0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706055; 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=oM7UVOs35tgiZ3tYOrtEqLV76qGi7JY/iHj7HSVdneU=; b=XnNYvNcy2CaFhYut4C7vOmfEl8NMb6r7t0PqYRwmIZVz9j4F1WYPhTwo5VFPnkQbfvq88a cxMT+yqmK57+sYhJe4kyHbJpAZu9DAcJ/bqO/PjnuVpbz7aeiBHuJFDS0tdBvjceg/44U7 PvWUK0aY9kp7cb2AQd+VABKLpEXTBWOGj4OeNNU7UwyXdWDnHbUdmk1vGJJI2Yur7+9gWK cTdDvlRu0fBV7mpEwJdqtaqmHW9H/iBTE9nz4WH8RNeu8M7jnNhIkh+eMb43Dw5sOUZv9J 6et/WxiLCMRgywFdbnm95Nh2InYY6kYxQYlu7vHnS3NVfEt1vddVszqfkmrmBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675706055; a=rsa-sha256; cv=none; b=eh49Wf0qG1QQUnpbAk4UWPaymoo0KCnjvO2bOBvwFvF4zkx8FfkK2A7BJdPZGwOJ+vXvUw LFGhmH24jLg5oVDYwydAsqHHe4+EX4KsAXbKb3SQUyddH1On6MdVLR0SdrMIfqUdxJKuLX Cc8rLv2cw1sfmKeCq7gVzkloJS+b86EpYodg36NlEl+1wFOo4WIAhK3qDPz3CTCx7wlFS/ X3vZlYh95RoH7c0c5951oDvHHFdhX4odv9z3V97XwAJ3Gb1pyfCTXudMwjWlSsHSrH/Zsu v3LEbQLv8ROlPM9miB5k81OzOQaYsg3iAHvysB8XLJE6wwBdj1zm7je4OzIweA== 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 4P9YmR1lnVzkg5; Mon, 6 Feb 2023 17:54:15 +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 316HsFFt074662; Mon, 6 Feb 2023 17:54:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 316HsFJO074661; Mon, 6 Feb 2023 17:54:15 GMT (envelope-from git) Date: Mon, 6 Feb 2023 17:54:15 GMT Message-Id: <202302061754.316HsFJO074661@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: 8c259c504842 - main - Mechanically convert smc(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: 8c259c504842638d4e69e1ab25b922eab1b3ee42 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=8c259c504842638d4e69e1ab25b922eab1b3ee42 commit 8c259c504842638d4e69e1ab25b922eab1b3ee42 Author: Justin Hibbits AuthorDate: 2022-08-17 20:33:46 +0000 Commit: Justin Hibbits CommitDate: 2023-02-06 17:32:10 +0000 Mechanically convert smc(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37824 --- sys/dev/smc/if_smc.c | 122 ++++++++++++++++++++++++------------------------ sys/dev/smc/if_smcvar.h | 2 +- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/sys/dev/smc/if_smc.c b/sys/dev/smc/if_smc.c index d1ae02356de9..2705c9933311 100644 --- a/sys/dev/smc/if_smc.c +++ b/sys/dev/smc/if_smc.c @@ -104,15 +104,15 @@ static const char *smc_chip_ids[16] = { }; static void smc_init(void *); -static void smc_start(struct ifnet *); +static void smc_start(if_t); static void smc_stop(struct smc_softc *); -static int smc_ioctl(struct ifnet *, u_long, caddr_t); +static int smc_ioctl(if_t, u_long, caddr_t); static void smc_init_locked(struct smc_softc *); -static void smc_start_locked(struct ifnet *); +static void smc_start_locked(if_t); static void smc_reset(struct smc_softc *); -static int smc_mii_ifmedia_upd(struct ifnet *); -static void smc_mii_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int smc_mii_ifmedia_upd(if_t); +static void smc_mii_ifmedia_sts(if_t, struct ifmediareq *); static void smc_mii_tick(void *); static void smc_mii_mediachg(struct smc_softc *); static int smc_mii_mediaioctl(struct smc_softc *, struct ifreq *, u_long); @@ -307,7 +307,7 @@ smc_attach(device_t dev) uint16_t val; u_char eaddr[ETHER_ADDR_LEN]; struct smc_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); error = 0; @@ -377,18 +377,18 @@ smc_attach(device_t dev) eaddr[5] = smc_read_1(sc, IAR5); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_softc = sc; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_init = smc_init; - ifp->if_ioctl = smc_ioctl; - ifp->if_start = smc_start; - IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); - IFQ_SET_READY(&ifp->if_snd); + if_setsoftc(ifp, sc); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setinitfn(ifp, smc_init); + if_setioctlfn(ifp, smc_ioctl); + if_setstartfn(ifp, smc_start); + if_setsendqlen(ifp, ifqmaxlen); + if_setsendqready(ifp); - ifp->if_capabilities = ifp->if_capenable = 0; + if_setcapabilities(ifp, if_getcapenable(ifp) ); #ifdef DEVICE_POLLING - ifp->if_capabilities |= IFCAP_POLLING; + if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0); #endif ether_ifattach(ifp, eaddr); @@ -437,7 +437,7 @@ smc_detach(device_t dev) callout_drain(&sc->smc_mii_tick_ch); #ifdef DEVICE_POLLING - if (sc->smc_ifp->if_capenable & IFCAP_POLLING) + if (sc->smc_if_getcapenable(ifp) & IFCAP_POLLING) ether_poll_deregister(sc->smc_ifp); #endif @@ -501,35 +501,35 @@ driver_t smc_driver = { DRIVER_MODULE(miibus, smc, miibus_driver, 0, 0); static void -smc_start(struct ifnet *ifp) +smc_start(if_t ifp) { struct smc_softc *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); SMC_LOCK(sc); smc_start_locked(ifp); SMC_UNLOCK(sc); } static void -smc_start_locked(struct ifnet *ifp) +smc_start_locked(if_t ifp) { struct smc_softc *sc; struct mbuf *m; u_int len, npages, spin_count; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); SMC_ASSERT_LOCKED(sc); - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) return; - if (IFQ_IS_EMPTY(&ifp->if_snd)) + if (if_sendq_empty(ifp)) return; /* * Grab the next packet. If it's too big, drop it. */ - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); len = m_length(m, NULL); len += (len & 1); if (len > ETHER_MAX_LEN - ETHER_CRC_LEN) { @@ -542,7 +542,7 @@ smc_start_locked(struct ifnet *ifp) /* * Flag that we're busy. */ - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); sc->smc_pending = m; /* @@ -577,7 +577,7 @@ smc_start_locked(struct ifnet *ifp) */ if (spin_count == 0) { sc->smc_mask |= ALLOC_INT; - if ((ifp->if_capenable & IFCAP_POLLING) == 0) + if ((if_getcapenable(ifp) & IFCAP_POLLING) == 0) smc_write_1(sc, MSK, sc->smc_mask); return; } @@ -588,7 +588,7 @@ smc_start_locked(struct ifnet *ifp) static void smc_task_tx(void *context, int pending) { - struct ifnet *ifp; + if_t ifp; struct smc_softc *sc; struct mbuf *m, *m0; u_int packet, len; @@ -596,8 +596,8 @@ smc_task_tx(void *context, int pending) uint8_t *data; (void)pending; - ifp = (struct ifnet *)context; - sc = ifp->if_softc; + ifp = (if_t)context; + sc = if_getsoftc(ifp); SMC_LOCK(sc); @@ -619,9 +619,9 @@ smc_task_tx(void *context, int pending) * If the allocation failed, requeue the packet and retry. */ if (packet & ARR_FAILED) { - IFQ_DRV_PREPEND(&ifp->if_snd, m); + if_sendq_prepend(ifp, m); if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); smc_start_locked(ifp); SMC_UNLOCK(sc); return; @@ -664,7 +664,7 @@ smc_task_tx(void *context, int pending) * Unmask the TX empty interrupt. */ sc->smc_mask |= TX_EMPTY_INT; - if ((ifp->if_capenable & IFCAP_POLLING) == 0) + if ((if_getcapenable(ifp) & IFCAP_POLLING) == 0) smc_write_1(sc, MSK, sc->smc_mask); /* @@ -678,7 +678,7 @@ smc_task_tx(void *context, int pending) * Finish up. */ if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); SMC_UNLOCK(sc); BPF_MTAP(ifp, m0); m_freem(m0); @@ -695,13 +695,13 @@ smc_task_rx(void *context, int pending) { u_int packet, status, len; uint8_t *data; - struct ifnet *ifp; + if_t ifp; struct smc_softc *sc; struct mbuf *m, *mhead, *mtail; (void)pending; - ifp = (struct ifnet *)context; - sc = ifp->if_softc; + ifp = (if_t)context; + sc = if_getsoftc(ifp); mhead = mtail = NULL; SMC_LOCK(sc); @@ -789,7 +789,7 @@ smc_task_rx(void *context, int pending) } sc->smc_mask |= RCV_INT; - if ((ifp->if_capenable & IFCAP_POLLING) == 0) + if ((if_getcapenable(ifp) & IFCAP_POLLING) == 0) smc_write_1(sc, MSK, sc->smc_mask); SMC_UNLOCK(sc); @@ -799,20 +799,20 @@ smc_task_rx(void *context, int pending) mhead = mhead->m_next; m->m_next = NULL; if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); } } #ifdef DEVICE_POLLING static int -smc_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +smc_poll(if_t ifp, enum poll_cmd cmd, int count) { struct smc_softc *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); SMC_LOCK(sc); - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) { SMC_UNLOCK(sc); return (0); } @@ -854,12 +854,12 @@ static void smc_task_intr(void *context, int pending) { struct smc_softc *sc; - struct ifnet *ifp; + if_t ifp; u_int status, packet, counter, tcr; (void)pending; - ifp = (struct ifnet *)context; - sc = ifp->if_softc; + ifp = (if_t)context; + sc = if_getsoftc(ifp); SMC_LOCK(sc); @@ -963,7 +963,7 @@ smc_task_intr(void *context, int pending) * Update the interrupt mask. */ smc_select_bank(sc, 2); - if ((ifp->if_capenable & IFCAP_POLLING) == 0) + if ((if_getcapenable(ifp) & IFCAP_POLLING) == 0) smc_write_1(sc, MSK, sc->smc_mask); SMC_UNLOCK(sc); @@ -1069,12 +1069,12 @@ smc_miibus_statchg(device_t dev) } static int -smc_mii_ifmedia_upd(struct ifnet *ifp) +smc_mii_ifmedia_upd(if_t ifp) { struct smc_softc *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); if (sc->smc_miibus == NULL) return (ENXIO); @@ -1083,12 +1083,12 @@ smc_mii_ifmedia_upd(struct ifnet *ifp) } static void -smc_mii_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) +smc_mii_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr) { struct smc_softc *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); if (sc->smc_miibus == NULL) return; @@ -1188,7 +1188,7 @@ smc_reset(struct smc_softc *sc) static void smc_enable(struct smc_softc *sc) { - struct ifnet *ifp; + if_t ifp; SMC_ASSERT_LOCKED(sc); ifp = sc->smc_ifp; @@ -1211,7 +1211,7 @@ smc_enable(struct smc_softc *sc) */ smc_select_bank(sc, 2); sc->smc_mask = EPH_INT | RX_OVRN_INT | RCV_INT | TX_INT; - if ((ifp->if_capenable & IFCAP_POLLING) != 0) + if ((if_getcapenable(ifp) & IFCAP_POLLING) != 0) smc_write_1(sc, MSK, sc->smc_mask); } @@ -1235,7 +1235,7 @@ smc_stop(struct smc_softc *sc) smc_write_1(sc, MSK, 0); #ifdef DEVICE_POLLING ether_poll_deregister(sc->smc_ifp); - sc->smc_ifp->if_capenable &= ~IFCAP_POLLING; + if_setcapenablebit(ifp, 0, IFCAP_POLLING); #endif /* @@ -1245,7 +1245,7 @@ smc_stop(struct smc_softc *sc) smc_write_2(sc, TCR, 0); smc_write_2(sc, RCR, 0); - sc->smc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(sc->smc_ifp, 0, IFF_DRV_RUNNING); } static void @@ -1272,18 +1272,18 @@ smc_init(void *context) static void smc_init_locked(struct smc_softc *sc) { - struct ifnet *ifp; + if_t ifp; SMC_ASSERT_LOCKED(sc); ifp = sc->smc_ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) return; smc_reset(sc); smc_enable(sc); - 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); smc_start_locked(ifp); @@ -1294,23 +1294,23 @@ smc_init_locked(struct smc_softc *sc) SMC_UNLOCK(sc); ether_poll_register(smc_poll, ifp); SMC_LOCK(sc); - ifp->if_capenable |= IFCAP_POLLING; + if_setcapenablebit(ifp, IFCAP_POLLING, 0); #endif } static int -smc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +smc_ioctl(if_t ifp, u_long cmd, caddr_t data) { struct smc_softc *sc; int error; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); error = 0; switch (cmd) { case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { + if ((if_getflags(ifp) & IFF_UP) == 0 && + (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { SMC_LOCK(sc); smc_stop(sc); SMC_UNLOCK(sc); diff --git a/sys/dev/smc/if_smcvar.h b/sys/dev/smc/if_smcvar.h index f7d3944d817d..8c0fa58b2e1e 100644 --- a/sys/dev/smc/if_smcvar.h +++ b/sys/dev/smc/if_smcvar.h @@ -31,7 +31,7 @@ #define _IF_SMCVAR_H_ struct smc_softc { - struct ifnet *smc_ifp; + if_t smc_ifp; device_t smc_dev; struct mtx smc_mtx; u_int smc_chip;