*magic = VLIB_FRAME_MAGIC;
}
- f->flags = VLIB_FRAME_IS_ALLOCATED | frame_flags;
+ f->frame_flags = VLIB_FRAME_IS_ALLOCATED | frame_flags;
f->n_vectors = 0;
f->scalar_size = scalar_size;
f->vector_size = vector_size;
vec_add2 (vm->node_main.pending_frames, p, 1);
- f->flags |= VLIB_FRAME_PENDING;
+ f->frame_flags |= VLIB_FRAME_PENDING;
p->frame_index = vlib_frame_index (vm, f);
p->node_runtime_index = to_node->runtime_index;
p->next_frame_index = VLIB_PENDING_FRAME_NO_NEXT_FRAME;
vlib_frame_size_t *fs;
u32 frame_index;
- ASSERT (f->flags & VLIB_FRAME_IS_ALLOCATED);
+ ASSERT (f->frame_flags & VLIB_FRAME_IS_ALLOCATED);
node = vlib_get_node (vm, r->node_index);
fs = get_frame_size_info (nm, node->scalar_size, node->vector_size);
frame_index = vlib_frame_index (vm, f);
- ASSERT (f->flags & VLIB_FRAME_IS_ALLOCATED);
+ ASSERT (f->frame_flags & VLIB_FRAME_IS_ALLOCATED);
/* No next frames may point to freed frame. */
if (CLIB_DEBUG > 0)
ASSERT (nf->frame_index != frame_index);
}
- f->flags &= ~VLIB_FRAME_IS_ALLOCATED;
+ f->frame_flags &= ~VLIB_FRAME_IS_ALLOCATED;
vec_add1 (fs->free_frame_indices, frame_index);
ASSERT (fs->n_alloc_frames > 0);
/* Has frame been removed from pending vector (e.g. finished dispatching)?
If so we can reuse frame. */
- if ((nf->flags & VLIB_FRAME_PENDING) && !(f->flags & VLIB_FRAME_PENDING))
+ if ((nf->flags & VLIB_FRAME_PENDING)
+ && !(f->frame_flags & VLIB_FRAME_PENDING))
{
nf->flags &= ~VLIB_FRAME_PENDING;
f->n_vectors = 0;
if (!(nf->flags & VLIB_FRAME_NO_FREE_AFTER_DISPATCH))
{
vlib_frame_t *f_old = vlib_get_frame (vm, nf->frame_index);
- f_old->flags |= VLIB_FRAME_FREE_AFTER_DISPATCH;
+ f_old->frame_flags |= VLIB_FRAME_FREE_AFTER_DISPATCH;
}
/* Allocate new frame to replace full one. */
vlib_frame_t *f;
u32 n_vectors_in_frame;
- if (vm->buffer_main->callbacks_registered == 0 && CLIB_DEBUG > 0)
+ if (buffer_main.callbacks_registered == 0 && CLIB_DEBUG > 0)
vlib_put_next_frame_validate (vm, r, next_index, n_vectors_left);
nf = vlib_node_runtime_get_next_frame (vm, r, next_index);
r->cached_next_index = next_index;
- if (!(f->flags & VLIB_FRAME_PENDING))
+ if (!(f->frame_flags & VLIB_FRAME_PENDING))
{
__attribute__ ((unused)) vlib_node_t *node;
vlib_node_t *next_node;
p->node_runtime_index = nf->node_runtime_index;
p->next_frame_index = nf - nm->next_frames;
nf->flags |= VLIB_FRAME_PENDING;
- f->flags |= VLIB_FRAME_PENDING;
+ f->frame_flags |= VLIB_FRAME_PENDING;
/*
* If we're going to dispatch this frame on another thread,
{
/* No next frame: so use dummy on stack. */
nf = &nf_dummy;
- nf->flags = f->flags & VLIB_NODE_FLAG_TRACE;
+ nf->flags = f->frame_flags & VLIB_NODE_FLAG_TRACE;
nf->frame_index = ~p->frame_index;
}
else
nf = vec_elt_at_index (nm->next_frames, p->next_frame_index);
- ASSERT (f->flags & VLIB_FRAME_IS_ALLOCATED);
+ ASSERT (f->frame_flags & VLIB_FRAME_IS_ALLOCATED);
/* Force allocation of new frame while current frame is being
dispatched. */
}
/* Frame must be pending. */
- ASSERT (f->flags & VLIB_FRAME_PENDING);
+ ASSERT (f->frame_flags & VLIB_FRAME_PENDING);
ASSERT (f->n_vectors > 0);
/* Copy trace flag from next frame to node.
VLIB_NODE_STATE_POLLING,
f, last_time_stamp);
- f->flags &= ~VLIB_FRAME_PENDING;
+ f->frame_flags &= ~VLIB_FRAME_PENDING;
/* Frame is ready to be used again, so restore it. */
if (restore_frame_index != ~0)
* longer part of the queue for that node and hence it cannot be
* it's overspill.
*/
- ASSERT (!(f->flags & VLIB_FRAME_FREE_AFTER_DISPATCH));
+ ASSERT (!(f->frame_flags & VLIB_FRAME_FREE_AFTER_DISPATCH));
/*
* NB: dispatching node n can result in the creation and scheduling
}
else
{
- if (f->flags & VLIB_FRAME_FREE_AFTER_DISPATCH)
+ if (f->frame_flags & VLIB_FRAME_FREE_AFTER_DISPATCH)
{
ASSERT (!(n->flags & VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH));
vlib_frame_free (vm, n, f);
vlib_node_main_t *nm = &vm->node_main;
vlib_node_runtime_t *node_runtime = &p->node_runtime;
vlib_node_t *node = vlib_get_node (vm, node_runtime->node_index);
+ u32 old_process_index;
u64 t;
uword n_vectors, is_suspend;
f ? f->n_vectors : 0, /* is_after */ 0);
/* Save away current process for suspend. */
+ old_process_index = nm->current_process_index;
nm->current_process_index = node->runtime_index;
n_vectors = vlib_process_startup (vm, p, f);
- nm->current_process_index = ~0;
+ nm->current_process_index = old_process_index;
ASSERT (n_vectors != VLIB_PROCESS_RETURN_LONGJMP_RETURN);
is_suspend = n_vectors == VLIB_PROCESS_RETURN_LONGJMP_SUSPEND;
}
}
}
+ /* Input nodes may have added work to the pending vector.
+ Process pending vector until there is nothing left.
+ All pending vectors will be processed from input -> output. */
+ for (i = 0; i < _vec_len (nm->pending_frames); i++)
+ cpu_time_now = dispatch_pending_node (vm, i, cpu_time_now);
+ /* Reset pending vector for next iteration. */
+ _vec_len (nm->pending_frames) = 0;
if (is_main)
{
{
uword i;
- processes_timing_wheel_data:
for (i = 0; i < _vec_len (nm->data_from_advancing_timing_wheel);
i++)
{
_vec_len (nm->data_from_advancing_timing_wheel) = 0;
}
}
-
- /* Input nodes may have added work to the pending vector.
- Process pending vector until there is nothing left.
- All pending vectors will be processed from input -> output. */
- for (i = 0; i < _vec_len (nm->pending_frames); i++)
- cpu_time_now = dispatch_pending_node (vm, i, cpu_time_now);
- /* Reset pending vector for next iteration. */
- _vec_len (nm->pending_frames) = 0;
-
- /* Pending internal nodes may resume processes. */
- if (is_main && _vec_len (nm->data_from_advancing_timing_wheel) > 0)
- goto processes_timing_wheel_data;
-
vlib_increment_main_loop_counter (vm);
/* Record time stamp in case there are no enabled nodes and above
{
}
+#define foreach_weak_reference_stub \
+_(vlib_map_stat_segment_init) \
+_(vpe_api_init) \
+_(vlibmemory_init) \
+_(map_api_segment_init)
+
+#define _(name) \
+clib_error_t *name (vlib_main_t *vm) __attribute__((weak)); \
+clib_error_t *name (vlib_main_t *vm) { return 0; }
+foreach_weak_reference_stub;
+#undef _
+
/* Main function. */
int
vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
goto done;
}
+ if ((error = vlib_map_stat_segment_init (vm)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
/* Register static nodes so that init functions may use them. */
vlib_register_all_static_nodes (vm);
goto done;
}
+ /* Direct call / weak reference, for vlib standalone use-cases */
+ if ((error = vpe_api_init (vm)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
+ if ((error = vlibmemory_init (vm)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
+ if ((error = map_api_segment_init (vm)))
+ {
+ clib_error_report (error);
+ goto done;
+ }
+
/* See unix/main.c; most likely already set up */
if (vm->init_functions_called == 0)
vm->init_functions_called = hash_create (0, /* value bytes */ 0);
goto done;
/* Create default buffer free list. */
- vlib_buffer_get_or_create_free_list (vm,
- VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES,
- "default");
+ vlib_buffer_create_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES,
+ "default");
nm->timing_wheel = clib_mem_alloc_aligned (sizeof (TWT (tw_timer_wheel)),
CLIB_CACHE_LINE_BYTES);