Merge tag 'net-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-block.git] / drivers / scsi / qedi / qedi_dbg.h
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 struct Scsi_Host;
91
92 struct sysfs_bin_attrs {
93         char *name;
94         struct bin_attribute *attr;
95 };
96
97 int qedi_create_sysfs_attr(struct Scsi_Host *shost,
98                            struct sysfs_bin_attrs *iter);
99 void qedi_remove_sysfs_attr(struct Scsi_Host *shost,
100                             struct sysfs_bin_attrs *iter);
101
102 /* DebugFS related code */
103 struct qedi_list_of_funcs {
104         char *oper_str;
105         ssize_t (*oper_func)(struct qedi_dbg_ctx *qedi);
106 };
107
108 struct qedi_debugfs_ops {
109         char *name;
110         struct qedi_list_of_funcs *qedi_funcs;
111 };
112
113 #define qedi_dbg_fileops(drv, ops) \
114 { \
115         .owner  = THIS_MODULE, \
116         .open   = simple_open, \
117         .read   = drv##_dbg_##ops##_cmd_read, \
118         .write  = drv##_dbg_##ops##_cmd_write \
119 }
120
121 /* Used for debugfs sequential files */
122 #define qedi_dbg_fileops_seq(drv, ops) \
123 { \
124         .owner = THIS_MODULE, \
125         .open = drv##_dbg_##ops##_open, \
126         .read = seq_read, \
127         .llseek = seq_lseek, \
128         .release = single_release, \
129 }
130
131 void qedi_dbg_host_init(struct qedi_dbg_ctx *qedi,
132                         const struct qedi_debugfs_ops *dops,
133                         const struct file_operations *fops);
134 void qedi_dbg_host_exit(struct qedi_dbg_ctx *qedi);
135 void qedi_dbg_init(char *drv_name);
136 void qedi_dbg_exit(void);
137
138 #endif /* _QEDI_DBG_H_ */