@@ -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
@@ -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 '-').
@@ -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
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(-)