12e21a3efSScott Long /*- 2eebd9d53SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 42e21a3efSScott Long * Copyright (c) 2006 IronPort Systems 52e21a3efSScott Long * All rights reserved. 62e21a3efSScott Long * 72e21a3efSScott Long * Redistribution and use in source and binary forms, with or without 82e21a3efSScott Long * modification, are permitted provided that the following conditions 92e21a3efSScott Long * are met: 102e21a3efSScott Long * 1. Redistributions of source code must retain the above copyright 112e21a3efSScott Long * notice, this list of conditions and the following disclaimer. 122e21a3efSScott Long * 2. Redistributions in binary form must reproduce the above copyright 132e21a3efSScott Long * notice, this list of conditions and the following disclaimer in the 142e21a3efSScott Long * documentation and/or other materials provided with the distribution. 152e21a3efSScott Long * 162e21a3efSScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172e21a3efSScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182e21a3efSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192e21a3efSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202e21a3efSScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 212e21a3efSScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222e21a3efSScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232e21a3efSScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242e21a3efSScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252e21a3efSScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262e21a3efSScott Long * SUCH DAMAGE. 272e21a3efSScott Long */ 28610f2ef3SScott Long /*- 29610f2ef3SScott Long * Copyright (c) 2007 LSI Corp. 30610f2ef3SScott Long * Copyright (c) 2007 Rajesh Prabhakaran. 31610f2ef3SScott Long * All rights reserved. 32610f2ef3SScott Long * 33610f2ef3SScott Long * Redistribution and use in source and binary forms, with or without 34610f2ef3SScott Long * modification, are permitted provided that the following conditions 35610f2ef3SScott Long * are met: 36610f2ef3SScott Long * 1. Redistributions of source code must retain the above copyright 37610f2ef3SScott Long * notice, this list of conditions and the following disclaimer. 38610f2ef3SScott Long * 2. Redistributions in binary form must reproduce the above copyright 39610f2ef3SScott Long * notice, this list of conditions and the following disclaimer in the 40610f2ef3SScott Long * documentation and/or other materials provided with the distribution. 41610f2ef3SScott Long * 42610f2ef3SScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 43610f2ef3SScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 44610f2ef3SScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 45610f2ef3SScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 46610f2ef3SScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47610f2ef3SScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 48610f2ef3SScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49610f2ef3SScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 50610f2ef3SScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 51610f2ef3SScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52610f2ef3SScott Long * SUCH DAMAGE. 53610f2ef3SScott Long */ 542e21a3efSScott Long 552e21a3efSScott Long #ifndef _MFIREG_H 562e21a3efSScott Long #define _MFIREG_H 572e21a3efSScott Long 582e21a3efSScott Long #include <sys/cdefs.h> 592e21a3efSScott Long /* 602e21a3efSScott Long * MegaRAID SAS MFI firmware definitions 612e21a3efSScott Long * 622e21a3efSScott Long * Calling this driver 'MegaRAID SAS' is a bit misleading. It's a completely 632e21a3efSScott Long * new firmware interface from the old AMI MegaRAID one, and there is no 642e21a3efSScott Long * reason why this interface should be limited to just SAS. In any case, LSI 652e21a3efSScott Long * seems to also call this interface 'MFI', so that will be used here. 662e21a3efSScott Long */ 670d9a4ef3SDoug Ambrisko #define MEGAMFI_FRAME_SIZE 64 682e21a3efSScott Long /* 692e21a3efSScott Long * Start with the register set. All registers are 32 bits wide. 702e21a3efSScott Long * The usual Intel IOP style setup. 712e21a3efSScott Long */ 722e21a3efSScott Long #define MFI_IMSG0 0x10 /* Inbound message 0 */ 732e21a3efSScott Long #define MFI_IMSG1 0x14 /* Inbound message 1 */ 742e21a3efSScott Long #define MFI_OMSG0 0x18 /* Outbound message 0 */ 752e21a3efSScott Long #define MFI_OMSG1 0x1c /* Outbound message 1 */ 762e21a3efSScott Long #define MFI_IDB 0x20 /* Inbound doorbell */ 772e21a3efSScott Long #define MFI_ISTS 0x24 /* Inbound interrupt status */ 782e21a3efSScott Long #define MFI_IMSK 0x28 /* Inbound interrupt mask */ 792e21a3efSScott Long #define MFI_ODB 0x2c /* Outbound doorbell */ 802e21a3efSScott Long #define MFI_OSTS 0x30 /* Outbound interrupt status */ 812e21a3efSScott Long #define MFI_OMSK 0x34 /* Outbound interrupt mask */ 822e21a3efSScott Long #define MFI_IQP 0x40 /* Inbound queue port */ 832e21a3efSScott Long #define MFI_OQP 0x44 /* Outbound queue port */ 842e21a3efSScott Long 85610f2ef3SScott Long /* 860d9a4ef3SDoug Ambrisko * ThunderBolt specific Register 870d9a4ef3SDoug Ambrisko */ 880d9a4ef3SDoug Ambrisko 8908c89430SSteven Hartland #define MFI_RFPI 0x48 /* reply_free_post_host_index */ 900d9a4ef3SDoug Ambrisko #define MFI_RPI 0x6c /* reply_post_host_index */ 910d9a4ef3SDoug Ambrisko #define MFI_ILQP 0xc0 /* inbound_low_queue_port */ 920d9a4ef3SDoug Ambrisko #define MFI_IHQP 0xc4 /* inbound_high_queue_port */ 930d9a4ef3SDoug Ambrisko 940d9a4ef3SDoug Ambrisko /* 95610f2ef3SScott Long * 1078 specific related register 96610f2ef3SScott Long */ 97610f2ef3SScott Long #define MFI_ODR0 0x9c /* outbound doorbell register0 */ 98610f2ef3SScott Long #define MFI_ODCR0 0xa0 /* outbound doorbell clear register0 */ 99610f2ef3SScott Long #define MFI_OSP0 0xb0 /* outbound scratch pad0 */ 10098b610b5SGordon Bergling #define MFI_1078_EIM 0x80000004 /* 1078 enable interrupt mask */ 101610f2ef3SScott Long #define MFI_RMI 0x2 /* reply message interrupt */ 102610f2ef3SScott Long #define MFI_1078_RM 0x80000000 /* reply 1078 message interrupt */ 103610f2ef3SScott Long #define MFI_ODC 0x4 /* outbound doorbell change interrupt */ 104610f2ef3SScott Long 1050d9a4ef3SDoug Ambrisko /* OCR registers */ 1060d9a4ef3SDoug Ambrisko #define MFI_WSR 0x004 /* write sequence register */ 1070d9a4ef3SDoug Ambrisko #define MFI_HDR 0x008 /* host diagnostic register */ 1080d9a4ef3SDoug Ambrisko #define MFI_RSR 0x3c3 /* Reset Status Register */ 1090d9a4ef3SDoug Ambrisko 110fa1e6ef4SDoug Ambrisko /* 111fa1e6ef4SDoug Ambrisko * GEN2 specific changes 112fa1e6ef4SDoug Ambrisko */ 113fa1e6ef4SDoug Ambrisko #define MFI_GEN2_EIM 0x00000005 /* GEN2 enable interrupt mask */ 114fa1e6ef4SDoug Ambrisko #define MFI_GEN2_RM 0x00000001 /* reply GEN2 message interrupt */ 115fa1e6ef4SDoug Ambrisko 1160d9a4ef3SDoug Ambrisko /* 1170d9a4ef3SDoug Ambrisko * skinny specific changes 1180d9a4ef3SDoug Ambrisko */ 1190d9a4ef3SDoug Ambrisko #define MFI_SKINNY_IDB 0x00 /* Inbound doorbell is at 0x00 for skinny */ 1200d9a4ef3SDoug Ambrisko #define MFI_IQPL 0x000000c0 1210d9a4ef3SDoug Ambrisko #define MFI_IQPH 0x000000c4 1220d9a4ef3SDoug Ambrisko #define MFI_SKINNY_RM 0x00000001 /* reply skinny message interrupt */ 1230d9a4ef3SDoug Ambrisko 1242e21a3efSScott Long /* Bits for MFI_OSTS */ 1252e21a3efSScott Long #define MFI_OSTS_INTR_VALID 0x00000002 1262e21a3efSScott Long 1270d9a4ef3SDoug Ambrisko /* OCR specific flags */ 1280d9a4ef3SDoug Ambrisko #define MFI_FIRMWARE_STATE_CHANGE 0x00000002 1290d9a4ef3SDoug Ambrisko #define MFI_STATE_CHANGE_INTERRUPT 0x00000004 /* MFI state change interrrupt */ 1300d9a4ef3SDoug Ambrisko 1312e21a3efSScott Long /* 1322e21a3efSScott Long * Firmware state values. Found in OMSG0 during initialization. 1332e21a3efSScott Long */ 1342e21a3efSScott Long #define MFI_FWSTATE_MASK 0xf0000000 1352e21a3efSScott Long #define MFI_FWSTATE_UNDEFINED 0x00000000 1362e21a3efSScott Long #define MFI_FWSTATE_BB_INIT 0x10000000 1372e21a3efSScott Long #define MFI_FWSTATE_FW_INIT 0x40000000 1382e21a3efSScott Long #define MFI_FWSTATE_WAIT_HANDSHAKE 0x60000000 1392e21a3efSScott Long #define MFI_FWSTATE_FW_INIT_2 0x70000000 1402e21a3efSScott Long #define MFI_FWSTATE_DEVICE_SCAN 0x80000000 1415dbee633SJohn Baldwin #define MFI_FWSTATE_BOOT_MESSAGE_PENDING 0x90000000 1422e21a3efSScott Long #define MFI_FWSTATE_FLUSH_CACHE 0xa0000000 1432e21a3efSScott Long #define MFI_FWSTATE_READY 0xb0000000 1442e21a3efSScott Long #define MFI_FWSTATE_OPERATIONAL 0xc0000000 1452e21a3efSScott Long #define MFI_FWSTATE_FAULT 0xf0000000 1462e21a3efSScott Long #define MFI_FWSTATE_MAXSGL_MASK 0x00ff0000 1472e21a3efSScott Long #define MFI_FWSTATE_MAXCMD_MASK 0x0000ffff 1480d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_HOSTMEMREQD_MASK 0x08000000 1490d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_BOOT_MESSAGE_PENDING 0x90000000 1500d9a4ef3SDoug Ambrisko #define MFI_RESET_REQUIRED 0x00000001 1512e21a3efSScott Long 152a6ba0fd6SDoug Ambrisko /* ThunderBolt Support */ 1530d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_TB_MASK 0xf0000000 1540d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_TB_RESET 0x00000000 1550d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_TB_READY 0x10000000 1560d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_TB_OPERATIONAL 0x20000000 1570d9a4ef3SDoug Ambrisko #define MFI_FWSTATE_TB_FAULT 0x40000000 1582e21a3efSScott Long 1592e21a3efSScott Long /* 1602e21a3efSScott Long * Control bits to drive the card to ready state. These go into the IDB 1612e21a3efSScott Long * register. 1622e21a3efSScott Long */ 1632e21a3efSScott Long #define MFI_FWINIT_ABORT 0x00000000 /* Abort all pending commands */ 1642e21a3efSScott Long #define MFI_FWINIT_READY 0x00000002 /* Move from operational to ready */ 1652e21a3efSScott Long #define MFI_FWINIT_MFIMODE 0x00000004 /* unknown */ 1662e21a3efSScott Long #define MFI_FWINIT_CLEAR_HANDSHAKE 0x00000008 /* Respond to WAIT_HANDSHAKE */ 1675dbee633SJohn Baldwin #define MFI_FWINIT_HOTPLUG 0x00000010 1682e21a3efSScott Long 1690d9a4ef3SDoug Ambrisko /* ADP reset flags */ 1700d9a4ef3SDoug Ambrisko #define MFI_STOP_ADP 0x00000020 1710d9a4ef3SDoug Ambrisko #define MFI_ADP_RESET 0x00000040 1720d9a4ef3SDoug Ambrisko #define DIAG_WRITE_ENABLE 0x00000080 1730d9a4ef3SDoug Ambrisko #define DIAG_RESET_ADAPTER 0x00000004 1740d9a4ef3SDoug Ambrisko 1752e21a3efSScott Long /* MFI Commands */ 1762e21a3efSScott Long typedef enum { 1772e21a3efSScott Long MFI_CMD_INIT = 0x00, 1782e21a3efSScott Long MFI_CMD_LD_READ, 1792e21a3efSScott Long MFI_CMD_LD_WRITE, 1802e21a3efSScott Long MFI_CMD_LD_SCSI_IO, 1812e21a3efSScott Long MFI_CMD_PD_SCSI_IO, 1822e21a3efSScott Long MFI_CMD_DCMD, 1832e21a3efSScott Long MFI_CMD_ABORT, 1842e21a3efSScott Long MFI_CMD_SMP, 1852e21a3efSScott Long MFI_CMD_STP 1862e21a3efSScott Long } mfi_cmd_t; 1872e21a3efSScott Long 1882e21a3efSScott Long /* Direct commands */ 1892e21a3efSScott Long typedef enum { 1902e21a3efSScott Long MFI_DCMD_CTRL_GETINFO = 0x01010000, 1910d9a4ef3SDoug Ambrisko MFI_DCMD_CTRL_MFI_HOST_MEM_ALLOC =0x0100e100, 192441f6d5dSScott Long MFI_DCMD_CTRL_MFC_DEFAULTS_GET =0x010e0201, 193441f6d5dSScott Long MFI_DCMD_CTRL_MFC_DEFAULTS_SET =0x010e0202, 1942e21a3efSScott Long MFI_DCMD_CTRL_FLUSHCACHE = 0x01101000, 195c22a9c36SSean Bruno MFI_DCMD_CTRL_GET_PROPS = 0x01020100, 196c22a9c36SSean Bruno MFI_DCMD_CTRL_SET_PROPS = 0x01020200, 1972e21a3efSScott Long MFI_DCMD_CTRL_SHUTDOWN = 0x01050000, 1982e21a3efSScott Long MFI_DCMD_CTRL_EVENT_GETINFO = 0x01040100, 1992e21a3efSScott Long MFI_DCMD_CTRL_EVENT_GET = 0x01040300, 2002e21a3efSScott Long MFI_DCMD_CTRL_EVENT_WAIT = 0x01040500, 201763fae79SScott Long MFI_DCMD_PR_GET_STATUS = 0x01070100, 202763fae79SScott Long MFI_DCMD_PR_GET_PROPERTIES = 0x01070200, 203763fae79SScott Long MFI_DCMD_PR_SET_PROPERTIES = 0x01070300, 204763fae79SScott Long MFI_DCMD_PR_START = 0x01070400, 205763fae79SScott Long MFI_DCMD_PR_STOP = 0x01070500, 206763fae79SScott Long MFI_DCMD_TIME_SECS_GET = 0x01080201, 207763fae79SScott Long MFI_DCMD_FLASH_FW_OPEN = 0x010f0100, 208763fae79SScott Long MFI_DCMD_FLASH_FW_DOWNLOAD = 0x010f0200, 209763fae79SScott Long MFI_DCMD_FLASH_FW_FLASH = 0x010f0300, 210763fae79SScott Long MFI_DCMD_FLASH_FW_CLOSE = 0x010f0400, 211763fae79SScott Long MFI_DCMD_PD_GET_LIST = 0x02010000, 2120d9a4ef3SDoug Ambrisko MFI_DCMD_PD_LIST_QUERY = 0x02010100, 213763fae79SScott Long MFI_DCMD_PD_GET_INFO = 0x02020000, 214763fae79SScott Long MFI_DCMD_PD_STATE_SET = 0x02030100, 215763fae79SScott Long MFI_DCMD_PD_REBUILD_START = 0x02040100, 216763fae79SScott Long MFI_DCMD_PD_REBUILD_ABORT = 0x02040200, 217763fae79SScott Long MFI_DCMD_PD_CLEAR_START = 0x02050100, 218763fae79SScott Long MFI_DCMD_PD_CLEAR_ABORT = 0x02050200, 219763fae79SScott Long MFI_DCMD_PD_GET_PROGRESS = 0x02060000, 220763fae79SScott Long MFI_DCMD_PD_LOCATE_START = 0x02070100, 221763fae79SScott Long MFI_DCMD_PD_LOCATE_STOP = 0x02070200, 2220d9a4ef3SDoug Ambrisko MFI_DCMD_LD_MAP_GET_INFO = 0x0300e101, 2230d9a4ef3SDoug Ambrisko MFI_DCMD_LD_SYNC = 0x0300e102, 224c0b332d1SPaul Saab MFI_DCMD_LD_GET_LIST = 0x03010000, 225c0b332d1SPaul Saab MFI_DCMD_LD_GET_INFO = 0x03020000, 2262e21a3efSScott Long MFI_DCMD_LD_GET_PROP = 0x03030000, 227c0b332d1SPaul Saab MFI_DCMD_LD_SET_PROP = 0x03040000, 228763fae79SScott Long MFI_DCMD_LD_INIT_START = 0x03060100, 2298ec5c98bSJohn Baldwin MFI_DCMD_LD_DELETE = 0x03090000, 230441f6d5dSScott Long MFI_DCMD_CFG_READ = 0x04010000, 231441f6d5dSScott Long MFI_DCMD_CFG_ADD = 0x04020000, 232441f6d5dSScott Long MFI_DCMD_CFG_CLEAR = 0x04030000, 233763fae79SScott Long MFI_DCMD_CFG_MAKE_SPARE = 0x04040000, 234763fae79SScott Long MFI_DCMD_CFG_REMOVE_SPARE = 0x04050000, 23506f1884fSSean Bruno MFI_DCMD_CFG_FOREIGN_SCAN = 0x04060100, 23606f1884fSSean Bruno MFI_DCMD_CFG_FOREIGN_DISPLAY = 0x04060200, 23706f1884fSSean Bruno MFI_DCMD_CFG_FOREIGN_PREVIEW = 0x04060300, 238fa1e6ef4SDoug Ambrisko MFI_DCMD_CFG_FOREIGN_IMPORT = 0x04060400, 23906f1884fSSean Bruno MFI_DCMD_CFG_FOREIGN_CLEAR = 0x04060500, 240763fae79SScott Long MFI_DCMD_BBU_GET_STATUS = 0x05010000, 241763fae79SScott Long MFI_DCMD_BBU_GET_CAPACITY_INFO =0x05020000, 242763fae79SScott Long MFI_DCMD_BBU_GET_DESIGN_INFO = 0x05030000, 243dee3e845SMark Johnston MFI_DCMD_BBU_START_LEARN = 0x05040000, 244dee3e845SMark Johnston MFI_DCMD_BBU_GET_PROP = 0x05050100, 245dee3e845SMark Johnston MFI_DCMD_BBU_SET_PROP = 0x05050200, 2462e21a3efSScott Long MFI_DCMD_CLUSTER = 0x08000000, 2472e21a3efSScott Long MFI_DCMD_CLUSTER_RESET_ALL = 0x08010100, 2482e21a3efSScott Long MFI_DCMD_CLUSTER_RESET_LD = 0x08010200 2492e21a3efSScott Long } mfi_dcmd_t; 2502e21a3efSScott Long 2512e21a3efSScott Long /* Modifiers for MFI_DCMD_CTRL_FLUSHCACHE */ 2522e21a3efSScott Long #define MFI_FLUSHCACHE_CTRL 0x01 2532e21a3efSScott Long #define MFI_FLUSHCACHE_DISK 0x02 2542e21a3efSScott Long 2552e21a3efSScott Long /* Modifiers for MFI_DCMD_CTRL_SHUTDOWN */ 2562e21a3efSScott Long #define MFI_SHUTDOWN_SPINDOWN 0x01 2572e21a3efSScott Long 2582e21a3efSScott Long /* 259741367d5SDoug Ambrisko * MFI Frame flags 2602e21a3efSScott Long */ 2612e21a3efSScott Long #define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000 2622e21a3efSScott Long #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001 2632e21a3efSScott Long #define MFI_FRAME_SGL32 0x0000 2642e21a3efSScott Long #define MFI_FRAME_SGL64 0x0002 2652e21a3efSScott Long #define MFI_FRAME_SENSE32 0x0000 2662e21a3efSScott Long #define MFI_FRAME_SENSE64 0x0004 2672e21a3efSScott Long #define MFI_FRAME_DIR_NONE 0x0000 2682e21a3efSScott Long #define MFI_FRAME_DIR_WRITE 0x0008 2692e21a3efSScott Long #define MFI_FRAME_DIR_READ 0x0010 2702e21a3efSScott Long #define MFI_FRAME_DIR_BOTH 0x0018 2710d9a4ef3SDoug Ambrisko #define MFI_FRAME_IEEE_SGL 0x0020 27208c89430SSteven Hartland #define MFI_FRAME_FMT "\20" \ 27308c89430SSteven Hartland "\1NOPOST" \ 27408c89430SSteven Hartland "\2SGL64" \ 27508c89430SSteven Hartland "\3SENSE64" \ 27608c89430SSteven Hartland "\4WRITE" \ 27708c89430SSteven Hartland "\5READ" \ 27808c89430SSteven Hartland "\6IEEESGL" 2790d9a4ef3SDoug Ambrisko 2800d9a4ef3SDoug Ambrisko /* ThunderBolt Specific */ 2810d9a4ef3SDoug Ambrisko 282a6ba0fd6SDoug Ambrisko /* 283a6ba0fd6SDoug Ambrisko * Pre-TB command size and TB command size. 284a6ba0fd6SDoug Ambrisko * We will be checking it at the load time for the time being 285a6ba0fd6SDoug Ambrisko */ 286a6ba0fd6SDoug Ambrisko #define MR_COMMAND_SIZE (MFI_FRAME_SIZE*20) /* 1280 bytes */ 2870d9a4ef3SDoug Ambrisko 2880d9a4ef3SDoug Ambrisko #define MEGASAS_THUNDERBOLT_MSG_ALLIGNMENT 256 289a6ba0fd6SDoug Ambrisko /* 290a6ba0fd6SDoug Ambrisko * We are defining only 128 byte message to reduce memory move over head 291a6ba0fd6SDoug Ambrisko * and also it will reduce the SRB extension size by 128byte compared with 292a6ba0fd6SDoug Ambrisko * 256 message size 293a6ba0fd6SDoug Ambrisko */ 2940d9a4ef3SDoug Ambrisko #define MEGASAS_THUNDERBOLT_NEW_MSG_SIZE 256 2950d9a4ef3SDoug Ambrisko #define MEGASAS_THUNDERBOLT_MAX_COMMANDS 1024 2960d9a4ef3SDoug Ambrisko #define MEGASAS_THUNDERBOLT_MAX_REPLY_COUNT 1024 2970d9a4ef3SDoug Ambrisko #define MEGASAS_THUNDERBOLT_REPLY_SIZE 8 2980d9a4ef3SDoug Ambrisko #define MEGASAS_THUNDERBOLT_MAX_CHAIN_COUNT 1 2990d9a4ef3SDoug Ambrisko #define MEGASAS_MAX_SZ_CHAIN_FRAME 1024 3000d9a4ef3SDoug Ambrisko 3010d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_PASSTHRU_IO_REQUEST 0xF0 3020d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_LD_IO_REQUEST 0xF1 3030d9a4ef3SDoug Ambrisko 3040d9a4ef3SDoug Ambrisko #define MR_INTERNAL_MFI_FRAMES_SMID 1 3050d9a4ef3SDoug Ambrisko #define MR_CTRL_EVENT_WAIT_SMID 2 3060d9a4ef3SDoug Ambrisko #define MR_INTERNAL_DRIVER_RESET_SMID 3 3070d9a4ef3SDoug Ambrisko 3082e21a3efSScott Long /* MFI Status codes */ 3092e21a3efSScott Long typedef enum { 3102e21a3efSScott Long MFI_STAT_OK = 0x00, 3112e21a3efSScott Long MFI_STAT_INVALID_CMD, 3122e21a3efSScott Long MFI_STAT_INVALID_DCMD, 3132e21a3efSScott Long MFI_STAT_INVALID_PARAMETER, 3142e21a3efSScott Long MFI_STAT_INVALID_SEQUENCE_NUMBER, 3152e21a3efSScott Long MFI_STAT_ABORT_NOT_POSSIBLE, 3162e21a3efSScott Long MFI_STAT_APP_HOST_CODE_NOT_FOUND, 3172e21a3efSScott Long MFI_STAT_APP_IN_USE, 3182e21a3efSScott Long MFI_STAT_APP_NOT_INITIALIZED, 3192e21a3efSScott Long MFI_STAT_ARRAY_INDEX_INVALID, 3202e21a3efSScott Long MFI_STAT_ARRAY_ROW_NOT_EMPTY, 3212e21a3efSScott Long MFI_STAT_CONFIG_RESOURCE_CONFLICT, 3222e21a3efSScott Long MFI_STAT_DEVICE_NOT_FOUND, 3232e21a3efSScott Long MFI_STAT_DRIVE_TOO_SMALL, 3242e21a3efSScott Long MFI_STAT_FLASH_ALLOC_FAIL, 3252e21a3efSScott Long MFI_STAT_FLASH_BUSY, 3262e21a3efSScott Long MFI_STAT_FLASH_ERROR = 0x10, 3272e21a3efSScott Long MFI_STAT_FLASH_IMAGE_BAD, 3282e21a3efSScott Long MFI_STAT_FLASH_IMAGE_INCOMPLETE, 3292e21a3efSScott Long MFI_STAT_FLASH_NOT_OPEN, 3302e21a3efSScott Long MFI_STAT_FLASH_NOT_STARTED, 3312e21a3efSScott Long MFI_STAT_FLUSH_FAILED, 3322e21a3efSScott Long MFI_STAT_HOST_CODE_NOT_FOUNT, 3332e21a3efSScott Long MFI_STAT_LD_CC_IN_PROGRESS, 3342e21a3efSScott Long MFI_STAT_LD_INIT_IN_PROGRESS, 3352e21a3efSScott Long MFI_STAT_LD_LBA_OUT_OF_RANGE, 3362e21a3efSScott Long MFI_STAT_LD_MAX_CONFIGURED, 3372e21a3efSScott Long MFI_STAT_LD_NOT_OPTIMAL, 3382e21a3efSScott Long MFI_STAT_LD_RBLD_IN_PROGRESS, 3392e21a3efSScott Long MFI_STAT_LD_RECON_IN_PROGRESS, 3402e21a3efSScott Long MFI_STAT_LD_WRONG_RAID_LEVEL, 3412e21a3efSScott Long MFI_STAT_MAX_SPARES_EXCEEDED, 3422e21a3efSScott Long MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20, 3432e21a3efSScott Long MFI_STAT_MFC_HW_ERROR, 3442e21a3efSScott Long MFI_STAT_NO_HW_PRESENT, 3452e21a3efSScott Long MFI_STAT_NOT_FOUND, 3462e21a3efSScott Long MFI_STAT_NOT_IN_ENCL, 3472e21a3efSScott Long MFI_STAT_PD_CLEAR_IN_PROGRESS, 3482e21a3efSScott Long MFI_STAT_PD_TYPE_WRONG, 3492e21a3efSScott Long MFI_STAT_PR_DISABLED, 3502e21a3efSScott Long MFI_STAT_ROW_INDEX_INVALID, 3512e21a3efSScott Long MFI_STAT_SAS_CONFIG_INVALID_ACTION, 3522e21a3efSScott Long MFI_STAT_SAS_CONFIG_INVALID_DATA, 3532e21a3efSScott Long MFI_STAT_SAS_CONFIG_INVALID_PAGE, 3542e21a3efSScott Long MFI_STAT_SAS_CONFIG_INVALID_TYPE, 3552e21a3efSScott Long MFI_STAT_SCSI_DONE_WITH_ERROR, 3562e21a3efSScott Long MFI_STAT_SCSI_IO_FAILED, 3572e21a3efSScott Long MFI_STAT_SCSI_RESERVATION_CONFLICT, 3582e21a3efSScott Long MFI_STAT_SHUTDOWN_FAILED = 0x30, 3592e21a3efSScott Long MFI_STAT_TIME_NOT_SET, 3602e21a3efSScott Long MFI_STAT_WRONG_STATE, 3612e21a3efSScott Long MFI_STAT_LD_OFFLINE, 3622e21a3efSScott Long MFI_STAT_PEER_NOTIFICATION_REJECTED, 3632e21a3efSScott Long MFI_STAT_PEER_NOTIFICATION_FAILED, 3642e21a3efSScott Long MFI_STAT_RESERVATION_IN_PROGRESS, 3652e21a3efSScott Long MFI_STAT_I2C_ERRORS_DETECTED, 3662e21a3efSScott Long MFI_STAT_PCI_ERRORS_DETECTED, 367763fae79SScott Long MFI_STAT_DIAG_FAILED, 368763fae79SScott Long MFI_STAT_BOOT_MSG_PENDING, 369763fae79SScott Long MFI_STAT_FOREIGN_CONFIG_INCOMPLETE, 3702e21a3efSScott Long MFI_STAT_INVALID_STATUS = 0xFF 3712e21a3efSScott Long } mfi_status_t; 3722e21a3efSScott Long 3732e21a3efSScott Long typedef enum { 3742e21a3efSScott Long MFI_EVT_CLASS_DEBUG = -2, 3752e21a3efSScott Long MFI_EVT_CLASS_PROGRESS = -1, 3762e21a3efSScott Long MFI_EVT_CLASS_INFO = 0, 3772e21a3efSScott Long MFI_EVT_CLASS_WARNING = 1, 3782e21a3efSScott Long MFI_EVT_CLASS_CRITICAL = 2, 3792e21a3efSScott Long MFI_EVT_CLASS_FATAL = 3, 3802e21a3efSScott Long MFI_EVT_CLASS_DEAD = 4 3812e21a3efSScott Long } mfi_evt_class_t; 3822e21a3efSScott Long 3832e21a3efSScott Long typedef enum { 3842e21a3efSScott Long MFI_EVT_LOCALE_LD = 0x0001, 3852e21a3efSScott Long MFI_EVT_LOCALE_PD = 0x0002, 3862e21a3efSScott Long MFI_EVT_LOCALE_ENCL = 0x0004, 3872e21a3efSScott Long MFI_EVT_LOCALE_BBU = 0x0008, 3882e21a3efSScott Long MFI_EVT_LOCALE_SAS = 0x0010, 3892e21a3efSScott Long MFI_EVT_LOCALE_CTRL = 0x0020, 3902e21a3efSScott Long MFI_EVT_LOCALE_CONFIG = 0x0040, 3912e21a3efSScott Long MFI_EVT_LOCALE_CLUSTER = 0x0080, 3922e21a3efSScott Long MFI_EVT_LOCALE_ALL = 0xffff 3932e21a3efSScott Long } mfi_evt_locale_t; 3942e21a3efSScott Long 3952e21a3efSScott Long typedef enum { 3962e21a3efSScott Long MR_EVT_ARGS_NONE = 0x00, 3972e21a3efSScott Long MR_EVT_ARGS_CDB_SENSE, 3982e21a3efSScott Long MR_EVT_ARGS_LD, 3992e21a3efSScott Long MR_EVT_ARGS_LD_COUNT, 4002e21a3efSScott Long MR_EVT_ARGS_LD_LBA, 4012e21a3efSScott Long MR_EVT_ARGS_LD_OWNER, 4022e21a3efSScott Long MR_EVT_ARGS_LD_LBA_PD_LBA, 4032e21a3efSScott Long MR_EVT_ARGS_LD_PROG, 4042e21a3efSScott Long MR_EVT_ARGS_LD_STATE, 4052e21a3efSScott Long MR_EVT_ARGS_LD_STRIP, 4062e21a3efSScott Long MR_EVT_ARGS_PD, 4072e21a3efSScott Long MR_EVT_ARGS_PD_ERR, 4082e21a3efSScott Long MR_EVT_ARGS_PD_LBA, 4092e21a3efSScott Long MR_EVT_ARGS_PD_LBA_LD, 4102e21a3efSScott Long MR_EVT_ARGS_PD_PROG, 4112e21a3efSScott Long MR_EVT_ARGS_PD_STATE, 4122e21a3efSScott Long MR_EVT_ARGS_PCI, 4132e21a3efSScott Long MR_EVT_ARGS_RATE, 4142e21a3efSScott Long MR_EVT_ARGS_STR, 4152e21a3efSScott Long MR_EVT_ARGS_TIME, 4162e21a3efSScott Long MR_EVT_ARGS_ECC 4172e21a3efSScott Long } mfi_evt_args; 4182e21a3efSScott Long 419a6ba0fd6SDoug Ambrisko #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152 420a6ba0fd6SDoug Ambrisko #define MR_EVT_PD_REMOVED 0x0070 421a6ba0fd6SDoug Ambrisko #define MR_EVT_PD_INSERTED 0x005b 422ddbffe7fSDoug Ambrisko #define MR_EVT_LD_CHANGE 0x0051 423a6ba0fd6SDoug Ambrisko 424441f6d5dSScott Long typedef enum { 425441f6d5dSScott Long MR_LD_CACHE_WRITE_BACK = 0x01, 426441f6d5dSScott Long MR_LD_CACHE_WRITE_ADAPTIVE = 0x02, 427441f6d5dSScott Long MR_LD_CACHE_READ_AHEAD = 0x04, 428441f6d5dSScott Long MR_LD_CACHE_READ_ADAPTIVE = 0x08, 429441f6d5dSScott Long MR_LD_CACHE_WRITE_CACHE_BAD_BBU=0x10, 430441f6d5dSScott Long MR_LD_CACHE_ALLOW_WRITE_CACHE = 0x20, 431441f6d5dSScott Long MR_LD_CACHE_ALLOW_READ_CACHE = 0x40 432441f6d5dSScott Long } mfi_ld_cache; 433763fae79SScott Long #define MR_LD_CACHE_MASK 0x7f 434763fae79SScott Long 435763fae79SScott Long #define MR_LD_CACHE_POLICY_READ_AHEAD_NONE 0 436763fae79SScott Long #define MR_LD_CACHE_POLICY_READ_AHEAD_ALWAYS MR_LD_CACHE_READ_AHEAD 437763fae79SScott Long #define MR_LD_CACHE_POLICY_READ_AHEAD_ADAPTIVE \ 438763fae79SScott Long (MR_LD_CACHE_READ_AHEAD | MR_LD_CACHE_READ_ADAPTIVE) 439763fae79SScott Long #define MR_LD_CACHE_POLICY_WRITE_THROUGH 0 440763fae79SScott Long #define MR_LD_CACHE_POLICY_WRITE_BACK MR_LD_CACHE_WRITE_BACK 441763fae79SScott Long #define MR_LD_CACHE_POLICY_IO_CACHED \ 442763fae79SScott Long (MR_LD_CACHE_ALLOW_WRITE_CACHE | MR_LD_CACHE_ALLOW_READ_CACHE) 443763fae79SScott Long #define MR_LD_CACHE_POLICY_IO_DIRECT 0 444441f6d5dSScott Long 445441f6d5dSScott Long typedef enum { 446441f6d5dSScott Long MR_PD_CACHE_UNCHANGED = 0, 447441f6d5dSScott Long MR_PD_CACHE_ENABLE = 1, 448441f6d5dSScott Long MR_PD_CACHE_DISABLE = 2 449441f6d5dSScott Long } mfi_pd_cache; 450441f6d5dSScott Long 4510d9a4ef3SDoug Ambrisko typedef enum { 4520d9a4ef3SDoug Ambrisko MR_PD_QUERY_TYPE_ALL = 0, 4530d9a4ef3SDoug Ambrisko MR_PD_QUERY_TYPE_STATE = 1, 4540d9a4ef3SDoug Ambrisko MR_PD_QUERY_TYPE_POWER_STATE = 2, 4550d9a4ef3SDoug Ambrisko MR_PD_QUERY_TYPE_MEDIA_TYPE = 3, 4560d9a4ef3SDoug Ambrisko MR_PD_QUERY_TYPE_SPEED = 4, 457a6ba0fd6SDoug Ambrisko MR_PD_QUERY_TYPE_EXPOSED_TO_HOST = 5 /*query for system drives */ 4580d9a4ef3SDoug Ambrisko } mfi_pd_query_type; 4590d9a4ef3SDoug Ambrisko 4602e21a3efSScott Long /* 4612e21a3efSScott Long * Other propertities and definitions 4622e21a3efSScott Long */ 4632e21a3efSScott Long #define MFI_MAX_PD_CHANNELS 2 4642e21a3efSScott Long #define MFI_MAX_LD_CHANNELS 2 4652e21a3efSScott Long #define MFI_MAX_CHANNELS (MFI_MAX_PD_CHANNELS + MFI_MAX_LD_CHANNELS) 4662e21a3efSScott Long #define MFI_MAX_CHANNEL_DEVS 128 4672e21a3efSScott Long #define MFI_DEFAULT_ID -1 4682e21a3efSScott Long #define MFI_MAX_LUN 8 4692e21a3efSScott Long #define MFI_MAX_LD 64 470763fae79SScott Long #define MFI_MAX_PD 256 4712e21a3efSScott Long 4722e21a3efSScott Long #define MFI_FRAME_SIZE 64 4732e21a3efSScott Long #define MFI_MBOX_SIZE 12 4742e21a3efSScott Long 47508c89430SSteven Hartland /* Firmware flashing can take 50+ seconds */ 47608c89430SSteven Hartland #define MFI_POLL_TIMEOUT_SECS 60 4772e21a3efSScott Long 4782e21a3efSScott Long /* Allow for speedier math calculations */ 4792e21a3efSScott Long #define MFI_SECTOR_LEN 512 4802e21a3efSScott Long 4812e21a3efSScott Long /* Scatter Gather elements */ 4822e21a3efSScott Long struct mfi_sg32 { 4832e21a3efSScott Long uint32_t addr; 4842e21a3efSScott Long uint32_t len; 4852e21a3efSScott Long } __packed; 4862e21a3efSScott Long 4872e21a3efSScott Long struct mfi_sg64 { 4882e21a3efSScott Long uint64_t addr; 4892e21a3efSScott Long uint32_t len; 4902e21a3efSScott Long } __packed; 4912e21a3efSScott Long 4920d9a4ef3SDoug Ambrisko struct mfi_sg_skinny { 4930d9a4ef3SDoug Ambrisko uint64_t addr; 4940d9a4ef3SDoug Ambrisko uint32_t len; 4950d9a4ef3SDoug Ambrisko uint32_t flag; 4960d9a4ef3SDoug Ambrisko } __packed; 4970d9a4ef3SDoug Ambrisko 4982e21a3efSScott Long union mfi_sgl { 4992e21a3efSScott Long struct mfi_sg32 sg32[1]; 5002e21a3efSScott Long struct mfi_sg64 sg64[1]; 5010d9a4ef3SDoug Ambrisko struct mfi_sg_skinny sg_skinny[1]; 5022e21a3efSScott Long } __packed; 5032e21a3efSScott Long 5042e21a3efSScott Long /* Message frames. All messages have a common header */ 5052e21a3efSScott Long struct mfi_frame_header { 5062e21a3efSScott Long uint8_t cmd; 5072e21a3efSScott Long uint8_t sense_len; 5082e21a3efSScott Long uint8_t cmd_status; 5092e21a3efSScott Long uint8_t scsi_status; 5102e21a3efSScott Long uint8_t target_id; 5112e21a3efSScott Long uint8_t lun_id; 5122e21a3efSScott Long uint8_t cdb_len; 5132e21a3efSScott Long uint8_t sg_count; 5142e21a3efSScott Long uint32_t context; 5150d9a4ef3SDoug Ambrisko /* 5160d9a4ef3SDoug Ambrisko * pad0 is MSI Specific. Not used by Driver. Zero the value before 517a6ba0fd6SDoug Ambrisko * sending the command to f/w. 5180d9a4ef3SDoug Ambrisko */ 5192e21a3efSScott Long uint32_t pad0; 5202e21a3efSScott Long uint16_t flags; 52104697de9SDoug Ambrisko #define MFI_FRAME_DATAOUT 0x08 52204697de9SDoug Ambrisko #define MFI_FRAME_DATAIN 0x10 5232e21a3efSScott Long uint16_t timeout; 5242e21a3efSScott Long uint32_t data_len; 5252e21a3efSScott Long } __packed; 5262e21a3efSScott Long 5272e21a3efSScott Long struct mfi_init_frame { 5282e21a3efSScott Long struct mfi_frame_header header; 5292e21a3efSScott Long uint32_t qinfo_new_addr_lo; 5302e21a3efSScott Long uint32_t qinfo_new_addr_hi; 5312e21a3efSScott Long uint32_t qinfo_old_addr_lo; 5322e21a3efSScott Long uint32_t qinfo_old_addr_hi; 5330d9a4ef3SDoug Ambrisko // Start LSIP200113393 5340d9a4ef3SDoug Ambrisko uint32_t driver_ver_lo; /*28h */ 5350d9a4ef3SDoug Ambrisko uint32_t driver_ver_hi; /*2Ch */ 5360d9a4ef3SDoug Ambrisko 5370d9a4ef3SDoug Ambrisko uint32_t reserved[4]; 5380d9a4ef3SDoug Ambrisko // End LSIP200113393 5392e21a3efSScott Long } __packed; 5402e21a3efSScott Long 5410d9a4ef3SDoug Ambrisko /* 542a6ba0fd6SDoug Ambrisko * Define MFI Address Context union. 5430d9a4ef3SDoug Ambrisko */ 5440d9a4ef3SDoug Ambrisko #ifdef MFI_ADDRESS_IS_uint64_t 5450d9a4ef3SDoug Ambrisko typedef uint64_t MFI_ADDRESS; 5460d9a4ef3SDoug Ambrisko #else 5470d9a4ef3SDoug Ambrisko typedef union _MFI_ADDRESS { 5480d9a4ef3SDoug Ambrisko struct { 5490d9a4ef3SDoug Ambrisko uint32_t addressLow; 5500d9a4ef3SDoug Ambrisko uint32_t addressHigh; 5510d9a4ef3SDoug Ambrisko } u; 5520d9a4ef3SDoug Ambrisko uint64_t address; 5530d9a4ef3SDoug Ambrisko } MFI_ADDRESS, *PMFI_ADDRESS; 5540d9a4ef3SDoug Ambrisko #endif 5550d9a4ef3SDoug Ambrisko 5562e21a3efSScott Long #define MFI_IO_FRAME_SIZE 40 5572e21a3efSScott Long struct mfi_io_frame { 5582e21a3efSScott Long struct mfi_frame_header header; 5592e21a3efSScott Long uint32_t sense_addr_lo; 5602e21a3efSScott Long uint32_t sense_addr_hi; 5612e21a3efSScott Long uint32_t lba_lo; 5622e21a3efSScott Long uint32_t lba_hi; 5632e21a3efSScott Long union mfi_sgl sgl; 5642e21a3efSScott Long } __packed; 5652e21a3efSScott Long 5662e21a3efSScott Long #define MFI_PASS_FRAME_SIZE 48 5672e21a3efSScott Long struct mfi_pass_frame { 5682e21a3efSScott Long struct mfi_frame_header header; 5692e21a3efSScott Long uint32_t sense_addr_lo; 5702e21a3efSScott Long uint32_t sense_addr_hi; 5712e21a3efSScott Long uint8_t cdb[16]; 5722e21a3efSScott Long union mfi_sgl sgl; 5732e21a3efSScott Long } __packed; 5742e21a3efSScott Long 5752e21a3efSScott Long #define MFI_DCMD_FRAME_SIZE 40 5762e21a3efSScott Long struct mfi_dcmd_frame { 5772e21a3efSScott Long struct mfi_frame_header header; 5782e21a3efSScott Long uint32_t opcode; 5792e21a3efSScott Long uint8_t mbox[MFI_MBOX_SIZE]; 5802e21a3efSScott Long union mfi_sgl sgl; 5812e21a3efSScott Long } __packed; 5822e21a3efSScott Long 5832e21a3efSScott Long struct mfi_abort_frame { 5842e21a3efSScott Long struct mfi_frame_header header; 5852e21a3efSScott Long uint32_t abort_context; 5860d9a4ef3SDoug Ambrisko /* pad is changed to reserved.*/ 5870d9a4ef3SDoug Ambrisko uint32_t reserved0; 5882e21a3efSScott Long uint32_t abort_mfi_addr_lo; 5892e21a3efSScott Long uint32_t abort_mfi_addr_hi; 5900d9a4ef3SDoug Ambrisko uint32_t reserved1[6]; 5912e21a3efSScott Long } __packed; 5922e21a3efSScott Long 5932e21a3efSScott Long struct mfi_smp_frame { 5942e21a3efSScott Long struct mfi_frame_header header; 5952e21a3efSScott Long uint64_t sas_addr; 5962e21a3efSScott Long union { 5972e21a3efSScott Long struct mfi_sg32 sg32[2]; 5982e21a3efSScott Long struct mfi_sg64 sg64[2]; 5992e21a3efSScott Long } sgl; 6002e21a3efSScott Long } __packed; 6012e21a3efSScott Long 6022e21a3efSScott Long struct mfi_stp_frame { 6032e21a3efSScott Long struct mfi_frame_header header; 6042e21a3efSScott Long uint16_t fis[10]; 6052e21a3efSScott Long uint32_t stp_flags; 6062e21a3efSScott Long union { 6072e21a3efSScott Long struct mfi_sg32 sg32[2]; 6082e21a3efSScott Long struct mfi_sg64 sg64[2]; 6092e21a3efSScott Long } sgl; 6102e21a3efSScott Long } __packed; 6112e21a3efSScott Long 6122e21a3efSScott Long union mfi_frame { 6132e21a3efSScott Long struct mfi_frame_header header; 6142e21a3efSScott Long struct mfi_init_frame init; 6150d9a4ef3SDoug Ambrisko /* ThunderBolt Initialization */ 6162e21a3efSScott Long struct mfi_io_frame io; 6172e21a3efSScott Long struct mfi_pass_frame pass; 6182e21a3efSScott Long struct mfi_dcmd_frame dcmd; 6192e21a3efSScott Long struct mfi_abort_frame abort; 6202e21a3efSScott Long struct mfi_smp_frame smp; 6212e21a3efSScott Long struct mfi_stp_frame stp; 6222e21a3efSScott Long uint8_t bytes[MFI_FRAME_SIZE]; 6232e21a3efSScott Long }; 6242e21a3efSScott Long 6252e21a3efSScott Long #define MFI_SENSE_LEN 128 6262e21a3efSScott Long struct mfi_sense { 6272e21a3efSScott Long uint8_t data[MFI_SENSE_LEN]; 6282e21a3efSScott Long }; 6292e21a3efSScott Long 6302e21a3efSScott Long /* The queue init structure that is passed with the init message */ 6312e21a3efSScott Long struct mfi_init_qinfo { 6322e21a3efSScott Long uint32_t flags; 6332e21a3efSScott Long uint32_t rq_entries; 6342e21a3efSScott Long uint32_t rq_addr_lo; 6352e21a3efSScott Long uint32_t rq_addr_hi; 6362e21a3efSScott Long uint32_t pi_addr_lo; 6372e21a3efSScott Long uint32_t pi_addr_hi; 6382e21a3efSScott Long uint32_t ci_addr_lo; 6392e21a3efSScott Long uint32_t ci_addr_hi; 6402e21a3efSScott Long } __packed; 6412e21a3efSScott Long 6422e21a3efSScott Long /* SAS (?) controller properties, part of mfi_ctrl_info */ 6432e21a3efSScott Long struct mfi_ctrl_props { 6442e21a3efSScott Long uint16_t seq_num; 6452e21a3efSScott Long uint16_t pred_fail_poll_interval; 6462e21a3efSScott Long uint16_t intr_throttle_cnt; 6472e21a3efSScott Long uint16_t intr_throttle_timeout; 6482e21a3efSScott Long uint8_t rebuild_rate; 6492e21a3efSScott Long uint8_t patrol_read_rate; 6502e21a3efSScott Long uint8_t bgi_rate; 6512e21a3efSScott Long uint8_t cc_rate; 6522e21a3efSScott Long uint8_t recon_rate; 6532e21a3efSScott Long uint8_t cache_flush_interval; 6542e21a3efSScott Long uint8_t spinup_drv_cnt; 6552e21a3efSScott Long uint8_t spinup_delay; 6562e21a3efSScott Long uint8_t cluster_enable; 6572e21a3efSScott Long uint8_t coercion_mode; 6582e21a3efSScott Long uint8_t alarm_enable; 6592e21a3efSScott Long uint8_t disable_auto_rebuild; 6602e21a3efSScott Long uint8_t disable_battery_warn; 6612e21a3efSScott Long uint8_t ecc_bucket_size; 6622e21a3efSScott Long uint16_t ecc_bucket_leak_rate; 6632e21a3efSScott Long uint8_t restore_hotspare_on_insertion; 6642e21a3efSScott Long uint8_t expose_encl_devices; 6650d9a4ef3SDoug Ambrisko uint8_t maintainPdFailHistory; 6660d9a4ef3SDoug Ambrisko uint8_t disallowHostRequestReordering; 667a6ba0fd6SDoug Ambrisko /* set TRUE to abort CC on detecting an inconsistency */ 668a6ba0fd6SDoug Ambrisko uint8_t abortCCOnError; 669a6ba0fd6SDoug Ambrisko /* load balance mode (MR_LOAD_BALANCE_MODE) */ 670a6ba0fd6SDoug Ambrisko uint8_t loadBalanceMode; 671a6ba0fd6SDoug Ambrisko /* 672a6ba0fd6SDoug Ambrisko * 0 - use auto detect logic of backplanes like SGPIO, i2c SEP using 673a6ba0fd6SDoug Ambrisko * h/w mechansim like GPIO pins 674a6ba0fd6SDoug Ambrisko * 1 - disable auto detect SGPIO, 675a6ba0fd6SDoug Ambrisko * 2 - disable i2c SEP auto detect 676a6ba0fd6SDoug Ambrisko * 3 - disable both auto detect 677a6ba0fd6SDoug Ambrisko */ 678a6ba0fd6SDoug Ambrisko uint8_t disableAutoDetectBackplane; 679a6ba0fd6SDoug Ambrisko /* 680a6ba0fd6SDoug Ambrisko * % of source LD to be reserved for a VDs snapshot in snapshot 681a6ba0fd6SDoug Ambrisko * repository, for metadata and user data: 1=5%, 2=10%, 3=15% and so on 682a6ba0fd6SDoug Ambrisko */ 683a6ba0fd6SDoug Ambrisko uint8_t snapVDSpace; 6840d9a4ef3SDoug Ambrisko 6850d9a4ef3SDoug Ambrisko /* 686a6ba0fd6SDoug Ambrisko * Add properties that can be controlled by a bit in the following 687a6ba0fd6SDoug Ambrisko * structure. 6880d9a4ef3SDoug Ambrisko */ 6890d9a4ef3SDoug Ambrisko struct { 690a6ba0fd6SDoug Ambrisko /* set TRUE to disable copyBack (0=copback enabled) */ 691a6ba0fd6SDoug Ambrisko uint32_t copyBackDisabled :1; 6920d9a4ef3SDoug Ambrisko uint32_t SMARTerEnabled :1; 6930d9a4ef3SDoug Ambrisko uint32_t prCorrectUnconfiguredAreas :1; 6940d9a4ef3SDoug Ambrisko uint32_t useFdeOnly :1; 6950d9a4ef3SDoug Ambrisko uint32_t disableNCQ :1; 6960d9a4ef3SDoug Ambrisko uint32_t SSDSMARTerEnabled :1; 6970d9a4ef3SDoug Ambrisko uint32_t SSDPatrolReadEnabled :1; 6980d9a4ef3SDoug Ambrisko uint32_t enableSpinDownUnconfigured :1; 6990d9a4ef3SDoug Ambrisko uint32_t autoEnhancedImport :1; 7000d9a4ef3SDoug Ambrisko uint32_t enableSecretKeyControl :1; 7010d9a4ef3SDoug Ambrisko uint32_t disableOnlineCtrlReset :1; 7020d9a4ef3SDoug Ambrisko uint32_t allowBootWithPinnedCache :1; 7030d9a4ef3SDoug Ambrisko uint32_t disableSpinDownHS :1; 7040d9a4ef3SDoug Ambrisko uint32_t enableJBOD :1; 7050d9a4ef3SDoug Ambrisko uint32_t reserved :18; 7060d9a4ef3SDoug Ambrisko } OnOffProperties; 707a6ba0fd6SDoug Ambrisko /* 708a6ba0fd6SDoug Ambrisko * % of source LD to be reserved for auto snapshot in snapshot 709a6ba0fd6SDoug Ambrisko * repository, for metadata and user data: 1=5%, 2=10%, 3=15% and so on. 710a6ba0fd6SDoug Ambrisko */ 711a6ba0fd6SDoug Ambrisko uint8_t autoSnapVDSpace; 712a6ba0fd6SDoug Ambrisko /* 713a6ba0fd6SDoug Ambrisko * Snapshot writeable VIEWs capacity as a % of source LD capacity: 714a6ba0fd6SDoug Ambrisko * 0=READ only, 1=5%, 2=10%, 3=15% and so on. 715a6ba0fd6SDoug Ambrisko */ 716a6ba0fd6SDoug Ambrisko uint8_t viewSpace; 717a6ba0fd6SDoug Ambrisko /* # of idle minutes before device is spun down (0=use FW defaults) */ 718a6ba0fd6SDoug Ambrisko uint16_t spinDownTime; 7190d9a4ef3SDoug Ambrisko uint8_t reserved[24]; 7202e21a3efSScott Long } __packed; 7212e21a3efSScott Long 7222e21a3efSScott Long /* PCI information about the card. */ 7232e21a3efSScott Long struct mfi_info_pci { 7242e21a3efSScott Long uint16_t vendor; 7252e21a3efSScott Long uint16_t device; 7262e21a3efSScott Long uint16_t subvendor; 7272e21a3efSScott Long uint16_t subdevice; 7282e21a3efSScott Long uint8_t reserved[24]; 7292e21a3efSScott Long } __packed; 7302e21a3efSScott Long 7312e21a3efSScott Long /* Host (front end) interface information */ 7322e21a3efSScott Long struct mfi_info_host { 7332e21a3efSScott Long uint8_t type; 7342e21a3efSScott Long #define MFI_INFO_HOST_PCIX 0x01 7352e21a3efSScott Long #define MFI_INFO_HOST_PCIE 0x02 7362e21a3efSScott Long #define MFI_INFO_HOST_ISCSI 0x04 7372e21a3efSScott Long #define MFI_INFO_HOST_SAS3G 0x08 7382e21a3efSScott Long uint8_t reserved[6]; 7392e21a3efSScott Long uint8_t port_count; 7402e21a3efSScott Long uint64_t port_addr[8]; 7412e21a3efSScott Long } __packed; 7422e21a3efSScott Long 7432e21a3efSScott Long /* Device (back end) interface information */ 7442e21a3efSScott Long struct mfi_info_device { 7452e21a3efSScott Long uint8_t type; 7462e21a3efSScott Long #define MFI_INFO_DEV_SPI 0x01 7472e21a3efSScott Long #define MFI_INFO_DEV_SAS3G 0x02 7482e21a3efSScott Long #define MFI_INFO_DEV_SATA1 0x04 7492e21a3efSScott Long #define MFI_INFO_DEV_SATA3G 0x08 7502e21a3efSScott Long uint8_t reserved[6]; 7512e21a3efSScott Long uint8_t port_count; 7522e21a3efSScott Long uint64_t port_addr[8]; 7532e21a3efSScott Long } __packed; 7542e21a3efSScott Long 7552e21a3efSScott Long /* Firmware component information */ 7562e21a3efSScott Long struct mfi_info_component { 7572e21a3efSScott Long char name[8]; 7582e21a3efSScott Long char version[32]; 7592e21a3efSScott Long char build_date[16]; 7602e21a3efSScott Long char build_time[16]; 7612e21a3efSScott Long } __packed; 7622e21a3efSScott Long 763441f6d5dSScott Long /* Controller default settings */ 764441f6d5dSScott Long struct mfi_defaults { 765441f6d5dSScott Long uint64_t sas_addr; 766441f6d5dSScott Long uint8_t phy_polarity; 767441f6d5dSScott Long uint8_t background_rate; 768441f6d5dSScott Long uint8_t stripe_size; 769441f6d5dSScott Long uint8_t flush_time; 770441f6d5dSScott Long uint8_t write_back; 771441f6d5dSScott Long uint8_t read_ahead; 772441f6d5dSScott Long uint8_t cache_when_bbu_bad; 773441f6d5dSScott Long uint8_t cached_io; 774441f6d5dSScott Long uint8_t smart_mode; 775441f6d5dSScott Long uint8_t alarm_disable; 776441f6d5dSScott Long uint8_t coercion; 777441f6d5dSScott Long uint8_t zrc_config; 778441f6d5dSScott Long uint8_t dirty_led_shows_drive_activity; 779441f6d5dSScott Long uint8_t bios_continue_on_error; 780441f6d5dSScott Long uint8_t spindown_mode; 781441f6d5dSScott Long uint8_t allowed_device_types; 782441f6d5dSScott Long uint8_t allow_mix_in_enclosure; 783441f6d5dSScott Long uint8_t allow_mix_in_ld; 784441f6d5dSScott Long uint8_t allow_sata_in_cluster; 785441f6d5dSScott Long uint8_t max_chained_enclosures; 786441f6d5dSScott Long uint8_t disable_ctrl_r; 787441f6d5dSScott Long uint8_t enabel_web_bios; 788441f6d5dSScott Long uint8_t phy_polarity_split; 789441f6d5dSScott Long uint8_t direct_pd_mapping; 790441f6d5dSScott Long uint8_t bios_enumerate_lds; 791441f6d5dSScott Long uint8_t restored_hot_spare_on_insertion; 792441f6d5dSScott Long uint8_t expose_enclosure_devices; 793441f6d5dSScott Long uint8_t maintain_pd_fail_history; 794441f6d5dSScott Long uint8_t resv[28]; 795441f6d5dSScott Long } __packed; 796441f6d5dSScott Long 797441f6d5dSScott Long /* Controller default settings */ 798441f6d5dSScott Long struct mfi_bios_data { 799441f6d5dSScott Long uint16_t boot_target_id; 800441f6d5dSScott Long uint8_t do_not_int_13; 801441f6d5dSScott Long uint8_t continue_on_error; 802441f6d5dSScott Long uint8_t verbose; 803441f6d5dSScott Long uint8_t geometry; 804441f6d5dSScott Long uint8_t expose_all_drives; 805441f6d5dSScott Long uint8_t reserved[56]; 806441f6d5dSScott Long uint8_t check_sum; 807441f6d5dSScott Long } __packed; 8082e21a3efSScott Long 8092e21a3efSScott Long /* SAS (?) controller info, returned from MFI_DCMD_CTRL_GETINFO. */ 8102e21a3efSScott Long struct mfi_ctrl_info { 8112e21a3efSScott Long struct mfi_info_pci pci; 8122e21a3efSScott Long struct mfi_info_host host; 8132e21a3efSScott Long struct mfi_info_device device; 8142e21a3efSScott Long 8152e21a3efSScott Long /* Firmware components that are present and active. */ 8162e21a3efSScott Long uint32_t image_check_word; 8172e21a3efSScott Long uint32_t image_component_count; 8182e21a3efSScott Long struct mfi_info_component image_component[8]; 8192e21a3efSScott Long 8202e21a3efSScott Long /* Firmware components that have been flashed but are inactive */ 8212e21a3efSScott Long uint32_t pending_image_component_count; 8222e21a3efSScott Long struct mfi_info_component pending_image_component[8]; 8232e21a3efSScott Long 8242e21a3efSScott Long uint8_t max_arms; 8252e21a3efSScott Long uint8_t max_spans; 8262e21a3efSScott Long uint8_t max_arrays; 8272e21a3efSScott Long uint8_t max_lds; 8282e21a3efSScott Long char product_name[80]; 8292e21a3efSScott Long char serial_number[32]; 8302e21a3efSScott Long uint32_t hw_present; 8312e21a3efSScott Long #define MFI_INFO_HW_BBU 0x01 8322e21a3efSScott Long #define MFI_INFO_HW_ALARM 0x02 8332e21a3efSScott Long #define MFI_INFO_HW_NVRAM 0x04 8342e21a3efSScott Long #define MFI_INFO_HW_UART 0x08 8352e21a3efSScott Long uint32_t current_fw_time; 8362e21a3efSScott Long uint16_t max_cmds; 8372e21a3efSScott Long uint16_t max_sg_elements; 8382e21a3efSScott Long uint32_t max_request_size; 8392e21a3efSScott Long uint16_t lds_present; 8402e21a3efSScott Long uint16_t lds_degraded; 8412e21a3efSScott Long uint16_t lds_offline; 8422e21a3efSScott Long uint16_t pd_present; 8432e21a3efSScott Long uint16_t pd_disks_present; 8442e21a3efSScott Long uint16_t pd_disks_pred_failure; 8452e21a3efSScott Long uint16_t pd_disks_failed; 8462e21a3efSScott Long uint16_t nvram_size; 8472e21a3efSScott Long uint16_t memory_size; 8482e21a3efSScott Long uint16_t flash_size; 8492e21a3efSScott Long uint16_t ram_correctable_errors; 8502e21a3efSScott Long uint16_t ram_uncorrectable_errors; 8512e21a3efSScott Long uint8_t cluster_allowed; 8522e21a3efSScott Long uint8_t cluster_active; 8532e21a3efSScott Long uint16_t max_strips_per_io; 8542e21a3efSScott Long 8552e21a3efSScott Long uint32_t raid_levels; 8562e21a3efSScott Long #define MFI_INFO_RAID_0 0x01 8572e21a3efSScott Long #define MFI_INFO_RAID_1 0x02 8582e21a3efSScott Long #define MFI_INFO_RAID_5 0x04 8592e21a3efSScott Long #define MFI_INFO_RAID_1E 0x08 8602e21a3efSScott Long #define MFI_INFO_RAID_6 0x10 8612e21a3efSScott Long 8622e21a3efSScott Long uint32_t adapter_ops; 8632e21a3efSScott Long #define MFI_INFO_AOPS_RBLD_RATE 0x0001 8642e21a3efSScott Long #define MFI_INFO_AOPS_CC_RATE 0x0002 8652e21a3efSScott Long #define MFI_INFO_AOPS_BGI_RATE 0x0004 8662e21a3efSScott Long #define MFI_INFO_AOPS_RECON_RATE 0x0008 8672e21a3efSScott Long #define MFI_INFO_AOPS_PATROL_RATE 0x0010 8682e21a3efSScott Long #define MFI_INFO_AOPS_ALARM_CONTROL 0x0020 8692e21a3efSScott Long #define MFI_INFO_AOPS_CLUSTER_SUPPORTED 0x0040 8702e21a3efSScott Long #define MFI_INFO_AOPS_BBU 0x0080 8712e21a3efSScott Long #define MFI_INFO_AOPS_SPANNING_ALLOWED 0x0100 8722e21a3efSScott Long #define MFI_INFO_AOPS_DEDICATED_SPARES 0x0200 8732e21a3efSScott Long #define MFI_INFO_AOPS_REVERTIBLE_SPARES 0x0400 8742e21a3efSScott Long #define MFI_INFO_AOPS_FOREIGN_IMPORT 0x0800 8752e21a3efSScott Long #define MFI_INFO_AOPS_SELF_DIAGNOSTIC 0x1000 8762e21a3efSScott Long #define MFI_INFO_AOPS_MIXED_ARRAY 0x2000 8772e21a3efSScott Long #define MFI_INFO_AOPS_GLOBAL_SPARES 0x4000 8782e21a3efSScott Long 8792e21a3efSScott Long uint32_t ld_ops; 8802e21a3efSScott Long #define MFI_INFO_LDOPS_READ_POLICY 0x01 8812e21a3efSScott Long #define MFI_INFO_LDOPS_WRITE_POLICY 0x02 8822e21a3efSScott Long #define MFI_INFO_LDOPS_IO_POLICY 0x04 8832e21a3efSScott Long #define MFI_INFO_LDOPS_ACCESS_POLICY 0x08 8842e21a3efSScott Long #define MFI_INFO_LDOPS_DISK_CACHE_POLICY 0x10 8852e21a3efSScott Long 8862e21a3efSScott Long struct { 8872e21a3efSScott Long uint8_t min; 8882e21a3efSScott Long uint8_t max; 8892e21a3efSScott Long uint8_t reserved[2]; 8902e21a3efSScott Long } __packed stripe_sz_ops; 8912e21a3efSScott Long 8922e21a3efSScott Long uint32_t pd_ops; 8932e21a3efSScott Long #define MFI_INFO_PDOPS_FORCE_ONLINE 0x01 8942e21a3efSScott Long #define MFI_INFO_PDOPS_FORCE_OFFLINE 0x02 8952e21a3efSScott Long #define MFI_INFO_PDOPS_FORCE_REBUILD 0x04 8962e21a3efSScott Long 8972e21a3efSScott Long uint32_t pd_mix_support; 8982e21a3efSScott Long #define MFI_INFO_PDMIX_SAS 0x01 8992e21a3efSScott Long #define MFI_INFO_PDMIX_SATA 0x02 9002e21a3efSScott Long #define MFI_INFO_PDMIX_ENCL 0x04 9012e21a3efSScott Long #define MFI_INFO_PDMIX_LD 0x08 9022e21a3efSScott Long #define MFI_INFO_PDMIX_SATA_CLUSTER 0x10 9032e21a3efSScott Long 9042e21a3efSScott Long uint8_t ecc_bucket_count; 9052e21a3efSScott Long uint8_t reserved2[11]; 9062e21a3efSScott Long struct mfi_ctrl_props properties; 9072e21a3efSScott Long char package_version[0x60]; 9082e21a3efSScott Long uint8_t pad[0x800 - 0x6a0]; 9092e21a3efSScott Long } __packed; 9102e21a3efSScott Long 911741367d5SDoug Ambrisko /* keep track of an event. */ 912741367d5SDoug Ambrisko union mfi_evt { 913741367d5SDoug Ambrisko struct { 914741367d5SDoug Ambrisko uint16_t locale; 915741367d5SDoug Ambrisko uint8_t reserved; 916aacea6e2SEd Maste int8_t evt_class; 917741367d5SDoug Ambrisko } members; 918741367d5SDoug Ambrisko uint32_t word; 919741367d5SDoug Ambrisko } __packed; 920741367d5SDoug Ambrisko 921741367d5SDoug Ambrisko /* event log state. */ 922741367d5SDoug Ambrisko struct mfi_evt_log_state { 923741367d5SDoug Ambrisko uint32_t newest_seq_num; 924741367d5SDoug Ambrisko uint32_t oldest_seq_num; 925741367d5SDoug Ambrisko uint32_t clear_seq_num; 926741367d5SDoug Ambrisko uint32_t shutdown_seq_num; 927741367d5SDoug Ambrisko uint32_t boot_seq_num; 928741367d5SDoug Ambrisko } __packed; 929741367d5SDoug Ambrisko 930741367d5SDoug Ambrisko struct mfi_progress { 931741367d5SDoug Ambrisko uint16_t progress; 932741367d5SDoug Ambrisko uint16_t elapsed_seconds; 933741367d5SDoug Ambrisko } __packed; 934741367d5SDoug Ambrisko 935741367d5SDoug Ambrisko struct mfi_evt_ld { 936741367d5SDoug Ambrisko uint16_t target_id; 937741367d5SDoug Ambrisko uint8_t ld_index; 938741367d5SDoug Ambrisko uint8_t reserved; 939741367d5SDoug Ambrisko } __packed; 940741367d5SDoug Ambrisko 941741367d5SDoug Ambrisko struct mfi_evt_pd { 942741367d5SDoug Ambrisko uint16_t device_id; 943741367d5SDoug Ambrisko uint8_t enclosure_index; 944741367d5SDoug Ambrisko uint8_t slot_number; 945741367d5SDoug Ambrisko } __packed; 946741367d5SDoug Ambrisko 947741367d5SDoug Ambrisko /* SAS (?) event detail, returned from MFI_DCMD_CTRL_EVENT_WAIT. */ 948741367d5SDoug Ambrisko struct mfi_evt_detail { 949741367d5SDoug Ambrisko uint32_t seq; 950741367d5SDoug Ambrisko uint32_t time; 951741367d5SDoug Ambrisko uint32_t code; 952aacea6e2SEd Maste union mfi_evt evt_class; 953741367d5SDoug Ambrisko uint8_t arg_type; 954741367d5SDoug Ambrisko uint8_t reserved1[15]; 955741367d5SDoug Ambrisko 956741367d5SDoug Ambrisko union { 957741367d5SDoug Ambrisko struct { 958741367d5SDoug Ambrisko struct mfi_evt_pd pd; 959741367d5SDoug Ambrisko uint8_t cdb_len; 960741367d5SDoug Ambrisko uint8_t sense_len; 961741367d5SDoug Ambrisko uint8_t reserved[2]; 962741367d5SDoug Ambrisko uint8_t cdb[16]; 963741367d5SDoug Ambrisko uint8_t sense[64]; 964741367d5SDoug Ambrisko } cdb_sense; 965741367d5SDoug Ambrisko 966741367d5SDoug Ambrisko struct mfi_evt_ld ld; 967741367d5SDoug Ambrisko 968741367d5SDoug Ambrisko struct { 969741367d5SDoug Ambrisko struct mfi_evt_ld ld; 970741367d5SDoug Ambrisko uint64_t count; 971741367d5SDoug Ambrisko } ld_count; 972741367d5SDoug Ambrisko 973741367d5SDoug Ambrisko struct { 974741367d5SDoug Ambrisko uint64_t lba; 975741367d5SDoug Ambrisko struct mfi_evt_ld ld; 976741367d5SDoug Ambrisko } ld_lba; 977741367d5SDoug Ambrisko 978741367d5SDoug Ambrisko struct { 979741367d5SDoug Ambrisko struct mfi_evt_ld ld; 980741367d5SDoug Ambrisko uint32_t pre_owner; 981741367d5SDoug Ambrisko uint32_t new_owner; 982741367d5SDoug Ambrisko } ld_owner; 983741367d5SDoug Ambrisko 984741367d5SDoug Ambrisko struct { 985741367d5SDoug Ambrisko uint64_t ld_lba; 986741367d5SDoug Ambrisko uint64_t pd_lba; 987741367d5SDoug Ambrisko struct mfi_evt_ld ld; 988741367d5SDoug Ambrisko struct mfi_evt_pd pd; 989741367d5SDoug Ambrisko } ld_lba_pd_lba; 990741367d5SDoug Ambrisko 991741367d5SDoug Ambrisko struct { 992741367d5SDoug Ambrisko struct mfi_evt_ld ld; 993741367d5SDoug Ambrisko struct mfi_progress prog; 994741367d5SDoug Ambrisko } ld_prog; 995741367d5SDoug Ambrisko 996741367d5SDoug Ambrisko struct { 997741367d5SDoug Ambrisko struct mfi_evt_ld ld; 998741367d5SDoug Ambrisko uint32_t prev_state; 999741367d5SDoug Ambrisko uint32_t new_state; 1000741367d5SDoug Ambrisko } ld_state; 1001741367d5SDoug Ambrisko 1002741367d5SDoug Ambrisko struct { 1003741367d5SDoug Ambrisko uint64_t strip; 1004741367d5SDoug Ambrisko struct mfi_evt_ld ld; 1005741367d5SDoug Ambrisko } ld_strip; 1006741367d5SDoug Ambrisko 1007741367d5SDoug Ambrisko struct mfi_evt_pd pd; 1008741367d5SDoug Ambrisko 1009741367d5SDoug Ambrisko struct { 1010741367d5SDoug Ambrisko struct mfi_evt_pd pd; 1011741367d5SDoug Ambrisko uint32_t err; 1012741367d5SDoug Ambrisko } pd_err; 1013741367d5SDoug Ambrisko 1014741367d5SDoug Ambrisko struct { 1015741367d5SDoug Ambrisko uint64_t lba; 1016741367d5SDoug Ambrisko struct mfi_evt_pd pd; 1017741367d5SDoug Ambrisko } pd_lba; 1018741367d5SDoug Ambrisko 1019741367d5SDoug Ambrisko struct { 1020741367d5SDoug Ambrisko uint64_t lba; 1021741367d5SDoug Ambrisko struct mfi_evt_pd pd; 1022741367d5SDoug Ambrisko struct mfi_evt_ld ld; 1023741367d5SDoug Ambrisko } pd_lba_ld; 1024741367d5SDoug Ambrisko 1025741367d5SDoug Ambrisko struct { 1026741367d5SDoug Ambrisko struct mfi_evt_pd pd; 1027741367d5SDoug Ambrisko struct mfi_progress prog; 1028741367d5SDoug Ambrisko } pd_prog; 1029741367d5SDoug Ambrisko 1030741367d5SDoug Ambrisko struct { 1031*66efdefeSWHR struct mfi_evt_pd pd; 1032741367d5SDoug Ambrisko uint32_t prev_state; 1033741367d5SDoug Ambrisko uint32_t new_state; 1034741367d5SDoug Ambrisko } pd_state; 1035741367d5SDoug Ambrisko 1036741367d5SDoug Ambrisko struct { 1037741367d5SDoug Ambrisko uint16_t venderId; 1038741367d5SDoug Ambrisko uint16_t deviceId; 1039741367d5SDoug Ambrisko uint16_t subVenderId; 1040741367d5SDoug Ambrisko uint16_t subDeviceId; 1041741367d5SDoug Ambrisko } pci; 1042741367d5SDoug Ambrisko 1043741367d5SDoug Ambrisko uint32_t rate; 1044741367d5SDoug Ambrisko 1045741367d5SDoug Ambrisko char str[96]; 1046741367d5SDoug Ambrisko 1047741367d5SDoug Ambrisko struct { 1048741367d5SDoug Ambrisko uint32_t rtc; 1049741367d5SDoug Ambrisko uint16_t elapsedSeconds; 1050741367d5SDoug Ambrisko } time; 1051741367d5SDoug Ambrisko 1052741367d5SDoug Ambrisko struct { 1053741367d5SDoug Ambrisko uint32_t ecar; 1054741367d5SDoug Ambrisko uint32_t elog; 1055741367d5SDoug Ambrisko char str[64]; 1056741367d5SDoug Ambrisko } ecc; 1057741367d5SDoug Ambrisko 1058741367d5SDoug Ambrisko uint8_t b[96]; 1059741367d5SDoug Ambrisko uint16_t s[48]; 1060741367d5SDoug Ambrisko uint32_t w[24]; 1061741367d5SDoug Ambrisko uint64_t d[12]; 1062741367d5SDoug Ambrisko } args; 1063741367d5SDoug Ambrisko 1064741367d5SDoug Ambrisko char description[128]; 1065741367d5SDoug Ambrisko } __packed; 1066741367d5SDoug Ambrisko 106747b470b9SDoug Ambrisko struct mfi_evt_list { 106847b470b9SDoug Ambrisko uint32_t count; 106947b470b9SDoug Ambrisko uint32_t reserved; 107047b470b9SDoug Ambrisko struct mfi_evt_detail event[1]; 1071741367d5SDoug Ambrisko } __packed; 1072741367d5SDoug Ambrisko 1073441f6d5dSScott Long union mfi_pd_ref { 1074441f6d5dSScott Long struct { 1075441f6d5dSScott Long uint16_t device_id; 1076441f6d5dSScott Long uint16_t seq_num; 1077441f6d5dSScott Long } v; 1078441f6d5dSScott Long uint32_t ref; 1079441f6d5dSScott Long } __packed; 1080441f6d5dSScott Long 1081441f6d5dSScott Long union mfi_pd_ddf_type { 1082441f6d5dSScott Long struct { 1083441f6d5dSScott Long union { 1084441f6d5dSScott Long struct { 1085441f6d5dSScott Long uint16_t forced_pd_guid : 1; 1086441f6d5dSScott Long uint16_t in_vd : 1; 1087441f6d5dSScott Long uint16_t is_global_spare : 1; 1088441f6d5dSScott Long uint16_t is_spare : 1; 1089441f6d5dSScott Long uint16_t is_foreign : 1; 1090441f6d5dSScott Long uint16_t reserved : 7; 1091441f6d5dSScott Long uint16_t intf : 4; 1092441f6d5dSScott Long } pd_type; 1093441f6d5dSScott Long uint16_t type; 1094441f6d5dSScott Long } v; 1095441f6d5dSScott Long uint16_t reserved; 1096441f6d5dSScott Long } ddf; 1097441f6d5dSScott Long struct { 1098441f6d5dSScott Long uint32_t reserved; 1099441f6d5dSScott Long } non_disk; 1100441f6d5dSScott Long uint32_t type; 1101441f6d5dSScott Long } __packed; 1102441f6d5dSScott Long 1103441f6d5dSScott Long struct mfi_pd_progress { 1104763fae79SScott Long uint32_t active; 1105763fae79SScott Long #define MFI_PD_PROGRESS_REBUILD (1<<0) 1106763fae79SScott Long #define MFI_PD_PROGRESS_PATROL (1<<1) 1107763fae79SScott Long #define MFI_PD_PROGRESS_CLEAR (1<<2) 1108441f6d5dSScott Long struct mfi_progress rbld; 1109441f6d5dSScott Long struct mfi_progress patrol; 1110441f6d5dSScott Long struct mfi_progress clear; 1111441f6d5dSScott Long struct mfi_progress reserved[4]; 1112441f6d5dSScott Long } __packed; 1113441f6d5dSScott Long 1114441f6d5dSScott Long struct mfi_pd_info { 1115441f6d5dSScott Long union mfi_pd_ref ref; 1116441f6d5dSScott Long uint8_t inquiry_data[96]; 1117441f6d5dSScott Long uint8_t vpd_page83[64]; 1118441f6d5dSScott Long uint8_t not_supported; 1119441f6d5dSScott Long uint8_t scsi_dev_type; 1120441f6d5dSScott Long uint8_t connected_port_bitmap; 1121441f6d5dSScott Long uint8_t device_speed; 1122441f6d5dSScott Long uint32_t media_err_count; 1123441f6d5dSScott Long uint32_t other_err_count; 1124441f6d5dSScott Long uint32_t pred_fail_count; 1125441f6d5dSScott Long uint32_t last_pred_fail_event_seq_num; 1126763fae79SScott Long uint16_t fw_state; /* MFI_PD_STATE_* */ 1127763fae79SScott Long uint8_t disabled_for_removal; 1128441f6d5dSScott Long uint8_t link_speed; 1129441f6d5dSScott Long union mfi_pd_ddf_type state; 1130441f6d5dSScott Long struct { 1131441f6d5dSScott Long uint8_t count; 1132441f6d5dSScott Long uint8_t is_path_broken; 1133441f6d5dSScott Long uint8_t reserved[6]; 1134441f6d5dSScott Long uint64_t sas_addr[4]; 1135441f6d5dSScott Long } path_info; 1136441f6d5dSScott Long uint64_t raw_size; 1137441f6d5dSScott Long uint64_t non_coerced_size; 1138441f6d5dSScott Long uint64_t coerced_size; 1139441f6d5dSScott Long uint16_t encl_device_id; 1140441f6d5dSScott Long uint8_t encl_index; 1141441f6d5dSScott Long uint8_t slot_number; 1142441f6d5dSScott Long struct mfi_pd_progress prog_info; 1143441f6d5dSScott Long uint8_t bad_block_table_full; 1144441f6d5dSScott Long uint8_t unusable_in_current_config; 1145441f6d5dSScott Long uint8_t vpd_page83_ext[64]; 1146441f6d5dSScott Long uint8_t reserved[512-358]; 1147441f6d5dSScott Long } __packed; 1148441f6d5dSScott Long 1149441f6d5dSScott Long struct mfi_pd_address { 1150441f6d5dSScott Long uint16_t device_id; 1151441f6d5dSScott Long uint16_t encl_device_id; 1152441f6d5dSScott Long uint8_t encl_index; 1153441f6d5dSScott Long uint8_t slot_number; 1154763fae79SScott Long uint8_t scsi_dev_type; /* 0 = disk */ 1155441f6d5dSScott Long uint8_t connect_port_bitmap; 1156441f6d5dSScott Long uint64_t sas_addr[2]; 1157441f6d5dSScott Long } __packed; 1158441f6d5dSScott Long 11590d9a4ef3SDoug Ambrisko #define MAX_SYS_PDS 240 1160441f6d5dSScott Long struct mfi_pd_list { 1161441f6d5dSScott Long uint32_t size; 1162441f6d5dSScott Long uint32_t count; 11630d9a4ef3SDoug Ambrisko struct mfi_pd_address addr[MAX_SYS_PDS]; 1164441f6d5dSScott Long } __packed; 1165441f6d5dSScott Long 1166763fae79SScott Long enum mfi_pd_state { 1167763fae79SScott Long MFI_PD_STATE_UNCONFIGURED_GOOD = 0x00, 1168763fae79SScott Long MFI_PD_STATE_UNCONFIGURED_BAD = 0x01, 1169763fae79SScott Long MFI_PD_STATE_HOT_SPARE = 0x02, 1170763fae79SScott Long MFI_PD_STATE_OFFLINE = 0x10, 1171763fae79SScott Long MFI_PD_STATE_FAILED = 0x11, 1172763fae79SScott Long MFI_PD_STATE_REBUILD = 0x14, 1173d63e9da3SSergey Kandaurov MFI_PD_STATE_ONLINE = 0x18, 1174d63e9da3SSergey Kandaurov MFI_PD_STATE_COPYBACK = 0x20, 1175d63e9da3SSergey Kandaurov MFI_PD_STATE_SYSTEM = 0x40 1176763fae79SScott Long }; 1177763fae79SScott Long 1178a6ba0fd6SDoug Ambrisko /* 1179a6ba0fd6SDoug Ambrisko * "SYSTEM" disk appears to be "JBOD" support from the RAID controller. 1180a6ba0fd6SDoug Ambrisko * Adding a #define to denote this. 1181a6ba0fd6SDoug Ambrisko */ 1182a6ba0fd6SDoug Ambrisko #define MFI_PD_STATE_JBOD MFI_PD_STATE_SYSTEM 1183a6ba0fd6SDoug Ambrisko 1184441f6d5dSScott Long union mfi_ld_ref { 1185441f6d5dSScott Long struct { 1186c0b332d1SPaul Saab uint8_t target_id; 1187c0b332d1SPaul Saab uint8_t reserved; 1188c0b332d1SPaul Saab uint16_t seq; 1189441f6d5dSScott Long } v; 1190441f6d5dSScott Long uint32_t ref; 1191c0b332d1SPaul Saab } __packed; 1192c0b332d1SPaul Saab 1193c0b332d1SPaul Saab struct mfi_ld_list { 1194c0b332d1SPaul Saab uint32_t ld_count; 1195c0b332d1SPaul Saab uint32_t reserved1; 1196c0b332d1SPaul Saab struct { 1197441f6d5dSScott Long union mfi_ld_ref ld; 1198c0b332d1SPaul Saab uint8_t state; 1199c0b332d1SPaul Saab uint8_t reserved2[3]; 1200c0b332d1SPaul Saab uint64_t size; 1201c0b332d1SPaul Saab } ld_list[MFI_MAX_LD]; 1202c0b332d1SPaul Saab } __packed; 1203c0b332d1SPaul Saab 1204c0b332d1SPaul Saab enum mfi_ld_access { 1205c0b332d1SPaul Saab MFI_LD_ACCESS_RW = 0, 1206c0b332d1SPaul Saab MFI_LD_ACCSSS_RO = 2, 1207c0b332d1SPaul Saab MFI_LD_ACCESS_BLOCKED = 3, 1208c0b332d1SPaul Saab }; 1209c0b332d1SPaul Saab #define MFI_LD_ACCESS_MASK 3 1210c0b332d1SPaul Saab 1211c0b332d1SPaul Saab enum mfi_ld_state { 1212c0b332d1SPaul Saab MFI_LD_STATE_OFFLINE = 0, 1213c0b332d1SPaul Saab MFI_LD_STATE_PARTIALLY_DEGRADED = 1, 1214c0b332d1SPaul Saab MFI_LD_STATE_DEGRADED = 2, 1215c0b332d1SPaul Saab MFI_LD_STATE_OPTIMAL = 3 1216c0b332d1SPaul Saab }; 1217c0b332d1SPaul Saab 1218c0b332d1SPaul Saab struct mfi_ld_props { 1219441f6d5dSScott Long union mfi_ld_ref ld; 1220c0b332d1SPaul Saab char name[16]; 1221c0b332d1SPaul Saab uint8_t default_cache_policy; 1222c0b332d1SPaul Saab uint8_t access_policy; 1223c0b332d1SPaul Saab uint8_t disk_cache_policy; 1224c0b332d1SPaul Saab uint8_t current_cache_policy; 1225c0b332d1SPaul Saab uint8_t no_bgi; 1226c0b332d1SPaul Saab uint8_t reserved[7]; 1227c0b332d1SPaul Saab } __packed; 1228c0b332d1SPaul Saab 1229c0b332d1SPaul Saab struct mfi_ld_params { 1230c0b332d1SPaul Saab uint8_t primary_raid_level; 1231c0b332d1SPaul Saab uint8_t raid_level_qualifier; 1232c0b332d1SPaul Saab uint8_t secondary_raid_level; 1233c0b332d1SPaul Saab uint8_t stripe_size; 1234c0b332d1SPaul Saab uint8_t num_drives; 1235c0b332d1SPaul Saab uint8_t span_depth; 1236c0b332d1SPaul Saab uint8_t state; 1237c0b332d1SPaul Saab uint8_t init_state; 1238763fae79SScott Long #define MFI_LD_PARAMS_INIT_NO 0 1239763fae79SScott Long #define MFI_LD_PARAMS_INIT_QUICK 1 1240763fae79SScott Long #define MFI_LD_PARAMS_INIT_FULL 2 1241c0b332d1SPaul Saab uint8_t is_consistent; 12420d9a4ef3SDoug Ambrisko uint8_t reserved1[6]; 12430d9a4ef3SDoug Ambrisko uint8_t isSSCD; 12440d9a4ef3SDoug Ambrisko uint8_t reserved2[16]; 1245c0b332d1SPaul Saab } __packed; 1246c0b332d1SPaul Saab 1247c0b332d1SPaul Saab struct mfi_ld_progress { 1248c0b332d1SPaul Saab uint32_t active; 1249c0b332d1SPaul Saab #define MFI_LD_PROGRESS_CC (1<<0) 1250c0b332d1SPaul Saab #define MFI_LD_PROGRESS_BGI (1<<1) 1251c0b332d1SPaul Saab #define MFI_LD_PROGRESS_FGI (1<<2) 1252763fae79SScott Long #define MFI_LD_PROGRESS_RECON (1<<3) 1253c0b332d1SPaul Saab struct mfi_progress cc; 1254c0b332d1SPaul Saab struct mfi_progress bgi; 1255c0b332d1SPaul Saab struct mfi_progress fgi; 1256c0b332d1SPaul Saab struct mfi_progress recon; 1257c0b332d1SPaul Saab struct mfi_progress reserved[4]; 1258c0b332d1SPaul Saab } __packed; 1259c0b332d1SPaul Saab 1260c0b332d1SPaul Saab struct mfi_span { 1261c0b332d1SPaul Saab uint64_t start_block; 1262c0b332d1SPaul Saab uint64_t num_blocks; 1263c0b332d1SPaul Saab uint16_t array_ref; 1264c0b332d1SPaul Saab uint8_t reserved[6]; 1265c0b332d1SPaul Saab } __packed; 1266c0b332d1SPaul Saab 1267c0b332d1SPaul Saab #define MFI_MAX_SPAN_DEPTH 8 1268c0b332d1SPaul Saab struct mfi_ld_config { 1269c0b332d1SPaul Saab struct mfi_ld_props properties; 1270c0b332d1SPaul Saab struct mfi_ld_params params; 1271c0b332d1SPaul Saab struct mfi_span span[MFI_MAX_SPAN_DEPTH]; 1272c0b332d1SPaul Saab } __packed; 1273c0b332d1SPaul Saab 1274c0b332d1SPaul Saab struct mfi_ld_info { 1275c0b332d1SPaul Saab struct mfi_ld_config ld_config; 1276c0b332d1SPaul Saab uint64_t size; 1277c0b332d1SPaul Saab struct mfi_ld_progress progress; 1278c0b332d1SPaul Saab uint16_t cluster_owner; 1279c0b332d1SPaul Saab uint8_t reconstruct_active; 1280c0b332d1SPaul Saab uint8_t reserved1[1]; 1281c0b332d1SPaul Saab uint8_t vpd_page83[64]; 1282c0b332d1SPaul Saab uint8_t reserved2[16]; 1283c0b332d1SPaul Saab } __packed; 1284c0b332d1SPaul Saab 1285a6ba0fd6SDoug Ambrisko #define MFI_MAX_ARRAYS 16 1286441f6d5dSScott Long struct mfi_spare { 1287441f6d5dSScott Long union mfi_pd_ref ref; 1288763fae79SScott Long uint8_t spare_type; 1289763fae79SScott Long #define MFI_SPARE_DEDICATED (1 << 0) 1290763fae79SScott Long #define MFI_SPARE_REVERTIBLE (1 << 1) 1291763fae79SScott Long #define MFI_SPARE_ENCL_AFFINITY (1 << 2) 1292441f6d5dSScott Long uint8_t reserved[2]; 1293441f6d5dSScott Long uint8_t array_count; 1294a6ba0fd6SDoug Ambrisko uint16_t array_ref[MFI_MAX_ARRAYS]; 1295441f6d5dSScott Long } __packed; 1296441f6d5dSScott Long 1297a6ba0fd6SDoug Ambrisko #define MFI_MAX_ROW_SIZE 32 1298441f6d5dSScott Long struct mfi_array { 1299441f6d5dSScott Long uint64_t size; 1300441f6d5dSScott Long uint8_t num_drives; 1301441f6d5dSScott Long uint8_t reserved; 1302441f6d5dSScott Long uint16_t array_ref; 1303441f6d5dSScott Long uint8_t pad[20]; 1304441f6d5dSScott Long struct { 1305763fae79SScott Long union mfi_pd_ref ref; /* 0xffff == missing drive */ 1306763fae79SScott Long uint16_t fw_state; /* MFI_PD_STATE_* */ 1307441f6d5dSScott Long struct { 1308441f6d5dSScott Long uint8_t pd; 1309441f6d5dSScott Long uint8_t slot; 1310441f6d5dSScott Long } encl; 1311a6ba0fd6SDoug Ambrisko } pd[MFI_MAX_ROW_SIZE]; 1312441f6d5dSScott Long } __packed; 1313441f6d5dSScott Long 1314441f6d5dSScott Long struct mfi_config_data { 1315441f6d5dSScott Long uint32_t size; 1316441f6d5dSScott Long uint16_t array_count; 1317441f6d5dSScott Long uint16_t array_size; 1318441f6d5dSScott Long uint16_t log_drv_count; 1319441f6d5dSScott Long uint16_t log_drv_size; 1320441f6d5dSScott Long uint16_t spares_count; 1321441f6d5dSScott Long uint16_t spares_size; 1322441f6d5dSScott Long uint8_t reserved[16]; 1323763fae79SScott Long struct mfi_array array[0]; 1324763fae79SScott Long struct mfi_ld_config ld[0]; 1325763fae79SScott Long struct mfi_spare spare[0]; 1326441f6d5dSScott Long } __packed; 1327441f6d5dSScott Long 1328763fae79SScott Long struct mfi_bbu_capacity_info { 1329763fae79SScott Long uint16_t relative_charge; 1330763fae79SScott Long uint16_t absolute_charge; 1331763fae79SScott Long uint16_t remaining_capacity; 1332763fae79SScott Long uint16_t full_charge_capacity; 1333763fae79SScott Long uint16_t run_time_to_empty; 1334763fae79SScott Long uint16_t average_time_to_empty; 1335763fae79SScott Long uint16_t average_time_to_full; 1336763fae79SScott Long uint16_t cycle_count; 1337763fae79SScott Long uint16_t max_error; 1338763fae79SScott Long uint16_t remaining_capacity_alarm; 1339763fae79SScott Long uint16_t remaining_time_alarm; 1340763fae79SScott Long uint8_t reserved[26]; 1341763fae79SScott Long } __packed; 1342763fae79SScott Long 1343763fae79SScott Long struct mfi_bbu_design_info { 1344763fae79SScott Long uint32_t mfg_date; 1345763fae79SScott Long uint16_t design_capacity; 1346763fae79SScott Long uint16_t design_voltage; 1347763fae79SScott Long uint16_t spec_info; 1348763fae79SScott Long uint16_t serial_number; 1349763fae79SScott Long uint16_t pack_stat_config; 1350763fae79SScott Long uint8_t mfg_name[12]; 1351763fae79SScott Long uint8_t device_name[8]; 1352763fae79SScott Long uint8_t device_chemistry[8]; 1353763fae79SScott Long uint8_t mfg_data[8]; 1354763fae79SScott Long uint8_t reserved[17]; 1355763fae79SScott Long } __packed; 1356763fae79SScott Long 1357763fae79SScott Long struct mfi_ibbu_state { 1358763fae79SScott Long uint16_t gas_guage_status; 1359763fae79SScott Long uint16_t relative_charge; 1360763fae79SScott Long uint16_t charger_system_state; 1361763fae79SScott Long uint16_t charger_system_ctrl; 1362763fae79SScott Long uint16_t charging_current; 1363763fae79SScott Long uint16_t absolute_charge; 1364763fae79SScott Long uint16_t max_error; 1365763fae79SScott Long uint8_t reserved[18]; 1366763fae79SScott Long } __packed; 1367763fae79SScott Long 1368763fae79SScott Long struct mfi_bbu_state { 1369763fae79SScott Long uint16_t gas_guage_status; 1370763fae79SScott Long uint16_t relative_charge; 1371763fae79SScott Long uint16_t charger_status; 1372763fae79SScott Long uint16_t remaining_capacity; 1373763fae79SScott Long uint16_t full_charge_capacity; 1374763fae79SScott Long uint8_t is_SOH_good; 1375763fae79SScott Long uint8_t reserved[21]; 1376763fae79SScott Long } __packed; 1377763fae79SScott Long 1378dee3e845SMark Johnston struct mfi_bbu_properties { 1379dee3e845SMark Johnston uint32_t auto_learn_period; 1380dee3e845SMark Johnston uint32_t next_learn_time; 1381dee3e845SMark Johnston uint8_t learn_delay_interval; 1382dee3e845SMark Johnston uint8_t auto_learn_mode; 1383dee3e845SMark Johnston uint8_t bbu_mode; 1384dee3e845SMark Johnston uint8_t reserved[21]; 1385dee3e845SMark Johnston } __packed; 1386dee3e845SMark Johnston 1387763fae79SScott Long union mfi_bbu_status_detail { 1388763fae79SScott Long struct mfi_ibbu_state ibbu; 1389763fae79SScott Long struct mfi_bbu_state bbu; 1390763fae79SScott Long }; 1391763fae79SScott Long 1392763fae79SScott Long struct mfi_bbu_status { 1393763fae79SScott Long uint8_t battery_type; 1394763fae79SScott Long #define MFI_BBU_TYPE_NONE 0 1395763fae79SScott Long #define MFI_BBU_TYPE_IBBU 1 1396763fae79SScott Long #define MFI_BBU_TYPE_BBU 2 1397763fae79SScott Long uint8_t reserved; 1398763fae79SScott Long uint16_t voltage; 1399763fae79SScott Long int16_t current; 1400763fae79SScott Long uint16_t temperature; 1401763fae79SScott Long uint32_t fw_status; 1402763fae79SScott Long #define MFI_BBU_STATE_PACK_MISSING (1 << 0) 1403763fae79SScott Long #define MFI_BBU_STATE_VOLTAGE_LOW (1 << 1) 1404763fae79SScott Long #define MFI_BBU_STATE_TEMPERATURE_HIGH (1 << 2) 1405c1def54fSSean Bruno #define MFI_BBU_STATE_CHARGE_ACTIVE (1 << 3) 1406c1def54fSSean Bruno #define MFI_BBU_STATE_DISCHARGE_ACTIVE (1 << 4) 1407c1def54fSSean Bruno #define MFI_BBU_STATE_LEARN_CYC_REQ (1 << 5) 1408c1def54fSSean Bruno #define MFI_BBU_STATE_LEARN_CYC_ACTIVE (1 << 6) 1409c1def54fSSean Bruno #define MFI_BBU_STATE_LEARN_CYC_FAIL (1 << 7) 1410c1def54fSSean Bruno #define MFI_BBU_STATE_LEARN_CYC_TIMEOUT (1 << 8) 1411c1def54fSSean Bruno #define MFI_BBU_STATE_I2C_ERR_DETECT (1 << 9) 1412763fae79SScott Long uint8_t pad[20]; 1413763fae79SScott Long union mfi_bbu_status_detail detail; 1414763fae79SScott Long } __packed; 1415763fae79SScott Long 1416763fae79SScott Long enum mfi_pr_state { 1417763fae79SScott Long MFI_PR_STATE_STOPPED = 0, 1418763fae79SScott Long MFI_PR_STATE_READY = 1, 1419763fae79SScott Long MFI_PR_STATE_ACTIVE = 2, 1420763fae79SScott Long MFI_PR_STATE_ABORTED = 0xff 1421763fae79SScott Long }; 1422763fae79SScott Long 1423763fae79SScott Long struct mfi_pr_status { 1424763fae79SScott Long uint32_t num_iteration; 1425763fae79SScott Long uint8_t state; 1426763fae79SScott Long uint8_t num_pd_done; 1427763fae79SScott Long uint8_t reserved[10]; 1428763fae79SScott Long }; 1429763fae79SScott Long 1430763fae79SScott Long enum mfi_pr_opmode { 1431763fae79SScott Long MFI_PR_OPMODE_AUTO = 0, 1432763fae79SScott Long MFI_PR_OPMODE_MANUAL = 1, 1433763fae79SScott Long MFI_PR_OPMODE_DISABLED = 2 1434763fae79SScott Long }; 1435763fae79SScott Long 1436763fae79SScott Long struct mfi_pr_properties { 1437763fae79SScott Long uint8_t op_mode; 1438763fae79SScott Long uint8_t max_pd; 1439763fae79SScott Long uint8_t reserved; 1440763fae79SScott Long uint8_t exclude_ld_count; 1441763fae79SScott Long uint16_t excluded_ld[MFI_MAX_LD]; 1442763fae79SScott Long uint8_t cur_pd_map[MFI_MAX_PD / 8]; 1443763fae79SScott Long uint8_t last_pd_map[MFI_MAX_PD / 8]; 1444763fae79SScott Long uint32_t next_exec; 1445763fae79SScott Long uint32_t exec_freq; 1446763fae79SScott Long uint32_t clear_freq; 1447763fae79SScott Long }; 1448763fae79SScott Long 14490d9a4ef3SDoug Ambrisko /* ThunderBolt support */ 14500d9a4ef3SDoug Ambrisko 14510d9a4ef3SDoug Ambrisko /* 14520d9a4ef3SDoug Ambrisko * Raid Context structure which describes MegaRAID specific IO Paramenters 14530d9a4ef3SDoug Ambrisko * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames 14540d9a4ef3SDoug Ambrisko */ 14550d9a4ef3SDoug Ambrisko typedef struct _MPI2_SCSI_IO_VENDOR_UNIQUE { 1456a6ba0fd6SDoug Ambrisko uint16_t resvd0; /* 0x00 - 0x01 */ 1457a6ba0fd6SDoug Ambrisko uint16_t timeoutValue; /* 0x02 - 0x03 */ 14580d9a4ef3SDoug Ambrisko uint8_t regLockFlags; 14590d9a4ef3SDoug Ambrisko uint8_t armId; 1460a6ba0fd6SDoug Ambrisko uint16_t TargetID; /* 0x06 - 0x07 */ 14610d9a4ef3SDoug Ambrisko 1462a6ba0fd6SDoug Ambrisko uint64_t RegLockLBA; /* 0x08 - 0x0F */ 14630d9a4ef3SDoug Ambrisko 1464a6ba0fd6SDoug Ambrisko uint32_t RegLockLength; /* 0x10 - 0x13 */ 14650d9a4ef3SDoug Ambrisko 1466a6ba0fd6SDoug Ambrisko uint16_t SMID; /* 0x14 - 0x15 nextLMId */ 1467a6ba0fd6SDoug Ambrisko uint8_t exStatus; /* 0x16 */ 1468a6ba0fd6SDoug Ambrisko uint8_t Status; /* 0x17 status */ 14690d9a4ef3SDoug Ambrisko 1470a6ba0fd6SDoug Ambrisko uint8_t RAIDFlags; /* 0x18 */ 1471a6ba0fd6SDoug Ambrisko uint8_t numSGE; /* 0x19 numSge */ 1472a6ba0fd6SDoug Ambrisko uint16_t configSeqNum; /* 0x1A - 0x1B */ 1473a6ba0fd6SDoug Ambrisko uint8_t spanArm; /* 0x1C */ 1474a6ba0fd6SDoug Ambrisko uint8_t resvd2[3]; /* 0x1D - 0x1F */ 14750d9a4ef3SDoug Ambrisko } MPI2_SCSI_IO_VENDOR_UNIQUE, MPI25_SCSI_IO_VENDOR_UNIQUE; 14760d9a4ef3SDoug Ambrisko 14770d9a4ef3SDoug Ambrisko /***************************************************************************** 14780d9a4ef3SDoug Ambrisko * 14790d9a4ef3SDoug Ambrisko * Message Functions 14800d9a4ef3SDoug Ambrisko * 14810d9a4ef3SDoug Ambrisko *****************************************************************************/ 14820d9a4ef3SDoug Ambrisko 14830d9a4ef3SDoug Ambrisko #define NA_MPI2_FUNCTION_SCSI_IO_REQUEST (0x00) /* SCSI IO */ 14840d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_SCSI_TASK_MGMT (0x01) /* SCSI Task Management */ 14850d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_IOC_INIT (0x02) /* IOC Init */ 14860d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_IOC_FACTS (0x03) /* IOC Facts */ 14870d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_CONFIG (0x04) /* Configuration */ 14880d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_PORT_FACTS (0x05) /* Port Facts */ 14890d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_PORT_ENABLE (0x06) /* Port Enable */ 14900d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_EVENT_NOTIFICATION (0x07) /* Event Notification */ 14910d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_EVENT_ACK (0x08) /* Event Acknowledge */ 14920d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_FW_DOWNLOAD (0x09) /* FW Download */ 14930d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_TARGET_ASSIST (0x0B) /* Target Assist */ 14940d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_TARGET_STATUS_SEND (0x0C) /* Target Status Send */ 14950d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_TARGET_MODE_ABORT (0x0D) /* Target Mode Abort */ 14960d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_FW_UPLOAD (0x12) /* FW Upload */ 14970d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_RAID_ACTION (0x15) /* RAID Action */ 14980d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH (0x16) /* SCSI IO RAID Passthrough */ 14990d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_TOOLBOX (0x17) /* Toolbox */ 15000d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_SCSI_ENCLOSURE_PROCESSOR (0x18) /* SCSI Enclosure Processor */ 15010d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_SMP_PASSTHROUGH (0x1A) /* SMP Passthrough */ 15020d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_SAS_IO_UNIT_CONTROL (0x1B) /* SAS IO Unit Control */ 15030d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_SATA_PASSTHROUGH (0x1C) /* SATA Passthrough */ 15040d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_DIAG_BUFFER_POST (0x1D) /* Diagnostic Buffer Post */ 15050d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_DIAG_RELEASE (0x1E) /* Diagnostic Release */ 15060d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_TARGET_CMD_BUF_BASE_POST (0x24) /* Target Command Buffer Post Base */ 15070d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_TARGET_CMD_BUF_LIST_POST (0x25) /* Target Command Buffer Post List */ 15080d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_RAID_ACCELERATOR (0x2C) /* RAID Accelerator */ 15090d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_HOST_BASED_DISCOVERY_ACTION (0x2F) /* Host Based Discovery Action */ 15100d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_PWR_MGMT_CONTROL (0x30) /* Power Management Control */ 15110d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_MIN_PRODUCT_SPECIFIC (0xF0) /* beginning of product-specific range */ 15120d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_MAX_PRODUCT_SPECIFIC (0xFF) /* end of product-specific range */ 15130d9a4ef3SDoug Ambrisko 15140d9a4ef3SDoug Ambrisko /* Doorbell functions */ 15150d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET (0x40) 15160d9a4ef3SDoug Ambrisko #define MPI2_FUNCTION_HANDSHAKE (0x42) 15170d9a4ef3SDoug Ambrisko 15180d9a4ef3SDoug Ambrisko /***************************************************************************** 15190d9a4ef3SDoug Ambrisko * 15200d9a4ef3SDoug Ambrisko * MPI Version Definitions 15210d9a4ef3SDoug Ambrisko * 15220d9a4ef3SDoug Ambrisko *****************************************************************************/ 15230d9a4ef3SDoug Ambrisko 15240d9a4ef3SDoug Ambrisko #define MPI2_VERSION_MAJOR (0x02) 15250d9a4ef3SDoug Ambrisko #define MPI2_VERSION_MINOR (0x00) 15260d9a4ef3SDoug Ambrisko #define MPI2_VERSION_MAJOR_MASK (0xFF00) 15270d9a4ef3SDoug Ambrisko #define MPI2_VERSION_MAJOR_SHIFT (8) 15280d9a4ef3SDoug Ambrisko #define MPI2_VERSION_MINOR_MASK (0x00FF) 15290d9a4ef3SDoug Ambrisko #define MPI2_VERSION_MINOR_SHIFT (0) 15300d9a4ef3SDoug Ambrisko #define MPI2_VERSION ((MPI2_VERSION_MAJOR << MPI2_VERSION_MAJOR_SHIFT) | \ 15310d9a4ef3SDoug Ambrisko MPI2_VERSION_MINOR) 15320d9a4ef3SDoug Ambrisko 15330d9a4ef3SDoug Ambrisko #define MPI2_VERSION_02_00 (0x0200) 15340d9a4ef3SDoug Ambrisko 15350d9a4ef3SDoug Ambrisko /* versioning for this MPI header set */ 15360d9a4ef3SDoug Ambrisko #define MPI2_HEADER_VERSION_UNIT (0x10) 15370d9a4ef3SDoug Ambrisko #define MPI2_HEADER_VERSION_DEV (0x00) 15380d9a4ef3SDoug Ambrisko #define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00) 15390d9a4ef3SDoug Ambrisko #define MPI2_HEADER_VERSION_UNIT_SHIFT (8) 15400d9a4ef3SDoug Ambrisko #define MPI2_HEADER_VERSION_DEV_MASK (0x00FF) 15410d9a4ef3SDoug Ambrisko #define MPI2_HEADER_VERSION_DEV_SHIFT (0) 1542a6ba0fd6SDoug Ambrisko #define MPI2_HEADER_VERSION ((MPI2_HEADER_VERSION_UNIT << 8) | \ 1543a6ba0fd6SDoug Ambrisko MPI2_HEADER_VERSION_DEV) 15440d9a4ef3SDoug Ambrisko 15450d9a4ef3SDoug Ambrisko /* IOCInit Request message */ 1546a6ba0fd6SDoug Ambrisko struct MPI2_IOC_INIT_REQUEST { 15470d9a4ef3SDoug Ambrisko uint8_t WhoInit; /* 0x00 */ 15480d9a4ef3SDoug Ambrisko uint8_t Reserved1; /* 0x01 */ 15490d9a4ef3SDoug Ambrisko uint8_t ChainOffset; /* 0x02 */ 15500d9a4ef3SDoug Ambrisko uint8_t Function; /* 0x03 */ 15510d9a4ef3SDoug Ambrisko uint16_t Reserved2; /* 0x04 */ 15520d9a4ef3SDoug Ambrisko uint8_t Reserved3; /* 0x06 */ 15530d9a4ef3SDoug Ambrisko uint8_t MsgFlags; /* 0x07 */ 15540d9a4ef3SDoug Ambrisko uint8_t VP_ID; /* 0x08 */ 15550d9a4ef3SDoug Ambrisko uint8_t VF_ID; /* 0x09 */ 15560d9a4ef3SDoug Ambrisko uint16_t Reserved4; /* 0x0A */ 15570d9a4ef3SDoug Ambrisko uint16_t MsgVersion; /* 0x0C */ 15580d9a4ef3SDoug Ambrisko uint16_t HeaderVersion; /* 0x0E */ 15590d9a4ef3SDoug Ambrisko uint32_t Reserved5; /* 0x10 */ 15600d9a4ef3SDoug Ambrisko uint16_t Reserved6; /* 0x14 */ 15610d9a4ef3SDoug Ambrisko uint8_t Reserved7; /* 0x16 */ 15620d9a4ef3SDoug Ambrisko uint8_t HostMSIxVectors; /* 0x17 */ 15630d9a4ef3SDoug Ambrisko uint16_t Reserved8; /* 0x18 */ 15640d9a4ef3SDoug Ambrisko uint16_t SystemRequestFrameSize; /* 0x1A */ 15650d9a4ef3SDoug Ambrisko uint16_t ReplyDescriptorPostQueueDepth; /* 0x1C */ 15660d9a4ef3SDoug Ambrisko uint16_t ReplyFreeQueueDepth; /* 0x1E */ 15670d9a4ef3SDoug Ambrisko uint32_t SenseBufferAddressHigh; /* 0x20 */ 15680d9a4ef3SDoug Ambrisko uint32_t SystemReplyAddressHigh; /* 0x24 */ 15690d9a4ef3SDoug Ambrisko uint64_t SystemRequestFrameBaseAddress; /* 0x28 */ 15700d9a4ef3SDoug Ambrisko uint64_t ReplyDescriptorPostQueueAddress;/* 0x30 */ 15710d9a4ef3SDoug Ambrisko uint64_t ReplyFreeQueueAddress; /* 0x38 */ 15720d9a4ef3SDoug Ambrisko uint64_t TimeStamp; /* 0x40 */ 15730d9a4ef3SDoug Ambrisko }; 15740d9a4ef3SDoug Ambrisko 15750d9a4ef3SDoug Ambrisko /* WhoInit values */ 15760d9a4ef3SDoug Ambrisko #define MPI2_WHOINIT_NOT_INITIALIZED (0x00) 15770d9a4ef3SDoug Ambrisko #define MPI2_WHOINIT_SYSTEM_BIOS (0x01) 15780d9a4ef3SDoug Ambrisko #define MPI2_WHOINIT_ROM_BIOS (0x02) 15790d9a4ef3SDoug Ambrisko #define MPI2_WHOINIT_PCI_PEER (0x03) 15800d9a4ef3SDoug Ambrisko #define MPI2_WHOINIT_HOST_DRIVER (0x04) 15810d9a4ef3SDoug Ambrisko #define MPI2_WHOINIT_MANUFACTURER (0x05) 15820d9a4ef3SDoug Ambrisko 1583a6ba0fd6SDoug Ambrisko struct MPI2_SGE_CHAIN_UNION { 15840d9a4ef3SDoug Ambrisko uint16_t Length; 15850d9a4ef3SDoug Ambrisko uint8_t NextChainOffset; 15860d9a4ef3SDoug Ambrisko uint8_t Flags; 1587a6ba0fd6SDoug Ambrisko union { 15880d9a4ef3SDoug Ambrisko uint32_t Address32; 15890d9a4ef3SDoug Ambrisko uint64_t Address64; 15900d9a4ef3SDoug Ambrisko } u; 15910d9a4ef3SDoug Ambrisko }; 15920d9a4ef3SDoug Ambrisko 1593a6ba0fd6SDoug Ambrisko struct MPI2_IEEE_SGE_SIMPLE32 { 15940d9a4ef3SDoug Ambrisko uint32_t Address; 15950d9a4ef3SDoug Ambrisko uint32_t FlagsLength; 15960d9a4ef3SDoug Ambrisko }; 15970d9a4ef3SDoug Ambrisko 1598a6ba0fd6SDoug Ambrisko struct MPI2_IEEE_SGE_SIMPLE64 { 15990d9a4ef3SDoug Ambrisko uint64_t Address; 16000d9a4ef3SDoug Ambrisko uint32_t Length; 16010d9a4ef3SDoug Ambrisko uint16_t Reserved1; 16020d9a4ef3SDoug Ambrisko uint8_t Reserved2; 16030d9a4ef3SDoug Ambrisko uint8_t Flags; 16040d9a4ef3SDoug Ambrisko }; 16050d9a4ef3SDoug Ambrisko 1606a6ba0fd6SDoug Ambrisko typedef union _MPI2_IEEE_SGE_SIMPLE_UNION { 16070d9a4ef3SDoug Ambrisko struct MPI2_IEEE_SGE_SIMPLE32 Simple32; 16080d9a4ef3SDoug Ambrisko struct MPI2_IEEE_SGE_SIMPLE64 Simple64; 16090d9a4ef3SDoug Ambrisko } MPI2_IEEE_SGE_SIMPLE_UNION; 16100d9a4ef3SDoug Ambrisko 1611a6ba0fd6SDoug Ambrisko typedef struct _MPI2_SGE_SIMPLE_UNION { 16120d9a4ef3SDoug Ambrisko uint32_t FlagsLength; 1613a6ba0fd6SDoug Ambrisko union { 16140d9a4ef3SDoug Ambrisko uint32_t Address32; 16150d9a4ef3SDoug Ambrisko uint64_t Address64; 16160d9a4ef3SDoug Ambrisko } u; 16170d9a4ef3SDoug Ambrisko } MPI2_SGE_SIMPLE_UNION; 16180d9a4ef3SDoug Ambrisko 16190d9a4ef3SDoug Ambrisko /**************************************************************************** 16200d9a4ef3SDoug Ambrisko * IEEE SGE field definitions and masks 16210d9a4ef3SDoug Ambrisko ****************************************************************************/ 16220d9a4ef3SDoug Ambrisko 16230d9a4ef3SDoug Ambrisko /* Flags field bit definitions */ 16240d9a4ef3SDoug Ambrisko 16250d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_ELEMENT_TYPE_MASK (0x80) 16260d9a4ef3SDoug Ambrisko 16270d9a4ef3SDoug Ambrisko #define MPI2_IEEE32_SGE_FLAGS_SHIFT (24) 16280d9a4ef3SDoug Ambrisko 16290d9a4ef3SDoug Ambrisko #define MPI2_IEEE32_SGE_LENGTH_MASK (0x00FFFFFF) 16300d9a4ef3SDoug Ambrisko 16310d9a4ef3SDoug Ambrisko /* Element Type */ 16320d9a4ef3SDoug Ambrisko 16330d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_SIMPLE_ELEMENT (0x00) 16340d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_CHAIN_ELEMENT (0x80) 16350d9a4ef3SDoug Ambrisko 16360d9a4ef3SDoug Ambrisko /* Data Location Address Space */ 16370d9a4ef3SDoug Ambrisko 16380d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_ADDR_MASK (0x03) 16390d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_SYSTEM_ADDR (0x00) 16400d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_IOCDDR_ADDR (0x01) 16410d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_IOCPLB_ADDR (0x02) 16420d9a4ef3SDoug Ambrisko #define MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR (0x03) 16430d9a4ef3SDoug Ambrisko 16440d9a4ef3SDoug Ambrisko /* Address Size */ 16450d9a4ef3SDoug Ambrisko 16460d9a4ef3SDoug Ambrisko #define MPI2_SGE_FLAGS_32_BIT_ADDRESSING (0x00) 16470d9a4ef3SDoug Ambrisko #define MPI2_SGE_FLAGS_64_BIT_ADDRESSING (0x02) 16480d9a4ef3SDoug Ambrisko 16490d9a4ef3SDoug Ambrisko /*******************/ 16500d9a4ef3SDoug Ambrisko /* SCSI IO Control bits */ 16510d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_ADDCDBLEN_MASK (0xFC000000) 16520d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_ADDCDBLEN_SHIFT (26) 16530d9a4ef3SDoug Ambrisko 16540d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_DATADIRECTION_MASK (0x03000000) 16550d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_NODATATRANSFER (0x00000000) 16560d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_WRITE (0x01000000) 16570d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_READ (0x02000000) 16580d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_BIDIRECTIONAL (0x03000000) 16590d9a4ef3SDoug Ambrisko 16600d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_TASKPRI_MASK (0x00007800) 16610d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_TASKPRI_SHIFT (11) 16620d9a4ef3SDoug Ambrisko 16630d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_TASKATTRIBUTE_MASK (0x00000700) 16640d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_SIMPLEQ (0x00000000) 16650d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_HEADOFQ (0x00000100) 16660d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_ORDEREDQ (0x00000200) 16670d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_ACAQ (0x00000400) 16680d9a4ef3SDoug Ambrisko 16690d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_TLR_MASK (0x000000C0) 16700d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_NO_TLR (0x00000000) 16710d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_TLR_ON (0x00000040) 16720d9a4ef3SDoug Ambrisko #define MPI2_SCSIIO_CONTROL_TLR_OFF (0x00000080) 16730d9a4ef3SDoug Ambrisko 16740d9a4ef3SDoug Ambrisko /*******************/ 16750d9a4ef3SDoug Ambrisko 1676a6ba0fd6SDoug Ambrisko typedef struct { 16770d9a4ef3SDoug Ambrisko uint8_t CDB[20]; /* 0x00 */ 16780d9a4ef3SDoug Ambrisko uint32_t PrimaryReferenceTag; /* 0x14 */ 16790d9a4ef3SDoug Ambrisko uint16_t PrimaryApplicationTag; /* 0x18 */ 16800d9a4ef3SDoug Ambrisko uint16_t PrimaryApplicationTagMask; /* 0x1A */ 16810d9a4ef3SDoug Ambrisko uint32_t TransferLength; /* 0x1C */ 16820d9a4ef3SDoug Ambrisko } MPI2_SCSI_IO_CDB_EEDP32; 16830d9a4ef3SDoug Ambrisko 1684a6ba0fd6SDoug Ambrisko typedef union _MPI2_IEEE_SGE_CHAIN_UNION { 16850d9a4ef3SDoug Ambrisko struct MPI2_IEEE_SGE_SIMPLE32 Chain32; 16860d9a4ef3SDoug Ambrisko struct MPI2_IEEE_SGE_SIMPLE64 Chain64; 16870d9a4ef3SDoug Ambrisko } MPI2_IEEE_SGE_CHAIN_UNION; 16880d9a4ef3SDoug Ambrisko 1689a6ba0fd6SDoug Ambrisko typedef union _MPI2_SIMPLE_SGE_UNION { 16900d9a4ef3SDoug Ambrisko MPI2_SGE_SIMPLE_UNION MpiSimple; 16910d9a4ef3SDoug Ambrisko MPI2_IEEE_SGE_SIMPLE_UNION IeeeSimple; 16920d9a4ef3SDoug Ambrisko } MPI2_SIMPLE_SGE_UNION; 16930d9a4ef3SDoug Ambrisko 1694a6ba0fd6SDoug Ambrisko typedef union _MPI2_SGE_IO_UNION { 16950d9a4ef3SDoug Ambrisko MPI2_SGE_SIMPLE_UNION MpiSimple; 16960d9a4ef3SDoug Ambrisko struct MPI2_SGE_CHAIN_UNION MpiChain; 16970d9a4ef3SDoug Ambrisko MPI2_IEEE_SGE_SIMPLE_UNION IeeeSimple; 16980d9a4ef3SDoug Ambrisko MPI2_IEEE_SGE_CHAIN_UNION IeeeChain; 16990d9a4ef3SDoug Ambrisko } MPI2_SGE_IO_UNION; 17000d9a4ef3SDoug Ambrisko 1701a6ba0fd6SDoug Ambrisko typedef union { 17020d9a4ef3SDoug Ambrisko uint8_t CDB32[32]; 17030d9a4ef3SDoug Ambrisko MPI2_SCSI_IO_CDB_EEDP32 EEDP32; 17040d9a4ef3SDoug Ambrisko MPI2_SGE_SIMPLE_UNION SGE; 17050d9a4ef3SDoug Ambrisko } MPI2_SCSI_IO_CDB_UNION; 17060d9a4ef3SDoug Ambrisko 17070d9a4ef3SDoug Ambrisko /* MPI 2.5 SGLs */ 17080d9a4ef3SDoug Ambrisko 17090d9a4ef3SDoug Ambrisko #define MPI25_IEEE_SGE_FLAGS_END_OF_LIST (0x40) 17100d9a4ef3SDoug Ambrisko 1711a6ba0fd6SDoug Ambrisko typedef struct _MPI25_IEEE_SGE_CHAIN64 { 17120d9a4ef3SDoug Ambrisko uint64_t Address; 17130d9a4ef3SDoug Ambrisko uint32_t Length; 17140d9a4ef3SDoug Ambrisko uint16_t Reserved1; 17150d9a4ef3SDoug Ambrisko uint8_t NextChainOffset; 17160d9a4ef3SDoug Ambrisko uint8_t Flags; 17170d9a4ef3SDoug Ambrisko } MPI25_IEEE_SGE_CHAIN64, *pMpi25IeeeSgeChain64_t; 17180d9a4ef3SDoug Ambrisko 17190d9a4ef3SDoug Ambrisko /* use MPI2_IEEE_SGE_FLAGS_ defines for the Flags field */ 17200d9a4ef3SDoug Ambrisko 17210d9a4ef3SDoug Ambrisko /********/ 17220d9a4ef3SDoug Ambrisko 17230d9a4ef3SDoug Ambrisko /* 17240d9a4ef3SDoug Ambrisko * RAID SCSI IO Request Message 17250d9a4ef3SDoug Ambrisko * Total SGE count will be one less than _MPI2_SCSI_IO_REQUEST 17260d9a4ef3SDoug Ambrisko */ 1727a6ba0fd6SDoug Ambrisko struct mfi_mpi2_request_raid_scsi_io { 17280d9a4ef3SDoug Ambrisko uint16_t DevHandle; /* 0x00 */ 17290d9a4ef3SDoug Ambrisko uint8_t ChainOffset; /* 0x02 */ 17300d9a4ef3SDoug Ambrisko uint8_t Function; /* 0x03 */ 17310d9a4ef3SDoug Ambrisko uint16_t Reserved1; /* 0x04 */ 17320d9a4ef3SDoug Ambrisko uint8_t Reserved2; /* 0x06 */ 17330d9a4ef3SDoug Ambrisko uint8_t MsgFlags; /* 0x07 */ 17340d9a4ef3SDoug Ambrisko uint8_t VP_ID; /* 0x08 */ 17350d9a4ef3SDoug Ambrisko uint8_t VF_ID; /* 0x09 */ 17360d9a4ef3SDoug Ambrisko uint16_t Reserved3; /* 0x0A */ 17370d9a4ef3SDoug Ambrisko uint32_t SenseBufferLowAddress; /* 0x0C */ 17380d9a4ef3SDoug Ambrisko uint16_t SGLFlags; /* 0x10 */ 17390d9a4ef3SDoug Ambrisko uint8_t SenseBufferLength; /* 0x12 */ 17400d9a4ef3SDoug Ambrisko uint8_t Reserved4; /* 0x13 */ 17410d9a4ef3SDoug Ambrisko uint8_t SGLOffset0; /* 0x14 */ 17420d9a4ef3SDoug Ambrisko uint8_t SGLOffset1; /* 0x15 */ 17430d9a4ef3SDoug Ambrisko uint8_t SGLOffset2; /* 0x16 */ 17440d9a4ef3SDoug Ambrisko uint8_t SGLOffset3; /* 0x17 */ 17450d9a4ef3SDoug Ambrisko uint32_t SkipCount; /* 0x18 */ 17460d9a4ef3SDoug Ambrisko uint32_t DataLength; /* 0x1C */ 17470d9a4ef3SDoug Ambrisko uint32_t BidirectionalDataLength; /* 0x20 */ 17480d9a4ef3SDoug Ambrisko uint16_t IoFlags; /* 0x24 */ 17490d9a4ef3SDoug Ambrisko uint16_t EEDPFlags; /* 0x26 */ 17500d9a4ef3SDoug Ambrisko uint32_t EEDPBlockSize; /* 0x28 */ 17510d9a4ef3SDoug Ambrisko uint32_t SecondaryReferenceTag; /* 0x2C */ 17520d9a4ef3SDoug Ambrisko uint16_t SecondaryApplicationTag; /* 0x30 */ 17530d9a4ef3SDoug Ambrisko uint16_t ApplicationTagTranslationMask; /* 0x32 */ 17540d9a4ef3SDoug Ambrisko uint8_t LUN[8]; /* 0x34 */ 17550d9a4ef3SDoug Ambrisko uint32_t Control; /* 0x3C */ 17560d9a4ef3SDoug Ambrisko MPI2_SCSI_IO_CDB_UNION CDB; /* 0x40 */ 17570d9a4ef3SDoug Ambrisko MPI2_SCSI_IO_VENDOR_UNIQUE RaidContext; /* 0x60 */ 17580d9a4ef3SDoug Ambrisko MPI2_SGE_IO_UNION SGL; /* 0x80 */ 17590d9a4ef3SDoug Ambrisko } __packed; 17600d9a4ef3SDoug Ambrisko 17610d9a4ef3SDoug Ambrisko /* 17620d9a4ef3SDoug Ambrisko * MPT RAID MFA IO Descriptor. 17630d9a4ef3SDoug Ambrisko */ 17640d9a4ef3SDoug Ambrisko typedef struct _MFI_RAID_MFA_IO_DESCRIPTOR { 17650d9a4ef3SDoug Ambrisko uint32_t RequestFlags : 8; 17660d9a4ef3SDoug Ambrisko uint32_t MessageAddress1 : 24; /* bits 31:8*/ 17670d9a4ef3SDoug Ambrisko uint32_t MessageAddress2; /* bits 61:32 */ 17680d9a4ef3SDoug Ambrisko } MFI_RAID_MFA_IO_REQUEST_DESCRIPTOR,*PMFI_RAID_MFA_IO_REQUEST_DESCRIPTOR; 17690d9a4ef3SDoug Ambrisko 17700d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_header { 17710d9a4ef3SDoug Ambrisko uint8_t RequestFlags; /* 0x00 */ 17720d9a4ef3SDoug Ambrisko uint8_t MSIxIndex; /* 0x01 */ 17730d9a4ef3SDoug Ambrisko uint16_t SMID; /* 0x02 */ 17740d9a4ef3SDoug Ambrisko uint16_t LMID; /* 0x04 */ 17750d9a4ef3SDoug Ambrisko }; 17760d9a4ef3SDoug Ambrisko 17770d9a4ef3SDoug Ambrisko /* defines for the RequestFlags field */ 17780d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_TYPE_MASK (0x0E) 17790d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO (0x00) 17800d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET (0x02) 17810d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY (0x06) 17820d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE (0x08) 17830d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_RAID_ACCELERATOR (0x0A) 17840d9a4ef3SDoug Ambrisko 17850d9a4ef3SDoug Ambrisko #define MPI2_REQ_DESCRIPT_FLAGS_IOC_FIFO_MARKER (0x01) 17860d9a4ef3SDoug Ambrisko 17870d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_high_priority { 17880d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_header header; 17890d9a4ef3SDoug Ambrisko uint16_t reserved; 17900d9a4ef3SDoug Ambrisko }; 17910d9a4ef3SDoug Ambrisko 17920d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_scsi_io { 17930d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_header header; 17940d9a4ef3SDoug Ambrisko uint16_t scsi_io_dev_handle; 17950d9a4ef3SDoug Ambrisko }; 17960d9a4ef3SDoug Ambrisko 17970d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_scsi_target { 17980d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_header header; 17990d9a4ef3SDoug Ambrisko uint16_t scsi_target_io_index; 18000d9a4ef3SDoug Ambrisko }; 18010d9a4ef3SDoug Ambrisko 18020d9a4ef3SDoug Ambrisko /* Request Descriptors */ 18030d9a4ef3SDoug Ambrisko union mfi_mpi2_request_descriptor { 18040d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_header header; 18050d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_high_priority high_priority; 18060d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_scsi_io scsi_io; 18070d9a4ef3SDoug Ambrisko struct mfi_mpi2_request_scsi_target scsi_target; 18080d9a4ef3SDoug Ambrisko uint64_t words; 18090d9a4ef3SDoug Ambrisko }; 18100d9a4ef3SDoug Ambrisko 18110d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header { 18120d9a4ef3SDoug Ambrisko uint8_t ReplyFlags; /* 0x00 */ 18130d9a4ef3SDoug Ambrisko uint8_t MSIxIndex; /* 0x01 */ 18140d9a4ef3SDoug Ambrisko uint16_t SMID; /* 0x02 */ 18150d9a4ef3SDoug Ambrisko }; 18160d9a4ef3SDoug Ambrisko 18170d9a4ef3SDoug Ambrisko /* defines for the ReplyFlags field */ 18180d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK (0x0F) 18190d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS (0x00) 18200d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY (0x01) 18210d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS (0x02) 18220d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER (0x03) 18230d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_RAID_ACCELERATOR_SUCCESS (0x05) 18240d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_FLAGS_UNUSED (0x0F) 18250d9a4ef3SDoug Ambrisko 18260d9a4ef3SDoug Ambrisko /* values for marking a reply descriptor as unused */ 18270d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_UNUSED_WORD0_MARK (0xFFFFFFFF) 18280d9a4ef3SDoug Ambrisko #define MPI2_RPY_DESCRIPT_UNUSED_WORD1_MARK (0xFFFFFFFF) 18290d9a4ef3SDoug Ambrisko 18300d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_default { 18310d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18320d9a4ef3SDoug Ambrisko uint32_t DescriptorTypeDependent2; 18330d9a4ef3SDoug Ambrisko }; 18340d9a4ef3SDoug Ambrisko 18350d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_address { 18360d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18370d9a4ef3SDoug Ambrisko uint32_t ReplyFrameAddress; 18380d9a4ef3SDoug Ambrisko }; 18390d9a4ef3SDoug Ambrisko 18400d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_scsi_io { 18410d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18420d9a4ef3SDoug Ambrisko uint16_t TaskTag; /* 0x04 */ 18430d9a4ef3SDoug Ambrisko uint16_t Reserved1; /* 0x06 */ 18440d9a4ef3SDoug Ambrisko }; 18450d9a4ef3SDoug Ambrisko 18460d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_target_assist { 18470d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18480d9a4ef3SDoug Ambrisko uint8_t SequenceNumber; /* 0x04 */ 18490d9a4ef3SDoug Ambrisko uint8_t Reserved1; /* 0x04 */ 18500d9a4ef3SDoug Ambrisko uint16_t IoIndex; /* 0x06 */ 18510d9a4ef3SDoug Ambrisko }; 18520d9a4ef3SDoug Ambrisko 18530d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_target_cmd_buffer { 18540d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18550d9a4ef3SDoug Ambrisko uint8_t SequenceNumber; /* 0x04 */ 18560d9a4ef3SDoug Ambrisko uint8_t Flags; /* 0x04 */ 18570d9a4ef3SDoug Ambrisko uint16_t InitiatorDevHandle; /* 0x06 */ 18580d9a4ef3SDoug Ambrisko uint16_t IoIndex; /* 0x06 */ 18590d9a4ef3SDoug Ambrisko }; 18600d9a4ef3SDoug Ambrisko 18610d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_raid_accel { 18620d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18630d9a4ef3SDoug Ambrisko uint8_t SequenceNumber; /* 0x04 */ 18640d9a4ef3SDoug Ambrisko uint32_t Reserved; /* 0x04 */ 18650d9a4ef3SDoug Ambrisko }; 18660d9a4ef3SDoug Ambrisko 18670d9a4ef3SDoug Ambrisko /* union of Reply Descriptors */ 1868a6ba0fd6SDoug Ambrisko union mfi_mpi2_reply_descriptor { 18690d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_header header; 18700d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_scsi_io scsi_io; 18710d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_target_assist target_assist; 18720d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_target_cmd_buffer target_cmd; 18730d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_raid_accel raid_accel; 18740d9a4ef3SDoug Ambrisko struct mfi_mpi2_reply_default reply_default; 18750d9a4ef3SDoug Ambrisko uint64_t words; 18760d9a4ef3SDoug Ambrisko }; 18770d9a4ef3SDoug Ambrisko 18780d9a4ef3SDoug Ambrisko struct IO_REQUEST_INFO { 18790d9a4ef3SDoug Ambrisko uint64_t ldStartBlock; 18800d9a4ef3SDoug Ambrisko uint32_t numBlocks; 18810d9a4ef3SDoug Ambrisko uint16_t ldTgtId; 18820d9a4ef3SDoug Ambrisko uint8_t isRead; 18830d9a4ef3SDoug Ambrisko uint16_t devHandle; 18840d9a4ef3SDoug Ambrisko uint64_t pdBlock; 18850d9a4ef3SDoug Ambrisko uint8_t fpOkForIo; 18860d9a4ef3SDoug Ambrisko }; 18870d9a4ef3SDoug Ambrisko 188835ef86f2SScott Long #define MFI_SCSI_MAX_TARGETS 128 188935ef86f2SScott Long #define MFI_SCSI_MAX_LUNS 8 189035ef86f2SScott Long #define MFI_SCSI_INITIATOR_ID 255 189135ef86f2SScott Long #define MFI_SCSI_MAX_CMDS 8 189235ef86f2SScott Long #define MFI_SCSI_MAX_CDB_LEN 16 189335ef86f2SScott Long 18942e21a3efSScott Long #endif /* _MFIREG_H */ 1895