megaraid_sas.h 65 KB

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