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