From patchwork Thu Nov 2 08:20:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133771 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 6ABF84326B; Thu, 2 Nov 2023 09:24:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FC19406B4; Thu, 2 Nov 2023 09:23:58 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 8F62C40284 for ; Thu, 2 Nov 2023 09:23:56 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SLcN672RKzvQP3; Thu, 2 Nov 2023 16:23:50 +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:52 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ori Kam CC: , , Subject: [PATCH v9 1/9] ethdev: overwrite some comment related to RSS Date: Thu, 2 Nov 2023 16:20:12 +0800 Message-ID: <20231102082020.2588392-2-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 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 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 "hash_key_size" bytes. If these requirements are not met, the query unreliable. 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", it should be equal to the "hash_key_size" if "rss_key" is not NULL. This patch overwrites the comments of fields of "rte_eth_rss_conf" and "RTE_ETH_HASH_FUNCTION_DEFAULT", checks "rss_key_len" in ethdev level, and documents these changes. Signed-off-by: Jie Hai Acked-by: Huisong Li Acked-by: Chengwen Feng --- doc/guides/rel_notes/release_23_11.rst | 4 ++++ lib/ethdev/rte_ethdev.c | 31 ++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 33 ++++++++++++++------------ lib/ethdev/rte_flow.h | 1 + 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 95db98d098d8..0b67f31dc385 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -345,6 +345,10 @@ API Changes Updated ``rte_ml_op``, ``rte_ml_io_quantize`` and ``rte_ml_io_dequantize`` to support an array of ``rte_ml_buff_seg``. +* ethdev: When ``rte_eth_dev_configure`` or ``rte_eth_dev_rss_hash_update`` are + called, the ``rss_key_len`` of structure ``rte_eth_rss_conf`` should be provided + by user for the case ``rss_key != NULL``, it won't be taken as default 40 + bytes anymore. ABI Changes ----------- diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index af23ac0ad00f..6727aca12dce 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1500,6 +1500,16 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, goto rollback; } + if (dev_conf->rx_adv_conf.rss_conf.rss_key != NULL && + dev_conf->rx_adv_conf.rss_conf.rss_key_len != dev_info.hash_key_size) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u invalid RSS key len: %u, valid value: %u\n", + port_id, dev_conf->rx_adv_conf.rss_conf.rss_key_len, + dev_info.hash_key_size); + ret = -EINVAL; + goto rollback; + } + /* * Setup new number of Rx/Tx queues and reconfigure device. */ @@ -4698,6 +4708,14 @@ rte_eth_dev_rss_hash_update(uint16_t port_id, return -ENOTSUP; } + if (rss_conf->rss_key != NULL && + rss_conf->rss_key_len != dev_info.hash_key_size) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u invalid RSS key len: %u, valid value: %u\n", + port_id, rss_conf->rss_key_len, dev_info.hash_key_size); + return -EINVAL; + } + if (*dev->dev_ops->rss_hash_update == NULL) return -ENOTSUP; ret = eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev, @@ -4712,6 +4730,7 @@ int rte_eth_dev_rss_hash_conf_get(uint16_t port_id, struct rte_eth_rss_conf *rss_conf) { + struct rte_eth_dev_info dev_info = { 0 }; struct rte_eth_dev *dev; int ret; @@ -4725,6 +4744,18 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id, return -EINVAL; } + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + return ret; + + if (rss_conf->rss_key != NULL && + rss_conf->rss_key_len < dev_info.hash_key_size) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u invalid RSS key len: %u, should not be less than: %u\n", + port_id, rss_conf->rss_key_len, dev_info.hash_key_size); + return -EINVAL; + } + 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 a53dd5a1efec..fb1a1f89c67f 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 + * *hash_key_size* bytes. If not meet these requirements, the query + * result is unreliable even if the operation returns success. + * + * In rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(), if + * *rss_key* is not NULL, the *rss_key_len* indicates the length of the + * *rss_key* in bytes and it should be equal to *hash_key_size*. + * If *rss_key* is NULL, drivers are free to use a random or a default key. + */ + 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 c16fe8c21f2f..751c29a0f3f3 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 Thu Nov 2 08:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133775 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 86F1A4326B; Thu, 2 Nov 2023 09:24:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 062D14161A; Thu, 2 Nov 2023 09:24:05 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 7DD6A40608 for ; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SLcJf5kXfzrTqG; Thu, 2 Nov 2023 16:20:50 +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:53 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ori Kam CC: , , Subject: [PATCH v9 2/9] ethdev: support setting and querying RSS algorithm Date: Thu, 2 Nov 2023 16:20:13 +0800 Message-ID: <20231102082020.2588392-3-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 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 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 Acked-by: Chengwen Feng --- doc/guides/rel_notes/release_23_11.rst | 13 ++++++++++++ lib/ethdev/rte_ethdev.c | 25 ++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 29 ++++++++++++++++++++++++++ lib/ethdev/rte_flow.c | 1 - lib/ethdev/rte_flow.h | 26 ++--------------------- 5 files changed, 69 insertions(+), 25 deletions(-) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 0b67f31dc385..20556b8a17ce 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -122,6 +122,13 @@ New Features a group's miss actions, which are the actions to be performed on packets that didn't match any of the flow rules in the group. +* **Added support for RSS hash algorithm.** + + * Added new field ``rss_algo_capa`` to ``rte_eth_dev_info`` structure for + reporting RSS hash algorithm capability that drivers support. + * Added new field ``algorithm`` to ``rte_eth_rss_conf`` structure for RSS + hash algorithm querying and configuring. + * **Updated Amazon ena (Elastic Network Adapter) net driver.** * Upgraded ENA HAL to latest version. @@ -376,6 +383,12 @@ 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 6727aca12dce..36d8deef90c5 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; @@ -1510,6 +1511,17 @@ 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 (algorithm >= CHAR_BIT * sizeof(dev_info.rss_algo_capa) || + (dev_info.rss_algo_capa & RTE_ETH_HASH_ALGO_TO_CAPA(algorithm)) == 0) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u configured RSS hash algorithm (%u)" + "is not in the algorithm capability (0x%" PRIx32 ")\n", + port_id, algorithm, dev_info.rss_algo_capa); + ret = -EINVAL; + goto rollback; + } + /* * Setup new number of Rx/Tx queues and reconfigure device. */ @@ -3767,6 +3779,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; @@ -4716,6 +4729,16 @@ rte_eth_dev_rss_hash_update(uint16_t port_id, return -EINVAL; } + if (rss_conf->algorithm >= CHAR_BIT * sizeof(dev_info.rss_algo_capa) || + (dev_info.rss_algo_capa & + RTE_ETH_HASH_ALGO_TO_CAPA(rss_conf->algorithm)) == 0) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%u configured RSS hash algorithm (%u)" + "is not in the algorithm capability (0x%" PRIx32 ")\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, @@ -4756,6 +4779,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 fb1a1f89c67f..37d8ef694523 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. */ }; /* @@ -1749,6 +1777,7 @@ struct rte_eth_dev_info { /** Device redirection table size, the total number of entries. */ uint16_t reta_size; uint8_t hash_key_size; /**< Hash key size in bytes */ + uint32_t rss_algo_capa; /** RSS hash algorithms capabilities */ /** Bit mask of RSS offloads, the bit offset also means flow type */ uint64_t flow_type_rss_offloads; struct rte_eth_rxconf default_rxconf; /**< Default Rx configuration */ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 20ee8430eaec..549e3295584c 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 751c29a0f3f3..affdc8121b57 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 Thu Nov 2 08:20: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: 133770 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 9AC814326B; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E09A402F2; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 6ED4940282 for ; Thu, 2 Nov 2023 09:23:56 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SLcJg1r5CzrTqh for ; Thu, 2 Nov 2023 16:20:51 +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:54 +0800 From: Jie Hai To: , Yisen Zhuang CC: , , Subject: [PATCH v9 3/9] net/hns3: report RSS hash algorithms capability Date: Thu, 2 Nov 2023 16:20:14 +0800 Message-ID: <20231102082020.2588392-4-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 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 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 Acked-by: Chengwen Feng --- 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 9327adbdc113..ff205426fab8 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -133,6 +133,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 Thu Nov 2 08:20: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: 133773 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 2006E4326B; Thu, 2 Nov 2023 09:24:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77A1A40ED9; Thu, 2 Nov 2023 09:24:02 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 1249D40282 for ; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SLcJh3L6tz1P7tn for ; Thu, 2 Nov 2023 16:20:52 +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:54 +0800 From: Jie Hai To: , Yisen Zhuang CC: , , Subject: [PATCH v9 4/9] net/hns3: support setting and querying RSS hash function Date: Thu, 2 Nov 2023 16:20:15 +0800 Message-ID: <20231102082020.2588392-5-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 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 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 eeeca71a5c1a..15feb26043af 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 = 0; 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 Thu Nov 2 08:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133772 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 DB8294326B; Thu, 2 Nov 2023 09:24:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C57940E72; Thu, 2 Nov 2023 09:24:01 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 32089402EB for ; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SLcJj05Fxz1P7tv; Thu, 2 Nov 2023 16:20:52 +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:55 +0800 From: Jie Hai To: , Reshma Pattan , John McNamara , Vipin Varghese CC: , , Subject: [PATCH v9 5/9] app/proc-info: fix never show RSS info Date: Thu, 2 Nov 2023 16:20:16 +0800 Message-ID: <20231102082020.2588392-6-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 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 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 Thu Nov 2 08:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133774 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 5F2FB4326B; Thu, 2 Nov 2023 09:24:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B4EA410FA; Thu, 2 Nov 2023 09:24:03 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 6B045402EC for ; Thu, 2 Nov 2023 09:23:57 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SLcJj6pqyz1P7v2; Thu, 2 Nov 2023 16:20:53 +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:55 +0800 From: Jie Hai To: , Reshma Pattan , John McNamara , Vipin Varghese CC: , , Subject: [PATCH v9 6/9] app/proc-info: adjust the display format of RSS info Date: Thu, 2 Nov 2023 16:20:17 +0800 Message-ID: <20231102082020.2588392-7-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 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 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 Acked-by: Chengwen Feng --- 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 Thu Nov 2 08:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133777 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 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 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; From patchwork Thu Nov 2 08:20:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133776 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 7A9584326B; Thu, 2 Nov 2023 09:24:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1754F427E2; Thu, 2 Nov 2023 09:24:06 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3F7D140282 for ; Thu, 2 Nov 2023 09:23:58 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SLcNB5b0fzvQRr for ; 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: , Reshma Pattan CC: , , Subject: [PATCH v9 8/9] app/proc-info: support querying RSS hash algorithm Date: Thu, 2 Nov 2023 16:20:19 +0800 Message-ID: <20231102082020.2588392-9-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 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 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 Acked-by: Huisong Li Acked-by: Chengwen Feng --- 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 Thu Nov 2 08:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 133778 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 4303B4326B; Thu, 2 Nov 2023 09:25:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50A4C42D0B; Thu, 2 Nov 2023 09:24:08 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id CFB6D40282 for ; Thu, 2 Nov 2023 09:23:58 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SLcNC2pJGzvQRw for ; Thu, 2 Nov 2023 16:23:55 +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:57 +0800 From: Jie Hai To: , Aman Singh , Yuying Zhang CC: , , Subject: [PATCH v9 9/9] app/testpmd: add RSS hash algorithms display Date: Thu, 2 Nov 2023 16:20:20 +0800 Message-ID: <20231102082020.2588392-10-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 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 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 algorithm: toeplitz Signed-off-by: Jie Hai Acked-by: Huisong Li Acked-by: Chengwen Feng --- app/test-pmd/cmdline.c | 29 +++++++++++++++++---- app/test-pmd/config.c | 10 ++++++- app/test-pmd/testpmd.h | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 35f5e4bbc002..912bf3355c10 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; @@ -12969,6 +12987,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 a3e32aa852d8..23fb4f8aa781 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -4469,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]; @@ -4519,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 algorithm:\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); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 3d242c85345f..b51e459998b0 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -235,9 +235,9 @@ size is used to indicate the hardware supported reta size show port rss-hash ~~~~~~~~~~~~~~~~~~ -Display the RSS hash functions and RSS hash key of a port:: +Display the RSS hash functions and RSS hash key or RSS hash algorithm of a port:: - testpmd> show port (port_id) rss-hash [key] + testpmd> show port (port_id) rss-hash [key | algorithm] clear port ~~~~~~~~~~