File netlink-add-netlink-handler-for-seee-set-eee.patch of Package ethtool

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

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

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 ethtool.c        |  5 +++--
 netlink/extapi.h |  1 +
 netlink/params.c | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 290d5a8633c0..020a161e24a3 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4853,6 +4853,7 @@ static int show_usage(struct cmd_context *ctx);
 #define nl_sring	NULL
 #define nl_spause	NULL
 #define nl_schannels	NULL
+#define nl_seee		NULL
 #endif
 
 static const struct option {
@@ -5025,10 +5026,10 @@ static const struct option {
 	  "		[ length N ]\n" },
 	{ "--show-eee", 1, do_geee, nl_geee,
 	  "Show EEE settings"},
-	{ "--set-eee", 1, do_seee, NULL,
+	{ "--set-eee", 1, do_seee, nl_seee,
 	  "Set EEE settings",
 	  "		[ eee on|off ]\n"
-	  "		[ advertise %x ]\n"
+	  "		[ advertise %x[/%x] | mode on|off ... ]\n"
 	  "		[ tx-lpi on|off ]\n"
 	  "		[ tx-timer %d ]\n"},
 	{ "--set-phy-tunable", 1, do_set_phy_tunable, NULL,
diff --git a/netlink/extapi.h b/netlink/extapi.h
index 50e00fd8de5b..ccb4f5e97a47 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -30,6 +30,7 @@ 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_seee(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 b2d92bb8a938..913a5417e679 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -601,3 +601,36 @@ int nl_schannels(struct cmd_context *ctx)
 {
 	return nl_set_param(ctx, "-L", schannels_params, ETHA_PARAMS_CHANNELS);
 }
+
+static const struct param_parser seee_params[] = {
+	{
+		.arg		= "advertise",
+		.type		= ETHA_EEE_LINK_MODES,
+		.handler	= nl_parse_bitset,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "tx-lpi",
+		.type		= ETHA_EEE_TX_LPI_ENABLED,
+		.handler	= nl_parse_u8bool,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "tx-timer",
+		.type		= ETHA_EEE_TX_LPI_TIMER,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
+	{
+		.arg		= "eee",
+		.type		= ETHA_EEE_ENABLED,
+		.handler	= nl_parse_u8bool,
+		.min_argc	= 1,
+	},
+	{}
+};
+
+int nl_seee(struct cmd_context *ctx)
+{
+	return nl_set_param(ctx, "--set-eee", seee_params, ETHA_PARAMS_EEE);
+}
-- 
2.19.0