Skip to content

Commit d4e50e4

Browse files
Hoommusksacilotto
authored andcommitted
net/mlx5: Disable QoS when min_rates on all VFs are zero
BugLink: https://bugs.launchpad.net/bugs/1908561 [ Upstream commit 470b747 ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Ian May <ian.may@canonical.com>
1 parent 782fa11 commit d4e50e4

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
@@ -2369,12 +2369,15 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
23692369
max_guarantee = evport->info.min_rate;
23702370
}
23712371

2372-
return max_t(u32, max_guarantee / fw_max_bw_share, 1);
2372+
if (max_guarantee)
2373+
return max_t(u32, max_guarantee / fw_max_bw_share, 1);
2374+
return 0;
23732375
}
23742376

2375-
static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
2377+
static int normalize_vports_min_rate(struct mlx5_eswitch *esw)
23762378
{
23772379
u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
2380+
u32 divider = calculate_vports_min_rate_divider(esw);
23782381
struct mlx5_vport *evport;
23792382
u32 vport_max_rate;
23802383
u32 vport_min_rate;
@@ -2387,9 +2390,9 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
23872390
continue;
23882391
vport_min_rate = evport->info.min_rate;
23892392
vport_max_rate = evport->info.max_rate;
2390-
bw_share = MLX5_MIN_BW_SHARE;
2393+
bw_share = 0;
23912394

2392-
if (vport_min_rate)
2395+
if (divider)
23932396
bw_share = MLX5_RATE_TO_BW_SHARE(vport_min_rate,
23942397
divider,
23952398
fw_max_bw_share);
@@ -2414,7 +2417,6 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
24142417
struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
24152418
u32 fw_max_bw_share;
24162419
u32 previous_min_rate;
2417-
u32 divider;
24182420
bool min_rate_supported;
24192421
bool max_rate_supported;
24202422
int err = 0;
@@ -2439,8 +2441,7 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, u16 vport,
24392441

24402442
previous_min_rate = evport->info.min_rate;
24412443
evport->info.min_rate = min_rate;
2442-
divider = calculate_vports_min_rate_divider(esw);
2443-
err = normalize_vports_min_rate(esw, divider);
2444+
err = normalize_vports_min_rate(esw);
24442445
if (err) {
24452446
evport->info.min_rate = previous_min_rate;
24462447
goto unlock;

0 commit comments

Comments
 (0)