Lines Matching full:family

48     def __init__(self, family, attr_set, attr, value):  argument
49 super().__init__(family, attr_set, attr, value)
64 if self.nested_attrs == family.name:
65 self.nested_render_name = c_lower(f"{family.ident_name}")
67 self.nested_render_name = c_lower(f"{family.ident_name}_{self.nested_attrs}")
69 if self.nested_attrs in self.family.consts:
88 if value in self.family.consts:
89 raise Exception("Resolving family constants not implemented, yet")
98 if value in self.family.consts:
99 return c_upper(f"{self.family['name']}-{value}")
313 def __init__(self, family, attr_set, attr, value): argument
314 super().__init__(family, attr_set, attr, value)
321 enum = self.family.consts[self.attr['enum']]
353 self.is_bitfield = self.family.consts[self.attr['enum']]['type'] == 'flags'
358 self.type_name = self.family.consts[self.attr['enum']].user_type
367 enum = self.family.consts[self.attr['enum']]
370 flags = self.family.consts[self.checks['flags-mask']]
532 enum = self.family.consts[self.attr['enum']]
549 return self.family.pure_nested_structs[self.nested_attrs].recursive
582 for _, attr in ri.family.pure_nested_structs[self.nested_attrs].member_list():
589 def __init__(self, family, attr_set, attr, value, base_type): argument
590 super().__init__(family, attr_set, attr, value)
709 def __init__(self, family, space_name, type_list=None, inherited=None): argument
710 self.family = family
712 self.attr_set = family.attr_sets[space_name]
718 if family.name == c_lower(space_name):
719 self.render_name = c_lower(family.ident_name)
721 self.render_name = c_lower(family.ident_name + '-' + space_name)
723 if self.nested and space_name in family.consts:
786 def __init__(self, family, yaml): argument
787 self.render_name = c_lower(family.ident_name + '-' + yaml['name'])
803 self.value_pfx = yaml.get('name-prefix', f"{family.ident_name}-{yaml['name']}-")
805 super().__init__(family, yaml)
821 def __init__(self, family, yaml): argument
822 super().__init__(family, yaml)
827 elif self.name == family.name:
828 pfx = family.ident_name + '-a-'
830 pfx = f"{family.ident_name}-a-{self.name}-"
835 self.name_prefix = family.attr_sets[self.subset_of].name_prefix
836 self.max_name = family.attr_sets[self.subset_of].max_name
837 self.cnt_name = family.attr_sets[self.subset_of].cnt_name
847 if self.c_name == self.family.c_name:
852 t = TypeScalar(self.family, self, elem, value)
854 t = TypeUnused(self.family, self, elem, value)
856 t = TypePad(self.family, self, elem, value)
858 t = TypeFlag(self.family, self, elem, value)
860 t = TypeString(self.family, self, elem, value)
862 t = TypeBinary(self.family, self, elem, value)
864 t = TypeBitfield32(self.family, self, elem, value)
866 t = TypeNest(self.family, self, elem, value)
869 t = TypeArrayNest(self.family, self, elem, value)
873 t = TypeNestTypeValue(self.family, self, elem, value)
878 t = TypeMultiAttr(self.family, self, elem, value, t)
884 def __init__(self, family, yaml, req_value, rsp_value): argument
885 super().__init__(family, yaml, req_value, rsp_value)
887 self.render_name = c_lower(family.ident_name + '_' + self.name)
902 self.enum_name = self.family.op_prefix + c_upper(self.name)
904 self.enum_name = self.family.async_op_prefix + c_upper(self.name)
910 class Family(SpecFamily): class
928 self.fam_key = c_upper(self.yaml.get('c-family-name', self.yaml["name"] + '_FAMILY_NAME'))
1174 def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None): argument
1175 self.family = family
1205 if attr_set in family.consts:
1218 self.struct[op_dir] = Struct(family, self.attr_set, type_list=type_list)
1220 … self.struct['reply'] = Struct(family, self.attr_set, type_list=op['event']['attributes'])
1499 return f"{ri.family.c_name}{suffix}"
1568 def put_op_name_fwd(family, cw): argument
1569 cw.write_func_prot('const char *', f'{family.c_name}_op_str', ['int op'], suffix=';')
1572 def put_op_name(family, cw): argument
1573 map_name = f'{family.c_name}_op_strmap'
1575 for op_name, op in family.msgs.items():
1579 if family.rsp_by_value[op.rsp_value] != op:
1590 _put_enum_to_str_helper(cw, family.c_name + '_op', map_name, 'op')
1593 def put_enum_to_str_fwd(family, cw, enum): argument
1598 def put_enum_to_str(family, cw, enum): argument
1642 iter_line = "ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len)"
1945 ri.cw.block_start(line=f"struct {ri.family.c_name}{suffix}")
2042 ri.cw.p('__u16 family;')
2124 if terminate and ri and policy_should_be_static(struct.family):
2130 if ri and policy_should_be_static(struct.family):
2158 def kernel_can_gen_family_struct(family): argument
2159 return family.proto == 'genetlink'
2162 def policy_should_be_static(family): argument
2163 return family.kernel_policy == 'split' or kernel_can_gen_family_struct(family)
2166 def print_kernel_policy_ranges(family, cw): argument
2168 for _, attr_set in family.attr_sets.items():
2195 def print_kernel_op_table_fwd(family, cw, terminate): argument
2196 exported = not kernel_can_gen_family_struct(family)
2199 cw.p(f"/* Ops table for {family.ident_name} */")
2204 struct_type = pol_to_struct[family.kernel_policy]
2208 elif family.kernel_policy == 'split':
2210 for op in family.ops.values():
2216 cnt = len(family.ops)
2219 line = f"{qual} struct {struct_type} {family.c_name}_nl_ops[{cnt}]"
2229 for name in family.hooks['pre']['do']['list']:
2233 for name in family.hooks['post']['do']['list']:
2237 for name in family.hooks['pre']['dump']['list']:
2240 for name in family.hooks['post']['dump']['list']:
2246 for op_name, op in family.ops.items():
2251 name = c_lower(f"{family.ident_name}-nl-{op_name}-doit")
2256 name = c_lower(f"{family.ident_name}-nl-{op_name}-dumpit")
2262 def print_kernel_op_table_hdr(family, cw): argument
2263 print_kernel_op_table_fwd(family, cw, terminate=True)
2266 def print_kernel_op_table(family, cw): argument
2267 print_kernel_op_table_fwd(family, cw, terminate=False)
2268 if family.kernel_policy == 'global' or family.kernel_policy == 'per-op':
2269 for op_name, op in family.ops.items():
2282 name = c_lower(f"{family.ident_name}-nl-{op_name}-{op_mode}it")
2284 if family.kernel_policy == 'per-op':
2285 struct = Struct(family, op['attribute-set'],
2288 name = c_lower(f"{family.ident_name}-{op_name}-nl-policy")
2295 elif family.kernel_policy == 'split':
2299 for op_name, op in family.ops.items():
2320 name = c_lower(f"{family.ident_name}-nl-{op_name}-{op_mode}it")
2327 struct = Struct(family, op['attribute-set'],
2331 name = c_lower(f"{family.ident_name}-{op_name}-{op_mode}-nl-policy")
2333 name = c_lower(f"{family.ident_name}-{op_name}-nl-policy")
2346 def print_kernel_mcgrp_hdr(family, cw): argument
2347 if not family.mcgrps['list']:
2351 for grp in family.mcgrps['list']:
2352 grp_id = c_upper(f"{family.ident_name}-nlgrp-{grp['name']},")
2358 def print_kernel_mcgrp_src(family, cw): argument
2359 if not family.mcgrps['list']:
2362 cw.block_start('static const struct genl_multicast_group ' + family.c_name + '_nl_mcgrps[] =')
2363 for grp in family.mcgrps['list']:
2365 grp_id = c_upper(f"{family.ident_name}-nlgrp-{name}")
2371 def print_kernel_family_struct_hdr(family, cw): argument
2372 if not kernel_can_gen_family_struct(family):
2375 cw.p(f"extern struct genl_family {family.c_name}_nl_family;")
2377 if 'sock-priv' in family.kernel_family:
2378 cw.p(f'void {family.c_name}_nl_sock_priv_init({family.kernel_family["sock-priv"]} *priv);')
2379 … cw.p(f'void {family.c_name}_nl_sock_priv_destroy({family.kernel_family["sock-priv"]} *priv);')
2383 def print_kernel_family_struct_src(family, cw): argument
2384 if not kernel_can_gen_family_struct(family):
2387 cw.block_start(f"struct genl_family {family.ident_name}_nl_family __ro_after_init =")
2388 cw.p('.name\t\t= ' + family.fam_key + ',')
2389 cw.p('.version\t= ' + family.ver_key + ',')
2393 if family.kernel_policy == 'per-op':
2394 cw.p(f'.ops\t\t= {family.c_name}_nl_ops,')
2395 cw.p(f'.n_ops\t\t= ARRAY_SIZE({family.c_name}_nl_ops),')
2396 elif family.kernel_policy == 'split':
2397 cw.p(f'.split_ops\t= {family.c_name}_nl_ops,')
2398 cw.p(f'.n_split_ops\t= ARRAY_SIZE({family.c_name}_nl_ops),')
2399 if family.mcgrps['list']:
2400 cw.p(f'.mcgrps\t\t= {family.c_name}_nl_mcgrps,')
2401 cw.p(f'.n_mcgrps\t= ARRAY_SIZE({family.c_name}_nl_mcgrps),')
2402 if 'sock-priv' in family.kernel_family:
2403 cw.p(f'.sock_priv_size\t= sizeof({family.kernel_family["sock-priv"]}),')
2405 cw.p(f'.sock_priv_init\t= (void *){family.c_name}_nl_sock_priv_init,')
2406 cw.p(f'.sock_priv_destroy = (void *){family.c_name}_nl_sock_priv_destroy,')
2410 def uapi_enum_start(family, cw, obj, ckey='', enum_name='enum-name'): argument
2416 start_line = 'enum ' + family.c_name + '_' + c_lower(obj[ckey])
2420 def render_uapi(family, cw): argument
2421 hdr_prot = f"_UAPI_LINUX_{c_upper(family.uapi_header_name)}_H"
2427 defines = [(family.fam_key, family["name"]),
2428 (family.ver_key, family.get('version', 1))]
2433 for const in family['definitions']:
2441 enum = family.consts[const['name']]
2459 uapi_enum_start(family, cw, const, 'name')
2460 name_pfx = const.get('name-prefix', f"{family.ident_name}-{const['name']}-")
2481 defines.append([c_upper(family.get('c-define-name',
2482 f"{family.ident_name}-{const['name']}")),
2489 max_by_define = family.get('max-by-define', False)
2491 for _, attr_set in family.attr_sets.items():
2498 uapi_enum_start(family, cw, attr_set.yaml, 'enum-name')
2516 separate_ntf = 'async-prefix' in family['operations']
2518 max_name = c_upper(family.get('cmd-max-name', f"{family.op_prefix}MAX"))
2519 cnt_name = c_upper(family.get('cmd-cnt-name', f"__{family.op_prefix}MAX"))
2522 uapi_enum_start(family, cw, family['operations'], 'enum-name')
2524 for op in family.msgs.values():
2544 uapi_enum_start(family, cw, family['operations'], enum_name='async-enum')
2545 for op in family.msgs.values():
2558 for grp in family.mcgrps['list']:
2560 defines.append([c_upper(grp.get('c-define-name', f"{family.ident_name}-mcgrp-{name}")),
2579 def render_user_family(family, cw, prototype): argument
2580 symbol = f'const struct ynl_family ynl_{family.c_name}_family'
2585 if family.ntfs:
2586 cw.block_start(line=f"static const struct ynl_ntf_info {family['name']}_ntf_info[] = ")
2587 for ntf_op_name, ntf_op in family.ntfs.items():
2589 op = family.ops[ntf_op['notify']]
2590 ri = RenderInfo(cw, family, "user", op, "notify")
2592 ri = RenderInfo(cw, family, "user", ntf_op, "event")
2596 for op_name, op in family.ops.items():
2599 ri = RenderInfo(cw, family, "user", op, "event")
2605 cw.p(f'.name\t\t= "{family.c_name}",')
2606 if family.fixed_header:
2607 … cw.p(f'.hdr_len\t= sizeof(struct genlmsghdr) + sizeof(struct {c_lower(family.fixed_header)}),')
2610 if family.ntfs:
2611 cw.p(f".ntf_info\t= {family['name']}_ntf_info,")
2612 cw.p(f".ntf_info_size\t= YNL_ARRAY_SIZE({family['name']}_ntf_info),")
2616 def family_contains_bitfield32(family): argument
2617 for _, attr_set in family.attr_sets.items():
2655 parsed = Family(args.spec, exclude_ops)