From patchwork Thu May 18 10:21:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Sekhar T K X-Patchwork-Id: 24390 X-Patchwork-Delegate: thomas@monjalon.net 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 049963258; Thu, 18 May 2017 12:23:32 +0200 (CEST) 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 9EC093258 for ; Thu, 18 May 2017 12:23:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8XRpq4YsFdbBmcjhI88B8EIwNWu+pUSUxBAOV+vg12U=; b=XfmBOk71615bcDy6TvkKkT962B6OxwKsRpzzPTwDZ9uPxssqzxSXqSVmKWsxVgxqJjdjAhiGYo1iZFVKFtrgkThTgZHhr47Z3r58rKbZ/QrUopcOFZ81x903GUvlgr7YXupWfuGW+JTJellLLAPsKHkztoKgqp+XXyRjY30wRS0= Authentication-Results: caviumnetworks.com; dkim=none (message not signed) header.d=none;caviumnetworks.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from 1scrb-1.caveonetworks.com (50.233.148.156) by BL2PR07MB2420.namprd07.prod.outlook.com (10.167.101.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Thu, 18 May 2017 10:23:25 +0000 From: Ashwin Sekhar T K To: jerin.jacob@caviumnetworks.com, john.mcnamara@intel.com, jianbo.liu@linaro.org Cc: dev@dpdk.org, Ashwin Sekhar T K Date: Thu, 18 May 2017 03:21:51 -0700 Message-Id: <20170518102151.35504-3-ashwin.sekhar@caviumnetworks.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170518102151.35504-1-ashwin.sekhar@caviumnetworks.com> References: <20170517181949.12002-1-ashwin.sekhar@caviumnetworks.com> <20170518102151.35504-1-ashwin.sekhar@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: BN6PR08CA0065.namprd08.prod.outlook.com (10.172.144.27) To BL2PR07MB2420.namprd07.prod.outlook.com (10.167.101.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93f713f6-eee2-4e0b-34f4-08d49dd7eb93 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:BL2PR07MB2420; X-Microsoft-Exchange-Diagnostics: 1; BL2PR07MB2420; 3:jTfXYnSg8IoC0VbIgRSdFSjT0euE0/xKjrBhU6d0/xNn8gmCgKXwJg7Tn5GSzVW3V4OrdiT9rOzGZiCQHEgozMWQvcDVxmvtmuVSK/izmj1GmhoCpwyTvi8/ltPxrWhCFQs2US3Rtbhu93T5QxeKDVK7UzSjzb088bcSH2bxueaBlobEY+vIfWY4eGt5HmrqbUS2I+RPvnINnNwSE7Iw/N2mB8K0Qf4CJLFaktHJq+ExLz9EHy67G3YXg2JEC2jRh9o50dPzBz8rQV6owbUZPa5GOPf/bldVSiIOREhMUt3csiu22sgvnxZVBdZqatU6dNU6RyBNszoDa2phvBJSnw==; 25:poV8IhKnoPRb4kQXwPZabkIY+2xq6pOItt+bhKGvR0JoLz4cwd94dGM0GwI5gjIzJ92cMVQN20gvhk7KNgelfhF43zqy8/BOyHfxnskq30G4L0kT+5LdJyrNTpsy9L/0q7JCBtyigMkfzhZzFqhHlYrESUCUpI9WXcr5yw7YF/TotRgyNegjn49a/s/gIBdrqJ6F8uOiKSYhds78/CCYLocYXc3OWhtGZ8o3+lA99gMWHQuQ2+PPpSvAvY19mPMCCydeJ096zU8RpH9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kW182VcDEWQBqZBUHXOFCN/t0Ytso/+kdWg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(166708455590820)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123560025)(20161123558100)(20161123555025)(6072148); SRVR:BL2PR07MB2420; BCL:0; PCL:0; RULEID:; SRVR:BL2PR07MB2420; X-Microsoft-Exchange-Diagnostics: 1; BL2PR07MB2420; 4:nLdURfMLEILWz/uag8yNriBqsmWfmLgu4YsKyfhBkd7dP3d0BJFmq0DbpI5crXLcx/zKRgYhq7IjceZPKZQlBPVufl9CAgUUlf6LTB+YYl/DRSgR6Mt0E/X9VGKDc5b/OWueCC2KU4B+mrg58r6LxI3s1/cUNbUSzHbmLQA1MtaPjBFMjaeSTY8BIN9na5Y4wJze2Bjvuz3rMJfyUfQ/K5j2t9KsmWl4SsC6543axYhfmXiX8tSPdHNWTimrFVG5zNo7j0uh05uh+q/OHErrrojX7gtvWr7fj1lL0NKcAX6/4FwpMABfEX63Gtxv5lXO/0XInhypmCMQskZiTexWVk/nUd6n8yeUS6JH5L/R45r4Wp1OO72GLZ6jvKLWeCOAwQjiTjxgPRp6eKr/X01FU9Y/vJT9WWol5mOYd31oO9VKxpPqi00sPgGS5JBybwxB/MvNB7Uh+8vvt3NVUWfDMr5XQMoLiUeCPXkZq6r8CqJTZ7KVkNmVmiwlSos7HYJzP7pCCZifl+jkqa7EtZJ8BgEsRstaIQ1UsGE1JouMk3ZnxrD7V7CbklxuOJa6ToDcfFkvhjfUrgvNkYaQy545Aw2LGuYHMySCKWJByz2iojSaTkbaJyPPbxe5IHwVeM9KYp4H11y2JTTjgi28b6I/ysvCf6Ipr1lt+qTWDPmHtB1lk8VvLy4mvaE+SMXoanc4Vt3XrghyMswmyiKp4WjGp0rl+Y0HGv12RwdoMLQp6a0LeHD5gsCuSikdjamTxAhpGJO+73rZNJpNUNOQzC4opSHsywDhp66FgV/w010yHgjz1Qa8pZtt3U+Ova0lUmrMNfaHRkR4IYy4zI8NeNebrA== X-Forefront-PRVS: 0311124FA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39400400002)(39410400002)(39450400003)(39850400002)(81166006)(5660300001)(25786009)(110136004)(6116002)(4326008)(7736002)(66066001)(53416004)(966005)(189998001)(50986999)(76176999)(8676002)(3846002)(50226002)(72206003)(33646002)(53936002)(6306002)(36756003)(6512007)(38730400002)(107886003)(478600001)(42186005)(6666003)(48376002)(1076002)(5003940100001)(6486002)(2950100002)(6506006)(50466002)(42882006); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR07MB2420; H:1scrb-1.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR07MB2420; 23:zvtc4FGdZ+lIwp1mZqhyM9SbnYkw1pUyyhrKYoZSg?= yy1rfMAqJRjFRYKOiYwwcuoi3WD+qUVPFCvI9jDrAkRorWgRNtRlD4tbDqK+ajrtpUNMYj7OazG4weTr6WKkolkvGw+pbjZuXURutOCg77Do6FaqgAGiaMgI4A1yikBxnicFM7tRChpwEubUs/gXlfXDdqW7XlA+mhjAxXefiKb/S2POp71fwWQICnlLV03V66yoWFISbDHkJhPUwFeHJEOPUa6J4PtHXgu77pM+UsA276Kvj5T9jvjcBFFWEilCPDtAdqKh7TbKRMliH7W/XmgIwxEqvOEZuosHfSchtsx9Ib+pTJ4qDpExeLxkjtx3iLVLFQHzcjhZHU91TLyyQnBILAiiX9+HBqaPhjKTjWen9U7AuijbVVQJL3OWSerV0lGEEL1zvKvGgtwTD5fcOiPCMHXt5acqBUxhXZsix/3bTB8+QXasRsfGF5uWBVaPsqkoiLtxvdPkqKmyfG8+Xa4Ir0EPpOsJE5tVUX+8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u3A1GD6jRlnTPg+AnDq4R77AWAUT9+78mN5NSouS1GFJw==; 5:leAo8nKw7wa+sdaSAhsTWMymotRrNuxVdUcMi3sj6rMatiXIGl2kf9OEZtQNs+wk5VxWyirb6gChzaljgaEuiSl7sTcdx5gKAKb536dgyDcdVNzS29vRaeo9drahm9p2k8aqQspcq6yJoDRPlboveQ==; 24:u19cqLUw6VeB9SHr7MFzEtEBUqoe8NPMLI4G1W6kmnrxPDn1eNE50mb3JQ9744Q/nUrPodcXV3ZcU+4JDORKEJ/fnG171G0feQKkrADcBPY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR07MB2420; 7:dlqrJ926Xi7R19JnRmQBbhGQFpyfqbIO+5GoIqpq8LfyQ37GxfEvFEnTrrdJeq/aweeMbJMQS3daL9v/SGCPZSBiwxUGE6XqoqEXGLAkqq1mRf7it9Skfne71v7pM7ON2I8NEwfdCN/rldcjrY9WOfPqN0xiTS7Mzevnx1WOl4Vx6WcV3VvBhO/N6T0dqz40SE5buQ2cDrn80rY5vTcAU0tsvd16vRaFhvnSevSsxgrv3ysyg4VfR/xvWw6R0eC7IU9XOO2Z1FNxrmgoeDwOG8JBFLobSEkeIidstm85XdDCWRb6dkKloSvm0NNHnPDqDB7gQihz7ssd2cO/CSqLSw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2017 10:23:25.6640 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR07MB2420 Subject: [dpdk-dev] [PATCH v3 2/2] examples/performance-thread: add arm64 support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Updated Makefile to allow compilation for arm64 architecture. Added necessary arm64 support for lthread. Fixed minor compilation errors for arm64 compilation. Tested the apps l3fwd-thread and lthread_pthread_shim on thunderx and x86_64. Signed-off-by: Ashwin Sekhar T K --- examples/performance-thread/Makefile | 4 +- .../performance-thread/common/arch/arm64/ctx.c | 117 +++++++++++++++++++++ .../performance-thread/common/arch/arm64/ctx.h | 110 +++++++++++++++++++ .../performance-thread/common/arch/arm64/stack.h | 111 +++++++++++++++++++ examples/performance-thread/common/common.mk | 2 + examples/performance-thread/l3fwd-thread/main.c | 2 +- 6 files changed, 343 insertions(+), 3 deletions(-) create mode 100644 examples/performance-thread/common/arch/arm64/ctx.c create mode 100644 examples/performance-thread/common/arch/arm64/ctx.h create mode 100644 examples/performance-thread/common/arch/arm64/stack.h diff --git a/examples/performance-thread/Makefile b/examples/performance-thread/Makefile index d19f8489e..0c5edfdb9 100644 --- a/examples/performance-thread/Makefile +++ b/examples/performance-thread/Makefile @@ -38,8 +38,8 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc include $(RTE_SDK)/mk/rte.vars.mk -ifneq ($(CONFIG_RTE_ARCH),"x86_64") -$(error This application is only supported for x86_64 targets) +ifeq ($(filter y,$(CONFIG_RTE_ARCH_X86_64) $(CONFIG_RTE_ARCH_ARM64)),) +$(error This application is only supported for x86_64 and arm64 targets) endif DIRS-y += l3fwd-thread diff --git a/examples/performance-thread/common/arch/arm64/ctx.c b/examples/performance-thread/common/arch/arm64/ctx.c new file mode 100644 index 000000000..95ce16095 --- /dev/null +++ b/examples/performance-thread/common/arch/arm64/ctx.c @@ -0,0 +1,117 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2017. + * + * 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 Cavium networks 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. + */ + +/* + * https://github.com/halayli/lthread which carries the following license. + * + * Copyright (C) 2012, Hasan Alayli + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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 + +void +ctx_switch(struct ctx *new_ctx __rte_unused, struct ctx *curr_ctx __rte_unused) +{ + /* SAVE CURRENT CONTEXT */ + asm volatile ( + /* Save SP */ + "mov x3, sp\n" + "str x3, [x1, #0]\n" + + /* Save FP and LR */ + "stp x29, x30, [x1, #8]\n" + + /* Save Callee Saved Regs x19 - x28 */ + "stp x19, x20, [x1, #24]\n" + "stp x21, x22, [x1, #40]\n" + "stp x23, x24, [x1, #56]\n" + "stp x25, x26, [x1, #72]\n" + "stp x27, x28, [x1, #88]\n" + + /* + * Save bottom 64-bits of Callee Saved + * SIMD Regs v8 - v15 + */ + "stp d8, d9, [x1, #104]\n" + "stp d10, d11, [x1, #120]\n" + "stp d12, d13, [x1, #136]\n" + "stp d14, d15, [x1, #152]\n" + ); + + /* RESTORE NEW CONTEXT */ + asm volatile ( + /* Restore SP */ + "ldr x3, [x0, #0]\n" + "mov sp, x3\n" + + /* Restore FP and LR */ + "ldp x29, x30, [x0, #8]\n" + + /* Restore Callee Saved Regs x19 - x28 */ + "ldp x19, x20, [x0, #24]\n" + "ldp x21, x22, [x0, #40]\n" + "ldp x23, x24, [x0, #56]\n" + "ldp x25, x26, [x0, #72]\n" + "ldp x27, x28, [x0, #88]\n" + + /* + * Restore bottom 64-bits of Callee Saved + * SIMD Regs v8 - v15 + */ + "ldp d8, d9, [x0, #104]\n" + "ldp d10, d11, [x0, #120]\n" + "ldp d12, d13, [x0, #136]\n" + "ldp d14, d15, [x0, #152]\n" + ); +} diff --git a/examples/performance-thread/common/arch/arm64/ctx.h b/examples/performance-thread/common/arch/arm64/ctx.h new file mode 100644 index 000000000..2905990b2 --- /dev/null +++ b/examples/performance-thread/common/arch/arm64/ctx.h @@ -0,0 +1,110 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2017. + * + * 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 Cavium networks 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. + */ + +/* + * https://github.com/halayli/lthread which carries the following license. + * + * Copyright (C) 2012, Hasan Alayli + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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 CTX_H +#define CTX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * CPU context registers + */ +struct ctx { + void *sp; /* 0 */ + void *fp; /* 8 */ + void *lr; /* 16 */ + + /* Callee Saved Generic Registers */ + void *r19; /* 24 */ + void *r20; /* 32 */ + void *r21; /* 40 */ + void *r22; /* 48 */ + void *r23; /* 56 */ + void *r24; /* 64 */ + void *r25; /* 72 */ + void *r26; /* 80 */ + void *r27; /* 88 */ + void *r28; /* 96 */ + + /* + * Callee Saved SIMD Registers. Only the bottom 64-bits + * of these registers needs to be saved. + */ + void *v8; /* 104 */ + void *v9; /* 112 */ + void *v10; /* 120 */ + void *v11; /* 128 */ + void *v12; /* 136 */ + void *v13; /* 144 */ + void *v14; /* 152 */ + void *v15; /* 160 */ +}; + + +void +ctx_switch(struct ctx *new_ctx, struct ctx *curr_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_CTX_H_ */ diff --git a/examples/performance-thread/common/arch/arm64/stack.h b/examples/performance-thread/common/arch/arm64/stack.h new file mode 100644 index 000000000..1e7c6444c --- /dev/null +++ b/examples/performance-thread/common/arch/arm64/stack.h @@ -0,0 +1,111 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2017. + * + * 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 Cavium networks 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. + */ + +/* + * https://github.com/halayli/lthread which carries the following license. + * + * Copyright (C) 2012, Hasan Alayli + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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 STACK_H +#define STACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "lthread_int.h" + +/* + * Sets up the initial stack for the lthread. + */ +static inline void +arch_set_stack(struct lthread *lt, void *func) +{ + void **stack_top = (void *)((char *)(lt->stack) + lt->stack_size); + + /* + * Align stack_top to 16 bytes. Arm64 has the constraint that the + * stack pointer must always be quad-word aligned. + */ + stack_top = (void **)(((unsigned long)(stack_top)) & ~0xfUL); + + /* + * First Stack Frame + */ + stack_top[0] = NULL; + stack_top[-1] = NULL; + + /* + * Initialize the context + */ + lt->ctx.fp = &stack_top[-1]; + lt->ctx.sp = &stack_top[-2]; + + /* + * Here only the address of _lthread_exec is saved as the link + * register value. The argument to _lthread_exec i.e the address of + * the lthread struct is not saved. This is because the first + * argument to ctx_switch is the address of the new context, + * which also happens to be the address of required lthread struct. + * So while returning from ctx_switch into _thread_exec, parameter + * register x0 will always contain the required value. + */ + lt->ctx.lr = func; +} + +#ifdef __cplusplus +} +#endif + +#endif /* STACK_H_ */ diff --git a/examples/performance-thread/common/common.mk b/examples/performance-thread/common/common.mk index 532dbf61d..f1f05fdde 100644 --- a/examples/performance-thread/common/common.mk +++ b/examples/performance-thread/common/common.mk @@ -39,6 +39,8 @@ MKFILE_PATH=$(abspath $(dir $(lastword $(MAKEFILE_LIST)))) ifeq ($(CONFIG_RTE_ARCH_X86_64),y) ARCH_PATH += $(MKFILE_PATH)/arch/x86 +else ifeq ($(CONFIG_RTE_ARCH_ARM64),y) +ARCH_PATH += $(MKFILE_PATH)/arch/arm64 endif VPATH := $(MKFILE_PATH) $(ARCH_PATH) diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 2d98473eb..3d9739e91 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -225,7 +225,7 @@ static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; static uint64_t dest_eth_addr[RTE_MAX_ETHPORTS]; static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; -static __m128i val_eth[RTE_MAX_ETHPORTS]; +static xmm_t val_eth[RTE_MAX_ETHPORTS]; /* replace first 12B of the ethernet header. */ #define MASK_ETH 0x3f