megaraid_sas.h 33 KB

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