net: dsa: bcm_sf2: Disable learning while in WoL
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 3 Aug 2018 18:08:42 +0000 (11:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Aug 2018 19:11:43 +0000 (12:11 -0700)
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.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/bcm_sf2_regs.h

index ac96ff40d37e1b0f1d46902a929542f1f7fdcea9..e0066adcd2f3d6ffd8e8ea6baba94337df0cd457 100644 (file)
@@ -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);
index 3ccd5a865dcba5f8615082ed6162bc24c97c0d4e..0a1e530d52b727a522626a1107138c853e44b011 100644 (file)
@@ -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))