mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 14:43:16 +00:00
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>
This commit is contained in:
parent
2db8abf0b4
commit
88901b9679
@ -322,6 +322,26 @@ class SpecOperation(SpecElement):
|
|||||||
self.attr_set = self.family.attr_sets[attr_set_name]
|
self.attr_set = self.family.attr_sets[attr_set_name]
|
||||||
|
|
||||||
|
|
||||||
|
class SpecMcastGroup(SpecElement):
|
||||||
|
"""Netlink Multicast Group
|
||||||
|
|
||||||
|
Information about a multicast group.
|
||||||
|
|
||||||
|
Value is only used for classic netlink families that use the
|
||||||
|
netlink-raw schema. Genetlink families use dynamic ID allocation
|
||||||
|
where the ids of multicast groups get resolved at runtime. Value
|
||||||
|
will be None for genetlink families.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
name name of the mulitcast group
|
||||||
|
value integer id of this multicast group for netlink-raw or None
|
||||||
|
yaml raw spec as loaded from the spec file
|
||||||
|
"""
|
||||||
|
def __init__(self, family, yaml):
|
||||||
|
super().__init__(family, yaml)
|
||||||
|
self.value = self.yaml.get('value')
|
||||||
|
|
||||||
|
|
||||||
class SpecFamily(SpecElement):
|
class SpecFamily(SpecElement):
|
||||||
""" Netlink Family Spec class.
|
""" Netlink Family Spec class.
|
||||||
|
|
||||||
@ -343,6 +363,7 @@ class SpecFamily(SpecElement):
|
|||||||
ntfs dict of all async events
|
ntfs dict of all async events
|
||||||
consts dict of all constants/enums
|
consts dict of all constants/enums
|
||||||
fixed_header string, optional name of family default fixed header struct
|
fixed_header string, optional name of family default fixed header struct
|
||||||
|
mcast_groups dict of all multicast groups (index by name)
|
||||||
"""
|
"""
|
||||||
def __init__(self, spec_path, schema_path=None, exclude_ops=None):
|
def __init__(self, spec_path, schema_path=None, exclude_ops=None):
|
||||||
with open(spec_path, "r") as stream:
|
with open(spec_path, "r") as stream:
|
||||||
@ -384,6 +405,7 @@ class SpecFamily(SpecElement):
|
|||||||
self.ops = collections.OrderedDict()
|
self.ops = collections.OrderedDict()
|
||||||
self.ntfs = collections.OrderedDict()
|
self.ntfs = collections.OrderedDict()
|
||||||
self.consts = collections.OrderedDict()
|
self.consts = collections.OrderedDict()
|
||||||
|
self.mcast_groups = collections.OrderedDict()
|
||||||
|
|
||||||
last_exception = None
|
last_exception = None
|
||||||
while len(self._resolution_list) > 0:
|
while len(self._resolution_list) > 0:
|
||||||
@ -416,6 +438,9 @@ class SpecFamily(SpecElement):
|
|||||||
def new_operation(self, elem, req_val, rsp_val):
|
def new_operation(self, elem, req_val, rsp_val):
|
||||||
return SpecOperation(self, elem, req_val, rsp_val)
|
return SpecOperation(self, elem, req_val, rsp_val)
|
||||||
|
|
||||||
|
def new_mcast_group(self, elem):
|
||||||
|
return SpecMcastGroup(self, elem)
|
||||||
|
|
||||||
def add_unresolved(self, elem):
|
def add_unresolved(self, elem):
|
||||||
self._resolution_list.append(elem)
|
self._resolution_list.append(elem)
|
||||||
|
|
||||||
@ -512,3 +537,9 @@ class SpecFamily(SpecElement):
|
|||||||
self.ops[op.name] = op
|
self.ops[op.name] = op
|
||||||
elif op.is_async:
|
elif op.is_async:
|
||||||
self.ntfs[op.name] = op
|
self.ntfs[op.name] = op
|
||||||
|
|
||||||
|
mcgs = self.yaml.get('mcast-groups')
|
||||||
|
if mcgs:
|
||||||
|
for elem in mcgs['list']:
|
||||||
|
mcg = self.new_mcast_group(elem)
|
||||||
|
self.mcast_groups[elem['name']] = mcg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user