File netlink-add-netlink-handler-for-spause-A.patch of Package ethtool

From: Michal Kubecek <mkubecek@suse.cz>
Date: Mon, 11 Dec 2017 08:17:41 +0100
Subject: netlink: add netlink handler for spause (-A)
Patch-mainline: Not yet, work in progress
References: none

Implement "ethtool -A <dev>" subcommand using netlink interface command
ETHNL_CMD_SET_PARAMS.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 ethtool.c        |  3 ++-
 netlink/extapi.h |  1 +
 netlink/params.c | 27 +++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/ethtool.c b/ethtool.c
index 54c700087b22..60c283a6cf28 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4851,6 +4851,7 @@ static int show_usage(struct cmd_context *ctx);
 #define nl_gfec		NULL
 #define nl_scoalesce	NULL
 #define nl_sring	NULL
+#define nl_spause	NULL
 #endif
 
 static const struct option {
@@ -4876,7 +4877,7 @@ static const struct option {
 	  "		[ msglvl %d[/%d] | type on|off ... [--] ]\n" },
 	{ "-a|--show-pause", 1, do_gpause, nl_gpause,
 	  "Show pause options" },
-	{ "-A|--pause", 1, do_spause, NULL,
+	{ "-A|--pause", 1, do_spause, nl_spause,
 	  "Set pause options",
 	  "		[ autoneg on|off ]\n"
 	  "		[ rx on|off ]\n"
diff --git a/netlink/extapi.h b/netlink/extapi.h
index 747731a8fe97..647cf14a2f5a 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -28,6 +28,7 @@ int nl_geee(struct cmd_context *ctx);
 int nl_gfec(struct cmd_context *ctx);
 int nl_scoalesce(struct cmd_context *ctx);
 int nl_sring(struct cmd_context *ctx);
+int nl_spause(struct cmd_context *ctx);
 int nl_monitor(struct cmd_context *ctx);
 
 void monitor_usage();
diff --git a/netlink/params.c b/netlink/params.c
index f73ea7e072f5..73d6f78b21be 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -541,3 +541,30 @@ int nl_sring(struct cmd_context *ctx)
 {
 	return nl_set_param(ctx, "-G", sring_params, ETHA_PARAMS_RING);
 }
+
+static const struct param_parser spause_params[] = {
+	{
+		.arg		= "autoneg",
+		.type		= ETHA_PAUSE_AUTONEG,
+		.handler	= nl_parse_u8bool,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "rx",
+		.type		= ETHA_PAUSE_RX,
+		.handler	= nl_parse_u8bool,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "tx",
+		.type		= ETHA_PAUSE_TX,
+		.handler	= nl_parse_u8bool,
+		.min_argc	= 1,
+	},
+	{}
+};
+
+int nl_spause(struct cmd_context *ctx)
+{
+	return nl_set_param(ctx, "-A", spause_params, ETHA_PARAMS_PAUSE);
+}
-- 
2.19.0