blob: 13ac37e80075122bedea4766ed7f9bc8f1149ea7 [file] [log] [blame]
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001/*
2 *
3 * Linux MegaRAID driver for SAS based RAID controllers
4 *
bo yangf28cd7c2007-11-09 04:44:56 -05005 * Copyright (c) 2003-2005 LSI Corporation.
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04006 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * FILE : megaraid_sas.h
13 */
14
15#ifndef LSI_MEGARAID_SAS_H
16#define LSI_MEGARAID_SAS_H
17
Randy Dunlapa69b74d2007-01-05 22:41:48 -080018/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040019 * MegaRAID SAS Driver meta data
20 */
Yang, Bo24541f92008-08-10 12:42:39 -070021#define MEGASAS_VERSION "00.00.04.01"
22#define MEGASAS_RELDATE "July 24, 2008"
23#define MEGASAS_EXT_VERSION "Thu July 24 11:41:51 PST 2008"
Sumant Patro0e989362006-06-20 15:32:37 -070024
25/*
26 * Device IDs
27 */
28#define PCI_DEVICE_ID_LSI_SAS1078R 0x0060
bo yangaf7a5642008-03-17 04:13:07 -040029#define PCI_DEVICE_ID_LSI_SAS1078DE 0x007C
Sumant Patro0e989362006-06-20 15:32:37 -070030#define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413
Yang, Bo6610a6b2008-08-10 12:42:38 -070031#define PCI_DEVICE_ID_LSI_SAS1078GEN2 0x0078
32#define PCI_DEVICE_ID_LSI_SAS0079GEN2 0x0079
Yang, Bo87911122009-10-06 14:31:54 -060033#define PCI_DEVICE_ID_LSI_SAS0073SKINNY 0x0073
34#define PCI_DEVICE_ID_LSI_SAS0071SKINNY 0x0071
Sumant Patro0e989362006-06-20 15:32:37 -070035
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040036/*
37 * =====================================
38 * MegaRAID SAS MFI firmware definitions
39 * =====================================
40 */
41
42/*
43 * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
44 * protocol between the software and firmware. Commands are issued using
45 * "message frames"
46 */
47
Randy Dunlapa69b74d2007-01-05 22:41:48 -080048/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040049 * FW posts its state in upper 4 bits of outbound_msg_0 register
50 */
51#define MFI_STATE_MASK 0xF0000000
52#define MFI_STATE_UNDEFINED 0x00000000
53#define MFI_STATE_BB_INIT 0x10000000
54#define MFI_STATE_FW_INIT 0x40000000
55#define MFI_STATE_WAIT_HANDSHAKE 0x60000000
56#define MFI_STATE_FW_INIT_2 0x70000000
57#define MFI_STATE_DEVICE_SCAN 0x80000000
Sumant Patroe3bbff92006-10-03 12:28:49 -070058#define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040059#define MFI_STATE_FLUSH_CACHE 0xA0000000
60#define MFI_STATE_READY 0xB0000000
61#define MFI_STATE_OPERATIONAL 0xC0000000
62#define MFI_STATE_FAULT 0xF0000000
63
64#define MEGAMFI_FRAME_SIZE 64
65
Randy Dunlapa69b74d2007-01-05 22:41:48 -080066/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040067 * During FW init, clear pending cmds & reset state using inbound_msg_0
68 *
69 * ABORT : Abort all pending cmds
70 * READY : Move from OPERATIONAL to READY state; discard queue info
71 * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
72 * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
Sumant Patroe3bbff92006-10-03 12:28:49 -070073 * HOTPLUG : Resume from Hotplug
74 * MFI_STOP_ADP : Send signal to FW to stop processing
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040075 */
Sumant Patroe3bbff92006-10-03 12:28:49 -070076#define MFI_INIT_ABORT 0x00000001
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040077#define MFI_INIT_READY 0x00000002
78#define MFI_INIT_MFIMODE 0x00000004
79#define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
Sumant Patroe3bbff92006-10-03 12:28:49 -070080#define MFI_INIT_HOTPLUG 0x00000010
81#define MFI_STOP_ADP 0x00000020
82#define MFI_RESET_FLAGS MFI_INIT_READY| \
83 MFI_INIT_MFIMODE| \
84 MFI_INIT_ABORT
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040085
Randy Dunlapa69b74d2007-01-05 22:41:48 -080086/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040087 * MFI frame flags
88 */
89#define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
90#define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
91#define MFI_FRAME_SGL32 0x0000
92#define MFI_FRAME_SGL64 0x0002
93#define MFI_FRAME_SENSE32 0x0000
94#define MFI_FRAME_SENSE64 0x0004
95#define MFI_FRAME_DIR_NONE 0x0000
96#define MFI_FRAME_DIR_WRITE 0x0008
97#define MFI_FRAME_DIR_READ 0x0010
98#define MFI_FRAME_DIR_BOTH 0x0018
Yang, Bof4c9a132009-10-06 14:43:28 -060099#define MFI_FRAME_IEEE 0x0020
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400100
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800101/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400102 * Definition for cmd_status
103 */
104#define MFI_CMD_STATUS_POLL_MODE 0xFF
105
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800106/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400107 * MFI command opcodes
108 */
109#define MFI_CMD_INIT 0x00
110#define MFI_CMD_LD_READ 0x01
111#define MFI_CMD_LD_WRITE 0x02
112#define MFI_CMD_LD_SCSI_IO 0x03
113#define MFI_CMD_PD_SCSI_IO 0x04
114#define MFI_CMD_DCMD 0x05
115#define MFI_CMD_ABORT 0x06
116#define MFI_CMD_SMP 0x07
117#define MFI_CMD_STP 0x08
118
119#define MR_DCMD_CTRL_GET_INFO 0x01010000
120
121#define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
122#define MR_FLUSH_CTRL_CACHE 0x01
123#define MR_FLUSH_DISK_CACHE 0x02
124
125#define MR_DCMD_CTRL_SHUTDOWN 0x01050000
bo yang31ea7082007-11-07 12:09:50 -0500126#define MR_DCMD_HIBERNATE_SHUTDOWN 0x01060000
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400127#define MR_ENABLE_DRIVE_SPINDOWN 0x01
128
129#define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
130#define MR_DCMD_CTRL_EVENT_GET 0x01040300
131#define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
132#define MR_DCMD_LD_GET_PROPERTIES 0x03030000
133
134#define MR_DCMD_CLUSTER 0x08000000
135#define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
136#define MR_DCMD_CLUSTER_RESET_LD 0x08010200
Yang, Bo81e403c2009-10-06 14:27:54 -0600137#define MR_DCMD_PD_LIST_QUERY 0x02010100
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400138
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800139/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400140 * MFI command completion codes
141 */
142enum MFI_STAT {
143 MFI_STAT_OK = 0x00,
144 MFI_STAT_INVALID_CMD = 0x01,
145 MFI_STAT_INVALID_DCMD = 0x02,
146 MFI_STAT_INVALID_PARAMETER = 0x03,
147 MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
148 MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
149 MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
150 MFI_STAT_APP_IN_USE = 0x07,
151 MFI_STAT_APP_NOT_INITIALIZED = 0x08,
152 MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
153 MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
154 MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
155 MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
156 MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
157 MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
158 MFI_STAT_FLASH_BUSY = 0x0f,
159 MFI_STAT_FLASH_ERROR = 0x10,
160 MFI_STAT_FLASH_IMAGE_BAD = 0x11,
161 MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
162 MFI_STAT_FLASH_NOT_OPEN = 0x13,
163 MFI_STAT_FLASH_NOT_STARTED = 0x14,
164 MFI_STAT_FLUSH_FAILED = 0x15,
165 MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
166 MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
167 MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
168 MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
169 MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
170 MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
171 MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
172 MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
173 MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
174 MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
175 MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
176 MFI_STAT_MFC_HW_ERROR = 0x21,
177 MFI_STAT_NO_HW_PRESENT = 0x22,
178 MFI_STAT_NOT_FOUND = 0x23,
179 MFI_STAT_NOT_IN_ENCL = 0x24,
180 MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
181 MFI_STAT_PD_TYPE_WRONG = 0x26,
182 MFI_STAT_PR_DISABLED = 0x27,
183 MFI_STAT_ROW_INDEX_INVALID = 0x28,
184 MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
185 MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
186 MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
187 MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
188 MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
189 MFI_STAT_SCSI_IO_FAILED = 0x2e,
190 MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
191 MFI_STAT_SHUTDOWN_FAILED = 0x30,
192 MFI_STAT_TIME_NOT_SET = 0x31,
193 MFI_STAT_WRONG_STATE = 0x32,
194 MFI_STAT_LD_OFFLINE = 0x33,
195 MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
196 MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
197 MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
198 MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
199 MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
200
201 MFI_STAT_INVALID_STATUS = 0xFF
202};
203
204/*
205 * Number of mailbox bytes in DCMD message frame
206 */
207#define MFI_MBOX_SIZE 12
208
209enum MR_EVT_CLASS {
210
211 MR_EVT_CLASS_DEBUG = -2,
212 MR_EVT_CLASS_PROGRESS = -1,
213 MR_EVT_CLASS_INFO = 0,
214 MR_EVT_CLASS_WARNING = 1,
215 MR_EVT_CLASS_CRITICAL = 2,
216 MR_EVT_CLASS_FATAL = 3,
217 MR_EVT_CLASS_DEAD = 4,
218
219};
220
221enum MR_EVT_LOCALE {
222
223 MR_EVT_LOCALE_LD = 0x0001,
224 MR_EVT_LOCALE_PD = 0x0002,
225 MR_EVT_LOCALE_ENCL = 0x0004,
226 MR_EVT_LOCALE_BBU = 0x0008,
227 MR_EVT_LOCALE_SAS = 0x0010,
228 MR_EVT_LOCALE_CTRL = 0x0020,
229 MR_EVT_LOCALE_CONFIG = 0x0040,
230 MR_EVT_LOCALE_CLUSTER = 0x0080,
231 MR_EVT_LOCALE_ALL = 0xffff,
232
233};
234
235enum MR_EVT_ARGS {
236
237 MR_EVT_ARGS_NONE,
238 MR_EVT_ARGS_CDB_SENSE,
239 MR_EVT_ARGS_LD,
240 MR_EVT_ARGS_LD_COUNT,
241 MR_EVT_ARGS_LD_LBA,
242 MR_EVT_ARGS_LD_OWNER,
243 MR_EVT_ARGS_LD_LBA_PD_LBA,
244 MR_EVT_ARGS_LD_PROG,
245 MR_EVT_ARGS_LD_STATE,
246 MR_EVT_ARGS_LD_STRIP,
247 MR_EVT_ARGS_PD,
248 MR_EVT_ARGS_PD_ERR,
249 MR_EVT_ARGS_PD_LBA,
250 MR_EVT_ARGS_PD_LBA_LD,
251 MR_EVT_ARGS_PD_PROG,
252 MR_EVT_ARGS_PD_STATE,
253 MR_EVT_ARGS_PCI,
254 MR_EVT_ARGS_RATE,
255 MR_EVT_ARGS_STR,
256 MR_EVT_ARGS_TIME,
257 MR_EVT_ARGS_ECC,
Yang, Bo81e403c2009-10-06 14:27:54 -0600258 MR_EVT_ARGS_LD_PROP,
259 MR_EVT_ARGS_PD_SPARE,
260 MR_EVT_ARGS_PD_INDEX,
261 MR_EVT_ARGS_DIAG_PASS,
262 MR_EVT_ARGS_DIAG_FAIL,
263 MR_EVT_ARGS_PD_LBA_LBA,
264 MR_EVT_ARGS_PORT_PHY,
265 MR_EVT_ARGS_PD_MISSING,
266 MR_EVT_ARGS_PD_ADDRESS,
267 MR_EVT_ARGS_BITMAP,
268 MR_EVT_ARGS_CONNECTOR,
269 MR_EVT_ARGS_PD_PD,
270 MR_EVT_ARGS_PD_FRU,
271 MR_EVT_ARGS_PD_PATHINFO,
272 MR_EVT_ARGS_PD_POWER_STATE,
273 MR_EVT_ARGS_GENERIC,
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400274};
275
276/*
Yang, Bo81e403c2009-10-06 14:27:54 -0600277 * define constants for device list query options
278 */
279enum MR_PD_QUERY_TYPE {
280 MR_PD_QUERY_TYPE_ALL = 0,
281 MR_PD_QUERY_TYPE_STATE = 1,
282 MR_PD_QUERY_TYPE_POWER_STATE = 2,
283 MR_PD_QUERY_TYPE_MEDIA_TYPE = 3,
284 MR_PD_QUERY_TYPE_SPEED = 4,
285 MR_PD_QUERY_TYPE_EXPOSED_TO_HOST = 5,
286};
287
288enum MR_PD_STATE {
289 MR_PD_STATE_UNCONFIGURED_GOOD = 0x00,
290 MR_PD_STATE_UNCONFIGURED_BAD = 0x01,
291 MR_PD_STATE_HOT_SPARE = 0x02,
292 MR_PD_STATE_OFFLINE = 0x10,
293 MR_PD_STATE_FAILED = 0x11,
294 MR_PD_STATE_REBUILD = 0x14,
295 MR_PD_STATE_ONLINE = 0x18,
296 MR_PD_STATE_COPYBACK = 0x20,
297 MR_PD_STATE_SYSTEM = 0x40,
298 };
299
300
301 /*
302 * defines the physical drive address structure
303 */
304struct MR_PD_ADDRESS {
305 u16 deviceId;
306 u16 enclDeviceId;
307
308 union {
309 struct {
310 u8 enclIndex;
311 u8 slotNumber;
312 } mrPdAddress;
313 struct {
314 u8 enclPosition;
315 u8 enclConnectorIndex;
316 } mrEnclAddress;
317 };
318 u8 scsiDevType;
319 union {
320 u8 connectedPortBitmap;
321 u8 connectedPortNumbers;
322 };
323 u64 sasAddr[2];
324} __packed;
325
326/*
327 * defines the physical drive list structure
328 */
329struct MR_PD_LIST {
330 u32 size;
331 u32 count;
332 struct MR_PD_ADDRESS addr[1];
333} __packed;
334
335struct megasas_pd_list {
336 u16 tid;
337 u8 driveType;
338 u8 driveState;
339} __packed;
340
341/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400342 * SAS controller properties
343 */
344struct megasas_ctrl_prop {
345
346 u16 seq_num;
347 u16 pred_fail_poll_interval;
348 u16 intr_throttle_count;
349 u16 intr_throttle_timeouts;
350 u8 rebuild_rate;
351 u8 patrol_read_rate;
352 u8 bgi_rate;
353 u8 cc_rate;
354 u8 recon_rate;
355 u8 cache_flush_interval;
356 u8 spinup_drv_count;
357 u8 spinup_delay;
358 u8 cluster_enable;
359 u8 coercion_mode;
360 u8 alarm_enable;
361 u8 disable_auto_rebuild;
362 u8 disable_battery_warn;
363 u8 ecc_bucket_size;
364 u16 ecc_bucket_leak_rate;
365 u8 restore_hotspare_on_insertion;
366 u8 expose_encl_devices;
367 u8 reserved[38];
368
Yang, Bo81e403c2009-10-06 14:27:54 -0600369} __packed;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400370
371/*
372 * SAS controller information
373 */
374struct megasas_ctrl_info {
375
376 /*
377 * PCI device information
378 */
379 struct {
380
381 u16 vendor_id;
382 u16 device_id;
383 u16 sub_vendor_id;
384 u16 sub_device_id;
385 u8 reserved[24];
386
387 } __attribute__ ((packed)) pci;
388
389 /*
390 * Host interface information
391 */
392 struct {
393
394 u8 PCIX:1;
395 u8 PCIE:1;
396 u8 iSCSI:1;
397 u8 SAS_3G:1;
398 u8 reserved_0:4;
399 u8 reserved_1[6];
400 u8 port_count;
401 u64 port_addr[8];
402
403 } __attribute__ ((packed)) host_interface;
404
405 /*
406 * Device (backend) interface information
407 */
408 struct {
409
410 u8 SPI:1;
411 u8 SAS_3G:1;
412 u8 SATA_1_5G:1;
413 u8 SATA_3G:1;
414 u8 reserved_0:4;
415 u8 reserved_1[6];
416 u8 port_count;
417 u64 port_addr[8];
418
419 } __attribute__ ((packed)) device_interface;
420
421 /*
422 * List of components residing in flash. All str are null terminated
423 */
424 u32 image_check_word;
425 u32 image_component_count;
426
427 struct {
428
429 char name[8];
430 char version[32];
431 char build_date[16];
432 char built_time[16];
433
434 } __attribute__ ((packed)) image_component[8];
435
436 /*
437 * List of flash components that have been flashed on the card, but
438 * are not in use, pending reset of the adapter. This list will be
439 * empty if a flash operation has not occurred. All stings are null
440 * terminated
441 */
442 u32 pending_image_component_count;
443
444 struct {
445
446 char name[8];
447 char version[32];
448 char build_date[16];
449 char build_time[16];
450
451 } __attribute__ ((packed)) pending_image_component[8];
452
453 u8 max_arms;
454 u8 max_spans;
455 u8 max_arrays;
456 u8 max_lds;
457
458 char product_name[80];
459 char serial_no[32];
460
461 /*
462 * Other physical/controller/operation information. Indicates the
463 * presence of the hardware
464 */
465 struct {
466
467 u32 bbu:1;
468 u32 alarm:1;
469 u32 nvram:1;
470 u32 uart:1;
471 u32 reserved:28;
472
473 } __attribute__ ((packed)) hw_present;
474
475 u32 current_fw_time;
476
477 /*
478 * Maximum data transfer sizes
479 */
480 u16 max_concurrent_cmds;
481 u16 max_sge_count;
482 u32 max_request_size;
483
484 /*
485 * Logical and physical device counts
486 */
487 u16 ld_present_count;
488 u16 ld_degraded_count;
489 u16 ld_offline_count;
490
491 u16 pd_present_count;
492 u16 pd_disk_present_count;
493 u16 pd_disk_pred_failure_count;
494 u16 pd_disk_failed_count;
495
496 /*
497 * Memory size information
498 */
499 u16 nvram_size;
500 u16 memory_size;
501 u16 flash_size;
502
503 /*
504 * Error counters
505 */
506 u16 mem_correctable_error_count;
507 u16 mem_uncorrectable_error_count;
508
509 /*
510 * Cluster information
511 */
512 u8 cluster_permitted;
513 u8 cluster_active;
514
515 /*
516 * Additional max data transfer sizes
517 */
518 u16 max_strips_per_io;
519
520 /*
521 * Controller capabilities structures
522 */
523 struct {
524
525 u32 raid_level_0:1;
526 u32 raid_level_1:1;
527 u32 raid_level_5:1;
528 u32 raid_level_1E:1;
529 u32 raid_level_6:1;
530 u32 reserved:27;
531
532 } __attribute__ ((packed)) raid_levels;
533
534 struct {
535
536 u32 rbld_rate:1;
537 u32 cc_rate:1;
538 u32 bgi_rate:1;
539 u32 recon_rate:1;
540 u32 patrol_rate:1;
541 u32 alarm_control:1;
542 u32 cluster_supported:1;
543 u32 bbu:1;
544 u32 spanning_allowed:1;
545 u32 dedicated_hotspares:1;
546 u32 revertible_hotspares:1;
547 u32 foreign_config_import:1;
548 u32 self_diagnostic:1;
549 u32 mixed_redundancy_arr:1;
550 u32 global_hot_spares:1;
551 u32 reserved:17;
552
553 } __attribute__ ((packed)) adapter_operations;
554
555 struct {
556
557 u32 read_policy:1;
558 u32 write_policy:1;
559 u32 io_policy:1;
560 u32 access_policy:1;
561 u32 disk_cache_policy:1;
562 u32 reserved:27;
563
564 } __attribute__ ((packed)) ld_operations;
565
566 struct {
567
568 u8 min;
569 u8 max;
570 u8 reserved[2];
571
572 } __attribute__ ((packed)) stripe_sz_ops;
573
574 struct {
575
576 u32 force_online:1;
577 u32 force_offline:1;
578 u32 force_rebuild:1;
579 u32 reserved:29;
580
581 } __attribute__ ((packed)) pd_operations;
582
583 struct {
584
585 u32 ctrl_supports_sas:1;
586 u32 ctrl_supports_sata:1;
587 u32 allow_mix_in_encl:1;
588 u32 allow_mix_in_ld:1;
589 u32 allow_sata_in_cluster:1;
590 u32 reserved:27;
591
592 } __attribute__ ((packed)) pd_mix_support;
593
594 /*
595 * Define ECC single-bit-error bucket information
596 */
597 u8 ecc_bucket_count;
598 u8 reserved_2[11];
599
600 /*
601 * Include the controller properties (changeable items)
602 */
603 struct megasas_ctrl_prop properties;
604
605 /*
606 * Define FW pkg version (set in envt v'bles on OEM basis)
607 */
608 char package_version[0x60];
609
610 u8 pad[0x800 - 0x6a0];
611
Yang, Bo81e403c2009-10-06 14:27:54 -0600612} __packed;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400613
614/*
615 * ===============================
616 * MegaRAID SAS driver definitions
617 * ===============================
618 */
619#define MEGASAS_MAX_PD_CHANNELS 2
620#define MEGASAS_MAX_LD_CHANNELS 2
621#define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
622 MEGASAS_MAX_LD_CHANNELS)
623#define MEGASAS_MAX_DEV_PER_CHANNEL 128
624#define MEGASAS_DEFAULT_INIT_ID -1
625#define MEGASAS_MAX_LUN 8
626#define MEGASAS_MAX_LD 64
Yang, Bo81e403c2009-10-06 14:27:54 -0600627#define MEGASAS_MAX_PD (MEGASAS_MAX_PD_CHANNELS * \
628 MEGASAS_MAX_DEV_PER_CHANNEL)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400629
Sumant Patro658dced2006-10-03 13:09:14 -0700630#define MEGASAS_DBG_LVL 1
631
Sumant Patro05e9ebb2007-05-17 05:47:51 -0700632#define MEGASAS_FW_BUSY 1
633
bo yangd532dbe2008-03-17 03:36:43 -0400634/* Frame Type */
635#define IO_FRAME 0
636#define PTHRU_FRAME 1
637
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400638/*
639 * When SCSI mid-layer calls driver's reset routine, driver waits for
640 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
641 * that the driver cannot _actually_ abort or reset pending commands. While
642 * it is waiting for the commands to complete, it prints a diagnostic message
643 * every MEGASAS_RESET_NOTICE_INTERVAL seconds
644 */
645#define MEGASAS_RESET_WAIT_TIME 180
Sumant Patro2a3681e2006-10-03 13:19:21 -0700646#define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400647#define MEGASAS_RESET_NOTICE_INTERVAL 5
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400648#define MEGASAS_IOCTL_CMD 0
Sumant Patro05e9ebb2007-05-17 05:47:51 -0700649#define MEGASAS_DEFAULT_CMD_TIMEOUT 90
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400650
651/*
652 * FW reports the maximum of number of commands that it can accept (maximum
653 * commands that can be outstanding) at any time. The driver must report a
654 * lower number to the mid layer because it can issue a few internal commands
655 * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
656 * is shown below
657 */
658#define MEGASAS_INT_CMDS 32
Yang, Bo7bebf5c2009-10-06 14:40:58 -0600659#define MEGASAS_SKINNY_INT_CMDS 5
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400660
661/*
662 * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
663 * SGLs based on the size of dma_addr_t
664 */
665#define IS_DMA64 (sizeof(dma_addr_t) == 8)
666
667#define MFI_OB_INTR_STATUS_MASK 0x00000002
bo yang14faea92007-11-09 04:14:00 -0500668#define MFI_POLL_TIMEOUT_SECS 60
bo yangad84db22007-11-09 04:40:16 -0500669#define MEGASAS_COMPLETION_TIMER_INTERVAL (HZ/10)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400670
Sumant Patrof9876f02006-02-03 15:34:35 -0800671#define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
Yang, Bo6610a6b2008-08-10 12:42:38 -0700672#define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
673#define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
Yang, Bo87911122009-10-06 14:31:54 -0600674#define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
675#define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
Sumant Patro0e989362006-06-20 15:32:37 -0700676
677/*
678* register set for both 1068 and 1078 controllers
679* structure extended for 1078 registers
680*/
Sumant Patrof9876f02006-02-03 15:34:35 -0800681
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400682struct megasas_register_set {
Sumant Patrof9876f02006-02-03 15:34:35 -0800683 u32 reserved_0[4]; /*0000h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400684
Sumant Patrof9876f02006-02-03 15:34:35 -0800685 u32 inbound_msg_0; /*0010h*/
686 u32 inbound_msg_1; /*0014h*/
687 u32 outbound_msg_0; /*0018h*/
688 u32 outbound_msg_1; /*001Ch*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400689
Sumant Patrof9876f02006-02-03 15:34:35 -0800690 u32 inbound_doorbell; /*0020h*/
691 u32 inbound_intr_status; /*0024h*/
692 u32 inbound_intr_mask; /*0028h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400693
Sumant Patrof9876f02006-02-03 15:34:35 -0800694 u32 outbound_doorbell; /*002Ch*/
695 u32 outbound_intr_status; /*0030h*/
696 u32 outbound_intr_mask; /*0034h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400697
Sumant Patrof9876f02006-02-03 15:34:35 -0800698 u32 reserved_1[2]; /*0038h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400699
Sumant Patrof9876f02006-02-03 15:34:35 -0800700 u32 inbound_queue_port; /*0040h*/
701 u32 outbound_queue_port; /*0044h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400702
Sumant Patrof9876f02006-02-03 15:34:35 -0800703 u32 reserved_2[22]; /*0048h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400704
Sumant Patrof9876f02006-02-03 15:34:35 -0800705 u32 outbound_doorbell_clear; /*00A0h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400706
Sumant Patrof9876f02006-02-03 15:34:35 -0800707 u32 reserved_3[3]; /*00A4h*/
708
709 u32 outbound_scratch_pad ; /*00B0h*/
710
711 u32 reserved_4[3]; /*00B4h*/
712
713 u32 inbound_low_queue_port ; /*00C0h*/
714
715 u32 inbound_high_queue_port ; /*00C4h*/
716
717 u32 reserved_5; /*00C8h*/
718 u32 index_registers[820]; /*00CCh*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400719
720} __attribute__ ((packed));
721
722struct megasas_sge32 {
723
724 u32 phys_addr;
725 u32 length;
726
727} __attribute__ ((packed));
728
729struct megasas_sge64 {
730
731 u64 phys_addr;
732 u32 length;
733
734} __attribute__ ((packed));
735
Yang, Bof4c9a132009-10-06 14:43:28 -0600736struct megasas_sge_skinny {
737 u64 phys_addr;
738 u32 length;
739 u32 flag;
740} __packed;
741
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400742union megasas_sgl {
743
744 struct megasas_sge32 sge32[1];
745 struct megasas_sge64 sge64[1];
Yang, Bof4c9a132009-10-06 14:43:28 -0600746 struct megasas_sge_skinny sge_skinny[1];
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400747
748} __attribute__ ((packed));
749
750struct megasas_header {
751
752 u8 cmd; /*00h */
753 u8 sense_len; /*01h */
754 u8 cmd_status; /*02h */
755 u8 scsi_status; /*03h */
756
757 u8 target_id; /*04h */
758 u8 lun; /*05h */
759 u8 cdb_len; /*06h */
760 u8 sge_count; /*07h */
761
762 u32 context; /*08h */
763 u32 pad_0; /*0Ch */
764
765 u16 flags; /*10h */
766 u16 timeout; /*12h */
767 u32 data_xferlen; /*14h */
768
769} __attribute__ ((packed));
770
771union megasas_sgl_frame {
772
773 struct megasas_sge32 sge32[8];
774 struct megasas_sge64 sge64[5];
775
776} __attribute__ ((packed));
777
778struct megasas_init_frame {
779
780 u8 cmd; /*00h */
781 u8 reserved_0; /*01h */
782 u8 cmd_status; /*02h */
783
784 u8 reserved_1; /*03h */
785 u32 reserved_2; /*04h */
786
787 u32 context; /*08h */
788 u32 pad_0; /*0Ch */
789
790 u16 flags; /*10h */
791 u16 reserved_3; /*12h */
792 u32 data_xfer_len; /*14h */
793
794 u32 queue_info_new_phys_addr_lo; /*18h */
795 u32 queue_info_new_phys_addr_hi; /*1Ch */
796 u32 queue_info_old_phys_addr_lo; /*20h */
797 u32 queue_info_old_phys_addr_hi; /*24h */
798
799 u32 reserved_4[6]; /*28h */
800
801} __attribute__ ((packed));
802
803struct megasas_init_queue_info {
804
805 u32 init_flags; /*00h */
806 u32 reply_queue_entries; /*04h */
807
808 u32 reply_queue_start_phys_addr_lo; /*08h */
809 u32 reply_queue_start_phys_addr_hi; /*0Ch */
810 u32 producer_index_phys_addr_lo; /*10h */
811 u32 producer_index_phys_addr_hi; /*14h */
812 u32 consumer_index_phys_addr_lo; /*18h */
813 u32 consumer_index_phys_addr_hi; /*1Ch */
814
815} __attribute__ ((packed));
816
817struct megasas_io_frame {
818
819 u8 cmd; /*00h */
820 u8 sense_len; /*01h */
821 u8 cmd_status; /*02h */
822 u8 scsi_status; /*03h */
823
824 u8 target_id; /*04h */
825 u8 access_byte; /*05h */
826 u8 reserved_0; /*06h */
827 u8 sge_count; /*07h */
828
829 u32 context; /*08h */
830 u32 pad_0; /*0Ch */
831
832 u16 flags; /*10h */
833 u16 timeout; /*12h */
834 u32 lba_count; /*14h */
835
836 u32 sense_buf_phys_addr_lo; /*18h */
837 u32 sense_buf_phys_addr_hi; /*1Ch */
838
839 u32 start_lba_lo; /*20h */
840 u32 start_lba_hi; /*24h */
841
842 union megasas_sgl sgl; /*28h */
843
844} __attribute__ ((packed));
845
846struct megasas_pthru_frame {
847
848 u8 cmd; /*00h */
849 u8 sense_len; /*01h */
850 u8 cmd_status; /*02h */
851 u8 scsi_status; /*03h */
852
853 u8 target_id; /*04h */
854 u8 lun; /*05h */
855 u8 cdb_len; /*06h */
856 u8 sge_count; /*07h */
857
858 u32 context; /*08h */
859 u32 pad_0; /*0Ch */
860
861 u16 flags; /*10h */
862 u16 timeout; /*12h */
863 u32 data_xfer_len; /*14h */
864
865 u32 sense_buf_phys_addr_lo; /*18h */
866 u32 sense_buf_phys_addr_hi; /*1Ch */
867
868 u8 cdb[16]; /*20h */
869 union megasas_sgl sgl; /*30h */
870
871} __attribute__ ((packed));
872
873struct megasas_dcmd_frame {
874
875 u8 cmd; /*00h */
876 u8 reserved_0; /*01h */
877 u8 cmd_status; /*02h */
878 u8 reserved_1[4]; /*03h */
879 u8 sge_count; /*07h */
880
881 u32 context; /*08h */
882 u32 pad_0; /*0Ch */
883
884 u16 flags; /*10h */
885 u16 timeout; /*12h */
886
887 u32 data_xfer_len; /*14h */
888 u32 opcode; /*18h */
889
890 union { /*1Ch */
891 u8 b[12];
892 u16 s[6];
893 u32 w[3];
894 } mbox;
895
896 union megasas_sgl sgl; /*28h */
897
898} __attribute__ ((packed));
899
900struct megasas_abort_frame {
901
902 u8 cmd; /*00h */
903 u8 reserved_0; /*01h */
904 u8 cmd_status; /*02h */
905
906 u8 reserved_1; /*03h */
907 u32 reserved_2; /*04h */
908
909 u32 context; /*08h */
910 u32 pad_0; /*0Ch */
911
912 u16 flags; /*10h */
913 u16 reserved_3; /*12h */
914 u32 reserved_4; /*14h */
915
916 u32 abort_context; /*18h */
917 u32 pad_1; /*1Ch */
918
919 u32 abort_mfi_phys_addr_lo; /*20h */
920 u32 abort_mfi_phys_addr_hi; /*24h */
921
922 u32 reserved_5[6]; /*28h */
923
924} __attribute__ ((packed));
925
926struct megasas_smp_frame {
927
928 u8 cmd; /*00h */
929 u8 reserved_1; /*01h */
930 u8 cmd_status; /*02h */
931 u8 connection_status; /*03h */
932
933 u8 reserved_2[3]; /*04h */
934 u8 sge_count; /*07h */
935
936 u32 context; /*08h */
937 u32 pad_0; /*0Ch */
938
939 u16 flags; /*10h */
940 u16 timeout; /*12h */
941
942 u32 data_xfer_len; /*14h */
943 u64 sas_addr; /*18h */
944
945 union {
946 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
947 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
948 } sgl;
949
950} __attribute__ ((packed));
951
952struct megasas_stp_frame {
953
954 u8 cmd; /*00h */
955 u8 reserved_1; /*01h */
956 u8 cmd_status; /*02h */
957 u8 reserved_2; /*03h */
958
959 u8 target_id; /*04h */
960 u8 reserved_3[2]; /*05h */
961 u8 sge_count; /*07h */
962
963 u32 context; /*08h */
964 u32 pad_0; /*0Ch */
965
966 u16 flags; /*10h */
967 u16 timeout; /*12h */
968
969 u32 data_xfer_len; /*14h */
970
971 u16 fis[10]; /*18h */
972 u32 stp_flags;
973
974 union {
975 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
976 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
977 } sgl;
978
979} __attribute__ ((packed));
980
981union megasas_frame {
982
983 struct megasas_header hdr;
984 struct megasas_init_frame init;
985 struct megasas_io_frame io;
986 struct megasas_pthru_frame pthru;
987 struct megasas_dcmd_frame dcmd;
988 struct megasas_abort_frame abort;
989 struct megasas_smp_frame smp;
990 struct megasas_stp_frame stp;
991
992 u8 raw_bytes[64];
993};
994
995struct megasas_cmd;
996
997union megasas_evt_class_locale {
998
999 struct {
1000 u16 locale;
1001 u8 reserved;
1002 s8 class;
1003 } __attribute__ ((packed)) members;
1004
1005 u32 word;
1006
1007} __attribute__ ((packed));
1008
1009struct megasas_evt_log_info {
1010 u32 newest_seq_num;
1011 u32 oldest_seq_num;
1012 u32 clear_seq_num;
1013 u32 shutdown_seq_num;
1014 u32 boot_seq_num;
1015
1016} __attribute__ ((packed));
1017
1018struct megasas_progress {
1019
1020 u16 progress;
1021 u16 elapsed_seconds;
1022
1023} __attribute__ ((packed));
1024
1025struct megasas_evtarg_ld {
1026
1027 u16 target_id;
1028 u8 ld_index;
1029 u8 reserved;
1030
1031} __attribute__ ((packed));
1032
1033struct megasas_evtarg_pd {
1034 u16 device_id;
1035 u8 encl_index;
1036 u8 slot_number;
1037
1038} __attribute__ ((packed));
1039
1040struct megasas_evt_detail {
1041
1042 u32 seq_num;
1043 u32 time_stamp;
1044 u32 code;
1045 union megasas_evt_class_locale cl;
1046 u8 arg_type;
1047 u8 reserved1[15];
1048
1049 union {
1050 struct {
1051 struct megasas_evtarg_pd pd;
1052 u8 cdb_length;
1053 u8 sense_length;
1054 u8 reserved[2];
1055 u8 cdb[16];
1056 u8 sense[64];
1057 } __attribute__ ((packed)) cdbSense;
1058
1059 struct megasas_evtarg_ld ld;
1060
1061 struct {
1062 struct megasas_evtarg_ld ld;
1063 u64 count;
1064 } __attribute__ ((packed)) ld_count;
1065
1066 struct {
1067 u64 lba;
1068 struct megasas_evtarg_ld ld;
1069 } __attribute__ ((packed)) ld_lba;
1070
1071 struct {
1072 struct megasas_evtarg_ld ld;
1073 u32 prevOwner;
1074 u32 newOwner;
1075 } __attribute__ ((packed)) ld_owner;
1076
1077 struct {
1078 u64 ld_lba;
1079 u64 pd_lba;
1080 struct megasas_evtarg_ld ld;
1081 struct megasas_evtarg_pd pd;
1082 } __attribute__ ((packed)) ld_lba_pd_lba;
1083
1084 struct {
1085 struct megasas_evtarg_ld ld;
1086 struct megasas_progress prog;
1087 } __attribute__ ((packed)) ld_prog;
1088
1089 struct {
1090 struct megasas_evtarg_ld ld;
1091 u32 prev_state;
1092 u32 new_state;
1093 } __attribute__ ((packed)) ld_state;
1094
1095 struct {
1096 u64 strip;
1097 struct megasas_evtarg_ld ld;
1098 } __attribute__ ((packed)) ld_strip;
1099
1100 struct megasas_evtarg_pd pd;
1101
1102 struct {
1103 struct megasas_evtarg_pd pd;
1104 u32 err;
1105 } __attribute__ ((packed)) pd_err;
1106
1107 struct {
1108 u64 lba;
1109 struct megasas_evtarg_pd pd;
1110 } __attribute__ ((packed)) pd_lba;
1111
1112 struct {
1113 u64 lba;
1114 struct megasas_evtarg_pd pd;
1115 struct megasas_evtarg_ld ld;
1116 } __attribute__ ((packed)) pd_lba_ld;
1117
1118 struct {
1119 struct megasas_evtarg_pd pd;
1120 struct megasas_progress prog;
1121 } __attribute__ ((packed)) pd_prog;
1122
1123 struct {
1124 struct megasas_evtarg_pd pd;
1125 u32 prevState;
1126 u32 newState;
1127 } __attribute__ ((packed)) pd_state;
1128
1129 struct {
1130 u16 vendorId;
1131 u16 deviceId;
1132 u16 subVendorId;
1133 u16 subDeviceId;
1134 } __attribute__ ((packed)) pci;
1135
1136 u32 rate;
1137 char str[96];
1138
1139 struct {
1140 u32 rtc;
1141 u32 elapsedSeconds;
1142 } __attribute__ ((packed)) time;
1143
1144 struct {
1145 u32 ecar;
1146 u32 elog;
1147 char str[64];
1148 } __attribute__ ((packed)) ecc;
1149
1150 u8 b[96];
1151 u16 s[48];
1152 u32 w[24];
1153 u64 d[12];
1154 } args;
1155
1156 char description[128];
1157
1158} __attribute__ ((packed));
1159
1160struct megasas_instance {
1161
1162 u32 *producer;
1163 dma_addr_t producer_h;
1164 u32 *consumer;
1165 dma_addr_t consumer_h;
1166
1167 u32 *reply_queue;
1168 dma_addr_t reply_queue_h;
1169
1170 unsigned long base_addr;
1171 struct megasas_register_set __iomem *reg_set;
1172
Yang, Bo81e403c2009-10-06 14:27:54 -06001173 struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001174 s8 init_id;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001175
1176 u16 max_num_sge;
1177 u16 max_fw_cmds;
1178 u32 max_sectors_per_req;
1179
1180 struct megasas_cmd **cmd_list;
1181 struct list_head cmd_pool;
1182 spinlock_t cmd_pool_lock;
bo yang7343eb62007-11-09 04:35:44 -05001183 /* used to synch producer, consumer ptrs in dpc */
1184 spinlock_t completion_lock;
Yang, Bo0c79e682009-10-06 14:47:35 -06001185 /* used to sync fire the cmd to fw */
1186 spinlock_t fire_lock;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001187 struct dma_pool *frame_dma_pool;
1188 struct dma_pool *sense_dma_pool;
1189
1190 struct megasas_evt_detail *evt_detail;
1191 dma_addr_t evt_detail_h;
1192 struct megasas_cmd *aen_cmd;
Matthias Kaehlckee5a69e22007-10-27 09:48:46 +02001193 struct mutex aen_mutex;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001194 struct semaphore ioctl_sem;
1195
1196 struct Scsi_Host *host;
1197
1198 wait_queue_head_t int_cmd_wait_q;
1199 wait_queue_head_t abort_cmd_wait_q;
1200
1201 struct pci_dev *pdev;
1202 u32 unique_id;
1203
Sumant Patroe4a082c2006-05-30 12:03:37 -07001204 atomic_t fw_outstanding;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001205 u32 hw_crit_error;
Sumant Patro1341c932006-01-25 12:02:40 -08001206
1207 struct megasas_instance_template *instancet;
Sumant Patro5d018ad2006-10-03 13:13:18 -07001208 struct tasklet_struct isr_tasklet;
Sumant Patro05e9ebb2007-05-17 05:47:51 -07001209
1210 u8 flag;
Yang, Boc3518832009-10-06 14:18:02 -06001211 u8 unload;
Yang, Bof4c9a132009-10-06 14:43:28 -06001212 u8 flag_ieee;
Sumant Patro05e9ebb2007-05-17 05:47:51 -07001213 unsigned long last_time;
bo yangad84db22007-11-09 04:40:16 -05001214
1215 struct timer_list io_completion_timer;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001216};
1217
Yang, Bo0c79e682009-10-06 14:47:35 -06001218struct megasas_instance_template {
1219 void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
1220 u32, struct megasas_register_set __iomem *);
1221
1222 void (*enable_intr)(struct megasas_register_set __iomem *) ;
1223 void (*disable_intr)(struct megasas_register_set __iomem *);
1224
1225 int (*clear_intr)(struct megasas_register_set __iomem *);
1226
1227 u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
1228};
1229
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001230#define MEGASAS_IS_LOGICAL(scp) \
1231 (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
1232
1233#define MEGASAS_DEV_INDEX(inst, scp) \
1234 ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
1235 scp->device->id
1236
1237struct megasas_cmd {
1238
1239 union megasas_frame *frame;
1240 dma_addr_t frame_phys_addr;
1241 u8 *sense;
1242 dma_addr_t sense_phys_addr;
1243
1244 u32 index;
1245 u8 sync_cmd;
1246 u8 cmd_status;
1247 u16 abort_aen;
1248
1249 struct list_head list;
1250 struct scsi_cmnd *scmd;
1251 struct megasas_instance *instance;
1252 u32 frame_count;
1253};
1254
1255#define MAX_MGMT_ADAPTERS 1024
1256#define MAX_IOCTL_SGE 16
1257
1258struct megasas_iocpacket {
1259
1260 u16 host_no;
1261 u16 __pad1;
1262 u32 sgl_off;
1263 u32 sge_count;
1264 u32 sense_off;
1265 u32 sense_len;
1266 union {
1267 u8 raw[128];
1268 struct megasas_header hdr;
1269 } frame;
1270
1271 struct iovec sgl[MAX_IOCTL_SGE];
1272
1273} __attribute__ ((packed));
1274
1275struct megasas_aen {
1276 u16 host_no;
1277 u16 __pad1;
1278 u32 seq_num;
1279 u32 class_locale_word;
1280} __attribute__ ((packed));
1281
1282#ifdef CONFIG_COMPAT
1283struct compat_megasas_iocpacket {
1284 u16 host_no;
1285 u16 __pad1;
1286 u32 sgl_off;
1287 u32 sge_count;
1288 u32 sense_off;
1289 u32 sense_len;
1290 union {
1291 u8 raw[128];
1292 struct megasas_header hdr;
1293 } frame;
1294 struct compat_iovec sgl[MAX_IOCTL_SGE];
1295} __attribute__ ((packed));
1296
Sumant Patro0e989362006-06-20 15:32:37 -07001297#define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001298#endif
1299
Sumant Patrocb59aa62006-01-25 11:53:25 -08001300#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001301#define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
1302
1303struct megasas_mgmt_info {
1304
1305 u16 count;
1306 struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
1307 int max_index;
1308};
1309
1310#endif /*LSI_MEGARAID_SAS_H */