Skip to content

Commit 534e736

Browse files
ayalevin123Saeed Mahameed
authored andcommitted
net/mlx5e: Fix ethtool self test: link speed
Ethtool self test contains a test for link speed. This test reads the PTYS register and determines whether the current speed is valid or not. Change current implementation to use the function mlx5e_port_linkspeed() that does the same check and fails when speed is invalid. This code redundancy lead to a bug when mlx5e_port_linkspeed() was updated with expended speeds and the self test was not. Fixes: 2c81bfd ("net/mlx5e: Move port speed code from en_ethtool.c to en/port.c") Signed-off-by: Aya Levin <ayal@mellanox.com> Reviewed-by: Moshe Shemesh <moshe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 9df86bd commit 534e736

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/udp.h>
3636
#include <net/udp.h>
3737
#include "en.h"
38+
#include "en/port.h"
3839

3940
enum {
4041
MLX5E_ST_LINK_STATE,
@@ -80,22 +81,12 @@ static int mlx5e_test_link_state(struct mlx5e_priv *priv)
8081

8182
static int mlx5e_test_link_speed(struct mlx5e_priv *priv)
8283
{
83-
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
84-
u32 eth_proto_oper;
85-
int i;
84+
u32 speed;
8685

8786
if (!netif_carrier_ok(priv->netdev))
8887
return 1;
8988

90-
if (mlx5_query_port_ptys(priv->mdev, out, sizeof(out), MLX5_PTYS_EN, 1))
91-
return 1;
92-
93-
eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
94-
for (i = 0; i < MLX5E_LINK_MODES_NUMBER; i++) {
95-
if (eth_proto_oper & MLX5E_PROT_MASK(i))
96-
return 0;
97-
}
98-
return 1;
89+
return mlx5e_port_linkspeed(priv->mdev, &speed);
9990
}
10091

10192
struct mlx5ehdr {

0 commit comments

Comments
 (0)