From 3b05c8231e7a2cdcd4ec6931dd535b6b1e92f8e5 Mon Sep 17 00:00:00 2001 From: Alaa Hleihel Date: Mon, 1 Jun 2020 15:40:26 -0400 Subject: [PATCH 274/312] [netdrv] net/mlx5e: Use devlink virtual flavour for VF devlink port Message-id: <20200601154102.25980-4-ahleihel@redhat.com> Patchwork-id: 315709 Patchwork-instance: patchwork O-Subject: [RHEL8.3 BZ 1842258 03/39] net/mlx5e: Use devlink virtual flavour for VF devlink port Bugzilla: 1842258 1790226 RH-Acked-by: Honggang Li RH-Acked-by: Kamal Heib RH-Acked-by: Marcelo Leitner RH-Acked-by: Jarod Wilson Bugzilla: http://bugzilla.redhat.com/1790226 Bugzilla: http://bugzilla.redhat.com/1842258 Upstream: v5.7-rc1 commit 162add8cbae4635cf0598c640a24d5ed2849774f Author: Parav Pandit Date: Tue Mar 3 08:12:43 2020 -0600 net/mlx5e: Use devlink virtual flavour for VF devlink port Use newly introduce 'virtual' port flavour for devlink port of PCI VF devlink device in non-representors mode. While at it, remove recently introduced empty lines at end of the file. Reviewed-by: Jiri Pirko Signed-off-by: Parav Pandit Signed-off-by: David S. Miller Signed-off-by: Alaa Hleihel Signed-off-by: Frantisek Hrbata --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- .../net/ethernet/mellanox/mlx5/core/en/devlink.c | 39 +++++++++++++--------- .../net/ethernet/mellanox/mlx5/core/en/devlink.h | 7 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++-- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index db0f2d9936cd..09c9f8c0ef48 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -872,7 +872,7 @@ struct mlx5e_priv { #endif struct devlink_health_reporter *tx_reporter; struct devlink_health_reporter *rx_reporter; - struct devlink_port dl_phy_port; + struct devlink_port dl_port; struct mlx5e_xsk xsk; struct mlx5e_scratchpad scratchpad; }; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c index 1a87a3fc6b44..e38495e4aa42 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c @@ -3,36 +3,43 @@ #include "en/devlink.h" -int mlx5e_devlink_phy_port_register(struct net_device *dev) +int mlx5e_devlink_port_register(struct net_device *netdev) { + struct mlx5_core_dev *dev; struct mlx5e_priv *priv; struct devlink *devlink; int err; - priv = netdev_priv(dev); - devlink = priv_to_devlink(priv->mdev); - - devlink_port_attrs_set(&priv->dl_phy_port, - DEVLINK_PORT_FLAVOUR_PHYSICAL, - PCI_FUNC(priv->mdev->pdev->devfn), - false, 0, - NULL, 0); - err = devlink_port_register(devlink, &priv->dl_phy_port, 1); + priv = netdev_priv(netdev); + dev = priv->mdev; + + if (mlx5_core_is_pf(dev)) + devlink_port_attrs_set(&priv->dl_port, + DEVLINK_PORT_FLAVOUR_PHYSICAL, + PCI_FUNC(dev->pdev->devfn), + false, 0, + NULL, 0); + else + devlink_port_attrs_set(&priv->dl_port, + DEVLINK_PORT_FLAVOUR_VIRTUAL, + 0, false, 0, NULL, 0); + + devlink = priv_to_devlink(dev); + err = devlink_port_register(devlink, &priv->dl_port, 1); if (err) return err; - devlink_port_type_eth_set(&priv->dl_phy_port, dev); + devlink_port_type_eth_set(&priv->dl_port, netdev); return 0; } -void mlx5e_devlink_phy_port_unregister(struct mlx5e_priv *priv) +void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv) { - devlink_port_unregister(&priv->dl_phy_port); + devlink_port_unregister(&priv->dl_port); } -struct devlink_port *mlx5e_get_devlink_phy_port(struct net_device *dev) +struct devlink_port *mlx5e_get_devlink_port(struct net_device *dev) { struct mlx5e_priv *priv = netdev_priv(dev); - return &priv->dl_phy_port; + return &priv->dl_port; } - diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h index b8cd63b88688..3e5393a0901f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h @@ -7,9 +7,8 @@ #include #include "en.h" -int mlx5e_devlink_phy_port_register(struct net_device *dev); -void mlx5e_devlink_phy_port_unregister(struct mlx5e_priv *priv); -struct devlink_port *mlx5e_get_devlink_phy_port(struct net_device *dev); +int mlx5e_devlink_port_register(struct net_device *dev); +void mlx5e_devlink_port_unregister(struct mlx5e_priv *priv); +struct devlink_port *mlx5e_get_devlink_port(struct net_device *dev); #endif - diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 0f48804f7fd2..5e52f415ef35 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -4635,7 +4635,7 @@ const struct net_device_ops mlx5e_netdev_ops = { .ndo_set_vf_link_state = mlx5e_set_vf_link_state, .ndo_get_vf_stats = mlx5e_get_vf_stats, #endif - .ndo_get_devlink_port = mlx5e_get_devlink_phy_port, + .ndo_get_devlink_port = mlx5e_get_devlink_port, }; static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev) @@ -5499,7 +5499,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) goto err_detach; } - err = mlx5e_devlink_phy_port_register(netdev); + err = mlx5e_devlink_port_register(netdev); if (err) { mlx5_core_err(mdev, "mlx5e_devlink_phy_port_register failed, %d\n", err); goto err_unregister_netdev; @@ -5533,7 +5533,7 @@ static void mlx5e_remove(struct mlx5_core_dev *mdev, void *vpriv) #ifdef CONFIG_MLX5_CORE_EN_DCB mlx5e_dcbnl_delete_app(priv); #endif - mlx5e_devlink_phy_port_unregister(priv); + mlx5e_devlink_port_unregister(priv); unregister_netdev(priv->netdev); mlx5e_detach(mdev, vpriv); mlx5e_destroy_netdev(priv); -- 2.13.6