summaryrefslogtreecommitdiff
path: root/tools/net
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-06-01 19:35:47 -0700
committerJakub Kicinski <kuba@kernel.org>2023-06-02 22:10:47 -0700
commit8cb6afb3354172360881d6a644967c35f767ca2b (patch)
tree7fb6d8e9d7013c3d976e84d9d1b8de90cd61b5b8 /tools/net
parent5d58f911c75544eeb213e75a69912f330ad9f052 (diff)
tools: ynl-gen: switch to family struct
We'll want to store static info about the family soon. Generate a struct. This changes creation from, e.g.: ys = ynl_sock_create("netdev", &yerr); to: ys = ynl_sock_create(&ynl_netdev_family, &yerr); on user's side. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net')
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 4a7ca2823270..320e5e90920a 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -2109,6 +2109,16 @@ def render_uapi(family, cw):
cw.p(f'#endif /* {hdr_prot} */')
+def render_user_family(family, cw, prototype):
+ symbol = f'const struct ynl_family ynl_{family.c_name}_family'
+ if prototype:
+ cw.p(f'extern {symbol};')
+ else:
+ cw.block_start(f'{symbol} = ')
+ cw.p(f'.name = "{family.name}",')
+ cw.block_end(line=';')
+
+
def find_kernel_root(full_path):
sub_path = ''
while True:
@@ -2204,6 +2214,8 @@ def main():
cw.p(f'#include "{one}"')
else:
cw.p('struct ynl_sock;')
+ cw.nl()
+ render_user_family(parsed, cw, True)
cw.nl()
if args.mode == "kernel":
@@ -2397,6 +2409,9 @@ def main():
cw.p('/* --------------- Common notification parsing --------------- */')
print_ntf_type_parse(parsed, cw, args.mode)
+ cw.nl()
+ render_user_family(parsed, cw, False)
+
if args.header:
cw.p(f'#endif /* {hdr_prot} */')