From patchwork Thu Jan 19 04:45:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 19759 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3C44AFB38; Thu, 19 Jan 2017 05:45:35 +0100 (CET) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id E68702B83 for ; Thu, 19 Jan 2017 05:45:24 +0100 (CET) Received: by mail-wm0-f42.google.com with SMTP id r144so58579401wme.1 for ; Wed, 18 Jan 2017 20:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wLIclXLTbwXrGoyR/O9KB0UnEHBK1naeodGa4i/L8t8=; b=JEwK8Y9FMNB50CRGMiyNMdqK0NSwb1zYrPUHCWTS3q3b/bqar7PvAM+3xJtgPFWl2l xMI7VlREV+EmGRiL0w0Ed3jmypAmrVE+6kZeJwtYYFOtV6ulPc1yWlNl8a1VgdHN8MWK Bt80SVWpSMqB7qpsy7cq1zAm77UTbFjldEqkOUi67eim+nN8ibZYtlIkL9ZxBW0Pbrw1 t2keCHvBOpO6kTxK3NjksRQ7HYl348DxFe8D5oWWYkFNtJqT5XEBzVchSaHkQOlP7Bs1 8JbvOB8CaOpBT/2RVwpApYoQuw4LUeFTxzttPo/tMhop81i9j1Fli6ux/HNfZFM/sXjr qsFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wLIclXLTbwXrGoyR/O9KB0UnEHBK1naeodGa4i/L8t8=; b=FV6gOwlFkBTkPHJn4u09lVEe1Syy/TYQYHu7jHF586lVOa2rYPBWBUmVi/Z37tPFFk C8FVVadPR1a9bIMMmyQXcOnc58Pwy9hy6TdXjkskW3QWUN34GO/8WOmPURuHpJo4Mwln g1+tQci7SKYP5csML0LHtHdPJkOMGix0vIhuFNDjMkzRZjSWXsEYvKFv05X3oKY6TcF9 xDmyHJKWVM3DBTpMKVky9hH3vkN5m3+fYBI/YS+2b9Lpdohc7dC79RbNZLpcFWSEXVPD ez6Dwc9hEA3KYvFe+lAWkQgD3SBsxx1J0Wlv/qTG/4aqTH3NkMtl4wnWm7xF9lyY7lFa Vvig== X-Gm-Message-State: AIkVDXIYNbdsF0i0WbsAeMhM5/GSFS/1aTrKtFwTBkTx/irJU6yNVpkDOa+nX2zYMDZ2+iWK X-Received: by 10.223.152.210 with SMTP id w76mr6297987wrb.72.1484801124618; Wed, 18 Jan 2017 20:45:24 -0800 (PST) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id t194sm2568586wmd.1.2017.01.18.20.45.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 20:45:24 -0800 (PST) From: Thomas Monjalon To: Shreyansh Jain Cc: dev@dpdk.org Date: Thu, 19 Jan 2017 05:45:07 +0100 Message-Id: <1484801117-779-4-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1484801117-779-1-git-send-email-thomas.monjalon@6wind.com> References: <1484748329-5418-1-git-send-email-shreyansh.jain@nxp.com> <1484801117-779-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-dev] [PATCH v11 03/13] bus: add probing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Shreyansh Jain Bus implementations can implement a probe handler to match the devices scanned against the drivers registered. Signed-off-by: Shreyansh Jain Reviewed-by: Ferruh Yigit Signed-off-by: Thomas Monjalon --- lib/librte_eal/bsdapp/eal/eal.c | 4 ++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 20 ++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 23 +++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 4 ++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 6 files changed, 53 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index be5d295..534aeea 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -612,6 +612,10 @@ rte_eal_init(int argc, char **argv) rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER); rte_eal_mp_wait_lcore(); + /* Probe all the buses and devices/drivers on them */ + if (rte_bus_probe()) + rte_panic("Cannot probe devices\n"); + /* Probe & Initialize PCI devices */ if (rte_eal_pci_probe()) rte_panic("Cannot probe PCI\n"); diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 931afeb..2cf1ac8 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -179,6 +179,7 @@ DPDK_17.02 { global: rte_bus_dump; + rte_bus_probe; rte_bus_register; rte_bus_scan; rte_bus_unregister; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index ef10390..4638e78 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -49,6 +49,7 @@ rte_bus_register(struct rte_bus *bus) RTE_VERIFY(bus->name && strlen(bus->name)); /* A bus should mandatorily have the scan implemented */ RTE_VERIFY(bus->scan); + RTE_VERIFY(bus->probe); TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name); @@ -80,6 +81,25 @@ rte_bus_scan(void) return 0; } +/* Probe all devices of all buses */ +int +rte_bus_probe(void) +{ + int ret; + struct rte_bus *bus; + + 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 b01930a..7c36969 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -70,12 +70,25 @@ TAILQ_HEAD(rte_bus_list, rte_bus); typedef int (*rte_bus_scan_t)(void); /** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * + * This is called while iterating over each registered bus. + * + * @return + * 0 for successful probe + * !0 for any error while probing + */ +typedef int (*rte_bus_probe_t)(void); + +/** * A structure describing a generic bus. */ struct rte_bus { TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */ const char *name; /**< Name of the bus */ rte_bus_scan_t scan; /**< Scan for devices attached to bus */ + rte_bus_probe_t probe; /**< Probe devices on bus */ }; /** @@ -106,6 +119,16 @@ void rte_bus_unregister(struct rte_bus *bus); int rte_bus_scan(void); /** + * For each device on the buses, perform a driver 'match' and call the + * driver-specific 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 1d2a16a..bf6b818 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -884,6 +884,10 @@ rte_eal_init(int argc, char **argv) rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER); rte_eal_mp_wait_lcore(); + /* Probe all the buses and devices/drivers on them */ + if (rte_bus_probe()) + rte_panic("Cannot probe devices\n"); + /* Probe & Initialize PCI devices */ if (rte_eal_pci_probe()) rte_panic("Cannot probe PCI\n"); diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index c238381..3c68ff5 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -183,6 +183,7 @@ DPDK_17.02 { global: rte_bus_dump; + rte_bus_probe; rte_bus_register; rte_bus_scan; rte_bus_unregister;