Date: Fri, 2 Apr 2021 10:12:44 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: 4ded022d3b89 - main - mlx5: remove dependency on ifnet specifics of linux/netdevice.h Message-ID: <202104021012.132ACiJ6049101@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=4ded022d3b8948e92c8f8353364ff2c79d720e68 commit 4ded022d3b8948e92c8f8353364ff2c79d720e68 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2021-03-30 15:58:55 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> 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 <linux/vmalloc.h> #include <linux/moduleparam.h> #include <linux/delay.h> -#include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/ktime.h> #include <linux/net_dim.h> 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 <linux/kernel.h> #include <linux/sched.h> #include <linux/printk.h> +#include <linux/netdevice.h> #include <rdma/ib_verbs.h> #include <rdma/ib_smi.h> #include <dev/mlx5/cq.h> @@ -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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104021012.132ACiJ6049101>