DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cunming Liang <cunming.liang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [RFC PATCH 3/6] pci: allow VDEV as pci device during device driver probe
Date: Tue, 25 Nov 2014 22:11:19 +0800	[thread overview]
Message-ID: <1416924682-24170-4-git-send-email-cunming.liang@intel.com> (raw)
In-Reply-To: <1416924682-24170-1-git-send-email-cunming.liang@intel.com>

Signed-off-by: Cunming Liang <cunming.liang@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

  parent reply	other threads:[~2014-11-25 14:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 14:11 [dpdk-dev] [RFC PATCH 0/6] DPDK support to bifurcated driver Cunming Liang
2014-11-25 14:11 ` [dpdk-dev] [RFC PATCH 1/6] eal: common direct ring access API Cunming Liang
2014-11-25 14:11 ` [dpdk-dev] [RFC PATCH 2/6] eal: direct ring access support by linux af_packet Cunming Liang
2014-11-25 14:11 ` Cunming Liang [this message]
2014-11-25 14:11 ` [dpdk-dev] [RFC PATCH 4/6] bifurc: add driver to scan bifurcated netdev Cunming Liang
2014-11-25 14:11 ` [dpdk-dev] [RFC PATCH 5/6] ixgbe: rx/tx queue stop bug fix Cunming Liang
2014-11-26  0:44   ` Ouyang, Changchun
2014-11-25 14:11 ` [dpdk-dev] [RFC PATCH 6/6] ixgbe: PMD for bifurc ixgbe net device Cunming Liang
2014-11-25 14:34   ` Bruce Richardson
2014-11-25 14:48     ` Liang, Cunming
2014-11-25 15:01       ` Bruce Richardson
2014-11-26  8:22         ` Liang, Cunming
2014-11-26 10:35           ` Bruce Richardson
2014-11-25 14:23 ` [dpdk-dev] [RFC PATCH 0/6] DPDK support to bifurcated driver Neil Horman
2014-11-25 14:29   ` Bruce Richardson
2014-11-25 14:40     ` Liang, Cunming
2014-11-25 14:46       ` Zhou, Danny
2014-11-25 14:57     ` Walukiewicz, Miroslaw
2014-11-25 15:02       ` Bruce Richardson
2014-11-25 15:23         ` Zhou, Danny
2014-11-26 10:45           ` Walukiewicz, Miroslaw
2014-11-26 12:22             ` Zhou, Danny
2015-04-09  3:43 ` 贾学涛
2015-04-20  9:53   ` Shelton Chia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416924682-24170-4-git-send-email-cunming.liang@intel.com \
    --to=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).