All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: mkubecek@suse.cz, idosch@nvidia.com
Cc: danieller@nvidia.com, netdev@vger.kernel.org,
	vladyslavt@nvidia.com, linux@armlinux.org.uk, andrew@lunn.ch,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH ethtool-next v2 2/2] cmis: report LOL / LOS / Tx Fault
Date: Mon, 12 Jun 2023 22:05:07 -0700	[thread overview]
Message-ID: <20230613050507.1899596-2-kuba@kernel.org> (raw)
In-Reply-To: <20230613050507.1899596-1-kuba@kernel.org>

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
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(+)

diff --git a/cmis.c b/cmis.c
index d0b62728e998..531932ee7eeb 100644
--- a/cmis.c
+++ b/cmis.c
@@ -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);
diff --git a/cmis.h b/cmis.h
index 46797081f13c..8d66f92dd971 100644
--- a/cmis.h
+++ b/cmis.h
@@ -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
-- 
2.40.1


  reply	other threads:[~2023-06-13  5:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13  5:05 [PATCH ethtool-next v2 1/2] sff-8636: report LOL / LOS / Tx Fault Jakub Kicinski
2023-06-13  5:05 ` Jakub Kicinski [this message]
2023-06-13  7:32   ` [PATCH ethtool-next v2 2/2] cmis: " Ido Schimmel
2023-06-13 16:48     ` Jakub Kicinski
2023-06-13  7:06 ` [PATCH ethtool-next v2 1/2] sff-8636: " Ido Schimmel
2023-06-14 18:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230613050507.1899596-2-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=danieller@nvidia.com \
    --cc=idosch@nvidia.com \
    --cc=linux@armlinux.org.uk \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=vladyslavt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.