46 s =
format (s,
"VNET_POLICER: sw_if_index %d policer_index %d next %d",
51 #define foreach_vnet_policer_error \ 52 _(TRANSMIT, "Packets Transmitted") \ 53 _(DROP, "Packets Dropped") 57 #define _(sym,str) VNET_POLICER_ERROR_##sym, 64 #define _(sym,string) string, 74 u32 n_left_from, *from, *to_next;
77 u64 time_in_policer_periods;
80 time_in_policer_periods =
87 while (n_left_from > 0)
93 while (n_left_from >= 4 && n_left_to_next >= 2)
98 u32 sw_if_index0, sw_if_index1;
114 to_next[0] = bi0 = from[0];
115 to_next[1] = bi1 = from[1];
146 pi0 = (pi0 != ~0) ? pi0 :
149 pi1 = (pi1 != ~0) ? pi1 :
182 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
189 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
200 to_next, n_left_to_next,
201 bi0, bi1, next0, next1);
204 while (n_left_from > 0 && n_left_to_next > 0)
234 pi0 = (pi0 != ~0) ? pi0 :
252 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
263 to_next, n_left_to_next,
271 VNET_POLICER_ERROR_TRANSMIT, transmitted);
283 #ifndef CLIB_MARCH_VARIANT 311 .name =
"policer-by-sw-if-index",
312 .vector_size =
sizeof (
u32),
330 #ifndef CLIB_MARCH_VARIANT 344 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
361 policer[0] =
template[0];
405 else if (
unformat (line_input,
"show"))
407 else if (
unformat (line_input,
"policer %s", &config_name))
409 else if (
unformat (line_input,
"del"))
431 if (is_add && config_name == 0)
446 (0,
"WARNING: vnet_vnet_policer_add_del returned %d", rv);
458 .path =
"test policer",
460 "intfc <intfc> policer <policer-config-name> [del]",
485 s =
format (s,
"POLICER_CLASSIFY: sw_if_index %d next %d table %d offset %d" 492 #define foreach_policer_classify_error \ 493 _(MISS, "Policer classify misses") \ 494 _(HIT, "Policer classify hits") \ 495 _(CHAIN_HIT, "Policer classify hits after chain walk") \ 496 _(DROP, "Policer classify action drop") 500 #define _(sym,str) POLICER_CLASSIFY_ERROR_##sym, 507 #define _(sym,string) string, 518 u32 n_left_from, *from, *to_next;
527 u64 time_in_policer_periods;
529 time_in_policer_periods =
538 while (n_left_from > 2)
543 u32 sw_if_index0, sw_if_index1;
544 u32 table_index0, table_index1;
590 vnet_buffer (b0)->l2_classify.table_index = table_index0;
592 vnet_buffer (b1)->l2_classify.table_index = table_index1;
598 while (n_left_from > 0)
619 vnet_buffer (b0)->l2_classify.table_index = table_index0;
630 while (n_left_from > 0)
637 while (n_left_from > 0 && n_left_to_next > 0)
644 vnet_classify_entry_t *e0;
657 table_index1 =
vnet_buffer (p1)->l2_classify.table_index;
677 table_index0 =
vnet_buffer (b0)->l2_classify.table_index;
685 L2INPUT_FEAT_POLICER_CLAS);
705 time_in_policer_periods,
710 b0->
error = node->
errors[POLICER_CLASSIFY_ERROR_DROP];
739 time_in_policer_periods,
745 node->
errors[POLICER_CLASSIFY_ERROR_DROP];
755 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
768 n_left_to_next, bi0, next0);
775 POLICER_CLASSIFY_ERROR_MISS, misses);
777 POLICER_CLASSIFY_ERROR_HIT, hits);
779 POLICER_CLASSIFY_ERROR_CHAIN_HIT, chain_hits);
794 .name =
"ip4-policer-classify",
795 .vector_size =
sizeof (
u32),
816 .name =
"ip6-policer-classify",
817 .vector_size =
sizeof (
u32),
837 .name =
"l2-policer-classify",
838 .vector_size =
sizeof (
u32),
849 #ifndef CLIB_MARCH_VARIANT u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
policer_classify_main_t policer_classify_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.
#define foreach_vnet_policer_error
#define POLICER_TICKS_PER_PERIOD_SHIFT
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vlib_node_registration_t ip6_policer_classify_node
(constructor) VLIB_REGISTER_NODE (ip6_policer_classify_node)
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 f64 vlib_time_now(vlib_main_t *vm)
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)
static u64 clib_cpu_time_now(void)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
u8 * format_policer_instance(u8 *s, va_list *va)
static u32 vnet_l2_feature_next(vlib_buffer_t *b, u32 *next_nodes, u32 feat_bit)
Return the graph node index for the feature corresponding to the next set bit after clearing the curr...
policer_classify_table_id_t
vnet_policer_main_t vnet_policer_main
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)
#define VLIB_INIT_FUNCTION(x)
static char * vnet_policer_error_strings[]
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
u32 * classify_table_index_by_sw_if_index[POLICER_CLASSIFY_N_TABLES]
static clib_error_t * policer_classify_init(vlib_main_t *vm)
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vnet_config_main_t * vnet_config_main[POLICER_CLASSIFY_N_TABLES]
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
static uword policer_classify_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, policer_classify_table_id_t tid)
u32 node_index
Node index.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
policer_read_response_type_st * policers
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#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).
void vnet_policer_node_funcs_reference(void)
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
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static char * policer_classify_error_strings[]
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
u32 feat_next_node_index[32]
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
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.
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
#define foreach_policer_classify_error
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define pool_put_index(p, i)
Free pool element with given index.
static_always_inline u8 vnet_policer_police(vlib_main_t *vm, vlib_buffer_t *b, u32 policer_index, u64 time_in_policer_periods, policer_result_e packet_color)
vnet_classify_main_t vnet_classify_main
policer_classify_next_index_t
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vnet_classify_main_t * vnet_classify_main
vlib_node_registration_t ip4_policer_classify_node
(constructor) VLIB_REGISTER_NODE (ip4_policer_classify_node)
static clib_error_t * test_policer_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define hash_get_mem(h, key)
policer_read_response_type_st * policer_templates
vlib_node_registration_t l2_policer_classify_node
(constructor) VLIB_REGISTER_NODE (l2_policer_classify_node)
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
static u8 * format_policer_trace(u8 *s, va_list *args)
static u8 * format_policer_classify_trace(u8 *s, va_list *args)