[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210818155306.1278356-4-idosch@idosch.org>
Date: Wed, 18 Aug 2021 18:53:03 +0300
From: Ido Schimmel <idosch@...sch.org>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, andrew@...n.ch,
mkubecek@...e.cz, pali@...nel.org, jacob.e.keller@...el.com,
jiri@...dia.com, vadimp@...dia.com, mlxsw@...dia.com,
Ido Schimmel <idosch@...dia.com>
Subject: [RFC PATCH ethtool-next v2 3/6] ethtool: Print CMIS Module State
From: Ido Schimmel <idosch@...dia.com>
Print the CMIS Module State when dumping EEPROM contents via the '-m'
option. It can be used, for example, to test module power mode settings.
Example output:
# ethtool -m swp11
Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628))
...
Module State : 0x03 (ModuleReady)
# ethtool --set-module swp11 power-mode-policy low
# ethtool -m swp11
Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628))
...
Module State : 0x01 (ModuleLowPwr)
In case the module is in fault state, print the CMIS Module Fault Cause.
Signed-off-by: Ido Schimmel <idosch@...dia.com>
---
cmis.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cmis.h | 15 +++++++++++++
2 files changed, 86 insertions(+)
diff --git a/cmis.c b/cmis.c
index 361b721f332f..c5c1f02398f6 100644
--- a/cmis.c
+++ b/cmis.c
@@ -42,6 +42,73 @@ static void cmis_show_rev_compliance(const __u8 *id)
printf("\t%-41s : Rev. %d.%d\n", "Revision compliance", major, minor);
}
+/**
+ * Print the current Module State. Relevant documents:
+ * [1] CMIS Rev. 5, pag. 57, section 6.3.2.2, Figure 6-3
+ * [2] CMIS Rev. 5, pag. 60, section 6.3.2.3, Figure 6-4
+ * [3] CMIS Rev. 5, pag. 107, section 8.2.2, Table 8-6
+ */
+static void cmis_show_mod_state(const __u8 *id)
+{
+ __u8 mod_state = (id[CMIS_MODULE_STATE_OFFSET] >> 1) & 0x07;
+
+ printf("\t%-41s : 0x%02x", "Module State", mod_state);
+ switch (mod_state) {
+ case CMIS_MODULE_STATE_MODULE_LOW_PWR:
+ printf(" (ModuleLowPwr)\n");
+ break;
+ case CMIS_MODULE_STATE_MODULE_PWR_UP:
+ printf(" (ModulePwrUp)\n");
+ break;
+ case CMIS_MODULE_STATE_MODULE_READY:
+ printf(" (ModuleReady)\n");
+ break;
+ case CMIS_MODULE_STATE_MODULE_PWR_DN:
+ printf(" (ModulePwrDn)\n");
+ break;
+ case CMIS_MODULE_STATE_MODULE_FAULT:
+ printf(" (ModuleFault)\n");
+ break;
+ default:
+ printf(" (reserved or unknown)\n");
+ break;
+ }
+}
+
+/**
+ * Print the Module Fault Information. Relevant documents:
+ * [1] CMIS Rev. 5, pag. 64, section 6.3.2.12
+ * [2] CMIS Rev. 5, pag. 115, section 8.2.10, Table 8-15
+ */
+static void cmis_show_mod_fault_cause(const __u8 *id)
+{
+ __u8 mod_state = (id[CMIS_MODULE_STATE_OFFSET] >> 1) & 0x07;
+ __u8 fault_cause = id[CMIS_MODULE_FAULT_OFFSET];
+
+ if (mod_state != CMIS_MODULE_STATE_MODULE_FAULT)
+ return;
+
+ printf("\t%-41s : 0x%02x", "Module Fault Cause", fault_cause);
+ switch (fault_cause) {
+ case CMIS_MODULE_FAULT_NO_FAULT:
+ printf(" (No fault detected / not supported)\n");
+ break;
+ case CMIS_MODULE_FAULT_TEC_RUNAWAY:
+ printf(" (TEC runaway)\n");
+ break;
+ case CMIS_MODULE_FAULT_DATA_MEM_CORRUPTED:
+ printf(" (Data memory corrupted)\n");
+ break;
+ case CMIS_MODULE_FAULT_PROG_MEM_CORRUPTED:
+ printf(" (Program memory corrupted)\n");
+ break;
+ default:
+ printf(" (reserved or unknown)\n");
+ break;
+ }
+}
+
+
/**
* Print information about the device's power consumption.
* Relevant documents:
@@ -336,6 +403,8 @@ void qsfp_dd_show_all(const __u8 *id)
cmis_show_link_len(id);
cmis_show_vendor_info(id);
cmis_show_rev_compliance(id);
+ cmis_show_mod_state(id);
+ cmis_show_mod_fault_cause(id);
}
void cmis_show_all(const struct ethtool_module_eeprom *page_zero,
@@ -356,4 +425,6 @@ void cmis_show_all(const struct ethtool_module_eeprom *page_zero,
cmis_show_vendor_info(page_zero_data);
cmis_show_rev_compliance(page_zero_data);
+ cmis_show_mod_state(page_zero_data);
+ cmis_show_mod_fault_cause(page_zero_data);
}
diff --git a/cmis.h b/cmis.h
index 78ee1495bc33..41383132cf8e 100644
--- a/cmis.h
+++ b/cmis.h
@@ -5,6 +5,21 @@
#define CMIS_ID_OFFSET 0x00
#define CMIS_REV_COMPLIANCE_OFFSET 0x01
+/* Module State (Page 0) */
+#define CMIS_MODULE_STATE_OFFSET 0x03
+#define CMIS_MODULE_STATE_MODULE_LOW_PWR 0x01
+#define CMIS_MODULE_STATE_MODULE_PWR_UP 0x02
+#define CMIS_MODULE_STATE_MODULE_READY 0x03
+#define CMIS_MODULE_STATE_MODULE_PWR_DN 0x04
+#define CMIS_MODULE_STATE_MODULE_FAULT 0x05
+
+/* Module Fault Information (Page 0) */
+#define CMIS_MODULE_FAULT_OFFSET 0x29
+#define CMIS_MODULE_FAULT_NO_FAULT 0
+#define CMIS_MODULE_FAULT_TEC_RUNAWAY 1
+#define CMIS_MODULE_FAULT_DATA_MEM_CORRUPTED 2
+#define CMIS_MODULE_FAULT_PROG_MEM_CORRUPTED 3
+
#define CMIS_MODULE_TYPE_OFFSET 0x55
#define CMIS_MT_MMF 0x01
#define CMIS_MT_SMF 0x02
--
2.31.1
Powered by blists - more mailing lists