[RFC,net-next,1/9] ethtool: Add ethtool operation to write to a transceiver module EEPROM
Message ID | 20240122084530.32451-2-danieller@nvidia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-32546-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2448263dyb; Mon, 22 Jan 2024 01:05:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLZhOedpV77Ck1gfPtoMYCZy7Ai38ewpp8fBPMMrSK1PsCFyJNfMejXyOSoNsMZH0NvdV5 X-Received: by 2002:a05:6a00:21c6:b0:6db:d17a:e3ca with SMTP id t6-20020a056a0021c600b006dbd17ae3camr967617pfj.63.1705914348147; Mon, 22 Jan 2024 01:05:48 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bw6-20020a056a02048600b005cfceb9d39csi1393946pgb.160.2024.01.22.01.05.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 01:05:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32546-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pE3kdyiw; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-32546-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32546-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D35C2B231C2 for <ouuuleilei@gmail.com>; Mon, 22 Jan 2024 08:47:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39A3A39AD4; Mon, 22 Jan 2024 08:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="pE3kdyiw" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) (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 BAD5A364CB; Mon, 22 Jan 2024 08:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705913172; cv=fail; b=I93Gh9LpZ6KTLzBVcTf1Ol/xwI+WpCVFmJM0aGJ1ZSOBl/suSC9jdUaNzjMZiAXgf3wYMKSGG89oBUYqBl0dFTh3+rTRs4roT1MzsuwhEgDdbUkZAjreVD8tV5IRRsO62b67xyb7HKMbGng4LwRlxKBDzV+lqcPSpqS+LlL23w8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705913172; c=relaxed/simple; bh=bMZz9FC0hpSJTWqNuvMPvmiaUjXR7ocPHtgB2At+hAo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jbXvx+Wq/oMXFYi39hc+qphdZdzVOVHZqu/j0eRiYxrfNxpzyN7NpJSzusEEYwzkr4pBA5PNpl4XHWe2S757RUHIHFe8Koz2LB1m2BcspRkC7M5gjSgXsnLHo7C3PmbLCtDWlN3+RyhVVZ2MHhTSPdhOCV+TWVV7fHFF20EZUpU= 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=pE3kdyiw; arc=fail smtp.client-ip=40.107.243.58 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELI+Oq49qg/M0LALzW/t0/3lp/M+Llc9BlruDCXI0ozvTcXz7AvQFup9KSrZ8AKg//vknAazlr+Tp5B0WI3lf+zFPhx7CTfXD7NwAcSMD0h1zZfg0YWhKZvG6UXvbwVdEYFMcHNBe+wAqHJ8N2uS6NrlfYB01MQqDisaSSLS6jQ2U/tcr60qm92KeiUku1N+siivj40KaFdjTvcnZrM02GpFxXIWwJjNlU4JViIVrC1Q8spCEmzuhbZXl6onzOWcKexMg9HAFfEtJEeQ5VphE27M7pAA3G1Sds6Qxw7ZzXGEUH6bCt9cn9APwqV0fGsVWjthG0EAy8AeVxD2t4YQKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ey2O5ktrthQlwGd9R2arXJH4t+wDrwCX5uMLGaZciKA=; b=jeCC2rVOPZ5r86mwatAL8dWxXqlnOOwaLFLJ5+BzhweDP8aG1sEP+xHUki71NWqTH9L5HrNxUnZxWHBWDmxRHSjcJBFcwXAF7s7YYy9aAc10pgFdVDCczePYkQgMysHqtNCo8aQUKG1gncEmay8NMZ8swrF4pZnGSHxeZuoA0yIUWv/Qy1fAsW31cSlJUFHUBRcMiU7G08MwO48t60xWxO1zNqg4Z8WciUc8Tos3kl5iZXPj66N5dEiYkiWdD/JtnmJoa1k+zGfnUNsDex5EW7Jrx3PrQln2cCeuYxdZkUGjXREJwWeYcrWv8YVLcMmJhF4B+OHUnkgTvsJ2cnQNPA== 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=Ey2O5ktrthQlwGd9R2arXJH4t+wDrwCX5uMLGaZciKA=; b=pE3kdyiwDpZl1mKMBuianDLjxHmWaEnEkSoH0t/hOEqbcfXH4LmBnBdobwTmEiNgbcEeh3tvnPeDznI31qEZdhEhTiiVsyDRa8NP+R9qa0Lc2yYHGPVniwvsGGj6igJDSPkHI0Htv00TrE07DuiiEzby60icmrFPPzgRdurrbY7l9Fq4chy62wtwRbi4D1DzEJhui+tiArWBHp0LBhBtpCG8Wo3QQjWQXG/yI1Iyo0wGe73Hl3Kk88u3EgR63ZrAN1KUVUPI/FtZmkBWlh7jdHfVZ9TwCDIrDTWuyY3v/a9lSKUTeYanC+hXUjnzRCNske4nEMim63V3XLLeZaF+bA== Received: from SJ0PR13CA0144.namprd13.prod.outlook.com (2603:10b6:a03:2c6::29) by SJ0PR12MB5406.namprd12.prod.outlook.com (2603:10b6:a03:3ae::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32; Mon, 22 Jan 2024 08:46:05 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:a03:2c6:cafe::2b) by SJ0PR13CA0144.outlook.office365.com (2603:10b6:a03:2c6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.17 via Frontend Transport; Mon, 22 Jan 2024 08:46:05 +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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Mon, 22 Jan 2024 08:46:05 +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.986.41; Mon, 22 Jan 2024 00:45:55 -0800 Received: from dev-r-vrt-155.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.986.41; Mon, 22 Jan 2024 00:45:49 -0800 From: Danielle Ratson <danieller@nvidia.com> To: <netdev@vger.kernel.org> CC: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <corbet@lwn.net>, <linux@armlinux.org.uk>, <sdf@google.com>, <kory.maincent@bootlin.com>, <maxime.chevallier@bootlin.com>, <vladimir.oltean@nxp.com>, <przemyslaw.kitszel@intel.com>, <ahmed.zaki@intel.com>, <richardcochran@gmail.com>, <shayagr@amazon.com>, <paul.greenwalt@intel.com>, <jiri@resnulli.us>, <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <mlxsw@nvidia.com>, <petrm@nvidia.com>, <idosch@nvidia.com> Subject: [RFC PATCH net-next 1/9] ethtool: Add ethtool operation to write to a transceiver module EEPROM Date: Mon, 22 Jan 2024 10:45:22 +0200 Message-ID: <20240122084530.32451-2-danieller@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240122084530.32451-1-danieller@nvidia.com> References: <20240122084530.32451-1-danieller@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: SJ5PEPF000001CE:EE_|SJ0PR12MB5406:EE_ X-MS-Office365-Filtering-Correlation-Id: b411a1ee-fc80-4ed4-fbc8-08dc1b269214 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1i5dRMbGY9tqhjmI5gaPbfpfuzHfFsy8JmpGk1uA6Ofi1STZi+jBUEbWkBTh8ADpiMrVuXSIL1MUrqALJqcQqokVZ0/8vMKrGDRL+6a8poEwikPEiHvgVStaRfcBTE5ivIHmkYiWMx2WTIDS5/eOSpr86i2oDdUxz1fajfMX5u9dDJ8rCglInokKYmxx2XUsmR9n+342BFkwC69Kglvqx2RAIDD26kNbK75cyqQOo9wo3KjOMmHrFjKy+Q79LiEF0EbMdba0CF376V+ymuXNE4Zu4R3mwkuN1VMGWL+Wk4uakEuSNpO1MYJxoWx7af/mHla1So/RXt8Ookr29iGhc4EpdJgrkus2l5SogJTy67o1s+YElF745WAGgvhGe1VdYPpmT5wgBpWrat9UGRzu5B3Z1xRnrLO1WniwnkscEKJflQSd4Z0QTg7hNgkIPaehN0lyNZyOLoO1TJCxJXIS1sLKBut9DAals6gWMaJ12SDG40m1rwk9YDijKvIR0a11GXBHUYOiRq/PeQDv018WbDXr017CRbtdzn1fKH6Eve8S3KWgiSrZKn2inlqBcqt2s5TNbjveS4CZuyxBN6U0oUpI9LTDaZr6AePCtbGmcCMt58bj8H4b36VIL4yvjDamY12n9SMJtr/aHlfHhWxtT3x/0DmTMG/oVy/UvNI7Zl35qLkNuspjgQfPKAZny7R3z9fvacnxUh/mov/049o2auH1bM7pBkYJaeU9ke8gjGDumvnyA6C5Y+FD3IA3Y28v 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:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(82310400011)(40470700004)(36840700001)(46966006)(16526019)(40480700001)(40460700003)(336012)(6666004)(426003)(2616005)(1076003)(26005)(107886003)(356005)(82740400003)(7636003)(86362001)(36756003)(83380400001)(36860700001)(5660300002)(7416002)(47076005)(2906002)(41300700001)(8676002)(8936002)(4326008)(70206006)(70586007)(316002)(478600001)(54906003)(6916009);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 08:46:05.3011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b411a1ee-fc80-4ed4-fbc8-08dc1b269214 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5406 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788780843403910639 X-GMAIL-MSGID: 1788780843403910639 |
Series |
Add ability to flash modules' firmware
|
|
Commit Message
Danielle Ratson
Jan. 22, 2024, 8:45 a.m. UTC
From: Ido Schimmel <idosch@nvidia.com> Ethtool can already retrieve information from a transceiver module EEPROM by invoking the ethtool_ops::get_module_eeprom_by_page operation. Add a corresponding operation that allows ethtool to write to a transceiver module EEPROM. The purpose of this operation is not to enable arbitrary read / write access, but to allow the kernel to write to specific addresses as part of transceiver module firmware flashing. In the future, more functionality can be implemented on top of these read / write operations. Adjust the comments of the 'ethtool_module_eeprom' structure as it is no longer used only for read access. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Petr Machata <petrm@nvidia.com> --- include/linux/ethtool.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
Comments
On Mon, Jan 22, 2024 at 10:45:22AM +0200, Danielle Ratson wrote: > /** > - * struct ethtool_module_eeprom - EEPROM dump from specified page > - * @offset: Offset within the specified EEPROM page to begin read, in bytes. > - * @length: Number of bytes to read. > - * @page: Page number to read from. > - * @bank: Page bank number to read from, if applicable by EEPROM spec. > + * struct ethtool_module_eeprom - plug-in module EEPROM read / write parameters > + * @offset: Offset within the specified page, in bytes. > + * @length: Number of bytes to read / write. > + * @page: Page number. > + * @bank: Bank number, if supported by EEPROM spec. I suppose I should have reviewed the addition of this (I can't recall whether I got the original or not.) If one looks at SFF-8472, then the first 128 bytes of the EEPROM at 0x50 (0xA0 on the wire) are not paged. Whereas bytes 128..255 are the paged bytes. Therefore, "offset within the specified page" can sensibly be interpreted as referring to the EEPROM at 0x50, at an offset of 128 + offset. Meanwhile, the actual implementation doesn't do that - the offset is the offset from the beginning of the EEPROM, and offsets >= 128 access the paged area. What this means is that the parameter description here is basically wrong, both before and after your change. This really ought to be fixed so that we describe things correctly rather than misleading people who read documentation. Otherwise, it's a recipe for broken implementations... and it's also completely pointless documenting it if the documentation is wrong.
> > /** > > - * struct ethtool_module_eeprom - EEPROM dump from specified page > > - * @offset: Offset within the specified EEPROM page to begin read, in > bytes. > > - * @length: Number of bytes to read. > > - * @page: Page number to read from. > > - * @bank: Page bank number to read from, if applicable by EEPROM spec. > > + * struct ethtool_module_eeprom - plug-in module EEPROM read / write > > + parameters > > + * @offset: Offset within the specified page, in bytes. > > + * @length: Number of bytes to read / write. > > + * @page: Page number. > > + * @bank: Bank number, if supported by EEPROM spec. > > I suppose I should have reviewed the addition of this (I can't recall whether I > got the original or not.) > > If one looks at SFF-8472, then the first 128 bytes of the EEPROM at > 0x50 (0xA0 on the wire) are not paged. Whereas bytes 128..255 are the paged > bytes. Therefore, "offset within the specified page" can sensibly be > interpreted as referring to the EEPROM at 0x50, at an offset of > 128 + offset. > > Meanwhile, the actual implementation doesn't do that - the offset is the > offset from the beginning of the EEPROM, and offsets >= 128 access the > paged area. > > What this means is that the parameter description here is basically wrong, > both before and after your change. > > This really ought to be fixed so that we describe things correctly rather than > misleading people who read documentation. Otherwise, it's a recipe for > broken implementations... and it's also completely pointless documenting it if > the documentation is wrong. > Will rephrase. > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
On Mon, Jan 22, 2024 at 10:45:22AM +0200, Danielle Ratson wrote: > From: Ido Schimmel <idosch@nvidia.com> > > Ethtool can already retrieve information from a transceiver module > EEPROM by invoking the ethtool_ops::get_module_eeprom_by_page operation. > Add a corresponding operation that allows ethtool to write to a > transceiver module EEPROM. > > The purpose of this operation is not to enable arbitrary read / write > access, but to allow the kernel to write to specific addresses as part > of transceiver module firmware flashing. In the future, more > functionality can be implemented on top of these read / write > operations. My memory is dim, but i thought we decided that since the algorithm to program these modules is defined in the standard, all we need to do is pass the firmware blob, and have an in kernel implementation of the algorithm. There is no need to have an arbitrary write blob to module, which might, or might not be abused in the future. Also, is the module functional while its firmware is being upgraded? Do we need to enforce the link is down? Andrew
On Thu, Jan 25, 2024 at 09:26:16PM +0100, Andrew Lunn wrote: > On Mon, Jan 22, 2024 at 10:45:22AM +0200, Danielle Ratson wrote: > > From: Ido Schimmel <idosch@nvidia.com> > > > > Ethtool can already retrieve information from a transceiver module > > EEPROM by invoking the ethtool_ops::get_module_eeprom_by_page operation. > > Add a corresponding operation that allows ethtool to write to a > > transceiver module EEPROM. > > > > The purpose of this operation is not to enable arbitrary read / write > > access, but to allow the kernel to write to specific addresses as part > > of transceiver module firmware flashing. In the future, more > > functionality can be implemented on top of these read / write > > operations. > > My memory is dim, but i thought we decided that since the algorithm to > program these modules is defined in the standard, all we need to do is > pass the firmware blob, and have an in kernel implementation of the > algorithm. There is no need to have an arbitrary write blob to module, > which might, or might not be abused in the future. O.K, back after reading more of the patches. If i'm understanding the code correctly, this is never exposed to userspace? Its purely an in kernel API? It would be good to make that clear in the commit message, and document that in the ethtool ops structure. Thanks Andrew
> > On Mon, Jan 22, 2024 at 10:45:22AM +0200, Danielle Ratson wrote: > > > From: Ido Schimmel <idosch@nvidia.com> > > > > > > Ethtool can already retrieve information from a transceiver module > > > EEPROM by invoking the ethtool_ops::get_module_eeprom_by_page > operation. > > > Add a corresponding operation that allows ethtool to write to a > > > transceiver module EEPROM. > > > > > > The purpose of this operation is not to enable arbitrary read / > > > write access, but to allow the kernel to write to specific addresses > > > as part of transceiver module firmware flashing. In the future, more > > > functionality can be implemented on top of these read / write > > > operations. > > > > My memory is dim, but i thought we decided that since the algorithm to > > program these modules is defined in the standard, all we need to do is > > pass the firmware blob, and have an in kernel implementation of the > > algorithm. There is no need to have an arbitrary write blob to module, > > which might, or might not be abused in the future. > > O.K, back after reading more of the patches. > > If i'm understanding the code correctly, this is never exposed to userspace? Its > purely an in kernel API? It would be good to make that clear in the commit > message, and document that in the ethtool ops structure. > > Thanks > Andrew Hi Andrew, Yes, that is correct. Will add a clarification. Thanks.
> > From: Ido Schimmel <idosch@nvidia.com> > > > > Ethtool can already retrieve information from a transceiver module > > EEPROM by invoking the ethtool_ops::get_module_eeprom_by_page > operation. > > Add a corresponding operation that allows ethtool to write to a > > transceiver module EEPROM. > > > > The purpose of this operation is not to enable arbitrary read / write > > access, but to allow the kernel to write to specific addresses as part > > of transceiver module firmware flashing. In the future, more > > functionality can be implemented on top of these read / write > > operations. > > My memory is dim, but i thought we decided that since the algorithm to > program these modules is defined in the standard, all we need to do is pass > the firmware blob, and have an in kernel implementation of the algorithm. > There is no need to have an arbitrary write blob to module, which might, or > might not be abused in the future. > > Also, is the module functional while its firmware is being upgraded? > Do we need to enforce the link is down? > > Andrew This is part of the reasons why we kept a flag for module_fw_flash_in_progress. I think it should be down since the module is doing some sort of reset during the flashing process (after the Run Firmware Image). So in order to avoid packet loss, this should be considered. Ill consider the relevant scenarios for vetoing in the actual version. Thanks.
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 325e0778e937..bb253d90352b 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -474,17 +474,14 @@ struct ethtool_rmon_stats { #define ETH_MODULE_MAX_I2C_ADDRESS 0x7f /** - * struct ethtool_module_eeprom - EEPROM dump from specified page - * @offset: Offset within the specified EEPROM page to begin read, in bytes. - * @length: Number of bytes to read. - * @page: Page number to read from. - * @bank: Page bank number to read from, if applicable by EEPROM spec. + * struct ethtool_module_eeprom - plug-in module EEPROM read / write parameters + * @offset: Offset within the specified page, in bytes. + * @length: Number of bytes to read / write. + * @page: Page number. + * @bank: Bank number, if supported by EEPROM spec. * @i2c_address: I2C address of a page. Value less than 0x7f expected. Most * EEPROMs use 0x50 or 0x51. * @data: Pointer to buffer with EEPROM data of @length size. - * - * This can be used to manage pages during EEPROM dump in ethtool and pass - * required information to the driver. */ struct ethtool_module_eeprom { u32 offset; @@ -789,6 +786,8 @@ struct ethtool_rxfh_param { * @get_module_eeprom_by_page: Get a region of plug-in module EEPROM data from * specified page. Returns a negative error code or the amount of bytes * read. + * @set_module_eeprom_by_page: Write to a region of plug-in module EEPROM. + * Returns a negative error code or zero. * @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics. * @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics. * @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics. @@ -921,6 +920,9 @@ struct ethtool_ops { int (*get_module_eeprom_by_page)(struct net_device *dev, const struct ethtool_module_eeprom *page, struct netlink_ext_ack *extack); + int (*set_module_eeprom_by_page)(struct net_device *dev, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack); void (*get_eth_phy_stats)(struct net_device *dev, struct ethtool_eth_phy_stats *phy_stats); void (*get_eth_mac_stats)(struct net_device *dev,