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