2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/policer/policer.h>
21 #include <vnet/policer/police_inlines.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/classify/policer_classify.h>
24 #include <vnet/classify/vnet_classify.h>
25 #include <vnet/l2/feat_bitmap.h>
26 #include <vnet/l2/l2_input.h>
29 /* Dispatch functions meant to be instantiated elsewhere */
36 } vnet_policer_trace_t;
38 /* packet trace format function */
40 format_policer_trace (u8 * s, va_list * args)
42 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
43 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
44 vnet_policer_trace_t *t = va_arg (*args, vnet_policer_trace_t *);
46 s = format (s, "VNET_POLICER: sw_if_index %d policer_index %d next %d",
47 t->sw_if_index, t->policer_index, t->next_index);
51 #define foreach_vnet_policer_error \
52 _(TRANSMIT, "Packets Transmitted") \
53 _(DROP, "Packets Dropped")
57 #define _(sym,str) VNET_POLICER_ERROR_##sym,
58 foreach_vnet_policer_error
61 } vnet_policer_error_t;
63 static char *vnet_policer_error_strings[] = {
64 #define _(sym,string) string,
65 foreach_vnet_policer_error
70 vnet_policer_inline (vlib_main_t * vm,
71 vlib_node_runtime_t * node,
72 vlib_frame_t * frame, vnet_policer_index_t which)
74 u32 n_left_from, *from, *to_next;
75 vnet_policer_next_t next_index;
76 vnet_policer_main_t *pm = &vnet_policer_main;
77 u64 time_in_policer_periods;
80 time_in_policer_periods =
81 clib_cpu_time_now () >> POLICER_TICKS_PER_PERIOD_SHIFT;
83 from = vlib_frame_vector_args (frame);
84 n_left_from = frame->n_vectors;
85 next_index = node->cached_next_index;
87 while (n_left_from > 0)
91 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
93 while (n_left_from >= 4 && n_left_to_next >= 2)
96 vlib_buffer_t *b0, *b1;
98 u32 sw_if_index0, sw_if_index1;
102 /* Prefetch next iteration. */
104 vlib_buffer_t *b2, *b3;
106 b2 = vlib_get_buffer (vm, from[2]);
107 b3 = vlib_get_buffer (vm, from[3]);
109 vlib_prefetch_buffer_header (b2, LOAD);
110 vlib_prefetch_buffer_header (b3, LOAD);
113 /* speculatively enqueue b0 and b1 to the current next frame */
114 to_next[0] = bi0 = from[0];
115 to_next[1] = bi1 = from[1];
121 b0 = vlib_get_buffer (vm, bi0);
122 b1 = vlib_get_buffer (vm, bi1);
124 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
125 next0 = VNET_POLICER_NEXT_TRANSMIT;
127 sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
128 next1 = VNET_POLICER_NEXT_TRANSMIT;
131 if (which == VNET_POLICER_INDEX_BY_SW_IF_INDEX)
133 pi0 = pm->policer_index_by_sw_if_index[sw_if_index0];
134 pi1 = pm->policer_index_by_sw_if_index[sw_if_index1];
137 if (which == VNET_POLICER_INDEX_BY_OPAQUE)
139 pi0 = vnet_buffer (b0)->policer.index;
140 pi1 = vnet_buffer (b1)->policer.index;
143 if (which == VNET_POLICER_INDEX_BY_EITHER)
145 pi0 = vnet_buffer (b0)->policer.index;
146 pi0 = (pi0 != ~0) ? pi0 :
147 pm->policer_index_by_sw_if_index[sw_if_index0];
148 pi1 = vnet_buffer (b1)->policer.index;
149 pi1 = (pi1 != ~0) ? pi1 :
150 pm->policer_index_by_sw_if_index[sw_if_index1];
153 act0 = vnet_policer_police (vm, b0, pi0, time_in_policer_periods,
154 POLICE_CONFORM /* no chaining */ );
156 act1 = vnet_policer_police (vm, b1, pi1, time_in_policer_periods,
157 POLICE_CONFORM /* no chaining */ );
159 if (PREDICT_FALSE (act0 == SSE2_QOS_ACTION_DROP)) /* drop action */
161 next0 = VNET_POLICER_NEXT_DROP;
162 b0->error = node->errors[VNET_POLICER_ERROR_DROP];
164 else /* transmit or mark-and-transmit action */
169 if (PREDICT_FALSE (act1 == SSE2_QOS_ACTION_DROP)) /* drop action */
171 next1 = VNET_POLICER_NEXT_DROP;
172 b1->error = node->errors[VNET_POLICER_ERROR_DROP];
174 else /* transmit or mark-and-transmit action */
180 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
182 if (b0->flags & VLIB_BUFFER_IS_TRACED)
184 vnet_policer_trace_t *t =
185 vlib_add_trace (vm, node, b0, sizeof (*t));
186 t->sw_if_index = sw_if_index0;
187 t->next_index = next0;
189 if (b1->flags & VLIB_BUFFER_IS_TRACED)
191 vnet_policer_trace_t *t =
192 vlib_add_trace (vm, node, b1, sizeof (*t));
193 t->sw_if_index = sw_if_index1;
194 t->next_index = next1;
198 /* verify speculative enqueues, maybe switch current next frame */
199 vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
200 to_next, n_left_to_next,
201 bi0, bi1, next0, next1);
204 while (n_left_from > 0 && n_left_to_next > 0)
220 b0 = vlib_get_buffer (vm, bi0);
222 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
223 next0 = VNET_POLICER_NEXT_TRANSMIT;
225 if (which == VNET_POLICER_INDEX_BY_SW_IF_INDEX)
226 pi0 = pm->policer_index_by_sw_if_index[sw_if_index0];
228 if (which == VNET_POLICER_INDEX_BY_OPAQUE)
229 pi0 = vnet_buffer (b0)->policer.index;
231 if (which == VNET_POLICER_INDEX_BY_EITHER)
233 pi0 = vnet_buffer (b0)->policer.index;
234 pi0 = (pi0 != ~0) ? pi0 :
235 pm->policer_index_by_sw_if_index[sw_if_index0];
238 act0 = vnet_policer_police (vm, b0, pi0, time_in_policer_periods,
239 POLICE_CONFORM /* no chaining */ );
241 if (PREDICT_FALSE (act0 == SSE2_QOS_ACTION_DROP)) /* drop action */
243 next0 = VNET_POLICER_NEXT_DROP;
244 b0->error = node->errors[VNET_POLICER_ERROR_DROP];
246 else /* transmit or mark-and-transmit action */
251 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
252 && (b0->flags & VLIB_BUFFER_IS_TRACED)))
254 vnet_policer_trace_t *t =
255 vlib_add_trace (vm, node, b0, sizeof (*t));
256 t->sw_if_index = sw_if_index0;
257 t->next_index = next0;
258 t->policer_index = pi0;
261 /* verify speculative enqueue, maybe switch current next frame */
262 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
263 to_next, n_left_to_next,
267 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
270 vlib_node_increment_counter (vm, node->node_index,
271 VNET_POLICER_ERROR_TRANSMIT, transmitted);
272 return frame->n_vectors;
276 vnet_policer_by_sw_if_index (vlib_main_t * vm,
277 vlib_node_runtime_t * node, vlib_frame_t * frame)
279 return vnet_policer_inline (vm, node, frame,
280 VNET_POLICER_INDEX_BY_SW_IF_INDEX);
284 vnet_policer_by_opaque (vlib_main_t * vm,
285 vlib_node_runtime_t * node, vlib_frame_t * frame)
287 return vnet_policer_inline (vm, node, frame, VNET_POLICER_INDEX_BY_OPAQUE);
291 vnet_policer_by_either (vlib_main_t * vm,
292 vlib_node_runtime_t * node, vlib_frame_t * frame)
294 return vnet_policer_inline (vm, node, frame, VNET_POLICER_INDEX_BY_EITHER);
298 vnet_policer_node_funcs_reference (void)
308 VLIB_REGISTER_NODE (policer_by_sw_if_index_node, static) = {
309 .function = vnet_policer_by_sw_if_index,
310 .name = "policer-by-sw-if-index",
311 .vector_size = sizeof (u32),
312 .format_trace = format_policer_trace,
313 .type = VLIB_NODE_TYPE_INTERNAL,
315 .n_errors = ARRAY_LEN(vnet_policer_error_strings),
316 .error_strings = vnet_policer_error_strings,
318 .n_next_nodes = VNET_POLICER_N_NEXT,
320 /* edit / add dispositions here */
322 [VNET_POLICER_NEXT_TRANSMIT] = "ethernet-input",
323 [VNET_POLICER_NEXT_DROP] = "error-drop",
327 VLIB_NODE_FUNCTION_MULTIARCH (policer_by_sw_if_index_node,
328 vnet_policer_by_sw_if_index);
333 test_policer_add_del (u32 rx_sw_if_index, u8 * config_name, int is_add)
335 vnet_policer_main_t *pm = &vnet_policer_main;
336 policer_read_response_type_st *template;
337 policer_read_response_type_st *policer;
338 vnet_hw_interface_t *rxhi;
341 rxhi = vnet_get_sup_hw_interface (pm->vnet_main, rx_sw_if_index);
343 /* Make sure caller didn't pass a vlan subif, etc. */
344 if (rxhi->sw_if_index != rx_sw_if_index)
345 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
350 p = hash_get_mem (pm->policer_config_by_name, config_name);
355 template = pool_elt_at_index (pm->policer_templates, p[0]);
357 vnet_hw_interface_rx_redirect_to_node
358 (pm->vnet_main, rxhi->hw_if_index, policer_by_sw_if_index_node.index);
360 pool_get_aligned (pm->policers, policer, CLIB_CACHE_LINE_BYTES);
362 policer[0] = template[0];
364 vec_validate (pm->policer_index_by_sw_if_index, rx_sw_if_index);
365 pm->policer_index_by_sw_if_index[rx_sw_if_index]
366 = policer - pm->policers;
371 vnet_hw_interface_rx_redirect_to_node (pm->vnet_main,
375 pi = pm->policer_index_by_sw_if_index[rx_sw_if_index];
376 pm->policer_index_by_sw_if_index[rx_sw_if_index] = ~0;
377 pool_put_index (pm->policers, pi);
383 static clib_error_t *
384 test_policer_command_fn (vlib_main_t * vm,
385 unformat_input_t * input, vlib_cli_command_t * cmd)
387 vnet_policer_main_t *pm = &vnet_policer_main;
388 unformat_input_t _line_input, *line_input = &_line_input;
395 clib_error_t *error = NULL;
397 /* Get a line of input. */
398 if (!unformat_user (input, unformat_line_input, line_input))
401 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
403 if (unformat (line_input, "intfc %U", unformat_vnet_sw_interface,
404 pm->vnet_main, &rx_sw_if_index))
406 else if (unformat (line_input, "show"))
408 else if (unformat (line_input, "policer %s", &config_name))
410 else if (unformat (line_input, "del"))
418 error = clib_error_return (0, "interface not set");
424 u32 pi = pm->policer_index_by_sw_if_index[rx_sw_if_index];
425 policer_read_response_type_st *policer;
426 policer = pool_elt_at_index (pm->policers, pi);
428 vlib_cli_output (vm, "%U", format_policer_instance, policer);
432 if (is_add && config_name == 0)
434 error = clib_error_return (0, "policer config name required");
438 rv = test_policer_add_del (rx_sw_if_index, config_name, is_add);
446 error = clib_error_return
447 (0, "WARNING: vnet_vnet_policer_add_del returned %d", rv);
452 unformat_free (line_input);
458 VLIB_CLI_COMMAND (test_patch_command, static) = {
459 .path = "test policer",
461 "intfc <intfc> policer <policer-config-name> [del]",
462 .function = test_policer_command_fn,
466 #endif /* TEST_CODE */
476 } policer_classify_trace_t;
479 format_policer_classify_trace (u8 * s, va_list * args)
481 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
482 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
483 policer_classify_trace_t *t = va_arg (*args, policer_classify_trace_t *);
485 s = format (s, "POLICER_CLASSIFY: sw_if_index %d next %d table %d offset %d"
487 t->sw_if_index, t->next_index, t->table_index, t->offset,
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,
501 foreach_policer_classify_error
503 POLICER_CLASSIFY_N_ERROR,
504 } policer_classify_error_t;
506 static char *policer_classify_error_strings[] = {
507 #define _(sym,string) string,
508 foreach_policer_classify_error
513 policer_classify_inline (vlib_main_t * vm,
514 vlib_node_runtime_t * node,
515 vlib_frame_t * frame,
516 policer_classify_table_id_t tid)
518 u32 n_left_from, *from, *to_next;
519 policer_classify_next_index_t next_index;
520 policer_classify_main_t *pcm = &policer_classify_main;
521 vnet_classify_main_t *vcm = pcm->vnet_classify_main;
522 f64 now = vlib_time_now (vm);
528 u64 time_in_policer_periods;
530 time_in_policer_periods =
531 clib_cpu_time_now () >> POLICER_TICKS_PER_PERIOD_SHIFT;
533 n_next_nodes = node->n_next_nodes;
535 from = vlib_frame_vector_args (frame);
536 n_left_from = frame->n_vectors;
538 /* First pass: compute hashes */
539 while (n_left_from > 2)
541 vlib_buffer_t *b0, *b1;
544 u32 sw_if_index0, sw_if_index1;
545 u32 table_index0, table_index1;
546 vnet_classify_table_t *t0, *t1;
548 /* Prefetch next iteration */
550 vlib_buffer_t *p1, *p2;
552 p1 = vlib_get_buffer (vm, from[1]);
553 p2 = vlib_get_buffer (vm, from[2]);
555 vlib_prefetch_buffer_header (p1, STORE);
556 CLIB_PREFETCH (p1->data, CLIB_CACHE_LINE_BYTES, STORE);
557 vlib_prefetch_buffer_header (p2, STORE);
558 CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
562 b0 = vlib_get_buffer (vm, bi0);
566 b1 = vlib_get_buffer (vm, bi1);
569 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
571 pcm->classify_table_index_by_sw_if_index[tid][sw_if_index0];
573 sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
575 pcm->classify_table_index_by_sw_if_index[tid][sw_if_index1];
577 t0 = pool_elt_at_index (vcm->tables, table_index0);
579 t1 = pool_elt_at_index (vcm->tables, table_index1);
581 vnet_buffer (b0)->l2_classify.hash =
582 vnet_classify_hash_packet (t0, (u8 *) h0);
584 vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash);
586 vnet_buffer (b1)->l2_classify.hash =
587 vnet_classify_hash_packet (t1, (u8 *) h1);
589 vnet_classify_prefetch_bucket (t1, vnet_buffer (b1)->l2_classify.hash);
591 vnet_buffer (b0)->l2_classify.table_index = table_index0;
593 vnet_buffer (b1)->l2_classify.table_index = table_index1;
599 while (n_left_from > 0)
606 vnet_classify_table_t *t0;
609 b0 = vlib_get_buffer (vm, bi0);
612 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
614 pcm->classify_table_index_by_sw_if_index[tid][sw_if_index0];
616 t0 = pool_elt_at_index (vcm->tables, table_index0);
617 vnet_buffer (b0)->l2_classify.hash =
618 vnet_classify_hash_packet (t0, (u8 *) h0);
620 vnet_buffer (b0)->l2_classify.table_index = table_index0;
621 vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash);
627 next_index = node->cached_next_index;
628 from = vlib_frame_vector_args (frame);
629 n_left_from = frame->n_vectors;
631 while (n_left_from > 0)
635 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
637 /* Not enough load/store slots to dual loop... */
638 while (n_left_from > 0 && n_left_to_next > 0)
642 u32 next0 = POLICER_CLASSIFY_NEXT_INDEX_DROP;
644 vnet_classify_table_t *t0;
645 vnet_classify_entry_t *e0;
650 /* Stride 3 seems to work best */
651 if (PREDICT_TRUE (n_left_from > 3))
653 vlib_buffer_t *p1 = vlib_get_buffer (vm, from[3]);
654 vnet_classify_table_t *tp1;
658 table_index1 = vnet_buffer (p1)->l2_classify.table_index;
660 if (PREDICT_TRUE (table_index1 != ~0))
662 tp1 = pool_elt_at_index (vcm->tables, table_index1);
663 phash1 = vnet_buffer (p1)->l2_classify.hash;
664 vnet_classify_prefetch_entry (tp1, phash1);
668 /* Speculatively enqueue b0 to the current next frame */
676 b0 = vlib_get_buffer (vm, bi0);
678 table_index0 = vnet_buffer (b0)->l2_classify.table_index;
682 if (tid == POLICER_CLASSIFY_TABLE_L2)
684 /* Feature bitmap update and determine the next node */
685 next0 = vnet_l2_feature_next (b0, pcm->feat_next_node_index,
686 L2INPUT_FEAT_POLICER_CLAS);
689 vnet_get_config_data (pcm->vnet_config_main[tid],
690 &b0->current_config_index, &next0,
691 /* # bytes of config data */ 0);
693 vnet_buffer (b0)->l2_classify.opaque_index = ~0;
695 if (PREDICT_TRUE (table_index0 != ~0))
697 hash0 = vnet_buffer (b0)->l2_classify.hash;
698 t0 = pool_elt_at_index (vcm->tables, table_index0);
699 e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
703 act0 = vnet_policer_police (vm,
706 time_in_policer_periods,
708 if (PREDICT_FALSE (act0 == SSE2_QOS_ACTION_DROP))
710 next0 = POLICER_CLASSIFY_NEXT_INDEX_DROP;
711 b0->error = node->errors[POLICER_CLASSIFY_ERROR_DROP];
720 if (PREDICT_TRUE (t0->next_table_index != ~0))
722 t0 = pool_elt_at_index (vcm->tables,
723 t0->next_table_index);
727 next0 = (t0->miss_next_index < n_next_nodes) ?
728 t0->miss_next_index : next0;
733 hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
735 vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
738 act0 = vnet_policer_police (vm,
741 time_in_policer_periods,
743 if (PREDICT_FALSE (act0 == SSE2_QOS_ACTION_DROP))
745 next0 = POLICER_CLASSIFY_NEXT_INDEX_DROP;
747 node->errors[POLICER_CLASSIFY_ERROR_DROP];
757 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
758 && (b0->flags & VLIB_BUFFER_IS_TRACED)))
760 policer_classify_trace_t *t =
761 vlib_add_trace (vm, node, b0, sizeof (*t));
762 t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
763 t->next_index = next0;
764 t->table_index = t0 ? t0 - vcm->tables : ~0;
765 t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0) : ~0;
766 t->policer_index = e0 ? e0->next_index : ~0;
769 /* Verify speculative enqueue, maybe switch current next frame */
770 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
771 n_left_to_next, bi0, next0);
774 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
777 vlib_node_increment_counter (vm, node->node_index,
778 POLICER_CLASSIFY_ERROR_MISS, misses);
779 vlib_node_increment_counter (vm, node->node_index,
780 POLICER_CLASSIFY_ERROR_HIT, hits);
781 vlib_node_increment_counter (vm, node->node_index,
782 POLICER_CLASSIFY_ERROR_CHAIN_HIT, chain_hits);
783 vlib_node_increment_counter (vm, node->node_index,
784 POLICER_CLASSIFY_ERROR_DROP, drop);
786 return frame->n_vectors;
790 ip4_policer_classify (vlib_main_t * vm,
791 vlib_node_runtime_t * node, vlib_frame_t * frame)
793 return policer_classify_inline (vm, node, frame,
794 POLICER_CLASSIFY_TABLE_IP4);
798 VLIB_REGISTER_NODE (ip4_policer_classify_node) = {
799 .function = ip4_policer_classify,
800 .name = "ip4-policer-classify",
801 .vector_size = sizeof (u32),
802 .format_trace = format_policer_classify_trace,
803 .n_errors = ARRAY_LEN(policer_classify_error_strings),
804 .error_strings = policer_classify_error_strings,
805 .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,
807 [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",
811 VLIB_NODE_FUNCTION_MULTIARCH (ip4_policer_classify_node, ip4_policer_classify);
815 ip6_policer_classify (vlib_main_t * vm,
816 vlib_node_runtime_t * node, vlib_frame_t * frame)
818 return policer_classify_inline (vm, node, frame,
819 POLICER_CLASSIFY_TABLE_IP6);
823 VLIB_REGISTER_NODE (ip6_policer_classify_node) = {
824 .function = ip6_policer_classify,
825 .name = "ip6-policer-classify",
826 .vector_size = sizeof (u32),
827 .format_trace = format_policer_classify_trace,
828 .n_errors = ARRAY_LEN(policer_classify_error_strings),
829 .error_strings = policer_classify_error_strings,
830 .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,
832 [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",
836 VLIB_NODE_FUNCTION_MULTIARCH (ip6_policer_classify_node, ip6_policer_classify);
840 l2_policer_classify (vlib_main_t * vm,
841 vlib_node_runtime_t * node, vlib_frame_t * frame)
843 return policer_classify_inline (vm, node, frame, POLICER_CLASSIFY_TABLE_L2);
847 VLIB_REGISTER_NODE (l2_policer_classify_node) = {
848 .function = l2_policer_classify,
849 .name = "l2-policer-classify",
850 .vector_size = sizeof (u32),
851 .format_trace = format_policer_classify_trace,
852 .n_errors = ARRAY_LEN (policer_classify_error_strings),
853 .error_strings = policer_classify_error_strings,
854 .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,
856 [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",
860 VLIB_NODE_FUNCTION_MULTIARCH (l2_policer_classify_node, l2_policer_classify);
863 static clib_error_t *
864 policer_classify_init (vlib_main_t * vm)
866 policer_classify_main_t *pcm = &policer_classify_main;
869 pcm->vnet_main = vnet_get_main ();
870 pcm->vnet_classify_main = &vnet_classify_main;
872 /* Initialize L2 feature next-node indexes */
873 feat_bitmap_init_next_nodes (vm,
874 l2_policer_classify_node.index,
876 l2input_get_feat_names (),
877 pcm->feat_next_node_index);
882 VLIB_INIT_FUNCTION (policer_classify_init);
885 * fd.io coding-style-patch-verification: ON
888 * eval: (c-set-style "gnu")