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 6138A458ED; Tue, 3 Sep 2024 07:53:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA21D40E44; Tue, 3 Sep 2024 07:53:13 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2120.outbound.protection.outlook.com [40.107.95.120]) by mails.dpdk.org (Postfix) with ESMTP id 3662E40295 for ; Tue, 3 Sep 2024 07:53:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BOmS6DlXmc/cUqOapr+sGJBhVkocR/qluY54MkvGLMc30RAk6x03VuxN6BgBpyvE4AE+Jr0e+ehfVaa71YUznsCuFXDA7KixbCT28kXdAmWjcMbqbLrh5/4jGASZY9JwGKWNwat09vci9UISio/lkB4ckkp4Af33/S7z2Moi7Pk/LlBbiQnToYiVpHl6okX+uKDXEBqdpTWPBdsLnAHsEceYsBdBpHJ6M3X75J50HMrpzPhfZu9oICBMQR06FjYxvqcQCAVBuoUBQaIAT+ad0AL4/laB9Pt2fpumvfrLFWR5XYMPVyNR525KxIRWG4O6YdRFaSSafItHzMJQ2dfgVQ== 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=TRNCVT+13eJWSInhvE5rv9uoEcJsFfKHBvi0HTjDJmg=; b=Hi42LcXY1BeaQgPncBbcSqrLda70AYmFXpZTEg0Bm4E2AgI3RttySp5bWmw7ytkvl6ClkFJ5lvY6Kj2MhEjbGcSpUHIf5zUDLrnjEMHPvjjrzMZh9LLSSdpgujL+Z7pxtg1ACs178xHzm/IVWzp4V3ya6vjp/tdxzdBCS858bidmVIU2/0xp6Y0G9KPettwUXjOwJ0JgmgnMQVfgr1hj97H9oj8azTmTXaEac39swFjHoqDPIuRYVw0mxYqJsIl9VAaXz607ZY++GJ1+t5mmI0iR90NpsZzdKtsJWW+yO9++6ypzCiV7mTOnWdnDJ7jWygqEMUhaMKccXcZE92PDyA== 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=TRNCVT+13eJWSInhvE5rv9uoEcJsFfKHBvi0HTjDJmg=; b=u2XJtvduw/QwK5cw9KX0HLVjnH9En8MFwARMvage8fFt52Z5ps2xAnR4Jla++xN8NumuCp2tbNVCK0uFYB2k/Hw/LpKnQzR1YZgJZVcMWRYsnsfBNWHalA5jNS/L2tA0ItQUpYupwcJJxMEvsxJ35nd1TeZW7b5Bxd/q4Vrzpic= 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 SA1PR13MB6126.namprd13.prod.outlook.com (2603:10b6:806:335::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Tue, 3 Sep 2024 05:53:05 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7918.020; Tue, 3 Sep 2024 05:53:05 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 3/3] net/nfp: support load firmware from flash Date: Tue, 3 Sep 2024 13:52:39 +0800 Message-Id: <20240903055239.2642656-4-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240903055239.2642656-1-chaoyong.he@corigine.com> References: <20240903055239.2642656-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0334.namprd03.prod.outlook.com (2603:10b6:a03:39c::9) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB6126:EE_ X-MS-Office365-Filtering-Correlation-Id: 1466c776-6f62-4802-7a50-08dccbdcadc0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/zTDqVa1AcUxLPmQuEx4uK+QznD4YbalRvg4CzIDxzcymhb6dSqLmLWRerW3?= =?us-ascii?Q?QVrX06T29BLnac0mkzQWbYlNxuaGYEPF+S4BKFSRrVVFxc6r8VI5T2nMUhzM?= =?us-ascii?Q?KUaiwfUqFljyVO/IXxjD0Vq+u10XLiXKmQcloUZU7dsHaEgVGYNuj/1fvt6d?= =?us-ascii?Q?AZB76zsc97Ikx1M8PxshR8kuF36Um0NwiodeLOiVrNy47h5YN5/NsvfBEUXo?= =?us-ascii?Q?FH0iG1hEOO3y6VFf8lJFtUAqf0DD0FA2ZccLb+DvWu3wu+4o9xD+hrdZUo0H?= =?us-ascii?Q?X+ynIg1XwuRbEH7Y6dyHl3m+mlkt3ij/YsYOT3cB820B5+IOg9j/bE0Y/Dhg?= =?us-ascii?Q?nA7VytB0tsIyATJp8RNTNcw+GxHHj+gP/6Iw8FWh5XnLQQAxLRVYLSKwppFP?= =?us-ascii?Q?LWoKqd1Em9+8RHi3guElUGPoD5mYcNdPyyqhC8PwAFYyPujUdXN1KjTdR1Tj?= =?us-ascii?Q?TuxyGooj6lBAAFxCyDfZrinHZr1j7ZhZbE/o5RnzlAFKntt8VRRAX4ZdXvqv?= =?us-ascii?Q?pXFuXmugAkVZmVLxBNtKyBFlqKithsPEXIAA3NaQ6jQ2EsCSCow96bnBdMii?= =?us-ascii?Q?5OwGyNMAYVTudxF138jKKOqtiHS4n2YW/B16961axWoRk9yuUwQoBtFzFZTa?= =?us-ascii?Q?+t2h4aufegOP7oE75nj1veL+kfKs/JUVup42eB3fhDxLdYZU4QgETtjr21H4?= =?us-ascii?Q?TsAai50U4FJf+RmveB9gXcBaRAFS1XX1w+ojoc6AgEIUyj62CDMNp0lCs3M4?= =?us-ascii?Q?dv3ZPtJGthFVX36QlZE5e9zIpqd2lioAivYvYpoa/xtNfpFNAyCU80bQki6y?= =?us-ascii?Q?IJtVNWiBM7lKN62yfoezL13kaiN0/Jtno0nB814kb2oEgz8V6N4xiwy2is/w?= =?us-ascii?Q?QEHvIO+sudpOe+jo+1ARs+rLztKvQAVOqRSTDjchk+LQSrY92trrV5IBep6I?= =?us-ascii?Q?cOwkHJYPcUc+GYbZSZ+i74jJPeuPSstJRfsWE3s3FO5egidk3YTRikNR6RsJ?= =?us-ascii?Q?y5htErAbxa58mpnheP0Irx1MHlWOIEBOcAK+KV4/GLT58DPneZpGRvRV2Ykn?= =?us-ascii?Q?f1LcXTVqyWKaTz/2nmBlMm/5/8QD/F2+fRuQyat/QVcyXFPg3OUcacdrC+r2?= =?us-ascii?Q?WIw++7nv0wBH0M7KCh7X3tTz35v30/ZJVrXc3oUID+k5XbgqWe3KzbqI8vxo?= =?us-ascii?Q?hO0imNrrs46n8sObRrhbIszp3q+zz78HjwG1MmV3Qj7FBjMiUvvfm0ndZH85?= =?us-ascii?Q?odqQSqDD5crymYS+hCnT0p1gIw8KE3XUcC62vnrW2Kf8VU1yKymn0/bZ80ex?= =?us-ascii?Q?d/oRtt9HNVs1xU8EfVmkHYGsbbNPepBl/8j8rwmY3hOWrzBEjKWxlWfFVmm+?= =?us-ascii?Q?sy6etZbzjHMlDp5shIyiil4cM1I3kqsV9b2wgDsIb+EZuSh1ew=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)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?o70yUCFGrBXgjAE8Bg4jzxexv6HseTYqzX/yh/H6ojWfOTd3MuAg9ee8Tx67?= =?us-ascii?Q?7Z6eFWUfOSDgVvd+zJaattfwfcr0jLfIewwZGBKscSn21Ox9z8ZgcT4U5CSi?= =?us-ascii?Q?hZzYEf5OAq8ywptmsyUapuEC5UhxAnOCEIqJZtG1ZMkJ7jC5/3MbVbimObTF?= =?us-ascii?Q?xxxaKGvnWXU6cjLNtt07fvIlu6ycawaSUATOnMr46KHpgEPwFN8xZc8edqwE?= =?us-ascii?Q?thCoXh0NdoNBvtOzU1aesvTwTLw9f1Q5FiTnk2b6C1c+ZSeKx/k7p29R3VeL?= =?us-ascii?Q?gK5BMRAq6cZjB8LEbwu8aGuq8Zy6jNXnDBVT7iB4gIen37AFhlQX93j1k4Nm?= =?us-ascii?Q?KtTlJbhEDSb4EQ3+bH/WrV36SVwzOvm3DUgj0s5lhcPi1pelplXHt9GHrFAF?= =?us-ascii?Q?6EkP6wtG+QTuScW9t79nWboq5YJQZhpkQ4VGNXXIGRVn0fhaY23Gnk+qw7a7?= =?us-ascii?Q?aUcuh0efJi9KrG/nHlE04RK62AfxzqRDd596yiMxgCwQsQI2C8zcwZ1RpbCF?= =?us-ascii?Q?oi1Q82Q2FKYT1jMqFlIkXms99vXrzCyLXKiyuZb0dOv3FmgPwM+n2mZ37VAE?= =?us-ascii?Q?93BQtfJj8MykKY0Y1Ekq0MebX5cilLZOTSBOVnoebsMXrhXSRV57EpO7QKoj?= =?us-ascii?Q?IUgL8hFYsWRZE/b9P08e9A5k7h6ZXoINl7wtxXJHyeV2yTybvGomJ/C/XH7Z?= =?us-ascii?Q?bWvy8iw3ghmZRVWO4K6eKcOjbBcQp3psMjCpoIAvLyvQ8KFdxQXIdcAGnHEK?= =?us-ascii?Q?xJRGcGSawdcwrpBy94373RW8S7cCuGKb3VP8o7ev8pcROqnXwx0EqAfrSdeE?= =?us-ascii?Q?x65rkIAT0dE9858+Nv+OkqGFc357qnEVdY4dY+1iMWc0BTSmfKoQ89o/dOIX?= =?us-ascii?Q?nrrqrAbAijLSFVPsZWH7eGKq8NhpV87JX6CCxu1xyI6dzxrFLV4rvDLXKrLr?= =?us-ascii?Q?WRmy8izz0SZNVnKULDF80ZCBb+FNDUwc5vITkyguVgW6DJIINm2RxnAzfyU4?= =?us-ascii?Q?ER4Mm7/ltmhQaoULT9gaC5S06TRHWp3CTiY/sX+JJQoJFesJDC8vaEgE88nI?= =?us-ascii?Q?GhClFXHqvTqkjc9oGK2jsyONlm48qdd3gyIc5JyteDWEEE82YEvJh2VeydfV?= =?us-ascii?Q?YYS+dry5OFXfnM2Cb1z9lHqQEAHpYYu/Du3BWP/52wbhePoQvMB9jPlAjVLY?= =?us-ascii?Q?RCaFRETkSt+Y8GxsitQIeCQiiZWKWnhOFfB37mNnAns9aNFS57K2o+Ko3oZs?= =?us-ascii?Q?1ED/hwArbS2HPJnHwZ9gU+h4pKrWjYcbsT8gTsh7ppKO+L/aVy1OA7tpo3dV?= =?us-ascii?Q?WBa72EWNKJrrA3+NHoW4sdrVIDCYpcFqLkmIpUOuDfvvpsIezsJ3RZIKEOE1?= =?us-ascii?Q?3CFKTdDe1xXbdw/azkdp1MwHUcFlvoiPmHtMNLxak4yC5qI5yxs3Ifmjsmdr?= =?us-ascii?Q?55HmW7eSIyrRUFXzhrq9p7AiqF5QIAOKS/TOjVmQdeCn6vd8i6ZSz5bPY/QM?= =?us-ascii?Q?rzeixrEx8ImczhPG47/H7QUrUj7m8gjSpPLAdZiDCexfjKejqTSLR7bOG2U4?= =?us-ascii?Q?XQ8ptutsuicJgNZgX32fmT9HlrLV7i3Uqd2ga3lMCsYz3u0qLrRi7i4EpKxv?= =?us-ascii?Q?lQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1466c776-6f62-4802-7a50-08dccbdcadc0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 05:53:05.0986 (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: qhKcUzlVQC97UzS04Y7YcuRsF5ABzczaYl2prLiFzeNZ98W211J8unl4WNpO88IUFhYnvbIPuFpcMvR6P7Z8ycvOF/eylQDc7R5wG7KBHBQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB6126 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 Add the logic to support load firmware from flash, also do some refactor to the related logic at the same time. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_ethdev.c | 233 ++++++++++++++++++++++++++++++----- 1 file changed, 202 insertions(+), 31 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index db12914afe..b35e40a7d0 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -1323,16 +1323,30 @@ nfp_fw_check_change(struct nfp_cpp *cpp, static int nfp_fw_reload(struct nfp_nsp *nsp, - char *fw_name) + char *fw_name, + int reset) { int err; + bool reset_flag; + + reset_flag = (reset == NFP_NSP_DRV_RESET_ALWAYS) || + (reset == NFP_NSP_DRV_RESET_DISK); + + if (reset_flag) { + err = nfp_nsp_device_soft_reset(nsp); + if (err != 0) { + PMD_DRV_LOG(ERR, "NFP firmware soft reset failed"); + return err; + } + } - nfp_nsp_device_soft_reset(nsp); err = nfp_fw_upload(nsp, fw_name); - if (err != 0) + if (err != 0) { PMD_DRV_LOG(ERR, "NFP firmware load failed"); + return err; + } - return err; + return 0; } static bool @@ -1398,11 +1412,27 @@ nfp_fw_skip_load(const struct nfp_dev_info *dev_info, return false; } + static int -nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, +nfp_fw_reload_from_flash(struct nfp_nsp *nsp) +{ + int ret; + + ret = nfp_nsp_load_stored_fw(nsp); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Load firmware from flash failed."); + return -EACCES; + } + + return 0; +} + +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) + bool force_reload_fw, + int reset) { int ret; bool fw_changed = true; @@ -1416,7 +1446,7 @@ nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, if (!fw_changed) return 0; - ret = nfp_fw_reload(nsp, fw_name); + ret = nfp_fw_reload(nsp, fw_name, reset); if (ret != 0) return ret; @@ -1424,18 +1454,81 @@ nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, } static int -nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp, +nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, + char *fw_name, + struct nfp_cpp *cpp, + bool force_reload_fw, + int reset, + int policy) +{ + int ret; + + if (policy == NFP_NSP_APP_FW_LOAD_FLASH && nfp_nsp_has_stored_fw_load(nsp)) { + ret = nfp_fw_reload_from_flash(nsp); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Load single PF firmware from flash failed."); + 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); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Load single PF firmware from disk failed."); + return ret; + } + } else { + PMD_DRV_LOG(ERR, "Not load firmware, please update flash or recofigure card."); + return -ENODATA; + } + + return 0; +} + +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) + bool force_reload_fw, + int reset) { int err; bool fw_changed = true; bool skip_load_fw = false; bool reload_fw = 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); + if (err != 0) + return err; + } + + if (!fw_changed || reload_fw) + skip_load_fw = nfp_fw_skip_load(dev_info, multi_pf, &reload_fw); + + if (skip_load_fw && !reload_fw) + return 0; + + err = nfp_fw_reload(nsp, fw_name, reset); + if (err != 0) + return err; + + return 0; +} + +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, + int reset, + int policy) +{ + int err; + err = nfp_net_keepalive_init(cpp, multi_pf); if (err != 0) { PMD_DRV_LOG(ERR, "NFP init beat failed"); @@ -1448,21 +1541,24 @@ nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp, goto keepalive_uninit; } - if (nfp_nsp_has_fw_loaded(nsp) && nfp_nsp_fw_loaded(nsp) && !reload_fw) { - err = nfp_fw_check_change(cpp, fw_name, &fw_changed); - if (err != 0) + if (policy == NFP_NSP_APP_FW_LOAD_FLASH && nfp_nsp_has_stored_fw_load(nsp)) { + err = nfp_fw_reload_from_flash(nsp); + if (err != 0) { + PMD_DRV_LOG(ERR, "Load multi PF firmware from flash failed."); goto keepalive_stop; - } - - if (!fw_changed || reload_fw) - skip_load_fw = nfp_fw_skip_load(dev_info, multi_pf, &reload_fw); - - if (skip_load_fw && !reload_fw) - return 0; - - err = nfp_fw_reload(nsp, fw_name); - if (err != 0) + } + } 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); + if (err != 0) { + PMD_DRV_LOG(ERR, "Load multi PF firmware from disk failed."); + goto keepalive_stop; + } + } else { + PMD_DRV_LOG(ERR, "Not load firmware, please update flash or recofigure card."); + err = -ENODATA; goto keepalive_stop; + } nfp_net_keepalive_clear_others(dev_info, multi_pf); @@ -1476,6 +1572,57 @@ nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp, return err; } +static int +nfp_strtol(const char *buf, + int base, + long *value) +{ + long val; + char *tmp; + + if (value == NULL) + return -EINVAL; + + val = strtol(buf, &tmp, base); + if (tmp == NULL || *tmp != 0) + return -EINVAL; + + *value = val; + + return 0; +} + +static int +nfp_fw_policy_value_get(struct nfp_nsp *nsp, + const char *key, + const char *default_val, + int max_val, + int *value) +{ + int ret; + int64_t val; + char buf[64]; + + snprintf(buf, sizeof(buf), "%s", key); + ret = nfp_nsp_hwinfo_lookup_optional(nsp, buf, sizeof(buf), default_val); + if (ret != 0) + return ret; + + ret = nfp_strtol(buf, 0, &val); + if (ret != 0 || val < 0 || val > max_val) { + PMD_DRV_LOG(WARNING, "Invalid value '%s' from '%s', ignoring", + buf, key); + /* Fall back to the default value */ + ret = nfp_strtol(default_val, 0, &val); + if (ret != 0) + return ret; + } + + *value = val; + + return 0; +} + static int nfp_fw_setup(struct rte_pci_device *dev, struct nfp_cpp *cpp, @@ -1486,27 +1633,51 @@ nfp_fw_setup(struct rte_pci_device *dev, bool force_reload_fw) { int err; + int reset; + int policy; char fw_name[125]; struct nfp_nsp *nsp; - err = nfp_fw_get_name(dev, cpp, nfp_eth_table, hwinfo, fw_name, sizeof(fw_name)); - if (err != 0) { - PMD_DRV_LOG(ERR, "Can't find suitable firmware."); - return err; - } - nsp = nfp_nsp_open(cpp); if (nsp == NULL) { PMD_DRV_LOG(ERR, "NFP error when obtaining NSP handle"); return -EIO; } + err = nfp_fw_policy_value_get(nsp, "abi_drv_reset", + NFP_NSP_DRV_RESET_DEFAULT, NFP_NSP_DRV_RESET_NEVER, + &reset); + if (err != 0) { + PMD_DRV_LOG(ERR, "Get 'abi_drv_reset' from HWinfo failed."); + goto close_nsp; + } + + err = nfp_fw_policy_value_get(nsp, "app_fw_from_flash", + NFP_NSP_APP_FW_LOAD_DEFAULT, NFP_NSP_APP_FW_LOAD_PREF, + &policy); + if (err != 0) { + PMD_DRV_LOG(ERR, "Get 'app_fw_from_flash' from HWinfo failed."); + goto close_nsp; + } + + 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)); + 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); + err = nfp_fw_reload_for_multi_pf(nsp, fw_name, cpp, dev_info, + multi_pf, force_reload_fw, reset, policy); else - err = nfp_fw_reload_for_single_pf(nsp, fw_name, cpp, force_reload_fw); + err = nfp_fw_reload_for_single_pf(nsp, fw_name, cpp, + force_reload_fw, reset, policy); +close_nsp: nfp_nsp_close(nsp); return err; } -- 2.39.1