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 DCABC43BC0; Fri, 1 Mar 2024 09:43:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99AEC4333C; Fri, 1 Mar 2024 09:43:11 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2130.outbound.protection.outlook.com [40.107.220.130]) by mails.dpdk.org (Postfix) with ESMTP id C4D1243267 for ; Fri, 1 Mar 2024 09:43:08 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W4hYjWsFicepJCWcyev4+qKNB9vSsfirfsLuJF11qZ/lYaQG/sEV67D4i3qd9mfz5XaJl7+UFWKNrf5nX4sjUTnAufEL7qid5XXBGmZpyS86sFnYXwhCDDvmaSG0X3a5f/noH6yvjYZ+9+ZcH6EzpoZrQidcE2fj2fhvR6CYUEi2W5GXChyK6atBehE+IZTu4x2SbsTXLi8z4aZ52axM5Zu7LyNmXaWjfBEMfUqK9lAhsA2Cu0qjThyXjfMY5xOrNnNrSOTGyYJKjXz7dE/VBps5VKl+MYpA5YkIz7CCCX853zHhgSNUXK1pfid7JHEqT0lk9ZCilZG50mtDRiDl2Q== 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=WyNX92Trok04kETDvRVSeBRPoxw/2axQGZUhWLX47RydU3IUbw4CchXAVMXh+vzHx7YsfsAaHEt9xLynj7N2TiXqAKPBxg7D3jLDsEB1KpuhFc1AgMN+0h/vs+ZNaMa20NAQYvWPFDqANYzeDwYxcDesscx1jiLZcEobakS/DP/LHisTubxz8Cccz4J4x0q6jMHJoaG4yq/+LMXio3TSQETX48DPhHzC4xNJiqnUAUU6GVcnm9pvLNalHYCU0H93LyvWqI7nR/h0gEzn2Y1XsJsb365s2S75neNrWUEO6ryHi+cn1FQHmvX+4DPpCP2Vreg/bJAhYmlztuuto2I1Iw== 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=bt7tsjHw3FIcVvYdt9rrqECVyEkiS6EMnnk1AFfQqCQEGKHG6rHCD0WCSRPcQxt7EOtu44YfarwXzB/hmxT7FZ5HMrYZM6Mm20voB9NSnjcIThalRIB/Imnm9VNXRri0mWVOusmvEheOvTqT95O/1Qz/X/74zLia4CmxutnGb6E= 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 MW3PR13MB4153.namprd13.prod.outlook.com (2603:10b6:303:5c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 08:43:07 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%4]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 08:43:07 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , Chaoyong He , Long Wu Subject: [PATCH v2 2/3] net/nfp: reload the firmware only when firmware changed Date: Fri, 1 Mar 2024 16:42:43 +0800 Message-Id: <20240301084244.190484-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240301084244.190484-1-chaoyong.he@corigine.com> References: <20240227111551.3773862-1-chaoyong.he@corigine.com> <20240301084244.190484-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0206.namprd03.prod.outlook.com (2603:10b6:a03:2ef::31) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW3PR13MB4153:EE_ X-MS-Office365-Filtering-Correlation-Id: e4a1c677-b95b-45cd-5e12-08dc39cb9dfd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2AOaALFKn3NuwrGYbmbp3BKQAIc1V/AKhgpXyyl02jDQLwWPYXP5vQjRnJNRxeEYX90JNFEhhR22+vcJZKw2N4m2GYVBhBeElvZIUXvqEEc8p7xtnmAzpqIwbuJ0GYFJaZVfG5OrnSAU+SNOkJSebYVwZe8TrkciC2ka20nnivy/rwtWO5/gPjxig7aEHpM9Q/fc3n8Cs8hFpuj0O9gYpj7vOOQPJ+p6RkonT1s2D7yJaVRFEJgOnuIl0PsPrlkRrBJRrf1f2KeLekcRzshiWnaOW7wZk+ctYrg+ma8h72Ofp/zkxpsO3dOXqU8oIk9X05r38XgdYcx99uq7IaB9ncHIh9k3rOIDk7imspYLR7ETQ5cdu6FxQCXTJMMHCuCen/FgbV60LXJa0ZPj5uoYVGy+omPxwQQvTiIl1swZCaFLixuq4KSRCdNNn/LBRvWaHK4yVG3UNQKBSdYlTicQAPv7DuMAx6bcSHUZuF3qPOGTViCSjSyEja60j4eikGJmtd28dRWdU31Pv+gCIDPyzk+rSqVUfp/mgUWNYcOPx9d2OWM+1OFIJqHIh4BFwZLYabGgje8WVEp3kNbycBN1GRlJXH+LH1ukBOD97TAiO5bcCKlm/i4IUqNycpoQRY382XM7FQp5SnCalm7Ec2Bq3jVVS/c9jzSVJ0Ew6IZoDI6UIjzLYLAv2kPbtYy1Wl6+10ERmljOYeWQafw5n1G2BhFWO1vwI8cwyFzSdRKdc/E= 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?ed+b9CaVUe+T023O2nO3RE3CISZoWQJ6a+3CEpIaVqLoOPTbEdbyxDnh8ApK?= =?us-ascii?Q?qyKT8hDZ24HTnNRyEISdBX5uS+sHlOV8ZbPNlk052X/eU6+Jvi2yBXphT68c?= =?us-ascii?Q?GRLq9YaXA73BpkTjR++Z9/HizMur5mMs9OXD+KyfJRX3ZmsKthbhXWJDhlWb?= =?us-ascii?Q?BuGJArazqmbmHTpgSco+SnBc+IlkNJJRBRycAR+yUBUhSiVYhw+IXUrH0pji?= =?us-ascii?Q?HesGruP8nCXqk8dcgG9xZxT3k5S4Jp4DgvKamlUPd30NBkC0+P3OGaEsxPZk?= =?us-ascii?Q?QrxEIrLVyQD38tocvAZkAiUGNB3BpaBQDiqFfWbL9rL+zdm0q8a0NcqPEc3X?= =?us-ascii?Q?71sksqiD8+jIcpdbsGChTwVJe0n/1+JdTPvWO6qoFfJ1y42chbUuxL83xw1v?= =?us-ascii?Q?mfjjovnfXTWK121YWmOOdEhb4eL21KDMa8a2sQgElmT6FKg5+5vpFGFfJb/a?= =?us-ascii?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MzZ70YSRoRIa9?= =?us-ascii?Q?tEVHxFKrQyziPUWAzqYzkGr6zLoW5iqSllIKPxpLTIKpDY78wPJ41kBTNqy5?= =?us-ascii?Q?L67qdLrHmKKM50c3EiPxRvQ8sNIXcP7G5n7Cx9XaYJP0RJ0c/ZmeooCZjKBs?= =?us-ascii?Q?4titu3QDaM5ZmkElyjMMI92CaEuoYxYUThEiqMT3zN0QnouH76vHJLZPZddb?= =?us-ascii?Q?g4eHvgQMij1Id5y04QlWz++HGr9Bn7cvGNKrcBhbxuPCucpDlIlDrf51BXE7?= =?us-ascii?Q?wg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4a1c677-b95b-45cd-5e12-08dc39cb9dfd X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 08:43:07.4341 (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: Oyy23P9KH5Dss0NWyEy+UPQ5Ipnto7JDl9dV4+AB6DcL5c4hBx74ELUoCPsOYgzULI4tnOfvB4L7u4r/Wt2adpN0DCMQ1h9fAFtChSWNjy8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB4153 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