From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE7EC4326B; Thu, 2 Nov 2023 09:24:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2908F4113D; Thu, 2 Nov 2023 09:24:07 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id EB24E402EB for ; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SLcNB293YzvQRt; Thu, 2 Nov 2023 16:23:54 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 2 Nov 2023 16:23:56 +0800 From: Jie Hai To: , Aman Singh , Yuying Zhang , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , , Subject: [PATCH v9 7/9] ethdev: add API to get RSS algorithm names Date: Thu, 2 Nov 2023 16:20:18 +0800 Message-ID: <20231102082020.2588392-8-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231102082020.2588392-1-haijie1@huawei.com> References: <20230315110033.30143-1-liudongdong3@huawei.com> <20231102082020.2588392-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected 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 This patch adds new API rte_eth_dev_rss_algo_name() to get name of a RSS algorithm and document it. Signed-off-by: Jie Hai Acked-by: Huisong Li Acked-by: Chengwen Feng --- app/test-pmd/config.c | 19 +------------------ doc/guides/rel_notes/release_23_11.rst | 5 +++++ lib/ethdev/rte_ethdev.c | 25 +++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 16 ++++++++++++++++ lib/ethdev/version.map | 1 + 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b9fdb7e8f162..a3e32aa852d8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1504,24 +1504,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) printf(" %d", rss_conf->queue[i]); printf("\n"); - printf(" function: "); - switch (rss_conf->func) { - case RTE_ETH_HASH_FUNCTION_DEFAULT: - printf("default\n"); - break; - case RTE_ETH_HASH_FUNCTION_TOEPLITZ: - printf("toeplitz\n"); - break; - case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: - printf("simple_xor\n"); - break; - case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: - printf("symmetric_toeplitz\n"); - break; - default: - printf("Unknown function\n"); - return; - } + printf(" function: %s\n", rte_eth_dev_rss_algo_name(rss_conf->func)); printf(" RSS key:\n"); if (rss_conf->key_len == 0) { diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 20556b8a17ce..e40429a2f853 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -129,6 +129,11 @@ New Features * Added new field ``algorithm`` to ``rte_eth_rss_conf`` structure for RSS hash algorithm querying and configuring. +* **Added new API for RSS hash algorithm** + + Added new function ``rte_eth_dev_rss_algo_name`` to get name of RSS hash + algorithm. + * **Updated Amazon ena (Elastic Network Adapter) net driver.** * Upgraded ENA HAL to latest version. diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 36d8deef90c5..33636529eb12 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -160,6 +160,17 @@ enum { STAT_QMAP_RX }; +static const struct { + enum rte_eth_hash_function algo; + const char *name; +} rte_eth_dev_rss_algo_names[] = { + {RTE_ETH_HASH_FUNCTION_DEFAULT, "default"}, + {RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, "simple_xor"}, + {RTE_ETH_HASH_FUNCTION_TOEPLITZ, "toeplitz"}, + {RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, "symmetric_toeplitz"}, + {RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT, "symmetric_toeplitz_sort"}, +}; + int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) { @@ -4791,6 +4802,20 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id, return ret; } +const char * +rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo) +{ + const char *name = "Unknown function"; + unsigned int i; + + for (i = 0; i < RTE_DIM(rte_eth_dev_rss_algo_names); i++) { + if (rss_algo == rte_eth_dev_rss_algo_names[i].algo) + return rte_eth_dev_rss_algo_names[i].name; + } + + return name; +} + int rte_eth_dev_udp_tunnel_port_add(uint16_t port_id, struct rte_eth_udp_tunnel *udp_tunnel) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 37d8ef694523..2042c19bca81 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4643,6 +4643,22 @@ int rte_eth_dev_rss_hash_conf_get(uint16_t port_id, struct rte_eth_rss_conf *rss_conf); +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * Get the name of RSS hash algorithm. + * + * @param rss_algo + * Hash algorithm. + * + * @return + * Hash algorithm name or 'UNKNOWN' if the rss_algo cannot be recognized. + */ +__rte_experimental +const char * +rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo); + /** * Add UDP tunneling port for a type of tunnel. * diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 919ba5b8e65b..9336522b713c 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -314,6 +314,7 @@ EXPERIMENTAL { rte_flow_restore_info_dynflag; # added in 23.11 + rte_eth_dev_rss_algo_name; rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; -- 2.30.0