Skip to contentSkip to conversation

dt-binding preparation for ocelot switches

PATCH Superseded Colin Foster 6 participants 36 messages Nov 27, 2022 – Dec 2, 2022

Subsystems (12)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover dt-binding preparation for ocelot switches

Ocelot switches have the abilitiy to be used internally via memory-mapped IO or externally via SPI or PCIe. This brings up issues for documentation, where the same chip might be accessed internally in a switchdev manner, or externally in a DSA configuration. This patch set is perparation to bring DSA functionality to the VSC7512, utilizing as much as possible with an almost identical VSC7514 chip.

This patch set changed quite a bit from v2, so I'll omit the background of how those sets came to be. Rob offered a lot of very useful guidance. My thanks.

At the end of the day, with this patch set, there should be a framework to document Ocelot switches (and any switch) in scenarios where they can be controlled internally (ethernet-switch) or externally (dsa-switch).

---

v2 -> v3
* Restructured everything to use a "base" iref for devices that don't have additional properties, and simply a "ref" for devices that do.
* New patches to fix up brcm,sf2, qca8k, and mt7530
* Fix unevaluatedProperties errors from previous sets (see specific patches for more detail)
* Removed redundant "Device Tree Binding" from titles, where applicable.

v1 -> v2
* Two MFD patches were brought into the MFD tree, so are dropped
* Add first patch 1/6 to allow DSA devices to add ports and port properties
* Test qca8k against new dt-bindings and fix warnings. (patch 2/6)
* Add tags (patch 3/6)
* Fix vsc7514 refs and properties

---

Colin Foster (10):
dt-bindings: net: dsa: sf2: fix brcm,use-bcm-hdr documentation
dt-bindings: net: dsa: qca8k: remove address-cells and size-cells from
switch node
dt-bindings: net: dsa: utilize base definitions for standard dsa
switches
dt-bindings: net: dsa: allow additional ethernet-port properties
dt-bindings: net: dsa: qca8k: utilize shared dsa.yaml
dt-bindings: net: dsa: mediatek,mt7530: fix port description location
dt-bindings: net: dsa: mediatek,mt7530: remove unnecessary dsa-port
reference
dt-bindings: net: add generic ethernet-switch
dt-bindings: net: add generic ethernet-switch-port binding
dt-bindings: net: mscc,vsc7514-switch: utilize generic
ethernet-switch.yaml

 .../bindings/net/dsa/arrow,xrs700x.yaml       |  2 +-
 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  2 +-
 .../devicetree/bindings/net/dsa/brcm,sf2.yaml | 15 +++--
 .../devicetree/bindings/net/dsa/dsa-port.yaml | 24 +------
 .../devicetree/bindings/net/dsa/dsa.yaml      | 37 +++++------
 .../net/dsa/hirschmann,hellcreek.yaml         |  2 +-
 .../bindings/net/dsa/mediatek,mt7530.yaml     | 17 ++---
 .../bindings/net/dsa/microchip,ksz.yaml       |  2 +-
 .../bindings/net/dsa/microchip,lan937x.yaml   |  2 +-
 .../bindings/net/dsa/mscc,ocelot.yaml         |  2 +-
 .../bindings/net/dsa/nxp,sja1105.yaml         |  2 +-
 .../devicetree/bindings/net/dsa/qca8k.yaml    | 15 +----
 .../devicetree/bindings/net/dsa/realtek.yaml  |  2 +-
 .../bindings/net/dsa/renesas,rzn1-a5psw.yaml  |  2 +-
 .../bindings/net/ethernet-switch-port.yaml    | 25 ++++++++
 .../bindings/net/ethernet-switch.yaml         | 62 +++++++++++++++++++
 .../bindings/net/mscc,vsc7514-switch.yaml     | 31 +---------
 MAINTAINERS                                   |  2 +
 18 files changed, 134 insertions(+), 112 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/ethernet-switch-port.yaml
 create mode 100644 Documentation/devicetree/bindings/net/ethernet-switch.yaml
Signature · 124 lines
2.25.1

From 20867224faa46fc375f31b11aece705af091151a Mon Sep 17 00:00:00 2001
From: Colin Foster <[email protected]>
Date: Thu, 3 Nov 2022 21:10:02 -0700
Subject: [PATCH v2 net-next 0/6] dt-binding preparation for ocelot switches
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Ocelot switches have the abilitiy to be used internally via
memory-mapped IO or externally via SPI or PCIe. This brings up issues
for documentation, where the same chip might be accessed internally in a
switchdev manner, or externally in a DSA configuration. This patch set
is perparation to bring DSA functionality to the VSC7512, utilizing as
much as possible with an almost identical VSC7514 chip.

During the most recent RFC for internal ethernet switch functionality to
the VSC7512, there were 10 steps laid out to adequately prepare
documentation:

https://lore.kernel.org/all/20221010174856.nd3n4soxk7zbmcm7@skbuf/

The full context is quoted below. This patch set represents steps 1-7 of
the 10 steps, with the remaining steps to likely be part of what was the
original RFC.

The first two patches are specifically rewording and fixing of the MFD
bindings. I kept them in this patch set since they might cause conflicts
with future documentation changes that will be part of the net-next
tree. I can separate them if desired.



Context:

```
To end the discussion on a constructive note, I think if I were Colin,
I would do the following, in the following order, according to what was
expressed as a constraint:

1. Reword the "driver" word out of mscc,vsc7514-switch.yaml and express
   the description in terms of what the switch can do, not what the
   driver can do.

2. Make qca8k.yaml have "$ref: dsa.yaml#". Remove "$ref: dsa-port.yaml#"
   from the same schema.

3. Remove "- $ref: dsa-port.yaml#" from mediatek,mt7530.yaml. It doesn't
   seem to be needed, since dsa.yaml also has this. We need this because
   we want to make sure no one except dsa.yaml references dsa-port.yaml.

4. Move the DSA-unspecific portion from dsa.yaml into a new
   ethernet-switch.yaml. What remains in dsa.yaml is "dsa,member".
   The dsa.yaml schema will have "$ref: ethernet-switch.yaml#" for the
   "(ethernet-)switch" node, plus its custom additions.

5. Move the DSA-unspecific portion from dsa-port.yaml into a new
   ethernet-switch-port.yaml. What remains in dsa-port.yaml is:
   * ethernet phandle
   * link phandle
   * label property
   * dsa-tag-protocol property
   * the constraint that CPU and DSA ports must have phylink bindings

6. The ethernet-switch.yaml will have "$ref: ethernet-switch-port.yaml#"
   and "$ref: dsa-port.yaml". The dsa-port.yaml schema will *not* have
   "$ref: ethernet-switch-port.yaml#", just its custom additions.
   I'm not 100% on this, but I think there will be a problem if:
   - dsa.yaml references ethernet-switch.yaml
     - ethernet-switch.yaml references ethernet-switch-port.yaml
   - dsa.yaml also references dsa-port.yaml
     - dsa-port.yaml references ethernet-switch-port.yaml
   because ethernet-switch-port.yaml will be referenced twice. Again,
   not sure if this is a problem. If it isn't, things can be simpler,
   just make dsa-port.yaml reference ethernet-switch-port.yaml, and skip
   steps 2 and 3 since dsa-port.yaml containing just the DSA specifics
   is no longer problematic.

7. Make mscc,vsc7514-switch.yaml have "$ref: ethernet-switch.yaml#" for
   the "mscc,vsc7514-switch.yaml" compatible string. This will eliminate
   its own definitions for the generic properties: $nodename and
   ethernet-ports (~45 lines of code if I'm not mistaken).

8. Introduce the "mscc,vsc7512-switch" compatible string as part of
   mscc,vsc7514-switch.yaml, but this will have "$ref: dsa.yaml#" (this
   will have to be referenced by full path because they are in different
   folders) instead of "ethernet-switch.yaml". Doing this will include
   the common bindings for a switch, plus the DSA specifics.

9. Optional: rework ti,cpsw-switch.yaml, microchip,lan966x-switch.yaml,
   microchip,sparx5-switch.yaml to have "$ref: ethernet-switch.yaml#"
   which should reduce some duplication in existing schemas.

10. Question for future support of VSC7514 in DSA mode: how do we decide
    whether to $ref: ethernet-switch.yaml or dsa.yaml? If the parent MFD
    node has a compatible string similar to "mscc,vsc7512", then use DSA,
    otherwise use generic ethernet-switch?
```

Colin Foster (6):
  dt-bindings: net: dsa: allow additional ethernet-port properties
  dt-bindings: net: dsa: qca8k: utilize shared dsa.yaml
  dt-bindings: net: dsa: mediatek,mt7530: remove unnecessary dsa-port
    reference
  dt-bindings: net: add generic ethernet-switch
  dt-bindings: net: add generic ethernet-switch-port binding
  dt-bindings: net: mscc,vsc7514-switch: utilize generic
    ethernet-switch.yaml

 .../devicetree/bindings/net/dsa/dsa-port.yaml | 27 +---------
 .../devicetree/bindings/net/dsa/dsa.yaml      | 26 +---------
 .../bindings/net/dsa/mediatek,mt7530.yaml     |  3 --
 .../devicetree/bindings/net/dsa/qca8k.yaml    | 18 +++----
 .../bindings/net/ethernet-switch-port.yaml    | 44 ++++++++++++++++
 .../bindings/net/ethernet-switch.yaml         | 51 +++++++++++++++++++
 .../bindings/net/mscc,vsc7514-switch.yaml     | 40 ++-------------
 MAINTAINERS                                   |  2 +
 8 files changed, 112 insertions(+), 99 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/ethernet-switch-port.yaml
 create mode 100644 Documentation/devicetree/bindings/net/ethernet-switch.yaml

-- 
2.25.1
#1 lore raw

PATCH v3 1/10 dt-bindings: net: dsa: sf2: fix brcm,use-bcm-hdr documentation

The property use-bcm-hdr was documented as an entry under the ports node for the bcm_sf2 DSA switch. This property is actually evaluated for each port. Correct the documentation to match the actual behavior and properly reference dsa-port.yaml for additional properties of the node.

---

v3
* New patch

---
 .../devicetree/bindings/net/dsa/brcm,sf2.yaml     | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/net/dsa/brcm,sf2.yaml +10 -5
index d159ac78cec1..eed16e216fb6 100644
@@ -85,11 +85,16 @@ properties:
   ports:
     type: object
 
-    properties:
-      brcm,use-bcm-hdr:
-        description: if present, indicates that the switch port has Broadcom
-          tags enabled (per-packet metadata)
-        type: boolean
+    patternProperties:
+      '^port@[0-9a-f]$':
+        $ref: dsa-port.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          brcm,use-bcm-hdr:
+            description: if present, indicates that the switch port has Broadcom
+              tags enabled (per-packet metadata)
+            type: boolean
 
 required:
   - reg
Signature · 1 line
2.25.1
Acked-by on v3 1/10
#2 lore raw

Re: [PATCH v3 net-next 01/10] dt-bindings: net: dsa: sf2: fix brcm,use-bcm-hdr documentation

Quoted 7 lines · Colin Foster

The property use-bcm-hdr was documented as an entry under the ports node for the bcm_sf2 DSA switch. This property is actually evaluated for each port. Correct the documentation to match the actual behavior and properly reference dsa-port.yaml for additional properties of the node.

Signature · 1 line
Florian
maintainer Reviewed-by on v3 1/10
#3 lore raw

Re: [PATCH v3 net-next 01/10] dt-bindings: net: dsa: sf2: fix brcm,use-bcm-hdr documentation

In reply to Colin Foster
Quoted 7 lines · Colin Foster

The property use-bcm-hdr was documented as an entry under the ports node for the bcm_sf2 DSA switch. This property is actually evaluated for each port. Correct the documentation to match the actual behavior and properly reference dsa-port.yaml for additional properties of the node.

Quoted 9 lines

---

v3
* New patch

---
 .../devicetree/bindings/net/dsa/brcm,sf2.yaml     | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
#4 lore raw

PATCH v3 2/10 dt-bindings: net: dsa: qca8k: remove address-cells and size-cells from switch node

In reply to Colin Foster

The children of the switch node don't have a unit address, and therefore should not need the #address-cells or #size-cells entries. Fix the example schemas accordingly.

---

v3
* New patch

---
 Documentation/devicetree/bindings/net/dsa/qca8k.yaml | 4 ----
 1 file changed, 4 deletions(-)
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +0 -4
index 978162df51f7..6fc9bc985726 100644
@@ -148,8 +148,6 @@ examples:
 
         switch@10 {
             compatible = "qca,qca8337";
-            #address-cells = <1>;
-            #size-cells = <0>;
             reset-gpios = <&gpio 42 GPIO_ACTIVE_LOW>;
             reg = <0x10>;
 
@@ -209,8 +207,6 @@ examples:
 
         switch@10 {
             compatible = "qca,qca8337";
-            #address-cells = <1>;
-            #size-cells = <0>;
             reset-gpios = <&gpio 42 GPIO_ACTIVE_LOW>;
             reg = <0x10>;
 
Signature · 1 line
2.25.1
Reviewed-by on v3 2/10
#5 lore raw

Re: [PATCH v3 net-next 02/10] dt-bindings: net: dsa: qca8k: remove address-cells and size-cells from switch node

Quoted 6 lines · Colin Foster

The children of the switch node don't have a unit address, and therefore should not need the #address-cells or #size-cells entries. Fix the example schemas accordingly.

Signature · 1 line
Florian
maintainer Reviewed-by on v3 2/10
#6 lore raw

Re: [PATCH v3 net-next 02/10] dt-bindings: net: dsa: qca8k: remove address-cells and size-cells from switch node

In reply to Colin Foster
Quoted 6 lines · Colin Foster

The children of the switch node don't have a unit address, and therefore should not need the #address-cells or #size-cells entries. Fix the example schemas accordingly.

Quoted 9 lines

---

v3
* New patch

---
 Documentation/devicetree/bindings/net/dsa/qca8k.yaml | 4 ----
 1 file changed, 4 deletions(-)
#7 lore raw

PATCH v3 3/10 dt-bindings: net: dsa: utilize base definitions for standard dsa switches

In reply to Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

---

v3
* New patch

---
 .../bindings/net/dsa/arrow,xrs700x.yaml       |  2 +-
 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  2 +-
 .../devicetree/bindings/net/dsa/dsa.yaml      | 19 ++++++++++++++++---
 .../net/dsa/hirschmann,hellcreek.yaml         |  2 +-
 .../bindings/net/dsa/mediatek,mt7530.yaml     |  2 +-
 .../bindings/net/dsa/microchip,ksz.yaml       |  2 +-
 .../bindings/net/dsa/microchip,lan937x.yaml   |  2 +-
 .../bindings/net/dsa/mscc,ocelot.yaml         |  2 +-
 .../bindings/net/dsa/nxp,sja1105.yaml         |  2 +-
 .../devicetree/bindings/net/dsa/realtek.yaml  |  2 +-
 .../bindings/net/dsa/renesas,rzn1-a5psw.yaml  |  2 +-
 11 files changed, 26 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml +1 -1
index 259a0c6547f3..8d5abb05abdf 100644
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Arrow SpeedChips XRS7000 Series Switch Device Tree Bindings
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 maintainers:
   - George McCollister <[email protected]>
Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml +1 -1
index 1219b830b1a4..f323fc01b224 100644
@@ -66,7 +66,7 @@ required:
   - reg
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
   - if:
       properties:
         compatible:
Documentation/devicetree/bindings/net/dsa/dsa.yaml +16 -3
index b9d48e357e77..bd1f0f7c14a8 100644
@@ -19,9 +19,6 @@ description:
 select: false
 
 properties:
-  $nodename:
-    pattern: "^(ethernet-)?switch(@.*)?$"
-
   dsa,member:
     minItems: 2
     maxItems: 2
@@ -58,4 +55,20 @@ oneOf:
 
 additionalProperties: true
 
+$defs:
+  base:
+    description: A DSA switch without any extra port properties
+    $ref: '#/'
+
+    patternProperties:
+      "^(ethernet-)?ports$":
+        type: object
+
+        patternProperties:
+          "^(ethernet-)?ports@[0-9]+$":
+            description: Ethernet switch ports
+            $ref: dsa-port.yaml#
+            unevaluatedProperties: false
+
+
 ...
Documentation/devicetree/bindings/net/dsa/hirschmann,hellcreek.yaml +1 -1
index 73b774eadd0b..e27b1619066f 100644
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Hirschmann Hellcreek TSN Switch Device Tree Bindings
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 maintainers:
   - Andrew Lunn <[email protected]>
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +1 -1
index f2e9ff3f580b..7df4ea1901ce 100644
@@ -238,7 +238,7 @@ $defs:
                       - sgmii
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
   - if:
       required:
         - mediatek,mcm
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +1 -1
index 4da75b1f9533..bfa2b76659c9 100644
@@ -11,7 +11,7 @@ maintainers:
   - Woojung Huh <[email protected]>
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
   - $ref: /schemas/spi/spi-peripheral-props.yaml#
 
 properties:
Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml +1 -1
index 630bf0f8294b..f4f9798addae 100644
@@ -10,7 +10,7 @@ maintainers:
   - [email protected]
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 properties:
   compatible:
Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml +1 -1
index 8d93ed9c172c..a7041ae4d811 100644
@@ -78,7 +78,7 @@ required:
   - reg
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
   - if:
       properties:
         compatible:
Documentation/devicetree/bindings/net/dsa/nxp,sja1105.yaml +1 -1
index 1e26d876d146..13a835af9468 100644
@@ -13,7 +13,7 @@ description:
   depends on the SPI bus master driver.
 
 allOf:
-  - $ref: "dsa.yaml#"
+  - $ref: dsa.yaml#/$defs/base
   - $ref: /schemas/spi/spi-peripheral-props.yaml#
 
 maintainers:
Documentation/devicetree/bindings/net/dsa/realtek.yaml +1 -1
index 1a7d45a8ad66..ad1793eba31a 100644
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Realtek switches for unmanaged switches
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 maintainers:
   - Linus Walleij <[email protected]>
Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml +1 -1
index 0a0d62b6c00e..9621f751a9dd 100644
@@ -14,7 +14,7 @@ description: |
   handles 4 ports + 1 CPU management port.
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 properties:
   compatible:
Signature · 1 line
2.25.1
Acked-by on v3 3/10
#8 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

Quoted 19 lines · Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

---

v3
* New patch

Quoted 13 lines
---
 .../bindings/net/dsa/arrow,xrs700x.yaml       |  2 +-
 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  2 +-
 .../devicetree/bindings/net/dsa/dsa.yaml      | 19 ++++++++++++++++---
 .../net/dsa/hirschmann,hellcreek.yaml         |  2 +-
 .../bindings/net/dsa/mediatek,mt7530.yaml     |  2 +-
 .../bindings/net/dsa/microchip,ksz.yaml       |  2 +-
 .../bindings/net/dsa/microchip,lan937x.yaml   |  2 +-
 .../bindings/net/dsa/mscc,ocelot.yaml         |  2 +-
 .../bindings/net/dsa/nxp,sja1105.yaml         |  2 +-
 .../devicetree/bindings/net/dsa/realtek.yaml  |  2 +-
 .../bindings/net/dsa/renesas,rzn1-a5psw.yaml  |  2 +-
 11 files changed, 26 insertions(+), 13 deletions(-)
Reviewed-by on v3 3/10
#9 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

In reply to Colin Foster
Quoted 7 lines · Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

Quoted 7 lines

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

This is neat.

Yours,
Linus Walleij

#10 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

Quoted 15 lines · Linus Walleij
Quoted 12 lines · Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

Quoted 5 lines
Quoted 2 lines

This is neat.

Thanks. All credit goes to Rob (except the bugs - those are mine)

Quoted 3 lines

Yours,
Linus Walleij

Reviewed-by on v3 3/10
#11 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

In reply to Colin Foster
Quoted 7 lines · Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

Quoted 7 lines

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

Signature · 1 line
Florian
maintainer
#12 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

In reply to Colin Foster
Quoted 11 lines · Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

You have this backwards. '$dsa.yaml#/$defs/base' can't be extended. Perhaps '$defs/ethernet-ports' would be a better name.

Quoted 63 lines

---

v3
* New patch

---
 .../bindings/net/dsa/arrow,xrs700x.yaml       |  2 +-
 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  2 +-
 .../devicetree/bindings/net/dsa/dsa.yaml      | 19 ++++++++++++++++---
 .../net/dsa/hirschmann,hellcreek.yaml         |  2 +-
 .../bindings/net/dsa/mediatek,mt7530.yaml     |  2 +-
 .../bindings/net/dsa/microchip,ksz.yaml       |  2 +-
 .../bindings/net/dsa/microchip,lan937x.yaml   |  2 +-
 .../bindings/net/dsa/mscc,ocelot.yaml         |  2 +-
 .../bindings/net/dsa/nxp,sja1105.yaml         |  2 +-
 .../devicetree/bindings/net/dsa/realtek.yaml  |  2 +-
 .../bindings/net/dsa/renesas,rzn1-a5psw.yaml  |  2 +-
 11 files changed, 26 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml +1 -1
index 259a0c6547f3..8d5abb05abdf 100644
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Arrow SpeedChips XRS7000 Series Switch Device Tree Bindings
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 maintainers:
   - George McCollister <[email protected]>
Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml +1 -1
index 1219b830b1a4..f323fc01b224 100644
@@ -66,7 +66,7 @@ required:
   - reg
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
   - if:
       properties:
         compatible:
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -3
index b9d48e357e77..bd1f0f7c14a8 100644
@@ -19,9 +19,6 @@ description:
 select: false
 
 properties:
-  $nodename:
-    pattern: "^(ethernet-)?switch(@.*)?$"
-
   dsa,member:
     minItems: 2
     maxItems: 2

Documentation/devicetree/bindings/net/dsa/dsa.yaml oneOf: · line 64

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +7 -0
@@ -58,4 +55,20 @@ oneOf:
 
 additionalProperties: true
 
+$defs:
+  base:
+    description: A DSA switch without any extra port properties
+    $ref: '#/'
+
+    patternProperties:
+      "^(ethernet-)?ports$":

This node at the top level needs 'additionalProperties: false' assuming we don't allow extra properties in 'ports' nodes. If we do, then we'll need to be able to reference the 'ports' schema to extend it like is done with dsa-ports.yaml.

Documentation/devicetree/bindings/net/dsa/dsa.yaml oneOf: · line 73

Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +9 -0
+        type: object
+
+        patternProperties:
+          "^(ethernet-)?ports@[0-9]+$":
+            description: Ethernet switch ports
+            $ref: dsa-port.yaml#
+            unevaluatedProperties: false
+
+

One blank line.

Quoted 1 line

...

#13 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

Hi Rob,

Quoted 8 lines · Rob Herring
Quoted 7 lines · Colin Foster

DSA switches can fall into one of two categories: switches where all ports follow standard '(ethernet-)?port' properties, and switches that have additional properties for the ports.

The scenario where DSA ports are all standardized can be handled by swtiches with a reference to 'dsa.yaml#'.

Quoted 7 lines
Quoted 4 lines

The scenario where DSA ports require additional properties can reference the new '$dsa.yaml#/$defs/base'. This will allow switches to reference these base defitions of the DSA switch, but add additional properties under the port nodes.

You have this backwards. '$dsa.yaml#/$defs/base' can't be extended. Perhaps '$defs/ethernet-ports' would be a better name.

Oops. I'll fix this up for next set.

Quoted 67 lines
Quoted 67 lines

---

v3
* New patch

---
 .../bindings/net/dsa/arrow,xrs700x.yaml       |  2 +-
 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  2 +-
 .../devicetree/bindings/net/dsa/dsa.yaml      | 19 ++++++++++++++++---
 .../net/dsa/hirschmann,hellcreek.yaml         |  2 +-
 .../bindings/net/dsa/mediatek,mt7530.yaml     |  2 +-
 .../bindings/net/dsa/microchip,ksz.yaml       |  2 +-
 .../bindings/net/dsa/microchip,lan937x.yaml   |  2 +-
 .../bindings/net/dsa/mscc,ocelot.yaml         |  2 +-
 .../bindings/net/dsa/nxp,sja1105.yaml         |  2 +-
 .../devicetree/bindings/net/dsa/realtek.yaml  |  2 +-
 .../bindings/net/dsa/renesas,rzn1-a5psw.yaml  |  2 +-
 11 files changed, 26 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml +1 -1
index 259a0c6547f3..8d5abb05abdf 100644
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Arrow SpeedChips XRS7000 Series Switch Device Tree Bindings
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
 
 maintainers:
   - George McCollister <[email protected]>
Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml +1 -1
index 1219b830b1a4..f323fc01b224 100644
@@ -66,7 +66,7 @@ required:
   - reg
 
 allOf:
-  - $ref: dsa.yaml#
+  - $ref: dsa.yaml#/$defs/base
   - if:
       properties:
         compatible:
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -3
index b9d48e357e77..bd1f0f7c14a8 100644
@@ -19,9 +19,6 @@ description:
 select: false
 
 properties:
-  $nodename:
-    pattern: "^(ethernet-)?switch(@.*)?$"
-
   dsa,member:
     minItems: 2
     maxItems: 2
@@ -58,4 +55,20 @@ oneOf:
 
 additionalProperties: true
 
Quoted 12 lines

Documentation/devicetree/bindings/net/dsa/dsa.yaml oneOf: · line 64

Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +7 -0
+$defs:
+  base:
+    description: A DSA switch without any extra port properties
+    $ref: '#/'
+
+    patternProperties:
+      "^(ethernet-)?ports$":

This node at the top level needs 'additionalProperties: false' assuming we don't allow extra properties in 'ports' nodes. If we do, then we'll need to be able to reference the 'ports' schema to extend it like is done with dsa-ports.yaml.

I'll double check if there's anything that adds any properties. If there is, would that be a separate file pair: "dsa-ports.yaml" and "ethernet-switch-ports.yaml"? Or do you think that could be contained in the existing dsa.yaml, ethernet-switch.yaml?

Quoted 12 lines

Documentation/devicetree/bindings/net/dsa/dsa.yaml oneOf: · line 73

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +9 -0
+        type: object
+
+        patternProperties:
+          "^(ethernet-)?ports@[0-9]+$":
+            description: Ethernet switch ports
+            $ref: dsa-port.yaml#
+            unevaluatedProperties: false
+
+

One blank line.

Oops again. Thanks for spotting this and for all your help on this!

Quoted 2 lines
Quoted 2 lines

...

#14 lore raw

Re: [PATCH v3 net-next 03/10] dt-bindings: net: dsa: utilize base definitions for standard dsa switches

Quoted 35 lines · Colin Foster

Hi Rob,

Quoted 19 lines · Rob Herring
Quoted 18 lines · Colin Foster
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -3
index b9d48e357e77..bd1f0f7c14a8 100644
@@ -19,9 +19,6 @@ description:
 select: false
 
 properties:
-  $nodename:
-    pattern: "^(ethernet-)?switch(@.*)?$"
-
   dsa,member:
     minItems: 2
     maxItems: 2
@@ -58,4 +55,20 @@ oneOf:
 
 additionalProperties: true
 
Quoted 12 lines

Documentation/devicetree/bindings/net/dsa/dsa.yaml oneOf: · line 64

Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +7 -0
+$defs:
+  base:
+    description: A DSA switch without any extra port properties
+    $ref: '#/'
+
+    patternProperties:
+      "^(ethernet-)?ports$":

This node at the top level needs 'additionalProperties: false' assuming we don't allow extra properties in 'ports' nodes. If we do, then we'll need to be able to reference the 'ports' schema to extend it like is done with dsa-ports.yaml.

Quoted 4 lines

I'll double check if there's anything that adds any properties. If there is, would that be a separate file pair: "dsa-ports.yaml" and "ethernet-switch-ports.yaml"? Or do you think that could be contained in the existing dsa.yaml, ethernet-switch.yaml?

I came up with this change. It also fixes my accidental 's' affix to ^(ethernet-)port@[0-9]+.

Documentation/devicetree/bindings/net/dsa/dsa.yaml +8 -2
index 616753ba85a2..c1900363a6ab 100644
@@ -41,12 +41,18 @@ $defs:
     patternProperties:
       "^(ethernet-)?ports$":
         type: object
+        additionalProperties: false
+
+        properties:
+          '#address-cells':
+            const: 1
+          '#size-cells':
+            const: 0
 
         patternProperties:
-          "^(ethernet-)?ports@[0-9]+$":
+          "^(ethernet-)?port@[0-9]+$":
             description: Ethernet switch ports
             $ref: dsa-port.yaml#
             unevaluatedProperties: false
 
-
 ...
#15 lore raw

PATCH v3 4/10 dt-bindings: net: dsa: allow additional ethernet-port properties

In reply to Colin Foster

Explicitly allow additional properties for both the ethernet-port and ethernet-ports properties. This specifically will allow the qca8k.yaml binding to use shared properties.

---

v2 -> v3
* No change

v1 -> v2
* New patch

---
 Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/dsa/dsa.yaml +3 -1
index bd1f0f7c14a8..87475c2ab092 100644
@@ -38,6 +38,8 @@ patternProperties:
       '#size-cells':
         const: 0
 
+    additionalProperties: true
+
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
         type: object
@@ -45,7 +47,7 @@ patternProperties:
 
         $ref: dsa-port.yaml#
 
-        unevaluatedProperties: false
+        unevaluatedProperties: true
 
 oneOf:
   - required:
Signature · 1 line
2.25.1
Reviewed-by on v3 4/10
#16 lore raw

Re: [PATCH v3 net-next 04/10] dt-bindings: net: dsa: allow additional ethernet-port properties

Quoted 5 lines · Colin Foster

Explicitly allow additional properties for both the ethernet-port and ethernet-ports properties. This specifically will allow the qca8k.yaml binding to use shared properties.

Signature · 1 line
Florian
maintainer
#17 lore raw

Re: [PATCH v3 net-next 04/10] dt-bindings: net: dsa: allow additional ethernet-port properties

In reply to Colin Foster
Quoted 22 lines · Colin Foster

Explicitly allow additional properties for both the ethernet-port and ethernet-ports properties. This specifically will allow the qca8k.yaml binding to use shared properties.

---

v2 -> v3
* No change

v1 -> v2
* New patch

---
 Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
index bd1f0f7c14a8..87475c2ab092 100644

Documentation/devicetree/bindings/net/dsa/dsa.yaml patternProperties: · line 42

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +2 -0
@@ -38,6 +38,8 @@ patternProperties:
       '#size-cells':
         const: 0
 
+    additionalProperties: true
+

Where then do we restrict adding properties to ethernet-ports nodes?

Documentation/devicetree/bindings/net/dsa/dsa.yaml patternProperties: · line 50

Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +1 -1
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
         type: object
@@ -45,7 +47,7 @@ patternProperties:
 
         $ref: dsa-port.yaml#
 
-        unevaluatedProperties: false
+        unevaluatedProperties: true

Same question for ethernet-port nodes.

Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
 oneOf:
   - required:
Signature · 1 line
2.25.1
#18 lore raw

Re: [PATCH v3 net-next 04/10] dt-bindings: net: dsa: allow additional ethernet-port properties

Quoted 36 lines · Rob Herring
Quoted 22 lines · Colin Foster

Explicitly allow additional properties for both the ethernet-port and ethernet-ports properties. This specifically will allow the qca8k.yaml binding to use shared properties.

---

v2 -> v3
* No change

v1 -> v2
* New patch

---
 Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
index bd1f0f7c14a8..87475c2ab092 100644

Documentation/devicetree/bindings/net/dsa/dsa.yaml patternProperties: · line 42

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +2 -0
@@ -38,6 +38,8 @@ patternProperties:
       '#size-cells':
         const: 0
 
+    additionalProperties: true
+

Where then do we restrict adding properties to ethernet-ports nodes?

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
         type: object
@@ -45,7 +47,7 @@ patternProperties:
 
Quoted 6 lines

Documentation/devicetree/bindings/net/dsa/dsa.yaml patternProperties: · line 50

Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +1 -1
         $ref: dsa-port.yaml#
 
-        unevaluatedProperties: false
+        unevaluatedProperties: true

Same question for ethernet-port nodes.

For ethernet-port nodes, the qca8k has unevaluatedProperties: false. But the fact that you're asking this question means I probably misunderstood something...

For the ethernet-ports node, I'm curious if my other follow-up answers that question where I realized dsa.yaml should, under the base definition, have additionalPrpoerties: false. But again, my guess is that isn't the case.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
 oneOf:
   - required:
Signature · 1 line
2.25.1
maintainer
#19 lore raw

Re: [PATCH v3 net-next 04/10] dt-bindings: net: dsa: allow additional ethernet-port properties

Quoted 39 lines · Colin Foster
Quoted 38 lines · Rob Herring
Quoted 22 lines · Colin Foster

Explicitly allow additional properties for both the ethernet-port and ethernet-ports properties. This specifically will allow the qca8k.yaml binding to use shared properties.

---

v2 -> v3
* No change

v1 -> v2
* New patch

---
 Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
index bd1f0f7c14a8..87475c2ab092 100644

Documentation/devicetree/bindings/net/dsa/dsa.yaml patternProperties: · line 42

Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +2 -0
@@ -38,6 +38,8 @@ patternProperties:
       '#size-cells':
         const: 0
 
+    additionalProperties: true
+

Where then do we restrict adding properties to ethernet-ports nodes?

Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +0 -0
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
         type: object
@@ -45,7 +47,7 @@ patternProperties:
 
         $ref: dsa-port.yaml#
 
Quoted 8 lines
Quoted 4 lines

Documentation/devicetree/bindings/net/dsa/dsa.yaml patternProperties: · line 50

Quoted 2 lines
Documentation/devicetree/bindings/net/dsa/dsa.yaml +1 -1
-        unevaluatedProperties: false
+        unevaluatedProperties: true

Same question for ethernet-port nodes.

For ethernet-port nodes, the qca8k has unevaluatedProperties: false. But the fact that you're asking this question means I probably misunderstood something...

The above is the case where you aren't adding extra properties (IIRC), so 'unevaluatedProperties: false' should be correct.

'unevaluatedProperties: true' is never correct in bindings. If you ref a schema that sets it to true, you can't override it.

So qca8k, should reference dsa-port.yaml, define its extra properties and set 'unevaluatedProperties: false'.

Quoted 4 lines

For the ethernet-ports node, I'm curious if my other follow-up answers that question where I realized dsa.yaml should, under the base definition, have additionalPrpoerties: false. But again, my guess is that isn't the case.

That one looks correct.

Rob

#20 lore raw

PATCH v3 5/10 dt-bindings: net: dsa: qca8k: utilize shared dsa.yaml

In reply to Colin Foster

The dsa.yaml binding contains duplicated bindings for address and size cells, as well as the reference to dsa-port.yaml. Instead of duplicating this information, remove the reference to dsa-port.yaml and include the full reference to dsa.yaml.

---

v2 -> v3
* Remove #address-cells and #size-cells from v2. The examples were incorrect and fixed elsewhere.
* Remove erroneous unevaluatedProperties: true under Ethernet Port.
* Add back ref: dsa-port.yaml#.

v1 -> v2
* Add #address-cells and #size-cells to the switch layer. They aren't part of dsa.yaml.
* Add unevaluatedProperties: true to the ethernet-port layer so it can correctly read properties from dsa.yaml.

---
 Documentation/devicetree/bindings/net/dsa/qca8k.yaml | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +3 -8
index 6fc9bc985726..93a9ddebcac8 100644
@@ -66,20 +66,15 @@ properties:
                  With the legacy mapping the reg corresponding to the internal
                  mdio is the switch reg with an offset of -1.
 
+$ref: "dsa.yaml#"
+
 patternProperties:
   "^(ethernet-)?ports$":
     type: object
-    properties:
-      '#address-cells':
-        const: 1
-      '#size-cells':
-        const: 0
-
     patternProperties:
       "^(ethernet-)?port@[0-6]$":
         type: object
         description: Ethernet switch ports
-
         $ref: dsa-port.yaml#
 
         properties:
@@ -116,7 +111,7 @@ required:
   - compatible
   - reg
 
-additionalProperties: true
+unevaluatedProperties: false
 
 examples:
   - |
Signature · 1 line
2.25.1
Reviewed-by on v3 5/10
#21 lore raw

Re: [PATCH v3 net-next 05/10] dt-bindings: net: dsa: qca8k: utilize shared dsa.yaml

Quoted 7 lines · Colin Foster

The dsa.yaml binding contains duplicated bindings for address and size cells, as well as the reference to dsa-port.yaml. Instead of duplicating this information, remove the reference to dsa-port.yaml and include the full reference to dsa.yaml.

Signature · 1 line
Florian
maintainer
#22 lore raw

Re: [PATCH v3 net-next 05/10] dt-bindings: net: dsa: qca8k: utilize shared dsa.yaml

In reply to Colin Foster
Quoted 40 lines · Colin Foster

The dsa.yaml binding contains duplicated bindings for address and size cells, as well as the reference to dsa-port.yaml. Instead of duplicating this information, remove the reference to dsa-port.yaml and include the full reference to dsa.yaml.

---

v2 -> v3
* Remove #address-cells and #size-cells from v2. The examples were incorrect and fixed elsewhere.
* Remove erroneous unevaluatedProperties: true under Ethernet Port.
* Add back ref: dsa-port.yaml#.

v1 -> v2
* Add #address-cells and #size-cells to the switch layer. They aren't part of dsa.yaml.
* Add unevaluatedProperties: true to the ethernet-port layer so it can correctly read properties from dsa.yaml.

---
 Documentation/devicetree/bindings/net/dsa/qca8k.yaml | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +2 -2
index 6fc9bc985726..93a9ddebcac8 100644
@@ -66,20 +66,15 @@ properties:
                  With the legacy mapping the reg corresponding to the internal
                  mdio is the switch reg with an offset of -1.
 
+$ref: "dsa.yaml#"
+
 patternProperties:
   "^(ethernet-)?ports$":
     type: object
-    properties:
-      '#address-cells':

Documentation/devicetree/bindings/net/dsa/qca8k.yaml properties: · line 78

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +0 -5
-        const: 1
-      '#size-cells':
-        const: 0
-
     patternProperties:
       "^(ethernet-)?port@[0-6]$":
         type: object
         description: Ethernet switch ports
-
         $ref: dsa-port.yaml#

So here you need 'unevaluatedProperties: false'.

unevaluatedProperties only applies to the properties defined in a single node level, and child nodes properties from 2 schemas can't 'see' each other. IOW, what dsa.yaml has in child nodes has no effect on this node.

Documentation/devicetree/bindings/net/dsa/qca8k.yaml required: · line 114

Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +1 -1
         properties:
@@ -116,7 +111,7 @@ required:
   - compatible
   - reg
 
-additionalProperties: true
+unevaluatedProperties: false

So this has no effect on anything within "^(ethernet-)?port@[0-6]$" and below.

Rob

#23 lore raw

Re: [PATCH v3 net-next 05/10] dt-bindings: net: dsa: qca8k: utilize shared dsa.yaml

Hi Rob,

Quoted 54 lines · Rob Herring
Quoted 40 lines · Colin Foster

The dsa.yaml binding contains duplicated bindings for address and size cells, as well as the reference to dsa-port.yaml. Instead of duplicating this information, remove the reference to dsa-port.yaml and include the full reference to dsa.yaml.

---

v2 -> v3
* Remove #address-cells and #size-cells from v2. The examples were incorrect and fixed elsewhere.
* Remove erroneous unevaluatedProperties: true under Ethernet Port.
* Add back ref: dsa-port.yaml#.

v1 -> v2
* Add #address-cells and #size-cells to the switch layer. They aren't part of dsa.yaml.
* Add unevaluatedProperties: true to the ethernet-port layer so it can correctly read properties from dsa.yaml.

---
 Documentation/devicetree/bindings/net/dsa/qca8k.yaml | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +2 -2
index 6fc9bc985726..93a9ddebcac8 100644
@@ -66,20 +66,15 @@ properties:
                  With the legacy mapping the reg corresponding to the internal
                  mdio is the switch reg with an offset of -1.
 
+$ref: "dsa.yaml#"
+
 patternProperties:
   "^(ethernet-)?ports$":
     type: object
-    properties:
-      '#address-cells':

Documentation/devicetree/bindings/net/dsa/qca8k.yaml properties: · line 78

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +0 -5
-        const: 1
-      '#size-cells':
-        const: 0
-
     patternProperties:
       "^(ethernet-)?port@[0-6]$":
         type: object
         description: Ethernet switch ports
-
         $ref: dsa-port.yaml#

So here you need 'unevaluatedProperties: false'.

Quoted 3 lines

unevaluatedProperties only applies to the properties defined in a single node level, and child nodes properties from 2 schemas can't 'see' each other. IOW, what dsa.yaml has in child nodes has no effect on this node.

I'm buttoning up v4 right now and removing this line deletion.
unevaluatedProperties: false exists under the etherent-port node, just at the end of the properties list.

Since the etherent-ports node in net/dsa/dsa.yaml has
unevaluatedProperties: false, I understand that isn't necessary here.

Quoted 14 lines

Documentation/devicetree/bindings/net/dsa/qca8k.yaml required: · line 114

Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +1 -1
         properties:
@@ -116,7 +111,7 @@ required:
   - compatible
   - reg
 
-additionalProperties: true
+unevaluatedProperties: false

So this has no effect on anything within "^(ethernet-)?port@[0-6]$" and below.

Rob

#24 lore raw

PATCH v3 6/10 dt-bindings: net: dsa: mediatek,mt7530: fix port description location

In reply to Colin Foster

The description property was located where it applies to every port, not just ports 5 or 6 (CPU ports). Fix this description.

---

v2 -> v3
* New patch.

---
 .../bindings/net/dsa/mediatek,mt7530.yaml          | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +3 -11
index 7df4ea1901ce..415e6c40787e 100644
@@ -156,17 +156,6 @@ patternProperties:
 
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
-        type: object
-        description: Ethernet switch ports
-
-        unevaluatedProperties: false
-
-        properties:
-          reg:
-            description:
-              Port address described must be 5 or 6 for CPU port and from 0 to 5
-              for user ports.
-
         allOf:
           - $ref: dsa-port.yaml#
           - if:
@@ -174,6 +163,9 @@ patternProperties:
             then:
               properties:
                 reg:
+                  description:
+                    Port address described must be 5 or 6 for CPU port and from
+                    0 to 5 for user ports
                   enum:
                     - 5
                     - 6
Signature · 1 line
2.25.1
#25 lore raw

Re: [PATCH v3 net-next 06/10] dt-bindings: net: dsa: mediatek,mt7530: fix port description location

Quoted 2 lines · Colin Foster

The description property was located where it applies to every port, not just ports 5 or 6 (CPU ports). Fix this description.

I'm not sure I understand. The description for reg does apply to every port. Both CPU ports and user ports are described. This patch moves the description to under CPU ports only.

Quoted 17 lines

---

v2 -> v3
* New patch.

---
  .../bindings/net/dsa/mediatek,mt7530.yaml          | 14 +++-----------
  1 file changed, 3 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -0
index 7df4ea1901ce..415e6c40787e 100644

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml patternProperties: · line 163

Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -5
@@ -156,17 +156,6 @@ patternProperties:
 
      patternProperties:
        "^(ethernet-)?port@[0-9]+$":
-        type: object
-        description: Ethernet switch ports
-
-        unevaluatedProperties: false
-

Would be nice to mention these being removed on the patch log. Or remove them while doing ("dt-bindings: net: dsa: utilize base definitions for standard dsa switches").

Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -6
-        properties:
-          reg:
-            description:
-              Port address described must be 5 or 6 for CPU port and from 0 to 5
-              for user ports.
-
          allOf:
            - $ref: dsa-port.yaml#
            - if:

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml patternProperties: · line 171

Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +3 -0
@@ -174,6 +163,9 @@ patternProperties:
              then:
                properties:
                  reg:
+                  description:
+                    Port address described must be 5 or 6 for CPU port and from
+                    0 to 5 for user ports
                    enum:
                      - 5
                      - 6

Thank you for your efforts.

Arınç

#26 lore raw

Re: [PATCH v3 net-next 06/10] dt-bindings: net: dsa: mediatek,mt7530: fix port description location

Hi Arınç,

Quoted 7 lines · Arınç ÜNAL
Quoted 2 lines · Colin Foster

The description property was located where it applies to every port, not just ports 5 or 6 (CPU ports). Fix this description.

I'm not sure I understand. The description for reg does apply to every port. Both CPU ports and user ports are described. This patch moves the description to under CPU ports only.

You're right. I misinterpreted what Rob suggested, so the commit message isn't correct. I see now that reg applies to every port, but is only restricted for CPU ports (if: required: [ ethernet ]). I'll clean this message up.

Quoted 13 lines
Quoted 13 lines

---

v2 -> v3
* New patch.

---
  .../bindings/net/dsa/mediatek,mt7530.yaml          | 14 +++-----------
  1 file changed, 3 insertions(+), 11 deletions(-)
Quoted 16 lines

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml patternProperties: · line 162

Quoted 12 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -5
index 7df4ea1901ce..415e6c40787e 100644
@@ -156,17 +156,6 @@ patternProperties:
      patternProperties:
        "^(ethernet-)?port@[0-9]+$":
-        type: object
-        description: Ethernet switch ports
-
-        unevaluatedProperties: false
-

Would be nice to mention these being removed on the patch log. Or remove them while doing ("dt-bindings: net: dsa: utilize base definitions for standard dsa switches").

Agreed. My gut is telling me this wants to be in a separate patch from the generic DSA base definitions patch... but I can't say why for certain. I'll plan to move these to the patch you suggest and add a comment in there about how the type, description, and unevaluatedProperties of mediatek,mt7530 is no longer needed as a result? Keep this patch as more of a "restrict custom port description to CPU ports only" patch?

I also see that ("dt-bindings: net: dsa: mediatek,mt7530: remove unnecessary dsa-port reference") should probably be earlier in this patch set. I'll plan to move that earlier in the series, before ("dt-bindings: net: dsa:
utilize base definitions for standard dsa switches").

Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -6
-        properties:
-          reg:
-            description:
-              Port address described must be 5 or 6 for CPU port and from 0 to 5
-              for user ports.
-
          allOf:
            - $ref: dsa-port.yaml#
            - if:
@@ -174,6 +163,9 @@ patternProperties:
              then:
                properties:
                  reg:
Quoted 8 lines

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml patternProperties: · line 171

Quoted 6 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +3 -0
+                  description:
+                    Port address described must be 5 or 6 for CPU port and from
+                    0 to 5 for user ports
                    enum:
                      - 5
                      - 6

Thank you for your efforts.

I greatly appreciate your help and feedback!

Quoted 2 lines

Arınç

#27 lore raw

Re: [PATCH v3 net-next 06/10] dt-bindings: net: dsa: mediatek,mt7530: fix port description location

Hey Colin,

Quoted 46 lines · Colin Foster

Hi Arınç,

Quoted 7 lines · Arınç ÜNAL
Quoted 2 lines · Colin Foster

The description property was located where it applies to every port, not just ports 5 or 6 (CPU ports). Fix this description.

I'm not sure I understand. The description for reg does apply to every port. Both CPU ports and user ports are described. This patch moves the description to under CPU ports only.

You're right. I misinterpreted what Rob suggested, so the commit message isn't correct. I see now that reg applies to every port, but is only restricted for CPU ports (if: required: [ ethernet ]). I'll clean this message up.

Quoted 13 lines
Quoted 13 lines

---

v2 -> v3
* New patch.

---
   .../bindings/net/dsa/mediatek,mt7530.yaml          | 14 +++-----------
   1 file changed, 3 insertions(+), 11 deletions(-)
Quoted 16 lines

Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml patternProperties: · line 162

Quoted 12 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -5
index 7df4ea1901ce..415e6c40787e 100644
@@ -156,17 +156,6 @@ patternProperties:
       patternProperties:
         "^(ethernet-)?port@[0-9]+$":
-        type: object
-        description: Ethernet switch ports
-
-        unevaluatedProperties: false
-

Would be nice to mention these being removed on the patch log. Or remove them while doing ("dt-bindings: net: dsa: utilize base definitions for standard dsa switches").

Quoted 3 lines

Agreed. My gut is telling me this wants to be in a separate patch from the generic DSA base definitions patch... but I can't say why for certain. I'll plan to move these to the patch you suggest and add a comment

If I understand correctly, with ("dt-bindings: net: dsa: utilize base definitions for standard dsa switches"), these properties are now defined on dsa.yaml#/$defs/base and no longer needed to be defined here since mediatek,mt7530.yaml was also made to refer to it. It'd make sense to remove these properties there as there's continuity.

Quoted 3 lines

in there about how the type, description, and unevaluatedProperties of mediatek,mt7530 is no longer needed as a result? Keep this patch as more of a "restrict custom port description to CPU ports only" patch?

I'd say get rid of this patch and do above. Trust your gut though. ;P

Arınç

#28 lore raw

PATCH v3 7/10 dt-bindings: net: dsa: mediatek,mt7530: remove unnecessary dsa-port reference

In reply to Colin Foster

dsa.yaml contains a reference to dsa-port.yaml, so a duplicate reference to the binding isn't necessary. Remove this unnecessary reference.

---

v2 -> v3
* Keep "unevaluatedProperties: false" under the switch ports node.

v1 -> v2
* Add Reviewed-by

---
 Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml | 1 -
 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0 -1
index 415e6c40787e..44608a9b244e 100644
@@ -157,7 +157,6 @@ patternProperties:
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
         allOf:
-          - $ref: dsa-port.yaml#
           - if:
               required: [ ethernet ]
             then:
Signature · 1 line
2.25.1
Reviewed-by on v3 7/10
#29 lore raw

Re: [PATCH v3 net-next 07/10] dt-bindings: net: dsa: mediatek,mt7530: remove unnecessary dsa-port reference

Quoted 6 lines · Colin Foster

dsa.yaml contains a reference to dsa-port.yaml, so a duplicate reference to the binding isn't necessary. Remove this unnecessary reference.

Signature · 1 line
Florian
#30 lore raw

PATCH v3 8/10 dt-bindings: net: add generic ethernet-switch

In reply to Colin Foster

The dsa.yaml bindings had references that can apply to non-dsa switches. To prevent duplication of this information, keep the dsa-specific information inside dsa.yaml and move the remaining generic information to the newly created ethernet-switch.yaml.

---

v2 -> v3
* Change ethernet-switch.yaml title from "Ethernet Switch Device Tree Bindings" to "Generic Ethernet Switch"
* Rework ethernet-switch.yaml description
* Add base defs structure for switches that don't have any additional properties.
* Add "additionalProperties: true" under "^(ethernet-)?ports$" node
* Correct port reference from /schemas/net/dsa/dsa-port.yaml# to ethernet-controller.yaml#

v1 -> v2
* No net change, but deletions from dsa.yaml included the changes for "addionalProperties: true" under ports and "unevaluatedProperties:
true" under port.

---
 .../devicetree/bindings/net/dsa/dsa.yaml      | 28 +-------
 .../bindings/net/ethernet-switch.yaml         | 64 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 3 files changed, 67 insertions(+), 26 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/ethernet-switch.yaml
Documentation/devicetree/bindings/net/dsa/dsa.yaml +2 -26
index 87475c2ab092..616753ba85a2 100644
@@ -18,6 +18,8 @@ description:
 
 select: false
 
+$ref: "/schemas/net/ethernet-switch.yaml#"
+
 properties:
   dsa,member:
     minItems: 2
@@ -29,32 +31,6 @@ properties:
       (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
-
-    additionalProperties: true
-
-    patternProperties:
-      "^(ethernet-)?port@[0-9]+$":
-        type: object
-        description: Ethernet switch ports
-
-        $ref: dsa-port.yaml#
-
-        unevaluatedProperties: true
-
-oneOf:
-  - required:
-      - ports
-  - required:
-      - ethernet-ports
-
 additionalProperties: true
 
 $defs:
Documentation/devicetree/bindings/net/ethernet-switch.yaml new file +64 -0

64 lines not on this page · raw message

MAINTAINERS +1 -0
index 9b12d715fc66..3077c5af6072 100644
@@ -14332,6 +14332,7 @@ M:	Florian Fainelli <[email protected]>
 M:	Vladimir Oltean <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/dsa/
+F:	Documentation/devicetree/bindings/net/ethernet-switch.yaml
 F:	drivers/net/dsa/
 F:	include/linux/dsa/
 F:	include/linux/platform_data/dsa.h
Signature · 1 line
2.25.1
Reviewed-by on v3 8/10
#31 lore raw

Re: [PATCH v3 net-next 08/10] dt-bindings: net: add generic ethernet-switch

Quoted 7 lines · Colin Foster

The dsa.yaml bindings had references that can apply to non-dsa switches. To prevent duplication of this information, keep the dsa-specific information inside dsa.yaml and move the remaining generic information to the newly created ethernet-switch.yaml.

Signature · 1 line
Florian
#32 lore raw

PATCH v3 9/10 dt-bindings: net: add generic ethernet-switch-port binding

In reply to Colin Foster

The dsa-port.yaml binding had several references that can be common to all ethernet ports, not just dsa-specific ones. Break out the generic bindings to ethernet-switch-port.yaml they can be used by non-dsa drivers.

---

v2 -> v3
* Change dsa-port title from "DSA Switch port Device Tree Bindings" to "Generic DSA Switch port"
* Add reference to ethernet-switch-port.yaml# in dsa-port.yaml
* Change title of ethernet-switch-port.yaml from "Ethernet Switch port Device Tree Bindings" to "Generic Ethernet Switch port"
* Remove most properties from ethernet-switch-port.yaml. They're all in ethernet-controller, and are all allowed.
* ethernet-switch.yaml now only references ethernet-switch-port.yaml# under the port node.

v1 -> v2
* Remove accidental addition of
"$ref: /schemas/net/ethernet-switch-port.yaml" which should be kept out of dsa-port so that it doesn't get referenced multiple times through both ethernet-switch and dsa-port.

---
 .../devicetree/bindings/net/dsa/dsa-port.yaml | 24 ++----------------
 .../bindings/net/ethernet-switch-port.yaml    | 25 +++++++++++++++++++
 .../bindings/net/ethernet-switch.yaml         |  4 +--
 MAINTAINERS                                   |  1 +
 4 files changed, 29 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/ethernet-switch-port.yaml
Documentation/devicetree/bindings/net/dsa/dsa-port.yaml +2 -22
index 9abb8eba5fad..5b457f41273a 100644
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/net/dsa/dsa-port.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Ethernet Switch port Device Tree Bindings
+title: Generic DSA Switch port
 
 maintainers:
   - Andrew Lunn <[email protected]>
@@ -14,8 +14,7 @@ maintainers:
 description:
   Ethernet switch port Description
 
-allOf:
-  - $ref: /schemas/net/ethernet-controller.yaml#
+$ref: /schemas/net/ethernet-switch-port.yaml#
 
 properties:
   reg:
@@ -58,25 +57,6 @@ properties:
       - rtl8_4t
       - seville
 
-  phy-handle: true
-
-  phy-mode: true
-
-  fixed-link: true
-
-  mac-address: true
-
-  sfp: true
-
-  managed: true
-
-  rx-internal-delay-ps: true
-
-  tx-internal-delay-ps: true
-
-required:
-  - reg
-
 # CPU and DSA ports must have phylink-compatible link descriptions
 if:
   oneOf:
Documentation/devicetree/bindings/net/ethernet-switch-port.yaml new file +25 -0
new file mode 100644
index 000000000000..3d7da6916fb8
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/ethernet-switch-port.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic Ethernet Switch port
+
+maintainers:
+  - Andrew Lunn <[email protected]>
+  - Florian Fainelli <[email protected]>
+  - Vivien Didelot <[email protected]>
+
+description:
+  Ethernet switch port Description
+
+$ref: ethernet-controller.yaml#
+
+properties:
+  reg:
+    description: Port number
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/net/ethernet-switch.yaml +1 -3
index d5bf9a2d8083..ef7503eba95c 100644
@@ -40,8 +40,6 @@ patternProperties:
         type: object
         description: Ethernet switch ports
 
-        $ref: ethernet-controller.yaml#
-
 oneOf:
   - required:
       - ports
@@ -58,7 +56,7 @@ $defs:
     patternProperties:
       "^(ethernet-)?port@[0-9]+$":
         description: Ethernet switch ports
-        $ref: ethernet-controller.yaml#
+        $ref: ethernet-switch-port.yaml#
         unevaluatedProperties: false
 
 ...
MAINTAINERS +1 -0
index 3077c5af6072..59674eb07491 100644
@@ -14332,6 +14332,7 @@ M:	Florian Fainelli <[email protected]>
 M:	Vladimir Oltean <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/dsa/
+F:	Documentation/devicetree/bindings/net/ethernet-switch-port.yaml
 F:	Documentation/devicetree/bindings/net/ethernet-switch.yaml
 F:	drivers/net/dsa/
 F:	include/linux/dsa/
Signature · 1 line
2.25.1
Reviewed-by on v3 9/10
#33 lore raw

Re: [PATCH v3 net-next 09/10] dt-bindings: net: add generic ethernet-switch-port binding

Quoted 6 lines · Colin Foster

The dsa-port.yaml binding had several references that can be common to all ethernet ports, not just dsa-specific ones. Break out the generic bindings to ethernet-switch-port.yaml they can be used by non-dsa drivers.

Signature · 1 line
Florian
#34 lore raw

PATCH v3 10/10 dt-bindings: net: mscc,vsc7514-switch: utilize generic ethernet-switch.yaml

In reply to Colin Foster

Several bindings for ethernet switches are available for non-dsa switches by way of ethernet-switch.yaml. Remove these duplicate entries and utilize the common bindings for the VSC7514.

---

v2 -> v3:
* Reference ethernet-switch-port.yaml# instead of ethernet-controller
* Undo the addition of "unevaluatedProperties: true" from v2. Those were only added because of my misunderstandings.
* Keep #address-cells and #size-cells in the ports node.

v1 -> v2:
* Fix "$ref: ethernet-switch.yaml" placement. Oops.
* Add "unevaluatedProperties: true" to ethernet-ports layer so it can correctly read into ethernet-switch.yaml
* Add "unevaluatedProperties: true" to ethernet-port layer so it can correctly read into ethernet-controller.yaml

---
 .../bindings/net/mscc,vsc7514-switch.yaml     | 31 ++-----------------
 1 file changed, 3 insertions(+), 28 deletions(-)
Documentation/devicetree/bindings/net/mscc,vsc7514-switch.yaml +3 -28
index ee0a504bdb24..5ffe831e59e4 100644
@@ -18,10 +18,9 @@ description: |
   packets using CPU. Additionally, PTP is supported as well as FDMA for faster
   packet extraction/injection.
 
-properties:
-  $nodename:
-    pattern: "^switch@[0-9a-f]+$"
+$ref: ethernet-switch.yaml#
 
+properties:
   compatible:
     const: mscc,vsc7514-switch
 
@@ -100,35 +99,11 @@ properties:
 
     patternProperties:
       "^port@[0-9a-f]+$":
-        type: object
-        description: Ethernet ports handled by the switch
 
-        $ref: ethernet-controller.yaml#
+        $ref: ethernet-switch-port.yaml#
 
         unevaluatedProperties: false
 
-        properties:
-          reg:
-            description: Switch port number
-
-          phy-handle: true
-
-          phy-mode: true
-
-          fixed-link: true
-
-          mac-address: true
-
-        required:
-          - reg
-          - phy-mode
-
-        oneOf:
-          - required:
-              - phy-handle
-          - required:
-              - fixed-link
-
 required:
   - compatible
   - reg
Signature · 1 line
2.25.1
Reviewed-by on v3 10/10
#35 lore raw

Re: [PATCH v3 net-next 10/10] dt-bindings: net: mscc,vsc7514-switch: utilize generic ethernet-switch.yaml

Quoted 6 lines · Colin Foster

Several bindings for ethernet switches are available for non-dsa switches by way of ethernet-switch.yaml. Remove these duplicate entries and utilize the common bindings for the VSC7514.

Signature · 1 line
Florian