struct rte_devargs;
+enum rte_pt_driver {
+ RTE_PT_UNKNOWN = 0,
+ RTE_PT_IGB_UIO = 1,
+ RTE_PT_VFIO = 2,
+ RTE_PT_UIO_GENERIC = 3,
+};
+
/**
* A structure describing a PCI device.
*/
uint16_t max_vfs; /**< sriov enable if not zero */
int numa_node; /**< NUMA node connection */
struct rte_devargs *devargs; /**< Device user arguments */
+ enum rte_pt_driver pt_driver; /**< Driver of passthrough */
};
/** Any PCI device identifier (vendor, device, ...) */
return -1;
}
+static int
+pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
+{
+ int count;
+ char path[PATH_MAX];
+ char *name;
+
+ if (!filename || !dri_name)
+ return -1;
+
+ count = readlink(filename, path, PATH_MAX);
+ if (count >= PATH_MAX)
+ return -1;
+
+ /* For device does not have a driver */
+ if (count < 0)
+ return 1;
+
+ path[count] = '\0';
+
+ name = strrchr(path, '/');
+ if (name) {
+ strncpy(dri_name, name + 1, strlen(name + 1) + 1);
+ return 0;
+ }
+
+ return -1;
+}
+
void *
pci_find_max_end_va(void)
{
char filename[PATH_MAX];
unsigned long tmp;
struct rte_pci_device *dev;
+ char driver[PATH_MAX];
+ int ret;
dev = malloc(sizeof(*dev));
- if (dev == NULL) {
+ if (dev == NULL)
return -1;
- }
memset(dev, 0, sizeof(*dev));
dev->addr.domain = domain;
return -1;
}
+ /* parse driver */
+ snprintf(filename, sizeof(filename), "%s/driver", dirname);
+ ret = pci_get_kernel_driver_by_path(filename, driver);
+ if (!ret) {
+ if (!strcmp(driver, "vfio-pci"))
+ dev->pt_driver = RTE_PT_VFIO;
+ else if (!strcmp(driver, "igb_uio"))
+ dev->pt_driver = RTE_PT_IGB_UIO;
+ else if (!strcmp(driver, "uio_pci_generic"))
+ dev->pt_driver = RTE_PT_UIO_GENERIC;
+ else
+ dev->pt_driver = RTE_PT_UNKNOWN;
+ } else if (ret < 0) {
+ RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
+ free(dev);
+ return -1;
+ } else
+ dev->pt_driver = RTE_PT_UNKNOWN;
+
/* device is valid, add in list (sorted) */
if (TAILQ_EMPTY(&pci_device_list)) {
TAILQ_INSERT_TAIL(&pci_device_list, dev, next);