]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/mlx5e: E-switch, Fix rate calculation division
authorParav Pandit <parav@nvidia.com>
Wed, 17 Feb 2021 06:23:29 +0000 (08:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Mar 2021 12:30:18 +0000 (14:30 +0200)
[ Upstream commit 8b90d897823b28a51811931f3bdc79f8df79407e ]

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

Fixes: 0e22bfb7c046 ("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>
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index 717fbaa6ce73657b36de5c6717b236c204105cd8..e9b7da05f14a02c1cacf468ff19fcf3bac32f8cb 100644 (file)
@@ -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);