2017-11-30 17:59:34

by Vivien Didelot

[permalink] [raw]
Subject: [PATCH net-next 0/2] net: dsa: cross-chip FDB support

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


From 1585791397022383755@xxx Sun Dec 03 19:15:26 +0000 2017
X-GM-THRID: 1585791397022383755
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-30 17:58:49

by Vivien Didelot

[permalink] [raw]
Subject: [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper

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 <[email protected]>
---
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


From 1585518447759140177@xxx Thu Nov 30 18:57:01 +0000 2017
X-GM-THRID: 1585517940150114735
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-30 17:57:39

by Vivien Didelot

[permalink] [raw]
Subject: [PATCH net-next 2/2] net: dsa: support cross-chip FDB operations

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 <[email protected]>
---
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


From 1585511111327166277@xxx Thu Nov 30 17:00:25 +0000 2017
X-GM-THRID: 1584302672956416146
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread