netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tools: ynl-gen: handle do ops with no input attrs
@ 2023-10-06 13:50 Jakub Kicinski
  2023-10-07  8:26 ` Lorenzo Bianconi
  2023-10-10  2:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-10-06 13:50 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, Jakub Kicinski, Lorenzo Bianconi

The code supports dumps with no input attributes currently
thru a combination of special-casing and luck.
Clean up the handling of ops with no inputs. Create empty
Structs, and skip printing of empty types.
This makes dos with no inputs work.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
--
CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

Hi Lorenzo, the StructNone from my initial patch felt a little
too hacky, so I ditched it :) Could you double check that this
works the same as the previous version?
---
 tools/net/ynl/ynl-gen-c.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 168fe612b029..f125b5f704ba 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -1041,9 +1041,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
         if op_mode == 'notify':
             op_mode = 'do'
         for op_dir in ['request', 'reply']:
-            if op and op_dir in op[op_mode]:
-                self.struct[op_dir] = Struct(family, self.attr_set,
-                                             type_list=op[op_mode][op_dir]['attributes'])
+            if op:
+                type_list = []
+                if op_dir in op[op_mode]:
+                    type_list = op[op_mode][op_dir]['attributes']
+                self.struct[op_dir] = Struct(family, self.attr_set, type_list=type_list)
         if op_mode == 'event':
             self.struct['reply'] = Struct(family, self.attr_set, type_list=op['event']['attributes'])
 
@@ -1752,6 +1754,8 @@ _C_KW = {
 
 
 def print_req_type_helpers(ri):
+    if len(ri.struct["request"].attr_list) == 0:
+        return
     print_alloc_wrapper(ri, "request")
     print_type_helpers(ri, "request")
 
@@ -1773,6 +1777,8 @@ _C_KW = {
 
 
 def print_req_type(ri):
+    if len(ri.struct["request"].attr_list) == 0:
+        return
     print_type(ri, "request")
 
 
@@ -2515,9 +2521,8 @@ _C_KW = {
                 if 'dump' in op:
                     cw.p(f"/* {op.enum_name} - dump */")
                     ri = RenderInfo(cw, parsed, args.mode, op, 'dump')
-                    if 'request' in op['dump']:
-                        print_req_type(ri)
-                        print_req_type_helpers(ri)
+                    print_req_type(ri)
+                    print_req_type_helpers(ri)
                     if not ri.type_consistent:
                         print_rsp_type(ri)
                     print_wrapped_type(ri)
-- 
2.41.0


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

* Re: [PATCH net-next] tools: ynl-gen: handle do ops with no input attrs
  2023-10-06 13:50 [PATCH net-next] tools: ynl-gen: handle do ops with no input attrs Jakub Kicinski
@ 2023-10-07  8:26 ` Lorenzo Bianconi
  2023-10-10  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2023-10-07  8:26 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni

[-- Attachment #1: Type: text/plain, Size: 2845 bytes --]

> The code supports dumps with no input attributes currently
> thru a combination of special-casing and luck.
> Clean up the handling of ops with no inputs. Create empty
> Structs, and skip printing of empty types.
> This makes dos with no inputs work.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> --
> CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> 
> Hi Lorenzo, the StructNone from my initial patch felt a little
> too hacky, so I ditched it :) Could you double check that this
> works the same as the previous version?
> ---
>  tools/net/ynl/ynl-gen-c.py | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)

Tested-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

Regards,
Lorenzo

> 
> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> index 168fe612b029..f125b5f704ba 100755
> --- a/tools/net/ynl/ynl-gen-c.py
> +++ b/tools/net/ynl/ynl-gen-c.py
> @@ -1041,9 +1041,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
>          if op_mode == 'notify':
>              op_mode = 'do'
>          for op_dir in ['request', 'reply']:
> -            if op and op_dir in op[op_mode]:
> -                self.struct[op_dir] = Struct(family, self.attr_set,
> -                                             type_list=op[op_mode][op_dir]['attributes'])
> +            if op:
> +                type_list = []
> +                if op_dir in op[op_mode]:
> +                    type_list = op[op_mode][op_dir]['attributes']
> +                self.struct[op_dir] = Struct(family, self.attr_set, type_list=type_list)
>          if op_mode == 'event':
>              self.struct['reply'] = Struct(family, self.attr_set, type_list=op['event']['attributes'])
>  
> @@ -1752,6 +1754,8 @@ _C_KW = {
>  
>  
>  def print_req_type_helpers(ri):
> +    if len(ri.struct["request"].attr_list) == 0:
> +        return
>      print_alloc_wrapper(ri, "request")
>      print_type_helpers(ri, "request")
>  
> @@ -1773,6 +1777,8 @@ _C_KW = {
>  
>  
>  def print_req_type(ri):
> +    if len(ri.struct["request"].attr_list) == 0:
> +        return
>      print_type(ri, "request")
>  
>  
> @@ -2515,9 +2521,8 @@ _C_KW = {
>                  if 'dump' in op:
>                      cw.p(f"/* {op.enum_name} - dump */")
>                      ri = RenderInfo(cw, parsed, args.mode, op, 'dump')
> -                    if 'request' in op['dump']:
> -                        print_req_type(ri)
> -                        print_req_type_helpers(ri)
> +                    print_req_type(ri)
> +                    print_req_type_helpers(ri)
>                      if not ri.type_consistent:
>                          print_rsp_type(ri)
>                      print_wrapped_type(ri)
> -- 
> 2.41.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH net-next] tools: ynl-gen: handle do ops with no input attrs
  2023-10-06 13:50 [PATCH net-next] tools: ynl-gen: handle do ops with no input attrs Jakub Kicinski
  2023-10-07  8:26 ` Lorenzo Bianconi
@ 2023-10-10  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-10  2:50 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, lorenzo.bianconi

Hello:

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

On Fri,  6 Oct 2023 06:50:32 -0700 you wrote:
> The code supports dumps with no input attributes currently
> thru a combination of special-casing and luck.
> Clean up the handling of ops with no inputs. Create empty
> Structs, and skip printing of empty types.
> This makes dos with no inputs work.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> --
> CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> 
> [...]

Here is the summary with links:
  - [net-next] tools: ynl-gen: handle do ops with no input attrs
    https://git.kernel.org/netdev/net-next/c/8cea95b0bd79

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] 3+ messages in thread

end of thread, other threads:[~2023-10-10  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 13:50 [PATCH net-next] tools: ynl-gen: handle do ops with no input attrs Jakub Kicinski
2023-10-07  8:26 ` Lorenzo Bianconi
2023-10-10  2:50 ` 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).