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