FD.io VPP  v17.07-30-g839fa73
Vector Packet Processing
l2_output_classify.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 <vnet/l2/l2_classify.h>
17 #include <vnet/api_errno.h>
18 
19 /**
20  * @file
21  * @brief Layer 2 Output Classifier.
22  *
23  * @sa @ref vnet/vnet/classify/vnet_classify.c
24  * @sa @ref vnet/vnet/classify/vnet_classify.h
25  */
26 
27 typedef struct
28 {
29  /** interface handle for the ith packet */
31  /** graph arc index selected for this packet */
33  /** classifier table which provided the final result */
35  /** offset in classifier heap of the corresponding session */
38 
39 typedef struct
40 {
41  /** use-case independent main object pointer */
43  /** l2 input classifier main object pointer */
46 
47 /** Packet trace format function. */
48 static u8 *
49 format_l2_output_classify_trace (u8 * s, va_list * args)
50 {
51  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
52  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
54  va_arg (*args, l2_output_classify_trace_t *);
55 
56  s = format (s, "l2-classify: sw_if_index %d, table %d, offset %x, next %d",
58  t->next_index);
59  return s;
60 }
61 
62 /** l2 output classifier main data structure. */
64 
66 
67 #define foreach_l2_output_classify_error \
68 _(MISS, "Classify misses") \
69 _(HIT, "Classify hits") \
70 _(CHAIN_HIT, "Classify hits after chain walk") \
71 _(DROP, "L2 Classify Drops")
72 
73 typedef enum
74 {
75 #define _(sym,str) L2_OUTPUT_CLASSIFY_ERROR_##sym,
77 #undef _
80 
82 #define _(sym,string) string,
84 #undef _
85 };
86 
87 /**
88  * @brief l2 output classifier node.
89  * @node l2-output-classify
90  *
91  * This is the l2 output classifier dispatch node
92  *
93  * @param vm vlib_main_t corresponding to the current thread.
94  * @param node vlib_node_runtime_t data for this node.
95  * @param frame vlib_frame_t whose contents should be dispatched.
96  *
97  * @par Graph mechanics: buffer metadata, next index usage
98  *
99  * @em Uses:
100  * - <code>(l2_output_classify_runtime_t *)
101  * rt->classify_table_index_by_sw_if_index</code>
102  * Head of the per-interface, perprotocol classifier table chain
103  * for a specific interface. ~0 => send pkts to the next
104  * feature in the L2 feature chain.
105  * - <code>vnet_buffer(b)->sw_if_index[VLIB_TX]</code>
106  * - Indicates the @c sw_if_index value of the interface that the
107  * packet was received on.
108  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
109  * - Used to steer packets across l2 features enabled on the interface
110  * - <code>(vnet_classify_entry_t) e0->next_index</code>
111  * - Used to steer traffic when the classifier hits on a session
112  * - <code>(vnet_classify_entry_t) e0->advance</code>
113  * - Signed quantity applied via <code>vlib_buffer_advance</code>
114  * when the classifier hits on a session
115  * - <code>(vnet_classify_table_t) t0->miss_next_index</code>
116  * - Used to steer traffic when the classifier misses
117  *
118  * @em Sets:
119  * - <code>vnet_buffer (b0)->l2_classify.table_index</code>
120  * - Classifier table index of the first classifier table in
121  * the classifier table chain
122  * - <code>vnet_buffer (b0)->l2_classify.hash</code>
123  * - Bounded-index extensible hash corresponding to the
124  * masked fields in the current packet
125  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
126  * - Used to steer packets across l2 features enabled on the interface
127  * - <code>vnet_buffer (b0)->l2_classify.opaque_index</code>
128  * - Copied from the classifier session object upon classifier hit
129  *
130  * @em Counters:
131  * - <code>L2_OUTPUT_CLASSIFY_ERROR_MISS</code> Classifier misses
132  * - <code>L2_OUTPUT_CLASSIFY_ERROR_HIT</code> Classifier hits
133  * - <code>L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT</code>
134  * Classifier hits in other than the first table
135  */
136 
137 static uword
139  vlib_node_runtime_t * node, vlib_frame_t * frame)
140 {
141  u32 n_left_from, *from, *to_next;
142  l2_output_classify_next_t next_index;
144  vnet_classify_main_t *vcm = cm->vnet_classify_main;
147  u32 feature_bitmap0;
148  u32 hits = 0;
149  u32 misses = 0;
150  u32 chain_hits = 0;
151  f64 now;
152  u32 n_next_nodes;
153  u32 cached_sw_if_index = (u32) ~ 0;
154  u32 cached_next_index = (u32) ~ 0;
155  u32 sw_if_index0;
156 
157  n_next_nodes = node->n_next_nodes;
158 
159  now = vlib_time_now (vm);
160 
161  n_left_from = frame->n_vectors;
162  from = vlib_frame_vector_args (frame);
163 
164  /* First pass: compute hash */
165 
166  while (n_left_from > 2)
167  {
168  vlib_buffer_t *b0, *b1;
169  u32 bi0, bi1;
170  ethernet_header_t *h0, *h1;
171  u32 sw_if_index0, sw_if_index1;
172  u16 type0, type1;
173  int type_index0, type_index1;
174  vnet_classify_table_t *t0, *t1;
175  u32 table_index0, table_index1;
176  u64 hash0, hash1;
177 
178 
179  /* prefetch next iteration */
180  {
181  vlib_buffer_t *p1, *p2;
182 
183  p1 = vlib_get_buffer (vm, from[1]);
184  p2 = vlib_get_buffer (vm, from[2]);
185 
186  vlib_prefetch_buffer_header (p1, STORE);
188  vlib_prefetch_buffer_header (p2, STORE);
190  }
191 
192  bi0 = from[0];
193  b0 = vlib_get_buffer (vm, bi0);
194  h0 = vlib_buffer_get_current (b0);
195 
196  bi1 = from[1];
197  b1 = vlib_get_buffer (vm, bi1);
198  h1 = vlib_buffer_get_current (b1);
199 
200  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
201  vnet_buffer (b0)->l2_classify.table_index = ~0;
202 
203  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
204  vnet_buffer (b1)->l2_classify.table_index = ~0;
205 
206  /* Select classifier table based on ethertype */
207  type0 = clib_net_to_host_u16 (h0->type);
208  type1 = clib_net_to_host_u16 (h1->type);
209 
210  type_index0 = (type0 == ETHERNET_TYPE_IP4)
212  type_index0 = (type0 == ETHERNET_TYPE_IP6)
213  ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index0;
214 
215  type_index1 = (type1 == ETHERNET_TYPE_IP4)
217  type_index1 = (type1 == ETHERNET_TYPE_IP6)
218  ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index1;
219 
220  vnet_buffer (b0)->l2_classify.table_index =
221  table_index0 =
222  rt->l2cm->classify_table_index_by_sw_if_index
223  [type_index0][sw_if_index0];
224 
225  if (table_index0 != ~0)
226  {
227  t0 = pool_elt_at_index (vcm->tables, table_index0);
228 
229  vnet_buffer (b0)->l2_classify.hash = hash0 =
230  vnet_classify_hash_packet (t0, (u8 *) h0);
231  vnet_classify_prefetch_bucket (t0, hash0);
232  }
233 
234  vnet_buffer (b1)->l2_classify.table_index =
235  table_index1 =
236  rt->l2cm->classify_table_index_by_sw_if_index
237  [type_index1][sw_if_index1];
238 
239  if (table_index1 != ~0)
240  {
241  t1 = pool_elt_at_index (vcm->tables, table_index1);
242 
243  vnet_buffer (b1)->l2_classify.hash = hash1 =
244  vnet_classify_hash_packet (t1, (u8 *) h1);
245  vnet_classify_prefetch_bucket (t1, hash1);
246  }
247 
248  from += 2;
249  n_left_from -= 2;
250  }
251 
252  while (n_left_from > 0)
253  {
254  vlib_buffer_t *b0;
255  u32 bi0;
256  ethernet_header_t *h0;
257  u16 type0;
258  u32 type_index0;
260  u32 table_index0;
261  u64 hash0;
262 
263  bi0 = from[0];
264  b0 = vlib_get_buffer (vm, bi0);
265  h0 = vlib_buffer_get_current (b0);
266 
267  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
268  vnet_buffer (b0)->l2_classify.table_index = ~0;
269 
270  /* Select classifier table based on ethertype */
271  type0 = clib_net_to_host_u16 (h0->type);
272 
273  type_index0 = (type0 == ETHERNET_TYPE_IP4)
275  type_index0 = (type0 == ETHERNET_TYPE_IP6)
276  ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index0;
277 
278  vnet_buffer (b0)->l2_classify.table_index =
279  table_index0 = rt->l2cm->classify_table_index_by_sw_if_index
280  [type_index0][sw_if_index0];
281 
282  if (table_index0 != ~0)
283  {
284  t0 = pool_elt_at_index (vcm->tables, table_index0);
285 
286  vnet_buffer (b0)->l2_classify.hash = hash0 =
287  vnet_classify_hash_packet (t0, (u8 *) h0);
288  vnet_classify_prefetch_bucket (t0, hash0);
289  }
290  from++;
291  n_left_from--;
292  }
293 
294  next_index = node->cached_next_index;
295  from = vlib_frame_vector_args (frame);
296  n_left_from = frame->n_vectors;
297 
298  while (n_left_from > 0)
299  {
300  u32 n_left_to_next;
301 
302  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
303 
304  /* Not enough load/store slots to dual loop... */
305  while (n_left_from > 0 && n_left_to_next > 0)
306  {
307  u32 bi0;
308  vlib_buffer_t *b0;
309  u32 next0 = ~0;
310  ethernet_header_t *h0;
311  u32 table_index0;
312  u64 hash0;
314  vnet_classify_entry_t *e0;
315 
316  if (PREDICT_TRUE (n_left_from > 2))
317  {
318  vlib_buffer_t *p2 = vlib_get_buffer (vm, from[2]);
319  u64 phash2;
320  u32 table_index2;
322 
323  /*
324  * Prefetch table entry two ahead. Buffer / data
325  * were prefetched above...
326  */
327  table_index2 = vnet_buffer (p2)->l2_classify.table_index;
328 
329  if (PREDICT_TRUE (table_index2 != ~0))
330  {
331  tp2 = pool_elt_at_index (vcm->tables, table_index2);
332  phash2 = vnet_buffer (p2)->l2_classify.hash;
333  vnet_classify_prefetch_entry (tp2, phash2);
334  }
335  }
336 
337  /* speculatively enqueue b0 to the current next frame */
338  bi0 = from[0];
339  to_next[0] = bi0;
340  from += 1;
341  to_next += 1;
342  n_left_from -= 1;
343  n_left_to_next -= 1;
344 
345  b0 = vlib_get_buffer (vm, bi0);
346  h0 = vlib_buffer_get_current (b0);
347  table_index0 = vnet_buffer (b0)->l2_classify.table_index;
348  e0 = 0;
349  vnet_buffer (b0)->l2_classify.opaque_index = ~0;
350  /* Remove ourself from the feature bitmap */
351  feature_bitmap0 = vnet_buffer (b0)->l2.feature_bitmap
352  & ~L2OUTPUT_FEAT_OUTPUT_CLASSIFY;
353 
354  /* save for next feature graph nodes */
355  vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap0;
356 
357  if (PREDICT_TRUE (table_index0 != ~0))
358  {
359  hash0 = vnet_buffer (b0)->l2_classify.hash;
360  t0 = pool_elt_at_index (vcm->tables, table_index0);
361 
362  e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
363  if (e0)
364  {
365  vnet_buffer (b0)->l2_classify.opaque_index
366  = e0->opaque_index;
367  vlib_buffer_advance (b0, e0->advance);
368  next0 = (e0->next_index < n_next_nodes) ?
369  e0->next_index : next0;
370  hits++;
371  }
372  else
373  {
374  while (1)
375  {
376  if (t0->next_table_index != ~0)
377  t0 = pool_elt_at_index (vcm->tables,
378  t0->next_table_index);
379  else
380  {
381  next0 = (t0->miss_next_index < n_next_nodes) ?
382  t0->miss_next_index : next0;
383  misses++;
384  break;
385  }
386 
387  hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
388  e0 =
389  vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
390  if (e0)
391  {
392  vnet_buffer (b0)->l2_classify.opaque_index
393  = e0->opaque_index;
394  vlib_buffer_advance (b0, e0->advance);
395  next0 = (e0->next_index < n_next_nodes) ?
396  e0->next_index : next0;
397  hits++;
398  chain_hits++;
399  break;
400  }
401  }
402  }
403  }
404 
405  if (PREDICT_FALSE (next0 == 0))
406  b0->error = node->errors[L2_OUTPUT_CLASSIFY_ERROR_DROP];
407 
408  if (PREDICT_FALSE (next0 == ~0))
409  {
410  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
411 
412  /* Determine next node */
413  l2_output_dispatch (cm->vlib_main,
414  cm->vnet_main,
415  node,
417  &cached_sw_if_index,
418  &cached_next_index,
419  &cm->next_nodes,
420  b0, sw_if_index0, feature_bitmap0, &next0);
421  }
422 
424  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
425  {
427  vlib_add_trace (vm, node, b0, sizeof (*t));
428  t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
429  t->table_index = table_index0;
430  t->next_index = next0;
431  t->session_offset = e0 ? vnet_classify_get_offset (t0, e0) : 0;
432  }
433 
434  /* verify speculative enqueue, maybe switch current next frame */
435  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
436  to_next, n_left_to_next,
437  bi0, next0);
438  }
439 
440  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
441  }
442 
444  L2_OUTPUT_CLASSIFY_ERROR_MISS, misses);
446  L2_OUTPUT_CLASSIFY_ERROR_HIT, hits);
448  L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT,
449  chain_hits);
450  return frame->n_vectors;
451 }
452 
453 /* *INDENT-OFF* */
455  .function = l2_output_classify_node_fn,
456  .name = "l2-output-classify",
457  .vector_size = sizeof (u32),
458  .format_trace = format_l2_output_classify_trace,
459  .type = VLIB_NODE_TYPE_INTERNAL,
460 
462  .error_strings = l2_output_classify_error_strings,
463 
464  .runtime_data_bytes = sizeof (l2_output_classify_runtime_t),
465 
466  .n_next_nodes = L2_OUTPUT_CLASSIFY_N_NEXT,
467 
468  /* edit / add dispositions here */
469  .next_nodes = {
470  [L2_OUTPUT_CLASSIFY_NEXT_DROP] = "error-drop",
471  },
472 };
473 /* *INDENT-ON* */
474 
477 
478 /** l2 output classsifier feature initialization. */
479 clib_error_t *
481 {
484 
486 
487  cm->vlib_main = vm;
488  cm->vnet_main = vnet_get_main ();
489  cm->vnet_classify_main = &vnet_classify_main;
490 
491  /* Initialize the feature next-node indexes */
496  cm->next_nodes.feat_next_node_index);
497  rt->l2cm = cm;
498  rt->vcm = cm->vnet_classify_main;
499 
500  return 0;
501 }
502 
504 
505 clib_error_t *
507 {
510 
512 
513  rt->l2cm = cm;
514  rt->vcm = cm->vnet_classify_main;
515 
516  return 0;
517 }
518 
520 
521 /** Enable/disable l2 input classification on a specific interface. */
522 void
523 vnet_l2_output_classify_enable_disable (u32 sw_if_index, int enable_disable)
524 {
525 
526  l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_OUTPUT_CLASSIFY,
527  (u32) enable_disable);
528 }
529 
530 /** @brief Set l2 per-protocol, per-interface output classification tables.
531  *
532  * @param sw_if_index interface handle
533  * @param ip4_table_index ip4 classification table index, or ~0
534  * @param ip6_table_index ip6 classification table index, or ~0
535  * @param other_table_index non-ip4, non-ip6 classification table index,
536  * or ~0
537  * @returns 0 on success, VNET_API_ERROR_NO_SUCH_TABLE, TABLE2, TABLE3
538  * if the indicated (non-~0) table does not exist.
539  */
540 
541 int
543  u32 ip4_table_index,
544  u32 ip6_table_index,
545  u32 other_table_index)
546 {
548  vnet_classify_main_t *vcm = cm->vnet_classify_main;
549 
550  /* Assume that we've validated sw_if_index in the API layer */
551 
552  if (ip4_table_index != ~0 &&
553  pool_is_free_index (vcm->tables, ip4_table_index))
554  return VNET_API_ERROR_NO_SUCH_TABLE;
555 
556  if (ip6_table_index != ~0 &&
557  pool_is_free_index (vcm->tables, ip6_table_index))
558  return VNET_API_ERROR_NO_SUCH_TABLE2;
559 
560  if (other_table_index != ~0 &&
561  pool_is_free_index (vcm->tables, other_table_index))
562  return VNET_API_ERROR_NO_SUCH_TABLE3;
563 
565  (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP4],
566  sw_if_index);
567 
569  (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP6],
570  sw_if_index);
571 
573  (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_OTHER],
574  sw_if_index);
575 
576  cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP4]
577  [sw_if_index] = ip4_table_index;
578 
579  cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP6]
580  [sw_if_index] = ip6_table_index;
581 
582  cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_OTHER]
583  [sw_if_index] = other_table_index;
584 
585  return 0;
586 }
587 
588 static clib_error_t *
590  unformat_input_t * input,
591  vlib_cli_command_t * cmd)
592 {
593  vnet_main_t *vnm = vnet_get_main ();
594  u32 sw_if_index = ~0;
595  u32 ip4_table_index = ~0;
596  u32 ip6_table_index = ~0;
597  u32 other_table_index = ~0;
598  int rv;
599 
601  {
602  if (unformat (input, "intfc %U", unformat_vnet_sw_interface,
603  vnm, &sw_if_index))
604  ;
605  else if (unformat (input, "ip4-table %d", &ip4_table_index))
606  ;
607  else if (unformat (input, "ip6-table %d", &ip6_table_index))
608  ;
609  else if (unformat (input, "other-table %d", &other_table_index))
610  ;
611  else
612  break;
613  }
614 
615  if (sw_if_index == ~0)
616  return clib_error_return (0, "interface must be specified");
617 
618 
619  if (ip4_table_index == ~0 && ip6_table_index == ~0
620  && other_table_index == ~0)
621  {
622  vlib_cli_output (vm, "L2 classification disabled");
623  vnet_l2_output_classify_enable_disable (sw_if_index, 0 /* enable */ );
624  return 0;
625  }
626 
627  rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
628  ip6_table_index,
629  other_table_index);
630  switch (rv)
631  {
632  case 0:
633  vnet_l2_output_classify_enable_disable (sw_if_index, 1 /* enable */ );
634  break;
635 
636  default:
637  return clib_error_return (0, "vnet_l2_output_classify_set_tables: %d",
638  rv);
639  break;
640  }
641 
642  return 0;
643 }
644 
645 /*?
646  * Configure Layer 2 output classification.
647  *
648  * @cliexpar
649  * @cliexstart{set interface l2 output classify intfc <interface-name> [ip4-table <index>] [ip6-table <index>] [other-table <index>]}
650  * @cliexend
651  * @todo This is incomplete. This needs a detailed description and a
652  * practical example.
653 ?*/
654 /* *INDENT-OFF* */
655 VLIB_CLI_COMMAND (int_l2_output_classify_cli, static) = {
656  .path = "set interface l2 output classify",
657  .short_help =
658  "set interface l2 output classify intfc <<interface-name>> [ip4-table <n>]\n"
659  " [ip6-table <n>] [other-table <n>]",
661 };
662 /* *INDENT-ON* */
663 
664 /*
665  * fd.io coding-style-patch-verification: ON
666  *
667  * Local Variables:
668  * eval: (c-set-style "gnu")
669  * End:
670  */
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) ...
Definition: vec.h:436
int vnet_l2_output_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface output classification tables.
l2_output_classify_main_t * l2cm
l2 input classifier main object pointer
#define CLIB_UNUSED(x)
Definition: clib.h:79
char ** l2output_get_feat_names(void)
Definition: l2_output.c:38
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:468
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
VLIB_NODE_FUNCTION_MULTIARCH(l2_output_classify_node, l2_output_classify_node_fn)
#define PREDICT_TRUE(x)
Definition: clib.h:98
void vnet_l2_output_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:192
clib_error_t * l2_output_classify_init(vlib_main_t *vm)
l2 output classsifier feature initialization.
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.
Definition: main.c:459
static uword l2_output_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
l2 output classifier node.
struct _vlib_node_registration vlib_node_registration_t
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unformat_function_t unformat_vnet_sw_interface
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:419
static char * l2_output_classify_error_strings[]
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:164
#define clib_error_return(e, args...)
Definition: error.h:99
unsigned long u64
Definition: types.h:89
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
void l2output_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_output.c:639
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
static u8 * format_l2_output_classify_trace(u8 *s, va_list *args)
Packet trace format function.
u32 sw_if_index
interface handle for the ith packet
struct _l2_classify_main l2_output_classify_main_t
Definition: l2_classify.h:86
l2_output_classify_main_t l2_output_classify_main
l2 output classifier main data structure.
struct _unformat_input_t unformat_input_t
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
VLIB_WORKER_INIT_FUNCTION(l2_output_classify_worker_init)
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
Definition: node_funcs.h:109
#define PREDICT_FALSE(x)
Definition: clib.h:97
u32 node_index
Node index.
Definition: node.h:441
#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:216
#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:366
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:113
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1131
l2_output_classify_next_t
Definition: l2_classify.h:55
clib_error_t * l2_output_classify_worker_init(vlib_main_t *vm)
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u16 n_vectors
Definition: node.h:345
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
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
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:85
vnet_classify_main_t * vcm
use-case independent main object pointer
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:238
#define ARRAY_LEN(x)
Definition: clib.h:59
u32 table_index
classifier table which provided the final result
#define foreach_l2_output_classify_error
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:72
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:460
unsigned int u32
Definition: types.h:88
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:201
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:260
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:22
static clib_error_t * int_l2_output_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
l2_output_classify_error_t
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:269
u32 session_offset
offset in classifier heap of the corresponding session
vlib_node_registration_t l2_output_classify_node
(constructor) VLIB_REGISTER_NODE (l2_output_classify_node)
#define vnet_buffer(b)
Definition: buffer.h:303
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:144
u32 next_index
graph arc index selected for this packet
u8 data[0]
Packet data.
Definition: buffer.h:152
u16 flags
Copy of main node flags.
Definition: node.h:454
static void l2_output_dispatch(vlib_main_t *vlib_main, vnet_main_t *vnet_main, vlib_node_runtime_t *node, u32 node_index, u32 *cached_sw_if_index, u32 *cached_next_index, l2_output_next_nodes_st *next_nodes, vlib_buffer_t *b0, u32 sw_if_index, u32 feature_bitmap, u32 *next0)
Determine the next L2 node based on the output feature bitmap.
Definition: l2_output.h:168
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169