Skip to contentSkip to conversation

net/mlx5/hws: skip RTE item when inserting rules by index

PATCH Superseded Itamar Gozlan 2 participants 20 messages Feb 13, 2024 – Feb 26, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/9 net/mlx5/hws: skip RTE item when inserting rules by index

The location of indexed rules is determined by the index, not the item hash. A matcher test is added to prevent access to non-existent items. This avoids unnecessary processing and potential segmentation faults.

Fixes 405242c ("net/mlx5/hws: add rule object")
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/mlx5/hws/mlx5dr_rule.c +3 -0
index fa19303b91..e39137a6ee 100644
@@ -23,6 +23,9 @@ static void mlx5dr_rule_skip(struct mlx5dr_matcher *matcher,
 	*skip_rx = false;
 	*skip_tx = false;
 
+	if (unlikely(mlx5dr_matcher_is_insert_by_idx(matcher)))
+		return;
+
 	if (mt->item_flags & MLX5_FLOW_ITEM_REPRESENTED_PORT) {
 		v = items[mt->vport_item_id].spec;
 		vport = flow_hw_conv_port_id(v->port_id);
Signature · 1 line
2.39.3
#1 lore raw

PATCH 2/9 net/mlx5/hws: add check for not supported fields in VXLAN

Don't allow the user to mask over rsvd1 / rsvd2 fields which are not supported.

Fixes dbff89ef806f ("net/mlx5/hws: fix tunnel protocol checks")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mlx5/hws/mlx5dr_definer.c +7 -0
index 79d98bbf78..8b8757ecac 100644
@@ -1414,6 +1414,13 @@ mlx5dr_definer_conv_item_vxlan(struct mlx5dr_definer_conv_data *cd,
 	struct mlx5dr_definer_fc *fc;
 	bool inner = cd->tunnel;
 
+	if (m && (m->rsvd0[0] != 0 || m->rsvd0[1] != 0 || m->rsvd0[2] != 0 ||
+	    m->rsvd1 != 0)) {
+		DR_LOG(ERR, "reserved fields are not supported");
+		rte_errno = ENOTSUP;
+		return rte_errno;
+	}
+
 	if (inner) {
 		DR_LOG(ERR, "Inner VXLAN item not supported");
 		rte_errno = ENOTSUP;
Signature · 1 line
2.39.3
#2 lore raw

PATCH 3/9 net/mlx5/hws: add support for resizable matchers

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Add support for matcher resize with the following new API calls:
- mlx5dr_matcher_resize_set_target
- mlx5dr_matcher_resize_rule_move

The first function links two matchers and allows moving rules from src matcher to dst matcher. Both matchers should have the same characteristics (e.g. same mt, same at). It is the user's responsibility to make sure that the dst matcher has enough space for the moved rules.
After this function, the user can move rules from src into dst matcher, and he is no longer allowed to insert rules to the src matcher.

The second function is used to move the rule from matcher that is being resized to a bigger matcher. Moving a single rule includes creating a new rule in the destination matcher, and deleting the rule from the source matcher. This operation creates a single completion.

---
 drivers/net/mlx5/hws/mlx5dr.h         |  39 ++++
 drivers/net/mlx5/hws/mlx5dr_definer.c |   5 +-
 drivers/net/mlx5/hws/mlx5dr_definer.h |   3 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 181 +++++++++++++++-
 drivers/net/mlx5/hws/mlx5dr_matcher.h |  21 ++
 drivers/net/mlx5/hws/mlx5dr_rule.c    | 290 ++++++++++++++++++++++----
 drivers/net/mlx5/hws/mlx5dr_rule.h    |  30 ++-
 drivers/net/mlx5/hws/mlx5dr_send.c    |  45 ++++
 8 files changed, 573 insertions(+), 41 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +39 -0
index d88f73ab57..9d8f8e13dc 100644
@@ -139,6 +139,8 @@ struct mlx5dr_matcher_attr {
 	/* Define the insertion and distribution modes for this matcher */
 	enum mlx5dr_matcher_insert_mode insert_mode;
 	enum mlx5dr_matcher_distribute_mode distribute_mode;
+	/* Define whether the created matcher supports resizing into a bigger matcher */
+	bool resizable;
 	union {
 		struct {
 			uint8_t sz_row_log;
@@ -419,6 +421,43 @@ int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
 int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher,
 			     struct mlx5dr_action_template *at);
 
+/* Link two matchers and enable moving rules from src matcher to dst matcher.
+ * Both matchers must be in the same table type, must be created with 'resizable'
+ * property, and should have the same characteristics (e.g. same mt, same at).
+ *
+ * It is the user's responsibility to make sure that the dst matcher
+ * was allocated with the appropriate size.
+ *
+ * Once the function is completed, the user is:
+ *  - allowed to move rules from src into dst matcher
+ *  - no longer allowed to insert rules to the src matcher
+ *
+ * The user is always allowed to insert rules to the dst matcher and
+ * to delete rules from any matcher.
+ *
+ * @param[in] src_matcher
+ *	source matcher for moving rules from
+ * @param[in] dst_matcher
+ *	destination matcher for moving rules to
+ * @return zero on successful move, non zero otherwise.
+ */
+int mlx5dr_matcher_resize_set_target(struct mlx5dr_matcher *src_matcher,
+				     struct mlx5dr_matcher *dst_matcher);
+
+/* Enqueue moving rule operation: moving rule from src matcher to a dst matcher
+ *
+ * @param[in] src_matcher
+ *	matcher that the rule belongs to
+ * @param[in] rule
+ *	the rule to move
+ * @param[in] attr
+ *	rule attributes
+ * @return zero on success, non zero otherwise.
+ */
+int mlx5dr_matcher_resize_rule_move(struct mlx5dr_matcher *src_matcher,
+				    struct mlx5dr_rule *rule,
+				    struct mlx5dr_rule_attr *attr);
+
 /* 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_definer.c +2 -3
index 8b8757ecac..e564062313 100644
@@ -3296,9 +3296,8 @@ int mlx5dr_definer_get_id(struct mlx5dr_definer *definer)
 	return definer->obj->id;
 }
 
-static int
-mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
-		       struct mlx5dr_definer *definer_b)
+int mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
+			   struct mlx5dr_definer *definer_b)
 {
 	int i;
 
drivers/net/mlx5/hws/mlx5dr_definer.h +3 -0
index ced9d9da13..71cc0e94de 100644
@@ -733,4 +733,7 @@ int mlx5dr_definer_init_cache(struct mlx5dr_definer_cache **cache);
 
 void mlx5dr_definer_uninit_cache(struct mlx5dr_definer_cache *cache);
 
+int mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
+			   struct mlx5dr_definer *definer_b);
+
 #endif
drivers/net/mlx5/hws/mlx5dr_matcher.c +180 -1

214 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_matcher.h +21 -0
index 363a61fd41..0f2bf96e8b 100644
@@ -26,6 +26,7 @@ enum mlx5dr_matcher_flags {
 	MLX5DR_MATCHER_FLAGS_RANGE_DEFINER	= 1 << 0,
 	MLX5DR_MATCHER_FLAGS_HASH_DEFINER	= 1 << 1,
 	MLX5DR_MATCHER_FLAGS_COLLISION		= 1 << 2,
+	MLX5DR_MATCHER_FLAGS_RESIZABLE		= 1 << 3,
 };
 
 struct mlx5dr_match_template {
@@ -59,6 +60,14 @@ struct mlx5dr_matcher_action_ste {
 	uint8_t max_stes;
 };
 
+struct mlx5dr_matcher_resize_data {
+	struct mlx5dr_pool_chunk stc;
+	struct mlx5dr_devx_obj *action_ste_rtc_0;
+	struct mlx5dr_devx_obj *action_ste_rtc_1;
+	struct mlx5dr_pool *action_ste_pool;
+	LIST_ENTRY(mlx5dr_matcher_resize_data) next;
+};
+
 struct mlx5dr_matcher {
 	struct mlx5dr_table *tbl;
 	struct mlx5dr_matcher_attr attr;
@@ -71,10 +80,12 @@ struct mlx5dr_matcher {
 	uint8_t flags;
 	struct mlx5dr_devx_obj *end_ft;
 	struct mlx5dr_matcher *col_matcher;
+	struct mlx5dr_matcher *resize_dst;
 	struct mlx5dr_matcher_match_ste match_ste;
 	struct mlx5dr_matcher_action_ste action_ste;
 	struct mlx5dr_definer *hash_definer;
 	LIST_ENTRY(mlx5dr_matcher) next;
+	LIST_HEAD(resize_data_head, mlx5dr_matcher_resize_data) resize_data;
 };
 
 static inline bool
@@ -89,6 +100,16 @@ mlx5dr_matcher_mt_is_range(struct mlx5dr_match_template *mt)
 	return (!!mt->range_definer);
 }
 
+static inline bool mlx5dr_matcher_is_resizable(struct mlx5dr_matcher *matcher)
+{
+	return !!(matcher->flags & MLX5DR_MATCHER_FLAGS_RESIZABLE);
+}
+
+static inline bool mlx5dr_matcher_is_in_resize(struct mlx5dr_matcher *matcher)
+{
+	return !!matcher->resize_dst;
+}
+
 static inline bool mlx5dr_matcher_req_fw_wqe(struct mlx5dr_matcher *matcher)
 {
 	/* Currently HWS doesn't support hash different from match or range */
drivers/net/mlx5/hws/mlx5dr_rule.c +254 -36

409 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_rule.h +29 -1
index f7d97eead5..07adf9c5ad 100644
@@ -10,7 +10,6 @@ enum {
 	MLX5DR_ACTIONS_SZ = 12,
 	MLX5DR_MATCH_TAG_SZ = 32,
 	MLX5DR_JUMBO_TAG_SZ = 44,
-	MLX5DR_STE_SZ = 64,
 };
 
 enum mlx5dr_rule_status {
@@ -23,6 +22,12 @@ enum mlx5dr_rule_status {
 	MLX5DR_RULE_STATUS_FAILED,
 };
 
+enum mlx5dr_rule_move_state {
+	MLX5DR_RULE_RESIZE_STATE_IDLE,
+	MLX5DR_RULE_RESIZE_STATE_WRITING,
+	MLX5DR_RULE_RESIZE_STATE_DELETING,
+};
+
 struct mlx5dr_rule_match_tag {
 	union {
 		uint8_t jumbo[MLX5DR_JUMBO_TAG_SZ];
@@ -33,6 +38,16 @@ struct mlx5dr_rule_match_tag {
 	};
 };
 
+struct mlx5dr_rule_resize_info {
+	uint8_t state;
+	uint32_t rtc_0;
+	uint32_t rtc_1;
+	uint32_t rule_idx;
+	struct mlx5dr_pool *action_ste_pool;
+	uint8_t ctrl_seg[MLX5DR_WQE_SZ_GTA_CTRL]; /* Ctrl segment of STE: 48 bytes */
+	uint8_t data_seg[MLX5DR_WQE_SZ_GTA_DATA]; /* Data segment of STE: 64 bytes */
+};
+
 struct mlx5dr_rule {
 	struct mlx5dr_matcher *matcher;
 	union {
@@ -40,6 +55,7 @@ struct mlx5dr_rule {
 		/* Pointer to tag to store more than one tag */
 		struct mlx5dr_rule_match_tag *tag_ptr;
 		struct ibv_flow *flow;
+		struct mlx5dr_rule_resize_info *resize_info;
 	};
 	uint32_t rtc_0; /* The RTC into which the STE was inserted */
 	uint32_t rtc_1; /* The RTC into which the STE was inserted */
@@ -50,4 +66,16 @@ struct mlx5dr_rule {
 
 void mlx5dr_rule_free_action_ste_idx(struct mlx5dr_rule *rule);
 
+int mlx5dr_rule_move_hws_remove(struct mlx5dr_rule *rule,
+				void *queue, void *user_data);
+
+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;
+}
+
 #endif /* MLX5DR_RULE_H_ */
drivers/net/mlx5/hws/mlx5dr_send.c +45 -0

57 lines not on this page · raw message

Signature · 1 line
2.39.3
#3 lore raw

PATCH 4/9 net/mlx5/hws: reordering the STE fields to improve hash

In reply to Itamar Gozlan

Inserting two rules with the same hash calculation result into the same matcher will cause collisions, which can cause degradation in PPS. Changing the order of some fields in the STE can change the hash result, and doing this for every value would give us a different hash distribution for the inputs. By using precomputed optimal DW locations, we can change the STE order for a limited set of the most common values to reduce the number of hash collisions and improve latency.

---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 64 +++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
drivers/net/mlx5/hws/mlx5dr_definer.c +64 -0
index e564062313..eb788a772a 100644
@@ -100,6 +100,33 @@
 	__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
+ * 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] = {
+	{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},
+	{1, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 1, 0, 1, 0, 0},
+	{1, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 1}, {1, 1, 1, 0, 0, 0},
+	{1, 1, 1, 0, 1, 0}, {0, 0, 1, 1, 0, 0}, {0, 1, 1, 0, 0, 1},
+	{0, 0, 1, 0, 0, 1}, {0, 0, 1, 0, 0, 0}, {1, 0, 1, 1, 0, 0},
+	{1, 0, 1, 0, 0, 1}, {0, 0, 1, 1, 0, 1}, {1, 1, 1, 0, 0, 0},
+	{0, 1, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 1, 1, 1},
+	{0, 0, 1, 0, 0, 1}, {1, 1, 0, 1, 1, 0}, {0, 0, 0, 0, 1, 0},
+	{0, 0, 0, 1, 1, 0}};
+
 struct mlx5dr_definer_sel_ctrl {
 	uint8_t allowed_full_dw; /* Full DW selectors cover all offsets */
 	uint8_t allowed_lim_dw;  /* Limited DW selectors cover offset < 64 */
@@ -3185,6 +3212,37 @@ mlx5dr_definer_find_best_range_fit(struct mlx5dr_definer *definer,
 	return rte_errno;
 }
 
+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};
+	int dw = 0, i = 0, j;
+	int *dw_flag;
+	uint8_t tmp;
+
+	dw_flag = optimal_dist_dw[num_log];
+
+	while (hl_prio[i] != MAX_HL_PRIO) {
+		j = 0;
+		/* Finding a candidate to improve its hash distribution */
+		while (j < DW_SELECTORS_MATCH && (hl_prio[i] != definer->dw_selector[j]))
+			j++;
+
+		/* Finding a DW location with good hash distribution */
+		while (dw < DW_SELECTORS_MATCH && dw_flag[dw] == 0)
+			dw++;
+
+		if (dw < DW_SELECTORS_MATCH && j < DW_SELECTORS_MATCH) {
+			tmp = definer->dw_selector[dw];
+			definer->dw_selector[dw] = definer->dw_selector[j];
+			definer->dw_selector[j] = tmp;
+			dw++;
+		}
+		i++;
+	}
+}
+
 static int
 mlx5dr_definer_find_best_match_fit(struct mlx5dr_context *ctx,
 				   struct mlx5dr_definer *definer,
@@ -3355,6 +3413,12 @@ 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))
+		mlx5dr_definer_optimize_order(match_definer, matcher->attr.rule.num_log);
+
 	/* Find the range definer layout for match templates fcrs */
 	ret = mlx5dr_definer_find_best_range_fit(range_definer, matcher);
 	if (ret) {
Signature · 1 line
2.39.3
#4 lore raw

PATCH 5/9 net/mlx5/hws: check the rule status on rule update

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Only allow rule updates for rules with their status value equal to MLX5DR_RULE_STATUS_CREATED.
Otherwise, the rule may be in an unstable stage like deleting and this will result in a faulty unexpected scenario.

---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/mlx5/hws/mlx5dr_rule.c +6 -0
index 6bf087e187..aa00c54e53 100644
@@ -977,6 +977,12 @@ int mlx5dr_rule_action_update(struct mlx5dr_rule *rule_handle,
 	if (unlikely(mlx5dr_rule_enqueue_precheck_update(rule_handle, attr)))
 		return -rte_errno;
 
+	if (rule_handle->status != MLX5DR_RULE_STATUS_CREATED) {
+		DR_LOG(ERR, "Current rule status does not allow update");
+		rte_errno = EBUSY;
+		return -rte_errno;
+	}
+
 	ret = mlx5dr_rule_create_hws(rule_handle,
 				     attr,
 				     0,
Signature · 1 line
2.39.3
#5 lore raw

PATCH 6/9 net/mlx5/hws: fix VLAN item handling on non relaxed mode

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

If a VLAN item was passed with null mask, the item handler would return immediately and thus won't set default values for non relax mode.
Also change the non relax default set to single-tagged (CVLAN).

Fixes c55c2bf35333 ("net/mlx5/hws: add definer layer")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +11 -2
index eb788a772a..b8a546989a 100644
@@ -223,6 +223,7 @@ struct mlx5dr_definer_conv_data {
 	X(SET,		ib_l4_opcode,		v->hdr.opcode,		rte_flow_item_ib_bth) \
 	X(SET,		random_number,		v->value,		rte_flow_item_random) \
 	X(SET,		ib_l4_bth_a,		v->hdr.a,		rte_flow_item_ib_bth) \
+	X(SET,		cvlan,			STE_CVLAN,		rte_flow_item_vlan) \
 
 /* Item set function format */
 #define X(set_type, func_name, value, item_type) \
@@ -864,6 +865,15 @@ mlx5dr_definer_conv_item_vlan(struct mlx5dr_definer_conv_data *cd,
 	struct mlx5dr_definer_fc *fc;
 	bool inner = cd->tunnel;
 
+	if (!cd->relaxed) {
+		/* Mark packet as tagged (CVLAN) */
+		fc = &cd->fc[DR_CALC_FNAME(VLAN_TYPE, inner)];
+		fc->item_idx = item_idx;
+		fc->tag_mask_set = &mlx5dr_definer_ones_set;
+		fc->tag_set = &mlx5dr_definer_cvlan_set;
+		DR_CALC_SET(fc, eth_l2, first_vlan_qualifier, inner);
+	}
+
 	if (!m)
 		return 0;
 
@@ -872,8 +882,7 @@ mlx5dr_definer_conv_item_vlan(struct mlx5dr_definer_conv_data *cd,
 		return rte_errno;
 	}
 
-	if (!cd->relaxed || m->has_more_vlan) {
-		/* Mark packet as tagged (CVLAN or SVLAN) even if TCI is not specified.*/
+	if (m->has_more_vlan) {
 		fc = &cd->fc[DR_CALC_FNAME(VLAN_TYPE, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
Signature · 1 line
2.39.3
#6 lore raw

PATCH 7/9 net/mlx5/hws: extend action template creation API

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Extend mlx5dr_action_template_create function params to include flags parameter.

---
 drivers/net/mlx5/hws/mlx5dr.h         | 10 +++++++++-
 drivers/net/mlx5/hws/mlx5dr_action.c  | 11 ++++++++++-
 drivers/net/mlx5/hws/mlx5dr_action.h  |  1 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 16 ++++++++++------
 drivers/net/mlx5/mlx5_flow_hw.c       |  2 +-
 5 files changed, 31 insertions(+), 9 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +9 -1
index 9d8f8e13dc..c11ec08616 100644
@@ -84,6 +84,11 @@ enum mlx5dr_match_template_flags {
 	MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH = 1,
 };
 
+enum mlx5dr_action_template_flags {
+	/* Allow relaxed actions order. */
+	MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER = 1 << 0,
+};
+
 enum mlx5dr_send_queue_actions {
 	/* Start executing all pending queued rules */
 	MLX5DR_SEND_QUEUE_ACTION_DRAIN_ASYNC = 1 << 0,
@@ -362,10 +367,13 @@ int mlx5dr_match_template_destroy(struct mlx5dr_match_template *mt);
  *	An array of actions based on the order of actions which will be provided
  *	with rule_actions to mlx5dr_rule_create. The last action is marked
  *	using MLX5DR_ACTION_TYP_LAST.
+ * @param[in] flags
+ *	Template creation flags
  * @return pointer to mlx5dr_action_template on success NULL otherwise
  */
 struct mlx5dr_action_template *
-mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[]);
+mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[],
+			      uint32_t flags);
 
 /* Destroy action template.
  *
drivers/net/mlx5/hws/mlx5dr_action.c +10 -1
index 862ee3e332..370886907f 100644
@@ -3385,12 +3385,19 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at)
 }
 
 struct mlx5dr_action_template *
-mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[])
+mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[],
+			      uint32_t flags)
 {
 	struct mlx5dr_action_template *at;
 	uint8_t num_actions = 0;
 	int i;
 
+	if (flags > MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER) {
+		DR_LOG(ERR, "Unsupported action template flag provided");
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
 	at = simple_calloc(1, sizeof(*at));
 	if (!at) {
 		DR_LOG(ERR, "Failed to allocate action template");
@@ -3398,6 +3405,8 @@ mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[])
 		return NULL;
 	}
 
+	at->flags = flags;
+
 	while (action_type[num_actions++] != MLX5DR_ACTION_TYP_LAST)
 		;
 
drivers/net/mlx5/hws/mlx5dr_action.h +1 -0
index fad35a845b..a8d9720c42 100644
@@ -119,6 +119,7 @@ struct mlx5dr_action_template {
 	uint8_t num_of_action_stes;
 	uint8_t num_actions;
 	uint8_t only_term;
+	uint32_t flags;
 };
 
 struct mlx5dr_action {
drivers/net/mlx5/hws/mlx5dr_matcher.c +10 -6
index 0d5c462734..402242308d 100644
@@ -686,12 +686,16 @@ static int mlx5dr_matcher_check_and_process_at(struct mlx5dr_matcher *matcher,
 	bool valid;
 	int ret;
 
-	/* Check if action combinabtion is valid */
-	valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type);
-	if (!valid) {
-		DR_LOG(ERR, "Invalid combination in action template");
-		rte_errno = EINVAL;
-		return rte_errno;
+	if (!(at->flags & MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER)) {
+		/* Check if actions combinabtion is valid,
+		 * in the case of not relaxed actions order.
+		 */
+		valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type);
+		if (!valid) {
+			DR_LOG(ERR, "Invalid combination in action template");
+			rte_errno = EINVAL;
+			return rte_errno;
+		}
 	}
 
 	/* Process action template to setters */
drivers/net/mlx5/mlx5_flow_hw.c +1 -1
index 3af5e1f160..5ad45ce2ae 100644
@@ -6198,7 +6198,7 @@ flow_hw_dr_actions_template_create(struct rte_eth_dev *dev,
 		at->recom_off = recom_off;
 		action_types[recom_off] = recom_type;
 	}
-	dr_template = mlx5dr_action_template_create(action_types);
+	dr_template = mlx5dr_action_template_create(action_types, 0);
 	if (dr_template) {
 		at->dr_actions_num = curr_off;
 	} else {
Signature · 1 line
2.39.3
#7 lore raw

PATCH 8/9 net/mlx5/hws: add missing actions STE limitation

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Today if we pass a remove header action and after it an insert header action then our action template builder will set two different STE setters, because it won't allow insert header in same STE as remove header.
But if we have the opposite order of insert header and then remove header actions, then the setter will set both of them on the same STE since the opposite check was missing.
This patch added the missing opposite limitation.

---
 drivers/net/mlx5/hws/mlx5dr_action.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_action.c +2 -1
index 370886907f..8589de5557 100644
@@ -3308,7 +3308,8 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at)
 		case MLX5DR_ACTION_TYP_REMOVE_HEADER:
 		case MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2:
 			/* Single remove header to header */
-			setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_MODIFY);
+			setter = mlx5dr_action_setter_find_first(last_setter,
+					ASF_SINGLE1 | ASF_MODIFY | ASF_INSERT);
 			setter->flags |= ASF_SINGLE1 | ASF_REMOVE;
 			setter->set_single = &mlx5dr_action_setter_single;
 			setter->idx_single = i;
Signature · 1 line
2.39.3
#8 lore raw

PATCH 9/9 net/mlx5/hws: support push_esp flag for insert header action

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

support push_esp flag for insert header action, it must be set when inserting an ESP header, it's also sets the next_protocol field in the IPsec trailer.

---
 drivers/common/mlx5/mlx5_prm.h       | 3 ++-
 drivers/net/mlx5/hws/mlx5dr.h        | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_action.c | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_action.h | 1 +
 drivers/net/mlx5/hws/mlx5dr_cmd.c    | 2 ++
 drivers/net/mlx5/hws/mlx5dr_cmd.h    | 1 +
 6 files changed, 14 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_prm.h +2 -1
index abff8e4dc3..6fa5553215 100644
@@ -3608,7 +3608,8 @@ struct mlx5_ifc_stc_ste_param_insert_bits {
 	u8 action_type[0x4];
 	u8 encap[0x1];
 	u8 inline_data[0x1];
-	u8 reserved_at_6[0x4];
+	u8 push_esp[0x1];
+	u8 reserved_at_7[0x3];
 	u8 insert_anchor[0x6];
 	u8 reserved_at_10[0x1];
 	u8 insert_offset[0x7];
drivers/net/mlx5/hws/mlx5dr.h +4 -0
index c11ec08616..78b16f3dc7 100644
@@ -192,6 +192,10 @@ struct mlx5dr_action_insert_header {
 	 * requiring device to update offloaded fields (for example IPv4 total length).
 	 */
 	bool encap;
+	/* It must be set when adding ESP header.
+	 * It's also sets the next_protocol value in the ipsec trailer.
+	 */
+	bool push_esp;
 };
 
 enum mlx5dr_action_remove_header_type {
drivers/net/mlx5/hws/mlx5dr_action.c +4 -0
index 8589de5557..f55069c675 100644
@@ -598,6 +598,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 		attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT;
 		attr->action_offset = MLX5DR_ACTION_OFFSET_DW6;
 		attr->insert_header.encap = action->reformat.encap;
+		attr->insert_header.push_esp = action->reformat.push_esp;
 		attr->insert_header.insert_anchor = action->reformat.anchor;
 		attr->insert_header.arg_id = action->reformat.arg_obj->id;
 		attr->insert_header.header_size = action->reformat.header_size;
@@ -635,6 +636,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 		attr->action_offset = MLX5DR_ACTION_OFFSET_DW6;
 		attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS;
 		attr->insert_header.encap = 0;
+		attr->insert_header.push_esp = 0;
 		attr->insert_header.is_inline = 1;
 		attr->insert_header.insert_anchor = MLX5_HEADER_ANCHOR_PACKET_START;
 		attr->insert_header.insert_offset = MLX5DR_ACTION_HDR_LEN_L2_MACS;
@@ -1340,6 +1342,7 @@ mlx5dr_action_handle_insert_with_ptr(struct mlx5dr_action *action,
 			action[i].reformat.anchor = MLX5_HEADER_ANCHOR_PACKET_START;
 			action[i].reformat.offset = 0;
 			action[i].reformat.encap = 1;
+			action[i].reformat.push_esp = 0;
 		}
 
 		if (likely(reparse == MLX5DR_ACTION_STC_REPARSE_DEFAULT))
@@ -2087,6 +2090,7 @@ mlx5dr_action_create_insert_header_reparse(struct mlx5dr_context *ctx,
 
 		action[i].reformat.anchor = hdrs[i].anchor;
 		action[i].reformat.encap = hdrs[i].encap;
+		action[i].reformat.push_esp = hdrs[i].push_esp;
 		action[i].reformat.offset = hdrs[i].offset;
 		reformat_hdrs[i].sz = hdrs[i].hdr.sz;
 		reformat_hdrs[i].data = hdrs[i].hdr.data;
drivers/net/mlx5/hws/mlx5dr_action.h +1 -0
index a8d9720c42..0c8e4bbb5a 100644
@@ -149,6 +149,7 @@ struct mlx5dr_action {
 					uint8_t offset;
 					bool encap;
 					uint8_t require_reparse;
+					bool push_esp;
 				} reformat;
 				struct {
 					struct mlx5dr_action
drivers/net/mlx5/hws/mlx5dr_cmd.c +2 -0
index 876a47147d..28d909df80 100644
@@ -486,6 +486,8 @@ mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr,
 			 MLX5_MODIFICATION_TYPE_INSERT);
 		MLX5_SET(stc_ste_param_insert, stc_parm, encap,
 			 stc_attr->insert_header.encap);
+		MLX5_SET(stc_ste_param_insert, stc_parm, push_esp,
+			 stc_attr->insert_header.push_esp);
 		MLX5_SET(stc_ste_param_insert, stc_parm, inline_data,
 			 stc_attr->insert_header.is_inline);
 		MLX5_SET(stc_ste_param_insert, stc_parm, insert_anchor,
drivers/net/mlx5/hws/mlx5dr_cmd.h +1 -0
index 18c2b07fc8..013a7e99e8 100644
@@ -122,6 +122,7 @@ struct mlx5dr_cmd_stc_modify_attr {
 			uint8_t encap;
 			uint16_t insert_anchor;
 			uint16_t insert_offset;
+			uint8_t push_esp;
 		} insert_header;
 		struct {
 			uint8_t aso_type;
Signature · 1 line
2.39.3
#9 lore raw

PATCH v2 1/10 net/mlx5/hws: skip RTE item when inserting rules by index

The location of indexed rules is determined by the index, not the item hash. A matcher test is added to prevent access to non-existent items. This avoids unnecessary processing and potential segmentation faults.

Fixes 405242c ("net/mlx5/hws: add rule object")
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/mlx5/hws/mlx5dr_rule.c +3 -0
index fa19303b91..e39137a6ee 100644
@@ -23,6 +23,9 @@ static void mlx5dr_rule_skip(struct mlx5dr_matcher *matcher,
 	*skip_rx = false;
 	*skip_tx = false;
 
+	if (unlikely(mlx5dr_matcher_is_insert_by_idx(matcher)))
+		return;
+
 	if (mt->item_flags & MLX5_FLOW_ITEM_REPRESENTED_PORT) {
 		v = items[mt->vport_item_id].spec;
 		vport = flow_hw_conv_port_id(v->port_id);
Signature · 1 line
2.39.3
#10 lore raw

PATCH v2 2/10 net/mlx5/hws: add check for not supported fields in VXLAN

From: Erez Shitrit <[email protected]>

Don't allow the user to mask over rsvd1 / rsvd2 fields which are not supported.

Fixes dbff89ef806f ("net/mlx5/hws: fix tunnel protocol checks")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mlx5/hws/mlx5dr_definer.c +7 -0
index 79d98bbf78..8b8757ecac 100644
@@ -1414,6 +1414,13 @@ mlx5dr_definer_conv_item_vxlan(struct mlx5dr_definer_conv_data *cd,
 	struct mlx5dr_definer_fc *fc;
 	bool inner = cd->tunnel;
 
+	if (m && (m->rsvd0[0] != 0 || m->rsvd0[1] != 0 || m->rsvd0[2] != 0 ||
+	    m->rsvd1 != 0)) {
+		DR_LOG(ERR, "reserved fields are not supported");
+		rte_errno = ENOTSUP;
+		return rte_errno;
+	}
+
 	if (inner) {
 		DR_LOG(ERR, "Inner VXLAN item not supported");
 		rte_errno = ENOTSUP;
Signature · 1 line
2.39.3
#11 lore raw

PATCH v2 3/10 net/mlx5/hws: add support for resizable matchers

In reply to Itamar Gozlan

From: Yevgeny Kliteynik <[email protected]>

Add support for matcher resize with the following new API calls:
- mlx5dr_matcher_resize_set_target
- mlx5dr_matcher_resize_rule_move

The first function links two matchers and allows moving rules from src matcher to dst matcher. Both matchers should have the same characteristics (e.g. same mt, same at). It is the user's responsibility to make sure that the dst matcher has enough space for the moved rules.
After this function, the user can move rules from src into dst matcher, and he is no longer allowed to insert rules to the src matcher.

The second function is used to move the rule from matcher that is being resized to a bigger matcher. Moving a single rule includes creating a new rule in the destination matcher, and deleting the rule from the source matcher. This operation creates a single completion.

---
 drivers/net/mlx5/hws/mlx5dr.h         |  39 ++++
 drivers/net/mlx5/hws/mlx5dr_definer.c |   5 +-
 drivers/net/mlx5/hws/mlx5dr_definer.h |   3 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 181 +++++++++++++++-
 drivers/net/mlx5/hws/mlx5dr_matcher.h |  21 ++
 drivers/net/mlx5/hws/mlx5dr_rule.c    | 290 ++++++++++++++++++++++----
 drivers/net/mlx5/hws/mlx5dr_rule.h    |  30 ++-
 drivers/net/mlx5/hws/mlx5dr_send.c    |  45 ++++
 8 files changed, 573 insertions(+), 41 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +39 -0
index 9c5b068c93..49f72118ba 100644
@@ -139,6 +139,8 @@ struct mlx5dr_matcher_attr {
 	/* Define the insertion and distribution modes for this matcher */
 	enum mlx5dr_matcher_insert_mode insert_mode;
 	enum mlx5dr_matcher_distribute_mode distribute_mode;
+	/* Define whether the created matcher supports resizing into a bigger matcher */
+	bool resizable;
 	union {
 		struct {
 			uint8_t sz_row_log;
@@ -440,6 +442,43 @@ int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
 int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher,
 			     struct mlx5dr_action_template *at);
 
+/* Link two matchers and enable moving rules from src matcher to dst matcher.
+ * Both matchers must be in the same table type, must be created with 'resizable'
+ * property, and should have the same characteristics (e.g. same mt, same at).
+ *
+ * It is the user's responsibility to make sure that the dst matcher
+ * was allocated with the appropriate size.
+ *
+ * Once the function is completed, the user is:
+ *  - allowed to move rules from src into dst matcher
+ *  - no longer allowed to insert rules to the src matcher
+ *
+ * The user is always allowed to insert rules to the dst matcher and
+ * to delete rules from any matcher.
+ *
+ * @param[in] src_matcher
+ *	source matcher for moving rules from
+ * @param[in] dst_matcher
+ *	destination matcher for moving rules to
+ * @return zero on successful move, non zero otherwise.
+ */
+int mlx5dr_matcher_resize_set_target(struct mlx5dr_matcher *src_matcher,
+				     struct mlx5dr_matcher *dst_matcher);
+
+/* Enqueue moving rule operation: moving rule from src matcher to a dst matcher
+ *
+ * @param[in] src_matcher
+ *	matcher that the rule belongs to
+ * @param[in] rule
+ *	the rule to move
+ * @param[in] attr
+ *	rule attributes
+ * @return zero on success, non zero otherwise.
+ */
+int mlx5dr_matcher_resize_rule_move(struct mlx5dr_matcher *src_matcher,
+				    struct mlx5dr_rule *rule,
+				    struct mlx5dr_rule_attr *attr);
+
 /* 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_definer.c +2 -3
index 8b8757ecac..e564062313 100644
@@ -3296,9 +3296,8 @@ int mlx5dr_definer_get_id(struct mlx5dr_definer *definer)
 	return definer->obj->id;
 }
 
-static int
-mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
-		       struct mlx5dr_definer *definer_b)
+int mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
+			   struct mlx5dr_definer *definer_b)
 {
 	int i;
 
drivers/net/mlx5/hws/mlx5dr_definer.h +3 -0
index ced9d9da13..71cc0e94de 100644
@@ -733,4 +733,7 @@ int mlx5dr_definer_init_cache(struct mlx5dr_definer_cache **cache);
 
 void mlx5dr_definer_uninit_cache(struct mlx5dr_definer_cache *cache);
 
+int mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
+			   struct mlx5dr_definer *definer_b);
+
 #endif
drivers/net/mlx5/hws/mlx5dr_matcher.c +180 -1

214 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_matcher.h +21 -0
index 363a61fd41..0f2bf96e8b 100644
@@ -26,6 +26,7 @@ enum mlx5dr_matcher_flags {
 	MLX5DR_MATCHER_FLAGS_RANGE_DEFINER	= 1 << 0,
 	MLX5DR_MATCHER_FLAGS_HASH_DEFINER	= 1 << 1,
 	MLX5DR_MATCHER_FLAGS_COLLISION		= 1 << 2,
+	MLX5DR_MATCHER_FLAGS_RESIZABLE		= 1 << 3,
 };
 
 struct mlx5dr_match_template {
@@ -59,6 +60,14 @@ struct mlx5dr_matcher_action_ste {
 	uint8_t max_stes;
 };
 
+struct mlx5dr_matcher_resize_data {
+	struct mlx5dr_pool_chunk stc;
+	struct mlx5dr_devx_obj *action_ste_rtc_0;
+	struct mlx5dr_devx_obj *action_ste_rtc_1;
+	struct mlx5dr_pool *action_ste_pool;
+	LIST_ENTRY(mlx5dr_matcher_resize_data) next;
+};
+
 struct mlx5dr_matcher {
 	struct mlx5dr_table *tbl;
 	struct mlx5dr_matcher_attr attr;
@@ -71,10 +80,12 @@ struct mlx5dr_matcher {
 	uint8_t flags;
 	struct mlx5dr_devx_obj *end_ft;
 	struct mlx5dr_matcher *col_matcher;
+	struct mlx5dr_matcher *resize_dst;
 	struct mlx5dr_matcher_match_ste match_ste;
 	struct mlx5dr_matcher_action_ste action_ste;
 	struct mlx5dr_definer *hash_definer;
 	LIST_ENTRY(mlx5dr_matcher) next;
+	LIST_HEAD(resize_data_head, mlx5dr_matcher_resize_data) resize_data;
 };
 
 static inline bool
@@ -89,6 +100,16 @@ mlx5dr_matcher_mt_is_range(struct mlx5dr_match_template *mt)
 	return (!!mt->range_definer);
 }
 
+static inline bool mlx5dr_matcher_is_resizable(struct mlx5dr_matcher *matcher)
+{
+	return !!(matcher->flags & MLX5DR_MATCHER_FLAGS_RESIZABLE);
+}
+
+static inline bool mlx5dr_matcher_is_in_resize(struct mlx5dr_matcher *matcher)
+{
+	return !!matcher->resize_dst;
+}
+
 static inline bool mlx5dr_matcher_req_fw_wqe(struct mlx5dr_matcher *matcher)
 {
 	/* Currently HWS doesn't support hash different from match or range */
drivers/net/mlx5/hws/mlx5dr_rule.c +254 -36

409 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_rule.h +29 -1
index f7d97eead5..07adf9c5ad 100644
@@ -10,7 +10,6 @@ enum {
 	MLX5DR_ACTIONS_SZ = 12,
 	MLX5DR_MATCH_TAG_SZ = 32,
 	MLX5DR_JUMBO_TAG_SZ = 44,
-	MLX5DR_STE_SZ = 64,
 };
 
 enum mlx5dr_rule_status {
@@ -23,6 +22,12 @@ enum mlx5dr_rule_status {
 	MLX5DR_RULE_STATUS_FAILED,
 };
 
+enum mlx5dr_rule_move_state {
+	MLX5DR_RULE_RESIZE_STATE_IDLE,
+	MLX5DR_RULE_RESIZE_STATE_WRITING,
+	MLX5DR_RULE_RESIZE_STATE_DELETING,
+};
+
 struct mlx5dr_rule_match_tag {
 	union {
 		uint8_t jumbo[MLX5DR_JUMBO_TAG_SZ];
@@ -33,6 +38,16 @@ struct mlx5dr_rule_match_tag {
 	};
 };
 
+struct mlx5dr_rule_resize_info {
+	uint8_t state;
+	uint32_t rtc_0;
+	uint32_t rtc_1;
+	uint32_t rule_idx;
+	struct mlx5dr_pool *action_ste_pool;
+	uint8_t ctrl_seg[MLX5DR_WQE_SZ_GTA_CTRL]; /* Ctrl segment of STE: 48 bytes */
+	uint8_t data_seg[MLX5DR_WQE_SZ_GTA_DATA]; /* Data segment of STE: 64 bytes */
+};
+
 struct mlx5dr_rule {
 	struct mlx5dr_matcher *matcher;
 	union {
@@ -40,6 +55,7 @@ struct mlx5dr_rule {
 		/* Pointer to tag to store more than one tag */
 		struct mlx5dr_rule_match_tag *tag_ptr;
 		struct ibv_flow *flow;
+		struct mlx5dr_rule_resize_info *resize_info;
 	};
 	uint32_t rtc_0; /* The RTC into which the STE was inserted */
 	uint32_t rtc_1; /* The RTC into which the STE was inserted */
@@ -50,4 +66,16 @@ struct mlx5dr_rule {
 
 void mlx5dr_rule_free_action_ste_idx(struct mlx5dr_rule *rule);
 
+int mlx5dr_rule_move_hws_remove(struct mlx5dr_rule *rule,
+				void *queue, void *user_data);
+
+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;
+}
+
 #endif /* MLX5DR_RULE_H_ */
drivers/net/mlx5/hws/mlx5dr_send.c +45 -0

57 lines not on this page · raw message

Signature · 1 line
2.39.3
#12 lore raw

PATCH v2 4/10 net/mlx5/hws: reordering the STE fields to improve hash

In reply to Itamar Gozlan

Inserting two rules with the same hash calculation result into the same matcher will cause collisions, which can cause degradation in PPS. Changing the order of some fields in the STE can change the hash result, and doing this for every value would give us a different hash distribution for the inputs. By using precomputed optimal DW locations, we can change the STE order for a limited set of the most common values to reduce the number of hash collisions and improve latency.

---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 64 +++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
drivers/net/mlx5/hws/mlx5dr_definer.c +64 -0
index e564062313..eb788a772a 100644
@@ -100,6 +100,33 @@
 	__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
+ * 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] = {
+	{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},
+	{1, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 1, 0, 1, 0, 0},
+	{1, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 1}, {1, 1, 1, 0, 0, 0},
+	{1, 1, 1, 0, 1, 0}, {0, 0, 1, 1, 0, 0}, {0, 1, 1, 0, 0, 1},
+	{0, 0, 1, 0, 0, 1}, {0, 0, 1, 0, 0, 0}, {1, 0, 1, 1, 0, 0},
+	{1, 0, 1, 0, 0, 1}, {0, 0, 1, 1, 0, 1}, {1, 1, 1, 0, 0, 0},
+	{0, 1, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 1, 1, 1},
+	{0, 0, 1, 0, 0, 1}, {1, 1, 0, 1, 1, 0}, {0, 0, 0, 0, 1, 0},
+	{0, 0, 0, 1, 1, 0}};
+
 struct mlx5dr_definer_sel_ctrl {
 	uint8_t allowed_full_dw; /* Full DW selectors cover all offsets */
 	uint8_t allowed_lim_dw;  /* Limited DW selectors cover offset < 64 */
@@ -3185,6 +3212,37 @@ mlx5dr_definer_find_best_range_fit(struct mlx5dr_definer *definer,
 	return rte_errno;
 }
 
+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};
+	int dw = 0, i = 0, j;
+	int *dw_flag;
+	uint8_t tmp;
+
+	dw_flag = optimal_dist_dw[num_log];
+
+	while (hl_prio[i] != MAX_HL_PRIO) {
+		j = 0;
+		/* Finding a candidate to improve its hash distribution */
+		while (j < DW_SELECTORS_MATCH && (hl_prio[i] != definer->dw_selector[j]))
+			j++;
+
+		/* Finding a DW location with good hash distribution */
+		while (dw < DW_SELECTORS_MATCH && dw_flag[dw] == 0)
+			dw++;
+
+		if (dw < DW_SELECTORS_MATCH && j < DW_SELECTORS_MATCH) {
+			tmp = definer->dw_selector[dw];
+			definer->dw_selector[dw] = definer->dw_selector[j];
+			definer->dw_selector[j] = tmp;
+			dw++;
+		}
+		i++;
+	}
+}
+
 static int
 mlx5dr_definer_find_best_match_fit(struct mlx5dr_context *ctx,
 				   struct mlx5dr_definer *definer,
@@ -3355,6 +3413,12 @@ 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))
+		mlx5dr_definer_optimize_order(match_definer, matcher->attr.rule.num_log);
+
 	/* Find the range definer layout for match templates fcrs */
 	ret = mlx5dr_definer_find_best_range_fit(range_definer, matcher);
 	if (ret) {
Signature · 1 line
2.39.3
#13 lore raw

PATCH v2 5/10 net/mlx5/hws: check the rule status on rule update

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Only allow rule updates for rules with their status value equal to MLX5DR_RULE_STATUS_CREATED.
Otherwise, the rule may be in an unstable stage like deleting and this will result in a faulty unexpected scenario.

---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/mlx5/hws/mlx5dr_rule.c +6 -0
index 6bf087e187..aa00c54e53 100644
@@ -977,6 +977,12 @@ int mlx5dr_rule_action_update(struct mlx5dr_rule *rule_handle,
 	if (unlikely(mlx5dr_rule_enqueue_precheck_update(rule_handle, attr)))
 		return -rte_errno;
 
+	if (rule_handle->status != MLX5DR_RULE_STATUS_CREATED) {
+		DR_LOG(ERR, "Current rule status does not allow update");
+		rte_errno = EBUSY;
+		return -rte_errno;
+	}
+
 	ret = mlx5dr_rule_create_hws(rule_handle,
 				     attr,
 				     0,
Signature · 1 line
2.39.3
#14 lore raw

PATCH v2 6/10 net/mlx5/hws: fix VLAN item handling on non relaxed mode

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

If a VLAN item was passed with null mask, the item handler would return immediately and thus won't set default values for non relax mode.
Also change the non relax default set to single-tagged (CVLAN).

Fixes c55c2bf35333 ("net/mlx5/hws: add definer layer")
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +11 -2
index eb788a772a..b8a546989a 100644
@@ -223,6 +223,7 @@ struct mlx5dr_definer_conv_data {
 	X(SET,		ib_l4_opcode,		v->hdr.opcode,		rte_flow_item_ib_bth) \
 	X(SET,		random_number,		v->value,		rte_flow_item_random) \
 	X(SET,		ib_l4_bth_a,		v->hdr.a,		rte_flow_item_ib_bth) \
+	X(SET,		cvlan,			STE_CVLAN,		rte_flow_item_vlan) \
 
 /* Item set function format */
 #define X(set_type, func_name, value, item_type) \
@@ -864,6 +865,15 @@ mlx5dr_definer_conv_item_vlan(struct mlx5dr_definer_conv_data *cd,
 	struct mlx5dr_definer_fc *fc;
 	bool inner = cd->tunnel;
 
+	if (!cd->relaxed) {
+		/* Mark packet as tagged (CVLAN) */
+		fc = &cd->fc[DR_CALC_FNAME(VLAN_TYPE, inner)];
+		fc->item_idx = item_idx;
+		fc->tag_mask_set = &mlx5dr_definer_ones_set;
+		fc->tag_set = &mlx5dr_definer_cvlan_set;
+		DR_CALC_SET(fc, eth_l2, first_vlan_qualifier, inner);
+	}
+
 	if (!m)
 		return 0;
 
@@ -872,8 +882,7 @@ mlx5dr_definer_conv_item_vlan(struct mlx5dr_definer_conv_data *cd,
 		return rte_errno;
 	}
 
-	if (!cd->relaxed || m->has_more_vlan) {
-		/* Mark packet as tagged (CVLAN or SVLAN) even if TCI is not specified.*/
+	if (m->has_more_vlan) {
 		fc = &cd->fc[DR_CALC_FNAME(VLAN_TYPE, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
Signature · 1 line
2.39.3
#15 lore raw

PATCH v2 7/10 net/mlx5/hws: extend action template creation API

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Extend mlx5dr_action_template_create function params to include flags parameter.

---
 drivers/net/mlx5/hws/mlx5dr.h         | 10 +++++++++-
 drivers/net/mlx5/hws/mlx5dr_action.c  | 11 ++++++++++-
 drivers/net/mlx5/hws/mlx5dr_action.h  |  1 +
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 16 ++++++++++------
 drivers/net/mlx5/mlx5_flow_hw.c       |  2 +-
 5 files changed, 31 insertions(+), 9 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +9 -1
index 49f72118ba..3647e25cf2 100644
@@ -84,6 +84,11 @@ enum mlx5dr_match_template_flags {
 	MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH = 1,
 };
 
+enum mlx5dr_action_template_flags {
+	/* Allow relaxed actions order. */
+	MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER = 1 << 0,
+};
+
 enum mlx5dr_send_queue_actions {
 	/* Start executing all pending queued rules */
 	MLX5DR_SEND_QUEUE_ACTION_DRAIN_ASYNC = 1 << 0,
@@ -383,10 +388,13 @@ int mlx5dr_match_template_destroy(struct mlx5dr_match_template *mt);
  *	An array of actions based on the order of actions which will be provided
  *	with rule_actions to mlx5dr_rule_create. The last action is marked
  *	using MLX5DR_ACTION_TYP_LAST.
+ * @param[in] flags
+ *	Template creation flags
  * @return pointer to mlx5dr_action_template on success NULL otherwise
  */
 struct mlx5dr_action_template *
-mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[]);
+mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[],
+			      uint32_t flags);
 
 /* Destroy action template.
  *
drivers/net/mlx5/hws/mlx5dr_action.c +10 -1
index 862ee3e332..370886907f 100644
@@ -3385,12 +3385,19 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at)
 }
 
 struct mlx5dr_action_template *
-mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[])
+mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[],
+			      uint32_t flags)
 {
 	struct mlx5dr_action_template *at;
 	uint8_t num_actions = 0;
 	int i;
 
+	if (flags > MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER) {
+		DR_LOG(ERR, "Unsupported action template flag provided");
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
 	at = simple_calloc(1, sizeof(*at));
 	if (!at) {
 		DR_LOG(ERR, "Failed to allocate action template");
@@ -3398,6 +3405,8 @@ mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[])
 		return NULL;
 	}
 
+	at->flags = flags;
+
 	while (action_type[num_actions++] != MLX5DR_ACTION_TYP_LAST)
 		;
 
drivers/net/mlx5/hws/mlx5dr_action.h +1 -0
index fad35a845b..a8d9720c42 100644
@@ -119,6 +119,7 @@ struct mlx5dr_action_template {
 	uint8_t num_of_action_stes;
 	uint8_t num_actions;
 	uint8_t only_term;
+	uint32_t flags;
 };
 
 struct mlx5dr_action {
drivers/net/mlx5/hws/mlx5dr_matcher.c +10 -6
index 0d5c462734..402242308d 100644
@@ -686,12 +686,16 @@ static int mlx5dr_matcher_check_and_process_at(struct mlx5dr_matcher *matcher,
 	bool valid;
 	int ret;
 
-	/* Check if action combinabtion is valid */
-	valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type);
-	if (!valid) {
-		DR_LOG(ERR, "Invalid combination in action template");
-		rte_errno = EINVAL;
-		return rte_errno;
+	if (!(at->flags & MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER)) {
+		/* Check if actions combinabtion is valid,
+		 * in the case of not relaxed actions order.
+		 */
+		valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type);
+		if (!valid) {
+			DR_LOG(ERR, "Invalid combination in action template");
+			rte_errno = EINVAL;
+			return rte_errno;
+		}
 	}
 
 	/* Process action template to setters */
drivers/net/mlx5/mlx5_flow_hw.c +1 -1
index 3bb3a9a178..9d3dad65d4 100644
@@ -6202,7 +6202,7 @@ flow_hw_dr_actions_template_create(struct rte_eth_dev *dev,
 		at->recom_off = recom_off;
 		action_types[recom_off] = recom_type;
 	}
-	dr_template = mlx5dr_action_template_create(action_types);
+	dr_template = mlx5dr_action_template_create(action_types, 0);
 	if (dr_template) {
 		at->dr_actions_num = curr_off;
 	} else {
Signature · 1 line
2.39.3
#16 lore raw

PATCH v2 8/10 net/mlx5/hws: add missing actions STE limitation

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

Today if we pass a remove header action and after it an insert header action then our action template builder will set two different STE setters, because it won't allow insert header in same STE as remove header.
But if we have the opposite order of insert header and then remove header actions, then the setter will set both of them on the same STE since the opposite check was missing.
This patch added the missing opposite limitation.

---
 drivers/net/mlx5/hws/mlx5dr_action.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_action.c +2 -1
index 370886907f..8589de5557 100644
@@ -3308,7 +3308,8 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at)
 		case MLX5DR_ACTION_TYP_REMOVE_HEADER:
 		case MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2:
 			/* Single remove header to header */
-			setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_MODIFY);
+			setter = mlx5dr_action_setter_find_first(last_setter,
+					ASF_SINGLE1 | ASF_MODIFY | ASF_INSERT);
 			setter->flags |= ASF_SINGLE1 | ASF_REMOVE;
 			setter->set_single = &mlx5dr_action_setter_single;
 			setter->idx_single = i;
Signature · 1 line
2.39.3
#17 lore raw

PATCH v2 9/10 net/mlx5/hws: support push_esp flag for insert header action

In reply to Itamar Gozlan

From: Hamdan Igbaria <[email protected]>

support push_esp flag for insert header action, it must be set when inserting an ESP header, it's also sets the next_protocol field in the IPsec trailer.

---
 drivers/common/mlx5/mlx5_prm.h       | 3 ++-
 drivers/net/mlx5/hws/mlx5dr.h        | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_action.c | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_action.h | 1 +
 drivers/net/mlx5/hws/mlx5dr_cmd.c    | 2 ++
 drivers/net/mlx5/hws/mlx5dr_cmd.h    | 1 +
 6 files changed, 14 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_prm.h +2 -1
index 787211c85c..282e59e52c 100644
@@ -3616,7 +3616,8 @@ struct mlx5_ifc_stc_ste_param_insert_bits {
 	u8 action_type[0x4];
 	u8 encap[0x1];
 	u8 inline_data[0x1];
-	u8 reserved_at_6[0x4];
+	u8 push_esp[0x1];
+	u8 reserved_at_7[0x3];
 	u8 insert_anchor[0x6];
 	u8 reserved_at_10[0x1];
 	u8 insert_offset[0x7];
drivers/net/mlx5/hws/mlx5dr.h +4 -0
index 3647e25cf2..d612f300c6 100644
@@ -192,6 +192,10 @@ struct mlx5dr_action_insert_header {
 	 * requiring device to update offloaded fields (for example IPv4 total length).
 	 */
 	bool encap;
+	/* It must be set when adding ESP header.
+	 * It's also sets the next_protocol value in the ipsec trailer.
+	 */
+	bool push_esp;
 };
 
 enum mlx5dr_action_remove_header_type {
drivers/net/mlx5/hws/mlx5dr_action.c +4 -0
index 8589de5557..f55069c675 100644
@@ -598,6 +598,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 		attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT;
 		attr->action_offset = MLX5DR_ACTION_OFFSET_DW6;
 		attr->insert_header.encap = action->reformat.encap;
+		attr->insert_header.push_esp = action->reformat.push_esp;
 		attr->insert_header.insert_anchor = action->reformat.anchor;
 		attr->insert_header.arg_id = action->reformat.arg_obj->id;
 		attr->insert_header.header_size = action->reformat.header_size;
@@ -635,6 +636,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 		attr->action_offset = MLX5DR_ACTION_OFFSET_DW6;
 		attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS;
 		attr->insert_header.encap = 0;
+		attr->insert_header.push_esp = 0;
 		attr->insert_header.is_inline = 1;
 		attr->insert_header.insert_anchor = MLX5_HEADER_ANCHOR_PACKET_START;
 		attr->insert_header.insert_offset = MLX5DR_ACTION_HDR_LEN_L2_MACS;
@@ -1340,6 +1342,7 @@ mlx5dr_action_handle_insert_with_ptr(struct mlx5dr_action *action,
 			action[i].reformat.anchor = MLX5_HEADER_ANCHOR_PACKET_START;
 			action[i].reformat.offset = 0;
 			action[i].reformat.encap = 1;
+			action[i].reformat.push_esp = 0;
 		}
 
 		if (likely(reparse == MLX5DR_ACTION_STC_REPARSE_DEFAULT))
@@ -2087,6 +2090,7 @@ mlx5dr_action_create_insert_header_reparse(struct mlx5dr_context *ctx,
 
 		action[i].reformat.anchor = hdrs[i].anchor;
 		action[i].reformat.encap = hdrs[i].encap;
+		action[i].reformat.push_esp = hdrs[i].push_esp;
 		action[i].reformat.offset = hdrs[i].offset;
 		reformat_hdrs[i].sz = hdrs[i].hdr.sz;
 		reformat_hdrs[i].data = hdrs[i].hdr.data;
drivers/net/mlx5/hws/mlx5dr_action.h +1 -0
index a8d9720c42..0c8e4bbb5a 100644
@@ -149,6 +149,7 @@ struct mlx5dr_action {
 					uint8_t offset;
 					bool encap;
 					uint8_t require_reparse;
+					bool push_esp;
 				} reformat;
 				struct {
 					struct mlx5dr_action
drivers/net/mlx5/hws/mlx5dr_cmd.c +2 -0
index f77b194708..4676f65d60 100644
@@ -486,6 +486,8 @@ mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr,
 			 MLX5_MODIFICATION_TYPE_INSERT);
 		MLX5_SET(stc_ste_param_insert, stc_parm, encap,
 			 stc_attr->insert_header.encap);
+		MLX5_SET(stc_ste_param_insert, stc_parm, push_esp,
+			 stc_attr->insert_header.push_esp);
 		MLX5_SET(stc_ste_param_insert, stc_parm, inline_data,
 			 stc_attr->insert_header.is_inline);
 		MLX5_SET(stc_ste_param_insert, stc_parm, insert_anchor,
drivers/net/mlx5/hws/mlx5dr_cmd.h +1 -0
index 694231e08f..ee4a61b7eb 100644
@@ -122,6 +122,7 @@ struct mlx5dr_cmd_stc_modify_attr {
 			uint8_t encap;
 			uint16_t insert_anchor;
 			uint16_t insert_offset;
+			uint8_t push_esp;
 		} insert_header;
 		struct {
 			uint8_t aso_type;
Signature · 1 line
2.39.3
#18 lore raw

PATCH v2 10/10 net/mlx5/hws: typo fix parm to param

In reply to Itamar Gozlan

Fixing a typo in mlx5dr_cmd.c file, changing a variable name from stc_parm to stc_param, as short for parameter.

---
 drivers/net/mlx5/hws/mlx5dr_cmd.c | 68 +++++++++++++++----------------
 1 file changed, 34 insertions(+), 34 deletions(-)
drivers/net/mlx5/hws/mlx5dr_cmd.c +34 -34
index 4676f65d60..fd07028e5f 100644
@@ -453,66 +453,66 @@ mlx5dr_cmd_stc_create(struct ibv_context *ctx,
 
 static int
 mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr,
-				    void *stc_parm)
+				    void *stc_param)
 {
 	switch (stc_attr->action_type) {
 	case MLX5_IFC_STC_ACTION_TYPE_COUNTER:
-		MLX5_SET(stc_ste_param_flow_counter, stc_parm, flow_counter_id, stc_attr->id);
+		MLX5_SET(stc_ste_param_flow_counter, stc_param, flow_counter_id, stc_attr->id);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_TIR:
-		MLX5_SET(stc_ste_param_tir, stc_parm, tirn, stc_attr->dest_tir_num);
+		MLX5_SET(stc_ste_param_tir, stc_param, tirn, stc_attr->dest_tir_num);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_FT:
-		MLX5_SET(stc_ste_param_table, stc_parm, table_id, stc_attr->dest_table_id);
+		MLX5_SET(stc_ste_param_table, stc_param, table_id, stc_attr->dest_table_id);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_ACC_MODIFY_LIST:
-		MLX5_SET(stc_ste_param_header_modify_list, stc_parm,
+		MLX5_SET(stc_ste_param_header_modify_list, stc_param,
 			 header_modify_pattern_id, stc_attr->modify_header.pattern_id);
-		MLX5_SET(stc_ste_param_header_modify_list, stc_parm,
+		MLX5_SET(stc_ste_param_header_modify_list, stc_param,
 			 header_modify_argument_id, stc_attr->modify_header.arg_id);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_HEADER_REMOVE:
-		MLX5_SET(stc_ste_param_remove, stc_parm, action_type,
+		MLX5_SET(stc_ste_param_remove, stc_param, action_type,
 			 MLX5_MODIFICATION_TYPE_REMOVE);
-		MLX5_SET(stc_ste_param_remove, stc_parm, decap,
+		MLX5_SET(stc_ste_param_remove, stc_param, decap,
 			 stc_attr->remove_header.decap);
-		MLX5_SET(stc_ste_param_remove, stc_parm, remove_start_anchor,
+		MLX5_SET(stc_ste_param_remove, stc_param, remove_start_anchor,
 			 stc_attr->remove_header.start_anchor);
-		MLX5_SET(stc_ste_param_remove, stc_parm, remove_end_anchor,
+		MLX5_SET(stc_ste_param_remove, stc_param, remove_end_anchor,
 			 stc_attr->remove_header.end_anchor);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT:
-		MLX5_SET(stc_ste_param_insert, stc_parm, action_type,
+		MLX5_SET(stc_ste_param_insert, stc_param, action_type,
 			 MLX5_MODIFICATION_TYPE_INSERT);
-		MLX5_SET(stc_ste_param_insert, stc_parm, encap,
+		MLX5_SET(stc_ste_param_insert, stc_param, encap,
 			 stc_attr->insert_header.encap);
-		MLX5_SET(stc_ste_param_insert, stc_parm, push_esp,
+		MLX5_SET(stc_ste_param_insert, stc_param, push_esp,
 			 stc_attr->insert_header.push_esp);
-		MLX5_SET(stc_ste_param_insert, stc_parm, inline_data,
+		MLX5_SET(stc_ste_param_insert, stc_param, inline_data,
 			 stc_attr->insert_header.is_inline);
-		MLX5_SET(stc_ste_param_insert, stc_parm, insert_anchor,
+		MLX5_SET(stc_ste_param_insert, stc_param, insert_anchor,
 			 stc_attr->insert_header.insert_anchor);
 		/* HW gets the next 2 sizes in words */
-		MLX5_SET(stc_ste_param_insert, stc_parm, insert_size,
+		MLX5_SET(stc_ste_param_insert, stc_param, insert_size,
 			 stc_attr->insert_header.header_size / W_SIZE);
-		MLX5_SET(stc_ste_param_insert, stc_parm, insert_offset,
+		MLX5_SET(stc_ste_param_insert, stc_param, insert_offset,
 			 stc_attr->insert_header.insert_offset / W_SIZE);
-		MLX5_SET(stc_ste_param_insert, stc_parm, insert_argument,
+		MLX5_SET(stc_ste_param_insert, stc_param, insert_argument,
 			 stc_attr->insert_header.arg_id);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_COPY:
 	case MLX5_IFC_STC_ACTION_TYPE_SET:
 	case MLX5_IFC_STC_ACTION_TYPE_ADD:
 	case MLX5_IFC_STC_ACTION_TYPE_ADD_FIELD:
-		*(__be64 *)stc_parm = stc_attr->modify_action.data;
+		*(__be64 *)stc_param = stc_attr->modify_action.data;
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_VPORT:
 	case MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_UPLINK:
-		MLX5_SET(stc_ste_param_vport, stc_parm, vport_number,
+		MLX5_SET(stc_ste_param_vport, stc_param, vport_number,
 			 stc_attr->vport.vport_num);
-		MLX5_SET(stc_ste_param_vport, stc_parm, eswitch_owner_vhca_id,
+		MLX5_SET(stc_ste_param_vport, stc_param, eswitch_owner_vhca_id,
 			 stc_attr->vport.esw_owner_vhca_id);
-		MLX5_SET(stc_ste_param_vport, stc_parm, eswitch_owner_vhca_id_valid, 1);
+		MLX5_SET(stc_ste_param_vport, stc_param, eswitch_owner_vhca_id_valid, 1);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_DROP:
 	case MLX5_IFC_STC_ACTION_TYPE_NOP:
@@ -520,27 +520,27 @@ mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr,
 	case MLX5_IFC_STC_ACTION_TYPE_ALLOW:
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_ASO:
-		MLX5_SET(stc_ste_param_execute_aso, stc_parm, aso_object_id,
+		MLX5_SET(stc_ste_param_execute_aso, stc_param, aso_object_id,
 			 stc_attr->aso.devx_obj_id);
-		MLX5_SET(stc_ste_param_execute_aso, stc_parm, return_reg_id,
+		MLX5_SET(stc_ste_param_execute_aso, stc_param, return_reg_id,
 			 stc_attr->aso.return_reg_id);
-		MLX5_SET(stc_ste_param_execute_aso, stc_parm, aso_type,
+		MLX5_SET(stc_ste_param_execute_aso, stc_param, aso_type,
 			 stc_attr->aso.aso_type);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_STE_TABLE:
-		MLX5_SET(stc_ste_param_ste_table, stc_parm, ste_obj_id,
+		MLX5_SET(stc_ste_param_ste_table, stc_param, ste_obj_id,
 			 stc_attr->ste_table.ste_obj_id);
-		MLX5_SET(stc_ste_param_ste_table, stc_parm, match_definer_id,
+		MLX5_SET(stc_ste_param_ste_table, stc_param, match_definer_id,
 			 stc_attr->ste_table.match_definer_id);
-		MLX5_SET(stc_ste_param_ste_table, stc_parm, log_hash_size,
+		MLX5_SET(stc_ste_param_ste_table, stc_param, log_hash_size,
 			 stc_attr->ste_table.log_hash_size);
 		break;
 	case MLX5_IFC_STC_ACTION_TYPE_REMOVE_WORDS:
-		MLX5_SET(stc_ste_param_remove_words, stc_parm, action_type,
+		MLX5_SET(stc_ste_param_remove_words, stc_param, action_type,
 			 MLX5_MODIFICATION_TYPE_REMOVE_WORDS);
-		MLX5_SET(stc_ste_param_remove_words, stc_parm, remove_start_anchor,
+		MLX5_SET(stc_ste_param_remove_words, stc_param, remove_start_anchor,
 			 stc_attr->remove_words.start_anchor);
-		MLX5_SET(stc_ste_param_remove_words, stc_parm,
+		MLX5_SET(stc_ste_param_remove_words, stc_param,
 			 remove_size, stc_attr->remove_words.num_of_words);
 		break;
 	default:
@@ -557,7 +557,7 @@ mlx5dr_cmd_stc_modify(struct mlx5dr_devx_obj *devx_obj,
 {
 	uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
 	uint32_t in[MLX5_ST_SZ_DW(create_stc_in)] = {0};
-	void *stc_parm;
+	void *stc_param;
 	void *attr;
 	int ret;
 
@@ -577,8 +577,8 @@ mlx5dr_cmd_stc_modify(struct mlx5dr_devx_obj *devx_obj,
 		   MLX5_IFC_MODIFY_STC_FIELD_SELECT_NEW_STC);
 
 	/* Set destination TIRN, TAG, FT ID, STE ID */
-	stc_parm = MLX5_ADDR_OF(stc, attr, stc_param);
-	ret = mlx5dr_cmd_stc_modify_set_stc_param(stc_attr, stc_parm);
+	stc_param = MLX5_ADDR_OF(stc, attr, stc_param);
+	ret = mlx5dr_cmd_stc_modify_set_stc_param(stc_attr, stc_param);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.39.3
#19 lore raw
In reply to Itamar Gozlan

Hi,

Quoted 13 lines

-----Original Message-----
From: Itamar Gozlan <[email protected]>
Sent: Sunday, February 18, 2024 7:11 AM
To: Itamar Gozlan <[email protected]>; Erez Shitrit <[email protected]>; Hamdan Agbariya <[email protected]>; Yevgeny Kliteynik <[email protected]>; Slava Ovsiienko <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Suanming Mou <[email protected]>; Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; Matan Azrad <[email protected]>; Alex Vesker <[email protected]>
Cc: [email protected]
Subject: [v2 01/10] net/mlx5/hws: skip RTE item when inserting rules by index

Quoted 7 lines

The location of indexed rules is determined by the index, not the item hash. A matcher test is added to prevent access to non-existent items. This avoids unnecessary processing and potential segmentation faults.

Fixes 405242c ("net/mlx5/hws: add rule object")

Fixed few fixes tags,
Series applied to next-net-mlx,

Kindest regards
Raslan Darawsheh