All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Danielle Ratson <danieller@nvidia.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	eric.dumazet@gmail.com, mkubecek@suse.cz, f.fainelli@gmail.com,
	acardace@redhat.com, irusskikh@marvell.com,
	gustavo@embeddedor.com, magnus.karlsson@intel.com,
	ecree@solarflare.com, idosch@nvidia.com, jiri@nvidia.com,
	mlxsw@nvidia.com
Subject: Re: [PATCH net v2 1/2] ethtool: Add link_mode parameter capability bit to ethtool_ops
Date: Sun, 4 Apr 2021 18:32:40 +0200	[thread overview]
Message-ID: <YGnqKFddCJGikOo8@lunn.ch> (raw)
In-Reply-To: <20210404081433.1260889-2-danieller@nvidia.com>

> @@ -436,12 +436,16 @@ int __ethtool_get_link_ksettings(struct net_device *dev,
>  
>  	memset(link_ksettings, 0, sizeof(*link_ksettings));
>  
> -	link_ksettings->link_mode = -1;
>  	err = dev->ethtool_ops->get_link_ksettings(dev, link_ksettings);
>  	if (err)
>  		return err;
>  
> -	if (link_ksettings->link_mode != -1) {
> +	if (dev->ethtool_ops->cap_link_mode_supported &&
> +	    link_ksettings->link_mode != -1) {

Is this -1 behaviour documented anywhere? It seems like you just
changed its meaning. It used to mean, this field has not been set,
ignore it. Adding the cap_link_mode_supported it now means, we have
field has been set, but we have no idea what link mode is being used.
So you should probably add something to the documentation of struct
ethtool_link_ksettings.

I wonder if we should actually add ETHTOOL_LINK_MODE_UNKNOWN to enum
ethtool_link_mode_bit_indices?

> +		if (WARN_ON_ONCE(link_ksettings->link_mode >=
> +				 __ETHTOOL_LINK_MODE_MASK_NBITS))
> +			return -EINVAL;
> +
>  		link_info = &link_mode_params[link_ksettings->link_mode];
>  		link_ksettings->base.speed = link_info->speed;
>  		link_ksettings->lanes = link_info->lanes;

If dev->ethtool_ops->cap_link_mode_supported &&
link_ksettings->link_mode == -1 should you be setting speed to
SPEED_UNKNOWN, and lanes to LANE_UNKNOWN? Or is that already the
default?

But over all, this API between the core and the driver seems
messy. Why not just add a helper in common.c which translates link
mode to speed/duplex/lanes and call it in the driver. Then you don't
need this capability flags, which i doubt any other driver will ever
use. And you don't need to worry about drivers returning random
values. As far as i can see, the link_mode returned by the driver is
not used for anything other than for this translation. So i don't see
a need for it outside of the driver. Or maybe i'm missing something?

	Andrew

  parent reply	other threads:[~2021-04-04 16:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-04  8:14 [PATCH net v2 0/2] Fix link_mode derived params functionality Danielle Ratson
2021-04-04  8:14 ` [PATCH net v2 1/2] ethtool: Add link_mode parameter capability bit to ethtool_ops Danielle Ratson
2021-04-04 14:18   ` Andrew Lunn
2021-04-04 15:04     ` Danielle Ratson
2021-04-04 16:07       ` Andrew Lunn
2021-04-04 16:32   ` Andrew Lunn [this message]
2021-04-05 17:01     ` Danielle Ratson
2021-04-04  8:14 ` [PATCH net v2 2/2] ethtool: Derive parameters from link_mode in ioctl path Danielle Ratson

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=YGnqKFddCJGikOo8@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=acardace@redhat.com \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=ecree@solarflare.com \
    --cc=eric.dumazet@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=gustavo@embeddedor.com \
    --cc=idosch@nvidia.com \
    --cc=irusskikh@marvell.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=magnus.karlsson@intel.com \
    --cc=mkubecek@suse.cz \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.