Loading...
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
15void xor_vis_2(unsigned long bytes, unsigned long * __restrict p1,
16 const unsigned long * __restrict p2);
17void xor_vis_3(unsigned long bytes, unsigned long * __restrict p1,
18 const unsigned long * __restrict p2,
19 const unsigned long * __restrict p3);
20void xor_vis_4(unsigned long bytes, unsigned long * __restrict p1,
21 const unsigned long * __restrict p2,
22 const unsigned long * __restrict p3,
23 const unsigned long * __restrict p4);
24void xor_vis_5(unsigned long bytes, unsigned long * __restrict p1,
25 const unsigned long * __restrict p2,
26 const unsigned long * __restrict p3,
27 const unsigned long * __restrict p4,
28 const unsigned long * __restrict p5);
29
30/* XXX Ugh, write cheetah versions... -DaveM */
31
32static struct xor_block_template xor_block_VIS = {
33 .name = "VIS",
34 .do_2 = xor_vis_2,
35 .do_3 = xor_vis_3,
36 .do_4 = xor_vis_4,
37 .do_5 = xor_vis_5,
38};
39
40void xor_niagara_2(unsigned long bytes, unsigned long * __restrict p1,
41 const unsigned long * __restrict p2);
42void xor_niagara_3(unsigned long bytes, unsigned long * __restrict p1,
43 const unsigned long * __restrict p2,
44 const unsigned long * __restrict p3);
45void xor_niagara_4(unsigned long bytes, unsigned long * __restrict p1,
46 const unsigned long * __restrict p2,
47 const unsigned long * __restrict p3,
48 const unsigned long * __restrict p4);
49void xor_niagara_5(unsigned long bytes, unsigned long * __restrict p1,
50 const unsigned long * __restrict p2,
51 const unsigned long * __restrict p3,
52 const unsigned long * __restrict p4,
53 const unsigned long * __restrict p5);
54
55static struct xor_block_template xor_block_niagara = {
56 .name = "Niagara",
57 .do_2 = xor_niagara_2,
58 .do_3 = xor_niagara_3,
59 .do_4 = xor_niagara_4,
60 .do_5 = xor_niagara_5,
61};
62
63#undef XOR_TRY_TEMPLATES
64#define XOR_TRY_TEMPLATES \
65 do { \
66 xor_speed(&xor_block_VIS); \
67 xor_speed(&xor_block_niagara); \
68 } while (0)
69
70/* For VIS for everything except Niagara. */
71#define XOR_SELECT_TEMPLATE(FASTEST) \
72 ((tlb_type == hypervisor && \
73 (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \
74 sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \
75 sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || \
76 sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || \
77 sun4v_chip_type == SUN4V_CHIP_NIAGARA5)) ? \
78 &xor_block_niagara : \
79 &xor_block_VIS)
1/*
2 * include/asm/xor.h
3 *
4 * High speed xor_block operation for RAID4/5 utilizing the
5 * UltraSparc Visual Instruction Set and Niagara block-init
6 * twin-load instructions.
7 *
8 * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz)
9 * Copyright (C) 2006 David S. Miller <davem@davemloft.net>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * You should have received a copy of the GNU General Public License
17 * (for example /usr/src/linux/COPYING); if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <asm/spitfire.h>
22
23void xor_vis_2(unsigned long, unsigned long *, unsigned long *);
24void xor_vis_3(unsigned long, unsigned long *, unsigned long *,
25 unsigned long *);
26void xor_vis_4(unsigned long, unsigned long *, unsigned long *,
27 unsigned long *, unsigned long *);
28void xor_vis_5(unsigned long, unsigned long *, unsigned long *,
29 unsigned long *, unsigned long *, unsigned long *);
30
31/* XXX Ugh, write cheetah versions... -DaveM */
32
33static struct xor_block_template xor_block_VIS = {
34 .name = "VIS",
35 .do_2 = xor_vis_2,
36 .do_3 = xor_vis_3,
37 .do_4 = xor_vis_4,
38 .do_5 = xor_vis_5,
39};
40
41void xor_niagara_2(unsigned long, unsigned long *, unsigned long *);
42void xor_niagara_3(unsigned long, unsigned long *, unsigned long *,
43 unsigned long *);
44void xor_niagara_4(unsigned long, unsigned long *, unsigned long *,
45 unsigned long *, unsigned long *);
46void xor_niagara_5(unsigned long, unsigned long *, unsigned long *,
47 unsigned long *, unsigned long *, unsigned long *);
48
49static struct xor_block_template xor_block_niagara = {
50 .name = "Niagara",
51 .do_2 = xor_niagara_2,
52 .do_3 = xor_niagara_3,
53 .do_4 = xor_niagara_4,
54 .do_5 = xor_niagara_5,
55};
56
57#undef XOR_TRY_TEMPLATES
58#define XOR_TRY_TEMPLATES \
59 do { \
60 xor_speed(&xor_block_VIS); \
61 xor_speed(&xor_block_niagara); \
62 } while (0)
63
64/* For VIS for everything except Niagara. */
65#define XOR_SELECT_TEMPLATE(FASTEST) \
66 ((tlb_type == hypervisor && \
67 (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \
68 sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \
69 sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || \
70 sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || \
71 sun4v_chip_type == SUN4V_CHIP_NIAGARA5)) ? \
72 &xor_block_niagara : \
73 &xor_block_VIS)