aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp/api
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2018-09-11 20:27:09 +0200
committerDamjan Marion <dmarion@me.com>2018-10-01 09:44:58 +0000
commit5d64c7868f67749a6c99eb4ee5998b518ab6c71c (patch)
tree57ce487477ddb12dddeb21340ad875328f2ea5a0 /src/vpp/api
parent28c142e3dedc0b136003f33f67243bf3c1873b71 (diff)
thread: Add show threads api
Change-Id: I3124238ab4d43bcef5590bad33a4ff0b5d8b7d15 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vpp/api')
-rw-r--r--src/vpp/api/api.c66
-rw-r--r--src/vpp/api/custom_dump.c10
-rw-r--r--src/vpp/api/vpe.api50
3 files changed, 124 insertions, 2 deletions
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index d69b84fd0b9..86865099532 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -2,7 +2,7 @@
*------------------------------------------------------------------
* api.c - message handler registration
*
- * Copyright (c) 2010-2016 Cisco and/or its affiliates.
+ * Copyright (c) 2010-2018 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -80,6 +80,7 @@ _(CLI_INBAND, cli_inband) \
_(GET_NODE_INDEX, get_node_index) \
_(ADD_NODE_NEXT, add_node_next) \
_(SHOW_VERSION, show_version) \
+_(SHOW_THREADS, show_threads) \
_(GET_NODE_GRAPH, get_node_graph) \
_(GET_NEXT_INDEX, get_next_index) \
@@ -255,6 +256,69 @@ vl_api_show_version_t_handler (vl_api_show_version_t * mp)
}
static void
+get_thread_data (vl_api_thread_data_t * td, int index)
+{
+ vlib_worker_thread_t *w = vlib_worker_threads + index;
+ td->id = htonl (index);
+ if (w->name)
+ strncpy ((char *) td->name, (char *) w->name, ARRAY_LEN (td->name) - 1);
+ if (w->registration)
+ strncpy ((char *) td->type, (char *) w->registration->name,
+ ARRAY_LEN (td->type) - 1);
+ td->pid = htonl (w->lwp);
+ td->cpu_id = htonl (w->cpu_id);
+ td->core = htonl (w->core_id);
+ td->cpu_socket = htonl (w->socket_id);
+}
+
+static void
+vl_api_show_threads_t_handler (vl_api_show_threads_t * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ int rv = 0, count = 0;
+
+#if !defined(__powerpc64__)
+ vl_api_registration_t *reg;
+ vl_api_show_threads_reply_t *rmp;
+ vl_api_thread_data_t *td;
+ int i, msg_size = 0;
+ count = vec_len (vlib_worker_threads);
+ if (!count)
+ return;
+
+ msg_size = sizeof (*rmp) + sizeof (rmp->thread_data[0]) * count;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ rmp = vl_msg_api_alloc (msg_size);
+ memset (rmp, 0, msg_size);
+ rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
+ rmp->context = mp->context;
+ rmp->count = htonl (count);
+ td = rmp->thread_data;
+
+ for (i = 0; i < count; i++)
+ {
+ get_thread_data (&td[i], i);
+ }
+
+ vl_api_send_msg (reg, (u8 *) rmp);
+#else
+
+ /* unimplemented support */
+ rv = -9;
+ clib_warning ("power pc does not support show threads api");
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_SHOW_THREADS_REPLY,
+ ({
+ rmp->count = htonl(count);
+ }));
+ /* *INDENT-ON* */
+#endif
+}
+
+static void
vl_api_get_node_index_t_handler (vl_api_get_node_index_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index baa675c908d..aa635668593 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -2154,6 +2154,16 @@ static void *vl_api_show_version_t_print
FINISH;
}
+static void *vl_api_show_threads_t_print
+ (vl_api_show_threads_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: show_threads ");
+
+ FINISH;
+}
+
static void *vl_api_vxlan_gpe_add_del_tunnel_t_print
(vl_api_vxlan_gpe_add_del_tunnel_t * mp, void *handle)
{
diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api
index 2eb14bc2fd4..488af1727bc 100644
--- a/src/vpp/api/vpe.api
+++ b/src/vpp/api/vpe.api
@@ -19,7 +19,7 @@
called through a shared memory interface.
*/
-option version = "1.0.0";
+option version = "1.1.0";
/*
* Note: API placement cleanup in progress
@@ -193,6 +193,54 @@ define show_version_reply
u8 build_directory[256];
};
+
+/** \brief show_threads display the information about vpp
+ threads running on system along with their process id,
+ cpu id, physical core and cpu socket.
+*/
+define show_threads
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief thread data
+ @param id - thread index
+ @param name - thread name i.e. vpp_main or vpp_wk_0
+ @param type - thread type i.e. workers or stats
+ @param pid - thread Process Id
+ @param cpu_id - thread pinned to cpu.
+ "CPUs or Logical cores are the number of physical cores times
+ the number of threads that can run on each core through
+ the use of hyperthreading." (from unix.stackexchange.com)
+ @param core - thread pinned to actual physical core.
+ @param cpu_socket - thread is running on which cpu socket.
+*/
+typeonly define thread_data
+{
+ u32 id;
+ u8 name[64];
+ u8 type[64];
+ u32 pid;
+ u32 cpu_id;
+ u32 core;
+ u32 cpu_socket;
+};
+
+/** \brief show_threads_reply
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+ @param count - number of threads in thread_data array
+ @param thread_data - array of thread data
+*/
+define show_threads_reply
+{
+ u32 context;
+ i32 retval;
+ u32 count;
+ vl_api_thread_data_t thread_data[count];
+};
+
define get_node_graph
{
u32 client_index;