File netlink-add-netlink-handler-for-sfec-set-fec.patch of Package ethtool

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

Implement "ethtool --set-fec <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 | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/ethtool.c b/ethtool.c
index 020a161e24a3..364834f1f69c 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4854,6 +4854,7 @@ static int show_usage(struct cmd_context *ctx);
 #define nl_spause	NULL
 #define nl_schannels	NULL
 #define nl_seee		NULL
+#define nl_sfec		NULL
 #endif
 
 static const struct option {
@@ -5063,7 +5064,7 @@ static const struct option {
 	  "		[ all ]\n"},
 	{ "--show-fec", 1, do_gfec, nl_gfec,
 	  "Show FEC settings"},
-	{ "--set-fec", 1, do_sfec, NULL,
+	{ "--set-fec", 1, do_sfec, nl_sfec,
 	  "Set FEC settings",
 	  "		[ encoding auto|off|rs|baser ]\n"},
 	{ "-h|--help", 0, show_usage, NULL,
diff --git a/netlink/extapi.h b/netlink/extapi.h
index ccb4f5e97a47..206f20029cff 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -31,6 +31,7 @@ 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_sfec(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 913a5417e679..4ff2f296170d 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -634,3 +634,19 @@ int nl_seee(struct cmd_context *ctx)
 {
 	return nl_set_param(ctx, "--set-eee", seee_params, ETHA_PARAMS_EEE);
 }
+
+static const struct param_parser sfec_params[] = {
+	{
+		.arg		= "modes",
+		.type		= ETHA_FEC_MODES,
+		.handler	= nl_parse_bitfield32,
+		.handler_data	= flags_fecenc,
+		.min_argc	= 1,
+	},
+	{}
+};
+
+int nl_sfec(struct cmd_context *ctx)
+{
+	return nl_set_param(ctx, "--set-fec", sfec_params, ETHA_PARAMS_FEC);
+}
-- 
2.19.0