34 #include <sys/mount.h> 40 #define ETHER_MAX_LEN 1518 45 #define LINK_STATE_ELOGS 0 53 if (dev_info->speed_capa & ETH_LINK_SPEED_100G)
55 else if (dev_info->speed_capa & ETH_LINK_SPEED_56G)
57 else if (dev_info->speed_capa & ETH_LINK_SPEED_50G)
59 else if (dev_info->speed_capa & ETH_LINK_SPEED_40G)
61 else if (dev_info->speed_capa & ETH_LINK_SPEED_25G)
63 else if (dev_info->speed_capa & ETH_LINK_SPEED_20G)
65 else if (dev_info->speed_capa & ETH_LINK_SPEED_10G)
67 else if (dev_info->speed_capa & ETH_LINK_SPEED_5G)
69 else if (dev_info->speed_capa & ETH_LINK_SPEED_2_5G)
71 else if (dev_info->speed_capa & ETH_LINK_SPEED_1G)
87 old = (xd->
flags & DPDK_DEVICE_FLAG_PROMISC) != 0;
90 xd->
flags |= DPDK_DEVICE_FLAG_PROMISC;
92 xd->
flags &= ~DPDK_DEVICE_FLAG_PROMISC;
94 if (xd->
flags & DPDK_DEVICE_FLAG_ADMIN_UP)
96 if (xd->
flags & DPDK_DEVICE_FLAG_PROMISC)
97 rte_eth_promiscuous_enable (xd->
port_id);
99 rte_eth_promiscuous_disable (xd->
port_id);
123 static struct rte_mempool_ops *
128 for (i = 0; i < rte_mempool_ops_table.num_ops; i++)
130 if (!strcmp (ops_name, rte_mempool_ops_table.ops[i].name))
131 return &rte_mempool_ops_table.ops[
i];
142 char rg_name[RTE_RING_NAMESIZE];
145 ret = snprintf (rg_name,
sizeof (rg_name), RTE_MEMPOOL_MZ_FORMAT, mp->name);
146 if (ret < 0 || ret >= (
i32)
sizeof (rg_name))
147 return -ENAMETOOLONG;
150 if (mp->flags & MEMPOOL_F_SP_PUT)
151 rg_flags |= RING_F_SP_ENQ;
152 if (mp->flags & MEMPOOL_F_SC_GET)
153 rg_flags |= RING_F_SC_DEQ;
155 count = rte_align32pow2 (mp->size + 1);
168 ret = rte_ring_init (r, rg_name,
count, rg_flags);
180 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 183 if (xd->
port_conf.rxmode.offloads & DEV_RX_OFFLOAD_CRC_STRIP)
193 u32 mtu, max_rx_frame;
203 vlib_pci_addr_t last_pci_addr;
204 u32 last_pci_addr_port = 0;
208 u32 next_hqos_cpu = 0;
209 u8 af_packet_instance_num = 0;
210 u8 bond_ether_instance_num = 0;
211 last_pci_addr.as_u32 = ~0;
220 if (tr_hqos && tr_hqos->
count > 0)
229 nports = rte_eth_dev_count_avail ();
241 | VNET_BUFFER_F_L4_CHECKSUM_COMPUTED);
258 RTE_ETH_FOREACH_DEV(i)
262 struct rte_eth_dev_info dev_info;
263 struct rte_pci_device *pci_dev;
264 struct rte_eth_link l;
266 vlib_pci_addr_t pci_addr;
269 if (!rte_eth_dev_is_valid_port(i))
272 rte_eth_link_get_nowait (i, &l);
273 rte_eth_dev_info_get (i, &dev_info);
275 if (dev_info.device == 0)
277 clib_warning (
"DPDK bug: missing device info. Skipping %s device",
278 dev_info.driver_name);
281 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
285 pci_addr.domain = pci_dev->addr.domain;
286 pci_addr.bus = pci_dev->addr.bus;
287 pci_addr.slot = pci_dev->addr.devid;
288 pci_addr.function = pci_dev->addr.function;
307 struct rte_eth_dev_info di = { 0 };
308 struct rte_pci_device *next_pci_dev;
309 rte_eth_dev_info_get (i + 1, &di);
310 next_pci_dev = di.device ? RTE_DEV_TO_PCI (di.device) : 0;
311 if (pci_dev && next_pci_dev &&
312 pci_addr.as_u32 != last_pci_addr.as_u32 &&
313 memcmp (&pci_dev->addr, &next_pci_dev->addr,
314 sizeof (
struct rte_pci_addr)) == 0)
317 last_pci_addr.as_u32 = pci_addr.as_u32;
318 last_pci_addr_port =
i;
320 else if (pci_addr.as_u32 == last_pci_addr.as_u32)
323 format (0,
"%u", i - last_pci_addr_port);
327 last_pci_addr.as_u32 = ~0;
331 last_pci_addr.as_u32 = ~0;
334 sizeof (
struct rte_eth_txconf));
338 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 339 xd->
tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
343 xd->
port_conf.txmode.offloads &= ~DEV_TX_OFFLOAD_MULTI_SEGS;
344 xd->
port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
345 xd->
port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER;
350 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 351 xd->
tx_conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
355 xd->
port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
356 xd->
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
357 xd->
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SCATTER;
359 xd->
flags |= DPDK_DEVICE_FLAG_MAYBE_MULTISEG;
364 if (devconf->num_tx_queues > 0
365 && devconf->num_tx_queues < xd->
tx_q_used)
368 if (devconf->num_rx_queues > 1
369 && dev_info.max_rx_queues >= devconf->num_rx_queues)
372 xd->
port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
373 if (devconf->rss_fn == 0)
374 xd->
port_conf.rx_adv_conf.rss_conf.rss_hf =
375 ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
378 u64 unsupported_bits;
379 xd->
port_conf.rx_adv_conf.rss_conf.rss_hf = devconf->rss_fn;
380 unsupported_bits = xd->
port_conf.rx_adv_conf.rss_conf.rss_hf;
381 unsupported_bits &= ~dev_info.flow_type_rss_offloads;
382 if (unsupported_bits)
386 xd->
port_conf.rx_adv_conf.rss_conf.rss_hf &=
387 dev_info.flow_type_rss_offloads;
392 xd->
flags |= DPDK_DEVICE_FLAG_PMD;
395 if ((!dev_info.driver_name) && (pci_dev))
396 dev_info.driver_name = pci_dev->driver->driver.name;
398 ASSERT (dev_info.driver_name);
404 #define _(s,f) else if (dev_info.driver_name && \ 405 !strcmp(dev_info.driver_name, s)) \ 406 xd->pmd = VNET_DPDK_PMD_##f; 421 case VNET_DPDK_PMD_E1000EM:
422 case VNET_DPDK_PMD_IGB:
423 case VNET_DPDK_PMD_IXGBE:
424 case VNET_DPDK_PMD_I40E:
427 VNET_FLOW_ACTION_REDIRECT_TO_NODE |
428 VNET_FLOW_ACTION_BUFFER_ADVANCE |
429 VNET_FLOW_ACTION_COUNT | VNET_FLOW_ACTION_DROP;
433 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 434 xd->
tx_conf.txq_flags &= ~(ETH_TXQ_FLAGS_NOXSUMUDP |
435 ETH_TXQ_FLAGS_NOXSUMTCP);
437 xd->
port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
438 xd->
port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
441 DPDK_DEVICE_FLAG_TX_OFFLOAD |
442 DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM;
447 case VNET_DPDK_PMD_CXGBE:
448 case VNET_DPDK_PMD_MLX4:
449 case VNET_DPDK_PMD_MLX5:
450 case VNET_DPDK_PMD_QEDE:
455 case VNET_DPDK_PMD_IGBVF:
456 case VNET_DPDK_PMD_IXGBEVF:
457 case VNET_DPDK_PMD_I40EVF:
459 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 462 xd->
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
466 case VNET_DPDK_PMD_THUNDERX:
468 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 471 xd->
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
475 case VNET_DPDK_PMD_ENA:
477 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 480 xd->
port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER;
484 case VNET_DPDK_PMD_DPAA2:
489 case VNET_DPDK_PMD_ENIC:
490 if (l.link_speed == 40000)
497 case VNET_DPDK_PMD_FM10K:
499 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 502 xd->
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
507 case VNET_DPDK_PMD_VIRTIO:
514 case VNET_DPDK_PMD_VMXNET3:
516 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 517 xd->
tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
519 xd->
port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
523 case VNET_DPDK_PMD_AF_PACKET:
528 case VNET_DPDK_PMD_BOND:
533 case VNET_DPDK_PMD_VIRTIO_USER:
537 case VNET_DPDK_PMD_VHOST_ETHER:
541 case VNET_DPDK_PMD_LIOVF_ETHER:
545 case VNET_DPDK_PMD_FAILSAFE:
554 if (devconf->num_rx_desc)
557 if (devconf->num_tx_desc)
561 if (xd->
pmd == VNET_DPDK_PMD_AF_PACKET)
565 rnd = (
u32) (now * 1e6);
572 rte_eth_macaddr_get (i, (
struct ether_addr *) addr);
584 if (devconf->hqos_enabled)
586 xd->
flags |= DPDK_DEVICE_FLAG_HQOS;
589 if (devconf->hqos.hqos_thread_valid)
607 devconf->hqos.hqos_thread_valid = 1;
608 devconf->hqos.hqos_thread = cpu;
639 max_rx_frame = dev_info.max_rx_pktlen;
680 if (xd->
pmd == VNET_DPDK_PMD_FAILSAFE)
687 if (!rte_eth_dev_get_mtu (i, &dev_mtu))
700 xd->
port_conf.rxmode.max_rx_pkt_len = max_rx_frame;
707 if (devconf->workers)
712 vnet_hw_interface_assign_rx_thread (dm->vnet_main, xd->hw_if_index, q++,
713 vdm->first_worker_thread_index + i);
735 if (xd->
flags & DPDK_DEVICE_FLAG_TX_OFFLOAD && hi !=
NULL)
741 dpdk_log_err (
"setup failed for device %U. Errors:\n %U",
745 if (devconf->hqos_enabled)
759 if (xd->
pmd == VNET_DPDK_PMD_ENIC)
772 vlan_off = rte_eth_dev_get_vlan_offload (xd->
port_id);
773 vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
774 #if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) 775 xd->
port_conf.rxmode.hw_vlan_strip = vlan_off;
778 xd->
port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
780 xd->
port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
782 if (rte_eth_dev_set_vlan_offload (xd->
port_id, vlan_off) == 0)
785 dpdk_log_warn (
"VLAN strip cannot be supported by interface\n");
797 rte_eth_dev_set_mtu (xd->
port_id, mtu);
802 dpdk_log_err (
"%d mbufs allocated but total rx/tx ring size is %d\n",
815 vlib_pci_addr_t *
addr = 0, *addrs;
906 devconf->
pci_addr.as_u32 = addr->as_u32;
942 "duplicate configuration for PCI address %U",
946 devconf->
pci_addr.as_u32 = pci_addr.as_u32;
956 if (
unformat (input,
"num-rx-queues %u", &devconf->num_rx_queues))
958 else if (
unformat (input,
"num-tx-queues %u", &devconf->num_tx_queues))
960 else if (
unformat (input,
"num-rx-desc %u", &devconf->num_rx_desc))
962 else if (
unformat (input,
"num-tx-desc %u", &devconf->num_tx_desc))
964 else if (
unformat (input,
"workers %U", unformat_bitmap_list,
975 else if (
unformat (input,
"vlan-strip-offload off"))
977 else if (
unformat (input,
"vlan-strip-offload on"))
1003 if (devconf->
workers && devconf->num_rx_queues == 0)
1007 devconf->num_rx_queues)
1010 "%U: number of worker threads must be " 1031 if (n < 0 && errno != EAGAIN)
1033 _vec_len (s) = len + (n < 0 ? 0 : n);
1055 vlib_pci_addr_t pci_addr;
1061 int num_whitelisted = 0;
1067 u8 *huge_dir_path = 0;
1073 log_level = RTE_LOG_NOTICE;
1078 if (
unformat (input,
"no-hugetlb"))
1084 else if (
unformat (input,
"enable-tcp-udp-checksum"))
1087 else if (
unformat (input,
"no-tx-checksum-offload"))
1090 else if (
unformat (input,
"decimal-interface-names"))
1096 else if (
unformat (input,
"no-multi-seg"))
1136 else if (
unformat (input,
"socket-mem %s", &socket_mem))
1138 else if (
unformat (input,
"no-pci"))
1141 tmp =
format (0,
"--no-pci%c", 0);
1146 else if (unformat(input, #a)) \ 1148 tmp = format (0, "--%s%c", #a, 0); \ 1149 vec_add1 (conf->eal_init_args, tmp); \ 1154 else if (unformat(input, #a " %s", &s)) \ 1156 if (!strncmp(#a, "huge-dir", 8)) \ 1158 else if (!strncmp(#a, "file-prefix", 11)) \ 1160 tmp = format (0, "--%s%c", #a, 0); \ 1161 vec_add1 (conf->eal_init_args, tmp); \ 1163 if (!strncmp(#a, "vdev", 4)) \ 1164 if (strstr((char*)s, "af_packet")) \ 1165 clib_warning ("af_packet obsoleted. Use CLI 'create host-interface'."); \ 1166 vec_add1 (conf->eal_init_args, s); \ 1171 else if (unformat(input, #a " %s", &s)) \ 1173 tmp = format (0, "-%s%c", #b, 0); \ 1174 vec_add1 (conf->eal_init_args, tmp); \ 1176 vec_add1 (conf->eal_init_args, s); \ 1181 else if (unformat(input, #a " %s", &s)) \ 1183 tmp = format (0, "-%s%c", #b, 0); \ 1184 vec_add1 (conf->eal_init_args, tmp); \ 1186 vec_add1 (conf->eal_init_args, s); \ 1187 conf->a##_set_manually = 1; \ 1191 else if (
unformat (input,
"default"))
1210 if (!no_huge && !huge_dir)
1212 u32 x, *mem_by_socket = 0;
1216 umount ((
char *) huge_dir_path);
1245 vec_validate(mem_by_socket, c);
1246 mem_by_socket[c] = 64;
1257 vec_validate(mem_by_socket, c);
1259 e = clib_sysfs_prealloc_hugepages(c, 2 << 10, mem_by_socket[c] / 2);
1261 clib_error_report (e);
1265 if (mem_by_socket == 0)
1270 _vec_len (mem_by_socket) = c + 1;
1274 socket_mem =
format (socket_mem,
"%s%u",
1275 socket_mem ?
"," :
"", mem_by_socket[x]);
1276 socket_mem =
format (socket_mem,
"%c", 0);
1286 rv = mount (
"none", (
char *) huge_dir_path,
"hugetlbfs", 0,
NULL);
1294 tmp =
format (0,
"--huge-dir%c", 0);
1296 tmp =
format (0,
"%s%c", huge_dir_path, 0);
1300 tmp =
format (0,
"--file-prefix%c", 0);
1302 tmp =
format (0,
"vpp%c", 0);
1314 uword *coremask = 0;
1328 tmp =
format (0,
"%U%c", format_bitmap_hex, coremask, 0);
1341 if (no_pci == 0 && geteuid () == 0)
1345 if (devconf->x == 0 && conf->default_devconf.x > 0) \ 1346 devconf->x = conf->default_devconf.x ; 1352 foreach_dpdk_device_config_item
1355 if (num_whitelisted > 0 && devconf->is_blacklisted == 0)
1357 tmp = format (0,
"-w%c", 0);
1358 vec_add1 (conf->eal_init_args, tmp);
1359 tmp = format (0,
"%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1360 vec_add1 (conf->eal_init_args, tmp);
1364 tmp = format (0,
"-b%c", 0);
1365 vec_add1 (conf->eal_init_args, tmp);
1366 tmp = format (0,
"%U%c", format_vlib_pci_addr, &devconf->pci_addr, 0);
1367 vec_add1 (conf->eal_init_args, tmp);
1375 tmp =
format (0,
"--master-lcore%c", 0);
1376 vec_add1 (conf->eal_init_args, tmp);
1377 tmp =
format (0,
"%u%c", tm->main_lcore, 0);
1378 vec_add1 (conf->eal_init_args, tmp);
1383 tmp =
format (0,
"--socket-mem%c", 0);
1384 vec_add1 (conf->eal_init_args, tmp);
1385 tmp =
format (0,
"%s%c", socket_mem, 0);
1386 vec_add1 (conf->eal_init_args, tmp);
1391 _vec_len (conf->eal_init_args) -= 1;
1395 rte_log_set_global_level (log_level);
1396 int log_fds[2] = { 0 };
1397 if (pipe (log_fds) == 0)
1399 if (fcntl (log_fds[1], F_SETFL, O_NONBLOCK) == 0)
1401 FILE *f = fdopen (log_fds[1],
"a");
1402 if (f && rte_openlog_stream (f) == 0)
1421 for (
i = 1;
i <
vec_len (conf->eal_init_args);
i++)
1422 conf->eal_init_args_str =
format (conf->eal_init_args_str,
"%s ",
1423 conf->eal_init_args[
i]);
1425 dpdk_log_warn (
"EAL init args: %s", conf->eal_init_args_str);
1426 ret = rte_eal_init (
vec_len (conf->eal_init_args),
1427 (
char **) conf->eal_init_args);
1430 umount2 ((
char *) huge_dir_path, MNT_DETACH);
1431 rmdir ((
char *) huge_dir_path);
1439 struct rte_mempool_ops *ops =
NULL;
1459 for (
i = 0;
i < RTE_MAX_LCORE;
i++)
1462 rte_lcore_to_socket_id (
i));
1477 struct rte_eth_link prev_link = xd->
link;
1479 u8 hw_flags_chg = 0;
1482 if ((xd->
flags & DPDK_DEVICE_FLAG_PMD) == 0)
1495 "update-link-state: sw_if_index %d, admin_up %d," 1496 "old link_state %d new link_state %d",.format_args =
"i4i1i1i1",};
1507 ed->admin_up = (xd->
flags & DPDK_DEVICE_FLAG_ADMIN_UP) != 0;
1508 ed->old_link_state = (
u8)
1510 ed->new_link_state = (
u8) xd->
link.link_status;
1513 if ((xd->
flags & (DPDK_DEVICE_FLAG_ADMIN_UP | DPDK_DEVICE_FLAG_BOND_SLAVE))
1514 && ((xd->
link.link_status != 0) ^
1521 if (hw_flags_chg || (xd->
link.link_duplex != prev_link.link_duplex))
1524 switch (xd->
link.link_duplex)
1526 case ETH_LINK_HALF_DUPLEX:
1529 case ETH_LINK_FULL_DUPLEX:
1536 if (hw_flags_chg || (xd->
link.link_speed != prev_link.link_speed))
1539 switch (xd->
link.link_speed)
1541 case ETH_SPEED_NUM_10M:
1544 case ETH_SPEED_NUM_100M:
1547 case ETH_SPEED_NUM_1G:
1550 case ETH_SPEED_NUM_2_5G:
1553 case ETH_SPEED_NUM_5G:
1556 case ETH_SPEED_NUM_10G:
1559 case ETH_SPEED_NUM_20G:
1562 case ETH_SPEED_NUM_25G:
1565 case ETH_SPEED_NUM_40G:
1568 case ETH_SPEED_NUM_50G:
1571 case ETH_SPEED_NUM_56G:
1574 case ETH_SPEED_NUM_100G:
1593 "update-link-state: sw_if_index %d, new flags %d",.format_args
1603 ed->flags = hw_flags;
1643 int nports = rte_eth_dev_count_avail ();
1647 RTE_ETH_FOREACH_DEV(i)
1650 for (j = 0; j < nports; j++)
1657 if (xd !=
NULL && xd->
pmd == VNET_DPDK_PMD_BOND)
1661 int nlink = rte_eth_bond_slaves_get (i, slink, 16);
1670 (slink[0], (
struct ether_addr *) addr);
1675 rv = rte_eth_bond_mac_address_set
1676 (i, (
struct ether_addr *) addr);
1692 int slave = slink[--nlink];
1702 rv = rte_eth_dev_mac_addr_add
1703 (slave, (
struct ether_addr *) addr, 0);
1709 rte_eth_dev_callback_register
1710 (slave, RTE_ETH_EVENT_INTR_LSC,
1713 sxd->
flags |= DPDK_DEVICE_FLAG_BOND_SLAVE;
1770 .name =
"dpdk-process",
1771 .process_log2_n_stack_bytes = 17,
1783 "Cache line marker must be 1st element in dpdk_device_t");
1786 "Data in cache line 0 is bigger than cache line size");
1788 "Cache line marker must be 1st element in frame_queue_trace_t");
1790 "DPDK RTE CACHE LINE SIZE does not match with 1<<CLIB_LOG2_CACHE_LINE_BYTES");
1802 (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_EXT_HDR_VALID
1803 | VNET_BUFFER_F_L4_CHECKSUM_COMPUTED |
1804 VNET_BUFFER_F_L4_CHECKSUM_CORRECT | VNET_BUFFER_F_L2_HDR_OFFSET_VALID);
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void dpdk_bind_devices_to_uio(dpdk_config_main_t *conf)
f64 time_last_link_update
format_function_t format_vlib_pci_addr
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
#define VIRTIO_PCI_MODERN_DEVICEID_NET
#define VNET_HW_INTERFACE_FLAG_SPEED_1G
ethernet_main_t ethernet_main
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
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...
#define VNET_HW_INTERFACE_FLAG_SPEED_50G
u8 interface_name_format_decimal
vnet_main_t * vnet_get_main(void)
vnet_device_class_t dpdk_device_class
#define DPDK_DEVICE_VLAN_STRIP_OFF
static f64 vlib_time_now(vlib_main_t *vm)
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
static uword * clib_bitmap_or(uword *ai, uword *bi)
Logical operator across two bitmaps.
static u32 dpdk_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
vlib_pci_device_info_t * vlib_pci_get_device_info(vlib_pci_addr_t *addr, clib_error_t **error)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define CLIB_LOG2_CACHE_LINE_BYTES
static struct rte_mempool_ops * get_ops_by_name(char *ops_name)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
dpdk_device_and_queue_t ** devices_by_hqos_cpu
#define DPDK_NB_RX_DESC_VIRTIO
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
u32 per_interface_next_index
u8 enable_tcp_udp_checksum
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. ...
#define DPDK_DEVICE_VLAN_STRIP_ON
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define VNET_HW_INTERFACE_FLAG_SPEED_100G
#define DPDK_NB_TX_DESC_DEFAULT
u32 supported_flow_actions
#define foreach_eal_double_hyphen_predicate_arg
unformat_function_t unformat_vlib_pci_addr
#define VNET_HW_INTERFACE_FLAG_LINK_UP
int dpdk_port_state_callback(dpdk_portid_t port_id, enum rte_eth_event_type type, void *param, void *ret_param)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
dpdk_device_config_hqos_t hqos
vlib_pci_addr_t * vlib_pci_get_all_dev_addrs()
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
dpdk_config_main_t dpdk_config_main
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_file_function_t * read_function
#define ETHER_MAX_LEN
Maximum frame len, including CRC.
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VNET_HW_INTERFACE_FLAG_SPEED_2_5G
memset(h->entries, 0, sizeof(h->entries[0])*entries)
foreach_dpdk_device_config_item clib_bitmap_t * workers
#define dpdk_log_warn(...)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static clib_error_t * dpdk_log_read_ready(clib_file_t *uf)
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
dpdk_device_config_t default_devconf
static char * vlib_unix_get_runtime_dir(void)
static dpdk_port_type_t port_type_from_speed_capa(struct rte_eth_dev_info *dev_info)
clib_error_t * vlib_pci_bind_to_uio(vlib_pci_addr_t *addr, char *uio_drv_name)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define VNET_HW_INTERFACE_FLAG_SPEED_25G
clib_file_main_t file_main
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
void dpdk_device_setup(dpdk_device_t *xd)
#define vlib_call_init_function(vm, x)
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
#define DPDK_NB_TX_DESC_VIRTIO
struct rte_eth_conf port_conf
static clib_error_t * dpdk_init(vlib_main_t *vm)
u32 max_supported_packet_bytes
f64 time_last_stats_update
struct rte_eth_txconf tx_conf
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
clib_error_t * dpdk_buffer_pool_create(vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
static clib_error_t * dpdk_config(vlib_main_t *vm, unformat_input_t *input)
#define foreach_eal_double_hyphen_arg
#define ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags)
#define VNET_HW_INTERFACE_FLAG_SPEED_10M
dpdk_per_thread_data_t * per_thread_data
#define VNET_HW_INTERFACE_FLAG_SPEED_56G
#define foreach_eal_single_hyphen_mandatory_arg
#define VNET_HW_INTERFACE_FLAG_HALF_DUPLEX
#define clib_error_return_unix(e, args...)
vlib_buffer_t buffer_template
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
#define VIRTIO_PCI_LEGACY_DEVICEID_NET
dpdk_port_type_t port_type
#define VLIB_CONFIG_FUNCTION(x, n,...)
vnet_sw_interface_flags_t flags
#define dpdk_log_info(...)
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
u16 af_packet_instance_num
#define foreach_eal_single_hyphen_arg
#define VLIB_REGISTER_NODE(x,...)
#define DPDK_NB_RX_DESC_DEFAULT
static clib_error_t * dpdk_device_config(dpdk_config_main_t *conf, vlib_pci_addr_t pci_addr, unformat_input_t *input, u8 is_default)
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
u8 nchannels_set_manually
#define vec_free(V)
Free vector's memory (no header).
#define dpdk_log_err(...)
dpdk_device_config_t * dev_confs
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
format_function_t format_dpdk_device_errors
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD
#define ELOG_TYPE_DECLARE(f)
#define VNET_HW_INTERFACE_FLAG_SPEED_10G
static void dpdk_device_lock_init(dpdk_device_t *xd)
format_function_t format_dpdk_rss_hf_name
u8 * interface_name_suffix
#define hash_create(elts, value_bytes)
#define VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
void dpdk_device_config_hqos_default(dpdk_device_config_hqos_t *hqos)
format_function_t format_dpdk_device_name
void vnet_hw_interface_assign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, uword thread_index)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
vlib_log_class_t log_default
static uword dpdk_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Bitmaps built as vectors of machine words.
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
#define clib_error_report(e)
#define clib_bitmap_free(v)
Free a bitmap.
#define DPDK_LINK_POLL_INTERVAL
uword * thread_registrations_by_name
clib_error_t * dpdk_cli_init(vlib_main_t *vm)
dpdk_portid_t device_index
static vlib_main_t * vlib_get_main(void)
clib_error_t * dpdk_port_setup_hqos(dpdk_device_t *xd, dpdk_device_config_hqos_t *hqos)
static int dpdk_port_crc_strip_enabled(dpdk_device_t *xd)
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
clib_error_t * vlib_unix_recursive_mkdir(char *path)
#define DPDK_STATS_POLL_INTERVAL
#define VNET_HW_INTERFACE_FLAG_SPEED_100M
static vlib_node_registration_t dpdk_process_node
(constructor) VLIB_REGISTER_NODE (dpdk_process_node)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
u8 admin_up_down_in_progress
#define STATIC_ASSERT(truth,...)
#define VNET_HW_INTERFACE_FLAG_SPEED_5G
u8 no_tx_checksum_offload
static clib_error_t * dpdk_lib_init(dpdk_main_t *dm)
#define hash_get_mem(h, key)
u32 buffer_flags_template
static void * clib_mem_alloc_aligned(uword size, uword align)
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
static u32 random_u32(u32 *seed)
32-bit random number generator
#define VNET_HW_INTERFACE_FLAG_SPEED_40G
static vlib_thread_main_t * vlib_get_thread_main()
#define ETHERNET_MAX_PACKET_BYTES
#define vec_foreach(var, vec)
Vector iterator.
#define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags)
uword * cpu_socket_bitmap
static int dpdk_ring_alloc(struct rte_mempool *mp)
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, vlib_buffer_free_list_index_t free_list_index)
vlib_thread_registration_t ** registrations
static void vlib_pci_free_device_info(vlib_pci_device_info_t *di)
#define CLIB_CACHE_LINE_BYTES
unformat_function_t unformat_dpdk_log_level
ethernet_interface_t * interfaces
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
clib_error_t * unformat_hqos(unformat_input_t *input, dpdk_device_config_hqos_t *hqos)
#define VNET_HW_INTERFACE_FLAG_SPEED_20G
uword * device_config_index_by_pci_addr
static uword vnet_hw_interface_is_link_up(vnet_main_t *vnm, u32 hw_if_index)
volatile u32 worker_thread_release
#define dpdk_log_notice(...)
static void vnet_hw_interface_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
vnet_device_main_t vnet_device_main
f64 link_state_poll_interval
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
dpdk_config_main_t * conf