Skip to content

Commit 297e1cf

Browse files
Awik84davem330
authored andcommitted
net/mlx4_en: Adding support of turning off link autonegotiation via ethtool
This feature will allow the user to disable auto negotiation on the port for mlx4 devices while setting the speed is limited to 1GbE speeds. Other speeds will not be accepted in autoneg off mode. This functionality is permitted providing that the firmware is compatible with this feature. The above is determined by querying a new dedicated capability bit in the device. Signed-off-by: Ariel Levkovich <lariel@mellanox.com> Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4b5e5b7 commit 297e1cf

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx4/en_ethtool.c‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ mlx4_en_set_link_ksettings(struct net_device *dev,
902902
struct mlx4_en_priv *priv = netdev_priv(dev);
903903
struct mlx4_ptys_reg ptys_reg;
904904
__be32 proto_admin;
905+
u8 cur_autoneg;
905906
int ret;
906907

907908
u32 ptys_adv = ethtool2ptys_link_modes(
@@ -931,18 +932,31 @@ mlx4_en_set_link_ksettings(struct net_device *dev,
931932
return 0;
932933
}
933934

934-
proto_admin = link_ksettings->base.autoneg == AUTONEG_ENABLE ?
935-
cpu_to_be32(ptys_adv) :
936-
speed_set_ptys_admin(priv, speed,
937-
ptys_reg.eth_proto_cap);
935+
cur_autoneg = ptys_reg.flags & MLX4_PTYS_AN_DISABLE_ADMIN ?
936+
AUTONEG_DISABLE : AUTONEG_ENABLE;
937+
938+
if (link_ksettings->base.autoneg == AUTONEG_DISABLE) {
939+
proto_admin = speed_set_ptys_admin(priv, speed,
940+
ptys_reg.eth_proto_cap);
941+
if ((be32_to_cpu(proto_admin) &
942+
(MLX4_PROT_MASK(MLX4_1000BASE_CX_SGMII) |
943+
MLX4_PROT_MASK(MLX4_1000BASE_KX))) &&
944+
(ptys_reg.flags & MLX4_PTYS_AN_DISABLE_CAP))
945+
ptys_reg.flags |= MLX4_PTYS_AN_DISABLE_ADMIN;
946+
} else {
947+
proto_admin = cpu_to_be32(ptys_adv);
948+
ptys_reg.flags &= ~MLX4_PTYS_AN_DISABLE_ADMIN;
949+
}
938950

939951
proto_admin &= ptys_reg.eth_proto_cap;
940952
if (!proto_admin) {
941953
en_warn(priv, "Not supported link mode(s) requested, check supported link modes.\n");
942954
return -EINVAL; /* nothing to change due to bad input */
943955
}
944956

945-
if (proto_admin == ptys_reg.eth_proto_admin)
957+
if ((proto_admin == ptys_reg.eth_proto_admin) &&
958+
((ptys_reg.flags & MLX4_PTYS_AN_DISABLE_CAP) &&
959+
(link_ksettings->base.autoneg == cur_autoneg)))
946960
return 0; /* Nothing to change */
947961

948962
en_dbg(DRV, priv, "mlx4_ACCESS_PTYS_REG SET: ptys_reg.eth_proto_admin = 0x%x\n",

‎include/linux/mlx4/device.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,8 +1539,13 @@ enum mlx4_ptys_proto {
15391539
MLX4_PTYS_EN = 1<<2,
15401540
};
15411541

1542+
enum mlx4_ptys_flags {
1543+
MLX4_PTYS_AN_DISABLE_CAP = 1 << 5,
1544+
MLX4_PTYS_AN_DISABLE_ADMIN = 1 << 6,
1545+
};
1546+
15421547
struct mlx4_ptys_reg {
1543-
u8 resrvd1;
1548+
u8 flags;
15441549
u8 local_port;
15451550
u8 resrvd2;
15461551
u8 proto_mask;

0 commit comments

Comments
 (0)