net: dsa: bcm_sf2: Utilize PHYLINK for all ports
cover net: dsa: bcm_sf2: Utilize PHYLINK for all ports
Hi all,
This patch series has the bcm_sf2 driver utilize PHYLINK to configure the CPU port link parameters to unify the configuration and pave the way for DSA to utilize PHYLINK for all ports in the future.
Tested on BCM7445 and BCM7278
Florian Fainelli (2):
net: dsa: bcm_sf2: Introduce helper for port override offset
net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s)
drivers/net/dsa/bcm_sf2.c | 130 ++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 67 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 net: dsa: bcm_sf2: Introduce helper for port override offset
Depending upon the generation of switches, we have different offsets for configuring a given port's status override where link parameters are applied. Introduce a helper function that we re-use throughout the code in order to let phylink callbacks configure the IMP/CPU port(s) in subsequent changes.
--- drivers/net/dsa/bcm_sf2.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)
drivers/net/dsa/bcm_sf2.c +21 -16
@@ -94,6 +94,24 @@ static u16 bcm_sf2_reg_led_base(struct bcm_sf2_priv *priv, int port)return REG_SWITCH_STATUS ; } +static u32 bcm_sf2_port_override_offset (struct bcm_sf2_priv *priv,int port) +{ +switch (priv->type) { +case BCM4908_DEVICE_ID : +case BCM7445_DEVICE_ID : +return port ==8 ?CORE_STS_OVERRIDE_IMP : +CORE_STS_OVERRIDE_GMIIP_PORT (port); +case BCM7278_DEVICE_ID : +return port ==8 ?CORE_STS_OVERRIDE_IMP2 : +CORE_STS_OVERRIDE_GMIIP2_PORT (port); +default : +WARN_ONCE (1 ,"Unsupported device: %d\n" , priv->type); + } + +/* RO fallback register */ +return REG_SWITCH_STATUS ; +} +/* Return the number of active ports, not counting the IMP (CPU) port */ static unsigned int bcm_sf2_num_active_ports (struct dsa_switch *ds) {
@@ -167,11 +185,7 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port)b53_brcm_hdr_setup (ds, port);if (port ==8 ) { -if (priv->type ==BCM4908_DEVICE_ID || - priv->type ==BCM7445_DEVICE_ID ) - offset =CORE_STS_OVERRIDE_IMP ; -else - offset =CORE_STS_OVERRIDE_IMP2 ; + offset =bcm_sf2_port_override_offset (priv, port);/* Force link status for IMP port */ reg =core_readl (priv, offset);
@@ -813,12 +827,7 @@ static void bcm_sf2_sw_mac_link_down(struct dsa_switch *ds, int port,return ;if (port !=core_readl (priv,CORE_IMP0_PRT_ID )) { -if (priv->type ==BCM4908_DEVICE_ID || - priv->type ==BCM7445_DEVICE_ID ) - offset =CORE_STS_OVERRIDE_GMIIP_PORT (port); -else - offset =CORE_STS_OVERRIDE_GMIIP2_PORT (port); - + offset =bcm_sf2_port_override_offset (priv, port); reg =core_readl (priv, offset); reg &= ~LINK_STS ;core_writel (priv, reg, offset);
@@ -843,11 +852,7 @@ static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port,u32 reg_rgmii_ctrl =0 ;u32 reg, offset; -if (priv->type ==BCM4908_DEVICE_ID || - priv->type ==BCM7445_DEVICE_ID ) - offset =CORE_STS_OVERRIDE_GMIIP_PORT (port); -else - offset =CORE_STS_OVERRIDE_GMIIP2_PORT (port); + offset =bcm_sf2_port_override_offset (priv, port); if (interface == PHY_INTERFACE_MODE_RGMII || interface == PHY_INTERFACE_MODE_RGMII_TXID ||
Signature · 1 line
2.25.1
PATCH 2/2 net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s)
In reply to Florian FainelliRemove the artificial limitations imposed upon bcm_sf2_sw_mac_link_{up,down} and allow us to override the link parameters for IMP port(s) as well as regular ports by accounting for the special differences that exist there.
Remove the code that did override the link parameters in bcm_sf2_imp_setup().
--- drivers/net/dsa/bcm_sf2.c | 95 ++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 52 deletions(-)
drivers/net/dsa/bcm_sf2.c +43 -52
@@ -159,7 +159,7 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) {struct bcm_sf2_priv *priv =bcm_sf2_to_priv (ds);unsigned int i; -u32 reg, offset; +u32 reg;/* Enable the port memories */ reg =core_readl (priv,CORE_MEM_PSM_VDD_CTRL );
@@ -185,17 +185,6 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port)b53_brcm_hdr_setup (ds, port);if (port ==8 ) { - offset =bcm_sf2_port_override_offset (priv, port); - -/* Force link status for IMP port */ - reg =core_readl (priv, offset); - reg |= (MII_SW_OR |LINK_STS ); -if (priv->type ==BCM4908_DEVICE_ID ) - reg |=GMII_SPEED_UP_2G ; -else - reg &= ~GMII_SPEED_UP_2G ; -core_writel (priv, reg, offset); -/* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ reg =core_readl (priv,CORE_IMP_CTL ); reg |= (RX_BCST_EN |RX_MCST_EN |RX_UCST_EN );
@@ -826,12 +815,10 @@ static void bcm_sf2_sw_mac_link_down(struct dsa_switch *ds, int port,if (priv->wol_ports_mask &BIT (port))return ; -if (port !=core_readl (priv,CORE_IMP0_PRT_ID )) { - offset =bcm_sf2_port_override_offset (priv, port); - reg =core_readl (priv, offset); - reg &= ~LINK_STS ; -core_writel (priv, reg, offset); - } + offset =bcm_sf2_port_override_offset (priv, port); + reg =core_readl (priv, offset); + reg &= ~LINK_STS ; +core_writel (priv, reg, offset);bcm_sf2_sw_mac_link_set (ds, port, interface, false); }
@@ -845,51 +832,55 @@ static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port, {struct bcm_sf2_priv *priv =bcm_sf2_to_priv (ds);struct ethtool_eee *p = &priv->dev->ports[port].eee; +u32 reg_rgmii_ctrl =0 ; +u32 reg, offset;bcm_sf2_sw_mac_link_set (ds, port, interface, true); -if (port !=core_readl (priv,CORE_IMP0_PRT_ID )) { -u32 reg_rgmii_ctrl =0 ; -u32 reg, offset; + offset =bcm_sf2_port_override_offset (priv, port); - offset =bcm_sf2_port_override_offset (priv, port); +if (phy_interface_mode_is_rgmii (interface) || + interface ==PHY_INTERFACE_MODE_MII || + interface ==PHY_INTERFACE_MODE_REVMII ) { + reg_rgmii_ctrl =bcm_sf2_reg_rgmii_cntrl (priv, port); + reg =reg_readl (priv, reg_rgmii_ctrl); + reg &= ~(RX_PAUSE_EN |TX_PAUSE_EN ); -if (interface ==PHY_INTERFACE_MODE_RGMII || - interface ==PHY_INTERFACE_MODE_RGMII_TXID || - interface ==PHY_INTERFACE_MODE_MII || - interface ==PHY_INTERFACE_MODE_REVMII ) { - reg_rgmii_ctrl =bcm_sf2_reg_rgmii_cntrl (priv, port); - reg =reg_readl (priv, reg_rgmii_ctrl); - reg &= ~(RX_PAUSE_EN |TX_PAUSE_EN ); +if (tx_pause) + reg |=TX_PAUSE_EN ; +if (rx_pause) + reg |=RX_PAUSE_EN ; -if (tx_pause) - reg |=TX_PAUSE_EN ; -if (rx_pause) - reg |=RX_PAUSE_EN ; +reg_writel (priv, reg, reg_rgmii_ctrl); + } -reg_writel (priv, reg, reg_rgmii_ctrl); - } + reg =LINK_STS ; +if (port ==8 ) { +if (priv->type ==BCM4908_DEVICE_ID ) + reg |=GMII_SPEED_UP_2G ; + reg |=MII_SW_OR ; + }else { + reg |=SW_OVERRIDE ; + } - reg =SW_OVERRIDE |LINK_STS ; -switch (speed) { -case SPEED_1000 : - reg |=SPDSTS_1000 <<SPEED_SHIFT ; -break ; -case SPEED_100 : - reg |=SPDSTS_100 <<SPEED_SHIFT ; -break ; - } +switch (speed) { +case SPEED_1000 : + reg |=SPDSTS_1000 <<SPEED_SHIFT ; +break ; +case SPEED_100 : + reg |=SPDSTS_100 <<SPEED_SHIFT ; +break ; + } -if (duplex ==DUPLEX_FULL ) - reg |=DUPLX_MODE ; +if (duplex ==DUPLEX_FULL ) + reg |=DUPLX_MODE ; -if (tx_pause) - reg |=TXFLOW_CNTL ; -if (rx_pause) - reg |=RXFLOW_CNTL ; +if (tx_pause) + reg |=TXFLOW_CNTL ; +if (rx_pause) + reg |=RXFLOW_CNTL ; -core_writel (priv, reg, offset); - } +core_writel (priv, reg, offset);if (mode ==MLO_AN_PHY && phydev) p->eee_enabled =b53_eee_init (ds, port, phydev);
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerQuoted 7 lines · On Mon, 15 Aug 2022 10:50:07 -0700 Florian Fainelli wrote:
Hi all,
This patch series has the
bcm_sf2driver utilize PHYLINK to configure the CPU port link parameters to unify the configuration and pave the way for DSA to utilize PHYLINK for all ports in the future.Tested on BCM7445 and BCM7278
Last call for reviews..
Vladimir Oltean
maintainerQuoted 10 lines · Jakub Kicinski
Quoted 7 lines · On Mon, 15 Aug 2022 10:50:07 -0700 Florian Fainelli wrote:
Hi all,
This patch series has the
bcm_sf2driver utilize PHYLINK to configure the CPU port link parameters to unify the configuration and pave the way for DSA to utilize PHYLINK for all ports in the future.Tested on BCM7445 and BCM7278
Last call for reviews..
My review is: let's see what breaks...
Jakub Kicinski
maintainerQuoted 8 lines · On Wed, 17 Aug 2022 20:27:04 +0300 Vladimir Oltean wrote:
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Mon, 15 Aug 2022 10:50:07 -0700 Florian Fainelli wrote:
Hi all,
This patch series has the
bcm_sf2driver utilize PHYLINK to configure the CPU port link parameters to unify the configuration and pave the way for DSA to utilize PHYLINK for all ports in the future.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Tested on BCM7445 and BCM7278
Last call for reviews..
My review is: let's see what breaks...
*nod*, thanks!
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 15 Aug 2022 10:50:07 -0700 you wrote:
Hi all,
This patch series has the
bcm_sf2driver utilize PHYLINK to configure the CPU port link parameters to unify the configuration and pave the way for DSA to utilize PHYLINK for all ports in the future.Tested on BCM7445 and BCM7278
[...]
Here is the summary with links:
- [net-next,1/2] net: dsa: bcm_sf2: Introduce helper for port override offset
https://git.kernel.org/netdev/net-next/c/1ed26ce4850a - [net-next,2/2] net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s) https://git.kernel.org/netdev/net-next/c/4d2f6dde4daa
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html