From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0049.outbound.protection.outlook.com [104.47.38.49]) by dpdk.org (Postfix) with ESMTP id 1122F3777 for ; Mon, 26 Dec 2016 13:50:38 +0100 (CET) Received: from BN3PR0301CA0040.namprd03.prod.outlook.com (10.160.180.178) by DM5PR03MB2476.namprd03.prod.outlook.com (10.168.233.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.11; Mon, 26 Dec 2016 12:50:37 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:137) by BN3PR0301CA0040.outlook.office365.com (2a01:111:e400:4000::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.11 via Frontend Transport; Mon, 26 Dec 2016 12:50:37 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.789.10 via Frontend Transport; Mon, 26 Dec 2016 12:50:37 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uBQCl90J011201; Mon, 26 Dec 2016 05:50:34 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Mon, 26 Dec 2016 18:20:33 +0530 Message-ID: <1482756644-13726-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482756644-13726-1-git-send-email-shreyansh.jain@nxp.com> References: <1481893853-31790-1-git-send-email-shreyansh.jain@nxp.com> <1482756644-13726-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131272302376465640; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(336005)(39840400002)(39860400002)(39380400002)(39850400002)(39450400003)(39400400002)(39410400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(69596002)(50986999)(76176999)(47776003)(106466001)(105606002)(2351001)(104016004)(77096006)(33646002)(2906002)(4326007)(92566002)(38730400001)(68736007)(305945005)(110136003)(8936002)(50466002)(5660300001)(8676002)(81156014)(81166006)(36756003)(626004)(8656002)(50226002)(5003940100001)(48376002)(85426001)(97736004)(356003)(86362001)(2950100002)(189998001)(6916009)(7059030)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2476; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:KhnVO5VOQSCZYTiLEL9mUzBnmGrNs5LosoYXXhxSwDfdsq71XKWrsbq9fhwIBKIB/hntrA3eXeK8veZPGQzKJ7jLTuPAEObDo9d5St4uz1jaaX43dVQ8hwRVO9DtSca6Nj9BQ1tvT0lK4qXApw35Bu7yQpjg/lV60KAIYDIWnevj0zMYwwntkod3WbyJ0Dlm47PPUXYlpSlCNlmFeTKprRrEyEebWYrY+USzLFK9GhLXrKZ3PauONlPL9A7IgS98lRJifUzK/1ONbFd68dq3UGKb/jQkOiC0M3sc9MAtEqu/hca0hWvKU6+EjpQMRvOVa12m7MICzKfk+vyH+NZ3OmiLw3N3/6WNkJRyawhjeXtm/IY5/B7KQ2lwkg/SbMkRYfYIcTRKq0/CAOf/p1/aNJnMeXadNgCUkflT+oby3UEdQwSPeeXuE0DSC5Bs5oAiig+DHLPK1v5rx+GA/VZXX07SwAIC5dDt7AORCIrqa5Iiud4aIQeBeSVlGCLz1n1kG9HYv+Gam8skV94TP5dzFLfUg81LJorFKQtrl0R/PyZ42UpjG7sZf1Dp4CNG/dJgKicekfBDvCERsJzeW3m6eiM7/rWKDgkSULJu3AyD1/ngmc8EgQ42z5xNGg91sNiWQel0C+0ztnno7Dm+Cs7Wq7cD1gj6O3ksLeFZHOUGcBkQ8yhvjUeey+FzqHc3sSYcb/Zr8c3YKFPeSKJrXZKy61wUxMCsAF6+wczLps6Tmr0= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 46f4cfca-01f3-49bc-d387-08d42d8dca73 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR03MB2476; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2476; 3:GB0UlcTG2EGwQ0BHl3dy4AQFyvS2IFYryjQFnCY9fZ5FR8DFRTkRkq3dpZpZAeyh2CIud2MV1xGbkfWQXKkmjEtmzSscK4b5WtvIVFeMldZvCUwB/qsirgEY2f9rQtF1vcnwblHhdue6I+VTNP+UEgvkuXgTkOgY+3UlJ1Agir+s+ldHtmQHMZtP9V8LT1dkfNM/Wqyh9ct15t4Bd+91zpX3pHwuTUOPGYfBwzS37+YcsmfltwxBwqVbh9DQQmBQwRI+9Eeq6FuMld2VUKqd4rTWUf2q7XmP+PPGPekW0H6hbTiirzcaNM70VWe7CRGM5g2bFk6R+3xqHnVwnd1pu3rE9nd017tE2IMT5pJTRd8= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2476; 25:3FdBa6VaIGqeQ/YEYRH/OYf8Rx1Oujp/aHvAN5LTFs3GgMEtvW9lLR0YqAYMjkR6QkK1FnD+syIV8wlzKm04MX+Tr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Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13024025)(13023025)(13015025)(13017025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123565025)(20161123563025); SRVR:DM5PR03MB2476; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2476; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2476; 4:WA0GAem227MEbz4maP0SwD8wMRsclHb/QvCCsepNiI3GUUCB+VHa597+qJoMC4BfRF38fp8/9i5LqQ2niBCCcIfNa9PHTWvYD+OqO8ZSGhfC2RoO4i+wV41JcwhcnrjZuL0hB+QRKCNsLRxcoBHDhZp16d2u2wR461iXbeZITe/j89sbYfmrHxjEcCUqyMGDUG0pvSGFM8M6L8ggs9bFLigXJtx88KfYKBH3R3g+FY+7D47dSO2JjuaqU/ODIcZWWI1gpzBrm1aAWQifj89sK9x2zTjjH0VYI601e/vzR8B2KiNkxJAByt6kPgSgzd5A8gL8GGlBgE/xA6As57YJ+ODpf3m2Q6u35yRvEK5TLtgYYsX8dNbrqIFUDkF11SV7sXjv8h2L4xe0lCECe1RJdKTLQ0XboI6KuoEsauIMyQOYTmsqpZCaROw7d/20weyKjCkBvaJ8RGxQ5ki+y7rWi+ERo1GWm/UvYgbJRI6afixzAE4EIHwOfaigoXvOaRbIw/V8fd6q2OtXaup+dYn2bFPJ3zKVZeZs2Ko0V86A4F6O69y91NiD2/iYCROLe+SpO6L9hl6/BbftqMsGilWflfGgBMyQIckx41sBGsqzc9+wUQNLz8Nf4ssI3PrugnhMELPrwTbxHlY4qh+IvNTWNh/bUdWmjb5qzWYBXoHaLTZtY8xvHpjee0bmowDlebfFa4fs2tVgUrewnUN/mGh2hCB3RpKACZuH6TUtonATSVF8Bm0WUzOLdlpzLTK21Lnz X-Forefront-PRVS: 016885DD9B X-Microsoft-Exchange-Diagnostics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rJTYSRBTdcj5Fca9zOP7iNmvXRzkZFDyEKRfJDt/TmxN0CbGo+CFe6SQMe0qLIBl+VKdPAPr3I5CgQRmudPV0ZOa797BGJpX/Cu0RGtx4N/HWusUtNEImLKOfud23bwdAaDbYqJOydBrJXE5hNZ2BVieuLXwImNqBxNom2+W4kj16hj+whftMWlXs5xiggfN; 24:qbPOH+Yuuqe3eemJly2R1Bx/71wVl+GT3Ht+05G1z/WhyOLzJKnY/G3jktmFiXn6bHjZs4u0TkLMrNaGMvM+lDkjoKrbPgp7Eb60W7Yw8DI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2476; 7:maRUJ3R93u+Zcri7/UtynWQytIJ9ePvN+HrfCbMeMmqfbxf0D5jLo2JnuEvttAM6VayJtUdg8s7DDG99tA8TTNsG62vlODfiH2jDGMsqsR7n2pEpQ5FqppqPRi5ScGQyXoGinmNkIfccoY5taLrkpo773aH9LGvE1B0v55mez6skuqd0Qs3d1imX/xvt0uHrIOUzFqeFIrmBE9FpvVFvr1WtOlUXIcDNijfpoM58hP2WIAiBUOS9N+s5RdMeKXLsgZMi2fu2H4+ieXofWKqxnG12MSd5j6K2/ma5f8uDk4cbhbvQR//BxAserfgGaZlXnLGwV1QD7lx2E/RrhzZIOfzE5ib2GajbrA5CBkpcI+4fP2dcVd7Y7CM+ncflYIzLvE30ti4Rr36qtvxEsi7agS2KGe8a0jWu9r3geDQ7Lu68ybxQy2qU/f4N+HN/cbncPhaKbmvkyTbt4WvoK1Tm7w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2016 12:50:37.4125 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2476 Subject: [dpdk-dev] [PATCH v4 01/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: Mon, 26 Dec 2016 12:50:39 -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 --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 16 ++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_bus.c | 190 ++++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 177 ++++++++++++++++++++++ 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 | 16 ++ 8 files changed, 404 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..51115f4 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -174,3 +174,19 @@ 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_bus_get; + rte_eal_bus_dump; + rte_eal_bus_register; + rte_eal_bus_insert_device; + 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..01730f8 --- /dev/null +++ b/lib/librte_eal/common/eal_common_bus.c @@ -0,0 +1,190 @@ +/*- + * 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_bus_get(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)) + 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..ad2873c --- /dev/null +++ b/lib/librte_eal/common/include/rte_bus.h @@ -0,0 +1,177 @@ +/*- + * 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; + +/** + * A structure describing a generic bus. + */ +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 bus + * 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 bus + * 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_bus_get(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 b17791f..8ac09e0 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 */ const 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..abfe93e 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -178,3 +178,19 @@ 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_bus_get; + rte_eal_bus_dump; + rte_eal_bus_register; + rte_eal_bus_insert_device; + rte_eal_bus_remove_device; + rte_eal_bus_remove_driver; + rte_eal_bus_unregister; + +} DPDK_16.11; -- 2.7.4