Skip to contentSkip to conversation

net/mlx5: fix the checking for age action

PATCH New Jiawei Wang 2 participants 9 messages May 11, 2021 – May 12, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net/mlx5: fix the checking for age action

Current the ASO age action was supported in the non-root table, and the counter based age action was be used in the root table.

The FDB table skips group 0 on MLX5 PMD by adding implicit rule that jump to non-root table, but PMD code use the original group value for checking.

This patch uses the actual group value for age action checking,

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +16 -8
index 70e8d0b113..8eddd850f2 100644
@@ -12252,12 +12252,16 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				MLX5_FLOW_FATE_QUEUE;
 			break;
 		case MLX5_RTE_FLOW_ACTION_TYPE_AGE:
-			flow->age = (uint32_t)(uintptr_t)(action->conf);
-			age_act = flow_aso_age_get_by_idx(dev, flow->age);
-			__atomic_fetch_add(&age_act->refcnt, 1,
-					   __ATOMIC_RELAXED);
-			age_act_pos = actions_n++;
-			action_flags |= MLX5_FLOW_ACTION_AGE;
+			if (priv->sh->flow_hit_aso_en && (attr->group ||
+			    attr->transfer)) {
+				flow->age = (uint32_t)(uintptr_t)(action->conf);
+				age_act = flow_aso_age_get_by_idx(dev,
+								  flow->age);
+				__atomic_fetch_add(&age_act->refcnt, 1,
+						   __ATOMIC_RELAXED);
+				age_act_pos = actions_n++;
+				action_flags |= MLX5_FLOW_ACTION_AGE;
+			}
 			break;
 		case RTE_FLOW_ACTION_TYPE_AGE:
 			non_shared_age = action->conf;
@@ -12615,7 +12619,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				if ((non_shared_age &&
 				     count && !count->shared) ||
 				    !(priv->sh->flow_hit_aso_en &&
-				      attr->group)) {
+				      dev_flow->dv.group)) {
 					/* Creates age by counters. */
 					cnt_act = flow_dv_prepare_counter
 								(dev, dev_flow,
@@ -12628,7 +12632,9 @@ flow_dv_translate(struct rte_eth_dev *dev,
 								cnt_act->action;
 					break;
 				}
-				if (!flow->age && non_shared_age) {
+				if (!flow->age && non_shared_age &&
+				    priv->sh->flow_hit_aso_en &&
+				    dev_flow->dv.group) {
 					flow->age =
 						flow_dv_translate_create_aso_age
 								(dev,
@@ -12641,6 +12647,8 @@ flow_dv_translate(struct rte_eth_dev *dev,
 						     NULL,
 						     "can't create ASO age action");
 				}
+				if (!flow->age)
+					return -rte_errno;
 				age_act = flow_aso_age_get_by_idx(dev,
 								  flow->age);
 				dev_flow->dv.actions[age_act_pos] =
Signature · 1 line
2.18.1
#1 lore raw

PATCH 2/2 net/mlx5: fix ASO age null context issue

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")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +20 -13
index 8eddd850f2..72a180bc3f 100644
@@ -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);
Signature · 1 line
2.18.1
#2 lore raw

PATCH v2 1/2 net/mlx5: fix age action in transfer root group

In reply to Jiawei Wang

Current the ASO age action was supported in the non-root table, and the counter based age action was be used in the root table.

The FDB table skips group 0 on MLX5 PMD by adding implicit rule that jump to non-root table, but PMD code use the original group value for checking.

This patch adds the transfer checking for ASO age action.

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
index 70e8d0b113..1e6cc8d01f 100644
@@ -12615,7 +12615,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				if ((non_shared_age &&
 				     count && !count->shared) ||
 				    !(priv->sh->flow_hit_aso_en &&
-				      attr->group)) {
+				      (attr->group || attr->transfer))) {
 					/* Creates age by counters. */
 					cnt_act = flow_dv_prepare_counter
 								(dev, dev_flow,
Signature · 1 line
2.18.1
#3 lore raw

PATCH 1/2 net/mlx5: fix the checking for age action

Current the ASO age action was supported in the non-root table, and the counter based age action was be used in the root table.

The FDB table skips group 0 on MLX5 PMD by adding implicit rule that jump to non-root table, but PMD code use the original group value for checking.

This patch uses the actual group value for age action checking,

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +16 -8
index 70e8d0b113..8eddd850f2 100644
@@ -12252,12 +12252,16 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				MLX5_FLOW_FATE_QUEUE;
 			break;
 		case MLX5_RTE_FLOW_ACTION_TYPE_AGE:
-			flow->age = (uint32_t)(uintptr_t)(action->conf);
-			age_act = flow_aso_age_get_by_idx(dev, flow->age);
-			__atomic_fetch_add(&age_act->refcnt, 1,
-					   __ATOMIC_RELAXED);
-			age_act_pos = actions_n++;
-			action_flags |= MLX5_FLOW_ACTION_AGE;
+			if (priv->sh->flow_hit_aso_en && (attr->group ||
+			    attr->transfer)) {
+				flow->age = (uint32_t)(uintptr_t)(action->conf);
+				age_act = flow_aso_age_get_by_idx(dev,
+								  flow->age);
+				__atomic_fetch_add(&age_act->refcnt, 1,
+						   __ATOMIC_RELAXED);
+				age_act_pos = actions_n++;
+				action_flags |= MLX5_FLOW_ACTION_AGE;
+			}
 			break;
 		case RTE_FLOW_ACTION_TYPE_AGE:
 			non_shared_age = action->conf;
@@ -12615,7 +12619,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				if ((non_shared_age &&
 				     count && !count->shared) ||
 				    !(priv->sh->flow_hit_aso_en &&
-				      attr->group)) {
+				      dev_flow->dv.group)) {
 					/* Creates age by counters. */
 					cnt_act = flow_dv_prepare_counter
 								(dev, dev_flow,
@@ -12628,7 +12632,9 @@ flow_dv_translate(struct rte_eth_dev *dev,
 								cnt_act->action;
 					break;
 				}
-				if (!flow->age && non_shared_age) {
+				if (!flow->age && non_shared_age &&
+				    priv->sh->flow_hit_aso_en &&
+				    dev_flow->dv.group) {
 					flow->age =
 						flow_dv_translate_create_aso_age
 								(dev,
@@ -12641,6 +12647,8 @@ flow_dv_translate(struct rte_eth_dev *dev,
 						     NULL,
 						     "can't create ASO age action");
 				}
+				if (!flow->age)
+					return -rte_errno;
 				age_act = flow_aso_age_get_by_idx(dev,
 								  flow->age);
 				dev_flow->dv.actions[age_act_pos] =
Signature · 1 line
2.18.1
#4 lore raw

PATCH 2/2 net/mlx5: fix ASO age null context issue

In reply to Jiawei Wang

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")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +20 -13
index 8eddd850f2..72a180bc3f 100644
@@ -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);
Signature · 1 line
2.18.1
#5 lore raw

PATCH v2 2/2 net/mlx5: fix default context in flow age action

In reply to Jiawei Wang

One of the user parameters for the flow AGE action is the action context. This context should be provided back to the user when the action is aged-out.
While this context is NULL, a default value should be provided by the PMD: the rte_flow pointer in case of rte_flow_create API and the action pointer in case of the rte_flow_action_handle API.

The default for rte_flow_action_handle was set correctly, while in case of rte_flow_create it wrongly remained NULL.

This patch set the default value for rte_flow_create case to be the rte_flow pointer.

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 81 +++++++++++++++++----------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +42 -39
index 1e6cc8d01f..56e6cd3af7 100644
@@ -11492,38 +11492,35 @@ flow_dv_aso_age_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error)
 }
 
 /**
- * Create a age action using ASO mechanism.
+ * Initialize flow ASO age parameters.
  *
  * @param[in] dev
  *   Pointer to rte_eth_dev structure.
- * @param[in] age
- *   Pointer to the aging action configuration.
- * @param[out] error
- *   Pointer to the error structure.
+ * @param[in] age_idx
+ *   Index of ASO age action.
+ * @param[in] context
+ *   Pointer to flow counter age context.
+ * @param[in] timeout
+ *   Aging timeout in seconds.
  *
- * @return
- *   Index to flow counter on success, 0 otherwise.
  */
-static uint32_t
-flow_dv_translate_create_aso_age(struct rte_eth_dev *dev,
-				 const struct rte_flow_action_age *age,
-				 struct rte_flow_error *error)
+static void
+flow_dv_aso_age_params_init(struct rte_eth_dev *dev,
+			    uint32_t age_idx,
+			    void *context,
+			    uint32_t timeout)
 {
-	uint32_t age_idx = 0;
 	struct mlx5_aso_age_action *aso_age;
 
-	age_idx = flow_dv_aso_age_alloc(dev, error);
-	if (!age_idx)
-		return 0;
 	aso_age = flow_aso_age_get_by_idx(dev, age_idx);
-	aso_age->age_params.context = age->context;
-	aso_age->age_params.timeout = age->timeout;
+	MLX5_ASSERT(aso_age);
+	aso_age->age_params.context = context;
+	aso_age->age_params.timeout = timeout;
 	aso_age->age_params.port_id = dev->data->port_id;
 	__atomic_store_n(&aso_age->age_params.sec_since_last_hit, 0,
 			 __ATOMIC_RELAXED);
 	__atomic_store_n(&aso_age->age_params.state, AGE_CANDIDATE,
 			 __ATOMIC_RELAXED);
-	return age_idx;
 }
 
 static void
@@ -12629,17 +12626,17 @@ flow_dv_translate(struct rte_eth_dev *dev,
 					break;
 				}
 				if (!flow->age && non_shared_age) {
-					flow->age =
-						flow_dv_translate_create_aso_age
-								(dev,
-								 non_shared_age,
-								 error);
+					flow->age = flow_dv_aso_age_alloc
+								(dev, error);
 					if (!flow->age)
-						return rte_flow_error_set
-						    (error, rte_errno,
-						     RTE_FLOW_ERROR_TYPE_ACTION,
-						     NULL,
-						     "can't create ASO age action");
+						return -rte_errno;
+					flow_dv_aso_age_params_init
+						    (dev, flow->age,
+						     non_shared_age->context ?
+						     non_shared_age->context :
+						     (void *)(uintptr_t)
+						     (dev_flow->flow_idx),
+						     non_shared_age->timeout);
 				}
 				age_act = flow_aso_age_get_by_idx(dev,
 								  flow->age);
@@ -14201,9 +14198,10 @@ flow_dv_action_create(struct rte_eth_dev *dev,
 		      const struct rte_flow_action *action,
 		      struct rte_flow_error *err)
 {
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t age_idx = 0;
 	uint32_t idx = 0;
 	uint32_t ret = 0;
-	struct mlx5_priv *priv = dev->data->dev_private;
 
 	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_RSS:
@@ -14212,17 +14210,22 @@ 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;
+		age_idx = flow_dv_aso_age_alloc(dev, err);
+		if (!age_idx) {
+			ret = -rte_errno;
+			break;
 		}
+		idx = (MLX5_INDIRECT_ACTION_TYPE_AGE <<
+		       MLX5_INDIRECT_ACTION_TYPE_OFFSET) | age_idx;
+		flow_dv_aso_age_params_init(dev, age_idx,
+					((const struct rte_flow_action_age *)
+						action->conf)->context ?
+					((const struct rte_flow_action_age *)
+						action->conf)->context :
+					(void *)(uintptr_t)idx,
+					((const struct rte_flow_action_age *)
+						action->conf)->timeout);
+		ret = age_idx;
 		break;
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		ret = flow_dv_translate_create_counter(dev, NULL, NULL, NULL);
Signature · 1 line
2.18.1
#6 lore raw

PATCH v3 1/2 net/mlx5: fix age action in transfer root group

In reply to Jiawei Wang

Current the ASO age action was supported in the non-root table, and the counter based age action was be used in the root table.

The FDB table skips group 0 on MLX5 PMD by adding implicit rule that jump to non-root table, but PMD code use the original group value for checking.

This patch adds the transfer checking for ASO age action.

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
index 70e8d0b113..1e6cc8d01f 100644
@@ -12615,7 +12615,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
 				if ((non_shared_age &&
 				     count && !count->shared) ||
 				    !(priv->sh->flow_hit_aso_en &&
-				      attr->group)) {
+				      (attr->group || attr->transfer))) {
 					/* Creates age by counters. */
 					cnt_act = flow_dv_prepare_counter
 								(dev, dev_flow,
Signature · 1 line
2.18.1
#7 lore raw

PATCH v3 2/2 net/mlx5: fix default context in flow age action

One of the user parameters for the flow AGE action is the action context. This context should be provided back to the user when the action is aged-out.
While this context is NULL, a default value should be provided by the PMD: the rte_flow pointer in case of rte_flow_create API and the action pointer in case of the rte_flow_action_handle API.

The default for rte_flow_action_handle was set correctly, while in case of rte_flow_create it wrongly remained NULL.

This patch set the default value for rte_flow_create case to be the rte_flow pointer.

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 81 +++++++++++++++++----------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +42 -39
index 1e6cc8d01f..56e6cd3af7 100644
@@ -11492,38 +11492,35 @@ flow_dv_aso_age_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error)
 }
 
 /**
- * Create a age action using ASO mechanism.
+ * Initialize flow ASO age parameters.
  *
  * @param[in] dev
  *   Pointer to rte_eth_dev structure.
- * @param[in] age
- *   Pointer to the aging action configuration.
- * @param[out] error
- *   Pointer to the error structure.
+ * @param[in] age_idx
+ *   Index of ASO age action.
+ * @param[in] context
+ *   Pointer to flow counter age context.
+ * @param[in] timeout
+ *   Aging timeout in seconds.
  *
- * @return
- *   Index to flow counter on success, 0 otherwise.
  */
-static uint32_t
-flow_dv_translate_create_aso_age(struct rte_eth_dev *dev,
-				 const struct rte_flow_action_age *age,
-				 struct rte_flow_error *error)
+static void
+flow_dv_aso_age_params_init(struct rte_eth_dev *dev,
+			    uint32_t age_idx,
+			    void *context,
+			    uint32_t timeout)
 {
-	uint32_t age_idx = 0;
 	struct mlx5_aso_age_action *aso_age;
 
-	age_idx = flow_dv_aso_age_alloc(dev, error);
-	if (!age_idx)
-		return 0;
 	aso_age = flow_aso_age_get_by_idx(dev, age_idx);
-	aso_age->age_params.context = age->context;
-	aso_age->age_params.timeout = age->timeout;
+	MLX5_ASSERT(aso_age);
+	aso_age->age_params.context = context;
+	aso_age->age_params.timeout = timeout;
 	aso_age->age_params.port_id = dev->data->port_id;
 	__atomic_store_n(&aso_age->age_params.sec_since_last_hit, 0,
 			 __ATOMIC_RELAXED);
 	__atomic_store_n(&aso_age->age_params.state, AGE_CANDIDATE,
 			 __ATOMIC_RELAXED);
-	return age_idx;
 }
 
 static void
@@ -12629,17 +12626,17 @@ flow_dv_translate(struct rte_eth_dev *dev,
 					break;
 				}
 				if (!flow->age && non_shared_age) {
-					flow->age =
-						flow_dv_translate_create_aso_age
-								(dev,
-								 non_shared_age,
-								 error);
+					flow->age = flow_dv_aso_age_alloc
+								(dev, error);
 					if (!flow->age)
-						return rte_flow_error_set
-						    (error, rte_errno,
-						     RTE_FLOW_ERROR_TYPE_ACTION,
-						     NULL,
-						     "can't create ASO age action");
+						return -rte_errno;
+					flow_dv_aso_age_params_init
+						    (dev, flow->age,
+						     non_shared_age->context ?
+						     non_shared_age->context :
+						     (void *)(uintptr_t)
+						     (dev_flow->flow_idx),
+						     non_shared_age->timeout);
 				}
 				age_act = flow_aso_age_get_by_idx(dev,
 								  flow->age);
@@ -14201,9 +14198,10 @@ flow_dv_action_create(struct rte_eth_dev *dev,
 		      const struct rte_flow_action *action,
 		      struct rte_flow_error *err)
 {
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t age_idx = 0;
 	uint32_t idx = 0;
 	uint32_t ret = 0;
-	struct mlx5_priv *priv = dev->data->dev_private;
 
 	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_RSS:
@@ -14212,17 +14210,22 @@ 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;
+		age_idx = flow_dv_aso_age_alloc(dev, err);
+		if (!age_idx) {
+			ret = -rte_errno;
+			break;
 		}
+		idx = (MLX5_INDIRECT_ACTION_TYPE_AGE <<
+		       MLX5_INDIRECT_ACTION_TYPE_OFFSET) | age_idx;
+		flow_dv_aso_age_params_init(dev, age_idx,
+					((const struct rte_flow_action_age *)
+						action->conf)->context ?
+					((const struct rte_flow_action_age *)
+						action->conf)->context :
+					(void *)(uintptr_t)idx,
+					((const struct rte_flow_action_age *)
+						action->conf)->timeout);
+		ret = age_idx;
 		break;
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		ret = flow_dv_translate_create_counter(dev, NULL, NULL, NULL);
Signature · 1 line
2.18.1
#8 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 2/2] net/mlx5: fix default context in flow age action

12/05/2021 14:09, Jiawei Wang:

Quoted 10 lines

One of the user parameters for the flow AGE action is the action context. This context should be provided back to the user when the action is aged-out.
While this context is NULL, a default value should be provided by the PMD: the rte_flow pointer in case of rte_flow_create API and the action pointer in case of the rte_flow_action_handle API.

The default for rte_flow_action_handle was set correctly, while in case of rte_flow_create it wrongly remained NULL.

Quoted 8 lines

This patch set the default value for rte_flow_create case to be the rte_flow pointer.

Fixes f9bc5274a6f9 ("net/mlx5: allow age modes combination")

Series applied in next-net-mlx, thanks