FD.io VPP  v19.04-6-g6f05f72
Vector Packet Processing
counter.h File Reference

Optimized thread-safe counters. More...

+ Include dependency graph for counter.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vlib_simple_counter_main_t
 A collection of simple counters. 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

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 void vlib_set_simple_counter (vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 value)
 Set 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...
 

Variables

serialize_function_t serialize_vlib_simple_counter_main
 
serialize_function_t unserialize_vlib_simple_counter_main
 
serialize_function_t serialize_vlib_combined_counter_main
 
serialize_function_t unserialize_vlib_combined_counter_main
 

Detailed Description

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.

Macro Definition Documentation

#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.

Parameters
cm- (vlib_simple_counter_main_t) or (vlib_combined_counter_main_t) the counter collection to interrogate
Returns
vec_len(cm->maxi)

Definition at line 324 of file counter.h.

Function Documentation

void vlib_clear_combined_counters ( vlib_combined_counter_main_t cm)

Clear a collection of combined counters.

Parameters
cm- (vlib_combined_counter_main_t *) collection to clear

Definition at line 60 of file counter.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_clear_simple_counters ( vlib_simple_counter_main_t cm)

Clear a collection of simple counters.

Parameters
cm- (vlib_simple_counter_main_t *) collection to clear

Definition at line 43 of file counter.c.

+ Here is the caller graph for this function:

u32 vlib_combined_counter_n_counters ( const vlib_combined_counter_main_t cm)

The number of counters (not the number of per-thread counters)

Definition at line 121 of file counter.c.

+ Here is the caller graph for this function:

static void vlib_counter_add ( vlib_counter_t a,
vlib_counter_t b 
)
inlinestatic

Add two combined counters, results in the first counter.

Parameters
[in,out]a- (vlib_counter_t *) dst counter
b- (vlib_counter_t *) src counter

Definition at line 159 of file counter.h.

static void vlib_counter_sub ( vlib_counter_t a,
vlib_counter_t b 
)
inlinestatic

Subtract combined counters, results in the first counter.

Parameters
[in,out]a- (vlib_counter_t *) dst counter
b- (vlib_counter_t *) src counter

Definition at line 170 of file counter.h.

static void vlib_counter_zero ( vlib_counter_t a)
inlinestatic

Clear a combined counter.

Parameters
a- (vlib_counter_t *) counter to clear

Definition at line 182 of file counter.h.

static void vlib_get_combined_counter ( const vlib_combined_counter_main_t cm,
u32  index,
vlib_counter_t result 
)
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

Parameters
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 259 of file counter.h.

+ Here is the caller graph for this function:

static counter_t vlib_get_simple_counter ( vlib_simple_counter_main_t cm,
u32  index 
)
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

Parameters
cm- (vlib_simple_counter_main_t *) simple counter main pointer
index- (u32) index of the counter to fetch
Returns
- (u64) current counter value

Definition at line 113 of file counter.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_increment_combined_counter ( vlib_combined_counter_main_t cm,
u32  thread_index,
u32  index,
u64  n_packets,
u64  n_bytes 
)
inlinestatic

Increment a combined counter.

Parameters
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

Definition at line 220 of file counter.h.

static void vlib_increment_simple_counter ( vlib_simple_counter_main_t cm,
u32  thread_index,
u32  index,
u64  increment 
)
inlinestatic

Increment a simple counter.

Parameters
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 78 of file counter.h.

+ Here is the caller graph for this function:

static void vlib_prefetch_combined_counter ( const vlib_combined_counter_main_t cm,
u32  thread_index,
u32  index 
)
inlinestatic

Pre-fetch a per-thread combined counter for the given object index.

Definition at line 235 of file counter.h.

+ Here is the caller graph for this function:

static void vlib_set_simple_counter ( vlib_simple_counter_main_t cm,
u32  thread_index,
u32  index,
u64  value 
)
inlinestatic

Set a simple counter.

Parameters
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
value- (u64) quantitiy to set to the counter

Definition at line 94 of file counter.h.

+ Here is the caller graph for this function:

u32 vlib_simple_counter_n_counters ( const vlib_simple_counter_main_t cm)

The number of counters (not the number of per-thread counters)

Definition at line 128 of file counter.c.

+ Here is the caller graph for this function:

void vlib_validate_combined_counter ( vlib_combined_counter_main_t cm,
u32  index 
)

validate a combined counter

Parameters
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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_validate_simple_counter ( vlib_simple_counter_main_t cm,
u32  index 
)

validate a simple counter

Parameters
cm- (vlib_simple_counter_main_t *) pointer to the counter collection
index- (u32) index of the counter to validate

Definition at line 91 of file counter.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_zero_combined_counter ( vlib_combined_counter_main_t cm,
u32  index 
)
inlinestatic

Clear a combined counter Clears the set of per-thread counters.

Parameters
cm- (vlib_combined_counter_main_t *) combined counter main pointer
index- (u32) index of the counter to clear

Definition at line 285 of file counter.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_zero_simple_counter ( vlib_simple_counter_main_t cm,
u32  index 
)
inlinestatic

Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.

Parameters
cm- (vlib_simple_counter_main_t *) simple counter main pointer
index- (u32) index of the counter to clear

Definition at line 139 of file counter.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

serialize_function_t serialize_vlib_combined_counter_main

Definition at line 328 of file counter.h.

serialize_function_t serialize_vlib_simple_counter_main

Definition at line 326 of file counter.h.

serialize_function_t unserialize_vlib_combined_counter_main

Definition at line 328 of file counter.h.

serialize_function_t unserialize_vlib_simple_counter_main

Definition at line 326 of file counter.h.