DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawei Wang <jiaweiw@nvidia.com>
To: <matan@nvidia.com>, <viacheslavo@nvidia.com>, <orika@nvidia.com>,
	<jackmin@nvidia.com>, <thomas@monjalon.net>,
	Shahaf Shuler <shahafs@nvidia.com>,
	Dekel Peled <dekelp@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue
Date: Wed, 12 May 2021 14:52:38 +0300	[thread overview]
Message-ID: <20210512115239.12783-3-jiaweiw@nvidia.com> (raw)
In-Reply-To: <20210512115239.12783-1-jiaweiw@nvidia.com>

The flow context in the rte_flow_action_age structure was set by user,
and reported by the MLX5 PMD while calling rte_flow_get_aged_flow API.
If the flow context was NULL while create ASO age action, while flow
aged, the PMD report the NULL context to user.

This patch adds the checking if context is NULL then return rte_flow
pointer to user, otherwise return the original flow context.

Fixes: f9bc5274a6f9 ("net/mlx5: allow age modes combination")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 8eddd850f2..72a180bc3f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -11496,17 +11496,23 @@ flow_dv_aso_age_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error)
  *
  * @param[in] dev
  *   Pointer to rte_eth_dev structure.
+ * @param[in] dev_flow
+ *   Pointer to the sub flow.
  * @param[in] age
  *   Pointer to the aging action configuration.
+ * @param[in] shared_age_offset
+ *   Shared age action offset.
  * @param[out] error
  *   Pointer to the error structure.
  *
  * @return
- *   Index to flow counter on success, 0 otherwise.
+ *   Index to flow ASO age on success, 0 otherwise.
  */
 static uint32_t
 flow_dv_translate_create_aso_age(struct rte_eth_dev *dev,
+				 struct mlx5_flow *dev_flow,
 				 const struct rte_flow_action_age *age,
+				 uint32_t shared_age_offset,
 				 struct rte_flow_error *error)
 {
 	uint32_t age_idx = 0;
@@ -11516,7 +11522,12 @@ flow_dv_translate_create_aso_age(struct rte_eth_dev *dev,
 	if (!age_idx)
 		return 0;
 	aso_age = flow_aso_age_get_by_idx(dev, age_idx);
-	aso_age->age_params.context = age->context;
+	if (shared_age_offset)
+		aso_age->age_params.context =
+			(void *)(uintptr_t)(shared_age_offset | age_idx);
+	else
+		aso_age->age_params.context = age->context ? age->context :
+			(void *)(uintptr_t)(dev_flow->flow_idx);
 	aso_age->age_params.timeout = age->timeout;
 	aso_age->age_params.port_id = dev->data->port_id;
 	__atomic_store_n(&aso_age->age_params.sec_since_last_hit, 0,
@@ -12637,8 +12648,9 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				    dev_flow->dv.group) {
 					flow->age =
 						flow_dv_translate_create_aso_age
-								(dev,
+								(dev, dev_flow,
 								 non_shared_age,
+								 0,
 								 error);
 					if (!flow->age)
 						return rte_flow_error_set
@@ -14220,17 +14232,12 @@ flow_dv_action_create(struct rte_eth_dev *dev,
 		       MLX5_INDIRECT_ACTION_TYPE_OFFSET) | ret;
 		break;
 	case RTE_FLOW_ACTION_TYPE_AGE:
-		ret = flow_dv_translate_create_aso_age(dev, action->conf, err);
 		idx = (MLX5_INDIRECT_ACTION_TYPE_AGE <<
-		       MLX5_INDIRECT_ACTION_TYPE_OFFSET) | ret;
-		if (ret) {
-			struct mlx5_aso_age_action *aso_age =
-					      flow_aso_age_get_by_idx(dev, ret);
-
-			if (!aso_age->age_params.context)
-				aso_age->age_params.context =
-							 (void *)(uintptr_t)idx;
-		}
+		       MLX5_INDIRECT_ACTION_TYPE_OFFSET);
+		ret = flow_dv_translate_create_aso_age(dev, NULL,
+						       action->conf,
+						       idx, err);
+		idx |= ret;
 		break;
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		ret = flow_dv_translate_create_counter(dev, NULL, NULL, NULL);
-- 
2.18.1


  parent reply	other threads:[~2021-05-12 11:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11  4:24 [dpdk-dev] [PATCH 1/2] net/mlx5: fix the checking for age action Jiawei Wang
2021-05-11  4:24 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue Jiawei Wang
2021-05-12 11:52 ` [dpdk-dev] [PATCH v2 1/2] net/mlx5: fix age action in transfer root group Jiawei Wang
2021-05-12 11:52   ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix the checking for age action Jiawei Wang
2021-05-12 11:52   ` Jiawei Wang [this message]
2021-05-12 11:52   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: fix default context in flow " Jiawei Wang
2021-05-12 12:09 ` [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix age action in transfer root group Jiawei Wang
2021-05-12 12:09   ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: fix default context in flow age action Jiawei Wang
2021-05-12 12:41     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon

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=20210512115239.12783-3-jiaweiw@nvidia.com \
    --to=jiaweiw@nvidia.com \
    --cc=dekelp@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=jackmin@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --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).