From patchwork Thu Nov 30 10:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 134733 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5B5F4340F; Thu, 30 Nov 2023 11:48:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DD0042EC9; Thu, 30 Nov 2023 11:48:04 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 6AD3642E94 for ; Thu, 30 Nov 2023 11:48:01 +0100 (CET) Received: from kwepemd100004.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SgtDd5c8HzWhty; Thu, 30 Nov 2023 18:47:13 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Thu, 30 Nov 2023 18:47:58 +0800 From: Jie Hai To: , , , CC: , Subject: [RESEND 1/2] ethdev: add new API to get RSS hash algorithm by name Date: Thu, 30 Nov 2023 18:44:14 +0800 Message-ID: <20231130104415.1064644-2-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231130104415.1064644-1-haijie1@huawei.com> References: <20231122094900.788126-1-haijie1@huawei.com> <20231130104415.1064644-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd100004.china.huawei.com (7.221.188.31) 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 supports conversion from names to hash algorithm (see RTE_ETH_HASH_FUNCTION_XXX). Signed-off-by: Jie Hai Reviewed-by: Huisong Li Reviewed-by: Ferruh Yigit --- doc/guides/rel_notes/release_24_03.rst | 5 +++++ lib/ethdev/rte_ethdev.c | 15 +++++++++++++++ lib/ethdev/rte_ethdev.h | 20 ++++++++++++++++++++ lib/ethdev/version.map | 3 +++ 4 files changed, 43 insertions(+) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index e9c9717706a0..bd84875d4f17 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Improved support of RSS hash algorithm.** + + * Added new function ``rte_eth_find_rss_algo`` to get RSS hash + algorithm by its name. + Removed Items ------------- diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 3858983fcc80..c0398d945502 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -4826,6 +4826,21 @@ rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo) return name; } +int +rte_eth_find_rss_algo(const char *name, uint32_t *algo) +{ + unsigned int i; + + for (i = 0; i < RTE_DIM(rte_eth_dev_rss_algo_names); i++) { + if (strcmp(name, rte_eth_dev_rss_algo_names[i].name) == 0) { + *algo = rte_eth_dev_rss_algo_names[i].algo; + return 0; + } + } + + return -EINVAL; +} + 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 77331ce6525e..3bde5c4c17a6 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4667,6 +4667,26 @@ __rte_experimental const char * rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo); +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. + * + * Get RSS hash algorithm by its name. + * + * @param name + * RSS hash algorithm. + * + * @param algo + * return the RSS hash algorithm found, @see rte_eth_hash_function. + * + * @return + * - (0) if successful. + * - (-EINVAL) if not found. + */ +__rte_experimental +int +rte_eth_find_rss_algo(const char *name, uint32_t *algo); + /** * Add UDP tunneling port for a type of tunnel. * diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 5c4917c020dc..a050baab0fe7 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -316,6 +316,9 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_eth_find_rss_algo; }; INTERNAL { From patchwork Thu Nov 30 10:44:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 134734 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 447734340F; Thu, 30 Nov 2023 11:48:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C034B42ED0; Thu, 30 Nov 2023 11:48:05 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 0CA5942E97 for ; Thu, 30 Nov 2023 11:48:02 +0100 (CET) Received: from kwepemd100004.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Sgt9J2wRwz1P8yr; Thu, 30 Nov 2023 18:44:20 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Thu, 30 Nov 2023 18:47:59 +0800 From: Jie Hai To: , , , CC: , Subject: [RESEND 2/2] app/testpmd: support set RSS hash algorithm Date: Thu, 30 Nov 2023 18:44:15 +0800 Message-ID: <20231130104415.1064644-3-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231130104415.1064644-1-haijie1@huawei.com> References: <20231122094900.788126-1-haijie1@huawei.com> <20231130104415.1064644-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd100004.china.huawei.com (7.221.188.31) 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 Since API rte_eth_dev_rss_hash_update() supports setting RSS hash algorithm, add new command to support it: testpmd> port config 0 rss-hash-algo symmetric_toeplitz Signed-off-by: Jie Hai Reviewed-by: Huisong Li --- app/test-pmd/cmdline.c | 79 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +++ 2 files changed, 90 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 9369d3b4c526..2cd85c918a09 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -726,6 +726,10 @@ static void cmd_help_long_parsed(void *parsed_result, "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" " Set the RSS redirection table.\n\n" + "port config port-id rss-hash-algo (default|simple_xor|toeplitz|" + "symmetric_toeplitz|symmetric_toeplitz_sort)\n" + " Set the RSS hash algorithm.\n\n" + "port config (port_id) dcb vt (on|off) (traffic_class)" " pfc (on|off)\n" " Set the DCB mode.\n\n" @@ -2275,6 +2279,80 @@ static cmdline_parse_inst_t cmd_config_rss_hash_key = { }, }; +/* *** configure rss hash algorithm *** */ +struct cmd_config_rss_hash_algo { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + portid_t port_id; + cmdline_fixed_string_t rss_hash_algo; + cmdline_fixed_string_t algo; +}; + +static void +cmd_config_rss_hash_algo_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_config_rss_hash_algo *res = parsed_result; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; + struct rte_eth_rss_conf rss_conf; + int ret; + + rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH; + rss_conf.rss_key = rss_key; + ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf); + if (ret != 0) { + fprintf(stderr, "failed to get port %u RSS confinguration\n", + res->port_id); + return; + } + + ret = rte_eth_find_rss_algo(res->algo, &rss_conf.algorithm); + if (ret != 0) { + fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n", + res->port_id, res->algo); + return; + } + + ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf); + if (ret != 0) { + fprintf(stderr, "failed to set port %u RSS hash algorithm\n", + res->port_id); + return; + } +} + +static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port"); +static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config, + "config"); +static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id, + RTE_UINT16); +static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, + rss_hash_algo, "rss-hash-algo"); +static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo, + "default#simple_xor#toeplitz#" + "symmetric_toeplitz#symmetric_toeplitz_sort"); + +static cmdline_parse_inst_t cmd_config_rss_hash_algo = { + .f = cmd_config_rss_hash_algo_parsed, + .data = NULL, + .help_str = "port config rss-hash-algo " + "(default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort)", + .tokens = { + (void *)&cmd_config_rss_hash_algo_port, + (void *)&cmd_config_rss_hash_algo_config, + (void *)&cmd_config_rss_hash_algo_port_id, + (void *)&cmd_config_rss_hash_algo_rss_hash_algo, + (void *)&cmd_config_rss_hash_algo_algo, + NULL, + }, +}; + /* *** cleanup txq mbufs *** */ struct cmd_cleanup_txq_mbufs_result { cmdline_fixed_string_t port; @@ -13165,6 +13243,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, (cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo, (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, + (cmdline_parse_inst_t *)&cmd_config_rss_hash_algo, (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 447e28e6944f..3c7d20c2db82 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2263,6 +2263,17 @@ hash of input [IP] packets received on port:: ipv6-udp-ex ) + +port config rss hash algorithm +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To configure the RSS hash algorithm used to compute the RSS +hash of input packets received on port:: + + testpmd> port config rss-hash-algo (default|\ + simple_xor|toeplitz|symmetric_toeplitz|\ + symmetric_toeplitz_sort) + port cleanup txq mbufs ~~~~~~~~~~~~~~~~~~~~~~