DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawei Wang <jiaweiw@nvidia.com>
To: <viacheslavo@nvidia.com>, <matan@nvidia.com>,
	Dekel Peled <dekelp@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [PATCH 2/2] net/mlx5: fix mirror flow validation with ASO action
Date: Wed, 2 Nov 2022 15:44:14 +0200	[thread overview]
Message-ID: <20221102134414.13573-3-jiaweiw@nvidia.com> (raw)
In-Reply-To: <20221102134414.13573-1-jiaweiw@nvidia.com>

While the ASO action(AGE, CT) with the sample action in the one
E-switch mirror flow, due to hardware limitation, the ASO action
after the sample action was not supported.

This patch adds the checking for this validation and reject the flows
with aso action after sample.

Fixes: f935ed4b645a ("net/mlx5: support flow hit action for aging")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 53 ++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index a2b85207b1..eabedfac17 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5759,8 +5759,8 @@ flow_dv_modify_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry)
  *   Pointer to the RSS action in sample action list.
  * @param[out] count
  *   Pointer to the COUNT action in sample action list.
- * @param[out] fdb_mirror_limit
- *   Pointer to the FDB mirror limitation flag.
+ * @param[out] fdb_mirror
+ *   Pointer to the FDB mirror flag.
  * @param root
  *   Whether action is on root table.
  * @param[out] error
@@ -5778,9 +5778,8 @@ flow_dv_validate_action_sample(uint64_t *action_flags,
 			       const struct rte_flow_action_rss *rss,
 			       const struct rte_flow_action_rss **sample_rss,
 			       const struct rte_flow_action_count **count,
-			       int *fdb_mirror_limit,
+			       int *fdb_mirror,
 			       bool root,
-			       struct mlx5_priv *act_priv,
 			       struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
@@ -5968,9 +5967,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags,
 						  NULL,
 						  "E-Switch must has a dest "
 						  "port for mirroring");
-		if (!priv->sh->cdev->config.hca_attr.reg_c_preserve &&
-		     flow_source_vport_representor(priv, act_priv))
-			*fdb_mirror_limit = 1;
+		*fdb_mirror = 1;
 	}
 	/* Continue validation for Xcap actions.*/
 	if ((sub_action_flags & MLX5_FLOW_XCAP_ACTIONS) &&
@@ -7056,7 +7053,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	uint16_t ether_type = 0;
 	int actions_n = 0;
 	uint8_t item_ipv6_proto = 0;
-	int fdb_mirror_limit = 0;
+	int fdb_mirror = 0;
 	int modify_after_mirror = 0;
 	const struct rte_flow_item *geneve_item = NULL;
 	const struct rte_flow_item *gre_item = NULL;
@@ -7122,6 +7119,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	const struct rte_flow_action_age *non_shared_age = NULL;
 	const struct rte_flow_action_count *count = NULL;
 	struct mlx5_priv *act_priv = NULL;
+	int aso_after_sample = 0;
 
 	if (items == NULL)
 		return -1;
@@ -7902,12 +7900,6 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 							   error);
 			if (ret)
 				return ret;
-			if ((action_flags & MLX5_FLOW_ACTION_SAMPLE) &&
-			    fdb_mirror_limit)
-				return rte_flow_error_set(error, EINVAL,
-						  RTE_FLOW_ERROR_TYPE_ACTION,
-						  NULL,
-						  "sample and jump action combination is not supported");
 			++actions_n;
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
@@ -7987,6 +7979,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 						   RTE_FLOW_ERROR_TYPE_ACTION,
 						   NULL,
 						   "duplicate age actions set");
+			if (action_flags & MLX5_FLOW_ACTION_SAMPLE)
+				aso_after_sample = 1;
 			action_flags |= MLX5_FLOW_ACTION_AGE;
 			++actions_n;
 			break;
@@ -8014,6 +8008,9 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 						RTE_FLOW_ERROR_TYPE_ACTION,
 						NULL,
 						"old age action and count must be in the same sub flow");
+			} else {
+				if (action_flags & MLX5_FLOW_ACTION_SAMPLE)
+					aso_after_sample = 1;
 			}
 			action_flags |= MLX5_FLOW_ACTION_AGE;
 			++actions_n;
@@ -8056,9 +8053,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 							     attr, item_flags,
 							     rss, &sample_rss,
 							     &sample_count,
-							     &fdb_mirror_limit,
+							     &fdb_mirror,
 							     is_root,
-							     act_priv,
 							     error);
 			if (ret < 0)
 				return ret;
@@ -8093,6 +8089,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 							     is_root, error);
 			if (ret < 0)
 				return ret;
+			if (action_flags & MLX5_FLOW_ACTION_SAMPLE)
+				aso_after_sample = 1;
 			action_flags |= MLX5_FLOW_ACTION_CT;
 			break;
 		case MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET:
@@ -8350,11 +8348,24 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 					  NULL, "too many header modify"
 					  " actions to support");
 	}
-	/* Eswitch egress mirror and modify flow has limitation on CX5 */
-	if (fdb_mirror_limit && modify_after_mirror)
-		return rte_flow_error_set(error, EINVAL,
-				RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-				"sample before modify action is not supported");
+	if (fdb_mirror) {
+		if (!priv->sh->cdev->config.hca_attr.reg_c_preserve &&
+		    flow_source_vport_representor(priv, act_priv)) {
+			/* Eswitch egress mirror and modify flow has limitation on CX5 */
+			if (modify_after_mirror)
+				return rte_flow_error_set(error, EINVAL,
+						RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+						"sample before modify action is not supported");
+			if (action_flags & MLX5_FLOW_ACTION_JUMP)
+				return rte_flow_error_set(error, EINVAL,
+							RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+							"sample and jump action combination is not supported");
+		}
+		if (aso_mask > 0 && aso_after_sample && fdb_mirror)
+			return rte_flow_error_set(error, ENOTSUP,
+						  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+						  "sample before ASO action is not supported");
+	}
 	/*
 	 * Validation the NIC Egress flow on representor, except implicit
 	 * hairpin default egress flow with TX_QUEUE item, other flows not
-- 
2.18.1


  parent reply	other threads:[~2022-11-02 13:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 13:44 [PATCH 0/2] net/mlx5: fix some sample/mirror issues Jiawei Wang
2022-11-02 13:44 ` [PATCH 1/2] net/mlx5: fix flow source port checking in sample flow rule Jiawei Wang
2022-11-02 13:44 ` Jiawei Wang [this message]
2022-11-03 11:41 ` [PATCH 0/2] net/mlx5: fix some sample/mirror issues 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=20221102134414.13573-3-jiaweiw@nvidia.com \
    --to=jiaweiw@nvidia.com \
    --cc=dekelp@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --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).