patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Jiawei Wang <jiaweiw@nvidia.com>
To: <viacheslavo@nvidia.com>, <matan@nvidia.com>, <orika@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [PATCH] net/mlx5: fix the sample flow failure on the trusted device
Date: Wed, 9 Mar 2022 12:19:46 +0200	[thread overview]
Message-ID: <20220309101946.9086-1-jiaweiw@nvidia.com> (raw)

The flow with sample action will be split into two sub flows,
and a tag action was added implicitly in the sample prefix sub flow,
the reserved metadata regC index was used for this tag action.

The reserved metadata regC was shared with metering action,
for Connect-5 trusted device(VF/SF), the reserved metadata regC was
invalid since PF only supported the legacy metering.

This patch adds the checking for the tag index and back to use the
application tag if a failure happened.

Fixes: a9b6ea45bed6 ("net/mlx5: fix tag ID conflict with sample action")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 doc/guides/nics/mlx5.rst        |  2 ++
 drivers/net/mlx5/mlx5_flow.c    |  6 ++++++
 drivers/net/mlx5/mlx5_flow_dv.c | 10 ++++++++++
 3 files changed, 18 insertions(+)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index a734d10d3f..ca7ebbe9cd 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -400,6 +400,8 @@ Limitations
     sample actions list.
   - For E-Switch mirroring flow, supports ``RAW ENCAP``, ``Port ID``,
     ``VXLAN ENCAP``, ``NVGRE ENCAP`` in the sample actions list.
+  - For ConnectX-5 trusted device, the application metadata with SET_TAG index 0
+    is not supported before ``RTE_FLOW_ACTION_TYPE_SAMPLE`` action.
 
 - Modify Field flow:
 
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index ffcaef0baa..e2bc6ce8ad 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -5881,6 +5881,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev,
 		append_index++;
 		set_tag = (void *)(actions_pre + actions_n + append_index);
 		ret = mlx5_flow_get_reg_id(dev, MLX5_SAMPLE_ID, 0, error);
+		/* Trust VF/SF on CX5 not supported meter so that the reserved
+		 * metadata regC is REG_NON, back to use application tag
+		 * index 0.
+		 */
+		if (unlikely(ret == REG_NON))
+			ret = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, 0, error);
 		if (ret < 0)
 			return ret;
 		mlx5_ipool_malloc(priv->sh->ipool
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 29751e7eda..ac21676416 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6931,6 +6931,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	bool def_policy = false;
 	bool shared_count = false;
 	uint16_t udp_dport = 0;
+	uint32_t tag_id = 0;
 
 	if (items == NULL)
 		return -1;
@@ -7407,6 +7408,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 				++actions_n;
 			if (action_flags & MLX5_FLOW_ACTION_SAMPLE)
 				modify_after_mirror = 1;
+			tag_id = ((const struct rte_flow_action_set_tag *)
+				  actions->conf)->index;
 			action_flags |= MLX5_FLOW_ACTION_SET_TAG;
 			rw_act_num += MLX5_ACT_NUM_SET_TAG;
 			break;
@@ -7841,6 +7844,13 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 							     error);
 			if (ret < 0)
 				return ret;
+			if ((action_flags & MLX5_FLOW_ACTION_SET_TAG) &&
+			    tag_id == 0 && priv->mtr_color_reg == REG_NON)
+				return rte_flow_error_set
+					(error, EINVAL,
+					RTE_FLOW_ERROR_TYPE_ACTION,
+					NULL,
+					"Sample after Tag action cause metadata tag index 0 corruption");
 			action_flags |= MLX5_FLOW_ACTION_SAMPLE;
 			++actions_n;
 			break;
-- 
2.18.1


             reply	other threads:[~2022-03-09 10:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 10:19 Jiawei Wang [this message]
2022-03-10  9:20 ` 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=20220309101946.9086-1-jiaweiw@nvidia.com \
    --to=jiaweiw@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@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).