From: Ben Hutchings <bhutchings@solarflare.com>
To: Jeff Garzik <jgarzik@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
sf-linux-drivers <linux-net-drivers@solarflare.com>
Subject: [PATCH 1/2] ethtool: Add generic structure and functions for named flags
Date: Tue, 18 May 2010 17:32:16 +0100 [thread overview]
Message-ID: <1274200336.2113.0.camel@achroite.uk.solarflarecom.com> (raw)
This will be used to support named message type flags.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 4226a67..7004b7f 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -355,6 +355,12 @@ struct cmdline_info {
void *ioctl_val;
};
+struct named_flag {
+ const char *name;
+ u32 flag;
+ int *wanted;
+};
+
static struct cmdline_info cmdline_gregs[] = {
{ "raw", CMDL_BOOL, &gregs_dump_raw, NULL },
{ "hex", CMDL_BOOL, &gregs_dump_hex, NULL },
@@ -520,6 +526,41 @@ static void parse_generic_cmdline(int argc, char **argp,
}
}
+static void
+print_flags(const struct named_flag *flags, unsigned int n_flags, u32 value)
+{
+ const char *sep = "";
+
+ while (n_flags) {
+ if (value & flags->flag) {
+ printf("%s%s", sep, flags->name);
+ sep = " ";
+ value &= ~flags->flag;
+ }
+ ++flags;
+ --n_flags;
+ }
+
+ /* Print any unrecognised flags in hex */
+ if (value)
+ printf("%s%#x", sep, value);
+}
+
+static u32
+update_flags(const struct named_flag *flags, unsigned int n_flags, u32 value)
+{
+ while (n_flags) {
+ if (*flags->wanted == 0)
+ value &= ~flags->flag;
+ else if (*flags->wanted == 1)
+ value |= flags->flag;
+ ++flags;
+ --n_flags;
+ }
+
+ return value;
+}
+
static int rxflow_str_to_type(const char *str)
{
int flow_type = 0;
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next reply other threads:[~2010-05-18 16:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-18 16:32 Ben Hutchings [this message]
2010-05-18 16:33 ` [PATCH 2/2] ethtool: Implement named message type flags Ben Hutchings
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=1274200336.2113.0.camel@achroite.uk.solarflarecom.com \
--to=bhutchings@solarflare.com \
--cc=jgarzik@redhat.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