ata-raid.h revision 153015
167071Ssos/*-
2144330Ssos * Copyright (c) 2000 - 2005 S�ren Schmidt <sos@FreeBSD.org>
367071Ssos * All rights reserved.
467071Ssos *
567071Ssos * Redistribution and use in source and binary forms, with or without
667071Ssos * modification, are permitted provided that the following conditions
767071Ssos * are met:
867071Ssos * 1. Redistributions of source code must retain the above copyright
967071Ssos *    notice, this list of conditions and the following disclaimer,
1067071Ssos *    without modification, immediately at the beginning of the file.
1167071Ssos * 2. Redistributions in binary form must reproduce the above copyright
1267071Ssos *    notice, this list of conditions and the following disclaimer in the
1367071Ssos *    documentation and/or other materials provided with the distribution.
1467071Ssos * 3. The name of the author may not be used to endorse or promote products
1567071Ssos *    derived from this software without specific prior written permission.
1667071Ssos *
1767071Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1867071Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1967071Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2067071Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2167071Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2267071Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2367071Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2467071Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2567071Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2667071Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2767071Ssos *
2867071Ssos * $FreeBSD: head/sys/dev/ata/ata-raid.h 153015 2005-12-02 10:13:53Z sos $
2967071Ssos */
3067071Ssos
3191816Ssos/* misc defines */
32144330Ssos#define MAX_ARRAYS      16
33144330Ssos#define MAX_DISKS       16
34144330Ssos#define AR_PROXIMITY    2048    /* how many sectors is "close" */
3591816Ssos
36144330Ssos#define ATA_MAGIC       "FreeBSD ATA driver RAID "
37144330Ssos
38144330Ssosstruct ata_raid_subdisk {
39144330Ssos    struct ar_softc     *raid;
40144330Ssos    int                 disk_number;
4190215Ssos};
4290215Ssos
43144330Ssos/*  ATA PseudoRAID Metadata */
4467071Ssosstruct ar_softc {
45144330Ssos    int                 lun;            /* logical unit number of this RAID */
46144330Ssos    u_int8_t            name[32];       /* name of array if any */
47144330Ssos    u_int64_t           magic_0;        /* magic for this array */
48144330Ssos    u_int64_t           magic_1;        /* magic for this array */
49144330Ssos    int                 type;
50144330Ssos#define AR_T_JBOD               0x0001
51144330Ssos#define AR_T_SPAN               0x0002
52144330Ssos#define AR_T_RAID0              0x0004
53144330Ssos#define AR_T_RAID1              0x0008
54144330Ssos#define AR_T_RAID01             0x0010
55144330Ssos#define AR_T_RAID3              0x0020
56144330Ssos#define AR_T_RAID4              0x0040
57144330Ssos#define AR_T_RAID5              0x0080
58131113Ssos
59144330Ssos    int                 status;
60144330Ssos#define AR_S_READY              0x0001
61144330Ssos#define AR_S_DEGRADED           0x0002
62144330Ssos#define AR_S_REBUILDING         0x0004
63131113Ssos
64144330Ssos    int                 format;
65144330Ssos#define AR_F_FREEBSD_RAID       0x0001
66144330Ssos#define AR_F_ADAPTEC_RAID       0x0002
67144330Ssos#define AR_F_HPTV2_RAID         0x0004
68144330Ssos#define AR_F_HPTV3_RAID         0x0008
69144330Ssos#define AR_F_INTEL_RAID         0x0010
70144330Ssos#define AR_F_ITE_RAID           0x0020
71144330Ssos#define AR_F_LSIV2_RAID         0x0040
72144330Ssos#define AR_F_LSIV3_RAID         0x0080
73147052Ssos#define AR_F_NVIDIA_RAID        0x0100
74147052Ssos#define AR_F_PROMISE_RAID       0x0200
75147052Ssos#define AR_F_SII_RAID           0x0400
76152908Ssos#define AR_F_SIS_RAID           0x0800
77152908Ssos#define AR_F_VIA_RAID           0x1000
78152908Ssos#define AR_F_FORMAT_MASK        0x1fff
79131113Ssos
80144330Ssos    u_int               generation;     /* generation of this array */
81144330Ssos    u_int64_t           total_sectors;
82144330Ssos    u_int64_t           offset_sectors; /* offset from start of disk */
83144330Ssos    u_int16_t           heads;
84144330Ssos    u_int16_t           sectors;
85144330Ssos    u_int32_t           cylinders;
86144330Ssos    u_int               width;          /* array width in disks */
87144330Ssos    u_int               interleave;     /* interleave in blocks */
88144330Ssos    u_int               total_disks;    /* number of disks in this array */
89144330Ssos    struct ar_disk {
90144330Ssos	device_t        dev;
91144330Ssos	u_int8_t        serial[16];     /* serial # of physical disk */
92144330Ssos	u_int64_t       sectors;        /* useable sectors on this disk */
93144330Ssos	off_t           last_lba;       /* last lba used (for performance) */
94144330Ssos	u_int           flags;
95144330Ssos#define AR_DF_PRESENT           0x0001  /* this HW pos has a disk present */
96144330Ssos#define AR_DF_ASSIGNED          0x0002  /* this HW pos assigned to an array */
97144330Ssos#define AR_DF_SPARE             0x0004  /* this HW pos is a spare */
98144330Ssos#define AR_DF_ONLINE            0x0008  /* this HW pos is online and in use */
9967071Ssos
100144330Ssos    } disks[MAX_DISKS];
101144330Ssos    int                 toggle;         /* performance hack for RAID1's */
102144330Ssos    u_int64_t           rebuild_lba;    /* rebuild progress indicator */
103144330Ssos    struct mtx          lock;           /* metadata lock */
104144330Ssos    struct disk         *disk;          /* disklabel/slice stuff */
105144330Ssos    struct proc         *pid;           /* rebuilder process id */
10667071Ssos};
10767071Ssos
108144330Ssos/* Adaptec HostRAID Metadata */
109144330Ssos#define ADP_LBA(dev) \
110144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 17)
111131113Ssos
112144330Ssos/* note all entries are big endian */
113144330Ssosstruct adaptec_raid_conf {
114144936Ssos    u_int32_t           magic_0;
115144330Ssos#define ADP_MAGIC_0             0xc4650790
11690215Ssos
117144330Ssos    u_int32_t           generation;
118144330Ssos    u_int16_t           dummy_0;
119144330Ssos    u_int16_t           total_configs;
120144330Ssos    u_int16_t           dummy_1;
121144330Ssos    u_int16_t           checksum;
122144936Ssos    u_int32_t           dummy_2;
123144330Ssos    u_int32_t           dummy_3;
124144330Ssos    u_int32_t           flags;
125144330Ssos    u_int32_t           timestamp;
126144936Ssos    u_int32_t           dummy_4[4];
127144936Ssos    u_int32_t           dummy_5[4];
128144936Ssos    struct {
129144330Ssos	u_int16_t       total_disks;
130144330Ssos	u_int16_t       generation;
131144330Ssos	u_int32_t       magic_0;
132144330Ssos	u_int8_t        dummy_0;
133144330Ssos	u_int8_t        type;
134144330Ssos#define ADP_T_RAID0             0x00
135144330Ssos#define ADP_T_RAID1             0x01
136144330Ssos	u_int8_t        dummy_1;
137144330Ssos	u_int8_t        flags;
13867071Ssos
139144330Ssos	u_int8_t        dummy_2;
140144330Ssos	u_int8_t        dummy_3;
141144330Ssos	u_int8_t        dummy_4;
142144330Ssos	u_int8_t        dummy_5;
14367071Ssos
144144330Ssos	u_int32_t       disk_number;
145144330Ssos	u_int32_t       dummy_6;
146144330Ssos	u_int32_t       sectors;
147144330Ssos	u_int16_t       stripe_shift;
148144330Ssos	u_int16_t       dummy_7;
14967071Ssos
150144330Ssos	u_int32_t       dummy_8[4];
151144330Ssos	u_int8_t        name[16];
152144936Ssos    } configs[127];
153144936Ssos    u_int32_t           dummy_6[13];
154144330Ssos    u_int32_t           magic_1;
155144330Ssos#define ADP_MAGIC_1             0x9ff85009
156144330Ssos    u_int32_t           dummy_7[3];
157144330Ssos    u_int32_t           magic_2;
158144330Ssos    u_int32_t           dummy_8[46];
159144330Ssos    u_int32_t           magic_3;
160144330Ssos#define ADP_MAGIC_3             0x4d545044
161144330Ssos    u_int32_t           magic_4;
162144330Ssos#define ADP_MAGIC_4             0x9ff85009
163144330Ssos    u_int32_t           dummy_9[62];
164144330Ssos} __packed;
165144330Ssos
166144330Ssos
167144330Ssos/* Highpoint V2 RocketRAID Metadata */
168144330Ssos#define HPTV2_LBA(dev)  9
169144330Ssos
170144330Ssosstruct hptv2_raid_conf {
171144330Ssos    int8_t              filler1[32];
172144330Ssos    u_int32_t           magic;
173144330Ssos#define HPTV2_MAGIC_OK          0x5a7816f0
174144330Ssos#define HPTV2_MAGIC_BAD         0x5a7816fd
175144330Ssos
176144330Ssos    u_int32_t           magic_0;
177144330Ssos    u_int32_t           magic_1;
178144330Ssos    u_int32_t           order;
179144330Ssos#define HPTV2_O_RAID0           0x01
180144330Ssos#define HPTV2_O_RAID1           0x02
181144330Ssos#define HPTV2_O_OK              0x04
182144330Ssos
183144330Ssos    u_int8_t            array_width;
184144330Ssos    u_int8_t            stripe_shift;
185144330Ssos    u_int8_t            type;
186144330Ssos#define HPTV2_T_RAID0           0x00
187144330Ssos#define HPTV2_T_RAID1           0x01
188144330Ssos#define HPTV2_T_RAID01_RAID0    0x02
189144330Ssos#define HPTV2_T_SPAN            0x03
190144330Ssos#define HPTV2_T_RAID_3          0x04
191144330Ssos#define HPTV2_T_RAID_5          0x05
192144330Ssos#define HPTV2_T_JBOD            0x06
193144330Ssos#define HPTV2_T_RAID01_RAID1    0x07
194144330Ssos
195144330Ssos    u_int8_t            disk_number;
196144330Ssos    u_int32_t           total_sectors;
197144330Ssos    u_int32_t           disk_mode;
198144330Ssos    u_int32_t           boot_mode;
199144330Ssos    u_int8_t            boot_disk;
200144330Ssos    u_int8_t            boot_protect;
201144330Ssos    u_int8_t            error_log_entries;
202144330Ssos    u_int8_t            error_log_index;
20367071Ssos    struct {
204144330Ssos	u_int32_t       timestamp;
205144330Ssos	u_int8_t        reason;
206144330Ssos#define HPTV2_R_REMOVED         0xfe
207144330Ssos#define HPTV2_R_BROKEN          0xff
20867071Ssos
209144330Ssos	u_int8_t        disk;
210144330Ssos	u_int8_t        status;
211144330Ssos	u_int8_t        sectors;
212144330Ssos	u_int32_t       lba;
21367071Ssos    } errorlog[32];
214144330Ssos    int8_t              filler2[16];
215144330Ssos    u_int32_t           rebuild_lba;
216144330Ssos    u_int8_t            dummy_1;
217144330Ssos    u_int8_t            name_1[15];
218144330Ssos    u_int8_t            dummy_2;
219144330Ssos    u_int8_t            name_2[15];
220144330Ssos    int8_t              filler3[8];
221103870Salfred} __packed;
22267071Ssos
22390566Ssos
224144330Ssos/* Highpoint V3 RocketRAID Metadata */
225144330Ssos#define HPTV3_LBA(dev) \
226144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 11)
227131113Ssos
228144330Ssosstruct hptv3_raid_conf {
229144330Ssos    u_int32_t           magic;
230144330Ssos#define HPTV3_MAGIC             0x5a7816f3
231131113Ssos
232144330Ssos    u_int32_t           magic_0;
233144330Ssos    u_int8_t            checksum_0;
234144330Ssos    u_int8_t            mode;
235144330Ssos#define HPTV3_BOOT_MARK         0x01
236144330Ssos#define HPTV3_USER_MODE         0x02
237144330Ssos
238144330Ssos    u_int8_t            user_mode;
239144330Ssos    u_int8_t            config_entries;
240144330Ssos    struct {
241144330Ssos	u_int32_t       total_sectors;
242144330Ssos	u_int8_t        type;
243144330Ssos#define HPTV3_T_SPARE           0x00
244144330Ssos#define HPTV3_T_JBOD            0x03
245144330Ssos#define HPTV3_T_SPAN            0x04
246144330Ssos#define HPTV3_T_RAID0           0x05
247144330Ssos#define HPTV3_T_RAID1           0x06
248144330Ssos#define HPTV3_T_RAID3           0x07
249144330Ssos#define HPTV3_T_RAID5           0x08
250131113Ssos
251144330Ssos	u_int8_t        total_disks;
252144330Ssos	u_int8_t        disk_number;
253144330Ssos	u_int8_t        stripe_shift;
254144330Ssos	u_int16_t       status;
255144330Ssos#define HPTV3_T_NEED_REBUILD    0x01
256144330Ssos#define HPTV3_T_RAID5_FLAG      0x02
257144330Ssos
258144330Ssos	u_int16_t       critical_disks;
259144330Ssos	u_int32_t       rebuild_lba;
260144330Ssos    } __packed configs[2];
261144330Ssos    u_int8_t            name[16];
262144330Ssos    u_int32_t           timestamp;
263144330Ssos    u_int8_t            description[64];
264144330Ssos    u_int8_t            creator[16];
265144330Ssos    u_int8_t            checksum_1;
266144330Ssos    u_int8_t            dummy_0;
267144330Ssos    u_int8_t            dummy_1;
268144330Ssos    u_int8_t            flags;
269144330Ssos#define HPTV3_T_ENABLE_TCQ      0x01
270144330Ssos#define HPTV3_T_ENABLE_NCQ      0x02
271144330Ssos#define HPTV3_T_ENABLE_WCACHE   0x04
272144330Ssos#define HPTV3_T_ENABLE_RCACHE   0x08
273144330Ssos
274144330Ssos    struct {
275144330Ssos	u_int32_t       total_sectors;
276144330Ssos	u_int32_t       rebuild_lba;
277144330Ssos    } __packed configs_high[2];
278144330Ssos    u_int32_t           filler[87];
279144330Ssos} __packed;
280144330Ssos
281144330Ssos
282144330Ssos/* Intel MatrixRAID Metadata */
283144330Ssos#define INTEL_LBA(dev) \
284153015Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 3)
285144330Ssos
286144330Ssosstruct intel_raid_conf {
287144330Ssos    u_int8_t            intel_id[24];
288145713Ssos#define INTEL_MAGIC             "Intel Raid ISM Cfg Sig. "
289144330Ssos
290144330Ssos    u_int8_t            version[6];
291144330Ssos    u_int8_t            dummy_0[2];
292144330Ssos    u_int32_t           checksum;
293144330Ssos    u_int32_t           config_size;
294144330Ssos    u_int32_t           config_id;
295144330Ssos    u_int32_t           generation;
296144330Ssos    u_int32_t           dummy_1[2];
297144330Ssos    u_int8_t            total_disks;
298144330Ssos    u_int8_t            total_volumes;
299144330Ssos    u_int8_t            dummy_2[2];
300144330Ssos    u_int32_t           filler_0[39];
301144330Ssos    struct {
302144330Ssos	u_int8_t        serial[16];
303144330Ssos	u_int32_t       sectors;
304144330Ssos	u_int32_t       id;
305144330Ssos	u_int32_t       flags;
306144330Ssos#define INTEL_F_SPARE           0x01
307144330Ssos#define INTEL_F_ASSIGNED        0x02
308144330Ssos#define INTEL_F_DOWN            0x04
309144330Ssos#define INTEL_F_ONLINE          0x08
310144330Ssos
311144330Ssos	u_int32_t       filler[5];
312144330Ssos    } __packed disk[1];
313144330Ssos    u_int32_t           filler_1[62];
314144330Ssos} __packed;
315144330Ssos
316144330Ssosstruct intel_raid_mapping {
317144330Ssos    u_int8_t            name[16];
318144330Ssos    u_int64_t           total_sectors __packed;
319144330Ssos    u_int32_t           state;
320144330Ssos    u_int32_t           reserved;
321144330Ssos    u_int32_t           filler_1[20];
322144330Ssos    u_int32_t           offset;
323144330Ssos    u_int32_t           disk_sectors;
324144330Ssos    u_int32_t           stripe_count;
325144330Ssos    u_int16_t           stripe_sectors;
326144330Ssos    u_int8_t            status;
327144330Ssos#define INTEL_S_READY           0x00
328144330Ssos#define INTEL_S_DISABLED        0x01
329144330Ssos#define INTEL_S_DEGRADED        0x02
330144330Ssos#define INTEL_S_FAILURE         0x03
331144330Ssos
332144330Ssos    u_int8_t            type;
333144330Ssos#define INTEL_T_RAID0           0x00
334144330Ssos#define INTEL_T_RAID1           0x01
335153015Ssos#define INTEL_T_RAID5           0x05
336144330Ssos
337144330Ssos    u_int8_t            total_disks;
338144330Ssos    u_int8_t            dummy_2[3];
339144330Ssos    u_int32_t           filler_2[7];
340144330Ssos    u_int32_t           disk_idx[1];
341144330Ssos} __packed;
342144330Ssos
343144330Ssos
344144330Ssos/* Integrated Technology Express Metadata */
345144330Ssos#define ITE_LBA(dev) \
346144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
347144330Ssos
348144330Ssosstruct ite_raid_conf {
349144330Ssos    u_int32_t           filler_1[5];
350144936Ssos    u_int8_t            timestamp_0[8];
351144330Ssos    u_int32_t           dummy_1;
352144330Ssos    u_int32_t           filler_2[5];
353144330Ssos    u_int16_t           filler_3;
354144936Ssos    u_int8_t            ite_id[40];
355145713Ssos#define ITE_MAGIC               "Integrated Technology Express Inc      "
356144330Ssos
357144330Ssos    u_int16_t           filler_4;
358144330Ssos    u_int32_t           filler_5[6];
359144330Ssos    u_int32_t           dummy_2;
360144330Ssos    u_int32_t           dummy_3;
361144330Ssos    u_int32_t           filler_6[12];
362144330Ssos    u_int32_t           dummy_4;
363144330Ssos    u_int32_t           filler_7[5];
364144330Ssos    u_int64_t           total_sectors __packed;
365144330Ssos    u_int32_t           filler_8[12];
366144330Ssos
367144936Ssos    u_int16_t           filler_9;
368144330Ssos    u_int8_t            type;
369144330Ssos#define ITE_T_RAID0             0x00
370144330Ssos#define ITE_T_RAID1             0x01
371144330Ssos#define ITE_T_RAID01            0x02
372144330Ssos#define ITE_T_SPAN              0x03
373144330Ssos
374144330Ssos    u_int8_t            filler_10;
375144330Ssos    u_int32_t           dummy_5[8];
376144330Ssos    u_int8_t            stripe_1kblocks;
377144330Ssos    u_int8_t            filler_11[3];
378144330Ssos    u_int32_t           filler_12[54];
379144330Ssos
380144936Ssos    u_int32_t           dummy_6[4];
381144936Ssos    u_int8_t            timestamp_1[8];
382144330Ssos    u_int32_t           filler_13[9];
383144330Ssos    u_int8_t            stripe_sectors;
384144330Ssos    u_int8_t            filler_14[3];
385144330Ssos    u_int8_t            array_width;
386144330Ssos    u_int8_t            filler_15[3];
387144330Ssos    u_int32_t           filler_16;
388144330Ssos    u_int8_t            filler_17;
389144330Ssos    u_int8_t            disk_number;
390144330Ssos    u_int32_t           disk_sectors;
391144330Ssos    u_int16_t           filler_18;
392144330Ssos    u_int32_t           dummy_7[4];
393144330Ssos    u_int32_t           filler_20[104];
394144330Ssos} __packed;
395144330Ssos
396144330Ssos
397144330Ssos/* LSILogic V2 MegaRAID Metadata */
398144330Ssos#define LSIV2_LBA(dev) \
399144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
400144330Ssos
401144330Ssosstruct lsiv2_raid_conf {
402144330Ssos    u_int8_t            lsi_id[6];
403145713Ssos#define LSIV2_MAGIC             "$XIDE$"
404144330Ssos
405144330Ssos    u_int8_t            dummy_0;
406144330Ssos    u_int8_t            flags;
407144330Ssos    u_int16_t           version;
408144330Ssos    u_int8_t            config_entries;
409144330Ssos    u_int8_t            raid_count;
410144330Ssos    u_int8_t            total_disks;
411144330Ssos    u_int8_t            dummy_1;
412144330Ssos    u_int16_t           dummy_2;
413144330Ssos
414131113Ssos    union {
415131113Ssos	struct {
416144330Ssos	    u_int8_t    type;
417144330Ssos#define LSIV2_T_RAID0           0x01
418144330Ssos#define LSIV2_T_RAID1           0x02
419144330Ssos#define LSIV2_T_SPARE           0x08
420131113Ssos
421144330Ssos	    u_int8_t    dummy_0;
422144330Ssos	    u_int16_t   stripe_sectors;
423144330Ssos	    u_int8_t    array_width;
424144330Ssos	    u_int8_t    disk_count;
425144330Ssos	    u_int8_t    config_offset;
426144330Ssos	    u_int8_t    dummy_1;
427144330Ssos	    u_int8_t    flags;
428144330Ssos#define LSIV2_R_DEGRADED        0x02
429131113Ssos
430144330Ssos	    u_int32_t   total_sectors;
431144330Ssos	    u_int8_t    filler[3];
432131113Ssos	} __packed raid;
433131113Ssos	struct {
434144330Ssos	    u_int8_t    device;
435144330Ssos#define LSIV2_D_MASTER          0x00
436144330Ssos#define LSIV2_D_SLAVE           0x01
437144330Ssos#define LSIV2_D_CHANNEL0        0x00
438144330Ssos#define LSIV2_D_CHANNEL1        0x10
439144330Ssos#define LSIV2_D_NONE            0xff
440131113Ssos
441144330Ssos	    u_int8_t    dummy_0;
442144330Ssos	    u_int32_t   disk_sectors;
443144330Ssos	    u_int8_t    disk_number;
444144330Ssos	    u_int8_t    raid_number;
445144330Ssos	    u_int8_t    flags;
446144330Ssos#define LSIV2_D_GONE            0x02
447131113Ssos
448144330Ssos	    u_int8_t    filler[7];
449131113Ssos	} __packed disk;
450131113Ssos    } configs[30];
451144330Ssos    u_int8_t            disk_number;
452144330Ssos    u_int8_t            raid_number;
453144330Ssos    u_int32_t           timestamp;
454144330Ssos    u_int8_t            filler[10];
455131113Ssos} __packed;
456131113Ssos
457131113Ssos
458144330Ssos/* LSILogic V3 MegaRAID Metadata */
459144330Ssos#define LSIV3_LBA(dev) \
460144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 4)
46190215Ssos
462144330Ssosstruct lsiv3_raid_conf {
463144330Ssos    u_int32_t           magic_0;        /* 0xa0203200 */
464144330Ssos    u_int32_t           filler_0[3];
465144330Ssos    u_int8_t            magic_1[4];     /* "SATA" */
466144330Ssos    u_int32_t           filler_1[40];
467144330Ssos    u_int32_t           dummy_0;        /* 0x0d000003 */
468144330Ssos    u_int32_t           filler_2[7];
469144330Ssos    u_int32_t           dummy_1;        /* 0x0d000003 */
470144330Ssos    u_int32_t           filler_3[70];
471144330Ssos    u_int8_t            magic_2[8];     /* "$_ENQ$31" */
472144330Ssos    u_int8_t            filler_4[7];
473144330Ssos    u_int8_t            checksum_0;
474144330Ssos    u_int8_t            filler_5[512*2];
475144330Ssos    u_int8_t            lsi_id[6];
476145713Ssos#define LSIV3_MAGIC             "$_IDE$"
477144330Ssos
478144330Ssos    u_int16_t           dummy_2;        /* 0x33de for OK disk */
479144330Ssos    u_int16_t           version;        /* 0x0131 for this version */
480144330Ssos    u_int16_t           dummy_3;        /* 0x0440 always */
481144330Ssos    u_int32_t           filler_6;
482144330Ssos
483144330Ssos    struct {
484144330Ssos	u_int16_t       stripe_pages;
485144330Ssos	u_int8_t        type;
486144330Ssos#define LSIV3_T_RAID0           0x00
487144330Ssos#define LSIV3_T_RAID1           0x01
488144330Ssos
489144330Ssos	u_int8_t        dummy_0;
490144330Ssos	u_int8_t        total_disks;
491144330Ssos	u_int8_t        array_width;
492144330Ssos	u_int8_t        filler_0[10];
493144330Ssos
494144330Ssos	u_int32_t       sectors;
495144330Ssos	u_int16_t       dummy_1;
496144330Ssos	u_int32_t       offset;
497144330Ssos	u_int16_t       dummy_2;
498144330Ssos	u_int8_t        device;
499144330Ssos#define LSIV3_D_DEVICE          0x01
500144330Ssos#define LSIV3_D_CHANNEL         0x10
501144330Ssos
502144330Ssos	u_int8_t        dummy_3;
503144330Ssos	u_int8_t        dummy_4;
504144330Ssos	u_int8_t        dummy_5;
505144330Ssos	u_int8_t        filler_1[16];
506144330Ssos    } __packed raid[8];
507144330Ssos    struct {
508144330Ssos	u_int32_t       disk_sectors;
509144330Ssos	u_int32_t       dummy_0;
510144330Ssos	u_int32_t       dummy_1;
511144330Ssos	u_int8_t        dummy_2;
512144330Ssos	u_int8_t        dummy_3;
513144330Ssos	u_int8_t        flags;
514144330Ssos#define LSIV3_D_MIRROR          0x00
515144330Ssos#define LSIV3_D_STRIPE          0xff
516144330Ssos	u_int8_t        dummy_4;
517144330Ssos    } __packed disk[6];
518144330Ssos    u_int8_t            filler_7[7];
519144330Ssos    u_int8_t            device;
520144330Ssos    u_int32_t           timestamp;
521144330Ssos    u_int8_t            filler_8[3];
522144330Ssos    u_int8_t            checksum_1;
523144330Ssos} __packed;
524144330Ssos
525144330Ssos
526147052Ssos/* nVidia MediaShield Metadata */
527147052Ssos#define NVIDIA_LBA(dev) \
528147052Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
529147052Ssos
530147052Ssosstruct nvidia_raid_conf {
531147052Ssos    u_int8_t            nvidia_id[8];
532147052Ssos#define NV_MAGIC                "NVIDIA  "
533147052Ssos
534147052Ssos    u_int32_t           config_size;
535147052Ssos    u_int32_t           checksum;
536147052Ssos    u_int16_t           version;
537147052Ssos    u_int8_t            disk_number;
538147052Ssos    u_int8_t            dummy_0;
539147052Ssos    u_int32_t           total_sectors;
540147052Ssos    u_int32_t           sector_size;
541147052Ssos    u_int8_t            serial[16];
542147052Ssos    u_int8_t            revision[4];
543147052Ssos    u_int32_t           dummy_1;
544147052Ssos
545147052Ssos    u_int32_t           magic_0;
546147052Ssos#define NV_MAGIC0               0x00640044
547147052Ssos
548147052Ssos    u_int64_t           magic_1;
549147052Ssos    u_int64_t           magic_2;
550147052Ssos    u_int8_t            flags;
551147052Ssos    u_int8_t            array_width;
552147052Ssos    u_int8_t            total_disks;
553147052Ssos    u_int8_t            dummy_2;
554147052Ssos    u_int16_t           type;
555147052Ssos#define NV_T_RAID0              0x00000080
556147052Ssos#define NV_T_RAID1              0x00000081
557147052Ssos#define NV_T_RAID3              0x00000083
558147052Ssos#define NV_T_RAID5              0x00000085
559147052Ssos#define NV_T_RAID01             0x00008180
560147052Ssos#define NV_T_SPAN               0x000000ff
561147052Ssos
562147052Ssos    u_int16_t           dummy_3;
563147052Ssos    u_int32_t           stripe_sectors;
564147052Ssos    u_int32_t           stripe_bytes;
565147052Ssos    u_int32_t           stripe_shift;
566147052Ssos    u_int32_t           stripe_mask;
567147052Ssos    u_int32_t           stripe_sizesectors;
568147052Ssos    u_int32_t           stripe_sizebytes;
569147052Ssos    u_int32_t           rebuild_lba;
570147052Ssos    u_int32_t           dummy_4;
571147052Ssos    u_int32_t           dummy_5;
572147052Ssos    u_int32_t           status;
573147052Ssos#define NV_S_BOOTABLE           0x00000001
574147052Ssos#define NV_S_DEGRADED           0x00000002
575147052Ssos
576147052Ssos    u_int32_t           filler[98];
577147052Ssos} __packed;
578147052Ssos
579147052Ssos
580144330Ssos/* Promise FastTrak Metadata */
581144330Ssos#define PR_LBA(dev) \
582145760Ssos	(((((struct ad_softc *)device_get_ivars(dev))->total_secs / (((struct ad_softc *)device_get_ivars(dev))->heads * ((struct ad_softc *)device_get_ivars(dev))->sectors)) * ((struct ad_softc *)device_get_ivars(dev))->heads * ((struct ad_softc *)device_get_ivars(dev))->sectors) - ((struct ad_softc *)device_get_ivars(dev))->sectors)
583144330Ssos
58467071Ssosstruct promise_raid_conf {
585144330Ssos    char                promise_id[24];
586145713Ssos#define PR_MAGIC                "Promise Technology, Inc."
58767071Ssos
588144330Ssos    u_int32_t           dummy_0;
589144330Ssos    u_int64_t           magic_0;
590145713Ssos#define PR_MAGIC0(x)            (((u_int64_t)(x.channel) << 48) | \
591144936Ssos				((u_int64_t)(x.device != 0) << 56))
592144330Ssos    u_int16_t           magic_1;
593144330Ssos    u_int32_t           magic_2;
594144330Ssos    u_int8_t            filler1[470];
59567071Ssos    struct {
596144330Ssos	u_int32_t       integrity;
597144330Ssos#define PR_I_VALID              0x00000080
59890215Ssos
599144330Ssos	u_int8_t        flags;
600144330Ssos#define PR_F_VALID              0x00000001
601144330Ssos#define PR_F_ONLINE             0x00000002
602144330Ssos#define PR_F_ASSIGNED           0x00000004
603144330Ssos#define PR_F_SPARE              0x00000008
604144330Ssos#define PR_F_DUPLICATE          0x00000010
605144330Ssos#define PR_F_REDIR              0x00000020
606144330Ssos#define PR_F_DOWN               0x00000040
607144330Ssos#define PR_F_READY              0x00000080
60867071Ssos
609144330Ssos	u_int8_t        disk_number;
610144330Ssos	u_int8_t        channel;
611144330Ssos	u_int8_t        device;
612144330Ssos	u_int64_t       magic_0 __packed;
613144330Ssos	u_int32_t       disk_offset;
614144330Ssos	u_int32_t       disk_sectors;
615144330Ssos	u_int32_t       rebuild_lba;
616144330Ssos	u_int16_t       generation;
617144330Ssos	u_int8_t        status;
618144330Ssos#define PR_S_VALID              0x01
619144330Ssos#define PR_S_ONLINE             0x02
620144330Ssos#define PR_S_INITED             0x04
621144330Ssos#define PR_S_READY              0x08
622144330Ssos#define PR_S_DEGRADED           0x10
623144330Ssos#define PR_S_MARKED             0x20
624144330Ssos#define PR_S_FUNCTIONAL         0x80
62567071Ssos
626144330Ssos	u_int8_t        type;
627144330Ssos#define PR_T_RAID0              0x00
628144330Ssos#define PR_T_RAID1              0x01
629144330Ssos#define PR_T_RAID3              0x02
630144330Ssos#define PR_T_RAID5              0x04
631144330Ssos#define PR_T_SPAN               0x08
632144330Ssos#define PR_T_JBOD               0x10
63367071Ssos
634144330Ssos	u_int8_t        total_disks;
635144330Ssos	u_int8_t        stripe_shift;
636144330Ssos	u_int8_t        array_width;
637144330Ssos	u_int8_t        array_number;
638144330Ssos	u_int32_t       total_sectors;
639144330Ssos	u_int16_t       cylinders;
640144330Ssos	u_int8_t        heads;
641144330Ssos	u_int8_t        sectors;
642144330Ssos	u_int64_t       magic_1 __packed;
643131113Ssos	struct {
644144330Ssos	    u_int8_t    flags;
645144330Ssos	    u_int8_t    dummy_0;
646144330Ssos	    u_int8_t    channel;
647144330Ssos	    u_int8_t    device;
648144330Ssos	    u_int64_t   magic_0 __packed;
64967071Ssos	} disk[8];
65068183Ssos    } raid;
651144330Ssos    int32_t             filler2[346];
652144330Ssos    u_int32_t           checksum;
653103870Salfred} __packed;
65467071Ssos
655144330Ssos
656144330Ssos/* Silicon Image Medley Metadata */
657144330Ssos#define SII_LBA(dev) \
658144330Ssos	( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
659144330Ssos
660144330Ssosstruct sii_raid_conf {
661152908Ssos    u_int16_t   	ata_params_00_53[54];
662152908Ssos    u_int64_t   	total_sectors;
663152908Ssos    u_int16_t   	ata_params_58_79[70];
664152908Ssos    u_int16_t   	dummy_0;
665152908Ssos    u_int16_t   	dummy_1;
666152908Ssos    u_int32_t   	controller_pci_id;
667152908Ssos    u_int16_t   	version_minor;
668152908Ssos    u_int16_t   	version_major;
669152908Ssos    u_int8_t    	timestamp[6];
670152908Ssos    u_int16_t   	stripe_sectors;
671152908Ssos    u_int16_t   	dummy_2;
672152908Ssos    u_int8_t    	disk_number;
673152908Ssos    u_int8_t    	type;
674144330Ssos#define SII_T_RAID0             0x00
675144330Ssos#define SII_T_RAID1             0x01
676144330Ssos#define SII_T_RAID01            0x02
677144330Ssos#define SII_T_SPARE             0x03
678144330Ssos
679152908Ssos    u_int8_t    	raid0_disks;
680152908Ssos    u_int8_t    	raid0_ident;
681152908Ssos    u_int8_t    	raid1_disks;
682152908Ssos    u_int8_t    	raid1_ident;
683152908Ssos    u_int64_t   	rebuild_lba;
684152908Ssos    u_int32_t   	generation;
685152908Ssos    u_int8_t    	status;
686144330Ssos#define SII_S_READY             0x01
687144330Ssos
688152908Ssos    u_int8_t    	base_raid1_position;
689152908Ssos    u_int8_t    	base_raid0_position;
690152908Ssos    u_int8_t    	position;
691152908Ssos    u_int16_t   	dummy_3;
692152908Ssos    u_int8_t    	name[16];
693152908Ssos    u_int16_t   	checksum_0;
694152908Ssos    int8_t      	filler1[190];
695152908Ssos    u_int16_t   	checksum_1;
696144330Ssos} __packed;
697144936Ssos
698144936Ssos
699152908Ssos/* Silicon Integrated Systems RAID Metadata */
700152908Ssos#define SIS_LBA(dev) \
701152908Ssos	( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 16)
702152908Ssos
703152908Ssosstruct sis_raid_conf {
704152908Ssos    u_int16_t   	magic;
705152908Ssos#define SIS_MAGIC               0x0010
706152908Ssos
707152908Ssos    u_int8_t		disks;
708152908Ssos#define SIS_D_MASTER          	0xf0
709152908Ssos#define SIS_D_MIRROR          	0x0f
710152908Ssos
711152908Ssos    u_int8_t		type_total_disks;
712152908Ssos#define SIS_D_MASK          	0x0f
713152908Ssos#define SIS_T_MASK              0xf0
714152908Ssos#define SIS_T_JBOD              0x10
715152908Ssos#define SIS_T_RAID0         	0x20
716152908Ssos#define SIS_T_RAID1             0x30
717152908Ssos
718152908Ssos    u_int32_t   	dummy_0;
719152908Ssos    u_int32_t   	controller_pci_id;
720152908Ssos    u_int16_t   	stripe_sectors;
721152908Ssos    u_int16_t   	dummy_1;
722152908Ssos    u_int32_t   	timestamp;
723152908Ssos    u_int8_t		model[40];
724152908Ssos    u_int8_t		disk_number;
725152908Ssos    u_int8_t		dummy_2[3];
726152908Ssos    int8_t      	filler1[448];
727152908Ssos} __packed;
728152908Ssos
729152908Ssos
730144940Ssos/* VIA Tech V-RAID Metadata */
731144936Ssos#define VIA_LBA(dev) \
732144936Ssos	( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
733144936Ssos
734144936Ssosstruct via_raid_conf {
735152908Ssos    u_int16_t   	magic;
736145713Ssos#define VIA_MAGIC               0xaa55
737144936Ssos
738152908Ssos    u_int8_t    	dummy_0;
739152908Ssos    u_int8_t    	type;
740145713Ssos#define VIA_T_MASK              0xfe
741145713Ssos#define VIA_T_BOOTABLE          0x01
742145713Ssos#define VIA_T_RAID0             0x04
743145713Ssos#define VIA_T_RAID1             0x0c
744145713Ssos#define VIA_T_SPAN              0x44
745144936Ssos
746152908Ssos    u_int8_t    	disk_index;
747149823Ssos#define VIA_D_MASK		0x0f
748149823Ssos#define VIA_D_DEGRADED		0x10
749149823Ssos
750152908Ssos    u_int8_t    	stripe_layout;
751145713Ssos#define VIA_L_MASK              0x07
752145713Ssos#define VIA_L_SHIFT             4
753144936Ssos
754152908Ssos    u_int64_t   	total_sectors;
755152908Ssos    u_int32_t   	disk_id;
756152908Ssos    u_int32_t   	disks[8];
757152908Ssos    u_int8_t    	checksum;
758152908Ssos    u_int8_t    	filler_1[461];
759144936Ssos} __packed;
760