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