* [PATCH net-next v2 0/5] net: dsa: use per-port upstream port
@ 2017-12-05 20:34 Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 1/5] net: dsa: mv88e6xxx: egress floods all DSA ports Vivien Didelot
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Vivien Didelot @ 2017-12-05 20:34 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v2 1/5] net: dsa: mv88e6xxx: egress floods all DSA ports
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
@ 2017-12-05 20:34 ` Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 2/5] net: dsa: mv88e6xxx: helper to setup upstream port Vivien Didelot
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Vivien Didelot @ 2017-12-05 20:34 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
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 <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index b5e0987c88f0..4b9ac962fd49 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1723,9 +1723,11 @@ static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
{
- bool flood = port == dsa_upstream_port(chip->ds);
+ struct dsa_switch *ds = chip->ds;
+ bool flood;
/* 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)
return chip->info->ops->port_set_egress_floods(chip, port,
flood, flood);
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 2/5] net: dsa: mv88e6xxx: helper to setup upstream port
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 1/5] net: dsa: mv88e6xxx: egress floods all DSA ports Vivien Didelot
@ 2017-12-05 20:34 ` Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 3/5] net: dsa: mv88e6xxx: setup global " Vivien Didelot
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Vivien Didelot @ 2017-12-05 20:34 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
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 <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 4b9ac962fd49..77488b40cceb 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1744,6 +1744,23 @@ static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
return 0;
}
+static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
+{
+ struct dsa_switch *ds = chip->ds;
+ int upstream_port;
+ int err;
+
+ upstream_port = dsa_upstream_port(ds);
+ if (chip->info->ops->port_set_upstream_port) {
+ err = chip->info->ops->port_set_upstream_port(chip, port,
+ upstream_port);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
{
struct dsa_switch *ds = chip->ds;
@@ -1814,13 +1831,9 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
if (err)
return err;
- reg = 0;
- if (chip->info->ops->port_set_upstream_port) {
- err = chip->info->ops->port_set_upstream_port(
- chip, port, dsa_upstream_port(ds));
- if (err)
- return err;
- }
+ err = mv88e6xxx_setup_upstream_port(chip, port);
+ if (err)
+ return err;
err = mv88e6xxx_port_set_8021q_mode(chip, port,
MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 3/5] net: dsa: mv88e6xxx: setup global upstream port
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 1/5] net: dsa: mv88e6xxx: egress floods all DSA ports Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 2/5] net: dsa: mv88e6xxx: helper to setup upstream port Vivien Didelot
@ 2017-12-05 20:34 ` Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 4/5] net: dsa: assign a CPU port to DSA port Vivien Didelot
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Vivien Didelot @ 2017-12-05 20:34 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
Move the setup of the global upstream port within the
mv88e6xxx_setup_upstream_port function.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 77488b40cceb..e1c0bb24f5b2 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1758,6 +1758,22 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
return err;
}
+ if (port == upstream_port) {
+ if (chip->info->ops->set_cpu_port) {
+ err = chip->info->ops->set_cpu_port(chip,
+ upstream_port);
+ if (err)
+ return err;
+ }
+
+ if (chip->info->ops->set_egress_port) {
+ err = chip->info->ops->set_egress_port(chip,
+ upstream_port);
+ if (err)
+ return err;
+ }
+ }
+
return 0;
}
@@ -1959,21 +1975,8 @@ static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
{
struct dsa_switch *ds = chip->ds;
- u32 upstream_port = dsa_upstream_port(ds);
int err;
- if (chip->info->ops->set_cpu_port) {
- err = chip->info->ops->set_cpu_port(chip, upstream_port);
- if (err)
- return err;
- }
-
- if (chip->info->ops->set_egress_port) {
- err = chip->info->ops->set_egress_port(chip, upstream_port);
- if (err)
- return err;
- }
-
/* Disable remote management, and set the switch's DSA device number. */
err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 4/5] net: dsa: assign a CPU port to DSA port
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
` (2 preceding siblings ...)
2017-12-05 20:34 ` [PATCH net-next v2 3/5] net: dsa: mv88e6xxx: setup global " Vivien Didelot
@ 2017-12-05 20:34 ` Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 5/5] net: dsa: return per-port upstream port Vivien Didelot
2017-12-05 23:02 ` [PATCH net-next v2 0/5] net: dsa: use " David Miller
5 siblings, 0 replies; 7+ messages in thread
From: Vivien Didelot @ 2017-12-05 20:34 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
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 <vivien.didelot@savoirfairelinux.com>
---
net/dsa/dsa2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 1e287420ff49..21f9bed11988 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -241,7 +241,7 @@ static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst)
for (port = 0; port < ds->num_ports; port++) {
dp = &ds->ports[port];
- if (dsa_port_is_user(dp))
+ if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp))
dp->cpu_dp = dst->cpu_dp;
}
}
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 5/5] net: dsa: return per-port upstream port
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
` (3 preceding siblings ...)
2017-12-05 20:34 ` [PATCH net-next v2 4/5] net: dsa: assign a CPU port to DSA port Vivien Didelot
@ 2017-12-05 20:34 ` Vivien Didelot
2017-12-05 23:02 ` [PATCH net-next v2 0/5] net: dsa: use " David Miller
5 siblings, 0 replies; 7+ messages in thread
From: Vivien Didelot @ 2017-12-05 20:34 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
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 <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
include/net/dsa.h | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index e1c0bb24f5b2..29b79d6d2925 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1750,7 +1750,7 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
int upstream_port;
int err;
- upstream_port = dsa_upstream_port(ds);
+ upstream_port = dsa_upstream_port(ds, port);
if (chip->info->ops->port_set_upstream_port) {
err = chip->info->ops->port_set_upstream_port(chip, port,
upstream_port);
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 8198efcc8ced..d29feccaefab 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -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 */
-static inline u8 dsa_upstream_port(struct dsa_switch *ds)
+static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port)
{
- struct dsa_switch_tree *dst = ds->dst;
- struct dsa_port *cpu_dp = dst->cpu_dp;
+ const struct dsa_port *dp = dsa_to_port(ds, port);
+ const struct dsa_port *cpu_dp = dp->cpu_dp;
+
+ if (!cpu_dp)
+ return port;
return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index);
}
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 0/5] net: dsa: use per-port upstream port
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
` (4 preceding siblings ...)
2017-12-05 20:34 ` [PATCH net-next v2 5/5] net: dsa: return per-port upstream port Vivien Didelot
@ 2017-12-05 23:02 ` David Miller
5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-12-05 23:02 UTC (permalink / raw)
To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
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
Series applied, thanks Vivien.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-12-05 23:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-05 20:34 [PATCH net-next v2 0/5] net: dsa: use per-port upstream port Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 1/5] net: dsa: mv88e6xxx: egress floods all DSA ports Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 2/5] net: dsa: mv88e6xxx: helper to setup upstream port Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 3/5] net: dsa: mv88e6xxx: setup global " Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 4/5] net: dsa: assign a CPU port to DSA port Vivien Didelot
2017-12-05 20:34 ` [PATCH net-next v2 5/5] net: dsa: return per-port upstream port Vivien Didelot
2017-12-05 23:02 ` [PATCH net-next v2 0/5] net: dsa: use " 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).