Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: add port fast ageing

Today the DSA drivers are in charge of flushing the MAC addresses
associated to a port when its STP state changes from Learning or
Forwarding, to Disabled or Blocking or Listening.

This makes the drivers more complex and hides the generic switch logic.
Introduce a new optional port_fast_age operation to dsa_switch_ops, to
move this logic to the DSA layer and keep drivers simple.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vivien Didelot and committed by
David S. Miller
732f794c 4acfee81

+20
+2
include/net/dsa.h
··· 143 143 struct net_device *netdev; 144 144 struct device_node *dn; 145 145 unsigned int ageing_time; 146 + u8 stp_state; 146 147 }; 147 148 148 149 struct dsa_switch { ··· 340 339 void (*port_bridge_leave)(struct dsa_switch *ds, int port); 341 340 void (*port_stp_state_set)(struct dsa_switch *ds, int port, 342 341 u8 state); 342 + void (*port_fast_age)(struct dsa_switch *ds, int port); 343 343 344 344 /* 345 345 * VLAN support
+18
net/dsa/slave.c
··· 71 71 72 72 static void dsa_port_set_stp_state(struct dsa_switch *ds, int port, u8 state) 73 73 { 74 + struct dsa_port *dp = &ds->ports[port]; 75 + 74 76 if (ds->ops->port_stp_state_set) 75 77 ds->ops->port_stp_state_set(ds, port, state); 78 + 79 + if (ds->ops->port_fast_age) { 80 + /* Fast age FDB entries or flush appropriate forwarding database 81 + * for the given port, if we are moving it from Learning or 82 + * Forwarding state, to Disabled or Blocking or Listening state. 83 + */ 84 + 85 + if ((dp->stp_state == BR_STATE_LEARNING || 86 + dp->stp_state == BR_STATE_FORWARDING) && 87 + (state == BR_STATE_DISABLED || 88 + state == BR_STATE_BLOCKING || 89 + state == BR_STATE_LISTENING)) 90 + ds->ops->port_fast_age(ds, port); 91 + } 92 + 93 + dp->stp_state = state; 76 94 } 77 95 78 96 static int dsa_slave_open(struct net_device *dev)