You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmod-redhat-mlx5_core/SOURCES/0273-netdrv-net-mlx5e-Add-s...

189 lines
6.6 KiB

From 5fa5489fb414fc500bb9eeef1f1600d8a1e0e2aa Mon Sep 17 00:00:00 2001
From: Alaa Hleihel <ahleihel@redhat.com>
Date: Mon, 1 Jun 2020 15:40:25 -0400
Subject: [PATCH 273/312] [netdrv] net/mlx5e: Add support for devlink-port in
non-representors mode
Message-id: <20200601154102.25980-3-ahleihel@redhat.com>
Patchwork-id: 315707
Patchwork-instance: patchwork
O-Subject: [RHEL8.3 BZ 1842258 02/39] net/mlx5e: Add support for devlink-port in non-representors mode
Bugzilla: 1842258 1790226
RH-Acked-by: Honggang Li <honli@redhat.com>
RH-Acked-by: Kamal Heib <kheib@redhat.com>
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
Bugzilla: http://bugzilla.redhat.com/1790226
Bugzilla: http://bugzilla.redhat.com/1842258
Upstream: v5.7-rc1
commit c6acd629eec754a9679f922d51f90e44c769b80c
Author: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
Date: Wed Nov 13 17:19:47 2019 +0200
net/mlx5e: Add support for devlink-port in non-representors mode
Added devlink_port field to mlx5e_priv structure and a callback to
netdev ops to enable devlink to get info about the port. The port
registration happens at driver initialization.
Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
---
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 +
.../net/ethernet/mellanox/mlx5/core/en/devlink.c | 38 ++++++++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/en/devlink.h | 15 +++++++++
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 11 +++++++
5 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index 9e85def607b9..51d6cc94adba 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -25,7 +25,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
en_selftest.o en/port.o en/monitor_stats.o en/health.o \
en/reporter_tx.o en/reporter_rx.o en/params.o en/xsk/umem.o \
- en/xsk/setup.o en/xsk/rx.o en/xsk/tx.o
+ en/xsk/setup.o en/xsk/rx.o en/xsk/tx.o en/devlink.o
#
# Netdev extra
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 2e3a4ba96793..db0f2d9936cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -872,6 +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 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
new file mode 100644
index 000000000000..1a87a3fc6b44
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+/* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
+
+#include "en/devlink.h"
+
+int mlx5e_devlink_phy_port_register(struct net_device *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);
+ if (err)
+ return err;
+ devlink_port_type_eth_set(&priv->dl_phy_port, dev);
+ return 0;
+}
+
+void mlx5e_devlink_phy_port_unregister(struct mlx5e_priv *priv)
+{
+ devlink_port_unregister(&priv->dl_phy_port);
+}
+
+struct devlink_port *mlx5e_get_devlink_phy_port(struct net_device *dev)
+{
+ struct mlx5e_priv *priv = netdev_priv(dev);
+
+ return &priv->dl_phy_port;
+}
+
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h
new file mode 100644
index 000000000000..b8cd63b88688
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
+/* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
+
+#ifndef __MLX5E_EN_DEVLINK_H
+#define __MLX5E_EN_DEVLINK_H
+
+#include <net/devlink.h>
+#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);
+
+#endif
+
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 22298f67fbd2..0f48804f7fd2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -62,6 +62,7 @@
#include "en/xsk/setup.h"
#include "en/xsk/rx.h"
#include "en/xsk/tx.h"
+#include "en/devlink.h"
bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev)
@@ -4634,6 +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,
};
static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev)
@@ -5497,11 +5499,19 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
goto err_detach;
}
+ err = mlx5e_devlink_phy_port_register(netdev);
+ if (err) {
+ mlx5_core_err(mdev, "mlx5e_devlink_phy_port_register failed, %d\n", err);
+ goto err_unregister_netdev;
+ }
+
#ifdef CONFIG_MLX5_CORE_EN_DCB
mlx5e_dcbnl_init_app(priv);
#endif
return priv;
+err_unregister_netdev:
+ unregister_netdev(netdev);
err_detach:
mlx5e_detach(mdev, priv);
err_destroy_netdev:
@@ -5523,6 +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);
unregister_netdev(priv->netdev);
mlx5e_detach(mdev, vpriv);
mlx5e_destroy_netdev(priv);
--
2.13.6