~psusi/ubuntu/precise/dmraid/fix-gpt

« back to all changes in this revision

Viewing changes to 1.0.0.rc15/lib/format/ataraid/asr.h

  • Committer: Bazaar Package Importer
  • Author(s): Giuseppe Iuculano, 6af052c
  • Date: 2009-03-25 22:34:59 UTC
  • mfrom: (2.1.9 sid)
  • mto: (2.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20090325223459-y54f0rmxem7htn6r
Tags: 1.0.0.rc15-6
[6af052c] Remove 15_isw_incorrect_status_fix.patch, it causes a
segfault. (Closes: #521104)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2005-2006 IBM (actual code changes by Darrick Wong)
 
3
 * 
 
4
 * Copyright (c) 2001, 2002, 2004 Adaptec Inc.
 
5
 * All rights reserved.
 
6
 *
 
7
 * Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions
 
9
 * are met:
 
10
 * 1. Redistributions of source code must retain the above copyright
 
11
 *    notice, this list of conditions, and the following disclaimer,
 
12
 *    without modification.
 
13
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 
14
 *    substantially similar to the "NO WARRANTY" disclaimer below
 
15
 *    ("Disclaimer") and any redistribution must be conditioned upon
 
16
 *    including a substantially similar Disclaimer requirement for further
 
17
 *    binary redistribution.
 
18
 * 3. Neither the names of the above-listed copyright holders nor the names
 
19
 *    of any contributors may be used to endorse or promote products derived
 
20
 *    from this software without specific prior written permission.
 
21
 *
 
22
 * Alternatively, this software may be distributed under the terms of the
 
23
 * GNU General Public License ("GPL") version 2 as published by the Free
 
24
 * Software Foundation.
 
25
 *
 
26
 * NO WARRANTY
 
27
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
28
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
29
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 
30
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
31
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
32
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
33
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
34
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 
35
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 
36
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
37
 * POSSIBILITY OF SUCH DAMAGES.
 
38
 */
 
39
 
 
40
#ifndef _ASR_H
 
41
#define _ASR_H
 
42
 
 
43
/* Beginning of stuff that Darrick Wong added */
 
44
#ifdef  FORMAT_HANDLER
 
45
#undef  FORMAT_HANDLER
 
46
 
 
47
/* ASR metadata offset in bytes */
 
48
#define ASR_CONFIGOFFSET        ((di->sectors - 1) << 9)
 
49
 
 
50
/* Data offset in sectors */
 
51
#define ASR_DATAOFFSET          0
 
52
 
 
53
/* Assume block size is 512.  So much for CD dmraid... */
 
54
#define ASR_DISK_BLOCK_SIZE     512
 
55
 
 
56
/* End of stuff that Darrick Wong added */
 
57
 
 
58
/* Begining of stuff copied verbatim from Adaptec's emd driver. */
 
59
 
 
60
/*
 
61
 * This is a metadata versioning mechanism, but rather a versioning
 
62
 * mechansim for Adaptec-sponsored changes to md.  (i.e. more of a driver
 
63
 * version)
 
64
 */
 
65
#define MD_ADAPTEC_MAJOR_VERSION        0
 
66
#define MD_ADAPTEC_MINOR_VERSION        0
 
67
#define MD_ADAPTEC_PATCHLEVEL_VERSION   13
 
68
 
 
69
#define FW_RESERVED_BLOCKS  0x800
 
70
 
 
71
#define MAX_SLEEPRATE_ENTRIES 10
 
72
 
 
73
/* define lsu levels */
 
74
#define LSU_LEVEL_PHYSICAL      1       /* Firmware Physical */
 
75
#define LSU_LEVEL_LOGICAL       2       /* Firmware Logical */
 
76
 
 
77
/* define RAID drive substates */
 
78
#define FWP             0       /* Firmware Physical */
 
79
#define FWL             1       /* Firmware Logical */
 
80
#define OSI             2       /* Operating System Intermediate */
 
81
#define FWL_2           3       /* Dual Level */
 
82
 
 
83
#define ASR_RAID0               0
 
84
#define ASR_RAID1               1
 
85
#define ASR_RAID4               4
 
86
#define ASR_RAID5               5
 
87
#define ASR_RAIDRED             0xFF
 
88
#define ASR_RAIDSPR             0xFE
 
89
 
 
90
/*** RAID CONFIGURATION TABLE STRUCTURE ***/
 
91
 
 
92
#define RVALID2                 0x900765C4      /* Version 2+ RAID table ID code
 
93
                                                   signature */
 
94
#define RCTBL_MAX_ENTRIES       127
 
95
#define HBA_RCTBL_MAX_ENTRIES   255
 
96
#define RTBLBLOCKS              16      /* Size of drive's raid table
 
97
                                           in blocks */
 
98
 
 
99
/* flag bits */
 
100
#define RCTBLCHNG                                       0x80    /* Set on comp OR log (NOT AND) if tbl updates needed */
 
101
#define COPYDIR                                         0x40
 
102
#define MIRCOPY                                         0x20
 
103
#define INITIAL_BUILD_COMPLETED                         0x10
 
104
#define SMART_DISABLED                                  0x08
 
105
#define WRITEBACK                                       0x04
 
106
#define PREDICTIVE_ENABLE                               0x02
 
107
#define RAID_ENTRY_FLAGS_ALARM_OFF_M                    0x01
 
108
 
 
109
struct asr_raid_configline {
 
110
        uint16_t raidcnt;       /* Component count of an OSL/FWL array */
 
111
        uint16_t raidseq;       /* Sequence # of component to look for */
 
112
        uint32_t raidmagic;     /* Magic # of component to look for */
 
113
        uint8_t raidlevel;      /* Array level = OSL/FWL/OSI/FWP */
 
114
        uint8_t raidtype;       /* Array type = RAID0/1/3/5, RAIDRED,
 
115
                                   RAIDSPR */
 
116
        uint8_t raidstate;      /* State of logical or physical drive */
 
117
 
 
118
        uint8_t flags;          /* misc flags set bit positions above */
 
119
 
 
120
        uint8_t refcnt;         /* Number of references to this log entry */
 
121
        uint8_t raidhba;        /* -- not used -- Host bus adapter number
 
122
                                   or RAIDID */
 
123
        uint8_t raidchnl;       /* Channel number */
 
124
        uint8_t raidlun;        /* SCSI LUN of log/phys drv */
 
125
        uint32_t raidid;        /* SCSI ID of log/phys drv */
 
126
        uint32_t loffset;       /* Offset of data for this comp in the
 
127
                                   array */
 
128
        uint32_t lcapcty;       /* Capacity of log drv or space used on
 
129
                                   phys */
 
130
        uint16_t strpsize;      /* Stripe size in blocks of this drive */
 
131
        uint16_t biosInfo;      /* bios info - set by
 
132
                                   I2O_EXEC_BIOS_INFO_SET */
 
133
        uint32_t lsu;           /* Pointer to phys/log lun of this entry */
 
134
        uint8_t addedDrives;
 
135
        uint8_t appSleepRate;
 
136
        uint16_t blockStorageTid;
 
137
        uint32_t curAppBlock;
 
138
        uint32_t appBurstCount;
 
139
#define ASR_NAMELEN     16
 
140
        uint8_t name[ASR_NAMELEN];      /* Full name of the array. */
 
141
} __attribute__ ((packed));
 
142
 
 
143
struct asr_raidtable {
 
144
/* raid Flag defines 32 bits 0 - FFFFFFFF */
 
145
#define RAID_FLAGS_ALARM_OFF_M 0x00000001
 
146
        uint32_t ridcode;       /* RAID table signature - 0x900765C4 */
 
147
        uint32_t rversion;      /* Version of the RAID config table */
 
148
        uint16_t maxelm;        /* Maximum number of elements */
 
149
        uint16_t elmcnt;        /* Element Count (number used) */
 
150
#define ASR_TBLELMCNT   7
 
151
        uint16_t elmsize;       /* Size of an individual raidCLine */
 
152
        uint16_t rchksum;       /* RAID table check sum
 
153
                                   (no rconfTblV2) */
 
154
        uint32_t res1;          /* Reserved */
 
155
        uint16_t res2;          /* was bldRate - Time in 1/10s
 
156
                                   between idle build bursts */
 
157
        uint16_t res3;          /* was bldAmount - Block to build
 
158
                                   during a build burst */
 
159
        uint32_t raidFlags;
 
160
        uint32_t timestamp;     /* used for iROC. A stamp to find
 
161
                                   which is latest */
 
162
        uint8_t irocFlags;
 
163
#define ASR_IF_VERIFY_WITH_AUTOFIX      0x01
 
164
#define ASR_IF_BOOTABLE                 0x80
 
165
        uint8_t dirty;          /* Records "open state" for array */
 
166
#define ARRAY_STATE_OK          0x00
 
167
#define ARRAY_STATE_DIRTY       0x03
 
168
        uint8_t actionPriority;
 
169
        uint8_t spareid;        /* Stored in member disk meta data
 
170
                                   to declare the ID of dedicated
 
171
                                   spare to show up. */
 
172
        uint32_t sparedrivemagic;       /* drivemagic (in RB) of the spare
 
173
                                           at above ID. */
 
174
        uint32_t raidmagic;     /* used to identify spare drive with
 
175
                                   its mirror set. */
 
176
        uint32_t verifyDate;    /* used by iomgr */
 
177
        uint32_t recreateDate;  /* used by iomgr */
 
178
        uint8_t res4[12];       /* Reserved */
 
179
        struct asr_raid_configline ent[RCTBL_MAX_ENTRIES];
 
180
} __attribute__ ((packed));
 
181
 
 
182
 
 
183
#define RBLOCK_VER  8           /* Version of the reserved block */
 
184
#define B0RESRVD    0x37FC4D1E  /* Signature of the reserved block */
 
185
#define SVALID      0x4450544D  /* ASCII code for "DPTM" DPT Mirror */
 
186
 
 
187
struct asr_reservedblock {
 
188
        uint32_t b0idcode;      /* 0x00 - ID code signifying block 0
 
189
                                   reserved */
 
190
        uint8_t lunsave[8];     /* 0x04 - NOT USED - LUN mappings for
 
191
                                   all drives */
 
192
        uint16_t sdtype;        /* 0x0C - NOT USED - drive type in
 
193
                                   boot prom */
 
194
        uint16_t ssavecyl;      /* 0x0E - NOT USED - Set Parameters
 
195
                                   cylinders */
 
196
        uint8_t ssavehed;       /* 0x10 - NOT USED - Set Parameters
 
197
                                   heads */
 
198
        uint8_t ssavesec;       /* 0x11 - NOT USED - Set Parameters
 
199
                                   sectors */
 
200
        uint8_t sb0flags;       /* 0x12 - flags saved in reserved
 
201
                                   block */
 
202
        uint8_t jbodEnable;     /* 0x13 - jbod enable -- DEC drive
 
203
                                   hiding */
 
204
        uint8_t lundsave;       /* 0x14 - NOT USED - LUNMAP disable
 
205
                                   flags */
 
206
        uint8_t svpdirty;       /* 0x15 - NOT USED - saved percentage
 
207
                                   dirty */
 
208
        uint16_t biosInfo;      /* 0x16 - bios info - set by
 
209
                                   I2O_EXEC_BIOS_INFO_SET */
 
210
        uint16_t svwbskip;      /* 0x18 - NOT USED - saved write-back
 
211
                                   skip value */
 
212
        uint16_t svwbcln;       /* 0x1A - NOT USED - saved maximum
 
213
                                   clean blocks in write-back */
 
214
        uint16_t svwbmax;       /* 0x1C - NOT USED - saved maximum
 
215
                                   write-back length */
 
216
        uint16_t res3;          /* 0x1E - unused (was write-back burst
 
217
                                   block count) */
 
218
        uint16_t svwbmin;       /* 0x20 - NOT USED - saved minimum
 
219
                                   block count to write */
 
220
        uint16_t res4;          /* 0x22 - unused (was minimum
 
221
                                   look-ahead length) */
 
222
        uint16_t svrcacth;      /* 0x24 - NOT USED - saved read cache
 
223
                                   threshold */
 
224
        uint16_t svwcacth;      /* 0x26 - NOT USED - saved write
 
225
                                   cache threshold */
 
226
        uint16_t svwbdly;       /* 0x28 - NOT USED - saved write-back
 
227
                                   delay */
 
228
        uint8_t svsdtime;       /* 0x2A - NOT USED - saved spin down
 
229
                                   time */
 
230
        uint8_t res5;           /* 0x2B - unused */
 
231
        uint16_t firmval;       /* 0x2C - NOT USED - firmware on
 
232
                                   drive  (dw) */
 
233
        uint16_t firmbln;       /* 0x2E - NOT USED - length in blocks
 
234
                                   for firmware */
 
235
        uint32_t firmblk;       /* 0x30 - NOT USED - starting block
 
236
                                   for firmware */
 
237
        uint32_t fstrsvrb;      /* 0x34 - 1st block reserved by
 
238
                                   Storage Manager */
 
239
        uint16_t svBlockStorageTid;     /* 0x38 - */
 
240
        uint16_t svtid;         /* 0x3A - */
 
241
        uint8_t svseccfl;       /* 0x3C - NOT USED - reserved block
 
242
                                   scsi bus ecc flags */
 
243
        uint8_t res6;           /* 0x3D - unused */
 
244
        uint8_t svhbanum;       /* 0x3E - NOT USED - HBA's unique
 
245
                                   RAID number */
 
246
        uint8_t resver;         /* 0x3F - reserved block version
 
247
                                   number */
 
248
        uint32_t drivemagic;    /* 0x40 - Magic number of this drive -
 
249
                                   used w/ RCTBLs */
 
250
        uint8_t reserved[20];   /* 0x44 - unused */
 
251
        uint8_t testnum;        /* 0x58 - NOT USED - diagnostic test
 
252
                                   number */
 
253
        uint8_t testflags;      /* 0x59 - NOT USED - diagnostic test
 
254
                                   flags */
 
255
        uint16_t maxErrorCount; /* 0x5A - NOT USED - diagnostic test
 
256
                                   maximum error count */
 
257
        uint32_t count;         /* 0x5C - NOT USED - diagnostic test
 
258
                                   cycles - # of iterations */
 
259
        uint32_t startTime;     /* 0x60 - NOT USED - diagnostic test
 
260
                                   absolute test start time in
 
261
                                   seconds */
 
262
        uint32_t interval;      /* 0x64 - NOT USED - diagnostic test
 
263
                                   interval in seconds */
 
264
        uint8_t tstxt0;         /* 0x68 - not used - originally
 
265
                                   diagnostic test exclusion period
 
266
                                   start hour */
 
267
        uint8_t tstxt1;         /* 0x69 - not used - originally
 
268
                                   diagnostic test exclusion period
 
269
                                   end hour */
 
270
        uint8_t serNum[32];     /* 0x6A - reserved */
 
271
        uint8_t res8[102];      /* 0x8A - reserved */
 
272
        uint32_t fwTestMagic;   /* 0xF0 - test magic number - used by
 
273
                                   FW Test for automated tests */
 
274
        uint32_t fwTestSeqNum;  /* 0xF4 - test sequence number - used
 
275
                                   by FW Test for automated tests */
 
276
        uint8_t fwTestRes[8];   /* 0xF6 - reserved by FW Test for
 
277
                                   automated tests */
 
278
        uint32_t smagic;        /* 0x100 - magic value saying software
 
279
                                   half is valid */
 
280
        uint32_t raidtbl;       /* 0x104 - pointer to first block of
 
281
                                   raid table */
 
282
        uint16_t raidline;      /* 0x108 - line number of this raid
 
283
                                   table entry - only if version <7 */
 
284
        uint8_t res9[0xF6];     /* 0x10A - reserved for software stuff */
 
285
} __attribute__ ((packed));
 
286
 
 
287
 
 
288
 
 
289
#define ARRAY_NEW       0x00
 
290
#define ARRAY_EQUAL     0x01
 
291
#define ARRAY_SEQ_LESS  0x02
 
292
#define ARRAY_SEQ_GREAT 0x03
 
293
 
 
294
#define LOCK_PRIORITY      10   /* Uses 10, 11, 12 - For all three channels */
 
295
 
 
296
 
 
297
/* B0FLAGS flag bits: */
 
298
 
 
299
#define SMARTENA                7       /* SMART emulation enabled */
 
300
#define CLRERROR                4       /* Clear stage of Interpret Format
 
301
                                           not completed */
 
302
#define FMTERROR                3       /* Format stage of Interpret Format
 
303
                                           not completed */
 
304
#define WRTTHRU                 2       /* write throughs */
 
305
#define CACHEDIS                0       /* cache disable bit */
 
306
#define PREDICTIVE_ENABLE       0x02
 
307
 
 
308
#define ID_MAP_PHYSICAL_M       1       /* Logical Map Physical */
 
309
#define ID_MAP_LOGICAL_M        2       /* Either Dual Level or Single Level
 
310
                                           Logical */
 
311
 
 
312
#define MAX_LSU_COUNT                   256
 
313
 
 
314
#define MAX_LSU_COMPONENTS              64
 
315
#define MAX_LSU_INQUIRY_DATA            64
 
316
#define MAX_LSU_SERIAL_NUMBER           8
 
317
#define STD_INQUIRY_SIZE                48
 
318
 
 
319
#define MAX_LSU_BAD_BLOCKS              8
 
320
 
 
321
/* lsuType definitions */
 
322
#define LT_UNCONFIGURED_M               0x00
 
323
#define LT_RAID0_M                      0x01
 
324
#define LT_RAID1_M                      0x02
 
325
#define LT_RAID3_M                      0x08
 
326
#define LT_RAID4_M                      0x10
 
327
#define LT_RAID5_M                      0x20
 
328
#define LT_REDIR_M                      0x40
 
329
#define LT_SPARE_M                      0x80
 
330
 
 
331
#define LSU_RAID_LEVEL_0                LT_RAID0_M
 
332
#define LSU_RAID_LEVEL_1                LT_RAID1_M
 
333
#define LSU_RAID_LEVEL_3                LT_RAID3_M
 
334
#define LSU_RAID_LEVEL_4                LT_RAID4_M
 
335
#define LSU_RAID_LEVEL_5                LT_RAID5_M
 
336
#define LSU_RAID_REDIRECT               LT_REDIR_M
 
337
#define LSU_RAID_SPARE                  LT_SPARE_M
 
338
 
 
339
/* raidState definitions */
 
340
#define LS_OPTIMAL_M                    0x00
 
341
#define LS_DEGRADED_M                   0x01
 
342
#define LS_REBUILDING_M                 0x02
 
343
#define LS_MORPHING_M                   0x03
 
344
#define LS_DEAD_M                       0x04
 
345
#define LS_WARNING_M                    0x05
 
346
 
 
347
#define LS_VERIFYING_M                  0x0A
 
348
#define LSU_ARRAY_SUBSTATE_WITH_FIX     0x10
 
349
 
 
350
#define LS_BUILDING_M                   0x0B
 
351
#define LS_CREATED_M                    0x54
 
352
#define LS_DIAGNOSING_M                 0xFD
 
353
 
 
354
 
 
355
/* arrayState definitions */
 
356
#define LSU_ARRAY_STATE_OPTIMAL                 0x00
 
357
#define LSU_ARRAY_STATE_DEGRADED                0x01
 
358
/* etc. */
 
359
 
 
360
/* component raidState definitions */
 
361
#define MAIN_STATE                              0x0F
 
362
#define LSU_COMPONENT_STATE_OPTIMAL             0x00
 
363
#define LSU_COMPONENT_STATE_DEGRADED            0x01
 
364
#define LSU_COMPONENT_STATE_UNCONFIGURED        0x02
 
365
#define LSU_COMPONENT_STATE_FAILED              0x03
 
366
#define LSU_COMPONENT_STATE_REPLACED            0x04
 
367
#define LSU_COMPONENT_STATE_UNINITIALIZED       0x0A
 
368
 
 
369
#define LSU_COMPONENT_SUBSTATE_BUILDING         0x10    /* drive is being built
 
370
                                                           for first time */
 
371
#define LSU_COMPONENT_SUBSTATE_REBUILDING       0x20    /* drive is being
 
372
                                                           rebuilt */
 
373
#define LSU_ARRAY_SUBSTATE_AWAIT_FORMAT         0x50
 
374
/* etc. */
 
375
 
 
376
/* Beginning of other stuff that Darrick Wong added */
 
377
 
 
378
struct asr {
 
379
        struct asr_reservedblock rb;
 
380
        struct asr_raidtable *rt;
 
381
};
 
382
 
 
383
#endif /* FORMAT_HANDLER */
 
384
 
 
385
int register_asr(struct lib_context *lc);
 
386
 
 
387
#endif /* _ASR_H */