Skip to content

Commit a7bf4d5

Browse files
gal-pressmanPaolo Abeni
authored andcommitted
net/mlx5e: Fix maxrate wraparound in threshold between units
The previous calculation used roundup() which caused an overflow for rates between 25.5Gbps and 26Gbps. For example, a rate of 25.6Gbps would result in using 100Mbps units with value of 256, which would overflow the 8 bits field. Simplify the upper_limit_mbps calculation by removing the unnecessary roundup, and adjust the comparison to use <= to correctly handle the boundary condition. Fixes: d888079 ("net/mlx5e: Implement DCBNL IEEE max rate") Signed-off-by: Gal Pressman <gal@nvidia.com> Reviewed-by: Nimrod Oren <noren@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/1762681073-1084058-4-git-send-email-tariqt@nvidia.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 2dc768c commit a7bf4d5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,18 +595,19 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
595595
struct mlx5_core_dev *mdev = priv->mdev;
596596
u8 max_bw_value[IEEE_8021QAZ_MAX_TCS];
597597
u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS];
598-
__u64 upper_limit_mbps = roundup(255 * MLX5E_100MB, MLX5E_1GB);
598+
__u64 upper_limit_mbps;
599599
int i;
600600

601601
memset(max_bw_value, 0, sizeof(max_bw_value));
602602
memset(max_bw_unit, 0, sizeof(max_bw_unit));
603+
upper_limit_mbps = 255 * MLX5E_100MB;
603604

604605
for (i = 0; i <= mlx5_max_tc(mdev); i++) {
605606
if (!maxrate->tc_maxrate[i]) {
606607
max_bw_unit[i] = MLX5_BW_NO_LIMIT;
607608
continue;
608609
}
609-
if (maxrate->tc_maxrate[i] < upper_limit_mbps) {
610+
if (maxrate->tc_maxrate[i] <= upper_limit_mbps) {
610611
max_bw_value[i] = div_u64(maxrate->tc_maxrate[i],
611612
MLX5E_100MB);
612613
max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1;

0 commit comments

Comments
 (0)