netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] net: dsa: qca8k: enable port flow control
@ 2019-07-28  0:57 xiaofeis
  2019-07-28 22:31 ` Andrew Lunn
  2019-07-30 22:08 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: xiaofeis @ 2019-07-28  0:57 UTC (permalink / raw)
  To: davem
  Cc: vkoul, netdev, andrew, linux-arm-msm, bjorn.andersson,
	vivien.didelot, f.fainelli, niklas.cassel, xiazha, xiaofeis

Set phy device advertising to enable MAC flow control.

Signed-off-by: Xiaofei Shen <xiaofeis@codeaurora.org>
---
Changes since V2:
 drivers/net/dsa/qca8k.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index 232e8cc..e429e92 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name>
  * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
- * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved.
  * Copyright (c) 2016 John Crispin <john@phrozen.org>
  */
 
@@ -935,6 +935,8 @@
 	qca8k_port_set_status(priv, port, 1);
 	priv->port_sts[port].enabled = 1;
 
+	phy_support_asym_pause(phy);
+
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] net: dsa: qca8k: enable port flow control
  2019-07-28  0:57 [PATCH v3] net: dsa: qca8k: enable port flow control xiaofeis
@ 2019-07-28 22:31 ` Andrew Lunn
  2019-07-29  5:01   ` xiaofeis
  2019-07-30 22:08 ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2019-07-28 22:31 UTC (permalink / raw)
  To: xiaofeis
  Cc: davem, vkoul, netdev, linux-arm-msm, bjorn.andersson,
	vivien.didelot, f.fainelli, niklas.cassel, xiazha

On Sun, Jul 28, 2019 at 08:57:50AM +0800, xiaofeis wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] net: dsa: qca8k: enable port flow control
  2019-07-28 22:31 ` Andrew Lunn
@ 2019-07-29  5:01   ` xiaofeis
  2019-07-29 13:23     ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: xiaofeis @ 2019-07-29  5:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, vkoul, netdev, linux-arm-msm, bjorn.andersson,
	vivien.didelot, f.fainelli, niklas.cassel, xiazha

On 2019-07-29 06:31, Andrew Lunn wrote:
> On Sun, Jul 28, 2019 at 08:57:50AM +0800, xiaofeis wrote:
>> 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
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] net: dsa: qca8k: enable port flow control
  2019-07-29  5:01   ` xiaofeis
@ 2019-07-29 13:23     ` Andrew Lunn
  2019-07-30  3:01       ` xiaofeis
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2019-07-29 13:23 UTC (permalink / raw)
  To: xiaofeis
  Cc: davem, vkoul, netdev, linux-arm-msm, bjorn.andersson,
	vivien.didelot, f.fainelli, niklas.cassel, xiazha

> 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;

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] net: dsa: qca8k: enable port flow control
  2019-07-29 13:23     ` Andrew Lunn
@ 2019-07-30  3:01       ` xiaofeis
  0 siblings, 0 replies; 6+ messages in thread
From: xiaofeis @ 2019-07-30  3:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, vkoul, netdev, linux-arm-msm, bjorn.andersson,
	vivien.didelot, f.fainelli, niklas.cassel, xiazha

On 2019-07-29 21:23, Andrew Lunn wrote:
>> 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;
> 
> 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.
> 
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] net: dsa: qca8k: enable port flow control
  2019-07-28  0:57 [PATCH v3] net: dsa: qca8k: enable port flow control xiaofeis
  2019-07-28 22:31 ` Andrew Lunn
@ 2019-07-30 22:08 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2019-07-30 22:08 UTC (permalink / raw)
  To: xiaofeis
  Cc: vkoul, netdev, andrew, linux-arm-msm, bjorn.andersson,
	vivien.didelot, f.fainelli, niklas.cassel, xiazha

From: xiaofeis <xiaofeis@codeaurora.org>
Date: Sun, 28 Jul 2019 08:57:50 +0800

> Set phy device advertising to enable MAC flow control.
> 
> Signed-off-by: Xiaofei Shen <xiaofeis@codeaurora.org>

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-30 22:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-28  0:57 [PATCH v3] net: dsa: qca8k: enable port flow control xiaofeis
2019-07-28 22:31 ` Andrew Lunn
2019-07-29  5:01   ` xiaofeis
2019-07-29 13:23     ` Andrew Lunn
2019-07-30  3:01       ` xiaofeis
2019-07-30 22:08 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).