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 7927A41D52 for ; Thu, 23 Feb 2023 16:08:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85BD74328D; Thu, 23 Feb 2023 16:08:06 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 15B554328C for ; Thu, 23 Feb 2023 16:08:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677164884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mw08y2N71euKNw0ITrYeJOFHJ3I/2rYmMkom0swOJuA=; b=AjSU2Kw2/DBMxnzZ8RCwYOHIt7ByW3eRbMfI43fiKJ9mfSIXtOH39iXO4WiYty3lVr7xj+ DWwp6U22FXaTqqz+oK2IzWchwfSaESN8tPjRkeQH7XAR1TvVmgu7fVzs3Y+hJJaZ5zJpn7 ghuTo9Q3d8TPBjoWIdgjAJzZvBVs1jI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-juJHw79rPLSrveOFNmOenw-1; Thu, 23 Feb 2023 10:07:59 -0500 X-MC-Unique: juJHw79rPLSrveOFNmOenw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C06B8021B9; Thu, 23 Feb 2023 15:07:57 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A77392166B2C; Thu, 23 Feb 2023 15:07:56 +0000 (UTC) From: Kevin Traynor To: Huisong Li Cc: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: extract common function to query device' has been queued to stable release 21.11.4 Date: Thu, 23 Feb 2023 15:05:48 +0000 Message-Id: <20230223150631.723699-57-ktraynor@redhat.com> In-Reply-To: <20230223150631.723699-1-ktraynor@redhat.com> References: <20230223150631.723699-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/28/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/b6328f7feb6691619bcb474d0e920f4aeec3f9fa Thanks. Kevin --- >From b6328f7feb6691619bcb474d0e920f4aeec3f9fa Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Tue, 31 Jan 2023 21:02:52 +0800 Subject: [PATCH] net/hns3: extract common function to query device [ upstream commit 52a4e960b49c526dd1ad7c1e91ebcfa664a38e6d ] Extract common function to query device specifications used by VF and PF. Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_common.c | 75 +++++++++++++++++++++++++++++++ drivers/net/hns3/hns3_common.h | 5 ++- drivers/net/hns3/hns3_ethdev.c | 63 -------------------------- drivers/net/hns3/hns3_ethdev_vf.c | 65 +-------------------------- 4 files changed, 81 insertions(+), 127 deletions(-) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index 9b6b18a5bc..dc24f7557d 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -12,4 +12,5 @@ #include "hns3_regs.h" #include "hns3_rxtx.h" +#include "hns3_dcb.h" int @@ -769,2 +770,76 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw) 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 0dbb1c0413..1d2ca24194 100644 --- a/drivers/net/hns3/hns3_common.h +++ b/drivers/net/hns3/hns3_common.h @@ -59,3 +59,6 @@ void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev); int hns3_restore_rx_interrupt(struct hns3_hw *hw); -#endif /* _HNS3_COMMON_H_ */ +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 ca59c42f4a..be6a92a313 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2665,67 +2665,4 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) } -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 87d094a6b4..0e66a82178 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -689,65 +689,4 @@ hns3vf_interrupt_handler(void *param) } -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) @@ -839,5 +778,5 @@ hns3vf_get_capability(struct hns3_hw *hw) if (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; @@ -850,5 +789,5 @@ hns3vf_get_capability(struct hns3_hw *hw) } - ret = hns3vf_query_dev_specifications(hw); + ret = hns3_query_dev_specifications(hw); if (ret) { PMD_INIT_LOG(ERR, -- 2.39.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-23 14:46:25.190492174 +0000 +++ 0057-net-hns3-extract-common-function-to-query-device.patch 2023-02-23 14:46:23.803236081 +0000 @@ -1 +1 @@ -From 52a4e960b49c526dd1ad7c1e91ebcfa664a38e6d Mon Sep 17 00:00:00 2001 +From b6328f7feb6691619bcb474d0e920f4aeec3f9fa Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 52a4e960b49c526dd1ad7c1e91ebcfa664a38e6d ] + @@ -10 +11,0 @@ -Cc: stable@dpdk.org @@ -16 +17 @@ - drivers/net/hns3/hns3_common.h | 2 + + drivers/net/hns3/hns3_common.h | 5 ++- @@ -19 +20 @@ - 4 files changed, 79 insertions(+), 126 deletions(-) + 4 files changed, 81 insertions(+), 127 deletions(-) @@ -22 +23 @@ -index da0a481f15..74d537d8d0 100644 +index 9b6b18a5bc..dc24f7557d 100644 @@ -25 +26 @@ -@@ -11,4 +11,5 @@ +@@ -12,4 +12,5 @@ @@ -29 +29,0 @@ - #include "hns3_common.h" @@ -31 +31,2 @@ -@@ -847,2 +848,76 @@ hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id) + int +@@ -769,2 +770,76 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw) @@ -109 +110 @@ -index 5aa001f0cc..8eaeda26e7 100644 +index 0dbb1c0413..1d2ca24194 100644 @@ -112 +113,2 @@ -@@ -61,4 +61,6 @@ int hns3_restore_rx_interrupt(struct hns3_hw *hw); +@@ -59,3 +59,6 @@ void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev); + int hns3_restore_rx_interrupt(struct hns3_hw *hw); @@ -114 +116 @@ - int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id); +-#endif /* _HNS3_COMMON_H_ */ @@ -117,2 +119,2 @@ - - #endif /* HNS3_COMMON_H */ ++ ++#endif /* HNS3_COMMON_H */ @@ -120 +122 @@ -index eb809cd8c9..ab565ce128 100644 +index ca59c42f4a..be6a92a313 100644 @@ -123 +125 @@ -@@ -2648,67 +2648,4 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) +@@ -2665,67 +2665,4 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) @@ -192 +194 @@ -index e43815607a..d3c1bdf2c5 100644 +index 87d094a6b4..0e66a82178 100644 @@ -261 +263 @@ -@@ -827,5 +766,5 @@ hns3vf_get_capability(struct hns3_hw *hw) +@@ -839,5 +778,5 @@ hns3vf_get_capability(struct hns3_hw *hw) @@ -263 +265 @@ - if (hw->revision < PCI_REVISION_ID_HIP09_A) { + if (revision < PCI_REVISION_ID_HIP09_A) { @@ -268 +270 @@ -@@ -838,5 +777,5 @@ hns3vf_get_capability(struct hns3_hw *hw) +@@ -850,5 +789,5 @@ hns3vf_get_capability(struct hns3_hw *hw)