diff options
Diffstat (limited to 'src/plugins/dpdk/device')
-rw-r--r-- | src/plugins/dpdk/device/cli.c | 54 | ||||
-rw-r--r-- | src/plugins/dpdk/device/format.c | 20 | ||||
-rw-r--r-- | src/plugins/dpdk/device/init.c | 46 |
3 files changed, 89 insertions, 31 deletions
diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c index 25308588469..2a49771ef26 100644 --- a/src/plugins/dpdk/device/cli.c +++ b/src/plugins/dpdk/device/cli.c @@ -46,6 +46,7 @@ get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd, dpdk_main_t *dm = &dpdk_main; vnet_hw_interface_t *hw; struct rte_eth_dev_info dev_info; + struct rte_pci_device *pci_dev; uword *p = 0; clib_error_t *error = NULL; @@ -66,14 +67,21 @@ get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd, *xd = vec_elt_at_index (dm->devices, hw->dev_instance); rte_eth_dev_info_get ((*xd)->port_id, &dev_info); - if (dev_info.pci_dev) + +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) + pci_dev = dev_info.pci_dev; +#else + pci_dev = RTE_DEV_TO_PCI (dev_info.device); +#endif + + if (pci_dev) { /* bonded interface has no pci info */ vlib_pci_addr_t pci_addr; - pci_addr.domain = dev_info.pci_dev->addr.domain; - pci_addr.bus = dev_info.pci_dev->addr.bus; - pci_addr.slot = dev_info.pci_dev->addr.devid; - pci_addr.function = dev_info.pci_dev->addr.function; + pci_addr.domain = pci_dev->addr.domain; + pci_addr.bus = pci_dev->addr.bus; + pci_addr.slot = pci_dev->addr.devid; + pci_addr.function = pci_dev->addr.function; p = hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32); @@ -1218,6 +1226,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, /* Device specific data */ struct rte_eth_dev_info dev_info; + struct rte_pci_device *pci_dev; dpdk_device_config_t *devconf = 0; vnet_hw_interface_t *hw; dpdk_device_t *xd; @@ -1284,14 +1293,21 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, xd = vec_elt_at_index (dm->devices, hw->dev_instance); rte_eth_dev_info_get (xd->port_id, &dev_info); - if (dev_info.pci_dev) + +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) + pci_dev = dev_info.pci_dev; +#else + pci_dev = RTE_DEV_TO_PCI (dev_info.device); +#endif + + if (pci_dev) { /* bonded interface has no pci info */ vlib_pci_addr_t pci_addr; - pci_addr.domain = dev_info.pci_dev->addr.domain; - pci_addr.bus = dev_info.pci_dev->addr.bus; - pci_addr.slot = dev_info.pci_dev->addr.devid; - pci_addr.function = dev_info.pci_dev->addr.function; + pci_addr.domain = pci_dev->addr.domain; + pci_addr.bus = pci_dev->addr.bus; + pci_addr.slot = pci_dev->addr.devid; + pci_addr.function = pci_dev->addr.function; p = hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32); @@ -1443,6 +1459,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, u32 hw_if_index = (u32) ~ 0; u32 profile_id, subport_id, i; struct rte_eth_dev_info dev_info; + struct rte_pci_device *pci_dev; dpdk_device_config_t *devconf = 0; vlib_thread_registration_t *tr; uword *p = 0; @@ -1475,14 +1492,21 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, xd = vec_elt_at_index (dm->devices, hw->dev_instance); rte_eth_dev_info_get (xd->port_id, &dev_info); - if (dev_info.pci_dev) + +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) + pci_dev = dev_info.pci_dev; +#else + pci_dev = RTE_DEV_TO_PCI (dev_info.device); +#endif + + if (pci_dev) { /* bonded interface has no pci info */ vlib_pci_addr_t pci_addr; - pci_addr.domain = dev_info.pci_dev->addr.domain; - pci_addr.bus = dev_info.pci_dev->addr.bus; - pci_addr.slot = dev_info.pci_dev->addr.devid; - pci_addr.function = dev_info.pci_dev->addr.function; + pci_addr.domain = pci_dev->addr.domain; + pci_addr.bus = pci_dev->addr.bus; + pci_addr.slot = pci_dev->addr.devid; + pci_addr.function = pci_dev->addr.function; p = hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32); diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c index f10b00e27a6..4b8e3be5240 100644 --- a/src/plugins/dpdk/device/format.c +++ b/src/plugins/dpdk/device/format.c @@ -163,6 +163,7 @@ format_dpdk_device_name (u8 * s, va_list * args) char *device_name; u32 i = va_arg (*args, u32); struct rte_eth_dev_info dev_info; + struct rte_pci_device *pci_dev; u8 *ret; if (dm->conf->interface_name_format_decimal) @@ -246,12 +247,15 @@ format_dpdk_device_name (u8 * s, va_list * args) } rte_eth_dev_info_get (i, &dev_info); - - if (dev_info.pci_dev && - dm->devices[i].port_type != VNET_DPDK_PORT_TYPE_FAILSAFE) - ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus, - dev_info.pci_dev->addr.devid, - dev_info.pci_dev->addr.function); +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) + pci_dev = dev_info.pci_dev; +#else + pci_dev = RTE_DEV_TO_PCI (dev_info.device); +#endif + + if (pci_dev && dm->devices[i].port_type != VNET_DPDK_PORT_TYPE_FAILSAFE) + ret = format (s, devname_format, device_name, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function); else ret = format (s, "%s%d", device_name, dm->devices[i].port_id); @@ -507,7 +511,11 @@ format_dpdk_device (u8 * s, va_list * args) retval = rte_eth_dev_rss_hash_conf_get (xd->port_id, &rss_conf); if (retval < 0) clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval); +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) pci = di.pci_dev; +#else + pci = RTE_DEV_TO_PCI (di.device); +#endif if (pci) s = diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index ceaa5bb61e9..2232b89e1b3 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -227,7 +227,12 @@ dpdk_lib_init (dpdk_main_t * dm) vec_validate_aligned (dm->devices_by_hqos_cpu, tm->n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES); +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) nports = rte_eth_dev_count (); +#else + nports = rte_eth_dev_count_avail (); +#endif + if (nports < 1) { dpdk_log_notice ("DPDK drivers found no ports..."); @@ -260,19 +265,36 @@ dpdk_lib_init (dpdk_main_t * dm) u8 addr[6]; u8 vlan_strip = 0; struct rte_eth_dev_info dev_info; + struct rte_pci_device *pci_dev; struct rte_eth_link l; dpdk_device_config_t *devconf = 0; vlib_pci_addr_t pci_addr; uword *p = 0; + if (!rte_eth_dev_is_valid_port(i)) + continue; + rte_eth_link_get_nowait (i, &l); rte_eth_dev_info_get (i, &dev_info); - if (dev_info.pci_dev) /* bonded interface has no pci info */ + +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) + pci_dev = dev_info.pci_dev; +#else + if (dev_info.device == 0) + { + clib_warning ("DPDK bug: missing device info. Skipping %s device", + dev_info.driver_name); + continue; + } + pci_dev = RTE_DEV_TO_PCI (dev_info.device); +#endif + + if (pci_dev) /* bonded interface has no pci info */ { - pci_addr.domain = dev_info.pci_dev->addr.domain; - pci_addr.bus = dev_info.pci_dev->addr.bus; - pci_addr.slot = dev_info.pci_dev->addr.devid; - pci_addr.function = dev_info.pci_dev->addr.function; + pci_addr.domain = pci_dev->addr.domain; + pci_addr.bus = pci_dev->addr.bus; + pci_addr.slot = pci_dev->addr.devid; + pci_addr.function = pci_dev->addr.function; p = hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32); @@ -290,12 +312,12 @@ dpdk_lib_init (dpdk_main_t * dm) xd->cpu_socket = (i8) rte_eth_dev_socket_id (i); /* Handle interface naming for devices with multiple ports sharing same PCI ID */ - if (dev_info.pci_dev) + if (pci_dev) { struct rte_eth_dev_info di = { 0 }; rte_eth_dev_info_get (i + 1, &di); - if (di.pci_dev && pci_addr.as_u32 != last_pci_addr.as_u32 && - memcmp (&dev_info.pci_dev->addr, &di.pci_dev->addr, + if (pci_dev && pci_addr.as_u32 != last_pci_addr.as_u32 && + memcmp (&pci_dev->addr, &pci_dev->addr, sizeof (struct rte_pci_addr)) == 0) { xd->interface_name_suffix = format (0, "0"); @@ -358,8 +380,8 @@ dpdk_lib_init (dpdk_main_t * dm) xd->flags |= DPDK_DEVICE_FLAG_PMD; /* workaround for drivers not setting driver_name */ - if ((!dev_info.driver_name) && (dev_info.pci_dev)) - dev_info.driver_name = dev_info.pci_dev->driver->driver.name; + if ((!dev_info.driver_name) && (pci_dev)) + dev_info.driver_name = pci_dev->driver->driver.name; ASSERT (dev_info.driver_name); @@ -1533,7 +1555,11 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) * 2. Set up info and register slave link state change callback handling. * 3. Set up info for bond interface related CLI support. */ +#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) int nports = rte_eth_dev_count (); +#else + int nports = rte_eth_dev_count_avail (); +#endif if (nports > 0) { /* *INDENT-OFF* */ |