All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Michal Kubecek <mkubecek@suse.cz>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	f.fainelli@gmail.com, ayal@nvidia.com, danieller@nvidia.com,
	amcohen@nvidia.com, mlxsw@nvidia.com,
	Ido Schimmel <idosch@nvidia.com>
Subject: Re: [RFC PATCH net] ethtool: Fix incompatibility between netlink and ioctl interfaces
Date: Wed, 30 Sep 2020 17:35:27 +0300	[thread overview]
Message-ID: <20200930143527.GA1824481@shredder> (raw)
In-Reply-To: <20200930141909.GJ3996795@lunn.ch>

On Wed, Sep 30, 2020 at 04:19:09PM +0200, Andrew Lunn wrote:
> > > I don't think so. Doing:
> > > 
> > > # ethtool -s eth0 autoneg
> > > 
> > > Is a pretty established behavior to enable all the supported advertise
> > > bits.
> 
> I would disagree. phylib will return -EINVAL for this.

This has nothing to do with the kernel / phylib. With the ioctl
interface when you do:

# ethtool -s eth0 autoneg on

The ethtool user space utility will enable all the supported link modes:

https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/ethtool.c#n3170

For the netlink interface this is done by the kernel:

https://github.com/torvalds/linux/blob/master/net/ethtool/linkmodes.c#L2

But only if speed or duplex were specified:

https://github.com/torvalds/linux/blob/master/net/ethtool/linkmodes.c#L383

Which is a problem.

> 
> int phy_ethtool_ksettings_set(struct phy_device *phydev,
>                               const struct ethtool_link_ksettings *cmd)
> {
>         __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
>         u8 autoneg = cmd->base.autoneg;
>         u8 duplex = cmd->base.duplex;
>         u32 speed = cmd->base.speed;
> 
> ...
>         linkmode_copy(advertising, cmd->link_modes.advertising);
> 
> ...
> 
>         if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising))
>                 return -EINVAL;
> 
> You have to pass a list of modes you want it to advertise. If you are
> using phylink and not a copper PHY, and autoneg, that means you are
> using in-band signalling. The same is imposed:
> 
>         /* If autonegotiation is enabled, we must have an advertisement */
>         if (config.an_enabled && phylink_is_empty_linkmode(config.advertising))
>                 return -EINVAL;
> 
> We have consistent behaviour whenever Linux is controlling the PHY
> because the core is imposing that behaviour. It would be nice if
> drivers ignoring the PHY core where consistent with this.

You will get an error from mlxsw as well (see example in the change
log).

> 
> 	Andrew

  reply	other threads:[~2020-09-30 14:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 16:02 [RFC PATCH net] ethtool: Fix incompatibility between netlink and ioctl interfaces Ido Schimmel
2020-09-29 16:44 ` Michal Kubecek
2020-09-30  7:25   ` Ido Schimmel
2020-09-30  8:59     ` Michal Kubecek
2020-09-30 14:19       ` Andrew Lunn
2020-09-30 14:35         ` Ido Schimmel [this message]
2020-09-30 14:43           ` Ido Schimmel
2020-09-30 20:06       ` Ido Schimmel
2020-09-30 20:45         ` Michal Kubecek

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=20200930143527.GA1824481@shredder \
    --to=idosch@idosch.org \
    --cc=amcohen@nvidia.com \
    --cc=andrew@lunn.ch \
    --cc=ayal@nvidia.com \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --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.