From patchwork Tue Jul 16 13:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13734527 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2072.outbound.protection.outlook.com [40.107.220.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A063019AD4B for ; Tue, 16 Jul 2024 13:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135509; cv=fail; b=ooSd1a71h2bqLOJPiUsxlVGVabEGX2rr1fF3gnYSZYtWJKuWOPrCdW1WB2Rdidh/+GpPFLFPUp7A6pBuEc9UXSzu5RbP9JsVzBZH1NbpCogtor6s2/iF/4FiIJp7WLDvKIg1WVs6zwvFmjiJwQdjY/xlNHdy91fEAGKi5gNrP4c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135509; c=relaxed/simple; bh=NQf3Y4aX3tmM1sLMXhVSGOv3+NeMSwsZRAdERLUTkFQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fvzTkwGLPn6zEeynPrIAUdLIWHfsIatmXGP1CbhIH9GWe3GECYcDIeetqgpfJ7atIeb5+IcoTUPA6y+g6uo7LSm+rMkdAPrKvgycjyyV5ba4GaBiQlVH4Z82GrOfhdJ3IrPElDoQJRrpuPWHGfw2KtIAmm10no7n8goC0MKfErU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=UO4TIDvt; arc=fail smtp.client-ip=40.107.220.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="UO4TIDvt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nOkqhzlhj6Kosos0pXnO7ujWKFDjiTmGdp+0EaA88wrVP/D+xB3/+yMgRfUHdw6G5/HpJ/Iod/orx1OTOwYtLmLT5ZIDWK6GQdPU8sEZkOaFtWly0EkJXlKGcwmiBSOHO2H7U6QZTcgUxqSE0V+ohE6GjDiGI7qWN+ZOC7rb/eTRlVGwVzu8QJxfqXDFwzKh62ccxK8wauiZk1cb2ZKYMm6CsvYVOz7mxh+7A0fwcAvUB0qOoJg+pMYr5weRgepXl82dW0uKhNrOMnXG+701BubkaeNC0Xpkeo6mum4hjM1onCjCisOvokatCJZerCpelCBi2Y3amtxuBkpOBleiPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=4gJzY5GH5V/INJt/yqTN0CYscGjjAoIMJT0WBzukMoA=; b=veQpAKJ8vjcin2RRtU+IxpykX0bcXjyHBCENa+s3a7Qkfj/5a8N8t5RizToTxxwPJYC0RLqpAsWe83TKBKF/3Hx06kjJZp5cPi+lXm1VlUeYP8vJ9aU2WI6siOvm9OlI+rTO3pqfU1YIucobg72BWBWalUTRzH5TLPzi924+QxeW8syTSASqCNewjPuGQRfMVEU0XO07pLDi5KhV+cGfx5hiYNAa7LAycNojKDaafVXwQi3KiItpqTgF8xej0W14Sj5cK3GaTaLgNiiTaj9eVNKD3eHmC/Bag308to/4T56hRQ/gZR/IhqLMH/nALlNHpudkSsrd02eGy+GdB+z2bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4gJzY5GH5V/INJt/yqTN0CYscGjjAoIMJT0WBzukMoA=; b=UO4TIDvt1JfImTsK2oTwgC65ey6h/dT9axkWd1iigzO66iBpiP7RVEZyUW/uvodMCwZHlRvRlUs/KTFjPi429BYfXMho4f+2Wi/2PeKjoPPuCuTGrvoQSITx+/yawzsT2RcH6EGefPUp+bW9tIeqidiuX7r7DmKRrY+I2A3E9zB3hwgGudGkw3DwXiE31XX2XnewL5zsSgd/mbehQae41QZKg/NUTmwrB6cQ88KNjuHwplQW9A5sc/N+JFtbUr9GLWje5lkk/6FVJ2oNq76hufoLpfSW7JLt+jcIQqCJ5n3wnk0P50uLXu6oDqeSfRiD8uW6JVsN8KRGWtBUeM7jJQ== Received: from DM6PR03CA0011.namprd03.prod.outlook.com (2603:10b6:5:40::24) by SN7PR12MB6984.namprd12.prod.outlook.com (2603:10b6:806:260::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 13:11:44 +0000 Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:5:40:cafe::e6) by DM6PR03CA0011.outlook.office365.com (2603:10b6:5:40::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Tue, 16 Jul 2024 13:11:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 13:11:44 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:28 -0700 Received: from dev-r-vrt-156.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:26 -0700 From: Danielle Ratson To: CC: , , Ido Schimmel , Danielle Ratson Subject: [PATCH ethtool-next 1/4] cmis: Print active and inactive firmware versions Date: Tue, 16 Jul 2024 16:11:09 +0300 Message-ID: <20240716131112.2634572-2-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716131112.2634572-1-danieller@nvidia.com> References: <20240716131112.2634572-1-danieller@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017094:EE_|SN7PR12MB6984:EE_ X-MS-Office365-Filtering-Correlation-Id: 78727eed-f65c-4be5-230d-08dca598d72c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: 707k0QyVX38sUyzk9cQwmkM9dxiF4/Y6XPli79Pk/c1SXI96ACqs6nJx6kUZRWVrX4yKMuWtxdInmOEZldO+mrl9ZdrHBzMyjFntS7EyCieWju5c6a+p0KjqDxJVOUxDyVjWM8TaIVPayAxd8aBiflQnILvgAJ6HNwIpx2qCLW/c1ybV6hNQkX4Ekfzuf7cnSm1VjsTKgu1CNQlaUp3iCTBqz8o3q/JLMBqdVIRkoHmzkvkD4cgVYLPU2deqQjqJHWFpxIzpP1U4lLAypqjKp9sHDYckwmRKMuhooz24jOkwAD76/RFvAsqmSRwgp5YfokErlXvOSjJV8O409gV9p1r/z3AbYPDLxqJS4QcESKzmq+j0Kx4w/6ALrQ4r6J0V4nxxyEU+KzTjmAp1tjudcDn1W04wWuA/37aVfDJyrjiineyyKw+dA73IlmOu8qM5y9Y5TRBjAMFNhU5nJ7LeRWMaepsvCMvDQvTFCb/E7srwyO+Df2liih0zzsQ1s2gUPGo3YyoaVmnAp8Fc/tZq9jnibVCLwSHh1DzsK/NayN6tR2NS44yjxAhSq141NUQnC+DOWa7vxQDF0WHOKH04b9TA9BO4WHNAiC2NO8qNVzazpLTlXS5FewIhvql03zzQ6vKL0dx3zz1FKhNLihFoD7lBpqNiHM/udMq6IjjpEPivA42Ym0/fymJqnxTkkd11tkMwItM3qtIkDvKULf8sOBMzkPu8qD/FePdHdOXPR5rMqpFlHc236USgc973KfKq5wQWaHXflhDj5OhB8Gy4x/R++bQ/NQrZDVvW4IgLKCaNInhN2EkH05RxRG2/XU7NUOrlsuhvZXJePc3HOKu/0dQO+l7aHmlyWIvlV0al4rH3bNBizOO/jKQ5yPecnZswQZroKPU/G00D3sNj1Sq9pa4u4USo6pHftRolgo/9zjO4/BtD0WrY5m8uWHLe+7Cpo8bk82MouuiB6cEd0h8ujVF35s6lsyMErdBw32C4xr9lKi7byXnEJXU/qlkJ0WB3N+EAGnoPrhImIwY3NUgFs1NwHkYU0TJ2+Lbeg7ivBBvjOvL/oRCB5RSDfC5i66qJydCnjmiob70//1mL0dPACRZf9Ztzg5hiNkfGbB1JXK1S8I0sCrAgxUpy+cYczwKitivoceRElwU3lh4T3e3bvkTh7R3RSK/sARVjcyLnKIrbGBy9PL3miySIToUnPbRweZ0WvtbYN8DdEiFGIesOGXlRUk5WtuWC9Erz+2EL55wP2XtUrtoiKFc3VTzLeh8Nh5Itcw0e8ZrKCMA8sw9ZjnYuvzFBFzmfN6H2c0WoJA3TcBSuzL1zvlpd4scM/CJ5uB5GfUCZtDMBzCQQv6QlW3NNQcdZXHzwhBGkWoJu8eCoa4zd15mwS3VicRaFRufsf/MSSSPTG72fT9V7t+MXOh6uphyzM0zFP0p6K23l6zg= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 13:11:44.2123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78727eed-f65c-4be5-230d-08dca598d72c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6984 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz From: Ido Schimmel Parse and print the active and inactive firmware versions from the CMIS EEPROM dump. Example output: # ethtool -m swp23 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) [...] Active firmware version : 2.6 Inactive firmware version : 2.7 Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Signed-off-by: Danielle Ratson --- cmis.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ cmis.h | 8 ++++++++ 2 files changed, 53 insertions(+) diff --git a/cmis.c b/cmis.c index 531932e..bbbbb47 100644 --- a/cmis.c +++ b/cmis.c @@ -884,6 +884,50 @@ static void cmis_show_dom(const struct cmis_memory_map *map) sff_show_thresholds(sd); } +/* Print active and inactive firmware versions. Relevant documents: + * [1] CMIS Rev. 5, page 115, section 8.2.9, Table 8-14 + * [2] CMIS Rev. 5, page 127, section 8.4.1, Table 8-37 + */ +static void cmis_show_fw_version_common(const char *name, __u8 major, + __u8 minor) +{ + if (major == 0 && minor == 0) { + return; + } else if (major == 0xFF && minor == 0xFF) { + printf("\t%-41s : Invalid\n", name); + return; + } + + printf("\t%-41s : %d.%d\n", name, major, minor); +} + +static void cmis_show_fw_active_version(const struct cmis_memory_map *map) +{ + __u8 major = map->lower_memory[CMIS_MODULE_ACTIVE_FW_MAJOR_OFFSET]; + __u8 minor = map->lower_memory[CMIS_MODULE_ACTIVE_FW_MINOR_OFFSET]; + + cmis_show_fw_version_common("Active firmware version", major, minor); +} + +static void cmis_show_fw_inactive_version(const struct cmis_memory_map *map) +{ + __u8 major; + __u8 minor; + + if (!map->page_01h) + return; + + major = map->page_01h[CMIS_MODULE_INACTIVE_FW_MAJOR_OFFSET]; + minor = map->page_01h[CMIS_MODULE_INACTIVE_FW_MINOR_OFFSET]; + cmis_show_fw_version_common("Inactive firmware version", major, minor); +} + +static void cmis_show_fw_version(const struct cmis_memory_map *map) +{ + cmis_show_fw_active_version(map); + cmis_show_fw_inactive_version(map); +} + static void cmis_show_all_common(const struct cmis_memory_map *map) { cmis_show_identifier(map); @@ -900,6 +944,7 @@ static void cmis_show_all_common(const struct cmis_memory_map *map) cmis_show_mod_fault_cause(map); cmis_show_mod_lvl_controls(map); cmis_show_dom(map); + cmis_show_fw_version(map); } static void cmis_memory_map_init_buf(struct cmis_memory_map *map, diff --git a/cmis.h b/cmis.h index 8d66f92..3015c54 100644 --- a/cmis.h +++ b/cmis.h @@ -41,6 +41,10 @@ #define CMIS_LOW_PWR_ALLOW_REQUEST_HW_MASK 0x40 #define CMIS_LOW_PWR_REQUEST_SW_MASK 0x10 +/* Module Active Firmware Version (Page 0) */ +#define CMIS_MODULE_ACTIVE_FW_MAJOR_OFFSET 0x27 +#define CMIS_MODULE_ACTIVE_FW_MINOR_OFFSET 0x28 + /* Module Fault Information (Page 0) */ #define CMIS_MODULE_FAULT_OFFSET 0x29 #define CMIS_MODULE_FAULT_NO_FAULT 0x00 @@ -134,6 +138,10 @@ * GlobalOffset = 2 * 0x80 + LocalOffset */ +/* Module Inactive Firmware Version (Page 1) */ +#define CMIS_MODULE_INACTIVE_FW_MAJOR_OFFSET 0x80 +#define CMIS_MODULE_INACTIVE_FW_MINOR_OFFSET 0x81 + /* Supported Link Length (Page 1) */ #define CMIS_SMF_LEN_OFFSET 0x84 #define CMIS_OM5_LEN_OFFSET 0x85 From patchwork Tue Jul 16 13:11:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13734529 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BB1919AD5B for ; Tue, 16 Jul 2024 13:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135516; cv=fail; b=WsXmDl61mMhHLLkW3Ji43AxvMkYFwkdfBmEvpvB5F3/05AmGwH10bs0Wikf7mDRL2P6r77xhAb/WBY1BDLuPxLrCkEwGGXTEqMrvaq5e3qThpLXL2BMzzC2mYHfEbWdC9TRm0E5PWK3gktykmz4ni7MzIVoPlHqoDW5ihl5j/5A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135516; c=relaxed/simple; bh=ypvifXDD6K+3EHUJ6OuNtvvPC7HxBCEQ0quwT1CtscE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eUg0gh/zufxCSnmnAPLxfehPCjWdx1zvGfVoT5CdNrPR8FoZPVYJZCUw1Dl4EvFyVzwxRRphoM4ATDFdpgdcAgu3EsHUVwzT3cXzFQWj4J5qT5kKe9vSEX0olmUBB+vuasaplY6Gudv8hZwEcyo39IoOavkOEF6p5WgepKQxbcE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=pUeOQinQ; arc=fail smtp.client-ip=40.107.223.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="pUeOQinQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B5kzfQWOk9Se6n7rfy38qBjXup7f4GqaFnGgfEbbpkmRpFuKPFrcXDNLuik/zkul9zW241FoGmtky7UMKu3GpJ9yqUoAXwvSLharlrKLI3mLhsUg32J3f5aZjfvAqnsffmLLvcoh+srCBAufuyv9natgQSgPQte89oPhA+ihQ+ZZRcVNYrtzOICMxvPgYacRX5XLzhUqylSjMxHdZzm4yl4XKZ/TbmhgfBe+qBfj7vHD9j4DieVC3Q2WRD5IOGAp1NSrxWNJRpqY27i2LtBjwQppbwkkI7uFlr20tJGEbVeTRxlNwvY7sQvH/ltwR5UtTIUWJvO2HCv6uTbr0KBjpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=8DICkl5y956lOBp5s5ApQVIfhzAOcm+r59oMg5hEwjE=; b=czwT/CMconmPwCD5JNHAXKpFgKviRvQpuw4MMfVXPf7aWThW4kNzT2yY1Mlp9aL9HF6SF+dw08I+LQ6rXUDu1K4F4obanymf/82VvxkLGfvRJPySobtJu2R0fqrCrv75OMXB+F5mPqj31ToaDZ01Kes6geveqVL78Jcgwk/VVJ6vZ/d/zHWML5cZtZPKyc1quYlXv3qqOkH5Fm/cjhrtWLHaD2TMnbBmJXY65J1Xam1oWYXQKVii6R7nHXnyQbOM68D+H6oViZCuD4aADmm/6nCLxYXPnBMFuCqM089c+SN1CHfLuJNss65j+5jbvXYaJsodAcw+9mObynstIfBzpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8DICkl5y956lOBp5s5ApQVIfhzAOcm+r59oMg5hEwjE=; b=pUeOQinQwdqFhi49Qvm1wdvHv2JRlU6ni2RVaCBjN/CxhOpiOS+CRr4qQm5Uze12eYkh32rnCv5po3VwTjuPYyEd6qPkPnQCIm4y1R3KhZVtmlzh/jAwuIiiFOro7r1KUaZQ9YRiMqaXsIoWkXLJeCdWf24/W775BUl9EjqnOMdC6zjOBhn1LB4FuNfEsU9jK8twO1DNI2eqXCxikY5Zj6Ogd2fxsIZNZgYbLAwykLqqeOfBTXMk3bCJ/FytaWz5bfFsRgY1dQFUSGLzAK/clrINhy/4/2LNMgejUxioPb3i5sBbT9aSrdIay5qYM96Jyb9FFur7hw+A45OWqhrWHQ== Received: from DM6PR03CA0009.namprd03.prod.outlook.com (2603:10b6:5:40::22) by IA1PR12MB7638.namprd12.prod.outlook.com (2603:10b6:208:426::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 13:11:47 +0000 Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:5:40:cafe::6e) by DM6PR03CA0009.outlook.office365.com (2603:10b6:5:40::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28 via Frontend Transport; Tue, 16 Jul 2024 13:11:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 13:11:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:31 -0700 Received: from dev-r-vrt-156.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:28 -0700 From: Danielle Ratson To: CC: , , Ido Schimmel , Danielle Ratson Subject: [PATCH ethtool-next 2/4] cmis: Print CDB messaging support advertisement Date: Tue, 16 Jul 2024 16:11:10 +0300 Message-ID: <20240716131112.2634572-3-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716131112.2634572-1-danieller@nvidia.com> References: <20240716131112.2634572-1-danieller@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017094:EE_|IA1PR12MB7638:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e025253-ee89-4613-b2c6-08dca598d85f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: cPxb2HX91U17Jt3336esX4+ZGuK8cDGrg85QNFfByUembpnty2dHj/so05m4xfGfybxTJfffo92JRHRt/2Ct2YNEjU/SB1dhmdu84b89Yy7WRZhVx7+zWQ+CZUPf/50mh2ObHOA8KfVquSu7UAwh6EHfgVM2bK3H+/qVzGS05SSblc/wPHKimmWmn7aGiZTAojWvXU5FZhW/2Wy/PuUl9Nl/p97dBz1ihjL8F6OUlShfu1M6sE5clWc0iWE2vCsWkTiL+Ak8dkRixO7YGiv5bTFCRMkRWcHn6kROoIpaWKueg2TNgtdbPE0JvGZPPgJwcx2kX54RnN2mWKja2vNQqXXYdtnBTh4K2Nebm3s10bE3Q+oa5mcfKnUNB0gmAioSV8uLgiBptSSP7TNftqbUvNrK8itVD0KUVMSWW61HaSX5ADJzOTJslz/UXfUf761raWFPhIcB0vaNG6xOU3yt2w/B6cZSPpMCK6yzv8u2iljTJw2zSyfozMeW7g8fU4YhSlOKhmwKPHj1teUIty5Qf3em3PrDaYWkgAtr+rLWe9Z1+rvy63NRrO2FUU5sanZx2LRY40imY7MqRd2TwRXmJgMV+lPhOa5PdzHNiFblmF8va0+PrBtQQVcRLc0oIS6jq/n9u07T56sNxTWbMNzUDUfq8O8CsshuijreSOXJhgbKZGu7rZaSlWOQ+CdYbIEGkOJW7qD3OAKErN0Z0s17vOea66KCbyTJmEaU1JsVJJxP432hSo9ihLJQFLGTkulo2Ow9yYm5ff4yEHXP7WggUHBumlT/0mKY2JglBa8jqCSa4ltS2AWqhW145DDldm8cRZi41s6uxiqLOwkQfxlGO0FnVqBJIm2WFemrZNggtz3g+5PrfUb+WByjFeVEw5X81+d7AN/ypywIAwHlcl7tFB4LzS4kJsbdCrDuhLadJ+R0MAyvfduO3nyzz6Yv9SdClZDat+TWV4izXGRp51T9DpbcOp5WZfz6wVdgzpRq05D4zFuv48by7DOPgVmJ4bphyet64W9QWS3F0GEmNmhtPcBnDOxjUla/ibj3Rqds0jSkzp8xw+3BoxKoNuoRa6QA2t/duw6c1nvQ/4v4QBHagZbJdke5kDV+A/TLDCCx6isF4aLVhDclbvp63A5rqoqjZCNFNuey2Tjr/hlOcSX9z3AIN2iPZ+IBOTysuaAOuzQ1u3pIIEaHlTQO7dveoKKcQszLcN5hQY56XaYFxfbki0Opqkuych083eBp16nGyjuWPGauPJRsiCKLFYFtzTs/oGKxCdy9QyAYV1FNbfjvBYYWsgsMvIjkwstxgCJ/6vXSffPKM8Nqj69hLtpRid9Nwvg5lGJS1Y/ePsyMjWTF091QRCufwx6V6zZtadohIUsofKfICBWtcqou+1us73tgtCbRbbdSsjXb/44w6FWEIPsSunxRiFwHy/XuBBgUHkZ39P6YfacXfgvD51DFhx5u X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 13:11:46.2280 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e025253-ee89-4613-b2c6-08dca598d85f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7638 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz From: Ido Schimmel Parse and print CDB messaging support advertisement information to aid in debugging CDB related problems. Example output: # ethtool -m swp23 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) [...] CDB instances : 1 CDB background mode : Supported CDB EPL pages : 0 CDB Maximum EPL RW length : 128 CDB Maximum LPL RW length : 128 CDB trigger method : Single write Fields that are not used by the CDB code in the kernel are not printed, but can be added in the future, when needed. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Signed-off-by: Danielle Ratson --- cmis.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmis.h | 11 ++++++++ 2 files changed, 91 insertions(+) diff --git a/cmis.c b/cmis.c index bbbbb47..6fe5dfb 100644 --- a/cmis.c +++ b/cmis.c @@ -928,6 +928,85 @@ static void cmis_show_fw_version(const struct cmis_memory_map *map) cmis_show_fw_inactive_version(map); } +static u8 cmis_cdb_instances_get(const struct cmis_memory_map *map) +{ + return (map->page_01h[CMIS_CDB_ADVER_OFFSET] & + CMIS_CDB_ADVER_INSTANCES_MASK) >> 6; +} + +static bool cmis_cdb_is_supported(const struct cmis_memory_map *map) +{ + __u8 cdb_instances = cmis_cdb_instances_get(map); + + /* Up to two CDB instances are supported. */ + return cdb_instances == 1 || cdb_instances == 2; +} + +static void cmis_show_cdb_instances(const struct cmis_memory_map *map) +{ + __u8 cdb_instances = cmis_cdb_instances_get(map); + + printf("\t%-41s : %u\n", "CDB instances", cdb_instances); +} + +static void cmis_show_cdb_mode(const struct cmis_memory_map *map) +{ + __u8 mode = map->page_01h[CMIS_CDB_ADVER_OFFSET] & + CMIS_CDB_ADVER_MODE_MASK; + + printf("\t%-41s : %s\n", "CDB background mode", + mode ? "Supported" : "Not supported"); +} + +static void cmis_show_cdb_epl_pages(const struct cmis_memory_map *map) +{ + __u8 epl_pages = map->page_01h[CMIS_CDB_ADVER_OFFSET] & + CMIS_CDB_ADVER_EPL_MASK; + + printf("\t%-41s : %u\n", "CDB EPL pages", epl_pages); +} + +static void cmis_show_cdb_rw_len(const struct cmis_memory_map *map) +{ + __u16 rw_len = map->page_01h[CMIS_CDB_ADVER_RW_LEN_OFFSET]; + + /* Maximum read / write length for CDB EPL pages and the LPL page in + * units of 8 bytes, in addition to the minimum 8 bytes. + */ + rw_len = (rw_len + 1) * 8; + printf("\t%-41s : %u\n", "CDB Maximum EPL RW length", rw_len); + printf("\t%-41s : %u\n", "CDB Maximum LPL RW length", + rw_len > CMIS_PAGE_SIZE ? CMIS_PAGE_SIZE : rw_len); +} + +static void cmis_show_cdb_trigger(const struct cmis_memory_map *map) +{ + __u8 trigger = map->page_01h[CMIS_CDB_ADVER_TRIGGER_OFFSET] & + CMIS_CDB_ADVER_TRIGGER_MASK; + + /* Whether a CDB command can be triggered in a single write to the LPL + * page, or by multiple writes ending with the writing of the CDB + * Command Code (CMDID). + */ + printf("\t%-41s : %s\n", "CDB trigger method", + trigger ? "Single write" : "Multiple writes"); +} + +/* Print CDB messaging support advertisement. Relevant documents: + * [1] CMIS Rev. 5, page 133, section 8.4.11 + */ +static void cmis_show_cdb_adver(const struct cmis_memory_map *map) +{ + if (!map->page_01h || !cmis_cdb_is_supported(map)) + return; + + cmis_show_cdb_instances(map); + cmis_show_cdb_mode(map); + cmis_show_cdb_epl_pages(map); + cmis_show_cdb_rw_len(map); + cmis_show_cdb_trigger(map); +} + static void cmis_show_all_common(const struct cmis_memory_map *map) { cmis_show_identifier(map); @@ -945,6 +1024,7 @@ static void cmis_show_all_common(const struct cmis_memory_map *map) cmis_show_mod_lvl_controls(map); cmis_show_dom(map); cmis_show_fw_version(map); + cmis_show_cdb_adver(map); } static void cmis_memory_map_init_buf(struct cmis_memory_map *map, diff --git a/cmis.h b/cmis.h index 3015c54..cee2a38 100644 --- a/cmis.h +++ b/cmis.h @@ -191,6 +191,17 @@ #define CMIS_SIG_INTEG_TX_OFFSET 0xA1 #define CMIS_SIG_INTEG_RX_OFFSET 0xA2 +/* CDB Messaging Support Advertisement */ +#define CMIS_CDB_ADVER_OFFSET 0xA3 +#define CMIS_CDB_ADVER_INSTANCES_MASK 0xC0 +#define CMIS_CDB_ADVER_MODE_MASK 0x20 +#define CMIS_CDB_ADVER_EPL_MASK 0x0F + +#define CMIS_CDB_ADVER_RW_LEN_OFFSET 0xA4 + +#define CMIS_CDB_ADVER_TRIGGER_OFFSET 0xA5 +#define CMIS_CDB_ADVER_TRIGGER_MASK 0x80 + /*----------------------------------------------------------------------- * Upper Memory Page 0x02: Optional Page that informs about module-defined * thresholds for module-level and lane-specific threshold crossing monitors. From patchwork Tue Jul 16 13:11:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13734528 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFFB119AD4B for ; Tue, 16 Jul 2024 13:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135515; cv=fail; b=XoPmhs4O8xj9vBzOoymGTtsHpihYOBByI27+YSPu3kq+TSd7uXNiWg6dBsJe6gtlFeAh6w1zKSAmtgNiC/mr98FgXw5PckcM3wDpieAsisLaQ8qkBcneu93QmdIfQk9MubxT5Z4uFsriLGkllgEnzUFtUNQbFKhNeORc60YH+qI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135515; c=relaxed/simple; bh=+PCRIAMLhysGncRwfOkklAdcYGtvaZ831x/lbhUBR+U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hwac537YPWu1WALz8HI9l/l3g+QB/XdeBMMgSIIObPZxCAVmBnkv/Kg7ymaR12SnLkFzlTVgCmn1rVb+buJnKmFoluk7jm1sqqX4SasI+UIMddRExUsDI2e6bzIh4VnVo/7AuD7ZJM1sf0U+tIiSLI0r7IVK8fSpU8/ngkofPNc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=FQ/RHuZN; arc=fail smtp.client-ip=40.107.92.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="FQ/RHuZN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MP2A1D6Ljo7E5530wh08liAoGqxG02iwiW/Y7BrOkDGXzHH3oWUED14/XA07YNgkAzaSs8zGogKBxopt/xFfT3+0udIK3hrhiBPokkOSHr0rYn2odOr2YJJ7aDgONGDow5a/iiE6AHfF/zu7gKt6Bn1WftbixoKnNQGi9e4oIJ0spuW/rTVvO6QcgZiIrsqJzSL/p6QXQJYt33anSw5n7wdKAs+VRBlEGpxOuRCh8w0/oQJyEC9BO/XS7y+UxsMWAIc/Yw89NxejGqkUxJhb7qt/X8y3Hbi6tmR18RzgJDTuuG4tYQzucrDUrGuKoufL7k5eJ0D/sjs++G3wo8m8PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=KNkh8cGT2Vyjkk4zzsHP0gkgH4cjzDS4xIwkoN4u+Ro=; b=Z6qQAR1BPiK39XzfsFujdMTnolDQiS2IMnKRzdfUnCZ0xMDyzxUUhQUPv91GKhbRAj6wYYMiv9EyuYnu9erR1KJCC+CDNKoAcBE7pRhMi5ICV+yNEkkcWtRLftRC2igdbO4LbqyqR6sVxmwi0XBdw7br1utXfjFyqRquencv4vsh11HehURVHNLF0w8jKYzHcGu4FhevJ/EY3gindbewMjN6OCEyE/l5049wLcPFIuCgKSiv3ylh0u3UI2irMRfo9KJL1vDEa3K+OSGDMBtuj+6mvcVk9rQ9/INetmrWtI6w/O1FyDIra6BWcKYALt0GginB4qDKttb+pATbo2tmHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KNkh8cGT2Vyjkk4zzsHP0gkgH4cjzDS4xIwkoN4u+Ro=; b=FQ/RHuZNHhY8OLdQnnVzheAyj7XVlXZMlBVV+lWQ+P7BlML1Pclip1SwsfByMSOm0WzUZ3QYmx+4VCJgsRt1zThmrXO1X7bEb6BxUsWO8kH4gB6N/wrQEpN5lSOg5c/Y2W0VCZIsnnlz2AzML86ZUVrhj7uL1r0PU1GkVIznho8OTLtURuwYhI6E5bUFH7L6muhRcFzavP2lytMTK9J8p6AsobwDokBxRNs6x9Af/GPKop39jjXE+rvZtTSWV4cUNgBpa4VQ294/Gk78CtCN3piT0qxx4jU2iBT+lgSS9P2grjs4Vik+QTXnSkd43/q8JUdpfE4sF8erNZ+gokQYcw== Received: from DM6PR05CA0042.namprd05.prod.outlook.com (2603:10b6:5:335::11) by IA1PR12MB6185.namprd12.prod.outlook.com (2603:10b6:208:3e7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Tue, 16 Jul 2024 13:11:49 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:5:335:cafe::ea) by DM6PR05CA0042.outlook.office365.com (2603:10b6:5:335::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14 via Frontend Transport; Tue, 16 Jul 2024 13:11:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 13:11:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:33 -0700 Received: from dev-r-vrt-156.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:31 -0700 From: Danielle Ratson To: CC: , , Danielle Ratson Subject: [PATCH ethtool-next 3/4] Update UAPI header copies Date: Tue, 16 Jul 2024 16:11:11 +0300 Message-ID: <20240716131112.2634572-4-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716131112.2634572-1-danieller@nvidia.com> References: <20240716131112.2634572-1-danieller@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC1:EE_|IA1PR12MB6185:EE_ X-MS-Office365-Filtering-Correlation-Id: 39ed7594-10bd-4b4a-c9b2-08dca598da0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: oaJJUTDiBM7octRh+PmDJpcEOagbpPl2ydfTXNfTR0cwKfpBcp2Eek+7pH5uREVDy/Dbd4KjcXsOAGtEI/fs491uKRe7en7gN648EitIunAvb7nTVGX4YJccz5g6/ejbUcpR71ag0GwmwqOzi/f+RkFd/vjlYZqu662lAEFDLlEC2F8q13+xDZD8m0zFW3qdFxbJNr9oB2P2XfRrB/aTCqquhBelU2ag4V2GyN3O1VMOyufSMlyPqfGLzXjEVk4QkS27yGO467KOpI/COiObWu9n5DsYu+sK6FSrrvmUBSXP8PsMycmo3aO8Krgh5qZrUxrDim3/DGA9pWQJSOxyNl/8TmmWM9g7MX2gJRdQEq1Lvv0GUEzIJGq2FbZNv6N7P0e0Dl1+xOkupIaxi9UUVcJlXf4rQ6OLzdnt26cQC1LQSK3lhzotCaXCqQF87QY2o/v9oJL5g6QYqWBvTFACCiNQKsbvmYmRPNihoaF3UA671UhGR6i3sCytfz4VYheTkqUBywELg+h+Gnsv+Nkzu4aN67vaXs/JMibBl2olZpAc9S3dyx4GHdotfsoVOVRY/YKlIDvmIhNRl30JHOsxeDs1dksSHcXmWbSd6sHJr+9sAShwmCN7s/26+PeD4kMCxU6bW7R340I/igJFbh3eK6LdaeHtKK+iCl5y3nCaaGB3gmB3B8l25DgRtRRV6Km/Q9Ykw6IC4rLXtl9NUQngZ2Ia789Cs63Ze6/CXSyN5G/CDhXYiwwiGzvavXtxgzYLX6GYlfI5OrkSfcuKEBMymIJMGcBf/rwpFskZxPS7MGSgQ1UVoqr7J8Q2a5wNQU/nKG3P5suHHQiONNIlELC3xsWGMVTEiSimnzzbzSfh50jpwhygFF9Mky2MuUPhgtS1xU2EugQ4Yo8u6yuPebAIuU9SUARrzfAJQ3aNULvkNEQJfZhqSKdkeLE5UOyWSqEn/VmODEsQpLZlLlm9w2E3M/J1NlMsIiue46/58CmX+jOmp+LEJ0BL/+0QPZA+cGPz+/his4U9eCRbDQCgn3Ig1zdgHw0HUrb/vZnQHz0UiCMls+xPt7ztVx3LKO+b2gCHguh5gSsINufld18h72apSytgcDhmGZlTKiwRWOwk74KXUmapr9KgjfoW6RbtiZAvdC4iy0YQMrFJsZJSlRo8MAPvszTJbT5H3w7694MjapALL7IKXXHtlZcBmk/SRZvgDnxXE9dzckSuulCO3B5aI3kFhPUG2ht+EICroB1qFWe8iZcfc340gj7TtJ4XXQog0XuCYVAMXhjrnvjuMirP8531GXZ/I1GFgDhSR9u8O98OHwn5QQkV7WHHegajs5RgBCug9JTU0wTmaARX73yOP3qIqC2g3c4G5bucyOFEynfUr4CQren1TGJIXkAYSJ6BSVohtSFs5g+wOyljr+kEkszR5pGpTKggqOiIGY6paB0Lz4cgBcDt/YvO7ajyWooD X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 13:11:49.0844 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39ed7594-10bd-4b4a-c9b2-08dca598da0e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6185 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Update to kernel commit 46fb3ba95b93. Signed-off-by: Danielle Ratson --- uapi/linux/ethtool.h | 18 ++++++++++++++++++ uapi/linux/ethtool_netlink.h | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/uapi/linux/ethtool.h b/uapi/linux/ethtool.h index bcec30c..d6e3652 100644 --- a/uapi/linux/ethtool.h +++ b/uapi/linux/ethtool.h @@ -875,6 +875,24 @@ enum ethtool_mm_verify_status { ETHTOOL_MM_VERIFY_STATUS_DISABLED, }; +/** + * enum ethtool_module_fw_flash_status - plug-in module firmware flashing status + * @ETHTOOL_MODULE_FW_FLASH_STATUS_STARTED: The firmware flashing process has + * started. + * @ETHTOOL_MODULE_FW_FLASH_STATUS_IN_PROGRESS: The firmware flashing process + * is in progress. + * @ETHTOOL_MODULE_FW_FLASH_STATUS_COMPLETED: The firmware flashing process was + * completed successfully. + * @ETHTOOL_MODULE_FW_FLASH_STATUS_ERROR: The firmware flashing process was + * stopped due to an error. + */ +enum ethtool_module_fw_flash_status { + ETHTOOL_MODULE_FW_FLASH_STATUS_STARTED = 1, + ETHTOOL_MODULE_FW_FLASH_STATUS_IN_PROGRESS, + ETHTOOL_MODULE_FW_FLASH_STATUS_COMPLETED, + ETHTOOL_MODULE_FW_FLASH_STATUS_ERROR, +}; + /** * struct ethtool_gstrings - string set for data tagging * @cmd: Command number = %ETHTOOL_GSTRINGS diff --git a/uapi/linux/ethtool_netlink.h b/uapi/linux/ethtool_netlink.h index c0be6e5..61af33b 100644 --- a/uapi/linux/ethtool_netlink.h +++ b/uapi/linux/ethtool_netlink.h @@ -57,6 +57,7 @@ enum { ETHTOOL_MSG_PLCA_GET_STATUS, ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET, + ETHTOOL_MSG_MODULE_FW_FLASH_ACT, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -109,6 +110,7 @@ enum { ETHTOOL_MSG_PLCA_NTF, ETHTOOL_MSG_MM_GET_REPLY, ETHTOOL_MSG_MM_NTF, + ETHTOOL_MSG_MODULE_FW_FLASH_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -996,6 +998,23 @@ enum { ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) }; +/* MODULE_FW_FLASH */ + +enum { + ETHTOOL_A_MODULE_FW_FLASH_UNSPEC, + ETHTOOL_A_MODULE_FW_FLASH_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME, /* string */ + ETHTOOL_A_MODULE_FW_FLASH_PASS, /* u32 */ + ETHTOOL_A_MODULE_FW_FLASH_STATUS, /* u32 */ + ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG, /* string */ + ETHTOOL_A_MODULE_FW_FLASH_DONE, /* uint */ + ETHTOOL_A_MODULE_FW_FLASH_TOTAL, /* uint */ + + /* add new constants above here */ + __ETHTOOL_A_MODULE_FW_FLASH_CNT, + ETHTOOL_A_MODULE_FW_FLASH_MAX = (__ETHTOOL_A_MODULE_FW_FLASH_CNT - 1) +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 From patchwork Tue Jul 16 13:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13734530 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EEBB145345 for ; Tue, 16 Jul 2024 13:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135517; cv=fail; b=JDJlRHhx2obKXVZ49ugpC+/Foq4v0wO3q4P8sFAHJkMic0jh9eTgE0GyiqRkykrKTpsNYPkavrWtroTFt/tkngtZmxsU3tfkAolI6Ooaaypw0kplxJquwcWmqImsNHbCZeqrjBHPB52DGmDue/7w3RV4b6xlCKXCccLWdw8C7h8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721135517; c=relaxed/simple; bh=9acZI5c+p1CFQhEYlQdJ7P/r+80QzzDvDUmVquiD5e4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AIs72XrBDg56w2tFlGMaDkmkd5baotjkSAK7HFSMMlevmOh883el2sipKLbt2korpxtMA+lejiLImevJNVS1Xi4D9D2yBuLI2Et0VQGCbtioEzqC/JZFpuTnBpYDmZ2nYtvG7go+p/BJqfo4+AEYHvLpQEORcOU6OFupuDbDkDA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=PAUn7uJ7; arc=fail smtp.client-ip=40.107.244.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="PAUn7uJ7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GIIu7CBYYgHpoCNDnZ74mNpyOQTkjWZnBKNeL1bWV5jD1tcu97QNA8ZP+9b+sF+MpWKseia1e74Ol/uH+8TfhhIQSb3OCn/m5O0AvJD2ShHndXRrqxsrI+e64dqXZW8Q2jQsm3VIVFCj75ziLuKXrXWwgkQMTJ1+nm/337y/8m5OQsROp4AIpH/LYCrP9+cpfkKLisuBqCcjwqVOGMWOq0IGh8guZqQG/5FNbaTuHeVyIt+LkI1ZsU3GA5M3/zzo/mpUqMqmuqi0YmeRS37DW2AGJd7bzP5lJAGRkfcZDyUOwBRlgTTK3U64dbK+8CH1A25Cxco+5KpJMwdCdjoa4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+qp0NySkWdIosViXMhdc24bw1Nvo6HoW3U1QtLoXnkg=; b=De/iyNlxAOAUMjPR5TAYqHlDFAMyLdalFDqPNokuU65dLeVgKpvkvHBA+SeSsO6MfG4Bd1tw22t5Ii601u7lJbuGXa2o7f2QWfY4DnOuB8iLwvVauNlo4cMmwCw5SeNPPt2AZF0DQhTpbxi5WgbHjkqfdG6U+I3FPcdqRtxDi6MFbmGmmMIDGkEAp0b/UXQ4ixQ7dJvTg/R4fhBzEOAp8LPOSgRR0JQKqrP22E93ssMn6Cyh4JCj0EyRshiFnKFLiNRDy/mc3bCy/lIRBhlwutsir9k/fgAQaydeQAzCj3WRqh7gjlf/VRUH/W3NesPN8DW0xv7NFUSliWXFgRRrtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+qp0NySkWdIosViXMhdc24bw1Nvo6HoW3U1QtLoXnkg=; b=PAUn7uJ75bkpySR869aW2PDmqhOJsswVI4jo7Y52nRGp4RY2sK3HtCKVIi0dm/YgOfbASvnubOJC5yxcLOiUiZyMCtGX0flZNhFAAU/eWK7H6h6uronCEipDJ/vSF51gzX/DEAjiPoHB2pk885EiYd4q1Ea3xRJuFZW6nT5gJnFK9y0hgTnNuGHy1y2TUyaH/ztqfuFTESIAfKM7rY7frTbHn30p6ZDq62g52vZp+WSTAf+5Bsxdlhlh7XbR2PT0C6Anm2SW1lkoXD9T9Wh8EvDCef3RQeCb37Zld872KZo09C9OWi9B5y+40NTF1yI7QP+/GCWOJY9MiQxw+fUCfA== Received: from CH3P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::18) by DM4PR12MB6302.namprd12.prod.outlook.com (2603:10b6:8:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Tue, 16 Jul 2024 13:11:50 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:610:1e8:cafe::3f) by CH3P220CA0019.outlook.office365.com (2603:10b6:610:1e8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15 via Frontend Transport; Tue, 16 Jul 2024 13:11:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 13:11:50 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:35 -0700 Received: from dev-r-vrt-156.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 16 Jul 2024 06:11:33 -0700 From: Danielle Ratson To: CC: , , Danielle Ratson , Ido Schimmel Subject: [PATCH ethtool-next 4/4] ethtool: Add ability to flash transceiver modules' firmware Date: Tue, 16 Jul 2024 16:11:12 +0300 Message-ID: <20240716131112.2634572-5-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716131112.2634572-1-danieller@nvidia.com> References: <20240716131112.2634572-1-danieller@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|DM4PR12MB6302:EE_ X-MS-Office365-Filtering-Correlation-Id: b5b8cec6-8079-492a-558c-08dca598dab0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: hjAvPqzeX/2yu6FB3rhiBvaONS1f0d9+ULGF1jspcdeK9nptLpp1Vzuz9wmsFHysWJHZFViHnR8On2VNGT4WVErgsvcR8pdD3O3Q3hR0p1xBkzF5xT633mM+mABlmepuqYENFIH5nsV8xvamfcyj7vMcc5hSykGZTwZs8IfTE5+bPFpnDXsk7PkWW48qGG+QcUsutWFLxs6W1cg9iZ3B18CAxsOw37mH446cTuUTtt7QpIc/84qCxi6heUhYCHRAU7UB+q753LUaiG3yNz2AasA0kltY1pYumDX2AD/QO1pDxqQ8k/m8V4xtRZAoayK5nHggidZr9OgwJ0xBrvzIO+HC+0QgHFqTqXScePiAHYG+KFlG6GWYFsmZf1EZXoZQqLpn33p5ppvsR8XuYMYwOSYK3ylluXyNBrSyAZrtNL5kRB7R9H+N+f7ExR8hz6p/sMYJGOWqyUcKtxTuXnzHSghSnHv3P9lN6n/6XTqBQ1TM0C4Y7tnxUptsw+3Zzs1mLJTn4nMmevsQMdr6sJVbsMhhzb6o6E5RjDFese/JceEnPoLI+ghTIU0zSu/bWgkNKTdBd0j/R+/hS82xnUUSE3DW38rW8nqEc5NEbBuky+ps8AsWDh/RfzyJnFXmD5bXcq3F24ndaSxuoLZab6U79vtiERzCDHmv43nyKj7auaPJLqVSlmrY1Z4HYYnC5CqJH9+DyzY4PVA6odfjfVYxYAJtPvm/9vp4mESATnOozfNfal5c8jg9hHicc0CijtFJOQr/lkLTd8HtCx9UBADvSTZjG8mxr3rMl6EBt1CPR83AIacdODKzDJPs+Mr27KRuQTBo8+x3WK1TtEmhXViSql//zHk9xzxU257oCQnttAlJA73McLNZn4as87AJsHAEBnAmU9Wd/WhTqktvklw+ntXQ+gi30ID2jzCx8/VSiGPdvWJFJSEfa52AEBxojBm0eCnqCkXv1/kvxTK1aLLS+U3RzoS+iVWWYPvuT3OwWdEZ7jRvXHzfoagCVPTgxtrXydMSmxnR5E30z4gGw79+kG+ksmLN5dB7IJQxO68NpdA34TONupSmmjRsQcRlmoN3lI++DL6fwlwF3ZvXXGbzfcJfYwQArIDohiPmYgU+U58bzdMkYmL8kc2FxJppeVLQ7Ot00OPuLfcIYmfOT5zQGtJoIcnutnrCCcuqZCZLHt1cYXri+PxEmGgn4vHB2Xjy+I4wuHd+nGr3HdMaxktKSLlwSm0KyCBl/5HTt368lw2I42Uz4duVE/oivnA9pEb1SUKLB+2LNF6iRIkkg8//cwuD9fC5MbZsGRYowygD2l6/EYPoP9h6l5nZ+lJWyKEjB4ftqT41Y/pA3TihHLc5Xx7PcPYfTKEB08Sff238AEVndkxjwL9sZEL4J94ehm0F4Rv7P+Z0AX2Rly9/qPKm8Fy8XhSPcmoQU7v31vtIMSQ6vCA88P7PrwyzsRyNojno X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 13:11:50.1431 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5b8cec6-8079-492a-558c-08dca598dab0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6302 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Add ability to flash transceiver modules' firmware over netlink. Example output: # ethtool --flash-module-firmware eth0 file test.img Transceiver module firmware flashing started for device swp23 Transceiver module firmware flashing in progress for device swp23 Progress: 99% Transceiver module firmware flashing completed for device swp23 Co-developed-by: Ido Schimmel Signed-off-by: Ido Schimmel Signed-off-by: Danielle Ratson --- ethtool.8.in | 29 ++++++ ethtool.c | 7 ++ netlink/desc-ethtool.c | 13 +++ netlink/extapi.h | 2 + netlink/module.c | 183 ++++++++++++++++++++++++++++++++++ netlink/netlink.h | 16 +++ netlink/prettymsg.c | 5 + netlink/prettymsg.h | 2 + shell-completion/bash/ethtool | 27 +++++ 9 files changed, 284 insertions(+) diff --git a/ethtool.8.in b/ethtool.8.in index 8090f0f..bfcaca8 100644 --- a/ethtool.8.in +++ b/ethtool.8.in @@ -536,6 +536,13 @@ ethtool \- query or control network driver and hardware settings .I devname .RB [ podl\-pse\-admin\-control .BR enable | disable ] +.HP +.B ethtool \-\-flash\-module\-firmware +.I devname +.BI file +.IR FILE +.RB [ pass +.IR PASS ] . .\" Adjust lines (i.e. full justification) and hyphenate. .ad @@ -1772,6 +1779,28 @@ Set Power Sourcing Equipment (PSE) parameters. This parameter manages PoDL PSE Admin operations in accordance with the IEEE 802.3-2018 30.15.1.2.1 (acPoDLPSEAdminControl) specification. +.RE +.TP +.B \-\-flash\-module\-firmware +Flash the transceiver module's firmware. The firmware update process is +composed from three logical steps. Downloading a firmware image to the +transceiver module, running the image and committing the image so that it is +run upon reset. When flash command is given, the firmware update process is +performed in its entirety in that order. +.RS 4 +.TP +.BI file \ FILE +Specifies the filename of the transceiver module firmware image. The firmware +must first be installed in one of the directories where the kernel firmware +loader or firmware agent will look, such as /lib/firmware. The firmware image +is downloaded to the transceiver module, validated, run and committed. +.RE +.RS 4 +.TP +.BI pass \ PASS +Optional transceiver module password that might be required as part of the +transceiver module firmware update process. + .SH BUGS Not supported (in part or whole) on all network drivers. .SH AUTHOR diff --git a/ethtool.c b/ethtool.c index d85a57a..0a6a9f9 100644 --- a/ethtool.c +++ b/ethtool.c @@ -6218,6 +6218,13 @@ static const struct option args[] = { .xhelp = " [ podl-pse-admin-control enable|disable ]\n" " [ c33-pse-admin-control enable|disable ]\n" }, + { + .opts = "--flash-module-firmware", + .nlfunc = nl_flash_module_fw, + .help = "Flash transceiver module firmware", + .xhelp = " file FILE\n" + " [ pass PASS ]\n" + }, { .opts = "-h|--help", .no_dev = true, diff --git a/netlink/desc-ethtool.c b/netlink/desc-ethtool.c index 661de26..bd5cbc1 100644 --- a/netlink/desc-ethtool.c +++ b/netlink/desc-ethtool.c @@ -496,6 +496,17 @@ static const struct pretty_nla_desc __mm_desc[] = { NLATTR_DESC_NESTED(ETHTOOL_A_MM_STATS, mm_stat), }; +static const struct pretty_nla_desc __module_fw_flash_desc[] = { + NLATTR_DESC_INVALID(ETHTOOL_A_MODULE_FW_FLASH_UNSPEC), + NLATTR_DESC_NESTED(ETHTOOL_A_MODULE_FW_FLASH_HEADER, header), + NLATTR_DESC_STRING(ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME), + NLATTR_DESC_U32(ETHTOOL_A_MODULE_FW_FLASH_PASS), + NLATTR_DESC_U32(ETHTOOL_A_MODULE_FW_FLASH_STATUS), + NLATTR_DESC_STRING(ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG), + NLATTR_DESC_UINT(ETHTOOL_A_MODULE_FW_FLASH_DONE), + NLATTR_DESC_UINT(ETHTOOL_A_MODULE_FW_FLASH_TOTAL), +}; + const struct pretty_nlmsg_desc ethnl_umsg_desc[] = { NLMSG_DESC_INVALID(ETHTOOL_MSG_USER_NONE), NLMSG_DESC(ETHTOOL_MSG_STRSET_GET, strset), @@ -541,6 +552,7 @@ const struct pretty_nlmsg_desc ethnl_umsg_desc[] = { NLMSG_DESC(ETHTOOL_MSG_PLCA_GET_STATUS, plca), NLMSG_DESC(ETHTOOL_MSG_MM_GET, mm), NLMSG_DESC(ETHTOOL_MSG_MM_SET, mm), + NLMSG_DESC(ETHTOOL_MSG_MODULE_FW_FLASH_ACT, module_fw_flash), }; const unsigned int ethnl_umsg_n_desc = ARRAY_SIZE(ethnl_umsg_desc); @@ -590,6 +602,7 @@ const struct pretty_nlmsg_desc ethnl_kmsg_desc[] = { NLMSG_DESC(ETHTOOL_MSG_PLCA_NTF, plca), NLMSG_DESC(ETHTOOL_MSG_MM_GET_REPLY, mm), NLMSG_DESC(ETHTOOL_MSG_MM_NTF, mm), + NLMSG_DESC(ETHTOOL_MSG_MODULE_FW_FLASH_NTF, module_fw_flash), }; const unsigned int ethnl_kmsg_n_desc = ARRAY_SIZE(ethnl_kmsg_desc); diff --git a/netlink/extapi.h b/netlink/extapi.h index e2d6b71..c882295 100644 --- a/netlink/extapi.h +++ b/netlink/extapi.h @@ -55,6 +55,7 @@ int nl_get_mm(struct cmd_context *ctx); int nl_set_mm(struct cmd_context *ctx); int nl_gpse(struct cmd_context *ctx); int nl_spse(struct cmd_context *ctx); +int nl_flash_module_fw(struct cmd_context *ctx); void nl_monitor_usage(void); @@ -130,6 +131,7 @@ nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused, #define nl_set_mm NULL #define nl_gpse NULL #define nl_spse NULL +#define nl_flash_module_fw NULL #endif /* ETHTOOL_ENABLE_NETLINK */ diff --git a/netlink/module.c b/netlink/module.c index 54aa6d0..42def91 100644 --- a/netlink/module.c +++ b/netlink/module.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "../internal.h" #include "../common.h" @@ -177,3 +178,185 @@ int nl_smodule(struct cmd_context *ctx) else return nlctx->exit_code ?: 83; } + +/* MODULE_FW_FLASH_ACT */ + +static const struct param_parser flash_module_fw_params[] = { + { + .arg = "file", + .type = ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME, + .handler = nl_parse_string, + .min_argc = 1, + }, + { + .arg = "pass", + .type = ETHTOOL_A_MODULE_FW_FLASH_PASS, + .handler = nl_parse_direct_u32, + .min_argc = 1, + }, + {} +}; + +struct module_flash_context { + uint8_t breakout:1, + first:1; +}; + +static int module_fw_flash_ntf_cb(const struct nlmsghdr *nlhdr, void *data) +{ + const struct nlattr *tb[ETHTOOL_A_MODULE_FW_FLASH_MAX + 1] = {}; + struct module_flash_context *mfctx; + struct nl_context *nlctx = data; + DECLARE_ATTR_TB_INFO(tb); + u8 status = 0; + int ret; + + mfctx = nlctx->cmd_private; + + ret = mnl_attr_parse(nlhdr, GENL_HDRLEN, attr_cb, &tb_info); + if (ret < 0) + return MNL_CB_OK; + nlctx->devname = get_dev_name(tb[ETHTOOL_A_MODULE_FW_FLASH_HEADER]); + if (!dev_ok(nlctx)) + return MNL_CB_OK; + + if (tb[ETHTOOL_A_MODULE_FW_FLASH_STATUS]) + status = mnl_attr_get_u32(tb[ETHTOOL_A_MODULE_FW_FLASH_STATUS]); + + switch (status) { + case ETHTOOL_MODULE_FW_FLASH_STATUS_STARTED: + print_string(PRINT_FP, NULL, + "Transceiver module firmware flashing started for device %s\n", + nlctx->devname); + break; + case ETHTOOL_MODULE_FW_FLASH_STATUS_IN_PROGRESS: + if (mfctx->first) { + print_string(PRINT_FP, NULL, + "Transceiver module firmware flashing in progress for device %s\n", + nlctx->devname); + mfctx->first = 0; + } + break; + case ETHTOOL_MODULE_FW_FLASH_STATUS_COMPLETED: + print_nl(); + print_string(PRINT_FP, NULL, + "Transceiver module firmware flashing completed for device %s\n", + nlctx->devname); + mfctx->breakout = 1; + break; + case ETHTOOL_MODULE_FW_FLASH_STATUS_ERROR: + print_nl(); + print_string(PRINT_FP, NULL, + "Transceiver module firmware flashing encountered an error for device %s\n", + nlctx->devname); + mfctx->breakout = 1; + break; + default: + break; + } + + if (tb[ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG]) { + const char *status_msg; + + status_msg = mnl_attr_get_str(tb[ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG]); + print_string(PRINT_FP, NULL, "Status message: %s\n", status_msg); + } + + if (tb[ETHTOOL_A_MODULE_FW_FLASH_DONE] && + tb[ETHTOOL_A_MODULE_FW_FLASH_TOTAL]) { + uint64_t done, total; + + done = attr_get_uint(tb[ETHTOOL_A_MODULE_FW_FLASH_DONE]); + total = attr_get_uint(tb[ETHTOOL_A_MODULE_FW_FLASH_TOTAL]); + + if (total) + print_u64(PRINT_FP, NULL, "Progress: %"PRIu64"%\r", + done * 100 / total); + } + + return MNL_CB_OK; +} + +static int nl_flash_module_fw_cb(const struct nlmsghdr *nlhdr, void *data) +{ + const struct genlmsghdr *ghdr = (const struct genlmsghdr *)(nlhdr + 1); + + if (ghdr->cmd != ETHTOOL_MSG_MODULE_FW_FLASH_NTF) + return MNL_CB_OK; + + module_fw_flash_ntf_cb(nlhdr, data); + + return MNL_CB_STOP; +} + +static int nl_flash_module_fw_process_ntf(struct cmd_context *ctx) +{ + struct nl_context *nlctx = ctx->nlctx; + struct module_flash_context *mfctx; + struct nl_socket *nlsk; + int ret; + + nlsk = nlctx->ethnl_socket; + + mfctx = malloc(sizeof(struct module_flash_context)); + if (!mfctx) + return -ENOMEM; + + mfctx->breakout = 0; + mfctx->first = 1; + nlctx->cmd_private = mfctx; + + while (!mfctx->breakout) { + ret = nlsock_process_reply(nlsk, nl_flash_module_fw_cb, nlctx); + if (ret) + goto out; + nlsk->seq++; + } + +out: + free(mfctx); + return ret; +} + +int nl_flash_module_fw(struct cmd_context *ctx) +{ + struct nl_context *nlctx = ctx->nlctx; + struct nl_msg_buff *msgbuff; + struct nl_socket *nlsk; + int ret; + + if (netlink_cmd_check(ctx, ETHTOOL_MSG_MODULE_FW_FLASH_ACT, false)) + return -EOPNOTSUPP; + if (!ctx->argc) { + fprintf(stderr, "ethtool (--flash-module-firmware): parameters missing\n"); + return 1; + } + + nlctx->cmd = "--flash-module-firmware"; + nlctx->argp = ctx->argp; + nlctx->argc = ctx->argc; + nlctx->devname = ctx->devname; + nlsk = nlctx->ethnl_socket; + msgbuff = &nlsk->msgbuff; + + ret = msg_init(nlctx, msgbuff, ETHTOOL_MSG_MODULE_FW_FLASH_ACT, + NLM_F_REQUEST | NLM_F_ACK); + if (ret < 0) + return 2; + if (ethnla_fill_header(msgbuff, ETHTOOL_A_MODULE_FW_FLASH_HEADER, + ctx->devname, 0)) + return -EMSGSIZE; + + ret = nl_parser(nlctx, flash_module_fw_params, NULL, PARSER_GROUP_NONE, + NULL); + if (ret < 0) + return 1; + + ret = nlsock_sendmsg(nlsk, NULL); + if (ret < 0) + fprintf(stderr, "Cannot flash transceiver module firmware\n"); + else + ret = nl_flash_module_fw_process_ntf(ctx); + + return ret; +} diff --git a/netlink/netlink.h b/netlink/netlink.h index 1274a3b..92a336e 100644 --- a/netlink/netlink.h +++ b/netlink/netlink.h @@ -175,4 +175,20 @@ static inline int netlink_init_rtnl_socket(struct nl_context *nlctx) return nlsock_init(nlctx, &nlctx->rtnl_socket, NETLINK_ROUTE); } +static inline uint64_t attr_get_uint(const struct nlattr *attr) +{ + switch (mnl_attr_get_payload_len(attr)) { + case sizeof(uint8_t): + return mnl_attr_get_u8(attr); + case sizeof(uint16_t): + return mnl_attr_get_u16(attr); + case sizeof(uint32_t): + return mnl_attr_get_u32(attr); + case sizeof(uint64_t): + return mnl_attr_get_u64(attr); + } + + return -1ULL; +} + #endif /* ETHTOOL_NETLINK_INT_H__ */ diff --git a/netlink/prettymsg.c b/netlink/prettymsg.c index fbf684f..0eb4447 100644 --- a/netlink/prettymsg.c +++ b/netlink/prettymsg.c @@ -15,6 +15,8 @@ #include #include +#include "../internal.h" +#include "netlink.h" #include "prettymsg.h" #define __INDENT 4 @@ -114,6 +116,9 @@ static int pretty_print_attr(const struct nlattr *attr, case NLA_U64: printf("%" PRIu64, mnl_attr_get_u64(attr)); break; + case NLA_UINT: + printf("%" PRIu64, attr_get_uint(attr)); + break; case NLA_X8: printf("0x%02x", mnl_attr_get_u8(attr)); break; diff --git a/netlink/prettymsg.h b/netlink/prettymsg.h index 8ca1db3..ef8e73f 100644 --- a/netlink/prettymsg.h +++ b/netlink/prettymsg.h @@ -18,6 +18,7 @@ enum pretty_nla_format { NLA_U16, NLA_U32, NLA_U64, + NLA_UINT, NLA_X8, NLA_X16, NLA_X32, @@ -67,6 +68,7 @@ struct pretty_nlmsg_desc { #define NLATTR_DESC_U16(_name) NLATTR_DESC(_name, NLA_U16) #define NLATTR_DESC_U32(_name) NLATTR_DESC(_name, NLA_U32) #define NLATTR_DESC_U64(_name) NLATTR_DESC(_name, NLA_U64) +#define NLATTR_DESC_UINT(_name) NLATTR_DESC(_name, NLA_UINT) #define NLATTR_DESC_X8(_name) NLATTR_DESC(_name, NLA_X8) #define NLATTR_DESC_X16(_name) NLATTR_DESC(_name, NLA_X16) #define NLATTR_DESC_X32(_name) NLATTR_DESC(_name, NLA_X32) diff --git a/shell-completion/bash/ethtool b/shell-completion/bash/ethtool index f7d6aed..3c775a1 100644 --- a/shell-completion/bash/ethtool +++ b/shell-completion/bash/ethtool @@ -1164,6 +1164,32 @@ _ethtool_set_module() COMPREPLY=( $( compgen -W "${!settings[*]}" -- "$cur" ) ) } +# Completion for ethtool --flash-module-firmware +_ethtool_flash_module_firmware() +{ + local -A settings=( + [file]=1 + [pass]=1 + ) + + case "$prev" in + file) + _ethtool_firmware + return ;; + pass) + # Number + return ;; + esac + + # Remove settings which have been seen + local word + for word in "${words[@]:3:${#words[@]}-4}"; do + unset "settings[$word]" + done + + COMPREPLY=( $( compgen -W "${!settings[*]}" -- "$cur" ) ) +} + # Complete any ethtool command _ethtool() { @@ -1217,6 +1243,7 @@ _ethtool() [--test]=test [--set-module]=set_module [--show-module]=devname + [--flash-module-firmware]=flash_module_firmware ) local -A other_funcs=( [--config-ntuple]=config_nfc