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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
21 #include <vnet/ethernet/ethernet.h>
22 #include <vnet/devices/dpdk/dpdk.h>
23 #include <vlib/unix/physmem.h>
24 #include <vlib/pci/pci.h>
25 #include <vlib/unix/pci.h>
31 #include <sys/mount.h>
35 #include "dpdk_priv.h"
37 dpdk_main_t dpdk_main;
39 /* force linker to link functions used by vlib and declared weak */
40 void *vlib_weakly_linked_functions[] = {
42 &rte_pktmbuf_pool_init,
45 #define LINK_STATE_ELOGS 0
47 #define DEFAULT_HUGE_DIR "/run/vpp/hugepages"
48 #define VPP_RUN_DIR "/run/vpp"
50 /* Port configuration, mildly modified Intel app values */
52 static struct rte_eth_conf port_conf_template = {
55 .header_split = 0, /**< Header Split disabled */
56 .hw_ip_checksum = 0, /**< IP checksum offload disabled */
57 .hw_vlan_filter = 0, /**< VLAN filtering disabled */
58 .hw_strip_crc = 1, /**< CRC stripped by hardware */
61 .mq_mode = ETH_MQ_TX_NONE,
66 dpdk_port_setup (dpdk_main_t * dm, dpdk_device_t * xd)
68 vlib_main_t * vm = vlib_get_main();
69 vlib_buffer_main_t * bm = vm->buffer_main;
73 ASSERT(os_get_cpu_number() == 0);
76 vnet_hw_interface_set_flags (dm->vnet_main, xd->vlib_hw_if_index, 0);
77 rte_eth_dev_stop (xd->device_index);
80 rv = rte_eth_dev_configure (xd->device_index, xd->rx_q_used,
81 xd->tx_q_used, &xd->port_conf);
84 return clib_error_return (0, "rte_eth_dev_configure[%d]: err %d",
85 xd->device_index, rv);
87 /* Set up one TX-queue per worker thread */
88 for (j = 0; j < xd->tx_q_used; j++)
90 rv = rte_eth_tx_queue_setup(xd->device_index, j, xd->nb_tx_desc,
91 xd->cpu_socket, &xd->tx_conf);
97 return clib_error_return (0, "rte_eth_tx_queue_setup[%d]: err %d",
98 xd->device_index, rv);
100 for (j = 0; j < xd->rx_q_used; j++)
103 rv = rte_eth_rx_queue_setup(xd->device_index, j, xd->nb_rx_desc,
105 bm->pktmbuf_pools[xd->cpu_socket_id_by_queue[j]]);
107 return clib_error_return (0, "rte_eth_rx_queue_setup[%d]: err %d",
108 xd->device_index, rv);
112 rte_eth_dev_start (xd->device_index);
117 static u32 dpdk_flag_change (vnet_main_t * vnm,
118 vnet_hw_interface_t * hi,
121 dpdk_main_t * dm = &dpdk_main;
122 dpdk_device_t * xd = vec_elt_at_index (dm->devices, hi->dev_instance);
125 if (ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags))
128 xd->promisc = flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL;
133 rte_eth_promiscuous_enable(xd->device_index);
135 rte_eth_promiscuous_disable(xd->device_index);
138 else if (ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags))
141 * DAW-FIXME: The Cisco VIC firmware does not provide an api for a
142 * driver to dynamically change the mtu. If/when the
143 * VIC firmware gets fixed, then this should be removed.
145 if (xd->pmd == VNET_DPDK_PMD_VICE ||
146 xd->pmd == VNET_DPDK_PMD_ENIC)
148 struct rte_eth_dev_info dev_info;
151 * Restore mtu to what has been set by CIMC in the firmware cfg.
153 rte_eth_dev_info_get(xd->device_index, &dev_info);
154 hi->max_packet_bytes = dev_info.max_rx_pktlen;
156 vlib_cli_output (vlib_get_main(),
157 "Cisco VIC mtu can only be changed "
158 "using CIMC then rebooting the server!");
164 xd->port_conf.rxmode.max_rx_pkt_len = hi->max_packet_bytes;
167 rte_eth_dev_stop (xd->device_index);
169 rv = rte_eth_dev_configure
176 vlib_cli_output (vlib_get_main(),
177 "rte_eth_dev_configure[%d]: err %d",
178 xd->device_index, rv);
180 rte_eth_dev_set_mtu(xd->device_index, hi->max_packet_bytes);
183 rte_eth_dev_start (xd->device_index);
190 extern int rte_netmap_probe(void);
194 dpdk_device_lock_init(dpdk_device_t * xd)
197 vec_validate(xd->lockp, xd->tx_q_used - 1);
198 for (q = 0; q < xd->tx_q_used; q++)
200 xd->lockp[q] = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES,
201 CLIB_CACHE_LINE_BYTES);
202 memset ((void *) xd->lockp[q], 0, CLIB_CACHE_LINE_BYTES);
208 dpdk_device_lock_free(dpdk_device_t * xd)
212 for (q = 0; q < vec_len(xd->lockp); q++)
213 clib_mem_free((void *) xd->lockp[q]);
219 static clib_error_t *
220 dpdk_lib_init (dpdk_main_t * dm)
225 clib_error_t * error;
226 vlib_main_t * vm = vlib_get_main();
227 vlib_thread_main_t * tm = vlib_get_thread_main();
228 vnet_sw_interface_t * sw;
229 vnet_hw_interface_t * hi;
231 vlib_thread_registration_t * tr;
235 u8 af_packet_port_id = 0;
237 dm->input_cpu_first_index = 0;
238 dm->input_cpu_count = 1;
240 /* find out which cpus will be used for input */
241 p = hash_get_mem (tm->thread_registrations_by_name, "io");
242 tr = p ? (vlib_thread_registration_t *) p[0] : 0;
244 if (!tr || tr->count == 0)
246 /* no io threads, workers doing input */
247 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
248 tr = p ? (vlib_thread_registration_t *) p[0] : 0;
252 dm->have_io_threads = 1;
255 if (tr && tr->count > 0)
257 dm->input_cpu_first_index = tr->first_index;
258 dm->input_cpu_count = tr->count;
261 vec_validate_aligned (dm->devices_by_cpu, tm->n_vlib_mains - 1,
262 CLIB_CACHE_LINE_BYTES);
264 vec_validate_aligned (dm->workers, tm->n_vlib_mains - 1,
265 CLIB_CACHE_LINE_BYTES);
268 if(rte_netmap_probe() < 0)
269 return clib_error_return (0, "rte netmap probe failed");
272 nports = rte_eth_dev_count();
275 clib_warning ("DPDK drivers found no ports...");
279 clib_warning ("DPDK drivers found %d ports...", nports);
282 * All buffers are all allocated from the same rte_mempool.
283 * Thus they all have the same number of data bytes.
285 dm->vlib_buffer_free_list_index =
286 vlib_buffer_get_or_create_free_list (
287 vm, VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES, "dpdk rx");
289 for (i = 0; i < nports; i++)
293 struct rte_eth_dev_info dev_info;
295 struct rte_eth_link l;
297 /* Create vnet interface */
298 vec_add2_aligned (dm->devices, xd, 1, CLIB_CACHE_LINE_BYTES);
299 xd->nb_rx_desc = DPDK_NB_RX_DESC_DEFAULT;
300 xd->nb_tx_desc = DPDK_NB_TX_DESC_DEFAULT;
301 xd->cpu_socket = (i8) rte_eth_dev_socket_id(i);
302 rte_eth_dev_info_get(i, &dev_info);
304 memcpy(&xd->tx_conf, &dev_info.default_txconf,
305 sizeof(struct rte_eth_txconf));
306 if (dm->no_multi_seg)
308 xd->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
309 port_conf_template.rxmode.jumbo_frame = 0;
313 xd->tx_conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
314 port_conf_template.rxmode.jumbo_frame = 1;
317 memcpy(&xd->port_conf, &port_conf_template, sizeof(struct rte_eth_conf));
319 xd->tx_q_used = clib_min(dev_info.max_tx_queues, tm->n_vlib_mains);
321 if (dm->max_tx_queues)
322 xd->tx_q_used = clib_min(xd->tx_q_used, dm->max_tx_queues);
324 if (dm->use_rss > 1 && dev_info.max_rx_queues >= dm->use_rss)
326 xd->rx_q_used = dm->use_rss;
327 xd->port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
328 xd->port_conf.rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
333 xd->dev_type = VNET_DPDK_DEV_ETH;
335 /* workaround for drivers not setting driver_name */
336 if (!dev_info.driver_name)
337 dev_info.driver_name = dev_info.pci_dev->driver->name;
338 ASSERT(dev_info.driver_name);
343 #define _(s,f) else if (!strcmp(dev_info.driver_name, s)) \
344 xd->pmd = VNET_DPDK_PMD_##f;
350 xd->pmd = VNET_DPDK_PMD_UNKNOWN;
355 case VNET_DPDK_PMD_E1000EM:
356 case VNET_DPDK_PMD_IGB:
357 case VNET_DPDK_PMD_IGBVF:
358 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_1G;
362 case VNET_DPDK_PMD_IXGBE:
363 case VNET_DPDK_PMD_IXGBEVF:
364 case VNET_DPDK_PMD_THUNDERX:
365 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
366 xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE;
367 xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE;
371 case VNET_DPDK_PMD_VICE:
372 case VNET_DPDK_PMD_ENIC:
373 rte_eth_link_get_nowait(i, &l);
374 if (l.link_speed == 40000)
376 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
377 xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE;
378 xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE;
382 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
383 xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE;
384 xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE;
388 /* Intel Fortville */
389 case VNET_DPDK_PMD_I40E:
390 case VNET_DPDK_PMD_I40EVF:
391 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
392 xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE;
393 xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE;
395 switch (dev_info.pci_dev->id.device_id) {
396 case I40E_DEV_ID_10G_BASE_T:
397 case I40E_DEV_ID_SFP_XL710:
398 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
400 case I40E_DEV_ID_QSFP_A:
401 case I40E_DEV_ID_QSFP_B:
402 case I40E_DEV_ID_QSFP_C:
403 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
406 rte_eth_link_get_nowait(i, &l);
407 xd->port_type = l.link_speed == 10000 ?
408 VNET_DPDK_PORT_TYPE_ETH_10G : VNET_DPDK_PORT_TYPE_ETH_40G;
411 xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN;
415 case VNET_DPDK_PMD_CXGBE:
416 switch (dev_info.pci_dev->id.device_id) {
417 case 0x5410: /* T580-LP-cr */
418 xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE;
419 xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE;
420 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
423 xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE;
424 xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE;
425 xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN;
429 /* Intel Red Rock Canyon */
430 case VNET_DPDK_PMD_FM10K:
431 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_SWITCH;
432 xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE;
433 xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE;
437 case VNET_DPDK_PMD_VIRTIO:
438 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_1G;
439 xd->nb_rx_desc = DPDK_NB_RX_DESC_VIRTIO;
440 xd->nb_tx_desc = DPDK_NB_TX_DESC_VIRTIO;
444 case VNET_DPDK_PMD_VMXNET3:
445 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_1G;
446 xd->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
449 case VNET_DPDK_PMD_AF_PACKET:
450 xd->port_type = VNET_DPDK_PORT_TYPE_AF_PACKET;
451 xd->af_packet_port_id = af_packet_port_id++;
454 case VNET_DPDK_PMD_BOND:
455 xd->port_type = VNET_DPDK_PORT_TYPE_ETH_BOND;
459 xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN;
463 if(strncmp(dev_info.driver_name, "vale", 4) == 0
464 || strncmp(dev_info.driver_name, "netmap", 6) == 0)
466 xd->pmd = VNET_DPDK_PMD_NETMAP;
467 xd->port_type = VNET_DPDK_PORT_TYPE_NETMAP;
474 * Ensure default mtu is not > the mtu read from the hardware.
475 * Otherwise rte_eth_dev_configure() will fail and the port will
478 if (ETHERNET_MAX_PACKET_BYTES > dev_info.max_rx_pktlen)
481 * This device does not support the platforms's max frame
482 * size. Use it's advertised mru instead.
484 xd->port_conf.rxmode.max_rx_pkt_len = dev_info.max_rx_pktlen;
488 xd->port_conf.rxmode.max_rx_pkt_len = ETHERNET_MAX_PACKET_BYTES;
491 * Some platforms do not account for Ethernet FCS (4 bytes) in
492 * MTU calculations. To interop with them increase mru but only
493 * if the device's settings can support it.
495 if ((dev_info.max_rx_pktlen >= (ETHERNET_MAX_PACKET_BYTES + 4)) &&
496 xd->port_conf.rxmode.hw_strip_crc)
499 * Allow additional 4 bytes (for Ethernet FCS). These bytes are
500 * stripped by h/w and so will not consume any buffer memory.
502 xd->port_conf.rxmode.max_rx_pkt_len += 4;
507 * DAW-FIXME: VMXNET3 driver doesn't support jumbo / multi-buffer pkts
509 if (xd->pmd == VNET_DPDK_PMD_VMXNET3)
511 xd->port_conf.rxmode.max_rx_pkt_len = 1518;
512 xd->port_conf.rxmode.jumbo_frame = 0;
515 if (xd->pmd == VNET_DPDK_PMD_AF_PACKET)
517 f64 now = vlib_time_now(vm);
519 rnd = (u32) (now * 1e6);
520 rnd = random_u32 (&rnd);
521 memcpy (addr+2, &rnd, sizeof(rnd));
526 rte_eth_macaddr_get(i,(struct ether_addr *)addr);
528 if (xd->tx_q_used < tm->n_vlib_mains)
529 dpdk_device_lock_init(xd);
531 xd->device_index = xd - dm->devices;
532 ASSERT(i == xd->device_index);
533 xd->per_interface_next_index = ~0;
535 /* assign interface to input thread */
536 dpdk_device_and_queue_t * dq;
539 for (q = 0; q < xd->rx_q_used; q++)
541 int cpu = dm->input_cpu_first_index + next_cpu;
542 unsigned lcore = vlib_worker_threads[cpu].dpdk_lcore_id;
545 * numa node for worker thread handling this queue
546 * needed for taking buffers from the right mempool
548 vec_validate(xd->cpu_socket_id_by_queue, q);
549 xd->cpu_socket_id_by_queue[q] = rte_lcore_to_socket_id(lcore);
552 * construct vector of (device,queue) pairs for each worker thread
554 vec_add2(dm->devices_by_cpu[cpu], dq, 1);
555 dq->device = xd->device_index;
559 if (next_cpu == dm->input_cpu_count)
563 vec_validate_aligned (xd->tx_vectors, tm->n_vlib_mains,
564 CLIB_CACHE_LINE_BYTES);
565 for (j = 0; j < tm->n_vlib_mains; j++)
567 vec_validate_ha (xd->tx_vectors[j], DPDK_TX_RING_SIZE,
568 sizeof(tx_ring_hdr_t), CLIB_CACHE_LINE_BYTES);
569 vec_reset_length (xd->tx_vectors[j]);
572 vec_validate_aligned (xd->rx_vectors, xd->rx_q_used,
573 CLIB_CACHE_LINE_BYTES);
574 for (j = 0; j< xd->rx_q_used; j++)
576 vec_validate_aligned (xd->rx_vectors[j], VLIB_FRAME_SIZE-1,
577 CLIB_CACHE_LINE_BYTES);
578 vec_reset_length (xd->rx_vectors[j]);
581 vec_validate_aligned (xd->frames, tm->n_vlib_mains,
582 CLIB_CACHE_LINE_BYTES);
584 rv = dpdk_port_setup(dm, xd);
589 /* count the number of descriptors used for this device */
590 nb_desc += xd->nb_rx_desc + xd->nb_tx_desc * xd->tx_q_used;
592 error = ethernet_register_interface
594 dpdk_device_class.index,
596 /* ethernet address */ addr,
597 &xd->vlib_hw_if_index,
602 sw = vnet_get_hw_sw_interface (dm->vnet_main, xd->vlib_hw_if_index);
603 xd->vlib_sw_if_index = sw->sw_if_index;
604 hi = vnet_get_hw_interface (dm->vnet_main, xd->vlib_hw_if_index);
607 * DAW-FIXME: The Cisco VIC firmware does not provide an api for a
608 * driver to dynamically change the mtu. If/when the
609 * VIC firmware gets fixed, then this should be removed.
611 if (xd->pmd == VNET_DPDK_PMD_VICE ||
612 xd->pmd == VNET_DPDK_PMD_ENIC)
615 * Initialize mtu to what has been set by CIMC in the firmware cfg.
617 hi->max_packet_bytes = dev_info.max_rx_pktlen;
619 * remove vlan tag from VIC port to fix VLAN0 issue.
620 * TODO Handle VLAN tagged traffic
623 vlan_off = rte_eth_dev_get_vlan_offload(xd->device_index);
624 vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
625 rte_eth_dev_set_vlan_offload(xd->device_index, vlan_off);
628 * DAW-FIXME: VMXNET3 driver doesn't support jumbo / multi-buffer pkts
630 else if (xd->pmd == VNET_DPDK_PMD_VMXNET3)
631 hi->max_packet_bytes = 1518;
633 hi->max_l3_packet_bytes[VLIB_RX] = hi->max_l3_packet_bytes[VLIB_TX] =
634 xd->port_conf.rxmode.max_rx_pkt_len - sizeof(ethernet_header_t);
636 rte_eth_dev_set_mtu(xd->device_index, hi->max_packet_bytes);
639 #ifdef RTE_LIBRTE_KNI
641 clib_warning("Initializing KNI interfaces...");
642 rte_kni_init(dm->num_kni);
643 for (i = 0; i < dm->num_kni; i++)
648 /* Create vnet interface */
649 vec_add2_aligned (dm->devices, xd, 1, CLIB_CACHE_LINE_BYTES);
650 xd->dev_type = VNET_DPDK_DEV_KNI;
652 xd->device_index = xd - dm->devices;
653 ASSERT(nports + i == xd->device_index);
654 xd->per_interface_next_index = ~0;
657 hash_set (dm->dpdk_device_by_kni_port_id, i, xd - dm->devices);
660 /* assign interface to input thread */
661 dpdk_device_and_queue_t * dq;
662 vec_add2(dm->devices_by_cpu[dm->input_cpu_first_index], dq, 1);
663 dq->device = xd->device_index;
666 vec_validate_aligned (xd->tx_vectors, tm->n_vlib_mains,
667 CLIB_CACHE_LINE_BYTES);
668 for (j = 0; j < tm->n_vlib_mains; j++)
670 vec_validate_ha (xd->tx_vectors[j], DPDK_TX_RING_SIZE,
671 sizeof(tx_ring_hdr_t), CLIB_CACHE_LINE_BYTES);
672 vec_reset_length (xd->tx_vectors[j]);
675 vec_validate_aligned (xd->rx_vectors, xd->rx_q_used,
676 CLIB_CACHE_LINE_BYTES);
677 for (j = 0; j< xd->rx_q_used; j++)
679 vec_validate_aligned (xd->rx_vectors[j], VLIB_FRAME_SIZE-1,
680 CLIB_CACHE_LINE_BYTES);
681 vec_reset_length (xd->rx_vectors[j]);
684 vec_validate_aligned (xd->frames, tm->n_vlib_mains,
685 CLIB_CACHE_LINE_BYTES);
687 /* FIXME Set up one TX-queue per worker thread */
690 f64 now = vlib_time_now(vm);
692 rnd = (u32) (now * 1e6);
693 rnd = random_u32 (&rnd);
695 memcpy (addr+2, &rnd, sizeof(rnd));
700 error = ethernet_register_interface
702 dpdk_device_class.index,
704 /* ethernet address */ addr,
705 &xd->vlib_hw_if_index,
711 sw = vnet_get_hw_sw_interface (dm->vnet_main, xd->vlib_hw_if_index);
712 xd->vlib_sw_if_index = sw->sw_if_index;
713 hi = vnet_get_hw_interface (dm->vnet_main, xd->vlib_hw_if_index);
718 if (nb_desc > dm->num_mbufs)
719 clib_warning ("%d mbufs allocated but total rx/tx ring size is %d\n",
720 dm->num_mbufs, nb_desc);
722 /* init next vhost-user if index */
723 dm->next_vu_if_id = 0;
729 dpdk_bind_devices_to_uio (dpdk_main_t * dm)
731 linux_pci_main_t * pm = &linux_pci_main;
732 clib_error_t * error;
733 vlib_pci_device_t * d;
734 pci_config_header_t * c;
737 pool_foreach (d, pm->pci_devs, ({
738 c = &d->config0.header;
739 vec_reset_length (pci_addr);
740 pci_addr = format (pci_addr, "%U%c", format_vlib_pci_addr, &d->bus_address, 0);
742 if (c->device_class != PCI_CLASS_NETWORK_ETHERNET)
745 /* if whitelist exists process only whitelisted devices */
746 if (dm->eth_if_whitelist &&
747 !strstr ((char *) dm->eth_if_whitelist, (char *) pci_addr))
751 if (c->vendor_id == 0x1af4 && c->device_id == 0x1000)
754 else if (c->vendor_id == 0x15ad && c->device_id == 0x07b0)
756 /* all Intel devices */
757 else if (c->vendor_id == 0x8086)
760 else if (c->vendor_id == 0x1137 && c->device_id == 0x0043)
763 else if (c->vendor_id == 0x1425 && (c->device_id & 0xe000) == 0x4000)
767 clib_warning ("Unsupported Ethernet PCI device 0x%04x:0x%04x found "
768 "at PCI address %s\n", (u16) c->vendor_id, (u16) c->device_id,
773 error = vlib_pci_bind_to_uio (d, (char *) dm->uio_driver_name);
777 if (!dm->eth_if_whitelist)
778 dm->eth_if_blacklist = format (dm->eth_if_blacklist, "%U ",
779 format_vlib_pci_addr, &d->bus_address);
780 clib_error_report (error);
786 static clib_error_t *
787 dpdk_config (vlib_main_t * vm, unformat_input_t * input)
789 clib_error_t * error = 0;
790 dpdk_main_t * dm = &dpdk_main;
791 vlib_thread_main_t * tm = vlib_get_thread_main();
794 u8 * rte_cmd = 0, * ethname = 0;
799 int rxrings, txrings, rxslots, txslots, txburst;
802 unformat_input_t _in;
803 unformat_input_t * in = &_in;
810 // MATT-FIXME: inverted virtio-vhost logic to use virtio by default
811 dm->use_virtio_vhost = 1;
813 while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT)
816 if (unformat (input, "no-hugetlb"))
818 vec_add1 (dm->eal_init_args, (u8 *) "no-huge");
822 else if (unformat (input, "enable-tcp-udp-checksum"))
824 dm->buffer_flags_template &=
825 ~(IP_BUFFER_L4_CHECKSUM_CORRECT | IP_BUFFER_L4_CHECKSUM_COMPUTED);
828 else if (unformat (input, "decimal-interface-names"))
829 dm->interface_name_format_decimal = 1;
831 else if (unformat (input, "no-multi-seg"))
832 dm->no_multi_seg = 1;
834 else if (unformat (input, "dev %s", &pci_dev_id))
836 if (dm->eth_if_whitelist)
839 * Don't add duplicate device id's.
841 if (strstr ((char *)dm->eth_if_whitelist, (char *)pci_dev_id))
844 _vec_len (dm->eth_if_whitelist) -= 1; // chomp trailing NULL.
845 dm->eth_if_whitelist = format (dm->eth_if_whitelist, " %s%c",
849 dm->eth_if_whitelist = format (0, "%s%c", pci_dev_id, 0);
853 else if (unformat(input, "netmap %s/%d:%d/%d:%d/%d",
854 &nmname, &rxrings, &rxslots, &txrings, &txslots, &txburst)) {
857 eth_nm_args(nmname, rxrings, rxslots, txrings, txslots, txburst);
859 error = clib_error_return (0, "%s", rv);
862 }else if (unformat(input, "netmap %s", &nmname)) {
865 eth_nm_args(nmname, 0, 0, 0, 0, 0);
867 error = clib_error_return (0, "%s", rv);
873 else if (unformat (input, "num-mbufs %d", &dm->num_mbufs))
875 else if (unformat (input, "max-tx-queues %d", &dm->max_tx_queues))
877 else if (unformat (input, "kni %d", &dm->num_kni))
879 else if (unformat (input, "uio-driver %s", &dm->uio_driver_name))
881 else if (unformat (input, "socket-mem %s", &socket_mem))
883 else if (unformat (input, "vhost-user-coalesce-frames %d", &dm->vhost_coalesce_frames))
885 else if (unformat (input, "vhost-user-coalesce-time %f", &dm->vhost_coalesce_time))
887 else if (unformat (input, "enable-vhost-user"))
888 dm->use_virtio_vhost = 0;
889 else if (unformat (input, "rss %d", &dm->use_rss))
893 else if (unformat(input, #a)) \
895 if (!strncmp(#a, "no-pci", 6)) \
897 tmp = format (0, "--%s%c", #a, 0); \
898 vec_add1 (dm->eal_init_args, tmp); \
900 foreach_eal_double_hyphen_predicate_arg
904 else if (unformat(input, #a " %s", &s)) \
906 if (!strncmp(#a, "huge-dir", 8)) \
908 else if (!strncmp(#a, "file-prefix", 11)) \
910 tmp = format (0, "--%s%c", #a, 0); \
911 vec_add1 (dm->eal_init_args, tmp); \
913 vec_add1 (dm->eal_init_args, s); \
915 foreach_eal_double_hyphen_arg
919 else if (unformat(input, #a " %s", &s)) \
921 tmp = format (0, "-%s%c", #b, 0); \
922 vec_add1 (dm->eal_init_args, tmp); \
924 vec_add1 (dm->eal_init_args, s); \
926 foreach_eal_single_hyphen_arg
930 else if (unformat(input, #a " %s", &s)) \
932 tmp = format (0, "-%s%c", #b, 0); \
933 vec_add1 (dm->eal_init_args, tmp); \
935 vec_add1 (dm->eal_init_args, s); \
936 dm->a##_set_manually = 1; \
938 foreach_eal_single_hyphen_mandatory_arg
941 else if (unformat(input, "default"))
946 error = clib_error_return (0, "unknown input `%U'",
947 format_unformat_error, input);
952 if (!dm->uio_driver_name)
953 dm->uio_driver_name = format (0, "igb_uio%c", 0);
956 * Use 1G huge pages if available.
958 if (!no_huge && !huge_dir)
960 u32 x, * mem_by_socket = 0;
967 umount(DEFAULT_HUGE_DIR);
969 /* Process "socket-mem" parameter value */
970 if (vec_len (socket_mem))
973 unformat_init_vector(&in, socket_mem);
974 while (unformat_check_input (&in) != UNFORMAT_END_OF_INPUT)
976 if (unformat (&in, "%u,", &x))
978 else if (unformat (&in, "%u", &x))
980 else if (unformat (&in, ","))
985 vec_add1(mem_by_socket, x);
994 clib_bitmap_foreach (c, tm->cpu_socket_bitmap, (
996 vec_validate(mem_by_socket, c);
997 mem_by_socket[c] = 512; /* default per-socket mem */
1002 /* check if available enough 1GB pages for each socket */
1003 clib_bitmap_foreach (c, tm->cpu_socket_bitmap, (
1005 u32 pages_avail, page_size, mem;
1007 char * path = "/sys/devices/system/node/node%u/hugepages/"
1008 "hugepages-%ukB/free_hugepages%c";
1010 vec_validate(mem_by_socket, c);
1011 mem = mem_by_socket[c];
1015 s = format (s, path, c, page_size * 1024, 0);
1016 read_sys_fs ((char *) s, "%u", &pages_avail);
1017 vec_reset_length (s);
1019 if (page_size * pages_avail < mem)
1024 s = format (s, path, c, page_size * 1024, 0);
1025 read_sys_fs ((char *) s, "%u", &pages_avail);
1026 vec_reset_length (s);
1028 if (page_size * pages_avail < mem)
1033 _vec_len (mem_by_socket) = c + 1;
1035 /* regenerate socket_mem string */
1036 vec_free (socket_mem);
1037 vec_foreach_index (x, mem_by_socket)
1038 socket_mem = format (socket_mem, "%s%u",
1039 socket_mem ? "," : "",
1041 socket_mem = format (socket_mem, "%c", 0);
1043 vec_free (mem_by_socket);
1045 rv = mkdir(VPP_RUN_DIR, 0755);
1046 if (rv && errno != EEXIST)
1048 error = clib_error_return (0, "mkdir '%s' failed errno %d",
1049 VPP_RUN_DIR, errno);
1053 rv = mkdir(DEFAULT_HUGE_DIR, 0755);
1054 if (rv && errno != EEXIST)
1056 error = clib_error_return (0, "mkdir '%s' failed errno %d",
1057 DEFAULT_HUGE_DIR, errno);
1061 if (use_1g && !(less_than_1g && use_2m))
1063 rv = mount("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, "pagesize=1G");
1067 rv = mount("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, NULL);
1071 return clib_error_return (0, "not enough free huge pages");
1076 error = clib_error_return (0, "mount failed %d", errno);
1080 tmp = format (0, "--huge-dir%c", 0);
1081 vec_add1 (dm->eal_init_args, tmp);
1082 tmp = format (0, "%s%c", DEFAULT_HUGE_DIR, 0);
1083 vec_add1 (dm->eal_init_args, tmp);
1086 tmp = format (0, "--file-prefix%c", 0);
1087 vec_add1 (dm->eal_init_args, tmp);
1088 tmp = format (0, "vpp%c", 0);
1089 vec_add1 (dm->eal_init_args, tmp);
1099 /* I'll bet that -c and -n must be the first and second args... */
1100 if (!dm->coremask_set_manually)
1102 vlib_thread_registration_t * tr;
1103 uword * coremask = 0;
1106 /* main thread core */
1107 coremask = clib_bitmap_set(coremask, tm->main_lcore, 1);
1109 for (i = 0; i < vec_len (tm->registrations); i++)
1111 tr = tm->registrations[i];
1112 coremask = clib_bitmap_or(coremask, tr->coremask);
1115 vec_insert (dm->eal_init_args, 2, 1);
1116 dm->eal_init_args[1] = (u8 *) "-c";
1117 tmp = format (0, "%U%c", format_bitmap_hex, coremask, 0);
1118 dm->eal_init_args[2] = tmp;
1119 clib_bitmap_free(coremask);
1122 if (!dm->nchannels_set_manually)
1124 vec_insert (dm->eal_init_args, 2, 3);
1125 dm->eal_init_args[3] = (u8 *) "-n";
1126 tmp = format (0, "%d", dm->nchannels);
1127 dm->eal_init_args[4] = tmp;
1130 if (no_pci == 0 && geteuid() == 0)
1131 dpdk_bind_devices_to_uio(dm);
1134 * If there are whitelisted devices,
1135 * add the whitelist option & device list to the dpdk arg list...
1137 if (dm->eth_if_whitelist)
1139 unformat_init_string (in, (char *)dm->eth_if_whitelist,
1140 vec_len(dm->eth_if_whitelist) - 1);
1145 * Otherwise add the blacklisted devices to the dpdk arg list.
1149 unformat_init_string (in, (char *)dm->eth_if_blacklist,
1150 vec_len(dm->eth_if_blacklist) - 1);
1154 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
1156 tmp = format (0, fmt, 0);
1157 vec_add1 (dm->eal_init_args, tmp);
1158 unformat (in, "%s", &pci_dev_id);
1159 vec_add1 (dm->eal_init_args, pci_dev_id);
1162 /* set master-lcore */
1163 tmp = format (0, "--master-lcore%c", 0);
1164 vec_add1 (dm->eal_init_args, tmp);
1165 tmp = format (0, "%u%c", tm->main_lcore, 0);
1166 vec_add1 (dm->eal_init_args, tmp);
1168 /* set socket-mem */
1169 tmp = format (0, "--socket-mem%c", 0);
1170 vec_add1 (dm->eal_init_args, tmp);
1171 tmp = format (0, "%s%c", socket_mem, 0);
1172 vec_add1 (dm->eal_init_args, tmp);
1174 /* NULL terminate the "argv" vector, in case of stupidity */
1175 vec_add1 (dm->eal_init_args, 0);
1176 _vec_len(dm->eal_init_args) -= 1;
1178 /* Set up DPDK eal and packet mbuf pool early. */
1180 log_level = (CLIB_DEBUG > 0) ? RTE_LOG_DEBUG : RTE_LOG_NOTICE;
1182 rte_set_log_level (log_level);
1186 /* make copy of args as rte_eal_init tends to mess up with arg array */
1187 for (i = 1; i < vec_len(dm->eal_init_args); i++)
1188 dm->eal_init_args_str = format(dm->eal_init_args_str, "%s ",
1189 dm->eal_init_args[i]);
1191 ret = rte_eal_init(vec_len(dm->eal_init_args), (char **) dm->eal_init_args);
1193 /* lazy umount hugepages */
1194 umount2(DEFAULT_HUGE_DIR, MNT_DETACH);
1197 return clib_error_return (0, "rte_eal_init returned %d", ret);
1199 /* Dump the physical memory layout prior to creating the mbuf_pool */
1200 fprintf(stdout, "DPDK physical memory layout:\n");
1201 rte_dump_physmem_layout(stdout);
1203 /* main thread 1st */
1204 error = vlib_buffer_pool_create(vm, dm->num_mbufs, rte_socket_id());
1208 for (i = 0; i < RTE_MAX_LCORE; i++)
1210 error = vlib_buffer_pool_create(vm, dm->num_mbufs,
1211 rte_lcore_to_socket_id(i));
1218 vlib_node_runtime_t * rt = vlib_node_get_runtime (vm, dpdk_input_node.index);
1219 rt->function = dpdk_input_rss;
1225 VLIB_CONFIG_FUNCTION (dpdk_config, "dpdk");
1227 void dpdk_update_link_state (dpdk_device_t * xd, f64 now)
1229 vnet_main_t * vnm = vnet_get_main();
1230 struct rte_eth_link prev_link = xd->link;
1232 u8 hw_flags_chg = 0;
1234 /* only update link state for PMD interfaces */
1235 if (xd->dev_type != VNET_DPDK_DEV_ETH)
1238 xd->time_last_link_update = now ? now : xd->time_last_link_update;
1239 memset(&xd->link, 0, sizeof(xd->link));
1240 rte_eth_link_get_nowait (xd->device_index, &xd->link);
1242 if (LINK_STATE_ELOGS)
1244 vlib_main_t * vm = vlib_get_main();
1245 ELOG_TYPE_DECLARE(e) = {
1247 "update-link-state: sw_if_index %d, admin_up %d,"
1248 "old link_state %d new link_state %d",
1249 .format_args = "i4i1i1i1",
1252 struct { u32 sw_if_index; u8 admin_up;
1253 u8 old_link_state; u8 new_link_state;} *ed;
1254 ed = ELOG_DATA (&vm->elog_main, e);
1255 ed->sw_if_index = xd->vlib_sw_if_index;
1256 ed->admin_up = xd->admin_up;
1257 ed->old_link_state = (u8)
1258 vnet_hw_interface_is_link_up (vnm, xd->vlib_hw_if_index);
1259 ed->new_link_state = (u8) xd->link.link_status;
1262 if ((xd->admin_up == 1) &&
1263 ((xd->link.link_status != 0) ^
1264 vnet_hw_interface_is_link_up (vnm, xd->vlib_hw_if_index)))
1267 hw_flags |= (xd->link.link_status ?
1268 VNET_HW_INTERFACE_FLAG_LINK_UP: 0);
1271 if (hw_flags_chg || (xd->link.link_duplex != prev_link.link_duplex))
1274 switch (xd->link.link_duplex)
1276 case ETH_LINK_HALF_DUPLEX:
1277 hw_flags |= VNET_HW_INTERFACE_FLAG_HALF_DUPLEX;
1279 case ETH_LINK_FULL_DUPLEX:
1280 hw_flags |= VNET_HW_INTERFACE_FLAG_FULL_DUPLEX;
1286 #if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
1287 if (hw_flags_chg || (xd->link.link_speed != prev_link.link_speed))
1290 switch (xd->link.link_speed)
1292 case ETH_SPEED_NUM_10M:
1293 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_10M;
1295 case ETH_SPEED_NUM_100M:
1296 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_100M;
1298 case ETH_SPEED_NUM_1G:
1299 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_1G;
1301 case ETH_SPEED_NUM_10G:
1302 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_10G;
1304 case ETH_SPEED_NUM_40G:
1305 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_40G;
1310 clib_warning("unknown link speed %d", xd->link.link_speed);
1315 if (hw_flags_chg || (xd->link.link_speed != prev_link.link_speed))
1318 switch (xd->link.link_speed)
1320 case ETH_LINK_SPEED_10:
1321 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_10M;
1323 case ETH_LINK_SPEED_100:
1324 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_100M;
1326 case ETH_LINK_SPEED_1000:
1327 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_1G;
1329 case ETH_LINK_SPEED_10000:
1330 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_10G;
1332 case ETH_LINK_SPEED_40G:
1333 hw_flags |= VNET_HW_INTERFACE_FLAG_SPEED_40G;
1338 clib_warning("unknown link speed %d", xd->link.link_speed);
1345 if (LINK_STATE_ELOGS)
1347 vlib_main_t * vm = vlib_get_main();
1349 ELOG_TYPE_DECLARE(e) = {
1350 .format = "update-link-state: sw_if_index %d, new flags %d",
1351 .format_args = "i4i4",
1354 struct { u32 sw_if_index; u32 flags; } *ed;
1355 ed = ELOG_DATA (&vm->elog_main, e);
1356 ed->sw_if_index = xd->vlib_sw_if_index;
1357 ed->flags = hw_flags;
1359 vnet_hw_interface_set_flags (vnm, xd->vlib_hw_if_index, hw_flags);
1364 dpdk_process (vlib_main_t * vm,
1365 vlib_node_runtime_t * rt,
1368 clib_error_t * error;
1369 vnet_main_t * vnm = vnet_get_main();
1370 dpdk_main_t * dm = &dpdk_main;
1371 ethernet_main_t * em = ðernet_main;
1373 vlib_thread_main_t * tm = vlib_get_thread_main();
1377 error = dpdk_lib_init (dm);
1380 * Turn on the input node if we found some devices to drive
1381 * and we're not running worker threads or i/o threads
1384 if (error == 0 && vec_len(dm->devices) > 0)
1386 if (tm->n_vlib_mains == 1)
1387 vlib_node_set_state (vm, dpdk_input_node.index,
1388 VLIB_NODE_STATE_POLLING);
1389 else if (tm->main_thread_is_io_node)
1390 vlib_node_set_state (vm, dpdk_io_input_node.index,
1391 VLIB_NODE_STATE_POLLING);
1392 else if (!dm->have_io_threads)
1393 for (i=0; i < tm->n_vlib_mains; i++)
1394 if (vec_len(dm->devices_by_cpu[i]) > 0)
1395 vlib_node_set_state (vlib_mains[i], dpdk_input_node.index,
1396 VLIB_NODE_STATE_POLLING);
1400 clib_error_report (error);
1402 dpdk_vhost_user_process_init(&vu_state);
1404 dm->io_thread_release = 1;
1406 f64 now = vlib_time_now (vm);
1407 vec_foreach (xd, dm->devices)
1409 dpdk_update_link_state (xd, now);
1412 { // Setup MACs for bond interfaces and their links which was initialized in
1413 // dpdk_port_setup() but needs to be done again here to take effect.
1414 int nports = rte_eth_dev_count();
1416 for (i = 0; i < nports; i++) {
1417 struct rte_eth_dev_info dev_info;
1418 rte_eth_dev_info_get(i, &dev_info);
1419 if (!dev_info.driver_name)
1420 dev_info.driver_name = dev_info.pci_dev->driver->name;
1421 ASSERT(dev_info.driver_name);
1422 if (strncmp(dev_info.driver_name, "rte_bond_pmd", 12) == 0) {
1425 int nlink = rte_eth_bond_slaves_get(i, slink, 16);
1427 vnet_hw_interface_t * bhi;
1428 ethernet_interface_t * bei;
1429 /* Get MAC of 1st slave link */
1430 rte_eth_macaddr_get(slink[0], (struct ether_addr *)addr);
1431 /* Set MAC of bounded interface to that of 1st slave link */
1432 rte_eth_bond_mac_address_set(i, (struct ether_addr *)addr);
1433 /* Populate MAC of bonded interface in VPP hw tables */
1434 bhi = vnet_get_hw_interface(
1435 vnm, dm->devices[i].vlib_hw_if_index);
1436 bei = pool_elt_at_index(em->interfaces, bhi->hw_instance);
1437 memcpy(bhi->hw_address, addr, 6);
1438 memcpy(bei->address, addr, 6);
1439 while (nlink >= 1) { /* for all slave links */
1440 int slave = slink[--nlink];
1441 dpdk_device_t * sdev = &dm->devices[slave];
1442 vnet_hw_interface_t * shi;
1443 vnet_sw_interface_t * ssi;
1444 /* Add MAC to all slave links except the first one */
1445 if (nlink) rte_eth_dev_mac_addr_add(
1446 slave, (struct ether_addr *)addr, 0);
1447 /* Set slaves bitmap for bonded interface */
1448 bhi->bond_info = clib_bitmap_set(
1449 bhi->bond_info, sdev->vlib_hw_if_index, 1);
1450 /* Set slave link flags on slave interface */
1451 shi = vnet_get_hw_interface(vnm, sdev->vlib_hw_if_index);
1452 ssi = vnet_get_sw_interface(vnm, sdev->vlib_sw_if_index);
1453 shi->bond_info = VNET_HW_INTERFACE_BOND_INFO_SLAVE;
1454 ssi->flags |= VNET_SW_INTERFACE_FLAG_BOND_SLAVE;
1465 * check each time through the loop in case intervals are changed
1467 f64 min_wait = dm->link_state_poll_interval < dm->stat_poll_interval ?
1468 dm->link_state_poll_interval : dm->stat_poll_interval;
1470 vlib_process_wait_for_event_or_clock (vm, min_wait);
1472 if (dpdk_get_admin_up_down_in_progress())
1473 /* skip the poll if an admin up down is in progress (on any interface) */
1476 vec_foreach (xd, dm->devices)
1478 f64 now = vlib_time_now (vm);
1479 if ((now - xd->time_last_stats_update) >= dm->stat_poll_interval)
1480 dpdk_update_counters (xd, now);
1481 if ((now - xd->time_last_link_update) >= dm->link_state_poll_interval)
1482 dpdk_update_link_state (xd, now);
1484 if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER)
1485 if (dpdk_vhost_user_process_if(vm, xd, vu_state) != 0)
1490 dpdk_vhost_user_process_cleanup(vu_state);
1495 VLIB_REGISTER_NODE (dpdk_process_node,static) = {
1496 .function = dpdk_process,
1497 .type = VLIB_NODE_TYPE_PROCESS,
1498 .name = "dpdk-process",
1499 .process_log2_n_stack_bytes = 17,
1502 int dpdk_set_stat_poll_interval (f64 interval)
1504 if (interval < DPDK_MIN_STATS_POLL_INTERVAL)
1505 return (VNET_API_ERROR_INVALID_VALUE);
1507 dpdk_main.stat_poll_interval = interval;
1512 int dpdk_set_link_state_poll_interval (f64 interval)
1514 if (interval < DPDK_MIN_LINK_POLL_INTERVAL)
1515 return (VNET_API_ERROR_INVALID_VALUE);
1517 dpdk_main.link_state_poll_interval = interval;
1523 dpdk_init (vlib_main_t * vm)
1525 dpdk_main_t * dm = &dpdk_main;
1527 clib_error_t * error = 0;
1528 vlib_thread_main_t * tm = vlib_get_thread_main();
1530 /* verify that structs are cacheline aligned */
1531 ASSERT(offsetof(dpdk_device_t, cacheline0) == 0);
1532 ASSERT(offsetof(dpdk_device_t, cacheline1) == CLIB_CACHE_LINE_BYTES);
1533 ASSERT(offsetof(dpdk_worker_t, cacheline0) == 0);
1534 ASSERT(offsetof(frame_queue_trace_t, cacheline0) == 0);
1537 dm->vnet_main = vnet_get_main();
1539 ei = vlib_get_node_by_name (vm, (u8 *) "ethernet-input");
1541 return clib_error_return (0, "ethernet-input node AWOL");
1543 dm->ethernet_input_node_index = ei->index;
1546 dm->num_mbufs = dm->num_mbufs ? dm->num_mbufs : NB_MBUF;
1547 vec_add1 (dm->eal_init_args, (u8 *) "vnet");
1549 dm->dpdk_device_by_kni_port_id = hash_create (0, sizeof (uword));
1550 dm->vu_sw_if_index_by_listener_fd = hash_create (0, sizeof (uword));
1551 dm->vu_sw_if_index_by_sock_fd = hash_create (0, sizeof (uword));
1553 /* $$$ use n_thread_stacks since it's known-good at this point */
1554 vec_validate (dm->recycle, tm->n_thread_stacks - 1);
1556 /* initialize EFD (early fast discard) default settings */
1557 dm->efd.enabled = DPDK_EFD_DISABLED;
1558 dm->efd.queue_hi_thresh = ((DPDK_EFD_DEFAULT_DEVICE_QUEUE_HI_THRESH_PCT *
1559 DPDK_NB_RX_DESC_10GE)/100);
1560 dm->efd.consec_full_frames_hi_thresh =
1561 DPDK_EFD_DEFAULT_CONSEC_FULL_FRAMES_HI_THRESH;
1563 /* vhost-user coalescence frames defaults */
1564 dm->vhost_coalesce_frames = 32;
1565 dm->vhost_coalesce_time = 1e-3;
1567 /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */
1568 dm->buffer_flags_template =
1569 (VLIB_BUFFER_TOTAL_LENGTH_VALID
1570 | IP_BUFFER_L4_CHECKSUM_COMPUTED
1571 | IP_BUFFER_L4_CHECKSUM_CORRECT);
1573 dm->stat_poll_interval = DPDK_STATS_POLL_INTERVAL;
1574 dm->link_state_poll_interval = DPDK_LINK_POLL_INTERVAL;
1577 if ((error = vlib_call_init_function (vm, dpdk_cli_init)))
1583 VLIB_INIT_FUNCTION (dpdk_init);