From: Michal Kubecek <mkubecek@suse.cz>
To: John Linville <linville@tuxdriver.com>, netdev@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH ethtool 03/19] add --debug option to control debugging messages
Date: Sun, 16 Feb 2020 23:46:45 +0100 (CET) [thread overview]
Message-ID: <1e01f6e1890d816966a509a6257e84a48fe40533.1581892124.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1581892124.git.mkubecek@suse.cz>
Introduce --debug option to control which debugging messages will be shown.
Argument is a number which is interpreted as bit mask; default value is
zero (i.e. no debug messages).
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
ethtool.8.in | 12 ++++++++++++
ethtool.c | 18 ++++++++++++++++--
internal.h | 6 ++++++
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/ethtool.8.in b/ethtool.8.in
index 94364c626330..680cad9fbb8f 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -129,6 +129,10 @@ ethtool \- query or control network driver and hardware settings
.HP
.B ethtool \-\-version
.HP
+.B ethtool
+.BN --debug
+.I args
+.HP
.B ethtool \-a|\-\-show\-pause
.I devname
.HP
@@ -437,6 +441,14 @@ Shows a short help message.
.B \-\-version
Shows the ethtool version number.
.TP
+.BI \-\-debug \ N
+Turns on debugging messages. Argument is interpreted as a mask:
+.TS
+nokeep;
+lB l.
+0x01 Parser information
+.TE
+.TP
.B \-a \-\-show\-pause
Queries the specified Ethernet device for pause parameter information.
.TP
diff --git a/ethtool.c b/ethtool.c
index acf183dc5586..dd0242b27a2f 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -5493,10 +5493,10 @@ static int show_usage(struct cmd_context *ctx maybe_unused)
fprintf(stdout, PACKAGE " version " VERSION "\n");
fprintf(stdout,
"Usage:\n"
- " ethtool DEVNAME\t"
+ " ethtool [ --debug MASK ] DEVNAME\t"
"Display standard information about device\n");
for (i = 0; args[i].opts; i++) {
- fputs(" ethtool ", stdout);
+ fputs(" ethtool [ --debug MASK ] ", stdout);
fprintf(stdout, "%s %s\t%s\n",
args[i].opts,
args[i].want_device ? "DEVNAME" : "\t",
@@ -5712,6 +5712,20 @@ int main(int argc, char **argp)
argp++;
argc--;
+ ctx.debug = 0;
+ if (*argp && !strcmp(*argp, "--debug")) {
+ char *eptr;
+
+ if (argc < 2)
+ exit_bad_args();
+ ctx.debug = strtoul(argp[1], &eptr, 0);
+ if (!argp[1][0] || *eptr)
+ exit_bad_args();
+
+ argp += 2;
+ argc -= 2;
+ }
+
/* First argument must be either a valid option or a device
* name to get settings for (which we don't expect to begin
* with '-').
diff --git a/internal.h b/internal.h
index 527245633338..9ec145f55dcb 100644
--- a/internal.h
+++ b/internal.h
@@ -107,6 +107,11 @@ static inline int test_bit(unsigned int nr, const unsigned long *addr)
#define SIOCETHTOOL 0x8946
#endif
+/* debugging flags */
+enum {
+ DEBUG_PARSE,
+};
+
/* Internal values for old-style offload flags. Values and names
* must not clash with the flags defined for ETHTOOL_{G,S}FLAGS.
*/
@@ -197,6 +202,7 @@ struct cmd_context {
struct ifreq ifr; /* ifreq suitable for ethtool ioctl */
int argc; /* number of arguments to the sub-command */
char **argp; /* arguments to the sub-command */
+ unsigned long debug; /* debugging mask */
};
#ifdef TEST_ETHTOOL
--
2.25.0
next prev parent reply other threads:[~2020-02-16 22:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-16 22:46 [PATCH ethtool 00/19] initial netlink interface implementation for 5.6 release Michal Kubecek
2020-02-16 22:46 ` [PATCH ethtool 01/19] move UAPI header copies to a separate directory Michal Kubecek
2020-02-16 22:46 ` [PATCH ethtool 02/19] update UAPI header copies Michal Kubecek
2020-02-16 22:46 ` Michal Kubecek [this message]
2020-02-16 22:46 ` [PATCH ethtool 04/19] use named initializers in command line option list Michal Kubecek
2020-02-16 22:46 ` [PATCH ethtool 05/19] netlink: add netlink related UAPI header files Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 06/19] netlink: introduce the netlink interface Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 07/19] netlink: message buffer and composition helpers Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 08/19] netlink: netlink socket wrapper and helpers Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 09/19] netlink: initialize ethtool netlink socket Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 10/19] netlink: add support for string sets Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 11/19] netlink: add notification monitor Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 12/19] move shared code into a common file Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 13/19] netlink: add bitset helpers Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 14/19] netlink: partial netlink handler for gset (no option) Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 15/19] netlink: support getting wake-on-lan and debugging settings Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 16/19] netlink: add basic command line parsing helpers Michal Kubecek
2020-02-16 22:47 ` [PATCH ethtool 17/19] netlink: add bitset command line parser handlers Michal Kubecek
2020-02-16 22:48 ` [PATCH ethtool 18/19] netlink: add netlink handler for sset (-s) Michal Kubecek
2020-02-16 22:48 ` [PATCH ethtool 19/19] netlink: support tests with netlink enabled Michal Kubecek
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=1e01f6e1890d816966a509a6257e84a48fe40533.1581892124.git.mkubecek@suse.cz \
--to=mkubecek@suse.cz \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=linville@tuxdriver.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).