FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
device.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/format.h>
18 #include <vlib/unix/cj.h>
19 #include <assert.h>
20 
21 #include <vnet/ethernet/ethernet.h>
22 #include <dpdk/device/dpdk.h>
23 
24 #include <dpdk/device/dpdk_priv.h>
25 #include <vppinfra/error.h>
26 
27 #define foreach_dpdk_tx_func_error \
28  _(BAD_RETVAL, "DPDK tx function returned an error") \
29  _(PKT_DROP, "Tx packet drops (dpdk tx failure)")
30 
31 typedef enum
32 {
33 #define _(f,s) DPDK_TX_FUNC_ERROR_##f,
35 #undef _
38 
39 static char *dpdk_tx_func_error_strings[] = {
40 #define _(n,s) s,
42 #undef _
43 };
44 
45 static clib_error_t *
47  const u8 * old_address, const u8 * address)
48 {
49  int error;
50  dpdk_main_t *dm = &dpdk_main;
52 
53  error = rte_eth_dev_default_mac_addr_set (xd->port_id,
54  (struct ether_addr *) address);
55 
56  if (error)
57  {
58  return clib_error_return (0, "mac address set failed: %d", error);
59  }
60  else
61  {
63  vec_add (xd->default_mac_address, address, sizeof (address));
64  return NULL;
65  }
66 }
67 
68 static void
70  dpdk_device_t * xd, u16 queue_id,
71  vlib_buffer_t * buffer)
72 {
73  vlib_main_t *vm = vlib_get_main ();
74  dpdk_tx_trace_t *t0;
75  struct rte_mbuf *mb;
76 
77  mb = rte_mbuf_from_vlib_buffer (buffer);
78 
79  t0 = vlib_add_trace (vm, node, buffer, sizeof (t0[0]));
80  t0->queue_index = queue_id;
81  t0->device_index = xd->device_index;
82  t0->buffer_index = vlib_get_buffer_index (vm, buffer);
83  clib_memcpy_fast (&t0->mb, mb, sizeof (t0->mb));
84  clib_memcpy_fast (&t0->buffer, buffer,
85  sizeof (buffer[0]) - sizeof (buffer->pre_data));
86  clib_memcpy_fast (t0->buffer.pre_data, buffer->data + buffer->current_data,
87  sizeof (t0->buffer.pre_data));
88  clib_memcpy_fast (&t0->data, mb->buf_addr + mb->data_off,
89  sizeof (t0->data));
90 }
91 
94  int maybe_multiseg)
95 {
96  struct rte_mbuf *mb, *first_mb, *last_mb;
97 
98  /* buffer is coming from non-dpdk source so we need to init
99  rte_mbuf header */
100  if (PREDICT_FALSE ((b->flags & VLIB_BUFFER_EXT_HDR_VALID) == 0))
101  {
102  vlib_buffer_t *b2 = b;
103  last_mb = mb = rte_mbuf_from_vlib_buffer (b2);
104  rte_pktmbuf_reset (mb);
105  while (maybe_multiseg && (b2->flags & VLIB_BUFFER_NEXT_PRESENT))
106  {
107  b2 = vlib_get_buffer (vm, b2->next_buffer);
108  mb = rte_mbuf_from_vlib_buffer (b2);
109  rte_pktmbuf_reset (mb);
110  }
111  }
112 
113  last_mb = first_mb = mb = rte_mbuf_from_vlib_buffer (b);
114  first_mb->nb_segs = 1;
115  mb->data_len = b->current_length;
116  mb->pkt_len = maybe_multiseg ? vlib_buffer_length_in_chain (vm, b) :
117  b->current_length;
118  mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + b->current_data;
119 
120  while (maybe_multiseg && (b->flags & VLIB_BUFFER_NEXT_PRESENT))
121  {
122  b = vlib_get_buffer (vm, b->next_buffer);
123  mb = rte_mbuf_from_vlib_buffer (b);
124  last_mb->next = mb;
125  last_mb = mb;
126  mb->data_len = b->current_length;
127  mb->pkt_len = b->current_length;
128  mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + b->current_data;
129  first_mb->nb_segs++;
130  if (PREDICT_FALSE (b->n_add_refs))
131  {
132  rte_mbuf_refcnt_update (mb, b->n_add_refs);
133  b->n_add_refs = 0;
134  }
135  }
136 }
137 
138 /*
139  * This function calls the dpdk's tx_burst function to transmit the packets.
140  * It manages a lock per-device if the device does not
141  * support multiple queues. It returns the number of packets untransmitted
142  * If all packets are transmitted (the normal case), the function returns 0.
143  */
146  dpdk_device_t * xd,
147  struct rte_mbuf **mb, u32 n_left)
148 {
149  dpdk_main_t *dm = &dpdk_main;
150  u32 n_retry;
151  int n_sent = 0;
152  int queue_id;
153 
154  n_retry = 16;
155  queue_id = vm->thread_index;
156 
157  do
158  {
159  /*
160  * This device only supports one TX queue,
161  * and we're running multi-threaded...
162  */
163  if (PREDICT_FALSE (xd->lockp != 0))
164  {
165  queue_id = queue_id % xd->tx_q_used;
166  while (clib_atomic_test_and_set (xd->lockp[queue_id]))
167  /* zzzz */
168  queue_id = (queue_id + 1) % xd->tx_q_used;
169  }
170 
171  if (PREDICT_FALSE (xd->flags & DPDK_DEVICE_FLAG_HQOS)) /* HQoS ON */
172  {
173  /* no wrap, transmit in one burst */
175  &xd->hqos_wt[vm->thread_index];
176 
177  ASSERT (hqos->swq != NULL);
178 
179  dpdk_hqos_metadata_set (hqos, mb, n_left);
180  n_sent = rte_ring_sp_enqueue_burst (hqos->swq, (void **) mb,
181  n_left, 0);
182  }
183  else if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD))
184  {
185  /* no wrap, transmit in one burst */
186  n_sent = rte_eth_tx_burst (xd->port_id, queue_id, mb, n_left);
187  }
188  else
189  {
190  ASSERT (0);
191  n_sent = 0;
192  }
193 
194  if (PREDICT_FALSE (xd->lockp != 0))
195  clib_atomic_release (xd->lockp[queue_id]);
196 
197  if (PREDICT_FALSE (n_sent < 0))
198  {
199  // emit non-fatal message, bump counter
200  vnet_main_t *vnm = dm->vnet_main;
202  u32 node_index;
203 
204  node_index = vec_elt_at_index (im->hw_interfaces,
205  xd->hw_if_index)->tx_node_index;
206 
207  vlib_error_count (vm, node_index, DPDK_TX_FUNC_ERROR_BAD_RETVAL, 1);
208  clib_warning ("rte_eth_tx_burst[%d]: error %d",
209  xd->port_id, n_sent);
210  return n_left; // untransmitted packets
211  }
212  n_left -= n_sent;
213  mb += n_sent;
214  }
215  while (n_sent && n_left && (n_retry > 0));
216 
217  return n_left;
218 }
219 
221 dpdk_prefetch_buffer (vlib_main_t * vm, struct rte_mbuf *mb)
222 {
224  CLIB_PREFETCH (mb, 2 * CLIB_CACHE_LINE_BYTES, STORE);
226 }
227 
230  struct rte_mbuf *mb)
231 {
232  u32 ip_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
233  u32 tcp_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
234  u32 udp_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
235  int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
236  u64 ol_flags;
237 
238  /* Is there any work for us? */
239  if (PREDICT_TRUE ((ip_cksum | tcp_cksum | udp_cksum) == 0))
240  return;
241 
242  mb->l2_len = vnet_buffer (b)->l3_hdr_offset - b->current_data;
243  mb->l3_len = vnet_buffer (b)->l4_hdr_offset -
244  vnet_buffer (b)->l3_hdr_offset;
245  mb->outer_l3_len = 0;
246  mb->outer_l2_len = 0;
247  ol_flags = is_ip4 ? PKT_TX_IPV4 : PKT_TX_IPV6;
248  ol_flags |= ip_cksum ? PKT_TX_IP_CKSUM : 0;
249  ol_flags |= tcp_cksum ? PKT_TX_TCP_CKSUM : 0;
250  ol_flags |= udp_cksum ? PKT_TX_UDP_CKSUM : 0;
251  mb->ol_flags |= ol_flags;
252 
253  /* we are trying to help compiler here by using local ol_flags with known
254  state of all flags */
255  if (xd->flags & DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM)
256  rte_net_intel_cksum_flags_prepare (mb, ol_flags);
257 }
258 
259 /*
260  * Transmits the packets on the frame to the interface associated with the
261  * node. It first copies packets on the frame to a per-thread arrays
262  * containing the rte_mbuf pointers.
263  */
265  vlib_node_runtime_t * node,
266  vlib_frame_t * f)
267 {
268  dpdk_main_t *dm = &dpdk_main;
269  vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
271  u32 n_packets = f->n_vectors;
272  u32 n_left;
273  u32 *from;
274  u32 thread_index = vm->thread_index;
275  int queue_id = thread_index;
276  u32 tx_pkts = 0, all_or_flags = 0;
278  thread_index);
279  struct rte_mbuf **mb;
280  vlib_buffer_t *b[4];
281 
282  from = vlib_frame_vector_args (f);
283 
284  ASSERT (n_packets <= VLIB_FRAME_SIZE);
285 
286  /* TX PCAP tracing */
288  {
289  n_left = n_packets;
290  while (n_left > 0)
291  {
292  u32 bi0 = from[0];
293  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
294  if (dm->pcap[VLIB_TX].pcap_sw_if_index == 0 ||
296  == vnet_buffer (b0)->sw_if_index[VLIB_TX])
297  pcap_add_buffer (&dm->pcap[VLIB_TX].pcap_main, vm, bi0, 512);
298  from++;
299  n_left--;
300  }
301  }
302 
303  /* calculate rte_mbuf pointers out of buffer indices */
305  (void **) ptd->mbufs, n_packets,
306  -(i32) sizeof (struct rte_mbuf));
307 
308  from = vlib_frame_vector_args (f);
309  n_left = n_packets;
310  mb = ptd->mbufs;
311 
312  while (n_left >= 8)
313  {
314  u32 or_flags;
315 
316  dpdk_prefetch_buffer (vm, mb[4]);
317  dpdk_prefetch_buffer (vm, mb[5]);
318  dpdk_prefetch_buffer (vm, mb[6]);
319  dpdk_prefetch_buffer (vm, mb[7]);
320 
321  b[0] = vlib_buffer_from_rte_mbuf (mb[0]);
322  b[1] = vlib_buffer_from_rte_mbuf (mb[1]);
323  b[2] = vlib_buffer_from_rte_mbuf (mb[2]);
324  b[3] = vlib_buffer_from_rte_mbuf (mb[3]);
325 
326  or_flags = b[0]->flags | b[1]->flags | b[2]->flags | b[3]->flags;
327  all_or_flags |= or_flags;
328 
333 
334  if (or_flags & VLIB_BUFFER_NEXT_PRESENT)
335  {
336  dpdk_validate_rte_mbuf (vm, b[0], 1);
337  dpdk_validate_rte_mbuf (vm, b[1], 1);
338  dpdk_validate_rte_mbuf (vm, b[2], 1);
339  dpdk_validate_rte_mbuf (vm, b[3], 1);
340  }
341  else
342  {
343  dpdk_validate_rte_mbuf (vm, b[0], 0);
344  dpdk_validate_rte_mbuf (vm, b[1], 0);
345  dpdk_validate_rte_mbuf (vm, b[2], 0);
346  dpdk_validate_rte_mbuf (vm, b[3], 0);
347  }
348 
349  if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD) &&
350  (or_flags &
351  (VNET_BUFFER_F_OFFLOAD_TCP_CKSUM
352  | VNET_BUFFER_F_OFFLOAD_IP_CKSUM
353  | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM))))
354  {
355  dpdk_buffer_tx_offload (xd, b[0], mb[0]);
356  dpdk_buffer_tx_offload (xd, b[1], mb[1]);
357  dpdk_buffer_tx_offload (xd, b[2], mb[2]);
358  dpdk_buffer_tx_offload (xd, b[3], mb[3]);
359  }
360 
361  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
362  {
363  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
364  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[0]);
365  if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
366  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[1]);
367  if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
368  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[2]);
369  if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
370  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[3]);
371  }
372 
373  mb += 4;
374  n_left -= 4;
375  }
376  while (n_left > 0)
377  {
378  b[0] = vlib_buffer_from_rte_mbuf (mb[0]);
379  all_or_flags |= b[0]->flags;
381 
382  dpdk_validate_rte_mbuf (vm, b[0], 1);
383  dpdk_buffer_tx_offload (xd, b[0], mb[0]);
384 
385  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
386  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
387  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[0]);
388 
389  mb++;
390  n_left--;
391  }
392 
393  /* transmit as many packets as possible */
394  tx_pkts = n_packets = mb - ptd->mbufs;
395  n_left = tx_burst_vector_internal (vm, xd, ptd->mbufs, n_packets);
396 
397  {
398  /* If there is no callback then drop any non-transmitted packets */
399  if (PREDICT_FALSE (n_left))
400  {
401  tx_pkts -= n_left;
403  vnet_main_t *vnm = vnet_get_main ();
404 
407 
408  vlib_increment_simple_counter (cm, thread_index, xd->sw_if_index,
409  n_left);
410 
411  vlib_error_count (vm, node->node_index, DPDK_TX_FUNC_ERROR_PKT_DROP,
412  n_left);
413 
414  while (n_left--)
415  rte_pktmbuf_free (ptd->mbufs[n_packets - n_left - 1]);
416  }
417  }
418 
419  return tx_pkts;
420 }
421 
422 static void
424 {
425  dpdk_main_t *dm = &dpdk_main;
426  dpdk_device_t *xd = vec_elt_at_index (dm->devices, instance);
427 
428  /*
429  * Set the "last_cleared_stats" to the current stats, so that
430  * things appear to clear from a display perspective.
431  */
433 
434  clib_memcpy_fast (&xd->last_cleared_stats, &xd->stats, sizeof (xd->stats));
437  sizeof (xd->last_cleared_xstats[0]));
438 
439 }
440 
441 static clib_error_t *
443 {
444  vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index);
445  uword is_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
446  dpdk_main_t *dm = &dpdk_main;
448 
449  if (xd->flags & DPDK_DEVICE_FLAG_PMD_INIT_FAIL)
450  return clib_error_return (0, "Interface not initialized");
451 
452  if (is_up)
453  {
454  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
455  dpdk_device_start (xd);
456  xd->flags |= DPDK_DEVICE_FLAG_ADMIN_UP;
457  f64 now = vlib_time_now (dm->vlib_main);
458  dpdk_update_counters (xd, now);
459  dpdk_update_link_state (xd, now);
460  }
461  else
462  {
464  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0)
465  dpdk_device_stop (xd);
466  xd->flags &= ~DPDK_DEVICE_FLAG_ADMIN_UP;
467  }
468 
469  return /* no error */ 0;
470 }
471 
472 /*
473  * Dynamically redirect all pkts from a specific interface
474  * to the specified node
475  */
476 static void
478  u32 node_index)
479 {
480  dpdk_main_t *xm = &dpdk_main;
481  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
483 
484  /* Shut off redirection */
485  if (node_index == ~0)
486  {
487  xd->per_interface_next_index = node_index;
488  return;
489  }
490 
492  vlib_node_add_next (xm->vlib_main, dpdk_input_node.index, node_index);
493 }
494 
495 
496 static clib_error_t *
498  u32 hw_if_index,
499  struct vnet_sw_interface_t *st, int is_add)
500 {
501  dpdk_main_t *xm = &dpdk_main;
502  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
505  int r, vlan_offload;
506  u32 prev_subifs = xd->num_subifs;
507  clib_error_t *err = 0;
508 
509  if (is_add)
510  xd->num_subifs++;
511  else if (xd->num_subifs)
512  xd->num_subifs--;
513 
514  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
515  goto done;
516 
517  /* currently we program VLANS only for IXGBE VF and I40E VF */
518  if ((xd->pmd != VNET_DPDK_PMD_IXGBEVF) && (xd->pmd != VNET_DPDK_PMD_I40EVF))
519  goto done;
520 
521  if (t->sub.eth.flags.no_tags == 1)
522  goto done;
523 
524  if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1))
525  {
526  xd->num_subifs = prev_subifs;
527  err = clib_error_return (0, "unsupported VLAN setup");
528  goto done;
529  }
530 
531  vlan_offload = rte_eth_dev_get_vlan_offload (xd->port_id);
532  vlan_offload |= ETH_VLAN_FILTER_OFFLOAD;
533 
534  if ((r = rte_eth_dev_set_vlan_offload (xd->port_id, vlan_offload)))
535  {
536  xd->num_subifs = prev_subifs;
537  err = clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
538  xd->port_id, r);
539  goto done;
540  }
541 
542 
543  if ((r =
544  rte_eth_dev_vlan_filter (xd->port_id,
545  t->sub.eth.outer_vlan_id, is_add)))
546  {
547  xd->num_subifs = prev_subifs;
548  err = clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
549  xd->port_id, r);
550  goto done;
551  }
552 
553 done:
554  if (xd->num_subifs)
555  xd->flags |= DPDK_DEVICE_FLAG_HAVE_SUBIF;
556  else
557  xd->flags &= ~DPDK_DEVICE_FLAG_HAVE_SUBIF;
558 
559  return err;
560 }
561 
562 /* *INDENT-OFF* */
564  .name = "dpdk",
565  .tx_function_n_errors = DPDK_TX_FUNC_N_ERROR,
566  .tx_function_error_strings = dpdk_tx_func_error_strings,
567  .format_device_name = format_dpdk_device_name,
568  .format_device = format_dpdk_device,
569  .format_tx_trace = format_dpdk_tx_trace,
570  .clear_counters = dpdk_clear_hw_interface_counters,
571  .admin_up_down_function = dpdk_interface_admin_up_down,
572  .subif_add_del_function = dpdk_subif_add_del_function,
573  .rx_redirect_to_node = dpdk_set_interface_next_node,
574  .mac_addr_change_function = dpdk_set_mac_address,
575  .format_flow = format_dpdk_flow,
576  .flow_ops_function = dpdk_flow_ops_fn,
577 };
578 /* *INDENT-ON* */
579 
580 #define UP_DOWN_FLAG_EVENT 1
581 
582 static uword
585 {
586  clib_error_t *error = 0;
587  uword event_type;
588  uword *event_data = 0;
590  u32 flags;
591 
592  while (1)
593  {
595 
596  event_type = vlib_process_get_events (vm, &event_data);
597 
599 
600  switch (event_type)
601  {
602  case UP_DOWN_FLAG_EVENT:
603  {
604  if (vec_len (event_data) == 2)
605  {
606  sw_if_index = event_data[0];
607  flags = event_data[1];
608  error =
610  flags);
611  clib_error_report (error);
612  }
613  }
614  break;
615  }
616 
617  vec_reset_length (event_data);
618 
620 
621  }
622  return 0; /* or not */
623 }
624 
625 /* *INDENT-OFF* */
627  .function = admin_up_down_process,
628  .type = VLIB_NODE_TYPE_PROCESS,
629  .name = "admin-up-down-process",
630  .process_log2_n_stack_bytes = 17, // 256KB
631 };
632 /* *INDENT-ON* */
633 
634 /*
635  * fd.io coding-style-patch-verification: ON
636  *
637  * Local Variables:
638  * eval: (c-set-style "gnu")
639  * End:
640  */
u8 * default_mac_address
Definition: dpdk.h:268
format_function_t format_dpdk_tx_trace
Definition: dpdk.h:518
vmrglw vmrglh hi
format_function_t format_dpdk_flow
Definition: dpdk.h:522
typedef address
Definition: ip_types.api:30
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
u32 flags
Definition: vhost_user.h:115
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:593
dpdk_main_t dpdk_main
Definition: init.c:43
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
vnet_interface_main_t interface_main
Definition: vnet.h:56
#define PREDICT_TRUE(x)
Definition: clib.h:112
unsigned long u64
Definition: types.h:89
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
Definition: error_funcs.h:57
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
#define NULL
Definition: clib.h:58
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:232
static char * dpdk_tx_func_error_strings[]
Definition: device.c:39
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:52
u16 flags
Definition: dpdk.h:216
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 thread_index
Definition: main.h:179
static clib_error_t * dpdk_set_mac_address(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *address)
Definition: device.c:46
u32 per_interface_next_index
Definition: dpdk.h:211
static_always_inline void vlib_get_buffers_with_offset(vlib_main_t *vm, u32 *bi, void **b, int count, i32 offset)
Translate array of buffer indices into buffer pointers with offset.
Definition: buffer_funcs.h:80
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
Definition: counter.h:78
struct rte_eth_xstat * last_cleared_xstats
Definition: dpdk.h:263
u16 num_subifs
Definition: dpdk.h:225
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:267
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1092
unsigned char u8
Definition: types.h:56
static void dpdk_tx_trace_buffer(dpdk_main_t *dm, vlib_node_runtime_t *node, dpdk_device_t *xd, u16 queue_id, vlib_buffer_t *buffer)
Definition: device.c:69
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:602
struct vnet_sub_interface_t::@198::@199::@201 flags
struct rte_eth_stats stats
Definition: dpdk.h:259
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:110
#define static_always_inline
Definition: clib.h:99
dpdk_portid_t port_id
Definition: dpdk.h:205
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
Definition: node_funcs.h:516
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:519
u32 sw_if_index
Definition: vxlan_gbp.api:37
u32 buffer_index
Definition: dpdk.h:460
static void dpdk_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: device.c:477
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
Definition: error.h:99
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:168
#define VNET_DEVICE_CLASS_TX_FN(devclass)
Definition: interface.h:287
unsigned int u32
Definition: types.h:88
vlib_node_registration_t admin_up_down_process_node
(constructor) VLIB_REGISTER_NODE (admin_up_down_process_node)
Definition: device.c:626
A collection of simple counters.
Definition: counter.h:57
#define VLIB_FRAME_SIZE
Definition: node.h:401
dpdk_device_hqos_per_worker_thread_t * hqos_wt
Definition: dpdk.h:245
#define clib_atomic_test_and_set(a)
Definition: atomics.h:40
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:158
vnet_hw_interface_t * hw_interfaces
Definition: interface.h:816
#define rte_mbuf_from_vlib_buffer(x)
Definition: dpdk_priv.h:16
void dpdk_device_start(dpdk_device_t *xd)
Definition: common.c:163
vnet_sub_interface_t sub
Definition: interface.h:726
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:114
u32 pcap_sw_if_index
Definition: dpdk.h:403
#define clib_atomic_release(a)
Definition: atomics.h:41
dpdk_per_thread_data_t * per_thread_data
Definition: dpdk.h:413
unsigned short u16
Definition: types.h:57
u8 data[256]
Definition: dpdk.h:466
void dpdk_hqos_metadata_set(dpdk_device_hqos_per_worker_thread_t *hqos, struct rte_mbuf **pkts, u32 n_pkts)
Definition: hqos.c:640
#define PREDICT_FALSE(x)
Definition: clib.h:111
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:838
u16 tx_q_used
Definition: dpdk.h:228
u32 hw_if_index
Definition: dpdk.h:207
dpdk_tx_func_error_t
Definition: device.c:31
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:79
dpdk_device_t * devices
Definition: dpdk.h:411
vlib_main_t * vm
Definition: buffer.c:301
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:88
volatile u32 ** lockp
Definition: dpdk.h:199
struct vnet_sub_interface_t::@198 eth
#define clib_warning(format, args...)
Definition: error.h:59
dpdk_pmd_t pmd
Definition: dpdk.h:213
static_always_inline void dpdk_prefetch_buffer(vlib_main_t *vm, struct rte_mbuf *mb)
Definition: device.c:221
format_function_t format_dpdk_device
Definition: dpdk.h:516
static_always_inline void dpdk_validate_rte_mbuf(vlib_main_t *vm, vlib_buffer_t *b, int maybe_multiseg)
Definition: device.c:93
void dpdk_device_stop(dpdk_device_t *xd)
Definition: common.c:210
static_always_inline u32 tx_burst_vector_internal(vlib_main_t *vm, dpdk_device_t *xd, struct rte_mbuf **mb, u32 n_left)
Definition: device.c:145
struct rte_eth_xstat * xstats
Definition: dpdk.h:262
struct rte_mbuf mb
Definition: dpdk.h:463
signed int i32
Definition: types.h:77
#define ASSERT(truth)
format_function_t format_dpdk_device_name
Definition: dpdk.h:515
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:130
#define clib_error_report(e)
Definition: error.h:113
VNET_DEVICE_CLASS(bond_dev_class)
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1494
dpdk_portid_t device_index
Definition: dpdk.h:202
u8 n_add_refs
Number of additional references to this buffer.
Definition: buffer.h:142
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
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:57
vlib_buffer_t buffer
Definition: dpdk.h:465
static void dpdk_clear_hw_interface_counters(u32 instance)
Definition: device.c:423
struct rte_mbuf * mbufs[DPDK_RX_BURST_SZ]
Definition: dpdk.h:392
static uword admin_up_down_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: device.c:583
pcap_main_t pcap_main
Definition: dpdk.h:404
Definition: defs.h:47
VNET_DEVICE_CLASS_TX_FN() dpdk_device_class(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Definition: device.c:264
#define foreach_dpdk_tx_func_error
Definition: device.c:27
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 admin_up_down_in_progress
Definition: dpdk.h:431
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:504
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:495
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:244
dpdk_pcap_t pcap[VLIB_N_RX_TX]
Definition: dpdk.h:419
#define UP_DOWN_FLAG_EVENT
Definition: device.c:580
u16 device_index
Definition: dpdk.h:461
static clib_error_t * dpdk_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: device.c:442
#define vnet_buffer(b)
Definition: buffer.h:368
vnet_flow_dev_ops_function_t dpdk_flow_ops_fn
Definition: dpdk.h:527
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:513
u8 data[0]
Packet data.
Definition: buffer.h:176
struct rte_eth_stats last_cleared_stats
Definition: dpdk.h:261
static clib_error_t * dpdk_subif_add_del_function(vnet_main_t *vnm, u32 hw_if_index, struct vnet_sw_interface_t *st, int is_add)
Definition: device.c:497
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:326
static_always_inline void dpdk_buffer_tx_offload(dpdk_device_t *xd, vlib_buffer_t *b, struct rte_mbuf *mb)
Definition: device.c:229
#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:117
u8 queue_index
Definition: dpdk.h:462
vnet_main_t * vnet_main
Definition: dpdk.h:443
static void pcap_add_buffer(pcap_main_t *pm, struct vlib_main_t *vm, u32 buffer_index, u32 n_bytes_in_trace)
Add buffer (vlib_buffer_t) to the trace.
Definition: pcap_funcs.h:63
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:62
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
int pcap_enable
Definition: dpdk.h:402
vlib_main_t * vlib_main
Definition: dpdk.h:442