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 A9E2943C08; Tue, 27 Feb 2024 12:16:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5B9340E2D; Tue, 27 Feb 2024 12:16:20 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2126.outbound.protection.outlook.com [40.107.93.126]) by mails.dpdk.org (Postfix) with ESMTP id 9B74F406B4 for ; Tue, 27 Feb 2024 12:16:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=loq+FMEvDuf9LCK4B7tgsV6AvuPqioLya0FSrtFOhlYYhwre1QKgLrHpcoDSL/0yx9J330rXHrcIaDt+tAMyvhOssnozm3JlTDbKCERDvDVlWYQruX6Jt2U9qD3ymPVERDy//kSaCi/Wnv8haSy8ZBUiEmcmZYt4IqDjx0XZibH5pEtWuW3SFEjiPT3q6ue90nSTX9s9UvyxiLjEGk6aoqLoWGPPZvVA/t7loXoVIgtquMvu9KwtU3Ks5YIvVQYNEFE0WpwDVUTwM1heWW4JNCoQ5oNnWo3LcVszfxYvQP1JezX0a5ArAX/Nmv3YmOOH7SVuDhtzyK8RWSVX1UHi4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=i5qgcCWM0A0EoUdV6WJ1lWQ2i1l6RrG5jC8cGVUzeWQ=; b=F6gHdZO+IByphntgHUFhvdXEMGxFSCQVPVJmgNGMw5c8kWUoDUwbRhIDECSHAN7RHijzACrndaS73liTTPvVPfihx5M7zwQaUKiu1emWXXPflVZ3RU/BP/i9nDqnBZjtV6SdoWF1owHqviOGQiFDhn8SpeHD4eYnYVXlWRlT5L2fpZRDbRlQdKUoyckGfOyOLxBg2+gZTHXlP7fDokZdG610hB8+JPNKkm8BjS5GZpB2jTxeXWsgEaHMLgcJYOv3CbF/LbJGazO8iw6ys6ol6EFdZUMxnxFNKSZHPDCCWz4DZ9+8IRs04POpC+miEBfvV+somoBzpJBGvqps7wrWDg== 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=i5qgcCWM0A0EoUdV6WJ1lWQ2i1l6RrG5jC8cGVUzeWQ=; b=BljpOVFWrRvRk7UhO3YZBLh5B+qnxfzIwJaRlx7RMQPOl6R854P977ENEEU6xyuO0jbRKAOBKg0o0xlglDqWqE/sd6tAiGEfIVYJEnQItIE6zEvcewVgVG0PbVVfV+nX5b+XFHVnMnMIbZxPxYD0V8cAPtfEvSMkExVi7vn2r9o= 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 PH7PR13MB5843.namprd13.prod.outlook.com (2603:10b6:510:151::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.39; Tue, 27 Feb 2024 11:16:16 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa%7]) with mapi id 15.20.7316.035; Tue, 27 Feb 2024 11:16:16 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , Chaoyong He , Long Wu Subject: [PATCH 2/3] net/nfp: reload the firmware only when firmware changed Date: Tue, 27 Feb 2024 19:15:50 +0800 Message-Id: <20240227111551.3773862-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240227111551.3773862-1-chaoyong.he@corigine.com> References: <20240227111551.3773862-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR20CA0002.namprd20.prod.outlook.com (2603:10b6:a03:1f4::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_|PH7PR13MB5843:EE_ X-MS-Office365-Filtering-Correlation-Id: 95b055c3-e371-4beb-bc46-08dc37858364 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: siVUMZc70Qvf8rYJd33VeRe/f4lmiTzYL2pxMI49sDLHg4bcz3Iww8IuuYQrPG3AG/Zlw5G/4Bxm0RptmO7Gg2dBc97D87AG3s/5OUmcWGt++xGyeH2Djeg6qJ5BM0uRhmvonFIRrNjd6bQH2atNvs2tvBNGWfFOFFVHjxpwBzp/nkJlJ4fGFygqugcntmlkNElwUOmYrDgtSghr/3zNlEJZtsQ6YtJGyhZ0eO/PgGWRlb3QXyFo/x4CaQ0GVSHmZy7rZG+me9og/h5RevB5fluiAib19XYVkPoKFvGAF7bBBubzZW1ewKYTn5wbNuicDhXkQ+jdzbml9B5iYCP5nbPyKSBLUWdIUpajrPe12ThvSOfz93K7d5dmCWguIbUNc7JCygkGyYnh9BN6lMeIrvhv/UF/G291Qy+kbohKcdG3qh/oPZLjKuIzCUmsu8VZ10AgyrBS4l7zk+XUo9J1/J0ovs8eQaNgSyXR0z7TtMbvhlybIFuiQH6s3E96lMyQmBhSWOctlHg+DiUM2KhuN8I4Vaj6pewnBqNlmfmOs5xWj+pa3U4U9NB04IHP9RfQeIB9vupRtGdlyO2rfqlUwiHoGm7uOjIWObr2RgXKY/CjzlCnfFwj6TXAcQWd1KJtCNzU+lbbF67UUU8RcXj01T+XdHqdLSxKFqE9dcIptMJmpfechf9yeFv2ZTU+OaIrEaeKtBhcdRJvpJ43tH1L4qJUmgUhTjAxfbHaV6UwU4k= 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:(13230031)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jUMkCSpMuoUNjrypZI/J5vW8OiZnkIQ4Bq7QN61keF3wEyCQMQVOI4VAKqz3?= =?us-ascii?Q?UUqLeXSDDVlq2ex/vlwjdBtCWC8WtSfe7U94HAQ5BPWVfJjS68uaQ/1egGR+?= =?us-ascii?Q?xVsaBpkMQYTodvsG/paYXKOI4FCq1sFrJpsqn0nP7d5qx8ILe8vjpJOeN7Q1?= =?us-ascii?Q?KPQ0cT5grjWOYyyr5UXqKdxR0c1JOotUfFFQvde+QOZkhQq9dcBphISnAisb?= =?us-ascii?Q?R1TaBGcroEzcZ3MRMLGVJoXVQdrhzv/8QEoSQetSUlvRYNW6i6e7HK/JMCBS?= =?us-ascii?Q?VDHDeOwpcg2ZU6IDss/Y/0f7fmGrWgyL24JhytG+JlTGrh+1euuV78dmcsA0?= =?us-ascii?Q?5lt0V6F6O+xCXbjtmmB0BUq7gpPLJuufhw+uL7mxPCWqBblGRHgcxW8f71ux?= =?us-ascii?Q?JPqjjaqpyLh8pciagKEAEHVV0H8MTKjxcawzjZ9LyLLqtbS4gO5f8SPjer36?= =?us-ascii?Q?3Q/Z/NFM4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znuc3cjM1u5J2gEN7PdC9zm0Y?= =?us-ascii?Q?U7dSkxz3b5UxP0/erl7NStd4OTqU+fBLFMR0aDJIyUZ/nIrRGORgR8GiCyrj?= =?us-ascii?Q?kmUsYovJvFRT1dhUEF73dJuWASoY+s4qaEyBL3f9mZKfY9tYUaJIBBusnJN/?= =?us-ascii?Q?/X/RT78K7zxl9QtJopbidLaOLR1S5MsmQ1VBkmvmQZZQMCWOxGzlWR9HoQhS?= =?us-ascii?Q?b+oM2OxFDKw8ww+LnhpyndgFQf62CcoxJNCpFpooEoBe7nOlbxlKZMGBXE6n?= =?us-ascii?Q?ag=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95b055c3-e371-4beb-bc46-08dc37858364 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 11:16:15.9273 (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: GgYOgr7cTjAF7uxpHt1wLyceJi/gAsOzVsEj3brxsHZLQPOcmZklr9WPb+OjPXizy1wxfjGyXw4oxhZhzzlJ5ZVNcN0ppEQoGGWDtgPJAzw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5843 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 From: Peng Zhang Add the interfaces of getting firmware version from BSP and ELF file, only reloading the firmware when the version is different, which means the firmware has changed. This will accelerate the average startup time for both multi-PF and single-PF firmware. Signed-off-by: Peng Zhang Reviewed-by: Chaoyong He Reviewed-by: Long Wu --- drivers/net/nfp/nfp_ethdev.c | 85 +++++++++++++++++++++++++++----- drivers/net/nfp/nfp_net_common.c | 17 +++++++ drivers/net/nfp/nfp_net_common.h | 2 + 3 files changed, 93 insertions(+), 11 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 3ece806487..902a62a86b 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -14,6 +14,7 @@ #include "nfd3/nfp_nfd3.h" #include "nfdk/nfp_nfdk.h" #include "nfpcore/nfp_cpp.h" +#include "nfpcore/nfp_elf.h" #include "nfpcore/nfp_hwinfo.h" #include "nfpcore/nfp_rtsym.h" #include "nfpcore/nfp_nsp.h" @@ -1070,6 +1071,35 @@ nfp_fw_unload(struct nfp_cpp *cpp) nfp_nsp_close(nsp); } +static int +nfp_fw_check_change(struct nfp_cpp *cpp, + char *fw_name, + bool *fw_changed) +{ + int ret; + struct nfp_net_hw hw; + uint32_t new_version = 0; + uint32_t old_version = 0; + + ret = nfp_elf_get_fw_version(&new_version, fw_name); + if (ret != 0) + return ret; + + hw.cpp = cpp; + nfp_net_get_fw_version(&hw, &old_version); + + if (new_version != old_version) { + PMD_DRV_LOG(INFO, "FW version is changed, new %u, old %u", + new_version, old_version); + *fw_changed = true; + } else { + PMD_DRV_LOG(INFO, "FW version is not changed and is %u", new_version); + *fw_changed = false; + } + + return 0; +} + static int nfp_fw_reload(struct nfp_nsp *nsp, char *fw_name) @@ -1135,15 +1165,39 @@ 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, + char *fw_name, + struct nfp_cpp *cpp) +{ + int ret; + bool fw_changed = true; + + if (nfp_nsp_fw_loaded(nsp)) { + ret = nfp_fw_check_change(cpp, fw_name, &fw_changed); + if (ret != 0) + return ret; + } + + if (!fw_changed) + return 0; + + ret = nfp_fw_reload(nsp, fw_name); + if (ret != 0) + return ret; + + return 0; +} static int -nfp_fw_reload_for_multipf(struct nfp_nsp *nsp, +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) { int err; + bool fw_changed = true; bool skip_load_fw = false; err = nfp_net_keepalive_init(cpp, multi_pf); @@ -1154,27 +1208,36 @@ nfp_fw_reload_for_multipf(struct nfp_nsp *nsp, err = nfp_net_keepalive_start(multi_pf); if (err != 0) { - nfp_net_keepalive_uninit(multi_pf); PMD_DRV_LOG(ERR, "NFP write beat failed"); - return err; + goto keepalive_uninit; + } + + if (nfp_nsp_fw_loaded(nsp)) { + err = nfp_fw_check_change(cpp, fw_name, &fw_changed); + if (err != 0) + goto keepalive_stop; } - if (nfp_nsp_fw_loaded(nsp)) + if (!fw_changed) skip_load_fw = nfp_fw_skip_load(dev_info, multi_pf); if (skip_load_fw) return 0; err = nfp_fw_reload(nsp, fw_name); - if (err != 0) { - nfp_net_keepalive_stop(multi_pf); - nfp_net_keepalive_uninit(multi_pf); - return err; - } + if (err != 0) + goto keepalive_stop; nfp_net_keepalive_clear_others(dev_info, multi_pf); return 0; + +keepalive_stop: + nfp_net_keepalive_stop(multi_pf); +keepalive_uninit: + nfp_net_keepalive_uninit(multi_pf); + + return err; } static int @@ -1231,9 +1294,9 @@ nfp_fw_setup(struct rte_pci_device *dev, } if (multi_pf->enabled) - err = nfp_fw_reload_for_multipf(nsp, fw_name, cpp, dev_info, multi_pf); + err = nfp_fw_reload_for_multi_pf(nsp, fw_name, cpp, dev_info, multi_pf); else - err = nfp_fw_reload(nsp, fw_name); + err = nfp_fw_reload_for_single_pf(nsp, fw_name, cpp); nfp_nsp_close(nsp); return err; diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 26ea4ec92f..20e628bfd1 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -2090,6 +2090,23 @@ nfp_net_get_nsp_info(struct nfp_net_hw *hw, nfp_nsp_close(nsp); } +void +nfp_net_get_fw_version(struct nfp_net_hw *hw, + uint32_t *mip_version) +{ + struct nfp_mip *mip; + + mip = nfp_mip_open(hw->cpp); + if (mip == NULL) { + *mip_version = 0; + return; + } + + *mip_version = nfp_mip_fw_version(mip); + + nfp_mip_close(mip); +} + static void nfp_net_get_mip_name(struct nfp_net_hw *hw, char *mip_name) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 1c24045b7d..9c46bfd4f6 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -316,6 +316,8 @@ int nfp_net_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa); int nfp_net_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa); +void nfp_net_get_fw_version(struct nfp_net_hw *hw, + uint32_t *fw_version); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) -- 2.39.1