From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id AC24C5A0A for ; Fri, 6 May 2016 15:50:10 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3r1Y7Q33Jyz7JM; Fri, 6 May 2016 15:50:10 +0200 (CEST) From: Jan Viktorin To: dev@dpdk.org Cc: Jan Viktorin , David Marchand , Thomas Monjalon , Bruce Richardson , Declan Doherty , jianbo.liu@linaro.org, jerin.jacob@caviumnetworks.com, Keith Wiles , Stephen Hemminger Date: Fri, 6 May 2016 15:48:00 +0200 Message-Id: <1462542490-15556-19-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1462542490-15556-1-git-send-email-viktorin@rehivetech.com> References: <1462542490-15556-1-git-send-email-viktorin@rehivetech.com> In-Reply-To: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> Subject: [dpdk-dev] [PATCH v1 18/28] eal/soc: detect numa_node of the rte_soc_device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2016 13:50:11 -0000 No idea whether this is useful. Who creates the numa_node in the sysfs? This can be probably dropped later. Signed-off-by: Jan Viktorin --- lib/librte_eal/common/eal_common_soc.c | 8 ++++---- lib/librte_eal/common/include/rte_soc.h | 1 + lib/librte_eal/linuxapp/eal/eal_soc.c | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_soc.c b/lib/librte_eal/common/eal_common_soc.c index d0e5351..af4daa5 100644 --- a/lib/librte_eal/common/eal_common_soc.c +++ b/lib/librte_eal/common/eal_common_soc.c @@ -108,8 +108,8 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *dr, if (!soc_id_match(dr->id_table, dev->id)) return 1; - RTE_LOG(DEBUG, EAL, "SoC device %s\n", - dev->addr.name); + RTE_LOG(DEBUG, EAL, "SoC device %s on NUMA socket %d\n", + dev->addr.name, dev->numa_node); RTE_LOG(DEBUG, EAL, " probe driver %s\n", dr->name); if (dev->devargs != NULL @@ -162,8 +162,8 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *dr, if (!soc_id_match(dr->id_table, dev->id)) return 1; - RTE_LOG(DEBUG, EAL, "SoC device %s\n", - dev->addr.name); + RTE_LOG(DEBUG, EAL, "SoC device %s on NUMA socket %i\n", + dev->addr.name, dev->numa_node); RTE_LOG(DEBUG, EAL, " remove driver: %s\n", dr->name); diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h index 830fcdc..49cfeb7 100644 --- a/lib/librte_eal/common/include/rte_soc.h +++ b/lib/librte_eal/common/include/rte_soc.h @@ -99,6 +99,7 @@ struct rte_soc_device { struct rte_soc_resource mem_resource[SOC_MAX_RESOURCE]; struct rte_intr_handle intr_handle; /**< Interrupt handle */ struct rte_soc_driver *driver; /**< Associated driver */ + int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ enum rte_kernel_driver kdrv; /**< Kernel driver */ }; diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c b/lib/librte_eal/linuxapp/eal/eal_soc.c index c0e123a..6ef7d2f 100644 --- a/lib/librte_eal/linuxapp/eal/eal_soc.c +++ b/lib/librte_eal/linuxapp/eal/eal_soc.c @@ -45,6 +45,7 @@ #include #include "eal_internal_cfg.h" +#include "eal_filesystem.h" #include "eal_private.h" int @@ -294,6 +295,28 @@ dev_setup_associated_driver(struct rte_soc_device *dev, const char *dirname) return 0; } +static int +dev_setup_numa_node(struct rte_soc_device *dev, const char *dirname) +{ + char filename[PATH_MAX]; + FILE *f; + /* if no NUMA support, set default to 0 */ + unsigned long tmp = 0; + int ret = 0; + + /* get numa node */ + snprintf(filename, sizeof(filename), "%s/numa_node", dirname); + if ((f = fopen(filename, "r")) != NULL) { + if (eal_parse_sysfs_valuef(f, &tmp) < 0) + ret = 1; + + fclose(f); + } + + dev->numa_node = tmp; + return ret; +} + /** * Scan one SoC sysfs entry, and fill the devices list from it. * We require to have the uevent file with records: OF_FULLNAME and @@ -335,6 +358,9 @@ soc_scan_one(const char *dirname, const char *name) if ((ret = dev_setup_associated_driver(dev, dirname))) goto fail; + if ((ret = dev_setup_numa_node(dev, dirname)) < 0) + goto fail; + /* device is valid, add in list (sorted) */ if (TAILQ_EMPTY(&soc_device_list)) { TAILQ_INSERT_TAIL(&soc_device_list, dev, next); -- 2.8.0