From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
jiri@resnulli.us, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 02/11] tools: ynl-gen: use enum names in op strmap more carefully
Date: Wed, 7 Jun 2023 13:23:54 -0700 [thread overview]
Message-ID: <20230607202403.1089925-3-kuba@kernel.org> (raw)
In-Reply-To: <20230607202403.1089925-1-kuba@kernel.org>
In preparation for supporting families which use different msg
ids to and from the kernel - make sure the ids in op strmap
are correct. The map is expected to be used mostly for notifications,
don't generate a separate map for the "to kernel" direction.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/generated/fou-user.c | 1 -
tools/net/ynl/lib/nlspec.py | 4 ++++
tools/net/ynl/ynl-gen-c.py | 6 +++++-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/net/ynl/generated/fou-user.c b/tools/net/ynl/generated/fou-user.c
index c99b5d438021..a0f33bb882e4 100644
--- a/tools/net/ynl/generated/fou-user.c
+++ b/tools/net/ynl/generated/fou-user.c
@@ -16,7 +16,6 @@
/* Enums */
static const char * const fou_op_strmap[] = {
- [FOU_CMD_UNSPEC] = "unspec",
[FOU_CMD_ADD] = "add",
[FOU_CMD_DEL] = "del",
[FOU_CMD_GET] = "get",
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index ada22b073aa2..bd5da8aaeac7 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -442,6 +442,10 @@ jsonschema = None
else:
raise Exception("Can't parse directional ops")
+ if req_val == req_val_next:
+ req_val = None
+ if rsp_val == rsp_val_next:
+ rsp_val = None
op = self.new_operation(elem, req_val, rsp_val)
req_val = req_val_next
rsp_val = rsp_val_next
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index c07340715601..8a0abf9048db 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -1220,7 +1220,11 @@ _C_KW = {
map_name = f'{family.name}_op_strmap'
cw.block_start(line=f"static const char * const {map_name}[] =")
for op_name, op in family.msgs.items():
- cw.p(f'[{op.enum_name}] = "{op_name}",')
+ if op.rsp_value:
+ if op.req_value == op.rsp_value:
+ cw.p(f'[{op.enum_name}] = "{op_name}",')
+ else:
+ cw.p(f'[{op.rsp_value}] = "{op_name}",')
cw.block_end(line=';')
cw.nl()
--
2.40.1
next prev parent reply other threads:[~2023-06-07 20:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 20:23 [PATCH net-next 00/11] tools: ynl: generate code for the devlink family Jakub Kicinski
2023-06-07 20:23 ` [PATCH net-next 01/11] netlink: specs: devlink: fill in some details important for C Jakub Kicinski
2023-06-07 20:23 ` Jakub Kicinski [this message]
2023-06-07 20:23 ` [PATCH net-next 03/11] tools: ynl-gen: refactor strmap helper generation Jakub Kicinski
2023-06-07 20:23 ` [PATCH net-next 04/11] tools: ynl-gen: enable code gen for directional specs Jakub Kicinski
2023-06-07 20:23 ` [PATCH net-next 05/11] tools: ynl-gen: try to sort the types more intelligently Jakub Kicinski
2023-06-07 20:23 ` [PATCH net-next 06/11] tools: ynl-gen: inherit struct use info Jakub Kicinski
2023-06-07 20:23 ` [PATCH net-next 07/11] tools: ynl-gen: walk nested types in depth Jakub Kicinski
2023-06-07 20:24 ` [PATCH net-next 08/11] tools: ynl-gen: don't generate forward declarations for policies Jakub Kicinski
2023-06-07 20:24 ` [PATCH net-next 09/11] tools: ynl-gen: don't generate forward declarations for policies - regen Jakub Kicinski
2023-06-07 20:24 ` [PATCH net-next 10/11] tools: ynl: generate code for the devlink family Jakub Kicinski
2023-06-08 11:48 ` Simon Horman
2023-06-08 15:53 ` Jakub Kicinski
2023-06-09 7:46 ` Simon Horman
2023-06-07 20:24 ` [PATCH net-next 11/11] tools: ynl: add sample for devlink Jakub Kicinski
2023-06-08 21:10 ` [PATCH net-next 00/11] tools: ynl: generate code for the devlink family patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230607202403.1089925-3-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).