patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Shun Hao <shunh@nvidia.com>
To: <viacheslavo@nvidia.com>, <matan@nvidia.com>, <orika@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [PATCH v1] net/mlx5: fix wrong counter in non-termination meter
Date: Wed, 6 Apr 2022 11:54:01 +0300	[thread overview]
Message-ID: <20220406085402.11639-1-shunh@nvidia.com> (raw)

In RTE flow, if a counter action is before a meter which has
non-termination policy, the counter value only includes packets not
being dropped.

This patch fixes this issue by differentiating the order of counter and
non-termination meter:
1. counter + meter, counts all packets hitting this flow.
2. meter + counter, only counts packets not being dropped.

Fixes: 51ec04dc7bcf ("net/mlx5: connect meter policy to created flows")
Cc: stable@dpdk.org

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

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 78cb38d42b..28afdfe011 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -5271,6 +5271,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	uint32_t flow_id = 0;
 	uint32_t flow_id_reversed = 0;
 	uint8_t flow_id_bits = 0;
+	bool after_meter = false;
 	int shift;
 
 	/* Prepare the suffix subflow items. */
@@ -5337,6 +5338,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 				tag_action = actions_pre++;
 				action_cur = actions_pre++;
 			}
+			after_meter = true;
 			break;
 		case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
 		case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP:
@@ -5365,6 +5367,11 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 						MLX5_RTE_FLOW_ITEM_TYPE_VLAN;
 			}
 			break;
+		case RTE_FLOW_ACTION_TYPE_COUNT:
+			if (fm->def_policy)
+				action_cur = after_meter ?
+						actions_sfx++ : actions_pre++;
+			break;
 		default:
 			break;
 		}
@@ -6393,8 +6400,10 @@ flow_create_split_meter(struct rte_eth_dev *dev,
 		if (!fm->def_policy && !is_mtr_hierarchy &&
 		    (!has_modify || !fm->drop_cnt))
 			set_mtr_reg = false;
-		/* Prefix actions: meter, decap, encap, tag, jump, end. */
-		act_size = sizeof(struct rte_flow_action) * (actions_n + 6) +
+		/* Prefix actions: meter, decap, encap, tag, jump, end, cnt. */
+#define METER_PREFIX_ACTION 7
+		act_size = (sizeof(struct rte_flow_action) *
+			    (actions_n + METER_PREFIX_ACTION)) +
 			   sizeof(struct mlx5_rte_flow_action_set_tag);
 		/* Suffix items: tag, vlan, port id, end. */
 #define METER_SUFFIX_ITEM 4
-- 
2.20.0


             reply	other threads:[~2022-04-06  8:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  8:54 Shun Hao [this message]
2022-04-14  7:34 ` Raslan Darawsheh

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=20220406085402.11639-1-shunh@nvidia.com \
    --to=shunh@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --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).