ipr.h 51 KB

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