Blame SOURCES/0031-add-support-for-stats-in-subcommands.patch

6975f2
From 26b419d729ee84a1924c31b2140281dace819dbc Mon Sep 17 00:00:00 2001
6975f2
From: Jakub Kicinski <kuba@kernel.org>
6975f2
Date: Sun, 18 Oct 2020 14:31:48 -0700
6975f2
Subject: [PATCH 31/37] add support for stats in subcommands
6975f2
6975f2
Add new parameters (-I | --include-statistics) which will
6975f2
control requesting statistic dumps from the kernel.
6975f2
6975f2
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
6975f2
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
6975f2
(cherry picked from commit 66ecd38ca8b4e6184af4c38c234a9dcfb6804a4a)
6975f2
---
6975f2
 ethtool.8.in | 7 +++++++
6975f2
 ethtool.c    | 8 ++++++++
6975f2
 internal.h   | 1 +
6975f2
 3 files changed, 16 insertions(+)
6975f2
6975f2
diff --git a/ethtool.8.in b/ethtool.8.in
6975f2
index 12866dc456cf..e0601b3db0cf 100644
6975f2
--- a/ethtool.8.in
6975f2
+++ b/ethtool.8.in
6975f2
@@ -140,6 +140,9 @@ ethtool \- query or control network driver and hardware settings
6975f2
 .B ethtool [--json]
6975f2
 .I args
6975f2
 .HP
6975f2
+.B ethtool [-I | --include-statistics]
6975f2
+.I args
6975f2
+.HP
6975f2
 .B ethtool \-\-monitor
6975f2
 [
6975f2
 .I command
6975f2
@@ -496,6 +499,10 @@ Output results in JavaScript Object Notation (JSON). Only a subset of
6975f2
 options support this. Those which do not will continue to output
6975f2
 plain text in the presence of this option.
6975f2
 .TP
6975f2
+.B \-I \-\-include\-statistics
6975f2
+Include command-related statistics in the output. This option allows
6975f2
+displaying relevant device statistics for selected get commands.
6975f2
+.TP
6975f2
 .B \-a \-\-show\-pause
6975f2
 Queries the specified Ethernet device for pause parameter information.
6975f2
 .TP
6975f2
diff --git a/ethtool.c b/ethtool.c
6975f2
index 9b56b0e2a628..f5fbb01e553a 100644
6975f2
--- a/ethtool.c
6975f2
+++ b/ethtool.c
6975f2
@@ -5979,6 +5979,7 @@ static int show_usage(struct cmd_context *ctx __maybe_unused)
6975f2
 	fprintf(stdout, "FLAGS:\n");
6975f2
 	fprintf(stdout, "	--debug MASK	turn on debugging messages\n");
6975f2
 	fprintf(stdout, "	--json		enable JSON output format (not supported by all commands)\n");
6975f2
+	fprintf(stdout, "	-I|--include-statistics		request device statistics related to the command (not supported by all commands)\n");
6975f2
 
6975f2
 	return 0;
6975f2
 }
6975f2
@@ -6239,6 +6240,13 @@ int main(int argc, char **argp)
6975f2
 			argc -= 1;
6975f2
 			continue;
6975f2
 		}
6975f2
+		if (*argp && (!strcmp(*argp, "--include-statistics") ||
6975f2
+			      !strcmp(*argp, "-I"))) {
6975f2
+			ctx.show_stats = true;
6975f2
+			argp += 1;
6975f2
+			argc -= 1;
6975f2
+			continue;
6975f2
+		}
6975f2
 		break;
6975f2
 	}
6975f2
 	if (*argp && !strcmp(*argp, "--monitor")) {
6975f2
diff --git a/internal.h b/internal.h
6975f2
index d096a28abfa2..1c0652d28793 100644
6975f2
--- a/internal.h
6975f2
+++ b/internal.h
6975f2
@@ -225,6 +225,7 @@ struct cmd_context {
6975f2
 	char **argp;		/* arguments to the sub-command */
6975f2
 	unsigned long debug;	/* debugging mask */
6975f2
 	bool json;		/* Output JSON, if supported */
6975f2
+	bool show_stats;	/* include command-specific stats */
6975f2
 #ifdef ETHTOOL_ENABLE_NETLINK
6975f2
 	struct nl_context *nlctx;	/* netlink context (opaque) */
6975f2
 #endif
6975f2
-- 
6975f2
2.26.2
6975f2