linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: dsa: cross-chip FDB support
@ 2017-11-30 17:56 Vivien Didelot
  2017-11-30 17:56 ` [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper Vivien Didelot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vivien Didelot @ 2017-11-30 17:56 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot

DSA can have interconnected switches. For instance, the ZII Dev Rev B
board described in arch/arm/boot/dts/vf610-zii-dev-rev-b.dts has a
switch fabric composed of 3 switch devices like this:

                          lan4                 lan6
        CPU (eth1)            |  lan5         |  lan7
                  |           | |             | |
       [0 1 2 3 4 6 5]---[6 0 1 2 3 4 5]---[9 0 1 2 3 4 5 6 7 8]
        | | |               |                     | | |
    lan0  |  lan2       lan3                  lan8  |  optical4
           lan1                                      optical3

One current issue with DSA is cross-chip FDB. If we add a static MAC
address on lan3, only its parent switch 1 (the one in the middle) will
be programmed. That is not correct in a cross-chip environment, because
the DSA ports connecting to switch 1 of adjacent switch 0 (on the left)
and switch 2 (on the right) must be programmed too.

Without this patchset, a dump of the hardware FDB of switches 0, 1 and 2
after programming a MAC address on lan3 looks like this (*):

    # bridge fdb add 11:22:33:44:55:66 dev lan3
    # cat /sys/kernel/debug/mv88e6xxx/sw*/atu/0 | grep -v FID
       0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
       0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  0 - - - - - -
       0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
       0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6 7 8 9

With this patchset applied, adjacent DSA ports get programmed too:

    # bridge fdb add 11:22:33:44:55:66 dev lan3
    # cat /sys/kernel/debug/mv88e6xxx/sw*/atu/0 | grep -v FID
       0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  - - - - - 5 -
       0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
       0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  0 - - - - - -
       0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
       0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  - - - - - - - - - 9
       0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6 7 8 9

In order to do that, the first commit introduces a dsa_towards_port()
helper which returns the local port of a switch which must be used to
reach an arbitrary switch port (local or from an adjacent switch.)

The second patch uses this helper to configure the port reaching the
target port for every switches of the fabric.

(*) a patch for squashed debugfs interface which applies on top of this
patchset is available here:

    https://github.com/vivien/linux/commit/f8e6ba34c68a72d3bf42f4dea79abacb2e61a3cc.patch

Vivien Didelot (2):
  net: dsa: introduce dsa_towards_port helper
  net: dsa: support cross-chip FDB operations

 include/net/dsa.h | 23 +++++++++++++----------
 net/dsa/switch.c  | 14 ++++----------
 2 files changed, 17 insertions(+), 20 deletions(-)

-- 
2.15.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper
  2017-11-30 17:56 [PATCH net-next 0/2] net: dsa: cross-chip FDB support Vivien Didelot
@ 2017-11-30 17:56 ` Vivien Didelot
  2017-11-30 17:56 ` [PATCH net-next 2/2] net: dsa: support cross-chip FDB operations Vivien Didelot
  2017-12-03  2:22 ` [PATCH net-next 0/2] net: dsa: cross-chip FDB support David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Vivien Didelot @ 2017-11-30 17:56 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot

Add a new helper returning the local port used to reach an arbitrary
switch port in the fabric.

Its only user at the moment is the dsa_upstream_port helper, which
returns the local port reaching the dedicated CPU port, but it will be
used in cross-chip FDB operations.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 include/net/dsa.h | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2a05738570d8..f90f342dc5b4 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -296,20 +296,23 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds)
 	return mask;
 }
 
+/* Return the local port used to reach an arbitrary switch port */
+static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device,
+					    int port)
+{
+	if (device == ds->index)
+		return port;
+	else
+		return ds->rtable[device];
+}
+
+/* Return the local port used to reach the dedicated CPU port */
 static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 {
 	struct dsa_switch_tree *dst = ds->dst;
+	struct dsa_port *cpu_dp = dst->cpu_dp;
 
-	/*
-	 * If this is the root switch (i.e. the switch that connects
-	 * to the CPU), return the cpu port number on this switch.
-	 * Else return the (DSA) port number that connects to the
-	 * switch that is one hop closer to the cpu.
-	 */
-	if (dst->cpu_dp->ds == ds)
-		return dst->cpu_dp->index;
-	else
-		return ds->rtable[dst->cpu_dp->ds->index];
+	return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index);
 }
 
 typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] net: dsa: support cross-chip FDB operations
  2017-11-30 17:56 [PATCH net-next 0/2] net: dsa: cross-chip FDB support Vivien Didelot
  2017-11-30 17:56 ` [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper Vivien Didelot
@ 2017-11-30 17:56 ` Vivien Didelot
  2017-12-03  2:22 ` [PATCH net-next 0/2] net: dsa: cross-chip FDB support David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Vivien Didelot @ 2017-11-30 17:56 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot

When a MAC address is added to or removed from a switch port in the
fabric, the target switch must program its port and adjacent switches
must program their local DSA port used to reach the target switch.

For this purpose, use the dsa_towards_port() helper to identify the
local switch port which must be programmed.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/switch.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 29608d087a7c..de1dddc320ff 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -83,29 +83,23 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
 static int dsa_switch_fdb_add(struct dsa_switch *ds,
 			      struct dsa_notifier_fdb_info *info)
 {
-	/* Do not care yet about other switch chips of the fabric */
-	if (ds->index != info->sw_index)
-		return 0;
+	int port = dsa_towards_port(ds, info->sw_index, info->port);
 
 	if (!ds->ops->port_fdb_add)
 		return -EOPNOTSUPP;
 
-	return ds->ops->port_fdb_add(ds, info->port, info->addr,
-				     info->vid);
+	return ds->ops->port_fdb_add(ds, port, info->addr, info->vid);
 }
 
 static int dsa_switch_fdb_del(struct dsa_switch *ds,
 			      struct dsa_notifier_fdb_info *info)
 {
-	/* Do not care yet about other switch chips of the fabric */
-	if (ds->index != info->sw_index)
-		return 0;
+	int port = dsa_towards_port(ds, info->sw_index, info->port);
 
 	if (!ds->ops->port_fdb_del)
 		return -EOPNOTSUPP;
 
-	return ds->ops->port_fdb_del(ds, info->port, info->addr,
-				     info->vid);
+	return ds->ops->port_fdb_del(ds, port, info->addr, info->vid);
 }
 
 static int dsa_switch_mdb_add(struct dsa_switch *ds,
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] net: dsa: cross-chip FDB support
  2017-11-30 17:56 [PATCH net-next 0/2] net: dsa: cross-chip FDB support Vivien Didelot
  2017-11-30 17:56 ` [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper Vivien Didelot
  2017-11-30 17:56 ` [PATCH net-next 2/2] net: dsa: support cross-chip FDB operations Vivien Didelot
@ 2017-12-03  2:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-12-03  2:22 UTC (permalink / raw)
  To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew

From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Thu, 30 Nov 2017 12:56:41 -0500

> DSA can have interconnected switches. For instance, the ZII Dev Rev B
> board described in arch/arm/boot/dts/vf610-zii-dev-rev-b.dts has a
> switch fabric composed of 3 switch devices like this:
> 
>                           lan4                 lan6
>         CPU (eth1)            |  lan5         |  lan7
>                   |           | |             | |
>        [0 1 2 3 4 6 5]---[6 0 1 2 3 4 5]---[9 0 1 2 3 4 5 6 7 8]
>         | | |               |                     | | |
>     lan0  |  lan2       lan3                  lan8  |  optical4
>            lan1                                      optical3
> 
> One current issue with DSA is cross-chip FDB. If we add a static MAC
> address on lan3, only its parent switch 1 (the one in the middle) will
> be programmed. That is not correct in a cross-chip environment, because
> the DSA ports connecting to switch 1 of adjacent switch 0 (on the left)
> and switch 2 (on the right) must be programmed too.
> 
> Without this patchset, a dump of the hardware FDB of switches 0, 1 and 2
> after programming a MAC address on lan3 looks like this (*):
> 
>     # bridge fdb add 11:22:33:44:55:66 dev lan3
>     # cat /sys/kernel/debug/mv88e6xxx/sw*/atu/0 | grep -v FID
>        0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
>        0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  0 - - - - - -
>        0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
>        0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6 7 8 9
> 
> With this patchset applied, adjacent DSA ports get programmed too:
> 
>     # bridge fdb add 11:22:33:44:55:66 dev lan3
>     # cat /sys/kernel/debug/mv88e6xxx/sw*/atu/0 | grep -v FID
>        0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  - - - - - 5 -
>        0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
>        0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  0 - - - - - -
>        0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6
>        0  11:22:33:44:55:66    MC_STATIC_MGMT_PO       n  - - - - - - - - - 9
>        0  ff:ff:ff:ff:ff:ff            MC_STATIC       n  0 1 2 3 4 5 6 7 8 9
 ...

Series applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-03  2:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30 17:56 [PATCH net-next 0/2] net: dsa: cross-chip FDB support Vivien Didelot
2017-11-30 17:56 ` [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper Vivien Didelot
2017-11-30 17:56 ` [PATCH net-next 2/2] net: dsa: support cross-chip FDB operations Vivien Didelot
2017-12-03  2:22 ` [PATCH net-next 0/2] net: dsa: cross-chip FDB support 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).