blob: 8ac6b2659c12d5a832c53219ec684ab0aee13d24 [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
658
659/*
660 * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
661 * SGLs based on the size of dma_addr_t
662 */
663#define IS_DMA64 (sizeof(dma_addr_t) == 8)
664
665#define MFI_OB_INTR_STATUS_MASK 0x00000002
bo yang14faea92007-11-09 04:14:00 -0500666#define MFI_POLL_TIMEOUT_SECS 60
bo yangad84db22007-11-09 04:40:16 -0500667#define MEGASAS_COMPLETION_TIMER_INTERVAL (HZ/10)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400668
Sumant Patrof9876f02006-02-03 15:34:35 -0800669#define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
Yang, Bo6610a6b2008-08-10 12:42:38 -0700670#define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
671#define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
Yang, Bo87911122009-10-06 14:31:54 -0600672#define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
673#define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
Sumant Patro0e989362006-06-20 15:32:37 -0700674
675/*
676* register set for both 1068 and 1078 controllers
677* structure extended for 1078 registers
678*/
Sumant Patrof9876f02006-02-03 15:34:35 -0800679
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400680struct megasas_register_set {
Sumant Patrof9876f02006-02-03 15:34:35 -0800681 u32 reserved_0[4]; /*0000h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400682
Sumant Patrof9876f02006-02-03 15:34:35 -0800683 u32 inbound_msg_0; /*0010h*/
684 u32 inbound_msg_1; /*0014h*/
685 u32 outbound_msg_0; /*0018h*/
686 u32 outbound_msg_1; /*001Ch*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400687
Sumant Patrof9876f02006-02-03 15:34:35 -0800688 u32 inbound_doorbell; /*0020h*/
689 u32 inbound_intr_status; /*0024h*/
690 u32 inbound_intr_mask; /*0028h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400691
Sumant Patrof9876f02006-02-03 15:34:35 -0800692 u32 outbound_doorbell; /*002Ch*/
693 u32 outbound_intr_status; /*0030h*/
694 u32 outbound_intr_mask; /*0034h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400695
Sumant Patrof9876f02006-02-03 15:34:35 -0800696 u32 reserved_1[2]; /*0038h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400697
Sumant Patrof9876f02006-02-03 15:34:35 -0800698 u32 inbound_queue_port; /*0040h*/
699 u32 outbound_queue_port; /*0044h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400700
Sumant Patrof9876f02006-02-03 15:34:35 -0800701 u32 reserved_2[22]; /*0048h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400702
Sumant Patrof9876f02006-02-03 15:34:35 -0800703 u32 outbound_doorbell_clear; /*00A0h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400704
Sumant Patrof9876f02006-02-03 15:34:35 -0800705 u32 reserved_3[3]; /*00A4h*/
706
707 u32 outbound_scratch_pad ; /*00B0h*/
708
709 u32 reserved_4[3]; /*00B4h*/
710
711 u32 inbound_low_queue_port ; /*00C0h*/
712
713 u32 inbound_high_queue_port ; /*00C4h*/
714
715 u32 reserved_5; /*00C8h*/
716 u32 index_registers[820]; /*00CCh*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400717
718} __attribute__ ((packed));
719
720struct megasas_sge32 {
721
722 u32 phys_addr;
723 u32 length;
724
725} __attribute__ ((packed));
726
727struct megasas_sge64 {
728
729 u64 phys_addr;
730 u32 length;
731
732} __attribute__ ((packed));
733
734union megasas_sgl {
735
736 struct megasas_sge32 sge32[1];
737 struct megasas_sge64 sge64[1];
738
739} __attribute__ ((packed));
740
741struct megasas_header {
742
743 u8 cmd; /*00h */
744 u8 sense_len; /*01h */
745 u8 cmd_status; /*02h */
746 u8 scsi_status; /*03h */
747
748 u8 target_id; /*04h */
749 u8 lun; /*05h */
750 u8 cdb_len; /*06h */
751 u8 sge_count; /*07h */
752
753 u32 context; /*08h */
754 u32 pad_0; /*0Ch */
755
756 u16 flags; /*10h */
757 u16 timeout; /*12h */
758 u32 data_xferlen; /*14h */
759
760} __attribute__ ((packed));
761
762union megasas_sgl_frame {
763
764 struct megasas_sge32 sge32[8];
765 struct megasas_sge64 sge64[5];
766
767} __attribute__ ((packed));
768
769struct megasas_init_frame {
770
771 u8 cmd; /*00h */
772 u8 reserved_0; /*01h */
773 u8 cmd_status; /*02h */
774
775 u8 reserved_1; /*03h */
776 u32 reserved_2; /*04h */
777
778 u32 context; /*08h */
779 u32 pad_0; /*0Ch */
780
781 u16 flags; /*10h */
782 u16 reserved_3; /*12h */
783 u32 data_xfer_len; /*14h */
784
785 u32 queue_info_new_phys_addr_lo; /*18h */
786 u32 queue_info_new_phys_addr_hi; /*1Ch */
787 u32 queue_info_old_phys_addr_lo; /*20h */
788 u32 queue_info_old_phys_addr_hi; /*24h */
789
790 u32 reserved_4[6]; /*28h */
791
792} __attribute__ ((packed));
793
794struct megasas_init_queue_info {
795
796 u32 init_flags; /*00h */
797 u32 reply_queue_entries; /*04h */
798
799 u32 reply_queue_start_phys_addr_lo; /*08h */
800 u32 reply_queue_start_phys_addr_hi; /*0Ch */
801 u32 producer_index_phys_addr_lo; /*10h */
802 u32 producer_index_phys_addr_hi; /*14h */
803 u32 consumer_index_phys_addr_lo; /*18h */
804 u32 consumer_index_phys_addr_hi; /*1Ch */
805
806} __attribute__ ((packed));
807
808struct megasas_io_frame {
809
810 u8 cmd; /*00h */
811 u8 sense_len; /*01h */
812 u8 cmd_status; /*02h */
813 u8 scsi_status; /*03h */
814
815 u8 target_id; /*04h */
816 u8 access_byte; /*05h */
817 u8 reserved_0; /*06h */
818 u8 sge_count; /*07h */
819
820 u32 context; /*08h */
821 u32 pad_0; /*0Ch */
822
823 u16 flags; /*10h */
824 u16 timeout; /*12h */
825 u32 lba_count; /*14h */
826
827 u32 sense_buf_phys_addr_lo; /*18h */
828 u32 sense_buf_phys_addr_hi; /*1Ch */
829
830 u32 start_lba_lo; /*20h */
831 u32 start_lba_hi; /*24h */
832
833 union megasas_sgl sgl; /*28h */
834
835} __attribute__ ((packed));
836
837struct megasas_pthru_frame {
838
839 u8 cmd; /*00h */
840 u8 sense_len; /*01h */
841 u8 cmd_status; /*02h */
842 u8 scsi_status; /*03h */
843
844 u8 target_id; /*04h */
845 u8 lun; /*05h */
846 u8 cdb_len; /*06h */
847 u8 sge_count; /*07h */
848
849 u32 context; /*08h */
850 u32 pad_0; /*0Ch */
851
852 u16 flags; /*10h */
853 u16 timeout; /*12h */
854 u32 data_xfer_len; /*14h */
855
856 u32 sense_buf_phys_addr_lo; /*18h */
857 u32 sense_buf_phys_addr_hi; /*1Ch */
858
859 u8 cdb[16]; /*20h */
860 union megasas_sgl sgl; /*30h */
861
862} __attribute__ ((packed));
863
864struct megasas_dcmd_frame {
865
866 u8 cmd; /*00h */
867 u8 reserved_0; /*01h */
868 u8 cmd_status; /*02h */
869 u8 reserved_1[4]; /*03h */
870 u8 sge_count; /*07h */
871
872 u32 context; /*08h */
873 u32 pad_0; /*0Ch */
874
875 u16 flags; /*10h */
876 u16 timeout; /*12h */
877
878 u32 data_xfer_len; /*14h */
879 u32 opcode; /*18h */
880
881 union { /*1Ch */
882 u8 b[12];
883 u16 s[6];
884 u32 w[3];
885 } mbox;
886
887 union megasas_sgl sgl; /*28h */
888
889} __attribute__ ((packed));
890
891struct megasas_abort_frame {
892
893 u8 cmd; /*00h */
894 u8 reserved_0; /*01h */
895 u8 cmd_status; /*02h */
896
897 u8 reserved_1; /*03h */
898 u32 reserved_2; /*04h */
899
900 u32 context; /*08h */
901 u32 pad_0; /*0Ch */
902
903 u16 flags; /*10h */
904 u16 reserved_3; /*12h */
905 u32 reserved_4; /*14h */
906
907 u32 abort_context; /*18h */
908 u32 pad_1; /*1Ch */
909
910 u32 abort_mfi_phys_addr_lo; /*20h */
911 u32 abort_mfi_phys_addr_hi; /*24h */
912
913 u32 reserved_5[6]; /*28h */
914
915} __attribute__ ((packed));
916
917struct megasas_smp_frame {
918
919 u8 cmd; /*00h */
920 u8 reserved_1; /*01h */
921 u8 cmd_status; /*02h */
922 u8 connection_status; /*03h */
923
924 u8 reserved_2[3]; /*04h */
925 u8 sge_count; /*07h */
926
927 u32 context; /*08h */
928 u32 pad_0; /*0Ch */
929
930 u16 flags; /*10h */
931 u16 timeout; /*12h */
932
933 u32 data_xfer_len; /*14h */
934 u64 sas_addr; /*18h */
935
936 union {
937 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
938 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
939 } sgl;
940
941} __attribute__ ((packed));
942
943struct megasas_stp_frame {
944
945 u8 cmd; /*00h */
946 u8 reserved_1; /*01h */
947 u8 cmd_status; /*02h */
948 u8 reserved_2; /*03h */
949
950 u8 target_id; /*04h */
951 u8 reserved_3[2]; /*05h */
952 u8 sge_count; /*07h */
953
954 u32 context; /*08h */
955 u32 pad_0; /*0Ch */
956
957 u16 flags; /*10h */
958 u16 timeout; /*12h */
959
960 u32 data_xfer_len; /*14h */
961
962 u16 fis[10]; /*18h */
963 u32 stp_flags;
964
965 union {
966 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
967 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
968 } sgl;
969
970} __attribute__ ((packed));
971
972union megasas_frame {
973
974 struct megasas_header hdr;
975 struct megasas_init_frame init;
976 struct megasas_io_frame io;
977 struct megasas_pthru_frame pthru;
978 struct megasas_dcmd_frame dcmd;
979 struct megasas_abort_frame abort;
980 struct megasas_smp_frame smp;
981 struct megasas_stp_frame stp;
982
983 u8 raw_bytes[64];
984};
985
986struct megasas_cmd;
987
988union megasas_evt_class_locale {
989
990 struct {
991 u16 locale;
992 u8 reserved;
993 s8 class;
994 } __attribute__ ((packed)) members;
995
996 u32 word;
997
998} __attribute__ ((packed));
999
1000struct megasas_evt_log_info {
1001 u32 newest_seq_num;
1002 u32 oldest_seq_num;
1003 u32 clear_seq_num;
1004 u32 shutdown_seq_num;
1005 u32 boot_seq_num;
1006
1007} __attribute__ ((packed));
1008
1009struct megasas_progress {
1010
1011 u16 progress;
1012 u16 elapsed_seconds;
1013
1014} __attribute__ ((packed));
1015
1016struct megasas_evtarg_ld {
1017
1018 u16 target_id;
1019 u8 ld_index;
1020 u8 reserved;
1021
1022} __attribute__ ((packed));
1023
1024struct megasas_evtarg_pd {
1025 u16 device_id;
1026 u8 encl_index;
1027 u8 slot_number;
1028
1029} __attribute__ ((packed));
1030
1031struct megasas_evt_detail {
1032
1033 u32 seq_num;
1034 u32 time_stamp;
1035 u32 code;
1036 union megasas_evt_class_locale cl;
1037 u8 arg_type;
1038 u8 reserved1[15];
1039
1040 union {
1041 struct {
1042 struct megasas_evtarg_pd pd;
1043 u8 cdb_length;
1044 u8 sense_length;
1045 u8 reserved[2];
1046 u8 cdb[16];
1047 u8 sense[64];
1048 } __attribute__ ((packed)) cdbSense;
1049
1050 struct megasas_evtarg_ld ld;
1051
1052 struct {
1053 struct megasas_evtarg_ld ld;
1054 u64 count;
1055 } __attribute__ ((packed)) ld_count;
1056
1057 struct {
1058 u64 lba;
1059 struct megasas_evtarg_ld ld;
1060 } __attribute__ ((packed)) ld_lba;
1061
1062 struct {
1063 struct megasas_evtarg_ld ld;
1064 u32 prevOwner;
1065 u32 newOwner;
1066 } __attribute__ ((packed)) ld_owner;
1067
1068 struct {
1069 u64 ld_lba;
1070 u64 pd_lba;
1071 struct megasas_evtarg_ld ld;
1072 struct megasas_evtarg_pd pd;
1073 } __attribute__ ((packed)) ld_lba_pd_lba;
1074
1075 struct {
1076 struct megasas_evtarg_ld ld;
1077 struct megasas_progress prog;
1078 } __attribute__ ((packed)) ld_prog;
1079
1080 struct {
1081 struct megasas_evtarg_ld ld;
1082 u32 prev_state;
1083 u32 new_state;
1084 } __attribute__ ((packed)) ld_state;
1085
1086 struct {
1087 u64 strip;
1088 struct megasas_evtarg_ld ld;
1089 } __attribute__ ((packed)) ld_strip;
1090
1091 struct megasas_evtarg_pd pd;
1092
1093 struct {
1094 struct megasas_evtarg_pd pd;
1095 u32 err;
1096 } __attribute__ ((packed)) pd_err;
1097
1098 struct {
1099 u64 lba;
1100 struct megasas_evtarg_pd pd;
1101 } __attribute__ ((packed)) pd_lba;
1102
1103 struct {
1104 u64 lba;
1105 struct megasas_evtarg_pd pd;
1106 struct megasas_evtarg_ld ld;
1107 } __attribute__ ((packed)) pd_lba_ld;
1108
1109 struct {
1110 struct megasas_evtarg_pd pd;
1111 struct megasas_progress prog;
1112 } __attribute__ ((packed)) pd_prog;
1113
1114 struct {
1115 struct megasas_evtarg_pd pd;
1116 u32 prevState;
1117 u32 newState;
1118 } __attribute__ ((packed)) pd_state;
1119
1120 struct {
1121 u16 vendorId;
1122 u16 deviceId;
1123 u16 subVendorId;
1124 u16 subDeviceId;
1125 } __attribute__ ((packed)) pci;
1126
1127 u32 rate;
1128 char str[96];
1129
1130 struct {
1131 u32 rtc;
1132 u32 elapsedSeconds;
1133 } __attribute__ ((packed)) time;
1134
1135 struct {
1136 u32 ecar;
1137 u32 elog;
1138 char str[64];
1139 } __attribute__ ((packed)) ecc;
1140
1141 u8 b[96];
1142 u16 s[48];
1143 u32 w[24];
1144 u64 d[12];
1145 } args;
1146
1147 char description[128];
1148
1149} __attribute__ ((packed));
1150
Sumant Patro1341c932006-01-25 12:02:40 -08001151 struct megasas_instance_template {
1152 void (*fire_cmd)(dma_addr_t ,u32 ,struct megasas_register_set __iomem *);
1153
1154 void (*enable_intr)(struct megasas_register_set __iomem *) ;
Sumant Patrob274cab2006-10-03 12:52:12 -07001155 void (*disable_intr)(struct megasas_register_set __iomem *);
Sumant Patro1341c932006-01-25 12:02:40 -08001156
1157 int (*clear_intr)(struct megasas_register_set __iomem *);
1158
1159 u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
1160 };
1161
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001162struct megasas_instance {
1163
1164 u32 *producer;
1165 dma_addr_t producer_h;
1166 u32 *consumer;
1167 dma_addr_t consumer_h;
1168
1169 u32 *reply_queue;
1170 dma_addr_t reply_queue_h;
1171
1172 unsigned long base_addr;
1173 struct megasas_register_set __iomem *reg_set;
1174
Yang, Bo81e403c2009-10-06 14:27:54 -06001175 struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001176 s8 init_id;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001177
1178 u16 max_num_sge;
1179 u16 max_fw_cmds;
1180 u32 max_sectors_per_req;
1181
1182 struct megasas_cmd **cmd_list;
1183 struct list_head cmd_pool;
1184 spinlock_t cmd_pool_lock;
bo yang7343eb62007-11-09 04:35:44 -05001185 /* used to synch producer, consumer ptrs in dpc */
1186 spinlock_t completion_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;
Sumant Patro05e9ebb2007-05-17 05:47:51 -07001212 unsigned long last_time;
bo yangad84db22007-11-09 04:40:16 -05001213
1214 struct timer_list io_completion_timer;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001215};
1216
1217#define MEGASAS_IS_LOGICAL(scp) \
1218 (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
1219
1220#define MEGASAS_DEV_INDEX(inst, scp) \
1221 ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
1222 scp->device->id
1223
1224struct megasas_cmd {
1225
1226 union megasas_frame *frame;
1227 dma_addr_t frame_phys_addr;
1228 u8 *sense;
1229 dma_addr_t sense_phys_addr;
1230
1231 u32 index;
1232 u8 sync_cmd;
1233 u8 cmd_status;
1234 u16 abort_aen;
1235
1236 struct list_head list;
1237 struct scsi_cmnd *scmd;
1238 struct megasas_instance *instance;
1239 u32 frame_count;
1240};
1241
1242#define MAX_MGMT_ADAPTERS 1024
1243#define MAX_IOCTL_SGE 16
1244
1245struct megasas_iocpacket {
1246
1247 u16 host_no;
1248 u16 __pad1;
1249 u32 sgl_off;
1250 u32 sge_count;
1251 u32 sense_off;
1252 u32 sense_len;
1253 union {
1254 u8 raw[128];
1255 struct megasas_header hdr;
1256 } frame;
1257
1258 struct iovec sgl[MAX_IOCTL_SGE];
1259
1260} __attribute__ ((packed));
1261
1262struct megasas_aen {
1263 u16 host_no;
1264 u16 __pad1;
1265 u32 seq_num;
1266 u32 class_locale_word;
1267} __attribute__ ((packed));
1268
1269#ifdef CONFIG_COMPAT
1270struct compat_megasas_iocpacket {
1271 u16 host_no;
1272 u16 __pad1;
1273 u32 sgl_off;
1274 u32 sge_count;
1275 u32 sense_off;
1276 u32 sense_len;
1277 union {
1278 u8 raw[128];
1279 struct megasas_header hdr;
1280 } frame;
1281 struct compat_iovec sgl[MAX_IOCTL_SGE];
1282} __attribute__ ((packed));
1283
Sumant Patro0e989362006-06-20 15:32:37 -07001284#define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001285#endif
1286
Sumant Patrocb59aa62006-01-25 11:53:25 -08001287#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001288#define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
1289
1290struct megasas_mgmt_info {
1291
1292 u16 count;
1293 struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
1294 int max_index;
1295};
1296
1297#endif /*LSI_MEGARAID_SAS_H */