blob: 4f478364fa435f7ab68c0761a47831c39ab626f5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Andrew Vasquezfa90c542005-10-27 11:10:08 -07002 * QLogic Fibre Channel HBA Driver
Andrew Vasquez01e58d82008-04-03 13:13:13 -07003 * Copyright (c) 2003-2008 QLogic Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Andrew Vasquezfa90c542005-10-27 11:10:08 -07005 * See LICENSE.qla2xxx for copyright and licensing details.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#include "qla_def.h"
8
9#include <linux/delay.h>
10
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070011static inline void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080012qla2xxx_prep_dump(struct qla_hw_data *ha, struct qla2xxx_fw_dump *fw_dump)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070013{
14 fw_dump->fw_major_version = htonl(ha->fw_major_version);
15 fw_dump->fw_minor_version = htonl(ha->fw_minor_version);
16 fw_dump->fw_subminor_version = htonl(ha->fw_subminor_version);
17 fw_dump->fw_attributes = htonl(ha->fw_attributes);
18
19 fw_dump->vendor = htonl(ha->pdev->vendor);
20 fw_dump->device = htonl(ha->pdev->device);
21 fw_dump->subsystem_vendor = htonl(ha->pdev->subsystem_vendor);
22 fw_dump->subsystem_device = htonl(ha->pdev->subsystem_device);
23}
24
25static inline void *
Anirban Chakraborty73208df2008-12-09 16:45:39 -080026qla2xxx_copy_queues(struct qla_hw_data *ha, void *ptr)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070027{
Anirban Chakraborty73208df2008-12-09 16:45:39 -080028 struct req_que *req = ha->req_q_map[0];
29 struct rsp_que *rsp = ha->rsp_q_map[0];
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070030 /* Request queue. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080031 memcpy(ptr, req->ring, req->length *
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070032 sizeof(request_t));
33
34 /* Response queue. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080035 ptr += req->length * sizeof(request_t);
36 memcpy(ptr, rsp->ring, rsp->length *
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070037 sizeof(response_t));
38
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080039 return ptr + (rsp->length * sizeof(response_t));
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070040}
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070042static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080043qla24xx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint32_t *ram,
Andrew Vasquezc5722702008-04-24 15:21:22 -070044 uint32_t ram_dwords, void **nxt)
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070045{
46 int rval;
Andrew Vasquezc5722702008-04-24 15:21:22 -070047 uint32_t cnt, stat, timer, dwords, idx;
48 uint16_t mb0;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070049 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
Andrew Vasquezc5722702008-04-24 15:21:22 -070050 dma_addr_t dump_dma = ha->gid_list_dma;
51 uint32_t *dump = (uint32_t *)ha->gid_list;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070052
53 rval = QLA_SUCCESS;
Andrew Vasquezc5722702008-04-24 15:21:22 -070054 mb0 = 0;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070055
Andrew Vasquezc5722702008-04-24 15:21:22 -070056 WRT_REG_WORD(&reg->mailbox0, MBC_DUMP_RISC_RAM_EXTENDED);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070057 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
58
Andrew Vasquezc5722702008-04-24 15:21:22 -070059 dwords = GID_LIST_SIZE / 4;
60 for (cnt = 0; cnt < ram_dwords && rval == QLA_SUCCESS;
61 cnt += dwords, addr += dwords) {
62 if (cnt + dwords > ram_dwords)
63 dwords = ram_dwords - cnt;
64
65 WRT_REG_WORD(&reg->mailbox1, LSW(addr));
66 WRT_REG_WORD(&reg->mailbox8, MSW(addr));
67
68 WRT_REG_WORD(&reg->mailbox2, MSW(dump_dma));
69 WRT_REG_WORD(&reg->mailbox3, LSW(dump_dma));
70 WRT_REG_WORD(&reg->mailbox6, MSW(MSD(dump_dma)));
71 WRT_REG_WORD(&reg->mailbox7, LSW(MSD(dump_dma)));
72
73 WRT_REG_WORD(&reg->mailbox4, MSW(dwords));
74 WRT_REG_WORD(&reg->mailbox5, LSW(dwords));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070075 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
76
77 for (timer = 6000000; timer; timer--) {
78 /* Check for pending interrupts. */
79 stat = RD_REG_DWORD(&reg->host_status);
80 if (stat & HSRX_RISC_INT) {
81 stat &= 0xff;
82
83 if (stat == 0x1 || stat == 0x2 ||
84 stat == 0x10 || stat == 0x11) {
85 set_bit(MBX_INTERRUPT,
86 &ha->mbx_cmd_flags);
87
Andrew Vasquezc5722702008-04-24 15:21:22 -070088 mb0 = RD_REG_WORD(&reg->mailbox0);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -070089
90 WRT_REG_DWORD(&reg->hccr,
91 HCCRX_CLR_RISC_INT);
92 RD_REG_DWORD(&reg->hccr);
93 break;
94 }
95
96 /* Clear this intr; it wasn't a mailbox intr */
97 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
98 RD_REG_DWORD(&reg->hccr);
99 }
100 udelay(5);
101 }
102
103 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
Andrew Vasquezc5722702008-04-24 15:21:22 -0700104 rval = mb0 & MBS_MASK;
105 for (idx = 0; idx < dwords; idx++)
106 ram[cnt + idx] = swab32(dump[idx]);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700107 } else {
108 rval = QLA_FUNCTION_FAILED;
109 }
110 }
111
Andrew Vasquezc5722702008-04-24 15:21:22 -0700112 *nxt = rval == QLA_SUCCESS ? &ram[cnt]: NULL;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700113 return rval;
114}
115
Andrew Vasquezc5722702008-04-24 15:21:22 -0700116static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800117qla24xx_dump_memory(struct qla_hw_data *ha, uint32_t *code_ram,
Andrew Vasquezc5722702008-04-24 15:21:22 -0700118 uint32_t cram_size, void **nxt)
119{
120 int rval;
121
122 /* Code RAM. */
123 rval = qla24xx_dump_ram(ha, 0x20000, code_ram, cram_size / 4, nxt);
124 if (rval != QLA_SUCCESS)
125 return rval;
126
127 /* External Memory. */
128 return qla24xx_dump_ram(ha, 0x100000, *nxt,
129 ha->fw_memory_size - 0x100000 + 1, nxt);
130}
131
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700132static uint32_t *
133qla24xx_read_window(struct device_reg_24xx __iomem *reg, uint32_t iobase,
134 uint32_t count, uint32_t *buf)
135{
136 uint32_t __iomem *dmp_reg;
137
138 WRT_REG_DWORD(&reg->iobase_addr, iobase);
139 dmp_reg = &reg->iobase_window;
140 while (count--)
141 *buf++ = htonl(RD_REG_DWORD(dmp_reg++));
142
143 return buf;
144}
145
146static inline int
147qla24xx_pause_risc(struct device_reg_24xx __iomem *reg)
148{
149 int rval = QLA_SUCCESS;
150 uint32_t cnt;
151
Andrew Vasquezc3b058a2007-09-20 14:07:38 -0700152 if (RD_REG_DWORD(&reg->hccr) & HCCRX_RISC_PAUSE)
153 return rval;
154
155 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_PAUSE);
156 for (cnt = 30000; (RD_REG_DWORD(&reg->hccr) & HCCRX_RISC_PAUSE) == 0 &&
157 rval == QLA_SUCCESS; cnt--) {
158 if (cnt)
159 udelay(100);
160 else
161 rval = QLA_FUNCTION_TIMEOUT;
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700162 }
163
164 return rval;
165}
166
167static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800168qla24xx_soft_reset(struct qla_hw_data *ha)
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700169{
170 int rval = QLA_SUCCESS;
171 uint32_t cnt;
172 uint16_t mb0, wd;
173 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
174
175 /* Reset RISC. */
176 WRT_REG_DWORD(&reg->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
177 for (cnt = 0; cnt < 30000; cnt++) {
178 if ((RD_REG_DWORD(&reg->ctrl_status) & CSRX_DMA_ACTIVE) == 0)
179 break;
180
181 udelay(10);
182 }
183
184 WRT_REG_DWORD(&reg->ctrl_status,
185 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
186 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
187
188 udelay(100);
189 /* Wait for firmware to complete NVRAM accesses. */
190 mb0 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
191 for (cnt = 10000 ; cnt && mb0; cnt--) {
192 udelay(5);
193 mb0 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
194 barrier();
195 }
196
197 /* Wait for soft-reset to complete. */
198 for (cnt = 0; cnt < 30000; cnt++) {
199 if ((RD_REG_DWORD(&reg->ctrl_status) &
200 CSRX_ISP_SOFT_RESET) == 0)
201 break;
202
203 udelay(10);
204 }
205 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_RESET);
206 RD_REG_DWORD(&reg->hccr); /* PCI Posting. */
207
208 for (cnt = 30000; RD_REG_WORD(&reg->mailbox0) != 0 &&
209 rval == QLA_SUCCESS; cnt--) {
210 if (cnt)
211 udelay(100);
212 else
213 rval = QLA_FUNCTION_TIMEOUT;
214 }
215
216 return rval;
217}
218
Andrew Vasquezc5722702008-04-24 15:21:22 -0700219static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800220qla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint16_t *ram,
221 uint16_t ram_words, void **nxt)
Andrew Vasquezc5722702008-04-24 15:21:22 -0700222{
223 int rval;
224 uint32_t cnt, stat, timer, words, idx;
225 uint16_t mb0;
226 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
227 dma_addr_t dump_dma = ha->gid_list_dma;
228 uint16_t *dump = (uint16_t *)ha->gid_list;
229
230 rval = QLA_SUCCESS;
231 mb0 = 0;
232
233 WRT_MAILBOX_REG(ha, reg, 0, MBC_DUMP_RISC_RAM_EXTENDED);
234 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
235
236 words = GID_LIST_SIZE / 2;
237 for (cnt = 0; cnt < ram_words && rval == QLA_SUCCESS;
238 cnt += words, addr += words) {
239 if (cnt + words > ram_words)
240 words = ram_words - cnt;
241
242 WRT_MAILBOX_REG(ha, reg, 1, LSW(addr));
243 WRT_MAILBOX_REG(ha, reg, 8, MSW(addr));
244
245 WRT_MAILBOX_REG(ha, reg, 2, MSW(dump_dma));
246 WRT_MAILBOX_REG(ha, reg, 3, LSW(dump_dma));
247 WRT_MAILBOX_REG(ha, reg, 6, MSW(MSD(dump_dma)));
248 WRT_MAILBOX_REG(ha, reg, 7, LSW(MSD(dump_dma)));
249
250 WRT_MAILBOX_REG(ha, reg, 4, words);
251 WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
252
253 for (timer = 6000000; timer; timer--) {
254 /* Check for pending interrupts. */
255 stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
256 if (stat & HSR_RISC_INT) {
257 stat &= 0xff;
258
259 if (stat == 0x1 || stat == 0x2) {
260 set_bit(MBX_INTERRUPT,
261 &ha->mbx_cmd_flags);
262
263 mb0 = RD_MAILBOX_REG(ha, reg, 0);
264
265 /* Release mailbox registers. */
266 WRT_REG_WORD(&reg->semaphore, 0);
267 WRT_REG_WORD(&reg->hccr,
268 HCCR_CLR_RISC_INT);
269 RD_REG_WORD(&reg->hccr);
270 break;
271 } else if (stat == 0x10 || stat == 0x11) {
272 set_bit(MBX_INTERRUPT,
273 &ha->mbx_cmd_flags);
274
275 mb0 = RD_MAILBOX_REG(ha, reg, 0);
276
277 WRT_REG_WORD(&reg->hccr,
278 HCCR_CLR_RISC_INT);
279 RD_REG_WORD(&reg->hccr);
280 break;
281 }
282
283 /* clear this intr; it wasn't a mailbox intr */
284 WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
285 RD_REG_WORD(&reg->hccr);
286 }
287 udelay(5);
288 }
289
290 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
291 rval = mb0 & MBS_MASK;
292 for (idx = 0; idx < words; idx++)
293 ram[cnt + idx] = swab16(dump[idx]);
294 } else {
295 rval = QLA_FUNCTION_FAILED;
296 }
297 }
298
299 *nxt = rval == QLA_SUCCESS ? &ram[cnt]: NULL;
300 return rval;
301}
302
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700303static inline void
304qla2xxx_read_window(struct device_reg_2xxx __iomem *reg, uint32_t count,
305 uint16_t *buf)
306{
307 uint16_t __iomem *dmp_reg = &reg->u.isp2300.fb_cmd;
308
309 while (count--)
310 *buf++ = htons(RD_REG_WORD(dmp_reg++));
311}
312
Andrew Vasquezbb99de62009-01-05 11:18:08 -0800313static inline void *
314qla24xx_copy_eft(struct qla_hw_data *ha, void *ptr)
315{
316 if (!ha->eft)
317 return ptr;
318
319 memcpy(ptr, ha->eft, ntohl(ha->fw_dump->eft_size));
320 return ptr + ntohl(ha->fw_dump->eft_size);
321}
322
323static inline void *
324qla25xx_copy_fce(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
325{
326 uint32_t cnt;
327 uint32_t *iter_reg;
328 struct qla2xxx_fce_chain *fcec = ptr;
329
330 if (!ha->fce)
331 return ptr;
332
333 *last_chain = &fcec->type;
334 fcec->type = __constant_htonl(DUMP_CHAIN_FCE);
335 fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
336 fce_calc_size(ha->fce_bufs));
337 fcec->size = htonl(fce_calc_size(ha->fce_bufs));
338 fcec->addr_l = htonl(LSD(ha->fce_dma));
339 fcec->addr_h = htonl(MSD(ha->fce_dma));
340
341 iter_reg = fcec->eregs;
342 for (cnt = 0; cnt < 8; cnt++)
343 *iter_reg++ = htonl(ha->fce_mb[cnt]);
344
345 memcpy(iter_reg, ha->fce, ntohl(fcec->size));
346
347 return iter_reg;
348}
349
Andrew Vasquezd63ab532009-01-05 11:18:09 -0800350static inline void *
351qla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
352{
353 uint32_t cnt, que_idx;
354 uint8_t req_cnt, rsp_cnt, que_cnt;
355 struct qla2xxx_mq_chain *mq = ptr;
356 struct device_reg_25xxmq __iomem *reg;
357
358 if (!ha->mqenable)
359 return ptr;
360
361 mq = ptr;
362 *last_chain = &mq->type;
363 mq->type = __constant_htonl(DUMP_CHAIN_MQ);
364 mq->chain_size = __constant_htonl(sizeof(struct qla2xxx_mq_chain));
365
366 req_cnt = find_first_zero_bit(ha->req_qid_map, ha->max_queues);
367 rsp_cnt = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues);
368 que_cnt = req_cnt > rsp_cnt ? req_cnt : rsp_cnt;
369 mq->count = htonl(que_cnt);
370 for (cnt = 0; cnt < que_cnt; cnt++) {
371 reg = (struct device_reg_25xxmq *) ((void *)
372 ha->mqiobase + cnt * QLA_QUE_PAGE);
373 que_idx = cnt * 4;
374 mq->qregs[que_idx] = htonl(RD_REG_DWORD(&reg->req_q_in));
375 mq->qregs[que_idx+1] = htonl(RD_REG_DWORD(&reg->req_q_out));
376 mq->qregs[que_idx+2] = htonl(RD_REG_DWORD(&reg->rsp_q_in));
377 mq->qregs[que_idx+3] = htonl(RD_REG_DWORD(&reg->rsp_q_out));
378 }
379
380 return ptr + sizeof(struct qla2xxx_mq_chain);
381}
382
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383/**
384 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
385 * @ha: HA context
386 * @hardware_locked: Called with the hardware_lock
387 */
388void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800389qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390{
391 int rval;
Andrew Vasquezc5722702008-04-24 15:21:22 -0700392 uint32_t cnt;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800393 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez3d716442005-07-06 10:30:26 -0700394 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 uint16_t __iomem *dmp_reg;
396 unsigned long flags;
397 struct qla2300_fw_dump *fw;
Andrew Vasquezc5722702008-04-24 15:21:22 -0700398 void *nxt;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800399 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 flags = 0;
402
403 if (!hardware_locked)
404 spin_lock_irqsave(&ha->hardware_lock, flags);
405
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700406 if (!ha->fw_dump) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 qla_printk(KERN_WARNING, ha,
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700408 "No buffer available for dump!!!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 goto qla2300_fw_dump_failed;
410 }
411
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700412 if (ha->fw_dumped) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 qla_printk(KERN_WARNING, ha,
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700414 "Firmware has been previously dumped (%p) -- ignoring "
415 "request...\n", ha->fw_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 goto qla2300_fw_dump_failed;
417 }
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700418 fw = &ha->fw_dump->isp.isp23;
419 qla2xxx_prep_dump(ha, ha->fw_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
421 rval = QLA_SUCCESS;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700422 fw->hccr = htons(RD_REG_WORD(&reg->hccr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424 /* Pause RISC. */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700425 WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 if (IS_QLA2300(ha)) {
427 for (cnt = 30000;
428 (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
429 rval == QLA_SUCCESS; cnt--) {
430 if (cnt)
431 udelay(100);
432 else
433 rval = QLA_FUNCTION_TIMEOUT;
434 }
435 } else {
436 RD_REG_WORD(&reg->hccr); /* PCI Posting. */
437 udelay(10);
438 }
439
440 if (rval == QLA_SUCCESS) {
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700441 dmp_reg = &reg->flash_address;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700442 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700443 fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700445 dmp_reg = &reg->u.isp2300.req_q_in;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700446 for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700447 fw->risc_host_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700449 dmp_reg = &reg->u.isp2300.mailbox0;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700450 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700451 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
453 WRT_REG_WORD(&reg->ctrl_status, 0x40);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700454 qla2xxx_read_window(reg, 32, fw->resp_dma_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 WRT_REG_WORD(&reg->ctrl_status, 0x50);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700457 qla2xxx_read_window(reg, 48, fw->dma_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
459 WRT_REG_WORD(&reg->ctrl_status, 0x00);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700460 dmp_reg = &reg->risc_hw;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700461 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700462 fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700464 WRT_REG_WORD(&reg->pcr, 0x2000);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700465 qla2xxx_read_window(reg, 16, fw->risc_gp0_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700467 WRT_REG_WORD(&reg->pcr, 0x2200);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700468 qla2xxx_read_window(reg, 16, fw->risc_gp1_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700470 WRT_REG_WORD(&reg->pcr, 0x2400);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700471 qla2xxx_read_window(reg, 16, fw->risc_gp2_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700473 WRT_REG_WORD(&reg->pcr, 0x2600);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700474 qla2xxx_read_window(reg, 16, fw->risc_gp3_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700476 WRT_REG_WORD(&reg->pcr, 0x2800);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700477 qla2xxx_read_window(reg, 16, fw->risc_gp4_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700479 WRT_REG_WORD(&reg->pcr, 0x2A00);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700480 qla2xxx_read_window(reg, 16, fw->risc_gp5_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700482 WRT_REG_WORD(&reg->pcr, 0x2C00);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700483 qla2xxx_read_window(reg, 16, fw->risc_gp6_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700485 WRT_REG_WORD(&reg->pcr, 0x2E00);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700486 qla2xxx_read_window(reg, 16, fw->risc_gp7_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700488 WRT_REG_WORD(&reg->ctrl_status, 0x10);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700489 qla2xxx_read_window(reg, 64, fw->frame_buf_hdw_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700491 WRT_REG_WORD(&reg->ctrl_status, 0x20);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700492 qla2xxx_read_window(reg, 64, fw->fpm_b0_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700494 WRT_REG_WORD(&reg->ctrl_status, 0x30);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700495 qla2xxx_read_window(reg, 64, fw->fpm_b1_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
497 /* Reset RISC. */
498 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
499 for (cnt = 0; cnt < 30000; cnt++) {
500 if ((RD_REG_WORD(&reg->ctrl_status) &
501 CSR_ISP_SOFT_RESET) == 0)
502 break;
503
504 udelay(10);
505 }
506 }
507
508 if (!IS_QLA2300(ha)) {
509 for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
510 rval == QLA_SUCCESS; cnt--) {
511 if (cnt)
512 udelay(100);
513 else
514 rval = QLA_FUNCTION_TIMEOUT;
515 }
516 }
517
Andrew Vasquezc5722702008-04-24 15:21:22 -0700518 /* Get RISC SRAM. */
519 if (rval == QLA_SUCCESS)
520 rval = qla2xxx_dump_ram(ha, 0x800, fw->risc_ram,
521 sizeof(fw->risc_ram) / 2, &nxt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522
Andrew Vasquezc5722702008-04-24 15:21:22 -0700523 /* Get stack SRAM. */
524 if (rval == QLA_SUCCESS)
525 rval = qla2xxx_dump_ram(ha, 0x10000, fw->stack_ram,
526 sizeof(fw->stack_ram) / 2, &nxt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527
Andrew Vasquezc5722702008-04-24 15:21:22 -0700528 /* Get data SRAM. */
529 if (rval == QLA_SUCCESS)
530 rval = qla2xxx_dump_ram(ha, 0x11000, fw->data_ram,
531 ha->fw_memory_size - 0x11000 + 1, &nxt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700533 if (rval == QLA_SUCCESS)
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800534 qla2xxx_copy_queues(ha, nxt);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700535
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 if (rval != QLA_SUCCESS) {
537 qla_printk(KERN_WARNING, ha,
538 "Failed to dump firmware (%x)!!!\n", rval);
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700539 ha->fw_dumped = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 } else {
542 qla_printk(KERN_INFO, ha,
543 "Firmware dump saved to temp buffer (%ld/%p).\n",
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800544 base_vha->host_no, ha->fw_dump);
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700545 ha->fw_dumped = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 }
547
548qla2300_fw_dump_failed:
549 if (!hardware_locked)
550 spin_unlock_irqrestore(&ha->hardware_lock, flags);
551}
552
553/**
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
555 * @ha: HA context
556 * @hardware_locked: Called with the hardware_lock
557 */
558void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800559qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560{
561 int rval;
562 uint32_t cnt, timer;
563 uint16_t risc_address;
564 uint16_t mb0, mb2;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800565 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez3d716442005-07-06 10:30:26 -0700566 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 uint16_t __iomem *dmp_reg;
568 unsigned long flags;
569 struct qla2100_fw_dump *fw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800570 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571
572 risc_address = 0;
573 mb0 = mb2 = 0;
574 flags = 0;
575
576 if (!hardware_locked)
577 spin_lock_irqsave(&ha->hardware_lock, flags);
578
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700579 if (!ha->fw_dump) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 qla_printk(KERN_WARNING, ha,
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700581 "No buffer available for dump!!!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 goto qla2100_fw_dump_failed;
583 }
584
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700585 if (ha->fw_dumped) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 qla_printk(KERN_WARNING, ha,
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700587 "Firmware has been previously dumped (%p) -- ignoring "
588 "request...\n", ha->fw_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 goto qla2100_fw_dump_failed;
590 }
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700591 fw = &ha->fw_dump->isp.isp21;
592 qla2xxx_prep_dump(ha, ha->fw_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
594 rval = QLA_SUCCESS;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700595 fw->hccr = htons(RD_REG_WORD(&reg->hccr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596
597 /* Pause RISC. */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700598 WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 for (cnt = 30000; (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
600 rval == QLA_SUCCESS; cnt--) {
601 if (cnt)
602 udelay(100);
603 else
604 rval = QLA_FUNCTION_TIMEOUT;
605 }
606 if (rval == QLA_SUCCESS) {
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700607 dmp_reg = &reg->flash_address;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700608 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700609 fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700611 dmp_reg = &reg->u.isp2100.mailbox0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700613 if (cnt == 8)
614 dmp_reg = &reg->u_end.isp2200.mailbox8;
615
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700616 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 }
618
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700619 dmp_reg = &reg->u.isp2100.unused_2[0];
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700620 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700621 fw->dma_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
623 WRT_REG_WORD(&reg->ctrl_status, 0x00);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700624 dmp_reg = &reg->risc_hw;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700625 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++)
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700626 fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700628 WRT_REG_WORD(&reg->pcr, 0x2000);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700629 qla2xxx_read_window(reg, 16, fw->risc_gp0_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700631 WRT_REG_WORD(&reg->pcr, 0x2100);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700632 qla2xxx_read_window(reg, 16, fw->risc_gp1_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700634 WRT_REG_WORD(&reg->pcr, 0x2200);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700635 qla2xxx_read_window(reg, 16, fw->risc_gp2_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700637 WRT_REG_WORD(&reg->pcr, 0x2300);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700638 qla2xxx_read_window(reg, 16, fw->risc_gp3_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700640 WRT_REG_WORD(&reg->pcr, 0x2400);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700641 qla2xxx_read_window(reg, 16, fw->risc_gp4_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700643 WRT_REG_WORD(&reg->pcr, 0x2500);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700644 qla2xxx_read_window(reg, 16, fw->risc_gp5_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700646 WRT_REG_WORD(&reg->pcr, 0x2600);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700647 qla2xxx_read_window(reg, 16, fw->risc_gp6_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700649 WRT_REG_WORD(&reg->pcr, 0x2700);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700650 qla2xxx_read_window(reg, 16, fw->risc_gp7_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700652 WRT_REG_WORD(&reg->ctrl_status, 0x10);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700653 qla2xxx_read_window(reg, 16, fw->frame_buf_hdw_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700655 WRT_REG_WORD(&reg->ctrl_status, 0x20);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700656 qla2xxx_read_window(reg, 64, fw->fpm_b0_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700658 WRT_REG_WORD(&reg->ctrl_status, 0x30);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700659 qla2xxx_read_window(reg, 64, fw->fpm_b1_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660
661 /* Reset the ISP. */
662 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
663 }
664
665 for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
666 rval == QLA_SUCCESS; cnt--) {
667 if (cnt)
668 udelay(100);
669 else
670 rval = QLA_FUNCTION_TIMEOUT;
671 }
672
673 /* Pause RISC. */
674 if (rval == QLA_SUCCESS && (IS_QLA2200(ha) || (IS_QLA2100(ha) &&
675 (RD_REG_WORD(&reg->mctr) & (BIT_1 | BIT_0)) != 0))) {
676
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700677 WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 for (cnt = 30000;
679 (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
680 rval == QLA_SUCCESS; cnt--) {
681 if (cnt)
682 udelay(100);
683 else
684 rval = QLA_FUNCTION_TIMEOUT;
685 }
686 if (rval == QLA_SUCCESS) {
687 /* Set memory configuration and timing. */
688 if (IS_QLA2100(ha))
689 WRT_REG_WORD(&reg->mctr, 0xf1);
690 else
691 WRT_REG_WORD(&reg->mctr, 0xf2);
692 RD_REG_WORD(&reg->mctr); /* PCI Posting. */
693
694 /* Release RISC. */
695 WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
696 }
697 }
698
699 if (rval == QLA_SUCCESS) {
700 /* Get RISC SRAM. */
701 risc_address = 0x1000;
702 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
703 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
704 }
705 for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
706 cnt++, risc_address++) {
707 WRT_MAILBOX_REG(ha, reg, 1, risc_address);
708 WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
709
710 for (timer = 6000000; timer != 0; timer--) {
711 /* Check for pending interrupts. */
712 if (RD_REG_WORD(&reg->istatus) & ISR_RISC_INT) {
713 if (RD_REG_WORD(&reg->semaphore) & BIT_0) {
714 set_bit(MBX_INTERRUPT,
715 &ha->mbx_cmd_flags);
716
717 mb0 = RD_MAILBOX_REG(ha, reg, 0);
718 mb2 = RD_MAILBOX_REG(ha, reg, 2);
719
720 WRT_REG_WORD(&reg->semaphore, 0);
721 WRT_REG_WORD(&reg->hccr,
722 HCCR_CLR_RISC_INT);
723 RD_REG_WORD(&reg->hccr);
724 break;
725 }
726 WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
727 RD_REG_WORD(&reg->hccr);
728 }
729 udelay(5);
730 }
731
732 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
733 rval = mb0 & MBS_MASK;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700734 fw->risc_ram[cnt] = htons(mb2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 } else {
736 rval = QLA_FUNCTION_FAILED;
737 }
738 }
739
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700740 if (rval == QLA_SUCCESS)
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800741 qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700742
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 if (rval != QLA_SUCCESS) {
744 qla_printk(KERN_WARNING, ha,
745 "Failed to dump firmware (%x)!!!\n", rval);
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700746 ha->fw_dumped = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 } else {
749 qla_printk(KERN_INFO, ha,
750 "Firmware dump saved to temp buffer (%ld/%p).\n",
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800751 base_vha->host_no, ha->fw_dump);
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700752 ha->fw_dumped = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 }
754
755qla2100_fw_dump_failed:
756 if (!hardware_locked)
757 spin_unlock_irqrestore(&ha->hardware_lock, flags);
758}
759
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700760void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800761qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700762{
763 int rval;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700764 uint32_t cnt;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700765 uint32_t risc_address;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800766 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700767 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
768 uint32_t __iomem *dmp_reg;
769 uint32_t *iter_reg;
770 uint16_t __iomem *mbx_reg;
771 unsigned long flags;
772 struct qla24xx_fw_dump *fw;
773 uint32_t ext_mem_cnt;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700774 void *nxt;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800775 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700776
777 risc_address = ext_mem_cnt = 0;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700778 flags = 0;
779
780 if (!hardware_locked)
781 spin_lock_irqsave(&ha->hardware_lock, flags);
782
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700783 if (!ha->fw_dump) {
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700784 qla_printk(KERN_WARNING, ha,
785 "No buffer available for dump!!!\n");
786 goto qla24xx_fw_dump_failed;
787 }
788
789 if (ha->fw_dumped) {
790 qla_printk(KERN_WARNING, ha,
791 "Firmware has been previously dumped (%p) -- ignoring "
Andrew Vasquezd4e3e042006-05-17 15:09:50 -0700792 "request...\n", ha->fw_dump);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700793 goto qla24xx_fw_dump_failed;
794 }
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700795 fw = &ha->fw_dump->isp.isp24;
796 qla2xxx_prep_dump(ha, ha->fw_dump);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700797
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700798 fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700799
800 /* Pause RISC. */
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700801 rval = qla24xx_pause_risc(reg);
802 if (rval != QLA_SUCCESS)
803 goto qla24xx_fw_dump_failed_0;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700804
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700805 /* Host interface registers. */
806 dmp_reg = &reg->flash_addr;
807 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
808 fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700809
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700810 /* Disable interrupts. */
811 WRT_REG_DWORD(&reg->ictrl, 0);
812 RD_REG_DWORD(&reg->ictrl);
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800813
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700814 /* Shadow registers. */
815 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
816 RD_REG_DWORD(&reg->iobase_addr);
817 WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
818 fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800819
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700820 WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
821 fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800822
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700823 WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
824 fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800825
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700826 WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
827 fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800828
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700829 WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
830 fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800831
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700832 WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
833 fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800834
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700835 WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
836 fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800837
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700838 /* Mailbox registers. */
839 mbx_reg = &reg->mailbox0;
840 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
841 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++));
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700842
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700843 /* Transfer sequence registers. */
844 iter_reg = fw->xseq_gp_reg;
845 iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
846 iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
847 iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
848 iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
849 iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
850 iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
851 iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
852 qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700853
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700854 qla24xx_read_window(reg, 0xBFE0, 16, fw->xseq_0_reg);
855 qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700856
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700857 /* Receive sequence registers. */
858 iter_reg = fw->rseq_gp_reg;
859 iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
860 iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
861 iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
862 iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
863 iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
864 iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
865 iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
866 qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700867
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700868 qla24xx_read_window(reg, 0xFFD0, 16, fw->rseq_0_reg);
869 qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
870 qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700871
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700872 /* Command DMA registers. */
873 qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700874
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700875 /* Queues. */
876 iter_reg = fw->req0_dma_reg;
877 iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
878 dmp_reg = &reg->iobase_q;
879 for (cnt = 0; cnt < 7; cnt++)
880 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700881
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700882 iter_reg = fw->resp0_dma_reg;
883 iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
884 dmp_reg = &reg->iobase_q;
885 for (cnt = 0; cnt < 7; cnt++)
886 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700887
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700888 iter_reg = fw->req1_dma_reg;
889 iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
890 dmp_reg = &reg->iobase_q;
891 for (cnt = 0; cnt < 7; cnt++)
892 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700893
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700894 /* Transmit DMA registers. */
895 iter_reg = fw->xmt0_dma_reg;
896 iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
897 qla24xx_read_window(reg, 0x7610, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700898
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700899 iter_reg = fw->xmt1_dma_reg;
900 iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
901 qla24xx_read_window(reg, 0x7630, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700902
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700903 iter_reg = fw->xmt2_dma_reg;
904 iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
905 qla24xx_read_window(reg, 0x7650, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700906
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700907 iter_reg = fw->xmt3_dma_reg;
908 iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
909 qla24xx_read_window(reg, 0x7670, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700910
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700911 iter_reg = fw->xmt4_dma_reg;
912 iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
913 qla24xx_read_window(reg, 0x7690, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700914
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700915 qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700916
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700917 /* Receive DMA registers. */
918 iter_reg = fw->rcvt0_data_dma_reg;
919 iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
920 qla24xx_read_window(reg, 0x7710, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700921
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700922 iter_reg = fw->rcvt1_data_dma_reg;
923 iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
924 qla24xx_read_window(reg, 0x7730, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700925
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700926 /* RISC registers. */
927 iter_reg = fw->risc_gp_reg;
928 iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
929 iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
930 iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
931 iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
932 iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
933 iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
934 iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
935 qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700936
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700937 /* Local memory controller registers. */
938 iter_reg = fw->lmc_reg;
939 iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
940 iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
941 iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
942 iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
943 iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
944 iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
945 qla24xx_read_window(reg, 0x3060, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700946
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700947 /* Fibre Protocol Module registers. */
948 iter_reg = fw->fpm_hdw_reg;
949 iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
950 iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
951 iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
952 iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
953 iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
954 iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
955 iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
956 iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
957 iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
958 iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
959 iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
960 qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700961
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700962 /* Frame Buffer registers. */
963 iter_reg = fw->fb_hdw_reg;
964 iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
965 iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
966 iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
967 iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
968 iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
969 iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
970 iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
971 iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
972 iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
973 iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
974 qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700975
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700976 rval = qla24xx_soft_reset(ha);
977 if (rval != QLA_SUCCESS)
978 goto qla24xx_fw_dump_failed_0;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700979
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700980 rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
Andrew Vasquezc5722702008-04-24 15:21:22 -0700981 &nxt);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700982 if (rval != QLA_SUCCESS)
983 goto qla24xx_fw_dump_failed_0;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700984
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800985 nxt = qla2xxx_copy_queues(ha, nxt);
Andrew Vasquezbb99de62009-01-05 11:18:08 -0800986
987 qla24xx_copy_eft(ha, nxt);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700988
Andrew Vasquezc81d04c2007-07-26 11:41:13 -0700989qla24xx_fw_dump_failed_0:
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700990 if (rval != QLA_SUCCESS) {
991 qla_printk(KERN_WARNING, ha,
992 "Failed to dump firmware (%x)!!!\n", rval);
993 ha->fw_dumped = 0;
994
995 } else {
996 qla_printk(KERN_INFO, ha,
997 "Firmware dump saved to temp buffer (%ld/%p).\n",
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800998 base_vha->host_no, ha->fw_dump);
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700999 ha->fw_dumped = 1;
1000 }
1001
1002qla24xx_fw_dump_failed:
1003 if (!hardware_locked)
1004 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1005}
1006
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001007void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001008qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001009{
1010 int rval;
1011 uint32_t cnt;
1012 uint32_t risc_address;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001013 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001014 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1015 uint32_t __iomem *dmp_reg;
1016 uint32_t *iter_reg;
1017 uint16_t __iomem *mbx_reg;
1018 unsigned long flags;
1019 struct qla25xx_fw_dump *fw;
1020 uint32_t ext_mem_cnt;
Andrew Vasquezd63ab532009-01-05 11:18:09 -08001021 void *nxt, *nxt_chain;
Andrew Vasquezbb99de62009-01-05 11:18:08 -08001022 uint32_t *last_chain = NULL;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001023 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001024
1025 risc_address = ext_mem_cnt = 0;
1026 flags = 0;
1027
1028 if (!hardware_locked)
1029 spin_lock_irqsave(&ha->hardware_lock, flags);
1030
1031 if (!ha->fw_dump) {
1032 qla_printk(KERN_WARNING, ha,
1033 "No buffer available for dump!!!\n");
1034 goto qla25xx_fw_dump_failed;
1035 }
1036
1037 if (ha->fw_dumped) {
1038 qla_printk(KERN_WARNING, ha,
1039 "Firmware has been previously dumped (%p) -- ignoring "
1040 "request...\n", ha->fw_dump);
1041 goto qla25xx_fw_dump_failed;
1042 }
1043 fw = &ha->fw_dump->isp.isp25;
1044 qla2xxx_prep_dump(ha, ha->fw_dump);
Andrew Vasquezb5836922007-09-20 14:07:39 -07001045 ha->fw_dump->version = __constant_htonl(2);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001046
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001047 fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
1048
1049 /* Pause RISC. */
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001050 rval = qla24xx_pause_risc(reg);
1051 if (rval != QLA_SUCCESS)
1052 goto qla25xx_fw_dump_failed_0;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001053
Andrew Vasquezb5836922007-09-20 14:07:39 -07001054 /* Host/Risc registers. */
1055 iter_reg = fw->host_risc_reg;
1056 iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
1057 qla24xx_read_window(reg, 0x7010, 16, iter_reg);
1058
1059 /* PCIe registers. */
1060 WRT_REG_DWORD(&reg->iobase_addr, 0x7C00);
1061 RD_REG_DWORD(&reg->iobase_addr);
1062 WRT_REG_DWORD(&reg->iobase_window, 0x01);
1063 dmp_reg = &reg->iobase_c4;
1064 fw->pcie_regs[0] = htonl(RD_REG_DWORD(dmp_reg++));
1065 fw->pcie_regs[1] = htonl(RD_REG_DWORD(dmp_reg++));
1066 fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
1067 fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001068
Andrew Vasquezb5836922007-09-20 14:07:39 -07001069 WRT_REG_DWORD(&reg->iobase_window, 0x00);
1070 RD_REG_DWORD(&reg->iobase_window);
1071
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001072 /* Host interface registers. */
1073 dmp_reg = &reg->flash_addr;
1074 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
1075 fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001076
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001077 /* Disable interrupts. */
1078 WRT_REG_DWORD(&reg->ictrl, 0);
1079 RD_REG_DWORD(&reg->ictrl);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001080
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001081 /* Shadow registers. */
1082 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1083 RD_REG_DWORD(&reg->iobase_addr);
1084 WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
1085 fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001086
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001087 WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
1088 fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001089
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001090 WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
1091 fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001092
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001093 WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
1094 fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001095
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001096 WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
1097 fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001098
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001099 WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
1100 fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001101
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001102 WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
1103 fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001104
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001105 WRT_REG_DWORD(&reg->iobase_select, 0xB0700000);
1106 fw->shadow_reg[7] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001107
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001108 WRT_REG_DWORD(&reg->iobase_select, 0xB0800000);
1109 fw->shadow_reg[8] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001110
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001111 WRT_REG_DWORD(&reg->iobase_select, 0xB0900000);
1112 fw->shadow_reg[9] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001113
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001114 WRT_REG_DWORD(&reg->iobase_select, 0xB0A00000);
1115 fw->shadow_reg[10] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001116
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001117 /* RISC I/O register. */
1118 WRT_REG_DWORD(&reg->iobase_addr, 0x0010);
1119 fw->risc_io_reg = htonl(RD_REG_DWORD(&reg->iobase_window));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001120
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001121 /* Mailbox registers. */
1122 mbx_reg = &reg->mailbox0;
1123 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
1124 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001125
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001126 /* Transfer sequence registers. */
1127 iter_reg = fw->xseq_gp_reg;
1128 iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
1129 iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
1130 iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
1131 iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
1132 iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
1133 iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
1134 iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
1135 qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001136
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001137 iter_reg = fw->xseq_0_reg;
1138 iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
1139 iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
1140 qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001141
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001142 qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001143
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001144 /* Receive sequence registers. */
1145 iter_reg = fw->rseq_gp_reg;
1146 iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
1147 iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
1148 iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
1149 iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
1150 iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
1151 iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
1152 iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
1153 qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001154
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001155 iter_reg = fw->rseq_0_reg;
1156 iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
1157 qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001158
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001159 qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
1160 qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001161
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001162 /* Auxiliary sequence registers. */
1163 iter_reg = fw->aseq_gp_reg;
1164 iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
1165 iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
1166 iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
1167 iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
1168 iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
1169 iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
1170 iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
1171 qla24xx_read_window(reg, 0xB070, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001172
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001173 iter_reg = fw->aseq_0_reg;
1174 iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
1175 qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001176
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001177 qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
1178 qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001179
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001180 /* Command DMA registers. */
1181 qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001182
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001183 /* Queues. */
1184 iter_reg = fw->req0_dma_reg;
1185 iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
1186 dmp_reg = &reg->iobase_q;
1187 for (cnt = 0; cnt < 7; cnt++)
1188 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001189
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001190 iter_reg = fw->resp0_dma_reg;
1191 iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
1192 dmp_reg = &reg->iobase_q;
1193 for (cnt = 0; cnt < 7; cnt++)
1194 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001195
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001196 iter_reg = fw->req1_dma_reg;
1197 iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
1198 dmp_reg = &reg->iobase_q;
1199 for (cnt = 0; cnt < 7; cnt++)
1200 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001201
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001202 /* Transmit DMA registers. */
1203 iter_reg = fw->xmt0_dma_reg;
1204 iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
1205 qla24xx_read_window(reg, 0x7610, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001206
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001207 iter_reg = fw->xmt1_dma_reg;
1208 iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
1209 qla24xx_read_window(reg, 0x7630, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001210
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001211 iter_reg = fw->xmt2_dma_reg;
1212 iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
1213 qla24xx_read_window(reg, 0x7650, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001214
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001215 iter_reg = fw->xmt3_dma_reg;
1216 iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
1217 qla24xx_read_window(reg, 0x7670, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001218
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001219 iter_reg = fw->xmt4_dma_reg;
1220 iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
1221 qla24xx_read_window(reg, 0x7690, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001222
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001223 qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001224
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001225 /* Receive DMA registers. */
1226 iter_reg = fw->rcvt0_data_dma_reg;
1227 iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
1228 qla24xx_read_window(reg, 0x7710, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001229
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001230 iter_reg = fw->rcvt1_data_dma_reg;
1231 iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
1232 qla24xx_read_window(reg, 0x7730, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001233
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001234 /* RISC registers. */
1235 iter_reg = fw->risc_gp_reg;
1236 iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
1237 iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
1238 iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
1239 iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
1240 iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
1241 iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
1242 iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
1243 qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001244
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001245 /* Local memory controller registers. */
1246 iter_reg = fw->lmc_reg;
1247 iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
1248 iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
1249 iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
1250 iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
1251 iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
1252 iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
1253 iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
1254 qla24xx_read_window(reg, 0x3070, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001255
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001256 /* Fibre Protocol Module registers. */
1257 iter_reg = fw->fpm_hdw_reg;
1258 iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
1259 iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
1260 iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
1261 iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
1262 iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
1263 iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
1264 iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
1265 iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
1266 iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
1267 iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
1268 iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
1269 qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001270
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001271 /* Frame Buffer registers. */
1272 iter_reg = fw->fb_hdw_reg;
1273 iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
1274 iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
1275 iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
1276 iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
1277 iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
1278 iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
1279 iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
1280 iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
1281 iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
1282 iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
1283 iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
1284 qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001285
Andrew Vasquezd63ab532009-01-05 11:18:09 -08001286 /* Multi queue registers */
1287 nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
1288 &last_chain);
1289
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001290 rval = qla24xx_soft_reset(ha);
1291 if (rval != QLA_SUCCESS)
1292 goto qla25xx_fw_dump_failed_0;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001293
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001294 rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
Andrew Vasquezc5722702008-04-24 15:21:22 -07001295 &nxt);
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001296 if (rval != QLA_SUCCESS)
1297 goto qla25xx_fw_dump_failed_0;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001298
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001299 nxt = qla2xxx_copy_queues(ha, nxt);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001300
Andrew Vasquezbb99de62009-01-05 11:18:08 -08001301 nxt = qla24xx_copy_eft(ha, nxt);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08001302
Andrew Vasquezd63ab532009-01-05 11:18:09 -08001303 /* Chain entries -- started with MQ. */
1304 qla25xx_copy_fce(ha, nxt_chain, &last_chain);
Andrew Vasquezbb99de62009-01-05 11:18:08 -08001305 if (last_chain) {
1306 ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
1307 *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
1308 }
Andrew Vasquezdf613b92008-01-17 09:02:17 -08001309
Andrew Vasquezc81d04c2007-07-26 11:41:13 -07001310qla25xx_fw_dump_failed_0:
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001311 if (rval != QLA_SUCCESS) {
1312 qla_printk(KERN_WARNING, ha,
1313 "Failed to dump firmware (%x)!!!\n", rval);
1314 ha->fw_dumped = 0;
1315
1316 } else {
1317 qla_printk(KERN_INFO, ha,
1318 "Firmware dump saved to temp buffer (%ld/%p).\n",
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001319 base_vha->host_no, ha->fw_dump);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001320 ha->fw_dumped = 1;
1321 }
1322
1323qla25xx_fw_dump_failed:
1324 if (!hardware_locked)
1325 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1326}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327/****************************************************************************/
1328/* Driver Debug Functions. */
1329/****************************************************************************/
1330
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001331void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001332qla2x00_dump_regs(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333{
Andrew Vasquez6afd9762007-08-12 18:22:56 -07001334 int i;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001335 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez3d716442005-07-06 10:30:26 -07001336 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
Andrew Vasquez6afd9762007-08-12 18:22:56 -07001337 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
1338 uint16_t __iomem *mbx_reg;
1339
1340 mbx_reg = IS_FWI2_CAPABLE(ha) ? &reg24->mailbox0:
1341 MAILBOX_REG(ha, reg, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342
1343 printk("Mailbox registers:\n");
Andrew Vasquez6afd9762007-08-12 18:22:56 -07001344 for (i = 0; i < 6; i++)
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001345 printk("scsi(%ld): mbox %d 0x%04x \n", vha->host_no, i,
Andrew Vasquez6afd9762007-08-12 18:22:56 -07001346 RD_REG_WORD(mbx_reg++));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347}
1348
1349
1350void
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001351qla2x00_dump_buffer(uint8_t * b, uint32_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352{
1353 uint32_t cnt;
1354 uint8_t c;
1355
1356 printk(" 0 1 2 3 4 5 6 7 8 9 "
1357 "Ah Bh Ch Dh Eh Fh\n");
1358 printk("----------------------------------------"
1359 "----------------------\n");
1360
1361 for (cnt = 0; cnt < size;) {
1362 c = *b++;
1363 printk("%02x",(uint32_t) c);
1364 cnt++;
1365 if (!(cnt % 16))
1366 printk("\n");
1367 else
1368 printk(" ");
1369 }
1370 if (cnt % 16)
1371 printk("\n");
1372}
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001373
1374