FD.io VPP  v19.08-27-gf4dcae4
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 #include <vppinfra/linux/sysfs.h>
21 #include <vlib/unix/unix.h>
22 #include <vlib/log.h>
23 
24 #include <vnet/ethernet/ethernet.h>
25 #include <dpdk/buffer.h>
26 #include <dpdk/device/dpdk.h>
27 #include <vlib/pci/pci.h>
28 #include <vlib/vmbus/vmbus.h>
29 
30 #include <rte_ring.h>
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35 #include <sys/stat.h>
36 #include <sys/mount.h>
37 #include <string.h>
38 #include <fcntl.h>
39 #include <dirent.h>
40 
41 #include <dpdk/device/dpdk_priv.h>
42 
43 #define ETHER_MAX_LEN 1518 /**< Maximum frame len, including CRC. */
44 
47 
48 #define LINK_STATE_ELOGS 0
49 
50 /* Port configuration, mildly modified Intel app values */
51 
52 static dpdk_port_type_t
53 port_type_from_speed_capa (struct rte_eth_dev_info *dev_info)
54 {
55 
56  if (dev_info->speed_capa & ETH_LINK_SPEED_100G)
58  else if (dev_info->speed_capa & ETH_LINK_SPEED_56G)
60  else if (dev_info->speed_capa & ETH_LINK_SPEED_50G)
62  else if (dev_info->speed_capa & ETH_LINK_SPEED_40G)
64  else if (dev_info->speed_capa & ETH_LINK_SPEED_25G)
66  else if (dev_info->speed_capa & ETH_LINK_SPEED_20G)
68  else if (dev_info->speed_capa & ETH_LINK_SPEED_10G)
70  else if (dev_info->speed_capa & ETH_LINK_SPEED_5G)
72  else if (dev_info->speed_capa & ETH_LINK_SPEED_2_5G)
74  else if (dev_info->speed_capa & ETH_LINK_SPEED_1G)
76 
78 }
79 
80 static dpdk_port_type_t
82 {
83  switch (link_speed)
84  {
85  case ETH_SPEED_NUM_1G:
87  case ETH_SPEED_NUM_2_5G:
89  case ETH_SPEED_NUM_5G:
91  case ETH_SPEED_NUM_10G:
93  case ETH_SPEED_NUM_20G:
95  case ETH_SPEED_NUM_25G:
97  case ETH_SPEED_NUM_40G:
99  case ETH_SPEED_NUM_50G:
101  case ETH_SPEED_NUM_56G:
103  case ETH_SPEED_NUM_100G:
105  default:
107  }
108 }
109 
110 static u32
112 {
113  dpdk_main_t *dm = &dpdk_main;
115  u32 old = 0;
116 
118  {
119  old = (xd->flags & DPDK_DEVICE_FLAG_PROMISC) != 0;
120 
122  xd->flags |= DPDK_DEVICE_FLAG_PROMISC;
123  else
124  xd->flags &= ~DPDK_DEVICE_FLAG_PROMISC;
125 
126  if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
127  {
128  if (xd->flags & DPDK_DEVICE_FLAG_PROMISC)
129  rte_eth_promiscuous_enable (xd->port_id);
130  else
131  rte_eth_promiscuous_disable (xd->port_id);
132  }
133  }
134  else if (ETHERNET_INTERFACE_FLAG_CONFIG_MTU (flags))
135  {
136  xd->port_conf.rxmode.max_rx_pkt_len = hi->max_packet_bytes;
137  dpdk_device_setup (xd);
138  }
139  return old;
140 }
141 
142 static void
144 {
145  int q;
146  vec_validate (xd->lockp, xd->tx_q_used - 1);
147  for (q = 0; q < xd->tx_q_used; q++)
148  {
151  clib_memset ((void *) xd->lockp[q], 0, CLIB_CACHE_LINE_BYTES);
152  }
153 }
154 
155 static int
157 {
158  return !(xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC);
159 }
160 
161 /* The funciton check_l3cache helps check if Level 3 cache exists or not on current CPUs
162  return value 1: exist.
163  return value 0: not exist.
164 */
165 static int
167 {
168 
169  struct dirent *dp;
170  clib_error_t *err;
171  const char *sys_cache_dir = "/sys/devices/system/cpu/cpu0/cache";
172  DIR *dir_cache = opendir (sys_cache_dir);
173 
174  if (dir_cache == NULL)
175  return -1;
176 
177  while ((dp = readdir (dir_cache)) != NULL)
178  {
179  if (dp->d_type == DT_DIR)
180  {
181  u8 *p = NULL;
182  int level_cache = -1;
183 
184  p = format (p, "%s/%s/%s", sys_cache_dir, dp->d_name, "level");
185  if ((err = clib_sysfs_read ((char *) p, "%d", &level_cache)))
186  clib_error_free (err);
187 
188  if (level_cache == 3)
189  {
190  closedir (dir_cache);
191  return 1;
192  }
193  }
194  }
195 
196  if (dir_cache != NULL)
197  closedir (dir_cache);
198 
199  return 0;
200 }
201 
202 static clib_error_t *
204 {
205  u32 nports;
206  u32 mtu, max_rx_frame;
207  int i;
208  clib_error_t *error;
214  dpdk_device_t *xd;
215  vlib_pci_addr_t last_pci_addr;
216  u32 last_pci_addr_port = 0;
218  uword *p_hqos;
219 
220  u32 next_hqos_cpu = 0;
221  u8 af_packet_instance_num = 0;
222  last_pci_addr.as_u32 = ~0;
223 
224  dm->hqos_cpu_first_index = 0;
225  dm->hqos_cpu_count = 0;
226 
227  /* find out which cpus will be used for I/O TX */
228  p_hqos = hash_get_mem (tm->thread_registrations_by_name, "hqos-threads");
229  tr_hqos = p_hqos ? (vlib_thread_registration_t *) p_hqos[0] : 0;
230 
231  if (tr_hqos && tr_hqos->count > 0)
232  {
233  dm->hqos_cpu_first_index = tr_hqos->first_index;
234  dm->hqos_cpu_count = tr_hqos->count;
235  }
236 
239 
240  nports = rte_eth_dev_count_avail ();
241 
242  if (nports < 1)
243  {
244  dpdk_log_notice ("DPDK drivers found no ports...");
245  }
246 
247  if (CLIB_DEBUG > 0)
248  dpdk_log_notice ("DPDK drivers found %d ports...", nports);
249 
250  if (dm->conf->enable_tcp_udp_checksum)
251  dm->buffer_flags_template &= ~(VNET_BUFFER_F_L4_CHECKSUM_CORRECT
252  | VNET_BUFFER_F_L4_CHECKSUM_COMPUTED);
253 
254  /* vlib_buffer_t template */
257  for (i = 0; i < tm->n_vlib_mains; i++)
258  {
260  clib_memset (&ptd->buffer_template, 0, sizeof (vlib_buffer_t));
262  vnet_buffer (&ptd->buffer_template)->sw_if_index[VLIB_TX] = (u32) ~ 0;
263  }
264 
265  /* *INDENT-OFF* */
266  RTE_ETH_FOREACH_DEV(i)
267  {
268  u8 addr[6];
269  int vlan_off;
270  struct rte_eth_dev_info dev_info;
271  struct rte_pci_device *pci_dev;
272  struct rte_eth_link l;
273  dpdk_portid_t next_port_id;
274  dpdk_device_config_t *devconf = 0;
275  vlib_pci_addr_t pci_addr;
276  uword *p = 0;
277 
278  if (!rte_eth_dev_is_valid_port(i))
279  continue;
280 
281  rte_eth_link_get_nowait (i, &l);
282  rte_eth_dev_info_get (i, &dev_info);
283 
284  if (dev_info.device == 0)
285  {
286  clib_warning ("DPDK bug: missing device info. Skipping %s device",
287  dev_info.driver_name);
288  continue;
289  }
290 
291  pci_dev = dpdk_get_pci_device (&dev_info);
292 
293  if (pci_dev)
294  {
295  pci_addr.domain = pci_dev->addr.domain;
296  pci_addr.bus = pci_dev->addr.bus;
297  pci_addr.slot = pci_dev->addr.devid;
298  pci_addr.function = pci_dev->addr.function;
300  pci_addr.as_u32);
301  }
302 
303 
304  /* Create vnet interface */
308  xd->cpu_socket = (i8) rte_eth_dev_socket_id (i);
309 
310  if (p)
311  {
312  devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
313  xd->name = devconf->name;
314  }
315  else
316  devconf = &dm->conf->default_devconf;
317 
318  /* Handle interface naming for devices with multiple ports sharing same PCI ID */
319  if (pci_dev &&
320  ((next_port_id = rte_eth_find_next (i + 1)) != RTE_MAX_ETHPORTS))
321  {
322  struct rte_eth_dev_info di = { 0 };
323  struct rte_pci_device *next_pci_dev;
324  rte_eth_dev_info_get (next_port_id, &di);
325  next_pci_dev = di.device ? RTE_DEV_TO_PCI (di.device) : 0;
326  if (next_pci_dev &&
327  pci_addr.as_u32 != last_pci_addr.as_u32 &&
328  memcmp (&pci_dev->addr, &next_pci_dev->addr,
329  sizeof (struct rte_pci_addr)) == 0)
330  {
331  xd->interface_name_suffix = format (0, "0");
332  last_pci_addr.as_u32 = pci_addr.as_u32;
333  last_pci_addr_port = i;
334  }
335  else if (pci_addr.as_u32 == last_pci_addr.as_u32)
336  {
338  format (0, "%u", i - last_pci_addr_port);
339  }
340  else
341  {
342  last_pci_addr.as_u32 = ~0;
343  }
344  }
345  else
346  last_pci_addr.as_u32 = ~0;
347 
348  clib_memcpy (&xd->tx_conf, &dev_info.default_txconf,
349  sizeof (struct rte_eth_txconf));
350 
351  if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
352  {
353  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_IPV4_CKSUM;
354  xd->flags |= DPDK_DEVICE_FLAG_RX_IP4_CKSUM;
355  }
356 
357  if (dm->conf->no_multi_seg)
358  {
359  xd->port_conf.txmode.offloads &= ~DEV_TX_OFFLOAD_MULTI_SEGS;
360  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
361  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER;
362  }
363  else
364  {
365  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
366  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
367  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SCATTER;
368  xd->flags |= DPDK_DEVICE_FLAG_MAYBE_MULTISEG;
369  }
370 
371  xd->tx_q_used = clib_min (dev_info.max_tx_queues, tm->n_vlib_mains);
372 
373  if (devconf->num_tx_queues > 0
374  && devconf->num_tx_queues < xd->tx_q_used)
375  xd->tx_q_used = clib_min (xd->tx_q_used, devconf->num_tx_queues);
376 
377  if (devconf->num_rx_queues > 1
378  && dev_info.max_rx_queues >= devconf->num_rx_queues)
379  {
380  xd->rx_q_used = devconf->num_rx_queues;
381  xd->port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
382  if (devconf->rss_fn == 0)
383  xd->port_conf.rx_adv_conf.rss_conf.rss_hf =
384  ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
385  else
386  {
387  u64 unsupported_bits;
388  xd->port_conf.rx_adv_conf.rss_conf.rss_hf = devconf->rss_fn;
389  unsupported_bits = xd->port_conf.rx_adv_conf.rss_conf.rss_hf;
390  unsupported_bits &= ~dev_info.flow_type_rss_offloads;
391  if (unsupported_bits)
392  dpdk_log_warn ("Unsupported RSS hash functions: %U",
393  format_dpdk_rss_hf_name, unsupported_bits);
394  }
395  xd->port_conf.rx_adv_conf.rss_conf.rss_hf &=
396  dev_info.flow_type_rss_offloads;
397  }
398  else
399  xd->rx_q_used = 1;
400 
401  xd->flags |= DPDK_DEVICE_FLAG_PMD;
402 
403  /* workaround for drivers not setting driver_name */
404  if ((!dev_info.driver_name) && (pci_dev))
405  dev_info.driver_name = pci_dev->driver->driver.name;
406 
407  ASSERT (dev_info.driver_name);
408 
409  if (!xd->pmd)
410  {
411 
412 
413 #define _(s,f) else if (dev_info.driver_name && \
414  !strcmp(dev_info.driver_name, s)) \
415  xd->pmd = VNET_DPDK_PMD_##f;
416  if (0)
417  ;
419 #undef _
420  else
422 
426 
427  switch (xd->pmd)
428  {
429  /* Drivers with valid speed_capa set */
430  case VNET_DPDK_PMD_E1000EM:
431  case VNET_DPDK_PMD_IGB:
432  case VNET_DPDK_PMD_IXGBE:
433  case VNET_DPDK_PMD_I40E:
434  case VNET_DPDK_PMD_ICE:
435  xd->port_type = port_type_from_speed_capa (&dev_info);
436  xd->supported_flow_actions = VNET_FLOW_ACTION_MARK |
437  VNET_FLOW_ACTION_REDIRECT_TO_NODE |
438  VNET_FLOW_ACTION_REDIRECT_TO_QUEUE |
439  VNET_FLOW_ACTION_BUFFER_ADVANCE |
440  VNET_FLOW_ACTION_COUNT | VNET_FLOW_ACTION_DROP;
441 
442  if (dm->conf->no_tx_checksum_offload == 0)
443  {
444  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
445  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
446  xd->flags |=
447  DPDK_DEVICE_FLAG_TX_OFFLOAD |
448  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
449  }
450 
451 
452  break;
453  case VNET_DPDK_PMD_CXGBE:
454  case VNET_DPDK_PMD_MLX4:
455  case VNET_DPDK_PMD_MLX5:
456  case VNET_DPDK_PMD_QEDE:
457  xd->port_type = port_type_from_speed_capa (&dev_info);
458  break;
459 
460  /* SR-IOV VFs */
461  case VNET_DPDK_PMD_IGBVF:
462  case VNET_DPDK_PMD_IXGBEVF:
463  case VNET_DPDK_PMD_I40EVF:
465  if (dm->conf->no_tx_checksum_offload == 0)
466  {
467  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
468  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
469  xd->flags |=
470  DPDK_DEVICE_FLAG_TX_OFFLOAD |
471  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
472  }
473  break;
474 
475  case VNET_DPDK_PMD_THUNDERX:
477 
478  if (dm->conf->no_tx_checksum_offload == 0)
479  {
480  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
481  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
482  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD;
483  }
484  break;
485 
486  case VNET_DPDK_PMD_ENA:
488  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER;
489  break;
490 
491  case VNET_DPDK_PMD_DPAA2:
493  break;
494 
495  /* Cisco VIC */
496  case VNET_DPDK_PMD_ENIC:
497  xd->port_type = port_type_from_link_speed (l.link_speed);
498  break;
499 
500  /* Intel Red Rock Canyon */
501  case VNET_DPDK_PMD_FM10K:
503  break;
504 
505  /* virtio */
506  case VNET_DPDK_PMD_VIRTIO:
510  break;
511 
512  /* vmxnet3 */
513  case VNET_DPDK_PMD_VMXNET3:
515  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
516  break;
517 
518  case VNET_DPDK_PMD_AF_PACKET:
520  xd->af_packet_instance_num = af_packet_instance_num++;
521  break;
522 
523  case VNET_DPDK_PMD_VIRTIO_USER:
525  break;
526 
527  case VNET_DPDK_PMD_VHOST_ETHER:
529  break;
530 
531  case VNET_DPDK_PMD_LIOVF_ETHER:
533  break;
534 
535  case VNET_DPDK_PMD_FAILSAFE:
537  xd->port_conf.intr_conf.lsc = 1;
538  break;
539 
540  case VNET_DPDK_PMD_NETVSC:
541  xd->port_type = port_type_from_link_speed (l.link_speed);
542  break;
543 
544  default:
546  }
547 
548  if (devconf->num_rx_desc)
549  xd->nb_rx_desc = devconf->num_rx_desc;
550  else {
551 
552  /* If num_rx_desc is not specified by VPP user, the current CPU is working
553  with 2M page and has no L3 cache, default num_rx_desc is changed to 512
554  from original 1024 to help reduce TLB misses.
555  */
556  if ((clib_mem_get_default_hugepage_size () == 2 << 20)
557  && check_l3cache() == 0)
558  xd->nb_rx_desc = 512;
559  }
560 
561  if (devconf->num_tx_desc)
562  xd->nb_tx_desc = devconf->num_tx_desc;
563  else {
564 
565  /* If num_tx_desc is not specified by VPP user, the current CPU is working
566  with 2M page and has no L3 cache, default num_tx_desc is changed to 512
567  from original 1024 to help reduce TLB misses.
568  */
569  if ((clib_mem_get_default_hugepage_size () == 2 << 20)
570  && check_l3cache() == 0)
571  xd->nb_tx_desc = 512;
572  }
573  }
574 
575  if (xd->pmd == VNET_DPDK_PMD_AF_PACKET)
576  {
577  f64 now = vlib_time_now (vm);
578  u32 rnd;
579  rnd = (u32) (now * 1e6);
580  rnd = random_u32 (&rnd);
581  clib_memcpy (addr + 2, &rnd, sizeof (rnd));
582  addr[0] = 2;
583  addr[1] = 0xfe;
584  }
585  else
586  rte_eth_macaddr_get (i, (struct ether_addr *) addr);
587 
588  if (xd->tx_q_used < tm->n_vlib_mains)
590 
591  xd->port_id = i;
592  xd->device_index = xd - dm->devices;
593  xd->per_interface_next_index = ~0;
594 
595  /* assign interface to input thread */
596  int q;
597 
598  if (devconf->hqos_enabled)
599  {
600  xd->flags |= DPDK_DEVICE_FLAG_HQOS;
601 
602  int cpu;
603  if (devconf->hqos.hqos_thread_valid)
604  {
605  if (devconf->hqos.hqos_thread >= dm->hqos_cpu_count)
606  return clib_error_return (0, "invalid HQoS thread index");
607 
608  cpu = dm->hqos_cpu_first_index + devconf->hqos.hqos_thread;
609  }
610  else
611  {
612  if (dm->hqos_cpu_count == 0)
613  return clib_error_return (0, "no HQoS threads available");
614 
615  cpu = dm->hqos_cpu_first_index + next_hqos_cpu;
616 
617  next_hqos_cpu++;
618  if (next_hqos_cpu == dm->hqos_cpu_count)
619  next_hqos_cpu = 0;
620 
621  devconf->hqos.hqos_thread_valid = 1;
622  devconf->hqos.hqos_thread = cpu;
623  }
624 
626  vec_add2 (dm->devices_by_hqos_cpu[cpu], dq, 1);
627  dq->device = xd->device_index;
628  dq->queue_id = 0;
629  }
630 
632  (dm->vnet_main, dpdk_device_class.index, xd->device_index,
633  /* ethernet address */ addr,
635  if (error)
636  return error;
637 
638  /*
639  * Ensure default mtu is not > the mtu read from the hardware.
640  * Otherwise rte_eth_dev_configure() will fail and the port will
641  * not be available.
642  * Calculate max_frame_size and mtu supported by NIC
643  */
644  if (ETHERNET_MAX_PACKET_BYTES > dev_info.max_rx_pktlen)
645  {
646  /*
647  * This device does not support the platforms's max frame
648  * size. Use it's advertised mru instead.
649  */
650  max_rx_frame = dev_info.max_rx_pktlen;
651  mtu = dev_info.max_rx_pktlen - sizeof (ethernet_header_t);
652  }
653  else
654  {
655  /* VPP treats MTU and max_rx_pktlen both equal to
656  * ETHERNET_MAX_PACKET_BYTES, if dev_info.max_rx_pktlen >=
657  * ETHERNET_MAX_PACKET_BYTES + sizeof(ethernet_header_t)
658  */
659  if (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES +
660  sizeof (ethernet_header_t)))
661  {
663  max_rx_frame = ETHERNET_MAX_PACKET_BYTES;
664 
665  /*
666  * Some platforms do not account for Ethernet FCS (4 bytes) in
667  * MTU calculations. To interop with them increase mru but only
668  * if the device's settings can support it.
669  */
670  if (dpdk_port_crc_strip_enabled (xd) &&
671  (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES +
672  sizeof (ethernet_header_t) +
673  4)))
674  {
675  max_rx_frame += 4;
676  }
677  }
678  else
679  {
680  max_rx_frame = ETHERNET_MAX_PACKET_BYTES;
682 
683  if (dpdk_port_crc_strip_enabled (xd) &&
684  (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES + 4)))
685  {
686  max_rx_frame += 4;
687  }
688  }
689  }
690 
691  if (xd->pmd == VNET_DPDK_PMD_FAILSAFE)
692  {
693  /* failsafe device numerables are reported with active device only,
694  * need to query the mtu for current device setup to overwrite
695  * reported value.
696  */
697  uint16_t dev_mtu;
698  if (!rte_eth_dev_get_mtu (i, &dev_mtu))
699  {
700  mtu = dev_mtu;
701  max_rx_frame = mtu + sizeof (ethernet_header_t);
702 
704  {
705  max_rx_frame += 4;
706  }
707  }
708  }
709 
710  /*Set port rxmode config */
711  xd->port_conf.rxmode.max_rx_pkt_len = max_rx_frame;
712 
714  xd->sw_if_index = sw->sw_if_index;
716  dpdk_input_node.index);
717 
718  if (devconf->workers)
719  {
720  int i;
721  q = 0;
722  clib_bitmap_foreach (i, devconf->workers, ({
723  vnet_hw_interface_assign_rx_thread (dm->vnet_main, xd->hw_if_index, q++,
724  vdm->first_worker_thread_index + i);
725  }));
726  }
727  else
728  for (q = 0; q < xd->rx_q_used; q++)
729  {
731  ~1);
732  }
733 
734  /*Get vnet hardware interface */
736 
737  /*Override default max_packet_bytes and max_supported_bytes set in
738  * ethernet_register_interface() above*/
739  if (hi)
740  {
741  hi->max_packet_bytes = mtu;
742  hi->max_supported_packet_bytes = max_rx_frame;
743  hi->numa_node = xd->cpu_socket;
744  }
745 
746  if (dm->conf->no_tx_checksum_offload == 0)
747  if (xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD && hi != NULL)
749 
750  dpdk_device_setup (xd);
751 
752  if (vec_len (xd->errors))
753  dpdk_log_err ("setup failed for device %U. Errors:\n %U",
756 
757  if (devconf->hqos_enabled)
758  {
759  clib_error_t *rv;
760  rv = dpdk_port_setup_hqos (xd, &devconf->hqos);
761  if (rv)
762  return rv;
763  }
764 
765  /*
766  * A note on Cisco VIC (PMD_ENIC) and VLAN:
767  *
768  * With Cisco VIC vNIC, every ingress packet is tagged. On a
769  * trunk vNIC (C series "standalone" server), packets on no VLAN
770  * are tagged with vlan 0. On an access vNIC (standalone or B
771  * series "blade" server), packets on the default/native VLAN
772  * are tagged with that vNIC's VLAN. VPP expects these packets
773  * to be untagged, and previously enabled VLAN strip on VIC by
774  * default. But it also broke vlan sub-interfaces.
775  *
776  * The VIC adapter has "untag default vlan" ingress VLAN rewrite
777  * mode, which removes tags from these packets. VPP now includes
778  * a local patch for the enic driver to use this untag mode, so
779  * enabling vlan stripping is no longer needed. In future, the
780  * driver + dpdk will have an API to set the mode after
781  * rte_eal_init. Then, this note and local patch will be
782  * removed.
783  */
784 
785  /*
786  * VLAN stripping: default to VLAN strip disabled, unless specified
787  * otherwise in the startup config.
788  */
789 
790  vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
792  {
793  vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
794  if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
795  dpdk_log_info ("VLAN strip enabled for interface\n");
796  else
797  dpdk_log_warn ("VLAN strip cannot be supported by interface\n");
798  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
799  }
800  else
801  {
802  if (vlan_off & ETH_VLAN_STRIP_OFFLOAD)
803  {
804  vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD;
805  if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
806  dpdk_log_warn ("set VLAN offload failed\n");
807  }
808  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
809  }
810 
811  if (hi)
812  hi->max_packet_bytes = xd->port_conf.rxmode.max_rx_pkt_len
813  - sizeof (ethernet_header_t);
814  else
815  clib_warning ("hi NULL");
816 
817  if (dm->conf->no_multi_seg)
818  mtu = mtu > ETHER_MAX_LEN ? ETHER_MAX_LEN : mtu;
819 
820  rte_eth_dev_set_mtu (xd->port_id, mtu);
821  }
822  /* *INDENT-ON* */
823 
824  return 0;
825 }
826 
827 static void
829 {
831  clib_error_t *error;
832  u8 *pci_addr = 0;
833  int num_whitelisted = vec_len (conf->dev_confs);
834  vlib_pci_device_info_t *d = 0;
835  vlib_pci_addr_t *addr = 0, *addrs;
836  int i;
837 
838  addrs = vlib_pci_get_all_dev_addrs ();
839  /* *INDENT-OFF* */
840  vec_foreach (addr, addrs)
841  {
842  dpdk_device_config_t * devconf = 0;
843  vec_reset_length (pci_addr);
844  pci_addr = format (pci_addr, "%U%c", format_vlib_pci_addr, addr, 0);
845  if (d)
846  {
848  d = 0;
849  }
850  d = vlib_pci_get_device_info (vm, addr, &error);
851  if (error)
852  {
853  clib_error_report (error);
854  continue;
855  }
856 
858  continue;
859 
860  if (num_whitelisted)
861  {
862  uword * p = hash_get (conf->device_config_index_by_pci_addr, addr->as_u32);
863 
864  if (!p)
865  {
866  skipped:
867  continue;
868  }
869 
870  devconf = pool_elt_at_index (conf->dev_confs, p[0]);
871  }
872 
873  /* Enforce Device blacklist by vendor and device */
874  for (i = 0; i < vec_len (conf->blacklist_by_pci_vendor_and_device); i++)
875  {
876  u16 vendor, device;
877  vendor = (u16)(conf->blacklist_by_pci_vendor_and_device[i] >> 16);
878  device = (u16)(conf->blacklist_by_pci_vendor_and_device[i] & 0xFFFF);
879  if (d->vendor_id == vendor && d->device_id == device)
880  {
881  /*
882  * Expected case: device isn't whitelisted,
883  * so blacklist it...
884  */
885  if (devconf == 0)
886  {
887  /* Device is blacklisted */
888  pool_get (conf->dev_confs, devconf);
889  hash_set (conf->device_config_index_by_pci_addr, addr->as_u32,
890  devconf - conf->dev_confs);
891  devconf->pci_addr.as_u32 = addr->as_u32;
892  devconf->is_blacklisted = 1;
893  goto skipped;
894  }
895  else /* explicitly whitelisted, ignore the device blacklist */
896  break;
897  }
898  }
899 
900  /* virtio */
901  if (d->vendor_id == 0x1af4 &&
904  ;
905  /* vmxnet3 */
906  else if (d->vendor_id == 0x15ad && d->device_id == 0x07b0)
907  {
908  /*
909  * For vmxnet3 PCI, unless it is explicitly specified in the whitelist,
910  * the default is to put it in the blacklist.
911  */
912  if (devconf == 0)
913  {
914  pool_get (conf->dev_confs, devconf);
915  hash_set (conf->device_config_index_by_pci_addr, addr->as_u32,
916  devconf - conf->dev_confs);
917  devconf->pci_addr.as_u32 = addr->as_u32;
918  devconf->is_blacklisted = 1;
919  }
920  }
921  /* all Intel network devices */
922  else if (d->vendor_id == 0x8086 && d->device_class == PCI_CLASS_NETWORK_ETHERNET)
923  ;
924  /* all Intel QAT devices VFs */
925  else if (d->vendor_id == 0x8086 && d->device_class == PCI_CLASS_PROCESSOR_CO &&
926  (d->device_id == 0x0443 || d->device_id == 0x37c9 || d->device_id == 0x19e3))
927  ;
928  /* Cisco VIC */
929  else if (d->vendor_id == 0x1137 &&
930  (d->device_id == 0x0043 || d->device_id == 0x0071))
931  ;
932  /* Chelsio T4/T5 */
933  else if (d->vendor_id == 0x1425 && (d->device_id & 0xe000) == 0x4000)
934  ;
935  /* Amazen Elastic Network Adapter */
936  else if (d->vendor_id == 0x1d0f && d->device_id >= 0xec20 && d->device_id <= 0xec21)
937  ;
938  /* Cavium Network Adapter */
939  else if (d->vendor_id == 0x177d && d->device_id == 0x9712)
940  ;
941  /* Cavium FastlinQ QL41000 Series */
942  else if (d->vendor_id == 0x1077 && d->device_id >= 0x8070 && d->device_id <= 0x8090)
943  ;
944  /* Mellanox mlx4 */
945  else if (d->vendor_id == 0x15b3 && d->device_id >= 0x1003 && d->device_id <= 0x1004)
946  {
947  continue;
948  }
949  /* Mellanox mlx5 */
950  else if (d->vendor_id == 0x15b3 && d->device_id >= 0x1013 && d->device_id <= 0x101a)
951  {
952  continue;
953  }
954  else
955  {
956  dpdk_log_warn ("Unsupported PCI device 0x%04x:0x%04x found "
957  "at PCI address %s\n", (u16) d->vendor_id, (u16) d->device_id,
958  pci_addr);
959  continue;
960  }
961 
962  error = vlib_pci_bind_to_uio (vm, addr, (char *) conf->uio_driver_name);
963 
964  if (error)
965  {
966  if (devconf == 0)
967  {
968  pool_get (conf->dev_confs, devconf);
969  hash_set (conf->device_config_index_by_pci_addr, addr->as_u32,
970  devconf - conf->dev_confs);
971  devconf->pci_addr.as_u32 = addr->as_u32;
972  }
973  devconf->is_blacklisted = 1;
974  clib_error_report (error);
975  }
976  }
977  /* *INDENT-ON* */
978  vec_free (pci_addr);
980 }
981 
982 static void
984 {
985  clib_error_t *error;
986  vlib_vmbus_addr_t *addrs, *addr = 0;
987 
988  addrs = vlib_vmbus_get_all_dev_addrs ();
989 
990  /* *INDENT-OFF* */
991  vec_foreach (addr, addrs)
992  {
993  error = vlib_vmbus_bind_to_uio (addr);
994 
995  if (error)
996  {
997  clib_error_report (error);
998  }
999  }
1000  /* *INDENT-ON* */
1001 }
1002 
1003 static clib_error_t *
1004 dpdk_device_config (dpdk_config_main_t * conf, vlib_pci_addr_t pci_addr,
1005  unformat_input_t * input, u8 is_default)
1006 {
1007  clib_error_t *error = 0;
1008  uword *p;
1009  dpdk_device_config_t *devconf;
1010  unformat_input_t sub_input;
1011 
1012  if (is_default)
1013  {
1014  devconf = &conf->default_devconf;
1015  }
1016  else
1017  {
1018  p = hash_get (conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1019 
1020  if (!p)
1021  {
1022  pool_get (conf->dev_confs, devconf);
1023  hash_set (conf->device_config_index_by_pci_addr, pci_addr.as_u32,
1024  devconf - conf->dev_confs);
1025  }
1026  else
1027  return clib_error_return (0,
1028  "duplicate configuration for PCI address %U",
1029  format_vlib_pci_addr, &pci_addr);
1030  }
1031 
1032  devconf->pci_addr.as_u32 = pci_addr.as_u32;
1033  devconf->hqos_enabled = 0;
1034 #if 0
1036 #endif
1037 
1038  if (!input)
1039  return 0;
1040 
1041  unformat_skip_white_space (input);
1042  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1043  {
1044  if (unformat (input, "num-rx-queues %u", &devconf->num_rx_queues))
1045  ;
1046  else if (unformat (input, "num-tx-queues %u", &devconf->num_tx_queues))
1047  ;
1048  else if (unformat (input, "num-rx-desc %u", &devconf->num_rx_desc))
1049  ;
1050  else if (unformat (input, "num-tx-desc %u", &devconf->num_tx_desc))
1051  ;
1052  else if (unformat (input, "name %s", &devconf->name))
1053  ;
1054  else if (unformat (input, "workers %U", unformat_bitmap_list,
1055  &devconf->workers))
1056  ;
1057  else
1058  if (unformat
1059  (input, "rss %U", unformat_vlib_cli_sub_input, &sub_input))
1060  {
1061  error = unformat_rss_fn (&sub_input, &devconf->rss_fn);
1062  if (error)
1063  break;
1064  }
1065  else if (unformat (input, "vlan-strip-offload off"))
1067  else if (unformat (input, "vlan-strip-offload on"))
1069  else
1070  if (unformat
1071  (input, "hqos %U", unformat_vlib_cli_sub_input, &sub_input))
1072  {
1073  devconf->hqos_enabled = 1;
1074  error = unformat_hqos (&sub_input, &devconf->hqos);
1075  if (error)
1076  break;
1077  }
1078  else if (unformat (input, "hqos"))
1079  {
1080  devconf->hqos_enabled = 1;
1081  }
1082  else
1083  {
1084  error = clib_error_return (0, "unknown input `%U'",
1085  format_unformat_error, input);
1086  break;
1087  }
1088  }
1089 
1090  if (error)
1091  return error;
1092 
1093  if (devconf->workers && devconf->num_rx_queues == 0)
1094  devconf->num_rx_queues = clib_bitmap_count_set_bits (devconf->workers);
1095  else if (devconf->workers &&
1096  clib_bitmap_count_set_bits (devconf->workers) !=
1097  devconf->num_rx_queues)
1098  error =
1099  clib_error_return (0,
1100  "%U: number of worker threads must be "
1101  "equal to number of rx queues", format_vlib_pci_addr,
1102  &pci_addr);
1103 
1104  return error;
1105 }
1106 
1107 static clib_error_t *
1109 {
1110  unformat_input_t input;
1111  u8 *line, *s = 0;
1112  int n, n_try;
1113 
1114  n = n_try = 4096;
1115  while (n == n_try)
1116  {
1117  uword len = vec_len (s);
1118  vec_resize (s, len + n_try);
1119 
1120  n = read (uf->file_descriptor, s + len, n_try);
1121  if (n < 0 && errno != EAGAIN)
1122  return clib_error_return_unix (0, "read");
1123  _vec_len (s) = len + (n < 0 ? 0 : n);
1124  }
1125 
1126  unformat_init_vector (&input, s);
1127 
1128  while (unformat_user (&input, unformat_line, &line))
1129  {
1130  dpdk_log_notice ("%v", line);
1131  vec_free (line);
1132  }
1133 
1134  unformat_free (&input);
1135  return 0;
1136 }
1137 
1138 static clib_error_t *
1140 {
1141  clib_error_t *error = 0;
1144  dpdk_device_config_t *devconf;
1145  vlib_pci_addr_t pci_addr;
1146  unformat_input_t sub_input;
1147  uword default_hugepage_sz, x;
1148  u8 *s, *tmp = 0;
1149  int ret, i;
1150  int num_whitelisted = 0;
1151  u8 no_pci = 0;
1152  u8 no_vmbus = 0;
1153  u8 file_prefix = 0;
1154  u8 *socket_mem = 0;
1155  u8 *huge_dir_path = 0;
1156  u32 vendor, device;
1157 
1158  huge_dir_path =
1159  format (0, "%s/hugepages%c", vlib_unix_get_runtime_dir (), 0);
1160 
1161  conf->device_config_index_by_pci_addr = hash_create (0, sizeof (uword));
1162 
1163  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1164  {
1165  /* Prime the pump */
1166  if (unformat (input, "no-hugetlb"))
1167  {
1168  vec_add1 (conf->eal_init_args, (u8 *) "--no-huge");
1169  }
1170 
1171  else if (unformat (input, "enable-tcp-udp-checksum"))
1172  conf->enable_tcp_udp_checksum = 1;
1173 
1174  else if (unformat (input, "no-tx-checksum-offload"))
1175  conf->no_tx_checksum_offload = 1;
1176 
1177  else if (unformat (input, "decimal-interface-names"))
1179 
1180  else if (unformat (input, "no-multi-seg"))
1181  conf->no_multi_seg = 1;
1182 
1183  else if (unformat (input, "dev default %U", unformat_vlib_cli_sub_input,
1184  &sub_input))
1185  {
1186  error =
1187  dpdk_device_config (conf, (vlib_pci_addr_t) (u32) ~ 1, &sub_input,
1188  1);
1189 
1190  if (error)
1191  return error;
1192  }
1193  else
1194  if (unformat
1195  (input, "dev %U %U", unformat_vlib_pci_addr, &pci_addr,
1196  unformat_vlib_cli_sub_input, &sub_input))
1197  {
1198  error = dpdk_device_config (conf, pci_addr, &sub_input, 0);
1199 
1200  if (error)
1201  return error;
1202 
1203  num_whitelisted++;
1204  }
1205  else if (unformat (input, "dev %U", unformat_vlib_pci_addr, &pci_addr))
1206  {
1207  error = dpdk_device_config (conf, pci_addr, 0, 0);
1208 
1209  if (error)
1210  return error;
1211 
1212  num_whitelisted++;
1213  }
1214  else if (unformat (input, "num-mem-channels %d", &conf->nchannels))
1215  conf->nchannels_set_manually = 0;
1216  else if (unformat (input, "num-crypto-mbufs %d",
1217  &conf->num_crypto_mbufs))
1218  ;
1219  else if (unformat (input, "uio-driver %s", &conf->uio_driver_name))
1220  ;
1221  else if (unformat (input, "socket-mem %s", &socket_mem))
1222  ;
1223  else if (unformat (input, "no-pci"))
1224  {
1225  no_pci = 1;
1226  tmp = format (0, "--no-pci%c", 0);
1227  vec_add1 (conf->eal_init_args, tmp);
1228  }
1229  else if (unformat (input, "blacklist %x:%x", &vendor, &device))
1230  {
1231  u32 blacklist_entry;
1232  if (vendor > 0xFFFF)
1233  return clib_error_return (0, "blacklist PCI vendor out of range");
1234  if (device > 0xFFFF)
1235  return clib_error_return (0, "blacklist PCI device out of range");
1236  blacklist_entry = (vendor << 16) | (device & 0xffff);
1238  blacklist_entry);
1239  }
1240  else if (unformat (input, "no-vmbus"))
1241  {
1242  no_vmbus = 1;
1243  tmp = format (0, "--no-vmbus%c", 0);
1244  vec_add1 (conf->eal_init_args, tmp);
1245  }
1246 
1247 #define _(a) \
1248  else if (unformat(input, #a)) \
1249  { \
1250  tmp = format (0, "--%s%c", #a, 0); \
1251  vec_add1 (conf->eal_init_args, tmp); \
1252  }
1254 #undef _
1255 #define _(a) \
1256  else if (unformat(input, #a " %s", &s)) \
1257  { \
1258  if (!strncmp(#a, "file-prefix", 11)) \
1259  file_prefix = 1; \
1260  tmp = format (0, "--%s%c", #a, 0); \
1261  vec_add1 (conf->eal_init_args, tmp); \
1262  vec_add1 (s, 0); \
1263  if (!strncmp(#a, "vdev", 4)) \
1264  if (strstr((char*)s, "af_packet")) \
1265  clib_warning ("af_packet obsoleted. Use CLI 'create host-interface'."); \
1266  vec_add1 (conf->eal_init_args, s); \
1267  }
1269 #undef _
1270 #define _(a,b) \
1271  else if (unformat(input, #a " %s", &s)) \
1272  { \
1273  tmp = format (0, "-%s%c", #b, 0); \
1274  vec_add1 (conf->eal_init_args, tmp); \
1275  vec_add1 (s, 0); \
1276  vec_add1 (conf->eal_init_args, s); \
1277  }
1279 #undef _
1280 #define _(a,b) \
1281  else if (unformat(input, #a " %s", &s)) \
1282  { \
1283  tmp = format (0, "-%s%c", #b, 0); \
1284  vec_add1 (conf->eal_init_args, tmp); \
1285  vec_add1 (s, 0); \
1286  vec_add1 (conf->eal_init_args, s); \
1287  conf->a##_set_manually = 1; \
1288  }
1290 #undef _
1291  else if (unformat (input, "default"))
1292  ;
1293 
1294  else if (unformat_skip_white_space (input))
1295  ;
1296  else
1297  {
1298  error = clib_error_return (0, "unknown input `%U'",
1299  format_unformat_error, input);
1300  goto done;
1301  }
1302  }
1303 
1304  if (!conf->uio_driver_name)
1305  conf->uio_driver_name = format (0, "auto%c", 0);
1306 
1307  default_hugepage_sz = clib_mem_get_default_hugepage_size ();
1308 
1309  /* *INDENT-OFF* */
1311  {
1312  clib_error_t *e;
1313  uword n_pages;
1314  /* preallocate at least 16MB of hugepages per socket,
1315  if more is needed it is up to consumer to preallocate more */
1316  n_pages = round_pow2 ((uword) 16 << 20, default_hugepage_sz);
1317  n_pages /= default_hugepage_sz;
1318 
1319  if ((e = clib_sysfs_prealloc_hugepages(x, 0, n_pages)))
1320  clib_error_report (e);
1321  }));
1322  /* *INDENT-ON* */
1323 
1324  if (!file_prefix)
1325  {
1326  tmp = format (0, "--file-prefix%c", 0);
1327  vec_add1 (conf->eal_init_args, tmp);
1328  tmp = format (0, "vpp%c", 0);
1329  vec_add1 (conf->eal_init_args, tmp);
1330  }
1331 
1332  if (error)
1333  return error;
1334 
1335  /* I'll bet that -c and -n must be the first and second args... */
1336  if (!conf->coremask_set_manually)
1337  {
1339  uword *coremask = 0;
1340  int i;
1341 
1342  /* main thread core */
1343  coremask = clib_bitmap_set (coremask, tm->main_lcore, 1);
1344 
1345  for (i = 0; i < vec_len (tm->registrations); i++)
1346  {
1347  tr = tm->registrations[i];
1348  coremask = clib_bitmap_or (coremask, tr->coremask);
1349  }
1350 
1351  vec_insert (conf->eal_init_args, 2, 1);
1352  conf->eal_init_args[1] = (u8 *) "-c";
1353  tmp = format (0, "%U%c", format_bitmap_hex, coremask, 0);
1354  conf->eal_init_args[2] = tmp;
1355  clib_bitmap_free (coremask);
1356  }
1357 
1358  if (!conf->nchannels_set_manually)
1359  {
1360  vec_insert (conf->eal_init_args, 2, 3);
1361  conf->eal_init_args[3] = (u8 *) "-n";
1362  tmp = format (0, "%d", conf->nchannels);
1363  conf->eal_init_args[4] = tmp;
1364  }
1365 
1366  if (no_pci == 0 && geteuid () == 0)
1367  dpdk_bind_devices_to_uio (conf);
1368 
1369  if (no_vmbus == 0 && geteuid () == 0)
1371 
1372 #define _(x) \
1373  if (devconf->x == 0 && conf->default_devconf.x > 0) \
1374  devconf->x = conf->default_devconf.x ;
1375 
1376  /* *INDENT-OFF* */
1377  pool_foreach (devconf, conf->dev_confs, ({
1378 
1379  /* default per-device config items */
1380  foreach_dpdk_device_config_item
1381 
1382  /* copy vlan_strip config from default device */
1383  if (devconf->vlan_strip_offload == 0 &&
1384  conf->default_devconf.vlan_strip_offload > 0)
1385  devconf->vlan_strip_offload =
1386  conf->default_devconf.vlan_strip_offload;
1387 
1388  /* add DPDK EAL whitelist/blacklist entry */
1389  if (num_whitelisted > 0 && devconf->is_blacklisted == 0)
1390  {
1391  tmp = format (0, "-w%c", 0);
1392  vec_add1 (conf->eal_init_args, tmp);
1393  tmp = format (0, "%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1394  vec_add1 (conf->eal_init_args, tmp);
1395  }
1396  else if (num_whitelisted == 0 && devconf->is_blacklisted != 0)
1397  {
1398  tmp = format (0, "-b%c", 0);
1399  vec_add1 (conf->eal_init_args, tmp);
1400  tmp = format (0, "%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1401  vec_add1 (conf->eal_init_args, tmp);
1402  }
1403  }));
1404  /* *INDENT-ON* */
1405 
1406 #undef _
1407 
1408  /* set master-lcore */
1409  tmp = format (0, "--master-lcore%c", 0);
1410  vec_add1 (conf->eal_init_args, tmp);
1411  tmp = format (0, "%u%c", tm->main_lcore, 0);
1412  vec_add1 (conf->eal_init_args, tmp);
1413 
1414 
1415  if (socket_mem)
1416  clib_warning ("socket-mem argument is deprecated");
1417 
1418  /* NULL terminate the "argv" vector, in case of stupidity */
1419  vec_add1 (conf->eal_init_args, 0);
1420  _vec_len (conf->eal_init_args) -= 1;
1421 
1422  /* Set up DPDK eal and packet mbuf pool early. */
1423 
1424  int log_fds[2] = { 0 };
1425  if (pipe (log_fds) == 0)
1426  {
1427  if (fcntl (log_fds[1], F_SETFL, O_NONBLOCK) == 0)
1428  {
1429  FILE *f = fdopen (log_fds[1], "a");
1430  if (f && rte_openlog_stream (f) == 0)
1431  {
1432  clib_file_t t = { 0 };
1434  t.file_descriptor = log_fds[0];
1435  t.description = format (0, "DPDK logging pipe");
1436  clib_file_add (&file_main, &t);
1437  }
1438  }
1439  else
1440  {
1441  close (log_fds[0]);
1442  close (log_fds[1]);
1443  }
1444  }
1445 
1446  vm = vlib_get_main ();
1447 
1448  /* make copy of args as rte_eal_init tends to mess up with arg array */
1449  for (i = 1; i < vec_len (conf->eal_init_args); i++)
1450  conf->eal_init_args_str = format (conf->eal_init_args_str, "%s ",
1451  conf->eal_init_args[i]);
1452 
1453  dpdk_log_warn ("EAL init args: %s", conf->eal_init_args_str);
1454  ret = rte_eal_init (vec_len (conf->eal_init_args),
1455  (char **) conf->eal_init_args);
1456 
1457  /* lazy umount hugepages */
1458  umount2 ((char *) huge_dir_path, MNT_DETACH);
1459  rmdir ((char *) huge_dir_path);
1460  vec_free (huge_dir_path);
1461 
1462  if (ret < 0)
1463  return clib_error_return (0, "rte_eal_init returned %d", ret);
1464 
1465  /* main thread 1st */
1466  if ((error = dpdk_buffer_pools_create (vm)))
1467  return error;
1468 
1469 done:
1470  return error;
1471 }
1472 
1474 
1475 void
1477 {
1478  vnet_main_t *vnm = vnet_get_main ();
1479  struct rte_eth_link prev_link = xd->link;
1480  u32 hw_flags = 0;
1481  u8 hw_flags_chg = 0;
1482 
1483  /* only update link state for PMD interfaces */
1484  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
1485  return;
1486 
1487  xd->time_last_link_update = now ? now : xd->time_last_link_update;
1488  clib_memset (&xd->link, 0, sizeof (xd->link));
1489  rte_eth_link_get_nowait (xd->port_id, &xd->link);
1490 
1491  if (LINK_STATE_ELOGS)
1492  {
1494  ELOG_TYPE_DECLARE (e) =
1495  {
1496  .format =
1497  "update-link-state: sw_if_index %d, admin_up %d,"
1498  "old link_state %d new link_state %d",.format_args = "i4i1i1i1",};
1499 
1500  struct
1501  {
1502  u32 sw_if_index;
1503  u8 admin_up;
1504  u8 old_link_state;
1505  u8 new_link_state;
1506  } *ed;
1507  ed = ELOG_DATA (&vm->elog_main, e);
1508  ed->sw_if_index = xd->sw_if_index;
1509  ed->admin_up = (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0;
1510  ed->old_link_state = (u8)
1512  ed->new_link_state = (u8) xd->link.link_status;
1513  }
1514 
1515  if ((xd->link.link_duplex != prev_link.link_duplex))
1516  {
1517  hw_flags_chg = 1;
1518  switch (xd->link.link_duplex)
1519  {
1520  case ETH_LINK_HALF_DUPLEX:
1522  break;
1523  case ETH_LINK_FULL_DUPLEX:
1525  break;
1526  default:
1527  break;
1528  }
1529  }
1530  if (xd->link.link_speed != prev_link.link_speed)
1532  xd->link.link_speed * 1000);
1533 
1534  if (xd->link.link_status != prev_link.link_status)
1535  {
1536  hw_flags_chg = 1;
1537 
1538  if (xd->link.link_status)
1539  hw_flags |= VNET_HW_INTERFACE_FLAG_LINK_UP;
1540  }
1541 
1542  if (hw_flags_chg)
1543  {
1544  if (LINK_STATE_ELOGS)
1545  {
1547 
1548  ELOG_TYPE_DECLARE (e) =
1549  {
1550  .format =
1551  "update-link-state: sw_if_index %d, new flags %d",.format_args
1552  = "i4i4",};
1553 
1554  struct
1555  {
1556  u32 sw_if_index;
1557  u32 flags;
1558  } *ed;
1559  ed = ELOG_DATA (&vm->elog_main, e);
1560  ed->sw_if_index = xd->sw_if_index;
1561  ed->flags = hw_flags;
1562  }
1563  vnet_hw_interface_set_flags (vnm, xd->hw_if_index, hw_flags);
1564  }
1565 }
1566 
1567 static uword
1569 {
1570  clib_error_t *error;
1571  dpdk_main_t *dm = &dpdk_main;
1572  dpdk_device_t *xd;
1574 
1575  error = dpdk_lib_init (dm);
1576 
1577  if (error)
1578  clib_error_report (error);
1579 
1580  tm->worker_thread_release = 1;
1581 
1582  f64 now = vlib_time_now (vm);
1583  vec_foreach (xd, dm->devices)
1584  {
1585  dpdk_update_link_state (xd, now);
1586  }
1587 
1588  while (1)
1589  {
1590  /*
1591  * check each time through the loop in case intervals are changed
1592  */
1593  f64 min_wait = dm->link_state_poll_interval < dm->stat_poll_interval ?
1595 
1596  vlib_process_wait_for_event_or_clock (vm, min_wait);
1597 
1598  if (dm->admin_up_down_in_progress)
1599  /* skip the poll if an admin up down is in progress (on any interface) */
1600  continue;
1601 
1602  vec_foreach (xd, dm->devices)
1603  {
1604  f64 now = vlib_time_now (vm);
1605  if ((now - xd->time_last_stats_update) >= dm->stat_poll_interval)
1606  dpdk_update_counters (xd, now);
1607  if ((now - xd->time_last_link_update) >= dm->link_state_poll_interval)
1608  dpdk_update_link_state (xd, now);
1609 
1610  }
1611  }
1612 
1613  return 0;
1614 }
1615 
1616 /* *INDENT-OFF* */
1618  .function = dpdk_process,
1619  .type = VLIB_NODE_TYPE_PROCESS,
1620  .name = "dpdk-process",
1621  .process_log2_n_stack_bytes = 17,
1622 };
1623 /* *INDENT-ON* */
1624 
1625 static clib_error_t *
1627 {
1628  dpdk_main_t *dm = &dpdk_main;
1629  clib_error_t *error = 0;
1630 
1631  /* verify that structs are cacheline aligned */
1632  STATIC_ASSERT (offsetof (dpdk_device_t, cacheline0) == 0,
1633  "Cache line marker must be 1st element in dpdk_device_t");
1634  STATIC_ASSERT (offsetof (dpdk_device_t, cacheline1) ==
1636  "Data in cache line 0 is bigger than cache line size");
1637  STATIC_ASSERT (offsetof (frame_queue_trace_t, cacheline0) == 0,
1638  "Cache line marker must be 1st element in frame_queue_trace_t");
1639  STATIC_ASSERT (RTE_CACHE_LINE_SIZE == 1 << CLIB_LOG2_CACHE_LINE_BYTES,
1640  "DPDK RTE CACHE LINE SIZE does not match with 1<<CLIB_LOG2_CACHE_LINE_BYTES");
1641 
1642  dpdk_cli_reference ();
1643 
1644  dm->vlib_main = vm;
1645  dm->vnet_main = vnet_get_main ();
1646  dm->conf = &dpdk_config_main;
1647 
1648  dm->conf->nchannels = 4;
1649  vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet");
1650  vec_add1 (dm->conf->eal_init_args, (u8 *) "--in-memory");
1651 
1652  /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */
1653  dm->buffer_flags_template = (VLIB_BUFFER_TOTAL_LENGTH_VALID |
1654  VLIB_BUFFER_EXT_HDR_VALID |
1655  VNET_BUFFER_F_L4_CHECKSUM_COMPUTED |
1656  VNET_BUFFER_F_L4_CHECKSUM_CORRECT);
1657 
1660 
1661  dm->log_default = vlib_log_register_class ("dpdk", 0);
1662 
1663  return error;
1664 }
1665 
1667 
1668 /*
1669  * fd.io coding-style-patch-verification: ON
1670  *
1671  * Local Variables:
1672  * eval: (c-set-style "gnu")
1673  * End:
1674  */
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:176
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
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
static void dpdk_bind_devices_to_uio(dpdk_config_main_t *conf)
Definition: init.c:828
f64 time_last_link_update
Definition: dpdk.h:245
vmrglw vmrglh hi
#define hash_set(h, key, value)
Definition: hash.h:255
#define VIRTIO_PCI_MODERN_DEVICEID_NET
Definition: pci_config.h:169
u32 flags
Definition: vhost_user.h:141
#define clib_min(x, y)
Definition: clib.h:295
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:673
u8 interface_name_format_decimal
Definition: dpdk.h:361
clib_error_t * vlib_vmbus_bind_to_uio(vlib_vmbus_addr_t *addr)
Definition: vmbus.c:213
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
Optimized string handling code, including c11-compliant "safe C library" variants.
vnet_device_class_t dpdk_device_class
unsigned long u64
Definition: types.h:89
u32 sw_if_index
Definition: dpdk.h:201
#define DPDK_DEVICE_VLAN_STRIP_OFF
Definition: dpdk.h:328
#define NULL
Definition: clib.h:58
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:258
#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:572
static uword * clib_bitmap_or(uword *ai, uword *bi)
Logical operator across two bitmaps.
static u32 dpdk_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
Definition: init.c:111
struct rte_pci_device * dpdk_get_pci_device(const struct rte_eth_dev_info *info)
Definition: common.c:249
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1476
u16 flags
Definition: dpdk.h:209
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define LINK_STATE_ELOGS
Definition: init.c:48
#define CLIB_LOG2_CACHE_LINE_BYTES
Definition: cache.h:50
u32 file_descriptor
Definition: file.h:54
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
dpdk_device_and_queue_t ** devices_by_hqos_cpu
Definition: dpdk.h:393
static void vlib_pci_free_device_info(vlib_pci_device_info_t *di)
Definition: pci.h:114
#define DPDK_NB_RX_DESC_VIRTIO
Definition: dpdk_priv.h:18
clib_error_t * errors
Definition: dpdk.h:257
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:560
int i
u32 per_interface_next_index
Definition: dpdk.h:204
u8 enable_tcp_udp_checksum
Definition: dpdk.h:347
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
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define DPDK_DEVICE_VLAN_STRIP_ON
Definition: dpdk.h:329
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define DPDK_NB_TX_DESC_DEFAULT
Definition: dpdk_priv.h:17
u32 supported_flow_actions
Definition: dpdk.h:230
#define foreach_eal_double_hyphen_predicate_arg
Definition: dpdk_priv.h:29
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:450
dpdk_device_config_hqos_t hqos
Definition: dpdk.h:336
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
vhost_vring_addr_t addr
Definition: vhost_user.h:147
u32 * blacklist_by_pci_vendor_and_device
Definition: dpdk.h:369
unsigned char u8
Definition: types.h:56
dpdk_config_main_t dpdk_config_main
Definition: init.c:46
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_file_function_t * read_function
Definition: file.h:67
#define ETHER_MAX_LEN
Maximum frame len, including CRC.
Definition: init.c:43
double f64
Definition: types.h:142
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_memcpy(d, s, n)
Definition: string.h:180
foreach_dpdk_device_config_item clib_bitmap_t * workers
Definition: dpdk.h:334
#define dpdk_log_warn(...)
Definition: dpdk.h:475
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
static clib_error_t * dpdk_log_read_ready(clib_file_t *uf)
Definition: init.c:1108
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
dpdk_portid_t port_id
Definition: dpdk.h:198
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:477
dpdk_device_config_t default_devconf
Definition: dpdk.h:364
f64 stat_poll_interval
Definition: dpdk.h:411
static char * vlib_unix_get_runtime_dir(void)
Definition: unix.h:139
static dpdk_port_type_t port_type_from_speed_capa(struct rte_eth_dev_info *dev_info)
Definition: init.c:53
vnet_hw_interface_flags_t flags
Definition: interface.h:505
#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
u16 rx_q_used
Definition: dpdk.h:222
vlib_pci_addr_t * vlib_pci_get_all_dev_addrs()
Definition: pci.c:1430
clib_file_main_t file_main
Definition: main.c:63
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:242
unsigned int u32
Definition: types.h:88
void dpdk_device_setup(dpdk_device_t *xd)
Definition: common.c:40
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:887
#define DPDK_NB_TX_DESC_VIRTIO
Definition: dpdk_priv.h:19
struct rte_eth_conf port_conf
Definition: dpdk.h:226
static clib_error_t * dpdk_init(vlib_main_t *vm)
Definition: init.c:1626
u32 max_supported_packet_bytes
Definition: interface.h:544
f64 time_last_stats_update
Definition: dpdk.h:250
vlib_pci_device_info_t * vlib_pci_get_device_info(vlib_main_t *vm, vlib_pci_addr_t *addr, clib_error_t **error)
Definition: pci.c:202
void dpdk_cli_reference(void)
Definition: cli.c:1746
struct rte_eth_txconf tx_conf
Definition: dpdk.h:227
u8 * description
Definition: file.h:70
#define hash_get(h, key)
Definition: hash.h:249
#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:514
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
Definition: vec.h:685
vlib_pci_addr_t pci_addr
Definition: dpdk.h:323
static clib_error_t * dpdk_config(vlib_main_t *vm, unformat_input_t *input)
Definition: init.c:1139
#define foreach_eal_double_hyphen_arg
Definition: dpdk_priv.h:45
#define ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags)
Definition: ethernet.h:147
u8 ** eal_init_args
Definition: dpdk.h:343
dpdk_per_thread_data_t * per_thread_data
Definition: dpdk.h:394
clib_error_t * vlib_pci_bind_to_uio(vlib_main_t *vm, vlib_pci_addr_t *addr, char *uio_drv_name)
Definition: pci.c:386
#define foreach_eal_single_hyphen_mandatory_arg
Definition: dpdk_priv.h:35
static dpdk_port_type_t port_type_from_link_speed(u32 link_speed)
Definition: init.c:81
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
#define clib_error_return_unix(e, args...)
Definition: error.h:102
#define foreach_dpdk_pmd
Definition: dpdk.h:61
vlib_buffer_t buffer_template
Definition: dpdk.h:385
unformat_function_t unformat_vlib_pci_addr
Definition: pci.h:323
#define ELOG_DATA(em, f)
Definition: elog.h:484
#define VIRTIO_PCI_LEGACY_DEVICEID_NET
Definition: pci_config.h:168
dpdk_port_type_t port_type
Definition: dpdk.h:251
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:182
signed char i8
Definition: types.h:45
u16 tx_q_used
Definition: dpdk.h:221
u16 nb_rx_desc
Definition: dpdk.h:223
uint16_t dpdk_portid_t
Definition: dpdk.h:119
#define dpdk_log_info(...)
Definition: dpdk.h:479
clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
Definition: sysfs.c:50
u32 hw_if_index
Definition: dpdk.h:200
u8 len
Definition: ip_types.api:90
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1037
u16 af_packet_instance_num
Definition: dpdk.h:242
#define foreach_eal_single_hyphen_arg
Definition: dpdk_priv.h:39
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u32 num_crypto_mbufs
Definition: dpdk.h:355
#define DPDK_NB_RX_DESC_DEFAULT
Definition: dpdk_priv.h:16
static int check_l3cache()
Definition: init.c:166
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
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:1004
dpdk_device_t * devices
Definition: dpdk.h:392
vlib_main_t * vm
Definition: buffer.c:312
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:77
u8 nchannels_set_manually
Definition: dpdk.h:352
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define dpdk_log_err(...)
Definition: dpdk.h:473
volatile u32 ** lockp
Definition: dpdk.h:192
dpdk_device_config_t * dev_confs
Definition: dpdk.h:365
#define clib_warning(format, args...)
Definition: error.h:59
dpdk_pmd_t pmd
Definition: dpdk.h:206
format_function_t format_dpdk_device_errors
Definition: dpdk.h:486
elog_main_t elog_main
Definition: main.h:172
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:141
u8 coremask_set_manually
Definition: dpdk.h:351
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:442
static void dpdk_device_lock_init(dpdk_device_t *xd)
Definition: init.c:143
format_function_t format_dpdk_rss_hf_name
Definition: dpdk.h:492
static void dpdk_bind_vmbus_devices_to_uio(dpdk_config_main_t *conf)
Definition: init.c:983
u8 * interface_name_suffix
Definition: dpdk.h:215
#define hash_create(elts, value_bytes)
Definition: hash.h:696
#define ASSERT(truth)
format_function_t format_dpdk_device_name
Definition: dpdk.h:484
int hqos_cpu_count
Definition: dpdk.h:407
void vnet_hw_interface_assign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, uword thread_index)
Definition: devices.c:139
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
vlib_log_class_t log_default
Definition: dpdk.h:422
static uword dpdk_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: init.c:1568
Bitmaps built as vectors of machine words.
#define clib_error_report(e)
Definition: error.h:113
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
uword clib_mem_get_default_hugepage_size(void)
Definition: mem.c:57
#define DPDK_LINK_POLL_INTERVAL
Definition: dpdk.h:263
dpdk_main_t dpdk_main
Definition: init.c:45
uword * thread_registrations_by_name
Definition: threads.h:289
dpdk_portid_t device_index
Definition: dpdk.h:195
struct rte_eth_link link
Definition: dpdk.h:244
u8 * name
Definition: dpdk.h:214
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
clib_error_t * dpdk_port_setup_hqos(dpdk_device_t *xd, dpdk_device_config_hqos_t *hqos)
Definition: hqos.c:247
dpdk_port_type_t
Definition: dpdk.h:97
static int dpdk_port_crc_strip_enabled(dpdk_device_t *xd)
Definition: init.c:156
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
Definition: bitmap.h:462
void dpdk_device_config_hqos_default(dpdk_device_config_hqos_t *hqos)
Definition: hqos.c:205
Definition: defs.h:47
#define DPDK_STATS_POLL_INTERVAL
Definition: dpdk.h:260
vlib_vmbus_addr_t * vlib_vmbus_get_all_dev_addrs()
Definition: vmbus.c:384
unformat_function_t unformat_line
Definition: format.h:280
static vlib_node_registration_t dpdk_process_node
(constructor) VLIB_REGISTER_NODE (dpdk_process_node)
Definition: init.c:1617
clib_error_t * dpdk_buffer_pools_create(vlib_main_t *vm)
Definition: buffer.c:427
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
Definition: cli.c:159
u8 admin_up_down_in_progress
Definition: dpdk.h:403
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:278
#define STATIC_ASSERT(truth,...)
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:501
u8 no_tx_checksum_offload
Definition: dpdk.h:348
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
static clib_error_t * dpdk_lib_init(dpdk_main_t *dm)
Definition: init.c:203
#define clib_error_free(e)
Definition: error.h:86
#define hash_get_mem(h, key)
Definition: hash.h:269
u32 buffer_flags_template
Definition: dpdk.h:397
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:161
#define vnet_buffer(b)
Definition: buffer.h:361
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
int hqos_cpu_first_index
Definition: dpdk.h:406
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
#define ETHERNET_MAX_PACKET_BYTES
Definition: ethernet.h:133
#define vec_foreach(var, vec)
Vector iterator.
i8 cpu_socket
Definition: dpdk.h:207
#define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags)
Definition: ethernet.h:142
uword * cpu_socket_bitmap
Definition: threads.h:324
Definition: file.h:51
u8 * uio_driver_name
Definition: dpdk.h:345
vlib_thread_registration_t ** registrations
Definition: threads.h:287
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vnet_main_t * vnet_main
Definition: dpdk.h:415
u16 nb_tx_desc
Definition: dpdk.h:211
clib_error_t * unformat_hqos(unformat_input_t *input, dpdk_device_config_hqos_t *hqos)
Definition: format.c:910
u16 device_class
Definition: pci.h:72
uword * device_config_index_by_pci_addr
Definition: dpdk.h:366
uword unformat_skip_white_space(unformat_input_t *input)
Definition: unformat.c:821
static uword vnet_hw_interface_is_link_up(vnet_main_t *vnm, u32 hw_if_index)
volatile u32 worker_thread_release
Definition: threads.h:330
#define dpdk_log_notice(...)
Definition: dpdk.h:477
static void vnet_hw_interface_set_link_speed(vnet_main_t *vnm, u32 hw_if_index, u32 link_speed)
static void vnet_hw_interface_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: devices.h:79
vnet_device_main_t vnet_device_main
Definition: devices.c:22
format_function_t format_vlib_pci_addr
Definition: pci.h:324
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
f64 link_state_poll_interval
Definition: dpdk.h:410
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
dpdk_config_main_t * conf
Definition: dpdk.h:416
vlib_main_t * vlib_main
Definition: dpdk.h:414