Netdev List
 help / color / mirror / Atom feed
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 3/8] cmis: Fix printing of CDB EPL pages
Date: Thu, 16 Jul 2026 09:45:27 +0300	[thread overview]
Message-ID: <20260716064532.1522382-4-idosch@nvidia.com> (raw)
In-Reply-To: <20260716064532.1522382-1-idosch@nvidia.com>

The "CdbMaxPagesEPL" field is 4-bits. The code currently assumes that
the value of the field directly determines the number of EPL pages, but
values 5 / 6 / 7 correspond to 8 / 12 / 16 EPL pages.

Fix the printing of the number of EPL pages by using a translation table
and avoid printing the field if the value is reserved (i.e., 8-15).

Fixes: fe8e296aa023 ("cmis: Print CDB messaging support advertisement")
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 cmis.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/cmis.c b/cmis.c
index 16f168a3b1af..da1ced75e4ef 100644
--- a/cmis.c
+++ b/cmis.c
@@ -924,10 +924,14 @@ static void cmis_show_cdb_mode(const struct cmis_memory_map *map)
 
 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;
+	static const __u8 epl_page_count[] = { 0, 1, 2, 3, 4, 8, 12, 16 };
+	__u8 epl = map->page_01h[CMIS_CDB_ADVER_OFFSET] &
+		CMIS_CDB_ADVER_EPL_MASK;
 
-	module_print_any_uint("CDB EPL pages", epl_pages, NULL);
+	if (epl >= ARRAY_SIZE(epl_page_count))
+		return;
+
+	module_print_any_uint("CDB EPL pages", epl_page_count[epl], NULL);
 }
 
 static void cmis_show_cdb_rw_len(const struct cmis_memory_map *map)
-- 
2.55.0


  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 ` Ido Schimmel [this message]
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-4-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