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 C160945B00; Thu, 10 Oct 2024 11:18:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE0DC4065C; Thu, 10 Oct 2024 11:17:46 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2137.outbound.protection.outlook.com [40.107.223.137]) by mails.dpdk.org (Postfix) with ESMTP id 6FC4740647 for ; Thu, 10 Oct 2024 11:17:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JYpHokMJ2lRJiD6fsjaJr0aOirUL8xOFudVyfxaP4516KSy2EQYNT01H7N7gPe5C8DRv7g4ZSe79kMINECB9cefTIHb1C2+NmHQEDEHVCcfKvFth2JM/fyFb2bs7WHynkTiLmhZcjUOPALCO4x7ZXESzhQKgzIrtWcNcMYLi50ToNUzNj/RskCYSzSaRNEJoJxi2UEUT4iJ2gmjwuLEprbgj0RNBUqAo4Y8A2riGf79B7ON5xv4OWVNYnhu220Z/fHOX7iUvoMrKr+bDu9IWLvLVkuXC0EDRe9YJSNXjxj9MZpHrnS6UEwFJmo9Ufg3VEJgL+GKEhj5rJMLpyrFexw== 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=RC+ONDSaNqDT1nDI0SMp99aJ0Ij7zKKuUAUWH3SRCtI=; b=LAobtEI9iLa9fuVE0bGoTIbM6BlvNnvzUzWqVBQwsKBKYMXBHoIEAY4nUHlM99DNjbvDDgEvP719X9RTYypzNpS8elMjU+XtLq090/2NGyzJo9e/Ujl7gURVklz6crDqONxFy+5FIuS1XGvc5qg0HEVJ6wIuerdytZeeIsvBON1lfTeO6vk78Oq8Dwg0hvJyx+uuLIapf34n6dgKqlBeV9wY+4uAjWmHSjYwihnSNDtGJHJQR1z8fKLsPZoBcwlNjPM/Z0zb9G7JP5GaY4I0YpsEOMWMf4djv32xx/LgVBcheuqsN5RlShsAl4KsFDPNbyELwqIXflTm2i+r9papTQ== 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=RC+ONDSaNqDT1nDI0SMp99aJ0Ij7zKKuUAUWH3SRCtI=; b=plAp2C2zz/v6UPuGFfU3Pv16l8pwXtcjPPJrkC170cSvOKotghfKTiInEudwN3UceEQ++xF/jJUmXG0PgGG3s51+yWif6H7QNaGc3qfK9orNapaLUpAjZT7gcUTPfNjbVdPyc3ypWTVzZ5EV/zBhiOon6HSplq8GBxtVrLln/Bc= 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 MW3PR13MB3980.namprd13.prod.outlook.com (2603:10b6:303:5c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 09:17: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.8026.020; Thu, 10 Oct 2024 09:17:42 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 03/10] net/nfp: simplify some function parameters Date: Thu, 10 Oct 2024 17:17:09 +0800 Message-Id: <20241010091716.3631747-4-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20241010091716.3631747-1-chaoyong.he@corigine.com> References: <20241010091716.3631747-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TP0P295CA0060.TWNP295.PROD.OUTLOOK.COM (2603:1096:910:3::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW3PR13MB3980:EE_ X-MS-Office365-Filtering-Correlation-Id: 09c181f0-511f-44de-74a3-08dce90c6505 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?M56zId2vD4blXATw0KfuzdfTfvZznLp+M/2oO+TrswQ0n8HpQTIQqS3ZtiCi?= =?us-ascii?Q?QkIXdRDyjJ5+29W5M8okmDkk0V4pSBX1zNB0ipbqUmPRXRD6qm5cUOhK/yWs?= =?us-ascii?Q?fOgi/5lImMFik85tdqTlUQaaw1Sogm83cqdXmNb0dZNAwqHBH3ne/811X3w4?= =?us-ascii?Q?Fw/gQKoD5x5hV2sW3DgAOx9BSOrRWRhgIl7m+9RV3n3pA7Nd49S2e4gnhUPY?= =?us-ascii?Q?lDQXmkKsbHw9n1i4GzdBxDnwt7WXPceDqVDnnYxE6YQyKmak/K6mrrBCHSTe?= =?us-ascii?Q?lbc1JaglfhK9FfCHBTi1nrJ2252bh0lI49NGmEbolWjgCHInWVIQW4LFUVOc?= =?us-ascii?Q?VoEYLgJ9+Xfnja905P0g6C73n35gy/OINAC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qqDsuJ8Gqk4y5NO5sv3vpYnJBvcNtg+YmD3D+46kxG84DuDIOc?= =?us-ascii?Q?brykjT01bi9ImKf6lbcilm425DJT1c93MoJy9eh3+VLa7w=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)(366016)(376014)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zUWxGaKy3UT+QxgiHngkHH5N2yf1x5783DKN1BGsI8j+UwoTIK/NzJPHHY98?= =?us-ascii?Q?6fXNHUdyEPt6xq38KIPEhWB91Fbxov0FrIOje1mk7cN/bbjXGMqgopmy+ZoF?= =?us-ascii?Q?3hsDu8I408y0UXuq5oOxNoWgQQMaiqPTOj6PM6EuIughegWAsHk4lXXY8ehJ?= =?us-ascii?Q?uIRfO/ff4L8DpxL+lCPY9/eTOO36ZJq8rn45WekogZIx7hWuzXG6fCHFtYq5?= =?us-ascii?Q?CO9CDLZKJd5NiBDPqXP0Zx4FHOzRi8jhxNC6W70aQYwbASKx3a9X8Iee/8Z4?= =?us-ascii?Q?RajlNwELfciQMuFFDJUlYlvIU91115EkS7AreSp6kfQhTQVLUsjFhOC058JY?= =?us-ascii?Q?nn8P3GvFvdoyZA8+Lpz0NVUOgZW9pizLPvJc5vQQSQYS+I+xjHeYxXXWz185?= =?us-ascii?Q?8QFL16dy056K2zqtcjrnCQG8XAhwXE1ef+uFqw94bPLVC1XZ4L9tgGG4VoFg?= =?us-ascii?Q?iLZ/rkSINJwEcxzT1gdbRuXOU19ZUoe27XmSWZvbAJuT+CSeBeQLvJZ0Jwvr?= =?us-ascii?Q?1niTIYNg8RfYkze7sg9P3ZsJ8TJdpQGmTdyBMrwKO2wdVJnsD/7NZjyA6eHw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GQ2ltbjaMy4EjqZDPxsXuE2?= =?us-ascii?Q?eqfmvWkstuopjtCrLL+h7AcdOuTnEc7FAkRj9EW+0KvUAMSsPs84A3udGWT6?= =?us-ascii?Q?8jACBggzc8o0pH129qeuNhs9S5ujpKCTWqYFY1JDQq1atV+xw6GMMYbqCsz7?= =?us-ascii?Q?gw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09c181f0-511f-44de-74a3-08dce90c6505 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:17:42.6848 (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: f0t35b3Fo8sfV+AtNAORydtPmf7ZD7o7EoIRpbUuAgEWMaNLQerYRXbZUYzKvtsxZdLMBzDSiJPVnzKyvtv9Rn9ItycE2krp7palIZ8YwRI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB3980 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 --- 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