diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2019-09-12 23:28:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-09-16 03:06:12 -0400 |
commit | 53568438e381d680bc84f1fe1d3ed2ac8d7ae85c (patch) | |
tree | 17b2a65e21b80664799a2e34af26a3cd3969b2e7 | |
parent | aa2eaa8c272a3211dec07ce9c6c863a7e355c10e (diff) |
net: dsa: b53: Add support for port_egress_floods callback
Add support for configuring the per-port egress flooding control for
both Unicast and Multicast traffic.
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>
-rw-r--r-- | drivers/net/dsa/b53/b53_common.c | 33 | ||||
-rw-r--r-- | drivers/net/dsa/b53/b53_priv.h | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 7d328a5f0161..526ba2ab66f1 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c | |||
@@ -342,6 +342,13 @@ static void b53_set_forwarding(struct b53_device *dev, int enable) | |||
342 | b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, &mgmt); | 342 | b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, &mgmt); |
343 | mgmt |= B53_MII_DUMB_FWDG_EN; | 343 | mgmt |= B53_MII_DUMB_FWDG_EN; |
344 | b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt); | 344 | b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_CTRL, mgmt); |
345 | |||
346 | /* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether | ||
347 | * frames should be flooded or not. | ||
348 | */ | ||
349 | b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt); | ||
350 | mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN; | ||
351 | b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt); | ||
345 | } | 352 | } |
346 | 353 | ||
347 | static void b53_enable_vlan(struct b53_device *dev, bool enable, | 354 | static void b53_enable_vlan(struct b53_device *dev, bool enable, |
@@ -1753,6 +1760,31 @@ void b53_br_fast_age(struct dsa_switch *ds, int port) | |||
1753 | } | 1760 | } |
1754 | EXPORT_SYMBOL(b53_br_fast_age); | 1761 | EXPORT_SYMBOL(b53_br_fast_age); |
1755 | 1762 | ||
1763 | int b53_br_egress_floods(struct dsa_switch *ds, int port, | ||
1764 | bool unicast, bool multicast) | ||
1765 | { | ||
1766 | struct b53_device *dev = ds->priv; | ||
1767 | u16 uc, mc; | ||
1768 | |||
1769 | b53_read16(dev, B53_CTRL_PAGE, B53_UC_FWD_EN, &uc); | ||
1770 | if (unicast) | ||
1771 | uc |= BIT(port); | ||
1772 | else | ||
1773 | uc &= ~BIT(port); | ||
1774 | b53_write16(dev, B53_CTRL_PAGE, B53_UC_FWD_EN, uc); | ||
1775 | |||
1776 | b53_read16(dev, B53_CTRL_PAGE, B53_MC_FWD_EN, &mc); | ||
1777 | if (multicast) | ||
1778 | mc |= BIT(port); | ||
1779 | else | ||
1780 | mc &= ~BIT(port); | ||
1781 | b53_write16(dev, B53_CTRL_PAGE, B53_MC_FWD_EN, mc); | ||
1782 | |||
1783 | return 0; | ||
1784 | |||
1785 | } | ||
1786 | EXPORT_SYMBOL(b53_br_egress_floods); | ||
1787 | |||
1756 | static bool b53_possible_cpu_port(struct dsa_switch *ds, int port) | 1788 | static bool b53_possible_cpu_port(struct dsa_switch *ds, int port) |
1757 | { | 1789 | { |
1758 | /* Broadcom switches will accept enabling Broadcom tags on the | 1790 | /* Broadcom switches will accept enabling Broadcom tags on the |
@@ -1953,6 +1985,7 @@ static const struct dsa_switch_ops b53_switch_ops = { | |||
1953 | .port_bridge_leave = b53_br_leave, | 1985 | .port_bridge_leave = b53_br_leave, |
1954 | .port_stp_state_set = b53_br_set_stp_state, | 1986 | .port_stp_state_set = b53_br_set_stp_state, |
1955 | .port_fast_age = b53_br_fast_age, | 1987 | .port_fast_age = b53_br_fast_age, |
1988 | .port_egress_floods = b53_br_egress_floods, | ||
1956 | .port_vlan_filtering = b53_vlan_filtering, | 1989 | .port_vlan_filtering = b53_vlan_filtering, |
1957 | .port_vlan_prepare = b53_vlan_prepare, | 1990 | .port_vlan_prepare = b53_vlan_prepare, |
1958 | .port_vlan_add = b53_vlan_add, | 1991 | .port_vlan_add = b53_vlan_add, |
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h index f25bc80c4ffc..a7dd8acc281b 100644 --- a/drivers/net/dsa/b53/b53_priv.h +++ b/drivers/net/dsa/b53/b53_priv.h | |||
@@ -319,6 +319,8 @@ int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge); | |||
319 | void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge); | 319 | void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge); |
320 | void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state); | 320 | void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state); |
321 | void b53_br_fast_age(struct dsa_switch *ds, int port); | 321 | void b53_br_fast_age(struct dsa_switch *ds, int port); |
322 | int b53_br_egress_floods(struct dsa_switch *ds, int port, | ||
323 | bool unicast, bool multicast); | ||
322 | void b53_port_event(struct dsa_switch *ds, int port); | 324 | void b53_port_event(struct dsa_switch *ds, int port); |
323 | void b53_phylink_validate(struct dsa_switch *ds, int port, | 325 | void b53_phylink_validate(struct dsa_switch *ds, int port, |
324 | unsigned long *supported, | 326 | unsigned long *supported, |