89ea86
From 1f20fb8e8b94d049672e48388ae57f89e89e880b Mon Sep 17 00:00:00 2001
89ea86
From: Ido Schimmel <idosch@nvidia.com>
89ea86
Date: Tue, 12 Oct 2021 16:25:20 +0300
89ea86
Subject: [PATCH 21/35] sff-8079: Split SFF-8079 parsing function
89ea86
89ea86
SFF-8079, unlike CMIS and SFF-8636, only has a single page and therefore
89ea86
its parsing function (i.e., sff8079_show_all()) is called from both the
89ea86
IOCTL and netlink paths with a buffer pointing to that single page.
89ea86
89ea86
In future patches, the netlink code (i.e., netlink/module-eeprom.c) will
89ea86
no longer call the SFF-8079 code with a buffer pointing to the first 128
89ea86
bytes of the EEPROM. Instead, the SFF-8079 code will need to request the
89ea86
needed EEPROM data, as will be done in CMIS and SFF-8636.
89ea86
89ea86
Therefore, as a preparation for this change, split the main parsing
89ea86
function into IOCTL and netlink variants.
89ea86
89ea86
No functional changes intended.
89ea86
89ea86
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
89ea86
---
89ea86
 ethtool.c               |  4 ++--
89ea86
 internal.h              |  3 ++-
89ea86
 netlink/module-eeprom.c |  2 +-
89ea86
 sfpid.c                 | 12 +++++++++++-
89ea86
 4 files changed, 16 insertions(+), 5 deletions(-)
89ea86
89ea86
diff --git a/ethtool.c b/ethtool.c
89ea86
index 6c744ff84eb9..5d4b5afbfd47 100644
89ea86
--- a/ethtool.c
89ea86
+++ b/ethtool.c
89ea86
@@ -4900,10 +4900,10 @@ static int do_getmodule(struct cmd_context *ctx)
89ea86
 			switch (modinfo.type) {
89ea86
 #ifdef ETHTOOL_ENABLE_PRETTY_DUMP
89ea86
 			case ETH_MODULE_SFF_8079:
89ea86
-				sff8079_show_all(eeprom->data);
89ea86
+				sff8079_show_all_ioctl(eeprom->data);
89ea86
 				break;
89ea86
 			case ETH_MODULE_SFF_8472:
89ea86
-				sff8079_show_all(eeprom->data);
89ea86
+				sff8079_show_all_ioctl(eeprom->data);
89ea86
 				sff8472_show_all(eeprom->data);
89ea86
 				break;
89ea86
 			case ETH_MODULE_SFF_8436:
89ea86
diff --git a/internal.h b/internal.h
89ea86
index 7ca6066d4e12..a77efd385698 100644
89ea86
--- a/internal.h
89ea86
+++ b/internal.h
89ea86
@@ -384,7 +384,8 @@ int rxclass_rule_ins(struct cmd_context *ctx,
89ea86
 int rxclass_rule_del(struct cmd_context *ctx, __u32 loc);
89ea86
 
89ea86
 /* Module EEPROM parsing code */
89ea86
-void sff8079_show_all(const __u8 *id);
89ea86
+void sff8079_show_all_ioctl(const __u8 *id);
89ea86
+void sff8079_show_all_nl(const __u8 *id);
89ea86
 
89ea86
 /* Optics diagnostics */
89ea86
 void sff8472_show_all(const __u8 *id);
89ea86
diff --git a/netlink/module-eeprom.c b/netlink/module-eeprom.c
89ea86
index 18b1abbe1252..101d5943c2bc 100644
89ea86
--- a/netlink/module-eeprom.c
89ea86
+++ b/netlink/module-eeprom.c
89ea86
@@ -323,7 +323,7 @@ static void decoder_print(void)
89ea86
 
89ea86
 	switch (module_id) {
89ea86
 	case SFF8024_ID_SFP:
89ea86
-		sff8079_show_all(page_zero->data);
89ea86
+		sff8079_show_all_nl(page_zero->data);
89ea86
 		break;
89ea86
 	case SFF8024_ID_QSFP:
89ea86
 	case SFF8024_ID_QSFP28:
89ea86
diff --git a/sfpid.c b/sfpid.c
89ea86
index da2b3f4df3d2..c214820226d1 100644
89ea86
--- a/sfpid.c
89ea86
+++ b/sfpid.c
89ea86
@@ -396,7 +396,7 @@ static void sff8079_show_options(const __u8 *id)
89ea86
 		printf("%s Power level 3 requirement\n", pfx);
89ea86
 }
89ea86
 
89ea86
-void sff8079_show_all(const __u8 *id)
89ea86
+static void sff8079_show_all_common(const __u8 *id)
89ea86
 {
89ea86
 	sff8079_show_identifier(id);
89ea86
 	if (((id[0] == 0x02) || (id[0] == 0x03)) && (id[1] == 0x04)) {
89ea86
@@ -439,3 +439,13 @@ void sff8079_show_all(const __u8 *id)
89ea86
 		sff8079_show_ascii(id, 84, 91, "Date code");
89ea86
 	}
89ea86
 }
89ea86
+
89ea86
+void sff8079_show_all_ioctl(const __u8 *id)
89ea86
+{
89ea86
+	sff8079_show_all_common(id);
89ea86
+}
89ea86
+
89ea86
+void sff8079_show_all_nl(const __u8 *id)
89ea86
+{
89ea86
+	sff8079_show_all_common(id);
89ea86
+}
89ea86
-- 
89ea86
2.35.1
89ea86