From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0069.outbound.protection.outlook.com [65.55.169.69]) by dpdk.org (Postfix) with ESMTP id 6A76B8DB4 for ; Fri, 6 Nov 2015 10:41:27 +0100 (CET) Received: from BLUPR0701MB1969.namprd07.prod.outlook.com (10.163.121.20) by BLUPR0701MB1587.namprd07.prod.outlook.com (10.163.84.149) with Microsoft SMTP Server (TLS) id 15.1.312.18; Fri, 6 Nov 2015 09:41:26 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@caviumnetworks.com; Received: from jerin.caveonetworks.com (111.93.218.67) by BLUPR0701MB1969.namprd07.prod.outlook.com (10.163.121.20) with Microsoft SMTP Server (TLS) id 15.1.318.15; Fri, 6 Nov 2015 09:41:23 +0000 From: Jerin Jacob To: Date: Fri, 6 Nov 2015 15:10:21 +0530 Message-ID: <1446802833-22265-3-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1446802833-22265-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1446802833-22265-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MA1PR01CA0066.INDPRD01.PROD.OUTLOOK.COM (25.164.116.166) To BLUPR0701MB1969.namprd07.prod.outlook.com (25.163.121.20) X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1969; 2:byisXKZj+JmAX88nvYXVTfKU7aORkfskNFF+iL3OH1LRqZzaVgFzoW+vUUyB8v8ALxkDY7Lm7elaYz9HIg67cU7nHmmQarsHmxH8P9pa/9jiF/Xl4Z6QX8xuc9amkSB+Fiu7JwtOpOrFdLunIJPDh8xEug+02bqMG8DbM6ltIr4=; 3:pybTQ1u4Beq9oI0G+xVUfERZ0iQxIrSBtjTwwh/QDXh+2wgxia0HOlUmT3NezVEpfaw11fzUOLJE5S14hXlKHah7x5EO+w2v+f9TDEX5sdFA+ISES49MhlMCR+I3wEy7SQjHpik2tK12v/kyxvVfNA==; 25:OY8ytNLRncEyM3oDmC54jEPDYx6f02S6SDX3gJAogYNAMpj1Lr2IPZMKDWMMH+1UafXYi5+WxmDJqtlnKuzW5I6aoTXBOdu83fUeBcL7E4UtClUbrincy+rVOIggqM2jifOtXdK6ehx4waYao0LbC4U1ZgRiykYBadrDW64gtaTX4vRE2CN6skIdpe9Lq+8QSi4JL8Q5TeRZt90fSa3QRyEbT2+GCvEV/oBCRJk88XvOW0i0+tNEG/1S+Nb5Vt73/h4e1rx0tGMGjC/lUNz/pQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1969; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1969; 20:zqRm7ogLChpngOBl81x9nu4PMNCTVdbiC5mxTT/oxDmMYqRQf/FZZGF4o+oXtqRLQgFNI8GLg+tNTG138eDcmBcU9vGJSCVu9NJhm7DriztcBdzBcp4uN/B7q00zSggVytxI/dzbzwaKdKxZlFa4vab9gUP/66kPJGULH3N3a8gCLx/8TiIQ7HbYYgR5CavgnW44MEHQFs6Ch9mmIyzrR/dhsr1MNp73OvIh3wWQnLaDBdU2kzIBPC3CmgcrwkmiHpKC90QATYrzcXtdoM6YovUxEVk1Y+1D1as3PSUqLIMo7ral/cRXb2gi8afjztiWt7SVcZIJdiYE274ma8AuxbXCecQecmWYzbM9T2J1On0JVdqoTdi41+vVHAtpWQgBzJMSeKlt77o5fki1mekB9/S70A5uoXEz2Q2T0057dLPVGLZ5LexggrWTr9wGOTzhz/wrqzDdOcuPUtNd6Pi2F5+O7qlZTy764yzkVKSG5l2gCXU/hWWc59Hfoms9pnQ6hqsa82M5ii5u8e53x4HOS+6GxFdFk3mkidV3WU1dDiXmq7GNm01ImxMpOwTVml0GJLP7iE9dnJ4IcxlI1r4YVWUEoCc8ra2X6GY0fdbHYEc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046); SRVR:BLUPR0701MB1969; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1969; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1969; 4:1aZqfOrjLZIOCqs7aHM5WhpnofkViH3L46GmniXGuHegWGbq5u1gb3rn9ArEuVTA4bbBnWPbMCvBKHUgAbNN6zqSh+Z7Q23Ox73+wZ4qwsIPTT5+iY+stYOuDa8oEu5f/1TJY4068u54oAyhOhNQaJZjHxc+P7HbM49e3Aw4DY31lhBssDRVZTej9vj3BPI+23y+8B9LzWowumR16EpDNt0Nu+/Bex4trofmlHkx01/e6t68smJoD2mp+jMz/N1J0rGERfDQaj/+aYxLjaBolp7dYvN4d9RHIILPVRl5vFff7Pg+0VnRydD9SbtopS57pFLyUVNPbPzzvHpxZvVs5EaL44nqP9p7ssWinq6CnCMGpC+VCET+QN26E6sSpH1s X-Forefront-PRVS: 07521929C1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(50226001)(122386002)(48376002)(50986999)(50466002)(106356001)(229853001)(110136002)(19580405001)(40100003)(76176999)(87976001)(105586002)(5004730100002)(77096005)(19580395003)(2351001)(5003940100001)(92566002)(107886002)(189998001)(5007970100001)(33646002)(5001960100002)(66066001)(5009440100003)(42186005)(2950100001)(4001430100002)(97736004)(101416001)(69596002)(47776003)(36756003)(5008740100001)(53416004)(81156007)(86362001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1969; H:jerin.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; BLUPR0701MB1969; 23:8Z8KfQDKmekR76g6C12sMw+MeFav+IAf6531as3?= =?us-ascii?Q?IGltpgCsqVrba14H0e2FO1IYtgHc3o4xTY/pIdhqP+gCQi/Uz2fwqwCTvaN9?= =?us-ascii?Q?73bMX1ivUy3RrHmOLKXvAgDBq9gFKoDvUgNfgJPklhp3ezw67XixtzcUN24G?= =?us-ascii?Q?WC5/O2gJeva4ngrzvaR5y1o0zCrkcaBCBHQ0TggfYWtsPl++D9QmHigRqX40?= =?us-ascii?Q?mhx7IGGtNhw8RQHKhMTNWavdU5ix2S43AAAuw4srP9urS0GQAV5FQZD8194x?= =?us-ascii?Q?e70A+H+yBJaAfwHiPDGHGKFLFZGMjFwCfqiny0qMs1S/ONz3baaAK7Jmo6Uu?= =?us-ascii?Q?wmLdP07B/JwbXsWFr3LbKhB577zd89+TO+aVCI2iHycoNWuV3x5DgShXzGTO?= =?us-ascii?Q?IB87tkU7zPRHoFQCpnNUTEYmxl8lePbri0RcEnplBRhHFXkkiHONJHGSCLwV?= =?us-ascii?Q?3istWy2k4br3ur5Y4WPppIgilwCAVu7TyGp/T49Y48SSxXHhOlVYiLW0lS+s?= =?us-ascii?Q?wHgHPPNbBS+1sYmRgyzG7SbmGp6gxt+gjY2TVvDrdY2CghtuHKFrpWB7mJyM?= =?us-ascii?Q?jUJjWXH0MNKIvK/co4dZN3YQa8xF+8Wixb519ohlSiXOoMc8f4ZDqq7vdZnw?= =?us-ascii?Q?fx+FqBk0YgGTGr3GkbMQReihwGdT14zZuNcKnvut248oBcYqXZ3OfhTxZB3T?= =?us-ascii?Q?jrUrZhsAUKeVZSm2cJGx1zfrZvCxJNdgONtEkYFduPVsLisiWpFytDQfGiFE?= =?us-ascii?Q?U7End/6NK5kBifnESTkbBhW2M9pfT3E5VRchGdpRh0cjdcbBPr1j2HWED6b3?= =?us-ascii?Q?JKKd8v3M95Yn4veTtZkzZS/hJS0uC+X/LcpEc170hzfxz/qSs+xEOXBN4hJU?= =?us-ascii?Q?3r8CQxZ9Jn7lAknRfUIgosSVcbim8F8lFDPoKICe4vimuyUAD2la9VWsuHUQ?= =?us-ascii?Q?Q+SYagmY/bWr52EN7lQ09Nt9B+waEHfQFUF8g+prMdYyzYfqGSly/LgPBu5S?= =?us-ascii?Q?3oM46f0zYtBmhml6DlklK14KRv2cVfi4Hs9tAvsyr0KYQnaKVbs7rSxfCkAP?= =?us-ascii?Q?Q8ie/iGje0VE1ofbYrHULKrMOkWnzDOrdubelcFZtQMeyPlYHFVUmPVV5yhY?= =?us-ascii?Q?wunoi7zXk+ui6Ou9QtNI9LWJyJFp8Pc+U?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1969; 5:i2gbTTaY7fZg4jxNLTw594m2hlvOxMXiql6wxMGWIVO0X5QzN+x7L3pvTVvnFSLMO5sSmBefK79eZdQE7rqMHjXxYxqyZMDeaH8vRcZAbA+meH2+TKQCSyyIxvSahfpmFO84Km7R3ZJZXcRgjeV15A==; 24:KG1nbyonRXJJ2+CA0Dh2QzeWYgkY7FnrB3Gefc97x/+sil8SvuEJqVRpMQgpaK3o1F9pLp874s7XdHdl5QnOQHCFamPXVv4zUjXcZP9jbek=; 20:dQvtl5E6cqmArVUsdvbm53wrngS7iJntitslyZ4N2aTE2gY0Wyfk20m6VLyoLedAQNRIz0Ka68SKiRH5WKkxTg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2015 09:41:23.3034 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1969 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1587; 2:3g21BpWlvDpyrHfGvU68OGzccwbSqpOuxMwH59aZJL5jLIQcTOZzleylJdGvjS2r/tSAus9wccK9r+SBMTmW7X9NOs2sEipMaV8Yg8Fn1yCHouGWN+tvoYtx8gSW7F7FKOM4qD4w593+qNwpIUJyXzjRUkyDQJxupQsTVaYywoA=; 23:Y4PQAJct5N0vspjsrECEojj4/68RQRp3xU/x/I8+HogdHNmDep4O+ye91FHVz9jdc5RLKFHio5G/72GG5EvcOGaluAooU0gEdR69JoocVqdnY85SGEWr9k+BI0r39T/rYeCVNfqYUjE+wQegt2w63Gk8D44t20pc1x3glGj3U+MopujAs5O+4tPs+zn5eB7e X-OriginatorOrg: caviumnetworks.com Subject: [dpdk-dev] [PATCH v3 02/14] 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: Fri, 06 Nov 2015 09:41:27 -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_ */ -- 1.9.3