提交 09010f4e 编写于 作者: V Vladyslav Tarasiuk 提交者: Yang Yingliang

net/mlx5: Disable QoS when min_rates on all VFs are zero

stable inclusion
from linux-4.19.160
commit ba0046dc414d64fff9bd5d74a0641cd25b214a2a

--------------------------------

[ Upstream commit 470b7475 ]

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: c9497c98 ("net/mlx5: Add support for setting VF min rate")
Signed-off-by: NVladyslav Tarasiuk <vladyslavt@nvidia.com>
Reviewed-by: NMoshe Shemesh <moshe@nvidia.com>
Signed-off-by: NSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NAichun Li <liaichun@huawei.com>
Reviewed-by: Nwangxiaopeng <wangxiaopeng7@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 646db3ae
...@@ -1999,12 +1999,15 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw) ...@@ -1999,12 +1999,15 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
max_guarantee = evport->info.min_rate; 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 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; struct mlx5_vport *evport;
u32 vport_max_rate; u32 vport_max_rate;
u32 vport_min_rate; u32 vport_min_rate;
...@@ -2018,9 +2021,9 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider) ...@@ -2018,9 +2021,9 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
continue; continue;
vport_min_rate = evport->info.min_rate; vport_min_rate = evport->info.min_rate;
vport_max_rate = evport->info.max_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, bw_share = MLX5_RATE_TO_BW_SHARE(vport_min_rate,
divider, divider,
fw_max_bw_share); fw_max_bw_share);
...@@ -2045,7 +2048,6 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport, ...@@ -2045,7 +2048,6 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
struct mlx5_vport *evport; struct mlx5_vport *evport;
u32 fw_max_bw_share; u32 fw_max_bw_share;
u32 previous_min_rate; u32 previous_min_rate;
u32 divider;
bool min_rate_supported; bool min_rate_supported;
bool max_rate_supported; bool max_rate_supported;
int err = 0; int err = 0;
...@@ -2071,8 +2073,7 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport, ...@@ -2071,8 +2073,7 @@ int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
previous_min_rate = evport->info.min_rate; previous_min_rate = evport->info.min_rate;
evport->info.min_rate = min_rate; evport->info.min_rate = min_rate;
divider = calculate_vports_min_rate_divider(esw); err = normalize_vports_min_rate(esw);
err = normalize_vports_min_rate(esw, divider);
if (err) { if (err) {
evport->info.min_rate = previous_min_rate; evport->info.min_rate = previous_min_rate;
goto unlock; goto unlock;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册