FD.io VPP  v19.04.4-rc0-5-ge88582fac
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/buffer.h>
23 #include <dpdk/device/dpdk.h>
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->ref_count > 1))
131  mb->pool =
133  }
134 }
135 
136 /*
137  * This function calls the dpdk's tx_burst function to transmit the packets.
138  * It manages a lock per-device if the device does not
139  * support multiple queues. It returns the number of packets untransmitted
140  * If all packets are transmitted (the normal case), the function returns 0.
141  */
144  dpdk_device_t * xd,
145  struct rte_mbuf **mb, u32 n_left)
146 {
147  dpdk_main_t *dm = &dpdk_main;
148  u32 n_retry;
149  int n_sent = 0;
150  int queue_id;
151 
152  n_retry = 16;
153  queue_id = vm->thread_index;
154 
155  do
156  {
157  /*
158  * This device only supports one TX queue,
159  * and we're running multi-threaded...
160  */
161  if (PREDICT_FALSE (xd->lockp != 0))
162  {
163  queue_id = queue_id % xd->tx_q_used;
164  while (clib_atomic_test_and_set (xd->lockp[queue_id]))
165  /* zzzz */
166  queue_id = (queue_id + 1) % xd->tx_q_used;
167  }
168 
169 #if 0
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
183 #endif
184  if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD))
185  {
186  /* no wrap, transmit in one burst */
187  n_sent = rte_eth_tx_burst (xd->port_id, queue_id, mb, n_left);
188  }
189  else
190  {
191  ASSERT (0);
192  n_sent = 0;
193  }
194 
195  if (PREDICT_FALSE (xd->lockp != 0))
196  clib_atomic_release (xd->lockp[queue_id]);
197 
198  if (PREDICT_FALSE (n_sent < 0))
199  {
200  // emit non-fatal message, bump counter
201  vnet_main_t *vnm = dm->vnet_main;
203  u32 node_index;
204 
205  node_index = vec_elt_at_index (im->hw_interfaces,
206  xd->hw_if_index)->tx_node_index;
207 
208  vlib_error_count (vm, node_index, DPDK_TX_FUNC_ERROR_BAD_RETVAL, 1);
209  clib_warning ("rte_eth_tx_burst[%d]: error %d",
210  xd->port_id, n_sent);
211  return n_left; // untransmitted packets
212  }
213  n_left -= n_sent;
214  mb += n_sent;
215  }
216  while (n_sent && n_left && (n_retry > 0));
217 
218  return n_left;
219 }
220 
222 dpdk_prefetch_buffer (vlib_main_t * vm, struct rte_mbuf *mb)
223 {
225  CLIB_PREFETCH (mb, 2 * CLIB_CACHE_LINE_BYTES, STORE);
227 }
228 
231  struct rte_mbuf *mb)
232 {
233  u32 ip_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
234  u32 tcp_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
235  u32 udp_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
236  int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
237  u64 ol_flags;
238 
239  /* Is there any work for us? */
240  if (PREDICT_TRUE ((ip_cksum | tcp_cksum | udp_cksum) == 0))
241  return;
242 
243  mb->l2_len = vnet_buffer (b)->l3_hdr_offset - b->current_data;
244  mb->l3_len = vnet_buffer (b)->l4_hdr_offset -
245  vnet_buffer (b)->l3_hdr_offset;
246  mb->outer_l3_len = 0;
247  mb->outer_l2_len = 0;
248  ol_flags = is_ip4 ? PKT_TX_IPV4 : PKT_TX_IPV6;
249  ol_flags |= ip_cksum ? PKT_TX_IP_CKSUM : 0;
250  ol_flags |= tcp_cksum ? PKT_TX_TCP_CKSUM : 0;
251  ol_flags |= udp_cksum ? PKT_TX_UDP_CKSUM : 0;
252  mb->ol_flags |= ol_flags;
253 
254  /* we are trying to help compiler here by using local ol_flags with known
255  state of all flags */
256  if (xd->flags & DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM)
257  rte_net_intel_cksum_flags_prepare (mb, ol_flags);
258 }
259 
260 /*
261  * Transmits the packets on the frame to the interface associated with the
262  * node. It first copies packets on the frame to a per-thread arrays
263  * containing the rte_mbuf pointers.
264  */
266  vlib_node_runtime_t * node,
267  vlib_frame_t * f)
268 {
269  dpdk_main_t *dm = &dpdk_main;
270  vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
272  u32 n_packets = f->n_vectors;
273  u32 n_left;
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  ASSERT (n_packets <= VLIB_FRAME_SIZE);
283 
284  /* calculate rte_mbuf pointers out of buffer indices */
286  (void **) ptd->mbufs, n_packets,
287  -(i32) sizeof (struct rte_mbuf));
288 
289  n_left = n_packets;
290  mb = ptd->mbufs;
291 
292  while (n_left >= 8)
293  {
294  u32 or_flags;
295 
296  dpdk_prefetch_buffer (vm, mb[4]);
297  dpdk_prefetch_buffer (vm, mb[5]);
298  dpdk_prefetch_buffer (vm, mb[6]);
299  dpdk_prefetch_buffer (vm, mb[7]);
300 
301  b[0] = vlib_buffer_from_rte_mbuf (mb[0]);
302  b[1] = vlib_buffer_from_rte_mbuf (mb[1]);
303  b[2] = vlib_buffer_from_rte_mbuf (mb[2]);
304  b[3] = vlib_buffer_from_rte_mbuf (mb[3]);
305 
306  or_flags = b[0]->flags | b[1]->flags | b[2]->flags | b[3]->flags;
307  all_or_flags |= or_flags;
308 
313 
314  if (or_flags & VLIB_BUFFER_NEXT_PRESENT)
315  {
316  dpdk_validate_rte_mbuf (vm, b[0], 1);
317  dpdk_validate_rte_mbuf (vm, b[1], 1);
318  dpdk_validate_rte_mbuf (vm, b[2], 1);
319  dpdk_validate_rte_mbuf (vm, b[3], 1);
320  }
321  else
322  {
323  dpdk_validate_rte_mbuf (vm, b[0], 0);
324  dpdk_validate_rte_mbuf (vm, b[1], 0);
325  dpdk_validate_rte_mbuf (vm, b[2], 0);
326  dpdk_validate_rte_mbuf (vm, b[3], 0);
327  }
328 
329  if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD) &&
330  (or_flags &
331  (VNET_BUFFER_F_OFFLOAD_TCP_CKSUM
332  | VNET_BUFFER_F_OFFLOAD_IP_CKSUM
333  | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM))))
334  {
335  dpdk_buffer_tx_offload (xd, b[0], mb[0]);
336  dpdk_buffer_tx_offload (xd, b[1], mb[1]);
337  dpdk_buffer_tx_offload (xd, b[2], mb[2]);
338  dpdk_buffer_tx_offload (xd, b[3], mb[3]);
339  }
340 
341  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
342  {
343  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
344  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[0]);
345  if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
346  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[1]);
347  if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
348  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[2]);
349  if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
350  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[3]);
351  }
352 
353  mb += 4;
354  n_left -= 4;
355  }
356  while (n_left > 0)
357  {
358  b[0] = vlib_buffer_from_rte_mbuf (mb[0]);
359  all_or_flags |= b[0]->flags;
361 
362  dpdk_validate_rte_mbuf (vm, b[0], 1);
363  dpdk_buffer_tx_offload (xd, b[0], mb[0]);
364 
365  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
366  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
367  dpdk_tx_trace_buffer (dm, node, xd, queue_id, b[0]);
368 
369  mb++;
370  n_left--;
371  }
372 
373  /* transmit as many packets as possible */
374  tx_pkts = n_packets = mb - ptd->mbufs;
375  n_left = tx_burst_vector_internal (vm, xd, ptd->mbufs, n_packets);
376 
377  {
378  /* If there is no callback then drop any non-transmitted packets */
379  if (PREDICT_FALSE (n_left))
380  {
381  tx_pkts -= n_left;
383  vnet_main_t *vnm = vnet_get_main ();
384 
387 
388  vlib_increment_simple_counter (cm, thread_index, xd->sw_if_index,
389  n_left);
390 
391  vlib_error_count (vm, node->node_index, DPDK_TX_FUNC_ERROR_PKT_DROP,
392  n_left);
393 
394  while (n_left--)
395  rte_pktmbuf_free (ptd->mbufs[n_packets - n_left - 1]);
396  }
397  }
398 
399  return tx_pkts;
400 }
401 
402 static void
404 {
405  dpdk_main_t *dm = &dpdk_main;
406  dpdk_device_t *xd = vec_elt_at_index (dm->devices, instance);
407 
408  /*
409  * Set the "last_cleared_stats" to the current stats, so that
410  * things appear to clear from a display perspective.
411  */
413 
414  clib_memcpy_fast (&xd->last_cleared_stats, &xd->stats, sizeof (xd->stats));
417  sizeof (xd->last_cleared_xstats[0]));
418 
419 }
420 
421 static clib_error_t *
423 {
424  vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index);
425  uword is_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
426  dpdk_main_t *dm = &dpdk_main;
428 
429  if (xd->flags & DPDK_DEVICE_FLAG_PMD_INIT_FAIL)
430  return clib_error_return (0, "Interface not initialized");
431 
432  if (is_up)
433  {
434  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
435  dpdk_device_start (xd);
436  xd->flags |= DPDK_DEVICE_FLAG_ADMIN_UP;
437  f64 now = vlib_time_now (dm->vlib_main);
438  dpdk_update_counters (xd, now);
439  dpdk_update_link_state (xd, now);
440  }
441  else
442  {
444  if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0)
445  dpdk_device_stop (xd);
446  xd->flags &= ~DPDK_DEVICE_FLAG_ADMIN_UP;
447  }
448 
449  return /* no error */ 0;
450 }
451 
452 /*
453  * Dynamically redirect all pkts from a specific interface
454  * to the specified node
455  */
456 static void
458  u32 node_index)
459 {
460  dpdk_main_t *xm = &dpdk_main;
461  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
463 
464  /* Shut off redirection */
465  if (node_index == ~0)
466  {
467  xd->per_interface_next_index = node_index;
468  return;
469  }
470 
472  vlib_node_add_next (xm->vlib_main, dpdk_input_node.index, node_index);
473 }
474 
475 
476 static clib_error_t *
478  u32 hw_if_index,
479  struct vnet_sw_interface_t *st, int is_add)
480 {
481  dpdk_main_t *xm = &dpdk_main;
482  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
485  int r, vlan_offload;
486  u32 prev_subifs = xd->num_subifs;
487  clib_error_t *err = 0;
488 
489  if (is_add)
490  xd->num_subifs++;
491  else if (xd->num_subifs)
492  xd->num_subifs--;
493 
494  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
495  goto done;
496 
497  /* currently we program VLANS only for IXGBE VF and I40E VF */
498  if ((xd->pmd != VNET_DPDK_PMD_IXGBEVF) && (xd->pmd != VNET_DPDK_PMD_I40EVF))
499  goto done;
500 
501  if (t->sub.eth.flags.no_tags == 1)
502  goto done;
503 
504  if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1))
505  {
506  xd->num_subifs = prev_subifs;
507  err = clib_error_return (0, "unsupported VLAN setup");
508  goto done;
509  }
510 
511  vlan_offload = rte_eth_dev_get_vlan_offload (xd->port_id);
512  vlan_offload |= ETH_VLAN_FILTER_OFFLOAD;
513 
514  if ((r = rte_eth_dev_set_vlan_offload (xd->port_id, vlan_offload)))
515  {
516  xd->num_subifs = prev_subifs;
517  err = clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
518  xd->port_id, r);
519  goto done;
520  }
521 
522 
523  if ((r =
524  rte_eth_dev_vlan_filter (xd->port_id,
525  t->sub.eth.outer_vlan_id, is_add)))
526  {
527  xd->num_subifs = prev_subifs;
528  err = clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
529  xd->port_id, r);
530  goto done;
531  }
532 
533 done:
534  if (xd->num_subifs)
535  xd->flags |= DPDK_DEVICE_FLAG_HAVE_SUBIF;
536  else
537  xd->flags &= ~DPDK_DEVICE_FLAG_HAVE_SUBIF;
538 
539  return err;
540 }
541 
542 /* *INDENT-OFF* */
544  .name = "dpdk",
545  .tx_function_n_errors = DPDK_TX_FUNC_N_ERROR,
546  .tx_function_error_strings = dpdk_tx_func_error_strings,
547  .format_device_name = format_dpdk_device_name,
548  .format_device = format_dpdk_device,
549  .format_tx_trace = format_dpdk_tx_trace,
550  .clear_counters = dpdk_clear_hw_interface_counters,
551  .admin_up_down_function = dpdk_interface_admin_up_down,
552  .subif_add_del_function = dpdk_subif_add_del_function,
553  .rx_redirect_to_node = dpdk_set_interface_next_node,
554  .mac_addr_change_function = dpdk_set_mac_address,
555  .format_flow = format_dpdk_flow,
556  .flow_ops_function = dpdk_flow_ops_fn,
557 };
558 /* *INDENT-ON* */
559 
560 #define UP_DOWN_FLAG_EVENT 1
561 
562 static uword
565 {
566  clib_error_t *error = 0;
567  uword event_type;
568  uword *event_data = 0;
570  u32 flags;
571 
572  while (1)
573  {
575 
576  event_type = vlib_process_get_events (vm, &event_data);
577 
579 
580  switch (event_type)
581  {
582  case UP_DOWN_FLAG_EVENT:
583  {
584  if (vec_len (event_data) == 2)
585  {
586  sw_if_index = event_data[0];
587  flags = event_data[1];
588  error =
590  flags);
591  clib_error_report (error);
592  }
593  }
594  break;
595  }
596 
597  vec_reset_length (event_data);
598 
600 
601  }
602  return 0; /* or not */
603 }
604 
605 /* *INDENT-OFF* */
607  .function = admin_up_down_process,
608  .type = VLIB_NODE_TYPE_PROCESS,
609  .name = "admin-up-down-process",
610  .process_log2_n_stack_bytes = 17, // 256KB
611 };
612 /* *INDENT-ON* */
613 
614 /*
615  * fd.io coding-style-patch-verification: ON
616  *
617  * Local Variables:
618  * eval: (c-set-style "gnu")
619  * End:
620  */
u32 sw_if_index
Definition: ipsec_gre.api:37
u8 * default_mac_address
Definition: dpdk.h:266
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:124
format_function_t format_dpdk_tx_trace
Definition: dpdk.h:499
vmrglw vmrglh hi
format_function_t format_dpdk_flow
Definition: dpdk.h:503
typedef address
Definition: ip_types.api:30
#define vlib_buffer_from_rte_mbuf(x)
Definition: buffer.h:20
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:44
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
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:110
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:255
static char * dpdk_tx_func_error_strings[]
Definition: device.c:39
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
u16 flags
Definition: dpdk.h:214
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 thread_index
Definition: main.h:197
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
u8 data[0]
Packet data.
Definition: buffer.h:181
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:209
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:178
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:261
u16 num_subifs
Definition: dpdk.h:223
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:366
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
u8 buffer_pool_index
index of buffer pool this buffer belongs.
Definition: buffer.h:133
#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:598
struct rte_eth_stats stats
Definition: dpdk.h:257
#define static_always_inline
Definition: clib.h:99
dpdk_portid_t port_id
Definition: dpdk.h:203
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:478
u32 buffer_index
Definition: dpdk.h:441
static void dpdk_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: device.c:457
#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
#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:606
A collection of simple counters.
Definition: counter.h:57
#define VLIB_FRAME_SIZE
Definition: node.h:376
dpdk_device_hqos_per_worker_thread_t * hqos_wt
Definition: dpdk.h:243
#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:257
struct vnet_sub_interface_t::@208::@209::@211 flags
vnet_hw_interface_t * hw_interfaces
Definition: interface.h:801
void dpdk_device_start(dpdk_device_t *xd)
Definition: common.c:161
vnet_sub_interface_t sub
Definition: interface.h:704
#define clib_atomic_release(a)
Definition: atomics.h:41
dpdk_per_thread_data_t * per_thread_data
Definition: dpdk.h:406
unsigned short u16
Definition: types.h:57
#define rte_mbuf_from_vlib_buffer(x)
Definition: buffer.h:19
u8 data[256]
Definition: dpdk.h:447
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:823
u16 tx_q_used
Definition: dpdk.h:226
u32 hw_if_index
Definition: dpdk.h:205
dpdk_tx_func_error_t
Definition: device.c:31
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
struct vnet_sub_interface_t::@208 eth
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
dpdk_device_t * devices
Definition: dpdk.h:404
vlib_main_t * vm
Definition: buffer.c:312
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:77
volatile u32 ** lockp
Definition: dpdk.h:197
#define clib_warning(format, args...)
Definition: error.h:59
dpdk_pmd_t pmd
Definition: dpdk.h:211
static_always_inline void dpdk_prefetch_buffer(vlib_main_t *vm, struct rte_mbuf *mb)
Definition: device.c:222
format_function_t format_dpdk_device
Definition: dpdk.h:497
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:208
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:143
struct rte_eth_xstat * xstats
Definition: dpdk.h:260
struct rte_mbuf mb
Definition: dpdk.h:444
signed int i32
Definition: types.h:77
#define ASSERT(truth)
format_function_t format_dpdk_device_name
Definition: dpdk.h:496
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:178
u8 is_add
Definition: ipsec_gre.api:36
#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:1398
dpdk_portid_t device_index
Definition: dpdk.h:200
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:446
static void dpdk_clear_hw_interface_counters(u32 instance)
Definition: device.c:403
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:563
VNET_DEVICE_CLASS_TX_FN() dpdk_device_class(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
Definition: device.c:265
#define foreach_dpdk_tx_func_error
Definition: device.c:27
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:140
u8 admin_up_down_in_progress
Definition: dpdk.h:415
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:451
struct rte_mempool ** dpdk_no_cache_mempool_by_buffer_pool_index
Definition: buffer.c:33
VLIB buffer representation.
Definition: buffer.h:102
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
#define UP_DOWN_FLAG_EVENT
Definition: device.c:560
u16 device_index
Definition: dpdk.h:442
static clib_error_t * dpdk_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: device.c:422
#define vnet_buffer(b)
Definition: buffer.h:369
vnet_flow_dev_ops_function_t dpdk_flow_ops_fn
Definition: dpdk.h:507
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
struct rte_eth_stats last_cleared_stats
Definition: dpdk.h:259
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:477
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:301
static_always_inline void dpdk_buffer_tx_offload(dpdk_device_t *xd, vlib_buffer_t *b, struct rte_mbuf *mb)
Definition: device.c:230
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
u8 queue_index
Definition: dpdk.h:443
vnet_main_t * vnet_main
Definition: dpdk.h:427
volatile u8 ref_count
Reference count for this buffer.
Definition: buffer.h:130
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:85
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
vlib_main_t * vlib_main
Definition: dpdk.h:426