ata-raid.h revision 153416
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 153416 2005-12-14 13:07:49Z sos $
2967071Ssos */
3067071Ssos
3191816Ssos/* misc defines */
32144330Ssos#define MAX_ARRAYS      16
33153117Ssos#define MAX_VOLUMES     4
34144330Ssos#define MAX_DISKS       16
35144330Ssos#define AR_PROXIMITY    2048    /* how many sectors is "close" */
3691816Ssos
37144330Ssos#define ATA_MAGIC       "FreeBSD ATA driver RAID "
38144330Ssos
39144330Ssosstruct ata_raid_subdisk {
40153117Ssos    struct ar_softc     *raid[MAX_VOLUMES];
41153117Ssos    int                 disk_number[MAX_VOLUMES];
4290215Ssos};
4390215Ssos
44144330Ssos/*  ATA PseudoRAID Metadata */
4567071Ssosstruct ar_softc {
46153117Ssos    int                 lun;
47153117Ssos    u_int8_t            name[32];
48153117Ssos    int			volume;
49153117Ssos    u_int64_t           magic_0;
50153117Ssos    u_int64_t           magic_1;
51144330Ssos    int                 type;
52144330Ssos#define AR_T_JBOD               0x0001
53144330Ssos#define AR_T_SPAN               0x0002
54144330Ssos#define AR_T_RAID0              0x0004
55144330Ssos#define AR_T_RAID1              0x0008
56144330Ssos#define AR_T_RAID01             0x0010
57144330Ssos#define AR_T_RAID3              0x0020
58144330Ssos#define AR_T_RAID4              0x0040
59144330Ssos#define AR_T_RAID5              0x0080
60131113Ssos
61144330Ssos    int                 status;
62144330Ssos#define AR_S_READY              0x0001
63144330Ssos#define AR_S_DEGRADED           0x0002
64144330Ssos#define AR_S_REBUILDING         0x0004
65131113Ssos
66144330Ssos    int                 format;
67144330Ssos#define AR_F_FREEBSD_RAID       0x0001
68144330Ssos#define AR_F_ADAPTEC_RAID       0x0002
69144330Ssos#define AR_F_HPTV2_RAID         0x0004
70144330Ssos#define AR_F_HPTV3_RAID         0x0008
71144330Ssos#define AR_F_INTEL_RAID         0x0010
72144330Ssos#define AR_F_ITE_RAID           0x0020
73144330Ssos#define AR_F_LSIV2_RAID         0x0040
74144330Ssos#define AR_F_LSIV3_RAID         0x0080
75147052Ssos#define AR_F_NVIDIA_RAID        0x0100
76147052Ssos#define AR_F_PROMISE_RAID       0x0200
77147052Ssos#define AR_F_SII_RAID           0x0400
78152908Ssos#define AR_F_SIS_RAID           0x0800
79152908Ssos#define AR_F_VIA_RAID           0x1000
80152908Ssos#define AR_F_FORMAT_MASK        0x1fff
81131113Ssos
82153117Ssos    u_int               generation;
83144330Ssos    u_int64_t           total_sectors;
84144330Ssos    u_int64_t           offset_sectors; /* offset from start of disk */
85144330Ssos    u_int16_t           heads;
86144330Ssos    u_int16_t           sectors;
87144330Ssos    u_int32_t           cylinders;
88144330Ssos    u_int               width;          /* array width in disks */
89153117Ssos    u_int               interleave;     /* interleave in sectors */
90144330Ssos    u_int               total_disks;    /* number of disks in this array */
91144330Ssos    struct ar_disk {
92144330Ssos	device_t        dev;
93144330Ssos	u_int8_t        serial[16];     /* serial # of physical disk */
94144330Ssos	u_int64_t       sectors;        /* useable sectors on this disk */
95144330Ssos	off_t           last_lba;       /* last lba used (for performance) */
96144330Ssos	u_int           flags;
97144330Ssos#define AR_DF_PRESENT           0x0001  /* this HW pos has a disk present */
98144330Ssos#define AR_DF_ASSIGNED          0x0002  /* this HW pos assigned to an array */
99144330Ssos#define AR_DF_SPARE             0x0004  /* this HW pos is a spare */
100144330Ssos#define AR_DF_ONLINE            0x0008  /* this HW pos is online and in use */
10167071Ssos
102144330Ssos    } disks[MAX_DISKS];
103144330Ssos    int                 toggle;         /* performance hack for RAID1's */
104144330Ssos    u_int64_t           rebuild_lba;    /* rebuild progress indicator */
105144330Ssos    struct mtx          lock;           /* metadata lock */
106144330Ssos    struct disk         *disk;          /* disklabel/slice stuff */
107144330Ssos    struct proc         *pid;           /* rebuilder process id */
10867071Ssos};
10967071Ssos
110144330Ssos/* Adaptec HostRAID Metadata */
111144330Ssos#define ADP_LBA(dev) \
112144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 17)
113131113Ssos
114144330Ssos/* note all entries are big endian */
115144330Ssosstruct adaptec_raid_conf {
116144936Ssos    u_int32_t           magic_0;
117144330Ssos#define ADP_MAGIC_0             0xc4650790
11890215Ssos
119144330Ssos    u_int32_t           generation;
120144330Ssos    u_int16_t           dummy_0;
121144330Ssos    u_int16_t           total_configs;
122144330Ssos    u_int16_t           dummy_1;
123144330Ssos    u_int16_t           checksum;
124144936Ssos    u_int32_t           dummy_2;
125144330Ssos    u_int32_t           dummy_3;
126144330Ssos    u_int32_t           flags;
127144330Ssos    u_int32_t           timestamp;
128144936Ssos    u_int32_t           dummy_4[4];
129144936Ssos    u_int32_t           dummy_5[4];
130144936Ssos    struct {
131144330Ssos	u_int16_t       total_disks;
132144330Ssos	u_int16_t       generation;
133144330Ssos	u_int32_t       magic_0;
134144330Ssos	u_int8_t        dummy_0;
135144330Ssos	u_int8_t        type;
136144330Ssos#define ADP_T_RAID0             0x00
137144330Ssos#define ADP_T_RAID1             0x01
138144330Ssos	u_int8_t        dummy_1;
139144330Ssos	u_int8_t        flags;
14067071Ssos
141144330Ssos	u_int8_t        dummy_2;
142144330Ssos	u_int8_t        dummy_3;
143144330Ssos	u_int8_t        dummy_4;
144144330Ssos	u_int8_t        dummy_5;
14567071Ssos
146144330Ssos	u_int32_t       disk_number;
147144330Ssos	u_int32_t       dummy_6;
148144330Ssos	u_int32_t       sectors;
149144330Ssos	u_int16_t       stripe_shift;
150144330Ssos	u_int16_t       dummy_7;
15167071Ssos
152144330Ssos	u_int32_t       dummy_8[4];
153144330Ssos	u_int8_t        name[16];
154144936Ssos    } configs[127];
155144936Ssos    u_int32_t           dummy_6[13];
156144330Ssos    u_int32_t           magic_1;
157144330Ssos#define ADP_MAGIC_1             0x9ff85009
158144330Ssos    u_int32_t           dummy_7[3];
159144330Ssos    u_int32_t           magic_2;
160144330Ssos    u_int32_t           dummy_8[46];
161144330Ssos    u_int32_t           magic_3;
162144330Ssos#define ADP_MAGIC_3             0x4d545044
163144330Ssos    u_int32_t           magic_4;
164144330Ssos#define ADP_MAGIC_4             0x9ff85009
165144330Ssos    u_int32_t           dummy_9[62];
166144330Ssos} __packed;
167144330Ssos
168144330Ssos
169144330Ssos/* Highpoint V2 RocketRAID Metadata */
170144330Ssos#define HPTV2_LBA(dev)  9
171144330Ssos
172144330Ssosstruct hptv2_raid_conf {
173144330Ssos    int8_t              filler1[32];
174144330Ssos    u_int32_t           magic;
175144330Ssos#define HPTV2_MAGIC_OK          0x5a7816f0
176144330Ssos#define HPTV2_MAGIC_BAD         0x5a7816fd
177144330Ssos
178144330Ssos    u_int32_t           magic_0;
179144330Ssos    u_int32_t           magic_1;
180144330Ssos    u_int32_t           order;
181144330Ssos#define HPTV2_O_RAID0           0x01
182144330Ssos#define HPTV2_O_RAID1           0x02
183144330Ssos#define HPTV2_O_OK              0x04
184144330Ssos
185144330Ssos    u_int8_t            array_width;
186144330Ssos    u_int8_t            stripe_shift;
187144330Ssos    u_int8_t            type;
188144330Ssos#define HPTV2_T_RAID0           0x00
189144330Ssos#define HPTV2_T_RAID1           0x01
190144330Ssos#define HPTV2_T_RAID01_RAID0    0x02
191144330Ssos#define HPTV2_T_SPAN            0x03
192144330Ssos#define HPTV2_T_RAID_3          0x04
193144330Ssos#define HPTV2_T_RAID_5          0x05
194144330Ssos#define HPTV2_T_JBOD            0x06
195144330Ssos#define HPTV2_T_RAID01_RAID1    0x07
196144330Ssos
197144330Ssos    u_int8_t            disk_number;
198144330Ssos    u_int32_t           total_sectors;
199144330Ssos    u_int32_t           disk_mode;
200144330Ssos    u_int32_t           boot_mode;
201144330Ssos    u_int8_t            boot_disk;
202144330Ssos    u_int8_t            boot_protect;
203144330Ssos    u_int8_t            error_log_entries;
204144330Ssos    u_int8_t            error_log_index;
20567071Ssos    struct {
206144330Ssos	u_int32_t       timestamp;
207144330Ssos	u_int8_t        reason;
208144330Ssos#define HPTV2_R_REMOVED         0xfe
209144330Ssos#define HPTV2_R_BROKEN          0xff
21067071Ssos
211144330Ssos	u_int8_t        disk;
212144330Ssos	u_int8_t        status;
213144330Ssos	u_int8_t        sectors;
214144330Ssos	u_int32_t       lba;
21567071Ssos    } errorlog[32];
216144330Ssos    int8_t              filler2[16];
217144330Ssos    u_int32_t           rebuild_lba;
218144330Ssos    u_int8_t            dummy_1;
219144330Ssos    u_int8_t            name_1[15];
220144330Ssos    u_int8_t            dummy_2;
221144330Ssos    u_int8_t            name_2[15];
222144330Ssos    int8_t              filler3[8];
223103870Salfred} __packed;
22467071Ssos
22590566Ssos
226144330Ssos/* Highpoint V3 RocketRAID Metadata */
227144330Ssos#define HPTV3_LBA(dev) \
228144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 11)
229131113Ssos
230144330Ssosstruct hptv3_raid_conf {
231144330Ssos    u_int32_t           magic;
232144330Ssos#define HPTV3_MAGIC             0x5a7816f3
233131113Ssos
234144330Ssos    u_int32_t           magic_0;
235144330Ssos    u_int8_t            checksum_0;
236144330Ssos    u_int8_t            mode;
237144330Ssos#define HPTV3_BOOT_MARK         0x01
238144330Ssos#define HPTV3_USER_MODE         0x02
239144330Ssos
240144330Ssos    u_int8_t            user_mode;
241144330Ssos    u_int8_t            config_entries;
242144330Ssos    struct {
243144330Ssos	u_int32_t       total_sectors;
244144330Ssos	u_int8_t        type;
245144330Ssos#define HPTV3_T_SPARE           0x00
246144330Ssos#define HPTV3_T_JBOD            0x03
247144330Ssos#define HPTV3_T_SPAN            0x04
248144330Ssos#define HPTV3_T_RAID0           0x05
249144330Ssos#define HPTV3_T_RAID1           0x06
250144330Ssos#define HPTV3_T_RAID3           0x07
251144330Ssos#define HPTV3_T_RAID5           0x08
252131113Ssos
253144330Ssos	u_int8_t        total_disks;
254144330Ssos	u_int8_t        disk_number;
255144330Ssos	u_int8_t        stripe_shift;
256144330Ssos	u_int16_t       status;
257144330Ssos#define HPTV3_T_NEED_REBUILD    0x01
258144330Ssos#define HPTV3_T_RAID5_FLAG      0x02
259144330Ssos
260144330Ssos	u_int16_t       critical_disks;
261144330Ssos	u_int32_t       rebuild_lba;
262144330Ssos    } __packed configs[2];
263144330Ssos    u_int8_t            name[16];
264144330Ssos    u_int32_t           timestamp;
265144330Ssos    u_int8_t            description[64];
266144330Ssos    u_int8_t            creator[16];
267144330Ssos    u_int8_t            checksum_1;
268144330Ssos    u_int8_t            dummy_0;
269144330Ssos    u_int8_t            dummy_1;
270144330Ssos    u_int8_t            flags;
271144330Ssos#define HPTV3_T_ENABLE_TCQ      0x01
272144330Ssos#define HPTV3_T_ENABLE_NCQ      0x02
273144330Ssos#define HPTV3_T_ENABLE_WCACHE   0x04
274144330Ssos#define HPTV3_T_ENABLE_RCACHE   0x08
275144330Ssos
276144330Ssos    struct {
277144330Ssos	u_int32_t       total_sectors;
278144330Ssos	u_int32_t       rebuild_lba;
279144330Ssos    } __packed configs_high[2];
280144330Ssos    u_int32_t           filler[87];
281144330Ssos} __packed;
282144330Ssos
283144330Ssos
284144330Ssos/* Intel MatrixRAID Metadata */
285144330Ssos#define INTEL_LBA(dev) \
286153015Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 3)
287144330Ssos
288144330Ssosstruct intel_raid_conf {
289144330Ssos    u_int8_t            intel_id[24];
290145713Ssos#define INTEL_MAGIC             "Intel Raid ISM Cfg Sig. "
291144330Ssos
292144330Ssos    u_int8_t            version[6];
293153117Ssos#define INTEL_VERSION_1100      "1.1.00"
294153117Ssos#define INTEL_VERSION_1201      "1.2.01"
295153117Ssos#define INTEL_VERSION_1202      "1.2.02"
296153117Ssos
297144330Ssos    u_int8_t            dummy_0[2];
298144330Ssos    u_int32_t           checksum;
299144330Ssos    u_int32_t           config_size;
300144330Ssos    u_int32_t           config_id;
301144330Ssos    u_int32_t           generation;
302144330Ssos    u_int32_t           dummy_1[2];
303144330Ssos    u_int8_t            total_disks;
304144330Ssos    u_int8_t            total_volumes;
305144330Ssos    u_int8_t            dummy_2[2];
306144330Ssos    u_int32_t           filler_0[39];
307144330Ssos    struct {
308144330Ssos	u_int8_t        serial[16];
309144330Ssos	u_int32_t       sectors;
310144330Ssos	u_int32_t       id;
311144330Ssos	u_int32_t       flags;
312144330Ssos#define INTEL_F_SPARE           0x01
313144330Ssos#define INTEL_F_ASSIGNED        0x02
314144330Ssos#define INTEL_F_DOWN            0x04
315144330Ssos#define INTEL_F_ONLINE          0x08
316144330Ssos
317144330Ssos	u_int32_t       filler[5];
318144330Ssos    } __packed disk[1];
319144330Ssos    u_int32_t           filler_1[62];
320144330Ssos} __packed;
321144330Ssos
322144330Ssosstruct intel_raid_mapping {
323144330Ssos    u_int8_t            name[16];
324144330Ssos    u_int64_t           total_sectors __packed;
325144330Ssos    u_int32_t           state;
326144330Ssos    u_int32_t           reserved;
327153117Ssos    u_int32_t           filler_0[20];
328144330Ssos    u_int32_t           offset;
329144330Ssos    u_int32_t           disk_sectors;
330144330Ssos    u_int32_t           stripe_count;
331144330Ssos    u_int16_t           stripe_sectors;
332144330Ssos    u_int8_t            status;
333144330Ssos#define INTEL_S_READY           0x00
334144330Ssos#define INTEL_S_DISABLED        0x01
335144330Ssos#define INTEL_S_DEGRADED        0x02
336144330Ssos#define INTEL_S_FAILURE         0x03
337144330Ssos
338144330Ssos    u_int8_t            type;
339144330Ssos#define INTEL_T_RAID0           0x00
340144330Ssos#define INTEL_T_RAID1           0x01
341153015Ssos#define INTEL_T_RAID5           0x05
342144330Ssos
343144330Ssos    u_int8_t            total_disks;
344153117Ssos    u_int8_t            magic[3];
345153117Ssos    u_int32_t           filler_1[7];
346144330Ssos    u_int32_t           disk_idx[1];
347144330Ssos} __packed;
348144330Ssos
349144330Ssos
350144330Ssos/* Integrated Technology Express Metadata */
351144330Ssos#define ITE_LBA(dev) \
352144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
353144330Ssos
354144330Ssosstruct ite_raid_conf {
355144330Ssos    u_int32_t           filler_1[5];
356144936Ssos    u_int8_t            timestamp_0[8];
357144330Ssos    u_int32_t           dummy_1;
358144330Ssos    u_int32_t           filler_2[5];
359144330Ssos    u_int16_t           filler_3;
360144936Ssos    u_int8_t            ite_id[40];
361145713Ssos#define ITE_MAGIC               "Integrated Technology Express Inc      "
362144330Ssos
363144330Ssos    u_int16_t           filler_4;
364144330Ssos    u_int32_t           filler_5[6];
365144330Ssos    u_int32_t           dummy_2;
366144330Ssos    u_int32_t           dummy_3;
367144330Ssos    u_int32_t           filler_6[12];
368144330Ssos    u_int32_t           dummy_4;
369144330Ssos    u_int32_t           filler_7[5];
370144330Ssos    u_int64_t           total_sectors __packed;
371144330Ssos    u_int32_t           filler_8[12];
372144330Ssos
373144936Ssos    u_int16_t           filler_9;
374144330Ssos    u_int8_t            type;
375144330Ssos#define ITE_T_RAID0             0x00
376144330Ssos#define ITE_T_RAID1             0x01
377144330Ssos#define ITE_T_RAID01            0x02
378144330Ssos#define ITE_T_SPAN              0x03
379144330Ssos
380144330Ssos    u_int8_t            filler_10;
381144330Ssos    u_int32_t           dummy_5[8];
382144330Ssos    u_int8_t            stripe_1kblocks;
383144330Ssos    u_int8_t            filler_11[3];
384144330Ssos    u_int32_t           filler_12[54];
385144330Ssos
386144936Ssos    u_int32_t           dummy_6[4];
387144936Ssos    u_int8_t            timestamp_1[8];
388144330Ssos    u_int32_t           filler_13[9];
389144330Ssos    u_int8_t            stripe_sectors;
390144330Ssos    u_int8_t            filler_14[3];
391144330Ssos    u_int8_t            array_width;
392144330Ssos    u_int8_t            filler_15[3];
393144330Ssos    u_int32_t           filler_16;
394144330Ssos    u_int8_t            filler_17;
395144330Ssos    u_int8_t            disk_number;
396144330Ssos    u_int32_t           disk_sectors;
397144330Ssos    u_int16_t           filler_18;
398144330Ssos    u_int32_t           dummy_7[4];
399144330Ssos    u_int32_t           filler_20[104];
400144330Ssos} __packed;
401144330Ssos
402144330Ssos
403144330Ssos/* LSILogic V2 MegaRAID Metadata */
404144330Ssos#define LSIV2_LBA(dev) \
405144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
406144330Ssos
407144330Ssosstruct lsiv2_raid_conf {
408144330Ssos    u_int8_t            lsi_id[6];
409145713Ssos#define LSIV2_MAGIC             "$XIDE$"
410144330Ssos
411144330Ssos    u_int8_t            dummy_0;
412144330Ssos    u_int8_t            flags;
413144330Ssos    u_int16_t           version;
414144330Ssos    u_int8_t            config_entries;
415144330Ssos    u_int8_t            raid_count;
416144330Ssos    u_int8_t            total_disks;
417144330Ssos    u_int8_t            dummy_1;
418144330Ssos    u_int16_t           dummy_2;
419144330Ssos
420131113Ssos    union {
421131113Ssos	struct {
422144330Ssos	    u_int8_t    type;
423144330Ssos#define LSIV2_T_RAID0           0x01
424144330Ssos#define LSIV2_T_RAID1           0x02
425144330Ssos#define LSIV2_T_SPARE           0x08
426131113Ssos
427144330Ssos	    u_int8_t    dummy_0;
428144330Ssos	    u_int16_t   stripe_sectors;
429144330Ssos	    u_int8_t    array_width;
430144330Ssos	    u_int8_t    disk_count;
431144330Ssos	    u_int8_t    config_offset;
432144330Ssos	    u_int8_t    dummy_1;
433144330Ssos	    u_int8_t    flags;
434144330Ssos#define LSIV2_R_DEGRADED        0x02
435131113Ssos
436144330Ssos	    u_int32_t   total_sectors;
437144330Ssos	    u_int8_t    filler[3];
438131113Ssos	} __packed raid;
439131113Ssos	struct {
440144330Ssos	    u_int8_t    device;
441144330Ssos#define LSIV2_D_MASTER          0x00
442144330Ssos#define LSIV2_D_SLAVE           0x01
443144330Ssos#define LSIV2_D_CHANNEL0        0x00
444144330Ssos#define LSIV2_D_CHANNEL1        0x10
445144330Ssos#define LSIV2_D_NONE            0xff
446131113Ssos
447144330Ssos	    u_int8_t    dummy_0;
448144330Ssos	    u_int32_t   disk_sectors;
449144330Ssos	    u_int8_t    disk_number;
450144330Ssos	    u_int8_t    raid_number;
451144330Ssos	    u_int8_t    flags;
452144330Ssos#define LSIV2_D_GONE            0x02
453131113Ssos
454144330Ssos	    u_int8_t    filler[7];
455131113Ssos	} __packed disk;
456131113Ssos    } configs[30];
457144330Ssos    u_int8_t            disk_number;
458144330Ssos    u_int8_t            raid_number;
459144330Ssos    u_int32_t           timestamp;
460144330Ssos    u_int8_t            filler[10];
461131113Ssos} __packed;
462131113Ssos
463131113Ssos
464144330Ssos/* LSILogic V3 MegaRAID Metadata */
465144330Ssos#define LSIV3_LBA(dev) \
466144330Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 4)
46790215Ssos
468144330Ssosstruct lsiv3_raid_conf {
469144330Ssos    u_int32_t           magic_0;        /* 0xa0203200 */
470144330Ssos    u_int32_t           filler_0[3];
471144330Ssos    u_int8_t            magic_1[4];     /* "SATA" */
472144330Ssos    u_int32_t           filler_1[40];
473144330Ssos    u_int32_t           dummy_0;        /* 0x0d000003 */
474144330Ssos    u_int32_t           filler_2[7];
475144330Ssos    u_int32_t           dummy_1;        /* 0x0d000003 */
476144330Ssos    u_int32_t           filler_3[70];
477144330Ssos    u_int8_t            magic_2[8];     /* "$_ENQ$31" */
478144330Ssos    u_int8_t            filler_4[7];
479144330Ssos    u_int8_t            checksum_0;
480144330Ssos    u_int8_t            filler_5[512*2];
481144330Ssos    u_int8_t            lsi_id[6];
482145713Ssos#define LSIV3_MAGIC             "$_IDE$"
483144330Ssos
484144330Ssos    u_int16_t           dummy_2;        /* 0x33de for OK disk */
485144330Ssos    u_int16_t           version;        /* 0x0131 for this version */
486144330Ssos    u_int16_t           dummy_3;        /* 0x0440 always */
487144330Ssos    u_int32_t           filler_6;
488144330Ssos
489144330Ssos    struct {
490144330Ssos	u_int16_t       stripe_pages;
491144330Ssos	u_int8_t        type;
492144330Ssos#define LSIV3_T_RAID0           0x00
493144330Ssos#define LSIV3_T_RAID1           0x01
494144330Ssos
495144330Ssos	u_int8_t        dummy_0;
496144330Ssos	u_int8_t        total_disks;
497144330Ssos	u_int8_t        array_width;
498144330Ssos	u_int8_t        filler_0[10];
499144330Ssos
500144330Ssos	u_int32_t       sectors;
501144330Ssos	u_int16_t       dummy_1;
502144330Ssos	u_int32_t       offset;
503144330Ssos	u_int16_t       dummy_2;
504144330Ssos	u_int8_t        device;
505144330Ssos#define LSIV3_D_DEVICE          0x01
506144330Ssos#define LSIV3_D_CHANNEL         0x10
507144330Ssos
508144330Ssos	u_int8_t        dummy_3;
509144330Ssos	u_int8_t        dummy_4;
510144330Ssos	u_int8_t        dummy_5;
511144330Ssos	u_int8_t        filler_1[16];
512144330Ssos    } __packed raid[8];
513144330Ssos    struct {
514144330Ssos	u_int32_t       disk_sectors;
515144330Ssos	u_int32_t       dummy_0;
516144330Ssos	u_int32_t       dummy_1;
517144330Ssos	u_int8_t        dummy_2;
518144330Ssos	u_int8_t        dummy_3;
519144330Ssos	u_int8_t        flags;
520144330Ssos#define LSIV3_D_MIRROR          0x00
521144330Ssos#define LSIV3_D_STRIPE          0xff
522144330Ssos	u_int8_t        dummy_4;
523144330Ssos    } __packed disk[6];
524144330Ssos    u_int8_t            filler_7[7];
525144330Ssos    u_int8_t            device;
526144330Ssos    u_int32_t           timestamp;
527144330Ssos    u_int8_t            filler_8[3];
528144330Ssos    u_int8_t            checksum_1;
529144330Ssos} __packed;
530144330Ssos
531144330Ssos
532147052Ssos/* nVidia MediaShield Metadata */
533147052Ssos#define NVIDIA_LBA(dev) \
534147052Ssos	(((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
535147052Ssos
536147052Ssosstruct nvidia_raid_conf {
537147052Ssos    u_int8_t            nvidia_id[8];
538147052Ssos#define NV_MAGIC                "NVIDIA  "
539147052Ssos
540147052Ssos    u_int32_t           config_size;
541147052Ssos    u_int32_t           checksum;
542147052Ssos    u_int16_t           version;
543147052Ssos    u_int8_t            disk_number;
544147052Ssos    u_int8_t            dummy_0;
545147052Ssos    u_int32_t           total_sectors;
546147052Ssos    u_int32_t           sector_size;
547147052Ssos    u_int8_t            serial[16];
548147052Ssos    u_int8_t            revision[4];
549147052Ssos    u_int32_t           dummy_1;
550147052Ssos
551147052Ssos    u_int32_t           magic_0;
552147052Ssos#define NV_MAGIC0               0x00640044
553147052Ssos
554147052Ssos    u_int64_t           magic_1;
555147052Ssos    u_int64_t           magic_2;
556147052Ssos    u_int8_t            flags;
557147052Ssos    u_int8_t            array_width;
558147052Ssos    u_int8_t            total_disks;
559147052Ssos    u_int8_t            dummy_2;
560147052Ssos    u_int16_t           type;
561147052Ssos#define NV_T_RAID0              0x00000080
562147052Ssos#define NV_T_RAID1              0x00000081
563147052Ssos#define NV_T_RAID3              0x00000083
564147052Ssos#define NV_T_RAID5              0x00000085
565147052Ssos#define NV_T_RAID01             0x00008180
566147052Ssos#define NV_T_SPAN               0x000000ff
567147052Ssos
568147052Ssos    u_int16_t           dummy_3;
569147052Ssos    u_int32_t           stripe_sectors;
570147052Ssos    u_int32_t           stripe_bytes;
571147052Ssos    u_int32_t           stripe_shift;
572147052Ssos    u_int32_t           stripe_mask;
573147052Ssos    u_int32_t           stripe_sizesectors;
574147052Ssos    u_int32_t           stripe_sizebytes;
575147052Ssos    u_int32_t           rebuild_lba;
576147052Ssos    u_int32_t           dummy_4;
577147052Ssos    u_int32_t           dummy_5;
578147052Ssos    u_int32_t           status;
579147052Ssos#define NV_S_BOOTABLE           0x00000001
580147052Ssos#define NV_S_DEGRADED           0x00000002
581147052Ssos
582147052Ssos    u_int32_t           filler[98];
583147052Ssos} __packed;
584147052Ssos
585147052Ssos
586144330Ssos/* Promise FastTrak Metadata */
587144330Ssos#define PR_LBA(dev) \
588145760Ssos	(((((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)
589144330Ssos
59067071Ssosstruct promise_raid_conf {
591144330Ssos    char                promise_id[24];
592145713Ssos#define PR_MAGIC                "Promise Technology, Inc."
59367071Ssos
594144330Ssos    u_int32_t           dummy_0;
595144330Ssos    u_int64_t           magic_0;
596145713Ssos#define PR_MAGIC0(x)            (((u_int64_t)(x.channel) << 48) | \
597144936Ssos				((u_int64_t)(x.device != 0) << 56))
598144330Ssos    u_int16_t           magic_1;
599144330Ssos    u_int32_t           magic_2;
600144330Ssos    u_int8_t            filler1[470];
60167071Ssos    struct {
602144330Ssos	u_int32_t       integrity;
603144330Ssos#define PR_I_VALID              0x00000080
60490215Ssos
605144330Ssos	u_int8_t        flags;
606144330Ssos#define PR_F_VALID              0x00000001
607144330Ssos#define PR_F_ONLINE             0x00000002
608144330Ssos#define PR_F_ASSIGNED           0x00000004
609144330Ssos#define PR_F_SPARE              0x00000008
610144330Ssos#define PR_F_DUPLICATE          0x00000010
611144330Ssos#define PR_F_REDIR              0x00000020
612144330Ssos#define PR_F_DOWN               0x00000040
613144330Ssos#define PR_F_READY              0x00000080
61467071Ssos
615144330Ssos	u_int8_t        disk_number;
616144330Ssos	u_int8_t        channel;
617144330Ssos	u_int8_t        device;
618144330Ssos	u_int64_t       magic_0 __packed;
619144330Ssos	u_int32_t       disk_offset;
620144330Ssos	u_int32_t       disk_sectors;
621144330Ssos	u_int32_t       rebuild_lba;
622144330Ssos	u_int16_t       generation;
623144330Ssos	u_int8_t        status;
624144330Ssos#define PR_S_VALID              0x01
625144330Ssos#define PR_S_ONLINE             0x02
626144330Ssos#define PR_S_INITED             0x04
627144330Ssos#define PR_S_READY              0x08
628144330Ssos#define PR_S_DEGRADED           0x10
629144330Ssos#define PR_S_MARKED             0x20
630144330Ssos#define PR_S_FUNCTIONAL         0x80
63167071Ssos
632144330Ssos	u_int8_t        type;
633144330Ssos#define PR_T_RAID0              0x00
634144330Ssos#define PR_T_RAID1              0x01
635144330Ssos#define PR_T_RAID3              0x02
636144330Ssos#define PR_T_RAID5              0x04
637144330Ssos#define PR_T_SPAN               0x08
638144330Ssos#define PR_T_JBOD               0x10
63967071Ssos
640144330Ssos	u_int8_t        total_disks;
641144330Ssos	u_int8_t        stripe_shift;
642144330Ssos	u_int8_t        array_width;
643144330Ssos	u_int8_t        array_number;
644144330Ssos	u_int32_t       total_sectors;
645144330Ssos	u_int16_t       cylinders;
646144330Ssos	u_int8_t        heads;
647144330Ssos	u_int8_t        sectors;
648144330Ssos	u_int64_t       magic_1 __packed;
649131113Ssos	struct {
650144330Ssos	    u_int8_t    flags;
651144330Ssos	    u_int8_t    dummy_0;
652144330Ssos	    u_int8_t    channel;
653144330Ssos	    u_int8_t    device;
654144330Ssos	    u_int64_t   magic_0 __packed;
65567071Ssos	} disk[8];
65668183Ssos    } raid;
657144330Ssos    int32_t             filler2[346];
658144330Ssos    u_int32_t           checksum;
659103870Salfred} __packed;
66067071Ssos
661144330Ssos
662144330Ssos/* Silicon Image Medley Metadata */
663144330Ssos#define SII_LBA(dev) \
664144330Ssos	( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
665144330Ssos
666144330Ssosstruct sii_raid_conf {
667152908Ssos    u_int16_t   	ata_params_00_53[54];
668152908Ssos    u_int64_t   	total_sectors;
669152908Ssos    u_int16_t   	ata_params_58_79[70];
670152908Ssos    u_int16_t   	dummy_0;
671152908Ssos    u_int16_t   	dummy_1;
672152908Ssos    u_int32_t   	controller_pci_id;
673152908Ssos    u_int16_t   	version_minor;
674152908Ssos    u_int16_t   	version_major;
675152908Ssos    u_int8_t    	timestamp[6];
676152908Ssos    u_int16_t   	stripe_sectors;
677152908Ssos    u_int16_t   	dummy_2;
678152908Ssos    u_int8_t    	disk_number;
679152908Ssos    u_int8_t    	type;
680144330Ssos#define SII_T_RAID0             0x00
681144330Ssos#define SII_T_RAID1             0x01
682144330Ssos#define SII_T_RAID01            0x02
683144330Ssos#define SII_T_SPARE             0x03
684144330Ssos
685152908Ssos    u_int8_t    	raid0_disks;
686152908Ssos    u_int8_t    	raid0_ident;
687152908Ssos    u_int8_t    	raid1_disks;
688152908Ssos    u_int8_t    	raid1_ident;
689152908Ssos    u_int64_t   	rebuild_lba;
690152908Ssos    u_int32_t   	generation;
691152908Ssos    u_int8_t    	status;
692144330Ssos#define SII_S_READY             0x01
693144330Ssos
694152908Ssos    u_int8_t    	base_raid1_position;
695152908Ssos    u_int8_t    	base_raid0_position;
696152908Ssos    u_int8_t    	position;
697152908Ssos    u_int16_t   	dummy_3;
698152908Ssos    u_int8_t    	name[16];
699152908Ssos    u_int16_t   	checksum_0;
700152908Ssos    int8_t      	filler1[190];
701152908Ssos    u_int16_t   	checksum_1;
702144330Ssos} __packed;
703144936Ssos
704144936Ssos
705152908Ssos/* Silicon Integrated Systems RAID Metadata */
706152908Ssos#define SIS_LBA(dev) \
707152908Ssos	( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 16)
708152908Ssos
709152908Ssosstruct sis_raid_conf {
710152908Ssos    u_int16_t   	magic;
711152908Ssos#define SIS_MAGIC               0x0010
712152908Ssos
713152908Ssos    u_int8_t		disks;
714152908Ssos#define SIS_D_MASTER          	0xf0
715152908Ssos#define SIS_D_MIRROR          	0x0f
716152908Ssos
717152908Ssos    u_int8_t		type_total_disks;
718152908Ssos#define SIS_D_MASK          	0x0f
719152908Ssos#define SIS_T_MASK              0xf0
720152908Ssos#define SIS_T_JBOD              0x10
721152908Ssos#define SIS_T_RAID0         	0x20
722152908Ssos#define SIS_T_RAID1             0x30
723152908Ssos
724152908Ssos    u_int32_t   	dummy_0;
725152908Ssos    u_int32_t   	controller_pci_id;
726152908Ssos    u_int16_t   	stripe_sectors;
727152908Ssos    u_int16_t   	dummy_1;
728152908Ssos    u_int32_t   	timestamp;
729152908Ssos    u_int8_t		model[40];
730152908Ssos    u_int8_t		disk_number;
731152908Ssos    u_int8_t		dummy_2[3];
732152908Ssos    int8_t      	filler1[448];
733152908Ssos} __packed;
734152908Ssos
735152908Ssos
736144940Ssos/* VIA Tech V-RAID Metadata */
737144936Ssos#define VIA_LBA(dev) \
738144936Ssos	( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
739144936Ssos
740144936Ssosstruct via_raid_conf {
741152908Ssos    u_int16_t   	magic;
742145713Ssos#define VIA_MAGIC               0xaa55
743144936Ssos
744152908Ssos    u_int8_t    	dummy_0;
745152908Ssos    u_int8_t    	type;
746153416Ssos#define VIA_T_MASK              0x7e
747145713Ssos#define VIA_T_BOOTABLE          0x01
748145713Ssos#define VIA_T_RAID0             0x04
749145713Ssos#define VIA_T_RAID1             0x0c
750153416Ssos#define VIA_T_RAID01            0x4c
751153416Ssos#define VIA_T_RAID5             0x2c
752145713Ssos#define VIA_T_SPAN              0x44
753153416Ssos#define VIA_T_UNKNOWN           0x80
754144936Ssos
755152908Ssos    u_int8_t    	disk_index;
756149823Ssos#define VIA_D_MASK		0x0f
757149823Ssos#define VIA_D_DEGRADED		0x10
758153416Ssos#define VIA_D_HIGH_IDX		0x20
759149823Ssos
760152908Ssos    u_int8_t    	stripe_layout;
761145713Ssos#define VIA_L_MASK              0x07
762145713Ssos#define VIA_L_SHIFT             4
763144936Ssos
764153414Ssos    u_int64_t   	disk_sectors;
765152908Ssos    u_int32_t   	disk_id;
766152908Ssos    u_int32_t   	disks[8];
767152908Ssos    u_int8_t    	checksum;
768152908Ssos    u_int8_t    	filler_1[461];
769144936Ssos} __packed;
770