summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2020-05-18 11:14:05 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-05-27 08:30:38 +0000
commite796a18734fae0783a226c38550796260f0acfec (patch)
treeeb6e2d17b2c2cbc6f2b3ed9ad781428b6ab9b392 /src/tools
parent0ab36f55753d3d1417c41f8a3aec5e79a882555c (diff)
api: make vpp api handlers endian independent
Add a new boolean to signal that the API infrastructure should performan any required endian conversions for the API handler. am->is_autoendian[mm->msg_id_base + VL_API_MAP_ADD_DOMAIN] = 1; Similarly add new REPLY_ macros that perform endian conversion. These changes do not change the on-the-wire encoding of the API messages, and therefore the API CRC is not changed. Type: feature Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I7588f8ccb38b2d1e8d85ea17be99bac43f756267 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/vppapigen/vppapigen_c.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index 46f60dea843..b7a62dc4102 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -394,6 +394,7 @@ def endianfun_array(o):
name=o.fieldname))
return output
+no_endian_conversion = {'client_index': None}
def endianfun_obj(o):
output = ''
@@ -403,6 +404,9 @@ def endianfun_obj(o):
output += (' s = format(s, "\\n{} {} {} (print not implemented");\n'
.format(o.type, o.fieldtype, o.fieldname))
return output
+ if o.fieldname in no_endian_conversion:
+ output += ' /* a->{n} = a->{n} (no-op) */\n'.format(n=o.fieldname)
+ return output
if o.fieldtype in endian_strings:
output += (' a->{name} = {format}(a->{name});\n'
.format(name=o.fieldname,
@@ -594,6 +598,7 @@ def generate_include_types(s, module, stream):
def generate_c_boilerplate(services, defines, file_crc, module, stream):
write = stream.write
+ define_hash = {d.name:d for d in defines}
hdr = '''\
#define vl_endianfun /* define message structures */
@@ -612,6 +617,7 @@ def generate_c_boilerplate(services, defines, file_crc, module, stream):
write('static u16\n')
write('setup_message_id_table (void) {\n')
write(' api_main_t *am = my_api_main;\n')
+ write(' vl_msg_api_msg_config_t c;\n')
write(' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", VL_MSG_FIRST_AVAILABLE);\n'
.format(module, crc=file_crc))
@@ -621,11 +627,16 @@ def generate_c_boilerplate(services, defines, file_crc, module, stream):
' VL_API_{ID} + msg_id_base);\n'
.format(n=d.name, ID=d.name.upper(), crc=d.crc))
for s in services:
- write(' vl_msg_api_set_handlers(VL_API_{ID} + msg_id_base, "{n}",\n'
- ' vl_api_{n}_t_handler, vl_noop_handler,\n'
- ' vl_api_{n}_t_endian, vl_api_{n}_t_print,\n'
- ' sizeof(vl_api_{n}_t), 1);\n'
+ d = define_hash[s.caller]
+ write(' c = (vl_msg_api_msg_config_t) {{.id = VL_API_{ID} + msg_id_base,\n'
+ ' .name = "{n}",\n'
+ ' .handler = vl_api_{n}_t_handler,\n'
+ ' .cleanup = vl_noop_handler,\n'
+ ' .endian = vl_api_{n}_t_endian,\n'
+ ' .print = vl_api_{n}_t_print,\n'
+ ' .is_autoendian = 0}};\n'
.format(n=s.caller, ID=s.caller.upper()))
+ write(' vl_msg_api_config (&c);\n')
write(' return msg_id_base;\n')
write('}\n')