FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
node_funcs.c
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #include <stdint.h>
17 
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/policer/policer.h>
22 #include <vnet/ip/ip.h>
25 #include <vnet/l2/feat_bitmap.h>
26 #include <vnet/l2/l2_input.h>
27 
28 
29 /* Dispatch functions meant to be instantiated elsewhere */
30 
31 typedef struct
32 {
37 
38 /* packet trace format function */
39 static u8 *
40 format_policer_trace (u8 * s, va_list * args)
41 {
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 *);
45 
46  s = format (s, "VNET_POLICER: sw_if_index %d policer_index %d next %d",
48  return s;
49 }
50 
51 #define foreach_vnet_policer_error \
52 _(TRANSMIT, "Packets Transmitted") \
53 _(DROP, "Packets Dropped")
54 
55 typedef enum
56 {
57 #define _(sym,str) VNET_POLICER_ERROR_##sym,
59 #undef _
62 
63 static char *vnet_policer_error_strings[] = {
64 #define _(sym,string) string,
66 #undef _
67 };
68 
69 static inline uword
72 {
73  u32 n_left_from, *from, *to_next;
76  u64 time_in_policer_periods;
77  u32 transmitted = 0;
78 
79  time_in_policer_periods =
81 
83  n_left_from = frame->n_vectors;
84  next_index = node->cached_next_index;
85 
86  while (n_left_from > 0)
87  {
88  u32 n_left_to_next;
89 
90  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
91 
92  while (n_left_from >= 4 && n_left_to_next >= 2)
93  {
94  u32 bi0, bi1;
95  vlib_buffer_t *b0, *b1;
96  u32 next0, next1;
97  u32 sw_if_index0, sw_if_index1;
98  u32 pi0 = 0, pi1 = 0;
99  u8 act0, act1;
100 
101  /* Prefetch next iteration. */
102  {
103  vlib_buffer_t *b2, *b3;
104 
105  b2 = vlib_get_buffer (vm, from[2]);
106  b3 = vlib_get_buffer (vm, from[3]);
107 
108  vlib_prefetch_buffer_header (b2, LOAD);
109  vlib_prefetch_buffer_header (b3, LOAD);
110  }
111 
112  /* speculatively enqueue b0 and b1 to the current next frame */
113  to_next[0] = bi0 = from[0];
114  to_next[1] = bi1 = from[1];
115  from += 2;
116  to_next += 2;
117  n_left_from -= 2;
118  n_left_to_next -= 2;
119 
120  b0 = vlib_get_buffer (vm, bi0);
121  b1 = vlib_get_buffer (vm, bi1);
122 
123  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
124  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
125 
126  pi0 = pm->policer_index_by_sw_if_index[sw_if_index0];
127  pi1 = pm->policer_index_by_sw_if_index[sw_if_index1];
128 
129  act0 = vnet_policer_police (vm, b0, pi0, time_in_policer_periods,
130  POLICE_CONFORM /* no chaining */, true);
131 
132  act1 = vnet_policer_police (vm, b1, pi1, time_in_policer_periods,
133  POLICE_CONFORM /* no chaining */, true);
134 
135  if (PREDICT_FALSE (act0 == QOS_ACTION_HANDOFF))
136  {
138  vnet_buffer (b0)->policer.index = pi0;
139  }
140  else if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
141  {
142  next0 = VNET_POLICER_NEXT_DROP;
143  b0->error = node->errors[VNET_POLICER_ERROR_DROP];
144  }
145  else /* transmit or mark-and-transmit action */
146  {
147  transmitted++;
148  vnet_feature_next (&next0, b0);
149  }
150 
151  if (PREDICT_FALSE (act1 == QOS_ACTION_HANDOFF))
152  {
154  vnet_buffer (b1)->policer.index = pi1;
155  }
156  else if (PREDICT_FALSE (act1 == QOS_ACTION_DROP)) /* drop action */
157  {
158  next1 = VNET_POLICER_NEXT_DROP;
159  b1->error = node->errors[VNET_POLICER_ERROR_DROP];
160  }
161  else /* transmit or mark-and-transmit action */
162  {
163  transmitted++;
164  vnet_feature_next (&next1, b1);
165  }
166 
167  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
168  {
169  if (b0->flags & VLIB_BUFFER_IS_TRACED)
170  {
172  vlib_add_trace (vm, node, b0, sizeof (*t));
173  t->sw_if_index = sw_if_index0;
174  t->next_index = next0;
175  }
176  if (b1->flags & VLIB_BUFFER_IS_TRACED)
177  {
179  vlib_add_trace (vm, node, b1, sizeof (*t));
180  t->sw_if_index = sw_if_index1;
181  t->next_index = next1;
182  }
183  }
184 
185  /* verify speculative enqueues, maybe switch current next frame */
187  to_next, n_left_to_next,
188  bi0, bi1, next0, next1);
189  }
190 
191  while (n_left_from > 0 && n_left_to_next > 0)
192  {
193  u32 bi0;
194  vlib_buffer_t *b0;
195  u32 next0;
196  u32 sw_if_index0;
197  u32 pi0 = 0;
198  u8 act0;
199 
200  bi0 = from[0];
201  to_next[0] = bi0;
202  from += 1;
203  to_next += 1;
204  n_left_from -= 1;
205  n_left_to_next -= 1;
206 
207  b0 = vlib_get_buffer (vm, bi0);
208 
209  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
210 
211  pi0 = pm->policer_index_by_sw_if_index[sw_if_index0];
212 
213  act0 = vnet_policer_police (vm, b0, pi0, time_in_policer_periods,
214  POLICE_CONFORM /* no chaining */, true);
215 
216  if (PREDICT_FALSE (act0 == QOS_ACTION_HANDOFF))
217  {
219  vnet_buffer (b0)->policer.index = pi0;
220  }
221  else if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
222  {
223  next0 = VNET_POLICER_NEXT_DROP;
224  b0->error = node->errors[VNET_POLICER_ERROR_DROP];
225  }
226  else /* transmit or mark-and-transmit action */
227  {
228  transmitted++;
229  vnet_feature_next (&next0, b0);
230  }
231 
232  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
233  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
234  {
236  vlib_add_trace (vm, node, b0, sizeof (*t));
237  t->sw_if_index = sw_if_index0;
238  t->next_index = next0;
239  t->policer_index = pi0;
240  }
241 
242  /* verify speculative enqueue, maybe switch current next frame */
244  to_next, n_left_to_next,
245  bi0, next0);
246  }
247 
248  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
249  }
250 
251  vlib_node_increment_counter (vm, node->node_index,
252  VNET_POLICER_ERROR_TRANSMIT, transmitted);
253  return frame->n_vectors;
254 }
255 
258 {
259  return vnet_policer_inline (vm, node, frame);
260 }
261 
263  .name = "policer-input",
264  .vector_size = sizeof (u32),
265  .format_trace = format_policer_trace,
268  .error_strings = vnet_policer_error_strings,
269  .n_next_nodes = VNET_POLICER_N_NEXT,
270  .next_nodes = {
271  [VNET_POLICER_NEXT_DROP] = "error-drop",
272  [VNET_POLICER_NEXT_HANDOFF] = "policer-input-handoff",
273  },
274 };
275 
277  .arc_name = "device-input",
278  .node_name = "policer-input",
279  .runs_before = VNET_FEATURES ("ethernet-input"),
280 };
281 
282 static char *policer_input_handoff_error_strings[] = { "congestion drop" };
283 
286 {
288 }
289 
291  .name = "policer-input-handoff",
292  .vector_size = sizeof (u32),
293  .format_trace = format_policer_handoff_trace,
296  .error_strings = policer_input_handoff_error_strings,
297 
298  .n_next_nodes = 1,
299  .next_nodes = {
300  [0] = "error-drop",
301  },
302 };
303 
304 typedef struct
305 {
312 
313 static u8 *
314 format_policer_classify_trace (u8 * s, va_list * args)
315 {
316  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
317  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
318  policer_classify_trace_t *t = va_arg (*args, policer_classify_trace_t *);
319 
320  s = format (s, "POLICER_CLASSIFY: sw_if_index %d next %d table %d offset %d"
321  " policer_index %d",
322  t->sw_if_index, t->next_index, t->table_index, t->offset,
323  t->policer_index);
324  return s;
325 }
326 
327 #define foreach_policer_classify_error \
328 _(MISS, "Policer classify misses") \
329 _(HIT, "Policer classify hits") \
330 _(CHAIN_HIT, "Policer classify hits after chain walk") \
331 _(DROP, "Policer classify action drop")
332 
333 typedef enum
334 {
335 #define _(sym,str) POLICER_CLASSIFY_ERROR_##sym,
337 #undef _
340 
342 #define _(sym,string) string,
344 #undef _
345 };
346 
347 static inline uword
352 {
353  u32 n_left_from, *from, *to_next;
357  f64 now = vlib_time_now (vm);
358  u32 hits = 0;
359  u32 misses = 0;
360  u32 chain_hits = 0;
361  u32 n_next_nodes;
362  u64 time_in_policer_periods;
363 
364  time_in_policer_periods =
366 
367  n_next_nodes = node->n_next_nodes;
368 
370  n_left_from = frame->n_vectors;
371 
372  /* First pass: compute hashes */
373  while (n_left_from > 2)
374  {
375  vlib_buffer_t *b0, *b1;
376  u32 bi0, bi1;
377  u8 *h0, *h1;
378  u32 sw_if_index0, sw_if_index1;
379  u32 table_index0, table_index1;
380  vnet_classify_table_t *t0, *t1;
381 
382  /* Prefetch next iteration */
383  {
384  vlib_buffer_t *p1, *p2;
385 
386  p1 = vlib_get_buffer (vm, from[1]);
387  p2 = vlib_get_buffer (vm, from[2]);
388 
389  vlib_prefetch_buffer_header (p1, STORE);
391  vlib_prefetch_buffer_header (p2, STORE);
393  }
394 
395  bi0 = from[0];
396  b0 = vlib_get_buffer (vm, bi0);
397  h0 = b0->data;
398 
399  bi1 = from[1];
400  b1 = vlib_get_buffer (vm, bi1);
401  h1 = b1->data;
402 
403  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
404  table_index0 =
405  pcm->classify_table_index_by_sw_if_index[tid][sw_if_index0];
406 
407  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
408  table_index1 =
409  pcm->classify_table_index_by_sw_if_index[tid][sw_if_index1];
410 
411  t0 = pool_elt_at_index (vcm->tables, table_index0);
412 
413  t1 = pool_elt_at_index (vcm->tables, table_index1);
414 
415  vnet_buffer (b0)->l2_classify.hash =
416  vnet_classify_hash_packet (t0, (u8 *) h0);
417 
418  vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash);
419 
420  vnet_buffer (b1)->l2_classify.hash =
421  vnet_classify_hash_packet (t1, (u8 *) h1);
422 
423  vnet_classify_prefetch_bucket (t1, vnet_buffer (b1)->l2_classify.hash);
424 
425  vnet_buffer (b0)->l2_classify.table_index = table_index0;
426 
427  vnet_buffer (b1)->l2_classify.table_index = table_index1;
428 
429  from += 2;
430  n_left_from -= 2;
431  }
432 
433  while (n_left_from > 0)
434  {
435  vlib_buffer_t *b0;
436  u32 bi0;
437  u8 *h0;
438  u32 sw_if_index0;
439  u32 table_index0;
441 
442  bi0 = from[0];
443  b0 = vlib_get_buffer (vm, bi0);
444  h0 = b0->data;
445 
446  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
447  table_index0 =
448  pcm->classify_table_index_by_sw_if_index[tid][sw_if_index0];
449 
450  t0 = pool_elt_at_index (vcm->tables, table_index0);
451  vnet_buffer (b0)->l2_classify.hash =
452  vnet_classify_hash_packet (t0, (u8 *) h0);
453 
454  vnet_buffer (b0)->l2_classify.table_index = table_index0;
455  vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash);
456 
457  from++;
458  n_left_from--;
459  }
460 
461  next_index = node->cached_next_index;
463  n_left_from = frame->n_vectors;
464 
465  while (n_left_from > 0)
466  {
467  u32 n_left_to_next;
468 
469  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
470 
471  /* Not enough load/store slots to dual loop... */
472  while (n_left_from > 0 && n_left_to_next > 0)
473  {
474  u32 bi0;
475  vlib_buffer_t *b0;
477  u32 table_index0;
480  u64 hash0;
481  u8 *h0;
482  u8 act0;
483 
484  /* Stride 3 seems to work best */
485  if (PREDICT_TRUE (n_left_from > 3))
486  {
487  vlib_buffer_t *p1 = vlib_get_buffer (vm, from[3]);
489  u32 table_index1;
490  u64 phash1;
491 
492  table_index1 = vnet_buffer (p1)->l2_classify.table_index;
493 
494  if (PREDICT_TRUE (table_index1 != ~0))
495  {
496  tp1 = pool_elt_at_index (vcm->tables, table_index1);
497  phash1 = vnet_buffer (p1)->l2_classify.hash;
498  vnet_classify_prefetch_entry (tp1, phash1);
499  }
500  }
501 
502  /* Speculatively enqueue b0 to the current next frame */
503  bi0 = from[0];
504  to_next[0] = bi0;
505  from += 1;
506  to_next += 1;
507  n_left_from -= 1;
508  n_left_to_next -= 1;
509 
510  b0 = vlib_get_buffer (vm, bi0);
511  h0 = b0->data;
512  table_index0 = vnet_buffer (b0)->l2_classify.table_index;
513  e0 = 0;
514  t0 = 0;
515 
516  if (tid == POLICER_CLASSIFY_TABLE_L2)
517  {
518  /* Feature bitmap update and determine the next node */
519  next0 = vnet_l2_feature_next (b0, pcm->feat_next_node_index,
520  L2INPUT_FEAT_POLICER_CLAS);
521  }
522  else
524  &b0->current_config_index, &next0,
525  /* # bytes of config data */ 0);
526 
527  vnet_buffer (b0)->l2_classify.opaque_index = ~0;
528 
529  if (PREDICT_TRUE (table_index0 != ~0))
530  {
531  hash0 = vnet_buffer (b0)->l2_classify.hash;
532  t0 = pool_elt_at_index (vcm->tables, table_index0);
533  e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
534 
535  if (e0)
536  {
537  act0 = vnet_policer_police (vm, b0, e0->next_index,
538  time_in_policer_periods,
539  e0->opaque_index, false);
540  if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
541  {
543  b0->error = node->errors[POLICER_CLASSIFY_ERROR_DROP];
544  }
545  hits++;
546  }
547  else
548  {
549  while (1)
550  {
551  if (PREDICT_TRUE (t0->next_table_index != ~0))
552  {
553  t0 = pool_elt_at_index (vcm->tables,
554  t0->next_table_index);
555  }
556  else
557  {
558  next0 = (t0->miss_next_index < n_next_nodes) ?
559  t0->miss_next_index : next0;
560  misses++;
561  break;
562  }
563 
564  hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
565  e0 =
566  vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
567  if (e0)
568  {
569  act0 = vnet_policer_police (vm, b0, e0->next_index,
570  time_in_policer_periods,
571  e0->opaque_index, false);
572  if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
573  {
575  b0->error =
576  node->errors[POLICER_CLASSIFY_ERROR_DROP];
577  }
578  hits++;
579  chain_hits++;
580  break;
581  }
582  }
583  }
584  }
585  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
586  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
587  {
589  vlib_add_trace (vm, node, b0, sizeof (*t));
590  t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
591  t->next_index = next0;
592  t->table_index = t0 ? t0 - vcm->tables : ~0;
593  t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0) : ~0;
594  t->policer_index = e0 ? e0->next_index : ~0;
595  }
596 
597  /* Verify speculative enqueue, maybe switch current next frame */
599  n_left_to_next, bi0, next0);
600  }
601 
602  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
603  }
604 
605  vlib_node_increment_counter (vm, node->node_index,
606  POLICER_CLASSIFY_ERROR_MISS, misses);
607  vlib_node_increment_counter (vm, node->node_index,
608  POLICER_CLASSIFY_ERROR_HIT, hits);
609  vlib_node_increment_counter (vm, node->node_index,
610  POLICER_CLASSIFY_ERROR_CHAIN_HIT, chain_hits);
611 
612  return frame->n_vectors;
613 }
614 
618 {
621 }
622 
623 /* *INDENT-OFF* */
625  .name = "ip4-policer-classify",
626  .vector_size = sizeof (u32),
627  .format_trace = format_policer_classify_trace,
629  .error_strings = policer_classify_error_strings,
630  .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,
631  .next_nodes = {
632  [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",
633  },
634 };
635 /* *INDENT-ON* */
636 
640 {
643 }
644 
645 /* *INDENT-OFF* */
647  .name = "ip6-policer-classify",
648  .vector_size = sizeof (u32),
649  .format_trace = format_policer_classify_trace,
651  .error_strings = policer_classify_error_strings,
652  .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,
653  .next_nodes = {
654  [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",
655  },
656 };
657 /* *INDENT-ON* */
658 
662 {
664 }
665 
666 /* *INDENT-OFF* */
668  .name = "l2-policer-classify",
669  .vector_size = sizeof (u32),
670  .format_trace = format_policer_classify_trace,
672  .error_strings = policer_classify_error_strings,
673  .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,
674  .next_nodes = {
675  [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",
676  },
677 };
678 /* *INDENT-ON* */
679 
680 #ifndef CLIB_MARCH_VARIANT
681 static clib_error_t *
683 {
685 
686  pcm->vlib_main = vm;
687  pcm->vnet_main = vnet_get_main ();
689 
690  /* Initialize L2 feature next-node indexes */
695  pcm->feat_next_node_index);
696 
697  return 0;
698 }
699 
701 #endif /* CLIB_MARCH_VARIANT */
702 
703 /*
704  * fd.io coding-style-patch-verification: ON
705  *
706  * Local Variables:
707  * eval: (c-set-style "gnu")
708  * End:
709  */
vlib.h
vnet_policer_main_t
Definition: policer.h:26
vnet_classify_entry_t
struct _vnet_classify_entry vnet_classify_entry_t
node
vlib_main_t vlib_node_runtime_t * node
Definition: node_funcs.c:257
policer_classify_trace_t::sw_if_index
u32 sw_if_index
Definition: node_funcs.c:306
vlib_prefetch_buffer_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:231
foreach_vnet_policer_error
#define foreach_vnet_policer_error
Definition: node_funcs.c:51
policer_classify_inline
static uword policer_classify_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, policer_classify_table_id_t tid)
Definition: node_funcs.c:348
vnet_classify_table_t::miss_next_index
u32 miss_next_index
Definition: vnet_classify.h:176
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
vnet_policer_main
vnet_policer_main_t vnet_policer_main
Definition: policer.c:22
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
vm
vlib_main_t * vm
Definition: node_funcs.c:257
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
ip6_policer_classify_node
vlib_node_registration_t ip6_policer_classify_node
(constructor) VLIB_REGISTER_NODE (ip6_policer_classify_node)
Definition: node_funcs.c:646
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
policer_classify_table_id_t
policer_classify_table_id_t
Definition: policer_classify.h:23
vnet_classify_main
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:32
policer_input_handoff_node
vlib_node_registration_t policer_input_handoff_node
(constructor) VLIB_REGISTER_NODE (policer_input_handoff_node)
Definition: node_funcs.c:290
policer_classify_trace_t::offset
u32 offset
Definition: node_funcs.c:309
vnet_policer_next_t
vnet_policer_next_t
Definition: policer.h:60
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: node_funcs.c:258
POLICER_CLASSIFY_TABLE_IP6
@ POLICER_CLASSIFY_TABLE_IP6
Definition: policer_classify.h:26
VNET_POLICER_NEXT_DROP
@ VNET_POLICER_NEXT_DROP
Definition: policer.h:62
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
policer.h
vlib_frame_t
Definition: node.h:372
vnet_policer_trace_t::policer_index
u32 policer_index
Definition: node_funcs.c:35
VNET_FEATURE_INIT
VNET_FEATURE_INIT(policer_input_node, static)
vnet_classify_find_entry
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
Definition: vnet_classify.c:657
policer_handoff
static_always_inline uword policer_handoff(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 fq_index, u32 policer_index)
Definition: police_inlines.h:118
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
vnet_policer_inline
static uword vnet_policer_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: node_funcs.c:70
POLICER_CLASSIFY_TABLE_L2
@ POLICER_CLASSIFY_TABLE_L2
Definition: policer_classify.h:27
policer_classify_main_t::classify_table_index_by_sw_if_index
u32 * classify_table_index_by_sw_if_index[POLICER_CLASSIFY_N_TABLES]
Definition: policer_classify.h:40
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
format_policer_handoff_trace
u8 * format_policer_handoff_trace(u8 *s, va_list *args)
Definition: policer.c:25
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vnet_feature_next
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:322
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
vnet_classify_prefetch_entry
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
Definition: vnet_classify.h:371
uword
u64 uword
Definition: types.h:112
policer_classify_trace_t::table_index
u32 table_index
Definition: node_funcs.c:308
l2input_get_feat_names
char ** l2input_get_feat_names(void)
Return an array of strings containing graph node names of each feature.
Definition: l2_input.c:59
vnet_classify_prefetch_bucket
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
Definition: vnet_classify.h:323
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
vnet_policer_main_t::policer_index_by_sw_if_index
u32 * policer_index_by_sw_if_index
Definition: policer.h:42
QOS_ACTION_DROP
@ QOS_ACTION_DROP
Definition: police.h:29
f64
double f64
Definition: types.h:142
foreach_policer_classify_error
#define foreach_policer_classify_error
Definition: node_funcs.c:327
policer_input_handoff_error_strings
static char * policer_input_handoff_error_strings[]
Definition: node_funcs.c:282
vnet_policer_police
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, bool handoff)
Definition: police_inlines.h:59
policer_classify_trace_t::policer_index
u32 policer_index
Definition: node_funcs.c:310
L2INPUT_N_FEAT
@ L2INPUT_N_FEAT
Definition: l2_input.h:163
vnet_classify_table_t
Definition: vnet_classify.h:147
police_inlines.h
policer_classify_main_t::vnet_classify_main
vnet_classify_main_t * vnet_classify_main
Definition: policer_classify.h:48
policer_classify_main
policer_classify_main_t policer_classify_main
Definition: policer_classify.c:18
policer_classify_main_t::vnet_main
vnet_main_t * vnet_main
Definition: policer_classify.h:47
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
l2_input.h
vnet_policer_trace_t::next_index
u32 next_index
Definition: node_funcs.c:33
policer_classify.h
vnet_l2_feature_next
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...
Definition: feat_bitmap.h:94
POLICER_TICKS_PER_PERIOD_SHIFT
#define POLICER_TICKS_PER_PERIOD_SHIFT
Definition: police.h:70
vlib_buffer_t::current_config_index
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
Definition: buffer.h:156
vnet_policer_trace_t
Definition: node_funcs.c:31
vnet_classify_table_t::next_table_index
u32 next_table_index
Definition: vnet_classify.h:170
vlib_validate_buffer_enqueue_x1
#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.
Definition: buffer_node.h:224
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
policer_classify_error_strings
static char * policer_classify_error_strings[]
Definition: node_funcs.c:341
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
policer_classify_main_t
Definition: policer_classify.h:37
vnet_policer_error_t
vnet_policer_error_t
Definition: node_funcs.c:55
policer_classify_main_t::vlib_main
vlib_main_t * vlib_main
Definition: policer_classify.h:46
ip.h
POLICE_CONFORM
@ POLICE_CONFORM
Definition: police.h:20
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
VNET_POLICER_NEXT_HANDOFF
@ VNET_POLICER_NEXT_HANDOFF
Definition: policer.h:63
policer_input_node
vlib_node_registration_t policer_input_node
(constructor) VLIB_REGISTER_NODE (policer_input_node)
Definition: node_funcs.c:262
vnet_policer_error_strings
static char * vnet_policer_error_strings[]
Definition: node_funcs.c:63
vnet_classify_main_t
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:61
vnet_classify_hash_packet
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
vnet_classify.h
vnet_classify_get_offset
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
Definition: vnet_classify.h:344
now
f64 now
Definition: nat44_ei_out2in.c:710
policer_classify_error_t
policer_classify_error_t
Definition: node_funcs.c:333
vlib_main_t
Definition: main.h:102
policer_classify_trace_t
Definition: node_funcs.c:304
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
VNET_FEATURES
#define VNET_FEATURES(...)
Definition: feature.h:470
policer_classify_trace_t::next_index
u32 next_index
Definition: node_funcs.c:307
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
format_policer_trace
static u8 * format_policer_trace(u8 *s, va_list *args)
Definition: node_funcs.c:40
feat_bitmap.h
QOS_ACTION_HANDOFF
@ QOS_ACTION_HANDOFF
Definition: police.h:32
policer_classify_main_t::feat_next_node_index
u32 feat_next_node_index[32]
Definition: policer_classify.h:43
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vnet_get_config_data
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
Definition: config.h:123
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
POLICER_CLASSIFY_N_ERROR
@ POLICER_CLASSIFY_N_ERROR
Definition: node_funcs.c:338
format_policer_classify_trace
static u8 * format_policer_classify_trace(u8 *s, va_list *args)
Definition: node_funcs.c:314
policer_classify_main_t::vnet_config_main
vnet_config_main_t * vnet_config_main[POLICER_CLASSIFY_N_TABLES]
Definition: policer_classify.h:49
POLICER_CLASSIFY_NEXT_INDEX_DROP
@ POLICER_CLASSIFY_NEXT_INDEX_DROP
Definition: policer_classify.h:33
vlib_validate_buffer_enqueue_x2
#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.
Definition: buffer_node.h:70
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
VNET_POLICER_N_ERROR
@ VNET_POLICER_N_ERROR
Definition: node_funcs.c:60
vnet.h
vlib_node_runtime_t
Definition: node.h:454
vnet_policer_trace_t::sw_if_index
u32 sw_if_index
Definition: node_funcs.c:34
clib_cpu_time_now
static u64 clib_cpu_time_now(void)
Definition: time.h:81
POLICER_CLASSIFY_TABLE_IP4
@ POLICER_CLASSIFY_TABLE_IP4
Definition: policer_classify.h:25
from
from
Definition: nat44_ei_hairpinning.c:415
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
policer_classify_next_index_t
policer_classify_next_index_t
Definition: policer_classify.h:31
vlib_get_next_frame
#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).
Definition: node_funcs.h:395
POLICER_CLASSIFY_NEXT_INDEX_N_NEXT
@ POLICER_CLASSIFY_NEXT_INDEX_N_NEXT
Definition: policer_classify.h:34
l2_policer_classify_node
vlib_node_registration_t l2_policer_classify_node
(constructor) VLIB_REGISTER_NODE (l2_policer_classify_node)
Definition: node_funcs.c:667
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
feat_bitmap_init_next_nodes
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.
Definition: feat_bitmap.h:43
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
ip4_policer_classify_node
vlib_node_registration_t ip4_policer_classify_node
(constructor) VLIB_REGISTER_NODE (ip4_policer_classify_node)
Definition: node_funcs.c:624
policer_classify_init
static clib_error_t * policer_classify_init(vlib_main_t *vm)
Definition: node_funcs.c:682
vnet_policer_main_t::fq_index
u32 fq_index
Definition: policer.h:51
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VNET_POLICER_N_NEXT
@ VNET_POLICER_N_NEXT
Definition: policer.h:64
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169