DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] net/mlx5: fix the checking for age action
@ 2021-05-11  4:24 Jiawei Wang
  2021-05-11  4:24 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue Jiawei Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jiawei Wang @ 2021-05-11  4:24 UTC (permalink / raw)
  To: matan, orika, viacheslavo, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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")
Cc: stable@dpdk.org

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

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 70e8d0b113..8eddd850f2 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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] =
-- 
2.18.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue
  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 ` 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 12:09 ` [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix age action in transfer root group Jiawei Wang
  2 siblings, 0 replies; 9+ messages in thread
From: Jiawei Wang @ 2021-05-11  4:24 UTC (permalink / raw)
  To: matan, orika, viacheslavo, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] net/mlx5: fix age action in transfer root group
  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 ` Jiawei Wang
  2021-05-12 11:52   ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix the checking for age action Jiawei Wang
                     ` (2 more replies)
  2021-05-12 12:09 ` [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix age action in transfer root group Jiawei Wang
  2 siblings, 3 replies; 9+ messages in thread
From: Jiawei Wang @ 2021-05-12 11:52 UTC (permalink / raw)
  To: matan, viacheslavo, orika, jackmin, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 70e8d0b113..1e6cc8d01f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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,
-- 
2.18.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH 1/2] net/mlx5: fix the checking for age action
  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   ` Jiawei Wang
  2021-05-12 11:52   ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue Jiawei Wang
  2021-05-12 11:52   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: fix default context in flow age action Jiawei Wang
  2 siblings, 0 replies; 9+ messages in thread
From: Jiawei Wang @ 2021-05-12 11:52 UTC (permalink / raw)
  To: matan, viacheslavo, orika, jackmin, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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")
Cc: stable@dpdk.org

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

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 70e8d0b113..8eddd850f2 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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] =
-- 
2.18.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue
  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
  2021-05-12 11:52   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: fix default context in flow age action Jiawei Wang
  2 siblings, 0 replies; 9+ messages in thread
From: Jiawei Wang @ 2021-05-12 11:52 UTC (permalink / raw)
  To: matan, viacheslavo, orika, jackmin, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] net/mlx5: fix default context in flow age action
  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   ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue Jiawei Wang
@ 2021-05-12 11:52   ` Jiawei Wang
  2 siblings, 0 replies; 9+ messages in thread
From: Jiawei Wang @ 2021-05-12 11:52 UTC (permalink / raw)
  To: matan, viacheslavo, orika, jackmin, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 81 +++++++++++++++++----------------
 1 file changed, 42 insertions(+), 39 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 1e6cc8d01f..56e6cd3af7 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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);
-- 
2.18.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix age action in transfer root group
  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 12:09 ` Jiawei Wang
  2021-05-12 12:09   ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: fix default context in flow age action Jiawei Wang
  2 siblings, 1 reply; 9+ messages in thread
From: Jiawei Wang @ 2021-05-12 12:09 UTC (permalink / raw)
  To: matan, viacheslavo, orika, jackmin, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 70e8d0b113..1e6cc8d01f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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,
-- 
2.18.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] net/mlx5: fix default context in flow age action
  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   ` Jiawei Wang
  2021-05-12 12:41     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
  0 siblings, 1 reply; 9+ messages in thread
From: Jiawei Wang @ 2021-05-12 12:09 UTC (permalink / raw)
  To: matan, viacheslavo, orika, jackmin, thomas, Shahaf Shuler, Dekel Peled
  Cc: dev, rasland, stable

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")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 81 +++++++++++++++++----------------
 1 file changed, 42 insertions(+), 39 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 1e6cc8d01f..56e6cd3af7 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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);
-- 
2.18.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH v3 2/2] net/mlx5: fix default context in flow age action
  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     ` Thomas Monjalon
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2021-05-12 12:41 UTC (permalink / raw)
  To: Jiawei Wang; +Cc: matan, viacheslavo, orika, jackmin, stable, dev, rasland

12/05/2021 14:09, 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Series applied in next-net-mlx, thanks




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-05-12 12:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix ASO age null context issue Jiawei Wang
2021-05-12 11:52   ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: fix default context in flow age action 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

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