FD.io VPP
v18.07-rc0-415-g6c78436
Vector Packet Processing
|
Optimized thread-safe counters. More...
Go to the source code of this file.
Data Structures | |
struct | vlib_simple_counter_main_t |
A collection of simple counters. More... | |
struct | vlib_counter_t |
Combined counter to hold both packets and byte differences. More... | |
struct | vlib_combined_counter_main_t |
A collection of combined counters. More... | |
Macros | |
#define | vlib_counter_len(cm) vec_len((cm)->maxi) |
Obtain the number of simple or combined counters allocated. More... | |
Typedefs | |
typedef u64 | counter_t |
64bit counters More... | |
Functions | |
u32 | vlib_simple_counter_n_counters (const vlib_simple_counter_main_t *cm) |
The number of counters (not the number of per-thread counters) More... | |
static void | vlib_increment_simple_counter (vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment) |
Increment a simple counter. More... | |
static counter_t | vlib_get_simple_counter (vlib_simple_counter_main_t *cm, u32 index) |
Get the value of a simple counter Scrapes the entire set of per-thread counters. More... | |
static void | vlib_zero_simple_counter (vlib_simple_counter_main_t *cm, u32 index) |
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter. More... | |
static void | vlib_counter_add (vlib_counter_t *a, vlib_counter_t *b) |
Add two combined counters, results in the first counter. More... | |
static void | vlib_counter_sub (vlib_counter_t *a, vlib_counter_t *b) |
Subtract combined counters, results in the first counter. More... | |
static void | vlib_counter_zero (vlib_counter_t *a) |
Clear a combined counter. More... | |
u32 | vlib_combined_counter_n_counters (const vlib_combined_counter_main_t *cm) |
The number of counters (not the number of per-thread counters) More... | |
void | vlib_clear_simple_counters (vlib_simple_counter_main_t *cm) |
Clear a collection of simple counters. More... | |
void | vlib_clear_combined_counters (vlib_combined_counter_main_t *cm) |
Clear a collection of combined counters. More... | |
static void | vlib_increment_combined_counter (vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes) |
Increment a combined counter. More... | |
static void | vlib_prefetch_combined_counter (const vlib_combined_counter_main_t *cm, u32 thread_index, u32 index) |
Pre-fetch a per-thread combined counter for the given object index. More... | |
static void | vlib_get_combined_counter (const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result) |
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thread counters. More... | |
static void | vlib_zero_combined_counter (vlib_combined_counter_main_t *cm, u32 index) |
Clear a combined counter Clears the set of per-thread counters. More... | |
void | vlib_validate_simple_counter (vlib_simple_counter_main_t *cm, u32 index) |
validate a simple counter More... | |
void | vlib_validate_combined_counter (vlib_combined_counter_main_t *cm, u32 index) |
validate a combined counter More... | |
Optimized thread-safe counters.
Each vlib_[simple|combined]_counter_main_t consists of a per-thread vector of per-object counters.
The idea is to drastically eliminate atomic operations.
Definition in file counter.h.
#define vlib_counter_len | ( | cm | ) | vec_len((cm)->maxi) |
Obtain the number of simple or combined counters allocated.
A macro which reduces to to vec_len(cm->maxi), the answer in either case.
cm | - (vlib_simple_counter_main_t) or (vlib_combined_counter_main_t) the counter collection to interrogate |
void vlib_clear_combined_counters | ( | vlib_combined_counter_main_t * | cm | ) |
Clear a collection of combined counters.
cm | - (vlib_combined_counter_main_t *) collection to clear |
Definition at line 60 of file counter.c.
void vlib_clear_simple_counters | ( | vlib_simple_counter_main_t * | cm | ) |
Clear a collection of simple counters.
cm | - (vlib_simple_counter_main_t *) collection to clear |
Definition at line 43 of file counter.c.
u32 vlib_combined_counter_n_counters | ( | const vlib_combined_counter_main_t * | cm | ) |
|
inlinestatic |
Add two combined counters, results in the first counter.
[in,out] | a | - (vlib_counter_t *) dst counter |
b | - (vlib_counter_t *) src counter |
|
inlinestatic |
Subtract combined counters, results in the first counter.
[in,out] | a | - (vlib_counter_t *) dst counter |
b | - (vlib_counter_t *) src counter |
|
inlinestatic |
Clear a combined counter.
a | - (vlib_counter_t *) counter to clear |
|
inlinestatic |
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thread counters.
Innacurate unless worker threads which might increment the counter are barrier-synchronized
cm | - (vlib_combined_counter_main_t *) combined counter main pointer |
index | - (u32) index of the combined counter to fetch |
result | [out] - (vlib_counter_t *) result stored here |
Definition at line 252 of file counter.h.
|
inlinestatic |
Get the value of a simple counter Scrapes the entire set of per-thread counters.
Innacurate unless worker threads which might increment the counter are barrier-synchronized
cm | - (vlib_simple_counter_main_t *) simple counter main pointer |
index | - (u32) index of the counter to fetch |
Definition at line 98 of file counter.h.
|
inlinestatic |
Increment a combined counter.
cm | - (vlib_combined_counter_main_t *) comined counter main pointer |
thread_index | - (u32) the current cpu index |
index | - (u32) index of the counter to increment |
packet_increment | - (u64) number of packets to add to the counter |
byte_increment | - (u64) number of bytes to add to the counter |
|
inlinestatic |
Increment a simple counter.
cm | - (vlib_simple_counter_main_t *) simple counter main pointer |
thread_index | - (u32) the current cpu index |
index | - (u32) index of the counter to increment |
increment | - (u64) quantitiy to add to the counter |
Definition at line 79 of file counter.h.
|
inlinestatic |
u32 vlib_simple_counter_n_counters | ( | const vlib_simple_counter_main_t * | cm | ) |
void vlib_validate_combined_counter | ( | vlib_combined_counter_main_t * | cm, |
u32 | index | ||
) |
validate a combined counter
cm | - (vlib_combined_counter_main_t *) pointer to the counter collection |
index | - (u32) index of the counter to validate |
Definition at line 106 of file counter.c.
void vlib_validate_simple_counter | ( | vlib_simple_counter_main_t * | cm, |
u32 | index | ||
) |
validate a simple counter
cm | - (vlib_simple_counter_main_t *) pointer to the counter collection |
index | - (u32) index of the counter to validate |
Definition at line 92 of file counter.c.
|
inlinestatic |
Clear a combined counter Clears the set of per-thread counters.
cm | - (vlib_combined_counter_main_t *) combined counter main pointer |
index | - (u32) index of the counter to clear |
Definition at line 278 of file counter.h.
|
inlinestatic |
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
cm | - (vlib_simple_counter_main_t *) simple counter main pointer |
index | - (u32) index of the counter to clear |
Definition at line 124 of file counter.h.
serialize_function_t serialize_vlib_combined_counter_main |
serialize_function_t serialize_vlib_simple_counter_main |
serialize_function_t unserialize_vlib_combined_counter_main |
serialize_function_t unserialize_vlib_simple_counter_main |