49 memset (ssvmp, 0,
sizeof (*ssvmp));
56 clib_warning (
"WARNING: segment map returned %d", retval);
60 fformat (stdout,
"Stat segment mapped OK...\n");
65 shared_header = ssvmp->
sh;
72 #define foreach_cached_pointer \ 73 _(/sys/vector_rate, SCALAR_POINTER, &stat_client_main.vector_rate_ptr) \ 74 _(/sys/input_rate, SCALAR_POINTER, &stat_client_main.input_rate_ptr) \ 75 _(/sys/last_update, SCALAR_POINTER, &stat_client_main.last_runtime_ptr) \ 76 _(/sys/last_stats_clear, SCALAR_POINTER, \ 77 &stat_client_main.last_runtime_stats_clear_ptr) \ 78 _(/if/rx, COUNTER_VECTOR, &stat_client_main.intfc_rx_counters) \ 79 _(/if/tx, COUNTER_VECTOR, &stat_client_main.intfc_tx_counters) \ 80 _(/err/0/counter_vector, VECTOR_POINTER, \ 81 &stat_client_main.thread_0_error_counts) \ 82 _(serialized_nodes, SERIALIZED_NODES, \ 83 &stat_client_main.serialized_nodes) 93 #define _(n,t,p) {#n, STAT_DIR_TYPE_##t, (void *)p}, 102 uword *p, *counter_vector_by_name;
113 fformat (stdout,
"Updating cached pointers...\n");
116 counter_vector_by_name = (
uword *)
121 cp = &cached_pointers[
i];
143 struct timespec ts, tsrem;
146 vlib_counter_t *thread0_rx_counters = 0, *thread0_tx_counters = 0;
150 f64 vector_rate, input_rate;
153 u32 source_address_match_errors;
159 ts.tv_nsec = 100000000;
160 while (nanosleep (&ts, &tsrem) < 0)
164 shared_header = ssvmp->sh;
172 while (nanosleep (&ts, &tsrem) < 0)
204 source_address_match_errors =
212 fformat (stdout,
"vector_rate %.2f input_rate %.2f\n",
213 vector_rate, input_rate);
215 for (i = 0; i <
vec_len (thread0_rx_counters); i++)
217 fformat (stdout,
"[%d]: %lld rx packets, %lld rx bytes\n",
218 i, thread0_rx_counters[i].packets,
219 thread0_rx_counters[i].bytes);
220 fformat (stdout,
"[%d]: %lld tx packets, %lld tx bytes\n",
221 i, thread0_tx_counters[i].packets,
222 thread0_tx_counters[i].bytes);
225 fformat (stdout,
"%lld source address match errors\n",
226 source_address_match_errors);
233 for (i = 0; i <
vec_len (nodes_by_thread); i++)
235 u64 n_input, n_output, n_drop, n_punt;
236 u64 n_internal_vectors, n_internal_calls;
237 u64 n_clocks, l,
v,
c;
240 nodes = nodes_by_thread[
i];
242 fformat (stdout,
"Thread %d -------------------------\n", i);
244 n_input = n_output = n_drop = n_punt = n_clocks = 0;
245 n_internal_vectors = n_internal_calls = 0;
248 for (j = 0; j <
vec_len (nodes); j++)
271 n_internal_vectors +=
v;
272 n_internal_calls +=
c;
286 "%s (%s): clocks %lld calls %lld vectors %lld ",
292 fformat (stdout,
"clocks/pkt %.2f\n",
303 fformat (stdout,
"average vectors/node %.2f\n",
304 (n_internal_calls > 0
305 ? (
f64) n_internal_vectors / (
f64) n_internal_calls
312 " vectors rates in %.4e, out %.4e, drop %.4e, " 315 (
f64) n_output / dt, (
f64) n_drop / dt,
324 fformat (stdout,
"serialized nodes NULL?\n");
335 u8 *stat_segment_name;
346 if (
unformat (a,
"socket-name %s", &stat_segment_name))
350 fformat (stderr,
"%s: usage [socket-name <name>]\n", argv[0]);
360 fformat (stderr,
"Couldn't connect to vpp, does %s exist?\n",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define STAT_SEGMENT_OPAQUE_DIR
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
u64 source_address_match_error_index
#define foreach_cached_pointer
stat_client_main_t stat_client_main
stat_directory_type_t type
Combined counter to hold both packets and byte differences.
#define VLIB_NODE_FLAG_IS_PUNT
for(i=1;i<=collision_buckets;i++)
clib_error_t * clib_socket_init(clib_socket_t *s)
ssvm_shared_header_t * sh
static void stat_poll_loop(stat_client_main_t *sm)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
int main(int argc, char **argv)
vlib_node_stats_t stats_last_clear
clib_spinlock_t * stat_segment_lockp
volatile int segment_ready
static clib_error_t * clib_socket_recvmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
vlib_node_stats_t stats_total
static clib_error_t * clib_socket_close(clib_socket_t *sock)
ssvm_private_t stat_segment
vlib_counter_t ** intfc_rx_counters
#define STAT_SEGMENT_OPAQUE_EPOCH
u64 * thread_0_error_counts
static int stat_segment_connect(stat_client_main_t *sm)
void * clib_mem_init(void *heap, uword size)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
vlib_node_t *** vlib_node_unserialize(u8 *vector)
#define CLIB_SOCKET_F_IS_CLIENT
#define clib_error_report(e)
struct _socket_t clib_socket_t
#define CLIB_SOCKET_F_SEQPACKET
#define VLIB_NODE_FLAG_IS_HANDOFF
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define STAT_SEGMENT_SOCKET_FILE
vlib_counter_t ** intfc_tx_counters
#define VLIB_NODE_FLAG_IS_DROP
#define hash_get_mem(h, key)
#define VLIB_NODE_FLAG_IS_OUTPUT
static void maybe_update_cached_pointers(stat_client_main_t *sm, ssvm_shared_header_t *shared_header)
int ssvm_slave_init_memfd(ssvm_private_t *memfd)
Initialize memfd segment slave.
f64 * last_runtime_stats_clear_ptr
stat_directory_type_t type