* [PATCH net-next] net: dsa: felix: Fix CPU port assignment when not last port
@ 2019-11-18 18:16 Vladimir Oltean
2019-11-19 23:22 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Oltean @ 2019-11-18 18:16 UTC (permalink / raw)
To: davem
Cc: andrew, f.fainelli, vivien.didelot, claudiu.manoil,
alexandru.marginean, xiaoliang.yang_1, yangbo.lu, netdev,
Vladimir Oltean
From: Vladimir Oltean <vladimir.oltean@nxp.com>
On the NXP LS1028A, there are 2 Ethernet links between the Felix switch
and the ENETC:
- eno2 <-> swp4, at 2.5G
- eno3 <-> swp5, at 1G
Only one of the above Ethernet port pairs can act as a DSA link for
tagging.
When adding initial support for the driver, it was tested only on the 1G
eno3 <-> swp5 interface, due to the necessity of using PHYLIB initially
(which treats fixed-link interfaces as emulated C22 PHYs, so it doesn't
support fixed-link speeds higher than 1G).
After making PHYLINK work, it appears that swp4 still can't act as CPU
port. So it looks like ocelot_set_cpu_port was being called for swp4,
but then it was called again for swp5, overwriting the CPU port assigned
in the DT.
It appears that when you call dsa_upstream_port for a port that is not
defined in the device tree (such as swp5 when using swp4 as CPU port),
its dp->cpu_dp pointer is not initialized by dsa_tree_setup_default_cpu,
and this trips up the following condition in dsa_upstream_port:
if (!cpu_dp)
return port;
So the moral of the story is: don't call dsa_upstream_port for a port
that is not defined in the device tree, and therefore its dsa_port
structure is not completely initialized (ds->num_ports is still 6).
Fixes: 56051948773e ("net: dsa: ocelot: add driver for Felix switch family")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/dsa/ocelot/felix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index d73c38c6cbcf..89d28f80b99d 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -314,7 +314,7 @@ static int felix_setup(struct dsa_switch *ds)
for (port = 0; port < ds->num_ports; port++) {
ocelot_init_port(ocelot, port);
- if (port == dsa_upstream_port(ds, port))
+ if (dsa_is_cpu_port(ds, port))
ocelot_set_cpu_port(ocelot, port,
OCELOT_TAG_PREFIX_NONE,
OCELOT_TAG_PREFIX_LONG);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: dsa: felix: Fix CPU port assignment when not last port
2019-11-18 18:16 [PATCH net-next] net: dsa: felix: Fix CPU port assignment when not last port Vladimir Oltean
@ 2019-11-19 23:22 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-11-19 23:22 UTC (permalink / raw)
To: olteanv
Cc: andrew, f.fainelli, vivien.didelot, claudiu.manoil,
alexandru.marginean, xiaoliang.yang_1, yangbo.lu, netdev,
vladimir.oltean
From: Vladimir Oltean <olteanv@gmail.com>
Date: Mon, 18 Nov 2019 20:16:57 +0200
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> On the NXP LS1028A, there are 2 Ethernet links between the Felix switch
> and the ENETC:
> - eno2 <-> swp4, at 2.5G
> - eno3 <-> swp5, at 1G
>
> Only one of the above Ethernet port pairs can act as a DSA link for
> tagging.
>
> When adding initial support for the driver, it was tested only on the 1G
> eno3 <-> swp5 interface, due to the necessity of using PHYLIB initially
> (which treats fixed-link interfaces as emulated C22 PHYs, so it doesn't
> support fixed-link speeds higher than 1G).
>
> After making PHYLINK work, it appears that swp4 still can't act as CPU
> port. So it looks like ocelot_set_cpu_port was being called for swp4,
> but then it was called again for swp5, overwriting the CPU port assigned
> in the DT.
>
> It appears that when you call dsa_upstream_port for a port that is not
> defined in the device tree (such as swp5 when using swp4 as CPU port),
> its dp->cpu_dp pointer is not initialized by dsa_tree_setup_default_cpu,
> and this trips up the following condition in dsa_upstream_port:
>
> if (!cpu_dp)
> return port;
>
> So the moral of the story is: don't call dsa_upstream_port for a port
> that is not defined in the device tree, and therefore its dsa_port
> structure is not completely initialized (ds->num_ports is still 6).
>
> Fixes: 56051948773e ("net: dsa: ocelot: add driver for Felix switch family")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-19 23:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 18:16 [PATCH net-next] net: dsa: felix: Fix CPU port assignment when not last port Vladimir Oltean
2019-11-19 23:22 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).