diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2022-05-05 19:22:11 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-05-07 07:00:12 +0300 |
commit | a51c1c3f3218c74c07fed55ea2ad5b18c374dc25 (patch) | |
tree | abe8f7064339085238f8a103562260fda933af96 /drivers/net/dsa/ocelot | |
parent | 2c110abc46168c3a8cc9f855c986a55650c777dd (diff) | |
download | linux-a51c1c3f3218c74c07fed55ea2ad5b18c374dc25.tar.xz |
net: dsa: felix: stop migrating FDBs back and forth on tag proto change
I just realized we don't need to migrate the host-filtered FDB entries
when the tagging protocol changes from "ocelot" to "ocelot-8021q".
Host-filtered addresses are learned towards the PGID_CPU "multicast"
port group, reserved by software, which contains BIT(ocelot->num_phys_ports).
That is the "special" port entry in the analyzer block for the CPU port
module.
In "ocelot" mode, the CPU port module's packets are redirected to the
NPI port.
In "ocelot-8021q" mode, felix_8021q_cpu_port_init() does something funny
anyway, and changes PGID_CPU to stop pointing at the CPU port module and
start pointing at the physical port where the DSA master is attached.
The fact that we can alter the destination of packets learned towards
PGID_CPU without altering the MAC table entries themselves means that it
is pointless to walk through the FDB entries, forget that they were
learned towards PGID_CPU, and re-learn them towards the "unicast" PGID
associated with the physical port connected to the DSA master. We can
let the PGID_CPU value change simply alter the destination of the
host-filtered unicast packets in one fell swoop.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/dsa/ocelot')
-rw-r--r-- | drivers/net/dsa/ocelot/felix.c | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 8abe48ae8c3a..6443cd573040 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -42,22 +42,6 @@ static struct net_device *felix_classify_db(struct dsa_db db) } } -/* We are called before felix_npi_port_init(), so ocelot->npi is -1. */ -static int felix_migrate_fdbs_to_npi_port(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid, - struct dsa_db db) -{ - struct net_device *bridge_dev = felix_classify_db(db); - struct ocelot *ocelot = ds->priv; - int err; - - err = ocelot_fdb_del(ocelot, port, addr, vid, bridge_dev); - if (err) - return err; - - return ocelot_fdb_add(ocelot, PGID_CPU, addr, vid, bridge_dev); -} - static int felix_migrate_mdbs_to_npi_port(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) @@ -116,26 +100,6 @@ felix_migrate_flood_to_tag_8021q_port(struct dsa_switch *ds, int port) felix_migrate_pgid_bit(ds, ocelot->num_phys_ports, port, PGID_BC); } -/* ocelot->npi was already set to -1 by felix_npi_port_deinit, so - * ocelot_fdb_add() will not redirect FDB entries towards the - * CPU port module here, which is what we want. - */ -static int -felix_migrate_fdbs_to_tag_8021q_port(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid, - struct dsa_db db) -{ - struct net_device *bridge_dev = felix_classify_db(db); - struct ocelot *ocelot = ds->priv; - int err; - - err = ocelot_fdb_del(ocelot, PGID_CPU, addr, vid, bridge_dev); - if (err) - return err; - - return ocelot_fdb_add(ocelot, port, addr, vid, bridge_dev); -} - static int felix_migrate_mdbs_to_tag_8021q_port(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, @@ -486,13 +450,9 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu) if (err) return err; - err = dsa_port_walk_fdbs(ds, cpu, felix_migrate_fdbs_to_tag_8021q_port); - if (err) - goto out_tag_8021q_unregister; - err = dsa_port_walk_mdbs(ds, cpu, felix_migrate_mdbs_to_tag_8021q_port); if (err) - goto out_migrate_fdbs; + goto out_tag_8021q_unregister; felix_migrate_flood_to_tag_8021q_port(ds, cpu); @@ -514,8 +474,6 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu) out_migrate_flood: felix_migrate_flood_to_npi_port(ds, cpu); dsa_port_walk_mdbs(ds, cpu, felix_migrate_mdbs_to_npi_port); -out_migrate_fdbs: - dsa_port_walk_fdbs(ds, cpu, felix_migrate_fdbs_to_npi_port); out_tag_8021q_unregister: dsa_tag_8021q_unregister(ds); return err; @@ -595,24 +553,15 @@ static int felix_setup_tag_npi(struct dsa_switch *ds, int cpu) struct ocelot *ocelot = ds->priv; int err; - err = dsa_port_walk_fdbs(ds, cpu, felix_migrate_fdbs_to_npi_port); - if (err) - return err; - err = dsa_port_walk_mdbs(ds, cpu, felix_migrate_mdbs_to_npi_port); if (err) - goto out_migrate_fdbs; + return err; felix_migrate_flood_to_npi_port(ds, cpu); felix_npi_port_init(ocelot, cpu); return 0; - -out_migrate_fdbs: - dsa_port_walk_fdbs(ds, cpu, felix_migrate_fdbs_to_tag_8021q_port); - - return err; } static void felix_teardown_tag_npi(struct dsa_switch *ds, int cpu) |