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  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]
Date:   Thu, 16 Jul 2020 16:10:44 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Helmut Grohne <helmut.grohne@...enta.de>
Cc:     Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        Woojung Huh <woojung.huh@...rochip.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Tristram Ha <Tristram.Ha@...rochip.com>
Subject: Re: [PATCH v2] net: dsa: microchip: call phy_remove_link_mode during
 probe

On Thu, Jul 16, 2020 at 02:57:24PM +0200, Helmut Grohne wrote:
> When doing "ip link set dev ... up" for a ksz9477 backed link,
> ksz9477_phy_setup is called and it calls phy_remove_link_mode to remove
> 1000baseT HDX. During phy_remove_link_mode, phy_advertise_supported is
> called. Doing so reverts any previous change to advertised link modes
> e.g. using a udevd .link file.
> 
> phy_remove_link_mode is not meant to be used while opening a link and
> should be called during phy probe when the link is not yet available to
> userspace.
> 
> Therefore move the phy_remove_link_mode calls into ksz9477_setup. This
> is called during dsa_switch_register and thus comes after
> ksz9477_switch_detect, which initializes dev->features.
> 
> Remove phy_setup from ksz_dev_ops as no users remain.
> 
> Link: https://lore.kernel.org/netdev/20200715192722.GD1256692@lunn.ch/
> Fixes: 42fc6a4c613019 ("net: dsa: microchip: prepare PHY for proper advertisement")
> Signed-off-by: Helmut Grohne <helmut.grohne@...enta.de>
> ---
>  drivers/net/dsa/microchip/ksz9477.c    | 31 ++++++++++----------------
>  drivers/net/dsa/microchip/ksz_common.c |  2 --
>  drivers/net/dsa/microchip/ksz_common.h |  2 --
>  3 files changed, 12 insertions(+), 23 deletions(-)
> 
> changes since v1:
>  * Don't change phy_remove_link_mode. Instead, call it at the right
>    time. Thanks to Andrew Lunn for the detailed explanation.
> 
> Helmut

Hi Helmut

This change looks better.

However, i'm having trouble understanding how PHYs actually work in
this driver. 

We have:

struct ksz_port {
        u16 member;
        u16 vid_member;
        int stp_state;
        struct phy_device phydev;

with an instance of this structure per port of the switch.

And it is this phydev which you are manipulating.

> +	for (i = 0; i < dev->phy_port_cnt; ++i) {
> +		/* The MAC actually cannot run in 1000 half-duplex mode. */
> +		phy_remove_link_mode(&dev->ports[i].phydev,
> +				     ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
> +
> +		/* PHY does not support gigabit. */
> +		if (!(dev->features & GBIT_SUPPORT))
> +			phy_remove_link_mode(&dev->ports[i].phydev,
> +					     ETHTOOL_LINK_MODE_1000baseT_Full_BIT);
> +	}
> +
>  	return 0;

But how is this phydev associated with the netdev? I don't see how
phylink_connect_phy() is called using this phydev structure?

      Andrew

Powered by blists - more mailing lists