mbox series

[v3,net-next,0/3] Add support for encoding multi-attr to ynl

Message ID cover.1706882196.git.alessandromarcolini99@gmail.com (mailing list archive)
Headers show
Series Add support for encoding multi-attr to ynl | expand

Message

Alessandro Marcolini Feb. 2, 2024, 2 p.m. UTC
This patchset add the support for encoding multi-attr attributes, making
it possible to use ynl with qdisc which have this kind of attributes
(e.g: taprio, ets).

Patch 1 corrects two docstrings in nlspec.py
Patch 2 adds the multi-attr attribute to taprio entry
Patch 3 adds the support for encoding multi-attr

v1 --> v2:
- Use SearchAttrs instead of ChainMap

v2 --> v3:
- Handle multi-attr at every level, not only in nested attributes

Alessandro Marcolini (3):
  tools: ynl: correct typo and docstring
  doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry
  tools: ynl: add support for encoding multi-attr

 Documentation/netlink/specs/tc.yaml | 1 +
 tools/net/ynl/lib/nlspec.py         | 7 +++----
 tools/net/ynl/lib/ynl.py            | 5 +++++
 3 files changed, 9 insertions(+), 4 deletions(-)

Comments

Donald Hunter Feb. 2, 2024, 3:05 p.m. UTC | #1
Alessandro Marcolini <alessandromarcolini99@gmail.com> writes:

> This patchset add the support for encoding multi-attr attributes, making
> it possible to use ynl with qdisc which have this kind of attributes
> (e.g: taprio, ets).

I liked the fact that your original cover letter included an example
ynl.py command. With this patchset plus the merged struct encoding
patch, you can add a taprio qdisc like this:

# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/tc.yaml \
  --do newqdisc --create --json '{
  "family":1, "ifindex":111, "handle":65536, "parent":4294967295, "info":0,
   "kind":"taprio",
   "stab":{
       "base": {
         "cell-log": 0,
         "size-log": 0,
         "cell-align": 0,
         "overhead": 31,
         "linklayer": 0,
         "mpu": 0,
         "mtu": 0,
         "tsize": 0
       }
   },
   "options":{
       "priomap": {
           "num-tc": 3,
           "prio-tc-map": "01010101010101010101010101010101",
           "hw": 0,
           "count": "0100010002000000000000000000000000000000000000000000000000000000",
           "offset": "0100020003000000000000000000000000000000000000000000000000000000"
       },
       "sched-clockid":11,
       "sched-entry-list": {"entry": [
           {"index":0, "cmd":0, "gate-mask":1, "interval":300000},
           {"index":1, "cmd":0, "gate-mask":2, "interval":300000},
           {"index":2, "cmd":0, "gate-mask":4, "interval":400000} ]
       },
       "sched-base-time":1528743495910289987, "flags": 1
   }
  }'

> Patch 1 corrects two docstrings in nlspec.py
> Patch 2 adds the multi-attr attribute to taprio entry
> Patch 3 adds the support for encoding multi-attr
>
> v1 --> v2:
> - Use SearchAttrs instead of ChainMap
>
> v2 --> v3:
> - Handle multi-attr at every level, not only in nested attributes
>
> Alessandro Marcolini (3):
>   tools: ynl: correct typo and docstring
>   doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry
>   tools: ynl: add support for encoding multi-attr
>
>  Documentation/netlink/specs/tc.yaml | 1 +
>  tools/net/ynl/lib/nlspec.py         | 7 +++----
>  tools/net/ynl/lib/ynl.py            | 5 +++++
>  3 files changed, 9 insertions(+), 4 deletions(-)
Alessandro Marcolini Feb. 2, 2024, 3:31 p.m. UTC | #2
On 2/2/24 16:05, Donald Hunter wrote:
> I liked the fact that your original cover letter included an example
> ynl.py command. With this patchset plus the merged struct encoding
> patch, you can add a taprio qdisc like this:
>
> # ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/tc.yaml \
>   --do newqdisc --create --json '{
>   "family":1, "ifindex":111, "handle":65536, "parent":4294967295, "info":0,
>    "kind":"taprio",
>    "stab":{
>        "base": {
>          "cell-log": 0,
>          "size-log": 0,
>          "cell-align": 0,
>          "overhead": 31,
>          "linklayer": 0,
>          "mpu": 0,
>          "mtu": 0,
>          "tsize": 0
>        }
>    },
>    "options":{
>        "priomap": {
>            "num-tc": 3,
>            "prio-tc-map": "01010101010101010101010101010101",
>            "hw": 0,
>            "count": "0100010002000000000000000000000000000000000000000000000000000000",
>            "offset": "0100020003000000000000000000000000000000000000000000000000000000"
>        },
>        "sched-clockid":11,
>        "sched-entry-list": {"entry": [
>            {"index":0, "cmd":0, "gate-mask":1, "interval":300000},
>            {"index":1, "cmd":0, "gate-mask":2, "interval":300000},
>            {"index":2, "cmd":0, "gate-mask":4, "interval":400000} ]
>        },
>        "sched-base-time":1528743495910289987, "flags": 1
>    }
>   }'
>
Yes, exactly! I didn't repost the updated command to avoid being too verbose.
FWIW, I've also tested it with an ets qdisc. The command is:

# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/tc.yaml --do newqdisc --create \
--json '{
"family":1, "ifindex":4, "handle":65536, "parent":4294967295, "kind":"ets",
"options":{
    "nbands":6,
    "nstrict":3,
    "quanta":{
        "quanta-band": [3500, 3000, 2500]
    },
    "priomap":{
        "priomap-band":[0, 1, 1, 1, 2, 3, 4, 5]
    }
}
}'