Commit 422b6402 authored by Matthias Schiffer's avatar Matthias Schiffer Committed by David S. Miller

net: dsa: qca8k: add support for bridge port isolation

Remove a pair of ports from the port matrix when both ports have the
isolated flag set.
Signed-off-by: default avatarMatthias Schiffer <mschiffer@universe-factory.net>
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 412e1775
......@@ -618,6 +618,7 @@ static int qca8k_update_port_member(struct qca8k_priv *priv, int port,
const struct net_device *bridge_dev,
bool join)
{
bool isolated = !!(priv->port_isolated_map & BIT(port)), other_isolated;
struct dsa_port *dp = dsa_to_port(priv->ds, port), *other_dp;
u32 port_mask = BIT(dp->cpu_dp->index);
int i, ret;
......@@ -632,10 +633,12 @@ static int qca8k_update_port_member(struct qca8k_priv *priv, int port,
if (!dsa_port_offloads_bridge_dev(other_dp, bridge_dev))
continue;
other_isolated = !!(priv->port_isolated_map & BIT(i));
/* Add/remove this port to/from the portvlan mask of the other
* ports in the bridge
*/
if (join) {
if (join && !(isolated && other_isolated)) {
port_mask |= BIT(i);
ret = regmap_set_bits(priv->regmap,
QCA8K_PORT_LOOKUP_CTRL(i),
......@@ -661,7 +664,7 @@ int qca8k_port_pre_bridge_flags(struct dsa_switch *ds, int port,
struct switchdev_brport_flags flags,
struct netlink_ext_ack *extack)
{
if (flags.mask & ~BR_LEARNING)
if (flags.mask & ~(BR_LEARNING | BR_ISOLATED))
return -EINVAL;
return 0;
......@@ -671,6 +674,7 @@ int qca8k_port_bridge_flags(struct dsa_switch *ds, int port,
struct switchdev_brport_flags flags,
struct netlink_ext_ack *extack)
{
struct qca8k_priv *priv = ds->priv;
int ret;
if (flags.mask & BR_LEARNING) {
......@@ -680,6 +684,20 @@ int qca8k_port_bridge_flags(struct dsa_switch *ds, int port,
return ret;
}
if (flags.mask & BR_ISOLATED) {
struct dsa_port *dp = dsa_to_port(ds, port);
struct net_device *bridge_dev = dsa_port_bridge_dev_get(dp);
if (flags.val & BR_ISOLATED)
priv->port_isolated_map |= BIT(port);
else
priv->port_isolated_map &= ~BIT(port);
ret = qca8k_update_port_member(priv, port, bridge_dev, true);
if (ret)
return ret;
}
return 0;
}
......
......@@ -451,6 +451,7 @@ struct qca8k_priv {
* Bit 1: port enabled. Bit 0: port disabled.
*/
u8 port_enabled_map;
u8 port_isolated_map;
struct qca8k_ports_config ports_config;
struct regmap *regmap;
struct mii_bus *bus;
......
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