blob: f660dd70b72e460671a00cc7342224197d8a4cc3 [file] [log] [blame]
Andrew Vasquezfa90c542005-10-27 11:10:08 -07001/*
2 * QLogic Fibre Channel HBA Driver
Andrew Vasquez01e58d82008-04-03 13:13:13 -07003 * Copyright (c) 2003-2008 QLogic Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Andrew Vasquezfa90c542005-10-27 11:10:08 -07005 * See LICENSE.qla2xxx for copyright and licensing details.
6 */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08007
8#include "qla_def.h"
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010/*
11 * Driver debug definitions.
12 */
13/* #define QL_DEBUG_LEVEL_1 */ /* Output register accesses to COM1 */
14/* #define QL_DEBUG_LEVEL_2 */ /* Output error msgs to COM1 */
15/* #define QL_DEBUG_LEVEL_3 */ /* Output function trace msgs to COM1 */
16/* #define QL_DEBUG_LEVEL_4 */ /* Output NVRAM trace msgs to COM1 */
17/* #define QL_DEBUG_LEVEL_5 */ /* Output ring trace msgs to COM1 */
18/* #define QL_DEBUG_LEVEL_6 */ /* Output WATCHDOG timer trace to COM1 */
19/* #define QL_DEBUG_LEVEL_7 */ /* Output RISC load trace msgs to COM1 */
20/* #define QL_DEBUG_LEVEL_8 */ /* Output ring saturation msgs to COM1 */
21/* #define QL_DEBUG_LEVEL_9 */ /* Output IOCTL trace msgs */
22/* #define QL_DEBUG_LEVEL_10 */ /* Output IOCTL error msgs */
23/* #define QL_DEBUG_LEVEL_11 */ /* Output Mbx Cmd trace msgs */
24/* #define QL_DEBUG_LEVEL_12 */ /* Output IP trace msgs */
25/* #define QL_DEBUG_LEVEL_13 */ /* Output fdmi function trace msgs */
26/* #define QL_DEBUG_LEVEL_14 */ /* Output RSCN trace msgs */
Seokmann Ju2c3dfe32007-07-05 13:16:51 -070027/* #define QL_DEBUG_LEVEL_15 */ /* Output NPIV trace msgs */
Harihara Kadayam4d4df192008-04-03 13:13:26 -070028/* #define QL_DEBUG_LEVEL_16 */ /* Output ISP84XX trace msgs */
Anirban Chakraborty73208df2008-12-09 16:45:39 -080029/* #define QL_DEBUG_LEVEL_17 */ /* Output MULTI-Q trace messages */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31/*
32* Macros use for debugging the driver.
33*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Andrew Vasquez11010fe2006-10-06 09:54:59 -070035#define DEBUG(x) do { if (ql2xextended_error_logging) { x; } } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37#if defined(QL_DEBUG_LEVEL_1)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070038#define DEBUG1(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070040#define DEBUG1(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#endif
42
Andrew Vasquez11010fe2006-10-06 09:54:59 -070043#define DEBUG2(x) do { if (ql2xextended_error_logging) { x; } } while (0)
44#define DEBUG2_3(x) do { if (ql2xextended_error_logging) { x; } } while (0)
45#define DEBUG2_3_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
46#define DEBUG2_9_10(x) do { if (ql2xextended_error_logging) { x; } } while (0)
47#define DEBUG2_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
48#define DEBUG2_13(x) do { if (ql2xextended_error_logging) { x; } } while (0)
Harihara Kadayam4d4df192008-04-03 13:13:26 -070049#define DEBUG2_16(x) do { if (ql2xextended_error_logging) { x; } } while (0)
Anirban Chakraborty73208df2008-12-09 16:45:39 -080050#define DEBUG2_17(x) do { if (ql2xextended_error_logging) { x; } } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#if defined(QL_DEBUG_LEVEL_3)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070053#define DEBUG3(x) do {x;} while (0)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070054#define DEBUG3_11(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070056#define DEBUG3(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#endif
58
59#if defined(QL_DEBUG_LEVEL_4)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070060#define DEBUG4(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070062#define DEBUG4(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#endif
64
65#if defined(QL_DEBUG_LEVEL_5)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070066#define DEBUG5(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070068#define DEBUG5(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#endif
70
71#if defined(QL_DEBUG_LEVEL_7)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070072#define DEBUG7(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070074#define DEBUG7(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#endif
76
77#if defined(QL_DEBUG_LEVEL_9)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070078#define DEBUG9(x) do {x;} while (0)
79#define DEBUG9_10(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070081#define DEBUG9(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif
83
84#if defined(QL_DEBUG_LEVEL_10)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070085#define DEBUG10(x) do {x;} while (0)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070086#define DEBUG9_10(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070088#define DEBUG10(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 #if !defined(DEBUG9_10)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070090 #define DEBUG9_10(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 #endif
92#endif
93
94#if defined(QL_DEBUG_LEVEL_11)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070095#define DEBUG11(x) do{x;} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#if !defined(DEBUG3_11)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -070097#define DEBUG3_11(x) do{x;} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#endif
99#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -0700100#define DEBUG11(x) do{} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 #if !defined(QL_DEBUG_LEVEL_3)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -0700102 #define DEBUG3_11(x) do{} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 #endif
104#endif
105
106#if defined(QL_DEBUG_LEVEL_12)
Andrew Vasquez744f11fd2006-06-23 16:11:05 -0700107#define DEBUG12(x) do {x;} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108#else
Andrew Vasquez744f11fd2006-06-23 16:11:05 -0700109#define DEBUG12(x) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#endif
111
112#if defined(QL_DEBUG_LEVEL_13)
113#define DEBUG13(x) do {x;} while (0)
114#else
115#define DEBUG13(x) do {} while (0)
116#endif
117
118#if defined(QL_DEBUG_LEVEL_14)
119#define DEBUG14(x) do {x;} while (0)
120#else
121#define DEBUG14(x) do {} while (0)
122#endif
123
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700124#if defined(QL_DEBUG_LEVEL_15)
125#define DEBUG15(x) do {x;} while (0)
126#else
127#define DEBUG15(x) do {} while (0)
128#endif
129
Harihara Kadayam4d4df192008-04-03 13:13:26 -0700130#if defined(QL_DEBUG_LEVEL_16)
131#define DEBUG16(x) do {x;} while (0)
132#else
133#define DEBUG16(x) do {} while (0)
134#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135/*
136 * Firmware Dump structure definition
137 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139struct qla2300_fw_dump {
140 uint16_t hccr;
141 uint16_t pbiu_reg[8];
142 uint16_t risc_host_reg[8];
143 uint16_t mailbox_reg[32];
144 uint16_t resp_dma_reg[32];
145 uint16_t dma_reg[48];
146 uint16_t risc_hdw_reg[16];
147 uint16_t risc_gp0_reg[16];
148 uint16_t risc_gp1_reg[16];
149 uint16_t risc_gp2_reg[16];
150 uint16_t risc_gp3_reg[16];
151 uint16_t risc_gp4_reg[16];
152 uint16_t risc_gp5_reg[16];
153 uint16_t risc_gp6_reg[16];
154 uint16_t risc_gp7_reg[16];
155 uint16_t frame_buf_hdw_reg[64];
156 uint16_t fpm_b0_reg[64];
157 uint16_t fpm_b1_reg[64];
158 uint16_t risc_ram[0xf800];
159 uint16_t stack_ram[0x1000];
160 uint16_t data_ram[1];
161};
162
163struct qla2100_fw_dump {
164 uint16_t hccr;
165 uint16_t pbiu_reg[8];
166 uint16_t mailbox_reg[32];
167 uint16_t dma_reg[48];
168 uint16_t risc_hdw_reg[16];
169 uint16_t risc_gp0_reg[16];
170 uint16_t risc_gp1_reg[16];
171 uint16_t risc_gp2_reg[16];
172 uint16_t risc_gp3_reg[16];
173 uint16_t risc_gp4_reg[16];
174 uint16_t risc_gp5_reg[16];
175 uint16_t risc_gp6_reg[16];
176 uint16_t risc_gp7_reg[16];
177 uint16_t frame_buf_hdw_reg[16];
178 uint16_t fpm_b0_reg[64];
179 uint16_t fpm_b1_reg[64];
180 uint16_t risc_ram[0xf000];
181};
182
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700183struct qla24xx_fw_dump {
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800184 uint32_t host_status;
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700185 uint32_t host_reg[32];
andrew.vasquez@qlogic.com210d5352006-01-13 17:05:21 -0800186 uint32_t shadow_reg[7];
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700187 uint16_t mailbox_reg[32];
188 uint32_t xseq_gp_reg[128];
189 uint32_t xseq_0_reg[16];
190 uint32_t xseq_1_reg[16];
191 uint32_t rseq_gp_reg[128];
192 uint32_t rseq_0_reg[16];
193 uint32_t rseq_1_reg[16];
194 uint32_t rseq_2_reg[16];
195 uint32_t cmd_dma_reg[16];
196 uint32_t req0_dma_reg[15];
197 uint32_t resp0_dma_reg[15];
198 uint32_t req1_dma_reg[15];
199 uint32_t xmt0_dma_reg[32];
200 uint32_t xmt1_dma_reg[32];
201 uint32_t xmt2_dma_reg[32];
202 uint32_t xmt3_dma_reg[32];
203 uint32_t xmt4_dma_reg[32];
204 uint32_t xmt_data_dma_reg[16];
205 uint32_t rcvt0_data_dma_reg[32];
206 uint32_t rcvt1_data_dma_reg[32];
207 uint32_t risc_gp_reg[128];
Andrew Vasquez6d9b61e2005-07-06 10:30:36 -0700208 uint32_t lmc_reg[112];
209 uint32_t fpm_hdw_reg[192];
210 uint32_t fb_hdw_reg[176];
211 uint32_t code_ram[0x2000];
212 uint32_t ext_mem[1];
213};
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700214
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700215struct qla25xx_fw_dump {
216 uint32_t host_status;
Andrew Vasquezb5836922007-09-20 14:07:39 -0700217 uint32_t host_risc_reg[32];
218 uint32_t pcie_regs[4];
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700219 uint32_t host_reg[32];
220 uint32_t shadow_reg[11];
221 uint32_t risc_io_reg;
222 uint16_t mailbox_reg[32];
223 uint32_t xseq_gp_reg[128];
224 uint32_t xseq_0_reg[48];
225 uint32_t xseq_1_reg[16];
226 uint32_t rseq_gp_reg[128];
227 uint32_t rseq_0_reg[32];
228 uint32_t rseq_1_reg[16];
229 uint32_t rseq_2_reg[16];
230 uint32_t aseq_gp_reg[128];
231 uint32_t aseq_0_reg[32];
232 uint32_t aseq_1_reg[16];
233 uint32_t aseq_2_reg[16];
234 uint32_t cmd_dma_reg[16];
235 uint32_t req0_dma_reg[15];
236 uint32_t resp0_dma_reg[15];
237 uint32_t req1_dma_reg[15];
238 uint32_t xmt0_dma_reg[32];
239 uint32_t xmt1_dma_reg[32];
240 uint32_t xmt2_dma_reg[32];
241 uint32_t xmt3_dma_reg[32];
242 uint32_t xmt4_dma_reg[32];
243 uint32_t xmt_data_dma_reg[16];
244 uint32_t rcvt0_data_dma_reg[32];
245 uint32_t rcvt1_data_dma_reg[32];
246 uint32_t risc_gp_reg[128];
247 uint32_t lmc_reg[128];
248 uint32_t fpm_hdw_reg[192];
249 uint32_t fb_hdw_reg[192];
250 uint32_t code_ram[0x2000];
251 uint32_t ext_mem[1];
252};
253
Andrew Vasquez3a03eb72009-01-05 11:18:11 -0800254struct qla81xx_fw_dump {
255 uint32_t host_status;
256 uint32_t host_risc_reg[32];
257 uint32_t pcie_regs[4];
258 uint32_t host_reg[32];
259 uint32_t shadow_reg[11];
260 uint32_t risc_io_reg;
261 uint16_t mailbox_reg[32];
262 uint32_t xseq_gp_reg[128];
263 uint32_t xseq_0_reg[48];
264 uint32_t xseq_1_reg[16];
265 uint32_t rseq_gp_reg[128];
266 uint32_t rseq_0_reg[32];
267 uint32_t rseq_1_reg[16];
268 uint32_t rseq_2_reg[16];
269 uint32_t aseq_gp_reg[128];
270 uint32_t aseq_0_reg[32];
271 uint32_t aseq_1_reg[16];
272 uint32_t aseq_2_reg[16];
273 uint32_t cmd_dma_reg[16];
274 uint32_t req0_dma_reg[15];
275 uint32_t resp0_dma_reg[15];
276 uint32_t req1_dma_reg[15];
277 uint32_t xmt0_dma_reg[32];
278 uint32_t xmt1_dma_reg[32];
279 uint32_t xmt2_dma_reg[32];
280 uint32_t xmt3_dma_reg[32];
281 uint32_t xmt4_dma_reg[32];
282 uint32_t xmt_data_dma_reg[16];
283 uint32_t rcvt0_data_dma_reg[32];
284 uint32_t rcvt1_data_dma_reg[32];
285 uint32_t risc_gp_reg[128];
286 uint32_t lmc_reg[128];
287 uint32_t fpm_hdw_reg[224];
288 uint32_t fb_hdw_reg[208];
289 uint32_t code_ram[0x2000];
290 uint32_t ext_mem[1];
291};
292
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700293#define EFT_NUM_BUFFERS 4
294#define EFT_BYTES_PER_BUFFER 0x4000
295#define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS))
296
Andrew Vasquezdf613b92008-01-17 09:02:17 -0800297#define FCE_NUM_BUFFERS 64
298#define FCE_BYTES_PER_BUFFER 0x400
299#define FCE_SIZE ((FCE_BYTES_PER_BUFFER) * (FCE_NUM_BUFFERS))
300#define fce_calc_size(b) ((FCE_BYTES_PER_BUFFER) * (b))
301
302struct qla2xxx_fce_chain {
303 uint32_t type;
304 uint32_t chain_size;
305
306 uint32_t size;
307 uint32_t addr_l;
308 uint32_t addr_h;
309 uint32_t eregs[8];
310};
311
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800312struct qla2xxx_mq_chain {
313 uint32_t type;
314 uint32_t chain_size;
315
316 uint32_t count;
317 uint32_t qregs[4 * QLA_MQ_SIZE];
318};
319
Andrew Vasquezdf613b92008-01-17 09:02:17 -0800320#define DUMP_CHAIN_VARIANT 0x80000000
321#define DUMP_CHAIN_FCE 0x7FFFFAF0
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800322#define DUMP_CHAIN_MQ 0x7FFFFAF1
Andrew Vasquezdf613b92008-01-17 09:02:17 -0800323#define DUMP_CHAIN_LAST 0x80000000
324
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700325struct qla2xxx_fw_dump {
326 uint8_t signature[4];
327 uint32_t version;
328
329 uint32_t fw_major_version;
330 uint32_t fw_minor_version;
331 uint32_t fw_subminor_version;
332 uint32_t fw_attributes;
333
334 uint32_t vendor;
335 uint32_t device;
336 uint32_t subsystem_vendor;
337 uint32_t subsystem_device;
338
339 uint32_t fixed_size;
340 uint32_t mem_size;
341 uint32_t req_q_size;
342 uint32_t rsp_q_size;
343
344 uint32_t eft_size;
345 uint32_t eft_addr_l;
346 uint32_t eft_addr_h;
347
348 uint32_t header_size;
349
350 union {
351 struct qla2100_fw_dump isp21;
352 struct qla2300_fw_dump isp23;
353 struct qla24xx_fw_dump isp24;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700354 struct qla25xx_fw_dump isp25;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -0800355 struct qla81xx_fw_dump isp81;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -0700356 } isp;
357};