1 /* 2 * arch/arm64/include/asm/xor.h 3 * 4 * Authors: Jackie Liu <liuyun01@kylinos.cn> 5 * Copyright (C) 2018,Tianjin KYLIN Information Technology Co., Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 */ 11 12 #include <linux/hardirq.h> 13 #include <asm-generic/xor.h> 14 #include <asm/hwcap.h> 15 #include <asm/neon.h> 16 17 #ifdef CONFIG_KERNEL_MODE_NEON 18 19 extern struct xor_block_template const xor_block_inner_neon; 20 21 static void 22 xor_neon_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) 23 { 24 kernel_neon_begin(); 25 xor_block_inner_neon.do_2(bytes, p1, p2); 26 kernel_neon_end(); 27 } 28 29 static void 30 xor_neon_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, 31 unsigned long *p3) 32 { 33 kernel_neon_begin(); 34 xor_block_inner_neon.do_3(bytes, p1, p2, p3); 35 kernel_neon_end(); 36 } 37 38 static void 39 xor_neon_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, 40 unsigned long *p3, unsigned long *p4) 41 { 42 kernel_neon_begin(); 43 xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4); 44 kernel_neon_end(); 45 } 46 47 static void 48 xor_neon_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, 49 unsigned long *p3, unsigned long *p4, unsigned long *p5) 50 { 51 kernel_neon_begin(); 52 xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5); 53 kernel_neon_end(); 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