From patchwork Sun Aug 11 11:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13759729 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) (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 054E233991 for ; Sun, 11 Aug 2024 12:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723377622; cv=fail; b=eM71nVFCSqek4BIAnu/oe3BOC8zT7HjqDq6EzD7vCtVf/6HRlfmt/5kCoaebTEtmPHjvCQrDGotWCmVIIp4B+xS3brFC2N8ERKREuayXjBHgKBZ+pdp/KlBxC1ypPYGiygmunUeSW+obteA7FvSasSK2iQ9nfzSMa567LILzY1U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723377622; c=relaxed/simple; bh=NQf3Y4aX3tmM1sLMXhVSGOv3+NeMSwsZRAdERLUTkFQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rc5Y4nX9+gWDpZFQD8v1/ybyHOZNYelVtuuj56SBPKTf3Xxgsw1vgZzZ6+QYBlcMQznlQw/Qu7fYyGNjHuqhzxf64R6vijiD3XvanizIALPcRr8u2RG0tXlqxbOP+wUGa5yEiuKZgiCE/5NyCt5p0cobTZuzoWlS2OrE+qglZXQ= 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=S2+vE1og; arc=fail smtp.client-ip=40.107.223.77 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="S2+vE1og" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EEJTs8kDJYPFrUrRs+78vi9r2xj6X+IIWriYeOMlaVEUtiFYGZ8ascHNODW1xlhS50i7IWz2B6QXTw3X28x9fQwE3hlqYRWx7FSRvuISHjssnKRQ3zA6JZodGotIF/Ui6n90c1Bhh4BPFSaoO0ql8JlgtMawxbizA1I+MTu9bFohtmAeUKibpfOhjwZiPYw12KnB1/xN2Tu1NuOB0KgCSmnCShMZtjk8HtzOd9+fdsWTtQ5Wrmql3b60m4RuoWkyAa6cGyfjGJmtJKSQeU/XRA/WDhVej0PORiFkHXBUIJ8Z2E/rzyAw5xL6v/lga7+9Al600CHBFk9dqSjhVqd7Dg== 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=RKZ76EmHGBSFe+roMVPv93LrefPyi8yf6Vc4tPPmJBWsH7gRFP5zK8vg+V0RGibqo3D1DlN4iz6m7H04AHf3CBAK/CtPTgf0pEOcMNZh21yeuv0DJe8VJJjscqNN60dnqVhuUbHuuXIH8wuXhGUWnoFOLZJAHQOoHkYAVDBb1gmp5E+uZOa9S6GRr5LXLc2yxBsEKjmmWPzEIjxO9zAStfhMSDz8SgkyVdKqJGYVwujEOC3DdsXaijZqoHrtuSAAp0bMMFAW6/yp36hdcTR/KfRTN4MvSKbzp3ciDBo34bfTuJhLGrp5y+1O68nO7oNWRbRRbCqwbha9MAbDD08F9w== 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=S2+vE1oggxJkroavgf2J/Bjq0Z1qKJdY38Ool16YOekWZsmHhpASMSajPMj/6yUWDohpMKgquLaGIANfGx5/MN0jTljjsVqyEez3z6AwyhJtrtHS31Uu6ksRr3g2B7kfoJAQ70ZTJ4JDKAiy+dyf0CezAN3C7VtVJcO1Xf31/hSYZLqDUjE+AwV40cIIM1lsScDKXnH+P+Y/0rk+Mv3XwRgz5ujaR9gIkPmtMpinbbwlJw4CTQDyTklETGTPp06lzgj+kdqu0dWHR/7DFh419E1cf/qq7HUy4wTdzRKpTcB54J7RGYWVTdWdDk47YCHxoqtLXEWUR5gWkWEhaALN7g== Received: from BN9PR03CA0381.namprd03.prod.outlook.com (2603:10b6:408:f7::26) by BL1PR12MB5849.namprd12.prod.outlook.com (2603:10b6:208:384::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.20; Sun, 11 Aug 2024 12:00:17 +0000 Received: from BN1PEPF00006001.namprd05.prod.outlook.com (2603:10b6:408:f7:cafe::25) by BN9PR03CA0381.outlook.office365.com (2603:10b6:408:f7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.33 via Frontend Transport; Sun, 11 Aug 2024 12:00:17 +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 BN1PEPF00006001.mail.protection.outlook.com (10.167.243.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Sun, 11 Aug 2024 12:00:16 +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; Sun, 11 Aug 2024 05:00:04 -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; Sun, 11 Aug 2024 05:00:02 -0700 From: Danielle Ratson To: CC: , , Ido Schimmel , Danielle Ratson Subject: [PATCH ethtool-next v2 1/3] cmis: Print active and inactive firmware versions Date: Sun, 11 Aug 2024 14:59:46 +0300 Message-ID: <20240811115948.3335883-2-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240811115948.3335883-1-danieller@nvidia.com> References: <20240811115948.3335883-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00006001:EE_|BL1PR12MB5849:EE_ X-MS-Office365-Filtering-Correlation-Id: b310814d-33a9-42b2-6e8c-08dcb9fd2a8b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: fbRzaNIm+kBRCJ1pq86pSQyxQSNfIIIt/k2ulSfbwQ9ZDOKip674JFFNKNy1za8/Ewmcrw/l7i7MJKzNJr4Pyk3fMiT/wGuo0xTlOqHsBN/IMZkhl0unu4BunwdfU9SG6Ih9LfqBocdoJp7T9U1AIczQM/axq3ctGegsXCJx9S7pljJAWpy5HnyspnYTDhsjnphL4tvQA26WoLocQz+0ULJ6a+rJ1h6ozXjyDV9spmydeuKXP4lGdPpE/la1wIFcTSFplRDcBmcpgUD8YP2YO59ZF7geT/7Vv2AJjJVcrrX47veYebyBLKldCUCo9fJ8rqoEc+JKLAdT8r5CX5dyqXkW6O8QPVvMZdP/GDA6opT3AWijNkCwEkEtjHF+NO6Q1IzRxDfnT6zilfyxuGprNpILE4D8wXAnccs/WtDnDc2wKYNOcH/vTUFcUzJFeKAZBuiLQC/WNkJNJ/O8279Tu1UP3u4uS4KT/+ceLCXHmJFrSNXqAJ8sFlPuzH9KbpQfKCqBZ1s3dv0DRfw1PV/Qrw+VkcRLaSwj8RMJpeuowH1k+zCieYajr8tMjeAd2GMBtQbUJHy/G2XhZU+KdSYWmqrQd8UsCLJNdWCgvn5sdLuCQ7L4i905I15UDTzqm1yooKy1FD2JsMg01BfXNyhQAY0r0KbL3hlsutMDCvIEwSciT0C92KCFiSRv+DfK7NYcvJ1J5x2FEcme1lOdbne9cYXU0igUxKDECDB7pj6tseFRXpDcFGsJDNqoq2/DSjD4znH3TxgJpm/fSlpGC5sHTrE6YFByAUff1wR7vUx5yhadWAtwyrTUXsyJsoD5MIYiwFN+f3kxdL9cWb2yTkXxbaDVoMDljrRTSaKkqkFeYMxGXRtX9osTo2yLhZHdpjq3ZN38r0rJEk8YaJmQ6kZN70zQTOVV+zUfHCDr+2WqDY2kpFnaM/KX0EcNrsHHiSR9cLvtD3n4nz6uDpqI2xD1ue5ez31o7/6cqdGWUj08smln846qX1U+epVxHQkuOnOlvhtBd4p+10XsZdQ05xyEqM1q4K3hlRqX6ZvP1oD1bHSZ3P56JIczHzwVCUA4hwDlrfjcx9L7oHPuwv/xYDBJGZGzI+KatpPkM82PrL8/G8W+qVdGfspd6fT0Z/+axNwOJJH0nYk/WFL0gZaVaQ2mRlD9PMIFmPgez8GDO/X/iLboRtLhhDc4P1K0U7hlbBf6uyNgiXkfq2YK0Is7wAUTp4BsMINIu70tR6FPr12yU6W2cjWNJ1X785toCSEMNmpjmEp+FU1BfT9Qb2OVaAL+t9oDjIi8zo5ZwkQSptwFZ8N0xE4o6cmMbXCuEVqWFr+9sEYUoFpl5BxyZqpqQlRNAHinLc/2VCr0s+O0GhsKuxJUSxWOawHfct/u1gIzC8fE7eMx5g5cGrVduVNfKw/S+Q== 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 12:00:16.8913 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b310814d-33a9-42b2-6e8c-08dcb9fd2a8b 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: BN1PEPF00006001.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5849 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 Sun Aug 11 11:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13759730 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) (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 2BB4211CB8 for ; Sun, 11 Aug 2024 12:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723377631; cv=fail; b=V4UUkR1VcOoTDYrB0O2Oa3c5NO90h5vpdz3UO3XNTgN7sH8WcT7jK2kv8QIn9iYtLa2gN+kx+KbhGmATi1qQSKFnArAtVrdnfxtsWeV6NIhLsxhLWpkWWGVC6IosISeRbF/U9S9rCLclPGEzHjX3eIAiesYt2k+DwH985w4ms48= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723377631; c=relaxed/simple; bh=ypvifXDD6K+3EHUJ6OuNtvvPC7HxBCEQ0quwT1CtscE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=upV8YZNMcmoWE+Arl4iLoizEn/c9erw6wAtcP9L5qMnBkieJLOujWnnoeG/ApzdGhJEVbNQenbJfWDeQjjtWa2FXngGCtMPCW1trD8fvwzGuJcUUpp1bA+0uJIZifJSm6OBqWUY5XRR7wPRMpSiw+iedNPZF4miQ67UqAiIPXPU= 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=OwesAKsP; arc=fail smtp.client-ip=40.107.92.77 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="OwesAKsP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M88aoJP+1v/kocveiopr9cvCSBJ8KOv4InRMUvCxLNxm8H/mENx0IcZ3vEc4a1BCbb0o5p7VdMOC/rP92F4D/rWTfg9yK7kd7gdSXDYOoHG8G+IhW4uVqR4b6Cx77Ohxd6hXX74Co7qjyUx1DCaxjbpE/dP86ej13zwfAFHvm7rsM+ohzxfdxOQedtd0IMglUXa6U18zx33+x5SJl+4uGeS0R1cTpUN63DgZ0Bg0PaBP0j342y0ChxLJkGNXNLZRDo4mi2QRIFiBspmpfVwRpkpAkcUzuFTP4p0ikwYdz81g2Y5tRRvj/vY+tRzBxJ5xzmeHTf/pgSSX5GqXwBSYMg== 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=sdx02RtSlnVnsToQVvQoJahKFM6V84DPETqg3Oy0KhJ4faVHe2rFQH2hC0vLiQQWxiLj7DpTW/ypHYvcvuwCDFj0nlJ962oC4HytO3oTJg7NgCm/SgbuSiaa9/bxf6wM0cnBUdeRfHVoilS5uZZFiPI85RXNJK4lDhdV96oie/1sa9sxKA/6G04lG7iemK+4EsJCpErpZ5M2eNw3SQQ2do32AQp+jRyF3fA1iGCn71W3ikMmyjNHzSdyLiypMosIb7kr/PEhI3zQwc7/utIGzGJ8lNNJ+o3JnzJPTGJEqpNVvrmPVqdn1N3Z2y/kpY4ayU3kyESyLwnafrzvrMZv7Q== 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=8DICkl5y956lOBp5s5ApQVIfhzAOcm+r59oMg5hEwjE=; b=OwesAKsPic65S/tCSQkrQveJOY2tFFFeHrBFJJRaiXWE5qc55FNSkSPB03MsqN1HZ7tSnZjtGyN5E1DJPfnJn3kdyZ6SeWcu1O/c5UTHB4sGcSCYShJjhby4C2CMFMx1L27bvcWO2F0Wrms3RCYrVmx2t/D6gq9/WQ/X7MQnJIrbjsgNSRTM5d/ep2mh2Uwr2iIhpSf2O51HrpJpOO+Ro9jUjw3hwI29Nti7e0KBExIK146E+qoNc+C4Dpu7HghpRl0HUxpW5V5w01sI3fLtphWwPsxE4QquxJ7Bs77vVby7w17DijMYe9O+xtNZF298Xr3QUzoie0HyWFigg/En0A== Received: from BN0PR03CA0008.namprd03.prod.outlook.com (2603:10b6:408:e6::13) by MW4PR12MB5626.namprd12.prod.outlook.com (2603:10b6:303:169::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Sun, 11 Aug 2024 12:00:21 +0000 Received: from BL02EPF00029929.namprd02.prod.outlook.com (2603:10b6:408:e6:cafe::38) by BN0PR03CA0008.outlook.office365.com (2603:10b6:408:e6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.33 via Frontend Transport; Sun, 11 Aug 2024 12:00:21 +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 BL02EPF00029929.mail.protection.outlook.com (10.167.249.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Sun, 11 Aug 2024 12:00:20 +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; Sun, 11 Aug 2024 05:00:06 -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; Sun, 11 Aug 2024 05:00:04 -0700 From: Danielle Ratson To: CC: , , Ido Schimmel , Danielle Ratson Subject: [PATCH ethtool-next v2 2/3] cmis: Print CDB messaging support advertisement Date: Sun, 11 Aug 2024 14:59:47 +0300 Message-ID: <20240811115948.3335883-3-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240811115948.3335883-1-danieller@nvidia.com> References: <20240811115948.3335883-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029929:EE_|MW4PR12MB5626:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d2f2794-8d02-4318-41aa-08dcb9fd2cbf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: BMyiEIjo3aTpBx8jIqTvUEXcQLPBfTVl95KHk9rYCP41/Y5E6YFuP5zesOSbTe7Hue6ysOpCPPd+gaGQ9fgNb/0Lc1XOLyW5Q6PCmYQspKnx3zMyzaj3JzNIgom3Kn2Gfc7uosIhETwVThGpLn77p01TFFvM2AbaAn6Y61J3lVrHBX8i7O3P7muct4xJV3cLzZsqC4XY7Q0Y93ZYk6tTW+k3tuR3RIHjZAxA4i8X3H50RnHS2Bp5RGC0cRmUITwcx6Nmuv1IaE0oB2qY7GaB9TjYXHmHq2Js8TQfKz1xh7YYR/LYdIvwwNRHjmcJzkE5hBprFlsLHLaVSeBFS6yUHRFoMS6MJRiIabP2C8W1uTFtGzssTNHcqJygSkPEG33xivoPVDg+cQEW5OpdHBO7hJOe2Bf4llEfCpjrJXyKLdtwrxCohXimS4RDNguUuMskAR0OWt2YTFRaN4m0Zx7iEGb9J/crvw74+XMuI71IXNkecIT2JNw6tF5DHsNouvAF5OtbZ32CmNiIR/qe8XZ4xGddf65RFVghlY4lXFc8KSQuJ3jO1FFKuNeLMOyVJMfqL+m685ZnTyz2fZX5lA4rJSRbNgi6RYwAm9shHumSzCqHmYoO4+97LurpF4zRoLwCGcCQ/EPHNR/kbTuVO/oKoQzU9bhgRpzzjJF4PhwX9ayNkLsy6/Dq5V4MU/znmBbymYlCK14ULXCoAtB3PdVfAjMda4pn0A6jtnZRPoQeO83GiWcRX9/k+DYz9J2nFPHTPPcR5+J4zHoVy55teqxGJjl5dcBo2uKznLw5aWinLeJJZkmus2wam0bSN4qyJzZ0v/Wnl0Be1Qb+wGZq3uclHti8+qvkBD8AlhGYN5OoLN1x9roejtoZVk2tRhhW2AKJ0BvUDgOO8gsghrldDyLTbfwSC6GJe4KrGyCNb+gB4i+mW4rc+g1Rk1jI2MasgbWUZeiykn7VCBOtmnoipWgE9l/aviUasimQ4XEWq8oWPIVU7KeEg2r5uv5ONUy1b27DEVLhFqs/Byi3wjiWmuJfrKODGWrl9HrNdWSzDUgC/lUxEwMIrqTVHElWx3S3OVQwkTgpZaKBE6JqwhIJw8HXY8WmsWMIPDfmlHY+EyySc2zOTRuGZRHGEjHqHHAbL4qoZGsK5i6SWdKtqnyTUn9LXdmbkUZ4hNV6zEWhM/ELPwtV7TAV7YdpHxTUGKiGviMFCgSpC9WYWpXdAx/ypusJMa7gqljTe6cNTUv/3XpJcY74Gdv1BKdS6sE4ekXj2c9hEV/YUOuKrFXFDG0wAVJROHWX9zz9N9ypy3PuWar66dvDzwXYd9wnyoYpXrXIUuaFLC8/ZP48PjCbmOtF4a5elVcBTfdn6DVYT3kVVUmXdL30FGAEK0UgJGWe8i6G2pP0X9xUNfli3HC2NYIZyJGNxuj6zK7dltIE9SCeXaLTL1ULFZsIYDK9Nqj0a6A7rzSm 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)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 12:00:20.6176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d2f2794-8d02-4318-41aa-08dcb9fd2cbf 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: BL02EPF00029929.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5626 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 Sun Aug 11 11:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danielle Ratson X-Patchwork-Id: 13759731 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) (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 9AE4412E71 for ; Sun, 11 Aug 2024 12:00:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723377631; cv=fail; b=FYbsJXJE2n/1Zfa3yZ3ZpYXupcfK84ZjJlvJN93+WrOgMnPtqD7pDdb/FiRO9XlGH1bZ5AQL2fBkqQBjYi+8w+5szbWJZPJG5uzZFZJvCKM3nwDJ6tWZCFm64Nr+5x3ZsT2nVF6nG/a75Fr0GoTcuA5vYpYM4TazFyFWQnr6kKI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723377631; c=relaxed/simple; bh=CTwdLR9vxJwjzHxxG2M93elhZRkkTr40IyMbeCNRRMw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mUS8O7ze5cFCEzLzT2ZsPAunPNFhGweWMtZfTVNF6bzJGz9px3Tq7vwRrC3e/1lSQGZEMs4vR5J1dO6VChSNAj8TX80miZFmz/Fp9To9XoALgryL7M4rvT6D+hh64Dc14KyvDyqpS/1HSlT6TOPcM+PWfbPVe0xezCcknznO+FE= 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=kGLfIQ/r; arc=fail smtp.client-ip=40.107.244.55 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="kGLfIQ/r" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EhBGat1HfLJbQlJbURbBam0RE5Y5+qdcr6vLHhWgDo+KX5Axi5dty210kRsn9jIN0nZyqQBDR0a1XLQVABAXZXKwdSzezjiGjbfzeVOmM8eem9DCVHmCogxxbLGS1RYqNpxF0F0YYHVjsymdL5VhnpYJWNw/VD3Y9LDcGInTP6S7wbLB/4jFNfypOL+Hx9Z8u5D7giOutw257fCLvDBjeNgStXnT4FUTehL7l+IEms3o12AZ6ir0F/MDRSEbHLpFturRoUXNqNcewtngdK2wPc0uSfQgGROwT25NrDvJFxt7JOSTJl6zc9c9SxbtuTIymb24YUFLdRXpaqGejkZE6A== 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=xv6crm5VZm0KUEnMrOkW494ZQwQD1Qu7ua52vrt7V/U=; b=Qr0jRftCU7bIzY2y4LXzR8AHWoLtvvO6wukqzN/1QH1JtdsnWDF0YAvmaRmcUyHIxvPJzo2bLuk4E1eytFxqaqrDB/O5A0mXsB2uuSPr9DAve/bcTzBA0fUBsQ3PJg2o7VOXbOh1lJ7VD15W0Of57Mv32hm05sGMTblJGbmSjwZr51mkQd2bI+89UbZl7QqLI2vK4QhdNyQubGbenWiyhQgTTdmVg6hP3QCvEA6RcxcP6Gq73xt+BqbTC+oatlOhjETJCOgJHxQkmy/pk6cl3YFwcdu5gcJchPjGLx7yGAu3WbOszBdCPLofuMimEypmTQRCquKqclmODTruI1a7jA== 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=xv6crm5VZm0KUEnMrOkW494ZQwQD1Qu7ua52vrt7V/U=; b=kGLfIQ/rp/kFRJBjaYfTt1oFdRz10GZ2bZQbPIw4c0+UctszzenmMlYZtIDUaYx9gmnpoUhWgHH77jlR4vF0qgCj00CTv6IS9J9lsqEJk5ws/YG4/R9OM5bRi2ASkZxcomUj0AF2YqG3ZeJkU6RjGwOQG3Gv6FCFj7HQ03dw4cXgNOL41Oan6fiNgg3vwisyG+gtkkNe7p55nG3gk3swnA1tKAc4OWZWbl9rFW6B25VcL8auISFtP+bTirD4Ar5JYpzcqPEVsnDlwkPzysTzAaFmJsxetHxQy1hY7tbKxVlxTCtCID3ZiP61I3OtLcBlN5tY6VZxE5ZPoGyvQvuxfQ== Received: from BN0PR03CA0022.namprd03.prod.outlook.com (2603:10b6:408:e6::27) by PH7PR12MB8055.namprd12.prod.outlook.com (2603:10b6:510:268::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Sun, 11 Aug 2024 12:00:23 +0000 Received: from BL02EPF00029929.namprd02.prod.outlook.com (2603:10b6:408:e6:cafe::dc) by BN0PR03CA0022.outlook.office365.com (2603:10b6:408:e6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.33 via Frontend Transport; Sun, 11 Aug 2024 12:00:22 +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 BL02EPF00029929.mail.protection.outlook.com (10.167.249.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Sun, 11 Aug 2024 12:00:22 +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; Sun, 11 Aug 2024 05:00:09 -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; Sun, 11 Aug 2024 05:00:06 -0700 From: Danielle Ratson To: CC: , , Danielle Ratson , Ido Schimmel Subject: [PATCH ethtool-next v2 3/3] ethtool: Add ability to flash transceiver modules' firmware Date: Sun, 11 Aug 2024 14:59:48 +0300 Message-ID: <20240811115948.3335883-4-danieller@nvidia.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240811115948.3335883-1-danieller@nvidia.com> References: <20240811115948.3335883-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029929:EE_|PH7PR12MB8055:EE_ X-MS-Office365-Filtering-Correlation-Id: acfdc981-17e6-4edb-e2fa-08dcb9fd2e05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: HorwAIu9B0eVns4TbF0tFCCTbSyQFtaFId9f4D4GKmuDa72v4Gwc/vzBiWkZX6TsoOMIsUWsblA2BD0Iqoqp0ZjhYABHEaM5u00VyElbjpmREveLNtZU65cWSI78TA1xVUbQV3uMNzWtpJ5yex6ADTNioz7a+Rz15yAkXVcU5MAONiFN4ncsQT8Vshfy5pRh1IMVqm/FKO1cehCpyOy8LsMhCOIqrWVsL4B9p2p4ZP0ysjWv4rNcHMwtbRoGJ7I1wPgpaFuJ1o0ziEQE62j20Pd08+ua5Y8ex2yapVjZVzGfNidaCIdLw+9FLqEETGM6ZQzkCkHnsi4osk2tQzaVi2GrKMgHFCRuXDt2e2ixRXj5JxYK+5/6PAf2INSDNgD2NbwzhAZOaWX97HJJV8nhzn+IMvITwv28ECUB6wXhRs0Uag/1xsSHu6YFpdcSVP86/3tYfJZW9LfeWD/a/x5iTuKXSddsRad9eVlM1tO6TkArbjNdORAn49bsfvXNtuOARk8nxNYeORWLQzW3kk2GSpHnI9kyoFm8p2ZF83jXIZwSXgf74cMa6aCDaFLuJrTkzaul7T3gYoTmGuDZQjbuKE/jSz/+70zPKiHSBBHDXXP6OFLqnNKytN/2Ndde0dupXOJzUgtQ51P9MOGM5wob3Btf/0zQcQbu2bBFyIc1d03MwmJ0ZQNWxpOxCvjLN6HyMLOOejW2MYdP4Yfr8mxxuXwaiB5UqwEpbH9vxXnjx8mYNX5VYzREaFeG9TOFrbLOsQu2t/Otwu+JhRUqSGcKyQRArQnUT8GCeJkiFMXVCnFGY1QQNNKT6YJ2C/ZD4YmmhFf/kZNyemnqxlLRX3M5UpOogrjqRRePNMuWz6bTPcHeWtG42CN45wYQUCjadPkYzfGWiMByEO9fR/G2hvM67CiUowg5miLPSpy2yXCEp5ORlYWm2pgLSrNWKRU2CR5Qq5yCyXtCYFxpBUIaDQpFdZF5MWXyROMg7x0ROkpC+DchUTnQhBxFoZcmR/AZry9+h8ScXpLfiJKKRhfzSEwW/x23lKthaNvob7nPqujJg4Uehb80il7w2lu8JuLBEUqFgJspViM0CWaIzsyYyHl1+akxBlda2DL7T5EdVSfSplps4OusNsdZ7lrpBTJk5jiabU+hF4f3urWs1R40IwL0gpLoHbbmjkIB0ev2ewuB67gsn3ZaIOWdy2PuHJVDs1qJdYhojCHJUSa5/rR+xNBgTG5FzeQcgo89QX/AGaho6NeP7/pPhS0ETEvLRmuQgZ2id8/qsRRG7Ere95A5Ur/BnGzSMPusGyyfML6D0Qjzr14jqt9ofFSoONHpwvKCgWD97wBb2fFFHpe1fHSqQkCM6GOaZwSP2AO/rcJWBQdYB6vLzVqWkNp6XzRkYpXuesaVPxgJnn/+Rmz7oA7OhzvgwJSBsHFTjJGwsehJz3DvikuOLZiNdtkSAw30uNI5FHRY 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 12:00:22.7738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acfdc981-17e6-4edb-e2fa-08dcb9fd2e05 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: BL02EPF00029929.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8055 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 --- Notes: v2: * s/ETHTOOL_A_MODULE_FW_FLASH_PASS/ETHTOOL_A_MODULE_FW_FLASH_PASSWORD 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 c798cc2..89811b9 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 1e0a349..225f3aa 100644 --- a/ethtool.c +++ b/ethtool.c @@ -6236,6 +6236,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..5c0e1c6 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_PASSWORD), + 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..a92f272 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_PASSWORD, + .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 4a4b68b..ad2a787 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