xref: /openbmc/linux/arch/arm64/include/asm/xor.h (revision a44e4f3a)
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/neon.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 *p1, unsigned long *p2)
20 {
21 	kernel_neon_begin();
22 	xor_block_inner_neon.do_2(bytes, p1, p2);
23 	kernel_neon_end();
24 }
25 
26 static void
27 xor_neon_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
28 		unsigned long *p3)
29 {
30 	kernel_neon_begin();
31 	xor_block_inner_neon.do_3(bytes, p1, p2, p3);
32 	kernel_neon_end();
33 }
34 
35 static void
36 xor_neon_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
37 		unsigned long *p3, unsigned long *p4)
38 {
39 	kernel_neon_begin();
40 	xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4);
41 	kernel_neon_end();
42 }
43 
44 static void
45 xor_neon_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
46 		unsigned long *p3, unsigned long *p4, unsigned long *p5)
47 {
48 	kernel_neon_begin();
49 	xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5);
50 	kernel_neon_end();
51 }
52 
53 static struct xor_block_template xor_block_arm64 = {
54 	.name   = "arm64_neon",
55 	.do_2   = xor_neon_2,
56 	.do_3   = xor_neon_3,
57 	.do_4   = xor_neon_4,
58 	.do_5	= xor_neon_5
59 };
60 #undef XOR_TRY_TEMPLATES
61 #define XOR_TRY_TEMPLATES           \
62 	do {        \
63 		xor_speed(&xor_block_8regs);    \
64 		xor_speed(&xor_block_32regs);    \
65 		if (cpu_has_neon()) { \
66 			xor_speed(&xor_block_arm64);\
67 		} \
68 	} while (0)
69 
70 #endif /* ! CONFIG_KERNEL_MODE_NEON */
71