From: Tomer Shmilovich <tshmilovich@nvidia.com>
To: Thomas Monjalon <thomas@monjalon.net>, Ori Kam <orika@nvidia.com>,
"Ferruh Yigit" <ferruh.yigit@amd.com>,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: <dev@dpdk.org>
Subject: [PATCH 1/2] ethdev: add group set miss actions API
Date: Wed, 20 Sep 2023 12:52:48 +0000 [thread overview]
Message-ID: <20230920125250.804055-2-tshmilovich@nvidia.com> (raw)
In-Reply-To: <20230920125250.804055-1-tshmilovich@nvidia.com>
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
next prev parent reply other threads:[~2023-09-20 12:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 12:52 [PATCH 0/2] " Tomer Shmilovich
2023-09-20 12:52 ` Tomer Shmilovich [this message]
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
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=20230920125250.804055-2-tshmilovich@nvidia.com \
--to=tshmilovich@nvidia.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=orika@nvidia.com \
--cc=thomas@monjalon.net \
/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).