DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: fix Committed Bucket Size calculation
@ 2022-02-07 13:28 Alexander Kozyrev
  2022-02-09  8:53 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kozyrev @ 2022-02-07 13:28 UTC (permalink / raw)
  To: dev; +Cc: stable, rasland, viacheslavo, matan, suanmingm

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: 3bd26b23cef ("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 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index 0dc7fbfb32..d0f8bcd100 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -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;
 }
-- 
2.18.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] net/mlx5: fix Committed Bucket Size calculation
  2022-02-07 13:28 [PATCH] net/mlx5: fix Committed Bucket Size calculation Alexander Kozyrev
@ 2022-02-09  8:53 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2022-02-09  8:53 UTC (permalink / raw)
  To: Alexander Kozyrev, dev; +Cc: stable, Slava Ovsiienko, Matan Azrad, Suanming Mou

Hi,

> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Monday, February 7, 2022 3:29 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad <matan@nvidia.com>;
> Suanming Mou <suanmingm@nvidia.com>
> Subject: [PATCH] net/mlx5: fix Committed Bucket Size calculation
> 
> 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: 3bd26b23cef ("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>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-09  8:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 13:28 [PATCH] net/mlx5: fix Committed Bucket Size calculation Alexander Kozyrev
2022-02-09  8:53 ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).