* [PATCH net-next 1/3] net: dsa/bcm_sf2: fix incorrect usage of state->link
2020-06-30 10:27 [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state Russell King - ARM Linux admin
@ 2020-06-30 10:28 ` Russell King
2020-06-30 10:28 ` [PATCH net-next 2/3] net: dsa/bcm_sf2: move speed/duplex forcing to mac_link_up() Russell King
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Russell King @ 2020-06-30 10:28 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: David S. Miller, netdev, Vivien Didelot, Jakub Kicinski
state->link has never been valid in mac_config() implementations -
while it may be correct in some calls, it is not true that it can be
relied upon.
Fix bcm_sf2 to use the correct method of handling forced link status.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/dsa/bcm_sf2.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 946e41f020a5..5a8759d2de6c 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -618,8 +618,6 @@ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
break;
}
- if (state->link)
- reg |= LINK_STS;
if (state->duplex == DUPLEX_FULL)
reg |= DUPLX_MODE;
@@ -650,6 +648,20 @@ static void bcm_sf2_sw_mac_link_down(struct dsa_switch *ds, int port,
unsigned int mode,
phy_interface_t interface)
{
+ struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
+ u32 reg, offset;
+
+ if (port != core_readl(priv, CORE_IMP0_PRT_ID)) {
+ if (priv->type == BCM7445_DEVICE_ID)
+ offset = CORE_STS_OVERRIDE_GMIIP_PORT(port);
+ else
+ offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
+
+ reg = core_readl(priv, offset);
+ reg &= ~LINK_STS;
+ core_writel(priv, reg, offset);
+ }
+
bcm_sf2_sw_mac_link_set(ds, port, interface, false);
}
@@ -662,9 +674,21 @@ 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, offset;
bcm_sf2_sw_mac_link_set(ds, port, interface, true);
+ if (port != core_readl(priv, CORE_IMP0_PRT_ID)) {
+ if (priv->type == BCM7445_DEVICE_ID)
+ offset = CORE_STS_OVERRIDE_GMIIP_PORT(port);
+ else
+ offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
+
+ reg = core_readl(priv, offset);
+ reg |= LINK_STS;
+ core_writel(priv, reg, offset);
+ }
+
if (mode == MLO_AN_PHY && phydev)
p->eee_enabled = b53_eee_init(ds, port, phydev);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 2/3] net: dsa/bcm_sf2: move speed/duplex forcing to mac_link_up()
2020-06-30 10:27 [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state Russell King - ARM Linux admin
2020-06-30 10:28 ` [PATCH net-next 1/3] net: dsa/bcm_sf2: fix incorrect usage of state->link Russell King
@ 2020-06-30 10:28 ` Russell King
2020-06-30 10:28 ` [PATCH net-next 3/3] net: dsa/bcm_sf2: move pause mode setting into mac_link_up() Russell King
2020-06-30 20:05 ` [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state David Miller
3 siblings, 0 replies; 7+ messages in thread
From: Russell King @ 2020-06-30 10:28 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: David S. Miller, netdev, Vivien Didelot, Jakub Kicinski
Convert the bcm_sf2 to use the finalised speed and duplex in its
mac_link_up() call rather than the parameters in mac_config().
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/dsa/bcm_sf2.c | 43 +++++++++++++++------------------------
1 file changed, 16 insertions(+), 27 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 5a8759d2de6c..062e6efad53f 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -558,16 +558,11 @@ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
{
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
u32 id_mode_dis = 0, port_mode;
- u32 reg, offset;
+ u32 reg;
if (port == core_readl(priv, CORE_IMP0_PRT_ID))
return;
- if (priv->type == BCM7445_DEVICE_ID)
- offset = CORE_STS_OVERRIDE_GMIIP_PORT(port);
- else
- offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
-
switch (state->interface) {
case PHY_INTERFACE_MODE_RGMII:
id_mode_dis = 1;
@@ -582,8 +577,8 @@ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
port_mode = EXT_REVMII;
break;
default:
- /* all other PHYs: internal and MoCA */
- goto force_link;
+ /* Nothing required for all other PHYs: internal and MoCA */
+ return;
}
/* Clear id_mode_dis bit, and the existing port mode, let
@@ -605,23 +600,6 @@ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
}
reg_writel(priv, reg, REG_RGMII_CNTRL_P(port));
-
-force_link:
- /* Force link settings detected from the PHY */
- reg = SW_OVERRIDE;
- switch (state->speed) {
- case SPEED_1000:
- reg |= SPDSTS_1000 << SPEED_SHIFT;
- break;
- case SPEED_100:
- reg |= SPDSTS_100 << SPEED_SHIFT;
- break;
- }
-
- if (state->duplex == DUPLEX_FULL)
- reg |= DUPLX_MODE;
-
- core_writel(priv, reg, offset);
}
static void bcm_sf2_sw_mac_link_set(struct dsa_switch *ds, int port,
@@ -684,8 +662,19 @@ static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port,
else
offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
- reg = core_readl(priv, offset);
- reg |= LINK_STS;
+ 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;
+ }
+
+ if (duplex == DUPLEX_FULL)
+ reg |= DUPLX_MODE;
+
core_writel(priv, reg, offset);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 3/3] net: dsa/bcm_sf2: move pause mode setting into mac_link_up()
2020-06-30 10:27 [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state Russell King - ARM Linux admin
2020-06-30 10:28 ` [PATCH net-next 1/3] net: dsa/bcm_sf2: fix incorrect usage of state->link Russell King
2020-06-30 10:28 ` [PATCH net-next 2/3] net: dsa/bcm_sf2: move speed/duplex forcing to mac_link_up() Russell King
@ 2020-06-30 10:28 ` Russell King
2020-06-30 16:14 ` Jakub Kicinski
2020-06-30 20:05 ` [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state David Miller
3 siblings, 1 reply; 7+ messages in thread
From: Russell King @ 2020-06-30 10:28 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: David S. Miller, netdev, Vivien Didelot, Jakub Kicinski
bcm_sf2 only appears to support pause modes on RGMII interfaces (the
enable bits are in the RGMII control register.) Setup the pause modes
for RGMII connections.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/dsa/bcm_sf2.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 062e6efad53f..45e4d40d7e25 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -587,18 +587,11 @@ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
reg = reg_readl(priv, REG_RGMII_CNTRL_P(port));
reg &= ~ID_MODE_DIS;
reg &= ~(PORT_MODE_MASK << PORT_MODE_SHIFT);
- reg &= ~(RX_PAUSE_EN | TX_PAUSE_EN);
reg |= port_mode;
if (id_mode_dis)
reg |= ID_MODE_DIS;
- if (state->pause & MLO_PAUSE_TXRX_MASK) {
- if (state->pause & MLO_PAUSE_TX)
- reg |= TX_PAUSE_EN;
- reg |= RX_PAUSE_EN;
- }
-
reg_writel(priv, reg, REG_RGMII_CNTRL_P(port));
}
@@ -662,6 +655,22 @@ static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port,
else
offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
+ if (interface == PHY_INTERFACE_MODE_RGMII ||
+ interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+ interface == PHY_INTERFACE_MODE_MII ||
+ interface == PHY_INTERFACE_MODE_REVMII) {
+ reg = reg_readl(priv, REG_RGMII_CNTRL_P(port));
+ reg &= ~(RX_PAUSE_EN | TX_PAUSE_EN);
+
+ if (tx_pause)
+ reg |= TX_PAUSE_EN;
+ if (rx_pause)
+ reg |= RX_PAUSE_EN;
+
+ reg_writel(priv, reg, REG_RGMII_CNTRL_P(port));
+ }
+
+
reg = SW_OVERRIDE | LINK_STS;
switch (speed) {
case SPEED_1000:
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 3/3] net: dsa/bcm_sf2: move pause mode setting into mac_link_up()
2020-06-30 10:28 ` [PATCH net-next 3/3] net: dsa/bcm_sf2: move pause mode setting into mac_link_up() Russell King
@ 2020-06-30 16:14 ` Jakub Kicinski
0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2020-06-30 16:14 UTC (permalink / raw)
To: Russell King
Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, David S. Miller,
netdev, Vivien Didelot
On Tue, 30 Jun 2020 11:28:18 +0100 Russell King wrote:
> @@ -662,6 +655,22 @@ static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port,
> else
> offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
>
> + if (interface == PHY_INTERFACE_MODE_RGMII ||
> + interface == PHY_INTERFACE_MODE_RGMII_TXID ||
> + interface == PHY_INTERFACE_MODE_MII ||
> + interface == PHY_INTERFACE_MODE_REVMII) {
> + reg = reg_readl(priv, REG_RGMII_CNTRL_P(port));
> + reg &= ~(RX_PAUSE_EN | TX_PAUSE_EN);
> +
> + if (tx_pause)
> + reg |= TX_PAUSE_EN;
> + if (rx_pause)
> + reg |= RX_PAUSE_EN;
> +
> + reg_writel(priv, reg, REG_RGMII_CNTRL_P(port));
> + }
> +
> +
nit: double new line
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state
2020-06-30 10:27 [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state Russell King - ARM Linux admin
` (2 preceding siblings ...)
2020-06-30 10:28 ` [PATCH net-next 3/3] net: dsa/bcm_sf2: move pause mode setting into mac_link_up() Russell King
@ 2020-06-30 20:05 ` David Miller
2020-06-30 20:37 ` Russell King - ARM Linux admin
3 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2020-06-30 20:05 UTC (permalink / raw)
To: linux; +Cc: andrew, f.fainelli, hkallweit1, kuba, netdev, vivien.didelot
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Date: Tue, 30 Jun 2020 11:27:51 +0100
> Convert Broadcom SF2 DSA support to use the newly provided resolved
> link state via mac_link_up() rather than using the state in
> mac_config().
Series applied with double newline in patch #3 fixed up.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state
2020-06-30 20:05 ` [PATCH net-next 0/3] Convert Broadcom SF2 to mac_link_up() resolved state David Miller
@ 2020-06-30 20:37 ` Russell King - ARM Linux admin
0 siblings, 0 replies; 7+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-30 20:37 UTC (permalink / raw)
To: David Miller; +Cc: andrew, f.fainelli, hkallweit1, kuba, netdev, vivien.didelot
On Tue, Jun 30, 2020 at 01:05:32PM -0700, David Miller wrote:
> From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
> Date: Tue, 30 Jun 2020 11:27:51 +0100
>
> > Convert Broadcom SF2 DSA support to use the newly provided resolved
> > link state via mac_link_up() rather than using the state in
> > mac_config().
>
> Series applied with double newline in patch #3 fixed up.
Thanks David, I was going to send a series with that fixed up tomorrow.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 7+ messages in thread