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") \ 58 _(REORDERED, "Packets reordered") 62 #define _(sym,str) NSIM_ERROR_##sym, 68 #ifndef CLIB_MARCH_VARIANT 70 #define _(sym,string) string, 88 memset (ctx->
action, 0, n_actions * sizeof (ctx->
action[0]));
92 for (i = 0; i < n_actions; i++)
94 ctx->
action[
i] |= NSIM_ACTION_DROP;
99 for (i = 0; i < n_actions; i++)
101 ctx->
action[
i] |= NSIM_ACTION_REORDER;
109 if (b->
flags & VLIB_BUFFER_IS_TRACED)
121 u32 * next,
u8 is_cross_connect)
123 if (is_cross_connect)
191 int is_cross_connect)
213 ctx.
reord = reorders;
220 while (n_left_from >= 8)
231 is_cross_connect, is_trace);
233 is_cross_connect, is_trace);
235 is_cross_connect, is_trace);
237 is_cross_connect, is_trace);
246 while (n_left_from > 0)
250 || (ctx.
action[0] & NSIM_ACTION_DROP)
251 || (ctx.
action[0] & NSIM_ACTION_REORDER)))
254 is_cross_connect, is_trace);
258 ctx.
drop[0] = from[0];
272 u32 n_left_to_drop = ctx.
drop - drops;
277 n_left_to_drop - ctx.
n_loss);
281 u32 n_reordered = ctx.
reord - reorders;
304 #ifndef CLIB_MARCH_VARIANT 308 .vector_size =
sizeof (
u32),
338 #ifndef CLIB_MARCH_VARIANT 341 .name =
"nsim-output-feature",
342 .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)
#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