Skip to contentSkip to conversation

net/mlx5/hws: add support for multi pattern

PATCH In review Alex Vesker 2 participants 2 messages Jul 9, 2023 – Aug 30, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5/hws: add support for multi pattern

When creating an action it can contain a bulk of objects, but the objects are fixed to a specific pattern and cannot be reused. This can lead to inefficient usage of the HW resources, This support allows creating multiple patterns over a single mlx5dr action.

---
 drivers/net/mlx5/hws/mlx5dr.h         |  45 ++-
 drivers/net/mlx5/hws/mlx5dr_action.c  | 538 +++++++++++++++-----------
 drivers/net/mlx5/hws/mlx5dr_action.h  |   8 +-
 drivers/net/mlx5/hws/mlx5dr_pat_arg.c | 252 +++++-------
 drivers/net/mlx5/hws/mlx5dr_pat_arg.h |  34 +-
 drivers/net/mlx5/mlx5_flow_hw.c       |  11 +-
 6 files changed, 483 insertions(+), 405 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +30 -15
index ec2230d136..6b96a120f7 100644
@@ -156,8 +156,21 @@ struct mlx5dr_devx_obj {
 	uint32_t id;
 };
 
-/* In actions that take offset, the offset is unique, and the user should not
- * reuse the same index because data changing is not atomic.
+struct mlx5dr_action_reformat_header {
+	size_t sz;
+	void *data;
+};
+
+struct mlx5dr_action_mh_pattern {
+	/* Byte size of modify actions provided by "data" */
+	size_t sz;
+	/* PRM format modify actions pattern */
+	__be64 *data;
+};
+
+/* In actions that take offset, the offset is unique, pointing to a single
+ * resource and the user should not reuse the same index because data changing
+ * is not atomic.
  */
 struct mlx5dr_rule_action {
 	struct mlx5dr_action *action;
@@ -172,11 +185,13 @@ struct mlx5dr_rule_action {
 
 		struct {
 			uint32_t offset;
+			uint8_t pattern_idx;
 			uint8_t *data;
 		} modify_header;
 
 		struct {
 			uint32_t offset;
+			uint8_t hdr_idx;
 			uint8_t *data;
 		} reformat;
 
@@ -481,12 +496,12 @@ mlx5dr_action_create_counter(struct mlx5dr_context *ctx,
  *	The context in which the new action will be created.
  * @param[in] reformat_type
  *	Type of reformat prefixed with MLX5DR_ACTION_TYP_REFORMAT.
- * @param[in] data_sz
- *	Size in bytes of data.
- * @param[in] inline_data
- *	Header data array in case of inline action.
+ * @param[in] num_of_hdrs
+ *	Number of provided headers in "hdrs" array.
+ * @param[in] hdrs
+ *	Headers array containing header information.
  * @param[in] log_bulk_size
- *	Number of unique values used with this pattern.
+ *	Number of unique values used with this reformat.
  * @param[in] flags
  *	Action creation flags. (enum mlx5dr_action_flags)
  * @return pointer to mlx5dr_action on success NULL otherwise.
@@ -494,8 +509,8 @@ mlx5dr_action_create_counter(struct mlx5dr_context *ctx,
 struct mlx5dr_action *
 mlx5dr_action_create_reformat(struct mlx5dr_context *ctx,
 			      enum mlx5dr_action_type reformat_type,
-			      size_t data_sz,
-			      void *inline_data,
+			      uint8_t num_of_hdrs,
+			      struct mlx5dr_action_reformat_header *hdrs,
 			      uint32_t log_bulk_size,
 			      uint32_t flags);
 
@@ -503,10 +518,10 @@ mlx5dr_action_create_reformat(struct mlx5dr_context *ctx,
  *
  * @param[in] ctx
  *	The context in which the new action will be created.
- * @param[in] pattern_sz
- *	Byte size of the pattern array.
- * @param[in] pattern
- *	PRM format modify pattern action array.
+ * @param[in] num_of_patterns
+ * 	Number of provided patterns in "patterns" array.
+ * @param[in] patterns
+ *	Patterns array containing pattern information.
  * @param[in] log_bulk_size
  *	Number of unique values used with this pattern.
  * @param[in] flags
@@ -515,8 +530,8 @@ mlx5dr_action_create_reformat(struct mlx5dr_context *ctx,
  */
 struct mlx5dr_action *
 mlx5dr_action_create_modify_header(struct mlx5dr_context *ctx,
-				   size_t pattern_sz,
-				   __be64 pattern[],
+				   uint8_t num_of_patterns,
+				   struct mlx5dr_action_mh_pattern *patterns,
 				   uint32_t log_bulk_size,
 				   uint32_t flags);
 
drivers/net/mlx5/hws/mlx5dr_action.c +314 -224

811 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_action.h +6 -2
index a85f3b0139..314e289780 100644
@@ -120,15 +120,19 @@ struct mlx5dr_action {
 			struct mlx5dr_pool_chunk stc[MLX5DR_TABLE_TYPE_MAX];
 			union {
 				struct {
-					struct mlx5dr_devx_obj *pattern_obj;
+					struct mlx5dr_devx_obj *pat_obj;
 					struct mlx5dr_devx_obj *arg_obj;
 					__be64 single_action;
+					uint8_t num_of_patterns;
 					uint8_t single_action_type;
-					uint16_t num_of_actions;
+					uint8_t num_of_actions;
+					uint8_t max_num_of_actions;
 				} modify_header;
 				struct {
 					struct mlx5dr_devx_obj *arg_obj;
 					uint32_t header_size;
+					uint8_t num_of_hdrs;
+					uint16_t max_hdr_sz;
 				} reformat;
 				struct {
 					struct mlx5dr_devx_obj *devx_obj;
drivers/net/mlx5/hws/mlx5dr_pat_arg.c +101 -151

381 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_pat_arg.h +23 -11
index ec467dbb4b..2a38891c4d 100644
@@ -28,7 +28,6 @@ struct mlx5dr_pattern_cache {
 };
 
 struct mlx5dr_pattern_cache_item {
-	enum mlx5dr_action_type type;
 	struct {
 		struct mlx5dr_devx_obj *pattern_obj;
 		struct dr_icm_chunk *chunk;
@@ -53,16 +52,29 @@ int mlx5dr_pat_init_pattern_cache(struct mlx5dr_pattern_cache **cache);
 
 void mlx5dr_pat_uninit_pattern_cache(struct mlx5dr_pattern_cache *cache);
 
-bool mlx5dr_pat_arg_verify_actions(__be64 pattern[], uint16_t num_of_actions);
-
-int mlx5dr_pat_arg_create_modify_header(struct mlx5dr_context *ctx,
-					struct mlx5dr_action *action,
-					size_t pattern_sz,
-					__be64 pattern[],
-					uint32_t bulk_size);
-
-void mlx5dr_pat_arg_destroy_modify_header(struct mlx5dr_context *ctx,
-					  struct mlx5dr_action *action);
+bool mlx5dr_pat_verify_actions(__be64 pattern[], size_t sz);
+
+struct mlx5dr_devx_obj *
+mlx5dr_arg_create(struct mlx5dr_context *ctx,
+		  uint8_t *data,
+		  size_t data_sz,
+		  uint32_t log_bulk_sz,
+		  bool write_data);
+
+struct mlx5dr_devx_obj *
+mlx5dr_arg_create_modify_header_arg(struct mlx5dr_context *ctx,
+				    __be64 *data,
+				    uint8_t num_of_actions,
+				    uint32_t log_bulk_sz,
+				    bool write_data);
+
+struct mlx5dr_devx_obj *
+mlx5dr_pat_get_pattern(struct mlx5dr_context *ctx,
+		       __be64 *pattern,
+		       size_t pattern_sz);
+
+void mlx5dr_pat_put_pattern(struct mlx5dr_context *ctx,
+			    struct mlx5dr_devx_obj *pat_obj);
 
 bool mlx5dr_arg_is_valid_arg_request_size(struct mlx5dr_context *ctx,
 					  uint32_t arg_size);
drivers/net/mlx5/mlx5_flow_hw.c +9 -2
index 8e146d99e2..271e4aae10 100644
@@ -1770,6 +1770,7 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,
 		}
 	}
 	if (mhdr.pos != UINT16_MAX) {
+		struct mlx5dr_action_mh_pattern pattern;
 		uint32_t flags;
 		uint32_t bulk_size;
 		size_t mhdr_len;
@@ -1791,14 +1792,17 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,
 		} else {
 			bulk_size = rte_log2_u32(table_attr->nb_flows);
 		}
+		pattern.data = (__be64 *)acts->mhdr->mhdr_cmds;
+		pattern.sz = mhdr_len;
 		acts->mhdr->action = mlx5dr_action_create_modify_header
-				(priv->dr_ctx, mhdr_len, (__be64 *)acts->mhdr->mhdr_cmds,
+				(priv->dr_ctx, 1, &pattern,
 				 bulk_size, flags);
 		if (!acts->mhdr->action)
 			goto err;
 		acts->rule_acts[acts->mhdr->pos].action = acts->mhdr->action;
 	}
 	if (reformat_used) {
+		struct mlx5dr_action_reformat_header hdr;
 		uint8_t buf[MLX5_ENCAP_MAX_LEN];
 		bool shared_rfmt = true;
 
@@ -1822,9 +1826,12 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,
 			acts->encap_decap->data_size = data_size;
 			memcpy(acts->encap_decap->data, encap_data, data_size);
 		}
+
+		hdr.sz = data_size;
+		hdr.data = encap_data;
 		acts->encap_decap->action = mlx5dr_action_create_reformat
 				(priv->dr_ctx, refmt_type,
-				 data_size, encap_data,
+				 1, &hdr,
 				 shared_rfmt ? 0 : rte_log2_u32(table_attr->nb_flows),
 				 mlx5_hw_act_flag[!!attr->group][type] |
 				 (shared_rfmt ? MLX5DR_ACTION_FLAG_SHARED : 0));
Signature · 1 line
2.18.1
#1 lore raw

Hi,

Quoted 19 lines

-----Original Message-----
From: Alex Vesker <[email protected]>
Sent: Sunday, July 9, 2023 5:20 PM
To: Alex Vesker <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]
Subject: [PATCH] net/mlx5/hws: add support for multi pattern

When creating an action it can contain a bulk of objects, but the objects are fixed to a specific pattern and cannot be reused. This can lead to inefficient usage of the HW resources, This support allows creating multiple patterns over a single mlx5dr action.

---

....

drivers/net/mlx5/hws/mlx5dr.h mlx5dr_action_create_reformat(struct · line 523

Quoted 12 lines
drivers/net/mlx5/hws/mlx5dr.h +2 -4
@@ -503,10 +518,10 @@ mlx5dr_action_create_reformat(struct
 mlx5dr_context *ctx,
  *
  * @param[in] ctx
  *	The context in which the new action will be created.
- * @param[in] pattern_sz
- *	Byte size of the pattern array.
- * @param[in] pattern
- *	PRM format modify pattern action array.
+ * @param[in] num_of_patterns
+ * 	Number of provided patterns in "patterns" array.

Fixed an issue with the wrong indentation usage of space

Quoted 6 lines
drivers/net/mlx5/hws/mlx5dr.h +2 -0
+ * @param[in] patterns
+ *	Patterns array containing pattern information.
  * @param[in] log_bulk_size
  *	Number of unique values used with this pattern.

* @param[in] flags

(quoted diff) +0 -0
@@ -515,8 +530,8 @@ mlx5dr_action_create_reformat(struct

....

drivers/net/mlx5/hws/mlx5dr_action.c mlx5dr_action_create_modify_header_root(struct mlx5dr_action *action,

Quoted 13 lines
drivers/net/mlx5/hws/mlx5dr_action.c +4 -0
+static int
+mlx5dr_action_create_modify_header_hws(struct mlx5dr_action *action,
+				       uint8_t num_of_patterns,
+				       struct mlx5dr_action_mh_pattern

*pattern,

drivers/net/mlx5/hws/mlx5dr_action.c +8 -0
+				       uint32_t log_bulk_size)
+{
+	struct mlx5dr_devx_obj *pat_obj, *arg_obj = NULL;
+	struct mlx5dr_context *ctx = action->ctx;
+	uint16_t max_mh_actions = 0;
+	int i, ret;
+
+	/* Caclulate maximum number of mh actions for shared arg allocation

Fixed a typo Caclulate =-> Calculate.
....

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh