Skip to content

Commit

Permalink
net/mlx5e: Fix ethtool self test: link speed
Browse files Browse the repository at this point in the history
[ Upstream commit 534e736 ]

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 <[email protected]>
Reviewed-by: Moshe Shemesh <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ayalevin123 authored and gregkh committed Nov 10, 2019
1 parent 5eb1967 commit db91be8
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/udp.h>
#include <net/udp.h>
#include "en.h"
#include "en/port.h"

enum {
MLX5E_ST_LINK_STATE,
Expand Down Expand Up @@ -80,22 +81,12 @@ static int mlx5e_test_link_state(struct mlx5e_priv *priv)

static int mlx5e_test_link_speed(struct mlx5e_priv *priv)
{
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
u32 eth_proto_oper;
int i;
u32 speed;

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

if (mlx5_query_port_ptys(priv->mdev, out, sizeof(out), MLX5_PTYS_EN, 1))
return 1;

eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
for (i = 0; i < MLX5E_LINK_MODES_NUMBER; i++) {
if (eth_proto_oper & MLX5E_PROT_MASK(i))
return 0;
}
return 1;
return mlx5e_port_linkspeed(priv->mdev, &speed);
}

struct mlx5ehdr {
Expand Down

0 comments on commit db91be8

Please sign in to comment.