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 E0BF145B17; Sat, 12 Oct 2024 04:41:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9528B40616; Sat, 12 Oct 2024 04:41:45 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2120.outbound.protection.outlook.com [40.107.100.120]) by mails.dpdk.org (Postfix) with ESMTP id 4ED7340268 for ; Sat, 12 Oct 2024 04:41:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oFfj3PZsKAvLu30Vw87E0ls9Ppxz9XJdmsQmnhz/quYE7T1HwdaIdT8xkqi1ODNddfQ8t/5CDBG+81ZCvbNecVFLURgyIbrkwIuCE80K8ONeOoPHqw9oUj8sz4z7PRjepETphyrY3CV7McCLBscsTusjaPgAlPJ6HVP+9zcTEMTBLMOju9b0q7SuKraD+uILaPdf6R4Baom1FJLXHppQJh6PRC9P7NbKg7g+7PyjBWo3k0T5jxF0/qGvNyslfCtiYD8wXeXZ8pWViEbf9t2f9mDO3hSYiu6iX06k05Z1r7wR+HIeYa9a2Uc5EfKivmMik/b7tWr0MqzxqC5RUMQS7Q== 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=479VcWxShuNeu3kUtCdfGAjTmCSTWbibAoIN1bQLEYQ=; b=aHfCMZZPUjnWLfHoRW83L6wLevRFYNe+mNeayR1syOQ91ave8Y2jmdFoYoz4umuAqV8wAPnHjxV5yKxHtWhGNg9EwMFkclWcY35pwdzwHGlkyjBJdczFqUu2dV9hf2d1S9ss/rBfH3L/was4QVV02Bd15Jriwl3zvSoywVqo3/rMgO0Q1H91lNLWr7vw9OXw1yYZyhe0VL/MDWJi+zbmyYFzGzI6CuhodvMb6IW2mRoIqguO1Bf1KZqU4IbV6lAedR7tkBFXzdHUN9HmHeBsJlJT1dqyxO2bg6+o+7JOLUQSWS2jOGQ4ejTnqDGAZ1WksUv9r6zBZmrFUq3wAQW8hA== 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=479VcWxShuNeu3kUtCdfGAjTmCSTWbibAoIN1bQLEYQ=; b=b9b6deJZ28KG1LCL6wCMZFhnlY/FcWJK9FV65T6K2hLD/5S+EIHAflL9uhyWGOXeg/mxLRe6MqNTw22MdCwdpANWfMcWUvmrctIwxGz60ryKz/LcDnYaSTD/9agrMDyO1NPSjwwRGQOjqw5MDF3bm1CX9QRj3A0hElobw8lWVr0= 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:39 +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:39 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang , Stephen Hemminger Subject: [PATCH v2 03/10] net/nfp: simplify some function parameters Date: Sat, 12 Oct 2024 10:41:00 +0800 Message-Id: <20241012024107.3795935-4-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: 015d690a-1f6b-4adf-c927-08dcea6765ef 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?NtljsynZV8lnMiA7+kpLuBej3XNEjMkLJnbRaHWGLVT3P0b9DkrDtbmBUfEu?= =?us-ascii?Q?o4l9HwPLd7MFxmbu8W62JocD1B1xr6hdfEc+HT0Uv4RzJrV5kESB+MPvXRBk?= =?us-ascii?Q?LoNvWzDeX4ZKEOmVms8r6E+V4vjuCfjmz3kufKPZDiDdyIx1L+YgHCV/el0C?= =?us-ascii?Q?J8F0GZL8M82LZWZYEQ5H96ZKy0N9NijARdumOd5relJGUr08whRKelKc0Nyf?= =?us-ascii?Q?2T/6YCpSKYvH9v5DBphRi/UmSLEeZ4KmqXpZkS4eON8OpiF2mK8sUBYdb3fg?= =?us-ascii?Q?vYLd65Agid4mrYEQNNi2CkaOu6R3Nu+wSO985YrumfxAVgU5RALx2NQD+c7f?= =?us-ascii?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ZzA/OYXNKvJV8JZ1udsjD7?= =?us-ascii?Q?oba5mwqM3RmNNQDhQyPBFf72Yj20EzOBfZoS3sadzgEXvKAGZlJ4fbUR7WWJ?= =?us-ascii?Q?SgguW0L6TM7D4qOYSTlAqiZBIfzWUPPlv8/V0V+5EO3WyQ=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?J3dZl4myFt+dcB8nZZAINsBkOHyvDuFApr7OdFXct4ldQK5GZvASflh5qfgy?= =?us-ascii?Q?ksPG7X1OU6mQEqBeXuI3l2KpIc03oKdIOupqOmotHpmkyWjI4s+ouLhm4pia?= =?us-ascii?Q?mm/JWnws05MUcMnl20IWxIalCmAUjOU4lln1YP+s7aUbkzfe9bknQoesHPtr?= =?us-ascii?Q?7hF6ZM8va43NpOJJ5STqisLfUMBenoPr5rdCk++cppLF2RGaaQQBXZy3xUsL?= =?us-ascii?Q?DuCkZWIhqCIVmngYu19BzGdTCZ5/K49vaETpn4jgXJEkhQDHSz7UFKgGRz8t?= =?us-ascii?Q?Mne9PZ1q3oWDiDUCJM6kEql4klRyp6XpHb5JJoxm+Jg0Bz+l6KU5uCSAO8jV?= =?us-ascii?Q?6r5P9USVNS1UNkQDC0Lc8kmHQpDQ4yQvT3h/o84ac3E7ElH+z5gOmqrZ7pxb?= =?us-ascii?Q?mMptJoOCtKa6Ae7G+uUuIR+p7UPR1/neihiRY5CEZvULGO9X5Jt5KA1KwDew?= =?us-ascii?Q?oK5ml2NdaTSSACTJgRbpCUOdw+e2uTmt496V2AInajeRD2kU6Px3hF/O/bHx?= =?us-ascii?Q?cvtEhrxf6re4uc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MiEd?= =?us-ascii?Q?uJO6OuwR/fP13qrdpXQnLWDFPkVxfCJL9MzNxwihLPby42Gq17CLsOUxvEi6?= =?us-ascii?Q?p/w875isJ+7ejBWaEPYveVaYbf7VDGq5sQqIndpjxLtUHA4XxaEHoipZXjbV?= =?us-ascii?Q?E/WUNjN5KS+Jmjxcn2jZsfGZFXL2ZhqjuLiiFows+H/WNy77y7D24YDZy7Yv?= =?us-ascii?Q?7Q=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 015d690a-1f6b-4adf-c927-08dcea6765ef 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:39.5802 (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: v3wKgg4YxQNHWKeZQKzvEbdQRByWqQhbEXD2NrcUs9GzbhVJ77SxRwbJsA3OjxZjZyQtMCUlUykT7Pabp7WzwQwYW4jCZs+fyMnjr2F4WDw= 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 Refactor to the logic of initialize process to simplify some function parameters, both for primary and secodary process. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang Acked-by: Stephen Hemminger --- drivers/net/nfp/nfp_ethdev.c | 153 +++++++++++++++---------------- drivers/net/nfp/nfp_net_common.c | 5 +- drivers/net/nfp/nfp_net_common.h | 3 +- 3 files changed, 76 insertions(+), 85 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 3732abc9fe..121f82af6d 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -1160,14 +1160,15 @@ nfp_net_init(struct rte_eth_dev *eth_dev, } static int -nfp_net_device_activate(struct nfp_cpp *cpp, - struct nfp_multi_pf *multi_pf) +nfp_net_device_activate(struct nfp_pf_dev *pf_dev) { int ret; struct nfp_nsp *nsp; + struct nfp_multi_pf *multi_pf; + multi_pf = &pf_dev->multi_pf; if (multi_pf->enabled && multi_pf->function_id != 0) { - nsp = nfp_nsp_open(cpp); + nsp = nfp_nsp_open(pf_dev->cpp); if (nsp == NULL) { PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle"); return -EIO; @@ -1185,10 +1186,7 @@ nfp_net_device_activate(struct nfp_cpp *cpp, #define DEFAULT_FW_PATH "/lib/firmware/netronome" static int -nfp_fw_get_name(struct rte_pci_device *dev, - struct nfp_cpp *cpp, - struct nfp_eth_table *nfp_eth_table, - struct nfp_hwinfo *hwinfo, +nfp_fw_get_name(struct nfp_pf_dev *pf_dev, char *fw_name, size_t fw_size) { @@ -1199,11 +1197,11 @@ nfp_fw_get_name(struct rte_pci_device *dev, const char *nfp_fw_model; const uint8_t *cpp_serial; - cpp_serial_len = nfp_cpp_serial(cpp, &cpp_serial); + cpp_serial_len = nfp_cpp_serial(pf_dev->cpp, &cpp_serial); if (cpp_serial_len != NFP_SERIAL_LEN) return -ERANGE; - interface = nfp_cpp_interface(cpp); + interface = nfp_cpp_interface(pf_dev->cpp); /* Looking for firmware file in order of priority */ @@ -1220,15 +1218,15 @@ nfp_fw_get_name(struct rte_pci_device *dev, /* Then try the PCI name */ snprintf(fw_name, fw_size, "%s/pci-%s.nffw", DEFAULT_FW_PATH, - dev->name); + pf_dev->pci_dev->name); PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name); if (access(fw_name, F_OK) == 0) return 0; - nfp_fw_model = nfp_hwinfo_lookup(hwinfo, "nffw.partno"); + nfp_fw_model = nfp_hwinfo_lookup(pf_dev->hwinfo, "nffw.partno"); if (nfp_fw_model == NULL) { - nfp_fw_model = nfp_hwinfo_lookup(hwinfo, "assembly.partno"); + nfp_fw_model = nfp_hwinfo_lookup(pf_dev->hwinfo, "assembly.partno"); if (nfp_fw_model == NULL) { PMD_DRV_LOG(ERR, "firmware model NOT found"); return -EIO; @@ -1244,8 +1242,8 @@ nfp_fw_get_name(struct rte_pci_device *dev, /* Finally try the card type and media */ snprintf(card_desc, sizeof(card_desc), "nic_%s_%dx%d.nffw", - nfp_fw_model, nfp_eth_table->count, - nfp_eth_table->ports[0].speed / 1000); + nfp_fw_model, pf_dev->nfp_eth_table->count, + pf_dev->nfp_eth_table->ports[0].speed / 1000); snprintf(fw_name, fw_size, "%s/%s", DEFAULT_FW_PATH, card_desc); PMD_DRV_LOG(DEBUG, "Trying with fw file: %s", fw_name); if (access(fw_name, F_OK) == 0) @@ -1433,15 +1431,15 @@ nfp_fw_reload_from_flash(struct nfp_nsp *nsp) static int nfp_fw_reload_for_single_pf_from_disk(struct nfp_nsp *nsp, char *fw_name, - struct nfp_cpp *cpp, - bool force_reload_fw, + struct nfp_pf_dev *pf_dev, int reset) { int ret; bool fw_changed = true; - if (nfp_nsp_has_fw_loaded(nsp) && nfp_nsp_fw_loaded(nsp) && !force_reload_fw) { - ret = nfp_fw_check_change(cpp, fw_name, &fw_changed); + if (nfp_nsp_has_fw_loaded(nsp) && nfp_nsp_fw_loaded(nsp) && + !pf_dev->devargs.force_reload_fw) { + ret = nfp_fw_check_change(pf_dev->cpp, fw_name, &fw_changed); if (ret != 0) return ret; } @@ -1459,8 +1457,7 @@ nfp_fw_reload_for_single_pf_from_disk(struct nfp_nsp *nsp, static int nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, char *fw_name, - struct nfp_cpp *cpp, - bool force_reload_fw, + struct nfp_pf_dev *pf_dev, int reset, int policy) { @@ -1473,8 +1470,7 @@ nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, return ret; } } else if (fw_name[0] != 0) { - ret = nfp_fw_reload_for_single_pf_from_disk(nsp, fw_name, cpp, - force_reload_fw, reset); + ret = nfp_fw_reload_for_single_pf_from_disk(nsp, fw_name, pf_dev, reset); if (ret != 0) { PMD_DRV_LOG(ERR, "Load single PF firmware from disk failed."); return ret; @@ -1490,25 +1486,23 @@ nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, static int nfp_fw_reload_for_multi_pf_from_disk(struct nfp_nsp *nsp, char *fw_name, - struct nfp_cpp *cpp, const struct nfp_dev_info *dev_info, - struct nfp_multi_pf *multi_pf, - bool force_reload_fw, + struct nfp_pf_dev *pf_dev, int reset) { int err; bool fw_changed = true; bool skip_load_fw = false; - bool reload_fw = force_reload_fw; + bool reload_fw = pf_dev->devargs.force_reload_fw; if (nfp_nsp_has_fw_loaded(nsp) && nfp_nsp_fw_loaded(nsp) && !reload_fw) { - err = nfp_fw_check_change(cpp, fw_name, &fw_changed); + err = nfp_fw_check_change(pf_dev->cpp, fw_name, &fw_changed); if (err != 0) return err; } if (!fw_changed || reload_fw) - skip_load_fw = nfp_fw_skip_load(dev_info, multi_pf, &reload_fw); + skip_load_fw = nfp_fw_skip_load(dev_info, &pf_dev->multi_pf, &reload_fw); if (skip_load_fw && !reload_fw) return 0; @@ -1523,16 +1517,17 @@ nfp_fw_reload_for_multi_pf_from_disk(struct nfp_nsp *nsp, static int nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp, char *fw_name, - struct nfp_cpp *cpp, const struct nfp_dev_info *dev_info, - struct nfp_multi_pf *multi_pf, - bool force_reload_fw, + struct nfp_pf_dev *pf_dev, int reset, int policy) { int err; + struct nfp_multi_pf *multi_pf; - err = nfp_net_keepalive_init(cpp, multi_pf); + multi_pf = &pf_dev->multi_pf; + + err = nfp_net_keepalive_init(pf_dev->cpp, multi_pf); if (err != 0) { PMD_DRV_LOG(ERR, "NFP init beat failed"); return err; @@ -1551,8 +1546,8 @@ nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp, goto keepalive_stop; } } else if (fw_name[0] != 0) { - err = nfp_fw_reload_for_multi_pf_from_disk(nsp, fw_name, cpp, - dev_info, multi_pf, force_reload_fw, reset); + err = nfp_fw_reload_for_multi_pf_from_disk(nsp, fw_name, dev_info, + pf_dev, reset); if (err != 0) { PMD_DRV_LOG(ERR, "Load multi PF firmware from disk failed."); goto keepalive_stop; @@ -1627,13 +1622,8 @@ nfp_fw_policy_value_get(struct nfp_nsp *nsp, } static int -nfp_fw_setup(struct rte_pci_device *dev, - struct nfp_cpp *cpp, - struct nfp_eth_table *nfp_eth_table, - struct nfp_hwinfo *hwinfo, - const struct nfp_dev_info *dev_info, - struct nfp_multi_pf *multi_pf, - bool force_reload_fw) +nfp_fw_setup(struct nfp_pf_dev *pf_dev, + const struct nfp_dev_info *dev_info) { int err; int reset; @@ -1641,7 +1631,7 @@ nfp_fw_setup(struct rte_pci_device *dev, char fw_name[125]; struct nfp_nsp *nsp; - nsp = nfp_nsp_open(cpp); + nsp = nfp_nsp_open(pf_dev->cpp); if (nsp == NULL) { PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle"); return -EIO; @@ -1665,20 +1655,19 @@ nfp_fw_setup(struct rte_pci_device *dev, fw_name[0] = 0; if (policy != NFP_NSP_APP_FW_LOAD_FLASH) { - err = nfp_fw_get_name(dev, cpp, nfp_eth_table, hwinfo, fw_name, - sizeof(fw_name)); + err = nfp_fw_get_name(pf_dev, fw_name, sizeof(fw_name)); if (err != 0) { PMD_DRV_LOG(ERR, "Can't find suitable firmware."); goto close_nsp; } } - if (multi_pf->enabled) - err = nfp_fw_reload_for_multi_pf(nsp, fw_name, cpp, dev_info, - multi_pf, force_reload_fw, reset, policy); + if (pf_dev->multi_pf.enabled) + err = nfp_fw_reload_for_multi_pf(nsp, fw_name, dev_info, + pf_dev, reset, policy); else - err = nfp_fw_reload_for_single_pf(nsp, fw_name, cpp, - force_reload_fw, reset, policy); + err = nfp_fw_reload_for_single_pf(nsp, fw_name, pf_dev, + reset, policy); close_nsp: nfp_nsp_close(nsp); @@ -2063,7 +2052,7 @@ nfp_net_speed_cap_get(struct nfp_pf_dev *pf_dev) uint32_t id; uint32_t count; - count = nfp_net_get_port_num(pf_dev, pf_dev->nfp_eth_table); + count = pf_dev->total_phyports; for (i = 0; i < count; i++) { id = nfp_function_id_get(pf_dev, i); ret = nfp_net_speed_cap_get_one(pf_dev, id); @@ -2078,9 +2067,7 @@ nfp_net_speed_cap_get(struct nfp_pf_dev *pf_dev) /* Force the physical port down to clear the possible DMA error */ static int -nfp_net_force_port_down(struct nfp_pf_dev *pf_dev, - struct nfp_eth_table *nfp_eth_table, - struct nfp_cpp *cpp) +nfp_net_force_port_down(struct nfp_pf_dev *pf_dev) { int ret; uint32_t i; @@ -2088,11 +2075,11 @@ nfp_net_force_port_down(struct nfp_pf_dev *pf_dev, uint32_t index; uint32_t count; - count = nfp_net_get_port_num(pf_dev, nfp_eth_table); + count = pf_dev->total_phyports; for (i = 0; i < count; i++) { id = nfp_function_id_get(pf_dev, i); - index = nfp_eth_table->ports[id].index; - ret = nfp_eth_set_configured(cpp, index, 0); + index = pf_dev->nfp_eth_table->ports[id].index; + ret = nfp_eth_set_configured(pf_dev->cpp, index, 0); if (ret < 0) return ret; } @@ -2322,6 +2309,9 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto hw_priv_free; } + hw_priv->dev_info = dev_info; + hw_priv->pf_dev = pf_dev; + sync = nfp_sync_alloc(); if (sync == NULL) { PMD_INIT_LOG(ERR, "Failed to alloc sync zone."); @@ -2329,6 +2319,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto pf_cleanup; } + pf_dev->sync = sync; + /* * When device bound to UIO, the device could be used, by mistake, * by two DPDK apps, and the UIO driver does not avoid it. This @@ -2347,6 +2339,9 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto sync_free; } + pf_dev->cpp = cpp; + pf_dev->pci_dev = pci_dev; + hwinfo = nfp_hwinfo_read(cpp); if (hwinfo == NULL) { PMD_INIT_LOG(ERR, "Error reading hwinfo table"); @@ -2354,6 +2349,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto cpp_cleanup; } + pf_dev->hwinfo = hwinfo; + /* Read the number of physical ports from hardware */ nfp_eth_table = nfp_eth_read_ports(cpp); if (nfp_eth_table == NULL) { @@ -2369,10 +2366,12 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto eth_table_cleanup; } + 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); - ret = nfp_net_force_port_down(pf_dev, nfp_eth_table, cpp); + ret = nfp_net_force_port_down(pf_dev); if (ret != 0) { PMD_INIT_LOG(ERR, "Failed to force port down"); ret = -EIO; @@ -2386,15 +2385,15 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto eth_table_cleanup; } - ret = nfp_net_device_activate(cpp, &pf_dev->multi_pf); + ret = nfp_net_device_activate(pf_dev); if (ret != 0) { PMD_INIT_LOG(ERR, "Failed to activate the NFP device"); ret = -EIO; goto eth_table_cleanup; } - if (nfp_fw_setup(pci_dev, cpp, nfp_eth_table, hwinfo, - dev_info, &pf_dev->multi_pf, pf_dev->devargs.force_reload_fw) != 0) { + ret = nfp_fw_setup(pf_dev, dev_info); + if (ret != 0) { PMD_INIT_LOG(ERR, "Error when uploading firmware"); ret = -EIO; goto eth_table_cleanup; @@ -2408,6 +2407,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto fw_cleanup; } + pf_dev->sym_tbl = sym_tbl; + /* 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); @@ -2417,6 +2418,8 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto sym_tbl_cleanup; } + pf_dev->app_fw_id = app_fw_id; + /* Write sp_indiff to hw_info */ ret = nfp_net_hwinfo_set(function_id, sym_tbl, cpp, app_fw_id); if (ret != 0) { @@ -2425,17 +2428,6 @@ nfp_pf_init(struct rte_pci_device *pci_dev) goto sym_tbl_cleanup; } - /* Populate the newly created PF device */ - pf_dev->app_fw_id = app_fw_id; - pf_dev->cpp = cpp; - pf_dev->hwinfo = hwinfo; - pf_dev->sym_tbl = sym_tbl; - pf_dev->pci_dev = pci_dev; - pf_dev->nfp_eth_table = nfp_eth_table; - pf_dev->sync = sync; - pf_dev->total_phyports = nfp_net_get_port_num(pf_dev, nfp_eth_table); - pf_dev->speed_updated = false; - ret = nfp_net_speed_cap_get(pf_dev); if (ret != 0) { PMD_INIT_LOG(ERR, "Failed to get speed capability."); @@ -2484,8 +2476,6 @@ nfp_pf_init(struct rte_pci_device *pci_dev) } hw_priv->is_pf = true; - hw_priv->pf_dev = pf_dev; - hw_priv->dev_info = dev_info; /* * PF initialization has been done at this point. Call app specific @@ -2678,6 +2668,9 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) goto hw_priv_free; } + hw_priv->pf_dev = pf_dev; + hw_priv->dev_info = dev_info; + sync = nfp_sync_alloc(); if (sync == NULL) { PMD_INIT_LOG(ERR, "Failed to alloc sync zone."); @@ -2685,6 +2678,8 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) goto pf_cleanup; } + pf_dev->sync = sync; + /* * When device bound to UIO, the device could be used, by mistake, * by two DPDK apps, and the UIO driver does not avoid it. This @@ -2703,6 +2698,9 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) goto sync_free; } + pf_dev->cpp = cpp; + pf_dev->pci_dev = pci_dev; + /* * We don't have access to the PF created in the primary process * here so we have to read the number of ports from firmware. @@ -2714,6 +2712,8 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) goto cpp_cleanup; } + pf_dev->sym_tbl = sym_tbl; + /* 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); @@ -2723,16 +2723,9 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) goto sym_tbl_cleanup; } - /* Populate the newly created PF device */ pf_dev->app_fw_id = app_fw_id; - pf_dev->cpp = cpp; - pf_dev->sym_tbl = sym_tbl; - pf_dev->pci_dev = pci_dev; - pf_dev->sync = sync; hw_priv->is_pf = true; - hw_priv->pf_dev = pf_dev; - hw_priv->dev_info = dev_info; /* Call app specific init code now */ ret = nfp_fw_app_secondary_init(hw_priv); diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index c9a95ed632..99f6b61947 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -2724,13 +2724,12 @@ nfp_net_fec_set(struct rte_eth_dev *dev, } uint32_t -nfp_net_get_port_num(struct nfp_pf_dev *pf_dev, - struct nfp_eth_table *nfp_eth_table) +nfp_net_get_port_num(struct nfp_pf_dev *pf_dev) { if (pf_dev->multi_pf.enabled) return 1; else - return nfp_eth_table->count; + return pf_dev->nfp_eth_table->count; } uint8_t diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 0b5bba2a3e..fb244383b7 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -374,8 +374,7 @@ 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, - struct nfp_eth_table *nfp_eth_table); +uint32_t nfp_net_get_port_num(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