18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * LoongArch SIMD XOR operations 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2023 WANG Xuerui <git@xen0n.name> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/export.h> 98c2ecf20Sopenharmony_ci#include <linux/sched.h> 108c2ecf20Sopenharmony_ci#include <asm/fpu.h> 118c2ecf20Sopenharmony_ci#include <asm/xor_simd.h> 128c2ecf20Sopenharmony_ci#include "xor_simd.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define MAKE_XOR_GLUE_2(flavor) \ 158c2ecf20Sopenharmony_civoid xor_##flavor##_2(unsigned long bytes, unsigned long *p1, \ 168c2ecf20Sopenharmony_ci unsigned long *p2) \ 178c2ecf20Sopenharmony_ci{ \ 188c2ecf20Sopenharmony_ci kernel_fpu_begin(); \ 198c2ecf20Sopenharmony_ci __xor_##flavor##_2(bytes, p1, p2); \ 208c2ecf20Sopenharmony_ci kernel_fpu_end(); \ 218c2ecf20Sopenharmony_ci} \ 228c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(xor_##flavor##_2) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define MAKE_XOR_GLUE_3(flavor) \ 258c2ecf20Sopenharmony_civoid xor_##flavor##_3(unsigned long bytes, unsigned long *p1, \ 268c2ecf20Sopenharmony_ci unsigned long *p2, unsigned long *p3) \ 278c2ecf20Sopenharmony_ci{ \ 288c2ecf20Sopenharmony_ci kernel_fpu_begin(); \ 298c2ecf20Sopenharmony_ci __xor_##flavor##_3(bytes, p1, p2, p3); \ 308c2ecf20Sopenharmony_ci kernel_fpu_end(); \ 318c2ecf20Sopenharmony_ci} \ 328c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(xor_##flavor##_3) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define MAKE_XOR_GLUE_4(flavor) \ 358c2ecf20Sopenharmony_civoid xor_##flavor##_4(unsigned long bytes, unsigned long *p1, \ 368c2ecf20Sopenharmony_ci unsigned long *p2, unsigned long *p3, \ 378c2ecf20Sopenharmony_ci unsigned long *p4) \ 388c2ecf20Sopenharmony_ci{ \ 398c2ecf20Sopenharmony_ci kernel_fpu_begin(); \ 408c2ecf20Sopenharmony_ci __xor_##flavor##_4(bytes, p1, p2, p3, p4); \ 418c2ecf20Sopenharmony_ci kernel_fpu_end(); \ 428c2ecf20Sopenharmony_ci} \ 438c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(xor_##flavor##_4) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define MAKE_XOR_GLUE_5(flavor) \ 468c2ecf20Sopenharmony_civoid xor_##flavor##_5(unsigned long bytes, unsigned long *p1, \ 478c2ecf20Sopenharmony_ci unsigned long *p2, unsigned long *p3, \ 488c2ecf20Sopenharmony_ci unsigned long *p4, unsigned long *p5) \ 498c2ecf20Sopenharmony_ci{ \ 508c2ecf20Sopenharmony_ci kernel_fpu_begin(); \ 518c2ecf20Sopenharmony_ci __xor_##flavor##_5(bytes, p1, p2, p3, p4, p5); \ 528c2ecf20Sopenharmony_ci kernel_fpu_end(); \ 538c2ecf20Sopenharmony_ci} \ 548c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(xor_##flavor##_5) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define MAKE_XOR_GLUES(flavor) \ 578c2ecf20Sopenharmony_ci MAKE_XOR_GLUE_2(flavor); \ 588c2ecf20Sopenharmony_ci MAKE_XOR_GLUE_3(flavor); \ 598c2ecf20Sopenharmony_ci MAKE_XOR_GLUE_4(flavor); \ 608c2ecf20Sopenharmony_ci MAKE_XOR_GLUE_5(flavor) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_LSX 638c2ecf20Sopenharmony_ciMAKE_XOR_GLUES(lsx); 648c2ecf20Sopenharmony_ci#endif 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_LASX 678c2ecf20Sopenharmony_ciMAKE_XOR_GLUES(lasx); 688c2ecf20Sopenharmony_ci#endif 69