pg: api cleanup
Use autogenerated code.
Does not change API definitions.
Type: improvement
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: Idf0c24c9c8f8f3c267285c6a231c9c1a364a902a
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index ffa2f8a..963d23a 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -356,6 +356,8 @@
/* 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 b3eb315..468c88e 100644
--- a/src/vnet/pg/pg_api.c
+++ b/src/vnet/pg/pg_api.c
@@ -19,35 +19,15 @@
#include <vnet/vnet.h>
#include <vlibmemory/api.h>
-
#include <vnet/pg/pg.h>
-#include <vnet/vnet_msg_enum.h>
+#include <vnet/format_fns.h>
+#include <vnet/pg/pg.api_enum.h>
+#include <vnet/pg/pg.api_types.h>
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#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 <vnet/vnet_all_api_h.h>
-#undef vl_printfun
-
+#define REPLY_MSG_ID_BASE pg->msg_id_base
#include <vlibapi/api_helper_macros.h>
-#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
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 @@
REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
}
-#define vl_msg_name_crc_list
-#include <vnet/pg/pg.api.h>
-#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 <vnet/pg/pg.api.c>
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;
}