mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
tools: ynl: Support enums in struct members in genetlink-legacy
Support decoding scalars as enums in struct members for genetlink-legacy specs. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5ac18889bd
commit
313a7a808c
3 changed files with 10 additions and 1 deletions
|
@ -127,6 +127,9 @@ properties:
|
||||||
doc:
|
doc:
|
||||||
description: Documentation for the struct member attribute.
|
description: Documentation for the struct member attribute.
|
||||||
type: string
|
type: string
|
||||||
|
enum:
|
||||||
|
description: Name of the enum type used for the attribute.
|
||||||
|
type: string
|
||||||
# End genetlink-legacy
|
# End genetlink-legacy
|
||||||
|
|
||||||
attribute-sets:
|
attribute-sets:
|
||||||
|
|
|
@ -228,11 +228,13 @@ class SpecStructMember(SpecElement):
|
||||||
Attributes:
|
Attributes:
|
||||||
type string, type of the member attribute
|
type string, type of the member attribute
|
||||||
byte_order string or None for native byte order
|
byte_order string or None for native byte order
|
||||||
|
enum string, name of the enum definition
|
||||||
"""
|
"""
|
||||||
def __init__(self, family, yaml):
|
def __init__(self, family, yaml):
|
||||||
super().__init__(family, yaml)
|
super().__init__(family, yaml)
|
||||||
self.type = yaml['type']
|
self.type = yaml['type']
|
||||||
self.byte_order = yaml.get('byte-order')
|
self.byte_order = yaml.get('byte-order')
|
||||||
|
self.enum = yaml.get('enum')
|
||||||
|
|
||||||
|
|
||||||
class SpecStruct(SpecElement):
|
class SpecStruct(SpecElement):
|
||||||
|
|
|
@ -412,7 +412,11 @@ class YnlFamily(SpecFamily):
|
||||||
|
|
||||||
def _decode_binary(self, attr, attr_spec):
|
def _decode_binary(self, attr, attr_spec):
|
||||||
if attr_spec.struct_name:
|
if attr_spec.struct_name:
|
||||||
decoded = attr.as_struct(self.consts[attr_spec.struct_name])
|
members = self.consts[attr_spec.struct_name]
|
||||||
|
decoded = attr.as_struct(members)
|
||||||
|
for m in members:
|
||||||
|
if m.enum:
|
||||||
|
self._decode_enum(decoded, m)
|
||||||
elif attr_spec.sub_type:
|
elif attr_spec.sub_type:
|
||||||
decoded = attr.as_c_array(attr_spec.sub_type)
|
decoded = attr.as_c_array(attr_spec.sub_type)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue