blob: 2371e5ca2a5bb94d6b7f8d6ccee3c3bd895f626d [file] [log] [blame]
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001/*
adam radford3f1530c2010-12-14 18:51:48 -08002 * Linux MegaRAID driver for SAS based RAID controllers
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04003 *
adam radfordae590572012-10-01 19:27:34 -07004 * Copyright (c) 2003-2012 LSI Corporation.
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04005 *
adam radford3f1530c2010-12-14 18:51:48 -08006 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040010 *
adam radford3f1530c2010-12-14 18:51:48 -080011 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040015 *
adam radford3f1530c2010-12-14 18:51:48 -080016 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * FILE: megaraid_sas.h
21 *
22 * Authors: LSI Corporation
23 *
24 * Send feedback to: <megaraidlinux@lsi.com>
25 *
26 * Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035
27 * ATTN: Linuxraid
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040028 */
29
30#ifndef LSI_MEGARAID_SAS_H
31#define LSI_MEGARAID_SAS_H
32
Randy Dunlapa69b74d2007-01-05 22:41:48 -080033/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040034 * MegaRAID SAS Driver meta data
35 */
adam radford5eca4a62013-02-09 15:29:25 -080036#define MEGASAS_VERSION "06.506.00.00-rc1"
37#define MEGASAS_RELDATE "Feb. 9, 2013"
38#define MEGASAS_EXT_VERSION "Sat. Feb. 9 17:00:00 PDT 2013"
Sumant Patro0e989362006-06-20 15:32:37 -070039
40/*
41 * Device IDs
42 */
43#define PCI_DEVICE_ID_LSI_SAS1078R 0x0060
bo yangaf7a5642008-03-17 04:13:07 -040044#define PCI_DEVICE_ID_LSI_SAS1078DE 0x007C
Sumant Patro0e989362006-06-20 15:32:37 -070045#define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413
Yang, Bo6610a6b2008-08-10 12:42:38 -070046#define PCI_DEVICE_ID_LSI_SAS1078GEN2 0x0078
47#define PCI_DEVICE_ID_LSI_SAS0079GEN2 0x0079
Yang, Bo87911122009-10-06 14:31:54 -060048#define PCI_DEVICE_ID_LSI_SAS0073SKINNY 0x0073
49#define PCI_DEVICE_ID_LSI_SAS0071SKINNY 0x0071
adam radford9c915a82010-12-21 13:34:31 -080050#define PCI_DEVICE_ID_LSI_FUSION 0x005b
adam radford36807e62011-10-08 18:15:06 -070051#define PCI_DEVICE_ID_LSI_INVADER 0x005d
Sumit.Saxena@lsi.com21d3c712013-05-22 12:31:43 +053052#define PCI_DEVICE_ID_LSI_FURY 0x005f
Sumant Patro0e989362006-06-20 15:32:37 -070053
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040054/*
Sumit.Saxena@lsi.com39b72c32013-05-22 12:32:43 +053055 * Intel HBA SSDIDs
56 */
57#define MEGARAID_INTEL_RS3DC080_SSDID 0x9360
58#define MEGARAID_INTEL_RS3DC040_SSDID 0x9362
59#define MEGARAID_INTEL_RS3SC008_SSDID 0x9380
60#define MEGARAID_INTEL_RS3MC044_SSDID 0x9381
61#define MEGARAID_INTEL_RS3WC080_SSDID 0x9341
62#define MEGARAID_INTEL_RS3WC040_SSDID 0x9343
63
64/*
65 * Intel HBA branding
66 */
67#define MEGARAID_INTEL_RS3DC080_BRANDING \
68 "Intel(R) RAID Controller RS3DC080"
69#define MEGARAID_INTEL_RS3DC040_BRANDING \
70 "Intel(R) RAID Controller RS3DC040"
71#define MEGARAID_INTEL_RS3SC008_BRANDING \
72 "Intel(R) RAID Controller RS3SC008"
73#define MEGARAID_INTEL_RS3MC044_BRANDING \
74 "Intel(R) RAID Controller RS3MC044"
75#define MEGARAID_INTEL_RS3WC080_BRANDING \
76 "Intel(R) RAID Controller RS3WC080"
77#define MEGARAID_INTEL_RS3WC040_BRANDING \
78 "Intel(R) RAID Controller RS3WC040"
79
80/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040081 * =====================================
82 * MegaRAID SAS MFI firmware definitions
83 * =====================================
84 */
85
86/*
87 * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
88 * protocol between the software and firmware. Commands are issued using
89 * "message frames"
90 */
91
Randy Dunlapa69b74d2007-01-05 22:41:48 -080092/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -040093 * FW posts its state in upper 4 bits of outbound_msg_0 register
94 */
95#define MFI_STATE_MASK 0xF0000000
96#define MFI_STATE_UNDEFINED 0x00000000
97#define MFI_STATE_BB_INIT 0x10000000
98#define MFI_STATE_FW_INIT 0x40000000
99#define MFI_STATE_WAIT_HANDSHAKE 0x60000000
100#define MFI_STATE_FW_INIT_2 0x70000000
101#define MFI_STATE_DEVICE_SCAN 0x80000000
Sumant Patroe3bbff92006-10-03 12:28:49 -0700102#define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400103#define MFI_STATE_FLUSH_CACHE 0xA0000000
104#define MFI_STATE_READY 0xB0000000
105#define MFI_STATE_OPERATIONAL 0xC0000000
106#define MFI_STATE_FAULT 0xF0000000
adam radford7e70e732011-05-11 18:34:08 -0700107#define MFI_RESET_REQUIRED 0x00000001
108#define MFI_RESET_ADAPTER 0x00000002
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400109#define MEGAMFI_FRAME_SIZE 64
110
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800111/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400112 * During FW init, clear pending cmds & reset state using inbound_msg_0
113 *
114 * ABORT : Abort all pending cmds
115 * READY : Move from OPERATIONAL to READY state; discard queue info
116 * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
117 * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
Sumant Patroe3bbff92006-10-03 12:28:49 -0700118 * HOTPLUG : Resume from Hotplug
119 * MFI_STOP_ADP : Send signal to FW to stop processing
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400120 */
bo yang39a98552010-09-22 22:36:29 -0400121#define WRITE_SEQUENCE_OFFSET (0x0000000FC) /* I20 */
122#define HOST_DIAGNOSTIC_OFFSET (0x000000F8) /* I20 */
123#define DIAG_WRITE_ENABLE (0x00000080)
124#define DIAG_RESET_ADAPTER (0x00000004)
125
126#define MFI_ADP_RESET 0x00000040
Sumant Patroe3bbff92006-10-03 12:28:49 -0700127#define MFI_INIT_ABORT 0x00000001
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400128#define MFI_INIT_READY 0x00000002
129#define MFI_INIT_MFIMODE 0x00000004
130#define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
Sumant Patroe3bbff92006-10-03 12:28:49 -0700131#define MFI_INIT_HOTPLUG 0x00000010
132#define MFI_STOP_ADP 0x00000020
133#define MFI_RESET_FLAGS MFI_INIT_READY| \
134 MFI_INIT_MFIMODE| \
135 MFI_INIT_ABORT
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400136
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800137/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400138 * MFI frame flags
139 */
140#define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
141#define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
142#define MFI_FRAME_SGL32 0x0000
143#define MFI_FRAME_SGL64 0x0002
144#define MFI_FRAME_SENSE32 0x0000
145#define MFI_FRAME_SENSE64 0x0004
146#define MFI_FRAME_DIR_NONE 0x0000
147#define MFI_FRAME_DIR_WRITE 0x0008
148#define MFI_FRAME_DIR_READ 0x0010
149#define MFI_FRAME_DIR_BOTH 0x0018
Yang, Bof4c9a132009-10-06 14:43:28 -0600150#define MFI_FRAME_IEEE 0x0020
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400151
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800152/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400153 * Definition for cmd_status
154 */
155#define MFI_CMD_STATUS_POLL_MODE 0xFF
156
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800157/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400158 * MFI command opcodes
159 */
160#define MFI_CMD_INIT 0x00
161#define MFI_CMD_LD_READ 0x01
162#define MFI_CMD_LD_WRITE 0x02
163#define MFI_CMD_LD_SCSI_IO 0x03
164#define MFI_CMD_PD_SCSI_IO 0x04
165#define MFI_CMD_DCMD 0x05
166#define MFI_CMD_ABORT 0x06
167#define MFI_CMD_SMP 0x07
168#define MFI_CMD_STP 0x08
adam radforde5f93a32011-10-08 18:15:19 -0700169#define MFI_CMD_INVALID 0xff
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400170
171#define MR_DCMD_CTRL_GET_INFO 0x01010000
Yang, Bobdc6fb82009-12-06 08:30:19 -0700172#define MR_DCMD_LD_GET_LIST 0x03010000
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400173
174#define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
175#define MR_FLUSH_CTRL_CACHE 0x01
176#define MR_FLUSH_DISK_CACHE 0x02
177
178#define MR_DCMD_CTRL_SHUTDOWN 0x01050000
bo yang31ea7082007-11-07 12:09:50 -0500179#define MR_DCMD_HIBERNATE_SHUTDOWN 0x01060000
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400180#define MR_ENABLE_DRIVE_SPINDOWN 0x01
181
182#define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
183#define MR_DCMD_CTRL_EVENT_GET 0x01040300
184#define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
185#define MR_DCMD_LD_GET_PROPERTIES 0x03030000
186
187#define MR_DCMD_CLUSTER 0x08000000
188#define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
189#define MR_DCMD_CLUSTER_RESET_LD 0x08010200
Yang, Bo81e403c2009-10-06 14:27:54 -0600190#define MR_DCMD_PD_LIST_QUERY 0x02010100
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400191
Randy Dunlapa69b74d2007-01-05 22:41:48 -0800192/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400193 * MFI command completion codes
194 */
195enum MFI_STAT {
196 MFI_STAT_OK = 0x00,
197 MFI_STAT_INVALID_CMD = 0x01,
198 MFI_STAT_INVALID_DCMD = 0x02,
199 MFI_STAT_INVALID_PARAMETER = 0x03,
200 MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
201 MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
202 MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
203 MFI_STAT_APP_IN_USE = 0x07,
204 MFI_STAT_APP_NOT_INITIALIZED = 0x08,
205 MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
206 MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
207 MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
208 MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
209 MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
210 MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
211 MFI_STAT_FLASH_BUSY = 0x0f,
212 MFI_STAT_FLASH_ERROR = 0x10,
213 MFI_STAT_FLASH_IMAGE_BAD = 0x11,
214 MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
215 MFI_STAT_FLASH_NOT_OPEN = 0x13,
216 MFI_STAT_FLASH_NOT_STARTED = 0x14,
217 MFI_STAT_FLUSH_FAILED = 0x15,
218 MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
219 MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
220 MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
221 MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
222 MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
223 MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
224 MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
225 MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
226 MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
227 MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
228 MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
229 MFI_STAT_MFC_HW_ERROR = 0x21,
230 MFI_STAT_NO_HW_PRESENT = 0x22,
231 MFI_STAT_NOT_FOUND = 0x23,
232 MFI_STAT_NOT_IN_ENCL = 0x24,
233 MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
234 MFI_STAT_PD_TYPE_WRONG = 0x26,
235 MFI_STAT_PR_DISABLED = 0x27,
236 MFI_STAT_ROW_INDEX_INVALID = 0x28,
237 MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
238 MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
239 MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
240 MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
241 MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
242 MFI_STAT_SCSI_IO_FAILED = 0x2e,
243 MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
244 MFI_STAT_SHUTDOWN_FAILED = 0x30,
245 MFI_STAT_TIME_NOT_SET = 0x31,
246 MFI_STAT_WRONG_STATE = 0x32,
247 MFI_STAT_LD_OFFLINE = 0x33,
248 MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
249 MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
250 MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
251 MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
252 MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
adam radford36807e62011-10-08 18:15:06 -0700253 MFI_STAT_CONFIG_SEQ_MISMATCH = 0x67,
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400254
255 MFI_STAT_INVALID_STATUS = 0xFF
256};
257
258/*
259 * Number of mailbox bytes in DCMD message frame
260 */
261#define MFI_MBOX_SIZE 12
262
263enum MR_EVT_CLASS {
264
265 MR_EVT_CLASS_DEBUG = -2,
266 MR_EVT_CLASS_PROGRESS = -1,
267 MR_EVT_CLASS_INFO = 0,
268 MR_EVT_CLASS_WARNING = 1,
269 MR_EVT_CLASS_CRITICAL = 2,
270 MR_EVT_CLASS_FATAL = 3,
271 MR_EVT_CLASS_DEAD = 4,
272
273};
274
275enum MR_EVT_LOCALE {
276
277 MR_EVT_LOCALE_LD = 0x0001,
278 MR_EVT_LOCALE_PD = 0x0002,
279 MR_EVT_LOCALE_ENCL = 0x0004,
280 MR_EVT_LOCALE_BBU = 0x0008,
281 MR_EVT_LOCALE_SAS = 0x0010,
282 MR_EVT_LOCALE_CTRL = 0x0020,
283 MR_EVT_LOCALE_CONFIG = 0x0040,
284 MR_EVT_LOCALE_CLUSTER = 0x0080,
285 MR_EVT_LOCALE_ALL = 0xffff,
286
287};
288
289enum MR_EVT_ARGS {
290
291 MR_EVT_ARGS_NONE,
292 MR_EVT_ARGS_CDB_SENSE,
293 MR_EVT_ARGS_LD,
294 MR_EVT_ARGS_LD_COUNT,
295 MR_EVT_ARGS_LD_LBA,
296 MR_EVT_ARGS_LD_OWNER,
297 MR_EVT_ARGS_LD_LBA_PD_LBA,
298 MR_EVT_ARGS_LD_PROG,
299 MR_EVT_ARGS_LD_STATE,
300 MR_EVT_ARGS_LD_STRIP,
301 MR_EVT_ARGS_PD,
302 MR_EVT_ARGS_PD_ERR,
303 MR_EVT_ARGS_PD_LBA,
304 MR_EVT_ARGS_PD_LBA_LD,
305 MR_EVT_ARGS_PD_PROG,
306 MR_EVT_ARGS_PD_STATE,
307 MR_EVT_ARGS_PCI,
308 MR_EVT_ARGS_RATE,
309 MR_EVT_ARGS_STR,
310 MR_EVT_ARGS_TIME,
311 MR_EVT_ARGS_ECC,
Yang, Bo81e403c2009-10-06 14:27:54 -0600312 MR_EVT_ARGS_LD_PROP,
313 MR_EVT_ARGS_PD_SPARE,
314 MR_EVT_ARGS_PD_INDEX,
315 MR_EVT_ARGS_DIAG_PASS,
316 MR_EVT_ARGS_DIAG_FAIL,
317 MR_EVT_ARGS_PD_LBA_LBA,
318 MR_EVT_ARGS_PORT_PHY,
319 MR_EVT_ARGS_PD_MISSING,
320 MR_EVT_ARGS_PD_ADDRESS,
321 MR_EVT_ARGS_BITMAP,
322 MR_EVT_ARGS_CONNECTOR,
323 MR_EVT_ARGS_PD_PD,
324 MR_EVT_ARGS_PD_FRU,
325 MR_EVT_ARGS_PD_PATHINFO,
326 MR_EVT_ARGS_PD_POWER_STATE,
327 MR_EVT_ARGS_GENERIC,
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400328};
329
330/*
Yang, Bo81e403c2009-10-06 14:27:54 -0600331 * define constants for device list query options
332 */
333enum MR_PD_QUERY_TYPE {
334 MR_PD_QUERY_TYPE_ALL = 0,
335 MR_PD_QUERY_TYPE_STATE = 1,
336 MR_PD_QUERY_TYPE_POWER_STATE = 2,
337 MR_PD_QUERY_TYPE_MEDIA_TYPE = 3,
338 MR_PD_QUERY_TYPE_SPEED = 4,
339 MR_PD_QUERY_TYPE_EXPOSED_TO_HOST = 5,
340};
341
Yang, Bo7e8a75f2009-10-06 14:50:17 -0600342#define MR_EVT_CFG_CLEARED 0x0004
343#define MR_EVT_LD_STATE_CHANGE 0x0051
344#define MR_EVT_PD_INSERTED 0x005b
345#define MR_EVT_PD_REMOVED 0x0070
346#define MR_EVT_LD_CREATED 0x008a
347#define MR_EVT_LD_DELETED 0x008b
348#define MR_EVT_FOREIGN_CFG_IMPORTED 0x00db
349#define MR_EVT_LD_OFFLINE 0x00fc
350#define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152
351#define MAX_LOGICAL_DRIVES 64
352
Yang, Bo81e403c2009-10-06 14:27:54 -0600353enum MR_PD_STATE {
354 MR_PD_STATE_UNCONFIGURED_GOOD = 0x00,
355 MR_PD_STATE_UNCONFIGURED_BAD = 0x01,
356 MR_PD_STATE_HOT_SPARE = 0x02,
357 MR_PD_STATE_OFFLINE = 0x10,
358 MR_PD_STATE_FAILED = 0x11,
359 MR_PD_STATE_REBUILD = 0x14,
360 MR_PD_STATE_ONLINE = 0x18,
361 MR_PD_STATE_COPYBACK = 0x20,
362 MR_PD_STATE_SYSTEM = 0x40,
363 };
364
365
366 /*
367 * defines the physical drive address structure
368 */
369struct MR_PD_ADDRESS {
370 u16 deviceId;
371 u16 enclDeviceId;
372
373 union {
374 struct {
375 u8 enclIndex;
376 u8 slotNumber;
377 } mrPdAddress;
378 struct {
379 u8 enclPosition;
380 u8 enclConnectorIndex;
381 } mrEnclAddress;
382 };
383 u8 scsiDevType;
384 union {
385 u8 connectedPortBitmap;
386 u8 connectedPortNumbers;
387 };
388 u64 sasAddr[2];
389} __packed;
390
391/*
392 * defines the physical drive list structure
393 */
394struct MR_PD_LIST {
395 u32 size;
396 u32 count;
397 struct MR_PD_ADDRESS addr[1];
398} __packed;
399
400struct megasas_pd_list {
401 u16 tid;
402 u8 driveType;
403 u8 driveState;
404} __packed;
405
Yang, Bobdc6fb82009-12-06 08:30:19 -0700406 /*
407 * defines the logical drive reference structure
408 */
409union MR_LD_REF {
410 struct {
411 u8 targetId;
412 u8 reserved;
413 u16 seqNum;
414 };
415 u32 ref;
416} __packed;
417
418/*
419 * defines the logical drive list structure
420 */
421struct MR_LD_LIST {
422 u32 ldCount;
423 u32 reserved;
424 struct {
425 union MR_LD_REF ref;
426 u8 state;
427 u8 reserved[3];
428 u64 size;
429 } ldList[MAX_LOGICAL_DRIVES];
430} __packed;
431
Yang, Bo81e403c2009-10-06 14:27:54 -0600432/*
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400433 * SAS controller properties
434 */
435struct megasas_ctrl_prop {
436
437 u16 seq_num;
438 u16 pred_fail_poll_interval;
439 u16 intr_throttle_count;
440 u16 intr_throttle_timeouts;
441 u8 rebuild_rate;
442 u8 patrol_read_rate;
443 u8 bgi_rate;
444 u8 cc_rate;
445 u8 recon_rate;
446 u8 cache_flush_interval;
447 u8 spinup_drv_count;
448 u8 spinup_delay;
449 u8 cluster_enable;
450 u8 coercion_mode;
451 u8 alarm_enable;
452 u8 disable_auto_rebuild;
453 u8 disable_battery_warn;
454 u8 ecc_bucket_size;
455 u16 ecc_bucket_leak_rate;
456 u8 restore_hotspare_on_insertion;
457 u8 expose_encl_devices;
bo yang39a98552010-09-22 22:36:29 -0400458 u8 maintainPdFailHistory;
459 u8 disallowHostRequestReordering;
460 u8 abortCCOnError;
461 u8 loadBalanceMode;
462 u8 disableAutoDetectBackplane;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400463
bo yang39a98552010-09-22 22:36:29 -0400464 u8 snapVDSpace;
465
466 /*
467 * Add properties that can be controlled by
468 * a bit in the following structure.
469 */
bo yang39a98552010-09-22 22:36:29 -0400470 struct {
471 u32 copyBackDisabled : 1;
472 u32 SMARTerEnabled : 1;
473 u32 prCorrectUnconfiguredAreas : 1;
474 u32 useFdeOnly : 1;
475 u32 disableNCQ : 1;
476 u32 SSDSMARTerEnabled : 1;
477 u32 SSDPatrolReadEnabled : 1;
478 u32 enableSpinDownUnconfigured : 1;
479 u32 autoEnhancedImport : 1;
480 u32 enableSecretKeyControl : 1;
481 u32 disableOnlineCtrlReset : 1;
482 u32 allowBootWithPinnedCache : 1;
483 u32 disableSpinDownHS : 1;
484 u32 enableJBOD : 1;
485 u32 reserved :18;
486 } OnOffProperties;
487 u8 autoSnapVDSpace;
488 u8 viewSpace;
489 u16 spinDownTime;
490 u8 reserved[24];
Yang, Bo81e403c2009-10-06 14:27:54 -0600491} __packed;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400492
493/*
494 * SAS controller information
495 */
496struct megasas_ctrl_info {
497
498 /*
499 * PCI device information
500 */
501 struct {
502
503 u16 vendor_id;
504 u16 device_id;
505 u16 sub_vendor_id;
506 u16 sub_device_id;
507 u8 reserved[24];
508
509 } __attribute__ ((packed)) pci;
510
511 /*
512 * Host interface information
513 */
514 struct {
515
516 u8 PCIX:1;
517 u8 PCIE:1;
518 u8 iSCSI:1;
519 u8 SAS_3G:1;
520 u8 reserved_0:4;
521 u8 reserved_1[6];
522 u8 port_count;
523 u64 port_addr[8];
524
525 } __attribute__ ((packed)) host_interface;
526
527 /*
528 * Device (backend) interface information
529 */
530 struct {
531
532 u8 SPI:1;
533 u8 SAS_3G:1;
534 u8 SATA_1_5G:1;
535 u8 SATA_3G:1;
536 u8 reserved_0:4;
537 u8 reserved_1[6];
538 u8 port_count;
539 u64 port_addr[8];
540
541 } __attribute__ ((packed)) device_interface;
542
543 /*
544 * List of components residing in flash. All str are null terminated
545 */
546 u32 image_check_word;
547 u32 image_component_count;
548
549 struct {
550
551 char name[8];
552 char version[32];
553 char build_date[16];
554 char built_time[16];
555
556 } __attribute__ ((packed)) image_component[8];
557
558 /*
559 * List of flash components that have been flashed on the card, but
560 * are not in use, pending reset of the adapter. This list will be
561 * empty if a flash operation has not occurred. All stings are null
562 * terminated
563 */
564 u32 pending_image_component_count;
565
566 struct {
567
568 char name[8];
569 char version[32];
570 char build_date[16];
571 char build_time[16];
572
573 } __attribute__ ((packed)) pending_image_component[8];
574
575 u8 max_arms;
576 u8 max_spans;
577 u8 max_arrays;
578 u8 max_lds;
579
580 char product_name[80];
581 char serial_no[32];
582
583 /*
584 * Other physical/controller/operation information. Indicates the
585 * presence of the hardware
586 */
587 struct {
588
589 u32 bbu:1;
590 u32 alarm:1;
591 u32 nvram:1;
592 u32 uart:1;
593 u32 reserved:28;
594
595 } __attribute__ ((packed)) hw_present;
596
597 u32 current_fw_time;
598
599 /*
600 * Maximum data transfer sizes
601 */
602 u16 max_concurrent_cmds;
603 u16 max_sge_count;
604 u32 max_request_size;
605
606 /*
607 * Logical and physical device counts
608 */
609 u16 ld_present_count;
610 u16 ld_degraded_count;
611 u16 ld_offline_count;
612
613 u16 pd_present_count;
614 u16 pd_disk_present_count;
615 u16 pd_disk_pred_failure_count;
616 u16 pd_disk_failed_count;
617
618 /*
619 * Memory size information
620 */
621 u16 nvram_size;
622 u16 memory_size;
623 u16 flash_size;
624
625 /*
626 * Error counters
627 */
628 u16 mem_correctable_error_count;
629 u16 mem_uncorrectable_error_count;
630
631 /*
632 * Cluster information
633 */
634 u8 cluster_permitted;
635 u8 cluster_active;
636
637 /*
638 * Additional max data transfer sizes
639 */
640 u16 max_strips_per_io;
641
642 /*
643 * Controller capabilities structures
644 */
645 struct {
646
647 u32 raid_level_0:1;
648 u32 raid_level_1:1;
649 u32 raid_level_5:1;
650 u32 raid_level_1E:1;
651 u32 raid_level_6:1;
652 u32 reserved:27;
653
654 } __attribute__ ((packed)) raid_levels;
655
656 struct {
657
658 u32 rbld_rate:1;
659 u32 cc_rate:1;
660 u32 bgi_rate:1;
661 u32 recon_rate:1;
662 u32 patrol_rate:1;
663 u32 alarm_control:1;
664 u32 cluster_supported:1;
665 u32 bbu:1;
666 u32 spanning_allowed:1;
667 u32 dedicated_hotspares:1;
668 u32 revertible_hotspares:1;
669 u32 foreign_config_import:1;
670 u32 self_diagnostic:1;
671 u32 mixed_redundancy_arr:1;
672 u32 global_hot_spares:1;
673 u32 reserved:17;
674
675 } __attribute__ ((packed)) adapter_operations;
676
677 struct {
678
679 u32 read_policy:1;
680 u32 write_policy:1;
681 u32 io_policy:1;
682 u32 access_policy:1;
683 u32 disk_cache_policy:1;
684 u32 reserved:27;
685
686 } __attribute__ ((packed)) ld_operations;
687
688 struct {
689
690 u8 min;
691 u8 max;
692 u8 reserved[2];
693
694 } __attribute__ ((packed)) stripe_sz_ops;
695
696 struct {
697
698 u32 force_online:1;
699 u32 force_offline:1;
700 u32 force_rebuild:1;
701 u32 reserved:29;
702
703 } __attribute__ ((packed)) pd_operations;
704
705 struct {
706
707 u32 ctrl_supports_sas:1;
708 u32 ctrl_supports_sata:1;
709 u32 allow_mix_in_encl:1;
710 u32 allow_mix_in_ld:1;
711 u32 allow_sata_in_cluster:1;
712 u32 reserved:27;
713
714 } __attribute__ ((packed)) pd_mix_support;
715
716 /*
717 * Define ECC single-bit-error bucket information
718 */
719 u8 ecc_bucket_count;
720 u8 reserved_2[11];
721
722 /*
723 * Include the controller properties (changeable items)
724 */
725 struct megasas_ctrl_prop properties;
726
727 /*
728 * Define FW pkg version (set in envt v'bles on OEM basis)
729 */
730 char package_version[0x60];
731
732 u8 pad[0x800 - 0x6a0];
733
Yang, Bo81e403c2009-10-06 14:27:54 -0600734} __packed;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400735
736/*
737 * ===============================
738 * MegaRAID SAS driver definitions
739 * ===============================
740 */
741#define MEGASAS_MAX_PD_CHANNELS 2
742#define MEGASAS_MAX_LD_CHANNELS 2
743#define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
744 MEGASAS_MAX_LD_CHANNELS)
745#define MEGASAS_MAX_DEV_PER_CHANNEL 128
746#define MEGASAS_DEFAULT_INIT_ID -1
747#define MEGASAS_MAX_LUN 8
748#define MEGASAS_MAX_LD 64
adam radford6bf579a2011-10-08 18:14:33 -0700749#define MEGASAS_DEFAULT_CMD_PER_LUN 256
Yang, Bo81e403c2009-10-06 14:27:54 -0600750#define MEGASAS_MAX_PD (MEGASAS_MAX_PD_CHANNELS * \
751 MEGASAS_MAX_DEV_PER_CHANNEL)
Yang, Bobdc6fb82009-12-06 08:30:19 -0700752#define MEGASAS_MAX_LD_IDS (MEGASAS_MAX_LD_CHANNELS * \
753 MEGASAS_MAX_DEV_PER_CHANNEL)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400754
Yang, Bo1fd10682010-10-12 07:18:50 -0600755#define MEGASAS_MAX_SECTORS (2*1024)
adam radford42a8d2b2011-02-24 20:57:09 -0800756#define MEGASAS_MAX_SECTORS_IEEE (2*128)
Sumant Patro658dced2006-10-03 13:09:14 -0700757#define MEGASAS_DBG_LVL 1
758
Sumant Patro05e9ebb2007-05-17 05:47:51 -0700759#define MEGASAS_FW_BUSY 1
760
bo yangd532dbe2008-03-17 03:36:43 -0400761/* Frame Type */
762#define IO_FRAME 0
763#define PTHRU_FRAME 1
764
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400765/*
766 * When SCSI mid-layer calls driver's reset routine, driver waits for
767 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
768 * that the driver cannot _actually_ abort or reset pending commands. While
769 * it is waiting for the commands to complete, it prints a diagnostic message
770 * every MEGASAS_RESET_NOTICE_INTERVAL seconds
771 */
772#define MEGASAS_RESET_WAIT_TIME 180
Sumant Patro2a3681e2006-10-03 13:19:21 -0700773#define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400774#define MEGASAS_RESET_NOTICE_INTERVAL 5
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400775#define MEGASAS_IOCTL_CMD 0
Sumant Patro05e9ebb2007-05-17 05:47:51 -0700776#define MEGASAS_DEFAULT_CMD_TIMEOUT 90
adam radfordc5daa6a2012-07-17 18:20:03 -0700777#define MEGASAS_THROTTLE_QUEUE_DEPTH 16
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400778
779/*
780 * FW reports the maximum of number of commands that it can accept (maximum
781 * commands that can be outstanding) at any time. The driver must report a
782 * lower number to the mid layer because it can issue a few internal commands
783 * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
784 * is shown below
785 */
786#define MEGASAS_INT_CMDS 32
Yang, Bo7bebf5c2009-10-06 14:40:58 -0600787#define MEGASAS_SKINNY_INT_CMDS 5
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400788
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +0530789#define MEGASAS_MAX_MSIX_QUEUES 128
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400790/*
791 * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
792 * SGLs based on the size of dma_addr_t
793 */
794#define IS_DMA64 (sizeof(dma_addr_t) == 8)
795
bo yang39a98552010-09-22 22:36:29 -0400796#define MFI_XSCALE_OMR0_CHANGE_INTERRUPT 0x00000001
797
798#define MFI_INTR_FLAG_REPLY_MESSAGE 0x00000001
799#define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE 0x00000002
800#define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT 0x00000004
801
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400802#define MFI_OB_INTR_STATUS_MASK 0x00000002
bo yang14faea92007-11-09 04:14:00 -0500803#define MFI_POLL_TIMEOUT_SECS 60
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400804
Sumant Patrof9876f02006-02-03 15:34:35 -0800805#define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
Yang, Bo6610a6b2008-08-10 12:42:38 -0700806#define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
807#define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
Yang, Bo87911122009-10-06 14:31:54 -0600808#define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
809#define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
Sumant Patro0e989362006-06-20 15:32:37 -0700810
bo yang39a98552010-09-22 22:36:29 -0400811#define MFI_1068_PCSR_OFFSET 0x84
812#define MFI_1068_FW_HANDSHAKE_OFFSET 0x64
813#define MFI_1068_FW_READY 0xDDDD0000
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +0530814
815#define MR_MAX_REPLY_QUEUES_OFFSET 0X0000001F
816#define MR_MAX_REPLY_QUEUES_EXT_OFFSET 0X003FC000
817#define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT 14
818#define MR_MAX_MSIX_REG_ARRAY 16
Sumant Patro0e989362006-06-20 15:32:37 -0700819/*
820* register set for both 1068 and 1078 controllers
821* structure extended for 1078 registers
822*/
Sumant Patrof9876f02006-02-03 15:34:35 -0800823
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400824struct megasas_register_set {
adam radford9c915a82010-12-21 13:34:31 -0800825 u32 doorbell; /*0000h*/
826 u32 fusion_seq_offset; /*0004h*/
827 u32 fusion_host_diag; /*0008h*/
828 u32 reserved_01; /*000Ch*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400829
Sumant Patrof9876f02006-02-03 15:34:35 -0800830 u32 inbound_msg_0; /*0010h*/
831 u32 inbound_msg_1; /*0014h*/
832 u32 outbound_msg_0; /*0018h*/
833 u32 outbound_msg_1; /*001Ch*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400834
Sumant Patrof9876f02006-02-03 15:34:35 -0800835 u32 inbound_doorbell; /*0020h*/
836 u32 inbound_intr_status; /*0024h*/
837 u32 inbound_intr_mask; /*0028h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400838
Sumant Patrof9876f02006-02-03 15:34:35 -0800839 u32 outbound_doorbell; /*002Ch*/
840 u32 outbound_intr_status; /*0030h*/
841 u32 outbound_intr_mask; /*0034h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400842
Sumant Patrof9876f02006-02-03 15:34:35 -0800843 u32 reserved_1[2]; /*0038h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400844
Sumant Patrof9876f02006-02-03 15:34:35 -0800845 u32 inbound_queue_port; /*0040h*/
846 u32 outbound_queue_port; /*0044h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400847
adam radford9c915a82010-12-21 13:34:31 -0800848 u32 reserved_2[9]; /*0048h*/
849 u32 reply_post_host_index; /*006Ch*/
850 u32 reserved_2_2[12]; /*0070h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400851
Sumant Patrof9876f02006-02-03 15:34:35 -0800852 u32 outbound_doorbell_clear; /*00A0h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400853
Sumant Patrof9876f02006-02-03 15:34:35 -0800854 u32 reserved_3[3]; /*00A4h*/
855
856 u32 outbound_scratch_pad ; /*00B0h*/
adam radford9c915a82010-12-21 13:34:31 -0800857 u32 outbound_scratch_pad_2; /*00B4h*/
Sumant Patrof9876f02006-02-03 15:34:35 -0800858
adam radford9c915a82010-12-21 13:34:31 -0800859 u32 reserved_4[2]; /*00B8h*/
Sumant Patrof9876f02006-02-03 15:34:35 -0800860
861 u32 inbound_low_queue_port ; /*00C0h*/
862
863 u32 inbound_high_queue_port ; /*00C4h*/
864
865 u32 reserved_5; /*00C8h*/
bo yang39a98552010-09-22 22:36:29 -0400866 u32 res_6[11]; /*CCh*/
867 u32 host_diag;
868 u32 seq_offset;
869 u32 index_registers[807]; /*00CCh*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400870} __attribute__ ((packed));
871
872struct megasas_sge32 {
873
874 u32 phys_addr;
875 u32 length;
876
877} __attribute__ ((packed));
878
879struct megasas_sge64 {
880
881 u64 phys_addr;
882 u32 length;
883
884} __attribute__ ((packed));
885
Yang, Bof4c9a132009-10-06 14:43:28 -0600886struct megasas_sge_skinny {
887 u64 phys_addr;
888 u32 length;
889 u32 flag;
890} __packed;
891
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400892union megasas_sgl {
893
894 struct megasas_sge32 sge32[1];
895 struct megasas_sge64 sge64[1];
Yang, Bof4c9a132009-10-06 14:43:28 -0600896 struct megasas_sge_skinny sge_skinny[1];
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400897
898} __attribute__ ((packed));
899
900struct megasas_header {
901
902 u8 cmd; /*00h */
903 u8 sense_len; /*01h */
904 u8 cmd_status; /*02h */
905 u8 scsi_status; /*03h */
906
907 u8 target_id; /*04h */
908 u8 lun; /*05h */
909 u8 cdb_len; /*06h */
910 u8 sge_count; /*07h */
911
912 u32 context; /*08h */
913 u32 pad_0; /*0Ch */
914
915 u16 flags; /*10h */
916 u16 timeout; /*12h */
917 u32 data_xferlen; /*14h */
918
919} __attribute__ ((packed));
920
921union megasas_sgl_frame {
922
923 struct megasas_sge32 sge32[8];
924 struct megasas_sge64 sge64[5];
925
926} __attribute__ ((packed));
927
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +0530928typedef union _MFI_CAPABILITIES {
929 struct {
930 u32 support_fp_remote_lun:1;
931 u32 support_additional_msix:1;
932 u32 reserved:30;
933 } mfi_capabilities;
934 u32 reg;
935} MFI_CAPABILITIES;
936
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400937struct megasas_init_frame {
938
939 u8 cmd; /*00h */
940 u8 reserved_0; /*01h */
941 u8 cmd_status; /*02h */
942
943 u8 reserved_1; /*03h */
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +0530944 MFI_CAPABILITIES driver_operations; /*04h*/
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -0400945
946 u32 context; /*08h */
947 u32 pad_0; /*0Ch */
948
949 u16 flags; /*10h */
950 u16 reserved_3; /*12h */
951 u32 data_xfer_len; /*14h */
952
953 u32 queue_info_new_phys_addr_lo; /*18h */
954 u32 queue_info_new_phys_addr_hi; /*1Ch */
955 u32 queue_info_old_phys_addr_lo; /*20h */
956 u32 queue_info_old_phys_addr_hi; /*24h */
957
958 u32 reserved_4[6]; /*28h */
959
960} __attribute__ ((packed));
961
962struct megasas_init_queue_info {
963
964 u32 init_flags; /*00h */
965 u32 reply_queue_entries; /*04h */
966
967 u32 reply_queue_start_phys_addr_lo; /*08h */
968 u32 reply_queue_start_phys_addr_hi; /*0Ch */
969 u32 producer_index_phys_addr_lo; /*10h */
970 u32 producer_index_phys_addr_hi; /*14h */
971 u32 consumer_index_phys_addr_lo; /*18h */
972 u32 consumer_index_phys_addr_hi; /*1Ch */
973
974} __attribute__ ((packed));
975
976struct megasas_io_frame {
977
978 u8 cmd; /*00h */
979 u8 sense_len; /*01h */
980 u8 cmd_status; /*02h */
981 u8 scsi_status; /*03h */
982
983 u8 target_id; /*04h */
984 u8 access_byte; /*05h */
985 u8 reserved_0; /*06h */
986 u8 sge_count; /*07h */
987
988 u32 context; /*08h */
989 u32 pad_0; /*0Ch */
990
991 u16 flags; /*10h */
992 u16 timeout; /*12h */
993 u32 lba_count; /*14h */
994
995 u32 sense_buf_phys_addr_lo; /*18h */
996 u32 sense_buf_phys_addr_hi; /*1Ch */
997
998 u32 start_lba_lo; /*20h */
999 u32 start_lba_hi; /*24h */
1000
1001 union megasas_sgl sgl; /*28h */
1002
1003} __attribute__ ((packed));
1004
1005struct megasas_pthru_frame {
1006
1007 u8 cmd; /*00h */
1008 u8 sense_len; /*01h */
1009 u8 cmd_status; /*02h */
1010 u8 scsi_status; /*03h */
1011
1012 u8 target_id; /*04h */
1013 u8 lun; /*05h */
1014 u8 cdb_len; /*06h */
1015 u8 sge_count; /*07h */
1016
1017 u32 context; /*08h */
1018 u32 pad_0; /*0Ch */
1019
1020 u16 flags; /*10h */
1021 u16 timeout; /*12h */
1022 u32 data_xfer_len; /*14h */
1023
1024 u32 sense_buf_phys_addr_lo; /*18h */
1025 u32 sense_buf_phys_addr_hi; /*1Ch */
1026
1027 u8 cdb[16]; /*20h */
1028 union megasas_sgl sgl; /*30h */
1029
1030} __attribute__ ((packed));
1031
1032struct megasas_dcmd_frame {
1033
1034 u8 cmd; /*00h */
1035 u8 reserved_0; /*01h */
1036 u8 cmd_status; /*02h */
1037 u8 reserved_1[4]; /*03h */
1038 u8 sge_count; /*07h */
1039
1040 u32 context; /*08h */
1041 u32 pad_0; /*0Ch */
1042
1043 u16 flags; /*10h */
1044 u16 timeout; /*12h */
1045
1046 u32 data_xfer_len; /*14h */
1047 u32 opcode; /*18h */
1048
1049 union { /*1Ch */
1050 u8 b[12];
1051 u16 s[6];
1052 u32 w[3];
1053 } mbox;
1054
1055 union megasas_sgl sgl; /*28h */
1056
1057} __attribute__ ((packed));
1058
1059struct megasas_abort_frame {
1060
1061 u8 cmd; /*00h */
1062 u8 reserved_0; /*01h */
1063 u8 cmd_status; /*02h */
1064
1065 u8 reserved_1; /*03h */
1066 u32 reserved_2; /*04h */
1067
1068 u32 context; /*08h */
1069 u32 pad_0; /*0Ch */
1070
1071 u16 flags; /*10h */
1072 u16 reserved_3; /*12h */
1073 u32 reserved_4; /*14h */
1074
1075 u32 abort_context; /*18h */
1076 u32 pad_1; /*1Ch */
1077
1078 u32 abort_mfi_phys_addr_lo; /*20h */
1079 u32 abort_mfi_phys_addr_hi; /*24h */
1080
1081 u32 reserved_5[6]; /*28h */
1082
1083} __attribute__ ((packed));
1084
1085struct megasas_smp_frame {
1086
1087 u8 cmd; /*00h */
1088 u8 reserved_1; /*01h */
1089 u8 cmd_status; /*02h */
1090 u8 connection_status; /*03h */
1091
1092 u8 reserved_2[3]; /*04h */
1093 u8 sge_count; /*07h */
1094
1095 u32 context; /*08h */
1096 u32 pad_0; /*0Ch */
1097
1098 u16 flags; /*10h */
1099 u16 timeout; /*12h */
1100
1101 u32 data_xfer_len; /*14h */
1102 u64 sas_addr; /*18h */
1103
1104 union {
1105 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
1106 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
1107 } sgl;
1108
1109} __attribute__ ((packed));
1110
1111struct megasas_stp_frame {
1112
1113 u8 cmd; /*00h */
1114 u8 reserved_1; /*01h */
1115 u8 cmd_status; /*02h */
1116 u8 reserved_2; /*03h */
1117
1118 u8 target_id; /*04h */
1119 u8 reserved_3[2]; /*05h */
1120 u8 sge_count; /*07h */
1121
1122 u32 context; /*08h */
1123 u32 pad_0; /*0Ch */
1124
1125 u16 flags; /*10h */
1126 u16 timeout; /*12h */
1127
1128 u32 data_xfer_len; /*14h */
1129
1130 u16 fis[10]; /*18h */
1131 u32 stp_flags;
1132
1133 union {
1134 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
1135 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
1136 } sgl;
1137
1138} __attribute__ ((packed));
1139
1140union megasas_frame {
1141
1142 struct megasas_header hdr;
1143 struct megasas_init_frame init;
1144 struct megasas_io_frame io;
1145 struct megasas_pthru_frame pthru;
1146 struct megasas_dcmd_frame dcmd;
1147 struct megasas_abort_frame abort;
1148 struct megasas_smp_frame smp;
1149 struct megasas_stp_frame stp;
1150
1151 u8 raw_bytes[64];
1152};
1153
1154struct megasas_cmd;
1155
1156union megasas_evt_class_locale {
1157
1158 struct {
1159 u16 locale;
1160 u8 reserved;
1161 s8 class;
1162 } __attribute__ ((packed)) members;
1163
1164 u32 word;
1165
1166} __attribute__ ((packed));
1167
1168struct megasas_evt_log_info {
1169 u32 newest_seq_num;
1170 u32 oldest_seq_num;
1171 u32 clear_seq_num;
1172 u32 shutdown_seq_num;
1173 u32 boot_seq_num;
1174
1175} __attribute__ ((packed));
1176
1177struct megasas_progress {
1178
1179 u16 progress;
1180 u16 elapsed_seconds;
1181
1182} __attribute__ ((packed));
1183
1184struct megasas_evtarg_ld {
1185
1186 u16 target_id;
1187 u8 ld_index;
1188 u8 reserved;
1189
1190} __attribute__ ((packed));
1191
1192struct megasas_evtarg_pd {
1193 u16 device_id;
1194 u8 encl_index;
1195 u8 slot_number;
1196
1197} __attribute__ ((packed));
1198
1199struct megasas_evt_detail {
1200
1201 u32 seq_num;
1202 u32 time_stamp;
1203 u32 code;
1204 union megasas_evt_class_locale cl;
1205 u8 arg_type;
1206 u8 reserved1[15];
1207
1208 union {
1209 struct {
1210 struct megasas_evtarg_pd pd;
1211 u8 cdb_length;
1212 u8 sense_length;
1213 u8 reserved[2];
1214 u8 cdb[16];
1215 u8 sense[64];
1216 } __attribute__ ((packed)) cdbSense;
1217
1218 struct megasas_evtarg_ld ld;
1219
1220 struct {
1221 struct megasas_evtarg_ld ld;
1222 u64 count;
1223 } __attribute__ ((packed)) ld_count;
1224
1225 struct {
1226 u64 lba;
1227 struct megasas_evtarg_ld ld;
1228 } __attribute__ ((packed)) ld_lba;
1229
1230 struct {
1231 struct megasas_evtarg_ld ld;
1232 u32 prevOwner;
1233 u32 newOwner;
1234 } __attribute__ ((packed)) ld_owner;
1235
1236 struct {
1237 u64 ld_lba;
1238 u64 pd_lba;
1239 struct megasas_evtarg_ld ld;
1240 struct megasas_evtarg_pd pd;
1241 } __attribute__ ((packed)) ld_lba_pd_lba;
1242
1243 struct {
1244 struct megasas_evtarg_ld ld;
1245 struct megasas_progress prog;
1246 } __attribute__ ((packed)) ld_prog;
1247
1248 struct {
1249 struct megasas_evtarg_ld ld;
1250 u32 prev_state;
1251 u32 new_state;
1252 } __attribute__ ((packed)) ld_state;
1253
1254 struct {
1255 u64 strip;
1256 struct megasas_evtarg_ld ld;
1257 } __attribute__ ((packed)) ld_strip;
1258
1259 struct megasas_evtarg_pd pd;
1260
1261 struct {
1262 struct megasas_evtarg_pd pd;
1263 u32 err;
1264 } __attribute__ ((packed)) pd_err;
1265
1266 struct {
1267 u64 lba;
1268 struct megasas_evtarg_pd pd;
1269 } __attribute__ ((packed)) pd_lba;
1270
1271 struct {
1272 u64 lba;
1273 struct megasas_evtarg_pd pd;
1274 struct megasas_evtarg_ld ld;
1275 } __attribute__ ((packed)) pd_lba_ld;
1276
1277 struct {
1278 struct megasas_evtarg_pd pd;
1279 struct megasas_progress prog;
1280 } __attribute__ ((packed)) pd_prog;
1281
1282 struct {
1283 struct megasas_evtarg_pd pd;
1284 u32 prevState;
1285 u32 newState;
1286 } __attribute__ ((packed)) pd_state;
1287
1288 struct {
1289 u16 vendorId;
1290 u16 deviceId;
1291 u16 subVendorId;
1292 u16 subDeviceId;
1293 } __attribute__ ((packed)) pci;
1294
1295 u32 rate;
1296 char str[96];
1297
1298 struct {
1299 u32 rtc;
1300 u32 elapsedSeconds;
1301 } __attribute__ ((packed)) time;
1302
1303 struct {
1304 u32 ecar;
1305 u32 elog;
1306 char str[64];
1307 } __attribute__ ((packed)) ecc;
1308
1309 u8 b[96];
1310 u16 s[48];
1311 u32 w[24];
1312 u64 d[12];
1313 } args;
1314
1315 char description[128];
1316
1317} __attribute__ ((packed));
1318
Yang, Bo7e8a75f2009-10-06 14:50:17 -06001319struct megasas_aen_event {
Xiaotian Fengc1d390d82012-12-04 19:33:54 +08001320 struct delayed_work hotplug_work;
Yang, Bo7e8a75f2009-10-06 14:50:17 -06001321 struct megasas_instance *instance;
1322};
1323
adam radfordc8e858f2011-10-08 18:15:13 -07001324struct megasas_irq_context {
1325 struct megasas_instance *instance;
1326 u32 MSIxIndex;
1327};
1328
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001329struct megasas_instance {
1330
1331 u32 *producer;
1332 dma_addr_t producer_h;
1333 u32 *consumer;
1334 dma_addr_t consumer_h;
1335
1336 u32 *reply_queue;
1337 dma_addr_t reply_queue_h;
1338
1339 unsigned long base_addr;
1340 struct megasas_register_set __iomem *reg_set;
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +05301341 u32 *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
Yang, Bo81e403c2009-10-06 14:27:54 -06001342 struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
Yang, Bobdc6fb82009-12-06 08:30:19 -07001343 u8 ld_ids[MEGASAS_MAX_LD_IDS];
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001344 s8 init_id;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001345
1346 u16 max_num_sge;
1347 u16 max_fw_cmds;
adam radford9c915a82010-12-21 13:34:31 -08001348 /* For Fusion its num IOCTL cmds, for others MFI based its
1349 max_fw_cmds */
1350 u16 max_mfi_cmds;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001351 u32 max_sectors_per_req;
Yang, Bo7e8a75f2009-10-06 14:50:17 -06001352 struct megasas_aen_event *ev;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001353
1354 struct megasas_cmd **cmd_list;
1355 struct list_head cmd_pool;
bo yang39a98552010-09-22 22:36:29 -04001356 /* used to sync fire the cmd to fw */
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001357 spinlock_t cmd_pool_lock;
bo yang39a98552010-09-22 22:36:29 -04001358 /* used to sync fire the cmd to fw */
1359 spinlock_t hba_lock;
bo yang7343eb62007-11-09 04:35:44 -05001360 /* used to synch producer, consumer ptrs in dpc */
1361 spinlock_t completion_lock;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001362 struct dma_pool *frame_dma_pool;
1363 struct dma_pool *sense_dma_pool;
1364
1365 struct megasas_evt_detail *evt_detail;
1366 dma_addr_t evt_detail_h;
1367 struct megasas_cmd *aen_cmd;
Matthias Kaehlckee5a69e22007-10-27 09:48:46 +02001368 struct mutex aen_mutex;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001369 struct semaphore ioctl_sem;
1370
1371 struct Scsi_Host *host;
1372
1373 wait_queue_head_t int_cmd_wait_q;
1374 wait_queue_head_t abort_cmd_wait_q;
1375
1376 struct pci_dev *pdev;
1377 u32 unique_id;
bo yang39a98552010-09-22 22:36:29 -04001378 u32 fw_support_ieee;
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001379
Sumant Patroe4a082c2006-05-30 12:03:37 -07001380 atomic_t fw_outstanding;
bo yang39a98552010-09-22 22:36:29 -04001381 atomic_t fw_reset_no_pci_access;
Sumant Patro1341c932006-01-25 12:02:40 -08001382
1383 struct megasas_instance_template *instancet;
Sumant Patro5d018ad2006-10-03 13:13:18 -07001384 struct tasklet_struct isr_tasklet;
bo yang39a98552010-09-22 22:36:29 -04001385 struct work_struct work_init;
Sumant Patro05e9ebb2007-05-17 05:47:51 -07001386
1387 u8 flag;
Yang, Boc3518832009-10-06 14:18:02 -06001388 u8 unload;
Yang, Bof4c9a132009-10-06 14:43:28 -06001389 u8 flag_ieee;
bo yang39a98552010-09-22 22:36:29 -04001390 u8 issuepend_done;
1391 u8 disableOnlineCtrlReset;
1392 u8 adprecovery;
Sumant Patro05e9ebb2007-05-17 05:47:51 -07001393 unsigned long last_time;
bo yang39a98552010-09-22 22:36:29 -04001394 u32 mfiStatus;
1395 u32 last_seq_num;
bo yangad84db22007-11-09 04:40:16 -05001396
bo yang39a98552010-09-22 22:36:29 -04001397 struct list_head internal_reset_pending_q;
adam radford80d9da92010-12-21 10:17:40 -08001398
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001399 /* Ptr to hba specific information */
adam radford9c915a82010-12-21 13:34:31 -08001400 void *ctrl_context;
adam radfordc8e858f2011-10-08 18:15:13 -07001401 unsigned int msix_vectors;
1402 struct msix_entry msixentry[MEGASAS_MAX_MSIX_QUEUES];
1403 struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
adam radford9c915a82010-12-21 13:34:31 -08001404 u64 map_id;
1405 struct megasas_cmd *map_update_cmd;
adam radfordb6d5d882010-12-14 18:56:07 -08001406 unsigned long bar;
adam radford9c915a82010-12-21 13:34:31 -08001407 long reset_flags;
1408 struct mutex reset_mutex;
adam radfordc5daa6a2012-07-17 18:20:03 -07001409 int throttlequeuedepth;
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +05301410 u8 mask_interrupts;
bo yang39a98552010-09-22 22:36:29 -04001411};
1412
1413enum {
1414 MEGASAS_HBA_OPERATIONAL = 0,
1415 MEGASAS_ADPRESET_SM_INFAULT = 1,
1416 MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS = 2,
1417 MEGASAS_ADPRESET_SM_OPERATIONAL = 3,
1418 MEGASAS_HW_CRITICAL_ERROR = 4,
1419 MEGASAS_ADPRESET_INPROG_SIGN = 0xDEADDEAD,
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001420};
1421
Yang, Bo0c79e682009-10-06 14:47:35 -06001422struct megasas_instance_template {
1423 void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
1424 u32, struct megasas_register_set __iomem *);
1425
Sumit.Saxena@lsi.comd46a3ad2013-05-22 12:34:14 +05301426 void (*enable_intr)(struct megasas_instance *);
1427 void (*disable_intr)(struct megasas_instance *);
Yang, Bo0c79e682009-10-06 14:47:35 -06001428
1429 int (*clear_intr)(struct megasas_register_set __iomem *);
1430
1431 u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
bo yang39a98552010-09-22 22:36:29 -04001432 int (*adp_reset)(struct megasas_instance *, \
1433 struct megasas_register_set __iomem *);
1434 int (*check_reset)(struct megasas_instance *, \
1435 struct megasas_register_set __iomem *);
adam radfordcd50ba82010-12-21 10:23:23 -08001436 irqreturn_t (*service_isr)(int irq, void *devp);
1437 void (*tasklet)(unsigned long);
1438 u32 (*init_adapter)(struct megasas_instance *);
1439 u32 (*build_and_issue_cmd) (struct megasas_instance *,
1440 struct scsi_cmnd *);
1441 void (*issue_dcmd) (struct megasas_instance *instance,
1442 struct megasas_cmd *cmd);
Yang, Bo0c79e682009-10-06 14:47:35 -06001443};
1444
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001445#define MEGASAS_IS_LOGICAL(scp) \
1446 (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
1447
1448#define MEGASAS_DEV_INDEX(inst, scp) \
1449 ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
1450 scp->device->id
1451
1452struct megasas_cmd {
1453
1454 union megasas_frame *frame;
1455 dma_addr_t frame_phys_addr;
1456 u8 *sense;
1457 dma_addr_t sense_phys_addr;
1458
1459 u32 index;
1460 u8 sync_cmd;
1461 u8 cmd_status;
bo yang39a98552010-09-22 22:36:29 -04001462 u8 abort_aen;
1463 u8 retry_for_fw_reset;
1464
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001465
1466 struct list_head list;
1467 struct scsi_cmnd *scmd;
1468 struct megasas_instance *instance;
adam radford9c915a82010-12-21 13:34:31 -08001469 union {
1470 struct {
1471 u16 smid;
1472 u16 resvd;
1473 } context;
1474 u32 frame_count;
1475 };
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001476};
1477
1478#define MAX_MGMT_ADAPTERS 1024
1479#define MAX_IOCTL_SGE 16
1480
1481struct megasas_iocpacket {
1482
1483 u16 host_no;
1484 u16 __pad1;
1485 u32 sgl_off;
1486 u32 sge_count;
1487 u32 sense_off;
1488 u32 sense_len;
1489 union {
1490 u8 raw[128];
1491 struct megasas_header hdr;
1492 } frame;
1493
1494 struct iovec sgl[MAX_IOCTL_SGE];
1495
1496} __attribute__ ((packed));
1497
1498struct megasas_aen {
1499 u16 host_no;
1500 u16 __pad1;
1501 u32 seq_num;
1502 u32 class_locale_word;
1503} __attribute__ ((packed));
1504
1505#ifdef CONFIG_COMPAT
1506struct compat_megasas_iocpacket {
1507 u16 host_no;
1508 u16 __pad1;
1509 u32 sgl_off;
1510 u32 sge_count;
1511 u32 sense_off;
1512 u32 sense_len;
1513 union {
1514 u8 raw[128];
1515 struct megasas_header hdr;
1516 } frame;
1517 struct compat_iovec sgl[MAX_IOCTL_SGE];
1518} __attribute__ ((packed));
1519
Sumant Patro0e989362006-06-20 15:32:37 -07001520#define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001521#endif
1522
Sumant Patrocb59aa62006-01-25 11:53:25 -08001523#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001524#define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
1525
1526struct megasas_mgmt_info {
1527
1528 u16 count;
1529 struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
1530 int max_index;
1531};
1532
Bagalkote, Sreenivasc4a3e0a2005-09-20 17:46:58 -04001533#endif /*LSI_MEGARAID_SAS_H */