2 * Copyright (c) 2000,2001,2002 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.2.2.8 2002/04/11 09:31:57 sos Exp $
29 * $DragonFly: src/sys/dev/disk/ata/ata-raid.h,v 1.6 2006/09/10 01:26:33 dillon Exp $
35 #define AR_PROXIMITY 2048
39 #define AD_SOFTC(x) ((struct ad_softc *)(x.device->driver))
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_RAID0 0x0001 /* STRIPE */
59 #define AR_F_RAID1 0x0002 /* MIRROR */
60 #define AR_F_SPAN 0x0004 /* SPAN */
61 #define AR_F_READY 0x0100
62 #define AR_F_DEGRADED 0x0200
63 #define AR_F_REBUILDING 0x0400
64 #define AR_F_PROMISE_RAID 0x1000
65 #define AR_F_HIGHPOINT_RAID 0x2000
66 #define AR_F_FREEBSD_RAID 0x4000
68 int total_disks
; /* number of disks in this array */
69 int generation
; /* generation of this array */
70 struct ar_disk disks
[MAX_DISKS
+1]; /* ptr to each disk in array */
71 int width
; /* array width in disks */
75 u_int64_t total_sectors
;
76 int interleave
; /* interleave in blocks */
77 int reserved
; /* sectors that are NOT to be used */
78 int offset
; /* offset from start of disk */
79 u_int64_t lock_start
; /* start of locked area for rebuild */
80 u_int64_t lock_end
; /* end of locked area for rebuild */
81 struct disk disk
; /* disklabel/slice stuff */
83 cdev_t dev
; /* device place holder */
87 struct buf bp
; /* must be first element! */
89 struct ar_buf
*mirror
;
92 #define AB_F_DONE 0x01
97 struct highpoint_raid_conf
{
99 u_int32_t magic
; /* 0x20 */
100 #define HPT_MAGIC_OK 0x5a7816f0
101 #define HPT_MAGIC_BAD 0x5a7816fd
106 #define HPT_O_RAID0 0x01
107 #define HPT_O_RAID1 0x02
108 #define HPT_O_OK 0x04
110 u_int8_t array_width
;
111 u_int8_t stripe_shift
;
113 #define HPT_T_RAID0 0x00
114 #define HPT_T_RAID1 0x01
115 #define HPT_T_RAID01_RAID0 0x02
116 #define HPT_T_SPAN 0x03
117 #define HPT_T_RAID_3 0x04
118 #define HPT_T_RAID_5 0x05
119 #define HPT_T_SINGLEDISK 0x06
120 #define HPT_T_RAID01_RAID1 0x07
122 u_int8_t disk_number
;
123 u_int32_t total_sectors
;
127 u_int8_t boot_protect
;
128 u_int8_t error_log_entries
;
129 u_int8_t error_log_index
;
133 #define HPT_R_REMOVED 0xfe
134 #define HPT_R_BROKEN 0xff
142 u_int32_t rebuild_lba
;
148 } __attribute__((packed
));
151 #define PR_LBA(adp) \
152 (((adp->total_secs / (adp->heads * adp->sectors)) * \
153 adp->heads * adp->sectors) - adp->sectors)
155 struct promise_raid_conf
{
157 #define PR_MAGIC "Promise Technology, Inc."
161 #define PR_MAGIC0(x) (x.device ? ((u_int64_t)x.device->channel->unit<<48) | \
162 ((u_int64_t)(x.device->unit != 0) << 56) : 0)
165 u_int8_t filler1
[470];
167 u_int32_t integrity
; /* 0x200 */
168 #define PR_I_VALID 0x00000080
171 #define PR_F_VALID 0x00000001
172 #define PR_F_ONLINE 0x00000002
173 #define PR_F_ASSIGNED 0x00000004
174 #define PR_F_SPARE 0x00000008
175 #define PR_F_DUPLICATE 0x00000010
176 #define PR_F_REDIR 0x00000020
177 #define PR_F_DOWN 0x00000040
178 #define PR_F_READY 0x00000080
180 u_int8_t disk_number
;
183 u_int64_t magic_0
__attribute__((packed
));
184 u_int32_t disk_offset
; /* 0x210 */
185 u_int32_t disk_sectors
;
186 u_int32_t rebuild_lba
;
187 u_int16_t generation
;
189 #define PR_S_VALID 0x01
190 #define PR_S_ONLINE 0x02
191 #define PR_S_INITED 0x04
192 #define PR_S_READY 0x08
193 #define PR_S_DEGRADED 0x10
194 #define PR_S_MARKED 0x20
195 #define PR_S_FUNCTIONAL 0x80
198 #define PR_T_RAID0 0x00
199 #define PR_T_RAID1 0x01
200 #define PR_T_RAID3 0x02
201 #define PR_T_RAID5 0x04
202 #define PR_T_SPAN 0x08
204 u_int8_t total_disks
; /* 0x220 */
205 u_int8_t stripe_shift
;
206 u_int8_t array_width
;
207 u_int8_t array_number
;
208 u_int32_t total_sectors
;
212 int64_t magic_1
__attribute__((packed
));
218 u_int64_t magic_0
__attribute__((packed
));
221 int32_t filler2
[346];
223 } __attribute__((packed
));
225 int ata_raiddisk_probe(struct ad_softc
*);
226 int ata_raiddisk_attach(struct ad_softc
*);
227 int ata_raiddisk_detach(struct ad_softc
*);
228 void ata_raid_attach(void);
229 int ata_raid_create(struct raid_setup
*);
230 int ata_raid_delete(int);
231 int ata_raid_status(int array
, struct raid_status
*);
232 int ata_raid_rebuild(int);