FD.io VPP  v16.09
Vector Packet Processing
init.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <vnet/vnet.h>
16 #include <vppinfra/vec.h>
17 #include <vppinfra/error.h>
18 #include <vppinfra/format.h>
19 #include <vppinfra/bitmap.h>
20 
21 #include <vnet/ethernet/ethernet.h>
22 #include <vnet/devices/dpdk/dpdk.h>
23 #include <vlib/unix/physmem.h>
24 #include <vlib/pci/pci.h>
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <sys/stat.h>
30 #include <sys/mount.h>
31 #include <string.h>
32 #include <fcntl.h>
33 
34 #include "dpdk_priv.h"
35 
37 
38 /* force linker to link functions used by vlib and declared weak */
40  &rte_pktmbuf_init,
41  &rte_pktmbuf_pool_init,
42 };
43 
44 #define LINK_STATE_ELOGS 0
45 
46 #define DEFAULT_HUGE_DIR "/run/vpp/hugepages"
47 #define VPP_RUN_DIR "/run/vpp"
48 
49 /* Port configuration, mildly modified Intel app values */
50 
51 static struct rte_eth_conf port_conf_template = {
52  .rxmode = {
53  .split_hdr_size = 0,
54  .header_split = 0, /**< Header Split disabled */
55  .hw_ip_checksum = 0, /**< IP checksum offload disabled */
56  .hw_vlan_filter = 0, /**< VLAN filtering disabled */
57  .hw_strip_crc = 0, /**< CRC stripped by hardware */
58  },
59  .txmode = {
60  .mq_mode = ETH_MQ_TX_NONE,
61  },
62 };
63 
66 {
67  vlib_main_t *vm = vlib_get_main ();
69  int rv;
70  int j;
71 
72  ASSERT (os_get_cpu_number () == 0);
73 
74  if (xd->admin_up)
75  {
77  rte_eth_dev_stop (xd->device_index);
78  }
79 
80  rv = rte_eth_dev_configure (xd->device_index, xd->rx_q_used,
81  xd->tx_q_used, &xd->port_conf);
82 
83  if (rv < 0)
84  return clib_error_return (0, "rte_eth_dev_configure[%d]: err %d",
85  xd->device_index, rv);
86 
87  /* Set up one TX-queue per worker thread */
88  for (j = 0; j < xd->tx_q_used; j++)
89  {
90  rv = rte_eth_tx_queue_setup (xd->device_index, j, xd->nb_tx_desc,
91  xd->cpu_socket, &xd->tx_conf);
92 
93  /* retry with any other CPU socket */
94  if (rv < 0)
95  rv = rte_eth_tx_queue_setup (xd->device_index, j, xd->nb_tx_desc,
96  SOCKET_ID_ANY, &xd->tx_conf);
97  if (rv < 0)
98  break;
99  }
100 
101  if (rv < 0)
102  return clib_error_return (0, "rte_eth_tx_queue_setup[%d]: err %d",
103  xd->device_index, rv);
104 
105  for (j = 0; j < xd->rx_q_used; j++)
106  {
107 
108  rv = rte_eth_rx_queue_setup (xd->device_index, j, xd->nb_rx_desc,
109  xd->cpu_socket, 0,
110  bm->
111  pktmbuf_pools[xd->cpu_socket_id_by_queue
112  [j]]);
113 
114  /* retry with any other CPU socket */
115  if (rv < 0)
116  rv = rte_eth_rx_queue_setup (xd->device_index, j, xd->nb_rx_desc,
117  SOCKET_ID_ANY, 0,
118  bm->
119  pktmbuf_pools[xd->cpu_socket_id_by_queue
120  [j]]);
121  if (rv < 0)
122  return clib_error_return (0, "rte_eth_rx_queue_setup[%d]: err %d",
123  xd->device_index, rv);
124  }
125 
126  if (xd->admin_up)
127  {
128  int rv;
129  rv = rte_eth_dev_start (xd->device_index);
130  if (rv < 0)
131  clib_warning ("rte_eth_dev_start %d returned %d",
132  xd->device_index, rv);
133  }
134  return 0;
135 }
136 
137 static u32
139 {
140  dpdk_main_t *dm = &dpdk_main;
142  u32 old = 0;
143 
145  {
146  old = xd->promisc;
148 
149  if (xd->admin_up)
150  {
151  if (xd->promisc)
152  rte_eth_promiscuous_enable (xd->device_index);
153  else
154  rte_eth_promiscuous_disable (xd->device_index);
155  }
156  }
157  else if (ETHERNET_INTERFACE_FLAG_CONFIG_MTU (flags))
158  {
159  /*
160  * DAW-FIXME: The Cisco VIC firmware does not provide an api for a
161  * driver to dynamically change the mtu. If/when the
162  * VIC firmware gets fixed, then this should be removed.
163  */
164  if (xd->pmd == VNET_DPDK_PMD_ENIC)
165  {
166  struct rte_eth_dev_info dev_info;
167 
168  /*
169  * Restore mtu to what has been set by CIMC in the firmware cfg.
170  */
171  rte_eth_dev_info_get (xd->device_index, &dev_info);
172  hi->max_packet_bytes = dev_info.max_rx_pktlen;
173 
175  "Cisco VIC mtu can only be changed "
176  "using CIMC then rebooting the server!");
177  }
178  else
179  {
180  int rv;
181 
182  xd->port_conf.rxmode.max_rx_pkt_len = hi->max_packet_bytes;
183 
184  if (xd->admin_up)
185  rte_eth_dev_stop (xd->device_index);
186 
187  rv = rte_eth_dev_configure
188  (xd->device_index, xd->rx_q_used, xd->tx_q_used, &xd->port_conf);
189 
190  if (rv < 0)
192  "rte_eth_dev_configure[%d]: err %d",
193  xd->device_index, rv);
194 
195  rte_eth_dev_set_mtu (xd->device_index, hi->max_packet_bytes);
196 
197  if (xd->admin_up)
198  {
199  int rv = rte_eth_dev_start (xd->device_index);
200  if (rv < 0)
201  clib_warning ("rte_eth_dev_start %d returned %d",
202  xd->device_index, rv);
203  }
204  }
205  }
206  return old;
207 }
208 
209 void
211 {
212  int q;
213  vec_validate (xd->lockp, xd->tx_q_used - 1);
214  for (q = 0; q < xd->tx_q_used; q++)
215  {
218  memset ((void *) xd->lockp[q], 0, CLIB_CACHE_LINE_BYTES);
219  }
220  xd->need_txlock = 1;
221 }
222 
223 void
225 {
226  int q;
227 
228  for (q = 0; q < vec_len (xd->lockp); q++)
229  clib_mem_free ((void *) xd->lockp[q]);
230  vec_free (xd->lockp);
231  xd->lockp = 0;
232  xd->need_txlock = 0;
233 }
234 
235 static clib_error_t *
237 {
238  u32 nports;
239  u32 nb_desc = 0;
240  int i;
241  clib_error_t *error;
242  vlib_main_t *vm = vlib_get_main ();
247  dpdk_device_t *xd;
248  vlib_pci_addr_t last_pci_addr;
249  u32 last_pci_addr_port = 0;
251  uword *p;
252 
253  u32 next_cpu = 0;
254  u8 af_packet_port_id = 0;
255  last_pci_addr.as_u32 = ~0;
256 
257  dm->input_cpu_first_index = 0;
258  dm->input_cpu_count = 1;
259 
260  rt = vlib_node_get_runtime (vm, dpdk_input_node.index);
262 
263  /* find out which cpus will be used for input */
264  p = hash_get_mem (tm->thread_registrations_by_name, "workers");
265  tr = p ? (vlib_thread_registration_t *) p[0] : 0;
266 
267  if (tr && tr->count > 0)
268  {
270  dm->input_cpu_count = tr->count;
271  }
272 
275 
278 
279  nports = rte_eth_dev_count ();
280  if (nports < 1)
281  {
282  clib_warning ("DPDK drivers found no ports...");
283  }
284 
285  if (CLIB_DEBUG > 0)
286  clib_warning ("DPDK drivers found %d ports...", nports);
287 
288  /*
289  * All buffers are all allocated from the same rte_mempool.
290  * Thus they all have the same number of data bytes.
291  */
295  "dpdk rx");
296 
297  if (dm->conf->enable_tcp_udp_checksum)
300 
301  for (i = 0; i < nports; i++)
302  {
303  u8 addr[6];
304  u8 vlan_strip = 0;
305  int j;
306  struct rte_eth_dev_info dev_info;
307  clib_error_t *rv;
308  struct rte_eth_link l;
309  dpdk_device_config_t *devconf = 0;
310  vlib_pci_addr_t pci_addr;
311  uword *p = 0;
312 
313  rte_eth_dev_info_get (i, &dev_info);
314  if (dev_info.pci_dev) /* bonded interface has no pci info */
315  {
316  pci_addr.domain = dev_info.pci_dev->addr.domain;
317  pci_addr.bus = dev_info.pci_dev->addr.bus;
318  pci_addr.slot = dev_info.pci_dev->addr.devid;
319  pci_addr.function = dev_info.pci_dev->addr.function;
320  p =
322  pci_addr.as_u32);
323  }
324 
325  if (p)
326  devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
327  else
328  devconf = &dm->conf->default_devconf;
329 
330  /* Create vnet interface */
334  xd->cpu_socket = (i8) rte_eth_dev_socket_id (i);
335 
336  /* Handle interface naming for devices with multiple ports sharing same PCI ID */
337  if (dev_info.pci_dev)
338  {
339  struct rte_eth_dev_info di = { 0 };
340  rte_eth_dev_info_get (i + 1, &di);
341  if (di.pci_dev && pci_addr.as_u32 != last_pci_addr.as_u32 &&
342  memcmp (&dev_info.pci_dev->addr, &di.pci_dev->addr,
343  sizeof (struct rte_pci_addr)) == 0)
344  {
345  xd->interface_name_suffix = format (0, "0");
346  last_pci_addr.as_u32 = pci_addr.as_u32;
347  last_pci_addr_port = i;
348  }
349  else if (pci_addr.as_u32 == last_pci_addr.as_u32)
350  {
352  format (0, "%u", i - last_pci_addr_port);
353  }
354  else
355  {
356  last_pci_addr.as_u32 = ~0;
357  }
358  }
359  else
360  last_pci_addr.as_u32 = ~0;
361 
362  clib_memcpy (&xd->tx_conf, &dev_info.default_txconf,
363  sizeof (struct rte_eth_txconf));
364  if (dm->conf->no_multi_seg)
365  {
366  xd->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
367  port_conf_template.rxmode.jumbo_frame = 0;
368  }
369  else
370  {
371  xd->tx_conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
372  port_conf_template.rxmode.jumbo_frame = 1;
373  }
374 
376  sizeof (struct rte_eth_conf));
377 
378  xd->tx_q_used = clib_min (dev_info.max_tx_queues, tm->n_vlib_mains);
379 
380  if (devconf->num_tx_queues > 0
381  && devconf->num_tx_queues < xd->tx_q_used)
382  xd->tx_q_used = clib_min (xd->tx_q_used, devconf->num_tx_queues);
383 
384  if (devconf->num_rx_queues > 1 && dm->use_rss == 0)
385  {
387  dm->use_rss = 1;
388  }
389 
390  if (devconf->num_rx_queues > 1
391  && dev_info.max_rx_queues >= devconf->num_rx_queues)
392  {
393  xd->rx_q_used = devconf->num_rx_queues;
394  xd->port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
395  if (devconf->rss_fn == 0)
396  xd->port_conf.rx_adv_conf.rss_conf.rss_hf =
397  ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
398  else
399  xd->port_conf.rx_adv_conf.rss_conf.rss_hf = devconf->rss_fn;
400  }
401  else
402  xd->rx_q_used = 1;
403 
405 
406  /* workaround for drivers not setting driver_name */
407  if ((!dev_info.driver_name) && (dev_info.pci_dev))
408  dev_info.driver_name = dev_info.pci_dev->driver->name;
409  ASSERT (dev_info.driver_name);
410 
411  if (!xd->pmd)
412  {
413 
414 
415 #define _(s,f) else if (dev_info.driver_name && \
416  !strcmp(dev_info.driver_name, s)) \
417  xd->pmd = VNET_DPDK_PMD_##f;
418  if (0)
419  ;
421 #undef _
422  else
424 
425 
426  switch (xd->pmd)
427  {
428  /* 1G adapters */
429  case VNET_DPDK_PMD_E1000EM:
430  case VNET_DPDK_PMD_IGB:
431  case VNET_DPDK_PMD_IGBVF:
433  break;
434 
435  /* 10G adapters */
436  case VNET_DPDK_PMD_IXGBE:
437  case VNET_DPDK_PMD_IXGBEVF:
438  case VNET_DPDK_PMD_THUNDERX:
442  break;
443  case VNET_DPDK_PMD_DPAA2:
445  break;
446 
447  /* Cisco VIC */
448  case VNET_DPDK_PMD_ENIC:
449  rte_eth_link_get_nowait (i, &l);
451  if (l.link_speed == 40000)
452  {
455  }
456  else
457  {
460  }
461  break;
462 
463  /* Intel Fortville */
464  case VNET_DPDK_PMD_I40E:
465  case VNET_DPDK_PMD_I40EVF:
469 
470  switch (dev_info.pci_dev->id.device_id)
471  {
475  break;
476  case I40E_DEV_ID_QSFP_A:
477  case I40E_DEV_ID_QSFP_B:
478  case I40E_DEV_ID_QSFP_C:
480  break;
481  case I40E_DEV_ID_VF:
482  rte_eth_link_get_nowait (i, &l);
483  xd->port_type = l.link_speed == 10000 ?
485  break;
486  default:
488  }
489  break;
490 
491  case VNET_DPDK_PMD_CXGBE:
492  switch (dev_info.pci_dev->id.device_id)
493  {
494  case 0x540d: /* T580-CR */
495  case 0x5410: /* T580-LP-cr */
499  break;
500  case 0x5403: /* T540-CR */
504  break;
505  default:
509  }
510  break;
511 
512  /* Intel Red Rock Canyon */
513  case VNET_DPDK_PMD_FM10K:
517  break;
518 
519  /* virtio */
520  case VNET_DPDK_PMD_VIRTIO:
524  break;
525 
526  /* vmxnet3 */
527  case VNET_DPDK_PMD_VMXNET3:
529  xd->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
530  break;
531 
532  case VNET_DPDK_PMD_AF_PACKET:
534  xd->af_packet_port_id = af_packet_port_id++;
535  break;
536 
537  case VNET_DPDK_PMD_BOND:
539  break;
540 
541  default:
543  }
544 
545  if (devconf->num_rx_desc)
546  xd->nb_rx_desc = devconf->num_rx_desc;
547 
548  if (devconf->num_tx_desc)
549  xd->nb_tx_desc = devconf->num_tx_desc;
550  }
551 
552  /*
553  * Ensure default mtu is not > the mtu read from the hardware.
554  * Otherwise rte_eth_dev_configure() will fail and the port will
555  * not be available.
556  */
557  if (ETHERNET_MAX_PACKET_BYTES > dev_info.max_rx_pktlen)
558  {
559  /*
560  * This device does not support the platforms's max frame
561  * size. Use it's advertised mru instead.
562  */
563  xd->port_conf.rxmode.max_rx_pkt_len = dev_info.max_rx_pktlen;
564  }
565  else
566  {
567  xd->port_conf.rxmode.max_rx_pkt_len = ETHERNET_MAX_PACKET_BYTES;
568 
569  /*
570  * Some platforms do not account for Ethernet FCS (4 bytes) in
571  * MTU calculations. To interop with them increase mru but only
572  * if the device's settings can support it.
573  */
574  if ((dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES + 4)) &&
575  xd->port_conf.rxmode.hw_strip_crc)
576  {
577  /*
578  * Allow additional 4 bytes (for Ethernet FCS). These bytes are
579  * stripped by h/w and so will not consume any buffer memory.
580  */
581  xd->port_conf.rxmode.max_rx_pkt_len += 4;
582  }
583  }
584 
585 #if RTE_VERSION < RTE_VERSION_NUM(16, 4, 0, 0)
586  /*
587  * Older VMXNET3 driver doesn't support jumbo / multi-buffer pkts
588  */
589  if (xd->pmd == VNET_DPDK_PMD_VMXNET3)
590  {
591  xd->port_conf.rxmode.max_rx_pkt_len = 1518;
592  xd->port_conf.rxmode.jumbo_frame = 0;
593  }
594 #endif
595 
596  if (xd->pmd == VNET_DPDK_PMD_AF_PACKET)
597  {
598  f64 now = vlib_time_now (vm);
599  u32 rnd;
600  rnd = (u32) (now * 1e6);
601  rnd = random_u32 (&rnd);
602  clib_memcpy (addr + 2, &rnd, sizeof (rnd));
603  addr[0] = 2;
604  addr[1] = 0xfe;
605  }
606  else
607  rte_eth_macaddr_get (i, (struct ether_addr *) addr);
608 
609  if (xd->tx_q_used < tm->n_vlib_mains)
611 
612  xd->device_index = xd - dm->devices;
613  ASSERT (i == xd->device_index);
614  xd->per_interface_next_index = ~0;
615 
616  /* assign interface to input thread */
618  int q;
619 
620  if (devconf->workers)
621  {
622  int i;
623  q = 0;
624  /* *INDENT-OFF* */
625  clib_bitmap_foreach (i, devconf->workers, ({
626  int cpu = dm->input_cpu_first_index + i;
627  unsigned lcore = vlib_worker_threads[cpu].dpdk_lcore_id;
628  vec_validate(xd->cpu_socket_id_by_queue, q);
629  xd->cpu_socket_id_by_queue[q] = rte_lcore_to_socket_id(lcore);
630  vec_add2(dm->devices_by_cpu[cpu], dq, 1);
631  dq->device = xd->device_index;
632  dq->queue_id = q++;
633  }));
634  /* *INDENT-ON* */
635  }
636  else
637  for (q = 0; q < xd->rx_q_used; q++)
638  {
639  int cpu = dm->input_cpu_first_index + next_cpu;
640  unsigned lcore = vlib_worker_threads[cpu].dpdk_lcore_id;
641 
642  /*
643  * numa node for worker thread handling this queue
644  * needed for taking buffers from the right mempool
645  */
647  xd->cpu_socket_id_by_queue[q] = rte_lcore_to_socket_id (lcore);
648 
649  /*
650  * construct vector of (device,queue) pairs for each worker thread
651  */
652  vec_add2 (dm->devices_by_cpu[cpu], dq, 1);
653  dq->device = xd->device_index;
654  dq->queue_id = q;
655 
656  next_cpu++;
657  if (next_cpu == dm->input_cpu_count)
658  next_cpu = 0;
659  }
660 
663  for (j = 0; j < tm->n_vlib_mains; j++)
664  {
667  vec_reset_length (xd->tx_vectors[j]);
668  }
669 
672  for (j = 0; j < xd->rx_q_used; j++)
673  {
676  vec_reset_length (xd->rx_vectors[j]);
677  }
678 
679  rv = dpdk_port_setup (dm, xd);
680 
681  if (rv)
682  return rv;
683 
684  /* count the number of descriptors used for this device */
685  nb_desc += xd->nb_rx_desc + xd->nb_tx_desc * xd->tx_q_used;
686 
688  (dm->vnet_main, dpdk_device_class.index, xd->device_index,
689  /* ethernet address */ addr,
691  if (error)
692  return error;
693 
695  xd->vlib_sw_if_index = sw->sw_if_index;
697 
698  /*
699  * DAW-FIXME: The Cisco VIC firmware does not provide an api for a
700  * driver to dynamically change the mtu. If/when the
701  * VIC firmware gets fixed, then this should be removed.
702  */
703  if (xd->pmd == VNET_DPDK_PMD_ENIC)
704  {
705  /*
706  * Initialize mtu to what has been set by CIMC in the firmware cfg.
707  */
708  hi->max_packet_bytes = dev_info.max_rx_pktlen;
709  if (devconf->vlan_strip_offload != DPDK_DEVICE_VLAN_STRIP_OFF)
710  vlan_strip = 1; /* remove vlan tag from VIC port by default */
711  else
712  clib_warning ("VLAN strip disabled for interface\n");
713  }
714  else if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON)
715  vlan_strip = 1;
716 
717  if (vlan_strip)
718  {
719  int vlan_off;
720  vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
721  vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
722  if (rte_eth_dev_set_vlan_offload (xd->device_index, vlan_off) == 0)
723  clib_warning ("VLAN strip enabled for interface\n");
724  else
725  clib_warning ("VLAN strip cannot be supported by interface\n");
726  }
727 
728 #if RTE_VERSION < RTE_VERSION_NUM(16, 4, 0, 0)
729  /*
730  * Older VMXNET3 driver doesn't support jumbo / multi-buffer pkts
731  */
732  else if (xd->pmd == VNET_DPDK_PMD_VMXNET3)
733  hi->max_packet_bytes = 1518;
734 #endif
735 
737  xd->port_conf.rxmode.max_rx_pkt_len - sizeof (ethernet_header_t);
738 
739  rte_eth_dev_set_mtu (xd->device_index, hi->max_packet_bytes);
740  }
741 
742 #ifdef RTE_LIBRTE_KNI
743  if (dm->conf->num_kni)
744  {
745  clib_warning ("Initializing KNI interfaces...");
746  rte_kni_init (dm->conf->num_kni);
747  for (i = 0; i < dm->conf->num_kni; i++)
748  {
749  u8 addr[6];
750  int j;
751 
752  /* Create vnet interface */
755 
756  xd->device_index = xd - dm->devices;
757  ASSERT (nports + i == xd->device_index);
758  xd->per_interface_next_index = ~0;
759  xd->kni_port_id = i;
760  xd->cpu_socket = -1;
761  hash_set (dm->dpdk_device_by_kni_port_id, i, xd - dm->devices);
762  xd->rx_q_used = 1;
763 
764  /* assign interface to input thread */
767  dq->device = xd->device_index;
768  dq->queue_id = 0;
769 
772  for (j = 0; j < tm->n_vlib_mains; j++)
773  {
776  vec_reset_length (xd->tx_vectors[j]);
777  }
778 
781  for (j = 0; j < xd->rx_q_used; j++)
782  {
785  vec_reset_length (xd->rx_vectors[j]);
786  }
787 
788  /* FIXME Set up one TX-queue per worker thread */
789 
790  {
791  f64 now = vlib_time_now (vm);
792  u32 rnd;
793  rnd = (u32) (now * 1e6);
794  rnd = random_u32 (&rnd);
795 
796  clib_memcpy (addr + 2, &rnd, sizeof (rnd));
797  addr[0] = 2;
798  addr[1] = 0xfe;
799  }
800 
802  (dm->vnet_main, dpdk_device_class.index, xd->device_index,
803  /* ethernet address */ addr,
805 
806  if (error)
807  return error;
808 
810  xd->vlib_sw_if_index = sw->sw_if_index;
812  }
813  }
814 #endif
815 
816  if (nb_desc > dm->conf->num_mbufs)
817  clib_warning ("%d mbufs allocated but total rx/tx ring size is %d\n",
818  dm->conf->num_mbufs, nb_desc);
819 
820  /* init next vhost-user if index */
821  dm->next_vu_if_id = 0;
822 
823  return 0;
824 }
825 
826 static void
828 {
829  vlib_pci_main_t *pm = &pci_main;
830  clib_error_t *error;
833  u8 *pci_addr = 0;
834  int num_whitelisted = vec_len (conf->dev_confs);
835 
836  /* *INDENT-OFF* */
837  pool_foreach (d, pm->pci_devs, ({
838  dpdk_device_config_t * devconf = 0;
839  c = &d->config0.header;
840  vec_reset_length (pci_addr);
841  pci_addr = format (pci_addr, "%U%c", format_vlib_pci_addr, &d->bus_address, 0);
842 
843  if (c->device_class != PCI_CLASS_NETWORK_ETHERNET)
844  continue;
845 
846  if (num_whitelisted)
847  {
848  uword * p = hash_get (conf->device_config_index_by_pci_addr, d->bus_address.as_u32);
849 
850  if (!p)
851  continue;
852 
853  devconf = pool_elt_at_index (conf->dev_confs, p[0]);
854  }
855 
856  /* virtio */
857  if (c->vendor_id == 0x1af4 && c->device_id == 0x1000)
858  ;
859  /* vmxnet3 */
860  else if (c->vendor_id == 0x15ad && c->device_id == 0x07b0)
861  ;
862  /* all Intel devices */
863  else if (c->vendor_id == 0x8086)
864  ;
865  /* Cisco VIC */
866  else if (c->vendor_id == 0x1137 && c->device_id == 0x0043)
867  ;
868  /* Chelsio T4/T5 */
869  else if (c->vendor_id == 0x1425 && (c->device_id & 0xe000) == 0x4000)
870  ;
871  else
872  {
873  clib_warning ("Unsupported Ethernet PCI device 0x%04x:0x%04x found "
874  "at PCI address %s\n", (u16) c->vendor_id, (u16) c->device_id,
875  pci_addr);
876  continue;
877  }
878 
879  error = vlib_pci_bind_to_uio (d, (char *) conf->uio_driver_name);
880 
881  if (error)
882  {
883  if (devconf == 0)
884  {
885  pool_get (conf->dev_confs, devconf);
887  devconf - conf->dev_confs);
888  devconf->pci_addr.as_u32 = d->bus_address.as_u32;
889  }
890  devconf->is_blacklisted = 1;
891  clib_error_report (error);
892  }
893  }));
894  /* *INDENT-ON* */
895  vec_free (pci_addr);
896 }
897 
898 static clib_error_t *
899 dpdk_device_config (dpdk_config_main_t * conf, vlib_pci_addr_t pci_addr,
900  unformat_input_t * input, u8 is_default)
901 {
902  clib_error_t *error = 0;
903  uword *p;
904  dpdk_device_config_t *devconf;
905  unformat_input_t sub_input;
906 
907  if (is_default)
908  {
909  devconf = &conf->default_devconf;
910  }
911  else
912  {
913  p = hash_get (conf->device_config_index_by_pci_addr, pci_addr.as_u32);
914 
915  if (!p)
916  {
917  pool_get (conf->dev_confs, devconf);
918  hash_set (conf->device_config_index_by_pci_addr, pci_addr.as_u32,
919  devconf - conf->dev_confs);
920  }
921  else
922  return clib_error_return (0,
923  "duplicate configuration for PCI address %U",
924  format_vlib_pci_addr, &pci_addr);
925  }
926 
927  devconf->pci_addr.as_u32 = pci_addr.as_u32;
928 
929  if (!input)
930  return 0;
931 
933  {
934  if (unformat (input, "num-rx-queues %u", &devconf->num_rx_queues))
935  ;
936  else if (unformat (input, "num-tx-queues %u", &devconf->num_tx_queues))
937  ;
938  else if (unformat (input, "num-rx-desc %u", &devconf->num_rx_desc))
939  ;
940  else if (unformat (input, "num-tx-desc %u", &devconf->num_tx_desc))
941  ;
942  else if (unformat (input, "workers %U", unformat_bitmap_list,
943  &devconf->workers))
944  ;
945  else
946  if (unformat
947  (input, "rss %U", unformat_vlib_cli_sub_input, &sub_input))
948  {
949  error = unformat_rss_fn (&sub_input, &devconf->rss_fn);
950  if (error)
951  break;
952  }
953  else if (unformat (input, "vlan-strip-offload off"))
955  else if (unformat (input, "vlan-strip-offload on"))
957  else
958  {
959  error = clib_error_return (0, "unknown input `%U'",
960  format_unformat_error, input);
961  break;
962  }
963  }
964 
965  if (error)
966  return error;
967 
968  if (devconf->workers && devconf->num_rx_queues == 0)
969  devconf->num_rx_queues = clib_bitmap_count_set_bits (devconf->workers);
970  else if (devconf->workers &&
971  clib_bitmap_count_set_bits (devconf->workers) !=
972  devconf->num_rx_queues)
973  error =
975  "%U: number of worker threadds must be "
976  "equal to number of rx queues", format_vlib_pci_addr,
977  &pci_addr);
978 
979  return error;
980 }
981 
982 static clib_error_t *
984 {
985  clib_error_t *error = 0;
986  dpdk_main_t *dm = &dpdk_main;
989  dpdk_device_config_t *devconf;
990  vlib_pci_addr_t pci_addr;
991  unformat_input_t sub_input;
992  u8 *s, *tmp = 0;
993  u8 *rte_cmd = 0, *ethname = 0;
994  u32 log_level;
995  int ret, i;
996  int num_whitelisted = 0;
997  u8 no_pci = 0;
998  u8 no_huge = 0;
999  u8 huge_dir = 0;
1000  u8 file_prefix = 0;
1001  u8 *socket_mem = 0;
1002 
1003  conf->device_config_index_by_pci_addr = hash_create (0, sizeof (uword));
1004 
1005  // MATT-FIXME: inverted virtio-vhost logic to use virtio by default
1006  conf->use_virtio_vhost = 1;
1007 
1008  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1009  {
1010  /* Prime the pump */
1011  if (unformat (input, "no-hugetlb"))
1012  {
1013  vec_add1 (conf->eal_init_args, (u8 *) "no-huge");
1014  no_huge = 1;
1015  }
1016 
1017  else if (unformat (input, "enable-tcp-udp-checksum"))
1018  conf->enable_tcp_udp_checksum = 1;
1019 
1020  else if (unformat (input, "decimal-interface-names"))
1022 
1023  else if (unformat (input, "no-multi-seg"))
1024  conf->no_multi_seg = 1;
1025 
1026  else if (unformat (input, "dev default %U", unformat_vlib_cli_sub_input,
1027  &sub_input))
1028  {
1029  error =
1030  dpdk_device_config (conf, (vlib_pci_addr_t) (u32) ~ 1, &sub_input,
1031  1);
1032 
1033  if (error)
1034  return error;
1035  }
1036  else
1037  if (unformat
1038  (input, "dev %U %U", unformat_vlib_pci_addr, &pci_addr,
1039  unformat_vlib_cli_sub_input, &sub_input))
1040  {
1041  error = dpdk_device_config (conf, pci_addr, &sub_input, 0);
1042 
1043  if (error)
1044  return error;
1045 
1046  num_whitelisted++;
1047  }
1048  else if (unformat (input, "dev %U", unformat_vlib_pci_addr, &pci_addr))
1049  {
1050  error = dpdk_device_config (conf, pci_addr, 0, 0);
1051 
1052  if (error)
1053  return error;
1054 
1055  num_whitelisted++;
1056  }
1057  else if (unformat (input, "num-mbufs %d", &conf->num_mbufs))
1058  ;
1059  else if (unformat (input, "kni %d", &conf->num_kni))
1060  ;
1061  else if (unformat (input, "uio-driver %s", &conf->uio_driver_name))
1062  ;
1063  else if (unformat (input, "socket-mem %s", &socket_mem))
1064  ;
1065  else
1066  if (unformat
1067  (input, "vhost-user-coalesce-frames %d",
1068  &conf->vhost_coalesce_frames))
1069  ;
1070  else
1071  if (unformat
1072  (input, "vhost-user-coalesce-time %f",
1073  &conf->vhost_coalesce_time))
1074  ;
1075  else if (unformat (input, "enable-vhost-user"))
1076  conf->use_virtio_vhost = 0;
1077  else if (unformat (input, "no-pci"))
1078  {
1079  no_pci = 1;
1080  tmp = format (0, "--no-pci%c", 0);
1081  vec_add1 (conf->eal_init_args, tmp);
1082  }
1083  else if (unformat (input, "poll-sleep %d", &dm->poll_sleep))
1084  ;
1085 
1086 #define _(a) \
1087  else if (unformat(input, #a)) \
1088  { \
1089  tmp = format (0, "--%s%c", #a, 0); \
1090  vec_add1 (conf->eal_init_args, tmp); \
1091  }
1093 #undef _
1094 #define _(a) \
1095  else if (unformat(input, #a " %s", &s)) \
1096  { \
1097  if (!strncmp(#a, "huge-dir", 8)) \
1098  huge_dir = 1; \
1099  else if (!strncmp(#a, "file-prefix", 11)) \
1100  file_prefix = 1; \
1101  tmp = format (0, "--%s%c", #a, 0); \
1102  vec_add1 (conf->eal_init_args, tmp); \
1103  vec_add1 (s, 0); \
1104  vec_add1 (conf->eal_init_args, s); \
1105  }
1107 #undef _
1108 #define _(a,b) \
1109  else if (unformat(input, #a " %s", &s)) \
1110  { \
1111  tmp = format (0, "-%s%c", #b, 0); \
1112  vec_add1 (conf->eal_init_args, tmp); \
1113  vec_add1 (s, 0); \
1114  vec_add1 (conf->eal_init_args, s); \
1115  }
1117 #undef _
1118 #define _(a,b) \
1119  else if (unformat(input, #a " %s", &s)) \
1120  { \
1121  tmp = format (0, "-%s%c", #b, 0); \
1122  vec_add1 (conf->eal_init_args, tmp); \
1123  vec_add1 (s, 0); \
1124  vec_add1 (conf->eal_init_args, s); \
1125  conf->a##_set_manually = 1; \
1126  }
1128 #undef _
1129  else if (unformat (input, "default"))
1130  ;
1131 
1132  else
1133  {
1134  error = clib_error_return (0, "unknown input `%U'",
1135  format_unformat_error, input);
1136  goto done;
1137  }
1138  }
1139 
1140  if (!conf->uio_driver_name)
1141  conf->uio_driver_name = format (0, "igb_uio%c", 0);
1142 
1143  /*
1144  * Use 1G huge pages if available.
1145  */
1146  if (!no_huge && !huge_dir)
1147  {
1148  u32 x, *mem_by_socket = 0;
1149  uword c = 0;
1150  u8 use_1g = 1;
1151  u8 use_2m = 1;
1152  u8 less_than_1g = 1;
1153  int rv;
1154 
1155  umount (DEFAULT_HUGE_DIR);
1156 
1157  /* Process "socket-mem" parameter value */
1158  if (vec_len (socket_mem))
1159  {
1160  unformat_input_t in;
1161  unformat_init_vector (&in, socket_mem);
1163  {
1164  if (unformat (&in, "%u,", &x))
1165  ;
1166  else if (unformat (&in, "%u", &x))
1167  ;
1168  else if (unformat (&in, ","))
1169  x = 0;
1170  else
1171  break;
1172 
1173  vec_add1 (mem_by_socket, x);
1174 
1175  if (x > 1023)
1176  less_than_1g = 0;
1177  }
1178  /* Note: unformat_free vec_frees(in.buffer), aka socket_mem... */
1179  unformat_free (&in);
1180  socket_mem = 0;
1181  }
1182  else
1183  {
1184  /* *INDENT-OFF* */
1186  {
1187  vec_validate(mem_by_socket, c);
1188  mem_by_socket[c] = 256; /* default per-socket mem */
1189  }
1190  ));
1191  /* *INDENT-ON* */
1192  }
1193 
1194  /* check if available enough 1GB pages for each socket */
1195  /* *INDENT-OFF* */
1197  {
1198  u32 pages_avail, page_size, mem;
1199  u8 *s = 0;
1200  u8 *p = 0;
1201  char * numa_path = "/sys/devices/system/node/node%u/";
1202  char * nonnuma_path = "/sys/kernel/mm/";
1203  char * suffix = "hugepages/hugepages-%ukB/free_hugepages%c";
1204  char * path = NULL;
1205  struct stat sb_numa, sb_nonnuma;
1206 
1207  p = format(p, numa_path, c);
1208  if (stat(numa_path, &sb_numa) < 0)
1209  sb_numa.st_mode = 0;
1210 
1211  if (stat(nonnuma_path, &sb_nonnuma) < 0)
1212  sb_nonnuma.st_mode = 0;
1213 
1214  if (S_ISDIR(sb_numa.st_mode)) {
1215  path = (char*)format((u8*)path, "%s%s", p, suffix);
1216  } else if (S_ISDIR(sb_nonnuma.st_mode)) {
1217  path = (char*)format((u8*)path, "%s%s", nonnuma_path, suffix);
1218  } else {
1219  use_1g = 0;
1220  use_2m = 0;
1221  vec_free(p);
1222  break;
1223  }
1224 
1225  vec_validate(mem_by_socket, c);
1226  mem = mem_by_socket[c];
1227 
1228  page_size = 1024;
1229  pages_avail = 0;
1230  s = format (s, path, page_size * 1024, 0);
1231  vlib_sysfs_read ((char *) s, "%u", &pages_avail);
1232  vec_reset_length (s);
1233 
1234  if (page_size * pages_avail < mem)
1235  use_1g = 0;
1236 
1237  page_size = 2;
1238  pages_avail = 0;
1239  s = format (s, path, page_size * 1024, 0);
1240  vlib_sysfs_read ((char *) s, "%u", &pages_avail);
1241  vec_reset_length (s);
1242 
1243  if (page_size * pages_avail < mem)
1244  use_2m = 0;
1245 
1246  vec_free(s);
1247  vec_free(p);
1248  vec_free(path);
1249  }));
1250  /* *INDENT-ON* */
1251 
1252  if (mem_by_socket == 0)
1253  {
1254  error = clib_error_return (0, "mem_by_socket NULL");
1255  goto done;
1256  }
1257  _vec_len (mem_by_socket) = c + 1;
1258 
1259  /* regenerate socket_mem string */
1260  vec_foreach_index (x, mem_by_socket)
1261  socket_mem = format (socket_mem, "%s%u",
1262  socket_mem ? "," : "", mem_by_socket[x]);
1263  socket_mem = format (socket_mem, "%c", 0);
1264 
1265  vec_free (mem_by_socket);
1266 
1267  rv = mkdir (VPP_RUN_DIR, 0755);
1268  if (rv && errno != EEXIST)
1269  {
1270  error = clib_error_return (0, "mkdir '%s' failed errno %d",
1271  VPP_RUN_DIR, errno);
1272  goto done;
1273  }
1274 
1275  rv = mkdir (DEFAULT_HUGE_DIR, 0755);
1276  if (rv && errno != EEXIST)
1277  {
1278  error = clib_error_return (0, "mkdir '%s' failed errno %d",
1279  DEFAULT_HUGE_DIR, errno);
1280  goto done;
1281  }
1282 
1283  if (use_1g && !(less_than_1g && use_2m))
1284  {
1285  rv =
1286  mount ("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, "pagesize=1G");
1287  }
1288  else if (use_2m)
1289  {
1290  rv = mount ("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, NULL);
1291  }
1292  else
1293  {
1294  return clib_error_return (0, "not enough free huge pages");
1295  }
1296 
1297  if (rv)
1298  {
1299  error = clib_error_return (0, "mount failed %d", errno);
1300  goto done;
1301  }
1302 
1303  tmp = format (0, "--huge-dir%c", 0);
1304  vec_add1 (conf->eal_init_args, tmp);
1305  tmp = format (0, "%s%c", DEFAULT_HUGE_DIR, 0);
1306  vec_add1 (conf->eal_init_args, tmp);
1307  if (!file_prefix)
1308  {
1309  tmp = format (0, "--file-prefix%c", 0);
1310  vec_add1 (conf->eal_init_args, tmp);
1311  tmp = format (0, "vpp%c", 0);
1312  vec_add1 (conf->eal_init_args, tmp);
1313  }
1314  }
1315 
1316  vec_free (rte_cmd);
1317  vec_free (ethname);
1318 
1319  if (error)
1320  return error;
1321 
1322  /* I'll bet that -c and -n must be the first and second args... */
1323  if (!conf->coremask_set_manually)
1324  {
1326  uword *coremask = 0;
1327  int i;
1328 
1329  /* main thread core */
1330  coremask = clib_bitmap_set (coremask, tm->main_lcore, 1);
1331 
1332  for (i = 0; i < vec_len (tm->registrations); i++)
1333  {
1334  tr = tm->registrations[i];
1335  coremask = clib_bitmap_or (coremask, tr->coremask);
1336  }
1337 
1338  vec_insert (conf->eal_init_args, 2, 1);
1339  conf->eal_init_args[1] = (u8 *) "-c";
1340  tmp = format (0, "%U%c", format_bitmap_hex, coremask, 0);
1341  conf->eal_init_args[2] = tmp;
1342  clib_bitmap_free (coremask);
1343  }
1344 
1345  if (!conf->nchannels_set_manually)
1346  {
1347  vec_insert (conf->eal_init_args, 2, 3);
1348  conf->eal_init_args[3] = (u8 *) "-n";
1349  tmp = format (0, "%d", conf->nchannels);
1350  conf->eal_init_args[4] = tmp;
1351  }
1352 
1353  if (no_pci == 0 && geteuid () == 0)
1354  dpdk_bind_devices_to_uio (conf);
1355 
1356 #define _(x) \
1357  if (devconf->x == 0 && conf->default_devconf.x > 0) \
1358  devconf->x = conf->default_devconf.x ;
1359 
1360  /* *INDENT-OFF* */
1361  pool_foreach (devconf, conf->dev_confs, ({
1362 
1363  /* default per-device config items */
1364  foreach_dpdk_device_config_item
1365 
1366  /* add DPDK EAL whitelist/blacklist entry */
1367  if (num_whitelisted > 0 && devconf->is_blacklisted == 0)
1368  {
1369  tmp = format (0, "-w%c", 0);
1370  vec_add1 (conf->eal_init_args, tmp);
1371  tmp = format (0, "%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1372  vec_add1 (conf->eal_init_args, tmp);
1373  }
1374  else if (num_whitelisted == 0 && devconf->is_blacklisted != 0)
1375  {
1376  tmp = format (0, "-b%c", 0);
1377  vec_add1 (conf->eal_init_args, tmp);
1378  tmp = format (0, "%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1379  vec_add1 (conf->eal_init_args, tmp);
1380  }
1381  }));
1382  /* *INDENT-ON* */
1383 
1384 #undef _
1385 
1386  /* set master-lcore */
1387  tmp = format (0, "--master-lcore%c", 0);
1388  vec_add1 (conf->eal_init_args, tmp);
1389  tmp = format (0, "%u%c", tm->main_lcore, 0);
1390  vec_add1 (conf->eal_init_args, tmp);
1391 
1392  /* set socket-mem */
1393  tmp = format (0, "--socket-mem%c", 0);
1394  vec_add1 (conf->eal_init_args, tmp);
1395  tmp = format (0, "%s%c", socket_mem, 0);
1396  vec_add1 (conf->eal_init_args, tmp);
1397 
1398  /* NULL terminate the "argv" vector, in case of stupidity */
1399  vec_add1 (conf->eal_init_args, 0);
1400  _vec_len (conf->eal_init_args) -= 1;
1401 
1402  /* Set up DPDK eal and packet mbuf pool early. */
1403 
1404  log_level = (CLIB_DEBUG > 0) ? RTE_LOG_DEBUG : RTE_LOG_NOTICE;
1405 
1406  rte_set_log_level (log_level);
1407 
1408  vm = vlib_get_main ();
1409 
1410  /* make copy of args as rte_eal_init tends to mess up with arg array */
1411  for (i = 1; i < vec_len (conf->eal_init_args); i++)
1412  conf->eal_init_args_str = format (conf->eal_init_args_str, "%s ",
1413  conf->eal_init_args[i]);
1414 
1415  ret =
1416  rte_eal_init (vec_len (conf->eal_init_args),
1417  (char **) conf->eal_init_args);
1418 
1419  /* lazy umount hugepages */
1420  umount2 (DEFAULT_HUGE_DIR, MNT_DETACH);
1421 
1422  if (ret < 0)
1423  return clib_error_return (0, "rte_eal_init returned %d", ret);
1424 
1425  /* Dump the physical memory layout prior to creating the mbuf_pool */
1426  fprintf (stdout, "DPDK physical memory layout:\n");
1427  rte_dump_physmem_layout (stdout);
1428 
1429  /* main thread 1st */
1430  error = vlib_buffer_pool_create (vm, conf->num_mbufs, rte_socket_id ());
1431  if (error)
1432  return error;
1433 
1434  for (i = 0; i < RTE_MAX_LCORE; i++)
1435  {
1436  error = vlib_buffer_pool_create (vm, conf->num_mbufs,
1437  rte_lcore_to_socket_id (i));
1438  if (error)
1439  return error;
1440  }
1441 
1442 done:
1443  return error;
1444 }
1445 
1447 
1448 void
1450 {
1451  vnet_main_t *vnm = vnet_get_main ();
1452  struct rte_eth_link prev_link = xd->link;
1453  u32 hw_flags = 0;
1454  u8 hw_flags_chg = 0;
1455 
1456  /* only update link state for PMD interfaces */
1457  if (xd->dev_type != VNET_DPDK_DEV_ETH)
1458  return;
1459 
1460  xd->time_last_link_update = now ? now : xd->time_last_link_update;
1461  memset (&xd->link, 0, sizeof (xd->link));
1462  rte_eth_link_get_nowait (xd->device_index, &xd->link);
1463 
1464  if (LINK_STATE_ELOGS)
1465  {
1466  vlib_main_t *vm = vlib_get_main ();
1467  ELOG_TYPE_DECLARE (e) =
1468  {
1469  .format =
1470  "update-link-state: sw_if_index %d, admin_up %d,"
1471  "old link_state %d new link_state %d",.format_args = "i4i1i1i1",};
1472 
1473  struct
1474  {
1475  u32 sw_if_index;
1476  u8 admin_up;
1477  u8 old_link_state;
1478  u8 new_link_state;
1479  } *ed;
1480  ed = ELOG_DATA (&vm->elog_main, e);
1481  ed->sw_if_index = xd->vlib_sw_if_index;
1482  ed->admin_up = xd->admin_up;
1483  ed->old_link_state = (u8)
1485  ed->new_link_state = (u8) xd->link.link_status;
1486  }
1487 
1488  if ((xd->admin_up == 1) &&
1489  ((xd->link.link_status != 0) ^
1491  {
1492  hw_flags_chg = 1;
1493  hw_flags |= (xd->link.link_status ? VNET_HW_INTERFACE_FLAG_LINK_UP : 0);
1494  }
1495 
1496  if (hw_flags_chg || (xd->link.link_duplex != prev_link.link_duplex))
1497  {
1498  hw_flags_chg = 1;
1499  switch (xd->link.link_duplex)
1500  {
1501  case ETH_LINK_HALF_DUPLEX:
1503  break;
1504  case ETH_LINK_FULL_DUPLEX:
1506  break;
1507  default:
1508  break;
1509  }
1510  }
1511 #if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
1512  if (hw_flags_chg || (xd->link.link_speed != prev_link.link_speed))
1513  {
1514  hw_flags_chg = 1;
1515  switch (xd->link.link_speed)
1516  {
1517  case ETH_SPEED_NUM_10M:
1519  break;
1520  case ETH_SPEED_NUM_100M:
1522  break;
1523  case ETH_SPEED_NUM_1G:
1524  hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_1G;
1525  break;
1526  case ETH_SPEED_NUM_10G:
1528  break;
1529  case ETH_SPEED_NUM_40G:
1531  break;
1532  case 0:
1533  break;
1534  default:
1535  clib_warning ("unknown link speed %d", xd->link.link_speed);
1536  break;
1537  }
1538  }
1539 #else
1540  if (hw_flags_chg || (xd->link.link_speed != prev_link.link_speed))
1541  {
1542  hw_flags_chg = 1;
1543  switch (xd->link.link_speed)
1544  {
1545  case ETH_LINK_SPEED_10:
1547  break;
1548  case ETH_LINK_SPEED_100:
1550  break;
1551  case ETH_LINK_SPEED_1000:
1552  hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_1G;
1553  break;
1554  case ETH_LINK_SPEED_10000:
1556  break;
1557  case ETH_LINK_SPEED_40G:
1559  break;
1560  case 0:
1561  break;
1562  default:
1563  clib_warning ("unknown link speed %d", xd->link.link_speed);
1564  break;
1565  }
1566  }
1567 #endif
1568  if (hw_flags_chg)
1569  {
1570  if (LINK_STATE_ELOGS)
1571  {
1572  vlib_main_t *vm = vlib_get_main ();
1573 
1574  ELOG_TYPE_DECLARE (e) =
1575  {
1576  .format =
1577  "update-link-state: sw_if_index %d, new flags %d",.format_args
1578  = "i4i4",};
1579 
1580  struct
1581  {
1582  u32 sw_if_index;
1583  u32 flags;
1584  } *ed;
1585  ed = ELOG_DATA (&vm->elog_main, e);
1586  ed->sw_if_index = xd->vlib_sw_if_index;
1587  ed->flags = hw_flags;
1588  }
1589  vnet_hw_interface_set_flags (vnm, xd->vlib_hw_if_index, hw_flags);
1590  }
1591 }
1592 
1593 static uword
1595 {
1596  clib_error_t *error;
1597  vnet_main_t *vnm = vnet_get_main ();
1598  dpdk_main_t *dm = &dpdk_main;
1600  dpdk_device_t *xd;
1602 #if DPDK_VHOST_USER
1603  void *vu_state;
1604 #endif
1605  int i;
1606 
1607  error = dpdk_lib_init (dm);
1608 
1609  /*
1610  * Turn on the input node if we found some devices to drive
1611  * and we're not running worker threads or i/o threads
1612  */
1613 
1614  if (error == 0 && vec_len (dm->devices) > 0)
1615  {
1616  if (tm->n_vlib_mains == 1)
1618  VLIB_NODE_STATE_POLLING);
1619  else
1620  for (i = 0; i < tm->n_vlib_mains; i++)
1621  if (vec_len (dm->devices_by_cpu[i]) > 0)
1623  VLIB_NODE_STATE_POLLING);
1624  }
1625 
1626  if (error)
1627  clib_error_report (error);
1628 
1629 #if DPDK_VHOST_USER
1630  dpdk_vhost_user_process_init (&vu_state);
1631 #endif
1632 
1633  tm->worker_thread_release = 1;
1634 
1635  f64 now = vlib_time_now (vm);
1636  vec_foreach (xd, dm->devices)
1637  {
1638  dpdk_update_link_state (xd, now);
1639  }
1640 
1641  {
1642  /*
1643  * Extra set up for bond interfaces:
1644  * 1. Setup MACs for bond interfaces and their slave links which was set
1645  * in dpdk_port_setup() but needs to be done again here to take effect.
1646  * 2. Set up info for bond interface related CLI support.
1647  */
1648  int nports = rte_eth_dev_count ();
1649  if (nports > 0)
1650  {
1651  for (i = 0; i < nports; i++)
1652  {
1653  struct rte_eth_dev_info dev_info;
1654  rte_eth_dev_info_get (i, &dev_info);
1655  if (!dev_info.driver_name)
1656  dev_info.driver_name = dev_info.pci_dev->driver->name;
1657  ASSERT (dev_info.driver_name);
1658  if (strncmp (dev_info.driver_name, "rte_bond_pmd", 12) == 0)
1659  {
1660  u8 addr[6];
1661  u8 slink[16];
1662  int nlink = rte_eth_bond_slaves_get (i, slink, 16);
1663  if (nlink > 0)
1664  {
1665  vnet_hw_interface_t *bhi;
1666  ethernet_interface_t *bei;
1667  int rv;
1668 
1669  /* Get MAC of 1st slave link */
1670  rte_eth_macaddr_get (slink[0],
1671  (struct ether_addr *) addr);
1672  /* Set MAC of bounded interface to that of 1st slave link */
1673  rv =
1674  rte_eth_bond_mac_address_set (i,
1675  (struct ether_addr *)
1676  addr);
1677  if (rv < 0)
1678  clib_warning ("Failed to set MAC address");
1679 
1680  /* Populate MAC of bonded interface in VPP hw tables */
1681  bhi =
1682  vnet_get_hw_interface (vnm,
1683  dm->devices[i].vlib_hw_if_index);
1684  bei =
1686  clib_memcpy (bhi->hw_address, addr, 6);
1687  clib_memcpy (bei->address, addr, 6);
1688  /* Init l3 packet size allowed on bonded interface */
1692  while (nlink >= 1)
1693  { /* for all slave links */
1694  int slave = slink[--nlink];
1695  dpdk_device_t *sdev = &dm->devices[slave];
1696  vnet_hw_interface_t *shi;
1697  vnet_sw_interface_t *ssi;
1698  /* Add MAC to all slave links except the first one */
1699  if (nlink)
1700  rte_eth_dev_mac_addr_add (slave,
1701  (struct ether_addr *)
1702  addr, 0);
1703  /* Set slaves bitmap for bonded interface */
1704  bhi->bond_info =
1705  clib_bitmap_set (bhi->bond_info,
1706  sdev->vlib_hw_if_index, 1);
1707  /* Set slave link flags on slave interface */
1708  shi =
1710  ssi =
1714  }
1715  }
1716  }
1717  }
1718  }
1719  }
1720 
1721  while (1)
1722  {
1723  /*
1724  * check each time through the loop in case intervals are changed
1725  */
1726  f64 min_wait = dm->link_state_poll_interval < dm->stat_poll_interval ?
1728 
1729  vlib_process_wait_for_event_or_clock (vm, min_wait);
1730 
1732  /* skip the poll if an admin up down is in progress (on any interface) */
1733  continue;
1734 
1735  vec_foreach (xd, dm->devices)
1736  {
1737  f64 now = vlib_time_now (vm);
1738  if ((now - xd->time_last_stats_update) >= dm->stat_poll_interval)
1739  dpdk_update_counters (xd, now);
1740  if ((now - xd->time_last_link_update) >= dm->link_state_poll_interval)
1741  dpdk_update_link_state (xd, now);
1742 
1743 #if DPDK_VHOST_USER
1745  if (dpdk_vhost_user_process_if (vm, xd, vu_state) != 0)
1746  continue;
1747 #endif
1748  }
1749  }
1750 
1751 #if DPDK_VHOST_USER
1752  dpdk_vhost_user_process_cleanup (vu_state);
1753 #endif
1754 
1755  return 0;
1756 }
1757 
1758 /* *INDENT-OFF* */
1760  .function = dpdk_process,
1761  .type = VLIB_NODE_TYPE_PROCESS,
1762  .name = "dpdk-process",
1763  .process_log2_n_stack_bytes = 17,
1764 };
1765 /* *INDENT-ON* */
1766 
1767 int
1769 {
1770  if (interval < DPDK_MIN_STATS_POLL_INTERVAL)
1771  return (VNET_API_ERROR_INVALID_VALUE);
1772 
1773  dpdk_main.stat_poll_interval = interval;
1774 
1775  return 0;
1776 }
1777 
1778 int
1780 {
1781  if (interval < DPDK_MIN_LINK_POLL_INTERVAL)
1782  return (VNET_API_ERROR_INVALID_VALUE);
1783 
1784  dpdk_main.link_state_poll_interval = interval;
1785 
1786  return 0;
1787 }
1788 
1789 clib_error_t *
1791 {
1792  dpdk_main_t *dm = &dpdk_main;
1793  vlib_node_t *ei;
1794  clib_error_t *error = 0;
1796 
1797  /* verify that structs are cacheline aligned */
1798  ASSERT (offsetof (dpdk_device_t, cacheline0) == 0);
1799  ASSERT (offsetof (dpdk_device_t, cacheline1) == CLIB_CACHE_LINE_BYTES);
1800  ASSERT (offsetof (dpdk_worker_t, cacheline0) == 0);
1801  ASSERT (offsetof (frame_queue_trace_t, cacheline0) == 0);
1802 
1803  dm->vlib_main = vm;
1804  dm->vnet_main = vnet_get_main ();
1805  dm->conf = &dpdk_config_main;
1806 
1807  ei = vlib_get_node_by_name (vm, (u8 *) "ethernet-input");
1808  if (ei == 0)
1809  return clib_error_return (0, "ethernet-input node AWOL");
1810 
1811  dm->ethernet_input_node_index = ei->index;
1812 
1813  dm->conf->nchannels = 4;
1814  dm->conf->num_mbufs = dm->conf->num_mbufs ? dm->conf->num_mbufs : NB_MBUF;
1815  vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet");
1816 
1817  dm->dpdk_device_by_kni_port_id = hash_create (0, sizeof (uword));
1818  dm->vu_sw_if_index_by_listener_fd = hash_create (0, sizeof (uword));
1819  dm->vu_sw_if_index_by_sock_fd = hash_create (0, sizeof (uword));
1820 
1821  /* $$$ use n_thread_stacks since it's known-good at this point */
1822  vec_validate (dm->recycle, tm->n_thread_stacks - 1);
1823 
1824  /* initialize EFD (early fast discard) default settings */
1827  DPDK_NB_RX_DESC_10GE) / 100);
1830 
1831  /* vhost-user coalescence frames defaults */
1832  dm->conf->vhost_coalesce_frames = 32;
1833  dm->conf->vhost_coalesce_time = 1e-3;
1834 
1835  /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */
1836  dm->buffer_flags_template =
1839 
1842 
1843  /* init CLI */
1844  if ((error = vlib_call_init_function (vm, dpdk_cli_init)))
1845  return error;
1846 
1847  return error;
1848 }
1849 
1851 
1852 
1853 /*
1854  * fd.io coding-style-patch-verification: ON
1855  *
1856  * Local Variables:
1857  * eval: (c-set-style "gnu")
1858  * End:
1859  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
#define DPDK_NB_TX_DESC_10GE
Definition: dpdk_priv.h:21
f64 time_last_link_update
Definition: dpdk.h:253
vmrglw vmrglh hi
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1025
static u8 * format_bitmap_hex(u8 *s, va_list *args)
Format a bitmap as a string of hex bytes.
Definition: bitmap.h:744
format_function_t format_vlib_pci_addr
Definition: pci.h:232
#define vec_foreach_index(var, v)
Iterate over vector indices.
u16 enabled
Definition: dpdk.h:306
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define clib_min(x, y)
Definition: clib.h:326
u8 promisc
Definition: dpdk.h:222
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
u32 vlib_buffer_get_or_create_free_list(vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
Definition: dpdk_buffer.c:383
#define VNET_HW_INTERFACE_FLAG_SPEED_1G
Definition: interface.h:286
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:513
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:682
u8 interface_name_format_decimal
Definition: dpdk.h:356
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
#define NB_MBUF
Definition: dpdk.h:72
static clib_error_t * dpdk_lib_init(dpdk_main_t *dm)
Definition: init.c:236
u8 use_rss
Definition: dpdk.h:424
vnet_device_class_t dpdk_device_class
static u32 dpdk_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
Definition: init.c:138
u32 vhost_coalesce_frames
Definition: dpdk.h:362
#define DPDK_DEVICE_VLAN_STRIP_OFF
Definition: dpdk.h:325
u8 need_txlock
Definition: dpdk.h:269
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
#define I40E_DEV_ID_QSFP_B
Definition: dpdk_priv.h:29
#define NULL
Definition: clib.h:55
u32 index
Definition: node.h:237
clib_error_t * vlib_pci_bind_to_uio(vlib_pci_device_t *d, char *uio_driver_name)
Definition: linux_pci.c:95
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:182
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:533
static uword * clib_bitmap_or(uword *ai, uword *bi)
Logical operator across two bitmaps.
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
Definition: cli.c:149
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
unsigned rte_socket_id()
#define DPDK_EFD_DISABLED
Definition: dpdk.h:296
#define DPDK_NB_RX_DESC_VIRTIO
Definition: dpdk_priv.h:18
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:521
vlib_buffer_main_t * buffer_main
Definition: main.h:104
u32 per_interface_next_index
Definition: dpdk.h:205
u8 enable_tcp_udp_checksum
Definition: dpdk.h:342
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.h:110
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
#define DPDK_DEVICE_VLAN_STRIP_ON
Definition: dpdk.h:326
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * dpdk_config(vlib_main_t *vm, unformat_input_t *input)
Definition: init.c:983
#define DPDK_NB_TX_DESC_DEFAULT
Definition: dpdk_priv.h:17
#define clib_error_report(e)
Definition: error.h:125
#define foreach_eal_double_hyphen_predicate_arg
Definition: dpdk_priv.h:36
unformat_function_t unformat_vlib_pci_addr
Definition: pci.h:231
u32 next_vu_if_id
Definition: dpdk.h:413
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:273
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:407
dpdk_main_t dpdk_main
Definition: init.c:36
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
vlib_pci_addr_t bus_address
Definition: pci.h:58
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_error_t * vlib_buffer_pool_create(vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
Definition: dpdk_buffer.c:968
u8 admin_up
Definition: dpdk.h:221
#define I40E_DEV_ID_QSFP_A
Definition: dpdk_priv.h:28
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
#define I40E_DEV_ID_SFP_XL710
Definition: dpdk_priv.h:27
#define LINK_STATE_ELOGS
Definition: init.c:44
struct rte_mbuf *** tx_vectors
Definition: dpdk.h:208
f64 vhost_coalesce_time
Definition: dpdk.h:363
foreach_dpdk_device_config_item clib_bitmap_t * workers
Definition: dpdk.h:331
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
vlib_node_function_t * function
Definition: node.h:415
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
dpdk_config_main_t dpdk_config_main
Definition: dpdk.h:372
#define I40E_DEV_ID_QSFP_C
Definition: dpdk_priv.h:30
#define VPP_RUN_DIR
Definition: init.c:47
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:787
dpdk_device_config_t default_devconf
Definition: dpdk.h:366
f64 stat_poll_interval
Definition: dpdk.h:432
#define IP_BUFFER_L4_CHECKSUM_CORRECT
Definition: buffer.h:50
int input_cpu_first_index
Definition: dpdk.h:427
char i8
Definition: types.h:45
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u16 rx_q_used
Definition: dpdk.h:230
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
#define clib_warning(format, args...)
Definition: error.h:59
#define vlib_call_init_function(vm, x)
Definition: init.h:161
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:845
#define DPDK_NB_TX_DESC_VIRTIO
Definition: dpdk_priv.h:19
u32 device_index
Definition: dpdk.h:199
struct rte_eth_conf port_conf
Definition: dpdk.h:234
dpdk_worker_t * workers
Definition: dpdk.h:394
void * dpdk_input_multiarch_select()
#define DPDK_NB_TX_DESC_40GE
Definition: dpdk_priv.h:23
#define I40E_DEV_ID_10G_BASE_T
Definition: dpdk_priv.h:31
f64 time_last_stats_update
Definition: dpdk.h:265
u16 consec_full_frames_hi_thresh
Definition: dpdk.h:308
vlib_main_t ** vlib_mains
Definition: dpdk_buffer.c:157
ethernet_main_t ethernet_main
Definition: init.c:44
static struct rte_eth_conf port_conf_template
Definition: init.c:51
clib_error_t * dpdk_init(vlib_main_t *vm)
Definition: init.c:1790
u32 vlib_sw_if_index
Definition: dpdk.h:202
struct rte_eth_txconf tx_conf
Definition: dpdk.h:235
#define hash_get(h, key)
Definition: hash.h:248
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
Definition: vec.h:646
vlib_pci_addr_t pci_addr
Definition: dpdk.h:321
#define foreach_eal_double_hyphen_arg
Definition: dpdk_priv.h:53
#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES
Definition: buffer.h:304
dpdk_device_and_queue_t ** devices_by_cpu
Definition: dpdk.h:379
#define ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags)
Definition: ethernet.h:91
u8 ** eal_init_args
Definition: dpdk.h:338
#define VNET_HW_INTERFACE_FLAG_SPEED_10M
Definition: interface.h:284
u32 vlib_hw_if_index
Definition: dpdk.h:201
#define VNET_SW_INTERFACE_FLAG_BOND_SLAVE
Definition: interface.h:424
#define foreach_eal_single_hyphen_mandatory_arg
Definition: dpdk_priv.h:43
vlib_pci_device_t * pci_devs
Definition: pci.h:111
int dpdk_set_link_state_poll_interval(f64 interval)
Definition: init.c:1779
#define VNET_HW_INTERFACE_FLAG_HALF_DUPLEX
Definition: interface.h:276
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
static vlib_node_registration_t dpdk_process_node
(constructor) VLIB_REGISTER_NODE (dpdk_process_node)
Definition: init.c:1759
#define foreach_dpdk_pmd
Definition: dpdk.h:86
#define ELOG_DATA(em, f)
Definition: elog.h:392
dpdk_port_type_t port_type
Definition: dpdk.h:266
static uword dpdk_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: init.c:1594
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:118
#define DPDK_MIN_STATS_POLL_INTERVAL
Definition: dpdk.h:276
int input_cpu_count
Definition: dpdk.h:428
#define VLIB_FRAME_SIZE
Definition: node.h:328
void * vlib_weakly_linked_functions[]
Definition: init.c:39
u16 tx_q_used
Definition: dpdk.h:229
u16 nb_rx_desc
Definition: dpdk.h:231
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
static clib_error_t * dpdk_device_config(dpdk_config_main_t *conf, vlib_pci_addr_t pci_addr, unformat_input_t *input, u8 is_default)
Definition: init.c:899
u32 ** recycle
Definition: dpdk.h:382
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:359
#define foreach_eal_single_hyphen_arg
Definition: dpdk_priv.h:47
int dpdk_set_stat_poll_interval(f64 interval)
Definition: init.c:1768
#define DPDK_NB_RX_DESC_DEFAULT
Definition: dpdk_priv.h:16
svmdb_client_t * c
dpdk_device_t * devices
Definition: dpdk.h:378
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:83
u16 * cpu_socket_id_by_queue
Definition: dpdk.h:233
#define DPDK_EFD_DEFAULT_DEVICE_QUEUE_HI_THRESH_PCT
Definition: dpdk.h:301
vlib_pci_main_t pci_main
Definition: pci.c:53
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
volatile u32 ** lockp
Definition: dpdk.h:196
dpdk_device_config_t * dev_confs
Definition: dpdk.h:367
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
struct rte_mbuf *** rx_vectors
Definition: dpdk.h:209
void dpdk_device_lock_free(dpdk_device_t *xd)
Definition: init.c:224
u16 queue_hi_thresh
Definition: dpdk.h:307
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
Definition: node_funcs.h:88
#define clib_memcpy(a, b, c)
Definition: string.h:63
#define DPDK_NB_RX_DESC_ENIC
Definition: dpdk_priv.h:24
dpdk_pmd_t pmd
Definition: dpdk.h:218
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Definition: buffer.h:97
elog_main_t elog_main
Definition: main.h:141
static void dpdk_bind_devices_to_uio(dpdk_config_main_t *conf)
Definition: init.c:827
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:85
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:350
#define DEFAULT_HUGE_DIR
Definition: init.c:46
clib_error_t * dpdk_port_setup(dpdk_main_t *dm, dpdk_device_t *xd)
Definition: init.c:65
#define VNET_HW_INTERFACE_FLAG_SPEED_10G
Definition: interface.h:287
#define vec_validate_ha(V, I, H, A)
Make sure vector is long enough for given index (general version).
Definition: vec.h:376
u8 * interface_name_suffix
Definition: dpdk.h:226
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1449
#define hash_create(elts, value_bytes)
Definition: hash.h:647
#define VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
Definition: interface.h:277
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
Definition: interface.h:345
#define DPDK_TX_RING_SIZE
Definition: dpdk.h:273
clib_error_t * vlib_sysfs_read(char *file_name, char *fmt,...)
Definition: util.c:126
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
u32 poll_sleep
Definition: dpdk.h:435
void * dpdk_input_rss_multiarch_select()
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
dpdk_efd_t efd
Definition: dpdk.h:416
#define DPDK_EFD_DEFAULT_CONSEC_FULL_FRAMES_HI_THRESH
Definition: dpdk.h:302
u8 af_packet_port_id
Definition: dpdk.h:250
#define I40E_DEV_ID_VF
Definition: dpdk_priv.h:32
static void clib_mem_free(void *p)
Definition: mem.h:154
Bitmaps built as vectors of machine words.
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:181
u8 use_virtio_vhost
Definition: dpdk.h:359
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:144
#define DPDK_LINK_POLL_INTERVAL
Definition: dpdk.h:278
uword * thread_registrations_by_name
Definition: threads.h:268
struct rte_eth_link link
Definition: dpdk.h:252
#define DPDK_NB_RX_DESC_10GE
Definition: dpdk_priv.h:20
u64 uword
Definition: types.h:112
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
Definition: bitmap.h:441
#define IP_BUFFER_L4_CHECKSUM_COMPUTED
Definition: buffer.h:49
u8 kni_port_id
Definition: dpdk.h:239
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
Definition: defs.h:47
#define DPDK_STATS_POLL_INTERVAL
Definition: dpdk.h:275
#define VNET_HW_INTERFACE_FLAG_SPEED_100M
Definition: interface.h:285
u32 ethernet_input_node_index
Definition: dpdk.h:398
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
dpdk_device_type_t dev_type
Definition: dpdk.h:217
unsigned char u8
Definition: types.h:56
static uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
Definition: bitmap.h:693
void dpdk_device_lock_init(dpdk_device_t *xd)
Definition: init.c:210
#define DPDK_MIN_LINK_POLL_INTERVAL
Definition: dpdk.h:279
#define hash_get_mem(h, key)
Definition: hash.h:268
u32 buffer_flags_template
Definition: dpdk.h:385
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:114
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
#define VNET_HW_INTERFACE_FLAG_SPEED_40G
Definition: interface.h:288
u32 vlib_buffer_free_list_index
Definition: dpdk.h:391
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u32 dpdk_get_admin_up_down_in_progress(void)
Definition: device.c:1287
#define ETHERNET_MAX_PACKET_BYTES
Definition: ethernet.h:78
#define vec_foreach(var, vec)
Vector iterator.
i8 cpu_socket
Definition: dpdk.h:219
#define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags)
Definition: ethernet.h:86
uword * cpu_socket_bitmap
Definition: threads.h:303
vhost_vring_addr_t addr
Definition: vhost-user.h:82
#define clib_error_return(e, args...)
Definition: error.h:111
struct _unformat_input_t unformat_input_t
u8 * uio_driver_name
Definition: dpdk.h:340
u32 flags
Definition: vhost-user.h:76
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
ethernet_interface_t * interfaces
Definition: ethernet.h:216
vnet_main_t * vnet_main
Definition: dpdk.h:439
u16 nb_tx_desc
Definition: dpdk.h:232
uword * device_config_index_by_pci_addr
Definition: dpdk.h:368
static uword vnet_hw_interface_is_link_up(vnet_main_t *vnm, u32 hw_if_index)
volatile u32 worker_thread_release
Definition: threads.h:315
#define DPDK_NB_RX_DESC_40GE
Definition: dpdk_priv.h:22
uword * dpdk_device_by_kni_port_id
Definition: dpdk.h:408
Definition: defs.h:46
uword * vu_sw_if_index_by_listener_fd
Definition: dpdk.h:409
f64 link_state_poll_interval
Definition: dpdk.h:431
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
clib_error_t * dpdk_cli_init(vlib_main_t *vm)
Definition: cli.c:894
dpdk_config_main_t * conf
Definition: dpdk.h:440
uword * vu_sw_if_index_by_sock_fd
Definition: dpdk.h:410
vlib_main_t * vlib_main
Definition: dpdk.h:438