Skip to content

Commit 470b747

Browse files
HoommusSaeed Mahameed
authored andcommitted
net/mlx5: Disable QoS when min_rates on all VFs are zero
Currently when QoS is enabled for VF and any min_rate is configured, the driver sets bw_share value to at least 1 and doesn’t allow to set it to 0 to make minimal rate unlimited. It means there is always a minimal rate configured for every VF, even if user tries to remove it. In order to make QoS disable possible, check whether all vports have configured min_rate = 0. If this is true, set their bw_share to 0 to disable min_rate limitations. Fixes: c9497c9 ("net/mlx5: Add support for setting VF min rate") Signed-off-by: Vladyslav Tarasiuk <vladyslavt@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 1ce5fc7 commit 470b747

File tree

1 file changed

+8
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+8
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,12 +2222,15 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
22222222
max_guarantee = evport->info.min_rate;
22232223
}
22242224

2225-
return max_t(u32, max_guarantee / fw_max_bw_share, 1);
2225+
if (max_guarantee)
2226+
return max_t(u32, max_guarantee / fw_max_bw_share, 1);
2227+
return 0;
22262228
}
22272229

2228-
static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
2230+
static int normalize_vports_min_rate(struct mlx5_eswitch *esw)
22292231
{
22302232
u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
2233+
u32 divider = calculate_vports_min_rate_divider(esw);
22312234
struct mlx5_vport *evport;
22322235
u32 vport_max_rate;
22332236
u32 vport_min_rate;
@@ -2240,9 +2243,9 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
22402243
continue;
22412244
vport_min_rate = evport->info.min_rate;
22422245
vport_max_rate = evport->info.max_rate;
2243-
bw_share = MLX5_MIN_BW_SHARE;
2246+
bw_share = 0;
22442247

2245-
if (vport_min_rate)
2248+
if (divider)
22462249
bw_share = MLX5_RATE_TO_BW_SHARE(vport_min_rate,
22472250
divider,
22482251
fw_max_bw_share);
@@ -2267,7 +2270,6 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
22672270
struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
22682271
u32 fw_max_bw_share;
22692272
u32 previous_min_rate;
2270-
u32 divider;
22712273
bool min_rate_supported;
22722274
bool max_rate_supported;
22732275
int err = 0;
@@ -2292,8 +2294,7 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
22922294

22932295
previous_min_rate = evport->info.min_rate;
22942296
evport->info.min_rate = min_rate;
2295-
divider = calculate_vports_min_rate_divider(esw);
2296-
err = normalize_vports_min_rate(esw, divider);
2297+
err = normalize_vports_min_rate(esw);
22972298
if (err) {
22982299
evport->info.min_rate = previous_min_rate;
22992300
goto unlock;

0 commit comments

Comments
 (0)