1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or https://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de> 24 */ 25 26 /* 27 * USER API: 28 * 29 * Kernel fpu methods: 30 * kfpu_allowed() 31 * kfpu_begin() 32 * kfpu_end() 33 * kfpu_init() 34 * kfpu_fini() 35 * 36 * SIMD support: 37 * 38 * Following functions should be called to determine whether CPU feature 39 * is supported. All functions are usable in kernel and user space. 40 * If a SIMD algorithm is using more than one instruction set 41 * all relevant feature test functions should be called. 42 * 43 * Supported features: 44 * zfs_neon_available() 45 * zfs_sha256_available() 46 */ 47 48 #ifndef _LINUX_SIMD_ARM_H 49 #define _LINUX_SIMD_ARM_H 50 51 #include <sys/types.h> 52 #include <asm/neon.h> 53 #include <asm/elf.h> 54 #include <asm/hwcap.h> 55 56 #define kfpu_allowed() 1 57 #define kfpu_begin() kernel_neon_begin() 58 #define kfpu_end() kernel_neon_end() 59 #define kfpu_init() (0) 60 #define kfpu_fini() do {} while (0) 61 62 /* 63 * Check if NEON is available 64 */ 65 static inline boolean_t 66 zfs_neon_available(void) 67 { 68 return (elf_hwcap & HWCAP_NEON); 69 } 70 71 /* 72 * Check if SHA256 is available 73 */ 74 static inline boolean_t 75 zfs_sha256_available(void) 76 { 77 return (elf_hwcap2 & HWCAP2_SHA2); 78 } 79 80 #endif /* _LINUX_SIMD_ARM_H */ 81