* [PATCH net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level
@ 2023-10-25 18:27 Jakub Kicinski
2023-10-26 6:25 ` Jiri Pirko
2023-10-27 2:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-10-25 18:27 UTC (permalink / raw)
To: davem; +Cc: netdev, edumazet, pabeni, martineau, Jakub Kicinski,
Davide Caratti
Davide reports that we look for the attr-cnt-name in the wrong
object. We try to read it from the family, but the schema only
allows for it to exist at attr-set level.
Reported-by: Davide Caratti <dcaratti@redhat.com>
Link: https://lore.kernel.org/all/CAKa-r6vCj+gPEUKpv7AsXqM77N6pB0evuh7myHq=585RA3oD5g@mail.gmail.com/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Looking at the schema this is plain wrong, so we should fix
regardless of what you decide to do with MPTCP.
---
tools/net/ynl/ynl-gen-c.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 1c7474ad92dc..13427436bfb7 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -789,9 +789,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
pfx = f"{family.name}-a-{self.name}-"
self.name_prefix = c_upper(pfx)
self.max_name = c_upper(self.yaml.get('attr-max-name', f"{self.name_prefix}max"))
+ self.cnt_name = c_upper(self.yaml.get('attr-cnt-name', f"__{self.name_prefix}max"))
else:
self.name_prefix = family.attr_sets[self.subset_of].name_prefix
self.max_name = family.attr_sets[self.subset_of].max_name
+ self.cnt_name = family.attr_sets[self.subset_of].cnt_name
# Added by resolve:
self.c_name = None
@@ -2354,8 +2356,7 @@ _C_KW = {
if attr_set.subset_of:
continue
- cnt_name = c_upper(family.get('attr-cnt-name', f"__{attr_set.name_prefix}MAX"))
- max_value = f"({cnt_name} - 1)"
+ max_value = f"({attr_set.cnt_name} - 1)"
val = 0
uapi_enum_start(family, cw, attr_set.yaml, 'enum-name')
@@ -2367,7 +2368,7 @@ _C_KW = {
val += 1
cw.p(attr.enum_name + suffix)
cw.nl()
- cw.p(cnt_name + ('' if max_by_define else ','))
+ cw.p(attr_set.cnt_name + ('' if max_by_define else ','))
if not max_by_define:
cw.p(f"{attr_set.max_name} = {max_value}")
cw.block_end(line=';')
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level
2023-10-25 18:27 [PATCH net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level Jakub Kicinski
@ 2023-10-26 6:25 ` Jiri Pirko
2023-10-27 2:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2023-10-26 6:25 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, martineau, Davide Caratti
Wed, Oct 25, 2023 at 08:27:39PM CEST, kuba@kernel.org wrote:
>Davide reports that we look for the attr-cnt-name in the wrong
>object. We try to read it from the family, but the schema only
>allows for it to exist at attr-set level.
>
>Reported-by: Davide Caratti <dcaratti@redhat.com>
>Link: https://lore.kernel.org/all/CAKa-r6vCj+gPEUKpv7AsXqM77N6pB0evuh7myHq=585RA3oD5g@mail.gmail.com/
>Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level
2023-10-25 18:27 [PATCH net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level Jakub Kicinski
2023-10-26 6:25 ` Jiri Pirko
@ 2023-10-27 2:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-27 2:50 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, martineau, dcaratti
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 25 Oct 2023 11:27:39 -0700 you wrote:
> Davide reports that we look for the attr-cnt-name in the wrong
> object. We try to read it from the family, but the schema only
> allows for it to exist at attr-set level.
>
> Reported-by: Davide Caratti <dcaratti@redhat.com>
> Link: https://lore.kernel.org/all/CAKa-r6vCj+gPEUKpv7AsXqM77N6pB0evuh7myHq=585RA3oD5g@mail.gmail.com/
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> [...]
Here is the summary with links:
- [net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level
https://git.kernel.org/netdev/net-next/c/eb9df668381d
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-27 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-25 18:27 [PATCH net-next] tools: ynl-gen: respect attr-cnt-name at the attr set level Jakub Kicinski
2023-10-26 6:25 ` Jiri Pirko
2023-10-27 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).