From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0073.outbound.protection.outlook.com [104.47.42.73]) by dpdk.org (Postfix) with ESMTP id 4ECA4558A for ; Fri, 16 Dec 2016 14:08:59 +0100 (CET) Received: from DM2PR03CA0002.namprd03.prod.outlook.com (10.141.96.12) by SN1PR0301MB1584.namprd03.prod.outlook.com (10.162.130.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8; Fri, 16 Dec 2016 13:08:57 +0000 Received: from BL2FFO11FD037.protection.gbl (2a01:111:f400:7c09::195) by DM2PR03CA0002.outlook.office365.com (2a01:111:e400:2428::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.789.14 via Frontend Transport; Fri, 16 Dec 2016 13:08:57 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.761.6 via Frontend Transport; Fri, 16 Dec 2016 13:08:56 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:800; Count:10 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uBGD8BtD028345; Fri, 16 Dec 2016 06:08:53 -0700 From: Shreyansh Jain To: , CC: , , , Shreyansh Jain Date: Fri, 16 Dec 2016 18:40:43 +0530 Message-ID: <1481893853-31790-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481893853-31790-1-git-send-email-shreyansh.jain@nxp.com> References: <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> <1481893853-31790-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131263673369896950; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7916002)(39450400003)(39860400002)(39400400002)(39850400002)(39380400002)(39410400002)(39840400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(626004)(356003)(5001770100001)(81156014)(81166006)(97736004)(305945005)(8676002)(92566002)(38730400001)(2906002)(104016004)(8666005)(5660300001)(189998001)(33646002)(48376002)(85426001)(77096006)(8936002)(106466001)(50986999)(105606002)(68736007)(47776003)(2950100002)(86362001)(50466002)(50226002)(4326007)(6666003)(36756003)(76176999)(5003940100001)(7059030)(21314002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1584; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD037; 1:ku6qlglXYFReY+quKWgmxdG+gRE5h32AMXrcmTOwqcOqU77dNu/psdAS+UV+gzUb8+KDcErlK/c3X9i7utRW2YlGMbHs+L6WBmw7RnJgvVyNay3l98a5GtG4LCrVTmaNydlVk1XOBqgTePLlSvZykGqfxNaxqAsEB9XBAcs0zZXlr/EYxQGiTkzQOhkS7v56apAjTYcYSLoENOguPdpDyzbr5HAmJqyNbuzpCcSkqcZBs3s4WXs7u59gBAHVBTW0IoeixlGI5wNw13S4s6UWvHMbs69EhyEoIJAagfPTAClQjKwk1szQQuhiim6yQ5ogb3qH1SPRrag/a++9/98OOOXK42RkAIdWWdOJGXtTJkJsr/05IkSO8QB4CnscJLiqd+oByuPnBtgh6I6f8BsTDuk5tUl7pps2f53pW6jfLg28viObuAZms6k3WsQA9qn9L51UpQpJoNIDnEpPdsZ3EAFLsLwksVWf2JK/GvlzT2kHYchO8YjCxW76C9tyBw87eSayGd9SJuIGQDNUag+BCy6SGOrAEIDyv8jntm2pPrt0/KbgILkhksE+WBvqrwPBkyKSrsLL+W0exkU6/LquX77nNAg1RxQrOtc2G3L6XE5vTU11FvhDHwoI+QH5mI2bacrljkVFyDg4siEKSPYY2dvk8V7Dhr0AVqW6u8xKPkpheDuvFpkbyiNn7W6QcalPe85e7i6yeEE34/UCYv7H4Q1WVQObsSQy3kjzHggUUGhCD4lfSCC1vlumkA/Y25Djm4OCnn1/hk66rwSygzWfng== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f116df16-d515-4bfe-c695-08d425b4b194 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:SN1PR0301MB1584; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 3:WsD8pq9pYvgZxK1//JZl6vDMCyO1wIFmedv7BZMBkUQv/ENF9Lot1+hS/2zkl4jn0gO1FeuKpb4nzgvIcojFgRjGtgXaKrhlDI0NBshQcyJKYVWm1iurmG91PxSyxPJRNd2g6H+mqopngaeZVfrMtM25NYOcz2URMGsWjVbWDrXEH4uYHoVvOJEgvFCcjmPr8RvRVTkcN6tAdBo8jklhMl2nbEYOS3jmNvIEJkrCvv6keEEAiUoapGj39DEXbWyGy99VivyM0ryWtZH+eyCyvdDzjCGjTCikQWa5n7NEaagCbEt+pL4EZk+TTN8MLy5qPl0wOyNoEEMFQdO9zLM1xxrAXVF9QtiRP51l1zhECp/LGBdo0RbE7I/A6wKNyP+C; 25:U6xMle5I3VgIyZFAzlFfBxBKFxh6jizP6v1RGc4IjpJFPCfYxZCv8e3eVvXc2bP1O/1BD4A6YjF6pq6em/UcCAJNVsZFZ79i64KmkjOhe5mxxut6RHI+ExxCjtHmWCE47dpuXm8rGSjl2Nx95k9a+OrArl5NSYw1vUh8ftiBcCJyMfJxeHEjYlZknnDu/s6LfmGy6UXJR1lKjBMvGTpbfDohPD8u3u+GUg4MzklA0AVhHv/jZALml3ffTMX9aLfYAQxhk8seH2V4QGxcXOhqzWAcB0xZAyBg526BFmbizdKVk5SBgQy9S8fRixnKF/eqAT9tvW6te2ylS5s5Vh1DJCdJoomKdFKtCc6UXv6S3ZsdSEpTt8g15EZyYyFm9w94Jcbm44vXkLop1YjA4DK6kMT1JLSyjyPPIYG/jJ1OQhM4NgljdFDICY5oKiIRLII/LgC6yAhc0cQJc7W3Crjirw== X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 31:S/jGfOY7bGQ4SAG5ebdisTBOIlBLlnGCTIpu5g95CWc7m+0RkMzb2Twb12jCctc1SH6kBGBuX9QXkGkDldNMyFGG3LkYYWtcDgJHVxDwDx7mDJXjcB2RF19a5IXhMVESyM8SujBAAr0lB17LBjVkpjrUc+QO/mXvWB3xE5j/nP1dy/W1HUnGC0XhdrD7Nypd08bVSnBg939zIXJJhG4uEuzhcC268I1deTw0k/BvoZnMIRLZNsux8f9s4qO8DV6WyQ7rGOvVBC3m2erFyHtnMg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13017025)(13015025)(13023025)(13018025)(5005006)(13024025)(8121501046)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123565025)(20161123556025)(20161123559025)(20161123563025); SRVR:SN1PR0301MB1584; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB1584; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 4:HgXMiKJ5p86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vNL8RYrMaw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 7:duooEwPVNmx+hvp6W4MzRcS0efsMmw8J8anabM13q3+s6cVNEiP+zAEUh0r8WEvvzmwj2IAMPZPgIsR9hfw/Yet3bcD370C70EQsz3f4AcrzDb1LOVf4lEGRrm/ngDVQ5zbUKxi1HWwfm5Ix6n/Zq5XncNPbeEfxWoaCSfUwsOxwqkdF4zM3Gx8JPekMXlwJUSAXO/eXRfpDL7k4rfK+J/ipAC0ifJTeXApvXWPgUau/0T6USQJny5uplAt97hQ5NAF1gGXw7ytpN8ujiJ4OSo5yt9IyIVSoZxHJwiwoZVVv5p6i/RraID1kzCyN08ErUfcfWb8v+Z6k5dv0Ydjd2Cu28+c3uQoKZ/p2wmUOsytDNx0fXIItrrxgQJUj41hil3DoHuQJ4HpS50tbj8ZP9Myv3O1fUl/qTmayyWaQjRypWchxixSVQ8+kkIfe9VzBwMwRtlGmVn64QGZO5BZ9OA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2016 13:08:56.8024 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB1584 Subject: [dpdk-dev] [PATCH v3 02/12] eal/bus: introduce bus abstraction 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: , X-List-Received-Date: Fri, 16 Dec 2016 13:09:00 -0000 This patch introduces the rte_bus abstraction for devices and drivers in EAL framework. The model is: - One or more buses are connected to a CPU (or core) - One or more devices are conneted to a Bus - Drivers are running instances which manage one or more devices - Bus is responsible for identifying devices (and interrupt propogation) - Driver is responsible for initializing the device This patch adds a 'rte_bus' class which rte_driver and rte_device refer. This way, each device (rte_xxx_device) would have reference to the bus it is based on. As well as, each driver (rte_xxx_driver) would have link to the bus and devices on it for servicing. __ rte_bus_list / +----------'---+ |rte_bus | | driver_list------> List of rte_bus specific | device_list---- devices | | `-> List of rte_bus associated | | drivers +--|------|----+ _________/ \_________ +--------/----+ +-\---------------+ |rte_device | |rte_driver | | rte_bus | | rte_bus | | rte_driver | | ... | | ... | +---------...-----+ | | ||| +---||--------+ ||| || ||| | \ \\\ | \_____________ \\\ | \ ||| +------|---------+ +----|----------+ ||| |rte_pci_device | |rte_xxx_device | ||| | .... | | .... | ||| +----------------+ +---------------+ / | \ / | \ _____________________/ / \ / ___/ \ +-------------'--+ +------------'---+ +--'------------+ |rte_pci_driver | |rte_vdev_driver | |rte_xxx_driver | | .... | | .... | | .... | +----------------+ +----------------+ +---------------+ This patch only enables the bus references on rte_driver and rte_driver. EAL wide global device and driver list continue to exist until an instance of bus is added in subsequent patches. This patch also introduces RTE_REGISTER_BUS macro on the lines of RTE_PMD_REGISTER_XXX. Key difference is that the constructor priority has been explicitly set to 101 so as to execute bus registration before PMD. Signed-off-by: Shreyansh Jain -- v2: - fix bsdapp compilation issue because of missing export symbols in map file --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 15 ++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_bus.c | 192 ++++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 174 +++++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 2 + lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 15 ++ 8 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/eal_common_bus.c create mode 100644 lib/librte_eal/common/include/rte_bus.h diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index a15b762..cce99f7 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_string_fns.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_hexdump.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_devargs.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_bus.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_dev.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_options.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_thread.c diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 2f81f7c..23fc1c1 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -174,3 +174,18 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_bus_list; + rte_eal_bus_add_device; + rte_eal_bus_add_driver; + rte_eal_get_bus; + rte_eal_bus_dump; + rte_eal_bus_register; + rte_eal_bus_remove_device; + rte_eal_bus_remove_driver; + rte_eal_bus_unregister; + +} DPDK_16.11; diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index a92c984..0c39414 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -38,7 +38,7 @@ INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h INC += rte_string_fns.h rte_version.h INC += rte_eal_memconfig.h rte_malloc_heap.h -INC += rte_hexdump.h rte_devargs.h rte_dev.h rte_vdev.h +INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h rte_vdev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c new file mode 100644 index 0000000..612f64e --- /dev/null +++ b/lib/librte_eal/common/eal_common_bus.c @@ -0,0 +1,192 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 NXP + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of NXP nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "eal_private.h" + +struct rte_bus_list rte_bus_list = + TAILQ_HEAD_INITIALIZER(rte_bus_list); + +/** @internal + * Add a device to a bus. + */ +void +rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev) +{ + RTE_VERIFY(bus); + RTE_VERIFY(dev); + + TAILQ_INSERT_TAIL(&bus->device_list, dev, next); + dev->bus = bus; +} + +/** @internal + * Remove a device from its bus. + */ +void +rte_eal_bus_remove_device(struct rte_device *dev) +{ + struct rte_bus *bus; + + RTE_VERIFY(dev); + RTE_VERIFY(dev->bus); + + bus = dev->bus; + TAILQ_REMOVE(&bus->device_list, dev, next); + dev->bus = NULL; +} + +/** @internal + * Associate a driver with a bus. + */ +void +rte_eal_bus_add_driver(struct rte_bus *bus, struct rte_driver *drv) +{ + RTE_VERIFY(bus); + RTE_VERIFY(drv); + + TAILQ_INSERT_TAIL(&bus->driver_list, drv, next); + drv->bus = bus; +} + +/** @internal + * Disassociate a driver from bus. + */ +void +rte_eal_bus_remove_driver(struct rte_driver *drv) +{ + struct rte_bus *bus; + + RTE_VERIFY(drv); + RTE_VERIFY(drv->bus); + + bus = drv->bus; + TAILQ_REMOVE(&bus->driver_list, drv, next); + drv->bus = NULL; +} + +/** + * Get the bus handle using its name + */ +struct rte_bus * +rte_eal_get_bus(const char *bus_name) +{ + struct rte_bus *bus; + + RTE_VERIFY(bus_name); + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + RTE_VERIFY(bus->name); + + if (!strcmp(bus_name, bus->name)) { + RTE_LOG(DEBUG, EAL, "Returning Bus object %p\n", bus); + return bus; + } + } + + /* Unable to find bus requested */ + return NULL; +} + +/* register a bus */ +void +rte_eal_bus_register(struct rte_bus *bus) +{ + RTE_VERIFY(bus); + RTE_VERIFY(bus->name && strlen(bus->name)); + + /* Initialize the driver and device list associated with the bus */ + TAILQ_INIT(&(bus->driver_list)); + TAILQ_INIT(&(bus->device_list)); + + TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); + RTE_LOG(INFO, EAL, "Registered [%s] bus.\n", bus->name); +} + +/* unregister a bus */ +void +rte_eal_bus_unregister(struct rte_bus *bus) +{ + /* All devices and drivers associated with the bus should have been + * 'device->uninit' and 'driver->remove()' already. + */ + RTE_VERIFY(TAILQ_EMPTY(&(bus->driver_list))); + RTE_VERIFY(TAILQ_EMPTY(&(bus->device_list))); + + /* TODO: For each device, call its rte_device->driver->remove() + * and rte_eal_bus_remove_driver() + */ + + TAILQ_REMOVE(&rte_bus_list, bus, next); + RTE_LOG(INFO, EAL, "Unregistered [%s] bus.\n", bus->name); +} + +/* dump one bus info */ +static int +bus_dump_one(FILE *f, struct rte_bus *bus) +{ + int ret; + + /* For now, dump only the bus name */ + ret = fprintf(f, " %s\n", bus->name); + + /* Error in case of inability in writing to stream */ + if (ret < 0) + return ret; + + return 0; +} + +void +rte_eal_bus_dump(FILE *f) +{ + int ret; + struct rte_bus *bus; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + ret = bus_dump_one(f, bus); + if (ret) { + RTE_LOG(ERR, EAL, "Unable to write to stream (%d)\n", + ret); + break; + } + } +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h new file mode 100644 index 0000000..f0297a9 --- /dev/null +++ b/lib/librte_eal/common/include/rte_bus.h @@ -0,0 +1,174 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 NXP + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of NXP nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_BUS_H_ +#define _RTE_BUS_H_ + +/** + * @file + * + * RTE PMD Bus Abstraction interfaces + * + * This file exposes APIs and Interfaces for Bus Abstraction over the devices + * drivers in EAL. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include +#include + +/** Double linked list of buses */ +TAILQ_HEAD(rte_bus_list, rte_bus); + +/* Global Bus list */ +extern struct rte_bus_list rte_bus_list; + +struct rte_bus { + TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */ + struct rte_driver_list driver_list; + /**< List of all drivers on bus */ + struct rte_device_list device_list; + /**< List of all devices on bus */ + const char *name; /**< Name of the bus */ +}; + +/** @internal + * Add a device to a bus. + * + * @param bus + * Bus on which device is to be added + * @param dev + * Device handle + * @return + * None + */ +void +rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev); + +/** @internal + * Remove a device from its bus. + * + * @param dev + * Device handle to remove + * @return + * None + */ +void +rte_eal_bus_remove_device(struct rte_device *dev); + +/** @internal + * Associate a driver with a bus. + * + * @param bus + * Bus on which driver is to be added + * @param dev + * Driver handle + * @return + * None + */ +void +rte_eal_bus_add_driver(struct rte_bus *bus, struct rte_driver *drv); + +/** @internal + * Disassociate a driver from its bus. + * + * @param dev + * Driver handle to remove + * @return + * None + */ +void +rte_eal_bus_remove_driver(struct rte_driver *drv); + +/** + * Register a Bus handler. + * + * @param driver + * A pointer to a rte_bus structure describing the bus + * to be registered. + */ +void rte_eal_bus_register(struct rte_bus *bus); + +/** + * Unregister a Bus handler. + * + * @param driver + * A pointer to a rte_bus structure describing the bus + * to be unregistered. + */ +void rte_eal_bus_unregister(struct rte_bus *bus); + +/** + * Obtain handle for bus given its name. + * + * @param bus_name + * Name of the bus handle to search + * @return + * Pointer to Bus object if name matches any registered bus object + * NULL, if no matching bus found + */ +struct rte_bus *rte_eal_get_bus(const char *bus_name); + +/** + * Dump information of all the buses registered with EAL. + * + * @param f + * A valid and open output stream handle + * + * @return + * 0 in case of success + * !0 in case there is error in opening the output stream + */ +void rte_eal_bus_dump(FILE *f); + +/** Helper for Bus registration. The constructor has higher priority than + * PMD constructors + */ +#define RTE_REGISTER_BUS(nm, bus) \ +static void __attribute__((constructor(101), used)) businitfn_ ##nm(void) \ +{\ + (bus).name = RTE_STR(nm);\ + rte_eal_bus_register(&bus); \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_BUS_H */ diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 8840380..4004f9a 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -122,6 +122,7 @@ struct rte_driver; */ struct rte_device { TAILQ_ENTRY(rte_device) next; /**< Next device */ + struct rte_bus *bus; /**< Device connected to this bus */ struct rte_driver *driver; /**< Associated driver */ int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ @@ -148,6 +149,7 @@ void rte_eal_device_remove(struct rte_device *dev); */ struct rte_driver { TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ + struct rte_bus *bus; /**< Bus serviced by this driver */ const char *name; /**< Driver name. */ const char *alias; /**< Driver alias. */ }; diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 4e206f0..aa874a5 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -87,6 +87,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_string_fns.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_hexdump.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_devargs.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_bus.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_dev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_options.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_thread.c diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 83721ba..c873a7f 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -178,3 +178,18 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_bus_list; + rte_eal_bus_add_device; + rte_eal_bus_add_driver; + rte_eal_get_bus; + rte_eal_bus_dump; + rte_eal_bus_register; + rte_eal_bus_remove_device; + rte_eal_bus_remove_driver; + rte_eal_bus_unregister; + +} DPDK_16.11; -- 2.7.4