From patchwork Tue Oct 12 13:25:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12552565 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E769FC433F5 for ; Tue, 12 Oct 2021 13:26:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF42B6101D for ; Tue, 12 Oct 2021 13:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236923AbhJLN2a (ORCPT ); Tue, 12 Oct 2021 09:28:30 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:40649 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237049AbhJLN2V (ORCPT ); Tue, 12 Oct 2021 09:28:21 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C2EE65C01B7; Tue, 12 Oct 2021 09:26:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 12 Oct 2021 09:26:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=E/JsxXRB4zdVs8oZvi/IUOP88op31uOiCnLdFcyfrUo=; b=B7RmG1Tw bELYcN9dT/6w5M+pQ5rFSVgxgQZm/SRCWSp87I2Z5cHEeJ6R4CbZDqCWXA5t8mCl lQOnqYdaFf0aV2TfL6CcqOFHiC5qH6GWYNX0geTig4u/PeHpwPSdUow1RL7fZIJ7 upREDDZzhh+mljTebHXGgoGLp/dsNY24HsXW9E4wD/pRkN4Nl/eoLJE/vmW+/aEs aLoJzFI164ArZi1onq4NoM4gS6ayygo16LI040Fh/squrjVZr2ll5dA5gD29PJcT G4t6A4SGA69KCgSAGypUYJn6MnZXP4WlVww4IC8hX24Xqe0CnYBGqxL++jDHR7XX mZryCVWMRIoZAw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtkedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecuggftrfgrthhtvghrnhepudetieevffffveelkeeljeffkefhke ehgfdtffethfelvdejgffghefgveejkefhnecuvehluhhsthgvrhfuihiivgepjeenucfr rghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Oct 2021 09:26:17 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: mkubecek@suse.cz, popadrian1996@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, moshe@nvidia.com, Ido Schimmel Subject: [PATCH ethtool-next 13/14] sff-8079: Request specific pages for parsing in netlink path Date: Tue, 12 Oct 2021 16:25:24 +0300 Message-Id: <20211012132525.457323-14-idosch@idosch.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012132525.457323-1-idosch@idosch.org> References: <20211012132525.457323-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: mkubecek+ethtool@suse.cz From: Ido Schimmel Convert the SFF-8079 code to request the required EEPROM contents in the netlink path as was done for CMIS and SFF-8636. It will allow us to remove standard-specific code from the netlink code (i.e., netlink/module-eeprom.c). In addition, in the future, it will allow the netlink path to support parsing of SFF-8472. Tested by making sure that the output of 'ethtool -m' does not change before and after the patch. Signed-off-by: Ido Schimmel --- internal.h | 2 +- netlink/module-eeprom.c | 2 +- sfpid.c | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/internal.h b/internal.h index 2407d3c223fa..0d9d816ab563 100644 --- a/internal.h +++ b/internal.h @@ -385,7 +385,7 @@ int rxclass_rule_del(struct cmd_context *ctx, __u32 loc); /* Module EEPROM parsing code */ void sff8079_show_all_ioctl(const __u8 *id); -void sff8079_show_all_nl(const __u8 *id); +int sff8079_show_all_nl(struct cmd_context *ctx); /* Optics diagnostics */ void sff8472_show_all(const __u8 *id); diff --git a/netlink/module-eeprom.c b/netlink/module-eeprom.c index f04f8e134223..6d76b8a96461 100644 --- a/netlink/module-eeprom.c +++ b/netlink/module-eeprom.c @@ -321,7 +321,7 @@ static void decoder_print(struct cmd_context *ctx) switch (module_id) { case SFF8024_ID_SFP: - sff8079_show_all_nl(page_zero->data); + sff8079_show_all_nl(ctx); break; case SFF8024_ID_QSFP: case SFF8024_ID_QSFP28: diff --git a/sfpid.c b/sfpid.c index c214820226d1..621d1e86c278 100644 --- a/sfpid.c +++ b/sfpid.c @@ -8,8 +8,13 @@ */ #include +#include #include "internal.h" #include "sff-common.h" +#include "netlink/extapi.h" + +#define SFF8079_PAGE_SIZE 0x80 +#define SFF8079_I2C_ADDRESS_LOW 0x50 static void sff8079_show_identifier(const __u8 *id) { @@ -445,7 +450,18 @@ void sff8079_show_all_ioctl(const __u8 *id) sff8079_show_all_common(id); } -void sff8079_show_all_nl(const __u8 *id) +int sff8079_show_all_nl(struct cmd_context *ctx) { - sff8079_show_all_common(id); + struct ethtool_module_eeprom request = { + .length = SFF8079_PAGE_SIZE, + .i2c_address = SFF8079_I2C_ADDRESS_LOW, + }; + int ret; + + ret = nl_get_eeprom_page(ctx, &request); + if (ret < 0) + return ret; + sff8079_show_all_common(request.data); + + return 0; }