From patchwork Wed Aug 31 11:00:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 15557 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 BBBB22965; Wed, 31 Aug 2016 13:01:11 +0200 (CEST) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0056.outbound.protection.outlook.com [104.47.33.56]) by dpdk.org (Postfix) with ESMTP id CAC6E2965 for ; Wed, 31 Aug 2016 13:01:09 +0200 (CEST) Received: from BN6PR03CA0057.namprd03.prod.outlook.com (10.173.137.19) by DM5PR03MB2443.namprd03.prod.outlook.com (10.168.233.13) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9; Wed, 31 Aug 2016 11:01:07 +0000 Received: from BN1BFFO11FD043.protection.gbl (2a01:111:f400:7c10::1:147) by BN6PR03CA0057.outlook.office365.com (2603:10b6:404:4c::19) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9 via Frontend Transport; Wed, 31 Aug 2016 11:01:07 +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 BN1BFFO11FD043.mail.protection.outlook.com (10.58.144.106) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Wed, 31 Aug 2016 11:01:07 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u7VB0laS010481; Wed, 31 Aug 2016 04:01:05 -0700 From: Shreyansh Jain To: CC: Shreyansh Jain , Jan Viktorin , Hemant Agrawal Date: Wed, 31 Aug 2016 16:30:22 +0530 Message-ID: <1472641235-23626-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472641235-23626-1-git-send-email-shreyansh.jain@nxp.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1472641235-23626-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131171148681193992; (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)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(5660300001)(76176999)(626004)(19580395003)(575784001)(19580405001)(48376002)(86362001)(50986999)(104016004)(97736004)(5003940100001)(106466001)(47776003)(50466002)(11100500001)(81156014)(105606002)(92566002)(36756003)(33646002)(4326007)(81166006)(68736007)(356003)(2950100001)(229853001)(50226002)(2351001)(189998001)(2906002)(85426001)(8676002)(586003)(110136002)(8936002)(77096005)(305945005)(7846002)(8666005)(87936001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2443; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD043; 1:1gov4xYNtN+jF2dxqwfT2cHDWxsIHtBS2WKeAjJgPpXHzU9e2Sb6fWAtwgaMyLgzasL8ePHL3akvuD9yeQA+4FZyVjCDQAze1qw+DXBzvCTMM9gtnYpY4ibcIqwK+sNC0sby+HNtIiQFdlj45SdbsLOarxbV1wB2VQyzoRywTGgWKPgAR/RxrQzfg+KlEGwYLB0GrcmKnGVZ92c1YyducZ9e2RBWPcbU8c+BYWPEDi10DQrxSyWr55qhLsaMiHAGFwNMXalTrmes+XJbHM7GcwOuhr2gtYU9BGyxiDfj3acQ6BIIN/wAuIYeSLio1Z3IT+/s2jbMc9Au6guYWNA0ahxlyST54eXY17/11+gwuJsvzAOEvkfo7V/nzN6hMAAWGnSdY7LdCixUkjDGXE24WStOvSnM/45NBoWrgkqNZtaZQD1fWJXleQAKAAahpaTHQGlP7cRGDWfoyzxZ7ZmqKOaoY5AdIT5V//+H5li6NLLqsS1peMke8oI11G94WPa74cp9fnAJxYYECMieoEtLlYXvoASjS4SycASJNqn0QK0G7tZ0tcZCf6/GJgIDO509Apsia5e3zs/AzD88K8Blfz96cs4B20zX9BYUQY2EOfsiWt4eZr0JmSEON6kDCpwYX6hkrCLGUM9xAXg/ivTaj/pIilJW18OvyYwvqg9CNDwuEPHBMTj/1sNs97kg+ZJFeScw5HedrDDFUO+UGKGi7jm1u5XGQFY0apA43eoYqEY= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 41de4e37-bf9a-4328-6746-08d3d18e1c5e X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2443; 2:zdR3Jq+33FRln3Ea/QsBlWGXOsnhTFCM3xyw+55vvE5RwodtjknQlJkkljAMcmfoCoHyM7kmhJz2LNfSajPzPEUuSLRF4rMi7J5MXFWyXALWofAOP1whrbc6qtuNk7pnhNza0nAJ8jCzCs/w9YnZAGqcS5XoUFqc4OWQqaasVt+jgLEh/JYd6jUhl4Jv5Qqf; 3:MHDBojlvF4HWOYqi4FQPurVQQLXuHxKKQN7ljLwFACWdy7/1UJw39vrNqM6ElVvfhi+KrhcDIFgv9Ab1WjNBzPGWkY6YkoZoBbbS2nobBzCbACyWxY0YQeHzZZM/WMmWwDDLU/93SeNlYERsOryo9EMvmOqI8Lvy8sSCX8wKNPnivIYXK+0JNhiZRzTOtcGeu41LcNlBjXcC9izAptjk6YothaJRN60h8qLCAiu1FoA=; 25:wydhfq/EXyFCH9NOXxo/rL5JD4COPBL1D7/BG8wHrZWPnGdUTFsr1+Rb027//YjmBfIxDRcsEtnZO45ZDrQ013tUhFjR03dqZsRQY5WrGY9bjyI5yOjGSpG/DJ6yMP0FRFMvcFtL/Bx/b454DAlA1PGWJr5M6fwDgDT8IlZ2+JDFgftomov3mUtGmlyrNsEY2b30rADOw6SmaTMJd9xbj00FJoyrkSMkjPb+LMwGGQDNnVznPiQ/tTG5Y6XQlKaOi1hfvuAPsxXfYk5KNPTbq7T4fA/Z61aEcBnq79xUEhg4H7FoVP0Gslm5QcXpuyaHbZKShGJCd1fgKiTblXyGyvvJNG73k6//p43bfOPLYS6qW+4Py0tm77A/hF0kw4Kzol2zfuYEbLjH+CeqZU3uzV3XRMw+Vxfm3xa2I7qll5o= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2443; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2443; 31:v4SGs88kyL3gZBolgZohbzLtoWuujc63VpWQK4gIhqODMRgXSBjuhmIG33fx2ZjGPHtKTSjou8bKakp1XEaRniFB0htry9kT4UESz8ab85SS9XAypk9kmnQv5/ixFBMJMnK1YY3CeZ00MzL2tskpFKwKVLohUVArcHYEOkNWVtzR0duVnoLd/UrB/rkuP4xogBP++IxJp0EUhZelgEil2e91iGHahXwK1m5SLSNOjY0=; 4:XmD9B9FqhVXV6RQaPJq5zoodFizQFxrDufin1MCLPtG9FqonKfAwpfpqDrvaWhuY6ofYKHOV6jd3A54pLmuM84U2lavvJDilCVzUmC1iCmzx3AZzlPLgd238bs9aaUcOs+8KMEXZaNc96LU+nw+9kyx7CykksKig/QYn/KSsKRraAUcFBsDbrKooXJxcDip0lp802brzDuR9Hz99mluEuBj1qD01k3H24X2TWO6RSVvKrULiER5ixcSDZViE/wHenES8qFuSGpBYDmopYpIY8/nOc4PIERH7x9d2eHdpBZrhdBlfn57qOfHFK8pK9iDNZdyhdVWb+z8Q2W9E/g8ebPs2FnxAjJ54UUScInbWZ1J0yXu07gR90I2kQC4yNek17NhbTzmb0vcKSgTFyfz0IDfxwsk9rGjv9AeAMCyGcWfdm65U7Lpoqk25eqBLL/ISzX4bUvPFnEeXUGUlboI8UPhbC+MMzxNPItbYClYoTfREhbd6lg0Cdeyd5TNOBrrfVawn+l4I0k07vR2yv4c4lKXCBXvB/jxczKYNNlSslA8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(13018025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:DM5PR03MB2443; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2443; X-Forefront-PRVS: 00514A2FE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2443; 23:GxaMJGhhlrD/S81RD6Nq7OT+fJjBSKjhhCxu+vOqO?= =?us-ascii?Q?tXZJVWdFzxtD9bgykUya8qbly4rAe9wsceB1naJWe0Elnl8USlK2yFbqQ81g?= =?us-ascii?Q?mZ6JCVGtDv3iJbiPRMhhTltc8xEn04Kb9OtwqQxzxMjpwp+v89KptrjNEUxs?= =?us-ascii?Q?/EgAV9sbEtuiu7273XYakB4Ygh8rzi1bcj+BawiFwOQ6IQM+HF2yN+3fzojC?= =?us-ascii?Q?LPPPu1YprdIt85xlNbsGq3sL+wdXeBWl8gJ4S9qMA6ojWAPNG+QNagc2ytKW?= =?us-ascii?Q?kKJ061i9+8+2Rv/MWOZlJkPtb6ddGaqbpe0OhrcA0NJ5ud3UzraO9BIh6+nc?= =?us-ascii?Q?mL16tQ1QGyTa1D6fYqKOcHlFN+1Myl4Ktu6WqQgNZGasR76W6vcemHrlSvfA?= =?us-ascii?Q?GMyRgt2oYE1bi5nPJXbBUaOuhgYwatS/wzsUJsZlE50XKP6IfRYZ0up2B1lW?= =?us-ascii?Q?FqDuoGxmJOArToiw1l3HAsjOXDGXcrCE6Mpk9tbe3g7z1OYY3FtRFV/wf0SZ?= =?us-ascii?Q?HjqqFMaHSpcIxJeRXn7EPTQT7ddyc5AoMbs/GGko5RgufVXbVYACuuf8R3q+?= =?us-ascii?Q?aQsn7FPfQWYCO4DPJuJdj1fTRpvKDL2MSOwjLEzawSvg4y5MtpkZKKOlT+nQ?= =?us-ascii?Q?scrrYuZDKz6pVca8ZwxbOs1FdyKzPJjEM1+W5YmV85LVAkX7yMnm9sdgBG0o?= =?us-ascii?Q?PBykD9cN7aphpW9TjSVlEPmJC7XJMaDJgBgYdm9A2WH8JAWlebmQ6L5NC3Fw?= =?us-ascii?Q?R+JdGHX5Q3NDmQ4dj7WSYSrGqQjv8MjJ/u1hDB6LRjSAcHFLiQdsa0+hyAXl?= =?us-ascii?Q?VNOjrreW672DAMe3tl2ZDwI+/BbnZWruMl5nGKumGGwV8zHfB+66AhxrCByW?= =?us-ascii?Q?W28uPXN5hQ/OxIsiWpzR/y7lD8tzgSw+sqmfn2ojHwILroQ4sdMsDDrhFrWv?= =?us-ascii?Q?de8ebGe8VRhGZ7pQTdIvGUlSwN5mR7zupsPoDLvi6yKx/GX/FsI2G1+Y5IBV?= =?us-ascii?Q?J+D2vBypfQRGoHmfkWscSzBijF8wY61W7cPKQfMCAQxttja6mm7QWdNyx721?= =?us-ascii?Q?7bcuDIpdBRmLDtfpdO8GZp2iTDsEcM6TDr3L/aR2c0EDL+/zLn8UcvJdZ4/k?= =?us-ascii?Q?eeU9VJT+XlKQ5emwlhgW/dBI/Vx1wgYcDyoBmQxtZyqLyympBmbJlUIgsqoS?= =?us-ascii?Q?E5SrA+EoJJn+SUeBmoaX4U8f6j7qadcxTEZ?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2443; 6:JszJqJ2WsmuR7s8r6VtTnUbRr4uz9fGlqWQyIT8qGJONmtW47YZHjdHtFOai1KVEsW3PEe74eEkyQloFe/ATsXoZm7QrhkS8NqL22odySF18KkKxhhuwFlKJBQMSyMzqPbRT6aI3Lo4CcPLd2XlDrzzy0yKqQ6eLsuHAYq0cT4KvPuQrIEdgYJw0+OOoaFJ2KbdVnouuiFVUxA2yDLNxE6iBPCnEy6bUcmfzKD/uJ+peEyMpkJXN46ahV8H7UUQRoZNc9xcxb5BJ/F4pkWJahek9CpCoMgGee7J21iaPb8w=; 5:CL6zqn7oVlmQ/v4IvlXjFa07fV2N+em/Nrs/+7bLJTmTUZ6bLp5wbus7QTZ0icgba121TvXZhBX/fsNGnuVXZXXZYj1PR7RxlV997FewHR69S1Z4qjdTPGTDuy6Qz2F2KnhiqZiO1pdI3rj5kiKTTvjaRXyJyJ5p/h8FaJ222S8=; 24:gIuhBCD/wCPRQyjq8ong3hJ+2+NRkxmkiBUMEKPyCGd9b4UXtjCoQ2K3xssysll6CidKdnM1YrRB4cRoJFSEG342XFHzPfc4VRSSpEjKzHo=; 7:fOjVcsJMIZxvLSXIgX5Utgjn81CdnM00TCAKm7LsjvKW06k2QgWTbBgzGJIfVn7n8VAufDDKK+0xZQF/Jyf8V2wVmcfgt+S4I8AQAqPfQ9xuu82SyyUzx6J8qv8STRUgkcJRWxCgVnK1B9Oye9+SMcx+qNQqFdvspeIIYDl3/dngfcCsRnE+6+iq9LrzGVB8mhe3PO+bIQtbLxJTY18JuHMNo4joDcqQkqfHb7dfxw+RD1w5DdHkVy2IqqXfwKaQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2016 11:01:07.8853 (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: DM5PR03MB2443 Subject: [dpdk-dev] [PATCH v2 01/14] eal/soc: introduce very essential SoC infra definitions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits. Includes rte_device/rte_driver inheritance of rte_soc_device/rte_soc_driver. Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain Signed-off-by: Hemant Agrawal --- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h diff --git a/app/test/Makefile b/app/test/Makefile index 611d77a..64b261d 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -77,6 +77,7 @@ APP = test # SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c SRCS-y += test.c +SRCS-y += test_soc.c SRCS-y += resource.c SRCS-y += test_resource.c test_resource.res: test_resource.c diff --git a/app/test/test_soc.c b/app/test/test_soc.c new file mode 100644 index 0000000..916a863 --- /dev/null +++ b/app/test/test_soc.c @@ -0,0 +1,90 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. All rights reserved. + * 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 RehiveTech 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 "test.h" + +static char *safe_strdup(const char *s) +{ + char *c = strdup(s); + + if (c == NULL) + rte_panic("failed to strdup '%s'\n", s); + + return c; +} + +static int test_compare_addr(void) +{ + struct rte_soc_addr a0; + struct rte_soc_addr a1; + struct rte_soc_addr a2; + + a0.name = safe_strdup("ethernet0"); + a0.fdt_path = NULL; + + a1.name = safe_strdup("ethernet0"); + a1.fdt_path = NULL; + + a2.name = safe_strdup("ethernet1"); + a2.fdt_path = NULL; + + TEST_ASSERT(!rte_eal_compare_soc_addr(&a0, &a1), + "Failed to compare two soc addresses that equal"); + TEST_ASSERT(rte_eal_compare_soc_addr(&a0, &a2), + "Failed to compare two soc addresses that differs"); + + free(a2.name); + free(a1.name); + free(a0.name); + return 0; +} + +static int +test_soc(void) +{ + if (test_compare_addr()) + return -1; + + return 0; +} + +REGISTER_TEST_COMMAND(soc_autotest, test_soc); diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index dfd64aa..b414008 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk INC := rte_branch_prediction.h rte_common.h INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h -INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h +INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h 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 diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 431d6c2..df6582d 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -36,6 +36,7 @@ #include #include +#include /** * Initialize the memzone subsystem (private to eal). @@ -126,6 +127,9 @@ int rte_eal_log_init(const char *id, int facility); */ int rte_eal_pci_init(void); +struct rte_soc_driver; +struct rte_soc_device; + struct rte_pci_driver; struct rte_pci_device; diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h new file mode 100644 index 0000000..bc0a43b --- /dev/null +++ b/lib/librte_eal/common/include/rte_soc.h @@ -0,0 +1,138 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. All rights reserved. + * 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 RehiveTech 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_SOC_H_ +#define _RTE_SOC_H_ + +/** + * @file + * + * RTE SoC Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#include +#include + +struct rte_soc_id { + const char *compatible; /**< OF compatible specification */ + uint64_t priv_data; /**< SoC Driver specific data */ +}; + +struct rte_soc_addr { + char *name; /**< name used in sysfs */ + char *fdt_path; /**< path to the associated node in FDT */ +}; + +/** + * A structure describing a SoC device. + */ +struct rte_soc_device { + TAILQ_ENTRY(rte_soc_device) next; /**< Next probed SoC device */ + struct rte_device device; /**< Inherit code device */ + struct rte_soc_addr addr; /**< SoC device Location */ + struct rte_soc_id *id; /**< SoC device ID list */ + struct rte_soc_driver *driver; /**< Associated driver */ +}; + +struct rte_soc_driver; + +/** + * Initialization function for the driver called during SoC probing. + */ +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device *); + +/** + * Uninitialization function for the driver called during hotplugging. + */ +typedef int (soc_devuninit_t)(struct rte_soc_device *); + +/** + * A structure describing a SoC driver. + */ +struct rte_soc_driver { + TAILQ_ENTRY(rte_soc_driver) next; /**< Next in list */ + struct rte_driver driver; /**< Inherit core driver. */ + soc_devinit_t *devinit; /**< Device initialization */ + soc_devuninit_t *devuninit; /**< Device uninitialization */ + const struct rte_soc_id *id_table; /**< ID table, NULL terminated */ +}; + +/** + * Utility function to write a SoC device name, this device name can later be + * used to retrieve the corresponding rte_soc_addr using above functions. + * + * @param addr + * The SoC address + * @param output + * The output buffer string + * @param size + * The output buffer size + * @return + * 0 on success, negative on error. + */ +static inline void +rte_eal_soc_device_name(const struct rte_soc_addr *addr, + char *output, size_t size) +{ + int ret; + + RTE_VERIFY(addr != NULL); + RTE_VERIFY(size >= strlen(addr->name)); + ret = snprintf(output, size, "%s", addr->name); + RTE_VERIFY(ret >= 0); +} + +static inline int +rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, + const struct rte_soc_addr *a1) +{ + if (a0 == NULL || a1 == NULL) + return -1; + + RTE_VERIFY(a0->name != NULL); + RTE_VERIFY(a1->name != NULL); + + return strcmp(a0->name, a1->name); +} + +#endif