]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: fix committed bucket size
authorAlexander Kozyrev <akozyrev@nvidia.com>
Mon, 7 Feb 2022 13:28:40 +0000 (15:28 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Thu, 10 Feb 2022 08:44:32 +0000 (09:44 +0100)
Committed Bucket Size calculation tries to fit into 8-bit wide
mantissa field by setting 256 as a maximum value for it.
To compensate for this increase in the mantissa value the exponent
value has to be reduced by 8. But it gives a negative exponent
value for CBS less than 128. And negative exponent value is not
supported by the NIC. Adjust CSB calculation only for values
bigger than 128 to allow both small and big bucket sizes.

Fixes: 3bd26b23cefc ("net/mlx5: support meter profile operations")
Cc: stable@dpdk.org
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
drivers/net/mlx5/mlx5_flow_meter.c

index 0dc7fbfb3232073a5fbaeabb1401b2f038f242b0..d0f8bcd10010a6f35d8b797af081333eb58ec210 100644 (file)
@@ -295,8 +295,10 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp)
        }
        /* xbs = xbs_mantissa * 2^xbs_exponent */
        _man = frexp(xbs, &_exp);
-       _man = _man * pow(2, MLX5_MAN_WIDTH);
-       _exp = _exp - MLX5_MAN_WIDTH;
+       if (_exp >= MLX5_MAN_WIDTH) {
+               _man = _man * pow(2, MLX5_MAN_WIDTH);
+               _exp = _exp - MLX5_MAN_WIDTH;
+       }
        *man = (uint8_t)ceil(_man);
        *exp = _exp;
 }