Skip to contentSkip to conversation

net/mlx5: fix Committed Bucket Size calculation

PATCH In review Alexander Kozyrev 2 participants 2 messages Feb 7, 2022 – Feb 9, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/net/mlx5/mlx5_flow_meter.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow_meter.c +4 -2
index 0dc7fbfb32..d0f8bcd100 100644
@@ -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;
 }
Signature · 1 line
2.18.2
#1 lore raw

Hi,

Quoted 17 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Monday, February 7, 2022 3:29 PM
To: [email protected]
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Suanming Mou <[email protected]>
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.

Quoted 5 lines
Fixes 3bd26b23cef ("net/mlx5: support meter profile operations")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh