X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fdpdk%2Fdevice%2Finit.c;h=df1a823f6da0c84792a23a8d5932e61c6daba239;hb=16d227aa148497e52023c1867614b06060bd04fd;hp=6cde04123ccf4b3b33c0f23caf13d128f4a871a3;hpb=940d1c8a18d672c37c6545ffdabd090d29f09850;p=vpp.git diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 6cde04123cc..df1a823f6da 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -206,9 +207,7 @@ dpdk_ring_alloc (struct rte_mempool *mp) static int dpdk_port_crc_strip_enabled (dpdk_device_t * xd) { -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - return ! !(xd->port_conf.rxmode.hw_strip_crc); -#elif RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) +#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) return ! !(xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_CRC_STRIP); #else return !(xd->port_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC); @@ -375,27 +374,15 @@ dpdk_lib_init (dpdk_main_t * dm) if (dm->conf->no_multi_seg) { -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS; - xd->port_conf.rxmode.jumbo_frame = 0; - xd->port_conf.rxmode.enable_scatter = 0; -#else xd->port_conf.txmode.offloads &= ~DEV_TX_OFFLOAD_MULTI_SEGS; xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER; -#endif } else { -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->tx_conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS; - xd->port_conf.rxmode.jumbo_frame = 1; - xd->port_conf.rxmode.enable_scatter = 1; -#else xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS; xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SCATTER; -#endif xd->flags |= DPDK_DEVICE_FLAG_MAYBE_MULTISEG; } @@ -470,13 +457,8 @@ dpdk_lib_init (dpdk_main_t * dm) if (dm->conf->no_tx_checksum_offload == 0) { -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->tx_conf.txq_flags &= ~(ETH_TXQ_FLAGS_NOXSUMUDP | - ETH_TXQ_FLAGS_NOXSUMTCP); -#else xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; -#endif xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD | DPDK_DEVICE_FLAG_INTEL_PHDR_CKSUM; @@ -496,42 +478,28 @@ dpdk_lib_init (dpdk_main_t * dm) case VNET_DPDK_PMD_IXGBEVF: case VNET_DPDK_PMD_I40EVF: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_VF; -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->port_conf.rxmode.hw_strip_crc = 1; -#elif RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) +#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP; #endif break; case VNET_DPDK_PMD_THUNDERX: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_VF; -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->port_conf.rxmode.hw_strip_crc = 1; -#elif RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) +#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP; #endif if (dm->conf->no_tx_checksum_offload == 0) { -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->tx_conf.txq_flags &= ~(ETH_TXQ_FLAGS_NOXSUMUDP | - ETH_TXQ_FLAGS_NOXSUMTCP); -#else xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; -#endif - xd->flags |= - DPDK_DEVICE_FLAG_TX_OFFLOAD; + xd->flags |= DPDK_DEVICE_FLAG_TX_OFFLOAD; } break; case VNET_DPDK_PMD_ENA: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_VF; -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->port_conf.rxmode.enable_scatter = 0; -#else xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_SCATTER; -#endif break; case VNET_DPDK_PMD_DPAA2: @@ -549,9 +517,7 @@ dpdk_lib_init (dpdk_main_t * dm) /* Intel Red Rock Canyon */ case VNET_DPDK_PMD_FM10K: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_SWITCH; -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->port_conf.rxmode.hw_strip_crc = 1; -#elif RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) +#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CRC_STRIP; #endif break; @@ -566,11 +532,7 @@ dpdk_lib_init (dpdk_main_t * dm) /* vmxnet3 */ case VNET_DPDK_PMD_VMXNET3: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_1G; -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS; -#else xd->port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS; -#endif break; case VNET_DPDK_PMD_AF_PACKET: @@ -828,14 +790,10 @@ dpdk_lib_init (dpdk_main_t * dm) int vlan_off; vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id); vlan_off |= ETH_VLAN_STRIP_OFFLOAD; -#if RTE_VERSION < RTE_VERSION_NUM(18, 8, 0, 0) - xd->port_conf.rxmode.hw_vlan_strip = vlan_off; -#else if (vlan_off) xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; else xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; -#endif if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) == 0) dpdk_log_info ("VLAN strip enabled for interface\n"); else @@ -871,6 +829,7 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf) int num_whitelisted = vec_len (conf->dev_confs); vlib_pci_device_info_t *d = 0; vlib_pci_addr_t *addr = 0, *addrs; + int i; addrs = vlib_pci_get_all_dev_addrs (); /* *INDENT-OFF* */ @@ -899,11 +858,41 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf) uword * p = hash_get (conf->device_config_index_by_pci_addr, addr->as_u32); if (!p) - continue; + { + skipped: + continue; + } devconf = pool_elt_at_index (conf->dev_confs, p[0]); } + /* Enforce Device blacklist by vendor and device */ + for (i = 0; i < vec_len (conf->blacklist_by_pci_vendor_and_device); i++) + { + u16 vendor, device; + vendor = (u16)(conf->blacklist_by_pci_vendor_and_device[i] >> 16); + device = (u16)(conf->blacklist_by_pci_vendor_and_device[i] & 0xFFFF); + if (d->vendor_id == vendor && d->device_id == device) + { + /* + * Expected case: device isn't whitelisted, + * so blacklist it... + */ + if (devconf == 0) + { + /* Device is blacklisted */ + pool_get (conf->dev_confs, devconf); + hash_set (conf->device_config_index_by_pci_addr, addr->as_u32, + devconf - conf->dev_confs); + devconf->pci_addr.as_u32 = addr->as_u32; + devconf->is_blacklisted = 1; + goto skipped; + } + else /* explicitly whitelisted, ignore the device blacklist */ + break; + } + } + /* virtio */ if (d->vendor_id == 0x1af4 && (d->device_id == VIRTIO_PCI_LEGACY_DEVICEID_NET || @@ -985,6 +974,27 @@ dpdk_bind_devices_to_uio (dpdk_config_main_t * conf) vlib_pci_free_device_info (d); } +static void +dpdk_bind_vmbus_devices_to_uio (dpdk_config_main_t * conf) +{ + clib_error_t *error; + vlib_vmbus_addr_t *addrs, *addr = 0; + + addrs = vlib_vmbus_get_all_dev_addrs (); + + /* *INDENT-OFF* */ + vec_foreach (addr, addrs) + { + error = vlib_vmbus_bind_to_uio (addr); + + if (error) + { + clib_error_report (error); + } + } + /* *INDENT-ON* */ +} + 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) @@ -1127,17 +1137,17 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) dpdk_device_config_t *devconf; vlib_pci_addr_t pci_addr; unformat_input_t sub_input; - uword x; + uword default_hugepage_sz, x; u8 *s, *tmp = 0; u32 log_level; int ret, i; int num_whitelisted = 0; u8 no_pci = 0; - u8 no_huge = 0; - u8 huge_dir = 0; + u8 no_vmbus = 0; u8 file_prefix = 0; u8 *socket_mem = 0; u8 *huge_dir_path = 0; + u32 vendor, device; huge_dir_path = format (0, "%s/hugepages%c", vlib_unix_get_runtime_dir (), 0); @@ -1151,7 +1161,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) if (unformat (input, "no-hugetlb")) { vec_add1 (conf->eal_init_args, (u8 *) "--no-huge"); - no_huge = 1; } else if (unformat (input, "enable-tcp-udp-checksum")) @@ -1214,6 +1223,23 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) tmp = format (0, "--no-pci%c", 0); vec_add1 (conf->eal_init_args, tmp); } + else if (unformat (input, "blacklist %x:%x", &vendor, &device)) + { + u32 blacklist_entry; + if (vendor > 0xFFFF) + return clib_error_return (0, "blacklist PCI vendor out of range"); + if (device > 0xFFFF) + return clib_error_return (0, "blacklist PCI device out of range"); + blacklist_entry = (vendor << 16) | (device & 0xffff); + vec_add1 (conf->blacklist_by_pci_vendor_and_device, + blacklist_entry); + } + else if (unformat (input, "no-vmbus")) + { + no_vmbus = 1; + tmp = format (0, "--no-vmbus%c", 0); + vec_add1 (conf->eal_init_args, tmp); + } #define _(a) \ else if (unformat(input, #a)) \ @@ -1226,9 +1252,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) #define _(a) \ else if (unformat(input, #a " %s", &s)) \ { \ - if (!strncmp(#a, "huge-dir", 8)) \ - huge_dir = 1; \ - else if (!strncmp(#a, "file-prefix", 11)) \ + if (!strncmp(#a, "file-prefix", 11)) \ file_prefix = 1; \ tmp = format (0, "--%s%c", #a, 0); \ vec_add1 (conf->eal_init_args, tmp); \ @@ -1277,107 +1301,29 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) if (!conf->uio_driver_name) conf->uio_driver_name = format (0, "auto%c", 0); - /* - * Use 1G huge pages if available. - */ - if (!no_huge && !huge_dir) - { - u32 x, *mem_by_socket = 0; - uword c = 0; - int rv; + default_hugepage_sz = clib_mem_get_default_hugepage_size (); - umount ((char *) huge_dir_path); - - /* Process "socket-mem" parameter value */ - if (vec_len (socket_mem)) - { - unformat_input_t in; - unformat_init_vector (&in, socket_mem); - while (unformat_check_input (&in) != UNFORMAT_END_OF_INPUT) - { - if (unformat (&in, "%u,", &x)) - ; - else if (unformat (&in, "%u", &x)) - ; - else if (unformat (&in, ",")) - x = 0; - else - break; - - vec_add1 (mem_by_socket, x); - } - /* Note: unformat_free vec_frees(in.buffer), aka socket_mem... */ - unformat_free (&in); - socket_mem = 0; - } - else - { - /* *INDENT-OFF* */ - clib_bitmap_foreach (c, tm->cpu_socket_bitmap, ( - { - vec_validate(mem_by_socket, c); - mem_by_socket[c] = 64; /* default per-socket mem */ - } - )); - /* *INDENT-ON* */ - } - - uword default_hugepage_sz = clib_mem_get_default_hugepage_size (); - /* *INDENT-OFF* */ - clib_bitmap_foreach (c, tm->cpu_socket_bitmap, ( - { - clib_error_t *e; - uword n_pages; - vec_validate(mem_by_socket, c); - n_pages = round_pow2 ((uword) mem_by_socket[c]<<20, - default_hugepage_sz); - n_pages /= default_hugepage_sz; - - if ((e = clib_sysfs_prealloc_hugepages(c, 0, n_pages))) - clib_error_report (e); - })); - /* *INDENT-ON* */ - - if (mem_by_socket == 0) - { - error = clib_error_return (0, "mem_by_socket NULL"); - goto done; - } - _vec_len (mem_by_socket) = c + 1; - - /* regenerate socket_mem string */ - vec_foreach_index (x, mem_by_socket) - socket_mem = format (socket_mem, "%s%u", - socket_mem ? "," : "", mem_by_socket[x]); - socket_mem = format (socket_mem, "%c", 0); - - vec_free (mem_by_socket); - - error = vlib_unix_recursive_mkdir ((char *) huge_dir_path); - if (error) - { - goto done; - } - - rv = mount ("none", (char *) huge_dir_path, "hugetlbfs", 0, NULL); - - if (rv) - { - error = clib_error_return (0, "mount failed %d", errno); - goto done; - } + /* *INDENT-OFF* */ + clib_bitmap_foreach (x, tm->cpu_socket_bitmap, ( + { + clib_error_t *e; + uword n_pages; + /* preallocate at least 16MB of hugepages per socket, + if more is needed it is up to consumer to preallocate more */ + n_pages = round_pow2 ((uword) 16 << 20, default_hugepage_sz); + n_pages /= default_hugepage_sz; + + if ((e = clib_sysfs_prealloc_hugepages(x, 0, n_pages))) + clib_error_report (e); + })); + /* *INDENT-ON* */ - tmp = format (0, "--huge-dir%c", 0); + if (!file_prefix) + { + tmp = format (0, "--file-prefix%c", 0); vec_add1 (conf->eal_init_args, tmp); - tmp = format (0, "%s%c", huge_dir_path, 0); + tmp = format (0, "vpp%c", 0); vec_add1 (conf->eal_init_args, tmp); - if (!file_prefix) - { - tmp = format (0, "--file-prefix%c", 0); - vec_add1 (conf->eal_init_args, tmp); - tmp = format (0, "vpp%c", 0); - vec_add1 (conf->eal_init_args, tmp); - } } if (error) @@ -1417,6 +1363,9 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) if (no_pci == 0 && geteuid () == 0) dpdk_bind_devices_to_uio (conf); + if (no_vmbus == 0 && geteuid () == 0) + dpdk_bind_vmbus_devices_to_uio (conf); + #define _(x) \ if (devconf->x == 0 && conf->default_devconf.x > 0) \ devconf->x = conf->default_devconf.x ; @@ -1453,14 +1402,9 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) tmp = format (0, "%u%c", tm->main_lcore, 0); vec_add1 (conf->eal_init_args, tmp); - /* set socket-mem */ - if (!no_huge) - { - tmp = format (0, "--socket-mem%c", 0); - vec_add1 (conf->eal_init_args, tmp); - tmp = format (0, "%s%c", socket_mem, 0); - vec_add1 (conf->eal_init_args, tmp); - } + + if (socket_mem) + clib_warning ("socket-mem argument is deprecated"); /* NULL terminate the "argv" vector, in case of stupidity */ vec_add1 (conf->eal_init_args, 0); @@ -1828,6 +1772,7 @@ dpdk_init (vlib_main_t * vm) dm->conf->nchannels = 4; dm->conf->num_mbufs = dm->conf->num_mbufs ? dm->conf->num_mbufs : NB_MBUF; vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet"); + vec_add1 (dm->conf->eal_init_args, (u8 *) "--in-memory"); /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */ dm->buffer_flags_template = (VLIB_BUFFER_TOTAL_LENGTH_VALID |