qla_dbg.c 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2014 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. /*
  8. * Table for showing the current message id in use for particular level
  9. * Change this table for addition of log/debug messages.
  10. * ----------------------------------------------------------------------
  11. * | Level | Last Value Used | Holes |
  12. * ----------------------------------------------------------------------
  13. * | Module Init and Probe | 0x0191 | 0x0146 |
  14. * | | | 0x015b-0x0160 |
  15. * | | | 0x016e |
  16. * | Mailbox commands | 0x1199 | 0x1193 |
  17. * | Device Discovery | 0x2004 | 0x2016 |
  18. * | | | 0x2011-0x2012, |
  19. * | | | 0x2099-0x20a4 |
  20. * | Queue Command and IO tracing | 0x3074 | 0x300b |
  21. * | | | 0x3027-0x3028 |
  22. * | | | 0x303d-0x3041 |
  23. * | | | 0x302d,0x3033 |
  24. * | | | 0x3036,0x3038 |
  25. * | | | 0x303a |
  26. * | DPC Thread | 0x4023 | 0x4002,0x4013 |
  27. * | Async Events | 0x5090 | 0x502b-0x502f |
  28. * | | | 0x5047 |
  29. * | | | 0x5084,0x5075 |
  30. * | | | 0x503d,0x5044 |
  31. * | | | 0x505f |
  32. * | Timer Routines | 0x6012 | |
  33. * | User Space Interactions | 0x70e3 | 0x7018,0x702e |
  34. * | | | 0x7020,0x7024 |
  35. * | | | 0x7039,0x7045 |
  36. * | | | 0x7073-0x7075 |
  37. * | | | 0x70a5-0x70a6 |
  38. * | | | 0x70a8,0x70ab |
  39. * | | | 0x70ad-0x70ae |
  40. * | | | 0x70d0-0x70d6 |
  41. * | | | 0x70d7-0x70db |
  42. * | Task Management | 0x8042 | 0x8000,0x800b |
  43. * | | | 0x8019 |
  44. * | | | 0x8025,0x8026 |
  45. * | | | 0x8031,0x8032 |
  46. * | | | 0x8039,0x803c |
  47. * | AER/EEH | 0x9011 | |
  48. * | Virtual Port | 0xa007 | |
  49. * | ISP82XX Specific | 0xb157 | 0xb002,0xb024 |
  50. * | | | 0xb09e,0xb0ae |
  51. * | | | 0xb0c3,0xb0c6 |
  52. * | | | 0xb0e0-0xb0ef |
  53. * | | | 0xb085,0xb0dc |
  54. * | | | 0xb107,0xb108 |
  55. * | | | 0xb111,0xb11e |
  56. * | | | 0xb12c,0xb12d |
  57. * | | | 0xb13a,0xb142 |
  58. * | | | 0xb13c-0xb140 |
  59. * | | | 0xb149 |
  60. * | MultiQ | 0xc00c | |
  61. * | Misc | 0xd301 | 0xd031-0xd0ff |
  62. * | | | 0xd101-0xd1fe |
  63. * | | | 0xd214-0xd2fe |
  64. * | Target Mode | 0xe080 | |
  65. * | Target Mode Management | 0xf09b | 0xf002 |
  66. * | | | 0xf046-0xf049 |
  67. * | Target Mode Task Management | 0x1000d | |
  68. * ----------------------------------------------------------------------
  69. */
  70. #include "qla_def.h"
  71. #include <linux/delay.h>
  72. static uint32_t ql_dbg_offset = 0x800;
  73. static inline void
  74. qla2xxx_prep_dump(struct qla_hw_data *ha, struct qla2xxx_fw_dump *fw_dump)
  75. {
  76. fw_dump->fw_major_version = htonl(ha->fw_major_version);
  77. fw_dump->fw_minor_version = htonl(ha->fw_minor_version);
  78. fw_dump->fw_subminor_version = htonl(ha->fw_subminor_version);
  79. fw_dump->fw_attributes = htonl(ha->fw_attributes);
  80. fw_dump->vendor = htonl(ha->pdev->vendor);
  81. fw_dump->device = htonl(ha->pdev->device);
  82. fw_dump->subsystem_vendor = htonl(ha->pdev->subsystem_vendor);
  83. fw_dump->subsystem_device = htonl(ha->pdev->subsystem_device);
  84. }
  85. static inline void *
  86. qla2xxx_copy_queues(struct qla_hw_data *ha, void *ptr)
  87. {
  88. struct req_que *req = ha->req_q_map[0];
  89. struct rsp_que *rsp = ha->rsp_q_map[0];
  90. /* Request queue. */
  91. memcpy(ptr, req->ring, req->length *
  92. sizeof(request_t));
  93. /* Response queue. */
  94. ptr += req->length * sizeof(request_t);
  95. memcpy(ptr, rsp->ring, rsp->length *
  96. sizeof(response_t));
  97. return ptr + (rsp->length * sizeof(response_t));
  98. }
  99. int
  100. qla27xx_dump_mpi_ram(struct qla_hw_data *ha, uint32_t addr, uint32_t *ram,
  101. uint32_t ram_dwords, void **nxt)
  102. {
  103. int rval;
  104. uint32_t cnt, stat, timer, dwords, idx;
  105. uint16_t mb0;
  106. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  107. dma_addr_t dump_dma = ha->gid_list_dma;
  108. uint32_t *dump = (uint32_t *)ha->gid_list;
  109. rval = QLA_SUCCESS;
  110. mb0 = 0;
  111. WRT_REG_WORD(&reg->mailbox0, MBC_LOAD_DUMP_MPI_RAM);
  112. clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
  113. dwords = qla2x00_gid_list_size(ha) / 4;
  114. for (cnt = 0; cnt < ram_dwords && rval == QLA_SUCCESS;
  115. cnt += dwords, addr += dwords) {
  116. if (cnt + dwords > ram_dwords)
  117. dwords = ram_dwords - cnt;
  118. WRT_REG_WORD(&reg->mailbox1, LSW(addr));
  119. WRT_REG_WORD(&reg->mailbox8, MSW(addr));
  120. WRT_REG_WORD(&reg->mailbox2, MSW(dump_dma));
  121. WRT_REG_WORD(&reg->mailbox3, LSW(dump_dma));
  122. WRT_REG_WORD(&reg->mailbox6, MSW(MSD(dump_dma)));
  123. WRT_REG_WORD(&reg->mailbox7, LSW(MSD(dump_dma)));
  124. WRT_REG_WORD(&reg->mailbox4, MSW(dwords));
  125. WRT_REG_WORD(&reg->mailbox5, LSW(dwords));
  126. WRT_REG_WORD(&reg->mailbox9, 0);
  127. WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
  128. ha->flags.mbox_int = 0;
  129. for (timer = 6000000; timer; timer--) {
  130. /* Check for pending interrupts. */
  131. stat = RD_REG_DWORD(&reg->host_status);
  132. if (stat & HSRX_RISC_INT) {
  133. stat &= 0xff;
  134. if (stat == 0x1 || stat == 0x2 ||
  135. stat == 0x10 || stat == 0x11) {
  136. set_bit(MBX_INTERRUPT,
  137. &ha->mbx_cmd_flags);
  138. mb0 = RD_REG_WORD(&reg->mailbox0);
  139. RD_REG_WORD(&reg->mailbox1);
  140. WRT_REG_DWORD(&reg->hccr,
  141. HCCRX_CLR_RISC_INT);
  142. RD_REG_DWORD(&reg->hccr);
  143. break;
  144. }
  145. /* Clear this intr; it wasn't a mailbox intr */
  146. WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
  147. RD_REG_DWORD(&reg->hccr);
  148. }
  149. udelay(5);
  150. }
  151. ha->flags.mbox_int = 1;
  152. if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
  153. rval = mb0 & MBS_MASK;
  154. for (idx = 0; idx < dwords; idx++)
  155. ram[cnt + idx] = IS_QLA27XX(ha) ?
  156. le32_to_cpu(dump[idx]) : swab32(dump[idx]);
  157. } else {
  158. rval = QLA_FUNCTION_FAILED;
  159. }
  160. }
  161. *nxt = rval == QLA_SUCCESS ? &ram[cnt] : NULL;
  162. return rval;
  163. }
  164. int
  165. qla24xx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint32_t *ram,
  166. uint32_t ram_dwords, void **nxt)
  167. {
  168. int rval;
  169. uint32_t cnt, stat, timer, dwords, idx;
  170. uint16_t mb0;
  171. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  172. dma_addr_t dump_dma = ha->gid_list_dma;
  173. uint32_t *dump = (uint32_t *)ha->gid_list;
  174. rval = QLA_SUCCESS;
  175. mb0 = 0;
  176. WRT_REG_WORD(&reg->mailbox0, MBC_DUMP_RISC_RAM_EXTENDED);
  177. clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
  178. dwords = qla2x00_gid_list_size(ha) / 4;
  179. for (cnt = 0; cnt < ram_dwords && rval == QLA_SUCCESS;
  180. cnt += dwords, addr += dwords) {
  181. if (cnt + dwords > ram_dwords)
  182. dwords = ram_dwords - cnt;
  183. WRT_REG_WORD(&reg->mailbox1, LSW(addr));
  184. WRT_REG_WORD(&reg->mailbox8, MSW(addr));
  185. WRT_REG_WORD(&reg->mailbox2, MSW(dump_dma));
  186. WRT_REG_WORD(&reg->mailbox3, LSW(dump_dma));
  187. WRT_REG_WORD(&reg->mailbox6, MSW(MSD(dump_dma)));
  188. WRT_REG_WORD(&reg->mailbox7, LSW(MSD(dump_dma)));
  189. WRT_REG_WORD(&reg->mailbox4, MSW(dwords));
  190. WRT_REG_WORD(&reg->mailbox5, LSW(dwords));
  191. WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
  192. ha->flags.mbox_int = 0;
  193. for (timer = 6000000; timer; timer--) {
  194. /* Check for pending interrupts. */
  195. stat = RD_REG_DWORD(&reg->host_status);
  196. if (stat & HSRX_RISC_INT) {
  197. stat &= 0xff;
  198. if (stat == 0x1 || stat == 0x2 ||
  199. stat == 0x10 || stat == 0x11) {
  200. set_bit(MBX_INTERRUPT,
  201. &ha->mbx_cmd_flags);
  202. mb0 = RD_REG_WORD(&reg->mailbox0);
  203. WRT_REG_DWORD(&reg->hccr,
  204. HCCRX_CLR_RISC_INT);
  205. RD_REG_DWORD(&reg->hccr);
  206. break;
  207. }
  208. /* Clear this intr; it wasn't a mailbox intr */
  209. WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
  210. RD_REG_DWORD(&reg->hccr);
  211. }
  212. udelay(5);
  213. }
  214. ha->flags.mbox_int = 1;
  215. if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
  216. rval = mb0 & MBS_MASK;
  217. for (idx = 0; idx < dwords; idx++)
  218. ram[cnt + idx] = IS_QLA27XX(ha) ?
  219. le32_to_cpu(dump[idx]) : swab32(dump[idx]);
  220. } else {
  221. rval = QLA_FUNCTION_FAILED;
  222. }
  223. }
  224. *nxt = rval == QLA_SUCCESS ? &ram[cnt]: NULL;
  225. return rval;
  226. }
  227. static int
  228. qla24xx_dump_memory(struct qla_hw_data *ha, uint32_t *code_ram,
  229. uint32_t cram_size, void **nxt)
  230. {
  231. int rval;
  232. /* Code RAM. */
  233. rval = qla24xx_dump_ram(ha, 0x20000, code_ram, cram_size / 4, nxt);
  234. if (rval != QLA_SUCCESS)
  235. return rval;
  236. set_bit(RISC_SRAM_DUMP_CMPL, &ha->fw_dump_cap_flags);
  237. /* External Memory. */
  238. rval = qla24xx_dump_ram(ha, 0x100000, *nxt,
  239. ha->fw_memory_size - 0x100000 + 1, nxt);
  240. if (rval == QLA_SUCCESS)
  241. set_bit(RISC_EXT_MEM_DUMP_CMPL, &ha->fw_dump_cap_flags);
  242. return rval;
  243. }
  244. static uint32_t *
  245. qla24xx_read_window(struct device_reg_24xx __iomem *reg, uint32_t iobase,
  246. uint32_t count, uint32_t *buf)
  247. {
  248. uint32_t __iomem *dmp_reg;
  249. WRT_REG_DWORD(&reg->iobase_addr, iobase);
  250. dmp_reg = &reg->iobase_window;
  251. for ( ; count--; dmp_reg++)
  252. *buf++ = htonl(RD_REG_DWORD(dmp_reg));
  253. return buf;
  254. }
  255. void
  256. qla24xx_pause_risc(struct device_reg_24xx __iomem *reg, struct qla_hw_data *ha)
  257. {
  258. WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_PAUSE);
  259. /* 100 usec delay is sufficient enough for hardware to pause RISC */
  260. udelay(100);
  261. if (RD_REG_DWORD(&reg->host_status) & HSRX_RISC_PAUSED)
  262. set_bit(RISC_PAUSE_CMPL, &ha->fw_dump_cap_flags);
  263. }
  264. int
  265. qla24xx_soft_reset(struct qla_hw_data *ha)
  266. {
  267. int rval = QLA_SUCCESS;
  268. uint32_t cnt;
  269. uint16_t wd;
  270. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  271. /*
  272. * Reset RISC. The delay is dependent on system architecture.
  273. * Driver can proceed with the reset sequence after waiting
  274. * for a timeout period.
  275. */
  276. WRT_REG_DWORD(&reg->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
  277. for (cnt = 0; cnt < 30000; cnt++) {
  278. if ((RD_REG_DWORD(&reg->ctrl_status) & CSRX_DMA_ACTIVE) == 0)
  279. break;
  280. udelay(10);
  281. }
  282. if (!(RD_REG_DWORD(&reg->ctrl_status) & CSRX_DMA_ACTIVE))
  283. set_bit(DMA_SHUTDOWN_CMPL, &ha->fw_dump_cap_flags);
  284. WRT_REG_DWORD(&reg->ctrl_status,
  285. CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
  286. pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
  287. udelay(100);
  288. /* Wait for soft-reset to complete. */
  289. for (cnt = 0; cnt < 30000; cnt++) {
  290. if ((RD_REG_DWORD(&reg->ctrl_status) &
  291. CSRX_ISP_SOFT_RESET) == 0)
  292. break;
  293. udelay(10);
  294. }
  295. if (!(RD_REG_DWORD(&reg->ctrl_status) & CSRX_ISP_SOFT_RESET))
  296. set_bit(ISP_RESET_CMPL, &ha->fw_dump_cap_flags);
  297. WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_RESET);
  298. RD_REG_DWORD(&reg->hccr); /* PCI Posting. */
  299. for (cnt = 10000; RD_REG_WORD(&reg->mailbox0) != 0 &&
  300. rval == QLA_SUCCESS; cnt--) {
  301. if (cnt)
  302. udelay(10);
  303. else
  304. rval = QLA_FUNCTION_TIMEOUT;
  305. }
  306. if (rval == QLA_SUCCESS)
  307. set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags);
  308. return rval;
  309. }
  310. static int
  311. qla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint16_t *ram,
  312. uint32_t ram_words, void **nxt)
  313. {
  314. int rval;
  315. uint32_t cnt, stat, timer, words, idx;
  316. uint16_t mb0;
  317. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  318. dma_addr_t dump_dma = ha->gid_list_dma;
  319. uint16_t *dump = (uint16_t *)ha->gid_list;
  320. rval = QLA_SUCCESS;
  321. mb0 = 0;
  322. WRT_MAILBOX_REG(ha, reg, 0, MBC_DUMP_RISC_RAM_EXTENDED);
  323. clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
  324. words = qla2x00_gid_list_size(ha) / 2;
  325. for (cnt = 0; cnt < ram_words && rval == QLA_SUCCESS;
  326. cnt += words, addr += words) {
  327. if (cnt + words > ram_words)
  328. words = ram_words - cnt;
  329. WRT_MAILBOX_REG(ha, reg, 1, LSW(addr));
  330. WRT_MAILBOX_REG(ha, reg, 8, MSW(addr));
  331. WRT_MAILBOX_REG(ha, reg, 2, MSW(dump_dma));
  332. WRT_MAILBOX_REG(ha, reg, 3, LSW(dump_dma));
  333. WRT_MAILBOX_REG(ha, reg, 6, MSW(MSD(dump_dma)));
  334. WRT_MAILBOX_REG(ha, reg, 7, LSW(MSD(dump_dma)));
  335. WRT_MAILBOX_REG(ha, reg, 4, words);
  336. WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
  337. for (timer = 6000000; timer; timer--) {
  338. /* Check for pending interrupts. */
  339. stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
  340. if (stat & HSR_RISC_INT) {
  341. stat &= 0xff;
  342. if (stat == 0x1 || stat == 0x2) {
  343. set_bit(MBX_INTERRUPT,
  344. &ha->mbx_cmd_flags);
  345. mb0 = RD_MAILBOX_REG(ha, reg, 0);
  346. /* Release mailbox registers. */
  347. WRT_REG_WORD(&reg->semaphore, 0);
  348. WRT_REG_WORD(&reg->hccr,
  349. HCCR_CLR_RISC_INT);
  350. RD_REG_WORD(&reg->hccr);
  351. break;
  352. } else if (stat == 0x10 || stat == 0x11) {
  353. set_bit(MBX_INTERRUPT,
  354. &ha->mbx_cmd_flags);
  355. mb0 = RD_MAILBOX_REG(ha, reg, 0);
  356. WRT_REG_WORD(&reg->hccr,
  357. HCCR_CLR_RISC_INT);
  358. RD_REG_WORD(&reg->hccr);
  359. break;
  360. }
  361. /* clear this intr; it wasn't a mailbox intr */
  362. WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
  363. RD_REG_WORD(&reg->hccr);
  364. }
  365. udelay(5);
  366. }
  367. if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
  368. rval = mb0 & MBS_MASK;
  369. for (idx = 0; idx < words; idx++)
  370. ram[cnt + idx] = swab16(dump[idx]);
  371. } else {
  372. rval = QLA_FUNCTION_FAILED;
  373. }
  374. }
  375. *nxt = rval == QLA_SUCCESS ? &ram[cnt]: NULL;
  376. return rval;
  377. }
  378. static inline void
  379. qla2xxx_read_window(struct device_reg_2xxx __iomem *reg, uint32_t count,
  380. uint16_t *buf)
  381. {
  382. uint16_t __iomem *dmp_reg = &reg->u.isp2300.fb_cmd;
  383. for ( ; count--; dmp_reg++)
  384. *buf++ = htons(RD_REG_WORD(dmp_reg));
  385. }
  386. static inline void *
  387. qla24xx_copy_eft(struct qla_hw_data *ha, void *ptr)
  388. {
  389. if (!ha->eft)
  390. return ptr;
  391. memcpy(ptr, ha->eft, ntohl(ha->fw_dump->eft_size));
  392. return ptr + ntohl(ha->fw_dump->eft_size);
  393. }
  394. static inline void *
  395. qla25xx_copy_fce(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
  396. {
  397. uint32_t cnt;
  398. uint32_t *iter_reg;
  399. struct qla2xxx_fce_chain *fcec = ptr;
  400. if (!ha->fce)
  401. return ptr;
  402. *last_chain = &fcec->type;
  403. fcec->type = htonl(DUMP_CHAIN_FCE);
  404. fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
  405. fce_calc_size(ha->fce_bufs));
  406. fcec->size = htonl(fce_calc_size(ha->fce_bufs));
  407. fcec->addr_l = htonl(LSD(ha->fce_dma));
  408. fcec->addr_h = htonl(MSD(ha->fce_dma));
  409. iter_reg = fcec->eregs;
  410. for (cnt = 0; cnt < 8; cnt++)
  411. *iter_reg++ = htonl(ha->fce_mb[cnt]);
  412. memcpy(iter_reg, ha->fce, ntohl(fcec->size));
  413. return (char *)iter_reg + ntohl(fcec->size);
  414. }
  415. static inline void *
  416. qla2xxx_copy_atioqueues(struct qla_hw_data *ha, void *ptr,
  417. uint32_t **last_chain)
  418. {
  419. struct qla2xxx_mqueue_chain *q;
  420. struct qla2xxx_mqueue_header *qh;
  421. uint32_t num_queues;
  422. int que;
  423. struct {
  424. int length;
  425. void *ring;
  426. } aq, *aqp;
  427. if (!ha->tgt.atio_ring)
  428. return ptr;
  429. num_queues = 1;
  430. aqp = &aq;
  431. aqp->length = ha->tgt.atio_q_length;
  432. aqp->ring = ha->tgt.atio_ring;
  433. for (que = 0; que < num_queues; que++) {
  434. /* aqp = ha->atio_q_map[que]; */
  435. q = ptr;
  436. *last_chain = &q->type;
  437. q->type = htonl(DUMP_CHAIN_QUEUE);
  438. q->chain_size = htonl(
  439. sizeof(struct qla2xxx_mqueue_chain) +
  440. sizeof(struct qla2xxx_mqueue_header) +
  441. (aqp->length * sizeof(request_t)));
  442. ptr += sizeof(struct qla2xxx_mqueue_chain);
  443. /* Add header. */
  444. qh = ptr;
  445. qh->queue = htonl(TYPE_ATIO_QUEUE);
  446. qh->number = htonl(que);
  447. qh->size = htonl(aqp->length * sizeof(request_t));
  448. ptr += sizeof(struct qla2xxx_mqueue_header);
  449. /* Add data. */
  450. memcpy(ptr, aqp->ring, aqp->length * sizeof(request_t));
  451. ptr += aqp->length * sizeof(request_t);
  452. }
  453. return ptr;
  454. }
  455. static inline void *
  456. qla25xx_copy_mqueues(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
  457. {
  458. struct qla2xxx_mqueue_chain *q;
  459. struct qla2xxx_mqueue_header *qh;
  460. struct req_que *req;
  461. struct rsp_que *rsp;
  462. int que;
  463. if (!ha->mqenable)
  464. return ptr;
  465. /* Request queues */
  466. for (que = 1; que < ha->max_req_queues; que++) {
  467. req = ha->req_q_map[que];
  468. if (!req)
  469. break;
  470. /* Add chain. */
  471. q = ptr;
  472. *last_chain = &q->type;
  473. q->type = htonl(DUMP_CHAIN_QUEUE);
  474. q->chain_size = htonl(
  475. sizeof(struct qla2xxx_mqueue_chain) +
  476. sizeof(struct qla2xxx_mqueue_header) +
  477. (req->length * sizeof(request_t)));
  478. ptr += sizeof(struct qla2xxx_mqueue_chain);
  479. /* Add header. */
  480. qh = ptr;
  481. qh->queue = htonl(TYPE_REQUEST_QUEUE);
  482. qh->number = htonl(que);
  483. qh->size = htonl(req->length * sizeof(request_t));
  484. ptr += sizeof(struct qla2xxx_mqueue_header);
  485. /* Add data. */
  486. memcpy(ptr, req->ring, req->length * sizeof(request_t));
  487. ptr += req->length * sizeof(request_t);
  488. }
  489. /* Response queues */
  490. for (que = 1; que < ha->max_rsp_queues; que++) {
  491. rsp = ha->rsp_q_map[que];
  492. if (!rsp)
  493. break;
  494. /* Add chain. */
  495. q = ptr;
  496. *last_chain = &q->type;
  497. q->type = htonl(DUMP_CHAIN_QUEUE);
  498. q->chain_size = htonl(
  499. sizeof(struct qla2xxx_mqueue_chain) +
  500. sizeof(struct qla2xxx_mqueue_header) +
  501. (rsp->length * sizeof(response_t)));
  502. ptr += sizeof(struct qla2xxx_mqueue_chain);
  503. /* Add header. */
  504. qh = ptr;
  505. qh->queue = htonl(TYPE_RESPONSE_QUEUE);
  506. qh->number = htonl(que);
  507. qh->size = htonl(rsp->length * sizeof(response_t));
  508. ptr += sizeof(struct qla2xxx_mqueue_header);
  509. /* Add data. */
  510. memcpy(ptr, rsp->ring, rsp->length * sizeof(response_t));
  511. ptr += rsp->length * sizeof(response_t);
  512. }
  513. return ptr;
  514. }
  515. static inline void *
  516. qla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
  517. {
  518. uint32_t cnt, que_idx;
  519. uint8_t que_cnt;
  520. struct qla2xxx_mq_chain *mq = ptr;
  521. device_reg_t *reg;
  522. if (!ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha))
  523. return ptr;
  524. mq = ptr;
  525. *last_chain = &mq->type;
  526. mq->type = htonl(DUMP_CHAIN_MQ);
  527. mq->chain_size = htonl(sizeof(struct qla2xxx_mq_chain));
  528. que_cnt = ha->max_req_queues > ha->max_rsp_queues ?
  529. ha->max_req_queues : ha->max_rsp_queues;
  530. mq->count = htonl(que_cnt);
  531. for (cnt = 0; cnt < que_cnt; cnt++) {
  532. reg = ISP_QUE_REG(ha, cnt);
  533. que_idx = cnt * 4;
  534. mq->qregs[que_idx] =
  535. htonl(RD_REG_DWORD(&reg->isp25mq.req_q_in));
  536. mq->qregs[que_idx+1] =
  537. htonl(RD_REG_DWORD(&reg->isp25mq.req_q_out));
  538. mq->qregs[que_idx+2] =
  539. htonl(RD_REG_DWORD(&reg->isp25mq.rsp_q_in));
  540. mq->qregs[que_idx+3] =
  541. htonl(RD_REG_DWORD(&reg->isp25mq.rsp_q_out));
  542. }
  543. return ptr + sizeof(struct qla2xxx_mq_chain);
  544. }
  545. void
  546. qla2xxx_dump_post_process(scsi_qla_host_t *vha, int rval)
  547. {
  548. struct qla_hw_data *ha = vha->hw;
  549. if (rval != QLA_SUCCESS) {
  550. ql_log(ql_log_warn, vha, 0xd000,
  551. "Failed to dump firmware (%x), dump status flags (0x%lx).\n",
  552. rval, ha->fw_dump_cap_flags);
  553. ha->fw_dumped = 0;
  554. } else {
  555. ql_log(ql_log_info, vha, 0xd001,
  556. "Firmware dump saved to temp buffer (%ld/%p), dump status flags (0x%lx).\n",
  557. vha->host_no, ha->fw_dump, ha->fw_dump_cap_flags);
  558. ha->fw_dumped = 1;
  559. qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);
  560. }
  561. }
  562. /**
  563. * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
  564. * @ha: HA context
  565. * @hardware_locked: Called with the hardware_lock
  566. */
  567. void
  568. qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  569. {
  570. int rval;
  571. uint32_t cnt;
  572. struct qla_hw_data *ha = vha->hw;
  573. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  574. uint16_t __iomem *dmp_reg;
  575. unsigned long flags;
  576. struct qla2300_fw_dump *fw;
  577. void *nxt;
  578. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  579. flags = 0;
  580. #ifndef __CHECKER__
  581. if (!hardware_locked)
  582. spin_lock_irqsave(&ha->hardware_lock, flags);
  583. #endif
  584. if (!ha->fw_dump) {
  585. ql_log(ql_log_warn, vha, 0xd002,
  586. "No buffer available for dump.\n");
  587. goto qla2300_fw_dump_failed;
  588. }
  589. if (ha->fw_dumped) {
  590. ql_log(ql_log_warn, vha, 0xd003,
  591. "Firmware has been previously dumped (%p) "
  592. "-- ignoring request.\n",
  593. ha->fw_dump);
  594. goto qla2300_fw_dump_failed;
  595. }
  596. fw = &ha->fw_dump->isp.isp23;
  597. qla2xxx_prep_dump(ha, ha->fw_dump);
  598. rval = QLA_SUCCESS;
  599. fw->hccr = htons(RD_REG_WORD(&reg->hccr));
  600. /* Pause RISC. */
  601. WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
  602. if (IS_QLA2300(ha)) {
  603. for (cnt = 30000;
  604. (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
  605. rval == QLA_SUCCESS; cnt--) {
  606. if (cnt)
  607. udelay(100);
  608. else
  609. rval = QLA_FUNCTION_TIMEOUT;
  610. }
  611. } else {
  612. RD_REG_WORD(&reg->hccr); /* PCI Posting. */
  613. udelay(10);
  614. }
  615. if (rval == QLA_SUCCESS) {
  616. dmp_reg = &reg->flash_address;
  617. for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++, dmp_reg++)
  618. fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  619. dmp_reg = &reg->u.isp2300.req_q_in;
  620. for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2;
  621. cnt++, dmp_reg++)
  622. fw->risc_host_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  623. dmp_reg = &reg->u.isp2300.mailbox0;
  624. for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2;
  625. cnt++, dmp_reg++)
  626. fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  627. WRT_REG_WORD(&reg->ctrl_status, 0x40);
  628. qla2xxx_read_window(reg, 32, fw->resp_dma_reg);
  629. WRT_REG_WORD(&reg->ctrl_status, 0x50);
  630. qla2xxx_read_window(reg, 48, fw->dma_reg);
  631. WRT_REG_WORD(&reg->ctrl_status, 0x00);
  632. dmp_reg = &reg->risc_hw;
  633. for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2;
  634. cnt++, dmp_reg++)
  635. fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  636. WRT_REG_WORD(&reg->pcr, 0x2000);
  637. qla2xxx_read_window(reg, 16, fw->risc_gp0_reg);
  638. WRT_REG_WORD(&reg->pcr, 0x2200);
  639. qla2xxx_read_window(reg, 16, fw->risc_gp1_reg);
  640. WRT_REG_WORD(&reg->pcr, 0x2400);
  641. qla2xxx_read_window(reg, 16, fw->risc_gp2_reg);
  642. WRT_REG_WORD(&reg->pcr, 0x2600);
  643. qla2xxx_read_window(reg, 16, fw->risc_gp3_reg);
  644. WRT_REG_WORD(&reg->pcr, 0x2800);
  645. qla2xxx_read_window(reg, 16, fw->risc_gp4_reg);
  646. WRT_REG_WORD(&reg->pcr, 0x2A00);
  647. qla2xxx_read_window(reg, 16, fw->risc_gp5_reg);
  648. WRT_REG_WORD(&reg->pcr, 0x2C00);
  649. qla2xxx_read_window(reg, 16, fw->risc_gp6_reg);
  650. WRT_REG_WORD(&reg->pcr, 0x2E00);
  651. qla2xxx_read_window(reg, 16, fw->risc_gp7_reg);
  652. WRT_REG_WORD(&reg->ctrl_status, 0x10);
  653. qla2xxx_read_window(reg, 64, fw->frame_buf_hdw_reg);
  654. WRT_REG_WORD(&reg->ctrl_status, 0x20);
  655. qla2xxx_read_window(reg, 64, fw->fpm_b0_reg);
  656. WRT_REG_WORD(&reg->ctrl_status, 0x30);
  657. qla2xxx_read_window(reg, 64, fw->fpm_b1_reg);
  658. /* Reset RISC. */
  659. WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
  660. for (cnt = 0; cnt < 30000; cnt++) {
  661. if ((RD_REG_WORD(&reg->ctrl_status) &
  662. CSR_ISP_SOFT_RESET) == 0)
  663. break;
  664. udelay(10);
  665. }
  666. }
  667. if (!IS_QLA2300(ha)) {
  668. for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
  669. rval == QLA_SUCCESS; cnt--) {
  670. if (cnt)
  671. udelay(100);
  672. else
  673. rval = QLA_FUNCTION_TIMEOUT;
  674. }
  675. }
  676. /* Get RISC SRAM. */
  677. if (rval == QLA_SUCCESS)
  678. rval = qla2xxx_dump_ram(ha, 0x800, fw->risc_ram,
  679. sizeof(fw->risc_ram) / 2, &nxt);
  680. /* Get stack SRAM. */
  681. if (rval == QLA_SUCCESS)
  682. rval = qla2xxx_dump_ram(ha, 0x10000, fw->stack_ram,
  683. sizeof(fw->stack_ram) / 2, &nxt);
  684. /* Get data SRAM. */
  685. if (rval == QLA_SUCCESS)
  686. rval = qla2xxx_dump_ram(ha, 0x11000, fw->data_ram,
  687. ha->fw_memory_size - 0x11000 + 1, &nxt);
  688. if (rval == QLA_SUCCESS)
  689. qla2xxx_copy_queues(ha, nxt);
  690. qla2xxx_dump_post_process(base_vha, rval);
  691. qla2300_fw_dump_failed:
  692. #ifndef __CHECKER__
  693. if (!hardware_locked)
  694. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  695. #else
  696. ;
  697. #endif
  698. }
  699. /**
  700. * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
  701. * @ha: HA context
  702. * @hardware_locked: Called with the hardware_lock
  703. */
  704. void
  705. qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  706. {
  707. int rval;
  708. uint32_t cnt, timer;
  709. uint16_t risc_address;
  710. uint16_t mb0, mb2;
  711. struct qla_hw_data *ha = vha->hw;
  712. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  713. uint16_t __iomem *dmp_reg;
  714. unsigned long flags;
  715. struct qla2100_fw_dump *fw;
  716. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  717. risc_address = 0;
  718. mb0 = mb2 = 0;
  719. flags = 0;
  720. #ifndef __CHECKER__
  721. if (!hardware_locked)
  722. spin_lock_irqsave(&ha->hardware_lock, flags);
  723. #endif
  724. if (!ha->fw_dump) {
  725. ql_log(ql_log_warn, vha, 0xd004,
  726. "No buffer available for dump.\n");
  727. goto qla2100_fw_dump_failed;
  728. }
  729. if (ha->fw_dumped) {
  730. ql_log(ql_log_warn, vha, 0xd005,
  731. "Firmware has been previously dumped (%p) "
  732. "-- ignoring request.\n",
  733. ha->fw_dump);
  734. goto qla2100_fw_dump_failed;
  735. }
  736. fw = &ha->fw_dump->isp.isp21;
  737. qla2xxx_prep_dump(ha, ha->fw_dump);
  738. rval = QLA_SUCCESS;
  739. fw->hccr = htons(RD_REG_WORD(&reg->hccr));
  740. /* Pause RISC. */
  741. WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
  742. for (cnt = 30000; (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
  743. rval == QLA_SUCCESS; cnt--) {
  744. if (cnt)
  745. udelay(100);
  746. else
  747. rval = QLA_FUNCTION_TIMEOUT;
  748. }
  749. if (rval == QLA_SUCCESS) {
  750. dmp_reg = &reg->flash_address;
  751. for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++, dmp_reg++)
  752. fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  753. dmp_reg = &reg->u.isp2100.mailbox0;
  754. for (cnt = 0; cnt < ha->mbx_count; cnt++, dmp_reg++) {
  755. if (cnt == 8)
  756. dmp_reg = &reg->u_end.isp2200.mailbox8;
  757. fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  758. }
  759. dmp_reg = &reg->u.isp2100.unused_2[0];
  760. for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++, dmp_reg++)
  761. fw->dma_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  762. WRT_REG_WORD(&reg->ctrl_status, 0x00);
  763. dmp_reg = &reg->risc_hw;
  764. for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++, dmp_reg++)
  765. fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg));
  766. WRT_REG_WORD(&reg->pcr, 0x2000);
  767. qla2xxx_read_window(reg, 16, fw->risc_gp0_reg);
  768. WRT_REG_WORD(&reg->pcr, 0x2100);
  769. qla2xxx_read_window(reg, 16, fw->risc_gp1_reg);
  770. WRT_REG_WORD(&reg->pcr, 0x2200);
  771. qla2xxx_read_window(reg, 16, fw->risc_gp2_reg);
  772. WRT_REG_WORD(&reg->pcr, 0x2300);
  773. qla2xxx_read_window(reg, 16, fw->risc_gp3_reg);
  774. WRT_REG_WORD(&reg->pcr, 0x2400);
  775. qla2xxx_read_window(reg, 16, fw->risc_gp4_reg);
  776. WRT_REG_WORD(&reg->pcr, 0x2500);
  777. qla2xxx_read_window(reg, 16, fw->risc_gp5_reg);
  778. WRT_REG_WORD(&reg->pcr, 0x2600);
  779. qla2xxx_read_window(reg, 16, fw->risc_gp6_reg);
  780. WRT_REG_WORD(&reg->pcr, 0x2700);
  781. qla2xxx_read_window(reg, 16, fw->risc_gp7_reg);
  782. WRT_REG_WORD(&reg->ctrl_status, 0x10);
  783. qla2xxx_read_window(reg, 16, fw->frame_buf_hdw_reg);
  784. WRT_REG_WORD(&reg->ctrl_status, 0x20);
  785. qla2xxx_read_window(reg, 64, fw->fpm_b0_reg);
  786. WRT_REG_WORD(&reg->ctrl_status, 0x30);
  787. qla2xxx_read_window(reg, 64, fw->fpm_b1_reg);
  788. /* Reset the ISP. */
  789. WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
  790. }
  791. for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
  792. rval == QLA_SUCCESS; cnt--) {
  793. if (cnt)
  794. udelay(100);
  795. else
  796. rval = QLA_FUNCTION_TIMEOUT;
  797. }
  798. /* Pause RISC. */
  799. if (rval == QLA_SUCCESS && (IS_QLA2200(ha) || (IS_QLA2100(ha) &&
  800. (RD_REG_WORD(&reg->mctr) & (BIT_1 | BIT_0)) != 0))) {
  801. WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
  802. for (cnt = 30000;
  803. (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
  804. rval == QLA_SUCCESS; cnt--) {
  805. if (cnt)
  806. udelay(100);
  807. else
  808. rval = QLA_FUNCTION_TIMEOUT;
  809. }
  810. if (rval == QLA_SUCCESS) {
  811. /* Set memory configuration and timing. */
  812. if (IS_QLA2100(ha))
  813. WRT_REG_WORD(&reg->mctr, 0xf1);
  814. else
  815. WRT_REG_WORD(&reg->mctr, 0xf2);
  816. RD_REG_WORD(&reg->mctr); /* PCI Posting. */
  817. /* Release RISC. */
  818. WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
  819. }
  820. }
  821. if (rval == QLA_SUCCESS) {
  822. /* Get RISC SRAM. */
  823. risc_address = 0x1000;
  824. WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
  825. clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
  826. }
  827. for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
  828. cnt++, risc_address++) {
  829. WRT_MAILBOX_REG(ha, reg, 1, risc_address);
  830. WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
  831. for (timer = 6000000; timer != 0; timer--) {
  832. /* Check for pending interrupts. */
  833. if (RD_REG_WORD(&reg->istatus) & ISR_RISC_INT) {
  834. if (RD_REG_WORD(&reg->semaphore) & BIT_0) {
  835. set_bit(MBX_INTERRUPT,
  836. &ha->mbx_cmd_flags);
  837. mb0 = RD_MAILBOX_REG(ha, reg, 0);
  838. mb2 = RD_MAILBOX_REG(ha, reg, 2);
  839. WRT_REG_WORD(&reg->semaphore, 0);
  840. WRT_REG_WORD(&reg->hccr,
  841. HCCR_CLR_RISC_INT);
  842. RD_REG_WORD(&reg->hccr);
  843. break;
  844. }
  845. WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
  846. RD_REG_WORD(&reg->hccr);
  847. }
  848. udelay(5);
  849. }
  850. if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
  851. rval = mb0 & MBS_MASK;
  852. fw->risc_ram[cnt] = htons(mb2);
  853. } else {
  854. rval = QLA_FUNCTION_FAILED;
  855. }
  856. }
  857. if (rval == QLA_SUCCESS)
  858. qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]);
  859. qla2xxx_dump_post_process(base_vha, rval);
  860. qla2100_fw_dump_failed:
  861. #ifndef __CHECKER__
  862. if (!hardware_locked)
  863. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  864. #else
  865. ;
  866. #endif
  867. }
  868. void
  869. qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  870. {
  871. int rval;
  872. uint32_t cnt;
  873. struct qla_hw_data *ha = vha->hw;
  874. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  875. uint32_t __iomem *dmp_reg;
  876. uint32_t *iter_reg;
  877. uint16_t __iomem *mbx_reg;
  878. unsigned long flags;
  879. struct qla24xx_fw_dump *fw;
  880. void *nxt;
  881. void *nxt_chain;
  882. uint32_t *last_chain = NULL;
  883. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  884. if (IS_P3P_TYPE(ha))
  885. return;
  886. flags = 0;
  887. ha->fw_dump_cap_flags = 0;
  888. #ifndef __CHECKER__
  889. if (!hardware_locked)
  890. spin_lock_irqsave(&ha->hardware_lock, flags);
  891. #endif
  892. if (!ha->fw_dump) {
  893. ql_log(ql_log_warn, vha, 0xd006,
  894. "No buffer available for dump.\n");
  895. goto qla24xx_fw_dump_failed;
  896. }
  897. if (ha->fw_dumped) {
  898. ql_log(ql_log_warn, vha, 0xd007,
  899. "Firmware has been previously dumped (%p) "
  900. "-- ignoring request.\n",
  901. ha->fw_dump);
  902. goto qla24xx_fw_dump_failed;
  903. }
  904. fw = &ha->fw_dump->isp.isp24;
  905. qla2xxx_prep_dump(ha, ha->fw_dump);
  906. fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
  907. /*
  908. * Pause RISC. No need to track timeout, as resetting the chip
  909. * is the right approach incase of pause timeout
  910. */
  911. qla24xx_pause_risc(reg, ha);
  912. /* Host interface registers. */
  913. dmp_reg = &reg->flash_addr;
  914. for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++, dmp_reg++)
  915. fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg));
  916. /* Disable interrupts. */
  917. WRT_REG_DWORD(&reg->ictrl, 0);
  918. RD_REG_DWORD(&reg->ictrl);
  919. /* Shadow registers. */
  920. WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
  921. RD_REG_DWORD(&reg->iobase_addr);
  922. WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
  923. fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  924. WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
  925. fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  926. WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
  927. fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  928. WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
  929. fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  930. WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
  931. fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  932. WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
  933. fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  934. WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
  935. fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  936. /* Mailbox registers. */
  937. mbx_reg = &reg->mailbox0;
  938. for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++, mbx_reg++)
  939. fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg));
  940. /* Transfer sequence registers. */
  941. iter_reg = fw->xseq_gp_reg;
  942. iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
  943. iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
  944. iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
  945. iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
  946. iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
  947. iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
  948. iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
  949. qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
  950. qla24xx_read_window(reg, 0xBFE0, 16, fw->xseq_0_reg);
  951. qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
  952. /* Receive sequence registers. */
  953. iter_reg = fw->rseq_gp_reg;
  954. iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
  955. iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
  956. iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
  957. iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
  958. iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
  959. iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
  960. iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
  961. qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
  962. qla24xx_read_window(reg, 0xFFD0, 16, fw->rseq_0_reg);
  963. qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
  964. qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
  965. /* Command DMA registers. */
  966. qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
  967. /* Queues. */
  968. iter_reg = fw->req0_dma_reg;
  969. iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
  970. dmp_reg = &reg->iobase_q;
  971. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  972. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  973. iter_reg = fw->resp0_dma_reg;
  974. iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
  975. dmp_reg = &reg->iobase_q;
  976. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  977. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  978. iter_reg = fw->req1_dma_reg;
  979. iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
  980. dmp_reg = &reg->iobase_q;
  981. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  982. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  983. /* Transmit DMA registers. */
  984. iter_reg = fw->xmt0_dma_reg;
  985. iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
  986. qla24xx_read_window(reg, 0x7610, 16, iter_reg);
  987. iter_reg = fw->xmt1_dma_reg;
  988. iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
  989. qla24xx_read_window(reg, 0x7630, 16, iter_reg);
  990. iter_reg = fw->xmt2_dma_reg;
  991. iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
  992. qla24xx_read_window(reg, 0x7650, 16, iter_reg);
  993. iter_reg = fw->xmt3_dma_reg;
  994. iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
  995. qla24xx_read_window(reg, 0x7670, 16, iter_reg);
  996. iter_reg = fw->xmt4_dma_reg;
  997. iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
  998. qla24xx_read_window(reg, 0x7690, 16, iter_reg);
  999. qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
  1000. /* Receive DMA registers. */
  1001. iter_reg = fw->rcvt0_data_dma_reg;
  1002. iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
  1003. qla24xx_read_window(reg, 0x7710, 16, iter_reg);
  1004. iter_reg = fw->rcvt1_data_dma_reg;
  1005. iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
  1006. qla24xx_read_window(reg, 0x7730, 16, iter_reg);
  1007. /* RISC registers. */
  1008. iter_reg = fw->risc_gp_reg;
  1009. iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
  1010. iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
  1011. iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
  1012. iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
  1013. iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
  1014. iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
  1015. iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
  1016. qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
  1017. /* Local memory controller registers. */
  1018. iter_reg = fw->lmc_reg;
  1019. iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
  1020. iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
  1021. iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
  1022. iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
  1023. iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
  1024. iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
  1025. qla24xx_read_window(reg, 0x3060, 16, iter_reg);
  1026. /* Fibre Protocol Module registers. */
  1027. iter_reg = fw->fpm_hdw_reg;
  1028. iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
  1029. iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
  1030. iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
  1031. iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
  1032. iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
  1033. iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
  1034. iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
  1035. iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
  1036. iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
  1037. iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
  1038. iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
  1039. qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
  1040. /* Frame Buffer registers. */
  1041. iter_reg = fw->fb_hdw_reg;
  1042. iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
  1043. iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
  1044. iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
  1045. iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
  1046. iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
  1047. iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
  1048. iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
  1049. iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
  1050. iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
  1051. iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
  1052. qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
  1053. rval = qla24xx_soft_reset(ha);
  1054. if (rval != QLA_SUCCESS)
  1055. goto qla24xx_fw_dump_failed_0;
  1056. rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
  1057. &nxt);
  1058. if (rval != QLA_SUCCESS)
  1059. goto qla24xx_fw_dump_failed_0;
  1060. nxt = qla2xxx_copy_queues(ha, nxt);
  1061. qla24xx_copy_eft(ha, nxt);
  1062. nxt_chain = (void *)ha->fw_dump + ha->chain_offset;
  1063. nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
  1064. if (last_chain) {
  1065. ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
  1066. *last_chain |= htonl(DUMP_CHAIN_LAST);
  1067. }
  1068. /* Adjust valid length. */
  1069. ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
  1070. qla24xx_fw_dump_failed_0:
  1071. qla2xxx_dump_post_process(base_vha, rval);
  1072. qla24xx_fw_dump_failed:
  1073. #ifndef __CHECKER__
  1074. if (!hardware_locked)
  1075. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1076. #else
  1077. ;
  1078. #endif
  1079. }
  1080. void
  1081. qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  1082. {
  1083. int rval;
  1084. uint32_t cnt;
  1085. struct qla_hw_data *ha = vha->hw;
  1086. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  1087. uint32_t __iomem *dmp_reg;
  1088. uint32_t *iter_reg;
  1089. uint16_t __iomem *mbx_reg;
  1090. unsigned long flags;
  1091. struct qla25xx_fw_dump *fw;
  1092. void *nxt, *nxt_chain;
  1093. uint32_t *last_chain = NULL;
  1094. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  1095. flags = 0;
  1096. ha->fw_dump_cap_flags = 0;
  1097. #ifndef __CHECKER__
  1098. if (!hardware_locked)
  1099. spin_lock_irqsave(&ha->hardware_lock, flags);
  1100. #endif
  1101. if (!ha->fw_dump) {
  1102. ql_log(ql_log_warn, vha, 0xd008,
  1103. "No buffer available for dump.\n");
  1104. goto qla25xx_fw_dump_failed;
  1105. }
  1106. if (ha->fw_dumped) {
  1107. ql_log(ql_log_warn, vha, 0xd009,
  1108. "Firmware has been previously dumped (%p) "
  1109. "-- ignoring request.\n",
  1110. ha->fw_dump);
  1111. goto qla25xx_fw_dump_failed;
  1112. }
  1113. fw = &ha->fw_dump->isp.isp25;
  1114. qla2xxx_prep_dump(ha, ha->fw_dump);
  1115. ha->fw_dump->version = htonl(2);
  1116. fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
  1117. /*
  1118. * Pause RISC. No need to track timeout, as resetting the chip
  1119. * is the right approach incase of pause timeout
  1120. */
  1121. qla24xx_pause_risc(reg, ha);
  1122. /* Host/Risc registers. */
  1123. iter_reg = fw->host_risc_reg;
  1124. iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
  1125. qla24xx_read_window(reg, 0x7010, 16, iter_reg);
  1126. /* PCIe registers. */
  1127. WRT_REG_DWORD(&reg->iobase_addr, 0x7C00);
  1128. RD_REG_DWORD(&reg->iobase_addr);
  1129. WRT_REG_DWORD(&reg->iobase_window, 0x01);
  1130. dmp_reg = &reg->iobase_c4;
  1131. fw->pcie_regs[0] = htonl(RD_REG_DWORD(dmp_reg));
  1132. dmp_reg++;
  1133. fw->pcie_regs[1] = htonl(RD_REG_DWORD(dmp_reg));
  1134. dmp_reg++;
  1135. fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
  1136. fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));
  1137. WRT_REG_DWORD(&reg->iobase_window, 0x00);
  1138. RD_REG_DWORD(&reg->iobase_window);
  1139. /* Host interface registers. */
  1140. dmp_reg = &reg->flash_addr;
  1141. for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++, dmp_reg++)
  1142. fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg));
  1143. /* Disable interrupts. */
  1144. WRT_REG_DWORD(&reg->ictrl, 0);
  1145. RD_REG_DWORD(&reg->ictrl);
  1146. /* Shadow registers. */
  1147. WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
  1148. RD_REG_DWORD(&reg->iobase_addr);
  1149. WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
  1150. fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1151. WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
  1152. fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1153. WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
  1154. fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1155. WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
  1156. fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1157. WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
  1158. fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1159. WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
  1160. fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1161. WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
  1162. fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1163. WRT_REG_DWORD(&reg->iobase_select, 0xB0700000);
  1164. fw->shadow_reg[7] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1165. WRT_REG_DWORD(&reg->iobase_select, 0xB0800000);
  1166. fw->shadow_reg[8] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1167. WRT_REG_DWORD(&reg->iobase_select, 0xB0900000);
  1168. fw->shadow_reg[9] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1169. WRT_REG_DWORD(&reg->iobase_select, 0xB0A00000);
  1170. fw->shadow_reg[10] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1171. /* RISC I/O register. */
  1172. WRT_REG_DWORD(&reg->iobase_addr, 0x0010);
  1173. fw->risc_io_reg = htonl(RD_REG_DWORD(&reg->iobase_window));
  1174. /* Mailbox registers. */
  1175. mbx_reg = &reg->mailbox0;
  1176. for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++, mbx_reg++)
  1177. fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg));
  1178. /* Transfer sequence registers. */
  1179. iter_reg = fw->xseq_gp_reg;
  1180. iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
  1181. iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
  1182. iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
  1183. iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
  1184. iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
  1185. iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
  1186. iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
  1187. qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
  1188. iter_reg = fw->xseq_0_reg;
  1189. iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
  1190. iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
  1191. qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
  1192. qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
  1193. /* Receive sequence registers. */
  1194. iter_reg = fw->rseq_gp_reg;
  1195. iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
  1196. iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
  1197. iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
  1198. iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
  1199. iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
  1200. iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
  1201. iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
  1202. qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
  1203. iter_reg = fw->rseq_0_reg;
  1204. iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
  1205. qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
  1206. qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
  1207. qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
  1208. /* Auxiliary sequence registers. */
  1209. iter_reg = fw->aseq_gp_reg;
  1210. iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
  1211. iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
  1212. iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
  1213. iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
  1214. iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
  1215. iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
  1216. iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
  1217. qla24xx_read_window(reg, 0xB070, 16, iter_reg);
  1218. iter_reg = fw->aseq_0_reg;
  1219. iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
  1220. qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
  1221. qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
  1222. qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
  1223. /* Command DMA registers. */
  1224. qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
  1225. /* Queues. */
  1226. iter_reg = fw->req0_dma_reg;
  1227. iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
  1228. dmp_reg = &reg->iobase_q;
  1229. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1230. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1231. iter_reg = fw->resp0_dma_reg;
  1232. iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
  1233. dmp_reg = &reg->iobase_q;
  1234. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1235. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1236. iter_reg = fw->req1_dma_reg;
  1237. iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
  1238. dmp_reg = &reg->iobase_q;
  1239. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1240. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1241. /* Transmit DMA registers. */
  1242. iter_reg = fw->xmt0_dma_reg;
  1243. iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
  1244. qla24xx_read_window(reg, 0x7610, 16, iter_reg);
  1245. iter_reg = fw->xmt1_dma_reg;
  1246. iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
  1247. qla24xx_read_window(reg, 0x7630, 16, iter_reg);
  1248. iter_reg = fw->xmt2_dma_reg;
  1249. iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
  1250. qla24xx_read_window(reg, 0x7650, 16, iter_reg);
  1251. iter_reg = fw->xmt3_dma_reg;
  1252. iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
  1253. qla24xx_read_window(reg, 0x7670, 16, iter_reg);
  1254. iter_reg = fw->xmt4_dma_reg;
  1255. iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
  1256. qla24xx_read_window(reg, 0x7690, 16, iter_reg);
  1257. qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
  1258. /* Receive DMA registers. */
  1259. iter_reg = fw->rcvt0_data_dma_reg;
  1260. iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
  1261. qla24xx_read_window(reg, 0x7710, 16, iter_reg);
  1262. iter_reg = fw->rcvt1_data_dma_reg;
  1263. iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
  1264. qla24xx_read_window(reg, 0x7730, 16, iter_reg);
  1265. /* RISC registers. */
  1266. iter_reg = fw->risc_gp_reg;
  1267. iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
  1268. iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
  1269. iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
  1270. iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
  1271. iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
  1272. iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
  1273. iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
  1274. qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
  1275. /* Local memory controller registers. */
  1276. iter_reg = fw->lmc_reg;
  1277. iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
  1278. iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
  1279. iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
  1280. iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
  1281. iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
  1282. iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
  1283. iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
  1284. qla24xx_read_window(reg, 0x3070, 16, iter_reg);
  1285. /* Fibre Protocol Module registers. */
  1286. iter_reg = fw->fpm_hdw_reg;
  1287. iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
  1288. iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
  1289. iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
  1290. iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
  1291. iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
  1292. iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
  1293. iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
  1294. iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
  1295. iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
  1296. iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
  1297. iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
  1298. qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
  1299. /* Frame Buffer registers. */
  1300. iter_reg = fw->fb_hdw_reg;
  1301. iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
  1302. iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
  1303. iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
  1304. iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
  1305. iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
  1306. iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
  1307. iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
  1308. iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
  1309. iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
  1310. iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
  1311. iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
  1312. qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
  1313. /* Multi queue registers */
  1314. nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
  1315. &last_chain);
  1316. rval = qla24xx_soft_reset(ha);
  1317. if (rval != QLA_SUCCESS)
  1318. goto qla25xx_fw_dump_failed_0;
  1319. rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
  1320. &nxt);
  1321. if (rval != QLA_SUCCESS)
  1322. goto qla25xx_fw_dump_failed_0;
  1323. nxt = qla2xxx_copy_queues(ha, nxt);
  1324. qla24xx_copy_eft(ha, nxt);
  1325. /* Chain entries -- started with MQ. */
  1326. nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
  1327. nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
  1328. nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
  1329. if (last_chain) {
  1330. ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
  1331. *last_chain |= htonl(DUMP_CHAIN_LAST);
  1332. }
  1333. /* Adjust valid length. */
  1334. ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
  1335. qla25xx_fw_dump_failed_0:
  1336. qla2xxx_dump_post_process(base_vha, rval);
  1337. qla25xx_fw_dump_failed:
  1338. #ifndef __CHECKER__
  1339. if (!hardware_locked)
  1340. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1341. #else
  1342. ;
  1343. #endif
  1344. }
  1345. void
  1346. qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  1347. {
  1348. int rval;
  1349. uint32_t cnt;
  1350. struct qla_hw_data *ha = vha->hw;
  1351. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  1352. uint32_t __iomem *dmp_reg;
  1353. uint32_t *iter_reg;
  1354. uint16_t __iomem *mbx_reg;
  1355. unsigned long flags;
  1356. struct qla81xx_fw_dump *fw;
  1357. void *nxt, *nxt_chain;
  1358. uint32_t *last_chain = NULL;
  1359. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  1360. flags = 0;
  1361. ha->fw_dump_cap_flags = 0;
  1362. #ifndef __CHECKER__
  1363. if (!hardware_locked)
  1364. spin_lock_irqsave(&ha->hardware_lock, flags);
  1365. #endif
  1366. if (!ha->fw_dump) {
  1367. ql_log(ql_log_warn, vha, 0xd00a,
  1368. "No buffer available for dump.\n");
  1369. goto qla81xx_fw_dump_failed;
  1370. }
  1371. if (ha->fw_dumped) {
  1372. ql_log(ql_log_warn, vha, 0xd00b,
  1373. "Firmware has been previously dumped (%p) "
  1374. "-- ignoring request.\n",
  1375. ha->fw_dump);
  1376. goto qla81xx_fw_dump_failed;
  1377. }
  1378. fw = &ha->fw_dump->isp.isp81;
  1379. qla2xxx_prep_dump(ha, ha->fw_dump);
  1380. fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
  1381. /*
  1382. * Pause RISC. No need to track timeout, as resetting the chip
  1383. * is the right approach incase of pause timeout
  1384. */
  1385. qla24xx_pause_risc(reg, ha);
  1386. /* Host/Risc registers. */
  1387. iter_reg = fw->host_risc_reg;
  1388. iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
  1389. qla24xx_read_window(reg, 0x7010, 16, iter_reg);
  1390. /* PCIe registers. */
  1391. WRT_REG_DWORD(&reg->iobase_addr, 0x7C00);
  1392. RD_REG_DWORD(&reg->iobase_addr);
  1393. WRT_REG_DWORD(&reg->iobase_window, 0x01);
  1394. dmp_reg = &reg->iobase_c4;
  1395. fw->pcie_regs[0] = htonl(RD_REG_DWORD(dmp_reg));
  1396. dmp_reg++;
  1397. fw->pcie_regs[1] = htonl(RD_REG_DWORD(dmp_reg));
  1398. dmp_reg++;
  1399. fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
  1400. fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));
  1401. WRT_REG_DWORD(&reg->iobase_window, 0x00);
  1402. RD_REG_DWORD(&reg->iobase_window);
  1403. /* Host interface registers. */
  1404. dmp_reg = &reg->flash_addr;
  1405. for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++, dmp_reg++)
  1406. fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg));
  1407. /* Disable interrupts. */
  1408. WRT_REG_DWORD(&reg->ictrl, 0);
  1409. RD_REG_DWORD(&reg->ictrl);
  1410. /* Shadow registers. */
  1411. WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
  1412. RD_REG_DWORD(&reg->iobase_addr);
  1413. WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
  1414. fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1415. WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
  1416. fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1417. WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
  1418. fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1419. WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
  1420. fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1421. WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
  1422. fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1423. WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
  1424. fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1425. WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
  1426. fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1427. WRT_REG_DWORD(&reg->iobase_select, 0xB0700000);
  1428. fw->shadow_reg[7] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1429. WRT_REG_DWORD(&reg->iobase_select, 0xB0800000);
  1430. fw->shadow_reg[8] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1431. WRT_REG_DWORD(&reg->iobase_select, 0xB0900000);
  1432. fw->shadow_reg[9] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1433. WRT_REG_DWORD(&reg->iobase_select, 0xB0A00000);
  1434. fw->shadow_reg[10] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1435. /* RISC I/O register. */
  1436. WRT_REG_DWORD(&reg->iobase_addr, 0x0010);
  1437. fw->risc_io_reg = htonl(RD_REG_DWORD(&reg->iobase_window));
  1438. /* Mailbox registers. */
  1439. mbx_reg = &reg->mailbox0;
  1440. for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++, mbx_reg++)
  1441. fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg));
  1442. /* Transfer sequence registers. */
  1443. iter_reg = fw->xseq_gp_reg;
  1444. iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
  1445. iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
  1446. iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
  1447. iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
  1448. iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
  1449. iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
  1450. iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
  1451. qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
  1452. iter_reg = fw->xseq_0_reg;
  1453. iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
  1454. iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
  1455. qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
  1456. qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
  1457. /* Receive sequence registers. */
  1458. iter_reg = fw->rseq_gp_reg;
  1459. iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
  1460. iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
  1461. iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
  1462. iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
  1463. iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
  1464. iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
  1465. iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
  1466. qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
  1467. iter_reg = fw->rseq_0_reg;
  1468. iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
  1469. qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
  1470. qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
  1471. qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
  1472. /* Auxiliary sequence registers. */
  1473. iter_reg = fw->aseq_gp_reg;
  1474. iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
  1475. iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
  1476. iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
  1477. iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
  1478. iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
  1479. iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
  1480. iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
  1481. qla24xx_read_window(reg, 0xB070, 16, iter_reg);
  1482. iter_reg = fw->aseq_0_reg;
  1483. iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
  1484. qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
  1485. qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
  1486. qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
  1487. /* Command DMA registers. */
  1488. qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
  1489. /* Queues. */
  1490. iter_reg = fw->req0_dma_reg;
  1491. iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
  1492. dmp_reg = &reg->iobase_q;
  1493. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1494. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1495. iter_reg = fw->resp0_dma_reg;
  1496. iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
  1497. dmp_reg = &reg->iobase_q;
  1498. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1499. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1500. iter_reg = fw->req1_dma_reg;
  1501. iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
  1502. dmp_reg = &reg->iobase_q;
  1503. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1504. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1505. /* Transmit DMA registers. */
  1506. iter_reg = fw->xmt0_dma_reg;
  1507. iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
  1508. qla24xx_read_window(reg, 0x7610, 16, iter_reg);
  1509. iter_reg = fw->xmt1_dma_reg;
  1510. iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
  1511. qla24xx_read_window(reg, 0x7630, 16, iter_reg);
  1512. iter_reg = fw->xmt2_dma_reg;
  1513. iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
  1514. qla24xx_read_window(reg, 0x7650, 16, iter_reg);
  1515. iter_reg = fw->xmt3_dma_reg;
  1516. iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
  1517. qla24xx_read_window(reg, 0x7670, 16, iter_reg);
  1518. iter_reg = fw->xmt4_dma_reg;
  1519. iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
  1520. qla24xx_read_window(reg, 0x7690, 16, iter_reg);
  1521. qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
  1522. /* Receive DMA registers. */
  1523. iter_reg = fw->rcvt0_data_dma_reg;
  1524. iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
  1525. qla24xx_read_window(reg, 0x7710, 16, iter_reg);
  1526. iter_reg = fw->rcvt1_data_dma_reg;
  1527. iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
  1528. qla24xx_read_window(reg, 0x7730, 16, iter_reg);
  1529. /* RISC registers. */
  1530. iter_reg = fw->risc_gp_reg;
  1531. iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
  1532. iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
  1533. iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
  1534. iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
  1535. iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
  1536. iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
  1537. iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
  1538. qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
  1539. /* Local memory controller registers. */
  1540. iter_reg = fw->lmc_reg;
  1541. iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
  1542. iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
  1543. iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
  1544. iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
  1545. iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
  1546. iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
  1547. iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
  1548. qla24xx_read_window(reg, 0x3070, 16, iter_reg);
  1549. /* Fibre Protocol Module registers. */
  1550. iter_reg = fw->fpm_hdw_reg;
  1551. iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
  1552. iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
  1553. iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
  1554. iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
  1555. iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
  1556. iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
  1557. iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
  1558. iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
  1559. iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
  1560. iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
  1561. iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
  1562. iter_reg = qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
  1563. iter_reg = qla24xx_read_window(reg, 0x40C0, 16, iter_reg);
  1564. qla24xx_read_window(reg, 0x40D0, 16, iter_reg);
  1565. /* Frame Buffer registers. */
  1566. iter_reg = fw->fb_hdw_reg;
  1567. iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
  1568. iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
  1569. iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
  1570. iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
  1571. iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
  1572. iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
  1573. iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
  1574. iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
  1575. iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
  1576. iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
  1577. iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
  1578. iter_reg = qla24xx_read_window(reg, 0x61C0, 16, iter_reg);
  1579. qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
  1580. /* Multi queue registers */
  1581. nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
  1582. &last_chain);
  1583. rval = qla24xx_soft_reset(ha);
  1584. if (rval != QLA_SUCCESS)
  1585. goto qla81xx_fw_dump_failed_0;
  1586. rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
  1587. &nxt);
  1588. if (rval != QLA_SUCCESS)
  1589. goto qla81xx_fw_dump_failed_0;
  1590. nxt = qla2xxx_copy_queues(ha, nxt);
  1591. qla24xx_copy_eft(ha, nxt);
  1592. /* Chain entries -- started with MQ. */
  1593. nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
  1594. nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
  1595. nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
  1596. if (last_chain) {
  1597. ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
  1598. *last_chain |= htonl(DUMP_CHAIN_LAST);
  1599. }
  1600. /* Adjust valid length. */
  1601. ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
  1602. qla81xx_fw_dump_failed_0:
  1603. qla2xxx_dump_post_process(base_vha, rval);
  1604. qla81xx_fw_dump_failed:
  1605. #ifndef __CHECKER__
  1606. if (!hardware_locked)
  1607. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1608. #else
  1609. ;
  1610. #endif
  1611. }
  1612. void
  1613. qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  1614. {
  1615. int rval;
  1616. uint32_t cnt;
  1617. struct qla_hw_data *ha = vha->hw;
  1618. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  1619. uint32_t __iomem *dmp_reg;
  1620. uint32_t *iter_reg;
  1621. uint16_t __iomem *mbx_reg;
  1622. unsigned long flags;
  1623. struct qla83xx_fw_dump *fw;
  1624. void *nxt, *nxt_chain;
  1625. uint32_t *last_chain = NULL;
  1626. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  1627. flags = 0;
  1628. ha->fw_dump_cap_flags = 0;
  1629. #ifndef __CHECKER__
  1630. if (!hardware_locked)
  1631. spin_lock_irqsave(&ha->hardware_lock, flags);
  1632. #endif
  1633. if (!ha->fw_dump) {
  1634. ql_log(ql_log_warn, vha, 0xd00c,
  1635. "No buffer available for dump!!!\n");
  1636. goto qla83xx_fw_dump_failed;
  1637. }
  1638. if (ha->fw_dumped) {
  1639. ql_log(ql_log_warn, vha, 0xd00d,
  1640. "Firmware has been previously dumped (%p) -- ignoring "
  1641. "request...\n", ha->fw_dump);
  1642. goto qla83xx_fw_dump_failed;
  1643. }
  1644. fw = &ha->fw_dump->isp.isp83;
  1645. qla2xxx_prep_dump(ha, ha->fw_dump);
  1646. fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
  1647. /*
  1648. * Pause RISC. No need to track timeout, as resetting the chip
  1649. * is the right approach incase of pause timeout
  1650. */
  1651. qla24xx_pause_risc(reg, ha);
  1652. WRT_REG_DWORD(&reg->iobase_addr, 0x6000);
  1653. dmp_reg = &reg->iobase_window;
  1654. RD_REG_DWORD(dmp_reg);
  1655. WRT_REG_DWORD(dmp_reg, 0);
  1656. dmp_reg = &reg->unused_4_1[0];
  1657. RD_REG_DWORD(dmp_reg);
  1658. WRT_REG_DWORD(dmp_reg, 0);
  1659. WRT_REG_DWORD(&reg->iobase_addr, 0x6010);
  1660. dmp_reg = &reg->unused_4_1[2];
  1661. RD_REG_DWORD(dmp_reg);
  1662. WRT_REG_DWORD(dmp_reg, 0);
  1663. /* select PCR and disable ecc checking and correction */
  1664. WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
  1665. RD_REG_DWORD(&reg->iobase_addr);
  1666. WRT_REG_DWORD(&reg->iobase_select, 0x60000000); /* write to F0h = PCR */
  1667. /* Host/Risc registers. */
  1668. iter_reg = fw->host_risc_reg;
  1669. iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
  1670. iter_reg = qla24xx_read_window(reg, 0x7010, 16, iter_reg);
  1671. qla24xx_read_window(reg, 0x7040, 16, iter_reg);
  1672. /* PCIe registers. */
  1673. WRT_REG_DWORD(&reg->iobase_addr, 0x7C00);
  1674. RD_REG_DWORD(&reg->iobase_addr);
  1675. WRT_REG_DWORD(&reg->iobase_window, 0x01);
  1676. dmp_reg = &reg->iobase_c4;
  1677. fw->pcie_regs[0] = htonl(RD_REG_DWORD(dmp_reg));
  1678. dmp_reg++;
  1679. fw->pcie_regs[1] = htonl(RD_REG_DWORD(dmp_reg));
  1680. dmp_reg++;
  1681. fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
  1682. fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));
  1683. WRT_REG_DWORD(&reg->iobase_window, 0x00);
  1684. RD_REG_DWORD(&reg->iobase_window);
  1685. /* Host interface registers. */
  1686. dmp_reg = &reg->flash_addr;
  1687. for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++, dmp_reg++)
  1688. fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg));
  1689. /* Disable interrupts. */
  1690. WRT_REG_DWORD(&reg->ictrl, 0);
  1691. RD_REG_DWORD(&reg->ictrl);
  1692. /* Shadow registers. */
  1693. WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
  1694. RD_REG_DWORD(&reg->iobase_addr);
  1695. WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
  1696. fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1697. WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
  1698. fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1699. WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
  1700. fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1701. WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
  1702. fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1703. WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
  1704. fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1705. WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
  1706. fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1707. WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
  1708. fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1709. WRT_REG_DWORD(&reg->iobase_select, 0xB0700000);
  1710. fw->shadow_reg[7] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1711. WRT_REG_DWORD(&reg->iobase_select, 0xB0800000);
  1712. fw->shadow_reg[8] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1713. WRT_REG_DWORD(&reg->iobase_select, 0xB0900000);
  1714. fw->shadow_reg[9] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1715. WRT_REG_DWORD(&reg->iobase_select, 0xB0A00000);
  1716. fw->shadow_reg[10] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
  1717. /* RISC I/O register. */
  1718. WRT_REG_DWORD(&reg->iobase_addr, 0x0010);
  1719. fw->risc_io_reg = htonl(RD_REG_DWORD(&reg->iobase_window));
  1720. /* Mailbox registers. */
  1721. mbx_reg = &reg->mailbox0;
  1722. for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++, mbx_reg++)
  1723. fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg));
  1724. /* Transfer sequence registers. */
  1725. iter_reg = fw->xseq_gp_reg;
  1726. iter_reg = qla24xx_read_window(reg, 0xBE00, 16, iter_reg);
  1727. iter_reg = qla24xx_read_window(reg, 0xBE10, 16, iter_reg);
  1728. iter_reg = qla24xx_read_window(reg, 0xBE20, 16, iter_reg);
  1729. iter_reg = qla24xx_read_window(reg, 0xBE30, 16, iter_reg);
  1730. iter_reg = qla24xx_read_window(reg, 0xBE40, 16, iter_reg);
  1731. iter_reg = qla24xx_read_window(reg, 0xBE50, 16, iter_reg);
  1732. iter_reg = qla24xx_read_window(reg, 0xBE60, 16, iter_reg);
  1733. iter_reg = qla24xx_read_window(reg, 0xBE70, 16, iter_reg);
  1734. iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
  1735. iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
  1736. iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
  1737. iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
  1738. iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
  1739. iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
  1740. iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
  1741. qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
  1742. iter_reg = fw->xseq_0_reg;
  1743. iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
  1744. iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
  1745. qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
  1746. qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
  1747. qla24xx_read_window(reg, 0xBEF0, 16, fw->xseq_2_reg);
  1748. /* Receive sequence registers. */
  1749. iter_reg = fw->rseq_gp_reg;
  1750. iter_reg = qla24xx_read_window(reg, 0xFE00, 16, iter_reg);
  1751. iter_reg = qla24xx_read_window(reg, 0xFE10, 16, iter_reg);
  1752. iter_reg = qla24xx_read_window(reg, 0xFE20, 16, iter_reg);
  1753. iter_reg = qla24xx_read_window(reg, 0xFE30, 16, iter_reg);
  1754. iter_reg = qla24xx_read_window(reg, 0xFE40, 16, iter_reg);
  1755. iter_reg = qla24xx_read_window(reg, 0xFE50, 16, iter_reg);
  1756. iter_reg = qla24xx_read_window(reg, 0xFE60, 16, iter_reg);
  1757. iter_reg = qla24xx_read_window(reg, 0xFE70, 16, iter_reg);
  1758. iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
  1759. iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
  1760. iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
  1761. iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
  1762. iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
  1763. iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
  1764. iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
  1765. qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
  1766. iter_reg = fw->rseq_0_reg;
  1767. iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
  1768. qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
  1769. qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
  1770. qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
  1771. qla24xx_read_window(reg, 0xFEF0, 16, fw->rseq_3_reg);
  1772. /* Auxiliary sequence registers. */
  1773. iter_reg = fw->aseq_gp_reg;
  1774. iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
  1775. iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
  1776. iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
  1777. iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
  1778. iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
  1779. iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
  1780. iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
  1781. iter_reg = qla24xx_read_window(reg, 0xB070, 16, iter_reg);
  1782. iter_reg = qla24xx_read_window(reg, 0xB100, 16, iter_reg);
  1783. iter_reg = qla24xx_read_window(reg, 0xB110, 16, iter_reg);
  1784. iter_reg = qla24xx_read_window(reg, 0xB120, 16, iter_reg);
  1785. iter_reg = qla24xx_read_window(reg, 0xB130, 16, iter_reg);
  1786. iter_reg = qla24xx_read_window(reg, 0xB140, 16, iter_reg);
  1787. iter_reg = qla24xx_read_window(reg, 0xB150, 16, iter_reg);
  1788. iter_reg = qla24xx_read_window(reg, 0xB160, 16, iter_reg);
  1789. qla24xx_read_window(reg, 0xB170, 16, iter_reg);
  1790. iter_reg = fw->aseq_0_reg;
  1791. iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
  1792. qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
  1793. qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
  1794. qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
  1795. qla24xx_read_window(reg, 0xB1F0, 16, fw->aseq_3_reg);
  1796. /* Command DMA registers. */
  1797. iter_reg = fw->cmd_dma_reg;
  1798. iter_reg = qla24xx_read_window(reg, 0x7100, 16, iter_reg);
  1799. iter_reg = qla24xx_read_window(reg, 0x7120, 16, iter_reg);
  1800. iter_reg = qla24xx_read_window(reg, 0x7130, 16, iter_reg);
  1801. qla24xx_read_window(reg, 0x71F0, 16, iter_reg);
  1802. /* Queues. */
  1803. iter_reg = fw->req0_dma_reg;
  1804. iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
  1805. dmp_reg = &reg->iobase_q;
  1806. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1807. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1808. iter_reg = fw->resp0_dma_reg;
  1809. iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
  1810. dmp_reg = &reg->iobase_q;
  1811. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1812. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1813. iter_reg = fw->req1_dma_reg;
  1814. iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
  1815. dmp_reg = &reg->iobase_q;
  1816. for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
  1817. *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg));
  1818. /* Transmit DMA registers. */
  1819. iter_reg = fw->xmt0_dma_reg;
  1820. iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
  1821. qla24xx_read_window(reg, 0x7610, 16, iter_reg);
  1822. iter_reg = fw->xmt1_dma_reg;
  1823. iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
  1824. qla24xx_read_window(reg, 0x7630, 16, iter_reg);
  1825. iter_reg = fw->xmt2_dma_reg;
  1826. iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
  1827. qla24xx_read_window(reg, 0x7650, 16, iter_reg);
  1828. iter_reg = fw->xmt3_dma_reg;
  1829. iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
  1830. qla24xx_read_window(reg, 0x7670, 16, iter_reg);
  1831. iter_reg = fw->xmt4_dma_reg;
  1832. iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
  1833. qla24xx_read_window(reg, 0x7690, 16, iter_reg);
  1834. qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
  1835. /* Receive DMA registers. */
  1836. iter_reg = fw->rcvt0_data_dma_reg;
  1837. iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
  1838. qla24xx_read_window(reg, 0x7710, 16, iter_reg);
  1839. iter_reg = fw->rcvt1_data_dma_reg;
  1840. iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
  1841. qla24xx_read_window(reg, 0x7730, 16, iter_reg);
  1842. /* RISC registers. */
  1843. iter_reg = fw->risc_gp_reg;
  1844. iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
  1845. iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
  1846. iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
  1847. iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
  1848. iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
  1849. iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
  1850. iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
  1851. qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
  1852. /* Local memory controller registers. */
  1853. iter_reg = fw->lmc_reg;
  1854. iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
  1855. iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
  1856. iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
  1857. iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
  1858. iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
  1859. iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
  1860. iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
  1861. qla24xx_read_window(reg, 0x3070, 16, iter_reg);
  1862. /* Fibre Protocol Module registers. */
  1863. iter_reg = fw->fpm_hdw_reg;
  1864. iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
  1865. iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
  1866. iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
  1867. iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
  1868. iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
  1869. iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
  1870. iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
  1871. iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
  1872. iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
  1873. iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
  1874. iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
  1875. iter_reg = qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
  1876. iter_reg = qla24xx_read_window(reg, 0x40C0, 16, iter_reg);
  1877. iter_reg = qla24xx_read_window(reg, 0x40D0, 16, iter_reg);
  1878. iter_reg = qla24xx_read_window(reg, 0x40E0, 16, iter_reg);
  1879. qla24xx_read_window(reg, 0x40F0, 16, iter_reg);
  1880. /* RQ0 Array registers. */
  1881. iter_reg = fw->rq0_array_reg;
  1882. iter_reg = qla24xx_read_window(reg, 0x5C00, 16, iter_reg);
  1883. iter_reg = qla24xx_read_window(reg, 0x5C10, 16, iter_reg);
  1884. iter_reg = qla24xx_read_window(reg, 0x5C20, 16, iter_reg);
  1885. iter_reg = qla24xx_read_window(reg, 0x5C30, 16, iter_reg);
  1886. iter_reg = qla24xx_read_window(reg, 0x5C40, 16, iter_reg);
  1887. iter_reg = qla24xx_read_window(reg, 0x5C50, 16, iter_reg);
  1888. iter_reg = qla24xx_read_window(reg, 0x5C60, 16, iter_reg);
  1889. iter_reg = qla24xx_read_window(reg, 0x5C70, 16, iter_reg);
  1890. iter_reg = qla24xx_read_window(reg, 0x5C80, 16, iter_reg);
  1891. iter_reg = qla24xx_read_window(reg, 0x5C90, 16, iter_reg);
  1892. iter_reg = qla24xx_read_window(reg, 0x5CA0, 16, iter_reg);
  1893. iter_reg = qla24xx_read_window(reg, 0x5CB0, 16, iter_reg);
  1894. iter_reg = qla24xx_read_window(reg, 0x5CC0, 16, iter_reg);
  1895. iter_reg = qla24xx_read_window(reg, 0x5CD0, 16, iter_reg);
  1896. iter_reg = qla24xx_read_window(reg, 0x5CE0, 16, iter_reg);
  1897. qla24xx_read_window(reg, 0x5CF0, 16, iter_reg);
  1898. /* RQ1 Array registers. */
  1899. iter_reg = fw->rq1_array_reg;
  1900. iter_reg = qla24xx_read_window(reg, 0x5D00, 16, iter_reg);
  1901. iter_reg = qla24xx_read_window(reg, 0x5D10, 16, iter_reg);
  1902. iter_reg = qla24xx_read_window(reg, 0x5D20, 16, iter_reg);
  1903. iter_reg = qla24xx_read_window(reg, 0x5D30, 16, iter_reg);
  1904. iter_reg = qla24xx_read_window(reg, 0x5D40, 16, iter_reg);
  1905. iter_reg = qla24xx_read_window(reg, 0x5D50, 16, iter_reg);
  1906. iter_reg = qla24xx_read_window(reg, 0x5D60, 16, iter_reg);
  1907. iter_reg = qla24xx_read_window(reg, 0x5D70, 16, iter_reg);
  1908. iter_reg = qla24xx_read_window(reg, 0x5D80, 16, iter_reg);
  1909. iter_reg = qla24xx_read_window(reg, 0x5D90, 16, iter_reg);
  1910. iter_reg = qla24xx_read_window(reg, 0x5DA0, 16, iter_reg);
  1911. iter_reg = qla24xx_read_window(reg, 0x5DB0, 16, iter_reg);
  1912. iter_reg = qla24xx_read_window(reg, 0x5DC0, 16, iter_reg);
  1913. iter_reg = qla24xx_read_window(reg, 0x5DD0, 16, iter_reg);
  1914. iter_reg = qla24xx_read_window(reg, 0x5DE0, 16, iter_reg);
  1915. qla24xx_read_window(reg, 0x5DF0, 16, iter_reg);
  1916. /* RP0 Array registers. */
  1917. iter_reg = fw->rp0_array_reg;
  1918. iter_reg = qla24xx_read_window(reg, 0x5E00, 16, iter_reg);
  1919. iter_reg = qla24xx_read_window(reg, 0x5E10, 16, iter_reg);
  1920. iter_reg = qla24xx_read_window(reg, 0x5E20, 16, iter_reg);
  1921. iter_reg = qla24xx_read_window(reg, 0x5E30, 16, iter_reg);
  1922. iter_reg = qla24xx_read_window(reg, 0x5E40, 16, iter_reg);
  1923. iter_reg = qla24xx_read_window(reg, 0x5E50, 16, iter_reg);
  1924. iter_reg = qla24xx_read_window(reg, 0x5E60, 16, iter_reg);
  1925. iter_reg = qla24xx_read_window(reg, 0x5E70, 16, iter_reg);
  1926. iter_reg = qla24xx_read_window(reg, 0x5E80, 16, iter_reg);
  1927. iter_reg = qla24xx_read_window(reg, 0x5E90, 16, iter_reg);
  1928. iter_reg = qla24xx_read_window(reg, 0x5EA0, 16, iter_reg);
  1929. iter_reg = qla24xx_read_window(reg, 0x5EB0, 16, iter_reg);
  1930. iter_reg = qla24xx_read_window(reg, 0x5EC0, 16, iter_reg);
  1931. iter_reg = qla24xx_read_window(reg, 0x5ED0, 16, iter_reg);
  1932. iter_reg = qla24xx_read_window(reg, 0x5EE0, 16, iter_reg);
  1933. qla24xx_read_window(reg, 0x5EF0, 16, iter_reg);
  1934. /* RP1 Array registers. */
  1935. iter_reg = fw->rp1_array_reg;
  1936. iter_reg = qla24xx_read_window(reg, 0x5F00, 16, iter_reg);
  1937. iter_reg = qla24xx_read_window(reg, 0x5F10, 16, iter_reg);
  1938. iter_reg = qla24xx_read_window(reg, 0x5F20, 16, iter_reg);
  1939. iter_reg = qla24xx_read_window(reg, 0x5F30, 16, iter_reg);
  1940. iter_reg = qla24xx_read_window(reg, 0x5F40, 16, iter_reg);
  1941. iter_reg = qla24xx_read_window(reg, 0x5F50, 16, iter_reg);
  1942. iter_reg = qla24xx_read_window(reg, 0x5F60, 16, iter_reg);
  1943. iter_reg = qla24xx_read_window(reg, 0x5F70, 16, iter_reg);
  1944. iter_reg = qla24xx_read_window(reg, 0x5F80, 16, iter_reg);
  1945. iter_reg = qla24xx_read_window(reg, 0x5F90, 16, iter_reg);
  1946. iter_reg = qla24xx_read_window(reg, 0x5FA0, 16, iter_reg);
  1947. iter_reg = qla24xx_read_window(reg, 0x5FB0, 16, iter_reg);
  1948. iter_reg = qla24xx_read_window(reg, 0x5FC0, 16, iter_reg);
  1949. iter_reg = qla24xx_read_window(reg, 0x5FD0, 16, iter_reg);
  1950. iter_reg = qla24xx_read_window(reg, 0x5FE0, 16, iter_reg);
  1951. qla24xx_read_window(reg, 0x5FF0, 16, iter_reg);
  1952. iter_reg = fw->at0_array_reg;
  1953. iter_reg = qla24xx_read_window(reg, 0x7080, 16, iter_reg);
  1954. iter_reg = qla24xx_read_window(reg, 0x7090, 16, iter_reg);
  1955. iter_reg = qla24xx_read_window(reg, 0x70A0, 16, iter_reg);
  1956. iter_reg = qla24xx_read_window(reg, 0x70B0, 16, iter_reg);
  1957. iter_reg = qla24xx_read_window(reg, 0x70C0, 16, iter_reg);
  1958. iter_reg = qla24xx_read_window(reg, 0x70D0, 16, iter_reg);
  1959. iter_reg = qla24xx_read_window(reg, 0x70E0, 16, iter_reg);
  1960. qla24xx_read_window(reg, 0x70F0, 16, iter_reg);
  1961. /* I/O Queue Control registers. */
  1962. qla24xx_read_window(reg, 0x7800, 16, fw->queue_control_reg);
  1963. /* Frame Buffer registers. */
  1964. iter_reg = fw->fb_hdw_reg;
  1965. iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
  1966. iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
  1967. iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
  1968. iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
  1969. iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
  1970. iter_reg = qla24xx_read_window(reg, 0x6060, 16, iter_reg);
  1971. iter_reg = qla24xx_read_window(reg, 0x6070, 16, iter_reg);
  1972. iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
  1973. iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
  1974. iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
  1975. iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
  1976. iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
  1977. iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
  1978. iter_reg = qla24xx_read_window(reg, 0x61C0, 16, iter_reg);
  1979. iter_reg = qla24xx_read_window(reg, 0x6530, 16, iter_reg);
  1980. iter_reg = qla24xx_read_window(reg, 0x6540, 16, iter_reg);
  1981. iter_reg = qla24xx_read_window(reg, 0x6550, 16, iter_reg);
  1982. iter_reg = qla24xx_read_window(reg, 0x6560, 16, iter_reg);
  1983. iter_reg = qla24xx_read_window(reg, 0x6570, 16, iter_reg);
  1984. iter_reg = qla24xx_read_window(reg, 0x6580, 16, iter_reg);
  1985. iter_reg = qla24xx_read_window(reg, 0x6590, 16, iter_reg);
  1986. iter_reg = qla24xx_read_window(reg, 0x65A0, 16, iter_reg);
  1987. iter_reg = qla24xx_read_window(reg, 0x65B0, 16, iter_reg);
  1988. iter_reg = qla24xx_read_window(reg, 0x65C0, 16, iter_reg);
  1989. iter_reg = qla24xx_read_window(reg, 0x65D0, 16, iter_reg);
  1990. iter_reg = qla24xx_read_window(reg, 0x65E0, 16, iter_reg);
  1991. qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
  1992. /* Multi queue registers */
  1993. nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
  1994. &last_chain);
  1995. rval = qla24xx_soft_reset(ha);
  1996. if (rval != QLA_SUCCESS) {
  1997. ql_log(ql_log_warn, vha, 0xd00e,
  1998. "SOFT RESET FAILED, forcing continuation of dump!!!\n");
  1999. rval = QLA_SUCCESS;
  2000. ql_log(ql_log_warn, vha, 0xd00f, "try a bigger hammer!!!\n");
  2001. WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET);
  2002. RD_REG_DWORD(&reg->hccr);
  2003. WRT_REG_DWORD(&reg->hccr, HCCRX_REL_RISC_PAUSE);
  2004. RD_REG_DWORD(&reg->hccr);
  2005. WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_RESET);
  2006. RD_REG_DWORD(&reg->hccr);
  2007. for (cnt = 30000; cnt && (RD_REG_WORD(&reg->mailbox0)); cnt--)
  2008. udelay(5);
  2009. if (!cnt) {
  2010. nxt = fw->code_ram;
  2011. nxt += sizeof(fw->code_ram);
  2012. nxt += (ha->fw_memory_size - 0x100000 + 1);
  2013. goto copy_queue;
  2014. } else {
  2015. set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags);
  2016. ql_log(ql_log_warn, vha, 0xd010,
  2017. "bigger hammer success?\n");
  2018. }
  2019. }
  2020. rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
  2021. &nxt);
  2022. if (rval != QLA_SUCCESS)
  2023. goto qla83xx_fw_dump_failed_0;
  2024. copy_queue:
  2025. nxt = qla2xxx_copy_queues(ha, nxt);
  2026. qla24xx_copy_eft(ha, nxt);
  2027. /* Chain entries -- started with MQ. */
  2028. nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
  2029. nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
  2030. nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
  2031. if (last_chain) {
  2032. ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
  2033. *last_chain |= htonl(DUMP_CHAIN_LAST);
  2034. }
  2035. /* Adjust valid length. */
  2036. ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
  2037. qla83xx_fw_dump_failed_0:
  2038. qla2xxx_dump_post_process(base_vha, rval);
  2039. qla83xx_fw_dump_failed:
  2040. #ifndef __CHECKER__
  2041. if (!hardware_locked)
  2042. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  2043. #else
  2044. ;
  2045. #endif
  2046. }
  2047. /****************************************************************************/
  2048. /* Driver Debug Functions. */
  2049. /****************************************************************************/
  2050. static inline int
  2051. ql_mask_match(uint32_t level)
  2052. {
  2053. if (ql2xextended_error_logging == 1)
  2054. ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK;
  2055. return (level & ql2xextended_error_logging) == level;
  2056. }
  2057. /*
  2058. * This function is for formatting and logging debug information.
  2059. * It is to be used when vha is available. It formats the message
  2060. * and logs it to the messages file.
  2061. * parameters:
  2062. * level: The level of the debug messages to be printed.
  2063. * If ql2xextended_error_logging value is correctly set,
  2064. * this message will appear in the messages file.
  2065. * vha: Pointer to the scsi_qla_host_t.
  2066. * id: This is a unique identifier for the level. It identifies the
  2067. * part of the code from where the message originated.
  2068. * msg: The message to be displayed.
  2069. */
  2070. void
  2071. ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...)
  2072. {
  2073. va_list va;
  2074. struct va_format vaf;
  2075. if (!ql_mask_match(level))
  2076. return;
  2077. va_start(va, fmt);
  2078. vaf.fmt = fmt;
  2079. vaf.va = &va;
  2080. if (vha != NULL) {
  2081. const struct pci_dev *pdev = vha->hw->pdev;
  2082. /* <module-name> <pci-name> <msg-id>:<host> Message */
  2083. pr_warn("%s [%s]-%04x:%ld: %pV",
  2084. QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset,
  2085. vha->host_no, &vaf);
  2086. } else {
  2087. pr_warn("%s [%s]-%04x: : %pV",
  2088. QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf);
  2089. }
  2090. va_end(va);
  2091. }
  2092. /*
  2093. * This function is for formatting and logging debug information.
  2094. * It is to be used when vha is not available and pci is available,
  2095. * i.e., before host allocation. It formats the message and logs it
  2096. * to the messages file.
  2097. * parameters:
  2098. * level: The level of the debug messages to be printed.
  2099. * If ql2xextended_error_logging value is correctly set,
  2100. * this message will appear in the messages file.
  2101. * pdev: Pointer to the struct pci_dev.
  2102. * id: This is a unique id for the level. It identifies the part
  2103. * of the code from where the message originated.
  2104. * msg: The message to be displayed.
  2105. */
  2106. void
  2107. ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id,
  2108. const char *fmt, ...)
  2109. {
  2110. va_list va;
  2111. struct va_format vaf;
  2112. if (pdev == NULL)
  2113. return;
  2114. if (!ql_mask_match(level))
  2115. return;
  2116. va_start(va, fmt);
  2117. vaf.fmt = fmt;
  2118. vaf.va = &va;
  2119. /* <module-name> <dev-name>:<msg-id> Message */
  2120. pr_warn("%s [%s]-%04x: : %pV",
  2121. QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, &vaf);
  2122. va_end(va);
  2123. }
  2124. /*
  2125. * This function is for formatting and logging log messages.
  2126. * It is to be used when vha is available. It formats the message
  2127. * and logs it to the messages file. All the messages will be logged
  2128. * irrespective of value of ql2xextended_error_logging.
  2129. * parameters:
  2130. * level: The level of the log messages to be printed in the
  2131. * messages file.
  2132. * vha: Pointer to the scsi_qla_host_t
  2133. * id: This is a unique id for the level. It identifies the
  2134. * part of the code from where the message originated.
  2135. * msg: The message to be displayed.
  2136. */
  2137. void
  2138. ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...)
  2139. {
  2140. va_list va;
  2141. struct va_format vaf;
  2142. char pbuf[128];
  2143. if (level > ql_errlev)
  2144. return;
  2145. if (vha != NULL) {
  2146. const struct pci_dev *pdev = vha->hw->pdev;
  2147. /* <module-name> <msg-id>:<host> Message */
  2148. snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ",
  2149. QL_MSGHDR, dev_name(&(pdev->dev)), id, vha->host_no);
  2150. } else {
  2151. snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
  2152. QL_MSGHDR, "0000:00:00.0", id);
  2153. }
  2154. pbuf[sizeof(pbuf) - 1] = 0;
  2155. va_start(va, fmt);
  2156. vaf.fmt = fmt;
  2157. vaf.va = &va;
  2158. switch (level) {
  2159. case ql_log_fatal: /* FATAL LOG */
  2160. pr_crit("%s%pV", pbuf, &vaf);
  2161. break;
  2162. case ql_log_warn:
  2163. pr_err("%s%pV", pbuf, &vaf);
  2164. break;
  2165. case ql_log_info:
  2166. pr_warn("%s%pV", pbuf, &vaf);
  2167. break;
  2168. default:
  2169. pr_info("%s%pV", pbuf, &vaf);
  2170. break;
  2171. }
  2172. va_end(va);
  2173. }
  2174. /*
  2175. * This function is for formatting and logging log messages.
  2176. * It is to be used when vha is not available and pci is available,
  2177. * i.e., before host allocation. It formats the message and logs
  2178. * it to the messages file. All the messages are logged irrespective
  2179. * of the value of ql2xextended_error_logging.
  2180. * parameters:
  2181. * level: The level of the log messages to be printed in the
  2182. * messages file.
  2183. * pdev: Pointer to the struct pci_dev.
  2184. * id: This is a unique id for the level. It identifies the
  2185. * part of the code from where the message originated.
  2186. * msg: The message to be displayed.
  2187. */
  2188. void
  2189. ql_log_pci(uint32_t level, struct pci_dev *pdev, int32_t id,
  2190. const char *fmt, ...)
  2191. {
  2192. va_list va;
  2193. struct va_format vaf;
  2194. char pbuf[128];
  2195. if (pdev == NULL)
  2196. return;
  2197. if (level > ql_errlev)
  2198. return;
  2199. /* <module-name> <dev-name>:<msg-id> Message */
  2200. snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
  2201. QL_MSGHDR, dev_name(&(pdev->dev)), id);
  2202. pbuf[sizeof(pbuf) - 1] = 0;
  2203. va_start(va, fmt);
  2204. vaf.fmt = fmt;
  2205. vaf.va = &va;
  2206. switch (level) {
  2207. case ql_log_fatal: /* FATAL LOG */
  2208. pr_crit("%s%pV", pbuf, &vaf);
  2209. break;
  2210. case ql_log_warn:
  2211. pr_err("%s%pV", pbuf, &vaf);
  2212. break;
  2213. case ql_log_info:
  2214. pr_warn("%s%pV", pbuf, &vaf);
  2215. break;
  2216. default:
  2217. pr_info("%s%pV", pbuf, &vaf);
  2218. break;
  2219. }
  2220. va_end(va);
  2221. }
  2222. void
  2223. ql_dump_regs(uint32_t level, scsi_qla_host_t *vha, int32_t id)
  2224. {
  2225. int i;
  2226. struct qla_hw_data *ha = vha->hw;
  2227. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  2228. struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
  2229. struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82;
  2230. uint16_t __iomem *mbx_reg;
  2231. if (!ql_mask_match(level))
  2232. return;
  2233. if (IS_P3P_TYPE(ha))
  2234. mbx_reg = &reg82->mailbox_in[0];
  2235. else if (IS_FWI2_CAPABLE(ha))
  2236. mbx_reg = &reg24->mailbox0;
  2237. else
  2238. mbx_reg = MAILBOX_REG(ha, reg, 0);
  2239. ql_dbg(level, vha, id, "Mailbox registers:\n");
  2240. for (i = 0; i < 6; i++)
  2241. ql_dbg(level, vha, id,
  2242. "mbox[%d] 0x%04x\n", i, RD_REG_WORD(mbx_reg++));
  2243. }
  2244. void
  2245. ql_dump_buffer(uint32_t level, scsi_qla_host_t *vha, int32_t id,
  2246. uint8_t *buf, uint size)
  2247. {
  2248. uint cnt;
  2249. if (!ql_mask_match(level))
  2250. return;
  2251. ql_dbg(level, vha, id,
  2252. "%-+5d 0 1 2 3 4 5 6 7 8 9 A B C D E F\n", size);
  2253. ql_dbg(level, vha, id,
  2254. "----- -----------------------------------------------\n");
  2255. for (cnt = 0; cnt < size; cnt += 16) {
  2256. ql_dbg(level, vha, id, "%04x: ", cnt);
  2257. print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1,
  2258. buf + cnt, min(16U, size - cnt), false);
  2259. }
  2260. }