From nobody Mon Feb 6 17:53:59 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 4P9Ym804qyz3n0Tm; Mon, 6 Feb 2023 17:54:00 +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 4P9Ym76k5Vz4XNH; Mon, 6 Feb 2023 17:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706039; 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=yYcQjSKqnP4q3uI9FpWioEKNFcpb8uY79BBt6p3tAk0=; b=Nn1DULfeoycTb04GhO10k95TVFtoveuue0d7MWItO5CR8REh1KlnCY8dQ+RjAEsK9eAYTd Zw29GpDDHwpQCO5De3eRr/ZpqQxc+NH2M0Q0CKLtdTbrw5fAtsEj5qjSqHbCBnLWxrQzyT 19mv6SA6p7XDQ/6O/ihXrODGJaXO0hMAfrfBQT4Dh1pzuH4DgRgcr4cdm9nrIHDDGVglWs ETJ35wMtmjjCjVE26/aBIe0cJcLF1jMj/D8TlX+7IEKgdL8B4JOTyPKw076yxdfIq2EgjR OhrLSkA40lAFhFmm9aO+jEmyx7TFrWV4KO+0oVQYL9liJlAQQryVa9fsTG3yiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706039; 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=yYcQjSKqnP4q3uI9FpWioEKNFcpb8uY79BBt6p3tAk0=; b=whsEzZseZACi9518HGWXRYBz/d8HM0fG/lDv3g9mQHkBzhy5/wVj5iMdA6l8vDlcbNQH4m sd5HttN0kvXEfMoIKJdH2auh6F+GmzMCYfwt3VsGY1Ya/+otEB+0vInIfEGOLi+cQOl+Cv Xil8FfhnK6hS7DdCFMMeTuYTw6RT7mUkL3CHcDa9pgsGhjoL4wO4r/aIL3SXA0x+uluLMy LljMRpZhFYmWjt7n3uEK45NhL+RK/2sz4EqvlrqwybW5erLBGhX2+AdqDynpo4iJrW/COD WQ3DtmqyVEVxi3eZGxJzpmMAt1CKyYNpq32Y8MW2Vb04M9JDPrwLFau48fx4wQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675706039; a=rsa-sha256; cv=none; b=v/F0cec/iEQH3Oa3B/mZvwW3Cymwdvqp+WXAWE9T/vN2Y+MWba9f1Cjib3WMCoS/XHWpDU bBBX5dGJqGD6+8maAPKk2QWpQDFIEjDZFcdCpsDOzUXrGAxqja5Jg6WHQZMNzmaSQ3OhGm RcMIrec7ZYI18DsSaP0LHLC7zSZzhJYqnnFdi/jnGg4ibPGqvNoV33WqHaUUspkT1bvHn2 fXkvJgU0gECQecHQBj2f68Q3LcIEcEZSbdQYkW+TUDKFaQeyMM38tR8j9vDiLI1HsPuot/ eHVEqicsFeUe6bg2kL4Tx5Vk32Z9AO5OVknGKInZbSx0MpRIvWAqc0Q8lDl20w== 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 4P9Ym75nnZzkMT; Mon, 6 Feb 2023 17:53:59 +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 316HrxGC074297; Mon, 6 Feb 2023 17:53:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 316Hrxwv074296; Mon, 6 Feb 2023 17:53:59 GMT (envelope-from git) Date: Mon, 6 Feb 2023 17:53:59 GMT Message-Id: <202302061753.316Hrxwv074296@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: 2568cd2ae95a - main - Mechanically convert if_plip(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: 2568cd2ae95a541c5d58e9efec29fbae146b69e3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=2568cd2ae95a541c5d58e9efec29fbae146b69e3 commit 2568cd2ae95a541c5d58e9efec29fbae146b69e3 Author: Justin Hibbits AuthorDate: 2022-09-26 14:33:20 +0000 Commit: Justin Hibbits CommitDate: 2023-02-06 17:32:06 +0000 Mechanically convert if_plip(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37854 --- sys/dev/ppbus/if_plip.c | 92 +++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 49 deletions(-) diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index e92896e9421f..91ac58ed484d 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -175,8 +175,8 @@ static u_char *ctxmith; /* Functions for the lp# interface */ static int lpinittables(void); -static int lpioctl(struct ifnet *, u_long, caddr_t); -static int lpoutput(struct ifnet *, struct mbuf *, const struct sockaddr *, +static int lpioctl(if_t, u_long, caddr_t); +static int lpoutput(if_t, struct mbuf *, const struct sockaddr *, struct route *); static void lpstop(struct lp_data *); static void lp_intr(void *); @@ -234,7 +234,7 @@ static int lp_attach(device_t dev) { struct lp_data *lp = DEVTOSOFTC(dev); - struct ifnet *ifp; + if_t ifp; int error, rid = 0; lp->sc_dev = dev; @@ -255,15 +255,13 @@ lp_attach(device_t dev) return (ENOSPC); } - ifp->if_softc = lp; + if_setsoftc(ifp, lp); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_mtu = LPMTU; - ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; - ifp->if_ioctl = lpioctl; - ifp->if_output = lpoutput; - ifp->if_hdrlen = 0; - ifp->if_addrlen = 0; - ifp->if_snd.ifq_maxlen = ifqmaxlen; + if_setmtu(ifp, LPMTU); + if_setflags(ifp, IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST); + if_setioctlfn(ifp, lpioctl); + if_setoutputfn(ifp, lpoutput); + if_setsendqlen(ifp, ifqmaxlen); if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); @@ -353,7 +351,7 @@ lpstop(struct lp_data *sc) ppb_assert_locked(ppbus); ppb_wctr(ppbus, 0x00); - sc->sc_ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(sc->sc_ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); free(sc->sc_ifbuf, M_DEVBUF); sc->sc_ifbuf = NULL; @@ -362,9 +360,9 @@ lpstop(struct lp_data *sc) } static int -lpinit_locked(struct ifnet *ifp) +lpinit_locked(if_t ifp) { - struct lp_data *sc = ifp->if_softc; + struct lp_data *sc = if_getsoftc(ifp); device_t dev = sc->sc_dev; device_t ppbus = device_get_parent(dev); int error; @@ -382,7 +380,7 @@ lpinit_locked(struct ifnet *ifp) return (ENOBUFS); } - sc->sc_ifbuf = malloc(sc->sc_ifp->if_mtu + MLPIPHDRLEN, + sc->sc_ifbuf = malloc(if_getmtu(sc->sc_ifp) + MLPIPHDRLEN, M_DEVBUF, M_NOWAIT); if (sc->sc_ifbuf == NULL) { ppb_release_bus(ppbus, dev); @@ -391,8 +389,8 @@ lpinit_locked(struct ifnet *ifp) ppb_wctr(ppbus, IRQENABLE); - 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); return (0); } @@ -400,9 +398,9 @@ lpinit_locked(struct ifnet *ifp) * Process an ioctl request. */ static int -lpioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +lpioctl(if_t ifp, u_long cmd, caddr_t data) { - struct lp_data *sc = ifp->if_softc; + struct lp_data *sc = if_getsoftc(ifp); device_t dev = sc->sc_dev; device_t ppbus = device_get_parent(dev); struct ifaddr *ifa = (struct ifaddr *)data; @@ -416,23 +414,23 @@ lpioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (ifa->ifa_addr->sa_family != AF_INET) return (EAFNOSUPPORT); - ifp->if_flags |= IFF_UP; + if_setflagbits(ifp, IFF_UP, 0); /* FALLTHROUGH */ case SIOCSIFFLAGS: error = 0; ppb_lock(ppbus); - 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)) lpstop(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))) error = lpinit_locked(ifp); ppb_unlock(ppbus); return (error); case SIOCSIFMTU: ppb_lock(ppbus); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { ptr = malloc(ifr->ifr_mtu + MLPIPHDRLEN, M_DEVBUF, M_NOWAIT); if (ptr == NULL) { @@ -443,12 +441,12 @@ lpioctl(struct ifnet *ifp, u_long cmd, caddr_t data) free(sc->sc_ifbuf, M_DEVBUF); sc->sc_ifbuf = ptr; } - sc->sc_ifp->if_mtu = ifr->ifr_mtu; + if_setmtu(ifp, ifr->ifr_mtu); ppb_unlock(ppbus); break; case SIOCGIFMTU: - ifr->ifr_mtu = sc->sc_ifp->if_mtu; + ifr->ifr_mtu = if_getmtu(sc->sc_ifp); break; case SIOCADDMULTI: @@ -518,11 +516,11 @@ clpinbyte(int spin, device_t ppbus) } static void -lptap(struct ifnet *ifp, struct mbuf *m) +lptap(if_t ifp, struct mbuf *m) { u_int32_t af = AF_INET; - bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); + bpf_mtap2_if(ifp, &af, sizeof(af), m); } static void @@ -536,7 +534,7 @@ lp_intr(void *arg) struct mbuf *top; ppb_assert_locked(ppbus); - if (sc->sc_ifp->if_flags & IFF_LINK0) { + if (if_getflags(sc->sc_ifp) & IFF_LINK0) { /* Ack. the request */ ppb_wdtr(ppbus, 0x01); @@ -549,7 +547,7 @@ lp_intr(void *arg) if (j == -1) goto err; len = len + (j << 8); - if (len > sc->sc_ifp->if_mtu + MLPIPHDRLEN) + if (len > if_getmtu(sc->sc_ifp) + MLPIPHDRLEN) goto err; bp = sc->sc_ifbuf; @@ -581,10 +579,9 @@ lp_intr(void *arg) 0); if (top) { ppb_unlock(ppbus); - if (bpf_peers_present(sc->sc_ifp->if_bpf)) - lptap(sc->sc_ifp, top); + lptap(sc->sc_ifp, top); - M_SETFIB(top, sc->sc_ifp->if_fib); + M_SETFIB(top, if_getfib(sc->sc_ifp)); /* mbuf is free'd on failure. */ netisr_queue(NETISR_IP, top); @@ -593,7 +590,7 @@ lp_intr(void *arg) return; } while ((ppb_rstr(ppbus) & LPIP_SHAKE)) { - len = sc->sc_ifp->if_mtu + LPIPHDRLEN; + len = if_getmtu(sc->sc_ifp) + LPIPHDRLEN; bp = sc->sc_ifbuf; while (len--) { cl = ppb_rstr(ppbus); @@ -634,10 +631,9 @@ lp_intr(void *arg) 0); if (top) { ppb_unlock(ppbus); - if (bpf_peers_present(sc->sc_ifp->if_bpf)) - lptap(sc->sc_ifp, top); + lptap(sc->sc_ifp, top); - M_SETFIB(top, sc->sc_ifp->if_fib); + M_SETFIB(top, if_getfib(sc->sc_ifp)); /* mbuf is free'd on failure. */ netisr_queue(NETISR_IP, top); @@ -659,7 +655,7 @@ err: if (sc->sc_iferrs > LPMAXERRS) { if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n"); ppb_wctr(ppbus, 0x00); - sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(sc->sc_ifp, 0, IFF_DRV_RUNNING); sc->sc_iferrs = 0; } } @@ -680,10 +676,10 @@ lpoutbyte(u_char byte, int spin, device_t ppbus) } static int -lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, +lpoutput(if_t ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { - struct lp_data *sc = ifp->if_softc; + struct lp_data *sc = if_getsoftc(ifp); device_t dev = sc->sc_dev; device_t ppbus = device_get_parent(dev); int err; @@ -696,14 +692,14 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /* We need a sensible value if we abort */ cp++; ppb_lock(ppbus); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); err = 1; /* assume we're aborting because of an error */ /* Suspend (on laptops) or receive-errors might have taken us offline */ ppb_wctr(ppbus, IRQENABLE); - if (ifp->if_flags & IFF_LINK0) { + if (if_getflags(ifp) & IFF_LINK0) { if (!(ppb_rstr(ppbus) & CLPIP_SHAKE)) { lprintf("&"); lp_intr(sc); @@ -764,15 +760,14 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, err = 0; /* No errors */ nend: - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if (err) { /* if we didn't timeout... */ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lprintf("X"); } else { if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); - if (bpf_peers_present(ifp->if_bpf)) - lptap(ifp, m); + lptap(ifp, m); } m_freem(m); @@ -810,15 +805,14 @@ end: --cp; ppb_wdtr(ppbus, txmitl[*cp] ^ 0x17); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if (err) { /* if we didn't timeout... */ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lprintf("X"); } else { if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); - if (bpf_peers_present(ifp->if_bpf)) - lptap(ifp, m); + lptap(ifp, m); } m_freem(m);