X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fdpdk%2Fdevice%2Finit.c;h=81803ab1cb4ba57cef1cace83654b956e378e832;hb=c4665093cdb0a8122d9640b6f5b3acd627918f32;hp=3eb510d6142588bae010740ef41613e7408bb620;hpb=827b929301ba3c8ac3a3d23262b0987a5fc33632;p=vpp.git diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 3eb510d6142..81803ab1cb4 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -113,44 +113,34 @@ dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags) { dpdk_main_t *dm = &dpdk_main; dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance); - u32 old = 0; + u32 old = (xd->flags & DPDK_DEVICE_FLAG_PROMISC) != 0; - if (ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC (flags)) - { - old = (xd->flags & DPDK_DEVICE_FLAG_PROMISC) != 0; - - if (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) - xd->flags |= DPDK_DEVICE_FLAG_PROMISC; - else - xd->flags &= ~DPDK_DEVICE_FLAG_PROMISC; - - if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) - { - if (xd->flags & DPDK_DEVICE_FLAG_PROMISC) - rte_eth_promiscuous_enable (xd->port_id); - else - rte_eth_promiscuous_disable (xd->port_id); - } - } - else if (ETHERNET_INTERFACE_FLAG_CONFIG_MTU (flags)) + switch (flags) { + case ETHERNET_INTERFACE_FLAG_DEFAULT_L3: + /* set to L3/non-promisc mode */ + xd->flags &= ~DPDK_DEVICE_FLAG_PROMISC; + break; + case ETHERNET_INTERFACE_FLAG_ACCEPT_ALL: + xd->flags |= DPDK_DEVICE_FLAG_PROMISC; + break; + case ETHERNET_INTERFACE_FLAG_MTU: xd->port_conf.rxmode.max_rx_pkt_len = hi->max_packet_bytes; dpdk_device_setup (xd); + return 0; + default: + return ~0; } - return old; -} -static void -dpdk_device_lock_init (dpdk_device_t * xd) -{ - int q; - vec_validate (xd->lockp, xd->tx_q_used - 1); - for (q = 0; q < xd->tx_q_used; q++) + if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) { - xd->lockp[q] = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, - CLIB_CACHE_LINE_BYTES); - clib_memset ((void *) xd->lockp[q], 0, CLIB_CACHE_LINE_BYTES); + if (xd->flags & DPDK_DEVICE_FLAG_PROMISC) + rte_eth_promiscuous_enable (xd->port_id); + else + rte_eth_promiscuous_disable (xd->port_id); } + + return old; } static int @@ -619,9 +609,6 @@ dpdk_lib_init (dpdk_main_t * dm) else rte_eth_macaddr_get (i, (void *) addr); - if (xd->tx_q_used < tm->n_vlib_mains) - dpdk_device_lock_init (xd); - xd->port_id = i; xd->device_index = xd - dm->devices; xd->per_interface_next_index = ~0; @@ -629,7 +616,6 @@ dpdk_lib_init (dpdk_main_t * dm) /* assign interface to input thread */ int q; - error = ethernet_register_interface (dm->vnet_main, dpdk_device_class.index, xd->device_index, /* ethernet address */ addr, @@ -743,6 +729,12 @@ dpdk_lib_init (dpdk_main_t * dm) hi->max_packet_bytes = mtu; hi->max_supported_packet_bytes = max_rx_frame; hi->numa_node = xd->cpu_socket; + + /* Indicate ability to support L3 DMAC filtering and + * initialize interface to L3 non-promisc mode */ + hi->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_MAC_FILTER; + ethernet_set_flags (dm->vnet_main, xd->hw_if_index, + ETHERNET_INTERFACE_FLAG_DEFAULT_L3); } if (dm->conf->no_tx_checksum_offload == 0) @@ -766,10 +758,20 @@ dpdk_lib_init (dpdk_main_t * dm) dpdk_device_setup (xd); + /* rss queues should be configured after dpdk_device_setup() */ + if (devconf->rss_queues != NULL) + { + if (vnet_hw_interface_set_rss_queues + (vnet_get_main (), hi, devconf->rss_queues)) + { + clib_warning ("%s: Failed to set rss queues", hi->name); + } + } + if (vec_len (xd->errors)) - dpdk_log_err ("setup failed for device %U. Errors:\n %U", - format_dpdk_device_name, i, - format_dpdk_device_errors, xd); + dpdk_log_err ("setup failed for device %U. Errors:\n %U", + format_dpdk_device_name, i, + format_dpdk_device_errors, xd); /* * A note on Cisco VIC (PMD_ENIC) and VLAN: @@ -796,38 +798,39 @@ dpdk_lib_init (dpdk_main_t * dm) * otherwise in the startup config. */ - vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id); - if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON) - { - vlan_off |= ETH_VLAN_STRIP_OFFLOAD; - if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0) - dpdk_log_info ("VLAN strip enabled for interface\n"); - else - dpdk_log_warn ("VLAN strip cannot be supported by interface\n"); - xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; - } - else - { - if (vlan_off & ETH_VLAN_STRIP_OFFLOAD) - { - vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD; - if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0) - dpdk_log_warn ("set VLAN offload failed\n"); - } - xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; - } + vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id); + if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON) + { + vlan_off |= ETH_VLAN_STRIP_OFFLOAD; + if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0) + dpdk_log_info ("VLAN strip enabled for interface\n"); + else + dpdk_log_warn ("VLAN strip cannot be supported by interface\n"); + xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; + } + else + { + if (vlan_off & ETH_VLAN_STRIP_OFFLOAD) + { + vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD; + if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0) + dpdk_log_warn ("set VLAN offload failed\n"); + } + xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; + } - if (hi) - hi->max_packet_bytes = xd->port_conf.rxmode.max_rx_pkt_len - - sizeof (ethernet_header_t); - else - dpdk_log_warn ("hi NULL"); + if (hi) + hi->max_packet_bytes = xd->port_conf.rxmode.max_rx_pkt_len + - sizeof (ethernet_header_t); + else + dpdk_log_warn ("hi NULL"); - if (dm->conf->no_multi_seg) - mtu = mtu > ETHER_MAX_LEN ? ETHER_MAX_LEN : mtu; + if (dm->conf->no_multi_seg) + mtu = mtu > ETHER_MAX_LEN ? ETHER_MAX_LEN : mtu; + + rte_eth_dev_set_mtu (xd->port_id, mtu); +} - rte_eth_dev_set_mtu (xd->port_id, mtu); - } /* *INDENT-ON* */ return 0; @@ -1101,6 +1104,9 @@ dpdk_device_config (dpdk_config_main_t * conf, vlib_pci_addr_t pci_addr, } else if (unformat (input, "devargs %s", &devconf->devargs)) ; + else if (unformat (input, "rss-queues %U", + unformat_bitmap_list, &devconf->rss_queues)) + ; else { error = clib_error_return (0, "unknown input `%U'", @@ -1175,7 +1181,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) u8 file_prefix = 0; u8 *socket_mem = 0; u8 *huge_dir_path = 0; - u32 vendor, device; + u32 vendor, device, domain, bus, func; huge_dir_path = format (0, "%s/hugepages%c", vlib_unix_get_runtime_dir (), 0); @@ -1248,6 +1254,15 @@ 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:%x.%x", &domain, &bus, &device, &func)) + { + tmp = + format (0, "-b %04x:%02x:%02x.%x%c", domain, bus, device, func, + 0); + vec_add1 (conf->eal_init_args, tmp); + } else if (unformat (input, "blacklist %x:%x", &vendor, &device)) { u32 blacklist_entry; @@ -1414,6 +1429,9 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) /* copy tso config from default device */ _(devargs) + /* copy rss_queues config from default device */ + _(rss_queues) + /* add DPDK EAL whitelist/blacklist entry */ if (num_whitelisted > 0 && devconf->is_blacklisted == 0) {