From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3B08FF8855 for ; Tue, 5 May 2026 18:39:34 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4834F40693; Tue, 5 May 2026 20:39:26 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id DA25240664 for ; Tue, 5 May 2026 20:39:24 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-48374014a77so66208855e9.3 for ; Tue, 05 May 2026 11:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dyna-nic.com; s=google; t=1778006364; x=1778611164; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mSeHXxbxsP+pUkJfC6Vg/Ka0pOk/VvtMnxFPB9FaAl8=; b=e0jNSSlRb30bfMSvlroLsDsMfA0LfqxmQJ6Bzv57NGPqxip+pTdckuBQz9vyFwN6RG Xy+Z/u/smAyqnG3oPx3BAunvPUXaQxCx7w0jy4ogvWKHBQXDNafRG1SCvrWhLgUUvNkP IpvR0y0aUv69sR9YXZ/JqhivPAx/PTm+PxRKLWFp7re09qJ8acmOXz3jjsyAv7s5zp4N 7Jphvrh2I5aOzJmKIhjkKw5+4X/Kug0PmgtF51+3UwXGvD80ogCPuCIG+z1ad35JsWKu BUL1NTsVNFTFpGhF9v7hWdji70GN0kj2ZV/tIrlfTjCfcD0zNOY+r1XwVkjbM+DSP3/0 Scrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778006364; x=1778611164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mSeHXxbxsP+pUkJfC6Vg/Ka0pOk/VvtMnxFPB9FaAl8=; b=cVIGYtsoDBRRWJOhUZfVdkusu2f4DC+oMiJ1NQSd2q7Oyt2IP5HnRo7xeVQlvW+tKe aQIQZGF8BetatDEnHbp9ks0KHOt512RbPEom1MhAZdmkC/TTXFDtQSsSxosmtThKB3df m9ra3q9WdzJbX5AhMkFAt+KbTxw/NnL7L/egZHz6f9qhI9bFeBd9QjpNetuBY9aiigJl Afj19xIYhJu2nn+qWMmacuHBW543/jtuEmhihJKUx//5T6/49foPVuHbUqDhvDEZtjgS uSQzqUWCclvEI6jSTl/QQblLTr4rnW6PYgJcj7H5ICrUYWAIETxZVDVGd8jEhS3EHxpW E46A== X-Gm-Message-State: AOJu0YxMYCJBrJyEpzc4a30tMaLVIMof2VoE16/3ikGCWnR82zbUJiMs sfoQLuGgraXfegs6yrH7j8qE+nzoFDycH21Z8WzjmHZFOQdRAw16wwAugN7lL8X4C89KooT/J6B 7OM7y X-Gm-Gg: AeBDievTjcQm6+EETl+c39GzDXfmQhVD2i/yO3JKe440ySLisoEWNAlSveav5I+p/BI 6JwUgUzHUtXFa36MHs2ZsELvyAFDTUImmtVmfavSED+OrYyvBbvwNqu+HIrqWZRm5vGmuLEzNKD pNbg4YLcbuNlIXspXl8aFyuc+sUye8+M9fqTgOhEyf38gAvEu+SJv/KsagyDQLaLFcIiRFlnS3S XgypEcWHtFD0gBY4lUVcYmdKW4UEKWkhmbBkKNUl1oU52Ls9zk6M2WDu4gnj4L2P3552molx5WY y4AZZDrTbcOnLwuqshHBIPRurVW4cmzAXQxGoDLHq6fZPLE0JA/XQDxV9NvxIqrn0F/mYJ1D5iA 7/q26kapfaagoTsqjShWc5RlUHQvItONzK06971Ey+eXjcZ5csL0cwol8821ps1ccF8OUhFxJDT aalyyF+n3p/4iJkT0fc2wt+B3Q1LELGD3G5O4axdNU64GOzrcmuP6/jt/GhRlflJ476KFZd0mXY g== X-Received: by 2002:a05:600c:3548:b0:489:1c1f:35f1 with SMTP id 5b1f17b1804b1-48e51e09706mr6983895e9.4.1778006364289; Tue, 05 May 2026 11:39:24 -0700 (PDT) Received: from dpdk-test3.liberouter.org (rt-tmc-kou.liberouter.org. [195.113.172.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45054b02abbsm6197067f8f.18.2026.05.05.11.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 11:39:23 -0700 (PDT) From: Lukas Sismis To: dev@dpdk.org Cc: orika@nvidia.com, stephen@networkplumber.org, thomas@monjalon.net, Lukas Sismis Subject: [PATCH v12 2/6] ethdev: add RSS type helper APIs Date: Tue, 5 May 2026 20:39:09 +0200 Message-ID: <20260505183917.370281-3-sismis@dyna-nic.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260505183917.370281-1-sismis@dyna-nic.com> References: <20260505183917.370281-1-sismis@dyna-nic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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 +#include + #include #include @@ -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