1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * arch/arm64/include/asm/xor.h 4 * 5 * Authors: Jackie Liu <liuyun01@kylinos.cn> 6 * Copyright (C) 2018,Tianjin KYLIN Information Technology Co., Ltd. 7 */ 8 9 #include <linux/hardirq.h> 10 #include <asm-generic/xor.h> 11 #include <asm/hwcap.h> 12 #include <asm/simd.h> 13 14 #ifdef CONFIG_KERNEL_MODE_NEON 15 16 extern struct xor_block_template const xor_block_inner_neon; 17 18 static void 19 xor_neon_2(unsigned long bytes, unsigned long * __restrict p1, 20 const unsigned long * __restrict p2) 21 { 22 scoped_ksimd() 23 xor_block_inner_neon.do_2(bytes, p1, p2); 24 } 25 26 static void 27 xor_neon_3(unsigned long bytes, unsigned long * __restrict p1, 28 const unsigned long * __restrict p2, 29 const unsigned long * __restrict p3) 30 { 31 scoped_ksimd() 32 xor_block_inner_neon.do_3(bytes, p1, p2, p3); 33 } 34 35 static void 36 xor_neon_4(unsigned long bytes, unsigned long * __restrict p1, 37 const unsigned long * __restrict p2, 38 const unsigned long * __restrict p3, 39 const unsigned long * __restrict p4) 40 { 41 scoped_ksimd() 42 xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4); 43 } 44 45 static void 46 xor_neon_5(unsigned long bytes, unsigned long * __restrict p1, 47 const unsigned long * __restrict p2, 48 const unsigned long * __restrict p3, 49 const unsigned long * __restrict p4, 50 const unsigned long * __restrict p5) 51 { 52 scoped_ksimd() 53 xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5); 54 } 55 56 static struct xor_block_template xor_block_arm64 = { 57 .name = "arm64_neon", 58 .do_2 = xor_neon_2, 59 .do_3 = xor_neon_3, 60 .do_4 = xor_neon_4, 61 .do_5 = xor_neon_5 62 }; 63 #undef XOR_TRY_TEMPLATES 64 #define XOR_TRY_TEMPLATES \ 65 do { \ 66 xor_speed(&xor_block_8regs); \ 67 xor_speed(&xor_block_32regs); \ 68 if (cpu_has_neon()) { \ 69 xor_speed(&xor_block_arm64);\ 70 } \ 71 } while (0) 72 73 #endif /* ! CONFIG_KERNEL_MODE_NEON */ 74