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 8E2CD454A2; Wed, 19 Jun 2024 05:07:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3BFB4275A; Wed, 19 Jun 2024 05:07:17 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2110.outbound.protection.outlook.com [40.107.95.110]) by mails.dpdk.org (Postfix) with ESMTP id 5F626402F2; Wed, 19 Jun 2024 05:07:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EA3pTjl5UnJBdkgBH0fFmU6BxSDP0AAE1RIbMoiId8nasIn5jbM4wF2KScTANO3UBsdGBg2g+c/Jjg5Abshz0QkNZ8SsOwXWKpBYj3wzsTlUMHKVb3PzPTJBu53Bwur6IKNBeuVIkKLWZDEru1M77TTGXxLPf8FIvkoWK2hQdMCF3DQ3uFWXGDpwphlbXtzLz8x9DKLc6fzkT4RUW+4T2aChjRrzvYw4bn3YG60Yj4sDsJlAzho1YJTo5K33s73vdMfzozpRY7fkDJbMBAUROmkMRn9zf8fWhEDFCOq6vntzksrxMb2ZuusXy7t0BpdyXJPKzS9v1gs3+QgRBrhemA== 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=y+Y/pUUBIyFb+TV2eyw/ary62ookRmISwsZi1HsYSKI=; b=KNvc2bK3dowBkVA6fjeaEF7akqHDu4e1el5Kj3wcrNLTm4Q+EDbFHZ1yaJFjMxIU3zSVwyIHUktgEt7pXdkPbB4QeZQolcHoicbmF6uhzzoE0TFYcRa1TajNjJIfa7/3ZJ5vWewNTShP0QnUaoOnSQvM/Y4aKkGBUuVKQph1NW/dT1Gv4ZUOBRO/PqB3eCT4bu/cozHhdDiAWbXc3kWC46TnNirZvPUZicCUGKubmKI3WD6cs8Dz13Itj5F8kQPQVJswNDNpYVQmWeHW2hWfyZDBvkIzWXp9V/hfBbSyFI4F84xk7vGrTOVnrJfAlbA6mHCOmGgxM+Y7bu10fSzBQw== 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=y+Y/pUUBIyFb+TV2eyw/ary62ookRmISwsZi1HsYSKI=; b=b1zHjTbIfSvCfLa3gRzPoPpA5Dpk/0XoHzPj75n5VUEhoFeXQIUYqlofGRxKa7bZh0Jfxt5ru2388IY4pal7VaUt2qqTAD+f9tf0XD6gIPbj6tfHN1Bknf55ZGv3Nb00Ap/rWO8IAT6dgARIhtKoqMDs6IE9XBe3msuJtZUcPvo= 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 SN4PR13MB5789.namprd13.prod.outlook.com (2603:10b6:806:218::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Wed, 19 Jun 2024 03:07:13 +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.7677.030; Wed, 19 Jun 2024 03:07:13 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , peng.zhang@corigine.com, stable@dpdk.org, Chaoyong He Subject: [PATCH 1/6] net/nfp: fix check logic for device arguments Date: Wed, 19 Jun 2024 11:06:50 +0800 Message-Id: <20240619030655.3216268-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240619030655.3216268-1-chaoyong.he@corigine.com> References: <20240619030655.3216268-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0239.namprd03.prod.outlook.com (2603:10b6:a03:39f::34) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SN4PR13MB5789:EE_ X-MS-Office365-Filtering-Correlation-Id: 48eeed8a-d380-407a-8c89-08dc900ceaac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|52116011|376011|1800799021|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vPWx14jwWGEHX57PpFFwB/4XRVoyTV9u4nRo3++HylN9UZuBBHjUY9aSDO3C?= =?us-ascii?Q?653GD+V/RWSB2Vgbtat/WX/uLvdUE9gdjnnSRDlVeCBbCiSCi7TkqIz9T+i9?= =?us-ascii?Q?rN2dGpVTOnaWIgA4aOwI1SVoYmLCg3saZioX2BfgvClg2SNoQpLRNgGI/rtJ?= =?us-ascii?Q?r/LcMb3KNDrEN80B2T1cZIzxGICzOLLqeYEsLNT7Ma9de2DBXPoQUx2tjPt0?= =?us-ascii?Q?djGrIum+Ft/qDLm9flV8gNFJXMcSRlpLHcrKDIAZ31W0dUFQxl3IbNumjJQ4?= =?us-ascii?Q?Us0YkF6uM0qXp2ZbPT48uH1n8U4yiD9bG9nvRdjN1zQdjA7KcmIPZqVrgbH+?= =?us-ascii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4GE/x7i8TkaRhQL0gK3qMwnZ/P/F+4F4M5jPoC?= =?us-ascii?Q?N4OyY7g64O/DBINcaxNkfL+sUbNenkYAuFHAyt6TlF+0rieh9QgMyg66aixl?= =?us-ascii?Q?3L6yLBlLVRI1uT0GewOKvtqPByrMeERORQ7/bxKNjgp9WU56hXqFe4gKTeRi?= =?us-ascii?Q?xYoQaRI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(52116011)(376011)(1800799021)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?BxgNWaFdIwK8ao4VZXdC2WQ9CIwHdTS4fgp8IRQ9FRcIMSd20mWEfIbvUzSJ?= =?us-ascii?Q?536EZpGqUbFqRAw17sJh/AbzD1apISUq6pyn8Y4FPNTmuiTyvxifiOzHsKmh?= =?us-ascii?Q?jWBJKkhTvnNV+9FvnOFyoaiJAuIbULxDHtj2TKcBVWGhhdMhBz7oVZo+XPbV?= =?us-ascii?Q?FXhcsG+E5ynj3LOOxAiBJQh95FXxp1u0rklX3dxHEzGpbEruSKD0phbpzkoz?= =?us-ascii?Q?CFv619LJlox6aP5efR+OPg3X5qMcpcolvJ03dSw3lT4C8t70kkvBjfXBu1cI?= =?us-ascii?Q?t/VOKQBSMA6ZwEN5nF7MnIQGsgOZ89NBeBDOljDX/laGd+unEAvFF9HwNUi3?= =?us-ascii?Q?exnoP9BulgK2HuoWi9E2ANkGbY738sJmhnk8xyVAJtlNrHk7bS6VwFNK5G4f?= =?us-ascii?Q?pY6NaM13bZE1u7v//CUCfFfov0I5m6ZbJfpzGTy90qRb7f46rFPE0Th3ZODF?= =?us-ascii?Q?8mvOTRu08sWO3WbSIcnO2xCLm9ACCsngmiaNzTr2edeN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+1vASguDrqN7lw/vPZ56XE2pz+52Mq+yDxU5CgCWqg8ht2+b9YHFA2?= =?us-ascii?Q?5jXCbihMHv4UUvvXL9ORbepqLqAH5LFCD4ylGj4HpMVEepEKOAJgEEsvY+BG?= =?us-ascii?Q?8YjBWbvXOHQeCp5v9uDCv2oRo3Lc/6z+Mk14DH43NhojUt18Be6Qd1ahWHsn?= =?us-ascii?Q?mmUZyCHNM6UBxEvWVg3Jpyi6hkRIHecN7eBvOFgU8ia5duVx32Tcd0aEdWMZ?= =?us-ascii?Q?Lw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48eeed8a-d380-407a-8c89-08dc900ceaac X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2024 03:07:13.3703 (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: PWTBm974IOlxi9xPJuIaTaV6gdUHmH3zNJ6WnHipwaq2FVycGpM/k2J7GeizTJ3iwWj3b2mvNzy3c/z8/DXS83L5yj9eMq4mvD4G0xY0lOY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR13MB5789 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: Long Wu There is no check for NFP device argument now, so the users may not be aware of the wrong device argument and feels confused with the result in some case. Add the check logic to fix this problem. Fixes: b301fd736003 ("net/nfp: add force reload firmware option") Cc: peng.zhang@corigine.com Cc: stable@dpdk.org Signed-off-by: Long Wu Reviewed-by: Peng Zhang Reviewed-by: Chaoyong He --- drivers/net/nfp/nfp_ethdev.c | 59 +++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 71c4f35c56..ddbbd736db 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -67,46 +67,64 @@ nfp_devarg_handle_int(const char *key, return 0; } -static void -nfp_devarg_parse_force_reload_fw(struct rte_kvargs *kvlist, - bool *force_reload_fw) +static int +nfp_devarg_parse_bool_para(struct rte_kvargs *kvlist, + const char *key_match, + bool *value_ret) { int ret; + uint32_t count; uint64_t value; + count = rte_kvargs_count(kvlist, key_match); + if (count == 0) + return 0; - if (rte_kvargs_count(kvlist, NFP_PF_FORCE_RELOAD_FW) != 1) - return; + if (count > 1) { + PMD_DRV_LOG(ERR, "Too much bool arguments: %s", key_match); + return -EINVAL; + } - ret = rte_kvargs_process(kvlist, NFP_PF_FORCE_RELOAD_FW, &nfp_devarg_handle_int, &value); + ret = rte_kvargs_process(kvlist, key_match, &nfp_devarg_handle_int, &value); if (ret != 0) - return; + return -EINVAL; - if (value == 1) - *force_reload_fw = true; - else if (value == 0) - *force_reload_fw = false; - else + if (value == 1) { + *value_ret = true; + } else if (value == 0) { + *value_ret = false; + } else { PMD_DRV_LOG(ERR, "The param does not work, the format is %s=0/1", - NFP_PF_FORCE_RELOAD_FW); + key_match); + return -EINVAL; + } + + return 0; } -static void +static int nfp_devargs_parse(struct nfp_devargs *nfp_devargs_param, const struct rte_devargs *devargs) { + int ret; struct rte_kvargs *kvlist; if (devargs == NULL) - return; + return 0; kvlist = rte_kvargs_parse(devargs->args, NULL); if (kvlist == NULL) - return; + return -EINVAL; - nfp_devarg_parse_force_reload_fw(kvlist, &nfp_devargs_param->force_reload_fw); + ret = nfp_devarg_parse_bool_para(kvlist, NFP_PF_FORCE_RELOAD_FW, + &nfp_devargs_param->force_reload_fw); + if (ret != 0) + goto exit; +exit: rte_kvargs_free(kvlist); + + return ret; } static void @@ -1856,7 +1874,12 @@ 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); + ret = nfp_devargs_parse(&pf_dev->devargs, pci_dev->device.devargs); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Error when parsing device args"); + ret = -EINVAL; + goto eth_table_cleanup; + } if (nfp_fw_setup(pci_dev, cpp, nfp_eth_table, hwinfo, dev_info, &pf_dev->multi_pf, pf_dev->devargs.force_reload_fw) != 0) { -- 2.39.1