mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-13 20:16:41 +07:00
mlxsw: spectrum: Add new operation for getting the port's speed
New operation for getting the port's speed as part of port-type-speed operations. Signed-off-by: Shalom Toledo <shalomt@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
399569cb0a
commit
4ae5cc42d3
@ -2655,28 +2655,33 @@ mlxsw_sp1_from_ptys_link(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
|
||||
}
|
||||
}
|
||||
|
||||
static u32
|
||||
mlxsw_sp1_from_ptys_speed(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MLXSW_SP1_PORT_LINK_MODE_LEN; i++) {
|
||||
if (ptys_eth_proto & mlxsw_sp1_port_link_mode[i].mask)
|
||||
return mlxsw_sp1_port_link_mode[i].speed;
|
||||
}
|
||||
|
||||
return SPEED_UNKNOWN;
|
||||
}
|
||||
|
||||
static void
|
||||
mlxsw_sp1_from_ptys_speed_duplex(struct mlxsw_sp *mlxsw_sp, bool carrier_ok,
|
||||
u32 ptys_eth_proto,
|
||||
struct ethtool_link_ksettings *cmd)
|
||||
{
|
||||
u32 speed = SPEED_UNKNOWN;
|
||||
u8 duplex = DUPLEX_UNKNOWN;
|
||||
int i;
|
||||
cmd->base.speed = SPEED_UNKNOWN;
|
||||
cmd->base.duplex = DUPLEX_UNKNOWN;
|
||||
|
||||
if (!carrier_ok)
|
||||
goto out;
|
||||
return;
|
||||
|
||||
for (i = 0; i < MLXSW_SP1_PORT_LINK_MODE_LEN; i++) {
|
||||
if (ptys_eth_proto & mlxsw_sp1_port_link_mode[i].mask) {
|
||||
speed = mlxsw_sp1_port_link_mode[i].speed;
|
||||
duplex = DUPLEX_FULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
cmd->base.speed = speed;
|
||||
cmd->base.duplex = duplex;
|
||||
cmd->base.speed = mlxsw_sp1_from_ptys_speed(mlxsw_sp, ptys_eth_proto);
|
||||
if (cmd->base.speed != SPEED_UNKNOWN)
|
||||
cmd->base.duplex = DUPLEX_FULL;
|
||||
}
|
||||
|
||||
static u32
|
||||
@ -2747,6 +2752,7 @@ static const struct mlxsw_sp_port_type_speed_ops
|
||||
mlxsw_sp1_port_type_speed_ops = {
|
||||
.from_ptys_supported_port = mlxsw_sp1_from_ptys_supported_port,
|
||||
.from_ptys_link = mlxsw_sp1_from_ptys_link,
|
||||
.from_ptys_speed = mlxsw_sp1_from_ptys_speed,
|
||||
.from_ptys_speed_duplex = mlxsw_sp1_from_ptys_speed_duplex,
|
||||
.to_ptys_advert_link = mlxsw_sp1_to_ptys_advert_link,
|
||||
.to_ptys_speed = mlxsw_sp1_to_ptys_speed,
|
||||
@ -2997,28 +3003,33 @@ mlxsw_sp2_from_ptys_link(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
|
||||
}
|
||||
}
|
||||
|
||||
static u32
|
||||
mlxsw_sp2_from_ptys_speed(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MLXSW_SP2_PORT_LINK_MODE_LEN; i++) {
|
||||
if (ptys_eth_proto & mlxsw_sp2_port_link_mode[i].mask)
|
||||
return mlxsw_sp2_port_link_mode[i].speed;
|
||||
}
|
||||
|
||||
return SPEED_UNKNOWN;
|
||||
}
|
||||
|
||||
static void
|
||||
mlxsw_sp2_from_ptys_speed_duplex(struct mlxsw_sp *mlxsw_sp, bool carrier_ok,
|
||||
u32 ptys_eth_proto,
|
||||
struct ethtool_link_ksettings *cmd)
|
||||
{
|
||||
u32 speed = SPEED_UNKNOWN;
|
||||
u8 duplex = DUPLEX_UNKNOWN;
|
||||
int i;
|
||||
cmd->base.speed = SPEED_UNKNOWN;
|
||||
cmd->base.duplex = DUPLEX_UNKNOWN;
|
||||
|
||||
if (!carrier_ok)
|
||||
goto out;
|
||||
return;
|
||||
|
||||
for (i = 0; i < MLXSW_SP2_PORT_LINK_MODE_LEN; i++) {
|
||||
if (ptys_eth_proto & mlxsw_sp2_port_link_mode[i].mask) {
|
||||
speed = mlxsw_sp2_port_link_mode[i].speed;
|
||||
duplex = DUPLEX_FULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
cmd->base.speed = speed;
|
||||
cmd->base.duplex = duplex;
|
||||
cmd->base.speed = mlxsw_sp2_from_ptys_speed(mlxsw_sp, ptys_eth_proto);
|
||||
if (cmd->base.speed != SPEED_UNKNOWN)
|
||||
cmd->base.duplex = DUPLEX_FULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -3129,6 +3140,7 @@ static const struct mlxsw_sp_port_type_speed_ops
|
||||
mlxsw_sp2_port_type_speed_ops = {
|
||||
.from_ptys_supported_port = mlxsw_sp2_from_ptys_supported_port,
|
||||
.from_ptys_link = mlxsw_sp2_from_ptys_link,
|
||||
.from_ptys_speed = mlxsw_sp2_from_ptys_speed,
|
||||
.from_ptys_speed_duplex = mlxsw_sp2_from_ptys_speed_duplex,
|
||||
.to_ptys_advert_link = mlxsw_sp2_to_ptys_advert_link,
|
||||
.to_ptys_speed = mlxsw_sp2_to_ptys_speed,
|
||||
|
@ -279,6 +279,7 @@ struct mlxsw_sp_port_type_speed_ops {
|
||||
struct ethtool_link_ksettings *cmd);
|
||||
void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
|
||||
unsigned long *mode);
|
||||
u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
|
||||
void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp,
|
||||
bool carrier_ok, u32 ptys_eth_proto,
|
||||
struct ethtool_link_ksettings *cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user