2 * Copyright (c) 2006 IronPort Systems
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * Copyright (c) 2007 LSI Corp.
28 * Copyright (c) 2007 Rajesh Prabhakaran.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
34 * 1. Redistributions of source code must retain the above copyright
35 * notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in the
38 * documentation and/or other materials provided with the distribution.
40 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * $FreeBSD: src/sys/dev/mfi/mfireg.h,v 1.16 2011/07/14 20:20:33 jhb Exp $
59 * MegaRAID SAS MFI firmware definitions
61 * Calling this driver 'MegaRAID SAS' is a bit misleading. It's a completely
62 * new firmware interface from the old AMI MegaRAID one, and there is no
63 * reason why this interface should be limited to just SAS. In any case, LSI
64 * seems to also call this interface 'MFI', so that will be used here.
68 * Start with the register set. All registers are 32 bits wide.
69 * The usual Intel IOP style setup.
71 #define MFI_IMSG0 0x10 /* Inbound message 0 */
72 #define MFI_IMSG1 0x14 /* Inbound message 1 */
73 #define MFI_OMSG0 0x18 /* Outbound message 0 */
74 #define MFI_OMSG1 0x1c /* Outbound message 1 */
75 #define MFI_IDB 0x20 /* Inbound doorbell */
76 #define MFI_ISTS 0x24 /* Inbound interrupt status */
77 #define MFI_IMSK 0x28 /* Inbound interrupt mask */
78 #define MFI_ODB 0x2c /* Outbound doorbell */
79 #define MFI_OSTS 0x30 /* Outbound interrupt status */
80 #define MFI_OMSK 0x34 /* Outbound interrupt mask */
81 #define MFI_IQP 0x40 /* Inbound queue port */
82 #define MFI_OQP 0x44 /* Outbound queue port */
85 * 1078 specific related register
87 #define MFI_ODR0 0x9c /* outbound doorbell register0 */
88 #define MFI_ODCR0 0xa0 /* outbound doorbell clear register0 */
89 #define MFI_OSP0 0xb0 /* outbound scratch pad0 */
90 #define MFI_1078_EIM 0x80000004 /* 1078 enable intrrupt mask */
91 #define MFI_RMI 0x2 /* reply message interrupt */
92 #define MFI_1078_RM 0x80000000 /* reply 1078 message interrupt */
93 #define MFI_ODC 0x4 /* outbound doorbell change interrupt */
96 * GEN2 specific changes
98 #define MFI_GEN2_EIM 0x00000005 /* GEN2 enable interrupt mask */
99 #define MFI_GEN2_RM 0x00000001 /* reply GEN2 message interrupt */
101 /* Bits for MFI_OSTS */
102 #define MFI_OSTS_INTR_VALID 0x00000002
105 * Firmware state values. Found in OMSG0 during initialization.
107 #define MFI_FWSTATE_MASK 0xf0000000
108 #define MFI_FWSTATE_UNDEFINED 0x00000000
109 #define MFI_FWSTATE_BB_INIT 0x10000000
110 #define MFI_FWSTATE_FW_INIT 0x40000000
111 #define MFI_FWSTATE_WAIT_HANDSHAKE 0x60000000
112 #define MFI_FWSTATE_FW_INIT_2 0x70000000
113 #define MFI_FWSTATE_DEVICE_SCAN 0x80000000
114 #define MFI_FWSTATE_BOOT_MESSAGE_PENDING 0x90000000
115 #define MFI_FWSTATE_FLUSH_CACHE 0xa0000000
116 #define MFI_FWSTATE_READY 0xb0000000
117 #define MFI_FWSTATE_OPERATIONAL 0xc0000000
118 #define MFI_FWSTATE_FAULT 0xf0000000
119 #define MFI_FWSTATE_MAXSGL_MASK 0x00ff0000
120 #define MFI_FWSTATE_MAXCMD_MASK 0x0000ffff
123 * Control bits to drive the card to ready state. These go into the IDB
126 #define MFI_FWINIT_ABORT 0x00000000 /* Abort all pending commands */
127 #define MFI_FWINIT_READY 0x00000002 /* Move from operational to ready */
128 #define MFI_FWINIT_MFIMODE 0x00000004 /* unknown */
129 #define MFI_FWINIT_CLEAR_HANDSHAKE 0x00000008 /* Respond to WAIT_HANDSHAKE */
130 #define MFI_FWINIT_HOTPLUG 0x00000010
145 /* Direct commands */
147 MFI_DCMD_CTRL_GETINFO = 0x01010000,
148 MFI_DCMD_CTRL_MFC_DEFAULTS_GET =0x010e0201,
149 MFI_DCMD_CTRL_MFC_DEFAULTS_SET =0x010e0202,
150 MFI_DCMD_CTRL_FLUSHCACHE = 0x01101000,
151 MFI_DCMD_CTRL_SHUTDOWN = 0x01050000,
152 MFI_DCMD_CTRL_EVENT_GETINFO = 0x01040100,
153 MFI_DCMD_CTRL_EVENT_GET = 0x01040300,
154 MFI_DCMD_CTRL_EVENT_WAIT = 0x01040500,
155 MFI_DCMD_PR_GET_STATUS = 0x01070100,
156 MFI_DCMD_PR_GET_PROPERTIES = 0x01070200,
157 MFI_DCMD_PR_SET_PROPERTIES = 0x01070300,
158 MFI_DCMD_PR_START = 0x01070400,
159 MFI_DCMD_PR_STOP = 0x01070500,
160 MFI_DCMD_TIME_SECS_GET = 0x01080201,
161 MFI_DCMD_FLASH_FW_OPEN = 0x010f0100,
162 MFI_DCMD_FLASH_FW_DOWNLOAD = 0x010f0200,
163 MFI_DCMD_FLASH_FW_FLASH = 0x010f0300,
164 MFI_DCMD_FLASH_FW_CLOSE = 0x010f0400,
165 MFI_DCMD_PD_GET_LIST = 0x02010000,
166 MFI_DCMD_PD_GET_INFO = 0x02020000,
167 MFI_DCMD_PD_STATE_SET = 0x02030100,
168 MFI_DCMD_PD_REBUILD_START = 0x02040100,
169 MFI_DCMD_PD_REBUILD_ABORT = 0x02040200,
170 MFI_DCMD_PD_CLEAR_START = 0x02050100,
171 MFI_DCMD_PD_CLEAR_ABORT = 0x02050200,
172 MFI_DCMD_PD_GET_PROGRESS = 0x02060000,
173 MFI_DCMD_PD_LOCATE_START = 0x02070100,
174 MFI_DCMD_PD_LOCATE_STOP = 0x02070200,
175 MFI_DCMD_LD_GET_LIST = 0x03010000,
176 MFI_DCMD_LD_GET_INFO = 0x03020000,
177 MFI_DCMD_LD_GET_PROP = 0x03030000,
178 MFI_DCMD_LD_SET_PROP = 0x03040000,
179 MFI_DCMD_LD_INIT_START = 0x03060100,
180 MFI_DCMD_LD_DELETE = 0x03090000,
181 MFI_DCMD_CFG_READ = 0x04010000,
182 MFI_DCMD_CFG_ADD = 0x04020000,
183 MFI_DCMD_CFG_CLEAR = 0x04030000,
184 MFI_DCMD_CFG_MAKE_SPARE = 0x04040000,
185 MFI_DCMD_CFG_REMOVE_SPARE = 0x04050000,
186 MFI_DCMD_CFG_FOREIGN_IMPORT = 0x04060400,
187 MFI_DCMD_BBU_GET_STATUS = 0x05010000,
188 MFI_DCMD_BBU_GET_CAPACITY_INFO =0x05020000,
189 MFI_DCMD_BBU_GET_DESIGN_INFO = 0x05030000,
190 MFI_DCMD_CLUSTER = 0x08000000,
191 MFI_DCMD_CLUSTER_RESET_ALL = 0x08010100,
192 MFI_DCMD_CLUSTER_RESET_LD = 0x08010200
195 /* Modifiers for MFI_DCMD_CTRL_FLUSHCACHE */
196 #define MFI_FLUSHCACHE_CTRL 0x01
197 #define MFI_FLUSHCACHE_DISK 0x02
199 /* Modifiers for MFI_DCMD_CTRL_SHUTDOWN */
200 #define MFI_SHUTDOWN_SPINDOWN 0x01
205 #define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
206 #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
207 #define MFI_FRAME_SGL32 0x0000
208 #define MFI_FRAME_SGL64 0x0002
209 #define MFI_FRAME_SENSE32 0x0000
210 #define MFI_FRAME_SENSE64 0x0004
211 #define MFI_FRAME_DIR_NONE 0x0000
212 #define MFI_FRAME_DIR_WRITE 0x0008
213 #define MFI_FRAME_DIR_READ 0x0010
214 #define MFI_FRAME_DIR_BOTH 0x0018
216 /* MFI Status codes */
219 MFI_STAT_INVALID_CMD,
220 MFI_STAT_INVALID_DCMD,
221 MFI_STAT_INVALID_PARAMETER,
222 MFI_STAT_INVALID_SEQUENCE_NUMBER,
223 MFI_STAT_ABORT_NOT_POSSIBLE,
224 MFI_STAT_APP_HOST_CODE_NOT_FOUND,
226 MFI_STAT_APP_NOT_INITIALIZED,
227 MFI_STAT_ARRAY_INDEX_INVALID,
228 MFI_STAT_ARRAY_ROW_NOT_EMPTY,
229 MFI_STAT_CONFIG_RESOURCE_CONFLICT,
230 MFI_STAT_DEVICE_NOT_FOUND,
231 MFI_STAT_DRIVE_TOO_SMALL,
232 MFI_STAT_FLASH_ALLOC_FAIL,
234 MFI_STAT_FLASH_ERROR = 0x10,
235 MFI_STAT_FLASH_IMAGE_BAD,
236 MFI_STAT_FLASH_IMAGE_INCOMPLETE,
237 MFI_STAT_FLASH_NOT_OPEN,
238 MFI_STAT_FLASH_NOT_STARTED,
239 MFI_STAT_FLUSH_FAILED,
240 MFI_STAT_HOST_CODE_NOT_FOUNT,
241 MFI_STAT_LD_CC_IN_PROGRESS,
242 MFI_STAT_LD_INIT_IN_PROGRESS,
243 MFI_STAT_LD_LBA_OUT_OF_RANGE,
244 MFI_STAT_LD_MAX_CONFIGURED,
245 MFI_STAT_LD_NOT_OPTIMAL,
246 MFI_STAT_LD_RBLD_IN_PROGRESS,
247 MFI_STAT_LD_RECON_IN_PROGRESS,
248 MFI_STAT_LD_WRONG_RAID_LEVEL,
249 MFI_STAT_MAX_SPARES_EXCEEDED,
250 MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
251 MFI_STAT_MFC_HW_ERROR,
252 MFI_STAT_NO_HW_PRESENT,
254 MFI_STAT_NOT_IN_ENCL,
255 MFI_STAT_PD_CLEAR_IN_PROGRESS,
256 MFI_STAT_PD_TYPE_WRONG,
257 MFI_STAT_PR_DISABLED,
258 MFI_STAT_ROW_INDEX_INVALID,
259 MFI_STAT_SAS_CONFIG_INVALID_ACTION,
260 MFI_STAT_SAS_CONFIG_INVALID_DATA,
261 MFI_STAT_SAS_CONFIG_INVALID_PAGE,
262 MFI_STAT_SAS_CONFIG_INVALID_TYPE,
263 MFI_STAT_SCSI_DONE_WITH_ERROR,
264 MFI_STAT_SCSI_IO_FAILED,
265 MFI_STAT_SCSI_RESERVATION_CONFLICT,
266 MFI_STAT_SHUTDOWN_FAILED = 0x30,
267 MFI_STAT_TIME_NOT_SET,
268 MFI_STAT_WRONG_STATE,
270 MFI_STAT_PEER_NOTIFICATION_REJECTED,
271 MFI_STAT_PEER_NOTIFICATION_FAILED,
272 MFI_STAT_RESERVATION_IN_PROGRESS,
273 MFI_STAT_I2C_ERRORS_DETECTED,
274 MFI_STAT_PCI_ERRORS_DETECTED,
275 MFI_STAT_DIAG_FAILED,
276 MFI_STAT_BOOT_MSG_PENDING,
277 MFI_STAT_FOREIGN_CONFIG_INCOMPLETE,
278 MFI_STAT_INVALID_STATUS = 0xFF
282 MFI_EVT_CLASS_DEBUG = -2,
283 MFI_EVT_CLASS_PROGRESS = -1,
284 MFI_EVT_CLASS_INFO = 0,
285 MFI_EVT_CLASS_WARNING = 1,
286 MFI_EVT_CLASS_CRITICAL = 2,
287 MFI_EVT_CLASS_FATAL = 3,
288 MFI_EVT_CLASS_DEAD = 4
292 MFI_EVT_LOCALE_LD = 0x0001,
293 MFI_EVT_LOCALE_PD = 0x0002,
294 MFI_EVT_LOCALE_ENCL = 0x0004,
295 MFI_EVT_LOCALE_BBU = 0x0008,
296 MFI_EVT_LOCALE_SAS = 0x0010,
297 MFI_EVT_LOCALE_CTRL = 0x0020,
298 MFI_EVT_LOCALE_CONFIG = 0x0040,
299 MFI_EVT_LOCALE_CLUSTER = 0x0080,
300 MFI_EVT_LOCALE_ALL = 0xffff
304 MR_EVT_ARGS_NONE = 0x00,
305 MR_EVT_ARGS_CDB_SENSE,
307 MR_EVT_ARGS_LD_COUNT,
309 MR_EVT_ARGS_LD_OWNER,
310 MR_EVT_ARGS_LD_LBA_PD_LBA,
312 MR_EVT_ARGS_LD_STATE,
313 MR_EVT_ARGS_LD_STRIP,
317 MR_EVT_ARGS_PD_LBA_LD,
319 MR_EVT_ARGS_PD_STATE,
328 MR_LD_CACHE_WRITE_BACK = 0x01,
329 MR_LD_CACHE_WRITE_ADAPTIVE = 0x02,
330 MR_LD_CACHE_READ_AHEAD = 0x04,
331 MR_LD_CACHE_READ_ADAPTIVE = 0x08,
332 MR_LD_CACHE_WRITE_CACHE_BAD_BBU=0x10,
333 MR_LD_CACHE_ALLOW_WRITE_CACHE = 0x20,
334 MR_LD_CACHE_ALLOW_READ_CACHE = 0x40
336 #define MR_LD_CACHE_MASK 0x7f
338 #define MR_LD_CACHE_POLICY_READ_AHEAD_NONE 0
339 #define MR_LD_CACHE_POLICY_READ_AHEAD_ALWAYS MR_LD_CACHE_READ_AHEAD
340 #define MR_LD_CACHE_POLICY_READ_AHEAD_ADAPTIVE \
341 (MR_LD_CACHE_READ_AHEAD | MR_LD_CACHE_READ_ADAPTIVE)
342 #define MR_LD_CACHE_POLICY_WRITE_THROUGH 0
343 #define MR_LD_CACHE_POLICY_WRITE_BACK MR_LD_CACHE_WRITE_BACK
344 #define MR_LD_CACHE_POLICY_IO_CACHED \
345 (MR_LD_CACHE_ALLOW_WRITE_CACHE | MR_LD_CACHE_ALLOW_READ_CACHE)
346 #define MR_LD_CACHE_POLICY_IO_DIRECT 0
349 MR_PD_CACHE_UNCHANGED = 0,
350 MR_PD_CACHE_ENABLE = 1,
351 MR_PD_CACHE_DISABLE = 2
355 * Other propertities and definitions
357 #define MFI_MAX_PD_CHANNELS 2
358 #define MFI_MAX_LD_CHANNELS 2
359 #define MFI_MAX_CHANNELS (MFI_MAX_PD_CHANNELS + MFI_MAX_LD_CHANNELS)
360 #define MFI_MAX_CHANNEL_DEVS 128
361 #define MFI_DEFAULT_ID -1
362 #define MFI_MAX_LUN 8
363 #define MFI_MAX_LD 64
364 #define MFI_MAX_PD 256
366 #define MFI_FRAME_SIZE 64
367 #define MFI_MBOX_SIZE 12
369 /* Firmware flashing can take 40s */
370 #define MFI_POLL_TIMEOUT_SECS 50
372 /* Allow for speedier math calculations */
373 #define MFI_SECTOR_LEN 512
375 /* Scatter Gather elements */
387 struct mfi_sg32 sg32[1];
388 struct mfi_sg64 sg64[1];
391 /* Message frames. All messages have a common header */
392 struct mfi_frame_header {
404 #define MFI_FRAME_DATAOUT 0x08
405 #define MFI_FRAME_DATAIN 0x10
410 struct mfi_init_frame {
411 struct mfi_frame_header header;
412 uint32_t qinfo_new_addr_lo;
413 uint32_t qinfo_new_addr_hi;
414 uint32_t qinfo_old_addr_lo;
415 uint32_t qinfo_old_addr_hi;
416 uint32_t reserved[6];
419 #define MFI_IO_FRAME_SIZE 40
420 struct mfi_io_frame {
421 struct mfi_frame_header header;
422 uint32_t sense_addr_lo;
423 uint32_t sense_addr_hi;
429 #define MFI_PASS_FRAME_SIZE 48
430 struct mfi_pass_frame {
431 struct mfi_frame_header header;
432 uint32_t sense_addr_lo;
433 uint32_t sense_addr_hi;
438 #define MFI_DCMD_FRAME_SIZE 40
439 struct mfi_dcmd_frame {
440 struct mfi_frame_header header;
442 uint8_t mbox[MFI_MBOX_SIZE];
446 struct mfi_abort_frame {
447 struct mfi_frame_header header;
448 uint32_t abort_context;
450 uint32_t abort_mfi_addr_lo;
451 uint32_t abort_mfi_addr_hi;
452 uint32_t reserved[6];
455 struct mfi_smp_frame {
456 struct mfi_frame_header header;
459 struct mfi_sg32 sg32[2];
460 struct mfi_sg64 sg64[2];
464 struct mfi_stp_frame {
465 struct mfi_frame_header header;
469 struct mfi_sg32 sg32[2];
470 struct mfi_sg64 sg64[2];
475 struct mfi_frame_header header;
476 struct mfi_init_frame init;
477 struct mfi_io_frame io;
478 struct mfi_pass_frame pass;
479 struct mfi_dcmd_frame dcmd;
480 struct mfi_abort_frame abort;
481 struct mfi_smp_frame smp;
482 struct mfi_stp_frame stp;
483 uint8_t bytes[MFI_FRAME_SIZE];
486 #define MFI_SENSE_LEN 128
488 uint8_t data[MFI_SENSE_LEN];
491 /* The queue init structure that is passed with the init message */
492 struct mfi_init_qinfo {
503 /* SAS (?) controller properties, part of mfi_ctrl_info */
504 struct mfi_ctrl_props {
506 uint16_t pred_fail_poll_interval;
507 uint16_t intr_throttle_cnt;
508 uint16_t intr_throttle_timeout;
509 uint8_t rebuild_rate;
510 uint8_t patrol_read_rate;
514 uint8_t cache_flush_interval;
515 uint8_t spinup_drv_cnt;
516 uint8_t spinup_delay;
517 uint8_t cluster_enable;
518 uint8_t coercion_mode;
519 uint8_t alarm_enable;
520 uint8_t disable_auto_rebuild;
521 uint8_t disable_battery_warn;
522 uint8_t ecc_bucket_size;
523 uint16_t ecc_bucket_leak_rate;
524 uint8_t restore_hotspare_on_insertion;
525 uint8_t expose_encl_devices;
526 uint8_t reserved[38];
529 /* PCI information about the card. */
530 struct mfi_info_pci {
535 uint8_t reserved[24];
538 /* Host (front end) interface information */
539 struct mfi_info_host {
541 #define MFI_INFO_HOST_PCIX 0x01
542 #define MFI_INFO_HOST_PCIE 0x02
543 #define MFI_INFO_HOST_ISCSI 0x04
544 #define MFI_INFO_HOST_SAS3G 0x08
547 uint64_t port_addr[8];
550 /* Device (back end) interface information */
551 struct mfi_info_device {
553 #define MFI_INFO_DEV_SPI 0x01
554 #define MFI_INFO_DEV_SAS3G 0x02
555 #define MFI_INFO_DEV_SATA1 0x04
556 #define MFI_INFO_DEV_SATA3G 0x08
559 uint64_t port_addr[8];
562 /* Firmware component information */
563 struct mfi_info_component {
570 /* Controller default settings */
571 struct mfi_defaults {
573 uint8_t phy_polarity;
574 uint8_t background_rate;
579 uint8_t cache_when_bbu_bad;
582 uint8_t alarm_disable;
585 uint8_t dirty_led_shows_drive_activity;
586 uint8_t bios_continue_on_error;
587 uint8_t spindown_mode;
588 uint8_t allowed_device_types;
589 uint8_t allow_mix_in_enclosure;
590 uint8_t allow_mix_in_ld;
591 uint8_t allow_sata_in_cluster;
592 uint8_t max_chained_enclosures;
593 uint8_t disable_ctrl_r;
594 uint8_t enabel_web_bios;
595 uint8_t phy_polarity_split;
596 uint8_t direct_pd_mapping;
597 uint8_t bios_enumerate_lds;
598 uint8_t restored_hot_spare_on_insertion;
599 uint8_t expose_enclosure_devices;
600 uint8_t maintain_pd_fail_history;
604 /* Controller default settings */
605 struct mfi_bios_data {
606 uint16_t boot_target_id;
607 uint8_t do_not_int_13;
608 uint8_t continue_on_error;
611 uint8_t expose_all_drives;
612 uint8_t reserved[56];
616 /* SAS (?) controller info, returned from MFI_DCMD_CTRL_GETINFO. */
617 struct mfi_ctrl_info {
618 struct mfi_info_pci pci;
619 struct mfi_info_host host;
620 struct mfi_info_device device;
622 /* Firmware components that are present and active. */
623 uint32_t image_check_word;
624 uint32_t image_component_count;
625 struct mfi_info_component image_component[8];
627 /* Firmware components that have been flashed but are inactive */
628 uint32_t pending_image_component_count;
629 struct mfi_info_component pending_image_component[8];
635 char product_name[80];
636 char serial_number[32];
638 #define MFI_INFO_HW_BBU 0x01
639 #define MFI_INFO_HW_ALARM 0x02
640 #define MFI_INFO_HW_NVRAM 0x04
641 #define MFI_INFO_HW_UART 0x08
642 uint32_t current_fw_time;
644 uint16_t max_sg_elements;
645 uint32_t max_request_size;
646 uint16_t lds_present;
647 uint16_t lds_degraded;
648 uint16_t lds_offline;
650 uint16_t pd_disks_present;
651 uint16_t pd_disks_pred_failure;
652 uint16_t pd_disks_failed;
654 uint16_t memory_size;
656 uint16_t ram_correctable_errors;
657 uint16_t ram_uncorrectable_errors;
658 uint8_t cluster_allowed;
659 uint8_t cluster_active;
660 uint16_t max_strips_per_io;
662 uint32_t raid_levels;
663 #define MFI_INFO_RAID_0 0x01
664 #define MFI_INFO_RAID_1 0x02
665 #define MFI_INFO_RAID_5 0x04
666 #define MFI_INFO_RAID_1E 0x08
667 #define MFI_INFO_RAID_6 0x10
669 uint32_t adapter_ops;
670 #define MFI_INFO_AOPS_RBLD_RATE 0x0001
671 #define MFI_INFO_AOPS_CC_RATE 0x0002
672 #define MFI_INFO_AOPS_BGI_RATE 0x0004
673 #define MFI_INFO_AOPS_RECON_RATE 0x0008
674 #define MFI_INFO_AOPS_PATROL_RATE 0x0010
675 #define MFI_INFO_AOPS_ALARM_CONTROL 0x0020
676 #define MFI_INFO_AOPS_CLUSTER_SUPPORTED 0x0040
677 #define MFI_INFO_AOPS_BBU 0x0080
678 #define MFI_INFO_AOPS_SPANNING_ALLOWED 0x0100
679 #define MFI_INFO_AOPS_DEDICATED_SPARES 0x0200
680 #define MFI_INFO_AOPS_REVERTIBLE_SPARES 0x0400
681 #define MFI_INFO_AOPS_FOREIGN_IMPORT 0x0800
682 #define MFI_INFO_AOPS_SELF_DIAGNOSTIC 0x1000
683 #define MFI_INFO_AOPS_MIXED_ARRAY 0x2000
684 #define MFI_INFO_AOPS_GLOBAL_SPARES 0x4000
687 #define MFI_INFO_LDOPS_READ_POLICY 0x01
688 #define MFI_INFO_LDOPS_WRITE_POLICY 0x02
689 #define MFI_INFO_LDOPS_IO_POLICY 0x04
690 #define MFI_INFO_LDOPS_ACCESS_POLICY 0x08
691 #define MFI_INFO_LDOPS_DISK_CACHE_POLICY 0x10
697 } __packed stripe_sz_ops;
700 #define MFI_INFO_PDOPS_FORCE_ONLINE 0x01
701 #define MFI_INFO_PDOPS_FORCE_OFFLINE 0x02
702 #define MFI_INFO_PDOPS_FORCE_REBUILD 0x04
704 uint32_t pd_mix_support;
705 #define MFI_INFO_PDMIX_SAS 0x01
706 #define MFI_INFO_PDMIX_SATA 0x02
707 #define MFI_INFO_PDMIX_ENCL 0x04
708 #define MFI_INFO_PDMIX_LD 0x08
709 #define MFI_INFO_PDMIX_SATA_CLUSTER 0x10
711 uint8_t ecc_bucket_count;
712 uint8_t reserved2[11];
713 struct mfi_ctrl_props properties;
714 char package_version[0x60];
715 uint8_t pad[0x800 - 0x6a0];
718 /* keep track of an event. */
728 /* event log state. */
729 struct mfi_evt_log_state {
730 uint32_t newest_seq_num;
731 uint32_t oldest_seq_num;
732 uint32_t clear_seq_num;
733 uint32_t shutdown_seq_num;
734 uint32_t boot_seq_num;
737 struct mfi_progress {
739 uint16_t elapsed_seconds;
750 uint8_t enclosure_index;
754 /* SAS (?) event detail, returned from MFI_DCMD_CTRL_EVENT_WAIT. */
755 struct mfi_evt_detail {
759 union mfi_evt evt_class;
761 uint8_t reserved1[15];
765 struct mfi_evt_pd pd;
773 struct mfi_evt_ld ld;
776 struct mfi_evt_ld ld;
782 struct mfi_evt_ld ld;
786 struct mfi_evt_ld ld;
794 struct mfi_evt_ld ld;
795 struct mfi_evt_pd pd;
799 struct mfi_evt_ld ld;
800 struct mfi_progress prog;
804 struct mfi_evt_ld ld;
811 struct mfi_evt_ld ld;
814 struct mfi_evt_pd pd;
817 struct mfi_evt_pd pd;
823 struct mfi_evt_pd pd;
828 struct mfi_evt_pd pd;
829 struct mfi_evt_ld ld;
833 struct mfi_evt_pd pd;
834 struct mfi_progress prog;
838 struct mfi_evt_pd ld;
846 uint16_t subVenderId;
847 uint16_t subDeviceId;
856 uint16_t elapsedSeconds;
871 char description[128];
874 struct mfi_evt_list {
877 struct mfi_evt_detail event[1];
888 union mfi_pd_ddf_type {
892 uint16_t forced_pd_guid : 1;
894 uint16_t is_global_spare : 1;
895 uint16_t is_spare : 1;
896 uint16_t is_foreign : 1;
897 uint16_t reserved : 7;
910 struct mfi_pd_progress {
912 #define MFI_PD_PROGRESS_REBUILD (1<<0)
913 #define MFI_PD_PROGRESS_PATROL (1<<1)
914 #define MFI_PD_PROGRESS_CLEAR (1<<2)
915 struct mfi_progress rbld;
916 struct mfi_progress patrol;
917 struct mfi_progress clear;
918 struct mfi_progress reserved[4];
922 union mfi_pd_ref ref;
923 uint8_t inquiry_data[96];
924 uint8_t vpd_page83[64];
925 uint8_t not_supported;
926 uint8_t scsi_dev_type;
927 uint8_t connected_port_bitmap;
928 uint8_t device_speed;
929 uint32_t media_err_count;
930 uint32_t other_err_count;
931 uint32_t pred_fail_count;
932 uint32_t last_pred_fail_event_seq_num;
933 uint16_t fw_state; /* MFI_PD_STATE_* */
934 uint8_t disabled_for_removal;
936 union mfi_pd_ddf_type state;
939 uint8_t is_path_broken;
941 uint64_t sas_addr[4];
944 uint64_t non_coerced_size;
945 uint64_t coerced_size;
946 uint16_t encl_device_id;
949 struct mfi_pd_progress prog_info;
950 uint8_t bad_block_table_full;
951 uint8_t unusable_in_current_config;
952 uint8_t vpd_page83_ext[64];
953 uint8_t reserved[512-358];
956 struct mfi_pd_address {
958 uint16_t encl_device_id;
961 uint8_t scsi_dev_type; /* 0 = disk */
962 uint8_t connect_port_bitmap;
963 uint64_t sas_addr[2];
969 struct mfi_pd_address addr[0];
973 MFI_PD_STATE_UNCONFIGURED_GOOD = 0x00,
974 MFI_PD_STATE_UNCONFIGURED_BAD = 0x01,
975 MFI_PD_STATE_HOT_SPARE = 0x02,
976 MFI_PD_STATE_OFFLINE = 0x10,
977 MFI_PD_STATE_FAILED = 0x11,
978 MFI_PD_STATE_REBUILD = 0x14,
979 MFI_PD_STATE_ONLINE = 0x18,
980 MFI_PD_STATE_COPYBACK = 0x20,
981 MFI_PD_STATE_SYSTEM = 0x40
999 uint8_t reserved2[3];
1001 } ld_list[MFI_MAX_LD];
1004 enum mfi_ld_access {
1005 MFI_LD_ACCESS_RW = 0,
1006 MFI_LD_ACCSSS_RO = 2,
1007 MFI_LD_ACCESS_BLOCKED = 3,
1009 #define MFI_LD_ACCESS_MASK 3
1012 MFI_LD_STATE_OFFLINE = 0,
1013 MFI_LD_STATE_PARTIALLY_DEGRADED = 1,
1014 MFI_LD_STATE_DEGRADED = 2,
1015 MFI_LD_STATE_OPTIMAL = 3
1018 struct mfi_ld_props {
1019 union mfi_ld_ref ld;
1021 uint8_t default_cache_policy;
1022 uint8_t access_policy;
1023 uint8_t disk_cache_policy;
1024 uint8_t current_cache_policy;
1026 uint8_t reserved[7];
1029 struct mfi_ld_params {
1030 uint8_t primary_raid_level;
1031 uint8_t raid_level_qualifier;
1032 uint8_t secondary_raid_level;
1033 uint8_t stripe_size;
1038 #define MFI_LD_PARAMS_INIT_NO 0
1039 #define MFI_LD_PARAMS_INIT_QUICK 1
1040 #define MFI_LD_PARAMS_INIT_FULL 2
1041 uint8_t is_consistent;
1042 uint8_t reserved[23];
1045 struct mfi_ld_progress {
1047 #define MFI_LD_PROGRESS_CC (1<<0)
1048 #define MFI_LD_PROGRESS_BGI (1<<1)
1049 #define MFI_LD_PROGRESS_FGI (1<<2)
1050 #define MFI_LD_PROGRESS_RECON (1<<3)
1051 struct mfi_progress cc;
1052 struct mfi_progress bgi;
1053 struct mfi_progress fgi;
1054 struct mfi_progress recon;
1055 struct mfi_progress reserved[4];
1059 uint64_t start_block;
1060 uint64_t num_blocks;
1062 uint8_t reserved[6];
1065 #define MFI_MAX_SPAN_DEPTH 8
1066 struct mfi_ld_config {
1067 struct mfi_ld_props properties;
1068 struct mfi_ld_params params;
1069 struct mfi_span span[MFI_MAX_SPAN_DEPTH];
1072 struct mfi_ld_info {
1073 struct mfi_ld_config ld_config;
1075 struct mfi_ld_progress progress;
1076 uint16_t cluster_owner;
1077 uint8_t reconstruct_active;
1078 uint8_t reserved1[1];
1079 uint8_t vpd_page83[64];
1080 uint8_t reserved2[16];
1083 #define MAX_ARRAYS 16
1085 union mfi_pd_ref ref;
1087 #define MFI_SPARE_DEDICATED (1 << 0)
1088 #define MFI_SPARE_REVERTIBLE (1 << 1)
1089 #define MFI_SPARE_ENCL_AFFINITY (1 << 2)
1090 uint8_t reserved[2];
1091 uint8_t array_count;
1092 uint16_t array_ref[MAX_ARRAYS];
1102 union mfi_pd_ref ref; /* 0xffff == missing drive */
1103 uint16_t fw_state; /* MFI_PD_STATE_* */
1111 struct mfi_config_data {
1113 uint16_t array_count;
1114 uint16_t array_size;
1115 uint16_t log_drv_count;
1116 uint16_t log_drv_size;
1117 uint16_t spares_count;
1118 uint16_t spares_size;
1119 uint8_t reserved[16];
1120 struct mfi_array array[0];
1121 struct mfi_ld_config ld[0];
1122 struct mfi_spare spare[0];
1125 struct mfi_bbu_capacity_info {
1126 uint16_t relative_charge;
1127 uint16_t absolute_charge;
1128 uint16_t remaining_capacity;
1129 uint16_t full_charge_capacity;
1130 uint16_t run_time_to_empty;
1131 uint16_t average_time_to_empty;
1132 uint16_t average_time_to_full;
1133 uint16_t cycle_count;
1135 uint16_t remaining_capacity_alarm;
1136 uint16_t remaining_time_alarm;
1137 uint8_t reserved[26];
1140 struct mfi_bbu_design_info {
1142 uint16_t design_capacity;
1143 uint16_t design_voltage;
1145 uint16_t serial_number;
1146 uint16_t pack_stat_config;
1147 uint8_t mfg_name[12];
1148 uint8_t device_name[8];
1149 uint8_t device_chemistry[8];
1150 uint8_t mfg_data[8];
1151 uint8_t reserved[17];
1154 struct mfi_ibbu_state {
1155 uint16_t gas_guage_status;
1156 uint16_t relative_charge;
1157 uint16_t charger_system_state;
1158 uint16_t charger_system_ctrl;
1159 uint16_t charging_current;
1160 uint16_t absolute_charge;
1162 uint8_t reserved[18];
1165 struct mfi_bbu_state {
1166 uint16_t gas_guage_status;
1167 uint16_t relative_charge;
1168 uint16_t charger_status;
1169 uint16_t remaining_capacity;
1170 uint16_t full_charge_capacity;
1171 uint8_t is_SOH_good;
1172 uint8_t reserved[21];
1175 union mfi_bbu_status_detail {
1176 struct mfi_ibbu_state ibbu;
1177 struct mfi_bbu_state bbu;
1180 struct mfi_bbu_status {
1181 uint8_t battery_type;
1182 #define MFI_BBU_TYPE_NONE 0
1183 #define MFI_BBU_TYPE_IBBU 1
1184 #define MFI_BBU_TYPE_BBU 2
1188 uint16_t temperature;
1190 #define MFI_BBU_STATE_PACK_MISSING (1 << 0)
1191 #define MFI_BBU_STATE_VOLTAGE_LOW (1 << 1)
1192 #define MFI_BBU_STATE_TEMPERATURE_HIGH (1 << 2)
1193 #define MFI_BBU_STATE_CHARGE_ACTIVE (1 << 0)
1194 #define MFI_BBU_STATE_DISCHARGE_ACTIVE (1 << 0)
1196 union mfi_bbu_status_detail detail;
1200 MFI_PR_STATE_STOPPED = 0,
1201 MFI_PR_STATE_READY = 1,
1202 MFI_PR_STATE_ACTIVE = 2,
1203 MFI_PR_STATE_ABORTED = 0xff
1206 struct mfi_pr_status {
1207 uint32_t num_iteration;
1209 uint8_t num_pd_done;
1210 uint8_t reserved[10];
1213 enum mfi_pr_opmode {
1214 MFI_PR_OPMODE_AUTO = 0,
1215 MFI_PR_OPMODE_MANUAL = 1,
1216 MFI_PR_OPMODE_DISABLED = 2
1219 struct mfi_pr_properties {
1223 uint8_t exclude_ld_count;
1224 uint16_t excluded_ld[MFI_MAX_LD];
1225 uint8_t cur_pd_map[MFI_MAX_PD / 8];
1226 uint8_t last_pd_map[MFI_MAX_PD / 8];
1229 uint32_t clear_freq;
1232 #define MFI_SCSI_MAX_TARGETS 128
1233 #define MFI_SCSI_MAX_LUNS 8
1234 #define MFI_SCSI_INITIATOR_ID 255
1235 #define MFI_SCSI_MAX_CMDS 8
1236 #define MFI_SCSI_MAX_CDB_LEN 16
1238 #endif /* _MFIREG_H */