From nobody Tue Jan 24 20:48:16 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 4P1fFD3MxRz3bSnt; Tue, 24 Jan 2023 20:48:16 +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 4P1fFD2n5qz41wn; Tue, 24 Jan 2023 20:48:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674593296; 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=ftmc7G29QG7ojx6igubN3d/dwRv7qX/dCQ0Q/oxNWgE=; b=iosWWWDCayHiIoSDZuyrCXTvKR66/37pOGBB3XMj9dsr1M6oKDRuWz+dQInZmIKFKRMNWn 30Kl0hNP1Ootew9QUnxbKs8O68SbmSvoGrYqL6Skj7M5X2TnMOpHHApibPpzR2E/d9gQFT dacKZhKj0c2fnvZYY2oR7kHSkCuXSUmzUGwkqw7/sMJspQC5oRr7sQtnpHv2CEy3ISOQSm FvbjXRrxq1o3ChUTAuXeek7ZSaxmx1Z5io8l8BJGArDZcxqPC84KAayrmUAkhfWbp18GYh DqMBI0tgm6j3uA8FLTgUdYcolEjyZSgpY8LopDdDCOYYmJpuBrCprq9YxHydwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674593296; 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=ftmc7G29QG7ojx6igubN3d/dwRv7qX/dCQ0Q/oxNWgE=; b=y04JyIYGGdDO+uSGecGj9U4/y+rxOE2jN6HRCQhgGbmNNXtiyZk/YV9KR0XHehUm5zgJnR azrirLukb2pXX75aBiQdZUpueRG67rAhgJ6fcuhNADbNYHFb9yMauY7cFsIfwc7EiTq3pH Ucs4I0DvwJqXNY6Ss9XqEFFVvHbAUAVw/JbyDwRDWWmdXuhjdp4wculeN90aEjmfzHaobc di+K2kNKomH/q+G9Nma/CmUaDOKle1rMtOeL3nZRJkVtro55MfKj/txafNACFZBz6wE+xu od3YXOjaJDlXQ+yqAF1von9ffjLKpx/EGCx7ctpW3tsSDpBXLkX3QMcIMTFaug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674593296; a=rsa-sha256; cv=none; b=ql0F0IDwkezLh2jm+9zp/BnaRnCEm5FPZgbMQzwJ/1o33r0zGLytN8Vl/eHGPuKSuWmGaM 9GzZ2WOFchvcAgJ441QigDKjs8VyzGPnsV/iIAZaiZYTFo5Q7IDf3qyyfRwXjmQwpICl1s LfWBkwOvCN3W4O/JglQ0PCUwrOJtduE+Iwv8RpeUj3r8LNwj9cKT9lqDya+Q5SNFKWToLe 4Pc1xTa5aD5siBLlQQZYHMVmTjmEk2nku1v7lyl2BbkL+CClJaACmRWJRPdF3pBCPMlvom CrA9hGMEgfApTpfpVsUkjwSefDRDhwumpg4kotoSwtB4QGqJZTsF0WBiafzPZg== 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 4P1fFD1qhSzN6M; Tue, 24 Jan 2023 20:48:16 +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 30OKmGpg053707; Tue, 24 Jan 2023 20:48:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OKmGNc053706; Tue, 24 Jan 2023 20:48:16 GMT (envelope-from git) Date: Tue, 24 Jan 2023 20:48:16 GMT Message-Id: <202301242048.30OKmGNc053706@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: 2c7bc0f55192 - main - Mechanically convert if_cpsw(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: 2c7bc0f5519262f6ab2d5643d974c7f2f47fc9b2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=2c7bc0f5519262f6ab2d5643d974c7f2f47fc9b2 commit 2c7bc0f5519262f6ab2d5643d974c7f2f47fc9b2 Author: Justin Hibbits AuthorDate: 2022-02-25 18:00:25 +0000 Commit: Justin Hibbits CommitDate: 2023-01-24 19:36:28 +0000 Mechanically convert if_cpsw(4) to IfAPI Reviewed By: manu Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37789 --- sys/arm/ti/cpsw/if_cpsw.c | 105 +++++++++++++++++++++---------------------- sys/arm/ti/cpsw/if_cpswvar.h | 4 +- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c index 1dbd53b72004..6f1bcc345f47 100644 --- a/sys/arm/ti/cpsw/if_cpsw.c +++ b/sys/arm/ti/cpsw/if_cpsw.c @@ -117,7 +117,7 @@ static int cpsw_suspend(device_t); static int cpsw_resume(device_t); /* Ioctl. */ -static int cpswp_ioctl(struct ifnet *, u_long command, caddr_t data); +static int cpswp_ioctl(if_t, u_long command, caddr_t data); static int cpswp_miibus_readreg(device_t, int phy, int reg); static int cpswp_miibus_writereg(device_t, int phy, int reg, int value); @@ -127,7 +127,7 @@ static void cpswp_miibus_statchg(device_t); static void cpsw_intr_rx(void *arg); static struct mbuf *cpsw_rx_dequeue(struct cpsw_softc *); static void cpsw_rx_enqueue(struct cpsw_softc *); -static void cpswp_start(struct ifnet *); +static void cpswp_start(if_t); static void cpsw_intr_tx(void *); static void cpswp_tx_enqueue(struct cpswp_softc *); static int cpsw_tx_dequeue(struct cpsw_softc *); @@ -136,8 +136,8 @@ static int cpsw_tx_dequeue(struct cpsw_softc *); static void cpsw_intr_rx_thresh(void *); static void cpsw_intr_misc(void *); static void cpswp_tick(void *); -static void cpswp_ifmedia_sts(struct ifnet *, struct ifmediareq *); -static int cpswp_ifmedia_upd(struct ifnet *); +static void cpswp_ifmedia_sts(if_t, struct ifmediareq *); +static int cpswp_ifmedia_upd(if_t); static void cpsw_tx_watchdog(void *); /* ALE support */ @@ -997,7 +997,7 @@ static int cpswp_attach(device_t dev) { int error; - struct ifnet *ifp; + if_t ifp; struct cpswp_softc *sc; uint32_t reg; uint8_t mac_addr[ETHER_ADDR_LEN]; @@ -1033,18 +1033,17 @@ cpswp_attach(device_t dev) } if_initname(ifp, device_get_name(sc->dev), sc->unit); - ifp->if_softc = sc; - ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST; - ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_HWCSUM; //FIXME VLAN? - ifp->if_capenable = ifp->if_capabilities; + if_setsoftc(ifp, sc); + if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST); - ifp->if_init = cpswp_init; - ifp->if_start = cpswp_start; - ifp->if_ioctl = cpswp_ioctl; + if_setcapenable(ifp, if_getcapabilities(ifp)); - ifp->if_snd.ifq_drv_maxlen = sc->swsc->tx.queue_slots; - IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); - IFQ_SET_READY(&ifp->if_snd); + if_setinitfn(ifp, cpswp_init); + if_setstartfn(ifp, cpswp_start); + if_setioctlfn(ifp, cpswp_ioctl); + + if_setsendqlen(ifp, sc->swsc->tx.queue_slots); + if_setsendqready(ifp); /* FIXME: For now; Go and kidnap syscon from opp-table */ /* ti,cpsw actually have an optional syscon reference but only for am33xx?? */ @@ -1129,7 +1128,7 @@ static int cpsw_ports_down(struct cpsw_softc *sc) { struct cpswp_softc *psc; - struct ifnet *ifp1, *ifp2; + if_t ifp1, ifp2; if (!sc->dualemac) return (1); @@ -1161,13 +1160,13 @@ cpswp_init_locked(void *arg) int i; #endif struct cpswp_softc *sc = arg; - struct ifnet *ifp; + if_t ifp; uint32_t reg; CPSW_DEBUGF(sc->swsc, ("")); CPSW_PORT_LOCK_ASSERT(sc); ifp = sc->ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) return; getbinuptime(&sc->init_uptime); @@ -1215,8 +1214,8 @@ cpswp_init_locked(void *arg) mii_mediachg(sc->mii); callout_reset(&sc->mii_callout, hz, cpswp_tick, 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); } static int @@ -1292,19 +1291,19 @@ cpsw_tx_teardown(struct cpsw_softc *sc) static void cpswp_stop_locked(struct cpswp_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t reg; ifp = sc->ifp; CPSW_DEBUGF(sc->swsc, ("")); CPSW_PORT_LOCK_ASSERT(sc); - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) return; /* Disable interface */ - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); /* Stop ticker */ callout_stop(&sc->mii_callout); @@ -1399,7 +1398,7 @@ cpsw_set_allmulti(struct cpswp_softc *sc, int set) } static int -cpswp_ioctl(struct ifnet *ifp, u_long command, caddr_t data) +cpswp_ioctl(if_t ifp, u_long command, caddr_t data) { struct cpswp_softc *sc; struct ifreq *ifr; @@ -1407,45 +1406,45 @@ cpswp_ioctl(struct ifnet *ifp, u_long command, caddr_t data) uint32_t changed; error = 0; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); ifr = (struct ifreq *)data; switch (command) { case SIOCSIFCAP: - changed = ifp->if_capenable ^ ifr->ifr_reqcap; + changed = if_getcapenable(ifp) ^ ifr->ifr_reqcap; if (changed & IFCAP_HWCSUM) { if ((ifr->ifr_reqcap & changed) & IFCAP_HWCSUM) - ifp->if_capenable |= IFCAP_HWCSUM; + if_setcapenablebit(ifp, IFCAP_HWCSUM, 0); else - ifp->if_capenable &= ~IFCAP_HWCSUM; + if_setcapenablebit(ifp, 0, IFCAP_HWCSUM); } error = 0; break; case SIOCSIFFLAGS: CPSW_PORT_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - changed = ifp->if_flags ^ sc->if_flags; + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { + changed = if_getflags(ifp) ^ sc->if_flags; CPSW_DEBUGF(sc->swsc, ("SIOCSIFFLAGS: UP & RUNNING (changed=0x%x)", changed)); if (changed & IFF_PROMISC) cpsw_set_promisc(sc, - ifp->if_flags & IFF_PROMISC); + if_getflags(ifp) & IFF_PROMISC); if (changed & IFF_ALLMULTI) cpsw_set_allmulti(sc, - ifp->if_flags & IFF_ALLMULTI); + if_getflags(ifp) & IFF_ALLMULTI); } else { CPSW_DEBUGF(sc->swsc, ("SIOCSIFFLAGS: starting up")); cpswp_init_locked(sc); } - } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + } else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { CPSW_DEBUGF(sc->swsc, ("SIOCSIFFLAGS: shutting down")); cpswp_stop_locked(sc); } - sc->if_flags = ifp->if_flags; + sc->if_flags = if_getflags(ifp); CPSW_PORT_UNLOCK(sc); break; case SIOCADDMULTI: @@ -1582,7 +1581,7 @@ static void cpsw_intr_rx(void *arg) { struct cpsw_softc *sc; - struct ifnet *ifp; + if_t ifp; struct mbuf *received, *next; sc = (struct cpsw_softc *)arg; @@ -1601,7 +1600,7 @@ cpsw_intr_rx(void *arg) next = received->m_nextpkt; received->m_nextpkt = NULL; ifp = received->m_pkthdr.rcvif; - (*ifp->if_input)(ifp, received); + if_input(ifp, received); if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); received = next; } @@ -1684,7 +1683,7 @@ cpsw_rx_dequeue(struct cpsw_softc *sc) nsegs = 0; } - if ((psc->ifp->if_capenable & IFCAP_RXCSUM) != 0) { + if ((if_getcapenable(psc->ifp) & IFCAP_RXCSUM) != 0) { /* check for valid CRC by looking into pkt_err[5:4] */ if ((bd.flags & (CPDMA_BD_SOP | CPDMA_BD_PKT_ERR_MASK)) == @@ -1712,7 +1711,7 @@ cpsw_rx_dequeue(struct cpsw_softc *sc) if (bootverbose) printf( "%s: %s: discanding fragment packet w/o header\n", - __func__, psc->ifp->if_xname); + __func__, if_name(psc->ifp)); m_freem(m); continue; } else { @@ -1816,12 +1815,12 @@ cpsw_rx_enqueue(struct cpsw_softc *sc) } static void -cpswp_start(struct ifnet *ifp) +cpswp_start(if_t ifp) { struct cpswp_softc *sc; - sc = ifp->if_softc; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || + sc = if_getsoftc(ifp); + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0 || sc->swsc->tx.running == 0) { return; } @@ -1859,7 +1858,7 @@ cpswp_tx_enqueue(struct cpswp_softc *sc) first_new_slot = NULL; last_old_slot = STAILQ_LAST(&sc->swsc->tx.active, cpsw_slot, next); while ((slot = STAILQ_FIRST(&sc->swsc->tx.avail)) != NULL) { - IF_DEQUEUE(&sc->ifp->if_snd, m0); + m0 = if_dequeue(sc->ifp); if (m0 == NULL) break; @@ -1885,7 +1884,7 @@ cpswp_tx_enqueue(struct cpswp_softc *sc) } else { CPSW_DEBUGF(sc->swsc, ("Requeueing defragmented packet")); - IF_PREPEND(&sc->ifp->if_snd, m0); + if_sendq_prepend(sc->ifp, m0); } slot->mbuf = NULL; continue; @@ -2075,7 +2074,7 @@ static void cpsw_intr_rx_thresh(void *arg) { struct cpsw_softc *sc; - struct ifnet *ifp; + if_t ifp; struct mbuf *received, *next; sc = (struct cpsw_softc *)arg; @@ -2089,7 +2088,7 @@ cpsw_intr_rx_thresh(void *arg) next = received->m_nextpkt; received->m_nextpkt = NULL; ifp = received->m_pkthdr.rcvif; - (*ifp->if_input)(ifp, received); + if_input(ifp, received); if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); received = next; } @@ -2224,12 +2223,12 @@ cpswp_tick(void *msc) } static void -cpswp_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) +cpswp_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr) { struct cpswp_softc *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); CPSW_DEBUGF(sc->swsc, ("")); CPSW_PORT_LOCK(sc); @@ -2242,11 +2241,11 @@ cpswp_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) } static int -cpswp_ifmedia_upd(struct ifnet *ifp) +cpswp_ifmedia_upd(if_t ifp) { struct cpswp_softc *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); CPSW_DEBUGF(sc->swsc, ("")); CPSW_PORT_LOCK(sc); mii_mediachg(sc->mii); @@ -2478,7 +2477,7 @@ cpswp_ale_update_addresses(struct cpswp_softc *sc, int purge) * For simplicity, keep this entry at table index 0 for port 1 and * at index 2 for port 2 in the ALE. */ - mac = LLADDR((struct sockaddr_dl *)sc->ifp->if_addr->ifa_addr); + mac = LLADDR((struct sockaddr_dl *)if_getifaddr(sc->ifp)->ifa_addr); ale_entry[0] = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5]; ale_entry[1] = ale_type | mac[0] << 8 | mac[1]; /* addr entry + mac */ ale_entry[2] = 0; /* port = 0 */ @@ -2668,7 +2667,7 @@ cpsw_stat_uptime(SYSCTL_HANDLER_ARGS) swsc = arg1; sc = device_get_softc(swsc->port[arg2].dev); - if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) { getbinuptime(&t); bintime_sub(&t, &sc->init_uptime); result = t.sec; diff --git a/sys/arm/ti/cpsw/if_cpswvar.h b/sys/arm/ti/cpsw/if_cpswvar.h index 9c51b76b9db4..36f6ac18ef43 100644 --- a/sys/arm/ti/cpsw/if_cpswvar.h +++ b/sys/arm/ti/cpsw/if_cpswvar.h @@ -55,7 +55,7 @@ struct cpsw_vlangroups { struct cpsw_slot { uint32_t bd_offset; /* Offset of corresponding BD within CPPI RAM. */ bus_dmamap_t dmamap; - struct ifnet *ifp; + if_t ifp; struct mbuf *mbuf; STAILQ_ENTRY(cpsw_slot) next; }; @@ -139,7 +139,7 @@ struct cpswp_softc { struct bintime init_uptime; /* system uptime when init happened. */ struct callout mii_callout; struct cpsw_softc *swsc; - struct ifnet *ifp; + if_t ifp; struct mii_data *mii; struct mtx lock; uint32_t if_flags;