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