summaryrefslogtreecommitdiff
path: root/tools/net/ynl/lib/nlspec.py
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-06-08 14:01:12 -0700
committerJakub Kicinski <kuba@kernel.org>2023-06-08 14:01:12 -0700
commit392c108bce6e405be56c38e6ac35d5c73f5fc439 (patch)
tree181da6c9a1479e29c0d4c60d0b21e4462209523c /tools/net/ynl/lib/nlspec.py
parent449f6bc17a51e68b06cfd742898e5ff3fe6e04d7 (diff)
parentfff8660b5425bb2f441d67758926df62e61a69aa (diff)
Merge branch 'tools-ynl-generate-code-for-the-devlink-family'
Jakub Kicinski says: ==================== tools: ynl: generate code for the devlink family Another chunk of changes to support more capabilities in the YNL code gen. Devlink brings in deep nesting and directional messages (requests and responses have different IDs). We need a healthy dose of codegen changes to support those (I wasn't planning to support code gen for "directional" families initially, but the importance of devlink and ethtool is undeniable). ==================== Link: https://lore.kernel.org/r/20230607202403.1089925-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net/ynl/lib/nlspec.py')
-rw-r--r--tools/net/ynl/lib/nlspec.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index ada22b073aa2..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'
@@ -442,6 +444,10 @@ class SpecFamily(SpecElement):
else:
raise Exception("Can't parse directional ops")
+ if req_val == req_val_next:
+ req_val = None
+ if rsp_val == rsp_val_next:
+ rsp_val = None
op = self.new_operation(elem, req_val, rsp_val)
req_val = req_val_next
rsp_val = rsp_val_next
@@ -473,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():