blob: 5312e0f9deb64a141558237f8347bf2e48d15c8e [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 Smartbd2cdd52017-02-12 13:52:33 -080053/* nvmestat output buffer size */
54#define LPFC_NVMESTAT_SIZE 8192
55#define LPFC_NVMEKTIME_SIZE 8192
56#define LPFC_CPUCHECK_SIZE 8192
57#define LPFC_NVMEIO_TRC_SIZE 8192
58
59#define LPFC_DEBUG_OUT_LINE_SZ 80
60
James Smartb76f2dc2011-07-22 18:37:42 -040061/*
62 * For SLI4 iDiag debugfs diagnostics tool
63 */
64
James Smart86a80842011-04-16 11:03:04 -040065/* pciConf */
66#define LPFC_PCI_CFG_BROWSE 0xffff
67#define LPFC_PCI_CFG_RD_CMD_ARG 2
68#define LPFC_PCI_CFG_WR_CMD_ARG 3
James Smart2a622bf2011-02-16 12:40:06 -050069#define LPFC_PCI_CFG_SIZE 4096
James Smart2a622bf2011-02-16 12:40:06 -050070#define LPFC_PCI_CFG_RD_SIZE (LPFC_PCI_CFG_SIZE/4)
71
James Smartb76f2dc2011-07-22 18:37:42 -040072#define IDIAG_PCICFG_WHERE_INDX 0
73#define IDIAG_PCICFG_COUNT_INDX 1
74#define IDIAG_PCICFG_VALUE_INDX 2
75
76/* barAcc */
77#define LPFC_PCI_BAR_BROWSE 0xffff
78#define LPFC_PCI_BAR_RD_CMD_ARG 3
79#define LPFC_PCI_BAR_WR_CMD_ARG 3
80
81#define LPFC_PCI_IF0_BAR0_SIZE (1024 * 16)
82#define LPFC_PCI_IF0_BAR1_SIZE (1024 * 128)
83#define LPFC_PCI_IF0_BAR2_SIZE (1024 * 128)
84#define LPFC_PCI_IF2_BAR0_SIZE (1024 * 32)
85
86#define LPFC_PCI_BAR_RD_BUF_SIZE 4096
87#define LPFC_PCI_BAR_RD_SIZE (LPFC_PCI_BAR_RD_BUF_SIZE/4)
88
89#define LPFC_PCI_IF0_BAR0_RD_SIZE (LPFC_PCI_IF0_BAR0_SIZE/4)
90#define LPFC_PCI_IF0_BAR1_RD_SIZE (LPFC_PCI_IF0_BAR1_SIZE/4)
91#define LPFC_PCI_IF0_BAR2_RD_SIZE (LPFC_PCI_IF0_BAR2_SIZE/4)
92#define LPFC_PCI_IF2_BAR0_RD_SIZE (LPFC_PCI_IF2_BAR0_SIZE/4)
93
94#define IDIAG_BARACC_BAR_NUM_INDX 0
95#define IDIAG_BARACC_OFF_SET_INDX 1
96#define IDIAG_BARACC_ACC_MOD_INDX 2
97#define IDIAG_BARACC_REG_VAL_INDX 2
98#define IDIAG_BARACC_BAR_SZE_INDX 3
99
100#define IDIAG_BARACC_BAR_0 0
101#define IDIAG_BARACC_BAR_1 1
102#define IDIAG_BARACC_BAR_2 2
103
104#define SINGLE_WORD 1
105
James Smart86a80842011-04-16 11:03:04 -0400106/* queue info */
107#define LPFC_QUE_INFO_GET_BUF_SIZE 4096
108
109/* queue acc */
110#define LPFC_QUE_ACC_BROWSE 0xffff
111#define LPFC_QUE_ACC_RD_CMD_ARG 4
112#define LPFC_QUE_ACC_WR_CMD_ARG 6
113#define LPFC_QUE_ACC_BUF_SIZE 4096
114#define LPFC_QUE_ACC_SIZE (LPFC_QUE_ACC_BUF_SIZE/2)
115
116#define LPFC_IDIAG_EQ 1
117#define LPFC_IDIAG_CQ 2
118#define LPFC_IDIAG_MQ 3
119#define LPFC_IDIAG_WQ 4
120#define LPFC_IDIAG_RQ 5
121
James Smartb76f2dc2011-07-22 18:37:42 -0400122#define IDIAG_QUEACC_QUETP_INDX 0
123#define IDIAG_QUEACC_QUEID_INDX 1
124#define IDIAG_QUEACC_INDEX_INDX 2
125#define IDIAG_QUEACC_COUNT_INDX 3
126#define IDIAG_QUEACC_OFFST_INDX 4
127#define IDIAG_QUEACC_VALUE_INDX 5
128
129/* doorbell register acc */
James Smart86a80842011-04-16 11:03:04 -0400130#define LPFC_DRB_ACC_ALL 0xffff
131#define LPFC_DRB_ACC_RD_CMD_ARG 1
132#define LPFC_DRB_ACC_WR_CMD_ARG 2
133#define LPFC_DRB_ACC_BUF_SIZE 256
134
135#define LPFC_DRB_EQCQ 1
136#define LPFC_DRB_MQ 2
137#define LPFC_DRB_WQ 3
138#define LPFC_DRB_RQ 4
139
140#define LPFC_DRB_MAX 4
James Smart2a622bf2011-02-16 12:40:06 -0500141
James Smartb76f2dc2011-07-22 18:37:42 -0400142#define IDIAG_DRBACC_REGID_INDX 0
143#define IDIAG_DRBACC_VALUE_INDX 1
144
145/* control register acc */
146#define LPFC_CTL_ACC_ALL 0xffff
147#define LPFC_CTL_ACC_RD_CMD_ARG 1
148#define LPFC_CTL_ACC_WR_CMD_ARG 2
149#define LPFC_CTL_ACC_BUF_SIZE 256
150
151#define LPFC_CTL_PORT_SEM 1
152#define LPFC_CTL_PORT_STA 2
153#define LPFC_CTL_PORT_CTL 3
154#define LPFC_CTL_PORT_ER1 4
155#define LPFC_CTL_PORT_ER2 5
156#define LPFC_CTL_PDEV_CTL 6
157
158#define LPFC_CTL_MAX 6
159
160#define IDIAG_CTLACC_REGID_INDX 0
161#define IDIAG_CTLACC_VALUE_INDX 1
162
163/* mailbox access */
164#define LPFC_MBX_DMP_ARG 4
165
166#define LPFC_MBX_ACC_BUF_SIZE 512
167#define LPFC_MBX_ACC_LBUF_SZ 128
168
169#define LPFC_MBX_DMP_MBX_WORD 0x00000001
170#define LPFC_MBX_DMP_MBX_BYTE 0x00000002
171#define LPFC_MBX_DMP_MBX_ALL (LPFC_MBX_DMP_MBX_WORD | LPFC_MBX_DMP_MBX_BYTE)
172
173#define LPFC_BSG_DMP_MBX_RD_MBX 0x00000001
174#define LPFC_BSG_DMP_MBX_RD_BUF 0x00000002
175#define LPFC_BSG_DMP_MBX_WR_MBX 0x00000004
176#define LPFC_BSG_DMP_MBX_WR_BUF 0x00000008
177#define LPFC_BSG_DMP_MBX_ALL (LPFC_BSG_DMP_MBX_RD_MBX | \
178 LPFC_BSG_DMP_MBX_RD_BUF | \
179 LPFC_BSG_DMP_MBX_WR_MBX | \
180 LPFC_BSG_DMP_MBX_WR_BUF)
181
182#define LPFC_MBX_DMP_ALL 0xffff
183#define LPFC_MBX_ALL_CMD 0xff
184
185#define IDIAG_MBXACC_MBCMD_INDX 0
186#define IDIAG_MBXACC_DPMAP_INDX 1
187#define IDIAG_MBXACC_DPCNT_INDX 2
188#define IDIAG_MBXACC_WDCNT_INDX 3
189
190/* extents access */
191#define LPFC_EXT_ACC_CMD_ARG 1
192#define LPFC_EXT_ACC_BUF_SIZE 4096
193
194#define LPFC_EXT_ACC_AVAIL 0x1
195#define LPFC_EXT_ACC_ALLOC 0x2
196#define LPFC_EXT_ACC_DRIVR 0x4
197#define LPFC_EXT_ACC_ALL (LPFC_EXT_ACC_DRIVR | \
198 LPFC_EXT_ACC_AVAIL | \
199 LPFC_EXT_ACC_ALLOC)
200
201#define IDIAG_EXTACC_EXMAP_INDX 0
202
James Smart2a622bf2011-02-16 12:40:06 -0500203#define SIZE_U8 sizeof(uint8_t)
204#define SIZE_U16 sizeof(uint16_t)
205#define SIZE_U32 sizeof(uint32_t)
206
James Smartbd2cdd52017-02-12 13:52:33 -0800207#define lpfc_nvmeio_data(phba, fmt, arg...) \
208 { \
209 if (phba->nvmeio_trc_on) \
210 lpfc_debugfs_nvme_trc(phba, fmt, ##arg); \
211 }
212
James Smart2a622bf2011-02-16 12:40:06 -0500213struct lpfc_debug {
214 char *i_private;
215 char op;
216#define LPFC_IDIAG_OP_RD 1
217#define LPFC_IDIAG_OP_WR 2
218 char *buffer;
219 int len;
220};
221
James Smarta58cbd52007-08-02 11:09:43 -0400222struct lpfc_debugfs_trc {
James Smart858c9f62007-06-17 19:56:39 -0500223 char *fmt;
224 uint32_t data1;
225 uint32_t data2;
226 uint32_t data3;
227 uint32_t seq_cnt;
228 unsigned long jif;
229};
James Smart2a622bf2011-02-16 12:40:06 -0500230
James Smartbd2cdd52017-02-12 13:52:33 -0800231struct lpfc_debugfs_nvmeio_trc {
232 char *fmt;
233 uint16_t data1;
234 uint16_t data2;
235 uint32_t data3;
236};
237
James Smart2a622bf2011-02-16 12:40:06 -0500238struct lpfc_idiag_offset {
239 uint32_t last_rd;
240};
241
James Smart86a80842011-04-16 11:03:04 -0400242#define LPFC_IDIAG_CMD_DATA_SIZE 8
James Smart2a622bf2011-02-16 12:40:06 -0500243struct lpfc_idiag_cmd {
244 uint32_t opcode;
245#define LPFC_IDIAG_CMD_PCICFG_RD 0x00000001
246#define LPFC_IDIAG_CMD_PCICFG_WR 0x00000002
247#define LPFC_IDIAG_CMD_PCICFG_ST 0x00000003
248#define LPFC_IDIAG_CMD_PCICFG_CL 0x00000004
James Smart86a80842011-04-16 11:03:04 -0400249
James Smartb76f2dc2011-07-22 18:37:42 -0400250#define LPFC_IDIAG_CMD_BARACC_RD 0x00000008
251#define LPFC_IDIAG_CMD_BARACC_WR 0x00000009
252#define LPFC_IDIAG_CMD_BARACC_ST 0x0000000a
253#define LPFC_IDIAG_CMD_BARACC_CL 0x0000000b
254
James Smart86a80842011-04-16 11:03:04 -0400255#define LPFC_IDIAG_CMD_QUEACC_RD 0x00000011
256#define LPFC_IDIAG_CMD_QUEACC_WR 0x00000012
257#define LPFC_IDIAG_CMD_QUEACC_ST 0x00000013
258#define LPFC_IDIAG_CMD_QUEACC_CL 0x00000014
259
260#define LPFC_IDIAG_CMD_DRBACC_RD 0x00000021
261#define LPFC_IDIAG_CMD_DRBACC_WR 0x00000022
262#define LPFC_IDIAG_CMD_DRBACC_ST 0x00000023
263#define LPFC_IDIAG_CMD_DRBACC_CL 0x00000024
James Smartb76f2dc2011-07-22 18:37:42 -0400264
265#define LPFC_IDIAG_CMD_CTLACC_RD 0x00000031
266#define LPFC_IDIAG_CMD_CTLACC_WR 0x00000032
267#define LPFC_IDIAG_CMD_CTLACC_ST 0x00000033
268#define LPFC_IDIAG_CMD_CTLACC_CL 0x00000034
269
270#define LPFC_IDIAG_CMD_MBXACC_DP 0x00000041
271#define LPFC_IDIAG_BSG_MBXACC_DP 0x00000042
272
273#define LPFC_IDIAG_CMD_EXTACC_RD 0x00000051
274
James Smart2a622bf2011-02-16 12:40:06 -0500275 uint32_t data[LPFC_IDIAG_CMD_DATA_SIZE];
276};
277
278struct lpfc_idiag {
279 uint32_t active;
280 struct lpfc_idiag_cmd cmd;
281 struct lpfc_idiag_offset offset;
James Smart86a80842011-04-16 11:03:04 -0400282 void *ptr_private;
James Smart2a622bf2011-02-16 12:40:06 -0500283};
James Smart858c9f62007-06-17 19:56:39 -0500284#endif
285
286/* Mask for discovery_trace */
287#define LPFC_DISC_TRC_ELS_CMD 0x1 /* Trace ELS commands */
288#define LPFC_DISC_TRC_ELS_RSP 0x2 /* Trace ELS response */
289#define LPFC_DISC_TRC_ELS_UNSOL 0x4 /* Trace ELS rcv'ed */
290#define LPFC_DISC_TRC_ELS_ALL 0x7 /* Trace ELS */
291#define LPFC_DISC_TRC_MBOX_VPORT 0x8 /* Trace vport MBOXs */
292#define LPFC_DISC_TRC_MBOX 0x10 /* Trace other MBOXs */
293#define LPFC_DISC_TRC_MBOX_ALL 0x18 /* Trace all MBOXs */
294#define LPFC_DISC_TRC_CT 0x20 /* Trace disc CT requests */
295#define LPFC_DISC_TRC_DSM 0x40 /* Trace DSM events */
296#define LPFC_DISC_TRC_RPORT 0x80 /* Trace rport events */
297#define LPFC_DISC_TRC_NODE 0x100 /* Trace ndlp state changes */
298
299#define LPFC_DISC_TRC_DISCOVERY 0xef /* common mask for general
300 * discovery */
301#endif /* H_LPFC_DEBUG_FS */
James Smart809c7532012-05-09 21:19:25 -0400302
303
304/*
305 * Driver debug utility routines outside of debugfs. The debug utility
306 * routines implemented here is intended to be used in the instrumented
307 * debug driver for debugging host or port issues.
308 */
309
310/**
311 * lpfc_debug_dump_qe - dump an specific entry from a queue
312 * @q: Pointer to the queue descriptor.
313 * @idx: Index to the entry on the queue.
314 *
315 * This function dumps an entry indexed by @idx from a queue specified by the
316 * queue descriptor @q.
317 **/
318static inline void
319lpfc_debug_dump_qe(struct lpfc_queue *q, uint32_t idx)
320{
321 char line_buf[LPFC_LBUF_SZ];
322 int i, esize, qe_word_cnt, len;
323 uint32_t *pword;
324
325 /* sanity checks */
326 if (!q)
327 return;
328 if (idx >= q->entry_count)
329 return;
330
331 esize = q->entry_size;
332 qe_word_cnt = esize / sizeof(uint32_t);
333 pword = q->qe[idx].address;
334
335 len = 0;
336 len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
337 if (qe_word_cnt > 8)
338 printk(KERN_ERR "%s\n", line_buf);
339
340 for (i = 0; i < qe_word_cnt; i++) {
341 if (!(i % 8)) {
342 if (i != 0)
343 printk(KERN_ERR "%s\n", line_buf);
344 if (qe_word_cnt > 8) {
345 len = 0;
346 memset(line_buf, 0, LPFC_LBUF_SZ);
347 len += snprintf(line_buf+len, LPFC_LBUF_SZ-len,
348 "%03d: ", i);
349 }
350 }
351 len += snprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
352 ((uint32_t)*pword) & 0xffffffff);
353 pword++;
354 }
355 if (qe_word_cnt <= 8 || (i - 1) % 8)
356 printk(KERN_ERR "%s\n", line_buf);
357}
358
359/**
360 * lpfc_debug_dump_q - dump all entries from an specific queue
361 * @q: Pointer to the queue descriptor.
362 *
363 * This function dumps all entries from a queue specified by the queue
364 * descriptor @q.
365 **/
366static inline void
367lpfc_debug_dump_q(struct lpfc_queue *q)
368{
369 int idx, entry_count;
370
371 /* sanity check */
372 if (!q)
373 return;
374
375 dev_printk(KERN_ERR, &(((q->phba))->pcidev)->dev,
376 "%d: [qid:%d, type:%d, subtype:%d, "
377 "qe_size:%d, qe_count:%d, "
378 "host_index:%d, port_index:%d]\n",
379 (q->phba)->brd_no,
380 q->queue_id, q->type, q->subtype,
381 q->entry_size, q->entry_count,
382 q->host_index, q->hba_index);
383 entry_count = q->entry_count;
384 for (idx = 0; idx < entry_count; idx++)
385 lpfc_debug_dump_qe(q, idx);
386 printk(KERN_ERR "\n");
387}
388
389/**
James Smart895427b2017-02-12 13:52:30 -0800390 * lpfc_debug_dump_wq - dump all entries from the fcp or nvme work queue
James Smart809c7532012-05-09 21:19:25 -0400391 * @phba: Pointer to HBA context object.
James Smart895427b2017-02-12 13:52:30 -0800392 * @wqidx: Index to a FCP or NVME work queue.
James Smart809c7532012-05-09 21:19:25 -0400393 *
James Smart895427b2017-02-12 13:52:30 -0800394 * This function dumps all entries from a FCP or NVME work queue specified
James Smart1d9d5a92017-02-12 13:52:29 -0800395 * by the wqidx.
James Smart809c7532012-05-09 21:19:25 -0400396 **/
397static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800398lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx)
James Smart809c7532012-05-09 21:19:25 -0400399{
James Smart1d9d5a92017-02-12 13:52:29 -0800400 struct lpfc_queue *wq;
401 char *qtypestr;
402
403 if (qtype == DUMP_FCP) {
404 wq = phba->sli4_hba.fcp_wq[wqidx];
405 qtypestr = "FCP";
James Smart895427b2017-02-12 13:52:30 -0800406 } else if (qtype == DUMP_NVME) {
407 wq = phba->sli4_hba.nvme_wq[wqidx];
408 qtypestr = "NVME";
James Smart1d9d5a92017-02-12 13:52:29 -0800409 } else if (qtype == DUMP_MBX) {
410 wq = phba->sli4_hba.mbx_wq;
411 qtypestr = "MBX";
412 } else if (qtype == DUMP_ELS) {
413 wq = phba->sli4_hba.els_wq;
414 qtypestr = "ELS";
James Smart895427b2017-02-12 13:52:30 -0800415 } else if (qtype == DUMP_NVMELS) {
416 wq = phba->sli4_hba.nvmels_wq;
417 qtypestr = "NVMELS";
James Smart1d9d5a92017-02-12 13:52:29 -0800418 } else
James Smart809c7532012-05-09 21:19:25 -0400419 return;
420
James Smart895427b2017-02-12 13:52:30 -0800421 if (qtype == DUMP_FCP || qtype == DUMP_NVME)
James Smart1d9d5a92017-02-12 13:52:29 -0800422 pr_err("%s WQ: WQ[Idx:%d|Qid:%d]\n",
423 qtypestr, wqidx, wq->queue_id);
424 else
425 pr_err("%s WQ: WQ[Qid:%d]\n",
426 qtypestr, wq->queue_id);
427
428 lpfc_debug_dump_q(wq);
James Smart809c7532012-05-09 21:19:25 -0400429}
430
431/**
James Smart895427b2017-02-12 13:52:30 -0800432 * lpfc_debug_dump_cq - dump all entries from a fcp or nvme work queue's
James Smart1d9d5a92017-02-12 13:52:29 -0800433 * cmpl queue
James Smart809c7532012-05-09 21:19:25 -0400434 * @phba: Pointer to HBA context object.
James Smart1d9d5a92017-02-12 13:52:29 -0800435 * @wqidx: Index to a FCP work queue.
James Smart809c7532012-05-09 21:19:25 -0400436 *
James Smart895427b2017-02-12 13:52:30 -0800437 * This function dumps all entries from a FCP or NVME completion queue
James Smart1d9d5a92017-02-12 13:52:29 -0800438 * which is associated to the work queue specified by the @wqidx.
James Smart809c7532012-05-09 21:19:25 -0400439 **/
440static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800441lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
James Smart809c7532012-05-09 21:19:25 -0400442{
James Smart1d9d5a92017-02-12 13:52:29 -0800443 struct lpfc_queue *wq, *cq, *eq;
444 char *qtypestr;
445 int eqidx;
James Smart809c7532012-05-09 21:19:25 -0400446
James Smart895427b2017-02-12 13:52:30 -0800447 /* fcp/nvme wq and cq are 1:1, thus same indexes */
James Smart1d9d5a92017-02-12 13:52:29 -0800448
449 if (qtype == DUMP_FCP) {
450 wq = phba->sli4_hba.fcp_wq[wqidx];
451 cq = phba->sli4_hba.fcp_cq[wqidx];
452 qtypestr = "FCP";
James Smart895427b2017-02-12 13:52:30 -0800453 } else if (qtype == DUMP_NVME) {
454 wq = phba->sli4_hba.nvme_wq[wqidx];
455 cq = phba->sli4_hba.nvme_cq[wqidx];
456 qtypestr = "NVME";
James Smart1d9d5a92017-02-12 13:52:29 -0800457 } else if (qtype == DUMP_MBX) {
458 wq = phba->sli4_hba.mbx_wq;
459 cq = phba->sli4_hba.mbx_cq;
460 qtypestr = "MBX";
461 } else if (qtype == DUMP_ELS) {
462 wq = phba->sli4_hba.els_wq;
463 cq = phba->sli4_hba.els_cq;
464 qtypestr = "ELS";
James Smart895427b2017-02-12 13:52:30 -0800465 } else if (qtype == DUMP_NVMELS) {
466 wq = phba->sli4_hba.nvmels_wq;
467 cq = phba->sli4_hba.nvmels_cq;
468 qtypestr = "NVMELS";
James Smart1d9d5a92017-02-12 13:52:29 -0800469 } else
James Smart809c7532012-05-09 21:19:25 -0400470 return;
471
James Smart895427b2017-02-12 13:52:30 -0800472 for (eqidx = 0; eqidx < phba->io_channel_irqs; eqidx++) {
James Smart1d9d5a92017-02-12 13:52:29 -0800473 eq = phba->sli4_hba.hba_eq[eqidx];
474 if (cq->assoc_qid == eq->queue_id)
James Smart809c7532012-05-09 21:19:25 -0400475 break;
James Smart1d9d5a92017-02-12 13:52:29 -0800476 }
James Smart895427b2017-02-12 13:52:30 -0800477 if (eqidx == phba->io_channel_irqs) {
James Smart1d9d5a92017-02-12 13:52:29 -0800478 pr_err("Couldn't find EQ for CQ. Using EQ[0]\n");
479 eqidx = 0;
480 eq = phba->sli4_hba.hba_eq[0];
James Smart3b3da6a2012-06-12 13:54:20 -0400481 }
James Smart809c7532012-05-09 21:19:25 -0400482
James Smart895427b2017-02-12 13:52:30 -0800483 if (qtype == DUMP_FCP || qtype == DUMP_NVME)
James Smart1d9d5a92017-02-12 13:52:29 -0800484 pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
485 "->EQ[Idx:%d|Qid:%d]:\n",
486 qtypestr, wqidx, wq->queue_id, wqidx, cq->queue_id,
487 eqidx, eq->queue_id);
488 else
489 pr_err("%s CQ: WQ[Qid:%d]->CQ[Qid:%d]"
490 "->EQ[Idx:%d|Qid:%d]:\n",
491 qtypestr, wq->queue_id, cq->queue_id,
492 eqidx, eq->queue_id);
493
494 lpfc_debug_dump_q(cq);
James Smart809c7532012-05-09 21:19:25 -0400495}
496
497/**
James Smart67d12732012-08-03 12:36:13 -0400498 * lpfc_debug_dump_hba_eq - dump all entries from a fcp work queue's evt queue
James Smart809c7532012-05-09 21:19:25 -0400499 * @phba: Pointer to HBA context object.
500 * @fcp_wqidx: Index to a FCP work queue.
501 *
502 * This function dumps all entries from a FCP event queue which is
503 * associated to the FCP work queue specified by the @fcp_wqidx.
504 **/
505static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800506lpfc_debug_dump_hba_eq(struct lpfc_hba *phba, int qidx)
James Smart809c7532012-05-09 21:19:25 -0400507{
James Smart1d9d5a92017-02-12 13:52:29 -0800508 struct lpfc_queue *qp;
James Smart809c7532012-05-09 21:19:25 -0400509
James Smart1d9d5a92017-02-12 13:52:29 -0800510 qp = phba->sli4_hba.hba_eq[qidx];
James Smart809c7532012-05-09 21:19:25 -0400511
James Smart1d9d5a92017-02-12 13:52:29 -0800512 pr_err("EQ[Idx:%d|Qid:%d]\n", qidx, qp->queue_id);
James Smart809c7532012-05-09 21:19:25 -0400513
James Smart1d9d5a92017-02-12 13:52:29 -0800514 lpfc_debug_dump_q(qp);
James Smart809c7532012-05-09 21:19:25 -0400515}
516
517/**
518 * lpfc_debug_dump_dat_rq - dump all entries from the receive data queue
519 * @phba: Pointer to HBA context object.
520 *
521 * This function dumps all entries from the receive data queue.
522 **/
523static inline void
524lpfc_debug_dump_dat_rq(struct lpfc_hba *phba)
525{
526 printk(KERN_ERR "DAT RQ: RQ[Qid:%d]\n",
527 phba->sli4_hba.dat_rq->queue_id);
528 lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
529}
530
531/**
532 * lpfc_debug_dump_hdr_rq - dump all entries from the receive header queue
533 * @phba: Pointer to HBA context object.
534 *
535 * This function dumps all entries from the receive header queue.
536 **/
537static inline void
538lpfc_debug_dump_hdr_rq(struct lpfc_hba *phba)
539{
540 printk(KERN_ERR "HDR RQ: RQ[Qid:%d]\n",
541 phba->sli4_hba.hdr_rq->queue_id);
542 lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
543}
544
545/**
James Smart809c7532012-05-09 21:19:25 -0400546 * lpfc_debug_dump_wq_by_id - dump all entries from a work queue by queue id
547 * @phba: Pointer to HBA context object.
548 * @qid: Work queue identifier.
549 *
550 * This function dumps all entries from a work queue identified by the queue
551 * identifier.
552 **/
553static inline void
554lpfc_debug_dump_wq_by_id(struct lpfc_hba *phba, int qid)
555{
556 int wq_idx;
557
James Smart67d12732012-08-03 12:36:13 -0400558 for (wq_idx = 0; wq_idx < phba->cfg_fcp_io_channel; wq_idx++)
James Smart809c7532012-05-09 21:19:25 -0400559 if (phba->sli4_hba.fcp_wq[wq_idx]->queue_id == qid)
560 break;
James Smart67d12732012-08-03 12:36:13 -0400561 if (wq_idx < phba->cfg_fcp_io_channel) {
James Smart1d9d5a92017-02-12 13:52:29 -0800562 pr_err("FCP WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
James Smart809c7532012-05-09 21:19:25 -0400563 lpfc_debug_dump_q(phba->sli4_hba.fcp_wq[wq_idx]);
564 return;
565 }
566
James Smart895427b2017-02-12 13:52:30 -0800567 for (wq_idx = 0; wq_idx < phba->cfg_nvme_io_channel; wq_idx++)
568 if (phba->sli4_hba.nvme_wq[wq_idx]->queue_id == qid)
569 break;
570 if (wq_idx < phba->cfg_nvme_io_channel) {
571 pr_err("NVME WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
572 lpfc_debug_dump_q(phba->sli4_hba.nvme_wq[wq_idx]);
573 return;
574 }
575
James Smart809c7532012-05-09 21:19:25 -0400576 if (phba->sli4_hba.els_wq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800577 pr_err("ELS WQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400578 lpfc_debug_dump_q(phba->sli4_hba.els_wq);
James Smart1d9d5a92017-02-12 13:52:29 -0800579 return;
James Smart809c7532012-05-09 21:19:25 -0400580 }
James Smart895427b2017-02-12 13:52:30 -0800581
582 if (phba->sli4_hba.nvmels_wq->queue_id == qid) {
583 pr_err("NVME LS WQ[Qid:%d]\n", qid);
584 lpfc_debug_dump_q(phba->sli4_hba.nvmels_wq);
585 }
James Smart809c7532012-05-09 21:19:25 -0400586}
587
588/**
589 * lpfc_debug_dump_mq_by_id - dump all entries from a mbox queue by queue id
590 * @phba: Pointer to HBA context object.
591 * @qid: Mbox work queue identifier.
592 *
593 * This function dumps all entries from a mbox work queue identified by the
594 * queue identifier.
595 **/
596static inline void
597lpfc_debug_dump_mq_by_id(struct lpfc_hba *phba, int qid)
598{
599 if (phba->sli4_hba.mbx_wq->queue_id == qid) {
600 printk(KERN_ERR "MBX WQ[Qid:%d]\n", qid);
601 lpfc_debug_dump_q(phba->sli4_hba.mbx_wq);
602 }
603}
604
605/**
606 * lpfc_debug_dump_rq_by_id - dump all entries from a receive queue by queue id
607 * @phba: Pointer to HBA context object.
608 * @qid: Receive queue identifier.
609 *
610 * This function dumps all entries from a receive queue identified by the
611 * queue identifier.
612 **/
613static inline void
614lpfc_debug_dump_rq_by_id(struct lpfc_hba *phba, int qid)
615{
616 if (phba->sli4_hba.hdr_rq->queue_id == qid) {
617 printk(KERN_ERR "HDR RQ[Qid:%d]\n", qid);
618 lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
619 return;
620 }
621 if (phba->sli4_hba.dat_rq->queue_id == qid) {
622 printk(KERN_ERR "DAT RQ[Qid:%d]\n", qid);
623 lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
624 }
625}
626
627/**
628 * lpfc_debug_dump_cq_by_id - dump all entries from a cmpl queue by queue id
629 * @phba: Pointer to HBA context object.
630 * @qid: Complete queue identifier.
631 *
632 * This function dumps all entries from a complete queue identified by the
633 * queue identifier.
634 **/
635static inline void
636lpfc_debug_dump_cq_by_id(struct lpfc_hba *phba, int qid)
637{
James Smart1d9d5a92017-02-12 13:52:29 -0800638 int cq_idx;
James Smart809c7532012-05-09 21:19:25 -0400639
James Smart1d9d5a92017-02-12 13:52:29 -0800640 for (cq_idx = 0; cq_idx < phba->cfg_fcp_io_channel; cq_idx++)
James Smart809c7532012-05-09 21:19:25 -0400641 if (phba->sli4_hba.fcp_cq[cq_idx]->queue_id == qid)
642 break;
James Smart809c7532012-05-09 21:19:25 -0400643
James Smart67d12732012-08-03 12:36:13 -0400644 if (cq_idx < phba->cfg_fcp_io_channel) {
James Smart1d9d5a92017-02-12 13:52:29 -0800645 pr_err("FCP CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
James Smart809c7532012-05-09 21:19:25 -0400646 lpfc_debug_dump_q(phba->sli4_hba.fcp_cq[cq_idx]);
647 return;
648 }
649
James Smart895427b2017-02-12 13:52:30 -0800650 for (cq_idx = 0; cq_idx < phba->cfg_nvme_io_channel; cq_idx++)
651 if (phba->sli4_hba.nvme_cq[cq_idx]->queue_id == qid)
652 break;
653
654 if (cq_idx < phba->cfg_nvme_io_channel) {
655 pr_err("NVME CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
656 lpfc_debug_dump_q(phba->sli4_hba.nvme_cq[cq_idx]);
657 return;
658 }
659
James Smart809c7532012-05-09 21:19:25 -0400660 if (phba->sli4_hba.els_cq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800661 pr_err("ELS CQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400662 lpfc_debug_dump_q(phba->sli4_hba.els_cq);
663 return;
664 }
665
James Smart895427b2017-02-12 13:52:30 -0800666 if (phba->sli4_hba.nvmels_cq->queue_id == qid) {
667 pr_err("NVME LS CQ[Qid:%d]\n", qid);
668 lpfc_debug_dump_q(phba->sli4_hba.nvmels_cq);
669 return;
670 }
671
James Smart809c7532012-05-09 21:19:25 -0400672 if (phba->sli4_hba.mbx_cq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800673 pr_err("MBX CQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400674 lpfc_debug_dump_q(phba->sli4_hba.mbx_cq);
675 }
676}
677
678/**
679 * lpfc_debug_dump_eq_by_id - dump all entries from an event queue by queue id
680 * @phba: Pointer to HBA context object.
681 * @qid: Complete queue identifier.
682 *
683 * This function dumps all entries from an event queue identified by the
684 * queue identifier.
685 **/
686static inline void
687lpfc_debug_dump_eq_by_id(struct lpfc_hba *phba, int qid)
688{
689 int eq_idx;
690
James Smart895427b2017-02-12 13:52:30 -0800691 for (eq_idx = 0; eq_idx < phba->io_channel_irqs; eq_idx++)
James Smart67d12732012-08-03 12:36:13 -0400692 if (phba->sli4_hba.hba_eq[eq_idx]->queue_id == qid)
James Smart809c7532012-05-09 21:19:25 -0400693 break;
James Smart809c7532012-05-09 21:19:25 -0400694
James Smart895427b2017-02-12 13:52:30 -0800695 if (eq_idx < phba->io_channel_irqs) {
James Smart809c7532012-05-09 21:19:25 -0400696 printk(KERN_ERR "FCP EQ[Idx:%d|Qid:%d]\n", eq_idx, qid);
James Smart67d12732012-08-03 12:36:13 -0400697 lpfc_debug_dump_q(phba->sli4_hba.hba_eq[eq_idx]);
James Smart809c7532012-05-09 21:19:25 -0400698 return;
699 }
James Smart809c7532012-05-09 21:19:25 -0400700}
701
702void lpfc_debug_dump_all_queues(struct lpfc_hba *);