Skip to contentSkip to conversation

sff-8636: report LOL / LOS / Tx Fault

PATCH Applied Jakub Kicinski 3 participants 6 messages Jun 13, 2023 – Jun 14, 2023

Subsystems (2)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/2 sff-8636: report LOL / LOS / Tx Fault

Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true.

---
v2: fix Rx / Tx for the "implemented" bit
v1: https://lore.kernel.org/all/[email protected]/

---
 qsfp.c       | 30 ++++++++++++++++++++++++++++++
 qsfp.h       |  8 ++++++++
 sff-common.c | 17 +++++++++++++++++
 sff-common.h |  2 ++
 4 files changed, 57 insertions(+)
qsfp.c +30 -0
index 1fe5de1a863f..5a535c5c092b 100644
@@ -872,6 +872,35 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map)
 	}
 }
 
+static void sff8636_show_signals(const struct sff8636_memory_map *map)
+{
+	unsigned int v;
+
+	/* There appears to be no Rx LOS support bit, use Tx for both */
+	if (map->page_00h[SFF8636_OPTION_4_OFFSET] & SFF8636_O4_TX_LOS) {
+		v = map->lower_memory[SFF8636_LOS_AW_OFFSET] & 0xf;
+		sff_show_lane_status("Rx loss of signal", 4, "Yes", "No", v);
+		v = map->lower_memory[SFF8636_LOS_AW_OFFSET] >> 4;
+		sff_show_lane_status("Tx loss of signal", 4, "Yes", "No", v);
+	}
+
+	v = map->lower_memory[SFF8636_LOL_AW_OFFSET] & 0xf;
+	if (map->page_00h[SFF8636_OPTION_3_OFFSET] & SFF8636_O3_RX_LOL)
+		sff_show_lane_status("Rx loss of lock", 4, "Yes", "No", v);
+
+	v = map->lower_memory[SFF8636_LOL_AW_OFFSET] >> 4;
+	if (map->page_00h[SFF8636_OPTION_3_OFFSET] & SFF8636_O3_TX_LOL)
+		sff_show_lane_status("Tx loss of lock", 4, "Yes", "No", v);
+
+	v = map->lower_memory[SFF8636_FAULT_AW_OFFSET] & 0xf;
+	if (map->page_00h[SFF8636_OPTION_4_OFFSET] & SFF8636_O4_TX_FAULT)
+		sff_show_lane_status("Tx fault", 4, "Yes", "No", v);
+
+	v = map->lower_memory[SFF8636_FAULT_AW_OFFSET] >> 4;
+	if (map->page_00h[SFF8636_OPTION_2_OFFSET] & SFF8636_O2_TX_EQ_AUTO)
+		sff_show_lane_status("Tx adaptive eq fault", 4, "Yes", "No", v);
+}
+
 static void sff8636_show_page_zero(const struct sff8636_memory_map *map)
 {
 	sff8636_show_ext_identifier(map);
@@ -905,6 +934,7 @@ static void sff8636_show_page_zero(const struct sff8636_memory_map *map)
 		       SFF8636_DATE_VENDOR_LOT_OFFSET + 1, "Date code");
 	sff_show_revision_compliance(map->lower_memory,
 				     SFF8636_REV_COMPLIANCE_OFFSET);
+	sff8636_show_signals(map);
 }
 
 static void sff8636_show_all_common(const struct sff8636_memory_map *map)
qsfp.h +8 -0
index aabf09fdc623..9f0cb0f7d55d 100644
@@ -55,6 +55,8 @@
 #define	 SFF8636_TX2_FAULT_AW	(1 << 1)
 #define	 SFF8636_TX1_FAULT_AW	(1 << 0)
 
+#define	SFF8636_LOL_AW_OFFSET	0x05
+
 /* Module Monitor Interrupt Flags - 6-8 */
 #define	SFF8636_TEMP_AW_OFFSET	0x06
 #define	 SFF8636_TEMP_HALARM_STATUS		(1 << 7)
@@ -525,9 +527,15 @@
 /*  56h-5Fh reserved */
 
 #define	 SFF8636_OPTION_2_OFFSET	0xC1
+/* Tx input equalizers auto-adaptive */
+#define	  SFF8636_O2_TX_EQ_AUTO		(1 << 3)
 /* Rx output amplitude */
 #define	  SFF8636_O2_RX_OUTPUT_AMP	(1 << 0)
 #define	 SFF8636_OPTION_3_OFFSET	0xC2
+/* Tx CDR Loss of Lock */
+#define	  SFF8636_O3_TX_LOL		(1 << 5)
+/* Rx CDR Loss of Lock */
+#define	  SFF8636_O3_RX_LOL		(1 << 4)
 /* Rx Squelch Disable */
 #define	  SFF8636_O3_RX_SQL_DSBL	(1 << 3)
 /* Rx Output Disable capable */
sff-common.c +17 -0
index e951cf15c1d6..a5c1510302a6 100644
@@ -53,6 +53,23 @@ void sff_show_ascii(const __u8 *id, unsigned int first_reg,
 	printf("\n");
 }
 
+void sff_show_lane_status(const char *name, unsigned int lane_cnt,
+			  const char *yes, const char *no, unsigned int value)
+{
+	printf("\t%-41s : ", name);
+	if (!value) {
+		printf("None\n");
+		return;
+	}
+
+	printf("[");
+	while (lane_cnt--) {
+		printf(" %s%c", value & 1 ? yes : no, lane_cnt ? ',': ' ');
+		value >>= 1;
+	}
+	printf("]\n");
+}
+
 void sff8024_show_oui(const __u8 *id, int id_offset)
 {
 	printf("\t%-41s : %02x:%02x:%02x\n", "Vendor OUI",
sff-common.h +2 -0
index dd12dda7bbce..57bcc4a415fe 100644
@@ -198,6 +198,8 @@ void sff_show_value_with_unit(const __u8 *id, unsigned int reg,
 			      const char *unit);
 void sff_show_ascii(const __u8 *id, unsigned int first_reg,
 		    unsigned int last_reg, const char *name);
+void sff_show_lane_status(const char *name, unsigned int lane_cnt,
+			  const char *yes, const char *no, unsigned int value);
 void sff_show_thresholds(struct sff_diags sd);
 
 void sff8024_show_oui(const __u8 *id, int id_offset);
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH v2 2/2 cmis: report LOL / LOS / Tx Fault

Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true.

---
Turns out I don't have access to any host with CMIS optics at this point so untested. I can only confirm it correctly shows nothing with a DAC...

---
 cmis.c | 39 +++++++++++++++++++++++++++++++++++++++
 cmis.h | 17 +++++++++++++++++
 2 files changed, 56 insertions(+)
cmis.c +39 -0
index d0b62728e998..531932ee7eeb 100644
@@ -139,6 +139,44 @@ static void cmis_show_rev_compliance(const struct cmis_memory_map *map)
 	printf("\t%-41s : Rev. %d.%d\n", "Revision compliance", major, minor);
 }
 
+static void
+cmis_show_signals_one(const struct cmis_memory_map *map, const char *name,
+		      int off, int ioff, unsigned int imask)
+{
+	unsigned int v;
+	int i;
+
+	if (!map->page_01h)
+		return;
+
+	v = 0;
+	for (i = 0; i < CMIS_MAX_BANKS && map->upper_memory[i][0x11]; i++)
+		v |= map->upper_memory[i][0x11][off] << (i * 8);
+
+	if (map->page_01h[ioff] & imask)
+		sff_show_lane_status(name, i * 8, "Yes", "No", v);
+}
+
+static void cmis_show_signals(const struct cmis_memory_map *map)
+{
+	cmis_show_signals_one(map, "Rx loss of signal", CMIS_RX_LOS_OFFSET,
+			      CMIS_DIAG_FLAGS_RX_OFFSET, CMIS_DIAG_FL_RX_LOS);
+	cmis_show_signals_one(map, "Tx loss of signal", CMIS_TX_LOS_OFFSET,
+			      CMIS_DIAG_FLAGS_TX_OFFSET, CMIS_DIAG_FL_TX_LOS);
+
+	cmis_show_signals_one(map, "Rx loss of lock", CMIS_RX_LOL_OFFSET,
+			      CMIS_DIAG_FLAGS_RX_OFFSET, CMIS_DIAG_FL_RX_LOL);
+	cmis_show_signals_one(map, "Tx loss of lock", CMIS_TX_LOL_OFFSET,
+			      CMIS_DIAG_FLAGS_TX_OFFSET, CMIS_DIAG_FL_TX_LOL);
+
+	cmis_show_signals_one(map, "Tx fault", CMIS_TX_FAIL_OFFSET,
+			      CMIS_DIAG_FLAGS_TX_OFFSET, CMIS_DIAG_FL_TX_FAIL);
+
+	cmis_show_signals_one(map, "Tx adaptive eq fault",
+			      CMIS_TX_EQ_FAIL_OFFSET, CMIS_DIAG_FLAGS_TX_OFFSET,
+			      CMIS_DIAG_FL_TX_ADAPTIVE_EQ_FAIL);
+}
+
 /**
  * Print information about the device's power consumption.
  * Relevant documents:
@@ -857,6 +895,7 @@ static void cmis_show_all_common(const struct cmis_memory_map *map)
 	cmis_show_link_len(map);
 	cmis_show_vendor_info(map);
 	cmis_show_rev_compliance(map);
+	cmis_show_signals(map);
 	cmis_show_mod_state(map);
 	cmis_show_mod_fault_cause(map);
 	cmis_show_mod_lvl_controls(map);
cmis.h +17 -0
index 46797081f13c..8d66f92dd971 100644
@@ -158,6 +158,17 @@
 #define CMIS_DIAG_TYPE_OFFSET			0x97
 #define CMIS_RX_PWR_TYPE_MASK			0x10
 
+/* Supported Flags Advertisement (Page 1) */
+#define CMIS_DIAG_FLAGS_TX_OFFSET		0x9d
+#define CMIS_DIAG_FL_TX_ADAPTIVE_EQ_FAIL	(1 << 3)
+#define CMIS_DIAG_FL_TX_LOL			(1 << 2)
+#define CMIS_DIAG_FL_TX_LOS			(1 << 1)
+#define CMIS_DIAG_FL_TX_FAIL			(1 << 0)
+
+#define CMIS_DIAG_FLAGS_RX_OFFSET		0x9e
+#define CMIS_DIAG_FL_RX_LOL			(1 << 2)
+#define CMIS_DIAG_FL_RX_LOS			(1 << 1)
+
 /* Supported Monitors Advertisement (Page 1) */
 #define CMIS_DIAG_CHAN_ADVER_OFFSET		0xA0
 #define CMIS_TX_BIAS_MON_MASK			0x01
@@ -207,6 +218,10 @@
  */
 
 /* Media Lane-Specific Flags (Page 0x11) */
+#define CMIS_TX_FAIL_OFFSET			0x87
+#define CMIS_TX_LOS_OFFSET			0x88
+#define CMIS_TX_LOL_OFFSET			0x89
+#define CMIS_TX_EQ_FAIL_OFFSET			0x8a
 #define CMIS_TX_PWR_AW_HALARM_OFFSET		0x8B
 #define CMIS_TX_PWR_AW_LALARM_OFFSET		0x8C
 #define CMIS_TX_PWR_AW_HWARN_OFFSET		0x8D
@@ -215,6 +230,8 @@
 #define CMIS_TX_BIAS_AW_LALARM_OFFSET		0x90
 #define CMIS_TX_BIAS_AW_HWARN_OFFSET		0x91
 #define CMIS_TX_BIAS_AW_LWARN_OFFSET		0x92
+#define CMIS_RX_LOS_OFFSET			0x93
+#define CMIS_RX_LOL_OFFSET			0x94
 #define CMIS_RX_PWR_AW_HALARM_OFFSET		0x95
 #define CMIS_RX_PWR_AW_LALARM_OFFSET		0x96
 #define CMIS_RX_PWR_AW_HWARN_OFFSET		0x97
Signature · 1 line
2.40.1
Reviewed-by Tested-by on v2 2/2
#2 lore raw

Re: [PATCH ethtool-next v2 2/2] cmis: report LOL / LOS / Tx Fault

In reply to Jakub Kicinski
Quoted 5 lines · Jakub Kicinski

Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true.

Quoted 4 lines

---
Turns out I don't have access to any host with CMIS optics at this point so untested. I can only confirm it correctly shows nothing with a DAC...

I'm not sure why, but the module I have reports two banks and therefore 16 lanes. "Tx fault" and "Tx adaptive eq fault" are not supported.

When both are up:

# ethtool -m swp11 | grep "Rx loss of signal" -A 4
        Rx loss of signal                         : None
        Tx loss of signal                         : None
        Rx loss of lock                           : None
        Tx loss of lock                           : None
        Module State                              : 0x03 (ModuleReady)

When I bring the other side down:

# ip link set dev swp12 down
# ethtool -m swp11 | grep "Rx loss of signal" -A 4
        Rx loss of signal                         : [ Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes ]
        Tx loss of signal                         : None
        Rx loss of lock                           : [ Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes ]
        Tx loss of lock                           : None
        Module State                              : 0x03 (ModuleReady)

When I bring the interface itself down:

# ip link set dev swp11 down
# ethtool -m swp11 | grep "Rx loss of signal" -A 4
        Rx loss of signal                         : [ Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes ]
        Tx loss of signal                         : [ Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, No, No, No, No, No, No, No, No ]
        Rx loss of lock                           : [ Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, No, No, No, No, No, No, No, No ]
        Tx loss of lock                           : [ Yes, Yes, Yes, Yes, Yes, Yes, Yes, Yes, No, No, No, No, No, No, No, No ]
        Module State                              : 0x03 (ModuleReady)

And I don't see these fields on PC:

# ethtool -m swp1 | grep "Rx loss of signal" -A 4
author maintainer
#3 lore raw

Re: [PATCH ethtool-next v2 2/2] cmis: report LOL / LOS / Tx Fault

Quoted 9 lines · On Tue, 13 Jun 2023 10:32:05 +0300 Ido Schimmel wrote:
Quoted 5 lines · Jakub Kicinski

Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true.

Thank you!

#5 lore raw
In reply to Jakub Kicinski
This series was applied to ethtool/ethtool.git (master) by Michal Kubecek <[email protected]>:

Hello:

This series was applied to ethtool/ethtool.git (master) by Michal Kubecek <[email protected]>:

Quoted 10 lines · On Mon, 12 Jun 2023 22:05:06 -0700 you wrote:

Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true.

---
v2: fix Rx / Tx for the "implemented" bit
v1: https://lore.kernel.org/all/[email protected]/

[...]

Here is the summary with links:
- [ethtool-next,v2,1/2] sff-8636: report LOL / LOS / Tx Fault

    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=045d8dbe4c52
  - [ethtool-next,v2,2/2] cmis: report LOL / LOS / Tx Fault
    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=b3e341c1a81b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html