[2/2] net/mlx5: fix ASO age null context issue

Message ID 20210512115239.12783-3-jiaweiw@nvidia.com (mailing list archive)
State Superseded, archived
Headers
Series [v2,1/2] net/mlx5: fix age action in transfer root group |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jiawei Wang May 12, 2021, 11:52 a.m. UTC
  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(-)
  

Patch

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);