~ [ 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 ] ~

Diff markup

Differences between /lib/raid6/int.uc (Architecture mips) and /lib/raid6/int.uc (Architecture alpha)


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