]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net/mlx5: Disable QoS when min_rates on all VFs are zero
authorVladyslav Tarasiuk <vladyslavt@nvidia.com>
Wed, 21 Oct 2020 08:05:41 +0000 (11:05 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Nov 2020 12:05:41 +0000 (13:05 +0100)
[ Upstream commit 470b74758260e4abc2508cf1614573c00a00465c ]

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: c9497c98901c ("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>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

index 387758fc6be499c81a442db7e482fc1f42a26526..fec01d294ed4565149ebe8cae819bdb07814f555 100644 (file)
@@ -1921,12 +1921,15 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
                max_guarantee = evport->info.min_rate;
        }
 
-       return max_t(u32, max_guarantee / fw_max_bw_share, 1);
+       if (max_guarantee)
+               return max_t(u32, max_guarantee / fw_max_bw_share, 1);
+       return 0;
 }
 
-static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
+static int normalize_vports_min_rate(struct mlx5_eswitch *esw)
 {
        u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
+       u32 divider = calculate_vports_min_rate_divider(esw);
        struct mlx5_vport *evport;
        u32 vport_max_rate;
        u32 vport_min_rate;
@@ -1940,9 +1943,9 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
                        continue;
                vport_min_rate = evport->info.min_rate;
                vport_max_rate = evport->info.max_rate;
-               bw_share = MLX5_MIN_BW_SHARE;
+               bw_share = 0;
 
-               if (vport_min_rate)
+               if (divider)
                        bw_share = MLX5_RATE_TO_BW_SHARE(vport_min_rate,
                                                         divider,
                                                         fw_max_bw_share);
@@ -1967,7 +1970,6 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
        struct mlx5_vport *evport;
        u32 fw_max_bw_share;
        u32 previous_min_rate;
-       u32 divider;
        bool min_rate_supported;
        bool max_rate_supported;
        int err = 0;
@@ -1993,8 +1995,7 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
 
        previous_min_rate = evport->info.min_rate;
        evport->info.min_rate = min_rate;
-       divider = calculate_vports_min_rate_divider(esw);
-       err = normalize_vports_min_rate(esw, divider);
+       err = normalize_vports_min_rate(esw);
        if (err) {
                evport->info.min_rate = previous_min_rate;
                goto unlock;