From patchwork Mon Jan 30 09:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122664 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 41D7941B7E; Mon, 30 Jan 2023 10:32:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A504940EE1; Mon, 30 Jan 2023 10:32:02 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 265C240C35; Mon, 30 Jan 2023 10:32:01 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4P52vp5hQmznVTW; Mon, 30 Jan 2023 17:29:58 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:31:58 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 01/10] net/hns3: fix error log about indirection table size Date: Mon, 30 Jan 2023 17:31:20 +0800 Message-ID: <20230130093129.18529-2-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500017.china.huawei.com (7.221.188.110) 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 The error log about indirection table size during initialization phase of PF and VF is unreasonable when the indirection table size obtained from firmware or PF function should be zero. In addition, VF driver should use error level to print this log. Fixes: 0fce2c46dc16 ("net/hns3: fix RSS indirection table size") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_ethdev.c | 2 +- drivers/net/hns3/hns3_ethdev_vf.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index d326f70129..eb809cd8c9 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2679,7 +2679,7 @@ hns3_check_dev_specifications(struct hns3_hw *hw) { if (hw->rss_ind_tbl_size == 0 || hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { - hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", + hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); return -EINVAL; } diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index d220522c43..e43815607a 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -718,8 +718,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw) { if (hw->rss_ind_tbl_size == 0 || hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { - hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)", - hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", + hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); return -EINVAL; } From patchwork Mon Jan 30 09:31:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122668 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 1448E41B7E; Mon, 30 Jan 2023 10:32:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BED6E42D0D; Mon, 30 Jan 2023 10:32:08 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 25AD940C35; Mon, 30 Jan 2023 10:32:02 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4P52vq6TnTz16Mqd; Mon, 30 Jan 2023 17:29:59 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:31:59 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 02/10] net/hns3: extract common API to query device Date: Mon, 30 Jan 2023 17:31:21 +0800 Message-ID: <20230130093129.18529-3-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500017.china.huawei.com (7.221.188.110) 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 Extract common function to query device specifications. Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_common.c | 75 +++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 2 + drivers/net/hns3/hns3_ethdev.c | 63 -------------------------- drivers/net/hns3/hns3_ethdev_vf.c | 65 +-------------------------- 4 files changed, 79 insertions(+), 126 deletions(-) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index 7adc6a4972..b0c7f8d62c 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -10,6 +10,7 @@ #include "hns3_logs.h" #include "hns3_regs.h" #include "hns3_rxtx.h" +#include "hns3_dcb.h" #include "hns3_common.h" int @@ -845,3 +846,77 @@ hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id) return 0; } + +void +hns3_set_default_dev_specifications(struct hns3_hw *hw) +{ + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + + hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; + hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; + hw->rss_key_size = HNS3_RSS_KEY_SIZE; + hw->intr.int_ql_max = HNS3_INTR_QL_NONE; + + if (hns->is_vf) + return; + + hw->max_tm_rate = HNS3_ETHER_MAX_RATE; +} + +static void +hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) +{ + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_dev_specs_0_cmd *req0; + struct hns3_dev_specs_1_cmd *req1; + + req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; + req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; + + hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; + hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); + hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); + hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); + hw->min_tx_pkt_len = req1->min_tx_pkt_len; + + if (hns->is_vf) + return; + + hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); +} + +static int +hns3_check_dev_specifications(struct hns3_hw *hw) +{ + if (hw->rss_ind_tbl_size == 0 || + hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { + hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", + hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); + return -EINVAL; + } + + return 0; +} + +int +hns3_query_dev_specifications(struct hns3_hw *hw) +{ + struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; + int ret; + int i; + + for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { + hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, + true); + desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); + } + hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); + + ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); + if (ret) + return ret; + + hns3_parse_dev_specifications(hw, desc); + + return hns3_check_dev_specifications(hw); +} diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h index 5aa001f0cc..8eaeda26e7 100644 --- a/drivers/net/hns3/hns3_common.h +++ b/drivers/net/hns3/hns3_common.h @@ -60,5 +60,7 @@ void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev); int hns3_restore_rx_interrupt(struct hns3_hw *hw); int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id); +void hns3_set_default_dev_specifications(struct hns3_hw *hw); +int hns3_query_dev_specifications(struct hns3_hw *hw); #endif /* HNS3_COMMON_H */ diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index eb809cd8c9..ab565ce128 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2647,69 +2647,6 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) return 0; } -static void -hns3_set_default_dev_specifications(struct hns3_hw *hw) -{ - hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; - hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; - hw->rss_key_size = HNS3_RSS_KEY_SIZE; - hw->max_tm_rate = HNS3_ETHER_MAX_RATE; - hw->intr.int_ql_max = HNS3_INTR_QL_NONE; -} - -static void -hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) -{ - struct hns3_dev_specs_0_cmd *req0; - struct hns3_dev_specs_1_cmd *req1; - - req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; - req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; - - hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; - hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); - hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); - hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate); - hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); - hw->min_tx_pkt_len = req1->min_tx_pkt_len; -} - -static int -hns3_check_dev_specifications(struct hns3_hw *hw) -{ - if (hw->rss_ind_tbl_size == 0 || - hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { - hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", - hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); - return -EINVAL; - } - - return 0; -} - -static int -hns3_query_dev_specifications(struct hns3_hw *hw) -{ - struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; - int ret; - int i; - - for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { - hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, - true); - desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); - } - hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); - - ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); - if (ret) - return ret; - - hns3_parse_dev_specifications(hw, desc); - - return hns3_check_dev_specifications(hw); -} - static int hns3_get_capability(struct hns3_hw *hw) { diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index e43815607a..d3c1bdf2c5 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -688,67 +688,6 @@ hns3vf_interrupt_handler(void *param) hns3vf_enable_irq0(hw); } -static void -hns3vf_set_default_dev_specifications(struct hns3_hw *hw) -{ - hw->max_non_tso_bd_num = HNS3_MAX_NON_TSO_BD_PER_PKT; - hw->rss_ind_tbl_size = HNS3_RSS_IND_TBL_SIZE; - hw->rss_key_size = HNS3_RSS_KEY_SIZE; - hw->intr.int_ql_max = HNS3_INTR_QL_NONE; -} - -static void -hns3vf_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) -{ - struct hns3_dev_specs_0_cmd *req0; - struct hns3_dev_specs_1_cmd *req1; - - req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data; - req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data; - - hw->max_non_tso_bd_num = req0->max_non_tso_bd_num; - hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size); - hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size); - hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max); - hw->min_tx_pkt_len = req1->min_tx_pkt_len; -} - -static int -hns3vf_check_dev_specifications(struct hns3_hw *hw) -{ - if (hw->rss_ind_tbl_size == 0 || - hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { - hns3_err(hw, "the indirection table size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", - hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX); - return -EINVAL; - } - - return 0; -} - -static int -hns3vf_query_dev_specifications(struct hns3_hw *hw) -{ - struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; - int ret; - int i; - - for (i = 0; i < HNS3_QUERY_DEV_SPECS_BD_NUM - 1; i++) { - hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, - true); - desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); - } - hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_QUERY_DEV_SPECS, true); - - ret = hns3_cmd_send(hw, desc, HNS3_QUERY_DEV_SPECS_BD_NUM); - if (ret) - return ret; - - hns3vf_parse_dev_specifications(hw, desc); - - return hns3vf_check_dev_specifications(hw); -} - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported) { @@ -826,7 +765,7 @@ hns3vf_get_capability(struct hns3_hw *hw) return ret; if (hw->revision < PCI_REVISION_ID_HIP09_A) { - hns3vf_set_default_dev_specifications(hw); + hns3_set_default_dev_specifications(hw); hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE; hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US; hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM; @@ -837,7 +776,7 @@ hns3vf_get_capability(struct hns3_hw *hw) return 0; } - ret = hns3vf_query_dev_specifications(hw); + ret = hns3_query_dev_specifications(hw); if (ret) { PMD_INIT_LOG(ERR, "failed to query dev specifications, ret = %d", From patchwork Mon Jan 30 09:31:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122667 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 E307E41B7E; Mon, 30 Jan 2023 10:32:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE99342D39; Mon, 30 Jan 2023 10:32:06 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 83F9C40EE2; Mon, 30 Jan 2023 10:32:01 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4P52wK5XcMzJqhP; Mon, 30 Jan 2023 17:30:25 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:31:59 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 03/10] net/hns3: refactor set RSS hash algorithm and key interface Date: Mon, 30 Jan 2023 17:31:22 +0800 Message-ID: <20230130093129.18529-4-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500017.china.huawei.com (7.221.188.110) 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 The hns3_rss_set_algo_key() is used to set RSS hash algorithm and key to hardware. The maximum times of command sent to firmware depend on the length of key. However, now this times is fixed, which isn't good for key expansion. In addition, hash algorithm comes from rss_info::hash_algo maintained in driver, which also isn't good for the usage of this function. This patch has to use hash algorithm and key length as the input parameters of this interface. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 3 ++- drivers/net/hns3/hns3_rss.c | 48 ++++++++++++++++-------------------- drivers/net/hns3/hns3_rss.h | 4 ++- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index a2c1589c39..95609f8483 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1494,7 +1494,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) if (ret) return ret; - ret = hns3_rss_set_algo_key(hw, rss_config->key); + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, + rss_config->key, HNS3_RSS_KEY_SIZE); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index ca5a129234..3db7bf0445 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -277,45 +277,37 @@ static const struct { /* * rss_generic_config command function, opcode:0x0D01. - * Used to set algorithm, key_offset and hash key of rss. + * Used to set algorithm and hash key of RSS. */ int -hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key) +hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + const uint8_t *key, uint8_t key_len) { -#define HNS3_KEY_OFFSET_MAX 3 -#define HNS3_SET_HASH_KEY_BYTE_FOUR 2 - struct hns3_rss_generic_config_cmd *req; struct hns3_cmd_desc desc; - uint32_t key_offset, key_size; - const uint8_t *key_cur; - uint8_t cur_offset; + const uint8_t *cur_key; + uint16_t cur_key_size; + uint16_t max_bd_num; + uint16_t idx; int ret; req = (struct hns3_rss_generic_config_cmd *)desc.data; - /* - * key_offset=0, hash key byte0~15 is set to hardware. - * key_offset=1, hash key byte16~31 is set to hardware. - * key_offset=2, hash key byte32~39 is set to hardware. - */ - for (key_offset = 0; key_offset < HNS3_KEY_OFFSET_MAX; key_offset++) { + max_bd_num = DIV_ROUND_UP(key_len, HNS3_RSS_HASH_KEY_NUM); + for (idx = 0; idx < max_bd_num; idx++) { hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_GENERIC_CONFIG, false); - req->hash_config |= - (hw->rss_info.hash_algo & HNS3_RSS_HASH_ALGO_MASK); - req->hash_config |= (key_offset << HNS3_RSS_HASH_KEY_OFFSET_B); + req->hash_config |= (hash_algo & HNS3_RSS_HASH_ALGO_MASK); + req->hash_config |= (idx << HNS3_RSS_HASH_KEY_OFFSET_B); - if (key_offset == HNS3_SET_HASH_KEY_BYTE_FOUR) - key_size = HNS3_RSS_KEY_SIZE - HNS3_RSS_HASH_KEY_NUM * - HNS3_SET_HASH_KEY_BYTE_FOUR; + if (idx == max_bd_num - 1) + cur_key_size = key_len % HNS3_RSS_HASH_KEY_NUM; else - key_size = HNS3_RSS_HASH_KEY_NUM; + cur_key_size = HNS3_RSS_HASH_KEY_NUM; - cur_offset = key_offset * HNS3_RSS_HASH_KEY_NUM; - key_cur = key + cur_offset; - memcpy(req->hash_key, key_cur, key_size); + cur_key = key + idx * HNS3_RSS_HASH_KEY_NUM; + memcpy(req->hash_key, cur_key, cur_key_size); ret = hns3_cmd_send(hw, &desc, 1); if (ret) { @@ -518,7 +510,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, goto set_tuple_fail; if (key) { - ret = hns3_rss_set_algo_key(hw, key); + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, + key, HNS3_RSS_KEY_SIZE); if (ret) goto set_algo_key_fail; } @@ -795,8 +788,9 @@ hns3_config_rss(struct hns3_adapter *hns) break; } - /* Configure RSS hash algorithm and hash key offset */ - ret = hns3_rss_set_algo_key(hw, hash_key); + /* Configure RSS hash algorithm and hash key */ + ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, + HNS3_RSS_KEY_SIZE); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 8e8b056f4e..b7f62ca1ee 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -109,6 +109,8 @@ int hns3_rss_reset_indir_table(struct hns3_hw *hw); int hns3_config_rss(struct hns3_adapter *hns); void hns3_rss_uninit(struct hns3_adapter *hns); int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); -int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); +int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, + const uint8_t *key, uint8_t key_len); + #endif /* HNS3_RSS_H */ From patchwork Mon Jan 30 09:31:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122666 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 C04CB41B7E; Mon, 30 Jan 2023 10:32:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D95342BB1; Mon, 30 Jan 2023 10:32: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 4EA8740EE1; Mon, 30 Jan 2023 10:32:01 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4P52vq5nVHznVS1; Mon, 30 Jan 2023 17:29:59 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:31:59 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 04/10] net/hns3: fix fixed RSS key size to be more compatibility Date: Mon, 30 Jan 2023 17:31:23 +0800 Message-ID: <20230130093129.18529-5-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500017.china.huawei.com (7.221.188.110) 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 For better compatibility, the RSS key size of PF and VF are obtained from firmware. However, many places still used the old macro HNS3_RSS_KEY_SIZE as the key size. Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_common.c | 12 +++++++++++- drivers/net/hns3/hns3_flow.c | 26 ++++++++++++-------------- drivers/net/hns3/hns3_rss.c | 23 +++++++++++------------ drivers/net/hns3/hns3_rss.h | 3 ++- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index b0c7f8d62c..2da0f30964 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -129,7 +129,7 @@ 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 = HNS3_RSS_KEY_SIZE; + info->hash_key_size = hw->rss_key_size; info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; @@ -895,6 +895,16 @@ hns3_check_dev_specifications(struct hns3_hw *hw) return -EINVAL; } + if (hw->rss_key_size == 0 || hw->rss_key_size > HNS3_RSS_KEY_SIZE_MAX) { + hns3_err(hw, "the RSS key size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", + hw->rss_key_size, HNS3_RSS_KEY_SIZE_MAX); + return -EINVAL; + } + + if (hw->rss_key_size > HNS3_RSS_KEY_SIZE) + hns3_warn(hw, "the RSS key size obtained (%u) is greater than the default key size (%u)", + hw->rss_key_size, HNS3_RSS_KEY_SIZE); + return 0; } diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 95609f8483..a18ec7650d 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1406,10 +1406,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, "a nonzero RSS encapsulation level is not supported"); - if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + if (rss->key_len && rss->key_len != hw->rss_key_size) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, - "RSS hash key must be exactly 40 bytes"); + "invalid RSS key length"); if (!hns3_rss_input_tuple_supported(hw, rss)) return rte_flow_error_set(error, EINVAL, @@ -1443,16 +1443,6 @@ hns3_disable_rss(struct hns3_hw *hw) return 0; } -static void -hns3_adjust_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) -{ - if (rss_conf->key == NULL || rss_conf->key_len < HNS3_RSS_KEY_SIZE) { - hns3_warn(hw, "Default RSS hash key to be set"); - rss_conf->key = hns3_hash_key; - rss_conf->key_len = HNS3_RSS_KEY_SIZE; - } -} - static int hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, uint8_t *hash_algo) @@ -1485,9 +1475,16 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, static int hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) { + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + bool use_default_key = false; int ret; - hns3_adjust_rss_key(hw, rss_config); + if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { + hns3_warn(hw, "Default RSS hash key to be set"); + memcpy(rss_key, hns3_hash_key, + RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); + use_default_key = true; + } ret = hns3_parse_rss_algorithm(hw, &rss_config->func, &hw->rss_info.hash_algo); @@ -1495,7 +1492,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) return ret; ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, - rss_config->key, HNS3_RSS_KEY_SIZE); + use_default_key ? rss_key : rss_config->key, + hw->rss_key_size); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 3db7bf0445..d6e0754273 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -316,7 +316,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, } } /* Update the shadow RSS key with user specified */ - memcpy(hw->rss_info.key, key, HNS3_RSS_KEY_SIZE); + memcpy(hw->rss_info.key, key, hw->rss_key_size); return 0; } @@ -498,9 +498,9 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, uint8_t *key = rss_conf->rss_key; int ret; - if (key && key_len != HNS3_RSS_KEY_SIZE) { + if (key && key_len != hw->rss_key_size) { hns3_err(hw, "the hash key len(%u) is invalid, must be %u", - key_len, HNS3_RSS_KEY_SIZE); + key_len, hw->rss_key_size); return -EINVAL; } @@ -511,7 +511,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, if (key) { ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, - key, HNS3_RSS_KEY_SIZE); + key, hw->rss_key_size); if (ret) goto set_algo_key_fail; } @@ -547,9 +547,9 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, rss_conf->rss_hf = rss_cfg->conf.types; /* Get the RSS Key required by the user */ - if (rss_conf->rss_key && rss_conf->rss_key_len >= HNS3_RSS_KEY_SIZE) { - memcpy(rss_conf->rss_key, rss_cfg->key, HNS3_RSS_KEY_SIZE); - rss_conf->rss_key_len = HNS3_RSS_KEY_SIZE; + if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { + memcpy(rss_conf->rss_key, rss_cfg->key, hw->rss_key_size); + rss_conf->rss_key_len = hw->rss_key_size; } rte_spinlock_unlock(&hw->lock); @@ -754,8 +754,8 @@ hns3_rss_set_default_args(struct hns3_hw *hw) /* Default hash algorithm */ rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; - /* Default RSS key */ - memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); + memcpy(rss_cfg->key, hns3_hash_key, + RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); /* Initialize RSS indirection table */ for (i = 0; i < hw->rss_ind_tbl_size; i++) @@ -788,9 +788,8 @@ hns3_config_rss(struct hns3_adapter *hns) break; } - /* Configure RSS hash algorithm and hash key */ - ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, - HNS3_RSS_KEY_SIZE); + ret = hns3_rss_set_algo_key(hw, rss_cfg->hash_algo, + hash_key, hw->rss_key_size); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index b7f62ca1ee..d6f81996f4 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -29,6 +29,7 @@ #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */ #define HNS3_RSS_IND_TBL_SIZE_MAX 2048 #define HNS3_RSS_KEY_SIZE 40 +#define HNS3_RSS_KEY_SIZE_MAX 128 #define HNS3_RSS_SET_BITMAP_MSK 0xffff #define HNS3_RSS_HASH_ALGO_TOEPLITZ 0 @@ -41,7 +42,7 @@ struct hns3_rss_conf { /* RSS parameters :algorithm, flow_types, key, queue */ struct rte_flow_action_rss conf; uint8_t hash_algo; /* hash function type defined by hardware */ - uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ + uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ bool valid; /* check if RSS rule is valid */ From patchwork Mon Jan 30 09:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122669 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 5CEBE41B7E; Mon, 30 Jan 2023 10:32:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 44C7D42F8C; Mon, 30 Jan 2023 10:32:11 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 540C741144; Mon, 30 Jan 2023 10:32:06 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4P52wR0436zJrW3; Mon, 30 Jan 2023 17:30:30 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:32:04 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 05/10] net/hns3: fix misclearing RSS configuration Date: Mon, 30 Jan 2023 17:31:24 +0800 Message-ID: <20230130093129.18529-6-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) 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 The RSS configuration will be miscleared when driver receives a RSS rule which has more one RSS action. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index a18ec7650d..c338eab049 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1421,12 +1421,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, /* Check if the next not void action is END */ NEXT_ITEM_OF_ACTION(act, actions, act_index); - if (act->type != RTE_FLOW_ACTION_TYPE_END) { - memset(rss_conf, 0, sizeof(struct hns3_rss_conf)); + if (act->type != RTE_FLOW_ACTION_TYPE_END) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act, "Not supported action."); - } return 0; } From patchwork Mon Jan 30 09:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122672 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 887A141B7E; Mon, 30 Jan 2023 10:33:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F84042FB2; Mon, 30 Jan 2023 10:32:15 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id B151742D0D; Mon, 30 Jan 2023 10:32:07 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4P52y5432nzfZ50; Mon, 30 Jan 2023 17:31:57 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:32:04 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 06/10] net/hns3: using RSS filter list to check duplicated rule Date: Mon, 30 Jan 2023 17:31:25 +0800 Message-ID: <20230130093129.18529-7-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) 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 All rules from user are saved in RSS filter list, so use RSS filter list to check duplicated rule. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index c338eab049..303275ae93 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1300,7 +1300,7 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, !memcmp(comp->key, with->key, with->key_len); return (func_is_same && rss_key_is_same && - comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && + comp->types == with->types && comp->level == with->level && comp->queue_num == with->queue_num && !memcmp(comp->queue, with->queue, @@ -1596,15 +1596,7 @@ hns3_config_rss_filter(struct hns3_hw *hw, } /* Set hash algorithm and flow types by the user's config */ - ret = hns3_hw_rss_hash_set(hw, &rss_flow_conf); - if (ret) - return ret; - - ret = hns3_rss_conf_copy(rss_info, &rss_flow_conf); - if (ret) - hns3_err(hw, "RSS config init fail(%d)", ret); - - return ret; + return hns3_hw_rss_hash_set(hw, &rss_flow_conf); } static int @@ -1676,17 +1668,32 @@ hns3_restore_filter(struct hns3_adapter *hns) return hns3_restore_rss_filter(hw); } +static bool +hns3_rss_action_is_dup(struct hns3_hw *hw, + const struct rte_flow_action_rss *act) +{ + struct hns3_rss_conf_ele *filter; + + TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) { + if (!filter->filter_info.valid) + continue; + + if (hns3_action_rss_same(&filter->filter_info.conf, act)) + return true; + } + + return false; +} + static int hns3_flow_parse_rss(struct rte_eth_dev *dev, const struct hns3_rss_conf *conf, bool add) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - bool ret; - ret = hns3_action_rss_same(&hw->rss_info.conf, &conf->conf); - if (ret) { - hns3_err(hw, "Enter duplicate RSS configuration : %d", ret); + if (hns3_rss_action_is_dup(hw, &conf->conf)) { + hns3_err(hw, "duplicate RSS configuration"); return -EINVAL; } From patchwork Mon Jan 30 09:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122671 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 7CDE741B7E; Mon, 30 Jan 2023 10:32:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E165442D38; Mon, 30 Jan 2023 10:32:13 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 29CDD42D3A; Mon, 30 Jan 2023 10:32:07 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4P52vy0zM8z16MwP; Mon, 30 Jan 2023 17:30:06 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:32:05 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 07/10] net/hns3: remove useless code when destroy valid RSS rule Date: Mon, 30 Jan 2023 17:31:26 +0800 Message-ID: <20230130093129.18529-8-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) 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 The hw::rss_info::conf::func was set to the macro RTE_ETH_HASH_FUNCTION_MAX and hw::rss_info::conf::queue was set to NULL when all rules are flushed, which indicates no flow rules is issued. See commit eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush"). Actually, the way determining whether there are rules has been changed by walking the flow RSS list. See commit 705a50800334 ("net/hns3: fix RSS filter restore"). In addition, the rte_flow_action_rss from user isn't saved to 'conf' in hw->rss_info now. So this code can be removed. Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush") Fixes: 705a50800334 ("net/hns3: fix RSS filter restore") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 303275ae93..7adde16cbc 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1279,19 +1279,8 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, bool rss_key_is_same; bool func_is_same; - /* - * When user flush all RSS rule, RSS func is set invalid with - * RTE_ETH_HASH_FUNCTION_MAX. Then the user create a flow after - * flushed, any validate RSS func is different with it before - * flushed. Others, when user create an action RSS with RSS func - * specified RTE_ETH_HASH_FUNCTION_DEFAULT, the func is the same - * between continuous RSS flow. - */ - if (comp->func == RTE_ETH_HASH_FUNCTION_MAX) - func_is_same = false; - else - func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? - (comp->func == with->func) : true; + func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? + (comp->func == with->func) : true; if (with->key_len == 0 || with->key == NULL) rss_key_is_same = 1; @@ -1533,7 +1522,6 @@ static int hns3_config_rss_filter(struct hns3_hw *hw, const struct hns3_rss_conf *conf, bool add) { - struct hns3_rss_conf *rss_info; uint64_t flow_types; uint16_t num; int ret; @@ -1560,7 +1548,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, /* Update the useful flow types */ rss_flow_conf.types = flow_types; - rss_info = &hw->rss_info; if (!add) { if (!conf->valid) return 0; @@ -1571,15 +1558,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, return ret; } - if (rss_flow_conf.queue_num) { - /* - * Due the content of queue pointer have been reset to - * 0, the rss_info->conf.queue should be set to NULL - */ - rss_info->conf.queue = NULL; - rss_info->conf.queue_num = 0; - } - return 0; } From patchwork Mon Jan 30 09:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122670 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 DDDF641B7E; Mon, 30 Jan 2023 10:32:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94CA542F94; Mon, 30 Jan 2023 10:32:12 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 295D342D0D; Mon, 30 Jan 2023 10:32:07 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4P52vx4vJYznV32; Mon, 30 Jan 2023 17:30:05 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:32:05 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 08/10] net/hns3: fix useless warning when flush or destroy rule Date: Mon, 30 Jan 2023 17:31:27 +0800 Message-ID: <20230130093129.18529-9-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) 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 The types of the rule will no longer be used when user flush all rules or destroy a rule. But user would receive some RSS types warnings, like, "modified RSS types based on hardware support, requested:0x137f83fffc configured:0x3ffc". Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 7adde16cbc..fbc38dd3d4 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1537,17 +1537,6 @@ hns3_config_rss_filter(struct hns3_hw *hw, .queue = conf->conf.queue, }; - /* Filter the unsupported flow types */ - flow_types = conf->conf.types ? - rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : - hw->rss_info.conf.types; - if (flow_types != rss_flow_conf.types) - hns3_warn(hw, "modified RSS types based on hardware support, " - "requested:0x%" PRIx64 " configured:0x%" PRIx64, - rss_flow_conf.types, flow_types); - /* Update the useful flow types */ - rss_flow_conf.types = flow_types; - if (!add) { if (!conf->valid) return 0; @@ -1573,6 +1562,17 @@ hns3_config_rss_filter(struct hns3_hw *hw, return ret; } + /* Filter the unsupported flow types */ + flow_types = conf->conf.types ? + rss_flow_conf.types & HNS3_ETH_RSS_SUPPORT : + hw->rss_info.conf.types; + if (flow_types != rss_flow_conf.types) + hns3_warn(hw, "modified RSS types based on hardware support," + " requested:0x%" PRIx64 " configured:0x%" PRIx64, + rss_flow_conf.types, flow_types); + /* Update the useful flow types */ + rss_flow_conf.types = flow_types; + /* Set hash algorithm and flow types by the user's config */ return hns3_hw_rss_hash_set(hw, &rss_flow_conf); } From patchwork Mon Jan 30 09:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122673 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 9923641B7E; Mon, 30 Jan 2023 10:33:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD26142FA4; Mon, 30 Jan 2023 10:32:16 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 9D1B742D3C; Mon, 30 Jan 2023 10:32:07 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4P52y63ylgzfZ0n; Mon, 30 Jan 2023 17:31:58 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:32:05 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 09/10] net/hns3: fix bad memory structure conversion Date: Mon, 30 Jan 2023 17:31:28 +0800 Message-ID: <20230130093129.18529-10-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) 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 When the type in 'struct rte_flow_action' is RTE_FLOW_ACTION_TYPE_RSS, the 'conf' pointer references the 'struct rte_flow_action_rss' instead of the 'struct hns3_rss_conf' in driver. But driver uses 'struct hns3_rss_conf' to convert this 'conf' pointer to get RSS action configuration. In addition, RSS filter configuration is directly cloned to RSS filter node instead of coping it after successfully setting to hardware. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 57 +++++++++++++----------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index fbc38dd3d4..307aba75a7 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -95,8 +95,8 @@ static const struct rte_flow_action * hns3_find_rss_general_action(const struct rte_flow_item pattern[], const struct rte_flow_action actions[]) { + const struct rte_flow_action_rss *rss_act; const struct rte_flow_action *act = NULL; - const struct hns3_rss_conf *rss; bool have_eth = false; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -115,8 +115,8 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[], } } - rss = act->conf; - if (have_eth && rss->conf.queue_num) { + rss_act = act->conf; + if (have_eth && rss_act->queue_num) { /* * Pattern have ETH and action's queue_num > 0, indicate this is * queue region configuration. @@ -1296,30 +1296,6 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, sizeof(*with->queue) * with->queue_num)); } -static int -hns3_rss_conf_copy(struct hns3_rss_conf *out, - const struct rte_flow_action_rss *in) -{ - if (in->key_len > RTE_DIM(out->key) || - in->queue_num > RTE_DIM(out->queue)) - return -EINVAL; - if (in->key == NULL && in->key_len) - return -EINVAL; - out->conf = (struct rte_flow_action_rss) { - .func = in->func, - .level = in->level, - .types = in->types, - .key_len = in->key_len, - .queue_num = in->queue_num, - }; - out->conf.queue = memcpy(out->queue, in->queue, - sizeof(*in->queue) * in->queue_num); - if (in->key) - out->conf.key = memcpy(out->key, in->key, in->key_len); - - return 0; -} - static bool hns3_rss_input_tuple_supported(struct hns3_hw *hw, const struct rte_flow_action_rss *rss) @@ -1733,9 +1709,10 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, struct rte_flow *flow) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + const struct rte_flow_action_rss *rss_act; struct hns3_rss_conf_ele *rss_filter_ptr; struct hns3_rss_conf_ele *filter_ptr; - const struct hns3_rss_conf *rss_conf; + struct hns3_rss_conf *new_conf; int ret; rss_filter_ptr = rte_zmalloc("hns3 rss filter", @@ -1745,19 +1722,25 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev, return -ENOMEM; } - /* - * After all the preceding tasks are successfully configured, configure - * rules to the hardware to simplify the rollback of rules in the - * hardware. - */ - rss_conf = (const struct hns3_rss_conf *)act->conf; - ret = hns3_flow_parse_rss(dev, rss_conf, true); + rss_act = (const struct rte_flow_action_rss *)act->conf; + new_conf = &rss_filter_ptr->filter_info; + memcpy(&new_conf->conf, rss_act, sizeof(*rss_act)); + if (rss_act->queue_num > 0) { + memcpy(new_conf->queue, rss_act->queue, + rss_act->queue_num * sizeof(new_conf->queue[0])); + new_conf->conf.queue = new_conf->queue; + } + if (rss_act->key_len > 0) { + memcpy(new_conf->key, rss_act->key, + rss_act->key_len * sizeof(new_conf->key[0])); + new_conf->conf.key = new_conf->key; + } + + ret = hns3_flow_parse_rss(dev, new_conf, true); if (ret != 0) { rte_free(rss_filter_ptr); return ret; } - - hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf); rss_filter_ptr->filter_info.valid = true; /* From patchwork Mon Jan 30 09:31:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 122674 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 1C20241B7E; Mon, 30 Jan 2023 10:33:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86C8342FD6; Mon, 30 Jan 2023 10:32:18 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 8436742D3F; Mon, 30 Jan 2023 10:32:12 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4P52vs0w5FzRqq2; Mon, 30 Jan 2023 17:30:01 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 30 Jan 2023 17:32:10 +0800 From: Dongdong Liu To: , , , CC: , , , Subject: [PATCH V2 10/10] net/hns3: fix incorrect check for duplicate RSS rule Date: Mon, 30 Jan 2023 17:31:29 +0800 Message-ID: <20230130093129.18529-11-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20230130093129.18529-1-liudongdong3@huawei.com> References: <20230129105140.29921-1-liudongdong3@huawei.com> <20230130093129.18529-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500017.china.huawei.com (7.221.188.110) 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 Currently, the interface for verifying duplicate RSS rules has some problems: 1) If the value of 'func' in configuring RSS rule is default value, this rule is mistakenly considered as a duplicate rule. 2) If key length is zero or 'key' is NULL in configuring RSS rule this rule is also mistakenly considered as a duplicate rule. 3) If 'key' or 'queue' in struct rte_flow_action_rss being NULL is used to memcpy, which may cause segment fault. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 63 +++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 307aba75a7..8ff9d4ae66 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1272,28 +1272,59 @@ hns3_filterlist_flush(struct rte_eth_dev *dev) } } +static bool +hns3_flow_rule_key_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + if (comp->key_len != with->key_len) + return false; + + if (with->key_len == 0) + return true; + + if (comp->key == NULL && with->key == NULL) + return true; + + if (!(comp->key != NULL && with->key != NULL)) + return false; + + return !memcmp(comp->key, with->key, with->key_len); +} + +static bool +hns3_flow_rule_queues_same(const struct rte_flow_action_rss *comp, + const struct rte_flow_action_rss *with) +{ + if (comp->queue_num != with->queue_num) + return false; + + if (with->queue_num == 0) + return true; + + if (comp->queue == NULL && with->queue == NULL) + return true; + + if (!(comp->queue != NULL && with->queue != NULL)) + return false; + + return !memcmp(comp->queue, with->queue, with->queue_num); +} + static bool hns3_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - bool rss_key_is_same; - bool func_is_same; + bool same_level; + bool same_types; + bool same_func; - func_is_same = (with->func != RTE_ETH_HASH_FUNCTION_DEFAULT) ? - (comp->func == with->func) : true; + same_level = (comp->level == with->level); + same_types = (comp->types == with->types); + same_func = (comp->func == with->func); - if (with->key_len == 0 || with->key == NULL) - rss_key_is_same = 1; - else - rss_key_is_same = comp->key_len == with->key_len && - !memcmp(comp->key, with->key, with->key_len); - - return (func_is_same && rss_key_is_same && - comp->types == with->types && - comp->level == with->level && - comp->queue_num == with->queue_num && - !memcmp(comp->queue, with->queue, - sizeof(*with->queue) * with->queue_num)); + return same_level && same_types && same_func && + hns3_flow_rule_key_same(comp, with) && + hns3_flow_rule_queues_same(comp, with); } static bool