megaraid_sas.h 33 KB

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