vfio: fix device initialization
The patch fixes vfio initialization issue introduced by below patch. Root cause is that VFIO_PRESENT is inaccessible in eal common level. To fix it, remove pci_map/unmap_device from common code, then implement in linux and bsd code. Fixes: 35b3313e322b ("pci: merge mapping functions for linux and bsd") Reported-by: Michael Qiu <michael.qiu@intel.com> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
This commit is contained in:
parent
2269e7e815
commit
538e7b8876
@ -92,6 +92,45 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Map pci device */
|
||||
int
|
||||
pci_map_device(struct rte_pci_device *dev)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
/* try mapping the NIC resources */
|
||||
switch (dev->kdrv) {
|
||||
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;
|
||||
}
|
||||
|
||||
/* Unmap pci device */
|
||||
void
|
||||
pci_unmap_device(struct rte_pci_device *dev)
|
||||
{
|
||||
/* try unmapping the NIC resources */
|
||||
switch (dev->kdrv) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pci_uio_free_resource(struct rte_pci_device *dev,
|
||||
struct mapped_pci_resource *uio_res)
|
||||
|
@ -137,61 +137,6 @@ pci_unmap_resource(void *requested_addr, size_t size)
|
||||
requested_addr);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If vendor/device ID match, call the devinit() function of the
|
||||
* driver.
|
||||
|
@ -164,6 +164,24 @@ 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
|
||||
*
|
||||
|
@ -123,6 +123,56 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Unmap pci device */
|
||||
void
|
||||
pci_unmap_device(struct rte_pci_device *dev)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
pci_find_max_end_va(void)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user