linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] net: stmmac: Set MAC's flow control register to reflect current settings
@ 2022-11-23  9:15 Goh, Wei Sheng
  2022-11-23 18:09 ` Alexander Lobakin
  0 siblings, 1 reply; 2+ messages in thread
From: Goh, Wei Sheng @ 2022-11-23  9:15 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	Ong Boon Leong, Voon Wei Feng, Tan Tee Min,
	Ahmad Tarmizi Noor Azura, Looi Hong Aun, Goh Wei Sheng

Currently, pause frame register GMAC_RX_FLOW_CTRL_RFE is not updated
correctly when 'ethtool -A <IFACE> autoneg off rx off tx off' command
is issued. This fix ensures the flow control change is reflected directly
in the GMAC_RX_FLOW_CTRL_RFE register.

Fixes: 46f69ded988d ("net: stmmac: Use resolved link config in mac_link_up()")
Cc: <stable@vger.kernel.org> # 5.10.x
Signed-off-by: Goh, Wei Sheng <wei.sheng.goh@intel.com>
Signed-off-by: Noor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@intel.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
V2 -> V3: Removed value assign for 'flow' in else statement based on review comments
V1 -> V2: Removed needless condition based on review comments

 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c |  2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index c25bfecb4a2d..369db308b1dd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -748,6 +748,8 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
 	if (fc & FLOW_RX) {
 		pr_debug("\tReceive Flow-Control ON\n");
 		flow |= GMAC_RX_FLOW_CTRL_RFE;
+	} else {
+		pr_debug("\tReceive Flow-Control OFF\n");
 	}
 	writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8273e6a175c8..ab7f48f32f5b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1061,8 +1061,16 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 		ctrl |= priv->hw->link.duplex;
 
 	/* Flow Control operation */
-	if (tx_pause && rx_pause)
-		stmmac_mac_flow_ctrl(priv, duplex);
+	if (rx_pause && tx_pause)
+		priv->flow_ctrl = FLOW_AUTO;
+	else if (rx_pause && !tx_pause)
+		priv->flow_ctrl = FLOW_RX;
+	else if (!rx_pause && tx_pause)
+		priv->flow_ctrl = FLOW_TX;
+	else
+		priv->flow_ctrl = FLOW_OFF;
+
+	stmmac_mac_flow_ctrl(priv, duplex);
 
 	if (ctrl != old_ctrl)
 		writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
-- 
2.17.1


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

* Re: [PATCH net v3] net: stmmac: Set MAC's flow control register to reflect current settings
  2022-11-23  9:15 [PATCH net v3] net: stmmac: Set MAC's flow control register to reflect current settings Goh, Wei Sheng
@ 2022-11-23 18:09 ` Alexander Lobakin
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Lobakin @ 2022-11-23 18:09 UTC (permalink / raw)
  To: Goh, Wei Sheng
  Cc: Alexander Lobakin, Giuseppe Cavallaro, Alexandre Torgue,
	Jose Abreu, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Maxime Coquelin, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel, Ong Boon Leong, Voon Wei Feng,
	Tan Tee Min, Ahmad Tarmizi Noor Azura, Looi Hong Aun

From: "Goh, Wei Sheng" <wei.sheng.goh@intel.com>
Date: Wed, 23 Nov 2022 17:15:29 +0800

> Currently, pause frame register GMAC_RX_FLOW_CTRL_RFE is not updated
> correctly when 'ethtool -A <IFACE> autoneg off rx off tx off' command
> is issued. This fix ensures the flow control change is reflected directly
> in the GMAC_RX_FLOW_CTRL_RFE register.
> 
> Fixes: 46f69ded988d ("net: stmmac: Use resolved link config in mac_link_up()")
> Cc: <stable@vger.kernel.org> # 5.10.x
> Signed-off-by: Goh, Wei Sheng <wei.sheng.goh@intel.com>
> Signed-off-by: Noor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@intel.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> ---
> V2 -> V3: Removed value assign for 'flow' in else statement based on review comments
> V1 -> V2: Removed needless condition based on review comments
> 
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c |  2 ++
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++--
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> index c25bfecb4a2d..369db308b1dd 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> @@ -748,6 +748,8 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
>  	if (fc & FLOW_RX) {
>  		pr_debug("\tReceive Flow-Control ON\n");
>  		flow |= GMAC_RX_FLOW_CTRL_RFE;
> +	} else {
> +		pr_debug("\tReceive Flow-Control OFF\n");

Doesn't belong the commit subject. Debug improvements usually are
-next material.
Also, don't use pr_*() when netdev_*(), pci_*() or dev_*() are
available. You won't understand which interface wrote this to the
kernel log currently.

>  	}
>  	writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
>  
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 8273e6a175c8..ab7f48f32f5b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1061,8 +1061,16 @@ static void stmmac_mac_link_up(struct phylink_config *config,
>  		ctrl |= priv->hw->link.duplex;
>  
>  	/* Flow Control operation */
> -	if (tx_pause && rx_pause)
> -		stmmac_mac_flow_ctrl(priv, duplex);
> +	if (rx_pause && tx_pause)
> +		priv->flow_ctrl = FLOW_AUTO;
> +	else if (rx_pause && !tx_pause)
> +		priv->flow_ctrl = FLOW_RX;
> +	else if (!rx_pause && tx_pause)
> +		priv->flow_ctrl = FLOW_TX;
> +	else
> +		priv->flow_ctrl = FLOW_OFF;

	priv->flow_ctrl = FLOW_OFF;
	if (rx_pause)
		priv->flow_ctrl |= FLOW_RX;
	if (tx_pause)
		priv->flow_ctrl |= FLOW_TX;

100% identical functionally.

> +
> +	stmmac_mac_flow_ctrl(priv, duplex);
>  
>  	if (ctrl != old_ctrl)
>  		writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
> -- 
> 2.17.1

Thanks,
Olek

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

end of thread, other threads:[~2022-11-23 18:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23  9:15 [PATCH net v3] net: stmmac: Set MAC's flow control register to reflect current settings Goh, Wei Sheng
2022-11-23 18:09 ` Alexander Lobakin

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).