megaraid_sas.h 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500
  1. /*
  2. * Linux MegaRAID driver for SAS based RAID controllers
  3. *
  4. * Copyright (c) 2003-2013 LSI Corporation
  5. * Copyright (c) 2013-2014 Avago Technologies
  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 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * FILE: megaraid_sas.h
  21. *
  22. * Authors: Avago Technologies
  23. * Kashyap Desai <kashyap.desai@avagotech.com>
  24. * Sumit Saxena <sumit.saxena@avagotech.com>
  25. *
  26. * Send feedback to: megaraidlinux.pdl@avagotech.com
  27. *
  28. * Mail to: Avago Technologies, 350 West Trimble Road, Building 90,
  29. * San Jose, California 95131
  30. */
  31. #ifndef LSI_MEGARAID_SAS_H
  32. #define LSI_MEGARAID_SAS_H
  33. /*
  34. * MegaRAID SAS Driver meta data
  35. */
  36. #define MEGASAS_VERSION "07.702.06.00-rc1"
  37. #define MEGASAS_RELDATE "June 21, 2017"
  38. /*
  39. * Device IDs
  40. */
  41. #define PCI_DEVICE_ID_LSI_SAS1078R 0x0060
  42. #define PCI_DEVICE_ID_LSI_SAS1078DE 0x007C
  43. #define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413
  44. #define PCI_DEVICE_ID_LSI_SAS1078GEN2 0x0078
  45. #define PCI_DEVICE_ID_LSI_SAS0079GEN2 0x0079
  46. #define PCI_DEVICE_ID_LSI_SAS0073SKINNY 0x0073
  47. #define PCI_DEVICE_ID_LSI_SAS0071SKINNY 0x0071
  48. #define PCI_DEVICE_ID_LSI_FUSION 0x005b
  49. #define PCI_DEVICE_ID_LSI_PLASMA 0x002f
  50. #define PCI_DEVICE_ID_LSI_INVADER 0x005d
  51. #define PCI_DEVICE_ID_LSI_FURY 0x005f
  52. #define PCI_DEVICE_ID_LSI_INTRUDER 0x00ce
  53. #define PCI_DEVICE_ID_LSI_INTRUDER_24 0x00cf
  54. #define PCI_DEVICE_ID_LSI_CUTLASS_52 0x0052
  55. #define PCI_DEVICE_ID_LSI_CUTLASS_53 0x0053
  56. #define PCI_DEVICE_ID_LSI_VENTURA 0x0014
  57. #define PCI_DEVICE_ID_LSI_HARPOON 0x0016
  58. #define PCI_DEVICE_ID_LSI_TOMCAT 0x0017
  59. #define PCI_DEVICE_ID_LSI_VENTURA_4PORT 0x001B
  60. #define PCI_DEVICE_ID_LSI_CRUSADER_4PORT 0x001C
  61. /*
  62. * Intel HBA SSDIDs
  63. */
  64. #define MEGARAID_INTEL_RS3DC080_SSDID 0x9360
  65. #define MEGARAID_INTEL_RS3DC040_SSDID 0x9362
  66. #define MEGARAID_INTEL_RS3SC008_SSDID 0x9380
  67. #define MEGARAID_INTEL_RS3MC044_SSDID 0x9381
  68. #define MEGARAID_INTEL_RS3WC080_SSDID 0x9341
  69. #define MEGARAID_INTEL_RS3WC040_SSDID 0x9343
  70. #define MEGARAID_INTEL_RMS3BC160_SSDID 0x352B
  71. /*
  72. * Intruder HBA SSDIDs
  73. */
  74. #define MEGARAID_INTRUDER_SSDID1 0x9371
  75. #define MEGARAID_INTRUDER_SSDID2 0x9390
  76. #define MEGARAID_INTRUDER_SSDID3 0x9370
  77. /*
  78. * Intel HBA branding
  79. */
  80. #define MEGARAID_INTEL_RS3DC080_BRANDING \
  81. "Intel(R) RAID Controller RS3DC080"
  82. #define MEGARAID_INTEL_RS3DC040_BRANDING \
  83. "Intel(R) RAID Controller RS3DC040"
  84. #define MEGARAID_INTEL_RS3SC008_BRANDING \
  85. "Intel(R) RAID Controller RS3SC008"
  86. #define MEGARAID_INTEL_RS3MC044_BRANDING \
  87. "Intel(R) RAID Controller RS3MC044"
  88. #define MEGARAID_INTEL_RS3WC080_BRANDING \
  89. "Intel(R) RAID Controller RS3WC080"
  90. #define MEGARAID_INTEL_RS3WC040_BRANDING \
  91. "Intel(R) RAID Controller RS3WC040"
  92. #define MEGARAID_INTEL_RMS3BC160_BRANDING \
  93. "Intel(R) Integrated RAID Module RMS3BC160"
  94. /*
  95. * =====================================
  96. * MegaRAID SAS MFI firmware definitions
  97. * =====================================
  98. */
  99. /*
  100. * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
  101. * protocol between the software and firmware. Commands are issued using
  102. * "message frames"
  103. */
  104. /*
  105. * FW posts its state in upper 4 bits of outbound_msg_0 register
  106. */
  107. #define MFI_STATE_MASK 0xF0000000
  108. #define MFI_STATE_UNDEFINED 0x00000000
  109. #define MFI_STATE_BB_INIT 0x10000000
  110. #define MFI_STATE_FW_INIT 0x40000000
  111. #define MFI_STATE_WAIT_HANDSHAKE 0x60000000
  112. #define MFI_STATE_FW_INIT_2 0x70000000
  113. #define MFI_STATE_DEVICE_SCAN 0x80000000
  114. #define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000
  115. #define MFI_STATE_FLUSH_CACHE 0xA0000000
  116. #define MFI_STATE_READY 0xB0000000
  117. #define MFI_STATE_OPERATIONAL 0xC0000000
  118. #define MFI_STATE_FAULT 0xF0000000
  119. #define MFI_STATE_FORCE_OCR 0x00000080
  120. #define MFI_STATE_DMADONE 0x00000008
  121. #define MFI_STATE_CRASH_DUMP_DONE 0x00000004
  122. #define MFI_RESET_REQUIRED 0x00000001
  123. #define MFI_RESET_ADAPTER 0x00000002
  124. #define MEGAMFI_FRAME_SIZE 64
  125. /*
  126. * During FW init, clear pending cmds & reset state using inbound_msg_0
  127. *
  128. * ABORT : Abort all pending cmds
  129. * READY : Move from OPERATIONAL to READY state; discard queue info
  130. * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
  131. * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
  132. * HOTPLUG : Resume from Hotplug
  133. * MFI_STOP_ADP : Send signal to FW to stop processing
  134. */
  135. #define WRITE_SEQUENCE_OFFSET (0x0000000FC) /* I20 */
  136. #define HOST_DIAGNOSTIC_OFFSET (0x000000F8) /* I20 */
  137. #define DIAG_WRITE_ENABLE (0x00000080)
  138. #define DIAG_RESET_ADAPTER (0x00000004)
  139. #define MFI_ADP_RESET 0x00000040
  140. #define MFI_INIT_ABORT 0x00000001
  141. #define MFI_INIT_READY 0x00000002
  142. #define MFI_INIT_MFIMODE 0x00000004
  143. #define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
  144. #define MFI_INIT_HOTPLUG 0x00000010
  145. #define MFI_STOP_ADP 0x00000020
  146. #define MFI_RESET_FLAGS MFI_INIT_READY| \
  147. MFI_INIT_MFIMODE| \
  148. MFI_INIT_ABORT
  149. #define MPI2_IOCINIT_MSGFLAG_RDPQ_ARRAY_MODE (0x01)
  150. /*
  151. * MFI frame flags
  152. */
  153. #define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
  154. #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
  155. #define MFI_FRAME_SGL32 0x0000
  156. #define MFI_FRAME_SGL64 0x0002
  157. #define MFI_FRAME_SENSE32 0x0000
  158. #define MFI_FRAME_SENSE64 0x0004
  159. #define MFI_FRAME_DIR_NONE 0x0000
  160. #define MFI_FRAME_DIR_WRITE 0x0008
  161. #define MFI_FRAME_DIR_READ 0x0010
  162. #define MFI_FRAME_DIR_BOTH 0x0018
  163. #define MFI_FRAME_IEEE 0x0020
  164. /* Driver internal */
  165. #define DRV_DCMD_POLLED_MODE 0x1
  166. #define DRV_DCMD_SKIP_REFIRE 0x2
  167. /*
  168. * Definition for cmd_status
  169. */
  170. #define MFI_CMD_STATUS_POLL_MODE 0xFF
  171. /*
  172. * MFI command opcodes
  173. */
  174. #define MFI_CMD_INIT 0x00
  175. #define MFI_CMD_LD_READ 0x01
  176. #define MFI_CMD_LD_WRITE 0x02
  177. #define MFI_CMD_LD_SCSI_IO 0x03
  178. #define MFI_CMD_PD_SCSI_IO 0x04
  179. #define MFI_CMD_DCMD 0x05
  180. #define MFI_CMD_ABORT 0x06
  181. #define MFI_CMD_SMP 0x07
  182. #define MFI_CMD_STP 0x08
  183. #define MFI_CMD_INVALID 0xff
  184. #define MR_DCMD_CTRL_GET_INFO 0x01010000
  185. #define MR_DCMD_LD_GET_LIST 0x03010000
  186. #define MR_DCMD_LD_LIST_QUERY 0x03010100
  187. #define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
  188. #define MR_FLUSH_CTRL_CACHE 0x01
  189. #define MR_FLUSH_DISK_CACHE 0x02
  190. #define MR_DCMD_CTRL_SHUTDOWN 0x01050000
  191. #define MR_DCMD_HIBERNATE_SHUTDOWN 0x01060000
  192. #define MR_ENABLE_DRIVE_SPINDOWN 0x01
  193. #define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
  194. #define MR_DCMD_CTRL_EVENT_GET 0x01040300
  195. #define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
  196. #define MR_DCMD_LD_GET_PROPERTIES 0x03030000
  197. #define MR_DCMD_CLUSTER 0x08000000
  198. #define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
  199. #define MR_DCMD_CLUSTER_RESET_LD 0x08010200
  200. #define MR_DCMD_PD_LIST_QUERY 0x02010100
  201. #define MR_DCMD_CTRL_SET_CRASH_DUMP_PARAMS 0x01190100
  202. #define MR_DRIVER_SET_APP_CRASHDUMP_MODE (0xF0010000 | 0x0600)
  203. #define MR_DCMD_PD_GET_INFO 0x02020000
  204. /*
  205. * Global functions
  206. */
  207. extern u8 MR_ValidateMapInfo(struct megasas_instance *instance);
  208. /*
  209. * MFI command completion codes
  210. */
  211. enum MFI_STAT {
  212. MFI_STAT_OK = 0x00,
  213. MFI_STAT_INVALID_CMD = 0x01,
  214. MFI_STAT_INVALID_DCMD = 0x02,
  215. MFI_STAT_INVALID_PARAMETER = 0x03,
  216. MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
  217. MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
  218. MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
  219. MFI_STAT_APP_IN_USE = 0x07,
  220. MFI_STAT_APP_NOT_INITIALIZED = 0x08,
  221. MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
  222. MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
  223. MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
  224. MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
  225. MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
  226. MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
  227. MFI_STAT_FLASH_BUSY = 0x0f,
  228. MFI_STAT_FLASH_ERROR = 0x10,
  229. MFI_STAT_FLASH_IMAGE_BAD = 0x11,
  230. MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
  231. MFI_STAT_FLASH_NOT_OPEN = 0x13,
  232. MFI_STAT_FLASH_NOT_STARTED = 0x14,
  233. MFI_STAT_FLUSH_FAILED = 0x15,
  234. MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
  235. MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
  236. MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
  237. MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
  238. MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
  239. MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
  240. MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
  241. MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
  242. MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
  243. MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
  244. MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
  245. MFI_STAT_MFC_HW_ERROR = 0x21,
  246. MFI_STAT_NO_HW_PRESENT = 0x22,
  247. MFI_STAT_NOT_FOUND = 0x23,
  248. MFI_STAT_NOT_IN_ENCL = 0x24,
  249. MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
  250. MFI_STAT_PD_TYPE_WRONG = 0x26,
  251. MFI_STAT_PR_DISABLED = 0x27,
  252. MFI_STAT_ROW_INDEX_INVALID = 0x28,
  253. MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
  254. MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
  255. MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
  256. MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
  257. MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
  258. MFI_STAT_SCSI_IO_FAILED = 0x2e,
  259. MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
  260. MFI_STAT_SHUTDOWN_FAILED = 0x30,
  261. MFI_STAT_TIME_NOT_SET = 0x31,
  262. MFI_STAT_WRONG_STATE = 0x32,
  263. MFI_STAT_LD_OFFLINE = 0x33,
  264. MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
  265. MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
  266. MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
  267. MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
  268. MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
  269. MFI_STAT_CONFIG_SEQ_MISMATCH = 0x67,
  270. MFI_STAT_INVALID_STATUS = 0xFF
  271. };
  272. enum mfi_evt_class {
  273. MFI_EVT_CLASS_DEBUG = -2,
  274. MFI_EVT_CLASS_PROGRESS = -1,
  275. MFI_EVT_CLASS_INFO = 0,
  276. MFI_EVT_CLASS_WARNING = 1,
  277. MFI_EVT_CLASS_CRITICAL = 2,
  278. MFI_EVT_CLASS_FATAL = 3,
  279. MFI_EVT_CLASS_DEAD = 4
  280. };
  281. /*
  282. * Crash dump related defines
  283. */
  284. #define MAX_CRASH_DUMP_SIZE 512
  285. #define CRASH_DMA_BUF_SIZE (1024 * 1024)
  286. enum MR_FW_CRASH_DUMP_STATE {
  287. UNAVAILABLE = 0,
  288. AVAILABLE = 1,
  289. COPYING = 2,
  290. COPIED = 3,
  291. COPY_ERROR = 4,
  292. };
  293. enum _MR_CRASH_BUF_STATUS {
  294. MR_CRASH_BUF_TURN_OFF = 0,
  295. MR_CRASH_BUF_TURN_ON = 1,
  296. };
  297. /*
  298. * Number of mailbox bytes in DCMD message frame
  299. */
  300. #define MFI_MBOX_SIZE 12
  301. enum MR_EVT_CLASS {
  302. MR_EVT_CLASS_DEBUG = -2,
  303. MR_EVT_CLASS_PROGRESS = -1,
  304. MR_EVT_CLASS_INFO = 0,
  305. MR_EVT_CLASS_WARNING = 1,
  306. MR_EVT_CLASS_CRITICAL = 2,
  307. MR_EVT_CLASS_FATAL = 3,
  308. MR_EVT_CLASS_DEAD = 4,
  309. };
  310. enum MR_EVT_LOCALE {
  311. MR_EVT_LOCALE_LD = 0x0001,
  312. MR_EVT_LOCALE_PD = 0x0002,
  313. MR_EVT_LOCALE_ENCL = 0x0004,
  314. MR_EVT_LOCALE_BBU = 0x0008,
  315. MR_EVT_LOCALE_SAS = 0x0010,
  316. MR_EVT_LOCALE_CTRL = 0x0020,
  317. MR_EVT_LOCALE_CONFIG = 0x0040,
  318. MR_EVT_LOCALE_CLUSTER = 0x0080,
  319. MR_EVT_LOCALE_ALL = 0xffff,
  320. };
  321. enum MR_EVT_ARGS {
  322. MR_EVT_ARGS_NONE,
  323. MR_EVT_ARGS_CDB_SENSE,
  324. MR_EVT_ARGS_LD,
  325. MR_EVT_ARGS_LD_COUNT,
  326. MR_EVT_ARGS_LD_LBA,
  327. MR_EVT_ARGS_LD_OWNER,
  328. MR_EVT_ARGS_LD_LBA_PD_LBA,
  329. MR_EVT_ARGS_LD_PROG,
  330. MR_EVT_ARGS_LD_STATE,
  331. MR_EVT_ARGS_LD_STRIP,
  332. MR_EVT_ARGS_PD,
  333. MR_EVT_ARGS_PD_ERR,
  334. MR_EVT_ARGS_PD_LBA,
  335. MR_EVT_ARGS_PD_LBA_LD,
  336. MR_EVT_ARGS_PD_PROG,
  337. MR_EVT_ARGS_PD_STATE,
  338. MR_EVT_ARGS_PCI,
  339. MR_EVT_ARGS_RATE,
  340. MR_EVT_ARGS_STR,
  341. MR_EVT_ARGS_TIME,
  342. MR_EVT_ARGS_ECC,
  343. MR_EVT_ARGS_LD_PROP,
  344. MR_EVT_ARGS_PD_SPARE,
  345. MR_EVT_ARGS_PD_INDEX,
  346. MR_EVT_ARGS_DIAG_PASS,
  347. MR_EVT_ARGS_DIAG_FAIL,
  348. MR_EVT_ARGS_PD_LBA_LBA,
  349. MR_EVT_ARGS_PORT_PHY,
  350. MR_EVT_ARGS_PD_MISSING,
  351. MR_EVT_ARGS_PD_ADDRESS,
  352. MR_EVT_ARGS_BITMAP,
  353. MR_EVT_ARGS_CONNECTOR,
  354. MR_EVT_ARGS_PD_PD,
  355. MR_EVT_ARGS_PD_FRU,
  356. MR_EVT_ARGS_PD_PATHINFO,
  357. MR_EVT_ARGS_PD_POWER_STATE,
  358. MR_EVT_ARGS_GENERIC,
  359. };
  360. #define SGE_BUFFER_SIZE 4096
  361. #define MEGASAS_CLUSTER_ID_SIZE 16
  362. /*
  363. * define constants for device list query options
  364. */
  365. enum MR_PD_QUERY_TYPE {
  366. MR_PD_QUERY_TYPE_ALL = 0,
  367. MR_PD_QUERY_TYPE_STATE = 1,
  368. MR_PD_QUERY_TYPE_POWER_STATE = 2,
  369. MR_PD_QUERY_TYPE_MEDIA_TYPE = 3,
  370. MR_PD_QUERY_TYPE_SPEED = 4,
  371. MR_PD_QUERY_TYPE_EXPOSED_TO_HOST = 5,
  372. };
  373. enum MR_LD_QUERY_TYPE {
  374. MR_LD_QUERY_TYPE_ALL = 0,
  375. MR_LD_QUERY_TYPE_EXPOSED_TO_HOST = 1,
  376. MR_LD_QUERY_TYPE_USED_TGT_IDS = 2,
  377. MR_LD_QUERY_TYPE_CLUSTER_ACCESS = 3,
  378. MR_LD_QUERY_TYPE_CLUSTER_LOCALE = 4,
  379. };
  380. #define MR_EVT_CFG_CLEARED 0x0004
  381. #define MR_EVT_LD_STATE_CHANGE 0x0051
  382. #define MR_EVT_PD_INSERTED 0x005b
  383. #define MR_EVT_PD_REMOVED 0x0070
  384. #define MR_EVT_LD_CREATED 0x008a
  385. #define MR_EVT_LD_DELETED 0x008b
  386. #define MR_EVT_FOREIGN_CFG_IMPORTED 0x00db
  387. #define MR_EVT_LD_OFFLINE 0x00fc
  388. #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152
  389. #define MR_EVT_CTRL_PROP_CHANGED 0x012f
  390. enum MR_PD_STATE {
  391. MR_PD_STATE_UNCONFIGURED_GOOD = 0x00,
  392. MR_PD_STATE_UNCONFIGURED_BAD = 0x01,
  393. MR_PD_STATE_HOT_SPARE = 0x02,
  394. MR_PD_STATE_OFFLINE = 0x10,
  395. MR_PD_STATE_FAILED = 0x11,
  396. MR_PD_STATE_REBUILD = 0x14,
  397. MR_PD_STATE_ONLINE = 0x18,
  398. MR_PD_STATE_COPYBACK = 0x20,
  399. MR_PD_STATE_SYSTEM = 0x40,
  400. };
  401. union MR_PD_REF {
  402. struct {
  403. u16 deviceId;
  404. u16 seqNum;
  405. } mrPdRef;
  406. u32 ref;
  407. };
  408. /*
  409. * define the DDF Type bit structure
  410. */
  411. union MR_PD_DDF_TYPE {
  412. struct {
  413. union {
  414. struct {
  415. #ifndef __BIG_ENDIAN_BITFIELD
  416. u16 forcedPDGUID:1;
  417. u16 inVD:1;
  418. u16 isGlobalSpare:1;
  419. u16 isSpare:1;
  420. u16 isForeign:1;
  421. u16 reserved:7;
  422. u16 intf:4;
  423. #else
  424. u16 intf:4;
  425. u16 reserved:7;
  426. u16 isForeign:1;
  427. u16 isSpare:1;
  428. u16 isGlobalSpare:1;
  429. u16 inVD:1;
  430. u16 forcedPDGUID:1;
  431. #endif
  432. } pdType;
  433. u16 type;
  434. };
  435. u16 reserved;
  436. } ddf;
  437. struct {
  438. u32 reserved;
  439. } nonDisk;
  440. u32 type;
  441. } __packed;
  442. /*
  443. * defines the progress structure
  444. */
  445. union MR_PROGRESS {
  446. struct {
  447. u16 progress;
  448. union {
  449. u16 elapsedSecs;
  450. u16 elapsedSecsForLastPercent;
  451. };
  452. } mrProgress;
  453. u32 w;
  454. } __packed;
  455. /*
  456. * defines the physical drive progress structure
  457. */
  458. struct MR_PD_PROGRESS {
  459. struct {
  460. #ifndef MFI_BIG_ENDIAN
  461. u32 rbld:1;
  462. u32 patrol:1;
  463. u32 clear:1;
  464. u32 copyBack:1;
  465. u32 erase:1;
  466. u32 locate:1;
  467. u32 reserved:26;
  468. #else
  469. u32 reserved:26;
  470. u32 locate:1;
  471. u32 erase:1;
  472. u32 copyBack:1;
  473. u32 clear:1;
  474. u32 patrol:1;
  475. u32 rbld:1;
  476. #endif
  477. } active;
  478. union MR_PROGRESS rbld;
  479. union MR_PROGRESS patrol;
  480. union {
  481. union MR_PROGRESS clear;
  482. union MR_PROGRESS erase;
  483. };
  484. struct {
  485. #ifndef MFI_BIG_ENDIAN
  486. u32 rbld:1;
  487. u32 patrol:1;
  488. u32 clear:1;
  489. u32 copyBack:1;
  490. u32 erase:1;
  491. u32 reserved:27;
  492. #else
  493. u32 reserved:27;
  494. u32 erase:1;
  495. u32 copyBack:1;
  496. u32 clear:1;
  497. u32 patrol:1;
  498. u32 rbld:1;
  499. #endif
  500. } pause;
  501. union MR_PROGRESS reserved[3];
  502. } __packed;
  503. struct MR_PD_INFO {
  504. union MR_PD_REF ref;
  505. u8 inquiryData[96];
  506. u8 vpdPage83[64];
  507. u8 notSupported;
  508. u8 scsiDevType;
  509. union {
  510. u8 connectedPortBitmap;
  511. u8 connectedPortNumbers;
  512. };
  513. u8 deviceSpeed;
  514. u32 mediaErrCount;
  515. u32 otherErrCount;
  516. u32 predFailCount;
  517. u32 lastPredFailEventSeqNum;
  518. u16 fwState;
  519. u8 disabledForRemoval;
  520. u8 linkSpeed;
  521. union MR_PD_DDF_TYPE state;
  522. struct {
  523. u8 count;
  524. #ifndef __BIG_ENDIAN_BITFIELD
  525. u8 isPathBroken:4;
  526. u8 reserved3:3;
  527. u8 widePortCapable:1;
  528. #else
  529. u8 widePortCapable:1;
  530. u8 reserved3:3;
  531. u8 isPathBroken:4;
  532. #endif
  533. u8 connectorIndex[2];
  534. u8 reserved[4];
  535. u64 sasAddr[2];
  536. u8 reserved2[16];
  537. } pathInfo;
  538. u64 rawSize;
  539. u64 nonCoercedSize;
  540. u64 coercedSize;
  541. u16 enclDeviceId;
  542. u8 enclIndex;
  543. union {
  544. u8 slotNumber;
  545. u8 enclConnectorIndex;
  546. };
  547. struct MR_PD_PROGRESS progInfo;
  548. u8 badBlockTableFull;
  549. u8 unusableInCurrentConfig;
  550. u8 vpdPage83Ext[64];
  551. u8 powerState;
  552. u8 enclPosition;
  553. u32 allowedOps;
  554. u16 copyBackPartnerId;
  555. u16 enclPartnerDeviceId;
  556. struct {
  557. #ifndef __BIG_ENDIAN_BITFIELD
  558. u16 fdeCapable:1;
  559. u16 fdeEnabled:1;
  560. u16 secured:1;
  561. u16 locked:1;
  562. u16 foreign:1;
  563. u16 needsEKM:1;
  564. u16 reserved:10;
  565. #else
  566. u16 reserved:10;
  567. u16 needsEKM:1;
  568. u16 foreign:1;
  569. u16 locked:1;
  570. u16 secured:1;
  571. u16 fdeEnabled:1;
  572. u16 fdeCapable:1;
  573. #endif
  574. } security;
  575. u8 mediaType;
  576. u8 notCertified;
  577. u8 bridgeVendor[8];
  578. u8 bridgeProductIdentification[16];
  579. u8 bridgeProductRevisionLevel[4];
  580. u8 satBridgeExists;
  581. u8 interfaceType;
  582. u8 temperature;
  583. u8 emulatedBlockSize;
  584. u16 userDataBlockSize;
  585. u16 reserved2;
  586. struct {
  587. #ifndef __BIG_ENDIAN_BITFIELD
  588. u32 piType:3;
  589. u32 piFormatted:1;
  590. u32 piEligible:1;
  591. u32 NCQ:1;
  592. u32 WCE:1;
  593. u32 commissionedSpare:1;
  594. u32 emergencySpare:1;
  595. u32 ineligibleForSSCD:1;
  596. u32 ineligibleForLd:1;
  597. u32 useSSEraseType:1;
  598. u32 wceUnchanged:1;
  599. u32 supportScsiUnmap:1;
  600. u32 reserved:18;
  601. #else
  602. u32 reserved:18;
  603. u32 supportScsiUnmap:1;
  604. u32 wceUnchanged:1;
  605. u32 useSSEraseType:1;
  606. u32 ineligibleForLd:1;
  607. u32 ineligibleForSSCD:1;
  608. u32 emergencySpare:1;
  609. u32 commissionedSpare:1;
  610. u32 WCE:1;
  611. u32 NCQ:1;
  612. u32 piEligible:1;
  613. u32 piFormatted:1;
  614. u32 piType:3;
  615. #endif
  616. } properties;
  617. u64 shieldDiagCompletionTime;
  618. u8 shieldCounter;
  619. u8 linkSpeedOther;
  620. u8 reserved4[2];
  621. struct {
  622. #ifndef __BIG_ENDIAN_BITFIELD
  623. u32 bbmErrCountSupported:1;
  624. u32 bbmErrCount:31;
  625. #else
  626. u32 bbmErrCount:31;
  627. u32 bbmErrCountSupported:1;
  628. #endif
  629. } bbmErr;
  630. u8 reserved1[512-428];
  631. } __packed;
  632. /*
  633. * Definition of structure used to expose attributes of VD or JBOD
  634. * (this structure is to be filled by firmware when MR_DCMD_DRV_GET_TARGET_PROP
  635. * is fired by driver)
  636. */
  637. struct MR_TARGET_PROPERTIES {
  638. u32 max_io_size_kb;
  639. u32 device_qdepth;
  640. u32 sector_size;
  641. u8 reserved[500];
  642. } __packed;
  643. /*
  644. * defines the physical drive address structure
  645. */
  646. struct MR_PD_ADDRESS {
  647. __le16 deviceId;
  648. u16 enclDeviceId;
  649. union {
  650. struct {
  651. u8 enclIndex;
  652. u8 slotNumber;
  653. } mrPdAddress;
  654. struct {
  655. u8 enclPosition;
  656. u8 enclConnectorIndex;
  657. } mrEnclAddress;
  658. };
  659. u8 scsiDevType;
  660. union {
  661. u8 connectedPortBitmap;
  662. u8 connectedPortNumbers;
  663. };
  664. u64 sasAddr[2];
  665. } __packed;
  666. /*
  667. * defines the physical drive list structure
  668. */
  669. struct MR_PD_LIST {
  670. __le32 size;
  671. __le32 count;
  672. struct MR_PD_ADDRESS addr[1];
  673. } __packed;
  674. struct megasas_pd_list {
  675. u16 tid;
  676. u8 driveType;
  677. u8 driveState;
  678. } __packed;
  679. /*
  680. * defines the logical drive reference structure
  681. */
  682. union MR_LD_REF {
  683. struct {
  684. u8 targetId;
  685. u8 reserved;
  686. __le16 seqNum;
  687. };
  688. __le32 ref;
  689. } __packed;
  690. /*
  691. * defines the logical drive list structure
  692. */
  693. struct MR_LD_LIST {
  694. __le32 ldCount;
  695. __le32 reserved;
  696. struct {
  697. union MR_LD_REF ref;
  698. u8 state;
  699. u8 reserved[3];
  700. __le64 size;
  701. } ldList[MAX_LOGICAL_DRIVES_EXT];
  702. } __packed;
  703. struct MR_LD_TARGETID_LIST {
  704. __le32 size;
  705. __le32 count;
  706. u8 pad[3];
  707. u8 targetId[MAX_LOGICAL_DRIVES_EXT];
  708. };
  709. /*
  710. * SAS controller properties
  711. */
  712. struct megasas_ctrl_prop {
  713. u16 seq_num;
  714. u16 pred_fail_poll_interval;
  715. u16 intr_throttle_count;
  716. u16 intr_throttle_timeouts;
  717. u8 rebuild_rate;
  718. u8 patrol_read_rate;
  719. u8 bgi_rate;
  720. u8 cc_rate;
  721. u8 recon_rate;
  722. u8 cache_flush_interval;
  723. u8 spinup_drv_count;
  724. u8 spinup_delay;
  725. u8 cluster_enable;
  726. u8 coercion_mode;
  727. u8 alarm_enable;
  728. u8 disable_auto_rebuild;
  729. u8 disable_battery_warn;
  730. u8 ecc_bucket_size;
  731. u16 ecc_bucket_leak_rate;
  732. u8 restore_hotspare_on_insertion;
  733. u8 expose_encl_devices;
  734. u8 maintainPdFailHistory;
  735. u8 disallowHostRequestReordering;
  736. u8 abortCCOnError;
  737. u8 loadBalanceMode;
  738. u8 disableAutoDetectBackplane;
  739. u8 snapVDSpace;
  740. /*
  741. * Add properties that can be controlled by
  742. * a bit in the following structure.
  743. */
  744. struct {
  745. #if defined(__BIG_ENDIAN_BITFIELD)
  746. u32 reserved:18;
  747. u32 enableJBOD:1;
  748. u32 disableSpinDownHS:1;
  749. u32 allowBootWithPinnedCache:1;
  750. u32 disableOnlineCtrlReset:1;
  751. u32 enableSecretKeyControl:1;
  752. u32 autoEnhancedImport:1;
  753. u32 enableSpinDownUnconfigured:1;
  754. u32 SSDPatrolReadEnabled:1;
  755. u32 SSDSMARTerEnabled:1;
  756. u32 disableNCQ:1;
  757. u32 useFdeOnly:1;
  758. u32 prCorrectUnconfiguredAreas:1;
  759. u32 SMARTerEnabled:1;
  760. u32 copyBackDisabled:1;
  761. #else
  762. u32 copyBackDisabled:1;
  763. u32 SMARTerEnabled:1;
  764. u32 prCorrectUnconfiguredAreas:1;
  765. u32 useFdeOnly:1;
  766. u32 disableNCQ:1;
  767. u32 SSDSMARTerEnabled:1;
  768. u32 SSDPatrolReadEnabled:1;
  769. u32 enableSpinDownUnconfigured:1;
  770. u32 autoEnhancedImport:1;
  771. u32 enableSecretKeyControl:1;
  772. u32 disableOnlineCtrlReset:1;
  773. u32 allowBootWithPinnedCache:1;
  774. u32 disableSpinDownHS:1;
  775. u32 enableJBOD:1;
  776. u32 reserved:18;
  777. #endif
  778. } OnOffProperties;
  779. u8 autoSnapVDSpace;
  780. u8 viewSpace;
  781. __le16 spinDownTime;
  782. u8 reserved[24];
  783. } __packed;
  784. /*
  785. * SAS controller information
  786. */
  787. struct megasas_ctrl_info {
  788. /*
  789. * PCI device information
  790. */
  791. struct {
  792. __le16 vendor_id;
  793. __le16 device_id;
  794. __le16 sub_vendor_id;
  795. __le16 sub_device_id;
  796. u8 reserved[24];
  797. } __attribute__ ((packed)) pci;
  798. /*
  799. * Host interface information
  800. */
  801. struct {
  802. u8 PCIX:1;
  803. u8 PCIE:1;
  804. u8 iSCSI:1;
  805. u8 SAS_3G:1;
  806. u8 SRIOV:1;
  807. u8 reserved_0:3;
  808. u8 reserved_1[6];
  809. u8 port_count;
  810. u64 port_addr[8];
  811. } __attribute__ ((packed)) host_interface;
  812. /*
  813. * Device (backend) interface information
  814. */
  815. struct {
  816. u8 SPI:1;
  817. u8 SAS_3G:1;
  818. u8 SATA_1_5G:1;
  819. u8 SATA_3G:1;
  820. u8 reserved_0:4;
  821. u8 reserved_1[6];
  822. u8 port_count;
  823. u64 port_addr[8];
  824. } __attribute__ ((packed)) device_interface;
  825. /*
  826. * List of components residing in flash. All str are null terminated
  827. */
  828. __le32 image_check_word;
  829. __le32 image_component_count;
  830. struct {
  831. char name[8];
  832. char version[32];
  833. char build_date[16];
  834. char built_time[16];
  835. } __attribute__ ((packed)) image_component[8];
  836. /*
  837. * List of flash components that have been flashed on the card, but
  838. * are not in use, pending reset of the adapter. This list will be
  839. * empty if a flash operation has not occurred. All stings are null
  840. * terminated
  841. */
  842. __le32 pending_image_component_count;
  843. struct {
  844. char name[8];
  845. char version[32];
  846. char build_date[16];
  847. char build_time[16];
  848. } __attribute__ ((packed)) pending_image_component[8];
  849. u8 max_arms;
  850. u8 max_spans;
  851. u8 max_arrays;
  852. u8 max_lds;
  853. char product_name[80];
  854. char serial_no[32];
  855. /*
  856. * Other physical/controller/operation information. Indicates the
  857. * presence of the hardware
  858. */
  859. struct {
  860. u32 bbu:1;
  861. u32 alarm:1;
  862. u32 nvram:1;
  863. u32 uart:1;
  864. u32 reserved:28;
  865. } __attribute__ ((packed)) hw_present;
  866. __le32 current_fw_time;
  867. /*
  868. * Maximum data transfer sizes
  869. */
  870. __le16 max_concurrent_cmds;
  871. __le16 max_sge_count;
  872. __le32 max_request_size;
  873. /*
  874. * Logical and physical device counts
  875. */
  876. __le16 ld_present_count;
  877. __le16 ld_degraded_count;
  878. __le16 ld_offline_count;
  879. __le16 pd_present_count;
  880. __le16 pd_disk_present_count;
  881. __le16 pd_disk_pred_failure_count;
  882. __le16 pd_disk_failed_count;
  883. /*
  884. * Memory size information
  885. */
  886. __le16 nvram_size;
  887. __le16 memory_size;
  888. __le16 flash_size;
  889. /*
  890. * Error counters
  891. */
  892. __le16 mem_correctable_error_count;
  893. __le16 mem_uncorrectable_error_count;
  894. /*
  895. * Cluster information
  896. */
  897. u8 cluster_permitted;
  898. u8 cluster_active;
  899. /*
  900. * Additional max data transfer sizes
  901. */
  902. __le16 max_strips_per_io;
  903. /*
  904. * Controller capabilities structures
  905. */
  906. struct {
  907. u32 raid_level_0:1;
  908. u32 raid_level_1:1;
  909. u32 raid_level_5:1;
  910. u32 raid_level_1E:1;
  911. u32 raid_level_6:1;
  912. u32 reserved:27;
  913. } __attribute__ ((packed)) raid_levels;
  914. struct {
  915. u32 rbld_rate:1;
  916. u32 cc_rate:1;
  917. u32 bgi_rate:1;
  918. u32 recon_rate:1;
  919. u32 patrol_rate:1;
  920. u32 alarm_control:1;
  921. u32 cluster_supported:1;
  922. u32 bbu:1;
  923. u32 spanning_allowed:1;
  924. u32 dedicated_hotspares:1;
  925. u32 revertible_hotspares:1;
  926. u32 foreign_config_import:1;
  927. u32 self_diagnostic:1;
  928. u32 mixed_redundancy_arr:1;
  929. u32 global_hot_spares:1;
  930. u32 reserved:17;
  931. } __attribute__ ((packed)) adapter_operations;
  932. struct {
  933. u32 read_policy:1;
  934. u32 write_policy:1;
  935. u32 io_policy:1;
  936. u32 access_policy:1;
  937. u32 disk_cache_policy:1;
  938. u32 reserved:27;
  939. } __attribute__ ((packed)) ld_operations;
  940. struct {
  941. u8 min;
  942. u8 max;
  943. u8 reserved[2];
  944. } __attribute__ ((packed)) stripe_sz_ops;
  945. struct {
  946. u32 force_online:1;
  947. u32 force_offline:1;
  948. u32 force_rebuild:1;
  949. u32 reserved:29;
  950. } __attribute__ ((packed)) pd_operations;
  951. struct {
  952. u32 ctrl_supports_sas:1;
  953. u32 ctrl_supports_sata:1;
  954. u32 allow_mix_in_encl:1;
  955. u32 allow_mix_in_ld:1;
  956. u32 allow_sata_in_cluster:1;
  957. u32 reserved:27;
  958. } __attribute__ ((packed)) pd_mix_support;
  959. /*
  960. * Define ECC single-bit-error bucket information
  961. */
  962. u8 ecc_bucket_count;
  963. u8 reserved_2[11];
  964. /*
  965. * Include the controller properties (changeable items)
  966. */
  967. struct megasas_ctrl_prop properties;
  968. /*
  969. * Define FW pkg version (set in envt v'bles on OEM basis)
  970. */
  971. char package_version[0x60];
  972. /*
  973. * If adapterOperations.supportMoreThan8Phys is set,
  974. * and deviceInterface.portCount is greater than 8,
  975. * SAS Addrs for first 8 ports shall be populated in
  976. * deviceInterface.portAddr, and the rest shall be
  977. * populated in deviceInterfacePortAddr2.
  978. */
  979. __le64 deviceInterfacePortAddr2[8]; /*6a0h */
  980. u8 reserved3[128]; /*6e0h */
  981. struct { /*760h */
  982. u16 minPdRaidLevel_0:4;
  983. u16 maxPdRaidLevel_0:12;
  984. u16 minPdRaidLevel_1:4;
  985. u16 maxPdRaidLevel_1:12;
  986. u16 minPdRaidLevel_5:4;
  987. u16 maxPdRaidLevel_5:12;
  988. u16 minPdRaidLevel_1E:4;
  989. u16 maxPdRaidLevel_1E:12;
  990. u16 minPdRaidLevel_6:4;
  991. u16 maxPdRaidLevel_6:12;
  992. u16 minPdRaidLevel_10:4;
  993. u16 maxPdRaidLevel_10:12;
  994. u16 minPdRaidLevel_50:4;
  995. u16 maxPdRaidLevel_50:12;
  996. u16 minPdRaidLevel_60:4;
  997. u16 maxPdRaidLevel_60:12;
  998. u16 minPdRaidLevel_1E_RLQ0:4;
  999. u16 maxPdRaidLevel_1E_RLQ0:12;
  1000. u16 minPdRaidLevel_1E0_RLQ0:4;
  1001. u16 maxPdRaidLevel_1E0_RLQ0:12;
  1002. u16 reserved[6];
  1003. } pdsForRaidLevels;
  1004. __le16 maxPds; /*780h */
  1005. __le16 maxDedHSPs; /*782h */
  1006. __le16 maxGlobalHSP; /*784h */
  1007. __le16 ddfSize; /*786h */
  1008. u8 maxLdsPerArray; /*788h */
  1009. u8 partitionsInDDF; /*789h */
  1010. u8 lockKeyBinding; /*78ah */
  1011. u8 maxPITsPerLd; /*78bh */
  1012. u8 maxViewsPerLd; /*78ch */
  1013. u8 maxTargetId; /*78dh */
  1014. __le16 maxBvlVdSize; /*78eh */
  1015. __le16 maxConfigurableSSCSize; /*790h */
  1016. __le16 currentSSCsize; /*792h */
  1017. char expanderFwVersion[12]; /*794h */
  1018. __le16 PFKTrialTimeRemaining; /*7A0h */
  1019. __le16 cacheMemorySize; /*7A2h */
  1020. struct { /*7A4h */
  1021. #if defined(__BIG_ENDIAN_BITFIELD)
  1022. u32 reserved:5;
  1023. u32 activePassive:2;
  1024. u32 supportConfigAutoBalance:1;
  1025. u32 mpio:1;
  1026. u32 supportDataLDonSSCArray:1;
  1027. u32 supportPointInTimeProgress:1;
  1028. u32 supportUnevenSpans:1;
  1029. u32 dedicatedHotSparesLimited:1;
  1030. u32 headlessMode:1;
  1031. u32 supportEmulatedDrives:1;
  1032. u32 supportResetNow:1;
  1033. u32 realTimeScheduler:1;
  1034. u32 supportSSDPatrolRead:1;
  1035. u32 supportPerfTuning:1;
  1036. u32 disableOnlinePFKChange:1;
  1037. u32 supportJBOD:1;
  1038. u32 supportBootTimePFKChange:1;
  1039. u32 supportSetLinkSpeed:1;
  1040. u32 supportEmergencySpares:1;
  1041. u32 supportSuspendResumeBGops:1;
  1042. u32 blockSSDWriteCacheChange:1;
  1043. u32 supportShieldState:1;
  1044. u32 supportLdBBMInfo:1;
  1045. u32 supportLdPIType3:1;
  1046. u32 supportLdPIType2:1;
  1047. u32 supportLdPIType1:1;
  1048. u32 supportPIcontroller:1;
  1049. #else
  1050. u32 supportPIcontroller:1;
  1051. u32 supportLdPIType1:1;
  1052. u32 supportLdPIType2:1;
  1053. u32 supportLdPIType3:1;
  1054. u32 supportLdBBMInfo:1;
  1055. u32 supportShieldState:1;
  1056. u32 blockSSDWriteCacheChange:1;
  1057. u32 supportSuspendResumeBGops:1;
  1058. u32 supportEmergencySpares:1;
  1059. u32 supportSetLinkSpeed:1;
  1060. u32 supportBootTimePFKChange:1;
  1061. u32 supportJBOD:1;
  1062. u32 disableOnlinePFKChange:1;
  1063. u32 supportPerfTuning:1;
  1064. u32 supportSSDPatrolRead:1;
  1065. u32 realTimeScheduler:1;
  1066. u32 supportResetNow:1;
  1067. u32 supportEmulatedDrives:1;
  1068. u32 headlessMode:1;
  1069. u32 dedicatedHotSparesLimited:1;
  1070. u32 supportUnevenSpans:1;
  1071. u32 supportPointInTimeProgress:1;
  1072. u32 supportDataLDonSSCArray:1;
  1073. u32 mpio:1;
  1074. u32 supportConfigAutoBalance:1;
  1075. u32 activePassive:2;
  1076. u32 reserved:5;
  1077. #endif
  1078. } adapterOperations2;
  1079. u8 driverVersion[32]; /*7A8h */
  1080. u8 maxDAPdCountSpinup60; /*7C8h */
  1081. u8 temperatureROC; /*7C9h */
  1082. u8 temperatureCtrl; /*7CAh */
  1083. u8 reserved4; /*7CBh */
  1084. __le16 maxConfigurablePds; /*7CCh */
  1085. u8 reserved5[2]; /*0x7CDh */
  1086. /*
  1087. * HA cluster information
  1088. */
  1089. struct {
  1090. #if defined(__BIG_ENDIAN_BITFIELD)
  1091. u32 reserved:25;
  1092. u32 passive:1;
  1093. u32 premiumFeatureMismatch:1;
  1094. u32 ctrlPropIncompatible:1;
  1095. u32 fwVersionMismatch:1;
  1096. u32 hwIncompatible:1;
  1097. u32 peerIsIncompatible:1;
  1098. u32 peerIsPresent:1;
  1099. #else
  1100. u32 peerIsPresent:1;
  1101. u32 peerIsIncompatible:1;
  1102. u32 hwIncompatible:1;
  1103. u32 fwVersionMismatch:1;
  1104. u32 ctrlPropIncompatible:1;
  1105. u32 premiumFeatureMismatch:1;
  1106. u32 passive:1;
  1107. u32 reserved:25;
  1108. #endif
  1109. } cluster;
  1110. char clusterId[MEGASAS_CLUSTER_ID_SIZE]; /*0x7D4 */
  1111. struct {
  1112. u8 maxVFsSupported; /*0x7E4*/
  1113. u8 numVFsEnabled; /*0x7E5*/
  1114. u8 requestorId; /*0x7E6 0:PF, 1:VF1, 2:VF2*/
  1115. u8 reserved; /*0x7E7*/
  1116. } iov;
  1117. struct {
  1118. #if defined(__BIG_ENDIAN_BITFIELD)
  1119. u32 reserved:7;
  1120. u32 useSeqNumJbodFP:1;
  1121. u32 supportExtendedSSCSize:1;
  1122. u32 supportDiskCacheSettingForSysPDs:1;
  1123. u32 supportCPLDUpdate:1;
  1124. u32 supportTTYLogCompression:1;
  1125. u32 discardCacheDuringLDDelete:1;
  1126. u32 supportSecurityonJBOD:1;
  1127. u32 supportCacheBypassModes:1;
  1128. u32 supportDisableSESMonitoring:1;
  1129. u32 supportForceFlash:1;
  1130. u32 supportNVDRAM:1;
  1131. u32 supportDrvActivityLEDSetting:1;
  1132. u32 supportAllowedOpsforDrvRemoval:1;
  1133. u32 supportHOQRebuild:1;
  1134. u32 supportForceTo512e:1;
  1135. u32 supportNVCacheErase:1;
  1136. u32 supportDebugQueue:1;
  1137. u32 supportSwZone:1;
  1138. u32 supportCrashDump:1;
  1139. u32 supportMaxExtLDs:1;
  1140. u32 supportT10RebuildAssist:1;
  1141. u32 supportDisableImmediateIO:1;
  1142. u32 supportThermalPollInterval:1;
  1143. u32 supportPersonalityChange:2;
  1144. #else
  1145. u32 supportPersonalityChange:2;
  1146. u32 supportThermalPollInterval:1;
  1147. u32 supportDisableImmediateIO:1;
  1148. u32 supportT10RebuildAssist:1;
  1149. u32 supportMaxExtLDs:1;
  1150. u32 supportCrashDump:1;
  1151. u32 supportSwZone:1;
  1152. u32 supportDebugQueue:1;
  1153. u32 supportNVCacheErase:1;
  1154. u32 supportForceTo512e:1;
  1155. u32 supportHOQRebuild:1;
  1156. u32 supportAllowedOpsforDrvRemoval:1;
  1157. u32 supportDrvActivityLEDSetting:1;
  1158. u32 supportNVDRAM:1;
  1159. u32 supportForceFlash:1;
  1160. u32 supportDisableSESMonitoring:1;
  1161. u32 supportCacheBypassModes:1;
  1162. u32 supportSecurityonJBOD:1;
  1163. u32 discardCacheDuringLDDelete:1;
  1164. u32 supportTTYLogCompression:1;
  1165. u32 supportCPLDUpdate:1;
  1166. u32 supportDiskCacheSettingForSysPDs:1;
  1167. u32 supportExtendedSSCSize:1;
  1168. u32 useSeqNumJbodFP:1;
  1169. u32 reserved:7;
  1170. #endif
  1171. } adapterOperations3;
  1172. struct {
  1173. #if defined(__BIG_ENDIAN_BITFIELD)
  1174. u8 reserved:7;
  1175. /* Indicates whether the CPLD image is part of
  1176. * the package and stored in flash
  1177. */
  1178. u8 cpld_in_flash:1;
  1179. #else
  1180. u8 cpld_in_flash:1;
  1181. u8 reserved:7;
  1182. #endif
  1183. u8 reserved1[3];
  1184. /* Null terminated string. Has the version
  1185. * information if cpld_in_flash = FALSE
  1186. */
  1187. u8 userCodeDefinition[12];
  1188. } cpld; /* Valid only if upgradableCPLD is TRUE */
  1189. struct {
  1190. #if defined(__BIG_ENDIAN_BITFIELD)
  1191. u16 reserved:8;
  1192. u16 fw_swaps_bbu_vpd_info:1;
  1193. u16 support_pd_map_target_id:1;
  1194. u16 support_ses_ctrl_in_multipathcfg:1;
  1195. u16 image_upload_supported:1;
  1196. u16 support_encrypted_mfc:1;
  1197. u16 supported_enc_algo:1;
  1198. u16 support_ibutton_less:1;
  1199. u16 ctrl_info_ext_supported:1;
  1200. #else
  1201. u16 ctrl_info_ext_supported:1;
  1202. u16 support_ibutton_less:1;
  1203. u16 supported_enc_algo:1;
  1204. u16 support_encrypted_mfc:1;
  1205. u16 image_upload_supported:1;
  1206. /* FW supports LUN based association and target port based */
  1207. u16 support_ses_ctrl_in_multipathcfg:1;
  1208. /* association for the SES device connected in multipath mode */
  1209. /* FW defines Jbod target Id within MR_PD_CFG_SEQ */
  1210. u16 support_pd_map_target_id:1;
  1211. /* FW swaps relevant fields in MR_BBU_VPD_INFO_FIXED to
  1212. * provide the data in little endian order
  1213. */
  1214. u16 fw_swaps_bbu_vpd_info:1;
  1215. u16 reserved:8;
  1216. #endif
  1217. } adapter_operations4;
  1218. u8 pad[0x800 - 0x7FE]; /* 0x7FE pad to 2K for expansion */
  1219. } __packed;
  1220. /*
  1221. * ===============================
  1222. * MegaRAID SAS driver definitions
  1223. * ===============================
  1224. */
  1225. #define MEGASAS_MAX_PD_CHANNELS 2
  1226. #define MEGASAS_MAX_LD_CHANNELS 2
  1227. #define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
  1228. MEGASAS_MAX_LD_CHANNELS)
  1229. #define MEGASAS_MAX_DEV_PER_CHANNEL 128
  1230. #define MEGASAS_DEFAULT_INIT_ID -1
  1231. #define MEGASAS_MAX_LUN 8
  1232. #define MEGASAS_DEFAULT_CMD_PER_LUN 256
  1233. #define MEGASAS_MAX_PD (MEGASAS_MAX_PD_CHANNELS * \
  1234. MEGASAS_MAX_DEV_PER_CHANNEL)
  1235. #define MEGASAS_MAX_LD_IDS (MEGASAS_MAX_LD_CHANNELS * \
  1236. MEGASAS_MAX_DEV_PER_CHANNEL)
  1237. #define MEGASAS_MAX_SECTORS (2*1024)
  1238. #define MEGASAS_MAX_SECTORS_IEEE (2*128)
  1239. #define MEGASAS_DBG_LVL 1
  1240. #define MEGASAS_FW_BUSY 1
  1241. /* Driver's internal Logging levels*/
  1242. #define OCR_LOGS (1 << 0)
  1243. #define SCAN_PD_CHANNEL 0x1
  1244. #define SCAN_VD_CHANNEL 0x2
  1245. #define MEGASAS_KDUMP_QUEUE_DEPTH 100
  1246. #define MR_LARGE_IO_MIN_SIZE (32 * 1024)
  1247. #define MR_R1_LDIO_PIGGYBACK_DEFAULT 4
  1248. enum MR_SCSI_CMD_TYPE {
  1249. READ_WRITE_LDIO = 0,
  1250. NON_READ_WRITE_LDIO = 1,
  1251. READ_WRITE_SYSPDIO = 2,
  1252. NON_READ_WRITE_SYSPDIO = 3,
  1253. };
  1254. enum DCMD_TIMEOUT_ACTION {
  1255. INITIATE_OCR = 0,
  1256. KILL_ADAPTER = 1,
  1257. IGNORE_TIMEOUT = 2,
  1258. };
  1259. enum FW_BOOT_CONTEXT {
  1260. PROBE_CONTEXT = 0,
  1261. OCR_CONTEXT = 1,
  1262. };
  1263. /* Frame Type */
  1264. #define IO_FRAME 0
  1265. #define PTHRU_FRAME 1
  1266. /*
  1267. * When SCSI mid-layer calls driver's reset routine, driver waits for
  1268. * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
  1269. * that the driver cannot _actually_ abort or reset pending commands. While
  1270. * it is waiting for the commands to complete, it prints a diagnostic message
  1271. * every MEGASAS_RESET_NOTICE_INTERVAL seconds
  1272. */
  1273. #define MEGASAS_RESET_WAIT_TIME 180
  1274. #define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
  1275. #define MEGASAS_RESET_NOTICE_INTERVAL 5
  1276. #define MEGASAS_IOCTL_CMD 0
  1277. #define MEGASAS_DEFAULT_CMD_TIMEOUT 90
  1278. #define MEGASAS_THROTTLE_QUEUE_DEPTH 16
  1279. #define MEGASAS_BLOCKED_CMD_TIMEOUT 60
  1280. /*
  1281. * FW reports the maximum of number of commands that it can accept (maximum
  1282. * commands that can be outstanding) at any time. The driver must report a
  1283. * lower number to the mid layer because it can issue a few internal commands
  1284. * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
  1285. * is shown below
  1286. */
  1287. #define MEGASAS_INT_CMDS 32
  1288. #define MEGASAS_SKINNY_INT_CMDS 5
  1289. #define MEGASAS_FUSION_INTERNAL_CMDS 8
  1290. #define MEGASAS_FUSION_IOCTL_CMDS 3
  1291. #define MEGASAS_MFI_IOCTL_CMDS 27
  1292. #define MEGASAS_MAX_MSIX_QUEUES 128
  1293. /*
  1294. * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
  1295. * SGLs based on the size of dma_addr_t
  1296. */
  1297. #define IS_DMA64 (sizeof(dma_addr_t) == 8)
  1298. #define MFI_XSCALE_OMR0_CHANGE_INTERRUPT 0x00000001
  1299. #define MFI_INTR_FLAG_REPLY_MESSAGE 0x00000001
  1300. #define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE 0x00000002
  1301. #define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT 0x00000004
  1302. #define MFI_OB_INTR_STATUS_MASK 0x00000002
  1303. #define MFI_POLL_TIMEOUT_SECS 60
  1304. #define MFI_IO_TIMEOUT_SECS 180
  1305. #define MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF (5 * HZ)
  1306. #define MEGASAS_OCR_SETTLE_TIME_VF (1000 * 30)
  1307. #define MEGASAS_ROUTINE_WAIT_TIME_VF 300
  1308. #define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
  1309. #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
  1310. #define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
  1311. #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
  1312. #define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
  1313. #define MFI_1068_PCSR_OFFSET 0x84
  1314. #define MFI_1068_FW_HANDSHAKE_OFFSET 0x64
  1315. #define MFI_1068_FW_READY 0xDDDD0000
  1316. #define MR_MAX_REPLY_QUEUES_OFFSET 0X0000001F
  1317. #define MR_MAX_REPLY_QUEUES_EXT_OFFSET 0X003FC000
  1318. #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT 14
  1319. #define MR_MAX_MSIX_REG_ARRAY 16
  1320. #define MR_RDPQ_MODE_OFFSET 0X00800000
  1321. #define MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT 16
  1322. #define MR_MAX_RAID_MAP_SIZE_MASK 0x1FF
  1323. #define MR_MIN_MAP_SIZE 0x10000
  1324. /* 64k */
  1325. #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET 0X01000000
  1326. enum MR_ADAPTER_TYPE {
  1327. MFI_SERIES = 1,
  1328. THUNDERBOLT_SERIES = 2,
  1329. INVADER_SERIES = 3,
  1330. VENTURA_SERIES = 4,
  1331. };
  1332. /*
  1333. * register set for both 1068 and 1078 controllers
  1334. * structure extended for 1078 registers
  1335. */
  1336. struct megasas_register_set {
  1337. u32 doorbell; /*0000h*/
  1338. u32 fusion_seq_offset; /*0004h*/
  1339. u32 fusion_host_diag; /*0008h*/
  1340. u32 reserved_01; /*000Ch*/
  1341. u32 inbound_msg_0; /*0010h*/
  1342. u32 inbound_msg_1; /*0014h*/
  1343. u32 outbound_msg_0; /*0018h*/
  1344. u32 outbound_msg_1; /*001Ch*/
  1345. u32 inbound_doorbell; /*0020h*/
  1346. u32 inbound_intr_status; /*0024h*/
  1347. u32 inbound_intr_mask; /*0028h*/
  1348. u32 outbound_doorbell; /*002Ch*/
  1349. u32 outbound_intr_status; /*0030h*/
  1350. u32 outbound_intr_mask; /*0034h*/
  1351. u32 reserved_1[2]; /*0038h*/
  1352. u32 inbound_queue_port; /*0040h*/
  1353. u32 outbound_queue_port; /*0044h*/
  1354. u32 reserved_2[9]; /*0048h*/
  1355. u32 reply_post_host_index; /*006Ch*/
  1356. u32 reserved_2_2[12]; /*0070h*/
  1357. u32 outbound_doorbell_clear; /*00A0h*/
  1358. u32 reserved_3[3]; /*00A4h*/
  1359. u32 outbound_scratch_pad ; /*00B0h*/
  1360. u32 outbound_scratch_pad_2; /*00B4h*/
  1361. u32 outbound_scratch_pad_3; /*00B8h*/
  1362. u32 outbound_scratch_pad_4; /*00BCh*/
  1363. u32 inbound_low_queue_port ; /*00C0h*/
  1364. u32 inbound_high_queue_port ; /*00C4h*/
  1365. u32 inbound_single_queue_port; /*00C8h*/
  1366. u32 res_6[11]; /*CCh*/
  1367. u32 host_diag;
  1368. u32 seq_offset;
  1369. u32 index_registers[807]; /*00CCh*/
  1370. } __attribute__ ((packed));
  1371. struct megasas_sge32 {
  1372. __le32 phys_addr;
  1373. __le32 length;
  1374. } __attribute__ ((packed));
  1375. struct megasas_sge64 {
  1376. __le64 phys_addr;
  1377. __le32 length;
  1378. } __attribute__ ((packed));
  1379. struct megasas_sge_skinny {
  1380. __le64 phys_addr;
  1381. __le32 length;
  1382. __le32 flag;
  1383. } __packed;
  1384. union megasas_sgl {
  1385. struct megasas_sge32 sge32[1];
  1386. struct megasas_sge64 sge64[1];
  1387. struct megasas_sge_skinny sge_skinny[1];
  1388. } __attribute__ ((packed));
  1389. struct megasas_header {
  1390. u8 cmd; /*00h */
  1391. u8 sense_len; /*01h */
  1392. u8 cmd_status; /*02h */
  1393. u8 scsi_status; /*03h */
  1394. u8 target_id; /*04h */
  1395. u8 lun; /*05h */
  1396. u8 cdb_len; /*06h */
  1397. u8 sge_count; /*07h */
  1398. __le32 context; /*08h */
  1399. __le32 pad_0; /*0Ch */
  1400. __le16 flags; /*10h */
  1401. __le16 timeout; /*12h */
  1402. __le32 data_xferlen; /*14h */
  1403. } __attribute__ ((packed));
  1404. union megasas_sgl_frame {
  1405. struct megasas_sge32 sge32[8];
  1406. struct megasas_sge64 sge64[5];
  1407. } __attribute__ ((packed));
  1408. typedef union _MFI_CAPABILITIES {
  1409. struct {
  1410. #if defined(__BIG_ENDIAN_BITFIELD)
  1411. u32 reserved:19;
  1412. u32 support_pd_map_target_id:1;
  1413. u32 support_qd_throttling:1;
  1414. u32 support_fp_rlbypass:1;
  1415. u32 support_vfid_in_ioframe:1;
  1416. u32 support_ext_io_size:1;
  1417. u32 support_ext_queue_depth:1;
  1418. u32 security_protocol_cmds_fw:1;
  1419. u32 support_core_affinity:1;
  1420. u32 support_ndrive_r1_lb:1;
  1421. u32 support_max_255lds:1;
  1422. u32 support_fastpath_wb:1;
  1423. u32 support_additional_msix:1;
  1424. u32 support_fp_remote_lun:1;
  1425. #else
  1426. u32 support_fp_remote_lun:1;
  1427. u32 support_additional_msix:1;
  1428. u32 support_fastpath_wb:1;
  1429. u32 support_max_255lds:1;
  1430. u32 support_ndrive_r1_lb:1;
  1431. u32 support_core_affinity:1;
  1432. u32 security_protocol_cmds_fw:1;
  1433. u32 support_ext_queue_depth:1;
  1434. u32 support_ext_io_size:1;
  1435. u32 support_vfid_in_ioframe:1;
  1436. u32 support_fp_rlbypass:1;
  1437. u32 support_qd_throttling:1;
  1438. u32 support_pd_map_target_id:1;
  1439. u32 reserved:19;
  1440. #endif
  1441. } mfi_capabilities;
  1442. __le32 reg;
  1443. } MFI_CAPABILITIES;
  1444. struct megasas_init_frame {
  1445. u8 cmd; /*00h */
  1446. u8 reserved_0; /*01h */
  1447. u8 cmd_status; /*02h */
  1448. u8 reserved_1; /*03h */
  1449. MFI_CAPABILITIES driver_operations; /*04h*/
  1450. __le32 context; /*08h */
  1451. __le32 pad_0; /*0Ch */
  1452. __le16 flags; /*10h */
  1453. __le16 reserved_3; /*12h */
  1454. __le32 data_xfer_len; /*14h */
  1455. __le32 queue_info_new_phys_addr_lo; /*18h */
  1456. __le32 queue_info_new_phys_addr_hi; /*1Ch */
  1457. __le32 queue_info_old_phys_addr_lo; /*20h */
  1458. __le32 queue_info_old_phys_addr_hi; /*24h */
  1459. __le32 reserved_4[2]; /*28h */
  1460. __le32 system_info_lo; /*30h */
  1461. __le32 system_info_hi; /*34h */
  1462. __le32 reserved_5[2]; /*38h */
  1463. } __attribute__ ((packed));
  1464. struct megasas_init_queue_info {
  1465. __le32 init_flags; /*00h */
  1466. __le32 reply_queue_entries; /*04h */
  1467. __le32 reply_queue_start_phys_addr_lo; /*08h */
  1468. __le32 reply_queue_start_phys_addr_hi; /*0Ch */
  1469. __le32 producer_index_phys_addr_lo; /*10h */
  1470. __le32 producer_index_phys_addr_hi; /*14h */
  1471. __le32 consumer_index_phys_addr_lo; /*18h */
  1472. __le32 consumer_index_phys_addr_hi; /*1Ch */
  1473. } __attribute__ ((packed));
  1474. struct megasas_io_frame {
  1475. u8 cmd; /*00h */
  1476. u8 sense_len; /*01h */
  1477. u8 cmd_status; /*02h */
  1478. u8 scsi_status; /*03h */
  1479. u8 target_id; /*04h */
  1480. u8 access_byte; /*05h */
  1481. u8 reserved_0; /*06h */
  1482. u8 sge_count; /*07h */
  1483. __le32 context; /*08h */
  1484. __le32 pad_0; /*0Ch */
  1485. __le16 flags; /*10h */
  1486. __le16 timeout; /*12h */
  1487. __le32 lba_count; /*14h */
  1488. __le32 sense_buf_phys_addr_lo; /*18h */
  1489. __le32 sense_buf_phys_addr_hi; /*1Ch */
  1490. __le32 start_lba_lo; /*20h */
  1491. __le32 start_lba_hi; /*24h */
  1492. union megasas_sgl sgl; /*28h */
  1493. } __attribute__ ((packed));
  1494. struct megasas_pthru_frame {
  1495. u8 cmd; /*00h */
  1496. u8 sense_len; /*01h */
  1497. u8 cmd_status; /*02h */
  1498. u8 scsi_status; /*03h */
  1499. u8 target_id; /*04h */
  1500. u8 lun; /*05h */
  1501. u8 cdb_len; /*06h */
  1502. u8 sge_count; /*07h */
  1503. __le32 context; /*08h */
  1504. __le32 pad_0; /*0Ch */
  1505. __le16 flags; /*10h */
  1506. __le16 timeout; /*12h */
  1507. __le32 data_xfer_len; /*14h */
  1508. __le32 sense_buf_phys_addr_lo; /*18h */
  1509. __le32 sense_buf_phys_addr_hi; /*1Ch */
  1510. u8 cdb[16]; /*20h */
  1511. union megasas_sgl sgl; /*30h */
  1512. } __attribute__ ((packed));
  1513. struct megasas_dcmd_frame {
  1514. u8 cmd; /*00h */
  1515. u8 reserved_0; /*01h */
  1516. u8 cmd_status; /*02h */
  1517. u8 reserved_1[4]; /*03h */
  1518. u8 sge_count; /*07h */
  1519. __le32 context; /*08h */
  1520. __le32 pad_0; /*0Ch */
  1521. __le16 flags; /*10h */
  1522. __le16 timeout; /*12h */
  1523. __le32 data_xfer_len; /*14h */
  1524. __le32 opcode; /*18h */
  1525. union { /*1Ch */
  1526. u8 b[12];
  1527. __le16 s[6];
  1528. __le32 w[3];
  1529. } mbox;
  1530. union megasas_sgl sgl; /*28h */
  1531. } __attribute__ ((packed));
  1532. struct megasas_abort_frame {
  1533. u8 cmd; /*00h */
  1534. u8 reserved_0; /*01h */
  1535. u8 cmd_status; /*02h */
  1536. u8 reserved_1; /*03h */
  1537. __le32 reserved_2; /*04h */
  1538. __le32 context; /*08h */
  1539. __le32 pad_0; /*0Ch */
  1540. __le16 flags; /*10h */
  1541. __le16 reserved_3; /*12h */
  1542. __le32 reserved_4; /*14h */
  1543. __le32 abort_context; /*18h */
  1544. __le32 pad_1; /*1Ch */
  1545. __le32 abort_mfi_phys_addr_lo; /*20h */
  1546. __le32 abort_mfi_phys_addr_hi; /*24h */
  1547. __le32 reserved_5[6]; /*28h */
  1548. } __attribute__ ((packed));
  1549. struct megasas_smp_frame {
  1550. u8 cmd; /*00h */
  1551. u8 reserved_1; /*01h */
  1552. u8 cmd_status; /*02h */
  1553. u8 connection_status; /*03h */
  1554. u8 reserved_2[3]; /*04h */
  1555. u8 sge_count; /*07h */
  1556. __le32 context; /*08h */
  1557. __le32 pad_0; /*0Ch */
  1558. __le16 flags; /*10h */
  1559. __le16 timeout; /*12h */
  1560. __le32 data_xfer_len; /*14h */
  1561. __le64 sas_addr; /*18h */
  1562. union {
  1563. struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
  1564. struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
  1565. } sgl;
  1566. } __attribute__ ((packed));
  1567. struct megasas_stp_frame {
  1568. u8 cmd; /*00h */
  1569. u8 reserved_1; /*01h */
  1570. u8 cmd_status; /*02h */
  1571. u8 reserved_2; /*03h */
  1572. u8 target_id; /*04h */
  1573. u8 reserved_3[2]; /*05h */
  1574. u8 sge_count; /*07h */
  1575. __le32 context; /*08h */
  1576. __le32 pad_0; /*0Ch */
  1577. __le16 flags; /*10h */
  1578. __le16 timeout; /*12h */
  1579. __le32 data_xfer_len; /*14h */
  1580. __le16 fis[10]; /*18h */
  1581. __le32 stp_flags;
  1582. union {
  1583. struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
  1584. struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
  1585. } sgl;
  1586. } __attribute__ ((packed));
  1587. union megasas_frame {
  1588. struct megasas_header hdr;
  1589. struct megasas_init_frame init;
  1590. struct megasas_io_frame io;
  1591. struct megasas_pthru_frame pthru;
  1592. struct megasas_dcmd_frame dcmd;
  1593. struct megasas_abort_frame abort;
  1594. struct megasas_smp_frame smp;
  1595. struct megasas_stp_frame stp;
  1596. u8 raw_bytes[64];
  1597. };
  1598. /**
  1599. * struct MR_PRIV_DEVICE - sdev private hostdata
  1600. * @is_tm_capable: firmware managed tm_capable flag
  1601. * @tm_busy: TM request is in progress
  1602. */
  1603. struct MR_PRIV_DEVICE {
  1604. bool is_tm_capable;
  1605. bool tm_busy;
  1606. atomic_t r1_ldio_hint;
  1607. u8 interface_type;
  1608. };
  1609. struct megasas_cmd;
  1610. union megasas_evt_class_locale {
  1611. struct {
  1612. #ifndef __BIG_ENDIAN_BITFIELD
  1613. u16 locale;
  1614. u8 reserved;
  1615. s8 class;
  1616. #else
  1617. s8 class;
  1618. u8 reserved;
  1619. u16 locale;
  1620. #endif
  1621. } __attribute__ ((packed)) members;
  1622. u32 word;
  1623. } __attribute__ ((packed));
  1624. struct megasas_evt_log_info {
  1625. __le32 newest_seq_num;
  1626. __le32 oldest_seq_num;
  1627. __le32 clear_seq_num;
  1628. __le32 shutdown_seq_num;
  1629. __le32 boot_seq_num;
  1630. } __attribute__ ((packed));
  1631. struct megasas_progress {
  1632. __le16 progress;
  1633. __le16 elapsed_seconds;
  1634. } __attribute__ ((packed));
  1635. struct megasas_evtarg_ld {
  1636. u16 target_id;
  1637. u8 ld_index;
  1638. u8 reserved;
  1639. } __attribute__ ((packed));
  1640. struct megasas_evtarg_pd {
  1641. u16 device_id;
  1642. u8 encl_index;
  1643. u8 slot_number;
  1644. } __attribute__ ((packed));
  1645. struct megasas_evt_detail {
  1646. __le32 seq_num;
  1647. __le32 time_stamp;
  1648. __le32 code;
  1649. union megasas_evt_class_locale cl;
  1650. u8 arg_type;
  1651. u8 reserved1[15];
  1652. union {
  1653. struct {
  1654. struct megasas_evtarg_pd pd;
  1655. u8 cdb_length;
  1656. u8 sense_length;
  1657. u8 reserved[2];
  1658. u8 cdb[16];
  1659. u8 sense[64];
  1660. } __attribute__ ((packed)) cdbSense;
  1661. struct megasas_evtarg_ld ld;
  1662. struct {
  1663. struct megasas_evtarg_ld ld;
  1664. __le64 count;
  1665. } __attribute__ ((packed)) ld_count;
  1666. struct {
  1667. __le64 lba;
  1668. struct megasas_evtarg_ld ld;
  1669. } __attribute__ ((packed)) ld_lba;
  1670. struct {
  1671. struct megasas_evtarg_ld ld;
  1672. __le32 prevOwner;
  1673. __le32 newOwner;
  1674. } __attribute__ ((packed)) ld_owner;
  1675. struct {
  1676. u64 ld_lba;
  1677. u64 pd_lba;
  1678. struct megasas_evtarg_ld ld;
  1679. struct megasas_evtarg_pd pd;
  1680. } __attribute__ ((packed)) ld_lba_pd_lba;
  1681. struct {
  1682. struct megasas_evtarg_ld ld;
  1683. struct megasas_progress prog;
  1684. } __attribute__ ((packed)) ld_prog;
  1685. struct {
  1686. struct megasas_evtarg_ld ld;
  1687. u32 prev_state;
  1688. u32 new_state;
  1689. } __attribute__ ((packed)) ld_state;
  1690. struct {
  1691. u64 strip;
  1692. struct megasas_evtarg_ld ld;
  1693. } __attribute__ ((packed)) ld_strip;
  1694. struct megasas_evtarg_pd pd;
  1695. struct {
  1696. struct megasas_evtarg_pd pd;
  1697. u32 err;
  1698. } __attribute__ ((packed)) pd_err;
  1699. struct {
  1700. u64 lba;
  1701. struct megasas_evtarg_pd pd;
  1702. } __attribute__ ((packed)) pd_lba;
  1703. struct {
  1704. u64 lba;
  1705. struct megasas_evtarg_pd pd;
  1706. struct megasas_evtarg_ld ld;
  1707. } __attribute__ ((packed)) pd_lba_ld;
  1708. struct {
  1709. struct megasas_evtarg_pd pd;
  1710. struct megasas_progress prog;
  1711. } __attribute__ ((packed)) pd_prog;
  1712. struct {
  1713. struct megasas_evtarg_pd pd;
  1714. u32 prevState;
  1715. u32 newState;
  1716. } __attribute__ ((packed)) pd_state;
  1717. struct {
  1718. u16 vendorId;
  1719. __le16 deviceId;
  1720. u16 subVendorId;
  1721. u16 subDeviceId;
  1722. } __attribute__ ((packed)) pci;
  1723. u32 rate;
  1724. char str[96];
  1725. struct {
  1726. u32 rtc;
  1727. u32 elapsedSeconds;
  1728. } __attribute__ ((packed)) time;
  1729. struct {
  1730. u32 ecar;
  1731. u32 elog;
  1732. char str[64];
  1733. } __attribute__ ((packed)) ecc;
  1734. u8 b[96];
  1735. __le16 s[48];
  1736. __le32 w[24];
  1737. __le64 d[12];
  1738. } args;
  1739. char description[128];
  1740. } __attribute__ ((packed));
  1741. struct megasas_aen_event {
  1742. struct delayed_work hotplug_work;
  1743. struct megasas_instance *instance;
  1744. };
  1745. struct megasas_irq_context {
  1746. struct megasas_instance *instance;
  1747. u32 MSIxIndex;
  1748. };
  1749. struct MR_DRV_SYSTEM_INFO {
  1750. u8 infoVersion;
  1751. u8 systemIdLength;
  1752. u16 reserved0;
  1753. u8 systemId[64];
  1754. u8 reserved[1980];
  1755. };
  1756. enum MR_PD_TYPE {
  1757. UNKNOWN_DRIVE = 0,
  1758. PARALLEL_SCSI = 1,
  1759. SAS_PD = 2,
  1760. SATA_PD = 3,
  1761. FC_PD = 4,
  1762. NVME_PD = 5,
  1763. };
  1764. /* JBOD Queue depth definitions */
  1765. #define MEGASAS_SATA_QD 32
  1766. #define MEGASAS_SAS_QD 64
  1767. #define MEGASAS_DEFAULT_PD_QD 64
  1768. #define MEGASAS_NVME_QD 32
  1769. #define MR_DEFAULT_NVME_PAGE_SIZE 4096
  1770. #define MR_DEFAULT_NVME_PAGE_SHIFT 12
  1771. #define MR_DEFAULT_NVME_MDTS_KB 128
  1772. #define MR_NVME_PAGE_SIZE_MASK 0x000000FF
  1773. struct megasas_instance {
  1774. unsigned int *reply_map;
  1775. __le32 *producer;
  1776. dma_addr_t producer_h;
  1777. __le32 *consumer;
  1778. dma_addr_t consumer_h;
  1779. struct MR_DRV_SYSTEM_INFO *system_info_buf;
  1780. dma_addr_t system_info_h;
  1781. struct MR_LD_VF_AFFILIATION *vf_affiliation;
  1782. dma_addr_t vf_affiliation_h;
  1783. struct MR_LD_VF_AFFILIATION_111 *vf_affiliation_111;
  1784. dma_addr_t vf_affiliation_111_h;
  1785. struct MR_CTRL_HB_HOST_MEM *hb_host_mem;
  1786. dma_addr_t hb_host_mem_h;
  1787. struct MR_PD_INFO *pd_info;
  1788. dma_addr_t pd_info_h;
  1789. struct MR_TARGET_PROPERTIES *tgt_prop;
  1790. dma_addr_t tgt_prop_h;
  1791. __le32 *reply_queue;
  1792. dma_addr_t reply_queue_h;
  1793. u32 *crash_dump_buf;
  1794. dma_addr_t crash_dump_h;
  1795. void *crash_buf[MAX_CRASH_DUMP_SIZE];
  1796. unsigned int fw_crash_buffer_size;
  1797. unsigned int fw_crash_state;
  1798. unsigned int fw_crash_buffer_offset;
  1799. u32 drv_buf_index;
  1800. u32 drv_buf_alloc;
  1801. u32 crash_dump_fw_support;
  1802. u32 crash_dump_drv_support;
  1803. u32 crash_dump_app_support;
  1804. u32 secure_jbod_support;
  1805. u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
  1806. bool use_seqnum_jbod_fp; /* Added for PD sequence */
  1807. spinlock_t crashdump_lock;
  1808. struct megasas_register_set __iomem *reg_set;
  1809. u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
  1810. struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
  1811. struct megasas_pd_list local_pd_list[MEGASAS_MAX_PD];
  1812. u8 ld_ids[MEGASAS_MAX_LD_IDS];
  1813. s8 init_id;
  1814. u16 max_num_sge;
  1815. u16 max_fw_cmds;
  1816. u16 max_mpt_cmds;
  1817. u16 max_mfi_cmds;
  1818. u16 max_scsi_cmds;
  1819. u16 ldio_threshold;
  1820. u16 cur_can_queue;
  1821. u32 max_sectors_per_req;
  1822. struct megasas_aen_event *ev;
  1823. struct megasas_cmd **cmd_list;
  1824. struct list_head cmd_pool;
  1825. /* used to sync fire the cmd to fw */
  1826. spinlock_t mfi_pool_lock;
  1827. /* used to sync fire the cmd to fw */
  1828. spinlock_t hba_lock;
  1829. /* used to synch producer, consumer ptrs in dpc */
  1830. spinlock_t stream_lock;
  1831. spinlock_t completion_lock;
  1832. struct dma_pool *frame_dma_pool;
  1833. struct dma_pool *sense_dma_pool;
  1834. struct megasas_evt_detail *evt_detail;
  1835. dma_addr_t evt_detail_h;
  1836. struct megasas_cmd *aen_cmd;
  1837. struct mutex hba_mutex;
  1838. struct semaphore ioctl_sem;
  1839. struct Scsi_Host *host;
  1840. wait_queue_head_t int_cmd_wait_q;
  1841. wait_queue_head_t abort_cmd_wait_q;
  1842. struct pci_dev *pdev;
  1843. u32 unique_id;
  1844. u32 fw_support_ieee;
  1845. atomic_t fw_outstanding;
  1846. atomic_t ldio_outstanding;
  1847. atomic_t fw_reset_no_pci_access;
  1848. atomic_t ieee_sgl;
  1849. atomic_t prp_sgl;
  1850. atomic_t sge_holes_type1;
  1851. atomic_t sge_holes_type2;
  1852. atomic_t sge_holes_type3;
  1853. struct megasas_instance_template *instancet;
  1854. struct tasklet_struct isr_tasklet;
  1855. struct work_struct work_init;
  1856. struct work_struct crash_init;
  1857. u8 flag;
  1858. u8 unload;
  1859. u8 flag_ieee;
  1860. u8 issuepend_done;
  1861. u8 disableOnlineCtrlReset;
  1862. u8 UnevenSpanSupport;
  1863. u8 supportmax256vd;
  1864. u8 pd_list_not_supported;
  1865. u16 fw_supported_vd_count;
  1866. u16 fw_supported_pd_count;
  1867. u16 drv_supported_vd_count;
  1868. u16 drv_supported_pd_count;
  1869. atomic_t adprecovery;
  1870. unsigned long last_time;
  1871. u32 mfiStatus;
  1872. u32 last_seq_num;
  1873. struct list_head internal_reset_pending_q;
  1874. /* Ptr to hba specific information */
  1875. void *ctrl_context;
  1876. u32 ctrl_context_pages;
  1877. struct megasas_ctrl_info *ctrl_info;
  1878. unsigned int msix_vectors;
  1879. struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
  1880. u64 map_id;
  1881. u64 pd_seq_map_id;
  1882. struct megasas_cmd *map_update_cmd;
  1883. struct megasas_cmd *jbod_seq_cmd;
  1884. unsigned long bar;
  1885. long reset_flags;
  1886. struct mutex reset_mutex;
  1887. struct timer_list sriov_heartbeat_timer;
  1888. char skip_heartbeat_timer_del;
  1889. u8 requestorId;
  1890. char PlasmaFW111;
  1891. char clusterId[MEGASAS_CLUSTER_ID_SIZE];
  1892. u8 peerIsPresent;
  1893. u8 passive;
  1894. u16 throttlequeuedepth;
  1895. u8 mask_interrupts;
  1896. u16 max_chain_frame_sz;
  1897. u8 is_imr;
  1898. u8 is_rdpq;
  1899. bool dev_handle;
  1900. bool fw_sync_cache_support;
  1901. u32 mfi_frame_size;
  1902. bool msix_combined;
  1903. u16 max_raid_mapsize;
  1904. /* preffered count to send as LDIO irrspective of FP capable.*/
  1905. u8 r1_ldio_hint_default;
  1906. u32 nvme_page_size;
  1907. u8 adapter_type;
  1908. };
  1909. struct MR_LD_VF_MAP {
  1910. u32 size;
  1911. union MR_LD_REF ref;
  1912. u8 ldVfCount;
  1913. u8 reserved[6];
  1914. u8 policy[1];
  1915. };
  1916. struct MR_LD_VF_AFFILIATION {
  1917. u32 size;
  1918. u8 ldCount;
  1919. u8 vfCount;
  1920. u8 thisVf;
  1921. u8 reserved[9];
  1922. struct MR_LD_VF_MAP map[1];
  1923. };
  1924. /* Plasma 1.11 FW backward compatibility structures */
  1925. #define IOV_111_OFFSET 0x7CE
  1926. #define MAX_VIRTUAL_FUNCTIONS 8
  1927. #define MR_LD_ACCESS_HIDDEN 15
  1928. struct IOV_111 {
  1929. u8 maxVFsSupported;
  1930. u8 numVFsEnabled;
  1931. u8 requestorId;
  1932. u8 reserved[5];
  1933. };
  1934. struct MR_LD_VF_MAP_111 {
  1935. u8 targetId;
  1936. u8 reserved[3];
  1937. u8 policy[MAX_VIRTUAL_FUNCTIONS];
  1938. };
  1939. struct MR_LD_VF_AFFILIATION_111 {
  1940. u8 vdCount;
  1941. u8 vfCount;
  1942. u8 thisVf;
  1943. u8 reserved[5];
  1944. struct MR_LD_VF_MAP_111 map[MAX_LOGICAL_DRIVES];
  1945. };
  1946. struct MR_CTRL_HB_HOST_MEM {
  1947. struct {
  1948. u32 fwCounter; /* Firmware heart beat counter */
  1949. struct {
  1950. u32 debugmode:1; /* 1=Firmware is in debug mode.
  1951. Heart beat will not be updated. */
  1952. u32 reserved:31;
  1953. } debug;
  1954. u32 reserved_fw[6];
  1955. u32 driverCounter; /* Driver heart beat counter. 0x20 */
  1956. u32 reserved_driver[7];
  1957. } HB;
  1958. u8 pad[0x400-0x40];
  1959. };
  1960. enum {
  1961. MEGASAS_HBA_OPERATIONAL = 0,
  1962. MEGASAS_ADPRESET_SM_INFAULT = 1,
  1963. MEGASAS_ADPRESET_SM_FW_RESET_SUCCESS = 2,
  1964. MEGASAS_ADPRESET_SM_OPERATIONAL = 3,
  1965. MEGASAS_HW_CRITICAL_ERROR = 4,
  1966. MEGASAS_ADPRESET_SM_POLLING = 5,
  1967. MEGASAS_ADPRESET_INPROG_SIGN = 0xDEADDEAD,
  1968. };
  1969. struct megasas_instance_template {
  1970. void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
  1971. u32, struct megasas_register_set __iomem *);
  1972. void (*enable_intr)(struct megasas_instance *);
  1973. void (*disable_intr)(struct megasas_instance *);
  1974. int (*clear_intr)(struct megasas_register_set __iomem *);
  1975. u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
  1976. int (*adp_reset)(struct megasas_instance *, \
  1977. struct megasas_register_set __iomem *);
  1978. int (*check_reset)(struct megasas_instance *, \
  1979. struct megasas_register_set __iomem *);
  1980. irqreturn_t (*service_isr)(int irq, void *devp);
  1981. void (*tasklet)(unsigned long);
  1982. u32 (*init_adapter)(struct megasas_instance *);
  1983. u32 (*build_and_issue_cmd) (struct megasas_instance *,
  1984. struct scsi_cmnd *);
  1985. void (*issue_dcmd)(struct megasas_instance *instance,
  1986. struct megasas_cmd *cmd);
  1987. };
  1988. #define MEGASAS_IS_LOGICAL(sdev) \
  1989. ((sdev->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)
  1990. #define MEGASAS_DEV_INDEX(scp) \
  1991. (((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
  1992. scp->device->id)
  1993. #define MEGASAS_PD_INDEX(scp) \
  1994. ((scp->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) + \
  1995. scp->device->id)
  1996. struct megasas_cmd {
  1997. union megasas_frame *frame;
  1998. dma_addr_t frame_phys_addr;
  1999. u8 *sense;
  2000. dma_addr_t sense_phys_addr;
  2001. u32 index;
  2002. u8 sync_cmd;
  2003. u8 cmd_status_drv;
  2004. u8 abort_aen;
  2005. u8 retry_for_fw_reset;
  2006. struct list_head list;
  2007. struct scsi_cmnd *scmd;
  2008. u8 flags;
  2009. struct megasas_instance *instance;
  2010. union {
  2011. struct {
  2012. u16 smid;
  2013. u16 resvd;
  2014. } context;
  2015. u32 frame_count;
  2016. };
  2017. };
  2018. #define MAX_MGMT_ADAPTERS 1024
  2019. #define MAX_IOCTL_SGE 16
  2020. struct megasas_iocpacket {
  2021. u16 host_no;
  2022. u16 __pad1;
  2023. u32 sgl_off;
  2024. u32 sge_count;
  2025. u32 sense_off;
  2026. u32 sense_len;
  2027. union {
  2028. u8 raw[128];
  2029. struct megasas_header hdr;
  2030. } frame;
  2031. struct iovec sgl[MAX_IOCTL_SGE];
  2032. } __attribute__ ((packed));
  2033. struct megasas_aen {
  2034. u16 host_no;
  2035. u16 __pad1;
  2036. u32 seq_num;
  2037. u32 class_locale_word;
  2038. } __attribute__ ((packed));
  2039. #ifdef CONFIG_COMPAT
  2040. struct compat_megasas_iocpacket {
  2041. u16 host_no;
  2042. u16 __pad1;
  2043. u32 sgl_off;
  2044. u32 sge_count;
  2045. u32 sense_off;
  2046. u32 sense_len;
  2047. union {
  2048. u8 raw[128];
  2049. struct megasas_header hdr;
  2050. } frame;
  2051. struct compat_iovec sgl[MAX_IOCTL_SGE];
  2052. } __attribute__ ((packed));
  2053. #define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
  2054. #endif
  2055. #define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
  2056. #define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
  2057. struct megasas_mgmt_info {
  2058. u16 count;
  2059. struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
  2060. int max_index;
  2061. };
  2062. enum MEGASAS_OCR_CAUSE {
  2063. FW_FAULT_OCR = 0,
  2064. SCSIIO_TIMEOUT_OCR = 1,
  2065. MFI_IO_TIMEOUT_OCR = 2,
  2066. };
  2067. enum DCMD_RETURN_STATUS {
  2068. DCMD_SUCCESS = 0,
  2069. DCMD_TIMEOUT = 1,
  2070. DCMD_FAILED = 2,
  2071. DCMD_NOT_FIRED = 3,
  2072. };
  2073. u8
  2074. MR_BuildRaidContext(struct megasas_instance *instance,
  2075. struct IO_REQUEST_INFO *io_info,
  2076. struct RAID_CONTEXT *pRAID_Context,
  2077. struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN);
  2078. u16 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
  2079. struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
  2080. u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
  2081. u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map);
  2082. __le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
  2083. u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
  2084. __le16 get_updated_dev_handle(struct megasas_instance *instance,
  2085. struct LD_LOAD_BALANCE_INFO *lbInfo,
  2086. struct IO_REQUEST_INFO *in_info,
  2087. struct MR_DRV_RAID_MAP_ALL *drv_map);
  2088. void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
  2089. struct LD_LOAD_BALANCE_INFO *lbInfo);
  2090. int megasas_get_ctrl_info(struct megasas_instance *instance);
  2091. /* PD sequence */
  2092. int
  2093. megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend);
  2094. void megasas_set_dynamic_target_properties(struct scsi_device *sdev);
  2095. int megasas_set_crash_dump_params(struct megasas_instance *instance,
  2096. u8 crash_buf_state);
  2097. void megasas_free_host_crash_buffer(struct megasas_instance *instance);
  2098. void megasas_fusion_crash_dump_wq(struct work_struct *work);
  2099. void megasas_return_cmd_fusion(struct megasas_instance *instance,
  2100. struct megasas_cmd_fusion *cmd);
  2101. int megasas_issue_blocked_cmd(struct megasas_instance *instance,
  2102. struct megasas_cmd *cmd, int timeout);
  2103. void __megasas_return_cmd(struct megasas_instance *instance,
  2104. struct megasas_cmd *cmd);
  2105. void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
  2106. struct megasas_cmd *cmd_mfi, struct megasas_cmd_fusion *cmd_fusion);
  2107. int megasas_cmd_type(struct scsi_cmnd *cmd);
  2108. void megasas_setup_jbod_map(struct megasas_instance *instance);
  2109. void megasas_update_sdev_properties(struct scsi_device *sdev);
  2110. int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
  2111. int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
  2112. int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
  2113. u32 mega_mod64(u64 dividend, u32 divisor);
  2114. int megasas_alloc_fusion_context(struct megasas_instance *instance);
  2115. void megasas_free_fusion_context(struct megasas_instance *instance);
  2116. #endif /*LSI_MEGARAID_SAS_H */