[v1,1/3] net/mlx5: modify shared counter allocation logic

Message ID 1545748697-3385-2-git-send-email-motih@mellanox.com (mailing list archive)
State Superseded, archived
Headers
Series support flow counters using devx |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Moti Haimovsky Dec. 25, 2018, 2:38 p.m. UTC
  This commit modifies the logic for searching an allocating a shared
counter in mlx5_flow_verbs.

modifies commit 84c406e74524 ("net/mlx5: add flow translate function")

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_verbs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
  

Comments

Shahaf Shuler Dec. 27, 2018, 8:12 a.m. UTC | #1
Tuesday, December 25, 2018 4:39 PM, Mordechay Haimovsky:
> Subject: [dpdk-dev] [PATCH v1 1/3] net/mlx5: modify shared counter allocation
> logic
> 
> This commit modifies the logic for searching an allocating a shared counter in
> mlx5_flow_verbs.

Need to explain - why you change it?
I assume it is because only shared counters need to be search on the PMD database, correct?

> 
> modifies commit 84c406e74524 ("net/mlx5: add flow translate function")

If above correct, better to introduce it as fix commit w/ Cc: stable@dpdk.org

> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow_verbs.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c
> b/drivers/net/mlx5/mlx5_flow_verbs.c
> index 81ec59d..409e1cd 100644
> --- a/drivers/net/mlx5/mlx5_flow_verbs.c
> +++ b/drivers/net/mlx5/mlx5_flow_verbs.c
> @@ -121,13 +121,13 @@
>  	struct mlx5_flow_counter *cnt;
>  	int ret;
> 
> -	LIST_FOREACH(cnt, &priv->flow_counters, next) {
> -		if (!cnt->shared || cnt->shared != shared)
> -			continue;
> -		if (cnt->id != id)
> -			continue;
> -		cnt->ref_cnt++;
> -		return cnt;
> +	if (shared) {
> +		LIST_FOREACH(cnt, &priv->flow_counters, next) {
> +			if (cnt->shared && cnt->id == id) {
> +				cnt->ref_cnt++;
> +				return cnt;
> +			}
> +		}
>  	}
>  	cnt = rte_calloc(__func__, 1, sizeof(*cnt), 0);
>  	if (!cnt) {
> --
> 1.8.3.1
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 81ec59d..409e1cd 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -121,13 +121,13 @@ 
 	struct mlx5_flow_counter *cnt;
 	int ret;
 
-	LIST_FOREACH(cnt, &priv->flow_counters, next) {
-		if (!cnt->shared || cnt->shared != shared)
-			continue;
-		if (cnt->id != id)
-			continue;
-		cnt->ref_cnt++;
-		return cnt;
+	if (shared) {
+		LIST_FOREACH(cnt, &priv->flow_counters, next) {
+			if (cnt->shared && cnt->id == id) {
+				cnt->ref_cnt++;
+				return cnt;
+			}
+		}
 	}
 	cnt = rte_calloc(__func__, 1, sizeof(*cnt), 0);
 	if (!cnt) {