From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0070.outbound.protection.outlook.com [104.47.40.70]) by dpdk.org (Postfix) with ESMTP id 332A26CCF for ; Sat, 15 Oct 2016 15:44:28 +0200 (CEST) Received: from BN3PR0301CA0048.namprd03.prod.outlook.com (10.160.152.144) by BL2PR03MB321.namprd03.prod.outlook.com (10.141.68.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.599.9; Sat, 15 Oct 2016 13:44:26 +0000 Received: from BN1AFFO11FD045.protection.gbl (2a01:111:f400:7c10::145) by BN3PR0301CA0048.outlook.office365.com (2a01:111:e400:401e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12 via Frontend Transport; Sat, 15 Oct 2016 13:44:26 +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 BN1AFFO11FD045.mail.protection.outlook.com (10.58.53.60) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Sat, 15 Oct 2016 13:44:24 +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 u9FDhhgI021870; Sat, 15 Oct 2016 06:44:21 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain , Hemant Agrawal Date: Sat, 15 Oct 2016 19:14:53 +0530 Message-ID: <1476539108-13170-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> References: <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131210126653089225; (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)(81166006)(48376002)(81156014)(5660300001)(92566002)(8936002)(2906002)(36756003)(50226002)(68736007)(356003)(8666005)(110136003)(8676002)(6666003)(7846002)(626004)(97736004)(305945005)(586003)(4326007)(85426001)(77096005)(106466001)(47776003)(87936001)(104016004)(11100500001)(2950100002)(575784001)(5003940100001)(6916009)(50986999)(50466002)(229853001)(86362001)(76176999)(105606002)(2351001)(19580395003)(189998001)(19580405001)(33646002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB321; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD045; 1:xPx6+YiH7oKeW89PTAAqIPVeiv9tR42c4r23HM9fEh2zZT65ZMKmQ42h0SaCG4pUBx0yjO8EPpxdUbWsQduw+x75cASthz7jSG0M6Z6CgbdhcRhO/MeyzopxAT9BYClU4/w7iujVGYnb+2a7/Pt/ldzOc5SJnA555/gBuTZa/seLMFSJPpkjXWY5CRy4FXS52epo4jvHRgEa60gTQous5d3w1ftOawj/YyVV5US6lJIxuHbWA4m8Oh1rxsubU/j8F4l6Nz7epn+M9B7l3jJwBDhLK6lZo/qb8UN1YsohGr06zQK/zVoTMFCCoCoZBP5/vvL3pasX7511YEo81rXtjL/7WgJ003MdVyQxh/vP76hd7vojpCC6Ihs8+Y+fzbJUMLanSBzIUXEKE6lo7KKiBIeKq9/f/dwa/uPastxEfE/oyWZha6PsBIMAtFIDUIoZt/z0DPeAou+C9EJF1CIA33xAX30oFWqt+3bJhXSXkAXfxqVw97pCo88QrxCp+e9qFIyNjgQtiAacZYi9PrZ49PvXr7g+howGH3WrPcVjyAseQZ8gt1Td0RfO3tKN2QZ2cG3vEJ3SPkWXc6HcT3wLxWf1ESUupvbzfIl2yWVeuaObytB5zeB0RF49ze4nl9u8gzDVoHqmKju3ubdbgP3xxoXbf3Ay08d+/r0nUfNbohBM5FYPDWrHwJ/njU1NNOsg9OJJ3L2GEtQM/U2wxaKmy0q9B5IPoCRZKXuTtDc+NBU= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5253c036-091e-4c0d-5ad1-08d3f501607b X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB321; 2:4dTLsL4Ep2NTn0vqtQfuY8+Yy6rbKxFixGPPcaie/ReMOF85ocKnW3yXGXrCwuxY70hkE1WAfeGKNf2mSWbAr2m+XUeCFa1sHX3D+FPgjoejkcXYtn1j/7j0Wv9BsxGH6FiqssoUOdBZwDCzLLKJwYZYXJILZC2aVOwBAgkHlmrxR60l+SUnFf6IMVuT0LB3; 3:pmMC30gUypwLSFDw3d6vMtfgOtuxgLMjNea2UQgTwG3gKzw7R6Ec/7Jd+cY1LdZMg0bqHfxt/CnUDpI2u7LhqoT5JZYLJCzW/pBQjHKZYawkTGrI1fNjmxKhQo6g4wVBymnBJCiJ/c2z5T4j9DzVa0GsIR3+wXuNfM24WzG+WfrxdwEJ/btDbW0vG3XFW5sxTkpXYq7JnJJp1xnh4N3jBvG+eHu9eFgHkSKV25V7yz0=; 25:t7pu0XSStcE5UcmY9o48/303E+YFDvLvAleyxEV2X37A8Nyw5QElXcgWLOeBKPPMVFfNm63s6syzlTnRgRuh1CwKglkP+gGSOUw7ygeuILwMTGuo+gPCRiQXTRVYN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VTpwlz0FiTxAtewsYqzzi/Zoe9DCi5cXJJ0hqOC8z4O37XxqH7jO7UcfU6NgzN2KUbwxzqteTZmJtP+UH1BmWkNsFD8obV8+twYsNBkaFcaB/tvD0i1AbsiJj+rXz8h1YSvZeU9tYigDLMKO5ItEBtYfBDz9ttaQhum0gE9K/o= 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)(13023025)(13017025)(13024025)(13018025)(13015025)(5005006)(3002001)(10201501046)(6055026); SRVR:BL2PR03MB321; BCL:0; PCL:0; RULEID:(400006); SRVR:BL2PR03MB321; X-Forefront-PRVS: 00963989E5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB321; 23:4Sx+NRT6819Bpzw8kDA3IGcwqUomd8m9nU4jYQTzl1?= =?us-ascii?Q?nVzBeE+G/pwO10Soon5Jp+UfEOdkM4o0Ab5JLGuho1uxJFWQKbjdhBbl7ewu?= =?us-ascii?Q?kcKxO28HuSOXgektQcZEZPvsXYEbN3Kr4JWktzXhHS+1OT5siUslW5Bw81/q?= =?us-ascii?Q?Vnf85e037O6m0/QORLFKrSouiO/9L7F81N1S2HMUSBtxeQdYu8MIl8hx+mzR?= =?us-ascii?Q?RPrRmF88pPCX8p4oARmI+9A7/pFRQB/DTxLKdxjXwWx6wrI2BxlZaLAybmm7?= =?us-ascii?Q?wQQCgHP5fuSmbRNDweSmZkZcoi8p0GqLjwNBKtb4jwbcuP5kL1uYFJamHrc1?= =?us-ascii?Q?iyRLrWXzMhlpmbv0w0xNej0Mff7UFmIfOB5lY0h1z+13AFmeaMr77GCHsWDB?= =?us-ascii?Q?ApGx7XK5DGtoHc5kCeIH7uEXXEpob36Z5+nNCh7zgn0OqdyB7HMEPxo45pg9?= =?us-ascii?Q?cqNVj0j+nUmmBJb4lCz01IuNNqjxPunsFncnvxuz3OBf7hHK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GUmuM2mDSNK9rB3EgE7svBxIj7nXXjjpOj0DDeUfoM4Z7yJU/XdaCO5PPz9O41aOtN+tkXow4iQ36E+KD8lVCMpl7clJaTdZfDhNsXb361K9hayUgz7bRSDzC/6AL0onD/YfKU2K4TQ6hYD74upbchX2AgGyjYffTbqoGE5AE3aJ1t6/Y=; 5:7ii0oGyz9L0WvsLF+H0i191THtiKI4fbqaWbES9Lr+zaUfdSWPOOrV00BBU3GfDpwdaK3iP8+bfVn0CW9TjBnlwWptnJXv2azCi24uvWrYzmuLh9JGSbyx1FA65Q/HkKoWOontuX33lkLh5h+Cfd33tprS0lBjHj5rS3dcIVTaE=; 24:ptJ99sCt+icv9NLdp/4SvwKw8LFdwC0M7e1+RAcFeZOG8jffwqpIYbdtiWv4A7O6KwVTg27Oitg5WuQ/7JclV566LkSpVC86UD08dyS2U2g=; 7:e3MY6VQ7cNJq6dnCyaV9yDsnbGYgsX+O837wXmN9/gcOhVmT2LkfQdf8hC4Lq823eZeJu5R03QQjFsyIRgbMq61aPVnxar6rXQ6nGRB44EUJDGDVT6Wube6/4N7jkDRF9X+YZVy1Rpeq0MMtdZ2OT7vd9X4I9dDajHzSXx4oa4saZofnBDwT/Ycj2RDk+UjQih7y9uU6kM9dEWlHih2p0GkNpVpL1Ts9e2Spi4J6jP/LL9W1SXa9VJ1FUANXgYw0wPonQeEzprUgs8I78n73qivxcekgwoN0lj1RDUagFUcehDIfeJPqwltTJpqos0vsH43ZOlDyE19hdSCeIcwLoA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2016 13:44:24.4977 (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: BL2PR03MB321 Subject: [dpdk-dev] [PATCH v4 02/17] 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: Sat, 15 Oct 2016 13:44:29 -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