1 /* 2 * QLogic FCoE 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 #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 85 extern void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 86 const char *fmt, ...); 87 extern void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 88 const char *, ...); 89 extern void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, 90 u32 line, const char *, ...); 91 extern void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 92 u32 info, const char *fmt, ...); 93 94 /* GRC Dump related defines */ 95 96 struct Scsi_Host; 97 98 #define QEDF_UEVENT_CODE_GRCDUMP 0 99 100 struct sysfs_bin_attrs { 101 char *name; 102 struct bin_attribute *attr; 103 }; 104 105 extern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len); 106 extern void qedf_free_grc_dump_buf(uint8_t **buf); 107 extern int qedf_get_grc_dump(struct qed_dev *cdev, 108 const struct qed_common_ops *common, uint8_t **buf, 109 uint32_t *grcsize); 110 extern void qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg); 111 extern int qedf_create_sysfs_attr(struct Scsi_Host *shost, 112 struct sysfs_bin_attrs *iter); 113 extern void qedf_remove_sysfs_attr(struct Scsi_Host *shost, 114 struct sysfs_bin_attrs *iter); 115 116 #ifdef CONFIG_DEBUG_FS 117 /* DebugFS related code */ 118 struct qedf_list_of_funcs { 119 char *oper_str; 120 ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf); 121 }; 122 123 struct qedf_debugfs_ops { 124 char *name; 125 struct qedf_list_of_funcs *qedf_funcs; 126 }; 127 128 #define qedf_dbg_fileops(drv, ops) \ 129 { \ 130 .owner = THIS_MODULE, \ 131 .open = simple_open, \ 132 .read = drv##_dbg_##ops##_cmd_read, \ 133 .write = drv##_dbg_##ops##_cmd_write \ 134 } 135 136 /* Used for debugfs sequential files */ 137 #define qedf_dbg_fileops_seq(drv, ops) \ 138 { \ 139 .owner = THIS_MODULE, \ 140 .open = drv##_dbg_##ops##_open, \ 141 .read = seq_read, \ 142 .llseek = seq_lseek, \ 143 .release = single_release, \ 144 } 145 146 extern void qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, 147 struct qedf_debugfs_ops *dops, 148 struct file_operations *fops); 149 extern void qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf); 150 extern void qedf_dbg_init(char *drv_name); 151 extern void qedf_dbg_exit(void); 152 #endif /* CONFIG_DEBUG_FS */ 153 154 #endif /* _QEDF_DBG_H_ */ 155