summaryrefslogtreecommitdiff
path: root/tools/net
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-03-01 10:36:41 -0800
committerDavid S. Miller <davem@davemloft.net>2023-03-03 08:22:39 +0000
commitad4fafcde5bc1badb8fc2c7f260a5d6b83a038e4 (patch)
treeec528cbb83651d354e3e139ee8429dc40e1ad004 /tools/net
parent7cf93538e087a792cb476008a757ab7c1c23b68c (diff)
downloadlinux-next-ad4fafcde5bc1badb8fc2c7f260a5d6b83a038e4.tar.gz
tools: ynl: use 1 as the default for first entry in attrs/ops
Pretty much all families use value: 1 or reserve as unspec the first entry in attribute set and the first operation. Make this the default. Update documentation (the doc for values of operations just refers back to doc for attrs so updating only attrs). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/net')
-rw-r--r--tools/net/ynl/lib/nlspec.py6
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py7
2 files changed, 8 insertions, 5 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index dff31dad36c5..9d394e50de23 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -96,7 +96,7 @@ class SpecAttrSet(SpecElement):
self.attrs_by_val = collections.OrderedDict()
if self.subset_of is None:
- val = 0
+ val = 1
for elem in self.yaml['attributes']:
if 'value' in elem:
val = elem['value']
@@ -252,7 +252,7 @@ class SpecFamily(SpecElement):
self._resolution_list.append(elem)
def _dictify_ops_unified(self):
- val = 0
+ val = 1
for elem in self.yaml['operations']['list']:
if 'value' in elem:
val = elem['value']
@@ -263,7 +263,7 @@ class SpecFamily(SpecElement):
self.msgs[op.name] = op
def _dictify_ops_directional(self):
- req_val = rsp_val = 0
+ req_val = rsp_val = 1
for elem in self.yaml['operations']['list']:
if 'notify' in elem:
if 'value' in elem:
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 274e9c566f61..62f8f2c3c56c 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -2044,14 +2044,17 @@ def render_uapi(family, cw):
max_value = f"({cnt_name} - 1)"
uapi_enum_start(family, cw, family['operations'], 'enum-name')
+ val = 0
for op in family.msgs.values():
if separate_ntf and ('notify' in op or 'event' in op):
continue
suffix = ','
- if 'value' in op:
- suffix = f" = {op['value']},"
+ if op.value != val:
+ suffix = f" = {op.value},"
+ val = op.value
cw.p(op.enum_name + suffix)
+ val += 1
cw.nl()
cw.p(cnt_name + ('' if max_by_define else ','))
if not max_by_define: