Commit 8cb6afb3 authored by Jakub Kicinski's avatar Jakub Kicinski

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: default avatarJakub Kicinski <kuba@kernel.org>
parent 5d58f911
...@@ -2109,6 +2109,16 @@ def render_uapi(family, cw): ...@@ -2109,6 +2109,16 @@ def render_uapi(family, cw):
cw.p(f'#endif /* {hdr_prot} */') 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): def find_kernel_root(full_path):
sub_path = '' sub_path = ''
while True: while True:
...@@ -2205,6 +2215,8 @@ def main(): ...@@ -2205,6 +2215,8 @@ def main():
else: else:
cw.p('struct ynl_sock;') cw.p('struct ynl_sock;')
cw.nl() cw.nl()
render_user_family(parsed, cw, True)
cw.nl()
if args.mode == "kernel": if args.mode == "kernel":
if args.header: if args.header:
...@@ -2397,6 +2409,9 @@ def main(): ...@@ -2397,6 +2409,9 @@ def main():
cw.p('/* --------------- Common notification parsing --------------- */') cw.p('/* --------------- Common notification parsing --------------- */')
print_ntf_type_parse(parsed, cw, args.mode) print_ntf_type_parse(parsed, cw, args.mode)
cw.nl()
render_user_family(parsed, cw, False)
if args.header: if args.header:
cw.p(f'#endif /* {hdr_prot} */') cw.p(f'#endif /* {hdr_prot} */')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment