Skip to contentSkip to conversation

tools: ynl-gen: lift type requirement for attribute subsets

PATCH Applied Jiri Pirko 3 participants 7 messages Oct 6, 2023 – Oct 10, 2023

Subsystems (5)
lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

v3 cover tools: ynl-gen: lift type requirement for attribute subsets

From: Jiri Pirko <[email protected]>

Remove the requirement from schema files to specify the "type" for attribute subsets and adjust existing schema files.

Jiri Pirko (2):
tools: ynl-gen: lift type requirement for attribute subsets
netlink: specs: remove redundant type keys from attributes in subsets

 Documentation/netlink/genetlink-c.yaml      | 14 +++++++++++++-
 Documentation/netlink/genetlink-legacy.yaml | 14 +++++++++++++-
 Documentation/netlink/genetlink.yaml        | 14 +++++++++++++-
 Documentation/netlink/netlink-raw.yaml      | 14 +++++++++++++-
 Documentation/netlink/specs/devlink.yaml    | 10 ----------
 Documentation/netlink/specs/dpll.yaml       |  8 --------
 Documentation/netlink/specs/ethtool.yaml    |  3 ---
 7 files changed, 52 insertions(+), 25 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH v3 1/2 tools: ynl-gen: lift type requirement for attribute subsets

From: Jiri Pirko <[email protected]>

In case an attribute is used in a subset, the type has to be currently specified. As the attribute is already defined in the original set, this is a redundant information in yaml file, moreover, may lead to inconsistencies.

Example:
attribute-sets:

    ...
    name: pin
    enum-name: dpll_a_pin
    attributes:
      ...
      -
        name: parent-id
        type: u32
      ...
  -
    name: pin-parent-device
    subset-of: pin
    attributes:
      -
        name: parent-id
        type: u32             <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Remove the requirement from schema files to specify the "type" for attribute subsets.

---
v2->v3:
- handled in schema instead of py file

---
 Documentation/netlink/genetlink-c.yaml      | 14 +++++++++++++-
 Documentation/netlink/genetlink-legacy.yaml | 14 +++++++++++++-
 Documentation/netlink/genetlink.yaml        | 14 +++++++++++++-
 Documentation/netlink/netlink-raw.yaml      | 14 +++++++++++++-
 4 files changed, 52 insertions(+), 4 deletions(-)
Documentation/netlink/genetlink-c.yaml +13 -1
index 9806c44f604c..32736b2d8ae8 100644
@@ -142,7 +142,7 @@ properties:
           type: array
           items:
             type: object
-            required: [ name, type ]
+            required: [ name ]
             additionalProperties: False
             properties:
               name:
@@ -215,6 +215,18 @@ properties:
           not:
             required: [ name-prefix ]
 
+      # type property is only required if not in subset definition
+      if:
+        properties:
+          subset-of:
+            not:
+              type: string
+      then:
+        properties:
+          attributes:
+            items:
+              required: [ type ]
+
   operations:
     description: Operations supported by the protocol.
     type: object
Documentation/netlink/genetlink-legacy.yaml +13 -1
index 12a0a045605d..25fe1379b180 100644
@@ -180,7 +180,7 @@ properties:
           type: array
           items:
             type: object
-            required: [ name, type ]
+            required: [ name ]
             additionalProperties: False
             properties:
               name:
@@ -254,6 +254,18 @@ properties:
           not:
             required: [ name-prefix ]
 
+      # type property is only required if not in subset definition
+      if:
+        properties:
+          subset-of:
+            not:
+              type: string
+      then:
+        properties:
+          attributes:
+            items:
+              required: [ type ]
+
   operations:
     description: Operations supported by the protocol.
     type: object
Documentation/netlink/genetlink.yaml +13 -1
index 3d338c48bf21..6ea1c947ce51 100644
@@ -115,7 +115,7 @@ properties:
           type: array
           items:
             type: object
-            required: [ name, type ]
+            required: [ name ]
             additionalProperties: False
             properties:
               name:
@@ -184,6 +184,18 @@ properties:
           not:
             required: [ name-prefix ]
 
+      # type property is only required if not in subset definition
+      if:
+        properties:
+          subset-of:
+            not:
+              type: string
+      then:
+        properties:
+          attributes:
+            items:
+              required: [ type ]
+
   operations:
     description: Operations supported by the protocol.
     type: object
Documentation/netlink/netlink-raw.yaml +13 -1
index 896797876414..d976851b80f8 100644
@@ -187,7 +187,7 @@ properties:
           type: array
           items:
             type: object
-            required: [ name, type ]
+            required: [ name ]
             additionalProperties: False
             properties:
               name:
@@ -261,6 +261,18 @@ properties:
           not:
             required: [ name-prefix ]
 
+      # type property is only required if not in subset definition
+      if:
+        properties:
+          subset-of:
+            not:
+              type: string
+      then:
+        properties:
+          attributes:
+            items:
+              required: [ type ]
+
   operations:
     description: Operations supported by the protocol.
     type: object
Signature · 1 line
2.41.0
maintainer Reviewed-by on v3 1/2
#2 lore raw
On Fri,  6 Oct 2023 13:44:35 +0200 Jiri Pirko wrote:
> +      # type property is only required if not in subset definition
> +      if:

Documentation/netlink/genetlink-c.yaml properties: · line 228

Quoted 9 lines
Documentation/netlink/genetlink-c.yaml +9 -0
+        properties:
+          subset-of:
+            not:
+              type: string
+      then:
+        properties:
+          attributes:
+            items:
+              required: [ type ]

Nice!

author maintainer
#3 lore raw
Quoted 13 lines · Fri, Oct 06, 2023 at 05:00:39PM CEST, [email protected] wrote:
On Fri,  6 Oct 2023 13:44:35 +0200 Jiri Pirko wrote:
> +      # type property is only required if not in subset definition
> +      if:

Documentation/netlink/genetlink-c.yaml properties: · line 228

Quoted 9 lines
Documentation/netlink/genetlink-c.yaml +9 -0
+        properties:
+          subset-of:
+            not:
+              type: string
+      then:
+        properties:
+          attributes:
+            items:
+              required: [ type ]
Quoted 1 line

Nice!

Took me like 3 hours debugging this. These json schemas are from different world than I am...

Quoted 2 lines
maintainer
#4 lore raw
Quoted 2 lines · On Fri, 6 Oct 2023 18:55:37 +0200 Jiri Pirko wrote:

Took me like 3 hours debugging this. These json schemas are from different world than I am...

That makes two of us. One of the most confusing languages I've worked with.. The effort is very much appreciated! :)

author maintainer
#5 lore raw

PATCH v3 2/2 netlink: specs: remove redundant type keys from attributes in subsets

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

No longer needed to define type for subset attributes. Remove those.

---
v1->v2:
- new patch

---
 Documentation/netlink/specs/devlink.yaml | 10 ----------
 Documentation/netlink/specs/dpll.yaml    |  8 --------
 Documentation/netlink/specs/ethtool.yaml |  3 ---
 3 files changed, 21 deletions(-)
Documentation/netlink/specs/devlink.yaml +0 -10
index d1ebcd927149..86a12c5bcff1 100644
@@ -199,54 +199,44 @@ attribute-sets:
     attributes:
       -
         name: reload-stats
-        type: nest
       -
         name: remote-reload-stats
-        type: nest
   -
     name: dl-reload-stats
     subset-of: devlink
     attributes:
       -
         name: reload-action-info
-        type: nest
   -
     name: dl-reload-act-info
     subset-of: devlink
     attributes:
       -
         name: reload-action
-        type: u8
       -
         name: reload-action-stats
-        type: nest
   -
     name: dl-reload-act-stats
     subset-of: devlink
     attributes:
       -
         name: reload-stats-entry
-        type: nest
   -
     name: dl-reload-stats-entry
     subset-of: devlink
     attributes:
       -
         name: reload-stats-limit
-        type: u8
       -
         name: reload-stats-value
-        type: u32
   -
     name: dl-info-version
     subset-of: devlink
     attributes:
       -
         name: info-version-name
-        type: string
       -
         name: info-version-value
-        type: string
 
 operations:
   enum-model: directional
Documentation/netlink/specs/dpll.yaml +0 -8
index 8b86b28b47a6..1c1b53136c7b 100644
@@ -278,36 +278,28 @@ attribute-sets:
     attributes:
       -
         name: parent-id
-        type: u32
       -
         name: direction
-        type: u32
       -
         name: prio
-        type: u32
       -
         name: state
-        type: u32
   -
     name: pin-parent-pin
     subset-of: pin
     attributes:
       -
         name: parent-id
-        type: u32
       -
         name: state
-        type: u32
   -
     name: frequency-range
     subset-of: pin
     attributes:
       -
         name: frequency-min
-        type: u64
       -
         name: frequency-max
-        type: u64
 
 operations:
   enum-name: dpll_cmd
Documentation/netlink/specs/ethtool.yaml +0 -3
index 837b565577ca..5c7a65b009b4 100644
@@ -818,13 +818,10 @@ attribute-sets:
     attributes:
       -
         name: hist-bkt-low
-        type: u32
       -
         name: hist-bkt-hi
-        type: u32
       -
         name: hist-val
-        type: u64
   -
     name: stats
     attributes:
Signature · 1 line
2.41.0
#6 lore raw
In reply to Jiri Pirko
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 6 Oct 2023 13:44:34 +0200 you wrote:

From: Jiri Pirko <[email protected]>

Remove the requirement from schema files to specify the "type" for attribute subsets and adjust existing schema files.

Jiri Pirko (2):
tools: ynl-gen: lift type requirement for attribute subsets
netlink: specs: remove redundant type keys from attributes in subsets

[...]

Here is the summary with links:
- [net-next,v3,1/2] tools: ynl-gen: lift type requirement for attribute subsets

    https://git.kernel.org/netdev/net-next/c/e18f3dc2beaa
  - [net-next,v3,2/2] netlink: specs: remove redundant type keys from attributes in subsets
    https://git.kernel.org/netdev/net-next/c/7049fd5df78c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html