netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Add support for encoding multi-attr to ynl
@ 2024-01-24 16:34 Alessandro Marcolini
  2024-01-24 16:34 ` [PATCH net-next 1/3] tools: ynl: correct typo and docstring Alessandro Marcolini
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Alessandro Marcolini @ 2024-01-24 16:34 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, donald.hunter, sdf, chuck.lever,
	lorenzo, jacob.e.keller, jiri
  Cc: netdev, Alessandro Marcolini

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

Example:
The equivalent to:
# tc qdisc add dev eni1np1 root handle:1 ets bands 8 priomap 7 6 5 4 3 2 1 0

would be in ynl:
# ./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":8, "priomap":
[{"priomap-band":7}, {"priomap-band":6}, {"priomap-band":5},
{"priomap-band":4}, {"priomap-band":3}, {"priomap-band":2},
{"priomap-band":1}, {"priomap-band":0}]}}'

This patchset depends on the work done by Donald Hunter:
https://lore.kernel.org/netdev/20240123160538.172-1-donald.hunter@gmail.com/T/#t

It is a modified version of a previous patch I've submitted, where I
removed the part already addressed by Donald and modified the rest
accordingly. Previous patch:
https://lore.kernel.org/netdev/cover.1705950652.git.alessandromarcolini99@gmail.com/T/#t

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

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         |  9 ++++-----
 tools/net/ynl/lib/ynl.py            | 16 ++++++++++++----
 3 files changed, 17 insertions(+), 9 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] tools: ynl: correct typo and docstring
  2024-01-24 16:34 [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Alessandro Marcolini
@ 2024-01-24 16:34 ` Alessandro Marcolini
  2024-01-24 16:34 ` [PATCH net-next 2/3] doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry Alessandro Marcolini
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alessandro Marcolini @ 2024-01-24 16:34 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, donald.hunter, sdf, chuck.lever,
	lorenzo, jacob.e.keller, jiri
  Cc: netdev, Alessandro Marcolini

Correct typo in SpecAttr docstring. Changed SpecSubMessageFormat
docstring.

Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail.com>
---
 tools/net/ynl/lib/nlspec.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index 5d197a12ab8d..9c205022f8c0 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -144,7 +144,7 @@ class SpecEnumSet(SpecElement):
 
 
 class SpecAttr(SpecElement):
-    """ Single Netlink atttribute type
+    """ Single Netlink attribute type
 
     Represents a single attribute type within an attr space.
 
@@ -308,10 +308,9 @@ class SpecSubMessage(SpecElement):
 
 
 class SpecSubMessageFormat(SpecElement):
-    """ Netlink sub-message definition
-
-    Represents a set of sub-message formats for polymorphic nlattrs
-    that contain type-specific sub messages.
+    """ Netlink sub-message format definition
+
+    Represents a single format for a sub-message.
 
     Attributes:
         value         attribute value to match against type selector
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry
  2024-01-24 16:34 [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Alessandro Marcolini
  2024-01-24 16:34 ` [PATCH net-next 1/3] tools: ynl: correct typo and docstring Alessandro Marcolini
@ 2024-01-24 16:34 ` Alessandro Marcolini
  2024-01-24 16:34 ` [PATCH net-next 3/3] tools: ynl: add support for encoding multi-attr Alessandro Marcolini
  2024-01-24 23:25 ` [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Jakub Kicinski
  3 siblings, 0 replies; 6+ messages in thread
From: Alessandro Marcolini @ 2024-01-24 16:34 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, donald.hunter, sdf, chuck.lever,
	lorenzo, jacob.e.keller, jiri
  Cc: netdev, Alessandro Marcolini

Add multi-attr attribute to tc-taprio-sched-entry to specify multiple
entries.

Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail.com>
---
 Documentation/netlink/specs/tc.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index 4b21b00dbebe..0468070e7872 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -3375,6 +3375,7 @@ attribute-sets:
       -
         name: entry
         type: nest
+        multi-attr: true
         nested-attributes: tc-taprio-sched-entry
   -
     name: tc-taprio-sched-entry
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] tools: ynl: add support for encoding multi-attr
  2024-01-24 16:34 [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Alessandro Marcolini
  2024-01-24 16:34 ` [PATCH net-next 1/3] tools: ynl: correct typo and docstring Alessandro Marcolini
  2024-01-24 16:34 ` [PATCH net-next 2/3] doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry Alessandro Marcolini
@ 2024-01-24 16:34 ` Alessandro Marcolini
  2024-01-24 23:25 ` [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Jakub Kicinski
  3 siblings, 0 replies; 6+ messages in thread
From: Alessandro Marcolini @ 2024-01-24 16:34 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, donald.hunter, sdf, chuck.lever,
	lorenzo, jacob.e.keller, jiri
  Cc: netdev, Alessandro Marcolini

Multi-attr elements could not be encoded because of missing logic in the
ynl code. Enable encoding of these attributes by checking if the nest
attribute in the spec contains multi-attr attributes and if the value to
be processed is a list.

This has been tested both with the taprio and ets qdisc which contain
this kind of attributes.

Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail.com>
---
 tools/net/ynl/lib/ynl.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index dff2c042e6c3..bd01b1016fef 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -427,10 +427,18 @@ class YnlFamily(SpecFamily):
         if attr["type"] == 'nest':
             nl_type |= Netlink.NLA_F_NESTED
             attr_payload = b''
-            subvals = ChainMap(value, vals)
-            for subname, subvalue in value.items():
-                attr_payload += self._add_attr(attr['nested-attributes'],
-                                               subname, subvalue, subvals)
+            nested_attrs = self.attr_sets[attr['nested-attributes']].attrs
+            if any(a.is_multi for a in nested_attrs.values()) and isinstance(value, list):
+                for item in value:
+                    subvals = ChainMap(item, vals)
+                    for subname, subvalue in item.items():
+                        attr_payload += self._add_attr(attr['nested-attributes'],
+                                                       subname, subvalue, subvals)
+            else:
+                subvals = ChainMap(value, vals)
+                for subname, subvalue in value.items():
+                    attr_payload += self._add_attr(attr['nested-attributes'],
+                                                   subname, subvalue, subvals)
         elif attr["type"] == 'flag':
             attr_payload = b''
         elif attr["type"] == 'string':
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] Add support for encoding multi-attr to ynl
  2024-01-24 16:34 [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Alessandro Marcolini
                   ` (2 preceding siblings ...)
  2024-01-24 16:34 ` [PATCH net-next 3/3] tools: ynl: add support for encoding multi-attr Alessandro Marcolini
@ 2024-01-24 23:25 ` Jakub Kicinski
  2024-01-25 14:09   ` Alessandro Marcolini
  3 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2024-01-24 23:25 UTC (permalink / raw)
  To: Alessandro Marcolini
  Cc: davem, edumazet, pabeni, donald.hunter, sdf, chuck.lever, lorenzo,
	jacob.e.keller, jiri, netdev

On Wed, 24 Jan 2024 17:34:35 +0100 Alessandro Marcolini wrote:
> This patchset depends on the work done by Donald Hunter:
> https://lore.kernel.org/netdev/20240123160538.172-1-donald.hunter@gmail.com/T/#t

You'll have to repost once Donald's changes are in, sorry :(
Our build bots and CI do not know how to handle series with
dependencies.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] Add support for encoding multi-attr to ynl
  2024-01-24 23:25 ` [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Jakub Kicinski
@ 2024-01-25 14:09   ` Alessandro Marcolini
  0 siblings, 0 replies; 6+ messages in thread
From: Alessandro Marcolini @ 2024-01-25 14:09 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, edumazet, pabeni, donald.hunter, sdf, chuck.lever, lorenzo,
	jacob.e.keller, jiri, netdev

On 1/25/24 00:25, Jakub Kicinski wrote:
> On Wed, 24 Jan 2024 17:34:35 +0100 Alessandro Marcolini wrote:
>> This patchset depends on the work done by Donald Hunter:
>> https://lore.kernel.org/netdev/20240123160538.172-1-donald.hunter@gmail.com/T/#t
> You'll have to repost once Donald's changes are in, sorry :(
> Our build bots and CI do not know how to handle series with
> dependencies.

Ok, thanks for the update :)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-25 14:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-24 16:34 [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Alessandro Marcolini
2024-01-24 16:34 ` [PATCH net-next 1/3] tools: ynl: correct typo and docstring Alessandro Marcolini
2024-01-24 16:34 ` [PATCH net-next 2/3] doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry Alessandro Marcolini
2024-01-24 16:34 ` [PATCH net-next 3/3] tools: ynl: add support for encoding multi-attr Alessandro Marcolini
2024-01-24 23:25 ` [PATCH net-next 0/3] Add support for encoding multi-attr to ynl Jakub Kicinski
2024-01-25 14:09   ` Alessandro Marcolini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).