megaraid_sas.h 31 KB

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