Blame SOURCES/0021-sff-8079-Split-SFF-8079-parsing-function.patch

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