DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shun Hao <shunh@nvidia.com>
To: <matan@nvidia.com>, <viacheslavo@nvidia.com>,
	<orika@nvidia.com   >, <thomas@monjalon.net >,
	Raja Zidane <rzidane@nvidia.com>
Cc: <dev@dpdk.org  >, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [PATCH v1] net/mlx5: fix meter policy creation assert
Date: Wed, 2 Mar 2022 12:33:01 +0200	[thread overview]
Message-ID: <20220302103302.10940-1-shunh@nvidia.com> (raw)

The meter policy creation doesn't belong to RTE flow creation
process, so thread workspace was not initialized and there will be
assert error when using it.

This patch removes the incorrect using of thread workspace in meter
policy creation, and adds a flag in policy instead. When creating
RTE flow, can use the flag to set the mark flag in thread workspace.

Fixes: 082becbf1f35 ("net/mlx5: fix mark enabling for Rx")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5.h         | 2 ++
 drivers/net/mlx5/mlx5_flow.c    | 2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 6 +++---
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 0f0045a2b5..b6405c0254 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -779,6 +779,8 @@ struct mlx5_flow_meter_policy {
 	/* If yellow color policy is skipped. */
 	uint32_t skip_g:1;
 	/* If green color policy is skipped. */
+	uint32_t mark:1;
+	/* If policy contains mark action. */
 	rte_spinlock_t sl;
 	uint32_t ref_cnt;
 	/* Use count. */
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index a690e2d337..2c7dcdd468 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -6287,6 +6287,8 @@ flow_create_split_meter(struct rte_eth_dev *dev,
 								  fm->policy_id,
 								  NULL);
 			MLX5_ASSERT(wks->policy);
+			if (wks->policy->mark)
+				wks->mark = 1;
 			if (wks->policy->is_hierarchy) {
 				wks->final_policy =
 				mlx5_flow_meter_hierarchy_get_final_policy(dev,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ae88a1cc29..c57f48fca7 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -15524,9 +15524,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
 			    (MLX5_MAX_MODIFY_NUM + 1)];
 	} mhdr_dummy;
 	struct mlx5_flow_dv_modify_hdr_resource *mhdr_res = &mhdr_dummy.res;
-	struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace();
 
-	MLX5_ASSERT(wks);
 	egress = (domain == MLX5_MTR_DOMAIN_EGRESS) ? 1 : 0;
 	transfer = (domain == MLX5_MTR_DOMAIN_TRANSFER) ? 1 : 0;
 	memset(&dh, 0, sizeof(struct mlx5_flow_handle));
@@ -15564,7 +15562,6 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
 					  NULL,
 					  "cannot create policy "
 					  "mark action for this color");
-				wks->mark = 1;
 				if (flow_dv_tag_resource_register(dev, tag_be,
 						  &dev_flow, &flow_err))
 					return -rte_mtr_error_set(error,
@@ -15576,6 +15573,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
 				act_cnt->rix_mark =
 					dev_flow.handle->dvh.rix_tag;
 				action_flags |= MLX5_FLOW_ACTION_MARK;
+				mtr_policy->mark = 1;
 				break;
 			}
 			case RTE_FLOW_ACTION_TYPE_SET_TAG:
@@ -15859,6 +15857,8 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,
 				act_cnt->next_sub_policy = NULL;
 				mtr_policy->is_hierarchy = 1;
 				mtr_policy->dev = next_policy->dev;
+				if (next_policy->mark)
+					mtr_policy->mark = 1;
 				action_flags |=
 				MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY;
 				break;
-- 
2.20.0


             reply	other threads:[~2022-03-02 10:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 10:33 Shun Hao [this message]
2022-03-07 10:36 ` Raslan Darawsheh

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=20220302103302.10940-1-shunh@nvidia.com \
    --to=shunh@nvidia.com \
    --cc=dev@dpdk.org   \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com    \
    --cc=rasland@nvidia.com \
    --cc=rzidane@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net  \
    --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).