Netdev List
 help / color / mirror / Atom feed
From: Danielle Ratson <danieller@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <mkubecek@suse.cz>, <idosch@nvidia.com>, <petrm@nvidia.com>,
	"Danielle Ratson" <danieller@nvidia.com>
Subject: [PATCH ethtool-next 1/5] module-common: Add module_dump_eeprom_page_hex() helper
Date: Thu, 7 May 2026 14:47:17 +0300	[thread overview]
Message-ID: <20260507114721.3409128-2-danieller@nvidia.com> (raw)
In-Reply-To: <20260507114721.3409128-1-danieller@nvidia.com>

Add module_dump_eeprom_page_hex() to module-common.c as the shared
building block for per-type EEPROM page hex dump functions.

It prints a per-page header (page number and optional bank) followed by
a hex dump in the established ethtool format, using dump_hex().

Assisted-by: Claude:claude-sonnet-4.6
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
---
 module-common.c | 16 ++++++++++++++++
 module-common.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/module-common.c b/module-common.c
index 4e9a0a7..17e4845 100644
--- a/module-common.c
+++ b/module-common.c
@@ -7,6 +7,7 @@
 #include <math.h>
 #include <ctype.h>
 #include "module-common.h"
+#include "internal.h"
 
 const struct module_aw_mod module_aw_mod_flags[] = {
 	{ MODULE_TYPE_CMIS, "Module temperature high alarm",
@@ -656,3 +657,18 @@ void module_show_dom_mod_lvl_monitors(const struct sff_diags *sd)
 	PRINT_VCC_ALL("Module voltage", "module_voltage_measurement",
 		      sd->sfp_voltage[MCURR]);
 }
+
+/* Print one EEPROM page with a descriptive header followed by hex dump.
+ * When bank is non-zero it is included in the header.
+ */
+void module_dump_eeprom_page_hex(const u8 *data, u8 bank, u8 page,
+				 u32 offset, u32 length)
+{
+	if (bank)
+		printf("Bank: 0x%x, Page: 0x%x\n\n", bank, page);
+	else
+		printf("Page: 0x%x\n\n", page);
+
+	dump_hex(stdout, data, length, offset);
+	printf("\n");
+}
diff --git a/module-common.h b/module-common.h
index 985b518..94a3a8e 100644
--- a/module-common.h
+++ b/module-common.h
@@ -284,4 +284,7 @@ void module_show_connector(const __u8 *id, int ctor_offset);
 void module_show_mit_compliance(u16 value);
 void module_show_dom_mod_lvl_monitors(const struct sff_diags *sd);
 
+void module_dump_eeprom_page_hex(const u8 *data, u8 bank, u8 page,
+				 u32 offset, u32 length);
+
 #endif /* MODULE_COMMON_H__ */
-- 
2.51.0


  reply	other threads:[~2026-05-07 11:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 11:47 [PATCH ethtool-next 0/5] ethtool: Add 'pages on|off' option for module EEROM hex dump Danielle Ratson
2026-05-07 11:47 ` Danielle Ratson [this message]
2026-05-07 11:47 ` [PATCH ethtool-next 2/5] sfpid: Refactor sff8079_show_all_nl() to separate page retrieval from display Danielle Ratson
2026-05-07 11:47 ` [PATCH ethtool-next 3/5] module: Add per-type EEPROM page hex dump functions Danielle Ratson
2026-05-07 11:47 ` [PATCH ethtool-next 4/5] netlink: module-eeprom: Add 'hex on pages on' option for page-organized hex dump Danielle Ratson
2026-05-07 11:47 ` [PATCH ethtool-next 5/5] ethtool: Add man page and bash completion for 'pages on|off' Danielle Ratson
2026-05-07 12:07 ` [PATCH ethtool-next 0/5] ethtool: Add 'pages on|off' option for module EEROM hex dump Michal Kubecek
2026-05-07 12:37   ` Danielle Ratson
2026-05-07 14:32     ` Michal Kubecek
2026-05-07 12:23 ` Andrew Lunn
2026-05-07 17:19   ` Danielle Ratson

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=20260507114721.3409128-2-danieller@nvidia.com \
    --to=danieller@nvidia.com \
    --cc=idosch@nvidia.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox