Skip to content

Commit

Permalink
net/mlx5e: E-switch, Fix rate calculation division
Browse files Browse the repository at this point in the history
[ Upstream commit 8b90d89 ]

do_div() returns reminder, while cited patch wanted to use
quotient.
Fix it by using quotient.

Fixes: 0e22bfb ("net/mlx5e: E-switch, Fix rate calculation for overflow")
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
paravmellanox authored and gregkh committed Mar 30, 2021
1 parent 49f80b1 commit cbe40c7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5040,7 +5040,8 @@ static int apply_police_params(struct mlx5e_priv *priv, u64 rate,
*/
if (rate) {
rate = (rate * BITS_PER_BYTE) + 500000;
rate_mbps = max_t(u64, do_div(rate, 1000000), 1);
do_div(rate, 1000000);
rate_mbps = max_t(u32, rate, 1);
}

err = mlx5_esw_modify_vport_rate(esw, vport_num, rate_mbps);
Expand Down

0 comments on commit cbe40c7

Please sign in to comment.