[dpdk-dev] [PATCH v1 14/28] eal/soc: detect assigned kernel driver
Jan Viktorin
viktorin at rehivetech.com
Fri May 6 15:47:56 CEST 2016
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 <viktorin at rehivetech.com>
---
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 <rte_debug.h>
#include <rte_eal.h>
+#include <rte_dev.h>
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
More information about the dev
mailing list