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