From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0053.outbound.protection.outlook.com [104.47.42.53]) by dpdk.org (Postfix) with ESMTP id BAA66568A for ; Mon, 24 Oct 2016 13:59:25 +0200 (CEST) Received: from BN6PR03CA0049.namprd03.prod.outlook.com (10.173.137.11) by SN1PR0301MB1629.namprd03.prod.outlook.com (10.162.130.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Mon, 24 Oct 2016 11:59:24 +0000 Received: from BY2FFO11FD022.protection.gbl (2a01:111:f400:7c0c::107) by BN6PR03CA0049.outlook.office365.com (2603:10b6:404:4c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Mon, 24 Oct 2016 11:59:24 +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 BY2FFO11FD022.mail.protection.outlook.com (10.1.15.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.669.7 via Frontend Transport; Mon, 24 Oct 2016 11:59:23 +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 u9OBwEMQ008267; Mon, 24 Oct 2016 04:59:20 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain , Hemant Agrawal Date: Mon, 24 Oct 2016 17:29:25 +0530 Message-ID: <1477310380-17944-7-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> References: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131217839639418489; (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)(68736007)(575784001)(86362001)(50226002)(36756003)(110136003)(33646002)(626004)(5660300001)(104016004)(97736004)(11100500001)(305945005)(2906002)(5003940100001)(189998001)(76176999)(8936002)(586003)(4326007)(81166006)(7846002)(356003)(8666005)(81156014)(8676002)(2351001)(106466001)(47776003)(50986999)(50466002)(87936001)(19580395003)(19580405001)(229853001)(48376002)(85426001)(105606002)(77096005)(2950100002)(6916009)(92566002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1629; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD022; 1:SzAeNDsIpQPbNjTFKEc5SYpbefHTxwC3D6dIJc2VmX+1OkOcaMVwSaZjyfdRrjDj9LyqVpPl2FyCRWeG5KL9c8nCmr4nXSXSBPioiV4xLRmE/3J0HMZswp71gMq/SX5ByYjoRHskI11S9nyUgMDDBepMlXMkPRnLE00WL7TiwjvXH6m9DMQ/LgINFR5VwCmnieWVOeToHNVcYuTFVeLo9L/hWNnXOc6G4vywfhjbgEJPdZ9hnmWJSEA+zrj/2xvq6e/GcDp5uyvJIaK3kdrt2eUeQz1qQuXuNZK1yTLATJZX0oYAnfoL1orfFhL8brUmSFn4AbXVVOwJ3AoxFaN1YG6MHgkrOUYg0fKOW7n7tpdGsaBfTe8llVI9LpPHln1HOPaCNc2L0z0jFYuochuAEKpYtUYUVuWf8On0xAzKz0/nS/PSq7cULhwYTAuqpqRKnA03aMazCMfuzlmOLWcVewR80gaYeuWnq/J8yyhbzPiyY8eQLo7D3pLFGMtdnCwr3XzgAr2Y9bGZhUz+WlNm/48mD+XZI7aZPp+WaraPGYilnQeinxJdDqJCL5RwUJddjZMlicN2n5AbFlniMI3ua0pto4325VRRRxtTOm5d8s7pCchkOne8v1KjVsBE+2sEpzsQXQExh/I3+ZkBT9ITaI1n6IHMy6lDL9Mm51Bye4sVCDpBABpL0zhjqcsYPpbgkqX7xaoiDmtsffZTT/GurxGlHAsX9hW4C5uYJ3q73RA= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f99e8a5d-1988-4f11-6a34-08d3fc053248 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1629; 2:8Ju6YehfBHMZTpGKGgKLWZv6z4aRe51+RDNJ42OboyTRb6V6bgPJ2gQRkDTOEtBii2/5RoHtDyK8DCN29iO6CAzZ+MHeXKfDKDdEUHFo1NpAInMWd3ePv0Ih9nBw9IqX3aow3XWvvfQ7xqjAvj/Qc0BlyK0dMgV9JfMcKcXR8TOF9StIKp5DXhNHqQxJP8GxGhwnJ92uAHm8czM12vBgCw==; 3:QiaTKF2ZGSZRu0Fp8yoZuwsmab9qgLZS0Kr1k+URNoAogNj1OwmXm9hDP3AtCzxJLKxXr/QKbKdPOYSzJy8f/UgSgmfS3gE30UeGL/UANkiNpWWYOrU1f9DlFBJCdiwaUKZUc6jjQkt4NYY63E5EnGrjogqwIl903z7+GsDiLA4689f5ZQyL7BJNY265j8ETKskQ37XnqW01vtFejubp3+gSkf+rXIsv/VvQmqLGqLyryaJmrc3IAYOq2ph8+QS1; 25:RCar+lAGZc2Fpv389yRZ6VFYFPprmDKANYK2/VPOlVKOOyVRuIaep3e9IoFAhob9Hin4a0kMezPXy5xDh2faYR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X3syPAG4jj9xjvszw5rponfJv3STIlk4Ik0kLLG9e/HcXtUxlVCq0xTPzBebVicgPdeFCjZNU45XVg9yQr7C6/v7gKP1VkN7OuP0EOGVh0UthGo3LVRrKSY+dZrni6hvn6wnmlBTtR64miedePUhHUuOlAXNZOZcw8tNH3ldUWOjYnLZLqbMUDznKU/Rr1wD6CuD4hQMF9/Dg5IaPJ5//RmMErZzBV9W47dYeMrwnjvd9UmESzZ9BSrFKLyBNXeFB9l3cE0ArFwHb1yDvRFc2/F/tuh6W5a7SRz 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)(13023025)(13024025)(13017025)(13015025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:SN1PR0301MB1629; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB1629; X-Forefront-PRVS: 0105DAA385 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB1629; 23:Nx/tOt5pr3MFquHPNxi6DY8zHplNlEXZyvCg+FM?= =?us-ascii?Q?/XvmIxXuUQpdKftNJB4UUCmDFCTFYnE3If6i6Lmsm8l57ZV/QsrQlvEO+dc3?= =?us-ascii?Q?GWCXekoNgoVcIRa7pIc6X77qrwwx1EBnsr1t1oM0IHcndc5UmJkFk9KeorPN?= =?us-ascii?Q?KB2KIftyVAB+Hs4mmq0fS4vFXzGj+9lP+eVc7sn4lFrmQkIR0tzIxUqm/bTr?= =?us-ascii?Q?rN+1V1guc/iaye0Kxwj3yPPZ5IKIy6F6NfV3gDigL69IEz8w3BgWBEHooAuA?= =?us-ascii?Q?kQ7zZ7lEZIUpfBb+klxpSB2lvareilXonJkjoRcakhNdL1ZIQXrQh+9cR7sb?= =?us-ascii?Q?iL/utOgwVEX3QX3VO3P74qTig9XOjkj8JUsU6ZgMzvThprgcSN+qvxwJ8JKS?= =?us-ascii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S-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2016 11:59:23.6142 (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: SN1PR0301MB1629 Subject: [dpdk-dev] [PATCH v5 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: Mon, 24 Oct 2016 11:59:26 -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..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