From patchwork Sat Oct 28 01:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133532 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 79C164321C; Sat, 28 Oct 2023 03:49:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F34B40ED8; Sat, 28 Oct 2023 03:49:48 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 1DFDC40291 for ; Sat, 28 Oct 2023 03:49:40 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SHMmf2pjjzMmGm; Sat, 28 Oct 2023 09:45:22 +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; Sat, 28 Oct 2023 09:49:37 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ori Kam CC: , , , Subject: [PATCH v7 1/9] ethdev: overwrite some comment related to RSS Date: Sat, 28 Oct 2023 09:46:03 +0800 Message-ID: <20231028014611.4086500-2-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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. overwrite the comments of fields of 'rte_eth_rss_conf'. 2. Add comments for RTE_ETH_HASH_FUNCTION_DEFAULT. Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.h | 33 ++++++++++++++++++--------------- lib/ethdev/rte_flow.h | 1 + 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 2fd3cd808dbf..37fd5afef48a 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -448,24 +448,27 @@ struct rte_vlan_filter_conf { /** * A structure used to configure the Receive Side Scaling (RSS) feature * of an Ethernet port. - * If not NULL, the *rss_key* pointer of the *rss_conf* structure points - * to an array holding the RSS key to use for hashing specific header - * fields of received packets. The length of this array should be indicated - * by *rss_key_len* below. Otherwise, a default random hash key is used by - * the device driver. - * - * The *rss_key_len* field of the *rss_conf* structure indicates the length - * in bytes of the array pointed by *rss_key*. To be compatible, this length - * will be checked in i40e only. Others assume 40 bytes to be used as before. - * - * The *rss_hf* field of the *rss_conf* structure indicates the different - * types of IPv4/IPv6 packets to which the RSS hashing must be applied. - * Supplying an *rss_hf* equal to zero disables the RSS feature. */ struct rte_eth_rss_conf { - uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */ + /** + * In rte_eth_dev_rss_hash_conf_get(), the *rss_key_len* should be + * greater than or equal to the hash_key_size which get from + * rte_eth_dev_info_get() API. And the *rss_key* should contain at least + * *rss_key_len* bytes. If not meet these requirements, the query result + * is unreliable even the operation returns success. + * + * In rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(), the + * *rss_key_len* indicates the length of the *rss_key* in bytes of + * the array pointed by *rss_key*. Drivers are free to ignore the + * *rss_key_len* and assume key length is 40 bytes. + */ + uint8_t *rss_key; uint8_t rss_key_len; /**< hash key length in bytes. */ - uint64_t rss_hf; /**< Hash functions to apply - see below. */ + /** + * Indicates the type of packets or the specific part of packets to + * which RSS hashing is to be applied. + */ + uint64_t rss_hf; }; /* diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index edefa34c10da..25f1dffd1f30 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3226,6 +3226,7 @@ struct rte_flow_query_count { * Hash function types. */ enum rte_eth_hash_function { + /** DEFAULT means driver decides which hash algorithm to pick. */ RTE_ETH_HASH_FUNCTION_DEFAULT = 0, RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */ RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */ From patchwork Sat Oct 28 01:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133531 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 B131A4321C; Sat, 28 Oct 2023 03:49:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 222F840C35; Sat, 28 Oct 2023 03:49:47 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 44B61402DF for ; Sat, 28 Oct 2023 03:49:40 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SHMmv0N9yzPnjB; Sat, 28 Oct 2023 09:45:35 +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; Sat, 28 Oct 2023 09:49:38 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ori Kam CC: , , , Subject: [PATCH v7 2/9] ethdev: support setting and querying RSS algorithm Date: Sat, 28 Oct 2023 09:46:04 +0800 Message-ID: <20231028014611.4086500-3-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 Currently, rte_eth_rss_conf supports configuring and querying RSS hash functions, rss key and it's length, but not RSS hash algorithm. The structure ``rte_eth_dev_info`` is extended by adding a new field "rss_algo_capa". Drivers are responsible for reporting this capa and configurations of RSS hash algorithm can be verified based on the capability. The default value of "rss_algo_capa" is RTE_ETH_HASH_ALGO_CAPA_MASK(DEFAULT) if drivers do not report it. The structure ``rte_eth_rss_conf`` is extended by adding a new field "algorithm". This represents the RSS algorithms to apply. If the value of "algorithm" used for configuration is a gibberish value, drivers should report the error. To check whether the drivers report valid "algorithm", it is set to default value before querying in rte_eth_dev_rss_hash_conf_get(). Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu Acked-by: Huisong Li --- doc/guides/rel_notes/release_23_11.rst | 5 ++++ lib/ethdev/rte_ethdev.c | 26 ++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 33 +++++++++++++++++++++++++- lib/ethdev/rte_flow.c | 1 - lib/ethdev/rte_flow.h | 26 ++------------------ 5 files changed, 65 insertions(+), 26 deletions(-) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 0a6fc76a9d02..a35d729d2cc7 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -360,6 +360,11 @@ ABI Changes * security: struct ``rte_security_ipsec_sa_options`` was updated due to inline out-of-place feature addition. +* ethdev: Added "rss_algo_capa" field to ``rte_eth_dev_info`` structure for +* reporting RSS hash algorithm capability. + +* ethdev: Added "algorithm" field to ``rte_eth_rss_conf`` structure for RSS + hash algorithm. Known Issues ------------ diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 9dabcb5ae28e..90bfbf14d1f7 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1269,6 +1269,7 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, const struct rte_eth_conf *dev_conf) { + enum rte_eth_hash_function algorithm; struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct rte_eth_conf orig_conf; @@ -1500,6 +1501,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, goto rollback; } + algorithm = dev_conf->rx_adv_conf.rss_conf.algorithm; + if ((dev_info.rss_algo_capa & + RTE_ETH_HASH_ALGO_TO_CAPA(algorithm)) == 0) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u config unsupported RSS hash algorithm: %u " + "with rss_algo_capa: %x\n", + port_id, algorithm, + dev_info.rss_algo_capa); + ret = -EINVAL; + goto rollback; + } + /* * Setup new number of Rx/Tx queues and reconfigure device. */ @@ -3757,6 +3770,7 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) dev_info->min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN; dev_info->max_mtu = UINT16_MAX; + dev_info->rss_algo_capa = RTE_ETH_HASH_ALGO_CAPA_MASK(DEFAULT); if (*dev->dev_ops->dev_infos_get == NULL) return -ENOTSUP; @@ -4698,6 +4712,16 @@ rte_eth_dev_rss_hash_update(uint16_t port_id, return -ENOTSUP; } + if ((dev_info.rss_algo_capa & + RTE_ETH_HASH_ALGO_TO_CAPA(rss_conf->algorithm)) == 0) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u config unsupported RSS hash algorithm: %u " + "with rss_algo_capa: %x\n", + port_id, rss_conf->algorithm, + dev_info.rss_algo_capa); + return -EINVAL; + } + if (*dev->dev_ops->rss_hash_update == NULL) return -ENOTSUP; ret = eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev, @@ -4725,6 +4749,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id, return -EINVAL; } + rss_conf->algorithm = RTE_ETH_HASH_FUNCTION_DEFAULT; + if (*dev->dev_ops->rss_hash_conf_get == NULL) return -ENOTSUP; ret = eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev, diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 37fd5afef48a..2f639edd8218 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -445,6 +445,33 @@ struct rte_vlan_filter_conf { uint64_t ids[64]; }; +/** + * Hash function types. + */ +enum rte_eth_hash_function { + /** DEFAULT means driver decides which hash algorithm to pick. */ + RTE_ETH_HASH_FUNCTION_DEFAULT = 0, + RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */ + RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */ + /** + * Symmetric Toeplitz: src, dst will be replaced by + * xor(src, dst). For the case with src/dst only, + * src or dst address will xor with zero pair. + */ + RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, + /** + * Symmetric Toeplitz: L3 and L4 fields are sorted prior to + * the hash function. + * If src_ip > dst_ip, swap src_ip and dst_ip. + * If src_port > dst_port, swap src_port and dst_port. + */ + RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT, + RTE_ETH_HASH_FUNCTION_MAX, +}; + +#define RTE_ETH_HASH_ALGO_TO_CAPA(x) RTE_BIT32(x) +#define RTE_ETH_HASH_ALGO_CAPA_MASK(x) RTE_BIT32(RTE_ETH_HASH_FUNCTION_ ## x) + /** * A structure used to configure the Receive Side Scaling (RSS) feature * of an Ethernet port. @@ -469,6 +496,7 @@ struct rte_eth_rss_conf { * which RSS hashing is to be applied. */ uint64_t rss_hf; + enum rte_eth_hash_function algorithm; /**< Hash algorithm. */ }; /* @@ -1783,7 +1811,10 @@ struct rte_eth_dev_info { /** Supported error handling mode. */ enum rte_eth_err_handle_mode err_handle_mode; - uint64_t reserved_64s[2]; /**< Reserved for future fields */ + /** RSS hash algorithms capabilities */ + uint32_t rss_algo_capa; + + uint32_t reserved_32s[3]; /**< Reserved for future fields */ void *reserved_ptrs[2]; /**< Reserved for future fields */ }; diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 3a67f1aaba9d..c13a2a391c37 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -13,7 +13,6 @@ #include #include #include -#include "rte_ethdev.h" #include "rte_flow_driver.h" #include "rte_flow.h" diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 25f1dffd1f30..c94f553ae06f 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -40,6 +40,8 @@ #include #include +#include "rte_ethdev.h" + #ifdef __cplusplus extern "C" { #endif @@ -3222,30 +3224,6 @@ struct rte_flow_query_count { uint64_t bytes; /**< Number of bytes through this rule [out]. */ }; -/** - * Hash function types. - */ -enum rte_eth_hash_function { - /** DEFAULT means driver decides which hash algorithm to pick. */ - RTE_ETH_HASH_FUNCTION_DEFAULT = 0, - RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */ - RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */ - /** - * Symmetric Toeplitz: src, dst will be replaced by - * xor(src, dst). For the case with src/dst only, - * src or dst address will xor with zero pair. - */ - RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, - /** - * Symmetric Toeplitz: L3 and L4 fields are sorted prior to - * the hash function. - * If src_ip > dst_ip, swap src_ip and dst_ip. - * If src_port > dst_port, swap src_port and dst_port. - */ - RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT, - RTE_ETH_HASH_FUNCTION_MAX, -}; - /** * RTE_FLOW_ACTION_TYPE_RSS * From patchwork Sat Oct 28 01:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133533 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 8AC5A4321C; Sat, 28 Oct 2023 03:50:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0637640F16; Sat, 28 Oct 2023 03:49:49 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 9C07F4029E for ; Sat, 28 Oct 2023 03:49:40 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SHMlw2MHLzpWTV for ; Sat, 28 Oct 2023 09:44:44 +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; Sat, 28 Oct 2023 09:49:39 +0800 From: Jie Hai To: , Yisen Zhuang CC: , , , Subject: [PATCH v7 3/9] net/hns3: report RSS hash algorithms capability Date: Sat, 28 Oct 2023 09:46:05 +0800 Message-ID: <20231028014611.4086500-4-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 The hns3 driver should reports RSS hash algorithm capability to support updating RSS hash algorithm by rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(). Signed-off-by: Jie Hai Acked-by: Huisong Li --- drivers/net/hns3/hns3_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index c4d47f43fe44..7f5067ea2fa2 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -132,6 +132,10 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) info->reta_size = hw->rss_ind_tbl_size; info->hash_key_size = hw->rss_key_size; info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; + info->rss_algo_capa = RTE_ETH_HASH_ALGO_CAPA_MASK(DEFAULT) | + RTE_ETH_HASH_ALGO_CAPA_MASK(TOEPLITZ) | + RTE_ETH_HASH_ALGO_CAPA_MASK(SIMPLE_XOR) | + RTE_ETH_HASH_ALGO_CAPA_MASK(SYMMETRIC_TOEPLITZ); info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; info->default_txportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; From patchwork Sat Oct 28 01:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133534 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 C45B34321C; Sat, 28 Oct 2023 03:50:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1DD542670; Sat, 28 Oct 2023 03:49:49 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 4AB5040291 for ; Sat, 28 Oct 2023 03:49:41 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SHMlw5q4dzpWVy for ; Sat, 28 Oct 2023 09:44:44 +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; Sat, 28 Oct 2023 09:49:39 +0800 From: Jie Hai To: , Yisen Zhuang CC: , , , Subject: [PATCH v7 4/9] net/hns3: support setting and querying RSS hash function Date: Sat, 28 Oct 2023 09:46:06 +0800 Message-ID: <20231028014611.4086500-5-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 From: Huisong Li Support setting and querying RSS hash function by ethdev ops. Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu Signed-off-by: Jie Hai Acked-by: Chengwen Feng --- drivers/net/hns3/hns3_rss.c | 47 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 6126512bd780..010a759f23d9 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, if (ret) goto set_tuple_fail; - if (key) { - ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, - key, hw->rss_key_size); - if (ret) - goto set_algo_key_fail; - /* Update the shadow RSS key with user specified */ + ret = hns3_update_rss_algo_key(hw, rss_conf->algorithm, key, key_len); + if (ret != 0) + goto set_algo_key_fail; + + if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT) + hw->rss_info.hash_algo = hns3_hash_func_map[rss_conf->algorithm]; + if (key != NULL) memcpy(hw->rss_info.key, key, hw->rss_key_size); - } hw->rss_info.rss_hf = rss_hf; rte_spinlock_unlock(&hw->lock); @@ -769,7 +769,13 @@ int hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { + const uint8_t hash_func_map[] = { + [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ, + [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, + [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, + }; struct hns3_adapter *hns = dev->data->dev_private; + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; struct hns3_hw *hw = &hns->hw; uint8_t hash_algo; int ret; @@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, rte_spinlock_lock(&hw->lock); ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf); if (ret != 0) { + rte_spinlock_unlock(&hw->lock); hns3_err(hw, "obtain hash tuples failed, ret = %d", ret); - goto out; + return ret; + } + + ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size); + if (ret != 0) { + rte_spinlock_unlock(&hw->lock); + hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret); + return ret; } + rte_spinlock_unlock(&hw->lock); - /* Get the RSS Key required by the user */ + /* Get the RSS Key if user required. */ if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { - ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key, - hw->rss_key_size); - if (ret != 0) { - hns3_err(hw, "obtain hash algo and key failed, ret = %d", - ret); - goto out; - } + memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size); rss_conf->rss_key_len = hw->rss_key_size; } + rss_conf->algorithm = hash_func_map[hash_algo]; -out: - rte_spinlock_unlock(&hw->lock); - - return ret; + return 0; } /* From patchwork Sat Oct 28 01:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133535 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 6F7A74321C; Sat, 28 Oct 2023 03:50:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05AD542D45; Sat, 28 Oct 2023 03:49:51 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id B18DD4029E for ; Sat, 28 Oct 2023 03:49:41 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SHMpF0cRlz1L9DR; Sat, 28 Oct 2023 09:46:45 +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; Sat, 28 Oct 2023 09:49:40 +0800 From: Jie Hai To: , Reshma Pattan , Vipin Varghese , John McNamara CC: , , , Subject: [PATCH v7 5/9] app/proc-info: fix never show RSS info Date: Sat, 28 Oct 2023 09:46:07 +0800 Message-ID: <20231028014611.4086500-6-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 shown 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 fixes it. Fixes: 8a37f37fc243 ("app/procinfo: add --show-port") Cc: stable@dpdk.org Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu Acked-by: Reshma Pattan Acked-by: Chengwen Feng Acked-by: Huisong Li --- app/proc-info/main.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index ce53bc30dfec..3a441ba07586 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -151,6 +151,8 @@ struct desc_param { static struct desc_param rx_desc_param; static struct desc_param tx_desc_param; +#define RSS_HASH_KEY_SIZE 64 + /* display usage */ static void proc_info_usage(const char *prgname) @@ -1011,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[RSS_HASH_KEY_SIZE]; /* Skip if port is not in mask */ if ((enabled_port_mask & (1ul << i)) == 0) @@ -1169,17 +1172,17 @@ show_port(void) printf("\n"); } + 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); } #ifdef RTE_LIB_SECURITY From patchwork Sat Oct 28 01:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133536 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 91E034321C; Sat, 28 Oct 2023 03:50:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1612F42D87; Sat, 28 Oct 2023 03:49:52 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 2A67140291 for ; Sat, 28 Oct 2023 03:49:42 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SHMpF4Qpxz1L9HN; Sat, 28 Oct 2023 09:46:45 +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; Sat, 28 Oct 2023 09:49:40 +0800 From: Jie Hai To: , Reshma Pattan , Vipin Varghese , John McNamara CC: , , , Subject: [PATCH v7 6/9] app/proc-info: adjust the display format of RSS info Date: Sat, 28 Oct 2023 09:46:08 +0800 Message-ID: <20231028014611.4086500-7-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 -- hash function : 0x0 Fixes: 8a37f37fc243 ("app/procinfo: add --show-port") Cc: stable@dpdk.org Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu Acked-by: Reshma Pattan --- 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 3a441ba07586..4c577fa417fd 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -1176,12 +1176,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 -- hash function : 0x%"PRIx64"\n", rss_conf.rss_hf); } From patchwork Sat Oct 28 01:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133537 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 19E424321C; Sat, 28 Oct 2023 03:50:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CD3742DD5; Sat, 28 Oct 2023 03:49:53 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id CC61B40291 for ; Sat, 28 Oct 2023 03:49:42 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SHMpF3JgDzrSy5; Sat, 28 Oct 2023 09:46:45 +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; Sat, 28 Oct 2023 09:49:41 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , , , Subject: [PATCH v7 7/9] lib/ethdev: add API to get RSS algorithm names Date: Sat, 28 Oct 2023 09:46:09 +0800 Message-ID: <20231028014611.4086500-8-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 --- doc/guides/rel_notes/release_23_11.rst | 3 +++ lib/ethdev/rte_ethdev.c | 25 +++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index a35d729d2cc7..fe561a6c59b9 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -243,6 +243,9 @@ New Features Added dispatcher library which purpose is to help decouple different parts (modules) of an eventdev-based application. +* **Added new API for RSS hash algorithm** + Added new function ``rte_eth_dev_rss_algo_name`` to get name of RSS hash + algorithm. Removed Items ------------- diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 90bfbf14d1f7..301531ba9628 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) { @@ -4761,6 +4772,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 2f639edd8218..b9d4bfa851b4 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4645,6 +4645,10 @@ int rte_eth_dev_rss_hash_conf_get(uint16_t port_id, struct rte_eth_rss_conf *rss_conf); + +const char * +rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo); + /** * Add UDP tunneling port for a type of tunnel. * From patchwork Sat Oct 28 01:46:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133538 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 4B3784321C; Sat, 28 Oct 2023 03:50:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2145742DE1; Sat, 28 Oct 2023 03:49:54 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 6BCFE40291 for ; Sat, 28 Oct 2023 03:49:43 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SHMmy1N9CzPnjj for ; Sat, 28 Oct 2023 09:45:38 +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; Sat, 28 Oct 2023 09:49:41 +0800 From: Jie Hai To: , Reshma Pattan CC: , , , Subject: [PATCH v7 8/9] app/proc-info: support querying RSS hash algorithm Date: Sat, 28 Oct 2023 09:46:10 +0800 Message-ID: <20231028014611.4086500-9-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 Acked-by: Reshma Pattan --- app/proc-info/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 4c577fa417fd..b672aaefbe99 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -1184,6 +1184,8 @@ show_port(void) printf("%02x", rss_conf.rss_key[k]); printf("\n\t -- hash function : 0x%"PRIx64"\n", rss_conf.rss_hf); + printf("\t -- hash algorithm : %s\n", + rte_eth_dev_rss_algo_name(rss_conf.algorithm)); } #ifdef RTE_LIB_SECURITY From patchwork Sat Oct 28 01:46:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133539 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 17BBA4321C; Sat, 28 Oct 2023 03:50:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31A0F42DC1; Sat, 28 Oct 2023 03:49:55 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id C9455402DF for ; Sat, 28 Oct 2023 03:49:43 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SHMlz3rRrzpWTV for ; Sat, 28 Oct 2023 09:44:47 +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; Sat, 28 Oct 2023 09:49:42 +0800 From: Jie Hai To: , Aman Singh , Yuying Zhang CC: , , , Subject: [PATCH v7 9/9] app/testpmd: add RSS hash algorithms display Date: Sat, 28 Oct 2023 09:46:11 +0800 Message-ID: <20231028014611.4086500-10-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231028014611.4086500-1-haijie1@huawei.com> References: <20231027092836.445224-1-haijie1@huawei.com> <20231028014611.4086500-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 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 the command "show port X rss-hash algorithm" to display the RSS hash algorithms of port X. An example is shown: testpmd> show port 0 rss-hash algorithm RSS algorithms: toeplitz Signed-off-by: Jie Hai Acked-by: Huisong Li --- app/test-pmd/cmdline.c | 29 ++++++++++++++++++++++++----- app/test-pmd/config.c | 29 ++++++++++------------------- app/test-pmd/testpmd.h | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 679ca47b9401..d0eafd7f1254 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 | algorithm]\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" @@ -3026,15 +3026,17 @@ 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 algorithm; /* 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); + port_rss_hash_conf_show(res->port_id, + !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm")); } static cmdline_parse_token_string_t cmd_showport_rss_hash_show = @@ -3049,6 +3051,8 @@ 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_algo = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm"); static cmdline_parse_inst_t cmd_showport_rss_hash = { .f = cmd_showport_rss_hash_parsed, @@ -3065,7 +3069,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, @@ -3077,6 +3081,20 @@ static cmdline_parse_inst_t cmd_showport_rss_hash_key = { }, }; +static cmdline_parse_inst_t cmd_showport_rss_hash_algo = { + .f = cmd_showport_rss_hash_parsed, + .data = NULL, + .help_str = "show port rss-hash algorithm", + .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_algo, + NULL, + }, +}; + /* *** Configure DCB *** */ struct cmd_config_dcb { cmdline_fixed_string_t port; @@ -12953,6 +12971,7 @@ 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_algo, (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 b9fdb7e8f162..c090b77b536c 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) { @@ -4486,7 +4469,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_algo) { struct rte_eth_rss_conf rss_conf = {0}; uint8_t rss_key[RSS_HASH_KEY_LENGTH]; @@ -4536,8 +4519,16 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) printf("RSS disabled\n"); return; } + + if (show_rss_algo) { + printf("RSS algorithms:\n %s\n", + rte_eth_dev_rss_algo_name(rss_conf.algorithm)); + return; + } + printf("RSS functions:\n"); rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); + if (!show_rss_key) return; printf("RSS key:\n"); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 09a36b90b806..9b10a9ea1cf2 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1153,7 +1153,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_algo); 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);