All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Krzysztof Olędzki" <ole@ans.pl>
To: Ido Schimmel <idosch@nvidia.com>, Andrew Lunn <andrew@lunn.ch>,
	Michal Kubecek <mkubecek@suse.cz>,
	Moshe Shemesh <moshe@nvidia.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	tariqt@nvidia.com, Dan Merillat <git@dan.merillat.org>
Subject: [PATCH v2 ethtool] qsfp: Better handling of Page 03h netlink read failure
Date: Tue, 30 Jul 2024 17:49:33 -0700	[thread overview]
Message-ID: <0d2504d1-e150-40bf-8e30-bf6414d42b60@ans.pl> (raw)

When dumping the EEPROM contents of a QSFP transceiver module, ethtool
will only ask the kernel to retrieve Upper Page 03h if the module
advertised it as supported.

However, some kernel drivers like mlx4 are currently unable to provide
the page, resulting in the kernel returning an error. Since Upper Page
03h is optional, do not treat the error as fatal. Instead, print an
error message and allow ethtool to continue and parse / print the
contents of the other pages.

Also, clarify potentially cryptic "netlink error: Invalid argument" message.

Before:
 # ethtool -m eth3
 netlink error: Invalid argument

After:
 # ethtool -m eth3
 netlink error: Invalid argument
 Failed to read Upper Page 03h, driver error?
         Identifier                                : 0x0d (QSFP+)
         Extended identifier                       : 0x00
 (...)

Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)")

Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
---
 qsfp.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/qsfp.c b/qsfp.c
index a2921fb..a3a919d 100644
--- a/qsfp.c
+++ b/qsfp.c
@@ -1038,8 +1038,15 @@ sff8636_memory_map_init_pages(struct cmd_context *ctx,
 
 	sff8636_request_init(&request, 0x3, SFF8636_PAGE_SIZE);
 	ret = nl_get_eeprom_page(ctx, &request);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		/* Page 03h is not available due to a bug in the driver.
+		 * This is a non-fatal error and sff8636_dom_parse()
+		 * handles this correctly.
+		 */
+		fprintf(stderr, "Failed to read Upper Page 03h, driver error?\n");
+		return 0;
+	}
+
 	map->page_03h = request.data - SFF8636_PAGE_SIZE;
 
 	return 0;
-- 
2.45.2

             reply	other threads:[~2024-07-31  0:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31  0:49 Krzysztof Olędzki [this message]
2024-07-31  8:20 ` [PATCH v2 ethtool] qsfp: Better handling of Page 03h netlink read failure Ido Schimmel
2024-07-31 13:58   ` Krzysztof Olędzki
2024-08-01  0:16     ` Jakub Kicinski
2024-08-08 13:41 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d2504d1-e150-40bf-8e30-bf6414d42b60@ans.pl \
    --to=ole@ans.pl \
    --cc=andrew@lunn.ch \
    --cc=git@dan.merillat.org \
    --cc=idosch@nvidia.com \
    --cc=mkubecek@suse.cz \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.