diff options
Diffstat (limited to 'src/plugins/vmxnet3/vmxnet3_api.c')
-rw-r--r-- | src/plugins/vmxnet3/vmxnet3_api.c | 130 |
1 files changed, 4 insertions, 126 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3_api.c b/src/plugins/vmxnet3/vmxnet3_api.c index c7f60ee723f..fa7554e3301 100644 --- a/src/plugins/vmxnet3/vmxnet3_api.c +++ b/src/plugins/vmxnet3/vmxnet3_api.c @@ -26,40 +26,11 @@ #include <vlibmemory/api.h> /* define message IDs */ -#include <vmxnet3/vmxnet3_msg_enum.h> - -/* define message structures */ -#define vl_typedefs -#include <vmxnet3/vmxnet3_all_api_h.h> -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#include <vmxnet3/vmxnet3_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__) - -/* get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include <vmxnet3/vmxnet3_all_api_h.h> -#undef vl_api_version - -/* Macro to finish up custom dump fns */ -#define FINISH \ - vec_add1 (s, 0); \ - vl_print (handle, (char *)s); \ - vec_free (s); \ - return handle; +#include <vmxnet3/vmxnet3.api_enum.h> +#include <vmxnet3/vmxnet3.api_types.h> #include <vlibapi/api_helper_macros.h> -#define foreach_vmxnet3_plugin_api_msg \ -_(VMXNET3_CREATE, vmxnet3_create) \ -_(VMXNET3_DELETE, vmxnet3_delete) \ -_(VMXNET3_DUMP, vmxnet3_dump) - static void vl_api_vmxnet3_create_t_handler (vl_api_vmxnet3_create_t * mp) { @@ -91,32 +62,6 @@ vl_api_vmxnet3_create_t_handler (vl_api_vmxnet3_create_t * mp) /* *INDENT-ON* */ } -static void * -vl_api_vmxnet3_create_t_print (vl_api_vmxnet3_create_t * mp, void *handle) -{ - u8 *s; - u32 pci_addr = ntohl (mp->pci_addr); - - s = format (0, "SCRIPT: vmxnet3_create "); - s = format (s, "%U ", format_vlib_pci_addr, &pci_addr); - if (mp->enable_elog) - s = format (s, "elog "); - if (mp->bind) - s = format (s, "bind "); - if (mp->enable_gso) - s = format (s, "gso "); - if (mp->rxq_size) - s = format (s, "rx-queue-size %u ", ntohs (mp->rxq_size)); - if (mp->txq_size) - s = format (s, "tx-queue-size %u ", ntohs (mp->txq_size)); - if (mp->rxq_num) - s = format (s, "num-rx-queues %u ", ntohs (mp->rxq_num)); - if (mp->txq_num) - s = format (s, "num-tx-queues %u ", ntohs (mp->txq_num)); - - FINISH; -} - static void vl_api_vmxnet3_delete_t_handler (vl_api_vmxnet3_delete_t * mp) { @@ -145,17 +90,6 @@ reply: REPLY_MACRO (VL_API_VMXNET3_DELETE_REPLY + vmxm->msg_id_base); } -static void * -vl_api_vmxnet3_delete_t_print (vl_api_vmxnet3_delete_t * mp, void *handle) -{ - u8 *s; - - s = format (0, "SCRIPT: vmxnet3_delete "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - - FINISH; -} - static void send_vmxnet3_details (vl_api_registration_t * reg, vmxnet3_device_t * vd, vnet_sw_interface_t * swif, u8 * interface_name, @@ -253,71 +187,15 @@ vl_api_vmxnet3_dump_t_handler (vl_api_vmxnet3_dump_t * mp) vec_free (if_name); } -static void * -vl_api_vmxnet3_dump_t_print (vl_api_vmxnet3_dump_t * mp, void *handle) -{ - u8 *s; - - s = format (0, "SCRIPT: vmxnet3_dump "); - - FINISH; -} - -#define vl_msg_name_crc_list -#include <vmxnet3/vmxnet3_all_api_h.h> -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (vmxnet3_main_t * vmxm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + vmxm->msg_id_base); - foreach_vl_msg_name_crc_vmxnet3; -#undef _ -} - -static void -plugin_custom_dump_configure (vmxnet3_main_t * vmxm) -{ -#define _(n,f) api_main.msg_print_handlers \ - [VL_API_##n + vmxm->msg_id_base] \ - = (void *) vl_api_##f##_t_print; - foreach_vmxnet3_plugin_api_msg; -#undef _ -} - /* set tup the API message handling tables */ +#include <vmxnet3/vmxnet3.api.c> clib_error_t * vmxnet3_plugin_api_hookup (vlib_main_t * vm) { vmxnet3_main_t *vmxm = &vmxnet3_main; - api_main_t *am = &api_main; - u8 *name; - - /* construct the API name */ - name = format (0, "vmxnet3_%08x%c", api_version, 0); /* ask for a correctly-sized block of API message decode slots */ - vmxm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + vmxm->msg_id_base), \ - #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_vmxnet3_plugin_api_msg; -#undef _ - - /* set up the (msg_name, crc, message-id) table */ - setup_message_id_table (vmxm, am); - - plugin_custom_dump_configure (vmxm); - - vec_free (name); + vmxm->msg_id_base = setup_message_id_table (); return 0; } |