diff mbox series

[v1,1/1] dt-bindings: net: dsa: Add DSA yaml binding

Message ID 20200710090618.28945-2-kurt@linutronix.de
State Changes Requested, archived
Headers show
Series dt-bindings: net: dsa: Add DSA yaml binding | expand

Checks

Context Check Description
robh/checkpatch warning total: 0 errors, 1 warnings, 80 lines checked
robh/dt-meta-schema fail build log

Commit Message

Kurt Kanzenbach July 10, 2020, 9:06 a.m. UTC
For future DSA drivers it makes sense to add a generic DSA yaml binding which
can be used then. This was created using the properties from dsa.txt. It
includes the ports and the dsa,member property.

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

Comments

Rob Herring July 10, 2020, 4:39 p.m. UTC | #1
On Fri, 10 Jul 2020 11:06:18 +0200, Kurt Kanzenbach wrote:
> For future DSA drivers it makes sense to add a generic DSA yaml binding which
> can be used then. This was created using the properties from dsa.txt. It
> includes the ports and the dsa,member property.
> 
> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
>  1 file changed, 80 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> 


My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/ti,cpsw-switch.example.dt.yaml: switch@0: 'ports' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml: switch@10: 'ports' is a required property


See https://patchwork.ozlabs.org/patch/1326594

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.
Rob Herring July 10, 2020, 4:45 p.m. UTC | #2
On Fri, Jul 10, 2020 at 11:06:18AM +0200, Kurt Kanzenbach wrote:
> For future DSA drivers it makes sense to add a generic DSA yaml binding which
> can be used then. This was created using the properties from dsa.txt. It
> includes the ports and the dsa,member property.
> 
> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
>  1 file changed, 80 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> new file mode 100644
> index 000000000000..bec257231bf8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> @@ -0,0 +1,80 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Distributed Switch Architecture Device Tree Bindings

DSA is a Linuxism, right?

> +
> +maintainers:
> +  - Andrew Lunn <andrew@lunn.ch>
> +  - Florian Fainelli <f.fainelli@gmail.com>
> +  - Vivien Didelot <vivien.didelot@gmail.com>
> +
> +description:
> +  Switches are true Linux devices and can be probed by any means. Once probed,

Bindings are OS independent.

> +  they register to the DSA framework, passing a node pointer. This node is
> +  expected to fulfil the following binding, and may contain additional
> +  properties as required by the device it is embedded within.

Describe what type of h/w should use this binding.

> +
> +properties:
> +  $nodename:
> +    pattern: "^switch(@.*)?$"
> +
> +  dsa,member:
> +    minItems: 2
> +    maxItems: 2
> +    description:
> +      A two element list indicates which DSA cluster, and position within the
> +      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
> +      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
> +      (single device hanging off a CPU port) must not specify this property
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +
> +  ports:
> +    type: object
> +    properties:
> +      '#address-cells':
> +        const: 1
> +      '#size-cells':
> +        const: 0
> +
> +    patternProperties:
> +      "^port@[0-9]+$":

As ports and port are OF graph nodes, it would be better if we 
standardized on a different name for these. I think we've used 
'ethernet-port' some.

> +          type: object
> +          description: DSA switch ports
> +
> +          allOf:
> +            - $ref: ../ethernet-controller.yaml#

How does this and 'ethernet' both apply?

> +
> +          properties:
> +            reg:
> +              description: Port number
> +
> +            label:
> +              description:
> +                Describes the label associated with this port, which will become
> +                the netdev name
> +              $ref: /schemas/types.yaml#definitions/string
> +
> +            link:
> +              description:
> +                Should be a list of phandles to other switch's DSA port. This
> +                port is used as the outgoing port towards the phandle ports. The
> +                full routing information must be given, not just the one hop
> +                routes to neighbouring switches
> +              $ref: /schemas/types.yaml#definitions/phandle-array
> +
> +            ethernet:
> +              description:
> +                Should be a phandle to a valid Ethernet device node.  This host
> +                device is what the switch port is connected to
> +              $ref: /schemas/types.yaml#definitions/phandle
> +
> +          required:
> +            - reg
> +
> +required:
> +  - ports
> +
> +...
> -- 
> 2.20.1
>
Florian Fainelli July 10, 2020, 5:20 p.m. UTC | #3
On 7/10/2020 9:45 AM, Rob Herring wrote:
> On Fri, Jul 10, 2020 at 11:06:18AM +0200, Kurt Kanzenbach wrote:
>> For future DSA drivers it makes sense to add a generic DSA yaml binding which
>> can be used then. This was created using the properties from dsa.txt. It
>> includes the ports and the dsa,member property.
>>
>> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
>> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
>> ---
>>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
>>  1 file changed, 80 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
>> new file mode 100644
>> index 000000000000..bec257231bf8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
>> @@ -0,0 +1,80 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Distributed Switch Architecture Device Tree Bindings
> 
> DSA is a Linuxism, right?

Not really, it is a Marvell term that describes their proprietary
switching protocol. Since then DSA within Linux expands well beyond just
Marvell switches, so the terms have been blurred a little bit.

> 
>> +
>> +maintainers:
>> +  - Andrew Lunn <andrew@lunn.ch>
>> +  - Florian Fainelli <f.fainelli@gmail.com>
>> +  - Vivien Didelot <vivien.didelot@gmail.com>
>> +
>> +description:
>> +  Switches are true Linux devices and can be probed by any means. Once probed,
> 
> Bindings are OS independent.
> 
>> +  they register to the DSA framework, passing a node pointer. This node is
>> +  expected to fulfil the following binding, and may contain additional
>> +  properties as required by the device it is embedded within.
> 
> Describe what type of h/w should use this binding.
> 
>> +
>> +properties:
>> +  $nodename:
>> +    pattern: "^switch(@.*)?$"
>> +
>> +  dsa,member:
>> +    minItems: 2
>> +    maxItems: 2
>> +    description:
>> +      A two element list indicates which DSA cluster, and position within the
>> +      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
>> +      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
>> +      (single device hanging off a CPU port) must not specify this property
>> +    $ref: /schemas/types.yaml#/definitions/uint32-array
>> +
>> +  ports:
>> +    type: object
>> +    properties:
>> +      '#address-cells':
>> +        const: 1
>> +      '#size-cells':
>> +        const: 0
>> +
>> +    patternProperties:
>> +      "^port@[0-9]+$":
> 
> As ports and port are OF graph nodes, it would be better if we 
> standardized on a different name for these. I think we've used 
> 'ethernet-port' some.

Yes we did talk about that before, however when the original DSA binding
was introduced about 7 years ago (or maybe more recently, my memory
fails me now), "ports" was chosen as the encapsulating node. We should
be accepting both ethernet-ports and ports.

> 
>> +          type: object
>> +          description: DSA switch ports
>> +
>> +          allOf:
>> +            - $ref: ../ethernet-controller.yaml#
> 
> How does this and 'ethernet' both apply?

I think the intent here was to mean that some of the properties from the
Ethernet controller such as phy-mode, phy-handle, fixed-link also apply
here since the switch port is a simplified Ethernet MAC on a number of
counts.
Andrew Lunn July 10, 2020, 5:39 p.m. UTC | #4
On Fri, Jul 10, 2020 at 10:45:00AM -0600, Rob Herring wrote:
> On Fri, Jul 10, 2020 at 11:06:18AM +0200, Kurt Kanzenbach wrote:
> > For future DSA drivers it makes sense to add a generic DSA yaml binding which
> > can be used then. This was created using the properties from dsa.txt. It
> > includes the ports and the dsa,member property.
> > 
> > Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> > Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> > ---
> >  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
> >  1 file changed, 80 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > new file mode 100644
> > index 000000000000..bec257231bf8
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > @@ -0,0 +1,80 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Distributed Switch Architecture Device Tree Bindings
> 
> DSA is a Linuxism, right?

Hi Rob

Marvell'ism actually. They came up the idea for how you can
interconnect multiple switches to form a distributed switch fabric. So
far, the Marvell driver is the only driver that makes use of D in
DSA. But it seems like some other vendors have similar concepts. And
those which don't allow D in DSA can use a simplified version of the
architecture for a single switch.

> Describe what type of h/w should use this binding.
> 
> > +
> > +properties:
> > +  $nodename:
> > +    pattern: "^switch(@.*)?$"
> > +
> > +  dsa,member:
> > +    minItems: 2
> > +    maxItems: 2
> > +    description:
> > +      A two element list indicates which DSA cluster, and position within the
> > +      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
> > +      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
> > +      (single device hanging off a CPU port) must not specify this property
> > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > +
> > +  ports:
> > +    type: object
> > +    properties:
> > +      '#address-cells':
> > +        const: 1
> > +      '#size-cells':
> > +        const: 0
> > +
> > +    patternProperties:
> > +      "^port@[0-9]+$":
> 
> As ports and port are OF graph nodes, it would be better if we 
> standardized on a different name for these. I think we've used 
> 'ethernet-port' some.

I suspect DSA was using port before OF graph came along. Yep:

commit 5e95329b701c4edf6c4d72487ec0369fa148c0bd
Author: Florian Fainelli <florian@openwrt.org>
Date:   Fri Mar 22 10:50:50 2013 +0000

    dsa: add device tree bindings to register DSA switches

commit 4d56ed5a009b7d31ecae1dd26c047b8bb0dd9287
Author: Philipp Zabel <p.zabel@pengutronix.de>
Date:   Tue Feb 25 15:44:49 2014 +0100

    Documentation: of: Document graph bindings

So this usage is will established and it is probably a bit late to
change it now.

   Andrew
Rob Herring July 10, 2020, 7:38 p.m. UTC | #5
On Fri, Jul 10, 2020 at 11:20 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>
>
> On 7/10/2020 9:45 AM, Rob Herring wrote:
> > On Fri, Jul 10, 2020 at 11:06:18AM +0200, Kurt Kanzenbach wrote:
> >> For future DSA drivers it makes sense to add a generic DSA yaml binding which
> >> can be used then. This was created using the properties from dsa.txt. It
> >> includes the ports and the dsa,member property.
> >>
> >> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> >> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> >> ---
> >>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
> >>  1 file changed, 80 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >> new file mode 100644
> >> index 000000000000..bec257231bf8
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >> @@ -0,0 +1,80 @@
> >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> >> +%YAML 1.2
> >> +---
> >> +$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> +
> >> +title: Distributed Switch Architecture Device Tree Bindings
> >
> > DSA is a Linuxism, right?
>
> Not really, it is a Marvell term that describes their proprietary
> switching protocol. Since then DSA within Linux expands well beyond just
> Marvell switches, so the terms have been blurred a little bit.

Either way, sounds like the terminology here should be more general.

Though I missed that this is really just a conversion of dsa.txt which
should be removed in this patch. Otherwise, you'll get me re-reviewing
the binding.

> >> +
> >> +maintainers:
> >> +  - Andrew Lunn <andrew@lunn.ch>
> >> +  - Florian Fainelli <f.fainelli@gmail.com>
> >> +  - Vivien Didelot <vivien.didelot@gmail.com>
> >> +
> >> +description:
> >> +  Switches are true Linux devices and can be probed by any means. Once probed,
> >
> > Bindings are OS independent.
> >
> >> +  they register to the DSA framework, passing a node pointer. This node is
> >> +  expected to fulfil the following binding, and may contain additional
> >> +  properties as required by the device it is embedded within.
> >
> > Describe what type of h/w should use this binding.
> >
> >> +
> >> +properties:
> >> +  $nodename:
> >> +    pattern: "^switch(@.*)?$"
> >> +
> >> +  dsa,member:
> >> +    minItems: 2
> >> +    maxItems: 2
> >> +    description:
> >> +      A two element list indicates which DSA cluster, and position within the
> >> +      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
> >> +      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
> >> +      (single device hanging off a CPU port) must not specify this property
> >> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> >> +
> >> +  ports:
> >> +    type: object
> >> +    properties:
> >> +      '#address-cells':
> >> +        const: 1
> >> +      '#size-cells':
> >> +        const: 0
> >> +
> >> +    patternProperties:
> >> +      "^port@[0-9]+$":
> >
> > As ports and port are OF graph nodes, it would be better if we
> > standardized on a different name for these. I think we've used
> > 'ethernet-port' some.
>
> Yes we did talk about that before, however when the original DSA binding
> was introduced about 7 years ago (or maybe more recently, my memory
> fails me now), "ports" was chosen as the encapsulating node. We should
> be accepting both ethernet-ports and ports.

Yes, I'm aware of the history. Back then it was a free-for-all on node
names. Now we're trying to be more disciplined. Ideally, we pick
something unique to standardize on and fix the dts files to match as
long as the node name is generally a don't care for the OS.

The schema says only port/ports is allowed, so at a minimum
ethernet-port/ethernet-ports needs to be added here.

>
> >
> >> +          type: object
> >> +          description: DSA switch ports
> >> +
> >> +          allOf:
> >> +            - $ref: ../ethernet-controller.yaml#
> >
> > How does this and 'ethernet' both apply?
>
> I think the intent here was to mean that some of the properties from the
> Ethernet controller such as phy-mode, phy-handle, fixed-link also apply
> here since the switch port is a simplified Ethernet MAC on a number of
> counts.

Okay, it's good to explicitly define which of those apply as I imagine
some don't. Just need "<prop>: true" to do that.

Rob
Kurt Kanzenbach July 11, 2020, 11:35 a.m. UTC | #6
On Fri Jul 10 2020, Rob Herring wrote:
> On Fri, 10 Jul 2020 11:06:18 +0200, Kurt Kanzenbach wrote:
>> For future DSA drivers it makes sense to add a generic DSA yaml binding which
>> can be used then. This was created using the properties from dsa.txt. It
>> includes the ports and the dsa,member property.
>> 
>> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
>> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
>> ---
>>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
>>  1 file changed, 80 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
>> 
>
>
> My bot found errors running 'make dt_binding_check' on your patch:
>
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/ti,cpsw-switch.example.dt.yaml: switch@0: 'ports' is a required property
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml: switch@10: 'ports' is a required property

Okay, the requirement for 'ports' has be to removed.

Thanks,
Kurt
Kurt Kanzenbach July 11, 2020, 11:59 a.m. UTC | #7
Hi,

On Fri Jul 10 2020, Rob Herring wrote:
> On Fri, Jul 10, 2020 at 11:20 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>>
>>
>> On 7/10/2020 9:45 AM, Rob Herring wrote:
>> > On Fri, Jul 10, 2020 at 11:06:18AM +0200, Kurt Kanzenbach wrote:
>> >> For future DSA drivers it makes sense to add a generic DSA yaml binding which
>> >> can be used then. This was created using the properties from dsa.txt. It
>> >> includes the ports and the dsa,member property.
>> >>
>> >> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
>> >> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
>> >> ---
>> >>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
>> >>  1 file changed, 80 insertions(+)
>> >>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
>> >>
>> >> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
>> >> new file mode 100644
>> >> index 000000000000..bec257231bf8
>> >> --- /dev/null
>> >> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
>> >> @@ -0,0 +1,80 @@
>> >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> >> +%YAML 1.2
>> >> +---
>> >> +$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
>> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> >> +
>> >> +title: Distributed Switch Architecture Device Tree Bindings
>> >
>> > DSA is a Linuxism, right?
>>
>> Not really, it is a Marvell term that describes their proprietary
>> switching protocol. Since then DSA within Linux expands well beyond just
>> Marvell switches, so the terms have been blurred a little bit.
>
> Either way, sounds like the terminology here should be more general.

How?

>
> Though I missed that this is really just a conversion of dsa.txt which
> should be removed in this patch. Otherwise, you'll get me re-reviewing
> the binding.

Yes, it's a conversion of the dsa.txt. I should have stated that more
clearly. I didn't remove the .txt file, because it's referenced in all
the different switch bindings such as b53.txt, ksz.txt and so on. How to
handle that?

>
>> >> +
>> >> +maintainers:
>> >> +  - Andrew Lunn <andrew@lunn.ch>
>> >> +  - Florian Fainelli <f.fainelli@gmail.com>
>> >> +  - Vivien Didelot <vivien.didelot@gmail.com>
>> >> +
>> >> +description:
>> >> +  Switches are true Linux devices and can be probed by any means. Once probed,
>> >
>> > Bindings are OS independent.

OK.

>> >
>> >> +  they register to the DSA framework, passing a node pointer. This node is
>> >> +  expected to fulfil the following binding, and may contain additional
>> >> +  properties as required by the device it is embedded within.
>> >
>> > Describe what type of h/w should use this binding.

I took the description from the dsa.txt. However, it makes sense to
adjust that description. Basically all Ethernet switches with a
dedicated CPU port should use DSA and this binding.

>> >
>> >> +
>> >> +properties:
>> >> +  $nodename:
>> >> +    pattern: "^switch(@.*)?$"
>> >> +
>> >> +  dsa,member:
>> >> +    minItems: 2
>> >> +    maxItems: 2
>> >> +    description:
>> >> +      A two element list indicates which DSA cluster, and position within the
>> >> +      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
>> >> +      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
>> >> +      (single device hanging off a CPU port) must not specify this property
>> >> +    $ref: /schemas/types.yaml#/definitions/uint32-array
>> >> +
>> >> +  ports:
>> >> +    type: object
>> >> +    properties:
>> >> +      '#address-cells':
>> >> +        const: 1
>> >> +      '#size-cells':
>> >> +        const: 0
>> >> +
>> >> +    patternProperties:
>> >> +      "^port@[0-9]+$":
>> >
>> > As ports and port are OF graph nodes, it would be better if we
>> > standardized on a different name for these. I think we've used
>> > 'ethernet-port' some.
>>
>> Yes we did talk about that before, however when the original DSA binding
>> was introduced about 7 years ago (or maybe more recently, my memory
>> fails me now), "ports" was chosen as the encapsulating node. We should
>> be accepting both ethernet-ports and ports.
>
> Yes, I'm aware of the history. Back then it was a free-for-all on node
> names. Now we're trying to be more disciplined. Ideally, we pick
> something unique to standardize on and fix the dts files to match as
> long as the node name is generally a don't care for the OS.
>
> The schema says only port/ports is allowed,

Yes, it does.

> so at a minimum
> ethernet-port/ethernet-ports needs to be added here.

Just to be sure. Instead of

  ports {
    port@1 {
      ...
    }
  }

The following should be possible as well?

  ethernet-ports {
    port@1 {
      ...
    }
  }

Is there an easy way to add that alternative to the schema? Or does the
ethernet-ports property has to be defined as well?

>
>>
>> >
>> >> +          type: object
>> >> +          description: DSA switch ports
>> >> +
>> >> +          allOf:
>> >> +            - $ref: ../ethernet-controller.yaml#
>> >
>> > How does this and 'ethernet' both apply?
>>
>> I think the intent here was to mean that some of the properties from the
>> Ethernet controller such as phy-mode, phy-handle, fixed-link also apply
>> here since the switch port is a simplified Ethernet MAC on a number of
>> counts.
>
> Okay, it's good to explicitly define which of those apply as I imagine
> some don't. Just need "<prop>: true" to do that.

Yes, that was my intent. Only a few properties from the Ethernet
controller are needed. I'll add them like you suggested.

>
> Rob

Thanks,
Kurt
Andrew Lunn July 11, 2020, 4:42 p.m. UTC | #8
> > Though I missed that this is really just a conversion of dsa.txt which
> > should be removed in this patch. Otherwise, you'll get me re-reviewing
> > the binding.
> 
> Yes, it's a conversion of the dsa.txt. I should have stated that more
> clearly. I didn't remove the .txt file, because it's referenced in all
> the different switch bindings such as b53.txt, ksz.txt and so on. How to
> handle that?

~/linux$ cat Documentation/devicetree/bindings/net/ethernet.txt 
This file has moved to ethernet-controller.yaml.

As an example. Once all the other files which reference it have been
converted, we can come back and remove the .txt file.

   Andrew
Andrew Lunn July 11, 2020, 4:52 p.m. UTC | #9
On Sat, Jul 11, 2020 at 01:35:12PM +0200, Kurt Kanzenbach wrote:
> On Fri Jul 10 2020, Rob Herring wrote:
> > On Fri, 10 Jul 2020 11:06:18 +0200, Kurt Kanzenbach wrote:
> >> For future DSA drivers it makes sense to add a generic DSA yaml binding which
> >> can be used then. This was created using the properties from dsa.txt. It
> >> includes the ports and the dsa,member property.
> >> 
> >> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> >> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> >> ---
> >>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
> >>  1 file changed, 80 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >> 
> >
> >
> > My bot found errors running 'make dt_binding_check' on your patch:
> >
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/ti,cpsw-switch.example.dt.yaml: switch@0: 'ports' is a required property
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml: switch@10: 'ports' is a required property
> 
> Okay, the requirement for 'ports' has be to removed.

Hummm....

ti.cpsw is not a DSA switch. So this binding should not apply to
it. It is a plain switchdev switch.

The qcom,ipq806 is just an MDIO bus master. The DSA binding might
apply, for a specific .dts file, if that dts file has a DSA switch on
the bus. But in general, it should not apply.

So i actually think you need to work out why this binding is being
applied when it should not be.

I suspect it is the keyword 'switch'. switch does not imply it is a
DSA switch. There are other sorts of switches as well.

	Andrew
Kurt Kanzenbach July 12, 2020, 10:29 a.m. UTC | #10
On Sat Jul 11 2020, Andrew Lunn wrote:
> On Sat, Jul 11, 2020 at 01:35:12PM +0200, Kurt Kanzenbach wrote:
>> On Fri Jul 10 2020, Rob Herring wrote:
>> > My bot found errors running 'make dt_binding_check' on your patch:
>> >
>> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/ti,cpsw-switch.example.dt.yaml: switch@0: 'ports' is a required property
>> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml: switch@10: 'ports' is a required property
>> 
>> Okay, the requirement for 'ports' has be to removed.
>
> Hummm....
>
> ti.cpsw is not a DSA switch. So this binding should not apply to
> it. It is a plain switchdev switch.
>
> The qcom,ipq806 is just an MDIO bus master. The DSA binding might
> apply, for a specific .dts file, if that dts file has a DSA switch on
> the bus. But in general, it should not apply.
>
> So i actually think you need to work out why this binding is being
> applied when it should not be.
>
> I suspect it is the keyword 'switch'. switch does not imply it is a
> DSA switch. There are other sorts of switches as well.

OK, makes sense. It seems like the nodename is responsible for that.

This fixes the problem:

|diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
|index bec257231bf8..4c360f8b170e 100644
|--- a/Documentation/devicetree/bindings/net/dsa/dsa.yaml
|+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
|@@ -18,9 +18,6 @@ description:
|   properties as required by the device it is embedded within.
| 
| properties:
|-  $nodename:
|-    pattern: "^switch(@.*)?$"
|-
|   dsa,member:
|     minItems: 2
|     maxItems: 2

Thanks,
Kurt
Rob Herring July 13, 2020, 8:41 p.m. UTC | #11
On Sat, Jul 11, 2020 at 5:59 AM Kurt Kanzenbach <kurt@linutronix.de> wrote:
>
> Hi,
>
> On Fri Jul 10 2020, Rob Herring wrote:
> > On Fri, Jul 10, 2020 at 11:20 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>
> >>
> >>
> >> On 7/10/2020 9:45 AM, Rob Herring wrote:
> >> > On Fri, Jul 10, 2020 at 11:06:18AM +0200, Kurt Kanzenbach wrote:
> >> >> For future DSA drivers it makes sense to add a generic DSA yaml binding which
> >> >> can be used then. This was created using the properties from dsa.txt. It
> >> >> includes the ports and the dsa,member property.
> >> >>
> >> >> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> >> >> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> >> >> ---
> >> >>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
> >> >>  1 file changed, 80 insertions(+)
> >> >>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >> >>
> >> >> diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >> >> new file mode 100644
> >> >> index 000000000000..bec257231bf8
> >> >> --- /dev/null
> >> >> +++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
> >> >> @@ -0,0 +1,80 @@
> >> >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> >> >> +%YAML 1.2
> >> >> +---
> >> >> +$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
> >> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> >> +
> >> >> +title: Distributed Switch Architecture Device Tree Bindings
> >> >
> >> > DSA is a Linuxism, right?
> >>
> >> Not really, it is a Marvell term that describes their proprietary
> >> switching protocol. Since then DSA within Linux expands well beyond just
> >> Marvell switches, so the terms have been blurred a little bit.
> >
> > Either way, sounds like the terminology here should be more general.
>
> How?

I don't know, just call it 'ethernet switch' binding or something.
>
> >
> > Though I missed that this is really just a conversion of dsa.txt which
> > should be removed in this patch. Otherwise, you'll get me re-reviewing
> > the binding.
>
> Yes, it's a conversion of the dsa.txt. I should have stated that more
> clearly. I didn't remove the .txt file, because it's referenced in all
> the different switch bindings such as b53.txt, ksz.txt and so on. How to
> handle that?

Either update them if not many, or make dsa.txt just point to dsa.yaml
as Andrew mentioned. I haven't looked, but seems like this would be a
small number.

Updating all the users to schema is also welcome. :)

> >> >> +
> >> >> +maintainers:
> >> >> +  - Andrew Lunn <andrew@lunn.ch>
> >> >> +  - Florian Fainelli <f.fainelli@gmail.com>
> >> >> +  - Vivien Didelot <vivien.didelot@gmail.com>
> >> >> +
> >> >> +description:
> >> >> +  Switches are true Linux devices and can be probed by any means. Once probed,
> >> >
> >> > Bindings are OS independent.
>
> OK.
>
> >> >
> >> >> +  they register to the DSA framework, passing a node pointer. This node is
> >> >> +  expected to fulfil the following binding, and may contain additional
> >> >> +  properties as required by the device it is embedded within.
> >> >
> >> > Describe what type of h/w should use this binding.
>
> I took the description from the dsa.txt. However, it makes sense to
> adjust that description. Basically all Ethernet switches with a
> dedicated CPU port should use DSA and this binding.
>
> >> >
> >> >> +
> >> >> +properties:
> >> >> +  $nodename:
> >> >> +    pattern: "^switch(@.*)?$"
> >> >> +
> >> >> +  dsa,member:
> >> >> +    minItems: 2
> >> >> +    maxItems: 2
> >> >> +    description:
> >> >> +      A two element list indicates which DSA cluster, and position within the
> >> >> +      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
> >> >> +      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
> >> >> +      (single device hanging off a CPU port) must not specify this property
> >> >> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> >> >> +
> >> >> +  ports:
> >> >> +    type: object
> >> >> +    properties:
> >> >> +      '#address-cells':
> >> >> +        const: 1
> >> >> +      '#size-cells':
> >> >> +        const: 0
> >> >> +
> >> >> +    patternProperties:
> >> >> +      "^port@[0-9]+$":
> >> >
> >> > As ports and port are OF graph nodes, it would be better if we
> >> > standardized on a different name for these. I think we've used
> >> > 'ethernet-port' some.
> >>
> >> Yes we did talk about that before, however when the original DSA binding
> >> was introduced about 7 years ago (or maybe more recently, my memory
> >> fails me now), "ports" was chosen as the encapsulating node. We should
> >> be accepting both ethernet-ports and ports.
> >
> > Yes, I'm aware of the history. Back then it was a free-for-all on node
> > names. Now we're trying to be more disciplined. Ideally, we pick
> > something unique to standardize on and fix the dts files to match as
> > long as the node name is generally a don't care for the OS.
> >
> > The schema says only port/ports is allowed,
>
> Yes, it does.
>
> > so at a minimum
> > ethernet-port/ethernet-ports needs to be added here.
>
> Just to be sure. Instead of
>
>   ports {
>     port@1 {
>       ...
>     }
>   }
>
> The following should be possible as well?
>
>   ethernet-ports {
>     port@1 {

Yes, but probably 'ethernet-port@1' here. Or both can be allowed.

>       ...
>     }
>   }
>
> Is there an easy way to add that alternative to the schema? Or does the
> ethernet-ports property has to be defined as well?

You need a pattern like:

patternProperties:
  "^(ethernet-)?ports$":
    ...

You could also make one property a $ref to another, but I prefer the above.

Rob
Rob Herring July 13, 2020, 8:56 p.m. UTC | #12
On Sat, Jul 11, 2020 at 10:52 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Sat, Jul 11, 2020 at 01:35:12PM +0200, Kurt Kanzenbach wrote:
> > On Fri Jul 10 2020, Rob Herring wrote:
> > > On Fri, 10 Jul 2020 11:06:18 +0200, Kurt Kanzenbach wrote:
> > >> For future DSA drivers it makes sense to add a generic DSA yaml binding which
> > >> can be used then. This was created using the properties from dsa.txt. It
> > >> includes the ports and the dsa,member property.
> > >>
> > >> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> > >> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> > >> ---
> > >>  .../devicetree/bindings/net/dsa/dsa.yaml      | 80 +++++++++++++++++++
> > >>  1 file changed, 80 insertions(+)
> > >>  create mode 100644 Documentation/devicetree/bindings/net/dsa/dsa.yaml
> > >>
> > >
> > >
> > > My bot found errors running 'make dt_binding_check' on your patch:
> > >
> > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/ti,cpsw-switch.example.dt.yaml: switch@0: 'ports' is a required property
> > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml: switch@10: 'ports' is a required property
> >
> > Okay, the requirement for 'ports' has be to removed.
>
> Hummm....
>
> ti.cpsw is not a DSA switch. So this binding should not apply to
> it. It is a plain switchdev switch.

Well, the binding looks very similar with the same
ethernet-ports/port@X structure. So maybe we need a switch schema that
covers both and then a DSA schema.

> The qcom,ipq806 is just an MDIO bus master. The DSA binding might
> apply, for a specific .dts file, if that dts file has a DSA switch on
> the bus. But in general, it should not apply.
>
> So i actually think you need to work out why this binding is being
> applied when it should not be.
>
> I suspect it is the keyword 'switch'. switch does not imply it is a
> DSA switch. There are other sorts of switches as well.

Yes, by default, we match on compatible or node name if no compatible.
The simple solution here is adding 'select: false' and then dsa.yaml
will only be applied when explicitly referenced by the h/w specific
bindings.

There's also mscc-ocelot which is not yet a schema.

Rob
Kurt Kanzenbach July 14, 2020, 6:18 a.m. UTC | #13
Hi Rob,

On Mon Jul 13 2020, Rob Herring wrote:
> On Sat, Jul 11, 2020 at 5:59 AM Kurt Kanzenbach <kurt@linutronix.de> wrote:
>> How?
>
> I don't know, just call it 'ethernet switch' binding or something.

OK.

>> Yes, it's a conversion of the dsa.txt. I should have stated that more
>> clearly. I didn't remove the .txt file, because it's referenced in all
>> the different switch bindings such as b53.txt, ksz.txt and so on. How to
>> handle that?
>
> Either update them if not many, or make dsa.txt just point to dsa.yaml
> as Andrew mentioned. I haven't looked, but seems like this would be a
> small number.

OK.

>
> Updating all the users to schema is also welcome. :)
>
>> Just to be sure. Instead of
>>
>>   ports {
>>     port@1 {
>>       ...
>>     }
>>   }
>>
>> The following should be possible as well?
>>
>>   ethernet-ports {
>>     port@1 {
>
> Yes, but probably 'ethernet-port@1' here. Or both can be allowed.

I think both should be allowed. No binding is using
ethernet-port. They're all using ethernet-ports and port within
(example: ti,cpsw-switch.yaml).

But, if the binding does allow for ethernet-ports, then the DSA core has
to be adjusted, or? The current code searches only for "ports" (in
dsa_switch_parse_ports_of()).

>
>>       ...
>>     }
>>   }
>>
>> Is there an easy way to add that alternative to the schema? Or does the
>> ethernet-ports property has to be defined as well?
>
> You need a pattern like:
>
> patternProperties:
>   "^(ethernet-)?ports$":
>     ...

I see. Thanks!

>
> You could also make one property a $ref to another, but I prefer the
> above.

That's what I wanted to avoid.

Thanks,
Kurt
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.yaml b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
new file mode 100644
index 000000000000..bec257231bf8
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.yaml
@@ -0,0 +1,80 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/dsa/dsa.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Distributed Switch Architecture Device Tree Bindings
+
+maintainers:
+  - Andrew Lunn <andrew@lunn.ch>
+  - Florian Fainelli <f.fainelli@gmail.com>
+  - Vivien Didelot <vivien.didelot@gmail.com>
+
+description:
+  Switches are true Linux devices and can be probed by any means. Once probed,
+  they register to the DSA framework, passing a node pointer. This node is
+  expected to fulfil the following binding, and may contain additional
+  properties as required by the device it is embedded within.
+
+properties:
+  $nodename:
+    pattern: "^switch(@.*)?$"
+
+  dsa,member:
+    minItems: 2
+    maxItems: 2
+    description:
+      A two element list indicates which DSA cluster, and position within the
+      cluster a switch takes. <0 0> is cluster 0, switch 0. <0 1> is cluster 0,
+      switch 1. <1 0> is cluster 1, switch 0. A switch not part of any cluster
+      (single device hanging off a CPU port) must not specify this property
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  ports:
+    type: object
+    properties:
+      '#address-cells':
+        const: 1
+      '#size-cells':
+        const: 0
+
+    patternProperties:
+      "^port@[0-9]+$":
+          type: object
+          description: DSA switch ports
+
+          allOf:
+            - $ref: ../ethernet-controller.yaml#
+
+          properties:
+            reg:
+              description: Port number
+
+            label:
+              description:
+                Describes the label associated with this port, which will become
+                the netdev name
+              $ref: /schemas/types.yaml#definitions/string
+
+            link:
+              description:
+                Should be a list of phandles to other switch's DSA port. This
+                port is used as the outgoing port towards the phandle ports. The
+                full routing information must be given, not just the one hop
+                routes to neighbouring switches
+              $ref: /schemas/types.yaml#definitions/phandle-array
+
+            ethernet:
+              description:
+                Should be a phandle to a valid Ethernet device node.  This host
+                device is what the switch port is connected to
+              $ref: /schemas/types.yaml#definitions/phandle
+
+          required:
+            - reg
+
+required:
+  - ports
+
+...