Message ID | 0252b7d3f7af70ce5d9da688bae4f883b8dfa9c7.1677153730.git.lorenzo@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | update xdp_features flag according to NIC re-configuration | expand |
On Thu, 23 Feb 2023 13:11:33 +0100 Lorenzo Bianconi wrote: > + if const['type'] == 'flags': > + max_name = c_upper(name_pfx + 'mask') > + max_val = f' = {(entry.user_value() << 1) - 1},' > + cw.p(max_name + max_val) Could you use EnumSet::get_mask instead() ? I think it also needs to be fixed to actually walk the elements and combine the user_value()s rather than count them and assume there are no gaps.
> On Thu, 23 Feb 2023 13:11:33 +0100 Lorenzo Bianconi wrote: > > + if const['type'] == 'flags': > > + max_name = c_upper(name_pfx + 'mask') > > + max_val = f' = {(entry.user_value() << 1) - 1},' > > + cw.p(max_name + max_val) > > Could you use EnumSet::get_mask instead() ? ack, I will fix it. > > I think it also needs to be fixed to actually walk the elements > and combine the user_value()s rather than count them and assume > there are no gaps. Do you mean get_mask()? Regards, Lorenzo
On Wed, 1 Mar 2023 00:16:16 +0100 Lorenzo Bianconi wrote: > > I think it also needs to be fixed to actually walk the elements > > and combine the user_value()s rather than count them and assume > > there are no gaps. > > Do you mean get_mask()? Yup, get_mask() predates the ability to control the values of enum entries individually so while at it we should fix it.
> On Wed, 1 Mar 2023 00:16:16 +0100 Lorenzo Bianconi wrote: > > > I think it also needs to be fixed to actually walk the elements > > > and combine the user_value()s rather than count them and assume > > > there are no gaps. > > > > Do you mean get_mask()? > > Yup, get_mask() predates the ability to control the values of enum > entries individually so while at it we should fix it. ack, I will add a separated patch to the series. Regards, Lorenzo
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 3942f24b9163..161ae02bee54 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -1995,9 +1995,14 @@ def render_uapi(family, cw): if const.get('render-max', False): cw.nl() - max_name = c_upper(name_pfx + 'max') - cw.p('__' + max_name + ',') - cw.p(max_name + ' = (__' + max_name + ' - 1)') + if const['type'] == 'flags': + max_name = c_upper(name_pfx + 'mask') + max_val = f' = {(entry.user_value() << 1) - 1},' + cw.p(max_name + max_val) + else: + max_name = c_upper(name_pfx + 'max') + cw.p('__' + max_name + ',') + cw.p(max_name + ' = (__' + max_name + ' - 1)') cw.block_end(line=';') cw.nl() elif const['type'] == 'const':
Properly manage render-max property for flags definition type introducing mask value and setting it to (last_element << 1) - 1 instead of adding max value set to last_element + 1 Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> --- tools/net/ynl/ynl-gen-c.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)