netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] ynl Makefile cleanup
@ 2023-10-03 15:34 Jakub Kicinski
  2023-10-03 15:34 ` [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags Jakub Kicinski
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Jakub Kicinski @ 2023-10-03 15:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, sdf, lorenzo, Jakub Kicinski

While catching up on recent changes I noticed unexpected
changes to Makefiles in YNL. Indeed they were not working
as intended but the fixes put in place were not what I had
in mind :)

Jakub Kicinski (3):
  ynl: netdev: drop unnecessary enum-as-flags
  tools: ynl: don't regen on every make
  tools: ynl: use uAPI include magic for samples

 Documentation/netlink/specs/netdev.yaml | 2 --
 tools/net/ynl/Makefile                  | 1 -
 tools/net/ynl/generated/Makefile        | 2 +-
 tools/net/ynl/samples/Makefile          | 5 ++++-
 4 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.41.0


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

* [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
@ 2023-10-03 15:34 ` Jakub Kicinski
  2023-10-16 17:34   ` Stanislav Fomichev
  2023-10-03 15:34 ` [PATCH net-next 2/3] tools: ynl: don't regen on every make Jakub Kicinski
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Jakub Kicinski @ 2023-10-03 15:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, sdf, lorenzo, Jakub Kicinski

enum-as-flags can be used when enum declares bit positions but
we want to carry bitmask in an attribute. If the definition
is already provided as flags there's no need to indicate
the flag-iness of the attribute.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 Documentation/netlink/specs/netdev.yaml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index c46fcc78fc04..14511b13f305 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -74,7 +74,6 @@ name: netdev
         doc: Bitmask of enabled xdp-features.
         type: u64
         enum: xdp-act
-        enum-as-flags: true
       -
         name: xdp-zc-max-segs
         doc: max fragment count supported by ZC driver
@@ -87,7 +86,6 @@ name: netdev
              See Documentation/networking/xdp-rx-metadata.rst for more details.
         type: u64
         enum: xdp-rx-metadata
-        enum-as-flags: true
 
 operations:
   list:
-- 
2.41.0


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

* [PATCH net-next 2/3] tools: ynl: don't regen on every make
  2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
  2023-10-03 15:34 ` [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags Jakub Kicinski
@ 2023-10-03 15:34 ` Jakub Kicinski
  2023-10-03 15:34 ` [PATCH net-next 3/3] tools: ynl: use uAPI include magic for samples Jakub Kicinski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Jakub Kicinski @ 2023-10-03 15:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, sdf, lorenzo, Jakub Kicinski

As far as I can tell the normal Makefile dependency tracking
works, generated files get re-generated if the YAML was updated.
Let make do its job, don't force the re-generation.
make hardclean can be used to force regeneration.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/Makefile           | 1 -
 tools/net/ynl/generated/Makefile | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index 8156f03e23ac..d664b36deb5b 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -3,7 +3,6 @@
 SUBDIRS = lib generated samples
 
 all: $(SUBDIRS)
-	./ynl-regen.sh -f -p $(PWD)/../../../
 
 $(SUBDIRS):
 	@if [ -f "$@/Makefile" ] ; then \
diff --git a/tools/net/ynl/generated/Makefile b/tools/net/ynl/generated/Makefile
index f8817d2e56e4..0f359ee3c46a 100644
--- a/tools/net/ynl/generated/Makefile
+++ b/tools/net/ynl/generated/Makefile
@@ -19,7 +19,7 @@ SRCS=$(patsubst %,%-user.c,${GENS})
 HDRS=$(patsubst %,%-user.h,${GENS})
 OBJS=$(patsubst %,%-user.o,${GENS})
 
-all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) regen
+all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI)
 
 protos.a: $(OBJS)
 	@echo -e "\tAR $@"
-- 
2.41.0


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

* [PATCH net-next 3/3] tools: ynl: use uAPI include magic for samples
  2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
  2023-10-03 15:34 ` [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags Jakub Kicinski
  2023-10-03 15:34 ` [PATCH net-next 2/3] tools: ynl: don't regen on every make Jakub Kicinski
@ 2023-10-03 15:34 ` Jakub Kicinski
  2023-10-03 16:00 ` [PATCH net-next 0/3] ynl Makefile cleanup Stanislav Fomichev
  2023-10-05  0:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 12+ messages in thread
From: Jakub Kicinski @ 2023-10-03 15:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, sdf, lorenzo, Jakub Kicinski

Makefile.deps provides direct includes in CFLAGS_$(obj).
We just need to rewrite the rules to make use of the extra
flags, no need to hard-include all of tools/include/uapi.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/samples/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/net/ynl/samples/Makefile b/tools/net/ynl/samples/Makefile
index 32abbc0af39e..3dbb106e87d9 100644
--- a/tools/net/ynl/samples/Makefile
+++ b/tools/net/ynl/samples/Makefile
@@ -4,7 +4,7 @@ include ../Makefile.deps
 
 CC=gcc
 CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
-	-I../../../include/uapi -I../lib/ -I../generated/ -idirafter $(UAPI_PATH)
+	-I../lib/ -I../generated/ -idirafter $(UAPI_PATH)
 ifeq ("$(DEBUG)","1")
   CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
 endif
@@ -19,6 +19,9 @@ include $(wildcard *.d)
 all: $(BINS)
 
 $(BINS): ../lib/ynl.a ../generated/protos.a
+	@echo -e '\tCC sample $@'
+	@$(COMPILE.c) $(CFLAGS_$@) $@.c -o $@.o
+	@$(LINK.c) $@.o -o $@  $(LDLIBS)
 
 clean:
 	rm -f *.o *.d *~
-- 
2.41.0


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

* Re: [PATCH net-next 0/3] ynl Makefile cleanup
  2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
                   ` (2 preceding siblings ...)
  2023-10-03 15:34 ` [PATCH net-next 3/3] tools: ynl: use uAPI include magic for samples Jakub Kicinski
@ 2023-10-03 16:00 ` Stanislav Fomichev
  2023-10-05  0:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 12+ messages in thread
From: Stanislav Fomichev @ 2023-10-03 16:00 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, lorenzo

On Tue, Oct 3, 2023 at 8:34 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> While catching up on recent changes I noticed unexpected
> changes to Makefiles in YNL. Indeed they were not working
> as intended but the fixes put in place were not what I had
> in mind :)

Whoops :-[ Thank you for the cleanup!

Acked-by: Stanislav Fomichev <sdf@google.com>


> Jakub Kicinski (3):
>   ynl: netdev: drop unnecessary enum-as-flags
>   tools: ynl: don't regen on every make
>   tools: ynl: use uAPI include magic for samples
>
>  Documentation/netlink/specs/netdev.yaml | 2 --
>  tools/net/ynl/Makefile                  | 1 -
>  tools/net/ynl/generated/Makefile        | 2 +-
>  tools/net/ynl/samples/Makefile          | 5 ++++-
>  4 files changed, 5 insertions(+), 5 deletions(-)
>
> --
> 2.41.0
>

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

* Re: [PATCH net-next 0/3] ynl Makefile cleanup
  2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
                   ` (3 preceding siblings ...)
  2023-10-03 16:00 ` [PATCH net-next 0/3] ynl Makefile cleanup Stanislav Fomichev
@ 2023-10-05  0:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-05  0:40 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, sdf, lorenzo

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  3 Oct 2023 08:34:13 -0700 you wrote:
> While catching up on recent changes I noticed unexpected
> changes to Makefiles in YNL. Indeed they were not working
> as intended but the fixes put in place were not what I had
> in mind :)
> 
> Jakub Kicinski (3):
>   ynl: netdev: drop unnecessary enum-as-flags
>   tools: ynl: don't regen on every make
>   tools: ynl: use uAPI include magic for samples
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] ynl: netdev: drop unnecessary enum-as-flags
    https://git.kernel.org/netdev/net-next/c/0629f22ec130
  - [net-next,2/3] tools: ynl: don't regen on every make
    https://git.kernel.org/netdev/net-next/c/a50660173c73
  - [net-next,3/3] tools: ynl: use uAPI include magic for samples
    https://git.kernel.org/netdev/net-next/c/e2ca31cee909

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-03 15:34 ` [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags Jakub Kicinski
@ 2023-10-16 17:34   ` Stanislav Fomichev
  2023-10-16 17:43     ` Willem de Bruijn
  0 siblings, 1 reply; 12+ messages in thread
From: Stanislav Fomichev @ 2023-10-16 17:34 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, lorenzo, willemb

On 10/03, Jakub Kicinski wrote:
> enum-as-flags can be used when enum declares bit positions but
> we want to carry bitmask in an attribute. If the definition
> is already provided as flags there's no need to indicate
> the flag-iness of the attribute.

Jakub, Willem hit an issue with this commit when running cli.py:

./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'

Traceback (most recent call last):
  File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
    main()
  File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
    reply = ynl.dump(args.dump, attrs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
    return self._op(method, vals, [], dump=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
    rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
    decoded = self._decode_enum(decoded, attr_spec)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
    value = enum.entries_by_val[raw].name
            ~~~~~~~~~~~~~~~~~~~^^^^^
KeyError: 127

I do see we have special handing for enum-as-flags to parse out the
individual fields:
	if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:

> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  Documentation/netlink/specs/netdev.yaml | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
> index c46fcc78fc04..14511b13f305 100644
> --- a/Documentation/netlink/specs/netdev.yaml
> +++ b/Documentation/netlink/specs/netdev.yaml
> @@ -74,7 +74,6 @@ name: netdev
>          doc: Bitmask of enabled xdp-features.
>          type: u64
>          enum: xdp-act
> -        enum-as-flags: true
>        -
>          name: xdp-zc-max-segs
>          doc: max fragment count supported by ZC driver
> @@ -87,7 +86,6 @@ name: netdev
>               See Documentation/networking/xdp-rx-metadata.rst for more details.
>          type: u64
>          enum: xdp-rx-metadata
> -        enum-as-flags: true
>  
>  operations:
>    list:
> -- 
> 2.41.0
> 

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

* Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-16 17:34   ` Stanislav Fomichev
@ 2023-10-16 17:43     ` Willem de Bruijn
  2023-10-16 18:46       ` Jakub Kicinski
  0 siblings, 1 reply; 12+ messages in thread
From: Willem de Bruijn @ 2023-10-16 17:43 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: Jakub Kicinski, davem, netdev, edumazet, pabeni, lorenzo, willemb

On Mon, Oct 16, 2023 at 1:35 PM Stanislav Fomichev <sdf@google.com> wrote:
>
> On 10/03, Jakub Kicinski wrote:
> > enum-as-flags can be used when enum declares bit positions but
> > we want to carry bitmask in an attribute. If the definition
> > is already provided as flags there's no need to indicate
> > the flag-iness of the attribute.
>
> Jakub, Willem hit an issue with this commit when running cli.py:
>
> ./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'
>
> Traceback (most recent call last):
>   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
>     main()
>   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
>     reply = ynl.dump(args.dump, attrs)
>             ^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
>     return self._op(method, vals, [], dump=True)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
>     rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
>     decoded = self._decode_enum(decoded, attr_spec)
>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
>     value = enum.entries_by_val[raw].name
>             ~~~~~~~~~~~~~~~~~~~^^^^^
> KeyError: 127

Indeed. The field is now interpreted as a value rather than a bitmap.

More subtly, even for requests that do not fail, all my devices now
incorrectly report to support xdp feature timestamp, because that is
enum 0.

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

* Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-16 17:43     ` Willem de Bruijn
@ 2023-10-16 18:46       ` Jakub Kicinski
  2023-10-16 19:07         ` Willem de Bruijn
  2023-10-16 19:08         ` Stanislav Fomichev
  0 siblings, 2 replies; 12+ messages in thread
From: Jakub Kicinski @ 2023-10-16 18:46 UTC (permalink / raw)
  To: Willem de Bruijn
  Cc: Stanislav Fomichev, davem, netdev, edumazet, pabeni, lorenzo,
	willemb

On Mon, 16 Oct 2023 13:43:07 -0400 Willem de Bruijn wrote:
> > Jakub, Willem hit an issue with this commit when running cli.py:
> >
> > ./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'
> >
> > Traceback (most recent call last):
> >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
> >     main()
> >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
> >     reply = ynl.dump(args.dump, attrs)
> >             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
> >     return self._op(method, vals, [], dump=True)
> >            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
> >     rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
> >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
> >     decoded = self._decode_enum(decoded, attr_spec)
> >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
> >     value = enum.entries_by_val[raw].name
> >             ~~~~~~~~~~~~~~~~~~~^^^^^
> > KeyError: 127  
> 
> Indeed. The field is now interpreted as a value rather than a bitmap.
> 
> More subtly, even for requests that do not fail, all my devices now
> incorrectly report to support xdp feature timestamp, because that is
> enum 0.

Sorry about that. This should fix it, right?

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 13c4b019a881..28ac35008e65 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -474,7 +474,7 @@ genl_family_name_to_id = None
 
     def _decode_enum(self, raw, attr_spec):
         enum = self.consts[attr_spec['enum']]
-        if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
+        if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
             i = 0
             value = set()
             while raw:

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

* Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-16 18:46       ` Jakub Kicinski
@ 2023-10-16 19:07         ` Willem de Bruijn
  2023-10-16 19:31           ` Willem de Bruijn
  2023-10-16 19:08         ` Stanislav Fomichev
  1 sibling, 1 reply; 12+ messages in thread
From: Willem de Bruijn @ 2023-10-16 19:07 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Stanislav Fomichev, davem, netdev, edumazet, pabeni, lorenzo,
	willemb

On Mon, Oct 16, 2023 at 2:46 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 16 Oct 2023 13:43:07 -0400 Willem de Bruijn wrote:
> > > Jakub, Willem hit an issue with this commit when running cli.py:
> > >
> > > ./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'
> > >
> > > Traceback (most recent call last):
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
> > >     main()
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
> > >     reply = ynl.dump(args.dump, attrs)
> > >             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
> > >     return self._op(method, vals, [], dump=True)
> > >            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
> > >     rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
> > >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
> > >     decoded = self._decode_enum(decoded, attr_spec)
> > >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
> > >     value = enum.entries_by_val[raw].name
> > >             ~~~~~~~~~~~~~~~~~~~^^^^^
> > > KeyError: 127
> >
> > Indeed. The field is now interpreted as a value rather than a bitmap.
> >
> > More subtly, even for requests that do not fail, all my devices now
> > incorrectly report to support xdp feature timestamp, because that is
> > enum 0.
>
> Sorry about that. This should fix it, right?
>
> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
> index 13c4b019a881..28ac35008e65 100644
> --- a/tools/net/ynl/lib/ynl.py
> +++ b/tools/net/ynl/lib/ynl.py
> @@ -474,7 +474,7 @@ genl_family_name_to_id = None
>
>      def _decode_enum(self, raw, attr_spec):
>          enum = self.consts[attr_spec['enum']]
> -        if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
> +        if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
>              i = 0
>              value = set()
>              while raw:

Mostly. The "set()" output is unintentional?

# ./cli.py --spec netdev.yaml --dump dev-get
[{'ifindex': 1, 'xdp-features': set(), 'xdp-rx-metadata-features': set()},
 {'ifindex': 2,
  'xdp-features': {'redirect', 'basic', 'rx-sg'},
  'xdp-rx-metadata-features': set()},
 {'ifindex': 3, 'xdp-features': set(), 'xdp-rx-metadata-features': set()}]

Contrast with netdev sample:

# ./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check): 0
      lo[1]     xdp-features (0): xdp-rx-metadata-features (0):
xdp-zc-max-segs=0
    eth0[2]     xdp-features (23): basic redirect rx-sg
xdp-rx-metadata-features (0): xdp-zc-max-segs=0
    sit0[3]     xdp-features (0): xdp-rx-metadata-features (0):
xdp-zc-max-segs=0

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

* Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-16 18:46       ` Jakub Kicinski
  2023-10-16 19:07         ` Willem de Bruijn
@ 2023-10-16 19:08         ` Stanislav Fomichev
  1 sibling, 0 replies; 12+ messages in thread
From: Stanislav Fomichev @ 2023-10-16 19:08 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Willem de Bruijn, davem, netdev, edumazet, pabeni, lorenzo,
	willemb

On Mon, Oct 16, 2023 at 11:46 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 16 Oct 2023 13:43:07 -0400 Willem de Bruijn wrote:
> > > Jakub, Willem hit an issue with this commit when running cli.py:
> > >
> > > ./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'
> > >
> > > Traceback (most recent call last):
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
> > >     main()
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
> > >     reply = ynl.dump(args.dump, attrs)
> > >             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
> > >     return self._op(method, vals, [], dump=True)
> > >            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
> > >     rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
> > >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
> > >     decoded = self._decode_enum(decoded, attr_spec)
> > >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
> > >     value = enum.entries_by_val[raw].name
> > >             ~~~~~~~~~~~~~~~~~~~^^^^^
> > > KeyError: 127
> >
> > Indeed. The field is now interpreted as a value rather than a bitmap.
> >
> > More subtly, even for requests that do not fail, all my devices now
> > incorrectly report to support xdp feature timestamp, because that is
> > enum 0.
>
> Sorry about that. This should fix it, right?

Yup, that fixes it for me, thanks!

Tested-by: Stanislav Fomichev <sdf@google.com>

> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
> index 13c4b019a881..28ac35008e65 100644
> --- a/tools/net/ynl/lib/ynl.py
> +++ b/tools/net/ynl/lib/ynl.py
> @@ -474,7 +474,7 @@ genl_family_name_to_id = None
>
>      def _decode_enum(self, raw, attr_spec):
>          enum = self.consts[attr_spec['enum']]
> -        if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
> +        if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
>              i = 0
>              value = set()
>              while raw:

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

* Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
  2023-10-16 19:07         ` Willem de Bruijn
@ 2023-10-16 19:31           ` Willem de Bruijn
  0 siblings, 0 replies; 12+ messages in thread
From: Willem de Bruijn @ 2023-10-16 19:31 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Stanislav Fomichev, davem, netdev, edumazet, pabeni, lorenzo,
	willemb

On Mon, Oct 16, 2023 at 3:07 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Mon, Oct 16, 2023 at 2:46 PM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Mon, 16 Oct 2023 13:43:07 -0400 Willem de Bruijn wrote:
> > > > Jakub, Willem hit an issue with this commit when running cli.py:
> > > >
> > > > ./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'
> > > >
> > > > Traceback (most recent call last):
> > > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
> > > >     main()
> > > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
> > > >     reply = ynl.dump(args.dump, attrs)
> > > >             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
> > > >     return self._op(method, vals, [], dump=True)
> > > >            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
> > > >     rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
> > > >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
> > > >     decoded = self._decode_enum(decoded, attr_spec)
> > > >               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > >   File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
> > > >     value = enum.entries_by_val[raw].name
> > > >             ~~~~~~~~~~~~~~~~~~~^^^^^
> > > > KeyError: 127
> > >
> > > Indeed. The field is now interpreted as a value rather than a bitmap.
> > >
> > > More subtly, even for requests that do not fail, all my devices now
> > > incorrectly report to support xdp feature timestamp, because that is
> > > enum 0.
> >
> > Sorry about that. This should fix it, right?
> >
> > diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
> > index 13c4b019a881..28ac35008e65 100644
> > --- a/tools/net/ynl/lib/ynl.py
> > +++ b/tools/net/ynl/lib/ynl.py
> > @@ -474,7 +474,7 @@ genl_family_name_to_id = None
> >
> >      def _decode_enum(self, raw, attr_spec):
> >          enum = self.consts[attr_spec['enum']]
> > -        if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
> > +        if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
> >              i = 0
> >              value = set()
> >              while raw:
>
> Mostly. The "set()" output is unintentional?

Never mind. That is the same at 0629f22ec130~1

Tested-by: Willem de Bruijn <willemb@google.com>

Thanks for the quick fix!

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

end of thread, other threads:[~2023-10-16 19:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
2023-10-03 15:34 ` [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags Jakub Kicinski
2023-10-16 17:34   ` Stanislav Fomichev
2023-10-16 17:43     ` Willem de Bruijn
2023-10-16 18:46       ` Jakub Kicinski
2023-10-16 19:07         ` Willem de Bruijn
2023-10-16 19:31           ` Willem de Bruijn
2023-10-16 19:08         ` Stanislav Fomichev
2023-10-03 15:34 ` [PATCH net-next 2/3] tools: ynl: don't regen on every make Jakub Kicinski
2023-10-03 15:34 ` [PATCH net-next 3/3] tools: ynl: use uAPI include magic for samples Jakub Kicinski
2023-10-03 16:00 ` [PATCH net-next 0/3] ynl Makefile cleanup Stanislav Fomichev
2023-10-05  0:40 ` patchwork-bot+netdevbpf

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