Skip to contentSkip to conversation

net: dsa and systemport WoL changes

PATCH In review Florian Fainelli 3 participants 9 messages Aug 3, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover net: dsa and systemport WoL changes

Hi David,

This patch series extracts what was previously submitted as part of the "WAKE_FILTER" Wake-on-LAN patch series into patches that do not.

Changes in this series:

- properly align the dsa_is_cpu_port() check in first patch

Florian Fainelli (4):
net: dsa: bcm_sf2: Allow targeting CPU ports for CFP rules
net: dsa: bcm_sf2: Disable learning while in WoL
net: systemport: Do not re-configure upon WoL interrupt
net: systemport: Create helper to set MPD

 drivers/net/dsa/bcm_sf2.c                  | 12 +++++++++++-
 drivers/net/dsa/bcm_sf2_cfp.c              |  3 ++-
 drivers/net/dsa/bcm_sf2_regs.h             |  2 ++
 drivers/net/ethernet/broadcom/bcmsysport.c | 24 ++++++++++++++----------
 4 files changed, 29 insertions(+), 12 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/4 net: dsa: bcm_sf2: Allow targeting CPU ports for CFP rules

ds->enabled_port_mask only contains a bitmask of user-facing enabled ports, we also need to allow programming CFP rules that target CPU ports (e.g: ports 5 and 8).

---
 drivers/net/dsa/bcm_sf2_cfp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2_cfp.c +2 -1
index b89acaee12d4..1e37b65aab93 100644
@@ -755,7 +755,8 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
 	port_num = fs->ring_cookie / SF2_NUM_EGRESS_QUEUES;
 
 	if (fs->ring_cookie == RX_CLS_FLOW_DISC ||
-	    !dsa_is_user_port(ds, port_num) ||
+	    !(dsa_is_user_port(ds, port_num) ||
+	      dsa_is_cpu_port(ds, port_num)) ||
 	    port_num >= priv->hw_params.num_ports)
 		return -EINVAL;
 	/*
Signature · 1 line
2.14.1
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH net-next 1/4] net: dsa: bcm_sf2: Allow targeting CPU ports for CFP rules

Quoted 5 lines · Florian Fainelli

ds->enabled_port_mask only contains a bitmask of user-facing enabled ports, we also need to allow programming CFP rules that target CPU ports (e.g: ports 5 and 8).

Andrew

#3 lore raw

PATCH 2/4 net: dsa: bcm_sf2: Disable learning while in WoL

In reply to Florian Fainelli

When we are in Wake-on-LAN, we operate with the host sofware not running a network stack, so we want to the switch to flood packets in order to cause a system wake-up when matching specific filters (unicast or multicast). This was not necessary before since we supported Magic Packet which are targeting a broadcast MAC address which the switch already floods.

---
 drivers/net/dsa/bcm_sf2.c      | 12 +++++++++++-
 drivers/net/dsa/bcm_sf2_regs.h |  2 ++
 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2.c +11 -1
index ac96ff40d37e..e0066adcd2f3 100644
@@ -166,6 +166,11 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
 	reg &= ~P_TXQ_PSM_VDD(port);
 	core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL);
 
+	/* Enable learning */
+	reg = core_readl(priv, CORE_DIS_LEARN);
+	reg &= ~BIT(port);
+	core_writel(priv, reg, CORE_DIS_LEARN);
+
 	/* Enable Broadcom tags for that port if requested */
 	if (priv->brcm_tag_mask & BIT(port))
 		b53_brcm_hdr_setup(ds, port);
@@ -222,8 +227,13 @@ static void bcm_sf2_port_disable(struct dsa_switch *ds, int port,
 	struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
 	u32 reg;
 
-	if (priv->wol_ports_mask & (1 << port))
+	/* Disable learning while in WoL mode */
+	if (priv->wol_ports_mask & (1 << port)) {
+		reg = core_readl(priv, CORE_DIS_LEARN);
+		reg |= BIT(port);
+		core_writel(priv, reg, CORE_DIS_LEARN);
 		return;
+	}
 
 	if (port == priv->moca_port)
 		bcm_sf2_port_intr_disable(priv, port);
drivers/net/dsa/bcm_sf2_regs.h +2 -0
index 3ccd5a865dcb..0a1e530d52b7 100644
@@ -168,6 +168,8 @@ enum bcm_sf2_reg_offs {
 #define CORE_SWITCH_CTRL		0x00088
 #define  MII_DUMB_FWDG_EN		(1 << 6)
 
+#define CORE_DIS_LEARN			0x000f0
+
 #define CORE_SFT_LRN_CTRL		0x000f8
 #define  SW_LEARN_CNTL(x)		(1 << (x))
 
Signature · 1 line
2.14.1
maintainer Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH net-next 2/4] net: dsa: bcm_sf2: Disable learning while in WoL

Quoted 8 lines · Florian Fainelli

When we are in Wake-on-LAN, we operate with the host sofware not running a network stack, so we want to the switch to flood packets in order to cause a system wake-up when matching specific filters (unicast or multicast). This was not necessary before since we supported Magic Packet which are targeting a broadcast MAC address which the switch already floods.

Andrew

#5 lore raw

PATCH 3/4 net: systemport: Do not re-configure upon WoL interrupt

In reply to Florian Fainelli

We already properly resume from Wake-on-LAN whether such a condition occured or not, no need to process the WoL interrupt for functional changes since that could race with other settings.

---
 drivers/net/ethernet/broadcom/bcmsysport.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +1 -3
index 631617d95769..7faad9e1a6f9 100644
@@ -1102,10 +1102,8 @@ static irqreturn_t bcm_sysport_rx_isr(int irq, void *dev_id)
 	if (priv->irq0_stat & INTRL2_0_TX_RING_FULL)
 		bcm_sysport_tx_reclaim_all(priv);
 
-	if (priv->irq0_stat & INTRL2_0_MPD) {
+	if (priv->irq0_stat & INTRL2_0_MPD)
 		netdev_info(priv->netdev, "Wake-on-LAN interrupt!\n");
-		bcm_sysport_resume_from_wol(priv);
-	}
 
 	if (!priv->is_lite)
 		goto out;
Signature · 1 line
2.14.1
#6 lore raw

PATCH 4/4 net: systemport: Create helper to set MPD

In reply to Florian Fainelli

Create a helper function to turn on/off MPD, this will be used to avoid duplicating code as we are going to add additional types of wake-up types.

---
 drivers/net/ethernet/broadcom/bcmsysport.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +13 -7
index 7faad9e1a6f9..284581c9680e 100644
@@ -1041,17 +1041,25 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget)
 	return work_done;
 }
 
-static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv)
+static void mpd_enable_set(struct bcm_sysport_priv *priv, bool enable)
 {
 	u32 reg;
 
+	reg = umac_readl(priv, UMAC_MPD_CTRL);
+	if (enable)
+		reg |= MPD_EN;
+	else
+		reg &= ~MPD_EN;
+	umac_writel(priv, reg, UMAC_MPD_CTRL);
+}
+
+static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv)
+{
 	/* Stop monitoring MPD interrupt */
 	intrl2_0_mask_set(priv, INTRL2_0_MPD);
 
 	/* Clear the MagicPacket detection logic */
-	reg = umac_readl(priv, UMAC_MPD_CTRL);
-	reg &= ~MPD_EN;
-	umac_writel(priv, reg, UMAC_MPD_CTRL);
+	mpd_enable_set(priv, false);
 
 	netif_dbg(priv, wol, priv->netdev, "resumed from WOL\n");
 }
@@ -2447,9 +2455,7 @@ static int bcm_sysport_suspend_to_wol(struct bcm_sysport_priv *priv)
 
 	/* Do not leave the UniMAC RBUF matching only MPD packets */
 	if (!timeout) {
-		reg = umac_readl(priv, UMAC_MPD_CTRL);
-		reg &= ~MPD_EN;
-		umac_writel(priv, reg, UMAC_MPD_CTRL);
+		mpd_enable_set(priv, false);
 		netif_err(priv, wol, ndev, "failed to enter WOL mode\n");
 		return -ETIMEDOUT;
 	}
Signature · 1 line
2.14.1
maintainer
#8 lore raw
In reply to Florian Fainelli

From: Florian Fainelli <[email protected]>
Date: Fri, 3 Aug 2018 11:08:40 -0700

Quoted 6 lines

This patch series extracts what was previously submitted as part of the "WAKE_FILTER" Wake-on-LAN patch series into patches that do not.

Changes in this series:

- properly align the dsa_is_cpu_port() check in first patch

Series applied, thanks for splitting these out into a separate series.