From patchwork Tue Sep 14 11:27:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12492791 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 X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E381EC433F5 for ; Tue, 14 Sep 2021 11:28:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF70A610E6 for ; Tue, 14 Sep 2021 11:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232145AbhINL32 (ORCPT ); Tue, 14 Sep 2021 07:29:28 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:35247 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbhINL3Y (ORCPT ); Tue, 14 Sep 2021 07:29:24 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id E947B5805B5; Tue, 14 Sep 2021 07:28:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 14 Sep 2021 07:28:06 -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= fm3; bh=dU3Nsjw82W/VcUZX2aY7ntGEaa4D2EK0lv10ohAqQ90=; b=Eb5R+3Hz FHBBGtsHwdc8k/lypOAJFHcIp1lFmBP5+CqwodwWrKVaHsbnPLdfgqoJeaDjw9Mh tT9KI0psWcAn4Hq+bqKOhXmLfCxN7ZRvsQ8aojC1J6iP3L62SzjI6f6cOo4OSFCH jShpIfyVkYb4V9+kSCP+KGGz88ftmp8tDvtE7uvvrmS2YZAOrtO9jUYkq1u9Co0O I28kn6dJZp1SXpe+Hjo8oKIgw2R5oSf3s3X+LAJEyZLVPYQPy7KtoXxLxyYu+8PP B7+aSPnRKPArfaZ+f45wIOTgZicXdEvgn6mMoqvF99cZkpTOyXSKyuNL81EhAkkZ XePyRqFvaYZ47g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegledgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecuggftrfgrthhtvghrnhepudetieevffffveelkeeljeffkefhke ehgfdtffethfelvdejgffghefgveejkefhnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Sep 2021 07:28:04 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: mkubecek@suse.cz, kuba@kernel.org, andrew@lunn.ch, f.fainelli@gmail.com, vadimp@nvidia.com, mlxsw@nvidia.com, vladyslavt@nvidia.com, moshe@nvidia.com, popadrian1996@gmail.com, Ido Schimmel Subject: [PATCH ethtool 3/5] netlink: eeprom: Fallback to IOCTL when a complete hex/raw dump is requested Date: Tue, 14 Sep 2021 14:27:36 +0300 Message-Id: <20210914112738.358627-4-idosch@idosch.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914112738.358627-1-idosch@idosch.org> References: <20210914112738.358627-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 The IOCTL backend provides a complete hex/raw dump of the module EEPROM contents: # ethtool -m swp11 hex on | wc -l 34 # ethtool -m swp11 raw on | wc -c 512 With the netlink backend, only the first 128 bytes from I2C address 0x50 are dumped: # ethtool -m swp11 hex on | wc -l 10 # ethtool -m swp11 raw on | wc -c 128 The presence of optional / banked pages is unknown without parsing the EEPROM contents which is unavailable when pretty printing is disabled (i.e., configure --disable-pretty-dump). With the IOCTL backend, this parsing happens inside the kernel. Therefore, when a complete hex/raw dump is requested, fallback to the IOCTL backend. After the patch: # ethtool -m swp11 hex on | wc -l 34 # ethtool -m swp11 raw on | wc -c 512 This avoids breaking users that are relying on current behavior. If users want a hex/raw dump of optional/banked pages that are not returned with the IOCTL backend, they will be required to request these explicitly via the netlink backend. For example: # ethtool -m swp11 hex on page 0x2 This is desirable as that way there is no ambiguity regarding the location of optional/banked pages in the dump. Another way to implement the above would be to use the 'nlchk' callback added in commit 67a9ef551661 ("ethtool: add nlchk for redirecting to netlink"). However, it is called before the netlink instance is initialized and before the command line parameters are parsed via nl_parser(). Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)") Signed-off-by: Ido Schimmel --- netlink/module-eeprom.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/netlink/module-eeprom.c b/netlink/module-eeprom.c index 38e7d2cd6cf3..e9a122df3259 100644 --- a/netlink/module-eeprom.c +++ b/netlink/module-eeprom.c @@ -365,6 +365,16 @@ int nl_getmodule(struct cmd_context *ctx) return -EINVAL; } + /* When complete hex/raw dump of the EEPROM is requested, fallback to + * ioctl. Netlink can only request specific pages. + */ + if ((getmodule_cmd_params.dump_hex || getmodule_cmd_params.dump_raw) && + !getmodule_cmd_params.page && !getmodule_cmd_params.bank && + !getmodule_cmd_params.i2c_address) { + nlctx->ioctl_fallback = true; + return -EOPNOTSUPP; + } + request.i2c_address = ETH_I2C_ADDRESS_LOW; request.length = 128; ret = page_fetch(nlctx, &request);