From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0063.outbound.protection.outlook.com [104.47.40.63]) by dpdk.org (Postfix) with ESMTP id 288174A59 for ; Sun, 4 Dec 2016 11:09:06 +0100 (CET) Received: from BY2PR03CA059.namprd03.prod.outlook.com (10.141.249.32) by DM2PR0301MB0750.namprd03.prod.outlook.com (10.160.97.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8; Sun, 4 Dec 2016 10:09:05 +0000 Received: from BN1BFFO11FD041.protection.gbl (2a01:111:f400:7c10::1:195) by BY2PR03CA059.outlook.office365.com (2a01:111:e400:2c5d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9 via Frontend Transport; Sun, 4 Dec 2016 10:09:04 +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 BN1BFFO11FD041.mail.protection.outlook.com (10.58.144.104) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Sun, 4 Dec 2016 10:09:04 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:683; Count:10 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uB4A8pK6019825; Sun, 4 Dec 2016 03:09:01 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Sun, 4 Dec 2016 15:41:17 +0530 Message-ID: <1480846288-2517-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480846288-2517-1-git-send-email-shreyansh.jain@nxp.com> References: <1480846288-2517-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131253197448413752; (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)(2980300002)(1110001)(1109001)(336004)(339900001)(189002)(199003)(47776003)(6666003)(92566002)(305945005)(48376002)(106466001)(626004)(69596002)(189998001)(38730400001)(86362001)(105606002)(8936002)(33646002)(110136003)(50986999)(50226002)(2351001)(97736004)(39400400001)(5003940100001)(104016004)(2906002)(77096006)(81156014)(76176999)(39410400001)(50466002)(4326007)(39450400002)(7846002)(81166006)(8666005)(85426001)(36756003)(2950100002)(68736007)(39380400001)(5660300001)(8676002)(6916009)(356003)(7059030)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0750; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD041; 1:WBrNFg9bSEl5DtI3lgtM8Za0dDoq23/QJDGwYHL3y1LdEd6REAUXBopF93u3d9pBq0j8eVSrHaguaiygGNdpuwlkQHMnl/Sja091dvOVLPoHULXjNFEc3xfxIB9shUQhhDdxWpxlCxW5gcMF1Eq2Fyhmnc7hBLxRWt3/Fx+cKoXqYhKEvIUBZkZkYI+50kKjW7vw8kvtzsnrGe81d9aYBSwkNqL7slJgaOXrOGijydPqApL7FGbt7u8tZ1tLv4Jn+TMWThDwy9FLoYMV9BapWU4zK0+ZjaLBNMRRvPMkTZQzkRU/Lcrlf4Nr7epqxOr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bdUSIgmlV9+KMJmPtx15mwtGPeL3YrFI2vhJC0WZDt0YTrXj/565KmRbJz8u3vkXyKopEinHIbhuPHpoANOBbkg/O4gPs7fO/0JzaeSc4EeKNXEpWYH3SPnCIgupK8MGe9yJ/IIGR/buekV297yIZH3VivAIUuHg+wBb+/rIMNfoPsT2l4YcC2RoOLrrvAxOqC1GxN6xfcnKW93S7AaHT6FX3eX3LVFFh2FmVOwlESC3mHkf/Z6rFVvHnM/wjrCsIKD8miXOcR3VaCKUrRxkYSx3X8DJPixxVnZUmsh6eepMF6iWWFRnh0/5Me8u/dIcXzPeLTFM6TL+doPDsbvP01gr1sHRerKnA== X-MS-Office365-Filtering-Correlation-Id: 1d7ec8e6-3e82-4819-a0d7-08d41c2d9400 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR0301MB0750; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0750; 31:DC2kMU7P6BfCgihjsTkL6GNk06yQ5dR2xj2s60iMusfDREV+VYv4WCqw8Skg8krnSGLEgADS11487UImk5GxRzGaIoIqNT6J9ONPQ+9VT2K3H5Ew7hEakB5WXutOSCfWvRf1cp5sjAVQmmIYy+ZVQZdVDXPQsPO/NW/iLic1zK8HHzob3M08UD1bjhE0+3/zLpvNGjWT+5JN6lp3smEfkce1iyKIy3lxe3ddzFs/5una6IzT9ZL17qDGHUZC7vSIs+50znX7dIA2CZe/sO1VkcXu09ggRh6nXyYCEqghF+o= 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)(13023025)(13015025)(13017025)(13018025)(13024025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123559025)(20161123565025)(20161123563025)(20161123556025); SRVR:DM2PR0301MB0750; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0750; X-Microsoft-Exchange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t9?= =?us-ascii?Q?4wgDfZOdrfBTrpwZ/U/tP4Cviry7LJtgY1MIe5jINFdpaDtJgA1LdtHPiUsG?= =?us-ascii?Q?0yWLbIAD+3o6hSyLoQiFaYf/VXeys4Dey3I9Bb63eBfj6u7FMwPeBAF7lMH8?= =?us-ascii?Q?cxQjS0/rxkGaLqUQdq5erENU0mwVt20v21iS4uRlivwMVLdyL2oC67ryXaib?= =?us-ascii?Q?cY5iDC/3MJxbSlZswPVDmN1CU1VuulnILt4QvXM9N?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0750; 6:KpBZ/JsjsMByl4S87q8Gbx/Lj7EtKIywTCeCve2S9Ic9ypAEOvedF2LUe5iZxnAg1I/1U+f6xK23w8/EAC4DL7l8LImkRRShcaBjx9vjM4qwOkrbUdtMwCWUarAr50+3zZ8OYTV7AiFbIRQ676TWUgJzvlz2VdR0KvU9ZeQXN0oPQ5M/ylCLu1hA9ezp8gbKA9jXpeYPn0eQoqcH5DK8OW/sGRljRV4b1m8KuK09RGkOhbtRw+XqkSlAU+HS2/Rv1OVKGgWxjZt45Eq5GK2QXL4kMJDZSL6q1ZELA2SIQJU0ZF6MxEZ/V/B2mIJ9QsshvqwWIwI1bVNTyA0r4vjztg==; 5:bWJAV3g6r625XGaz5dPyNSMOuhxWhriC0sf+pJus+MWoZxLNTaaPLAq1kxLHxx60tNI9FBjmVN8Ka3p2+TQrp1cWCNXy4iA/3GI0QTrvWlCqgOzVhHClV+JVoktIMoqI1PHpAQG+aZwQ8wjCh9EE/1WHoo0PBKXgeNTALEKjZup3v1pL+AuOw1+Y69G4vqzH; 24:Fnq12nAsrWeWfyn844IuUmYY4gzgKKRy5ni33ElOXBlg0hOdU1hjhpX72LdXizidYkJJYwa38jIe0Pscyg6LEX+oYAOM9KYVW/x/aS68z5s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0750; 7:9O+aZHcIctVOh4XON+ZFlYmKstr6/1XO3WvmfFtaVLZLIXit67o2bRkOvWk/Nkx/RPAd4EWkfbq1VjcG0t/1O84ZVX127MqrDxCMXs1pq+jjjN01sYE0bleGxgxYFW1uMltZunMi+6g0knL96fyGheO/EWI1RqAZkjbgMsSszZpgSpBkwL29rSiVP0kWptBp8KxyjgWtiSv1jX+LWk1D8YEvoPlBewVxjKixxpTjWoTVdNXYivmgfOKcY5TK5uyTsnVcO5OZbbhSC9/ZjlzsMMKOHE/b0U0ezVZLQhzIvRE4hMPMCmitBkiQIddRtpEavwlKS2BYUIqB1NTTz7VgybvQ5FM5daZINFpjWiFa+y8= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2016 10:09:04.5917 (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: DM2PR0301MB0750 Subject: [dpdk-dev] [PATCH 02/13] 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: Sun, 04 Dec 2016 10:09:07 -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/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 ++ 7 files changed, 400 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/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 dfd64aa..79f958d 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