1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright 2003 H. Peter Anvin - All Rights Reserved
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 * Bostom MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
13 #ifndef LINUX_RAID_RAID6_H
14 #define LINUX_RAID_RAID6_H
18 /* Set to 1 to use kernel-wide empty_zero_page */
19 #define RAID6_USE_EMPTY_ZERO_PAGE 0
21 #include <linux/raid/md.h>
22 #include <linux/raid/raid5.h>
24 typedef raid5_conf_t raid6_conf_t; /* Same configuration */
26 /* Additional compute_parity mode -- updates the parity w/o LOCKING */
27 #define UPDATE_PARITY 4
29 /* We need a pre-zeroed page... if we don't want to use the kernel-provided
31 #if RAID6_USE_EMPTY_ZERO_PAGE
32 # define raid6_empty_zero_page empty_zero_page
34 extern const char raid6_empty_zero_page[PAGE_SIZE];
37 #else /* ! __KERNEL__ */
38 /* Used for testing in user space */
45 #include <sys/types.h>
47 /* Not standard, but glibc defines it */
48 #define BITS_PER_LONG __WORDSIZE
56 # define PAGE_SIZE 4096
58 extern const char raid6_empty_zero_page[PAGE_SIZE];
62 #define __attribute_const__ __attribute__((const))
63 #define noinline __attribute__((noinline))
65 #define preempt_enable()
66 #define preempt_disable()
67 #define cpu_has_feature(x) 1
68 #define enable_kernel_altivec()
69 #define disable_kernel_altivec()
71 #endif /* __KERNEL__ */
75 void (*gen_syndrome)(int, size_t, void **);
76 int (*valid)(void); /* Returns 1 if this routine set is usable */
77 const char *name; /* Name of this routine set */
78 int prefer; /* Has special performance attribute */
81 /* Selected algorithm */
82 extern struct raid6_calls raid6_call;
85 extern const struct raid6_calls * const raid6_algos[];
86 int raid6_select_algo(void);
88 /* Return values from chk_syndrome */
92 #define RAID6_PQ_BAD 3
94 /* Galois field tables */
95 extern const u8 raid6_gfmul[256][256] __attribute__((aligned(256)));
96 extern const u8 raid6_gfexp[256] __attribute__((aligned(256)));
97 extern const u8 raid6_gfinv[256] __attribute__((aligned(256)));
98 extern const u8 raid6_gfexi[256] __attribute__((aligned(256)));
100 /* Recovery routines */
101 void raid6_2data_recov(int disks, size_t bytes, int faila, int failb, void **ptrs);
102 void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs);
103 void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, void **ptrs);
105 /* Some definitions to allow code to be compiled for testing in userspace */
108 # define jiffies raid6_jiffies()
109 # define printk printf
110 # define GFP_KERNEL 0
111 # define __get_free_pages(x,y) ((unsigned long)mmap(NULL, PAGE_SIZE << (y), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))
112 # define free_pages(x,y) munmap((void *)(x), (y)*PAGE_SIZE)
114 static inline void cpu_relax(void)
121 static inline uint32_t raid6_jiffies(void)
124 gettimeofday(&tv, NULL);
125 return tv.tv_sec*1000 + tv.tv_usec/1000;
128 #endif /* ! __KERNEL__ */
130 #endif /* LINUX_RAID_RAID6_H */