DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix aging counter deallocation
@ 2021-06-09 12:32 Matan Azrad
  2021-06-09 15:40 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Matan Azrad @ 2021-06-09 12:32 UTC (permalink / raw)
  To: dev; +Cc: Viacheslav Ovsiienko, stable, Bing Zhao

When a counter is destroyed and used for aging action, the driver should
remove the counter object from the age-out list if it is there.

The counter memory of the list entry and of the counter shared
information is shared because, currently, shared counter cannot be used
for aging.

When the support for counter action in action handle API was added, the
counter shared information was reused and moved to be used also for
non-shared case. Wrongly, it is used for aging case too.

Remove the usage of shared information in case of aging.

Fixes: f3191849f2c2 ("net/mlx5: support flow count action handle")
Cc: stable@dpdk.org

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

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index c9887c8376..1b2639d232 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6110,28 +6110,33 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t counter)
 		return;
 	cnt = flow_dv_counter_get_by_idx(dev, counter, &pool);
 	MLX5_ASSERT(pool);
-	/*
-	 * If the counter action is shared by ID, the l3t_clear_entry function
-	 * reduces its references counter. If after the reduction the action is
-	 * still referenced, the function returns here and does not release it.
-	 */
-	if (IS_LEGACY_SHARED_CNT(counter) &&
-	    mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl, cnt->shared_info.id))
-		return;
-	/*
-	 * If the counter action is shared by indirect action API, the atomic
-	 * function reduces its references counter. If after the reduction the
-	 * action is still referenced, the function returns here and does not
-	 * release it.
-	 * When the counter action is not shared neither by ID nor by indirect
-	 * action API, shared info is 1 before the reduction, so this condition
-	 * is failed and function doesn't return here.
-	 */
-	if (!IS_LEGACY_SHARED_CNT(counter) &&
-	    __atomic_sub_fetch(&cnt->shared_info.refcnt, 1, __ATOMIC_RELAXED))
-		return;
-	if (pool->is_aged)
+	if (pool->is_aged) {
 		flow_dv_counter_remove_from_age(dev, counter, cnt);
+	} else {
+		/*
+		 * If the counter action is shared by ID, the l3t_clear_entry
+		 * function reduces its references counter. If after the
+		 * reduction the action is still referenced, the function
+		 * returns here and does not release it.
+		 */
+		if (IS_LEGACY_SHARED_CNT(counter) &&
+		    mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl,
+					 cnt->shared_info.id))
+			return;
+		/*
+		 * If the counter action is shared by indirect action API,
+		 * the atomic function reduces its references counter.
+		 * If after the reduction the action is still referenced, the
+		 * function returns here and does not release it.
+		 * When the counter action is not shared neither by ID nor by
+		 * indirect action API, shared info is 1 before the reduction,
+		 * so this condition is failed and function doesn't return here.
+		 */
+		if (!IS_LEGACY_SHARED_CNT(counter) &&
+		    __atomic_sub_fetch(&cnt->shared_info.refcnt, 1,
+				       __ATOMIC_RELAXED))
+			return;
+	}
 	cnt->pool = pool;
 	/*
 	 * Put the counter back to list to be updated in none fallback mode.
-- 
2.25.1


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

* Re: [dpdk-dev] [PATCH] net/mlx5: fix aging counter deallocation
  2021-06-09 12:32 [dpdk-dev] [PATCH] net/mlx5: fix aging counter deallocation Matan Azrad
@ 2021-06-09 15:40 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2021-06-09 15:40 UTC (permalink / raw)
  To: Matan Azrad, dev; +Cc: Slava Ovsiienko, stable, Bing Zhao

Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Matan Azrad
> Sent: Wednesday, June 9, 2021 3:33 PM
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@nvidia.com>; stable@dpdk.org; Bing Zhao
> <bingz@nvidia.com>
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix aging counter deallocation
> 
> When a counter is destroyed and used for aging action, the driver should
> remove the counter object from the age-out list if it is there.
> 
> The counter memory of the list entry and of the counter shared
> information is shared because, currently, shared counter cannot be used
> for aging.
> 
> When the support for counter action in action handle API was added, the
> counter shared information was reused and moved to be used also for
> non-shared case. Wrongly, it is used for aging case too.
> 
> Remove the usage of shared information in case of aging.
> 
> Fixes: f3191849f2c2 ("net/mlx5: support flow count action handle")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Matan Azrad <matan@nvidia.com>
> Acked-by: Bing Zhao <bingz@nvidia.com>
> ---

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2021-06-09 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 12:32 [dpdk-dev] [PATCH] net/mlx5: fix aging counter deallocation Matan Azrad
2021-06-09 15:40 ` Raslan Darawsheh

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git