ipr.h 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991
  1. /*
  2. * ipr.h -- driver for IBM Power Linux RAID adapters
  3. *
  4. * Written By: Brian King <brking@us.ibm.com>, IBM Corporation
  5. *
  6. * Copyright (C) 2003, 2004 IBM Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * Alan Cox <alan@lxorguk.ukuu.org.uk> - Removed several careless u32/dma_addr_t errors
  23. * that broke 64bit platforms.
  24. */
  25. #ifndef _IPR_H
  26. #define _IPR_H
  27. #include <asm/unaligned.h>
  28. #include <linux/types.h>
  29. #include <linux/completion.h>
  30. #include <linux/libata.h>
  31. #include <linux/list.h>
  32. #include <linux/kref.h>
  33. #include <linux/blk-iopoll.h>
  34. #include <scsi/scsi.h>
  35. #include <scsi/scsi_cmnd.h>
  36. /*
  37. * Literals
  38. */
  39. #define IPR_DRIVER_VERSION "2.6.3"
  40. #define IPR_DRIVER_DATE "(October 17, 2015)"
  41. /*
  42. * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
  43. * ops per device for devices not running tagged command queuing.
  44. * This can be adjusted at runtime through sysfs device attributes.
  45. */
  46. #define IPR_MAX_CMD_PER_LUN 6
  47. #define IPR_MAX_CMD_PER_ATA_LUN 1
  48. /*
  49. * IPR_NUM_BASE_CMD_BLKS: This defines the maximum number of
  50. * ops the mid-layer can send to the adapter.
  51. */
  52. #define IPR_NUM_BASE_CMD_BLKS (ioa_cfg->max_cmds)
  53. #define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339
  54. #define PCI_DEVICE_ID_IBM_CROC_FPGA_E2 0x033D
  55. #define PCI_DEVICE_ID_IBM_CROCODILE 0x034A
  56. #define IPR_SUBS_DEV_ID_2780 0x0264
  57. #define IPR_SUBS_DEV_ID_5702 0x0266
  58. #define IPR_SUBS_DEV_ID_5703 0x0278
  59. #define IPR_SUBS_DEV_ID_572E 0x028D
  60. #define IPR_SUBS_DEV_ID_573E 0x02D3
  61. #define IPR_SUBS_DEV_ID_573D 0x02D4
  62. #define IPR_SUBS_DEV_ID_571A 0x02C0
  63. #define IPR_SUBS_DEV_ID_571B 0x02BE
  64. #define IPR_SUBS_DEV_ID_571E 0x02BF
  65. #define IPR_SUBS_DEV_ID_571F 0x02D5
  66. #define IPR_SUBS_DEV_ID_572A 0x02C1
  67. #define IPR_SUBS_DEV_ID_572B 0x02C2
  68. #define IPR_SUBS_DEV_ID_572F 0x02C3
  69. #define IPR_SUBS_DEV_ID_574E 0x030A
  70. #define IPR_SUBS_DEV_ID_575B 0x030D
  71. #define IPR_SUBS_DEV_ID_575C 0x0338
  72. #define IPR_SUBS_DEV_ID_57B3 0x033A
  73. #define IPR_SUBS_DEV_ID_57B7 0x0360
  74. #define IPR_SUBS_DEV_ID_57B8 0x02C2
  75. #define IPR_SUBS_DEV_ID_57B4 0x033B
  76. #define IPR_SUBS_DEV_ID_57B2 0x035F
  77. #define IPR_SUBS_DEV_ID_57C0 0x0352
  78. #define IPR_SUBS_DEV_ID_57C3 0x0353
  79. #define IPR_SUBS_DEV_ID_57C4 0x0354
  80. #define IPR_SUBS_DEV_ID_57C6 0x0357
  81. #define IPR_SUBS_DEV_ID_57CC 0x035C
  82. #define IPR_SUBS_DEV_ID_57B5 0x033C
  83. #define IPR_SUBS_DEV_ID_57CE 0x035E
  84. #define IPR_SUBS_DEV_ID_57B1 0x0355
  85. #define IPR_SUBS_DEV_ID_574D 0x0356
  86. #define IPR_SUBS_DEV_ID_57C8 0x035D
  87. #define IPR_SUBS_DEV_ID_57D5 0x03FB
  88. #define IPR_SUBS_DEV_ID_57D6 0x03FC
  89. #define IPR_SUBS_DEV_ID_57D7 0x03FF
  90. #define IPR_SUBS_DEV_ID_57D8 0x03FE
  91. #define IPR_SUBS_DEV_ID_57D9 0x046D
  92. #define IPR_SUBS_DEV_ID_57DA 0x04CA
  93. #define IPR_SUBS_DEV_ID_57EB 0x0474
  94. #define IPR_SUBS_DEV_ID_57EC 0x0475
  95. #define IPR_SUBS_DEV_ID_57ED 0x0499
  96. #define IPR_SUBS_DEV_ID_57EE 0x049A
  97. #define IPR_SUBS_DEV_ID_57EF 0x049B
  98. #define IPR_SUBS_DEV_ID_57F0 0x049C
  99. #define IPR_SUBS_DEV_ID_2CCA 0x04C7
  100. #define IPR_SUBS_DEV_ID_2CD2 0x04C8
  101. #define IPR_SUBS_DEV_ID_2CCD 0x04C9
  102. #define IPR_NAME "ipr"
  103. /*
  104. * Return codes
  105. */
  106. #define IPR_RC_JOB_CONTINUE 1
  107. #define IPR_RC_JOB_RETURN 2
  108. /*
  109. * IOASCs
  110. */
  111. #define IPR_IOASC_NR_INIT_CMD_REQUIRED 0x02040200
  112. #define IPR_IOASC_NR_IOA_RESET_REQUIRED 0x02048000
  113. #define IPR_IOASC_SYNC_REQUIRED 0x023f0000
  114. #define IPR_IOASC_MED_DO_NOT_REALLOC 0x03110C00
  115. #define IPR_IOASC_HW_SEL_TIMEOUT 0x04050000
  116. #define IPR_IOASC_HW_DEV_BUS_STATUS 0x04448500
  117. #define IPR_IOASC_IOASC_MASK 0xFFFFFF00
  118. #define IPR_IOASC_SCSI_STATUS_MASK 0x000000FF
  119. #define IPR_IOASC_HW_CMD_FAILED 0x046E0000
  120. #define IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT 0x05240000
  121. #define IPR_IOASC_IR_RESOURCE_HANDLE 0x05250000
  122. #define IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA 0x05258100
  123. #define IPR_IOASA_IR_DUAL_IOA_DISABLED 0x052C8000
  124. #define IPR_IOASC_BUS_WAS_RESET 0x06290000
  125. #define IPR_IOASC_BUS_WAS_RESET_BY_OTHER 0x06298000
  126. #define IPR_IOASC_ABORTED_CMD_TERM_BY_HOST 0x0B5A0000
  127. #define IPR_IOASC_IR_NON_OPTIMIZED 0x05258200
  128. #define IPR_FIRST_DRIVER_IOASC 0x10000000
  129. #define IPR_IOASC_IOA_WAS_RESET 0x10000001
  130. #define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002
  131. /* Driver data flags */
  132. #define IPR_USE_LONG_TRANSOP_TIMEOUT 0x00000001
  133. #define IPR_USE_PCI_WARM_RESET 0x00000002
  134. #define IPR_DEFAULT_MAX_ERROR_DUMP 984
  135. #define IPR_NUM_LOG_HCAMS 2
  136. #define IPR_NUM_CFG_CHG_HCAMS 2
  137. #define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS)
  138. #define IPR_MAX_SIS64_TARGETS_PER_BUS 1024
  139. #define IPR_MAX_SIS64_LUNS_PER_TARGET 0xffffffff
  140. #define IPR_MAX_NUM_TARGETS_PER_BUS 256
  141. #define IPR_MAX_NUM_LUNS_PER_TARGET 256
  142. #define IPR_VSET_BUS 0xff
  143. #define IPR_IOA_BUS 0xff
  144. #define IPR_IOA_TARGET 0xff
  145. #define IPR_IOA_LUN 0xff
  146. #define IPR_MAX_NUM_BUSES 16
  147. #define IPR_NUM_RESET_RELOAD_RETRIES 3
  148. /* We need resources for HCAMS, IOA reset, IOA bringdown, and ERP */
  149. #define IPR_NUM_INTERNAL_CMD_BLKS (IPR_NUM_HCAMS + \
  150. ((IPR_NUM_RESET_RELOAD_RETRIES + 1) * 2) + 4)
  151. #define IPR_MAX_COMMANDS 100
  152. #define IPR_NUM_CMD_BLKS (IPR_NUM_BASE_CMD_BLKS + \
  153. IPR_NUM_INTERNAL_CMD_BLKS)
  154. #define IPR_MAX_PHYSICAL_DEVS 192
  155. #define IPR_DEFAULT_SIS64_DEVS 1024
  156. #define IPR_MAX_SIS64_DEVS 4096
  157. #define IPR_MAX_SGLIST 64
  158. #define IPR_IOA_MAX_SECTORS 32767
  159. #define IPR_VSET_MAX_SECTORS 512
  160. #define IPR_MAX_CDB_LEN 16
  161. #define IPR_MAX_HRRQ_RETRIES 3
  162. #define IPR_DEFAULT_BUS_WIDTH 16
  163. #define IPR_80MBs_SCSI_RATE ((80 * 10) / (IPR_DEFAULT_BUS_WIDTH / 8))
  164. #define IPR_U160_SCSI_RATE ((160 * 10) / (IPR_DEFAULT_BUS_WIDTH / 8))
  165. #define IPR_U320_SCSI_RATE ((320 * 10) / (IPR_DEFAULT_BUS_WIDTH / 8))
  166. #define IPR_MAX_SCSI_RATE(width) ((320 * 10) / ((width) / 8))
  167. #define IPR_IOA_RES_HANDLE 0xffffffff
  168. #define IPR_INVALID_RES_HANDLE 0
  169. #define IPR_IOA_RES_ADDR 0x00ffffff
  170. /*
  171. * Adapter Commands
  172. */
  173. #define IPR_CANCEL_REQUEST 0xC0
  174. #define IPR_CANCEL_64BIT_IOARCB 0x01
  175. #define IPR_QUERY_RSRC_STATE 0xC2
  176. #define IPR_RESET_DEVICE 0xC3
  177. #define IPR_RESET_TYPE_SELECT 0x80
  178. #define IPR_LUN_RESET 0x40
  179. #define IPR_TARGET_RESET 0x20
  180. #define IPR_BUS_RESET 0x10
  181. #define IPR_ATA_PHY_RESET 0x80
  182. #define IPR_ID_HOST_RR_Q 0xC4
  183. #define IPR_QUERY_IOA_CONFIG 0xC5
  184. #define IPR_CANCEL_ALL_REQUESTS 0xCE
  185. #define IPR_HOST_CONTROLLED_ASYNC 0xCF
  186. #define IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE 0x01
  187. #define IPR_HCAM_CDB_OP_CODE_LOG_DATA 0x02
  188. #define IPR_SET_SUPPORTED_DEVICES 0xFB
  189. #define IPR_SET_ALL_SUPPORTED_DEVICES 0x80
  190. #define IPR_IOA_SHUTDOWN 0xF7
  191. #define IPR_WR_BUF_DOWNLOAD_AND_SAVE 0x05
  192. #define IPR_IOA_SERVICE_ACTION 0xD2
  193. /* IOA Service Actions */
  194. #define IPR_IOA_SA_CHANGE_CACHE_PARAMS 0x14
  195. /*
  196. * Timeouts
  197. */
  198. #define IPR_SHUTDOWN_TIMEOUT (ipr_fastfail ? 60 * HZ : 10 * 60 * HZ)
  199. #define IPR_VSET_RW_TIMEOUT (ipr_fastfail ? 30 * HZ : 2 * 60 * HZ)
  200. #define IPR_ABBREV_SHUTDOWN_TIMEOUT (10 * HZ)
  201. #define IPR_DUAL_IOA_ABBR_SHUTDOWN_TO (2 * 60 * HZ)
  202. #define IPR_DEVICE_RESET_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
  203. #define IPR_CANCEL_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
  204. #define IPR_CANCEL_ALL_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
  205. #define IPR_ABORT_TASK_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
  206. #define IPR_INTERNAL_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
  207. #define IPR_WRITE_BUFFER_TIMEOUT (30 * 60 * HZ)
  208. #define IPR_SET_SUP_DEVICE_TIMEOUT (2 * 60 * HZ)
  209. #define IPR_REQUEST_SENSE_TIMEOUT (10 * HZ)
  210. #define IPR_OPERATIONAL_TIMEOUT (5 * 60)
  211. #define IPR_LONG_OPERATIONAL_TIMEOUT (12 * 60)
  212. #define IPR_WAIT_FOR_RESET_TIMEOUT (2 * HZ)
  213. #define IPR_CHECK_FOR_RESET_TIMEOUT (HZ / 10)
  214. #define IPR_WAIT_FOR_BIST_TIMEOUT (2 * HZ)
  215. #define IPR_PCI_ERROR_RECOVERY_TIMEOUT (120 * HZ)
  216. #define IPR_PCI_RESET_TIMEOUT (HZ / 2)
  217. #define IPR_SIS32_DUMP_TIMEOUT (15 * HZ)
  218. #define IPR_SIS64_DUMP_TIMEOUT (40 * HZ)
  219. #define IPR_DUMP_DELAY_SECONDS 4
  220. #define IPR_DUMP_DELAY_TIMEOUT (IPR_DUMP_DELAY_SECONDS * HZ)
  221. /*
  222. * SCSI Literals
  223. */
  224. #define IPR_VENDOR_ID_LEN 8
  225. #define IPR_PROD_ID_LEN 16
  226. #define IPR_SERIAL_NUM_LEN 8
  227. /*
  228. * Hardware literals
  229. */
  230. #define IPR_FMT2_MBX_ADDR_MASK 0x0fffffff
  231. #define IPR_FMT2_MBX_BAR_SEL_MASK 0xf0000000
  232. #define IPR_FMT2_MKR_BAR_SEL_SHIFT 28
  233. #define IPR_GET_FMT2_BAR_SEL(mbx) \
  234. (((mbx) & IPR_FMT2_MBX_BAR_SEL_MASK) >> IPR_FMT2_MKR_BAR_SEL_SHIFT)
  235. #define IPR_SDT_FMT2_BAR0_SEL 0x0
  236. #define IPR_SDT_FMT2_BAR1_SEL 0x1
  237. #define IPR_SDT_FMT2_BAR2_SEL 0x2
  238. #define IPR_SDT_FMT2_BAR3_SEL 0x3
  239. #define IPR_SDT_FMT2_BAR4_SEL 0x4
  240. #define IPR_SDT_FMT2_BAR5_SEL 0x5
  241. #define IPR_SDT_FMT2_EXP_ROM_SEL 0x8
  242. #define IPR_FMT2_SDT_READY_TO_USE 0xC4D4E3F2
  243. #define IPR_FMT3_SDT_READY_TO_USE 0xC4D4E3F3
  244. #define IPR_DOORBELL 0x82800000
  245. #define IPR_RUNTIME_RESET 0x40000000
  246. #define IPR_IPL_INIT_MIN_STAGE_TIME 5
  247. #define IPR_IPL_INIT_DEFAULT_STAGE_TIME 30
  248. #define IPR_IPL_INIT_STAGE_UNKNOWN 0x0
  249. #define IPR_IPL_INIT_STAGE_TRANSOP 0xB0000000
  250. #define IPR_IPL_INIT_STAGE_MASK 0xff000000
  251. #define IPR_IPL_INIT_STAGE_TIME_MASK 0x0000ffff
  252. #define IPR_PCII_IPL_STAGE_CHANGE (0x80000000 >> 0)
  253. #define IPR_PCII_MAILBOX_STABLE (0x80000000 >> 4)
  254. #define IPR_WAIT_FOR_MAILBOX (2 * HZ)
  255. #define IPR_PCII_IOA_TRANS_TO_OPER (0x80000000 >> 0)
  256. #define IPR_PCII_IOARCB_XFER_FAILED (0x80000000 >> 3)
  257. #define IPR_PCII_IOA_UNIT_CHECKED (0x80000000 >> 4)
  258. #define IPR_PCII_NO_HOST_RRQ (0x80000000 >> 5)
  259. #define IPR_PCII_CRITICAL_OPERATION (0x80000000 >> 6)
  260. #define IPR_PCII_IO_DEBUG_ACKNOWLEDGE (0x80000000 >> 7)
  261. #define IPR_PCII_IOARRIN_LOST (0x80000000 >> 27)
  262. #define IPR_PCII_MMIO_ERROR (0x80000000 >> 28)
  263. #define IPR_PCII_PROC_ERR_STATE (0x80000000 >> 29)
  264. #define IPR_PCII_HRRQ_UPDATED (0x80000000 >> 30)
  265. #define IPR_PCII_CORE_ISSUED_RST_REQ (0x80000000 >> 31)
  266. #define IPR_PCII_ERROR_INTERRUPTS \
  267. (IPR_PCII_IOARCB_XFER_FAILED | IPR_PCII_IOA_UNIT_CHECKED | \
  268. IPR_PCII_NO_HOST_RRQ | IPR_PCII_IOARRIN_LOST | IPR_PCII_MMIO_ERROR)
  269. #define IPR_PCII_OPER_INTERRUPTS \
  270. (IPR_PCII_ERROR_INTERRUPTS | IPR_PCII_HRRQ_UPDATED | IPR_PCII_IOA_TRANS_TO_OPER)
  271. #define IPR_UPROCI_RESET_ALERT (0x80000000 >> 7)
  272. #define IPR_UPROCI_IO_DEBUG_ALERT (0x80000000 >> 9)
  273. #define IPR_UPROCI_SIS64_START_BIST (0x80000000 >> 23)
  274. #define IPR_LDUMP_MAX_LONG_ACK_DELAY_IN_USEC 200000 /* 200 ms */
  275. #define IPR_LDUMP_MAX_SHORT_ACK_DELAY_IN_USEC 200000 /* 200 ms */
  276. /*
  277. * Dump literals
  278. */
  279. #define IPR_FMT2_MAX_IOA_DUMP_SIZE (4 * 1024 * 1024)
  280. #define IPR_FMT3_MAX_IOA_DUMP_SIZE (80 * 1024 * 1024)
  281. #define IPR_FMT2_NUM_SDT_ENTRIES 511
  282. #define IPR_FMT3_NUM_SDT_ENTRIES 0xFFF
  283. #define IPR_FMT2_MAX_NUM_DUMP_PAGES ((IPR_FMT2_MAX_IOA_DUMP_SIZE / PAGE_SIZE) + 1)
  284. #define IPR_FMT3_MAX_NUM_DUMP_PAGES ((IPR_FMT3_MAX_IOA_DUMP_SIZE / PAGE_SIZE) + 1)
  285. /*
  286. * Misc literals
  287. */
  288. #define IPR_NUM_IOADL_ENTRIES IPR_MAX_SGLIST
  289. #define IPR_MAX_MSIX_VECTORS 0x10
  290. #define IPR_MAX_HRRQ_NUM 0x10
  291. #define IPR_INIT_HRRQ 0x0
  292. /*
  293. * Adapter interface types
  294. */
  295. struct ipr_res_addr {
  296. u8 reserved;
  297. u8 bus;
  298. u8 target;
  299. u8 lun;
  300. #define IPR_GET_PHYS_LOC(res_addr) \
  301. (((res_addr).bus << 16) | ((res_addr).target << 8) | (res_addr).lun)
  302. }__attribute__((packed, aligned (4)));
  303. struct ipr_std_inq_vpids {
  304. u8 vendor_id[IPR_VENDOR_ID_LEN];
  305. u8 product_id[IPR_PROD_ID_LEN];
  306. }__attribute__((packed));
  307. struct ipr_vpd {
  308. struct ipr_std_inq_vpids vpids;
  309. u8 sn[IPR_SERIAL_NUM_LEN];
  310. }__attribute__((packed));
  311. struct ipr_ext_vpd {
  312. struct ipr_vpd vpd;
  313. __be32 wwid[2];
  314. }__attribute__((packed));
  315. struct ipr_ext_vpd64 {
  316. struct ipr_vpd vpd;
  317. __be32 wwid[4];
  318. }__attribute__((packed));
  319. struct ipr_std_inq_data {
  320. u8 peri_qual_dev_type;
  321. #define IPR_STD_INQ_PERI_QUAL(peri) ((peri) >> 5)
  322. #define IPR_STD_INQ_PERI_DEV_TYPE(peri) ((peri) & 0x1F)
  323. u8 removeable_medium_rsvd;
  324. #define IPR_STD_INQ_REMOVEABLE_MEDIUM 0x80
  325. #define IPR_IS_DASD_DEVICE(std_inq) \
  326. ((IPR_STD_INQ_PERI_DEV_TYPE((std_inq).peri_qual_dev_type) == TYPE_DISK) && \
  327. !(((std_inq).removeable_medium_rsvd) & IPR_STD_INQ_REMOVEABLE_MEDIUM))
  328. #define IPR_IS_SES_DEVICE(std_inq) \
  329. (IPR_STD_INQ_PERI_DEV_TYPE((std_inq).peri_qual_dev_type) == TYPE_ENCLOSURE)
  330. u8 version;
  331. u8 aen_naca_fmt;
  332. u8 additional_len;
  333. u8 sccs_rsvd;
  334. u8 bq_enc_multi;
  335. u8 sync_cmdq_flags;
  336. struct ipr_std_inq_vpids vpids;
  337. u8 ros_rsvd_ram_rsvd[4];
  338. u8 serial_num[IPR_SERIAL_NUM_LEN];
  339. }__attribute__ ((packed));
  340. #define IPR_RES_TYPE_AF_DASD 0x00
  341. #define IPR_RES_TYPE_GENERIC_SCSI 0x01
  342. #define IPR_RES_TYPE_VOLUME_SET 0x02
  343. #define IPR_RES_TYPE_REMOTE_AF_DASD 0x03
  344. #define IPR_RES_TYPE_GENERIC_ATA 0x04
  345. #define IPR_RES_TYPE_ARRAY 0x05
  346. #define IPR_RES_TYPE_IOAFP 0xff
  347. struct ipr_config_table_entry {
  348. u8 proto;
  349. #define IPR_PROTO_SATA 0x02
  350. #define IPR_PROTO_SATA_ATAPI 0x03
  351. #define IPR_PROTO_SAS_STP 0x06
  352. #define IPR_PROTO_SAS_STP_ATAPI 0x07
  353. u8 array_id;
  354. u8 flags;
  355. #define IPR_IS_IOA_RESOURCE 0x80
  356. u8 rsvd_subtype;
  357. #define IPR_QUEUEING_MODEL(res) ((((res)->flags) & 0x70) >> 4)
  358. #define IPR_QUEUE_FROZEN_MODEL 0
  359. #define IPR_QUEUE_NACA_MODEL 1
  360. struct ipr_res_addr res_addr;
  361. __be32 res_handle;
  362. __be32 lun_wwn[2];
  363. struct ipr_std_inq_data std_inq_data;
  364. }__attribute__ ((packed, aligned (4)));
  365. struct ipr_config_table_entry64 {
  366. u8 res_type;
  367. u8 proto;
  368. u8 vset_num;
  369. u8 array_id;
  370. __be16 flags;
  371. __be16 res_flags;
  372. #define IPR_QUEUEING_MODEL64(res) ((((res)->res_flags) & 0x7000) >> 12)
  373. __be32 res_handle;
  374. u8 dev_id_type;
  375. u8 reserved[3];
  376. __be64 dev_id;
  377. __be64 lun;
  378. __be64 lun_wwn[2];
  379. #define IPR_MAX_RES_PATH_LENGTH 48
  380. __be64 res_path;
  381. struct ipr_std_inq_data std_inq_data;
  382. u8 reserved2[4];
  383. __be64 reserved3[2];
  384. u8 reserved4[8];
  385. }__attribute__ ((packed, aligned (8)));
  386. struct ipr_config_table_hdr {
  387. u8 num_entries;
  388. u8 flags;
  389. #define IPR_UCODE_DOWNLOAD_REQ 0x10
  390. __be16 reserved;
  391. }__attribute__((packed, aligned (4)));
  392. struct ipr_config_table_hdr64 {
  393. __be16 num_entries;
  394. __be16 reserved;
  395. u8 flags;
  396. u8 reserved2[11];
  397. }__attribute__((packed, aligned (4)));
  398. struct ipr_config_table {
  399. struct ipr_config_table_hdr hdr;
  400. struct ipr_config_table_entry dev[0];
  401. }__attribute__((packed, aligned (4)));
  402. struct ipr_config_table64 {
  403. struct ipr_config_table_hdr64 hdr64;
  404. struct ipr_config_table_entry64 dev[0];
  405. }__attribute__((packed, aligned (8)));
  406. struct ipr_config_table_entry_wrapper {
  407. union {
  408. struct ipr_config_table_entry *cfgte;
  409. struct ipr_config_table_entry64 *cfgte64;
  410. } u;
  411. };
  412. struct ipr_hostrcb_cfg_ch_not {
  413. union {
  414. struct ipr_config_table_entry cfgte;
  415. struct ipr_config_table_entry64 cfgte64;
  416. } u;
  417. u8 reserved[936];
  418. }__attribute__((packed, aligned (4)));
  419. struct ipr_supported_device {
  420. __be16 data_length;
  421. u8 reserved;
  422. u8 num_records;
  423. struct ipr_std_inq_vpids vpids;
  424. u8 reserved2[16];
  425. }__attribute__((packed, aligned (4)));
  426. struct ipr_hrr_queue {
  427. struct ipr_ioa_cfg *ioa_cfg;
  428. __be32 *host_rrq;
  429. dma_addr_t host_rrq_dma;
  430. #define IPR_HRRQ_REQ_RESP_HANDLE_MASK 0xfffffffc
  431. #define IPR_HRRQ_RESP_BIT_SET 0x00000002
  432. #define IPR_HRRQ_TOGGLE_BIT 0x00000001
  433. #define IPR_HRRQ_REQ_RESP_HANDLE_SHIFT 2
  434. #define IPR_ID_HRRQ_SELE_ENABLE 0x02
  435. volatile __be32 *hrrq_start;
  436. volatile __be32 *hrrq_end;
  437. volatile __be32 *hrrq_curr;
  438. struct list_head hrrq_free_q;
  439. struct list_head hrrq_pending_q;
  440. spinlock_t _lock;
  441. spinlock_t *lock;
  442. volatile u32 toggle_bit;
  443. u32 size;
  444. u32 min_cmd_id;
  445. u32 max_cmd_id;
  446. u8 allow_interrupts:1;
  447. u8 ioa_is_dead:1;
  448. u8 allow_cmds:1;
  449. u8 removing_ioa:1;
  450. struct blk_iopoll iopoll;
  451. };
  452. /* Command packet structure */
  453. struct ipr_cmd_pkt {
  454. u8 reserved; /* Reserved by IOA */
  455. u8 hrrq_id;
  456. u8 request_type;
  457. #define IPR_RQTYPE_SCSICDB 0x00
  458. #define IPR_RQTYPE_IOACMD 0x01
  459. #define IPR_RQTYPE_HCAM 0x02
  460. #define IPR_RQTYPE_ATA_PASSTHRU 0x04
  461. #define IPR_RQTYPE_PIPE 0x05
  462. u8 reserved2;
  463. u8 flags_hi;
  464. #define IPR_FLAGS_HI_WRITE_NOT_READ 0x80
  465. #define IPR_FLAGS_HI_NO_ULEN_CHK 0x20
  466. #define IPR_FLAGS_HI_SYNC_OVERRIDE 0x10
  467. #define IPR_FLAGS_HI_SYNC_COMPLETE 0x08
  468. #define IPR_FLAGS_HI_NO_LINK_DESC 0x04
  469. u8 flags_lo;
  470. #define IPR_FLAGS_LO_ALIGNED_BFR 0x20
  471. #define IPR_FLAGS_LO_DELAY_AFTER_RST 0x10
  472. #define IPR_FLAGS_LO_UNTAGGED_TASK 0x00
  473. #define IPR_FLAGS_LO_SIMPLE_TASK 0x02
  474. #define IPR_FLAGS_LO_ORDERED_TASK 0x04
  475. #define IPR_FLAGS_LO_HEAD_OF_Q_TASK 0x06
  476. #define IPR_FLAGS_LO_ACA_TASK 0x08
  477. u8 cdb[16];
  478. __be16 timeout;
  479. }__attribute__ ((packed, aligned(4)));
  480. struct ipr_ioarcb_ata_regs { /* 22 bytes */
  481. u8 flags;
  482. #define IPR_ATA_FLAG_PACKET_CMD 0x80
  483. #define IPR_ATA_FLAG_XFER_TYPE_DMA 0x40
  484. #define IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION 0x20
  485. u8 reserved[3];
  486. __be16 data;
  487. u8 feature;
  488. u8 nsect;
  489. u8 lbal;
  490. u8 lbam;
  491. u8 lbah;
  492. u8 device;
  493. u8 command;
  494. u8 reserved2[3];
  495. u8 hob_feature;
  496. u8 hob_nsect;
  497. u8 hob_lbal;
  498. u8 hob_lbam;
  499. u8 hob_lbah;
  500. u8 ctl;
  501. }__attribute__ ((packed, aligned(2)));
  502. struct ipr_ioadl_desc {
  503. __be32 flags_and_data_len;
  504. #define IPR_IOADL_FLAGS_MASK 0xff000000
  505. #define IPR_IOADL_GET_FLAGS(x) (be32_to_cpu(x) & IPR_IOADL_FLAGS_MASK)
  506. #define IPR_IOADL_DATA_LEN_MASK 0x00ffffff
  507. #define IPR_IOADL_GET_DATA_LEN(x) (be32_to_cpu(x) & IPR_IOADL_DATA_LEN_MASK)
  508. #define IPR_IOADL_FLAGS_READ 0x48000000
  509. #define IPR_IOADL_FLAGS_READ_LAST 0x49000000
  510. #define IPR_IOADL_FLAGS_WRITE 0x68000000
  511. #define IPR_IOADL_FLAGS_WRITE_LAST 0x69000000
  512. #define IPR_IOADL_FLAGS_LAST 0x01000000
  513. __be32 address;
  514. }__attribute__((packed, aligned (8)));
  515. struct ipr_ioadl64_desc {
  516. __be32 flags;
  517. __be32 data_len;
  518. __be64 address;
  519. }__attribute__((packed, aligned (16)));
  520. struct ipr_ata64_ioadl {
  521. struct ipr_ioarcb_ata_regs regs;
  522. u16 reserved[5];
  523. struct ipr_ioadl64_desc ioadl64[IPR_NUM_IOADL_ENTRIES];
  524. }__attribute__((packed, aligned (16)));
  525. struct ipr_ioarcb_add_data {
  526. union {
  527. struct ipr_ioarcb_ata_regs regs;
  528. struct ipr_ioadl_desc ioadl[5];
  529. __be32 add_cmd_parms[10];
  530. } u;
  531. }__attribute__ ((packed, aligned (4)));
  532. struct ipr_ioarcb_sis64_add_addr_ecb {
  533. __be64 ioasa_host_pci_addr;
  534. __be64 data_ioadl_addr;
  535. __be64 reserved;
  536. __be32 ext_control_buf[4];
  537. }__attribute__((packed, aligned (8)));
  538. /* IOA Request Control Block 128 bytes */
  539. struct ipr_ioarcb {
  540. union {
  541. __be32 ioarcb_host_pci_addr;
  542. __be64 ioarcb_host_pci_addr64;
  543. } a;
  544. __be32 res_handle;
  545. __be32 host_response_handle;
  546. __be32 reserved1;
  547. __be32 reserved2;
  548. __be32 reserved3;
  549. __be32 data_transfer_length;
  550. __be32 read_data_transfer_length;
  551. __be32 write_ioadl_addr;
  552. __be32 ioadl_len;
  553. __be32 read_ioadl_addr;
  554. __be32 read_ioadl_len;
  555. __be32 ioasa_host_pci_addr;
  556. __be16 ioasa_len;
  557. __be16 reserved4;
  558. struct ipr_cmd_pkt cmd_pkt;
  559. __be16 add_cmd_parms_offset;
  560. __be16 add_cmd_parms_len;
  561. union {
  562. struct ipr_ioarcb_add_data add_data;
  563. struct ipr_ioarcb_sis64_add_addr_ecb sis64_addr_data;
  564. } u;
  565. }__attribute__((packed, aligned (4)));
  566. struct ipr_ioasa_vset {
  567. __be32 failing_lba_hi;
  568. __be32 failing_lba_lo;
  569. __be32 reserved;
  570. }__attribute__((packed, aligned (4)));
  571. struct ipr_ioasa_af_dasd {
  572. __be32 failing_lba;
  573. __be32 reserved[2];
  574. }__attribute__((packed, aligned (4)));
  575. struct ipr_ioasa_gpdd {
  576. u8 end_state;
  577. u8 bus_phase;
  578. __be16 reserved;
  579. __be32 ioa_data[2];
  580. }__attribute__((packed, aligned (4)));
  581. struct ipr_ioasa_gata {
  582. u8 error;
  583. u8 nsect; /* Interrupt reason */
  584. u8 lbal;
  585. u8 lbam;
  586. u8 lbah;
  587. u8 device;
  588. u8 status;
  589. u8 alt_status; /* ATA CTL */
  590. u8 hob_nsect;
  591. u8 hob_lbal;
  592. u8 hob_lbam;
  593. u8 hob_lbah;
  594. }__attribute__((packed, aligned (4)));
  595. struct ipr_auto_sense {
  596. __be16 auto_sense_len;
  597. __be16 ioa_data_len;
  598. __be32 data[SCSI_SENSE_BUFFERSIZE/sizeof(__be32)];
  599. };
  600. struct ipr_ioasa_hdr {
  601. __be32 ioasc;
  602. #define IPR_IOASC_SENSE_KEY(ioasc) ((ioasc) >> 24)
  603. #define IPR_IOASC_SENSE_CODE(ioasc) (((ioasc) & 0x00ff0000) >> 16)
  604. #define IPR_IOASC_SENSE_QUAL(ioasc) (((ioasc) & 0x0000ff00) >> 8)
  605. #define IPR_IOASC_SENSE_STATUS(ioasc) ((ioasc) & 0x000000ff)
  606. __be16 ret_stat_len; /* Length of the returned IOASA */
  607. __be16 avail_stat_len; /* Total Length of status available. */
  608. __be32 residual_data_len; /* number of bytes in the host data */
  609. /* buffers that were not used by the IOARCB command. */
  610. __be32 ilid;
  611. #define IPR_NO_ILID 0
  612. #define IPR_DRIVER_ILID 0xffffffff
  613. __be32 fd_ioasc;
  614. __be32 fd_phys_locator;
  615. __be32 fd_res_handle;
  616. __be32 ioasc_specific; /* status code specific field */
  617. #define IPR_ADDITIONAL_STATUS_FMT 0x80000000
  618. #define IPR_AUTOSENSE_VALID 0x40000000
  619. #define IPR_ATA_DEVICE_WAS_RESET 0x20000000
  620. #define IPR_IOASC_SPECIFIC_MASK 0x00ffffff
  621. #define IPR_FIELD_POINTER_VALID (0x80000000 >> 8)
  622. #define IPR_FIELD_POINTER_MASK 0x0000ffff
  623. }__attribute__((packed, aligned (4)));
  624. struct ipr_ioasa {
  625. struct ipr_ioasa_hdr hdr;
  626. union {
  627. struct ipr_ioasa_vset vset;
  628. struct ipr_ioasa_af_dasd dasd;
  629. struct ipr_ioasa_gpdd gpdd;
  630. struct ipr_ioasa_gata gata;
  631. } u;
  632. struct ipr_auto_sense auto_sense;
  633. }__attribute__((packed, aligned (4)));
  634. struct ipr_ioasa64 {
  635. struct ipr_ioasa_hdr hdr;
  636. u8 fd_res_path[8];
  637. union {
  638. struct ipr_ioasa_vset vset;
  639. struct ipr_ioasa_af_dasd dasd;
  640. struct ipr_ioasa_gpdd gpdd;
  641. struct ipr_ioasa_gata gata;
  642. } u;
  643. struct ipr_auto_sense auto_sense;
  644. }__attribute__((packed, aligned (4)));
  645. struct ipr_mode_parm_hdr {
  646. u8 length;
  647. u8 medium_type;
  648. u8 device_spec_parms;
  649. u8 block_desc_len;
  650. }__attribute__((packed));
  651. struct ipr_mode_pages {
  652. struct ipr_mode_parm_hdr hdr;
  653. u8 data[255 - sizeof(struct ipr_mode_parm_hdr)];
  654. }__attribute__((packed));
  655. struct ipr_mode_page_hdr {
  656. u8 ps_page_code;
  657. #define IPR_MODE_PAGE_PS 0x80
  658. #define IPR_GET_MODE_PAGE_CODE(hdr) ((hdr)->ps_page_code & 0x3F)
  659. u8 page_length;
  660. }__attribute__ ((packed));
  661. struct ipr_dev_bus_entry {
  662. struct ipr_res_addr res_addr;
  663. u8 flags;
  664. #define IPR_SCSI_ATTR_ENABLE_QAS 0x80
  665. #define IPR_SCSI_ATTR_DISABLE_QAS 0x40
  666. #define IPR_SCSI_ATTR_QAS_MASK 0xC0
  667. #define IPR_SCSI_ATTR_ENABLE_TM 0x20
  668. #define IPR_SCSI_ATTR_NO_TERM_PWR 0x10
  669. #define IPR_SCSI_ATTR_TM_SUPPORTED 0x08
  670. #define IPR_SCSI_ATTR_LVD_TO_SE_NOT_ALLOWED 0x04
  671. u8 scsi_id;
  672. u8 bus_width;
  673. u8 extended_reset_delay;
  674. #define IPR_EXTENDED_RESET_DELAY 7
  675. __be32 max_xfer_rate;
  676. u8 spinup_delay;
  677. u8 reserved3;
  678. __be16 reserved4;
  679. }__attribute__((packed, aligned (4)));
  680. struct ipr_mode_page28 {
  681. struct ipr_mode_page_hdr hdr;
  682. u8 num_entries;
  683. u8 entry_length;
  684. struct ipr_dev_bus_entry bus[0];
  685. }__attribute__((packed));
  686. struct ipr_mode_page24 {
  687. struct ipr_mode_page_hdr hdr;
  688. u8 flags;
  689. #define IPR_ENABLE_DUAL_IOA_AF 0x80
  690. }__attribute__((packed));
  691. struct ipr_ioa_vpd {
  692. struct ipr_std_inq_data std_inq_data;
  693. u8 ascii_part_num[12];
  694. u8 reserved[40];
  695. u8 ascii_plant_code[4];
  696. }__attribute__((packed));
  697. struct ipr_inquiry_page3 {
  698. u8 peri_qual_dev_type;
  699. u8 page_code;
  700. u8 reserved1;
  701. u8 page_length;
  702. u8 ascii_len;
  703. u8 reserved2[3];
  704. u8 load_id[4];
  705. u8 major_release;
  706. u8 card_type;
  707. u8 minor_release[2];
  708. u8 ptf_number[4];
  709. u8 patch_number[4];
  710. }__attribute__((packed));
  711. struct ipr_inquiry_cap {
  712. u8 peri_qual_dev_type;
  713. u8 page_code;
  714. u8 reserved1;
  715. u8 page_length;
  716. u8 ascii_len;
  717. u8 reserved2;
  718. u8 sis_version[2];
  719. u8 cap;
  720. #define IPR_CAP_DUAL_IOA_RAID 0x80
  721. u8 reserved3[15];
  722. }__attribute__((packed));
  723. #define IPR_INQUIRY_PAGE0_ENTRIES 20
  724. struct ipr_inquiry_page0 {
  725. u8 peri_qual_dev_type;
  726. u8 page_code;
  727. u8 reserved1;
  728. u8 len;
  729. u8 page[IPR_INQUIRY_PAGE0_ENTRIES];
  730. }__attribute__((packed));
  731. struct ipr_inquiry_pageC4 {
  732. u8 peri_qual_dev_type;
  733. u8 page_code;
  734. u8 reserved1;
  735. u8 len;
  736. u8 cache_cap[4];
  737. #define IPR_CAP_SYNC_CACHE 0x08
  738. u8 reserved2[20];
  739. } __packed;
  740. struct ipr_hostrcb_device_data_entry {
  741. struct ipr_vpd vpd;
  742. struct ipr_res_addr dev_res_addr;
  743. struct ipr_vpd new_vpd;
  744. struct ipr_vpd ioa_last_with_dev_vpd;
  745. struct ipr_vpd cfc_last_with_dev_vpd;
  746. __be32 ioa_data[5];
  747. }__attribute__((packed, aligned (4)));
  748. struct ipr_hostrcb_device_data_entry_enhanced {
  749. struct ipr_ext_vpd vpd;
  750. u8 ccin[4];
  751. struct ipr_res_addr dev_res_addr;
  752. struct ipr_ext_vpd new_vpd;
  753. u8 new_ccin[4];
  754. struct ipr_ext_vpd ioa_last_with_dev_vpd;
  755. struct ipr_ext_vpd cfc_last_with_dev_vpd;
  756. }__attribute__((packed, aligned (4)));
  757. struct ipr_hostrcb64_device_data_entry_enhanced {
  758. struct ipr_ext_vpd vpd;
  759. u8 ccin[4];
  760. u8 res_path[8];
  761. struct ipr_ext_vpd new_vpd;
  762. u8 new_ccin[4];
  763. struct ipr_ext_vpd ioa_last_with_dev_vpd;
  764. struct ipr_ext_vpd cfc_last_with_dev_vpd;
  765. }__attribute__((packed, aligned (4)));
  766. struct ipr_hostrcb_array_data_entry {
  767. struct ipr_vpd vpd;
  768. struct ipr_res_addr expected_dev_res_addr;
  769. struct ipr_res_addr dev_res_addr;
  770. }__attribute__((packed, aligned (4)));
  771. struct ipr_hostrcb64_array_data_entry {
  772. struct ipr_ext_vpd vpd;
  773. u8 ccin[4];
  774. u8 expected_res_path[8];
  775. u8 res_path[8];
  776. }__attribute__((packed, aligned (4)));
  777. struct ipr_hostrcb_array_data_entry_enhanced {
  778. struct ipr_ext_vpd vpd;
  779. u8 ccin[4];
  780. struct ipr_res_addr expected_dev_res_addr;
  781. struct ipr_res_addr dev_res_addr;
  782. }__attribute__((packed, aligned (4)));
  783. struct ipr_hostrcb_type_ff_error {
  784. __be32 ioa_data[758];
  785. }__attribute__((packed, aligned (4)));
  786. struct ipr_hostrcb_type_01_error {
  787. __be32 seek_counter;
  788. __be32 read_counter;
  789. u8 sense_data[32];
  790. __be32 ioa_data[236];
  791. }__attribute__((packed, aligned (4)));
  792. struct ipr_hostrcb_type_21_error {
  793. __be32 wwn[4];
  794. u8 res_path[8];
  795. u8 primary_problem_desc[32];
  796. u8 second_problem_desc[32];
  797. __be32 sense_data[8];
  798. __be32 cdb[4];
  799. __be32 residual_trans_length;
  800. __be32 length_of_error;
  801. __be32 ioa_data[236];
  802. }__attribute__((packed, aligned (4)));
  803. struct ipr_hostrcb_type_02_error {
  804. struct ipr_vpd ioa_vpd;
  805. struct ipr_vpd cfc_vpd;
  806. struct ipr_vpd ioa_last_attached_to_cfc_vpd;
  807. struct ipr_vpd cfc_last_attached_to_ioa_vpd;
  808. __be32 ioa_data[3];
  809. }__attribute__((packed, aligned (4)));
  810. struct ipr_hostrcb_type_12_error {
  811. struct ipr_ext_vpd ioa_vpd;
  812. struct ipr_ext_vpd cfc_vpd;
  813. struct ipr_ext_vpd ioa_last_attached_to_cfc_vpd;
  814. struct ipr_ext_vpd cfc_last_attached_to_ioa_vpd;
  815. __be32 ioa_data[3];
  816. }__attribute__((packed, aligned (4)));
  817. struct ipr_hostrcb_type_03_error {
  818. struct ipr_vpd ioa_vpd;
  819. struct ipr_vpd cfc_vpd;
  820. __be32 errors_detected;
  821. __be32 errors_logged;
  822. u8 ioa_data[12];
  823. struct ipr_hostrcb_device_data_entry dev[3];
  824. }__attribute__((packed, aligned (4)));
  825. struct ipr_hostrcb_type_13_error {
  826. struct ipr_ext_vpd ioa_vpd;
  827. struct ipr_ext_vpd cfc_vpd;
  828. __be32 errors_detected;
  829. __be32 errors_logged;
  830. struct ipr_hostrcb_device_data_entry_enhanced dev[3];
  831. }__attribute__((packed, aligned (4)));
  832. struct ipr_hostrcb_type_23_error {
  833. struct ipr_ext_vpd ioa_vpd;
  834. struct ipr_ext_vpd cfc_vpd;
  835. __be32 errors_detected;
  836. __be32 errors_logged;
  837. struct ipr_hostrcb64_device_data_entry_enhanced dev[3];
  838. }__attribute__((packed, aligned (4)));
  839. struct ipr_hostrcb_type_04_error {
  840. struct ipr_vpd ioa_vpd;
  841. struct ipr_vpd cfc_vpd;
  842. u8 ioa_data[12];
  843. struct ipr_hostrcb_array_data_entry array_member[10];
  844. __be32 exposed_mode_adn;
  845. __be32 array_id;
  846. struct ipr_vpd incomp_dev_vpd;
  847. __be32 ioa_data2;
  848. struct ipr_hostrcb_array_data_entry array_member2[8];
  849. struct ipr_res_addr last_func_vset_res_addr;
  850. u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
  851. u8 protection_level[8];
  852. }__attribute__((packed, aligned (4)));
  853. struct ipr_hostrcb_type_14_error {
  854. struct ipr_ext_vpd ioa_vpd;
  855. struct ipr_ext_vpd cfc_vpd;
  856. __be32 exposed_mode_adn;
  857. __be32 array_id;
  858. struct ipr_res_addr last_func_vset_res_addr;
  859. u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
  860. u8 protection_level[8];
  861. __be32 num_entries;
  862. struct ipr_hostrcb_array_data_entry_enhanced array_member[18];
  863. }__attribute__((packed, aligned (4)));
  864. struct ipr_hostrcb_type_24_error {
  865. struct ipr_ext_vpd ioa_vpd;
  866. struct ipr_ext_vpd cfc_vpd;
  867. u8 reserved[2];
  868. u8 exposed_mode_adn;
  869. #define IPR_INVALID_ARRAY_DEV_NUM 0xff
  870. u8 array_id;
  871. u8 last_res_path[8];
  872. u8 protection_level[8];
  873. struct ipr_ext_vpd64 array_vpd;
  874. u8 description[16];
  875. u8 reserved2[3];
  876. u8 num_entries;
  877. struct ipr_hostrcb64_array_data_entry array_member[32];
  878. }__attribute__((packed, aligned (4)));
  879. struct ipr_hostrcb_type_07_error {
  880. u8 failure_reason[64];
  881. struct ipr_vpd vpd;
  882. __be32 data[222];
  883. }__attribute__((packed, aligned (4)));
  884. struct ipr_hostrcb_type_17_error {
  885. u8 failure_reason[64];
  886. struct ipr_ext_vpd vpd;
  887. __be32 data[476];
  888. }__attribute__((packed, aligned (4)));
  889. struct ipr_hostrcb_config_element {
  890. u8 type_status;
  891. #define IPR_PATH_CFG_TYPE_MASK 0xF0
  892. #define IPR_PATH_CFG_NOT_EXIST 0x00
  893. #define IPR_PATH_CFG_IOA_PORT 0x10
  894. #define IPR_PATH_CFG_EXP_PORT 0x20
  895. #define IPR_PATH_CFG_DEVICE_PORT 0x30
  896. #define IPR_PATH_CFG_DEVICE_LUN 0x40
  897. #define IPR_PATH_CFG_STATUS_MASK 0x0F
  898. #define IPR_PATH_CFG_NO_PROB 0x00
  899. #define IPR_PATH_CFG_DEGRADED 0x01
  900. #define IPR_PATH_CFG_FAILED 0x02
  901. #define IPR_PATH_CFG_SUSPECT 0x03
  902. #define IPR_PATH_NOT_DETECTED 0x04
  903. #define IPR_PATH_INCORRECT_CONN 0x05
  904. u8 cascaded_expander;
  905. u8 phy;
  906. u8 link_rate;
  907. #define IPR_PHY_LINK_RATE_MASK 0x0F
  908. __be32 wwid[2];
  909. }__attribute__((packed, aligned (4)));
  910. struct ipr_hostrcb64_config_element {
  911. __be16 length;
  912. u8 descriptor_id;
  913. #define IPR_DESCRIPTOR_MASK 0xC0
  914. #define IPR_DESCRIPTOR_SIS64 0x00
  915. u8 reserved;
  916. u8 type_status;
  917. u8 reserved2[2];
  918. u8 link_rate;
  919. u8 res_path[8];
  920. __be32 wwid[2];
  921. }__attribute__((packed, aligned (8)));
  922. struct ipr_hostrcb_fabric_desc {
  923. __be16 length;
  924. u8 ioa_port;
  925. u8 cascaded_expander;
  926. u8 phy;
  927. u8 path_state;
  928. #define IPR_PATH_ACTIVE_MASK 0xC0
  929. #define IPR_PATH_NO_INFO 0x00
  930. #define IPR_PATH_ACTIVE 0x40
  931. #define IPR_PATH_NOT_ACTIVE 0x80
  932. #define IPR_PATH_STATE_MASK 0x0F
  933. #define IPR_PATH_STATE_NO_INFO 0x00
  934. #define IPR_PATH_HEALTHY 0x01
  935. #define IPR_PATH_DEGRADED 0x02
  936. #define IPR_PATH_FAILED 0x03
  937. __be16 num_entries;
  938. struct ipr_hostrcb_config_element elem[1];
  939. }__attribute__((packed, aligned (4)));
  940. struct ipr_hostrcb64_fabric_desc {
  941. __be16 length;
  942. u8 descriptor_id;
  943. u8 reserved[2];
  944. u8 path_state;
  945. u8 reserved2[2];
  946. u8 res_path[8];
  947. u8 reserved3[6];
  948. __be16 num_entries;
  949. struct ipr_hostrcb64_config_element elem[1];
  950. }__attribute__((packed, aligned (8)));
  951. #define for_each_hrrq(hrrq, ioa_cfg) \
  952. for (hrrq = (ioa_cfg)->hrrq; \
  953. hrrq < ((ioa_cfg)->hrrq + (ioa_cfg)->hrrq_num); hrrq++)
  954. #define for_each_fabric_cfg(fabric, cfg) \
  955. for (cfg = (fabric)->elem; \
  956. cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \
  957. cfg++)
  958. struct ipr_hostrcb_type_20_error {
  959. u8 failure_reason[64];
  960. u8 reserved[3];
  961. u8 num_entries;
  962. struct ipr_hostrcb_fabric_desc desc[1];
  963. }__attribute__((packed, aligned (4)));
  964. struct ipr_hostrcb_type_30_error {
  965. u8 failure_reason[64];
  966. u8 reserved[3];
  967. u8 num_entries;
  968. struct ipr_hostrcb64_fabric_desc desc[1];
  969. }__attribute__((packed, aligned (4)));
  970. struct ipr_hostrcb_error {
  971. __be32 fd_ioasc;
  972. struct ipr_res_addr fd_res_addr;
  973. __be32 fd_res_handle;
  974. __be32 prc;
  975. union {
  976. struct ipr_hostrcb_type_ff_error type_ff_error;
  977. struct ipr_hostrcb_type_01_error type_01_error;
  978. struct ipr_hostrcb_type_02_error type_02_error;
  979. struct ipr_hostrcb_type_03_error type_03_error;
  980. struct ipr_hostrcb_type_04_error type_04_error;
  981. struct ipr_hostrcb_type_07_error type_07_error;
  982. struct ipr_hostrcb_type_12_error type_12_error;
  983. struct ipr_hostrcb_type_13_error type_13_error;
  984. struct ipr_hostrcb_type_14_error type_14_error;
  985. struct ipr_hostrcb_type_17_error type_17_error;
  986. struct ipr_hostrcb_type_20_error type_20_error;
  987. } u;
  988. }__attribute__((packed, aligned (4)));
  989. struct ipr_hostrcb64_error {
  990. __be32 fd_ioasc;
  991. __be32 ioa_fw_level;
  992. __be32 fd_res_handle;
  993. __be32 prc;
  994. __be64 fd_dev_id;
  995. __be64 fd_lun;
  996. u8 fd_res_path[8];
  997. __be64 time_stamp;
  998. u8 reserved[16];
  999. union {
  1000. struct ipr_hostrcb_type_ff_error type_ff_error;
  1001. struct ipr_hostrcb_type_12_error type_12_error;
  1002. struct ipr_hostrcb_type_17_error type_17_error;
  1003. struct ipr_hostrcb_type_21_error type_21_error;
  1004. struct ipr_hostrcb_type_23_error type_23_error;
  1005. struct ipr_hostrcb_type_24_error type_24_error;
  1006. struct ipr_hostrcb_type_30_error type_30_error;
  1007. } u;
  1008. }__attribute__((packed, aligned (8)));
  1009. struct ipr_hostrcb_raw {
  1010. __be32 data[sizeof(struct ipr_hostrcb_error)/sizeof(__be32)];
  1011. }__attribute__((packed, aligned (4)));
  1012. struct ipr_hcam {
  1013. u8 op_code;
  1014. #define IPR_HOST_RCB_OP_CODE_CONFIG_CHANGE 0xE1
  1015. #define IPR_HOST_RCB_OP_CODE_LOG_DATA 0xE2
  1016. u8 notify_type;
  1017. #define IPR_HOST_RCB_NOTIF_TYPE_EXISTING_CHANGED 0x00
  1018. #define IPR_HOST_RCB_NOTIF_TYPE_NEW_ENTRY 0x01
  1019. #define IPR_HOST_RCB_NOTIF_TYPE_REM_ENTRY 0x02
  1020. #define IPR_HOST_RCB_NOTIF_TYPE_ERROR_LOG_ENTRY 0x10
  1021. #define IPR_HOST_RCB_NOTIF_TYPE_INFORMATION_ENTRY 0x11
  1022. u8 notifications_lost;
  1023. #define IPR_HOST_RCB_NO_NOTIFICATIONS_LOST 0
  1024. #define IPR_HOST_RCB_NOTIFICATIONS_LOST 0x80
  1025. u8 flags;
  1026. #define IPR_HOSTRCB_INTERNAL_OPER 0x80
  1027. #define IPR_HOSTRCB_ERR_RESP_SENT 0x40
  1028. u8 overlay_id;
  1029. #define IPR_HOST_RCB_OVERLAY_ID_1 0x01
  1030. #define IPR_HOST_RCB_OVERLAY_ID_2 0x02
  1031. #define IPR_HOST_RCB_OVERLAY_ID_3 0x03
  1032. #define IPR_HOST_RCB_OVERLAY_ID_4 0x04
  1033. #define IPR_HOST_RCB_OVERLAY_ID_6 0x06
  1034. #define IPR_HOST_RCB_OVERLAY_ID_7 0x07
  1035. #define IPR_HOST_RCB_OVERLAY_ID_12 0x12
  1036. #define IPR_HOST_RCB_OVERLAY_ID_13 0x13
  1037. #define IPR_HOST_RCB_OVERLAY_ID_14 0x14
  1038. #define IPR_HOST_RCB_OVERLAY_ID_16 0x16
  1039. #define IPR_HOST_RCB_OVERLAY_ID_17 0x17
  1040. #define IPR_HOST_RCB_OVERLAY_ID_20 0x20
  1041. #define IPR_HOST_RCB_OVERLAY_ID_21 0x21
  1042. #define IPR_HOST_RCB_OVERLAY_ID_23 0x23
  1043. #define IPR_HOST_RCB_OVERLAY_ID_24 0x24
  1044. #define IPR_HOST_RCB_OVERLAY_ID_26 0x26
  1045. #define IPR_HOST_RCB_OVERLAY_ID_30 0x30
  1046. #define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF
  1047. u8 reserved1[3];
  1048. __be32 ilid;
  1049. __be32 time_since_last_ioa_reset;
  1050. __be32 reserved2;
  1051. __be32 length;
  1052. union {
  1053. struct ipr_hostrcb_error error;
  1054. struct ipr_hostrcb64_error error64;
  1055. struct ipr_hostrcb_cfg_ch_not ccn;
  1056. struct ipr_hostrcb_raw raw;
  1057. } u;
  1058. }__attribute__((packed, aligned (4)));
  1059. struct ipr_hostrcb {
  1060. struct ipr_hcam hcam;
  1061. dma_addr_t hostrcb_dma;
  1062. struct list_head queue;
  1063. struct ipr_ioa_cfg *ioa_cfg;
  1064. char rp_buffer[IPR_MAX_RES_PATH_LENGTH];
  1065. };
  1066. /* IPR smart dump table structures */
  1067. struct ipr_sdt_entry {
  1068. __be32 start_token;
  1069. __be32 end_token;
  1070. u8 reserved[4];
  1071. u8 flags;
  1072. #define IPR_SDT_ENDIAN 0x80
  1073. #define IPR_SDT_VALID_ENTRY 0x20
  1074. u8 resv;
  1075. __be16 priority;
  1076. }__attribute__((packed, aligned (4)));
  1077. struct ipr_sdt_header {
  1078. __be32 state;
  1079. __be32 num_entries;
  1080. __be32 num_entries_used;
  1081. __be32 dump_size;
  1082. }__attribute__((packed, aligned (4)));
  1083. struct ipr_sdt {
  1084. struct ipr_sdt_header hdr;
  1085. struct ipr_sdt_entry entry[IPR_FMT3_NUM_SDT_ENTRIES];
  1086. }__attribute__((packed, aligned (4)));
  1087. struct ipr_uc_sdt {
  1088. struct ipr_sdt_header hdr;
  1089. struct ipr_sdt_entry entry[1];
  1090. }__attribute__((packed, aligned (4)));
  1091. /*
  1092. * Driver types
  1093. */
  1094. struct ipr_bus_attributes {
  1095. u8 bus;
  1096. u8 qas_enabled;
  1097. u8 bus_width;
  1098. u8 reserved;
  1099. u32 max_xfer_rate;
  1100. };
  1101. struct ipr_sata_port {
  1102. struct ipr_ioa_cfg *ioa_cfg;
  1103. struct ata_port *ap;
  1104. struct ipr_resource_entry *res;
  1105. struct ipr_ioasa_gata ioasa;
  1106. };
  1107. struct ipr_resource_entry {
  1108. u8 needs_sync_complete:1;
  1109. u8 in_erp:1;
  1110. u8 add_to_ml:1;
  1111. u8 del_from_ml:1;
  1112. u8 resetting_device:1;
  1113. u8 reset_occurred:1;
  1114. u8 raw_mode:1;
  1115. u32 bus; /* AKA channel */
  1116. u32 target; /* AKA id */
  1117. u32 lun;
  1118. #define IPR_ARRAY_VIRTUAL_BUS 0x1
  1119. #define IPR_VSET_VIRTUAL_BUS 0x2
  1120. #define IPR_IOAFP_VIRTUAL_BUS 0x3
  1121. #define IPR_GET_RES_PHYS_LOC(res) \
  1122. (((res)->bus << 24) | ((res)->target << 8) | (res)->lun)
  1123. u8 ata_class;
  1124. u8 type;
  1125. u16 flags;
  1126. u16 res_flags;
  1127. u8 qmodel;
  1128. struct ipr_std_inq_data std_inq_data;
  1129. __be32 res_handle;
  1130. __be64 dev_id;
  1131. u64 lun_wwn;
  1132. struct scsi_lun dev_lun;
  1133. u8 res_path[8];
  1134. struct ipr_ioa_cfg *ioa_cfg;
  1135. struct scsi_device *sdev;
  1136. struct ipr_sata_port *sata_port;
  1137. struct list_head queue;
  1138. }; /* struct ipr_resource_entry */
  1139. struct ipr_resource_hdr {
  1140. u16 num_entries;
  1141. u16 reserved;
  1142. };
  1143. struct ipr_misc_cbs {
  1144. struct ipr_ioa_vpd ioa_vpd;
  1145. struct ipr_inquiry_page0 page0_data;
  1146. struct ipr_inquiry_page3 page3_data;
  1147. struct ipr_inquiry_cap cap;
  1148. struct ipr_inquiry_pageC4 pageC4_data;
  1149. struct ipr_mode_pages mode_pages;
  1150. struct ipr_supported_device supp_dev;
  1151. };
  1152. struct ipr_interrupt_offsets {
  1153. unsigned long set_interrupt_mask_reg;
  1154. unsigned long clr_interrupt_mask_reg;
  1155. unsigned long clr_interrupt_mask_reg32;
  1156. unsigned long sense_interrupt_mask_reg;
  1157. unsigned long sense_interrupt_mask_reg32;
  1158. unsigned long clr_interrupt_reg;
  1159. unsigned long clr_interrupt_reg32;
  1160. unsigned long sense_interrupt_reg;
  1161. unsigned long sense_interrupt_reg32;
  1162. unsigned long ioarrin_reg;
  1163. unsigned long sense_uproc_interrupt_reg;
  1164. unsigned long sense_uproc_interrupt_reg32;
  1165. unsigned long set_uproc_interrupt_reg;
  1166. unsigned long set_uproc_interrupt_reg32;
  1167. unsigned long clr_uproc_interrupt_reg;
  1168. unsigned long clr_uproc_interrupt_reg32;
  1169. unsigned long init_feedback_reg;
  1170. unsigned long dump_addr_reg;
  1171. unsigned long dump_data_reg;
  1172. #define IPR_ENDIAN_SWAP_KEY 0x00080800
  1173. unsigned long endian_swap_reg;
  1174. };
  1175. struct ipr_interrupts {
  1176. void __iomem *set_interrupt_mask_reg;
  1177. void __iomem *clr_interrupt_mask_reg;
  1178. void __iomem *clr_interrupt_mask_reg32;
  1179. void __iomem *sense_interrupt_mask_reg;
  1180. void __iomem *sense_interrupt_mask_reg32;
  1181. void __iomem *clr_interrupt_reg;
  1182. void __iomem *clr_interrupt_reg32;
  1183. void __iomem *sense_interrupt_reg;
  1184. void __iomem *sense_interrupt_reg32;
  1185. void __iomem *ioarrin_reg;
  1186. void __iomem *sense_uproc_interrupt_reg;
  1187. void __iomem *sense_uproc_interrupt_reg32;
  1188. void __iomem *set_uproc_interrupt_reg;
  1189. void __iomem *set_uproc_interrupt_reg32;
  1190. void __iomem *clr_uproc_interrupt_reg;
  1191. void __iomem *clr_uproc_interrupt_reg32;
  1192. void __iomem *init_feedback_reg;
  1193. void __iomem *dump_addr_reg;
  1194. void __iomem *dump_data_reg;
  1195. void __iomem *endian_swap_reg;
  1196. };
  1197. struct ipr_chip_cfg_t {
  1198. u32 mailbox;
  1199. u16 max_cmds;
  1200. u8 cache_line_size;
  1201. u8 clear_isr;
  1202. u32 iopoll_weight;
  1203. struct ipr_interrupt_offsets regs;
  1204. };
  1205. struct ipr_chip_t {
  1206. u16 vendor;
  1207. u16 device;
  1208. u16 intr_type;
  1209. #define IPR_USE_LSI 0x00
  1210. #define IPR_USE_MSI 0x01
  1211. #define IPR_USE_MSIX 0x02
  1212. u16 sis_type;
  1213. #define IPR_SIS32 0x00
  1214. #define IPR_SIS64 0x01
  1215. u16 bist_method;
  1216. #define IPR_PCI_CFG 0x00
  1217. #define IPR_MMIO 0x01
  1218. const struct ipr_chip_cfg_t *cfg;
  1219. };
  1220. enum ipr_shutdown_type {
  1221. IPR_SHUTDOWN_NORMAL = 0x00,
  1222. IPR_SHUTDOWN_PREPARE_FOR_NORMAL = 0x40,
  1223. IPR_SHUTDOWN_ABBREV = 0x80,
  1224. IPR_SHUTDOWN_NONE = 0x100,
  1225. IPR_SHUTDOWN_QUIESCE = 0x101,
  1226. };
  1227. struct ipr_trace_entry {
  1228. u32 time;
  1229. u8 op_code;
  1230. u8 ata_op_code;
  1231. u8 type;
  1232. #define IPR_TRACE_START 0x00
  1233. #define IPR_TRACE_FINISH 0xff
  1234. u8 cmd_index;
  1235. __be32 res_handle;
  1236. union {
  1237. u32 ioasc;
  1238. u32 add_data;
  1239. u32 res_addr;
  1240. } u;
  1241. };
  1242. struct ipr_sglist {
  1243. u32 order;
  1244. u32 num_sg;
  1245. u32 num_dma_sg;
  1246. u32 buffer_len;
  1247. struct scatterlist scatterlist[1];
  1248. };
  1249. enum ipr_sdt_state {
  1250. INACTIVE,
  1251. WAIT_FOR_DUMP,
  1252. GET_DUMP,
  1253. READ_DUMP,
  1254. ABORT_DUMP,
  1255. DUMP_OBTAINED
  1256. };
  1257. /* Per-controller data */
  1258. struct ipr_ioa_cfg {
  1259. char eye_catcher[8];
  1260. #define IPR_EYECATCHER "iprcfg"
  1261. struct list_head queue;
  1262. u8 in_reset_reload:1;
  1263. u8 in_ioa_bringdown:1;
  1264. u8 ioa_unit_checked:1;
  1265. u8 dump_taken:1;
  1266. u8 scan_done:1;
  1267. u8 needs_hard_reset:1;
  1268. u8 dual_raid:1;
  1269. u8 needs_warm_reset:1;
  1270. u8 msi_received:1;
  1271. u8 sis64:1;
  1272. u8 dump_timeout:1;
  1273. u8 cfg_locked:1;
  1274. u8 clear_isr:1;
  1275. u8 probe_done:1;
  1276. u8 revid;
  1277. /*
  1278. * Bitmaps for SIS64 generated target values
  1279. */
  1280. unsigned long target_ids[BITS_TO_LONGS(IPR_MAX_SIS64_DEVS)];
  1281. unsigned long array_ids[BITS_TO_LONGS(IPR_MAX_SIS64_DEVS)];
  1282. unsigned long vset_ids[BITS_TO_LONGS(IPR_MAX_SIS64_DEVS)];
  1283. u16 type; /* CCIN of the card */
  1284. u8 log_level;
  1285. #define IPR_MAX_LOG_LEVEL 4
  1286. #define IPR_DEFAULT_LOG_LEVEL 2
  1287. #define IPR_NUM_TRACE_INDEX_BITS 8
  1288. #define IPR_NUM_TRACE_ENTRIES (1 << IPR_NUM_TRACE_INDEX_BITS)
  1289. #define IPR_TRACE_INDEX_MASK (IPR_NUM_TRACE_ENTRIES - 1)
  1290. #define IPR_TRACE_SIZE (sizeof(struct ipr_trace_entry) * IPR_NUM_TRACE_ENTRIES)
  1291. char trace_start[8];
  1292. #define IPR_TRACE_START_LABEL "trace"
  1293. struct ipr_trace_entry *trace;
  1294. atomic_t trace_index;
  1295. char cfg_table_start[8];
  1296. #define IPR_CFG_TBL_START "cfg"
  1297. union {
  1298. struct ipr_config_table *cfg_table;
  1299. struct ipr_config_table64 *cfg_table64;
  1300. } u;
  1301. dma_addr_t cfg_table_dma;
  1302. u32 cfg_table_size;
  1303. u32 max_devs_supported;
  1304. char resource_table_label[8];
  1305. #define IPR_RES_TABLE_LABEL "res_tbl"
  1306. struct ipr_resource_entry *res_entries;
  1307. struct list_head free_res_q;
  1308. struct list_head used_res_q;
  1309. char ipr_hcam_label[8];
  1310. #define IPR_HCAM_LABEL "hcams"
  1311. struct ipr_hostrcb *hostrcb[IPR_NUM_HCAMS];
  1312. dma_addr_t hostrcb_dma[IPR_NUM_HCAMS];
  1313. struct list_head hostrcb_free_q;
  1314. struct list_head hostrcb_pending_q;
  1315. struct ipr_hrr_queue hrrq[IPR_MAX_HRRQ_NUM];
  1316. u32 hrrq_num;
  1317. atomic_t hrrq_index;
  1318. u16 identify_hrrq_index;
  1319. struct ipr_bus_attributes bus_attr[IPR_MAX_NUM_BUSES];
  1320. unsigned int transop_timeout;
  1321. const struct ipr_chip_cfg_t *chip_cfg;
  1322. const struct ipr_chip_t *ipr_chip;
  1323. void __iomem *hdw_dma_regs; /* iomapped PCI memory space */
  1324. unsigned long hdw_dma_regs_pci; /* raw PCI memory space */
  1325. void __iomem *ioa_mailbox;
  1326. struct ipr_interrupts regs;
  1327. u16 saved_pcix_cmd_reg;
  1328. u16 reset_retries;
  1329. u32 errors_logged;
  1330. u32 doorbell;
  1331. struct Scsi_Host *host;
  1332. struct pci_dev *pdev;
  1333. struct ipr_sglist *ucode_sglist;
  1334. u8 saved_mode_page_len;
  1335. struct work_struct work_q;
  1336. struct workqueue_struct *reset_work_q;
  1337. wait_queue_head_t reset_wait_q;
  1338. wait_queue_head_t msi_wait_q;
  1339. wait_queue_head_t eeh_wait_q;
  1340. struct ipr_dump *dump;
  1341. enum ipr_sdt_state sdt_state;
  1342. struct ipr_misc_cbs *vpd_cbs;
  1343. dma_addr_t vpd_cbs_dma;
  1344. struct dma_pool *ipr_cmd_pool;
  1345. struct ipr_cmnd *reset_cmd;
  1346. int (*reset) (struct ipr_cmnd *);
  1347. struct ata_host ata_host;
  1348. char ipr_cmd_label[8];
  1349. #define IPR_CMD_LABEL "ipr_cmd"
  1350. u32 max_cmds;
  1351. struct ipr_cmnd **ipr_cmnd_list;
  1352. dma_addr_t *ipr_cmnd_list_dma;
  1353. u16 intr_flag;
  1354. unsigned int nvectors;
  1355. struct {
  1356. unsigned short vec;
  1357. char desc[22];
  1358. } vectors_info[IPR_MAX_MSIX_VECTORS];
  1359. u32 iopoll_weight;
  1360. }; /* struct ipr_ioa_cfg */
  1361. struct ipr_cmnd {
  1362. struct ipr_ioarcb ioarcb;
  1363. union {
  1364. struct ipr_ioadl_desc ioadl[IPR_NUM_IOADL_ENTRIES];
  1365. struct ipr_ioadl64_desc ioadl64[IPR_NUM_IOADL_ENTRIES];
  1366. struct ipr_ata64_ioadl ata_ioadl;
  1367. } i;
  1368. union {
  1369. struct ipr_ioasa ioasa;
  1370. struct ipr_ioasa64 ioasa64;
  1371. } s;
  1372. struct list_head queue;
  1373. struct scsi_cmnd *scsi_cmd;
  1374. struct ata_queued_cmd *qc;
  1375. struct completion completion;
  1376. struct timer_list timer;
  1377. struct work_struct work;
  1378. void (*fast_done) (struct ipr_cmnd *);
  1379. void (*done) (struct ipr_cmnd *);
  1380. int (*job_step) (struct ipr_cmnd *);
  1381. int (*job_step_failed) (struct ipr_cmnd *);
  1382. u16 cmd_index;
  1383. u8 sense_buffer[SCSI_SENSE_BUFFERSIZE];
  1384. dma_addr_t sense_buffer_dma;
  1385. unsigned short dma_use_sg;
  1386. dma_addr_t dma_addr;
  1387. struct ipr_cmnd *sibling;
  1388. union {
  1389. enum ipr_shutdown_type shutdown_type;
  1390. struct ipr_hostrcb *hostrcb;
  1391. unsigned long time_left;
  1392. unsigned long scratch;
  1393. struct ipr_resource_entry *res;
  1394. struct scsi_device *sdev;
  1395. } u;
  1396. struct completion *eh_comp;
  1397. struct ipr_hrr_queue *hrrq;
  1398. struct ipr_ioa_cfg *ioa_cfg;
  1399. };
  1400. struct ipr_ses_table_entry {
  1401. char product_id[17];
  1402. char compare_product_id_byte[17];
  1403. u32 max_bus_speed_limit; /* MB/sec limit for this backplane */
  1404. };
  1405. struct ipr_dump_header {
  1406. u32 eye_catcher;
  1407. #define IPR_DUMP_EYE_CATCHER 0xC5D4E3F2
  1408. u32 len;
  1409. u32 num_entries;
  1410. u32 first_entry_offset;
  1411. u32 status;
  1412. #define IPR_DUMP_STATUS_SUCCESS 0
  1413. #define IPR_DUMP_STATUS_QUAL_SUCCESS 2
  1414. #define IPR_DUMP_STATUS_FAILED 0xffffffff
  1415. u32 os;
  1416. #define IPR_DUMP_OS_LINUX 0x4C4E5558
  1417. u32 driver_name;
  1418. #define IPR_DUMP_DRIVER_NAME 0x49505232
  1419. }__attribute__((packed, aligned (4)));
  1420. struct ipr_dump_entry_header {
  1421. u32 eye_catcher;
  1422. #define IPR_DUMP_EYE_CATCHER 0xC5D4E3F2
  1423. u32 len;
  1424. u32 num_elems;
  1425. u32 offset;
  1426. u32 data_type;
  1427. #define IPR_DUMP_DATA_TYPE_ASCII 0x41534349
  1428. #define IPR_DUMP_DATA_TYPE_BINARY 0x42494E41
  1429. u32 id;
  1430. #define IPR_DUMP_IOA_DUMP_ID 0x494F4131
  1431. #define IPR_DUMP_LOCATION_ID 0x4C4F4341
  1432. #define IPR_DUMP_TRACE_ID 0x54524143
  1433. #define IPR_DUMP_DRIVER_VERSION_ID 0x44525652
  1434. #define IPR_DUMP_DRIVER_TYPE_ID 0x54595045
  1435. #define IPR_DUMP_IOA_CTRL_BLK 0x494F4342
  1436. #define IPR_DUMP_PEND_OPS 0x414F5053
  1437. u32 status;
  1438. }__attribute__((packed, aligned (4)));
  1439. struct ipr_dump_location_entry {
  1440. struct ipr_dump_entry_header hdr;
  1441. u8 location[20];
  1442. }__attribute__((packed));
  1443. struct ipr_dump_trace_entry {
  1444. struct ipr_dump_entry_header hdr;
  1445. u32 trace[IPR_TRACE_SIZE / sizeof(u32)];
  1446. }__attribute__((packed, aligned (4)));
  1447. struct ipr_dump_version_entry {
  1448. struct ipr_dump_entry_header hdr;
  1449. u8 version[sizeof(IPR_DRIVER_VERSION)];
  1450. };
  1451. struct ipr_dump_ioa_type_entry {
  1452. struct ipr_dump_entry_header hdr;
  1453. u32 type;
  1454. u32 fw_version;
  1455. };
  1456. struct ipr_driver_dump {
  1457. struct ipr_dump_header hdr;
  1458. struct ipr_dump_version_entry version_entry;
  1459. struct ipr_dump_location_entry location_entry;
  1460. struct ipr_dump_ioa_type_entry ioa_type_entry;
  1461. struct ipr_dump_trace_entry trace_entry;
  1462. }__attribute__((packed));
  1463. struct ipr_ioa_dump {
  1464. struct ipr_dump_entry_header hdr;
  1465. struct ipr_sdt sdt;
  1466. __be32 **ioa_data;
  1467. u32 reserved;
  1468. u32 next_page_index;
  1469. u32 page_offset;
  1470. u32 format;
  1471. }__attribute__((packed, aligned (4)));
  1472. struct ipr_dump {
  1473. struct kref kref;
  1474. struct ipr_ioa_cfg *ioa_cfg;
  1475. struct ipr_driver_dump driver_dump;
  1476. struct ipr_ioa_dump ioa_dump;
  1477. };
  1478. struct ipr_error_table_t {
  1479. u32 ioasc;
  1480. int log_ioasa;
  1481. int log_hcam;
  1482. char *error;
  1483. };
  1484. struct ipr_software_inq_lid_info {
  1485. __be32 load_id;
  1486. __be32 timestamp[3];
  1487. }__attribute__((packed, aligned (4)));
  1488. struct ipr_ucode_image_header {
  1489. __be32 header_length;
  1490. __be32 lid_table_offset;
  1491. u8 major_release;
  1492. u8 card_type;
  1493. u8 minor_release[2];
  1494. u8 reserved[20];
  1495. char eyecatcher[16];
  1496. __be32 num_lids;
  1497. struct ipr_software_inq_lid_info lid[1];
  1498. }__attribute__((packed, aligned (4)));
  1499. /*
  1500. * Macros
  1501. */
  1502. #define IPR_DBG_CMD(CMD) if (ipr_debug) { CMD; }
  1503. #ifdef CONFIG_SCSI_IPR_TRACE
  1504. #define ipr_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
  1505. #define ipr_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
  1506. #else
  1507. #define ipr_create_trace_file(kobj, attr) 0
  1508. #define ipr_remove_trace_file(kobj, attr) do { } while(0)
  1509. #endif
  1510. #ifdef CONFIG_SCSI_IPR_DUMP
  1511. #define ipr_create_dump_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
  1512. #define ipr_remove_dump_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
  1513. #else
  1514. #define ipr_create_dump_file(kobj, attr) 0
  1515. #define ipr_remove_dump_file(kobj, attr) do { } while(0)
  1516. #endif
  1517. /*
  1518. * Error logging macros
  1519. */
  1520. #define ipr_err(...) printk(KERN_ERR IPR_NAME ": "__VA_ARGS__)
  1521. #define ipr_info(...) printk(KERN_INFO IPR_NAME ": "__VA_ARGS__)
  1522. #define ipr_dbg(...) IPR_DBG_CMD(printk(KERN_INFO IPR_NAME ": "__VA_ARGS__))
  1523. #define ipr_res_printk(level, ioa_cfg, bus, target, lun, fmt, ...) \
  1524. printk(level IPR_NAME ": %d:%d:%d:%d: " fmt, (ioa_cfg)->host->host_no, \
  1525. bus, target, lun, ##__VA_ARGS__)
  1526. #define ipr_res_err(ioa_cfg, res, fmt, ...) \
  1527. ipr_res_printk(KERN_ERR, ioa_cfg, (res)->bus, (res)->target, (res)->lun, fmt, ##__VA_ARGS__)
  1528. #define ipr_ra_printk(level, ioa_cfg, ra, fmt, ...) \
  1529. printk(level IPR_NAME ": %d:%d:%d:%d: " fmt, (ioa_cfg)->host->host_no, \
  1530. (ra).bus, (ra).target, (ra).lun, ##__VA_ARGS__)
  1531. #define ipr_ra_err(ioa_cfg, ra, fmt, ...) \
  1532. ipr_ra_printk(KERN_ERR, ioa_cfg, ra, fmt, ##__VA_ARGS__)
  1533. #define ipr_phys_res_err(ioa_cfg, res, fmt, ...) \
  1534. { \
  1535. if ((res).bus >= IPR_MAX_NUM_BUSES) { \
  1536. ipr_err(fmt": unknown\n", ##__VA_ARGS__); \
  1537. } else { \
  1538. ipr_err(fmt": %d:%d:%d:%d\n", \
  1539. ##__VA_ARGS__, (ioa_cfg)->host->host_no, \
  1540. (res).bus, (res).target, (res).lun); \
  1541. } \
  1542. }
  1543. #define ipr_hcam_err(hostrcb, fmt, ...) \
  1544. { \
  1545. if (ipr_is_device(hostrcb)) { \
  1546. if ((hostrcb)->ioa_cfg->sis64) { \
  1547. printk(KERN_ERR IPR_NAME ": %s: " fmt, \
  1548. ipr_format_res_path(hostrcb->ioa_cfg, \
  1549. hostrcb->hcam.u.error64.fd_res_path, \
  1550. hostrcb->rp_buffer, \
  1551. sizeof(hostrcb->rp_buffer)), \
  1552. __VA_ARGS__); \
  1553. } else { \
  1554. ipr_ra_err((hostrcb)->ioa_cfg, \
  1555. (hostrcb)->hcam.u.error.fd_res_addr, \
  1556. fmt, __VA_ARGS__); \
  1557. } \
  1558. } else { \
  1559. dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, __VA_ARGS__); \
  1560. } \
  1561. }
  1562. #define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
  1563. __FILE__, __func__, __LINE__)
  1564. #define ENTER IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Entering %s\n", __func__))
  1565. #define LEAVE IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Leaving %s\n", __func__))
  1566. #define ipr_err_separator \
  1567. ipr_err("----------------------------------------------------------\n")
  1568. /*
  1569. * Inlines
  1570. */
  1571. /**
  1572. * ipr_is_ioa_resource - Determine if a resource is the IOA
  1573. * @res: resource entry struct
  1574. *
  1575. * Return value:
  1576. * 1 if IOA / 0 if not IOA
  1577. **/
  1578. static inline int ipr_is_ioa_resource(struct ipr_resource_entry *res)
  1579. {
  1580. return res->type == IPR_RES_TYPE_IOAFP;
  1581. }
  1582. /**
  1583. * ipr_is_af_dasd_device - Determine if a resource is an AF DASD
  1584. * @res: resource entry struct
  1585. *
  1586. * Return value:
  1587. * 1 if AF DASD / 0 if not AF DASD
  1588. **/
  1589. static inline int ipr_is_af_dasd_device(struct ipr_resource_entry *res)
  1590. {
  1591. return res->type == IPR_RES_TYPE_AF_DASD ||
  1592. res->type == IPR_RES_TYPE_REMOTE_AF_DASD;
  1593. }
  1594. /**
  1595. * ipr_is_vset_device - Determine if a resource is a VSET
  1596. * @res: resource entry struct
  1597. *
  1598. * Return value:
  1599. * 1 if VSET / 0 if not VSET
  1600. **/
  1601. static inline int ipr_is_vset_device(struct ipr_resource_entry *res)
  1602. {
  1603. return res->type == IPR_RES_TYPE_VOLUME_SET;
  1604. }
  1605. /**
  1606. * ipr_is_gscsi - Determine if a resource is a generic scsi resource
  1607. * @res: resource entry struct
  1608. *
  1609. * Return value:
  1610. * 1 if GSCSI / 0 if not GSCSI
  1611. **/
  1612. static inline int ipr_is_gscsi(struct ipr_resource_entry *res)
  1613. {
  1614. return res->type == IPR_RES_TYPE_GENERIC_SCSI;
  1615. }
  1616. /**
  1617. * ipr_is_scsi_disk - Determine if a resource is a SCSI disk
  1618. * @res: resource entry struct
  1619. *
  1620. * Return value:
  1621. * 1 if SCSI disk / 0 if not SCSI disk
  1622. **/
  1623. static inline int ipr_is_scsi_disk(struct ipr_resource_entry *res)
  1624. {
  1625. if (ipr_is_af_dasd_device(res) ||
  1626. (ipr_is_gscsi(res) && IPR_IS_DASD_DEVICE(res->std_inq_data)))
  1627. return 1;
  1628. else
  1629. return 0;
  1630. }
  1631. /**
  1632. * ipr_is_gata - Determine if a resource is a generic ATA resource
  1633. * @res: resource entry struct
  1634. *
  1635. * Return value:
  1636. * 1 if GATA / 0 if not GATA
  1637. **/
  1638. static inline int ipr_is_gata(struct ipr_resource_entry *res)
  1639. {
  1640. return res->type == IPR_RES_TYPE_GENERIC_ATA;
  1641. }
  1642. /**
  1643. * ipr_is_naca_model - Determine if a resource is using NACA queueing model
  1644. * @res: resource entry struct
  1645. *
  1646. * Return value:
  1647. * 1 if NACA queueing model / 0 if not NACA queueing model
  1648. **/
  1649. static inline int ipr_is_naca_model(struct ipr_resource_entry *res)
  1650. {
  1651. if (ipr_is_gscsi(res) && res->qmodel == IPR_QUEUE_NACA_MODEL)
  1652. return 1;
  1653. return 0;
  1654. }
  1655. /**
  1656. * ipr_is_device - Determine if the hostrcb structure is related to a device
  1657. * @hostrcb: host resource control blocks struct
  1658. *
  1659. * Return value:
  1660. * 1 if AF / 0 if not AF
  1661. **/
  1662. static inline int ipr_is_device(struct ipr_hostrcb *hostrcb)
  1663. {
  1664. struct ipr_res_addr *res_addr;
  1665. u8 *res_path;
  1666. if (hostrcb->ioa_cfg->sis64) {
  1667. res_path = &hostrcb->hcam.u.error64.fd_res_path[0];
  1668. if ((res_path[0] == 0x00 || res_path[0] == 0x80 ||
  1669. res_path[0] == 0x81) && res_path[2] != 0xFF)
  1670. return 1;
  1671. } else {
  1672. res_addr = &hostrcb->hcam.u.error.fd_res_addr;
  1673. if ((res_addr->bus < IPR_MAX_NUM_BUSES) &&
  1674. (res_addr->target < (IPR_MAX_NUM_TARGETS_PER_BUS - 1)))
  1675. return 1;
  1676. }
  1677. return 0;
  1678. }
  1679. /**
  1680. * ipr_sdt_is_fmt2 - Determine if a SDT address is in format 2
  1681. * @sdt_word: SDT address
  1682. *
  1683. * Return value:
  1684. * 1 if format 2 / 0 if not
  1685. **/
  1686. static inline int ipr_sdt_is_fmt2(u32 sdt_word)
  1687. {
  1688. u32 bar_sel = IPR_GET_FMT2_BAR_SEL(sdt_word);
  1689. switch (bar_sel) {
  1690. case IPR_SDT_FMT2_BAR0_SEL:
  1691. case IPR_SDT_FMT2_BAR1_SEL:
  1692. case IPR_SDT_FMT2_BAR2_SEL:
  1693. case IPR_SDT_FMT2_BAR3_SEL:
  1694. case IPR_SDT_FMT2_BAR4_SEL:
  1695. case IPR_SDT_FMT2_BAR5_SEL:
  1696. case IPR_SDT_FMT2_EXP_ROM_SEL:
  1697. return 1;
  1698. };
  1699. return 0;
  1700. }
  1701. #ifndef writeq
  1702. static inline void writeq(u64 val, void __iomem *addr)
  1703. {
  1704. writel(((u32) (val >> 32)), addr);
  1705. writel(((u32) (val)), (addr + 4));
  1706. }
  1707. #endif
  1708. #endif /* _IPR_H */