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 42 return dt < 0 ? -1 : (dt > 0 ? +1 : 0);
53 for (i = 0; i <
vec_len (client_trace_cache); i++)
55 th = client_trace_cache[
i];
61 tdmp->
traces[client_index] = client_trace_cache;
74 client_trace_cache = tdmp->
traces[client_index];
92 u32 iterator_thread_id, iterator_position, max_records;
93 i32 retval = VNET_API_ERROR_NO_SUCH_ENTRY;
94 u32 last_thread_id = ~0, last_position = ~0;
96 u8 last_more_this_thread = 0;
97 u8 last_more_threads = 0;
109 client_trace_cache = tdmp->
traces[client_index];
115 client_trace_cache = 0;
119 iterator_thread_id = clib_net_to_host_u32 (mp->
thread_id);
120 iterator_position = clib_net_to_host_u32 (mp->
position);
121 max_records = clib_net_to_host_u32 (mp->
max_records);
124 if (
vec_len (client_trace_cache) == 0
125 && (iterator_thread_id != ~0 || iterator_position != ~0))
143 vec_add1 (client_trace_cache[i], th[0]);
147 if (
vec_len (client_trace_cache[i]))
157 tdmp->
traces[client_index] = client_trace_cache;
159 for (i = iterator_thread_id; i <
vec_len (client_trace_cache); i++)
161 for (j = iterator_position; j <
vec_len (client_trace_cache[i]); j++)
163 if (max_records == 0)
167 th = &client_trace_cache[
i][j];
176 htons (VL_API_TRACE_DETAILS + (tdmp->
msg_id_base));
178 last_thread_id = dmp->
thread_id = ntohl (i);
179 last_position = dmp->
position = ntohl (j);
185 if (max_records == 1)
188 if (j == (vec_len (client_trace_cache[i]) - 1))
195 if (i == (vec_len (client_trace_cache) - 1) &&
196 j == (vec_len (client_trace_cache[i]) - 1))
198 last_done = dmp->
done = 1;
204 last_done = dmp->
done;
209 iterator_position = 0;
215 rmp->_vl_msg_id = htons (VL_API_TRACE_DUMP_REPLY + (tdmp->
msg_id_base));
217 rmp->
retval = clib_host_to_net_u32 (retval);
220 rmp->
done = last_done;
225 if (iterator_thread_id == ~0 && iterator_position == ~0)
237 #include <tracedump/tracedump.api.c> 262 .version = VPP_BUILD_VER,
263 .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)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
void * vl_msg_api_alloc(int nbytes)
vlib_main_t ** vlib_mains
#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 pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
tracedump_main_t tracedump_main
vlib_trace_header_t **** traces
format_function_t format_vlib_trace
VL_MSG_API_REAPER_FUNCTION(tracedump_cache_reaper)
#define foreach_vlib_main(body)
API main structure, used by both vpp and binary API clients.
An API client registration, only in vpp/vlib.
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)
static clib_error_t * tracedump_cache_reaper(u32 client_index)
#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 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 void setup_message_id_table(snat_main_t *sm, api_main_t *am)
#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)
void trace_apply_filter(vlib_main_t *vm)
int vl_api_vec_to_api_string(const u8 *vec, vl_api_string_t *str)