xref: /openbmc/linux/arch/sparc/include/asm/xor_64.h (revision ae213c44)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * include/asm/xor.h
4  *
5  * High speed xor_block operation for RAID4/5 utilizing the
6  * UltraSparc Visual Instruction Set and Niagara block-init
7  * twin-load instructions.
8  *
9  * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz)
10  * Copyright (C) 2006 David S. Miller <davem@davemloft.net>
11  */
12 
13 #include <asm/spitfire.h>
14 
15 void xor_vis_2(unsigned long, unsigned long *, unsigned long *);
16 void xor_vis_3(unsigned long, unsigned long *, unsigned long *,
17 	       unsigned long *);
18 void xor_vis_4(unsigned long, unsigned long *, unsigned long *,
19 	       unsigned long *, unsigned long *);
20 void xor_vis_5(unsigned long, unsigned long *, unsigned long *,
21 	       unsigned long *, unsigned long *, unsigned long *);
22 
23 /* XXX Ugh, write cheetah versions... -DaveM */
24 
25 static struct xor_block_template xor_block_VIS = {
26         .name	= "VIS",
27         .do_2	= xor_vis_2,
28         .do_3	= xor_vis_3,
29         .do_4	= xor_vis_4,
30         .do_5	= xor_vis_5,
31 };
32 
33 void xor_niagara_2(unsigned long, unsigned long *, unsigned long *);
34 void xor_niagara_3(unsigned long, unsigned long *, unsigned long *,
35 		   unsigned long *);
36 void xor_niagara_4(unsigned long, unsigned long *, unsigned long *,
37 		   unsigned long *, unsigned long *);
38 void xor_niagara_5(unsigned long, unsigned long *, unsigned long *,
39 		   unsigned long *, unsigned long *, unsigned long *);
40 
41 static struct xor_block_template xor_block_niagara = {
42         .name	= "Niagara",
43         .do_2	= xor_niagara_2,
44         .do_3	= xor_niagara_3,
45         .do_4	= xor_niagara_4,
46         .do_5	= xor_niagara_5,
47 };
48 
49 #undef XOR_TRY_TEMPLATES
50 #define XOR_TRY_TEMPLATES				\
51 	do {						\
52 		xor_speed(&xor_block_VIS);		\
53 		xor_speed(&xor_block_niagara);		\
54 	} while (0)
55 
56 /* For VIS for everything except Niagara.  */
57 #define XOR_SELECT_TEMPLATE(FASTEST) \
58 	((tlb_type == hypervisor && \
59 	  (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \
60 	   sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \
61 	   sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || \
62 	   sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || \
63 	   sun4v_chip_type == SUN4V_CHIP_NIAGARA5)) ? \
64 	 &xor_block_niagara : \
65 	 &xor_block_VIS)
66