git: 47842ecfe01d - main - Mechanically convert if_tsec(4) to IfAPI

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Mon, 06 Feb 2023 17:53:56 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=47842ecfe01d19516d7197603e5949d4dbb3e558

commit 47842ecfe01d19516d7197603e5949d4dbb3e558
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-03-01 19:49:10 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
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 */