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 A434545B17; Sat, 12 Oct 2024 04:42:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A6E040656; Sat, 12 Oct 2024 04:41:47 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2133.outbound.protection.outlook.com [40.107.100.133]) by mails.dpdk.org (Postfix) with ESMTP id E6B4A4064F for ; Sat, 12 Oct 2024 04:41:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zV4Eb0gvjGDL8dI4csT/bB4tto3dgBG1ifNRNaCZOyGHeM8dNhCRAOpC7PS/UbWFsP1C3DtOlThb6gyDf7yW9gkjPFuNAXdoYViI/iKkChNGO+XHVFbpSairCETXc9T4uuuhxu/bopdnQmzjObpjEnoDkaRMYUstcLmzBnw2nOCiHxgBGhzQDxrKq7eUJvQEE0p0mU+PGSAhCsKcma5fsPQdR+q/18pX9QEl4oI6Z6VLS61t4gUVklXVMMSwhSLPv3c9YzrjFRYivc3x0AjbVwr4ji4xRrjld/Ejp5onXcYnUMcl7JrdYpHb13Aabr4BHCI0B5hvMbby7DIWDnyWuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WbgaHOrBFPcD1b90icegQ4yaee/z7noTTLbZNLhVEB0=; b=lDEoWFUDstTpQ3g+l/Eiw3GEa7q6Mf1HpGyZ+AHKM601aB/BUoP287OSfkq3oRvO1yv3C37JfPZ1evq5ogQVr9igRpxFPfhyaizcMNQn6b9MI8PUc1t7yAlY0B7Fpr18P5tbvnblZMvaMSht09E7/1nBX8aFjX6XUFhauwhyxeUY5oCLqhqtZoEIwqnkikhqfC70PARPtPWGAKj3lTCHBrOvDsSjEAPshN2eQg3sG78LulbZoSTjbw3rpiDM9GgLXfdsXzevHS0wvdMy772XnV9U55k0PWpeBUxivvE33cI5jKKD5aiUZjkGlp6aa+nQS9oB+SA4fX/PqjsrfzZI4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WbgaHOrBFPcD1b90icegQ4yaee/z7noTTLbZNLhVEB0=; b=TM0HzXDmUqsvWPubLXDNYVfq0llPqJ56vFgwxTIJYErFqJOSdME/Ia3uPDbQuOe3MpKkzLQWMJ4GZjIEkBuQTCCKkwHyCobheynuoaZbJdwoWd0wvnCzP9EXZYBPk610muRlwK4Yfl8RS/i0TzQBfQEjmcOAAA9vmsQYhy3AslQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by CO1PR13MB4902.namprd13.prod.outlook.com (2603:10b6:303:f0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.21; Sat, 12 Oct 2024 02:41:42 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%5]) with mapi id 15.20.8048.017; Sat, 12 Oct 2024 02:41:42 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH v2 04/10] net/nfp: improve the logic readability Date: Sat, 12 Oct 2024 10:41:01 +0800 Message-Id: <20241012024107.3795935-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20241012024107.3795935-1-chaoyong.he@corigine.com> References: <20241010091716.3631747-1-chaoyong.he@corigine.com> <20241012024107.3795935-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR06CA0001.apcprd06.prod.outlook.com (2603:1096:4:186::21) To PH0PR13MB5568.namprd13.prod.outlook.com (2603:10b6:510:12b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO1PR13MB4902:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c25bd0a-5e11-465b-11c1-08dcea676785 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qtKSMmnKvSSvCCfEn5Fv4fngRCCtmUv+33eLAZqgzVBuP6NORGrwdeDxtGxz?= =?us-ascii?Q?Reoj3GPgG06edjkVkCnnIV+i2wwXOhVvH32D0OLlYgXEI+qd6jrCU6QkKcFo?= =?us-ascii?Q?kWb6O84AAHhvs4650abWaUryWai1yQAZh14mnTC4mGWJT4cqLuOoWe0H/PGn?= =?us-ascii?Q?d8lycHYptJxRqJRUoOzRIR2fHrG8nocJRWClK7SlUwijNHhdzY5LHv82EG7Y?= =?us-ascii?Q?qPfMouxBoSNgdRWdf/kqoyQQaBPMitR2vyTHwJYS1ednC0q4YIq+zMZ/syj2?= =?us-ascii?Q?FhfR+qUTs2fAgveBXjLSUyEERhZMV9qANITJTRnR2xmJhSvbgSaWcf4Rs6Al?= =?us-ascii?Q?4mwb9FdXqpTjQb9bmD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ascii?Q?QQeI/GgDQo1TtTsPSofpV7uBSWi20Nrje0qKGxBFa39KhsqLnGbG9k4pR0AS?= =?us-ascii?Q?GwcYIw2YhR/t5LSg8bf6pB810I8R9RnL2u7ByJ3ISdV7Ng=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?BNY/kFVDY5PJA466Ca+gTB3Jrb3Xw9JyzMsjnMMQPpj7S29wvDx+32iz4iJJ?= =?us-ascii?Q?B49AtX/j3jyIoD3udfUJnlCLYteHBvh5z0Vvh4wdSEHSpps1kEme8y/aspX+?= =?us-ascii?Q?L/jpj3xFg7a7qF0wvKTM+JNJfMKFTjcssS92NxCZD8/V13fxF4jx4BeIvKBO?= =?us-ascii?Q?DwtRSqszZhiHKmmYH9nv134LxbacO5mhi6NqAsJ2LMeckzyURx7FimMHNdbV?= =?us-ascii?Q?zNanDpVz9jBxaxNokNHUwMGt5TPJpbixHzgthXvFQZ/MoHYWQNQgD9q1TfbB?= =?us-ascii?Q?C3MUBXoI4OJAoiZg2DgFN68almZ6hGCJ84yHNVVd/BDIKVgUrk39OanKOpx0?= =?us-ascii?Q?jmViZNRjjObb/RMUq++INFFEpnHmulegPpVVMgSTGESid3bUwYpcwq6Pwc6K?= =?us-ascii?Q?QV3vJjk0r6Kflk6Frhmn8iID5bhfusL8zITG9zuvzkCyaxsGBBJtbuBoM0sH?= =?us-ascii?Q?z4D6mEL4MlBtIdE33i1E9zc6xysqm+2BvXr6iToZ9K3OJKs9f3sqXAO5P0O5?= =?us-ascii?Q?bYF20x2oXjBJC9g2wfgP4sPJMscJCVtnmviKWK85+EnVRNzPLa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i/uGTDObB4ACe9sNxBXr+qwXssVG5/z1i0gG2Y4Aa?= =?us-ascii?Q?FRbBLRCj34ZPs3lqZIJJ9WCsO1tQkOhwUn0vrKZLFA7C6PTvHWm7kNc3h7o4?= =?us-ascii?Q?9cEg1/DACr4WC2Brbm9PJLwQcmYywgbMJe9IwR1vmndM2gtFgdAwnlVi6ddX?= =?us-ascii?Q?tA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c25bd0a-5e11-465b-11c1-08dcea676785 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB5568.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2024 02:41:42.2361 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eNCARfCbGjRK2mXlVb/POUPsVKkkDjsxboF7xWFetsnUWc5VzW4GVSckrj5mLEALWlB/R/CTd3SOKVbqO/d3BBXyBxiSMs7aw6Z3Bujcwz8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR13MB4902 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 Try our best to make the logic in secondary proess the same with the primary process and improve the readability, by add helper functions and rename function. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_ethdev.c | 86 +++++++++++++++----------------- drivers/net/nfp/nfp_net_common.c | 22 +++++++- drivers/net/nfp/nfp_net_common.h | 3 +- 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 121f82af6d..405386e882 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -1764,19 +1764,9 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev) static bool nfp_app_fw_nic_total_phyports_check(struct nfp_pf_dev *pf_dev) { - int ret; - uint8_t id; uint8_t total_phyports; - char vnic_name[RTE_ETH_NAME_MAX_LEN]; - /* Read the number of vNIC's created for the PF */ - id = nfp_function_id_get(pf_dev, 0); - snprintf(vnic_name, sizeof(vnic_name), "nfd_cfg_pf%u_num_ports", id); - total_phyports = nfp_rtsym_read_le(pf_dev->sym_tbl, vnic_name, &ret); - if (ret != 0 || total_phyports == 0 || total_phyports > 8) { - PMD_INIT_LOG(ERR, "%s symbol with wrong value", vnic_name); - return false; - } + total_phyports = nfp_net_get_phyports_from_fw(pf_dev); if (pf_dev->multi_pf.enabled) { if (!nfp_check_multi_pf_from_fw(total_phyports)) { @@ -1797,6 +1787,20 @@ nfp_app_fw_nic_total_phyports_check(struct nfp_pf_dev *pf_dev) return true; } +static void +nfp_port_name_generate(char *port_name, + size_t length, + int port_id, + struct nfp_pf_dev *pf_dev) +{ + const char *name = pf_dev->pci_dev->device.name; + + if (pf_dev->multi_pf.enabled) + snprintf(port_name, length, "%s", name); + else + snprintf(port_name, length, "%s_port%u", name, port_id); +} + static int nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) { @@ -1849,12 +1853,7 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) /* Loop through all physical ports on PF */ for (i = 0; i < pf_dev->total_phyports; i++) { - if (pf_dev->multi_pf.enabled) - snprintf(port_name, sizeof(port_name), "%s", - pf_dev->pci_dev->device.name); - else - snprintf(port_name, sizeof(port_name), "%s_port%u", - pf_dev->pci_dev->device.name, i); + nfp_port_name_generate(port_name, sizeof(port_name), i, pf_dev); id = nfp_function_id_get(pf_dev, i); hw_init.idx = id; @@ -1870,15 +1869,10 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) return 0; port_cleanup: - for (i = 0; i < pf_dev->total_phyports; i++) { + for (uint32_t j = 0; j < i; j++) { struct rte_eth_dev *eth_dev; - if (pf_dev->multi_pf.enabled) - snprintf(port_name, sizeof(port_name), "%s", - pf_dev->pci_dev->device.name); - else - snprintf(port_name, sizeof(port_name), "%s_port%u", - pf_dev->pci_dev->device.name, i); + nfp_port_name_generate(port_name, sizeof(port_name), j, pf_dev); eth_dev = rte_eth_dev_get_by_name(port_name); if (eth_dev != NULL) rte_eth_dev_destroy(eth_dev, nfp_net_uninit); @@ -2369,7 +2363,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev) pf_dev->nfp_eth_table = nfp_eth_table; pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_nsp(pci_dev, cpp); pf_dev->multi_pf.function_id = function_id; - pf_dev->total_phyports = nfp_net_get_port_num(pf_dev); + pf_dev->total_phyports = nfp_net_get_phyports_from_nsp(pf_dev); ret = nfp_net_force_port_down(pf_dev); if (ret != 0) { @@ -2547,42 +2541,37 @@ static int nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) { uint32_t i; - int err = 0; int ret = 0; - uint8_t function_id; uint32_t total_vnics; - char pf_name[RTE_ETH_NAME_MAX_LEN]; + char port_name[RTE_ETH_NAME_MAX_LEN]; struct nfp_pf_dev *pf_dev = hw_priv->pf_dev; - /* Read the number of vNIC's created for the PF */ - function_id = (pf_dev->pci_dev->addr.function) & 0x07; - snprintf(pf_name, sizeof(pf_name), "nfd_cfg_pf%u_num_ports", function_id); - total_vnics = nfp_rtsym_read_le(pf_dev->sym_tbl, pf_name, &err); - if (err != 0 || total_vnics == 0 || total_vnics > 8) { - PMD_INIT_LOG(ERR, "%s symbol with wrong value", pf_name); - return -ENODEV; - } + total_vnics = nfp_net_get_phyports_from_fw(pf_dev); for (i = 0; i < total_vnics; i++) { - char port_name[RTE_ETH_NAME_MAX_LEN]; - - if (nfp_check_multi_pf_from_fw(total_vnics)) - snprintf(port_name, sizeof(port_name), "%s", - pf_dev->pci_dev->device.name); - else - snprintf(port_name, sizeof(port_name), "%s_port%u", - pf_dev->pci_dev->device.name, i); + nfp_port_name_generate(port_name, sizeof(port_name), i, pf_dev); PMD_INIT_LOG(DEBUG, "Secondary attaching to port %s", port_name); ret = rte_eth_dev_create(&pf_dev->pci_dev->device, port_name, 0, NULL, NULL, nfp_secondary_net_init, hw_priv); if (ret != 0) { PMD_INIT_LOG(ERR, "Secondary process attach to port %s failed", port_name); - ret = -ENODEV; - break; + goto port_cleanup; } } + return 0; + +port_cleanup: + for (uint32_t j = 0; j < i; j++) { + struct rte_eth_dev *eth_dev; + + nfp_port_name_generate(port_name, sizeof(port_name), j, pf_dev); + eth_dev = rte_eth_dev_get_by_name(port_name); + if (eth_dev != NULL) + rte_eth_dev_destroy(eth_dev, NULL); + } + return ret; } @@ -2714,6 +2703,11 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) pf_dev->sym_tbl = sym_tbl; + /* Read the number of physical ports from firmware */ + pf_dev->multi_pf.function_id = function_id; + pf_dev->total_phyports = nfp_net_get_phyports_from_fw(pf_dev); + pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_fw(pf_dev->total_phyports); + /* Read the app ID of the firmware loaded */ snprintf(app_name, sizeof(app_name), "_pf%u_net_app_id", function_id); app_fw_id = nfp_rtsym_read_le(sym_tbl, app_name, &ret); diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 99f6b61947..86a1fbfaf2 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -14,6 +14,7 @@ #include "nfdk/nfp_nfdk.h" #include "nfpcore/nfp_mip.h" #include "nfpcore/nfp_nsp.h" +#include "nfpcore/nfp_rtsym.h" #include "nfp_logs.h" #include "nfp_net_meta.h" @@ -2724,7 +2725,7 @@ nfp_net_fec_set(struct rte_eth_dev *dev, } uint32_t -nfp_net_get_port_num(struct nfp_pf_dev *pf_dev) +nfp_net_get_phyports_from_nsp(struct nfp_pf_dev *pf_dev) { if (pf_dev->multi_pf.enabled) return 1; @@ -2732,6 +2733,25 @@ nfp_net_get_port_num(struct nfp_pf_dev *pf_dev) return pf_dev->nfp_eth_table->count; } +uint32_t +nfp_net_get_phyports_from_fw(struct nfp_pf_dev *pf_dev) +{ + int ret = 0; + uint8_t total_phyports; + char pf_name[RTE_ETH_NAME_MAX_LEN]; + + /* Read the number of vNIC's created for the PF */ + snprintf(pf_name, sizeof(pf_name), "nfd_cfg_pf%u_num_ports", + pf_dev->multi_pf.function_id); + total_phyports = nfp_rtsym_read_le(pf_dev->sym_tbl, pf_name, &ret); + if (ret != 0 || total_phyports == 0 || total_phyports > 8) { + PMD_INIT_LOG(ERR, "%s symbol with wrong value", pf_name); + return 0; + } + + return total_phyports; +} + uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev, uint8_t port_id) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index fb244383b7..8429db68f0 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -374,7 +374,8 @@ void nfp_net_get_fw_version(struct nfp_cpp *cpp, uint32_t *fw_version); int nfp_net_txrwb_alloc(struct rte_eth_dev *eth_dev); void nfp_net_txrwb_free(struct rte_eth_dev *eth_dev); -uint32_t nfp_net_get_port_num(struct nfp_pf_dev *pf_dev); +uint32_t nfp_net_get_phyports_from_nsp(struct nfp_pf_dev *pf_dev); +uint32_t nfp_net_get_phyports_from_fw(struct nfp_pf_dev *pf_dev); uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev, uint8_t port_id); int nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw, -- 2.39.1