Subject: Re: [PATCH net-next v2 1/1] net: phy: dp83867: retrigger SGMII AN when link change

From: Andrew Lunn <[email-masked]>
Date: Fri, 27 May 2022 14:43:04 +0200

On Fri, May 27, 2022 at 09:47:09AM +0800, Tan Tee Min wrote:
> On Thu, May 26, 2022 at 02:32:14PM +0200, Andrew Lunn wrote:
> > On Thu, May 26, 2022 at 05:03:47PM +0800, Tan Tee Min wrote:
> > > This could cause an issue during power up, when PHY is up prior to MAC.
> > > At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t
> > > receive new in-band message from TI PHY with correct link status, speed
> > > and duplex info.
> > > 
> > > As suggested by TI, implemented a SW solution here to retrigger SGMII
> > > Auto-Neg whenever there is a link change.
> > 
> > Is there a bit in the PHY which reports host side link? There is no
> > point triggering an AN if there is already link.
> > 
> >       Andrew
> 
> Thanks for your comment.
> 
> There is no register bit in TI PHY which reports the SGMII AN link status.
> But, there is a bit that only reports the SGMII AN completion status.
> 
> In this case, the PHY side SGMII AN has been already completed prior to MAC is up.
> So, once MAC side SGMII is up, MAC side SGMII wouldn`t receive any new
> in-band message from TI PHY.

That does not make any sense for how i understand how this should
work.

Say the bootloader brings the MAC up, the SERDES gets sync and AN is
performed between the MAC and the PHY.

Linux takes over, downs the MAC and so the SERDES link is lost. The
PHY should notice this. Later Linux configures the MAC up, the SERDES
link should establish and AN should be performed.

Are you saying that the SERDES link is established, and stays
established, even when the MAC is down?

What is the structure of the host? Does it have a MAC block and a
SERDES block? It could be, the SERDES block is running independent of
the MAC block, and the link is established all the time, even when the
MAC is down. What you are missing is the MAC asking the SERDES block
for the results of the AN when the MAC comes up. So this is actually
an Ethernet driver bug, and you are working around it in the PHY
driver.

Are there registers in the MAC for the SERDES? Can you read the SERDES
link and AN state?

I have seen some MAC/SERDES combinations where you have to manually
move the AN results from the SERDES into the MAC. So could be, your
host will do it automatically is the MAC is up, but it won't do it if
the MAC is down when SERDES AN completes.

I just want to fully understand the issue, because if this is just a
workaround in the PHY, and you change the PHY, you are going to need
the same workaround in the next PHY driver.

    Andrew