ipr.h 48 KB

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