From: Vivien Didelot <hidden> Date: 2017-12-05 20:34:21
An upstream port is a local switch port used to reach a CPU port.
DSA still considers a unique CPU port in the whole switch fabric and
thus return a unique upstream port for a given switch. This is wrong in
a multiple CPU ports environment.
We are now switching to using the dedicated CPU port assigned to each
port in order to get rid of the deprecated unique tree CPU port.
This patchset makes the dsa_upstream_port() helper take a port argument
and goes one step closer complete support for multiple CPU ports.
Changes in v2:
- reverse-christmas-tree-fy variables
Vivien Didelot (5):
net: dsa: mv88e6xxx: egress floods all DSA ports
net: dsa: mv88e6xxx: helper to setup upstream port
net: dsa: mv88e6xxx: setup global upstream port
net: dsa: assign a CPU port to DSA port
net: dsa: return per-port upstream port
drivers/net/dsa/mv88e6xxx/chip.c | 60 ++++++++++++++++++++++++++--------------
include/net/dsa.h | 9 ++++--
net/dsa/dsa2.c | 2 +-
3 files changed, 46 insertions(+), 25 deletions(-)
--
2.15.1
From: Vivien Didelot <hidden> Date: 2017-12-05 20:34:25
DSA ports also need to have a dedicated CPU port assigned to them,
because they need to know where to egress frames targeting the CPU,
e.g. To_Cpu frames received on a Marvell Tag port.
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/dsa2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Vivien Didelot <hidden> Date: 2017-12-05 20:34:27
The current dsa_upstream_port() helper still assumes a unique CPU port
in the whole switch fabric. This is becoming wrong, as every port in the
fabric has its dedicated CPU port, thus every port has an upstream port.
Add a port argument to the dsa_upstream_port() helper and fetch its CPU
port instead of the deprecated unique fabric CPU port. A CPU or unused
port has no dedicated CPU port, so return itself in this case.
At the same time, change the return value from u8 to unsigned int since
there is no need to limit the size here.
Signed-off-by: Vivien Didelot <redacted>
---
drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
include/net/dsa.h | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
@@ -307,10 +307,13 @@ static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device,}/* Return the local port used to reach the dedicated CPU port */-staticinlineu8dsa_upstream_port(structdsa_switch*ds)+staticinlineunsignedintdsa_upstream_port(structdsa_switch*ds,intport){-structdsa_switch_tree*dst=ds->dst;-structdsa_port*cpu_dp=dst->cpu_dp;+conststructdsa_port*dp=dsa_to_port(ds,port);+conststructdsa_port*cpu_dp=dp->cpu_dp;++if(!cpu_dp)+returnport;returndsa_towards_port(ds,cpu_dp->ds->index,cpu_dp->index);}
From: Vivien Didelot <hidden> Date: 2017-12-05 20:34:28
The mv88e6xxx driver currently assumes a single CPU port in the fabric
and thus floods frames with unknown DA on a single DSA port, the one
that is one hop closer to the CPU port.
With multiple CPU ports in mind, this isn't true anymore because CPU
ports could be found behind both DSA ports of a device in-between
others.
For example in a A <-> B <-> C fabric, both A and C having CPU ports,
device B will have to flood such frame to its two DSA ports.
This patch considers both CPU and DSA ports of a device as upstream
ports, where to flood frames with unknown DA addresses.
Signed-off-by: Vivien Didelot <redacted>
---
drivers/net/dsa/mv88e6xxx/chip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -1723,9 +1723,11 @@ static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)staticintmv88e6xxx_setup_egress_floods(structmv88e6xxx_chip*chip,intport){-boolflood=port==dsa_upstream_port(chip->ds);+structdsa_switch*ds=chip->ds;+boolflood;/* Upstream ports flood frames with unknown unicast or multicast DA */+flood=dsa_is_cpu_port(ds,port)||dsa_is_dsa_port(ds,port);if(chip->info->ops->port_set_egress_floods)returnchip->info->ops->port_set_egress_floods(chip,port,flood,flood);
From: Vivien Didelot <hidden> Date: 2017-12-05 20:35:26
Move the setup of the global upstream port within the
mv88e6xxx_setup_upstream_port function.
Signed-off-by: Vivien Didelot <redacted>
---
drivers/net/dsa/mv88e6xxx/chip.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
@@ -1758,6 +1758,22 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)returnerr;}+if(port==upstream_port){+if(chip->info->ops->set_cpu_port){+err=chip->info->ops->set_cpu_port(chip,+upstream_port);+if(err)+returnerr;+}++if(chip->info->ops->set_egress_port){+err=chip->info->ops->set_egress_port(chip,+upstream_port);+if(err)+returnerr;+}+}+return0;}
@@ -1959,21 +1975,8 @@ static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,staticintmv88e6xxx_g1_setup(structmv88e6xxx_chip*chip){structdsa_switch*ds=chip->ds;-u32upstream_port=dsa_upstream_port(ds);interr;-if(chip->info->ops->set_cpu_port){-err=chip->info->ops->set_cpu_port(chip,upstream_port);-if(err)-returnerr;-}--if(chip->info->ops->set_egress_port){-err=chip->info->ops->set_egress_port(chip,upstream_port);-if(err)-returnerr;-}-/* Disable remote management, and set the switch's DSA device number. */err=mv88e6xxx_g1_write(chip,MV88E6XXX_G1_CTL2,MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE|
From: Vivien Didelot <hidden> Date: 2017-12-05 20:35:27
Add a helper function to setup the upstream port of a given port.
This is the port used to reach the dedicated CPU port. This function
will be extended later to setup the global upstream port as well.
Signed-off-by: Vivien Didelot <redacted>
---
drivers/net/dsa/mv88e6xxx/chip.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
From: David Miller <davem@davemloft.net> Date: 2017-12-05 23:03:05
From: Vivien Didelot <redacted>
Date: Tue, 5 Dec 2017 15:34:08 -0500
An upstream port is a local switch port used to reach a CPU port.
DSA still considers a unique CPU port in the whole switch fabric and
thus return a unique upstream port for a given switch. This is wrong in
a multiple CPU ports environment.
We are now switching to using the dedicated CPU port assigned to each
port in order to get rid of the deprecated unique tree CPU port.
This patchset makes the dsa_upstream_port() helper take a port argument
and goes one step closer complete support for multiple CPU ports.
Changes in v2:
- reverse-christmas-tree-fy variables