2 * include/asm-generic/xor.h
4 * Generic optimized RAID-5 checksumming functions.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * You should have received a copy of the GNU General Public License
12 * (for example /usr/src/linux/COPYING); if not, write to the Free
13 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 #include <linux/prefetch.h>
19 xor_8regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
21 long lines = bytes / (sizeof (long)) / 8;
34 } while (--lines > 0);
38 xor_8regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
41 long lines = bytes / (sizeof (long)) / 8;
44 p1[0] ^= p2[0] ^ p3[0];
45 p1[1] ^= p2[1] ^ p3[1];
46 p1[2] ^= p2[2] ^ p3[2];
47 p1[3] ^= p2[3] ^ p3[3];
48 p1[4] ^= p2[4] ^ p3[4];
49 p1[5] ^= p2[5] ^ p3[5];
50 p1[6] ^= p2[6] ^ p3[6];
51 p1[7] ^= p2[7] ^ p3[7];
55 } while (--lines > 0);
59 xor_8regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
60 unsigned long *p3, unsigned long *p4)
62 long lines = bytes / (sizeof (long)) / 8;
65 p1[0] ^= p2[0] ^ p3[0] ^ p4[0];
66 p1[1] ^= p2[1] ^ p3[1] ^ p4[1];
67 p1[2] ^= p2[2] ^ p3[2] ^ p4[2];
68 p1[3] ^= p2[3] ^ p3[3] ^ p4[3];
69 p1[4] ^= p2[4] ^ p3[4] ^ p4[4];
70 p1[5] ^= p2[5] ^ p3[5] ^ p4[5];
71 p1[6] ^= p2[6] ^ p3[6] ^ p4[6];
72 p1[7] ^= p2[7] ^ p3[7] ^ p4[7];
77 } while (--lines > 0);
81 xor_8regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
82 unsigned long *p3, unsigned long *p4, unsigned long *p5)
84 long lines = bytes / (sizeof (long)) / 8;
87 p1[0] ^= p2[0] ^ p3[0] ^ p4[0] ^ p5[0];
88 p1[1] ^= p2[1] ^ p3[1] ^ p4[1] ^ p5[1];
89 p1[2] ^= p2[2] ^ p3[2] ^ p4[2] ^ p5[2];
90 p1[3] ^= p2[3] ^ p3[3] ^ p4[3] ^ p5[3];
91 p1[4] ^= p2[4] ^ p3[4] ^ p4[4] ^ p5[4];
92 p1[5] ^= p2[5] ^ p3[5] ^ p4[5] ^ p5[5];
93 p1[6] ^= p2[6] ^ p3[6] ^ p4[6] ^ p5[6];
94 p1[7] ^= p2[7] ^ p3[7] ^ p4[7] ^ p5[7];
100 } while (--lines > 0);
104 xor_32regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
106 long lines = bytes / (sizeof (long)) / 8;
109 register long d0, d1, d2, d3, d4, d5, d6, d7;
110 d0 = p1[0]; /* Pull the stuff into registers */
111 d1 = p1[1]; /* ... in bursts, if possible. */
126 p1[0] = d0; /* Store the result (in bursts) */
136 } while (--lines > 0);
140 xor_32regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
143 long lines = bytes / (sizeof (long)) / 8;
146 register long d0, d1, d2, d3, d4, d5, d6, d7;
147 d0 = p1[0]; /* Pull the stuff into registers */
148 d1 = p1[1]; /* ... in bursts, if possible. */
171 p1[0] = d0; /* Store the result (in bursts) */
182 } while (--lines > 0);
186 xor_32regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
187 unsigned long *p3, unsigned long *p4)
189 long lines = bytes / (sizeof (long)) / 8;
192 register long d0, d1, d2, d3, d4, d5, d6, d7;
193 d0 = p1[0]; /* Pull the stuff into registers */
194 d1 = p1[1]; /* ... in bursts, if possible. */
225 p1[0] = d0; /* Store the result (in bursts) */
237 } while (--lines > 0);
241 xor_32regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
242 unsigned long *p3, unsigned long *p4, unsigned long *p5)
244 long lines = bytes / (sizeof (long)) / 8;
247 register long d0, d1, d2, d3, d4, d5, d6, d7;
248 d0 = p1[0]; /* Pull the stuff into registers */
249 d1 = p1[1]; /* ... in bursts, if possible. */
288 p1[0] = d0; /* Store the result (in bursts) */
301 } while (--lines > 0);
305 xor_8regs_p_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
307 long lines = bytes / (sizeof (long)) / 8 - 1;
325 } while (--lines > 0);
331 xor_8regs_p_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
334 long lines = bytes / (sizeof (long)) / 8 - 1;
344 p1[0] ^= p2[0] ^ p3[0];
345 p1[1] ^= p2[1] ^ p3[1];
346 p1[2] ^= p2[2] ^ p3[2];
347 p1[3] ^= p2[3] ^ p3[3];
348 p1[4] ^= p2[4] ^ p3[4];
349 p1[5] ^= p2[5] ^ p3[5];
350 p1[6] ^= p2[6] ^ p3[6];
351 p1[7] ^= p2[7] ^ p3[7];
355 } while (--lines > 0);
361 xor_8regs_p_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
362 unsigned long *p3, unsigned long *p4)
364 long lines = bytes / (sizeof (long)) / 8 - 1;
377 p1[0] ^= p2[0] ^ p3[0] ^ p4[0];
378 p1[1] ^= p2[1] ^ p3[1] ^ p4[1];
379 p1[2] ^= p2[2] ^ p3[2] ^ p4[2];
380 p1[3] ^= p2[3] ^ p3[3] ^ p4[3];
381 p1[4] ^= p2[4] ^ p3[4] ^ p4[4];
382 p1[5] ^= p2[5] ^ p3[5] ^ p4[5];
383 p1[6] ^= p2[6] ^ p3[6] ^ p4[6];
384 p1[7] ^= p2[7] ^ p3[7] ^ p4[7];
389 } while (--lines > 0);
395 xor_8regs_p_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
396 unsigned long *p3, unsigned long *p4, unsigned long *p5)
398 long lines = bytes / (sizeof (long)) / 8 - 1;
413 p1[0] ^= p2[0] ^ p3[0] ^ p4[0] ^ p5[0];
414 p1[1] ^= p2[1] ^ p3[1] ^ p4[1] ^ p5[1];
415 p1[2] ^= p2[2] ^ p3[2] ^ p4[2] ^ p5[2];
416 p1[3] ^= p2[3] ^ p3[3] ^ p4[3] ^ p5[3];
417 p1[4] ^= p2[4] ^ p3[4] ^ p4[4] ^ p5[4];
418 p1[5] ^= p2[5] ^ p3[5] ^ p4[5] ^ p5[5];
419 p1[6] ^= p2[6] ^ p3[6] ^ p4[6] ^ p5[6];
420 p1[7] ^= p2[7] ^ p3[7] ^ p4[7] ^ p5[7];
426 } while (--lines > 0);
432 xor_32regs_p_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
434 long lines = bytes / (sizeof (long)) / 8 - 1;
440 register long d0, d1, d2, d3, d4, d5, d6, d7;
445 d0 = p1[0]; /* Pull the stuff into registers */
446 d1 = p1[1]; /* ... in bursts, if possible. */
461 p1[0] = d0; /* Store the result (in bursts) */
471 } while (--lines > 0);
477 xor_32regs_p_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
480 long lines = bytes / (sizeof (long)) / 8 - 1;
487 register long d0, d1, d2, d3, d4, d5, d6, d7;
493 d0 = p1[0]; /* Pull the stuff into registers */
494 d1 = p1[1]; /* ... in bursts, if possible. */
517 p1[0] = d0; /* Store the result (in bursts) */
528 } while (--lines > 0);
534 xor_32regs_p_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
535 unsigned long *p3, unsigned long *p4)
537 long lines = bytes / (sizeof (long)) / 8 - 1;
545 register long d0, d1, d2, d3, d4, d5, d6, d7;
552 d0 = p1[0]; /* Pull the stuff into registers */
553 d1 = p1[1]; /* ... in bursts, if possible. */
584 p1[0] = d0; /* Store the result (in bursts) */
596 } while (--lines > 0);
602 xor_32regs_p_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
603 unsigned long *p3, unsigned long *p4, unsigned long *p5)
605 long lines = bytes / (sizeof (long)) / 8 - 1;
614 register long d0, d1, d2, d3, d4, d5, d6, d7;
622 d0 = p1[0]; /* Pull the stuff into registers */
623 d1 = p1[1]; /* ... in bursts, if possible. */
662 p1[0] = d0; /* Store the result (in bursts) */
675 } while (--lines > 0);
680 static struct xor_block_template xor_block_8regs = {
688 static struct xor_block_template xor_block_32regs = {
690 .do_2 = xor_32regs_2,
691 .do_3 = xor_32regs_3,
692 .do_4 = xor_32regs_4,
693 .do_5 = xor_32regs_5,
696 static struct xor_block_template xor_block_8regs_p __maybe_unused = {
697 .name = "8regs_prefetch",
698 .do_2 = xor_8regs_p_2,
699 .do_3 = xor_8regs_p_3,
700 .do_4 = xor_8regs_p_4,
701 .do_5 = xor_8regs_p_5,
704 static struct xor_block_template xor_block_32regs_p __maybe_unused = {
705 .name = "32regs_prefetch",
706 .do_2 = xor_32regs_p_2,
707 .do_3 = xor_32regs_p_3,
708 .do_4 = xor_32regs_p_4,
709 .do_5 = xor_32regs_p_5,
712 #define XOR_TRY_TEMPLATES \
714 xor_speed(&xor_block_8regs); \
715 xor_speed(&xor_block_8regs_p); \
716 xor_speed(&xor_block_32regs); \
717 xor_speed(&xor_block_32regs_p); \