blob: 34070874616d0cc7535b4844f1838506e97dc55b [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 Smart0d041212019-01-28 11:14:41 -08004 * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term *
James Smart4ae2ebd2018-06-26 08:24:31 -07005 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
James Smart2a622bf2011-02-16 12:40:06 -05006 * Copyright (C) 2007-2011 Emulex. All rights reserved. *
James Smart858c9f62007-06-17 19:56:39 -05007 * EMULEX and SLI are trademarks of Emulex. *
James Smartd080abe2017-02-12 13:52:39 -08008 * www.broadcom.com *
James Smart858c9f62007-06-17 19:56:39 -05009 * *
10 * This program is free software; you can redistribute it and/or *
11 * modify it under the terms of version 2 of the GNU General *
12 * Public License as published by the Free Software Foundation. *
13 * This program is distributed in the hope that it will be useful. *
14 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
15 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
17 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18 * TO BE LEGALLY INVALID. See the GNU General Public License for *
19 * more details, a copy of which can be found in the file COPYING *
20 * included with this package. *
21 *******************************************************************/
22
23#ifndef _H_LPFC_DEBUG_FS
24#define _H_LPFC_DEBUG_FS
25
James Smart923e4b62008-12-04 22:40:07 -050026#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
James Smart2a622bf2011-02-16 12:40:06 -050027
28/* size of output line, for discovery_trace and slow_ring_trace */
29#define LPFC_DEBUG_TRC_ENTRY_SIZE 100
30
31/* nodelist output buffer size */
32#define LPFC_NODELIST_SIZE 8192
33#define LPFC_NODELIST_ENTRY_SIZE 120
34
35/* dumpHBASlim output buffer size */
36#define LPFC_DUMPHBASLIM_SIZE 4096
37
38/* dumpHostSlim output buffer size */
39#define LPFC_DUMPHOSTSLIM_SIZE 4096
40
James Smartb84daac2012-08-03 12:35:13 -040041/* dumpSLIqinfo output buffer size */
42#define LPFC_DUMPSLIQINFO_SIZE 4096
43
James Smart2a622bf2011-02-16 12:40:06 -050044/* hbqinfo output buffer size */
45#define LPFC_HBQINFO_SIZE 8192
46
James Smartbd2cdd52017-02-12 13:52:33 -080047/* nvmestat output buffer size */
48#define LPFC_NVMESTAT_SIZE 8192
49#define LPFC_NVMEKTIME_SIZE 8192
50#define LPFC_CPUCHECK_SIZE 8192
51#define LPFC_NVMEIO_TRC_SIZE 8192
52
James Smart4c47efc2019-01-28 11:14:25 -080053/* scsistat output buffer size */
54#define LPFC_SCSISTAT_SIZE 8192
55
James Smartbd2cdd52017-02-12 13:52:33 -080056#define LPFC_DEBUG_OUT_LINE_SZ 80
57
James Smartb76f2dc2011-07-22 18:37:42 -040058/*
59 * For SLI4 iDiag debugfs diagnostics tool
60 */
61
James Smart86a80842011-04-16 11:03:04 -040062/* pciConf */
63#define LPFC_PCI_CFG_BROWSE 0xffff
64#define LPFC_PCI_CFG_RD_CMD_ARG 2
65#define LPFC_PCI_CFG_WR_CMD_ARG 3
James Smart2a622bf2011-02-16 12:40:06 -050066#define LPFC_PCI_CFG_SIZE 4096
James Smart2a622bf2011-02-16 12:40:06 -050067#define LPFC_PCI_CFG_RD_SIZE (LPFC_PCI_CFG_SIZE/4)
68
James Smartb76f2dc2011-07-22 18:37:42 -040069#define IDIAG_PCICFG_WHERE_INDX 0
70#define IDIAG_PCICFG_COUNT_INDX 1
71#define IDIAG_PCICFG_VALUE_INDX 2
72
73/* barAcc */
74#define LPFC_PCI_BAR_BROWSE 0xffff
75#define LPFC_PCI_BAR_RD_CMD_ARG 3
76#define LPFC_PCI_BAR_WR_CMD_ARG 3
77
78#define LPFC_PCI_IF0_BAR0_SIZE (1024 * 16)
79#define LPFC_PCI_IF0_BAR1_SIZE (1024 * 128)
80#define LPFC_PCI_IF0_BAR2_SIZE (1024 * 128)
81#define LPFC_PCI_IF2_BAR0_SIZE (1024 * 32)
82
83#define LPFC_PCI_BAR_RD_BUF_SIZE 4096
84#define LPFC_PCI_BAR_RD_SIZE (LPFC_PCI_BAR_RD_BUF_SIZE/4)
85
86#define LPFC_PCI_IF0_BAR0_RD_SIZE (LPFC_PCI_IF0_BAR0_SIZE/4)
87#define LPFC_PCI_IF0_BAR1_RD_SIZE (LPFC_PCI_IF0_BAR1_SIZE/4)
88#define LPFC_PCI_IF0_BAR2_RD_SIZE (LPFC_PCI_IF0_BAR2_SIZE/4)
89#define LPFC_PCI_IF2_BAR0_RD_SIZE (LPFC_PCI_IF2_BAR0_SIZE/4)
90
91#define IDIAG_BARACC_BAR_NUM_INDX 0
92#define IDIAG_BARACC_OFF_SET_INDX 1
93#define IDIAG_BARACC_ACC_MOD_INDX 2
94#define IDIAG_BARACC_REG_VAL_INDX 2
95#define IDIAG_BARACC_BAR_SZE_INDX 3
96
97#define IDIAG_BARACC_BAR_0 0
98#define IDIAG_BARACC_BAR_1 1
99#define IDIAG_BARACC_BAR_2 2
100
101#define SINGLE_WORD 1
102
James Smart86a80842011-04-16 11:03:04 -0400103/* queue info */
104#define LPFC_QUE_INFO_GET_BUF_SIZE 4096
105
106/* queue acc */
107#define LPFC_QUE_ACC_BROWSE 0xffff
108#define LPFC_QUE_ACC_RD_CMD_ARG 4
109#define LPFC_QUE_ACC_WR_CMD_ARG 6
110#define LPFC_QUE_ACC_BUF_SIZE 4096
111#define LPFC_QUE_ACC_SIZE (LPFC_QUE_ACC_BUF_SIZE/2)
112
113#define LPFC_IDIAG_EQ 1
114#define LPFC_IDIAG_CQ 2
115#define LPFC_IDIAG_MQ 3
116#define LPFC_IDIAG_WQ 4
117#define LPFC_IDIAG_RQ 5
118
James Smartb76f2dc2011-07-22 18:37:42 -0400119#define IDIAG_QUEACC_QUETP_INDX 0
120#define IDIAG_QUEACC_QUEID_INDX 1
121#define IDIAG_QUEACC_INDEX_INDX 2
122#define IDIAG_QUEACC_COUNT_INDX 3
123#define IDIAG_QUEACC_OFFST_INDX 4
124#define IDIAG_QUEACC_VALUE_INDX 5
125
126/* doorbell register acc */
James Smart86a80842011-04-16 11:03:04 -0400127#define LPFC_DRB_ACC_ALL 0xffff
128#define LPFC_DRB_ACC_RD_CMD_ARG 1
129#define LPFC_DRB_ACC_WR_CMD_ARG 2
130#define LPFC_DRB_ACC_BUF_SIZE 256
131
James Smart9dd35422018-02-22 08:18:41 -0800132#define LPFC_DRB_EQ 1
133#define LPFC_DRB_CQ 2
134#define LPFC_DRB_MQ 3
135#define LPFC_DRB_WQ 4
136#define LPFC_DRB_RQ 5
James Smart86a80842011-04-16 11:03:04 -0400137
James Smart9dd35422018-02-22 08:18:41 -0800138#define LPFC_DRB_MAX 5
James Smart2a622bf2011-02-16 12:40:06 -0500139
James Smartb76f2dc2011-07-22 18:37:42 -0400140#define IDIAG_DRBACC_REGID_INDX 0
141#define IDIAG_DRBACC_VALUE_INDX 1
142
143/* control register acc */
144#define LPFC_CTL_ACC_ALL 0xffff
145#define LPFC_CTL_ACC_RD_CMD_ARG 1
146#define LPFC_CTL_ACC_WR_CMD_ARG 2
147#define LPFC_CTL_ACC_BUF_SIZE 256
148
149#define LPFC_CTL_PORT_SEM 1
150#define LPFC_CTL_PORT_STA 2
151#define LPFC_CTL_PORT_CTL 3
152#define LPFC_CTL_PORT_ER1 4
153#define LPFC_CTL_PORT_ER2 5
154#define LPFC_CTL_PDEV_CTL 6
155
156#define LPFC_CTL_MAX 6
157
158#define IDIAG_CTLACC_REGID_INDX 0
159#define IDIAG_CTLACC_VALUE_INDX 1
160
161/* mailbox access */
162#define LPFC_MBX_DMP_ARG 4
163
164#define LPFC_MBX_ACC_BUF_SIZE 512
165#define LPFC_MBX_ACC_LBUF_SZ 128
166
167#define LPFC_MBX_DMP_MBX_WORD 0x00000001
168#define LPFC_MBX_DMP_MBX_BYTE 0x00000002
169#define LPFC_MBX_DMP_MBX_ALL (LPFC_MBX_DMP_MBX_WORD | LPFC_MBX_DMP_MBX_BYTE)
170
171#define LPFC_BSG_DMP_MBX_RD_MBX 0x00000001
172#define LPFC_BSG_DMP_MBX_RD_BUF 0x00000002
173#define LPFC_BSG_DMP_MBX_WR_MBX 0x00000004
174#define LPFC_BSG_DMP_MBX_WR_BUF 0x00000008
175#define LPFC_BSG_DMP_MBX_ALL (LPFC_BSG_DMP_MBX_RD_MBX | \
176 LPFC_BSG_DMP_MBX_RD_BUF | \
177 LPFC_BSG_DMP_MBX_WR_MBX | \
178 LPFC_BSG_DMP_MBX_WR_BUF)
179
180#define LPFC_MBX_DMP_ALL 0xffff
181#define LPFC_MBX_ALL_CMD 0xff
182
183#define IDIAG_MBXACC_MBCMD_INDX 0
184#define IDIAG_MBXACC_DPMAP_INDX 1
185#define IDIAG_MBXACC_DPCNT_INDX 2
186#define IDIAG_MBXACC_WDCNT_INDX 3
187
188/* extents access */
189#define LPFC_EXT_ACC_CMD_ARG 1
190#define LPFC_EXT_ACC_BUF_SIZE 4096
191
192#define LPFC_EXT_ACC_AVAIL 0x1
193#define LPFC_EXT_ACC_ALLOC 0x2
194#define LPFC_EXT_ACC_DRIVR 0x4
195#define LPFC_EXT_ACC_ALL (LPFC_EXT_ACC_DRIVR | \
196 LPFC_EXT_ACC_AVAIL | \
197 LPFC_EXT_ACC_ALLOC)
198
199#define IDIAG_EXTACC_EXMAP_INDX 0
200
James Smart2a622bf2011-02-16 12:40:06 -0500201#define SIZE_U8 sizeof(uint8_t)
202#define SIZE_U16 sizeof(uint16_t)
203#define SIZE_U32 sizeof(uint32_t)
204
James Smartbd2cdd52017-02-12 13:52:33 -0800205#define lpfc_nvmeio_data(phba, fmt, arg...) \
206 { \
207 if (phba->nvmeio_trc_on) \
208 lpfc_debugfs_nvme_trc(phba, fmt, ##arg); \
209 }
210
James Smart2a622bf2011-02-16 12:40:06 -0500211struct lpfc_debug {
212 char *i_private;
213 char op;
214#define LPFC_IDIAG_OP_RD 1
215#define LPFC_IDIAG_OP_WR 2
216 char *buffer;
217 int len;
218};
219
James Smarta58cbd52007-08-02 11:09:43 -0400220struct lpfc_debugfs_trc {
James Smart858c9f62007-06-17 19:56:39 -0500221 char *fmt;
222 uint32_t data1;
223 uint32_t data2;
224 uint32_t data3;
225 uint32_t seq_cnt;
226 unsigned long jif;
227};
James Smart2a622bf2011-02-16 12:40:06 -0500228
James Smartbd2cdd52017-02-12 13:52:33 -0800229struct lpfc_debugfs_nvmeio_trc {
230 char *fmt;
231 uint16_t data1;
232 uint16_t data2;
233 uint32_t data3;
234};
235
James Smart2a622bf2011-02-16 12:40:06 -0500236struct lpfc_idiag_offset {
237 uint32_t last_rd;
238};
239
James Smart86a80842011-04-16 11:03:04 -0400240#define LPFC_IDIAG_CMD_DATA_SIZE 8
James Smart2a622bf2011-02-16 12:40:06 -0500241struct lpfc_idiag_cmd {
242 uint32_t opcode;
243#define LPFC_IDIAG_CMD_PCICFG_RD 0x00000001
244#define LPFC_IDIAG_CMD_PCICFG_WR 0x00000002
245#define LPFC_IDIAG_CMD_PCICFG_ST 0x00000003
246#define LPFC_IDIAG_CMD_PCICFG_CL 0x00000004
James Smart86a80842011-04-16 11:03:04 -0400247
James Smartb76f2dc2011-07-22 18:37:42 -0400248#define LPFC_IDIAG_CMD_BARACC_RD 0x00000008
249#define LPFC_IDIAG_CMD_BARACC_WR 0x00000009
250#define LPFC_IDIAG_CMD_BARACC_ST 0x0000000a
251#define LPFC_IDIAG_CMD_BARACC_CL 0x0000000b
252
James Smart86a80842011-04-16 11:03:04 -0400253#define LPFC_IDIAG_CMD_QUEACC_RD 0x00000011
254#define LPFC_IDIAG_CMD_QUEACC_WR 0x00000012
255#define LPFC_IDIAG_CMD_QUEACC_ST 0x00000013
256#define LPFC_IDIAG_CMD_QUEACC_CL 0x00000014
257
258#define LPFC_IDIAG_CMD_DRBACC_RD 0x00000021
259#define LPFC_IDIAG_CMD_DRBACC_WR 0x00000022
260#define LPFC_IDIAG_CMD_DRBACC_ST 0x00000023
261#define LPFC_IDIAG_CMD_DRBACC_CL 0x00000024
James Smartb76f2dc2011-07-22 18:37:42 -0400262
263#define LPFC_IDIAG_CMD_CTLACC_RD 0x00000031
264#define LPFC_IDIAG_CMD_CTLACC_WR 0x00000032
265#define LPFC_IDIAG_CMD_CTLACC_ST 0x00000033
266#define LPFC_IDIAG_CMD_CTLACC_CL 0x00000034
267
268#define LPFC_IDIAG_CMD_MBXACC_DP 0x00000041
269#define LPFC_IDIAG_BSG_MBXACC_DP 0x00000042
270
271#define LPFC_IDIAG_CMD_EXTACC_RD 0x00000051
272
James Smart2a622bf2011-02-16 12:40:06 -0500273 uint32_t data[LPFC_IDIAG_CMD_DATA_SIZE];
274};
275
276struct lpfc_idiag {
277 uint32_t active;
278 struct lpfc_idiag_cmd cmd;
279 struct lpfc_idiag_offset offset;
James Smart86a80842011-04-16 11:03:04 -0400280 void *ptr_private;
James Smart2a622bf2011-02-16 12:40:06 -0500281};
Arnd Bergmann223b78e2017-03-23 15:53:45 +0100282
283#else
284
285#define lpfc_nvmeio_data(phba, fmt, arg...) \
286 no_printk(fmt, ##arg)
287
James Smart858c9f62007-06-17 19:56:39 -0500288#endif
289
James Smartc4908502019-01-28 11:14:28 -0800290/* multixripool output buffer size */
291#define LPFC_DUMP_MULTIXRIPOOL_SIZE 8192
292
Arnd Bergmann223b78e2017-03-23 15:53:45 +0100293enum {
294 DUMP_FCP,
295 DUMP_NVME,
296 DUMP_MBX,
297 DUMP_ELS,
298 DUMP_NVMELS,
299};
300
James Smart858c9f62007-06-17 19:56:39 -0500301/* Mask for discovery_trace */
302#define LPFC_DISC_TRC_ELS_CMD 0x1 /* Trace ELS commands */
303#define LPFC_DISC_TRC_ELS_RSP 0x2 /* Trace ELS response */
304#define LPFC_DISC_TRC_ELS_UNSOL 0x4 /* Trace ELS rcv'ed */
305#define LPFC_DISC_TRC_ELS_ALL 0x7 /* Trace ELS */
306#define LPFC_DISC_TRC_MBOX_VPORT 0x8 /* Trace vport MBOXs */
307#define LPFC_DISC_TRC_MBOX 0x10 /* Trace other MBOXs */
308#define LPFC_DISC_TRC_MBOX_ALL 0x18 /* Trace all MBOXs */
309#define LPFC_DISC_TRC_CT 0x20 /* Trace disc CT requests */
310#define LPFC_DISC_TRC_DSM 0x40 /* Trace DSM events */
311#define LPFC_DISC_TRC_RPORT 0x80 /* Trace rport events */
312#define LPFC_DISC_TRC_NODE 0x100 /* Trace ndlp state changes */
313
314#define LPFC_DISC_TRC_DISCOVERY 0xef /* common mask for general
315 * discovery */
316#endif /* H_LPFC_DEBUG_FS */
James Smart809c7532012-05-09 21:19:25 -0400317
318
319/*
320 * Driver debug utility routines outside of debugfs. The debug utility
321 * routines implemented here is intended to be used in the instrumented
322 * debug driver for debugging host or port issues.
323 */
324
325/**
326 * lpfc_debug_dump_qe - dump an specific entry from a queue
327 * @q: Pointer to the queue descriptor.
328 * @idx: Index to the entry on the queue.
329 *
330 * This function dumps an entry indexed by @idx from a queue specified by the
331 * queue descriptor @q.
332 **/
Arnd Bergmann057959c2019-06-28 14:37:47 +0200333static void
James Smart809c7532012-05-09 21:19:25 -0400334lpfc_debug_dump_qe(struct lpfc_queue *q, uint32_t idx)
335{
336 char line_buf[LPFC_LBUF_SZ];
337 int i, esize, qe_word_cnt, len;
338 uint32_t *pword;
339
340 /* sanity checks */
341 if (!q)
342 return;
343 if (idx >= q->entry_count)
344 return;
345
346 esize = q->entry_size;
347 qe_word_cnt = esize / sizeof(uint32_t);
James Smart9afbee32019-03-12 16:30:28 -0700348 pword = lpfc_sli4_qe(q, idx);
James Smart809c7532012-05-09 21:19:25 -0400349
350 len = 0;
Silvio Cesaree7f7b6f2019-03-21 09:44:32 -0700351 len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
James Smart809c7532012-05-09 21:19:25 -0400352 if (qe_word_cnt > 8)
353 printk(KERN_ERR "%s\n", line_buf);
354
355 for (i = 0; i < qe_word_cnt; i++) {
356 if (!(i % 8)) {
357 if (i != 0)
358 printk(KERN_ERR "%s\n", line_buf);
359 if (qe_word_cnt > 8) {
360 len = 0;
361 memset(line_buf, 0, LPFC_LBUF_SZ);
Silvio Cesaree7f7b6f2019-03-21 09:44:32 -0700362 len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len,
James Smart809c7532012-05-09 21:19:25 -0400363 "%03d: ", i);
364 }
365 }
Silvio Cesaree7f7b6f2019-03-21 09:44:32 -0700366 len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
James Smart809c7532012-05-09 21:19:25 -0400367 ((uint32_t)*pword) & 0xffffffff);
368 pword++;
369 }
370 if (qe_word_cnt <= 8 || (i - 1) % 8)
371 printk(KERN_ERR "%s\n", line_buf);
372}
373
374/**
375 * lpfc_debug_dump_q - dump all entries from an specific queue
376 * @q: Pointer to the queue descriptor.
377 *
378 * This function dumps all entries from a queue specified by the queue
379 * descriptor @q.
380 **/
381static inline void
382lpfc_debug_dump_q(struct lpfc_queue *q)
383{
384 int idx, entry_count;
385
386 /* sanity check */
387 if (!q)
388 return;
389
390 dev_printk(KERN_ERR, &(((q->phba))->pcidev)->dev,
391 "%d: [qid:%d, type:%d, subtype:%d, "
392 "qe_size:%d, qe_count:%d, "
393 "host_index:%d, port_index:%d]\n",
394 (q->phba)->brd_no,
395 q->queue_id, q->type, q->subtype,
396 q->entry_size, q->entry_count,
397 q->host_index, q->hba_index);
398 entry_count = q->entry_count;
399 for (idx = 0; idx < entry_count; idx++)
400 lpfc_debug_dump_qe(q, idx);
401 printk(KERN_ERR "\n");
402}
403
404/**
James Smart895427b2017-02-12 13:52:30 -0800405 * lpfc_debug_dump_wq - dump all entries from the fcp or nvme work queue
James Smart809c7532012-05-09 21:19:25 -0400406 * @phba: Pointer to HBA context object.
James Smart895427b2017-02-12 13:52:30 -0800407 * @wqidx: Index to a FCP or NVME work queue.
James Smart809c7532012-05-09 21:19:25 -0400408 *
James Smart895427b2017-02-12 13:52:30 -0800409 * This function dumps all entries from a FCP or NVME work queue specified
James Smart1d9d5a92017-02-12 13:52:29 -0800410 * by the wqidx.
James Smart809c7532012-05-09 21:19:25 -0400411 **/
412static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800413lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx)
James Smart809c7532012-05-09 21:19:25 -0400414{
James Smart1d9d5a92017-02-12 13:52:29 -0800415 struct lpfc_queue *wq;
416 char *qtypestr;
417
418 if (qtype == DUMP_FCP) {
James Smartcdb42be2019-01-28 11:14:21 -0800419 wq = phba->sli4_hba.hdwq[wqidx].fcp_wq;
James Smart1d9d5a92017-02-12 13:52:29 -0800420 qtypestr = "FCP";
James Smart895427b2017-02-12 13:52:30 -0800421 } else if (qtype == DUMP_NVME) {
James Smartcdb42be2019-01-28 11:14:21 -0800422 wq = phba->sli4_hba.hdwq[wqidx].nvme_wq;
James Smart895427b2017-02-12 13:52:30 -0800423 qtypestr = "NVME";
James Smart1d9d5a92017-02-12 13:52:29 -0800424 } else if (qtype == DUMP_MBX) {
425 wq = phba->sli4_hba.mbx_wq;
426 qtypestr = "MBX";
427 } else if (qtype == DUMP_ELS) {
428 wq = phba->sli4_hba.els_wq;
429 qtypestr = "ELS";
James Smart895427b2017-02-12 13:52:30 -0800430 } else if (qtype == DUMP_NVMELS) {
431 wq = phba->sli4_hba.nvmels_wq;
432 qtypestr = "NVMELS";
James Smart1d9d5a92017-02-12 13:52:29 -0800433 } else
James Smart809c7532012-05-09 21:19:25 -0400434 return;
435
James Smart895427b2017-02-12 13:52:30 -0800436 if (qtype == DUMP_FCP || qtype == DUMP_NVME)
James Smart1d9d5a92017-02-12 13:52:29 -0800437 pr_err("%s WQ: WQ[Idx:%d|Qid:%d]\n",
438 qtypestr, wqidx, wq->queue_id);
439 else
440 pr_err("%s WQ: WQ[Qid:%d]\n",
441 qtypestr, wq->queue_id);
442
443 lpfc_debug_dump_q(wq);
James Smart809c7532012-05-09 21:19:25 -0400444}
445
446/**
James Smart895427b2017-02-12 13:52:30 -0800447 * lpfc_debug_dump_cq - dump all entries from a fcp or nvme work queue's
James Smart1d9d5a92017-02-12 13:52:29 -0800448 * cmpl queue
James Smart809c7532012-05-09 21:19:25 -0400449 * @phba: Pointer to HBA context object.
James Smart1d9d5a92017-02-12 13:52:29 -0800450 * @wqidx: Index to a FCP work queue.
James Smart809c7532012-05-09 21:19:25 -0400451 *
James Smart895427b2017-02-12 13:52:30 -0800452 * This function dumps all entries from a FCP or NVME completion queue
James Smart1d9d5a92017-02-12 13:52:29 -0800453 * which is associated to the work queue specified by the @wqidx.
James Smart809c7532012-05-09 21:19:25 -0400454 **/
455static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800456lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
James Smart809c7532012-05-09 21:19:25 -0400457{
James Smart1d9d5a92017-02-12 13:52:29 -0800458 struct lpfc_queue *wq, *cq, *eq;
459 char *qtypestr;
460 int eqidx;
James Smart809c7532012-05-09 21:19:25 -0400461
James Smart895427b2017-02-12 13:52:30 -0800462 /* fcp/nvme wq and cq are 1:1, thus same indexes */
James Smartcdb42be2019-01-28 11:14:21 -0800463 eq = NULL;
James Smart1d9d5a92017-02-12 13:52:29 -0800464
465 if (qtype == DUMP_FCP) {
James Smartcdb42be2019-01-28 11:14:21 -0800466 wq = phba->sli4_hba.hdwq[wqidx].fcp_wq;
467 cq = phba->sli4_hba.hdwq[wqidx].fcp_cq;
James Smart1d9d5a92017-02-12 13:52:29 -0800468 qtypestr = "FCP";
James Smart895427b2017-02-12 13:52:30 -0800469 } else if (qtype == DUMP_NVME) {
James Smartcdb42be2019-01-28 11:14:21 -0800470 wq = phba->sli4_hba.hdwq[wqidx].nvme_wq;
471 cq = phba->sli4_hba.hdwq[wqidx].nvme_cq;
James Smart895427b2017-02-12 13:52:30 -0800472 qtypestr = "NVME";
James Smart1d9d5a92017-02-12 13:52:29 -0800473 } else if (qtype == DUMP_MBX) {
474 wq = phba->sli4_hba.mbx_wq;
475 cq = phba->sli4_hba.mbx_cq;
476 qtypestr = "MBX";
477 } else if (qtype == DUMP_ELS) {
478 wq = phba->sli4_hba.els_wq;
479 cq = phba->sli4_hba.els_cq;
480 qtypestr = "ELS";
James Smart895427b2017-02-12 13:52:30 -0800481 } else if (qtype == DUMP_NVMELS) {
482 wq = phba->sli4_hba.nvmels_wq;
483 cq = phba->sli4_hba.nvmels_cq;
484 qtypestr = "NVMELS";
James Smart1d9d5a92017-02-12 13:52:29 -0800485 } else
James Smart809c7532012-05-09 21:19:25 -0400486 return;
487
James Smartcdb42be2019-01-28 11:14:21 -0800488 for (eqidx = 0; eqidx < phba->cfg_hdw_queue; eqidx++) {
489 eq = phba->sli4_hba.hdwq[eqidx].hba_eq;
490 if (cq->assoc_qid == eq->queue_id)
James Smart809c7532012-05-09 21:19:25 -0400491 break;
James Smart1d9d5a92017-02-12 13:52:29 -0800492 }
James Smartcdb42be2019-01-28 11:14:21 -0800493 if (eqidx == phba->cfg_hdw_queue) {
James Smart1d9d5a92017-02-12 13:52:29 -0800494 pr_err("Couldn't find EQ for CQ. Using EQ[0]\n");
495 eqidx = 0;
James Smartcdb42be2019-01-28 11:14:21 -0800496 eq = phba->sli4_hba.hdwq[0].hba_eq;
James Smart3b3da6a2012-06-12 13:54:20 -0400497 }
James Smart809c7532012-05-09 21:19:25 -0400498
James Smart895427b2017-02-12 13:52:30 -0800499 if (qtype == DUMP_FCP || qtype == DUMP_NVME)
James Smart1d9d5a92017-02-12 13:52:29 -0800500 pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
501 "->EQ[Idx:%d|Qid:%d]:\n",
502 qtypestr, wqidx, wq->queue_id, wqidx, cq->queue_id,
503 eqidx, eq->queue_id);
504 else
505 pr_err("%s CQ: WQ[Qid:%d]->CQ[Qid:%d]"
506 "->EQ[Idx:%d|Qid:%d]:\n",
507 qtypestr, wq->queue_id, cq->queue_id,
508 eqidx, eq->queue_id);
509
510 lpfc_debug_dump_q(cq);
James Smart809c7532012-05-09 21:19:25 -0400511}
512
513/**
James Smart67d12732012-08-03 12:36:13 -0400514 * lpfc_debug_dump_hba_eq - dump all entries from a fcp work queue's evt queue
James Smart809c7532012-05-09 21:19:25 -0400515 * @phba: Pointer to HBA context object.
516 * @fcp_wqidx: Index to a FCP work queue.
517 *
518 * This function dumps all entries from a FCP event queue which is
519 * associated to the FCP work queue specified by the @fcp_wqidx.
520 **/
521static inline void
James Smart1d9d5a92017-02-12 13:52:29 -0800522lpfc_debug_dump_hba_eq(struct lpfc_hba *phba, int qidx)
James Smart809c7532012-05-09 21:19:25 -0400523{
James Smart1d9d5a92017-02-12 13:52:29 -0800524 struct lpfc_queue *qp;
James Smart809c7532012-05-09 21:19:25 -0400525
James Smartcdb42be2019-01-28 11:14:21 -0800526 qp = phba->sli4_hba.hdwq[qidx].hba_eq;
James Smart809c7532012-05-09 21:19:25 -0400527
James Smart1d9d5a92017-02-12 13:52:29 -0800528 pr_err("EQ[Idx:%d|Qid:%d]\n", qidx, qp->queue_id);
James Smart809c7532012-05-09 21:19:25 -0400529
James Smart1d9d5a92017-02-12 13:52:29 -0800530 lpfc_debug_dump_q(qp);
James Smart809c7532012-05-09 21:19:25 -0400531}
532
533/**
534 * lpfc_debug_dump_dat_rq - dump all entries from the receive data queue
535 * @phba: Pointer to HBA context object.
536 *
537 * This function dumps all entries from the receive data queue.
538 **/
539static inline void
540lpfc_debug_dump_dat_rq(struct lpfc_hba *phba)
541{
542 printk(KERN_ERR "DAT RQ: RQ[Qid:%d]\n",
543 phba->sli4_hba.dat_rq->queue_id);
544 lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
545}
546
547/**
548 * lpfc_debug_dump_hdr_rq - dump all entries from the receive header queue
549 * @phba: Pointer to HBA context object.
550 *
551 * This function dumps all entries from the receive header queue.
552 **/
553static inline void
554lpfc_debug_dump_hdr_rq(struct lpfc_hba *phba)
555{
556 printk(KERN_ERR "HDR RQ: RQ[Qid:%d]\n",
557 phba->sli4_hba.hdr_rq->queue_id);
558 lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
559}
560
561/**
James Smart809c7532012-05-09 21:19:25 -0400562 * lpfc_debug_dump_wq_by_id - dump all entries from a work queue by queue id
563 * @phba: Pointer to HBA context object.
564 * @qid: Work queue identifier.
565 *
566 * This function dumps all entries from a work queue identified by the queue
567 * identifier.
568 **/
569static inline void
570lpfc_debug_dump_wq_by_id(struct lpfc_hba *phba, int qid)
571{
572 int wq_idx;
573
James Smartcdb42be2019-01-28 11:14:21 -0800574 for (wq_idx = 0; wq_idx < phba->cfg_hdw_queue; wq_idx++)
575 if (phba->sli4_hba.hdwq[wq_idx].fcp_wq->queue_id == qid)
James Smart809c7532012-05-09 21:19:25 -0400576 break;
James Smartcdb42be2019-01-28 11:14:21 -0800577 if (wq_idx < phba->cfg_hdw_queue) {
James Smart1d9d5a92017-02-12 13:52:29 -0800578 pr_err("FCP WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
James Smartcdb42be2019-01-28 11:14:21 -0800579 lpfc_debug_dump_q(phba->sli4_hba.hdwq[wq_idx].fcp_wq);
James Smart809c7532012-05-09 21:19:25 -0400580 return;
581 }
582
James Smartcdb42be2019-01-28 11:14:21 -0800583 for (wq_idx = 0; wq_idx < phba->cfg_hdw_queue; wq_idx++)
584 if (phba->sli4_hba.hdwq[wq_idx].nvme_wq->queue_id == qid)
James Smart895427b2017-02-12 13:52:30 -0800585 break;
James Smartcdb42be2019-01-28 11:14:21 -0800586 if (wq_idx < phba->cfg_hdw_queue) {
James Smart895427b2017-02-12 13:52:30 -0800587 pr_err("NVME WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
James Smartcdb42be2019-01-28 11:14:21 -0800588 lpfc_debug_dump_q(phba->sli4_hba.hdwq[wq_idx].nvme_wq);
James Smart895427b2017-02-12 13:52:30 -0800589 return;
590 }
591
James Smart809c7532012-05-09 21:19:25 -0400592 if (phba->sli4_hba.els_wq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800593 pr_err("ELS WQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400594 lpfc_debug_dump_q(phba->sli4_hba.els_wq);
James Smart1d9d5a92017-02-12 13:52:29 -0800595 return;
James Smart809c7532012-05-09 21:19:25 -0400596 }
James Smart895427b2017-02-12 13:52:30 -0800597
598 if (phba->sli4_hba.nvmels_wq->queue_id == qid) {
599 pr_err("NVME LS WQ[Qid:%d]\n", qid);
600 lpfc_debug_dump_q(phba->sli4_hba.nvmels_wq);
601 }
James Smart809c7532012-05-09 21:19:25 -0400602}
603
604/**
605 * lpfc_debug_dump_mq_by_id - dump all entries from a mbox queue by queue id
606 * @phba: Pointer to HBA context object.
607 * @qid: Mbox work queue identifier.
608 *
609 * This function dumps all entries from a mbox work queue identified by the
610 * queue identifier.
611 **/
612static inline void
613lpfc_debug_dump_mq_by_id(struct lpfc_hba *phba, int qid)
614{
615 if (phba->sli4_hba.mbx_wq->queue_id == qid) {
616 printk(KERN_ERR "MBX WQ[Qid:%d]\n", qid);
617 lpfc_debug_dump_q(phba->sli4_hba.mbx_wq);
618 }
619}
620
621/**
622 * lpfc_debug_dump_rq_by_id - dump all entries from a receive queue by queue id
623 * @phba: Pointer to HBA context object.
624 * @qid: Receive queue identifier.
625 *
626 * This function dumps all entries from a receive queue identified by the
627 * queue identifier.
628 **/
629static inline void
630lpfc_debug_dump_rq_by_id(struct lpfc_hba *phba, int qid)
631{
632 if (phba->sli4_hba.hdr_rq->queue_id == qid) {
633 printk(KERN_ERR "HDR RQ[Qid:%d]\n", qid);
634 lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
635 return;
636 }
637 if (phba->sli4_hba.dat_rq->queue_id == qid) {
638 printk(KERN_ERR "DAT RQ[Qid:%d]\n", qid);
639 lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
640 }
641}
642
643/**
644 * lpfc_debug_dump_cq_by_id - dump all entries from a cmpl queue by queue id
645 * @phba: Pointer to HBA context object.
646 * @qid: Complete queue identifier.
647 *
648 * This function dumps all entries from a complete queue identified by the
649 * queue identifier.
650 **/
651static inline void
652lpfc_debug_dump_cq_by_id(struct lpfc_hba *phba, int qid)
653{
James Smart1d9d5a92017-02-12 13:52:29 -0800654 int cq_idx;
James Smart809c7532012-05-09 21:19:25 -0400655
James Smartcdb42be2019-01-28 11:14:21 -0800656 for (cq_idx = 0; cq_idx < phba->cfg_hdw_queue; cq_idx++)
657 if (phba->sli4_hba.hdwq[cq_idx].fcp_cq->queue_id == qid)
James Smart809c7532012-05-09 21:19:25 -0400658 break;
James Smart809c7532012-05-09 21:19:25 -0400659
James Smartcdb42be2019-01-28 11:14:21 -0800660 if (cq_idx < phba->cfg_hdw_queue) {
James Smart1d9d5a92017-02-12 13:52:29 -0800661 pr_err("FCP CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
James Smartcdb42be2019-01-28 11:14:21 -0800662 lpfc_debug_dump_q(phba->sli4_hba.hdwq[cq_idx].fcp_cq);
James Smart809c7532012-05-09 21:19:25 -0400663 return;
664 }
665
James Smartcdb42be2019-01-28 11:14:21 -0800666 for (cq_idx = 0; cq_idx < phba->cfg_hdw_queue; cq_idx++)
667 if (phba->sli4_hba.hdwq[cq_idx].nvme_cq->queue_id == qid)
James Smart895427b2017-02-12 13:52:30 -0800668 break;
669
James Smartcdb42be2019-01-28 11:14:21 -0800670 if (cq_idx < phba->cfg_hdw_queue) {
James Smart895427b2017-02-12 13:52:30 -0800671 pr_err("NVME CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
James Smartcdb42be2019-01-28 11:14:21 -0800672 lpfc_debug_dump_q(phba->sli4_hba.hdwq[cq_idx].nvme_cq);
James Smart895427b2017-02-12 13:52:30 -0800673 return;
674 }
675
James Smart809c7532012-05-09 21:19:25 -0400676 if (phba->sli4_hba.els_cq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800677 pr_err("ELS CQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400678 lpfc_debug_dump_q(phba->sli4_hba.els_cq);
679 return;
680 }
681
James Smart895427b2017-02-12 13:52:30 -0800682 if (phba->sli4_hba.nvmels_cq->queue_id == qid) {
683 pr_err("NVME LS CQ[Qid:%d]\n", qid);
684 lpfc_debug_dump_q(phba->sli4_hba.nvmels_cq);
685 return;
686 }
687
James Smart809c7532012-05-09 21:19:25 -0400688 if (phba->sli4_hba.mbx_cq->queue_id == qid) {
James Smart1d9d5a92017-02-12 13:52:29 -0800689 pr_err("MBX CQ[Qid:%d]\n", qid);
James Smart809c7532012-05-09 21:19:25 -0400690 lpfc_debug_dump_q(phba->sli4_hba.mbx_cq);
691 }
692}
693
694/**
695 * lpfc_debug_dump_eq_by_id - dump all entries from an event queue by queue id
696 * @phba: Pointer to HBA context object.
697 * @qid: Complete queue identifier.
698 *
699 * This function dumps all entries from an event queue identified by the
700 * queue identifier.
701 **/
702static inline void
703lpfc_debug_dump_eq_by_id(struct lpfc_hba *phba, int qid)
704{
705 int eq_idx;
706
James Smartcdb42be2019-01-28 11:14:21 -0800707 for (eq_idx = 0; eq_idx < phba->cfg_hdw_queue; eq_idx++)
708 if (phba->sli4_hba.hdwq[eq_idx].hba_eq->queue_id == qid)
James Smart809c7532012-05-09 21:19:25 -0400709 break;
James Smart809c7532012-05-09 21:19:25 -0400710
James Smartcdb42be2019-01-28 11:14:21 -0800711 if (eq_idx < phba->cfg_hdw_queue) {
James Smart809c7532012-05-09 21:19:25 -0400712 printk(KERN_ERR "FCP EQ[Idx:%d|Qid:%d]\n", eq_idx, qid);
James Smartcdb42be2019-01-28 11:14:21 -0800713 lpfc_debug_dump_q(phba->sli4_hba.hdwq[eq_idx].hba_eq);
James Smart809c7532012-05-09 21:19:25 -0400714 return;
715 }
James Smart809c7532012-05-09 21:19:25 -0400716}
717
718void lpfc_debug_dump_all_queues(struct lpfc_hba *);