From nobody Mon Feb 06 17:53:56 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 4P9Ym50rr5z3mypx; Mon, 6 Feb 2023 17:53:57 +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 4P9Ym44jMLz4X5W; Mon, 6 Feb 2023 17: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=1675706036; 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=2AghYqafErmXj8Rs0JaDRTQHrV4DilXy9Ddl3g0HHiU=; b=IXCQWjIpE7tHFDLdVBOANQBeCBwA3i+VRi3BTlLiyAYs9gMj2vRJak7XKpEX6WuNzwXPtS bitL6B1+S7t3hJ7l3LEcW76OVUCvDQNssYytpcMfTNt86aG2A0jY1paPbxcv53dG4tAoyS LEVAr6j/Sd58baDeDYGuGzKJ66T4T+jCUSUs4VD0k/WkOKsIT4mU65KgWbhT3v4Us+F2cu G7jI1w0Z/IYHs6XkNurRGeWUp+W8AkzCrSzpBsHtGv1SjzQmKTMZ1qB+rn9OXBrs1a5qz9 jVgt7lwKkbymnD7np5zYbtQLgN+PY8QizilH+CzB4sI5VyhPXeLFk7UYDcq5Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706036; 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=2AghYqafErmXj8Rs0JaDRTQHrV4DilXy9Ddl3g0HHiU=; b=SkzHpWk6Fb9S8FrO/hKZYduzotS62R5qlQIcb8/+4gkIH7hQvLOHXt/wy9G7S+Amb96SfG tXsYahrPth+gvnCqFgAexxzxvPtriWVxoMm1XzF9KvDgQ4isxs8aRXDUHscRsaD8SOXoU5 b5qS0L2QAeBn8WqmTKjEOydkR9vgcYf+uiAJd3Ynqgf5HCmTRzz9qo/WpWq30HBDfZAmzU peeB8+qLkNQdaP3V786Jxk+XlW3F9AIdC2QduxkuOzc5dVywERJgqkvG951CiR29QTwclH ggzjQMxFh0E2b0kxu0SmmdIaDs1u61hmDTfUT93+Jk2kojkWWWX5XxNozBct2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675706036; a=rsa-sha256; cv=none; b=LeNNh5LXJqWdltADKT1GnX7w4Uz9mEpNHcqsQZqh4GDoEmgJma17MSpvK3ssDIgkINUgJg tNvtaNOJ7aooYP9yJtOF5a0JWevLTY83deeGqfxxYrsb1VtVVHWJIh4ehiKU+dAWTQJStw opaDRtrjwqK9zaUcCfyNLjkj86Fr0e0Jm62U7Z4UqRM0UHjxpAfLLVPmZyDZFTmDCyb7ej H5huCWS6feKsnb8liRx/ZUJM5Z+ICg5TpMOOmdzYDjweuwwIUZAuSYql7k1kyChY1XYUtP X/LTJPIUumaicI+vKNGGuviPxVylwgARaFXaQ4rY1Y5gl4D4pntH53sh/JN49w== 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 4P9Ym43W9qzkMS; Mon, 6 Feb 2023 17: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 316HruW5074217; Mon, 6 Feb 2023 17: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 316HrujC074216; Mon, 6 Feb 2023 17:53:56 GMT (envelope-from git) Date: Mon, 6 Feb 2023 17:53:56 GMT Message-Id: <202302061753.316HrujC074216@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: 47842ecfe01d - main - Mechanically convert if_tsec(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: 47842ecfe01d19516d7197603e5949d4dbb3e558 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=47842ecfe01d19516d7197603e5949d4dbb3e558 commit 47842ecfe01d19516d7197603e5949d4dbb3e558 Author: Justin Hibbits AuthorDate: 2022-03-01 19:49:10 +0000 Commit: Justin Hibbits CommitDate: 2023-02-06 17:32:05 +0000 Mechanically convert if_tsec(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37805 --- sys/dev/tsec/if_tsec.c | 159 ++++++++++++++++++++++++------------------------- sys/dev/tsec/if_tsec.h | 2 +- 2 files changed, 80 insertions(+), 81 deletions(-) diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index 979c0c4e62cc..7680ef43b775 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -73,12 +73,12 @@ static int tsec_alloc_dma_desc(device_t dev, bus_dma_tag_t *dtag, bus_dmamap_t *dmap, bus_size_t dsize, void **vaddr, void *raddr, const char *dname); static void tsec_dma_ctl(struct tsec_softc *sc, int state); -static void tsec_encap(struct ifnet *ifp, struct tsec_softc *sc, +static void tsec_encap(if_t ifp, struct tsec_softc *sc, struct mbuf *m0, uint16_t fcb_flags, int *start_tx); static void tsec_free_dma(struct tsec_softc *sc); static void tsec_free_dma_desc(bus_dma_tag_t dtag, bus_dmamap_t dmap, void *vaddr); -static int tsec_ifmedia_upd(struct ifnet *ifp); -static void tsec_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); +static int tsec_ifmedia_upd(if_t ifp); +static void tsec_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr); static int tsec_new_rxbuf(bus_dma_tag_t tag, bus_dmamap_t map, struct mbuf **mbufp, uint32_t *paddr); static void tsec_map_dma_addr(void *arg, bus_dma_segment_t *segs, @@ -86,12 +86,12 @@ static void tsec_map_dma_addr(void *arg, bus_dma_segment_t *segs, static void tsec_intrs_ctl(struct tsec_softc *sc, int state); static void tsec_init(void *xsc); static void tsec_init_locked(struct tsec_softc *sc); -static int tsec_ioctl(struct ifnet *ifp, u_long command, caddr_t data); +static int tsec_ioctl(if_t ifp, u_long command, caddr_t data); static void tsec_reset_mac(struct tsec_softc *sc); static void tsec_setfilter(struct tsec_softc *sc); static void tsec_set_mac_address(struct tsec_softc *sc); -static void tsec_start(struct ifnet *ifp); -static void tsec_start_locked(struct ifnet *ifp); +static void tsec_start(if_t ifp); +static void tsec_start_locked(if_t ifp); static void tsec_stop(struct tsec_softc *sc); static void tsec_tick(void *arg); static void tsec_watchdog(struct tsec_softc *sc); @@ -119,7 +119,7 @@ int tsec_attach(struct tsec_softc *sc) { uint8_t hwaddr[ETHER_ADDR_LEN]; - struct ifnet *ifp; + if_t ifp; int error = 0; int i; @@ -247,26 +247,25 @@ tsec_attach(struct tsec_softc *sc) return (ENOMEM); } - ifp->if_softc = sc; + if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); - ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST; - ifp->if_init = tsec_init; - ifp->if_start = tsec_start; - ifp->if_ioctl = tsec_ioctl; + if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST); + if_setinitfn(ifp, tsec_init); + if_setstartfn(ifp, tsec_start); + if_setioctlfn(ifp, tsec_ioctl); - IFQ_SET_MAXLEN(&ifp->if_snd, TSEC_TX_NUM_DESC - 1); - ifp->if_snd.ifq_drv_maxlen = TSEC_TX_NUM_DESC - 1; - IFQ_SET_READY(&ifp->if_snd); + if_setsendqlen(ifp, TSEC_TX_NUM_DESC - 1); + if_setsendqready(ifp); - ifp->if_capabilities = IFCAP_VLAN_MTU; + if_setcapabilities(ifp, IFCAP_VLAN_MTU); if (sc->is_etsec) - ifp->if_capabilities |= IFCAP_HWCSUM; + if_setcapabilitiesbit(ifp, IFCAP_HWCSUM, 0); - ifp->if_capenable = ifp->if_capabilities; + if_setcapenable(ifp, if_getcapabilities(ifp)); #ifdef DEVICE_POLLING /* Advertise that polling is supported */ - ifp->if_capabilities |= IFCAP_POLLING; + if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0); #endif /* Attach PHY(s) */ @@ -295,7 +294,7 @@ tsec_detach(struct tsec_softc *sc) if (sc->tsec_ifp != NULL) { #ifdef DEVICE_POLLING - if (sc->tsec_ifp->if_capenable & IFCAP_POLLING) + if (sc->tsec_if_getcapenable(ifp) & IFCAP_POLLING) ether_poll_deregister(sc->tsec_ifp); #endif @@ -377,11 +376,11 @@ tsec_init_locked(struct tsec_softc *sc) { struct tsec_desc *tx_desc = sc->tsec_tx_vaddr; struct tsec_desc *rx_desc = sc->tsec_rx_vaddr; - struct ifnet *ifp = sc->tsec_ifp; + if_t ifp = sc->tsec_ifp; uint32_t val, i; int timeout; - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) return; TSEC_GLOBAL_LOCK_ASSERT(sc); @@ -458,7 +457,7 @@ tsec_init_locked(struct tsec_softc *sc) * ...only if polling is not turned on. Disable interrupts explicitly * if polling is enabled. */ - if (ifp->if_capenable & IFCAP_POLLING ) + if (if_getcapenable(ifp) & IFCAP_POLLING ) tsec_intrs_ctl(sc, 0); else #endif /* DEVICE_POLLING */ @@ -523,7 +522,7 @@ tsec_init_locked(struct tsec_softc *sc) /* Step 19: Configure ethernet frame sizes */ TSEC_WRITE(sc, TSEC_REG_MINFLR, TSEC_MIN_FRAME_SIZE); - tsec_set_mtu(sc, ifp->if_mtu); + tsec_set_mtu(sc, if_getmtu(ifp)); /* Step 20: Enable Rx and RxBD sdata snooping */ TSEC_WRITE(sc, TSEC_REG_ATTR, TSEC_ATTR_RDSEN | TSEC_ATTR_RBDSEN); @@ -556,9 +555,9 @@ tsec_init_locked(struct tsec_softc *sc) tsec_setup_multicast(sc); /* Step 27: Activate network interface */ - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - sc->tsec_if_flags = ifp->if_flags; + if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); + sc->tsec_if_flags = if_getflags(ifp); sc->tsec_watchdog = 0; /* Schedule watchdog timeout */ @@ -579,7 +578,7 @@ tsec_set_mac_address(struct tsec_softc *sc) sizeof(macbuf))); macbufp = (char *)macbuf; - curmac = (char *)IF_LLADDR(sc->tsec_ifp); + curmac = (char *)if_getlladdr(sc->tsec_ifp); /* Correct order of MAC address bytes */ for (i = 1; i <= ETHER_ADDR_LEN; i++) @@ -693,7 +692,7 @@ tsec_reset_mac(struct tsec_softc *sc) static void tsec_watchdog(struct tsec_softc *sc) { - struct ifnet *ifp; + if_t ifp; TSEC_GLOBAL_LOCK_ASSERT(sc); @@ -709,9 +708,9 @@ tsec_watchdog(struct tsec_softc *sc) } static void -tsec_start(struct ifnet *ifp) +tsec_start(if_t ifp) { - struct tsec_softc *sc = ifp->if_softc; + struct tsec_softc *sc = if_getsoftc(ifp); TSEC_TRANSMIT_LOCK(sc); tsec_start_locked(ifp); @@ -719,7 +718,7 @@ tsec_start(struct ifnet *ifp) } static void -tsec_start_locked(struct ifnet *ifp) +tsec_start_locked(if_t ifp) { struct tsec_softc *sc; struct mbuf *m0; @@ -728,7 +727,7 @@ tsec_start_locked(struct ifnet *ifp) int start_tx; uint16_t fcb_flags; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); start_tx = 0; TSEC_TRANSMIT_LOCK_ASSERT(sc); @@ -742,12 +741,12 @@ tsec_start_locked(struct ifnet *ifp) for (;;) { if (TSEC_FREE_TX_DESC(sc) < TSEC_TX_MAX_DMA_SEGS) { /* No free descriptors */ - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); break; } /* Get packet from the queue */ - IFQ_DRV_DEQUEUE(&ifp->if_snd, m0); + m0 = if_dequeue(ifp); if (m0 == NULL) break; @@ -790,7 +789,7 @@ tsec_start_locked(struct ifnet *ifp) } static void -tsec_encap(struct ifnet *ifp, struct tsec_softc *sc, struct mbuf *m0, +tsec_encap(if_t ifp, struct tsec_softc *sc, struct mbuf *m0, uint16_t fcb_flags, int *start_tx) { bus_dma_segment_t segs[TSEC_TX_MAX_DMA_SEGS]; @@ -872,14 +871,14 @@ tsec_encap(struct ifnet *ifp, struct tsec_softc *sc, struct mbuf *m0, static void tsec_setfilter(struct tsec_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t flags; ifp = sc->tsec_ifp; flags = TSEC_READ(sc, TSEC_REG_RCTRL); /* Promiscuous mode */ - if (ifp->if_flags & IFF_PROMISC) + if (if_getflags(ifp) & IFF_PROMISC) flags |= TSEC_RCTRL_PROM; else flags &= ~TSEC_RCTRL_PROM; @@ -891,16 +890,16 @@ tsec_setfilter(struct tsec_softc *sc) static poll_handler_t tsec_poll; static int -tsec_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +tsec_poll(if_t ifp, enum poll_cmd cmd, int count) { uint32_t ie; - struct tsec_softc *sc = ifp->if_softc; + struct tsec_softc *sc = if_getsoftc(ifp); int rx_npkts; rx_npkts = 0; TSEC_GLOBAL_LOCK(sc); - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { TSEC_GLOBAL_UNLOCK(sc); return (rx_npkts); } @@ -926,9 +925,9 @@ tsec_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) #endif /* DEVICE_POLLING */ static int -tsec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) +tsec_ioctl(if_t ifp, u_long command, caddr_t data) { - struct tsec_softc *sc = ifp->if_softc; + struct tsec_softc *sc = if_getsoftc(ifp); struct ifreq *ifr = (struct ifreq *)data; int mask, error = 0; @@ -936,33 +935,33 @@ tsec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) case SIOCSIFMTU: TSEC_GLOBAL_LOCK(sc); if (tsec_set_mtu(sc, ifr->ifr_mtu)) - ifp->if_mtu = ifr->ifr_mtu; + if_setmtu(ifp, ifr->ifr_mtu); else error = EINVAL; TSEC_GLOBAL_UNLOCK(sc); break; case SIOCSIFFLAGS: TSEC_GLOBAL_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - if ((sc->tsec_if_flags ^ ifp->if_flags) & + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { + if ((sc->tsec_if_flags ^ if_getflags(ifp)) & IFF_PROMISC) tsec_setfilter(sc); - if ((sc->tsec_if_flags ^ ifp->if_flags) & + if ((sc->tsec_if_flags ^ if_getflags(ifp)) & IFF_ALLMULTI) tsec_setup_multicast(sc); } else tsec_init_locked(sc); - } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) + } else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) tsec_stop(sc); - sc->tsec_if_flags = ifp->if_flags; + sc->tsec_if_flags = if_getflags(ifp); TSEC_GLOBAL_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { TSEC_GLOBAL_LOCK(sc); tsec_setup_multicast(sc); TSEC_GLOBAL_UNLOCK(sc); @@ -973,11 +972,11 @@ tsec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) command); break; case SIOCSIFCAP: - mask = ifp->if_capenable ^ ifr->ifr_reqcap; + mask = if_getcapenable(ifp) ^ ifr->ifr_reqcap; if ((mask & IFCAP_HWCSUM) && sc->is_etsec) { TSEC_GLOBAL_LOCK(sc); - ifp->if_capenable &= ~IFCAP_HWCSUM; - ifp->if_capenable |= IFCAP_HWCSUM & ifr->ifr_reqcap; + if_setcapenablebit(ifp, 0, IFCAP_HWCSUM); + if_setcapenablebit(ifp, IFCAP_HWCSUM & ifr->ifr_reqcap, 0); tsec_offload_setup(sc); TSEC_GLOBAL_UNLOCK(sc); } @@ -991,14 +990,14 @@ tsec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) TSEC_GLOBAL_LOCK(sc); /* Disable interrupts */ tsec_intrs_ctl(sc, 0); - ifp->if_capenable |= IFCAP_POLLING; + if_setcapenablebit(ifp, IFCAP_POLLING, 0); TSEC_GLOBAL_UNLOCK(sc); } else { error = ether_poll_deregister(ifp); TSEC_GLOBAL_LOCK(sc); /* Enable interrupts */ tsec_intrs_ctl(sc, 1); - ifp->if_capenable &= ~IFCAP_POLLING; + if_setcapenablebit(ifp, 0, IFCAP_POLLING); TSEC_GLOBAL_UNLOCK(sc); } } @@ -1010,15 +1009,15 @@ tsec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) } /* Flush buffers if not empty */ - if (ifp->if_flags & IFF_UP) + if (if_getflags(ifp) & IFF_UP) tsec_start(ifp); return (error); } static int -tsec_ifmedia_upd(struct ifnet *ifp) +tsec_ifmedia_upd(if_t ifp) { - struct tsec_softc *sc = ifp->if_softc; + struct tsec_softc *sc = if_getsoftc(ifp); struct mii_data *mii; TSEC_TRANSMIT_LOCK(sc); @@ -1031,9 +1030,9 @@ tsec_ifmedia_upd(struct ifnet *ifp) } static void -tsec_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) +tsec_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr) { - struct tsec_softc *sc = ifp->if_softc; + struct tsec_softc *sc = if_getsoftc(ifp); struct mii_data *mii; TSEC_TRANSMIT_LOCK(sc); @@ -1213,7 +1212,7 @@ tsec_free_dma(struct tsec_softc *sc) static void tsec_stop(struct tsec_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t tmpval; TSEC_GLOBAL_LOCK_ASSERT(sc); @@ -1222,7 +1221,7 @@ tsec_stop(struct tsec_softc *sc) /* Disable interface and watchdog timer */ callout_stop(&sc->tsec_callout); - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); sc->tsec_watchdog = 0; /* Disable all interrupts and stop DMA */ @@ -1252,7 +1251,7 @@ static void tsec_tick(void *arg) { struct tsec_softc *sc = arg; - struct ifnet *ifp; + if_t ifp; int link; TSEC_GLOBAL_LOCK(sc); @@ -1265,7 +1264,7 @@ tsec_tick(void *arg) mii_tick(sc->tsec_mii); if (link == 0 && sc->tsec_link == 1 && - (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))) + (!if_sendq_empty(ifp))) tsec_start_locked(ifp); /* Schedule another timeout one second from now. */ @@ -1284,7 +1283,7 @@ static int tsec_receive_intr_locked(struct tsec_softc *sc, int count) { struct tsec_desc *rx_desc; - struct ifnet *ifp; + if_t ifp; struct rx_data_type *rx_data; struct mbuf *m; uint32_t i; @@ -1386,7 +1385,7 @@ tsec_receive_intr_locked(struct tsec_softc *sc, int count) tsec_offload_process_frame(sc, m); TSEC_RECEIVE_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); TSEC_RECEIVE_LOCK(sc); rx_npkts++; } @@ -1415,7 +1414,7 @@ tsec_receive_intr(void *arg) TSEC_RECEIVE_LOCK(sc); #ifdef DEVICE_POLLING - if (sc->tsec_ifp->if_capenable & IFCAP_POLLING) { + if (sc->tsec_if_getcapenable(ifp) & IFCAP_POLLING) { TSEC_RECEIVE_UNLOCK(sc); return; } @@ -1431,7 +1430,7 @@ tsec_receive_intr(void *arg) static void tsec_transmit_intr_locked(struct tsec_softc *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t tx_idx; TSEC_TRANSMIT_LOCK_ASSERT(sc); @@ -1481,7 +1480,7 @@ tsec_transmit_intr_locked(struct tsec_softc *sc) bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); tsec_start_locked(ifp); if (sc->tx_idx_tail == sc->tx_idx_head) @@ -1496,7 +1495,7 @@ tsec_transmit_intr(void *arg) TSEC_TRANSMIT_LOCK(sc); #ifdef DEVICE_POLLING - if (sc->tsec_ifp->if_capenable & IFCAP_POLLING) { + if (sc->tsec_if_getcapenable(ifp) & IFCAP_POLLING) { TSEC_TRANSMIT_UNLOCK(sc); return; } @@ -1511,7 +1510,7 @@ tsec_transmit_intr(void *arg) static void tsec_error_intr_locked(struct tsec_softc *sc, int count) { - struct ifnet *ifp; + if_t ifp; uint32_t eflags; TSEC_GLOBAL_LOCK_ASSERT(sc); @@ -1541,7 +1540,7 @@ tsec_error_intr_locked(struct tsec_softc *sc, int count) if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); } - if (ifp->if_flags & IFF_DEBUG) + if (if_getflags(ifp) & IFF_DEBUG) if_printf(ifp, "tsec_error_intr(): event flags: 0x%x\n", eflags); @@ -1817,7 +1816,7 @@ tsec_set_txic(struct tsec_softc *sc) static void tsec_offload_setup(struct tsec_softc *sc) { - struct ifnet *ifp = sc->tsec_ifp; + if_t ifp = sc->tsec_ifp; uint32_t reg; TSEC_GLOBAL_LOCK_ASSERT(sc); @@ -1825,10 +1824,10 @@ tsec_offload_setup(struct tsec_softc *sc) reg = TSEC_READ(sc, TSEC_REG_TCTRL); reg |= TSEC_TCTRL_IPCSEN | TSEC_TCTRL_TUCSEN; - if (ifp->if_capenable & IFCAP_TXCSUM) - ifp->if_hwassist = TSEC_CHECKSUM_FEATURES; + if (if_getcapenable(ifp) & IFCAP_TXCSUM) + if_sethwassist(ifp, TSEC_CHECKSUM_FEATURES); else - ifp->if_hwassist = 0; + if_sethwassist(ifp, 0); TSEC_WRITE(sc, TSEC_REG_TCTRL, reg); @@ -1836,7 +1835,7 @@ tsec_offload_setup(struct tsec_softc *sc) reg &= ~(TSEC_RCTRL_IPCSEN | TSEC_RCTRL_TUCSEN | TSEC_RCTRL_PRSDEP); reg |= TSEC_RCTRL_PRSDEP_PARSE_L2 | TSEC_RCTRL_VLEX; - if (ifp->if_capenable & IFCAP_RXCSUM) + if (if_getcapenable(ifp) & IFCAP_RXCSUM) reg |= TSEC_RCTRL_IPCSEN | TSEC_RCTRL_TUCSEN | TSEC_RCTRL_PRSDEP_PARSE_L234; @@ -1895,12 +1894,12 @@ static void tsec_setup_multicast(struct tsec_softc *sc) { uint32_t hashtable[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - struct ifnet *ifp = sc->tsec_ifp; + if_t ifp = sc->tsec_ifp; int i; TSEC_GLOBAL_LOCK_ASSERT(sc); - if (ifp->if_flags & IFF_ALLMULTI) { + if (if_getflags(ifp) & IFF_ALLMULTI) { for (i = 0; i < 8; i++) TSEC_WRITE(sc, TSEC_REG_GADDR(i), 0xFFFFFFFF); diff --git a/sys/dev/tsec/if_tsec.h b/sys/dev/tsec/if_tsec.h index dbd8bb7a035b..5fc5a7b8ff70 100644 --- a/sys/dev/tsec/if_tsec.h +++ b/sys/dev/tsec/if_tsec.h @@ -55,7 +55,7 @@ struct tsec_bufmap { struct tsec_softc { /* XXX MII bus requires that struct ifnet is first!!! */ - struct ifnet *tsec_ifp; + if_t tsec_ifp; struct mtx transmit_lock; /* transmitter lock */ struct mtx receive_lock; /* receiver lock */