From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0043.outbound.protection.outlook.com [104.47.32.43]) by dpdk.org (Postfix) with ESMTP id 7EB82590E for ; Fri, 28 Oct 2016 14:30:42 +0200 (CEST) Received: from BN6PR03CA0026.namprd03.prod.outlook.com (10.175.124.12) by CO2PR03MB2374.namprd03.prod.outlook.com (10.166.93.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Fri, 28 Oct 2016 12:30:41 +0000 Received: from BN1BFFO11FD003.protection.gbl (2a01:111:f400:7c10::1:174) by BN6PR03CA0026.outlook.office365.com (2603:10b6:404:10c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12 via Frontend Transport; Fri, 28 Oct 2016 12:30:40 +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 BN1BFFO11FD003.mail.protection.outlook.com (10.58.144.66) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Fri, 28 Oct 2016 12:30:40 +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 u9SCPEMI019399; Fri, 28 Oct 2016 05:30:37 -0700 From: Shreyansh Jain To: Date: Fri, 28 Oct 2016 17:56:23 +0530 Message-ID: <1477657598-826-7-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> References: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131221314405825743; (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)(199003)(189002)(19580405001)(19580395003)(50226002)(356003)(8936002)(48376002)(110136003)(586003)(68736007)(5660300001)(97736004)(85426001)(104016004)(50466002)(7846002)(87936001)(2950100002)(6916009)(33646002)(8666005)(81166006)(305945005)(81156014)(105606002)(2906002)(92566002)(5003940100001)(6666003)(106466001)(11100500001)(47776003)(86362001)(2351001)(4326007)(229853001)(189998001)(8676002)(36756003)(77096005)(626004)(76176999)(50986999)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2374; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD003; 1:4tROsrOm9QQgvabDbeAmr/Jbi6iJkUwOgiSGyoVNuUIbBpe0tMCAwCBwRU32zeDJJpLG2iqkt7iO/YcrorOZlYiyvEFF0efMxCjQ7zLdeuV6bidd7Gxb7DKrFJgs3PeIk4GpaH2IG2t3UifIwFfBV6z4+dfoBZ17yoS+Hw+TEqIDTuTO4saBKB5G/ofwYdE6M7FJX8Mmsm4rqn3NQNuadiiV9zpGOjGgLghwNi4r31yCg4fcCryfyWZEIy2Tun7c7AmF9vPu/zu6A8kMFQNBZt3qkc6f9VxBmBSfT9T6sLB4fscpxHVp7NAt3Y9iLFEr0JJgto0g5Y6U5ntZpvLQBCaBsYg8MC7jHyJmfzQRgjxO1jOtkze3oi1w7lONiyBuWo9wW8hh7z1sPxjY5uEw+WVg22cUIGwMJMSPoJUI2iILH8CltrqpMeBzdWJ1n4hdJBWm7Jnan4YdBVvpoh/ZBzIcSHkZeGV/YTu4gHluVzvkQfSaBIv7xJsk3MGEEtbDDrln8vhoF93f6hy/B8Su6ibBNJaKSkZy8nV49QRv9dHwLCSQIwmn/3SO3tBpsUnD0XXjhxyD0H0hD1c0sb7iykvzyQ8M/9yAboKNOOt5Gb4/s7WewtS7rITvkrBb2CvSs1zawb9fkTVxUT64BOTaK801i4f37GfkTvzj02W/kEERszWvgcIcCLHlPwjw2Kw5zm32+nnQOXajByQwKlKoI+0M3iEs/0XPrBg8WAY7o6U= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: c0bd1c9e-db2a-4819-71c7-08d3ff2e3a82 X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2374; 2:DPDO5+aAeHM4LSEb8FMxb38BRG4TCoNqewNl8xXDAGNea9cR3ud27EIMICHyI1kc81uM8i3KdqNA9NjJRzdQkYKbSZE4Mtx69jrEg1Ao6z3bT+2dm9EXEjVW0oaA/YUraaLRNZ2wvH3xyuQJxXTO1YuPUgAXcOynFTp+X44ZStWtqJIeItNr1fiIDNwSW0Ne1gzR5V3CHXfGCBV5atI7uw==; 3:HCbrhIwZvTdDOHGhGbB/tNxrVKOtpAd1emRvcqGsPk0yNhNWmEjR44CaMDvUHZ0p28YSQQFgPJSEGBtHj9YSjaAtierBwRnENGgvyRM3+wYzGu1/Vug6cMN6l5VSvtTfDGoAM3HD7PqeSkn/3S+ul3us+wwgzd8V8OBvSVrtI72grzj4UlF8Ew5DnjxzgvFnaFYf5tmjthzpne4Fa2tfuipsk1n0sagT3Toh+MbGs0A8YBk2TR/lYuMcV3H8QFk2; 25:BnNyaBU+LsoIVZGEGJJkTDEI4NNkf81jWrMVg/BndEb79JBskMz1izpYkWhpRe9hSJm1dE3vtrXtJqVHob+wbJnlF+xQZIhRvtm3gass+a6PxqYE2E5MBkHYa/dYoJM+kQOXp2tkaLWvQKL28biVnHqQJFfY0+aU1soUeX0NisyDqevpL54pmwxXRGj9/OFJ8La/6v+ma1S+tzPKMe2y9Dk7PA7EIzHUcRlKSGQXXNNGu76RZze/pNw484zjY008rgzSIIER9ENYvsmp4Ri1Tb6jt2o8pZ+aiIMw/oVrKZI5ZAXa9RkdLYOYmEaGAVtjI9PCNxrpxOMwQPy/SxhdfDEZQq6WLQdO6uAHfwzgv7AZgFCuqlFaRC1w+OPorBnvUQUOqGOJ2NWx5OMWhxwAOUhB0j8K8HnCOfTRzW7XVHCnriCu28DXfNC79hMmVgXgmNpqRhUKBQE0uDKcWpseRA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR03MB2374; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2374; 31:TgM2RbSJ0+y/GOHIbXoc1aZ1S3K5xdXnyU26FU2AYuqkYpSziulGtbE4ceY2pjEjguVKXErxbpANxR0t0nbqnCo+mW3tavJYiYGC+hStLlEljIj2L2cutotwq96YOh5jT1+O81X+PpUNYwJEwINfRjy9h3huPzQbCsNY5qQHdtlz+xw195oqNsOIFelCBmiLA3ZrcYcAwQOumSuZQg6S7fVHkS8MxBaIep9wDyxnG1qxuvIaYbNGrEu8WL37wH2nVOnoTJWyVGUKO2Gro0W1JA==; 4:rPJl9v1HsR0en8ztcFHPGm2Jd5mUZc+kddAYO6kY/0Epp1FnIhgHxCxGoNhlxBPlL+Pt+yF6zvs74S5LDws41BlJ48rx2KUf//CuZLzgANkMOQudUxJMf9aE6GjrGzvnQFNISvd8BPkgRvIYqc4/O+FhtS1RZ3eq3W9DylcdRGqpXXl1ICrzFpopCXiulufI5Qn93A+djtQ4qzGaZfPqZr6nqgyFfKHB+9ynCggORnlGR/n63o1+xyCmWvAPcvWe2iI0JMROPdfibt9Wm139bPLG3WhYtbQOxygLtGZK1ebNGhJ/GAcjPpkreLttryN7GY2s3rekfTM6cmyvXDtmhe3SGnqoawi2N+Buxrr2WQF57JmbOAu3faa+tUm3SG7YlGbqDBYWIpXtRX7fINodakVF/nQTIXroDQ2y0bnKs2MgXMReabgXebXfC8s+pLSm4kgutKdclXM+SFOdWQwZNrsxQMRXKPE31YYVptHzeQnXlpBtbaYh1G2fUzK3uII+cH443F8xiPygXth2kxOJ9V9K4DZ40IUnp+cNMPsLQcfJz5mdpux1TP78dmEjGbOl 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)(8121501046)(5005006)(13018025)(13024025)(13015025)(13017025)(13023025)(3002001)(10201501046)(6055026); SRVR:CO2PR03MB2374; BCL:0; PCL:0; RULEID:(400006); SRVR:CO2PR03MB2374; X-Forefront-PRVS: 0109D382B0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2374; 23:+95nUDcvHJDbAM8VmltQ55br8foJa0RWaktAubg8E?= =?us-ascii?Q?r1CquXk0XMPqhsT3jmwTJ5faAEw9xVsegI7edAU/H+QbEPHyyrzIFWD1wTca?= =?us-ascii?Q?gycYp9INGm4FksI1nC/+0TinE1/aFMzY4g9NpRRnwpt5vinupvurJtIeJT9Q?= =?us-ascii?Q?rb5crk1X2hlBXrXbf/VmajI6zbc08X3b2VEJaZi2urOC4uvd7EzdJwuajoFl?= =?us-ascii?Q?+mcaE7a6pEDNcD0Q+3NlMFfU+KVsuSS04HLYjWVkWF5d5a44WCd4CAQQJS/R?= =?us-ascii?Q?II7ne07hkUCLOSzhqwP2PdF/fR+QZVejpzTKfGbn2kPnONRC0rGmVk/vYaVC?= =?us-ascii?Q?N3vstHQkGvhBUuXhalhAeRwBWFCnE+QXWH9B4Gwhlhe9KYsINa0EQ/B8JL7T?= =?us-ascii?Q?t+9rwINTblp+YJIFOjvZLns++aYvb04fwTF+OhgI22gu8pVOvnDHukGKBB2m?= =?us-ascii?Q?8aXhZ622B2zFVVWCZMB8LN7l41/n30Sb418zupkXGBGs/vJJIWGn8XQyvqcK?= =?us-ascii?Q?bQFT91PU6RrxbZddQmJ+yf66oIzKg132be9WSGsRRan5cVcctztbL7MG6npW?= =?us-ascii?Q?+piR/3+cbnzYmxbg/dvjGoI2HBKlGgj9aXavJZzl39dkMQQfjYwmLfmjXPuA?= =?us-ascii?Q?iIin/OFgckaVq8RX3ozPqtHIW7zIZd8mZMGQYo4go98dzq53LhI36NMaYlTL?= =?us-ascii?Q?c/BUHHXkciR7fcgD6OgnfkRpy+IzLyw2UpQ9eTB5T9oXpnrryEjJm2L7dDnj?= =?us-ascii?Q?uBlB7Bxj0eoznyvkzE4fGhnHIVm6CsNgVSPQFOSWG3WxYH9iotIow+U9OhiP?= =?us-ascii?Q?cjtLNV8JjM3Dof9NJpgBnbTkbBSfKeA/j0wRFZvLydSF2nCmz+hKkZhBAQ7F?= =?us-ascii?Q?JZ2jWb/zKFlYmiTupQDOmawBK308X+yXrT8QpYO3dtJihmiyvvl3LnqwmWq5?= =?us-ascii?Q?ClbJ2NCFRT7c/9qEDXgNEkJ80FbI5byMoA0p/7N5UVfw7Eb8qxebKJnTYPwv?= =?us-ascii?Q?cGMw7AmeIGQfSLPJghRQyrbT6782AYXvRmUTq0jO/cxFtRPc87uhLOBts5MJ?= =?us-ascii?Q?S6jH5niMX3ck8yJzdPI9SNANKIHByKXz7jQX2TiWAllFsGl1JPzoLQirsNGx?= =?us-ascii?Q?lKTZvaqw20dEz6e9OnKJVinIvd6bLS1uhIcYJJ+i4+R1wxExabtDYIbSQK0D?= =?us-ascii?Q?yWUnZBN+wQXUhobfhWYB09EV21eKMiEqIKq?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2374; 6:LAtt62/Moh4PMFoZt2wOoNgb3PAyEOSSrTY0FgPnmqsiWF00lj7ub43svy5FU/ONn2I9QvCUFkBEdSsEWKQZXURhxd8rI3I+x91Uma1uOHQaViaAg3mOi/QHBYvLwCOUzP9N9GaCCB4IoWVNg1L8NWGCRX+/MEaKYOPJ1oaU+WPHxG6nIcZAa380bffaUQfTzRUgiZKQem0J8ufsLHeEkB1/9CC9B+pPtom4XS6jwK8PW3lVYdSZCxLoL0OyvO0gvKb7Na3fXM2e0snkXEtPUcAsRvCM76BXwpAecQN227TAPYiIPJ4fWBj6pCkzxgmo; 5:aMqlL+YjDgSTDl8ZqkvlBS0Ko5gs2Z+6J9QiCq8IPIsw92htkbX01z6SIDB9KQP/mlUi82yKRTkMCBBk67MflOu/3k0ezvyzJTviAmMUmPsjSa8hb8i7C2N2MC7+9qAbRM3q+JKVnRrMbrjUCWUK4poSGz7in0EMekFYyoceNNMW95lE5SvGzmowM1kyNm1z; 24:K4c1IuJrGzGQ3r+o9uhVoDa8ozlLuZTnoQcN4o364Tue91cJ+IEN7fQRnOvGFaLz5kF0LooToiN1ivy27yPxdWT1V+c3dkm5ViGoAORXsB4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2374; 7:q0ZMlhzjrGcQxIPjfmagbRvjl5HTOGofmdHuCy9712CjqNsfMvSccjqQ82UJwdUkSqqxV3jDTNAGv36ibAcRgxFHlQZPwbgi4NY3yoVYvC74nYyJ9aptXVM/NIqklug6AOdlzjVJC4JUUpBP+X/Ik+jMX4V9xwfHwaUlyzKEwh72DEbjd07KZVrqHwqeOvro4NHjq76ZeU8sfLjAXV0yVUz3nAetLG8spGxzyJeFL9gN+slRXVfDrqm4AWJc0sxql2Ask6lxCwdAFu6eBG1qiHeTWV3Py2xWcsZHGvCB/7VBbhpCRBvI/xyCGKRojYDyISt913DMzdDuzCobvZcYCzcXrD4iMzRhimUG82yr1Ec= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 12:30:40.2705 (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: CO2PR03MB2374 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v7 06/21] 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: , X-List-Received-Date: Fri, 28 Oct 2016 12:30:43 -0000 From: Jan Viktorin 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 5be023a..30295af 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 c8c2131..0e8d6f7 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). @@ -118,6 +119,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..5c32737 --- /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; + +/** + * Probe function for the driver called during SoC probing. + */ +typedef int (soc_probe_t)(struct rte_soc_driver *, struct rte_soc_device *); + +/** + * Remove function for the driver called during hotplugging. + */ +typedef int (soc_remove_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_probe_t *probe; /**< Device probe */ + soc_remove_t *remove; /**< Device remove */ + 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 -- 2.7.4