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.4 2004/05/19 22:52:40 dillon Exp $
35 #define AR_PROXIMITY 2048
39 #define AR_STRATEGY(x) dev_dstrategy((x)->b_dev, x)
40 #define AD_SOFTC(x) ((struct ad_softc *)(x.device->driver))
41 #define ATA_MAGIC "FreeBSD ATA driver RAID "
44 struct ata_device *device;
45 u_int64_t disk_sectors; /* sectors on this disk */
46 off_t last_lba; /* last lba used */
48 #define AR_DF_PRESENT 0x00000001
49 #define AR_DF_ASSIGNED 0x00000002
50 #define AR_DF_SPARE 0x00000004
51 #define AR_DF_ONLINE 0x00000008
56 int32_t magic_0; /* ident for this array */
57 int32_t magic_1; /* ident for this array */
59 #define AR_F_RAID0 0x0001 /* STRIPE */
60 #define AR_F_RAID1 0x0002 /* MIRROR */
61 #define AR_F_SPAN 0x0004 /* SPAN */
62 #define AR_F_READY 0x0100
63 #define AR_F_DEGRADED 0x0200
64 #define AR_F_REBUILDING 0x0400
65 #define AR_F_PROMISE_RAID 0x1000
66 #define AR_F_HIGHPOINT_RAID 0x2000
67 #define AR_F_FREEBSD_RAID 0x4000
69 int total_disks; /* number of disks in this array */
70 int generation; /* generation of this array */
71 struct ar_disk disks[MAX_DISKS+1]; /* ptr to each disk in array */
72 int width; /* array width in disks */
76 u_int64_t total_sectors;
77 int interleave; /* interleave in blocks */
78 int reserved; /* sectors that are NOT to be used */
79 int offset; /* offset from start of disk */
80 u_int64_t lock_start; /* start of locked area for rebuild */
81 u_int64_t lock_end; /* end of locked area for rebuild */
82 struct disk disk; /* disklabel/slice stuff */
84 dev_t dev; /* device place holder */
88 struct buf bp; /* must be first element! */
90 struct ar_buf *mirror;
93 #define AB_F_DONE 0x01
98 struct highpoint_raid_conf {
100 u_int32_t magic; /* 0x20 */
101 #define HPT_MAGIC_OK 0x5a7816f0
102 #define HPT_MAGIC_BAD 0x5a7816fd
107 #define HPT_O_RAID0 0x01
108 #define HPT_O_RAID1 0x02
109 #define HPT_O_OK 0x04
111 u_int8_t array_width;
112 u_int8_t stripe_shift;
114 #define HPT_T_RAID0 0x00
115 #define HPT_T_RAID1 0x01
116 #define HPT_T_RAID01_RAID0 0x02
117 #define HPT_T_SPAN 0x03
118 #define HPT_T_RAID_3 0x04
119 #define HPT_T_RAID_5 0x05
120 #define HPT_T_SINGLEDISK 0x06
121 #define HPT_T_RAID01_RAID1 0x07
123 u_int8_t disk_number;
124 u_int32_t total_sectors;
128 u_int8_t boot_protect;
129 u_int8_t error_log_entries;
130 u_int8_t error_log_index;
134 #define HPT_R_REMOVED 0xfe
135 #define HPT_R_BROKEN 0xff
143 u_int32_t rebuild_lba;
149 } __attribute__((packed));
152 #define PR_LBA(adp) \
153 (((adp->total_secs / (adp->heads * adp->sectors)) * \
154 adp->heads * adp->sectors) - adp->sectors)
156 struct promise_raid_conf {
158 #define PR_MAGIC "Promise Technology, Inc."
162 #define PR_MAGIC0(x) (x.device ? ((u_int64_t)x.device->channel->unit<<48) | \
163 ((u_int64_t)(x.device->unit != 0) << 56) : 0)
166 u_int8_t filler1[470];
168 u_int32_t integrity; /* 0x200 */
169 #define PR_I_VALID 0x00000080
172 #define PR_F_VALID 0x00000001
173 #define PR_F_ONLINE 0x00000002
174 #define PR_F_ASSIGNED 0x00000004
175 #define PR_F_SPARE 0x00000008
176 #define PR_F_DUPLICATE 0x00000010
177 #define PR_F_REDIR 0x00000020
178 #define PR_F_DOWN 0x00000040
179 #define PR_F_READY 0x00000080
181 u_int8_t disk_number;
184 u_int64_t magic_0 __attribute__((packed));
185 u_int32_t disk_offset; /* 0x210 */
186 u_int32_t disk_sectors;
187 u_int32_t rebuild_lba;
188 u_int16_t generation;
190 #define PR_S_VALID 0x01
191 #define PR_S_ONLINE 0x02
192 #define PR_S_INITED 0x04
193 #define PR_S_READY 0x08
194 #define PR_S_DEGRADED 0x10
195 #define PR_S_MARKED 0x20
196 #define PR_S_FUNCTIONAL 0x80
199 #define PR_T_RAID0 0x00
200 #define PR_T_RAID1 0x01
201 #define PR_T_RAID3 0x02
202 #define PR_T_RAID5 0x04
203 #define PR_T_SPAN 0x08
205 u_int8_t total_disks; /* 0x220 */
206 u_int8_t stripe_shift;
207 u_int8_t array_width;
208 u_int8_t array_number;
209 u_int32_t total_sectors;
213 int64_t magic_1 __attribute__((packed));
219 u_int64_t magic_0 __attribute__((packed));
222 int32_t filler2[346];
224 } __attribute__((packed));
226 int ata_raiddisk_probe(struct ad_softc *);
227 int ata_raiddisk_attach(struct ad_softc *);
228 int ata_raiddisk_detach(struct ad_softc *);
229 void ata_raid_attach(void);
230 int ata_raid_create(struct raid_setup *);
231 int ata_raid_delete(int);
232 int ata_raid_status(int array, struct raid_status *);
233 int ata_raid_rebuild(int);