git: 954712e8f622 - main - Mechanically convert cxgb(4) and cxgbe(4) to IfAPI

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Tue, 07 Mar 2023 20:29:12 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=954712e8f62273ec4c25d05cf56c23fd670d79c0

commit 954712e8f62273ec4c25d05cf56c23fd670d79c0
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-05-30 19:39:59 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-03-07 20:31:48 +0000

    Mechanically convert cxgb(4) and cxgbe(4) to IfAPI
    
    Reviewed by:    np
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D38597
---
 sys/dev/cxgb/common/cxgb_ctl_defs.h |   4 +-
 sys/dev/cxgb/cxgb_adapter.h         |   6 +-
 sys/dev/cxgb/cxgb_main.c            | 179 ++++++++++++-----------
 sys/dev/cxgb/cxgb_osdep.h           |   4 +-
 sys/dev/cxgb/cxgb_sge.c             |  28 ++--
 sys/dev/cxgbe/adapter.h             |  24 +--
 sys/dev/cxgbe/crypto/t6_kern_tls.c  |  10 +-
 sys/dev/cxgbe/iw_cxgbe/cm.c         |  12 +-
 sys/dev/cxgbe/iw_cxgbe/provider.c   |  10 +-
 sys/dev/cxgbe/t4_clip.c             |   6 +-
 sys/dev/cxgbe/t4_l2t.c              |   2 +-
 sys/dev/cxgbe/t4_l2t.h              |   2 +-
 sys/dev/cxgbe/t4_main.c             | 282 ++++++++++++++++++------------------
 sys/dev/cxgbe/t4_netmap.c           |  28 ++--
 sys/dev/cxgbe/t4_sched.c            |  14 +-
 sys/dev/cxgbe/t4_sge.c              |  46 +++---
 sys/dev/cxgbe/t4_tracer.c           |  57 ++++----
 sys/dev/cxgbe/tom/t4_connect.c      |  14 +-
 sys/dev/cxgbe/tom/t4_listen.c       |  22 +--
 sys/dev/cxgbe/tom/t4_tom_l2t.c      |  16 +-
 sys/dev/cxgbe/tom/t4_tom_l2t.h      |   4 +-
 21 files changed, 384 insertions(+), 386 deletions(-)

diff --git a/sys/dev/cxgb/common/cxgb_ctl_defs.h b/sys/dev/cxgb/common/cxgb_ctl_defs.h
index 188e54fb0fc2..369debe34e29 100644
--- a/sys/dev/cxgb/common/cxgb_ctl_defs.h
+++ b/sys/dev/cxgb/common/cxgb_ctl_defs.h
@@ -64,7 +64,7 @@ struct mtutab {
  * Structure used to request the ifnet that owns a given MAC address.
  */
 struct iff_mac {
-	struct ifnet *dev;
+	if_t dev;
 	const unsigned char *mac_addr;
 	u16 vlan_tag;
 };
@@ -83,7 +83,7 @@ struct ddp_params {
 
 struct adap_ports {
 	unsigned int nports;     /* number of ports on this adapter */
-	struct ifnet *lldevs[MAX_NPORTS];
+	if_t devs[MAX_NPORTS];
 };
 
 /*
diff --git a/sys/dev/cxgb/cxgb_adapter.h b/sys/dev/cxgb/cxgb_adapter.h
index ae5fa9f357c8..04ba7e056b31 100644
--- a/sys/dev/cxgb/cxgb_adapter.h
+++ b/sys/dev/cxgb/cxgb_adapter.h
@@ -90,7 +90,7 @@ enum {
 
 struct port_info {
 	struct adapter	*adapter;
-	struct ifnet	*ifp;
+	if_t		ifp;
 	int		if_flags;
 	int		flags;
 	const struct port_type_info *port_type;
@@ -549,8 +549,8 @@ static inline int offload_running(adapter_t *adapter)
 }
 
 void cxgb_tx_watchdog(void *arg);
-int cxgb_transmit(struct ifnet *ifp, struct mbuf *m);
-void cxgb_qflush(struct ifnet *ifp);
+int cxgb_transmit(if_t ifp, struct mbuf *m);
+void cxgb_qflush(if_t ifp);
 void t3_iterate(void (*)(struct adapter *, void *), void *);
 void cxgb_refresh_stats(struct port_info *);
 
diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c
index e31050a2f946..a2cf9d6b5a17 100644
--- a/sys/dev/cxgb/cxgb_main.c
+++ b/sys/dev/cxgb/cxgb_main.c
@@ -92,12 +92,12 @@ static void cxgb_init(void *);
 static int cxgb_init_locked(struct port_info *);
 static int cxgb_uninit_locked(struct port_info *);
 static int cxgb_uninit_synchronized(struct port_info *);
-static int cxgb_ioctl(struct ifnet *, unsigned long, caddr_t);
-static int cxgb_media_change(struct ifnet *);
+static int cxgb_ioctl(if_t, unsigned long, caddr_t);
+static int cxgb_media_change(if_t);
 static int cxgb_ifm_type(int);
 static void cxgb_build_medialist(struct port_info *);
-static void cxgb_media_status(struct ifnet *, struct ifmediareq *);
-static uint64_t cxgb_get_counter(struct ifnet *, ift_counter);
+static void cxgb_media_status(if_t, struct ifmediareq *);
+static uint64_t cxgb_get_counter(if_t, ift_counter);
 static int setup_sge_qsets(adapter_t *);
 static void cxgb_async_intr(void *);
 static void cxgb_tick_handler(void *, int);
@@ -983,7 +983,7 @@ static int
 cxgb_makedev(struct port_info *pi)
 {
 	
-	pi->port_cdev = make_dev(&cxgb_cdevsw, pi->ifp->if_dunit,
+	pi->port_cdev = make_dev(&cxgb_cdevsw, if_getdunit(pi->ifp),
 	    UID_ROOT, GID_WHEEL, 0600, "%s", if_name(pi->ifp));
 	
 	if (pi->port_cdev == NULL)
@@ -1003,7 +1003,7 @@ static int
 cxgb_port_attach(device_t dev)
 {
 	struct port_info *p;
-	struct ifnet *ifp;
+	if_t ifp;
 	int err;
 	struct adapter *sc;
 
@@ -1024,33 +1024,33 @@ cxgb_port_attach(device_t dev)
 	}
 	
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_init = cxgb_init;
-	ifp->if_softc = p;
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-	ifp->if_ioctl = cxgb_ioctl;
-	ifp->if_transmit = cxgb_transmit;
-	ifp->if_qflush = cxgb_qflush;
-	ifp->if_get_counter = cxgb_get_counter;
-
-	ifp->if_capabilities = CXGB_CAP;
+	if_setinitfn(ifp, cxgb_init);
+	if_setsoftc(ifp, p);
+	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+	if_setioctlfn(ifp, cxgb_ioctl);
+	if_settransmitfn(ifp, cxgb_transmit);
+	if_setqflushfn(ifp, cxgb_qflush);
+	if_setgetcounterfn(ifp, cxgb_get_counter);
+
+	if_setcapabilities(ifp, CXGB_CAP);
 #ifdef TCP_OFFLOAD
 	if (is_offload(sc))
-		ifp->if_capabilities |= IFCAP_TOE4;
+		if_setcapabilitiesbit(ifp, IFCAP_TOE4, 0);
 #endif
-	ifp->if_capenable = CXGB_CAP_ENABLE;
-	ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO |
-	    CSUM_UDP_IPV6 | CSUM_TCP_IPV6;
-	ifp->if_hw_tsomax = IP_MAXPACKET;
-	ifp->if_hw_tsomaxsegcount = 36;
-	ifp->if_hw_tsomaxsegsize = 65536;
+	if_setcapenable(ifp, CXGB_CAP_ENABLE);
+	if_sethwassist(ifp, CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO |
+	    CSUM_UDP_IPV6 | CSUM_TCP_IPV6);
+	if_sethwtsomax(ifp, IP_MAXPACKET);
+	if_sethwtsomaxsegcount(ifp, 36);
+	if_sethwtsomaxsegsize(ifp, 65536);
 
 	/*
 	 * Disable TSO on 4-port - it isn't supported by the firmware.
 	 */	
 	if (sc->params.nports > 2) {
-		ifp->if_capabilities &= ~(IFCAP_TSO | IFCAP_VLAN_HWTSO);
-		ifp->if_capenable &= ~(IFCAP_TSO | IFCAP_VLAN_HWTSO);
-		ifp->if_hwassist &= ~CSUM_TSO;
+		if_setcapabilitiesbit(ifp, 0, IFCAP_TSO | IFCAP_VLAN_HWTSO);
+		if_setcapenablebit(ifp, 0, IFCAP_TSO | IFCAP_VLAN_HWTSO);
+		if_sethwassistbits(ifp, 0, CSUM_TSO);
 	}
 
 	ether_ifattach(ifp, p->hw_addr);
@@ -1060,7 +1060,7 @@ cxgb_port_attach(device_t dev)
 
 #ifdef DEFAULT_JUMBO
 	if (sc->params.nports <= 2)
-		ifp->if_mtu = ETHERMTU_JUMBO;
+		if_setmtu(ifp, ETHERMTU_JUMBO);
 #endif
 	if ((err = cxgb_makedev(p)) != 0) {
 		printf("makedev failed %d\n", err);
@@ -1231,7 +1231,7 @@ t3_os_link_changed(adapter_t *adapter, int port_id, int link_status, int speed,
      int duplex, int fc, int mac_was_reset)
 {
 	struct port_info *pi = &adapter->port[port_id];
-	struct ifnet *ifp = pi->ifp;
+	if_t ifp = pi->ifp;
 
 	/* no race with detach, so ifp should always be good */
 	KASSERT(ifp, ("%s: if detached.", __func__));
@@ -1244,7 +1244,7 @@ t3_os_link_changed(adapter_t *adapter, int port_id, int link_status, int speed,
 	}
 
 	if (link_status) {
-		ifp->if_baudrate = IF_Mbps(speed);
+		if_setbaudrate(ifp, IF_Mbps(speed));
 		if_link_state_change(ifp, LINK_STATE_UP);
 	} else
 		if_link_state_change(ifp, LINK_STATE_DOWN);
@@ -1300,20 +1300,20 @@ t3_os_set_hw_addr(adapter_t *adapter, int port_idx, u8 hw_addr[])
 static void
 cxgb_update_mac_settings(struct port_info *p)
 {
-	struct ifnet *ifp = p->ifp;
+	if_t ifp = p->ifp;
 	struct t3_rx_mode rm;
 	struct cmac *mac = &p->mac;
 	int mtu, hwtagging;
 
 	PORT_LOCK_ASSERT_OWNED(p);
 
-	bcopy(IF_LLADDR(ifp), p->hw_addr, ETHER_ADDR_LEN);
+	bcopy(if_getlladdr(ifp), p->hw_addr, ETHER_ADDR_LEN);
 
-	mtu = ifp->if_mtu;
-	if (ifp->if_capenable & IFCAP_VLAN_MTU)
+	mtu = if_getmtu(ifp);
+	if (if_getcapenable(ifp) & IFCAP_VLAN_MTU)
 		mtu += ETHER_VLAN_ENCAP_LEN;
 
-	hwtagging = (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0;
+	hwtagging = (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0;
 
 	t3_mac_set_mtu(mac, mtu);
 	t3_set_vlan_accel(p->adapter, 1 << p->tx_chan, hwtagging);
@@ -1686,7 +1686,7 @@ static int
 cxgb_init_locked(struct port_info *p)
 {
 	struct adapter *sc = p->adapter;
-	struct ifnet *ifp = p->ifp;
+	if_t ifp = p->ifp;
 	struct cmac *mac = &p->mac;
 	int i, rc = 0, may_sleep = 0, gave_up_lock = 0;
 
@@ -1722,7 +1722,7 @@ cxgb_init_locked(struct port_info *p)
 
 	PORT_LOCK(p);
 	if (isset(&sc->open_device_map, p->port_id) &&
-	    (ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+	    (if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
 		PORT_UNLOCK(p);
 		goto done;
 	}
@@ -1732,8 +1732,7 @@ cxgb_init_locked(struct port_info *p)
 	cxgb_update_mac_settings(p);
 	t3_link_start(&p->phy, mac, &p->link_config);
 	t3_mac_enable(mac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
-	ifp->if_drv_flags |= IFF_DRV_RUNNING;
-	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+	if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE);
 	PORT_UNLOCK(p);
 
 	for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) {
@@ -1802,7 +1801,7 @@ static int
 cxgb_uninit_synchronized(struct port_info *pi)
 {
 	struct adapter *sc = pi->adapter;
-	struct ifnet *ifp = pi->ifp;
+	if_t ifp = pi->ifp;
 
 	/*
 	 * taskqueue_drain may cause a deadlock if the adapter lock is held.
@@ -1829,7 +1828,7 @@ cxgb_uninit_synchronized(struct port_info *pi)
 	taskqueue_drain(sc->tq, &pi->link_check_task);
 
 	PORT_LOCK(pi);
-	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+	if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
 
 	/* disable pause frames */
 	t3_set_reg_field(sc, A_XGM_TX_CFG + pi->mac.offset, F_TXPAUSEEN, 0);
@@ -1878,9 +1877,9 @@ cxgb_set_lro(struct port_info *p, int enabled)
 }
 
 static int
-cxgb_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
+cxgb_ioctl(if_t ifp, unsigned long command, caddr_t data)
 {
-	struct port_info *p = ifp->if_softc;
+	struct port_info *p = if_getsoftc(ifp);
 	struct adapter *sc = p->adapter;
 	struct ifreq *ifr = (struct ifreq *)data;
 	int flags, error = 0, mtu;
@@ -1900,7 +1899,7 @@ fail:
 		if ((mtu < ETHERMIN) || (mtu > ETHERMTU_JUMBO)) {
 			error = EINVAL;
 		} else {
-			ifp->if_mtu = mtu;
+			if_setmtu(ifp, mtu);
 			PORT_LOCK(p);
 			cxgb_update_mac_settings(p);
 			PORT_UNLOCK(p);
@@ -1913,11 +1912,11 @@ fail:
 			error = ENXIO;
 			goto fail;
 		}
-		if (ifp->if_flags & IFF_UP) {
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+		if (if_getflags(ifp) & IFF_UP) {
+			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 				flags = p->if_flags;
-				if (((ifp->if_flags ^ flags) & IFF_PROMISC) ||
-				    ((ifp->if_flags ^ flags) & IFF_ALLMULTI)) {
+				if (((if_getflags(ifp) ^ flags) & IFF_PROMISC) ||
+				    ((if_getflags(ifp) ^ flags) & IFF_ALLMULTI)) {
 					if (IS_BUSY(sc)) {
 						error = EBUSY;
 						goto fail;
@@ -1929,8 +1928,8 @@ fail:
 				ADAPTER_UNLOCK(sc);
 			} else
 				error = cxgb_init_locked(p);
-			p->if_flags = ifp->if_flags;
-		} else if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+			p->if_flags = if_getflags(ifp);
+		} else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
 			error = cxgb_uninit_locked(p);
 		else
 			ADAPTER_UNLOCK(sc);
@@ -1944,7 +1943,7 @@ fail:
 		if (error)
 			goto fail;
 
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+		if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 			PORT_LOCK(p);
 			cxgb_update_mac_settings(p);
 			PORT_UNLOCK(p);
@@ -1958,35 +1957,35 @@ fail:
 		if (error)
 			goto fail;
 
-		mask = ifr->ifr_reqcap ^ ifp->if_capenable;
+		mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
 		if (mask & IFCAP_TXCSUM) {
-			ifp->if_capenable ^= IFCAP_TXCSUM;
-			ifp->if_hwassist ^= (CSUM_TCP | CSUM_UDP | CSUM_IP);
+			if_togglecapenable(ifp, IFCAP_TXCSUM);
+			if_togglehwassist(ifp, CSUM_TCP | CSUM_UDP | CSUM_IP);
 
-			if (IFCAP_TSO4 & ifp->if_capenable &&
-			    !(IFCAP_TXCSUM & ifp->if_capenable)) {
+			if (IFCAP_TSO4 & if_getcapenable(ifp) &&
+			    !(IFCAP_TXCSUM & if_getcapenable(ifp))) {
 				mask &= ~IFCAP_TSO4;
-				ifp->if_capenable &= ~IFCAP_TSO4;
+				if_setcapenablebit(ifp, 0, IFCAP_TSO4);
 				if_printf(ifp,
 				    "tso4 disabled due to -txcsum.\n");
 			}
 		}
 		if (mask & IFCAP_TXCSUM_IPV6) {
-			ifp->if_capenable ^= IFCAP_TXCSUM_IPV6;
-			ifp->if_hwassist ^= (CSUM_UDP_IPV6 | CSUM_TCP_IPV6);
+			if_togglecapenable(ifp, IFCAP_TXCSUM_IPV6);
+			if_togglehwassist(ifp, CSUM_UDP_IPV6 | CSUM_TCP_IPV6);
 
-			if (IFCAP_TSO6 & ifp->if_capenable &&
-			    !(IFCAP_TXCSUM_IPV6 & ifp->if_capenable)) {
+			if (IFCAP_TSO6 & if_getcapenable(ifp) &&
+			    !(IFCAP_TXCSUM_IPV6 & if_getcapenable(ifp))) {
 				mask &= ~IFCAP_TSO6;
-				ifp->if_capenable &= ~IFCAP_TSO6;
+				if_setcapenablebit(ifp, 0, IFCAP_TSO6);
 				if_printf(ifp,
 				    "tso6 disabled due to -txcsum6.\n");
 			}
 		}
 		if (mask & IFCAP_RXCSUM)
-			ifp->if_capenable ^= IFCAP_RXCSUM;
+			if_togglecapenable(ifp, IFCAP_RXCSUM);
 		if (mask & IFCAP_RXCSUM_IPV6)
-			ifp->if_capenable ^= IFCAP_RXCSUM_IPV6;
+			if_togglecapenable(ifp, IFCAP_RXCSUM_IPV6);
 
 		/*
 		 * Note that we leave CSUM_TSO alone (it is always set).  The
@@ -1995,58 +1994,58 @@ fail:
 		 * IFCAP_TSOx only.
 		 */
 		if (mask & IFCAP_TSO4) {
-			if (!(IFCAP_TSO4 & ifp->if_capenable) &&
-			    !(IFCAP_TXCSUM & ifp->if_capenable)) {
+			if (!(IFCAP_TSO4 & if_getcapenable(ifp)) &&
+			    !(IFCAP_TXCSUM & if_getcapenable(ifp))) {
 				if_printf(ifp, "enable txcsum first.\n");
 				error = EAGAIN;
 				goto fail;
 			}
-			ifp->if_capenable ^= IFCAP_TSO4;
+			if_togglecapenable(ifp, IFCAP_TSO4);
 		}
 		if (mask & IFCAP_TSO6) {
-			if (!(IFCAP_TSO6 & ifp->if_capenable) &&
-			    !(IFCAP_TXCSUM_IPV6 & ifp->if_capenable)) {
+			if (!(IFCAP_TSO6 & if_getcapenable(ifp)) &&
+			    !(IFCAP_TXCSUM_IPV6 & if_getcapenable(ifp))) {
 				if_printf(ifp, "enable txcsum6 first.\n");
 				error = EAGAIN;
 				goto fail;
 			}
-			ifp->if_capenable ^= IFCAP_TSO6;
+			if_togglecapenable(ifp, IFCAP_TSO6);
 		}
 		if (mask & IFCAP_LRO) {
-			ifp->if_capenable ^= IFCAP_LRO;
+			if_togglecapenable(ifp, IFCAP_LRO);
 
 			/* Safe to do this even if cxgb_up not called yet */
-			cxgb_set_lro(p, ifp->if_capenable & IFCAP_LRO);
+			cxgb_set_lro(p, if_getcapenable(ifp) & IFCAP_LRO);
 		}
 #ifdef TCP_OFFLOAD
 		if (mask & IFCAP_TOE4) {
-			int enable = (ifp->if_capenable ^ mask) & IFCAP_TOE4;
+			int enable = (if_getcapenable(ifp) ^ mask) & IFCAP_TOE4;
 
 			error = toe_capability(p, enable);
 			if (error == 0)
-				ifp->if_capenable ^= mask;
+				if_togglecapenable(ifp, mask);
 		}
 #endif
 		if (mask & IFCAP_VLAN_HWTAGGING) {
-			ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+			if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
+			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 				PORT_LOCK(p);
 				cxgb_update_mac_settings(p);
 				PORT_UNLOCK(p);
 			}
 		}
 		if (mask & IFCAP_VLAN_MTU) {
-			ifp->if_capenable ^= IFCAP_VLAN_MTU;
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+			if_togglecapenable(ifp, IFCAP_VLAN_MTU);
+			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 				PORT_LOCK(p);
 				cxgb_update_mac_settings(p);
 				PORT_UNLOCK(p);
 			}
 		}
 		if (mask & IFCAP_VLAN_HWTSO)
-			ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
+			if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
 		if (mask & IFCAP_VLAN_HWCSUM)
-			ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
+			if_togglecapenable(ifp, IFCAP_VLAN_HWCSUM);
 
 #ifdef VLAN_CAPABILITIES
 		VLAN_CAPABILITIES(ifp);
@@ -2065,7 +2064,7 @@ fail:
 }
 
 static int
-cxgb_media_change(struct ifnet *ifp)
+cxgb_media_change(if_t ifp)
 {
 	return (EOPNOTSUPP);
 }
@@ -2166,9 +2165,9 @@ cxgb_build_medialist(struct port_info *p)
 }
 
 static void
-cxgb_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+cxgb_media_status(if_t ifp, struct ifmediareq *ifmr)
 {
-	struct port_info *p = ifp->if_softc;
+	struct port_info *p = if_getsoftc(ifp);
 	struct ifmedia_entry *cur = p->media.ifm_cur;
 	int speed = p->link_config.speed;
 
@@ -2207,9 +2206,9 @@ cxgb_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
 }
 
 static uint64_t
-cxgb_get_counter(struct ifnet *ifp, ift_counter c)
+cxgb_get_counter(if_t ifp, ift_counter c)
 {
-	struct port_info *pi = ifp->if_softc;
+	struct port_info *pi = if_getsoftc(ifp);
 	struct adapter *sc = pi->adapter;
 	struct cmac *mac = &pi->mac;
 	struct mac_stats *mstats = &mac->stats;
@@ -2332,16 +2331,16 @@ check_t3b2_mac(struct adapter *sc)
 		struct port_info *p = &sc->port[i];
 		int status;
 #ifdef INVARIANTS
-		struct ifnet *ifp = p->ifp;
+		if_t ifp = p->ifp;
 #endif		
 
 		if (!isset(&sc->open_device_map, p->port_id) || p->link_fault ||
 		    !p->link_config.link_ok)
 			continue;
 
-		KASSERT(ifp->if_drv_flags & IFF_DRV_RUNNING,
+		KASSERT(if_getdrvflags(ifp) & IFF_DRV_RUNNING,
 			("%s: state mismatch (drv_flags %x, device_map %x)",
-			 __func__, ifp->if_drv_flags, sc->open_device_map));
+			 __func__, if_getdrvflags(ifp), sc->open_device_map));
 
 		PORT_LOCK(p);
 		status = t3b2_mac_watchdog_task(&p->mac);
@@ -3596,7 +3595,7 @@ cxgbc_mod_event(module_t mod, int cmd, void *arg)
 
 #ifdef DEBUGNET
 static void
-cxgb_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+cxgb_debugnet_init(if_t ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct port_info *pi;
 	adapter_t *adap;
@@ -3611,7 +3610,7 @@ cxgb_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 }
 
 static void
-cxgb_debugnet_event(struct ifnet *ifp, enum debugnet_ev event)
+cxgb_debugnet_event(if_t ifp, enum debugnet_ev event)
 {
 	struct port_info *pi;
 	struct sge_qset *qs;
@@ -3630,7 +3629,7 @@ cxgb_debugnet_event(struct ifnet *ifp, enum debugnet_ev event)
 }
 
 static int
-cxgb_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
+cxgb_debugnet_transmit(if_t ifp, struct mbuf *m)
 {
 	struct port_info *pi;
 	struct sge_qset *qs;
@@ -3645,7 +3644,7 @@ cxgb_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
 }
 
 static int
-cxgb_debugnet_poll(struct ifnet *ifp, int count)
+cxgb_debugnet_poll(if_t ifp, int count)
 {
 	struct port_info *pi;
 	adapter_t *adap;
diff --git a/sys/dev/cxgb/cxgb_osdep.h b/sys/dev/cxgb/cxgb_osdep.h
index e3f745fee020..d5e7f84d523d 100644
--- a/sys/dev/cxgb/cxgb_osdep.h
+++ b/sys/dev/cxgb/cxgb_osdep.h
@@ -123,8 +123,8 @@ static const int debug_flags = DBG_RX;
 
 #include <sys/syslog.h>
 
-#define promisc_rx_mode(rm)  ((rm)->port->ifp->if_flags & IFF_PROMISC) 
-#define allmulti_rx_mode(rm) ((rm)->port->ifp->if_flags & IFF_ALLMULTI) 
+#define promisc_rx_mode(rm)  (if_getflags((rm)->port->ifp) & IFF_PROMISC)
+#define allmulti_rx_mode(rm) (if_getflags((rm)->port->ifp) & IFF_ALLMULTI)
 
 #define CH_ERR(adap, fmt, ...) log(LOG_ERR, fmt, ##__VA_ARGS__)
 #define CH_WARN(adap, fmt, ...)	log(LOG_WARNING, fmt, ##__VA_ARGS__)
diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c
index f79149e8e7e6..f422bda61e22 100644
--- a/sys/dev/cxgb/cxgb_sge.c
+++ b/sys/dev/cxgb/cxgb_sge.c
@@ -1626,7 +1626,7 @@ cxgb_tx_watchdog(void *arg)
 		qs->qs_flags &= ~QS_FLUSHING;
 		TXQ_UNLOCK(qs);
 	}
-	if (qs->port->ifp->if_drv_flags & IFF_DRV_RUNNING)
+	if (if_getdrvflags(qs->port->ifp) & IFF_DRV_RUNNING)
 		callout_reset_on(&txq->txq_watchdog, hz/4, cxgb_tx_watchdog,
 		    qs, txq->txq_watchdog.c_cpu);
 }
@@ -1653,7 +1653,7 @@ cxgb_start_locked(struct sge_qset *qs)
 	struct mbuf *m_head = NULL;
 	struct sge_txq *txq = &qs->txq[TXQ_ETH];
 	struct port_info *pi = qs->port;
-	struct ifnet *ifp = pi->ifp;
+	if_t ifp = pi->ifp;
 
 	if (qs->qs_flags & (QS_FLUSHING|QS_TIMEOUT))
 		reclaim_completed_tx(qs, 0, TXQ_ETH);
@@ -1663,7 +1663,7 @@ cxgb_start_locked(struct sge_qset *qs)
 		return;
 	}
 	TXQ_LOCK_ASSERT(qs);
-	while (!TXQ_RING_EMPTY(qs) && (ifp->if_drv_flags & IFF_DRV_RUNNING) &&
+	while (!TXQ_RING_EMPTY(qs) && (if_getdrvflags(ifp) & IFF_DRV_RUNNING) &&
 	    pi->link_config.link_ok) {
 		reclaim_completed_tx(qs, cxgb_tx_reclaim_threshold, TXQ_ETH);
 
@@ -1694,7 +1694,7 @@ cxgb_start_locked(struct sge_qset *qs)
 }
 
 static int
-cxgb_transmit_locked(struct ifnet *ifp, struct sge_qset *qs, struct mbuf *m)
+cxgb_transmit_locked(if_t ifp, struct sge_qset *qs, struct mbuf *m)
 {
 	struct port_info *pi = qs->port;
 	struct sge_txq *txq = &qs->txq[TXQ_ETH];
@@ -1742,13 +1742,13 @@ cxgb_transmit_locked(struct ifnet *ifp, struct sge_qset *qs, struct mbuf *m)
 }
 
 int
-cxgb_transmit(struct ifnet *ifp, struct mbuf *m)
+cxgb_transmit(if_t ifp, struct mbuf *m)
 {
 	struct sge_qset *qs;
-	struct port_info *pi = ifp->if_softc;
+	struct port_info *pi = if_getsoftc(ifp);
 	int error, qidx = pi->first_qset;
 
-	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0
+	if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0
 	    ||(!pi->link_config.link_ok)) {
 		m_freem(m);
 		return (0);
@@ -1770,7 +1770,7 @@ cxgb_transmit(struct ifnet *ifp, struct mbuf *m)
 }
 
 void
-cxgb_qflush(struct ifnet *ifp)
+cxgb_qflush(if_t ifp)
 {
 	/*
 	 * flush any enqueued mbufs in the buf_rings
@@ -2528,7 +2528,7 @@ t3_sge_alloc_qset(adapter_t *sc, u_int id, int nports, int irq_vec_idx,
 	q->fl[1].buf_size = p->jumbo_buf_size;
 
 	/* Allocate and setup the lro_ctrl structure */
-	q->lro.enabled = !!(pi->ifp->if_capenable & IFCAP_LRO);
+	q->lro.enabled = !!(if_getcapenable(pi->ifp) & IFCAP_LRO);
 #if defined(INET6) || defined(INET)
 	ret = tcp_lro_init(&q->lro.ctrl);
 	if (ret) {
@@ -2621,7 +2621,7 @@ t3_rx_eth(struct adapter *adap, struct mbuf *m, int ethpad)
 {
 	struct cpl_rx_pkt *cpl = (struct cpl_rx_pkt *)(mtod(m, uint8_t *) + ethpad);
 	struct port_info *pi = &adap->port[adap->rxpkt_map[cpl->iff]];
-	struct ifnet *ifp = pi->ifp;
+	if_t ifp = pi->ifp;
 	
 	if (cpl->vlan_valid) {
 		m->m_pkthdr.ether_vtag = ntohs(cpl->vlan);
@@ -2647,12 +2647,12 @@ t3_rx_eth(struct adapter *adap, struct mbuf *m, int ethpad)
 		} else
 			eh_type = eh->ether_type;
 
-		if (ifp->if_capenable & IFCAP_RXCSUM &&
+		if (if_getcapenable(ifp) & IFCAP_RXCSUM &&
 		    eh_type == htons(ETHERTYPE_IP)) {
 			m->m_pkthdr.csum_flags = (CSUM_IP_CHECKED |
 			    CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
 			m->m_pkthdr.csum_data = 0xffff;
-		} else if (ifp->if_capenable & IFCAP_RXCSUM_IPV6 &&
+		} else if (if_getcapenable(ifp) & IFCAP_RXCSUM_IPV6 &&
 		    eh_type == htons(ETHERTYPE_IPV6)) {
 			m->m_pkthdr.csum_flags = (CSUM_DATA_VALID_IPV6 |
 			    CSUM_PSEUDO_HDR);
@@ -2953,8 +2953,8 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget)
 				 * or unable to queue.  Pass it up right now in
 				 * either case.
 				 */
-				struct ifnet *ifp = m->m_pkthdr.rcvif;
-				(*ifp->if_input)(ifp, m);
+				if_t ifp = m->m_pkthdr.rcvif;
+				if_input(ifp, m);
 			}
 			mh->mh_head = NULL;
 
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 4206bca95cdf..2a5f50f51d13 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -197,7 +197,7 @@ struct vi_info {
 	struct port_info *pi;
 	struct adapter *adapter;
 
-	struct ifnet *ifp;
+	if_t ifp;
 	struct pfil_head *pfil;
 
 	unsigned long flags;
@@ -603,7 +603,7 @@ struct txpkts {
 struct sge_txq {
 	struct sge_eq eq;	/* MUST be first */
 
-	struct ifnet *ifp;	/* the interface this txq belongs to */
+	if_t ifp;		/* the interface this txq belongs to */
 	struct mp_ring *r;	/* tx software ring */
 	struct tx_sdesc *sdesc;	/* KVA of software descriptor ring */
 	struct sglist *gl;
@@ -654,7 +654,7 @@ struct sge_rxq {
 	struct sge_iq iq;	/* MUST be first */
 	struct sge_fl fl;	/* MUST follow iq */
 
-	struct ifnet *ifp;	/* the interface this rxq belongs to */
+	if_t ifp;		/* the interface this rxq belongs to */
 	struct lro_ctrl lro;	/* LRO state */
 
 	/* stats for common events first */
@@ -956,7 +956,7 @@ struct adapter {
 
 	char ifp_lockname[16];
 	struct mtx ifp_lock;
-	struct ifnet *ifp;	/* tracer ifp */
+	if_t ifp;		/* tracer ifp */
 	struct ifmedia media;
 	int traceq;		/* iq used by all tracers, -1 if none */
 	int tracer_valid;	/* bitmap of valid tracers */
@@ -1359,7 +1359,7 @@ void t4_sysctls(struct adapter *);
 int begin_synchronized_op(struct adapter *, struct vi_info *, int, char *);
 void doom_vi(struct adapter *, struct vi_info *);
 void end_synchronized_op(struct adapter *, int);
-int update_mac_settings(struct ifnet *, int);
+int update_mac_settings(if_t, int);
 int adapter_init(struct adapter *);
 int vi_init(struct vi_info *);
 void vi_sysctls(struct vi_info *);
@@ -1368,17 +1368,17 @@ int alloc_atid(struct adapter *, void *);
 void *lookup_atid(struct adapter *, int);
 void free_atid(struct adapter *, int);
 void release_tid(struct adapter *, int, struct sge_wrq *);
-int cxgbe_media_change(struct ifnet *);
-void cxgbe_media_status(struct ifnet *, struct ifmediareq *);
+int cxgbe_media_change(if_t);
+void cxgbe_media_status(if_t, struct ifmediareq *);
 void t4_os_cim_err(struct adapter *);
 
 #ifdef KERN_TLS
 /* t6_kern_tls.c */
-int t6_tls_tag_alloc(struct ifnet *, union if_snd_tag_alloc_params *,
+int t6_tls_tag_alloc(if_t, union if_snd_tag_alloc_params *,
     struct m_snd_tag **);
 void t6_ktls_modload(void);
 void t6_ktls_modunload(void);
-int t6_ktls_try(struct ifnet *, struct socket *, struct ktls_session *);
+int t6_ktls_try(if_t, struct socket *, struct ktls_session *);
 int t6_ktls_parse_pkt(struct mbuf *);
 int t6_ktls_write_wr(struct sge_txq *, void *, struct mbuf *, u_int);
 #endif
@@ -1451,7 +1451,7 @@ void t4_vi_intr(void *);
 void t4_intr_err(void *);
 void t4_intr_evt(void *);
 void t4_wrq_tx_locked(struct adapter *, struct sge_wrq *, struct wrqe *);
-void t4_update_fl_bufsize(struct ifnet *);
+void t4_update_fl_bufsize(if_t);
 struct mbuf *alloc_wr_mbuf(int, int);
 int parse_pkt(struct mbuf **, bool);
 void *start_wrq_wr(struct sge_wrq *, int, struct wrq_cookie *);
@@ -1489,10 +1489,10 @@ int sysctl_tc_params(SYSCTL_HANDLER_ARGS);
 void t4_init_etid_table(struct adapter *);
 void t4_free_etid_table(struct adapter *);
 struct cxgbe_rate_tag *lookup_etid(struct adapter *, int);
-int cxgbe_rate_tag_alloc(struct ifnet *, union if_snd_tag_alloc_params *,
+int cxgbe_rate_tag_alloc(if_t, union if_snd_tag_alloc_params *,
     struct m_snd_tag **);
 void cxgbe_rate_tag_free_locked(struct cxgbe_rate_tag *);
-void cxgbe_ratelimit_query(struct ifnet *, struct if_ratelimit_query_results *);
+void cxgbe_ratelimit_query(if_t, struct if_ratelimit_query_results *);
 #endif
 
 /* t4_filter.c */
diff --git a/sys/dev/cxgbe/crypto/t6_kern_tls.c b/sys/dev/cxgbe/crypto/t6_kern_tls.c
index f1302d063051..2b50899ba17a 100644
--- a/sys/dev/cxgbe/crypto/t6_kern_tls.c
+++ b/sys/dev/cxgbe/crypto/t6_kern_tls.c
@@ -118,7 +118,7 @@ mst_to_tls(struct m_snd_tag *t)
 }
 
 static struct tlspcb *
-alloc_tlspcb(struct ifnet *ifp, struct vi_info *vi, int flags)
+alloc_tlspcb(if_t ifp, struct vi_info *vi, int flags)
 {
 	struct port_info *pi = vi->pi;
 	struct adapter *sc = pi->adapter;
@@ -373,7 +373,7 @@ ktls_set_tcb_fields(struct tlspcb *tlsp, struct tcpcb *tp, struct sge_txq *txq)
 }
 
 int
-t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
+t6_tls_tag_alloc(if_t ifp, union if_snd_tag_alloc_params *params,
     struct m_snd_tag **pt)
 {
 	const struct ktls_session *tls;
@@ -434,7 +434,7 @@ t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
 		return (EPROTONOSUPPORT);
 	}
 
-	vi = ifp->if_softc;
+	vi = if_getsoftc(ifp);
 	sc = vi->adapter;
 
 	tlsp = alloc_tlspcb(ifp, vi, M_WAITOK);
@@ -1761,7 +1761,7 @@ ktls_write_tls_wr(struct tlspcb *tlsp, struct sge_txq *txq, void *dst,
 	} else if (tlsp->prev_mss != 0)
 		mss = tlsp->prev_mss;
 	else
-		mss = tlsp->vi->ifp->if_mtu -
+		mss = if_getmtu(tlsp->vi->ifp) -
 		    (m->m_pkthdr.l3hlen + m->m_pkthdr.l4hlen);
 	if (offset == 0) {
 		tx_data->len = htobe32(V_TX_DATA_MSS(mss) | V_TX_LENGTH(tlen));
@@ -2109,7 +2109,7 @@ t6_ktls_modunload(void)
 #else
 
 int
-t6_tls_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
+t6_tls_tag_alloc(if_t ifp, union if_snd_tag_alloc_params *params,
     struct m_snd_tag **pt)
 {
 	return (ENXIO);
diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index 08d507524c01..457290875583 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -128,7 +128,7 @@ static int rem_ep_from_listenlist(struct c4iw_listen_ep *lep);
 static struct c4iw_listen_ep *
 find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so);
 static int get_ifnet_from_raddr(struct sockaddr_storage *raddr,
-		struct ifnet **ifp);
+		if_t *ifp);
 static void process_newconn(struct c4iw_listen_ep *master_lep,
 		struct socket *new_so);
 #define START_EP_TIMER(ep) \
@@ -337,7 +337,7 @@ find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so)
 {
 	struct adapter *adap = NULL;
 	struct c4iw_listen_ep *lep = NULL;
-	struct ifnet *ifp = NULL, *hw_ifp = NULL;
+	if_t ifp = NULL, hw_ifp = NULL;
 	struct listen_port_info *port_info = NULL;
 	int i = 0, found_portinfo = 0, found_lep = 0;
 	uint16_t port;
@@ -348,7 +348,7 @@ find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so)
 	 * TBD: lagg support, lagg + vlan support.
 	 */
 	ifp = TOEPCB(so)->l2te->ifp;
-	if (ifp->if_type == IFT_L2VLAN) {
+	if (if_gettype(ifp) == IFT_L2VLAN) {
 		hw_ifp = VLAN_TRUNKDEV(ifp);
 		if (hw_ifp == NULL) {
 			CTR4(KTR_IW_CXGBE, "%s: Failed to get parent ifnet of "
@@ -533,7 +533,7 @@ done:
 
 }
 static int
-get_ifnet_from_raddr(struct sockaddr_storage *raddr, struct ifnet **ifp)
+get_ifnet_from_raddr(struct sockaddr_storage *raddr, if_t *ifp)
 {
 	int err = 0;
 	struct nhop_object *nh;
@@ -2593,7 +2593,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 	int err = 0;
 	struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
 	struct c4iw_ep *ep = NULL;
-	struct ifnet    *nh_ifp;        /* Logical egress interface */
+	if_t nh_ifp;        /* Logical egress interface */
 	struct epoch_tracker et;
 #ifdef VIMAGE
 	struct rdma_cm_id *rdma_id = (struct rdma_cm_id*)cm_id->context;
@@ -2659,7 +2659,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 		return err;
 	}
 
-	if (!(nh_ifp->if_capenable & IFCAP_TOE) ||
+	if (!(if_getcapenable(nh_ifp) & IFCAP_TOE) ||
 	    TOEDEV(nh_ifp) == NULL) {
 		err = -ENOPROTOOPT;
 		goto fail;
diff --git a/sys/dev/cxgbe/iw_cxgbe/provider.c b/sys/dev/cxgbe/iw_cxgbe/provider.c
index bfa00bb4c658..15f9cbe47062 100644
--- a/sys/dev/cxgbe/iw_cxgbe/provider.c
+++ b/sys/dev/cxgbe/iw_cxgbe/provider.c
@@ -337,7 +337,7 @@ c4iw_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr *props)
 	struct c4iw_dev *dev;
 	struct adapter *sc;
 	struct port_info *pi;
-	struct ifnet *ifp;
+	if_t ifp;
 
 	CTR4(KTR_IW_CXGBE, "%s ibdev %p, port %d, props %p", __func__, ibdev,
 	    port, props);
@@ -351,13 +351,13 @@ c4iw_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr *props)
 
 	memset(props, 0, sizeof(struct ib_port_attr));
 	props->max_mtu = IB_MTU_4096;
-	if (ifp->if_mtu >= 4096)
+	if (if_getmtu(ifp) >= 4096)
 		props->active_mtu = IB_MTU_4096;
-	else if (ifp->if_mtu >= 2048)
+	else if (if_getmtu(ifp) >= 2048)
 		props->active_mtu = IB_MTU_2048;
-	else if (ifp->if_mtu >= 1024)
+	else if (if_getmtu(ifp) >= 1024)
 		props->active_mtu = IB_MTU_1024;
-	else if (ifp->if_mtu >= 512)
+	else if (if_getmtu(ifp) >= 512)
 		props->active_mtu = IB_MTU_512;
 	else
 		props->active_mtu = IB_MTU_256;
diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c
index 5f4fbd0f07a6..72147cd9c48d 100644
--- a/sys/dev/cxgbe/t4_clip.c
+++ b/sys/dev/cxgbe/t4_clip.c
@@ -416,7 +416,7 @@ update_clip_db(void)
 	VNET_FOREACH(vnet_iter) {
 		CURVNET_SET_QUIET(vnet_iter);
 		CK_STAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) {
-			if (ia->ia_ifp->if_flags & IFF_LOOPBACK)
+			if (if_getflags(ia->ia_ifp) & IFF_LOOPBACK)
 				continue;
 			in6 = &ia->ia_addr.sin6_addr;
 			KASSERT(!IN6_IS_ADDR_MULTICAST(in6),
@@ -719,7 +719,7 @@ done:
 }
 
 static void
-t4_ifaddr_event(void *arg __unused, struct ifnet *ifp, struct ifaddr *ifa,
+t4_ifaddr_event(void *arg __unused, if_t ifp, struct ifaddr *ifa,
     int event)
 {
 	struct in6_addr *in6;
@@ -728,7 +728,7 @@ t4_ifaddr_event(void *arg __unused, struct ifnet *ifp, struct ifaddr *ifa,
 		return;		/* Automatic updates not allowed. */
 	if (ifa->ifa_addr->sa_family != AF_INET6)
 		return;
-	if (ifp->if_flags & IFF_LOOPBACK)
+	if (if_getflags(ifp) & IFF_LOOPBACK)
 		return;
 	in6 = &((struct in6_ifaddr *)ifa)->ia_addr.sin6_addr;
 	if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_MULTICAST(in6))
diff --git a/sys/dev/cxgbe/t4_l2t.c b/sys/dev/cxgbe/t4_l2t.c
index 47c995932a21..517d39a32be4 100644
--- a/sys/dev/cxgbe/t4_l2t.c
+++ b/sys/dev/cxgbe/t4_l2t.c
@@ -453,7 +453,7 @@ sysctl_l2t(SYSCTL_HANDLER_ARGS)
 			   e->dmac[3], e->dmac[4], e->dmac[5],
 			   e->vlan & 0xfff, vlan_prio(e), e->lport,
 			   l2e_state(e), atomic_load_acq_int(&e->refcnt),
-			   e->ifp ? e->ifp->if_xname : "-");
+			   e->ifp ? if_name(e->ifp) : "-");
 skip:
 		mtx_unlock(&e->lock);
 	}
diff --git a/sys/dev/cxgbe/t4_l2t.h b/sys/dev/cxgbe/t4_l2t.h
index 19b738752c2d..f638c55381fa 100644
--- a/sys/dev/cxgbe/t4_l2t.h
+++ b/sys/dev/cxgbe/t4_l2t.h
@@ -66,7 +66,7 @@ struct l2t_entry {
 	uint32_t addr[4];		/* next hop IP or IPv6 address */
 	uint32_t iqid;			/* iqid for reply to write_l2e */
 	struct sge_wrq *wrq;		/* queue to use for write_l2e */
-	struct ifnet *ifp;		/* outgoing interface */
+	if_t ifp;		/* outgoing interface */
 	uint16_t smt_idx;		/* SMT index */
 	uint16_t vlan;			/* VLAN TCI (id: 0-11, prio: 13-15) */
 	struct l2t_entry *first;	/* start of hash chain */
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 71ee366e04e0..18698ff468f3 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -247,11 +247,11 @@ static driver_t vcc_driver = {
 
 /* ifnet interface */
 static void cxgbe_init(void *);
-static int cxgbe_ioctl(struct ifnet *, unsigned long, caddr_t);
-static int cxgbe_transmit(struct ifnet *, struct mbuf *);
-static void cxgbe_qflush(struct ifnet *);
+static int cxgbe_ioctl(if_t, unsigned long, caddr_t);
+static int cxgbe_transmit(if_t, struct mbuf *);
+static void cxgbe_qflush(if_t);
 #if defined(KERN_TLS) || defined(RATELIMIT)
-static int cxgbe_snd_tag_alloc(struct ifnet *, union if_snd_tag_alloc_params *,
+static int cxgbe_snd_tag_alloc(if_t, union if_snd_tag_alloc_params *,
     struct m_snd_tag **);
 #endif
 
@@ -859,8 +859,8 @@ static int ktls_capability(struct adapter *, bool);
 #endif
 static int mod_event(module_t, int, void *);
 static int notify_siblings(device_t, int);
-static uint64_t vi_get_counter(struct ifnet *, ift_counter);
-static uint64_t cxgbe_get_counter(struct ifnet *, ift_counter);
+static uint64_t vi_get_counter(if_t, ift_counter);
+static uint64_t cxgbe_get_counter(if_t, ift_counter);
*** 1478 LINES SKIPPED ***