1f2507
From bda06d81f41bb1cde16a319728d479cda4b9f295 Mon Sep 17 00:00:00 2001
1f2507
From: Ido Schimmel <idosch@nvidia.com>
1f2507
Date: Tue, 12 Oct 2021 16:25:24 +0300
1f2507
Subject: [PATCH 25/35] sff-8079: Request specific pages for parsing in netlink
1f2507
 path
1f2507
1f2507
Convert the SFF-8079 code to request the required EEPROM contents in the
1f2507
netlink path as was done for CMIS and SFF-8636. It will allow us to
1f2507
remove standard-specific code from the netlink code (i.e.,
1f2507
netlink/module-eeprom.c).
1f2507
1f2507
In addition, in the future, it will allow the netlink path to support
1f2507
parsing of SFF-8472.
1f2507
1f2507
Tested by making sure that the output of 'ethtool -m' does not change
1f2507
before and after the patch.
1f2507
1f2507
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
1f2507
---
1f2507
 internal.h              |  2 +-
1f2507
 netlink/module-eeprom.c |  2 +-
1f2507
 sfpid.c                 | 20 ++++++++++++++++++--
1f2507
 3 files changed, 20 insertions(+), 4 deletions(-)
1f2507
1f2507
diff --git a/internal.h b/internal.h
1f2507
index 2407d3c223fa..0d9d816ab563 100644
1f2507
--- a/internal.h
1f2507
+++ b/internal.h
1f2507
@@ -385,7 +385,7 @@ int rxclass_rule_del(struct cmd_context *ctx, __u32 loc);
1f2507
 
1f2507
 /* Module EEPROM parsing code */
1f2507
 void sff8079_show_all_ioctl(const __u8 *id);
1f2507
-void sff8079_show_all_nl(const __u8 *id);
1f2507
+int sff8079_show_all_nl(struct cmd_context *ctx);
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 f04f8e134223..6d76b8a96461 100644
1f2507
--- a/netlink/module-eeprom.c
1f2507
+++ b/netlink/module-eeprom.c
1f2507
@@ -321,7 +321,7 @@ static void decoder_print(struct cmd_context *ctx)
1f2507
 
1f2507
 	switch (module_id) {
1f2507
 	case SFF8024_ID_SFP:
1f2507
-		sff8079_show_all_nl(page_zero->data);
1f2507
+		sff8079_show_all_nl(ctx);
1f2507
 		break;
1f2507
 	case SFF8024_ID_QSFP:
1f2507
 	case SFF8024_ID_QSFP28:
1f2507
diff --git a/sfpid.c b/sfpid.c
1f2507
index c214820226d1..621d1e86c278 100644
1f2507
--- a/sfpid.c
1f2507
+++ b/sfpid.c
1f2507
@@ -8,8 +8,13 @@
1f2507
  */
1f2507
 
1f2507
 #include <stdio.h>
1f2507
+#include <errno.h>
1f2507
 #include "internal.h"
1f2507
 #include "sff-common.h"
1f2507
+#include "netlink/extapi.h"
1f2507
+
1f2507
+#define SFF8079_PAGE_SIZE	0x80
1f2507
+#define SFF8079_I2C_ADDRESS_LOW	0x50
1f2507
 
1f2507
 static void sff8079_show_identifier(const __u8 *id)
1f2507
 {
1f2507
@@ -445,7 +450,18 @@ void sff8079_show_all_ioctl(const __u8 *id)
1f2507
 	sff8079_show_all_common(id);
1f2507
 }
1f2507
 
1f2507
-void sff8079_show_all_nl(const __u8 *id)
1f2507
+int sff8079_show_all_nl(struct cmd_context *ctx)
1f2507
 {
1f2507
-	sff8079_show_all_common(id);
1f2507
+	struct ethtool_module_eeprom request = {
1f2507
+		.length = SFF8079_PAGE_SIZE,
1f2507
+		.i2c_address = SFF8079_I2C_ADDRESS_LOW,
1f2507
+	};
1f2507
+	int ret;
1f2507
+
1f2507
+	ret = nl_get_eeprom_page(ctx, &request);
1f2507
+	if (ret < 0)
1f2507
+		return ret;
1f2507
+	sff8079_show_all_common(request.data);
1f2507
+
1f2507
+	return 0;
1f2507
 }
1f2507
-- 
1f2507
2.35.1
1f2507