FD.io VPP  v17.04.2-2-ga8f93f8
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_UNICAST));
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 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  while ((mb->nb_segs > 1) && (nb_seg < mb->nb_segs))
212  {
213  ASSERT (mb_seg != 0);
214 
215  b_seg = vlib_buffer_from_rte_mbuf (mb_seg);
216  vlib_buffer_init_for_free_list (b_seg, fl);
217 
218  ASSERT ((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
219  ASSERT (b_seg->current_data == 0);
220 
221  /*
222  * The driver (e.g. virtio) may not put the packet data at the start
223  * of the segment, so don't assume b_seg->current_data == 0 is correct.
224  */
225  b_seg->current_data =
226  (mb_seg->buf_addr + mb_seg->data_off) - (void *) b_seg->data;
227 
228  b_seg->current_length = mb_seg->data_len;
229  b->total_length_not_including_first_buffer += mb_seg->data_len;
230 
231  b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT;
232  b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg);
233 
234  b_chain = b_seg;
235  mb_seg = mb_seg->next;
236  nb_seg++;
237  }
238 }
239 
241 dpdk_prefetch_buffer (struct rte_mbuf *mb)
242 {
246 }
247 
249 dpdk_prefetch_ethertype (struct rte_mbuf *mb)
250 {
251  CLIB_PREFETCH (mb->buf_addr + mb->data_off +
253  CLIB_CACHE_LINE_BYTES, LOAD);
254 }
255 
256 
257 /*
258  This function should fill 1st cacheline of vlib_buffer_t metadata with data
259  from buffer template. Instead of filling field by field, we construct
260  template and then use 128/256 bit vector instruction to copy data.
261  This code first loads whole cacheline into 4 128-bit registers (xmm)
262  or two 256 bit registers (ymm) and then stores data into all 4 buffers
263  efectively saving on register load operations.
264 */
265 
267 dpdk_buffer_init_from_template (void *d0, void *d1, void *d2, void *d3,
268  void *s)
269 {
270  int i;
271  for (i = 0; i < 2; i++)
272  {
273  *(u8x32 *) (((u8 *) d0) + i * 32) =
274  *(u8x32 *) (((u8 *) d1) + i * 32) =
275  *(u8x32 *) (((u8 *) d2) + i * 32) =
276  *(u8x32 *) (((u8 *) d3) + i * 32) = *(u8x32 *) (((u8 *) s) + i * 32);
277  }
278 }
279 
280 /*
281  * This function is used when there are no worker threads.
282  * The main thread performs IO and forwards the packets.
283  */
286  vlib_node_runtime_t * node, u32 cpu_index, u16 queue_id,
287  int maybe_multiseg)
288 {
289  u32 n_buffers;
291  u32 n_left_to_next, *to_next;
292  u32 mb_index;
294  uword n_rx_bytes = 0;
295  u32 n_trace, trace_cnt __attribute__ ((unused));
297  vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, cpu_index);
298 
299  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
300  return 0;
301 
302  n_buffers = dpdk_rx_burst (dm, xd, queue_id);
303 
304  if (n_buffers == 0)
305  {
306  return 0;
307  }
308 
309  vec_reset_length (xd->d_trace_buffers[cpu_index]);
310  trace_cnt = n_trace = vlib_get_trace_count (vm, node);
311 
312  if (n_trace > 0)
313  {
314  u32 n = clib_min (n_trace, n_buffers);
315  mb_index = 0;
316 
317  while (n--)
318  {
319  struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++];
321  vec_add1 (xd->d_trace_buffers[cpu_index],
322  vlib_get_buffer_index (vm, b));
323  }
324  }
325 
327 
328  /* Update buffer template */
329  vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
330  bt->error = node->errors[DPDK_ERROR_NONE];
331 
332  mb_index = 0;
333 
334  while (n_buffers > 0)
335  {
336  vlib_buffer_t *b0, *b1, *b2, *b3;
337  u32 bi0, next0;
338  u32 bi1, next1;
339  u32 bi2, next2;
340  u32 bi3, next3;
341  u8 error0, error1, error2, error3;
342  u64 or_ol_flags;
343 
344  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
345 
346  while (n_buffers >= 12 && n_left_to_next >= 4)
347  {
348  struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
349 
350  /* prefetches are interleaved with the rest of the code to reduce
351  pressure on L1 cache */
352  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 8]);
353  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 4]);
354 
355  mb0 = xd->rx_vectors[queue_id][mb_index];
356  mb1 = xd->rx_vectors[queue_id][mb_index + 1];
357  mb2 = xd->rx_vectors[queue_id][mb_index + 2];
358  mb3 = xd->rx_vectors[queue_id][mb_index + 3];
359 
360  ASSERT (mb0);
361  ASSERT (mb1);
362  ASSERT (mb2);
363  ASSERT (mb3);
364 
365  if (maybe_multiseg)
366  {
367  if (PREDICT_FALSE (mb0->nb_segs > 1))
368  dpdk_prefetch_buffer (mb0->next);
369  if (PREDICT_FALSE (mb1->nb_segs > 1))
370  dpdk_prefetch_buffer (mb1->next);
371  if (PREDICT_FALSE (mb2->nb_segs > 1))
372  dpdk_prefetch_buffer (mb2->next);
373  if (PREDICT_FALSE (mb3->nb_segs > 1))
374  dpdk_prefetch_buffer (mb3->next);
375  }
376 
377  b0 = vlib_buffer_from_rte_mbuf (mb0);
378  b1 = vlib_buffer_from_rte_mbuf (mb1);
379  b2 = vlib_buffer_from_rte_mbuf (mb2);
380  b3 = vlib_buffer_from_rte_mbuf (mb3);
381 
382  dpdk_buffer_init_from_template (b0, b1, b2, b3, bt);
383 
384  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 9]);
385  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 5]);
386 
387  /* current_data must be set to -RTE_PKTMBUF_HEADROOM in template */
388  b0->current_data += mb0->data_off;
389  b1->current_data += mb1->data_off;
390  b2->current_data += mb2->data_off;
391  b3->current_data += mb3->data_off;
392 
393  b0->current_length = mb0->data_len;
394  b1->current_length = mb1->data_len;
395  b2->current_length = mb2->data_len;
396  b3->current_length = mb3->data_len;
397 
398  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 10]);
399  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 7]);
400 
401  bi0 = vlib_get_buffer_index (vm, b0);
402  bi1 = vlib_get_buffer_index (vm, b1);
403  bi2 = vlib_get_buffer_index (vm, b2);
404  bi3 = vlib_get_buffer_index (vm, b3);
405 
406  to_next[0] = bi0;
407  to_next[1] = bi1;
408  to_next[2] = bi2;
409  to_next[3] = bi3;
410  to_next += 4;
411  n_left_to_next -= 4;
412 
413  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
414  {
415  next0 = next1 = next2 = next3 = xd->per_interface_next_index;
416  }
417  else
418  {
419  next0 = dpdk_rx_next_from_etype (mb0, b0);
420  next1 = dpdk_rx_next_from_etype (mb1, b1);
421  next2 = dpdk_rx_next_from_etype (mb2, b2);
422  next3 = dpdk_rx_next_from_etype (mb3, b3);
423  }
424 
425  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 11]);
426  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 6]);
427 
428  or_ol_flags = (mb0->ol_flags | mb1->ol_flags |
429  mb2->ol_flags | mb3->ol_flags);
430  if (PREDICT_FALSE (or_ol_flags & PKT_RX_IP_CKSUM_BAD))
431  {
432  dpdk_rx_error_from_mb (mb0, &next0, &error0);
433  dpdk_rx_error_from_mb (mb1, &next1, &error1);
434  dpdk_rx_error_from_mb (mb2, &next2, &error2);
435  dpdk_rx_error_from_mb (mb3, &next3, &error3);
436  b0->error = node->errors[error0];
437  b1->error = node->errors[error1];
438  b2->error = node->errors[error2];
439  b3->error = node->errors[error3];
440  }
441 
446 
447  n_rx_bytes += mb0->pkt_len;
448  n_rx_bytes += mb1->pkt_len;
449  n_rx_bytes += mb2->pkt_len;
450  n_rx_bytes += mb3->pkt_len;
451 
452  /* Process subsequent segments of multi-segment packets */
453  if (maybe_multiseg)
454  {
455  dpdk_process_subseq_segs (vm, b0, mb0, fl);
456  dpdk_process_subseq_segs (vm, b1, mb1, fl);
457  dpdk_process_subseq_segs (vm, b2, mb2, fl);
458  dpdk_process_subseq_segs (vm, b3, mb3, fl);
459  }
460 
461  /*
462  * Turn this on if you run into
463  * "bad monkey" contexts, and you want to know exactly
464  * which nodes they've visited... See main.c...
465  */
470 
471  /* Do we have any driver RX features configured on the interface? */
473  &next0, &next1, &next2, &next3,
474  b0, b1, b2, b3);
475 
476  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
477  to_next, n_left_to_next,
478  bi0, bi1, bi2, bi3,
479  next0, next1, next2, next3);
480  n_buffers -= 4;
481  mb_index += 4;
482  }
483  while (n_buffers > 0 && n_left_to_next > 0)
484  {
485  struct rte_mbuf *mb0 = xd->rx_vectors[queue_id][mb_index];
486 
487  if (PREDICT_TRUE (n_buffers > 3))
488  {
489  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 2]);
490  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id]
491  [mb_index + 1]);
492  }
493 
494  ASSERT (mb0);
495 
496  b0 = vlib_buffer_from_rte_mbuf (mb0);
497 
498  /* Prefetch one next segment if it exists. */
499  if (PREDICT_FALSE (mb0->nb_segs > 1))
500  dpdk_prefetch_buffer (mb0->next);
501 
503 
504  ASSERT (b0->current_data == -RTE_PKTMBUF_HEADROOM);
505  b0->current_data += mb0->data_off;
506  b0->current_length = mb0->data_len;
507 
508  bi0 = vlib_get_buffer_index (vm, b0);
509 
510  to_next[0] = bi0;
511  to_next++;
512  n_left_to_next--;
513 
514  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
515  next0 = xd->per_interface_next_index;
516  else
517  next0 = dpdk_rx_next_from_etype (mb0, b0);
518 
519  dpdk_rx_error_from_mb (mb0, &next0, &error0);
520  b0->error = node->errors[error0];
521 
523 
524  n_rx_bytes += mb0->pkt_len;
525 
526  /* Process subsequent segments of multi-segment packets */
527  dpdk_process_subseq_segs (vm, b0, mb0, fl);
528 
529  /*
530  * Turn this on if you run into
531  * "bad monkey" contexts, and you want to know exactly
532  * which nodes they've visited... See main.c...
533  */
535 
536  /* Do we have any driver RX features configured on the interface? */
538  b0);
539 
540  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
541  to_next, n_left_to_next,
542  bi0, next0);
543  n_buffers--;
544  mb_index++;
545  }
546  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
547  }
548 
549  if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[cpu_index]) > 0))
550  {
551  dpdk_rx_trace (dm, node, xd, queue_id, xd->d_trace_buffers[cpu_index],
552  vec_len (xd->d_trace_buffers[cpu_index]));
553  vlib_set_trace_count (vm, node, n_trace -
554  vec_len (xd->d_trace_buffers[cpu_index]));
555  }
556 
558  (vnet_get_main ()->interface_main.combined_sw_if_counters
560  cpu_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
561 
562  vnet_device_increment_rx_packets (cpu_index, mb_index);
563 
564  return mb_index;
565 }
566 
567 static inline void
569 {
570  /* Limit the poll rate by sleeping for N msec between polls */
571  if (PREDICT_FALSE (dm->poll_sleep_usec != 0))
572  {
573  struct timespec ts, tsrem;
574 
575  ts.tv_sec = 0;
576  ts.tv_nsec = 1000 * dm->poll_sleep_usec;
577 
578  while (nanosleep (&ts, &tsrem) < 0)
579  {
580  ts = tsrem;
581  }
582  }
583 }
584 
585 /** \brief Main DPDK input node
586  @node dpdk-input
587 
588  This is the main DPDK input node: across each assigned interface,
589  call rte_eth_rx_burst(...) or similar to obtain a vector of
590  packets to process. Handle early packet discard. Derive @c
591  vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata,
592  Depending on the resulting metadata: adjust <code>b->current_data,
593  b->current_length </code> and dispatch directly to
594  ip4-input-no-checksum, or ip6-input. Trace the packet if required.
595 
596  @param vm vlib_main_t corresponding to the current thread
597  @param node vlib_node_runtime_t
598  @param f vlib_frame_t input-node, not used.
599 
600  @par Graph mechanics: buffer metadata, next index usage
601 
602  @em Uses:
603  - <code>struct rte_mbuf mb->ol_flags</code>
604  - PKT_RX_IP_CKSUM_BAD
605  - <code> RTE_ETH_IS_xxx_HDR(mb->packet_type) </code>
606  - packet classification result
607 
608  @em Sets:
609  - <code>b->error</code> if the packet is to be dropped immediately
610  - <code>b->current_data, b->current_length</code>
611  - adjusted as needed to skip the L2 header in direct-dispatch cases
612  - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
613  - rx interface sw_if_index
614  - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
615  - required by ipX-lookup
616  - <code>b->flags</code>
617  - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
618 
619  <em>Next Nodes:</em>
620  - Static arcs to: error-drop, ethernet-input,
621  ip4-input-no-checksum, ip6-input, mpls-input
622  - per-interface redirection, controlled by
623  <code>xd->per_interface_next_index</code>
624 */
625 
626 static uword
628 {
629  dpdk_main_t *dm = &dpdk_main;
630  dpdk_device_t *xd;
631  uword n_rx_packets = 0;
633  u32 cpu_index = os_get_cpu_number ();
634 
635  /*
636  * Poll all devices on this cpu for input/interrupts.
637  */
638  /* *INDENT-OFF* */
639  vec_foreach (dq, dm->devices_by_cpu[cpu_index])
640  {
641  xd = vec_elt_at_index(dm->devices, dq->device);
643  n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, /* maybe_multiseg */ 1);
644  else
645  n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, /* maybe_multiseg */ 0);
646  }
647  /* *INDENT-ON* */
648 
649  poll_rate_limit (dm);
650 
651  return n_rx_packets;
652 }
653 
654 /* *INDENT-OFF* */
656  .function = dpdk_input,
657  .type = VLIB_NODE_TYPE_INPUT,
658  .name = "dpdk-input",
659  .sibling_of = "device-input",
660 
661  /* Will be enabled if/when hardware is detected. */
662  .state = VLIB_NODE_STATE_DISABLED,
663 
664  .format_buffer = format_ethernet_header_with_length,
665  .format_trace = format_dpdk_rx_dma_trace,
666 
667  .n_errors = DPDK_N_ERROR,
668  .error_strings = dpdk_error_strings,
669 };
670 
672 /* *INDENT-ON* */
673 
674 /*
675  * fd.io coding-style-patch-verification: ON
676  *
677  * Local Variables:
678  * eval: (c-set-style "gnu")
679  * End:
680  */
u32 ** d_trace_buffers
Definition: dpdk.h:189
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, int maybe_multiseg)
Definition: node.c:285
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
static uword dpdk_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Main DPDK input node.
Definition: node.c:627
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#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
dpdk_main_t dpdk_main
Definition: dpdk.h:422
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:460
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
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
u16 flags
Definition: dpdk.h:194
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
#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:182
#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:363
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:418
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:197
static int vlib_buffer_is_ip6(vlib_buffer_t *b)
Definition: node.c:45
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 vnet_device_increment_rx_packets(u32 cpu_index, u64 count)
Definition: devices.h:98
#define VLIB_BUFFER_NEXT_PRESENT
Definition: buffer.h:87
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:67
#define static_always_inline
Definition: clib.h:85
u8 data[256]
Definition: dpdk.h:441
#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:144
unsigned long u64
Definition: types.h:89
#define DPDK_DEVICE_FLAG_MAYBE_MULTISEG
Definition: dpdk.h:199
u32 device_index
Definition: dpdk.h:176
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:70
static void poll_rate_limit(dpdk_main_t *dm)
Definition: node.c:568
struct rte_mbuf mb
Definition: dpdk.h:439
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:179
#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:494
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:71
dpdk_device_and_queue_t ** devices_by_cpu
Definition: dpdk.h:356
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:249
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:390
static_always_inline void dpdk_buffer_init_from_template(void *d0, void *d1, void *d2, void *d3, void *s)
Definition: node.c:267
#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:113
static char * dpdk_error_strings[]
Definition: node.c:31
#define DPDK_DEVICE_FLAG_ADMIN_UP
Definition: dpdk.h:195
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:91
dpdk_device_t * devices
Definition: dpdk.h:355
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
vlib_main_t * vm
Definition: buffer.c:276
vec_header_t h
Definition: buffer.c:275
struct rte_mbuf *** rx_vectors
Definition: dpdk.h:186
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:655
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:211
static 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:408
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:201
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
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:103
unsigned short u16
Definition: types.h:57
vlib_buffer_t buffer
Definition: dpdk.h:440
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:484
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:777
#define vnet_buffer(b)
Definition: buffer.h:294
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:152
#define vec_foreach(var, vec)
Vector iterator.
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:385
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:74
static_always_inline void dpdk_prefetch_buffer(struct rte_mbuf *mb)
Definition: node.c:241
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:1170
Definition: defs.h:46
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".