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