FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
node.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 #include <vnet/vnet.h>
16 #include <vppinfra/vec.h>
17 #include <vppinfra/error.h>
18 #include <vppinfra/format.h>
19 #include <vppinfra/xxhash.h>
20 
21 #include <vnet/ethernet/ethernet.h>
22 #include <dpdk/device/dpdk.h>
24 #include <vnet/mpls/packet.h>
25 #include <vnet/handoff.h>
26 #include <vnet/devices/devices.h>
27 #include <vnet/feature/feature.h>
28 
29 #include <dpdk/device/dpdk_priv.h>
30 
31 static char *dpdk_error_strings[] = {
32 #define _(n,s) s,
34 #undef _
35 };
36 
37 always_inline int
39 {
41  return (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP4));
42 }
43 
44 always_inline int
46 {
48  return (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6));
49 }
50 
51 always_inline int
53 {
55  return (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS));
56 }
57 
59 dpdk_rx_next_from_etype (struct rte_mbuf * mb, vlib_buffer_t * b0)
60 {
62  {
63  if (PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
65  else
67  }
68  else if (PREDICT_TRUE (vlib_buffer_is_ip6 (b0)))
70  else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
72  else
74 }
75 
77 dpdk_rx_next_from_packet_start (struct rte_mbuf * mb, vlib_buffer_t * b0)
78 {
79  word start_delta;
80  int rv;
81 
82  start_delta = b0->current_data -
83  ((mb->buf_addr + mb->data_off) - (void *) b0->data);
84 
85  vlib_buffer_advance (b0, -start_delta);
86 
88  {
89  if (PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
91  else
93  }
94  else if (PREDICT_TRUE (vlib_buffer_is_ip6 (b0)))
96  else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
98  else
100 
101  vlib_buffer_advance (b0, start_delta);
102  return rv;
103 }
104 
105 always_inline void
106 dpdk_rx_error_from_mb (struct rte_mbuf *mb, u32 * next, u8 * error)
107 {
108  if (mb->ol_flags & PKT_RX_IP_CKSUM_BAD)
109  {
110  *error = DPDK_ERROR_IP_CHECKSUM_ERROR;
112  }
113  else
114  *error = DPDK_ERROR_NONE;
115 }
116 
117 static void
119  vlib_node_runtime_t * node,
120  dpdk_device_t * xd,
121  u16 queue_id, u32 * buffers, uword n_buffers)
122 {
124  u32 *b, n_left;
125  u32 next0;
126 
127  n_left = n_buffers;
128  b = buffers;
129 
130  while (n_left >= 1)
131  {
132  u32 bi0;
133  vlib_buffer_t *b0;
135  struct rte_mbuf *mb;
136  u8 error0;
137 
138  bi0 = b[0];
139  n_left -= 1;
140 
141  b0 = vlib_get_buffer (vm, bi0);
142  mb = rte_mbuf_from_vlib_buffer (b0);
143 
144  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
145  next0 = xd->per_interface_next_index;
146  else
147  next0 = dpdk_rx_next_from_packet_start (mb, b0);
148 
149  dpdk_rx_error_from_mb (mb, &next0, &error0);
150 
151  vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0);
152  t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
153  t0->queue_index = queue_id;
154  t0->device_index = xd->device_index;
155  t0->buffer_index = bi0;
156 
157  clib_memcpy (&t0->mb, mb, sizeof (t0->mb));
158  clib_memcpy (&t0->buffer, b0, sizeof (b0[0]) - sizeof (b0->pre_data));
159  clib_memcpy (t0->buffer.pre_data, b0->data,
160  sizeof (t0->buffer.pre_data));
161  clib_memcpy (&t0->data, mb->buf_addr + mb->data_off, sizeof (t0->data));
162 
163  b += 1;
164  }
165 }
166 
167 static inline u32
169 {
170  u32 n_buffers;
171  u32 n_left;
172  u32 n_this_chunk;
173 
174  n_left = VLIB_FRAME_SIZE;
175  n_buffers = 0;
176 
178  {
179  while (n_left)
180  {
181  n_this_chunk = rte_eth_rx_burst (xd->device_index, queue_id,
182  xd->rx_vectors[queue_id] +
183  n_buffers, n_left);
184  n_buffers += n_this_chunk;
185  n_left -= n_this_chunk;
186 
187  /* Empirically, DPDK r1.8 produces vectors w/ 32 or fewer elts */
188  if (n_this_chunk < 32)
189  break;
190  }
191  }
192  else
193  {
194  ASSERT (0);
195  }
196 
197  return n_buffers;
198 }
199 
200 
203  struct rte_mbuf *mb, vlib_buffer_free_list_t * fl)
204 {
205  u8 nb_seg = 1;
206  struct rte_mbuf *mb_seg = 0;
207  vlib_buffer_t *b_seg, *b_chain = 0;
208  mb_seg = mb->next;
209  b_chain = b;
210 
211  if (mb->nb_segs < 2)
212  return;
213 
216 
217  while (nb_seg < mb->nb_segs)
218  {
219  ASSERT (mb_seg != 0);
220 
221  b_seg = vlib_buffer_from_rte_mbuf (mb_seg);
222  vlib_buffer_init_for_free_list (b_seg, fl);
223 
224  ASSERT ((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
225  ASSERT (b_seg->current_data == 0);
226 
227  /*
228  * The driver (e.g. virtio) may not put the packet data at the start
229  * of the segment, so don't assume b_seg->current_data == 0 is correct.
230  */
231  b_seg->current_data =
232  (mb_seg->buf_addr + mb_seg->data_off) - (void *) b_seg->data;
233 
234  b_seg->current_length = mb_seg->data_len;
235  b->total_length_not_including_first_buffer += mb_seg->data_len;
236 
237  b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT;
238  b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg);
239 
240  b_chain = b_seg;
241  mb_seg = mb_seg->next;
242  nb_seg++;
243  }
244 }
245 
247 dpdk_prefetch_buffer (struct rte_mbuf *mb)
248 {
252 }
253 
255 dpdk_prefetch_ethertype (struct rte_mbuf *mb)
256 {
257  CLIB_PREFETCH (mb->buf_addr + mb->data_off +
259  CLIB_CACHE_LINE_BYTES, LOAD);
260 }
261 
262 
263 /*
264  This function should fill 1st cacheline of vlib_buffer_t metadata with data
265  from buffer template. Instead of filling field by field, we construct
266  template and then use 128/256 bit vector instruction to copy data.
267  This code first loads whole cacheline into 4 128-bit registers (xmm)
268  or two 256 bit registers (ymm) and then stores data into all 4 buffers
269  efectively saving on register load operations.
270 */
271 
273 dpdk_buffer_init_from_template (void *d0, void *d1, void *d2, void *d3,
274  void *s)
275 {
276 #if defined(CLIB_HAVE_VEC128)
277  int i;
278  for (i = 0; i < 2; i++)
279  {
280  *(u8x32 *) (((u8 *) d0) + i * 32) =
281  *(u8x32 *) (((u8 *) d1) + i * 32) =
282  *(u8x32 *) (((u8 *) d2) + i * 32) =
283  *(u8x32 *) (((u8 *) d3) + i * 32) = *(u8x32 *) (((u8 *) s) + i * 32);
284  }
285 #elif defined(CLIB_HAVE_VEC64)
286  int i;
287  for (i = 0; i < 4; i++)
288  {
289  *(u8x16 *) (((u8 *) d0) + i * 16) =
290  *(u8x16 *) (((u8 *) d1) + i * 16) =
291  *(u8x16 *) (((u8 *) d2) + i * 16) =
292  *(u8x16 *) (((u8 *) d3) + i * 16) = *(u8x16 *) (((u8 *) s) + i * 16);
293  }
294 #else
295 #error "Either CLIB_HAVE_VEC128 or CLIB_HAVE_VEC64 has to be defined"
296 #endif
297 }
298 
299 /*
300  * This function is used when there are no worker threads.
301  * The main thread performs IO and forwards the packets.
302  */
305  vlib_node_runtime_t * node, u32 thread_index, u16 queue_id,
306  int maybe_multiseg)
307 {
308  u32 n_buffers;
310  u32 n_left_to_next, *to_next;
311  u32 mb_index;
313  uword n_rx_bytes = 0;
314  u32 n_trace, trace_cnt __attribute__ ((unused));
316  vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, thread_index);
317 
318  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
319  return 0;
320 
321  n_buffers = dpdk_rx_burst (dm, xd, queue_id);
322 
323  if (n_buffers == 0)
324  {
325  return 0;
326  }
327 
328  vec_reset_length (xd->d_trace_buffers[thread_index]);
329  trace_cnt = n_trace = vlib_get_trace_count (vm, node);
330 
331  if (n_trace > 0)
332  {
333  u32 n = clib_min (n_trace, n_buffers);
334  mb_index = 0;
335 
336  while (n--)
337  {
338  struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++];
340  vec_add1 (xd->d_trace_buffers[thread_index],
341  vlib_get_buffer_index (vm, b));
342  }
343  }
344 
346 
347  /* Update buffer template */
348  vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
349  bt->error = node->errors[DPDK_ERROR_NONE];
350 
351  mb_index = 0;
352 
353  while (n_buffers > 0)
354  {
355  vlib_buffer_t *b0, *b1, *b2, *b3;
356  u32 bi0, next0;
357  u32 bi1, next1;
358  u32 bi2, next2;
359  u32 bi3, next3;
360  u8 error0, error1, error2, error3;
361  u64 or_ol_flags;
362 
363  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
364 
365  while (n_buffers >= 12 && n_left_to_next >= 4)
366  {
367  struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
368 
369  /* prefetches are interleaved with the rest of the code to reduce
370  pressure on L1 cache */
371  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 8]);
372  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 4]);
373 
374  mb0 = xd->rx_vectors[queue_id][mb_index];
375  mb1 = xd->rx_vectors[queue_id][mb_index + 1];
376  mb2 = xd->rx_vectors[queue_id][mb_index + 2];
377  mb3 = xd->rx_vectors[queue_id][mb_index + 3];
378 
379  ASSERT (mb0);
380  ASSERT (mb1);
381  ASSERT (mb2);
382  ASSERT (mb3);
383 
384  if (maybe_multiseg)
385  {
386  if (PREDICT_FALSE (mb0->nb_segs > 1))
387  dpdk_prefetch_buffer (mb0->next);
388  if (PREDICT_FALSE (mb1->nb_segs > 1))
389  dpdk_prefetch_buffer (mb1->next);
390  if (PREDICT_FALSE (mb2->nb_segs > 1))
391  dpdk_prefetch_buffer (mb2->next);
392  if (PREDICT_FALSE (mb3->nb_segs > 1))
393  dpdk_prefetch_buffer (mb3->next);
394  }
395 
396  b0 = vlib_buffer_from_rte_mbuf (mb0);
397  b1 = vlib_buffer_from_rte_mbuf (mb1);
398  b2 = vlib_buffer_from_rte_mbuf (mb2);
399  b3 = vlib_buffer_from_rte_mbuf (mb3);
400 
401  dpdk_buffer_init_from_template (b0, b1, b2, b3, bt);
402 
403  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 9]);
404  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 5]);
405 
406  /* current_data must be set to -RTE_PKTMBUF_HEADROOM in template */
407  b0->current_data += mb0->data_off;
408  b1->current_data += mb1->data_off;
409  b2->current_data += mb2->data_off;
410  b3->current_data += mb3->data_off;
411 
412  b0->current_length = mb0->data_len;
413  b1->current_length = mb1->data_len;
414  b2->current_length = mb2->data_len;
415  b3->current_length = mb3->data_len;
416 
417  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 10]);
418  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 7]);
419 
420  bi0 = vlib_get_buffer_index (vm, b0);
421  bi1 = vlib_get_buffer_index (vm, b1);
422  bi2 = vlib_get_buffer_index (vm, b2);
423  bi3 = vlib_get_buffer_index (vm, b3);
424 
425  to_next[0] = bi0;
426  to_next[1] = bi1;
427  to_next[2] = bi2;
428  to_next[3] = bi3;
429  to_next += 4;
430  n_left_to_next -= 4;
431 
432  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
433  {
434  next0 = next1 = next2 = next3 = xd->per_interface_next_index;
435  }
436  else
437  {
438  next0 = dpdk_rx_next_from_etype (mb0, b0);
439  next1 = dpdk_rx_next_from_etype (mb1, b1);
440  next2 = dpdk_rx_next_from_etype (mb2, b2);
441  next3 = dpdk_rx_next_from_etype (mb3, b3);
442  }
443 
444  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 11]);
445  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 6]);
446 
447  or_ol_flags = (mb0->ol_flags | mb1->ol_flags |
448  mb2->ol_flags | mb3->ol_flags);
449  if (PREDICT_FALSE (or_ol_flags & PKT_RX_IP_CKSUM_BAD))
450  {
451  dpdk_rx_error_from_mb (mb0, &next0, &error0);
452  dpdk_rx_error_from_mb (mb1, &next1, &error1);
453  dpdk_rx_error_from_mb (mb2, &next2, &error2);
454  dpdk_rx_error_from_mb (mb3, &next3, &error3);
455  b0->error = node->errors[error0];
456  b1->error = node->errors[error1];
457  b2->error = node->errors[error2];
458  b3->error = node->errors[error3];
459  }
460 
465 
466  n_rx_bytes += mb0->pkt_len;
467  n_rx_bytes += mb1->pkt_len;
468  n_rx_bytes += mb2->pkt_len;
469  n_rx_bytes += mb3->pkt_len;
470 
471  /* Process subsequent segments of multi-segment packets */
472  if (maybe_multiseg)
473  {
474  dpdk_process_subseq_segs (vm, b0, mb0, fl);
475  dpdk_process_subseq_segs (vm, b1, mb1, fl);
476  dpdk_process_subseq_segs (vm, b2, mb2, fl);
477  dpdk_process_subseq_segs (vm, b3, mb3, fl);
478  }
479 
480  /*
481  * Turn this on if you run into
482  * "bad monkey" contexts, and you want to know exactly
483  * which nodes they've visited... See main.c...
484  */
489 
490  /* Do we have any driver RX features configured on the interface? */
492  &next0, &next1, &next2, &next3,
493  b0, b1, b2, b3);
494 
495  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
496  to_next, n_left_to_next,
497  bi0, bi1, bi2, bi3,
498  next0, next1, next2, next3);
499  n_buffers -= 4;
500  mb_index += 4;
501  }
502  while (n_buffers > 0 && n_left_to_next > 0)
503  {
504  struct rte_mbuf *mb0 = xd->rx_vectors[queue_id][mb_index];
505 
506  if (PREDICT_TRUE (n_buffers > 3))
507  {
508  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 2]);
509  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id]
510  [mb_index + 1]);
511  }
512 
513  ASSERT (mb0);
514 
515  b0 = vlib_buffer_from_rte_mbuf (mb0);
516 
517  /* Prefetch one next segment if it exists. */
518  if (PREDICT_FALSE (mb0->nb_segs > 1))
519  dpdk_prefetch_buffer (mb0->next);
520 
522 
523  ASSERT (b0->current_data == -RTE_PKTMBUF_HEADROOM);
524  b0->current_data += mb0->data_off;
525  b0->current_length = mb0->data_len;
526 
527  bi0 = vlib_get_buffer_index (vm, b0);
528 
529  to_next[0] = bi0;
530  to_next++;
531  n_left_to_next--;
532 
533  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
534  next0 = xd->per_interface_next_index;
535  else
536  next0 = dpdk_rx_next_from_etype (mb0, b0);
537 
538  dpdk_rx_error_from_mb (mb0, &next0, &error0);
539  b0->error = node->errors[error0];
540 
542 
543  n_rx_bytes += mb0->pkt_len;
544 
545  /* Process subsequent segments of multi-segment packets */
546  dpdk_process_subseq_segs (vm, b0, mb0, fl);
547 
548  /*
549  * Turn this on if you run into
550  * "bad monkey" contexts, and you want to know exactly
551  * which nodes they've visited... See main.c...
552  */
554 
555  /* Do we have any driver RX features configured on the interface? */
557  b0);
558 
559  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
560  to_next, n_left_to_next,
561  bi0, next0);
562  n_buffers--;
563  mb_index++;
564  }
565  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
566  }
567 
568  if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[thread_index]) > 0))
569  {
570  dpdk_rx_trace (dm, node, xd, queue_id,
571  xd->d_trace_buffers[thread_index],
572  vec_len (xd->d_trace_buffers[thread_index]));
573  vlib_set_trace_count (vm, node,
574  n_trace -
575  vec_len (xd->d_trace_buffers[thread_index]));
576  }
577 
579  (vnet_get_main ()->interface_main.combined_sw_if_counters
581  thread_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
582 
583  vnet_device_increment_rx_packets (thread_index, mb_index);
584 
585  return mb_index;
586 }
587 
588 static inline void
590 {
591  /* Limit the poll rate by sleeping for N msec between polls */
592  if (PREDICT_FALSE (dm->poll_sleep_usec != 0))
593  {
594  struct timespec ts, tsrem;
595 
596  ts.tv_sec = 0;
597  ts.tv_nsec = 1000 * dm->poll_sleep_usec;
598 
599  while (nanosleep (&ts, &tsrem) < 0)
600  {
601  ts = tsrem;
602  }
603  }
604 }
605 
606 /** \brief Main DPDK input node
607  @node dpdk-input
608 
609  This is the main DPDK input node: across each assigned interface,
610  call rte_eth_rx_burst(...) or similar to obtain a vector of
611  packets to process. Handle early packet discard. Derive @c
612  vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata,
613  Depending on the resulting metadata: adjust <code>b->current_data,
614  b->current_length </code> and dispatch directly to
615  ip4-input-no-checksum, or ip6-input. Trace the packet if required.
616 
617  @param vm vlib_main_t corresponding to the current thread
618  @param node vlib_node_runtime_t
619  @param f vlib_frame_t input-node, not used.
620 
621  @par Graph mechanics: buffer metadata, next index usage
622 
623  @em Uses:
624  - <code>struct rte_mbuf mb->ol_flags</code>
625  - PKT_RX_IP_CKSUM_BAD
626  - <code> RTE_ETH_IS_xxx_HDR(mb->packet_type) </code>
627  - packet classification result
628 
629  @em Sets:
630  - <code>b->error</code> if the packet is to be dropped immediately
631  - <code>b->current_data, b->current_length</code>
632  - adjusted as needed to skip the L2 header in direct-dispatch cases
633  - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
634  - rx interface sw_if_index
635  - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
636  - required by ipX-lookup
637  - <code>b->flags</code>
638  - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
639 
640  <em>Next Nodes:</em>
641  - Static arcs to: error-drop, ethernet-input,
642  ip4-input-no-checksum, ip6-input, mpls-input
643  - per-interface redirection, controlled by
644  <code>xd->per_interface_next_index</code>
645 */
646 
647 static uword
649 {
650  dpdk_main_t *dm = &dpdk_main;
651  dpdk_device_t *xd;
652  uword n_rx_packets = 0;
653  vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
655  u32 thread_index = node->thread_index;
656 
657  /*
658  * Poll all devices on this cpu for input/interrupts.
659  */
660  /* *INDENT-OFF* */
662  {
663  xd = vec_elt_at_index(dm->devices, dq->dev_instance);
665  continue; /* Do not poll slave to a bonded interface */
667  n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 1);
668  else
669  n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 0);
670  }
671  /* *INDENT-ON* */
672 
673  poll_rate_limit (dm);
674 
675  return n_rx_packets;
676 }
677 
678 /* *INDENT-OFF* */
680  .function = dpdk_input,
681  .type = VLIB_NODE_TYPE_INPUT,
682  .name = "dpdk-input",
683  .sibling_of = "device-input",
684 
685  /* Will be enabled if/when hardware is detected. */
686  .state = VLIB_NODE_STATE_DISABLED,
687 
688  .format_buffer = format_ethernet_header_with_length,
689  .format_trace = format_dpdk_rx_dma_trace,
690 
691  .n_errors = DPDK_N_ERROR,
692  .error_strings = dpdk_error_strings,
693 };
694 
696 /* *INDENT-ON* */
697 
698 /*
699  * fd.io coding-style-patch-verification: ON
700  *
701  * Local Variables:
702  * eval: (c-set-style "gnu")
703  * End:
704  */
u32 ** d_trace_buffers
Definition: dpdk.h:166
static void vnet_device_increment_rx_packets(u32 thread_index, u64 count)
Definition: devices.h:109
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
vnet_device_and_queue_t * devices_and_queues
Definition: devices.h:69
static uword dpdk_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Main DPDK input node.
Definition: node.c:648
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define clib_min(x, y)
Definition: clib.h:332
static int vlib_buffer_is_mpls(vlib_buffer_t *b)
Definition: node.c:52
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:143
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:211
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:464
static void dpdk_rx_trace(dpdk_main_t *dm, vlib_node_runtime_t *node, dpdk_device_t *xd, u16 queue_id, u32 *buffers, uword n_buffers)
Definition: node.c:118
dpdk_main_t dpdk_main
Definition: init.c:37
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define PREDICT_TRUE(x)
Definition: clib.h:98
#define foreach_dpdk_error
Definition: dpdk.h:432
static_always_inline void vnet_feature_start_device_input_x4(u32 sw_if_index, u32 *next0, u32 *next1, u32 *next2, u32 *next3, vlib_buffer_t *b0, vlib_buffer_t *b1, vlib_buffer_t *b2, vlib_buffer_t *b3)
Definition: feature.h:302
u16 flags
Definition: dpdk.h:171
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
#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
u32 per_interface_next_index
Definition: dpdk.h:159
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
static int vlib_buffer_is_ip4(vlib_buffer_t *b)
Definition: node.c:38
vlib_buffer_t * buffer_templates
Definition: dpdk.h:348
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:415
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:174
static int vlib_buffer_is_ip6(vlib_buffer_t *b)
Definition: node.c:45
u16 thread_index
thread this node runs on
Definition: node.h:462
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
Definition: trace_funcs.h:104
#define VLIB_BUFFER_NEXT_PRESENT
Definition: buffer.h:95
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:68
#define static_always_inline
Definition: clib.h:85
u8 data[256]
Definition: dpdk.h:416
#define always_inline
Definition: clib.h:84
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Definition: buffer.h:97
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:149
unsigned long u64
Definition: types.h:89
#define DPDK_DEVICE_FLAG_MAYBE_MULTISEG
Definition: dpdk.h:176
u32 device_index
Definition: dpdk.h:153
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:74
static void poll_rate_limit(dpdk_main_t *dm)
Definition: node.c:589
#define fl(x, y)
struct rte_mbuf mb
Definition: dpdk.h:414
static u32 dpdk_rx_burst(dpdk_main_t *dm, dpdk_device_t *xd, u16 queue_id)
Definition: node.c:168
u32 vlib_sw_if_index
Definition: dpdk.h:156
#define rte_mbuf_from_vlib_buffer(x)
Definition: dpdk_priv.h:16
const u32 device_input_next_node_advance[((VNET_DEVICE_INPUT_N_NEXT_NODES/CLIB_CACHE_LINE_BYTES)+1)*CLIB_CACHE_LINE_BYTES]
Definition: devices.c:47
format_function_t format_dpdk_rx_dma_trace
Definition: dpdk.h:455
static_always_inline void dpdk_process_subseq_segs(vlib_main_t *vm, vlib_buffer_t *b, struct rte_mbuf *mb, vlib_buffer_free_list_t *fl)
Definition: node.c:202
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:72
static u32 dpdk_rx_next_from_etype(struct rte_mbuf *mb, vlib_buffer_t *b0)
Definition: node.c:59
static_always_inline void dpdk_prefetch_ethertype(struct rte_mbuf *mb)
Definition: node.c:255
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:193
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:422
static_always_inline void dpdk_buffer_init_from_template(void *d0, void *d1, void *d2, void *d3, void *s)
Definition: node.c:273
#define PREDICT_FALSE(x)
Definition: clib.h:97
#define VLIB_FRAME_SIZE
Definition: node.h:328
#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:364
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:113
static char * dpdk_error_strings[]
Definition: node.c:31
#define DPDK_DEVICE_FLAG_ADMIN_UP
Definition: dpdk.h:172
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:91
dpdk_device_t * devices
Definition: dpdk.h:341
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
vlib_main_t * vm
Definition: buffer.c:283
vec_header_t h
Definition: buffer.c:282
struct rte_mbuf *** rx_vectors
Definition: dpdk.h:163
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:679
#define clib_memcpy(a, b, c)
Definition: string.h:69
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:454
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static void dpdk_rx_error_from_mb(struct rte_mbuf *mb, u32 *next, u8 *error)
Definition: node.c:106
u32 poll_sleep_usec
Definition: dpdk.h:383
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:109
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:206
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
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
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
Definition: buffer.h:141
#define foreach_device_and_queue(var, vec)
Definition: devices.h:155
unsigned short u16
Definition: types.h:57
vlib_buffer_t buffer
Definition: dpdk.h:415
i64 word
Definition: types.h:111
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:517
static_always_inline u32 dpdk_device_input(dpdk_main_t *dm, dpdk_device_t *xd, vlib_node_runtime_t *node, u32 thread_index, u16 queue_id, int maybe_multiseg)
Definition: node.c:304
#define DPDK_DEVICE_FLAG_BOND_SLAVE
Definition: dpdk.h:179
static u32 dpdk_rx_next_from_packet_start(struct rte_mbuf *mb, vlib_buffer_t *b0)
Definition: node.c:77
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
Definition: buffer_funcs.h:770
#define vnet_buffer(b)
Definition: buffer.h:306
static_always_inline void vnet_feature_start_device_input_x1(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:227
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 data[0]
Packet data.
Definition: buffer.h:157
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:412
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
Definition: trace_funcs.h:159
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:75
static_always_inline void dpdk_prefetch_buffer(struct rte_mbuf *mb)
Definition: node.c:247
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
VLIB_NODE_FUNCTION_MULTIARCH(ethernet_input_not_l2_node, ethernet_input_not_l2)
Definition: node.c:1207
Definition: defs.h:46
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".