net: dsa: qca8k: enable port flow control
Subsystems (4)
PATCH v3 1/1 net: dsa: qca8k: enable port flow control
Set phy device advertising to enable MAC flow control.
---
Changes since V2:
drivers/net/dsa/qca8k.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/qca8k.c +3 -1
@@ -2,7 +2,7 @@/* * Copyright (C) 2009 Felix Fietkau <[email protected]> * Copyright (C) 2011-2012 Gabor Juhos <[email protected]> -* Copyright (c) 2015, The Linux Foundation. All rights reserved. +* Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved. * Copyright (c) 2016 John Crispin <[email protected]> */
@@ -935,6 +935,8 @@qca8k_port_set_status (priv, port,1 ); priv->port_sts[port].enabled =1 ; +phy_support_asym_pause (phy); +return 0 ; }
Signature · 1 line
1.9.1
Andrew Lunn
maintainerQuoted 1 line · xiaofeis
Set phy device advertising to enable MAC flow control.
Hi Xiaofei.
This is half of the needed change for MAC flow control.
phy_support_asym_pause(phy) is used by the MAC to tell the PHY layer that the MAC supports flow control. The PHY will then advertise this. When auto-negotiation is completed, the PHY layer will call qca8k_adjust_link() with the results. It could be that the peer does not support flow control, or only supports symmetric flow control. So in that function, you need to program the MAC with the results of the auto-neg. This is currently missing. You need to look at phydev->pause and phydev->asym_pause to decide how to configure the MAC.
Andrew
Quoted 16 lines · Andrew Lunn
Quoted 1 line · xiaofeis
Set phy device advertising to enable MAC flow control.
Hi Xiaofei.
This is half of the needed change for MAC flow control.
phy_support_asym_pause(phy)is used by the MAC to tell the PHY layer that the MAC supports flow control. The PHY will then advertise this. When auto-negotiation is completed, the PHY layer will callqca8k_adjust_link()with the results. It could be that the peer does not support flow control, or only supports symmetric flow control. So in that function, you need to program the MAC with the results of the auto-neg. This is currently missing. You need to look atphydev->pauseandphydev->asym_pauseto decide how to configure the MAC.
Quoted 1 line
Andrew
Hi Andrew
You are correct. With the change, the auto-negotiation result still depends on the peer.
But our qca8k HW can auto sync the pause status to MAC from phy with the auto-negotiated result.
So no need to set in qca8k_adjust_link, since there is one setting in qca8k_port_set_status: mask |= QCA8K_PORT_STATUS_LINK_AUTO;
This change's purpose is to keep enable advertise on our side.
Thanks
Xiaofeis
Andrew Lunn
maintainerQuoted 4 lines
But our qca8k HW can auto sync the pause status to MAC from phy with the auto-negotiated result.
So no need to set inqca8k_adjust_link, since there is one setting inqca8k_port_set_status: mask |=QCA8K_PORT_STATUS_LINK_AUTO;
How does the auto-sync actually work? Does the MAC make MDIO reads to the PHY? That is generally unsafe, since some PHYs support pages, and the PHY driver might be using a different page while the MAC tries to access the auto-neg results.
Do any of the ports support an external PHY? The auto-sync might not work in that condition as well. Different register layout, c45 not c22, etc.
The safest option is to explicitly set the MAC flow configuration based on the values in phydev.
Andrew
Quoted 10 lines · Andrew Lunn
Quoted 4 lines
But our qca8k HW can auto sync the pause status to MAC from phy with the auto-negotiated result.
So no need to set inqca8k_adjust_link, since there is one setting inqca8k_port_set_status: mask |=QCA8K_PORT_STATUS_LINK_AUTO;How does the auto-sync actually work? Does the MAC make MDIO reads to the PHY? That is generally unsafe, since some PHYs support pages, and the PHY driver might be using a different page while the MAC tries to access the auto-neg results.
Quoted 7 lines
Do any of the ports support an external PHY? The auto-sync might not work in that condition as well. Different register layout, c45 not c22, etc.
The safest option is to explicitly set the MAC flow configuration based on the values in phydev.
Hi Andrew
To explicitly set the configuration is one option, but then we need disable QCA8K_PORT_STATUS_LINK_AUTO, and not only flow control, speed/duplex all need to be set explicitly.
Here the qca8k driver is only support qca,qca8337/qca8334 switch family. The phy is internal phy. There is signals internaly to sync the status from phy to mac directly which is HW specific implementation, it doesn't support to connect external phy.
Thanks
Xiaofeis
David Miller
maintainerFrom: xiaofeis <[email protected]>
Date: Sun, 28 Jul 2019 08:57:50 +0800
Quoted 3 lines
Set phy device advertising to enable MAC flow control.
Signed-off-by Xiaofei Shen <[email protected]>
I've read the discussion over a few times and if internal PHY is the only thing supported, and the specific setup this driver supports uses internal signalling to sync the PHY and MAC settings I guess this is OK although suboptimal.
So applied, thanks.
Thanks.