blob: 98814d651239045fa1cb550dc3d623f315c13833 [file] [log] [blame]
James Smart858c9f62007-06-17 19:56:39 -05001/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
James Smart2a622bf2011-02-16 12:40:06 -05004 * Copyright (C) 2007-2011 Emulex. All rights reserved. *
James Smart858c9f62007-06-17 19:56:39 -05005 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com *
7 * *
8 * This program is free software; you can redistribute it and/or *
9 * modify it under the terms of version 2 of the GNU General *
10 * Public License as published by the Free Software Foundation. *
11 * This program is distributed in the hope that it will be useful. *
12 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16 * TO BE LEGALLY INVALID. See the GNU General Public License for *
17 * more details, a copy of which can be found in the file COPYING *
18 * included with this package. *
19 *******************************************************************/
20
21#ifndef _H_LPFC_DEBUG_FS
22#define _H_LPFC_DEBUG_FS
23
James Smart923e4b62008-12-04 22:40:07 -050024#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
James Smart2a622bf2011-02-16 12:40:06 -050025
26/* size of output line, for discovery_trace and slow_ring_trace */
27#define LPFC_DEBUG_TRC_ENTRY_SIZE 100
28
29/* nodelist output buffer size */
30#define LPFC_NODELIST_SIZE 8192
31#define LPFC_NODELIST_ENTRY_SIZE 120
32
33/* dumpHBASlim output buffer size */
34#define LPFC_DUMPHBASLIM_SIZE 4096
35
36/* dumpHostSlim output buffer size */
37#define LPFC_DUMPHOSTSLIM_SIZE 4096
38
James Smartb84daac2012-08-03 12:35:13 -040039/* dumpSLIqinfo output buffer size */
40#define LPFC_DUMPSLIQINFO_SIZE 4096
41
James Smart2a622bf2011-02-16 12:40:06 -050042/* hbqinfo output buffer size */
43#define LPFC_HBQINFO_SIZE 8192
44
James Smart1d9d5a92017-02-12 13:52:29 -080045enum {
46 DUMP_FCP,
James Smart895427b2017-02-12 13:52:30 -080047 DUMP_NVME,
James Smart1d9d5a92017-02-12 13:52:29 -080048 DUMP_MBX,
49 DUMP_ELS,
James Smart895427b2017-02-12 13:52:30 -080050 DUMP_NVMELS,
James Smart1d9d5a92017-02-12 13:52:29 -080051};
52
James Smartb76f2dc2011-07-22 18:37:42 -040053/*
54 * For SLI4 iDiag debugfs diagnostics tool
55 */
56
James Smart86a80842011-04-16 11:03:04 -040057/* pciConf */
58#define LPFC_PCI_CFG_BROWSE 0xffff
59#define LPFC_PCI_CFG_RD_CMD_ARG 2
60#define LPFC_PCI_CFG_WR_CMD_ARG 3
James Smart2a622bf2011-02-16 12:40:06 -050061#define LPFC_PCI_CFG_SIZE 4096
James Smart2a622bf2011-02-16 12:40:06 -050062#define LPFC_PCI_CFG_RD_SIZE (LPFC_PCI_CFG_SIZE/4)
63
James Smartb76f2dc2011-07-22 18:37:42 -040064#define IDIAG_PCICFG_WHERE_INDX 0
65#define IDIAG_PCICFG_COUNT_INDX 1
66#define IDIAG_PCICFG_VALUE_INDX 2
67
68/* barAcc */
69#define LPFC_PCI_BAR_BROWSE 0xffff
70#define LPFC_PCI_BAR_RD_CMD_ARG 3
71#define LPFC_PCI_BAR_WR_CMD_ARG 3
72
73#define LPFC_PCI_IF0_BAR0_SIZE (1024 * 16)
74#define LPFC_PCI_IF0_BAR1_SIZE (1024 * 128)
75#define LPFC_PCI_IF0_BAR2_SIZE (1024 * 128)
76#define LPFC_PCI_IF2_BAR0_SIZE (1024 * 32)
77
78#define LPFC_PCI_BAR_RD_BUF_SIZE 4096
79#define LPFC_PCI_BAR_RD_SIZE (LPFC_PCI_BAR_RD_BUF_SIZE/4)
80
81#define LPFC_PCI_IF0_BAR0_RD_SIZE (LPFC_PCI_IF0_BAR0_SIZE/4)
82#define LPFC_PCI_IF0_BAR1_RD_SIZE (LPFC_PCI_IF0_BAR1_SIZE/4)
83#define LPFC_PCI_IF0_BAR2_RD_SIZE (LPFC_PCI_IF0_BAR2_SIZE/4)
84#define LPFC_PCI_IF2_BAR0_RD_SIZE (LPFC_PCI_IF2_BAR0_SIZE/4)
85
86#define IDIAG_BARACC_BAR_NUM_INDX 0
87#define IDIAG_BARACC_OFF_SET_INDX 1
88#define IDIAG_BARACC_ACC_MOD_INDX 2
89#define IDIAG_BARACC_REG_VAL_INDX 2
90#define IDIAG_BARACC_BAR_SZE_INDX 3
91
92#define IDIAG_BARACC_BAR_0 0
93#define IDIAG_BARACC_BAR_1 1
94#define IDIAG_BARACC_BAR_2 2
95
96#define SINGLE_WORD 1
97
James Smart86a80842011-04-16 11:03:04 -040098/* queue info */
99#define LPFC_QUE_INFO_GET_BUF_SIZE 4096
100
101/* queue acc */
102#define LPFC_QUE_ACC_BROWSE 0xffff
103#define LPFC_QUE_ACC_RD_CMD_ARG 4
104#define LPFC_QUE_ACC_WR_CMD_ARG 6
105#define LPFC_QUE_ACC_BUF_SIZE 4096
106#define LPFC_QUE_ACC_SIZE (LPFC_QUE_ACC_BUF_SIZE/2)
107
108#define LPFC_IDIAG_EQ 1
109#define LPFC_IDIAG_CQ 2
110#define LPFC_IDIAG_MQ 3
111#define LPFC_IDIAG_WQ 4
112#define LPFC_IDIAG_RQ 5
113
James Smartb76f2dc2011-07-22 18:37:42 -0400114#define IDIAG_QUEACC_QUETP_INDX 0
115#define IDIAG_QUEACC_QUEID_INDX 1
116#define IDIAG_QUEACC_INDEX_INDX 2
117#define IDIAG_QUEACC_COUNT_INDX 3
118#define IDIAG_QUEACC_OFFST_INDX 4
119#define IDIAG_QUEACC_VALUE_INDX 5
120
121/* doorbell register acc */
James Smart86a80842011-04-16 11:03:04 -0400122#define LPFC_DRB_ACC_ALL 0xffff
123#define LPFC_DRB_ACC_RD_CMD_ARG 1
124#define LPFC_DRB_ACC_WR_CMD_ARG 2
125#define LPFC_DRB_ACC_BUF_SIZE 256
126
127#define LPFC_DRB_EQCQ 1
128#define LPFC_DRB_MQ 2
129#define LPFC_DRB_WQ 3
130#define LPFC_DRB_RQ 4
131
132#define LPFC_DRB_MAX 4
James Smart2a622bf2011-02-16 12:40:06 -0500133
James Smartb76f2dc2011-07-22 18:37:42 -0400134#define IDIAG_DRBACC_REGID_INDX 0
135#define IDIAG_DRBACC_VALUE_INDX 1
136
137/* control register acc */
138#define LPFC_CTL_ACC_ALL 0xffff
139#define LPFC_CTL_ACC_RD_CMD_ARG 1
140#define LPFC_CTL_ACC_WR_CMD_ARG 2
141#define LPFC_CTL_ACC_BUF_SIZE 256
142
143#define LPFC_CTL_PORT_SEM 1
144#define LPFC_CTL_PORT_STA 2
145#define LPFC_CTL_PORT_CTL 3
146#define LPFC_CTL_PORT_ER1 4
147#define LPFC_CTL_PORT_ER2 5
148#define LPFC_CTL_PDEV_CTL 6
149
150#define LPFC_CTL_MAX 6
151
152#define IDIAG_CTLACC_REGID_INDX 0
153#define IDIAG_CTLACC_VALUE_INDX 1
154
155/* mailbox access */
156#define LPFC_MBX_DMP_ARG 4
157
158#define LPFC_MBX_ACC_BUF_SIZE 512
159#define LPFC_MBX_ACC_LBUF_SZ 128
160
161#define LPFC_MBX_DMP_MBX_WORD 0x00000001
162#define LPFC_MBX_DMP_MBX_BYTE 0x00000002
163#define LPFC_MBX_DMP_MBX_ALL (LPFC_MBX_DMP_MBX_WORD | LPFC_MBX_DMP_MBX_BYTE)
164
165#define LPFC_BSG_DMP_MBX_RD_MBX 0x00000001
166#define LPFC_BSG_DMP_MBX_RD_BUF 0x00000002
167#define LPFC_BSG_DMP_MBX_WR_MBX 0x00000004
168#define LPFC_BSG_DMP_MBX_WR_BUF 0x00000008
169#define LPFC_BSG_DMP_MBX_ALL (LPFC_BSG_DMP_MBX_RD_MBX | \
170 LPFC_BSG_DMP_MBX_RD_BUF | \
171 LPFC_BSG_DMP_MBX_WR_MBX | \
172 LPFC_BSG_DMP_MBX_WR_BUF)
173
174#define LPFC_MBX_DMP_ALL 0xffff
175#define LPFC_MBX_ALL_CMD 0xff
176
177#define IDIAG_MBXACC_MBCMD_INDX 0
178#define IDIAG_MBXACC_DPMAP_INDX 1
179#define IDIAG_MBXACC_DPCNT_INDX 2
180#define IDIAG_MBXACC_WDCNT_INDX 3
181
182/* extents access */
183#define LPFC_EXT_ACC_CMD_ARG 1
184#define LPFC_EXT_ACC_BUF_SIZE 4096
185
186#define LPFC_EXT_ACC_AVAIL 0x1
187#define LPFC_EXT_ACC_ALLOC 0x2
188#define LPFC_EXT_ACC_DRIVR 0x4
189#define LPFC_EXT_ACC_ALL (LPFC_EXT_ACC_DRIVR | \
190 LPFC_EXT_ACC_AVAIL | \
191 LPFC_EXT_ACC_ALLOC)
192
193#define IDIAG_EXTACC_EXMAP_INDX 0
194
James Smart2a622bf2011-02-16 12:40:06 -0500195#define SIZE_U8 sizeof(uint8_t)
196#define SIZE_U16 sizeof(uint16_t)
197#define SIZE_U32 sizeof(uint32_t)
198
199struct lpfc_debug {
200 char *i_private;
201 char op;
202#define LPFC_IDIAG_OP_RD 1
203#define LPFC_IDIAG_OP_WR 2
204 char *buffer;
205 int len;
206};
207
James Smarta58cbd52007-08-02 11:09:43 -0400208struct lpfc_debugfs_trc {
James Smart858c9f62007-06-17 19:56:39 -0500209 char *fmt;
210 uint32_t data1;
211 uint32_t data2;
212 uint32_t data3;
213 uint32_t seq_cnt;
214 unsigned long jif;
215};
James Smart2a622bf2011-02-16 12:40:06 -0500216
217struct lpfc_idiag_offset {
218 uint32_t last_rd;
219};
220
James Smart86a80842011-04-16 11:03:04 -0400221#define LPFC_IDIAG_CMD_DATA_SIZE 8
James Smart2a622bf2011-02-16 12:40:06 -0500222struct lpfc_idiag_cmd {
223 uint32_t opcode;
224#define LPFC_IDIAG_CMD_PCICFG_RD 0x00000001
225#define LPFC_IDIAG_CMD_PCICFG_WR 0x00000002
226#define LPFC_IDIAG_CMD_PCICFG_ST 0x00000003
227#define LPFC_IDIAG_CMD_PCICFG_CL 0x00000004
James Smart86a80842011-04-16 11:03:04 -0400228
James Smartb76f2dc2011-07-22 18:37:42 -0400229#define LPFC_IDIAG_CMD_BARACC_RD 0x00000008
230#define LPFC_IDIAG_CMD_BARACC_WR 0x00000009
231#define LPFC_IDIAG_CMD_BARACC_ST 0x0000000a
232#define LPFC_IDIAG_CMD_BARACC_CL 0x0000000b
233
James Smart86a80842011-04-16 11:03:04 -0400234#define LPFC_IDIAG_CMD_QUEACC_RD 0x00000011
235#define LPFC_IDIAG_CMD_QUEACC_WR 0x00000012
236#define LPFC_IDIAG_CMD_QUEACC_ST 0x00000013
237#define LPFC_IDIAG_CMD_QUEACC_CL 0x00000014
238
239#define LPFC_IDIAG_CMD_DRBACC_RD 0x00000021
240#define LPFC_IDIAG_CMD_DRBACC_WR 0x00000022
241#define LPFC_IDIAG_CMD_DRBACC_ST 0x00000023
242#define LPFC_IDIAG_CMD_DRBACC_CL 0x00000024
James Smartb76f2dc2011-07-22 18:37:42 -0400243
244#define LPFC_IDIAG_CMD_CTLACC_RD 0x00000031
245#define LPFC_IDIAG_CMD_CTLACC_WR 0x00000032
246#define LPFC_IDIAG_CMD_CTLACC_ST 0x00000033
247#define LPFC_IDIAG_CMD_CTLACC_CL 0x00000034
248
249#define LPFC_IDIAG_CMD_MBXACC_DP 0x00000041
250#define LPFC_IDIAG_BSG_MBXACC_DP 0x00000042
251
252#define LPFC_IDIAG_CMD_EXTACC_RD 0x00000051
253
James Smart2a622bf2011-02-16 12:40:06 -0500254 uint32_t data[LPFC_IDIAG_CMD_DATA_SIZE];
255};
256
257struct lpfc_idiag {
258 uint32_t active;
259 struct lpfc_idiag_cmd cmd;
260 struct lpfc_idiag_offset offset;
James Smart86a80842011-04-16 11:03:04 -0400261 void *ptr_private;
James Smart2a622bf2011-02-16 12:40:06 -0500262};
James Smart858c9f62007-06-17 19:56:39 -0500263#endif
264
265/* Mask for discovery_trace */
266#define LPFC_DISC_TRC_ELS_CMD 0x1 /* Trace ELS commands */
267#define LPFC_DISC_TRC_ELS_RSP 0x2 /* Trace ELS response */
268#define LPFC_DISC_TRC_ELS_UNSOL 0x4 /* Trace ELS rcv'ed */
269#define LPFC_DISC_TRC_ELS_ALL 0x7 /* Trace ELS */
270#define LPFC_DISC_TRC_MBOX_VPORT 0x8 /* Trace vport MBOXs */
271#define LPFC_DISC_TRC_MBOX 0x10 /* Trace other MBOXs */
272#define LPFC_DISC_TRC_MBOX_ALL 0x18 /* Trace all MBOXs */
273#define LPFC_DISC_TRC_CT 0x20 /* Trace disc CT requests */
274#define LPFC_DISC_TRC_DSM 0x40 /* Trace DSM events */
275#define LPFC_DISC_TRC_RPORT 0x80 /* Trace rport events */
276#define LPFC_DISC_TRC_NODE 0x100 /* Trace ndlp state changes */
277
278#define LPFC_DISC_TRC_DISCOVERY 0xef /* common mask for general
279 * discovery */
280#endif /* H_LPFC_DEBUG_FS */
James Smart809c7532012-05-09 21:19:25 -0400281
282
283/*
284 * Driver debug utility routines outside of debugfs. The debug utility
285 * routines implemented here is intended to be used in the instrumented
286 * debug driver for debugging host or port issues.
287 */
288
289/**
290 * lpfc_debug_dump_qe - dump an specific entry from a queue
291 * @q: Pointer to the queue descriptor.
292 * @idx: Index to the entry on the queue.
293 *
294 * This function dumps an entry indexed by @idx from a queue specified by the
295 * queue descriptor @q.
296 **/
297static inline void
298lpfc_debug_dump_qe(struct lpfc_queue *q, uint32_t idx)
299{
300 char line_buf[LPFC_LBUF_SZ];
301 int i, esize, qe_word_cnt, len;
302 uint32_t *pword;
303
304 /* sanity checks */
305 if (!q)
306 return;
307 if (idx >= q->entry_count)
308 return;
309
310 esize = q->entry_size;
311 qe_word_cnt = esize / sizeof(uint32_t);
312 pword = q->qe[idx].address;
313
314 len = 0;
315 len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
316 if (qe_word_cnt > 8)
317 printk(KERN_ERR "%s\n", line_buf);
318
319 for (i = 0; i < qe_word_cnt; i++) {
320 if (!(i % 8)) {
321 if (i != 0)
322 printk(KERN_ERR "%s\n", line_buf);
323 if (qe_word_cnt > 8) {
324 len = 0;
325 memset(line_buf, 0, LPFC_LBUF_SZ);
326 len += snprintf(line_buf+len, LPFC_LBUF_SZ-len,
327 "%03d: ", i);
328 }
329 }
330 len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
331 ((uint32_t)*pword) & 0xffffffff);
332 pword++;
333 }
334 if (qe_word_cnt <= 8 || (i - 1) % 8)
335 printk(KERN_ERR "%s\n", line_buf);
336}
337
338/**
339 * lpfc_debug_dump_q - dump all entries from an specific queue
340 * @q: Pointer to the queue descriptor.
341 *
342 * This function dumps all entries from a queue specified by the queue
343 * descriptor @q.
344 **/
345static inline void
346lpfc_debug_dump_q(struct lpfc_queue *q)
347{
348 int idx, entry_count;
349
350 /* sanity check */
351 if (!q)
352 return;
353
354 dev_printk(KERN_ERR, &(((q->phba))->pcidev)->dev,
355 "%d: [qid:%d, type:%d, subtype:%d, "
356 "qe_size:%d, qe_count:%d, "
357 "host_index:%d, port_index:%d]\n",
358 (q->phba)->brd_no,
359 q->queue_id, q->type, q->subtype,
360 q->entry_size, q->entry_count,
361 q->host_index, q->hba_index);
362 entry_count = q->entry_count;
363 for (idx = 0; idx < entry_count; idx++)
364 lpfc_debug_dump_qe(q, idx);
365 printk(KERN_ERR "\n");
366}
367
368/**
James Smart895427b2017-02-12 13:52:30 -0800369 * lpfc_debug_dump_wq - dump all entries from the fcp or nvme work queue
James Smart809c7532012-05-09 21:19:25 -0400370 * @phba: Pointer to HBA context object.
James Smart895427b2017-02-12 13:52:30 -0800371 * @wqidx: Index to a FCP or NVME work queue.
James Smart809c7532012-05-09 21:19:25 -0400372 *
James Smart895427b2017-02-12 13:52:30 -0800373 * This function dumps all entries from a FCP or NVME work queue specified
James Smart1d9d5a92017-02-12 13:52:29 -0800374 * by the wqidx.
James Smart809c7532012-05-09 21:19:25 -0400375 **/
376static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800377lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx)
James Smart809c7532012-05-09 21:19:25 -0400378{
James Smart1d9d5a92017-02-12 13:52:29 -0800379 struct lpfc_queue *wq;
380 char *qtypestr;
381
382 if (qtype == DUMP_FCP) {
383 wq = phba->sli4_hba.fcp_wq[wqidx];
384 qtypestr = "FCP";
James Smart895427b2017-02-12 13:52:30 -0800385 } else if (qtype == DUMP_NVME) {
386 wq = phba->sli4_hba.nvme_wq[wqidx];
387 qtypestr = "NVME";
James Smart1d9d5a92017-02-12 13:52:29 -0800388 } else if (qtype == DUMP_MBX) {
389 wq = phba->sli4_hba.mbx_wq;
390 qtypestr = "MBX";
391 } else if (qtype == DUMP_ELS) {
392 wq = phba->sli4_hba.els_wq;
393 qtypestr = "ELS";
James Smart895427b2017-02-12 13:52:30 -0800394 } else if (qtype == DUMP_NVMELS) {
395 wq = phba->sli4_hba.nvmels_wq;
396 qtypestr = "NVMELS";
James Smart1d9d5a92017-02-12 13:52:29 -0800397 } else
James Smart809c7532012-05-09 21:19:25 -0400398 return;
399
James Smart895427b2017-02-12 13:52:30 -0800400 if (qtype == DUMP_FCP || qtype == DUMP_NVME)
James Smart1d9d5a92017-02-12 13:52:29 -0800401 pr_err("%s WQ: WQ[Idx:%d|Qid:%d]\n",
402 qtypestr, wqidx, wq->queue_id);
403 else
404 pr_err("%s WQ: WQ[Qid:%d]\n",
405 qtypestr, wq->queue_id);
406
407 lpfc_debug_dump_q(wq);
James Smart809c7532012-05-09 21:19:25 -0400408}
409
410/**
James Smart895427b2017-02-12 13:52:30 -0800411 * lpfc_debug_dump_cq - dump all entries from a fcp or nvme work queue's
James Smart1d9d5a92017-02-12 13:52:29 -0800412 * cmpl queue
James Smart809c7532012-05-09 21:19:25 -0400413 * @phba: Pointer to HBA context object.
James Smart1d9d5a92017-02-12 13:52:29 -0800414 * @wqidx: Index to a FCP work queue.
James Smart809c7532012-05-09 21:19:25 -0400415 *
James Smart895427b2017-02-12 13:52:30 -0800416 * This function dumps all entries from a FCP or NVME completion queue
James Smart1d9d5a92017-02-12 13:52:29 -0800417 * which is associated to the work queue specified by the @wqidx.
James Smart809c7532012-05-09 21:19:25 -0400418 **/
419static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800420lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
James Smart809c7532012-05-09 21:19:25 -0400421{
James Smart1d9d5a92017-02-12 13:52:29 -0800422 struct lpfc_queue *wq, *cq, *eq;
423 char *qtypestr;
424 int eqidx;
James Smart809c7532012-05-09 21:19:25 -0400425
James Smart895427b2017-02-12 13:52:30 -0800426 /* fcp/nvme wq and cq are 1:1, thus same indexes */
James Smart1d9d5a92017-02-12 13:52:29 -0800427
428 if (qtype == DUMP_FCP) {
429 wq = phba->sli4_hba.fcp_wq[wqidx];
430 cq = phba->sli4_hba.fcp_cq[wqidx];
431 qtypestr = "FCP";
James Smart895427b2017-02-12 13:52:30 -0800432 } else if (qtype == DUMP_NVME) {
433 wq = phba->sli4_hba.nvme_wq[wqidx];
434 cq = phba->sli4_hba.nvme_cq[wqidx];
435 qtypestr = "NVME";
James Smart1d9d5a92017-02-12 13:52:29 -0800436 } else if (qtype == DUMP_MBX) {
437 wq = phba->sli4_hba.mbx_wq;
438 cq = phba->sli4_hba.mbx_cq;
439 qtypestr = "MBX";
440 } else if (qtype == DUMP_ELS) {
441 wq = phba->sli4_hba.els_wq;
442 cq = phba->sli4_hba.els_cq;
443 qtypestr = "ELS";
James Smart895427b2017-02-12 13:52:30 -0800444 } else if (qtype == DUMP_NVMELS) {
445 wq = phba->sli4_hba.nvmels_wq;
446 cq = phba->sli4_hba.nvmels_cq;
447 qtypestr = "NVMELS";
James Smart1d9d5a92017-02-12 13:52:29 -0800448 } else
James Smart809c7532012-05-09 21:19:25 -0400449 return;
450
James Smart895427b2017-02-12 13:52:30 -0800451 for (eqidx = 0; eqidx < phba->io_channel_irqs; eqidx++) {
James Smart1d9d5a92017-02-12 13:52:29 -0800452 eq = phba->sli4_hba.hba_eq[eqidx];
453 if (cq->assoc_qid == eq->queue_id)
James Smart809c7532012-05-09 21:19:25 -0400454 break;
James Smart1d9d5a92017-02-12 13:52:29 -0800455 }
James Smart895427b2017-02-12 13:52:30 -0800456 if (eqidx == phba->io_channel_irqs) {
James Smart1d9d5a92017-02-12 13:52:29 -0800457 pr_err("Couldn't find EQ for CQ. Using EQ[0]\n");
458 eqidx = 0;
459 eq = phba->sli4_hba.hba_eq[0];
James Smart3b3da6a2012-06-12 13:54:20 -0400460 }
James Smart809c7532012-05-09 21:19:25 -0400461
James Smart895427b2017-02-12 13:52:30 -0800462 if (qtype == DUMP_FCP || qtype == DUMP_NVME)
James Smart1d9d5a92017-02-12 13:52:29 -0800463 pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
464 "->EQ[Idx:%d|Qid:%d]:\n",
465 qtypestr, wqidx, wq->queue_id, wqidx, cq->queue_id,
466 eqidx, eq->queue_id);
467 else
468 pr_err("%s CQ: WQ[Qid:%d]->CQ[Qid:%d]"
469 "->EQ[Idx:%d|Qid:%d]:\n",
470 qtypestr, wq->queue_id, cq->queue_id,
471 eqidx, eq->queue_id);
472
473 lpfc_debug_dump_q(cq);
James Smart809c7532012-05-09 21:19:25 -0400474}
475
476/**
James Smart67d12732012-08-03 12:36:13 -0400477 * lpfc_debug_dump_hba_eq - dump all entries from a fcp work queue's evt queue
James Smart809c7532012-05-09 21:19:25 -0400478 * @phba: Pointer to HBA context object.
479 * @fcp_wqidx: Index to a FCP work queue.
480 *
481 * This function dumps all entries from a FCP event queue which is
482 * associated to the FCP work queue specified by the @fcp_wqidx.
483 **/
484static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800485lpfc_debug_dump_hba_eq(struct lpfc_hba *phba, int qidx)
James Smart809c7532012-05-09 21:19:25 -0400486{
James Smart1d9d5a92017-02-12 13:52:29 -0800487 struct lpfc_queue *qp;
James Smart809c7532012-05-09 21:19:25 -0400488
James Smart1d9d5a92017-02-12 13:52:29 -0800489 qp = phba->sli4_hba.hba_eq[qidx];
James Smart809c7532012-05-09 21:19:25 -0400490
James Smart1d9d5a92017-02-12 13:52:29 -0800491 pr_err("EQ[Idx:%d|Qid:%d]\n", qidx, qp->queue_id);
James Smart809c7532012-05-09 21:19:25 -0400492
James Smart1d9d5a92017-02-12 13:52:29 -0800493 lpfc_debug_dump_q(qp);
James Smart809c7532012-05-09 21:19:25 -0400494}
495
496/**
497 * lpfc_debug_dump_dat_rq - dump all entries from the receive data queue
498 * @phba: Pointer to HBA context object.
499 *
500 * This function dumps all entries from the receive data queue.
501 **/
502static inline void
503lpfc_debug_dump_dat_rq(struct lpfc_hba *phba)
504{
505 printk(KERN_ERR "DAT RQ: RQ[Qid:%d]\n",
506 phba->sli4_hba.dat_rq->queue_id);
507 lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
508}
509
510/**
511 * lpfc_debug_dump_hdr_rq - dump all entries from the receive header queue
512 * @phba: Pointer to HBA context object.
513 *
514 * This function dumps all entries from the receive header queue.
515 **/
516static inline void
517lpfc_debug_dump_hdr_rq(struct lpfc_hba *phba)
518{
519 printk(KERN_ERR "HDR RQ: RQ[Qid:%d]\n",
520 phba->sli4_hba.hdr_rq->queue_id);
521 lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
522}
523
524/**
James Smart809c7532012-05-09 21:19:25 -0400525 * lpfc_debug_dump_wq_by_id - dump all entries from a work queue by queue id
526 * @phba: Pointer to HBA context object.
527 * @qid: Work queue identifier.
528 *
529 * This function dumps all entries from a work queue identified by the queue
530 * identifier.
531 **/
532static inline void
533lpfc_debug_dump_wq_by_id(struct lpfc_hba *phba, int qid)
534{
535 int wq_idx;
536
James Smart67d12732012-08-03 12:36:13 -0400537 for (wq_idx = 0; wq_idx < phba->cfg_fcp_io_channel; wq_idx++)
James Smart809c7532012-05-09 21:19:25 -0400538 if (phba->sli4_hba.fcp_wq[wq_idx]->queue_id == qid)
539 break;
James Smart67d12732012-08-03 12:36:13 -0400540 if (wq_idx < phba->cfg_fcp_io_channel) {
James Smart1d9d5a92017-02-12 13:52:29 -0800541 pr_err("FCP WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
James Smart809c7532012-05-09 21:19:25 -0400542 lpfc_debug_dump_q(phba->sli4_hba.fcp_wq[wq_idx]);
543 return;
544 }
545
James Smart895427b2017-02-12 13:52:30 -0800546 for (wq_idx = 0; wq_idx < phba->cfg_nvme_io_channel; wq_idx++)
547 if (phba->sli4_hba.nvme_wq[wq_idx]->queue_id == qid)
548 break;
549 if (wq_idx < phba->cfg_nvme_io_channel) {
550 pr_err("NVME WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
551 lpfc_debug_dump_q(phba->sli4_hba.nvme_wq[wq_idx]);
552 return;
553 }
554
James Smart809c7532012-05-09 21:19:25 -0400555 if (phba->sli4_hba.els_wq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800556 pr_err("ELS WQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400557 lpfc_debug_dump_q(phba->sli4_hba.els_wq);
James Smart1d9d5a92017-02-12 13:52:29 -0800558 return;
James Smart809c7532012-05-09 21:19:25 -0400559 }
James Smart895427b2017-02-12 13:52:30 -0800560
561 if (phba->sli4_hba.nvmels_wq->queue_id == qid) {
562 pr_err("NVME LS WQ[Qid:%d]\n", qid);
563 lpfc_debug_dump_q(phba->sli4_hba.nvmels_wq);
564 }
James Smart809c7532012-05-09 21:19:25 -0400565}
566
567/**
568 * lpfc_debug_dump_mq_by_id - dump all entries from a mbox queue by queue id
569 * @phba: Pointer to HBA context object.
570 * @qid: Mbox work queue identifier.
571 *
572 * This function dumps all entries from a mbox work queue identified by the
573 * queue identifier.
574 **/
575static inline void
576lpfc_debug_dump_mq_by_id(struct lpfc_hba *phba, int qid)
577{
578 if (phba->sli4_hba.mbx_wq->queue_id == qid) {
579 printk(KERN_ERR "MBX WQ[Qid:%d]\n", qid);
580 lpfc_debug_dump_q(phba->sli4_hba.mbx_wq);
581 }
582}
583
584/**
585 * lpfc_debug_dump_rq_by_id - dump all entries from a receive queue by queue id
586 * @phba: Pointer to HBA context object.
587 * @qid: Receive queue identifier.
588 *
589 * This function dumps all entries from a receive queue identified by the
590 * queue identifier.
591 **/
592static inline void
593lpfc_debug_dump_rq_by_id(struct lpfc_hba *phba, int qid)
594{
595 if (phba->sli4_hba.hdr_rq->queue_id == qid) {
596 printk(KERN_ERR "HDR RQ[Qid:%d]\n", qid);
597 lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
598 return;
599 }
600 if (phba->sli4_hba.dat_rq->queue_id == qid) {
601 printk(KERN_ERR "DAT RQ[Qid:%d]\n", qid);
602 lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
603 }
604}
605
606/**
607 * lpfc_debug_dump_cq_by_id - dump all entries from a cmpl queue by queue id
608 * @phba: Pointer to HBA context object.
609 * @qid: Complete queue identifier.
610 *
611 * This function dumps all entries from a complete queue identified by the
612 * queue identifier.
613 **/
614static inline void
615lpfc_debug_dump_cq_by_id(struct lpfc_hba *phba, int qid)
616{
James Smart1d9d5a92017-02-12 13:52:29 -0800617 int cq_idx;
James Smart809c7532012-05-09 21:19:25 -0400618
James Smart1d9d5a92017-02-12 13:52:29 -0800619 for (cq_idx = 0; cq_idx < phba->cfg_fcp_io_channel; cq_idx++)
James Smart809c7532012-05-09 21:19:25 -0400620 if (phba->sli4_hba.fcp_cq[cq_idx]->queue_id == qid)
621 break;
James Smart809c7532012-05-09 21:19:25 -0400622
James Smart67d12732012-08-03 12:36:13 -0400623 if (cq_idx < phba->cfg_fcp_io_channel) {
James Smart1d9d5a92017-02-12 13:52:29 -0800624 pr_err("FCP CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
James Smart809c7532012-05-09 21:19:25 -0400625 lpfc_debug_dump_q(phba->sli4_hba.fcp_cq[cq_idx]);
626 return;
627 }
628
James Smart895427b2017-02-12 13:52:30 -0800629 for (cq_idx = 0; cq_idx < phba->cfg_nvme_io_channel; cq_idx++)
630 if (phba->sli4_hba.nvme_cq[cq_idx]->queue_id == qid)
631 break;
632
633 if (cq_idx < phba->cfg_nvme_io_channel) {
634 pr_err("NVME CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
635 lpfc_debug_dump_q(phba->sli4_hba.nvme_cq[cq_idx]);
636 return;
637 }
638
James Smart809c7532012-05-09 21:19:25 -0400639 if (phba->sli4_hba.els_cq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800640 pr_err("ELS CQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400641 lpfc_debug_dump_q(phba->sli4_hba.els_cq);
642 return;
643 }
644
James Smart895427b2017-02-12 13:52:30 -0800645 if (phba->sli4_hba.nvmels_cq->queue_id == qid) {
646 pr_err("NVME LS CQ[Qid:%d]\n", qid);
647 lpfc_debug_dump_q(phba->sli4_hba.nvmels_cq);
648 return;
649 }
650
James Smart809c7532012-05-09 21:19:25 -0400651 if (phba->sli4_hba.mbx_cq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800652 pr_err("MBX CQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400653 lpfc_debug_dump_q(phba->sli4_hba.mbx_cq);
654 }
655}
656
657/**
658 * lpfc_debug_dump_eq_by_id - dump all entries from an event queue by queue id
659 * @phba: Pointer to HBA context object.
660 * @qid: Complete queue identifier.
661 *
662 * This function dumps all entries from an event queue identified by the
663 * queue identifier.
664 **/
665static inline void
666lpfc_debug_dump_eq_by_id(struct lpfc_hba *phba, int qid)
667{
668 int eq_idx;
669
James Smart895427b2017-02-12 13:52:30 -0800670 for (eq_idx = 0; eq_idx < phba->io_channel_irqs; eq_idx++)
James Smart67d12732012-08-03 12:36:13 -0400671 if (phba->sli4_hba.hba_eq[eq_idx]->queue_id == qid)
James Smart809c7532012-05-09 21:19:25 -0400672 break;
James Smart809c7532012-05-09 21:19:25 -0400673
James Smart895427b2017-02-12 13:52:30 -0800674 if (eq_idx < phba->io_channel_irqs) {
James Smart809c7532012-05-09 21:19:25 -0400675 printk(KERN_ERR "FCP EQ[Idx:%d|Qid:%d]\n", eq_idx, qid);
James Smart67d12732012-08-03 12:36:13 -0400676 lpfc_debug_dump_q(phba->sli4_hba.hba_eq[eq_idx]);
James Smart809c7532012-05-09 21:19:25 -0400677 return;
678 }
James Smart809c7532012-05-09 21:19:25 -0400679}
680
681void lpfc_debug_dump_all_queues(struct lpfc_hba *);