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 A441943C08; Tue, 27 Feb 2024 12:16:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10A4B40ED2; Tue, 27 Feb 2024 12:16:22 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2111.outbound.protection.outlook.com [40.107.93.111]) by mails.dpdk.org (Postfix) with ESMTP id 0457440DF8 for ; Tue, 27 Feb 2024 12:16:19 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nIaGpy36TGhxhjxtMcYaILGV6DPWG6p2fQSbtw+4WRR34JFCXX4K1O9Fr4tFbFXl8wFLBWtw0oeTe0ljjNK2I/SHNDODzsvj8sqa/s6hHCUh3LOCftEKSTiv/yEzM0ZCqgBvbW8sl2m5zCYm6frknkp8BYeJNSyy3XHHWXU9o0Q2PwwHXLxsa+GiV5SC/izOtebYTCQKDrIKovunpUU8K0iLCdLAoIQ0ZnhT1CuN+F6WweGlsqUD1DfA13lfNoUoOmEaU+Qeloi14tDkVVoZdpasesHImGRTJkD0Kyp4bZWessnq7wodl+DOGthnudzSTmIEBKjRPHC2cWmFxNIvJQ== 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=IciFkEM6H34j0fftlM7sD9YSabJ71Xd0jYsnJvcX73g=; b=T6mk6q8PHhyYPt/4OxAdgk6WOmRdqHn60an5hdUft11R5xrUT9MfLD6LsclC/A1eSTOoemUhFMm+a81L5IiMvRA8vIqauqkj6hIc8mI/l7/0pP2TK4GtUw5sS872PK76qpEmFi8I8ES/xA+P11/BKX1GI93AXd+cEL0Zsa8lG0OJ9FI+Q3HGJ1ID2iDEFF8SzHCg/DBpn8fE9lagyNlh/SF9dTLLUOrqUXdbq7s0qdcQT0Wb4L+1QP7Qf+kp6eKSfbB8+7FlzBIPOikRWMgkiwacqcPUb5bQGPCCdJOb7gPsE4pRo8t+pTeTv/JUBR6O0lk54MKgWzu3PBWYwby5WQ== 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=IciFkEM6H34j0fftlM7sD9YSabJ71Xd0jYsnJvcX73g=; b=jwI19UEQebp0YCe99AKMJ2HIi9iL9UltryBjG1pcyZfZAc3myyrdOk/z4USR70TB1OvlZxkCyrtXdD8cmN/8J9T8JoePVH5Fqqt8kScsOARXbuas2B5s/+9W1/KuLVGnMiFwEX202Zn4Ga8rL2Zt3LKz9dqPP7FwjsioduIkRsM= 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:17 +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:17 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , Chaoyong He Subject: [PATCH 3/3] net/nfp: add force reload firmware option Date: Tue, 27 Feb 2024 19:15:51 +0800 Message-Id: <20240227111551.3773862-4-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: a799c1be-d7a7-41e8-a7c3-08dc37858495 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3CUvWmdFKTEsrPl/P86LKu2J9iAygfddKKQNikwk0cR/h6W0BiUD82la8fDdfT11jXAcwfHWAbz0GGbgNeMzGsOK/AMg0swU8vXu7XDMJqr76hPq8WzpILjtFV0pIKkupNkBS81MA+lTd5SoVCGV5L/h8dL4CkhZ+ctHORU1/KdbhbryCJB5WN1CuVIO2X9/n2ZYpPhn2MMcUXI182hRzmtsvh84mzgyTTi+elwNgcBoSjYhy6twiy7AYqdmDg0YpWBRrVWBrLoQ1BZkw+MYK42GHYuC6NZg8CttFQC8I18kxm7Cah8Dd37l2tn0v26DnhmFzv+XF8O70ppXtLcH7PwVTbtsLly3CMKKaW+6w/FvYRz24PUNWEzOcNiePB+VpkWH6w0R3NzSdX3I/p7GMBnxLx5pUMGdQVHAofdnzpbEgPx9tywyvuk7bG8N+ndr9C8gb2is2pCPdvJ4CRR+cQcrXhX49G+aXgqr/uZLEHwb57h1M4FiULjMkfybgYWdxa08A906gfGRp0kEuCGX/f0rZ+nSdMllkRW6jwuj8DHR81cMOVF966AsFdzUiwF0TscXk/FiumAf7TQKaGzGv6zwQrRdBfxKEaCgNiZCz0cAulsSG6uXfmJuGdgJaJLJMSF0NyHChjagRPf8Gsue+k/fgLVE0a1uUip2Y9c4//zdwMXITl0+W2H8G27oLYyIxbPy78QvKHMS8RzMGnELLZ1PkuTjGH4sc0Miy6Q7gyw= 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?K49uq1AdASi2em6rRg+3cQ84DOynySlmzj4OIeHzkGR90eW2t4MVTnjn3fPM?= =?us-ascii?Q?2f94BgXhIP5jaRXYVuxN7HOl11mTW8+lT6g9YUVUMKCjL8/DJ91DdHS2EXIq?= =?us-ascii?Q?RDHhaxGtNxFRKEdesliGbWUujLmzG6GOb4Q7zKLP/aesS+EpkeDpnay1dUB6?= =?us-ascii?Q?/XZNBfHCYLo9hQdqpFtpaptBUljHEe8R8KQ0nESfS4t38f64gRtcEiwwt6BZ?= =?us-ascii?Q?YONdMejPM1BywnKUsZVAIPAXLKFCpMA2LggQbuMpsMoRz9Me8tr1y++t/djB?= =?us-ascii?Q?167bVAhKhc/ZzKfymGHyLjdOlBqu2LxKVosKApOTmacOYZVE2wFLch4d8ocH?= =?us-ascii?Q?xFrVTHl+BPtBpYl2QJXpeILTBJ9ZqDxcZwSvx0K41Qh7JofKHGldFmvk2UoV?= =?us-ascii?Q?ho6FAVE6Bd02xwVoVcorslTZLW1j0eSYQWpHqhmygYuROn5O5tYtYeCmcEmT?= =?us-ascii?Q?nifgk7NCTJyg2qpsSiMJ39hTZfGowFbZIfV/bjua1HiAaL5ZidS6uFfk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/8zGX0dhh5j31ts1FYT32ZdFXR6ELSsc9D8SCZ/lPb?= =?us-ascii?Q?LbnLbd+jj0XLKhkFCNKu2LbBrApM3/qIGShJgWGZ9KLzyS7n5/3zscwvWXoe?= =?us-ascii?Q?JnxBz2eXt/SsVTQWniF4aX4qQSHY8MdHgICLbjUShRaX8mrOYM+oS2DsHQy+?= =?us-ascii?Q?5Mp24aqFRYqVurnEdSJvDekNEewvaqM+JvrcwiTdcOTcnF5WGiDQIK/UrJHr?= =?us-ascii?Q?Gw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a799c1be-d7a7-41e8-a7c3-08dc37858495 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:17.7167 (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: 4tMb7GaOyvyGdFryf3z7Qr/h6HXcPJY4RmgyzgropbRssP60Bh/il91RP2jroaS5qTniF9MmERW7P35w5eRJ47kt7Fnsg7XDai1fLGxv5NQ= 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 an option to force reload the firmware. This option can be ignored in some case, for example: When using a 2 port NFP card and both with this reload firmware option, only the first one will cause the firmware reload and the second one will be ignored. Signed-off-by: Peng Zhang Reviewed-by: Chaoyong He --- drivers/net/nfp/nfp_ethdev.c | 104 +++++++++++++++++++++++++++---- drivers/net/nfp/nfp_net_common.h | 8 +++ 2 files changed, 100 insertions(+), 12 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 902a62a86b..8c38b4e134 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -9,6 +9,7 @@ #include #include +#include #include "flower/nfp_flower.h" #include "nfd3/nfp_nfd3.h" @@ -31,6 +32,71 @@ #define NFP_NET_APP_CAP_SP_INDIFF RTE_BIT64(0) /* Indifferent to port speed */ #define NFP_PF_DRIVER_NAME net_nfp_pf +#define NFP_PF_FORCE_RELOAD_FW "force_reload_fw" + +static int +nfp_devarg_handle_int(const char *key, + const char *value, + void *extra_args) +{ + char *end_ptr; + uint64_t *num = extra_args; + + if (value == NULL) + return -EPERM; + + *num = strtoul(value, &end_ptr, 10); + if (*num == ULONG_MAX) { + PMD_DRV_LOG(ERR, "%s: '%s' is not a valid param", key, value); + return -ERANGE; + } else if (value == end_ptr) { + return -EPERM; + } + + return 0; +} + +static void +nfp_devarg_parse_force_reload_fw(struct rte_kvargs *kvlist, + bool *force_reload_fw) +{ + int ret; + uint64_t value; + + + if (rte_kvargs_count(kvlist, NFP_PF_FORCE_RELOAD_FW) != 1) + return; + + ret = rte_kvargs_process(kvlist, NFP_PF_FORCE_RELOAD_FW, &nfp_devarg_handle_int, &value); + if (ret != 0) + return; + + if (value == 1) + *force_reload_fw = true; + else if (value == 0) + *force_reload_fw = false; + else + PMD_DRV_LOG(ERR, "The param does not work, the format is %s=0/1", + NFP_PF_FORCE_RELOAD_FW); +} + +static void +nfp_devargs_parse(struct nfp_devargs *nfp_devargs_param, + const struct rte_devargs *devargs) +{ + struct rte_kvargs *kvlist; + + if (devargs == NULL) + return; + + kvlist = rte_kvargs_parse(devargs->args, NULL); + if (kvlist == NULL) + return; + + nfp_devarg_parse_force_reload_fw(kvlist, &nfp_devargs_param->force_reload_fw); + + rte_kvargs_free(kvlist); +} static void nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, @@ -1116,7 +1182,8 @@ nfp_fw_reload(struct nfp_nsp *nsp, static bool nfp_fw_skip_load(const struct nfp_dev_info *dev_info, - struct nfp_multi_pf *multi_pf) + struct nfp_multi_pf *multi_pf, + bool *reload_fw) { uint8_t i; uint64_t tmp_beat; @@ -1150,6 +1217,11 @@ nfp_fw_skip_load(const struct nfp_dev_info *dev_info, in_use++; abnormal--; beat[port_num] = 0; + if (*reload_fw) { + *reload_fw = false; + PMD_DRV_LOG(ERR, "The param %s does not work", + NFP_PF_FORCE_RELOAD_FW); + } } } @@ -1168,12 +1240,13 @@ nfp_fw_skip_load(const struct nfp_dev_info *dev_info, static int nfp_fw_reload_for_single_pf(struct nfp_nsp *nsp, char *fw_name, - struct nfp_cpp *cpp) + struct nfp_cpp *cpp, + bool force_reload_fw) { int ret; bool fw_changed = true; - if (nfp_nsp_fw_loaded(nsp)) { + if (nfp_nsp_fw_loaded(nsp) && !force_reload_fw) { ret = nfp_fw_check_change(cpp, fw_name, &fw_changed); if (ret != 0) return ret; @@ -1194,11 +1267,13 @@ 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) + struct nfp_multi_pf *multi_pf, + bool force_reload_fw) { int err; bool fw_changed = true; bool skip_load_fw = false; + bool reload_fw = force_reload_fw; err = nfp_net_keepalive_init(cpp, multi_pf); if (err != 0) { @@ -1212,16 +1287,16 @@ nfp_fw_reload_for_multi_pf(struct nfp_nsp *nsp, goto keepalive_uninit; } - if (nfp_nsp_fw_loaded(nsp)) { + if (nfp_nsp_fw_loaded(nsp) && !reload_fw) { err = nfp_fw_check_change(cpp, fw_name, &fw_changed); if (err != 0) goto keepalive_stop; } - if (!fw_changed) - skip_load_fw = nfp_fw_skip_load(dev_info, multi_pf); + if (!fw_changed || reload_fw) + skip_load_fw = nfp_fw_skip_load(dev_info, multi_pf, &reload_fw); - if (skip_load_fw) + if (skip_load_fw && !reload_fw) return 0; err = nfp_fw_reload(nsp, fw_name); @@ -1246,7 +1321,8 @@ nfp_fw_setup(struct rte_pci_device *dev, struct nfp_eth_table *nfp_eth_table, struct nfp_hwinfo *hwinfo, const struct nfp_dev_info *dev_info, - struct nfp_multi_pf *multi_pf) + struct nfp_multi_pf *multi_pf, + bool force_reload_fw) { int err; char fw_name[125]; @@ -1294,9 +1370,10 @@ nfp_fw_setup(struct rte_pci_device *dev, } if (multi_pf->enabled) - err = nfp_fw_reload_for_multi_pf(nsp, fw_name, cpp, dev_info, multi_pf); + err = nfp_fw_reload_for_multi_pf(nsp, fw_name, cpp, dev_info, multi_pf, + force_reload_fw); else - err = nfp_fw_reload_for_single_pf(nsp, fw_name, cpp); + err = nfp_fw_reload_for_single_pf(nsp, fw_name, cpp, force_reload_fw); nfp_nsp_close(nsp); return err; @@ -1769,8 +1846,10 @@ nfp_pf_init(struct rte_pci_device *pci_dev) nfp_eth_set_configured(cpp, index, 0); } + nfp_devargs_parse(&pf_dev->devargs, pci_dev->device.devargs); + if (nfp_fw_setup(pci_dev, cpp, nfp_eth_table, hwinfo, - dev_info, &pf_dev->multi_pf) != 0) { + dev_info, &pf_dev->multi_pf, pf_dev->devargs.force_reload_fw) != 0) { PMD_INIT_LOG(ERR, "Error when uploading firmware"); ret = -EIO; goto eth_table_cleanup; @@ -2151,3 +2230,4 @@ static struct rte_pci_driver rte_nfp_net_pf_pmd = { RTE_PMD_REGISTER_PCI(NFP_PF_DRIVER_NAME, rte_nfp_net_pf_pmd); RTE_PMD_REGISTER_PCI_TABLE(NFP_PF_DRIVER_NAME, pci_id_nfp_pf_net_map); RTE_PMD_REGISTER_KMOD_DEP(NFP_PF_DRIVER_NAME, "* igb_uio | uio_pci_generic | vfio"); +RTE_PMD_REGISTER_PARAM_STRING(NFP_PF_DRIVER_NAME, NFP_PF_FORCE_RELOAD_FW "=<0|1>"); diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 9c46bfd4f6..628c0d3491 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -94,6 +94,11 @@ struct nfp_process_share { struct nfp_flower_service *fl_service; }; +struct nfp_devargs { + /** Force reload firmware */ + bool force_reload_fw; +}; + struct nfp_pf_dev { /** Backpointer to associated pci device */ struct rte_pci_device *pci_dev; @@ -129,6 +134,9 @@ struct nfp_pf_dev { /** Synchronized info */ struct nfp_sync *sync; struct nfp_process_share process_share; + + /** NFP devarg param */ + struct nfp_devargs devargs; }; #define NFP_NET_FLOW_LIMIT 1024 -- 2.39.1