|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
6 #include <vpp/app/version.h>
24 #define VLIB_PCAP_MAJOR_VERSION 1
25 #define VLIB_PCAP_MINOR_VERSION 0
44 s =
format (s,
"current_data: %d, current_length: %d\n",
47 s,
"current_config_index/punt_reason: %d, flow_id: %x, next_buffer: %x\n",
49 s =
format (s,
"error: %d, ref_count: %d, buffer_pool_index: %d\n",
52 s =
format (s,
"trace_handle: 0x%x, len_not_first_buf: %d\n",
57 #define A(x) vec_add1 (dtt->pcap_buffer, (x))
88 for (
i = 0;
i <
frame->n_vectors;
i++)
104 A ((
from[
i] >> 24) & 0xff);
105 A ((
from[
i] >> 16) & 0xff);
106 A ((
from[
i] >> 8) & 0xff);
107 A ((
from[
i] >> 0) & 0xff);
198 (
char *)
format (0,
"/tmp/dispatch_post_mortem.%d%c", getpid (), 0);
225 "pcap dispatch capture enabled: %d of %d pkts...",
232 vm,
"Buffer trace of %d pkts from %U enabled...",
246 return VNET_API_ERROR_INVALID_VALUE;
249 if (dtm->
enable == 0 &&
a->enable == 0)
250 return VNET_API_ERROR_VALUE_EXIST;
253 if (dtm->
enable &&
a->enable &&
255 return VNET_API_ERROR_INVALID_VALUE_2;
258 if (
a->buffer_trace_node_index != ~0)
262 tm = &this_vlib_main->trace_main;
265 tn = tm->
nodes +
a->buffer_trace_node_index;
266 tn->
limit +=
a->buffer_traces_to_capture;
275 clib_warning (0,
"Dispatch wrapper already in use on thread %u",
276 this_vlib_main->thread_index);
286 memset (pm, 0,
sizeof (*pm));
293 if (
a->filename == 0)
294 a->filename =
format (0,
"/tmp/dispatch.pcap%c", 0);
307 tm = &this_vlib_main->trace_main;
326 return VNET_API_ERROR_SYSCALL_ERROR_1;
331 return VNET_API_ERROR_NO_SUCH_ENTRY;
338 if (epoll_input_node)
371 if (
unformat (line_input,
"on %=", &enable, 1))
373 else if (
unformat (line_input,
"enable %=", &enable, 1))
375 else if (
unformat (line_input,
"off %=", &enable, 0))
377 else if (
unformat (line_input,
"disable %=", &enable, 0))
379 else if (
unformat (line_input,
"max %d", &max))
381 else if (
unformat (line_input,
"packets-to-capture %d", &max))
386 else if (
unformat (line_input,
"status %=", &status, 1))
391 else if (
unformat (line_input,
"post-mortem %=", &post_mortem, 1))
403 a->filename = filename;
406 a->packets_to_capture = max;
408 a->buffer_traces_to_capture = buffer_traces_to_capture;
409 a->post_mortem = post_mortem;
426 0,
"can't change number of records to capture while tracing...");
498 .path =
"pcap dispatch trace",
500 "pcap dispatch trace [on|off] [max <nn>] [file <name>] [status]\n"
501 " [buffer-trace <input-node-name> <nn>][post-mortem]",
506 .version = VPP_BUILD_VER,
507 .description =
"Dispatch Trace",
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_init(clib_spinlock_t *p)
u32 next_buffer
Next buffer for this linked-list of buffers.
void vlib_add_del_post_mortem_callback(void *cb, int is_add)
u8 buffer_pool_index
index of buffer pool this buffer belongs.
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
format_function_t format_vlib_trace
static void * pcap_add_packet(pcap_main_t *pm, f64 time_now, u32 n_bytes_in_trace, u32 n_bytes_in_packet)
Add packet.
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define FILTER_FLAG_POST_MORTEM
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define VLIB_PCAP_MAJOR_VERSION
dispatch_trace_thread_t * threads
vlib_get_buffers(vm, from, b, n_left_from)
__clib_export clib_error_t * pcap_close(pcap_main_t *pm)
Close PCAP file.
format_function_t format_vnet_buffer_opaque
vlib_main_t vlib_node_runtime_t * node
#define clib_error_return(e, args...)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
u32 input_main_loops_per_call
For input nodes: decremented on each main loop interation until it reaches zero and function is calle...
dispatch_trace_main_t dispatch_trace_main
pcap_packet_type_t packet_type
Packet type.
u32 trace_handle
Specifies trace buffer handle if VLIB_PACKET_IS_TRACED flag is set.
#define clib_error_report(e)
PCAP main state data structure.
vlib_worker_thread_t * vlib_worker_threads
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static void pcap_postmortem_dump(void)
clib_spinlock_t lock
spinlock to protect e.g.
#define foreach_vlib_main()
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static u8 * format_buffer_metadata(u8 *s, va_list *args)
u32 * dispatch_buffer_trace_nodes
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
unformat_function_t unformat_vlib_node
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
u32 buffer_trace_node_index
u8 * pcap_data
Vector of pcap data.
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
volatile u8 ref_count
Reference count for this buffer.
uword dispatch_pcap_trace(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 flow_id
Generic flow identifier.
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u16 current_length
Nbytes between current data and the end of this buffer.
static void pcap_postmortem_reset(vlib_main_t *vm)
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
static int vlib_node_set_dispatch_wrapper(vlib_main_t *vm, vlib_node_function_t *fn)
#define VLIB_PCAP_MINOR_VERSION
#define vec_free(V)
Free vector's memory (no header).
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
void(**volatile worker_thread_main_loop_callback_tmp)(struct vlib_main_t *, u64 t)
u32 epoll_input_node_index
format_function_t format_vlib_node_name
vlib_trace_header_t ** trace_buffer_pool
u8 * vnet_trace_placeholder
description fragment has unexpected format
static clib_error_t * dispatch_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
vlib_trace_node_t * nodes
format_function_t format_vnet_buffer_flags
static vlib_cli_command_t pcap_dispatch_trace_command
(constructor) VLIB_CLI_COMMAND (pcap_dispatch_trace_command)
__clib_export clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
clib_spinlock_t worker_thread_main_loop_callback_lock
u32 n_packets_to_capture
Number of packets to capture.
static vlib_main_t * vlib_get_main(void)
#define PCAP_MAIN_INIT_DONE
u32 buffer_traces_to_capture
char * file_name
File name of pcap output.
#define clib_warning(format, args...)
void(**volatile worker_thread_main_loop_callbacks)(struct vlib_main_t *, u64 t)
static f64 vlib_time_now(vlib_main_t *vm)
pcap_main_t dispatch_pcap_main
vlib_trace_main_t trace_main
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static u32 vlib_buffer_get_trace_index(vlib_buffer_t *b)
Extract the trace (pool) index from a trace handle.
#define clib_callback_enable_disable(h, tmp, l, f, enable)
Add or remove a callback to the specified callback set.
static vlib_thread_main_t * vlib_get_thread_main()
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
format_function_t format_vnet_buffer_opaque2
static int vlib_pcap_dispatch_trace_configure(vlib_pcap_dispatch_trace_args_t *a)
u32 n_packets_captured
Number of packets currently captured.
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.