summaryrefslogtreecommitdiff
path: root/drivers/net/dsa/ocelot/felix.c
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2022-05-11 12:50:18 +0300
committerJakub Kicinski <kuba@kernel.org>2022-05-12 16:38:55 -0700
commitbacf93b0561937695e9c6c1dc1d8ed10ca80eb81 (patch)
treef6631572c4903afed0f1d13955c59ffc291b3c4d /drivers/net/dsa/ocelot/felix.c
parent72c3b0c7359a6f91dd03e08b839adccd9d4268a8 (diff)
downloadlwn-bacf93b0561937695e9c6c1dc1d8ed10ca80eb81.tar.gz
lwn-bacf93b0561937695e9c6c1dc1d8ed10ca80eb81.zip
net: dsa: remove port argument from ->change_tag_protocol()
DSA has not supported (and probably will not support in the future either) independent tagging protocols per CPU port. Different switch drivers have different requirements, some may need to replicate some settings for each CPU port, some may need to apply some settings on a single CPU port, while some may have to configure some global settings and then some per-CPU-port settings. In any case, the current model where DSA calls ->change_tag_protocol for each CPU port turns out to be impractical for drivers where there are global things to be done. For example, felix calls dsa_tag_8021q_register(), which makes no sense per CPU port, so it suppresses the second call. Let drivers deal with replication towards all CPU ports, and remove the CPU port argument from the function prototype. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Acked-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/dsa/ocelot/felix.c')
-rw-r--r--drivers/net/dsa/ocelot/felix.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 6b67ab4e05ab..0edec7c2b847 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -575,14 +575,13 @@ static void felix_del_tag_protocol(struct dsa_switch *ds, int cpu,
* tag_8021q setup can fail, the NPI setup can't. So either the change is made,
* or the restoration is guaranteed to work.
*/
-static int felix_change_tag_protocol(struct dsa_switch *ds, int cpu,
+static int felix_change_tag_protocol(struct dsa_switch *ds,
enum dsa_tag_protocol proto)
{
struct ocelot *ocelot = ds->priv;
struct felix *felix = ocelot_to_felix(ocelot);
enum dsa_tag_protocol old_proto = felix->tag_proto;
- bool cpu_port_active = false;
- struct dsa_port *dp;
+ struct dsa_port *cpu_dp;
int err;
if (proto != DSA_TAG_PROTO_SEVILLE &&
@@ -590,33 +589,17 @@ static int felix_change_tag_protocol(struct dsa_switch *ds, int cpu,
proto != DSA_TAG_PROTO_OCELOT_8021Q)
return -EPROTONOSUPPORT;
- /* We don't support multiple CPU ports, yet the DT blob may have
- * multiple CPU ports defined. The first CPU port is the active one,
- * the others are inactive. In this case, DSA will call
- * ->change_tag_protocol() multiple times, once per CPU port.
- * Since we implement the tagging protocol change towards "ocelot" or
- * "seville" as effectively initializing the NPI port, what we are
- * doing is effectively changing who the NPI port is to the last @cpu
- * argument passed, which is an unused DSA CPU port and not the one
- * that should actively pass traffic.
- * Suppress DSA's calls on CPU ports that are inactive.
- */
- dsa_switch_for_each_user_port(dp, ds) {
- if (dp->cpu_dp->index == cpu) {
- cpu_port_active = true;
- break;
- }
- }
-
- if (!cpu_port_active)
- return 0;
+ dsa_switch_for_each_cpu_port(cpu_dp, ds) {
+ felix_del_tag_protocol(ds, cpu_dp->index, old_proto);
- felix_del_tag_protocol(ds, cpu, old_proto);
+ err = felix_set_tag_protocol(ds, cpu_dp->index, proto);
+ if (err) {
+ felix_set_tag_protocol(ds, cpu_dp->index, old_proto);
+ return err;
+ }
- err = felix_set_tag_protocol(ds, cpu, proto);
- if (err) {
- felix_set_tag_protocol(ds, cpu, old_proto);
- return err;
+ /* Stop at first CPU port */
+ break;
}
felix->tag_proto = proto;