Skip to contentSkip to conversation

net/mlx5: fix wrong counter in non-termination meter

PATCH In review Shun Hao 2 participants 2 messages Apr 6, 2022 – Apr 14, 2022 Network drivers

lore
Share & tools
lore

Shun Hao

author
#0 lore raw

PATCH 1/1 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")
---
 drivers/net/mlx5/mlx5_flow.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.c +11 -2
index 78cb38d42b..28afdfe011 100644
@@ -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
Signature · 1 line
2.20.0
#1 lore raw

Hi,

Quoted 18 lines

-----Original Message-----
From: Shun Hao <[email protected]>
Sent: Wednesday, April 6, 2022 11:54 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
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.

Quoted 5 lines
Fixes 51ec04dc7bcf ("net/mlx5: connect meter policy to created flows")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh