patch 'net/mlx5: fix drop action attribute validation' has been queued to stable release 22.11.3

Xueming Li xuemingl at nvidia.com
Sun Jun 25 08:35:10 CEST 2023


Hi,

FYI, your patch has been queued to stable release 22.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/27/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=255fcff79e8b8cefdbce7b12f0ff27fb7f9767bb

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 255fcff79e8b8cefdbce7b12f0ff27fb7f9767bb Mon Sep 17 00:00:00 2001
From: Dariusz Sosnowski <dsosnowski at nvidia.com>
Date: Wed, 17 May 2023 20:36:14 +0000
Subject: [PATCH] net/mlx5: fix drop action attribute validation
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit c1f0cdae14c5399cd6201e6cf39d5e51f60c6efb ]

Before this patch, DROP flow action was rejected for all egress
flow rules, which was not correct for all cases.

When Verbs flow engine is used (dv_flow_en=0) DROP flow action
is implemented using IBV_FLOW_SPEC_ACTION_DROP IBV action.
This action is supported on ingress only.
This patch amends the DROP flow action validation to allow it only on
ingress.

When DV flow engine is used (dv_flow_en=1) there are 2 implementation
options for DROP flow action:

- DR drop action (allocated through mlx5dv_dr_action_create_drop() API),
- dedicated drop queue.

When flow rules are created on non-root flow tables DR drop action can
be used on all steering domains. On root flow table however, this action
ca be used if and only if it is supported by rdma-core and kernel
drivers. mlx5 PMD dynamically checks if DR drop action is supported
on root tables during device probing
(it is checked in mlx5_flow_discover_dr_action_support()).
If DR drop action is not supported on root table, then dedicated
drop queue must be used and as a result, DROP flow action on root
is supported only for ingress flow rules.
This patch amends the DROP flow action validation with this logic
for DV flow engine.

This patch also renames the dr_drop_action_en field in device's private
data to dr_root_drop_action_en to align the name with field's meaning.

Fixes: 3c4338a42134 ("net/mlx5: optimize device spawn time with representors")
Fixes: 45633c460c22 ("net/mlx5: workaround drop action with old kernel")
Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs")

Signed-off-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c   |  4 ++--
 drivers/net/mlx5/mlx5.h            |  2 +-
 drivers/net/mlx5/mlx5_flow.c       | 20 ++++++++++++++++----
 drivers/net/mlx5/mlx5_flow.h       |  3 ++-
 drivers/net/mlx5/mlx5_flow_dv.c    |  4 ++--
 drivers/net/mlx5/mlx5_flow_verbs.c |  7 ++++---
 6 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 2cce0a7f0f..6fdade7dab 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -873,10 +873,10 @@ mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused)
 	 */
 	if (!priv->sh->drop_action_check_flag) {
 		if (!mlx5_flow_discover_dr_action_support(dev))
-			priv->sh->dr_drop_action_en = 1;
+			priv->sh->dr_root_drop_action_en = 1;
 		priv->sh->drop_action_check_flag = 1;
 	}
-	if (priv->sh->dr_drop_action_en)
+	if (priv->sh->dr_root_drop_action_en)
 		priv->root_drop_action = priv->sh->dr_drop_action;
 	else
 		priv->root_drop_action = priv->drop_queue.hrxq->action;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 16b33e1548..9f27e1dba4 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1367,7 +1367,7 @@ struct mlx5_dev_ctx_shared {
 	uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */
 	uint32_t tunnel_header_2_3:1; /* tunnel_header_2_3 is supported. */
 	uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */
-	uint32_t dr_drop_action_en:1; /* Use DR drop action. */
+	uint32_t dr_root_drop_action_en:1; /* DR drop action is usable on root tables. */
 	uint32_t drop_action_check_flag:1; /* Check Flag for drop action. */
 	uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */
 	uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 787dd02881..f4487bc136 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1903,8 +1903,10 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
 /*
  * Validate the drop action.
  *
- * @param[in] action_flags
- *   Bit-fields that holds the actions detected until now.
+ * @param[in] dev
+ *   Pointer to the Ethernet device structure.
+ * @param[in] is_root
+ *   True if flow is validated for root table. False otherwise.
  * @param[in] attr
  *   Attributes of flow that includes this action.
  * @param[out] error
@@ -1914,15 +1916,25 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
-mlx5_flow_validate_action_drop(uint64_t action_flags __rte_unused,
+mlx5_flow_validate_action_drop(struct rte_eth_dev *dev,
+			       bool is_root,
 			       const struct rte_flow_attr *attr,
 			       struct rte_flow_error *error)
 {
-	if (attr->egress)
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	if (priv->sh->config.dv_flow_en == 0 && attr->egress)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
 					  "drop action not supported for "
 					  "egress");
+	if (priv->sh->config.dv_flow_en == 1 && is_root && (attr->egress || attr->transfer) &&
+	    !priv->sh->dr_root_drop_action_en) {
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ATTR, NULL,
+					  "drop action not supported for "
+					  "egress and transfer on group 0");
+	}
 	return 0;
 }
 
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 1f57ecd6e1..f4eecbcb0a 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2226,7 +2226,8 @@ int mlx5_validate_action_rss(struct rte_eth_dev *dev,
 int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
 				    const struct rte_flow_attr *attr,
 				    struct rte_flow_error *error);
-int mlx5_flow_validate_action_drop(uint64_t action_flags,
+int mlx5_flow_validate_action_drop(struct rte_eth_dev *dev,
+				   bool is_root,
 				   const struct rte_flow_attr *attr,
 				   struct rte_flow_error *error);
 int mlx5_flow_validate_action_flag(uint64_t action_flags,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3d252f736b..22058ed980 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7579,7 +7579,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 			rw_act_num += MLX5_ACT_NUM_SET_TAG;
 			break;
 		case RTE_FLOW_ACTION_TYPE_DROP:
-			ret = mlx5_flow_validate_action_drop(action_flags,
+			ret = mlx5_flow_validate_action_drop(dev, is_root,
 							     attr, error);
 			if (ret < 0)
 				return ret;
@@ -18916,7 +18916,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
 				break;
 			case RTE_FLOW_ACTION_TYPE_DROP:
 				ret = mlx5_flow_validate_action_drop
-					(action_flags[i], attr, &flow_err);
+					(dev, false, attr, &flow_err);
 				if (ret < 0)
 					return -rte_mtr_error_set(error,
 					ENOTSUP,
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 28ea28bfbe..1e9c7cf7c5 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -1280,14 +1280,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,
 	uint16_t ether_type = 0;
 	bool is_empty_vlan = false;
 	uint16_t udp_dport = 0;
-	bool is_root;
+	/* Verbs interface does not support groups higher than 0. */
+	bool is_root = true;
 
 	if (items == NULL)
 		return -1;
 	ret = flow_verbs_validate_attributes(dev, attr, error);
 	if (ret < 0)
 		return ret;
-	is_root = ret;
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
 		int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
 		int ret = 0;
@@ -1484,7 +1484,8 @@ flow_verbs_validate(struct rte_eth_dev *dev,
 			action_flags |= MLX5_FLOW_ACTION_MARK;
 			break;
 		case RTE_FLOW_ACTION_TYPE_DROP:
-			ret = mlx5_flow_validate_action_drop(action_flags,
+			ret = mlx5_flow_validate_action_drop(dev,
+							     is_root,
 							     attr,
 							     error);
 			if (ret < 0)
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-06-25 14:32:00.984356100 +0800
+++ 0092-net-mlx5-fix-drop-action-attribute-validation.patch	2023-06-25 14:31:58.535773900 +0800
@@ -1 +1 @@
-From c1f0cdae14c5399cd6201e6cf39d5e51f60c6efb Mon Sep 17 00:00:00 2001
+From 255fcff79e8b8cefdbce7b12f0ff27fb7f9767bb Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit c1f0cdae14c5399cd6201e6cf39d5e51f60c6efb ]
@@ -39 +41,0 @@
-Cc: stable at dpdk.org
@@ -53 +55 @@
-index 980234e2ac..d8f1adfe3d 100644
+index 2cce0a7f0f..6fdade7dab 100644
@@ -56 +58 @@
-@@ -876,10 +876,10 @@ mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused)
+@@ -873,10 +873,10 @@ mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused)
@@ -70 +72 @@
-index 04febd3282..021049ad2b 100644
+index 16b33e1548..9f27e1dba4 100644
@@ -73 +75 @@
-@@ -1387,7 +1387,7 @@ struct mlx5_dev_ctx_shared {
+@@ -1367,7 +1367,7 @@ struct mlx5_dev_ctx_shared {
@@ -83 +85 @@
-index 8c76f1fa10..eb1d7a6be2 100644
+index 787dd02881..f4487bc136 100644
@@ -86 +88 @@
-@@ -1941,8 +1941,10 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
+@@ -1903,8 +1903,10 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
@@ -99 +101 @@
-@@ -1952,15 +1954,25 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
+@@ -1914,15 +1916,25 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
@@ -128 +130 @@
-index ff397a2a3b..02e33c7fb3 100644
+index 1f57ecd6e1..f4eecbcb0a 100644
@@ -131 +133 @@
-@@ -2290,7 +2290,8 @@ int mlx5_validate_action_rss(struct rte_eth_dev *dev,
+@@ -2226,7 +2226,8 @@ int mlx5_validate_action_rss(struct rte_eth_dev *dev,
@@ -142 +144 @@
-index 27e8b3a5a9..7535500870 100644
+index 3d252f736b..22058ed980 100644
@@ -145 +147 @@
-@@ -7826,7 +7826,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+@@ -7579,7 +7579,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
@@ -154 +156 @@
-@@ -19248,7 +19248,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
+@@ -18916,7 +18916,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
@@ -164 +166 @@
-index b363fb4ad3..fe9c818abc 100644
+index 28ea28bfbe..1e9c7cf7c5 100644
@@ -167 +169 @@
-@@ -1317,14 +1317,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,
+@@ -1280,14 +1280,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,
@@ -184 +186 @@
-@@ -1531,7 +1531,8 @@ flow_verbs_validate(struct rte_eth_dev *dev,
+@@ -1484,7 +1484,8 @@ flow_verbs_validate(struct rte_eth_dev *dev,


More information about the stable mailing list