Signed-off-by: Cunming Liang <cunming.liang at intel.com> --- lib/librte_eal/common/include/rte_pci.h | 4 ++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 42 +++++++++++++++++++++------------ lib/librte_ether/rte_ethdev.c | 3 +-- 3 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 66ed793..e205330 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -139,11 +139,13 @@ struct rte_pci_addr { struct rte_devargs; +#define RTE_PCI_DEV_NAME_SIZE (32) /** * A structure describing a PCI device. */ struct rte_pci_device { TAILQ_ENTRY(rte_pci_device) next; /**< Next probed PCI device. */ + char name[RTE_PCI_DEV_NAME_SIZE]; /**< PCI device name. */ struct rte_pci_addr addr; /**< PCI location. */ struct rte_pci_id id; /**< PCI ID. */ struct rte_pci_resource mem_resource[PCI_MAX_RESOURCE]; /**< PCI Memory Resource */ @@ -199,6 +201,8 @@ struct rte_pci_driver { #define RTE_PCI_DRV_FORCE_UNBIND 0x0004 /** Device driver supports link state interrupt */ #define RTE_PCI_DRV_INTR_LSC 0x0008 +/** Device driver supports bifurcated queue pair mapping */ +#define RTE_PCI_DRV_BIFURC 0x0010 /**< Internal use only - Macro used by pci addr parsing functions **/ #define GET_PCIADDR_FIELD(in, fd, lim, dlm) \ diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index ddb0535..8a97906 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -284,6 +284,10 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, return -1; } + /* record pci address as device name */ + snprintf(dev->name, RTE_PCI_DEV_NAME_SIZE, "%d:%d.%d", + bus, devid, function); + /* device is valid, add in list (sorted) */ if (TAILQ_EMPTY(&pci_device_list)) { TAILQ_INSERT_TAIL(&pci_device_list, dev, next); @@ -549,23 +553,31 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d return 1; } - if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { + if ((dev->devargs != NULL) && + (dev->devargs->type == RTE_DEVTYPE_VIRTUAL)) { + if (!(dr->drv_flags & RTE_PCI_DRV_BIFURC)) + return 1; + } else { + if (dr->drv_flags & RTE_PCI_DRV_BIFURC) + return 1; + else if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { #ifdef RTE_PCI_CONFIG - /* - * Set PCIe config space for high performance. - * Return value can be ignored. - */ - pci_config_space_set(dev); + /* + * Set PCIe config space for high performance. + * Return value can be ignored. + */ + pci_config_space_set(dev); #endif - /* map resources for devices that use igb_uio */ - ret = pci_map_device(dev); - if (ret != 0) - return ret; - } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && - rte_eal_process_type() == RTE_PROC_PRIMARY) { - /* unbind current driver */ - if (pci_unbind_kernel_driver(dev) < 0) - return -1; + /* map resources for devices that use igb_uio */ + ret = pci_map_device(dev); + if (ret != 0) + return ret; + } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && + rte_eal_process_type() == RTE_PROC_PRIMARY) { + /* unbind current driver */ + if (pci_unbind_kernel_driver(dev) < 0) + return -1; + } } /* reference driver structure */ diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 3e2b5d8..76be736 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -246,8 +246,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv, eth_drv = (struct eth_driver *)pci_drv; /* Create unique Ethernet device name using PCI address */ - snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d", - pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); + snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%s", pci_dev->name); eth_dev = rte_eth_dev_allocate(ethdev_name); if (eth_dev == NULL) -- 1.8.1.4