1 /* -*- linux-c -*- --------------------------- 2 * 3 * Copyright 2002-2004 H. Peter Anvin - All 4 * 5 * This program is free software; you can re 6 * it under the terms of the GNU General Pub 7 * the Free Software Foundation, Inc., 53 Te 8 * Boston MA 02111-1307, USA; either version 9 * (at your option) any later version; incor 10 * 11 * ------------------------------------------- 12 13 /* 14 * int$#.c 15 * 16 * $#-way unrolled portable integer math RAID- 17 * 18 * This file is postprocessed using unroll.awk 19 */ 20 21 #include <linux/raid/pq.h> 22 23 /* 24 * This is the C data type to use 25 */ 26 27 /* Change this from BITS_PER_LONG if there is 28 #if BITS_PER_LONG == 64 29 # define NBYTES(x) ((x) * 0x0101010101010101UL 30 # define NSIZE 8 31 # define NSHIFT 3 32 # define NSTRING "64" 33 typedef u64 unative_t; 34 #else 35 # define NBYTES(x) ((x) * 0x01010101U) 36 # define NSIZE 4 37 # define NSHIFT 2 38 # define NSTRING "32" 39 typedef u32 unative_t; 40 #endif 41 42 43 44 /* 45 * These sub-operations are separate inlines s 46 * specially optimized using architecture-spec 47 */ 48 49 /* 50 * The SHLBYTE() operation shifts each byte le 51 * rolling over into the next byte 52 */ 53 static inline __attribute_const__ unative_t SH 54 { 55 unative_t vv; 56 57 vv = (v << 1) & NBYTES(0xfe); 58 return vv; 59 } 60 61 /* 62 * The MASK() operation returns 0xFF in any by 63 * bit is 1, 0x00 for any byte for which the h 64 */ 65 static inline __attribute_const__ unative_t MA 66 { 67 unative_t vv; 68 69 vv = v & NBYTES(0x80); 70 vv = (vv << 1) - (vv >> 7); /* Overflo 71 return vv; 72 } 73 74 75 static void raid6_int$#_gen_syndrome(int disks 76 { 77 u8 **dptr = (u8 **)ptrs; 78 u8 *p, *q; 79 int d, z, z0; 80 81 unative_t wd$$, wq$$, wp$$, w1$$, w2$$ 82 83 z0 = disks - 3; /* Highest dat 84 p = dptr[z0+1]; /* XOR parity 85 q = dptr[z0+2]; /* RS syndrome 86 87 for ( d = 0 ; d < bytes ; d += NSIZE*$ 88 wq$$ = wp$$ = *(unative_t *)&d 89 for ( z = z0-1 ; z >= 0 ; z-- 90 wd$$ = *(unative_t *)& 91 wp$$ ^= wd$$; 92 w2$$ = MASK(wq$$); 93 w1$$ = SHLBYTE(wq$$); 94 w2$$ &= NBYTES(0x1d); 95 w1$$ ^= w2$$; 96 wq$$ = w1$$ ^ wd$$; 97 } 98 *(unative_t *)&p[d+NSIZE*$$] = 99 *(unative_t *)&q[d+NSIZE*$$] = 100 } 101 } 102 103 static void raid6_int$#_xor_syndrome(int disks 104 size_t by 105 { 106 u8 **dptr = (u8 **)ptrs; 107 u8 *p, *q; 108 int d, z, z0; 109 110 unative_t wd$$, wq$$, wp$$, w1$$, w2$$ 111 112 z0 = stop; /* P/Q right s 113 p = dptr[disks-2]; /* XOR parity 114 q = dptr[disks-1]; /* RS syndrome 115 116 for ( d = 0 ; d < bytes ; d += NSIZE*$ 117 /* P/Q data pages */ 118 wq$$ = wp$$ = *(unative_t *)&d 119 for ( z = z0-1 ; z >= start ; 120 wd$$ = *(unative_t *)& 121 wp$$ ^= wd$$; 122 w2$$ = MASK(wq$$); 123 w1$$ = SHLBYTE(wq$$); 124 w2$$ &= NBYTES(0x1d); 125 w1$$ ^= w2$$; 126 wq$$ = w1$$ ^ wd$$; 127 } 128 /* P/Q left side optimization 129 for ( z = start-1 ; z >= 0 ; z 130 w2$$ = MASK(wq$$); 131 w1$$ = SHLBYTE(wq$$); 132 w2$$ &= NBYTES(0x1d); 133 wq$$ = w1$$ ^ w2$$; 134 } 135 *(unative_t *)&p[d+NSIZE*$$] ^ 136 *(unative_t *)&q[d+NSIZE*$$] ^ 137 } 138 139 } 140 141 const struct raid6_calls raid6_intx$# = { 142 raid6_int$#_gen_syndrome, 143 raid6_int$#_xor_syndrome, 144 NULL, /* always vali 145 "int" NSTRING "x$#", 146 0 147 };
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.