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 A596543BC0; Fri, 1 Mar 2024 09:43:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD02B4332C; Fri, 1 Mar 2024 09:43:12 +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 6AF7643328 for ; Fri, 1 Mar 2024 09:43:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RsYhO/fQgYV1yBjcMBX/VwELDlUIWgdHr5WLOlBCbnPlM9EzF3hCEPts05e1FqQ760q1kU7CyN8gWabb/Ok+MJ3lxu1cRlYIxH1hQiowc2qzBD7bJL+dIwZN2hahYY1s3/+K46Aj5oiEFIzqqJVt/cXsWczeisVSeEH1BWLHK2L3Flf4B1evhAL05IeHoiUXeBviunD1FR8PL7Uu62Ovjrb+NDElr0Kmdd2bJM3oeXKER0MiTKPKHlxOJqXjGlORkCM9wCSVFgb2FGYmKVkl3PiIOzvSlynyazQM4yRRv/moLg6L5diqqNq7GVHNX9Ac90egn6CKM1ZO78mhr0Q30A== 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=b2kolChHTBsf4U1zm3edH90iNFG/BPSyVquKUTPqF38=; b=mYo7Vmu/RctLs15Hj+m8bVNBaYABUOaqTDxV+W/dPgttWWjM3ygVEjXLPTDwRdj7IQX3rCYbrGQ9I0KHNGZ6qq53LeKsJQYpPxoy1FHKHbxiM73L7821HiwFmEfp1dz5iouaBHH9F9VPEExjECVJiaGTtqFXVS5RmPNw4hQTsGlnD8YQesSmL0PMfE1+mN8ZCVOvMytoV3ey6WJLO7WeJy1+RrsbFRbLn6vQqGUzeDv+LXudnjKIFnkBNQNkmm3VEKZk5cNAjIMV6g4GQbNurjhZ+qNIg5ZEE5GCwKOLC/m97YebYTXq0RKG+V7/I7ZXZOsVimst/0lU/Xm9Xf5N9g== 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=b2kolChHTBsf4U1zm3edH90iNFG/BPSyVquKUTPqF38=; b=exad/rAekMfwqU6Ns7J76dILkIuip4m6RHMpck1dzD4WInkArS2rc6gg4QZ014Em+wgLI+K7n/CRz2+fVIQz+eBnkHsW/XBIEnn2IgspSZugIK50aeAerlJKM5ZaFYr+eRhVwIpaJGxHBexmYaC6Qa5RJ47OB+Y93gOu0Aagtwg= 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:09 +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:09 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , Chaoyong He Subject: [PATCH v2 3/3] net/nfp: add force reload firmware option Date: Fri, 1 Mar 2024 16:42:44 +0800 Message-Id: <20240301084244.190484-4-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: 7797c06e-917a-48ae-0fec-08dc39cb9ef9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aVYDMrrQKtmRqQr2vomfZgH7RGCLcm1zN5PWmYIQqotJTuRdLbn1c9uSd1YMd8sdeSV8tXfCZo457g1mjgMatP8Zw2jCqYZs0Q9C8P13DRBiBdOENV5PPD0NxLP9H/kfJzdJ42fhDmvo2rxNvyjD0o5SfMuGXFb+B9hUlRZpc3xbBLpUdyLPhO60TAm9m2RJjzWKQyXNOTYxy3L87irHd/J3hE8obiAek2LLNoOnWY/wdtGhb6xlkigvrbbheG0Y82Up4GSbLb6Cy8kKWDhAvBW9jdDaW9HR44Uu57nFKgh2G4xJvVXEK9UCr79jMkMb5+g+POTnm3xlx9IHX0ei7f8T+ewyvpfZMig+goCNTCIEBhAJ7hZAyOLa07i6I5pS0TI4CsRDhp9KIifhcA3Q9QWCU2sEXJvBwAcnBtLHYqP2BByOQZfanO4k9Uj7zqR8lz+lobSZKzXS4uAqcBFrvDzvo/0Wi6zfwE1ZkDf4qZEC/y/hMULiBoTJ3UPE6h+v+ICvrqndUw2BFNcTPt3Y5YUpaa82NBS3ShtCRp7srvfMfkR0lslQWR8LUWtkEG17oK/uheYakJWy83dDysbjS6LTkJbObRlrWwOc4PcEt2vKmw4xsksh2Kz+o+qOze/wyYnFh85ZHaGFmjJ4TM9qMDek7jbtILH8MmzUjsl+FbXfGQBh3+2JEoL/55U0SN2E77+6KCNXKN2D0CaMPJgjRw== 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?TGKbnaHU9F3ScR8Y+rwr2hh2YDIPs7X4Tf5sAQ16vClvadePFlpHUiS06Oer?= =?us-ascii?Q?7+Ssgj5PTAnNDFBk7yYLBamfcAqcUM7foTiKsrjz6ac36kpW/J7E4bBpt9se?= =?us-ascii?Q?l2xN1XiZthYFw8lFhAZPlfvnnGLf1QPt5UjmQqvTQEBRkyguu7aVeCKkS2OU?= =?us-ascii?Q?iOeosvpMM3tHA4ppD5wlozHicvsG4sujM5efgI5MGQuzDK+CXBEtrTlzAcmI?= =?us-ascii?Q?XIEdKOUGarLP20GrFdxCzVV1aCkH7OR1oVNkURfvRErmlf73UyToJjrcMeNd?= =?us-ascii?Q?Cz7PqEHLAKglQGfOkPcYwsxrjOu/F6umIgM2F9uKZtJrUZzdVB8ZSxeKQDjn?= =?us-ascii?Q?bfWHD6+PGoC8fBRsQF1b0s6Nq441Tzxhn6wnwr8qRSPAhmW2C7htpmmu8mH9?= =?us-ascii?Q?TNJlMb44W9siJyvNOxOiZNWC4TkQ3wClP+H89LVV+IKtyclGmMQzKYkFlBub?= =?us-ascii?Q?ysRyjK7T527cYc2ZEiqPvQ67RQzc6Zhg/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BDyy9us9V8eyaVIK5uvvP3dMP5fh8D7Blywil0ZB4eJfpMQdLfj?= =?us-ascii?Q?67f54EsWw/lLHwBZip6hqej/r6GzUsTka0oLjnxVsY3YoOF3R3aG+0rnTAWV?= =?us-ascii?Q?p0rIiwD43Wm5sOQZsCaJWPqoehgDvpXEQhUzlpCkGSMn2F1SQl3GCPBGKzWU?= =?us-ascii?Q?mQJViTW0c3oTpRXmVhQLyP6YyYsaEIXEE6uDLyZWAbzUDpbyjEFJvxvOptvx?= =?us-ascii?Q?/w=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7797c06e-917a-48ae-0fec-08dc39cb9ef9 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:09.0758 (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: oaXOIE184cOUFzErsVEoLZeTMY8zwU/0kFRDlelraJT0r3pQxp6ectgR1OzWRe1QNZIJczoZ5Qq+/wfGANkoIfoqwZbyQ4oJa6F6hYSHVAY= 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 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 --- doc/guides/nics/nfp.rst | 21 +++++++ drivers/net/nfp/nfp_ethdev.c | 104 +++++++++++++++++++++++++++---- drivers/net/nfp/nfp_net_common.h | 8 +++ 3 files changed, 121 insertions(+), 12 deletions(-) diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst index fee1860f4a..4f2be0856c 100644 --- a/doc/guides/nics/nfp.rst +++ b/doc/guides/nics/nfp.rst @@ -225,6 +225,27 @@ The ctrl vNIC service handles various control messages, for example, the creation and configuration of representor port, the pattern and action of flow rules, the statistics of flow rules, etc. +NFP devargs +----------- + +- ``force_reload_fw`` (default **0**) + + The NFP PF PMD supports force reload the firmware and ignore the firmware + version. For example, user can force a PF with PCI ID 0000:af:00.0 reload + firmware by: + + .. code-block:: console + + -a af:00.0,force_reload_fw=1 -- -i + + .. Note:: + + This parameter 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. + Metadata Format --------------- 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