From: Danielle Ratson <danieller@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <mkubecek@suse.cz>, <matt@traverse.com.au>,
<daniel.zahka@gmail.com>, <amcohen@nvidia.com>,
<nbu-mlxsw@exchange.nvidia.com>,
Danielle Ratson <danieller@nvidia.com>
Subject: [PATCH ethtool-next v2 03/14] cmis: Change loop order in cmis_show_dom_chan_lvl_flags()
Date: Wed, 29 Jan 2025 15:15:36 +0200 [thread overview]
Message-ID: <20250129131547.964711-4-danieller@nvidia.com> (raw)
In-Reply-To: <20250129131547.964711-1-danieller@nvidia.com>
Currently, when printing channel-level flags in ethtool dump, we are
going over the banks, and for each bank, we are printing all the flags.
When JSON support will be added, in per-channel fields we would like to
have an array that each of its elements represents a channel.
Therefore, change the loop order so first we loop over the flags, and
for each one, we print all its channels.
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
---
cmis.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/cmis.c b/cmis.c
index 71f0745..9d89a5e 100644
--- a/cmis.c
+++ b/cmis.c
@@ -683,22 +683,19 @@ static void cmis_show_dom_mod_lvl_flags(const struct cmis_memory_map *map)
* [1] CMIS Rev. 5, page 162, section 8.9.3, Table 8-77
* [1] CMIS Rev. 5, page 164, section 8.9.3, Table 8-78
*/
-static void cmis_show_dom_chan_lvl_flags_chan(const struct cmis_memory_map *map,
- int bank, int chan)
+static void cmis_show_dom_chan_lvl_flag(const struct cmis_memory_map *map,
+ int bank, int flag)
{
const __u8 *page_11h = map->upper_memory[bank][0x11];
int i;
- for (i = 0; module_aw_chan_flags[i].fmt_str; i++) {
+ for (i = 0; i < CMIS_CHANNELS_PER_BANK; i++) {
+ int chan = bank * CMIS_CHANNELS_PER_BANK + i;
char str[80];
- if (!(map->page_01h[module_aw_chan_flags[i].adver_offset] &
- module_aw_chan_flags[i].adver_value))
- continue;
-
- snprintf(str, 80, module_aw_chan_flags[i].fmt_str, chan + 1);
+ snprintf(str, 80, module_aw_chan_flags[flag].fmt_str, chan + 1);
printf("\t%-41s : %s\n", str,
- page_11h[module_aw_chan_flags[i].offset] & chan ?
+ page_11h[module_aw_chan_flags[flag].offset] & chan ?
"On" : "Off");
}
}
@@ -708,15 +705,17 @@ cmis_show_dom_chan_lvl_flags_bank(const struct cmis_memory_map *map,
int bank)
{
const __u8 *page_11h = map->upper_memory[bank][0x11];
- int i;
+ int flag;
if (!page_11h)
return;
- for (i = 0; i < CMIS_CHANNELS_PER_BANK; i++) {
- int chan = bank * CMIS_CHANNELS_PER_BANK + i;
+ for (flag = 0; module_aw_chan_flags[flag].fmt_str; flag++) {
+ if (!(map->page_01h[module_aw_chan_flags[flag].adver_offset] &
+ module_aw_chan_flags[flag].adver_value))
+ continue;
- cmis_show_dom_chan_lvl_flags_chan(map, bank, chan);
+ cmis_show_dom_chan_lvl_flag(map, bank, flag);
}
}
--
2.47.0
next prev parent reply other threads:[~2025-01-29 13:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-29 13:15 [PATCH ethtool-next v2 00/14] Add JSON output to --module-info Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 01/14] module_common: Add a new file to all the common code for all module types Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 02/14] sff_common: Move sff_show_revision_compliance() to qsfp.c Danielle Ratson
2025-01-29 13:15 ` Danielle Ratson [this message]
2025-01-29 13:15 ` [PATCH ethtool-next v2 04/14] qsfp: Reorder the channel-level flags list for SFF8636 module type Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 05/14] qsfp: Refactor sff8636_show_dom() by moving code into separate functions Danielle Ratson
2025-01-30 12:26 ` Vadim Fedorenko
2025-01-30 13:03 ` Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 06/14] module_common: Add helpers to support JSON printing for common value types Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 07/14] cmis: Add JSON output handling to --module-info in CMIS modules Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 08/14] cmis: Enable JSON output support " Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 09/14] qsfp: Add JSON output handling to --module-info in SFF8636 modules Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 10/14] qsfp: Enable JSON output support for " Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 11/14] sfpid: Add JSON output handling to --module-info in SFF8079 modules Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 12/14] sfpdiag: Add JSON output handling to --module-info in SFF8472 modules Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 13/14] ethtool: Enable JSON output support for SFF8079 and " Danielle Ratson
2025-01-29 13:15 ` [PATCH ethtool-next v2 14/14] ethtool: Add '-j' support to ethtool 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=20250129131547.964711-4-danieller@nvidia.com \
--to=danieller@nvidia.com \
--cc=amcohen@nvidia.com \
--cc=daniel.zahka@gmail.com \
--cc=matt@traverse.com.au \
--cc=mkubecek@suse.cz \
--cc=nbu-mlxsw@exchange.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).