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] [day] [month] [year] [list]
Message-ID: <3fbddaec-3bcb-4a57-99bd-c9c8895a6919@lunn.ch>
Date: Sat, 11 May 2024 18:33:26 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Hans Ulli Kroll <ulli.kroll@...glemail.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 4/5] net: ethernet: cortina: Use negotiated
 TX/RX pause

On Sat, May 11, 2024 at 12:08:42AM +0200, Linus Walleij wrote:
> Instead of directly poking into registers of the PHY, use
> the existing function to query phylib about this directly.
> 
> Suggested-by: Andrew Lunn <andrew@...n.ch>
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
> ---
>  drivers/net/ethernet/cortina/gemini.c | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index e9b4946ec45f..d3134db032a2 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -293,8 +293,8 @@ static void gmac_adjust_link(struct net_device *netdev)
>  	struct gemini_ethernet_port *port = netdev_priv(netdev);
>  	struct phy_device *phydev = netdev->phydev;
>  	union gmac_status status, old_status;
> -	int pause_tx = 0;
> -	int pause_rx = 0;
> +	bool pause_tx = false;
> +	bool pause_rx = false;
>  
>  	status.bits32 = readl(port->gmac_base + GMAC_STATUS);
>  	old_status.bits32 = status.bits32;
> @@ -328,19 +328,13 @@ static void gmac_adjust_link(struct net_device *netdev)
>  			    phydev->speed, phydev_name(phydev));
>  	}
>  
> -	if (phydev->duplex == DUPLEX_FULL) {
> -		u16 lcladv = phy_read(phydev, MII_ADVERTISE);
> -		u16 rmtadv = phy_read(phydev, MII_LPA);
> -		u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
> -
> -		if (cap & FLOW_CTRL_RX)
> -			pause_rx = 1;
> -		if (cap & FLOW_CTRL_TX)
> -			pause_tx = 1;
> +	if (phydev->autoneg) {
> +		phy_get_pause(phydev, &pause_tx, &pause_rx);
> +		netdev_dbg(netdev, "set negotiated pause params pause TX = %s, pause RX = %s\n",
> +			   pause_tx ? "ON" : "OFF", pause_rx ? "ON" : "OFF");
> +		gmac_set_flow_control(netdev, pause_tx, pause_rx);
>  	}

This is a lot better, but not quite correct. The pause kAPi is more
complex than it probably needs to be...

phydev->autoneg is about overall autoneg, basically speed and duplex
negotiation. However:

 * If @autoneg is non-zero, the MAC is configured to send and/or
 * receive pause frames according to the result of autonegotiation.
 * Otherwise, it is configured directly based on the @rx_pause and
 * @tx_pause flags.
 */
struct ethtool_pauseparam {
	__u32	cmd;
	__u32	autoneg;
	__u32	rx_pause;
	__u32	tx_pause;
};

So if pauseparam.autoneg is false, it does not matter if
phydev->autoneg is true, you should not be touching the hardware
here. The hardware should of been set as part of ethtool_set_pause().

Or you can simplify this and return -EOPNOTSUPP in ethtool_set_pause()
is pauseparam.autoneg is false.

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ