FD.io VPP  v18.01.2-1-g9b554f3
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 #ifndef CLIB_MULTIARCH_VARIANT
32 static char *dpdk_error_strings[] = {
33 #define _(n,s) s,
35 #undef _
36 };
37 #endif
38 
40 dpdk_rx_next_from_etype (struct rte_mbuf *mb)
41 {
42  ethernet_header_t *h = rte_pktmbuf_mtod (mb, ethernet_header_t *);
43  if (PREDICT_TRUE (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP4)))
44  {
45  if (PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
47  else
49  }
50  else if (PREDICT_TRUE (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6)))
52  else
53  if (PREDICT_TRUE (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS)))
55  else
57 }
58 
59 always_inline void
60 dpdk_rx_error_from_mb (struct rte_mbuf *mb, u32 * next, u8 * error)
61 {
62  if (mb->ol_flags & PKT_RX_IP_CKSUM_BAD)
63  {
64  *error = DPDK_ERROR_IP_CHECKSUM_ERROR;
66  }
67  else
68  *error = DPDK_ERROR_NONE;
69 }
70 
71 static void
73  vlib_node_runtime_t * node,
74  dpdk_device_t * xd,
75  u16 queue_id, u32 * buffers, uword n_buffers)
76 {
77  vlib_main_t *vm = vlib_get_main ();
78  u32 *b, n_left;
79  u32 next0;
80 
81  n_left = n_buffers;
82  b = buffers;
83 
84  while (n_left >= 1)
85  {
86  u32 bi0;
87  vlib_buffer_t *b0;
89  struct rte_mbuf *mb;
90  u8 error0;
91 
92  bi0 = b[0];
93  n_left -= 1;
94 
95  b0 = vlib_get_buffer (vm, bi0);
96  mb = rte_mbuf_from_vlib_buffer (b0);
97 
99  next0 = xd->per_interface_next_index;
100  else
101  next0 = dpdk_rx_next_from_etype (mb);
102 
103  dpdk_rx_error_from_mb (mb, &next0, &error0);
104 
105  vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0);
106  t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
107  t0->queue_index = queue_id;
108  t0->device_index = xd->device_index;
109  t0->buffer_index = bi0;
110 
111  clib_memcpy (&t0->mb, mb, sizeof (t0->mb));
112  clib_memcpy (&t0->buffer, b0, sizeof (b0[0]) - sizeof (b0->pre_data));
113  clib_memcpy (t0->buffer.pre_data, b0->data,
114  sizeof (t0->buffer.pre_data));
115  clib_memcpy (&t0->data, mb->buf_addr + mb->data_off, sizeof (t0->data));
116 
117  b += 1;
118  }
119 }
120 
121 static inline u32
123 {
124  u32 n_buffers;
125  u32 n_left;
126  u32 n_this_chunk;
127 
128  n_left = VLIB_FRAME_SIZE;
129  n_buffers = 0;
130 
132  {
133  while (n_left)
134  {
135  n_this_chunk = rte_eth_rx_burst (xd->device_index, queue_id,
136  xd->rx_vectors[queue_id] +
137  n_buffers, n_left);
138  n_buffers += n_this_chunk;
139  n_left -= n_this_chunk;
140 
141  /* Empirically, DPDK r1.8 produces vectors w/ 32 or fewer elts */
142  if (n_this_chunk < 32)
143  break;
144  }
145  }
146  else
147  {
148  ASSERT (0);
149  }
150 
151  return n_buffers;
152 }
153 
154 
157  struct rte_mbuf *mb, vlib_buffer_free_list_t * fl)
158 {
159  u8 nb_seg = 1;
160  struct rte_mbuf *mb_seg = 0;
161  vlib_buffer_t *b_seg, *b_chain = 0;
162  mb_seg = mb->next;
163  b_chain = b;
164 
165  if (mb->nb_segs < 2)
166  return;
167 
170 
171  while (nb_seg < mb->nb_segs)
172  {
173  ASSERT (mb_seg != 0);
174 
175  b_seg = vlib_buffer_from_rte_mbuf (mb_seg);
176  vlib_buffer_init_for_free_list (b_seg, fl);
177 
178  ASSERT ((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
179  ASSERT (b_seg->current_data == 0);
180 
181  /*
182  * The driver (e.g. virtio) may not put the packet data at the start
183  * of the segment, so don't assume b_seg->current_data == 0 is correct.
184  */
185  b_seg->current_data =
186  (mb_seg->buf_addr + mb_seg->data_off) - (void *) b_seg->data;
187 
188  b_seg->current_length = mb_seg->data_len;
189  b->total_length_not_including_first_buffer += mb_seg->data_len;
190 
191  b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT;
192  b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg);
193 
194  b_chain = b_seg;
195  mb_seg = mb_seg->next;
196  nb_seg++;
197  }
198 }
199 
201 dpdk_prefetch_buffer (struct rte_mbuf *mb)
202 {
206 }
207 
209 dpdk_prefetch_ethertype (struct rte_mbuf *mb)
210 {
211  CLIB_PREFETCH (mb->buf_addr + mb->data_off +
213  CLIB_CACHE_LINE_BYTES, LOAD);
214 }
215 
216 /*
217  * This function is used when there are no worker threads.
218  * The main thread performs IO and forwards the packets.
219  */
222  vlib_node_runtime_t * node, u32 thread_index, u16 queue_id,
223  int maybe_multiseg)
224 {
225  u32 n_buffers;
227  u32 n_left_to_next, *to_next;
228  u32 mb_index;
229  vlib_main_t *vm = vlib_get_main ();
230  uword n_rx_bytes = 0;
231  u32 n_trace, trace_cnt __attribute__ ((unused));
233  vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, thread_index);
234 
235  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
236  return 0;
237 
238  n_buffers = dpdk_rx_burst (dm, xd, queue_id);
239 
240  if (n_buffers == 0)
241  {
242  return 0;
243  }
244 
245  vec_reset_length (xd->d_trace_buffers[thread_index]);
246  trace_cnt = n_trace = vlib_get_trace_count (vm, node);
247 
248  if (n_trace > 0)
249  {
250  u32 n = clib_min (n_trace, n_buffers);
251  mb_index = 0;
252 
253  while (n--)
254  {
255  struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++];
257  vec_add1 (xd->d_trace_buffers[thread_index],
258  vlib_get_buffer_index (vm, b));
259  }
260  }
261 
263 
264  /* Update buffer template */
265  vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
266  bt->error = node->errors[DPDK_ERROR_NONE];
267  /* as DPDK is allocating empty buffers from mempool provided before interface
268  start for each queue, it is safe to store this in the template */
269  bt->buffer_pool_index = xd->buffer_pool_for_queue[queue_id];
270 
271  mb_index = 0;
272 
273  while (n_buffers > 0)
274  {
275  vlib_buffer_t *b0, *b1, *b2, *b3;
276  u32 bi0, next0;
277  u32 bi1, next1;
278  u32 bi2, next2;
279  u32 bi3, next3;
280  u8 error0, error1, error2, error3;
281  i16 offset0, offset1, offset2, offset3;
282  u64 or_ol_flags;
283 
284  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
285 
286  while (n_buffers >= 12 && n_left_to_next >= 4)
287  {
288  struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
289 
290  /* prefetches are interleaved with the rest of the code to reduce
291  pressure on L1 cache */
292  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 8]);
293  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 4]);
294 
295  mb0 = xd->rx_vectors[queue_id][mb_index];
296  mb1 = xd->rx_vectors[queue_id][mb_index + 1];
297  mb2 = xd->rx_vectors[queue_id][mb_index + 2];
298  mb3 = xd->rx_vectors[queue_id][mb_index + 3];
299 
300  ASSERT (mb0);
301  ASSERT (mb1);
302  ASSERT (mb2);
303  ASSERT (mb3);
304 
305  if (maybe_multiseg)
306  {
307  if (PREDICT_FALSE (mb0->nb_segs > 1))
308  dpdk_prefetch_buffer (mb0->next);
309  if (PREDICT_FALSE (mb1->nb_segs > 1))
310  dpdk_prefetch_buffer (mb1->next);
311  if (PREDICT_FALSE (mb2->nb_segs > 1))
312  dpdk_prefetch_buffer (mb2->next);
313  if (PREDICT_FALSE (mb3->nb_segs > 1))
314  dpdk_prefetch_buffer (mb3->next);
315  }
316 
317  b0 = vlib_buffer_from_rte_mbuf (mb0);
318  b1 = vlib_buffer_from_rte_mbuf (mb1);
319  b2 = vlib_buffer_from_rte_mbuf (mb2);
320  b3 = vlib_buffer_from_rte_mbuf (mb3);
321 
322  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 9]);
323  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 5]);
324 
325  clib_memcpy64_x4 (b0, b1, b2, b3, bt);
326 
327  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 10]);
328  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 7]);
329 
330  bi0 = vlib_get_buffer_index (vm, b0);
331  bi1 = vlib_get_buffer_index (vm, b1);
332  bi2 = vlib_get_buffer_index (vm, b2);
333  bi3 = vlib_get_buffer_index (vm, b3);
334 
335  to_next[0] = bi0;
336  to_next[1] = bi1;
337  to_next[2] = bi2;
338  to_next[3] = bi3;
339  to_next += 4;
340  n_left_to_next -= 4;
341 
342  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
343  {
344  next0 = next1 = next2 = next3 = xd->per_interface_next_index;
345  }
346  else
347  {
348  next0 = dpdk_rx_next_from_etype (mb0);
349  next1 = dpdk_rx_next_from_etype (mb1);
350  next2 = dpdk_rx_next_from_etype (mb2);
351  next3 = dpdk_rx_next_from_etype (mb3);
352  }
353 
354  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 11]);
355  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 6]);
356 
357  or_ol_flags = (mb0->ol_flags | mb1->ol_flags |
358  mb2->ol_flags | mb3->ol_flags);
359  if (PREDICT_FALSE (or_ol_flags & PKT_RX_IP_CKSUM_BAD))
360  {
361  dpdk_rx_error_from_mb (mb0, &next0, &error0);
362  dpdk_rx_error_from_mb (mb1, &next1, &error1);
363  dpdk_rx_error_from_mb (mb2, &next2, &error2);
364  dpdk_rx_error_from_mb (mb3, &next3, &error3);
365  b0->error = node->errors[error0];
366  b1->error = node->errors[error1];
367  b2->error = node->errors[error2];
368  b3->error = node->errors[error3];
369  }
370 
371  offset0 = device_input_next_node_advance[next0];
372  b0->current_data = mb0->data_off + offset0 - RTE_PKTMBUF_HEADROOM;
373  b0->flags |= device_input_next_node_flags[next0];
374  vnet_buffer (b0)->l3_hdr_offset = b0->current_data;
375  vnet_buffer (b0)->l2_hdr_offset =
376  mb0->data_off - RTE_PKTMBUF_HEADROOM;
377  b0->current_length = mb0->data_len - offset0;
378  n_rx_bytes += mb0->pkt_len;
379 
380  offset1 = device_input_next_node_advance[next1];
381  b1->current_data = mb1->data_off + offset1 - RTE_PKTMBUF_HEADROOM;
382  b1->flags |= device_input_next_node_flags[next1];
383  vnet_buffer (b1)->l3_hdr_offset = b1->current_data;
384  vnet_buffer (b1)->l2_hdr_offset =
385  mb1->data_off - RTE_PKTMBUF_HEADROOM;
386  b1->current_length = mb1->data_len - offset1;
387  n_rx_bytes += mb1->pkt_len;
388 
389  offset2 = device_input_next_node_advance[next2];
390  b2->current_data = mb2->data_off + offset2 - RTE_PKTMBUF_HEADROOM;
391  b2->flags |= device_input_next_node_flags[next2];
392  vnet_buffer (b2)->l3_hdr_offset = b2->current_data;
393  vnet_buffer (b2)->l2_hdr_offset =
394  mb2->data_off - RTE_PKTMBUF_HEADROOM;
395  b2->current_length = mb2->data_len - offset2;
396  n_rx_bytes += mb2->pkt_len;
397 
398  offset3 = device_input_next_node_advance[next3];
399  b3->current_data = mb3->data_off + offset3 - RTE_PKTMBUF_HEADROOM;
400  b3->flags |= device_input_next_node_flags[next3];
401  vnet_buffer (b3)->l3_hdr_offset = b3->current_data;
402  vnet_buffer (b3)->l2_hdr_offset =
403  mb3->data_off - RTE_PKTMBUF_HEADROOM;
404  b3->current_length = mb3->data_len - offset3;
405  n_rx_bytes += mb3->pkt_len;
406 
407 
408  /* Process subsequent segments of multi-segment packets */
409  if (maybe_multiseg)
410  {
411  dpdk_process_subseq_segs (vm, b0, mb0, fl);
412  dpdk_process_subseq_segs (vm, b1, mb1, fl);
413  dpdk_process_subseq_segs (vm, b2, mb2, fl);
414  dpdk_process_subseq_segs (vm, b3, mb3, fl);
415  }
416 
417  /*
418  * Turn this on if you run into
419  * "bad monkey" contexts, and you want to know exactly
420  * which nodes they've visited... See main.c...
421  */
426 
427  /* Do we have any driver RX features configured on the interface? */
429  &next0, &next1, &next2, &next3,
430  b0, b1, b2, b3);
431 
432  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
433  to_next, n_left_to_next,
434  bi0, bi1, bi2, bi3,
435  next0, next1, next2, next3);
436  n_buffers -= 4;
437  mb_index += 4;
438  }
439  while (n_buffers > 0 && n_left_to_next > 0)
440  {
441  struct rte_mbuf *mb0 = xd->rx_vectors[queue_id][mb_index];
442 
443  if (PREDICT_TRUE (n_buffers > 3))
444  {
445  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 2]);
446  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id]
447  [mb_index + 1]);
448  }
449 
450  ASSERT (mb0);
451 
452  b0 = vlib_buffer_from_rte_mbuf (mb0);
453 
454  /* Prefetch one next segment if it exists. */
455  if (PREDICT_FALSE (mb0->nb_segs > 1))
456  dpdk_prefetch_buffer (mb0->next);
457 
459 
460  bi0 = vlib_get_buffer_index (vm, b0);
461 
462  to_next[0] = bi0;
463  to_next++;
464  n_left_to_next--;
465 
466  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
467  next0 = xd->per_interface_next_index;
468  else
469  next0 = dpdk_rx_next_from_etype (mb0);
470 
471  dpdk_rx_error_from_mb (mb0, &next0, &error0);
472  b0->error = node->errors[error0];
473 
474  offset0 = device_input_next_node_advance[next0];
475  b0->current_data = mb0->data_off + offset0 - RTE_PKTMBUF_HEADROOM;
476  b0->flags |= device_input_next_node_flags[next0];
477  vnet_buffer (b0)->l3_hdr_offset = b0->current_data;
478  vnet_buffer (b0)->l2_hdr_offset =
479  mb0->data_off - RTE_PKTMBUF_HEADROOM;
480  b0->current_length = mb0->data_len - offset0;
481  n_rx_bytes += mb0->pkt_len;
482 
483  /* Process subsequent segments of multi-segment packets */
484  dpdk_process_subseq_segs (vm, b0, mb0, fl);
485 
486  /*
487  * Turn this on if you run into
488  * "bad monkey" contexts, and you want to know exactly
489  * which nodes they've visited... See main.c...
490  */
492 
493  /* Do we have any driver RX features configured on the interface? */
495  b0);
496 
497  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
498  to_next, n_left_to_next,
499  bi0, next0);
500  n_buffers--;
501  mb_index++;
502  }
503  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
504  }
505 
506  if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[thread_index]) > 0))
507  {
508  dpdk_rx_trace (dm, node, xd, queue_id,
509  xd->d_trace_buffers[thread_index],
510  vec_len (xd->d_trace_buffers[thread_index]));
511  vlib_set_trace_count (vm, node,
512  n_trace -
513  vec_len (xd->d_trace_buffers[thread_index]));
514  }
515 
517  (vnet_get_main ()->interface_main.combined_sw_if_counters
519  thread_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
520 
521  vnet_device_increment_rx_packets (thread_index, mb_index);
522 
523  return mb_index;
524 }
525 
526 static inline void
528 {
529  /* Limit the poll rate by sleeping for N msec between polls */
530  if (PREDICT_FALSE (dm->poll_sleep_usec != 0))
531  {
532  struct timespec ts, tsrem;
533 
534  ts.tv_sec = 0;
535  ts.tv_nsec = 1000 * dm->poll_sleep_usec;
536 
537  while (nanosleep (&ts, &tsrem) < 0)
538  {
539  ts = tsrem;
540  }
541  }
542 }
543 
544 /** \brief Main DPDK input node
545  @node dpdk-input
546 
547  This is the main DPDK input node: across each assigned interface,
548  call rte_eth_rx_burst(...) or similar to obtain a vector of
549  packets to process. Handle early packet discard. Derive @c
550  vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata,
551  Depending on the resulting metadata: adjust <code>b->current_data,
552  b->current_length </code> and dispatch directly to
553  ip4-input-no-checksum, or ip6-input. Trace the packet if required.
554 
555  @param vm vlib_main_t corresponding to the current thread
556  @param node vlib_node_runtime_t
557  @param f vlib_frame_t input-node, not used.
558 
559  @par Graph mechanics: buffer metadata, next index usage
560 
561  @em Uses:
562  - <code>struct rte_mbuf mb->ol_flags</code>
563  - PKT_RX_IP_CKSUM_BAD
564  - <code> RTE_ETH_IS_xxx_HDR(mb->packet_type) </code>
565  - packet classification result
566 
567  @em Sets:
568  - <code>b->error</code> if the packet is to be dropped immediately
569  - <code>b->current_data, b->current_length</code>
570  - adjusted as needed to skip the L2 header in direct-dispatch cases
571  - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
572  - rx interface sw_if_index
573  - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
574  - required by ipX-lookup
575  - <code>b->flags</code>
576  - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
577 
578  <em>Next Nodes:</em>
579  - Static arcs to: error-drop, ethernet-input,
580  ip4-input-no-checksum, ip6-input, mpls-input
581  - per-interface redirection, controlled by
582  <code>xd->per_interface_next_index</code>
583 */
584 
585 uword
587  vlib_frame_t * f)
588 {
589  dpdk_main_t *dm = &dpdk_main;
590  dpdk_device_t *xd;
591  uword n_rx_packets = 0;
592  vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
594  u32 thread_index = node->thread_index;
595 
596  /*
597  * Poll all devices on this cpu for input/interrupts.
598  */
599  /* *INDENT-OFF* */
601  {
602  xd = vec_elt_at_index(dm->devices, dq->dev_instance);
604  continue; /* Do not poll slave to a bonded interface */
606  n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 1);
607  else
608  n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 0);
609  }
610  /* *INDENT-ON* */
611 
612  poll_rate_limit (dm);
613 
614  return n_rx_packets;
615 }
616 
617 #ifndef CLIB_MULTIARCH_VARIANT
618 /* *INDENT-OFF* */
620  .function = dpdk_input,
621  .type = VLIB_NODE_TYPE_INPUT,
622  .name = "dpdk-input",
623  .sibling_of = "device-input",
624 
625  /* Will be enabled if/when hardware is detected. */
626  .state = VLIB_NODE_STATE_DISABLED,
627 
628  .format_buffer = format_ethernet_header_with_length,
629  .format_trace = format_dpdk_rx_dma_trace,
630 
631  .n_errors = DPDK_N_ERROR,
632  .error_strings = dpdk_error_strings,
633 };
634 /* *INDENT-ON* */
635 
638 
639 #if __x86_64__
640 static void __clib_constructor
642 {
643  if (dpdk_input_avx512 && clib_cpu_supports_avx512f ())
645  else if (dpdk_input_avx2 && clib_cpu_supports_avx2 ())
646  dpdk_input_node.function = dpdk_input_avx2;
647 }
648 #endif
649 #endif
650 
651 /*
652  * fd.io coding-style-patch-verification: ON
653  *
654  * Local Variables:
655  * eval: (c-set-style "gnu")
656  * End:
657  */
u32 ** d_trace_buffers
Definition: dpdk.h:176
static void vnet_device_increment_rx_packets(u32 thread_index, u64 count)
Definition: devices.h:110
uword( vlib_node_function_t)(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, struct vlib_frame_t *frame)
Definition: node.h:54
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
vnet_device_and_queue_t * devices_and_queues
Definition: devices.h:69
#define clib_min(x, y)
Definition: clib.h:340
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
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:72
dpdk_main_t dpdk_main
Definition: init.c:39
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
#define PREDICT_TRUE(x)
Definition: clib.h:106
#define foreach_dpdk_error
Definition: dpdk.h:435
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:181
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
u8 buffer_pool_index
index of buffer pool this buffer belongs.
Definition: buffer.h:126
#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:169
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
vlib_buffer_t * buffer_templates
Definition: dpdk.h:360
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:184
vlib_node_function_t __clib_weak dpdk_input_avx2
Definition: node.c:637
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:93
u8 data[256]
Definition: dpdk.h:424
vlib_node_function_t __clib_weak dpdk_input_avx512
Definition: node.c:636
#define always_inline
Definition: clib.h:92
#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:151
unsigned long u64
Definition: types.h:89
#define DPDK_DEVICE_FLAG_MAYBE_MULTISEG
Definition: dpdk.h:186
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:527
#define fl(x, y)
struct rte_mbuf mb
Definition: dpdk.h:422
static u32 dpdk_rx_burst(dpdk_main_t *dm, dpdk_device_t *xd, u16 queue_id)
Definition: node.c:122
u32 vlib_sw_if_index
Definition: dpdk.h:166
#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:458
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:156
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:72
static_always_inline void dpdk_prefetch_ethertype(struct rte_mbuf *mb)
Definition: node.c:209
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:434
static void __clib_constructor dpdk_input_multiarch_select(void)
Definition: node.c:641
#define PREDICT_FALSE(x)
Definition: clib.h:105
#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:218
#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:32
#define DPDK_DEVICE_FLAG_ADMIN_UP
Definition: dpdk.h:182
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:91
static u32 dpdk_rx_next_from_etype(struct rte_mbuf *mb)
Definition: node.c:40
dpdk_device_t * devices
Definition: dpdk.h:353
#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:173
static_always_inline void clib_memcpy64_x4(void *d0, void *d1, void *d2, void *d3, void *s)
Definition: string.h:89
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:619
#define clib_memcpy(a, b, c)
Definition: string.h:75
const u32 device_input_next_node_flags[((VNET_DEVICE_INPUT_N_NEXT_NODES/CLIB_CACHE_LINE_BYTES)+1)*CLIB_CACHE_LINE_BYTES]
Definition: devices.c:57
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
uword CLIB_MULTIARCH_FN() dpdk_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Main DPDK input node.
Definition: node.c:586
#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:60
u32 poll_sleep_usec
Definition: dpdk.h:390
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:109
dpdk_portid_t device_index
Definition: dpdk.h:163
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:142
#define foreach_device_and_queue(var, vec)
Definition: devices.h:156
unsigned short u16
Definition: types.h:57
vlib_buffer_t buffer
Definition: dpdk.h:423
#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:534
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:221
#define DPDK_DEVICE_FLAG_BOND_SLAVE
Definition: dpdk.h:189
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
Definition: buffer_funcs.h:809
short i16
Definition: types.h:46
#define vnet_buffer(b)
Definition: buffer.h:326
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:159
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:451
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:201
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
u8 * buffer_pool_for_queue
Definition: dpdk.h:207
Definition: defs.h:46
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
#define CLIB_MULTIARCH_FN(fn)
Definition: cpu.h:59