RE: [PATCH net 1/1] net: phy: marvell: add link status check before enabling phy loopback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Andrew Lunn <andrew@xxxxxxx>
> Sent: Tuesday, 30 August, 2022 8:17 PM
> To: Jamaluddin, Aminuddin <aminuddin.jamaluddin@xxxxxxxxx>
> Cc: Heiner Kallweit <hkallweit1@xxxxxxxxx>; Russell King
> <linux@xxxxxxxxxxxxxxx>; David S . Miller <davem@xxxxxxxxxxxxx>; Eric
> Dumazet <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>;
> Paolo Abeni <pabeni@xxxxxxxxxx>; Ismail, Mohammad Athari
> <mohammad.athari.ismail@xxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; stable@xxxxxxxxxxxxxxx; Tan, Tee Min
> <tee.min.tan@xxxxxxxxx>; Zulkifli, Muhammad Husaini
> <muhammad.husaini.zulkifli@xxxxxxxxx>
> Subject: Re: [PATCH net 1/1] net: phy: marvell: add link status check before
> enabling phy loopback
> 
> > > > @@ -2015,14 +2016,23 @@ static int m88e1510_loopback(struct
> > > phy_device *phydev, bool enable)
> > > >  		if (err < 0)
> > > >  			return err;
> > > >
> > > > -		/* FIXME: Based on trial and error test, it seem 1G need to
> > > have
> > > > -		 * delay between soft reset and loopback enablement.
> > > > -		 */
> > > > -		if (phydev->speed == SPEED_1000)
> > > > -			msleep(1000);
> > > > +		if (phydev->speed == SPEED_1000) {
> > > > +			err = phy_read_poll_timeout(phydev, MII_BMSR,
> > > val, val & BMSR_LSTATUS,
> > > > +						    PHY_LOOP_BACK_SLEEP,
> > > > +
> > > PHY_LOOP_BACK_TIMEOUT, true);
> > >
> > > Is this link with itself?
> >
> > Its required cabled plug in, back to back connection.
> 
> Loopback should not require that. The whole point of loopback in the PHY is
> you can do it without needing a cable.
> 
> > >
> > > Have you tested this with the cable unplugged?
> >
> > Yes we have and its expected to have the timeout. But the self-test
> > required the link to be up first before it can be run.
> 
> So you get an ETIMEDOUT, and then skip the code which actually sets the
> LOOPBACK bit?

If cable unplugged, test result will be displayed as 1. See comments below.

> 
> Please look at this again, and make it work without a cable.

Related to this the flow without cable, what we see in the codes during debugging.
After the phy loopback bit was set.
The test will be run through this __stmmac_test_loopback()
https://elixir.bootlin.com/linux/v5.19.8/source/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c#L320
Here, it will have another set of checking in dev_direct_xmit(), __dev_direct_xmit().
returning value 1(NET_XMIT_DROP)
https://elixir.bootlin.com/linux/v5.19.8/source/net/core/dev.c#L4288
Which means the interface is not available or the interface link status is not up.
For this case the interface link status is not up. 
Thus failing the phy loopback test.
https://elixir.bootlin.com/linux/v5.19.8/source/net/core/dev.c#L4296
Since we don't own this __stmmac_test_loopback(), we conclude the behaviour was as expected.

> 
> Maybe you are addressing the wrong issue? Is the PHY actually performing
> loopback, but reporting the link is down? Maybe you need to fake a link up?
> Maybe you need the self test to not care about the link state, all it really
> needs is that packets get looped?

When bit 14 was set, the link will be broken. 
But before the self-test was triggered it requires link to be up as stated above comments.

> 
Amin




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux