[BIONIC/linux-azure-4.15][PATCH 2/3] net/mlx5: Expose port speed when possible
William Breathitt Gray
william.gray at canonical.com
Mon Aug 17 12:37:39 UTC 2020
From: Mark Bloch <markb at mellanox.com>
When port speed can't be reported based on ext_eth_proto_capability
or eth_proto_capability instead of reporting speed as unknown check
if the port's speed can be inferred based on the data_rate_oper field.
Signed-off-by: Mark Bloch <markb at mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm at mellanox.com>
BugLink: https://bugs.launchpad.net/bugs/1876770
(backported from commit c268ca6087f553bfc0e16ffec412b983ffe32fd4)
[ vilhelmgray: refactor data_rate_oper check for get_speed_duplex() ]
Signed-off-by: William Breathitt Gray <william.gray at canonical.com>
---
.../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 3a1f798fbe8d..071a84f64881 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -707,7 +707,7 @@ int mlx5e_get_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)
}
static void get_speed_duplex(struct net_device *netdev,
- u32 eth_proto_oper,
+ u32 eth_proto_oper, u16 data_rate_oper,
struct ethtool_link_ksettings *link_ksettings)
{
int i;
@@ -724,6 +724,12 @@ static void get_speed_duplex(struct net_device *netdev,
break;
}
}
+ if (!speed) {
+ if (data_rate_oper)
+ speed = 100 * data_rate_oper;
+ else
+ speed = SPEED_UNKNOWN;
+ }
out:
link_ksettings->base.speed = speed;
link_ksettings->base.duplex = duplex;
@@ -808,6 +814,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev;
u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0};
+ u16 data_rate_oper;
u32 rx_pause = 0;
u32 tx_pause = 0;
u32 eth_proto_cap;
@@ -833,6 +840,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin);
an_status = MLX5_GET(ptys_reg, out, an_status);
connector_type = MLX5_GET(ptys_reg, out, connector_type);
+ data_rate_oper = MLX5_GET(ptys_reg, out, data_rate_oper);
mlx5_query_port_pause(mdev, &rx_pause, &tx_pause);
@@ -841,7 +849,8 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
get_supported(eth_proto_cap, link_ksettings);
get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings);
- get_speed_duplex(netdev, eth_proto_oper, link_ksettings);
+ get_speed_duplex(netdev, eth_proto_oper, data_rate_oper,
+ link_ksettings);
eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;
--
2.25.1
More information about the kernel-team
mailing list