Blame SOURCES/0025-sff-8079-Request-specific-pages-for-parsing-in-netli.patch

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