xref: /linux/drivers/scsi/qedi/qedi_dbg.h (revision f66bc387efbee59978e076ce9bf123ac353b389c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * QLogic iSCSI Offload Driver
4  * Copyright (c) 2016 Cavium Inc.
5  */
6 
7 #ifndef _QEDI_DBG_H_
8 #define _QEDI_DBG_H_
9 
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/compiler.h>
13 #include <linux/string.h>
14 #include <linux/pci.h>
15 #include <linux/delay.h>
16 #include <scsi/scsi_transport.h>
17 #include <scsi/scsi_transport_iscsi.h>
18 #include <linux/fs.h>
19 
20 #define __PREVENT_QED_HSI__
21 #include <linux/qed/common_hsi.h>
22 #include <linux/qed/qed_if.h>
23 
24 extern uint qedi_dbg_log;
25 
26 /* Debug print level definitions */
27 #define QEDI_LOG_DEFAULT	0x1		/* Set default logging mask */
28 #define QEDI_LOG_INFO		0x2		/* Informational logs,
29 						 * MAC address, WWPN, WWNN
30 						 */
31 #define QEDI_LOG_DISC		0x4		/* Init, discovery, rport */
32 #define QEDI_LOG_LL2		0x8		/* LL2, VLAN logs */
33 #define QEDI_LOG_CONN		0x10		/* Connection setup, cleanup */
34 #define QEDI_LOG_EVT		0x20		/* Events, link, mtu */
35 #define QEDI_LOG_TIMER		0x40		/* Timer events */
36 #define QEDI_LOG_MP_REQ		0x80		/* Middle Path (MP) logs */
37 #define QEDI_LOG_SCSI_TM	0x100		/* SCSI Aborts, Task Mgmt */
38 #define QEDI_LOG_UNSOL		0x200		/* unsolicited event logs */
39 #define QEDI_LOG_IO		0x400		/* scsi cmd, completion */
40 #define QEDI_LOG_MQ		0x800		/* Multi Queue logs */
41 #define QEDI_LOG_BSG		0x1000		/* BSG logs */
42 #define QEDI_LOG_DEBUGFS	0x2000		/* debugFS logs */
43 #define QEDI_LOG_LPORT		0x4000		/* lport logs */
44 #define QEDI_LOG_ELS		0x8000		/* ELS logs */
45 #define QEDI_LOG_NPIV		0x10000		/* NPIV logs */
46 #define QEDI_LOG_SESS		0x20000		/* Connection setup, cleanup */
47 #define QEDI_LOG_UIO		0x40000		/* iSCSI UIO logs */
48 #define QEDI_LOG_TID		0x80000         /* FW TID context acquire,
49 						 * free
50 						 */
51 #define QEDI_TRACK_TID		0x100000        /* Track TID state. To be
52 						 * enabled only at module load
53 						 * and not run-time.
54 						 */
55 #define QEDI_TRACK_CMD_LIST    0x300000        /* Track active cmd list nodes,
56 						* done with reference to TID,
57 						* hence TRACK_TID also enabled.
58 						*/
59 #define QEDI_LOG_NOTICE		0x40000000	/* Notice logs */
60 #define QEDI_LOG_WARN		0x80000000	/* Warning logs */
61 
62 /* Debug context structure */
63 struct qedi_dbg_ctx {
64 	unsigned int host_no;
65 	struct pci_dev *pdev;
66 #ifdef CONFIG_DEBUG_FS
67 	struct dentry *bdf_dentry;
68 #endif
69 };
70 
71 #define QEDI_ERR(pdev, fmt, ...)	\
72 		qedi_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
73 #define QEDI_WARN(pdev, fmt, ...)	\
74 		qedi_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
75 #define QEDI_NOTICE(pdev, fmt, ...)	\
76 		qedi_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
77 #define QEDI_INFO(pdev, level, fmt, ...)	\
78 		qedi_dbg_info(pdev, __func__, __LINE__, level, fmt,	\
79 			      ## __VA_ARGS__)
80 
81 void qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
82 		  const char *fmt, ...);
83 void qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
84 		   const char *fmt, ...);
85 void qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
86 		     const char *fmt, ...);
87 void qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
88 		   u32 info, const char *fmt, ...);
89 
90 /* DebugFS related code */
91 struct qedi_list_of_funcs {
92 	char *oper_str;
93 	ssize_t (*oper_func)(struct qedi_dbg_ctx *qedi);
94 };
95 
96 struct qedi_debugfs_ops {
97 	char *name;
98 	struct qedi_list_of_funcs *qedi_funcs;
99 };
100 
101 #define qedi_dbg_fileops(drv, ops) \
102 { \
103 	.owner  = THIS_MODULE, \
104 	.open   = simple_open, \
105 	.read   = drv##_dbg_##ops##_cmd_read, \
106 	.write  = drv##_dbg_##ops##_cmd_write \
107 }
108 
109 /* Used for debugfs sequential files */
110 #define qedi_dbg_fileops_seq(drv, ops) \
111 { \
112 	.owner = THIS_MODULE, \
113 	.open = drv##_dbg_##ops##_open, \
114 	.read = seq_read, \
115 	.llseek = seq_lseek, \
116 	.release = single_release, \
117 }
118 
119 void qedi_dbg_host_init(struct qedi_dbg_ctx *qedi,
120 			const struct qedi_debugfs_ops *dops,
121 			const struct file_operations *fops);
122 void qedi_dbg_host_exit(struct qedi_dbg_ctx *qedi);
123 void qedi_dbg_init(char *drv_name);
124 void qedi_dbg_exit(void);
125 
126 #endif /* _QEDI_DBG_H_ */
127