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