Commit f9b3827e authored by Florian Fainelli's avatar Florian Fainelli Committed by Jakub Kicinski

net: dsa: b53: Support setting learning on port

Add support for being able to set the learning attribute on port, and
make sure that the standalone ports start up with learning disabled.

We can remove the code in bcm_sf2 that configured the ports learning
attribute because we want the standalone ports to have learning disabled
by default and port 7 cannot be bridged, so its learning attribute will
not change past its initial configuration.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e6dd86ed
...@@ -543,6 +543,19 @@ static void b53_port_set_mcast_flood(struct b53_device *dev, int port, ...@@ -543,6 +543,19 @@ static void b53_port_set_mcast_flood(struct b53_device *dev, int port,
b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc); b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc);
} }
static void b53_port_set_learning(struct b53_device *dev, int port,
bool learning)
{
u16 reg;
b53_read16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, &reg);
if (learning)
reg &= ~BIT(port);
else
reg |= BIT(port);
b53_write16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, reg);
}
int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
{ {
struct b53_device *dev = ds->priv; struct b53_device *dev = ds->priv;
...@@ -557,6 +570,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) ...@@ -557,6 +570,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
b53_port_set_ucast_flood(dev, port, true); b53_port_set_ucast_flood(dev, port, true);
b53_port_set_mcast_flood(dev, port, true); b53_port_set_mcast_flood(dev, port, true);
b53_port_set_learning(dev, port, false);
if (dev->ops->irq_enable) if (dev->ops->irq_enable)
ret = dev->ops->irq_enable(dev, port); ret = dev->ops->irq_enable(dev, port);
...@@ -691,6 +705,7 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port) ...@@ -691,6 +705,7 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)
b53_port_set_ucast_flood(dev, port, true); b53_port_set_ucast_flood(dev, port, true);
b53_port_set_mcast_flood(dev, port, true); b53_port_set_mcast_flood(dev, port, true);
b53_port_set_learning(dev, port, false);
} }
static void b53_enable_mib(struct b53_device *dev) static void b53_enable_mib(struct b53_device *dev)
...@@ -1957,7 +1972,7 @@ int b53_br_flags_pre(struct dsa_switch *ds, int port, ...@@ -1957,7 +1972,7 @@ int b53_br_flags_pre(struct dsa_switch *ds, int port,
struct switchdev_brport_flags flags, struct switchdev_brport_flags flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD)) if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD | BR_LEARNING))
return -EINVAL; return -EINVAL;
return 0; return 0;
...@@ -1974,6 +1989,9 @@ int b53_br_flags(struct dsa_switch *ds, int port, ...@@ -1974,6 +1989,9 @@ int b53_br_flags(struct dsa_switch *ds, int port,
if (flags.mask & BR_MCAST_FLOOD) if (flags.mask & BR_MCAST_FLOOD)
b53_port_set_mcast_flood(ds->priv, port, b53_port_set_mcast_flood(ds->priv, port,
!!(flags.val & BR_MCAST_FLOOD)); !!(flags.val & BR_MCAST_FLOOD));
if (flags.mask & BR_LEARNING)
b53_port_set_learning(ds->priv, port,
!!(flags.val & BR_LEARNING));
return 0; return 0;
} }
......
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
#define B53_UC_FLOOD_MASK 0x32 #define B53_UC_FLOOD_MASK 0x32
#define B53_MC_FLOOD_MASK 0x34 #define B53_MC_FLOOD_MASK 0x34
#define B53_IPMC_FLOOD_MASK 0x36 #define B53_IPMC_FLOOD_MASK 0x36
#define B53_DIS_LEARNING 0x3c
/* /*
* Override Ports 0-7 State on devices with xMII interfaces (8 bit) * Override Ports 0-7 State on devices with xMII interfaces (8 bit)
......
...@@ -223,23 +223,10 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port, ...@@ -223,23 +223,10 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
reg &= ~P_TXQ_PSM_VDD(port); reg &= ~P_TXQ_PSM_VDD(port);
core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL); 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 */ /* Enable Broadcom tags for that port if requested */
if (priv->brcm_tag_mask & BIT(port)) { if (priv->brcm_tag_mask & BIT(port))
b53_brcm_hdr_setup(ds, port); b53_brcm_hdr_setup(ds, port);
/* Disable learning on ASP port */
if (port == 7) {
reg = core_readl(priv, CORE_DIS_LEARN);
reg |= BIT(port);
core_writel(priv, reg, CORE_DIS_LEARN);
}
}
/* Configure Traffic Class to QoS mapping, allow each priority to map /* Configure Traffic Class to QoS mapping, allow each priority to map
* to a different queue number * to a different queue number
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment