2 * Copyright (c) 2000 - 2003 Søren Schmidt <sos@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/sys/dev/ata/ata-raid.h,v 1.27 2004/06/25 21:21:59 sos Exp $
34 #define AR_PROXIMITY 2048
38 #define AR_STRATEGY(x) (x)->bio_disk->d_strategy((x))
39 #define AD_SOFTC(x) ((struct ad_softc *)(x.device->softc))
40 #define ATA_MAGIC "FreeBSD ATA driver RAID "
43 struct ata_device *device;
44 u_int64_t disk_sectors; /* sectors on this disk */
45 off_t last_lba; /* last lba used */
47 #define AR_DF_PRESENT 0x00000001
48 #define AR_DF_ASSIGNED 0x00000002
49 #define AR_DF_SPARE 0x00000004
50 #define AR_DF_ONLINE 0x00000008
55 int32_t magic_0; /* ident for this array */
56 int32_t magic_1; /* ident for this array */
58 #define AR_F_SPAN 0x00000001
59 #define AR_F_RAID0 0x00000002
60 #define AR_F_RAID1 0x00000004
61 #define AR_F_RAID3 0x00000008
62 #define AR_F_RAID5 0x00000010
64 #define AR_F_READY 0x00000100
65 #define AR_F_DEGRADED 0x00000200
66 #define AR_F_REBUILDING 0x00000400
67 #define AR_F_TOGGLE 0x00000800
69 #define AR_F_FREEBSD_RAID 0x00010000
70 #define AR_F_PROMISE_RAID 0x00020000
71 #define AR_F_HIGHPOINT_RAID 0x00040000
72 #define AR_F_ADAPTEC_RAID 0x00080000
73 #define AR_F_LSI_RAID 0x00100000
74 #define AR_F_INTEL_RAID 0x00200000
75 #define AR_F_QTEC_RAID 0x00400000
77 int total_disks; /* number of disks in this array */
78 int generation; /* generation of this array */
79 struct ar_disk disks[MAX_DISKS+1]; /* ptr to each disk in array */
80 int width; /* array width in disks */
84 u_int64_t total_sectors;
85 int interleave; /* interleave in blocks */
86 int reserved; /* sectors that are NOT to be used */
87 int offset; /* offset from start of disk */
88 u_int64_t lock_start; /* start of locked area for rebuild */
89 u_int64_t lock_end; /* end of locked area for rebuild */
90 struct disk *disk; /* disklabel/slice stuff */
91 struct proc *pid; /* rebuilder process id */
95 struct bio bp; /* must be first element! */
97 struct ar_buf *mirror;
100 #define AB_F_DONE 0x01
106 struct highpoint_raid_conf {
109 #define HPT_MAGIC_OK 0x5a7816f0
110 #define HPT_MAGIC_BAD 0x5a7816fd
115 #define HPT_O_RAID0 0x01
116 #define HPT_O_RAID1 0x02
117 #define HPT_O_OK 0x04
119 u_int8_t array_width;
120 u_int8_t stripe_shift;
122 #define HPT_T_RAID0 0x00
123 #define HPT_T_RAID1 0x01
124 #define HPT_T_RAID01_RAID0 0x02
125 #define HPT_T_SPAN 0x03
126 #define HPT_T_RAID_3 0x04
127 #define HPT_T_RAID_5 0x05
128 #define HPT_T_SINGLEDISK 0x06
129 #define HPT_T_RAID01_RAID1 0x07
131 u_int8_t disk_number;
132 u_int32_t total_sectors;
136 u_int8_t boot_protect;
137 u_int8_t error_log_entries;
138 u_int8_t error_log_index;
142 #define HPT_R_REMOVED 0xfe
143 #define HPT_R_BROKEN 0xff
151 u_int32_t rebuild_lba;
160 #define LSI_LBA(adp) (adp->total_secs - 1)
162 struct lsi_raid_conf {
164 #define LSI_MAGIC "$XIDE$"
169 u_int8_t config_entries;
171 u_int8_t total_disks;
179 #define LSI_R_RAID0 0x01
180 #define LSI_R_RAID1 0x02
181 #define LSI_R_SPARE 0x08
184 u_int16_t stripe_size;
187 u_int8_t config_offset;
190 #define LSI_R_DEGRADED 0x02
192 u_int32_t total_sectors;
197 #define LSI_D_MASTER 0x00
198 #define LSI_D_SLAVE 0x01
199 #define LSI_D_CHANNEL0 0x00
200 #define LSI_D_CHANNEL1 0x10
201 #define LSI_D_NONE 0xff
204 u_int32_t disk_sectors;
205 u_int8_t disk_number;
206 u_int8_t raid_number;
208 #define LSI_D_GONE 0x02
213 u_int8_t disk_number;
214 u_int8_t raid_number;
220 #define PR_LBA(adp) \
221 (((adp->total_secs / (adp->heads * adp->sectors)) * \
222 adp->heads * adp->sectors) - adp->sectors)
224 struct promise_raid_conf {
226 #define PR_MAGIC "Promise Technology, Inc."
230 #define PR_MAGIC0(x) (x.device ? ((u_int64_t)x.device->channel->unit<<48) | \
231 ((u_int64_t)(x.device->unit != 0) << 56) : 0)
234 u_int8_t filler1[470];
237 #define PR_I_VALID 0x00000080
240 #define PR_F_VALID 0x00000001
241 #define PR_F_ONLINE 0x00000002
242 #define PR_F_ASSIGNED 0x00000004
243 #define PR_F_SPARE 0x00000008
244 #define PR_F_DUPLICATE 0x00000010
245 #define PR_F_REDIR 0x00000020
246 #define PR_F_DOWN 0x00000040
247 #define PR_F_READY 0x00000080
249 u_int8_t disk_number;
252 u_int64_t magic_0 __packed;
253 u_int32_t disk_offset;
254 u_int32_t disk_sectors;
255 u_int32_t rebuild_lba;
256 u_int16_t generation;
258 #define PR_S_VALID 0x01
259 #define PR_S_ONLINE 0x02
260 #define PR_S_INITED 0x04
261 #define PR_S_READY 0x08
262 #define PR_S_DEGRADED 0x10
263 #define PR_S_MARKED 0x20
264 #define PR_S_FUNCTIONAL 0x80
267 #define PR_T_RAID0 0x00
268 #define PR_T_RAID1 0x01
269 #define PR_T_RAID3 0x02
270 #define PR_T_RAID5 0x04
271 #define PR_T_SPAN 0x08
273 u_int8_t total_disks;
274 u_int8_t stripe_shift;
275 u_int8_t array_width;
276 u_int8_t array_number;
277 u_int32_t total_sectors;
281 int64_t magic_1 __packed;
287 u_int64_t magic_0 __packed;
290 int32_t filler2[346];
294 int ata_raiddisk_attach(struct ad_softc *);
295 int ata_raiddisk_detach(struct ad_softc *);
296 void ata_raid_attach(void);
297 int ata_raid_create(struct raid_setup *);
298 int ata_raid_delete(int);
299 int ata_raid_status(int, struct raid_status *);
300 int ata_raid_addspare(int, int);
301 int ata_raid_rebuild(int);