From owner-dev-commits-src-all@freebsd.org Fri Apr 2 10:12:44 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 D5DEF5CA5FB; Fri, 2 Apr 2021 10:12:44 +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 4FBbTS5j9Xz4g71; Fri, 2 Apr 2021 10:12:44 +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 B68761DC75; Fri, 2 Apr 2021 10:12:44 +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 132ACi4i049102; Fri, 2 Apr 2021 10:12:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 132ACiJ6049101; Fri, 2 Apr 2021 10:12:44 GMT (envelope-from git) Date: Fri, 2 Apr 2021 10:12:44 GMT Message-Id: <202104021012.132ACiJ6049101@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: 4ded022d3b89 - main - mlx5: remove dependency on ifnet specifics of linux/netdevice.h 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: 4ded022d3b8948e92c8f8353364ff2c79d720e68 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: Fri, 02 Apr 2021 10:12:44 -0000 The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4ded022d3b8948e92c8f8353364ff2c79d720e68 commit 4ded022d3b8948e92c8f8353364ff2c79d720e68 Author: Bjoern A. Zeeb AuthorDate: 2021-03-30 15:58:55 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-04-02 10:01:30 +0000 mlx5: remove dependency on ifnet specifics of linux/netdevice.h Rename the last remaining bits depending on ifnet from linux/netdevice.h instead of using the compat macros. This helps clearing up struct netdevice being struct ifnet from linux/netdevice.h. Sponsored-by: The FreeBSD Foundation MFC-after: 2 weeks Reviewed-by: hselasky, kib X-D-R: D29366 Differential Revision: https://reviews.freebsd.org/D29497 --- sys/dev/mlx5/mlx5_en/en.h | 1 - sys/dev/mlx5/mlx5_ib/mlx5_ib.h | 3 ++- sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c | 27 ++++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h index b990bb754962..2ec47fa96a6d 100644 --- a/sys/dev/mlx5/mlx5_en/en.h +++ b/sys/dev/mlx5/mlx5_en/en.h @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib.h b/sys/dev/mlx5/mlx5_ib/mlx5_ib.h index b9828f1da466..0420b294de80 100644 --- a/sys/dev/mlx5/mlx5_ib/mlx5_ib.h +++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -627,7 +628,7 @@ struct mlx5_roce { * netdev pointer */ rwlock_t netdev_lock; - struct net_device *netdev; + struct ifnet *netdev; struct notifier_block nb; atomic_t next_port; }; diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c index f2485d13d791..c2a01b26de1c 100644 --- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c +++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c @@ -93,7 +93,7 @@ mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num) return mlx5_port_type_cap_to_rdma_ll(port_type_cap); } -static bool mlx5_netdev_match(struct net_device *ndev, +static bool mlx5_netdev_match(struct ifnet *ndev, struct mlx5_core_dev *mdev, const char *dname) { @@ -107,7 +107,7 @@ static bool mlx5_netdev_match(struct net_device *ndev, static int mlx5_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) { - struct net_device *ndev = netdev_notifier_info_to_dev(ptr); + struct ifnet *ndev = netdev_notifier_info_to_dev(ptr); struct mlx5_ib_dev *ibdev = container_of(this, struct mlx5_ib_dev, roce.nb); @@ -124,7 +124,7 @@ static int mlx5_netdev_event(struct notifier_block *this, case NETDEV_UP: case NETDEV_DOWN: { - struct net_device *upper = NULL; + struct ifnet *upper = NULL; if ((upper == ndev || (!upper && ndev == ibdev->roce.netdev)) && ibdev->ib_active) { @@ -146,18 +146,18 @@ static int mlx5_netdev_event(struct notifier_block *this, return NOTIFY_DONE; } -static struct net_device *mlx5_ib_get_netdev(struct ib_device *device, +static struct ifnet *mlx5_ib_get_netdev(struct ib_device *device, u8 port_num) { struct mlx5_ib_dev *ibdev = to_mdev(device); - struct net_device *ndev; + struct ifnet *ndev; - /* Ensure ndev does not disappear before we invoke dev_hold() + /* Ensure ndev does not disappear before we invoke if_ref() */ read_lock(&ibdev->roce.netdev_lock); ndev = ibdev->roce.netdev; if (ndev) - dev_hold(ndev); + if_ref(ndev); read_unlock(&ibdev->roce.netdev_lock); return ndev; @@ -283,7 +283,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, { struct mlx5_ib_dev *dev = to_mdev(device); u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {}; - struct net_device *ndev; + struct ifnet *ndev; enum ib_mtu ndev_ib_mtu; u16 qkey_viol_cntr; u32 eth_prot_oper; @@ -328,14 +328,15 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, if (!ndev) return 0; - if (netif_running(ndev) && netif_carrier_ok(ndev)) { + if (ndev->if_drv_flags & IFF_DRV_RUNNING && + ndev->if_link_state == LINK_STATE_UP) { props->state = IB_PORT_ACTIVE; props->phys_state = 5; } ndev_ib_mtu = iboe_get_mtu(ndev->if_mtu); - dev_put(ndev); + if_rele(ndev); props->active_mtu = min(props->max_mtu, ndev_ib_mtu); return 0; @@ -437,7 +438,7 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, if (!attr.ndev) return 0; - dev_put(attr.ndev); + if_rele(attr.ndev); if (attr.gid_type != IB_GID_TYPE_ROCE_UDP_ENCAP) return 0; @@ -459,7 +460,7 @@ int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num, if (!attr.ndev) return -ENODEV; - dev_put(attr.ndev); + if_rele(attr.ndev); *gid_type = attr.gid_type; @@ -3060,7 +3061,7 @@ static void mlx5_remove_roce_notifier(struct mlx5_ib_dev *dev) static int mlx5_enable_roce(struct mlx5_ib_dev *dev) { VNET_ITERATOR_DECL(vnet_iter); - struct net_device *idev; + struct ifnet *idev; int err; /* Check if mlx5en net device already exists */