qla_dbg.c 88 KB

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