From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0073.outbound.protection.outlook.com [104.47.36.73]) by dpdk.org (Postfix) with ESMTP id 80BC6B33E for ; Mon, 26 Dec 2016 14:21:13 +0100 (CET) Received: from BN6PR03CA0038.namprd03.prod.outlook.com (10.175.124.24) by DM5PR03MB2474.namprd03.prod.outlook.com (10.168.233.20) 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 13:21:12 +0000 Received: from BL2FFO11OLC010.protection.gbl (2a01:111:f400:7c09::161) by BN6PR03CA0038.outlook.office365.com (2603:10b6:404:10c::24) 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 13:21:11 +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 BL2FFO11OLC010.mail.protection.outlook.com (10.173.160.154) 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 13:21:11 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uBQDKVCR029786; Mon, 26 Dec 2016 06:21:08 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Mon, 26 Dec 2016 18:53:54 +0530 Message-ID: <1482758645-23057-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482758645-23057-1-git-send-email-shreyansh.jain@nxp.com> References: <1482756644-13726-1-git-send-email-shreyansh.jain@nxp.com> <1482758645-23057-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131272320720849237; (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)(39400400002)(39380400002)(39850400002)(39840400002)(39450400003)(39860400002)(39410400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(92566002)(2906002)(4326007)(8656002)(48376002)(50466002)(50226002)(33646002)(50986999)(76176999)(8676002)(81156014)(38730400001)(81166006)(68736007)(8936002)(77096006)(5003940100001)(5660300001)(69596002)(6666003)(2950100002)(6916009)(110136003)(189998001)(47776003)(626004)(36756003)(105606002)(305945005)(106466001)(97736004)(356003)(2351001)(86362001)(85426001)(104016004)(7059030)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2474; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC010; 1:Mv5w3ZSGg9YuhRh3h0gR7UeX9d4dKbf38jVlXoBdhamRskrOMiMcfjxmo5Bphnmt6dw2jJzob/Db/vxIr/cf0tCRw2DT5aaxlBwIgcyaHj2Fgi3xTmM8tXFcv6pBBOjXKchrtdaRDxd+XmW8W7bMgf5oz0TriJliLtyysrqgKGXryNmIzyF/Rx54drHsL07L5XikMbsdw+Mk2NWRZZGCznbwDBnVUKpRc0dT+Ctix+0/fuox0ljLMFn+MNfL9rm+s+6ukCZyXrAbgPCtcrIqhmyDCsT3sYoQ0BgVDLL4FoAVK0im2d4tzgKFAsnnGcJjcOXZ+CnKRUbfO0+VlEEwiQD26eBCkaOebQ6m2JUuyBA7ZJ4+Wdx/M2RfKHBS5RV3qVruTJLsasHI6jMQtLE/KWV6nNCOBu5Q/o7yOrq1PBo049cU4XlGDdiKs5C9AQTAu8443hAP61BObssGdbeE/1mXa92yh6GyqWF5PsW5/XxA96C7uv4SZP6RfuWvxG2Il6Gu+M6/nAo7X6fQH3rOJRPNMxfDhRBUFwdJsUTHQEjCtVS3kJApJkDQBPLMQte4KEFz4UQad9zVU7jTRe/k093z6cnzlZa3i0hT6bWFa275Zx3T4a5ywZXZGIsXvG2yKuohaPlSIK1bSlKRc3Id0ZcqSUb+8ujDlc/AHEuX7dvFvvLrQd+ihqIEk7DerDHkIgpZ1dBpGcflPSt5oJvD0+j546k0zL3Psi0SNm0Irwc= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ad06e8fe-ac69-440e-e7f7-08d42d920fdc X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR03MB2474; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 3:mUFuTvOAgPgUuQ2HKCyduLuPuStJIMd5rPXBeXjHKH8ACwUmaZCNx6GwLgKZ+h3mgKPkeFo90r9rLHE5qIcPLzMlV5/YdLY5RMO4qwubfjNLdvnmF7V+cksiLMYVayYlYJQXBHBQBNdZzpuSr7ytU1F3kvAgXu+QCmqJvNhegdCyfMNYEfAk/ZMm22gTAVimBsK5PtM8ARdISY10dEYFEl2ifIvUyp5T5fJjcN6T0b59BZLmwmFJTkbvzV/sq+nqpzKntnoO6o9JXDNN8SSdmROUredp6qCN5nLjU01+oY5WmhKhlzBhhFcA4iR0uYUmFQk0Rd1akGq+FovmcD11H2G8kSxDe3L/clMWaeKgFqOZ+aEIoG0dNci+zQMZ/zWx; 25:x9wYjxRMpZ0U+hkffi7eXBimXttqXGGsknK4rv+VG/MZKlxtKH57xWlXN+5fqVCdp2G4kIH2rGbqU6pn6ZEvWmdGuu+gq3fI+asUrKfPGdhJNjWpipnNZcmQT/BT+G7rVRlhooPNXJtK9ycMXZh/KrN/4JDXwjH/0auy8Ckl8KIy4H65cxjLJY9YGgjqEs3rzuwBkvKf225i6hmLBag9xkGIsacAAVJQx6qvEtK4SUS83cPiMmU+E5jXNrrqH+BFwabGwL3eB5sOKTV1IJc6mNYe2sQi42MELw/PyQEaObfN7C9hVg3ig0z3C/69H9wgm4jhZGlnDtyPUSgfGmBvS/WV8Zksx5P3abDAOnimEtemtMzOzjCIf2cNr2ukbYmAm3YSjxcyTD4b4o9sm1mu7r+7E/eLB6b7XLxUFG7DPbHtqsObcBfW7NoCN/F88u1t/Er1/geYyjsUODvFLVLRoA== X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 31:RBnr1jkS9bJh07tMMvaNE1FNd1GKM5XAIiyYtTscwwtTQrAgh5SNJi6vCgSlNcNb50/eh7cZJ+yPX8sT87WqqWdBqaSEghRIbDs2HImViOSgS8VBzSzNqBuYxLp8q2Bze9VsErqevPfH5mJJyD8zX0bGE8BtrKTCpyiC+R4JMmlsxOyL2CfLL/UEIBqWBH0NrhYbcRubJZUFhHgWngWZbGD8G/wd0E27zd5WbqSl9GaF9mSAqPh6bLYgr7QFRFNEjHnmj2/5eyKEM++L5BoPFg== 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)(13024025)(13023025)(13015025)(13017025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123565025)(20161123563025); SRVR:DM5PR03MB2474; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2474; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 4:H7rtVTpOOT9ajnNRI70uMnidJcGkpwXhlZvyLVhiamazZK6KhC0LdvZpBulW21mRRv6ugnQPv81oNsKshAf5O4+5Tblf+LfB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li9TBon27ZwyJJmeLvsr1Efrj?= =?us-ascii?Q?d1uuEKC+boXRkMNuy8QLyJFlvvf9gHxDyAB6978y9XTw1vSzi4HcZUcN6JCY?= =?us-ascii?Q?YW36s1yeQXDbhnOa3E73aNobDi+YoptxXS0fPuvigha6QZ1e8F4id8EGXUOQ?= =?us-ascii?Q?sYbhHHal9o548G+WY6H5loHTuUlnjnnVq9EWuBHedBm?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 6:p7UPEx9CUqSnpb8vsfZHN1TQPEE+bcwb6H8toORYWrmq/RjDI78ZrmaWE5oEtIJW0Sfe5yL1ewpgiICDf1/+bWXiOXRnVPIzBI4qBDViYTM/ansytWsPw84dBEzIHoIet1/xxhuU8YNiRzOXhctEIdpta5+9sjLRsUyyR1v7Wb7MEchid5fzx42U17pJpMBuiAIy+gF5wki2UYOBH11fgxwHqWbeL5c2El5KaHHZKN/Yn26n/XCHBXJqWTcZE3xwJAV5axc+qpa9c/AxRr2jSXemsCl5cWuTfQE8wRB3AkR0xMjwWlbadXvLWBpFtjT3U6PfBYQxN3Qg6I5RowP7CdADzMdNZ0WcGQF5Ta6eMmXdEvZS5Qf2U/6JYEEvr26K7lqJcG7ruQaXiDsl9b3uxAwniqdj/w4I6794jxG727YNcLJcJlUB/6rXwdUF6bDw; 5:H51uj9Z04uk9fuN5wvFFI9mvBvobpgyNjmAouAZDDmmBAsHJK7B6jfNWdJk0vvWsiVONfCORFss35Udeg44JlYH+s8ayq7YEOgZfOy3wY4Z269QyKLAOOBH3mtDj1dwCr4ydFgK9GneQw46anPPHyT7A04fKmOKb6LUhBPT7tHsZyDfk2Bl+Bm0b+3o9rdzR; 24:G2Qg6f/KCvhB0Px2p6Fdxvb4qBCIBurN9IA5D32Hz5NqlpGsBWpLdDlrDWuZvOrPIw2ZrBDosN3Gj24uvJ9GK50pDBO90MviziRFNfhYHmQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 7:rTzDfslG74wPDfe8llEnusx2OYJSzF+pZj9iPu7CyCvehtFP2ZsXDTGaTGf8ImGm9yHQVjExSMf4kUtmwjL7vmeYZ8e4btlUQvba6uKk9zSiSR2D9cw68YemL0BVnS458VN4sgq/DhWXVLzAf/7117j0mUI2bl164AVMJ/1P2cldo3U7rXRV8/TKoTvwwDCI91pR7GGF1OzxBsNmEdmMeTwBwvFG7E0GRL/TYqP2RuRNZDycUXUGRwkedZ/8oMK8CC5kbNZuBJdzSWVe15OdCDbLPUQ2NEpxr6TW16qhs6KcwreY6Y1FUkp6ux8QIm1KJvZR0rMcaN4kolp+fp+iMhM+gDnSzxt8PmWQxBz/nr5nIg5XnbxIUfH1PB7c/rhbKQ/0CiS21x35IxYVNjtThFvv95EdQ9rae2YDWcE5L6N89nvw3vYUPvE9+Hb6WIxIAPl1zMFfZgAZ7cOW3Ew+Cw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2016 13:21:11.8041 (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: DM5PR03MB2474 Subject: [dpdk-dev] [PATCH v5 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 13:21:14 -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