From patchwork Thu May 18 07:34:26 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: 24382 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 A6CA7324B; Thu, 18 May 2017 09:34:46 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0050.outbound.protection.outlook.com [104.47.36.50]) by dpdk.org (Postfix) with ESMTP id CCE763247 for ; Thu, 18 May 2017 09:34:42 +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=UwZXDwOF1eVIfENFuWmIN/5UXecdrrT/8uUOCn+65vI=; b=ZK5+sCzbvglD6kut6pldvszyjMNeVEDSdHkfZs9ho8noTHzthJ+DsQh2fnrtILSsHzb5LdLRvPkPfRcrNeAsMxSLRZdqLE3MD5kR4I9M00zrVLPSEHZGz01g7H+gj434V213qbWp/2SIUXvyCoGhIZ9Lx68OujKTv1GnLVhEeiM= 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 SN1PR07MB2429.namprd07.prod.outlook.com (10.169.127.141) 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 07:34:41 +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 00:34:26 -0700 Message-Id: <20170518073426.14920-3-ashwin.sekhar@caviumnetworks.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170518073426.14920-1-ashwin.sekhar@caviumnetworks.com> References: <20170517181949.12002-1-ashwin.sekhar@caviumnetworks.com> <20170518073426.14920-1-ashwin.sekhar@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: MWHPR15CA0064.namprd15.prod.outlook.com (10.174.254.26) To SN1PR07MB2429.namprd07.prod.outlook.com (10.169.127.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0a6f6f0-b81e-4868-49d6-08d49dc058ce X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:SN1PR07MB2429; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2429; 3:jVx/3K12WzLj6f29rtGU3wZjpJaC6FXzVVB2bOp/GvX+WtvLp+AvRIBfDn4DXX1URoChtPt1dqBP0gNazbxSBjA1VuuuXkaRw1gs85JqWl4C/wDIfRnL+QJn7Us7Ielc0wN3mDYqI21rrMOljg/D2prLdTyYuVK2PJLSodV933klcMFVx7mRs6L8Z5Rrpd42mz+leNLgAwhBaaPWsnM4cpqIUtqHbDgqW93IqhDwErnPXBcLXqeywvL6oMWsDsD9c3P2q9rp58f3SLLV/8BjleMW8CXeApkMxOSEuWizH/ZITQK/AKzk6e3JKNBaUM75nyaDgNbmLLkf7j0g5LRaSw==; 25:6JHTl6v+6o0WZyijOuch2bPYF/u/sqVSnd7dR4FGR7WrFQRvEtgkFXn/DLAjnNDD6ePxrbIXkqVbBxIcr4c9mPXPojqeYvp6uuISDBrde4zJ23KTw/sx9H7w6JdYrIyJj/NfBEZhNbshw6l57kpFhavoSnxGE7rSGLJT+YhiKX5mZ81lHrqFeycdu1yXod7MmRqkNnAlwMnpdhw3iXmOV6u903lVXHmBsz6EfVl2035S1Mff6SU0gyt/sEy5Yjwlufx5U432RLKALXvsGEeCqpZgYh4lhy/uPRGo1lJ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nZtmbf5MUJnlf5kU= 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)(10201501046)(93006095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(20161123555025)(20161123562025)(20161123564025)(6072148); SRVR:SN1PR07MB2429; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2429; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2429; 4:YkllnwUa75E66mowfxCSUBFbcBAde7+uwnOxsR47Q+sM5ysKrZkKtKyfP7bsuNMMc63xGPDRjS6VrSRA6YNq2LpEp4klTUty5IOnHD8zvRcEZu5/vRNGX9nWnU+DXSSV8asHyaWRuFC9uAOd100oz3HT9OVaVBMUjLVlrwod2EudkstctOkH/YGvVEzRbiBjUhSTKTMBRUFnqtlGIbajEDWSVwZ2xjHkq943mJXdd9QEUzA+udJFrOeoheNTfH3TNQTsxU6gFv1zPqvBLrGsW275DrLRWdwKG8OoEEqDv4QUACLLKSQ5IUOVelOUFsKIbDIsfa9mbFJxUd7G1pzygyn9umvQbKGAEu2Ia+1Ae/2zRjim/l1FSPiQHWL8lNkh3BScOrffWgkDiED1K1hrzOCGMIKuICFiUwCqR8tDAHqMAhYa9GC9buRmn3QZU0bnqoE9hDjuL58cY+V6p45vqpy2VuHYkzWGIvTpejzhyy3EKBeUrSTL6/zDhS9jFyrziqokm/hlqypHWn7qp/OHQGKje05CyyorWgj+KWkGYPfT0NClAZas9WGUW+kOxSwrrSKvNpys/ycn7eKiYKzjunXA442ap04J2L1UvIm792AxCzMc/mcnNMBgti3jXdPhSugSYvhU0TbVKHUx5tNqANFD4bPsRLW7doau/W12aAXHszxqu/EQfvJw1HY2Ei/n7WSC5MafPjTREJlMcNRShMZFPXv2Oy47o8tBeZ3nW2X0FQAa/EjB1Ifq0zB21gUuJGOJZ4g3UBxIYSOdW/2PietI8RjOJVqQbgaTmCyUbI6yBmAD2aGdnrgArSn4iBm/HCwjRzmxr2EvSMA85Y1xSg== X-Forefront-PRVS: 0311124FA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39850400002)(39450400003)(39840400002)(39400400002)(39410400002)(53936002)(72206003)(33646002)(966005)(6306002)(53416004)(42186005)(6486002)(5660300001)(305945005)(7736002)(50226002)(4326008)(5003940100001)(189998001)(478600001)(1076002)(6666003)(81166006)(36756003)(8676002)(66066001)(38730400002)(110136004)(2906002)(48376002)(6512007)(47776003)(42882006)(6506006)(2950100002)(3846002)(25786009)(6116002)(50986999)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2429; H:1scrb-1.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2429; 23:P+ktxx0LbVYN/IrSPmdRlQuNuayt4GocpA7SSOvz7?= JaDIjbteemjEUjj3YHFI0iifeZXgOc1ca1FigEvZYA6YtpBsJudM+LWyLU7Aic9CpwutjfEyMCC2r9TkydprYqe0W1hHOV+x6cOEHCnR6j1tEPv0r0lqA4vbmZa2AIcQFU5v3W0PnB0/sNTvUzSIH6zHaIcJv45caGq/o9OrQOSRQj4U9NMPkvLk36Lp4Tg0iIawjY/yxG9dHiolCqWBoJs+ETAMGbBSno9YksK9VyzmZjazo6TyldLalkLkKcD2QURGXK9OYe4Xlpc9mlEjlj/2a4qQ4sLNGZVIjxtWo0+6MgkFpaax2Nz6FxASh6Vfa0OEN0Ah9CpbyVeLCW8PgM0xL5pkdQM9i+YvqN3BJc/cWLx3uzIGyzwuYjpy75FNbZrvVJV82vHhpz8PRsfsIczpQBetjZwJmk7ra9Q9AiM4PYum+60W++XtMLb2r16eb46ah1t+dE0nb9W7z6Nl6c3VZzW2v8v+egUgyCRBwe0ARCEoGfIZ83In0xTcI4Xfu6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pYLA==; 5:WKzAZtlLegSBrqO6HS50BATFKVbk9HiB7Yv6wemflJi6wAmYCwZlUCPQDQTpyxrA1guVkuk/rwK14VDAsCQOEzgPWvhjvfiVrm6e5GocyXia2oiye/yLoas+ABWJVO/lV2iGcdl+SMPJZFY/0bJH2A==; 24:Vm5MEH+SbVhWcKqMYSim3wZApAqb+eMsORYj0Mi34cPg+63anC0nfJUo9RR+uKgc4yzh/PFCTkYFCtl4MCFgQrWZeYwWvLTdgfOwAs5BZSk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2429; 7:+Pey3U5Cngh+VeFBrTuldO6aDVLuwr2O0ZTcqA9XNOOmgTJ3z/1qRD2BCYDYq3fn4EEiK/70yCD/Ox1GsjpqjmgkhBdwA+oIApcydT490t5wa0NaTqzI7325/bCdFE7sstnwuDJbL2m9pV3kGcBPJ4mesVh+LuNxpKafaVNmA6qvwgjfVXx+DTuHjEb2lN+szEGIDwbqh8SFuWiXD28gCaa2DL+IA5IYeFjjlcFjtDsJzrRqqXSCliNpv1J2262gsKxMxGCEWjzsKX+3Zamna/i4FCDPxZsX6FMvb+BMq0U7P3zRoAcCBihxETYrepjrkc6Qf9Iotd2SRPlBTRUXDg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2017 07:34:41.0404 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2429 Subject: [dpdk-dev] [PATCH v2 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 | 99 ++++++++++++++++++ .../performance-thread/common/arch/arm64/ctx.h | 95 ++++++++++++++++++ .../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, 310 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..7073cfd75 --- /dev/null +++ b/examples/performance-thread/common/arch/arm64/ctx.c @@ -0,0 +1,99 @@ +/* + * 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" + ); + + /* 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" + ); +} 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..27a124d1b --- /dev/null +++ b/examples/performance-thread/common/arch/arm64/ctx.h @@ -0,0 +1,95 @@ +/* + * 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 */ + 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 */ +}; + + +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