lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230530160743.2c93a388@wsk>
Date: Tue, 30 May 2023 16:07:43 +0200
From: Lukasz Majewski <lukma@...x.de>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>, Vivien Didelot <vivien.didelot@...il.com>,
 Florian Fainelli <f.fainelli@...il.com>, Vladimir Oltean
 <olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>, Jakub
 Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [RFC] net: dsa: slave: Advertise correct EEE capabilities at
 slave PHY setup

Hi Russell,

> On Tue, May 30, 2023 at 02:26:21PM +0200, Lukasz Majewski wrote:
> > One can disable in device tree advertising of EEE capabilities of
> > PHY when 'eee-broken-100tx' property is present in DTS.
> > 
> > With DSA switch it also may happen that one would need to disable
> > EEE due to some network issues.
> > 
> > Corresponding switch DTS description:
> > 
> >  switch@0 {
> > 	 ports {
> > 		port@0 {
> > 		reg = <0>;
> > 		label = "lan1";
> > 		phy-handle = <&switchphy0>;
> > 		};
> > 	}
> > 	mdio {
> > 		switchphy0: switchphy@0 {
> > 		reg = <0>;
> > 		eee-broken-100tx;
> > 	};
> > 	};
> > 
> > This patch adjusts the content of MDIO_AN_EEE_ADV in MDIO_MMD_AN
> > "device" so the phydev->eee_broken_modes are taken into account
> > from the start of the slave PHYs.  
> 
> This should be handled by phylib today in recent kernels without the
> need for any patch (as I describe below, because the config_aneg PHY
> method should be programming it.) Are you seeing a problem with it
> in 6.4-rc?

Unfortunately, for this project I use LTS 5.15.z kernel.

My impression is that the mv88e6xxx driver is not handling EEE setup
during initialization (even with v6.4-rc).

I've tried to replace genphy_config_eee_advert() with phy_init_eee, but
it lacks the part to program PCS advertise registers.

> 
> > As a result the 'ethtool --show-eee lan1' shows that EEE is not
> > supported from the outset.
> > 
> > Questions:
> > 
> > - Is the genphy_config_eee_advert() appropriate to be used here?
> >   As I found this issue on 5.15 kernel, it looks like mainline now
> > uses PHY features for handle EEE (but the aforementioned function
> > is still present in newest mainline - v6.4-rc1).
> > 
> > - I've also observed strange behaviour for EEE capability register:
> >   Why the value in MDIO_MMD_PCS device; reg MDIO_PCS_EEE_ABLE is
> > somewhat "volatile" - in a sense that when I use:
> >   ethtool --set-eee lan2 eee off
> > 
> >   It is cleared by PHY itself to 0x0 (from 0x2) and turning it on
> > again is not working.
> > 
> >   Is this expected? Or am I missing something?  
> 
> No - this register is supposed to report the capabilities of the PHY,
> and bits 1..15 should be read-only, and as they report the
> capabilities they should be fixed. Writing to bit 1 of this register
> will therefore be ignored. It sounds like your PHY has some odd
> behaviour - maybe someone misinterpreted 802.3 45.2.3.9?
> 

It is a good question. Or maybe after EEE disabling I read some wrong
data (however, up till this moment bit offsets and values seems
reasonable).

> > Signed-off-by: Lukasz Majewski <lukma@...x.de>
> > ---
> >  net/dsa/slave.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> > index 353d8fff3166..712923c7d4e2 100644
> > --- a/net/dsa/slave.c
> > +++ b/net/dsa/slave.c
> > @@ -2247,6 +2247,7 @@ static int dsa_slave_phy_setup(struct
> > net_device *slave_dev) phylink_destroy(dp->pl);
> >  	}
> >  
> > +	genphy_config_eee_advert(slave_dev->phydev);  
> 
> No network driver (which includes DSA) should be calling any function
> starting genphy_*. These functions are purely for phylib or phy
> drivers to use, and no one else.

As stated before, it looks like some PHY "update" in respect of EEE is
not done when DSA framework creates phydevs for slave ports.

> 
> genphy_config_eee_advert() is a deprecated function (see commit
> 5827b168125d ("net: phy: c45: migrate to genphy_c45_write_eee_adv()")
> and thus should not be used.

Ok.

> 
> genphy_c45_write_eee_adv() is called by
> genphy_c45_an_config_eee_aneg() which will in turn be called by
> genphy_config_aneg() for a clause 22 PHY, or by
> genphy_c45_an_config_aneg() for a clause 45 PHY. These will write the
> EEE advertisement mask to the PHY's AN MMD.
> 

Ok.

> So, EEE should be handled by phylib according to the firmware
> settings. 

I also would expect, that phy core code parses DTS properties and then
phydev->eee_broken_mode is used to mask EEE advertisement during PHY
initialization and startup.

> The only thing that network drivers that use phylib have to
> deal with is setting their hardware for the LPI timeout and
> enabling/disabling the timeout as necessary.
> 

Yes. I do agree.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@...x.de

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ