89ea86
From 37093971b0f645542c4bff603f41f807e8023bd3 Mon Sep 17 00:00:00 2001
89ea86
From: Ido Schimmel <idosch@nvidia.com>
89ea86
Date: Tue, 23 Nov 2021 19:40:55 +0200
89ea86
Subject: [PATCH 27/35] sff-8636: Use an SFF-8636 specific define for maximum
89ea86
 number of channels
89ea86
89ea86
'MAX_CHANNEL_NUM' is defined in the common SFF code as 4 and used to set
89ea86
the size of the per-channel diagnostics array in the common 'sff_diags'
89ea86
structure.
89ea86
89ea86
The CMIS parsing code is also going to use the structure, but it can
89ea86
have up to 32 channels, unlike SFF-8636 that only has 4.
89ea86
89ea86
Therefore, set 'MAX_CHANNEL_NUM' to 32 and change the SFF-8636 code to
89ea86
use an SFF-8636 specific define instead of the common 'MAX_CHANNEL_NUM'.
89ea86
89ea86
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
89ea86
---
89ea86
 qsfp.c       | 9 +++++----
89ea86
 sff-common.h | 2 +-
89ea86
 2 files changed, 6 insertions(+), 5 deletions(-)
89ea86
89ea86
diff --git a/qsfp.c b/qsfp.c
89ea86
index e7c2f51cd9c6..58c4c4775e9b 100644
89ea86
--- a/qsfp.c
89ea86
+++ b/qsfp.c
89ea86
@@ -71,6 +71,7 @@ struct sff8636_memory_map {
89ea86
 
89ea86
 #define SFF8636_PAGE_SIZE	0x80
89ea86
 #define SFF8636_I2C_ADDRESS	0x50
89ea86
+#define SFF8636_MAX_CHANNEL_NUM	4
89ea86
 
89ea86
 #define MAX_DESC_SIZE	42
89ea86
 
89ea86
@@ -761,7 +762,7 @@ static void sff8636_dom_parse(const struct sff8636_memory_map *map,
89ea86
 
89ea86
 out:
89ea86
 	/* Channel Specific Data */
89ea86
-	for (i = 0; i < MAX_CHANNEL_NUM; i++) {
89ea86
+	for (i = 0; i < SFF8636_MAX_CHANNEL_NUM; i++) {
89ea86
 		u8 rx_power_offset, tx_bias_offset;
89ea86
 		u8 tx_power_offset;
89ea86
 
89ea86
@@ -832,13 +833,13 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map)
89ea86
 	printf("\t%-41s : %s\n", "Alarm/warning flags implemented",
89ea86
 		(sd.supports_alarms ? "Yes" : "No"));
89ea86
 
89ea86
-	for (i = 0; i < MAX_CHANNEL_NUM; i++) {
89ea86
+	for (i = 0; i < SFF8636_MAX_CHANNEL_NUM; i++) {
89ea86
 		snprintf(power_string, MAX_DESC_SIZE, "%s (Channel %d)",
89ea86
 					"Laser tx bias current", i+1);
89ea86
 		PRINT_BIAS(power_string, sd.scd[i].bias_cur);
89ea86
 	}
89ea86
 
89ea86
-	for (i = 0; i < MAX_CHANNEL_NUM; i++) {
89ea86
+	for (i = 0; i < SFF8636_MAX_CHANNEL_NUM; i++) {
89ea86
 		snprintf(power_string, MAX_DESC_SIZE, "%s (Channel %d)",
89ea86
 					"Transmit avg optical power", i+1);
89ea86
 		PRINT_xX_PWR(power_string, sd.scd[i].tx_power);
89ea86
@@ -849,7 +850,7 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map)
89ea86
 	else
89ea86
 		rx_power_string = "Rcvr signal avg optical power";
89ea86
 
89ea86
-	for (i = 0; i < MAX_CHANNEL_NUM; i++) {
89ea86
+	for (i = 0; i < SFF8636_MAX_CHANNEL_NUM; i++) {
89ea86
 		snprintf(power_string, MAX_DESC_SIZE, "%s(Channel %d)",
89ea86
 					rx_power_string, i+1);
89ea86
 		PRINT_xX_PWR(power_string, sd.scd[i].rx_power);
89ea86
diff --git a/sff-common.h b/sff-common.h
89ea86
index 2183f41ff9c9..aab306e0b74f 100644
89ea86
--- a/sff-common.h
89ea86
+++ b/sff-common.h
89ea86
@@ -160,7 +160,7 @@ struct sff_channel_diags {
89ea86
 /* Module Monitoring Fields */
89ea86
 struct sff_diags {
89ea86
 
89ea86
-#define MAX_CHANNEL_NUM 4
89ea86
+#define MAX_CHANNEL_NUM 32
89ea86
 #define LWARN 0
89ea86
 #define HWARN 1
89ea86
 #define LALRM 2
89ea86
-- 
89ea86
2.35.1
89ea86