2
* Copyright (c) 2005-2006 IBM (actual code changes by Darrick Wong)
4
* Copyright (c) 2001, 2002, 2004 Adaptec Inc.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
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.
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.
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.
43
/* Beginning of stuff that Darrick Wong added */
47
/* ASR metadata offset in bytes */
48
#define ASR_CONFIGOFFSET ((di->sectors - 1) << 9)
50
/* Data offset in sectors */
51
#define ASR_DATAOFFSET 0
53
/* Assume block size is 512. So much for CD dmraid... */
54
#define ASR_DISK_BLOCK_SIZE 512
56
/* End of stuff that Darrick Wong added */
58
/* Begining of stuff copied verbatim from Adaptec's emd driver. */
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
65
#define MD_ADAPTEC_MAJOR_VERSION 0
66
#define MD_ADAPTEC_MINOR_VERSION 0
67
#define MD_ADAPTEC_PATCHLEVEL_VERSION 13
69
#define FW_RESERVED_BLOCKS 0x800
71
#define MAX_SLEEPRATE_ENTRIES 10
73
/* define lsu levels */
74
#define LSU_LEVEL_PHYSICAL 1 /* Firmware Physical */
75
#define LSU_LEVEL_LOGICAL 2 /* Firmware Logical */
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 */
87
#define ASR_RAIDRED 0xFF
88
#define ASR_RAIDSPR 0xFE
90
/*** RAID CONFIGURATION TABLE STRUCTURE ***/
92
#define RVALID2 0x900765C4 /* Version 2+ RAID table ID code
94
#define RCTBL_MAX_ENTRIES 127
95
#define HBA_RCTBL_MAX_ENTRIES 255
96
#define RTBLBLOCKS 16 /* Size of drive's raid table
100
#define RCTBLCHNG 0x80 /* Set on comp OR log (NOT AND) if tbl updates needed */
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
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,
116
uint8_t raidstate; /* State of logical or physical drive */
118
uint8_t flags; /* misc flags set bit positions above */
120
uint8_t refcnt; /* Number of references to this log entry */
121
uint8_t raidhba; /* -- not used -- Host bus adapter number
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
128
uint32_t lcapcty; /* Capacity of log drv or space used on
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 */
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));
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
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 */
160
uint32_t timestamp; /* used for iROC. A stamp to find
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
172
uint32_t sparedrivemagic; /* drivemagic (in RB) of the spare
174
uint32_t raidmagic; /* used to identify spare drive with
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));
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 */
187
struct asr_reservedblock {
188
uint32_t b0idcode; /* 0x00 - ID code signifying block 0
190
uint8_t lunsave[8]; /* 0x04 - NOT USED - LUN mappings for
192
uint16_t sdtype; /* 0x0C - NOT USED - drive type in
194
uint16_t ssavecyl; /* 0x0E - NOT USED - Set Parameters
196
uint8_t ssavehed; /* 0x10 - NOT USED - Set Parameters
198
uint8_t ssavesec; /* 0x11 - NOT USED - Set Parameters
200
uint8_t sb0flags; /* 0x12 - flags saved in reserved
202
uint8_t jbodEnable; /* 0x13 - jbod enable -- DEC drive
204
uint8_t lundsave; /* 0x14 - NOT USED - LUNMAP disable
206
uint8_t svpdirty; /* 0x15 - NOT USED - saved percentage
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
212
uint16_t svwbcln; /* 0x1A - NOT USED - saved maximum
213
clean blocks in write-back */
214
uint16_t svwbmax; /* 0x1C - NOT USED - saved maximum
216
uint16_t res3; /* 0x1E - unused (was write-back burst
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
224
uint16_t svwcacth; /* 0x26 - NOT USED - saved write
226
uint16_t svwbdly; /* 0x28 - NOT USED - saved write-back
228
uint8_t svsdtime; /* 0x2A - NOT USED - saved spin down
230
uint8_t res5; /* 0x2B - unused */
231
uint16_t firmval; /* 0x2C - NOT USED - firmware on
233
uint16_t firmbln; /* 0x2E - NOT USED - length in blocks
235
uint32_t firmblk; /* 0x30 - NOT USED - starting block
237
uint32_t fstrsvrb; /* 0x34 - 1st block reserved by
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
246
uint8_t resver; /* 0x3F - reserved block version
248
uint32_t drivemagic; /* 0x40 - Magic number of this drive -
250
uint8_t reserved[20]; /* 0x44 - unused */
251
uint8_t testnum; /* 0x58 - NOT USED - diagnostic test
253
uint8_t testflags; /* 0x59 - NOT USED - diagnostic test
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
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
267
uint8_t tstxt1; /* 0x69 - not used - originally
268
diagnostic test exclusion period
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
278
uint32_t smagic; /* 0x100 - magic value saying software
280
uint32_t raidtbl; /* 0x104 - pointer to first block of
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));
289
#define ARRAY_NEW 0x00
290
#define ARRAY_EQUAL 0x01
291
#define ARRAY_SEQ_LESS 0x02
292
#define ARRAY_SEQ_GREAT 0x03
294
#define LOCK_PRIORITY 10 /* Uses 10, 11, 12 - For all three channels */
297
/* B0FLAGS flag bits: */
299
#define SMARTENA 7 /* SMART emulation enabled */
300
#define CLRERROR 4 /* Clear stage of Interpret Format
302
#define FMTERROR 3 /* Format stage of Interpret Format
304
#define WRTTHRU 2 /* write throughs */
305
#define CACHEDIS 0 /* cache disable bit */
306
#define PREDICTIVE_ENABLE 0x02
308
#define ID_MAP_PHYSICAL_M 1 /* Logical Map Physical */
309
#define ID_MAP_LOGICAL_M 2 /* Either Dual Level or Single Level
312
#define MAX_LSU_COUNT 256
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
319
#define MAX_LSU_BAD_BLOCKS 8
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
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
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
347
#define LS_VERIFYING_M 0x0A
348
#define LSU_ARRAY_SUBSTATE_WITH_FIX 0x10
350
#define LS_BUILDING_M 0x0B
351
#define LS_CREATED_M 0x54
352
#define LS_DIAGNOSING_M 0xFD
355
/* arrayState definitions */
356
#define LSU_ARRAY_STATE_OPTIMAL 0x00
357
#define LSU_ARRAY_STATE_DEGRADED 0x01
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
369
#define LSU_COMPONENT_SUBSTATE_BUILDING 0x10 /* drive is being built
371
#define LSU_COMPONENT_SUBSTATE_REBUILDING 0x20 /* drive is being
373
#define LSU_ARRAY_SUBSTATE_AWAIT_FORMAT 0x50
376
/* Beginning of other stuff that Darrick Wong added */
379
struct asr_reservedblock rb;
380
struct asr_raidtable *rt;
383
#endif /* FORMAT_HANDLER */
385
int register_asr(struct lib_context *lc);