Steve Shin | 268e64e | 2017-10-09 15:04:56 -0700 | [diff] [blame] | 1 | diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c |
| 2 | index bb634c6..7c65dda 100644 |
| 3 | --- a/drivers/net/bonding/rte_eth_bond_args.c |
| 4 | +++ b/drivers/net/bonding/rte_eth_bond_args.c |
| 5 | @@ -61,16 +61,6 @@ |
| 6 | unsigned i; |
| 7 | |
| 8 | for (i = 0; i < rte_eth_dev_count(); i++) { |
| 9 | - |
| 10 | - /* Currently populated by rte_eth_copy_pci_info(). |
| 11 | - * |
| 12 | - * TODO: Once the PCI bus has arrived we should have a better |
| 13 | - * way to test for being a PCI device or not. |
| 14 | - */ |
| 15 | - if (rte_eth_devices[i].data->kdrv == RTE_KDRV_UNKNOWN || |
| 16 | - rte_eth_devices[i].data->kdrv == RTE_KDRV_NONE) |
| 17 | - continue; |
| 18 | - |
| 19 | pci_dev = RTE_ETH_DEV_TO_PCI(&rte_eth_devices[i]); |
| 20 | eth_pci_addr = &pci_dev->addr; |
| 21 | |
| 22 | @@ -98,6 +88,16 @@ |
| 23 | return -1; |
| 24 | } |
| 25 | |
| 26 | +static inline int |
| 27 | +pci_addr_cmp(const struct rte_device *dev, const void *_pci_addr) |
| 28 | +{ |
| 29 | + struct rte_pci_device *pdev; |
| 30 | + const struct rte_pci_addr *paddr = _pci_addr; |
| 31 | + |
| 32 | + pdev = RTE_DEV_TO_PCI(*(struct rte_device **)(void *)&dev); |
| 33 | + return rte_eal_compare_pci_addr(&pdev->addr, paddr); |
| 34 | +} |
| 35 | + |
| 36 | /** |
| 37 | * Parses a port identifier string to a port id by pci address, then by name, |
| 38 | * and finally port id. |
| 39 | @@ -106,10 +106,23 @@ |
| 40 | parse_port_id(const char *port_str) |
| 41 | { |
| 42 | struct rte_pci_addr dev_addr; |
| 43 | + struct rte_bus *pci_bus; |
| 44 | + struct rte_device *dev; |
| 45 | int port_id; |
| 46 | |
| 47 | + pci_bus = rte_bus_find_by_name("pci"); |
| 48 | + if (pci_bus == NULL) { |
| 49 | + RTE_LOG(ERR, PMD, "unable to find PCI bus\n"); |
| 50 | + return -1; |
| 51 | + } |
| 52 | + |
| 53 | /* try parsing as pci address, physical devices */ |
| 54 | - if (eal_parse_pci_DomBDF(port_str, &dev_addr) == 0) { |
| 55 | + if (pci_bus->parse(port_str, &dev_addr) == 0) { |
| 56 | + dev = pci_bus->find_device(NULL, pci_addr_cmp, &dev_addr); |
| 57 | + if (dev == NULL) { |
| 58 | + RTE_LOG(ERR, PMD, "unable to find PCI device\n"); |
| 59 | + return -1; |
| 60 | + } |
| 61 | port_id = find_port_id_by_pci_addr(&dev_addr); |
| 62 | if (port_id < 0) |
| 63 | return -1; |