All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Subject: [PATCH v3 5/8] eal: Consolidate pci_map/unmap_device() of linuxapp and bsdapp
Date: Mon, 29 Jun 2015 11:56:47 +0900	[thread overview]
Message-ID: <1435546610-4533-6-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1435546610-4533-1-git-send-email-mukawa@igel.co.jp>

From: "Tetsuya.Mukawa" <mukawa@igel.co.jp>

The patch consolidates below functions, and implemented in common
eal code.
 - pci_map_device()
 - pci_unmap_device()

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_eal/bsdapp/eal/eal_pci.c     | 12 +++----
 lib/librte_eal/common/eal_common_pci.c  | 57 +++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_private.h     |  4 +--
 lib/librte_eal/common/include/rte_pci.h |  1 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 55 -------------------------------
 lib/librte_ether/rte_ethdev.c           |  1 +
 6 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 2a623e3..56dc98c 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -275,7 +275,7 @@ fail:
 }
 
 /* map the PCI resource of a PCI device in virtual memory */
-static int
+int
 pci_uio_map_resource(struct rte_pci_device *dev)
 {
 	int i, map_idx, ret;
@@ -366,6 +366,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 	/* FreeBSD has no NUMA support (yet) */
 	dev->numa_node = 0;
 
+	/* FreeBSD has only one pass through driver */
+	dev->kdrv = RTE_KDRV_NIC_UIO;
+
 	/* parse resources */
 	switch (conf->pc_hdr & PCIM_HDRTYPE) {
 	case PCIM_HDRTYPE_NORMAL:
@@ -430,13 +433,6 @@ skipdev:
 	return 0;
 }
 
-/* Map pci device */
-int
-pci_map_device(struct rte_pci_device *dev)
-{
-	return pci_uio_map_resource(dev);
-}
-
 /*
  * Scan the content of the PCI bus, and add the devices in the devices
  * list. Call pci_scan_one() for each pci entry found.
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 6eb6257..00547d9 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -98,6 +98,63 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 	return NULL;
 }
 
+/* Map pci device */
+static int
+pci_map_device(struct rte_pci_device *dev)
+{
+	int ret = -1;
+
+	/* try mapping the NIC resources using VFIO if it exists */
+	switch (dev->kdrv) {
+	case RTE_KDRV_VFIO:
+#ifdef VFIO_PRESENT
+		if (pci_vfio_is_enabled())
+			ret = pci_vfio_map_resource(dev);
+#endif
+		break;
+	case RTE_KDRV_IGB_UIO:
+	case RTE_KDRV_UIO_GENERIC:
+	case RTE_KDRV_NIC_UIO:
+		/* map resources for devices that use uio */
+		ret = pci_uio_map_resource(dev);
+		break;
+	default:
+		RTE_LOG(DEBUG, EAL, "  Not managed by a supported kernel driver,"
+			" skipped\n");
+		ret = 1;
+		break;
+	}
+
+	return ret;
+}
+
+#ifdef RTE_LIBRTE_EAL_HOTPLUG
+/* Unmap pci device */
+static void
+pci_unmap_device(struct rte_pci_device *dev)
+{
+	if (dev == NULL)
+		return;
+
+	/* try unmapping the NIC resources using VFIO if it exists */
+	switch (dev->kdrv) {
+	case RTE_KDRV_VFIO:
+		RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");
+		break;
+	case RTE_KDRV_IGB_UIO:
+	case RTE_KDRV_UIO_GENERIC:
+	case RTE_KDRV_NIC_UIO:
+		/* unmap resources for devices that use uio */
+		pci_uio_unmap_resource(dev);
+		break;
+	default:
+		RTE_LOG(DEBUG, EAL, "  Not managed by a supported kernel driver,"
+			" skipped\n");
+		break;
+	}
+}
+#endif /* RTE_LIBRTE_EAL_HOTPLUG */
+
 /*
  * If vendor/device ID match, call the devinit() function of the
  * driver.
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index fe2c596..badb55c 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -171,14 +171,14 @@ int pci_unbind_kernel_driver(struct rte_pci_device *dev);
  * @return
  *   0 on success, negative on error
  */
-int pci_map_device(struct rte_pci_device *dev);
+int pci_uio_map_resource(struct rte_pci_device *dev);
 
 /**
  * Unmap this device
  *
  * This function is private to EAL.
  */
-void pci_unmap_device(struct rte_pci_device *dev);
+void pci_uio_unmap_resource(struct rte_pci_device *dev);
 
 /**
  * Init tail queues for non-EAL library structures. This is to allow
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 0a2ef09..bd1ef4e 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -148,6 +148,7 @@ enum rte_kernel_driver {
 	RTE_KDRV_IGB_UIO,
 	RTE_KDRV_VFIO,
 	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
 };
 
 /**
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 91e958e..5c30469 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -563,61 +563,6 @@ pci_config_space_set(struct rte_pci_device *dev)
 }
 #endif
 
-/* Map pci device */
-int
-pci_map_device(struct rte_pci_device *dev)
-{
-	int ret = -1;
-
-	/* try mapping the NIC resources using VFIO if it exists */
-	switch (dev->kdrv) {
-	case RTE_KDRV_VFIO:
-#ifdef VFIO_PRESENT
-		if (pci_vfio_is_enabled())
-			ret = pci_vfio_map_resource(dev);
-#endif
-		break;
-	case RTE_KDRV_IGB_UIO:
-	case RTE_KDRV_UIO_GENERIC:
-		/* map resources for devices that use uio */
-		ret = pci_uio_map_resource(dev);
-		break;
-	default:
-		RTE_LOG(DEBUG, EAL, "  Not managed by a supported kernel driver,"
-			" skipped\n");
-		ret = 1;
-		break;
-	}
-
-	return ret;
-}
-
-#ifdef RTE_LIBRTE_EAL_HOTPLUG
-/* Unmap pci device */
-void
-pci_unmap_device(struct rte_pci_device *dev)
-{
-	if (dev == NULL)
-		return;
-
-	/* try unmapping the NIC resources using VFIO if it exists */
-	switch (dev->kdrv) {
-	case RTE_KDRV_VFIO:
-		RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");
-		break;
-	case RTE_KDRV_IGB_UIO:
-	case RTE_KDRV_UIO_GENERIC:
-		/* unmap resources for devices that use uio */
-		pci_uio_unmap_resource(dev);
-		break;
-	default:
-		RTE_LOG(DEBUG, EAL, "  Not managed by a supported kernel driver,"
-			" skipped\n");
-		break;
-	}
-}
-#endif /* RTE_LIBRTE_EAL_HOTPLUG */
-
 /* Init the PCI EAL subsystem */
 int
 rte_eal_pci_init(void)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 02cd07f..1822258 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -515,6 +515,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 		switch (rte_eth_devices[port_id].pci_dev->kdrv) {
 		case RTE_KDRV_IGB_UIO:
 		case RTE_KDRV_UIO_GENERIC:
+		case RTE_KDRV_NIC_UIO:
 			break;
 		case RTE_KDRV_VFIO:
 		default:
-- 
2.1.4

  parent reply	other threads:[~2015-06-29  2:57 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19  6:21 [PATCH 0/8] Add Port Hotplug support to BSD Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 1/8] eal: Add pci_uio_alloc_uio_resource() Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 2/8] eal: Add pci_uio_map_uio_resource_by_index() Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 3/8] eal: Consolidate pci_map and mapped_pci_resource of linuxapp and bsdapp Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 4/8] eal: Consolidate rte_eal_pci_probe/close_one_driver() " Tetsuya Mukawa
2015-06-26  8:21   ` [PATCH v2 0/8] Add Port Hotplug support to BSD Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 1/8] eal: Add pci_uio_alloc_uio_resource() Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 2/8] eal: Add pci_uio_map_uio_resource_by_index() Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 3/8] eal: Consolidate pci_map and mapped_pci_resource of linuxapp and bsdapp Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 4/8] eal: Consolidate rte_eal_pci_probe/close_one_driver() " Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 5/8] eal: Consolidate pci_map/unmap_device() " Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 6/8] eal: Consolidate pci_map/unmap_resource() " Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 7/8] eal: Consolidate pci uio functions " Tetsuya Mukawa
2015-06-26  8:21     ` [PATCH v2 8/8] eal: Enable Port Hotplug as default in Linux and BSD Tetsuya Mukawa
2015-06-29  2:56   ` [PATCH v3 0/8] Add Port Hotplug support to BSD Tetsuya Mukawa
2015-06-29  2:56     ` [PATCH v3 1/8] eal: Add pci_uio_alloc_uio_resource() Tetsuya Mukawa
2015-06-29 13:24       ` Iremonger, Bernard
2015-06-30  2:31         ` Tetsuya Mukawa
2015-06-29  2:56     ` [PATCH v3 2/8] eal: Add pci_uio_map_uio_resource_by_index() Tetsuya Mukawa
2015-06-29 13:36       ` Iremonger, Bernard
2015-06-30  2:34         ` Tetsuya Mukawa
2015-06-29  2:56     ` [PATCH v3 3/8] eal: Consolidate pci_map and mapped_pci_resource of linuxapp and bsdapp Tetsuya Mukawa
2015-06-29  2:56     ` [PATCH v3 4/8] eal: Consolidate rte_eal_pci_probe/close_one_driver() " Tetsuya Mukawa
2015-06-29 15:28       ` Bruce Richardson
2015-06-30  8:08         ` Tetsuya Mukawa
2015-06-30 12:50           ` Bruce Richardson
2015-06-29  2:56     ` Tetsuya Mukawa [this message]
2015-06-29  2:56     ` [PATCH v3 6/8] eal: Consolidate pci_map/unmap_resource() " Tetsuya Mukawa
2015-06-29  2:56     ` [PATCH v3 7/8] eal: Consolidate pci uio functions " Tetsuya Mukawa
2015-06-29 14:03       ` Iremonger, Bernard
2015-06-30  2:43         ` Tetsuya Mukawa
2015-06-30  8:28           ` Tetsuya Mukawa
2015-06-29  2:56     ` [PATCH v3 8/8] eal: Enable Port Hotplug as default in Linux and BSD Tetsuya Mukawa
2015-06-30  8:26       ` [PATCH v4] Add Port Hotplug support to BSD Tetsuya Mukawa
2015-06-30  8:26         ` [PATCH v4] eal: Enable Port Hotplug as default in Linux and BSD Tetsuya Mukawa
2015-06-30 15:08           ` Iremonger, Bernard
2015-06-30 15:40             ` Bruce Richardson
2015-07-01  6:37               ` Tetsuya Mukawa
2015-07-08 22:15           ` Thomas Monjalon
2015-06-29 15:30     ` [PATCH v3 0/8] Add Port Hotplug support to BSD Bruce Richardson
2015-06-30  8:08       ` Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 5/8] eal: Consolidate pci_map/unmap_device() of linuxapp and bsdapp Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 6/8] eal: Consolidate pci_map/unmap_resource() " Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 7/8] eal: Consolidate pci uio functions " Tetsuya Mukawa
2015-05-19  6:21 ` [PATCH 8/8] eal: Enable Port Hotplug as default in Linux and BSD Tetsuya Mukawa
2015-05-19 16:03 ` [PATCH 0/8] Add Port Hotplug support to BSD Stephen Hemminger

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=1435546610-4533-6-git-send-email-mukawa@igel.co.jp \
    --to=mukawa@igel.co.jp \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.