netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Frank <Frank.Sae@motor-comm.com>,
	Peter Geis <pgwipeout@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	yinghong.zhang@motor-comm.com, fei.zhang@motor-comm.com,
	hua.sun@motor-comm.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4.4] net: phy: Add driver for Motorcomm yt8521 gigabit ethernet phy
Date: Tue, 23 Aug 2022 16:14:16 +0200	[thread overview]
Message-ID: <YwTguA0azox3j5vi@lunn.ch> (raw)
In-Reply-To: <20220822202147.4be904de@kernel.org>

On Mon, Aug 22, 2022 at 08:21:47PM -0700, Jakub Kicinski wrote:
> On Wed, 17 Aug 2022 19:25:54 +0800 Frank wrote:
> > +static int yt8521_fiber_config_aneg(struct phy_device *phydev)
> > +{
> > +	int err, changed;
> > +	u16 adv;
> > +
> > +	if (phydev->autoneg != AUTONEG_ENABLE)
> > +		return yt8521_fiber_setup_forced(phydev);
> > +
> > +	err =  ytphy_modify_ext_with_lock(phydev, YTPHY_MISC_CONFIG_REG,
> > +					  YTPHY_MCR_FIBER_SPEED_MASK,
> > +					  YTPHY_MCR_FIBER_1000BX);
> > +	if (err < 0)
> > +		return err;
> > +
> > +	/* enable Fiber auto sensing */
> > +	err =  ytphy_modify_ext_with_lock(phydev, YT8521_LINK_TIMER_CFG2_REG,
> > +					  0, YT8521_LTCR_EN_AUTOSEN);
> > +	if (err < 0)
> > +		return err;
> > +
> > +	/* Setup fiber advertisement */
> > +	adv = ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
> > +	      ADVERTISE_1000XPSE_ASYM;
> 
> Is it okay to ignore phydev->advertising and always set the same mask?

The user could of changed the pause settings, which are going to be
ignored here. Also, you should not assume the MAC can actually do
asymmetric pause, not all can. phydev->advertising will be set to only
include what the MAC can actually do.

The whole concept of having two line sides connected to one MAC and
seeing which gets link first is unsupported in Linux. In theory, you
want to be able to configure each line side differently. Maybe you
want autoneg on copper, but fixed on fibre, asymmetric pause with
fibre, but symmetric pause on copper, etc. Since there is only one
instance of phydev here, you don't have anywhere to store two sets of
configuration, nor any sort of kAPI to deal with two phydev structures
etc. So the user experience is not so great.

With the Marvell Switches which also have this capability, i actually
ignore it, use the phy-mode it decide which should be used, either
copper or fibre, and leave the other powered off so it can never get
link. There is at least one Marvell PHY which does however support
first up wins, so this behaviour is not new. I just don't recommend
it.

And it gets even more interesting when the SFP is actually copper. But
since the integration with phylink is missing in this driver, that is
not supported here.

	Andrew


  reply	other threads:[~2022-08-23 16:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 11:25 [PATCH v4.4] net: phy: Add driver for Motorcomm yt8521 gigabit ethernet phy Frank
2022-08-23  3:21 ` Jakub Kicinski
2022-08-23 14:14   ` Andrew Lunn [this message]
2022-08-23 18:37     ` Jakub Kicinski
2022-08-23 18:53       ` Andrew Lunn
2022-08-23 20:19         ` Russell King (Oracle)

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=YwTguA0azox3j5vi@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Frank.Sae@motor-comm.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fei.zhang@motor-comm.com \
    --cc=hkallweit1@gmail.com \
    --cc=hua.sun@motor-comm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pgwipeout@gmail.com \
    --cc=yinghong.zhang@motor-comm.com \
    /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).