diff mbox series

[net-next,2/7] ynl: support render attribute in legacy definitions

Message ID 20241113181023.2030098-3-sdf@fomichev.me (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ethtool: generate uapi header from the spec | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl fail Generated files up to date; build failed; build has 3 warnings/errors; GEN HAS DIFF 2 files changed, 75 insertions(+), 10 deletions(-);
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success Errors and warnings before: 0 (+0) this patch: 0 (+0)
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Stanislav Fomichev Nov. 13, 2024, 6:10 p.m. UTC
To allow omitting some of the attributes in the final generated file.
Some of the definitions that seemingly belong to the spec
are defined in the ethtool.h. To minimize the amount of churn,
skip rendering a similar (and conflicting) definition from the spec.

Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
 Documentation/netlink/genetlink-legacy.yaml | 5 +++++
 tools/net/ynl/ynl-gen-c.py                  | 4 ++++
 2 files changed, 9 insertions(+)

Comments

Jakub Kicinski Nov. 13, 2024, 8:11 p.m. UTC | #1
On Wed, 13 Nov 2024 10:10:18 -0800 Stanislav Fomichev wrote:
> To allow omitting some of the attributes in the final generated file.
> Some of the definitions that seemingly belong to the spec
> are defined in the ethtool.h. To minimize the amount of churn,
> skip rendering a similar (and conflicting) definition from the spec.

Hm, is this mostly for enums and definitions? We have header: for this.
"header" should tell the codegen that the define is "foreign" and
should be skipped in uAPI, and in -user codegen we need an include.

Coincidentally

make -C tools/net/ynl/ -j

In file included from ethtool-user.c:9:
ethtool-user.h:13:10: fatal error: linux/ethetool_netlink_generated.h: No such file or directory
   13 | #include <linux/ethetool_netlink_generated.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stanislav Fomichev Nov. 13, 2024, 11:40 p.m. UTC | #2
On 11/13, Jakub Kicinski wrote:
> On Wed, 13 Nov 2024 10:10:18 -0800 Stanislav Fomichev wrote:
> > To allow omitting some of the attributes in the final generated file.
> > Some of the definitions that seemingly belong to the spec
> > are defined in the ethtool.h. To minimize the amount of churn,
> > skip rendering a similar (and conflicting) definition from the spec.
> 
> Hm, is this mostly for enums and definitions? We have header: for this.
> "header" should tell the codegen that the define is "foreign" and
> should be skipped in uAPI, and in -user codegen we need an include.
> 
> Coincidentally
> 
> make -C tools/net/ynl/ -j
> 
> In file included from ethtool-user.c:9:
> ethtool-user.h:13:10: fatal error: linux/ethetool_netlink_generated.h: No such file or directory
>    13 | #include <linux/ethetool_netlink_generated.h>
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I don't see any existing usage (or maybe I'm looking at the wrong
place), but will spend some time reading the c-gen part. Worst case I
might refresh this thread with more questions.
Jakub Kicinski Nov. 14, 2024, 2:33 a.m. UTC | #3
On Wed, 13 Nov 2024 15:40:00 -0800 Stanislav Fomichev wrote:
> > In file included from ethtool-user.c:9:
> > ethtool-user.h:13:10: fatal error: linux/ethetool_netlink_generated.h: No such file or directory
> >    13 | #include <linux/ethetool_netlink_generated.h>
> >       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 
> I don't see any existing usage (or maybe I'm looking at the wrong
> place), but will spend some time reading the c-gen part. Worst case I
> might refresh this thread with more questions.

Could be the magic in the makefiles that tries to include uAPI
headers directly that needs updating.
diff mbox series

Patch

diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 83f874ae7198..cdda9e6f4062 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -83,6 +83,11 @@  additionalProperties: False
           enum: [ const, enum, flags, struct ] # Trim
         doc:
           type: string
+        # Start genetlink-legacy
+        render:
+          description: Render this definition (true by default) or not.
+          type: boolean
+        # End genetlink-legacy
         # For const
         value:
           description: For const - the value.
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 210972b4796a..0de918c7f18d 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -798,6 +798,7 @@  from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
             self.user_type = 'int'
 
         self.value_pfx = yaml.get('name-prefix', f"{family.ident_name}-{yaml['name']}-")
+        self.render = yaml.get('render', True)
         self.attr_cnt_name = yaml.get('attr-cnt-name', None)
 
         super().__init__(family, yaml)
@@ -2437,6 +2438,9 @@  _C_KW = {
         if const['type'] == 'enum' or const['type'] == 'flags':
             enum = family.consts[const['name']]
 
+            if not enum.render:
+                continue
+
             if enum.has_doc():
                 if enum.has_entry_doc():
                     cw.p('/**')