From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id A6279590F for ; Tue, 25 Nov 2014 15:02:32 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 25 Nov 2014 06:12:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,455,1413270000"; d="scan'208";a="637798945" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 25 Nov 2014 06:11:56 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sAPEBse5023876; Tue, 25 Nov 2014 22:11:54 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sAPEBq1K024235; Tue, 25 Nov 2014 22:11:54 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAPEBqvv024231; Tue, 25 Nov 2014 22:11:52 +0800 From: Cunming Liang To: dev@dpdk.org Date: Tue, 25 Nov 2014 22:11:19 +0800 Message-Id: <1416924682-24170-4-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1416924682-24170-1-git-send-email-cunming.liang@intel.com> References: <1416924682-24170-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [RFC PATCH 3/6] pci: allow VDEV as pci device during device driver probe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Nov 2014 14:02:33 -0000 Signed-off-by: Cunming Liang --- 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