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 1B3E658F1 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 3r1Y7P6Dmkz7HF; Fri, 6 May 2016 15:50:09 +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:47:56 +0200 Message-Id: <1462542490-15556-15-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 14/28] eal/soc: detect assigned kernel driver 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:10 -0000 We reuse the existing infrastructure (rte_eal_get_kernel_driver_by_path) here however another possible implementation is by parsing the uevent file. As there are no well-known driver for SoC infra, we does not detect any. This will be changed in the future by checking for VFIO and UIO drivers. Signed-off-by: Jan Viktorin --- lib/librte_eal/common/include/rte_soc.h | 2 ++ lib/librte_eal/linuxapp/eal/eal_soc.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h index 00fd0a6..206244a 100644 --- a/lib/librte_eal/common/include/rte_soc.h +++ b/lib/librte_eal/common/include/rte_soc.h @@ -53,6 +53,7 @@ extern "C" { #include #include +#include TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */ TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */ @@ -83,6 +84,7 @@ struct rte_soc_device { struct rte_soc_id *id; /**< SoC device ID list */ struct rte_soc_driver *driver; /**< Associated driver */ struct rte_devargs *devargs; /**< Device user arguments */ + enum rte_kernel_driver kdrv; /**< Kernel driver */ }; struct rte_soc_driver; diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c b/lib/librte_eal/linuxapp/eal/eal_soc.c index 742d80d..4f9070e 100644 --- a/lib/librte_eal/linuxapp/eal/eal_soc.c +++ b/lib/librte_eal/linuxapp/eal/eal_soc.c @@ -179,6 +179,30 @@ dev_content_free(struct rte_soc_device *dev) dev->id = NULL; } +static int +dev_setup_associated_driver(struct rte_soc_device *dev, const char *dirname) +{ + char filename[PATH_MAX]; + char driver[PATH_MAX]; + int ret; + + /* parse driver */ + snprintf(filename, sizeof(filename), "%s/driver", dirname); + ret = rte_eal_get_kernel_driver_by_path(filename, driver); + if (ret < 0) { + RTE_LOG(ERR, EAL, "Fail to get kernel driver for %s\n", dirname); + return 1; + } + + if (!ret) { + dev->kdrv = RTE_KDRV_UNKNOWN; + } else { + dev->kdrv = RTE_KDRV_NONE; + } + + return 0; +} + /** * Scan one SoC sysfs entry, and fill the devices list from it. * We require to have the uevent file with records: OF_FULLNAME and @@ -217,6 +241,9 @@ soc_scan_one(const char *dirname, const char *name) goto fail; free(uevent); /* not needed anymore */ + if ((ret = dev_setup_associated_driver(dev, dirname))) + goto fail; + /* device is valid, add in list (sorted) */ if (TAILQ_EMPTY(&soc_device_list)) { TAILQ_INSERT_TAIL(&soc_device_list, dev, next); @@ -231,6 +258,7 @@ soc_scan_one(const char *dirname, const char *name) if (ret < 0) { TAILQ_INSERT_BEFORE(dev2, dev, next); } else { /* already registered */ + dev2->kdrv = dev->kdrv; dev_content_free(dev2); dev2->addr.fdt_path = dev->addr.fdt_path; -- 2.8.0