1 |
1275 |
phoenix |
#ifndef __MEGARAID_H__
|
2 |
|
|
#define __MEGARAID_H__
|
3 |
|
|
|
4 |
|
|
#include <linux/version.h>
|
5 |
|
|
#include <linux/spinlock.h>
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
#define MEGARAID_VERSION \
|
9 |
|
|
"v2.10.1 (Release Date: Wed Dec 3 15:34:42 EST 2003)\n"
|
10 |
|
|
|
11 |
|
|
/*
|
12 |
|
|
* Driver features - change the values to enable or disable features in the
|
13 |
|
|
* driver.
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
/*
|
17 |
|
|
* Comand coalescing - This feature allows the driver to be able to combine
|
18 |
|
|
* two or more commands and issue as one command in order to boost I/O
|
19 |
|
|
* performance. Useful if the nature of the I/O is sequential. It is not very
|
20 |
|
|
* useful for random natured I/Os.
|
21 |
|
|
*/
|
22 |
|
|
#define MEGA_HAVE_COALESCING 0
|
23 |
|
|
|
24 |
|
|
/*
|
25 |
|
|
* Clustering support - Set this flag if you are planning to use the
|
26 |
|
|
* clustering services provided by the megaraid controllers and planning to
|
27 |
|
|
* setup a cluster
|
28 |
|
|
*/
|
29 |
|
|
#define MEGA_HAVE_CLUSTERING 1
|
30 |
|
|
|
31 |
|
|
/*
|
32 |
|
|
* Driver statistics - Set this flag if you are interested in statics about
|
33 |
|
|
* number of I/O completed on each logical drive and how many interrupts
|
34 |
|
|
* generated. If enabled, this information is available through /proc
|
35 |
|
|
* interface and through the private ioctl. Setting this flag has a
|
36 |
|
|
* performance penalty.
|
37 |
|
|
*/
|
38 |
|
|
#define MEGA_HAVE_STATS 0
|
39 |
|
|
|
40 |
|
|
/*
|
41 |
|
|
* Enhanced /proc interface - This feature will allow you to have a more
|
42 |
|
|
* detailed /proc interface for megaraid driver. E.g., a real time update of
|
43 |
|
|
* the status of the logical drives, battery status, physical drives etc.
|
44 |
|
|
*/
|
45 |
|
|
#define MEGA_HAVE_ENH_PROC 1
|
46 |
|
|
|
47 |
|
|
#define MAX_DEV_TYPE 32
|
48 |
|
|
|
49 |
|
|
#ifndef PCI_VENDOR_ID_LSI_LOGIC
|
50 |
|
|
#define PCI_VENDOR_ID_LSI_LOGIC 0x1000
|
51 |
|
|
#endif
|
52 |
|
|
|
53 |
|
|
#ifndef PCI_VENDOR_ID_AMI
|
54 |
|
|
#define PCI_VENDOR_ID_AMI 0x101E
|
55 |
|
|
#endif
|
56 |
|
|
|
57 |
|
|
#ifndef PCI_VENDOR_ID_DELL
|
58 |
|
|
#define PCI_VENDOR_ID_DELL 0x1028
|
59 |
|
|
#endif
|
60 |
|
|
|
61 |
|
|
#ifndef PCI_VENDOR_ID_INTEL
|
62 |
|
|
#define PCI_VENDOR_ID_INTEL 0x8086
|
63 |
|
|
#endif
|
64 |
|
|
|
65 |
|
|
#ifndef PCI_DEVICE_ID_AMI_MEGARAID
|
66 |
|
|
#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010
|
67 |
|
|
#endif
|
68 |
|
|
|
69 |
|
|
#ifndef PCI_DEVICE_ID_AMI_MEGARAID2
|
70 |
|
|
#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060
|
71 |
|
|
#endif
|
72 |
|
|
|
73 |
|
|
#ifndef PCI_DEVICE_ID_AMI_MEGARAID3
|
74 |
|
|
#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960
|
75 |
|
|
#endif
|
76 |
|
|
|
77 |
|
|
#define PCI_DEVICE_ID_DISCOVERY 0x000E
|
78 |
|
|
#define PCI_DEVICE_ID_PERC4_DI 0x000F
|
79 |
|
|
#define PCI_DEVICE_ID_PERC4_QC_VERDE 0x0407
|
80 |
|
|
#define PCI_DEVICE_ID_PERC4E_SI_DI 0x0013
|
81 |
|
|
#define PCI_DEVICE_ID_PERC4E_DC_SC 0x0408
|
82 |
|
|
#define PCI_DEVICE_ID_LSI_SATA_PCIX 0x0409
|
83 |
|
|
|
84 |
|
|
/* Sub-System Vendor IDs */
|
85 |
|
|
#define AMI_SUBSYS_VID 0x101E
|
86 |
|
|
#define DELL_SUBSYS_VID 0x1028
|
87 |
|
|
#define HP_SUBSYS_VID 0x103C
|
88 |
|
|
#define LSI_SUBSYS_VID 0x1000
|
89 |
|
|
#define INTEL_SUBSYS_VID 0x8086
|
90 |
|
|
|
91 |
|
|
#define HBA_SIGNATURE 0x3344
|
92 |
|
|
#define HBA_SIGNATURE_471 0xCCCC
|
93 |
|
|
#define HBA_SIGNATURE_64BIT 0x0299
|
94 |
|
|
|
95 |
|
|
#define MBOX_BUSY_WAIT 10 /* wait for up to 10 usec for
|
96 |
|
|
mailbox to be free */
|
97 |
|
|
#define DEFAULT_INITIATOR_ID 7
|
98 |
|
|
|
99 |
|
|
#define MAX_SGLIST 64 /* max supported in f/w */
|
100 |
|
|
#define MIN_SGLIST 26 /* guaranteed to support these many */
|
101 |
|
|
#define MAX_COMMANDS 126
|
102 |
|
|
#define CMDID_INT_CMDS MAX_COMMANDS+1 /* make sure CMDID_INT_CMDS
|
103 |
|
|
is less than max commands
|
104 |
|
|
supported by any f/w */
|
105 |
|
|
|
106 |
|
|
#define MAX_CDB_LEN 10
|
107 |
|
|
#define MAX_EXT_CDB_LEN 16 /* we support cdb length up to 16 */
|
108 |
|
|
|
109 |
|
|
#define DEF_CMD_PER_LUN 63
|
110 |
|
|
#define MAX_CMD_PER_LUN MAX_COMMANDS
|
111 |
|
|
#define MAX_FIRMWARE_STATUS 46
|
112 |
|
|
#define MAX_XFER_PER_CMD (64*1024)
|
113 |
|
|
#define MAX_SECTORS_PER_IO 128
|
114 |
|
|
|
115 |
|
|
#define MAX_LOGICAL_DRIVES_40LD 40
|
116 |
|
|
#define FC_MAX_PHYSICAL_DEVICES 256
|
117 |
|
|
#define MAX_LOGICAL_DRIVES_8LD 8
|
118 |
|
|
#define MAX_CHANNELS 5
|
119 |
|
|
#define MAX_TARGET 15
|
120 |
|
|
#define MAX_PHYSICAL_DRIVES MAX_CHANNELS*MAX_TARGET
|
121 |
|
|
#define MAX_ROW_SIZE_40LD 32
|
122 |
|
|
#define MAX_ROW_SIZE_8LD 8
|
123 |
|
|
#define MAX_SPAN_DEPTH 8
|
124 |
|
|
|
125 |
|
|
#define NVIRT_CHAN 4 /* # of virtual channels to represent
|
126 |
|
|
up to 60 logical drives */
|
127 |
|
|
|
128 |
|
|
#define MEGARAID \
|
129 |
|
|
{ \
|
130 |
|
|
.name = "MegaRAID", \
|
131 |
|
|
.proc_name = "megaraid", \
|
132 |
|
|
.detect = megaraid_detect, \
|
133 |
|
|
.release = megaraid_release, \
|
134 |
|
|
.info = megaraid_info, \
|
135 |
|
|
.command = megaraid_command, \
|
136 |
|
|
.queuecommand = megaraid_queue, \
|
137 |
|
|
.bios_param = megaraid_biosparam, \
|
138 |
|
|
.max_sectors = MAX_SECTORS_PER_IO, \
|
139 |
|
|
.can_queue = MAX_COMMANDS, \
|
140 |
|
|
.this_id = DEFAULT_INITIATOR_ID, \
|
141 |
|
|
.sg_tablesize = MAX_SGLIST, \
|
142 |
|
|
.cmd_per_lun = DEF_CMD_PER_LUN, \
|
143 |
|
|
.present = 0, \
|
144 |
|
|
.unchecked_isa_dma = 0, \
|
145 |
|
|
.use_clustering = ENABLE_CLUSTERING, \
|
146 |
|
|
.use_new_eh_code = 1, \
|
147 |
|
|
.eh_abort_handler = megaraid_abort, \
|
148 |
|
|
.eh_device_reset_handler = megaraid_reset, \
|
149 |
|
|
.eh_bus_reset_handler = megaraid_reset, \
|
150 |
|
|
.eh_host_reset_handler = megaraid_reset, \
|
151 |
|
|
.highmem_io = 1 \
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
typedef struct {
|
157 |
|
|
/* 0x0 */ u8 cmd;
|
158 |
|
|
/* 0x1 */ u8 cmdid;
|
159 |
|
|
/* 0x2 */ u16 numsectors;
|
160 |
|
|
/* 0x4 */ u32 lba;
|
161 |
|
|
/* 0x8 */ u32 xferaddr;
|
162 |
|
|
/* 0xC */ u8 logdrv;
|
163 |
|
|
/* 0xD */ u8 numsgelements;
|
164 |
|
|
/* 0xE */ u8 resvd;
|
165 |
|
|
/* 0xF */ volatile u8 busy;
|
166 |
|
|
/* 0x10 */ volatile u8 numstatus;
|
167 |
|
|
/* 0x11 */ volatile u8 status;
|
168 |
|
|
/* 0x12 */ volatile u8 completed[MAX_FIRMWARE_STATUS];
|
169 |
|
|
volatile u8 poll;
|
170 |
|
|
volatile u8 ack;
|
171 |
|
|
} __attribute__ ((packed)) mbox_t;
|
172 |
|
|
|
173 |
|
|
typedef struct {
|
174 |
|
|
u32 xfer_segment_lo;
|
175 |
|
|
u32 xfer_segment_hi;
|
176 |
|
|
mbox_t mbox;
|
177 |
|
|
} __attribute__ ((packed)) mbox64_t;
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
/*
|
181 |
|
|
* Passthru definitions
|
182 |
|
|
*/
|
183 |
|
|
#define MAX_REQ_SENSE_LEN 0x20
|
184 |
|
|
|
185 |
|
|
typedef struct {
|
186 |
|
|
u8 timeout:3; /* 0=6sec/1=60sec/2=10min/3=3hrs */
|
187 |
|
|
u8 ars:1;
|
188 |
|
|
u8 reserved:3;
|
189 |
|
|
u8 islogical:1;
|
190 |
|
|
u8 logdrv; /* if islogical == 1 */
|
191 |
|
|
u8 channel; /* if islogical == 0 */
|
192 |
|
|
u8 target; /* if islogical == 0 */
|
193 |
|
|
u8 queuetag; /* unused */
|
194 |
|
|
u8 queueaction; /* unused */
|
195 |
|
|
u8 cdb[MAX_CDB_LEN];
|
196 |
|
|
u8 cdblen;
|
197 |
|
|
u8 reqsenselen;
|
198 |
|
|
u8 reqsensearea[MAX_REQ_SENSE_LEN];
|
199 |
|
|
u8 numsgelements;
|
200 |
|
|
u8 scsistatus;
|
201 |
|
|
u32 dataxferaddr;
|
202 |
|
|
u32 dataxferlen;
|
203 |
|
|
} __attribute__ ((packed)) mega_passthru;
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
/*
|
207 |
|
|
* Extended passthru: support CDB > 10 bytes
|
208 |
|
|
*/
|
209 |
|
|
typedef struct {
|
210 |
|
|
u8 timeout:3; /* 0=6sec/1=60sec/2=10min/3=3hrs */
|
211 |
|
|
u8 ars:1;
|
212 |
|
|
u8 rsvd1:1;
|
213 |
|
|
u8 cd_rom:1;
|
214 |
|
|
u8 rsvd2:1;
|
215 |
|
|
u8 islogical:1;
|
216 |
|
|
u8 logdrv; /* if islogical == 1 */
|
217 |
|
|
u8 channel; /* if islogical == 0 */
|
218 |
|
|
u8 target; /* if islogical == 0 */
|
219 |
|
|
u8 queuetag; /* unused */
|
220 |
|
|
u8 queueaction; /* unused */
|
221 |
|
|
u8 cdblen;
|
222 |
|
|
u8 rsvd3;
|
223 |
|
|
u8 cdb[MAX_EXT_CDB_LEN];
|
224 |
|
|
u8 numsgelements;
|
225 |
|
|
u8 status;
|
226 |
|
|
u8 reqsenselen;
|
227 |
|
|
u8 reqsensearea[MAX_REQ_SENSE_LEN];
|
228 |
|
|
u8 rsvd4;
|
229 |
|
|
u32 dataxferaddr;
|
230 |
|
|
u32 dataxferlen;
|
231 |
|
|
} __attribute__ ((packed)) mega_ext_passthru;
|
232 |
|
|
|
233 |
|
|
typedef struct {
|
234 |
|
|
u64 address;
|
235 |
|
|
u32 length;
|
236 |
|
|
} __attribute__ ((packed)) mega_sgl64;
|
237 |
|
|
|
238 |
|
|
typedef struct {
|
239 |
|
|
u32 address;
|
240 |
|
|
u32 length;
|
241 |
|
|
} __attribute__ ((packed)) mega_sglist;
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
/* Queued command data */
|
245 |
|
|
typedef struct {
|
246 |
|
|
int idx;
|
247 |
|
|
u32 state;
|
248 |
|
|
struct list_head list;
|
249 |
|
|
u8 raw_mbox[66];
|
250 |
|
|
u32 dma_type;
|
251 |
|
|
u32 dma_direction;
|
252 |
|
|
|
253 |
|
|
Scsi_Cmnd *cmd;
|
254 |
|
|
dma_addr_t dma_h_bulkdata;
|
255 |
|
|
dma_addr_t dma_h_sgdata;
|
256 |
|
|
|
257 |
|
|
mega_sglist *sgl;
|
258 |
|
|
mega_sgl64 *sgl64;
|
259 |
|
|
dma_addr_t sgl_dma_addr;
|
260 |
|
|
|
261 |
|
|
mega_passthru *pthru;
|
262 |
|
|
dma_addr_t pthru_dma_addr;
|
263 |
|
|
mega_ext_passthru *epthru;
|
264 |
|
|
dma_addr_t epthru_dma_addr;
|
265 |
|
|
} scb_t;
|
266 |
|
|
|
267 |
|
|
/*
|
268 |
|
|
* Flags to follow the scb as it transitions between various stages
|
269 |
|
|
*/
|
270 |
|
|
#define SCB_FREE 0x0000 /* on the free list */
|
271 |
|
|
#define SCB_ACTIVE 0x0001 /* off the free list */
|
272 |
|
|
#define SCB_PENDQ 0x0002 /* on the pending queue */
|
273 |
|
|
#define SCB_ISSUED 0x0004 /* issued - owner f/w */
|
274 |
|
|
#define SCB_ABORT 0x0008 /* Got an abort for this one */
|
275 |
|
|
#define SCB_RESET 0x0010 /* Got a reset for this one */
|
276 |
|
|
|
277 |
|
|
/*
|
278 |
|
|
* Utilities declare this strcture size as 1024 bytes. So more fields can
|
279 |
|
|
* be added in future.
|
280 |
|
|
*/
|
281 |
|
|
typedef struct {
|
282 |
|
|
u32 data_size; /* current size in bytes (not including resvd) */
|
283 |
|
|
|
284 |
|
|
u32 config_signature;
|
285 |
|
|
/* Current value is 0x00282008
|
286 |
|
|
* 0x28=MAX_LOGICAL_DRIVES,
|
287 |
|
|
* 0x20=Number of stripes and
|
288 |
|
|
* 0x08=Number of spans */
|
289 |
|
|
|
290 |
|
|
u8 fw_version[16]; /* printable ASCI string */
|
291 |
|
|
u8 bios_version[16]; /* printable ASCI string */
|
292 |
|
|
u8 product_name[80]; /* printable ASCI string */
|
293 |
|
|
|
294 |
|
|
u8 max_commands; /* Max. concurrent commands supported */
|
295 |
|
|
u8 nchannels; /* Number of SCSI Channels detected */
|
296 |
|
|
u8 fc_loop_present; /* Number of Fibre Loops detected */
|
297 |
|
|
u8 mem_type; /* EDO, FPM, SDRAM etc */
|
298 |
|
|
|
299 |
|
|
u32 signature;
|
300 |
|
|
u16 dram_size; /* In terms of MB */
|
301 |
|
|
u16 subsysid;
|
302 |
|
|
|
303 |
|
|
u16 subsysvid;
|
304 |
|
|
u8 notify_counters;
|
305 |
|
|
u8 pad1k[889]; /* 135 + 889 resvd = 1024 total size */
|
306 |
|
|
} __attribute__ ((packed)) mega_product_info;
|
307 |
|
|
|
308 |
|
|
struct notify {
|
309 |
|
|
u32 global_counter; /* Any change increments this counter */
|
310 |
|
|
|
311 |
|
|
u8 param_counter; /* Indicates any params changed */
|
312 |
|
|
u8 param_id; /* Param modified - defined below */
|
313 |
|
|
u16 param_val; /* New val of last param modified */
|
314 |
|
|
|
315 |
|
|
u8 write_config_counter; /* write config occurred */
|
316 |
|
|
u8 write_config_rsvd[3];
|
317 |
|
|
|
318 |
|
|
u8 ldrv_op_counter; /* Indicates ldrv op started/completed */
|
319 |
|
|
u8 ldrv_opid; /* ldrv num */
|
320 |
|
|
u8 ldrv_opcmd; /* ldrv operation - defined below */
|
321 |
|
|
u8 ldrv_opstatus; /* status of the operation */
|
322 |
|
|
|
323 |
|
|
u8 ldrv_state_counter; /* Indicates change of ldrv state */
|
324 |
|
|
u8 ldrv_state_id; /* ldrv num */
|
325 |
|
|
u8 ldrv_state_new; /* New state */
|
326 |
|
|
u8 ldrv_state_old; /* old state */
|
327 |
|
|
|
328 |
|
|
u8 pdrv_state_counter; /* Indicates change of ldrv state */
|
329 |
|
|
u8 pdrv_state_id; /* pdrv id */
|
330 |
|
|
u8 pdrv_state_new; /* New state */
|
331 |
|
|
u8 pdrv_state_old; /* old state */
|
332 |
|
|
|
333 |
|
|
u8 pdrv_fmt_counter; /* Indicates pdrv format started/over */
|
334 |
|
|
u8 pdrv_fmt_id; /* pdrv id */
|
335 |
|
|
u8 pdrv_fmt_val; /* format started/over */
|
336 |
|
|
u8 pdrv_fmt_rsvd;
|
337 |
|
|
|
338 |
|
|
u8 targ_xfer_counter; /* Indicates SCSI-2 Xfer rate change */
|
339 |
|
|
u8 targ_xfer_id; /* pdrv Id */
|
340 |
|
|
u8 targ_xfer_val; /* new Xfer params of last pdrv */
|
341 |
|
|
u8 targ_xfer_rsvd;
|
342 |
|
|
|
343 |
|
|
u8 fcloop_id_chg_counter; /* Indicates loopid changed */
|
344 |
|
|
u8 fcloopid_pdrvid; /* pdrv id */
|
345 |
|
|
u8 fcloop_id0; /* loopid on fc loop 0 */
|
346 |
|
|
u8 fcloop_id1; /* loopid on fc loop 1 */
|
347 |
|
|
|
348 |
|
|
u8 fcloop_state_counter; /* Indicates loop state changed */
|
349 |
|
|
u8 fcloop_state0; /* state of fc loop 0 */
|
350 |
|
|
u8 fcloop_state1; /* state of fc loop 1 */
|
351 |
|
|
u8 fcloop_state_rsvd;
|
352 |
|
|
} __attribute__ ((packed));
|
353 |
|
|
|
354 |
|
|
#define MAX_NOTIFY_SIZE 0x80
|
355 |
|
|
#define CUR_NOTIFY_SIZE sizeof(struct notify)
|
356 |
|
|
|
357 |
|
|
typedef struct {
|
358 |
|
|
u32 data_size; /* current size in bytes (not including resvd) */
|
359 |
|
|
|
360 |
|
|
struct notify notify;
|
361 |
|
|
|
362 |
|
|
u8 notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
|
363 |
|
|
|
364 |
|
|
u8 rebuild_rate; /* Rebuild rate (0% - 100%) */
|
365 |
|
|
u8 cache_flush_interval; /* In terms of Seconds */
|
366 |
|
|
u8 sense_alert;
|
367 |
|
|
u8 drive_insert_count; /* drive insertion count */
|
368 |
|
|
|
369 |
|
|
u8 battery_status;
|
370 |
|
|
u8 num_ldrv; /* No. of Log Drives configured */
|
371 |
|
|
u8 recon_state[MAX_LOGICAL_DRIVES_40LD / 8]; /* State of
|
372 |
|
|
reconstruct */
|
373 |
|
|
u16 ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8]; /* logdrv
|
374 |
|
|
Status */
|
375 |
|
|
|
376 |
|
|
u32 ldrv_size[MAX_LOGICAL_DRIVES_40LD];/* Size of each log drv */
|
377 |
|
|
u8 ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
|
378 |
|
|
u8 ldrv_state[MAX_LOGICAL_DRIVES_40LD];/* State of log drives */
|
379 |
|
|
u8 pdrv_state[FC_MAX_PHYSICAL_DEVICES];/* State of phys drvs. */
|
380 |
|
|
u16 pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
|
381 |
|
|
|
382 |
|
|
u8 targ_xfer[80]; /* phys device transfer rate */
|
383 |
|
|
u8 pad1k[263]; /* 761 + 263reserved = 1024 bytes total size */
|
384 |
|
|
} __attribute__ ((packed)) mega_inquiry3;
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
/* Structures */
|
388 |
|
|
typedef struct {
|
389 |
|
|
u8 max_commands; /* Max concurrent commands supported */
|
390 |
|
|
u8 rebuild_rate; /* Rebuild rate - 0% thru 100% */
|
391 |
|
|
u8 max_targ_per_chan; /* Max targ per channel */
|
392 |
|
|
u8 nchannels; /* Number of channels on HBA */
|
393 |
|
|
u8 fw_version[4]; /* Firmware version */
|
394 |
|
|
u16 age_of_flash; /* Number of times FW has been flashed */
|
395 |
|
|
u8 chip_set_value; /* Contents of 0xC0000832 */
|
396 |
|
|
u8 dram_size; /* In MB */
|
397 |
|
|
u8 cache_flush_interval; /* in seconds */
|
398 |
|
|
u8 bios_version[4];
|
399 |
|
|
u8 board_type;
|
400 |
|
|
u8 sense_alert;
|
401 |
|
|
u8 write_config_count; /* Increase with every configuration
|
402 |
|
|
change */
|
403 |
|
|
u8 drive_inserted_count; /* Increase with every drive inserted
|
404 |
|
|
*/
|
405 |
|
|
u8 inserted_drive; /* Channel:Id of inserted drive */
|
406 |
|
|
u8 battery_status; /*
|
407 |
|
|
* BIT 0: battery module missing
|
408 |
|
|
* BIT 1: VBAD
|
409 |
|
|
* BIT 2: temprature high
|
410 |
|
|
* BIT 3: battery pack missing
|
411 |
|
|
* BIT 4,5:
|
412 |
|
|
* 00 - charge complete
|
413 |
|
|
* 01 - fast charge in progress
|
414 |
|
|
* 10 - fast charge fail
|
415 |
|
|
* 11 - undefined
|
416 |
|
|
* Bit 6: counter > 1000
|
417 |
|
|
* Bit 7: Undefined
|
418 |
|
|
*/
|
419 |
|
|
u8 dec_fault_bus_info;
|
420 |
|
|
} __attribute__ ((packed)) mega_adp_info;
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
typedef struct {
|
424 |
|
|
u8 num_ldrv; /* Number of logical drives configured */
|
425 |
|
|
u8 rsvd[3];
|
426 |
|
|
u32 ldrv_size[MAX_LOGICAL_DRIVES_8LD];
|
427 |
|
|
u8 ldrv_prop[MAX_LOGICAL_DRIVES_8LD];
|
428 |
|
|
u8 ldrv_state[MAX_LOGICAL_DRIVES_8LD];
|
429 |
|
|
} __attribute__ ((packed)) mega_ldrv_info;
|
430 |
|
|
|
431 |
|
|
typedef struct {
|
432 |
|
|
u8 pdrv_state[MAX_PHYSICAL_DRIVES];
|
433 |
|
|
u8 rsvd;
|
434 |
|
|
} __attribute__ ((packed)) mega_pdrv_info;
|
435 |
|
|
|
436 |
|
|
/* RAID inquiry: Mailbox command 0x05*/
|
437 |
|
|
typedef struct {
|
438 |
|
|
mega_adp_info adapter_info;
|
439 |
|
|
mega_ldrv_info logdrv_info;
|
440 |
|
|
mega_pdrv_info pdrv_info;
|
441 |
|
|
} __attribute__ ((packed)) mraid_inquiry;
|
442 |
|
|
|
443 |
|
|
|
444 |
|
|
/* RAID extended inquiry: Mailbox command 0x04*/
|
445 |
|
|
typedef struct {
|
446 |
|
|
mraid_inquiry raid_inq;
|
447 |
|
|
u16 phys_drv_format[MAX_CHANNELS];
|
448 |
|
|
u8 stack_attn;
|
449 |
|
|
u8 modem_status;
|
450 |
|
|
u8 rsvd[2];
|
451 |
|
|
} __attribute__ ((packed)) mraid_ext_inquiry;
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
typedef struct {
|
455 |
|
|
u8 channel;
|
456 |
|
|
u8 target;
|
457 |
|
|
}__attribute__ ((packed)) adp_device;
|
458 |
|
|
|
459 |
|
|
typedef struct {
|
460 |
|
|
u32 start_blk; /* starting block */
|
461 |
|
|
u32 num_blks; /* # of blocks */
|
462 |
|
|
adp_device device[MAX_ROW_SIZE_40LD];
|
463 |
|
|
}__attribute__ ((packed)) adp_span_40ld;
|
464 |
|
|
|
465 |
|
|
typedef struct {
|
466 |
|
|
u32 start_blk; /* starting block */
|
467 |
|
|
u32 num_blks; /* # of blocks */
|
468 |
|
|
adp_device device[MAX_ROW_SIZE_8LD];
|
469 |
|
|
}__attribute__ ((packed)) adp_span_8ld;
|
470 |
|
|
|
471 |
|
|
typedef struct {
|
472 |
|
|
u8 span_depth; /* Total # of spans */
|
473 |
|
|
u8 level; /* RAID level */
|
474 |
|
|
u8 read_ahead; /* read ahead, no read ahead, adaptive read
|
475 |
|
|
ahead */
|
476 |
|
|
u8 stripe_sz; /* Encoded stripe size */
|
477 |
|
|
u8 status; /* Status of the logical drive */
|
478 |
|
|
u8 write_mode; /* write mode, write_through/write_back */
|
479 |
|
|
u8 direct_io; /* direct io or through cache */
|
480 |
|
|
u8 row_size; /* Number of stripes in a row */
|
481 |
|
|
} __attribute__ ((packed)) logdrv_param;
|
482 |
|
|
|
483 |
|
|
typedef struct {
|
484 |
|
|
logdrv_param lparam;
|
485 |
|
|
adp_span_40ld span[MAX_SPAN_DEPTH];
|
486 |
|
|
}__attribute__ ((packed)) logdrv_40ld;
|
487 |
|
|
|
488 |
|
|
typedef struct {
|
489 |
|
|
logdrv_param lparam;
|
490 |
|
|
adp_span_8ld span[MAX_SPAN_DEPTH];
|
491 |
|
|
}__attribute__ ((packed)) logdrv_8ld;
|
492 |
|
|
|
493 |
|
|
typedef struct {
|
494 |
|
|
u8 type; /* Type of the device */
|
495 |
|
|
u8 cur_status; /* current status of the device */
|
496 |
|
|
u8 tag_depth; /* Level of tagging */
|
497 |
|
|
u8 sync_neg; /* sync negotiation - ENABLE or DISBALE */
|
498 |
|
|
u32 size; /* configurable size in terms of 512 byte
|
499 |
|
|
blocks */
|
500 |
|
|
}__attribute__ ((packed)) phys_drv;
|
501 |
|
|
|
502 |
|
|
typedef struct {
|
503 |
|
|
u8 nlog_drives; /* number of logical drives */
|
504 |
|
|
u8 resvd[3];
|
505 |
|
|
logdrv_40ld ldrv[MAX_LOGICAL_DRIVES_40LD];
|
506 |
|
|
phys_drv pdrv[MAX_PHYSICAL_DRIVES];
|
507 |
|
|
}__attribute__ ((packed)) disk_array_40ld;
|
508 |
|
|
|
509 |
|
|
typedef struct {
|
510 |
|
|
u8 nlog_drives; /* number of logical drives */
|
511 |
|
|
u8 resvd[3];
|
512 |
|
|
logdrv_8ld ldrv[MAX_LOGICAL_DRIVES_8LD];
|
513 |
|
|
phys_drv pdrv[MAX_PHYSICAL_DRIVES];
|
514 |
|
|
}__attribute__ ((packed)) disk_array_8ld;
|
515 |
|
|
|
516 |
|
|
/*
|
517 |
|
|
* FW Definitions & Data Structures for 8LD 4-Span and 8-Span Controllers
|
518 |
|
|
*/
|
519 |
|
|
#define MAX_STRIPES 8
|
520 |
|
|
#define SPAN4_DEPTH 4
|
521 |
|
|
#define SPAN8_DEPTH 8
|
522 |
|
|
#define MAX_PHYDRVS 5 * 16 /* 5 Channels * 16 Targets */
|
523 |
|
|
|
524 |
|
|
typedef struct {
|
525 |
|
|
unsigned char channel;
|
526 |
|
|
unsigned char target;
|
527 |
|
|
}__attribute__ ((packed)) device_t;
|
528 |
|
|
|
529 |
|
|
typedef struct {
|
530 |
|
|
unsigned long start_blk;
|
531 |
|
|
unsigned long total_blks;
|
532 |
|
|
device_t device[ MAX_STRIPES ];
|
533 |
|
|
}__attribute__ ((packed)) span_t;
|
534 |
|
|
|
535 |
|
|
typedef struct {
|
536 |
|
|
unsigned char type;
|
537 |
|
|
unsigned char curr_status;
|
538 |
|
|
unsigned char tag_depth;
|
539 |
|
|
unsigned char resvd1;
|
540 |
|
|
unsigned long size;
|
541 |
|
|
}__attribute__ ((packed)) phydrv_t;
|
542 |
|
|
|
543 |
|
|
typedef struct {
|
544 |
|
|
unsigned char span_depth;
|
545 |
|
|
unsigned char raid;
|
546 |
|
|
unsigned char read_ahead; /* 0=No rdahead,1=RDAHEAD,2=adaptive */
|
547 |
|
|
unsigned char stripe_sz;
|
548 |
|
|
unsigned char status;
|
549 |
|
|
unsigned char write_policy; /* 0=wrthru,1=wrbak */
|
550 |
|
|
unsigned char direct_io; /* 1=directio,0=cached */
|
551 |
|
|
unsigned char no_stripes;
|
552 |
|
|
span_t span[ SPAN4_DEPTH ];
|
553 |
|
|
}__attribute__ ((packed)) ld_span4_t;
|
554 |
|
|
|
555 |
|
|
typedef struct {
|
556 |
|
|
unsigned char span_depth;
|
557 |
|
|
unsigned char raid;
|
558 |
|
|
unsigned char read_ahead; /* 0=No rdahead,1=RDAHEAD,2=adaptive */
|
559 |
|
|
unsigned char stripe_sz;
|
560 |
|
|
unsigned char status;
|
561 |
|
|
unsigned char write_policy; /* 0=wrthru,1=wrbak */
|
562 |
|
|
unsigned char direct_io; /* 1=directio,0=cached */
|
563 |
|
|
unsigned char no_stripes;
|
564 |
|
|
span_t span[ SPAN8_DEPTH ];
|
565 |
|
|
}__attribute__ ((packed)) ld_span8_t;
|
566 |
|
|
|
567 |
|
|
typedef struct {
|
568 |
|
|
unsigned char no_log_drives;
|
569 |
|
|
unsigned char pad[3];
|
570 |
|
|
ld_span4_t log_drv[ MAX_LOGICAL_DRIVES_8LD ];
|
571 |
|
|
phydrv_t phys_drv[ MAX_PHYDRVS ];
|
572 |
|
|
}__attribute__ ((packed)) diskarray_span4_t;
|
573 |
|
|
|
574 |
|
|
typedef struct {
|
575 |
|
|
unsigned char no_log_drives;
|
576 |
|
|
unsigned char pad[3];
|
577 |
|
|
ld_span8_t log_drv[ MAX_LOGICAL_DRIVES_8LD ];
|
578 |
|
|
phydrv_t phys_drv[ MAX_PHYDRVS ];
|
579 |
|
|
}__attribute__ ((packed)) diskarray_span8_t;
|
580 |
|
|
|
581 |
|
|
/*
|
582 |
|
|
* User ioctl structure.
|
583 |
|
|
* This structure will be used for Traditional Method ioctl interface
|
584 |
|
|
* commands (0x80),Alternate Buffer Method (0x81) ioctl commands and the
|
585 |
|
|
* Driver ioctls.
|
586 |
|
|
* The Driver ioctl interface handles the commands at the driver level,
|
587 |
|
|
* without being sent to the card.
|
588 |
|
|
*/
|
589 |
|
|
/* system call imposed limit. Change accordingly */
|
590 |
|
|
#define IOCTL_MAX_DATALEN 4096
|
591 |
|
|
|
592 |
|
|
struct uioctl_t {
|
593 |
|
|
u32 inlen;
|
594 |
|
|
u32 outlen;
|
595 |
|
|
union {
|
596 |
|
|
u8 fca[16];
|
597 |
|
|
struct {
|
598 |
|
|
u8 opcode;
|
599 |
|
|
u8 subopcode;
|
600 |
|
|
u16 adapno;
|
601 |
|
|
#if BITS_PER_LONG == 32
|
602 |
|
|
u8 *buffer;
|
603 |
|
|
u8 pad[4];
|
604 |
|
|
#endif
|
605 |
|
|
#if BITS_PER_LONG == 64
|
606 |
|
|
u8 *buffer;
|
607 |
|
|
#endif
|
608 |
|
|
u32 length;
|
609 |
|
|
} __attribute__ ((packed)) fcs;
|
610 |
|
|
} __attribute__ ((packed)) ui;
|
611 |
|
|
u8 mbox[18]; /* 16 bytes + 2 status bytes */
|
612 |
|
|
mega_passthru pthru;
|
613 |
|
|
#if BITS_PER_LONG == 32
|
614 |
|
|
char *data; /* buffer <= 4096 for 0x80 commands */
|
615 |
|
|
char pad[4];
|
616 |
|
|
#endif
|
617 |
|
|
#if BITS_PER_LONG == 64
|
618 |
|
|
char *data;
|
619 |
|
|
#endif
|
620 |
|
|
} __attribute__ ((packed));
|
621 |
|
|
|
622 |
|
|
/*
|
623 |
|
|
* struct mcontroller is used to pass information about the controllers in the
|
624 |
|
|
* system. Its upto the application how to use the information. We are passing
|
625 |
|
|
* as much info about the cards as possible and useful. Before issuing the
|
626 |
|
|
* call to find information about the cards, the applicaiton needs to issue a
|
627 |
|
|
* ioctl first to find out the number of controllers in the system.
|
628 |
|
|
*/
|
629 |
|
|
#define MAX_CONTROLLERS 32
|
630 |
|
|
|
631 |
|
|
struct mcontroller {
|
632 |
|
|
u64 base;
|
633 |
|
|
u8 irq;
|
634 |
|
|
u8 numldrv;
|
635 |
|
|
u8 pcibus;
|
636 |
|
|
u16 pcidev;
|
637 |
|
|
u8 pcifun;
|
638 |
|
|
u16 pciid;
|
639 |
|
|
u16 pcivendor;
|
640 |
|
|
u8 pcislot;
|
641 |
|
|
u32 uid;
|
642 |
|
|
};
|
643 |
|
|
|
644 |
|
|
/*
|
645 |
|
|
* mailbox structure used for internal commands
|
646 |
|
|
*/
|
647 |
|
|
typedef struct {
|
648 |
|
|
u8 cmd;
|
649 |
|
|
u8 cmdid;
|
650 |
|
|
u8 opcode;
|
651 |
|
|
u8 subopcode;
|
652 |
|
|
u32 lba;
|
653 |
|
|
u32 xferaddr;
|
654 |
|
|
u8 logdrv;
|
655 |
|
|
u8 rsvd[3];
|
656 |
|
|
u8 numstatus;
|
657 |
|
|
u8 status;
|
658 |
|
|
} __attribute__ ((packed)) megacmd_t;
|
659 |
|
|
|
660 |
|
|
/*
|
661 |
|
|
* Defines for Driver IOCTL interface
|
662 |
|
|
*/
|
663 |
|
|
#define MEGAIOC_MAGIC 'm'
|
664 |
|
|
|
665 |
|
|
#define MEGAIOC_QNADAP 'm' /* Query # of adapters */
|
666 |
|
|
#define MEGAIOC_QDRVRVER 'e' /* Query driver version */
|
667 |
|
|
#define MEGAIOC_QADAPINFO 'g' /* Query adapter information */
|
668 |
|
|
#define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
|
669 |
|
|
#define GETADAP(mkadap) ( (mkadap) ^ MEGAIOC_MAGIC << 8 )
|
670 |
|
|
|
671 |
|
|
/*
|
672 |
|
|
* Definition for the new ioctl interface (NIT)
|
673 |
|
|
*/
|
674 |
|
|
|
675 |
|
|
/*
|
676 |
|
|
* Vendor specific Group-7 commands
|
677 |
|
|
*/
|
678 |
|
|
#define VENDOR_SPECIFIC_COMMANDS 0xE0
|
679 |
|
|
#define MEGA_INTERNAL_CMD VENDOR_SPECIFIC_COMMANDS + 0x01
|
680 |
|
|
|
681 |
|
|
/*
|
682 |
|
|
* The ioctl command. No other command shall be used for this interface
|
683 |
|
|
*/
|
684 |
|
|
#define USCSICMD VENDOR_SPECIFIC_COMMANDS
|
685 |
|
|
|
686 |
|
|
/*
|
687 |
|
|
* Data direction flags
|
688 |
|
|
*/
|
689 |
|
|
#define UIOC_RD 0x00001
|
690 |
|
|
#define UIOC_WR 0x00002
|
691 |
|
|
|
692 |
|
|
/*
|
693 |
|
|
* ioctl opcodes
|
694 |
|
|
*/
|
695 |
|
|
#define MBOX_CMD 0x00000 /* DCMD or passthru command */
|
696 |
|
|
#define GET_DRIVER_VER 0x10000 /* Get driver version */
|
697 |
|
|
#define GET_N_ADAP 0x20000 /* Get number of adapters */
|
698 |
|
|
#define GET_ADAP_INFO 0x30000 /* Get information about a adapter */
|
699 |
|
|
#define GET_CAP 0x40000 /* Get ioctl capabilities */
|
700 |
|
|
#define GET_STATS 0x50000 /* Get statistics, including error info */
|
701 |
|
|
|
702 |
|
|
|
703 |
|
|
/*
|
704 |
|
|
* The ioctl structure.
|
705 |
|
|
* MBOX macro converts a nitioctl_t structure to megacmd_t pointer and
|
706 |
|
|
* MBOX_P macro converts a nitioctl_t pointer to megacmd_t pointer.
|
707 |
|
|
*/
|
708 |
|
|
typedef struct {
|
709 |
|
|
char signature[8]; /* Must contain "MEGANIT" */
|
710 |
|
|
u32 opcode; /* opcode for the command */
|
711 |
|
|
u32 adapno; /* adapter number */
|
712 |
|
|
union {
|
713 |
|
|
u8 __raw_mbox[18];
|
714 |
|
|
caddr_t __uaddr; /* xferaddr for non-mbox cmds */
|
715 |
|
|
}__ua;
|
716 |
|
|
|
717 |
|
|
#define uioc_rmbox __ua.__raw_mbox
|
718 |
|
|
#define MBOX(uioc) ((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
|
719 |
|
|
#define MBOX_P(uioc) ((megacmd_t *)&((uioc)->__ua.__raw_mbox[0]))
|
720 |
|
|
#define uioc_uaddr __ua.__uaddr
|
721 |
|
|
|
722 |
|
|
u32 xferlen; /* xferlen for DCMD and non-mbox
|
723 |
|
|
commands */
|
724 |
|
|
u32 flags; /* data direction flags */
|
725 |
|
|
}nitioctl_t;
|
726 |
|
|
|
727 |
|
|
|
728 |
|
|
/*
|
729 |
|
|
* I/O statistics for some applications like SNMP agent. The caller must
|
730 |
|
|
* provide the number of logical drives for which status should be reported.
|
731 |
|
|
*/
|
732 |
|
|
typedef struct {
|
733 |
|
|
int num_ldrv; /* Number for logical drives for which the
|
734 |
|
|
status should be reported. */
|
735 |
|
|
u32 nreads[MAX_LOGICAL_DRIVES_40LD]; /* number of reads for
|
736 |
|
|
each logical drive */
|
737 |
|
|
u32 nreadblocks[MAX_LOGICAL_DRIVES_40LD]; /* number of blocks
|
738 |
|
|
read for each logical
|
739 |
|
|
drive */
|
740 |
|
|
u32 nwrites[MAX_LOGICAL_DRIVES_40LD]; /* number of writes
|
741 |
|
|
for each logical
|
742 |
|
|
drive */
|
743 |
|
|
u32 nwriteblocks[MAX_LOGICAL_DRIVES_40LD]; /* number of blocks
|
744 |
|
|
writes for each
|
745 |
|
|
logical drive */
|
746 |
|
|
u32 rd_errors[MAX_LOGICAL_DRIVES_40LD]; /* number of read
|
747 |
|
|
errors for each
|
748 |
|
|
logical drive */
|
749 |
|
|
u32 wr_errors[MAX_LOGICAL_DRIVES_40LD]; /* number of write
|
750 |
|
|
errors for each
|
751 |
|
|
logical drive */
|
752 |
|
|
}megastat_t;
|
753 |
|
|
|
754 |
|
|
|
755 |
|
|
struct private_bios_data {
|
756 |
|
|
u8 geometry:4; /*
|
757 |
|
|
* bits 0-3 - BIOS geometry
|
758 |
|
|
* 0x0001 - 1GB
|
759 |
|
|
* 0x0010 - 2GB
|
760 |
|
|
* 0x1000 - 8GB
|
761 |
|
|
* Others values are invalid
|
762 |
|
|
*/
|
763 |
|
|
u8 unused:4; /* bits 4-7 are unused */
|
764 |
|
|
u8 boot_drv; /*
|
765 |
|
|
* logical drive set as boot drive
|
766 |
|
|
* 0..7 - for 8LD cards
|
767 |
|
|
* 0..39 - for 40LD cards
|
768 |
|
|
*/
|
769 |
|
|
u8 rsvd[12];
|
770 |
|
|
u16 cksum; /* 0-(sum of first 13 bytes of this structure) */
|
771 |
|
|
} __attribute__ ((packed));
|
772 |
|
|
|
773 |
|
|
|
774 |
|
|
|
775 |
|
|
|
776 |
|
|
/*
|
777 |
|
|
* Mailbox and firmware commands and subopcodes used in this driver.
|
778 |
|
|
*/
|
779 |
|
|
|
780 |
|
|
#define MEGA_MBOXCMD_LREAD 0x01
|
781 |
|
|
#define MEGA_MBOXCMD_LWRITE 0x02
|
782 |
|
|
#define MEGA_MBOXCMD_PASSTHRU 0x03
|
783 |
|
|
#define MEGA_MBOXCMD_ADPEXTINQ 0x04
|
784 |
|
|
#define MEGA_MBOXCMD_ADAPTERINQ 0x05
|
785 |
|
|
#define MEGA_MBOXCMD_LREAD64 0xA7
|
786 |
|
|
#define MEGA_MBOXCMD_LWRITE64 0xA8
|
787 |
|
|
#define MEGA_MBOXCMD_PASSTHRU64 0xC3
|
788 |
|
|
#define MEGA_MBOXCMD_EXTPTHRU 0xE3
|
789 |
|
|
|
790 |
|
|
#define MAIN_MISC_OPCODE 0xA4 /* f/w misc opcode */
|
791 |
|
|
#define GET_MAX_SG_SUPPORT 0x01 /* get max sg len supported by f/w */
|
792 |
|
|
|
793 |
|
|
#define FC_NEW_CONFIG 0xA1
|
794 |
|
|
#define NC_SUBOP_PRODUCT_INFO 0x0E
|
795 |
|
|
#define NC_SUBOP_ENQUIRY3 0x0F
|
796 |
|
|
#define ENQ3_GET_SOLICITED_FULL 0x02
|
797 |
|
|
#define OP_DCMD_READ_CONFIG 0x04
|
798 |
|
|
#define NEW_READ_CONFIG_8LD 0x67
|
799 |
|
|
#define READ_CONFIG_8LD 0x07
|
800 |
|
|
#define FLUSH_ADAPTER 0x0A
|
801 |
|
|
#define FLUSH_SYSTEM 0xFE
|
802 |
|
|
|
803 |
|
|
/*
|
804 |
|
|
* Command for random deletion of logical drives
|
805 |
|
|
*/
|
806 |
|
|
#define FC_DEL_LOGDRV 0xA4 /* f/w command */
|
807 |
|
|
#define OP_SUP_DEL_LOGDRV 0x2A /* is feature supported */
|
808 |
|
|
#define OP_GET_LDID_MAP 0x18 /* get ldid and logdrv number map */
|
809 |
|
|
#define OP_DEL_LOGDRV 0x1C /* delete logical drive */
|
810 |
|
|
|
811 |
|
|
/*
|
812 |
|
|
* BIOS commands
|
813 |
|
|
*/
|
814 |
|
|
#define IS_BIOS_ENABLED 0x62
|
815 |
|
|
#define GET_BIOS 0x01
|
816 |
|
|
#define CHNL_CLASS 0xA9
|
817 |
|
|
#define GET_CHNL_CLASS 0x00
|
818 |
|
|
#define SET_CHNL_CLASS 0x01
|
819 |
|
|
#define CH_RAID 0x01
|
820 |
|
|
#define CH_SCSI 0x00
|
821 |
|
|
#define BIOS_PVT_DATA 0x40
|
822 |
|
|
#define GET_BIOS_PVT_DATA 0x00
|
823 |
|
|
|
824 |
|
|
|
825 |
|
|
/*
|
826 |
|
|
* Commands to support clustering
|
827 |
|
|
*/
|
828 |
|
|
#define MEGA_GET_TARGET_ID 0x7D
|
829 |
|
|
#define MEGA_CLUSTER_OP 0x70
|
830 |
|
|
#define MEGA_GET_CLUSTER_MODE 0x02
|
831 |
|
|
#define MEGA_CLUSTER_CMD 0x6E
|
832 |
|
|
#define MEGA_RESERVE_LD 0x01
|
833 |
|
|
#define MEGA_RELEASE_LD 0x02
|
834 |
|
|
#define MEGA_RESET_RESERVATIONS 0x03
|
835 |
|
|
#define MEGA_RESERVATION_STATUS 0x04
|
836 |
|
|
#define MEGA_RESERVE_PD 0x05
|
837 |
|
|
#define MEGA_RELEASE_PD 0x06
|
838 |
|
|
|
839 |
|
|
|
840 |
|
|
/*
|
841 |
|
|
* Module battery status
|
842 |
|
|
*/
|
843 |
|
|
#define MEGA_BATT_MODULE_MISSING 0x01
|
844 |
|
|
#define MEGA_BATT_LOW_VOLTAGE 0x02
|
845 |
|
|
#define MEGA_BATT_TEMP_HIGH 0x04
|
846 |
|
|
#define MEGA_BATT_PACK_MISSING 0x08
|
847 |
|
|
#define MEGA_BATT_CHARGE_MASK 0x30
|
848 |
|
|
#define MEGA_BATT_CHARGE_DONE 0x00
|
849 |
|
|
#define MEGA_BATT_CHARGE_INPROG 0x10
|
850 |
|
|
#define MEGA_BATT_CHARGE_FAIL 0x20
|
851 |
|
|
#define MEGA_BATT_CYCLES_EXCEEDED 0x40
|
852 |
|
|
|
853 |
|
|
/*
|
854 |
|
|
* Physical drive states.
|
855 |
|
|
*/
|
856 |
|
|
#define PDRV_UNCNF 0
|
857 |
|
|
#define PDRV_ONLINE 3
|
858 |
|
|
#define PDRV_FAILED 4
|
859 |
|
|
#define PDRV_RBLD 5
|
860 |
|
|
#define PDRV_HOTSPARE 6
|
861 |
|
|
|
862 |
|
|
|
863 |
|
|
/*
|
864 |
|
|
* Raid logical drive states.
|
865 |
|
|
*/
|
866 |
|
|
#define RDRV_OFFLINE 0
|
867 |
|
|
#define RDRV_DEGRADED 1
|
868 |
|
|
#define RDRV_OPTIMAL 2
|
869 |
|
|
#define RDRV_DELETED 3
|
870 |
|
|
|
871 |
|
|
/*
|
872 |
|
|
* Read, write and cache policies
|
873 |
|
|
*/
|
874 |
|
|
#define NO_READ_AHEAD 0
|
875 |
|
|
#define READ_AHEAD 1
|
876 |
|
|
#define ADAP_READ_AHEAD 2
|
877 |
|
|
#define WRMODE_WRITE_THRU 0
|
878 |
|
|
#define WRMODE_WRITE_BACK 1
|
879 |
|
|
#define CACHED_IO 0
|
880 |
|
|
#define DIRECT_IO 1
|
881 |
|
|
|
882 |
|
|
|
883 |
|
|
/*
|
884 |
|
|
* Each controller's soft state
|
885 |
|
|
*/
|
886 |
|
|
typedef struct {
|
887 |
|
|
int this_id; /* our id, may set to different than 7 if
|
888 |
|
|
clustering is available */
|
889 |
|
|
u32 flag;
|
890 |
|
|
|
891 |
|
|
unsigned long base;
|
892 |
|
|
|
893 |
|
|
/* mbox64 with mbox not aligned on 16-byte boundry */
|
894 |
|
|
mbox64_t *una_mbox64;
|
895 |
|
|
dma_addr_t una_mbox64_dma;
|
896 |
|
|
|
897 |
|
|
volatile mbox64_t *mbox64;/* ptr to 64-bit mailbox */
|
898 |
|
|
volatile mbox_t *mbox; /* ptr to standard mailbox */
|
899 |
|
|
dma_addr_t mbox_dma;
|
900 |
|
|
struct pci_dev *dev;
|
901 |
|
|
|
902 |
|
|
struct list_head free_list;
|
903 |
|
|
struct list_head pending_list;
|
904 |
|
|
|
905 |
|
|
struct Scsi_Host *host;
|
906 |
|
|
|
907 |
|
|
#define MEGA_BUFFER_SIZE (2*1024)
|
908 |
|
|
u8 *mega_buffer;
|
909 |
|
|
dma_addr_t buf_dma_handle;
|
910 |
|
|
|
911 |
|
|
mega_product_info product_info;
|
912 |
|
|
|
913 |
|
|
u8 max_cmds;
|
914 |
|
|
scb_t *scb_list;
|
915 |
|
|
|
916 |
|
|
atomic_t pend_cmds; /* maintain a counter for
|
917 |
|
|
pending commands in firmware */
|
918 |
|
|
|
919 |
|
|
#if MEGA_HAVE_STATS
|
920 |
|
|
u32 nreads[MAX_LOGICAL_DRIVES_40LD];
|
921 |
|
|
u32 nreadblocks[MAX_LOGICAL_DRIVES_40LD];
|
922 |
|
|
u32 nwrites[MAX_LOGICAL_DRIVES_40LD];
|
923 |
|
|
u32 nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
|
924 |
|
|
u32 rd_errors[MAX_LOGICAL_DRIVES_40LD];
|
925 |
|
|
u32 wr_errors[MAX_LOGICAL_DRIVES_40LD];
|
926 |
|
|
#endif
|
927 |
|
|
|
928 |
|
|
/* Host adapter parameters */
|
929 |
|
|
u8 numldrv;
|
930 |
|
|
u8 fw_version[7];
|
931 |
|
|
u8 bios_version[7];
|
932 |
|
|
|
933 |
|
|
#ifdef CONFIG_PROC_FS
|
934 |
|
|
struct proc_dir_entry *controller_proc_dir_entry;
|
935 |
|
|
struct proc_dir_entry *proc_read;
|
936 |
|
|
struct proc_dir_entry *proc_stat;
|
937 |
|
|
struct proc_dir_entry *proc_mbox;
|
938 |
|
|
|
939 |
|
|
#if MEGA_HAVE_ENH_PROC
|
940 |
|
|
struct proc_dir_entry *proc_rr;
|
941 |
|
|
struct proc_dir_entry *proc_battery;
|
942 |
|
|
#define MAX_PROC_CHANNELS 4
|
943 |
|
|
struct proc_dir_entry *proc_pdrvstat[MAX_PROC_CHANNELS];
|
944 |
|
|
struct proc_dir_entry *proc_rdrvstat[MAX_PROC_CHANNELS];
|
945 |
|
|
#endif
|
946 |
|
|
|
947 |
|
|
#endif
|
948 |
|
|
|
949 |
|
|
int has_64bit_addr; /* are we using 64-bit addressing */
|
950 |
|
|
int support_ext_cdb;
|
951 |
|
|
int boot_ldrv_enabled;
|
952 |
|
|
int boot_ldrv;
|
953 |
|
|
int boot_pdrv_enabled; /* boot from physical drive */
|
954 |
|
|
int boot_pdrv_ch; /* boot physical drive channel */
|
955 |
|
|
int boot_pdrv_tgt; /* boot physical drive target */
|
956 |
|
|
|
957 |
|
|
|
958 |
|
|
int support_random_del; /* Do we support random deletion of
|
959 |
|
|
logdrvs */
|
960 |
|
|
int read_ldidmap; /* set after logical drive deltion. The
|
961 |
|
|
logical drive number must be read from the
|
962 |
|
|
map */
|
963 |
|
|
atomic_t quiescent; /* a stage reached when delete logical
|
964 |
|
|
drive needs to be done. Stop
|
965 |
|
|
sending requests to the hba till
|
966 |
|
|
delete operation is completed */
|
967 |
|
|
spinlock_t lock;
|
968 |
|
|
spinlock_t *host_lock; // pointer to appropriate lock
|
969 |
|
|
|
970 |
|
|
u8 logdrv_chan[MAX_CHANNELS+NVIRT_CHAN]; /* logical drive are on
|
971 |
|
|
what channels. */
|
972 |
|
|
int mega_ch_class;
|
973 |
|
|
|
974 |
|
|
u8 sglen; /* f/w supported scatter-gather list length */
|
975 |
|
|
|
976 |
|
|
scb_t int_scb;
|
977 |
|
|
Scsi_Cmnd int_scmd;
|
978 |
|
|
struct semaphore int_mtx; /* To synchronize the internal
|
979 |
|
|
commands */
|
980 |
|
|
wait_queue_head_t int_waitq; /* wait queue for internal
|
981 |
|
|
cmds */
|
982 |
|
|
|
983 |
|
|
int has_cluster; /* cluster support on this HBA */
|
984 |
|
|
}adapter_t;
|
985 |
|
|
|
986 |
|
|
|
987 |
|
|
struct mega_hbas {
|
988 |
|
|
int is_bios_enabled;
|
989 |
|
|
adapter_t *hostdata_addr;
|
990 |
|
|
};
|
991 |
|
|
|
992 |
|
|
|
993 |
|
|
/*
|
994 |
|
|
* For state flag. Do not use LSB(8 bits) which are
|
995 |
|
|
* reserved for storing info about channels.
|
996 |
|
|
*/
|
997 |
|
|
#define IN_ABORT 0x80000000L
|
998 |
|
|
#define IN_RESET 0x40000000L
|
999 |
|
|
#define BOARD_MEMMAP 0x20000000L
|
1000 |
|
|
#define BOARD_IOMAP 0x10000000L
|
1001 |
|
|
#define BOARD_40LD 0x08000000L
|
1002 |
|
|
#define BOARD_64BIT 0x04000000L
|
1003 |
|
|
|
1004 |
|
|
#define INTR_VALID 0x40
|
1005 |
|
|
|
1006 |
|
|
#define PCI_CONF_AMISIG 0xa0
|
1007 |
|
|
#define PCI_CONF_AMISIG64 0xa4
|
1008 |
|
|
|
1009 |
|
|
|
1010 |
|
|
#define MEGA_DMA_TYPE_NONE 0xFFFF
|
1011 |
|
|
#define MEGA_BULK_DATA 0x0001
|
1012 |
|
|
#define MEGA_SGLIST 0x0002
|
1013 |
|
|
|
1014 |
|
|
/*
|
1015 |
|
|
* lockscope definitions, callers can specify the lock scope with this data
|
1016 |
|
|
* type. LOCK_INT would mean the caller has not acquired the lock before
|
1017 |
|
|
* making the call and LOCK_EXT would mean otherwise.
|
1018 |
|
|
*/
|
1019 |
|
|
typedef enum { LOCK_INT, LOCK_EXT } lockscope_t;
|
1020 |
|
|
|
1021 |
|
|
/*
|
1022 |
|
|
* Parameters for the io-mapped controllers
|
1023 |
|
|
*/
|
1024 |
|
|
|
1025 |
|
|
/* I/O Port offsets */
|
1026 |
|
|
#define CMD_PORT 0x00
|
1027 |
|
|
#define ACK_PORT 0x00
|
1028 |
|
|
#define TOGGLE_PORT 0x01
|
1029 |
|
|
#define INTR_PORT 0x0a
|
1030 |
|
|
|
1031 |
|
|
#define MBOX_BUSY_PORT 0x00
|
1032 |
|
|
#define MBOX_PORT0 0x04
|
1033 |
|
|
#define MBOX_PORT1 0x05
|
1034 |
|
|
#define MBOX_PORT2 0x06
|
1035 |
|
|
#define MBOX_PORT3 0x07
|
1036 |
|
|
#define ENABLE_MBOX_REGION 0x0B
|
1037 |
|
|
|
1038 |
|
|
/* I/O Port Values */
|
1039 |
|
|
#define ISSUE_BYTE 0x10
|
1040 |
|
|
#define ACK_BYTE 0x08
|
1041 |
|
|
#define ENABLE_INTR_BYTE 0xc0
|
1042 |
|
|
#define DISABLE_INTR_BYTE 0x00
|
1043 |
|
|
#define VALID_INTR_BYTE 0x40
|
1044 |
|
|
#define MBOX_BUSY_BYTE 0x10
|
1045 |
|
|
#define ENABLE_MBOX_BYTE 0x00
|
1046 |
|
|
|
1047 |
|
|
|
1048 |
|
|
/* Setup some port macros here */
|
1049 |
|
|
#define issue_command(adapter) \
|
1050 |
|
|
outb_p(ISSUE_BYTE, (adapter)->base + CMD_PORT)
|
1051 |
|
|
|
1052 |
|
|
#define irq_state(adapter) inb_p((adapter)->base + INTR_PORT)
|
1053 |
|
|
|
1054 |
|
|
#define set_irq_state(adapter, value) \
|
1055 |
|
|
outb_p((value), (adapter)->base + INTR_PORT)
|
1056 |
|
|
|
1057 |
|
|
#define irq_ack(adapter) \
|
1058 |
|
|
outb_p(ACK_BYTE, (adapter)->base + ACK_PORT)
|
1059 |
|
|
|
1060 |
|
|
#define irq_enable(adapter) \
|
1061 |
|
|
outb_p(ENABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
|
1062 |
|
|
|
1063 |
|
|
#define irq_disable(adapter) \
|
1064 |
|
|
outb_p(DISABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
|
1065 |
|
|
|
1066 |
|
|
|
1067 |
|
|
/*
|
1068 |
|
|
* This is our SYSDEP area. All kernel specific detail should be placed here -
|
1069 |
|
|
* as much as possible
|
1070 |
|
|
*/
|
1071 |
|
|
|
1072 |
|
|
/*
|
1073 |
|
|
* End of SYSDEP area
|
1074 |
|
|
*/
|
1075 |
|
|
|
1076 |
|
|
/*
|
1077 |
|
|
* ASSERT macro for megaraid. This should panic but printk should do for now
|
1078 |
|
|
*/
|
1079 |
|
|
#ifdef DEBUG
|
1080 |
|
|
#define ASSERT( expression ) \
|
1081 |
|
|
if( !(expression) ) { \
|
1082 |
|
|
panic("assertion failed: %s, file: %s, line: %d\n", \
|
1083 |
|
|
#expression, __FILE__, __LINE__); \
|
1084 |
|
|
}
|
1085 |
|
|
#else
|
1086 |
|
|
#define ASSERT(expression)
|
1087 |
|
|
#endif
|
1088 |
|
|
|
1089 |
|
|
#define MBOX_ABORT_SLEEP 60
|
1090 |
|
|
#define MBOX_RESET_SLEEP 30
|
1091 |
|
|
|
1092 |
|
|
const char *megaraid_info (struct Scsi_Host *);
|
1093 |
|
|
|
1094 |
|
|
static int megaraid_detect(Scsi_Host_Template *);
|
1095 |
|
|
static void mega_find_card(Scsi_Host_Template *, u16, u16);
|
1096 |
|
|
static int mega_query_adapter(adapter_t *);
|
1097 |
|
|
static inline int issue_scb(adapter_t *, scb_t *);
|
1098 |
|
|
static int mega_setup_mailbox(adapter_t *);
|
1099 |
|
|
|
1100 |
|
|
static int megaraid_queue (Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
|
1101 |
|
|
static scb_t * mega_build_cmd(adapter_t *, Scsi_Cmnd *, int *);
|
1102 |
|
|
static inline scb_t *mega_allocate_scb(adapter_t *, Scsi_Cmnd *);
|
1103 |
|
|
static void __mega_runpendq(adapter_t *);
|
1104 |
|
|
static inline void mega_runpendq(adapter_t *);
|
1105 |
|
|
static int issue_scb_block(adapter_t *, u_char *);
|
1106 |
|
|
|
1107 |
|
|
static void megaraid_isr_memmapped(int, void *, struct pt_regs *);
|
1108 |
|
|
static inline void megaraid_memmbox_ack_sequence(adapter_t *);
|
1109 |
|
|
static void megaraid_isr_iomapped(int, void *, struct pt_regs *);
|
1110 |
|
|
static inline void megaraid_iombox_ack_sequence(adapter_t *);
|
1111 |
|
|
|
1112 |
|
|
static void mega_free_scb(adapter_t *, scb_t *);
|
1113 |
|
|
|
1114 |
|
|
static int megaraid_release (struct Scsi_Host *);
|
1115 |
|
|
static int megaraid_command (Scsi_Cmnd *);
|
1116 |
|
|
static int megaraid_abort(Scsi_Cmnd *);
|
1117 |
|
|
static int megaraid_reset(Scsi_Cmnd *);
|
1118 |
|
|
static int megaraid_biosparam (Disk *, kdev_t, int *);
|
1119 |
|
|
|
1120 |
|
|
static int mega_build_sglist (adapter_t *adapter, scb_t *scb,
|
1121 |
|
|
u32 *buffer, u32 *length);
|
1122 |
|
|
static inline int mega_busywait_mbox (adapter_t *);
|
1123 |
|
|
static int __mega_busywait_mbox (adapter_t *);
|
1124 |
|
|
static inline void mega_cmd_done(adapter_t *, u8 [], int, int);
|
1125 |
|
|
static inline void mega_free_sgl (adapter_t *adapter);
|
1126 |
|
|
static void mega_8_to_40ld (mraid_inquiry *inquiry,
|
1127 |
|
|
mega_inquiry3 *enquiry3, mega_product_info *);
|
1128 |
|
|
|
1129 |
|
|
static int megaraid_reboot_notify (struct notifier_block *,
|
1130 |
|
|
unsigned long, void *);
|
1131 |
|
|
static int megadev_open (struct inode *, struct file *);
|
1132 |
|
|
static int megadev_ioctl (struct inode *, struct file *, unsigned int,
|
1133 |
|
|
unsigned long);
|
1134 |
|
|
static int mega_m_to_n(void *, nitioctl_t *);
|
1135 |
|
|
static int mega_n_to_m(void *, megacmd_t *);
|
1136 |
|
|
static int megadev_close (struct inode *, struct file *);
|
1137 |
|
|
|
1138 |
|
|
static int mega_init_scb (adapter_t *);
|
1139 |
|
|
|
1140 |
|
|
static int mega_is_bios_enabled (adapter_t *);
|
1141 |
|
|
static void mega_reorder_hosts (void);
|
1142 |
|
|
static void mega_swap_hosts (struct Scsi_Host *, struct Scsi_Host *);
|
1143 |
|
|
|
1144 |
|
|
#ifdef CONFIG_PROC_FS
|
1145 |
|
|
static void mega_create_proc_entry(int, struct proc_dir_entry *);
|
1146 |
|
|
static int proc_read_config(char *, char **, off_t, int, int *, void *);
|
1147 |
|
|
static int proc_read_stat(char *, char **, off_t, int, int *, void *);
|
1148 |
|
|
static int proc_read_mbox(char *, char **, off_t, int, int *, void *);
|
1149 |
|
|
static int proc_rebuild_rate(char *, char **, off_t, int, int *, void *);
|
1150 |
|
|
static int proc_battery(char *, char **, off_t, int, int *, void *);
|
1151 |
|
|
static int proc_pdrv_ch0(char *, char **, off_t, int, int *, void *);
|
1152 |
|
|
static int proc_pdrv_ch1(char *, char **, off_t, int, int *, void *);
|
1153 |
|
|
static int proc_pdrv_ch2(char *, char **, off_t, int, int *, void *);
|
1154 |
|
|
static int proc_pdrv_ch3(char *, char **, off_t, int, int *, void *);
|
1155 |
|
|
static int proc_pdrv(adapter_t *, char *, int);
|
1156 |
|
|
static int proc_rdrv_10(char *, char **, off_t, int, int *, void *);
|
1157 |
|
|
static int proc_rdrv_20(char *, char **, off_t, int, int *, void *);
|
1158 |
|
|
static int proc_rdrv_30(char *, char **, off_t, int, int *, void *);
|
1159 |
|
|
static int proc_rdrv_40(char *, char **, off_t, int, int *, void *);
|
1160 |
|
|
static int proc_rdrv(adapter_t *, char *, int, int);
|
1161 |
|
|
|
1162 |
|
|
static int mega_adapinq(adapter_t *, dma_addr_t);
|
1163 |
|
|
static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
|
1164 |
|
|
static inline caddr_t mega_allocate_inquiry(dma_addr_t *, struct pci_dev *);
|
1165 |
|
|
static inline void mega_free_inquiry(caddr_t, dma_addr_t, struct pci_dev *);
|
1166 |
|
|
static int mega_print_inquiry(char *, char *);
|
1167 |
|
|
#endif
|
1168 |
|
|
|
1169 |
|
|
static int mega_support_ext_cdb(adapter_t *);
|
1170 |
|
|
static mega_passthru* mega_prepare_passthru(adapter_t *, scb_t *,
|
1171 |
|
|
Scsi_Cmnd *, int, int);
|
1172 |
|
|
static mega_ext_passthru* mega_prepare_extpassthru(adapter_t *,
|
1173 |
|
|
scb_t *, Scsi_Cmnd *, int, int);
|
1174 |
|
|
static void mega_enum_raid_scsi(adapter_t *);
|
1175 |
|
|
static int mega_partsize(Disk *, kdev_t, int *);
|
1176 |
|
|
static void mega_get_boot_drv(adapter_t *);
|
1177 |
|
|
static inline int mega_get_ldrv_num(adapter_t *, Scsi_Cmnd *, int);
|
1178 |
|
|
static int mega_support_random_del(adapter_t *);
|
1179 |
|
|
static int mega_del_logdrv(adapter_t *, int);
|
1180 |
|
|
static int mega_do_del_logdrv(adapter_t *, int);
|
1181 |
|
|
static void mega_get_max_sgl(adapter_t *);
|
1182 |
|
|
static int mega_internal_command(adapter_t *, lockscope_t, megacmd_t *,
|
1183 |
|
|
mega_passthru *);
|
1184 |
|
|
static void mega_internal_done(Scsi_Cmnd *);
|
1185 |
|
|
static int mega_support_cluster(adapter_t *);
|
1186 |
|
|
#endif
|
1187 |
|
|
|
1188 |
|
|
/* vi: set ts=8 sw=8 tw=78: */
|