Skip to content

Commit 31a1639

Browse files
committed
Correct header len to be specificed per op
rt-link operation can have its fixed header, which may not be the same as the the family one. Signed-off-by: Zibo Gong <gongzib@outlook.com>
1 parent 336b70e commit 31a1639

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ynl-gen-cpp.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
12901290
self.fixed_hdr = op.fixed_header if op else None
12911291
self.fixed_hdr_len = "ys->family->hdr_len"
12921292
if op and op.fixed_header:
1293+
if op.fixed_header != family.fixed_header:
1294+
if family.is_classic():
1295+
self.fixed_hdr_len = f"sizeof(struct {c_lower(self.fixed_hdr)})"
1296+
else:
1297+
raise Exception(f"Per-op fixed header not supported, yet")
12931298
self.fixed_hdr = "struct " + c_lower(op.fixed_header)
12941299

12951300
# 'do' and 'dump' response parsing is identical
@@ -1792,6 +1797,11 @@ def _multi_parse(ri, struct, init_lines, local_vars):
17921797
if ri.fixed_hdr:
17931798
local_vars += ["void *hdr;"]
17941799
iter_line = "ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len)"
1800+
if ri.op.fixed_header != ri.family.fixed_header:
1801+
if ri.family.is_classic():
1802+
iter_line = f"ynl_attr_for_each(attr, nlh, sizeof({ri.fixed_hdr}))"
1803+
else:
1804+
raise Exception(f"Per-op fixed header not supported, yet")
17951805

17961806
array_nests = set()
17971807
multi_attrs = set()

0 commit comments

Comments
 (0)