All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports
@ 2022-08-15 17:50 Florian Fainelli
  2022-08-15 17:50 ` [PATCH net-next 1/2] net: dsa: bcm_sf2: Introduce helper for port override offset Florian Fainelli
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Florian Fainelli @ 2022-08-15 17:50 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Andrew Lunn, Vivien Didelot, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list

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

-- 
2.25.1


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

* [PATCH net-next 1/2] net: dsa: bcm_sf2: Introduce helper for port override offset
  2022-08-15 17:50 [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Florian Fainelli
@ 2022-08-15 17:50 ` Florian Fainelli
  2022-08-15 17:50 ` [PATCH net-next 2/2] net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s) Florian Fainelli
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2022-08-15 17:50 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Andrew Lunn, Vivien Didelot, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list

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.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/bcm_sf2.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index be0edfa093d0..10de0cffa047 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -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 ||
-- 
2.25.1


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

* [PATCH net-next 2/2] net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s)
  2022-08-15 17:50 [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Florian Fainelli
  2022-08-15 17:50 ` [PATCH net-next 1/2] net: dsa: bcm_sf2: Introduce helper for port override offset Florian Fainelli
@ 2022-08-15 17:50 ` Florian Fainelli
  2022-08-17 15:54 ` [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Jakub Kicinski
  2022-08-17 18:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2022-08-15 17:50 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Andrew Lunn, Vivien Didelot, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list

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

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/bcm_sf2.c | 95 ++++++++++++++++++---------------------
 1 file changed, 43 insertions(+), 52 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 10de0cffa047..572f7450b527 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -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);
-- 
2.25.1


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

* Re: [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports
  2022-08-15 17:50 [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Florian Fainelli
  2022-08-15 17:50 ` [PATCH net-next 1/2] net: dsa: bcm_sf2: Introduce helper for port override offset Florian Fainelli
  2022-08-15 17:50 ` [PATCH net-next 2/2] net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s) Florian Fainelli
@ 2022-08-17 15:54 ` Jakub Kicinski
  2022-08-17 17:27   ` Vladimir Oltean
  2022-08-17 18:40 ` patchwork-bot+netdevbpf
  3 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2022-08-17 15:54 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: Florian Fainelli, netdev, Andrew Lunn, Vivien Didelot,
	David S. Miller, Eric Dumazet, Paolo Abeni, open list

On Mon, 15 Aug 2022 10:50:07 -0700 Florian Fainelli wrote:
> 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

Last call for reviews..

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

* Re: [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports
  2022-08-17 15:54 ` [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Jakub Kicinski
@ 2022-08-17 17:27   ` Vladimir Oltean
  2022-08-17 17:56     ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir Oltean @ 2022-08-17 17:27 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Florian Fainelli, netdev, Andrew Lunn, Vivien Didelot,
	David S. Miller, Eric Dumazet, Paolo Abeni, open list

On Wed, Aug 17, 2022 at 08:54:14AM -0700, Jakub Kicinski wrote:
> On Mon, 15 Aug 2022 10:50:07 -0700 Florian Fainelli wrote:
> > 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
> 
> Last call for reviews..

My review is: let's see what breaks...

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

* Re: [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports
  2022-08-17 17:27   ` Vladimir Oltean
@ 2022-08-17 17:56     ` Jakub Kicinski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2022-08-17 17:56 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: Florian Fainelli, netdev, Andrew Lunn, Vivien Didelot,
	David S. Miller, Eric Dumazet, Paolo Abeni, open list

On Wed, 17 Aug 2022 20:27:04 +0300 Vladimir Oltean wrote:
> On Wed, Aug 17, 2022 at 08:54:14AM -0700, Jakub Kicinski wrote:
> > On Mon, 15 Aug 2022 10:50:07 -0700 Florian Fainelli wrote:  
> > > 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  
> > 
> > Last call for reviews..  
> 
> My review is: let's see what breaks...

*nod*, thanks!

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

* Re: [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports
  2022-08-15 17:50 [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Florian Fainelli
                   ` (2 preceding siblings ...)
  2022-08-17 15:54 ` [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Jakub Kicinski
@ 2022-08-17 18:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-17 18:40 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, andrew, vivien.didelot, olteanv, davem, edumazet, kuba,
	pabeni, linux-kernel

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 15 Aug 2022 10:50:07 -0700 you wrote:
> 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
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-08-17 18:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 17:50 [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Florian Fainelli
2022-08-15 17:50 ` [PATCH net-next 1/2] net: dsa: bcm_sf2: Introduce helper for port override offset Florian Fainelli
2022-08-15 17:50 ` [PATCH net-next 2/2] net: dsa: bcm_sf2: Have PHYLINK configure CPU/IMP port(s) Florian Fainelli
2022-08-17 15:54 ` [PATCH net-next 0/2] net: dsa: bcm_sf2: Utilize PHYLINK for all ports Jakub Kicinski
2022-08-17 17:27   ` Vladimir Oltean
2022-08-17 17:56     ` Jakub Kicinski
2022-08-17 18:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.