From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shreyansh Jain Subject: [PATCH v9 07/12] eal: integrate bus scan and probe with EAL Date: Wed, 18 Jan 2017 16:07:55 +0530 Message-ID: <1484735880-17178-8-git-send-email-shreyansh.jain@nxp.com> References: <1484660264-6531-1-git-send-email-shreyansh.jain@nxp.com> <1484735880-17178-1-git-send-email-shreyansh.jain@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , Shreyansh Jain To: Return-path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0050.outbound.protection.outlook.com [104.47.34.50]) by dpdk.org (Postfix) with ESMTP id 9D2ABF979 for ; Wed, 18 Jan 2017 11:35:30 +0100 (CET) In-Reply-To: <1484735880-17178-1-git-send-email-shreyansh.jain@nxp.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add functions for scanning all the buses and performing probe on all the buses on EAL initialization. Presently, no bus exists - in subseqent patches, PCI bus would be introduced. Signed-off-by: Shreyansh Jain Reviewed-by: Ferruh Yigit --- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_bus.c | 40 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 19 ++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 8 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 6 files changed, 78 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 2206277..f0abd82 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -577,6 +577,9 @@ rte_eal_init(int argc, char **argv) rte_config.master_lcore, thread_id, cpuset, ret == 0 ? "" : "..."); + if (rte_bus_scan()) + rte_panic("Cannot scan the buses for devices\n"); + RTE_LCORE_FOREACH_SLAVE(i) { /* @@ -613,6 +616,10 @@ rte_eal_init(int argc, char **argv) if (rte_eal_pci_probe()) rte_panic("Cannot probe PCI\n"); + /* Probe all the buses and devices/drivers on them */ + if (rte_bus_probe()) + rte_panic("Cannot probe devices\n"); + if (rte_eal_dev_init() < 0) rte_panic("Cannot init pmd devices\n"); diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index c015889..c43140c 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -182,6 +182,8 @@ DPDK_17.02 { rte_bus_dump; rte_bus_register; rte_bus_unregister; + rte_bus_probe; + rte_bus_scan; rte_pci_match; } DPDK_16.11; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 3f529e6..ead9a22 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -65,6 +65,46 @@ rte_bus_unregister(struct rte_bus *bus) RTE_LOG(INFO, EAL, "Unregistered [%s] bus.\n", bus->name); } +/* Scan all the buses for registering devices */ +int +rte_bus_scan(void) +{ + int ret; + struct rte_bus *bus = NULL; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + ret = bus->scan(); + if (ret) { + RTE_LOG(ERR, EAL, "Scan for (%s) bus failed.\n", + bus->name); + /* Error in scanning any bus stops the EAL init. */ + return ret; + } + } + + return 0; +} + +/* Call bus specific probe */ +int +rte_bus_probe(void) +{ + int ret; + struct rte_bus *bus; + + /* For each bus registered with EAL */ + TAILQ_FOREACH(bus, &rte_bus_list, next) { + ret = bus->probe(); + if (ret) { + RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n", + bus->name); + return ret; + } + } + + return 0; +} + /* Dump information of a single bus */ static int bus_dump_one(FILE *f, struct rte_bus *bus) diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 17583ad..4b4bb36 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -113,6 +113,25 @@ void rte_bus_register(struct rte_bus *bus); void rte_bus_unregister(struct rte_bus *bus); /** + * Scan all the buses attached to the framework. + * + * @return + * 0 in case of success in scanning all buses + * !0 in case of failure to scan + */ +int rte_bus_scan(void); + +/** + * For each device on the bus, perform a driver 'match' and call the + * bus's probe for device initialization. + * + * @return + * 0 for successful match/probe + * !0 otherwise + */ +int rte_bus_probe(void); + +/** * Dump information of all the buses registered with EAL. * * @param f diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 16dd5b9..f77ff5c 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -844,6 +845,9 @@ rte_eal_init(int argc, char **argv) if (rte_eal_intr_init() < 0) rte_panic("Cannot init interrupt-handling thread\n"); + if (rte_bus_scan()) + rte_panic("Cannot scan the buses for devices\n"); + RTE_LCORE_FOREACH_SLAVE(i) { /* @@ -884,6 +888,10 @@ rte_eal_init(int argc, char **argv) if (rte_eal_pci_probe()) rte_panic("Cannot probe PCI\n"); + /* Probe all the buses and devices/drivers on them */ + if (rte_bus_probe()) + rte_panic("Cannot probe devices\n"); + if (rte_eal_dev_init() < 0) rte_panic("Cannot init pmd devices\n"); diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 5ed2589..6f047c5 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -186,6 +186,8 @@ DPDK_17.02 { rte_bus_dump; rte_bus_register; rte_bus_unregister; + rte_bus_probe; + rte_bus_scan; rte_pci_match; } DPDK_16.11; -- 2.7.4