[v1,2/2] net/mlx5: fix domains detection in meter hierarchy

Message ID 20210804072647.2077832-3-shunh@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Fix Meter Hierarchy related issues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional 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-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/Intel-compilation warning apply issues

Commit Message

Shun Hao Aug. 4, 2021, 7:26 a.m. UTC
  Meters in one hierarchy might support different domains. For
example, one meter may support ingress only, but the root meter
can support all the domains.

If the later meter in the meter hierarchy wrongly doesn't inherit
the first meter's domains, it will lead to invalid domain table
access.

Fix is when creating meter hierarchy, try to inherit the first meter
domains in the meter hierarchy.

Fixes: a3b7af90baba ("net/mlx5: validate meter action in policy")
Cc: stable@dpdk.org

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f54440c6f5..31d857030f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -17527,6 +17527,7 @@  flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev,
 					RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
 					NULL,
 					"Multiple fate actions not supported.");
+	*hierarchy_domain = 0;
 	while (true) {
 		fm = mlx5_flow_meter_find(priv, meter_id, NULL);
 		if (!fm)
@@ -17539,7 +17540,12 @@  flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev,
 			"Non termination meter not supported in hierarchy.");
 		policy = mlx5_flow_meter_policy_find(dev, fm->policy_id, NULL);
 		MLX5_ASSERT(policy);
-		if (!policy->is_hierarchy) {
+		/**
+		 * Only inherit the supported domains of the first meter in
+		 * hierarchy.
+		 * One meter supports at least one domain.
+		 */
+		if (!*hierarchy_domain) {
 			if (policy->transfer)
 				*hierarchy_domain |=
 						MLX5_MTR_DOMAIN_TRANSFER_BIT;
@@ -17548,6 +17554,8 @@  flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev,
 						MLX5_MTR_DOMAIN_INGRESS_BIT;
 			if (policy->egress)
 				*hierarchy_domain |= MLX5_MTR_DOMAIN_EGRESS_BIT;
+		}
+		if (!policy->is_hierarchy) {
 			*is_rss = policy->is_rss;
 			break;
 		}
@@ -17825,11 +17833,11 @@  flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
 			 * so MARK action is only in ingress domain.
 			 */
 			domain_color[i] = MLX5_MTR_DOMAIN_INGRESS_BIT;
-		else if (action_flags[i] &
-			 MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)
-			domain_color[i] = hierarchy_domain;
 		else
 			domain_color[i] = def_domain;
+		if (action_flags[i] &
+		    MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)
+			domain_color[i] &= hierarchy_domain;
 		/*
 		 * Non-termination actions only support NIC Tx domain.
 		 * The adjustion should be skipped when there is no