Skip to content

Commit 25a96f0

Browse files
daniellertskuba-moo
authored andcommitted
mlxsw: ethtool: Pass link mode in use to ethtool
Currently, when user space queries the link's parameters, as speed and duplex, each parameter is passed from the driver to ethtool. Instead, pass the link mode bit in use. In Spectrum-1, simply pass the bit that is set to '1' from PTYS register. In Spectrum-2, pass the first link mode bit in the mask of the used link mode. Signed-off-by: Danielle Ratson <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 763ece8 commit 25a96f0

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ struct mlxsw_sp_port_type_speed_ops {
330330
void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
331331
unsigned long *mode);
332332
u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
333-
void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp,
334-
bool carrier_ok, u32 ptys_eth_proto,
335-
struct ethtool_link_ksettings *cmd);
333+
void (*from_ptys_link_mode)(struct mlxsw_sp *mlxsw_sp,
334+
bool carrier_ok, u32 ptys_eth_proto,
335+
struct ethtool_link_ksettings *cmd);
336336
int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed);
337337
u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp,
338338
const struct ethtool_link_ksettings *cmd);

drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ static int mlxsw_sp_port_get_link_ksettings(struct net_device *dev,
966966

967967
cmd->base.autoneg = autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE;
968968
cmd->base.port = mlxsw_sp_port_connector_port(connector_type);
969-
ops->from_ptys_speed_duplex(mlxsw_sp, netif_carrier_ok(dev),
970-
eth_proto_oper, cmd);
969+
ops->from_ptys_link_mode(mlxsw_sp, netif_carrier_ok(dev),
970+
eth_proto_oper, cmd);
971971

972972
return 0;
973973
}
@@ -1221,19 +1221,21 @@ mlxsw_sp1_from_ptys_speed(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto)
12211221
}
12221222

12231223
static void
1224-
mlxsw_sp1_from_ptys_speed_duplex(struct mlxsw_sp *mlxsw_sp, bool carrier_ok,
1225-
u32 ptys_eth_proto,
1226-
struct ethtool_link_ksettings *cmd)
1224+
mlxsw_sp1_from_ptys_link_mode(struct mlxsw_sp *mlxsw_sp, bool carrier_ok,
1225+
u32 ptys_eth_proto,
1226+
struct ethtool_link_ksettings *cmd)
12271227
{
1228-
cmd->base.speed = SPEED_UNKNOWN;
1229-
cmd->base.duplex = DUPLEX_UNKNOWN;
1228+
int i;
1229+
1230+
cmd->link_mode = -1;
12301231

12311232
if (!carrier_ok)
12321233
return;
12331234

1234-
cmd->base.speed = mlxsw_sp1_from_ptys_speed(mlxsw_sp, ptys_eth_proto);
1235-
if (cmd->base.speed != SPEED_UNKNOWN)
1236-
cmd->base.duplex = DUPLEX_FULL;
1235+
for (i = 0; i < MLXSW_SP1_PORT_LINK_MODE_LEN; i++) {
1236+
if (ptys_eth_proto & mlxsw_sp1_port_link_mode[i].mask)
1237+
cmd->link_mode = mlxsw_sp1_port_link_mode[i].mask_ethtool;
1238+
}
12371239
}
12381240

12391241
static int mlxsw_sp1_ptys_max_speed(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed)
@@ -1322,7 +1324,7 @@ const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops = {
13221324
.from_ptys_supported_port = mlxsw_sp1_from_ptys_supported_port,
13231325
.from_ptys_link = mlxsw_sp1_from_ptys_link,
13241326
.from_ptys_speed = mlxsw_sp1_from_ptys_speed,
1325-
.from_ptys_speed_duplex = mlxsw_sp1_from_ptys_speed_duplex,
1327+
.from_ptys_link_mode = mlxsw_sp1_from_ptys_link_mode,
13261328
.ptys_max_speed = mlxsw_sp1_ptys_max_speed,
13271329
.to_ptys_advert_link = mlxsw_sp1_to_ptys_advert_link,
13281330
.to_ptys_speed_lanes = mlxsw_sp1_to_ptys_speed_lanes,
@@ -1658,19 +1660,24 @@ mlxsw_sp2_from_ptys_speed(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto)
16581660
}
16591661

16601662
static void
1661-
mlxsw_sp2_from_ptys_speed_duplex(struct mlxsw_sp *mlxsw_sp, bool carrier_ok,
1662-
u32 ptys_eth_proto,
1663-
struct ethtool_link_ksettings *cmd)
1663+
mlxsw_sp2_from_ptys_link_mode(struct mlxsw_sp *mlxsw_sp, bool carrier_ok,
1664+
u32 ptys_eth_proto,
1665+
struct ethtool_link_ksettings *cmd)
16641666
{
1665-
cmd->base.speed = SPEED_UNKNOWN;
1666-
cmd->base.duplex = DUPLEX_UNKNOWN;
1667+
struct mlxsw_sp2_port_link_mode link;
1668+
int i;
1669+
1670+
cmd->link_mode = -1;
16671671

16681672
if (!carrier_ok)
16691673
return;
16701674

1671-
cmd->base.speed = mlxsw_sp2_from_ptys_speed(mlxsw_sp, ptys_eth_proto);
1672-
if (cmd->base.speed != SPEED_UNKNOWN)
1673-
cmd->base.duplex = DUPLEX_FULL;
1675+
for (i = 0; i < MLXSW_SP2_PORT_LINK_MODE_LEN; i++) {
1676+
if (ptys_eth_proto & mlxsw_sp2_port_link_mode[i].mask) {
1677+
link = mlxsw_sp2_port_link_mode[i];
1678+
cmd->link_mode = link.mask_ethtool[1];
1679+
}
1680+
}
16741681
}
16751682

16761683
static int mlxsw_sp2_ptys_max_speed(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed)
@@ -1793,7 +1800,7 @@ const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops = {
17931800
.from_ptys_supported_port = mlxsw_sp2_from_ptys_supported_port,
17941801
.from_ptys_link = mlxsw_sp2_from_ptys_link,
17951802
.from_ptys_speed = mlxsw_sp2_from_ptys_speed,
1796-
.from_ptys_speed_duplex = mlxsw_sp2_from_ptys_speed_duplex,
1803+
.from_ptys_link_mode = mlxsw_sp2_from_ptys_link_mode,
17971804
.ptys_max_speed = mlxsw_sp2_ptys_max_speed,
17981805
.to_ptys_advert_link = mlxsw_sp2_to_ptys_advert_link,
17991806
.to_ptys_speed_lanes = mlxsw_sp2_to_ptys_speed_lanes,

0 commit comments

Comments
 (0)