Skip to contentSkip to conversation

net/mlx5/hws: move warn into debug level when needed

PATCH Superseded Itamar Gozlan 4 participants 34 messages Mar 14, 2024 – May 20, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/13 net/mlx5/hws: move warn into debug level when needed

From: Erez Shitrit <[email protected]>

When the user tries to create a matcher and if failed with specific errno (E2BIG) the message will be in debug level and not in warning. It is a part of a feature when the user re-try to insert a new matching depends on that errno, no need the annoying message.

Fixes c55c2bf3533 ("net/mlx5/hws: net/mlx5/hws: add definer layer")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 6 +++---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +3 -3
index 35a2ed2048..81d0e0e6df 100644
@@ -3534,7 +3534,7 @@ mlx5dr_definer_find_best_match_fit(struct mlx5dr_context *ctx,
 		return 0;
 	}
 
-	DR_LOG(ERR, "Unable to find supporting match/jumbo definer combination");
+	DR_LOG(DEBUG, "Unable to find supporting match/jumbo definer combination");
 	rte_errno = E2BIG;
 	return rte_errno;
 }
@@ -3689,7 +3689,7 @@ mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher,
 	/* Find the match definer layout for header layout match union */
 	ret = mlx5dr_definer_find_best_match_fit(ctx, match_definer, match_hl);
 	if (ret) {
-		DR_LOG(ERR, "Failed to create match definer from header layout");
+		DR_LOG(DEBUG, "Failed to create match definer from header layout");
 		goto free_fc;
 	}
 
@@ -4041,7 +4041,7 @@ int mlx5dr_definer_matcher_init(struct mlx5dr_context *ctx,
 
 	ret = mlx5dr_definer_calc_layout(matcher, &match_layout, &range_layout);
 	if (ret) {
-		DR_LOG(ERR, "Failed to calculate matcher definer layout");
+		DR_LOG(DEBUG, "Failed to calculate matcher definer layout");
 		return ret;
 	}
 
drivers/net/mlx5/hws/mlx5dr_matcher.c +1 -1
index 1c64abfa57..1213e7f0ad 100644
@@ -877,7 +877,7 @@ static int mlx5dr_matcher_bind_mt(struct mlx5dr_matcher *matcher)
 	/* Calculate match, range and hash definers */
 	ret = mlx5dr_definer_matcher_init(ctx, matcher);
 	if (ret) {
-		DR_LOG(ERR, "Failed to set matcher templates with match definers");
+		DR_LOG(DEBUG, "Failed to set matcher templates with match definers");
 		return ret;
 	}
 
Signature · 1 line
2.39.3
#1 lore raw

PATCH 2/13 common/mlx5: fix error in mlx5 prm structs

From: Yevgeny Kliteynik <[email protected]>

Fix wrong reserved size and add helpful comment

Fixes 365cdf5f8ce ("net/mlx5/hws: add command layer")
---
 drivers/common/mlx5/mlx5_prm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/common/mlx5/mlx5_prm.h +3 -3
index c671c75bfd..c6846cdb7e 100644
@@ -2360,8 +2360,8 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {
 	u8 reserved_at_d0[0x3];
 	u8 log_conn_track_max_alloc[0x5];
 	u8 reserved_at_d8[0x3];
-	u8 log_max_conn_track_offload[0x5];
-	u8 cross_vhca_object_to_object_supported[0x20]; /* End of DW7. */
+	u8 log_max_conn_track_offload[0x5]; /* End of DW7. */
+	u8 cross_vhca_object_to_object_supported[0x20];
 	u8 allowed_object_for_other_vhca_access_high[0x20];
 	u8 allowed_object_for_other_vhca_access[0x20];
 	u8 reserved_at_140[0x20];
@@ -3655,7 +3655,7 @@ struct mlx5_ifc_stc_ste_param_vport_bits {
 	u8 eswitch_owner_vhca_id[0x10];
 	u8 vport_number[0x10];
 	u8 eswitch_owner_vhca_id_valid[0x1];
-	u8 reserved_at_21[0x59];
+	u8 reserved_at_21[0x5f];
 };
 
 union mlx5_ifc_stc_param_bits {
Signature · 1 line
2.39.3
#2 lore raw

PATCH 3/13 net/mlx5/hws: fix wrong comment in mlx5dr_send

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Remove comment that documents parameter that doesn't exist.

Fixes 3eb748869d2d ("net/mlx5/hws: add send layer")
---
 drivers/net/mlx5/hws/mlx5dr_send.h | 2 --
 1 file changed, 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_send.h +0 -2
index c4eaea52ab..0c89faa8a7 100644
@@ -203,8 +203,6 @@ struct mlx5dr_send_ste_attr {
  *   value to write in CPU endian format.
  * @param addr
  *   Address to write to.
- * @param lock
- *   Address of the lock to use for that UAR access.
  */
 static __rte_always_inline void
 mlx5dr_uar_write64_relaxed(uint64_t val, void *addr)
Signature · 1 line
2.39.3
#3 lore raw

PATCH 4/13 net/mlx5/hws: remove unused capabilities and fields

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

The following caps were never in use:
- wire_regc
- metadata_c
- metadata_c_mask
Also send ring's reg_addr field wasn't in use.

Removing these caps and fields from structs and removing the code that queried them.

---
 drivers/net/mlx5/hws/mlx5dr_cmd.c  | 11 ++---------
 drivers/net/mlx5/hws/mlx5dr_cmd.h  |  3 ---
 drivers/net/mlx5/hws/mlx5dr_send.c |  1 -
 drivers/net/mlx5/hws/mlx5dr_send.h |  1 -
 4 files changed, 2 insertions(+), 14 deletions(-)
drivers/net/mlx5/hws/mlx5dr_cmd.c +2 -9
index 0e0cc479a6..666d678b42 100644
@@ -1344,12 +1344,10 @@ int mlx5dr_cmd_query_caps(struct ibv_context *ctx,
 	strlcpy(caps->fw_ver, attr_ex.orig_attr.fw_ver, sizeof(caps->fw_ver));
 
 	port_info = flow_hw_get_wire_port(ctx);
-	if (port_info) {
-		caps->wire_regc = port_info->regc_value;
+	if (port_info)
 		caps->wire_regc_mask = port_info->regc_mask;
-	} else {
+	else
 		DR_LOG(INFO, "Failed to query wire port regc value");
-	}
 
 	return ret;
 }
@@ -1374,10 +1372,5 @@ int mlx5dr_cmd_query_ib_port(struct ibv_context *ctx,
 	vport_caps->vport_num = port_info.vport_id;
 	vport_caps->esw_owner_vhca_id = port_info.esw_owner_vhca_id;
 
-	if (port_info.query_flags & MLX5_PORT_QUERY_REG_C0) {
-		vport_caps->metadata_c = port_info.vport_meta_tag;
-		vport_caps->metadata_c_mask = port_info.vport_meta_mask;
-	}
-
 	return 0;
 }
drivers/net/mlx5/hws/mlx5dr_cmd.h +0 -3
index 9d385fc57f..ea5d346d8e 100644
@@ -194,8 +194,6 @@ struct mlx5dr_cmd_query_ft_caps {
 struct mlx5dr_cmd_query_vport_caps {
 	uint16_t vport_num;
 	uint16_t esw_owner_vhca_id;
-	uint32_t metadata_c;
-	uint32_t metadata_c_mask;
 };
 
 struct mlx5dr_cmd_generate_wqe_attr {
@@ -207,7 +205,6 @@ struct mlx5dr_cmd_generate_wqe_attr {
 };
 
 struct mlx5dr_cmd_query_caps {
-	uint32_t wire_regc;
 	uint32_t wire_regc_mask;
 	uint32_t flex_protocols;
 	uint8_t wqe_based_update;
drivers/net/mlx5/hws/mlx5dr_send.c +0 -1
index f749401c6f..d58fdb108f 100644
@@ -729,7 +729,6 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	buf_sz = queue->num_entries * MAX_WQES_PER_RULE;
 	sq_log_buf_sz = log2above(buf_sz);
 	sq_buf_sz = 1 << (sq_log_buf_sz + log2above(MLX5_SEND_WQE_BB));
-	sq->reg_addr = queue->uar->reg_addr;
 
 	page_size = sysconf(_SC_PAGESIZE);
 	buf_aligned = align(sq_buf_sz, page_size);
drivers/net/mlx5/hws/mlx5dr_send.h +0 -1
index 0c89faa8a7..48593adbed 100644
@@ -114,7 +114,6 @@ struct mlx5dr_send_ring_sq {
 	char *buf;
 	uint32_t sqn;
 	__be32 *db;
-	void *reg_addr;
 	uint16_t cur_post;
 	uint16_t buf_mask;
 	struct mlx5dr_send_ring_priv *wr_priv;
Signature · 1 line
2.39.3
#4 lore raw

PATCH 5/13 net/mlx5/hws: return -rte_errno on rule creation failure

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

mlx5dr_rule_create returns -ret, so internal functions should return rte_errno on failure. Fix return values of the function that creates rule in root table.

---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +1 -1
index f14e1e6ecd..7bcf2de55f 100644
@@ -733,7 +733,7 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
 free_attr:
 	simple_free(attr);
 
-	return -rte_errno;
+	return rte_errno;
 }
 
 static int mlx5dr_rule_destroy_root(struct mlx5dr_rule *rule,
Signature · 1 line
2.39.3
#5 lore raw

PATCH 6/13 net/mlx5/hws: simplify send_queues_close code

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Small simplification to the send_queues_close code

---
 drivers/net/mlx5/hws/mlx5dr_send.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/mlx5/hws/mlx5dr_send.c +2 -7
index d58fdb108f..d61862f074 100644
@@ -970,13 +970,8 @@ int mlx5dr_send_queue_open(struct mlx5dr_context *ctx,
 
 static void __mlx5dr_send_queues_close(struct mlx5dr_context *ctx, uint16_t queues)
 {
-	struct mlx5dr_send_engine *queue;
-
-	while (queues--) {
-		queue = &ctx->send_queue[queues];
-
-		mlx5dr_send_queue_close(queue);
-	}
+	while (queues--)
+		mlx5dr_send_queue_close(&ctx->send_queue[queues]);
 }
 
 void mlx5dr_send_queues_close(struct mlx5dr_context *ctx)
Signature · 1 line
2.39.3
#6 lore raw

PATCH 7/13 net/mlx5/hws: fix error flow in mlx5dr_context_open

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Add missing spinlock destruction in error flow.

Fixes b0290e56dd08 ("net/mlx5/hws: add context object")
---
 drivers/net/mlx5/hws/mlx5dr_context.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/hws/mlx5dr_context.c +1 -0
index 15d53c578a..7f120b3b1b 100644
@@ -263,6 +263,7 @@ struct mlx5dr_context *mlx5dr_context_open(struct ibv_context *ibv_ctx,
 free_caps:
 	simple_free(ctx->caps);
 free_ctx:
+	pthread_spin_destroy(&ctx->ctrl_lock);
 	simple_free(ctx);
 	return NULL;
 }
Signature · 1 line
2.39.3
#7 lore raw

PATCH 8/13 net/mlx5/hws: fix code analysis error in passing 0 enum val

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Instead of passing 0 as an enum parameter, define flag NONE. This resolves the following code analysis error: "enumerated type mixed with another type".
This value is currently used in tests only, and will later be used in backward-compatible steering API.

Fixes 5cadd74fbc08 ("net/mlx5: add HW steering low-level abstract stub")
---
 drivers/net/mlx5/hws/mlx5dr.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 80e118a980..d2c426e679 100644
@@ -82,6 +82,7 @@ enum mlx5dr_action_aso_ct_flags {
 };
 
 enum mlx5dr_match_template_flags {
+	MLX5DR_MATCH_TEMPLATE_FLAG_NONE = 0,
 	/* Allow relaxed matching by skipping derived dependent match fields. */
 	MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH = 1,
 };
Signature · 1 line
2.39.3
#8 lore raw

PATCH 9/13 net/mlx5/hws: simplify code for updating CQ doorbell record

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Simplify the code that does CQ poll - have DB record update as part of CQ polling.

---
 drivers/net/mlx5/hws/mlx5dr_send.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/mlx5/hws/mlx5dr_send.c +3 -6
index d61862f074..2942668e76 100644
@@ -594,7 +594,7 @@ static void mlx5dr_send_engine_poll_cq(struct mlx5dr_send_engine *queue,
 	    cqe_owner != sw_own)
 		return;
 
-	if (unlikely(mlx5dv_get_cqe_opcode(cqe) != MLX5_CQE_REQ))
+	if (unlikely(cqe_opcode != MLX5_CQE_REQ))
 		queue->err = true;
 
 	rte_io_rmb();
@@ -611,6 +611,7 @@ static void mlx5dr_send_engine_poll_cq(struct mlx5dr_send_engine *queue,
 	cq->poll_wqe = (wqe_cnt + priv->num_wqebbs) & sq->buf_mask;
 	mlx5dr_send_engine_update(queue, cqe, priv, res, i, res_nb, wqe_cnt);
 	cq->cons_index++;
+	*cq->db = htobe32(cq->cons_index & 0xffffff);
 }
 
 static void mlx5dr_send_engine_poll_cqs(struct mlx5dr_send_engine *queue,
@@ -620,13 +621,9 @@ static void mlx5dr_send_engine_poll_cqs(struct mlx5dr_send_engine *queue,
 {
 	int j;
 
-	for (j = 0; j < MLX5DR_NUM_SEND_RINGS; j++) {
+	for (j = 0; j < MLX5DR_NUM_SEND_RINGS; j++)
 		mlx5dr_send_engine_poll_cq(queue, &queue->send_ring[j],
 					   res, polled, res_nb);
-
-		*queue->send_ring[j].send_cq.db =
-			htobe32(queue->send_ring[j].send_cq.cons_index & 0xffffff);
-	}
 }
 
 static void mlx5dr_send_engine_poll_list(struct mlx5dr_send_engine *queue,
Signature · 1 line
2.39.3
#9 lore raw

PATCH 10/13 net/mlx5/hws: fix rule is in resize check

In reply to Itamar Gozlan

From: Alex Vesker <[email protected]>

The check to detect if a rule is in resize was done incorrectly, this can lead to an incorrect function call upon completion for rules which are not in resize (move).
Since the resize_info is in a union we cannot rely only on the pointer value but also need to make sure the matcher is in resize process, this assures us the resize info is valid.

Fixes 762feceb8294 ("net/mlx5/hws: support resizable matchers")
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 7 +++++++
 drivers/net/mlx5/hws/mlx5dr_rule.h | 6 +-----
 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +7 -0
index 7bcf2de55f..3e8e90ba76 100644
@@ -350,6 +350,13 @@ static void mlx5dr_rule_move_init(struct mlx5dr_rule *rule,
 	rule->resize_info->state = MLX5DR_RULE_RESIZE_STATE_WRITING;
 }
 
+bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule)
+{
+	return unlikely(mlx5dr_matcher_is_in_resize(rule->matcher)) &&
+	       rule->resize_info &&
+	       rule->resize_info->state != MLX5DR_RULE_RESIZE_STATE_IDLE;
+}
+
 static int mlx5dr_rule_create_hws_fw_wqe(struct mlx5dr_rule *rule,
 					 struct mlx5dr_rule_attr *attr,
 					 uint8_t mt_idx,
drivers/net/mlx5/hws/mlx5dr_rule.h +1 -5
index 07adf9c5ad..dffaec1c0f 100644
@@ -72,10 +72,6 @@ int mlx5dr_rule_move_hws_remove(struct mlx5dr_rule *rule,
 int mlx5dr_rule_move_hws_add(struct mlx5dr_rule *rule,
 			     struct mlx5dr_rule_attr *attr);
 
-static inline bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule)
-{
-	return rule->resize_info &&
-	       rule->resize_info->state != MLX5DR_RULE_RESIZE_STATE_IDLE;
-}
+bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule);
 
 #endif /* MLX5DR_RULE_H_ */
Signature · 1 line
2.39.3
#10 lore raw

PATCH 11/13 net/mlx5/hws: drop at attach number of actions

In reply to Itamar Gozlan

From: Alex Vesker <[email protected]>

Requesting the user for number of action resources is not defined well enough, instead the user should provide an initial action template which should contain the future attached action templates.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mlx5/hws/mlx5dr_matcher.c +7 -0
index 1213e7f0ad..78d525e578 100644
@@ -785,6 +785,13 @@ static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher)
 	if (matcher->flags & MLX5DR_MATCHER_FLAGS_COLLISION)
 		return 0;
 
+	if (matcher->attr.max_num_of_at_attach &&
+	    mlx5dr_matcher_req_fw_wqe(matcher)) {
+		DR_LOG(ERR, "FW extended matcher doesn't support additional at");
+		rte_errno = ENOTSUP;
+		return rte_errno;
+	}
+
 	for (i = 0; i < matcher->num_of_at; i++) {
 		struct mlx5dr_action_template *at = &matcher->at[i];
 
Signature · 1 line
2.39.3
#11 lore raw

PATCH 12/13 net/mlx5/hws: extending tag saving for match and jumbo

In reply to Itamar Gozlan

From: Erez Shitrit <[email protected]>

Save the exact tag when matching over jumbo masking.

Fixes 348cdeec6472 ("net/mlx5/hws: add FW WQE rule creation logic")
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +7 -2
index 3e8e90ba76..d56677a1a5 100644
@@ -195,8 +195,13 @@ mlx5dr_rule_save_delete_info(struct mlx5dr_rule *rule,
 		rule->tag_ptr = simple_calloc(2, sizeof(*rule->tag_ptr));
 		assert(rule->tag_ptr);
 
-		src_tag = (uint8_t *)ste_attr->wqe_data->tag;
-		memcpy(rule->tag_ptr[0].match, src_tag, MLX5DR_MATCH_TAG_SZ);
+		if (is_jumbo)
+			memcpy(rule->tag_ptr[0].jumbo, ste_attr->wqe_data->action,
+			       MLX5DR_JUMBO_TAG_SZ);
+		else
+			memcpy(rule->tag_ptr[0].match, ste_attr->wqe_data->tag,
+			       MLX5DR_MATCH_TAG_SZ);
+
 		rule->tag_ptr[1].reserved[0] = ste_attr->send_attr.match_definer_id;
 
 		/* Save range definer id and tag for delete */
Signature · 1 line
2.39.3
#12 lore raw

PATCH 13/13 net/mlx5/hws: fix port ID for root matcher and rule

In reply to Itamar Gozlan

From: Erez Shitrit <[email protected]>

In root tables matcher and rule need to have their port-id, otherwise the translate function that done in dpdk layer will not get the right attributes.
For that whenever the matcher is matching the source-port we need to get the relevant port-id before calling the translate function.

Fixes 405242c52dd5 ("net/mlx5/hws: add rule object")
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 17 +++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_rule.c    | 18 ++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h          | 18 ++++++++++++++++++
 3 files changed, 53 insertions(+)
drivers/net/mlx5/hws/mlx5dr_matcher.c +17 -0
index 78d525e578..394244b55b 100644
@@ -1227,6 +1227,7 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher)
 	struct mlx5dv_flow_match_parameters *mask;
 	struct mlx5_flow_attr flow_attr = {0};
 	struct rte_flow_error rte_error;
+	struct rte_flow_item *item;
 	uint8_t match_criteria;
 	int ret;
 
@@ -1255,6 +1256,22 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher)
 		return rte_errno;
 	}
 
+	/* We need the port id in case of matching representor */
+	item = matcher->mt[0].items;
+	while (item->type != RTE_FLOW_ITEM_TYPE_END) {
+		if (item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ||
+		    item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) {
+			ret = flow_hw_get_port_id_from_ctx(ctx, &flow_attr.port_id);
+			if (ret) {
+				DR_LOG(ERR, "Failed to get port id for dev %s",
+				       ctx->ibv_ctx->device->name);
+				rte_errno = EINVAL;
+				return rte_errno;
+			}
+		}
+		++item;
+	}
+
 	mask = simple_calloc(1, MLX5_ST_SZ_BYTES(fte_match_param) +
 			     offsetof(struct mlx5dv_flow_match_parameters, match_buf));
 	if (!mask) {
drivers/net/mlx5/hws/mlx5dr_rule.c +18 -0
index d56677a1a5..5dae4f3442 100644
@@ -692,10 +692,28 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
 	struct mlx5dv_flow_match_parameters *value;
 	struct mlx5_flow_attr flow_attr = {0};
 	struct mlx5dv_flow_action_attr *attr;
+	const struct rte_flow_item *cur_item;
 	struct rte_flow_error error;
 	uint8_t match_criteria;
 	int ret;
 
+	/* We need the port id in case of matching representor */
+	cur_item = items;
+	while (cur_item->type != RTE_FLOW_ITEM_TYPE_END) {
+		if (cur_item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ||
+		    cur_item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) {
+			ret = flow_hw_get_port_id_from_ctx(rule->matcher->tbl->ctx,
+							   &flow_attr.port_id);
+			if (ret) {
+				DR_LOG(ERR, "Failed to get port id for dev %s",
+				       rule->matcher->tbl->ctx->ibv_ctx->device->name);
+				rte_errno = EINVAL;
+				return rte_errno;
+			}
+		}
+		++cur_item;
+	}
+
 	attr = simple_calloc(num_actions, sizeof(*attr));
 	if (!attr) {
 		rte_errno = ENOMEM;
drivers/net/mlx5/mlx5_flow.h +18 -0
index 34b5e0f45b..e435a686fd 100644
@@ -2001,6 +2001,24 @@ flow_hw_get_reg_id(struct rte_eth_dev *dev,
 #endif
 }
 
+static __rte_always_inline int
+flow_hw_get_port_id_from_ctx(void *dr_ctx, uint32_t *port_val)
+{
+	uint32_t port;
+
+	MLX5_ETH_FOREACH_DEV(port, NULL) {
+		struct mlx5_priv *priv;
+		priv = rte_eth_devices[port].data->dev_private;
+
+		if (priv->dr_ctx == dr_ctx) {
+			*port_val = port;
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+
 /**
  * Get GENEVE TLV option FW information according type and class.
  *
Signature · 1 line
2.39.3
#13 lore raw
In reply to Itamar Gozlan

Hi,

Quoted 21 lines

-----Original Message-----
From: Itamar Gozlan <[email protected]>
Sent: Thursday, March 14, 2024 1:42 PM
To: Itamar Gozlan <[email protected]>; Erez Shitrit <[email protected]>; Hamdan Agbariya <[email protected]>; Yevgeny Kliteynik <[email protected]>; Alex Vesker <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Mark Bloch <[email protected]>
Cc: [email protected]; Maayan Kashani <[email protected]>
Subject: [PATCH 01/13] net/mlx5/hws: move warn into debug level when needed

From: Erez Shitrit <[email protected]>

When the user tries to create a matcher and if failed with specific errno (E2BIG) the message will be in debug level and not in warning.
It is a part of a feature when the user re-try to insert a new matching depends on that errno, no need the annoying message.

Quoted 4 lines
Fixes c55c2bf3533 ("net/mlx5/hws: net/mlx5/hws: add definer layer")

Fixed Cc stable on several patches on this series, and reworded the commits Series applied to next-net-mlx,

Kindest regards
Raslan Darawsheh

#14 lore raw

18/03/2024 13:56, Raslan Darawsheh:

Quoted 8 lines

From: Itamar Gozlan <[email protected]>

Quoted 7 lines

From: Erez Shitrit <[email protected]>

When the user tries to create a matcher and if failed with specific errno (E2BIG) the message will be in debug level and not in warning.
It is a part of a feature when the user re-try to insert a new matching depends on that errno, no need the annoying message.

Quoted 6 lines
Quoted 4 lines
Fixes c55c2bf3533 ("net/mlx5/hws: net/mlx5/hws: add definer layer")

Fixed Cc stable on several patches on this series, and reworded the commits Series applied to next-net-mlx,

There is no cover letter for this series,
so we are not able to understand how critical it is, and what is the general intent.

Is it supposed to be integrated in the last week of 24.03 release cycle?

#15 lore raw

Hi,

Quoted 29 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, March 18, 2024 4:49 PM
To: Itamar Gozlan <[email protected]>; Erez Shitrit <[email protected]>; Hamdan Agbariya <[email protected]>; Yevgeny Kliteynik <[email protected]>; Alex Vesker <[email protected]>; Raslan Darawsheh <[email protected]>
Cc: Slava Ovsiienko <[email protected]>; Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Mark Bloch <[email protected]>; [email protected]; Maayan Kashani <[email protected]>
Subject: Re: [PATCH 01/13] net/mlx5/hws: move warn into debug level when needed

18/03/2024 13:56, Raslan Darawsheh:

Quoted 13 lines

From: Itamar Gozlan <[email protected]>

Quoted 12 lines

From: Erez Shitrit <[email protected]>

When the user tries to create a matcher and if failed with specific errno
(E2BIG) the message will be in debug level and not in warning. It is a part of a feature when the user re-try to insert a new matching depends on that errno, no need the annoying message.

Fixes c55c2bf3533 ("net/mlx5/hws: net/mlx5/hws: add definer layer")
Quoted 8 lines
Quoted 2 lines

Fixed Cc stable on several patches on this series, and reworded the commits Series applied to next-net-mlx,

There is no cover letter for this series, so we are not able to understand how critical it is, and what is the general intent.

Is it supposed to be integrated in the last week of 24.03 release cycle?

No, it's not critical for RC4 It's my fault, I'll drop it for now and we'll merge it in the next release cycle only.

Kindest regards
Raslan Darawsheh

#16 lore raw
Quoted 6 lines · Raslan Darawsheh

Hi,

Quoted 4 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>

18/03/2024 13:56, Raslan Darawsheh:

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

From: Itamar Gozlan <[email protected]>

There is no cover letter for this series, so we are not able to understand how critical it is, and what is the general intent.

Is it supposed to be integrated in the last week of 24.03 release cycle?

No, it's not critical for RC4 It's my fault, I'll drop it for now and we'll merge it in the next release cycle only.

Actually, this series contain a bugfix for a show stopper bug:
[DPDK Upstream - Bug SW #3808915] Seg fault on dequeue flow

The fix is in patch 10/13:
[PATCH 10/13] net/mlx5/hws: fix rule is in resize check

-- YK

Quoted 2 lines

Kindest regards
Raslan Darawsheh

#17 lore raw

PATCH v2 1/16 net/mlx5/hws: move warn into debug level when needed

In reply to Itamar Gozlan

From: Erez Shitrit <[email protected]>

When the user tries to create a matcher and if failed with specific errno (E2BIG) the message will be in debug level and not in warning. It is a part of a feature when the user re-try to insert a new matching depends on that errno, no need the annoying message.

Fixes c55c2bf35333 ("net/mlx5/hws: add definer layer")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 6 +++---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +3 -3
index 35a2ed2048..81d0e0e6df 100644
@@ -3534,7 +3534,7 @@ mlx5dr_definer_find_best_match_fit(struct mlx5dr_context *ctx,
 		return 0;
 	}
 
-	DR_LOG(ERR, "Unable to find supporting match/jumbo definer combination");
+	DR_LOG(DEBUG, "Unable to find supporting match/jumbo definer combination");
 	rte_errno = E2BIG;
 	return rte_errno;
 }
@@ -3689,7 +3689,7 @@ mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher,
 	/* Find the match definer layout for header layout match union */
 	ret = mlx5dr_definer_find_best_match_fit(ctx, match_definer, match_hl);
 	if (ret) {
-		DR_LOG(ERR, "Failed to create match definer from header layout");
+		DR_LOG(DEBUG, "Failed to create match definer from header layout");
 		goto free_fc;
 	}
 
@@ -4041,7 +4041,7 @@ int mlx5dr_definer_matcher_init(struct mlx5dr_context *ctx,
 
 	ret = mlx5dr_definer_calc_layout(matcher, &match_layout, &range_layout);
 	if (ret) {
-		DR_LOG(ERR, "Failed to calculate matcher definer layout");
+		DR_LOG(DEBUG, "Failed to calculate matcher definer layout");
 		return ret;
 	}
 
drivers/net/mlx5/hws/mlx5dr_matcher.c +1 -1
index 1c64abfa57..1213e7f0ad 100644
@@ -877,7 +877,7 @@ static int mlx5dr_matcher_bind_mt(struct mlx5dr_matcher *matcher)
 	/* Calculate match, range and hash definers */
 	ret = mlx5dr_definer_matcher_init(ctx, matcher);
 	if (ret) {
-		DR_LOG(ERR, "Failed to set matcher templates with match definers");
+		DR_LOG(DEBUG, "Failed to set matcher templates with match definers");
 		return ret;
 	}
 
Signature · 1 line
2.39.3
#18 lore raw

PATCH v2 2/16 common/mlx5: fix error in mlx5 prm structs

From: Yevgeny Kliteynik <[email protected]>

Fix wrong reserved size and add helpful comment

Fixes 365cdf5f8ce7 ("net/mlx5/hws: add command layer")
---
 drivers/common/mlx5/mlx5_prm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/common/mlx5/mlx5_prm.h +3 -3
index c671c75bfd..c6846cdb7e 100644
@@ -2360,8 +2360,8 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {
 	u8 reserved_at_d0[0x3];
 	u8 log_conn_track_max_alloc[0x5];
 	u8 reserved_at_d8[0x3];
-	u8 log_max_conn_track_offload[0x5];
-	u8 cross_vhca_object_to_object_supported[0x20]; /* End of DW7. */
+	u8 log_max_conn_track_offload[0x5]; /* End of DW7. */
+	u8 cross_vhca_object_to_object_supported[0x20];
 	u8 allowed_object_for_other_vhca_access_high[0x20];
 	u8 allowed_object_for_other_vhca_access[0x20];
 	u8 reserved_at_140[0x20];
@@ -3655,7 +3655,7 @@ struct mlx5_ifc_stc_ste_param_vport_bits {
 	u8 eswitch_owner_vhca_id[0x10];
 	u8 vport_number[0x10];
 	u8 eswitch_owner_vhca_id_valid[0x1];
-	u8 reserved_at_21[0x59];
+	u8 reserved_at_21[0x5f];
 };
 
 union mlx5_ifc_stc_param_bits {
Signature · 1 line
2.39.3
#19 lore raw

PATCH v2 3/16 net/mlx5/hws: fix wrong comment in mlx5dr send

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Remove comment that documents parameter that doesn't exist.

Fixes 3eb748869d2d ("net/mlx5/hws: add send layer")
---
 drivers/net/mlx5/hws/mlx5dr_send.h | 2 --
 1 file changed, 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_send.h +0 -2
index c4eaea52ab..0c89faa8a7 100644
@@ -203,8 +203,6 @@ struct mlx5dr_send_ste_attr {
  *   value to write in CPU endian format.
  * @param addr
  *   Address to write to.
- * @param lock
- *   Address of the lock to use for that UAR access.
  */
 static __rte_always_inline void
 mlx5dr_uar_write64_relaxed(uint64_t val, void *addr)
Signature · 1 line
2.39.3
#20 lore raw

PATCH v2 4/16 net/mlx5/hws: remove unused capabilities and fields

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

The following caps were never in use:
- wire_regc
- metadata_c
- metadata_c_mask
Also send ring's reg_addr field wasn't in use.

Removing these caps and fields from structs and removing the code that queried them.

---
 drivers/net/mlx5/hws/mlx5dr_cmd.c  | 11 ++---------
 drivers/net/mlx5/hws/mlx5dr_cmd.h  |  3 ---
 drivers/net/mlx5/hws/mlx5dr_send.c |  1 -
 drivers/net/mlx5/hws/mlx5dr_send.h |  1 -
 4 files changed, 2 insertions(+), 14 deletions(-)
drivers/net/mlx5/hws/mlx5dr_cmd.c +2 -9
index 0e0cc479a6..666d678b42 100644
@@ -1344,12 +1344,10 @@ int mlx5dr_cmd_query_caps(struct ibv_context *ctx,
 	strlcpy(caps->fw_ver, attr_ex.orig_attr.fw_ver, sizeof(caps->fw_ver));
 
 	port_info = flow_hw_get_wire_port(ctx);
-	if (port_info) {
-		caps->wire_regc = port_info->regc_value;
+	if (port_info)
 		caps->wire_regc_mask = port_info->regc_mask;
-	} else {
+	else
 		DR_LOG(INFO, "Failed to query wire port regc value");
-	}
 
 	return ret;
 }
@@ -1374,10 +1372,5 @@ int mlx5dr_cmd_query_ib_port(struct ibv_context *ctx,
 	vport_caps->vport_num = port_info.vport_id;
 	vport_caps->esw_owner_vhca_id = port_info.esw_owner_vhca_id;
 
-	if (port_info.query_flags & MLX5_PORT_QUERY_REG_C0) {
-		vport_caps->metadata_c = port_info.vport_meta_tag;
-		vport_caps->metadata_c_mask = port_info.vport_meta_mask;
-	}
-
 	return 0;
 }
drivers/net/mlx5/hws/mlx5dr_cmd.h +0 -3
index 9d385fc57f..ea5d346d8e 100644
@@ -194,8 +194,6 @@ struct mlx5dr_cmd_query_ft_caps {
 struct mlx5dr_cmd_query_vport_caps {
 	uint16_t vport_num;
 	uint16_t esw_owner_vhca_id;
-	uint32_t metadata_c;
-	uint32_t metadata_c_mask;
 };
 
 struct mlx5dr_cmd_generate_wqe_attr {
@@ -207,7 +205,6 @@ struct mlx5dr_cmd_generate_wqe_attr {
 };
 
 struct mlx5dr_cmd_query_caps {
-	uint32_t wire_regc;
 	uint32_t wire_regc_mask;
 	uint32_t flex_protocols;
 	uint8_t wqe_based_update;
drivers/net/mlx5/hws/mlx5dr_send.c +0 -1
index f749401c6f..d58fdb108f 100644
@@ -729,7 +729,6 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	buf_sz = queue->num_entries * MAX_WQES_PER_RULE;
 	sq_log_buf_sz = log2above(buf_sz);
 	sq_buf_sz = 1 << (sq_log_buf_sz + log2above(MLX5_SEND_WQE_BB));
-	sq->reg_addr = queue->uar->reg_addr;
 
 	page_size = sysconf(_SC_PAGESIZE);
 	buf_aligned = align(sq_buf_sz, page_size);
drivers/net/mlx5/hws/mlx5dr_send.h +0 -1
index 0c89faa8a7..48593adbed 100644
@@ -114,7 +114,6 @@ struct mlx5dr_send_ring_sq {
 	char *buf;
 	uint32_t sqn;
 	__be32 *db;
-	void *reg_addr;
 	uint16_t cur_post;
 	uint16_t buf_mask;
 	struct mlx5dr_send_ring_priv *wr_priv;
Signature · 1 line
2.39.3
#21 lore raw

PATCH v2 5/16 net/mlx5/hws: negating rte errno on rule creation failure

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

mlx5dr_rule_create returns -ret, so internal functions should return rte_errno on failure. Fix return values of the function that creates rule in root table.

---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +1 -1
index f14e1e6ecd..7bcf2de55f 100644
@@ -733,7 +733,7 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
 free_attr:
 	simple_free(attr);
 
-	return -rte_errno;
+	return rte_errno;
 }
 
 static int mlx5dr_rule_destroy_root(struct mlx5dr_rule *rule,
Signature · 1 line
2.39.3
#22 lore raw

PATCH v2 6/16 net/mlx5/hws: simplify send queues close code

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Small simplification to the send_queues_close code

---
 drivers/net/mlx5/hws/mlx5dr_send.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/mlx5/hws/mlx5dr_send.c +2 -7
index d58fdb108f..d61862f074 100644
@@ -970,13 +970,8 @@ int mlx5dr_send_queue_open(struct mlx5dr_context *ctx,
 
 static void __mlx5dr_send_queues_close(struct mlx5dr_context *ctx, uint16_t queues)
 {
-	struct mlx5dr_send_engine *queue;
-
-	while (queues--) {
-		queue = &ctx->send_queue[queues];
-
-		mlx5dr_send_queue_close(queue);
-	}
+	while (queues--)
+		mlx5dr_send_queue_close(&ctx->send_queue[queues]);
 }
 
 void mlx5dr_send_queues_close(struct mlx5dr_context *ctx)
Signature · 1 line
2.39.3
#23 lore raw

PATCH v2 7/16 net/mlx5/hws: fix error flow in mlx5dr context open

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Add missing spinlock destruction in error flow.

Fixes b0290e56dd08 ("net/mlx5/hws: add context object")
---
 drivers/net/mlx5/hws/mlx5dr_context.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/hws/mlx5dr_context.c +1 -0
index 15d53c578a..7f120b3b1b 100644
@@ -263,6 +263,7 @@ struct mlx5dr_context *mlx5dr_context_open(struct ibv_context *ibv_ctx,
 free_caps:
 	simple_free(ctx->caps);
 free_ctx:
+	pthread_spin_destroy(&ctx->ctrl_lock);
 	simple_free(ctx);
 	return NULL;
 }
Signature · 1 line
2.39.3
#24 lore raw

PATCH v2 8/16 net/mlx5/hws: fix code analysis error in passing 0 enum val

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Instead of passing 0 as an enum parameter, define flag NONE. This resolves the following code analysis error: "enumerated type mixed with another type".
This value is currently used in tests only, and will later be used in backward-compatible steering API.

Fixes 5cadd74fbc08 ("net/mlx5: add HW steering low-level abstract stub")
---
 drivers/net/mlx5/hws/mlx5dr.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/hws/mlx5dr.h +1 -0
index 80e118a980..d2c426e679 100644
@@ -82,6 +82,7 @@ enum mlx5dr_action_aso_ct_flags {
 };
 
 enum mlx5dr_match_template_flags {
+	MLX5DR_MATCH_TEMPLATE_FLAG_NONE = 0,
 	/* Allow relaxed matching by skipping derived dependent match fields. */
 	MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH = 1,
 };
Signature · 1 line
2.39.3
#25 lore raw

PATCH v2 9/16 net/mlx5/hws: simplify code for updating CQ doorbell record

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Simplify the code that does CQ poll - have DB record update as part of CQ polling.

---
 drivers/net/mlx5/hws/mlx5dr_send.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/mlx5/hws/mlx5dr_send.c +3 -6
index d61862f074..2942668e76 100644
@@ -594,7 +594,7 @@ static void mlx5dr_send_engine_poll_cq(struct mlx5dr_send_engine *queue,
 	    cqe_owner != sw_own)
 		return;
 
-	if (unlikely(mlx5dv_get_cqe_opcode(cqe) != MLX5_CQE_REQ))
+	if (unlikely(cqe_opcode != MLX5_CQE_REQ))
 		queue->err = true;
 
 	rte_io_rmb();
@@ -611,6 +611,7 @@ static void mlx5dr_send_engine_poll_cq(struct mlx5dr_send_engine *queue,
 	cq->poll_wqe = (wqe_cnt + priv->num_wqebbs) & sq->buf_mask;
 	mlx5dr_send_engine_update(queue, cqe, priv, res, i, res_nb, wqe_cnt);
 	cq->cons_index++;
+	*cq->db = htobe32(cq->cons_index & 0xffffff);
 }
 
 static void mlx5dr_send_engine_poll_cqs(struct mlx5dr_send_engine *queue,
@@ -620,13 +621,9 @@ static void mlx5dr_send_engine_poll_cqs(struct mlx5dr_send_engine *queue,
 {
 	int j;
 
-	for (j = 0; j < MLX5DR_NUM_SEND_RINGS; j++) {
+	for (j = 0; j < MLX5DR_NUM_SEND_RINGS; j++)
 		mlx5dr_send_engine_poll_cq(queue, &queue->send_ring[j],
 					   res, polled, res_nb);
-
-		*queue->send_ring[j].send_cq.db =
-			htobe32(queue->send_ring[j].send_cq.cons_index & 0xffffff);
-	}
 }
 
 static void mlx5dr_send_engine_poll_list(struct mlx5dr_send_engine *queue,
Signature · 1 line
2.39.3
#26 lore raw

PATCH v2 10/16 net/mlx5/hws: drop at attach number of actions

In reply to Itamar Gozlan

From: Alex Vesker <[email protected]>

Requesting the user for number of action resources is not defined well enough, instead the user should provide an initial action template which should contain the future attached action templates.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mlx5/hws/mlx5dr_matcher.c +7 -0
index 1213e7f0ad..78d525e578 100644
@@ -785,6 +785,13 @@ static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher)
 	if (matcher->flags & MLX5DR_MATCHER_FLAGS_COLLISION)
 		return 0;
 
+	if (matcher->attr.max_num_of_at_attach &&
+	    mlx5dr_matcher_req_fw_wqe(matcher)) {
+		DR_LOG(ERR, "FW extended matcher doesn't support additional at");
+		rte_errno = ENOTSUP;
+		return rte_errno;
+	}
+
 	for (i = 0; i < matcher->num_of_at; i++) {
 		struct mlx5dr_action_template *at = &matcher->at[i];
 
Signature · 1 line
2.39.3
#27 lore raw

PATCH v2 11/16 net/mlx5/hws: extending tag saving for match and jumbo

In reply to Itamar Gozlan

From: Erez Shitrit <[email protected]>

Save the exact tag when matching over jumbo masking.

Fixes 348cdeec6472 ("net/mlx5/hws: add FW WQE rule creation logic")
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +7 -2
index 7bcf2de55f..5b74e6d85f 100644
@@ -195,8 +195,13 @@ mlx5dr_rule_save_delete_info(struct mlx5dr_rule *rule,
 		rule->tag_ptr = simple_calloc(2, sizeof(*rule->tag_ptr));
 		assert(rule->tag_ptr);
 
-		src_tag = (uint8_t *)ste_attr->wqe_data->tag;
-		memcpy(rule->tag_ptr[0].match, src_tag, MLX5DR_MATCH_TAG_SZ);
+		if (is_jumbo)
+			memcpy(rule->tag_ptr[0].jumbo, ste_attr->wqe_data->action,
+			       MLX5DR_JUMBO_TAG_SZ);
+		else
+			memcpy(rule->tag_ptr[0].match, ste_attr->wqe_data->tag,
+			       MLX5DR_MATCH_TAG_SZ);
+
 		rule->tag_ptr[1].reserved[0] = ste_attr->send_attr.match_definer_id;
 
 		/* Save range definer id and tag for delete */
Signature · 1 line
2.39.3
#28 lore raw

PATCH v2 12/16 net/mlx5/hws: dw order optimization code enhancement

In reply to Itamar Gozlan

Improving code readability by following code styles such as mlx5dr prefix and extracting a support check to an external function call. Also, reducing unneeded static memory allocation using a bounded size macro.

Fixes 88ff41793e7a ("net/mlx5/hws: reorder STE fields to improve hash")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 39 ++++++++++++++-------------
 1 file changed, 20 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +20 -19
index 81d0e0e6df..cffbb7b589 100644
@@ -31,6 +31,8 @@
 
 #define MLX5DR_DEFINER_QUOTA_BLOCK 0
 #define MLX5DR_DEFINER_QUOTA_PASS  2
+#define MLX5DR_DEFINER_MAX_ROW_LOG 32
+#define MLX5DR_DEFINER_HL_OPT_MAX 2
 
 /* Setter function based on bit offset and mask, for 32bit DW*/
 #define _DR_SET_32(p, v, byte_off, bit_off, mask) \
@@ -104,21 +106,13 @@
 	__mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \
 	__mlx5_mask(typ, fld))
 
-#define MAX_ROW_LOG 31
-
-enum header_layout {
-	MLX5DR_HL_IPV4_SRC = 64,
-	MLX5DR_HL_IPV4_DST = 65,
-	MAX_HL_PRIO,
-};
-
 /* Each row (i) indicates a different matcher size, and each column (j)
  * represents {DW5, DW4, DW3, DW2, DW1, DW0}.
- * For values 0,..,2^i, and j (DW) 0,..,5: optimal_dist_dw[i][j] is 1 if the
+ * For values 0,..,2^i, and j (DW) 0,..,5: mlx5dr_optimal_dist_dw[i][j] is 1 if the
  * number of different hash results on these values equals 2^i, meaning this
  * DW hash distribution is complete.
  */
-int optimal_dist_dw[MAX_ROW_LOG][DW_SELECTORS_MATCH] = {
+int mlx5dr_optimal_dist_dw[MLX5DR_DEFINER_MAX_ROW_LOG][DW_SELECTORS_MATCH] = {
 	{1, 1, 1, 1, 1, 1}, {0, 1, 1, 0, 1, 0}, {0, 1, 1, 0, 1, 0},
 	{1, 0, 1, 0, 1, 0}, {0, 0, 0, 1, 1, 0}, {0, 1, 1, 0, 1, 0},
 	{0, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 1, 0}, {0, 0, 0, 0, 0, 0},
@@ -3471,16 +3465,16 @@ mlx5dr_definer_find_best_range_fit(struct mlx5dr_definer *definer,
 
 static void mlx5dr_definer_optimize_order(struct mlx5dr_definer *definer, int num_log)
 {
-	uint8_t hl_prio[MAX_HL_PRIO - 1] = {MLX5DR_HL_IPV4_SRC,
-					    MLX5DR_HL_IPV4_DST,
-					    MAX_HL_PRIO};
+	uint8_t hl_prio[MLX5DR_DEFINER_HL_OPT_MAX];
 	int dw = 0, i = 0, j;
 	int *dw_flag;
 	uint8_t tmp;
 
-	dw_flag = optimal_dist_dw[num_log];
+	dw_flag = mlx5dr_optimal_dist_dw[num_log];
+	hl_prio[0] = __mlx5_dw_off(definer_hl, ipv4_src_dest_outer.source_address);
+	hl_prio[1] = __mlx5_dw_off(definer_hl, ipv4_src_dest_outer.destination_address);
 
-	while (hl_prio[i] != MAX_HL_PRIO) {
+	while (i < MLX5DR_DEFINER_HL_OPT_MAX) {
 		j = 0;
 		/* Finding a candidate to improve its hash distribution */
 		while (j < DW_SELECTORS_MATCH && (hl_prio[i] != definer->dw_selector[j]))
@@ -3632,6 +3626,16 @@ int mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
 	return 0;
 }
 
+static int
+mlx5dr_definer_optimize_order_supported(struct mlx5dr_definer *match_definer,
+					struct mlx5dr_matcher *matcher)
+{
+	return !mlx5dr_definer_is_jumbo(match_definer) &&
+	       !mlx5dr_matcher_req_fw_wqe(matcher) &&
+	       !mlx5dr_matcher_is_resizable(matcher) &&
+	       !mlx5dr_matcher_is_insert_by_idx(matcher);
+}
+
 static int
 mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher,
 			   struct mlx5dr_definer *match_definer,
@@ -3693,10 +3697,7 @@ mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher,
 		goto free_fc;
 	}
 
-	if (!mlx5dr_definer_is_jumbo(match_definer) &&
-	    !mlx5dr_matcher_req_fw_wqe(matcher) &&
-	    !mlx5dr_matcher_is_resizable(matcher) &&
-	    !mlx5dr_matcher_is_insert_by_idx(matcher))
+	if (mlx5dr_definer_optimize_order_supported(match_definer, matcher))
 		mlx5dr_definer_optimize_order(match_definer, matcher->attr.rule.num_log);
 
 	/* Find the range definer layout for match templates fcrs */
Signature · 1 line
2.39.3
#29 lore raw

PATCH v2 13/16 net/mlx5/hws: set default miss when replacing table

In reply to Itamar Gozlan

Allowing the replacement of a miss table without enforcing a previous disconnecting. This feature extension allows the user to change the destination miss table when the system runs without losing traffic.

Fixes b81f95ca770d ("net/mlx5/hws: support default miss table")
---
 drivers/net/mlx5/hws/mlx5dr_table.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/mlx5/hws/mlx5dr_table.c +6 -5
index 55b9b20150..ab73017ade 100644
@@ -611,8 +611,7 @@ static int mlx5dr_table_set_default_miss_not_valid(struct mlx5dr_table *tbl,
 
 	if (mlx5dr_table_is_root(tbl) ||
 	    (miss_tbl && mlx5dr_table_is_root(miss_tbl)) ||
-	    (miss_tbl && miss_tbl->type != tbl->type) ||
-	    (miss_tbl && tbl->default_miss.miss_tbl)) {
+	    (miss_tbl && miss_tbl->type != tbl->type)) {
 		DR_LOG(ERR, "Invalid arguments");
 		rte_errno = EINVAL;
 		return -rte_errno;
@@ -625,6 +624,7 @@ int mlx5dr_table_set_default_miss(struct mlx5dr_table *tbl,
 				  struct mlx5dr_table *miss_tbl)
 {
 	struct mlx5dr_context *ctx = tbl->ctx;
+	struct mlx5dr_table *old_miss_tbl;
 	int ret;
 
 	ret = mlx5dr_table_set_default_miss_not_valid(tbl, miss_tbl);
@@ -632,15 +632,16 @@ int mlx5dr_table_set_default_miss(struct mlx5dr_table *tbl,
 		return ret;
 
 	pthread_spin_lock(&ctx->ctrl_lock);
-
+	old_miss_tbl = tbl->default_miss.miss_tbl;
 	ret = mlx5dr_table_connect_to_miss_table(tbl, miss_tbl);
 	if (ret)
 		goto out;
 
+	if (old_miss_tbl)
+		LIST_REMOVE(tbl, default_miss.next);
+
 	if (miss_tbl)
 		LIST_INSERT_HEAD(&miss_tbl->default_miss.head, tbl, default_miss.next);
-	else
-		LIST_REMOVE(tbl, default_miss.next);
 
 	pthread_spin_unlock(&ctx->ctrl_lock);
 	return 0;
Signature · 1 line
2.39.3
#30 lore raw

PATCH v2 14/16 net/mlx5/hws: fix invalid memory access in decapl3

In reply to Itamar Gozlan

From: Alex Vesker <[email protected]>

In case decapL3 action is created we would access header data even in case the SHARED flag is not set, this would lead to an invalid memory access.

Fixes 3a6c50215c07 ("net/mlx5/hws: support multi-pattern")
---
 drivers/net/mlx5/hws/mlx5dr_action.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_action.c +3 -1
index 084d4d606e..562fb5cbb4 100644
@@ -1775,7 +1775,9 @@ mlx5dr_action_handle_tunnel_l3_to_l2(struct mlx5dr_action *action,
 
 	/* Create a full modify header action list in case shared */
 	mlx5dr_action_prepare_decap_l3_actions(hdrs->sz, mh_data, &num_of_actions);
-	mlx5dr_action_prepare_decap_l3_data(hdrs->data, mh_data, num_of_actions);
+
+	if (action->flags & MLX5DR_ACTION_FLAG_SHARED)
+		mlx5dr_action_prepare_decap_l3_data(hdrs->data, mh_data, num_of_actions);
 
 	/* All DecapL3 cases require the same max arg size */
 	arg_obj = mlx5dr_arg_create_modify_header_arg(ctx,
Signature · 1 line
2.39.3
#31 lore raw

PATCH v2 15/16 net/mlx5/hws: dump action ste arrays info

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Dump action ste arrays info for resizing matchers.

---
 drivers/net/mlx5/hws/mlx5dr_debug.c   | 23 +++++++++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_debug.h   |  1 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c |  1 +
 drivers/net/mlx5/hws/mlx5dr_matcher.h |  1 +
 4 files changed, 26 insertions(+)
drivers/net/mlx5/hws/mlx5dr_debug.c +23 -0
index 8f07c7fd66..5ad4ca2da5 100644
@@ -206,6 +206,7 @@ static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
 	bool is_shared = mlx5dr_context_shared_gvmi_used(matcher->tbl->ctx);
 	bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL;
 	enum mlx5dr_table_type tbl_type = matcher->tbl->type;
+	struct mlx5dr_matcher_resize_data *resize_data;
 	struct mlx5dr_cmd_ft_query_attr ft_attr = {0};
 	struct mlx5dr_devx_obj *ste_0, *ste_1 = NULL;
 	struct mlx5dr_pool_chunk *ste;
@@ -288,6 +289,28 @@ static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
 	if (ret)
 		return ret;
 
+	LIST_FOREACH(resize_data, &matcher->resize_data, next) {
+		ste = &resize_data->ste;
+		ste_pool = resize_data->action_ste_pool;
+		if (ste_pool) {
+			ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste);
+			if (tbl_type == MLX5DR_TABLE_TYPE_FDB)
+				ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste);
+		} else {
+			ste_0 = NULL;
+			ste_1 = NULL;
+		}
+		ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d\n",
+			      MLX5DR_DEBUG_RES_TYPE_MATCHER_RESIZABLE_ACTION_ARRAY,
+			      (uint64_t)(uintptr_t)matcher,
+			      resize_data->action_ste_rtc_0 ? resize_data->action_ste_rtc_0->id : 0,
+			      ste_0 ? (int)ste_0->id : -1,
+			      resize_data->action_ste_rtc_1 ? resize_data->action_ste_rtc_1->id : 0,
+			      ste_1 ? (int)ste_1->id : -1);
+		if (ret < 0)
+			return ret;
+	}
+
 	return 0;
 
 out_err:
drivers/net/mlx5/hws/mlx5dr_debug.h +1 -0
index a89a6a0b1d..b69002b5cd 100644
@@ -25,6 +25,7 @@ enum mlx5dr_debug_res_type {
 	MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_HASH_DEFINER = 4205,
 	MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_RANGE_DEFINER = 4206,
 	MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_COMPARE_MATCH_DEFINER = 4207,
+	MLX5DR_DEBUG_RES_TYPE_MATCHER_RESIZABLE_ACTION_ARRAY = 4208,
 };
 
 static inline uint64_t
drivers/net/mlx5/hws/mlx5dr_matcher.c +1 -0
index 78d525e578..8f1a202f81 100644
@@ -724,6 +724,7 @@ mlx5dr_matcher_resize_init(struct mlx5dr_matcher *src_matcher)
 		return rte_errno;
 	}
 
+	resize_data->ste = src_matcher->action_ste.ste;
 	resize_data->stc = src_matcher->action_ste.stc;
 	resize_data->action_ste_rtc_0 = src_matcher->action_ste.rtc_0;
 	resize_data->action_ste_rtc_1 = src_matcher->action_ste.rtc_1;
drivers/net/mlx5/hws/mlx5dr_matcher.h +1 -0
index 6dc3bf4d0d..caff403a38 100644
@@ -62,6 +62,7 @@ struct mlx5dr_matcher_action_ste {
 };
 
 struct mlx5dr_matcher_resize_data {
+	struct mlx5dr_pool_chunk ste;
 	struct mlx5dr_pool_chunk stc;
 	struct mlx5dr_devx_obj *action_ste_rtc_0;
 	struct mlx5dr_devx_obj *action_ste_rtc_1;
Signature · 1 line
2.39.3
#32 lore raw

PATCH v2 16/16 net/mlx5/hws: fix action template only term param dump print

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

The debug print of only_term param in the action template was printed incorrectly.

Fixes 78580cf4e796 ("net/mlx5/hws: add debug layer")
---
 drivers/net/mlx5/hws/mlx5dr_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_debug.c +1 -1
index 5ad4ca2da5..741a725842 100644
@@ -153,7 +153,7 @@ mlx5dr_debug_dump_matcher_action_template(FILE *f, struct mlx5dr_matcher *matche
 			      MLX5DR_DEBUG_RES_TYPE_MATCHER_ACTION_TEMPLATE,
 			      (uint64_t)(uintptr_t)at,
 			      (uint64_t)(uintptr_t)matcher,
-			      at->only_term ? 0 : 1,
+			      at->only_term,
 			      is_root ? 0 : at->num_of_action_stes,
 			      at->num_actions);
 		if (ret < 0) {
Signature · 1 line
2.39.3
Acked-by Matan Azrad on v2 1/16
#33 lore raw
In reply to Itamar Gozlan

Hi,
________________________________________
From: Itamar Gozlan <[email protected]>
Sent: Monday, May 6, 2024 2:44 PM
To: Itamar Gozlan; Erez Shitrit; Hamdan Agbariya; Yevgeny Kliteynik; Slava Ovsiienko; NBU-Contact-Thomas Monjalon (EXTERNAL); Suanming Mou; Dariusz Sosnowski; Ori Kam; Matan Azrad; Mark Bloch; Alex Vesker
Cc: [email protected]; [email protected]
Subject: [v2 01/16] net/mlx5/hws: move warn into debug level when needed

From: Erez Shitrit <[email protected]>

When the user tries to create a matcher and if failed with specific errno (E2BIG) the message will be in debug level and not in warning. It is a part of a feature when the user re-try to insert a new matching depends on that errno, no need the annoying message.

Fixes c55c2bf35333 ("net/mlx5/hws: add definer layer")

Series applied to next-net-mlx,
please make sure you are sending some cover-letter for such big series next time.

Kindest regards,
Raslan Darawsheh