xor.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include <linux/hardirq.h>
  9. #include <asm-generic/xor.h>
  10. #include <asm/hwcap.h>
  11. #include <asm/simd.h>
  12. #ifdef CONFIG_KERNEL_MODE_NEON
  13. extern struct xor_block_template const xor_block_inner_neon;
  14. static void
  15. xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
  16. const unsigned long * __restrict p2)
  17. {
  18. scoped_ksimd()
  19. xor_block_inner_neon.do_2(bytes, p1, p2);
  20. }
  21. static void
  22. xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
  23. const unsigned long * __restrict p2,
  24. const unsigned long * __restrict p3)
  25. {
  26. scoped_ksimd()
  27. xor_block_inner_neon.do_3(bytes, p1, p2, p3);
  28. }
  29. static void
  30. xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
  31. const unsigned long * __restrict p2,
  32. const unsigned long * __restrict p3,
  33. const unsigned long * __restrict p4)
  34. {
  35. scoped_ksimd()
  36. xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4);
  37. }
  38. static void
  39. xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
  40. const unsigned long * __restrict p2,
  41. const unsigned long * __restrict p3,
  42. const unsigned long * __restrict p4,
  43. const unsigned long * __restrict p5)
  44. {
  45. scoped_ksimd()
  46. xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5);
  47. }
  48. static struct xor_block_template xor_block_arm64 = {
  49. .name = "arm64_neon",
  50. .do_2 = xor_neon_2,
  51. .do_3 = xor_neon_3,
  52. .do_4 = xor_neon_4,
  53. .do_5 = xor_neon_5
  54. };
  55. #undef XOR_TRY_TEMPLATES
  56. #define XOR_TRY_TEMPLATES \
  57. do { \
  58. xor_speed(&xor_block_8regs); \
  59. xor_speed(&xor_block_32regs); \
  60. if (cpu_has_neon()) { \
  61. xor_speed(&xor_block_arm64);\
  62. } \
  63. } while (0)
  64. #endif /* ! CONFIG_KERNEL_MODE_NEON */