summaryrefslogtreecommitdiff
path: root/tools/net/ynl
diff options
context:
space:
mode:
authorDonald Hunter <donald.hunter@gmail.com>2023-05-27 16:31:06 +0300
committerJakub Kicinski <kuba@kernel.org>2023-05-30 08:05:38 +0300
commit313a7a808ca8ca0fe08e2175eb145479bd86937e (patch)
treecfb4dfe2e0211ec3fd5b910a3b00654d29610a35 /tools/net/ynl
parent5ac18889bde04ed2d4f2559da01e9b160234525c (diff)
downloadlinux-313a7a808ca8ca0fe08e2175eb145479bd86937e.tar.xz
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>
Diffstat (limited to 'tools/net/ynl')
-rw-r--r--tools/net/ynl/lib/nlspec.py2
-rw-r--r--tools/net/ynl/lib/ynl.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index c624cdfde223..ada22b073aa2 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -228,11 +228,13 @@ class SpecStructMember(SpecElement):
Attributes:
type string, type of the member attribute
byte_order string or None for native byte order
+ enum string, name of the enum definition
"""
def __init__(self, family, yaml):
super().__init__(family, yaml)
self.type = yaml['type']
self.byte_order = yaml.get('byte-order')
+ self.enum = yaml.get('enum')
class SpecStruct(SpecElement):
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 85ee6a4bee72..0692293447ad 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -412,7 +412,11 @@ class YnlFamily(SpecFamily):
def _decode_binary(self, attr, attr_spec):
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:
decoded = attr.as_c_array(attr_spec.sub_type)
else: