Message ID | 20241113181023.2030098-2-sdf@fomichev.me (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ethtool: generate uapi header from the spec | expand |
On Wed, 13 Nov 2024 10:10:17 -0800 Stanislav Fomichev wrote: > This is similar to existing attr-cnt-name in the attributes > to allow changing the name of the 'count' enum entry. why attr- ? we have similar attrs for cmd and we use cmd- as a prefix, so I'd just use enum- I'd put it into genetlink-c level (you'll have to copy/paste into two specs), all the non-functional stuff related to C code gen is in the genetlink-c spec Please double check Documentation doesn't need extending
On 11/13, Jakub Kicinski wrote: > On Wed, 13 Nov 2024 10:10:17 -0800 Stanislav Fomichev wrote: > > This is similar to existing attr-cnt-name in the attributes > > to allow changing the name of the 'count' enum entry. > > why attr- ? we have similar attrs for cmd and we use cmd- as a prefix, > so I'd just use enum- Mostly because I don't have too much state on the spec side :-[ Did a copy-paste from the attributes... Will switch to enum. > I'd put it into genetlink-c level (you'll have to copy/paste into two > specs), all the non-functional stuff related to C code gen is in the > genetlink-c spec > > Please double check Documentation doesn't need extending Will do, thanks for the pointers! The doc is definitely missing.
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 8db0e22fa72c..83f874ae7198 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -119,6 +119,9 @@ additionalProperties: False type: string # End genetlink-c # Start genetlink-legacy + attr-cnt-name: + description: Name of the render-max counter enum entry. + type: string members: description: List of struct members. Only scalars and strings members allowed. type: array diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index c48b69071111..210972b4796a 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.attr_cnt_name = yaml.get('attr-cnt-name', None) super().__init__(family, yaml) @@ -2468,9 +2469,12 @@ _C_KW = { max_val = f' = {enum.get_mask()},' cw.p(max_name + max_val) else: + cnt_name = enum.attr_cnt_name max_name = c_upper(name_pfx + 'max') - cw.p('__' + max_name + ',') - cw.p(max_name + ' = (__' + max_name + ' - 1)') + if not cnt_name: + cnt_name = '__' + c_upper(name_pfx + 'max') + cw.p(cnt_name + ',') + cw.p(max_name + ' = (' + cnt_name + ' - 1)') cw.block_end(line=';') cw.nl() elif const['type'] == 'const':
This is similar to existing attr-cnt-name in the attributes to allow changing the name of the 'count' enum entry. Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> --- Documentation/netlink/genetlink-legacy.yaml | 3 +++ tools/net/ynl/ynl-gen-c.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)