From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 * -- 2.30.0