Commit 39f32101 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: don't fast age standalone ports

DSA drives the procedure to flush dynamic FDB entries from a port based
on the change of STP state: whenever we go from a state where address
learning is enabled (LEARNING, FORWARDING) to a state where it isn't
(LISTENING, BLOCKING, DISABLED), we need to flush the existing dynamic
entries.

However, there are cases when this is not needed. Internally, when a
DSA switch interface is not under a bridge, DSA still keeps it in the
"FORWARDING" STP state. And when that interface joins a bridge, the
bridge will meticulously iterate that port through all STP states,
starting with BLOCKING and ending with FORWARDING. Because there is a
state transition from the standalone version of FORWARDING into the
temporary BLOCKING bridge port state, DSA calls the fast age procedure.

Since commit 5e38c158 ("net: dsa: configure better brport flags when
ports leave the bridge"), DSA asks standalone ports to disable address
learning. Therefore, there can be no dynamic FDB entries on a standalone
port. Therefore, it does not make sense to flush dynamic FDB entries on
one.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f9be84db
...@@ -199,7 +199,7 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev, ...@@ -199,7 +199,7 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
/* port.c */ /* port.c */
void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp, void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp,
const struct dsa_device_ops *tag_ops); const struct dsa_device_ops *tag_ops);
int dsa_port_set_state(struct dsa_port *dp, u8 state); int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age);
int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy); int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy);
int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy); int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy);
void dsa_port_disable_rt(struct dsa_port *dp); void dsa_port_disable_rt(struct dsa_port *dp);
......
...@@ -30,7 +30,7 @@ static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v) ...@@ -30,7 +30,7 @@ static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v)
return dsa_tree_notify(dp->ds->dst, e, v); return dsa_tree_notify(dp->ds->dst, e, v);
} }
int dsa_port_set_state(struct dsa_port *dp, u8 state) int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age)
{ {
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
int port = dp->index; int port = dp->index;
...@@ -40,10 +40,13 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state) ...@@ -40,10 +40,13 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state)
ds->ops->port_stp_state_set(ds, port, state); ds->ops->port_stp_state_set(ds, port, state);
if (ds->ops->port_fast_age) { if (do_fast_age && ds->ops->port_fast_age) {
/* Fast age FDB entries or flush appropriate forwarding database /* Fast age FDB entries or flush appropriate forwarding database
* for the given port, if we are moving it from Learning or * for the given port, if we are moving it from Learning or
* Forwarding state, to Disabled or Blocking or Listening state. * Forwarding state, to Disabled or Blocking or Listening state.
* Ports that were standalone before the STP state change don't
* need to fast age the FDB, since address learning is off in
* standalone mode.
*/ */
if ((dp->stp_state == BR_STATE_LEARNING || if ((dp->stp_state == BR_STATE_LEARNING ||
...@@ -59,11 +62,12 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state) ...@@ -59,11 +62,12 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state)
return 0; return 0;
} }
static void dsa_port_set_state_now(struct dsa_port *dp, u8 state) static void dsa_port_set_state_now(struct dsa_port *dp, u8 state,
bool do_fast_age)
{ {
int err; int err;
err = dsa_port_set_state(dp, state); err = dsa_port_set_state(dp, state, do_fast_age);
if (err) if (err)
pr_err("DSA: failed to set STP state %u (%d)\n", state, err); pr_err("DSA: failed to set STP state %u (%d)\n", state, err);
} }
...@@ -81,7 +85,7 @@ int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy) ...@@ -81,7 +85,7 @@ int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy)
} }
if (!dp->bridge_dev) if (!dp->bridge_dev)
dsa_port_set_state_now(dp, BR_STATE_FORWARDING); dsa_port_set_state_now(dp, BR_STATE_FORWARDING, false);
if (dp->pl) if (dp->pl)
phylink_start(dp->pl); phylink_start(dp->pl);
...@@ -109,7 +113,7 @@ void dsa_port_disable_rt(struct dsa_port *dp) ...@@ -109,7 +113,7 @@ void dsa_port_disable_rt(struct dsa_port *dp)
phylink_stop(dp->pl); phylink_stop(dp->pl);
if (!dp->bridge_dev) if (!dp->bridge_dev)
dsa_port_set_state_now(dp, BR_STATE_DISABLED); dsa_port_set_state_now(dp, BR_STATE_DISABLED, false);
if (ds->ops->port_disable) if (ds->ops->port_disable)
ds->ops->port_disable(ds, port); ds->ops->port_disable(ds, port);
...@@ -178,7 +182,7 @@ static int dsa_port_switchdev_sync_attrs(struct dsa_port *dp, ...@@ -178,7 +182,7 @@ static int dsa_port_switchdev_sync_attrs(struct dsa_port *dp,
if (err) if (err)
return err; return err;
err = dsa_port_set_state(dp, br_port_get_stp_state(brport_dev)); err = dsa_port_set_state(dp, br_port_get_stp_state(brport_dev), false);
if (err && err != -EOPNOTSUPP) if (err && err != -EOPNOTSUPP)
return err; return err;
...@@ -211,7 +215,7 @@ static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp) ...@@ -211,7 +215,7 @@ static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp)
/* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer, /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
* so allow it to be in BR_STATE_FORWARDING to be kept functional * so allow it to be in BR_STATE_FORWARDING to be kept functional
*/ */
dsa_port_set_state_now(dp, BR_STATE_FORWARDING); dsa_port_set_state_now(dp, BR_STATE_FORWARDING, true);
/* VLAN filtering is handled by dsa_switch_bridge_leave */ /* VLAN filtering is handled by dsa_switch_bridge_leave */
......
...@@ -286,7 +286,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ...@@ -286,7 +286,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx,
if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev)) if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ret = dsa_port_set_state(dp, attr->u.stp_state); ret = dsa_port_set_state(dp, attr->u.stp_state, true);
break; break;
case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
if (!dsa_port_offloads_bridge(dp, attr->orig_dev)) if (!dsa_port_offloads_bridge(dp, attr->orig_dev))
......
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