summaryrefslogtreecommitdiffstats
path: root/src/vlibmemory
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-02-27 13:10:27 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2017-02-28 11:23:27 +0000
commit987e11dffecc4ec3f55ae3d2fa5d2cc40dcf91f0 (patch)
tree1208868bcec1f5b63bad39a58d3b731332be90ed /src/vlibmemory
parentf61bc52eb99019da519c105c8d4ca2c433433e53 (diff)
Trace plugin binary API message range allocation
Change-Id: I544a5d2906548607b69f999567b92f802fddddbb Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlibmemory')
-rw-r--r--src/vlibmemory/memclnt.api15
-rw-r--r--src/vlibmemory/memory_vlib.c82
2 files changed, 89 insertions, 8 deletions
diff --git a/src/vlibmemory/memclnt.api b/src/vlibmemory/memclnt.api
index 2f654caf2c1..0532d7b6a85 100644
--- a/src/vlibmemory/memclnt.api
+++ b/src/vlibmemory/memclnt.api
@@ -89,3 +89,18 @@ define get_first_msg_id_reply {
i32 retval;
u16 first_msg_id;
};
+
+/*
+ * Trace the plugin message-id allocator
+ * so we stand a chance of dealing with different sets of plugins
+ * at api trace replay time
+ */
+
+manual_print define trace_plugin_msg_ids
+{
+ u32 client_index;
+ u32 context;
+ u8 plugin_name[128];
+ u16 first_msg_id;
+ u16 last_msg_id;
+};
diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c
index 7d21c9dd125..231caa58f12 100644
--- a/src/vlibmemory/memory_vlib.c
+++ b/src/vlibmemory/memory_vlib.c
@@ -70,6 +70,17 @@ vl_api_memclnt_delete_t_print (vl_api_memclnt_delete_t * a, void *handle)
return handle;
}
+static inline void *
+vl_api_trace_plugin_msg_ids_t_print (vl_api_trace_plugin_msg_ids_t * a,
+ void *handle)
+{
+ vl_print (handle, "vl_api_trace_plugin_msg_ids: %s first %u last %u\n",
+ a->plugin_name,
+ clib_host_to_net_u16 (a->first_msg_id),
+ clib_host_to_net_u16 (a->last_msg_id));
+ return handle;
+}
+
/* instantiate all the endian swap functions we know about */
#define vl_endianfun
#include <vlibmemory/vl_memory_api_h.h>
@@ -112,14 +123,13 @@ vl_api_serialize_message_table (api_main_t * am, u8 * vector)
/* serialize the count */
serialize_integer (sm, nmsg, sizeof (u32));
- hash_foreach_pair (hp, am->msg_index_by_name_and_crc, (
- {
- serialize_likely_small_unsigned_integer
- (sm, hp->value[0]);
- serialize_cstring
- (sm,
- (char *) hp->key);
- }));
+ /* *INDENT-OFF* */
+ hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
+ ({
+ serialize_likely_small_unsigned_integer (sm, hp->value[0]);
+ serialize_cstring (sm, (char *) hp->key);
+ }));
+ /* *INDENT-ON* */
return serialize_close_vector (sm);
}
@@ -389,6 +399,31 @@ static u64 vector_rate_histogram[SLEEP_N_BUCKETS];
static void memclnt_queue_callback (vlib_main_t * vm);
+/*
+ * Callback to send ourselves a plugin numbering-space trace msg
+ */
+static void
+send_one_plugin_msg_ids_msg (u8 * name, u16 first_msg_id, u16 last_msg_id)
+{
+ vl_api_trace_plugin_msg_ids_t *mp;
+ api_main_t *am = &api_main;
+ vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr;
+ unix_shared_memory_queue_t *q;
+
+ mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+
+ mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
+ strncpy ((char *) mp->plugin_name, (char *) name,
+ sizeof (mp->plugin_name) - 1);
+ mp->first_msg_id = clib_host_to_net_u16 (first_msg_id);
+ mp->last_msg_id = clib_host_to_net_u16 (last_msg_id);
+
+ q = shmem_hdr->vl_input_queue;
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
static uword
memclnt_process (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * f)
@@ -402,6 +437,7 @@ memclnt_process (vlib_main_t * vm,
f64 dead_client_scan_time;
f64 sleep_time, start_time;
f64 vector_rate;
+ int i;
vlib_set_queue_signal_callback (vm, memclnt_queue_callback);
@@ -424,6 +460,16 @@ memclnt_process (vlib_main_t * vm,
sleep_time = 20.0;
dead_client_scan_time = vlib_time_now (vm) + 20.0;
+ /*
+ * Send plugin message range messages for each plugin we loaded
+ */
+ for (i = 0; i < vec_len (am->msg_ranges); i++)
+ {
+ vl_api_msg_range_t *rp = am->msg_ranges + i;
+ send_one_plugin_msg_ids_msg (rp->name, rp->first_msg_id,
+ rp->last_msg_id);
+ }
+
/* $$$ pay attention to frame size, control CPU usage */
while (1)
{
@@ -1320,10 +1366,20 @@ vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
pthread_mutex_unlock (&q->mutex);
}
+static void
+vl_api_trace_plugin_msg_ids_t_handler (vl_api_trace_plugin_msg_ids_t * mp)
+{
+ /* Do nothing. We just want to trace the message */
+}
+
+
#define foreach_rpc_api_msg \
_(RPC_CALL,rpc_call) \
_(RPC_REPLY,rpc_reply)
+#define foreach_plugin_trace_msg \
+_(TRACE_PLUGIN_MSG_IDS,trace_plugin_msg_ids)
+
static clib_error_t *
rpc_api_hookup (vlib_main_t * vm)
{
@@ -1336,6 +1392,16 @@ rpc_api_hookup (vlib_main_t * vm)
sizeof(vl_api_##n##_t), 0 /* do not trace */);
foreach_rpc_api_msg;
#undef _
+
+#define _(N,n) \
+ vl_msg_api_set_handlers(VL_API_##N, #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1 /* do trace */);
+ foreach_plugin_trace_msg;
+#undef _
return 0;
}