linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Andrew Lunn <andrew@lunn.ch>,
	John Linville <linville@tuxdriver.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 12/22] ethtool: provide string sets with GET_STRSET request
Date: Thu, 28 Mar 2019 14:43:13 +0100	[thread overview]
Message-ID: <20190328134313.GO14297@nanopsycho> (raw)
In-Reply-To: <20190328071853.GY26076@unicorn.suse.cz>

Thu, Mar 28, 2019 at 08:18:53AM CET, mkubecek@suse.cz wrote:
>On Wed, Mar 27, 2019 at 07:25:47PM -0700, Florian Fainelli wrote:
>> > +GET_STRSET
>> > +----------
>> > +
>> > +Requests contents of a string set as provided by ioctl commands
>> > +ETHTOOL_GSSET_INFO and ETHTOOL_GSTRINGS. String sets are not user writeable so
>> > +that the corresponding SET_STRSET message is only used in kernel replies.
>> > +There are two types of string sets: global (independent of a device, e.g.
>> > +device feature names) and device specific (e.g. device private flags).
>> > +
>> > +Request contents:
>> > +
>> > +    ETHA_STRSET_DEV		(nested)	device identification
>> > +    ETHA_STRSET_COUNTS		(flag)		request only string counts
>> 
>> Should not that be part of the nested attribute under
>> ETHA_STRSET_STRINGSET. We should probably think about adding another
>> flag which indicates that we want to get the stringset associated data,
>> see below why.
>> 
>> > +    ETHA_STRSET_STRINGSET	(nested)	string set to request
>> > +        ETHA_STRINGSET_ID		(u32)		set id
>> > +
>> > +Kernel response contents:
>> > +
>> > +    ETHA_STRSET_DEV		(nested)	device identification
>> > +    ETHA_STRSET_STRINGSET	(nested)	string set to request
>> 
>> string set requested?
>> 
>> > +        ETHA_STRINGSET_ID		(u32)		set id
>> > +        ETHA_STRINGSET_COUNT		(u32)		number of strings
>> > +        ETHA_STRINGSET_STRINGS		(nested)	array of strings
>> > +            ETHA_STRING_INDEX			(u32)		string index
>> > +            ETHA_STRING_VALUE			(string)	string value
>> 
>> This is one of the areas where the legacy ethtool ioctl() is painful
>> because we need to request a string set to know how many of those exist
>> to allocate space for those in both kernel and user space.
>> 
>> If we could find a way to have a single command that allows us to dump
>> stringset (count, values) and associated data, then we save ourselves a
>> context switch and having to pre-allocate memory accordingly.
>
>The way the proposed interface is designed, we can get both without an
>extra roundtrip but it's done the other way around, i.e. passing the
>strings with the request for data. The API allows two modes of
>operation:
>
>1. One shot requests, e.g. typical ethtool use. We use "verbose" mode
>(no ETHA_*_COMPACT flag in the request) and data is provided together
>with the names. E.g. "ethtool eth2" request would look like
>
>  ETHA_SETTINGS_DEV
>      ETHA_DEV_NAME = "eth2"
>  ETHA_SETTINGS_INFO_MASK = ... | ETH_SETTINGS_IM_LINKMODES | ...
>
>and the reply would be
>
>  ETHA_SETTINGS_DEV = {
>      ETHA_DEV_INDEX = 4
>      ETHA_DEV_NAME = "eth2"
>  }
>  ETHA_SETTINGS_LINK_INFO = {
>      ...
>  }
>  ETHA_SETTRINGS_LINK_MODES = {
>      ETHA_LINKMODES_AUTONEG = 1 (AUTONEG_ENABLE)
>      ETHA_LINKMODES_OURS = {
>          ETHA_BITSET_SIZE = 67
>          ETHA_BITSET_BITS = {
>              ETHA_BITS_BIT = {
>                  ETHA_BIT_INDEX = 0 (ETHTOOL_LINK_MODE_10baseT_Half_BIT)
>                  ETHA_BIT_NAME = "10baseT/Half"
>              }
>              ETHA_BITS_BIT = {
>                  ETHA_BIT_INDEX = 1 (ETHTOOL_LINK_MODE_10baseT_Full_BIT)
>                  ETHA_BIT_NAME = "10baseT/Full"
>              }
>              ETHA_BITS_BIT = {
>                  ETHA_BIT_INDEX = 2 (ETHTOOL_LINK_MODE_100baseT_Half_BIT)
>                  ETHA_BIT_NAME = "100baseT/Half"
>                  ETHA_BIT_VALUE
>              }
>              ETHA_BITS_BIT = {
>                  ETHA_BIT_INDEX = 3 (ETHTOOL_LINK_MODE_100baseT_Full_BIT)
>                  ETHA_BIT_NAME = "100baseT/Full"
>                  ETHA_BIT_VALUE
>              }
>              ETHA_BITS_BIT = {
>                  ETHA_BIT_INDEX = 5 (ETHTOOL_LINK_MODE_1000baseT_Full_BIT)
>                  ETHA_BIT_NAME = "1000baseT/Full"
>                  ETHA_BIT_VALUE

I don't like this. This should not be bitfield/set. This should be
simply nested array of enum values:

enum ethtool_link_mode {
	ETHTOOL_LINK_MODE_10baseT_Half,
	ETHTOOL_LINK_MODE_10baseT_Full,
	ETHTOOL_LINK_MODE_100baseT_Half,
	ETHTOOL_LINK_MODE_100baseT_Full,
	ETHTOOL_LINK_MODE_1000baseT_Full,
};

and then there should be 2 attrs:
ETHTOOL_A_LINK_MODE_LIST_OUR	/* nest */
ETHTOOL_A_LINK_MODE_LIST_PEER	/* nest */
ETHTOOL_A_LINK_MODE		/* u32 */

and then the message should look like:

   ETHTOOL_A_LINK_MODE_LIST_OUR start nest
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_10baseT_Half
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_10baseT_Full
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_100baseT_Half
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_100baseT_Full
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_1000baseT_Full
   ETHTOOL_A_LINK_MODE_LIST_OUR end nest
   ETHTOOL_A_LINK_MODE_LIST_PEER start nest
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_10baseT_Half
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_10baseT_Full
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_100baseT_Half
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_100baseT_Full
     ETHTOOL_A_LINK_MODE = ETHTOOL_LINK_MODE_1000baseT_Full
   ETHTOOL_A_LINK_MODE_LIST_PEER end nest

Nice and simple. No bits, no strings.



>              }
>          }
>      }
>      ETHA_LINKMODES_PEER = {
>          ...
>      }
>      ETHA_LINKMODES_SPEED = 1000 (SPEED_1000)
>      ETHA_LINKMODES_DUPLEX = 1 (DUPLEX_FULL)
>  }
>  ...
>
>2. Long time running applications, e.g. "ethtool --monitor", wicked,
>systemd-networkd, ... For these, it would make sense to cache the
>strings and either retrieve them in advance (on start and when new
>device appears) or when they are needed for the first time. The request
>would then include the ETHA_SETTINGS_COMPACT flag and reply would be
>
>  ...
>  ETHA_LINKMODES_OURS = {
>      ETHA_BITSET_SIZE = 67
>      ETHA_BITSET_VALUE = 0x0000002c 0x00000000 0x00000000
>      ETHA_BITSET_MASK = 0x0000002f 0x00000000 0x00000000
>  }
>
>For "set" type requests, it's up to the application if it uses verbose
>or compact form. The verbose form is most useful when we want e.g. to
>set the values of one or two bits which may be identified by their names
>(on command line or in config file).
>
>Michal

  reply	other threads:[~2019-03-28 13:43 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25 17:07 [PATCH net-next v5 00/22] ethtool netlink interface, part 1 Michal Kubecek
2019-03-25 17:07 ` [PATCH net-next v5 01/22] rtnetlink: provide permanent hardware address in RTM_NEWLINK Michal Kubecek
2019-03-26 10:08   ` Jiri Pirko
2019-03-26 10:31     ` Michal Kubecek
2019-03-26 11:38       ` Jiri Pirko
2019-03-26 19:46   ` David Miller
2019-03-25 17:08 ` [PATCH net-next v5 02/22] netlink: introduce nla_put_bitfield32() Michal Kubecek
2019-03-26 10:09   ` Jiri Pirko
2019-03-28  1:56   ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 03/22] netlink: add strict version of nla_parse_nested() Michal Kubecek
2019-03-26 10:11   ` Jiri Pirko
2019-03-28  1:57   ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 04/22] ethtool: move to its own directory Michal Kubecek
2019-03-26 10:14   ` Jiri Pirko
2019-03-28  1:57   ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 05/22] ethtool: introduce ethtool netlink interface Michal Kubecek
2019-03-26 12:09   ` Jiri Pirko
2019-03-26 13:24     ` Michal Kubecek
2019-03-26 13:42       ` Jiri Pirko
2019-03-27  9:26         ` Michal Kubecek
2019-03-27  9:50           ` Jiri Pirko
2019-03-28  2:05             ` Florian Fainelli
2019-03-28  8:10               ` Jiri Pirko
2019-03-28  9:37                 ` Michal Kubecek
2019-03-28 13:23                   ` Jiri Pirko
2019-03-28 17:00                     ` Florian Fainelli
2019-03-28 17:28                       ` Jiri Pirko
2019-03-26 16:36   ` Jiri Pirko
2019-03-26 17:32     ` Michal Kubecek
2019-03-27  9:26       ` Jiri Pirko
2019-03-25 17:08 ` [PATCH net-next v5 06/22] ethtool: helper functions for " Michal Kubecek
2019-03-26 12:38   ` Jiri Pirko
2019-03-26 14:19     ` Michal Kubecek
2019-03-26 16:22       ` Jiri Pirko
2019-03-25 17:08 ` [PATCH net-next v5 07/22] ethtool: netlink bitset handling Michal Kubecek
2019-03-26 15:59   ` Jiri Pirko
2019-03-26 17:59     ` Michal Kubecek
2019-03-27  9:57       ` Jiri Pirko
2019-03-27 10:19         ` Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 08/22] ethtool: support for netlink notifications Michal Kubecek
2019-03-26 16:34   ` Jiri Pirko
2019-03-26 18:17     ` Michal Kubecek
2019-03-27  9:38       ` Jiri Pirko
2019-03-27  9:51         ` Andrew Lunn
2019-03-27 10:04           ` Jiri Pirko
2019-03-27 10:16             ` Andrew Lunn
2019-03-27 10:41               ` Jiri Pirko
2019-03-27  9:59         ` Michal Kubecek
2019-03-27 10:43           ` Jiri Pirko
2019-03-25 17:08 ` [PATCH net-next v5 09/22] ethtool: implement EVENT notifications Michal Kubecek
2019-03-27 13:04   ` Jiri Pirko
2019-03-27 14:14     ` Michal Kubecek
2019-03-28  2:14       ` Florian Fainelli
2019-03-28  6:41         ` Michal Kubecek
2019-03-28  9:16           ` Jiri Pirko
2019-03-25 17:08 ` [PATCH net-next v5 10/22] ethtool: generic handlers for GET requests Michal Kubecek
2019-03-27 16:35   ` Jiri Pirko
2019-03-27 21:53     ` Michal Kubecek
2019-03-28 13:32       ` Jiri Pirko
2019-03-25 17:08 ` [PATCH net-next v5 11/22] ethtool: move string arrays into common file Michal Kubecek
2019-03-28  2:17   ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 12/22] ethtool: provide string sets with GET_STRSET request Michal Kubecek
2019-03-27 20:12   ` Jiri Pirko
2019-03-27 22:56     ` Michal Kubecek
2019-03-29  8:43       ` Jiri Pirko
2019-03-28  2:25   ` Florian Fainelli
2019-03-28  7:18     ` Michal Kubecek
2019-03-28 13:43       ` Jiri Pirko [this message]
2019-03-28 14:04         ` Michal Kubecek
2019-03-28 17:35           ` Jiri Pirko
2019-03-28 18:52             ` Jakub Kicinski
2019-03-28 20:43               ` Michal Kubecek
2019-03-28 21:06                 ` Jakub Kicinski
2019-03-29  6:52                   ` Jiri Pirko
2019-03-28 22:28             ` Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 13/22] ethtool: provide driver/device information in GET_INFO request Michal Kubecek
2019-03-27 20:14   ` Jiri Pirko
2019-03-27 22:25     ` Michal Kubecek
2019-03-28  2:30       ` Florian Fainelli
2019-03-28  9:21       ` Jiri Pirko
2019-03-28  9:53         ` Michal Kubecek
2019-03-28 16:34           ` Jiri Pirko
2019-03-28 20:09             ` Jakub Kicinski
2019-03-28 22:46               ` Michal Kubecek
2019-03-29 18:48                 ` Jakub Kicinski
2019-03-29 18:53               ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 14/22] ethtool: provide timestamping " Michal Kubecek
2019-03-28  3:36   ` Florian Fainelli
2019-03-28 10:03     ` Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 15/22] ethtool: provide link mode names as a string set Michal Kubecek
2019-03-28  3:52   ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 16/22] ethtool: provide link settings and link modes in GET_SETTINGS request Michal Kubecek
2019-03-28  3:44   ` Florian Fainelli
2019-03-28 10:04     ` Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 17/22] ethtool: set link settings and link modes with SET_SETTINGS request Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 18/22] ethtool: provide link state in GET_SETTINGS request Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 19/22] ethtool: provide WoL information " Michal Kubecek
2019-03-28  3:42   ` Florian Fainelli
2019-03-28 10:10     ` Michal Kubecek
2019-03-25 17:08 ` [PATCH net-next v5 20/22] ethtool: set WoL settings with SET_SETTINGS request Michal Kubecek
2019-03-28  3:49   ` Florian Fainelli
2019-03-25 17:08 ` [PATCH net-next v5 21/22] ethtool: provide message level in GET_SETTINGS request Michal Kubecek
2019-03-28  3:46   ` Florian Fainelli
2019-03-25 17:09 ` [PATCH net-next v5 22/22] ethtool: set message level with SET_SETTINGS request Michal Kubecek
2019-03-28  3:48   ` Florian Fainelli
2019-03-27 13:09 ` [PATCH net-next v5 00/22] ethtool netlink interface, part 1 Jiri Pirko
2019-03-27 14:28   ` Michal Kubecek
2019-03-27 15:19     ` Jiri Pirko
2019-03-27 19:12     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190328134313.GO14297@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).