162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * include/asm/xor.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * High speed xor_block operation for RAID4/5 utilizing the 662306a36Sopenharmony_ci * UltraSparc Visual Instruction Set and Niagara block-init 762306a36Sopenharmony_ci * twin-load instructions. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz) 1062306a36Sopenharmony_ci * Copyright (C) 2006 David S. Miller <davem@davemloft.net> 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <asm/spitfire.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_civoid xor_vis_2(unsigned long bytes, unsigned long * __restrict p1, 1662306a36Sopenharmony_ci const unsigned long * __restrict p2); 1762306a36Sopenharmony_civoid xor_vis_3(unsigned long bytes, unsigned long * __restrict p1, 1862306a36Sopenharmony_ci const unsigned long * __restrict p2, 1962306a36Sopenharmony_ci const unsigned long * __restrict p3); 2062306a36Sopenharmony_civoid xor_vis_4(unsigned long bytes, unsigned long * __restrict p1, 2162306a36Sopenharmony_ci const unsigned long * __restrict p2, 2262306a36Sopenharmony_ci const unsigned long * __restrict p3, 2362306a36Sopenharmony_ci const unsigned long * __restrict p4); 2462306a36Sopenharmony_civoid xor_vis_5(unsigned long bytes, unsigned long * __restrict p1, 2562306a36Sopenharmony_ci const unsigned long * __restrict p2, 2662306a36Sopenharmony_ci const unsigned long * __restrict p3, 2762306a36Sopenharmony_ci const unsigned long * __restrict p4, 2862306a36Sopenharmony_ci const unsigned long * __restrict p5); 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/* XXX Ugh, write cheetah versions... -DaveM */ 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistatic struct xor_block_template xor_block_VIS = { 3362306a36Sopenharmony_ci .name = "VIS", 3462306a36Sopenharmony_ci .do_2 = xor_vis_2, 3562306a36Sopenharmony_ci .do_3 = xor_vis_3, 3662306a36Sopenharmony_ci .do_4 = xor_vis_4, 3762306a36Sopenharmony_ci .do_5 = xor_vis_5, 3862306a36Sopenharmony_ci}; 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_civoid xor_niagara_2(unsigned long bytes, unsigned long * __restrict p1, 4162306a36Sopenharmony_ci const unsigned long * __restrict p2); 4262306a36Sopenharmony_civoid xor_niagara_3(unsigned long bytes, unsigned long * __restrict p1, 4362306a36Sopenharmony_ci const unsigned long * __restrict p2, 4462306a36Sopenharmony_ci const unsigned long * __restrict p3); 4562306a36Sopenharmony_civoid xor_niagara_4(unsigned long bytes, unsigned long * __restrict p1, 4662306a36Sopenharmony_ci const unsigned long * __restrict p2, 4762306a36Sopenharmony_ci const unsigned long * __restrict p3, 4862306a36Sopenharmony_ci const unsigned long * __restrict p4); 4962306a36Sopenharmony_civoid xor_niagara_5(unsigned long bytes, unsigned long * __restrict p1, 5062306a36Sopenharmony_ci const unsigned long * __restrict p2, 5162306a36Sopenharmony_ci const unsigned long * __restrict p3, 5262306a36Sopenharmony_ci const unsigned long * __restrict p4, 5362306a36Sopenharmony_ci const unsigned long * __restrict p5); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_cistatic struct xor_block_template xor_block_niagara = { 5662306a36Sopenharmony_ci .name = "Niagara", 5762306a36Sopenharmony_ci .do_2 = xor_niagara_2, 5862306a36Sopenharmony_ci .do_3 = xor_niagara_3, 5962306a36Sopenharmony_ci .do_4 = xor_niagara_4, 6062306a36Sopenharmony_ci .do_5 = xor_niagara_5, 6162306a36Sopenharmony_ci}; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#undef XOR_TRY_TEMPLATES 6462306a36Sopenharmony_ci#define XOR_TRY_TEMPLATES \ 6562306a36Sopenharmony_ci do { \ 6662306a36Sopenharmony_ci xor_speed(&xor_block_VIS); \ 6762306a36Sopenharmony_ci xor_speed(&xor_block_niagara); \ 6862306a36Sopenharmony_ci } while (0) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/* For VIS for everything except Niagara. */ 7162306a36Sopenharmony_ci#define XOR_SELECT_TEMPLATE(FASTEST) \ 7262306a36Sopenharmony_ci ((tlb_type == hypervisor && \ 7362306a36Sopenharmony_ci (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \ 7462306a36Sopenharmony_ci sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \ 7562306a36Sopenharmony_ci sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || \ 7662306a36Sopenharmony_ci sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || \ 7762306a36Sopenharmony_ci sun4v_chip_type == SUN4V_CHIP_NIAGARA5)) ? \ 7862306a36Sopenharmony_ci &xor_block_niagara : \ 7962306a36Sopenharmony_ci &xor_block_VIS) 80