megaraid_sas.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458
  1. /*
  2. * Linux MegaRAID driver for SAS based RAID controllers
  3. *
  4. * Copyright (c) 2009-2011 LSI Corporation.
  5. *
  6. * 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.
  10. *
  11. * 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.
  15. *
  16. * 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
  28. */
  29. #ifndef LSI_MEGARAID_SAS_H
  30. #define LSI_MEGARAID_SAS_H
  31. /*
  32. * MegaRAID SAS Driver meta data
  33. */
  34. #define MEGASAS_VERSION "00.00.04.31-rc1"
  35. #define MEGASAS_RELDATE "May 3, 2010"
  36. #define MEGASAS_EXT_VERSION "Mon. May 3, 11:41:51 PST 2010"
  37. /*
  38. * Device IDs
  39. */
  40. #define PCI_DEVICE_ID_LSI_SAS1078R 0x0060
  41. #define PCI_DEVICE_ID_LSI_SAS1078DE 0x007C
  42. #define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413
  43. #define PCI_DEVICE_ID_LSI_SAS1078GEN2 0x0078
  44. #define PCI_DEVICE_ID_LSI_SAS0079GEN2 0x0079
  45. #define PCI_DEVICE_ID_LSI_SAS0073SKINNY 0x0073
  46. #define PCI_DEVICE_ID_LSI_SAS0071SKINNY 0x0071
  47. /*
  48. * =====================================
  49. * MegaRAID SAS MFI firmware definitions
  50. * =====================================
  51. */
  52. /*
  53. * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
  54. * protocol between the software and firmware. Commands are issued using
  55. * "message frames"
  56. */
  57. /*
  58. * FW posts its state in upper 4 bits of outbound_msg_0 register
  59. */
  60. #define MFI_STATE_MASK 0xF0000000
  61. #define MFI_STATE_UNDEFINED 0x00000000
  62. #define MFI_STATE_BB_INIT 0x10000000
  63. #define MFI_STATE_FW_INIT 0x40000000
  64. #define MFI_STATE_WAIT_HANDSHAKE 0x60000000
  65. #define MFI_STATE_FW_INIT_2 0x70000000
  66. #define MFI_STATE_DEVICE_SCAN 0x80000000
  67. #define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000
  68. #define MFI_STATE_FLUSH_CACHE 0xA0000000
  69. #define MFI_STATE_READY 0xB0000000
  70. #define MFI_STATE_OPERATIONAL 0xC0000000
  71. #define MFI_STATE_FAULT 0xF0000000
  72. #define MFI_RESET_REQUIRED 0x00000001
  73. #define MEGAMFI_FRAME_SIZE 64
  74. /*
  75. * During FW init, clear pending cmds & reset state using inbound_msg_0
  76. *
  77. * ABORT : Abort all pending cmds
  78. * READY : Move from OPERATIONAL to READY state; discard queue info
  79. * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
  80. * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
  81. * HOTPLUG : Resume from Hotplug
  82. * MFI_STOP_ADP : Send signal to FW to stop processing
  83. */
  84. #define WRITE_SEQUENCE_OFFSET (0x0000000FC) /* I20 */
  85. #define HOST_DIAGNOSTIC_OFFSET (0x000000F8) /* I20 */
  86. #define DIAG_WRITE_ENABLE (0x00000080)
  87. #define DIAG_RESET_ADAPTER (0x00000004)
  88. #define MFI_ADP_RESET 0x00000040
  89. #define MFI_INIT_ABORT 0x00000001
  90. #define MFI_INIT_READY 0x00000002
  91. #define MFI_INIT_MFIMODE 0x00000004
  92. #define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
  93. #define MFI_INIT_HOTPLUG 0x00000010
  94. #define MFI_STOP_ADP 0x00000020
  95. #define MFI_RESET_FLAGS MFI_INIT_READY| \
  96. MFI_INIT_MFIMODE| \
  97. MFI_INIT_ABORT
  98. /*
  99. * MFI frame flags
  100. */
  101. #define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
  102. #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
  103. #define MFI_FRAME_SGL32 0x0000
  104. #define MFI_FRAME_SGL64 0x0002
  105. #define MFI_FRAME_SENSE32 0x0000
  106. #define MFI_FRAME_SENSE64 0x0004
  107. #define MFI_FRAME_DIR_NONE 0x0000
  108. #define MFI_FRAME_DIR_WRITE 0x0008
  109. #define MFI_FRAME_DIR_READ 0x0010
  110. #define MFI_FRAME_DIR_BOTH 0x0018
  111. #define MFI_FRAME_IEEE 0x0020
  112. /*
  113. * Definition for cmd_status
  114. */
  115. #define MFI_CMD_STATUS_POLL_MODE 0xFF
  116. /*
  117. * MFI command opcodes
  118. */
  119. #define MFI_CMD_INIT 0x00
  120. #define MFI_CMD_LD_READ 0x01
  121. #define MFI_CMD_LD_WRITE 0x02
  122. #define MFI_CMD_LD_SCSI_IO 0x03
  123. #define MFI_CMD_PD_SCSI_IO 0x04
  124. #define MFI_CMD_DCMD 0x05
  125. #define MFI_CMD_ABORT 0x06
  126. #define MFI_CMD_SMP 0x07
  127. #define MFI_CMD_STP 0x08
  128. #define MR_DCMD_CTRL_GET_INFO 0x01010000
  129. #define MR_DCMD_LD_GET_LIST 0x03010000
  130. #define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
  131. #define MR_FLUSH_CTRL_CACHE 0x01
  132. #define MR_FLUSH_DISK_CACHE 0x02
  133. #define MR_DCMD_CTRL_SHUTDOWN 0x01050000
  134. #define MR_DCMD_HIBERNATE_SHUTDOWN 0x01060000
  135. #define MR_ENABLE_DRIVE_SPINDOWN 0x01
  136. #define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
  137. #define MR_DCMD_CTRL_EVENT_GET 0x01040300
  138. #define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
  139. #define MR_DCMD_LD_GET_PROPERTIES 0x03030000
  140. #define MR_DCMD_CLUSTER 0x08000000
  141. #define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
  142. #define MR_DCMD_CLUSTER_RESET_LD 0x08010200
  143. #define MR_DCMD_PD_LIST_QUERY 0x02010100
  144. /*
  145. * MFI command completion codes
  146. */
  147. enum MFI_STAT {
  148. MFI_STAT_OK = 0x00,
  149. MFI_STAT_INVALID_CMD = 0x01,
  150. MFI_STAT_INVALID_DCMD = 0x02,
  151. MFI_STAT_INVALID_PARAMETER = 0x03,
  152. MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
  153. MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
  154. MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
  155. MFI_STAT_APP_IN_USE = 0x07,
  156. MFI_STAT_APP_NOT_INITIALIZED = 0x08,
  157. MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
  158. MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
  159. MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
  160. MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
  161. MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
  162. MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
  163. MFI_STAT_FLASH_BUSY = 0x0f,
  164. MFI_STAT_FLASH_ERROR = 0x10,
  165. MFI_STAT_FLASH_IMAGE_BAD = 0x11,
  166. MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
  167. MFI_STAT_FLASH_NOT_OPEN = 0x13,
  168. MFI_STAT_FLASH_NOT_STARTED = 0x14,
  169. MFI_STAT_FLUSH_FAILED = 0x15,
  170. MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
  171. MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
  172. MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
  173. MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
  174. MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
  175. MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
  176. MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
  177. MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
  178. MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
  179. MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
  180. MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
  181. MFI_STAT_MFC_HW_ERROR = 0x21,
  182. MFI_STAT_NO_HW_PRESENT = 0x22,
  183. MFI_STAT_NOT_FOUND = 0x23,
  184. MFI_STAT_NOT_IN_ENCL = 0x24,
  185. MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
  186. MFI_STAT_PD_TYPE_WRONG = 0x26,
  187. MFI_STAT_PR_DISABLED = 0x27,
  188. MFI_STAT_ROW_INDEX_INVALID = 0x28,
  189. MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
  190. MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
  191. MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
  192. MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
  193. MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
  194. MFI_STAT_SCSI_IO_FAILED = 0x2e,
  195. MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
  196. MFI_STAT_SHUTDOWN_FAILED = 0x30,
  197. MFI_STAT_TIME_NOT_SET = 0x31,
  198. MFI_STAT_WRONG_STATE = 0x32,
  199. MFI_STAT_LD_OFFLINE = 0x33,
  200. MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
  201. MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
  202. MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
  203. MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
  204. MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
  205. MFI_STAT_INVALID_STATUS = 0xFF
  206. };
  207. /*
  208. * Number of mailbox bytes in DCMD message frame
  209. */
  210. #define MFI_MBOX_SIZE 12
  211. enum MR_EVT_CLASS {
  212. MR_EVT_CLASS_DEBUG = -2,
  213. MR_EVT_CLASS_PROGRESS = -1,
  214. MR_EVT_CLASS_INFO = 0,
  215. MR_EVT_CLASS_WARNING = 1,
  216. MR_EVT_CLASS_CRITICAL = 2,
  217. MR_EVT_CLASS_FATAL = 3,
  218. MR_EVT_CLASS_DEAD = 4,
  219. };
  220. enum MR_EVT_LOCALE {
  221. MR_EVT_LOCALE_LD = 0x0001,
  222. MR_EVT_LOCALE_PD = 0x0002,
  223. MR_EVT_LOCALE_ENCL = 0x0004,
  224. MR_EVT_LOCALE_BBU = 0x0008,
  225. MR_EVT_LOCALE_SAS = 0x0010,
  226. MR_EVT_LOCALE_CTRL = 0x0020,
  227. MR_EVT_LOCALE_CONFIG = 0x0040,
  228. MR_EVT_LOCALE_CLUSTER = 0x0080,
  229. MR_EVT_LOCALE_ALL = 0xffff,
  230. };
  231. enum MR_EVT_ARGS {
  232. MR_EVT_ARGS_NONE,
  233. MR_EVT_ARGS_CDB_SENSE,
  234. MR_EVT_ARGS_LD,
  235. MR_EVT_ARGS_LD_COUNT,
  236. MR_EVT_ARGS_LD_LBA,
  237. MR_EVT_ARGS_LD_OWNER,
  238. MR_EVT_ARGS_LD_LBA_PD_LBA,
  239. MR_EVT_ARGS_LD_PROG,
  240. MR_EVT_ARGS_LD_STATE,
  241. MR_EVT_ARGS_LD_STRIP,
  242. MR_EVT_ARGS_PD,
  243. MR_EVT_ARGS_PD_ERR,
  244. MR_EVT_ARGS_PD_LBA,
  245. MR_EVT_ARGS_PD_LBA_LD,
  246. MR_EVT_ARGS_PD_PROG,
  247. MR_EVT_ARGS_PD_STATE,
  248. MR_EVT_ARGS_PCI,
  249. MR_EVT_ARGS_RATE,
  250. MR_EVT_ARGS_STR,
  251. MR_EVT_ARGS_TIME,
  252. MR_EVT_ARGS_ECC,
  253. MR_EVT_ARGS_LD_PROP,
  254. MR_EVT_ARGS_PD_SPARE,
  255. MR_EVT_ARGS_PD_INDEX,
  256. MR_EVT_ARGS_DIAG_PASS,
  257. MR_EVT_ARGS_DIAG_FAIL,
  258. MR_EVT_ARGS_PD_LBA_LBA,
  259. MR_EVT_ARGS_PORT_PHY,
  260. MR_EVT_ARGS_PD_MISSING,
  261. MR_EVT_ARGS_PD_ADDRESS,
  262. MR_EVT_ARGS_BITMAP,
  263. MR_EVT_ARGS_CONNECTOR,
  264. MR_EVT_ARGS_PD_PD,
  265. MR_EVT_ARGS_PD_FRU,
  266. MR_EVT_ARGS_PD_PATHINFO,
  267. MR_EVT_ARGS_PD_POWER_STATE,
  268. MR_EVT_ARGS_GENERIC,
  269. };
  270. /*
  271. * define constants for device list query options
  272. */
  273. enum MR_PD_QUERY_TYPE {
  274. MR_PD_QUERY_TYPE_ALL = 0,
  275. MR_PD_QUERY_TYPE_STATE = 1,
  276. MR_PD_QUERY_TYPE_POWER_STATE = 2,
  277. MR_PD_QUERY_TYPE_MEDIA_TYPE = 3,
  278. MR_PD_QUERY_TYPE_SPEED = 4,
  279. MR_PD_QUERY_TYPE_EXPOSED_TO_HOST = 5,
  280. };
  281. #define MR_EVT_CFG_CLEARED 0x0004
  282. #define MR_EVT_LD_STATE_CHANGE 0x0051
  283. #define MR_EVT_PD_INSERTED 0x005b
  284. #define MR_EVT_PD_REMOVED 0x0070
  285. #define MR_EVT_LD_CREATED 0x008a
  286. #define MR_EVT_LD_DELETED 0x008b
  287. #define MR_EVT_FOREIGN_CFG_IMPORTED 0x00db
  288. #define MR_EVT_LD_OFFLINE 0x00fc
  289. #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152
  290. #define MAX_LOGICAL_DRIVES 64
  291. enum MR_PD_STATE {
  292. MR_PD_STATE_UNCONFIGURED_GOOD = 0x00,
  293. MR_PD_STATE_UNCONFIGURED_BAD = 0x01,
  294. MR_PD_STATE_HOT_SPARE = 0x02,
  295. MR_PD_STATE_OFFLINE = 0x10,
  296. MR_PD_STATE_FAILED = 0x11,
  297. MR_PD_STATE_REBUILD = 0x14,
  298. MR_PD_STATE_ONLINE = 0x18,
  299. MR_PD_STATE_COPYBACK = 0x20,
  300. MR_PD_STATE_SYSTEM = 0x40,
  301. };
  302. /*
  303. * defines the physical drive address structure
  304. */
  305. struct MR_PD_ADDRESS {
  306. u16 deviceId;
  307. u16 enclDeviceId;
  308. union {
  309. struct {
  310. u8 enclIndex;
  311. u8 slotNumber;
  312. } mrPdAddress;
  313. struct {
  314. u8 enclPosition;
  315. u8 enclConnectorIndex;
  316. } mrEnclAddress;
  317. };
  318. u8 scsiDevType;
  319. union {
  320. u8 connectedPortBitmap;
  321. u8 connectedPortNumbers;
  322. };
  323. u64 sasAddr[2];
  324. } __packed;
  325. /*
  326. * defines the physical drive list structure
  327. */
  328. struct MR_PD_LIST {
  329. u32 size;
  330. u32 count;
  331. struct MR_PD_ADDRESS addr[1];
  332. } __packed;
  333. struct megasas_pd_list {
  334. u16 tid;
  335. u8 driveType;
  336. u8 driveState;
  337. } __packed;
  338. /*
  339. * defines the logical drive reference structure
  340. */
  341. union MR_LD_REF {
  342. struct {
  343. u8 targetId;
  344. u8 reserved;
  345. u16 seqNum;
  346. };
  347. u32 ref;
  348. } __packed;
  349. /*
  350. * defines the logical drive list structure
  351. */
  352. struct MR_LD_LIST {
  353. u32 ldCount;
  354. u32 reserved;
  355. struct {
  356. union MR_LD_REF ref;
  357. u8 state;
  358. u8 reserved[3];
  359. u64 size;
  360. } ldList[MAX_LOGICAL_DRIVES];
  361. } __packed;
  362. /*
  363. * SAS controller properties
  364. */
  365. struct megasas_ctrl_prop {
  366. u16 seq_num;
  367. u16 pred_fail_poll_interval;
  368. u16 intr_throttle_count;
  369. u16 intr_throttle_timeouts;
  370. u8 rebuild_rate;
  371. u8 patrol_read_rate;
  372. u8 bgi_rate;
  373. u8 cc_rate;
  374. u8 recon_rate;
  375. u8 cache_flush_interval;
  376. u8 spinup_drv_count;
  377. u8 spinup_delay;
  378. u8 cluster_enable;
  379. u8 coercion_mode;
  380. u8 alarm_enable;
  381. u8 disable_auto_rebuild;
  382. u8 disable_battery_warn;
  383. u8 ecc_bucket_size;
  384. u16 ecc_bucket_leak_rate;
  385. u8 restore_hotspare_on_insertion;
  386. u8 expose_encl_devices;
  387. u8 maintainPdFailHistory;
  388. u8 disallowHostRequestReordering;
  389. u8 abortCCOnError;
  390. u8 loadBalanceMode;
  391. u8 disableAutoDetectBackplane;
  392. u8 snapVDSpace;
  393. /*
  394. * Add properties that can be controlled by
  395. * a bit in the following structure.
  396. */
  397. struct {
  398. u32 copyBackDisabled : 1;
  399. u32 SMARTerEnabled : 1;
  400. u32 prCorrectUnconfiguredAreas : 1;
  401. u32 useFdeOnly : 1;
  402. u32 disableNCQ : 1;
  403. u32 SSDSMARTerEnabled : 1;
  404. u32 SSDPatrolReadEnabled : 1;
  405. u32 enableSpinDownUnconfigured : 1;
  406. u32 autoEnhancedImport : 1;
  407. u32 enableSecretKeyControl : 1;
  408. u32 disableOnlineCtrlReset : 1;
  409. u32 allowBootWithPinnedCache : 1;
  410. u32 disableSpinDownHS : 1;
  411. u32 enableJBOD : 1;
  412. u32 reserved :18;
  413. } OnOffProperties;
  414. u8 autoSnapVDSpace;
  415. u8 viewSpace;
  416. u16 spinDownTime;
  417. u8 reserved[24];
  418. } __packed;
  419. /*
  420. * SAS controller information
  421. */
  422. struct megasas_ctrl_info {
  423. /*
  424. * PCI device information
  425. */
  426. struct {
  427. u16 vendor_id;
  428. u16 device_id;
  429. u16 sub_vendor_id;
  430. u16 sub_device_id;
  431. u8 reserved[24];
  432. } __attribute__ ((packed)) pci;
  433. /*
  434. * Host interface information
  435. */
  436. struct {
  437. u8 PCIX:1;
  438. u8 PCIE:1;
  439. u8 iSCSI:1;
  440. u8 SAS_3G:1;
  441. u8 reserved_0:4;
  442. u8 reserved_1[6];
  443. u8 port_count;
  444. u64 port_addr[8];
  445. } __attribute__ ((packed)) host_interface;
  446. /*
  447. * Device (backend) interface information
  448. */
  449. struct {
  450. u8 SPI:1;
  451. u8 SAS_3G:1;
  452. u8 SATA_1_5G:1;
  453. u8 SATA_3G:1;
  454. u8 reserved_0:4;
  455. u8 reserved_1[6];
  456. u8 port_count;
  457. u64 port_addr[8];
  458. } __attribute__ ((packed)) device_interface;
  459. /*
  460. * List of components residing in flash. All str are null terminated
  461. */
  462. u32 image_check_word;
  463. u32 image_component_count;
  464. struct {
  465. char name[8];
  466. char version[32];
  467. char build_date[16];
  468. char built_time[16];
  469. } __attribute__ ((packed)) image_component[8];
  470. /*
  471. * List of flash components that have been flashed on the card, but
  472. * are not in use, pending reset of the adapter. This list will be
  473. * empty if a flash operation has not occurred. All stings are null
  474. * terminated
  475. */
  476. u32 pending_image_component_count;
  477. struct {
  478. char name[8];
  479. char version[32];
  480. char build_date[16];
  481. char build_time[16];
  482. } __attribute__ ((packed)) pending_image_component[8];
  483. u8 max_arms;
  484. u8 max_spans;
  485. u8 max_arrays;
  486. u8 max_lds;
  487. char product_name[80];
  488. char serial_no[32];
  489. /*
  490. * Other physical/controller/operation information. Indicates the
  491. * presence of the hardware
  492. */
  493. struct {
  494. u32 bbu:1;
  495. u32 alarm:1;
  496. u32 nvram:1;
  497. u32 uart:1;
  498. u32 reserved:28;
  499. } __attribute__ ((packed)) hw_present;
  500. u32 current_fw_time;
  501. /*
  502. * Maximum data transfer sizes
  503. */
  504. u16 max_concurrent_cmds;
  505. u16 max_sge_count;
  506. u32 max_request_size;
  507. /*
  508. * Logical and physical device counts
  509. */
  510. u16 ld_present_count;
  511. u16 ld_degraded_count;
  512. u16 ld_offline_count;
  513. u16 pd_present_count;
  514. u16 pd_disk_present_count;
  515. u16 pd_disk_pred_failure_count;
  516. u16 pd_disk_failed_count;
  517. /*
  518. * Memory size information
  519. */
  520. u16 nvram_size;
  521. u16 memory_size;
  522. u16 flash_size;
  523. /*
  524. * Error counters
  525. */
  526. u16 mem_correctable_error_count;
  527. u16 mem_uncorrectable_error_count;
  528. /*
  529. * Cluster information
  530. */
  531. u8 cluster_permitted;
  532. u8 cluster_active;
  533. /*
  534. * Additional max data transfer sizes
  535. */
  536. u16 max_strips_per_io;
  537. /*
  538. * Controller capabilities structures
  539. */
  540. struct {
  541. u32 raid_level_0:1;
  542. u32 raid_level_1:1;
  543. u32 raid_level_5:1;
  544. u32 raid_level_1E:1;
  545. u32 raid_level_6:1;
  546. u32 reserved:27;
  547. } __attribute__ ((packed)) raid_levels;
  548. struct {
  549. u32 rbld_rate:1;
  550. u32 cc_rate:1;
  551. u32 bgi_rate:1;
  552. u32 recon_rate:1;
  553. u32 patrol_rate:1;
  554. u32 alarm_control:1;
  555. u32 cluster_supported:1;
  556. u32 bbu:1;
  557. u32 spanning_allowed:1;
  558. u32 dedicated_hotspares:1;
  559. u32 revertible_hotspares:1;
  560. u32 foreign_config_import:1;
  561. u32 self_diagnostic:1;
  562. u32 mixed_redundancy_arr:1;
  563. u32 global_hot_spares:1;
  564. u32 reserved:17;
  565. } __attribute__ ((packed)) adapter_operations;
  566. struct {
  567. u32 read_policy:1;
  568. u32 write_policy:1;
  569. u32 io_policy:1;
  570. u32 access_policy:1;
  571. u32 disk_cache_policy:1;
  572. u32 reserved:27;
  573. } __attribute__ ((packed)) ld_operations;
  574. struct {
  575. u8 min;
  576. u8 max;
  577. u8 reserved[2];
  578. } __attribute__ ((packed)) stripe_sz_ops;
  579. struct {
  580. u32 force_online:1;
  581. u32 force_offline:1;
  582. u32 force_rebuild:1;
  583. u32 reserved:29;
  584. } __attribute__ ((packed)) pd_operations;
  585. struct {
  586. u32 ctrl_supports_sas:1;
  587. u32 ctrl_supports_sata:1;
  588. u32 allow_mix_in_encl:1;
  589. u32 allow_mix_in_ld:1;
  590. u32 allow_sata_in_cluster:1;
  591. u32 reserved:27;
  592. } __attribute__ ((packed)) pd_mix_support;
  593. /*
  594. * Define ECC single-bit-error bucket information
  595. */
  596. u8 ecc_bucket_count;
  597. u8 reserved_2[11];
  598. /*
  599. * Include the controller properties (changeable items)
  600. */
  601. struct megasas_ctrl_prop properties;
  602. /*
  603. * Define FW pkg version (set in envt v'bles on OEM basis)
  604. */
  605. char package_version[0x60];
  606. u8 pad[0x800 - 0x6a0];
  607. } __packed;
  608. /*
  609. * ===============================
  610. * MegaRAID SAS driver definitions
  611. * ===============================
  612. */
  613. #define MEGASAS_MAX_PD_CHANNELS 2
  614. #define MEGASAS_MAX_LD_CHANNELS 2
  615. #define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
  616. MEGASAS_MAX_LD_CHANNELS)
  617. #define MEGASAS_MAX_DEV_PER_CHANNEL 128
  618. #define MEGASAS_DEFAULT_INIT_ID -1
  619. #define MEGASAS_MAX_LUN 8
  620. #define MEGASAS_MAX_LD 64
  621. #define MEGASAS_MAX_PD (MEGASAS_MAX_PD_CHANNELS * \
  622. MEGASAS_MAX_DEV_PER_CHANNEL)
  623. #define MEGASAS_MAX_LD_IDS (MEGASAS_MAX_LD_CHANNELS * \
  624. MEGASAS_MAX_DEV_PER_CHANNEL)
  625. #define MEGASAS_MAX_SECTORS (2*1024)
  626. #define MEGASAS_DBG_LVL 1
  627. #define MEGASAS_FW_BUSY 1
  628. /* Frame Type */
  629. #define IO_FRAME 0
  630. #define PTHRU_FRAME 1
  631. /*
  632. * When SCSI mid-layer calls driver's reset routine, driver waits for
  633. * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
  634. * that the driver cannot _actually_ abort or reset pending commands. While
  635. * it is waiting for the commands to complete, it prints a diagnostic message
  636. * every MEGASAS_RESET_NOTICE_INTERVAL seconds
  637. */
  638. #define MEGASAS_RESET_WAIT_TIME 180
  639. #define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
  640. #define MEGASAS_RESET_NOTICE_INTERVAL 5
  641. #define MEGASAS_IOCTL_CMD 0
  642. #define MEGASAS_DEFAULT_CMD_TIMEOUT 90
  643. /*
  644. * FW reports the maximum of number of commands that it can accept (maximum
  645. * commands that can be outstanding) at any time. The driver must report a
  646. * lower number to the mid layer because it can issue a few internal commands
  647. * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
  648. * is shown below
  649. */
  650. #define MEGASAS_INT_CMDS 32
  651. #define MEGASAS_SKINNY_INT_CMDS 5
  652. /*
  653. * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
  654. * SGLs based on the size of dma_addr_t
  655. */
  656. #define IS_DMA64 (sizeof(dma_addr_t) == 8)
  657. #define MFI_XSCALE_OMR0_CHANGE_INTERRUPT 0x00000001
  658. #define MFI_INTR_FLAG_REPLY_MESSAGE 0x00000001
  659. #define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE 0x00000002
  660. #define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT 0x00000004
  661. #define MFI_OB_INTR_STATUS_MASK 0x00000002
  662. #define MFI_POLL_TIMEOUT_SECS 60
  663. #define MEGASAS_COMPLETION_TIMER_INTERVAL (HZ/10)
  664. #define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
  665. #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
  666. #define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
  667. #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
  668. #define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
  669. #define MFI_1068_PCSR_OFFSET 0x84
  670. #define MFI_1068_FW_HANDSHAKE_OFFSET 0x64
  671. #define MFI_1068_FW_READY 0xDDDD0000
  672. /*
  673. * register set for both 1068 and 1078 controllers
  674. * structure extended for 1078 registers
  675. */
  676. struct megasas_register_set {
  677. u32 reserved_0[4]; /*0000h*/
  678. u32 inbound_msg_0; /*0010h*/
  679. u32 inbound_msg_1; /*0014h*/
  680. u32 outbound_msg_0; /*0018h*/
  681. u32 outbound_msg_1; /*001Ch*/
  682. u32 inbound_doorbell; /*0020h*/
  683. u32 inbound_intr_status; /*0024h*/
  684. u32 inbound_intr_mask; /*0028h*/
  685. u32 outbound_doorbell; /*002Ch*/
  686. u32 outbound_intr_status; /*0030h*/
  687. u32 outbound_intr_mask; /*0034h*/
  688. u32 reserved_1[2]; /*0038h*/
  689. u32 inbound_queue_port; /*0040h*/
  690. u32 outbound_queue_port; /*0044h*/
  691. u32 reserved_2[22]; /*0048h*/
  692. u32 outbound_doorbell_clear; /*00A0h*/
  693. u32 reserved_3[3]; /*00A4h*/
  694. u32 outbound_scratch_pad ; /*00B0h*/
  695. u32 reserved_4[3]; /*00B4h*/
  696. u32 inbound_low_queue_port ; /*00C0h*/
  697. u32 inbound_high_queue_port ; /*00C4h*/
  698. u32 reserved_5; /*00C8h*/
  699. u32 res_6[11]; /*CCh*/
  700. u32 host_diag;
  701. u32 seq_offset;
  702. u32 index_registers[807]; /*00CCh*/
  703. } __attribute__ ((packed));
  704. struct megasas_sge32 {
  705. u32 phys_addr;
  706. u32 length;
  707. } __attribute__ ((packed));
  708. struct megasas_sge64 {
  709. u64 phys_addr;
  710. u32 length;
  711. } __attribute__ ((packed));
  712. struct megasas_sge_skinny {
  713. u64 phys_addr;
  714. u32 length;
  715. u32 flag;
  716. } __packed;
  717. union megasas_sgl {
  718. struct megasas_sge32 sge32[1];
  719. struct megasas_sge64 sge64[1];
  720. struct megasas_sge_skinny sge_skinny[1];
  721. } __attribute__ ((packed));
  722. struct megasas_header {
  723. u8 cmd; /*00h */
  724. u8 sense_len; /*01h */
  725. u8 cmd_status; /*02h */
  726. u8 scsi_status; /*03h */
  727. u8 target_id; /*04h */
  728. u8 lun; /*05h */
  729. u8 cdb_len; /*06h */
  730. u8 sge_count; /*07h */
  731. u32 context; /*08h */
  732. u32 pad_0; /*0Ch */
  733. u16 flags; /*10h */
  734. u16 timeout; /*12h */
  735. u32 data_xferlen; /*14h */
  736. } __attribute__ ((packed));
  737. union megasas_sgl_frame {
  738. struct megasas_sge32 sge32[8];
  739. struct megasas_sge64 sge64[5];
  740. } __attribute__ ((packed));
  741. struct megasas_init_frame {
  742. u8 cmd; /*00h */
  743. u8 reserved_0; /*01h */
  744. u8 cmd_status; /*02h */
  745. u8 reserved_1; /*03h */
  746. u32 reserved_2; /*04h */
  747. u32 context; /*08h */
  748. u32 pad_0; /*0Ch */
  749. u16 flags; /*10h */
  750. u16 reserved_3; /*12h */
  751. u32 data_xfer_len; /*14h */
  752. u32 queue_info_new_phys_addr_lo; /*18h */
  753. u32 queue_info_new_phys_addr_hi; /*1Ch */
  754. u32 queue_info_old_phys_addr_lo; /*20h */
  755. u32 queue_info_old_phys_addr_hi; /*24h */
  756. u32 reserved_4[6]; /*28h */
  757. } __attribute__ ((packed));
  758. struct megasas_init_queue_info {
  759. u32 init_flags; /*00h */
  760. u32 reply_queue_entries; /*04h */
  761. u32 reply_queue_start_phys_addr_lo; /*08h */
  762. u32 reply_queue_start_phys_addr_hi; /*0Ch */
  763. u32 producer_index_phys_addr_lo; /*10h */
  764. u32 producer_index_phys_addr_hi; /*14h */
  765. u32 consumer_index_phys_addr_lo; /*18h */
  766. u32 consumer_index_phys_addr_hi; /*1Ch */
  767. } __attribute__ ((packed));
  768. struct megasas_io_frame {
  769. u8 cmd; /*00h */
  770. u8 sense_len; /*01h */
  771. u8 cmd_status; /*02h */
  772. u8 scsi_status; /*03h */
  773. u8 target_id; /*04h */
  774. u8 access_byte; /*05h */
  775. u8 reserved_0; /*06h */
  776. u8 sge_count; /*07h */
  777. u32 context; /*08h */
  778. u32 pad_0; /*0Ch */
  779. u16 flags; /*10h */
  780. u16 timeout; /*12h */
  781. u32 lba_count; /*14h */
  782. u32 sense_buf_phys_addr_lo; /*18h */
  783. u32 sense_buf_phys_addr_hi; /*1Ch */
  784. u32 start_lba_lo; /*20h */
  785. u32 start_lba_hi; /*24h */
  786. union megasas_sgl sgl; /*28h */
  787. } __attribute__ ((packed));
  788. struct megasas_pthru_frame {
  789. u8 cmd; /*00h */
  790. u8 sense_len; /*01h */
  791. u8 cmd_status; /*02h */
  792. u8 scsi_status; /*03h */
  793. u8 target_id; /*04h */
  794. u8 lun; /*05h */
  795. u8 cdb_len; /*06h */
  796. u8 sge_count; /*07h */
  797. u32 context; /*08h */
  798. u32 pad_0; /*0Ch */
  799. u16 flags; /*10h */
  800. u16 timeout; /*12h */
  801. u32 data_xfer_len; /*14h */
  802. u32 sense_buf_phys_addr_lo; /*18h */
  803. u32 sense_buf_phys_addr_hi; /*1Ch */
  804. u8 cdb[16]; /*20h */
  805. union megasas_sgl sgl; /*30h */
  806. } __attribute__ ((packed));
  807. struct megasas_dcmd_frame {
  808. u8 cmd; /*00h */
  809. u8 reserved_0; /*01h */
  810. u8 cmd_status; /*02h */
  811. u8 reserved_1[4]; /*03h */
  812. u8 sge_count; /*07h */
  813. u32 context; /*08h */
  814. u32 pad_0; /*0Ch */
  815. u16 flags; /*10h */
  816. u16 timeout; /*12h */
  817. u32 data_xfer_len; /*14h */
  818. u32 opcode; /*18h */
  819. union { /*1Ch */
  820. u8 b[12];
  821. u16 s[6];
  822. u32 w[3];
  823. } mbox;
  824. union megasas_sgl sgl; /*28h */
  825. } __attribute__ ((packed));
  826. struct megasas_abort_frame {
  827. u8 cmd; /*00h */
  828. u8 reserved_0; /*01h */
  829. u8 cmd_status; /*02h */
  830. u8 reserved_1; /*03h */
  831. u32 reserved_2; /*04h */
  832. u32 context; /*08h */
  833. u32 pad_0; /*0Ch */
  834. u16 flags; /*10h */
  835. u16 reserved_3; /*12h */
  836. u32 reserved_4; /*14h */
  837. u32 abort_context; /*18h */
  838. u32 pad_1; /*1Ch */
  839. u32 abort_mfi_phys_addr_lo; /*20h */
  840. u32 abort_mfi_phys_addr_hi; /*24h */
  841. u32 reserved_5[6]; /*28h */
  842. } __attribute__ ((packed));
  843. struct megasas_smp_frame {
  844. u8 cmd; /*00h */
  845. u8 reserved_1; /*01h */
  846. u8 cmd_status; /*02h */
  847. u8 connection_status; /*03h */
  848. u8 reserved_2[3]; /*04h */
  849. u8 sge_count; /*07h */
  850. u32 context; /*08h */
  851. u32 pad_0; /*0Ch */
  852. u16 flags; /*10h */
  853. u16 timeout; /*12h */
  854. u32 data_xfer_len; /*14h */
  855. u64 sas_addr; /*18h */
  856. union {
  857. struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
  858. struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
  859. } sgl;
  860. } __attribute__ ((packed));
  861. struct megasas_stp_frame {
  862. u8 cmd; /*00h */
  863. u8 reserved_1; /*01h */
  864. u8 cmd_status; /*02h */
  865. u8 reserved_2; /*03h */
  866. u8 target_id; /*04h */
  867. u8 reserved_3[2]; /*05h */
  868. u8 sge_count; /*07h */
  869. u32 context; /*08h */
  870. u32 pad_0; /*0Ch */
  871. u16 flags; /*10h */
  872. u16 timeout; /*12h */
  873. u32 data_xfer_len; /*14h */
  874. u16 fis[10]; /*18h */
  875. u32 stp_flags;
  876. union {
  877. struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
  878. struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
  879. } sgl;
  880. } __attribute__ ((packed));
  881. union megasas_frame {
  882. struct megasas_header hdr;
  883. struct megasas_init_frame init;
  884. struct megasas_io_frame io;
  885. struct megasas_pthru_frame pthru;
  886. struct megasas_dcmd_frame dcmd;
  887. struct megasas_abort_frame abort;
  888. struct megasas_smp_frame smp;
  889. struct megasas_stp_frame stp;
  890. u8 raw_bytes[64];
  891. };
  892. struct megasas_cmd;
  893. union megasas_evt_class_locale {
  894. struct {
  895. u16 locale;
  896. u8 reserved;
  897. s8 class;
  898. } __attribute__ ((packed)) members;
  899. u32 word;
  900. } __attribute__ ((packed));
  901. struct megasas_evt_log_info {
  902. u32 newest_seq_num;
  903. u32 oldest_seq_num;
  904. u32 clear_seq_num;
  905. u32 shutdown_seq_num;
  906. u32 boot_seq_num;
  907. } __attribute__ ((packed));
  908. struct megasas_progress {
  909. u16 progress;
  910. u16 elapsed_seconds;
  911. } __attribute__ ((packed));
  912. struct megasas_evtarg_ld {
  913. u16 target_id;
  914. u8 ld_index;
  915. u8 reserved;
  916. } __attribute__ ((packed));
  917. struct megasas_evtarg_pd {
  918. u16 device_id;
  919. u8 encl_index;
  920. u8 slot_number;
  921. } __attribute__ ((packed));
  922. struct megasas_evt_detail {
  923. u32 seq_num;
  924. u32 time_stamp;
  925. u32 code;
  926. union megasas_evt_class_locale cl;
  927. u8 arg_type;
  928. u8 reserved1[15];
  929. union {
  930. struct {
  931. struct megasas_evtarg_pd pd;
  932. u8 cdb_length;
  933. u8 sense_length;
  934. u8 reserved[2];
  935. u8 cdb[16];
  936. u8 sense[64];
  937. } __attribute__ ((packed)) cdbSense;
  938. struct megasas_evtarg_ld ld;
  939. struct {
  940. struct megasas_evtarg_ld ld;
  941. u64 count;
  942. } __attribute__ ((packed)) ld_count;
  943. struct {
  944. u64 lba;
  945. struct megasas_evtarg_ld ld;
  946. } __attribute__ ((packed)) ld_lba;
  947. struct {
  948. struct megasas_evtarg_ld ld;
  949. u32 prevOwner;
  950. u32 newOwner;
  951. } __attribute__ ((packed)) ld_owner;
  952. struct {
  953. u64 ld_lba;
  954. u64 pd_lba;
  955. struct megasas_evtarg_ld ld;
  956. struct megasas_evtarg_pd pd;
  957. } __attribute__ ((packed)) ld_lba_pd_lba;
  958. struct {
  959. struct megasas_evtarg_ld ld;
  960. struct megasas_progress prog;
  961. } __attribute__ ((packed)) ld_prog;
  962. struct {
  963. struct megasas_evtarg_ld ld;
  964. u32 prev_state;
  965. u32 new_state;
  966. } __attribute__ ((packed)) ld_state;
  967. struct {
  968. u64 strip;
  969. struct megasas_evtarg_ld ld;
  970. } __attribute__ ((packed)) ld_strip;
  971. struct megasas_evtarg_pd pd;
  972. struct {
  973. struct megasas_evtarg_pd pd;
  974. u32 err;
  975. } __attribute__ ((packed)) pd_err;
  976. struct {
  977. u64 lba;
  978. struct megasas_evtarg_pd pd;
  979. } __attribute__ ((packed)) pd_lba;
  980. struct {
  981. u64 lba;
  982. struct megasas_evtarg_pd pd;
  983. struct megasas_evtarg_ld ld;
  984. } __attribute__ ((packed)) pd_lba_ld;
  985. struct {
  986. struct megasas_evtarg_pd pd;
  987. struct megasas_progress prog;
  988. } __attribute__ ((packed)) pd_prog;
  989. struct {
  990. struct megasas_evtarg_pd pd;
  991. u32 prevState;
  992. u32 newState;
  993. } __attribute__ ((packed)) pd_state;
  994. struct {
  995. u16 vendorId;
  996. u16 deviceId;
  997. u16 subVendorId;
  998. u16 subDeviceId;
  999. } __attribute__ ((packed)) pci;
  1000. u32 rate;
  1001. char str[96];
  1002. struct {
  1003. u32 rtc;
  1004. u32 elapsedSeconds;
  1005. } __attribute__ ((packed)) time;
  1006. struct {
  1007. u32 ecar;
  1008. u32 elog;
  1009. char str[64];
  1010. } __attribute__ ((packed)) ecc;
  1011. u8 b[96];
  1012. u16 s[48];
  1013. u32 w[24];
  1014. u64 d[12];
  1015. } args;
  1016. char description[128];
  1017. } __attribute__ ((packed));
  1018. struct megasas_aen_event {
  1019. struct work_struct hotplug_work;
  1020. struct megasas_instance *instance;
  1021. };
  1022. struct megasas_instance {
  1023. u32 *producer;
  1024. dma_addr_t producer_h;
  1025. u32 *consumer;
  1026. dma_addr_t consumer_h;
  1027. u32 *reply_queue;
  1028. dma_addr_t reply_queue_h;
  1029. unsigned long base_addr;
  1030. struct megasas_register_set __iomem *reg_set;
  1031. struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
  1032. u8 ld_ids[MEGASAS_MAX_LD_IDS];
  1033. s8 init_id;
  1034. u16 max_num_sge;
  1035. u16 max_fw_cmds;
  1036. u32 max_sectors_per_req;
  1037. struct megasas_aen_event *ev;
  1038. struct megasas_cmd **cmd_list;
  1039. struct list_head cmd_pool;
  1040. /* used to sync fire the cmd to fw */
  1041. spinlock_t cmd_pool_lock;
  1042. /* used to sync fire the cmd to fw */
  1043. spinlock_t hba_lock;
  1044. /* used to synch producer, consumer ptrs in dpc */
  1045. spinlock_t completion_lock;
  1046. struct dma_pool *frame_dma_pool;
  1047. struct dma_pool *sense_dma_pool;
  1048. struct megasas_evt_detail *evt_detail;
  1049. dma_addr_t evt_detail_h;
  1050. struct megasas_cmd *aen_cmd;
  1051. struct mutex aen_mutex;
  1052. struct semaphore ioctl_sem;
  1053. struct Scsi_Host *host;
  1054. wait_queue_head_t int_cmd_wait_q;
  1055. wait_queue_head_t abort_cmd_wait_q;
  1056. struct pci_dev *pdev;
  1057. u32 unique_id;
  1058. u32 fw_support_ieee;
  1059. atomic_t fw_outstanding;
  1060. atomic_t fw_reset_no_pci_access;
  1061. struct megasas_instance_template *instancet;
  1062. struct tasklet_struct isr_tasklet;
  1063. struct work_struct work_init;
  1064. u8 flag;
  1065. u8 unload;
  1066. u8 flag_ieee;
  1067. u8 issuepend_done;
  1068. u8 disableOnlineCtrlReset;
  1069. u8 adprecovery;
  1070. unsigned long last_time;
  1071. u32 mfiStatus;
  1072. u32 last_seq_num;
  1073. struct timer_list io_completion_timer;
  1074. struct list_head internal_reset_pending_q;
  1075. u8 msi_flag;
  1076. struct msix_entry msixentry;
  1077. unsigned long bar;
  1078. };
  1079. enum {
  1080. MEGASAS_HBA_OPERATIONAL = 0,
  1081. MEGASAS_ADPRESET_SM_INFAULT = 1,
  1082. MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS = 2,
  1083. MEGASAS_ADPRESET_SM_OPERATIONAL = 3,
  1084. MEGASAS_HW_CRITICAL_ERROR = 4,
  1085. MEGASAS_ADPRESET_INPROG_SIGN = 0xDEADDEAD,
  1086. };
  1087. struct megasas_instance_template {
  1088. void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
  1089. u32, struct megasas_register_set __iomem *);
  1090. void (*enable_intr)(struct megasas_register_set __iomem *) ;
  1091. void (*disable_intr)(struct megasas_register_set __iomem *);
  1092. int (*clear_intr)(struct megasas_register_set __iomem *);
  1093. u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
  1094. int (*adp_reset)(struct megasas_instance *, \
  1095. struct megasas_register_set __iomem *);
  1096. int (*check_reset)(struct megasas_instance *, \
  1097. struct megasas_register_set __iomem *);
  1098. irqreturn_t (*service_isr)(int irq, void *devp);
  1099. void (*tasklet)(unsigned long);
  1100. u32 (*init_adapter)(struct megasas_instance *);
  1101. u32 (*build_and_issue_cmd) (struct megasas_instance *,
  1102. struct scsi_cmnd *);
  1103. void (*issue_dcmd) (struct megasas_instance *instance,
  1104. struct megasas_cmd *cmd);
  1105. };
  1106. #define MEGASAS_IS_LOGICAL(scp) \
  1107. (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
  1108. #define MEGASAS_DEV_INDEX(inst, scp) \
  1109. ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
  1110. scp->device->id
  1111. struct megasas_cmd {
  1112. union megasas_frame *frame;
  1113. dma_addr_t frame_phys_addr;
  1114. u8 *sense;
  1115. dma_addr_t sense_phys_addr;
  1116. u32 index;
  1117. u8 sync_cmd;
  1118. u8 cmd_status;
  1119. u8 abort_aen;
  1120. u8 retry_for_fw_reset;
  1121. struct list_head list;
  1122. struct scsi_cmnd *scmd;
  1123. struct megasas_instance *instance;
  1124. u32 frame_count;
  1125. };
  1126. #define MAX_MGMT_ADAPTERS 1024
  1127. #define MAX_IOCTL_SGE 16
  1128. struct megasas_iocpacket {
  1129. u16 host_no;
  1130. u16 __pad1;
  1131. u32 sgl_off;
  1132. u32 sge_count;
  1133. u32 sense_off;
  1134. u32 sense_len;
  1135. union {
  1136. u8 raw[128];
  1137. struct megasas_header hdr;
  1138. } frame;
  1139. struct iovec sgl[MAX_IOCTL_SGE];
  1140. } __attribute__ ((packed));
  1141. struct megasas_aen {
  1142. u16 host_no;
  1143. u16 __pad1;
  1144. u32 seq_num;
  1145. u32 class_locale_word;
  1146. } __attribute__ ((packed));
  1147. #ifdef CONFIG_COMPAT
  1148. struct compat_megasas_iocpacket {
  1149. u16 host_no;
  1150. u16 __pad1;
  1151. u32 sgl_off;
  1152. u32 sge_count;
  1153. u32 sense_off;
  1154. u32 sense_len;
  1155. union {
  1156. u8 raw[128];
  1157. struct megasas_header hdr;
  1158. } frame;
  1159. struct compat_iovec sgl[MAX_IOCTL_SGE];
  1160. } __attribute__ ((packed));
  1161. #define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
  1162. #endif
  1163. #define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
  1164. #define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
  1165. struct megasas_mgmt_info {
  1166. u16 count;
  1167. struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
  1168. int max_index;
  1169. };
  1170. #endif /*LSI_MEGARAID_SAS_H */