git: 5dc00f00b747 - main - Mechanically convert mlx5en(4) to IfAPI

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Wed, 15 Feb 2023 14:43:26 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=5dc00f00b74775ee70a13048c2393f1246555452

commit 5dc00f00b74775ee70a13048c2393f1246555452
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-09-19 20:58:00 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-02-15 14:32:41 +0000

    Mechanically convert mlx5en(4) to IfAPI
    
    Reviewed by:    zlei
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D38595
---
 sys/dev/mlx5/mlx5_en/en.h                 |  18 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c    |   2 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c |  38 ++---
 sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c     |   6 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c  |   8 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_main.c       | 268 +++++++++++++++---------------
 sys/dev/mlx5/mlx5_en/mlx5_en_rl.c         |   6 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_rx.c         |  14 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_tx.c         |  16 +-
 sys/dev/mlx5/mlx5_ib/mlx5_ib.h            |   2 +-
 sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c       |  56 ++++---
 11 files changed, 221 insertions(+), 213 deletions(-)

diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h
index d24383f4c927..f4a048a6d2ca 100644
--- a/sys/dev/mlx5/mlx5_en/en.h
+++ b/sys/dev/mlx5/mlx5_en/en.h
@@ -770,7 +770,7 @@ struct mlx5e_rq {
 	u32	wqe_sz;
 	u32	nsegs;
 	struct mlx5e_rq_mbuf *mbuf;
-	struct ifnet *ifp;
+	if_t	ifp;
 	struct mlx5e_cq cq;
 	struct lro_ctrl lro;
 	volatile int enabled;
@@ -1114,7 +1114,7 @@ struct mlx5e_priv {
 	struct work_struct set_rx_mode_work;
 	MLX5_DECLARE_DOORBELL_LOCK(doorbell_lock)
 
-	struct ifnet *ifp;
+	if_t	ifp;
 	struct sysctl_ctx_list sysctl_ctx;
 	struct sysctl_oid *sysctl_ifnet;
 	struct sysctl_oid *sysctl_hw;
@@ -1200,10 +1200,10 @@ struct mlx5e_eeprom {
 
 bool	mlx5e_do_send_cqe(struct mlx5e_sq *);
 int	mlx5e_get_full_header_size(const struct mbuf *, const struct tcphdr **);
-int	mlx5e_xmit(struct ifnet *, struct mbuf *);
+int	mlx5e_xmit(if_t, struct mbuf *);
 
-int	mlx5e_open_locked(struct ifnet *);
-int	mlx5e_close_locked(struct ifnet *);
+int	mlx5e_open_locked(if_t);
+int	mlx5e_close_locked(if_t);
 
 void	mlx5e_cq_error_event(struct mlx5_core_cq *mcq, int event);
 void	mlx5e_dump_err_cqe(struct mlx5e_cq *, u32, const struct mlx5_err_cqe *);
@@ -1221,14 +1221,14 @@ int	mlx5e_open_flow_rules(struct mlx5e_priv *priv);
 void	mlx5e_close_flow_rules(struct mlx5e_priv *priv);
 void	mlx5e_set_rx_mode_work(struct work_struct *work);
 
-void	mlx5e_vlan_rx_add_vid(void *, struct ifnet *, u16);
-void	mlx5e_vlan_rx_kill_vid(void *, struct ifnet *, u16);
+void	mlx5e_vlan_rx_add_vid(void *, if_t, u16);
+void	mlx5e_vlan_rx_kill_vid(void *, if_t, u16);
 void	mlx5e_enable_vlan_filter(struct mlx5e_priv *priv);
 void	mlx5e_disable_vlan_filter(struct mlx5e_priv *priv);
 
-void	mlx5e_vxlan_start(void *arg, struct ifnet *ifp, sa_family_t family,
+void	mlx5e_vxlan_start(void *arg, if_t ifp, sa_family_t family,
 	    u_int port);
-void	mlx5e_vxlan_stop(void *arg, struct ifnet *ifp, sa_family_t family,
+void	mlx5e_vxlan_stop(void *arg, if_t ifp, sa_family_t family,
 	    u_int port);
 int	mlx5e_add_all_vxlan_rules(struct mlx5e_priv *priv);
 void	mlx5e_del_all_vxlan_rules(struct mlx5e_priv *priv);
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
index f57d70080a46..59a8cbc56bbb 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
@@ -1133,7 +1133,7 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
 		    MLX5_CAP_ETH(priv->mdev, lro_cap)) {
 			priv->params_ethtool.hw_lro = 1;
 			/* check if feature should actually be enabled */
-			if (priv->ifp->if_capenable & IFCAP_LRO) {
+			if (if_getcapenable(priv->ifp) & IFCAP_LRO) {
 				priv->params.hw_lro_en = true;
 			} else {
 				priv->params.hw_lro_en = false;
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
index 5607aad50da5..aec2bb646644 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
@@ -722,7 +722,7 @@ add_main_vxlan_rules_out:
 
 static int mlx5e_vport_context_update_vlans(struct mlx5e_priv *priv)
 {
-	struct ifnet *ifp = priv->ifp;
+	if_t ifp = priv->ifp;
 	int max_list_size;
 	int list_size;
 	u16 *vlans;
@@ -914,7 +914,7 @@ mlx5e_enable_vlan_filter(struct mlx5e_priv *priv)
 {
 	if (priv->vlan.filter_disabled) {
 		priv->vlan.filter_disabled = false;
-		if (priv->ifp->if_flags & IFF_PROMISC)
+		if (if_getflags(priv->ifp) & IFF_PROMISC)
 			return;
 		if (test_bit(MLX5E_STATE_FLOW_RULES_READY, &priv->state))
 			mlx5e_del_any_vid_rules(priv);
@@ -926,7 +926,7 @@ mlx5e_disable_vlan_filter(struct mlx5e_priv *priv)
 {
 	if (!priv->vlan.filter_disabled) {
 		priv->vlan.filter_disabled = true;
-		if (priv->ifp->if_flags & IFF_PROMISC)
+		if (if_getflags(priv->ifp) & IFF_PROMISC)
 			return;
 		if (test_bit(MLX5E_STATE_FLOW_RULES_READY, &priv->state))
 			mlx5e_add_any_vid_rules(priv);
@@ -934,7 +934,7 @@ mlx5e_disable_vlan_filter(struct mlx5e_priv *priv)
 }
 
 void
-mlx5e_vlan_rx_add_vid(void *arg, struct ifnet *ifp, u16 vid)
+mlx5e_vlan_rx_add_vid(void *arg, if_t ifp, u16 vid)
 {
 	struct mlx5e_priv *priv = arg;
 
@@ -949,7 +949,7 @@ mlx5e_vlan_rx_add_vid(void *arg, struct ifnet *ifp, u16 vid)
 }
 
 void
-mlx5e_vlan_rx_kill_vid(void *arg, struct ifnet *ifp, u16 vid)
+mlx5e_vlan_rx_kill_vid(void *arg, if_t ifp, u16 vid)
 {
 	struct mlx5e_priv *priv = arg;
 
@@ -1087,7 +1087,7 @@ mlx5e_sync_ifp_addr(struct mlx5e_priv *priv)
 	struct mlx5e_eth_addr_hash_head head_uc;
 	struct mlx5e_eth_addr_hash_head head_mc;
 	struct mlx5e_eth_addr_hash_node *hn;
-	struct ifnet *ifp = priv->ifp;
+	if_t ifp = priv->ifp;
 	size_t x;
 	size_t num;
 
@@ -1110,8 +1110,7 @@ retry:
 	hn = mlx5e_move_hn(&head_free, &head_uc);
 	MPASS(hn != NULL);
 
-	ether_addr_copy(hn->ai.addr,
-	    LLADDR((struct sockaddr_dl *)(ifp->if_addr->ifa_addr)));
+	ether_addr_copy(hn->ai.addr, if_getlladdr(ifp));
 
 	ctx.free = &head_free;
 	ctx.fill = &head_uc;
@@ -1158,7 +1157,7 @@ static void mlx5e_fill_addr_array(struct mlx5e_priv *priv, int list_type,
 				  u8 addr_array[][ETH_ALEN], int size)
 {
 	bool is_uc = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC);
-	struct ifnet *ifp = priv->ifp;
+	if_t ifp = priv->ifp;
 	struct mlx5e_eth_addr_hash_node *hn;
 	struct mlx5e_eth_addr_hash_head *addr_list;
 	struct mlx5e_eth_addr_hash_node *tmp;
@@ -1168,12 +1167,12 @@ static void mlx5e_fill_addr_array(struct mlx5e_priv *priv, int list_type,
 	addr_list = is_uc ? priv->eth_addr.if_uc : priv->eth_addr.if_mc;
 
 	if (is_uc) /* Make sure our own address is pushed first */
-		ether_addr_copy(addr_array[i++], IF_LLADDR(ifp));
+		ether_addr_copy(addr_array[i++], if_getlladdr(ifp));
 	else if (priv->eth_addr.broadcast_enabled)
-		ether_addr_copy(addr_array[i++], ifp->if_broadcastaddr);
+		ether_addr_copy(addr_array[i++], if_getbroadcastaddr(ifp));
 
 	mlx5e_for_each_hash_node(hn, tmp, addr_list, hi) {
-		if (ether_addr_equal(IF_LLADDR(ifp), hn->ai.addr))
+		if (ether_addr_equal(if_getlladdr(ifp), hn->ai.addr))
 			continue;
 		if (i >= size)
 			break;
@@ -1275,10 +1274,11 @@ static void
 mlx5e_set_rx_mode_core(struct mlx5e_priv *priv, bool rx_mode_enable)
 {
 	struct mlx5e_eth_addr_db *ea = &priv->eth_addr;
-	struct ifnet *ndev = priv->ifp;
+	if_t ndev = priv->ifp;
+	int ndev_flags = if_getflags(ndev);
 
-	bool promisc_enabled = rx_mode_enable && (ndev->if_flags & IFF_PROMISC);
-	bool allmulti_enabled = rx_mode_enable && (ndev->if_flags & IFF_ALLMULTI);
+	bool promisc_enabled = rx_mode_enable && (ndev_flags & IFF_PROMISC);
+	bool allmulti_enabled = rx_mode_enable && (ndev_flags & IFF_ALLMULTI);
 	bool broadcast_enabled = rx_mode_enable;
 
 	bool enable_promisc = !ea->promisc_enabled && promisc_enabled;
@@ -1290,7 +1290,7 @@ mlx5e_set_rx_mode_core(struct mlx5e_priv *priv, bool rx_mode_enable)
 
 	/* update broadcast address */
 	ether_addr_copy(priv->eth_addr.broadcast.addr,
-	    priv->ifp->if_broadcastaddr);
+	    if_getbroadcastaddr(priv->ifp));
 
 	if (enable_promisc) {
 		mlx5e_add_eth_addr_rule(priv, &ea->promisc, MLX5E_PROMISC);
@@ -1894,7 +1894,7 @@ mlx5e_add_vxlan_rule(struct mlx5e_priv *priv, sa_family_t family, u_int port)
 	}
 	el = mlx5e_vxlan_alloc_db_el(priv, proto, port);
 
-	if ((priv->ifp->if_capenable & IFCAP_VXLAN_HWCSUM) != 0) {
+	if ((if_getcapenable(priv->ifp) & IFCAP_VXLAN_HWCSUM) != 0) {
 		err = mlx5e_add_vxlan_rule_from_db(priv, el);
 		if (err == 0)
 			el->installed = true;
@@ -2023,7 +2023,7 @@ mlx5e_del_vxlan_catchall_rule(struct mlx5e_priv *priv)
 }
 
 void
-mlx5e_vxlan_start(void *arg, struct ifnet *ifp __unused, sa_family_t family,
+mlx5e_vxlan_start(void *arg, if_t ifp __unused, sa_family_t family,
     u_int port)
 {
 	struct mlx5e_priv *priv = arg;
@@ -2037,7 +2037,7 @@ mlx5e_vxlan_start(void *arg, struct ifnet *ifp __unused, sa_family_t family,
 }
 
 void
-mlx5e_vxlan_stop(void *arg, struct ifnet *ifp __unused, sa_family_t family,
+mlx5e_vxlan_stop(void *arg, if_t ifp __unused, sa_family_t family,
     u_int port)
 {
 	struct mlx5e_priv *priv = arg;
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
index e6b4759aeb7a..b99a7c98500c 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
@@ -309,7 +309,7 @@ mlx5e_tls_set_params(void *ctx, const struct tls_session_params *en)
 CTASSERT(MLX5E_TLS_ST_INIT == 0);
 
 int
-mlx5e_tls_snd_tag_alloc(struct ifnet *ifp,
+mlx5e_tls_snd_tag_alloc(if_t ifp,
     union if_snd_tag_alloc_params *params,
     struct m_snd_tag **ppmt)
 {
@@ -320,7 +320,7 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp,
 	const struct tls_session_params *en;
 	int error;
 
-	priv = ifp->if_softc;
+	priv = if_getsoftc(ifp);
 
 	if (priv->gone != 0 || priv->tls.init == 0)
 		return (EOPNOTSUPP);
@@ -489,7 +489,7 @@ mlx5e_tls_snd_tag_free(struct m_snd_tag *pmt)
 	ptag->state = MLX5E_TLS_ST_RELEASE;
 	MLX5E_TLS_TAG_UNLOCK(ptag);
 
-	priv = ptag->tag.ifp->if_softc;
+	priv = if_getsoftc(ptag->tag.ifp);
 	queue_work(priv->tls.wq, &ptag->work);
 }
 
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
index 356962cfad99..576eea1d7660 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls_rx.c
@@ -654,7 +654,7 @@ CTASSERT(MLX5E_TLS_RX_ST_INIT == 0);
  * Returns zero on success else an error happened.
  */
 int
-mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp,
+mlx5e_tls_rx_snd_tag_alloc(if_t ifp,
     union if_snd_tag_alloc_params *params,
     struct m_snd_tag **ppmt)
 {
@@ -666,7 +666,7 @@ mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp,
 	uint32_t value;
 	int error;
 
-	priv = ifp->if_softc;
+	priv = if_getsoftc(ifp);
 
 	if (unlikely(priv->gone != 0 || priv->tls_rx.init == 0 ||
 	    params->hdr.flowtype == M_HASHTYPE_NONE))
@@ -801,7 +801,7 @@ mlx5e_tls_rx_snd_tag_alloc(struct ifnet *ifp,
 		goto cleanup;
 	}
 
-	if (ifp->if_pcp != IFNET_PCP_NONE || params->tls_rx.vlan_id != 0) {
+	if (if_getpcp(ifp) != IFNET_PCP_NONE || params->tls_rx.vlan_id != 0) {
 		/* create flow rule for TLS RX traffic (tagged) */
 		flow_rule = mlx5e_accel_fs_add_inpcb(priv, params->tls_rx.inp,
 		    ptag->tirn, MLX5_FS_DEFAULT_FLOW_TAG, params->tls_rx.vlan_id);
@@ -996,7 +996,7 @@ mlx5e_tls_rx_snd_tag_free(struct m_snd_tag *pmt)
 	ptag->state = MLX5E_TLS_RX_ST_RELEASE;
 	MLX5E_TLS_RX_TAG_UNLOCK(ptag);
 
-	priv = ptag->tag.ifp->if_softc;
+	priv = if_getsoftc(ptag->tag.ifp);
 	queue_work(priv->tls_rx.wq, &ptag->work);
 }
 
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 04e3c302005b..84adef8398bb 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -391,7 +391,7 @@ mlx5e_update_carrier(struct mlx5e_priv *priv)
 	    MLX5_PTYS_EN, 1);
 	if (error) {
 		priv->media_active_last = IFM_ETHER;
-		priv->ifp->if_baudrate = 1;
+		if_setbaudrate(priv->ifp, 1);
 		mlx5_en_err(priv->ifp, "query port ptys failed: 0x%x\n",
 		    error);
 		return;
@@ -449,15 +449,15 @@ mlx5e_update_carrier(struct mlx5e_priv *priv)
 		break;
 	}
 	priv->media_active_last = media_entry.subtype | IFM_ETHER | IFM_FDX;
-	priv->ifp->if_baudrate = media_entry.baudrate;
+	if_setbaudrate(priv->ifp, media_entry.baudrate);
 
 	if_link_state_change(priv->ifp, LINK_STATE_UP);
 }
 
 static void
-mlx5e_media_status(struct ifnet *dev, struct ifmediareq *ifmr)
+mlx5e_media_status(if_t dev, struct ifmediareq *ifmr)
 {
-	struct mlx5e_priv *priv = dev->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(dev);
 
 	ifmr->ifm_status = priv->media_status_last;
 	ifmr->ifm_current = ifmr->ifm_active = priv->media_active_last |
@@ -530,9 +530,9 @@ mlx5e_set_port_pfc(struct mlx5e_priv *priv)
 }
 
 static int
-mlx5e_media_change(struct ifnet *dev)
+mlx5e_media_change(if_t dev)
 {
-	struct mlx5e_priv *priv = dev->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(dev);
 	struct mlx5_core_dev *mdev = priv->mdev;
 	u32 eth_proto_cap;
 	u32 link_mode;
@@ -2332,7 +2332,7 @@ mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs)
 	u32 r, n;
 
 	r = priv->params.hw_lro_en ? priv->params.lro_wqe_sz :
-	    MLX5E_SW2MB_MTU(priv->ifp->if_mtu);
+	    MLX5E_SW2MB_MTU(if_getmtu(priv->ifp));
 	if (r > MJUM16BYTES)
 		return (-ENOMEM);
 
@@ -3207,9 +3207,9 @@ mlx5e_close_tirs(struct mlx5e_priv *priv)
  * HW MTU includes all headers and checksums.
  */
 static int
-mlx5e_set_dev_port_mtu(struct ifnet *ifp, int sw_mtu)
+mlx5e_set_dev_port_mtu(if_t ifp, int sw_mtu)
 {
-	struct mlx5e_priv *priv = ifp->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(ifp);
 	struct mlx5_core_dev *mdev = priv->mdev;
 	int hw_mtu;
 	int err;
@@ -3231,7 +3231,7 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp, int sw_mtu)
 		    err);
 	}
 
-	ifp->if_mtu = sw_mtu;
+	if_setmtu(ifp, sw_mtu);
 
 	err = mlx5_query_vport_mtu(mdev, &hw_mtu);
 	if (err || !hw_mtu) {
@@ -3264,9 +3264,9 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp, int sw_mtu)
 }
 
 int
-mlx5e_open_locked(struct ifnet *ifp)
+mlx5e_open_locked(if_t ifp)
 {
-	struct mlx5e_priv *priv = ifp->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(ifp);
 	int err;
 	u16 set_id;
 
@@ -3338,14 +3338,14 @@ mlx5e_open(void *arg)
 		    "Setting port status to up failed\n");
 
 	mlx5e_open_locked(priv->ifp);
-	priv->ifp->if_drv_flags |= IFF_DRV_RUNNING;
+	if_setdrvflagbits(priv->ifp, IFF_DRV_RUNNING, 0);
 	PRIV_UNLOCK(priv);
 }
 
 int
-mlx5e_close_locked(struct ifnet *ifp)
+mlx5e_close_locked(if_t ifp)
 {
-	struct mlx5e_priv *priv = ifp->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(ifp);
 
 	/* check if already closed */
 	if (test_bit(MLX5E_STATE_OPENED, &priv->state) == 0)
@@ -3365,9 +3365,9 @@ mlx5e_close_locked(struct ifnet *ifp)
 }
 
 static uint64_t
-mlx5e_get_counter(struct ifnet *ifp, ift_counter cnt)
+mlx5e_get_counter(if_t ifp, ift_counter cnt)
 {
-	struct mlx5e_priv *priv = ifp->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(ifp);
 	u64 retval;
 
 	/* PRIV_LOCK(priv); XXX not allowed */
@@ -3418,15 +3418,15 @@ mlx5e_get_counter(struct ifnet *ifp, ift_counter cnt)
 }
 
 static void
-mlx5e_set_rx_mode(struct ifnet *ifp)
+mlx5e_set_rx_mode(if_t ifp)
 {
-	struct mlx5e_priv *priv = ifp->if_softc;
+	struct mlx5e_priv *priv = if_getsoftc(ifp);
 
 	queue_work(priv->wq, &priv->set_rx_mode_work);
 }
 
 static int
-mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+mlx5e_ioctl(if_t ifp, u_long command, caddr_t data)
 {
 	struct mlx5e_priv *priv;
 	struct ifreq *ifr;
@@ -3443,7 +3443,7 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 	int max_mtu;
 	uint8_t read_addr;
 
-	priv = ifp->if_softc;
+	priv = if_getsoftc(ifp);
 
 	/* check if detaching */
 	if (priv == NULL || priv->gone != 0)
@@ -3478,27 +3478,27 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 		PRIV_UNLOCK(priv);
 		break;
 	case SIOCSIFFLAGS:
-		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)) {
 			mlx5e_set_rx_mode(ifp);
 			break;
 		}
 		PRIV_LOCK(priv);
-		if (ifp->if_flags & IFF_UP) {
-			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+		if (if_getflags(ifp) & IFF_UP) {
+			if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
 				if (test_bit(MLX5E_STATE_OPENED, &priv->state) == 0)
 					mlx5e_open_locked(ifp);
-				ifp->if_drv_flags |= IFF_DRV_RUNNING;
+				if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
 				mlx5_set_port_status(priv->mdev, MLX5_PORT_UP);
 			}
 		} else {
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 				mlx5_set_port_status(priv->mdev,
 				    MLX5_PORT_DOWN);
 				if (test_bit(MLX5E_STATE_OPENED, &priv->state) != 0)
 					mlx5e_close_locked(ifp);
 				mlx5e_update_carrier(priv);
-				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+				if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
 			}
 		}
 		PRIV_UNLOCK(priv);
@@ -3521,98 +3521,98 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 		drv_ioctl_data = &drv_ioctl_data_d;
 		drv_ioctl_data->reqcap = ifr->ifr_reqcap;
 		PRIV_LOCK(priv);
-		drv_ioctl_data->reqcap2 = ifp->if_capenable2;
+		drv_ioctl_data->reqcap2 = if_getcapenable2(ifp);
 		drv_ioctl_data->nvcap = NULL;
 		goto siocsifcap_driver;
 	case SIOCSIFCAPNV:
 		drv_ioctl_data = (struct siocsifcapnv_driver_data *)data;
 		PRIV_LOCK(priv);
 siocsifcap_driver:
-		mask = drv_ioctl_data->reqcap ^ ifp->if_capenable;
+		mask = drv_ioctl_data->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;
-				ifp->if_hwassist &= ~CSUM_IP_TSO;
+				if_setcapenablebit(ifp, 0, IFCAP_TSO4);
+				if_sethwassistbits(ifp, 0, CSUM_IP_TSO);
 				mlx5_en_err(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;
-				ifp->if_hwassist &= ~CSUM_IP6_TSO;
+				if_setcapenablebit(ifp, 0, IFCAP_TSO6);
+				if_sethwassistbits(ifp, 0, CSUM_IP6_TSO);
 				mlx5_en_err(ifp,
 				    "tso6 disabled due to -txcsum6.\n");
 			}
 		}
 		if (mask & IFCAP_MEXTPG)
-			ifp->if_capenable ^= IFCAP_MEXTPG;
+			if_togglecapenable(ifp, IFCAP_MEXTPG);
 		if (mask & IFCAP_TXTLS4)
-			ifp->if_capenable ^= IFCAP_TXTLS4;
+			if_togglecapenable(ifp, IFCAP_TXTLS4);
 		if (mask & IFCAP_TXTLS6)
-			ifp->if_capenable ^= IFCAP_TXTLS6;
+			if_togglecapenable(ifp, IFCAP_TXTLS6);
 #ifdef RATELIMIT
 		if (mask & IFCAP_TXTLS_RTLMT)
-			ifp->if_capenable ^= IFCAP_TXTLS_RTLMT;
+			if_togglecapenable(ifp, IFCAP_TXTLS_RTLMT);
 #endif
 		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);
 		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))) {
 				mlx5_en_err(ifp, "enable txcsum first.\n");
 				error = EAGAIN;
 				goto out;
 			}
-			ifp->if_capenable ^= IFCAP_TSO4;
-			ifp->if_hwassist ^= CSUM_IP_TSO;
+			if_togglecapenable(ifp, IFCAP_TSO4);
+			if_togglehwassist(ifp, CSUM_IP_TSO);
 		}
 		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))) {
 				mlx5_en_err(ifp, "enable txcsum6 first.\n");
 				error = EAGAIN;
 				goto out;
 			}
-			ifp->if_capenable ^= IFCAP_TSO6;
-			ifp->if_hwassist ^= CSUM_IP6_TSO;
+			if_togglecapenable(ifp, IFCAP_TSO6);
+			if_togglehwassist(ifp, CSUM_IP6_TSO);
 		}
 		if (mask & IFCAP_VLAN_HWTSO)
-			ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
+			if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
 		if (mask & IFCAP_VLAN_HWFILTER) {
-			if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+			if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
 				mlx5e_disable_vlan_filter(priv);
 			else
 				mlx5e_enable_vlan_filter(priv);
 
-			ifp->if_capenable ^= IFCAP_VLAN_HWFILTER;
+			if_togglecapenable(ifp, IFCAP_VLAN_HWFILTER);
 		}
 		if (mask & IFCAP_VLAN_HWTAGGING)
-			ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
+			if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
 		if (mask & IFCAP_WOL_MAGIC)
-			ifp->if_capenable ^= IFCAP_WOL_MAGIC;
+			if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
 		if (mask & IFCAP_VXLAN_HWCSUM) {
 			const bool was_enabled =
-			    (ifp->if_capenable & IFCAP_VXLAN_HWCSUM) != 0;
+			    (if_getcapenable(ifp) & IFCAP_VXLAN_HWCSUM) != 0;
 			if (was_enabled)
 				mlx5e_del_all_vxlan_rules(priv);
-			ifp->if_capenable ^= IFCAP_VXLAN_HWCSUM;
-			ifp->if_hwassist ^= CSUM_INNER_IP | CSUM_INNER_IP_UDP |
+			if_togglecapenable(ifp, IFCAP_VXLAN_HWCSUM);
+			if_togglehwassist(ifp, CSUM_INNER_IP | CSUM_INNER_IP_UDP |
 			    CSUM_INNER_IP_TCP | CSUM_INNER_IP6_UDP |
-			    CSUM_INNER_IP6_TCP;
+			    CSUM_INNER_IP6_TCP);
 			if (!was_enabled) {
 				int err = mlx5e_add_all_vxlan_rules(priv);
 				if (err != 0) {
@@ -3622,9 +3622,9 @@ siocsifcap_driver:
 			}
 		}
 		if (mask & IFCAP_VXLAN_HWTSO) {
-			ifp->if_capenable ^= IFCAP_VXLAN_HWTSO;
-			ifp->if_hwassist ^= CSUM_INNER_IP_TSO |
-			    CSUM_INNER_IP6_TSO;
+			if_togglecapenable(ifp, IFCAP_VXLAN_HWTSO);
+			if_togglehwassist(ifp, CSUM_INNER_IP_TSO |
+			    CSUM_INNER_IP6_TSO);
 		}
 
 		VLAN_CAPABILITIES(ifp);
@@ -3633,10 +3633,10 @@ siocsifcap_driver:
 			int was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
 			bool need_restart = false;
 
-			ifp->if_capenable ^= IFCAP_LRO;
+			if_togglecapenable(ifp, IFCAP_LRO);
 
 			/* figure out if updating HW LRO is needed */
-			if (!(ifp->if_capenable & IFCAP_LRO)) {
+			if (!(if_getcapenable(ifp) & IFCAP_LRO)) {
 				if (priv->params.hw_lro_en) {
 					priv->params.hw_lro_en = false;
 					need_restart = true;
@@ -3654,8 +3654,8 @@ siocsifcap_driver:
 			}
 		}
 		if (mask & IFCAP_HWRXTSTMP) {
-			ifp->if_capenable ^= IFCAP_HWRXTSTMP;
-			if (ifp->if_capenable & IFCAP_HWRXTSTMP) {
+			if_togglecapenable(ifp, IFCAP_HWRXTSTMP);
+			if (if_getcapenable(ifp) & IFCAP_HWRXTSTMP) {
 				if (priv->clbr_done == 0)
 					mlx5e_reset_calibration_callout(priv);
 			} else {
@@ -3663,11 +3663,11 @@ siocsifcap_driver:
 				priv->clbr_done = 0;
 			}
 		}
-		mask = drv_ioctl_data->reqcap2 ^ ifp->if_capenable2;
+		mask = drv_ioctl_data->reqcap2 ^ if_getcapenable2(ifp);
 		if ((mask & IFCAP2_BIT(IFCAP2_RXTLS4)) != 0)
-			ifp->if_capenable2 ^= IFCAP2_BIT(IFCAP2_RXTLS4);
+			if_togglecapenable2(ifp, IFCAP2_BIT(IFCAP2_RXTLS4));
 		if ((mask & IFCAP2_BIT(IFCAP2_RXTLS6)) != 0)
-			ifp->if_capenable2 ^= IFCAP2_BIT(IFCAP2_RXTLS6);
+			if_togglecapenable2(ifp, IFCAP2_BIT(IFCAP2_RXTLS6));
 out:
 		PRIV_UNLOCK(priv);
 		break;
@@ -3911,7 +3911,7 @@ static int
 mlx5e_create_mkey(struct mlx5e_priv *priv, u32 pdn,
 		  struct mlx5_core_mkey *mkey)
 {
-	struct ifnet *ifp = priv->ifp;
+	if_t ifp = priv->ifp;
 	struct mlx5_core_dev *mdev = priv->mdev;
 	int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
 	void *mkc;
@@ -4332,14 +4332,14 @@ mlx5e_setup_pauseframes(struct mlx5e_priv *priv)
 }
 
 static int
-mlx5e_ul_snd_tag_alloc(struct ifnet *ifp,
+mlx5e_ul_snd_tag_alloc(if_t ifp,
     union if_snd_tag_alloc_params *params,
     struct m_snd_tag **ppmt)
 {
 	struct mlx5e_priv *priv;
 	struct mlx5e_channel *pch;
 
-	priv = ifp->if_softc;
+	priv = if_getsoftc(ifp);
 
 	if (unlikely(priv->gone || params->hdr.flowtype == M_HASHTYPE_NONE)) {
 		return (EOPNOTSUPP);
@@ -4394,7 +4394,7 @@ mlx5e_ul_snd_tag_free(struct m_snd_tag *pmt)
 }
 
 static int
-mlx5e_snd_tag_alloc(struct ifnet *ifp,
+mlx5e_snd_tag_alloc(if_t ifp,
     union if_snd_tag_alloc_params *params,
     struct m_snd_tag **ppmt)
 {
@@ -4440,7 +4440,7 @@ static const uint64_t adapter_rates_mlx[NUM_HDWR_RATES_MLX] = {
 };
 
 static void
-mlx5e_ratelimit_query(struct ifnet *ifp __unused, struct if_ratelimit_query_results *q)
+mlx5e_ratelimit_query(if_t ifp __unused, struct if_ratelimit_query_results *q)
 {
 	/*
 	 * This function needs updating by the driver maintainer!
@@ -4485,7 +4485,7 @@ mlx5e_ifm_add(struct mlx5e_priv *priv, int type)
 static void *
 mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 {
-	struct ifnet *ifp;
+	if_t ifp;
 	struct mlx5e_priv *priv;
 	u8 dev_addr[ETHER_ADDR_LEN] __aligned(4);
 	struct sysctl_oid_list *child;
@@ -4522,71 +4522,71 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 		goto err_free_ifp;
 	}
 
-	ifp->if_softc = priv;
+	if_setsoftc(ifp, priv);
 	if_initname(ifp, "mce", device_get_unit(mdev->pdev->dev.bsddev));
-	ifp->if_mtu = ETHERMTU;
-	ifp->if_init = mlx5e_open;
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-	    IFF_KNOWSEPOCH;
-	ifp->if_ioctl = mlx5e_ioctl;
-	ifp->if_transmit = mlx5e_xmit;
-	ifp->if_qflush = if_qflush;
-	ifp->if_get_counter = mlx5e_get_counter;
-	ifp->if_snd.ifq_maxlen = ifqmaxlen;
+	if_setmtu(ifp, ETHERMTU);
+	if_setinitfn(ifp, mlx5e_open);
+	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+	    IFF_KNOWSEPOCH);
+	if_setioctlfn(ifp, mlx5e_ioctl);
+	if_settransmitfn(ifp, mlx5e_xmit);
+	if_setqflushfn(ifp, if_qflush);
+	if_setgetcounterfn(ifp, mlx5e_get_counter);
+	if_setsendqlen(ifp, ifqmaxlen);
 	/*
          * Set driver features
          */
-	ifp->if_capabilities |= IFCAP_NV;
-	ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6;
-	ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING;
-	ifp->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER;
-	ifp->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU;
-	ifp->if_capabilities |= IFCAP_LRO;
-	ifp->if_capabilities |= IFCAP_TSO | IFCAP_VLAN_HWTSO;
-	ifp->if_capabilities |= IFCAP_HWSTATS | IFCAP_HWRXTSTMP;
-	ifp->if_capabilities |= IFCAP_MEXTPG;
-	ifp->if_capabilities |= IFCAP_TXTLS4 | IFCAP_TXTLS6;
+	if_setcapabilities(ifp, IFCAP_NV);
+	if_setcapabilitiesbit(ifp, IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_LINKSTATE | IFCAP_JUMBO_MTU, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_LRO, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_TSO | IFCAP_VLAN_HWTSO, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_HWSTATS | IFCAP_HWRXTSTMP, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_MEXTPG, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_TXTLS4 | IFCAP_TXTLS6, 0);
 #ifdef RATELIMIT
-	ifp->if_capabilities |= IFCAP_TXRTLMT | IFCAP_TXTLS_RTLMT;
+	if_setcapabilitiesbit(ifp, IFCAP_TXRTLMT | IFCAP_TXTLS_RTLMT, 0);
 #endif
-	ifp->if_capabilities |= IFCAP_VXLAN_HWCSUM | IFCAP_VXLAN_HWTSO;
-	ifp->if_capabilities2 |= IFCAP2_BIT(IFCAP2_RXTLS4) |
-	    IFCAP2_BIT(IFCAP2_RXTLS6);
-	ifp->if_snd_tag_alloc = mlx5e_snd_tag_alloc;
+	if_setcapabilitiesbit(ifp, IFCAP_VXLAN_HWCSUM | IFCAP_VXLAN_HWTSO, 0);
+	if_setcapabilities2bit(ifp, IFCAP2_BIT(IFCAP2_RXTLS4) |
+	    IFCAP2_BIT(IFCAP2_RXTLS6), 0);
+	if_setsndtagallocfn(ifp, mlx5e_snd_tag_alloc);
 #ifdef RATELIMIT
-	ifp->if_ratelimit_query = mlx5e_ratelimit_query;
+	if_setratelimitqueryfn(ifp, mlx5e_ratelimit_query);
 #endif
 	/* set TSO limits so that we don't have to drop TX packets */
-	ifp->if_hw_tsomax = MLX5E_MAX_TX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
-	ifp->if_hw_tsomaxsegcount = MLX5E_MAX_TX_MBUF_FRAGS - 1 /* hdr */;
-	ifp->if_hw_tsomaxsegsize = MLX5E_MAX_TX_MBUF_SIZE;
-
-	ifp->if_capenable = ifp->if_capabilities;
-	ifp->if_capenable2 = ifp->if_capabilities2;
-	ifp->if_hwassist = 0;
-	if (ifp->if_capenable & IFCAP_TSO)
-		ifp->if_hwassist |= CSUM_TSO;
-	if (ifp->if_capenable & IFCAP_TXCSUM)
-		ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP | CSUM_IP);
-	if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
-		ifp->if_hwassist |= (CSUM_UDP_IPV6 | CSUM_TCP_IPV6);
-	if (ifp->if_capabilities & IFCAP_VXLAN_HWCSUM)
-		ifp->if_hwassist |= CSUM_INNER_IP6_UDP | CSUM_INNER_IP6_TCP |
+	if_sethwtsomax(ifp, MLX5E_MAX_TX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN));
+	if_sethwtsomaxsegcount(ifp, MLX5E_MAX_TX_MBUF_FRAGS - 1 /* hdr */);
+	if_sethwtsomaxsegsize(ifp, MLX5E_MAX_TX_MBUF_SIZE);
+
+	if_setcapenable(ifp, if_getcapabilities(ifp));
+	if_setcapenable2(ifp, if_getcapabilities2(ifp));
+	if_sethwassist(ifp, 0);
+	if (if_getcapenable(ifp) & IFCAP_TSO)
+		if_sethwassistbits(ifp, CSUM_TSO, 0);
+	if (if_getcapenable(ifp) & IFCAP_TXCSUM)
+		if_sethwassistbits(ifp, (CSUM_TCP | CSUM_UDP | CSUM_IP), 0);
+	if (if_getcapenable(ifp) & IFCAP_TXCSUM_IPV6)
+		if_sethwassistbits(ifp, (CSUM_UDP_IPV6 | CSUM_TCP_IPV6), 0);
+	if (if_getcapabilities(ifp) & IFCAP_VXLAN_HWCSUM)
+		if_sethwassistbits(ifp, CSUM_INNER_IP6_UDP | CSUM_INNER_IP6_TCP |
 		    CSUM_INNER_IP | CSUM_INNER_IP_UDP | CSUM_INNER_IP_TCP |
-		    CSUM_ENCAP_VXLAN;
-	if (ifp->if_capabilities  & IFCAP_VXLAN_HWTSO)
-		ifp->if_hwassist |= CSUM_INNER_IP6_TSO | CSUM_INNER_IP_TSO;
+		    CSUM_ENCAP_VXLAN, 0);
+	if (if_getcapabilities(ifp) & IFCAP_VXLAN_HWTSO)
+		if_sethwassistbits(ifp, CSUM_INNER_IP6_TSO | CSUM_INNER_IP_TSO, 0);
 
 	/* ifnet sysctl tree */
 	sysctl_ctx_init(&priv->sysctl_ctx);
 	priv->sysctl_ifnet = SYSCTL_ADD_NODE(&priv->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_dev),
-	    OID_AUTO, ifp->if_dname, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
+	    OID_AUTO, if_getdname(ifp), CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
 	    "MLX5 ethernet - interface name");
 	if (priv->sysctl_ifnet == NULL) {
 		mlx5_core_err(mdev, "SYSCTL_ADD_NODE() failed\n");
 		goto err_free_sysctl;
 	}
-	snprintf(unit, sizeof(unit), "%d", ifp->if_dunit);
+	snprintf(unit, sizeof(unit), "%d", if_getdunit(ifp));
 	priv->sysctl_ifnet = SYSCTL_ADD_NODE(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
 	    OID_AUTO, unit, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
 	    "MLX5 ethernet - interface unit");
@@ -4682,7 +4682,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 	}
 
 	/* set default MTU */
-	mlx5e_set_dev_port_mtu(ifp, ifp->if_mtu);
+	mlx5e_set_dev_port_mtu(ifp, if_getmtu(ifp));
 
 	/* Set default media status */
 	priv->media_status_last = IFM_AVALID;
@@ -4805,7 +4805,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 	pa.pa_version = PFIL_VERSION;
 	pa.pa_flags = PFIL_IN;
 	pa.pa_type = PFIL_TYPE_ETHERNET;
-	pa.pa_headname = ifp->if_xname;
+	pa.pa_headname = if_name(ifp);
 	priv->pfil = pfil_head_register(&pa);
 
 	PRIV_LOCK(priv);
@@ -4866,7 +4866,7 @@ static void
 mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vpriv)
 {
 	struct mlx5e_priv *priv = vpriv;
-	struct ifnet *ifp = priv->ifp;
+	if_t ifp = priv->ifp;
 
 	/* don't allow more IOCTLs */
 	priv->gone = 1;
@@ -4964,7 +4964,7 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vpriv)
 
 #ifdef DEBUGNET
 static void
-mlx5_en_debugnet_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize)
+mlx5_en_debugnet_init(if_t dev, int *nrxr, int *ncl, int *clsize)
 {
 	struct mlx5e_priv *priv = if_getsoftc(dev);
 
@@ -4976,12 +4976,12 @@ mlx5_en_debugnet_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize)
 }
 
 static void
-mlx5_en_debugnet_event(struct ifnet *dev, enum debugnet_ev event)
+mlx5_en_debugnet_event(if_t dev, enum debugnet_ev event)
 {
 }
 
 static int
-mlx5_en_debugnet_transmit(struct ifnet *dev, struct mbuf *m)
+mlx5_en_debugnet_transmit(if_t dev, struct mbuf *m)
 {
 	struct mlx5e_priv *priv = if_getsoftc(dev);
 	struct mlx5e_sq *sq;
@@ -5011,7 +5011,7 @@ mlx5_en_debugnet_transmit(struct ifnet *dev, struct mbuf *m)
 }
 
 static int
-mlx5_en_debugnet_poll(struct ifnet *dev, int count)
+mlx5_en_debugnet_poll(if_t dev, int count)
 {
 	struct mlx5e_priv *priv = if_getsoftc(dev);
 
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c b/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c
index d00e99fce1d4..e4f6c0bdf979 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c
@@ -515,7 +515,7 @@ mlx5e_rlw_channel_set_rate_locked(struct mlx5e_rl_worker *rlw,
 
 		/* get current burst size in bytes */
 		temp = rl->param.tx_burst_size *
-		    MLX5E_SW2HW_MTU(rlw->priv->ifp->if_mtu);
+		    MLX5E_SW2HW_MTU(if_getmtu(rlw->priv->ifp));
 
 		/* limit burst size to 64K currently */
 		if (temp > 65535)
@@ -1202,7 +1202,7 @@ mlx5e_find_available_tx_ring_index(struct mlx5e_rl_worker *rlw,
 }
 
 int
-mlx5e_rl_snd_tag_alloc(struct ifnet *ifp,
+mlx5e_rl_snd_tag_alloc(if_t ifp,
     union if_snd_tag_alloc_params *params,
     struct m_snd_tag **ppmt)
 {
@@ -1211,7 +1211,7 @@ mlx5e_rl_snd_tag_alloc(struct ifnet *ifp,
 	struct mlx5e_priv *priv;
 	int error;
 
-	priv = ifp->if_softc;
+	priv = if_getsoftc(ifp);
 
 	/* check if there is support for packet pacing or if device is going away */
 	if (!MLX5_CAP_GEN(priv->mdev, qos) ||
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
index 4b1fb25e0f82..28a49ec98fb2 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
@@ -279,7 +279,7 @@ mlx5e_build_rx_mbuf(struct mlx5_cqe64 *cqe,
     struct mlx5e_rq *rq, struct mbuf *mb,
     u32 cqe_bcnt)
 {
-	struct ifnet *ifp = rq->ifp;
+	if_t ifp = rq->ifp;
 	struct mlx5e_channel *c;
 	struct mbuf *mb_head;
 	int lro_num_seg;	/* HW LRO session aggregated packets counter */
@@ -375,7 +375,7 @@ mlx5e_build_rx_mbuf(struct mlx5_cqe64 *cqe,
 		} else {
 			rq->stats.csum_none++;
 		}
-	} else if (likely((ifp->if_capenable & (IFCAP_RXCSUM |
+	} else if (likely((if_getcapenable(ifp) & (IFCAP_RXCSUM |
 	    IFCAP_RXCSUM_IPV6)) != 0) &&
 	    ((cqe->hds_ip_ext & (CQE_L2_OK | CQE_L3_OK | CQE_L4_OK)) ==
 	    (CQE_L2_OK | CQE_L3_OK | CQE_L4_OK))) {
@@ -501,7 +501,7 @@ mlx5e_poll_rx_cq(struct mlx5e_rq *rq, int budget)
 	struct pfil_head *pfil;
 	int i, rv;
 
-	CURVNET_SET_QUIET(rq->ifp->if_vnet);
+	CURVNET_SET_QUIET(if_getvnet(rq->ifp));
 	pfil = rq->channel->priv->pfil;
 	for (i = 0; i < budget; i++) {
 		struct mlx5e_rx_wqe *wqe;
@@ -586,17 +586,17 @@ rx_common:
 		rq->stats.bytes += byte_cnt;
 		rq->stats.packets++;
 #ifdef NUMA
-		mb->m_pkthdr.numa_domain = rq->ifp->if_numa_domain;
+		mb->m_pkthdr.numa_domain = if_getnumadomain(rq->ifp);
 #endif
 
 #if !defined(HAVE_TCP_LRO_RX)
 		tcp_lro_queue_mbuf(&rq->lro, mb);
 #else
 		if (mb->m_pkthdr.csum_flags == 0 ||
-		    (rq->ifp->if_capenable & IFCAP_LRO) == 0 ||
+		    (if_getcapenable(rq->ifp) & IFCAP_LRO) == 0 ||
 		    rq->lro.lro_cnt == 0 ||
*** 228 LINES SKIPPED ***