X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fmain.h;h=0e65c817ae151a2a3dec2995a4e14968327425c4;hb=000a029e4a6a481f35b978dfe474c82d8da88e95;hp=474756bebd64bfefeaf6d23284e8dc718c607d4c;hpb=7fff3d205463d5e0a95d6bdd337100988ef323a3;p=vpp.git diff --git a/src/vlib/main.h b/src/vlib/main.h index 474756bebd6..0e65c817ae1 100644 --- a/src/vlib/main.h +++ b/src/vlib/main.h @@ -58,11 +58,36 @@ #define VLIB_ELOG_MAIN_LOOP 0 #endif +typedef struct +{ + /* Trace RX pkts */ + u8 pcap_rx_enable; + /* Trace TX pkts */ + u8 pcap_tx_enable; + /* Trace drop pkts */ + u8 pcap_drop_enable; + u8 pad1; + u32 max_bytes_per_pkt; + u32 pcap_sw_if_index; + pcap_main_t pcap_main; + u32 filter_classify_table_index; +} vnet_pcap_t; + +typedef struct +{ + u8 trace_filter_enable; + u32 trace_classify_table_index; + u32 trace_filter_set_index; +} vlib_trace_filter_t; + typedef struct vlib_main_t { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); /* Instruction level timing state. */ clib_time_t clib_time; + /* Offset from main thread time */ + f64 time_offset; + f64 time_last_barrier_release; /* Time stamp of last node dispatch. */ u64 cpu_time_last_node_dispatch; @@ -77,17 +102,24 @@ typedef struct vlib_main_t u32 main_loop_vectors_processed; u32 main_loop_nodes_processed; - /* Circular buffer of input node vector counts. - Indexed by low bits of - (main_loop_count >> VLIB_LOG2_INPUT_VECTORS_PER_MAIN_LOOP). */ - u32 vector_counts_per_main_loop[2]; - u32 node_counts_per_main_loop[2]; + /* Internal node vectors, calls */ + u64 internal_node_vectors; + u64 internal_node_calls; + u64 internal_node_vectors_last_clear; + u64 internal_node_calls_last_clear; - /* Main loop hw / sw performance counters */ - u64 (*vlib_node_runtime_perf_counter_cb) (struct vlib_main_t *); - int perf_counter_id; - int perf_counter_fd; + /* Instantaneous vector rate */ + u32 internal_node_last_vectors_per_main_loop; + /* Main loop hw / sw performance counters */ + void (**vlib_node_runtime_perf_counter_cbs) (struct vlib_main_t *, + u64 *, u64 *, + vlib_node_runtime_t *, + vlib_frame_t *, int); + void (**vlib_node_runtime_perf_counter_cb_tmp) (struct vlib_main_t *, + u64 *, u64 *, + vlib_node_runtime_t *, + vlib_frame_t *, int); /* Every so often we switch to the next counter. */ #define VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE 7 @@ -116,8 +148,8 @@ typedef struct vlib_main_t /* Size of the heap */ uword heap_size; - /* Pool of buffer free lists. */ - vlib_buffer_free_list_t *buffer_free_list_pool; + /* buffer main structure. */ + vlib_buffer_main_t *buffer_main; /* physical memory main structure. */ vlib_physmem_main_t physmem_main; @@ -134,8 +166,15 @@ typedef struct vlib_main_t /* Pcap dispatch trace main */ pcap_main_t dispatch_pcap_main; uword dispatch_pcap_enable; + u32 *dispatch_buffer_trace_nodes; u8 *pcap_buffer; + /* pcap rx / tx tracing */ + vnet_pcap_t pcap; + + /* Packet trace capture filter */ + vlib_trace_filter_t trace_filter; + /* Error handling. */ vlib_error_main_t error_main; @@ -156,6 +195,9 @@ typedef struct vlib_main_t /* Event logger trace flags */ int elog_trace_api_messages; int elog_trace_cli_commands; + int elog_trace_graph_dispatch; + int elog_trace_graph_circuit; + u32 elog_trace_graph_circuit_node_index; /* Node call and return event types. */ elog_event_type_t *node_call_elog_event_types; @@ -172,8 +214,10 @@ typedef struct vlib_main_t /* Hash table to record which init functions have been called. */ uword *init_functions_called; - /* to compare with node runtime */ + /* thread, cpu and numa_node indices */ u32 thread_index; + u32 cpu_id; + u32 numa_node; /* List of init functions to call, setup by constructors */ _vlib_init_function_list_elt_t *init_function_registrations; @@ -190,7 +234,10 @@ typedef struct vlib_main_t u8 **argv; /* Top of (worker) dispatch loop callback */ - volatile void (*worker_thread_main_loop_callback) (struct vlib_main_t *); + void (**volatile worker_thread_main_loop_callbacks) (struct vlib_main_t *); + void (**volatile worker_thread_main_loop_callback_tmp) + (struct vlib_main_t *); + clib_spinlock_t worker_thread_main_loop_callback_lock; /* debugging */ volatile int parked_at_barrier; @@ -204,6 +251,14 @@ typedef struct vlib_main_t */ int need_vlib_worker_thread_node_runtime_update; + /* Dispatch loop time accounting */ + u64 loops_this_reporting_interval; + f64 loop_interval_end; + f64 loop_interval_start; + f64 loops_per_second; + f64 seconds_per_loop; + f64 damping_constant; + /* * Barrier epoch - Set to current time, each time barrier_sync or * barrier_release is called with zero recursion. @@ -213,6 +268,9 @@ typedef struct vlib_main_t /* Earliest barrier can be closed again */ f64 barrier_no_close_before; + /* Need to check the frame queues */ + volatile uword check_frame_queues; + /* RPC requests, main thread only */ uword *pending_rpc_requests; uword *processing_rpc_requests; @@ -228,7 +286,7 @@ void vlib_worker_loop (vlib_main_t * vm); always_inline f64 vlib_time_now (vlib_main_t * vm) { - return clib_time_now (&vm->clib_time); + return clib_time_now (&vm->clib_time) + vm->time_offset; } always_inline f64 @@ -286,75 +344,46 @@ vlib_panic (vlib_main_t * vm) vlib_panic_with_error (vm, 0); } -always_inline u32 -vlib_vector_input_stats_index (vlib_main_t * vm, word delta) -{ - u32 i; - i = vm->main_loop_count >> VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE; - ASSERT (is_pow2 (ARRAY_LEN (vm->vector_counts_per_main_loop))); - return (i + delta) & (ARRAY_LEN (vm->vector_counts_per_main_loop) - 1); -} -/* Estimate input rate based on previous - 2^VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE - samples. */ -always_inline u32 -vlib_last_vectors_per_main_loop (vlib_main_t * vm) -{ - u32 i = vlib_vector_input_stats_index (vm, -1); - u32 n = vm->vector_counts_per_main_loop[i]; - return n >> VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE; -} - -/* Total ave vector count per iteration of main loop. */ always_inline f64 -vlib_last_vectors_per_main_loop_as_f64 (vlib_main_t * vm) +vlib_internal_node_vector_rate (vlib_main_t * vm) { - u32 i = vlib_vector_input_stats_index (vm, -1); - u32 v = vm->vector_counts_per_main_loop[i]; - return (f64) v / (f64) (1 << VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE); + u64 vectors; + u64 calls; + + calls = vm->internal_node_calls - vm->internal_node_calls_last_clear; + + if (PREDICT_FALSE (calls == 0)) + return 0.0; + + vectors = vm->internal_node_vectors - vm->internal_node_vectors_last_clear; + + return (f64) vectors / (f64) calls; } -/* Total ave vectors/node count per iteration of main loop. */ -always_inline f64 -vlib_last_vector_length_per_node (vlib_main_t * vm) +always_inline void +vlib_clear_internal_node_vector_rate (vlib_main_t * vm) { - u32 i = vlib_vector_input_stats_index (vm, -1); - u32 v = vm->vector_counts_per_main_loop[i]; - u32 n = vm->node_counts_per_main_loop[i]; - return n == 0 ? 0 : (f64) v / (f64) n; + vm->internal_node_calls_last_clear = vm->internal_node_calls; + vm->internal_node_vectors_last_clear = vm->internal_node_vectors; } -extern u32 wraps; - always_inline void vlib_increment_main_loop_counter (vlib_main_t * vm) { - u32 i, c, n, v, is_wrap; - - c = vm->main_loop_count++; - - is_wrap = (c & pow2_mask (VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE)) == 0; - - if (is_wrap) - wraps++; - - i = vlib_vector_input_stats_index (vm, /* delta */ is_wrap); - - v = is_wrap ? 0 : vm->vector_counts_per_main_loop[i]; - n = is_wrap ? 0 : vm->node_counts_per_main_loop[i]; - - v += vm->main_loop_vectors_processed; - n += vm->main_loop_nodes_processed; - vm->main_loop_vectors_processed = 0; - vm->main_loop_nodes_processed = 0; - vm->vector_counts_per_main_loop[i] = v; - vm->node_counts_per_main_loop[i] = n; + vm->main_loop_count++; + vm->internal_node_last_vectors_per_main_loop = 0; if (PREDICT_FALSE (vm->main_loop_exit_now)) clib_longjmp (&vm->main_loop_exit, VLIB_MAIN_LOOP_EXIT_CLI); } +always_inline u32 +vlib_last_vectors_per_main_loop (vlib_main_t * vm) +{ + return vm->internal_node_last_vectors_per_main_loop; +} + always_inline void vlib_set_queue_signal_callback (vlib_main_t * vm, void (*fp) (vlib_main_t *)) { @@ -375,6 +404,18 @@ extern void vlib_node_sync_stats (vlib_main_t * vm, vlib_node_t * n); #define VLIB_PCAP_MAJOR_VERSION 1 #define VLIB_PCAP_MINOR_VERSION 0 +typedef struct +{ + u8 *filename; + int enable; + int status; + u32 packets_to_capture; + u32 buffer_trace_node_index; + u32 buffer_traces_to_capture; +} vlib_pcap_dispatch_trace_args_t; + +int vlib_pcap_dispatch_trace_configure (vlib_pcap_dispatch_trace_args_t *); + #endif /* included_vlib_main_h */ /*