net/mlx5: Move vport DOWN state check out of mlx5_query_vport_max_tx_speed()

mlx5_query_vport_max_tx_speed() was introduced to serve the
query_port_speed path, which uses max_tx_speed == 0 when port is down.

This is incorrect for callers that need the actual configured speed
regardless of vport state, such as modify-vport-state helpers
that must preserve the speed across state transitions.

Move this logic to the caller function in the verb flow and let
mlx5_query_vport_max_tx_speed() return the raw firmware value
unconditionally.

Fixes: aaecff5e13 ("RDMA/mlx5: Implement query_port_speed callback")
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Reviewed-by: Shay Drori <shayd@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260816065015.3280733-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Or Har-Toov 2026-08-16 09:50:14 +03:00 committed by Jakub Kicinski
parent ff0f9b7aa1
commit 20f11b5cfa
3 changed files with 9 additions and 11 deletions

View File

@ -1631,14 +1631,15 @@ static int mlx5_ib_query_port_speed_from_vport(struct mlx5_core_dev *mdev,
u32 port_num)
{
u32 max_tx_speed;
u8 vport_state;
int err;
err = mlx5_query_vport_max_tx_speed(mdev, op_mod, vport, other_vport,
&max_tx_speed);
&max_tx_speed, &vport_state);
if (err)
return err;
if (max_tx_speed == 0)
if (vport_state == VPORT_STATE_DOWN || max_tx_speed == 0)
/* Value 0 indicates field not supported, fallback */
return mlx5_ib_query_port_speed_from_port(dev, port_num,
speed);

View File

@ -131,11 +131,11 @@ int mlx5_modify_vport_max_tx_speed(struct mlx5_core_dev *mdev, u8 opmod,
}
int mlx5_query_vport_max_tx_speed(struct mlx5_core_dev *mdev, u8 op_mod,
u16 vport, u8 other_vport, u32 *max_tx_speed)
u16 vport, u8 other_vport,
u32 *max_tx_speed, u8 *state)
{
u32 out[MLX5_ST_SZ_DW(query_vport_state_out)] = {};
u32 in[MLX5_ST_SZ_DW(query_vport_state_in)] = {};
u32 state;
int err;
MLX5_SET(query_vport_state_in, in, opcode,
@ -148,13 +148,9 @@ int mlx5_query_vport_max_tx_speed(struct mlx5_core_dev *mdev, u8 op_mod,
if (err)
return err;
state = MLX5_GET(query_vport_state_out, out, state);
if (state == VPORT_STATE_DOWN) {
*max_tx_speed = 0;
return 0;
}
*max_tx_speed = MLX5_GET(query_vport_state_out, out, max_tx_speed);
if (state)
*state = MLX5_GET(query_vport_state_out, out, state);
return 0;
}
EXPORT_SYMBOL_GPL(mlx5_query_vport_max_tx_speed);

View File

@ -61,7 +61,8 @@ u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport);
int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
u16 vport, u8 other_vport, u8 state);
int mlx5_query_vport_max_tx_speed(struct mlx5_core_dev *mdev, u8 op_mod,
u16 vport, u8 other_vport, u32 *max_tx_speed);
u16 vport, u8 other_vport,
u32 *max_tx_speed, u8 *state);
int mlx5_modify_vport_max_tx_speed(struct mlx5_core_dev *mdev, u8 opmod,
u16 vport, u8 other_vport, u16 max_tx_speed);
int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,