megaraid_sas.h 45 KB

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