FD.io VPP  v17.07-30-g839fa73
Vector Packet Processing
node.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <vnet/vnet.h>
16 #include <vppinfra/vec.h>
17 #include <vppinfra/error.h>
18 #include <vppinfra/format.h>
19 #include <vppinfra/xxhash.h>
20 
21 #include <vnet/ethernet/ethernet.h>
22 #include <dpdk/device/dpdk.h>
24 #include <vnet/mpls/packet.h>
25 #include <vnet/handoff.h>
26 #include <vnet/devices/devices.h>
27 #include <vnet/feature/feature.h>
28 
29 #include <dpdk/device/dpdk_priv.h>
30 
31 static char *dpdk_error_strings[] = {
32 #define _(n,s) s,
34 #undef _
35 };
36 
37 always_inline int
39 {
41  return (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP4));
42 }
43 
44 always_inline int
46 {
48  return (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_IP6));
49 }
50 
51 always_inline int
53 {
55  return (h->type == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS));
56 }
57 
59 dpdk_rx_next_from_etype (struct rte_mbuf * mb, vlib_buffer_t * b0)
60 {
62  {
63  if (PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
65  else
67  }
68  else if (PREDICT_TRUE (vlib_buffer_is_ip6 (b0)))
70  else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
72  else
74 }
75 
77 dpdk_rx_next_from_packet_start (struct rte_mbuf * mb, vlib_buffer_t * b0)
78 {
79  word start_delta;
80  int rv;
81 
82  start_delta = b0->current_data -
83  ((mb->buf_addr + mb->data_off) - (void *) b0->data);
84 
85  vlib_buffer_advance (b0, -start_delta);
86 
88  {
89  if (PREDICT_TRUE ((mb->ol_flags & PKT_RX_IP_CKSUM_GOOD) != 0))
91  else
93  }
94  else if (PREDICT_TRUE (vlib_buffer_is_ip6 (b0)))
96  else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
98  else
100 
101  vlib_buffer_advance (b0, start_delta);
102  return rv;
103 }
104 
105 always_inline void
106 dpdk_rx_error_from_mb (struct rte_mbuf *mb, u32 * next, u8 * error)
107 {
108  if (mb->ol_flags & PKT_RX_IP_CKSUM_BAD)
109  {
110  *error = DPDK_ERROR_IP_CHECKSUM_ERROR;
112  }
113  else
114  *error = DPDK_ERROR_NONE;
115 }
116 
117 static void
119  vlib_node_runtime_t * node,
120  dpdk_device_t * xd,
121  u16 queue_id, u32 * buffers, uword n_buffers)
122 {
123  vlib_main_t *vm = vlib_get_main ();
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 #if defined(CLIB_HAVE_VEC128)
271  int i;
272  for (i = 0; i < 2; i++)
273  {
274  *(u8x32 *) (((u8 *) d0) + i * 32) =
275  *(u8x32 *) (((u8 *) d1) + i * 32) =
276  *(u8x32 *) (((u8 *) d2) + i * 32) =
277  *(u8x32 *) (((u8 *) d3) + i * 32) = *(u8x32 *) (((u8 *) s) + i * 32);
278  }
279 #elif defined(CLIB_HAVE_VEC64)
280  int i;
281  for (i = 0; i < 4; i++)
282  {
283  *(u8x16 *) (((u8 *) d0) + i * 16) =
284  *(u8x16 *) (((u8 *) d1) + i * 16) =
285  *(u8x16 *) (((u8 *) d2) + i * 16) =
286  *(u8x16 *) (((u8 *) d3) + i * 16) = *(u8x16 *) (((u8 *) s) + i * 16);
287  }
288 #else
289 #error "Either CLIB_HAVE_VEC128 or CLIB_HAVE_VEC64 has to be defined"
290 #endif
291 }
292 
293 /*
294  * This function is used when there are no worker threads.
295  * The main thread performs IO and forwards the packets.
296  */
299  vlib_node_runtime_t * node, u32 thread_index, u16 queue_id,
300  int maybe_multiseg)
301 {
302  u32 n_buffers;
304  u32 n_left_to_next, *to_next;
305  u32 mb_index;
306  vlib_main_t *vm = vlib_get_main ();
307  uword n_rx_bytes = 0;
308  u32 n_trace, trace_cnt __attribute__ ((unused));
310  vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, thread_index);
311 
312  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
313  return 0;
314 
315  n_buffers = dpdk_rx_burst (dm, xd, queue_id);
316 
317  if (n_buffers == 0)
318  {
319  return 0;
320  }
321 
322  vec_reset_length (xd->d_trace_buffers[thread_index]);
323  trace_cnt = n_trace = vlib_get_trace_count (vm, node);
324 
325  if (n_trace > 0)
326  {
327  u32 n = clib_min (n_trace, n_buffers);
328  mb_index = 0;
329 
330  while (n--)
331  {
332  struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++];
334  vec_add1 (xd->d_trace_buffers[thread_index],
335  vlib_get_buffer_index (vm, b));
336  }
337  }
338 
340 
341  /* Update buffer template */
342  vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
343  bt->error = node->errors[DPDK_ERROR_NONE];
344 
345  mb_index = 0;
346 
347  while (n_buffers > 0)
348  {
349  vlib_buffer_t *b0, *b1, *b2, *b3;
350  u32 bi0, next0;
351  u32 bi1, next1;
352  u32 bi2, next2;
353  u32 bi3, next3;
354  u8 error0, error1, error2, error3;
355  u64 or_ol_flags;
356 
357  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
358 
359  while (n_buffers >= 12 && n_left_to_next >= 4)
360  {
361  struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
362 
363  /* prefetches are interleaved with the rest of the code to reduce
364  pressure on L1 cache */
365  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 8]);
366  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 4]);
367 
368  mb0 = xd->rx_vectors[queue_id][mb_index];
369  mb1 = xd->rx_vectors[queue_id][mb_index + 1];
370  mb2 = xd->rx_vectors[queue_id][mb_index + 2];
371  mb3 = xd->rx_vectors[queue_id][mb_index + 3];
372 
373  ASSERT (mb0);
374  ASSERT (mb1);
375  ASSERT (mb2);
376  ASSERT (mb3);
377 
378  if (maybe_multiseg)
379  {
380  if (PREDICT_FALSE (mb0->nb_segs > 1))
381  dpdk_prefetch_buffer (mb0->next);
382  if (PREDICT_FALSE (mb1->nb_segs > 1))
383  dpdk_prefetch_buffer (mb1->next);
384  if (PREDICT_FALSE (mb2->nb_segs > 1))
385  dpdk_prefetch_buffer (mb2->next);
386  if (PREDICT_FALSE (mb3->nb_segs > 1))
387  dpdk_prefetch_buffer (mb3->next);
388  }
389 
390  b0 = vlib_buffer_from_rte_mbuf (mb0);
391  b1 = vlib_buffer_from_rte_mbuf (mb1);
392  b2 = vlib_buffer_from_rte_mbuf (mb2);
393  b3 = vlib_buffer_from_rte_mbuf (mb3);
394 
395  dpdk_buffer_init_from_template (b0, b1, b2, b3, bt);
396 
397  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 9]);
398  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 5]);
399 
400  /* current_data must be set to -RTE_PKTMBUF_HEADROOM in template */
401  b0->current_data += mb0->data_off;
402  b1->current_data += mb1->data_off;
403  b2->current_data += mb2->data_off;
404  b3->current_data += mb3->data_off;
405 
406  b0->current_length = mb0->data_len;
407  b1->current_length = mb1->data_len;
408  b2->current_length = mb2->data_len;
409  b3->current_length = mb3->data_len;
410 
411  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 10]);
412  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 7]);
413 
414  bi0 = vlib_get_buffer_index (vm, b0);
415  bi1 = vlib_get_buffer_index (vm, b1);
416  bi2 = vlib_get_buffer_index (vm, b2);
417  bi3 = vlib_get_buffer_index (vm, b3);
418 
419  to_next[0] = bi0;
420  to_next[1] = bi1;
421  to_next[2] = bi2;
422  to_next[3] = bi3;
423  to_next += 4;
424  n_left_to_next -= 4;
425 
426  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
427  {
428  next0 = next1 = next2 = next3 = xd->per_interface_next_index;
429  }
430  else
431  {
432  next0 = dpdk_rx_next_from_etype (mb0, b0);
433  next1 = dpdk_rx_next_from_etype (mb1, b1);
434  next2 = dpdk_rx_next_from_etype (mb2, b2);
435  next3 = dpdk_rx_next_from_etype (mb3, b3);
436  }
437 
438  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 11]);
439  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id][mb_index + 6]);
440 
441  or_ol_flags = (mb0->ol_flags | mb1->ol_flags |
442  mb2->ol_flags | mb3->ol_flags);
443  if (PREDICT_FALSE (or_ol_flags & PKT_RX_IP_CKSUM_BAD))
444  {
445  dpdk_rx_error_from_mb (mb0, &next0, &error0);
446  dpdk_rx_error_from_mb (mb1, &next1, &error1);
447  dpdk_rx_error_from_mb (mb2, &next2, &error2);
448  dpdk_rx_error_from_mb (mb3, &next3, &error3);
449  b0->error = node->errors[error0];
450  b1->error = node->errors[error1];
451  b2->error = node->errors[error2];
452  b3->error = node->errors[error3];
453  }
454 
459 
460  n_rx_bytes += mb0->pkt_len;
461  n_rx_bytes += mb1->pkt_len;
462  n_rx_bytes += mb2->pkt_len;
463  n_rx_bytes += mb3->pkt_len;
464 
465  /* Process subsequent segments of multi-segment packets */
466  if (maybe_multiseg)
467  {
468  dpdk_process_subseq_segs (vm, b0, mb0, fl);
469  dpdk_process_subseq_segs (vm, b1, mb1, fl);
470  dpdk_process_subseq_segs (vm, b2, mb2, fl);
471  dpdk_process_subseq_segs (vm, b3, mb3, fl);
472  }
473 
474  /*
475  * Turn this on if you run into
476  * "bad monkey" contexts, and you want to know exactly
477  * which nodes they've visited... See main.c...
478  */
483 
484  /* Do we have any driver RX features configured on the interface? */
486  &next0, &next1, &next2, &next3,
487  b0, b1, b2, b3);
488 
489  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
490  to_next, n_left_to_next,
491  bi0, bi1, bi2, bi3,
492  next0, next1, next2, next3);
493  n_buffers -= 4;
494  mb_index += 4;
495  }
496  while (n_buffers > 0 && n_left_to_next > 0)
497  {
498  struct rte_mbuf *mb0 = xd->rx_vectors[queue_id][mb_index];
499 
500  if (PREDICT_TRUE (n_buffers > 3))
501  {
502  dpdk_prefetch_buffer (xd->rx_vectors[queue_id][mb_index + 2]);
503  dpdk_prefetch_ethertype (xd->rx_vectors[queue_id]
504  [mb_index + 1]);
505  }
506 
507  ASSERT (mb0);
508 
509  b0 = vlib_buffer_from_rte_mbuf (mb0);
510 
511  /* Prefetch one next segment if it exists. */
512  if (PREDICT_FALSE (mb0->nb_segs > 1))
513  dpdk_prefetch_buffer (mb0->next);
514 
516 
517  ASSERT (b0->current_data == -RTE_PKTMBUF_HEADROOM);
518  b0->current_data += mb0->data_off;
519  b0->current_length = mb0->data_len;
520 
521  bi0 = vlib_get_buffer_index (vm, b0);
522 
523  to_next[0] = bi0;
524  to_next++;
525  n_left_to_next--;
526 
527  if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
528  next0 = xd->per_interface_next_index;
529  else
530  next0 = dpdk_rx_next_from_etype (mb0, b0);
531 
532  dpdk_rx_error_from_mb (mb0, &next0, &error0);
533  b0->error = node->errors[error0];
534 
536 
537  n_rx_bytes += mb0->pkt_len;
538 
539  /* Process subsequent segments of multi-segment packets */
540  dpdk_process_subseq_segs (vm, b0, mb0, fl);
541 
542  /*
543  * Turn this on if you run into
544  * "bad monkey" contexts, and you want to know exactly
545  * which nodes they've visited... See main.c...
546  */
548 
549  /* Do we have any driver RX features configured on the interface? */
551  b0);
552 
553  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
554  to_next, n_left_to_next,
555  bi0, next0);
556  n_buffers--;
557  mb_index++;
558  }
559  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
560  }
561 
562  if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[thread_index]) > 0))
563  {
564  dpdk_rx_trace (dm, node, xd, queue_id,
565  xd->d_trace_buffers[thread_index],
566  vec_len (xd->d_trace_buffers[thread_index]));
567  vlib_set_trace_count (vm, node,
568  n_trace -
569  vec_len (xd->d_trace_buffers[thread_index]));
570  }
571 
573  (vnet_get_main ()->interface_main.combined_sw_if_counters
575  thread_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
576 
577  vnet_device_increment_rx_packets (thread_index, mb_index);
578 
579  return mb_index;
580 }
581 
582 static inline void
584 {
585  /* Limit the poll rate by sleeping for N msec between polls */
586  if (PREDICT_FALSE (dm->poll_sleep_usec != 0))
587  {
588  struct timespec ts, tsrem;
589 
590  ts.tv_sec = 0;
591  ts.tv_nsec = 1000 * dm->poll_sleep_usec;
592 
593  while (nanosleep (&ts, &tsrem) < 0)
594  {
595  ts = tsrem;
596  }
597  }
598 }
599 
600 /** \brief Main DPDK input node
601  @node dpdk-input
602 
603  This is the main DPDK input node: across each assigned interface,
604  call rte_eth_rx_burst(...) or similar to obtain a vector of
605  packets to process. Handle early packet discard. Derive @c
606  vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata,
607  Depending on the resulting metadata: adjust <code>b->current_data,
608  b->current_length </code> and dispatch directly to
609  ip4-input-no-checksum, or ip6-input. Trace the packet if required.
610 
611  @param vm vlib_main_t corresponding to the current thread
612  @param node vlib_node_runtime_t
613  @param f vlib_frame_t input-node, not used.
614 
615  @par Graph mechanics: buffer metadata, next index usage
616 
617  @em Uses:
618  - <code>struct rte_mbuf mb->ol_flags</code>
619  - PKT_RX_IP_CKSUM_BAD
620  - <code> RTE_ETH_IS_xxx_HDR(mb->packet_type) </code>
621  - packet classification result
622 
623  @em Sets:
624  - <code>b->error</code> if the packet is to be dropped immediately
625  - <code>b->current_data, b->current_length</code>
626  - adjusted as needed to skip the L2 header in direct-dispatch cases
627  - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
628  - rx interface sw_if_index
629  - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
630  - required by ipX-lookup
631  - <code>b->flags</code>
632  - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
633 
634  <em>Next Nodes:</em>
635  - Static arcs to: error-drop, ethernet-input,
636  ip4-input-no-checksum, ip6-input, mpls-input
637  - per-interface redirection, controlled by
638  <code>xd->per_interface_next_index</code>
639 */
640 
641 static uword
643 {
644  dpdk_main_t *dm = &dpdk_main;
645  dpdk_device_t *xd;
646  uword n_rx_packets = 0;
647  vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
649  u32 thread_index = node->thread_index;
650 
651  /*
652  * Poll all devices on this cpu for input/interrupts.
653  */
654  /* *INDENT-OFF* */
656  {
657  xd = vec_elt_at_index(dm->devices, dq->dev_instance);
659  n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 1);
660  else
661  n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 0);
662  }
663  /* *INDENT-ON* */
664 
665  poll_rate_limit (dm);
666 
667  return n_rx_packets;
668 }
669 
670 /* *INDENT-OFF* */
672  .function = dpdk_input,
673  .type = VLIB_NODE_TYPE_INPUT,
674  .name = "dpdk-input",
675  .sibling_of = "device-input",
676 
677  /* Will be enabled if/when hardware is detected. */
678  .state = VLIB_NODE_STATE_DISABLED,
679 
680  .format_buffer = format_ethernet_header_with_length,
681  .format_trace = format_dpdk_rx_dma_trace,
682 
683  .n_errors = DPDK_N_ERROR,
684  .error_strings = dpdk_error_strings,
685 };
686 
688 /* *INDENT-ON* */
689 
690 /*
691  * fd.io coding-style-patch-verification: ON
692  *
693  * Local Variables:
694  * eval: (c-set-style "gnu")
695  * End:
696  */
u32 ** d_trace_buffers
Definition: dpdk.h:164
static void vnet_device_increment_rx_packets(u32 thread_index, u64 count)
Definition: devices.h:109
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
vnet_device_and_queue_t * devices_and_queues
Definition: devices.h:69
static uword dpdk_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Main DPDK input node.
Definition: node.c:642
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define clib_min(x, y)
Definition: clib.h:332
static int vlib_buffer_is_mpls(vlib_buffer_t *b)
Definition: node.c:52
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:143
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:211
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:468
static void dpdk_rx_trace(dpdk_main_t *dm, vlib_node_runtime_t *node, dpdk_device_t *xd, u16 queue_id, u32 *buffers, uword n_buffers)
Definition: node.c:118
dpdk_main_t dpdk_main
Definition: init.c:36
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:421
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:169
#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:157
#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:344
vlib_error_t * errors
Vector of errors for this node.
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:172
static int vlib_buffer_is_ip6(vlib_buffer_t *b)
Definition: node.c:45
u16 thread_index
thread this node runs on
Definition: node.h:466
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: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:412
#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:174
u32 device_index
Definition: dpdk.h:151
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:583
struct rte_mbuf mb
Definition: dpdk.h:410
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:154
#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:444
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
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
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:402
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:329
#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:366
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:170
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:91
dpdk_device_t * devices
Definition: dpdk.h:337
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
struct rte_mbuf *** rx_vectors
Definition: dpdk.h:161
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:671
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static void dpdk_rx_error_from_mb(struct rte_mbuf *mb, u32 *next, u8 *error)
Definition: node.c:106
u32 poll_sleep_usec
Definition: dpdk.h:379
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
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
#define foreach_device_and_queue(var, vec)
Definition: devices.h:155
unsigned short u16
Definition: types.h:57
vlib_buffer_t buffer
Definition: dpdk.h:411
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:496
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:298
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:303
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:144
u8 data[0]
Packet data.
Definition: buffer.h:152
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:1175
Definition: defs.h:46
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".