File netlink-add-netlink-handler-for-sring-G.patch of Package ethtool

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

Implement "ethtool -G <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 d5979d58341c..54c700087b22 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4850,6 +4850,7 @@ static int show_usage(struct cmd_context *ctx);
 #define nl_geee		NULL
 #define nl_gfec		NULL
 #define nl_scoalesce	NULL
+#define nl_sring	NULL
 #endif
 
 static const struct option {
@@ -4908,7 +4909,7 @@ static const struct option {
 	  "		[sample-interval N]\n" },
 	{ "-g|--show-ring", 1, do_gring, nl_gring,
 	  "Query RX/TX ring parameters" },
-	{ "-G|--set-ring", 1, do_sring, NULL,
+	{ "-G|--set-ring", 1, do_sring, nl_sring,
 	  "Set RX/TX ring parameters",
 	  "		[ rx N ]\n"
 	  "		[ rx-mini N ]\n"
diff --git a/netlink/extapi.h b/netlink/extapi.h
index fd3e0ca062f4..747731a8fe97 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -27,6 +27,7 @@ int nl_gchannels(struct cmd_context *ctx);
 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_monitor(struct cmd_context *ctx);
 
 void monitor_usage();
diff --git a/netlink/params.c b/netlink/params.c
index a5fe473676e4..f73ea7e072f5 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -508,3 +508,36 @@ int nl_scoalesce(struct cmd_context *ctx)
 {
 	return nl_set_param(ctx, "-C", scoalesce_params, ETHA_PARAMS_COALESCE);
 }
+
+static const struct param_parser sring_params[] = {
+	{
+		.arg		= "rx",
+		.type		= ETHA_RING_RX_PENDING,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "rx-mini",
+		.type		= ETHA_RING_RX_MINI_PENDING,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "rx-jumbo",
+		.type		= ETHA_RING_RX_JUMBO_PENDING,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "tx",
+		.type		= ETHA_RING_TX_PENDING,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{}
+};
+
+int nl_sring(struct cmd_context *ctx)
+{
+	return nl_set_param(ctx, "-G", sring_params, ETHA_PARAMS_RING);
+}
-- 
2.19.0