summaryrefslogtreecommitdiff
path: root/tools/net
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-06-07 23:23:56 +0300
committerJakub Kicinski <kuba@kernel.org>2023-06-09 00:01:10 +0300
commitff6db4b58c93eada66f58423aa02363f987679c5 (patch)
treed511b8a82dd63533319d1e0dcaafc140683b9680 /tools/net
parent6f115d4575ab7225fc16ba816b9d25d88976a540 (diff)
downloadlinux-ff6db4b58c93eada66f58423aa02363f987679c5.tar.xz
tools: ynl-gen: enable code gen for directional specs
I think that user space code gen for directional specs works after recent changes. Let them through. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net')
-rw-r--r--tools/net/ynl/lib/nlspec.py7
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py10
2 files changed, 11 insertions, 6 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index bd5da8aaeac7..9f7ad87d69af 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -324,6 +324,7 @@ class SpecFamily(SpecElement):
Attributes:
proto protocol type (e.g. genetlink)
+ msg_id_model enum-model for operations (unified, directional etc.)
license spec license (loaded from an SPDX tag on the spec)
attr_sets dict of attribute sets
@@ -349,6 +350,7 @@ class SpecFamily(SpecElement):
super().__init__(self, spec)
self.proto = self.yaml.get('protocol', 'genetlink')
+ self.msg_id_model = self.yaml['operations'].get('enum-model', 'unified')
if schema_path is None:
schema_path = os.path.dirname(os.path.dirname(spec_path)) + f'/{self.proto}.yaml'
@@ -477,10 +479,9 @@ class SpecFamily(SpecElement):
attr_set = self.new_attr_set(elem)
self.attr_sets[elem['name']] = attr_set
- msg_id_model = self.yaml['operations'].get('enum-model', 'unified')
- if msg_id_model == 'unified':
+ if self.msg_id_model == 'unified':
self._dictify_ops_unified()
- elif msg_id_model == 'directional':
+ elif self.msg_id_model == 'directional':
self._dictify_ops_directional()
for op in self.msgs.values():
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index efcf91675dfa..7b3e79e17c01 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -709,9 +709,6 @@ class Operation(SpecOperation):
def __init__(self, family, yaml, req_value, rsp_value):
super().__init__(family, yaml, req_value, rsp_value)
- if req_value != rsp_value:
- raise Exception("Directional messages not supported by codegen")
-
self.render_name = family.name + '_' + c_lower(self.name)
self.dual_policy = ('do' in yaml and 'request' in yaml['do']) and \
@@ -2243,6 +2240,13 @@ def main():
os.sys.exit(1)
return
+ supported_models = ['unified']
+ if args.mode == 'user':
+ supported_models += ['directional']
+ if parsed.msg_id_model not in supported_models:
+ print(f'Message enum-model {parsed.msg_id_model} not supported for {args.mode} generation')
+ os.sys.exit(1)
+
cw = CodeWriter(BaseNlLib(), out_file)
_, spec_kernel = find_kernel_root(args.spec)