89ea86
From 5b46ca06c9888c663a74bdd804b0ecb7199cfb62 Mon Sep 17 00:00:00 2001
89ea86
From: Ido Schimmel <idosch@nvidia.com>
89ea86
Date: Fri, 1 Oct 2021 18:06:21 +0300
89ea86
Subject: [PATCH 06/35] cmis: Fix CLEI code parsing
89ea86
89ea86
In CMIS, unlike SFF-8636, there is no presence indication for the CLEI
89ea86
code (Common Language Equipment Identification) field. The field is
89ea86
always present, but might not be supported. In which case, "a value of
89ea86
all ASCII 20h (spaces) shall be entered".
89ea86
89ea86
Therefore, remove the erroneous check which seems to be influenced from
89ea86
SFF-8636 and only print the string if it is supported and has a non-zero
89ea86
length.
89ea86
89ea86
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
89ea86
---
89ea86
 cmis.c | 8 +++++---
89ea86
 cmis.h | 4 ++--
89ea86
 2 files changed, 7 insertions(+), 5 deletions(-)
89ea86
89ea86
diff --git a/cmis.c b/cmis.c
89ea86
index 1a91e798e4b8..499355d0e024 100644
89ea86
--- a/cmis.c
89ea86
+++ b/cmis.c
89ea86
@@ -307,6 +307,8 @@ static void cmis_show_link_len(const __u8 *id)
89ea86
  */
89ea86
 static void cmis_show_vendor_info(const __u8 *id)
89ea86
 {
89ea86
+	const char *clei = (const char *)(id + CMIS_CLEI_START_OFFSET);
89ea86
+
89ea86
 	sff_show_ascii(id, CMIS_VENDOR_NAME_START_OFFSET,
89ea86
 		       CMIS_VENDOR_NAME_END_OFFSET, "Vendor name");
89ea86
 	cmis_show_oui(id);
89ea86
@@ -319,9 +321,9 @@ static void cmis_show_vendor_info(const __u8 *id)
89ea86
 	sff_show_ascii(id, CMIS_DATE_YEAR_OFFSET,
89ea86
 		       CMIS_DATE_VENDOR_LOT_OFFSET + 1, "Date code");
89ea86
 
89ea86
-	if (id[CMIS_CLEI_PRESENT_BYTE] & CMIS_CLEI_PRESENT_MASK)
89ea86
-		sff_show_ascii(id, CMIS_CLEI_START_OFFSET,
89ea86
-			       CMIS_CLEI_END_OFFSET, "CLEI code");
89ea86
+	if (*clei && strncmp(clei, CMIS_CLEI_BLANK, CMIS_CLEI_LEN))
89ea86
+		sff_show_ascii(id, CMIS_CLEI_START_OFFSET, CMIS_CLEI_END_OFFSET,
89ea86
+			       "CLEI code");
89ea86
 }
89ea86
 
89ea86
 void qsfp_dd_show_all(const __u8 *id)
89ea86
diff --git a/cmis.h b/cmis.h
89ea86
index 78ee1495bc33..cfac08f42904 100644
89ea86
--- a/cmis.h
89ea86
+++ b/cmis.h
89ea86
@@ -34,10 +34,10 @@
89ea86
 #define CMIS_DATE_VENDOR_LOT_OFFSET		0xBC
89ea86
 
89ea86
 /* CLEI Code (Page 0) */
89ea86
-#define CMIS_CLEI_PRESENT_BYTE			0x02
89ea86
-#define CMIS_CLEI_PRESENT_MASK			0x20
89ea86
 #define CMIS_CLEI_START_OFFSET			0xBE
89ea86
 #define CMIS_CLEI_END_OFFSET			0xC7
89ea86
+#define CMIS_CLEI_BLANK				"          "
89ea86
+#define CMIS_CLEI_LEN				0x0A
89ea86
 
89ea86
 /* Cable assembly length */
89ea86
 #define CMIS_CBL_ASM_LEN_OFFSET			0xCA
89ea86
-- 
89ea86
2.35.1
89ea86