DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
	Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>,
	Gregory Etelson <getelson@nvidia.com>
Cc: <dev@dpdk.org>, Raslan Darawsheh <rasland@nvidia.com>
Subject: [PATCH 3/3] net/mlx5: fix RSS and queue action validation
Date: Thu, 18 Jul 2024 11:57:17 +0200	[thread overview]
Message-ID: <20240718095717.290960-4-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20240718095717.290960-1-dsosnowski@nvidia.com>

mlx5 PMD supports configuration where
Rx queues managed by DPDK are not set up.
Externally allocated RQs can be used by mapping them to some
DPDK Rx queue indexes using rte_pmd_mlx5_external_rx_queue_id_map()
API. In this case, mlx5 PMD will allow creating flow rules which
reference such external RQ.

HWS validation of RSS and QUEUE unmasked flow actions in actions
templates worked by constructing a "mock" action which was then checked.
This procedure incorrectly assumed that queue index 0 can be used as
"always valid queue", which is not the case in scenario mentioned above,
because queue 0 was not set up

This patch fixes that by removing "mock" actions, since there's no real
data available for validation. RSS and QUEUE validation in unmasked
action case only checks flow attributes.

Fixes: d6dc072aeb12 ("net/mlx5: validate flow actions in table creation")

Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 37 +++++++++++++--------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 39d1cd96d4..d243b59b71 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -6806,8 +6806,6 @@ mlx5_hw_validate_action_mark(struct rte_eth_dev *dev,
 					      &attr, error);
 }
 
-#define MLX5_FLOW_DEFAULT_INGRESS_QUEUE 0
-
 static int
 mlx5_hw_validate_action_queue(struct rte_eth_dev *dev,
 			      const struct rte_flow_action *template_action,
@@ -6817,22 +6815,22 @@ mlx5_hw_validate_action_queue(struct rte_eth_dev *dev,
 			      struct rte_flow_error *error)
 {
 	const struct rte_flow_action_queue *queue_mask = template_mask->conf;
-	const struct rte_flow_action *action =
-		queue_mask && queue_mask->index ? template_action :
-		&(const struct rte_flow_action) {
-		.type = RTE_FLOW_ACTION_TYPE_QUEUE,
-		.conf = &(const struct rte_flow_action_queue) {
-			.index = MLX5_FLOW_DEFAULT_INGRESS_QUEUE
-		}
-	};
 	const struct rte_flow_attr attr = {
 		.ingress = template_attr->ingress,
 		.egress = template_attr->egress,
 		.transfer = template_attr->transfer
 	};
+	bool masked = queue_mask != NULL && queue_mask->index;
 
-	return mlx5_flow_validate_action_queue(action, action_flags,
-					       dev, &attr, error);
+	if (template_attr->egress || template_attr->transfer)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ATTR, NULL,
+					  "QUEUE action supported for ingress only");
+	if (masked)
+		return mlx5_flow_validate_action_queue(template_action, action_flags, dev,
+						       &attr, error);
+	else
+		return 0;
 }
 
 static int
@@ -6844,22 +6842,15 @@ mlx5_hw_validate_action_rss(struct rte_eth_dev *dev,
 			      struct rte_flow_error *error)
 {
 	const struct rte_flow_action_rss *mask = template_mask->conf;
-	const struct rte_flow_action *action = mask ? template_action :
-		&(const struct rte_flow_action) {
-		.type = RTE_FLOW_ACTION_TYPE_RSS,
-		.conf = &(const struct rte_flow_action_rss) {
-			.queue_num = 1,
-			.queue = (uint16_t [1]) {
-				MLX5_FLOW_DEFAULT_INGRESS_QUEUE
-			}
-		}
-	};
 
 	if (template_attr->egress || template_attr->transfer)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ATTR, NULL,
 					  "RSS action supported for ingress only");
-	return mlx5_validate_action_rss(dev, action, error);
+	if (mask != NULL)
+		return mlx5_validate_action_rss(dev, template_action, error);
+	else
+		return 0;
 }
 
 static int
-- 
2.39.2


  parent reply	other threads:[~2024-07-18  9:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-18  9:57 [PATCH 0/3] net/mlx5: E-Switch and validation fixes Dariusz Sosnowski
2024-07-18  9:57 ` [PATCH 1/3] net/mlx5: fix disabling E-Switch default flow rules Dariusz Sosnowski
2024-07-18  9:57 ` [PATCH 2/3] net/mlx5: fix action configuration validation Dariusz Sosnowski
2024-07-18  9:57 ` Dariusz Sosnowski [this message]
2024-07-21 13:58 ` [PATCH 0/3] net/mlx5: E-Switch and validation fixes 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=20240718095717.290960-4-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=getelson@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --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).