patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Shun Hao <shunh@nvidia.com>
To: <orika@nvidia.com>, <viacheslavo@nvidia.com>, <matan@nvidia.com>,
	"Shahaf Shuler" <shahafs@nvidia.com>,
	Michael Baum <michaelba@nvidia.com>
Cc: <dev@dpdk.org>, <thomas@monjalon.net>, <rasland@nvidia.com>,
	<stable@dpdk.org>
Subject: [dpdk-stable] [PATCH v1 1/2] net/mlx5: fix meter flow counter traslation
Date: Wed, 4 Aug 2021 10:26:46 +0300	[thread overview]
Message-ID: <20210804072647.2077832-2-shunh@nvidia.com> (raw)
In-Reply-To: <20210804072647.2077832-1-shunh@nvidia.com>

When an RTE flow uses a meter without any modify packet action,
there will be an internal drop flow with meter counter created,
matching the same 5-tuple as the original flow.

In this case, the meter flow count action is wrongly reused as the
original flow counter, leading to wrong flow statistics.

Add a check in the count action translation to detect the meter case
and use the meter drop dedicated counter in the meter 5-tuple flow
only.

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

Signed-off-by: Shun Hao <shunh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 4644ae46bd..f54440c6f5 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -12824,13 +12824,26 @@ flow_dv_translate(struct rte_eth_dev *dev,
 			action_flags |= MLX5_FLOW_ACTION_AGE;
 			break;
 		case MLX5_RTE_FLOW_ACTION_TYPE_COUNT:
-			flow->counter = (uint32_t)(uintptr_t)(action->conf);
-			cnt_act = flow_dv_counter_get_by_idx(dev, flow->counter,
-							     NULL);
-			__atomic_fetch_add(&cnt_act->shared_info.refcnt, 1,
-					   __ATOMIC_RELAXED);
-			/* Save information first, will apply later. */
-			action_flags |= MLX5_FLOW_ACTION_COUNT;
+			cnt_act = flow_dv_counter_get_by_idx(dev,
+					(uint32_t)(uintptr_t)action->conf,
+					NULL);
+			MLX5_ASSERT(cnt_act != NULL);
+			/**
+			 * When creating meter drop flow in drop table, the
+			 * counter should not overwrite the rte flow counter.
+			 */
+			if (attr->group == MLX5_FLOW_TABLE_LEVEL_METER &&
+			    dev_flow->dv.table_id == MLX5_MTR_TABLE_ID_DROP) {
+				dev_flow->dv.actions[actions_n++] =
+							cnt_act->action;
+			} else {
+				flow->counter =
+					(uint32_t)(uintptr_t)(action->conf);
+				__atomic_fetch_add(&cnt_act->shared_info.refcnt,
+						1, __ATOMIC_RELAXED);
+				/* Save information first, will apply later. */
+				action_flags |= MLX5_FLOW_ACTION_COUNT;
+			}
 			break;
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			if (!dev_conf->devx) {
-- 
2.20.0


       reply	other threads:[~2021-08-04  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210804072647.2077832-1-shunh@nvidia.com>
2021-08-04  7:26 ` Shun Hao [this message]
2021-08-04  7:26 ` [dpdk-stable] [PATCH v1 2/2] net/mlx5: fix domains detection in meter hierarchy Shun Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210804072647.2077832-2-shunh@nvidia.com \
    --to=shunh@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=michaelba@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).