From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: mkubecek@suse.cz, danieller@nvidia.com, Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH ethtool 4/8] module-common: Fix printing of transmitter technology for CMIS transceivers
Date: Thu, 16 Jul 2026 09:45:28 +0300 [thread overview]
Message-ID: <20260716064532.1522382-5-idosch@nvidia.com> (raw)
In-Reply-To: <20260716064532.1522382-1-idosch@nvidia.com>
In CMIS, the transceiver technology is encoded in the
"MediaInterfaceTechnology" field which is 8-bits, while in SFF-8636 it
is encoded in the 4 MSBs of the "Device Technology" field. Both
specifications share the same encoding for the common values (0-15), but
CMIS supports more values given the field is 8-bits.
Given the common encoding, cited commit consolidated the printing of
this field between CMIS and SFF-8636. The CMIS parser passes the
"MediaInterfaceTechnology" field and the SFF-8636 parser passes the
"Device Technology" field while masking the 4 LSBs. This creates a
situation where both parsers pass different values for the same
transmitter technology (e.g., "1310 nm VCSEL" is 0x01 in CMIS and 0x10
in SFF-8636). To overcome this, the common code matches on two values
for each transmitter technology.
While this works most of the time, it is going to create a problem for
CMIS transceivers that utilize the 4 MSBs of the
"MediaInterfaceTechnology" field.
Fix by creating a common encoding for the transmitter technology field
and have the SFF-8636 parser pass the shifted value of the "Device
Technology" field to the common code. That way both parsers pass the
same value for a given transmitter technology.
Fixes: 504c4f573571 ("module_common: Add a new file to all the common code for all module types")
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
cmis.c | 4 ++--
module-common.c | 47 +++++++++++++++-----------------------------
module-common.h | 52 +++++++++++++++----------------------------------
qsfp.c | 5 ++---
4 files changed, 36 insertions(+), 72 deletions(-)
diff --git a/cmis.c b/cmis.c
index da1ced75e4ef..19a3eb7cf925 100644
--- a/cmis.c
+++ b/cmis.c
@@ -254,11 +254,11 @@ static void cmis_show_sig_integrity(const struct cmis_memory_map *map)
*/
static void cmis_show_mit_compliance(const struct cmis_memory_map *map)
{
- u16 value = map->page_00h[CMIS_MEDIA_INTF_TECH_OFFSET];
+ __u8 value = map->page_00h[CMIS_MEDIA_INTF_TECH_OFFSET];
module_show_mit_compliance(value);
- if (value >= CMIS_COPPER_UNEQUAL) {
+ if (value >= MODULE_TT_COPPER_UNEQUAL) {
module_print_any_uint("Attenuation at 5GHz",
map->page_00h[CMIS_COPPER_ATT_5GHZ], "db");
module_print_any_uint("Attenuation at 7GHz",
diff --git a/module-common.c b/module-common.c
index 42fccf68301b..997dd2b37ce7 100644
--- a/module-common.c
+++ b/module-common.c
@@ -575,71 +575,56 @@ void module_show_mit_compliance(u16 value)
char description[SFF_MAX_DESC_LEN];
switch (value) {
- case MODULE_850_VCSEL:
+ case MODULE_TT_850_VCSEL:
strncpy(description, "850 nm VCSEL", SFF_MAX_DESC_LEN);
break;
- case CMIS_1310_VCSEL:
- case SFF8636_TRANS_1310_VCSEL:
+ case MODULE_TT_1310_VCSEL:
strncpy(description, "1310 nm VCSEL", SFF_MAX_DESC_LEN);
break;
- case CMIS_1550_VCSEL:
- case SFF8636_TRANS_1550_VCSEL:
+ case MODULE_TT_1550_VCSEL:
strncpy(description, "1550 nm VCSEL", SFF_MAX_DESC_LEN);
break;
- case CMIS_1310_FP:
- case SFF8636_TRANS_1310_FP:
+ case MODULE_TT_1310_FP:
strncpy(description, "1310 nm FP", SFF_MAX_DESC_LEN);
break;
- case CMIS_1310_DFB:
- case SFF8636_TRANS_1310_DFB:
+ case MODULE_TT_1310_DFB:
strncpy(description, "1310 nm DFB", SFF_MAX_DESC_LEN);
break;
- case CMIS_1550_DFB:
- case SFF8636_TRANS_1550_DFB:
+ case MODULE_TT_1550_DFB:
strncpy(description, "1550 nm DFB", SFF_MAX_DESC_LEN);
break;
- case CMIS_1310_EML:
- case SFF8636_TRANS_1310_EML:
+ case MODULE_TT_1310_EML:
strncpy(description, "1310 nm EML", SFF_MAX_DESC_LEN);
break;
- case CMIS_1550_EML:
- case SFF8636_TRANS_1550_EML:
+ case MODULE_TT_1550_EML:
strncpy(description, "1550 nm EML", SFF_MAX_DESC_LEN);
break;
- case CMIS_OTHERS:
- case SFF8636_TRANS_OTHERS:
+ case MODULE_TT_OTHERS:
strncpy(description, "Others/Undefined", SFF_MAX_DESC_LEN);
break;
- case CMIS_1490_DFB:
- case SFF8636_TRANS_1490_DFB:
+ case MODULE_TT_1490_DFB:
strncpy(description, "1490 nm DFB", SFF_MAX_DESC_LEN);
break;
- case CMIS_COPPER_UNEQUAL:
- case SFF8636_TRANS_COPPER_PAS_UNEQUAL:
+ case MODULE_TT_COPPER_UNEQUAL:
snprintf(description, SFF_MAX_DESC_LEN, "%s unequalized", cc);
break;
- case CMIS_COPPER_PASS_EQUAL:
- case SFF8636_TRANS_COPPER_PAS_EQUAL:
+ case MODULE_TT_COPPER_PASS_EQUAL:
snprintf(description, SFF_MAX_DESC_LEN, "%s passive equalized",
cc);
break;
- case CMIS_COPPER_NF_EQUAL:
- case SFF8636_TRANS_COPPER_LNR_FAR_EQUAL:
+ case MODULE_TT_COPPER_NF_EQUAL:
snprintf(description, SFF_MAX_DESC_LEN,
"%s near and far end limiting active equalizers", cc);
break;
- case CMIS_COPPER_F_EQUAL:
- case SFF8636_TRANS_COPPER_FAR_EQUAL:
+ case MODULE_TT_COPPER_F_EQUAL:
snprintf(description, SFF_MAX_DESC_LEN,
"%s far end limiting active equalizers", cc);
break;
- case CMIS_COPPER_N_EQUAL:
- case SFF8636_TRANS_COPPER_NEAR_EQUAL:
+ case MODULE_TT_COPPER_N_EQUAL:
snprintf(description, SFF_MAX_DESC_LEN,
"%s near end limiting active equalizers", cc);
break;
- case CMIS_COPPER_LINEAR_EQUAL:
- case SFF8636_TRANS_COPPER_LNR_EQUAL:
+ case MODULE_TT_COPPER_LINEAR_EQUAL:
snprintf(description, SFF_MAX_DESC_LEN, "%s linear active equalizers",
cc);
break;
diff --git a/module-common.h b/module-common.h
index 4063448f3eea..fba1d36f7f86 100644
--- a/module-common.h
+++ b/module-common.h
@@ -83,42 +83,22 @@ enum module_type {
#define MODULE_CTOR_VENDOR_LAST 0xFF
/* Transmitter Technology */
-#define MODULE_850_VCSEL 0x00
-
-/* SFF8636 */
-#define SFF8636_TRANS_TECH_MASK 0xF0
-#define SFF8636_TRANS_COPPER_LNR_EQUAL (15 << 4)
-#define SFF8636_TRANS_COPPER_NEAR_EQUAL (14 << 4)
-#define SFF8636_TRANS_COPPER_FAR_EQUAL (13 << 4)
-#define SFF8636_TRANS_COPPER_LNR_FAR_EQUAL (12 << 4)
-#define SFF8636_TRANS_COPPER_PAS_EQUAL (11 << 4)
-#define SFF8636_TRANS_COPPER_PAS_UNEQUAL (10 << 4)
-#define SFF8636_TRANS_1490_DFB (9 << 4)
-#define SFF8636_TRANS_OTHERS (8 << 4)
-#define SFF8636_TRANS_1550_EML (7 << 4)
-#define SFF8636_TRANS_1310_EML (6 << 4)
-#define SFF8636_TRANS_1550_DFB (5 << 4)
-#define SFF8636_TRANS_1310_DFB (4 << 4)
-#define SFF8636_TRANS_1310_FP (3 << 4)
-#define SFF8636_TRANS_1550_VCSEL (2 << 4)
-#define SFF8636_TRANS_1310_VCSEL (1 << 4)
-
-/* CMIS */
-#define CMIS_1310_VCSEL 0x01
-#define CMIS_1550_VCSEL 0x02
-#define CMIS_1310_FP 0x03
-#define CMIS_1310_DFB 0x04
-#define CMIS_1550_DFB 0x05
-#define CMIS_1310_EML 0x06
-#define CMIS_1550_EML 0x07
-#define CMIS_OTHERS 0x08
-#define CMIS_1490_DFB 0x09
-#define CMIS_COPPER_UNEQUAL 0x0A
-#define CMIS_COPPER_PASS_EQUAL 0x0B
-#define CMIS_COPPER_NF_EQUAL 0x0C
-#define CMIS_COPPER_F_EQUAL 0x0D
-#define CMIS_COPPER_N_EQUAL 0x0E
-#define CMIS_COPPER_LINEAR_EQUAL 0x0F
+#define MODULE_TT_850_VCSEL 0x00
+#define MODULE_TT_1310_VCSEL 0x01
+#define MODULE_TT_1550_VCSEL 0x02
+#define MODULE_TT_1310_FP 0x03
+#define MODULE_TT_1310_DFB 0x04
+#define MODULE_TT_1550_DFB 0x05
+#define MODULE_TT_1310_EML 0x06
+#define MODULE_TT_1550_EML 0x07
+#define MODULE_TT_OTHERS 0x08
+#define MODULE_TT_1490_DFB 0x09
+#define MODULE_TT_COPPER_UNEQUAL 0x0A
+#define MODULE_TT_COPPER_PASS_EQUAL 0x0B
+#define MODULE_TT_COPPER_NF_EQUAL 0x0C
+#define MODULE_TT_COPPER_F_EQUAL 0x0D
+#define MODULE_TT_COPPER_N_EQUAL 0x0E
+#define MODULE_TT_COPPER_LINEAR_EQUAL 0x0F
/* Module Flags (Page 0) */
#define CMIS_VCC_AW_OFFSET 0x09
diff --git a/qsfp.c b/qsfp.c
index c82a3dec9b0b..20b6c2173284 100644
--- a/qsfp.c
+++ b/qsfp.c
@@ -562,12 +562,11 @@ static void sff8636_show_rate_identifier(const struct sff8636_memory_map *map)
static void
sff8636_show_wavelength_or_copper_compliance(const struct sff8636_memory_map *map)
{
- u16 value = map->page_00h[SFF8636_DEVICE_TECH_OFFSET] &
- SFF8636_TRANS_TECH_MASK;
+ __u8 value = map->page_00h[SFF8636_DEVICE_TECH_OFFSET] >> 4;
module_show_mit_compliance(value);
- if (value >= SFF8636_TRANS_COPPER_PAS_UNEQUAL) {
+ if (value >= MODULE_TT_COPPER_UNEQUAL) {
module_print_any_uint("Attenuation at 2.5GHz",
map->page_00h[SFF8636_WAVELEN_HIGH_BYTE_OFFSET],
"db");
--
2.55.0
next prev parent reply other threads:[~2026-07-16 6:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 6:45 [PATCH ethtool 0/8] cmis: Miscellaneous fixes Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 1/8] cmis: Fix printing of Tx bias current Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 2/8] cmis: Fix printing of channel-level flags Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 3/8] cmis: Fix printing of CDB EPL pages Ido Schimmel
2026-07-16 6:45 ` Ido Schimmel [this message]
2026-07-16 6:45 ` [PATCH ethtool 5/8] module-common: Avoid undefined behavior with CMIS transceivers Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 6/8] module-common: Add missing CMIS transmitter technologies Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 7/8] cmis: Fix printing of attenuation and wavelength Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 8/8] cmis: Fix printing of link length Ido Schimmel
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=20260716064532.1522382-5-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=danieller@nvidia.com \
--cc=mkubecek@suse.cz \
--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