Commit 7edc58d6 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: dsa: b53: Turn on Broadcom tags

Enable Broadcom tags for b53 devices, except 5325 and 5365 which use a
different Broadcom tag format not yet supported by net/dsa/tag_brcm.c.

We also make sure that we can turn on Broadcom tags on a CPU port number
that is capable of that: 5, 7 or 8.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c499696e
menuconfig B53 menuconfig B53
tristate "Broadcom BCM53xx managed switch support" tristate "Broadcom BCM53xx managed switch support"
depends on NET_DSA depends on NET_DSA
select NET_DSA_TAG_BRCM
help help
This driver adds support for Broadcom managed switch chips. It supports This driver adds support for Broadcom managed switch chips. It supports
BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX
......
...@@ -325,7 +325,6 @@ static void b53_get_vlan_entry(struct b53_device *dev, u16 vid, ...@@ -325,7 +325,6 @@ static void b53_get_vlan_entry(struct b53_device *dev, u16 vid,
static void b53_set_forwarding(struct b53_device *dev, int enable) static void b53_set_forwarding(struct b53_device *dev, int enable)
{ {
struct dsa_switch *ds = dev->ds;
u8 mgmt; u8 mgmt;
b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt); b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &mgmt);
...@@ -337,14 +336,11 @@ static void b53_set_forwarding(struct b53_device *dev, int enable) ...@@ -337,14 +336,11 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt); b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, mgmt);
/* Include IMP port in dumb forwarding mode when no tagging protocol is /* Include IMP port in dumb forwarding mode
* set
*/ */
if (ds->ops->get_tag_protocol(ds) == DSA_TAG_PROTO_NONE) { b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, &mgmt);
b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, &mgmt); mgmt |= B53_MII_DUMB_FWDG_EN;
mgmt |= B53_MII_DUMB_FWDG_EN; b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt);
}
} }
static void b53_enable_vlan(struct b53_device *dev, bool enable) static void b53_enable_vlan(struct b53_device *dev, bool enable)
...@@ -612,6 +608,8 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port) ...@@ -612,6 +608,8 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)
PORT_CTRL_RX_MCST_EN | PORT_CTRL_RX_MCST_EN |
PORT_CTRL_RX_UCST_EN; PORT_CTRL_RX_UCST_EN;
b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), port_ctrl); b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), port_ctrl);
b53_brcm_hdr_setup(dev->ds, port);
} }
static void b53_enable_mib(struct b53_device *dev) static void b53_enable_mib(struct b53_device *dev)
...@@ -1480,9 +1478,41 @@ void b53_br_fast_age(struct dsa_switch *ds, int port) ...@@ -1480,9 +1478,41 @@ void b53_br_fast_age(struct dsa_switch *ds, int port)
} }
EXPORT_SYMBOL(b53_br_fast_age); EXPORT_SYMBOL(b53_br_fast_age);
static bool b53_can_enable_brcm_tags(struct dsa_switch *ds)
{
unsigned int brcm_tag_mask;
unsigned int i;
/* Broadcom switches will accept enabling Broadcom tags on the
* following ports: 5, 7 and 8, any other port is not supported
*/
brcm_tag_mask = BIT(B53_CPU_PORT_25) | BIT(7) | BIT(B53_CPU_PORT);
for (i = 0; i < ds->num_ports; i++) {
if (dsa_is_cpu_port(ds, i)) {
if (!(BIT(i) & brcm_tag_mask)) {
dev_warn(ds->dev,
"Port %d is not Broadcom tag capable\n",
i);
return false;
}
}
}
return true;
}
static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds) static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds)
{ {
return DSA_TAG_PROTO_NONE; struct b53_device *dev = ds->priv;
/* Older models support a different tag format that we do not
* support in net/dsa/tag_brcm.c yet.
*/
if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds))
return DSA_TAG_PROTO_NONE;
else
return DSA_TAG_PROTO_BRCM;
} }
int b53_mirror_add(struct dsa_switch *ds, int port, int b53_mirror_add(struct dsa_switch *ds, int port,
......
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