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 E998E5A1F for ; Fri, 1 Jan 2016 22:06:52 +0100 (CET) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3pXJnS5CcjzrM; Fri, 1 Jan 2016 22:06:52 +0100 (CET) From: Jan Viktorin To: dev@dpdk.org Date: Fri, 1 Jan 2016 22:05:25 +0100 Message-Id: <1451682326-5834-7-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> Cc: Jan Viktorin Subject: [dpdk-dev] [RFC 6/7] eal/soc: make SoC infra testable on any platform 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, 01 Jan 2016 21:06:53 -0000 The hardcoded constant paths to sysfs and device-tree locations makes the SoC infra difficult to test. With this code, it is possible to override the default path by setting the appropriate environment variables. A test can provide a fake sysfs and device-tree hierarchy of devices. Signed-off-by: Jan Viktorin --- lib/librte_eal/common/include/rte_soc.h | 6 ++++-- lib/librte_eal/linuxapp/eal/eal_soc.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h index 7c279b1..d7d6827 100644 --- a/lib/librte_eal/common/include/rte_soc.h +++ b/lib/librte_eal/common/include/rte_soc.h @@ -56,9 +56,11 @@ extern struct soc_device_list soc_device_list; extern struct soc_driver_list soc_driver_list; /* Path to detect platform devices (in architecture-specific bus systems). */ -#define SYSFS_SOC_DEVICES "/sys/bus/platform/devices" +#define SYSFS_SOC_DEVICES __sysfs_soc_devices +extern const char *__sysfs_soc_devices; /* Flat Device Tree location in the system. */ -#define FDT_ROOT "/proc/device-tree" +#define FDT_ROOT __fdt_root +extern const char *__fdt_root; struct rte_soc_resource { uint64_t phys_addr; /**< Physical address, 0 if no resource. */ diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c b/lib/librte_eal/linuxapp/eal/eal_soc.c index be0e44d..aafb9c3 100644 --- a/lib/librte_eal/linuxapp/eal/eal_soc.c +++ b/lib/librte_eal/linuxapp/eal/eal_soc.c @@ -46,6 +46,9 @@ #include "eal_private.h" #include "eal_pci_init.h" +const char *__sysfs_soc_devices = "/sys/bus/platform/devices"; +const char *__fdt_root = "/proc/device-tree"; + int soc_map_device(struct rte_soc_device *dev) { @@ -378,12 +381,24 @@ error: int rte_eal_soc_init(void) { + char *tmp; + TAILQ_INIT(&soc_driver_list); TAILQ_INIT(&soc_device_list); if (internal_config.no_soc) return 0; + if ((tmp = getenv("SYSFS_SOC_DEVICES"))) + __sysfs_soc_devices = tmp; + else + __sysfs_soc_devices = "/sys/bus/platform/devices"; + + if ((tmp = getenv("FDT_ROOT"))) + __fdt_root = tmp; + else + __fdt_root = "/proc/device-tree"; + if (rte_eal_soc_scan() < 0) { RTE_LOG(ERR, EAL, "%s(): Failed to scan for SoC devices\n", __func__); -- 2.6.3