X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Flinuxapp%2Feal%2Feal_pci.c;h=9538efee0e3e10095b8fb725fec0dcb2c2b591bf;hb=2ef79b212a79e87afd16fd75376c1e0d49ca2942;hp=e6216c5eee229a2957337ffe8005ed817d244a3e;hpb=61410438da8fd1da3b7e09475afc4f3a3a64aec8;p=dpdk.git diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index e6216c5eee..9538efee0e 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -64,6 +64,7 @@ #include #include #include +#include #include "rte_pci_dev_ids.h" #include "eal_filesystem.h" @@ -460,6 +461,47 @@ pci_uio_map_secondary(struct rte_pci_device *dev) return -1; } +static int pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned uio_num) +{ + FILE *f; + char filename[PATH_MAX]; + int ret; + unsigned major, minor; + dev_t dev; + + /* get the name of the sysfs file that contains the major and minor + * of the uio device and read its content */ + rte_snprintf(filename, sizeof(filename), "%s/dev", sysfs_uio_path); + + f = fopen(filename, "r"); + if (f == NULL) { + RTE_LOG(ERR, EAL, "%s(): cannot open sysfs to get major:minor\n", + __func__); + return -1; + } + + ret = fscanf(f, "%d:%d", &major, &minor); + if (ret != 2) { + RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs to get major:minor\n", + __func__); + fclose(f); + return -1; + } + fclose(f); + + /* create the char device "mknod /dev/uioX c major minor" */ + rte_snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num); + dev = makedev(major, minor); + ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev); + if (f == NULL) { + RTE_LOG(ERR, EAL, "%s(): mknod() failed %s\n", + __func__, strerror(errno)); + return -1; + } + + return ret; +} + /* * Return the uioX char device used for a pci device. On success, return * the UIO number and fill dstbuf string with the path of the device in @@ -529,7 +571,11 @@ static int pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf, if (e == NULL) return -1; - return 0; + /* create uio device if we've been asked to */ + if (internal_config.create_uio_dev && pci_mknod_uio_dev(dstbuf, uio_num) < 0) + RTE_LOG(WARNING, EAL, "Cannot create /dev/uio%u\n", uio_num); + + return uio_num; } /* map the PCI resource of a PCI device in virtual memory */ @@ -843,13 +889,13 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, } /* device is valid, add in list (sorted) */ - if (TAILQ_EMPTY(&device_list)) { - TAILQ_INSERT_TAIL(&device_list, dev, next); + if (TAILQ_EMPTY(&pci_device_list)) { + TAILQ_INSERT_TAIL(&pci_device_list, dev, next); } else { struct rte_pci_device *dev2 = NULL; - TAILQ_FOREACH(dev2, &device_list, next) { + TAILQ_FOREACH(dev2, &pci_device_list, next) { if (pci_addr_comparison(&dev->addr, &dev2->addr)) continue; else { @@ -857,7 +903,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, return 0; } } - TAILQ_INSERT_TAIL(&device_list, dev, next); + TAILQ_INSERT_TAIL(&pci_device_list, dev, next); } return 0; @@ -986,7 +1032,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d dev->id.device_id, dr->name); /* no initialization when blacklisted, return without error */ - if (dev->blacklisted) { + if (dev->devargs != NULL && + dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) { RTE_LOG(DEBUG, EAL, " Device is blacklisted, not initializing\n"); return 0; } @@ -1023,8 +1070,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d int rte_eal_pci_init(void) { - TAILQ_INIT(&driver_list); - TAILQ_INIT(&device_list); + TAILQ_INIT(&pci_driver_list); + TAILQ_INIT(&pci_device_list); uio_res_list = RTE_TAILQ_RESERVE_BY_IDX(RTE_TAILQ_PCI, uio_res_list); /* for debug purposes, PCI can be disabled */