xref: /linux/drivers/scsi/lpfc/lpfc_debugfs.h (revision 22c5696e3fe029f4fc2decbe7cc6663b5d281223)
1 /*******************************************************************
2  * This file is part of the Emulex Linux Device Driver for         *
3  * Fibre Channel Host Bus Adapters.                                *
4  * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
5  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
6  * Copyright (C) 2007-2011 Emulex.  All rights reserved.           *
7  * EMULEX and SLI are trademarks of Emulex.                        *
8  * www.broadcom.com                                                *
9  *                                                                 *
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 
26 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
27 
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 
41 /* dumpSLIqinfo output buffer size */
42 #define	LPFC_DUMPSLIQINFO_SIZE 4096
43 
44 /* hbqinfo output buffer size */
45 #define LPFC_HBQINFO_SIZE 8192
46 
47 /* nvmestat output buffer size */
48 #define LPFC_NVMESTAT_SIZE 8192
49 #define LPFC_IOKTIME_SIZE 8192
50 #define LPFC_NVMEIO_TRC_SIZE 8192
51 
52 /* scsistat output buffer size */
53 #define LPFC_SCSISTAT_SIZE 8192
54 
55 /* Congestion Info Buffer size */
56 #define LPFC_CGN_BUF_SIZE 8192
57 
58 #define LPFC_DEBUG_OUT_LINE_SZ	80
59 
60 /*
61  * For SLI4 iDiag debugfs diagnostics tool
62  */
63 
64 /* pciConf */
65 #define LPFC_PCI_CFG_BROWSE 0xffff
66 #define LPFC_PCI_CFG_RD_CMD_ARG 2
67 #define LPFC_PCI_CFG_WR_CMD_ARG 3
68 #define LPFC_PCI_CFG_SIZE 4096
69 #define LPFC_PCI_CFG_RD_SIZE (LPFC_PCI_CFG_SIZE/4)
70 
71 #define IDIAG_PCICFG_WHERE_INDX 0
72 #define IDIAG_PCICFG_COUNT_INDX 1
73 #define IDIAG_PCICFG_VALUE_INDX 2
74 
75 /* barAcc */
76 #define LPFC_PCI_BAR_BROWSE 0xffff
77 #define LPFC_PCI_BAR_RD_CMD_ARG 3
78 #define LPFC_PCI_BAR_WR_CMD_ARG 3
79 
80 #define LPFC_PCI_IF0_BAR0_SIZE (1024 *  16)
81 #define LPFC_PCI_IF0_BAR1_SIZE (1024 * 128)
82 #define LPFC_PCI_IF0_BAR2_SIZE (1024 * 128)
83 #define LPFC_PCI_IF2_BAR0_SIZE (1024 *  32)
84 
85 #define LPFC_PCI_BAR_RD_BUF_SIZE 4096
86 #define LPFC_PCI_BAR_RD_SIZE (LPFC_PCI_BAR_RD_BUF_SIZE/4)
87 
88 #define LPFC_PCI_IF0_BAR0_RD_SIZE (LPFC_PCI_IF0_BAR0_SIZE/4)
89 #define LPFC_PCI_IF0_BAR1_RD_SIZE (LPFC_PCI_IF0_BAR1_SIZE/4)
90 #define LPFC_PCI_IF0_BAR2_RD_SIZE (LPFC_PCI_IF0_BAR2_SIZE/4)
91 #define LPFC_PCI_IF2_BAR0_RD_SIZE (LPFC_PCI_IF2_BAR0_SIZE/4)
92 
93 #define IDIAG_BARACC_BAR_NUM_INDX 0
94 #define IDIAG_BARACC_OFF_SET_INDX 1
95 #define IDIAG_BARACC_ACC_MOD_INDX 2
96 #define IDIAG_BARACC_REG_VAL_INDX 2
97 #define IDIAG_BARACC_BAR_SZE_INDX 3
98 
99 #define IDIAG_BARACC_BAR_0 0
100 #define IDIAG_BARACC_BAR_1 1
101 #define IDIAG_BARACC_BAR_2 2
102 
103 #define SINGLE_WORD 1
104 
105 /* queue info */
106 #define LPFC_QUE_INFO_GET_BUF_SIZE 4096
107 
108 /* queue acc */
109 #define LPFC_QUE_ACC_BROWSE 0xffff
110 #define LPFC_QUE_ACC_RD_CMD_ARG 4
111 #define LPFC_QUE_ACC_WR_CMD_ARG 6
112 #define LPFC_QUE_ACC_BUF_SIZE 4096
113 #define LPFC_QUE_ACC_SIZE (LPFC_QUE_ACC_BUF_SIZE/2)
114 
115 #define LPFC_IDIAG_EQ 1
116 #define LPFC_IDIAG_CQ 2
117 #define LPFC_IDIAG_MQ 3
118 #define LPFC_IDIAG_WQ 4
119 #define LPFC_IDIAG_RQ 5
120 
121 #define IDIAG_QUEACC_QUETP_INDX 0
122 #define IDIAG_QUEACC_QUEID_INDX 1
123 #define IDIAG_QUEACC_INDEX_INDX 2
124 #define IDIAG_QUEACC_COUNT_INDX 3
125 #define IDIAG_QUEACC_OFFST_INDX 4
126 #define IDIAG_QUEACC_VALUE_INDX 5
127 
128 /* doorbell register acc */
129 #define LPFC_DRB_ACC_ALL 0xffff
130 #define LPFC_DRB_ACC_RD_CMD_ARG 1
131 #define LPFC_DRB_ACC_WR_CMD_ARG 2
132 #define LPFC_DRB_ACC_BUF_SIZE 256
133 
134 #define LPFC_DRB_EQ   1
135 #define LPFC_DRB_CQ   2
136 #define LPFC_DRB_MQ   3
137 #define LPFC_DRB_WQ   4
138 #define LPFC_DRB_RQ   5
139 
140 #define LPFC_DRB_MAX  5
141 
142 #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 
203 #define SIZE_U8  sizeof(uint8_t)
204 #define SIZE_U16 sizeof(uint16_t)
205 #define SIZE_U32 sizeof(uint32_t)
206 
207 #define lpfc_nvmeio_data(phba, fmt, arg...) \
208 	{ \
209 	if (phba->nvmeio_trc_on) \
210 		lpfc_debugfs_nvme_trc(phba, fmt, ##arg); \
211 	}
212 
213 struct 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 
222 struct lpfc_debugfs_trc {
223 	char *fmt;
224 	uint32_t data1;
225 	uint32_t data2;
226 	uint32_t data3;
227 	uint32_t seq_cnt;
228 	unsigned long jif;
229 };
230 
231 struct lpfc_debugfs_nvmeio_trc {
232 	char *fmt;
233 	uint16_t data1;
234 	uint16_t data2;
235 	uint32_t data3;
236 };
237 
238 struct lpfc_idiag_offset {
239 	uint32_t last_rd;
240 };
241 
242 #define LPFC_IDIAG_CMD_DATA_SIZE 8
243 struct 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
249 
250 #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 
255 #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
264 
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 
275 	uint32_t data[LPFC_IDIAG_CMD_DATA_SIZE];
276 };
277 
278 struct lpfc_idiag {
279 	uint32_t active;
280 	struct lpfc_idiag_cmd cmd;
281 	struct lpfc_idiag_offset offset;
282 	void *ptr_private;
283 };
284 
285 #define MAX_DEBUGFS_RX_INFO_SIZE	(128 * LPFC_MAX_RXMONITOR_ENTRY)
286 struct lpfc_rx_monitor_debug {
287 	char *i_private;
288 	char *buffer;
289 };
290 
291 #else
292 
293 #define lpfc_nvmeio_data(phba, fmt, arg...) \
294 	no_printk(fmt, ##arg)
295 
296 #endif
297 
298 /* multixripool output buffer size */
299 #define LPFC_DUMP_MULTIXRIPOOL_SIZE 8192
300 
301 enum {
302 	DUMP_IO,
303 	DUMP_MBX,
304 	DUMP_ELS,
305 	DUMP_NVMELS,
306 };
307 
308 /* Mask for discovery_trace */
309 #define LPFC_DISC_TRC_ELS_CMD		0x1	/* Trace ELS commands */
310 #define LPFC_DISC_TRC_ELS_RSP		0x2	/* Trace ELS response */
311 #define LPFC_DISC_TRC_ELS_UNSOL		0x4	/* Trace ELS rcv'ed   */
312 #define LPFC_DISC_TRC_ELS_ALL		0x7	/* Trace ELS */
313 #define LPFC_DISC_TRC_MBOX_VPORT	0x8	/* Trace vport MBOXs */
314 #define LPFC_DISC_TRC_MBOX		0x10	/* Trace other MBOXs */
315 #define LPFC_DISC_TRC_MBOX_ALL		0x18	/* Trace all MBOXs */
316 #define LPFC_DISC_TRC_CT		0x20	/* Trace disc CT requests */
317 #define LPFC_DISC_TRC_DSM		0x40    /* Trace DSM events */
318 #define LPFC_DISC_TRC_RPORT		0x80    /* Trace rport events */
319 #define LPFC_DISC_TRC_NODE		0x100   /* Trace ndlp state changes */
320 
321 #define LPFC_DISC_TRC_DISCOVERY		0xef    /* common mask for general
322 						 * discovery */
323 #endif /* H_LPFC_DEBUG_FS */
324 
325 enum {
326 	writeGuard = 1,
327 	writeApp,
328 	writeRef,
329 	readGuard,
330 	readApp,
331 	readRef,
332 	InjErrLBA,
333 	InjErrNPortID,
334 	InjErrWWPN,
335 };
336 
337 /*
338  * Driver debug utility routines outside of debugfs. The debug utility
339  * routines implemented here is intended to be used in the instrumented
340  * debug driver for debugging host or port issues.
341  */
342 
343 /**
344  * lpfc_debug_dump_qe - dump an specific entry from a queue
345  * @q: Pointer to the queue descriptor.
346  * @idx: Index to the entry on the queue.
347  *
348  * This function dumps an entry indexed by @idx from a queue specified by the
349  * queue descriptor @q.
350  **/
351 static void
lpfc_debug_dump_qe(struct lpfc_queue * q,uint32_t idx)352 lpfc_debug_dump_qe(struct lpfc_queue *q, uint32_t idx)
353 {
354 	char line_buf[LPFC_LBUF_SZ];
355 	int i, esize, qe_word_cnt, len;
356 	uint32_t *pword;
357 
358 	/* sanity checks */
359 	if (!q)
360 		return;
361 	if (idx >= q->entry_count)
362 		return;
363 
364 	esize = q->entry_size;
365 	qe_word_cnt = esize / sizeof(uint32_t);
366 	pword = lpfc_sli4_qe(q, idx);
367 
368 	len = 0;
369 	len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "QE[%04d]: ", idx);
370 	if (qe_word_cnt > 8)
371 		printk(KERN_ERR "%s\n", line_buf);
372 
373 	for (i = 0; i < qe_word_cnt; i++) {
374 		if (!(i % 8)) {
375 			if (i != 0)
376 				printk(KERN_ERR "%s\n", line_buf);
377 			if (qe_word_cnt > 8) {
378 				len = 0;
379 				memset(line_buf, 0, LPFC_LBUF_SZ);
380 				len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len,
381 						"%03d: ", i);
382 			}
383 		}
384 		len += scnprintf(line_buf+len, LPFC_LBUF_SZ-len, "%08x ",
385 				((uint32_t)*pword) & 0xffffffff);
386 		pword++;
387 	}
388 	if (qe_word_cnt <= 8 || (i - 1) % 8)
389 		printk(KERN_ERR "%s\n", line_buf);
390 }
391 
392 /**
393  * lpfc_debug_dump_q - dump all entries from an specific queue
394  * @q: Pointer to the queue descriptor.
395  *
396  * This function dumps all entries from a queue specified by the queue
397  * descriptor @q.
398  **/
399 static inline void
lpfc_debug_dump_q(struct lpfc_queue * q)400 lpfc_debug_dump_q(struct lpfc_queue *q)
401 {
402 	int idx, entry_count;
403 
404 	/* sanity check */
405 	if (!q)
406 		return;
407 
408 	dev_printk(KERN_ERR, &(((q->phba))->pcidev)->dev,
409 		"%d: [qid:%d, type:%d, subtype:%d, "
410 		"qe_size:%d, qe_count:%d, "
411 		"host_index:%d, port_index:%d]\n",
412 		(q->phba)->brd_no,
413 		q->queue_id, q->type, q->subtype,
414 		q->entry_size, q->entry_count,
415 		q->host_index, q->hba_index);
416 	entry_count = q->entry_count;
417 	for (idx = 0; idx < entry_count; idx++)
418 		lpfc_debug_dump_qe(q, idx);
419 	printk(KERN_ERR "\n");
420 }
421 
422 /**
423  * lpfc_debug_dump_wq - dump all entries from the fcp or nvme work queue
424  * @phba: Pointer to HBA context object.
425  * @wqidx: Index to a FCP or NVME work queue.
426  *
427  * This function dumps all entries from a FCP or NVME work queue specified
428  * by the wqidx.
429  **/
430 static inline void
lpfc_debug_dump_wq(struct lpfc_hba * phba,int qtype,int wqidx)431 lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx)
432 {
433 	struct lpfc_queue *wq;
434 	char *qtypestr;
435 
436 	if (qtype == DUMP_IO) {
437 		wq = phba->sli4_hba.hdwq[wqidx].io_wq;
438 		qtypestr = "IO";
439 	} else if (qtype == DUMP_MBX) {
440 		wq = phba->sli4_hba.mbx_wq;
441 		qtypestr = "MBX";
442 	} else if (qtype == DUMP_ELS) {
443 		wq = phba->sli4_hba.els_wq;
444 		qtypestr = "ELS";
445 	} else if (qtype == DUMP_NVMELS) {
446 		wq = phba->sli4_hba.nvmels_wq;
447 		qtypestr = "NVMELS";
448 	} else
449 		return;
450 
451 	if (qtype == DUMP_IO)
452 		pr_err("%s WQ: WQ[Idx:%d|Qid:%d]\n",
453 			qtypestr, wqidx, wq->queue_id);
454 	else
455 		pr_err("%s WQ: WQ[Qid:%d]\n",
456 			qtypestr, wq->queue_id);
457 
458 	lpfc_debug_dump_q(wq);
459 }
460 
461 /**
462  * lpfc_debug_dump_cq - dump all entries from a fcp or nvme work queue's
463  * cmpl queue
464  * @phba: Pointer to HBA context object.
465  * @wqidx: Index to a FCP work queue.
466  *
467  * This function dumps all entries from a FCP or NVME completion queue
468  * which is associated to the work queue specified by the @wqidx.
469  **/
470 static inline void
lpfc_debug_dump_cq(struct lpfc_hba * phba,int qtype,int wqidx)471 lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
472 {
473 	struct lpfc_queue *wq, *cq, *eq;
474 	char *qtypestr;
475 	int eqidx;
476 
477 	/* io wq and cq are 1:1, thus same indexes */
478 	eq = NULL;
479 
480 	if (qtype == DUMP_IO) {
481 		wq = phba->sli4_hba.hdwq[wqidx].io_wq;
482 		cq = phba->sli4_hba.hdwq[wqidx].io_cq;
483 		qtypestr = "IO";
484 	} else if (qtype == DUMP_MBX) {
485 		wq = phba->sli4_hba.mbx_wq;
486 		cq = phba->sli4_hba.mbx_cq;
487 		qtypestr = "MBX";
488 	} else if (qtype == DUMP_ELS) {
489 		wq = phba->sli4_hba.els_wq;
490 		cq = phba->sli4_hba.els_cq;
491 		qtypestr = "ELS";
492 	} else if (qtype == DUMP_NVMELS) {
493 		wq = phba->sli4_hba.nvmels_wq;
494 		cq = phba->sli4_hba.nvmels_cq;
495 		qtypestr = "NVMELS";
496 	} else
497 		return;
498 
499 	for (eqidx = 0; eqidx < phba->cfg_hdw_queue; eqidx++) {
500 		eq = phba->sli4_hba.hdwq[eqidx].hba_eq;
501 		if (cq->assoc_qid == eq->queue_id)
502 			break;
503 	}
504 	if (eqidx == phba->cfg_hdw_queue) {
505 		pr_err("Couldn't find EQ for CQ. Using EQ[0]\n");
506 		eqidx = 0;
507 		eq = phba->sli4_hba.hdwq[0].hba_eq;
508 	}
509 
510 	if (qtype == DUMP_IO)
511 		pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
512 			"->EQ[Idx:%d|Qid:%d]:\n",
513 			qtypestr, wqidx, wq->queue_id, wqidx, cq->queue_id,
514 			eqidx, eq->queue_id);
515 	else
516 		pr_err("%s CQ: WQ[Qid:%d]->CQ[Qid:%d]"
517 			"->EQ[Idx:%d|Qid:%d]:\n",
518 			qtypestr, wq->queue_id, cq->queue_id,
519 			eqidx, eq->queue_id);
520 
521 	lpfc_debug_dump_q(cq);
522 }
523 
524 /**
525  * lpfc_debug_dump_hba_eq - dump all entries from a fcp work queue's evt queue
526  * @phba: Pointer to HBA context object.
527  * @fcp_wqidx: Index to a FCP work queue.
528  *
529  * This function dumps all entries from a FCP event queue which is
530  * associated to the FCP work queue specified by the @fcp_wqidx.
531  **/
532 static inline void
lpfc_debug_dump_hba_eq(struct lpfc_hba * phba,int qidx)533 lpfc_debug_dump_hba_eq(struct lpfc_hba *phba, int qidx)
534 {
535 	struct lpfc_queue *qp;
536 
537 	qp = phba->sli4_hba.hdwq[qidx].hba_eq;
538 
539 	pr_err("EQ[Idx:%d|Qid:%d]\n", qidx, qp->queue_id);
540 
541 	lpfc_debug_dump_q(qp);
542 }
543 
544 /**
545  * lpfc_debug_dump_dat_rq - dump all entries from the receive data queue
546  * @phba: Pointer to HBA context object.
547  *
548  * This function dumps all entries from the receive data queue.
549  **/
550 static inline void
lpfc_debug_dump_dat_rq(struct lpfc_hba * phba)551 lpfc_debug_dump_dat_rq(struct lpfc_hba *phba)
552 {
553 	printk(KERN_ERR "DAT RQ: RQ[Qid:%d]\n",
554 		phba->sli4_hba.dat_rq->queue_id);
555 	lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
556 }
557 
558 /**
559  * lpfc_debug_dump_hdr_rq - dump all entries from the receive header queue
560  * @phba: Pointer to HBA context object.
561  *
562  * This function dumps all entries from the receive header queue.
563  **/
564 static inline void
lpfc_debug_dump_hdr_rq(struct lpfc_hba * phba)565 lpfc_debug_dump_hdr_rq(struct lpfc_hba *phba)
566 {
567 	printk(KERN_ERR "HDR RQ: RQ[Qid:%d]\n",
568 		phba->sli4_hba.hdr_rq->queue_id);
569 	lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
570 }
571 
572 /**
573  * lpfc_debug_dump_wq_by_id - dump all entries from a work queue by queue id
574  * @phba: Pointer to HBA context object.
575  * @qid: Work queue identifier.
576  *
577  * This function dumps all entries from a work queue identified by the queue
578  * identifier.
579  **/
580 static inline void
lpfc_debug_dump_wq_by_id(struct lpfc_hba * phba,int qid)581 lpfc_debug_dump_wq_by_id(struct lpfc_hba *phba, int qid)
582 {
583 	int wq_idx;
584 
585 	for (wq_idx = 0; wq_idx < phba->cfg_hdw_queue; wq_idx++)
586 		if (phba->sli4_hba.hdwq[wq_idx].io_wq->queue_id == qid)
587 			break;
588 	if (wq_idx < phba->cfg_hdw_queue) {
589 		pr_err("IO WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
590 		lpfc_debug_dump_q(phba->sli4_hba.hdwq[wq_idx].io_wq);
591 		return;
592 	}
593 
594 	if (phba->sli4_hba.els_wq->queue_id == qid) {
595 		pr_err("ELS WQ[Qid:%d]\n", qid);
596 		lpfc_debug_dump_q(phba->sli4_hba.els_wq);
597 		return;
598 	}
599 
600 	if (phba->sli4_hba.nvmels_wq->queue_id == qid) {
601 		pr_err("NVME LS WQ[Qid:%d]\n", qid);
602 		lpfc_debug_dump_q(phba->sli4_hba.nvmels_wq);
603 	}
604 }
605 
606 /**
607  * lpfc_debug_dump_mq_by_id - dump all entries from a mbox queue by queue id
608  * @phba: Pointer to HBA context object.
609  * @qid: Mbox work queue identifier.
610  *
611  * This function dumps all entries from a mbox work queue identified by the
612  * queue identifier.
613  **/
614 static inline void
lpfc_debug_dump_mq_by_id(struct lpfc_hba * phba,int qid)615 lpfc_debug_dump_mq_by_id(struct lpfc_hba *phba, int qid)
616 {
617 	if (phba->sli4_hba.mbx_wq->queue_id == qid) {
618 		printk(KERN_ERR "MBX WQ[Qid:%d]\n", qid);
619 		lpfc_debug_dump_q(phba->sli4_hba.mbx_wq);
620 	}
621 }
622 
623 /**
624  * lpfc_debug_dump_rq_by_id - dump all entries from a receive queue by queue id
625  * @phba: Pointer to HBA context object.
626  * @qid: Receive queue identifier.
627  *
628  * This function dumps all entries from a receive queue identified by the
629  * queue identifier.
630  **/
631 static inline void
lpfc_debug_dump_rq_by_id(struct lpfc_hba * phba,int qid)632 lpfc_debug_dump_rq_by_id(struct lpfc_hba *phba, int qid)
633 {
634 	if (phba->sli4_hba.hdr_rq->queue_id == qid) {
635 		printk(KERN_ERR "HDR RQ[Qid:%d]\n", qid);
636 		lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
637 		return;
638 	}
639 	if (phba->sli4_hba.dat_rq->queue_id == qid) {
640 		printk(KERN_ERR "DAT RQ[Qid:%d]\n", qid);
641 		lpfc_debug_dump_q(phba->sli4_hba.dat_rq);
642 	}
643 }
644 
645 /**
646  * lpfc_debug_dump_cq_by_id - dump all entries from a cmpl queue by queue id
647  * @phba: Pointer to HBA context object.
648  * @qid: Complete queue identifier.
649  *
650  * This function dumps all entries from a complete queue identified by the
651  * queue identifier.
652  **/
653 static inline void
lpfc_debug_dump_cq_by_id(struct lpfc_hba * phba,int qid)654 lpfc_debug_dump_cq_by_id(struct lpfc_hba *phba, int qid)
655 {
656 	int cq_idx;
657 
658 	for (cq_idx = 0; cq_idx < phba->cfg_hdw_queue; cq_idx++)
659 		if (phba->sli4_hba.hdwq[cq_idx].io_cq->queue_id == qid)
660 			break;
661 
662 	if (cq_idx < phba->cfg_hdw_queue) {
663 		pr_err("IO CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
664 		lpfc_debug_dump_q(phba->sli4_hba.hdwq[cq_idx].io_cq);
665 		return;
666 	}
667 
668 	if (phba->sli4_hba.els_cq->queue_id == qid) {
669 		pr_err("ELS CQ[Qid:%d]\n", qid);
670 		lpfc_debug_dump_q(phba->sli4_hba.els_cq);
671 		return;
672 	}
673 
674 	if (phba->sli4_hba.nvmels_cq->queue_id == qid) {
675 		pr_err("NVME LS CQ[Qid:%d]\n", qid);
676 		lpfc_debug_dump_q(phba->sli4_hba.nvmels_cq);
677 		return;
678 	}
679 
680 	if (phba->sli4_hba.mbx_cq->queue_id == qid) {
681 		pr_err("MBX CQ[Qid:%d]\n", qid);
682 		lpfc_debug_dump_q(phba->sli4_hba.mbx_cq);
683 	}
684 }
685 
686 /**
687  * lpfc_debug_dump_eq_by_id - dump all entries from an event queue by queue id
688  * @phba: Pointer to HBA context object.
689  * @qid: Complete queue identifier.
690  *
691  * This function dumps all entries from an event queue identified by the
692  * queue identifier.
693  **/
694 static inline void
lpfc_debug_dump_eq_by_id(struct lpfc_hba * phba,int qid)695 lpfc_debug_dump_eq_by_id(struct lpfc_hba *phba, int qid)
696 {
697 	int eq_idx;
698 
699 	for (eq_idx = 0; eq_idx < phba->cfg_hdw_queue; eq_idx++)
700 		if (phba->sli4_hba.hdwq[eq_idx].hba_eq->queue_id == qid)
701 			break;
702 
703 	if (eq_idx < phba->cfg_hdw_queue) {
704 		printk(KERN_ERR "FCP EQ[Idx:%d|Qid:%d]\n", eq_idx, qid);
705 		lpfc_debug_dump_q(phba->sli4_hba.hdwq[eq_idx].hba_eq);
706 		return;
707 	}
708 }
709 
710 void lpfc_debug_dump_all_queues(struct lpfc_hba *);
711