1 /* 2 * QLogic FCoE Offload Driver 3 * Copyright (c) 2016-2017 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 #ifndef _QEDF_DBG_H_ 10 #define _QEDF_DBG_H_ 11 12 #include <linux/types.h> 13 #include <linux/kernel.h> 14 #include <linux/compiler.h> 15 #include <linux/string.h> 16 #include <linux/version.h> 17 #include <linux/pci.h> 18 #include <linux/delay.h> 19 #include <scsi/scsi_transport.h> 20 #include <linux/fs.h> 21 22 #include <linux/qed/common_hsi.h> 23 #include <linux/qed/qed_if.h> 24 25 extern uint qedf_debug; 26 27 /* Debug print level definitions */ 28 #define QEDF_LOG_DEFAULT 0x1 /* Set default logging mask */ 29 #define QEDF_LOG_INFO 0x2 /* 30 * Informational logs, 31 * MAC address, WWPN, WWNN 32 */ 33 #define QEDF_LOG_DISC 0x4 /* Init, discovery, rport */ 34 #define QEDF_LOG_LL2 0x8 /* LL2, VLAN logs */ 35 #define QEDF_LOG_CONN 0x10 /* Connection setup, cleanup */ 36 #define QEDF_LOG_EVT 0x20 /* Events, link, mtu */ 37 #define QEDF_LOG_TIMER 0x40 /* Timer events */ 38 #define QEDF_LOG_MP_REQ 0x80 /* Middle Path (MP) logs */ 39 #define QEDF_LOG_SCSI_TM 0x100 /* SCSI Aborts, Task Mgmt */ 40 #define QEDF_LOG_UNSOL 0x200 /* unsolicited event logs */ 41 #define QEDF_LOG_IO 0x400 /* scsi cmd, completion */ 42 #define QEDF_LOG_MQ 0x800 /* Multi Queue logs */ 43 #define QEDF_LOG_BSG 0x1000 /* BSG logs */ 44 #define QEDF_LOG_DEBUGFS 0x2000 /* debugFS logs */ 45 #define QEDF_LOG_LPORT 0x4000 /* lport logs */ 46 #define QEDF_LOG_ELS 0x8000 /* ELS logs */ 47 #define QEDF_LOG_NPIV 0x10000 /* NPIV logs */ 48 #define QEDF_LOG_SESS 0x20000 /* Conection setup, cleanup */ 49 #define QEDF_LOG_TID 0x80000 /* 50 * FW TID context acquire 51 * free 52 */ 53 #define QEDF_TRACK_TID 0x100000 /* 54 * Track TID state. To be 55 * enabled only at module load 56 * and not run-time. 57 */ 58 #define QEDF_TRACK_CMD_LIST 0x300000 /* 59 * Track active cmd list nodes, 60 * done with reference to TID, 61 * hence TRACK_TID also enabled. 62 */ 63 #define QEDF_LOG_NOTICE 0x40000000 /* Notice logs */ 64 #define QEDF_LOG_WARN 0x80000000 /* Warning logs */ 65 66 /* Debug context structure */ 67 struct qedf_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 QEDF_ERR(pdev, fmt, ...) \ 76 qedf_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 77 #define QEDF_WARN(pdev, fmt, ...) \ 78 qedf_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 79 #define QEDF_NOTICE(pdev, fmt, ...) \ 80 qedf_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 81 #define QEDF_INFO(pdev, level, fmt, ...) \ 82 qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \ 83 ## __VA_ARGS__) 84 __printf(4, 5) 85 void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 86 const char *fmt, ...); 87 __printf(4, 5) 88 void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 89 const char *, ...); 90 __printf(4, 5) 91 void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, 92 u32 line, const char *, ...); 93 __printf(5, 6) 94 void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 95 u32 info, const char *fmt, ...); 96 97 /* GRC Dump related defines */ 98 99 struct Scsi_Host; 100 101 #define QEDF_UEVENT_CODE_GRCDUMP 0 102 103 struct sysfs_bin_attrs { 104 char *name; 105 struct bin_attribute *attr; 106 }; 107 108 extern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len); 109 extern void qedf_free_grc_dump_buf(uint8_t **buf); 110 extern int qedf_get_grc_dump(struct qed_dev *cdev, 111 const struct qed_common_ops *common, uint8_t **buf, 112 uint32_t *grcsize); 113 extern void qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg); 114 extern int qedf_create_sysfs_attr(struct Scsi_Host *shost, 115 struct sysfs_bin_attrs *iter); 116 extern void qedf_remove_sysfs_attr(struct Scsi_Host *shost, 117 struct sysfs_bin_attrs *iter); 118 119 #ifdef CONFIG_DEBUG_FS 120 /* DebugFS related code */ 121 struct qedf_list_of_funcs { 122 char *oper_str; 123 ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf); 124 }; 125 126 struct qedf_debugfs_ops { 127 char *name; 128 struct qedf_list_of_funcs *qedf_funcs; 129 }; 130 131 #define qedf_dbg_fileops(drv, ops) \ 132 { \ 133 .owner = THIS_MODULE, \ 134 .open = simple_open, \ 135 .read = drv##_dbg_##ops##_cmd_read, \ 136 .write = drv##_dbg_##ops##_cmd_write \ 137 } 138 139 /* Used for debugfs sequential files */ 140 #define qedf_dbg_fileops_seq(drv, ops) \ 141 { \ 142 .owner = THIS_MODULE, \ 143 .open = drv##_dbg_##ops##_open, \ 144 .read = seq_read, \ 145 .llseek = seq_lseek, \ 146 .release = single_release, \ 147 } 148 149 extern void qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, 150 struct qedf_debugfs_ops *dops, 151 struct file_operations *fops); 152 extern void qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf); 153 extern void qedf_dbg_init(char *drv_name); 154 extern void qedf_dbg_exit(void); 155 #endif /* CONFIG_DEBUG_FS */ 156 157 #endif /* _QEDF_DBG_H_ */ 158