net: stmmac: Set MAC's flow control register to reflect current settings
Subsystems (4)
PATCH v2 1/1 net: stmmac: Set MAC's flow control register to reflect current settings
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.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 +++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +3 -0
@@ -748,6 +748,9 @@ 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" ); + flow &= ~GMAC_RX_FLOW_CTRL_RFE ; }writel (flow, ioaddr +GMAC_RX_FLOW_CTRL );
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -2
@@ -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 );
Signature · 1 line
2.17.1
Quoted 4 lines · Wei Sheng
Currently, pause frame register
GMAC_RX_FLOW_CTRL_RFEis 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 theGMAC_RX_FLOW_CTRL_RFEregister.
In future, please include a summary of what changed from version 1 of the patch. This is generally placed under the --- marker.
Quoted 5 lines
Fixes 46f69ded988d ("net: stmmac: Use resolved link config in mac_link_up()")Cc <[email protected]> # 5.10.xSigned-off-by Goh, Wei Sheng <[email protected]>Signed-off-by Noor Azura Ahmad Tarmizi <[email protected]>
Andrew
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, · line 755
Quoted 13 lines · Wei Sheng
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +3
-0@@ -748,6 +748,9 @@ 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" ); + flow &= ~GMAC_RX_FLOW_CTRL_RFE ; }writel (flow, ioaddr +GMAC_RX_FLOW_CTRL );
This doesn't look correct to me. The function starts off:
unsigned int flow = 0;
flow is not written to before the context above. So, the code you've added effectively does:
flow = 0 & ~GMAC_RX_FLOW_CTRL_RFE;
which is still zero. So, I don't think this hunk is meaningful apart from adding the pr_debug().
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3
-2@@ -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)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_mac_link_up(struct phylink_config *config, · line 1076
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7
-0+ 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 );
This looks like the true fix for correctly setting the flow control depending on the phylink link_up() (which will contain the resuts of pause negotiation, rate adaption or overriden by ethtool - but only when operating in full duplex mode.)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 19 lines · Russell King (Oracle)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, · line 755
Quoted 13 lines · Wei Sheng
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +3
-0@@ -748,6 +748,9 @@ 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" ); + flow &= ~GMAC_RX_FLOW_CTRL_RFE ; }writel (flow, ioaddr +GMAC_RX_FLOW_CTRL );This doesn't look correct to me. The function starts off:
unsigned int flow = 0;
Quoted 7 lines
flow is not written to before the context above. So, the code you've added effectively does:
flow = 0 & ~GMAC_RX_FLOW_CTRL_RFE;which is still zero. So, I don't think this hunk is meaningful apart from adding the
pr_debug().
It also should be noted that it looks like:
dwxgmac2_core.c::dwxgmac2_flow_ctrl() is definitely buggy - it will only set flow control, never clearing it.
dwmac100_core.c::dwmac100_flow_ctrl() looks potentially buggy - always enabling flow control irrespective of anything.
The other two implmentations look sane to me.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!