diff mbox series

[RFC,1/3] dt-bindings: net: Add network-class schema for mac-address properties

Message ID 20230203-dt-bindings-network-class-v1-1-452e0375200d@jannau.net (mailing list archive)
State RFC
Delegated to: Johannes Berg
Headers show
Series dt-bindings: net: Add network-class.yaml schema | expand

Commit Message

Janne Grunau Feb. 3, 2023, 1:56 p.m. UTC
The ethernet-controller schema specifies "mac-address" and
"local-mac-address" but other network devices such as wireless network
adapters use mac addresses as well.
The Devicetree Specification, Release v0.3 specifies in section 4.3.1
a generic "Network Class Binding" with "address-bits", "mac-address",
"local-mac-address" and "max-frame-size". This schema specifies the
"address-bits" property and moves "local-mac-address" and "mac-address"
over from ethernet-controller.yaml.
The schema currently does not restrict MAC address size based on
address-bits.

Signed-off-by: Janne Grunau <j@jannau.net>
---
 .../bindings/net/ethernet-controller.yaml          | 18 +---------
 .../devicetree/bindings/net/network-class.yaml     | 40 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 17 deletions(-)

Comments

Rob Herring Feb. 3, 2023, 2:25 p.m. UTC | #1
On Fri, Feb 3, 2023 at 7:56 AM Janne Grunau <j@jannau.net> wrote:
>
> The ethernet-controller schema specifies "mac-address" and
> "local-mac-address" but other network devices such as wireless network
> adapters use mac addresses as well.
> The Devicetree Specification, Release v0.3 specifies in section 4.3.1
> a generic "Network Class Binding" with "address-bits", "mac-address",
> "local-mac-address" and "max-frame-size". This schema specifies the
> "address-bits" property and moves "local-mac-address" and "mac-address"
> over from ethernet-controller.yaml.
> The schema currently does not restrict MAC address size based on
> address-bits.
>
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
>  .../bindings/net/ethernet-controller.yaml          | 18 +---------
>  .../devicetree/bindings/net/network-class.yaml     | 40 ++++++++++++++++++++++
>  2 files changed, 41 insertions(+), 17 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> index 00be387984ac..a5f6a09dfdea 100644
> --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
> @@ -17,23 +17,6 @@ properties:
>      $ref: /schemas/types.yaml#/definitions/string
>      description: Human readable label on a port of a box.
>
> -  local-mac-address:
> -    description:
> -      Specifies the MAC address that was assigned to the network device.
> -    $ref: /schemas/types.yaml#/definitions/uint8-array
> -    minItems: 6
> -    maxItems: 6
> -
> -  mac-address:
> -    description:
> -      Specifies the MAC address that was last used by the boot
> -      program; should be used in cases where the MAC address assigned
> -      to the device by the boot program is different from the
> -      local-mac-address property.
> -    $ref: /schemas/types.yaml#/definitions/uint8-array
> -    minItems: 6
> -    maxItems: 6
> -
>    max-frame-size:
>      $ref: /schemas/types.yaml#/definitions/uint32
>      description:
> @@ -226,6 +209,7 @@ dependencies:
>    pcs-handle-names: [pcs-handle]
>
>  allOf:
> +  - $ref: /schemas/net/network-class.yaml#
>    - if:
>        properties:
>          phy-mode:
> diff --git a/Documentation/devicetree/bindings/net/network-class.yaml b/Documentation/devicetree/bindings/net/network-class.yaml
> new file mode 100644
> index 000000000000..676aec1c458e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/network-class.yaml
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/network-class.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Network Class Bindings
> +
> +maintainers:
> +  - Devicetree Specification Mailing List <devicetree-spec@vger.kernel.org>
> +
> +properties:
> +  address-bits:
> +    description:
> +      Specifies number of address bits required to address the device described
> +      by this node. This property specifies number of bits in MAC address.
> +      If unspecified, the default value is 48.

You can drop the last sentence.

> +    default: 48
> +    enum: [48, 64]

I wonder if we should just deprecate this property. I see 1 occurrence
and no consumer in the kernel tree at least. I guess one could set the
length, but not have mac addresses in the DT. Otherwise you could just
infer the length from the property length. Anyways, a conversation for
another time I guess.

Rob
Krzysztof Kozlowski Feb. 3, 2023, 9:08 p.m. UTC | #2
On 03/02/2023 14:56, Janne Grunau wrote:
> The ethernet-controller schema specifies "mac-address" and
> "local-mac-address" but other network devices such as wireless network
> adapters use mac addresses as well.
> The Devicetree Specification, Release v0.3 specifies in section 4.3.1
> a generic "Network Class Binding" with "address-bits", "mac-address",
> "local-mac-address" and "max-frame-size". This schema specifies the
> "address-bits" property and moves "local-mac-address" and "mac-address"
> over from ethernet-controller.yaml.
> The schema currently does not restrict MAC address size based on
> address-bits.

A nit below

>          phy-mode:
> diff --git a/Documentation/devicetree/bindings/net/network-class.yaml b/Documentation/devicetree/bindings/net/network-class.yaml
> new file mode 100644
> index 000000000000..676aec1c458e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/network-class.yaml
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/network-class.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Network Class Bindings

s/Bindings/Common Properties/
Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index 00be387984ac..a5f6a09dfdea 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -17,23 +17,6 @@  properties:
     $ref: /schemas/types.yaml#/definitions/string
     description: Human readable label on a port of a box.
 
-  local-mac-address:
-    description:
-      Specifies the MAC address that was assigned to the network device.
-    $ref: /schemas/types.yaml#/definitions/uint8-array
-    minItems: 6
-    maxItems: 6
-
-  mac-address:
-    description:
-      Specifies the MAC address that was last used by the boot
-      program; should be used in cases where the MAC address assigned
-      to the device by the boot program is different from the
-      local-mac-address property.
-    $ref: /schemas/types.yaml#/definitions/uint8-array
-    minItems: 6
-    maxItems: 6
-
   max-frame-size:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
@@ -226,6 +209,7 @@  dependencies:
   pcs-handle-names: [pcs-handle]
 
 allOf:
+  - $ref: /schemas/net/network-class.yaml#
   - if:
       properties:
         phy-mode:
diff --git a/Documentation/devicetree/bindings/net/network-class.yaml b/Documentation/devicetree/bindings/net/network-class.yaml
new file mode 100644
index 000000000000..676aec1c458e
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/network-class.yaml
@@ -0,0 +1,40 @@ 
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/network-class.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Network Class Bindings
+
+maintainers:
+  - Devicetree Specification Mailing List <devicetree-spec@vger.kernel.org>
+
+properties:
+  address-bits:
+    description:
+      Specifies number of address bits required to address the device described
+      by this node. This property specifies number of bits in MAC address.
+      If unspecified, the default value is 48.
+    default: 48
+    enum: [48, 64]
+
+  local-mac-address:
+    description:
+      Specifies MAC address that was assigned to the network device described by
+      the node containing this property.
+    $ref: /schemas/types.yaml#/definitions/uint8-array
+    minItems: 6
+    maxItems: 8
+
+  mac-address:
+    description:
+      Specifies the MAC address that was last used by the boot program. This
+      property should be used in cases where the MAC address assigned to the
+      device by the boot program is different from the
+      local-mac-address property. This property shall be used only if the value
+      differs from local-mac-address property value.
+    $ref: /schemas/types.yaml#/definitions/uint8-array
+    minItems: 6
+    maxItems: 8
+
+additionalProperties: true