All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] D in DSA patches
@ 2015-08-17 21:52 Andrew Lunn
  2015-08-17 21:52 ` [PATCH net-next 1/3] net: dsa: Allow multi hop routes to be expressed Andrew Lunn
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andrew Lunn @ 2015-08-17 21:52 UTC (permalink / raw)
  To: David Miller
  Cc: Guenter Roeck, Florian Fainelli, Vivien Didelot, netdev, Andrew Lunn

The D in DSA is distributed, meaning multiple switches can be
connected together. Currently no mainline system does this, and so the
code is broken. This patchset contains two fixes, and a small helper.

With three of more switches, the current device tree binding is not
sufficient to express the routing between the switches. The first
patch extends the binding, in a backwards compatible way, to allow a
link between a switch to describe all the switches accessible over the
link, not just the direct neighbor.

The third patch fixes the port configuration on newer devices for
links connecting switches.

Andrew Lunn (3):
  net: dsa: Allow multi hop routes to be expressed
  net: dsa: Add dsa_is_dsa_port() helper
  dsa: mv88e6xxx: Set DSA mode based on chip abilities

 Documentation/devicetree/bindings/net/dsa/dsa.txt | 33 +++++++++++++++----
 drivers/net/dsa/mv88e6xxx.c                       | 16 +++++----
 include/net/dsa.h                                 |  5 +++
 net/dsa/dsa.c                                     | 40 +++++++++++++++++------
 4 files changed, 71 insertions(+), 23 deletions(-)

-- 
2.5.0

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

* [PATCH net-next 1/3] net: dsa: Allow multi hop routes to be expressed
  2015-08-17 21:52 [PATCH net-next 0/3] D in DSA patches Andrew Lunn
@ 2015-08-17 21:52 ` Andrew Lunn
  2015-08-17 21:52 ` [PATCH net-next 2/3] net: dsa: Add dsa_is_dsa_port() helper Andrew Lunn
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2015-08-17 21:52 UTC (permalink / raw)
  To: David Miller
  Cc: Guenter Roeck, Florian Fainelli, Vivien Didelot, netdev, Andrew Lunn

With more than two switches in a hierarchy, it becomes necessary to
describe multi-hop routes between switches. The current binding does
not allow this, although the older platform_data did. Extend the link
property to be a list rather than a single phandle to a remote switch.
It is then possible to express that a port should be used to reach
more than one switch and the switch maybe more than one hop away.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 Documentation/devicetree/bindings/net/dsa/dsa.txt | 33 +++++++++++++++----
 net/dsa/dsa.c                                     | 40 +++++++++++++++++------
 2 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index 9cf9a0ec333c..04e6bef3ac3f 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -44,9 +44,10 @@ Note that a port labelled "dsa" will imply checking for the uplink phandle
 described below.
 
 Optionnal property:
-- link			: Should be a phandle to another switch's DSA port.
+- link			: Should be a list of phandles to another switch's DSA port.
 			  This property is only used when switches are being
-			  chained/cascaded together.
+			  chained/cascaded together. This port is used as outgoing port
+			  towards the phandle port, which can be more than one hop away.
 
 - phy-handle		: Phandle to a PHY on an external MDIO bus, not the
 			  switch internal one. See
@@ -100,10 +101,11 @@ Example:
 				label = "cpu";
 			};
 
-			switch0uplink: port@6 {
+			switch0port6: port@6 {
 				reg = <6>;
 				label = "dsa";
-				link = <&switch1uplink>;
+				link = <&switch1port0
+				        &switch2port0>;
 			};
 		};
 
@@ -113,10 +115,29 @@ Example:
 			reg = <17 1>;	/* MDIO address 17, switch 1 in tree */
 			mii-bus = <&mii_bus1>;
 
-			switch1uplink: port@0 {
+			switch1port0: port@0 {
 				reg = <0>;
 				label = "dsa";
-				link = <&switch0uplink>;
+				link = <&switch0port6>;
+			};
+			switch1port1: port@1 {
+				reg = <1>;
+				label = "dsa";
+				link = <&switch2port1>;
+			};
+		};
+
+		switch@2 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <18 2>;	/* MDIO address 18, switch 2 in tree */
+			mii-bus = <&mii_bus1>;
+
+			switch2port0: port@0 {
+				reg = <0>;
+				label = "dsa";
+				link = <&switch1port1
+				        &switch0port6>;
 			};
 		};
 	};
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 78d4ac97aae3..053eb2b8e682 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -554,6 +554,31 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
 	return 0;
 }
 
+static int dsa_of_probe_links(struct dsa_platform_data *pd,
+			      struct dsa_chip_data *cd,
+			      int chip_index, int port_index,
+			      struct device_node *port,
+			      const char *port_name)
+{
+	struct device_node *link;
+	int link_index;
+	int ret;
+
+	for (link_index = 0;; link_index++) {
+		link = of_parse_phandle(port, "link", link_index);
+		if (!link)
+			break;
+
+		if (!strcmp(port_name, "dsa") && pd->nr_chips > 1) {
+			ret = dsa_of_setup_routing_table(pd, cd, chip_index,
+							 port_index, link);
+			if (ret)
+				return ret;
+		}
+	}
+	return 0;
+}
+
 static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
 {
 	int i;
@@ -573,7 +598,7 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
 static int dsa_of_probe(struct device *dev)
 {
 	struct device_node *np = dev->of_node;
-	struct device_node *child, *mdio, *ethernet, *port, *link;
+	struct device_node *child, *mdio, *ethernet, *port;
 	struct mii_bus *mdio_bus, *mdio_bus_switch;
 	struct net_device *ethernet_dev;
 	struct dsa_platform_data *pd;
@@ -668,15 +693,10 @@ static int dsa_of_probe(struct device *dev)
 				goto out_free_chip;
 			}
 
-			link = of_parse_phandle(port, "link", 0);
-
-			if (!strcmp(port_name, "dsa") && link &&
-					pd->nr_chips > 1) {
-				ret = dsa_of_setup_routing_table(pd, cd,
-						chip_index, port_index, link);
-				if (ret)
-					goto out_free_chip;
-			}
+			ret = dsa_of_probe_links(pd, cd, chip_index,
+						 port_index, port, port_name);
+			if (ret)
+				goto out_free_chip;
 
 		}
 	}
-- 
2.5.0

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

* [PATCH net-next 2/3] net: dsa: Add dsa_is_dsa_port() helper
  2015-08-17 21:52 [PATCH net-next 0/3] D in DSA patches Andrew Lunn
  2015-08-17 21:52 ` [PATCH net-next 1/3] net: dsa: Allow multi hop routes to be expressed Andrew Lunn
@ 2015-08-17 21:52 ` Andrew Lunn
  2015-08-17 21:52 ` [PATCH net-next 3/3] dsa: mv88e6xxx: Set DSA mode based on chip abilities Andrew Lunn
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2015-08-17 21:52 UTC (permalink / raw)
  To: David Miller
  Cc: Guenter Roeck, Florian Fainelli, Vivien Didelot, netdev, Andrew Lunn

Add an inline helper for determining is a port is a DSA port.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx.c | 5 ++---
 include/net/dsa.h           | 5 +++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 332f2c8090d0..486e9792fc05 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1926,8 +1926,7 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
 		 * full duplex.
 		 */
 		reg = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_PCS_CTRL);
-		if (dsa_is_cpu_port(ds, port) ||
-		    ds->dsa_port_mask & (1 << port)) {
+		if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) {
 			reg |= PORT_PCS_CTRL_FORCE_LINK |
 				PORT_PCS_CTRL_LINK_UP |
 				PORT_PCS_CTRL_DUPLEX_FULL |
@@ -1992,7 +1991,7 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
 	    mv88e6xxx_6165_family(ds) || mv88e6xxx_6097_family(ds) ||
 	    mv88e6xxx_6095_family(ds) || mv88e6xxx_6065_family(ds) ||
 	    mv88e6xxx_6320_family(ds)) {
-		if (ds->dsa_port_mask & (1 << port))
+		if (dsa_is_dsa_port(ds, port))
 			reg |= PORT_CONTROL_FRAME_MODE_DSA;
 		if (port == dsa_upstream_port(ds))
 			reg |= PORT_CONTROL_FORWARD_UNKNOWN |
diff --git a/include/net/dsa.h b/include/net/dsa.h
index bd9b76502458..b34d812bc5d0 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -171,6 +171,11 @@ static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
 	return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
 }
 
+static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
+{
+	return !!((ds->dsa_port_mask) & (1 << p));
+}
+
 static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
 {
 	return ds->phys_port_mask & (1 << p) && ds->ports[p];
-- 
2.5.0

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

* [PATCH net-next 3/3] dsa: mv88e6xxx: Set DSA mode based on chip abilities
  2015-08-17 21:52 [PATCH net-next 0/3] D in DSA patches Andrew Lunn
  2015-08-17 21:52 ` [PATCH net-next 1/3] net: dsa: Allow multi hop routes to be expressed Andrew Lunn
  2015-08-17 21:52 ` [PATCH net-next 2/3] net: dsa: Add dsa_is_dsa_port() helper Andrew Lunn
@ 2015-08-17 21:52 ` Andrew Lunn
  2015-08-18 21:17 ` [PATCH net-next 0/3] D in DSA patches David Miller
  2015-08-19 21:25 ` Florian Fainelli
  4 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2015-08-17 21:52 UTC (permalink / raw)
  To: David Miller
  Cc: Guenter Roeck, Florian Fainelli, Vivien Didelot, netdev, Andrew Lunn

Older devices only support a single DSA frame format, where as newer
devices have two. Take this into account when configuring a DSA port.
The port needs to be in plain old DSA mode, since this is a DSA link,
where as the newer format can be used for the CPU port.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 486e9792fc05..2ab3f9810593 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1987,12 +1987,15 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
 				reg |= PORT_CONTROL_EGRESS_ADD_TAG;
 		}
 	}
-	if (mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds) ||
-	    mv88e6xxx_6165_family(ds) || mv88e6xxx_6097_family(ds) ||
-	    mv88e6xxx_6095_family(ds) || mv88e6xxx_6065_family(ds) ||
-	    mv88e6xxx_6320_family(ds)) {
-		if (dsa_is_dsa_port(ds, port))
+	if (dsa_is_dsa_port(ds, port)) {
+		if (mv88e6xxx_6095_family(ds) || mv88e6xxx_6185_family(ds))
+			reg |= PORT_CONTROL_DSA_TAG;
+		if (mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds) ||
+		    mv88e6xxx_6165_family(ds) || mv88e6xxx_6097_family(ds) ||
+		    mv88e6xxx_6320_family(ds)) {
 			reg |= PORT_CONTROL_FRAME_MODE_DSA;
+		}
+
 		if (port == dsa_upstream_port(ds))
 			reg |= PORT_CONTROL_FORWARD_UNKNOWN |
 				PORT_CONTROL_FORWARD_UNKNOWN_MC;
-- 
2.5.0

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

* Re: [PATCH net-next 0/3] D in DSA patches
  2015-08-17 21:52 [PATCH net-next 0/3] D in DSA patches Andrew Lunn
                   ` (2 preceding siblings ...)
  2015-08-17 21:52 ` [PATCH net-next 3/3] dsa: mv88e6xxx: Set DSA mode based on chip abilities Andrew Lunn
@ 2015-08-18 21:17 ` David Miller
  2015-08-19 21:25 ` Florian Fainelli
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-08-18 21:17 UTC (permalink / raw)
  To: andrew; +Cc: linux, f.fainelli, vivien.didelot, netdev

From: Andrew Lunn <andrew@lunn.ch>
Date: Mon, 17 Aug 2015 23:52:49 +0200

> The D in DSA is distributed, meaning multiple switches can be
> connected together. Currently no mainline system does this, and so the
> code is broken. This patchset contains two fixes, and a small helper.
> 
> With three of more switches, the current device tree binding is not
> sufficient to express the routing between the switches. The first
> patch extends the binding, in a backwards compatible way, to allow a
> link between a switch to describe all the switches accessible over the
> link, not just the direct neighbor.
> 
> The third patch fixes the port configuration on newer devices for
> links connecting switches.

Series applied, thanks Andrew.

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

* Re: [PATCH net-next 0/3] D in DSA patches
  2015-08-17 21:52 [PATCH net-next 0/3] D in DSA patches Andrew Lunn
                   ` (3 preceding siblings ...)
  2015-08-18 21:17 ` [PATCH net-next 0/3] D in DSA patches David Miller
@ 2015-08-19 21:25 ` Florian Fainelli
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2015-08-19 21:25 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: David Miller, Guenter Roeck, Vivien Didelot, netdev

2015-08-17 14:52 GMT-07:00 Andrew Lunn <andrew@lunn.ch>:
> The D in DSA is distributed, meaning multiple switches can be
> connected together. Currently no mainline system does this, and so the
> code is broken. This patchset contains two fixes, and a small helper.
>
> With three of more switches, the current device tree binding is not
> sufficient to express the routing between the switches. The first
> patch extends the binding, in a backwards compatible way, to allow a
> link between a switch to describe all the switches accessible over the
> link, not just the direct neighbor.
>
> The third patch fixes the port configuration on newer devices for
> links connecting switches.

Little late, but this looks good, thanks Andrew!

>
> Andrew Lunn (3):
>   net: dsa: Allow multi hop routes to be expressed
>   net: dsa: Add dsa_is_dsa_port() helper
>   dsa: mv88e6xxx: Set DSA mode based on chip abilities
>
>  Documentation/devicetree/bindings/net/dsa/dsa.txt | 33 +++++++++++++++----
>  drivers/net/dsa/mv88e6xxx.c                       | 16 +++++----
>  include/net/dsa.h                                 |  5 +++
>  net/dsa/dsa.c                                     | 40 +++++++++++++++++------
>  4 files changed, 71 insertions(+), 23 deletions(-)
>
> --
> 2.5.0
>



-- 
Florian

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

end of thread, other threads:[~2015-08-19 21:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17 21:52 [PATCH net-next 0/3] D in DSA patches Andrew Lunn
2015-08-17 21:52 ` [PATCH net-next 1/3] net: dsa: Allow multi hop routes to be expressed Andrew Lunn
2015-08-17 21:52 ` [PATCH net-next 2/3] net: dsa: Add dsa_is_dsa_port() helper Andrew Lunn
2015-08-17 21:52 ` [PATCH net-next 3/3] dsa: mv88e6xxx: Set DSA mode based on chip abilities Andrew Lunn
2015-08-18 21:17 ` [PATCH net-next 0/3] D in DSA patches David Miller
2015-08-19 21:25 ` Florian Fainelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.