Skip to contentSkip to conversation

net/mlx5: support count action in shared action API

RFC New Michael Baum 1 participant 1 message Mar 10, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

RFC 1/1 net/mlx5: support count action in shared action API

Existing API supports counter action to count traffic of a single flow. The user could use the shared flag to share the action between different flows. The user gives an id for counter action in creating the flow, and when he wants to share it with another flow, he uses the same id.

Recent patch [1] introduced the shared action API.
Using this API, an action can be created as shared, unattached to any flow rule.
Multiple flows can then be created using the shared action. The new API also supports query operation of a shared action.

The new API is more efficient because PMD selects the id for the user, thus saving the conversion of the user's id to its id.

Following this RFC, the MLX5 PMD will implement support of shared count action.
This new feature will support validate, create, query and destroy operations.

Application will use the shared action query operation to query this count action.
The response will be returned In the same existing query count format.

In the meantime the old sharing mechanism (with the sharing flag) continues to be supported, and the user can choose the way he wants to share the counter.
The new shared action API is only supported in DevX, so sharing counter action in Verbs can only be done through the old mechanism.

[1] https://mails.dpdk.org/archives/dev/2020-July/174110.html

---
 drivers/net/mlx5/mlx5.h         |   5 +-
 drivers/net/mlx5/mlx5_defs.h    |   2 +-
 drivers/net/mlx5/mlx5_flow.c    |   6 ++
 drivers/net/mlx5/mlx5_flow.h    |   2 +
 drivers/net/mlx5/mlx5_flow_dv.c | 218 ++++++++++++++++++++++++++++++----------
 5 files changed, 176 insertions(+), 57 deletions(-)
drivers/net/mlx5/mlx5.h +4 -1
index a281fd2..447767b 100644
@@ -341,7 +341,10 @@ struct flow_counter_stats {
 
 /* Shared counters information for counters. */
 struct mlx5_flow_counter_shared {
-	uint32_t id; /**< User counter ID. */
+	union {
+		uint32_t refcnt; /* Count action reference counter. */
+		uint32_t id; /* User counter ID. */
+	};
 };
 
 /* Shared counter configuration. */
drivers/net/mlx5/mlx5_defs.h +1 -1
index af29d93..8e45f55 100644
@@ -197,7 +197,7 @@
 #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2)
 
 /* Maximum number of shared actions supported by rte_flow */
-#define MLX5_MAX_SHARED_ACTIONS 2
+#define MLX5_MAX_SHARED_ACTIONS 3
 
 /*
  * Linux definition of static_assert is found in /usr/include/assert.h.
drivers/net/mlx5/mlx5_flow.c +6 -0
index ab5be3d..6b5889a 100644
@@ -3498,6 +3498,12 @@ struct mlx5_translated_shared_action {
 			translated[shared->index].conf =
 				&shared_rss->origin;
 			break;
+		case MLX5_SHARED_ACTION_TYPE_COUNT:
+			translated[shared->index].type =
+						(enum rte_flow_action_type)
+						MLX5_RTE_FLOW_ACTION_TYPE_COUNT;
+			translated[shared->index].conf = (void *)(uintptr_t)idx;
+			break;
 		case MLX5_SHARED_ACTION_TYPE_AGE:
 			if (priv->sh->flow_hit_aso_en) {
 				translated[shared->index].type =
drivers/net/mlx5/mlx5_flow.h +2 -0
index 8324e18..16659be 100644
@@ -37,6 +37,7 @@ enum mlx5_rte_flow_action_type {
 	MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS,
 	MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET,
 	MLX5_RTE_FLOW_ACTION_TYPE_AGE,
+	MLX5_RTE_FLOW_ACTION_TYPE_COUNT,
 };
 
 #define MLX5_SHARED_ACTION_TYPE_OFFSET 30
@@ -44,6 +45,7 @@ enum mlx5_rte_flow_action_type {
 enum {
 	MLX5_SHARED_ACTION_TYPE_RSS,
 	MLX5_SHARED_ACTION_TYPE_AGE,
+	MLX5_SHARED_ACTION_TYPE_COUNT,
 };
 
 /* Matches on selected register. */
drivers/net/mlx5/mlx5_flow_dv.c +163 -55

371 lines not on this page · raw message

Signature · 1 line
1.8.3.1