netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Serge Semin <fancer.lancer@gmail.com>
Cc: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	linux-kernel@vger.kernel.org, andrew@lunn.ch,
	Jose.Abreu@synopsys.com, UNGLinuxDriver@microchip.com
Subject: Re: [PATCH net-next V3] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers
Date: Fri, 27 Oct 2023 13:40:34 +0100	[thread overview]
Message-ID: <ZTuvwnGZKEueGDwa@shell.armlinux.org.uk> (raw)
In-Reply-To: <6j7szthl34z5q2ea4qnno7e2fnde3djxifx7chhhaihqty23q6@7j42bte7b3dv>

On Fri, Oct 27, 2023 at 03:06:19PM +0300, Serge Semin wrote:
> Hi Russell
> 
> On Fri, Oct 27, 2023 at 12:54:36PM +0100, Russell King (Oracle) wrote:
> > On Fri, Oct 27, 2023 at 02:04:15PM +0300, Serge Semin wrote:
> > > Cc += Russell
> > > 
> > > * It's a good practice to add all the reviewers to Cc in the new patch
> > > * revisions.
> > > 
> > > On Fri, Oct 27, 2023 at 10:13:06AM +0530, Raju Lakkaraju wrote:
> > > > Add DW_2500BASEX case in xpcs_get_state( ) to update speed, duplex and pause
> > > > 
> > > > Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
> > > 
> > > With a nitpick below clarified, feel free to add:
> > > Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> > > 
> > > > ---
> > > >  drivers/net/pcs/pcs-xpcs.c | 29 +++++++++++++++++++++++++++++
> > > >  drivers/net/pcs/pcs-xpcs.h |  2 ++
> > > >  2 files changed, 31 insertions(+)
> > > > 
> > > > diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
> > > > index 4dbc21f604f2..31f0beba638a 100644
> > > > --- a/drivers/net/pcs/pcs-xpcs.c
> > > > +++ b/drivers/net/pcs/pcs-xpcs.c
> > > > @@ -1090,6 +1090,28 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
> > > >  	return 0;
> > > >  }
> > > >  
> > > > +static int xpcs_get_state_2500basex(struct dw_xpcs *xpcs,
> > > > +				    struct phylink_link_state *state)
> > > > +{
> > > > +	int ret;
> > > > +
> > > > +	ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_STS);
> > > > +	if (ret < 0) {
> > > > +		state->link = 0;
> > > > +		return ret;
> > > > +	}
> > > > +
> > > > +	state->link = !!(ret & DW_VR_MII_MMD_STS_LINK_STS);
> > > > +	if (!state->link)
> > > > +		return 0;
> > > > +
> > > > +	state->speed = SPEED_2500;
> > > 
> > > > +	state->pause |= MLO_PAUSE_TX | MLO_PAUSE_RX;
> > > 
> > > Why is it '|=' instead of just '='? Is it possible to have the 'pause'
> > > field having some additional flags set which would be required to
> > > preserve?
> > 
> > The code is correct. There are other flags on state->pause other than
> > these, and phylink initialises state->pause prior to calling the
> > function. The only flags that should be modified here are these two
> > bits that the code is setting.
> > 
> > Phylink will initialise it to MLO_PAUSE_NONE if expecting autoneg, or
> > the configured values if autoneg on the link is disabled.
> 
> Thanks for clarification. Then no more comments from my side in this
> patch regard.
> 
> Regarding the XPCS driver in general. Based on what you said the rest
> of the XPCS state getters are wrong in fully re-writing the 'pause'
> field. Right?

Yes.

xpcs_resolve_pma:
        state->pause = MLO_PAUSE_TX | MLO_PAUSE_RX;

xpcs_get_state_c37_sgmii:
        state->pause = 0;

are both incorrect. The former should be |=, the latter is totally
unnecessary.

Documentation:
 * pcs_get_state() - Read the current inband link state from the hardware
 * @pcs: a pointer to a &struct phylink_pcs.
 * @state: a pointer to a &struct phylink_link_state.
 *
 * Read the current inband link state from the MAC PCS, reporting the
 * current speed in @state->speed, duplex mode in @state->duplex, pause
                                                                  ^^^^^
 * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I guess I need to make that more explicit that pcs_get_state() methods
are only expected to _set_ these two bits as appropriate, leaving all
other bits as-is.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-10-27 12:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27  4:43 [PATCH net-next V3] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers Raju Lakkaraju
2023-10-27 11:04 ` Serge Semin
2023-10-27 11:54   ` Russell King (Oracle)
2023-10-27 12:06     ` Serge Semin
2023-10-27 12:40       ` Russell King (Oracle) [this message]
2023-10-31  0:56         ` Serge Semin
2023-10-27 23:10 ` patchwork-bot+netdevbpf

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=ZTuvwnGZKEueGDwa@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Jose.Abreu@synopsys.com \
    --cc=Raju.Lakkaraju@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=fancer.lancer@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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).