Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 May 2021 12:39:22 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 60afad6fc307 - main - mlx4: replace LinuxKPI macros with ifnet functions
Message-ID:  <202105271239.14RCdMUK034007@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=60afad6fc307815ad2b70a9974d908b6d5d50674

commit 60afad6fc307815ad2b70a9974d908b6d5d50674
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2021-05-26 17:47:02 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2021-05-27 12:26:01 +0000

    mlx4: replace LinuxKPI macros with ifnet functions
    
    The LinuxKPI net_device actually is an ifnet;  in order to further
    clean that up so we can extend "net_device" replace the few macros
    inline in mlx4.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      12 days
    Reviewed by:    kib
    Differential Revision: https://reviews.freebsd.org/D30476
---
 sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c   |  2 +-
 sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c | 21 +++++++++++----------
 sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c   |  6 +++---
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
index 76f78a9e2c9d..33c0f9e6b4e2 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
@@ -98,7 +98,7 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr
 	if (gid_attr.ndev) {
 		vlan_tag = rdma_vlan_dev_vlan_id(gid_attr.ndev);
 		memcpy(ah->av.eth.s_mac, IF_LLADDR(gid_attr.ndev), ETH_ALEN);
-		dev_put(gid_attr.ndev);
+		if_rele(gid_attr.ndev);
 	}
 	if (vlan_tag < 0x1000)
 		vlan_tag |= (ah_attr->sl & 7) << 13;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
index b31744e73be6..b050272e49d0 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
@@ -156,7 +156,7 @@ static struct net_device *mlx4_ib_get_netdev(struct ib_device *device, u8 port_n
 	}
 #endif
 	if (dev)
-		dev_hold(dev);
+		if_ref(dev);
 
 	rcu_read_unlock();
 	return dev;
@@ -415,7 +415,7 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
 		return ret;
 
 	if (attr.ndev)
-		dev_put(attr.ndev);
+		if_rele(attr.ndev);
 
 	if (!memcmp(&gid, &zgid, sizeof(gid)))
 		return -EINVAL;
@@ -736,7 +736,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
 	tmp = iboe_get_mtu(ndev->if_mtu);
 	props->active_mtu = tmp ? min(props->max_mtu, tmp) : IB_MTU_256;
 
-	props->state		= (netif_running(ndev) && netif_carrier_ok(ndev)) ?
+	props->state		= ((ndev->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
+				   ndev->if_link_state == LINK_STATE_UP) ?
 					IB_PORT_ACTIVE : IB_PORT_DOWN;
 	props->phys_state	= state_to_phys_state(props->state);
 out_unlock:
@@ -1356,12 +1357,12 @@ int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
 	spin_lock_bh(&mdev->iboe.lock);
 	ndev = mdev->iboe.netdevs[mqp->port - 1];
 	if (ndev)
-		dev_hold(ndev);
+		if_ref(ndev);
 	spin_unlock_bh(&mdev->iboe.lock);
 
 	if (ndev) {
 		ret = 1;
-		dev_put(ndev);
+		if_rele(ndev);
 	}
 
 	return ret;
@@ -2002,10 +2003,10 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 		spin_lock_bh(&mdev->iboe.lock);
 		ndev = ge->added ? mdev->iboe.netdevs[ge->port - 1] : NULL;
 		if (ndev)
-			dev_hold(ndev);
+			if_ref(ndev);
 		spin_unlock_bh(&mdev->iboe.lock);
 		if (ndev)
-			dev_put(ndev);
+			if_rele(ndev);
 		list_del(&ge->list);
 		kfree(ge);
 	} else
@@ -2372,7 +2373,7 @@ static int mlx4_ib_netdev_event(struct notifier_block *this,
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 	struct mlx4_ib_dev *ibdev;
 
-	if (!net_eq(dev_net(dev), &init_net))
+	if (dev->if_vnet != &init_net)
 		return NOTIFY_DONE;
 
 	ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb);
@@ -3111,8 +3112,8 @@ static void handle_bonded_port_state_event(struct work_struct *work)
 			continue;
 
 		curr_port_state =
-			(netif_running(curr_netdev) &&
-			 netif_carrier_ok(curr_netdev)) ?
+			((curr_netdev->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
+			 curr_netdev->if_link_state == LINK_STATE_UP) ?
 			IB_PORT_ACTIVE : IB_PORT_DOWN;
 
 		bonded_port_state = (bonded_port_state != IB_PORT_ACTIVE) ?
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
index a3bd86b182cb..3b81797b46b0 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
@@ -1783,7 +1783,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 			if (!status && gid_attr.ndev) {
 				vlan = rdma_vlan_dev_vlan_id(gid_attr.ndev);
 				memcpy(smac, IF_LLADDR(gid_attr.ndev), ETH_ALEN);
-				dev_put(gid_attr.ndev);
+				if_rele(gid_attr.ndev);
 			}
 		}
 		if (status)
@@ -2471,7 +2471,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
 						&gid_attr);
 			if (!err) {
 				if (gid_attr.ndev)
-					dev_put(gid_attr.ndev);
+					if_rele(gid_attr.ndev);
 				if (!memcmp(&sgid, &zgid, sizeof(sgid)))
 					err = -ENOENT;
 			}
@@ -2962,7 +2962,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 					       ah->av.ib.gid_index, &gid,
 					       &gid_attr)) {
 				if (gid_attr.ndev)
-					dev_put(gid_attr.ndev);
+					if_rele(gid_attr.ndev);
 				qp = (gid_attr.gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) ?
 					to_mqp(sqp->roce_v2_gsi) : qp;
 			} else {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105271239.14RCdMUK034007>