patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Bing Zhao <bingz@nvidia.com>
To: <viacheslavo@nvidia.com>, <matan@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <lizh@nvidia.com>,
	<stable@dpdk.org>
Subject: [PATCH] net/mlx5: fix missing RSS validation with meter policy
Date: Mon, 15 Nov 2021 13:35:18 +0200	[thread overview]
Message-ID: <20211115113518.1654183-1-bingz@nvidia.com> (raw)

The RSS can be one of the fate actions when creating a meter with
policy. In the previous implementation, the RSS validation was missed
when creating a flow rule with such meter due to the fact that a
policy meter was created firstly and then used in the rule. In the
stage of meter creation, no rte_flow_item* information was provided.

A unnecessary RSS expansion might be called since the validation was
missed and would cause an unexpected error of the rule creation. Even
though the rule should be rejected from the very beginning, it would
cause confusion. There might be some other errors when the validation
was missed.

Adding the RSS validation inside the meter action validation will
prevent the code from continuing when there is a conflict between the
items, other actions and the policy meter RSS action.

Fixes: 444320186393 ("net/mlx5: support meter creation with policy")
Cc: lizh@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 287a17d956..da975e0351 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5133,6 +5133,8 @@ flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev __rte_unused,
  *   Pointer to rte_eth_dev structure.
  * @param[in] action_flags
  *   Bit-fields that holds the actions detected until now.
+ * @param[in] item_flags
+ *   Holds the items detected.
  * @param[in] action
  *   Pointer to the meter action.
  * @param[in] attr
@@ -5147,7 +5149,7 @@ flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev __rte_unused,
  */
 static int
 mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
-				uint64_t action_flags,
+				uint64_t action_flags, uint64_t item_flags,
 				const struct rte_flow_action *action,
 				const struct rte_flow_attr *attr,
 				const struct rte_flow_item *port_id_item,
@@ -5251,6 +5253,27 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,
 						NULL,
 						"Flow and meter policy "
 						"have different src port.");
+		} else if (mtr_policy->is_rss) {
+			struct mlx5_meter_policy_action_container *acg =
+				&mtr_policy->act_cnt[RTE_COLOR_GREEN];
+			struct mlx5_meter_policy_action_container *acy =
+				&mtr_policy->act_cnt[RTE_COLOR_YELLOW];
+			const struct rte_flow_action *rss_act;
+			int ret;
+
+			MLX5_ASSERT(acg->fate_action ==
+				    MLX5_FLOW_FATE_SHARED_RSS ||
+				    acy->fate_action ==
+				    MLX5_FLOW_FATE_SHARED_RSS);
+			if (acg->fate_action == MLX5_FLOW_FATE_SHARED_RSS)
+				rss_act = acg->rss;
+			else rss_act = acy->rss;
+
+			ret = mlx5_flow_validate_action_rss(rss_act,
+					action_flags, dev, attr,
+					item_flags, error);
+			if (ret)
+				return ret;
 		}
 		*def_policy = false;
 	}
@@ -7684,6 +7707,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 		case RTE_FLOW_ACTION_TYPE_METER:
 			ret = mlx5_flow_validate_action_meter(dev,
 							      action_flags,
+							      item_flags,
 							      actions, attr,
 							      port_id_item,
 							      &def_policy,
-- 
2.21.0


             reply	other threads:[~2021-11-15 11:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 11:35 Bing Zhao [this message]
2021-11-15 14:51 ` [PATCH v2] " Bing Zhao
2021-11-16  9:25   ` 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=20211115113518.1654183-1-bingz@nvidia.com \
    --to=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=lizh@nvidia.com \
    --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).