Add callbacks for extended trace functionality, one as content is added with vlib_add_trace, and one to post-process the captured content immediately after trace filtering.

Change-Id: Ieb521686d8c0e7ce1a0ef325f7abdde613e1eb9c
Signed-off-by: Gary Boon <gboon@cisco.com>
This commit is contained in:
Gary Boon
2019-05-03 13:30:14 -04:00
committed by Dave Barach
parent c5fa2b8099
commit 4681e07a02
2 changed files with 33 additions and 1 deletions

View File

@@ -66,6 +66,20 @@ typedef struct
u32 limit;
} vlib_trace_node_t;
/* Callback type for post-processing the vlib trace buffer */
struct vlib_main_t;
struct vlib_trace_main_t;
typedef void (vlib_trace_buffer_callback_t) (struct vlib_main_t *,
struct vlib_trace_main_t *);
/* Callback type for alternate handling of vlib_add_trace internals */
struct vlib_node_runtime_t;
struct vlib_buffer_t;
typedef void *(vlib_add_trace_callback_t) (struct vlib_main_t *,
struct vlib_node_runtime_t * r,
struct vlib_buffer_t * b,
u32 n_data_bytes);
typedef struct
{
/* Pool of trace buffers. */
@@ -87,6 +101,13 @@ typedef struct
/* verbosity */
int verbose;
/* a callback to enable customized consumption of the trace buffer content */
vlib_trace_buffer_callback_t *trace_buffer_callback;
/* a callback to enable customized addition of a new trace */
vlib_add_trace_callback_t *add_trace_callback;
} vlib_trace_main_t;
format_function_t format_vlib_trace;

View File

@@ -63,7 +63,14 @@ vlib_add_trace (vlib_main_t * vm,
ASSERT (vnet_trace_dummy);
if (PREDICT_FALSE (tm->trace_enable == 0))
if (PREDICT_FALSE (tm->add_trace_callback != 0))
{
return tm->add_trace_callback ((struct vlib_main_t *) vm,
(struct vlib_node_runtime_t *) r,
(struct vlib_buffer_t *) b,
n_data_bytes);
}
else if (PREDICT_FALSE (tm->trace_enable == 0))
{
ASSERT (vec_len (vnet_trace_dummy) >= n_data_bytes + sizeof (*h));
return vnet_trace_dummy;
@@ -129,6 +136,10 @@ vlib_trace_buffer (vlib_main_t * vm,
{
tm->last_main_loop_count = vm->main_loop_count;
trace_apply_filter (vm);
if (tm->trace_buffer_callback)
(tm->trace_buffer_callback) ((struct vlib_main_t *) vm,
(struct vlib_trace_main_t *) tm);
}
vlib_trace_next_frame (vm, r, next_index);