FD.io VPP  v21.10.1-2-g0a485f517
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>
26 #include <dpdk/buffer.h>
27 #include <dpdk/device/dpdk.h>
29 #include <vlib/pci/pci.h>
30 #include <vlib/vmbus/vmbus.h>
31 
32 #include <rte_ring.h>
33 #include <rte_vect.h>
34 
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <sys/stat.h>
39 #include <sys/mount.h>
40 #include <string.h>
41 #include <fcntl.h>
42 #include <dirent.h>
43 
44 #include <dpdk/device/dpdk_priv.h>
45 
46 #define ETHER_MAX_LEN 1518 /**< Maximum frame len, including CRC. */
47 
50 
51 #define LINK_STATE_ELOGS 0
52 
53 /* Port configuration, mildly modified Intel app values */
54 
55 static dpdk_port_type_t
56 port_type_from_speed_capa (struct rte_eth_dev_info *dev_info)
57 {
58 
59  if (dev_info->speed_capa & ETH_LINK_SPEED_100G)
61  else if (dev_info->speed_capa & ETH_LINK_SPEED_56G)
63  else if (dev_info->speed_capa & ETH_LINK_SPEED_50G)
65  else if (dev_info->speed_capa & ETH_LINK_SPEED_40G)
67  else if (dev_info->speed_capa & ETH_LINK_SPEED_25G)
69  else if (dev_info->speed_capa & ETH_LINK_SPEED_20G)
71  else if (dev_info->speed_capa & ETH_LINK_SPEED_10G)
73  else if (dev_info->speed_capa & ETH_LINK_SPEED_5G)
75  else if (dev_info->speed_capa & ETH_LINK_SPEED_2_5G)
77  else if (dev_info->speed_capa & ETH_LINK_SPEED_1G)
79 
81 }
82 
83 static dpdk_port_type_t
85 {
86  switch (link_speed)
87  {
88  case ETH_SPEED_NUM_1G:
90  case ETH_SPEED_NUM_2_5G:
92  case ETH_SPEED_NUM_5G:
94  case ETH_SPEED_NUM_10G:
96  case ETH_SPEED_NUM_20G:
98  case ETH_SPEED_NUM_25G:
100  case ETH_SPEED_NUM_40G:
102  case ETH_SPEED_NUM_50G:
104  case ETH_SPEED_NUM_56G:
106  case ETH_SPEED_NUM_100G:
108  default:
110  }
111 }
112 
113 static u32
115 {
116  dpdk_main_t *dm = &dpdk_main;
117  dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance);
118  u32 old = (xd->flags & DPDK_DEVICE_FLAG_PROMISC) != 0;
119 
120  switch (flags)
121  {
123  /* set to L3/non-promisc mode */
124  xd->flags &= ~DPDK_DEVICE_FLAG_PROMISC;
125  break;
127  xd->flags |= DPDK_DEVICE_FLAG_PROMISC;
128  break;
130  xd->port_conf.rxmode.max_rx_pkt_len = hi->max_packet_bytes;
131  dpdk_device_setup (xd);
132  return 0;
133  default:
134  return ~0;
135  }
136 
137  if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
138  {
139  if (xd->flags & DPDK_DEVICE_FLAG_PROMISC)
140  rte_eth_promiscuous_enable (xd->port_id);
141  else
142  rte_eth_promiscuous_disable (xd->port_id);
143  }
144 
145  return old;
146 }
147 
148 static int
150 {
151  return !(xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC);
152 }
153 
154 /* The function check_l3cache helps check if Level 3 cache exists or not on current CPUs
155  return value 1: exist.
156  return value 0: not exist.
157 */
158 static int
160 {
161 
162  struct dirent *dp;
163  clib_error_t *err;
164  const char *sys_cache_dir = "/sys/devices/system/cpu/cpu0/cache";
165  DIR *dir_cache = opendir (sys_cache_dir);
166 
167  if (dir_cache == NULL)
168  return -1;
169 
170  while ((dp = readdir (dir_cache)) != NULL)
171  {
172  if (dp->d_type == DT_DIR)
173  {
174  u8 *p = NULL;
175  int level_cache = -1;
176 
177  p = format (p, "%s/%s/%s%c", sys_cache_dir, dp->d_name, "level", 0);
178  if ((err = clib_sysfs_read ((char *) p, "%d", &level_cache)))
179  clib_error_free (err);
180 
181  if (level_cache == 3)
182  {
183  closedir (dir_cache);
184  return 1;
185  }
186  }
187  }
188 
189  if (dir_cache != NULL)
190  closedir (dir_cache);
191 
192  return 0;
193 }
194 
195 static void
197 {
198  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
199  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
200  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD |
201  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
202 }
203 
204 static clib_error_t *
206 {
207  u32 nports;
208  u32 mtu, max_rx_frame;
209  int i;
216  dpdk_device_t *xd;
217  vlib_pci_addr_t last_pci_addr;
218  u32 last_pci_addr_port = 0;
219  u8 af_packet_instance_num = 0;
220  last_pci_addr.as_u32 = ~0;
221 
222  nports = rte_eth_dev_count_avail ();
223 
224  if (nports < 1)
225  {
226  dpdk_log_notice ("DPDK drivers found no Ethernet devices...");
227  }
228 
229  if (CLIB_DEBUG > 0)
230  dpdk_log_notice ("DPDK drivers found %d ports...", nports);
231 
232  if (dm->conf->enable_tcp_udp_checksum)
233  dm->buffer_flags_template &= ~(VNET_BUFFER_F_L4_CHECKSUM_CORRECT
234  | VNET_BUFFER_F_L4_CHECKSUM_COMPUTED);
235 
236  /* vlib_buffer_t template */
239  for (i = 0; i < tm->n_vlib_mains; i++)
240  {
242  clib_memset (&ptd->buffer_template, 0, sizeof (vlib_buffer_t));
244  vnet_buffer (&ptd->buffer_template)->sw_if_index[VLIB_TX] = (u32) ~ 0;
245  }
246 
247  /* *INDENT-OFF* */
248  RTE_ETH_FOREACH_DEV(i)
249  {
250  u8 addr[6];
251  int vlan_off;
252  struct rte_eth_dev_info dev_info;
253  struct rte_pci_device *pci_dev;
254  struct rte_vmbus_device *vmbus_dev;
255  dpdk_portid_t next_port_id;
256  dpdk_device_config_t *devconf = 0;
257  vlib_pci_addr_t pci_addr;
258  vlib_vmbus_addr_t vmbus_addr;
259  uword *p = 0;
260 
261  if (!rte_eth_dev_is_valid_port(i))
262  continue;
263 
264  rte_eth_dev_info_get (i, &dev_info);
265 
266  if (dev_info.device == 0)
267  {
268  dpdk_log_notice ("DPDK bug: missing device info. Skipping %s device",
269  dev_info.driver_name);
270  continue;
271  }
272 
273  pci_dev = dpdk_get_pci_device (&dev_info);
274 
275  if (pci_dev)
276  {
277  pci_addr.domain = pci_dev->addr.domain;
278  pci_addr.bus = pci_dev->addr.bus;
279  pci_addr.slot = pci_dev->addr.devid;
280  pci_addr.function = pci_dev->addr.function;
282  pci_addr.as_u32);
283  }
284 
285  vmbus_dev = dpdk_get_vmbus_device (&dev_info);
286 
287  if (vmbus_dev)
288  {
289  unformat_input_t input_vmbus;
290 
291  unformat_init_vector (&input_vmbus, (u8 *) dev_info.device->name);
292  if (unformat (&input_vmbus, "%U", unformat_vlib_vmbus_addr,
293  &vmbus_addr))
294  {
296  &vmbus_addr);
297  }
298  }
299 
300  if (p)
301  {
302  devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
303  /* If device is blacklisted, we should skip it */
304  if (devconf->is_blacklisted)
305  {
306  continue;
307  }
308  }
309  else
310  devconf = &dm->conf->default_devconf;
311 
312  /* Create vnet interface */
316  xd->cpu_socket = (i8) rte_eth_dev_socket_id (i);
317  if (p)
318  {
319  xd->name = devconf->name;
320  }
321 
322  /* Handle representor devices that share the same PCI ID */
323  if (dev_info.switch_info.domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID)
324  {
325  if (dev_info.switch_info.port_id != (uint16_t)-1)
326  xd->interface_name_suffix = format (0, "%d", dev_info.switch_info.port_id);
327  }
328  /* Handle interface naming for devices with multiple ports sharing same PCI ID */
329  else if (pci_dev &&
330  ((next_port_id = rte_eth_find_next (i + 1)) != RTE_MAX_ETHPORTS))
331  {
332  struct rte_eth_dev_info di = { 0 };
333  struct rte_pci_device *next_pci_dev;
334  rte_eth_dev_info_get (next_port_id, &di);
335  next_pci_dev = di.device ? RTE_DEV_TO_PCI (di.device) : 0;
336  if (next_pci_dev &&
337  pci_addr.as_u32 != last_pci_addr.as_u32 &&
338  memcmp (&pci_dev->addr, &next_pci_dev->addr,
339  sizeof (struct rte_pci_addr)) == 0)
340  {
341  xd->interface_name_suffix = format (0, "0");
342  last_pci_addr.as_u32 = pci_addr.as_u32;
343  last_pci_addr_port = i;
344  }
345  else if (pci_addr.as_u32 == last_pci_addr.as_u32)
346  {
348  format (0, "%u", i - last_pci_addr_port);
349  }
350  else
351  {
352  last_pci_addr.as_u32 = ~0;
353  }
354  }
355  else
356  last_pci_addr.as_u32 = ~0;
357 
358  clib_memcpy (&xd->tx_conf, &dev_info.default_txconf,
359  sizeof (struct rte_eth_txconf));
360 
361  if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
362  {
363  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_IPV4_CKSUM;
364  xd->flags |= DPDK_DEVICE_FLAG_RX_IP4_CKSUM;
365  }
366 
367  if (dm->conf->enable_tcp_udp_checksum)
368  {
369  if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM)
370  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_UDP_CKSUM;
371  if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)
372  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_TCP_CKSUM;
373  if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM)
374  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
375 
377  {
378  if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)
379  xd->port_conf.txmode.offloads |=
380  DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
381  if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
382  xd->port_conf.txmode.offloads |=
383  DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
384  }
385  }
386 
387  if (dm->conf->enable_lro)
388  {
389  if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_LRO)
390  {
391  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_TCP_LRO;
392  if (devconf->max_lro_pkt_size)
393  xd->port_conf.rxmode.max_lro_pkt_size =
394  devconf->max_lro_pkt_size;
395  else
396  xd->port_conf.rxmode.max_lro_pkt_size =
398  }
399  }
400  if (dm->conf->no_multi_seg)
401  {
402  xd->port_conf.txmode.offloads &= ~DEV_TX_OFFLOAD_MULTI_SEGS;
403  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
404  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER;
405  }
406  else
407  {
408  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
409  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
410  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SCATTER;
411  xd->flags |= DPDK_DEVICE_FLAG_MAYBE_MULTISEG;
412  }
413 
414  xd->tx_q_used = clib_min (dev_info.max_tx_queues, tm->n_vlib_mains);
415 
416  if (devconf->num_tx_queues > 0
417  && devconf->num_tx_queues < xd->tx_q_used)
418  xd->tx_q_used = clib_min (xd->tx_q_used, devconf->num_tx_queues);
419 
420  if (devconf->num_rx_queues > 1
421  && dev_info.max_rx_queues >= devconf->num_rx_queues)
422  {
423  xd->rx_q_used = devconf->num_rx_queues;
424  xd->port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
425  if (devconf->rss_fn == 0)
426  xd->port_conf.rx_adv_conf.rss_conf.rss_hf =
427  ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
428  else
429  {
430  u64 unsupported_bits;
431  xd->port_conf.rx_adv_conf.rss_conf.rss_hf = devconf->rss_fn;
432  unsupported_bits = xd->port_conf.rx_adv_conf.rss_conf.rss_hf;
433  unsupported_bits &= ~dev_info.flow_type_rss_offloads;
434  if (unsupported_bits)
435  dpdk_log_warn ("Unsupported RSS hash functions: %U",
436  format_dpdk_rss_hf_name, unsupported_bits);
437  }
438  xd->port_conf.rx_adv_conf.rss_conf.rss_hf &=
439  dev_info.flow_type_rss_offloads;
440  }
441  else
442  xd->rx_q_used = 1;
443 
446 
447  xd->flags |= DPDK_DEVICE_FLAG_PMD;
448 
449  /* workaround for drivers not setting driver_name */
450  if ((!dev_info.driver_name) && (pci_dev))
451  dev_info.driver_name = pci_dev->driver->driver.name;
452 
453  ASSERT (dev_info.driver_name);
454 
455  if (!xd->pmd)
456  {
457 
458 
459 #define _(s,f) else if (dev_info.driver_name && \
460  !strcmp(dev_info.driver_name, s)) \
461  xd->pmd = VNET_DPDK_PMD_##f;
462  if (0)
463  ;
465 #undef _
466  else
468 
472 
473  switch (xd->pmd)
474  {
475  /* Drivers with valid speed_capa set */
476  case VNET_DPDK_PMD_I40E:
477  xd->flags |= DPDK_DEVICE_FLAG_INT_UNMASKABLE;
478  case VNET_DPDK_PMD_E1000EM:
479  case VNET_DPDK_PMD_IGB:
480  case VNET_DPDK_PMD_IGC:
481  case VNET_DPDK_PMD_IXGBE:
482  case VNET_DPDK_PMD_ICE:
483  xd->port_type = port_type_from_speed_capa (&dev_info);
484  xd->supported_flow_actions = VNET_FLOW_ACTION_MARK |
485  VNET_FLOW_ACTION_REDIRECT_TO_NODE |
486  VNET_FLOW_ACTION_REDIRECT_TO_QUEUE |
487  VNET_FLOW_ACTION_BUFFER_ADVANCE |
488  VNET_FLOW_ACTION_COUNT | VNET_FLOW_ACTION_DROP |
489  VNET_FLOW_ACTION_RSS;
490 
491  if (dm->conf->no_tx_checksum_offload == 0)
492  {
493  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
494  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
495  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD |
496  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
497  }
498 
499  xd->port_conf.intr_conf.rxq = 1;
500  break;
501  case VNET_DPDK_PMD_MLX5:
502  if (dm->conf->no_tx_checksum_offload == 0)
503  {
504  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
505  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
506  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD |
507  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
508  }
509  xd->port_type = port_type_from_speed_capa (&dev_info);
510  break;
511  case VNET_DPDK_PMD_CXGBE:
512  case VNET_DPDK_PMD_MLX4:
513  case VNET_DPDK_PMD_QEDE:
514  case VNET_DPDK_PMD_BNXT:
515  xd->port_type = port_type_from_speed_capa (&dev_info);
516  break;
517 
518  /* SR-IOV VFs */
519  case VNET_DPDK_PMD_I40EVF:
520  xd->flags |= DPDK_DEVICE_FLAG_INT_UNMASKABLE;
521  case VNET_DPDK_PMD_IGBVF:
522  case VNET_DPDK_PMD_IXGBEVF:
524  if (dm->conf->no_tx_checksum_offload == 0)
525  {
526  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
527  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
528  xd->flags |=
529  DPDK_DEVICE_FLAG_TX_OFFLOAD |
530  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
531  }
532  /* DPDK bug in multiqueue... */
533  /* xd->port_conf.intr_conf.rxq = 1; */
534  break;
535 
536  /* iAVF */
537  case VNET_DPDK_PMD_IAVF:
538  xd->flags |= DPDK_DEVICE_FLAG_INT_UNMASKABLE;
541  VNET_FLOW_ACTION_MARK | VNET_FLOW_ACTION_REDIRECT_TO_NODE |
542  VNET_FLOW_ACTION_REDIRECT_TO_QUEUE |
543  VNET_FLOW_ACTION_BUFFER_ADVANCE | VNET_FLOW_ACTION_COUNT |
544  VNET_FLOW_ACTION_DROP | VNET_FLOW_ACTION_RSS;
545 
546  if (dm->conf->no_tx_checksum_offload == 0)
547  {
548  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
549  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
550  xd->flags |=
551  DPDK_DEVICE_FLAG_TX_OFFLOAD |
552  DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
553  }
554  /* DPDK bug in multiqueue... */
555  /* xd->port_conf.intr_conf.rxq = 1; */
556  break;
557 
558  case VNET_DPDK_PMD_THUNDERX:
560 
561  if (dm->conf->no_tx_checksum_offload == 0)
562  {
563  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
564  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
565  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD;
566  }
567  break;
568 
569  case VNET_DPDK_PMD_ENA:
571  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER;
572  xd->port_conf.intr_conf.rxq = 1;
573  if (dm->conf->no_tx_checksum_offload == 0)
574  {
575  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
576  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
577  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
578  xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD;
579  }
580  break;
581 
582  case VNET_DPDK_PMD_DPAA2:
584  break;
585 
586  /* Cisco VIC */
587  case VNET_DPDK_PMD_ENIC:
588  {
589  struct rte_eth_link l;
590  rte_eth_link_get_nowait (i, &l);
591  xd->port_type = port_type_from_link_speed (l.link_speed);
592  if (dm->conf->enable_tcp_udp_checksum)
594  }
595  break;
596 
597  /* Intel Red Rock Canyon */
598  case VNET_DPDK_PMD_FM10K:
600  break;
601 
602  /* virtio */
603  case VNET_DPDK_PMD_VIRTIO:
604  xd->port_conf.rxmode.mq_mode = ETH_MQ_RX_NONE;
608  /*
609  * Enable use of RX interrupts if supported.
610  *
611  * There is no device flag or capability for this, so
612  * use the same check that the virtio driver does.
613  */
614  if (pci_dev && rte_intr_cap_multiple (&pci_dev->intr_handle))
615  xd->port_conf.intr_conf.rxq = 1;
616  break;
617 
618  /* vmxnet3 */
619  case VNET_DPDK_PMD_VMXNET3:
621  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
622  break;
623 
624  case VNET_DPDK_PMD_AF_PACKET:
626  xd->af_packet_instance_num = af_packet_instance_num++;
627  break;
628 
629  case VNET_DPDK_PMD_VIRTIO_USER:
631  break;
632 
633  case VNET_DPDK_PMD_VHOST_ETHER:
635  break;
636 
637  case VNET_DPDK_PMD_LIOVF_ETHER:
639  break;
640 
641  case VNET_DPDK_PMD_FAILSAFE:
643  xd->port_conf.intr_conf.lsc = 1;
644  break;
645 
646  case VNET_DPDK_PMD_NETVSC:
647  {
648  struct rte_eth_link l;
649  rte_eth_link_get_nowait (i, &l);
651  }
652  break;
653 
654  default:
656  }
657 
658  if (devconf->num_rx_desc)
659  xd->nb_rx_desc = devconf->num_rx_desc;
660  else {
661 
662  /* If num_rx_desc is not specified by VPP user, the current CPU is working
663  with 2M page and has no L3 cache, default num_rx_desc is changed to 512
664  from original 1024 to help reduce TLB misses.
665  */
666  if ((clib_mem_get_default_hugepage_size () == 2 << 20)
667  && check_l3cache() == 0)
668  xd->nb_rx_desc = 512;
669  }
670 
671  if (devconf->num_tx_desc)
672  xd->nb_tx_desc = devconf->num_tx_desc;
673  else {
674 
675  /* If num_tx_desc is not specified by VPP user, the current CPU is working
676  with 2M page and has no L3 cache, default num_tx_desc is changed to 512
677  from original 1024 to help reduce TLB misses.
678  */
679  if ((clib_mem_get_default_hugepage_size () == 2 << 20)
680  && check_l3cache() == 0)
681  xd->nb_tx_desc = 512;
682  }
683  }
684 
685  if (xd->pmd == VNET_DPDK_PMD_AF_PACKET)
686  {
687  f64 now = vlib_time_now (vm);
688  u32 rnd;
689  rnd = (u32) (now * 1e6);
690  rnd = random_u32 (&rnd);
691  clib_memcpy (addr + 2, &rnd, sizeof (rnd));
692  addr[0] = 2;
693  addr[1] = 0xfe;
694  }
695  else
696  rte_eth_macaddr_get (i, (void *) addr);
697 
698  xd->port_id = i;
699  xd->device_index = xd - dm->devices;
700  xd->per_interface_next_index = ~0;
701 
702  /* assign interface to input thread */
703  int q;
704 
706  (dm->vnet_main, dpdk_device_class.index, xd->device_index,
707  /* ethernet address */ addr,
709  if (error)
710  return error;
711 
712  /*
713  * Ensure default mtu is not > the mtu read from the hardware.
714  * Otherwise rte_eth_dev_configure() will fail and the port will
715  * not be available.
716  * Calculate max_frame_size and mtu supported by NIC
717  */
718  if (ETHERNET_MAX_PACKET_BYTES > dev_info.max_rx_pktlen)
719  {
720  /*
721  * This device does not support the platforms's max frame
722  * size. Use it's advertised mru instead.
723  */
724  max_rx_frame = dev_info.max_rx_pktlen;
725  mtu = dev_info.max_rx_pktlen - sizeof (ethernet_header_t);
726  }
727  else
728  {
729  /* VPP treats MTU and max_rx_pktlen both equal to
730  * ETHERNET_MAX_PACKET_BYTES, if dev_info.max_rx_pktlen >=
731  * ETHERNET_MAX_PACKET_BYTES + sizeof(ethernet_header_t)
732  */
733  if (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES +
734  sizeof (ethernet_header_t)))
735  {
737  max_rx_frame = ETHERNET_MAX_PACKET_BYTES;
738 
739  /*
740  * Some platforms do not account for Ethernet FCS (4 bytes) in
741  * MTU calculations. To interop with them increase mru but only
742  * if the device's settings can support it.
743  */
744  if (dpdk_port_crc_strip_enabled (xd) &&
745  (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES +
746  sizeof (ethernet_header_t) +
747  4)))
748  {
749  max_rx_frame += 4;
750  }
751  }
752  else
753  {
754  max_rx_frame = ETHERNET_MAX_PACKET_BYTES;
756 
757  if (dpdk_port_crc_strip_enabled (xd) &&
758  (dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES + 4)))
759  {
760  max_rx_frame += 4;
761  }
762  }
763  }
764 
765  if (xd->pmd == VNET_DPDK_PMD_FAILSAFE)
766  {
767  /* failsafe device numerables are reported with active device only,
768  * need to query the mtu for current device setup to overwrite
769  * reported value.
770  */
771  uint16_t dev_mtu;
772  if (!rte_eth_dev_get_mtu (i, &dev_mtu))
773  {
774  mtu = dev_mtu;
775  max_rx_frame = mtu + sizeof (ethernet_header_t);
776 
778  {
779  max_rx_frame += 4;
780  }
781  }
782  }
783 
784  /*Set port rxmode config */
785  xd->port_conf.rxmode.max_rx_pkt_len = max_rx_frame;
786 
788  xd->sw_if_index = sw->sw_if_index;
790  dpdk_input_node.index);
791 
792  if (devconf->workers)
793  {
794  int i;
795  q = 0;
796  clib_bitmap_foreach (i, devconf->workers) {
799  dm->vnet_main, xd->hw_if_index, q++,
801  }
802  }
803  else
804  for (q = 0; q < xd->rx_q_used; q++)
805  {
809  }
810 
812 
813  /*Get vnet hardware interface */
815 
816  /*Override default max_packet_bytes and max_supported_bytes set in
817  * ethernet_register_interface() above*/
818  if (hi)
819  {
820  hi->max_packet_bytes = mtu;
821  hi->max_supported_packet_bytes = max_rx_frame;
822  hi->numa_node = xd->cpu_socket;
823 
824  /* Indicate ability to support L3 DMAC filtering and
825  * initialize interface to L3 non-promisc mode */
829  }
830 
831  if (dm->conf->no_tx_checksum_offload == 0)
832  if (xd->flags & DPDK_DEVICE_FLAG_TX_OFFLOAD && hi != NULL)
833  {
838  {
841  }
842  }
843  if (devconf->tso == DPDK_DEVICE_TSO_ON && hi != NULL)
844  {
845  /*tcp_udp checksum must be enabled*/
846  if ((dm->conf->enable_tcp_udp_checksum) &&
848  {
850  xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_TSO;
851 
853  (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
854  {
855  xd->port_conf.txmode.offloads |=
856  DEV_TX_OFFLOAD_VXLAN_TNL_TSO;
858  }
859  }
860  else
861  clib_warning ("%s: TCP/UDP checksum offload must be enabled",
862  hi->name);
863  }
864 
865  dpdk_device_setup (xd);
866 
867  /* rss queues should be configured after dpdk_device_setup() */
868  if ((hi != NULL) && (devconf->rss_queues != NULL))
869  {
871  (vnet_get_main (), hi, devconf->rss_queues))
872  {
873  clib_warning ("%s: Failed to set rss queues", hi->name);
874  }
875  }
876 
877  if (vec_len (xd->errors))
878  dpdk_log_err ("setup failed for device %U. Errors:\n %U",
881 
882  /*
883  * A note on Cisco VIC (PMD_ENIC) and VLAN:
884  *
885  * With Cisco VIC vNIC, every ingress packet is tagged. On a
886  * trunk vNIC (C series "standalone" server), packets on no VLAN
887  * are tagged with vlan 0. On an access vNIC (standalone or B
888  * series "blade" server), packets on the default/native VLAN
889  * are tagged with that vNIC's VLAN. VPP expects these packets
890  * to be untagged, and previously enabled VLAN strip on VIC by
891  * default. But it also broke vlan sub-interfaces.
892  *
893  * The VIC adapter has "untag default vlan" ingress VLAN rewrite
894  * mode, which removes tags from these packets. VPP now includes
895  * a local patch for the enic driver to use this untag mode, so
896  * enabling vlan stripping is no longer needed. In future, the
897  * driver + dpdk will have an API to set the mode after
898  * rte_eal_init. Then, this note and local patch will be
899  * removed.
900  */
901 
902  /*
903  * VLAN stripping: default to VLAN strip disabled, unless specified
904  * otherwise in the startup config.
905  */
906 
907  vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
909  {
910  vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
911  if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
912  dpdk_log_info ("VLAN strip enabled for interface\n");
913  else
914  dpdk_log_warn ("VLAN strip cannot be supported by interface\n");
915  xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
916  }
917  else
918  {
919  if (vlan_off & ETH_VLAN_STRIP_OFFLOAD)
920  {
921  vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD;
922  if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
923  dpdk_log_warn ("set VLAN offload failed\n");
924  }
925  xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
926  }
927 
928  if (hi)
929  hi->max_packet_bytes = xd->port_conf.rxmode.max_rx_pkt_len
930  - sizeof (ethernet_header_t);
931  else
932  dpdk_log_warn ("hi NULL");
933 
934  if (dm->conf->no_multi_seg)
935  mtu = mtu > ETHER_MAX_LEN ? ETHER_MAX_LEN : mtu;
936 
937  rte_eth_dev_set_mtu (xd->port_id, mtu);
938 }
939 
940  /* *INDENT-ON* */
941 
942  return 0;
943 }
944 
945 static void
947 {
950  u8 *pci_addr = 0;
951  int num_whitelisted = vec_len (conf->dev_confs);
952  vlib_pci_device_info_t *d = 0;
953  vlib_pci_addr_t *addr = 0, *addrs;
954  int i;
955 
956  addrs = vlib_pci_get_all_dev_addrs ();
957  /* *INDENT-OFF* */
958  vec_foreach (addr, addrs)
959  {
960  dpdk_device_config_t * devconf = 0;
961  vec_reset_length (pci_addr);
962  pci_addr = format (pci_addr, "%U%c", format_vlib_pci_addr, addr, 0);
963  if (d)
964  {
966  d = 0;
967  }
969  if (error)
970  {
973  continue;
974  }
975 
977  continue;
978 
979  if (num_whitelisted)
980  {
981  uword * p = hash_get (conf->device_config_index_by_pci_addr, addr->as_u32);
982 
983  if (!p)
984  {
985  skipped_pci:
986  continue;
987  }
988 
989  devconf = pool_elt_at_index (conf->dev_confs, p[0]);
990  }
991 
992  /* Enforce Device blacklist by vendor and device */
993  for (i = 0; i < vec_len (conf->blacklist_by_pci_vendor_and_device); i++)
994  {
995  u16 vendor, device;
996  vendor = (u16)(conf->blacklist_by_pci_vendor_and_device[i] >> 16);
997  device = (u16)(conf->blacklist_by_pci_vendor_and_device[i] & 0xFFFF);
998  if (d->vendor_id == vendor && d->device_id == device)
999  {
1000  /*
1001  * Expected case: device isn't whitelisted,
1002  * so blacklist it...
1003  */
1004  if (devconf == 0)
1005  {
1006  /* Device is blacklisted */
1007  pool_get (conf->dev_confs, devconf);
1009  devconf - conf->dev_confs);
1010  devconf->pci_addr.as_u32 = addr->as_u32;
1011  devconf->dev_addr_type = VNET_DEV_ADDR_PCI;
1012  devconf->is_blacklisted = 1;
1013  goto skipped_pci;
1014  }
1015  else /* explicitly whitelisted, ignore the device blacklist */
1016  break;
1017  }
1018  }
1019 
1020  /* virtio */
1021  if (d->vendor_id == 0x1af4 &&
1024  ;
1025  /* vmxnet3 */
1026  else if (d->vendor_id == 0x15ad && d->device_id == 0x07b0)
1027  {
1028  /*
1029  * For vmxnet3 PCI, unless it is explicitly specified in the whitelist,
1030  * the default is to put it in the blacklist.
1031  */
1032  if (devconf == 0)
1033  {
1034  pool_get (conf->dev_confs, devconf);
1036  devconf - conf->dev_confs);
1037  devconf->pci_addr.as_u32 = addr->as_u32;
1038  devconf->is_blacklisted = 1;
1039  }
1040  }
1041  /* all Intel network devices */
1042  else if (d->vendor_id == 0x8086 && d->device_class == PCI_CLASS_NETWORK_ETHERNET)
1043  ;
1044  /* all Intel QAT devices VFs */
1045  else if (d->vendor_id == 0x8086 && d->device_class == PCI_CLASS_PROCESSOR_CO &&
1046  (d->device_id == 0x0443 || d->device_id == 0x18a1 || d->device_id == 0x19e3 ||
1047  d->device_id == 0x37c9 || d->device_id == 0x6f55))
1048  ;
1049  /* Cisco VIC */
1050  else if (d->vendor_id == 0x1137 &&
1051  (d->device_id == 0x0043 || d->device_id == 0x0071))
1052  ;
1053  /* Chelsio T4/T5 */
1054  else if (d->vendor_id == 0x1425 && (d->device_id & 0xe000) == 0x4000)
1055  ;
1056  /* Amazon Elastic Network Adapter */
1057  else if (d->vendor_id == 0x1d0f && d->device_id >= 0xec20 && d->device_id <= 0xec21)
1058  ;
1059  /* Cavium Network Adapter */
1060  else if (d->vendor_id == 0x177d && d->device_id == 0x9712)
1061  ;
1062  /* Cavium FastlinQ QL41000 Series */
1063  else if (d->vendor_id == 0x1077 && d->device_id >= 0x8070 && d->device_id <= 0x8090)
1064  ;
1065  /* Mellanox CX3, CX3VF */
1066  else if (d->vendor_id == 0x15b3 && d->device_id >= 0x1003 && d->device_id <= 0x1004)
1067  {
1068  continue;
1069  }
1070  /* Mellanox CX4, CX4VF, CX4LX, CX4LXVF, CX5, CX5VF, CX5EX, CX5EXVF */
1071  else if (d->vendor_id == 0x15b3 && d->device_id >= 0x1013 && d->device_id <= 0x101a)
1072  {
1073  continue;
1074  }
1075  /* Mellanox CX6, CX6VF, CX6DX, CX6DXVF */
1076  else if (d->vendor_id == 0x15b3 && d->device_id >= 0x101b && d->device_id <= 0x101e)
1077  {
1078  continue;
1079  }
1080  /* Broadcom NetXtreme S, and E series only */
1081  else if (d->vendor_id == 0x14e4 &&
1082  ((d->device_id >= 0x16c0 &&
1083  d->device_id != 0x16c6 && d->device_id != 0x16c7 &&
1084  d->device_id != 0x16dd && d->device_id != 0x16f7 &&
1085  d->device_id != 0x16fd && d->device_id != 0x16fe &&
1086  d->device_id != 0x170d && d->device_id != 0x170c &&
1087  d->device_id != 0x170e && d->device_id != 0x1712 &&
1088  d->device_id != 0x1713) ||
1089  (d->device_id == 0x1604 || d->device_id == 0x1605 ||
1090  d->device_id == 0x1614 || d->device_id == 0x1606 ||
1091  d->device_id == 0x1609 || d->device_id == 0x1614)))
1092  ;
1093  else
1094  {
1095  dpdk_log_warn ("Unsupported PCI device 0x%04x:0x%04x found "
1096  "at PCI address %s\n", (u16) d->vendor_id, (u16) d->device_id,
1097  pci_addr);
1098  continue;
1099  }
1100 
1101  error = vlib_pci_bind_to_uio (vm, addr, (char *) conf->uio_driver_name);
1102 
1103  if (error)
1104  {
1105  if (devconf == 0)
1106  {
1107  pool_get (conf->dev_confs, devconf);
1109  devconf - conf->dev_confs);
1110  devconf->pci_addr.as_u32 = addr->as_u32;
1111  }
1112  devconf->dev_addr_type = VNET_DEV_ADDR_PCI;
1113  devconf->is_blacklisted = 1;
1115  }
1116  }
1117  /* *INDENT-ON* */
1118  vec_free (pci_addr);
1120 }
1121 
1122 static void
1124 {
1126  vlib_vmbus_addr_t *addrs, *addr = 0;
1127  int num_whitelisted = vec_len (conf->dev_confs);
1128  int i;
1129 
1130  addrs = vlib_vmbus_get_all_dev_addrs ();
1131 
1132  /* *INDENT-OFF* */
1133  vec_foreach (addr, addrs)
1134  {
1135  dpdk_device_config_t *devconf = 0;
1136  if (num_whitelisted)
1137  {
1138  uword *p =
1140  if (!p)
1141  {
1142  /* No devices blacklisted, but have whitelisted. blacklist all
1143  * non-whitelisted */
1144  pool_get (conf->dev_confs, devconf);
1146  devconf - conf->dev_confs, 0);
1147  devconf->vmbus_addr = *addr;
1149  devconf->is_blacklisted = 1;
1150  skipped_vmbus:
1151  continue;
1152  }
1153 
1154  devconf = pool_elt_at_index (conf->dev_confs, p[0]);
1155  }
1156 
1157  /* Enforce Device blacklist by vmbus_addr */
1158  for (i = 0; i < vec_len (conf->blacklist_by_vmbus_addr); i++)
1159  {
1161  vlib_vmbus_addr_t *a2 = addr;
1162  if (memcmp (a1, a2, sizeof (vlib_vmbus_addr_t)) == 0)
1163  {
1164  if (devconf == 0)
1165  {
1166  /* Device not whitelisted */
1167  pool_get (conf->dev_confs, devconf);
1169  devconf - conf->dev_confs, 0);
1170  devconf->vmbus_addr = *addr;
1172  devconf->is_blacklisted = 1;
1173  goto skipped_vmbus;
1174  }
1175  else
1176  {
1177  break;
1178  }
1179  }
1180  }
1181 
1183  if (error)
1184  {
1185  if (devconf == 0)
1186  {
1187  pool_get (conf->dev_confs, devconf);
1189  devconf - conf->dev_confs, 0);
1190  devconf->vmbus_addr = *addr;
1191  }
1193  devconf->is_blacklisted = 1;
1195  }
1196  }
1197  /* *INDENT-ON* */
1198 }
1199 
1200 uword
1202 {
1203  uword *max_simd_bitwidth = va_arg (*va, uword *);
1204 
1205  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1206  {
1207  if (!unformat (input, "%u", max_simd_bitwidth))
1208  goto error;
1209 
1210  if (*max_simd_bitwidth != DPDK_MAX_SIMD_BITWIDTH_256 &&
1211  *max_simd_bitwidth != DPDK_MAX_SIMD_BITWIDTH_512)
1212  goto error;
1213  }
1214  return 1;
1215 error:
1216  return 0;
1217 }
1218 
1219 static clib_error_t *
1221  dpdk_device_addr_type_t addr_type, unformat_input_t *input,
1222  u8 is_default)
1223 {
1224  clib_error_t *error = 0;
1225  uword *p;
1226  dpdk_device_config_t *devconf = 0;
1227  unformat_input_t sub_input;
1228 
1229  if (is_default)
1230  {
1231  devconf = &conf->default_devconf;
1232  }
1233  else if (addr_type == VNET_DEV_ADDR_PCI)
1234  {
1236  ((vlib_pci_addr_t *) (addr))->as_u32);
1237 
1238  if (!p)
1239  {
1240  pool_get (conf->dev_confs, devconf);
1242  ((vlib_pci_addr_t *) (addr))->as_u32,
1243  devconf - conf->dev_confs);
1244  }
1245  else
1246  return clib_error_return (0,
1247  "duplicate configuration for PCI address %U",
1249  }
1250  else if (addr_type == VNET_DEV_ADDR_VMBUS)
1251  {
1253  (vlib_vmbus_addr_t *) (addr));
1254 
1255  if (!p)
1256  {
1257  pool_get (conf->dev_confs, devconf);
1259  devconf - conf->dev_confs, 0);
1260  }
1261  else
1262  return clib_error_return (
1263  0, "duplicate configuration for VMBUS address %U",
1265  }
1266 
1267  if (addr_type == VNET_DEV_ADDR_PCI)
1268  {
1269  devconf->pci_addr.as_u32 = ((vlib_pci_addr_t *) (addr))->as_u32;
1270  devconf->tso = DPDK_DEVICE_TSO_DEFAULT;
1271  devconf->dev_addr_type = VNET_DEV_ADDR_PCI;
1272  }
1273  else if (addr_type == VNET_DEV_ADDR_VMBUS)
1274  {
1275  devconf->vmbus_addr = *((vlib_vmbus_addr_t *) (addr));
1276  devconf->tso = DPDK_DEVICE_TSO_DEFAULT;
1278  }
1279 
1280  if (!input)
1281  return 0;
1282 
1283  unformat_skip_white_space (input);
1284  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1285  {
1286  if (unformat (input, "num-rx-queues %u", &devconf->num_rx_queues))
1287  ;
1288  else if (unformat (input, "num-tx-queues %u", &devconf->num_tx_queues))
1289  ;
1290  else if (unformat (input, "num-rx-desc %u", &devconf->num_rx_desc))
1291  ;
1292  else if (unformat (input, "num-tx-desc %u", &devconf->num_tx_desc))
1293  ;
1294  else if (unformat (input, "name %s", &devconf->name))
1295  ;
1296  else if (unformat (input, "workers %U", unformat_bitmap_list,
1297  &devconf->workers))
1298  ;
1299  else
1300  if (unformat
1301  (input, "rss %U", unformat_vlib_cli_sub_input, &sub_input))
1302  {
1303  error = unformat_rss_fn (&sub_input, &devconf->rss_fn);
1304  if (error)
1305  break;
1306  }
1307  else if (unformat (input, "vlan-strip-offload off"))
1309  else if (unformat (input, "vlan-strip-offload on"))
1311  else if (unformat (input, "tso on"))
1312  {
1313  devconf->tso = DPDK_DEVICE_TSO_ON;
1314  }
1315  else if (unformat (input, "tso off"))
1316  {
1317  devconf->tso = DPDK_DEVICE_TSO_OFF;
1318  }
1319  else if (unformat (input, "devargs %s", &devconf->devargs))
1320  ;
1321  else if (unformat (input, "rss-queues %U",
1322  unformat_bitmap_list, &devconf->rss_queues))
1323  ;
1324  else if (unformat (input, "max-lro-pkt-size %u",
1325  &devconf->max_lro_pkt_size))
1326  ;
1327  else
1328  {
1329  error = clib_error_return (0, "unknown input `%U'",
1330  format_unformat_error, input);
1331  break;
1332  }
1333  }
1334 
1335  if (error)
1336  return error;
1337 
1338  if (devconf->workers && devconf->num_rx_queues == 0)
1339  devconf->num_rx_queues = clib_bitmap_count_set_bits (devconf->workers);
1340  else if (devconf->workers &&
1341  clib_bitmap_count_set_bits (devconf->workers) !=
1342  devconf->num_rx_queues)
1343  error = clib_error_return (0,
1344  "%U: number of worker threads must be "
1345  "equal to number of rx queues",
1347 
1348  return error;
1349 }
1350 
1351 static clib_error_t *
1353 {
1354  unformat_input_t input;
1355  u8 *line, *s = 0;
1356  int n, n_try;
1357 
1358  n = n_try = 4096;
1359  while (n == n_try)
1360  {
1361  uword len = vec_len (s);
1362  vec_resize (s, len + n_try);
1363 
1364  n = read (uf->file_descriptor, s + len, n_try);
1365  if (n < 0 && errno != EAGAIN)
1366  return clib_error_return_unix (0, "read");
1367  _vec_len (s) = len + (n < 0 ? 0 : n);
1368  }
1369 
1370  unformat_init_vector (&input, s);
1371 
1372  while (unformat_user (&input, unformat_line, &line))
1373  {
1374  dpdk_log_notice ("%v", line);
1375  vec_free (line);
1376  }
1377 
1378  unformat_free (&input);
1379  return 0;
1380 }
1381 
1382 static clib_error_t *
1384 {
1385  clib_error_t *error = 0;
1388  dpdk_device_config_t *devconf;
1389  vlib_pci_addr_t pci_addr = { 0 };
1390  vlib_vmbus_addr_t vmbus_addr = { 0 };
1391  unformat_input_t sub_input;
1392  uword default_hugepage_sz, x;
1393  u8 *s, *tmp = 0;
1394  int ret, i;
1395  int num_whitelisted = 0;
1396  int eal_no_hugetlb = 0;
1397  u8 no_pci = 0;
1398  u8 no_vmbus = 0;
1399  u8 file_prefix = 0;
1400  u8 *socket_mem = 0;
1401  u8 *huge_dir_path = 0;
1402  u32 vendor, device, domain, bus, func;
1403 
1404  huge_dir_path =
1405  format (0, "%s/hugepages%c", vlib_unix_get_runtime_dir (), 0);
1406 
1407  conf->device_config_index_by_pci_addr = hash_create (0, sizeof (uword));
1409  sizeof (vlib_vmbus_addr_t));
1410 
1411  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1412  {
1413  /* Prime the pump */
1414  if (unformat (input, "no-hugetlb"))
1415  {
1416  vec_add1 (conf->eal_init_args, (u8 *) "--no-huge");
1417  eal_no_hugetlb = 1;
1418  }
1419  else if (unformat (input, "telemetry"))
1420  conf->enable_telemetry = 1;
1421 
1422  else if (unformat (input, "enable-tcp-udp-checksum"))
1423  {
1424  conf->enable_tcp_udp_checksum = 1;
1425  if (unformat (input, "enable-outer-checksum-offload"))
1427  }
1428  else if (unformat (input, "no-tx-checksum-offload"))
1429  conf->no_tx_checksum_offload = 1;
1430 
1431  else if (unformat (input, "decimal-interface-names"))
1433 
1434  else if (unformat (input, "no-multi-seg"))
1435  conf->no_multi_seg = 1;
1436  else if (unformat (input, "enable-lro"))
1437  conf->enable_lro = 1;
1438  else if (unformat (input, "max-simd-bitwidth %U",
1440  ;
1441  else if (unformat (input, "dev default %U", unformat_vlib_cli_sub_input,
1442  &sub_input))
1443  {
1444  error =
1445  dpdk_device_config (conf, 0, VNET_DEV_ADDR_ANY, &sub_input, 1);
1446 
1447  if (error)
1448  return error;
1449  }
1450  else
1451  if (unformat
1452  (input, "dev %U %U", unformat_vlib_pci_addr, &pci_addr,
1453  unformat_vlib_cli_sub_input, &sub_input))
1454  {
1455  error = dpdk_device_config (conf, &pci_addr, VNET_DEV_ADDR_PCI,
1456  &sub_input, 0);
1457 
1458  if (error)
1459  return error;
1460 
1461  num_whitelisted++;
1462  }
1463  else if (unformat (input, "dev %U", unformat_vlib_pci_addr, &pci_addr))
1464  {
1465  error =
1466  dpdk_device_config (conf, &pci_addr, VNET_DEV_ADDR_PCI, 0, 0);
1467 
1468  if (error)
1469  return error;
1470 
1471  num_whitelisted++;
1472  }
1473  else if (unformat (input, "dev %U %U", unformat_vlib_vmbus_addr,
1474  &vmbus_addr, unformat_vlib_cli_sub_input, &sub_input))
1475  {
1476  error = dpdk_device_config (conf, &vmbus_addr, VNET_DEV_ADDR_VMBUS,
1477  &sub_input, 0);
1478 
1479  if (error)
1480  return error;
1481 
1482  num_whitelisted++;
1483  }
1484  else if (unformat (input, "dev %U", unformat_vlib_vmbus_addr,
1485  &vmbus_addr))
1486  {
1487  error =
1488  dpdk_device_config (conf, &vmbus_addr, VNET_DEV_ADDR_VMBUS, 0, 0);
1489 
1490  if (error)
1491  return error;
1492 
1493  num_whitelisted++;
1494  }
1495  else if (unformat (input, "num-mem-channels %d", &conf->nchannels))
1496  conf->nchannels_set_manually = 0;
1497  else if (unformat (input, "num-crypto-mbufs %d",
1498  &conf->num_crypto_mbufs))
1499  ;
1500  else if (unformat (input, "uio-driver %s", &conf->uio_driver_name))
1501  ;
1502  else if (unformat (input, "socket-mem %s", &socket_mem))
1503  ;
1504  else if (unformat (input, "no-pci"))
1505  {
1506  no_pci = 1;
1507  tmp = format (0, "--no-pci%c", 0);
1508  vec_add1 (conf->eal_init_args, tmp);
1509  }
1510  else if (unformat (input, "blacklist %U", unformat_vlib_vmbus_addr,
1511  &vmbus_addr))
1512  {
1513  vec_add1 (conf->blacklist_by_vmbus_addr, vmbus_addr);
1514  }
1515  else
1516  if (unformat
1517  (input, "blacklist %x:%x:%x.%x", &domain, &bus, &device, &func))
1518  {
1519  tmp = format (0, "-b%c", 0);
1520  vec_add1 (conf->eal_init_args, tmp);
1521  tmp =
1522  format (0, "%04x:%02x:%02x.%x%c", domain, bus, device, func, 0);
1523  vec_add1 (conf->eal_init_args, tmp);
1524  }
1525  else if (unformat (input, "blacklist %x:%x", &vendor, &device))
1526  {
1527  u32 blacklist_entry;
1528  if (vendor > 0xFFFF)
1529  return clib_error_return (0, "blacklist PCI vendor out of range");
1530  if (device > 0xFFFF)
1531  return clib_error_return (0, "blacklist PCI device out of range");
1532  blacklist_entry = (vendor << 16) | (device & 0xffff);
1534  blacklist_entry);
1535  }
1536  else if (unformat (input, "no-vmbus"))
1537  {
1538  no_vmbus = 1;
1539  tmp = format (0, "--no-vmbus%c", 0);
1540  vec_add1 (conf->eal_init_args, tmp);
1541  }
1542 
1543 #define _(a) \
1544  else if (unformat(input, #a)) \
1545  { \
1546  tmp = format (0, "--%s%c", #a, 0); \
1547  vec_add1 (conf->eal_init_args, tmp); \
1548  }
1550 #undef _
1551 #define _(a) \
1552  else if (unformat(input, #a " %s", &s)) \
1553  { \
1554  if (!strncmp(#a, "file-prefix", 11)) \
1555  file_prefix = 1; \
1556  tmp = format (0, "--%s%c", #a, 0); \
1557  vec_add1 (conf->eal_init_args, tmp); \
1558  vec_add1 (s, 0); \
1559  if (!strncmp(#a, "vdev", 4)) \
1560  if (strstr((char*)s, "af_packet")) \
1561  clib_warning ("af_packet obsoleted. Use CLI 'create host-interface'."); \
1562  vec_add1 (conf->eal_init_args, s); \
1563  }
1565 #undef _
1566 #define _(a,b) \
1567  else if (unformat(input, #a " %s", &s)) \
1568  { \
1569  tmp = format (0, "-%s%c", #b, 0); \
1570  vec_add1 (conf->eal_init_args, tmp); \
1571  vec_add1 (s, 0); \
1572  vec_add1 (conf->eal_init_args, s); \
1573  }
1575 #undef _
1576 #define _(a,b) \
1577  else if (unformat(input, #a " %s", &s)) \
1578  { \
1579  tmp = format (0, "-%s%c", #b, 0); \
1580  vec_add1 (conf->eal_init_args, tmp); \
1581  vec_add1 (s, 0); \
1582  vec_add1 (conf->eal_init_args, s); \
1583  conf->a##_set_manually = 1; \
1584  }
1586 #undef _
1587  else if (unformat (input, "default"))
1588  ;
1589 
1590  else if (unformat_skip_white_space (input))
1591  ;
1592  else
1593  {
1594  error = clib_error_return (0, "unknown input `%U'",
1595  format_unformat_error, input);
1596  goto done;
1597  }
1598  }
1599 
1600  if (!conf->uio_driver_name)
1601  conf->uio_driver_name = format (0, "auto%c", 0);
1602 
1603  if (eal_no_hugetlb == 0)
1604  {
1605  vec_add1 (conf->eal_init_args, (u8 *) "--in-memory");
1606 
1607  default_hugepage_sz = clib_mem_get_default_hugepage_size ();
1608 
1609  /* *INDENT-OFF* */
1611  {
1612  clib_error_t *e;
1613  uword n_pages;
1614  /* preallocate at least 16MB of hugepages per socket,
1615  if more is needed it is up to consumer to preallocate more */
1616  n_pages = round_pow2 ((uword) 16 << 20, default_hugepage_sz);
1617  n_pages /= default_hugepage_sz;
1618 
1619  if ((e = clib_sysfs_prealloc_hugepages(x, 0, n_pages)))
1620  clib_error_report (e);
1621  }
1622  /* *INDENT-ON* */
1623  }
1624 
1625  /* on/off dpdk's telemetry thread */
1626  if (conf->enable_telemetry == 0)
1627  {
1628  vec_add1 (conf->eal_init_args, (u8 *) "--no-telemetry");
1629  }
1630 
1631  if (!file_prefix)
1632  {
1633  tmp = format (0, "--file-prefix%c", 0);
1634  vec_add1 (conf->eal_init_args, tmp);
1635  tmp = format (0, "vpp%c", 0);
1636  vec_add1 (conf->eal_init_args, tmp);
1637  }
1638 
1639  if (error)
1640  return error;
1641 
1642  /* I'll bet that -c and -n must be the first and second args... */
1643  if (!conf->coremask_set_manually)
1644  {
1646  uword *coremask = 0;
1647  int i;
1648 
1649  /* main thread core */
1650  coremask = clib_bitmap_set (coremask, tm->main_lcore, 1);
1651 
1652  for (i = 0; i < vec_len (tm->registrations); i++)
1653  {
1654  tr = tm->registrations[i];
1655  coremask = clib_bitmap_or (coremask, tr->coremask);
1656  }
1657 
1658  vec_insert (conf->eal_init_args, 2, 1);
1659  conf->eal_init_args[1] = (u8 *) "-c";
1660  tmp = format (0, "%U%c", format_bitmap_hex, coremask, 0);
1661  conf->eal_init_args[2] = tmp;
1662  clib_bitmap_free (coremask);
1663  }
1664 
1665  if (!conf->nchannels_set_manually)
1666  {
1667  vec_insert (conf->eal_init_args, 2, 3);
1668  conf->eal_init_args[3] = (u8 *) "-n";
1669  tmp = format (0, "%d", conf->nchannels);
1671  conf->eal_init_args[4] = tmp;
1672  }
1673 
1674  if (no_pci == 0 && geteuid () == 0)
1675  dpdk_bind_devices_to_uio (conf);
1676 
1677  if (no_vmbus == 0 && geteuid () == 0)
1679 
1680 #define _(x) \
1681  if (devconf->x == 0 && conf->default_devconf.x > 0) \
1682  devconf->x = conf->default_devconf.x ;
1683 
1684  /* *INDENT-OFF* */
1685  pool_foreach (devconf, conf->dev_confs) {
1686 
1687  /* default per-device config items */
1689 
1690  /* copy vlan_strip config from default device */
1691  _ (vlan_strip_offload)
1692 
1693  /* copy tso config from default device */
1694  _ (tso)
1695 
1696  /* copy tso config from default device */
1697  _ (devargs)
1698 
1699  /* copy rss_queues config from default device */
1700  _ (rss_queues)
1701 
1702  /* add DPDK EAL whitelist/blacklist entry */
1703  if (num_whitelisted > 0 && devconf->is_blacklisted == 0 &&
1704  devconf->dev_addr_type == VNET_DEV_ADDR_PCI)
1705  {
1706  tmp = format (0, "-a%c", 0);
1707  vec_add1 (conf->eal_init_args, tmp);
1708  if (devconf->devargs)
1709  {
1710  tmp = format (0, "%U,%s%c", format_vlib_pci_addr,
1711  &devconf->pci_addr, devconf->devargs, 0);
1712  }
1713  else
1714  {
1715  tmp = format (0, "%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1716  }
1717  vec_add1 (conf->eal_init_args, tmp);
1718  }
1719  else if (num_whitelisted == 0 && devconf->is_blacklisted != 0 &&
1720  devconf->dev_addr_type == VNET_DEV_ADDR_PCI)
1721  {
1722  tmp = format (0, "-b%c", 0);
1723  vec_add1 (conf->eal_init_args, tmp);
1724  tmp = format (0, "%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1725  vec_add1 (conf->eal_init_args, tmp);
1726  }
1727  }
1728  /* *INDENT-ON* */
1729 
1730 #undef _
1731 
1732  /* set master-lcore */
1733  tmp = format (0, "--main-lcore%c", 0);
1734  vec_add1 (conf->eal_init_args, tmp);
1735  tmp = format (0, "%u%c", tm->main_lcore, 0);
1736  vec_add1 (conf->eal_init_args, tmp);
1737 
1738 
1739  if (socket_mem)
1740  clib_warning ("socket-mem argument is deprecated");
1741 
1742  /* NULL terminate the "argv" vector, in case of stupidity */
1743  vec_add1 (conf->eal_init_args, 0);
1744  _vec_len (conf->eal_init_args) -= 1;
1745 
1746  /* Set up DPDK eal and packet mbuf pool early. */
1747 
1748  int log_fds[2] = { 0 };
1749  if (pipe (log_fds) == 0)
1750  {
1751  if (fcntl (log_fds[1], F_SETFL, O_NONBLOCK) == 0)
1752  {
1753  FILE *f = fdopen (log_fds[1], "a");
1754  if (f && rte_openlog_stream (f) == 0)
1755  {
1756  clib_file_t t = { 0 };
1758  t.file_descriptor = log_fds[0];
1759  t.description = format (0, "DPDK logging pipe");
1760  clib_file_add (&file_main, &t);
1761  }
1762  }
1763  else
1764  {
1765  close (log_fds[0]);
1766  close (log_fds[1]);
1767  }
1768  }
1769 
1770  vm = vlib_get_main ();
1771 
1772  /* make copy of args as rte_eal_init tends to mess up with arg array */
1773  for (i = 1; i < vec_len (conf->eal_init_args); i++)
1774  conf->eal_init_args_str = format (conf->eal_init_args_str, "%s ",
1775  conf->eal_init_args[i]);
1776 
1778 
1779  dpdk_log_notice ("EAL init args: %s", conf->eal_init_args_str);
1780  ret = rte_eal_init (vec_len (conf->eal_init_args),
1781  (char **) conf->eal_init_args);
1782 
1783  /* enable the AVX-512 vPMDs in DPDK */
1784  if (clib_cpu_supports_avx512_bitalg () &&
1786  rte_vect_set_max_simd_bitwidth (RTE_VECT_SIMD_512);
1788  rte_vect_set_max_simd_bitwidth (conf->max_simd_bitwidth ==
1790  RTE_VECT_SIMD_256 :
1791  RTE_VECT_SIMD_512);
1792 
1793  /* lazy umount hugepages */
1794  umount2 ((char *) huge_dir_path, MNT_DETACH);
1795  rmdir ((char *) huge_dir_path);
1796  vec_free (huge_dir_path);
1797 
1798  if (ret < 0)
1799  return clib_error_return (0, "rte_eal_init returned %d", ret);
1800 
1801  /* main thread 1st */
1802  if ((error = dpdk_buffer_pools_create (vm)))
1803  return error;
1804 
1805 done:
1806  return error;
1807 }
1808 
1810 
1811 void
1813 {
1814  vnet_main_t *vnm = vnet_get_main ();
1815  struct rte_eth_link prev_link = xd->link;
1816  u32 hw_flags = 0;
1817  u8 hw_flags_chg = 0;
1818 
1819  /* only update link state for PMD interfaces */
1820  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
1821  return;
1822 
1824  clib_memset (&xd->link, 0, sizeof (xd->link));
1825  rte_eth_link_get_nowait (xd->port_id, &xd->link);
1826 
1827  if (LINK_STATE_ELOGS)
1828  {
1829  ELOG_TYPE_DECLARE (e) =
1830  {
1831  .format =
1832  "update-link-state: sw_if_index %d, admin_up %d,"
1833  "old link_state %d new link_state %d",.format_args = "i4i1i1i1",};
1834 
1835  struct
1836  {
1837  u32 sw_if_index;
1838  u8 admin_up;
1839  u8 old_link_state;
1840  u8 new_link_state;
1841  } *ed;
1843  ed->sw_if_index = xd->sw_if_index;
1844  ed->admin_up = (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0;
1845  ed->old_link_state = (u8)
1847  ed->new_link_state = (u8) xd->link.link_status;
1848  }
1849 
1850  if ((xd->link.link_duplex != prev_link.link_duplex))
1851  {
1852  hw_flags_chg = 1;
1853  switch (xd->link.link_duplex)
1854  {
1855  case ETH_LINK_HALF_DUPLEX:
1857  break;
1858  case ETH_LINK_FULL_DUPLEX:
1860  break;
1861  default:
1862  break;
1863  }
1864  }
1865  if (xd->link.link_speed != prev_link.link_speed)
1867  xd->link.link_speed * 1000);
1868 
1869  if (xd->link.link_status != prev_link.link_status)
1870  {
1871  hw_flags_chg = 1;
1872 
1873  if (xd->link.link_status)
1874  hw_flags |= VNET_HW_INTERFACE_FLAG_LINK_UP;
1875  }
1876 
1877  if (hw_flags_chg)
1878  {
1879  if (LINK_STATE_ELOGS)
1880  {
1881  ELOG_TYPE_DECLARE (e) =
1882  {
1883  .format =
1884  "update-link-state: sw_if_index %d, new flags %d",.format_args
1885  = "i4i4",};
1886 
1887  struct
1888  {
1889  u32 sw_if_index;
1890  u32 flags;
1891  } *ed;
1893  ed->sw_if_index = xd->sw_if_index;
1894  ed->flags = hw_flags;
1895  }
1896  vnet_hw_interface_set_flags (vnm, xd->hw_if_index, hw_flags);
1897  }
1898 }
1899 
1900 static uword
1902 {
1904  dpdk_main_t *dm = &dpdk_main;
1905  dpdk_device_t *xd;
1907 
1908  error = dpdk_lib_init (dm);
1909 
1910  if (error)
1912 
1913  if (dpdk_cryptodev_init)
1914  {
1916  if (error)
1917  {
1919  error);
1921  }
1922  }
1923 
1924  tm->worker_thread_release = 1;
1925 
1926  f64 now = vlib_time_now (vm);
1927  vec_foreach (xd, dm->devices)
1928  {
1930  }
1931 
1932  while (1)
1933  {
1934  /*
1935  * check each time through the loop in case intervals are changed
1936  */
1937  f64 min_wait = dm->link_state_poll_interval < dm->stat_poll_interval ?
1939 
1941 
1942  if (dm->admin_up_down_in_progress)
1943  /* skip the poll if an admin up down is in progress (on any interface) */
1944  continue;
1945 
1946  vec_foreach (xd, dm->devices)
1947  {
1948  f64 now = vlib_time_now (vm);
1949  if ((now - xd->time_last_stats_update) >= dm->stat_poll_interval)
1950  dpdk_update_counters (xd, now);
1953 
1954  }
1955  }
1956 
1957  return 0;
1958 }
1959 
1960 /* *INDENT-OFF* */
1962  .function = dpdk_process,
1963  .type = VLIB_NODE_TYPE_PROCESS,
1964  .name = "dpdk-process",
1965  .process_log2_n_stack_bytes = 17,
1966 };
1967 /* *INDENT-ON* */
1968 
1969 static clib_error_t *
1971 {
1972  dpdk_main_t *dm = &dpdk_main;
1973  clib_error_t *error = 0;
1974 
1975  /* verify that structs are cacheline aligned */
1976  STATIC_ASSERT (offsetof (dpdk_device_t, cacheline0) == 0,
1977  "Cache line marker must be 1st element in dpdk_device_t");
1978  STATIC_ASSERT (offsetof (dpdk_device_t, cacheline1) ==
1980  "Data in cache line 0 is bigger than cache line size");
1981  STATIC_ASSERT (offsetof (frame_queue_trace_t, cacheline0) == 0,
1982  "Cache line marker must be 1st element in frame_queue_trace_t");
1983 
1984  dpdk_cli_reference ();
1985 
1986  dm->vlib_main = vm;
1987  dm->vnet_main = vnet_get_main ();
1988  dm->conf = &dpdk_config_main;
1989 
1990  dm->conf->nchannels = 4;
1991  vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet");
1992 
1993  /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */
1994  dm->buffer_flags_template = (VLIB_BUFFER_TOTAL_LENGTH_VALID |
1995  VLIB_BUFFER_EXT_HDR_VALID |
1996  VNET_BUFFER_F_L4_CHECKSUM_COMPUTED |
1997  VNET_BUFFER_F_L4_CHECKSUM_CORRECT);
1998 
2001 
2002  dm->log_default = vlib_log_register_class ("dpdk", 0);
2003  dm->log_cryptodev = vlib_log_register_class ("dpdk", "cryptodev");
2004  dm->log_ipsec = vlib_log_register_class ("dpdk", "ipsec");
2005 
2006  return error;
2007 }
2008 
2010 
2011 /*
2012  * fd.io coding-style-patch-verification: ON
2013  *
2014  * Local Variables:
2015  * eval: (c-set-style "gnu")
2016  * End:
2017  */
dpdk_config_main_t::nchannels_set_manually
u8 nchannels_set_manually
Definition: dpdk.h:318
dpdk_device_config_t::tso
u8 tso
Definition: dpdk.h:288
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
format_dpdk_device_errors
format_function_t format_dpdk_device_errors
Definition: dpdk.h:479
VNET_DPDK_PORT_TYPE_VIRTIO_USER
@ VNET_DPDK_PORT_TYPE_VIRTIO_USER
Definition: dpdk.h:123
dpdk_config_main_t::eal_init_args_str
u8 * eal_init_args_str
Definition: dpdk.h:302
ETHERNET_INTERFACE_FLAG_DEFAULT_L3
#define ETHERNET_INTERFACE_FLAG_DEFAULT_L3
Definition: ethernet.h:159
clib_file::file_descriptor
u32 file_descriptor
Definition: file.h:54
DPDK_MAX_SIMD_BITWIDTH_DEFAULT
#define DPDK_MAX_SIMD_BITWIDTH_DEFAULT
Definition: dpdk.h:312
dpdk_process
static uword dpdk_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: init.c:1901
tmp
u32 * tmp
Definition: interface_output.c:1096
check_l3cache
static int check_l3cache()
Definition: init.c:159
vlib_pci_get_all_dev_addrs
vlib_pci_addr_t * vlib_pci_get_all_dev_addrs()
Definition: pci.c:1466
VNET_HW_IF_RXQ_THREAD_ANY
#define VNET_HW_IF_RXQ_THREAD_ANY
Definition: interface.h:598
vnet_device_main
vnet_device_main_t vnet_device_main
Definition: devices.c:22
VNET_DPDK_PMD_UNKNOWN
@ VNET_DPDK_PMD_UNKNOWN
Definition: dpdk.h:105
dpdk.h
dpdk_device_t::supported_flow_actions
u32 supported_flow_actions
Definition: dpdk.h:222
dpdk_device_config_t::vmbus_addr
vlib_vmbus_addr_t vmbus_addr
Definition: dpdk.h:274
file_main
clib_file_main_t file_main
Definition: main.c:63
dpdk_cryptodev_init
clib_error_t * dpdk_cryptodev_init(vlib_main_t *vm)
Definition: cryptodev.c:1061
dpdk_update_link_state
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1812
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
unformat_init_vector
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1037
VNET_DPDK_PORT_TYPE_UNKNOWN
@ VNET_DPDK_PORT_TYPE_UNKNOWN
Definition: dpdk.h:127
dpdk_config
static clib_error_t * dpdk_config(vlib_main_t *vm, unformat_input_t *input)
Definition: init.c:1383
DPDK_NB_RX_DESC_VIRTIO
#define DPDK_NB_RX_DESC_VIRTIO
Definition: dpdk_priv.h:19
vnet_sw_interface_t
Definition: interface.h:869
dpdk_config_main_t::interface_name_format_decimal
u8 interface_name_format_decimal
Definition: dpdk.h:327
dpdk_device_t::flags
u16 flags
Definition: dpdk.h:200
dpdk_main_t::buffer_flags_template
u32 buffer_flags_template
Definition: dpdk.h:365
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
vnet_hw_interface_set_rss_queues
clib_error_t * vnet_hw_interface_set_rss_queues(vnet_main_t *vnm, vnet_hw_interface_t *hi, clib_bitmap_t *bitmap)
Definition: interface.c:1814
VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER
@ VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER
Definition: interface.h:552
dpdk_main_t::devices
dpdk_device_t * devices
Definition: dpdk.h:361
dpdk_get_pci_device
struct rte_pci_device * dpdk_get_pci_device(const struct rte_eth_dev_info *info)
Definition: common.c:335
ethernet_set_flags
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:441
dpdk_portid_t
uint16_t dpdk_portid_t
Definition: dpdk.h:130
dpdk_log_notice
#define dpdk_log_notice(...)
Definition: dpdk.h:442
f
vlib_frame_t * f
Definition: interface_output.c:1098
dpdk_rx_queue_t
Definition: dpdk.h:167
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
dpdk_config_main_t::coremask_set_manually
u8 coremask_set_manually
Definition: dpdk.h:317
bitmap.h
dpdk_main_t::vnet_main
vnet_main_t * vnet_main
Definition: dpdk.h:379
foreach_eal_double_hyphen_predicate_arg
#define foreach_eal_double_hyphen_predicate_arg
Definition: dpdk_priv.h:30
dpdk_input_node
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
Definition: node.c:542
string.h
vlib_log_register_class
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:339
clib_mem_get_default_hugepage_size
static_always_inline uword clib_mem_get_default_hugepage_size(void)
Definition: mem.h:489
dpdk_cli_reference
void dpdk_cli_reference(void)
Definition: cli.c:389
ETHER_MAX_LEN
#define ETHER_MAX_LEN
Maximum frame len, including CRC.
Definition: init.c:46
dpdk_device_addr_type_t
dpdk_device_addr_type_t
Definition: dpdk.h:262
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
u8
#define u8
Padding.
Definition: clib.h:121
clib_file::read_function
clib_file_function_t * read_function
Definition: file.h:67
vlib_log_warn
#define vlib_log_warn(...)
Definition: log.h:134
DPDK_DEVICE_TSO_DEFAULT
#define DPDK_DEVICE_TSO_DEFAULT
Definition: dpdk.h:292
dpdk_device_t::time_last_link_update
f64 time_last_link_update
Definition: dpdk.h:233
unformat_vlib_pci_addr
unformat_function_t unformat_vlib_pci_addr
Definition: pci.h:325
u16
unsigned short u16
Definition: types.h:57
foreach_dpdk_pmd
#define foreach_dpdk_pmd
Definition: dpdk.h:69
mhash_get
static uword * mhash_get(mhash_t *h, const void *key)
Definition: mhash.h:110
PCI_CLASS_PROCESSOR_CO
@ PCI_CLASS_PROCESSOR_CO
Definition: pci_config.h:128
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
clib_sysfs_prealloc_hugepages
clib_error_t * clib_sysfs_prealloc_hugepages(int numa_node, int log2_page_size, int nr)
Definition: sysfs.c:240
dpdk_bind_devices_to_uio
static void dpdk_bind_devices_to_uio(dpdk_config_main_t *conf)
Definition: init.c:946
dpdk_device_t::time_last_stats_update
f64 time_last_stats_update
Definition: dpdk.h:238
VNET_HW_INTERFACE_FLAG_LINK_UP
@ VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:509
domain
description no domain
Definition: map.api:415
DPDK_MAX_SIMD_BITWIDTH_512
#define DPDK_MAX_SIMD_BITWIDTH_512
Definition: dpdk.h:314
dpdk_device_t::port_id
dpdk_portid_t port_id
Definition: dpdk.h:203
dpdk_device_setup
void dpdk_device_setup(dpdk_device_t *xd)
Definition: common.c:42
unformat_max_simd_bitwidth
uword unformat_max_simd_bitwidth(unformat_input_t *input, va_list *va)
Definition: init.c:1201
clib_file::description
u8 * description
Definition: file.h:70
vlib_thread_main_t::main_lcore
u32 main_lcore
Definition: threads.h:280
vlib_thread_main_t::cpu_socket_bitmap
uword * cpu_socket_bitmap
Definition: threads.h:286
vlib_pci_bind_to_uio
clib_error_t * vlib_pci_bind_to_uio(vlib_main_t *vm, vlib_pci_addr_t *addr, char *uio_drv_name)
Definition: pci.c:397
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
vnet_hw_interface_set_link_speed
static void vnet_hw_interface_set_link_speed(vnet_main_t *vnm, u32 hw_if_index, u32 link_speed)
Definition: interface_funcs.h:372
dpdk_device_t::errors
clib_error_t * errors
Definition: dpdk.h:245
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
unformat_input_t
struct _unformat_input_t unformat_input_t
dpdk_lib_init
static clib_error_t * dpdk_lib_init(dpdk_main_t *dm)
Definition: init.c:205
dpdk_config_main_t::device_config_index_by_pci_addr
uword * device_config_index_by_pci_addr
Definition: dpdk.h:332
VIRTIO_PCI_LEGACY_DEVICEID_NET
#define VIRTIO_PCI_LEGACY_DEVICEID_NET
Definition: pci_config.h:168
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
mhash_init
__clib_export void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
Definition: mhash.c:168
vlib_frame_t
Definition: node.h:372
format_vlib_vmbus_addr
format_function_t format_vlib_vmbus_addr
Definition: vmbus.h:38
ethernet.h
error
Definition: cJSON.c:88
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_OUTER_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_OUTER_CKSUM
Definition: interface.h:527
sysfs.h
vlib_thread_main_t::worker_thread_release
volatile u32 worker_thread_release
Definition: threads.h:292
dpdk_device_class
vnet_device_class_t dpdk_device_class
dpdk_device_t::port_type
dpdk_port_type_t port_type
Definition: dpdk.h:239
dpdk_main_t::log_ipsec
vlib_log_class_t log_ipsec
Definition: dpdk.h:388
format_clib_error
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
dpdk_log_info
#define dpdk_log_info(...)
Definition: dpdk.h:444
VNET_DPDK_PORT_TYPE_ETH_10G
@ VNET_DPDK_PORT_TYPE_ETH_10G
Definition: dpdk.h:113
random_u32
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
VNET_DPDK_PORT_TYPE_ETH_40G
@ VNET_DPDK_PORT_TYPE_ETH_40G
Definition: dpdk.h:116
dpdk_config_main_t::blacklist_by_vmbus_addr
vlib_vmbus_addr_t * blacklist_by_vmbus_addr
Definition: dpdk.h:338
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM
Definition: interface.h:524
VLIB_CONFIG_FUNCTION
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:181
vlib_pci_device_info
Definition: pci.h:60
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
foreach_eal_single_hyphen_mandatory_arg
#define foreach_eal_single_hyphen_mandatory_arg
Definition: dpdk_priv.h:36
dpdk_config_main
dpdk_config_main_t dpdk_config_main
Definition: init.c:49
dpdk_log_read_ready
static clib_error_t * dpdk_log_read_ready(clib_file_t *uf)
Definition: init.c:1352
clib_sysfs_read
__clib_export clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
Definition: sysfs.c:51
round_pow2
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:279
vnet_sw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:876
DPDK_DEVICE_TSO_ON
#define DPDK_DEVICE_TSO_ON
Definition: dpdk.h:294
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
foreach_eal_double_hyphen_arg
#define foreach_eal_double_hyphen_arg
Definition: dpdk_priv.h:46
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
dpdk_device_t::per_interface_next_index
u32 per_interface_next_index
Definition: dpdk.h:196
dpdk_config_main_t::enable_telemetry
u8 enable_telemetry
Definition: dpdk.h:309
VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
@ VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
Definition: interface.h:512
port_type_from_speed_capa
static dpdk_port_type_t port_type_from_speed_capa(struct rte_eth_dev_info *dev_info)
Definition: init.c:56
VNET_DPDK_PORT_TYPE_ETH_1G
@ VNET_DPDK_PORT_TYPE_ETH_1G
Definition: dpdk.h:110
dpdk_device_t::hw_if_index
u32 hw_if_index
Definition: dpdk.h:192
dpdk_config_main_t::no_multi_seg
u8 no_multi_seg
Definition: dpdk.h:304
dpdk_port_crc_strip_enabled
static int dpdk_port_crc_strip_enabled(dpdk_device_t *xd)
Definition: init.c:149
dpdk_config_main_t::enable_outer_checksum_offload
u8 enable_outer_checksum_offload
Definition: dpdk.h:307
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
dpdk_device_config_t::pci_addr
vlib_pci_addr_t pci_addr
Definition: dpdk.h:273
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
ELOG_TYPE_DECLARE
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:442
DPDK_NB_TX_DESC_VIRTIO
#define DPDK_NB_TX_DESC_VIRTIO
Definition: dpdk_priv.h:20
len
u8 len
Definition: ip_types.api:103
error.h
dpdk_get_vmbus_device
struct rte_vmbus_device * dpdk_get_vmbus_device(const struct rte_eth_dev_info *info)
Definition: common.c:348
clib_bitmap_or
static uword * clib_bitmap_or(uword *ai, uword *bi)
Logical operator across two bitmaps.
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vmbus.h
VNET_DPDK_PORT_TYPE_ETH_5G
@ VNET_DPDK_PORT_TYPE_ETH_5G
Definition: dpdk.h:112
unformat_skip_white_space
uword unformat_skip_white_space(unformat_input_t *input)
Definition: unformat.c:821
dpdk_device_t::rx_q_used
u16 rx_q_used
Definition: dpdk.h:198
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
clib_file
Definition: file.h:51
dpdk_config_main_t::no_tx_checksum_offload
u8 no_tx_checksum_offload
Definition: dpdk.h:308
clib_bitmap_count_set_bits
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
Definition: bitmap.h:449
dpdk_config_main_t::eal_init_args
u8 ** eal_init_args
Definition: dpdk.h:301
VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
Definition: interface.h:537
hash_get
#define hash_get(h, key)
Definition: hash.h:249
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
foreach_eal_single_hyphen_arg
#define foreach_eal_single_hyphen_arg
Definition: dpdk_priv.h:40
dpdk_device_t::device_index
u32 device_index
Definition: dpdk.h:190
dpdk_device_t::port_conf
struct rte_eth_conf port_conf
Definition: dpdk.h:218
vlib_config_function_runtime_t
Definition: init.h:68
rx_queue_funcs.h
vlib_global_main
vlib_global_main_t vlib_global_main
Definition: main.c:1786
dpdk_main_t
Definition: dpdk.h:357
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
dpdk_config_main_t::uio_driver_name
u8 * uio_driver_name
Definition: dpdk.h:303
log.h
dpdk_log_warn
#define dpdk_log_warn(...)
Definition: dpdk.h:440
VNET_HW_INTERFACE_CAP_SUPPORTS_VXLAN_TNL_GSO
@ VNET_HW_INTERFACE_CAP_SUPPORTS_VXLAN_TNL_GSO
Definition: interface.h:539
clib_bitmap_free
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
uword
u64 uword
Definition: types.h:112
dpdk_main_t::per_thread_data
dpdk_per_thread_data_t * per_thread_data
Definition: dpdk.h:362
ethernet_header_t
Definition: packet.h:52
buffer.h
vnet_hw_if_update_runtime_data
void vnet_hw_if_update_runtime_data(vnet_main_t *vnm, u32 hw_if_index)
Definition: runtime.c:58
vlib_unix_get_runtime_dir
static char * vlib_unix_get_runtime_dir(void)
Definition: unix.h:151
dpdk_device_t::tx_conf
struct rte_eth_txconf tx_conf
Definition: dpdk.h:219
VNET_DPDK_PORT_TYPE_AF_PACKET
@ VNET_DPDK_PORT_TYPE_AF_PACKET
Definition: dpdk.h:121
foreach_dpdk_device_config_item
#define foreach_dpdk_device_config_item
Definition: dpdk.h:254
vlib_thread_registration_::coremask
uword * coremask
Definition: threads.h:45
f64
double f64
Definition: types.h:142
dpdk_per_thread_data_t
Definition: dpdk.h:346
ETHERNET_INTERFACE_FLAG_MTU
#define ETHERNET_INTERFACE_FLAG_MTU
Definition: ethernet.h:165
DPDK_DEVICE_TSO_OFF
#define DPDK_DEVICE_TSO_OFF
Definition: dpdk.h:293
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
VNET_DPDK_PORT_TYPE_ETH_25G
@ VNET_DPDK_PORT_TYPE_ETH_25G
Definition: dpdk.h:115
dpdk_device_config_t::is_blacklisted
u8 is_blacklisted
Definition: dpdk.h:278
format.h
unformat_rss_fn
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:958
dpdk_device_config_t::vlan_strip_offload
u8 vlan_strip_offload
Definition: dpdk.h:279
dpdk_config_main_t::nchannels
u32 nchannels
Definition: dpdk.h:320
vlib_pci_get_device_info
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
dpdk_enable_l4_csum_offload
static void dpdk_enable_l4_csum_offload(dpdk_device_t *xd)
Definition: init.c:196
dpdk_main_t::conf
dpdk_config_main_t * conf
Definition: dpdk.h:380
VNET_DEV_ADDR_ANY
@ VNET_DEV_ADDR_ANY
Definition: dpdk.h:266
clib_bitmap_set
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
dpdk_flag_change
static u32 dpdk_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
Definition: init.c:114
clib_min
#define clib_min(x, y)
Definition: clib.h:342
STATIC_ASSERT
#define STATIC_ASSERT(truth,...)
Definition: error_bootstrap.h:111
dpdk_device_t::tx_q_used
u16 tx_q_used
Definition: dpdk.h:199
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
VNET_DPDK_PORT_TYPE_ETH_50G
@ VNET_DPDK_PORT_TYPE_ETH_50G
Definition: dpdk.h:117
unformat_vlib_cli_sub_input
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
Definition: cli.c:163
dpdk_device_t::nb_rx_desc
u16 nb_rx_desc
Definition: dpdk.h:209
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_global_main_t::elog_main
elog_main_t elog_main
Definition: main.h:302
DPDK_LINK_POLL_INTERVAL
#define DPDK_LINK_POLL_INTERVAL
Definition: dpdk.h:251
dpdk_device_t::name
u8 * name
Definition: dpdk.h:211
format_dpdk_rss_hf_name
format_function_t format_dpdk_rss_hf_name
Definition: dpdk.h:485
dpdk_device_config_t::rss_queues
clib_bitmap_t * rss_queues
Definition: dpdk.h:290
vec_add2_aligned
#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:656
dpdk_device_t::af_packet_instance_num
u16 af_packet_instance_num
Definition: dpdk.h:230
dpdk_device_config_t::devargs
u8 * devargs
Definition: dpdk.h:289
dpdk_bind_vmbus_devices_to_uio
static void dpdk_bind_vmbus_devices_to_uio(dpdk_config_main_t *conf)
Definition: init.c:1123
VNET_DPDK_PORT_TYPE_ETH_56G
@ VNET_DPDK_PORT_TYPE_ETH_56G
Definition: dpdk.h:118
vnet_device_main_t::first_worker_thread_index
uword first_worker_thread_index
Definition: devices.h:63
vlib_vmbus_get_all_dev_addrs
vlib_vmbus_addr_t * vlib_vmbus_get_all_dev_addrs()
Definition: vmbus.c:390
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
VNET_DEV_ADDR_PCI
@ VNET_DEV_ADDR_PCI
Definition: dpdk.h:264
dpdk_log_err
#define dpdk_log_err(...)
Definition: dpdk.h:438
vlib_thread_main_t::registrations
vlib_thread_registration_t ** registrations
Definition: threads.h:249
VNET_DPDK_PORT_TYPE_VHOST_ETHER
@ VNET_DPDK_PORT_TYPE_VHOST_ETHER
Definition: dpdk.h:124
format_vlib_pci_addr
format_function_t format_vlib_pci_addr
Definition: pci.h:326
u64
unsigned long u64
Definition: types.h:89
i8
signed char i8
Definition: types.h:45
vlib_process_wait_for_event_or_clock
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:755
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
dpdk_main_t::log_default
vlib_log_class_t log_default
Definition: dpdk.h:386
dpdk_device_t::link
struct rte_eth_link link
Definition: dpdk.h:232
dpdk_config_main_t
Definition: dpdk.h:297
dpdk_main_t::admin_up_down_in_progress
u8 admin_up_down_in_progress
Definition: dpdk.h:371
vnet_get_hw_sw_interface
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:72
vlib_pci_device_info::vendor_id
u16 vendor_id
Definition: pci.h:73
u32
unsigned int u32
Definition: types.h:88
DPDK_NB_TX_DESC_DEFAULT
#define DPDK_NB_TX_DESC_DEFAULT
Definition: dpdk_priv.h:17
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
dpdk_config_main_t::num_crypto_mbufs
u32 num_crypto_mbufs
Definition: dpdk.h:321
dpdk_config_main_t::dev_confs
dpdk_device_config_t * dev_confs
Definition: dpdk.h:331
vlib_thread_main_t
Definition: threads.h:243
VNET_DEV_ADDR_VMBUS
@ VNET_DEV_ADDR_VMBUS
Definition: dpdk.h:265
dpdk_device_t::cpu_socket
i8 cpu_socket
Definition: dpdk.h:205
VNET_DPDK_PORT_TYPE_ETH_20G
@ VNET_DPDK_PORT_TYPE_ETH_20G
Definition: dpdk.h:114
DPDK_DEVICE_VLAN_STRIP_OFF
#define DPDK_DEVICE_VLAN_STRIP_OFF
Definition: dpdk.h:281
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
dpdk_main_t::stat_poll_interval
f64 stat_poll_interval
Definition: dpdk.h:375
pci.h
dpdk_device_t::interface_name_suffix
u8 * interface_name_suffix
Definition: dpdk.h:212
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
clib_error_return_unix
#define clib_error_return_unix(e, args...)
Definition: error.h:102
PCI_CLASS_NETWORK_ETHERNET
@ PCI_CLASS_NETWORK_ETHERNET
Definition: pci_config.h:59
dpdk_device_config_t::workers
foreach_dpdk_device_config_item clib_bitmap_t * workers
Definition: dpdk.h:287
clib_file_add
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
vec_resize
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
Definition: vec.h:296
dpdk_config_main_t::enable_lro
u8 enable_lro
Definition: dpdk.h:305
dpdk_device_t::pmd
dpdk_pmd_t pmd
Definition: dpdk.h:204
vec.h
dpdk_main_t::vlib_main
vlib_main_t * vlib_main
Definition: dpdk.h:378
now
f64 now
Definition: nat44_ei_out2in.c:710
VNET_DPDK_PORT_TYPE_FAILSAFE
@ VNET_DPDK_PORT_TYPE_FAILSAFE
Definition: dpdk.h:125
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
dpdk_main_t::link_state_poll_interval
f64 link_state_poll_interval
Definition: dpdk.h:374
dpdk_main
dpdk_main_t dpdk_main
Definition: init.c:48
vnet_hw_if_register_rx_queue
u32 vnet_hw_if_register_rx_queue(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, u32 thread_index)
Definition: rx_queue.c:64
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
dpdk_config_main_t::device_config_index_by_vmbus_addr
mhash_t device_config_index_by_vmbus_addr
Definition: dpdk.h:333
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vnet_hw_interface_set_flags
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:513
cryptodev.h
unix.h
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
VNET_DPDK_PORT_TYPE_ETH_2_5G
@ VNET_DPDK_PORT_TYPE_ETH_2_5G
Definition: dpdk.h:111
frame_queue_trace_t
Definition: node.h:763
VIRTIO_PCI_MODERN_DEVICEID_NET
#define VIRTIO_PCI_MODERN_DEVICEID_NET
Definition: pci_config.h:169
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_CKSUM
Definition: interface.h:523
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
dpdk_main_t::log_cryptodev
vlib_log_class_t log_cryptodev
Definition: dpdk.h:387
ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:162
vec_terminate_c_string
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1132
i
int i
Definition: flowhash_template.h:376
ETHERNET_MAX_PACKET_BYTES
#define ETHERNET_MAX_PACKET_BYTES
Definition: ethernet.h:132
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM
Definition: interface.h:525
DPDK_DEVICE_VLAN_STRIP_ON
#define DPDK_DEVICE_VLAN_STRIP_ON
Definition: dpdk.h:282
vlib_vmbus_addr_t
Definition: vmbus.h:24
VNET_DPDK_PORT_TYPE_ETH_100G
@ VNET_DPDK_PORT_TYPE_ETH_100G
Definition: dpdk.h:119
DPDK_MAX_LRO_SIZE_DEFAULT
#define DPDK_MAX_LRO_SIZE_DEFAULT
Definition: dpdk_priv.h:18
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
LINK_STATE_ELOGS
#define LINK_STATE_ELOGS
Definition: init.c:51
format_bitmap_hex
__clib_export u8 * format_bitmap_hex(u8 *s, va_list *args)
Format a bitmap as a string of hex bytes.
Definition: bitmap.c:107
port_type_from_link_speed
static dpdk_port_type_t port_type_from_link_speed(u32 link_speed)
Definition: init.c:84
VNET_DPDK_PORT_TYPE_ETH_VF
@ VNET_DPDK_PORT_TYPE_ETH_VF
Definition: dpdk.h:122
dpdk_device_t::nb_tx_desc
u16 nb_tx_desc
Definition: dpdk.h:208
dpdk_config_main_t::default_devconf
dpdk_device_config_t default_devconf
Definition: dpdk.h:330
ELOG_DATA
#define ELOG_DATA(em, f)
Definition: elog.h:484
DPDK_NB_RX_DESC_DEFAULT
#define DPDK_NB_RX_DESC_DEFAULT
Definition: dpdk_priv.h:16
dpdk_device_config_t::dev_addr_type
dpdk_device_addr_type_t dev_addr_type
Definition: dpdk.h:276
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
vlib_pci_device_info::device_id
u16 device_id
Definition: pci.h:74
vnet.h
VNET_HW_INTERFACE_FLAG_HALF_DUPLEX
@ VNET_HW_INTERFACE_FLAG_HALF_DUPLEX
Definition: interface.h:511
VNET_DPDK_PORT_TYPE_ETH_SWITCH
@ VNET_DPDK_PORT_TYPE_ETH_SWITCH
Definition: dpdk.h:120
clib_bitmap_foreach
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
vlib_node_runtime_t
Definition: node.h:454
DPDK_MAX_SIMD_BITWIDTH_256
#define DPDK_MAX_SIMD_BITWIDTH_256
Definition: dpdk.h:313
vlib_thread_registration_
Definition: threads.h:27
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM
#define VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM
Definition: interface.h:559
vlib_pci_free_device_info
static void vlib_pci_free_device_info(vlib_pci_device_info_t *di)
Definition: pci.h:114
dpdk_update_counters
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:99
dpdk_config_main_t::enable_tcp_udp_checksum
u8 enable_tcp_udp_checksum
Definition: dpdk.h:306
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
vnet_hw_interface_is_link_up
static uword vnet_hw_interface_is_link_up(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:324
vlib_vmbus_bind_to_uio
clib_error_t * vlib_vmbus_bind_to_uio(vlib_vmbus_addr_t *addr)
Definition: vmbus.c:213
dpdk_device_config_t::name
u8 * name
Definition: dpdk.h:277
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
di
void di(unformat_input_t *i)
Definition: unformat.c:163
hash_create
#define hash_create(elts, value_bytes)
Definition: hash.h:695
unformat_line
unformat_function_t unformat_line
Definition: format.h:272
dpdk_device_config_t
Definition: dpdk.h:269
format_dpdk_device_name
format_function_t format_dpdk_device_name
Definition: dpdk.h:477
dpdk_config_main_t::blacklist_by_pci_vendor_and_device
u32 * blacklist_by_pci_vendor_and_device
Definition: dpdk.h:336
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
vnet_device_main_t
Definition: devices.h:60
dpdk_rx_queue_t::queue_index
u32 queue_index
Definition: dpdk.h:171
vlib_pci_device_info::device_class
u16 device_class
Definition: pci.h:72
dpdk_device_t::sw_if_index
u32 sw_if_index
Definition: dpdk.h:193
dpdk_buffer_pools_create
clib_error_t * dpdk_buffer_pools_create(vlib_main_t *vm)
Definition: buffer.c:438
dpdk_config_main_t::max_simd_bitwidth
u16 max_simd_bitwidth
Definition: dpdk.h:310
unformat_bitmap_list
__clib_export 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.c:55
vec_insert
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header,...
Definition: vec.h:775
bus
u8 bus
Definition: pci_types.api:21
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_OUTER_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_OUTER_CKSUM
Definition: interface.h:526
ethernet_register_interface
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:348
dpdk_port_type_t
dpdk_port_type_t
Definition: dpdk.h:108
dpdk_priv.h
vnet_hw_if_set_input_node
void vnet_hw_if_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: rx_queue.c:157
dpdk_process_node
static vlib_node_registration_t dpdk_process_node
(constructor) VLIB_REGISTER_NODE (dpdk_process_node)
Definition: init.c:1961
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
mhash_set
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
Definition: mhash.h:117
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
DPDK_STATS_POLL_INTERVAL
#define DPDK_STATS_POLL_INTERVAL
Definition: dpdk.h:248
dpdk_device_t::rx_queues
dpdk_rx_queue_t * rx_queues
Definition: dpdk.h:186
dpdk_per_thread_data_t::buffer_template
vlib_buffer_t buffer_template
Definition: dpdk.h:354
dpdk_init
static clib_error_t * dpdk_init(vlib_main_t *vm)
Definition: init.c:1970
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
unformat_vlib_vmbus_addr
unformat_function_t unformat_vlib_vmbus_addr
Definition: vmbus.h:39
dpdk_device_config
static clib_error_t * dpdk_device_config(dpdk_config_main_t *conf, void *addr, dpdk_device_addr_type_t addr_type, unformat_input_t *input, u8 is_default)
Definition: init.c:1220
dpdk_device_t
Definition: dpdk.h:182
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105