From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0056.outbound.protection.outlook.com [65.55.169.56]) by dpdk.org (Postfix) with ESMTP id ACFBB91DC for ; Tue, 3 Nov 2015 14:10:07 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@caviumnetworks.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BY2PR0701MB1974.namprd07.prod.outlook.com (10.163.155.20) with Microsoft SMTP Server (TLS) id 15.1.312.18; Tue, 3 Nov 2015 13:10:04 +0000 From: Jerin Jacob To: Date: Tue, 3 Nov 2015 18:39:03 +0530 Message-ID: <1446556153-18845-3-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446556153-18845-2-git-send-email-jerin.jacob@caviumnetworks.com> References: <1446556153-18845-1-git-send-email-jerin.jacob@caviumnetworks.com> <1446556153-18845-2-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0048.INDPRD01.PROD.OUTLOOK.COM (25.164.146.148) To BY2PR0701MB1974.namprd07.prod.outlook.com (25.163.155.20) X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1974; 2:dodegObU/W6hz+jK4v8TB7X0gVG44uLACW0EheG4Ip1mJNUlDeOX1NmvW8i2bVs0/zA5653MiGzKk9/Td8fm60S21XpZWplI0oM/MPp6mIK3PZyKBsjXdn/V011FwtpZZBGAD2VQWOvwLzsEBbrNqDOPLZWZjT0lVbDwhwSH4LA=; 3:pJdVTwN80sZJwj8MFoRBjcIJeQgFQiUz0PfjJLm3O2LYdl6UaIwJb/zB3ViI69Op+O8YKGtZ1yPUHg83LUV7MIM+vnR2W3wWqmEO8XBMBie5H9wUF3xMjwSzoG34y26OcQNEDn9yldb8zgEF0KrE7A==; 25:z74f297Jekzq2gXum88JpEe3eN3xfvnKCnEdK/vA3dW/4h3ZXzSZJ1p1c7+Tlk5w+/srrq3d1qNexqqGidjZFH0AL8imk79XuoU1d33kaQKuo/TfnwOddVhq30HCB3nA5fNXKxlXQuZ2WiakuuXlLyLHW6ZhrLOWDn2w43zUYjyaENvHDudx3vdyQCmGmZc0mt0u2rJ03kXSlA0rywDTrnKtOpbEReInmf6iL0fjN4/2OipFW0VE7L3CKRR33rQDPuXx1kpCigRNDKd5dmP8Ww== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0701MB1974; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1974; 20:RhnNn6STclbxSwgYAHC5khCmEmuQBfsDBgTgiIbJ5nllPzb7HakDKUCjJonblWfNBW1bU5phx243aq4UqxZDaNyeLTP+HahKdX2bHFvRAtP36JIliFjBHhTiCI8fI+fdV8qzOxIvhG4JJoNaiNQ8ylJzOQXjsgPkrYSFGHBL+fBI2q9wnFPotOa40YYtqAbF+Zvm7GhJcTdQgU9by/TcSWbxXFkHuyMzZQtnQXKOSdel9MHB95YB4FOOEqqO+5UsXih6NLFcWpqCWhqkQ0iopZ9OhwakicrT+bML/k/fpB+FOfGfOk4fJEOx5yZRFmsQFbrH3kbknSpEIuoDiyuIvZ3PnoQ5HD4U25D/hojHd/ErIObCRMkxX00n9qO/lRmqIFozW3MSsNndnnpue6WOMvkMgUd305eKYRvoL3i4VzJHleZPa8qZ3YOYBOqNNpN012hGysYXh0TbPWOW1S7oBq3ABCcFQQyCfPBS7mS0ujGbJeLAMje7myhoEabP5+Lt0h6F6BcnGPBZngvlSn0xXeFTetOTIRUjBD241YN76i/kh2RgGq4X/1FOOiry3rPOzBQvNmkF96qrgH68+nULcZQX3mDtLdcgdY7W6CGImEg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001); SRVR:BY2PR0701MB1974; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0701MB1974; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1974; 4:4O7r0CAeBgwxxauF422iIlJB2Ur0m76pcTONz7XTKg2EIEEV+TTZQYb2qbkXqwYcDlwRRsziY7kKKdF3QfJKnTDagc8YIYte8h2mB4WNA5ZoJkqEMGLb8RnmYyXueDsaxkrQmoJgYd7g8sIMqxeleKfMUSVnNVIh5CAr9WpEl8WTL3P7QGp4rXtAt9n05IIraghHLHyGra+hTI69O6Yxv2A6TdVOSn9BhGUCik1OhnCRqoRlHcS6gv4GdtT2E2jUT7+UST9iU2p3/8f/A34gSQbma/ez+906InGSOybxypie/BoE2iw1wZXAtRCQjpB9mehJEqse+oMcGcftSbFzfU0Q7qAWGZGdZ8AnJk+lgum3rpu565j7bfeScSVuePOz X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(81156007)(5001960100002)(50226001)(50986999)(5004730100002)(2950100001)(110136002)(77096005)(107886002)(66066001)(47776003)(189998001)(5007970100001)(42186005)(19580395003)(86362001)(76506005)(87976001)(69596002)(97736004)(50466002)(101416001)(53416004)(48376002)(106356001)(105586002)(19580405001)(36756003)(5008740100001)(76176999)(40100003)(92566002)(4001430100002)(5009440100003)(33646002)(122386002)(5003940100001)(229853001)(2351001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0701MB1974; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0701MB1974; 23:jsyGvKh7BlOs/NYRMOWECUm1RQBRVVy161swTGU?= =?us-ascii?Q?rrb5Wks6QS3fXVlj77Y5si9uTdgB06rYBWTrxvM6reiMduGdMqDTJ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I+723DA7JrsQ6e0e2EMLR7Ho6CmdNpmHAmJw9gqV3nKC3+X?= =?us-ascii?Q?ni/NK9YIJQO1yo3y3b+4m61lVB+Z9ucG3Mh7neF0Z7s2rocLt9ALr6tFefgE?= =?us-ascii?Q?EyIvILkkQHT1ngwt2wTgW3DSmvkss94ayj+WKGt7eOgV7/3EBAAsJo+uv4oR?= =?us-ascii?Q?tsb7nBwyRqeN6dEWe8e+4tJXoMS7McKtVzU/cVeAnB9Uk4N0HR9e0bUe82pQ?= =?us-ascii?Q?tYT/ZwyYriurskrg=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1974; 5:KxuKsVedxu4JKQDmP5sfZvwUARsaPov9oTA+QhUVofJwqWQjUgkQ/NHYH9N7PR0fcKBc0VD3GShfVPwzwLU7xHqYkuT+pB+iuCET5undAo/AeYyG46o7Or1mKpWPWLJolJ/iLiK3hkgjhWVYp1c3sA==; 24:LwGFtS/nuXbz83zpmFsEL1KgmmFO4brPYvnZQUnT0U62wfoHCh+GgQauuC0rxh1PsXp9wXfiDRXbDUARcigjA5VraO0SiaOX20G2bEgS7hA=; 20:ZIyDstXJhff9O9PTPCqhMAGXZxlx1KrVL3+ryI7P1PajCTQHHmeTMeoyaEfh9H+cgarSoT/tloYUqpPZYS9/ew== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2015 13:10:04.7359 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0701MB1974 Subject: [dpdk-dev] [PATCH 02/12] eal: arm64: add armv8-a version of rte_cpuflags_64.h 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: Tue, 03 Nov 2015 13:10:08 -0000 Signed-off-by: Jerin Jacob --- .../common/include/arch/arm/rte_cpuflags.h | 4 + .../common/include/arch/arm/rte_cpuflags_64.h | 152 +++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 lib/librte_eal/common/include/arch/arm/rte_cpuflags_64.h diff --git a/lib/librte_eal/common/include/arch/arm/rte_cpuflags.h b/lib/librte_eal/common/include/arch/arm/rte_cpuflags.h index 8de78d2..b8f6288 100644 --- a/lib/librte_eal/common/include/arch/arm/rte_cpuflags.h +++ b/lib/librte_eal/common/include/arch/arm/rte_cpuflags.h @@ -33,6 +33,10 @@ #ifndef _RTE_CPUFLAGS_ARM_H_ #define _RTE_CPUFLAGS_ARM_H_ +#ifdef RTE_ARCH_64 +#include +#else #include +#endif #endif /* _RTE_CPUFLAGS_ARM_H_ */ diff --git a/lib/librte_eal/common/include/arch/arm/rte_cpuflags_64.h b/lib/librte_eal/common/include/arch/arm/rte_cpuflags_64.h new file mode 100644 index 0000000..7bcc12f --- /dev/null +++ b/lib/librte_eal/common/include/arch/arm/rte_cpuflags_64.h @@ -0,0 +1,152 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2015. + * + * 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. + */ + +#ifndef _RTE_CPUFLAGS_ARM64_H_ +#define _RTE_CPUFLAGS_ARM64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#include "generic/rte_cpuflags.h" + +#ifndef AT_HWCAP +#define AT_HWCAP 16 +#endif + +#ifndef AT_HWCAP2 +#define AT_HWCAP2 26 +#endif + +#ifndef AT_PLATFORM +#define AT_PLATFORM 15 +#endif + +/* software based registers */ +enum cpu_register_t { + REG_HWCAP = 0, + REG_HWCAP2, + REG_PLATFORM, +}; + +/** + * Enumeration of all CPU features supported + */ +enum rte_cpu_flag_t { + RTE_CPUFLAG_FP = 0, + RTE_CPUFLAG_NEON, + RTE_CPUFLAG_EVTSTRM, + RTE_CPUFLAG_AES, + RTE_CPUFLAG_PMULL, + RTE_CPUFLAG_SHA1, + RTE_CPUFLAG_SHA2, + RTE_CPUFLAG_CRC32, + RTE_CPUFLAG_AARCH64, + /* The last item */ + RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ +}; + +static const struct feature_entry cpu_feature_table[] = { + FEAT_DEF(FP, 0x00000001, 0, REG_HWCAP, 0) + FEAT_DEF(NEON, 0x00000001, 0, REG_HWCAP, 1) + FEAT_DEF(EVTSTRM, 0x00000001, 0, REG_HWCAP, 2) + FEAT_DEF(AES, 0x00000001, 0, REG_HWCAP, 3) + FEAT_DEF(PMULL, 0x00000001, 0, REG_HWCAP, 4) + FEAT_DEF(SHA1, 0x00000001, 0, REG_HWCAP, 5) + FEAT_DEF(SHA2, 0x00000001, 0, REG_HWCAP, 6) + FEAT_DEF(CRC32, 0x00000001, 0, REG_HWCAP, 7) + FEAT_DEF(AARCH64, 0x00000001, 0, REG_PLATFORM, 1) +}; + +/* + * Read AUXV software register and get cpu features for ARM + */ +static inline void +rte_cpu_get_features(__attribute__((unused)) uint32_t leaf, + __attribute__((unused)) uint32_t subleaf, + cpuid_registers_t out) +{ + int auxv_fd; + Elf64_auxv_t auxv; + + auxv_fd = open("/proc/self/auxv", O_RDONLY); + assert(auxv_fd); + while (read(auxv_fd, &auxv, + sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t)) { + if (auxv.a_type == AT_HWCAP) { + out[REG_HWCAP] = auxv.a_un.a_val; + } else if (auxv.a_type == AT_HWCAP2) { + out[REG_HWCAP2] = auxv.a_un.a_val; + } else if (auxv.a_type == AT_PLATFORM) { + if (!strcmp((const char *)auxv.a_un.a_val, "aarch64")) + out[REG_PLATFORM] = 0x0001; + } + } +} + +/* + * Checks if a particular flag is available on current machine. + */ +static inline int +rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) +{ + const struct feature_entry *feat; + cpuid_registers_t regs = {0}; + + if (feature >= RTE_CPUFLAG_NUMFLAGS) + /* Flag does not match anything in the feature tables */ + return -ENOENT; + + feat = &cpu_feature_table[feature]; + + if (!feat->leaf) + /* This entry in the table wasn't filled out! */ + return -EFAULT; + + /* get the cpuid leaf containing the desired feature */ + rte_cpu_get_features(feat->leaf, feat->subleaf, regs); + + /* check if the feature is enabled */ + return (regs[feat->reg] >> feat->bit) & 1; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_CPUFLAGS_ARM64_H_ */ -- 2.1.0