FD.io VPP  v17.01.1-3-gc6833f8
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 <vnet/devices/dpdk/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_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_UNICAST));
56 }
57 
58 #if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0)
59 /* New ol_flags bits added in DPDK-16.11 */
60 #define PKT_RX_IP_CKSUM_GOOD (1ULL << 7)
61 #endif
62 
64 dpdk_rx_next_from_etype (struct rte_mbuf * mb, vlib_buffer_t * b0)
65 {
67  if (PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
69  else
71  else if (PREDICT_TRUE (vlib_buffer_is_ip6 (b0)))
73  else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
75  else
77 }
78 
79 always_inline int
80 dpdk_mbuf_is_vlan (struct rte_mbuf *mb)
81 {
82 #if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
83  return (mb->packet_type & RTE_PTYPE_L2_ETHER_VLAN) ==
84  RTE_PTYPE_L2_ETHER_VLAN;
85 #else
86  return
87  (mb->ol_flags &
88  (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) ==
89  PKT_RX_VLAN_PKT;
90 #endif
91 }
92 
93 always_inline int
94 dpdk_mbuf_is_ip4 (struct rte_mbuf *mb)
95 {
96  return RTE_ETH_IS_IPV4_HDR (mb->packet_type) != 0;
97 }
98 
99 always_inline int
100 dpdk_mbuf_is_ip6 (struct rte_mbuf *mb)
101 {
102  return RTE_ETH_IS_IPV6_HDR (mb->packet_type) != 0;
103 }
104 
106 dpdk_rx_next_from_mb (struct rte_mbuf * mb, vlib_buffer_t * b0)
107 {
108  if (PREDICT_FALSE (dpdk_mbuf_is_vlan (mb)))
110  else if (PREDICT_TRUE (dpdk_mbuf_is_ip4 (mb)))
112  else if (PREDICT_TRUE (dpdk_mbuf_is_ip6 (mb)))
114  else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
116  else
117  return dpdk_rx_next_from_etype (mb, b0);
118 }
119 
120 always_inline void
121 dpdk_rx_error_from_mb (struct rte_mbuf *mb, u32 * next, u8 * error)
122 {
123  if (mb->ol_flags & PKT_RX_IP_CKSUM_BAD)
124  {
125  *error = DPDK_ERROR_IP_CHECKSUM_ERROR;
127  }
128  else
129  *error = DPDK_ERROR_NONE;
130 }
131 
132 void
134  vlib_node_runtime_t * node,
135  dpdk_device_t * xd,
136  u16 queue_id, u32 * buffers, uword n_buffers)
137 {
138  vlib_main_t *vm = vlib_get_main ();
139  u32 *b, n_left;
140  u32 next0;
141 
142  n_left = n_buffers;
143  b = buffers;
144 
145  while (n_left >= 1)
146  {
147  u32 bi0;
148  vlib_buffer_t *b0;
150  struct rte_mbuf *mb;
151  u8 error0;
152 
153  bi0 = b[0];
154  n_left -= 1;
155 
156  b0 = vlib_get_buffer (vm, bi0);
157  mb = rte_mbuf_from_vlib_buffer (b0);
158 
159  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
160  next0 = xd->per_interface_next_index;
161  else if (PREDICT_TRUE
163  next0 = dpdk_rx_next_from_mb (mb, b0);
164  else
165  next0 = dpdk_rx_next_from_etype (mb, b0);
166 
167  dpdk_rx_error_from_mb (mb, &next0, &error0);
168 
169  vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0);
170  t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
171  t0->queue_index = queue_id;
172  t0->device_index = xd->device_index;
173  t0->buffer_index = bi0;
174 
175  clib_memcpy (&t0->mb, mb, sizeof (t0->mb));
176  clib_memcpy (&t0->buffer, b0, sizeof (b0[0]) - sizeof (b0->pre_data));
177  clib_memcpy (t0->buffer.pre_data, b0->data,
178  sizeof (t0->buffer.pre_data));
179  clib_memcpy (&t0->data, mb->buf_addr + mb->data_off, sizeof (t0->data));
180 
181  b += 1;
182  }
183 }
184 
185 static inline u32
187 {
188  u32 n_buffers;
189  u32 n_left;
190  u32 n_this_chunk;
191 
192  n_left = VLIB_FRAME_SIZE;
193  n_buffers = 0;
194 
196  {
197  while (n_left)
198  {
199  n_this_chunk = rte_eth_rx_burst (xd->device_index, queue_id,
200  xd->rx_vectors[queue_id] +
201  n_buffers, n_left);
202  n_buffers += n_this_chunk;
203  n_left -= n_this_chunk;
204 
205  /* Empirically, DPDK r1.8 produces vectors w/ 32 or fewer elts */
206  if (n_this_chunk < 32)
207  break;
208  }
209  }
210  else
211  {
212  ASSERT (0);
213  }
214 
215  return n_buffers;
216 }
217 
218 
221  struct rte_mbuf *mb, vlib_buffer_free_list_t * fl)
222 {
223  u8 nb_seg = 1;
224  struct rte_mbuf *mb_seg = 0;
225  vlib_buffer_t *b_seg, *b_chain = 0;
226  mb_seg = mb->next;
227  b_chain = b;
228 
229  while ((mb->nb_segs > 1) && (nb_seg < mb->nb_segs))
230  {
231  ASSERT (mb_seg != 0);
232 
233  b_seg = vlib_buffer_from_rte_mbuf (mb_seg);
234  vlib_buffer_init_for_free_list (b_seg, fl);
235 
236  ASSERT ((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
237  ASSERT (b_seg->current_data == 0);
238 
239  /*
240  * The driver (e.g. virtio) may not put the packet data at the start
241  * of the segment, so don't assume b_seg->current_data == 0 is correct.
242  */
243  b_seg->current_data =
244  (mb_seg->buf_addr + mb_seg->data_off) - (void *) b_seg->data;
245 
246  b_seg->current_length = mb_seg->data_len;
247  b->total_length_not_including_first_buffer += mb_seg->data_len;
248 
249  b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT;
250  b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg);
251 
252  b_chain = b_seg;
253  mb_seg = mb_seg->next;
254  nb_seg++;
255  }
256 }
257 
259 dpdk_prefetch_buffer (struct rte_mbuf *mb)
260 {
264 }
265 
266 /*
267  * This function is used when there are no worker threads.
268  * The main thread performs IO and forwards the packets.
269  */
272  vlib_node_runtime_t * node, u32 cpu_index, u16 queue_id)
273 {
274  u32 n_buffers;
276  u32 n_left_to_next, *to_next;
277  u32 mb_index;
278  vlib_main_t *vm = vlib_get_main ();
279  uword n_rx_bytes = 0;
280  u32 n_trace, trace_cnt __attribute__ ((unused));
282  u32 buffer_flags_template;
283 
284  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
285  return 0;
286 
287  n_buffers = dpdk_rx_burst (dm, xd, queue_id);
288 
289  if (n_buffers == 0)
290  {
291  return 0;
292  }
293 
294  buffer_flags_template = dm->buffer_flags_template;
295 
296  vec_reset_length (xd->d_trace_buffers[cpu_index]);
297  trace_cnt = n_trace = vlib_get_trace_count (vm, node);
298 
299  if (n_trace > 0)
300  {
301  u32 n = clib_min (n_trace, n_buffers);
302  mb_index = 0;
303 
304  while (n--)
305  {
306  struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++];
308  vec_add1 (xd->d_trace_buffers[cpu_index],
309  vlib_get_buffer_index (vm, b));
310  }
311  }
312 
314 
315  mb_index = 0;
316 
317  while (n_buffers > 0)
318  {
319  vlib_buffer_t *b0, *b1, *b2, *b3;
320  u32 bi0, next0, l3_offset0;
321  u32 bi1, next1, l3_offset1;
322  u32 bi2, next2, l3_offset2;
323  u32 bi3, next3, l3_offset3;
324  u8 error0, error1, error2, error3;
325  u64 or_ol_flags;
326 
327  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
328 
329  while (n_buffers > 8 && n_left_to_next > 4)
330  {
331  struct rte_mbuf *mb0 = xd->rx_vectors[queue_id][mb_index];
332  struct rte_mbuf *mb1 = xd->rx_vectors[queue_id][mb_index + 1];
333  struct rte_mbuf *mb2 = xd->rx_vectors[queue_id][mb_index + 2];
334  struct rte_mbuf *mb3 = xd->rx_vectors[queue_id][mb_index + 3];
335 
336  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 4]);
337  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 5]);
338  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 6]);
339  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 7]);
340 
342  {
343  if (PREDICT_FALSE (mb0->nb_segs > 1))
344  dpdk_prefetch_buffer (mb0->next);
345  if (PREDICT_FALSE (mb1->nb_segs > 1))
346  dpdk_prefetch_buffer (mb1->next);
347  if (PREDICT_FALSE (mb2->nb_segs > 1))
348  dpdk_prefetch_buffer (mb2->next);
349  if (PREDICT_FALSE (mb3->nb_segs > 1))
350  dpdk_prefetch_buffer (mb3->next);
351  }
352 
353  ASSERT (mb0);
354  ASSERT (mb1);
355  ASSERT (mb2);
356  ASSERT (mb3);
357 
358  or_ol_flags = (mb0->ol_flags | mb1->ol_flags |
359  mb2->ol_flags | mb3->ol_flags);
360  b0 = vlib_buffer_from_rte_mbuf (mb0);
361  b1 = vlib_buffer_from_rte_mbuf (mb1);
362  b2 = vlib_buffer_from_rte_mbuf (mb2);
363  b3 = vlib_buffer_from_rte_mbuf (mb3);
364 
369 
370  bi0 = vlib_get_buffer_index (vm, b0);
371  bi1 = vlib_get_buffer_index (vm, b1);
372  bi2 = vlib_get_buffer_index (vm, b2);
373  bi3 = vlib_get_buffer_index (vm, b3);
374 
375  to_next[0] = bi0;
376  to_next[1] = bi1;
377  to_next[2] = bi2;
378  to_next[3] = bi3;
379  to_next += 4;
380  n_left_to_next -= 4;
381 
382  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
383  {
384  next0 = next1 = next2 = next3 = xd->per_interface_next_index;
385  }
386  else if (PREDICT_TRUE
388  {
389  next0 = dpdk_rx_next_from_mb (mb0, b0);
390  next1 = dpdk_rx_next_from_mb (mb1, b1);
391  next2 = dpdk_rx_next_from_mb (mb2, b2);
392  next3 = dpdk_rx_next_from_mb (mb3, b3);
393  }
394  else
395  {
396  next0 = dpdk_rx_next_from_etype (mb0, b0);
397  next1 = dpdk_rx_next_from_etype (mb1, b1);
398  next2 = dpdk_rx_next_from_etype (mb2, b2);
399  next3 = dpdk_rx_next_from_etype (mb3, b3);
400  }
401 
402  if (PREDICT_FALSE (or_ol_flags & PKT_RX_IP_CKSUM_BAD))
403  {
404  dpdk_rx_error_from_mb (mb0, &next0, &error0);
405  dpdk_rx_error_from_mb (mb1, &next1, &error1);
406  dpdk_rx_error_from_mb (mb2, &next2, &error2);
407  dpdk_rx_error_from_mb (mb3, &next3, &error3);
408  b0->error = node->errors[error0];
409  b1->error = node->errors[error1];
410  b2->error = node->errors[error2];
411  b3->error = node->errors[error3];
412  }
413  else
414  {
415  b0->error = b1->error = node->errors[DPDK_ERROR_NONE];
416  b2->error = b3->error = node->errors[DPDK_ERROR_NONE];
417  }
418 
419  l3_offset0 = device_input_next_node_advance[next0];
420  l3_offset1 = device_input_next_node_advance[next1];
421  l3_offset2 = device_input_next_node_advance[next2];
422  l3_offset3 = device_input_next_node_advance[next3];
423 
424  b0->current_data = l3_offset0 + mb0->data_off;
425  b1->current_data = l3_offset1 + mb1->data_off;
426  b2->current_data = l3_offset2 + mb2->data_off;
427  b3->current_data = l3_offset3 + mb3->data_off;
428 
429  b0->current_data -= RTE_PKTMBUF_HEADROOM;
430  b1->current_data -= RTE_PKTMBUF_HEADROOM;
431  b2->current_data -= RTE_PKTMBUF_HEADROOM;
432  b3->current_data -= RTE_PKTMBUF_HEADROOM;
433 
434  b0->current_length = mb0->data_len - l3_offset0;
435  b1->current_length = mb1->data_len - l3_offset1;
436  b2->current_length = mb2->data_len - l3_offset2;
437  b3->current_length = mb3->data_len - l3_offset3;
438 
439  b0->flags = buffer_flags_template;
440  b1->flags = buffer_flags_template;
441  b2->flags = buffer_flags_template;
442  b3->flags = buffer_flags_template;
443 
444  vnet_buffer (b0)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
445  vnet_buffer (b1)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
446  vnet_buffer (b2)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
447  vnet_buffer (b3)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
448 
449  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
450  vnet_buffer (b1)->sw_if_index[VLIB_TX] = (u32) ~ 0;
451  vnet_buffer (b2)->sw_if_index[VLIB_TX] = (u32) ~ 0;
452  vnet_buffer (b3)->sw_if_index[VLIB_TX] = (u32) ~ 0;
453 
454  n_rx_bytes += mb0->pkt_len;
455  n_rx_bytes += mb1->pkt_len;
456  n_rx_bytes += mb2->pkt_len;
457  n_rx_bytes += mb3->pkt_len;
458 
459  /* Process subsequent segments of multi-segment packets */
461  {
462  dpdk_process_subseq_segs (vm, b0, mb0, fl);
463  dpdk_process_subseq_segs (vm, b1, mb1, fl);
464  dpdk_process_subseq_segs (vm, b2, mb2, fl);
465  dpdk_process_subseq_segs (vm, b3, mb3, fl);
466  }
467 
468  /*
469  * Turn this on if you run into
470  * "bad monkey" contexts, and you want to know exactly
471  * which nodes they've visited... See main.c...
472  */
477 
478  /* Do we have any driver RX features configured on the interface? */
480  &next0, &next1, &next2, &next3,
481  b0, b1, b2, b3,
482  l3_offset0, l3_offset1,
483  l3_offset2, l3_offset3);
484 
485  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
486  to_next, n_left_to_next,
487  bi0, bi1, bi2, bi3,
488  next0, next1, next2, next3);
489  n_buffers -= 4;
490  mb_index += 4;
491  }
492  while (n_buffers > 0 && n_left_to_next > 0)
493  {
494  struct rte_mbuf *mb0 = xd->rx_vectors[queue_id][mb_index];
495 
496  ASSERT (mb0);
497 
498  b0 = vlib_buffer_from_rte_mbuf (mb0);
499 
500  /* Prefetch one next segment if it exists. */
501  if (PREDICT_FALSE (mb0->nb_segs > 1))
502  dpdk_prefetch_buffer (mb0->next);
503 
505 
506  bi0 = vlib_get_buffer_index (vm, b0);
507 
508  to_next[0] = bi0;
509  to_next++;
510  n_left_to_next--;
511 
512  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
513  next0 = xd->per_interface_next_index;
514  else if (PREDICT_TRUE
516  next0 = dpdk_rx_next_from_mb (mb0, b0);
517  else
518  next0 = dpdk_rx_next_from_etype (mb0, b0);
519 
520  dpdk_rx_error_from_mb (mb0, &next0, &error0);
521  b0->error = node->errors[error0];
522 
523  l3_offset0 = device_input_next_node_advance[next0];
524 
525  b0->current_data = l3_offset0;
526  b0->current_data += mb0->data_off - RTE_PKTMBUF_HEADROOM;
527  b0->current_length = mb0->data_len - l3_offset0;
528 
529  b0->flags = buffer_flags_template;
530 
531  vnet_buffer (b0)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
532  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
533  n_rx_bytes += mb0->pkt_len;
534 
535  /* Process subsequent segments of multi-segment packets */
536  dpdk_process_subseq_segs (vm, b0, mb0, fl);
537 
538  /*
539  * Turn this on if you run into
540  * "bad monkey" contexts, and you want to know exactly
541  * which nodes they've visited... See main.c...
542  */
544 
545  /* Do we have any driver RX features configured on the interface? */
547  b0, l3_offset0);
548 
549  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
550  to_next, n_left_to_next,
551  bi0, next0);
552  n_buffers--;
553  mb_index++;
554  }
555  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
556  }
557 
558  if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[cpu_index]) > 0))
559  {
560  dpdk_rx_trace (dm, node, xd, queue_id, xd->d_trace_buffers[cpu_index],
561  vec_len (xd->d_trace_buffers[cpu_index]));
562  vlib_set_trace_count (vm, node, n_trace -
563  vec_len (xd->d_trace_buffers[cpu_index]));
564  }
565 
567  (vnet_get_main ()->interface_main.combined_sw_if_counters
569  cpu_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
570 
571  dpdk_worker_t *dw = vec_elt_at_index (dm->workers, cpu_index);
572  dw->aggregate_rx_packets += mb_index;
573 
574  return mb_index;
575 }
576 
577 static inline void
579 {
580  /* Limit the poll rate by sleeping for N msec between polls */
581  if (PREDICT_FALSE (dm->poll_sleep != 0))
582  {
583  struct timespec ts, tsrem;
584 
585  ts.tv_sec = 0;
586  ts.tv_nsec = 1000 * 1000 * dm->poll_sleep; /* 1ms */
587 
588  while (nanosleep (&ts, &tsrem) < 0)
589  {
590  ts = tsrem;
591  }
592  }
593 }
594 
595 /** \brief Main DPDK input node
596  @node dpdk-input
597 
598  This is the main DPDK input node: across each assigned interface,
599  call rte_eth_rx_burst(...) or similar to obtain a vector of
600  packets to process. Handle early packet discard. Derive @c
601  vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata,
602  Depending on the resulting metadata: adjust <code>b->current_data,
603  b->current_length </code> and dispatch directly to
604  ip4-input-no-checksum, or ip6-input. Trace the packet if required.
605 
606  @param vm vlib_main_t corresponding to the current thread
607  @param node vlib_node_runtime_t
608  @param f vlib_frame_t input-node, not used.
609 
610  @par Graph mechanics: buffer metadata, next index usage
611 
612  @em Uses:
613  - <code>struct rte_mbuf mb->ol_flags</code>
614  - PKT_RX_IP_CKSUM_BAD
615  - <code> RTE_ETH_IS_xxx_HDR(mb->packet_type) </code>
616  - packet classification result
617 
618  @em Sets:
619  - <code>b->error</code> if the packet is to be dropped immediately
620  - <code>b->current_data, b->current_length</code>
621  - adjusted as needed to skip the L2 header in direct-dispatch cases
622  - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
623  - rx interface sw_if_index
624  - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
625  - required by ipX-lookup
626  - <code>b->flags</code>
627  - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
628 
629  <em>Next Nodes:</em>
630  - Static arcs to: error-drop, ethernet-input,
631  ip4-input-no-checksum, ip6-input, mpls-input
632  - per-interface redirection, controlled by
633  <code>xd->per_interface_next_index</code>
634 */
635 
636 static uword
638 {
639  dpdk_main_t *dm = &dpdk_main;
640  dpdk_device_t *xd;
641  uword n_rx_packets = 0;
643  u32 cpu_index = os_get_cpu_number ();
644 
645  /*
646  * Poll all devices on this cpu for input/interrupts.
647  */
648  /* *INDENT-OFF* */
649  vec_foreach (dq, dm->devices_by_cpu[cpu_index])
650  {
651  xd = vec_elt_at_index(dm->devices, dq->device);
652  n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id);
653  }
654  /* *INDENT-ON* */
655 
656  poll_rate_limit (dm);
657 
658  return n_rx_packets;
659 }
660 
661 /* *INDENT-OFF* */
663  .function = dpdk_input,
664  .type = VLIB_NODE_TYPE_INPUT,
665  .name = "dpdk-input",
666  .sibling_of = "device-input",
667 
668  /* Will be enabled if/when hardware is detected. */
669  .state = VLIB_NODE_STATE_DISABLED,
670 
671  .format_buffer = format_ethernet_header_with_length,
672  .format_trace = format_dpdk_rx_dma_trace,
673 
674  .n_errors = DPDK_N_ERROR,
675  .error_strings = dpdk_error_strings,
676 };
677 
679 /* *INDENT-ON* */
680 
681 /*
682  * fd.io coding-style-patch-verification: ON
683  *
684  * Local Variables:
685  * eval: (c-set-style "gnu")
686  * End:
687  */
u32 ** d_trace_buffers
Definition: dpdk.h:186
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
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:133
#define clib_min(x, y)
Definition: clib.h:326
#define rte_mbuf_from_vlib_buffer(x)
Definition: buffer.h:389
static int vlib_buffer_is_mpls(vlib_buffer_t *b)
Definition: node.c:52
static int vlib_buffer_is_ip6(vlib_buffer_t *b)
Definition: node.c:45
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:143
dpdk_main_t dpdk_main
Definition: dpdk.h:428
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
static u32 dpdk_rx_burst(dpdk_main_t *dm, dpdk_device_t *xd, u16 queue_id)
Definition: node.c:186
static u32 dpdk_rx_next_from_etype(struct rte_mbuf *mb, vlib_buffer_t *b0)
Definition: node.c:64
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:406
#define PREDICT_TRUE(x)
Definition: clib.h:98
#define foreach_dpdk_error
Definition: dpdk.h:466
u16 flags
Definition: dpdk.h:191
static_always_inline void vnet_feature_start_device_input_x1(u32 sw_if_index, u32 *next0, vlib_buffer_t *b0, u16 buffer_advanced0)
Definition: feature.h:229
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
#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
static_always_inline u32 dpdk_device_input(dpdk_main_t *dm, dpdk_device_t *xd, vlib_node_runtime_t *node, u32 cpu_index, u16 queue_id)
Definition: node.c:271
u32 per_interface_next_index
Definition: dpdk.h:179
static int dpdk_mbuf_is_ip6(struct rte_mbuf *mb)
Definition: node.c:100
static void poll_rate_limit(dpdk_main_t *dm)
Definition: node.c:578
static char * dpdk_error_strings[]
Definition: node.c:31
vlib_error_t * errors
Definition: node.h:419
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:194
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
static void vlib_buffer_init_for_free_list(vlib_buffer_t *_dst, vlib_buffer_free_list_t *fl)
Definition: buffer_funcs.h:613
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:78
#define static_always_inline
Definition: clib.h:85
u8 data[256]
Definition: dpdk.h:447
static int dpdk_mbuf_is_ip4(struct rte_mbuf *mb)
Definition: node.c:94
#define always_inline
Definition: clib.h:84
#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:150
unsigned long u64
Definition: types.h:89
#define DPDK_DEVICE_FLAG_MAYBE_MULTISEG
Definition: dpdk.h:196
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:662
u32 device_index
Definition: dpdk.h:173
dpdk_worker_t * workers
Definition: dpdk.h:378
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:70
#define VLIB_BUFFER_NEXT_PRESENT
Definition: buffer.h:97
struct rte_mbuf mb
Definition: dpdk.h:445
u32 vlib_sw_if_index
Definition: dpdk.h:176
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:44
format_function_t format_dpdk_rx_dma_trace
Definition: dpdk.h:512
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:82
dpdk_device_and_queue_t ** devices_by_cpu
Definition: dpdk.h:365
static int dpdk_mbuf_is_vlan(struct rte_mbuf *mb)
Definition: node.c:80
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
#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:350
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:121
u64 aggregate_rx_packets
Definition: dpdk.h:246
#define DPDK_DEVICE_FLAG_ADMIN_UP
Definition: dpdk.h:192
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:115
dpdk_device_t * devices
Definition: dpdk.h:364
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
static_always_inline void dpdk_prefetch_buffer(struct rte_mbuf *mb)
Definition: node.c:259
struct rte_mbuf *** rx_vectors
Definition: dpdk.h:183
#define clib_memcpy(a, b, c)
Definition: string.h:69
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:220
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:310
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
Definition: counter.h:241
#define ASSERT(truth)
#define DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE
Definition: dpdk.h:195
unsigned int u32
Definition: types.h:88
static int vlib_buffer_is_ip4(vlib_buffer_t *b)
Definition: node.c:38
#define vnet_buffer(b)
Definition: buffer.h:361
u32 poll_sleep
Definition: dpdk.h:420
VLIB_NODE_FUNCTION_MULTIARCH(dpdk_input_node, dpdk_input)
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:117
static void dpdk_rx_error_from_mb(struct rte_mbuf *mb, u32 *next, u8 *error)
Definition: node.c:121
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:112
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
vlib_buffer_t buffer
Definition: dpdk.h:446
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
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, u16 buffer_advanced0, u16 buffer_advanced1, u16 buffer_advanced2, u16 buffer_advanced3)
Definition: feature.h:299
u32 buffer_flags_template
Definition: dpdk.h:372
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
#define vlib_buffer_from_rte_mbuf(x)
Definition: buffer.h:390
u8 data[0]
Packet data.
Definition: buffer.h:158
#define vec_foreach(var, vec)
Vector iterator.
static u32 dpdk_rx_next_from_mb(struct rte_mbuf *mb, vlib_buffer_t *b0)
Definition: node.c:106
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:317
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_IS_TRACED: trace this buffer.
Definition: buffer.h:85
static uword dpdk_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Main DPDK input node.
Definition: node.c:637
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
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".