net/mlx5: Expose port speed when possible
authorMark Bloch <markb@mellanox.com>
Tue, 25 Feb 2020 18:04:40 +0000 (18:04 +0000)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 9 Mar 2020 23:58:31 +0000 (16:58 -0700)
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@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

index 01539b874b5eca9a32d969b1966ed314dd9f3f1e..f4491fba14a08e92a5b910421511f013b785e01c 100644 (file)
@@ -773,6 +773,7 @@ static void ptys2ethtool_supported_advertised_port(struct ethtool_link_ksettings
 
 static void get_speed_duplex(struct net_device *netdev,
                             u32 eth_proto_oper, bool force_legacy,
+                            u16 data_rate_oper,
                             struct ethtool_link_ksettings *link_ksettings)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -784,7 +785,10 @@ static void get_speed_duplex(struct net_device *netdev,
 
        speed = mlx5e_port_ptys2speed(priv->mdev, eth_proto_oper, force_legacy);
        if (!speed) {
-               speed = SPEED_UNKNOWN;
+               if (data_rate_oper)
+                       speed = 100 * data_rate_oper;
+               else
+                       speed = SPEED_UNKNOWN;
                goto out;
        }
 
@@ -874,6 +878,7 @@ int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,
 {
        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;
@@ -917,6 +922,7 @@ int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,
        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);
 
@@ -927,7 +933,7 @@ int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,
        get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings,
                        admin_ext);
        get_speed_duplex(priv->netdev, eth_proto_oper, !admin_ext,
-                        link_ksettings);
+                        data_rate_oper, link_ksettings);
 
        eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;