aboutsummaryrefslogtreecommitdiffstats
path: root/vlib/vlib/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'vlib/vlib/node.h')
-rw-r--r--vlib/vlib/node.h218
1 files changed, 131 insertions, 87 deletions
diff --git a/vlib/vlib/node.h b/vlib/vlib/node.h
index e9842275..795856e6 100644
--- a/vlib/vlib/node.h
+++ b/vlib/vlib/node.h
@@ -55,7 +55,8 @@ typedef uword (vlib_node_function_t) (struct vlib_main_t * vm,
struct vlib_node_runtime_t * node,
struct vlib_frame_t * frame);
-typedef enum {
+typedef enum
+{
/* An internal node on the call graph (could be output). */
VLIB_NODE_TYPE_INTERNAL,
@@ -74,15 +75,16 @@ typedef enum {
VLIB_N_NODE_TYPE,
} vlib_node_type_t;
-typedef struct _vlib_node_registration {
+typedef struct _vlib_node_registration
+{
/* Vector processing function for this node. */
- vlib_node_function_t * function;
+ vlib_node_function_t *function;
/* Node name. */
- char * name;
+ char *name;
/* Name of sibling (if applicable). */
- char * sibling_of;
+ char *sibling_of;
/* Node index filled in by registration. */
u32 index;
@@ -91,23 +93,23 @@ typedef struct _vlib_node_registration {
vlib_node_type_t type;
/* Error strings indexed by error code for this node. */
- char ** error_strings;
+ char **error_strings;
/* Buffer format/unformat for this node. */
- format_function_t * format_buffer;
- unformat_function_t * unformat_buffer;
+ format_function_t *format_buffer;
+ unformat_function_t *unformat_buffer;
/* Trace format/unformat for this node. */
- format_function_t * format_trace;
- unformat_function_t * unformat_trace;
+ format_function_t *format_trace;
+ unformat_function_t *unformat_trace;
/* Function to validate incoming frames. */
- u8 * (* validate_frame) (struct vlib_main_t * vm,
- struct vlib_node_runtime_t *,
- struct vlib_frame_t * f);
+ u8 *(*validate_frame) (struct vlib_main_t * vm,
+ struct vlib_node_runtime_t *,
+ struct vlib_frame_t * f);
/* Per-node runtime data. */
- void * runtime_data;
+ void *runtime_data;
/* Process stack size. */
u16 process_log2_n_stack_bytes;
@@ -131,10 +133,10 @@ typedef struct _vlib_node_registration {
u16 n_next_nodes;
/* Constructor link-list, don't ask... */
- struct _vlib_node_registration * next_registration;
+ struct _vlib_node_registration *next_registration;
/* Names of next nodes which this node feeds into. */
- char * next_nodes[];
+ char *next_nodes[];
} vlib_node_registration_t;
@@ -148,7 +150,7 @@ static void __vlib_add_node_registration_##x (void) \
x.next_registration = vm->node_main.node_registrations; \
vm->node_main.node_registrations = &x; \
} \
-__VA_ARGS__ vlib_node_registration_t x
+__VA_ARGS__ vlib_node_registration_t x
#if CLIB_DEBUG > 0
#define VLIB_NODE_FUNCTION_CLONE_TEMPLATE(arch, fn)
@@ -179,11 +181,14 @@ __VA_ARGS__ vlib_node_registration_t x
always_inline vlib_node_registration_t *
vlib_node_next_registered (vlib_node_registration_t * c)
{
- c = clib_elf_section_data_next (c, c->n_next_nodes * sizeof (c->next_nodes[0]));
+ c =
+ clib_elf_section_data_next (c,
+ c->n_next_nodes * sizeof (c->next_nodes[0]));
return c;
}
-typedef struct {
+typedef struct
+{
/* Total calls, clock ticks and vector elements processed for this node. */
u64 calls, vectors, clocks, suspends;
u64 max_clock;
@@ -199,19 +204,21 @@ typedef struct {
/* Input node is never called. */ \
_ (DISABLED)
-typedef enum {
+typedef enum
+{
#define _(f) VLIB_NODE_STATE_##f,
foreach_vlib_node_state
#undef _
- VLIB_N_NODE_STATE,
+ VLIB_N_NODE_STATE,
} vlib_node_state_t;
-typedef struct vlib_node_t {
+typedef struct vlib_node_t
+{
/* Vector processing function for this node. */
- vlib_node_function_t * function;
+ vlib_node_function_t *function;
/* Node name. */
- u8 * name;
+ u8 *name;
/* Node name index in elog string table. */
u32 name_elog_string;
@@ -233,7 +240,7 @@ typedef struct vlib_node_t {
u32 runtime_index;
/* Runtime data for this node. */
- void * runtime_data;
+ void *runtime_data;
/* Node flags. */
u16 flags;
@@ -271,48 +278,48 @@ typedef struct vlib_node_t {
u32 error_heap_index;
/* Error strings indexed by error code for this node. */
- char ** error_strings;
+ char **error_strings;
/* Vector of next node names.
Only used before next_nodes array is initialized. */
- char ** next_node_names;
+ char **next_node_names;
/* Next node indices for this node. */
- u32 * next_nodes;
+ u32 *next_nodes;
/* Name of node that we are sibling of. */
- char * sibling_of;
+ char *sibling_of;
/* Bitmap of all of this node's siblings. */
- uword * sibling_bitmap;
+ uword *sibling_bitmap;
/* Total number of vectors sent to each next node. */
- u64 * n_vectors_by_next_node;
+ u64 *n_vectors_by_next_node;
/* Hash table mapping next node index into slot in
next_nodes vector. Quickly determines whether this node
is connected to given next node and, if so, with which slot. */
- uword * next_slot_by_node;
+ uword *next_slot_by_node;
/* Bitmap of node indices which feed this node. */
- uword * prev_node_bitmap;
+ uword *prev_node_bitmap;
/* Node/next-index which own enqueue rights with to this node. */
u32 owner_node_index, owner_next_index;
/* Buffer format/unformat for this node. */
- format_function_t * format_buffer;
- unformat_function_t * unformat_buffer;
+ format_function_t *format_buffer;
+ unformat_function_t *unformat_buffer;
/* Trace buffer format/unformat for this node. */
- format_function_t * format_trace;
+ format_function_t *format_trace;
/* Function to validate incoming frames. */
- u8 * (* validate_frame) (struct vlib_main_t * vm,
- struct vlib_node_runtime_t *,
- struct vlib_frame_t * f);
+ u8 *(*validate_frame) (struct vlib_main_t * vm,
+ struct vlib_node_runtime_t *,
+ struct vlib_frame_t * f);
/* for pretty-printing, not typically valid */
- u8 * state_string;
+ u8 *state_string;
} vlib_node_t;
#define VLIB_INVALID_NODE_INDEX ((u32) ~0)
@@ -322,7 +329,8 @@ typedef struct vlib_node_t {
#define VLIB_FRAME_ALIGN VLIB_MAX_CPUS
/* Calling frame (think stack frame) for a node. */
-typedef struct vlib_frame_t {
+typedef struct vlib_frame_t
+{
/* Frame flags. */
u16 flags;
@@ -342,7 +350,8 @@ typedef struct vlib_frame_t {
u8 arguments[0];
} vlib_frame_t;
-typedef struct {
+typedef struct
+{
/* Frame index. */
u32 frame_index;
@@ -385,7 +394,8 @@ vlib_next_frame_init (vlib_next_frame_t * nf)
}
/* A frame pending dispatch by main loop. */
-typedef struct {
+typedef struct
+{
/* Node and runtime for this frame. */
u32 node_runtime_index;
@@ -399,12 +409,13 @@ typedef struct {
#define VLIB_PENDING_FRAME_NO_NEXT_FRAME ((u32) ~0)
} vlib_pending_frame_t;
-typedef struct vlib_node_runtime_t {
+typedef struct vlib_node_runtime_t
+{
/* Node function to call. */
- vlib_node_function_t * function;
+ vlib_node_function_t *function;
/* Vector of errors for this node. */
- vlib_error_t * errors;
+ vlib_error_t *errors;
/* Number of clock cycles. */
u32 clocks_since_last_overflow;
@@ -459,22 +470,26 @@ typedef struct vlib_node_runtime_t {
- 1 * sizeof (vlib_error_t *)
- 11 * sizeof (u32)
- 5 * sizeof (u16)) / sizeof (uword)];
-} vlib_node_runtime_t;
+}
+vlib_node_runtime_t;
-typedef struct {
+typedef struct
+{
/* Number of allocated frames for this scalar/vector size. */
u32 n_alloc_frames;
/* Vector of free frame indices for this scalar/vector size. */
- u32 * free_frame_indices;
+ u32 *free_frame_indices;
} vlib_frame_size_t;
-typedef struct {
+typedef struct
+{
/* Users opaque value for event type. */
uword opaque;
} vlib_process_event_type_t;
-typedef struct {
+typedef struct
+{
/* Node runtime for this process. */
vlib_node_runtime_t node_runtime;
@@ -507,20 +522,20 @@ typedef struct {
u32 n_suspends;
/* Vectors of pending event data indexed by event type index. */
- void ** pending_event_data_by_type_index;
+ void **pending_event_data_by_type_index;
/* Bitmap of event type-indices with non-empty vectors. */
- uword * non_empty_event_type_bitmap;
+ uword *non_empty_event_type_bitmap;
/* Bitmap of event type-indices which are one time events. */
- uword * one_time_event_type_bitmap;
+ uword *one_time_event_type_bitmap;
/* Type is opaque pointer -- typically a pointer to an event handler
function. Hash table to map opaque to a type index. */
- uword * event_type_index_by_type_opaque;
+ uword *event_type_index_by_type_opaque;
/* Pool of currently valid event types. */
- vlib_process_event_type_t * event_type_pool;
+ vlib_process_event_type_t *event_type_pool;
/* When suspending saves cpu cycle counter when process is to be resumed. */
u64 resume_cpu_time;
@@ -547,17 +562,25 @@ typedef struct {
#ifdef CLIB_UNIX
/* Ensure that the stack is aligned on the multiple of the page size */
-typedef char assert_process_stack_must_be_aligned_exactly_to_page_size_multiple
- [(sizeof(vlib_process_t) - PAGE_SIZE_MULTIPLE) == 0 ? 0 : -1];
+typedef char
+ assert_process_stack_must_be_aligned_exactly_to_page_size_multiple[(sizeof
+ (vlib_process_t)
+ -
+ PAGE_SIZE_MULTIPLE)
+ ==
+ 0 ? 0 :
+ -1];
#endif
-typedef struct {
- u32 node_index;
+typedef struct
+{
+ u32 node_index;
- u32 one_time_event;
+ u32 one_time_event;
} vlib_one_time_waiting_process_t;
-typedef struct {
+typedef struct
+{
u16 n_data_elts;
u16 n_data_elt_bytes;
@@ -570,46 +593,57 @@ typedef struct {
u32 event_type_index;
- union {
+ union
+ {
u8 inline_event_data[64 - 3 * sizeof (u32) - 2 * sizeof (u16)];
/* Vector of event data used only when data does not fit inline. */
- u8 * event_data_as_vector;
+ u8 *event_data_as_vector;
};
-} vlib_signal_timed_event_data_t;
+}
+vlib_signal_timed_event_data_t;
always_inline uword
vlib_timing_wheel_data_is_timed_event (u32 d)
-{ return d & 1; }
+{
+ return d & 1;
+}
always_inline u32
vlib_timing_wheel_data_set_suspended_process (u32 i)
-{ return 0 + 2*i; }
+{
+ return 0 + 2 * i;
+}
always_inline u32
vlib_timing_wheel_data_set_timed_event (u32 i)
-{ return 1 + 2*i; }
+{
+ return 1 + 2 * i;
+}
always_inline uword
vlib_timing_wheel_data_get_index (u32 d)
-{ return d / 2; }
+{
+ return d / 2;
+}
-typedef struct {
+typedef struct
+{
/* Public nodes. */
- vlib_node_t ** nodes;
+ vlib_node_t **nodes;
/* Node index hashed by node name. */
- uword * node_by_name;
+ uword *node_by_name;
u32 flags;
#define VLIB_NODE_MAIN_RUNTIME_STARTED (1 << 0)
/* Nodes segregated by type for cache locality.
Does not apply to nodes of type VLIB_NODE_TYPE_INTERNAL. */
- vlib_node_runtime_t * nodes_by_type[VLIB_N_NODE_TYPE];
+ vlib_node_runtime_t *nodes_by_type[VLIB_N_NODE_TYPE];
/* Node runtime indices for input nodes with pending interrupts. */
- u32 * pending_interrupt_node_runtime_indices;
+ u32 *pending_interrupt_node_runtime_indices;
/* Input nodes are switched from/to interrupt to/from polling mode
when average vector length goes above/below polling/interrupt
@@ -618,55 +652,56 @@ typedef struct {
u32 interrupt_threshold_vector_length;
/* Vector of next frames. */
- vlib_next_frame_t * next_frames;
+ vlib_next_frame_t *next_frames;
/* Vector of internal node's frames waiting to be called. */
- vlib_pending_frame_t * pending_frames;
+ vlib_pending_frame_t *pending_frames;
/* Timing wheel for scheduling time-based node dispatch. */
timing_wheel_t timing_wheel;
- vlib_signal_timed_event_data_t * signal_timed_event_data_pool;
+ vlib_signal_timed_event_data_t *signal_timed_event_data_pool;
/* Opaque data vector added via timing_wheel_advance. */
- u32 * data_from_advancing_timing_wheel;
+ u32 *data_from_advancing_timing_wheel;
/* CPU time of next process to be ready on timing wheel. */
u64 cpu_time_next_process_ready;
/* Vector of process nodes.
One for each node of type VLIB_NODE_TYPE_PROCESS. */
- vlib_process_t ** processes;
+ vlib_process_t **processes;
/* Current running process or ~0 if no process running. */
u32 current_process_index;
/* Pool of pending process frames. */
- vlib_pending_frame_t * suspended_process_frames;
+ vlib_pending_frame_t *suspended_process_frames;
/* Vector of event data vectors pending recycle. */
- void ** recycled_event_data_vectors;
+ void **recycled_event_data_vectors;
/* Current counts of nodes in each state. */
u32 input_node_counts_by_state[VLIB_N_NODE_STATE];
/* Hash of (scalar_size,vector_size) to frame_sizes index. */
- uword * frame_size_hash;
+ uword *frame_size_hash;
/* Per-size frame allocation information. */
- vlib_frame_size_t * frame_sizes;
+ vlib_frame_size_t *frame_sizes;
/* Time of last node runtime stats clear. */
f64 time_last_runtime_stats_clear;
/* Node registrations added by constructors */
- vlib_node_registration_t * node_registrations;
+ vlib_node_registration_t *node_registrations;
} vlib_node_main_t;
#define FRAME_QUEUE_MAX_NELTS 32
-typedef struct {
- CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
+typedef struct
+{
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
u64 head;
u64 head_hint;
u64 tail;
@@ -677,8 +712,17 @@ typedef struct {
i32 n_vectors[FRAME_QUEUE_MAX_NELTS];
} frame_queue_trace_t;
-typedef struct {
+typedef struct
+{
u64 count[FRAME_QUEUE_MAX_NELTS];
} frame_queue_nelt_counter_t;
#endif /* included_vlib_node_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */