pci: store numa_node per device
authorIntel <intel.com>
Mon, 3 Jun 2013 00:00:00 +0000 (00:00 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Sep 2013 12:09:22 +0000 (14:09 +0200)
Signed-off-by: Intel
lib/librte_eal/common/include/rte_pci.h
lib/librte_eal/linuxapp/eal/eal_pci.c

index 2235acb..1314d20 100644 (file)
@@ -143,6 +143,7 @@ struct rte_pci_device {
        struct rte_intr_handle intr_handle;     /**< Interrupt handle */
        const struct rte_pci_driver *driver;    /**< Associated driver */
        uint16_t max_vfs;                       /**< sriov enable if not zero */
+       int numa_node;                          /**< NUMA node connection */
        unsigned int blacklisted:1;             /**< Device is blacklisted */
 };
 
index de975ad..063a070 100644 (file)
@@ -774,6 +774,20 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
                dev->max_vfs = (uint16_t)tmp;
        }
 
+       /* get numa node */
+       rte_snprintf(filename, sizeof(filename), "%s/numa_node",
+                dirname);
+       if (access(filename, R_OK) != 0) {
+               /* if no NUMA support just set node to 0 */
+               dev->numa_node = -1;
+       } else {
+               if (eal_parse_sysfs_value(filename, &tmp) < 0) {
+                       free(dev);
+                       return -1;
+               }
+               dev->numa_node = tmp;
+       }
+
        /* parse resources */
        rte_snprintf(filename, sizeof(filename), "%s/resource", dirname);
        if (pci_parse_sysfs_resource(filename, dev) < 0) {
@@ -923,6 +937,12 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
                                id_table->subsystem_device_id != PCI_ANY_ID)
                        continue;
 
+               struct rte_pci_addr *loc = &dev->addr;
+
+               RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+                               loc->domain, loc->bus, loc->devid, loc->function,
+                               dev->numa_node);
+
                RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
                                dev->id.device_id, dr->name);