[dpdk-dev,v8,02/14] eal_pci: pci memory map work with driver type
Commit Message
From: Michael Qiu <michael.qiu@intel.com>
With the driver type flag in struct rte_pci_dev, we do not need
to always map uio devices with vfio related function when
vfio enabled.
Signed-off-by: Michael Qiu <michael.qiu@intel.com>
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_eal/linuxapp/eal/eal_pci.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
Comments
> -----Original Message-----
> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
> Sent: Monday, February 16, 2015 4:14 AM
> To: dev@dpdk.org
> Cc: Qiu, Michael; Iremonger, Bernard; Tetsuya Mukawa
> Subject: [PATCH v8 02/14] eal_pci: pci memory map work with driver type
>
> From: Michael Qiu <michael.qiu@intel.com>
>
> With the driver type flag in struct rte_pci_dev, we do not need to always map uio devices with vfio
> related function when vfio enabled.
>
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
@@ -556,25 +556,29 @@ pci_config_space_set(struct rte_pci_device *dev)
static int
pci_map_device(struct rte_pci_device *dev)
{
- int ret, mapped = 0;
+ int ret = -1;
/* try mapping the NIC resources using VFIO if it exists */
+ switch (dev->pt_driver) {
+ case RTE_PT_VFIO:
#ifdef VFIO_PRESENT
- if (pci_vfio_is_enabled()) {
- ret = pci_vfio_map_resource(dev);
- if (ret == 0)
- mapped = 1;
- else if (ret < 0)
- return ret;
- }
+ if (pci_vfio_is_enabled())
+ ret = pci_vfio_map_resource(dev);
#endif
- /* map resources for devices that use igb_uio */
- if (!mapped) {
+ break;
+ case RTE_PT_IGB_UIO:
+ case RTE_PT_UIO_GENERIC:
+ /* map resources for devices that use uio */
ret = pci_uio_map_resource(dev);
- if (ret != 0)
- return ret;
+ break;
+ default:
+ RTE_LOG(DEBUG, EAL, " Not managed by known pt driver,"
+ " skipped\n");
+ ret = 1;
+ break;
}
- return 0;
+
+ return ret;
}
/*