From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0083.outbound.protection.outlook.com [104.47.36.83]) by dpdk.org (Postfix) with ESMTP id CBC8C106A for ; Tue, 17 Jan 2017 14:34:56 +0100 (CET) Received: from BN6PR03CA0056.namprd03.prod.outlook.com (10.173.137.18) 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.845.12; Tue, 17 Jan 2017 13:34:55 +0000 Received: from BN1BFFO11FD021.protection.gbl (2a01:111:f400:7c10::1:153) by BN6PR03CA0056.outlook.office365.com (2603:10b6:404:4c::18) 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 13:34:55 +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 BN1BFFO11FD021.mail.protection.outlook.com (10.58.144.84) 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 13:34:54 +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 v0HDYI2f005071; Tue, 17 Jan 2017 06:34:52 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Tue, 17 Jan 2017 19:07:36 +0530 Message-ID: <1484660264-6531-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484660264-6531-1-git-send-email-shreyansh.jain@nxp.com> References: <1484647774-28984-1-git-send-email-shreyansh.jain@nxp.com> <1484660264-6531-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131291336944983275; (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)(39400400002)(39860400002)(39450400003)(39410400002)(39380400002)(39850400002)(39840400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(33646002)(189998001)(47776003)(6916009)(106466001)(356003)(110136003)(30001)(105606002)(6666003)(48376002)(50466002)(2950100002)(104016004)(97736004)(76176999)(50986999)(2351001)(305945005)(5660300001)(38730400001)(77096006)(8656002)(36756003)(81166006)(8936002)(85426001)(54906002)(8676002)(50226002)(5003940100001)(2906002)(4326007)(86362001)(81156014)(68736007)(92566002)(626004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2474; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD021; 1:api47WXlSI+IizpNnscniyz3cs8PrI46vrBmsWrw0OPBJjVnXjHVVfAOMxAfndcILzl3f6vBSLlliO5SHwTRK+AQ/W3gw544zK0DheQOSwwJYtXfZSw25rBQUMJ/+po3rSj848RSJOaZ6U1SK54PgEBwAtMtAvUCrvyDNEaOvsikUo28XqjjmU/tH9uKJ4eB4G0Z8H4d7SfphhIf1PT/AZ0VOYFf5qxoq42RRmIcdAJsE4uV1VLHA2f1ZdK+xQng99qrpT9Mf6ZVLCxbE9cFFM/zfAHoygutlHXHKZkbuKpZotacl2c9pCz3BKnkPvMLPP33wflKkMJwya60Cyeiig6KI0A7uO3gLSJfeZ3g5BznD23AYonLkDt05Dh4iILyVubQL1DB51YFZZmRh9YUAhPjpDPBnMipOzo+lT+HTG2SzCFvkgcf6JC8Y6ZEaUYfT68aBvnUZq44dADhh+SjFhHFCOGj2UleQmEMQ7oz+3hkI6QwPnmXTrTrtkMSZguKxN7qLKv2MtKjNK4xoRYnRfRrgMnmGgXDF0jVMhTOduqNfbOyDHbEEsxltKLIjbfxbtTZ4U3zxQiKZZUj+AZMjuYYNFPlURsFAOEY3nNRCPtGgzgFtVNrcbp9xkEZy8m/qfEiTF3HWnJeUmUWT2GhCZsXUWYwbNYlUrynDzh0PD/M6FuB1JCK1hvTJWd4jPr9KEsxwhicriovKLNnFIGBtw== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5dea5612-47ae-4dd5-bb8f-08d43edd9f25 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR03MB2474; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 3:ZBElVeYUzwDTuui570RnF7ZhEBiVYK/yxLVoLhltHc85qUnCc1OGXf6LsF7cGhXGkxcsdbPeDfnJabZb4qmTR7WxGb5lAUWvoGTjFe2mUjj+gjl0aYQB6Uc73x1gBexVjkBKEVFXbWkgN6IW9XYUVfjP97yCTey2iPqZZhNLxPtLjHhfCytkG9btenTg8Q++gcWXBcPjE3bKbnkopANwLWlTUNnNv6CKU8JWqn5VsaJ76GhhOQvSi2VIh0Qe8iYNDRVixwEq5dktPYPpj6SyzyAdPho/j3sXHaLrldYl15rzG6md5TqGNPFpyzFP77tByOLEDhKjWZW9n93J5N87y2R7SzOwbhqLDKEI75eGfFguM3neFzOsoHBnpkK4uKD9; 25:nNy9VmXyy6ZLARyO7I7gWtEvU5CpTg6yBPmV78lCp6VHJUG6aEvuLPOJLqo21ZEEbTUz98fVnw8Ja6QnKMBEuimJIZrdLAqT5LYKt1XyEl2BzrLI1pQ2ZZa57v6C4SPemLFW/2G7QiLeD/uCjKk7rGdJ2dgldwJtIxibCYB/JtYqqTmW7K8gQNnYBNnchuIYOl2PdPgOznHTQBEYo4/UYi8tdElXrtbX9Emongpb+c2RMVtVUwIQKSRPcqfbofRrlVsMrOAxp89MqGdJL/fkpCK+1+fY7DxS3+y19DJXDdHME0ucs9kbjyrs6mHT9MHeNDbhXjmXsrlNIJcmthVX/jNpkjKkCKEBbHFmCxcIkLlJ2fBDW8lgj7jeJgi6s4UuvPGpLVe52FoPDlQlXoOsy0iaRscK7FV2wECpzoQc0f94KrYZiofZ3JPt4dBc6wnNdBrTZrF2lCuTGokWFUYbKA== X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 31:Yg6vojji+dUarPj7GhsYw6pd8wnxI/PFO6awhYEWCKIHm5PUv0y3OlGp5XQbmLq7KQqxc/T2K2a6XgXv4vKSx4XgPaaOqMYPLvrD3JPdoxCbboQmd5qWl8GyWdpawRGrAXH8q8SAet705PbOQb/ysKaQKblzJfHsjyACCV/Uh0vUsuTEMPDuxzB6W+ZPpWMuT0f/nTcyjLRgz5W37u0GOfP3R98lKzjZgEUYKsVcL49ZzV3GZjgiNlxiqUVKvcvMUqiLrfNtkquJKbmHB7rSVLd9gMc7id8aXXzoLqmtJ7g= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(8121501046)(5005006)(13024025)(13015025)(13023025)(13018025)(13017025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123556025)(20161123563025)(20161123559025)(20161123565025); SRVR:DM5PR03MB2474; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2474; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2474; 4:2VkGK2x+gOACBZ6gxLWYweWZ6s5bu91PmQF208kJAIFc0EC8GmDq+ilJUOpZXlBXZ5bHnoBJAqpNejZEaawHAz20WSScpFUIAdMgv1Xovrjd6JcdIV7cM637LRAK44bmzqWmiOiym/EPOKactxoxtaPPmlA/PMxgfKeQbKkcpNKDD8I2WKpv0RJ7dkMPOC2x6IbPR7jjNsxJudcdrRzZmNARIBsfSbxNpy0thflUxHK9MOJdxNdgRflJEk3qhU+oM0m4Rm8ycKLZZN6AJ+g/fDJec/Xz4oQEEhHYSQYpd85bZRFnQttdZCsesASNZ94g4rrCb6xHESBDODDzglit6wuWxAD6sWIkdd1eThiPMiKeMllQYVPtKCOeLDdwj5Xhncaz+9KIx8cI3jRSDUeQNzjjaNe3CESl1c0kd2wiFKgkGbkBw989hbjqJixQnoPV0dSwfR5FvXez+OmgQiovY4naNUeUf9mf4dstbWI5qB1WaulkvrVqbMqJRpoVQwY4kjekczh13c6UmfFDIXaSOnwMB47MLDW35P27zKebSQEgSC5eUTM/Xs3ZloSU+IvoXTkk9ZCbNQ9clX31GheOM43Mqb3zWeFFW0BMxILorA1e7lRnuL4qZUvPm6ojTxkmz+hdlO4Fwy860ZR2h4mIzuG3/UqY46a715oeYCB71v+OuDaxPpqDDZ68QFYGvEMTP+O1nBQTstkp7O6uZV8AMH8u+8Brdp8OitJhlYnNFci45Vt0QbEdQJGEVKanFbZsuS+zc4XZAbq86OLHooKuTA== X-Forefront-PRVS: 01901B3451 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2474; 23:ZnL5FC3uE/BMCeI2m9t6uB9EAQZbwEHobnikB5D15?= =?us-ascii?Q?q1BP6HPmufxZ9OAP0lYOx3VJxAllELlHEPpDxDebx808/4Gnu+YpfXy0/EcQ?= =?us-ascii?Q?Rpr+EK01AmlzDbi+RS7fjOenXp8nycA3MIHQoXHnLiceYKZkTnxB9TaFPzFi?= =?us-ascii?Q?QQHWELzrCjWOuUsgu6WmZpPWDlOfNDa93sdFthErx88/nMSZe3iDxIZr5c3f?= =?us-ascii?Q?CXHDmJ8GMzrY+SUhOlUe6Teno6AYTzkXQrDEzHP5xdZNj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7:2rcKcjujTqaXj5SaUKaq1mzlfSELwuIsSyG3MHI32sxTXLTpHhBykbuzp8iETbNLym82G1jfHrm9bm4mU+WgaqsIddRX3Q4aE1NN2cuRhQCnvKNVUI60rabW0KXbJ5ZitXnGQzEOXrmFwCL5kYEU24VU4B5pCkNxSOujtHDaBxsYvCfjb/b8fLY1VHfFBEhhqk3hEZePctR8m2YV5RREtmyLX93XAN0YXZztWe3aky01ACcXwQnhQJtgeDSqF6VtCIdElU/JYlPEPhF7RYk20EHCX7iFOjN0RDPkASyJqLEhAhektT5GMZHun2wVVT5z1bWJ3WKnPcLXxs5lzM4XYCm+Ruek9y34WVkcWMHT9cA5OWKqZFrOGmIGu4IuOoAS3aPSK758F02+YKwdYh2LURFTj1UQpPtRpCpct2V2yxRbMcaMS2b+UF+2/0Keh6jjtVxk7THmuKRKj1QYB21J0g== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2017 13:34:54.2487 (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: DM5PR03MB2474 Subject: [dpdk-dev] [PATCH v8 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: , X-List-Received-Date: Tue, 17 Jan 2017 13:34:57 -0000 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 Reviewed-by: Ferruh Yigit --- 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; -- 2.7.4