Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Andrew Vasquez | 01e58d8 | 2008-04-03 13:13:13 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2008 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | |
| 9 | #include <linux/delay.h> |
| 10 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 11 | static inline void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 12 | qla2xxx_prep_dump(struct qla_hw_data *ha, struct qla2xxx_fw_dump *fw_dump) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 13 | { |
| 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 | |
| 25 | static inline void * |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 26 | qla2xxx_copy_queues(struct qla_hw_data *ha, void *ptr) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 27 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 28 | struct req_que *req = ha->req_q_map[0]; |
| 29 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 30 | /* Request queue. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 31 | memcpy(ptr, req->ring, req->length * |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 32 | sizeof(request_t)); |
| 33 | |
| 34 | /* Response queue. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 35 | ptr += req->length * sizeof(request_t); |
| 36 | memcpy(ptr, rsp->ring, rsp->length * |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 37 | sizeof(response_t)); |
| 38 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 39 | return ptr + (rsp->length * sizeof(response_t)); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 40 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 42 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 43 | qla24xx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint32_t *ram, |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 44 | uint32_t ram_dwords, void **nxt) |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 45 | { |
| 46 | int rval; |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 47 | uint32_t cnt, stat, timer, dwords, idx; |
| 48 | uint16_t mb0; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 49 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 50 | dma_addr_t dump_dma = ha->gid_list_dma; |
| 51 | uint32_t *dump = (uint32_t *)ha->gid_list; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 52 | |
| 53 | rval = QLA_SUCCESS; |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 54 | mb0 = 0; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 55 | |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 56 | WRT_REG_WORD(®->mailbox0, MBC_DUMP_RISC_RAM_EXTENDED); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 57 | clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); |
| 58 | |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 59 | 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(®->mailbox1, LSW(addr)); |
| 66 | WRT_REG_WORD(®->mailbox8, MSW(addr)); |
| 67 | |
| 68 | WRT_REG_WORD(®->mailbox2, MSW(dump_dma)); |
| 69 | WRT_REG_WORD(®->mailbox3, LSW(dump_dma)); |
| 70 | WRT_REG_WORD(®->mailbox6, MSW(MSD(dump_dma))); |
| 71 | WRT_REG_WORD(®->mailbox7, LSW(MSD(dump_dma))); |
| 72 | |
| 73 | WRT_REG_WORD(®->mailbox4, MSW(dwords)); |
| 74 | WRT_REG_WORD(®->mailbox5, LSW(dwords)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 75 | WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT); |
| 76 | |
| 77 | for (timer = 6000000; timer; timer--) { |
| 78 | /* Check for pending interrupts. */ |
| 79 | stat = RD_REG_DWORD(®->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 Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 88 | mb0 = RD_REG_WORD(®->mailbox0); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 89 | |
| 90 | WRT_REG_DWORD(®->hccr, |
| 91 | HCCRX_CLR_RISC_INT); |
| 92 | RD_REG_DWORD(®->hccr); |
| 93 | break; |
| 94 | } |
| 95 | |
| 96 | /* Clear this intr; it wasn't a mailbox intr */ |
| 97 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); |
| 98 | RD_REG_DWORD(®->hccr); |
| 99 | } |
| 100 | udelay(5); |
| 101 | } |
| 102 | |
| 103 | if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 104 | rval = mb0 & MBS_MASK; |
| 105 | for (idx = 0; idx < dwords; idx++) |
| 106 | ram[cnt + idx] = swab32(dump[idx]); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 107 | } else { |
| 108 | rval = QLA_FUNCTION_FAILED; |
| 109 | } |
| 110 | } |
| 111 | |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 112 | *nxt = rval == QLA_SUCCESS ? &ram[cnt]: NULL; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 113 | return rval; |
| 114 | } |
| 115 | |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 116 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 117 | qla24xx_dump_memory(struct qla_hw_data *ha, uint32_t *code_ram, |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 118 | 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 Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 132 | static uint32_t * |
| 133 | qla24xx_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(®->iobase_addr, iobase); |
| 139 | dmp_reg = ®->iobase_window; |
| 140 | while (count--) |
| 141 | *buf++ = htonl(RD_REG_DWORD(dmp_reg++)); |
| 142 | |
| 143 | return buf; |
| 144 | } |
| 145 | |
| 146 | static inline int |
| 147 | qla24xx_pause_risc(struct device_reg_24xx __iomem *reg) |
| 148 | { |
| 149 | int rval = QLA_SUCCESS; |
| 150 | uint32_t cnt; |
| 151 | |
Andrew Vasquez | c3b058a | 2007-09-20 14:07:38 -0700 | [diff] [blame] | 152 | if (RD_REG_DWORD(®->hccr) & HCCRX_RISC_PAUSE) |
| 153 | return rval; |
| 154 | |
| 155 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE); |
| 156 | for (cnt = 30000; (RD_REG_DWORD(®->hccr) & HCCRX_RISC_PAUSE) == 0 && |
| 157 | rval == QLA_SUCCESS; cnt--) { |
| 158 | if (cnt) |
| 159 | udelay(100); |
| 160 | else |
| 161 | rval = QLA_FUNCTION_TIMEOUT; |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | return rval; |
| 165 | } |
| 166 | |
| 167 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 168 | qla24xx_soft_reset(struct qla_hw_data *ha) |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 169 | { |
| 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(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
| 177 | for (cnt = 0; cnt < 30000; cnt++) { |
| 178 | if ((RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) |
| 179 | break; |
| 180 | |
| 181 | udelay(10); |
| 182 | } |
| 183 | |
| 184 | WRT_REG_DWORD(®->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(®->mailbox0); |
| 191 | for (cnt = 10000 ; cnt && mb0; cnt--) { |
| 192 | udelay(5); |
| 193 | mb0 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 194 | barrier(); |
| 195 | } |
| 196 | |
| 197 | /* Wait for soft-reset to complete. */ |
| 198 | for (cnt = 0; cnt < 30000; cnt++) { |
| 199 | if ((RD_REG_DWORD(®->ctrl_status) & |
| 200 | CSRX_ISP_SOFT_RESET) == 0) |
| 201 | break; |
| 202 | |
| 203 | udelay(10); |
| 204 | } |
| 205 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET); |
| 206 | RD_REG_DWORD(®->hccr); /* PCI Posting. */ |
| 207 | |
| 208 | for (cnt = 30000; RD_REG_WORD(®->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 Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 219 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 220 | qla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint16_t *ram, |
| 221 | uint16_t ram_words, void **nxt) |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 222 | { |
| 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(®->hccr, HCCR_SET_HOST_INT); |
| 252 | |
| 253 | for (timer = 6000000; timer; timer--) { |
| 254 | /* Check for pending interrupts. */ |
| 255 | stat = RD_REG_DWORD(®->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(®->semaphore, 0); |
| 267 | WRT_REG_WORD(®->hccr, |
| 268 | HCCR_CLR_RISC_INT); |
| 269 | RD_REG_WORD(®->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(®->hccr, |
| 278 | HCCR_CLR_RISC_INT); |
| 279 | RD_REG_WORD(®->hccr); |
| 280 | break; |
| 281 | } |
| 282 | |
| 283 | /* clear this intr; it wasn't a mailbox intr */ |
| 284 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 285 | RD_REG_WORD(®->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 Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 303 | static inline void |
| 304 | qla2xxx_read_window(struct device_reg_2xxx __iomem *reg, uint32_t count, |
| 305 | uint16_t *buf) |
| 306 | { |
| 307 | uint16_t __iomem *dmp_reg = ®->u.isp2300.fb_cmd; |
| 308 | |
| 309 | while (count--) |
| 310 | *buf++ = htons(RD_REG_WORD(dmp_reg++)); |
| 311 | } |
| 312 | |
Andrew Vasquez | bb99de6 | 2009-01-05 11:18:08 -0800 | [diff] [blame] | 313 | static inline void * |
| 314 | qla24xx_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 | |
| 323 | static inline void * |
| 324 | qla25xx_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 Vasquez | d63ab53 | 2009-01-05 11:18:09 -0800 | [diff] [blame^] | 350 | static inline void * |
| 351 | qla25xx_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(®->req_q_in)); |
| 375 | mq->qregs[que_idx+1] = htonl(RD_REG_DWORD(®->req_q_out)); |
| 376 | mq->qregs[que_idx+2] = htonl(RD_REG_DWORD(®->rsp_q_in)); |
| 377 | mq->qregs[que_idx+3] = htonl(RD_REG_DWORD(®->rsp_q_out)); |
| 378 | } |
| 379 | |
| 380 | return ptr + sizeof(struct qla2xxx_mq_chain); |
| 381 | } |
| 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | /** |
| 384 | * qla2300_fw_dump() - Dumps binary data from the 2300 firmware. |
| 385 | * @ha: HA context |
| 386 | * @hardware_locked: Called with the hardware_lock |
| 387 | */ |
| 388 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 389 | qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | { |
| 391 | int rval; |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 392 | uint32_t cnt; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 393 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 394 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | uint16_t __iomem *dmp_reg; |
| 396 | unsigned long flags; |
| 397 | struct qla2300_fw_dump *fw; |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 398 | void *nxt; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 399 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | flags = 0; |
| 402 | |
| 403 | if (!hardware_locked) |
| 404 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 405 | |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 406 | if (!ha->fw_dump) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | qla_printk(KERN_WARNING, ha, |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 408 | "No buffer available for dump!!!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | goto qla2300_fw_dump_failed; |
| 410 | } |
| 411 | |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 412 | if (ha->fw_dumped) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | qla_printk(KERN_WARNING, ha, |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 414 | "Firmware has been previously dumped (%p) -- ignoring " |
| 415 | "request...\n", ha->fw_dump); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | goto qla2300_fw_dump_failed; |
| 417 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 418 | fw = &ha->fw_dump->isp.isp23; |
| 419 | qla2xxx_prep_dump(ha, ha->fw_dump); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
| 421 | rval = QLA_SUCCESS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 422 | fw->hccr = htons(RD_REG_WORD(®->hccr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
| 424 | /* Pause RISC. */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 425 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | if (IS_QLA2300(ha)) { |
| 427 | for (cnt = 30000; |
| 428 | (RD_REG_WORD(®->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(®->hccr); /* PCI Posting. */ |
| 437 | udelay(10); |
| 438 | } |
| 439 | |
| 440 | if (rval == QLA_SUCCESS) { |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 441 | dmp_reg = ®->flash_address; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 442 | for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 443 | fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 445 | dmp_reg = ®->u.isp2300.req_q_in; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 446 | for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 447 | fw->risc_host_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 449 | dmp_reg = ®->u.isp2300.mailbox0; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 450 | for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 451 | fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
| 453 | WRT_REG_WORD(®->ctrl_status, 0x40); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 454 | qla2xxx_read_window(reg, 32, fw->resp_dma_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
| 456 | WRT_REG_WORD(®->ctrl_status, 0x50); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 457 | qla2xxx_read_window(reg, 48, fw->dma_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
| 459 | WRT_REG_WORD(®->ctrl_status, 0x00); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 460 | dmp_reg = ®->risc_hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 461 | for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 462 | fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 464 | WRT_REG_WORD(®->pcr, 0x2000); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 465 | qla2xxx_read_window(reg, 16, fw->risc_gp0_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 467 | WRT_REG_WORD(®->pcr, 0x2200); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 468 | qla2xxx_read_window(reg, 16, fw->risc_gp1_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 470 | WRT_REG_WORD(®->pcr, 0x2400); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 471 | qla2xxx_read_window(reg, 16, fw->risc_gp2_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 473 | WRT_REG_WORD(®->pcr, 0x2600); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 474 | qla2xxx_read_window(reg, 16, fw->risc_gp3_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 476 | WRT_REG_WORD(®->pcr, 0x2800); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 477 | qla2xxx_read_window(reg, 16, fw->risc_gp4_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 479 | WRT_REG_WORD(®->pcr, 0x2A00); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 480 | qla2xxx_read_window(reg, 16, fw->risc_gp5_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 482 | WRT_REG_WORD(®->pcr, 0x2C00); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 483 | qla2xxx_read_window(reg, 16, fw->risc_gp6_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 485 | WRT_REG_WORD(®->pcr, 0x2E00); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 486 | qla2xxx_read_window(reg, 16, fw->risc_gp7_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 488 | WRT_REG_WORD(®->ctrl_status, 0x10); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 489 | qla2xxx_read_window(reg, 64, fw->frame_buf_hdw_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 491 | WRT_REG_WORD(®->ctrl_status, 0x20); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 492 | qla2xxx_read_window(reg, 64, fw->fpm_b0_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 494 | WRT_REG_WORD(®->ctrl_status, 0x30); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 495 | qla2xxx_read_window(reg, 64, fw->fpm_b1_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
| 497 | /* Reset RISC. */ |
| 498 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
| 499 | for (cnt = 0; cnt < 30000; cnt++) { |
| 500 | if ((RD_REG_WORD(®->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 Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 518 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 523 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 528 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 533 | if (rval == QLA_SUCCESS) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 534 | qla2xxx_copy_queues(ha, nxt); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | if (rval != QLA_SUCCESS) { |
| 537 | qla_printk(KERN_WARNING, ha, |
| 538 | "Failed to dump firmware (%x)!!!\n", rval); |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 539 | ha->fw_dumped = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | } else { |
| 542 | qla_printk(KERN_INFO, ha, |
| 543 | "Firmware dump saved to temp buffer (%ld/%p).\n", |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 544 | base_vha->host_no, ha->fw_dump); |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 545 | ha->fw_dumped = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | qla2300_fw_dump_failed: |
| 549 | if (!hardware_locked) |
| 550 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 551 | } |
| 552 | |
| 553 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware. |
| 555 | * @ha: HA context |
| 556 | * @hardware_locked: Called with the hardware_lock |
| 557 | */ |
| 558 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 559 | qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | { |
| 561 | int rval; |
| 562 | uint32_t cnt, timer; |
| 563 | uint16_t risc_address; |
| 564 | uint16_t mb0, mb2; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 565 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 566 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | uint16_t __iomem *dmp_reg; |
| 568 | unsigned long flags; |
| 569 | struct qla2100_fw_dump *fw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 570 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
| 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 Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 579 | if (!ha->fw_dump) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | qla_printk(KERN_WARNING, ha, |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 581 | "No buffer available for dump!!!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | goto qla2100_fw_dump_failed; |
| 583 | } |
| 584 | |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 585 | if (ha->fw_dumped) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | qla_printk(KERN_WARNING, ha, |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 587 | "Firmware has been previously dumped (%p) -- ignoring " |
| 588 | "request...\n", ha->fw_dump); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | goto qla2100_fw_dump_failed; |
| 590 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 591 | fw = &ha->fw_dump->isp.isp21; |
| 592 | qla2xxx_prep_dump(ha, ha->fw_dump); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
| 594 | rval = QLA_SUCCESS; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 595 | fw->hccr = htons(RD_REG_WORD(®->hccr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | |
| 597 | /* Pause RISC. */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 598 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | for (cnt = 30000; (RD_REG_WORD(®->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 Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 607 | dmp_reg = ®->flash_address; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 608 | for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 609 | fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 611 | dmp_reg = ®->u.isp2100.mailbox0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 613 | if (cnt == 8) |
| 614 | dmp_reg = ®->u_end.isp2200.mailbox8; |
| 615 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 616 | fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } |
| 618 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 619 | dmp_reg = ®->u.isp2100.unused_2[0]; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 620 | for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 621 | fw->dma_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | |
| 623 | WRT_REG_WORD(®->ctrl_status, 0x00); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 624 | dmp_reg = ®->risc_hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 625 | for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 626 | fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 628 | WRT_REG_WORD(®->pcr, 0x2000); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 629 | qla2xxx_read_window(reg, 16, fw->risc_gp0_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 631 | WRT_REG_WORD(®->pcr, 0x2100); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 632 | qla2xxx_read_window(reg, 16, fw->risc_gp1_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 634 | WRT_REG_WORD(®->pcr, 0x2200); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 635 | qla2xxx_read_window(reg, 16, fw->risc_gp2_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 637 | WRT_REG_WORD(®->pcr, 0x2300); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 638 | qla2xxx_read_window(reg, 16, fw->risc_gp3_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 640 | WRT_REG_WORD(®->pcr, 0x2400); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 641 | qla2xxx_read_window(reg, 16, fw->risc_gp4_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 643 | WRT_REG_WORD(®->pcr, 0x2500); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 644 | qla2xxx_read_window(reg, 16, fw->risc_gp5_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 646 | WRT_REG_WORD(®->pcr, 0x2600); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 647 | qla2xxx_read_window(reg, 16, fw->risc_gp6_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 649 | WRT_REG_WORD(®->pcr, 0x2700); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 650 | qla2xxx_read_window(reg, 16, fw->risc_gp7_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 652 | WRT_REG_WORD(®->ctrl_status, 0x10); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 653 | qla2xxx_read_window(reg, 16, fw->frame_buf_hdw_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 655 | WRT_REG_WORD(®->ctrl_status, 0x20); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 656 | qla2xxx_read_window(reg, 64, fw->fpm_b0_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 658 | WRT_REG_WORD(®->ctrl_status, 0x30); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 659 | qla2xxx_read_window(reg, 64, fw->fpm_b1_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
| 661 | /* Reset the ISP. */ |
| 662 | WRT_REG_WORD(®->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(®->mctr) & (BIT_1 | BIT_0)) != 0))) { |
| 676 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 677 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | for (cnt = 30000; |
| 679 | (RD_REG_WORD(®->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(®->mctr, 0xf1); |
| 690 | else |
| 691 | WRT_REG_WORD(®->mctr, 0xf2); |
| 692 | RD_REG_WORD(®->mctr); /* PCI Posting. */ |
| 693 | |
| 694 | /* Release RISC. */ |
| 695 | WRT_REG_WORD(®->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(®->hccr, HCCR_SET_HOST_INT); |
| 709 | |
| 710 | for (timer = 6000000; timer != 0; timer--) { |
| 711 | /* Check for pending interrupts. */ |
| 712 | if (RD_REG_WORD(®->istatus) & ISR_RISC_INT) { |
| 713 | if (RD_REG_WORD(®->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(®->semaphore, 0); |
| 721 | WRT_REG_WORD(®->hccr, |
| 722 | HCCR_CLR_RISC_INT); |
| 723 | RD_REG_WORD(®->hccr); |
| 724 | break; |
| 725 | } |
| 726 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 727 | RD_REG_WORD(®->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 Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 734 | fw->risc_ram[cnt] = htons(mb2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | } else { |
| 736 | rval = QLA_FUNCTION_FAILED; |
| 737 | } |
| 738 | } |
| 739 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 740 | if (rval == QLA_SUCCESS) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 741 | qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 742 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | if (rval != QLA_SUCCESS) { |
| 744 | qla_printk(KERN_WARNING, ha, |
| 745 | "Failed to dump firmware (%x)!!!\n", rval); |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 746 | ha->fw_dumped = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | } else { |
| 749 | qla_printk(KERN_INFO, ha, |
| 750 | "Firmware dump saved to temp buffer (%ld/%p).\n", |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 751 | base_vha->host_no, ha->fw_dump); |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 752 | ha->fw_dumped = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | qla2100_fw_dump_failed: |
| 756 | if (!hardware_locked) |
| 757 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 758 | } |
| 759 | |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 760 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 761 | qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 762 | { |
| 763 | int rval; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 764 | uint32_t cnt; |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 765 | uint32_t risc_address; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 766 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 767 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 774 | void *nxt; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 775 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 776 | |
| 777 | risc_address = ext_mem_cnt = 0; |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 778 | flags = 0; |
| 779 | |
| 780 | if (!hardware_locked) |
| 781 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 782 | |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 783 | if (!ha->fw_dump) { |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 784 | 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 Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 792 | "request...\n", ha->fw_dump); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 793 | goto qla24xx_fw_dump_failed; |
| 794 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 795 | fw = &ha->fw_dump->isp.isp24; |
| 796 | qla2xxx_prep_dump(ha, ha->fw_dump); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 797 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 798 | fw->host_status = htonl(RD_REG_DWORD(®->host_status)); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 799 | |
| 800 | /* Pause RISC. */ |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 801 | rval = qla24xx_pause_risc(reg); |
| 802 | if (rval != QLA_SUCCESS) |
| 803 | goto qla24xx_fw_dump_failed_0; |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 804 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 805 | /* Host interface registers. */ |
| 806 | dmp_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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 809 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 810 | /* Disable interrupts. */ |
| 811 | WRT_REG_DWORD(®->ictrl, 0); |
| 812 | RD_REG_DWORD(®->ictrl); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 813 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 814 | /* Shadow registers. */ |
| 815 | WRT_REG_DWORD(®->iobase_addr, 0x0F70); |
| 816 | RD_REG_DWORD(®->iobase_addr); |
| 817 | WRT_REG_DWORD(®->iobase_select, 0xB0000000); |
| 818 | fw->shadow_reg[0] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 819 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 820 | WRT_REG_DWORD(®->iobase_select, 0xB0100000); |
| 821 | fw->shadow_reg[1] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 822 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 823 | WRT_REG_DWORD(®->iobase_select, 0xB0200000); |
| 824 | fw->shadow_reg[2] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 825 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 826 | WRT_REG_DWORD(®->iobase_select, 0xB0300000); |
| 827 | fw->shadow_reg[3] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 828 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 829 | WRT_REG_DWORD(®->iobase_select, 0xB0400000); |
| 830 | fw->shadow_reg[4] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 831 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 832 | WRT_REG_DWORD(®->iobase_select, 0xB0500000); |
| 833 | fw->shadow_reg[5] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 834 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 835 | WRT_REG_DWORD(®->iobase_select, 0xB0600000); |
| 836 | fw->shadow_reg[6] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
andrew.vasquez@qlogic.com | 210d535 | 2006-01-13 17:05:21 -0800 | [diff] [blame] | 837 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 838 | /* Mailbox registers. */ |
| 839 | mbx_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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 842 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 843 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 853 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 854 | qla24xx_read_window(reg, 0xBFE0, 16, fw->xseq_0_reg); |
| 855 | qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 856 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 857 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 867 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 868 | 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 871 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 872 | /* Command DMA registers. */ |
| 873 | qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 874 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 875 | /* Queues. */ |
| 876 | iter_reg = fw->req0_dma_reg; |
| 877 | iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg); |
| 878 | dmp_reg = ®->iobase_q; |
| 879 | for (cnt = 0; cnt < 7; cnt++) |
| 880 | *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 881 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 882 | iter_reg = fw->resp0_dma_reg; |
| 883 | iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg); |
| 884 | dmp_reg = ®->iobase_q; |
| 885 | for (cnt = 0; cnt < 7; cnt++) |
| 886 | *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 887 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 888 | iter_reg = fw->req1_dma_reg; |
| 889 | iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg); |
| 890 | dmp_reg = ®->iobase_q; |
| 891 | for (cnt = 0; cnt < 7; cnt++) |
| 892 | *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 893 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 894 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 898 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 899 | 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 902 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 903 | 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 906 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 907 | 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 910 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 911 | 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 914 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 915 | qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 916 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 917 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 921 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 922 | 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 925 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 926 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 936 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 937 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 946 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 947 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 961 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 962 | /* 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 Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 975 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 976 | rval = qla24xx_soft_reset(ha); |
| 977 | if (rval != QLA_SUCCESS) |
| 978 | goto qla24xx_fw_dump_failed_0; |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 979 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 980 | rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram), |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 981 | &nxt); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 982 | if (rval != QLA_SUCCESS) |
| 983 | goto qla24xx_fw_dump_failed_0; |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 984 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 985 | nxt = qla2xxx_copy_queues(ha, nxt); |
Andrew Vasquez | bb99de6 | 2009-01-05 11:18:08 -0800 | [diff] [blame] | 986 | |
| 987 | qla24xx_copy_eft(ha, nxt); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 988 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 989 | qla24xx_fw_dump_failed_0: |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 990 | 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 Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 998 | base_vha->host_no, ha->fw_dump); |
Andrew Vasquez | 6d9b61e | 2005-07-06 10:30:36 -0700 | [diff] [blame] | 999 | ha->fw_dumped = 1; |
| 1000 | } |
| 1001 | |
| 1002 | qla24xx_fw_dump_failed: |
| 1003 | if (!hardware_locked) |
| 1004 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1005 | } |
| 1006 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1007 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1008 | qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1009 | { |
| 1010 | int rval; |
| 1011 | uint32_t cnt; |
| 1012 | uint32_t risc_address; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1013 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1014 | 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 Vasquez | d63ab53 | 2009-01-05 11:18:09 -0800 | [diff] [blame^] | 1021 | void *nxt, *nxt_chain; |
Andrew Vasquez | bb99de6 | 2009-01-05 11:18:08 -0800 | [diff] [blame] | 1022 | uint32_t *last_chain = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1023 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1024 | |
| 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 Vasquez | b583692 | 2007-09-20 14:07:39 -0700 | [diff] [blame] | 1045 | ha->fw_dump->version = __constant_htonl(2); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1046 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1047 | fw->host_status = htonl(RD_REG_DWORD(®->host_status)); |
| 1048 | |
| 1049 | /* Pause RISC. */ |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1050 | rval = qla24xx_pause_risc(reg); |
| 1051 | if (rval != QLA_SUCCESS) |
| 1052 | goto qla25xx_fw_dump_failed_0; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1053 | |
Andrew Vasquez | b583692 | 2007-09-20 14:07:39 -0700 | [diff] [blame] | 1054 | /* 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(®->iobase_addr, 0x7C00); |
| 1061 | RD_REG_DWORD(®->iobase_addr); |
| 1062 | WRT_REG_DWORD(®->iobase_window, 0x01); |
| 1063 | dmp_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(®->iobase_window)); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1068 | |
Andrew Vasquez | b583692 | 2007-09-20 14:07:39 -0700 | [diff] [blame] | 1069 | WRT_REG_DWORD(®->iobase_window, 0x00); |
| 1070 | RD_REG_DWORD(®->iobase_window); |
| 1071 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1072 | /* Host interface registers. */ |
| 1073 | dmp_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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1076 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1077 | /* Disable interrupts. */ |
| 1078 | WRT_REG_DWORD(®->ictrl, 0); |
| 1079 | RD_REG_DWORD(®->ictrl); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1080 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1081 | /* Shadow registers. */ |
| 1082 | WRT_REG_DWORD(®->iobase_addr, 0x0F70); |
| 1083 | RD_REG_DWORD(®->iobase_addr); |
| 1084 | WRT_REG_DWORD(®->iobase_select, 0xB0000000); |
| 1085 | fw->shadow_reg[0] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1086 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1087 | WRT_REG_DWORD(®->iobase_select, 0xB0100000); |
| 1088 | fw->shadow_reg[1] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1089 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1090 | WRT_REG_DWORD(®->iobase_select, 0xB0200000); |
| 1091 | fw->shadow_reg[2] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1092 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1093 | WRT_REG_DWORD(®->iobase_select, 0xB0300000); |
| 1094 | fw->shadow_reg[3] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1095 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1096 | WRT_REG_DWORD(®->iobase_select, 0xB0400000); |
| 1097 | fw->shadow_reg[4] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1098 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1099 | WRT_REG_DWORD(®->iobase_select, 0xB0500000); |
| 1100 | fw->shadow_reg[5] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1101 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1102 | WRT_REG_DWORD(®->iobase_select, 0xB0600000); |
| 1103 | fw->shadow_reg[6] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1104 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1105 | WRT_REG_DWORD(®->iobase_select, 0xB0700000); |
| 1106 | fw->shadow_reg[7] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1107 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1108 | WRT_REG_DWORD(®->iobase_select, 0xB0800000); |
| 1109 | fw->shadow_reg[8] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1110 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1111 | WRT_REG_DWORD(®->iobase_select, 0xB0900000); |
| 1112 | fw->shadow_reg[9] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1113 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1114 | WRT_REG_DWORD(®->iobase_select, 0xB0A00000); |
| 1115 | fw->shadow_reg[10] = htonl(RD_REG_DWORD(®->iobase_sdata)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1116 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1117 | /* RISC I/O register. */ |
| 1118 | WRT_REG_DWORD(®->iobase_addr, 0x0010); |
| 1119 | fw->risc_io_reg = htonl(RD_REG_DWORD(®->iobase_window)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1120 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1121 | /* Mailbox registers. */ |
| 1122 | mbx_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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1125 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1126 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1136 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1137 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1141 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1142 | qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1143 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1144 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1154 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1155 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1158 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1159 | qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg); |
| 1160 | qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1161 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1162 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1172 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1173 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1176 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1177 | qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg); |
| 1178 | qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1179 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1180 | /* Command DMA registers. */ |
| 1181 | qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1182 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1183 | /* Queues. */ |
| 1184 | iter_reg = fw->req0_dma_reg; |
| 1185 | iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg); |
| 1186 | dmp_reg = ®->iobase_q; |
| 1187 | for (cnt = 0; cnt < 7; cnt++) |
| 1188 | *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1189 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1190 | iter_reg = fw->resp0_dma_reg; |
| 1191 | iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg); |
| 1192 | dmp_reg = ®->iobase_q; |
| 1193 | for (cnt = 0; cnt < 7; cnt++) |
| 1194 | *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1195 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1196 | iter_reg = fw->req1_dma_reg; |
| 1197 | iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg); |
| 1198 | dmp_reg = ®->iobase_q; |
| 1199 | for (cnt = 0; cnt < 7; cnt++) |
| 1200 | *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1201 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1202 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1206 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1207 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1210 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1211 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1214 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1215 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1218 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1219 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1222 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1223 | qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1224 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1225 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1229 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1230 | 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1233 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1234 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1244 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1245 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1255 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1256 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1270 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1271 | /* 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 Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1285 | |
Andrew Vasquez | d63ab53 | 2009-01-05 11:18:09 -0800 | [diff] [blame^] | 1286 | /* Multi queue registers */ |
| 1287 | nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset, |
| 1288 | &last_chain); |
| 1289 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1290 | rval = qla24xx_soft_reset(ha); |
| 1291 | if (rval != QLA_SUCCESS) |
| 1292 | goto qla25xx_fw_dump_failed_0; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1293 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1294 | rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram), |
Andrew Vasquez | c572270 | 2008-04-24 15:21:22 -0700 | [diff] [blame] | 1295 | &nxt); |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1296 | if (rval != QLA_SUCCESS) |
| 1297 | goto qla25xx_fw_dump_failed_0; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1298 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1299 | nxt = qla2xxx_copy_queues(ha, nxt); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1300 | |
Andrew Vasquez | bb99de6 | 2009-01-05 11:18:08 -0800 | [diff] [blame] | 1301 | nxt = qla24xx_copy_eft(ha, nxt); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1302 | |
Andrew Vasquez | d63ab53 | 2009-01-05 11:18:09 -0800 | [diff] [blame^] | 1303 | /* Chain entries -- started with MQ. */ |
| 1304 | qla25xx_copy_fce(ha, nxt_chain, &last_chain); |
Andrew Vasquez | bb99de6 | 2009-01-05 11:18:08 -0800 | [diff] [blame] | 1305 | if (last_chain) { |
| 1306 | ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT); |
| 1307 | *last_chain |= __constant_htonl(DUMP_CHAIN_LAST); |
| 1308 | } |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1309 | |
Andrew Vasquez | c81d04c | 2007-07-26 11:41:13 -0700 | [diff] [blame] | 1310 | qla25xx_fw_dump_failed_0: |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1311 | 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 Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1319 | base_vha->host_no, ha->fw_dump); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1320 | ha->fw_dumped = 1; |
| 1321 | } |
| 1322 | |
| 1323 | qla25xx_fw_dump_failed: |
| 1324 | if (!hardware_locked) |
| 1325 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1326 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | /****************************************************************************/ |
| 1328 | /* Driver Debug Functions. */ |
| 1329 | /****************************************************************************/ |
| 1330 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1331 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1332 | qla2x00_dump_regs(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | { |
Andrew Vasquez | 6afd976 | 2007-08-12 18:22:56 -0700 | [diff] [blame] | 1334 | int i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1335 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1336 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Andrew Vasquez | 6afd976 | 2007-08-12 18:22:56 -0700 | [diff] [blame] | 1337 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 1338 | uint16_t __iomem *mbx_reg; |
| 1339 | |
| 1340 | mbx_reg = IS_FWI2_CAPABLE(ha) ? ®24->mailbox0: |
| 1341 | MAILBOX_REG(ha, reg, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | |
| 1343 | printk("Mailbox registers:\n"); |
Andrew Vasquez | 6afd976 | 2007-08-12 18:22:56 -0700 | [diff] [blame] | 1344 | for (i = 0; i < 6; i++) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1345 | printk("scsi(%ld): mbox %d 0x%04x \n", vha->host_no, i, |
Andrew Vasquez | 6afd976 | 2007-08-12 18:22:56 -0700 | [diff] [blame] | 1346 | RD_REG_WORD(mbx_reg++)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | |
| 1350 | void |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1351 | qla2x00_dump_buffer(uint8_t * b, uint32_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | { |
| 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 Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1373 | |
| 1374 | |