From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0087.outbound.protection.outlook.com [104.47.34.87]) by dpdk.org (Postfix) with ESMTP id 760C65599 for ; Fri, 9 Sep 2016 10:44:44 +0200 (CEST) Received: from BN6PR03CA0047.namprd03.prod.outlook.com (10.175.124.33) by CY1PR0301MB2009.namprd03.prod.outlook.com (10.164.2.15) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Fri, 9 Sep 2016 08:44:43 +0000 Received: from BN1AFFO11OLC001.protection.gbl (2a01:111:f400:7c10::177) by BN6PR03CA0047.outlook.office365.com (2603:10b6:404:10c::33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9 via Frontend Transport; Fri, 9 Sep 2016 08:44:42 +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 BN1AFFO11OLC001.mail.protection.outlook.com (10.58.53.72) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Fri, 9 Sep 2016 08:44:42 +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 u898hoYt018305; Fri, 9 Sep 2016 01:44:40 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Fri, 9 Sep 2016 14:13:45 +0530 Message-ID: <1473410639-10367-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131178842826599363; (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)(1109001)(1110001)(339900001)(199003)(189002)(2950100001)(5660300001)(97736004)(33646002)(110136002)(77096005)(86362001)(626004)(50466002)(19580395003)(48376002)(229853001)(305945005)(8666005)(575784001)(5003940100001)(189998001)(7846002)(105606002)(2351001)(586003)(356003)(104016004)(47776003)(87936001)(8676002)(11100500001)(19580405001)(81156014)(50226002)(106466001)(85426001)(76176999)(8936002)(50986999)(68736007)(2906002)(36756003)(81166006)(92566002)(4326007)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB2009; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11OLC001; 1:K8wLH8m5mQuA52USRmUkPc5dKqfcQ10hPVaEnrqCiMul6HVDuqxU3vv/b4Vtm35UbNw6YzABn/wliiyAqNG9YINuvHGpOvbwJvJrDJrEYbJOsikWo37OvLZsdIbxDaYzBEUW8nGV1iir52RX1IJeoHejenh2J9Ha/Vaup7fBouqGAWtzguiFEq1LyVdKgucFJ5z6+dEk5Y3fcMplY8mDABTdThEaUxBkoHWE+6zDMB5NF/aXVu/QZnmwColYZkgN8Lor2yepx+y+wW7BJ90q4ksqV0lgOgk5HlW+ljVCUj8WgrHF2k/JBFTKREgmcdH2Ge/8KGAXefEaWvrqeIHFWO1f21IxT4inwPYtmIwXXI659VZK0q83bpUgqt3ClLopYjENrBBCKadekTPn0lOzZfgjP882UM0C7XI8CXMEDzOsQFZqGwEgbmYAtL2vpcglfnhF2tXG2EOjavRyFoKcC/iihrFQzEm7QB4M7fXnNsyo1fydjMcEjdtcSEmkYsi2+/FPVhxtlDB+mO57i4KZkpyUbiRhVdJO/axbHbnqMXGjuEztPVo4RPVVRqRfI7vwfiqRkVI5rrEq40eAJ9pVl5C5zu0sJRyD9+TEz8xf2u8DnKK9ltx9I//9r/59KlEgrxMKf3/MFiVRKgWyJYNPv9/0fch5pBL+SaEcnohdKNNIpQnSIAKQwTrgydJxiYLXlchndUuMrK5QaFcCa/lS6ExCo+msrkIlIJ8tIOLsT3Y= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6f83878b-e529-4aa3-8a66-08d3d88d8b2e X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2009; 2:wxYbIpEgqH4XQfzudmF4SBz9nChuu/F6+yt3H0g/5NR8ptzbSqH32NeP9X5uegC7VIz72Yb3H5g8XdLdwqd7YXUTG22LA7+6qixf4nGaAHTuoaInyUKt3Bqq/AezMpYPnKAS4N273MspZxPMBAc9Xro5aPsqgRGEJbQaj7PRBybxxLgzkTzE+eEOgafc40YZ; 3:sIa/Djc3jj0xrqznKu5PpQEuFUTuhjXvID6gZMMyb+uXVc7W75lpQTDWMssK1fXjjYXzhVhE3HiryD1dVFOJ7CKdT6R3d5ckI0/zMSqmD6tIsbiiYcvelVOlDd5YJhNBnAdiXZFXGnyy7Di9nHUwaxvkTDz9f61n32TwZ9DB+sSbFEXq1U/LvrIhGy3m84QNF/pOyEsvtP5csxVykGVrOHY2082Idpg5MahYKna7fjI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB2009; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2009; 25:uFHOh5fsVLUV9ijj+GyckwVScjrdPC4nycH0VJodwB1F82saGbboDJLg1+NJz65dvd0ujZ9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qZLiCwRHhECnq4YHwr9wN5yWup2aZJQmcvRtjvvPLskhsC+QvSPLwDLnX5P/zlx9TBcGKH5d9tR4Bk15tm9xQGe1xa5Jl+iVSqPQGMfB6DYPmAZCgaxUm2YCrRlKuqEntG9gmDj4JQOFSb+M/Exm2ClA2z2G0lUkRQ7tP8yurLmhHh21XOReN+LUGbWfDMi1k+xl+PDO/xavAIj38+Qi3KjVMG4RLusD2tNzGNTsVUp9C6wt3iZToeDhSLdpK4Dl2kWc2opOt6J3tJBJKwpp3iMohq/Jwrzb7KuqQAdhTPe78dPn6VaAtASJbYOSEKbtWu4hdxILP0euighuhfFYKD226WEbK3KUwufBKc7xv5mNbWPd3GCymdajr/o7tyPrr823J6ghJmuinn646mlnKOxU7YJPn2G1SrFP9BemGbfj8o3TzYk2D2c= 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)(13017025)(13015025)(13024025)(13023025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB2009; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB2009; X-Forefront-PRVS: 00603B7EEF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB2009; 23:JS4veJoMIvDIwpDmEEdNOZtq+gg9x9nMRqzLovg?= =?us-ascii?Q?AcUKIs/NwVZ0vtq6gs0aeKgwXTtB9nZLLpkmadZ5mo7rGOeqaPxy8MaLUnJZ?= =?us-ascii?Q?DxzmIFuu7iT2jnT+bZFTOkG7xetxHcPHqv1m4PeerNeKlfO4eYlnSj9uNz+4?= =?us-ascii?Q?CH5Tdjeipa7oKzFHXq563unVNrQeUksVQ6Na0YkT/7jypwc3Apc9AYXvu7uy?= =?us-ascii?Q?QVciF0s+YuAQDj+TLhQ+3VYoAoywzWdDm6cBEUap3Q96P49glkRoWN0K1sUK?= =?us-ascii?Q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r3tF?= =?us-ascii?Q?dfdWJ4a6ozCtsUTEh23wHvBamVzpBrly1L9Fl?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2009; 6:dporrLBMU8CP4dv4VM2vbTrezrwgKy0ePYkzqc53e+e/KDsmghw5oMUrQOqVUnayoUKiNJTHM99zlr8vyekcrVEs4NlCXv43TIe1NQi0yvPKExPW0BjgOJKC4KSn5nz23ADUCcn/O+VDwD6murQyTCqiYhCNerm73BuDOnV9xlWT4BbupM0Ra00PDJdWeaAjRnHB6PfkR9z43/A2vb3Dm9XbOLlgC/cxM7VOPLOIiM9HqcXYop1kt+Nh4qWLOP4fr4StTH6SF/yY8aaYwZsjjPQA65w2ZKqwQwK2RwRza9k=; 5:Q09z8NMgEsu1VPfkrdPhmnTXPKNzUN3ckUy/JfabyEKWfeJk/L/PWnhuk5wBuEmRUuojwcwYmnlFTzzeGA/EBwB4GGNh3PjYNFV7+ofBDR2EmhmHuqTpF182lRHwsfH8rS1ry0wU9HVVoDABDzGadaSR9Mdu2Ek8Oecjtlz/T5w=; 24:76dMrgwPeM/8Zyg7i9hsoL+8mjdTaLuSC3mFt+vS44nlCAGofaOFog8GJQJubE4nojJKz38OQMIuCQMr2QrjCwPzRvclNr7F3wXdNaNfiKw=; 7:io25C3scNT1/b8VVP9kT3VT/av2BNvSpD9HRBbSxaBYYRGhWmLI/S4dDMrMesb+9epBf3gJ76nbPrCs6hk1s4fS5HSHB47LpH7EVng0w7bKy8EYtYiAjH8D23Y8iIugCPxiDsnfY/leZKrwKzONQm21LAEm0RLvsO8r4goaIRZITFTWWTLrl2Gll4mCv7HW2DhxPfQzHvctEqPT6I6VIUbr2+a0Hh/DUIUQ1iM/WCgjAOXZ5qNGejt0ocdMrJXsr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2016 08:44:42.4571 (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: CY1PR0301MB2009 Subject: [dpdk-dev] [PATCH v3 01/15] 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, 09 Sep 2016 08:44:45 -0000 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 -- 2.7.4