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