From patchwork Tue Jan 17 10:09:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 19557 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 3209F2BB9; Tue, 17 Jan 2017 11:06:34 +0100 (CET) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0048.outbound.protection.outlook.com [104.47.34.48]) by dpdk.org (Postfix) with ESMTP id 2E2232B99 for ; Tue, 17 Jan 2017 11:06:17 +0100 (CET) Received: from CY1PR03CA0015.namprd03.prod.outlook.com (10.174.128.25) by DM2PR0301MB0752.namprd03.prod.outlook.com (10.160.97.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Tue, 17 Jan 2017 10:06:15 +0000 Received: from BL2FFO11OLC009.protection.gbl (2a01:111:f400:7c09::170) by CY1PR03CA0015.outlook.office365.com (2603:10b6:600::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12 via Frontend Transport; Tue, 17 Jan 2017 10:06:15 +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 BL2FFO11OLC009.mail.protection.outlook.com (10.173.160.145) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Tue, 17 Jan 2017 10:06:14 +0000 Received: from tophie.ap.freescale.net ([10.232.14.39]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v0HA67Te024558; Tue, 17 Jan 2017 03:06:12 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Tue, 17 Jan 2017 15:39:26 +0530 Message-ID: <1484647774-28984-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484647774-28984-1-git-send-email-shreyansh.jain@nxp.com> References: <1484581107-2025-1-git-send-email-shreyansh.jain@nxp.com> <1484647774-28984-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131291211749298644; (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)(7916002)(336005)(39410400002)(39850400002)(39450400003)(39400400002)(39860400002)(39840400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(626004)(5003940100001)(47776003)(4326007)(5660300001)(36756003)(8936002)(2351001)(30001)(104016004)(106466001)(48376002)(50226002)(356003)(68736007)(86362001)(105606002)(33646002)(8676002)(189998001)(77096006)(2950100002)(2906002)(92566002)(85426001)(81156014)(6666003)(76176999)(6916009)(8656002)(50466002)(81166006)(305945005)(38730400001)(110136003)(50986999)(97736004)(54906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0752; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC009; 1:q/3Np4kE1VnWBuAbGzZfeRPVikmhHgSvje5yJNN7V4w+HKjATXf6jEWsMcIn6lK9C7IE/tEm4w4Xs1bPmIZq7Kr9CZHzufzLS9P2DHBiYla5q7UFWU/vvWRDrw5gKKMiZ3U0akD95CC5M2A5ubjHEyDLiyLTiQvE7nXz7b7ZQBONhiBUFyTbLa2/eXAAk0ysulCHA3QdDAaXtULM0EV7YBXpl823hJ/VvhTHGJ4taDNQcvAgfOtxIvX/2Kn2OYvMPaFHLqOKi5umq6JVj4bHKSO8q+Cl0+r7v8SjAZ0a03cfLNVBUfOXfUMqt4W/VLgcfsM8vStGcePtqDfeCA8FM7hz3wK7ex1JRJvtvtjcCDLEVkbawSQ8zEqTqceD/ycx3DUHROEw8eP3FKR7clEbyX4NagEbIutEgDd34yc7LTLd0MwtFf6FITO8VE9HGmQy8UoxOmRGV7+lbnZkv/AuL+xWD99TF1Gf3KsDcTQdl2pBI9yJlk+76zuTzpTjmdU+/A+YPgvSdP2aOp7+XyhvScHmV1xCYGtJCt0h94CX7/moIkEQddi459pL4c4HTJXNCVmWXLjuUI1uWheOeMY/12wu9nLQdcU6REvmws4P6JjqoPmD3TQN1fkjBAXIkvK9UP1/bPtO/mdhBQhqYwmZ67tXCBC/+8Soz1s6TTfVUpTbS8xKNUgvtWiFuh9HKB3bR83wyDJFRPuvej+PlDBCoA== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 07cbf690-bb4b-4dfb-30e8-08d43ec078e7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR0301MB0752; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0752; 3:kZ/6ySESM8wo0UUXKXI1fFZP4zgbK0SPN83NOr9Qd/20+iVOBfrShg5pjtUQ6DQMARCXFI/8t8jvSDzhj3jKp81+hdsyBgcvYvoxvbu9lTPiaNshJF88M+i6kz5H6Qe8Bqrr3KUSowtqVjInSyRy/WfAjmrb0Grt6IZoVItOCHFqoydWNqJSmmj1PHd5SyI4u58Kvc59I6UhT8/OC6PYr0IYlQElOz1NAGSkm1pMlZsXz/x5WhRX6a2Jsaum0lmCGNlK5fEsS8ZAlXuRK5f1pBqaS5MchJOsoRwBV4EIZmDHwknthPc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eREp0rKRcSo7CdEmq6QnyTHcczYT/zKSU8gbEnwxd/3hle0KUhWSV6FCG57leyBI95qHJSeFqaqvpXETRQoQT4pij3wv1rEsokKRFJ+fln2OlxRNYcg1VFZdfCDlDasNj8nXUwH2nfRQbxN/s8l2YEhS2xy8T2L6K+X2u+p7t+Rdc6zYbJrOZn3/j8Y92M= 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)(5005006)(8121501046)(13017025)(13023025)(13024025)(13015025)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123563025)(20161123556025)(20161123561025)(20161123559025); SRVR:DM2PR0301MB0752; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0752; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0752; 4:1qp6y3lTKLI9K9K4ZnK3Abn9cb/IfzOXRXvW9rgFHDyp/GmlmTRjFybL3f2zsynLoomK1bYtkralxohuHW3MPZScLRPmOpd581GrLULUwDTF1O57u8gc2ujetmDP0FAUq87wGbpdc1shlGnSmftUAvQPX2VDpUK/kEr+qOrqO3RZT/BH7v4cklvxESJBhKgNlDyMGQ5vQH1M6yTJjOG2T0dfHpW8Tf3kTvvSuT1NPlzbw4N8H4HC+9N2LFb74HnzwRygkrTegZY9LxqTw29thRG/MB4XGOrfUQhpQHksHytm40iQCB3hLA1/Xl2m1xYA0Gr84zlaH2owON+a8v3EeZlJrxjTCLzN7lC5Kt6AFJ02IphlSXiKABnOBAd5MemhVXC2cunhsdw/ATkM85mbeA4ld8xQ1qBmwq41v15FwQOsD46oA/5iXDUZK0kEi0yDWd3M4/VIfUqgBdhlSeLCE2UH8jT2RthrDubX1T5BgPYZtAR+7FelfcZtpD2E0bWKagn+T+jxONS9X8TAPo12h4M1Mdr8Y32cLxb6+DBJlOXlSuq+/xmJCQy2Jr1NiadCcr3iv0P8pKD6JC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KwEsFTqgXf2YVBEEFXVemhKG89VwKtkyyNXRIMQK+VKLtxZdTJFoU2SaRzs0zHvutOa19Ht2eUWuctaX4eOH/gPG+1svkqzn/bdKSwT; 24:MK92fovhp7Enb9FEIlBzSkNZC7fIE5OhwdlqFI8/T1rsHGJecGtL8HXcil5JwjoC4lTTslvYQkZeKY5L2uQdkViaG51V49NLoTe9lyBaJY4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0752; 7:k/C/YjVPIc+Leq3OUxMezCkEAdTQpJ7+p6yhhf7Kl/G54Ud34EJ2PtOMbmK/QdxnFaYDAU1H7zbQeRxQKRZh/Sh6p10chDO4Rjkp7TdE8MKvLMBLf2WW2pa2zzI3+kl0jwpAO+ormJH4y9k1zX9YXdOkq+dHPHQYbGKr56Y/5hTmCWeobThbf0xBZIMH/9/fRBqOO7NX7zLxhckFn/oMOjB2aNWXsipF38dPvAbybcPq1fOlbA9hODxsCheKv+qU/JccBmlSKGbSFIKUWjZqnk4L3X2L6aWrqL8H/9Q9cltqHiQeNBJOz6o3nMxVhcymop45wyztl85CD2Zj32o8Gg41Ux0uIwHduEHHNeZyic92Tg4W6FWypKpAAW/SclOdyTo4tyIavCzpQUnReKnEwlaze7jUjsXtNEN77uZy7fP0R5h1R81Sj30w+veVnbdCwMPg6bOPTCAKxEyz9aa/wg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2017 10:06:14.7428 (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: DM2PR0301MB0752 Subject: [dpdk-dev] [PATCH v7 1/9] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch introduces the rte_bus abstraction for EAL. 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' base class which would be extended for specific implementations. It also introduces Bus registration and deregistration functions. An example implementation would be like: .--------------->+-------------------+ | |rte_pci_bus | | | +----------------+| | | |rte_bus <------. | | | name || | | | | scan || | | | | match || | | | | probe || | | | | remove || | | | | ... || | | | +----------------+| | | | pci_driver_list | | | .-------------->pci_device_list | | | | | ... | | | | +-------------------+ | | | | | +-------------------+ | | |rte_pci_device | | '----bus | | | +----------------+| | | |rte_device || | | | bus --------------------------------' | | ... || | +----------------+| | ... | +-------------------+ Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 10 +++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_bus.c | 97 +++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 111 ++++++++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 1 + lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 10 +++ 8 files changed, 232 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..4dcf653 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -174,3 +174,13 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_bus_list; + rte_bus_dump; + rte_bus_register; + rte_bus_unregister; + +} DPDK_16.11; diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index 09a3d3a..240995c 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..c891392 --- /dev/null +++ b/lib/librte_eal/common/eal_common_bus.c @@ -0,0 +1,97 @@ +/*- + * 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); + +/* register a bus */ +void +rte_bus_register(struct rte_bus *bus) +{ + RTE_VERIFY(bus); + RTE_VERIFY(bus->name && strlen(bus->name)); + + TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); + RTE_LOG(INFO, EAL, "Registered [%s] bus.\n", bus->name); +} + +/* unregister a bus */ +void +rte_bus_unregister(struct rte_bus *bus) +{ + 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_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..2250269 --- /dev/null +++ b/lib/librte_eal/common/include/rte_bus.h @@ -0,0 +1,111 @@ +/*- + * 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); + +/** + * 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 */ +}; + +/** + * Register a Bus handler. + * + * @param bus + * A pointer to a rte_bus structure describing the bus + * to be registered. + */ +void rte_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_bus_unregister(struct rte_bus *bus); + +/** + * 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_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_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..24c1c00 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 */ 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..b553b13 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -178,3 +178,13 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_bus_list; + rte_bus_dump; + rte_bus_register; + rte_bus_unregister; + +} DPDK_16.11;