net: dsa: sja1105: overwrite dynamic FDB entries with static ones in .port_fdb_add
authorVladimir Oltean <vladimir.oltean@nxp.com>
Fri, 30 Jul 2021 17:18:11 +0000 (20:18 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Aug 2021 13:28:28 +0000 (14:28 +0100)
commite11e865bf84e3c6ea91563ff3e858cfe0e184bd2
tree6baa7a6f0dc43172c360e3d2a778de118864d7e6
parentcb81698fddbcc9a3ee75857e99dfc29caa96135b
net: dsa: sja1105: overwrite dynamic FDB entries with static ones in .port_fdb_add

The SJA1105 switch family leaves it up to software to decide where
within the FDB to install a static entry, and to concatenate destination
ports for already existing entries (the FDB is also used for multicast
entries), it is not as simple as just saying "please add this entry".

This means we first need to search for an existing FDB entry before
adding a new one. The driver currently manages to fool itself into
thinking that if an FDB entry already exists, there is nothing to be
done. But that FDB entry might be dynamically learned, case in which it
should be replaced with a static entry, but instead it is left alone.

This patch checks the LOCKEDS ("locked/static") bit from found FDB
entries, and lets the code "goto skip_finding_an_index;" if the FDB
entry was not static. So we also need to move the place where we set
LOCKEDS = true, to cover the new case where a dynamic FDB entry existed
but was dynamic.

Fixes: 291d1e72b756 ("net: dsa: sja1105: Add support for FDB and MDB management")
Fixes: 1da73821343c ("net: dsa: sja1105: Add FDB operations for P/Q/R/S series")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_main.c