FD.io VPP  v17.04.2-2-ga8f93f8
Vector Packet Processing
mpls_lookup.c
Go to the documentation of this file.
1 /*
2  * mpls_lookup.c: MPLS lookup
3  *
4  * Copyright (c) 2012-2014 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vlib/vlib.h>
19 #include <vnet/pg/pg.h>
20 #include <vnet/mpls/mpls_lookup.h>
21 #include <vnet/fib/mpls_fib.h>
22 #include <vnet/dpo/load_balance.h>
23 
24 
25 /**
26  * Static MPLS VLIB forwarding node
27  */
29 
30 /**
31  * The arc/edge from the MPLS lookup node to the MPLS replicate node
32  */
33 
34 typedef struct {
41 
42 static u8 *
43 format_mpls_lookup_trace (u8 * s, va_list * args)
44 {
45  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
46  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
47  mpls_lookup_trace_t * t = va_arg (*args, mpls_lookup_trace_t *);
48 
49  s = format (s, "MPLS: next [%d], lookup fib index %d, LB index %d hash %x "
50  "label %d eos %d",
51  t->next_index, t->lfib_index, t->lb_index, t->hash,
53  clib_net_to_host_u32(t->label_net_byte_order)),
55  return s;
56 }
57 
58 static inline uword
60  vlib_node_runtime_t * node,
61  vlib_frame_t * from_frame)
62 {
64  u32 n_left_from, next_index, * from, * to_next;
65  mpls_main_t * mm = &mpls_main;
66  u32 cpu_index = os_get_cpu_number();
67 
68  from = vlib_frame_vector_args (from_frame);
69  n_left_from = from_frame->n_vectors;
70  next_index = node->cached_next_index;
71 
72  while (n_left_from > 0)
73  {
74  u32 n_left_to_next;
75 
76  vlib_get_next_frame (vm, node, next_index,
77  to_next, n_left_to_next);
78 
79  while (n_left_from >= 8 && n_left_to_next >= 4)
80  {
81  u32 lbi0, next0, lfib_index0, bi0, hash_c0;
82  const mpls_unicast_header_t * h0;
83  const load_balance_t *lb0;
84  const dpo_id_t *dpo0;
85  vlib_buffer_t * b0;
86  u32 lbi1, next1, lfib_index1, bi1, hash_c1;
87  const mpls_unicast_header_t * h1;
88  const load_balance_t *lb1;
89  const dpo_id_t *dpo1;
90  vlib_buffer_t * b1;
91  u32 lbi2, next2, lfib_index2, bi2, hash_c2;
92  const mpls_unicast_header_t * h2;
93  const load_balance_t *lb2;
94  const dpo_id_t *dpo2;
95  vlib_buffer_t * b2;
96  u32 lbi3, next3, lfib_index3, bi3, hash_c3;
97  const mpls_unicast_header_t * h3;
98  const load_balance_t *lb3;
99  const dpo_id_t *dpo3;
100  vlib_buffer_t * b3;
101 
102  /* Prefetch next iteration. */
103  {
104  vlib_buffer_t * p2, * p3, *p4, *p5;
105 
106  p2 = vlib_get_buffer (vm, from[2]);
107  p3 = vlib_get_buffer (vm, from[3]);
108  p4 = vlib_get_buffer (vm, from[4]);
109  p5 = vlib_get_buffer (vm, from[5]);
110 
111  vlib_prefetch_buffer_header (p2, STORE);
112  vlib_prefetch_buffer_header (p3, STORE);
113  vlib_prefetch_buffer_header (p4, STORE);
114  vlib_prefetch_buffer_header (p5, STORE);
115 
116  CLIB_PREFETCH (p2->data, sizeof (h0[0]), STORE);
117  CLIB_PREFETCH (p3->data, sizeof (h0[0]), STORE);
118  CLIB_PREFETCH (p4->data, sizeof (h0[0]), STORE);
119  CLIB_PREFETCH (p5->data, sizeof (h0[0]), STORE);
120  }
121 
122  bi0 = to_next[0] = from[0];
123  bi1 = to_next[1] = from[1];
124  bi2 = to_next[2] = from[2];
125  bi3 = to_next[3] = from[3];
126 
127  from += 4;
128  n_left_from -= 4;
129  to_next += 4;
130  n_left_to_next -= 4;
131 
132  b0 = vlib_get_buffer (vm, bi0);
133  b1 = vlib_get_buffer (vm, bi1);
134  b2 = vlib_get_buffer (vm, bi2);
135  b3 = vlib_get_buffer (vm, bi3);
136  h0 = vlib_buffer_get_current (b0);
137  h1 = vlib_buffer_get_current (b1);
138  h2 = vlib_buffer_get_current (b2);
139  h3 = vlib_buffer_get_current (b3);
140 
141  lfib_index0 = vec_elt(mm->fib_index_by_sw_if_index,
142  vnet_buffer(b0)->sw_if_index[VLIB_RX]);
143  lfib_index1 = vec_elt(mm->fib_index_by_sw_if_index,
144  vnet_buffer(b1)->sw_if_index[VLIB_RX]);
145  lfib_index2 = vec_elt(mm->fib_index_by_sw_if_index,
146  vnet_buffer(b2)->sw_if_index[VLIB_RX]);
147  lfib_index3 = vec_elt(mm->fib_index_by_sw_if_index,
148  vnet_buffer(b3)->sw_if_index[VLIB_RX]);
149 
150  lbi0 = mpls_fib_table_forwarding_lookup (lfib_index0, h0);
151  lbi1 = mpls_fib_table_forwarding_lookup (lfib_index1, h1);
152  lbi2 = mpls_fib_table_forwarding_lookup (lfib_index2, h2);
153  lbi3 = mpls_fib_table_forwarding_lookup (lfib_index3, h3);
154 
155  lb0 = load_balance_get(lbi0);
156  lb1 = load_balance_get(lbi1);
157  lb2 = load_balance_get(lbi2);
158  lb3 = load_balance_get(lbi3);
159 
160  hash_c0 = vnet_buffer(b0)->ip.flow_hash = 0;
161  hash_c1 = vnet_buffer(b1)->ip.flow_hash = 0;
162  hash_c2 = vnet_buffer(b2)->ip.flow_hash = 0;
163  hash_c3 = vnet_buffer(b3)->ip.flow_hash = 0;
164 
165  if (PREDICT_FALSE(lb0->lb_n_buckets > 1))
166  {
167  hash_c0 = vnet_buffer (b0)->ip.flow_hash =
169  }
170  if (PREDICT_FALSE(lb1->lb_n_buckets > 1))
171  {
172  hash_c1 = vnet_buffer (b1)->ip.flow_hash =
174  }
175  if (PREDICT_FALSE(lb2->lb_n_buckets > 1))
176  {
177  hash_c2 = vnet_buffer (b2)->ip.flow_hash =
179  }
180  if (PREDICT_FALSE(lb3->lb_n_buckets > 1))
181  {
182  hash_c3 = vnet_buffer (b3)->ip.flow_hash =
184  }
185 
186  ASSERT (lb0->lb_n_buckets > 0);
187  ASSERT (is_pow2 (lb0->lb_n_buckets));
188  ASSERT (lb1->lb_n_buckets > 0);
189  ASSERT (is_pow2 (lb1->lb_n_buckets));
190  ASSERT (lb2->lb_n_buckets > 0);
191  ASSERT (is_pow2 (lb2->lb_n_buckets));
192  ASSERT (lb3->lb_n_buckets > 0);
193  ASSERT (is_pow2 (lb3->lb_n_buckets));
194 
195  dpo0 = load_balance_get_bucket_i(lb0,
196  (hash_c0 &
197  (lb0->lb_n_buckets_minus_1)));
198  dpo1 = load_balance_get_bucket_i(lb1,
199  (hash_c1 &
200  (lb1->lb_n_buckets_minus_1)));
201  dpo2 = load_balance_get_bucket_i(lb2,
202  (hash_c2 &
203  (lb2->lb_n_buckets_minus_1)));
204  dpo3 = load_balance_get_bucket_i(lb3,
205  (hash_c3 &
206  (lb3->lb_n_buckets_minus_1)));
207 
208  next0 = dpo0->dpoi_next_node;
209  next1 = dpo1->dpoi_next_node;
210  next2 = dpo2->dpoi_next_node;
211  next3 = dpo3->dpoi_next_node;
212 
213  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
214  vnet_buffer (b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
215  vnet_buffer (b2)->ip.adj_index[VLIB_TX] = dpo2->dpoi_index;
216  vnet_buffer (b3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index;
217 
219  (cm, cpu_index, lbi0, 1,
220  vlib_buffer_length_in_chain (vm, b0));
222  (cm, cpu_index, lbi1, 1,
223  vlib_buffer_length_in_chain (vm, b1));
225  (cm, cpu_index, lbi2, 1,
226  vlib_buffer_length_in_chain (vm, b2));
228  (cm, cpu_index, lbi3, 1,
229  vlib_buffer_length_in_chain (vm, b3));
230 
231  /*
232  * before we pop the label copy th values we need to maintain.
233  * The label header is in network byte order.
234  * last byte is the TTL.
235  * bits 2 to 4 inclusive are the EXP bits
236  */
237  vnet_buffer (b0)->mpls.ttl = ((char*)h0)[3];
238  vnet_buffer (b0)->mpls.exp = (((char*)h0)[2] & 0xe) >> 1;
239  vnet_buffer (b0)->mpls.first = 1;
240  vnet_buffer (b1)->mpls.ttl = ((char*)h1)[3];
241  vnet_buffer (b1)->mpls.exp = (((char*)h1)[2] & 0xe) >> 1;
242  vnet_buffer (b1)->mpls.first = 1;
243  vnet_buffer (b2)->mpls.ttl = ((char*)h2)[3];
244  vnet_buffer (b2)->mpls.exp = (((char*)h2)[2] & 0xe) >> 1;
245  vnet_buffer (b2)->mpls.first = 1;
246  vnet_buffer (b3)->mpls.ttl = ((char*)h3)[3];
247  vnet_buffer (b3)->mpls.exp = (((char*)h3)[2] & 0xe) >> 1;
248  vnet_buffer (b3)->mpls.first = 1;
249 
250  /*
251  * pop the label that was just used in the lookup
252  */
253  vlib_buffer_advance(b0, sizeof(*h0));
254  vlib_buffer_advance(b1, sizeof(*h1));
255  vlib_buffer_advance(b2, sizeof(*h2));
256  vlib_buffer_advance(b3, sizeof(*h3));
257 
259  {
260  mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
261  b0, sizeof (*tr));
262  tr->next_index = next0;
263  tr->lb_index = lbi0;
264  tr->lfib_index = lfib_index0;
265  tr->hash = hash_c0;
267  }
268 
270  {
271  mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
272  b1, sizeof (*tr));
273  tr->next_index = next1;
274  tr->lb_index = lbi1;
275  tr->lfib_index = lfib_index1;
276  tr->hash = hash_c1;
278  }
279 
281  {
282  mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
283  b2, sizeof (*tr));
284  tr->next_index = next2;
285  tr->lb_index = lbi2;
286  tr->lfib_index = lfib_index2;
287  tr->hash = hash_c2;
289  }
290 
292  {
293  mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
294  b3, sizeof (*tr));
295  tr->next_index = next3;
296  tr->lb_index = lbi3;
297  tr->lfib_index = lfib_index3;
298  tr->hash = hash_c3;
300  }
301 
302  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
303  to_next, n_left_to_next,
304  bi0, bi1, bi2, bi3,
305  next0, next1, next2, next3);
306  }
307 
308  while (n_left_from > 0 && n_left_to_next > 0)
309  {
310  u32 lbi0, next0, lfib_index0, bi0, hash_c0;
311  const mpls_unicast_header_t * h0;
312  const load_balance_t *lb0;
313  const dpo_id_t *dpo0;
314  vlib_buffer_t * b0;
315 
316  bi0 = from[0];
317  to_next[0] = bi0;
318  from += 1;
319  to_next += 1;
320  n_left_from -= 1;
321  n_left_to_next -= 1;
322 
323  b0 = vlib_get_buffer (vm, bi0);
324  h0 = vlib_buffer_get_current (b0);
325 
326  lfib_index0 = vec_elt(mm->fib_index_by_sw_if_index,
327  vnet_buffer(b0)->sw_if_index[VLIB_RX]);
328 
329  lbi0 = mpls_fib_table_forwarding_lookup(lfib_index0, h0);
330  lb0 = load_balance_get(lbi0);
331 
332  hash_c0 = vnet_buffer(b0)->ip.flow_hash = 0;
333  if (PREDICT_FALSE(lb0->lb_n_buckets > 1))
334  {
335  hash_c0 = vnet_buffer (b0)->ip.flow_hash =
337  }
338 
339  ASSERT (lb0->lb_n_buckets > 0);
340  ASSERT (is_pow2 (lb0->lb_n_buckets));
341 
342  dpo0 = load_balance_get_bucket_i(lb0,
343  (hash_c0 &
344  (lb0->lb_n_buckets_minus_1)));
345 
346  next0 = dpo0->dpoi_next_node;
347  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
348 
350  (cm, cpu_index, lbi0, 1,
351  vlib_buffer_length_in_chain (vm, b0));
352 
353  /*
354  * before we pop the label copy th values we need to maintain.
355  * The label header is in network byte order.
356  * last byte is the TTL.
357  * bits 2 to 4 inclusive are the EXP bits
358  */
359  vnet_buffer (b0)->mpls.ttl = ((char*)h0)[3];
360  vnet_buffer (b0)->mpls.exp = (((char*)h0)[2] & 0xe) >> 1;
361  vnet_buffer (b0)->mpls.first = 1;
362 
363  /*
364  * pop the label that was just used in the lookup
365  */
366  vlib_buffer_advance(b0, sizeof(*h0));
367 
369  {
370  mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
371  b0, sizeof (*tr));
372  tr->next_index = next0;
373  tr->lb_index = lbi0;
374  tr->lfib_index = lfib_index0;
375  tr->hash = hash_c0;
377  }
378 
379  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
380  to_next, n_left_to_next,
381  bi0, next0);
382  }
383 
384  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
385  }
387  MPLS_ERROR_PKTS_DECAP, from_frame->n_vectors);
388  return from_frame->n_vectors;
389 }
390 
391 static char * mpls_error_strings[] = {
392 #define mpls_error(n,s) s,
393 #include "error.def"
394 #undef mpls_error
395 };
396 
398  .function = mpls_lookup,
399  .name = "mpls-lookup",
400  /* Takes a vector of packets. */
401  .vector_size = sizeof (u32),
402  .n_errors = MPLS_N_ERROR,
403  .error_strings = mpls_error_strings,
404 
405  .sibling_of = "ip4-lookup",
406 
407  .format_buffer = format_mpls_header,
408  .format_trace = format_mpls_lookup_trace,
409  .unformat_buffer = unformat_mpls_header,
410 };
411 
413 
414 typedef struct {
419 
420 static u8 *
421 format_mpls_load_balance_trace (u8 * s, va_list * args)
422 {
423  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
424  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
426 
427  s = format (s, "MPLS: next [%d], LB index %d hash %d",
428  t->next_index, t->lb_index, t->hash);
429  return s;
430 }
431 
434  vlib_node_runtime_t * node,
435  vlib_frame_t * frame)
436 {
438  u32 n_left_from, n_left_to_next, * from, * to_next;
439  u32 cpu_index = os_get_cpu_number();
440  u32 next;
441 
442  from = vlib_frame_vector_args (frame);
443  n_left_from = frame->n_vectors;
444  next = node->cached_next_index;
445 
446  while (n_left_from > 0)
447  {
448  vlib_get_next_frame (vm, node, next,
449  to_next, n_left_to_next);
450 
451 
452  while (n_left_from >= 4 && n_left_to_next >= 2)
453  {
454  const load_balance_t *lb0, *lb1;
455  vlib_buffer_t * p0, *p1;
456  u32 pi0, lbi0, hc0, pi1, lbi1, hc1, next0, next1;
457  const mpls_unicast_header_t *mpls0, *mpls1;
458  const dpo_id_t *dpo0, *dpo1;
459 
460  /* Prefetch next iteration. */
461  {
462  vlib_buffer_t * p2, * p3;
463 
464  p2 = vlib_get_buffer (vm, from[2]);
465  p3 = vlib_get_buffer (vm, from[3]);
466 
467  vlib_prefetch_buffer_header (p2, STORE);
468  vlib_prefetch_buffer_header (p3, STORE);
469 
470  CLIB_PREFETCH (p2->data, sizeof (mpls0[0]), STORE);
471  CLIB_PREFETCH (p3->data, sizeof (mpls0[0]), STORE);
472  }
473 
474  pi0 = to_next[0] = from[0];
475  pi1 = to_next[1] = from[1];
476 
477  from += 2;
478  n_left_from -= 2;
479  to_next += 2;
480  n_left_to_next -= 2;
481 
482  p0 = vlib_get_buffer (vm, pi0);
483  p1 = vlib_get_buffer (vm, pi1);
484 
485  mpls0 = vlib_buffer_get_current (p0);
486  mpls1 = vlib_buffer_get_current (p1);
487  lbi0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
488  lbi1 = vnet_buffer (p1)->ip.adj_index[VLIB_TX];
489 
490  lb0 = load_balance_get(lbi0);
491  lb1 = load_balance_get(lbi1);
492 
493  /*
494  * this node is for via FIBs we can re-use the hash value from the
495  * to node if present.
496  * We don't want to use the same hash value at each level in the recursion
497  * graph as that would lead to polarisation
498  */
499  hc0 = vnet_buffer (p0)->ip.flow_hash = 0;
500  hc1 = vnet_buffer (p1)->ip.flow_hash = 0;
501 
502  if (PREDICT_FALSE (lb0->lb_n_buckets > 1))
503  {
504  if (PREDICT_TRUE (vnet_buffer(p0)->ip.flow_hash))
505  {
506  hc0 = vnet_buffer(p0)->ip.flow_hash = vnet_buffer(p0)->ip.flow_hash >> 1;
507  }
508  else
509  {
510  hc0 = vnet_buffer(p0)->ip.flow_hash = mpls_compute_flow_hash(mpls0, hc0);
511  }
512  }
513  if (PREDICT_FALSE (lb1->lb_n_buckets > 1))
514  {
515  if (PREDICT_TRUE (vnet_buffer(p1)->ip.flow_hash))
516  {
517  hc1 = vnet_buffer(p1)->ip.flow_hash = vnet_buffer(p1)->ip.flow_hash >> 1;
518  }
519  else
520  {
521  hc1 = vnet_buffer(p1)->ip.flow_hash = mpls_compute_flow_hash(mpls1, hc1);
522  }
523  }
524 
525  dpo0 = load_balance_get_bucket_i(lb0, hc0 & (lb0->lb_n_buckets_minus_1));
526  dpo1 = load_balance_get_bucket_i(lb1, hc1 & (lb1->lb_n_buckets_minus_1));
527 
528  next0 = dpo0->dpoi_next_node;
529  next1 = dpo1->dpoi_next_node;
530 
531  vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
532  vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
533 
535  (cm, cpu_index, lbi0, 1,
536  vlib_buffer_length_in_chain (vm, p0));
538  (cm, cpu_index, lbi1, 1,
539  vlib_buffer_length_in_chain (vm, p1));
540 
542  {
544  p0, sizeof (*tr));
545  tr->next_index = next0;
546  tr->lb_index = lbi0;
547  tr->hash = hc0;
548  }
549 
550  vlib_validate_buffer_enqueue_x2 (vm, node, next,
551  to_next, n_left_to_next,
552  pi0, pi1, next0, next1);
553  }
554 
555  while (n_left_from > 0 && n_left_to_next > 0)
556  {
557  const load_balance_t *lb0;
558  vlib_buffer_t * p0;
559  u32 pi0, lbi0, hc0, next0;
560  const mpls_unicast_header_t *mpls0;
561  const dpo_id_t *dpo0;
562 
563  pi0 = from[0];
564  to_next[0] = pi0;
565  from += 1;
566  to_next += 1;
567  n_left_to_next -= 1;
568  n_left_from -= 1;
569 
570  p0 = vlib_get_buffer (vm, pi0);
571 
572  mpls0 = vlib_buffer_get_current (p0);
573  lbi0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
574 
575  lb0 = load_balance_get(lbi0);
576 
577  hc0 = vnet_buffer (p0)->ip.flow_hash = 0;
578  if (PREDICT_FALSE (lb0->lb_n_buckets > 1))
579  {
580  if (PREDICT_TRUE (vnet_buffer(p0)->ip.flow_hash))
581  {
582  hc0 = vnet_buffer(p0)->ip.flow_hash = vnet_buffer(p0)->ip.flow_hash >> 1;
583  }
584  else
585  {
586  hc0 = vnet_buffer(p0)->ip.flow_hash = mpls_compute_flow_hash(mpls0, hc0);
587  }
588  }
589 
590  dpo0 = load_balance_get_bucket_i(lb0, hc0 & (lb0->lb_n_buckets_minus_1));
591 
592  next0 = dpo0->dpoi_next_node;
593  vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
594 
596  (cm, cpu_index, lbi0, 1,
597  vlib_buffer_length_in_chain (vm, p0));
598 
599  vlib_validate_buffer_enqueue_x1 (vm, node, next,
600  to_next, n_left_to_next,
601  pi0, next0);
602  }
603 
604  vlib_put_next_frame (vm, node, next, n_left_to_next);
605  }
606 
607  return frame->n_vectors;
608 }
609 
611  .function = mpls_load_balance,
612  .name = "mpls-load-balance",
613  .vector_size = sizeof (u32),
614  .sibling_of = "mpls-lookup",
615 
616  .format_trace = format_mpls_load_balance_trace,
617 };
618 
u16 lb_n_buckets
number of buckets in the load-balance.
Definition: load_balance.h:88
vlib_combined_counter_main_t lbm_to_counters
Definition: load_balance.h:46
#define CLIB_UNUSED(x)
Definition: clib.h:79
format_function_t format_mpls_header
Definition: mpls.h:92
The arc/edge from the MPLS lookup node to the MPLS replicate node.
Definition: mpls_lookup.c:34
#define PREDICT_TRUE(x)
Definition: clib.h:98
u32 * fib_index_by_sw_if_index
Definition: mpls.h:65
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
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
Definition: load_balance.h:128
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
Definition: buffer_node.h:138
struct _vlib_node_registration vlib_node_registration_t
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:100
#define always_inline
Definition: clib.h:84
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
Definition: load_balance.h:93
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:164
static uword mpls_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: mpls_lookup.c:59
vlib_node_registration_t mpls_lookup_node
Static MPLS VLIB forwarding node.
Definition: mpls_lookup.c:28
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:146
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
Definition: load_balance.h:202
static u32 mpls_compute_flow_hash(const mpls_unicast_header_t *hdr, flow_hash_config_t flow_hash_config)
Definition: mpls_lookup.h:27
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
The FIB DPO provieds;.
Definition: load_balance.h:84
#define PREDICT_FALSE(x)
Definition: clib.h:97
static u32 vnet_mpls_uc_get_label(mpls_label_t label_exp_s_ttl)
Definition: packet.h:77
load_balance_main_t load_balance_main
The one instance of load-balance main.
Definition: load_balance.c:55
#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
#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:350
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1115
u16 n_vectors
Definition: node.h:344
mpls_main_t mpls_main
Definition: mpls.c:25
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
vlib_main_t * vm
Definition: buffer.c:276
unformat_function_t unformat_mpls_header
Definition: mpls.h:106
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:85
vlib_combined_counter_main_t lbm_via_counters
Definition: load_balance.h:47
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:455
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:211
static load_balance_t * load_balance_get(index_t lbi)
Definition: load_balance.h:193
static char * mpls_error_strings[]
Definition: mpls_lookup.c:391
mpls_label_t label_exp_s_ttl
Definition: packet.h:31
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:201
static uword mpls_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: mpls_lookup.c:433
static uword is_pow2(uword x)
Definition: clib.h:272
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
#define vec_elt(v, i)
Get vector value at index i.
Definition: defs.h:47
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:162
static u32 vnet_mpls_uc_get_s(mpls_label_t label_exp_s_ttl)
Definition: packet.h:87
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:253
A collection of combined counters.
Definition: counter.h:180
static index_t mpls_fib_table_forwarding_lookup(u32 mpls_fib_index, const mpls_unicast_header_t *hdr)
Lookup a label and EOS bit in the MPLS_FIB table to retrieve the load-balance index to be used for pa...
Definition: mpls_fib.h:86
#define vnet_buffer(b)
Definition: buffer.h:294
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
static u8 * format_mpls_load_balance_trace(u8 *s, va_list *args)
Definition: mpls_lookup.c:421
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 data[0]
Packet data.
Definition: buffer.h:152
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:158
static u8 * format_mpls_lookup_trace(u8 *s, va_list *args)
Definition: mpls_lookup.c:43
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
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
Definition: defs.h:46
vlib_node_registration_t mpls_load_balance_node
(constructor) VLIB_REGISTER_NODE (mpls_load_balance_node)
Definition: mpls_lookup.c:610