31 #ifndef CLIB_MARCH_VARIANT 43 "simulated network loss" :
"no space in ring");
45 s =
format (s,
"NSIM: tx time %.6f sw_if_index %d",
54 #define foreach_nsim_error \ 55 _(BUFFERED, "Packets buffered") \ 56 _(DROPPED, "Packets dropped due to lack of space") \ 57 _(LOSS, "Network loss simulation drop packets") 61 #define _(sym,str) NSIM_ERROR_##sym, 67 #ifndef CLIB_MARCH_VARIANT 69 #define _(sym,string) string, 87 u32 n_left_from, *from;
88 u32 *to_next, n_left_to_next;
98 u32 no_buffer_error = node->
errors[NSIM_ERROR_DROPPED];
99 u32 loss_error = node->
errors[NSIM_ERROR_LOSS];
113 while (n_left_from >= 8)
120 memset (&is_drop, 0,
sizeof (is_drop));
133 b[0]->
error = loss_error;
138 b[1]->
error = loss_error;
143 b[2]->
error = loss_error;
148 b[3]->
error = loss_error;
163 if (is_cross_connect)
185 if (b[1]->
flags & VLIB_BUFFER_IS_TRACED)
205 if (is_cross_connect)
227 if (b[2]->
flags & VLIB_BUFFER_IS_TRACED)
246 if (is_cross_connect)
268 if (b[2]->
flags & VLIB_BUFFER_IS_TRACED)
287 if (is_cross_connect)
309 if (b[3]->
flags & VLIB_BUFFER_IS_TRACED)
336 while (n_left_from > 0)
349 b[0]->
error = loss_error;
363 if (is_cross_connect)
384 b[0]->
error = no_buffer_error;
391 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
413 u32 n_left_to_drop = drop - drops;
416 while (n_left_to_drop > 0)
421 this_copy_size =
clib_min (n_left_to_drop, n_left_to_next);
423 n_left_to_next -= this_copy_size;
425 drop += this_copy_size;
426 n_left_to_drop -= this_copy_size;
430 NSIM_ERROR_BUFFERED, buffered);
446 #ifndef CLIB_MARCH_VARIANT 450 .vector_size =
sizeof (
u32),
480 #ifndef CLIB_MARCH_VARIANT 483 .name =
"nsim-output-feature",
484 .vector_size =
sizeof (
u32),
u32 * output_next_index_by_sw_if_index
#define clib_memcpy_fast(a, b, c)
static f64 vlib_time_now(vlib_main_t *vm)
#define VLIB_NODE_FN(node)
vlib_node_registration_t nsim_node
(constructor) VLIB_REGISTER_NODE (nsim_node)
vlib_error_t * errors
Vector of errors for this node.
static u32 slow_path(dslite_main_t *dm, dslite_session_key_t *in2out_key, dslite_session_t **sp, u32 next, u8 *error, u32 thread_index)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static char * nsim_error_strings[]
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define foreach_nsim_error
u32 node_index
Node index.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
vlib_node_registration_t nsim_feature_node
(constructor) VLIB_REGISTER_NODE (nsim_feature_node)
#define VLIB_REGISTER_NODE(x,...)
nsim_wheel_entry_t * entries
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_main_t vlib_node_runtime_t * node
static uword nsim_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_trace, int is_cross_connect)
nsim_wheel_t ** wheel_by_thread
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
static u8 * format_nsim_trace(u8 *s, va_list *args)