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.h | 2 ++ src/vnet/pg/pg_api.c | 57 +++++++---------------------------------------- src/vnet/vnet_all_api_h.h | 1 - 3 files changed, 10 insertions(+), 50 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h index ffa2f8a82f4..963d23a8e01 100644 --- a/src/vnet/pg/pg.h +++ b/src/vnet/pg/pg.h @@ -356,6 +356,8 @@ typedef struct pg_main_t /* Per VLIB node information. */ pg_node_t *nodes; + + u16 msg_id_base; } pg_main_t; /* Global main structure. */ 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; } diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h index 47e22795cbf..113b9dd3ded 100644 --- a/src/vnet/vnet_all_api_h.h +++ b/src/vnet/vnet_all_api_h.h @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include -- cgit 1.2.3-korg