patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v1] net/mlx5: fix wrong counter in non-termination meter
@ 2022-04-06  8:54 Shun Hao
  2022-04-14  7:34 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Shun Hao @ 2022-04-06  8:54 UTC (permalink / raw)
  To: viacheslavo, matan, orika; +Cc: dev, rasland, stable

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


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

* RE: [PATCH v1] net/mlx5: fix wrong counter in non-termination meter
  2022-04-06  8:54 [PATCH v1] net/mlx5: fix wrong counter in non-termination meter Shun Hao
@ 2022-04-14  7:34 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2022-04-14  7:34 UTC (permalink / raw)
  To: Shun Hao, Slava Ovsiienko, Matan Azrad, Ori Kam; +Cc: dev, stable

Hi,

> -----Original Message-----
> From: Shun Hao <shunh@nvidia.com>
> Sent: Wednesday, April 6, 2022 11:54 AM
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>;
> stable@dpdk.org
> Subject: [PATCH v1] net/mlx5: fix wrong counter in non-termination meter
> 
> 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>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2022-04-14  7:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  8:54 [PATCH v1] net/mlx5: fix wrong counter in non-termination meter Shun Hao
2022-04-14  7:34 ` Raslan Darawsheh

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/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 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

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


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