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