FD.io VPP
v17.01-9-ge7dcee4
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_mini_counter_t |
Mini combined counter. 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... | |
Functions | |
static void | vlib_increment_simple_counter (vlib_simple_counter_main_t *cm, u32 cpu_index, u32 index, u32 increment) |
Increment a simple counter. More... | |
static u64 | vlib_get_simple_counter (vlib_simple_counter_main_t *cm, u32 index) |
Get the value of a simple counter Scrapes the entire set of mini 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... | |
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 cpu_index, u32 index, u32 packet_increment, u32 byte_increment) |
Increment a combined counter. More... | |
static void | vlib_get_combined_counter (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 mini 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 u16 counters, and the shared vlib_counter_t. 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 single vector of thread-safe / atomically-updated u64 counters [the "maxi" vector], and a (u16 **) per-thread vector [the "minis" vector] of narrow, per-thread counters.
The idea is to drastically reduce the number of atomic operations. In the case of packet counts, we divide the number of atomic ops by 2**16, etc.
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 67 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.
|
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 |
Definition at line 187 of file counter.h.
|
inlinestatic |
Clear a combined counter.
a | - (vlib_counter_t *) counter to clear |
Definition at line 199 of file counter.h.
|
inlinestatic |
Get the value of a combined counter, never called in the speed path Scrapes the entire set of mini 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 287 of file counter.h.
|
inlinestatic |
Get the value of a simple counter Scrapes the entire set of mini 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 108 of file counter.h.
|
inlinestatic |
Increment a combined counter.
cm | - (vlib_combined_counter_main_t *) comined counter main pointer |
cpu_index | - (u32) the current cpu index |
index | - (u32) index of the counter to increment |
packet_increment | - (u32) number of packets to add to the counter |
byte_increment | - (u32) number of bytes to add to the counter |
Definition at line 241 of file counter.h.
|
inlinestatic |
Increment a simple counter.
cm | - (vlib_simple_counter_main_t *) simple counter main pointer |
cpu_index | - (u32) the current cpu index |
index | - (u32) index of the counter to increment |
increment | - (u32) quantitiy to add to the counter |
Definition at line 78 of file counter.h.
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 110 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 98 of file counter.c.
|
inlinestatic |
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t.
cm | - (vlib_combined_counter_main_t *) combined counter main pointer |
index | - (u32) index of the counter to clear |
Definition at line 321 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 143 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 |