netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Add DSA yaml binding
@ 2020-07-20 12:49 Kurt Kanzenbach
  2020-07-20 12:49 ` [PATCH v2 1/3] dt-bindings: net: dsa: " Kurt Kanzenbach
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kurt Kanzenbach @ 2020-07-20 12:49 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Rob Herring
  Cc: David S. Miller, Jakub Kicinski, netdev, devicetree, Kurt Kanzenbach

Hi,

as discussed [1] [2] it makes sense to add a DSA yaml binding. This is the
second version and contains now two ways of specifying the switch ports: Either
by "ports" or by "ethernet-ports". That is why the third patch also adjusts the
DSA core for it.

Tested in combination with the hellcreek.yaml file.

Changes since v1:

 * Use select to not match unrelated switches
 * Allow ethernet-port(s)
 * List ethernet-controller properties
 * Include better description
 * Let dsa.txt refer to dsa.yaml

Thanks,
Kurt

[1] - https://lkml.kernel.org/netdev/449f0a03-a91d-ae82-b31f-59dfd1457ec5@gmail.com/
[2] - https://lkml.kernel.org/netdev/20200710090618.28945-1-kurt@linutronix.de/

Kurt Kanzenbach (3):
  dt-bindings: net: dsa: Add DSA yaml binding
  dt-bindings: net: dsa: Let dsa.txt refer to dsa.yaml
  net: dsa: of: Allow ethernet-ports as encapsulating node

 .../devicetree/bindings/net/dsa/dsa.txt       | 255 +-----------------
 .../devicetree/bindings/net/dsa/dsa.yaml      |  92 +++++++
 net/dsa/dsa2.c                                |   8 +-
 3 files changed, 99 insertions(+), 256 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml

-- 
2.20.1


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

* [PATCH v2 1/3] dt-bindings: net: dsa: Add DSA yaml binding
  2020-07-20 12:49 [PATCH v2 0/3] Add DSA yaml binding Kurt Kanzenbach
@ 2020-07-20 12:49 ` Kurt Kanzenbach
  2020-07-20 12:49 ` [PATCH v2 2/3] dt-bindings: net: dsa: Let dsa.txt refer to dsa.yaml Kurt Kanzenbach
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Kurt Kanzenbach @ 2020-07-20 12:49 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Rob Herring
  Cc: David S. Miller, Jakub Kicinski, netdev, devicetree, Kurt Kanzenbach

For future DSA drivers it makes sense to add a generic DSA yaml binding which
can be used then. This was created using the properties from dsa.txt. It
includes the ports and the dsa,member property.

Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 .../devicetree/bindings/net/dsa/dsa.yaml      | 92 +++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
new file mode 100644
index 000000000000..faea214339ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Ethernet Switch Device Tree Bindings
+
+maintainers:
+  - Andrew Lunn <andrew@lunn.ch>
+  - Florian Fainelli <f.fainelli@gmail.com>
+  - Vivien Didelot <vivien.didelot@gmail.com>
+
+description:
+  This binding represents Ethernet Switches which have a dedicated CPU
+  port. That port is usually connected to an Ethernet Controller of the
+  SoC. Such setups are typical for embedded devices.
+
+select: false
+
+properties:
+  $nodename:
+    pattern: "^switch(@.*)?$"
+
+  dsa,member:
+    minItems: 2
+    maxItems: 2
+    description:
+      A two element list indicates which DSA cluster, and position within the
+      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
+      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
+      (single device hanging off a CPU port) must not specify this property
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+patternProperties:
+  "^(ethernet-)?ports$":
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^(ethernet-)?port@[0-9]+$":
+        type: object
+        description: Ethernet switch ports
+
+        properties:
+          reg:
+            description: Port number
+
+          label:
+            description:
+              Describes the label associated with this port, which will become
+              the netdev name
+            $ref: /schemas/types.yaml#definitions/string
+
+          link:
+            description:
+              Should be a list of phandles to other switch's DSA port. This
+              port is used as the outgoing port towards the phandle ports. The
+              full routing information must be given, not just the one hop
+              routes to neighbouring switches
+            $ref: /schemas/types.yaml#definitions/phandle-array
+
+          ethernet:
+            description:
+              Should be a phandle to a valid Ethernet device node.  This host
+              device is what the switch port is connected to
+            $ref: /schemas/types.yaml#definitions/phandle
+
+          phy-handle: true
+
+          phy-mode: true
+
+          fixed-link: true
+
+          mac-address: true
+
+        required:
+          - reg
+
+        additionalProperties: false
+
+oneOf:
+  - required:
+    - ports
+  - required:
+    - ethernet-ports
+
+...
-- 
2.20.1


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

* [PATCH v2 2/3] dt-bindings: net: dsa: Let dsa.txt refer to dsa.yaml
  2020-07-20 12:49 [PATCH v2 0/3] Add DSA yaml binding Kurt Kanzenbach
  2020-07-20 12:49 ` [PATCH v2 1/3] dt-bindings: net: dsa: " Kurt Kanzenbach
@ 2020-07-20 12:49 ` Kurt Kanzenbach
  2020-07-20 12:49 ` [PATCH v2 3/3] net: dsa: of: Allow ethernet-ports as encapsulating node Kurt Kanzenbach
  2020-07-22 23:57 ` [PATCH v2 0/3] Add DSA yaml binding David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Kurt Kanzenbach @ 2020-07-20 12:49 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Rob Herring
  Cc: David S. Miller, Jakub Kicinski, netdev, devicetree, Kurt Kanzenbach

The DSA bindings have been converted to YAML. Therefore, the old text style
documentation should refer to that one.

The text file can be removed completely once all the existing DSA switch
bindings have been converted as well.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 .../devicetree/bindings/net/dsa/dsa.txt       | 255 +-----------------
 1 file changed, 1 insertion(+), 254 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index f66bb7ecdb82..bf7328aba330 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -1,257 +1,4 @@
 Distributed Switch Architecture Device Tree Bindings
 ----------------------------------------------------
 
-Switches are true Linux devices and can be probed by any means. Once
-probed, they register to the DSA framework, passing a node
-pointer. This node is expected to fulfil the following binding, and
-may contain additional properties as required by the device it is
-embedded within.
-
-Required properties:
-
-- ports		: A container for child nodes representing switch ports.
-
-Optional properties:
-
-- dsa,member	: A two element list indicates which DSA cluster, and position
-		  within the cluster a switch takes. <0 0> is cluster 0,
-		  switch 0. <0 1> is cluster 0, switch 1. <1 0> is cluster 1,
-		  switch 0. A switch not part of any cluster (single device
-		  hanging off a CPU port) must not specify this property
-
-The ports container has the following properties
-
-Required properties:
-
-- #address-cells	: Must be 1
-- #size-cells		: Must be 0
-
-Each port children node must have the following mandatory properties:
-- reg			: Describes the port address in the switch
-
-An uplink/downlink port between switches in the cluster has the following
-mandatory property:
-
-- link			: Should be a list of phandles to other switch's DSA
-			  port. This port is used as the outgoing port
-			  towards the phandle ports. The full routing
-			  information must be given, not just the one hop
-			  routes to neighbouring switches.
-
-A CPU port has the following mandatory property:
-
-- ethernet		: Should be a phandle to a valid Ethernet device node.
-                          This host device is what the switch port is
-			  connected to.
-
-A user port has the following optional property:
-
-- label			: Describes the label associated with this port, which
-                          will become the netdev name.
-
-Port child nodes may also contain the following optional standardised
-properties, described in binding documents:
-
-- phy-handle		: Phandle to a PHY on an MDIO bus. See
-			  Documentation/devicetree/bindings/net/ethernet.txt
-			  for details.
-
-- phy-mode		: See
-			  Documentation/devicetree/bindings/net/ethernet.txt
-			  for details.
-
-- fixed-link		: Fixed-link subnode describing a link to a non-MDIO
-			  managed entity. See
-			  Documentation/devicetree/bindings/net/fixed-link.txt
-			  for details.
-
-The MAC address will be determined using the optional properties
-defined in ethernet.txt.
-
-Example
-
-The following example shows three switches on three MDIO busses,
-linked into one DSA cluster.
-
-&mdio1 {
-	#address-cells = <1>;
-	#size-cells = <0>;
-
-	switch0: switch0@0 {
-		compatible = "marvell,mv88e6085";
-		reg = <0>;
-
-		dsa,member = <0 0>;
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-			port@0 {
-				reg = <0>;
-				label = "lan0";
-			};
-
-			port@1 {
-				reg = <1>;
-				label = "lan1";
-				local-mac-address = [00 00 00 00 00 00];
-			};
-
-			port@2 {
-				reg = <2>;
-				label = "lan2";
-			};
-
-			switch0port5: port@5 {
-				reg = <5>;
-				phy-mode = "rgmii-txid";
-				link = <&switch1port6
-					&switch2port9>;
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-				};
-			};
-
-			port@6 {
-				reg = <6>;
-				ethernet = <&fec1>;
-				fixed-link {
-					speed = <100>;
-					full-duplex;
-				};
-			};
-		};
-	};
-};
-
-&mdio2 {
-	#address-cells = <1>;
-	#size-cells = <0>;
-
-	switch1: switch1@0 {
-		compatible = "marvell,mv88e6085";
-		reg = <0>;
-
-		dsa,member = <0 1>;
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-			port@0 {
-				reg = <0>;
-				label = "lan3";
-				phy-handle = <&switch1phy0>;
-			};
-
-			port@1 {
-				reg = <1>;
-				label = "lan4";
-				phy-handle = <&switch1phy1>;
-			};
-
-			port@2 {
-				reg = <2>;
-				label = "lan5";
-				phy-handle = <&switch1phy2>;
-			};
-
-			switch1port5: port@5 {
-				reg = <5>;
-				link = <&switch2port9>;
-				phy-mode = "rgmii-txid";
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-				};
-			};
-
-			switch1port6: port@6 {
-				reg = <6>;
-				phy-mode = "rgmii-txid";
-				link = <&switch0port5>;
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-				};
-			};
-		};
-		mdio-bus {
-			#address-cells = <1>;
-			#size-cells = <0>;
-			switch1phy0: switch1phy0@0 {
-				reg = <0>;
-			};
-			switch1phy1: switch1phy0@1 {
-				reg = <1>;
-			};
-			switch1phy2: switch1phy0@2 {
-				reg = <2>;
-			};
-		};
-	 };
-};
-
-&mdio4 {
-	#address-cells = <1>;
-	#size-cells = <0>;
-
-	switch2: switch2@0 {
-		compatible = "marvell,mv88e6085";
-		reg = <0>;
-
-		dsa,member = <0 2>;
-
-		ports {
-			#address-cells = <1>;
-			#size-cells = <0>;
-			port@0 {
-				reg = <0>;
-				label = "lan6";
-			};
-
-			port@1 {
-				reg = <1>;
-				label = "lan7";
-			};
-
-			port@2 {
-				reg = <2>;
-				label = "lan8";
-			};
-
-			port@3 {
-				reg = <3>;
-				label = "optical3";
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-					link-gpios = <&gpio6 2
-					      GPIO_ACTIVE_HIGH>;
-				};
-			};
-
-			port@4 {
-				reg = <4>;
-				label = "optical4";
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-					link-gpios = <&gpio6 3
-					      GPIO_ACTIVE_HIGH>;
-				};
-			};
-
-			switch2port9: port@9 {
-				reg = <9>;
-				phy-mode = "rgmii-txid";
-				link = <&switch1port5
-					&switch0port5>;
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-				};
-			};
-		};
-	};
-};
+See Documentation/devicetree/bindings/net/dsa/dsa.yaml for the documenation.
-- 
2.20.1


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

* [PATCH v2 3/3] net: dsa: of: Allow ethernet-ports as encapsulating node
  2020-07-20 12:49 [PATCH v2 0/3] Add DSA yaml binding Kurt Kanzenbach
  2020-07-20 12:49 ` [PATCH v2 1/3] dt-bindings: net: dsa: " Kurt Kanzenbach
  2020-07-20 12:49 ` [PATCH v2 2/3] dt-bindings: net: dsa: Let dsa.txt refer to dsa.yaml Kurt Kanzenbach
@ 2020-07-20 12:49 ` Kurt Kanzenbach
  2020-07-22 23:57 ` [PATCH v2 0/3] Add DSA yaml binding David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Kurt Kanzenbach @ 2020-07-20 12:49 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Rob Herring
  Cc: David S. Miller, Jakub Kicinski, netdev, devicetree, Kurt Kanzenbach

Due to unified Ethernet Switch Device Tree Bindings allow for ethernet-ports as
encapsulating node as well.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 net/dsa/dsa2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index e055efff390b..c0ffc7a2b65f 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -727,8 +727,12 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 
 	ports = of_get_child_by_name(dn, "ports");
 	if (!ports) {
-		dev_err(ds->dev, "no ports child node found\n");
-		return -EINVAL;
+		/* The second possibility is "ethernet-ports" */
+		ports = of_get_child_by_name(dn, "ethernet-ports");
+		if (!ports) {
+			dev_err(ds->dev, "no ports child node found\n");
+			return -EINVAL;
+		}
 	}
 
 	for_each_available_child_of_node(ports, port) {
-- 
2.20.1


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

* Re: [PATCH v2 0/3] Add DSA yaml binding
  2020-07-20 12:49 [PATCH v2 0/3] Add DSA yaml binding Kurt Kanzenbach
                   ` (2 preceding siblings ...)
  2020-07-20 12:49 ` [PATCH v2 3/3] net: dsa: of: Allow ethernet-ports as encapsulating node Kurt Kanzenbach
@ 2020-07-22 23:57 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-07-22 23:57 UTC (permalink / raw)
  To: kurt
  Cc: andrew, vivien.didelot, f.fainelli, robh+dt, kuba, netdev, devicetree

From: Kurt Kanzenbach <kurt@linutronix.de>
Date: Mon, 20 Jul 2020 14:49:36 +0200

> as discussed [1] [2] it makes sense to add a DSA yaml binding. This is the
> second version and contains now two ways of specifying the switch ports: Either
> by "ports" or by "ethernet-ports". That is why the third patch also adjusts the
> DSA core for it.
> 
> Tested in combination with the hellcreek.yaml file.
> 
> Changes since v1:
> 
>  * Use select to not match unrelated switches
>  * Allow ethernet-port(s)
>  * List ethernet-controller properties
>  * Include better description
>  * Let dsa.txt refer to dsa.yaml
 ...
> [1] - https://lkml.kernel.org/netdev/449f0a03-a91d-ae82-b31f-59dfd1457ec5@gmail.com/
> [2] - https://lkml.kernel.org/netdev/20200710090618.28945-1-kurt@linutronix.de/

Series applied to net-next, thanks.

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

end of thread, other threads:[~2020-07-22 23:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 12:49 [PATCH v2 0/3] Add DSA yaml binding Kurt Kanzenbach
2020-07-20 12:49 ` [PATCH v2 1/3] dt-bindings: net: dsa: " Kurt Kanzenbach
2020-07-20 12:49 ` [PATCH v2 2/3] dt-bindings: net: dsa: Let dsa.txt refer to dsa.yaml Kurt Kanzenbach
2020-07-20 12:49 ` [PATCH v2 3/3] net: dsa: of: Allow ethernet-ports as encapsulating node Kurt Kanzenbach
2020-07-22 23:57 ` [PATCH v2 0/3] Add DSA yaml binding 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).