DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Subject: [dpdk-dev] [PATCH v3 6/8] eal: pci: export pci_[un]map_device
Date: Thu, 14 Jan 2016 15:42:50 +0800	[thread overview]
Message-ID: <1452757372-686-7-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1452757372-686-1-git-send-email-yuanhan.liu@linux.intel.com>

Normally we could set RTE_PCI_DRV_NEED_MAPPING flag so that eal will
invoke pci_map_device internally for us. From that point view, there
is no need to export pci_map_device.

However, for virtio pmd driver, which is designed to work without
binding UIO (or something similar first), pci_map_device() will fail,
which ends up with virtio pmd driver being skipped. Therefore, we can
not set RTE_PCI_DRV_NEED_MAPPING blindly at virtio pmd driver.

Therefore, this patch exports pci_map_device, and let virtio pmd
call it when necessary.

Cc: David Marchand <david.marchand@6wind.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
v3: - export pci_unmap_device as well

    - Add few more comments about rte_eal_pci_map_device().
---
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  4 ++--
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 +++++++
 lib/librte_eal/common/eal_common_pci.c          |  4 ++--
 lib/librte_eal/common/eal_private.h             | 18 -----------------
 lib/librte_eal/common/include/rte_pci.h         | 27 +++++++++++++++++++++++++
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  4 ++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 +++++++
 7 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 6c21fbd..95c32c1 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -93,7 +93,7 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
 
 /* Map pci device */
 int
-pci_map_device(struct rte_pci_device *dev)
+rte_eal_pci_map_device(struct rte_pci_device *dev)
 {
 	int ret = -1;
 
@@ -115,7 +115,7 @@ pci_map_device(struct rte_pci_device *dev)
 
 /* Unmap pci device */
 void
-pci_unmap_device(struct rte_pci_device *dev)
+rte_eal_pci_unmap_device(struct rte_pci_device *dev)
 {
 	/* try unmapping the NIC resources */
 	switch (dev->kdrv) {
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 9d7adf1..1b28170 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -135,3 +135,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_eal_pci_map_device;
+	rte_eal_pci_unmap_device;
+} DPDK_2.2;
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index dcfe947..96d5113 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -188,7 +188,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 			pci_config_space_set(dev);
 #endif
 			/* map resources for devices that use igb_uio */
-			ret = pci_map_device(dev);
+			ret = rte_eal_pci_map_device(dev);
 			if (ret != 0)
 				return ret;
 		} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
@@ -254,7 +254,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
 
 		if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
 			/* unmap resources for devices that use igb_uio */
-			pci_unmap_device(dev);
+			rte_eal_pci_unmap_device(dev);
 
 		return 0;
 	}
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 072e672..2342fa1 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -165,24 +165,6 @@ struct rte_pci_device;
 int pci_unbind_kernel_driver(struct rte_pci_device *dev);
 
 /**
- * Map this device
- *
- * This function is private to EAL.
- *
- * @return
- *   0 on success, negative on error and positive if no driver
- *   is found for the device.
- */
-int pci_map_device(struct rte_pci_device *dev);
-
-/**
- * Unmap this device
- *
- * This function is private to EAL.
- */
-void pci_unmap_device(struct rte_pci_device *dev);
-
-/**
  * Map the PCI resource of a PCI device in virtual memory
  *
  * This function is private to EAL.
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 334c12e..2224109 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -485,6 +485,33 @@ int rte_eal_pci_read_config(const struct rte_pci_device *device,
  */
 int rte_eal_pci_write_config(const struct rte_pci_device *device,
 			     const void *buf, size_t len, off_t offset);
+/**
+ * Map the PCI device resources in user space virtual memory address
+ *
+ * Note that driver should not call this function when flag
+ * RTE_PCI_DRV_NEED_MAPPING is set, as EAL will do that for
+ * you when it's on.
+ *
+ * @param dev
+ *   A pointer to a rte_pci_device structure describing the device
+ *   to use
+ *
+ * @return
+ *   0 on success, negative on error and positive if no driver
+ *   is found for the device.
+ */
+int rte_eal_pci_map_device(struct rte_pci_device *dev);
+
+/**
+ * Unmap this device
+ *
+ * @param dev
+ *   A pointer to a rte_pci_device structure describing the device
+ *   to use
+ */
+void rte_eal_pci_unmap_device(struct rte_pci_device *dev);
+
+
 
 #ifdef RTE_PCI_CONFIG
 /**
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index bc5b5be..db947da 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -124,7 +124,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
 
 /* Map pci device */
 int
-pci_map_device(struct rte_pci_device *dev)
+rte_eal_pci_map_device(struct rte_pci_device *dev)
 {
 	int ret = -1;
 
@@ -153,7 +153,7 @@ pci_map_device(struct rte_pci_device *dev)
 
 /* Unmap pci device */
 void
-pci_unmap_device(struct rte_pci_device *dev)
+rte_eal_pci_unmap_device(struct rte_pci_device *dev)
 {
 	/* try unmapping the NIC resources using VFIO if it exists */
 	switch (dev->kdrv) {
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index cbe175f..b9937c4 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -138,3 +138,10 @@ DPDK_2.2 {
 	rte_xen_dom0_supported;
 
 } DPDK_2.1;
+
+DPDK_2.3 {
+	global:
+
+	rte_eal_pci_map_device;
+	rte_eal_pci_unmap_device;
+} DPDK_2.2;
-- 
1.9.0

  parent reply	other threads:[~2016-01-14  7:41 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  3:54 [dpdk-dev] [PATCH 0/6 for 2.3] initial virtio 1.0 enabling Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 1/6] virtio: don't set vring address again at queue startup Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 2/6] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2015-12-29 11:31   ` Tan, Jianfeng
2015-12-30  3:45     ` Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 3/6] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 4/6] viritio: switch to 64 bit features Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 5/6] virtio: set RTE_PCI_DRV_NEED_MAPPING flag Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 6/6] virtio: add virtio v1.0 support Yuanhan Liu
2015-12-29 11:39   ` Tan, Jianfeng
2015-12-30  3:40     ` Yuanhan Liu
2015-12-10  3:58 ` [dpdk-dev] [PATCH 0/6 for 2.3] initial virtio 1.0 enabling Yuanhan Liu
2015-12-29 11:19 ` Tan, Jianfeng
2015-12-30  3:53   ` Yuanhan Liu
2016-01-04  3:55   ` Xu, Qian Q
2016-01-04  4:16     ` Yuanhan Liu
2016-01-12  6:58 ` [dpdk-dev] [PATCH v2 0/7] virtio 1.0 enabling for virtio pmd driver Yuanhan Liu
2016-01-12  6:58   ` [dpdk-dev] [PATCH v2 1/7] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-12  6:58   ` [dpdk-dev] [PATCH v2 2/7] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 3/7] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 4/7] viritio: switch to 64 bit features Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 5/7] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 6/7] eal: pci: export pci_map_device Yuanhan Liu
2016-01-12  8:31     ` David Marchand
2016-01-12  8:40       ` Yuanhan Liu
2016-01-12  9:05         ` Yuanhan Liu
2016-01-13 14:44           ` Santosh Shukla
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 7/7] virtio: add 1.0 support Yuanhan Liu
2016-01-13  3:31     ` Tetsuya Mukawa
2016-01-13  9:38       ` Yuanhan Liu
2016-01-14  7:47     ` Xie, Huawei
2016-01-14  7:50       ` Yuanhan Liu
2016-01-14  7:51         ` Xie, Huawei
2016-01-14  7:58           ` Yuanhan Liu
2016-01-14  8:08             ` Xie, Huawei
2016-01-14  8:22               ` Yuanhan Liu
2016-01-14  8:28                 ` Xie, Huawei
2016-01-14  7:50     ` Xie, Huawei
2016-01-14  8:38       ` Yuanhan Liu
2016-01-12  7:07   ` [dpdk-dev] [PATCH v2 0/7] virtio 1.0 enabling for virtio pmd driver Yuanhan Liu
2016-01-14  4:27   ` Tetsuya Mukawa
2016-01-14  5:59     ` Yuanhan Liu
2016-01-14  6:09     ` Tan, Jianfeng
2016-01-14  6:41       ` Tetsuya Mukawa
2016-01-18  9:04         ` Tetsuya Mukawa
2016-01-14  6:45       ` Yuanhan Liu
2016-01-14  7:42   ` [dpdk-dev] [PATCH v3 0/8] " Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 1/8] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 2/8] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 3/8] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 4/8] viritio: switch to 64 bit features Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 5/8] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-14  7:42     ` Yuanhan Liu [this message]
2016-01-14  7:45       ` [dpdk-dev] [PATCH v3 6/8] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 7/8] virtio: add 1.0 support Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-01-16 10:08       ` Santosh Shukla
2016-01-17 14:07         ` Santosh Shukla
2016-01-15  4:36   ` [dpdk-dev] [PATCH v4 0/8] virtio 1.0 enabling for virtio pmd driver Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 1/8] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 2/8] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-18 17:21       ` Xie, Huawei
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 3/8] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 4/8] viritio: switch to 64 bit features Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 5/8] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 6/8] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 7/8] virtio: add 1.0 support Yuanhan Liu
2016-01-18 16:38       ` Xie, Huawei
2016-01-18 16:50       ` Xie, Huawei
2016-01-19  5:55         ` Yuanhan Liu
2016-01-19  7:44           ` Xie, Huawei
2016-01-19  7:54             ` Yuanhan Liu
2016-01-19  8:02             ` Xie, Huawei
2016-01-18 17:07       ` Xie, Huawei
2016-01-19  1:36         ` Yuanhan Liu
2016-01-19  1:51           ` Xie, Huawei
2016-01-19  2:46             ` Yuanhan Liu
2016-01-19  2:48               ` Xie, Huawei
2016-01-19  5:54                 ` Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-01-15  8:57       ` Xu, Qian Q
2016-01-18  8:04     ` [dpdk-dev] [PATCH v4 0/8] virtio 1.0 enabling for virtio pmd driver Tetsuya Mukawa
2016-01-19  8:11     ` [dpdk-dev] [PATCH v5 0/9] " Yuanhan Liu
2016-01-19  8:11       ` [dpdk-dev] [PATCH v5 1/9] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-19  8:11       ` [dpdk-dev] [PATCH v5 2/9] virtio: define offset as size_t type Yuanhan Liu
2016-01-19  8:11       ` [dpdk-dev] [PATCH v5 3/9] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 4/9] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 5/9] viritio: switch to 64 bit features Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 6/9] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 7/9] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-19  8:17         ` David Marchand
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 8/9] virtio: add 1.0 support Yuanhan Liu
2016-01-21 11:37         ` Thomas Monjalon
2016-01-27  3:49           ` Yuanhan Liu
2016-01-21 11:49         ` Thomas Monjalon
2016-01-27  3:46           ` Yuanhan Liu
2016-01-27  8:11             ` Thomas Monjalon
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 9/9] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-01-19  8:55       ` [dpdk-dev] [PATCH v5 0/9] virtio 1.0 enabling for virtio pmd driver Xie, Huawei
2016-01-28  7:54       ` [dpdk-dev] [PATCH v6 " Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 1/9] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 2/9] virtio: define offset as size_t type Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 3/9] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 4/9] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 5/9] viritio: switch to 64 bit features Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 6/9] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 7/9] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 8/9] virtio: add 1.0 support Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 9/9] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-02-02 10:46         ` [dpdk-dev] [PATCH v6 0/9] virtio 1.0 enabling for virtio pmd driver Thomas Monjalon
2016-02-02 13:00           ` Yuanhan Liu
2016-02-02 13:48         ` [dpdk-dev] [PATCH v7 " Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 1/9] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 2/9] virtio: define offset as size_t type Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 3/9] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 4/9] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 5/9] viritio: switch to 64 bit features Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 6/9] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 7/9] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 8/9] virtio: add 1.0 support Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 9/9] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-02-03 15:09           ` [dpdk-dev] [PATCH v7 0/9] virtio 1.0 enabling for virtio pmd driver Thomas Monjalon

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=1452757372-686-7-git-send-email-yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=mst@redhat.com \
    /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).