Manish Rangankar | ace7f46 | 2016-12-01 00:21:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * QLogic iSCSI Offload Driver |
| 3 | * Copyright (c) 2016 Cavium Inc. |
| 4 | * |
| 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 | */ |
| 9 | |
| 10 | #ifndef _QEDI_DBG_H_ |
| 11 | #define _QEDI_DBG_H_ |
| 12 | |
| 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> |
| 23 | |
| 24 | #define __PREVENT_QED_HSI__ |
| 25 | #include <linux/qed/common_hsi.h> |
| 26 | #include <linux/qed/qed_if.h> |
| 27 | |
| 28 | extern uint qedi_dbg_log; |
| 29 | |
| 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 |
| 34 | */ |
| 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 |
| 54 | */ |
| 55 | #define QEDI_TRACK_TID 0x100000 /* Track TID state. To be |
| 56 | * enabled only at module load |
| 57 | * and not run-time. |
| 58 | */ |
| 59 | #define QEDI_TRACK_CMD_LIST 0x300000 /* Track active cmd list nodes, |
| 60 | * done with reference to TID, |
| 61 | * hence TRACK_TID also enabled. |
| 62 | */ |
| 63 | #define QEDI_LOG_NOTICE 0x40000000 /* Notice logs */ |
| 64 | #define QEDI_LOG_WARN 0x80000000 /* Warning logs */ |
| 65 | |
| 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 |
| 73 | }; |
| 74 | |
| 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__) |
| 84 | |
| 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, ...); |
| 93 | |
| 94 | struct Scsi_Host; |
| 95 | |
| 96 | struct sysfs_bin_attrs { |
| 97 | char *name; |
| 98 | struct bin_attribute *attr; |
| 99 | }; |
| 100 | |
| 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); |
| 105 | |
Manish Rangankar | ace7f46 | 2016-12-01 00:21:08 -0800 | [diff] [blame] | 106 | /* DebugFS related code */ |
| 107 | struct qedi_list_of_funcs { |
| 108 | char *oper_str; |
| 109 | ssize_t (*oper_func)(struct qedi_dbg_ctx *qedi); |
| 110 | }; |
| 111 | |
| 112 | struct qedi_debugfs_ops { |
| 113 | char *name; |
| 114 | struct qedi_list_of_funcs *qedi_funcs; |
| 115 | }; |
| 116 | |
| 117 | #define qedi_dbg_fileops(drv, ops) \ |
| 118 | { \ |
| 119 | .owner = THIS_MODULE, \ |
| 120 | .open = simple_open, \ |
| 121 | .read = drv##_dbg_##ops##_cmd_read, \ |
| 122 | .write = drv##_dbg_##ops##_cmd_write \ |
| 123 | } |
| 124 | |
| 125 | /* Used for debugfs sequential files */ |
| 126 | #define qedi_dbg_fileops_seq(drv, ops) \ |
| 127 | { \ |
| 128 | .owner = THIS_MODULE, \ |
| 129 | .open = drv##_dbg_##ops##_open, \ |
| 130 | .read = seq_read, \ |
| 131 | .llseek = seq_lseek, \ |
| 132 | .release = single_release, \ |
| 133 | } |
| 134 | |
| 135 | void qedi_dbg_host_init(struct qedi_dbg_ctx *qedi, |
Arnd Bergmann | 779936f | 2018-02-02 14:12:19 +0100 | [diff] [blame] | 136 | const struct qedi_debugfs_ops *dops, |
Manish Rangankar | ace7f46 | 2016-12-01 00:21:08 -0800 | [diff] [blame] | 137 | const struct file_operations *fops); |
| 138 | void qedi_dbg_host_exit(struct qedi_dbg_ctx *qedi); |
| 139 | void qedi_dbg_init(char *drv_name); |
| 140 | void qedi_dbg_exit(void); |
Manish Rangankar | ace7f46 | 2016-12-01 00:21:08 -0800 | [diff] [blame] | 141 | |
| 142 | #endif /* _QEDI_DBG_H_ */ |