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 1/8] cmis: Fix printing of Tx bias current
Date: Thu, 16 Jul 2026 09:45:25 +0300 [thread overview]
Message-ID: <20260716064532.1522382-2-idosch@nvidia.com> (raw)
In-Reply-To: <20260716064532.1522382-1-idosch@nvidia.com>
In CMIS, unlike SFF-8636 and SFF-8472, the Tx bias current can be scaled
(i.e., multiplied by 1 / 2 / 4). Fix the application of the scaling
factor from shift right to shift left. In addition, increase the size of
the field that stores the scaled value from 16-bits to 32-bits to avoid
truncation.
Fixes: 340d88ee1289 ("cmis: Parse and print diagnostic information")
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
cmis.c | 10 +++++-----
sff-common.h | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmis.c b/cmis.c
index f494268ba3b7..a4bf455c2a77 100644
--- a/cmis.c
+++ b/cmis.c
@@ -517,7 +517,7 @@ cmis_parse_dom_chan_lvl_monitors_bank(const struct cmis_memory_map *map,
sd->scd[chan].bias_cur = OFFSET_TO_U16_PTR(page_11h,
tx_bias_offset);
- sd->scd[chan].bias_cur >>= bias_mul;
+ sd->scd[chan].bias_cur <<= bias_mul;
sd->scd[chan].rx_power = OFFSET_TO_U16_PTR(page_11h,
rx_power_offset);
sd->scd[chan].tx_power = OFFSET_TO_U16_PTR(page_11h,
@@ -544,16 +544,16 @@ static void cmis_parse_dom_chan_lvl_thresh(const struct cmis_memory_map *map,
sd->bias_cur[HALRM] = OFFSET_TO_U16_PTR(map->page_02h,
CMIS_TX_BIAS_HALRM_OFFSET);
- sd->bias_cur[HALRM] >>= bias_mul;
+ sd->bias_cur[HALRM] <<= bias_mul;
sd->bias_cur[LALRM] = OFFSET_TO_U16_PTR(map->page_02h,
CMIS_TX_BIAS_LALRM_OFFSET);
- sd->bias_cur[LALRM] >>= bias_mul;
+ sd->bias_cur[LALRM] <<= bias_mul;
sd->bias_cur[HWARN] = OFFSET_TO_U16_PTR(map->page_02h,
CMIS_TX_BIAS_HWARN_OFFSET);
- sd->bias_cur[HWARN] >>= bias_mul;
+ sd->bias_cur[HWARN] <<= bias_mul;
sd->bias_cur[LWARN] = OFFSET_TO_U16_PTR(map->page_02h,
CMIS_TX_BIAS_LWARN_OFFSET);
- sd->bias_cur[LWARN] >>= bias_mul;
+ sd->bias_cur[LWARN] <<= bias_mul;
sd->tx_power[HALRM] = OFFSET_TO_U16_PTR(map->page_02h,
CMIS_TX_PWR_HALRM_OFFSET);
diff --git a/sff-common.h b/sff-common.h
index 3c02a69ec7f6..59ae21038c9c 100644
--- a/sff-common.h
+++ b/sff-common.h
@@ -126,7 +126,7 @@
/* Channel Monitoring Fields */
struct sff_channel_diags {
- __u16 bias_cur; /* Measured bias current in 2uA units */
+ __u32 bias_cur; /* Measured bias current in 2uA units */
__u16 rx_power; /* Measured RX Power */
__u16 tx_power; /* Measured TX Power */
};
@@ -157,7 +157,7 @@ struct sff_diags {
/* SFP Temp in 16-bit signed 1/256 Celcius */
__s16 sfp_temp[5];
/* Measured bias current in 2uA units */
- __u16 bias_cur[5];
+ __u32 bias_cur[5];
/* Measured TX Power */
__u16 tx_power[5];
/* Measured RX Power */
--
2.55.0
next prev parent reply other threads:[~2026-07-16 6:46 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 ` Ido Schimmel [this message]
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 ` [PATCH ethtool 4/8] module-common: Fix printing of transmitter technology for CMIS transceivers Ido Schimmel
2026-07-16 6:45 ` [PATCH ethtool 5/8] module-common: Avoid undefined behavior with " 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-2-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