megaraid_sas.h 38 KB

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