Skip to contentSkip to conversation

Add QSFP-DD support

PATCH Superseded Adrian Pop 2 participants 5 messages Aug 6, 2020 – Aug 13, 2020

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Adrian Pop

author
#0 lore raw

PATCH v2 1/1 Add QSFP-DD support

The Common Management Interface Specification (CMIS) for QSFP-DD shares some similarities with other form factors such as QSFP or SFP, but due to the fact that the module memory map is different, the current ethtool version is not able to provide relevant information about an interface.

This patch adds QSFP-DD support to ethtool. The changes are similar to the ones already existing in qsfp.c, but customized to use the memory addresses and logic as defined in the specifications document.

Page 0x00 (lower and higher memory) are always implemented, so the ethtool expects at least 256 bytes if the identifier matches the one for QSFP-DD. For optical connected cables, additional pages are usually available.

Several functions from qsfp.c could be reused, so an additional parameter was added to each and the functions were moved to sff-common.c.

Changelog (diff from v1):
* Report cable length in meters instead of kilometers
* Fix bad value for QSFP_DD_DATE_VENDOR_LOT_OFFSET
* Fix initialization for struct qsfp_dd_diags
* Remove unrelated whitespace cleanups in qsfp.c and Makefile.am

---
 Makefile.am  |   2 +-
 qsfp-dd.c    | 553 +++++++++++++++++++++++++++++++++++++++++++++++++++
 qsfp-dd.h    | 236 ++++++++++++++++++++++
 qsfp.c       |  47 +----
 qsfp.h       |   8 -
 sff-common.c |  51 +++++
 sff-common.h |  26 ++-
 7 files changed, 874 insertions(+), 49 deletions(-)
 create mode 100644 qsfp-dd.c
 create mode 100644 qsfp-dd.h
Makefile.am +1 -1
index 2abb274..38dde09 100644
@@ -17,7 +17,7 @@ ethtool_SOURCES += \
 		  smsc911x.c at76c50x-usb.c sfc.c stmmac.c	\
 		  sff-common.c sff-common.h sfpid.c sfpdiag.c	\
 		  ixgbevf.c tse.c vmxnet3.c qsfp.c qsfp.h fjes.c lan78xx.c \
-		  igc.c
+		  igc.c qsfp-dd.c qsfp-dd.h
 endif
 
 if ENABLE_BASH_COMPLETION
qsfp-dd.c new file +553 -0

553 lines not on this page · raw message

qsfp-dd.h new file +236 -0

236 lines not on this page · raw message

qsfp.c +11 -36

81 lines not on this page · raw message

qsfp.h +0 -8
index 3215932..9636b0c 100644
@@ -31,14 +31,6 @@
 #define	SFF8636_ID_OFFSET	0x00
 
 #define	SFF8636_REV_COMPLIANCE_OFFSET	0x01
-#define	 SFF8636_REV_UNSPECIFIED		0x00
-#define	 SFF8636_REV_8436_48			0x01
-#define	 SFF8636_REV_8436_8636			0x02
-#define	 SFF8636_REV_8636_13			0x03
-#define	 SFF8636_REV_8636_14			0x04
-#define	 SFF8636_REV_8636_15			0x05
-#define	 SFF8636_REV_8636_20			0x06
-#define	 SFF8636_REV_8636_27			0x07
 
 #define	SFF8636_STATUS_2_OFFSET	0x02
 /* Flat Memory:0- Paging, 1- Page 0 only */
sff-common.c +51 -0

66 lines not on this page · raw message

sff-common.h +22 -4
index 5562b4d..0d04851 100644
@@ -26,7 +26,17 @@
 #include <stdio.h>
 #include "internal.h"
 
-#define SFF8024_ID_OFFSET				0x00
+/* Revision compliance */
+#define	 SFF8636_REV_UNSPECIFIED		0x00
+#define	 SFF8636_REV_8436_48			0x01
+#define	 SFF8636_REV_8436_8636			0x02
+#define	 SFF8636_REV_8636_13			0x03
+#define	 SFF8636_REV_8636_14			0x04
+#define	 SFF8636_REV_8636_15			0x05
+#define	 SFF8636_REV_8636_20			0x06
+#define	 SFF8636_REV_8636_27			0x07
+
+#define  SFF8024_ID_OFFSET				0x00
 #define  SFF8024_ID_UNKNOWN				0x00
 #define  SFF8024_ID_GBIC				0x01
 #define  SFF8024_ID_SOLDERED_MODULE		0x02
@@ -51,7 +61,8 @@
 #define  SFF8024_ID_HD8X_FANOUT			0x15
 #define  SFF8024_ID_CDFP_S3				0x16
 #define  SFF8024_ID_MICRO_QSFP			0x17
-#define  SFF8024_ID_LAST				SFF8024_ID_MICRO_QSFP
+#define  SFF8024_ID_QSFP_DD				0x18
+#define  SFF8024_ID_LAST				SFF8024_ID_QSFP_DD
 #define  SFF8024_ID_UNALLOCATED_LAST	0x7F
 #define  SFF8024_ID_VENDOR_START		0x80
 #define  SFF8024_ID_VENDOR_LAST			0xFF
@@ -76,8 +87,14 @@
 #define  SFF8024_CTOR_RJ45				0x22
 #define  SFF8024_CTOR_NO_SEPARABLE		0x23
 #define  SFF8024_CTOR_MXC_2x16			0x24
-#define  SFF8024_CTOR_LAST				SFF8024_CTOR_MXC_2x16
-#define  SFF8024_CTOR_UNALLOCATED_LAST	0x7F
+#define  SFF8024_CTOR_CS_OPTICAL		0x25
+#define  SFF8024_CTOR_CS_OPTICAL_MINI		0x26
+#define  SFF8024_CTOR_MPO_2X12		    	0x27
+#define  SFF8024_CTOR_MPO_1X16		    	0x28
+#define  SFF8024_CTOR_LAST			SFF8024_CTOR_MPO_1X16
+
+#define  SFF8024_CTOR_NO_SEP_QSFP_DD 		0x6F
+#define  SFF8024_CTOR_UNALLOCATED_LAST		0x7F
 #define  SFF8024_CTOR_VENDOR_START		0x80
 #define  SFF8024_CTOR_VENDOR_LAST		0xFF
 
@@ -185,5 +202,6 @@ void sff8024_show_oui(const __u8 *id, int id_offset);
 void sff8024_show_identifier(const __u8 *id, int id_offset);
 void sff8024_show_connector(const __u8 *id, int ctor_offset);
 void sff8024_show_encoding(const __u8 *id, int encoding_offset, int sff_type);
+void sff_show_revision_compliance(const __u8 *id, int rev_offset);
 
 #endif /* SFF_COMMON_H__ */
Signature · 1 line
2.17.1
#1 lore raw

Hi Adrian

Quoted 38 lines
qsfp-dd.c new file +37 -0
+static void
+qsfp_dd_parse_diagnostics(const __u8 *id, struct qsfp_dd_diags *const sd)
+{
+	__u16 rx_power_offset;
+	__u16 tx_power_offset;
+	__u16 tx_bias_offset;
+	__u16 temp_offset;
+	__u16 volt_offset;
+	int i;
+
+	for (i = 0; i < QSFP_DD_MAX_CHANNELS; ++i) {
+		/*
+		 * Add Tx/Rx output/input optical power relevant information.
+		 * To access the info for the ith lane, we have to skip i * 2
+		 * bytes starting from the offset of the first lane for that
+		 * specific channel property.
+		 */
+		tx_bias_offset = QSFP_DD_TX_BIAS_START_OFFSET + (i << 1);
+		rx_power_offset = QSFP_DD_RX_PWR_START_OFFSET + (i << 1);
+		tx_power_offset = QSFP_DD_TX_PWR_START_OFFSET + (i << 1);
 
+/*-----------------------------------------------------------------------
+ * Upper Memory Page 0x10: contains dynamic control bytes.
+ * RealOffset = 3 * 0x80 + LocalOffset
+ */
+#define PAG10H_OFFSET				(0x03 * 0x80)
+
+/*-----------------------------------------------------------------------
+ * Upper Memory Page 0x11: contains lane dynamic status bytes.
+ * RealOffset = 4 * 0x80 + LocalOffset
+ */
+#define PAG11H_OFFSET				(0x04 * 0x80)
+#define QSFP_DD_TX_PWR_START_OFFSET		(PAG11H_OFFSET + 0x9A)
+#define QSFP_DD_TX_BIAS_START_OFFSET		(PAG11H_OFFSET + 0xAA)
+#define QSFP_DD_RX_PWR_START_OFFSET		(PAG11H_OFFSET + 0xBA)
+
+/* HA = High Alarm; LA = Low Alarm
+ * HW = High Warning; LW = Low Warning

qsfp-dd.c

Quoted 10 lines
qsfp-dd.c new file +10 -0
+ */
+#define QSFP_DD_TX_HA_OFFSET			(PAG11H_OFFSET + 0x8B)
+#define QSFP_DD_TX_LA_OFFSET			(PAG11H_OFFSET + 0x8C)
+#define QSFP_DD_TX_HW_OFFSET			(PAG11H_OFFSET + 0x8D)
+#define QSFP_DD_TX_LW_OFFSET			(PAG11H_OFFSET + 0x8E)
+
+#define QSFP_DD_RX_HA_OFFSET			(PAG11H_OFFSET + 0x95)
+#define QSFP_DD_RX_LA_OFFSET			(PAG11H_OFFSET + 0x96)
+#define QSFP_DD_RX_HW_OFFSET			(PAG11H_OFFSET + 0x97)
+#define QSFP_DD_RX_LW_OFFSET			(PAG11H_OFFSET + 0x98)

You still have code which implies page 0x10 and 0x11 follow directly after page 2. This is something i would like to avoid until we have a driver which really does export these pages. Please could you remove all this code.

Thanks
Andrew

author
#2 lore raw

Hi Andrew!

Should I resubmit v3 after I delete the code that has to do with page 0x10 and 0x11?

Adrian

Quoted 59 lines · Andrew Lunn

Hi Adrian

Quoted 38 lines
qsfp-dd.c new file +37 -0
+static void
+qsfp_dd_parse_diagnostics(const __u8 *id, struct qsfp_dd_diags *const sd)
+{
+     __u16 rx_power_offset;
+     __u16 tx_power_offset;
+     __u16 tx_bias_offset;
+     __u16 temp_offset;
+     __u16 volt_offset;
+     int i;
+
+     for (i = 0; i < QSFP_DD_MAX_CHANNELS; ++i) {
+             /*
+              * Add Tx/Rx output/input optical power relevant information.
+              * To access the info for the ith lane, we have to skip i * 2
+              * bytes starting from the offset of the first lane for that
+              * specific channel property.
+              */
+             tx_bias_offset = QSFP_DD_TX_BIAS_START_OFFSET + (i << 1);
+             rx_power_offset = QSFP_DD_RX_PWR_START_OFFSET + (i << 1);
+             tx_power_offset = QSFP_DD_TX_PWR_START_OFFSET + (i << 1);
 
+/*-----------------------------------------------------------------------
+ * Upper Memory Page 0x10: contains dynamic control bytes.
+ * RealOffset = 3 * 0x80 + LocalOffset
+ */
+#define PAG10H_OFFSET                                (0x03 * 0x80)
+
+/*-----------------------------------------------------------------------
+ * Upper Memory Page 0x11: contains lane dynamic status bytes.
+ * RealOffset = 4 * 0x80 + LocalOffset
+ */
+#define PAG11H_OFFSET                                (0x04 * 0x80)
+#define QSFP_DD_TX_PWR_START_OFFSET          (PAG11H_OFFSET + 0x9A)
+#define QSFP_DD_TX_BIAS_START_OFFSET         (PAG11H_OFFSET + 0xAA)
+#define QSFP_DD_RX_PWR_START_OFFSET          (PAG11H_OFFSET + 0xBA)
+
+/* HA = High Alarm; LA = Low Alarm
+ * HW = High Warning; LW = Low Warning

qsfp-dd.c

Quoted 10 lines
qsfp-dd.c new file +10 -0
+ */
+#define QSFP_DD_TX_HA_OFFSET                 (PAG11H_OFFSET + 0x8B)
+#define QSFP_DD_TX_LA_OFFSET                 (PAG11H_OFFSET + 0x8C)
+#define QSFP_DD_TX_HW_OFFSET                 (PAG11H_OFFSET + 0x8D)
+#define QSFP_DD_TX_LW_OFFSET                 (PAG11H_OFFSET + 0x8E)
+
+#define QSFP_DD_RX_HA_OFFSET                 (PAG11H_OFFSET + 0x95)
+#define QSFP_DD_RX_LA_OFFSET                 (PAG11H_OFFSET + 0x96)
+#define QSFP_DD_RX_HW_OFFSET                 (PAG11H_OFFSET + 0x97)
+#define QSFP_DD_RX_LW_OFFSET                 (PAG11H_OFFSET + 0x98)

You still have code which implies page 0x10 and 0x11 follow directly after page 2. This is something i would like to avoid until we have a driver which really does export these pages. Please could you remove all this code.

Thanks
Andrew

#3 lore raw
Quoted 4 lines · Adrian Pop

Hi Andrew!

Should I resubmit v3 after I delete the code that has to do with page 0x10 and 0x11?

Yes please.

Andrew

author Tested-by Ido Schimmel
#4 lore raw

Hi Andrew!

I removed all the comments/constants/structs/functions that were assuming the existence of page 0x10 and 0x11. I sent v3 to Ido (before submitting it), he helped me test it and everything works fine. Please let me know if there's anything else that should be changed.

Also, I just noticed I forgot to sign-off the patch. Can the following lines be added by you or it's me who needs to add them by re-submitting?

Thank you!
Adrian

Quoted 10 lines · Andrew Lunn
Quoted 4 lines · Adrian Pop

Hi Andrew!

Should I resubmit v3 after I delete the code that has to do with page 0x10 and 0x11?

Yes please.

Andrew