25 #include <vpp/app/version.h> 28 #include <tracedump/tracedump.api_enum.h> 29 #include <tracedump/tracedump.api_types.h> 31 #define REPLY_MSG_ID_BASE tdmp->msg_id_base 43 u32 flag = clib_net_to_host_u32 (mp->
flag);
45 vl_api_trace_set_filters_reply_t *rmp;
50 count = node_index = 0;
54 rv = VNET_API_ERROR_INVALID_VALUE;
62 rv = VNET_API_ERROR_NO_SUCH_NODE;
83 vl_api_trace_capture_packets_reply_t *rmp;
94 rv = VNET_API_ERROR_NO_SUCH_NODE;
101 rv = VNET_API_ERROR_NO_SUCH_NODE;
118 vl_api_trace_clear_capture_reply_t *rmp;
135 return dt < 0 ? -1 : (dt > 0 ? +1 : 0);
146 for (i = 0; i <
vec_len (client_trace_cache); i++)
148 th = client_trace_cache[
i];
154 tdmp->
traces[client_index] = client_trace_cache;
167 client_trace_cache = tdmp->
traces[client_index];
185 u32 iterator_thread_id, iterator_position, max_records;
186 i32 retval = VNET_API_ERROR_NO_SUCH_ENTRY;
187 u32 last_thread_id = ~0, last_position = ~0;
189 u8 last_more_this_thread = 0;
190 u8 last_more_threads = 0;
202 client_trace_cache = tdmp->
traces[client_index];
208 client_trace_cache = 0;
212 iterator_thread_id = clib_net_to_host_u32 (mp->
thread_id);
213 iterator_position = clib_net_to_host_u32 (mp->
position);
214 max_records = clib_net_to_host_u32 (mp->
max_records);
218 u32 queue_slots_available = q->maxsize - q->cursize;
219 int chunk = (queue_slots_available > 0) ? queue_slots_available - 1 : 0;
220 if (chunk < max_records)
224 if (
vec_len (client_trace_cache) == 0
225 && (iterator_thread_id != ~0 || iterator_position != ~0))
243 vec_add1 (client_trace_cache[i], th[0]);
247 if (
vec_len (client_trace_cache[i]))
257 tdmp->
traces[client_index] = client_trace_cache;
259 for (i = iterator_thread_id; i <
vec_len (client_trace_cache); i++)
261 for (j = iterator_position; j <
vec_len (client_trace_cache[i]); j++)
263 if (max_records == 0)
267 th = &client_trace_cache[
i][j];
275 htons (VL_API_TRACE_DETAILS + (tdmp->
msg_id_base));
277 last_thread_id = dmp->
thread_id = ntohl (i);
278 last_position = dmp->
position = ntohl (j);
285 if (max_records == 1)
288 if (j == (vec_len (client_trace_cache[i]) - 1))
295 if (i == (vec_len (client_trace_cache) - 1) &&
296 j == (vec_len (client_trace_cache[i]) - 1))
298 last_done = dmp->
done = 1;
304 last_done = dmp->
done;
309 iterator_position = 0;
315 rmp->_vl_msg_id = htons (VL_API_TRACE_DUMP_REPLY + (tdmp->
msg_id_base));
317 rmp->
retval = clib_host_to_net_u32 (retval);
320 rmp->
done = last_done;
325 if (iterator_thread_id == ~0 && iterator_position == ~0)
337 #include <tracedump/tracedump.api.c> 362 .version = VPP_BUILD_VER,
363 .description =
"Streaming packet trace dump plugin",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
vlib_main_t vlib_global_main
vnet_main_t * vnet_get_main(void)
static void vl_api_trace_dump_t_handler(vl_api_trace_dump_t *mp)
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define VLIB_NODE_FLAG_TRACE_SUPPORTED
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void trace_filter_set(u32 node_index, u32 flag, u32 count)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
void * vl_msg_api_alloc(int nbytes)
void trace_update_capture_options(u32 add, u32 node_index, u32 filter, u8 verbose)
vlib_main_t ** vlib_mains
u32 node_index[default=0xffffffff]
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
vlib_trace_header_t ** trace_buffer_pool
static clib_error_t * tracedump_init(vlib_main_t *vm)
#define VLIB_INIT_FUNCTION(x)
description fragment has unexpected format
tracedump_main_t tracedump_main
u8 * vnet_trace_placeholder
vlib_trace_header_t **** traces
format_function_t format_vlib_trace
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
VL_MSG_API_REAPER_FUNCTION(tracedump_cache_reaper)
static void vl_api_trace_set_filters_t_handler(vl_api_trace_set_filters_t *mp)
static void vl_api_trace_clear_capture_t_handler(vl_api_trace_clear_capture_t *mp)
void vlib_trace_stop_and_clear(void)
#define foreach_vlib_main(body)
vl_api_trace_filter_flag_t flag
API main structure, used by both vpp and binary API clients.
An API client registration, only in vpp/vlib.
static void setup_message_id_table(api_main_t *am)
static void toss_client_cache(tracedump_main_t *tdmp, u32 client_index, vlib_trace_header_t ***client_trace_cache)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
vlib_main_t vlib_node_runtime_t * node
static clib_error_t * tracedump_cache_reaper(u32 client_index)
static vlib_main_t * vlib_get_main(void)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
u32 vl_api_registration_pool_index
Index in VLIB's brain (not shared memory).
static void vl_api_trace_capture_packets_t_handler(vl_api_trace_capture_packets_t *mp)
struct _svm_queue svm_queue_t
static api_main_t * vlibapi_get_main(void)
static int trace_cmp(void *a1, void *a2)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
u8 * is_mp_safe
Message is mp safe vector.
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
void trace_apply_filter(vlib_main_t *vm)
int vl_api_vec_to_api_string(const u8 *vec, vl_api_string_t *str)