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 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 -- 2.33.0