Commit 8d5f7954 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Jakub Kicinski

net: dsa: felix: break at first CPU port during init and teardown

The NXP LS1028A switch has two Ethernet ports towards the CPU, but only
one of them is capable of acting as an NPI port at a time (inject and
extract packets using DSA tags).

However, using the alternative ocelot-8021q tagging protocol, it should
be possible to use both CPU ports symmetrically, but for that we need to
mark both ports in the device tree as DSA masters.

In the process of doing that, it can be seen that traffic to/from the
network stack gets broken, and this is because the Felix driver iterates
through all DSA CPU ports and configures them as NPI ports. But since
there can only be a single NPI port, we effectively end up in a
situation where DSA thinks the default CPU port is the first one, but
the hardware port configured to be an NPI is the last one.

I would like to treat this as a bug, because if the updated device trees
are going to start circulating, it would be really good for existing
kernels to support them, too.

Fixes: adb3dccf ("net: dsa: felix: convert to the new .change_tag_protocol DSA API")
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 43ba33b4
...@@ -266,12 +266,12 @@ static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port) ...@@ -266,12 +266,12 @@ static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port)
*/ */
static int felix_setup_mmio_filtering(struct felix *felix) static int felix_setup_mmio_filtering(struct felix *felix)
{ {
unsigned long user_ports = 0, cpu_ports = 0; unsigned long user_ports = dsa_user_ports(felix->ds);
struct ocelot_vcap_filter *redirect_rule; struct ocelot_vcap_filter *redirect_rule;
struct ocelot_vcap_filter *tagging_rule; struct ocelot_vcap_filter *tagging_rule;
struct ocelot *ocelot = &felix->ocelot; struct ocelot *ocelot = &felix->ocelot;
struct dsa_switch *ds = felix->ds; struct dsa_switch *ds = felix->ds;
int port, ret; int cpu = -1, port, ret;
tagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL); tagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL);
if (!tagging_rule) if (!tagging_rule)
...@@ -284,12 +284,15 @@ static int felix_setup_mmio_filtering(struct felix *felix) ...@@ -284,12 +284,15 @@ static int felix_setup_mmio_filtering(struct felix *felix)
} }
for (port = 0; port < ocelot->num_phys_ports; port++) { for (port = 0; port < ocelot->num_phys_ports; port++) {
if (dsa_is_user_port(ds, port)) if (dsa_is_cpu_port(ds, port)) {
user_ports |= BIT(port); cpu = port;
if (dsa_is_cpu_port(ds, port)) break;
cpu_ports |= BIT(port); }
} }
if (cpu < 0)
return -EINVAL;
tagging_rule->key_type = OCELOT_VCAP_KEY_ETYPE; tagging_rule->key_type = OCELOT_VCAP_KEY_ETYPE;
*(__be16 *)tagging_rule->key.etype.etype.value = htons(ETH_P_1588); *(__be16 *)tagging_rule->key.etype.etype.value = htons(ETH_P_1588);
*(__be16 *)tagging_rule->key.etype.etype.mask = htons(0xffff); *(__be16 *)tagging_rule->key.etype.etype.mask = htons(0xffff);
...@@ -325,7 +328,7 @@ static int felix_setup_mmio_filtering(struct felix *felix) ...@@ -325,7 +328,7 @@ static int felix_setup_mmio_filtering(struct felix *felix)
* the CPU port module * the CPU port module
*/ */
redirect_rule->action.mask_mode = OCELOT_MASK_MODE_REDIRECT; redirect_rule->action.mask_mode = OCELOT_MASK_MODE_REDIRECT;
redirect_rule->action.port_mask = cpu_ports; redirect_rule->action.port_mask = BIT(cpu);
} else { } else {
/* Trap PTP packets only to the CPU port module (which is /* Trap PTP packets only to the CPU port module (which is
* redirected to the NPI port) * redirected to the NPI port)
...@@ -1235,6 +1238,7 @@ static int felix_setup(struct dsa_switch *ds) ...@@ -1235,6 +1238,7 @@ static int felix_setup(struct dsa_switch *ds)
* there's no real point in checking for errors. * there's no real point in checking for errors.
*/ */
felix_set_tag_protocol(ds, port, felix->tag_proto); felix_set_tag_protocol(ds, port, felix->tag_proto);
break;
} }
ds->mtu_enforcement_ingress = true; ds->mtu_enforcement_ingress = true;
...@@ -1275,6 +1279,7 @@ static void felix_teardown(struct dsa_switch *ds) ...@@ -1275,6 +1279,7 @@ static void felix_teardown(struct dsa_switch *ds)
continue; continue;
felix_del_tag_protocol(ds, port, felix->tag_proto); felix_del_tag_protocol(ds, port, felix->tag_proto);
break;
} }
for (port = 0; port < ocelot->num_phys_ports; port++) { for (port = 0; port < ocelot->num_phys_ports; port++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment