[RFC PATCH ethtool v2 23/23] netlink: add netlink handler for sfec (--set-fec)

From: Michal Kubecek
Date: Mon Jul 30 2018 - 08:57:44 EST


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

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

diff --git a/ethtool.c b/ethtool.c
index bd85b0c50ce2..8160ab200a16 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4890,6 +4890,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 {
@@ -5099,7 +5100,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 80ed4afb5227..1938c6075758 100644
--- a/netlink/extapi.h
+++ b/netlink/extapi.h
@@ -29,6 +29,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 1cc2ffbc4b27..95a54d0d2978 100644
--- a/netlink/params.c
+++ b/netlink/params.c
@@ -640,3 +640,20 @@ int nl_seee(struct cmd_context *ctx)
return nl_set_param(ctx, "--set-eee", seee_params, ETHA_PARAMS_EEE,
ETHA_EEE_MAX);
}
+
+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,
+ ETHA_FEC_MAX);
+}
--
2.18.0