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