From owner-dev-commits-src-all@freebsd.org Thu May 27 12:39:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C628D63C580; Thu, 27 May 2021 12:39:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FrS7G51Hvz3M2l; Thu, 27 May 2021 12:39:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 940FF23C62; Thu, 27 May 2021 12:39:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14RCdMcZ034008; Thu, 27 May 2021 12:39:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14RCdMUK034007; Thu, 27 May 2021 12:39:22 GMT (envelope-from git) Date: Thu, 27 May 2021 12:39:22 GMT Message-Id: <202105271239.14RCdMUK034007@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 60afad6fc307 - main - mlx4: replace LinuxKPI macros with ifnet functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 60afad6fc307815ad2b70a9974d908b6d5d50674 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2021 12:39:22 -0000 The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=60afad6fc307815ad2b70a9974d908b6d5d50674 commit 60afad6fc307815ad2b70a9974d908b6d5d50674 Author: Bjoern A. Zeeb AuthorDate: 2021-05-26 17:47:02 +0000 Commit: Bjoern A. Zeeb 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 {