DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] ethdev: add group set miss actions API
@ 2023-09-20 12:52 Tomer Shmilovich
  2023-09-20 12:52 ` [PATCH 1/2] " Tomer Shmilovich
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tomer Shmilovich @ 2023-09-20 12:52 UTC (permalink / raw)
  To: Thomas Monjalon, Ori Kam, Ferruh Yigit, Andrew Rybchenko,
	Aman Singh, Yuying Zhang
  Cc: dev

Introduce new group set miss actions API:
rte_flow_group_set_miss_actions().

A group's miss actions are a set of actions to be performed
in case of a miss on a group, i.e. when a packet didn't hit any flow
rules in the group.

Currently, the expected behavior in this case is undefined.
In order to achieve such functionality, a user can add a flow rule
that matches on all traffic with the lowest priority in the group -
this is not explicit however, and can be overridden by another flow rule
with a lower priority.

This new API function allows a user to set a group's miss actions in an
explicit way.

RFC discussion: http://patches.dpdk.org/project/dpdk/patch/20230807133601.164018-1-tshmilovich@nvidia.com/

Tomer Shmilovich (2):
  ethdev: add group set miss actions API
  app/testpmd: add group set miss actions CLI commands

 .mailmap                               |   1 +
 app/test-pmd/cmdline_flow.c            | 112 +++++++++++++++++++++++++
 app/test-pmd/config.c                  |  27 ++++++
 app/test-pmd/testpmd.h                 |   2 +
 doc/guides/prog_guide/rte_flow.rst     |  30 +++++++
 doc/guides/rel_notes/release_23_11.rst |   5 ++
 lib/ethdev/rte_flow.c                  |  22 +++++
 lib/ethdev/rte_flow.h                  |  35 ++++++++
 lib/ethdev/rte_flow_driver.h           |   7 ++
 lib/ethdev/version.map                 |   3 +
 10 files changed, 244 insertions(+)

-- 
2.34.1


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

* [PATCH 1/2] ethdev: add group set miss actions API
  2023-09-20 12:52 [PATCH 0/2] ethdev: add group set miss actions API Tomer Shmilovich
@ 2023-09-20 12:52 ` Tomer Shmilovich
  2023-09-20 12:52 ` [PATCH 2/2] app/testpmd: add group set miss actions CLI commands Tomer Shmilovich
  2023-09-29 11:02 ` [PATCH 0/2] ethdev: add group set miss actions API Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Tomer Shmilovich @ 2023-09-20 12:52 UTC (permalink / raw)
  To: Thomas Monjalon, Ori Kam, Ferruh Yigit, Andrew Rybchenko; +Cc: dev

Introduce new group set miss actions API:
rte_flow_group_set_miss_actions().

A group's miss actions are a set of actions to be performed
in case of a miss on a group, meaning a packet didn't hit any rules
in the group. This API function allows a user to set a group's
miss actions.

Signed-off-by: Tomer Shmilovich <tshmilovich@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 .mailmap                               |  1 +
 doc/guides/prog_guide/rte_flow.rst     | 30 ++++++++++++++++++++++
 doc/guides/rel_notes/release_23_11.rst |  5 ++++
 lib/ethdev/rte_flow.c                  | 22 ++++++++++++++++
 lib/ethdev/rte_flow.h                  | 35 ++++++++++++++++++++++++++
 lib/ethdev/rte_flow_driver.h           |  7 ++++++
 lib/ethdev/version.map                 |  3 +++
 7 files changed, 103 insertions(+)

diff --git a/.mailmap b/.mailmap
index 864d33ee46..0cd6be849e 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1411,6 +1411,7 @@ Tom Barbette <barbette@kth.se> <tom.barbette@ulg.ac.be>
 Tom Crugnale <tcrugnale@sandvine.com>
 Tom Millington <tmillington@solarflare.com>
 Tom Rix <trix@redhat.com>
+Tomer Shmilovich <tshmilovich@nvidia.com>
 Tone Zhang <tone.zhang@arm.com>
 Tonghao Zhang <xiangxia.m.yue@gmail.com> <nic@opencloud.tech>
 Tony Nguyen <anthony.l.nguyen@intel.com>
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 5bc998a433..590d2a770e 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -3758,6 +3758,36 @@ Information about the number of available resources can be retrieved via
                      struct rte_flow_queue_info *queue_info,
                      struct rte_flow_error *error);
 
+Group Miss Actions
+~~~~~~~~~~~~~~~~~~
+
+In an application, many flow rules share common group attributes, meaning they can be grouped and
+classified together. A user can explicitly specify a set of actions performed on a packet when it
+did not match any flows rules in a group using the following API:
+
+.. code-block:: c
+
+      int
+      rte_flow_group_set_miss_actions(uint16_t port_id,
+                                      uint32_t group_id,
+                                      const struct rte_flow_group_attr *attr,
+                                      const struct rte_flow_action actions[],
+                                      struct rte_flow_error *error);
+
+For example, to configure a RTE_FLOW_TYPE_JUMP action as a miss action for ingress group 1:
+
+.. code-block:: c
+
+      struct rte_flow_group_attr attr = {.ingress = 1};
+      struct rte_flow_action act[] = {
+      /* Setting miss actions to jump to group 3 */
+          [0] = {.type = RTE_FLOW_ACTION_TYPE_JUMP,
+                 .conf = &(struct rte_flow_action_jump){.group = 3}},
+          [1] = {.type = RTE_FLOW_ACTION_TYPE_END},
+      };
+      struct rte_flow_error err;
+      rte_flow_group_set_miss_actions(port, 1, &attr, act, &err);
+
 Flow templates
 ~~~~~~~~~~~~~~
 
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 333e1d95a2..da0ddc2078 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -41,6 +41,11 @@ DPDK Release 23.11
 New Features
 ------------
 
+* **Added flow group set miss actions.**
+   Introduced ``rte_flow_group_set_miss_actions()`` API to explicitly set a group's miss actions,
+   which are the actions to be performed on packets that didn't match any of the flow rules
+   in the group.
+
 .. This section should contain new features added in this release.
    Sample format:
 
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 271d854f78..a98d87265f 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -1973,6 +1973,28 @@ rte_flow_template_table_destroy(uint16_t port_id,
 				  NULL, rte_strerror(ENOTSUP));
 }
 
+int
+rte_flow_group_set_miss_actions(uint16_t port_id,
+				uint32_t group_id,
+				const struct rte_flow_group_attr *attr,
+				const struct rte_flow_action actions[],
+				struct rte_flow_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error);
+
+	if (unlikely(!ops))
+		return -rte_errno;
+	if (likely(!!ops->group_set_miss_actions)) {
+		return flow_err(port_id,
+				ops->group_set_miss_actions(dev, group_id, attr, actions, error),
+				error);
+	}
+	return rte_flow_error_set(error, ENOTSUP,
+				  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				  NULL, rte_strerror(ENOTSUP));
+}
+
 struct rte_flow *
 rte_flow_async_create(uint16_t port_id,
 		      uint32_t queue_id,
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 2ebb76dbc0..82548a8b93 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -129,6 +129,12 @@ struct rte_flow_attr {
 	uint32_t reserved:29; /**< Reserved, must be zero. */
 };
 
+struct rte_flow_group_attr {
+	uint32_t ingress:1;
+	uint32_t egress:1;
+	uint32_t transfer:1;
+};
+
 /**
  * Matching pattern item types.
  *
@@ -5828,6 +5834,35 @@ rte_flow_template_table_destroy(uint16_t port_id,
 		struct rte_flow_template_table *template_table,
 		struct rte_flow_error *error);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Set group miss actions.
+ *
+ * @param port_id
+ *   Port identifier of Ethernet device.
+ * @param group_id
+ *   Identifier of a group to set miss actions for.
+ * @param attr
+ *   Group attributes.
+ * @param actions
+ *   List of group miss actions.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL.
+ *   PMDs initialize this structure in case of error only.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+__rte_experimental
+int
+rte_flow_group_set_miss_actions(uint16_t port_id,
+				uint32_t group_id,
+				const struct rte_flow_group_attr *attr,
+				const struct rte_flow_action actions[],
+				struct rte_flow_error *error);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h
index f9fb01b8a2..3ced086c47 100644
--- a/lib/ethdev/rte_flow_driver.h
+++ b/lib/ethdev/rte_flow_driver.h
@@ -227,6 +227,13 @@ struct rte_flow_ops {
 		(struct rte_eth_dev *dev,
 		 struct rte_flow_template_table *template_table,
 		 struct rte_flow_error *err);
+	/** See rte_flow_group_set_miss_actions() */
+	int (*group_set_miss_actions)
+		(struct rte_eth_dev *dev,
+		 uint32_t group_id,
+		 const struct rte_flow_group_attr *attr,
+		 const struct rte_flow_action actions[],
+		 struct rte_flow_error *err);
 	/** See rte_flow_async_create() */
 	struct rte_flow *(*async_create)
 		(struct rte_eth_dev *dev,
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index b965d6aa52..ff9b92f21e 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -312,6 +312,9 @@ EXPERIMENTAL {
 	rte_flow_async_action_list_handle_query_update;
 	rte_flow_async_actions_update;
 	rte_flow_restore_info_dynflag;
+
+	# added in 23.11
+	rte_flow_group_set_miss_actions;
 };
 
 INTERNAL {
-- 
2.34.1


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

* [PATCH 2/2] app/testpmd: add group set miss actions CLI commands
  2023-09-20 12:52 [PATCH 0/2] ethdev: add group set miss actions API Tomer Shmilovich
  2023-09-20 12:52 ` [PATCH 1/2] " Tomer Shmilovich
@ 2023-09-20 12:52 ` Tomer Shmilovich
  2023-09-29 11:02 ` [PATCH 0/2] ethdev: add group set miss actions API Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Tomer Shmilovich @ 2023-09-20 12:52 UTC (permalink / raw)
  To: Ori Kam, Aman Singh, Yuying Zhang; +Cc: dev

Add testpmd CLI interface for the group set miss actions API:

	flow group 0 group_id 1 ingress set_miss_actions jump group 3 / end
	flow group 0 group_id 1 ingress set_miss_actions end

Signed-off-by: Tomer Shmilovich <tshmilovich@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 112 ++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c       |  27 +++++++++
 app/test-pmd/testpmd.h      |   2 +
 3 files changed, 141 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 94827bcc4a..b3b8893e37 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -86,6 +86,7 @@ enum index {
 	PATTERN_TEMPLATE,
 	ACTIONS_TEMPLATE,
 	TABLE,
+	FLOW_GROUP,
 	INDIRECT_ACTION,
 	VALIDATE,
 	CREATE,
@@ -206,6 +207,13 @@ enum index {
 	TABLE_PATTERN_TEMPLATE,
 	TABLE_ACTIONS_TEMPLATE,
 
+	/* Group arguments */
+	GROUP_ID,
+	GROUP_INGRESS,
+	GROUP_EGRESS,
+	GROUP_TRANSFER,
+	GROUP_SET_MISS_ACTIONS,
+
 	/* Tunnel arguments. */
 	TUNNEL_CREATE,
 	TUNNEL_CREATE_TYPE,
@@ -1293,6 +1301,14 @@ static const enum index next_at_destroy_attr[] = {
 	ZERO,
 };
 
+static const enum index next_group_attr[] = {
+	GROUP_INGRESS,
+	GROUP_EGRESS,
+	GROUP_TRANSFER,
+	GROUP_SET_MISS_ACTIONS,
+	ZERO,
+};
+
 static const enum index next_table_subcmd[] = {
 	TABLE_CREATE,
 	TABLE_DESTROY,
@@ -2678,6 +2694,9 @@ static int parse_push(struct context *, const struct token *,
 static int parse_pull(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
+static int parse_group(struct context *, const struct token *,
+		       const char *, unsigned int,
+		       void *, unsigned int);
 static int parse_tunnel(struct context *, const struct token *,
 			const char *, unsigned int,
 			void *, unsigned int);
@@ -3021,6 +3040,7 @@ static const struct token token_list[] = {
 			      PATTERN_TEMPLATE,
 			      ACTIONS_TEMPLATE,
 			      TABLE,
+			      FLOW_GROUP,
 			      INDIRECT_ACTION,
 			      VALIDATE,
 			      CREATE,
@@ -3411,6 +3431,46 @@ static const struct token token_list[] = {
 		.call = parse_table,
 	},
 	/* Top-level command. */
+	[FLOW_GROUP] = {
+		.name = "group",
+		.help = "manage flow groups",
+		.next = NEXT(NEXT_ENTRY(GROUP_ID), NEXT_ENTRY(COMMON_PORT_ID)),
+		.args = ARGS(ARGS_ENTRY(struct buffer, port)),
+		.call = parse_group,
+	},
+	/* Sub-level commands. */
+	[GROUP_SET_MISS_ACTIONS] = {
+		.name = "set_miss_actions",
+		.help = "set group miss actions",
+		.next = NEXT(next_action),
+		.call = parse_group,
+	},
+	/* Group arguments */
+	[GROUP_ID]	= {
+		.name = "group_id",
+		.help = "group id",
+		.next = NEXT(next_group_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
+		.args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
+	},
+	[GROUP_INGRESS] = {
+		.name = "ingress",
+		.help = "group ingress attr",
+		.next = NEXT(next_group_attr),
+		.call = parse_group,
+	},
+	[GROUP_EGRESS] = {
+		.name = "egress",
+		.help = "group egress attr",
+		.next = NEXT(next_group_attr),
+		.call = parse_group,
+	},
+	[GROUP_TRANSFER] = {
+		.name = "transfer",
+		.help = "group transfer attr",
+		.next = NEXT(next_group_attr),
+		.call = parse_group,
+	},
+	/* Top-level command. */
 	[QUEUE] = {
 		.name = "queue",
 		.help = "queue a flow rule operation",
@@ -10449,6 +10509,54 @@ parse_pull(struct context *ctx, const struct token *token,
 	return len;
 }
 
+static int
+parse_group(struct context *ctx, const struct token *token,
+	    const char *str, unsigned int len,
+	    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+
+	/* Token name must match. */
+	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+		return -1;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return len;
+	if (!out->command) {
+		if (ctx->curr != FLOW_GROUP)
+			return -1;
+		if (sizeof(*out) > size)
+			return -1;
+		out->command = ctx->curr;
+		ctx->objdata = 0;
+		ctx->object = out;
+		ctx->objmask = NULL;
+		out->args.vc.data = (uint8_t *)out + size;
+		return len;
+	}
+	switch (ctx->curr) {
+	case GROUP_INGRESS:
+		out->args.vc.attr.ingress = 1;
+		return len;
+	case GROUP_EGRESS:
+		out->args.vc.attr.egress = 1;
+		return len;
+	case GROUP_TRANSFER:
+		out->args.vc.attr.transfer = 1;
+		return len;
+	case GROUP_SET_MISS_ACTIONS:
+		out->command = ctx->curr;
+		ctx->objdata = 0;
+		ctx->object = out;
+		ctx->objmask = NULL;
+		out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
+							       sizeof(double));
+		return len;
+	default:
+		return -1;
+	}
+}
+
 static int
 parse_flex(struct context *ctx, const struct token *token,
 	     const char *str, unsigned int len,
@@ -12329,6 +12437,10 @@ cmd_flow_parsed(const struct buffer *in)
 					in->args.table_destroy.table_id_n,
 					in->args.table_destroy.table_id);
 		break;
+	case GROUP_SET_MISS_ACTIONS:
+		port_queue_group_set_miss_actions(in->port, &in->args.vc.attr,
+						  in->args.vc.actions);
+		break;
 	case QUEUE_CREATE:
 		port_queue_flow_create(in->port, in->queue, in->postpone,
 			in->args.vc.table_id, in->args.vc.rule_id,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 3d1da99307..709864bb44 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3514,6 +3514,33 @@ port_queue_flow_pull(portid_t port_id, queueid_t queue_id)
 	return ret;
 }
 
+/* Set group miss actions */
+int
+port_queue_group_set_miss_actions(portid_t port_id, const struct rte_flow_attr *attr,
+				  const struct rte_flow_action *actions)
+{
+	struct rte_flow_group_attr gattr = {
+		.ingress = attr->ingress,
+		.egress = attr->egress,
+		.transfer = attr->transfer,
+	};
+	struct rte_flow_error error;
+	int ret = 0;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+	    port_id == (portid_t)RTE_PORT_ALL)
+		return -EINVAL;
+
+	memset(&error, 0x66, sizeof(error));
+	ret = rte_flow_group_set_miss_actions(port_id, attr->group, &gattr, actions, &error);
+
+	if (ret < 0)
+		return port_flow_complain(&error);
+
+	printf("Group #%u set miss actions succeeded\n", attr->group);
+	return ret;
+}
+
 /** Create flow rule. */
 int
 port_flow_create(portid_t port_id,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index f1df6a8faf..e69b76f380 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -979,6 +979,8 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id,
 int port_flow_template_table_destroy(portid_t port_id,
 			    uint32_t n, const uint32_t *table);
 int port_flow_template_table_flush(portid_t port_id);
+int port_queue_group_set_miss_actions(portid_t port_id, const struct rte_flow_attr *attr,
+				      const struct rte_flow_action *actions);
 int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
 			   bool postpone, uint32_t table_id, uint32_t rule_idx,
 			   uint32_t pattern_idx, uint32_t actions_idx,
-- 
2.34.1


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

* Re: [PATCH 0/2] ethdev: add group set miss actions API
  2023-09-20 12:52 [PATCH 0/2] ethdev: add group set miss actions API Tomer Shmilovich
  2023-09-20 12:52 ` [PATCH 1/2] " Tomer Shmilovich
  2023-09-20 12:52 ` [PATCH 2/2] app/testpmd: add group set miss actions CLI commands Tomer Shmilovich
@ 2023-09-29 11:02 ` Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2023-09-29 11:02 UTC (permalink / raw)
  To: Tomer Shmilovich, Thomas Monjalon, Ori Kam, Andrew Rybchenko,
	Aman Singh, Yuying Zhang
  Cc: dev

On 9/20/2023 1:52 PM, Tomer Shmilovich wrote:
> Introduce new group set miss actions API:
> rte_flow_group_set_miss_actions().
> 
> A group's miss actions are a set of actions to be performed
> in case of a miss on a group, i.e. when a packet didn't hit any flow
> rules in the group.
> 
> Currently, the expected behavior in this case is undefined.
> In order to achieve such functionality, a user can add a flow rule
> that matches on all traffic with the lowest priority in the group -
> this is not explicit however, and can be overridden by another flow rule
> with a lower priority.
> 
> This new API function allows a user to set a group's miss actions in an
> explicit way.
> 
> RFC discussion: http://patches.dpdk.org/project/dpdk/patch/20230807133601.164018-1-tshmilovich@nvidia.com/
> 
> Tomer Shmilovich (2):
>   ethdev: add group set miss actions API
>   app/testpmd: add group set miss actions CLI commands
> 

Series applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2023-09-29 11:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20 12:52 [PATCH 0/2] ethdev: add group set miss actions API Tomer Shmilovich
2023-09-20 12:52 ` [PATCH 1/2] " Tomer Shmilovich
2023-09-20 12:52 ` [PATCH 2/2] app/testpmd: add group set miss actions CLI commands Tomer Shmilovich
2023-09-29 11:02 ` [PATCH 0/2] ethdev: add group set miss actions API Ferruh Yigit

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).