ipr.h 51 KB

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