37 s =
format (s,
"VNET_POLICER: sw_if_index %d policer_index %d next %d",
42 #define foreach_vnet_policer_error \ 43 _(TRANSMIT, "Packets Transmitted") \ 44 _(DROP, "Packets Dropped") 47 #define _(sym,str) VNET_POLICER_ERROR_##sym, 54 #define _(sym,string) string, 65 u32 n_left_from, * from, * to_next;
68 u64 time_in_policer_periods;
71 time_in_policer_periods =
78 while (n_left_from > 0)
83 to_next, n_left_to_next);
85 while (n_left_from >= 4 && n_left_to_next >= 2)
90 u32 sw_if_index0, sw_if_index1;
108 to_next[0] = bi0 = from[0];
109 to_next[1] = bi1 = from[1];
140 pi0 = (pi0 != ~0) ? pi0 :
143 pi1 = (pi1 != ~0) ? pi1 :
151 time_in_policer_periods);
157 time_in_policer_periods);
196 to_next, n_left_to_next,
197 bi0, bi1, next0, next1);
200 while (n_left_from > 0 && n_left_to_next > 0)
232 pi0 = (pi0 != ~0) ? pi0 :
240 time_in_policer_periods);
264 to_next, n_left_to_next,
272 VNET_POLICER_ERROR_TRANSMIT,
310 .name =
"policer-by-sw-if-index",
311 .vector_size =
sizeof (
u32),
341 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
360 policer[0] =
template[0];
390 u8 * config_name = 0;
404 else if (
unformat (line_input,
"show"))
406 else if (
unformat (line_input,
"policer %s", &config_name))
408 else if (
unformat (line_input,
"del"))
426 if (is_add && config_name == 0)
440 (0,
"WARNING: vnet_vnet_policer_add_del returned %d", rv);
447 .path =
"test policer",
449 "intfc <intfc> policer <policer-config-name> [del]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
#define foreach_vnet_policer_error
#define POLICER_TICKS_PER_PERIOD_SHIFT
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
uword * policer_config_by_name
int vnet_hw_interface_rx_redirect_to_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
static uword vnet_policer_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, vnet_policer_index_t which)
int test_policer_add_del(u32 rx_sw_if_index, u8 *config_name, int is_add)
unformat_function_t unformat_vnet_sw_interface
u8 * format_policer_instance(u8 *s, va_list *va)
vlib_node_registration_t policer_by_sw_if_index_node
(constructor) VLIB_REGISTER_NODE (policer_by_sw_if_index_node)
uword vnet_policer_by_opaque(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static char * vnet_policer_error_strings[]
static policer_result_e vnet_police_packet(policer_read_response_type_st *policer, uint32_t packet_length, policer_result_e packet_color, uint64_t time)
always_inline uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define pool_elt_at_index(p, i)
always_inline void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
policer_read_response_type_st * policers
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void vnet_policer_node_funcs_reference(void)
uword vnet_policer_by_sw_if_index(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
uword vnet_policer_by_either(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 * policer_index_by_sw_if_index
#define pool_get_aligned(P, E, A)
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
#define pool_put_index(p, i)
#define VLIB_NODE_FLAG_TRACE
#define VLIB_BUFFER_IS_TRACED
static clib_error_t * test_policer_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define hash_get_mem(h, key)
policer_read_response_type_st * policer_templates
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline u64 clib_cpu_time_now(void)
vnet_policer_main_t vnet_policer_main
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u8 * format_policer_trace(u8 *s, va_list *args)