Skip to content

Commit 88901b9

Browse files
donaldhkuba-moo
authored andcommitted
tools/ynl: Add mcast-group schema parsing to ynl
Add a SpecMcastGroup class to the nlspec lib. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://lore.kernel.org/r/20230825122756.7603-6-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2db8abf commit 88901b9

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

tools/net/ynl/lib/nlspec.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,26 @@ def resolve(self):
322322
self.attr_set = self.family.attr_sets[attr_set_name]
323323

324324

325+
class SpecMcastGroup(SpecElement):
326+
"""Netlink Multicast Group
327+
328+
Information about a multicast group.
329+
330+
Value is only used for classic netlink families that use the
331+
netlink-raw schema. Genetlink families use dynamic ID allocation
332+
where the ids of multicast groups get resolved at runtime. Value
333+
will be None for genetlink families.
334+
335+
Attributes:
336+
name name of the mulitcast group
337+
value integer id of this multicast group for netlink-raw or None
338+
yaml raw spec as loaded from the spec file
339+
"""
340+
def __init__(self, family, yaml):
341+
super().__init__(family, yaml)
342+
self.value = self.yaml.get('value')
343+
344+
325345
class SpecFamily(SpecElement):
326346
""" Netlink Family Spec class.
327347
@@ -343,6 +363,7 @@ class SpecFamily(SpecElement):
343363
ntfs dict of all async events
344364
consts dict of all constants/enums
345365
fixed_header string, optional name of family default fixed header struct
366+
mcast_groups dict of all multicast groups (index by name)
346367
"""
347368
def __init__(self, spec_path, schema_path=None, exclude_ops=None):
348369
with open(spec_path, "r") as stream:
@@ -384,6 +405,7 @@ def __init__(self, spec_path, schema_path=None, exclude_ops=None):
384405
self.ops = collections.OrderedDict()
385406
self.ntfs = collections.OrderedDict()
386407
self.consts = collections.OrderedDict()
408+
self.mcast_groups = collections.OrderedDict()
387409

388410
last_exception = None
389411
while len(self._resolution_list) > 0:
@@ -416,6 +438,9 @@ def new_struct(self, elem):
416438
def new_operation(self, elem, req_val, rsp_val):
417439
return SpecOperation(self, elem, req_val, rsp_val)
418440

441+
def new_mcast_group(self, elem):
442+
return SpecMcastGroup(self, elem)
443+
419444
def add_unresolved(self, elem):
420445
self._resolution_list.append(elem)
421446

@@ -512,3 +537,9 @@ def resolve(self):
512537
self.ops[op.name] = op
513538
elif op.is_async:
514539
self.ntfs[op.name] = op
540+
541+
mcgs = self.yaml.get('mcast-groups')
542+
if mcgs:
543+
for elem in mcgs['list']:
544+
mcg = self.new_mcast_group(elem)
545+
self.mcast_groups[elem['name']] = mcg

0 commit comments

Comments
 (0)