30 #ifndef CLIB_MARCH_VARIANT 42 "simulated network loss" :
"no space in ring");
44 s =
format (s,
"NSIM: tx time %.6f sw_if_index %d",
53 #define foreach_nsim_error \ 54 _(BUFFERED, "Packets buffered") \ 55 _(DROPPED, "Packets dropped due to lack of space") \ 56 _(LOSS, "Network loss simulation drop packets") \ 57 _(REORDERED, "Packets reordered") 61 #define _(sym,str) NSIM_ERROR_##sym, 67 #ifndef CLIB_MARCH_VARIANT 69 #define _(sym,string) string, 87 memset (ctx->
action, 0, n_actions * sizeof (ctx->
action[0]));
91 for (i = 0; i < n_actions; i++)
93 ctx->
action[
i] |= NSIM_ACTION_DROP;
98 for (i = 0; i < n_actions; i++)
100 ctx->
action[
i] |= NSIM_ACTION_REORDER;
108 if (b->
flags & VLIB_BUFFER_IS_TRACED)
120 u32 * next,
u8 is_cross_connect)
122 if (is_cross_connect)
190 int is_cross_connect)
212 ctx.
reord = reorders;
219 while (n_left_from >= 8)
230 is_cross_connect, is_trace);
232 is_cross_connect, is_trace);
234 is_cross_connect, is_trace);
236 is_cross_connect, is_trace);
245 while (n_left_from > 0)
249 || (ctx.
action[0] & NSIM_ACTION_DROP)
250 || (ctx.
action[0] & NSIM_ACTION_REORDER)))
253 is_cross_connect, is_trace);
257 ctx.
drop[0] = from[0];
271 u32 n_left_to_drop = ctx.
drop - drops;
276 n_left_to_drop - ctx.
n_loss);
280 u32 n_reordered = ctx.
reord - reorders;
303 #ifndef CLIB_MARCH_VARIANT 307 .vector_size =
sizeof (
u32),
337 #ifndef CLIB_MARCH_VARIANT 340 .name =
"nsim-output-feature",
341 .vector_size =
sizeof (
u32),
vnet_config_main_t config_main
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
u32 * output_next_index_by_sw_if_index
static char * nsim_error_strings[]
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static f64 vlib_time_now(vlib_main_t *vm)
vlib_node_registration_t nsim_node
(constructor) VLIB_REGISTER_NODE (nsim_node)
#define VLIB_NODE_FN(node)
vnet_feature_config_main_t * fcm
vlib_node_registration_t nsim_feature_node
(constructor) VLIB_REGISTER_NODE (nsim_feature_node)
#define foreach_nsim_error
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)
description fragment has unexpected format
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vl_api_fib_path_type_t type
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
u32 node_index
Node index.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
sll srl srl sll sra u16x4 i
nsim_wheel_entry_t * entries
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
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 u8 * format_nsim_trace(u8 *s, va_list *args)
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
struct _vlib_node_registration vlib_node_registration_t
static void nsim_set_actions(nsim_main_t *nsm, vlib_buffer_t **b, nsim_node_ctx_t *ctx, u32 n_actions)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
vl_api_flow_action_t actions
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void nsim_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, nsim_node_ctx_t *ctx, u32 is_drop)
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 void nsim_dispatch_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, nsim_main_t *nsm, nsim_wheel_t *wp, vlib_buffer_t *b, u32 bi, nsim_node_ctx_t *ctx, u8 is_cross_connect, u8 is_trace)
static void nsim_buffer_fwd_lookup(nsim_main_t *nsm, vlib_buffer_t *b, u32 *next, u8 is_cross_connect)
static_always_inline vnet_feature_config_main_t * vnet_feature_get_config_main(u16 arc)
vl_api_interface_index_t sw_if_index