netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Frank <Frank.Sae@motor-comm.com>
Cc: 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>,
	Jakub Kicinski <kuba@kernel.org>, 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: Re: [PATCH v2] net: phy: Add driver for Motorcomm yt8521 gigabit
Date: Wed, 29 Jun 2022 14:56:22 +0200	[thread overview]
Message-ID: <YrxL9g1WQLn4TIMW@lunn.ch> (raw)
In-Reply-To: <20220629124848.142-1-Frank.Sae@motor-comm.com>

> > > +int yt8521_config_aneg(struct phy_device *phydev)
> > > +{
> > > + struct yt8521_priv *priv = phydev->priv;
> > > + u8 polling_mode = priv->polling_mode;
> > > + int old_page;
> > > + int ret;
> > > +
> > > + old_page = yt8521_read_page_with_lock(phydev);
> > > + if (old_page)
> > > +  return old_page;
> > > +
> > > + if (polling_mode == YT8521_MODE_FIBER ||
> > > +     polling_mode == YT8521_MODE_POLL) {
> > > +  ret = yt8521_write_page_with_lock(phydev,
> > > +        YT8521_RSSR_FIBER_SPACE);
> > > +  if (ret < 0)
> > > +   goto err_restore_page;
> > > +
> > > +  ret = genphy_config_aneg(phydev);
> > > +  if (ret < 0)
> > > +   goto err_restore_page;
> > > + }
> > > +
> > > + if (polling_mode == YT8521_MODE_UTP ||
> > > +     polling_mode == YT8521_MODE_POLL) {
> > > +  ret = yt8521_write_page_with_lock(phydev,
> > > +        YT8521_RSSR_UTP_SPACE);
> > > +  if (ret < 0)
> > > +   goto err_restore_page;
> > > +
> > > +  ret = genphy_config_aneg(phydev);
> > > +  if (ret < 0)
> > > +   goto err_restore_page;
> > > + }
> > 
> > Looks like this could be refactored to reduce duplication.
> > 
> 
> sure, as the reason said above, the same operation is required in both utp and
> fiber spaces.

So you can probably pull the 'core' of this function out into a
helper, and then call it either with YT8521_RSSR_UTP_SPACE or
YT8521_RSSR_FIBER_SPACE.

> > > + ret = !!(link_fiber | link_utp);
> > 
> > Does this mean it can do both copper and fibre at the same time. And
> > whichever gives up first wins?
> 
> Sure, the phy supports utp, fiber, and both. In the case of both, this driver
> supposes that fiber is of priority.

It is generally not that simple. Fibre, you probably want 1000BaseX,
unless the fibre module is actually copper, and then you want
SGMII. So you need something to talk to the fibre module and ask it
what it is. That something is phylink. Phylink does not support both
copper and fibre at the same time for one MAC.

       Andrew

  reply	other threads:[~2022-06-29 12:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29 12:48 Re: [PATCH v2] net: phy: Add driver for Motorcomm yt8521 gigabit Frank
2022-06-29 12:56 ` Andrew Lunn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-29 13:30 Frank

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=YrxL9g1WQLn4TIMW@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).