Re: [PATCH net-next v5 12/22] ethtool: provide string sets with GET_STRSET request

Jiri Pirko
2019-03-28T17:35:28Z

Thu, Mar 28, 2019 at 03:04:28PM CET, mkubecek@suse.cz wrote:
>On Thu, Mar 28, 2019 at 02:43:13PM +0100, Jiri Pirko wrote:
>>
>> 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,
>> };
>
>We already have such enum. The problem with your "no string" approach is
>that it requires all userspace applications to (1) keep this enum in

That is how it is usually done. UAPI defines ATTRS and values, userspace
assigns appropriate strings.

>sync with kernel and (2) maintain their our tables of names. Experience
>shows we are not very good and satisfying these conditions even for the
>one which should be best at keeping up.

Moreover, I think that speed, duplex and type should be sent
separatelly:

ETHTOOL_A_LINK_MODE_LIST_OUR start nest
ETHTOOL_A_LINK_MODE start nest
ETHTOOL_A_LINK_MODE_SPEED = 100 /* this should be u64 */
ETHTOOL_A_LINK_MODE_DUPLEX = ETHTOOL_LINK_MODE_DUPLEX_FULL
ETHTOOL_A_LINK_MODE_TYPE = ETHTOOL_LINK_MODE_TYPE_BASET
ETHTOOL_A_LINK_MODE start end
ETHTOOL_A_LINK_MODE start nest
ETHTOOL_A_LINK_MODE_SPEED = 10
ETHTOOL_A_LINK_MODE_DUPLEX = ETHTOOL_LINK_MODE_DUPLEX_HALF
ETHTOOL_A_LINK_MODE_TYPE = ETHTOOL_LINK_MODE_TYPE_BASET
ETHTOOL_A_LINK_MODE start end
ETHTOOL_A_LINK_MODE_LIST_PEER end nest

Does not really make sense to combine those 3 attributes together.

>
>> 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.
>
>A bit too simple, actually. You would need third nest to distinguish

It is just an example.

>supported and advertised modes. And for setting, you would also need two
>arrays if you want to set only some of the modes (unless you introduce
>something that would be similar to mine except for omitting the names).
>
>More important: you still didn't explain how is your "no strings"
>approach supposed to work for bit sets where userspace cannot possibly
>know the set of available flags (e.g. the private flags).

I know, that is a different part of this thread.

>
>Michal