File netlink-add-netlink-handler-for-schannels-L.patch of Package ethtool

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

Implement "ethtool -L <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 | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/ethtool.c b/ethtool.c
index 60c283a6cf28..290d5a8633c0 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4852,6 +4852,7 @@ static int show_usage(struct cmd_context *ctx);
 #define nl_scoalesce	NULL
 #define nl_sring	NULL
 #define nl_spause	NULL
+#define nl_schannels	NULL
 #endif
 
 static const struct option {
@@ -5005,7 +5006,7 @@ static const struct option {
 	  "		N\n"},
 	{ "-l|--show-channels", 1, do_gchannels, nl_gchannels,
 	  "Query Channels" },
-	{ "-L|--set-channels", 1, do_schannels, NULL,
+	{ "-L|--set-channels", 1, do_schannels, nl_schannels,
 	  "Set Channels",
 	  "               [ rx N ]\n"
 	  "               [ tx N ]\n"
diff --git a/netlink/extapi.h b/netlink/extapi.h
index 647cf14a2f5a..50e00fd8de5b 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -29,6 +29,7 @@ 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_schannels(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 73d6f78b21be..b2d92bb8a938 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -568,3 +568,36 @@ int nl_spause(struct cmd_context *ctx)
 {
 	return nl_set_param(ctx, "-A", spause_params, ETHA_PARAMS_PAUSE);
 }
+
+static const struct param_parser schannels_params[] = {
+	{
+		.arg		= "rx",
+		.type		= ETHA_CHANNELS_RX_COUNT,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "tx",
+		.type		= ETHA_CHANNELS_TX_COUNT,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "other",
+		.type		= ETHA_CHANNELS_OTHER_COUNT,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "combined",
+		.type		= ETHA_CHANNELS_COMBINED_COUNT,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{}
+};
+
+int nl_schannels(struct cmd_context *ctx)
+{
+	return nl_set_param(ctx, "-L", schannels_params, ETHA_PARAMS_CHANNELS);
+}
-- 
2.19.0