[v1] net/mlx5: fix meter policy creation assert

Message ID 20220302103302.10940-1-shunh@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v1] net/mlx5: fix meter policy creation assert |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Shun Hao March 2, 2022, 10:33 a.m. UTC
  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(-)
  

Comments

Raslan Darawsheh March 7, 2022, 10:36 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Shun Hao <shunh@nvidia.com>
> Sent: Wednesday, March 2, 2022 12:33 PM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; orika@nvidia.com ; thomas@monjalon.net ; Raja
> Zidane <rzidane@nvidia.com>
> Cc: dev@dpdk.org ; Raslan Darawsheh <rasland@nvidia.com>;
> stable@dpdk.org
> Subject: [PATCH v1] net/mlx5: fix meter policy creation assert
> 
> 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>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

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;