ethtool netlink interface (userspace side) (WiP)
Subsystems (3)
v2 cover ethtool netlink interface (userspace side) (WiP)
(The series is based on v4.17)
This patch series is and ethtool counterpart to kernel series "ethtool netlink interface (WiP)"; it's marked as "v2" to match kernel series version even if I never really sent "v1" to the list. It's only an RFC as the netlink API it implements is still only a proposal.
The series modifies ethtool to use the netlink based kernel API when available. If not, it falls back to the ioctl API. The aim is to preserve command line syntax (with few extensions) and preserve the output as much as possible.
This brings a natural question: why? It would be certainly tempting to start with a new tool without the limitations of the old command line syntax and without having to immitatte strange artefacts of the past. It may still come to that but experience with iproute2 shows even if you provide a new tool with cleaner syntax, more features and better organized output, 19 years later you may still meet (a lot of) people still using the old tool and claiming they are not going to learn some new tools with "strange syntax and incomprehensible output" (the sadest part being that many of them haven't learn using ifconfig before it had been already obsolete for ten years). That's why I tried to give this approach at least a try.
As both parser and dump functions in current ethtool code are closely tied to data structures used by ioctl API, only very little of existing code could be reused. The parts used also by netlink code were moved to common.h and common.c. New netlink related code resides in netlink/ subdirectory. Copies of kernel uapi headers were moved to uapi/ directory to make their status more apparent. Netlink code uses libmnl for message composition and parsing.
Currently reimplemented functions are
-i / --driver (no option) -s -k / --show-features / --show-offload -K / --features / --offload -c / --show-coalesce -C / --coalesce -g / --show-ring -G / --set-ring -a / --show-pause -A / --pause -l / --show-channels -L / --set-channels --show-eee --set-eee --show-fec --set-fec
For all "get" type options, "*" can be used as device name to request information about all interfaces supporting that request type.
The most interesting new feature is notification monitoring. When started as
ethtool --monitor --all
ethtool will listen to netlink notifications and display information about changes. Replacing "--all" with one of the options above will show only notifications about changes related to that option. A device name can be also used to display only notifications related to that device.
ToDo / open questions:
- the most important question still is if we want to reimplement ethtool or come with a completely new utility instead
- if we go on with teaching ethtool netlink, another interesting question is how closely we need to stick to current output and its formatting; even if people are told not to, there are certainly tons of scripts parsing ethtool output which may break on any change
- an example of this are legacy "flags" for netdev features; we will have to make sure "ethtool -K dev tso off" will do what users expect it to but can we get rid of them at least in "ethtool -k" output?
- having to say "--monitor -all" for monitoring all events while just "--monitor" only watches for sset ("-s") type changes is probably counterintuitive; would it be better to make "--all" default and leave only "--monitor -s" for watching only "sset" events
Michal Kubecek (23):
move UAPI header copies to a separate directory update UAPI header copies
netlink: add netlink interface
netlink: add support for string sets
netlink: add notification monitor
netlink: add netlink handler for gdrv (-i)
netlink: add netlink handler for gset (no option)
netlink: add helpers for command line parsing
netlink: add netlink handler for sset (-s)
netlink: add netlink handler for gfeatures (-k)
netlink: add netlink handler for sfeatures (-K)
netlink: add netlink handler for gcoalesce (-c)
netlink: add netlink handler for gring (-g)
netlink: add netlink handler for gpause (-a)
netlink: add netlink handler for gchannels (-l)
netlink: add netlink handler for geee (--show-eee)
netlink: add netlink handler for gfec (--show-fec)
netlink: add netlink handler for scoalesce (-C)
netlink: add netlink handler for sring (-G)
netlink: add netlink handler for spause (-A)
netlink: add netlink handler for schannels (-L)
netlink: add netlink handler for seee (--set-eee)
netlink: add netlink handler for sfec (--set-fec)
Makefile.am | 20 +- common.c | 325 ++++++ common.h | 83 ++ configure.ac | 14 +- ethtool.c | 437 +++----- internal.h | 12 +- netlink/drvinfo.c | 43 + netlink/extapi.h | 37 + netlink/monitor.c | 283 +++++ netlink/netlink.c | 681 ++++++++++++ netlink/netlink.h | 189 ++++ netlink/params.c | 659 +++++++++++ netlink/parser.c | 559 ++++++++++ netlink/parser.h | 49 + netlink/settings.c | 1035 ++++++++++++++++++ netlink/strset.c | 265 +++++ netlink/strset.h | 16 + ethtool-copy.h => uapi/linux/ethtool.h | 13 +- uapi/linux/ethtool_netlink.h | 325 ++++++ uapi/linux/genetlink.h | 89 ++ net_tstamp-copy.h => uapi/linux/net_tstamp.h | 19 + uapi/linux/netlink.h | 247 +++++ 22 files changed, 5134 insertions(+), 266 deletions(-) create mode 100644 common.c create mode 100644 common.h create mode 100644 netlink/drvinfo.c create mode 100644 netlink/extapi.h create mode 100644 netlink/monitor.c create mode 100644 netlink/netlink.c create mode 100644 netlink/netlink.h create mode 100644 netlink/params.c create mode 100644 netlink/parser.c create mode 100644 netlink/parser.h create mode 100644 netlink/settings.c create mode 100644 netlink/strset.c create mode 100644 netlink/strset.h rename ethtool-copy.h => uapi/linux/ethtool.h (99%) create mode 100644 uapi/linux/ethtool_netlink.h create mode 100644 uapi/linux/genetlink.h rename net_tstamp-copy.h => uapi/linux/net_tstamp.h (89%) create mode 100644 uapi/linux/netlink.h
Signature · 1 line
2.18.0
RFC PATCH v2 1/23 move UAPI header copies to a separate directory
The upcoming netlink series is going to add more local copies of kernel UAPI header files and some of them are going to include others. Keeping them in the main directory under modified name would require modifying those includes as well which would be impractical.
Create a subdirectory uapi and move the UAPI headers there to allow including them in the usual way.
--- Makefile.am | 6 +++--- internal.h | 4 ++-- ethtool-copy.h => uapi/linux/ethtool.h | 0 net_tstamp-copy.h => uapi/linux/net_tstamp.h | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename ethtool-copy.h => uapi/linux/ethtool.h (100%) rename net_tstamp-copy.h => uapi/linux/net_tstamp.h (100%)
Makefile.am +3 -3
@@ -1,12 +1,12 @@ -AM_CFLAGS = -Wall +AM_CFLAGS = -I./uapi -Wall LDADD = -lm man_MANS = ethtool.8 EXTRA_DIST = LICENSE ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog autogen.sh sbin_PROGRAMS = ethtool -ethtool_SOURCES = ethtool.c ethtool-copy.h internal.h net_tstamp-copy.h \ - rxclass.c +ethtool_SOURCES = ethtool.c uapi/linux/ethtool.h internal.h \ + uapi/linux/net_tstamp.h rxclass.c if ETHTOOL_ENABLE_PRETTY_DUMP ethtool_SOURCES += \ amd8111e.c de2104x.c e100.c e1000.c et131x.c igb.c \
internal.h +2 -2
@@ -42,8 +42,8 @@ typedef int32_t s32;#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))#endif -#include "ethtool-copy.h" -#include "net_tstamp-copy.h" +#include <linux/ethtool.h> +#include <linux/net_tstamp.h> #if __BYTE_ORDER == __BIG_ENDIANstatic inline u16 cpu_to_be16 (u16 value)
uapi/linux/ethtool.h renamed from ethtool-copy.h +0 -0
uapi/linux/net_tstamp.h renamed from net_tstamp-copy.h +0 -0
Signature · 1 line
2.18.0
RFC PATCH v2 2/23 update UAPI header copies
In reply to Michal KubecekUpdate to current net-next (commit 3bc950c34b28).
--- uapi/linux/ethtool.h | 6 +++++- uapi/linux/net_tstamp.h | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-)
uapi/linux/ethtool.h +5 -1
@@ -215,12 +215,16 @@ struct ethtool_value {__u32 data; }; +#define PFC_STORM_PREVENTION_AUTO 0xffff +#define PFC_STORM_PREVENTION_DISABLE 0 +enum tunable_id {ETHTOOL_ID_UNSPEC ,ETHTOOL_RX_COPYBREAK ,ETHTOOL_TX_COPYBREAK , +ETHTOOL_PFC_PREVENTION_TOUT ,/* timeout in msecs */ /* -* Add your fresh new tubale attribute above and remember to update +* Add your fresh new tunable attribute above and remember to update * tunable_strings[] in net/core/ethtool.c */ __ETHTOOL_TUNABLE_COUNT,
uapi/linux/net_tstamp.h +19 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Userspace API for hardware time stamping of network packets *
@@ -140,4 +141,22 @@ struct scm_ts_pktinfo { __u32 reserved[2]; }; +/* +* SO_TXTIME gets a struct sock_txtime with flags being an integer bit +* field comprised of these values. +*/ +enum txtime_flags { +SOF_TXTIME_DEADLINE_MODE = (1 <<0 ), +SOF_TXTIME_REPORT_ERRORS = (1 <<1 ), + +SOF_TXTIME_FLAGS_LAST =SOF_TXTIME_REPORT_ERRORS , +SOF_TXTIME_FLAGS_MASK = (SOF_TXTIME_FLAGS_LAST -1 ) | +SOF_TXTIME_FLAGS_LAST +}; + +struct sock_txtime { +clockid_t clockid;/* reference clockid */ +__u32 flags;/* as defined by enum txtime_flags */ +}; +#endif /* _NET_TIMESTAMPING_H */
Signature · 1 line
2.18.0
RFC PATCH v2 3/23 netlink: add netlink interface
In reply to Michal KubecekAdd basic netlink interface based on genetlink and libmnl. This commit only adds the generic infrastructure but does not override any ethtool command (so that there is no actual behaviour change).
Netlink handlers for ethtool subcommands are added as nl_func members to args array in ethtool.c. Netlink handler is used if it is available (i.e. nl_func is not null) and ethtool succeeds to open a netlink socket and get id of genetlink family "ethtool". At the moment, all nl_func are null so that ioctl() is always used.
Running configure with --disable-netlink disables netlink interface completely.
--- Makefile.am | 11 + configure.ac | 14 +- ethtool.c | 178 ++++++++---- internal.h | 8 + netlink/extapi.h | 16 ++ netlink/netlink.c | 522 +++++++++++++++++++++++++++++++++++ netlink/netlink.h | 154 +++++++++++ uapi/linux/ethtool.h | 7 + uapi/linux/ethtool_netlink.h | 325 ++++++++++++++++++++++ uapi/linux/genetlink.h | 89 ++++++ uapi/linux/netlink.h | 247 +++++++++++++++++ 11 files changed, 1514 insertions(+), 57 deletions(-) create mode 100644 netlink/extapi.h create mode 100644 netlink/netlink.c create mode 100644 netlink/netlink.h create mode 100644 uapi/linux/ethtool_netlink.h create mode 100644 uapi/linux/genetlink.h create mode 100644 uapi/linux/netlink.h
Makefile.am +11 -0
@@ -7,6 +7,8 @@ EXTRA_DIST = LICENSE ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog autogen.sh sbin_PROGRAMS = ethtool ethtool_SOURCES = ethtool.c uapi/linux/ethtool.h internal.h \ uapi/linux/net_tstamp.h rxclass.c +ethtool_CFLAGS = -I./uapi -Wall +ethtool_LDADD = -lm if ETHTOOL_ENABLE_PRETTY_DUMP ethtool_SOURCES += \ amd8111e.c de2104x.c e100.c e1000.c et131x.c igb.c \
@@ -17,6 +19,15 @@ ethtool_SOURCES += \ ixgbevf.c tse.c vmxnet3.c qsfp.c qsfp.h fjes.c lan78xx.c endif +if ETHTOOL_ENABLE_NETLINK +ethtool_SOURCES += \ + netlink/netlink.c netlink/netlink.h netlink/extapi.h \ + uapi/linux/ethtool_netlink.h \ + uapi/linux/netlink.h uapi/linux/genetlink.h +ethtool_CFLAGS += @MNL_CFLAGS@ +ethtool_LDADD += @MNL_LIBS@ +endif + TESTS = test-cmdline test-features check_PROGRAMS = test-cmdline test-features test_cmdline_SOURCES = test-cmdline.c test-common.c $(ethtool_SOURCES)
configure.ac +13 -1
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(ethtool, 4.17, [email protected]) AC_PREREQ(2.52) AC_CONFIG_SRCDIR([ethtool.c]) -AM_INIT_AUTOMAKE([gnu]) +AM_INIT_AUTOMAKE([gnu subdir-objects]) AC_CONFIG_HEADERS([ethtool-config.h]) AM_MAINTAINER_MODE
@@ -40,5 +40,17 @@ if test x$enable_pretty_dump = xyes; then fi AM_CONDITIONAL([ETHTOOL_ENABLE_PRETTY_DUMP], [test x$enable_pretty_dump = xyes]) +AC_ARG_ENABLE(netlink, + [ --enable-netlink enable netlink interface (enabled by default)], + , + enable_netlink=yes) +if test x$enable_netlink = xyes; then + PKG_PROG_PKG_CONFIG + PKG_CHECK_MODULES([MNL], [libmnl]) + AC_DEFINE(ETHTOOL_ENABLE_NETLINK, 1, + Define this to support netlink interface to talk to kernel.) +fi +AM_CONDITIONAL([ETHTOOL_ENABLE_NETLINK], [test x$enable_netlink = xyes]) + AC_CONFIG_FILES([Makefile ethtool.spec ethtool.8]) AC_OUTPUT
ethtool.c +122 -56
315 lines not on this page · raw message
internal.h +8 -0
@@ -23,6 +23,11 @@#include <sys/ioctl.h> #include <net/if.h> +/* internal for netlink interface */ +#ifdef ETHTOOL_ENABLE_NETLINK +struct nl_context ; +#endif +/* ethtool.h expects these to be defined by <linux/types.h> */ #ifndef HAVE_BE_TYPES typedef uint16_t __be16 ;
@@ -195,6 +200,9 @@ struct cmd_context {struct ifreq ifr;/* ifreq suitable for ethtool ioctl */ int argc;/* number of arguments to the sub-command */ char **argp;/* arguments to the sub-command */ +#ifdef ETHTOOL_ENABLE_NETLINK +struct nl_context *nlctx;/* netlink context (opaque) */ +#endif };#ifdef TEST_ETHTOOL
netlink/extapi.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* extapi.h - external netlink interface +* +* interface for general non-netlink code +*/ + +#ifndef ETHTOOL_EXTAPI_H__ +#define ETHTOOL_EXTAPI_H__ + +struct cmd_context ; +struct nl_context ; + +int netlink_init (struct cmd_context *ctx); +int netlink_done (struct cmd_context *ctx); + +#endif /* ETHTOOL_EXTAPI_H__ */
netlink/netlink.c new file +522 -0
522 lines not on this page · raw message
netlink/netlink.h new file +154 -0
154 lines not on this page · raw message
uapi/linux/ethtool.h +7 -0
@@ -141,6 +141,9 @@ static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)*/ #define ETH_MDIO_SUPPORTS_C45 2 +/* All defined ETH_MDIO_SUPPORTS_* flags */ +#define ETH_MDIO_SUPPORTS_ALL (ETH_MDIO_SUPPORTS_C22 | ETH_MDIO_SUPPORTS_C45) +#define ETHTOOL_FWVERS_LEN 32#define ETHTOOL_BUSINFO_LEN 32#define ETHTOOL_EROMVERS_LEN 32
@@ -576,6 +579,10 @@ enum ethtool_stringset {ETH_SS_TUNABLES ,ETH_SS_PHY_STATS ,ETH_SS_PHY_TUNABLES , +ETH_SS_LINK_MODES , + + __ETH_SS_MAX, + ETH_SS_MAX = (__ETH_SS_MAX - 1) };/**
uapi/linux/ethtool_netlink.h new file +325 -0
325 lines not on this page · raw message
uapi/linux/genetlink.h new file +89 -0
89 lines not on this page · raw message
uapi/linux/netlink.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 4/23 netlink: add support for string sets
In reply to Michal KubecekAdd infrastructure for querying kernel string sets (analog to ioct commands ETHTOOL_GSSET_INFO and ETHTOOL_GSTRINGS).
Let notification monitor request string sets on start so that it can resolve bit indices to names when processing bitsets in compact format.
--- Makefile.am | 1 + netlink/strset.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++ netlink/strset.h | 16 +++ 3 files changed, 282 insertions(+) create mode 100644 netlink/strset.c create mode 100644 netlink/strset.h
Makefile.am +1 -0
@@ -22,6 +22,7 @@ endif if ETHTOOL_ENABLE_NETLINK ethtool_SOURCES += \ netlink/netlink.c netlink/netlink.h netlink/extapi.h \ + netlink/strset.c netlink/strset.h \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h ethtool_CFLAGS += @MNL_CFLAGS@
netlink/strset.c new file +265 -0
265 lines not on this page · raw message
netlink/strset.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef ETHTOOL_NETLINK_STRSET_H__ +#define ETHTOOL_NETLINK_STRSET_H__ + +struct stringset ; + +const struct stringset *global_stringset (unsigned int type); +const struct stringset *perdev_stringset (const char *dev,unsigned int type); + +unsigned int get_count (const struct stringset *set); +const char *get_string (const struct stringset *set,unsigned int idx); + +int load_global_strings (struct nl_context *nlctx); +int load_perdev_strings (struct nl_context *nlctx,const char *dev); +void free_perdev_strings (const char *devname); + +#endif /* ETHTOOL_NETLINK_STRSET_H__ */
Signature · 1 line
2.18.0
RFC PATCH v2 5/23 netlink: add notification monitor
In reply to Michal KubecekWith 'ethtool --monitor [ --all | opt ] [dev]', let ethtool listen to netlink notification and display them in a format similar to output of related "get" commands. With --all, show all types of notifications. If device name is specified, show only notifications for that device, if no device name or "*" is passed, show notifications for all devices.
--- Makefile.am | 2 +- ethtool.c | 17 ++++ netlink/extapi.h | 4 + netlink/monitor.c | 218 ++++++++++++++++++++++++++++++++++++++++++++++ netlink/netlink.c | 32 ++++++- netlink/netlink.h | 26 ++++++ 6 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 netlink/monitor.c
Makefile.am +1 -1
@@ -22,7 +22,7 @@ endif if ETHTOOL_ENABLE_NETLINK ethtool_SOURCES += \ netlink/netlink.c netlink/netlink.h netlink/extapi.h \ - netlink/strset.c netlink/strset.h \ + netlink/strset.c netlink/strset.h netlink/monitor.c \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h ethtool_CFLAGS += @MNL_CFLAGS@
ethtool.c +17 -0
@@ -5294,6 +5294,9 @@ static int show_usage(struct cmd_context *ctx)if (args[i].opthelp)fputs (args[i].opthelp, stdout); } +#ifdef ETHTOOL_ENABLE_NETLINK +monitor_usage (); +#endif return 0 ; }
@@ -5335,6 +5338,20 @@ int main(int argc, char **argp) argp++; argc--; +#ifdef ETHTOOL_ENABLE_NETLINK +if (*argp && !strcmp (*argp,"--monitor" )) { +if (netlink_init (&ctx)) { +fprintf (stderr, +"Option --monitor is only available with netlink.\n" ); +return 1 ; + }else { + ctx.argp = ++argp; + ctx.argc = --argc; +return nl_monitor (&ctx); + } + } +#endif +/* First argument must be either a valid option or a device * name to get settings for (which we don't expect to begin * with '-').
netlink/extapi.h +4 -0
@@ -13,4 +13,8 @@ struct nl_context;int netlink_init (struct cmd_context *ctx);int netlink_done (struct cmd_context *ctx); +int nl_monitor (struct cmd_context *ctx); + +void monitor_usage (); +#endif /* ETHTOOL_EXTAPI_H__ */
netlink/monitor.c new file +218 -0
218 lines not on this page · raw message
netlink/netlink.c +31 -1
@@ -391,6 +391,31 @@ err:/* get ethtool family id */ +static void ethnl_find_monitor_group (struct nl_context *nlctx, +struct nlattr *nest) +{ +const struct nlattr *grp_tb[CTRL_ATTR_MCAST_GRP_MAX +1 ] = {}; +DECLARE_ATTR_TB_INFO (grp_tb); +struct nlattr *grp_attr; +int ret; + + nlctx->mon_mcgrp_id =0 ; +mnl_attr_for_each_nested (grp_attr, nest) { + ret =mnl_attr_parse_nested (grp_attr, attr_cb, &grp_tb_info); +if (ret <0 ) +return ; +if (!grp_tb[CTRL_ATTR_MCAST_GRP_NAME ] || + !grp_tb[CTRL_ATTR_MCAST_GRP_ID ]) +continue ; +if (strcmp (mnl_attr_get_str (grp_tb[CTRL_ATTR_MCAST_GRP_NAME ]), +ETHTOOL_MCGRP_MONITOR_NAME )) +continue ; + nlctx->mon_mcgrp_id = +mnl_attr_get_u32 (grp_tb[CTRL_ATTR_MCAST_GRP_ID ]); +return ; + } +} +static int ethnl_family_cb (const struct nlmsghdr *nlhdr,void *data) {struct nl_context *nlctx = data;
@@ -398,9 +423,13 @@ static int ethnl_family_cb(const struct nlmsghdr *nlhdr, void *data) nlctx->ethnl_fam =0 ;mnl_attr_for_each (attr, nlhdr,GENL_HDRLEN ) { -if (mnl_attr_get_type (attr) ==CTRL_ATTR_FAMILY_ID ) { +switch (mnl_attr_get_type (attr)) { +case CTRL_ATTR_FAMILY_ID : nlctx->ethnl_fam =mnl_attr_get_u16 (attr);break ; +case CTRL_ATTR_MCAST_GROUPS : +ethnl_find_monitor_group (nlctx, attr); +break ; } }
@@ -478,6 +507,7 @@ int __init_aux_nlctx(struct nl_context *nlctx) } aux->ethnl_fam = nlctx->ethnl_fam; + aux->mon_mcgrp_id = nlctx->mon_mcgrp_id; nlctx->aux_nlctx = aux;return 0 ;
netlink/netlink.h +26 -0
@@ -17,6 +17,7 @@struct nl_context {int ethnl_fam; +uint32_t mon_mcgrp_id;struct mnl_socket *sk;struct nl_context *aux_nlctx;void *cmd_private;
@@ -30,6 +31,10 @@ struct nl_context {const char *devname;bool is_dump;int exit_code; +bool is_monitor; +uint8_t filter_cmd; +uint32_t filter_mask; +const char *filter_devname; };struct attr_tb_info {
@@ -144,6 +149,27 @@ static inline void show_u32_yn(const struct nlattr **tb, unsigned int idx, mnl_attr_get_u32(tb[idx]) ? "yes" : "no"); } +/* reply content filtering */ + +static inline bool mask_ok (const struct nl_context *nlctx,uint32_t bits) +{ +return !nlctx->filter_mask || (nlctx->filter_mask & bits); +} + +static inline bool dev_ok (const struct nl_context *nlctx) +{ +return !nlctx->filter_devname || + (nlctx->devname && + !strcmp (nlctx->devname, nlctx->filter_devname)); +} + +static inline bool show_only (const struct nl_context *nlctx,uint32_t bits) +{ +if (nlctx->is_monitor || !nlctx->filter_mask) +return false; +return nlctx->filter_mask & ~bits; +} +/* misc */ static inline int init_aux_nlctx (struct nl_context *nlctx)
Signature · 1 line
2.18.0
RFC PATCH v2 6/23 netlink: add netlink handler for gdrv (-i)
In reply to Michal KubecekImplement "-i" subcommand using netlink interface command ETHNL_CMD_GET_DRVINFO.
--- Makefile.am | 1 + ethtool.c | 3 ++- netlink/drvinfo.c | 43 +++++++++++++++++++++++++++++++++++++++++++ netlink/extapi.h | 1 + netlink/monitor.c | 10 ++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 netlink/drvinfo.c
Makefile.am +1 -0
@@ -23,6 +23,7 @@ if ETHTOOL_ENABLE_NETLINK ethtool_SOURCES += \ netlink/netlink.c netlink/netlink.h netlink/extapi.h \ netlink/strset.c netlink/strset.h netlink/monitor.c \ + netlink/drvinfo.c \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h ethtool_CFLAGS += @MNL_CFLAGS@
ethtool.c +2 -1
@@ -5056,6 +5056,7 @@ static int show_usage(struct cmd_context *ctx);/* Just define all netlink handlers as null when building without netlink * support so that we do not get unresolved symbols in args array below */ +#define nl_gdrv NULL#endif static const struct option {
@@ -5125,7 +5126,7 @@ static const struct option { {"-K|--features|--offload" ,1 , do_sfeatures,NULL ,"Set protocol offload and other features" , " FEATURE on|off ...\n" }, - { "-i|--driver", 1, do_gdrv, NULL, + { "-i|--driver", 1, do_gdrv, nl_gdrv, "Show driver information" }, { "-d|--register-dump", 1, do_gregs, NULL, "Do a register dump",
netlink/drvinfo.c new file +43 -0
43 lines not on this page · raw message
netlink/extapi.h +1 -0
@@ -13,6 +13,7 @@ struct nl_context;int netlink_init (struct cmd_context *ctx);int netlink_done (struct cmd_context *ctx); +int nl_gdrv (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +10 -0
@@ -66,6 +66,8 @@ static int monitor_event_cb(const struct nlmsghdr *nlhdr, void *data)return MNL_CB_OK ; } +int drvinfo_reply_cb (const struct nlmsghdr *nlhdr,void *data); + static struct { uint8_t cmd; mnl_cb_t cb;
@@ -74,6 +76,10 @@ static struct { .cmd = ETHNL_CMD_EVENT, .cb = monitor_event_cb, }, + { + .cmd = ETHNL_CMD_SET_DRVINFO, + .cb = drvinfo_reply_cb, + }, };static int monitor_any_cb (const struct nlmsghdr *nlhdr,void *data)
@@ -103,6 +109,10 @@ static struct monitor_option monitor_opts[] = { .pattern = "--all", .cmd = 0, }, + { + .pattern = "-i|--driver", + .cmd = ETHNL_CMD_SET_DRVINFO, + }, };static bool pattern_match (const char *s,const char *pattern)
Signature · 1 line
2.18.0
RFC PATCH v2 7/23 netlink: add netlink handler for gset (no option)
In reply to Michal KubecekImplement "ethtool <dev>" subcommand using netlink interface command ETHNL_CMD_GET_SETTINGS.
Move some output helpers used by both ioctl() and netlink from ethtool.c into new file common.c.
--- Makefile.am | 4 +- common.c | 285 ++++++++++++++++++++++++++++++++++++++++++ common.h | 60 +++++++++ ethtool.c | 151 ++--------------------- netlink/extapi.h | 1 + netlink/monitor.c | 14 +++ netlink/netlink.c | 120 ++++++++++++++++++ netlink/netlink.h | 4 + netlink/settings.c | 301 +++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 796 insertions(+), 144 deletions(-) create mode 100644 common.c create mode 100644 common.h create mode 100644 netlink/settings.c
Makefile.am +2 -2
@@ -6,7 +6,7 @@ EXTRA_DIST = LICENSE ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog autogen.sh sbin_PROGRAMS = ethtool ethtool_SOURCES = ethtool.c uapi/linux/ethtool.h internal.h \ - uapi/linux/net_tstamp.h rxclass.c + uapi/linux/net_tstamp.h rxclass.c common.c common.h ethtool_CFLAGS = -I./uapi -Wall ethtool_LDADD = -lm if ETHTOOL_ENABLE_PRETTY_DUMP
@@ -23,7 +23,7 @@ if ETHTOOL_ENABLE_NETLINK ethtool_SOURCES += \ netlink/netlink.c netlink/netlink.h netlink/extapi.h \ netlink/strset.c netlink/strset.h netlink/monitor.c \ - netlink/drvinfo.c \ + netlink/drvinfo.c netlink/settings.c \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h ethtool_CFLAGS += @MNL_CFLAGS@
common.c new file +285 -0
285 lines not on this page · raw message
common.h new file +60 -0
60 lines not on this page · raw message
ethtool.c +9 -142
216 lines not on this page · raw message
netlink/extapi.h +1 -0
@@ -14,6 +14,7 @@ int netlink_init(struct cmd_context *ctx);int netlink_done (struct cmd_context *ctx);int nl_gdrv (struct cmd_context *ctx); +int nl_gset (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +14 -0
@@ -67,6 +67,7 @@ static int monitor_event_cb(const struct nlmsghdr *nlhdr, void *data) }int drvinfo_reply_cb (const struct nlmsghdr *nlhdr,void *data); +int settings_reply_cb (const struct nlmsghdr *nlhdr,void *data); static struct { uint8_t cmd;
@@ -80,6 +81,10 @@ static struct { .cmd = ETHNL_CMD_SET_DRVINFO, .cb = drvinfo_reply_cb, }, + { + .cmd = ETHNL_CMD_SET_SETTINGS, + .cb = settings_reply_cb, + }, };static int monitor_any_cb (const struct nlmsghdr *nlhdr,void *data)
@@ -113,6 +118,15 @@ static struct monitor_option monitor_opts[] = { .pattern = "-i|--driver", .cmd = ETHNL_CMD_SET_DRVINFO, }, + { + .pattern = "|-s|--change", + .cmd = ETHNL_CMD_SET_SETTINGS, + .info_mask = ETH_SETTINGS_IM_LINKINFO | + ETH_SETTINGS_IM_LINKMODES | + ETH_SETTINGS_IM_MSGLEVEL | + ETH_SETTINGS_IM_WOLINFO | + ETH_SETTINGS_IM_LINK, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/netlink.c +120 -0
134 lines not on this page · raw message
netlink/netlink.h +4 -0
@@ -58,6 +58,10 @@ bool bitset_get_bit(const struct nlattr *bitset, bool mask, unsigned int idx, int *retptr);bool bitset_is_empty (const struct nlattr *bitset,bool mask,int *retptr); +int dump_link_modes (const struct nlattr *bitset,bool mask,unsigned class, +const char *before,const char *between,const char *after, +const char *if_none); +int msg_init (struct nl_context *nlctx,int cmd,unsigned int flags);int ethnl_process_reply (struct nl_context *nlctx,mnl_cb_t reply_cb);int attr_cb (const struct nlattr *attr,void *data);
netlink/settings.c new file +301 -0
301 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 8/23 netlink: add helpers for command line parsing
In reply to Michal KubecekSupport for easier parsing of subcommand parameters and their values from command line. Existing parser helpers in ethtool.c are closely tied to ioctl() interface and using them would be often inconvenient.
--- Makefile.am | 1 + netlink/netlink.h | 4 + netlink/parser.c | 527 ++++++++++++++++++++++++++++++++++++++++++++++ netlink/parser.h | 45 ++++ 4 files changed, 577 insertions(+) create mode 100644 netlink/parser.c create mode 100644 netlink/parser.h
Makefile.am +1 -0
@@ -23,6 +23,7 @@ if ETHTOOL_ENABLE_NETLINK ethtool_SOURCES += \ netlink/netlink.c netlink/netlink.h netlink/extapi.h \ netlink/strset.c netlink/strset.h netlink/monitor.c \ + netlink/parser.c netlink/parser.h \ netlink/drvinfo.c netlink/settings.c \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h
netlink/netlink.h +4 -0
@@ -30,6 +30,10 @@ struct nl_context {void *msg;const char *devname;bool is_dump; +const char *cmd; +const char *param; +char **argp; +int argc;int exit_code;bool is_monitor;uint8_t filter_cmd;
netlink/parser.c new file +527 -0
527 lines not on this page · raw message
netlink/parser.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 9/23 netlink: add netlink handler for sset (-s)
In reply to Michal KubecekImplement "ethtool -s <dev>" subcommand using netlink interface command ETHNL_CMD_SET_SETTINGS.
Add specific parsers for wol modes and MAC address (used for wake-on-lan password here).
--- ethtool.c | 9 +- netlink/extapi.h | 1 + netlink/netlink.c | 9 ++ netlink/netlink.h | 1 + netlink/parser.c | 34 ++++++- netlink/parser.h | 4 + netlink/settings.c | 216 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 269 insertions(+), 5 deletions(-)
ethtool.c +5 -4
@@ -4923,6 +4923,7 @@ static int show_usage(struct cmd_context *ctx);*/ #define nl_gdrv NULL#define nl_gset NULL +#define nl_sset NULL#endif static const struct option {
@@ -4933,19 +4934,19 @@ static const struct option {char *help;char *opthelp; } args[] = { - {"-s|--change" ,1 , do_sset,NULL , + {"-s|--change" ,1 , do_sset, nl_sset,"Change generic options" ," [ speed %d ]\n" " [ duplex half|full ]\n" " [ port tp|aui|bnc|mii|fibre ]\n" " [ mdix auto|on|off ]\n" " [ autoneg on|off ]\n" -" [ advertise %x ]\n" +" [ advertise %x[/%x] | mode on|off ... [--] ]\n" " [ phyad %d ]\n" " [ xcvr internal|external ]\n" -" [ wol p|u|m|b|a|g|s|d... ]\n" +" [ wol %d[/%d] | p|u|m|b|a|g|s|d...[/p|u|m|b|a|g|s|d...] ]\n" " [ sopass %x:%x:%x:%x:%x:%x ]\n" - " [ msglvl %d | msglvl type on|off ... ]\n" }, + " [ msglvl %d[/%d] | type on|off ... [--] ]\n" }, { "-a|--show-pause", 1, do_gpause, NULL, "Show pause options" }, { "-A|--pause", 1, do_spause, NULL,
netlink/extapi.h +1 -0
@@ -15,6 +15,7 @@ int netlink_done(struct cmd_context *ctx);int nl_gdrv (struct cmd_context *ctx);int nl_gset (struct cmd_context *ctx); +int nl_sset (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/netlink.c +9 -0
@@ -573,6 +573,15 @@ static int get_ethnl_family(struct nl_context *nlctx)return (nlctx->ethnl_fam ?0 : -EADDRNOTAVAIL ); } +int nomsg_reply_cb (const struct nlmsghdr *nlhdr,void *data) +{ +const struct genlmsghdr *ghdr = (const struct genlmsghdr *)(nlhdr +1 ); + +fprintf (stderr,"received unexpected message: len=%u type=%u cmd=%u\n" , + nlhdr->nlmsg_len, nlhdr->nlmsg_type, ghdr->cmd); +return MNL_CB_OK ; +} +/* initialization */ static int nlctx_init (struct nl_context *nlctx)
netlink/netlink.h +1 -0
@@ -72,6 +72,7 @@ int attr_cb(const struct nlattr *attr, void *data);int ethnl_prep_get_request (struct cmd_context *ctx,unsigned int nlcmd,uint16_t dev_attrtype);int ethnl_send_get_request (struct nl_context *nlctx,mnl_cb_t cb); +int nomsg_reply_cb (const struct nlmsghdr *nlhdr,void *data);int __init_aux_nlctx (struct nl_context *nlctx);/* put data wrappers */
netlink/parser.c +33 -1
@@ -69,7 +69,7 @@ static int parse_x32(const char *arg, u32 *result)return __parse_u32 (arg, result,0 ,0xffffffff ,16 ); } -static int parse_u32 (const char *arg,u32 *result) +int parse_u32 (const char *arg,u32 *result) {if (!arg)return -EINVAL ;
@@ -485,6 +485,38 @@ int nl_parse_bitset(struct nl_context *nlctx, uint16_t type, const void *data)return nl_parse_bitset_list (nlctx, type, data); } +int nl_parse_mac_addr (struct nl_context *nlctx,uint16_t type,const void *data) +{ +const char *arg = *nlctx->argp; +u8 val[ETH_ALEN ]; +unsigned int i; +const char *p; + + nlctx->argp++; + nlctx->argc--; + + p = arg; + i =0 ; +while (i <ETH_ALEN && *p) { +char *endp; +unsigned long byte =strtoul (p, &endp,16 ); + +if ((endp - p >2 ) || (*endp && *endp !=':' )) + goto err; + val[i++] = (u8 ) byte; + p = endp + (*endp ?1 :0 ); + } +if (i <ETH_ALEN ) + goto err; + +return ethnla_put (nlctx, type,ETH_ALEN , val); + +err: +fprintf (stderr,"ethtool (%s): invalid value '%s' of parameter '%s'\n" , + nlctx->cmd, arg, nlctx->param); +return -EINVAL ; +} +int nl_parser (struct cmd_context *ctx,const struct param_parser *params,unsigned int max_type) {
netlink/parser.h +4 -0
@@ -28,6 +28,8 @@ struct param_parser {unsigned int min_argc; }; +int parse_u32 (const char *arg,u32 *result); +int nl_parse_direct_u32 (struct nl_context *nlctx,uint16_t type,const void *data); int nl_parse_direct_u8(struct nl_context *nlctx, uint16_t type,
@@ -38,6 +40,8 @@ int nl_parse_lookup_u8(struct nl_context *nlctx, uint16_t type,int nl_parse_bitfield32 (struct nl_context *nlctx,uint16_t type,const void *data);int nl_parse_bitset (struct nl_context *nlctx,uint16_t type,const void *data); +int nl_parse_mac_addr (struct nl_context *nlctx,uint16_t type, +const void *data);int nl_parser (struct cmd_context *ctx,const struct param_parser *params,unsigned int max_type);
netlink/settings.c +216 -0
225 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 10/23 netlink: add netlink handler for gfeatures (-k)
In reply to Michal KubecekImplement "ethtool -k <dev>" subcommand using netlink interface command ETHNL_CMD_GET_SETTINGS with ETH_SETTINGS_IM_FEATURES mask.
The implementation tries to emulate legacy flags but the result is not exactly equal to the ioctl code. In particular, we map netdev features to legacy flags based on name patterns in off_flag_def[] but this mapping is slightly different from mapping used by kernel ioctl code.
--- common.c | 30 ++++++ common.h | 21 +++++ ethtool.c | 70 +++----------- netlink/extapi.h | 1 + netlink/monitor.c | 6 ++ netlink/settings.c | 226 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 296 insertions(+), 58 deletions(-)
common.c +30 -0
@@ -283,3 +283,33 @@ void dump_mdix(u8 mdix, u8 mdix_ctrl)fprintf (stdout,"\n" ); } } + +const struct off_flag_def off_flag_def[OFF_FLAG_DEF_SIZE ] = { + {"rx" ,"rx-checksumming" ,"rx-checksum" , +ETHTOOL_GRXCSUM ,ETHTOOL_SRXCSUM ,ETH_FLAG_RXCSUM ,0 }, + {"tx" ,"tx-checksumming" ,"tx-checksum-*" , +ETHTOOL_GTXCSUM ,ETHTOOL_STXCSUM ,ETH_FLAG_TXCSUM ,0 }, + {"sg" ,"scatter-gather" ,"tx-scatter-gather*" , +ETHTOOL_GSG ,ETHTOOL_SSG ,ETH_FLAG_SG ,0 }, + {"tso" ,"tcp-segmentation-offload" ,"tx-tcp*-segmentation" , +ETHTOOL_GTSO ,ETHTOOL_STSO ,ETH_FLAG_TSO ,0 }, + {"ufo" ,"udp-fragmentation-offload" ,"tx-udp-fragmentation" , +ETHTOOL_GUFO ,ETHTOOL_SUFO ,ETH_FLAG_UFO ,0 }, + {"gso" ,"generic-segmentation-offload" ,"tx-generic-segmentation" , +ETHTOOL_GGSO ,ETHTOOL_SGSO ,ETH_FLAG_GSO ,0 }, + {"gro" ,"generic-receive-offload" ,"rx-gro" , +ETHTOOL_GGRO ,ETHTOOL_SGRO ,ETH_FLAG_GRO ,0 }, + {"lro" ,"large-receive-offload" ,"rx-lro" , +0 ,0 ,ETH_FLAG_LRO , +KERNEL_VERSION (2 ,6 ,24 ) }, + {"rxvlan" ,"rx-vlan-offload" ,"rx-vlan-hw-parse" , +0 ,0 ,ETH_FLAG_RXVLAN , +KERNEL_VERSION (2 ,6 ,37 ) }, + {"txvlan" ,"tx-vlan-offload" ,"tx-vlan-hw-insert" , +0 ,0 ,ETH_FLAG_TXVLAN , +KERNEL_VERSION (2 ,6 ,37 ) }, + {"ntuple" ,"ntuple-filters" ,"rx-ntuple-filter" , +0 ,0 ,ETH_FLAG_NTUPLE ,0 }, + {"rxhash" ,"receive-hashing" ,"rx-hashing" , +0 ,0 ,ETH_FLAG_RXHASH ,0 }, +};
common.h +21 -0
@@ -1,6 +1,8 @@ #ifndef ETHTOOL_COMMON_H__ #define ETHTOOL_COMMON_H__ +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) + struct flag_info { const char *name; u32 value;
@@ -25,6 +27,25 @@ struct link_mode_info {u8 duplex; }; +struct off_flag_def { +const char *short_name; +const char *long_name; +const char *kernel_name; +u32 get_cmd, set_cmd; +u32 value; +/* For features exposed through ETHTOOL_GFLAGS, the oldest +* kernel version for which we can trust the result. Where +* the flag was added at the same time the kernel started +* supporting the feature, this is 0 (to allow for backports). +* Where the feature was supported before the flag was added, +* it is the version that introduced the flag. +*/ +u32 min_kernel_ver; +}; + +#define OFF_FLAG_DEF_SIZE 12 +extern const struct off_flag_def off_flag_def[OFF_FLAG_DEF_SIZE ]; +extern const struct link_mode_info link_modes[];extern const unsigned int link_modes_count;
ethtool.c +12 -58
149 lines not on this page · raw message
netlink/extapi.h +1 -0
@@ -16,6 +16,7 @@ int netlink_done(struct cmd_context *ctx);int nl_gdrv (struct cmd_context *ctx);int nl_gset (struct cmd_context *ctx);int nl_sset (struct cmd_context *ctx); +int nl_gfeatures (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +6 -0
@@ -127,6 +127,12 @@ static struct monitor_option monitor_opts[] = {ETH_SETTINGS_IM_WOLINFO | ETH_SETTINGS_IM_LINK, }, + { + .pattern ="-k|--show-features|--show-offload" + "|-K|--features|--offload", + .cmd = ETHNL_CMD_SET_SETTINGS, + .info_mask = ETH_SETTINGS_IM_FEATURES, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/settings.c +226 -0
250 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 11/23 netlink: add netlink handler for sfeatures (-K)
In reply to Michal KubecekImplement "ethtool -K <dev>" subcommand using netlink interface command ETHNL_CMD_SET_SETTINGS.
The implementation tries to emulate legacy flags but the result is not exactly equal to the ioctl code. In particular, we map netdev features to legacy flags based on name patterns in off_flag_def[] but this mapping is slightly different from mapping used by kernel ioctl code. It also does not try to emulate legacy flags in "actual changes" output show when actual change of device features does not match userspace request exactly.
--- ethtool.c | 3 +- netlink/extapi.h | 1 + netlink/settings.c | 292 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 295 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4878,6 +4878,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gset NULL#define nl_sset NULL#define nl_gfeatures NULL +#define nl_sfeatures NULL#endif static const struct option {
@@ -4944,7 +4945,7 @@ static const struct option { " [ tx N ]\n" }, {"-k|--show-features|--show-offload" ,1 , do_gfeatures, nl_gfeatures, "Get state of protocol offload and other features" }, - { "-K|--features|--offload", 1, do_sfeatures, NULL, + { "-K|--features|--offload", 1, do_sfeatures, nl_sfeatures,"Set protocol offload and other features" , " FEATURE on|off ...\n" }, { "-i|--driver", 1, do_gdrv, nl_gdrv,
netlink/extapi.h +1 -0
@@ -17,6 +17,7 @@ int nl_gdrv(struct cmd_context *ctx);int nl_gset (struct cmd_context *ctx);int nl_sset (struct cmd_context *ctx);int nl_gfeatures (struct cmd_context *ctx); +int nl_sfeatures (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/settings.c +292 -0
295 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 12/23 netlink: add netlink handler for gcoalesce (-c)
In reply to Michal KubecekImplement "ethtool -c <dev>" subcommand using netlink interface command ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_COALESCE mask.
--- Makefile.am | 2 +- ethtool.c | 3 +- netlink/extapi.h | 1 + netlink/monitor.c | 10 +++++ netlink/params.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 netlink/params.c
Makefile.am +1 -1
@@ -24,7 +24,7 @@ ethtool_SOURCES += \ netlink/netlink.c netlink/netlink.h netlink/extapi.h \ netlink/strset.c netlink/strset.h netlink/monitor.c \ netlink/parser.c netlink/parser.h \ - netlink/drvinfo.c netlink/settings.c \ + netlink/drvinfo.c netlink/settings.c netlink/params.c \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h ethtool_CFLAGS += @MNL_CFLAGS@
ethtool.c +2 -1
@@ -4879,6 +4879,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_sset NULL#define nl_gfeatures NULL#define nl_sfeatures NULL +#define nl_gcoalesce NULL#endif static const struct option {
@@ -4909,7 +4910,7 @@ static const struct option {" [ autoneg on|off ]\n" " [ rx on|off ]\n" " [ tx on|off ]\n" }, - { "-c|--show-coalesce", 1, do_gcoalesce, NULL, + { "-c|--show-coalesce", 1, do_gcoalesce, nl_gcoalesce, "Show coalesce options" }, { "-C|--coalesce", 1, do_scoalesce, NULL, "Set coalesce options",
netlink/extapi.h +1 -0
@@ -18,6 +18,7 @@ int nl_gset(struct cmd_context *ctx);int nl_sset (struct cmd_context *ctx);int nl_gfeatures (struct cmd_context *ctx);int nl_sfeatures (struct cmd_context *ctx); +int nl_gcoalesce (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +10 -0
@@ -68,6 +68,7 @@ static int monitor_event_cb(const struct nlmsghdr *nlhdr, void *data)int drvinfo_reply_cb (const struct nlmsghdr *nlhdr,void *data);int settings_reply_cb (const struct nlmsghdr *nlhdr,void *data); +int params_reply_cb (const struct nlmsghdr *nlhdr,void *data); static struct { uint8_t cmd;
@@ -85,6 +86,10 @@ static struct { .cmd = ETHNL_CMD_SET_SETTINGS, .cb = settings_reply_cb, }, + { + .cmd = ETHNL_CMD_SET_PARAMS, + .cb = params_reply_cb, + }, };static int monitor_any_cb (const struct nlmsghdr *nlhdr,void *data)
@@ -133,6 +138,11 @@ static struct monitor_option monitor_opts[] = { .cmd = ETHNL_CMD_SET_SETTINGS, .info_mask = ETH_SETTINGS_IM_FEATURES, }, + { + .pattern = "-c|--show-coalesce|-C|--coalesce", + .cmd = ETHNL_CMD_SET_PARAMS, + .info_mask = ETH_PARAMS_IM_COALESCE, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/params.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 13/23 netlink: add netlink handler for gring (-g)
In reply to Michal KubecekImplement "ethtool -g <dev>" subcommand using netlink interface command ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_RING mask.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/monitor.c | 5 +++++ netlink/params.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4880,6 +4880,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gfeatures NULL#define nl_sfeatures NULL#define nl_gcoalesce NULL +#define nl_gring NULL#endif static const struct option {
@@ -4936,7 +4937,7 @@ static const struct option {" [tx-usecs-high N]\n" " [tx-frames-high N]\n" " [sample-interval N]\n" }, - { "-g|--show-ring", 1, do_gring, NULL, + { "-g|--show-ring", 1, do_gring, nl_gring, "Query RX/TX ring parameters" }, { "-G|--set-ring", 1, do_sring, NULL, "Set RX/TX ring parameters",
netlink/extapi.h +1 -0
@@ -19,6 +19,7 @@ int nl_sset(struct cmd_context *ctx);int nl_gfeatures (struct cmd_context *ctx);int nl_sfeatures (struct cmd_context *ctx);int nl_gcoalesce (struct cmd_context *ctx); +int nl_gring (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +5 -0
@@ -143,6 +143,11 @@ static struct monitor_option monitor_opts[] = { .cmd = ETHNL_CMD_SET_PARAMS, .info_mask = ETH_PARAMS_IM_COALESCE, }, + { + .pattern = "-g|--show-ring|-G|--set-ring", + .cmd = ETHNL_CMD_SET_PARAMS, + .info_mask = ETH_PARAMS_IM_RING, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/params.c +42 -0
57 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 14/23 netlink: add netlink handler for gpause (-a)
In reply to Michal KubecekImplement "ethtool -a <dev>" subcommand using netlink interface command ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_PAUSE mask.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/monitor.c | 5 +++++ netlink/params.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4881,6 +4881,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_sfeatures NULL#define nl_gcoalesce NULL#define nl_gring NULL +#define nl_gpause NULL#endif static const struct option {
@@ -4904,7 +4905,7 @@ static const struct option {" [ wol %d[/%d] | p|u|m|b|a|g|s|d...[/p|u|m|b|a|g|s|d...] ]\n" " [ sopass %x:%x:%x:%x:%x:%x ]\n" " [ msglvl %d[/%d] | type on|off ... [--] ]\n" }, - { "-a|--show-pause", 1, do_gpause, NULL, + { "-a|--show-pause", 1, do_gpause, nl_gpause, "Show pause options" }, { "-A|--pause", 1, do_spause, NULL, "Set pause options",
netlink/extapi.h +1 -0
@@ -20,6 +20,7 @@ int nl_gfeatures(struct cmd_context *ctx);int nl_sfeatures (struct cmd_context *ctx);int nl_gcoalesce (struct cmd_context *ctx);int nl_gring (struct cmd_context *ctx); +int nl_gpause (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +5 -0
@@ -148,6 +148,11 @@ static struct monitor_option monitor_opts[] = { .cmd = ETHNL_CMD_SET_PARAMS, .info_mask = ETH_PARAMS_IM_RING, }, + { + .pattern = "-a|--show-pause|-A|--pause", + .cmd = ETHNL_CMD_SET_PARAMS, + .info_mask = ETH_PARAMS_IM_PAUSE, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/params.c +36 -0
@@ -83,6 +83,28 @@ static int show_ring(struct nl_context *nlctx, const struct nlattr *nest)return 0 ; } +static int show_pause (struct nl_context *nlctx,const struct nlattr *nest) +{ +const struct nlattr *tb[ETHA_PAUSE_MAX +1 ] = {}; +DECLARE_ATTR_TB_INFO (tb); +int ret; + +if (!nest) +return -EOPNOTSUPP ; + ret =mnl_attr_parse_nested (nest, attr_cb, &tb_info); +if (ret <0 ) +return ret; + +printf ("Pause parameters for %s:\n" , nlctx->devname); +show_bool (tb[ETHA_PAUSE_AUTONEG ],"Autonegotiate:\t" ); +show_bool (tb[ETHA_PAUSE_RX ],"RX:\t\t" ); +show_bool (tb[ETHA_PAUSE_TX ],"TX:\t\t" ); +/* ToDo: query negotiated pause frame usage */ +putchar ('\n' ); + +return 0 ; +} +int params_reply_cb (const struct nlmsghdr *nlhdr,void *data) {const struct nlattr *tb[ETHA_PARAMS_MAX +1 ] = {};
@@ -115,6 +137,15 @@ int params_reply_cb(const struct nlmsghdr *nlhdr, void *data)return MNL_CB_ERROR ; } } +if (mask_ok (nlctx,ETH_PARAMS_IM_PAUSE )) { + ret =show_pause (nlctx, tb[ETHA_PARAMS_PAUSE ]); +if ((ret <0 ) &&show_only (nlctx,ETH_PARAMS_IM_PAUSE )) { + nlctx->exit_code =76 ; + errno = -ret; +perror ("Cannot get device pause settings" ); +return MNL_CB_ERROR ; + } + }return MNL_CB_OK ; }
@@ -141,3 +172,8 @@ int nl_gring(struct cmd_context *ctx) {return params_request (ctx,ETH_PARAMS_IM_RING ); } + +int nl_gpause (struct cmd_context *ctx) +{ +return params_request (ctx,ETH_PARAMS_IM_PAUSE ); +}
Signature · 1 line
2.18.0
RFC PATCH v2 15/23 netlink: add netlink handler for gchannels (-l)
In reply to Michal KubecekImplement "ethtool -l <dev>" subcommand using netlink interface command ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_CHANNELS mask.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/monitor.c | 5 +++++ netlink/params.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4882,6 +4882,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gcoalesce NULL#define nl_gring NULL#define nl_gpause NULL +#define nl_gchannels NULL#endif static const struct option {
@@ -5033,7 +5034,7 @@ static const struct option { {"-W|--set-dump" ,1 , do_setfwdump,NULL ,"Set dump flag of the device" , " N\n"}, - { "-l|--show-channels", 1, do_gchannels, NULL, + { "-l|--show-channels", 1, do_gchannels, nl_gchannels, "Query Channels" }, { "-L|--set-channels", 1, do_schannels, NULL, "Set Channels",
netlink/extapi.h +1 -0
@@ -21,6 +21,7 @@ int nl_sfeatures(struct cmd_context *ctx);int nl_gcoalesce (struct cmd_context *ctx);int nl_gring (struct cmd_context *ctx);int nl_gpause (struct cmd_context *ctx); +int nl_gchannels (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +5 -0
@@ -153,6 +153,11 @@ static struct monitor_option monitor_opts[] = { .cmd = ETHNL_CMD_SET_PARAMS, .info_mask = ETH_PARAMS_IM_PAUSE, }, + { + .pattern = "-l|--show-channels|-L|--set-channels", + .cmd = ETHNL_CMD_SET_PARAMS, + .info_mask = ETH_PARAMS_IM_CHANNELS, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/params.c +42 -0
57 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 16/23 netlink: add netlink handler for geee (--show-eee)
In reply to Michal KubecekImplement "ethtool --show-eee <dev>" subcommand using netlink interface command ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_EEE mask.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/monitor.c | 5 ++++ netlink/params.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4883,6 +4883,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gring NULL#define nl_gpause NULL#define nl_gchannels NULL +#define nl_geee NULL#endif static const struct option {
@@ -5053,7 +5054,7 @@ static const struct option {" [ hex on|off ]\n" " [ offset N ]\n" " [ length N ]\n" }, - { "--show-eee", 1, do_geee, NULL, + { "--show-eee", 1, do_geee, nl_geee, "Show EEE settings"}, { "--set-eee", 1, do_seee, NULL, "Set EEE settings",
netlink/extapi.h +1 -0
@@ -22,6 +22,7 @@ int nl_gcoalesce(struct cmd_context *ctx);int nl_gring (struct cmd_context *ctx);int nl_gpause (struct cmd_context *ctx);int nl_gchannels (struct cmd_context *ctx); +int nl_geee (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +5 -0
@@ -158,6 +158,11 @@ static struct monitor_option monitor_opts[] = { .cmd = ETHNL_CMD_SET_PARAMS, .info_mask = ETH_PARAMS_IM_CHANNELS, }, + { + .pattern = "--show-eee|--set-eee", + .cmd = ETHNL_CMD_SET_PARAMS, + .info_mask = ETH_PARAMS_IM_EEE, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/params.c +66 -0
81 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 17/23 netlink: add netlink handler for gfec (--show-fec)
In reply to Michal KubecekImplement "ethtool --show-fec <dev>" subcommand showing Forward Error Correction (FEC) settings using netlink interface command ETHNL_CMD_GET_PARAMS with ETH_PARAMS_IM_FEC mask.
--- common.c | 10 ++++++++++ common.h | 2 ++ ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/monitor.c | 5 +++++ netlink/params.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 1 deletion(-)
common.c +10 -0
@@ -41,6 +41,16 @@ const struct flag_info flags_msglvl[] = { };const unsigned int n_flags_msglvl =ARRAY_SIZE (flags_msglvl) -1 ; +const struct flag_info flags_fecenc[] = { + {"none" ,ETHTOOL_FEC_NONE }, + {"auto" ,ETHTOOL_FEC_AUTO }, + {"off" ,ETHTOOL_FEC_OFF }, + {"RS" ,ETHTOOL_FEC_RS }, + {"baser" ,ETHTOOL_FEC_BASER }, + {} +}; +const unsigned int n_flags_fecenc =ARRAY_SIZE (flags_fecenc) -1 ; +const char *names_duplex[] = { [DUPLEX_HALF ] ="Half" , [DUPLEX_FULL ] ="Full" ,
common.h +2 -0
@@ -10,6 +10,8 @@ struct flag_info {extern const struct flag_info flags_msglvl[];extern const unsigned int n_flags_msglvl; +extern const struct flag_info flags_fecenc[]; +extern const unsigned int n_flags_fecenc;enum link_mode_class {
ethtool.c +2 -1
@@ -4884,6 +4884,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gpause NULL#define nl_gchannels NULL#define nl_geee NULL +#define nl_gfec NULL#endif static const struct option {
@@ -5091,7 +5092,7 @@ static const struct option {" [ ap-shared ]\n" " [ dedicated ]\n" " [ all ]\n"}, - { "--show-fec", 1, do_gfec, NULL, + { "--show-fec", 1, do_gfec, nl_gfec, "Show FEC settings"}, { "--set-fec", 1, do_sfec, NULL, "Set FEC settings",
netlink/extapi.h +1 -0
@@ -23,6 +23,7 @@ int nl_gring(struct cmd_context *ctx);int nl_gpause (struct cmd_context *ctx);int nl_gchannels (struct cmd_context *ctx);int nl_geee (struct cmd_context *ctx); +int nl_gfec (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/monitor.c +5 -0
@@ -163,6 +163,11 @@ static struct monitor_option monitor_opts[] = { .cmd = ETHNL_CMD_SET_PARAMS, .info_mask = ETH_PARAMS_IM_EEE, }, + { + .pattern = "--show-fec|--set-fec", + .cmd = ETHNL_CMD_SET_PARAMS, + .info_mask = ETH_PARAMS_IM_FEC, + }, };static bool pattern_match (const char *s,const char *pattern)
netlink/params.c +43 -0
58 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 18/23 netlink: add netlink handler for scoalesce (-C)
In reply to Michal KubecekImplement "ethtool -C <dev>" subcommand using netlink interface command ETHNL_CMD_SET_PARAMS.
--- ethtool.c | 3 +- netlink/extapi.h | 1 + netlink/params.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4885,6 +4885,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gchannels NULL#define nl_geee NULL#define nl_gfec NULL +#define nl_scoalesce NULL#endif static const struct option {
@@ -4917,7 +4918,7 @@ static const struct option { " [ tx on|off ]\n" }, {"-c|--show-coalesce" ,1 , do_gcoalesce, nl_gcoalesce, "Show coalesce options" }, - { "-C|--coalesce", 1, do_scoalesce, NULL, + { "-C|--coalesce", 1, do_scoalesce, nl_scoalesce,"Set coalesce options" ," [adaptive-rx on|off]\n" " [adaptive-tx on|off]\n"
netlink/extapi.h +1 -0
@@ -24,6 +24,7 @@ int nl_gpause(struct cmd_context *ctx);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_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/params.c +182 -0
185 lines not on this page · raw message
Signature · 1 line
2.18.0
RFC PATCH v2 19/23 netlink: add netlink handler for sring (-G)
In reply to Michal KubecekImplement "ethtool -G <dev>" subcommand using netlink interface command ETHNL_CMD_SET_PARAMS.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/params.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4886,6 +4886,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 {
@@ -4944,7 +4945,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"
netlink/extapi.h +1 -0
@@ -25,6 +25,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 ();
netlink/params.c +34 -0
@@ -510,3 +510,37 @@ int nl_scoalesce(struct cmd_context *ctx)return nl_set_param (ctx,"-C" , scoalesce_params,ETHA_PARAMS_COALESCE ,ETHA_COALESCE_MAX ); } + +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 , +ETHA_RING_MAX ); +}
Signature · 1 line
2.18.0
RFC PATCH v2 20/23 netlink: add netlink handler for spause (-A)
In reply to Michal KubecekImplement "ethtool -A <dev>" subcommand using netlink interface command ETHNL_CMD_SET_PARAMS.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/params.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4887,6 +4887,7 @@ static int show_usage(struct cmd_context *ctx);#define nl_gfec NULL#define nl_scoalesce NULL#define nl_sring NULL +#define nl_spause NULL#endif static const struct option {
@@ -4912,7 +4913,7 @@ static const struct option { " [ msglvl %d[/%d] | type on|off ... [--] ]\n" }, {"-a|--show-pause" ,1 , do_gpause, nl_gpause, "Show pause options" }, - { "-A|--pause", 1, do_spause, NULL, + { "-A|--pause", 1, do_spause, nl_spause,"Set pause options" ," [ autoneg on|off ]\n" " [ rx on|off ]\n"
netlink/extapi.h +1 -0
@@ -26,6 +26,7 @@ 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_spause (struct cmd_context *ctx);int nl_monitor (struct cmd_context *ctx);void monitor_usage ();
netlink/params.c +28 -0
@@ -544,3 +544,31 @@ int nl_sring(struct cmd_context *ctx)return nl_set_param (ctx,"-G" , sring_params,ETHA_PARAMS_RING ,ETHA_RING_MAX ); } + +static const struct param_parser spause_params[] = { + { + .arg ="autoneg" , + .type =ETHA_PAUSE_AUTONEG , + .handler = nl_parse_bool, + .min_argc =1 , + }, + { + .arg ="rx" , + .type =ETHA_PAUSE_RX , + .handler = nl_parse_bool, + .min_argc =1 , + }, + { + .arg ="tx" , + .type =ETHA_PAUSE_TX , + .handler = nl_parse_bool, + .min_argc =1 , + }, + {} +}; + +int nl_spause (struct cmd_context *ctx) +{ +return nl_set_param (ctx,"-A" , spause_params,ETHA_PARAMS_PAUSE , +ETHA_PAUSE_MAX ); +}
Signature · 1 line
2.18.0
RFC PATCH v2 21/23 netlink: add netlink handler for schannels (-L)
In reply to Michal KubecekImplement "ethtool -L <dev>" subcommand using netlink interface command ETHNL_CMD_SET_PARAMS.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/params.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -4888,6 +4888,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 {
@@ -5041,7 +5042,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"
netlink/extapi.h +1 -0
@@ -27,6 +27,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 ();
netlink/params.c +34 -0
@@ -572,3 +572,37 @@ int nl_spause(struct cmd_context *ctx)return nl_set_param (ctx,"-A" , spause_params,ETHA_PARAMS_PAUSE ,ETHA_PAUSE_MAX ); } + +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 , +ETHA_CHANNELS_MAX ); +}
Signature · 1 line
2.18.0
RFC PATCH v2 22/23 netlink: add netlink handler for seee (--set-eee)
In reply to Michal KubecekImplement "ethtool --set-eee <dev>" subcommand using netlink interface command ETHNL_CMD_SET_PARAMS.
--- ethtool.c | 5 +++-- netlink/extapi.h | 1 + netlink/params.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-)
ethtool.c +3 -2
@@ -4889,6 +4889,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 {
@@ -5061,10 +5062,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,
netlink/extapi.h +1 -0
@@ -28,6 +28,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 ();
netlink/params.c +34 -0
@@ -606,3 +606,37 @@ int nl_schannels(struct cmd_context *ctx)return nl_set_param (ctx,"-L" , schannels_params,ETHA_PARAMS_CHANNELS ,ETHA_CHANNELS_MAX ); } + +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_bool, + .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_bool, + .min_argc =1 , + }, + {} +}; + +int nl_seee (struct cmd_context *ctx) +{ +return nl_set_param (ctx,"--set-eee" , seee_params,ETHA_PARAMS_EEE , +ETHA_EEE_MAX ); +}
Signature · 1 line
2.18.0
RFC PATCH v2 23/23 netlink: add netlink handler for sfec (--set-fec)
In reply to Michal KubecekImplement "ethtool --set-fec <dev>" subcommand using netlink interface command ETHNL_CMD_SET_PARAMS.
--- ethtool.c | 3 ++- netlink/extapi.h | 1 + netlink/params.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)
ethtool.c +2 -1
@@ -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,
netlink/extapi.h +1 -0
@@ -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 ();
netlink/params.c +17 -0
@@ -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 ); +}
Signature · 1 line
2.18.0
A message that is not in the archive (sent off-list or not yet received): BN6PR1101MB2130A3A92409FBF732174764E7C40@BN6PR1101MB2130.namprd11.prod.outlook.com
Quoted 11 lines · On Wed, Nov 07, 2018 at 11:57:03PM +0000, [email protected] wrote:
Quoted 9 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Michal Kubecek
Sent: Monday, July 30, 2018 8:56 AM
To: [email protected]
Cc: [email protected]; John W. Linville <[email protected]>
Subject: [RFC PATCH ethtool v2 00/23] ethtool netlink interface (userspace side) (WiP)(The series is based on v4.17)
Can you help me find exact version of version I can apply patch? v4.17 from either net-next.git or linux.git shows some failure while patching.
Based on the subject you quoted, you tried to apply the patch series for ethtool (userspace utility). Kernel patch series was sent shortly before this one with subject "[RFC PATCH net-next v2 00/17] ethtool netlink interface (WiP)":
http://patchwork.ozlabs.org/project/netdev/list/?series=58290&state=*
But if you want to try it, I would rather suggest updated version from
https://github.com/mkubecek/ethnl
It has kernel series based on current net-next (this morning) and ethtool series based on v4.19.
I would like to send a v3 to the list soon but in the last few weeks I was quite busy with higher priority work.
Michal Kubecek
Hi Michal,
Quoted 4 lines
Based on the subject you quoted, you tried to apply the patch series for ethtool (userspace utility). Kernel patch series was sent shortly before this one with subject "[RFC PATCH net-next v2 00/17] ethtool netlink interface (WiP)":
Oh.. You are right. I picked up wrong email header. :(
Quoted 6 lines
But if you want to try it, I would rather suggest updated version from
https://github.com/mkubecek/ethnl
It has kernel series based on current net-next (this morning) and ethtool series based on v4.19.
Thanks for this link. It would be clean tree.
Quoted 2 lines
I would like to send a v3 to the list soon but in the last few weeks I was quite busy with higher priority work.
Great news. Will wait new series.
Regards,
Woojung