FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
fib_walk.c File Reference
+ Include dependency graph for fib_walk.c:

Go to the source code of this file.

Data Structures

struct  fib_walk_t_
 A representation of a graph walk from a parent object to its children. More...
 
struct  fib_walk_queue_t_
 A represenation of one queue of walk. More...
 
struct  fib_walk_queues_t_
 A set of priority queues for outstanding walks. More...
 
struct  fib_walk_history_t_
 

Macros

#define FIB_WALK_EVENT   0
 There's only one event type sent to the walk process. More...
 
#define FIB_WALK_QUEUE_STATS_NUM   ((fib_walk_queue_stats_t)(FIB_WALK_COMPLETED+1))
 
#define FIB_WALK_QUEUE_STATS
 
#define FOR_EACH_FIB_WALK_QUEUE_STATS(_wqs)
 
#define HISTOGRAM_VISITS_PER_WALK_MAX   (1<<23)
 Histogram stats on the lenths of each walk in elemenets visisted. More...
 
#define HISTOGRAM_VISITS_PER_WALK_INCR   (1<<10)
 
#define HISTOGRAM_VISITS_PER_WALK_N_BUCKETS   (HISTOGRAM_VISITS_PER_WALK_MAX/HISTOGRAM_VISITS_PER_WALK_INCR)
 
#define HISTORY_N_WALKS   128
 History of state for the last 128 walks. More...
 
#define MAX_HISTORY_REASONS   16
 
#define FIB_WALK_N_SLEEP   (FIB_WALK_LONG_SLEEP+1)
 
#define N_TIME_BUCKETS   128
 Histogram on the amount of work done (in msecs) in each walk. More...
 
#define TIME_INCREMENTS   (N_TIME_BUCKETS/2)
 
#define N_ELTS_BUCKETS   128
 Histogram on the number of nodes visted in each quota. More...
 
#define USEC   1000000
 

Typedefs

typedef enum fib_walk_flags_t_ fib_walk_flags_t
 The flags on a walk. More...
 
typedef struct fib_walk_t_ fib_walk_t
 A representation of a graph walk from a parent object to its children. More...
 
typedef enum fib_walk_queue_stats_t_ fib_walk_queue_stats_t
 Statistics maintained per-walk queue. More...
 
typedef struct fib_walk_queue_t_ fib_walk_queue_t
 A represenation of one queue of walk. More...
 
typedef struct fib_walk_queues_t_ fib_walk_queues_t
 A set of priority queues for outstanding walks. More...
 
typedef struct fib_walk_history_t_ fib_walk_history_t
 
typedef enum fib_walk_advance_rc_t_ fib_walk_advance_rc_t
 return code when advancing a walk More...
 
typedef enum fib_walk_sleep_type_t_ fib_walk_sleep_type_t
 Enurmerate the times of sleep between walks More...
 

Enumerations

enum  fib_walk_flags_t_ { FIB_WALK_FLAG_SYNC = (1 << 0), FIB_WALK_FLAG_ASYNC = (1 << 1), FIB_WALK_FLAG_EXECUTING = (1 << 2) }
 The flags on a walk. More...
 
enum  fib_walk_queue_stats_t_ { FIB_WALK_SCHEDULED, FIB_WALK_COMPLETED }
 Statistics maintained per-walk queue. More...
 
enum  fib_walk_advance_rc_t_ { FIB_WALK_ADVANCE_DONE, FIB_WALK_ADVANCE_MORE, FIB_WALK_ADVANCE_MERGE }
 return code when advancing a walk More...
 
enum  fib_walk_sleep_type_t_ { FIB_WALK_SHORT_SLEEP, FIB_WALK_LONG_SLEEP }
 Enurmerate the times of sleep between walks More...
 

Functions

u8format_fib_walk_priority (u8 *s, va_list ap)
 
static u8format_fib_walk_queue_stats (u8 *s, va_list ap)
 
static index_t fib_walk_get_index (fib_walk_t *fwalk)
 
static fib_walk_tfib_walk_get (index_t fwi)
 
u32 fib_walk_queue_get_size (fib_walk_priority_t prio)
 
static fib_node_index_t fib_walk_queue_get_front (fib_walk_priority_t prio)
 
static void fib_walk_destroy (fib_walk_t *fwalk)
 
static fib_walk_advance_rc_t fib_walk_advance (fib_node_index_t fwi)
 Advance the walk one element in its work list. More...
 
f64 fib_walk_process_queues (vlib_main_t *vm, const f64 quota)
 Service the queues This is not declared static so that it can be unit tested - i know i know... More...
 
static uword fib_walk_process (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
 The 'fib-walk' process's main loop. More...
 
static fib_walk_tfib_walk_alloc (fib_node_type_t parent_type, fib_node_index_t parent_index, fib_walk_flags_t flags, fib_node_back_walk_ctx_t *ctx)
 Allocate a new walk object. More...
 
static index_t fib_walk_prio_queue_enquue (fib_walk_priority_t prio, fib_walk_t *fwalk)
 Enqueue a walk onto the appropriate priority queue. More...
 
void fib_walk_async (fib_node_type_t parent_type, fib_node_index_t parent_index, fib_walk_priority_t prio, fib_node_back_walk_ctx_t *ctx)
 
void fib_walk_sync (fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_back_walk_ctx_t *ctx)
 Back walk all the children of a FIB node. More...
 
static fib_node_tfib_walk_get_node (fib_node_index_t index)
 
static void fib_walk_last_lock_gone (fib_node_t *node)
 Walk objects are not parents, nor are they locked. More...
 
static fib_walk_tfib_walk_get_from_node (fib_node_t *node)
 
static fib_node_back_walk_rc_t fib_walk_back_walk_notify (fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
 Another back walk has reach this walk. More...
 
void fib_walk_module_init (void)
 
static u8format_fib_walk (u8 *s, va_list ap)
 
static clib_error_tfib_walk_show (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tfib_walk_set_quota (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tfib_walk_set_histogram_elements_size (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tfib_walk_clear (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 

Variables

static fib_walk_tfib_walk_pool
 The pool of all walk objects. More...
 
static const char *const fib_walk_queue_stats_names [] = FIB_WALK_QUEUE_STATS
 The names of the walk stats. More...
 
static const char *const fib_node_bw_reason_names [] = FIB_NODE_BW_REASONS
 The names of the walk reasons. More...
 
static fib_walk_queues_t fib_walk_queues
 The global queues of outstanding walks. More...
 
static const char *const fib_walk_priority_names [] = FIB_WALK_PRIORITIES
 The names of the walk priorities. More...
 
static u64 fib_walk_hist_vists_per_walk [HISTOGRAM_VISITS_PER_WALK_N_BUCKETS]
 
static u32 history_last_walk_pos
 
static fib_walk_history_t fib_walk_history [HISTORY_N_WALKS]
 
static f64 fib_walk_sleep_duration []
 Durations for the sleep types. More...
 
static f64 quota = 1e-4
 The time quota for a walk. More...
 
static u64 fib_walk_work_time_taken [N_TIME_BUCKETS]
 
static u32 fib_walk_work_nodes_visisted_incr = 2
 
static u64 fib_walk_work_nodes_visited [N_ELTS_BUCKETS]
 
static u64 fib_walk_sleep_lengths [2]
 Histogram of the sleep lengths. More...
 
static vlib_node_registration_t fib_walk_process_node
 (constructor) VLIB_REGISTER_NODE (fib_walk_process_node) More...
 
static const fib_node_vft_t fib_walk_vft
 The FIB walk's graph node virtual function table. More...
 
static vlib_cli_command_t fib_walk_show_command
 (constructor) VLIB_CLI_COMMAND (fib_walk_show_command) More...
 
static vlib_cli_command_t fib_walk_set_quota_command
 (constructor) VLIB_CLI_COMMAND (fib_walk_set_quota_command) More...
 
static vlib_cli_command_t fib_walk_set_histogram_elements_size_command
 (constructor) VLIB_CLI_COMMAND (fib_walk_set_histogram_elements_size_command) More...
 
static vlib_cli_command_t fib_walk_clear_command
 (constructor) VLIB_CLI_COMMAND (fib_walk_clear_command) More...
 

Macro Definition Documentation

#define FIB_WALK_EVENT   0

There's only one event type sent to the walk process.

Definition at line 101 of file fib_walk.c.

#define FIB_WALK_N_SLEEP   (FIB_WALK_LONG_SLEEP+1)

Definition at line 387 of file fib_walk.c.

#define FIB_WALK_QUEUE_STATS
Value:
{ \
[FIB_WALK_SCHEDULED] = "scheduled", \
[FIB_WALK_COMPLETED] = "completed", \
}

Definition at line 113 of file fib_walk.c.

#define FIB_WALK_QUEUE_STATS_NUM   ((fib_walk_queue_stats_t)(FIB_WALK_COMPLETED+1))

Definition at line 111 of file fib_walk.c.

#define FOR_EACH_FIB_WALK_QUEUE_STATS (   _wqs)
Value:
for ((_wqs) = FIB_WALK_SCHEDULED; \
(_wqs)++)
#define FIB_WALK_QUEUE_STATS_NUM
Definition: fib_walk.c:111

Definition at line 118 of file fib_walk.c.

#define HISTOGRAM_VISITS_PER_WALK_INCR   (1<<10)

Definition at line 171 of file fib_walk.c.

#define HISTOGRAM_VISITS_PER_WALK_MAX   (1<<23)

Histogram stats on the lenths of each walk in elemenets visisted.

Store upto 1<<23 elements in increments of 1<<10

Definition at line 170 of file fib_walk.c.

#define HISTOGRAM_VISITS_PER_WALK_N_BUCKETS   (HISTOGRAM_VISITS_PER_WALK_MAX/HISTOGRAM_VISITS_PER_WALK_INCR)

Definition at line 172 of file fib_walk.c.

#define HISTORY_N_WALKS   128

History of state for the last 128 walks.

Definition at line 179 of file fib_walk.c.

#define MAX_HISTORY_REASONS   16

Definition at line 180 of file fib_walk.c.

#define N_ELTS_BUCKETS   128

Histogram on the number of nodes visted in each quota.

Definition at line 413 of file fib_walk.c.

#define N_TIME_BUCKETS   128

Histogram on the amount of work done (in msecs) in each walk.

Definition at line 406 of file fib_walk.c.

#define TIME_INCREMENTS   (N_TIME_BUCKETS/2)

Definition at line 407 of file fib_walk.c.

#define USEC   1000000

Typedef Documentation

return code when advancing a walk

The flags on a walk.

Statistics maintained per-walk queue.

A represenation of one queue of walk.

A set of priority queues for outstanding walks.

Enurmerate the times of sleep between walks

typedef struct fib_walk_t_ fib_walk_t

A representation of a graph walk from a parent object to its children.

Enumeration Type Documentation

return code when advancing a walk

Enumerator
FIB_WALK_ADVANCE_DONE 

The walk is complete.

FIB_WALK_ADVANCE_MORE 

the walk has more work

FIB_WALK_ADVANCE_MERGE 

The walk merged with the one in front.

Definition at line 299 of file fib_walk.c.

The flags on a walk.

Enumerator
FIB_WALK_FLAG_SYNC 

A synchronous walk.

This walk will run to completion, i.e. visit ALL the children. It is a depth first traversal of the graph.

FIB_WALK_FLAG_ASYNC 

An asynchronous walk.

This walk will be scheduled to run in the background. It will thus visits the children at a later point in time. It is a depth first traversal of the graph.

FIB_WALK_FLAG_EXECUTING 

An indication that the walk is currently executing.

Definition at line 22 of file fib_walk.c.

Statistics maintained per-walk queue.

Enumerator
FIB_WALK_SCHEDULED 
FIB_WALK_COMPLETED 

Definition at line 106 of file fib_walk.c.

Enurmerate the times of sleep between walks

Enumerator
FIB_WALK_SHORT_SLEEP 
FIB_WALK_LONG_SLEEP 

Definition at line 381 of file fib_walk.c.

Function Documentation

static fib_walk_advance_rc_t fib_walk_advance ( fib_node_index_t  fwi)
static

Advance the walk one element in its work list.

Definition at line 319 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static fib_walk_t* fib_walk_alloc ( fib_node_type_t  parent_type,
fib_node_index_t  parent_index,
fib_walk_flags_t  flags,
fib_node_back_walk_ctx_t ctx 
)
static

Allocate a new walk object.

Definition at line 558 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fib_walk_async ( fib_node_type_t  parent_type,
fib_node_index_t  parent_index,
fib_walk_priority_t  prio,
fib_node_back_walk_ctx_t ctx 
)

Definition at line 620 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static fib_node_back_walk_rc_t fib_walk_back_walk_notify ( fib_node_t node,
fib_node_back_walk_ctx_t ctx 
)
static

Another back walk has reach this walk.

Megre them so there is only one left. It is this node being visited that will remain, so copy or merge the context onto it.

Definition at line 814 of file fib_walk.c.

+ Here is the call graph for this function:

static clib_error_t* fib_walk_clear ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1091 of file fib_walk.c.

static void fib_walk_destroy ( fib_walk_t fwalk)
static

Definition at line 243 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static fib_walk_t* fib_walk_get ( index_t  fwi)
static

Definition at line 218 of file fib_walk.c.

+ Here is the caller graph for this function:

static fib_walk_t* fib_walk_get_from_node ( fib_node_t node)
static

Definition at line 802 of file fib_walk.c.

+ Here is the caller graph for this function:

static index_t fib_walk_get_index ( fib_walk_t fwalk)
static

Definition at line 212 of file fib_walk.c.

+ Here is the caller graph for this function:

static fib_node_t* fib_walk_get_node ( fib_node_index_t  index)
static

Definition at line 782 of file fib_walk.c.

+ Here is the call graph for this function:

static void fib_walk_last_lock_gone ( fib_node_t node)
static

Walk objects are not parents, nor are they locked.

are no-ops

Definition at line 796 of file fib_walk.c.

void fib_walk_module_init ( void  )

Definition at line 864 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static index_t fib_walk_prio_queue_enquue ( fib_walk_priority_t  prio,
fib_walk_t fwalk 
)
static

Enqueue a walk onto the appropriate priority queue.

Then signal the background process there is work to do.

Definition at line 595 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uword fib_walk_process ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t f 
)
static

The 'fib-walk' process's main loop.

Definition at line 517 of file fib_walk.c.

+ Here is the call graph for this function:

f64 fib_walk_process_queues ( vlib_main_t vm,
const f64  quota 
)

Service the queues This is not declared static so that it can be unit tested - i know i know...

Definition at line 427 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static fib_node_index_t fib_walk_queue_get_front ( fib_walk_priority_t  prio)
static

Definition at line 233 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 fib_walk_queue_get_size ( fib_walk_priority_t  prio)

Definition at line 227 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* fib_walk_set_histogram_elements_size ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1065 of file fib_walk.c.

+ Here is the call graph for this function:

static clib_error_t* fib_walk_set_quota ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1039 of file fib_walk.c.

+ Here is the call graph for this function:

static clib_error_t* fib_walk_show ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 892 of file fib_walk.c.

+ Here is the call graph for this function:

void fib_walk_sync ( fib_node_type_t  parent_type,
fib_node_index_t  parent_index,
fib_node_back_walk_ctx_t ctx 
)

Back walk all the children of a FIB node.

note this is a synchronous depth first walk. Children visited may propagate the walk to thier children. Other children node types may not propagate, synchronously but instead queue the walk for later async completion.

Definition at line 674 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u8* format_fib_walk ( u8 s,
va_list  ap 
)
static

Definition at line 877 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_fib_walk_priority ( u8 s,
va_list  ap 
)

Definition at line 193 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u8* format_fib_walk_queue_stats ( u8 s,
va_list  ap 
)
static

Definition at line 202 of file fib_walk.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const char* const fib_node_bw_reason_names[] = FIB_NODE_BW_REASONS
static

The names of the walk reasons.

Definition at line 130 of file fib_walk.c.

vlib_cli_command_t fib_walk_clear_command
static
Initial value:
= {
.path = "clear fib walk",
.short_help = "clear fib walk",
.function = fib_walk_clear,
}
static clib_error_t * fib_walk_clear(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: fib_walk.c:1091

(constructor) VLIB_CLI_COMMAND (fib_walk_clear_command)

Definition at line 1104 of file fib_walk.c.

u64 fib_walk_hist_vists_per_walk[HISTOGRAM_VISITS_PER_WALK_N_BUCKETS]
static

Definition at line 174 of file fib_walk.c.

fib_walk_history_t fib_walk_history[HISTORY_N_WALKS]
static

Definition at line 190 of file fib_walk.c.

fib_walk_t* fib_walk_pool
static

The pool of all walk objects.

Definition at line 96 of file fib_walk.c.

const char* const fib_walk_priority_names[] = FIB_WALK_PRIORITIES
static

The names of the walk priorities.

Definition at line 164 of file fib_walk.c.

vlib_node_registration_t fib_walk_process_node
static
Initial value:
= {
.function = fib_walk_process,
.name = "fib-walk",
}
static uword fib_walk_process(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
The &#39;fib-walk&#39; process&#39;s main loop.
Definition: fib_walk.c:517

(constructor) VLIB_REGISTER_NODE (fib_walk_process_node)

Definition at line 547 of file fib_walk.c.

const char* const fib_walk_queue_stats_names[] = FIB_WALK_QUEUE_STATS
static

The names of the walk stats.

Definition at line 126 of file fib_walk.c.

fib_walk_queues_t fib_walk_queues
static

The global queues of outstanding walks.

Definition at line 159 of file fib_walk.c.

vlib_cli_command_t fib_walk_set_histogram_elements_size_command
static
Initial value:
= {
.path = "set fib walk histogram elements size",
.short_help = "set fib walk histogram elements size",
}
static clib_error_t * fib_walk_set_histogram_elements_size(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: fib_walk.c:1065

(constructor) VLIB_CLI_COMMAND (fib_walk_set_histogram_elements_size_command)

Definition at line 1084 of file fib_walk.c.

vlib_cli_command_t fib_walk_set_quota_command
static
Initial value:
= {
.path = "set fib walk quota",
.short_help = "set fib walk quota",
.function = fib_walk_set_quota,
}
static clib_error_t * fib_walk_set_quota(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: fib_walk.c:1039

(constructor) VLIB_CLI_COMMAND (fib_walk_set_quota_command)

Definition at line 1058 of file fib_walk.c.

vlib_cli_command_t fib_walk_show_command
static
Initial value:
= {
.path = "show fib walk",
.short_help = "show fib walk",
.function = fib_walk_show,
}
static clib_error_t * fib_walk_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: fib_walk.c:892

(constructor) VLIB_CLI_COMMAND (fib_walk_show_command)

Definition at line 1032 of file fib_walk.c.

f64 fib_walk_sleep_duration[]
static
Initial value:

Durations for the sleep types.

Definition at line 392 of file fib_walk.c.

u64 fib_walk_sleep_lengths[2]
static

Histogram of the sleep lengths.

Definition at line 420 of file fib_walk.c.

const fib_node_vft_t fib_walk_vft
static
Initial value:
= {
.fnv_get = fib_walk_get_node,
.fnv_last_lock = fib_walk_last_lock_gone,
.fnv_back_walk = fib_walk_back_walk_notify,
}
static fib_node_back_walk_rc_t fib_walk_back_walk_notify(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Another back walk has reach this walk.
Definition: fib_walk.c:814
static fib_node_t * fib_walk_get_node(fib_node_index_t index)
Definition: fib_walk.c:782
static void fib_walk_last_lock_gone(fib_node_t *node)
Walk objects are not parents, nor are they locked.
Definition: fib_walk.c:796

The FIB walk's graph node virtual function table.

Definition at line 857 of file fib_walk.c.

u32 fib_walk_work_nodes_visisted_incr = 2
static

Definition at line 414 of file fib_walk.c.

u64 fib_walk_work_nodes_visited[N_ELTS_BUCKETS]
static

Definition at line 415 of file fib_walk.c.

u64 fib_walk_work_time_taken[N_TIME_BUCKETS]
static

Definition at line 408 of file fib_walk.c.

u32 history_last_walk_pos
static

Definition at line 181 of file fib_walk.c.

f64 quota = 1e-4
static

The time quota for a walk.

When more than this amount of time is spent, the walk process will yield.

Definition at line 401 of file fib_walk.c.