DPDK patches and discussions
 help / color / mirror / Atom feed
From: Erez Shitrit <erezsh@nvidia.com>
To: <dev@dpdk.org>
Cc: <valex@nvidia.com>, Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH 1/4] net/mlx5/hws: fix bug in pattern creation
Date: Mon, 20 Mar 2023 16:53:40 +0200	[thread overview]
Message-ID: <20230320145343.449023-1-erezsh@nvidia.com> (raw)


When creating a new pattern the data area should be clean, otherwise
when the data will come from the arg object it will do OR operation on
the data part in the pattern.

Fixes: f8c8a6d8440d ("net/mlx5/hws: add action object")
Reviewed-by: Alex Vesker <valex@nvidia.com>
Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_cmd.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c b/drivers/net/mlx5/hws/mlx5dr_cmd.c
index a444fb4438..0adcedd9c9 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.c
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c
@@ -523,9 +523,11 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,
 	uint32_t in[MLX5_ST_SZ_DW(create_header_modify_pattern_in)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
 	struct mlx5dr_devx_obj *devx_obj;
-	void *pattern_data;
+	uint64_t *pattern_data;
+	int num_of_actions;
 	void *pattern;
 	void *attr;
+	int i;
 
 	if (pattern_length > MAX_ACTIONS_DATA_IN_HEADER_MODIFY) {
 		DR_LOG(ERR, "Pattern length %d exceeds limit %d",
@@ -551,9 +553,19 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,
 	/* Pattern_length is in ddwords */
 	MLX5_SET(header_modify_pattern_in, pattern, pattern_length, pattern_length / (2 * DW_SIZE));
 
-	pattern_data = MLX5_ADDR_OF(header_modify_pattern_in, pattern, pattern_data);
+	pattern_data = (uint64_t *)MLX5_ADDR_OF(header_modify_pattern_in, pattern, pattern_data);
 	memcpy(pattern_data, actions, pattern_length);
 
+	num_of_actions = pattern_length / MLX5DR_MODIFY_ACTION_SIZE;
+	for (i = 0; i < num_of_actions; i++) {
+		int type;
+
+		type = MLX5_GET(set_action_in, &pattern_data[i], action_type);
+		if (type != MLX5_MODIFICATION_TYPE_COPY)
+			/* Action typ-copy use all bytes for control */
+			MLX5_SET(set_action_in, &pattern_data[i], data, 0);
+	}
+
 	devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out));
 	if (!devx_obj->obj) {
 		DR_LOG(ERR, "Failed to create header_modify_pattern");
-- 
2.18.2


             reply	other threads:[~2023-03-20 14:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 14:53 Erez Shitrit [this message]
2023-03-20 14:53 ` [PATCH 2/4] net/mlx5/hws: shared context uses defaults from local context Erez Shitrit
2023-03-20 14:53 ` [PATCH 3/4] net/mlx5/hws: keep all jumbo tag for deletion Erez Shitrit
2023-03-20 14:53 ` [PATCH 4/4] net/mlx5/hws: add check for modify-header actions Erez Shitrit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230320145343.449023-1-erezsh@nvidia.com \
    --to=erezsh@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=valex@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).