From 83e5a116ec731bfa89d97d8b4abebcc9b7fc3b6a Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Mon, 21 Jun 2021 12:11:28 +0000 Subject: pg: api cleanup Use autogenerated code. Does not change API definitions. Type: improvement Signed-off-by: Filip Tehlar Change-Id: Idf0c24c9c8f8f3c267285c6a231c9c1a364a902a --- src/vnet/pg/pg_api.c | 57 ++++++++-------------------------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) (limited to 'src/vnet/pg/pg_api.c') diff --git a/src/vnet/pg/pg_api.c b/src/vnet/pg/pg_api.c index b3eb315e807..468c88ee8bb 100644 --- a/src/vnet/pg/pg_api.c +++ b/src/vnet/pg/pg_api.c @@ -19,35 +19,15 @@ #include #include - #include -#include - -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#define vl_printfun -#include -#undef vl_printfun +#include +#include +#include +#define REPLY_MSG_ID_BASE pg->msg_id_base #include -#define foreach_pg_api_msg \ - _ (PG_CREATE_INTERFACE, pg_create_interface) \ - _ (PG_CREATE_INTERFACE_V2, pg_create_interface_v2) \ - _ (PG_CAPTURE, pg_capture) \ - _ (PG_ENABLE_DISABLE, pg_enable_disable) \ - _ (PG_INTERFACE_ENABLE_DISABLE_COALESCE, \ - pg_interface_enable_disable_coalesce) - static void vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp) { @@ -122,6 +102,7 @@ static void static void vl_api_pg_capture_t_handler (vl_api_pg_capture_t * mp) { + pg_main_t *pg = &pg_main; vl_api_pg_capture_reply_t *rmp; int rv = 0; @@ -187,37 +168,15 @@ vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t * mp) REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (api_main_t * am) -{ -#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); - foreach_vl_msg_name_crc_pg; -#undef _ -} - +#include static clib_error_t * pg_api_hookup (vlib_main_t * vm) { - api_main_t *am = vlibapi_get_main (); - -#define _(N,n) \ - vl_msg_api_set_handlers(VL_API_##N, #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_pg_api_msg; -#undef _ - + pg_main_t *pg = &pg_main; /* * Set up the (msg_name, crc, message-id) table */ - setup_message_id_table (am); + pg->msg_id_base = setup_message_id_table (); return 0; } -- cgit 1.2.3-korg