netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: <netdev@vger.kernel.org>
Cc: <linux-net-drivers@solarflare.com>
Subject: [PATCH ethtool] sfc: Omit zero values in register tables
Date: Wed, 21 Dec 2011 19:48:44 +0000	[thread overview]
Message-ID: <1324496924.2764.13.camel@bwh-desktop> (raw)

I just pushed this change out.

Ben.
---
Some register tables on Solarflare controllers are very large and may
have only a few rows in use.  Make register dumps more readable by
omitting rows where all bits read as zero.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 sfc.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/sfc.c b/sfc.c
index 46a617b..3ba3da8 100644
--- a/sfc.c
+++ b/sfc.c
@@ -3777,6 +3777,15 @@ print_simple_table(unsigned revision, const struct efx_nic_reg_table *table,
 	return buf;
 }
 
+static int buf_is_zero(const u8 *buf, size_t size)
+{
+	size_t i;
+	for (i = 0; i < size; i++)
+		if (buf[i])
+			return 0;
+	return 1;
+}
+
 static const void *
 print_complex_table(unsigned revision, const struct efx_nic_reg_table *table,
 		    const void *buf)
@@ -3808,16 +3817,18 @@ print_complex_table(unsigned revision, const struct efx_nic_reg_table *table,
 	fputc('\n', stdout);
 
 	for (j = 0; j < table->rows; j++) {
-		printf("%4zu", j);
-		for (i = 0; i < table->field_count; i++) {
-			field = &table->fields[i];
-			if (!(revision >= field->min_revision &&
-			      revision <= field->max_revision))
-				continue;
-			printf(" %*s", (int)column_padding(field), "");
-			print_field_value(field, buf);
+		if (!buf_is_zero(buf, size)) {
+			printf("%4zu", j);
+			for (i = 0; i < table->field_count; i++) {
+				field = &table->fields[i];
+				if (!(revision >= field->min_revision &&
+				      revision <= field->max_revision))
+					continue;
+				printf(" %*s", (int)column_padding(field), "");
+				print_field_value(field, buf);
+			}
+			fputc('\n', stdout);
 		}
-		fputc('\n', stdout);
 		buf = (const u8 *)buf + size;
 	}
 
-- 
1.7.4.4


-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

                 reply	other threads:[~2011-12-21 19:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1324496924.2764.13.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=linux-net-drivers@solarflare.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).