Skip to content

Commit 749efcb

Browse files
viviendavem330
authored andcommitted
net: dsa: mv88e6xxx: implement DSA port fast ageing
Now that the DSA layer handles port fast ageing on correct STP change, simplify _mv88e6xxx_port_state and implement mv88e6xxx_port_fast_age. Signed-off-by: Vivien Didelot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 597698f commit 749efcb

File tree

1 file changed

+23
-22
lines changed
  • drivers/net/dsa/mv88e6xxx

1 file changed

+23
-22
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,31 +1133,18 @@ static int _mv88e6xxx_port_state(struct mv88e6xxx_chip *chip, int port,
11331133

11341134
oldstate = reg & PORT_CONTROL_STATE_MASK;
11351135

1136-
if (oldstate != state) {
1137-
/* Flush forwarding database if we're moving a port
1138-
* from Learning or Forwarding state to Disabled or
1139-
* Blocking or Listening state.
1140-
*/
1141-
if ((oldstate == PORT_CONTROL_STATE_LEARNING ||
1142-
oldstate == PORT_CONTROL_STATE_FORWARDING) &&
1143-
(state == PORT_CONTROL_STATE_DISABLED ||
1144-
state == PORT_CONTROL_STATE_BLOCKING)) {
1145-
err = _mv88e6xxx_atu_remove(chip, 0, port, false);
1146-
if (err)
1147-
return err;
1148-
}
1136+
reg &= ~PORT_CONTROL_STATE_MASK;
1137+
reg |= state;
11491138

1150-
reg = (reg & ~PORT_CONTROL_STATE_MASK) | state;
1151-
err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg);
1152-
if (err)
1153-
return err;
1139+
err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg);
1140+
if (err)
1141+
return err;
11541142

1155-
netdev_dbg(ds->ports[port].netdev, "PortState %s (was %s)\n",
1156-
mv88e6xxx_port_state_names[state],
1157-
mv88e6xxx_port_state_names[oldstate]);
1158-
}
1143+
netdev_dbg(ds->ports[port].netdev, "PortState %s (was %s)\n",
1144+
mv88e6xxx_port_state_names[state],
1145+
mv88e6xxx_port_state_names[oldstate]);
11591146

1160-
return err;
1147+
return 0;
11611148
}
11621149

11631150
static int _mv88e6xxx_port_based_vlan_map(struct mv88e6xxx_chip *chip, int port)
@@ -1232,6 +1219,19 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
12321219
mv88e6xxx_port_state_names[stp_state]);
12331220
}
12341221

1222+
static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1223+
{
1224+
struct mv88e6xxx_chip *chip = ds->priv;
1225+
int err;
1226+
1227+
mutex_lock(&chip->reg_lock);
1228+
err = _mv88e6xxx_atu_remove(chip, 0, port, false);
1229+
mutex_unlock(&chip->reg_lock);
1230+
1231+
if (err)
1232+
netdev_err(ds->ports[port].netdev, "failed to flush ATU\n");
1233+
}
1234+
12351235
static int _mv88e6xxx_port_pvid(struct mv88e6xxx_chip *chip, int port,
12361236
u16 *new, u16 *old)
12371237
{
@@ -3684,6 +3684,7 @@ static struct dsa_switch_ops mv88e6xxx_switch_ops = {
36843684
.port_bridge_join = mv88e6xxx_port_bridge_join,
36853685
.port_bridge_leave = mv88e6xxx_port_bridge_leave,
36863686
.port_stp_state_set = mv88e6xxx_port_stp_state_set,
3687+
.port_fast_age = mv88e6xxx_port_fast_age,
36873688
.port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
36883689
.port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
36893690
.port_vlan_add = mv88e6xxx_port_vlan_add,

0 commit comments

Comments
 (0)