2022-11-27 23:00:08

by Colin Foster

[permalink] [raw]
Subject: [PATCH v3 net-next 00/10] 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

--
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


2022-11-27 23:01:34

by Colin Foster

[permalink] [raw]
Subject: [PATCH v3 net-next 01/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.

Suggested-by: Rob Herring <[email protected]>
Signed-off-by: Colin Foster <[email protected]>
---

v3
* New patch

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

diff --git a/Documentation/devicetree/bindings/net/dsa/brcm,sf2.yaml b/Documentation/devicetree/bindings/net/dsa/brcm,sf2.yaml
index d159ac78cec1..eed16e216fb6 100644
--- a/Documentation/devicetree/bindings/net/dsa/brcm,sf2.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/brcm,sf2.yaml
@@ -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
--
2.25.1

2022-11-27 23:02:36

by Colin Foster

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

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.

Signed-off-by: Colin Foster <[email protected]>
Suggested-by: Vladimir Oltean <[email protected]>
---

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

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
index 87475c2ab092..616753ba85a2 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
@@ -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:
diff --git a/Documentation/devicetree/bindings/net/ethernet-switch.yaml b/Documentation/devicetree/bindings/net/ethernet-switch.yaml
new file mode 100644
index 000000000000..d5bf9a2d8083
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ethernet-switch.yaml
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/ethernet-switch.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic Ethernet Switch
+
+maintainers:
+ - Andrew Lunn <[email protected]>
+ - Florian Fainelli <[email protected]>
+ - Vivien Didelot <[email protected]>
+
+description:
+ Ethernet switches are multi-port Ethernet controllers. Each port has
+ its own number and is represented as its own Ethernet controller.
+ The minimum required functionality is to pass packets to software.
+ They may or may not be able to forward packets automonously between
+ ports.
+
+select: false
+
+properties:
+ $nodename:
+ pattern: "^(ethernet-)?switch(@.*)?$"
+
+patternProperties:
+ "^(ethernet-)?ports$":
+ type: object
+ additionalProperties: false
+
+ properties:
+ '#address-cells':
+ const: 1
+ '#size-cells':
+ const: 0
+
+ patternProperties:
+ "^(ethernet-)?port@[0-9]+$":
+ type: object
+ description: Ethernet switch ports
+
+ $ref: ethernet-controller.yaml#
+
+oneOf:
+ - required:
+ - ports
+ - required:
+ - ethernet-ports
+
+additionalProperties: true
+
+$defs:
+ base:
+ description: An ethernet switch without any extra port properties
+ $ref: '#/'
+
+ patternProperties:
+ "^(ethernet-)?port@[0-9]+$":
+ description: Ethernet switch ports
+ $ref: ethernet-controller.yaml#
+ unevaluatedProperties: false
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 9b12d715fc66..3077c5af6072 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
--
2.25.1

2022-11-27 23:04:46

by Colin Foster

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

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.

Signed-off-by: Colin Foster <[email protected]>
Suggested-by: Vladimir Oltean <[email protected]>
---

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(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
index 6fc9bc985726..93a9ddebcac8 100644
--- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
@@ -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:
- |
--
2.25.1

2022-11-27 23:04:50

by Colin Foster

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

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

Suggested-by: Rob Herring <[email protected]>
Signed-off-by: Colin Foster <[email protected]>
---

v2 -> v3
* New patch.

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

diff --git a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
index 7df4ea1901ce..415e6c40787e 100644
--- a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
@@ -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
--
2.25.1

2022-11-27 23:07:05

by Colin Foster

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

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.

Suggested-by: Vladimir Oltean <[email protected]>
Signed-off-by: Colin Foster <[email protected]>
---

v3
* New patch

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

diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
index 978162df51f7..6fc9bc985726 100644
--- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
@@ -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>;

--
2.25.1

2022-11-27 23:07:47

by Colin Foster

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

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.

Signed-off-by: Colin Foster <[email protected]>
---

v2 -> v3
* No change

v1 -> v2
* New patch

---
Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
index bd1f0f7c14a8..87475c2ab092 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
@@ -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:
--
2.25.1

2022-11-27 23:08:36

by Colin Foster

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

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.

Signed-off-by: Colin Foster <[email protected]>
Suggested-by: Vladimir Oltean <[email protected]>
---

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

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml
index 9abb8eba5fad..5b457f41273a 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml
@@ -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:
diff --git a/Documentation/devicetree/bindings/net/ethernet-switch-port.yaml b/Documentation/devicetree/bindings/net/ethernet-switch-port.yaml
new file mode 100644
index 000000000000..3d7da6916fb8
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ethernet-switch-port.yaml
@@ -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
+
+...
diff --git a/Documentation/devicetree/bindings/net/ethernet-switch.yaml b/Documentation/devicetree/bindings/net/ethernet-switch.yaml
index d5bf9a2d8083..ef7503eba95c 100644
--- a/Documentation/devicetree/bindings/net/ethernet-switch.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-switch.yaml
@@ -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

...
diff --git a/MAINTAINERS b/MAINTAINERS
index 3077c5af6072..59674eb07491 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
--
2.25.1

2022-11-27 23:47:18

by Colin Foster

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

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.

Suggested-by: Rob Herring <[email protected]>
Signed-off-by: Colin Foster <[email protected]>
---

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(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml b/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
index 259a0c6547f3..8d5abb05abdf 100644
--- a/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
@@ -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]>
diff --git a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
index 1219b830b1a4..f323fc01b224 100644
--- a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
@@ -66,7 +66,7 @@ required:
- reg

allOf:
- - $ref: dsa.yaml#
+ - $ref: dsa.yaml#/$defs/base
- if:
properties:
compatible:
diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
index b9d48e357e77..bd1f0f7c14a8 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
@@ -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
+
+
...
diff --git a/Documentation/devicetree/bindings/net/dsa/hirschmann,hellcreek.yaml b/Documentation/devicetree/bindings/net/dsa/hirschmann,hellcreek.yaml
index 73b774eadd0b..e27b1619066f 100644
--- a/Documentation/devicetree/bindings/net/dsa/hirschmann,hellcreek.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/hirschmann,hellcreek.yaml
@@ -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]>
diff --git a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
index f2e9ff3f580b..7df4ea1901ce 100644
--- a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
@@ -238,7 +238,7 @@ $defs:
- sgmii

allOf:
- - $ref: dsa.yaml#
+ - $ref: dsa.yaml#/$defs/base
- if:
required:
- mediatek,mcm
diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
index 4da75b1f9533..bfa2b76659c9 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
@@ -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:
diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml
index 630bf0f8294b..f4f9798addae 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml
@@ -10,7 +10,7 @@ maintainers:
- [email protected]

allOf:
- - $ref: dsa.yaml#
+ - $ref: dsa.yaml#/$defs/base

properties:
compatible:
diff --git a/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml b/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml
index 8d93ed9c172c..a7041ae4d811 100644
--- a/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/mscc,ocelot.yaml
@@ -78,7 +78,7 @@ required:
- reg

allOf:
- - $ref: dsa.yaml#
+ - $ref: dsa.yaml#/$defs/base
- if:
properties:
compatible:
diff --git a/Documentation/devicetree/bindings/net/dsa/nxp,sja1105.yaml b/Documentation/devicetree/bindings/net/dsa/nxp,sja1105.yaml
index 1e26d876d146..13a835af9468 100644
--- a/Documentation/devicetree/bindings/net/dsa/nxp,sja1105.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/nxp,sja1105.yaml
@@ -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:
diff --git a/Documentation/devicetree/bindings/net/dsa/realtek.yaml b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
index 1a7d45a8ad66..ad1793eba31a 100644
--- a/Documentation/devicetree/bindings/net/dsa/realtek.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
@@ -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]>
diff --git a/Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml b/Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml
index 0a0d62b6c00e..9621f751a9dd 100644
--- a/Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml
@@ -14,7 +14,7 @@ description: |
handles 4 ports + 1 CPU management port.

allOf:
- - $ref: dsa.yaml#
+ - $ref: dsa.yaml#/$defs/base

properties:
compatible:
--
2.25.1

2022-11-28 08:58:13

by Arınç ÜNAL

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

On 28.11.2022 01:47, Colin Foster wrote:
> 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.

>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>
> ---
>
> v2 -> v3
> * New patch.
>
> ---
> .../bindings/net/dsa/mediatek,mt7530.yaml | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
> index 7df4ea1901ce..415e6c40787e 100644
> --- a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
> @@ -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").

> - 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

Thank you for your efforts.

Arınç

2022-11-28 10:04:07

by Alvin Šipraga

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

On Sun, Nov 27, 2022 at 02:47:27PM -0800, Colin Foster wrote:
> 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.
>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>
> ---
>
> 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(-)

Acked-by: Alvin Šipraga <[email protected]> # realtek

2022-11-28 20:38:44

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>

Acked-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 20:40:40

by Linus Walleij

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

On Sun, Nov 27, 2022 at 11:47 PM Colin Foster
<[email protected]> wrote:

> 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.
>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>

This is neat.
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2022-11-28 20:44:06

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Suggested-by: Vladimir Oltean <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 20:47:19

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 21:02:29

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Signed-off-by: Colin Foster <[email protected]>
> Suggested-by: Vladimir Oltean <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 21:05:10

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Signed-off-by: Colin Foster <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 21:27:38

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Signed-off-by: Colin Foster <[email protected]>
> Suggested-by: Vladimir Oltean <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 21:29:42

by Florian Fainelli

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

On 11/27/22 14:47, Colin Foster wrote:
> 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.
>
> Signed-off-by: Colin Foster <[email protected]>
> Suggested-by: Vladimir Oltean <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-28 23:39:21

by Rob Herring (Arm)

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

On Sun, Nov 27, 2022 at 02:47:27PM -0800, Colin Foster wrote:
> 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.

>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>
> ---
>
> 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(-)
>
> diff --git a/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml b/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
> index 259a0c6547f3..8d5abb05abdf 100644
> --- a/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
> @@ -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]>
> diff --git a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
> index 1219b830b1a4..f323fc01b224 100644
> --- a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
> @@ -66,7 +66,7 @@ required:
> - reg
>
> allOf:
> - - $ref: dsa.yaml#
> + - $ref: dsa.yaml#/$defs/base
> - if:
> properties:
> compatible:
> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> index b9d48e357e77..bd1f0f7c14a8 100644
> --- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> @@ -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$":

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.

> + type: object
> +
> + patternProperties:
> + "^(ethernet-)?ports@[0-9]+$":
> + description: Ethernet switch ports
> + $ref: dsa-port.yaml#
> + unevaluatedProperties: false
> +
> +

One blank line.

> ...

2022-11-29 00:08:00

by Rob Herring (Arm)

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

On Sun, Nov 27, 2022 at 02:47:28PM -0800, Colin Foster wrote:
> 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.
>
> Signed-off-by: Colin Foster <[email protected]>
> ---
>
> v2 -> v3
> * No change
>
> v1 -> v2
> * New patch
>
> ---
> Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> index bd1f0f7c14a8..87475c2ab092 100644
> --- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> @@ -38,6 +38,8 @@ patternProperties:
> '#size-cells':
> const: 0
>
> + additionalProperties: true
> +

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

> 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.

>
> oneOf:
> - required:
> --
> 2.25.1
>
>

2022-11-29 02:36:40

by Colin Foster

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

On Mon, Nov 28, 2022 at 09:21:26PM +0100, Linus Walleij wrote:
> On Sun, Nov 27, 2022 at 11:47 PM Colin Foster
> <[email protected]> wrote:
>
> > 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.
> >
> > Suggested-by: Rob Herring <[email protected]>
> > Signed-off-by: Colin Foster <[email protected]>
>
> This is neat.
> Reviewed-by: Linus Walleij <[email protected]>

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

>
> Yours,
> Linus Walleij

2022-11-29 02:52:57

by Colin Foster

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

Hi Rob,

On Mon, Nov 28, 2022 at 05:23:37PM -0600, Rob Herring wrote:
> On Sun, Nov 27, 2022 at 02:47:27PM -0800, Colin Foster wrote:
> > 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.

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

>
> >
> > Suggested-by: Rob Herring <[email protected]>
> > Signed-off-by: Colin Foster <[email protected]>
> > ---
> >
> > 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(-)
> >
> > diff --git a/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml b/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
> > index 259a0c6547f3..8d5abb05abdf 100644
> > --- a/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
> > +++ b/Documentation/devicetree/bindings/net/dsa/arrow,xrs700x.yaml
> > @@ -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]>
> > diff --git a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
> > index 1219b830b1a4..f323fc01b224 100644
> > --- a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
> > +++ b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
> > @@ -66,7 +66,7 @@ required:
> > - reg
> >
> > allOf:
> > - - $ref: dsa.yaml#
> > + - $ref: dsa.yaml#/$defs/base
> > - if:
> > properties:
> > compatible:
> > diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > index b9d48e357e77..bd1f0f7c14a8 100644
> > --- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > @@ -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$":
>
> 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?

>
> > + 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!

>
> > ...

2022-11-29 04:19:36

by Colin Foster

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

On Tue, Nov 29, 2022 at 01:34:52AM -0800, Colin Foster wrote:
> Hi Rob,
>
> On Mon, Nov 28, 2022 at 05:23:37PM -0600, Rob Herring wrote:
> > On Sun, Nov 27, 2022 at 02:47:27PM -0800, Colin Foster wrote:
> > > diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > > index b9d48e357e77..bd1f0f7c14a8 100644
> > > --- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > > +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > > @@ -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$":
> >
> > 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?

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

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
index 616753ba85a2..c1900363a6ab 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
@@ -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

-
...

2022-11-29 06:46:52

by Colin Foster

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

Hi Arınç,

On Mon, Nov 28, 2022 at 11:28:31AM +0300, Arınç ÜNAL wrote:
> On 28.11.2022 01:47, Colin Foster wrote:
> > 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.

>
> >
> > Suggested-by: Rob Herring <[email protected]>
> > Signed-off-by: Colin Foster <[email protected]>
> > ---
> >
> > v2 -> v3
> > * New patch.
> >
> > ---
> > .../bindings/net/dsa/mediatek,mt7530.yaml | 14 +++-----------
> > 1 file changed, 3 insertions(+), 11 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
> > index 7df4ea1901ce..415e6c40787e 100644
> > --- a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
> > +++ b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
> > @@ -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").

>
> > - 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
>
> Thank you for your efforts.

I greatly appreciate your help and feedback!

>
> Arınç

2022-11-29 07:31:53

by Colin Foster

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

On Mon, Nov 28, 2022 at 05:27:59PM -0600, Rob Herring wrote:
> On Sun, Nov 27, 2022 at 02:47:28PM -0800, Colin Foster wrote:
> > 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.
> >
> > Signed-off-by: Colin Foster <[email protected]>
> > ---
> >
> > v2 -> v3
> > * No change
> >
> > v1 -> v2
> > * New patch
> >
> > ---
> > Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > index bd1f0f7c14a8..87475c2ab092 100644
> > --- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > @@ -38,6 +38,8 @@ patternProperties:
> > '#size-cells':
> > const: 0
> >
> > + additionalProperties: true
> > +
>
> Where then do we restrict adding properties to ethernet-ports nodes?
>
> > 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.

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.


>
> >
> > oneOf:
> > - required:
> > --
> > 2.25.1
> >
> >

2022-11-29 08:46:01

by Arınç ÜNAL

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

Hey Colin,

On 29.11.2022 09:32, Colin Foster wrote:
> Hi Arınç,
>
> On Mon, Nov 28, 2022 at 11:28:31AM +0300, Arınç ÜNAL wrote:
>> On 28.11.2022 01:47, Colin Foster wrote:
>>> 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.
>
>>
>>>
>>> Suggested-by: Rob Herring <[email protected]>
>>> Signed-off-by: Colin Foster <[email protected]>
>>> ---
>>>
>>> v2 -> v3
>>> * New patch.
>>>
>>> ---
>>> .../bindings/net/dsa/mediatek,mt7530.yaml | 14 +++-----------
>>> 1 file changed, 3 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
>>> index 7df4ea1901ce..415e6c40787e 100644
>>> --- a/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
>>> +++ b/Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml
>>> @@ -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

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.

> 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ç

2022-12-01 22:41:35

by Rob Herring (Arm)

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


On Sun, 27 Nov 2022 14:47:26 -0800, Colin Foster wrote:
> 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.
>
> Suggested-by: Vladimir Oltean <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>
> ---
>
> v3
> * New patch
>
> ---
> Documentation/devicetree/bindings/net/dsa/qca8k.yaml | 4 ----
> 1 file changed, 4 deletions(-)
>

Reviewed-by: Rob Herring <[email protected]>

2022-12-01 23:10:32

by Rob Herring (Arm)

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


On Sun, 27 Nov 2022 14:47:25 -0800, Colin Foster wrote:
> 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.
>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Colin Foster <[email protected]>
> ---
>
> v3
> * New patch
>
> ---
> .../devicetree/bindings/net/dsa/brcm,sf2.yaml | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>

Reviewed-by: Rob Herring <[email protected]>

2022-12-01 23:12:05

by Rob Herring (Arm)

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

On Mon, Nov 28, 2022 at 11:21:18PM -0800, Colin Foster wrote:
> On Mon, Nov 28, 2022 at 05:27:59PM -0600, Rob Herring wrote:
> > On Sun, Nov 27, 2022 at 02:47:28PM -0800, Colin Foster wrote:
> > > 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.
> > >
> > > Signed-off-by: Colin Foster <[email protected]>
> > > ---
> > >
> > > v2 -> v3
> > > * No change
> > >
> > > v1 -> v2
> > > * New patch
> > >
> > > ---
> > > Documentation/devicetree/bindings/net/dsa/dsa.yaml | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > > index bd1f0f7c14a8..87475c2ab092 100644
> > > --- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > > +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > > @@ -38,6 +38,8 @@ patternProperties:
> > > '#size-cells':
> > > const: 0
> > >
> > > + additionalProperties: true
> > > +
> >
> > Where then do we restrict adding properties to ethernet-ports nodes?
> >
> > > 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.
>
> 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'.

> 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

2022-12-01 23:12:54

by Rob Herring (Arm)

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

On Sun, Nov 27, 2022 at 02:47:29PM -0800, Colin Foster wrote:
> 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.
>
> Signed-off-by: Colin Foster <[email protected]>
> Suggested-by: Vladimir Oltean <[email protected]>
> ---
>
> 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(-)
>
> diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
> index 6fc9bc985726..93a9ddebcac8 100644
> --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
> +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
> @@ -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#

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.

>
> 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

2022-12-02 19:59:06

by Colin Foster

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

Hi Rob,

On Thu, Dec 01, 2022 at 04:42:40PM -0600, Rob Herring wrote:
> On Sun, Nov 27, 2022 at 02:47:29PM -0800, Colin Foster wrote:
> > 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.
> >
> > Signed-off-by: Colin Foster <[email protected]>
> > Suggested-by: Vladimir Oltean <[email protected]>
> > ---
> >
> > 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(-)
> >
> > diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
> > index 6fc9bc985726..93a9ddebcac8 100644
> > --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
> > +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml
> > @@ -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#
>
> 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.

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.

>
> >
> > 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