Skip to content

Commit 5126ec7

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: add FDB fast ageing support
Delete the dynamically learned FDB entries when the STP state changes and when address learning is disabled. On sja1105 there is no shorthand SPI command for this, so we need to walk through the entire FDB to delete. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5313a37 commit 5126ec7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,46 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
17941794
return 0;
17951795
}
17961796

1797+
static void sja1105_fast_age(struct dsa_switch *ds, int port)
1798+
{
1799+
struct sja1105_private *priv = ds->priv;
1800+
int i;
1801+
1802+
for (i = 0; i < SJA1105_MAX_L2_LOOKUP_COUNT; i++) {
1803+
struct sja1105_l2_lookup_entry l2_lookup = {0};
1804+
u8 macaddr[ETH_ALEN];
1805+
int rc;
1806+
1807+
rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP,
1808+
i, &l2_lookup);
1809+
/* No fdb entry at i, not an issue */
1810+
if (rc == -ENOENT)
1811+
continue;
1812+
if (rc) {
1813+
dev_err(ds->dev, "Failed to read FDB: %pe\n",
1814+
ERR_PTR(rc));
1815+
return;
1816+
}
1817+
1818+
if (!(l2_lookup.destports & BIT(port)))
1819+
continue;
1820+
1821+
/* Don't delete static FDB entries */
1822+
if (l2_lookup.lockeds)
1823+
continue;
1824+
1825+
u64_to_ether_addr(l2_lookup.macaddr, macaddr);
1826+
1827+
rc = sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid);
1828+
if (rc) {
1829+
dev_err(ds->dev,
1830+
"Failed to delete FDB entry %pM vid %lld: %pe\n",
1831+
macaddr, l2_lookup.vlanid, ERR_PTR(rc));
1832+
return;
1833+
}
1834+
}
1835+
}
1836+
17971837
static int sja1105_mdb_add(struct dsa_switch *ds, int port,
17981838
const struct switchdev_obj_port_mdb *mdb)
17991839
{
@@ -3036,6 +3076,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = {
30363076
.port_fdb_dump = sja1105_fdb_dump,
30373077
.port_fdb_add = sja1105_fdb_add,
30383078
.port_fdb_del = sja1105_fdb_del,
3079+
.port_fast_age = sja1105_fast_age,
30393080
.port_bridge_join = sja1105_bridge_join,
30403081
.port_bridge_leave = sja1105_bridge_leave,
30413082
.port_pre_bridge_flags = sja1105_port_pre_bridge_flags,

0 commit comments

Comments
 (0)