Subject: Re: [PATCH net-next 3/3] tools: ynl: cli: Display enum values in --list-attrs output

From: Donald Hunter <[email-masked]>
Date: Mon, 17 Nov 2025 16:05:22 +0000

Gal Pressman <[email-masked]> writes:

> When listing attributes with --list-attrs, display the actual enum
> values for attributes that reference an enum type.
>
>   # ./cli.py --family netdev --list-attrs dev-get
>   [..]
>     - xdp-features: u64 (enum: xdp-act)
>       Values: basic, redirect, ndo-xmit, xsk-zerocopy, hw-offload, rx-sg, ndo-xmit-sg
>       Bitmask of enabled xdp-features.
>   [..]
>
> Reviewed-by: Nimrod Oren <[email-masked]>
> Signed-off-by: Gal Pressman <[email-masked]>
> ---
>  tools/net/ynl/pyynl/cli.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/net/ynl/pyynl/cli.py b/tools/net/ynl/pyynl/cli.py
> index 3389e552ec4e..d305add514cd 100755
> --- a/tools/net/ynl/pyynl/cli.py
> +++ b/tools/net/ynl/pyynl/cli.py
> @@ -139,7 +139,12 @@ def main():
>                  attr = attr_set.attrs[attr_name]
>                  attr_info = f'{prefix}- {attr_name}: {attr.type}'
>                  if 'enum' in attr.yaml:
> -                    attr_info += f" (enum: {attr.yaml['enum']})"
> +                    enum_name = attr.yaml['enum']
> +                    attr_info += f" (enum: {enum_name})"

Would be good to say enum | flags so that people know what semantics are valid.

> +                    # Print enum values if available
> +                    if enum_name in ynl.consts:
> +                        enum_values = list(ynl.consts[enum_name].entries.keys())
> +                        attr_info += f"\n{prefix}  Values: {', '.join(enum_values)}"

This produces quite noisy output for e.g.

./tools/net/ynl/pyynl/cli.py --family ethtool --list-attrs rss-get

Not sure what to suggest to improve readability but maybe it doesn't
need 'Values:' or commas, or perhaps only output each enum once?

>  
>                  # Show nested attributes reference and recursively display them
>                  nested_set_name = None