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 B453F454B8; Mon, 24 Jun 2024 03:59:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E1A940A84; Mon, 24 Jun 2024 03:58:12 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2123.outbound.protection.outlook.com [40.107.95.123]) by mails.dpdk.org (Postfix) with ESMTP id 6DF9A40A84; Mon, 24 Jun 2024 03:58:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dGcWRG/ORoeMGsaYeSFOX9uroI7vmj+XRoWVlaHDE/PZHVpJ6/Pdb07cT89LlL4fHPcYv/5XGOTQ1qY3kGTFHCNwj905bEp0IF/TR6p9xtxW8ANeq2Do2NiSr+qJ9jht/AXUpt9I38EVJFtvL/4yitmzZL4axpgenPHwoWVRJQkNnO/j91w7qrZKvbgwW5ncDWmmaMcOsTbkKI2YNETbW3oJJFqfU7xH7iodXQA9HVq5jWCaJvY0Vehll9zGpKvGpyF0LCzpnoIZNieQOKphKVvsk+0Q6wd2ztjZpGJ5PCY6SGaDeOfUCRrWXeCAK2hu2bkykUsJQ51p8SUlypnZTw== 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=GA/PsIhWDa6x4pkADExivMNExWD5hswsHffbXs3Nqfk=; b=UJXeKyRk0h9Yce0i+qEKAGQTjr55YXIG1Gyk0vYji7sQLsEEcGojOLbmnckC3tLwq2WhNIXrWN3zl8qCfXPuGalq+gw1jexiCnDIk1pOjJp0ZHik9NVozWAcfP/SH83ijLNDqSyJRJUGyhgB20GjIkAGm58K2Ob5rSpTduPVdUPzXB42XvpuHMJG5TFPjl6vCdG6NQqzV/iLSeKUgw0IsVf0yGCjZJ5H7Vp0HgYyXNnlKFPg+FeB34Cqj1RFaX7ARVGgiEUGZl70DBu59lhXoPl1DT19AEGzRJXejzLAIjnBonkaCSyNvkwH1L4DEqWbLaukaKZtoBS4rW/gxPdChg== 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=GA/PsIhWDa6x4pkADExivMNExWD5hswsHffbXs3Nqfk=; b=tN9u5Bka7uHXG7+GlagAqQjcj+zeJJPqV+zOvZUQu9EjO7GRCMUpzr415yilQvXhj0V4uCX7IVbA+eAxbBGilGUvuehqDcHLg2ejwfxo3+oT3cOC/w0hLKnOqNlkiit8BxvKwbOf7y+APhCxY8U3k0LNw/TzcrC6/hM4ZgEuHrI= 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 PH7PR13MB5867.namprd13.prod.outlook.com (2603:10b6:510:159::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Mon, 24 Jun 2024 01:58:08 +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.7698.024; Mon, 24 Jun 2024 01:58:08 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Zerun Fu , stable@dpdk.org, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 12/17] net/nfp: fix getting firmware version Date: Mon, 24 Jun 2024 09:57:18 +0800 Message-Id: <20240624015723.3712898-13-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240624015723.3712898-1-chaoyong.he@corigine.com> References: <20240624015723.3712898-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0070.namprd13.prod.outlook.com (2603:10b6:a03:2c4::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_|PH7PR13MB5867:EE_ X-MS-Office365-Filtering-Correlation-Id: c7980032-d3e6-4d0e-e95f-08dc93f1180f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|52116011|366013|1800799021|376011|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?INWddTgA8nn72f1f/ppsLqWLVRNZenVNzXrB+GwRUvbS8tPkTOD6fVeHQsf+?= =?us-ascii?Q?/tZTj9o10OYIjSpHYeCArSvnsEjR+4bYTYErLUzSd5Ntnt7JaF5FX8Y9TWjU?= =?us-ascii?Q?dysYPmd1MhGF0pQ7gG2davBdLGJ4cfsv500zdeOY8V4ucbe9ffy95g8h0Fa/?= =?us-ascii?Q?Rj8rMol+TkgUOy7XLQvypY45O8+EEF5Zs+HmyOiyeMs9XYQlNmZ0sQ7kRS+O?= =?us-ascii?Q?zE29K8wCdu38zoNVgIxltrBc1S6RKClr6xOCXNShPIG+OqdWFWSiOr+QPipw?= =?us-ascii?Q?qBHbbV/yB+GzC6Cy6yCfQu/1D2hHlztNtWgbejZWeEebZAMNGqzv56F9iQkB?= =?us-ascii?Q?nm1aAzAA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= =?us-ascii?Q?IsRfg8PXFnmSir5AceR0JWs240uy3M5q1+AEYIzBJM7Ex0Wdve7jj7ffeZGK?= =?us-ascii?Q?u9IPtIkPAt5y62cq0ULX/fdmNzTiDmNYO48IeddWPIsTbu/0cuu4BLeosxFg?= =?us-ascii?Q?abQfrrM=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)(366013)(1800799021)(376011)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2C+PlEYlTeYwcj/iKGjhw8DREMjK0P4kVBJ1XxDk/B6gh7+KVG9ftqnaSuP4?= =?us-ascii?Q?o/pITK61I3hmGhzV+TzEUa61GSzoMOiKlcbTQGJJK/TWkNtIbXZHfSSDPeDr?= =?us-ascii?Q?D7hZ7ZckGx2UV639ge80Ff2pX/Dnrn0/H8dyKycWkE2yqgXRvEL2Ku7+9hhY?= =?us-ascii?Q?rUTgfBYebr0N+TwXhxmouDzxJKm+XWuZn1Nt5/uMUXIp32dVMQozAMZMP2Ph?= =?us-ascii?Q?5YiPyPSNiufsDj+Xvd+YYwUH3EdGQ4QNpL0B///rYL//brWuUFwiPA/3MZpd?= =?us-ascii?Q?SmvfOORJOEDzA8hv86aItGdBoC2DD8LxwSPBbqowY6zyoeqWoU01S4u4smYF?= =?us-ascii?Q?GIVhAzY3/a/gG6hwBKLQFiSgYzzsH84NWZ603gC5FDAUBrpiSw9252Gs4mJS?= =?us-ascii?Q?7rQ7+ne19puOCuVTX+d1Z7CvRMdS0ayyk+s4gaGqnIgc863duD79qVnc8lxr?= =?us-ascii?Q?pMnEZEjussxwXcijrTT6ErVG7tCzaxUzAfh8nx6SILejPCA9eEIiFKMWR2+V?= =?us-ascii?Q?DQ20mihkA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ruyX?= =?us-ascii?Q?39IwlWOLRlmB3n5jydPaDBFKxG5Y580NdF8XO/fGtq6ygSIgIvwcEtZweiXA?= =?us-ascii?Q?RmwUt8MsFLsFBLwVldfxWLZTeQ+WokngrCUr2w/RGkTfFCu5SZyt3xYCVsr2?= =?us-ascii?Q?UW+rcc+OV6ye0VdjmFFrOjfM1NOKtSuQ/AUiRbglr/cIMAsxvjTIkv5nXjhd?= =?us-ascii?Q?lw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7980032-d3e6-4d0e-e95f-08dc93f1180f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 01:58:08.2488 (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: AjeQ456TSLc1qCE7p5J/oig4hOjiXGsZ2txo2Dnud8BKOqNTUFNJE1aO+nmjRZgGeuM9mTcaGep4o7LxYUp44/lskd0/vtMqd1KVyOKNfH0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5867 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: Zerun Fu The original logic try to get the NSP resource every time the application call 'rte_eth_dev_fw_version_get()' interface, there are chances the NSP resource busy and fail to get it. And because the local string variables not initialized, there will be out of range problem when it fail to get the NSP resource. Fix this by initializing the local string variables and storing the firmware version string once we get it. Fixes: 128c8ad951bf ("net/nfp: support getting firmware version") Cc: stable@dpdk.org Signed-off-by: Zerun Fu Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_net_common.c | 26 ++++++++++++++++++-------- drivers/net/nfp/nfp_net_common.h | 6 ++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index a6573ed45c..84893e2d73 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -193,9 +193,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw, nfp_net_link_speed_rte2nfp(link->link_speed)); } -/* The length of firmware version string */ -#define FW_VER_LEN 32 - /** * Reconfigure the firmware of VF configure * @@ -2274,11 +2271,11 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, size_t fw_size) { struct nfp_net_hw *hw; - char mip_name[FW_VER_LEN]; - char app_name[FW_VER_LEN]; - char nsp_version[FW_VER_LEN]; - char vnic_version[FW_VER_LEN]; struct nfp_net_hw_priv *hw_priv; + char app_name[FW_VER_LEN] = {0}; + char mip_name[FW_VER_LEN] = {0}; + char nsp_version[FW_VER_LEN] = {0}; + char vnic_version[FW_VER_LEN] = {0}; if (fw_size < FW_VER_LEN) return FW_VER_LEN; @@ -2286,6 +2283,11 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, hw = nfp_net_get_hw(dev); hw_priv = dev->process_private; + if (hw->fw_version[0] != 0) { + snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version); + return 0; + } + if (!rte_eth_dev_is_repr(dev)) { snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, @@ -2298,8 +2300,16 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, nfp_net_get_mip_name(hw_priv, mip_name); nfp_net_get_app_name(hw_priv, app_name); - snprintf(fw_version, FW_VER_LEN, "%s %s %s %s", + if (nsp_version[0] == 0 || mip_name[0] == 0) { + snprintf(fw_version, FW_VER_LEN, "%s %s %s %s", vnic_version, nsp_version, mip_name, app_name); + return 0; + } + + snprintf(hw->fw_version, FW_VER_LEN, "%s %s %s %s", + vnic_version, nsp_version, mip_name, app_name); + + snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version); return 0; } diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 6c739891be..3c4d305b01 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -50,6 +50,9 @@ RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ RTE_ETH_RSS_NONFRAG_IPV6_SCTP) +/* The length of firmware version string */ +#define FW_VER_LEN 32 + /* * Each PF has corresponding word to beat: * Offset | Usage @@ -255,6 +258,9 @@ struct nfp_net_hw { /** Used for rte_flow of CoreNIC firmware */ struct nfp_net_priv *priv; + + /** Used for firmware version */ + char fw_version[FW_VER_LEN]; }; static inline uint32_t -- 2.39.1