Skip to contentSkip to conversation

net/mlx5/hws: allow relaxed mode in MPLS matching

PATCH In review Erez Shitrit 2 participants 5 messages Sep 10, 2023 – Sep 19, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 net/mlx5/hws: allow relaxed mode in MPLS matching

Remove the previous constrain on relaxed mode, that way it will be like all other matching items, can be used in relaxed or non-relaxed mode.

The previous constrain was due to HW limitation that supports MPLS over specific UDP port, now we give the ability to the user to make sure it is with the right needs for MPLS matching.

---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 45 ++++++++++-----------------
 1 file changed, 17 insertions(+), 28 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +17 -28
index 33d0f2d18e..88f22e7f70 100644
@@ -1320,35 +1320,24 @@ mlx5dr_definer_conv_item_mpls(struct mlx5dr_definer_conv_data *cd,
 		return rte_errno;
 	}
 
-	if (cd->relaxed) {
-		DR_LOG(ERR, "Relaxed mode is not supported");
-		rte_errno = ENOTSUP;
-		return rte_errno;
-	}
-
-	/* Currently support only MPLSoUDP */
-	if (cd->last_item != RTE_FLOW_ITEM_TYPE_UDP &&
-	    cd->last_item != RTE_FLOW_ITEM_TYPE_MPLS) {
-		DR_LOG(ERR, "MPLS supported only after UDP");
-		rte_errno = ENOTSUP;
-		return rte_errno;
-	}
-
-	/* In order to match on MPLS we must match on ip_protocol and l4_dport. */
-	fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, false)];
-	if (!fc->tag_set) {
-		fc->item_idx = item_idx;
-		fc->tag_mask_set = &mlx5dr_definer_ones_set;
-		fc->tag_set = &mlx5dr_definer_udp_protocol_set;
-		DR_CALC_SET(fc, eth_l2, l4_type_bwc, false);
-	}
+	if (!cd->relaxed) {
+		/* In order to match on MPLS we must match on ip_protocol and l4_dport. */
+		fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, false)];
+		if (!fc->tag_set) {
+			fc->item_idx = item_idx;
+			fc->tag_mask_set = &mlx5dr_definer_ones_set;
+			fc->tag_set = &mlx5dr_definer_udp_protocol_set;
+			DR_CALC_SET(fc, eth_l2, l4_type_bwc, false);
+		}
 
-	fc = &cd->fc[DR_CALC_FNAME(L4_DPORT, false)];
-	if (!fc->tag_set) {
-		fc->item_idx = item_idx;
-		fc->tag_mask_set = &mlx5dr_definer_ones_set;
-		fc->tag_set = &mlx5dr_definer_mpls_udp_port_set;
-		DR_CALC_SET(fc, eth_l4, destination_port, false);
+		/* Currently support only MPLSoUDP */
+		fc = &cd->fc[DR_CALC_FNAME(L4_DPORT, false)];
+		if (!fc->tag_set) {
+			fc->item_idx = item_idx;
+			fc->tag_mask_set = &mlx5dr_definer_ones_set;
+			fc->tag_set = &mlx5dr_definer_mpls_udp_port_set;
+			DR_CALC_SET(fc, eth_l4, destination_port, false);
+		}
 	}
 
 	if (m && (!is_mem_zero(m->label_tc_s, 3) || m->ttl)) {
Signature · 1 line
2.18.2
#1 lore raw

PATCH 2/4 net/mlx5/hws: allow attaching action template to matcher

Allow user to add new action-template after the creation of the matcher. It is allowed only if the user indicates in the mlx5dr_matcher_attr that he might add new AT in the future by indicating the max_num_of_at and if needed the max_num_of_actions_in_at value.
With these two values the matcher is configured to get new AT in the future.

---
 drivers/net/mlx5/hws/mlx5dr.h         | 13 +++++
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 82 +++++++++++++++++++++++----
 2 files changed, 83 insertions(+), 12 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +13 -0
index 5592af93c9..184de8feaf 100644
@@ -139,6 +139,8 @@ struct mlx5dr_matcher_attr {
 			uint8_t num_log;
 		} rule;
 	};
+	/* Optional AT attach configuration - Max number of additional AT */
+	uint8_t max_num_of_at_attach;
 };
 
 struct mlx5dr_rule_attr {
@@ -328,6 +330,17 @@ mlx5dr_matcher_create(struct mlx5dr_table *table,
  */
 int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
 
+/* Attach new action template to direct rule matcher.
+ *
+ * @param[in] matcher
+ *	Matcher to attach at to.
+ * @param[in] at
+ *	Action template to be attached to the matcher.
+ * @return zero on success non zero otherwise.
+ */
+int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher,
+			     struct mlx5dr_action_template *at);
+
 /* Get the size of the rule handle (mlx5dr_rule) to be used on rule creation.
  *
  * @return size in bytes of rule handle struct.
drivers/net/mlx5/hws/mlx5dr_matcher.c +70 -12

123 lines not on this page · raw message

Signature · 1 line
2.18.2
#2 lore raw

PATCH 3/4 net/mlx5/hws: print syndrome value on error

In reply to Erez Shitrit

Print the syndrome of failure of FW command.

---
 drivers/net/mlx5/hws/mlx5dr_cmd.c | 48 ++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 14 deletions(-)
drivers/net/mlx5/hws/mlx5dr_cmd.c +34 -14
index f9f220cc6a..7771aeb8cf 100644
@@ -4,6 +4,12 @@
 
 #include "mlx5dr_internal.h"
 
+static uint32_t mlx5dr_cmd_get_syndrome(uint32_t *out)
+{
+	/* Assumption: syndrome is always the second u32 */
+	return be32toh(out[1]);
+}
+
 int mlx5dr_cmd_destroy_obj(struct mlx5dr_devx_obj *devx_obj)
 {
 	int ret;
@@ -39,7 +45,8 @@ mlx5dr_cmd_flow_table_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create FT");
+		DR_LOG(ERR, "Failed to create FT (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -73,7 +80,8 @@ mlx5dr_cmd_flow_table_modify(struct mlx5dr_devx_obj *devx_obj,
 
 	ret = mlx5_glue->devx_obj_modify(devx_obj->obj, in, sizeof(in), out, sizeof(out));
 	if (ret) {
-		DR_LOG(ERR, "Failed to modify FT");
+		DR_LOG(ERR, "Failed to modify FT (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		rte_errno = errno;
 	}
 
@@ -96,7 +104,8 @@ mlx5dr_cmd_flow_table_query(struct mlx5dr_devx_obj *devx_obj,
 
 	ret = mlx5_glue->devx_obj_query(devx_obj->obj, in, sizeof(in), out, sizeof(out));
 	if (ret) {
-		DR_LOG(ERR, "Failed to query FT");
+		DR_LOG(ERR, "Failed to query FT (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		rte_errno = errno;
 		return ret;
 	}
@@ -129,7 +138,8 @@ mlx5dr_cmd_flow_group_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create Flow group");
+		DR_LOG(ERR, "Failed to create Flow group(syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -182,7 +192,8 @@ mlx5dr_cmd_set_fte(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create FTE");
+		DR_LOG(ERR, "Failed to create FTE (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		rte_errno = errno;
 		goto free_devx;
 	}
@@ -325,7 +336,8 @@ mlx5dr_cmd_rtc_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create RTC");
+		DR_LOG(ERR, "Failed to create RTC (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -365,7 +377,8 @@ mlx5dr_cmd_stc_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create STC");
+		DR_LOG(ERR, "Failed to create STC (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -505,7 +518,8 @@ mlx5dr_cmd_stc_modify(struct mlx5dr_devx_obj *devx_obj,
 
 	ret = mlx5_glue->devx_obj_modify(devx_obj->obj, in, sizeof(in), out, sizeof(out));
 	if (ret) {
-		DR_LOG(ERR, "Failed to modify STC FW action_type %d", stc_attr->action_type);
+		DR_LOG(ERR, "Failed to modify STC FW action_type %d (syndrome: %#x)",
+		       stc_attr->action_type, mlx5dr_cmd_get_syndrome(out));
 		rte_errno = errno;
 	}
 
@@ -542,7 +556,8 @@ mlx5dr_cmd_arg_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create ARG");
+		DR_LOG(ERR, "Failed to create ARG (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -606,7 +621,8 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create header_modify_pattern");
+		DR_LOG(ERR, "Failed to create header_modify_pattern (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		rte_errno = errno;
 		goto free_obj;
 	}
@@ -649,7 +665,8 @@ mlx5dr_cmd_ste_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create STE");
+		DR_LOG(ERR, "Failed to create STE (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -708,7 +725,8 @@ mlx5dr_cmd_definer_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create Definer");
+		DR_LOG(ERR, "Failed to create Definer (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
@@ -775,7 +793,8 @@ int mlx5dr_cmd_sq_modify_rdy(struct mlx5dr_devx_obj *devx_obj)
 
 	ret = mlx5_glue->devx_obj_modify(devx_obj->obj, in, sizeof(in), out, sizeof(out));
 	if (ret) {
-		DR_LOG(ERR, "Failed to modify SQ");
+		DR_LOG(ERR, "Failed to modify SQ (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		rte_errno = errno;
 	}
 
@@ -843,7 +862,8 @@ mlx5dr_cmd_alias_obj_create(struct ibv_context *ctx,
 
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
-		DR_LOG(ERR, "Failed to create ALIAS OBJ");
+		DR_LOG(ERR, "Failed to create ALIAS OBJ (syndrome: %#x)",
+		       mlx5dr_cmd_get_syndrome(out));
 		simple_free(devx_obj);
 		rte_errno = errno;
 		return NULL;
Signature · 1 line
2.18.2
#3 lore raw

PATCH 4/4 net/mlx5/hws: skip process action-template on coll matcher

In reply to Erez Shitrit

Collision matcher uses the same action-template and action STE's as its parent matcher, so ne need to redo it.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_matcher.c +4 -1
index a02f42a7e8..102e4f19c8 100644
@@ -714,6 +714,9 @@ static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher)
 	uint32_t required_stes;
 	int i, ret;
 
+	if (matcher->flags & MLX5DR_MATCHER_FLAGS_COLLISION)
+		return 0;
+
 	for (i = 0; i < matcher->num_of_at; i++) {
 		struct mlx5dr_action_template *at = &matcher->at[i];
 
@@ -786,7 +789,7 @@ static void mlx5dr_matcher_unbind_at(struct mlx5dr_matcher *matcher)
 {
 	struct mlx5dr_table *tbl = matcher->tbl;
 
-	if (!matcher->action_ste.max_stes)
+	if (!matcher->action_ste.max_stes || matcher->flags & MLX5DR_MATCHER_FLAGS_COLLISION)
 		return;
 
 	mlx5dr_action_free_single_stc(tbl->ctx, tbl->type, &matcher->action_ste.stc);
Signature · 1 line
2.18.2
#4 lore raw
In reply to Erez Shitrit

Hi,

Quoted 14 lines

-----Original Message-----
From: Erez Shitrit <[email protected]>
Sent: Sunday, September 10, 2023 5:03 PM
To: Alex Vesker <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH 1/4] net/mlx5/hws: allow relaxed mode in MPLS matching

Remove the previous constrain on relaxed mode, that way it will be like all other matching items, can be used in relaxed or non-relaxed mode.

Quoted 7 lines

The previous constrain was due to HW limitation that supports MPLS over specific UDP port, now we give the ability to the user to make sure it is with the right needs for MPLS matching.

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh