From patchwork Mon Jan 16 15:38:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 19426 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 03AB4152A; Mon, 16 Jan 2017 16:35:21 +0100 (CET) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0041.outbound.protection.outlook.com [104.47.34.41]) by dpdk.org (Postfix) with ESMTP id 2CA43152A for ; Mon, 16 Jan 2017 16:35:15 +0100 (CET) Received: from BN6PR03CA0017.namprd03.prod.outlook.com (10.168.230.155) by CY4PR03MB2470.namprd03.prod.outlook.com (10.168.163.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Mon, 16 Jan 2017 15:35:14 +0000 Received: from BY2FFO11FD019.protection.gbl (2a01:111:f400:7c0c::128) by BN6PR03CA0017.outlook.office365.com (2603:10b6:404:23::27) 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; Mon, 16 Jan 2017 15:35:14 +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 BY2FFO11FD019.mail.protection.outlook.com (10.1.14.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Mon, 16 Jan 2017 15:35:13 +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 v0GFZ4mh019448; Mon, 16 Jan 2017 08:35:11 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Mon, 16 Jan 2017 21:08:20 +0530 Message-ID: <1484581107-2025-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484581107-2025-1-git-send-email-shreyansh.jain@nxp.com> References: <1484581107-2025-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131290545137417137; (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)(39380400002)(39840400002)(39850400002)(39410400002)(39860400002)(39400400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(50986999)(76176999)(50226002)(97736004)(8936002)(33646002)(5003940100001)(6916009)(2950100002)(36756003)(77096006)(5660300001)(68736007)(47776003)(6666003)(4326007)(27001)(38730400001)(2906002)(626004)(48376002)(50466002)(105606002)(110136003)(189998001)(2351001)(92566002)(104016004)(8656002)(106466001)(54906002)(305945005)(81166006)(81156014)(85426001)(86362001)(356003)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2470; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD019; 1:4SQXgvE/hhrLKsi2dKKt6j+wqmqIntDQJMcO7nnY6rnfxCsHMsTa1SztCpJ5BAPpiJ1hyp5OQ1SqAWpZYSLM0vl1RHFZk2xKnmhJ7tZscVb4O+Oc7FkWJtCSG+xbz1I1uQnUTK3PlfuNYbfZeAT5LP5J5ce7FVfHAye3bwYZSFmZNtyc5OQU1oEZ9V6H9CSKvHgd6bOigcp1A4DzUqjee+r8x7G4FW7ddlofd4SuiJU0PyeEsn0II3SOADmoOicNGfKw3VdjzLTrSNzvM0B9m0dOjTuI7I7MOT6MoEi2vfLCom2n2gHYAvxfdULBIzNdaZKtnL0GF2hqwmwSvIqPsXSsEYu9vFfRCf9W5jHiM6B2l6BSOO8amSfSeIeAi6fFM4pnTuuj3deVFOIIcLEeXoWg+CaSfeja9mxMCP+PQabqdiUu9tOEdW6fQ1UI1R1yMUfDHx/LOdHZuDxWrF/h8728oZLcIecAzyE0n9dzBDHfjZWPZWG+dgyvXTMd1bcdz+Rno6wCeWEOXblkyispVSXrGr2noj51jck7jGOw/HX4UGeN22G+jp1D1Qs2yF+d/d3k5rWzN7YFw2Qlszl7pfjLykLit102RQexzijFa1UteL+sXucOVZSEFdYN4nsa7lKXNeXRHXXDKF+T2tTy+ZMFRPxQhzSAHEBg1EJp1fgMte+YdyQXf2+LxwgWc8+0i/39I867oHEp0cpk7ofBhA== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 87313a97-5248-4dcc-0f7e-08d43e2543aa X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR03MB2470; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2470; 3:/uphdId580IUXKtehzM4ai2gw4LhtZHD8oI5Sli9bRsf4U9a7+FnJOZ2+oh2n8sB1ih5qQ8aqx+vzQk6+JkfJXtsqEs9o0Ag+/bTSVe/r2QtC43bC2UF4ylBDS66q7X8DuC3twxifOkOn7nORqNUrQBHrJ0mBFbFh5Q+I7bkqUJ2ljj3DmSwN9ZMU2WJ3qOkCoxwfT3BQ0y8POHJlU1atfSx3enYeMzx+JdFcI+QmqYwb8Z4A7VJQLOuyg8X5KBYeRaZKlrdxNUMZ3bQjf1unSG5Hnc5odlSLZMzqdVs2RV49hU4E49IQ8cz2BOxZ8PBDP2ZurKl+0qV/HNEVmX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Q1P+ubpzMneUPyQOXsxioxlibkH5a9cJu2nbLvfM6tNcJDo3VjpRzZ0eI2wSbyIKFDktJ5cR16xqFukr2yL8svaGuT5tUvjIv9ijSVdvqJNcFF17Bs1X7hCQlECbF3qeYRhMgQfWHY0rccziSyLsF+2nkmPrVGmNJsHb/KNXB5c7Nl6lMp1rgH 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:CY4PR03MB2470; BCL:0; PCL:0; RULEID:(400006); SRVR:CY4PR03MB2470; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2470; 4:wRyNLjasHHpyXanV2irpc28DvhSx9kA47S1jZMZ+FSISURdWOPXYRU5d1lEOHo/7sqhKaTm+6HDowNqGZjxRop3+szrABP8kTmHUgh0iHaoEC9NqgBVqigMrtNiF8Xj9garpzHpHEzz1iUk0K0gtqvwnu2iDHJk/0qQ9a4WqP2CH5NNFbDyYgsDeRJPZbIp/xikx6u5857iNn1aP+/HPZp6EBfH5SRD8i2OBiBCEEZ1BPjkapTvJTnXM0XpenQcUlNU1xSrn9Wl8/Qiqt0ZUw0dtB5XTPGXNJd161yl03v0UkS6WoX/KUeAg55i3yjZdcCxXposxgoapHky/VYQ9v69nUd/YUG0pitmfE7Cwy11kd+SK9jUNXZYfw8+qnawYsrURjmApDf7jutQt/ApmS41Zxm7lk5qHl2+gq9lGtOlRUBYz9Yw9zRpSOThf5KWpWyEXCpVqVDSgYPHUUbAfZz4T1UVCrYlEsleBRFqRpLpdzXSmRUWxvj5mrY4dOLM7MaGrUBgxJMyPD5m/JpGUwLR9zBNql0bJMVIRBKAfSkmIWzwKz0Oxq7QNbXjgTrhKiWf1hn9Bo7WasspF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PUP2KK7TDXj5JwCdDRBRLA6quGTeWTXIg9ANwhwVlIysUGw7BlKUTj3DDp/nh63yXZIOAmYCKdR86mV178mANXj5SSb38/b3; 24:clTArpzcH5XkEnhQ570kaYRvUx10bnBhtqUmFBn6RJE5uEh53h3HOB+7O5kqlidnXwTWkNa9ujX53Xww+rvF4ELW5ndmabEtj6hfdzN2oY8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2470; 7:dBbrXySUDMVUYc2/mLyt5m8Yg8NMASvD5nQjEjSzPsV1a6lcGiV8rC0EGgk7Cx0ucRbwSyjcc3ecuQoU8X8GsOZFI5+vJBPJ4dTNlsbE8ZAeO08w5g4fZJxvdHxtnORNAuHsGU4gnMJCDdLiw7OA6jPsmExzDbWIbmZgLap3IMNyfpnUPW3MXZavygT8LuWL/1RYOhbG/SpIbE2m2uPhcaD3yE9wi4IL3vvl5poVsktXe14faiiO5/rjXUXUUJrj+ZwLb4WPXFBwHRJ5pGww3wx96YmgQD/RGg27R7G9iTCy4UR/sDSHlMLz7/bmLcnMQOttLxe2KRjI//uJxE2Y1GNUUVKOtQuls1HsEPIDNRxSuqSaKpb0ck2ATGsYcqJbOPWnDZS2SBUzOE1D9h02M4tT2F1fGyaLLk3cdgoFOgICMJmbXt/6Q5dxVOnjWsLn/hbvQRSyoJllZ/gLYsnJ4w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2017 15:35:13.4141 (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: CY4PR03MB2470 Subject: [dpdk-dev] [PATCH v6 1/8] 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;