eal: add name field to generic device
authorJan Blunck <jblunck@infradead.org>
Tue, 11 Apr 2017 15:44:08 +0000 (17:44 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 18 Apr 2017 16:57:56 +0000 (18:57 +0200)
This adds a name field to the generic struct rte_device. The EAL is
checking for the name being populated when registering a device but
doesn't enforce global unique names as this is left to the bus
implementations.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_eal/bsdapp/eal/eal_pci.c
lib/librte_eal/common/eal_common_dev.c
lib/librte_eal/common/eal_common_vdev.c
lib/librte_eal/common/include/rte_dev.h
lib/librte_eal/common/include/rte_pci.h
lib/librte_eal/linuxapp/eal/eal_pci.c

index 1e9031c..6e289da 100644 (file)
@@ -282,6 +282,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
        /* FreeBSD has no NUMA support (yet) */
        dev->device.numa_node = 0;
 
+       rte_eal_pci_device_name(&dev->addr, dev->name, sizeof(dev->name));
+       dev->device.name = dev->name;
+
        /* FreeBSD has only one pass through driver */
        dev->kdrv = RTE_KDRV_NIC_UIO;
 
index 4bde430..12a2286 100644 (file)
@@ -68,6 +68,9 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 
 void rte_eal_device_insert(struct rte_device *dev)
 {
+       RTE_VERIFY(dev->name);
+       RTE_VERIFY(dev->name[0] != '\0');
+
        TAILQ_INSERT_TAIL(&dev_device_list, dev, next);
 }
 
index 22fe2ca..c922297 100644 (file)
@@ -180,6 +180,7 @@ rte_eal_vdev_init(const char *name, const char *args)
 
        dev->device.devargs = devargs;
        dev->device.numa_node = SOCKET_ID_ANY;
+       dev->device.name = devargs->virt.drv_name;
 
        ret = vdev_probe_all_drivers(dev);
        if (ret) {
@@ -271,6 +272,7 @@ vdev_scan(void)
 
                dev->device.devargs = devargs;
                dev->device.numa_node = SOCKET_ID_ANY;
+               dev->device.name = devargs->virt.drv_name;
 
                rte_eal_device_insert(&dev->device);
                TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
index 4251099..67c2b0c 100644 (file)
@@ -122,6 +122,7 @@ struct rte_driver;
  */
 struct rte_device {
        TAILQ_ENTRY(rte_device) next; /**< Next device */
+       const char *name;             /**< Device name */
        const struct rte_driver *driver;/**< Associated driver */
        int numa_node;                /**< NUMA node connection */
        struct rte_devargs *devargs;  /**< Device user arguments */
index 5980dd1..fedb197 100644 (file)
@@ -172,6 +172,7 @@ struct rte_pci_device {
        struct rte_pci_driver *driver;          /**< Associated driver */
        uint16_t max_vfs;                       /**< sriov enable if not zero */
        enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
+       char name[PCI_PRI_STR_SIZE+1];          /**< PCI location (ASCII) */
 };
 
 /**
index 7897e15..ab5f8c6 100644 (file)
@@ -324,6 +324,9 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
                dev->device.numa_node = tmp;
        }
 
+       rte_eal_pci_device_name(addr, dev->name, sizeof(dev->name));
+       dev->device.name = dev->name;
+
        /* parse resources */
        snprintf(filename, sizeof(filename), "%s/resource", dirname);
        if (pci_parse_sysfs_resource(filename, dev) < 0) {