summaryrefslogtreecommitdiffstats
path: root/src/plugins/vmxnet3/vmxnet3_api.c
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-06-25 22:36:26 -0700
committerNeale Ranns <nranns@cisco.com>2019-06-26 07:51:54 +0000
commit4201e96cbc80525b2a42295b1ab43967f844160f (patch)
tree50b365290dd3864a65173e36e0cbaf2b6c452abc /src/plugins/vmxnet3/vmxnet3_api.c
parentf6a9ec5cfccb26553e8fefddd355fe2e400ad396 (diff)
vmxnet3: custom dump and debug cli fix
Add missing custom dump for vmxnet3_create, vmxnet3_delete, and vmxnet3_dump. Fix vmxnet3_create debug cli which may not parse all parameters correctly due to passing address of u16 to unformat(). The fix is to use a u32 local variable to receive the correct value from unformat(). Type: fix Change-Id: I04251c9ed0ab397ed4b1b5843a73880aec98b9f6 Signed-off-by: Steven Luong <sluong@cisco.com>
Diffstat (limited to 'src/plugins/vmxnet3/vmxnet3_api.c')
-rw-r--r--src/plugins/vmxnet3/vmxnet3_api.c67
1 files changed, 64 insertions, 3 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3_api.c b/src/plugins/vmxnet3/vmxnet3_api.c
index 5e1bb9e2f18..8395f158c9a 100644
--- a/src/plugins/vmxnet3/vmxnet3_api.c
+++ b/src/plugins/vmxnet3/vmxnet3_api.c
@@ -40,15 +40,19 @@
/* instantiate all the print functions we know about */
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vmxnet3/vmxnet3_all_api_h.h>
-#undef vl_printfun
/* 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 <vlibapi/api_helper_macros.h>
#define foreach_vmxnet3_plugin_api_msg \
@@ -86,6 +90,30 @@ 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->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)
{
@@ -112,6 +140,17 @@ 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,
@@ -209,6 +248,16 @@ 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_create_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
@@ -222,6 +271,16 @@ setup_message_id_table (vmxnet3_main_t * vmxm, api_main_t * am)
#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 */
clib_error_t *
vmxnet3_plugin_api_hookup (vlib_main_t * vm)
@@ -251,6 +310,8 @@ vmxnet3_plugin_api_hookup (vlib_main_t * vm)
/* set up the (msg_name, crc, message-id) table */
setup_message_id_table (vmxm, am);
+ plugin_custom_dump_configure (vmxm);
+
vec_free (name);
return 0;
}