From patchwork Mon Sep 4 06:10:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 131132 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 75022424EC; Mon, 4 Sep 2023 08:14:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71405402C6; Mon, 4 Sep 2023 08:14:33 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 078D6402B0 for ; Mon, 4 Sep 2023 08:14:32 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RfJG518mczrS8w; Mon, 4 Sep 2023 14:12:45 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) 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; Mon, 4 Sep 2023 14:14:30 +0800 From: Jie Hai To: , Reshma Pattan , Vipin Varghese , John McNamara CC: , Subject: [PATCH v3 1/5] app/proc-info: fix never show RSS info Date: Mon, 4 Sep 2023 14:10:40 +0800 Message-ID: <20230904061044.5692-2-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230904061044.5692-1-haijie1@huawei.com> References: <20230826074607.16771-1-haijie1@huawei.com> <20230904061044.5692-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 Command show-port should show RSS info (rss_key, len and rss_hf), However, the information is showned only when rss_conf.rss_key is not NULL. Since no memory is allocated for rss_conf.rss_key, rss_key will always be NULL and the rss_info will never show. This patch allocates memory for rss_conf.rss_key and makes it possible to show RSS info. Fixes: 8a37f37fc243 ("app/procinfo: add --show-port") Cc: stable@dpdk.org Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu --- app/proc-info/main.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 88cee0ca487b..f6b77a705dce 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -1013,6 +1013,7 @@ show_port(void) struct rte_eth_fc_conf fc_conf; struct rte_ether_addr mac; struct rte_eth_dev_owner owner; + uint8_t *rss_key; /* Skip if port is not in mask */ if ((enabled_port_mask & (1ul << i)) == 0) @@ -1171,19 +1172,25 @@ show_port(void) printf("\n"); } + rss_key = malloc(dev_info.hash_key_size * sizeof(uint8_t)); + if (rss_key == NULL) + return; + + rss_conf.rss_key = rss_key; + rss_conf.rss_key_len = dev_info.hash_key_size; ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf); if (ret == 0) { - if (rss_conf.rss_key) { - printf(" - RSS\n"); - printf("\t -- RSS len %u key (hex):", - rss_conf.rss_key_len); - for (k = 0; k < rss_conf.rss_key_len; k++) - printf(" %x", rss_conf.rss_key[k]); - printf("\t -- hf 0x%"PRIx64"\n", - rss_conf.rss_hf); - } + printf(" - RSS\n"); + printf("\t -- RSS len %u key (hex):", + rss_conf.rss_key_len); + for (k = 0; k < rss_conf.rss_key_len; k++) + printf(" %x", rss_conf.rss_key[k]); + printf("\t -- hf 0x%"PRIx64"\n", + rss_conf.rss_hf); } + free(rss_key); + #ifdef RTE_LIB_SECURITY show_security_context(i, true); #endif From patchwork Mon Sep 4 06:10:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 131133 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 49888424EC; Mon, 4 Sep 2023 08:14:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90C46402CB; Mon, 4 Sep 2023 08:14:34 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id C3C4E402B0 for ; Mon, 4 Sep 2023 08:14:32 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RfJDK3LV0z1DDVw; Mon, 4 Sep 2023 14:11:13 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) 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; Mon, 4 Sep 2023 14:14:30 +0800 From: Jie Hai To: , Reshma Pattan , John McNamara , Vipin Varghese CC: , Subject: [PATCH v3 2/5] app/proc-info: adjust the display format of RSS info Date: Mon, 4 Sep 2023 14:10:41 +0800 Message-ID: <20230904061044.5692-3-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230904061044.5692-1-haijie1@huawei.com> References: <20230826074607.16771-1-haijie1@huawei.com> <20230904061044.5692-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 splits the length and value of RSS key into two parts, removes spaces between RSS keys, and adds line breaks between RSS key and RSS hf. Before the adjustment, RSS info is shown as: - RSS -- RSS len 40 key (hex): 6d 5a 56 da 25 5b e c2 41 67 \ 25 3d 43 a3 8f b0 d0 ca 2b cb ae 7b 30 b4 77 cb 2d \ a3 80 30 f2 c 6a 42 b7 3b be ac 1 fa -- hf 0x0 and after: - RSS info -- key len : 40 -- key (hex) : 6d5a56da255b0ec24167253d43a38fb0d0c \ a2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa -- hf : 0x0 Fixes: 8a37f37fc243 ("app/procinfo: add --show-port") Cc: stable@dpdk.org Signed-off-by: Jie Hai --- app/proc-info/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index f6b77a705dce..6d2d77fea6ba 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -1180,12 +1180,13 @@ show_port(void) rss_conf.rss_key_len = dev_info.hash_key_size; ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf); if (ret == 0) { - printf(" - RSS\n"); - printf("\t -- RSS len %u key (hex):", + printf(" - RSS info\n"); + printf("\t -- key len : %u\n", rss_conf.rss_key_len); + printf("\t -- key (hex) : "); for (k = 0; k < rss_conf.rss_key_len; k++) - printf(" %x", rss_conf.rss_key[k]); - printf("\t -- hf 0x%"PRIx64"\n", + printf("%02x", rss_conf.rss_key[k]); + printf("\n\t -- hf : 0x%"PRIx64"\n", rss_conf.rss_hf); } From patchwork Mon Sep 4 06:10:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 131134 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 4B8C3424EC; Mon, 4 Sep 2023 08:14:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8601402D2; Mon, 4 Sep 2023 08:14:35 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 415EB402A9 for ; Mon, 4 Sep 2023 08:14:33 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RfJCw0wwvzNn7L for ; Mon, 4 Sep 2023 14:10:52 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) 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; Mon, 4 Sep 2023 14:14:31 +0800 From: Jie Hai To: , Reshma Pattan CC: , Subject: [PATCH v3 3/5] app/proc-info: support querying RSS hash algorithm Date: Mon, 4 Sep 2023 14:10:42 +0800 Message-ID: <20230904061044.5692-4-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230904061044.5692-1-haijie1@huawei.com> References: <20230826074607.16771-1-haijie1@huawei.com> <20230904061044.5692-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 Display RSS hash algorithm with command show-port as below. - RSS info -- hash algorithm : toeplitz Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu --- app/proc-info/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 6d2d77fea6ba..02b418a4c661 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -996,6 +996,23 @@ show_offloads(uint64_t offloads, } } +static const char * +rss_func_to_str(enum rte_eth_hash_function func) +{ + switch (func) { + case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: + return "simple_xor"; + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + return "toeplitz"; + case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: + return "symmetric_toeplitz"; + case RTE_ETH_HASH_FUNCTION_DEFAULT: + return "default"; + default: + return "unknown"; + } +} + static void show_port(void) { @@ -1188,6 +1205,8 @@ show_port(void) printf("%02x", rss_conf.rss_key[k]); printf("\n\t -- hf : 0x%"PRIx64"\n", rss_conf.rss_hf); + printf("\t -- hash algorithm : %s\n", + rss_func_to_str(rss_conf.func)); } free(rss_key); From patchwork Mon Sep 4 06:10:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 131135 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 27590424EC; Mon, 4 Sep 2023 08:14:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2ECE402DC; Mon, 4 Sep 2023 08:14:36 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 94C2E402C8 for ; Mon, 4 Sep 2023 08:14:33 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RfJCb26XGztSCc for ; Mon, 4 Sep 2023 14:10:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) 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; Mon, 4 Sep 2023 14:14:31 +0800 From: Jie Hai To: , Aman Singh , Yuying Zhang CC: , Subject: [PATCH v3 4/5] app/testpmd: add RSS hash algorithms display Date: Mon, 4 Sep 2023 14:10:43 +0800 Message-ID: <20230904061044.5692-5-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230904061044.5692-1-haijie1@huawei.com> References: <20230826074607.16771-1-haijie1@huawei.com> <20230904061044.5692-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 1. Add the command "show port X rss-hash func" to display the RSS hash algorithms of port X. 2. Add the command "show port X rss-hash all" to display the RSS hash configuration of port X, including RSS hash types, key and algorithms. Signed-off-by: Jie Hai --- app/test-pmd/cmdline.c | 50 +++++++++++++++++++++++++++++++++++++----- app/test-pmd/config.c | 46 +++++++++++++++++++++++--------------- app/test-pmd/testpmd.h | 2 +- 3 files changed, 74 insertions(+), 24 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0d0723f6596e..e7888be305da 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -174,8 +174,8 @@ static void cmd_help_long_parsed(void *parsed_result, " by masks on port X. size is used to indicate the" " hardware supported reta size\n\n" - "show port (port_id) rss-hash [key]\n" - " Display the RSS hash functions and RSS hash key of port\n\n" + "show port (port_id) rss-hash [key | func | all]\n" + " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n" "clear port (info|stats|xstats|fdir) (port_id|all)\n" " Clear information for port_id, or all.\n\n" @@ -3017,15 +3017,21 @@ struct cmd_showport_rss_hash { cmdline_fixed_string_t rss_hash; cmdline_fixed_string_t rss_type; cmdline_fixed_string_t key; /* optional argument */ + cmdline_fixed_string_t func; /* optional argument */ + cmdline_fixed_string_t all; /* optional argument */ }; static void cmd_showport_rss_hash_parsed(void *parsed_result, __rte_unused struct cmdline *cl, - void *show_rss_key) + __rte_unused void *data) { struct cmd_showport_rss_hash *res = parsed_result; - port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); + if (!strcmp(res->all, "all")) + port_rss_hash_conf_show(res->port_id, true, true); + else + port_rss_hash_conf_show(res->port_id, + !strcmp(res->key, "key"), !strcmp(res->func, "func")); } static cmdline_parse_token_string_t cmd_showport_rss_hash_show = @@ -3040,6 +3046,10 @@ static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = "rss-hash"); static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); +static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_func = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, func, "func"); +static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_all = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, all, "all"); static cmdline_parse_inst_t cmd_showport_rss_hash = { .f = cmd_showport_rss_hash_parsed, @@ -3056,7 +3066,7 @@ static cmdline_parse_inst_t cmd_showport_rss_hash = { static cmdline_parse_inst_t cmd_showport_rss_hash_key = { .f = cmd_showport_rss_hash_parsed, - .data = (void *)1, + .data = NULL, .help_str = "show port rss-hash key", .tokens = { (void *)&cmd_showport_rss_hash_show, @@ -3068,6 +3078,34 @@ static cmdline_parse_inst_t cmd_showport_rss_hash_key = { }, }; +static cmdline_parse_inst_t cmd_showport_rss_hash_func = { + .f = cmd_showport_rss_hash_parsed, + .data = NULL, + .help_str = "show port rss-hash func", + .tokens = { + (void *)&cmd_showport_rss_hash_show, + (void *)&cmd_showport_rss_hash_port, + (void *)&cmd_showport_rss_hash_port_id, + (void *)&cmd_showport_rss_hash_rss_hash, + (void *)&cmd_showport_rss_hash_rss_func, + NULL, + }, +}; + +static cmdline_parse_inst_t cmd_showport_rss_hash_all = { + .f = cmd_showport_rss_hash_parsed, + .data = NULL, + .help_str = "show port rss-hash all", + .tokens = { + (void *)&cmd_showport_rss_hash_show, + (void *)&cmd_showport_rss_hash_port, + (void *)&cmd_showport_rss_hash_port_id, + (void *)&cmd_showport_rss_hash_rss_hash, + (void *)&cmd_showport_rss_hash_rss_all, + NULL, + }, +}; + /* *** Configure DCB *** */ struct cmd_config_dcb { cmdline_fixed_string_t port; @@ -12905,6 +12943,8 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, (cmdline_parse_inst_t *)&cmd_showport_rss_hash, (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, + (cmdline_parse_inst_t *)&cmd_showport_rss_hash_func, + (cmdline_parse_inst_t *)&cmd_showport_rss_hash_all, (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, (cmdline_parse_inst_t *)&cmd_dump, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 11f3a2204839..65eca8467d61 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1485,6 +1485,27 @@ rss_types_display(uint64_t rss_types, uint16_t char_num_per_line) printf("\n"); } +static void rss_algo_display(enum rte_eth_hash_function func) +{ + switch (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; + } +} + static void rss_config_display(struct rte_flow_action_rss *rss_conf) { @@ -1504,23 +1525,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) 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; - } + rss_algo_display(rss_conf->func); printf(" RSS key:\n"); if (rss_conf->key_len == 0) { @@ -4406,7 +4411,7 @@ port_rss_reta_info(portid_t port_id, * key of the port. */ void -port_rss_hash_conf_show(portid_t port_id, int show_rss_key) +port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_func) { struct rte_eth_rss_conf rss_conf = {0}; uint8_t rss_key[RSS_HASH_KEY_LENGTH]; @@ -4458,6 +4463,11 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) } printf("RSS functions:\n"); rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); + + if (show_rss_func) { + printf("RSS algorithms:\n "); + rss_algo_display(rss_conf.func); + } if (!show_rss_key) return; printf("RSS key:\n"); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index f1df6a8fafaa..3dc2f47280ad 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1146,7 +1146,7 @@ int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate, int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id, uint8_t avail_thresh); -void port_rss_hash_conf_show(portid_t port_id, int show_rss_key); +void port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_func); void port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key, uint8_t hash_key_len); int rx_queue_id_is_invalid(queueid_t rxq_id); From patchwork Mon Sep 4 06:10:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 131136 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 E5ACC424EC; Mon, 4 Sep 2023 08:14:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE9EF402E2; Mon, 4 Sep 2023 08:14:37 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3162F402CC for ; Mon, 4 Sep 2023 08:14:34 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RfJG71jxrzrSDT for ; Mon, 4 Sep 2023 14:12:47 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) 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; Mon, 4 Sep 2023 14:14:32 +0800 From: Jie Hai To: , Aman Singh , Yuying Zhang CC: , Subject: [PATCH v3 5/5] app/testpmd: add RSS hash algorithms setting Date: Mon, 4 Sep 2023 14:10:44 +0800 Message-ID: <20230904061044.5692-6-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230904061044.5692-1-haijie1@huawei.com> References: <20230826074607.16771-1-haijie1@huawei.com> <20230904061044.5692-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 Add command "port config rss-hash-func " to set RSS hash algorithms. Signed-off-by: Jie Hai --- app/test-pmd/cmdline.c | 78 ++++++++++++++++++++++++++++++++++++++++-- app/test-pmd/config.c | 16 ++++----- app/test-pmd/testpmd.h | 3 +- 3 files changed, 84 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index e7888be305da..375f16fcee14 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2136,6 +2136,76 @@ static cmdline_parse_inst_t cmd_config_rss = { }, }; +/* *** configure rss hash algorithms *** */ +struct cmd_config_rss_hash_func { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + portid_t port_id; + cmdline_fixed_string_t rss_hash_func; + cmdline_fixed_string_t func; +}; + +static void +cmd_config_rss_hash_func_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_config_rss_hash_func *res = parsed_result; + struct rte_eth_rss_conf rss_conf = {0}; + struct { + const char *name; + enum rte_eth_hash_function func; + } hash_func_map[] = { + {"default", RTE_ETH_HASH_FUNCTION_DEFAULT}, + {"toeplitz", RTE_ETH_HASH_FUNCTION_TOEPLITZ}, + {"simple_xor", RTE_ETH_HASH_FUNCTION_SIMPLE_XOR}, + {"symmetric_toeplitz", RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ}, + {NULL, RTE_ETH_HASH_FUNCTION_MAX}, + }; + int i = 0; + + rss_conf.func = RTE_ETH_HASH_FUNCTION_MAX; + while (hash_func_map[i].name != NULL) { + if (!strcmp(hash_func_map[i].name, res->func)) { + rss_conf.func = hash_func_map[i].func; + break; + } + i++; + } + + port_rss_hash_key_update(res->port_id, &rss_conf); +} + +static cmdline_parse_token_string_t cmd_config_rss_hash_func_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, port, "port"); +static cmdline_parse_token_string_t cmd_config_rss_hash_func_config = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, config, + "config"); +static cmdline_parse_token_num_t cmd_config_rss_hash_func_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_func, port_id, + RTE_UINT16); +static cmdline_parse_token_string_t cmd_config_rss_hash_func_rss_hash_func = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, + rss_hash_func, "rss-hash-func"); +static cmdline_parse_token_string_t cmd_config_rss_hash_func_value = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, func, + "default#toeplitz#simple_xor#symmetric_toeplitz"); + +static cmdline_parse_inst_t cmd_config_rss_hash_func = { + .f = cmd_config_rss_hash_func_parsed, + .data = NULL, + .help_str = "port config rss-hash-func" + "default|toeplitz|simple_xor|symmetric_toeplitz", + .tokens = { + (void *)&cmd_config_rss_hash_func_port, + (void *)&cmd_config_rss_hash_func_config, + (void *)&cmd_config_rss_hash_func_port_id, + (void *)&cmd_config_rss_hash_func_rss_hash_func, + (void *)&cmd_config_rss_hash_func_value, + NULL, + }, +}; + /* *** configure rss hash key *** */ struct cmd_config_rss_hash_key { cmdline_fixed_string_t port; @@ -2182,6 +2252,7 @@ cmd_config_rss_hash_key_parsed(void *parsed_result, uint8_t xdgt0; uint8_t xdgt1; int i; + struct rte_eth_rss_conf rss_conf = {0}; struct rte_eth_dev_info dev_info; uint8_t hash_key_size; uint32_t key_len; @@ -2217,8 +2288,10 @@ cmd_config_rss_hash_key_parsed(void *parsed_result, return; hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); } - port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, - hash_key_size); + rss_conf.rss_key = hash_key; + rss_conf.rss_key_len = hash_key_size; + rss_conf.rss_hf = str_to_rsstypes(res->rss_type); + port_rss_hash_key_update(res->port_id, &rss_conf); } static cmdline_parse_token_string_t cmd_config_rss_hash_key_port = @@ -12946,6 +13019,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_showport_rss_hash_func, (cmdline_parse_inst_t *)&cmd_showport_rss_hash_all, (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, + (cmdline_parse_inst_t *)&cmd_config_rss_hash_func, (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 65eca8467d61..2f27642c31d2 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -4477,21 +4477,19 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_func) } void -port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key, - uint8_t hash_key_len) +port_rss_hash_key_update(portid_t port_id, struct rte_eth_rss_conf *conf) { - struct rte_eth_rss_conf rss_conf; + struct rte_eth_rss_conf rss_conf = {0}; int diag; - rss_conf.rss_key = NULL; - rss_conf.rss_key_len = 0; - rss_conf.rss_hf = str_to_rsstypes(rss_type); diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); if (diag == 0) { - rss_conf.rss_key = hash_key; - rss_conf.rss_key_len = hash_key_len; - diag = rte_eth_dev_rss_hash_update(port_id, &rss_conf); + conf->rss_key = conf->rss_key == NULL ? rss_conf.rss_key : conf->rss_key; + conf->rss_key_len = conf->rss_key_len == 0 ? rss_conf.rss_key_len : conf->rss_key_len; + conf->rss_hf = conf->rss_hf == 0 ? rss_conf.rss_hf : conf->rss_hf; + diag = rte_eth_dev_rss_hash_update(port_id, conf); } + if (diag == 0) return; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 3dc2f47280ad..8ec7fd39e586 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1147,8 +1147,7 @@ int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id, uint8_t avail_thresh); void port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_func); -void port_rss_hash_key_update(portid_t port_id, char rss_type[], - uint8_t *hash_key, uint8_t hash_key_len); +void port_rss_hash_key_update(portid_t port_id, struct rte_eth_rss_conf *rss_conf); int rx_queue_id_is_invalid(queueid_t rxq_id); int tx_queue_id_is_invalid(queueid_t txq_id); #ifdef RTE_LIB_GRO