~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/raid6/int.uc

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* -*- linux-c -*- ------------------------------------------------------- *
  2  *
  3  *   Copyright 2002-2004 H. Peter Anvin - All Rights Reserved
  4  *
  5  *   This program is free software; you can redistribute it and/or modify
  6  *   it under the terms of the GNU General Public License as published by
  7  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
  8  *   Boston MA 02111-1307, USA; either version 2 of the License, or
  9  *   (at your option) any later version; incorporated herein by reference.
 10  *
 11  * ----------------------------------------------------------------------- */
 12 
 13 /*
 14  * int$#.c
 15  *
 16  * $#-way unrolled portable integer math RAID-6 instruction set
 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 something better... */
 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 since they can sometimes be
 46  * specially optimized using architecture-specific hacks.
 47  */
 48 
 49 /*
 50  * The SHLBYTE() operation shifts each byte left by 1, *not*
 51  * rolling over into the next byte
 52  */
 53 static inline __attribute_const__ unative_t SHLBYTE(unative_t v)
 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 byte for which the high
 63  * bit is 1, 0x00 for any byte for which the high bit is 0.
 64  */
 65 static inline __attribute_const__ unative_t MASK(unative_t v)
 66 {
 67         unative_t vv;
 68 
 69         vv = v & NBYTES(0x80);
 70         vv = (vv << 1) - (vv >> 7); /* Overflow on the top bit is OK */
 71         return vv;
 72 }
 73 
 74 
 75 static void raid6_int$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
 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 data disk */
 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 *)&dptr[z0][d+$$*NSIZE];
 89                 for ( z = z0-1 ; z >= 0 ; z-- ) {
 90                         wd$$ = *(unative_t *)&dptr[z][d+$$*NSIZE];
 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*$$] = wp$$;
 99                 *(unative_t *)&q[d+NSIZE*$$] = wq$$;
100         }
101 }
102 
103 static void raid6_int$#_xor_syndrome(int disks, int start, int stop,
104                                      size_t bytes, void **ptrs)
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 side optimization */
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 *)&dptr[z0][d+$$*NSIZE];
119                 for ( z = z0-1 ; z >= start ; z-- ) {
120                         wd$$ = *(unative_t *)&dptr[z][d+$$*NSIZE];
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*$$] ^= wp$$;
136                 *(unative_t *)&q[d+NSIZE*$$] ^= wq$$;
137         }
138 
139 }
140 
141 const struct raid6_calls raid6_intx$# = {
142         raid6_int$#_gen_syndrome,
143         raid6_int$#_xor_syndrome,
144         NULL,                   /* always valid */
145         "int" NSTRING "x$#",
146         0
147 };

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php