From: Lukas Sismis <sismis@dyna-nic.com>
To: dev@dpdk.org
Cc: orika@nvidia.com, stephen@networkplumber.org,
thomas@monjalon.net, Lukas Sismis <sismis@dyna-nic.com>
Subject: [PATCH v12 2/6] ethdev: add RSS type helper APIs
Date: Tue, 5 May 2026 20:39:09 +0200 [thread overview]
Message-ID: <20260505183917.370281-3-sismis@dyna-nic.com> (raw)
In-Reply-To: <20260505183917.370281-1-sismis@dyna-nic.com>
Add a global RSS type string table and helper functions to convert
between RSS type names and values.
Add unit tests for RSS type helper.
Signed-off-by: Lukas Sismis <sismis@dyna-nic.com>
---
app/test/test_ethdev_api.c | 56 +++++++++++++
doc/guides/rel_notes/release_26_07.rst | 5 ++
lib/ethdev/rte_ethdev.c | 109 +++++++++++++++++++++++++
lib/ethdev/rte_ethdev.h | 60 ++++++++++++++
4 files changed, 230 insertions(+)
diff --git a/app/test/test_ethdev_api.c b/app/test/test_ethdev_api.c
index 76afd0345c..ab0e018c60 100644
--- a/app/test/test_ethdev_api.c
+++ b/app/test/test_ethdev_api.c
@@ -2,6 +2,9 @@
* Copyright (C) 2023, Advanced Micro Devices, Inc.
*/
+#include <stdbool.h>
+#include <string.h>
+
#include <rte_log.h>
#include <rte_ethdev.h>
@@ -162,12 +165,65 @@ ethdev_api_queue_status(void)
return TEST_SUCCESS;
}
+static int
+ethdev_api_rss_type_helpers(void)
+{
+ const struct rte_eth_rss_type_info *tbl;
+ const char *zero_name = NULL;
+ unsigned int i;
+ bool has_zero = false;
+ const char *name;
+ uint64_t type;
+
+ tbl = rte_eth_rss_type_info_get();
+ TEST_ASSERT_NOT_NULL(tbl, "rss type table missing");
+
+ for (i = 0; tbl[i].str != NULL; i++) {
+ TEST_ASSERT_SUCCESS(rte_eth_rss_type_from_str(tbl[i].str,
+ &type), "rss type lookup failed for %s", tbl[i].str);
+ TEST_ASSERT_EQUAL(type, tbl[i].rss_type,
+ "rss type mismatch for %s", tbl[i].str);
+
+ if (tbl[i].rss_type == 0 && !has_zero) {
+ has_zero = true;
+ zero_name = tbl[i].str;
+ }
+
+ name = rte_eth_rss_type_to_str(tbl[i].rss_type);
+ TEST_ASSERT_NOT_NULL(name, "rss type name missing for %s",
+ tbl[i].str);
+ TEST_ASSERT_SUCCESS(rte_eth_rss_type_from_str(name, &type),
+ "rss type round-trip lookup failed for %s", name);
+ TEST_ASSERT_EQUAL(type, tbl[i].rss_type,
+ "rss type round-trip mismatch for %s", name);
+ }
+
+ TEST_ASSERT(tbl[i].str == NULL, "rss type table not NULL terminated");
+ TEST_ASSERT(rte_eth_rss_type_from_str(NULL, &type) != 0,
+ "rss type from NULL str should fail");
+ TEST_ASSERT(rte_eth_rss_type_from_str("ipv4", NULL) != 0,
+ "rss type from NULL rss_type should fail");
+ TEST_ASSERT(rte_eth_rss_type_from_str("not-a-type", &type) != 0,
+ "rss type unknown should fail");
+ name = rte_eth_rss_type_to_str(0);
+ if (has_zero) {
+ TEST_ASSERT_NOT_NULL(name, "rss type 0 should be defined");
+ TEST_ASSERT(strcmp(name, zero_name) == 0,
+ "rss type 0 name mismatch");
+ } else {
+ TEST_ASSERT(name == NULL, "rss type 0 should be NULL");
+ }
+
+ return TEST_SUCCESS;
+}
+
static struct unit_test_suite ethdev_api_testsuite = {
.suite_name = "ethdev API tests",
.setup = NULL,
.teardown = NULL,
.unit_test_cases = {
TEST_CASE(ethdev_api_queue_status),
+ TEST_CASE(ethdev_api_rss_type_helpers),
/* TODO: Add deferred_start queue status test */
TEST_CASES_END() /**< NULL terminate unit test array */
}
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index f012d47a4b..01d064ebd1 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -63,6 +63,11 @@ New Features
``rte_eal_init`` and the application is responsible for probing each device,
* ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
+* **Added experimental RSS type helper APIs in ethdev.**
+
+ * Added new APIs to convert between RSS type names and values.
+ * Added new API call to obtain the global RSS string table.
+
Removed Items
-------------
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 2edc7a362e..571947371c 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -5178,6 +5178,115 @@ rte_eth_find_rss_algo(const char *name, uint32_t *algo)
return -EINVAL;
}
+/* Global RSS type string table. */
+static const struct rte_eth_rss_type_info rte_eth_rss_type_table[] = {
+ /* Group types */
+ { "all", RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
+ RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
+ RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 |
+ RTE_ETH_RSS_ESP | RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP |
+ RTE_ETH_RSS_GTPU | RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_MPLS |
+ RTE_ETH_RSS_L2TPV2 | RTE_ETH_RSS_IB_BTH },
+ { "none", 0 },
+ { "ip", RTE_ETH_RSS_IP },
+ { "udp", RTE_ETH_RSS_UDP },
+ { "tcp", RTE_ETH_RSS_TCP },
+ { "sctp", RTE_ETH_RSS_SCTP },
+ { "tunnel", RTE_ETH_RSS_TUNNEL },
+ { "vlan", RTE_ETH_RSS_VLAN },
+
+ /* Individual type */
+ { "ipv4", RTE_ETH_RSS_IPV4 },
+ { "ipv4-frag", RTE_ETH_RSS_FRAG_IPV4 },
+ { "ipv4-tcp", RTE_ETH_RSS_NONFRAG_IPV4_TCP },
+ { "ipv4-udp", RTE_ETH_RSS_NONFRAG_IPV4_UDP },
+ { "ipv4-sctp", RTE_ETH_RSS_NONFRAG_IPV4_SCTP },
+ { "ipv4-other", RTE_ETH_RSS_NONFRAG_IPV4_OTHER },
+ { "ipv6", RTE_ETH_RSS_IPV6 },
+ { "ipv6-frag", RTE_ETH_RSS_FRAG_IPV6 },
+ { "ipv6-tcp", RTE_ETH_RSS_NONFRAG_IPV6_TCP },
+ { "ipv6-udp", RTE_ETH_RSS_NONFRAG_IPV6_UDP },
+ { "ipv6-sctp", RTE_ETH_RSS_NONFRAG_IPV6_SCTP },
+ { "ipv6-other", RTE_ETH_RSS_NONFRAG_IPV6_OTHER },
+ { "l2-payload", RTE_ETH_RSS_L2_PAYLOAD },
+ { "ipv6-ex", RTE_ETH_RSS_IPV6_EX },
+ { "ipv6-tcp-ex", RTE_ETH_RSS_IPV6_TCP_EX },
+ { "ipv6-udp-ex", RTE_ETH_RSS_IPV6_UDP_EX },
+ { "port", RTE_ETH_RSS_PORT },
+ { "vxlan", RTE_ETH_RSS_VXLAN },
+ { "geneve", RTE_ETH_RSS_GENEVE },
+ { "nvgre", RTE_ETH_RSS_NVGRE },
+ { "gtpu", RTE_ETH_RSS_GTPU },
+ { "eth", RTE_ETH_RSS_ETH },
+ { "s-vlan", RTE_ETH_RSS_S_VLAN },
+ { "c-vlan", RTE_ETH_RSS_C_VLAN },
+ { "esp", RTE_ETH_RSS_ESP },
+ { "ah", RTE_ETH_RSS_AH },
+ { "l2tpv3", RTE_ETH_RSS_L2TPV3 },
+ { "pfcp", RTE_ETH_RSS_PFCP },
+ { "pppoe", RTE_ETH_RSS_PPPOE },
+ { "ecpri", RTE_ETH_RSS_ECPRI },
+ { "mpls", RTE_ETH_RSS_MPLS },
+ { "ipv4-chksum", RTE_ETH_RSS_IPV4_CHKSUM },
+ { "l4-chksum", RTE_ETH_RSS_L4_CHKSUM },
+ { "l2tpv2", RTE_ETH_RSS_L2TPV2 },
+ { "l3-pre96", RTE_ETH_RSS_L3_PRE96 },
+ { "l3-pre64", RTE_ETH_RSS_L3_PRE64 },
+ { "l3-pre56", RTE_ETH_RSS_L3_PRE56 },
+ { "l3-pre48", RTE_ETH_RSS_L3_PRE48 },
+ { "l3-pre40", RTE_ETH_RSS_L3_PRE40 },
+ { "l3-pre32", RTE_ETH_RSS_L3_PRE32 },
+ { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY },
+ { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY },
+ { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY },
+ { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY },
+ { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY },
+ { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY },
+ { "ipv6-flow-label", RTE_ETH_RSS_IPV6_FLOW_LABEL },
+ { "ib-bth", RTE_ETH_RSS_IB_BTH },
+ { NULL, 0 },
+};
+
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_rss_type_info_get, 26.07)
+const struct rte_eth_rss_type_info *
+rte_eth_rss_type_info_get(void)
+{
+ return rte_eth_rss_type_table;
+}
+
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_rss_type_from_str, 26.07)
+int
+rte_eth_rss_type_from_str(const char *str, uint64_t *rss_type)
+{
+ unsigned int i;
+
+ if (str == NULL || rss_type == NULL)
+ return -EINVAL;
+
+ for (i = 0; rte_eth_rss_type_table[i].str != NULL; i++) {
+ if (strcmp(rte_eth_rss_type_table[i].str, str) == 0) {
+ *rss_type = rte_eth_rss_type_table[i].rss_type;
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_rss_type_to_str, 26.07)
+const char *
+rte_eth_rss_type_to_str(uint64_t rss_type)
+{
+ unsigned int i;
+
+ for (i = 0; rte_eth_rss_type_table[i].str != NULL; i++) {
+ if (rte_eth_rss_type_table[i].rss_type == rss_type)
+ return rte_eth_rss_type_table[i].str;
+ }
+
+ return NULL;
+}
+
RTE_EXPORT_SYMBOL(rte_eth_dev_udp_tunnel_port_add)
int
rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 0d8e2d0236..72f0a64e75 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -4889,6 +4889,66 @@ __rte_experimental
int
rte_eth_find_rss_algo(const char *name, uint32_t *algo);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ *
+ * RSS type name mapping entry.
+ *
+ * The table returned by rte_eth_rss_type_info_get() is terminated by an entry
+ * with a NULL string.
+ */
+struct rte_eth_rss_type_info {
+ const char *str; /**< RSS type name. */
+ uint64_t rss_type; /**< RSS type value (RTE_ETH_RSS_*). */
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
+ *
+ * Get the global RSS type string table.
+ *
+ * @return
+ * Pointer to a table of RSS type string mappings terminated by an entry with
+ * a NULL string.
+ */
+__rte_experimental
+const struct rte_eth_rss_type_info *
+rte_eth_rss_type_info_get(void);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
+ *
+ * Convert an RSS type name to its value.
+ *
+ * @param str
+ * RSS type name.
+ * @param rss_type
+ * Pointer to store RSS type value (RTE_ETH_RSS_*) on success.
+ * @return
+ * 0 on success, -EINVAL if str or rss_type is NULL, -ENOENT if not found.
+ */
+__rte_experimental
+int
+rte_eth_rss_type_from_str(const char *str, uint64_t *rss_type);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
+ *
+ * Convert an RSS type value to its name.
+ *
+ * @param rss_type
+ * RSS type value (RTE_ETH_RSS_*).
+ * @return
+ * RSS type name, or NULL if the value cannot be recognized.
+ */
+__rte_experimental
+const char *
+rte_eth_rss_type_to_str(uint64_t rss_type);
+
/**
* Add UDP tunneling port for a type of tunnel.
*
--
2.43.7
next prev parent reply other threads:[~2026-05-05 18:39 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 18:39 [PATCH v12 0/6] flow_parser: add shared parser library Lukas Sismis
2026-05-05 18:39 ` [PATCH v12 1/6] cmdline: include stddef.h for MSVC compatibility Lukas Sismis
2026-05-05 18:39 ` Lukas Sismis [this message]
2026-05-05 18:39 ` [PATCH v12 3/6] ethdev: add flow parser library Lukas Sismis
2026-05-05 18:39 ` [PATCH v12 4/6] app/testpmd: use flow parser from ethdev Lukas Sismis
2026-05-05 18:39 ` [PATCH v12 5/6] examples/flow_parsing: add flow parser demo Lukas Sismis
2026-05-05 18:39 ` [PATCH v12 6/6] test: add flow parser functional tests Lukas Sismis
2026-05-05 18:46 ` [PATCH v12 0/6] flow_parser: add shared parser library Lukáš Šišmiš
2026-05-05 21:59 ` Stephen Hemminger
2026-05-07 12:29 ` Lukáš Šišmiš
2026-05-06 3:29 ` [RFC PATCH 0/3] flow_compile: textual flow rule compiler Stephen Hemminger
2026-05-06 3:29 ` [RFC 1/3] flow_compile: introduce " Stephen Hemminger
2026-05-06 8:06 ` Bruce Richardson
2026-05-06 10:10 ` Konstantin Ananyev
2026-05-06 15:46 ` Stephen Hemminger
2026-05-06 15:56 ` Bruce Richardson
2026-05-06 17:11 ` Stephen Hemminger
2026-05-06 3:29 ` [RFC 2/3] doc: add programmer's guide for " Stephen Hemminger
2026-05-06 3:29 ` [RFC 3/3] test/flow_compile: add unit tests " Stephen Hemminger
2026-05-07 0:06 ` [RFC v2 0/4] flow_compile: textual " Stephen Hemminger
2026-05-07 0:06 ` [RFC v2 1/4] config: add support for using flex and bison Stephen Hemminger
2026-05-07 0:06 ` [RFC v2 2/4] flow_compile: introduce textual flow rule compiler Stephen Hemminger
2026-05-07 0:06 ` [RFC v2 3/4] doc: add programmer's guide for " Stephen Hemminger
2026-05-07 0:06 ` [RFC v2 4/4] test/flow_compile: add unit tests " Stephen Hemminger
2026-05-07 2:54 ` [RFC v2 0/4] flow_compile: textual " Stephen Hemminger
2026-05-07 8:10 ` Bruce Richardson
2026-05-07 16:09 ` Stephen Hemminger
2026-05-07 16:26 ` Bruce Richardson
2026-05-07 16:57 ` Stephen Hemminger
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=20260505183917.370281-3-sismis@dyna-nic.com \
--to=sismis@dyna-nic.com \
--cc=dev@dpdk.org \
--cc=orika@nvidia.com \
--cc=stephen@networkplumber.org \
--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