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