net/mlx5: fix meter EIR calculation
authorBing Zhao <bingz@nvidia.com>
Thu, 29 Jul 2021 16:04:03 +0000 (19:04 +0300)
committerRaslan Darawsheh <rasland@nvidia.com>
Thu, 29 Jul 2021 20:05:36 +0000 (22:05 +0200)
commita9e3a4a9e2dc583d827fbb4c7e427aa5af98281a
treefd0e19791011158aaad51984ce3479eb2b254215
parent8a0fca1101212c0980b8c007359b843d12854c7e
net/mlx5: fix meter EIR calculation

Before the yellow color policy was supported, the only supported
profile of metering is RFC2697 and EIR is not part of the profile.
When creating a meter with this profile, the EIR part was always
zero.

After the yellow color policy supported and RFC2698 & 4115 support
was introduced, EIR is relevant and should be calculated. Usually
the EIR could not be zero and the formula for calculating CIR
mantissa & exponent could be reused.

The EIR could be 0 and then only green and red colors will be
supported from the specification. Both the mantissa and exponent
parts should be set to 0. Currently, the formula wrongly sets
non-zero values for the EIR=0 case.

Setting the mantissa and the exponent parts to zeros when EIR is 0
will solve the issue.

Fixes: 33a7493c8df8 ("net/mlx5: support meter for trTCM profiles")

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/mlx5_flow_meter.c