Skip to contentSkip to conversation

net/mlx5: fix meter profile validation

PATCH In review Bing Zhao 2 participants 8 messages Jul 29, 2021 Network drivers

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH 1/1 net/mlx5: fix meter profile validation

After the support for yellow color and RFC2698 & RFC4115 were added, the profile validation adjustment was missed. With this fix, the validation is like below:
1. Legacy metering only supports RFC2697 without EBS.
2. ASO metering can support all the three profiles.
3. For backward compatibility, none EBS with RFC2697 profile is still supported and the checking is done in the meter creation stage.

In the meanwhile, some checking which was done in the parameters calculation stage is moved in the validation in order to skip the useless checking.

Fixes 33a7493c8df8 ("net/mlx5: support meter for trTCM profiles")
---
 drivers/common/mlx5/mlx5_prm.h     |   7 +-
 drivers/net/mlx5/mlx5_flow_meter.c | 139 ++++++++++++++++++-----------
 2 files changed, 88 insertions(+), 58 deletions(-)
drivers/common/mlx5/mlx5_prm.h +3 -4
index 5b73a193ee..fdb20f5d49 100644
@@ -3849,10 +3849,9 @@ enum {
 	MLX5_FLOW_COLOR_UNDEFINED,
 };
 
-/* Maximum value of srTCM metering parameters. */
-#define MLX5_SRTCM_CBS_MAX (0xFF * (1ULL << 0x1F))
-#define MLX5_SRTCM_CIR_MAX (8 * (1ULL << 30) * 0xFF)
-#define MLX5_SRTCM_EBS_MAX 0
+/* Maximum value of srTCM & trTCM metering parameters. */
+#define MLX5_SRTCM_XBS_MAX (0xFF * (1ULL << 0x1F))
+#define MLX5_SRTCM_XIR_MAX (8 * (1ULL << 30) * 0xFF)
 
 /* The bits meter color use. */
 #define MLX5_MTR_COLOR_BITS 8
drivers/net/mlx5/mlx5_flow_meter.c +85 -54

178 lines not on this page · raw message

Signature · 1 line
2.27.0
author
#1 lore raw

PATCH 1/1 net/mlx5: fix the 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")
---
 drivers/net/mlx5/mlx5_flow_meter.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_flow_meter.c +10 -4
index 0f51710907..a24bd9c7ae 100644
@@ -245,17 +245,23 @@ mlx5_flow_meter_profile_validate(struct rte_eth_dev *dev,
 static inline void
 mlx5_flow_meter_xir_man_exp_calc(int64_t xir, uint8_t *man, uint8_t *exp)
 {
-	int64_t _cir;
+	int64_t _xir;
 	int64_t delta = INT64_MAX;
 	uint8_t _man = 0;
 	uint8_t _exp = 0;
 	uint64_t m, e;
 
+	/* Special case xir == 0 ? both exp and matissa are 0. */
+	if (xir == 0) {
+		*man = 0;
+		*exp = 0;
+		return;
+	}
 	for (m = 0; m <= 0xFF; m++) { /* man width 8 bit */
 		for (e = 0; e <= 0x1F; e++) { /* exp width 5bit */
-			_cir = (1000000000ULL * m) >> e;
-			if (llabs(xir - _cir) <= delta) {
-				delta = llabs(xir - _cir);
+			_xir = (1000000000ULL * m) >> e;
+			if (llabs(xir - _xir) <= delta) {
+				delta = llabs(xir - _xir);
 				_man = m;
 				_exp = e;
 			}
Signature · 1 line
2.27.0
#2 lore raw

Re: [dpdk-dev] [PATCH] net/mlx5: fix the EIR calculation

Hi,

Quoted 26 lines

-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, July 29, 2021 7:04 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Subject: [PATCH] net/mlx5: fix the 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.

Quoted 8 lines
Fixes 33a7493c8df8 ("net/mlx5: support meter for trTCM profiles")
---
 drivers/net/mlx5/mlx5_flow_meter.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

author
#3 lore raw

PATCH 1/1 net/mlx5: fix the green color policy RSS queues overwritten

In reply to Bing Zhao

Both green policy and yellow policy could support RSS actions simultaneous, the Rx queues configuration may be different between them while the other fields should be the same.

When the only green color policy was supported in the past, the queues copied and saved in the temporary workspace were used. Since the yellow support was added, the queues stored in the thread workspace would be overwritten by the yellow color policy. The flow rule created using a meter with such a policy would have the same RSS distribution for both green and yellow packets.

By using the meter action containers RSS information instead of the workspace RSS, this overwritten can be prevented.

Fixes b38a12272b3a ("net/mlx5: split meter color policy handling")
---
 drivers/net/mlx5/mlx5_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.c +4 -1
index f7f16883cd..0689e6d45d 100644
@@ -4710,7 +4710,7 @@ get_meter_sub_policy(struct rte_eth_dev *dev,
 			uint8_t fate = final_policy->act_cnt[i].fate_action;
 
 			if (fate == MLX5_FLOW_FATE_SHARED_RSS) {
-				const void *rss_act =
+				const struct rte_flow_action_rss *rss_act =
 					final_policy->act_cnt[i].rss->conf;
 				struct rte_flow_action rss_actions[2] = {
 					[0] = {
@@ -4746,6 +4746,9 @@ get_meter_sub_policy(struct rte_eth_dev *dev,
 				rss_desc_v[i].tunnel =
 						!!(dev_flow.handle->layers &
 						   MLX5_FLOW_LAYER_TUNNEL);
+				/* Use the RSS queues in the containers. */
+				rss_desc_v[i].queue =
+					(uint16_t *)(uintptr_t)rss_act->queue;
 				rss_desc[i] = &rss_desc_v[i];
 			} else if (fate == MLX5_FLOW_FATE_QUEUE) {
 				/* This is queue action. */
Signature · 1 line
2.27.0
#4 lore raw

Re: [dpdk-dev] [PATCH] net/mlx5: fix the green color policy RSS queues overwritten

Hi,

Quoted 21 lines

-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, July 29, 2021 7:04 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Subject: [PATCH] net/mlx5: fix the green color policy RSS queues overwritten

Both green policy and yellow policy could support RSS actions simultaneous, the Rx queues configuration may be different between them while the other fields should be the same.

When the only green color policy was supported in the past, the queues copied and saved in the temporary workspace were used. Since the yellow support was added, the queues stored in the thread workspace would be overwritten by the yellow color policy. The flow rule created using a meter with such a policy would have the same RSS distribution for both green and yellow packets.

Quoted 8 lines

By using the meter action containers RSS information instead of the workspace RSS, this overwritten can be prevented.

Fixes b38a12272b3a ("net/mlx5: split meter color policy handling")

---

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

author
#5 lore raw

PATCH 1/1 net/mlx5: fix the meter hierarchy validation with yellow

In reply to Bing Zhao

In mlx5 PMD, the meter hierarchy only supports the green color. It means that a meter action can only be in the green action list. In the meanwhile, the yellow action list should be empty now. Any action for the yellow color policy will be considered invalid if the green color policy is a hierarchy.

Also, the error message printing of meter hierarchy validation is fixed by removing an incorrect checking.

Fixes 4b7bf3ffb473 ("net/mlx5: support yellow in meter policy validation")
Fixes a3b7af90baba ("net/mlx5: validate meter action in policy")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +8 -3
index 837450722a..d5669e209d 100644
@@ -17691,9 +17691,14 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
 					return -rte_mtr_error_set(error,
 						ENOTSUP,
 						RTE_MTR_ERROR_TYPE_METER_POLICY,
-						NULL, flow_err.message ?
-						flow_err.message :
-				  "Meter hierarchy only supports GREEN color.");
+						NULL,
+						"Meter hierarchy only supports GREEN color.");
+				if (*policy_mode != MLX5_MTR_POLICY_MODE_OG)
+					return -rte_mtr_error_set(error,
+						ENOTSUP,
+						RTE_MTR_ERROR_TYPE_METER_POLICY,
+						NULL,
+						"No yellow policy should be provided in meter hierarchy.");
 				mtr = act->conf;
 				ret = flow_dv_validate_policy_mtr_hierarchy(dev,
 							mtr->mtr_id,
Signature · 1 line
2.27.0
#6 lore raw

Re: [dpdk-dev] [PATCH] net/mlx5: fix the meter hierarchy validation with yellow

Hi,

Quoted 22 lines

-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, July 29, 2021 7:04 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Shun Hao <[email protected]>
Subject: [PATCH] net/mlx5: fix the meter hierarchy validation with yellow

In mlx5 PMD, the meter hierarchy only supports the green color. It means that a meter action can only be in the green action list. In the meanwhile, the yellow action list should be empty now. Any action for the yellow color policy will be considered invalid if the green color policy is a hierarchy.

Also, the error message printing of meter hierarchy validation is fixed by removing an incorrect checking.

Fixes 4b7bf3ffb473 ("net/mlx5: support yellow in meter policy validation")
Fixes a3b7af90baba ("net/mlx5: validate meter action in policy")
Quoted 6 lines
---
 drivers/net/mlx5/mlx5_flow_dv.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

#7 lore raw
In reply to Bing Zhao

Hi,

Quoted 23 lines

-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, July 29, 2021 7:04 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Subject: [PATCH] net/mlx5: fix meter profile validation

After the support for yellow color and RFC2698 & RFC4115 were added, the profile validation adjustment was missed. With this fix, the validation is like below:
1. Legacy metering only supports RFC2697 without EBS.
2. ASO metering can support all three profiles.
3. For backward compatibility, none EBS with RFC2697 profile is still supported and the checking is done in the meter creation stage.

In the meanwhile, some checking which was done in the parameters calculation stage is moved in the validation in order to skip the useless checking.

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

---

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh