From: Danielle Ratson <danieller@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <mkubecek@suse.cz>, <mlxsw@nvidia.com>,
Ido Schimmel <idosch@nvidia.com>,
Danielle Ratson <danieller@nvidia.com>
Subject: [PATCH ethtool-next v2 2/3] cmis: Print CDB messaging support advertisement
Date: Sun, 11 Aug 2024 14:59:47 +0300 [thread overview]
Message-ID: <20240811115948.3335883-3-danieller@nvidia.com> (raw)
In-Reply-To: <20240811115948.3335883-1-danieller@nvidia.com>
From: Ido Schimmel <idosch@nvidia.com>
Parse and print CDB messaging support advertisement information to aid
in debugging CDB related problems. Example output:
# ethtool -m swp23
Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628))
[...]
CDB instances : 1
CDB background mode : Supported
CDB EPL pages : 0
CDB Maximum EPL RW length : 128
CDB Maximum LPL RW length : 128
CDB trigger method : Single write
Fields that are not used by the CDB code in the kernel are not printed,
but can be added in the future, when needed.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
---
cmis.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cmis.h | 11 ++++++++
2 files changed, 91 insertions(+)
diff --git a/cmis.c b/cmis.c
index bbbbb47..6fe5dfb 100644
--- a/cmis.c
+++ b/cmis.c
@@ -928,6 +928,85 @@ static void cmis_show_fw_version(const struct cmis_memory_map *map)
cmis_show_fw_inactive_version(map);
}
+static u8 cmis_cdb_instances_get(const struct cmis_memory_map *map)
+{
+ return (map->page_01h[CMIS_CDB_ADVER_OFFSET] &
+ CMIS_CDB_ADVER_INSTANCES_MASK) >> 6;
+}
+
+static bool cmis_cdb_is_supported(const struct cmis_memory_map *map)
+{
+ __u8 cdb_instances = cmis_cdb_instances_get(map);
+
+ /* Up to two CDB instances are supported. */
+ return cdb_instances == 1 || cdb_instances == 2;
+}
+
+static void cmis_show_cdb_instances(const struct cmis_memory_map *map)
+{
+ __u8 cdb_instances = cmis_cdb_instances_get(map);
+
+ printf("\t%-41s : %u\n", "CDB instances", cdb_instances);
+}
+
+static void cmis_show_cdb_mode(const struct cmis_memory_map *map)
+{
+ __u8 mode = map->page_01h[CMIS_CDB_ADVER_OFFSET] &
+ CMIS_CDB_ADVER_MODE_MASK;
+
+ printf("\t%-41s : %s\n", "CDB background mode",
+ mode ? "Supported" : "Not supported");
+}
+
+static void cmis_show_cdb_epl_pages(const struct cmis_memory_map *map)
+{
+ __u8 epl_pages = map->page_01h[CMIS_CDB_ADVER_OFFSET] &
+ CMIS_CDB_ADVER_EPL_MASK;
+
+ printf("\t%-41s : %u\n", "CDB EPL pages", epl_pages);
+}
+
+static void cmis_show_cdb_rw_len(const struct cmis_memory_map *map)
+{
+ __u16 rw_len = map->page_01h[CMIS_CDB_ADVER_RW_LEN_OFFSET];
+
+ /* Maximum read / write length for CDB EPL pages and the LPL page in
+ * units of 8 bytes, in addition to the minimum 8 bytes.
+ */
+ rw_len = (rw_len + 1) * 8;
+ printf("\t%-41s : %u\n", "CDB Maximum EPL RW length", rw_len);
+ printf("\t%-41s : %u\n", "CDB Maximum LPL RW length",
+ rw_len > CMIS_PAGE_SIZE ? CMIS_PAGE_SIZE : rw_len);
+}
+
+static void cmis_show_cdb_trigger(const struct cmis_memory_map *map)
+{
+ __u8 trigger = map->page_01h[CMIS_CDB_ADVER_TRIGGER_OFFSET] &
+ CMIS_CDB_ADVER_TRIGGER_MASK;
+
+ /* Whether a CDB command can be triggered in a single write to the LPL
+ * page, or by multiple writes ending with the writing of the CDB
+ * Command Code (CMDID).
+ */
+ printf("\t%-41s : %s\n", "CDB trigger method",
+ trigger ? "Single write" : "Multiple writes");
+}
+
+/* Print CDB messaging support advertisement. Relevant documents:
+ * [1] CMIS Rev. 5, page 133, section 8.4.11
+ */
+static void cmis_show_cdb_adver(const struct cmis_memory_map *map)
+{
+ if (!map->page_01h || !cmis_cdb_is_supported(map))
+ return;
+
+ cmis_show_cdb_instances(map);
+ cmis_show_cdb_mode(map);
+ cmis_show_cdb_epl_pages(map);
+ cmis_show_cdb_rw_len(map);
+ cmis_show_cdb_trigger(map);
+}
+
static void cmis_show_all_common(const struct cmis_memory_map *map)
{
cmis_show_identifier(map);
@@ -945,6 +1024,7 @@ static void cmis_show_all_common(const struct cmis_memory_map *map)
cmis_show_mod_lvl_controls(map);
cmis_show_dom(map);
cmis_show_fw_version(map);
+ cmis_show_cdb_adver(map);
}
static void cmis_memory_map_init_buf(struct cmis_memory_map *map,
diff --git a/cmis.h b/cmis.h
index 3015c54..cee2a38 100644
--- a/cmis.h
+++ b/cmis.h
@@ -191,6 +191,17 @@
#define CMIS_SIG_INTEG_TX_OFFSET 0xA1
#define CMIS_SIG_INTEG_RX_OFFSET 0xA2
+/* CDB Messaging Support Advertisement */
+#define CMIS_CDB_ADVER_OFFSET 0xA3
+#define CMIS_CDB_ADVER_INSTANCES_MASK 0xC0
+#define CMIS_CDB_ADVER_MODE_MASK 0x20
+#define CMIS_CDB_ADVER_EPL_MASK 0x0F
+
+#define CMIS_CDB_ADVER_RW_LEN_OFFSET 0xA4
+
+#define CMIS_CDB_ADVER_TRIGGER_OFFSET 0xA5
+#define CMIS_CDB_ADVER_TRIGGER_MASK 0x80
+
/*-----------------------------------------------------------------------
* Upper Memory Page 0x02: Optional Page that informs about module-defined
* thresholds for module-level and lane-specific threshold crossing monitors.
--
2.45.0
next prev parent reply other threads:[~2024-08-11 12:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-11 11:59 [PATCH ethtool-next v2 0/3] Add ability to flash modules' firmware Danielle Ratson
2024-08-11 11:59 ` [PATCH ethtool-next v2 1/3] cmis: Print active and inactive firmware versions Danielle Ratson
2024-08-11 11:59 ` Danielle Ratson [this message]
2024-08-11 11:59 ` [PATCH ethtool-next v2 3/3] ethtool: Add ability to flash transceiver modules' firmware Danielle Ratson
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=20240811115948.3335883-3-danieller@nvidia.com \
--to=danieller@nvidia.com \
--cc=idosch@nvidia.com \
--cc=mkubecek@suse.cz \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).