161d8658bSDupuis, Chad /* 261d8658bSDupuis, Chad * QLogic FCoE Offload Driver 361d8658bSDupuis, Chad * Copyright (c) 2016 Cavium Inc. 461d8658bSDupuis, Chad * 561d8658bSDupuis, Chad * This software is available under the terms of the GNU General Public License 661d8658bSDupuis, Chad * (GPL) Version 2, available from the file COPYING in the main directory of 761d8658bSDupuis, Chad * this source tree. 861d8658bSDupuis, Chad */ 961d8658bSDupuis, Chad #ifndef _QEDF_DBG_H_ 1061d8658bSDupuis, Chad #define _QEDF_DBG_H_ 1161d8658bSDupuis, Chad 1261d8658bSDupuis, Chad #include <linux/types.h> 1361d8658bSDupuis, Chad #include <linux/kernel.h> 1461d8658bSDupuis, Chad #include <linux/compiler.h> 1561d8658bSDupuis, Chad #include <linux/string.h> 1661d8658bSDupuis, Chad #include <linux/version.h> 1761d8658bSDupuis, Chad #include <linux/pci.h> 1861d8658bSDupuis, Chad #include <linux/delay.h> 1961d8658bSDupuis, Chad #include <scsi/scsi_transport.h> 2061d8658bSDupuis, Chad #include <linux/fs.h> 2161d8658bSDupuis, Chad 2261d8658bSDupuis, Chad #include <linux/qed/common_hsi.h> 2361d8658bSDupuis, Chad #include <linux/qed/qed_if.h> 2461d8658bSDupuis, Chad 2561d8658bSDupuis, Chad extern uint qedf_debug; 2661d8658bSDupuis, Chad 2761d8658bSDupuis, Chad /* Debug print level definitions */ 2861d8658bSDupuis, Chad #define QEDF_LOG_DEFAULT 0x1 /* Set default logging mask */ 2961d8658bSDupuis, Chad #define QEDF_LOG_INFO 0x2 /* 3061d8658bSDupuis, Chad * Informational logs, 3161d8658bSDupuis, Chad * MAC address, WWPN, WWNN 3261d8658bSDupuis, Chad */ 3361d8658bSDupuis, Chad #define QEDF_LOG_DISC 0x4 /* Init, discovery, rport */ 3461d8658bSDupuis, Chad #define QEDF_LOG_LL2 0x8 /* LL2, VLAN logs */ 3561d8658bSDupuis, Chad #define QEDF_LOG_CONN 0x10 /* Connection setup, cleanup */ 3661d8658bSDupuis, Chad #define QEDF_LOG_EVT 0x20 /* Events, link, mtu */ 3761d8658bSDupuis, Chad #define QEDF_LOG_TIMER 0x40 /* Timer events */ 3861d8658bSDupuis, Chad #define QEDF_LOG_MP_REQ 0x80 /* Middle Path (MP) logs */ 3961d8658bSDupuis, Chad #define QEDF_LOG_SCSI_TM 0x100 /* SCSI Aborts, Task Mgmt */ 4061d8658bSDupuis, Chad #define QEDF_LOG_UNSOL 0x200 /* unsolicited event logs */ 4161d8658bSDupuis, Chad #define QEDF_LOG_IO 0x400 /* scsi cmd, completion */ 4261d8658bSDupuis, Chad #define QEDF_LOG_MQ 0x800 /* Multi Queue logs */ 4361d8658bSDupuis, Chad #define QEDF_LOG_BSG 0x1000 /* BSG logs */ 4461d8658bSDupuis, Chad #define QEDF_LOG_DEBUGFS 0x2000 /* debugFS logs */ 4561d8658bSDupuis, Chad #define QEDF_LOG_LPORT 0x4000 /* lport logs */ 4661d8658bSDupuis, Chad #define QEDF_LOG_ELS 0x8000 /* ELS logs */ 4761d8658bSDupuis, Chad #define QEDF_LOG_NPIV 0x10000 /* NPIV logs */ 4861d8658bSDupuis, Chad #define QEDF_LOG_SESS 0x20000 /* Conection setup, cleanup */ 4961d8658bSDupuis, Chad #define QEDF_LOG_TID 0x80000 /* 5061d8658bSDupuis, Chad * FW TID context acquire 5161d8658bSDupuis, Chad * free 5261d8658bSDupuis, Chad */ 5361d8658bSDupuis, Chad #define QEDF_TRACK_TID 0x100000 /* 5461d8658bSDupuis, Chad * Track TID state. To be 5561d8658bSDupuis, Chad * enabled only at module load 5661d8658bSDupuis, Chad * and not run-time. 5761d8658bSDupuis, Chad */ 5861d8658bSDupuis, Chad #define QEDF_TRACK_CMD_LIST 0x300000 /* 5961d8658bSDupuis, Chad * Track active cmd list nodes, 6061d8658bSDupuis, Chad * done with reference to TID, 6161d8658bSDupuis, Chad * hence TRACK_TID also enabled. 6261d8658bSDupuis, Chad */ 6361d8658bSDupuis, Chad #define QEDF_LOG_NOTICE 0x40000000 /* Notice logs */ 6461d8658bSDupuis, Chad #define QEDF_LOG_WARN 0x80000000 /* Warning logs */ 6561d8658bSDupuis, Chad 6661d8658bSDupuis, Chad /* Debug context structure */ 6761d8658bSDupuis, Chad struct qedf_dbg_ctx { 6861d8658bSDupuis, Chad unsigned int host_no; 6961d8658bSDupuis, Chad struct pci_dev *pdev; 7061d8658bSDupuis, Chad #ifdef CONFIG_DEBUG_FS 7161d8658bSDupuis, Chad struct dentry *bdf_dentry; 7261d8658bSDupuis, Chad #endif 7361d8658bSDupuis, Chad }; 7461d8658bSDupuis, Chad 7561d8658bSDupuis, Chad #define QEDF_ERR(pdev, fmt, ...) \ 7661d8658bSDupuis, Chad qedf_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 7761d8658bSDupuis, Chad #define QEDF_WARN(pdev, fmt, ...) \ 7861d8658bSDupuis, Chad qedf_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 7961d8658bSDupuis, Chad #define QEDF_NOTICE(pdev, fmt, ...) \ 8061d8658bSDupuis, Chad qedf_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 8161d8658bSDupuis, Chad #define QEDF_INFO(pdev, level, fmt, ...) \ 8261d8658bSDupuis, Chad qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \ 8361d8658bSDupuis, Chad ## __VA_ARGS__) 84*db6b2060SJoe Perches __printf(4, 5) 85*db6b2060SJoe Perches void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 8661d8658bSDupuis, Chad const char *fmt, ...); 87*db6b2060SJoe Perches __printf(4, 5) 88*db6b2060SJoe Perches void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 8961d8658bSDupuis, Chad const char *, ...); 90*db6b2060SJoe Perches __printf(4, 5) 91*db6b2060SJoe Perches void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, 9261d8658bSDupuis, Chad u32 line, const char *, ...); 93*db6b2060SJoe Perches __printf(5, 6) 94*db6b2060SJoe Perches void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 9561d8658bSDupuis, Chad u32 info, const char *fmt, ...); 9661d8658bSDupuis, Chad 9761d8658bSDupuis, Chad /* GRC Dump related defines */ 9861d8658bSDupuis, Chad 9961d8658bSDupuis, Chad struct Scsi_Host; 10061d8658bSDupuis, Chad 10161d8658bSDupuis, Chad #define QEDF_UEVENT_CODE_GRCDUMP 0 10261d8658bSDupuis, Chad 10361d8658bSDupuis, Chad struct sysfs_bin_attrs { 10461d8658bSDupuis, Chad char *name; 10561d8658bSDupuis, Chad struct bin_attribute *attr; 10661d8658bSDupuis, Chad }; 10761d8658bSDupuis, Chad 10861d8658bSDupuis, Chad extern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len); 10961d8658bSDupuis, Chad extern void qedf_free_grc_dump_buf(uint8_t **buf); 11061d8658bSDupuis, Chad extern int qedf_get_grc_dump(struct qed_dev *cdev, 11161d8658bSDupuis, Chad const struct qed_common_ops *common, uint8_t **buf, 11261d8658bSDupuis, Chad uint32_t *grcsize); 11361d8658bSDupuis, Chad extern void qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg); 11461d8658bSDupuis, Chad extern int qedf_create_sysfs_attr(struct Scsi_Host *shost, 11561d8658bSDupuis, Chad struct sysfs_bin_attrs *iter); 11661d8658bSDupuis, Chad extern void qedf_remove_sysfs_attr(struct Scsi_Host *shost, 11761d8658bSDupuis, Chad struct sysfs_bin_attrs *iter); 11861d8658bSDupuis, Chad 11961d8658bSDupuis, Chad #ifdef CONFIG_DEBUG_FS 12061d8658bSDupuis, Chad /* DebugFS related code */ 12161d8658bSDupuis, Chad struct qedf_list_of_funcs { 12261d8658bSDupuis, Chad char *oper_str; 12361d8658bSDupuis, Chad ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf); 12461d8658bSDupuis, Chad }; 12561d8658bSDupuis, Chad 12661d8658bSDupuis, Chad struct qedf_debugfs_ops { 12761d8658bSDupuis, Chad char *name; 12861d8658bSDupuis, Chad struct qedf_list_of_funcs *qedf_funcs; 12961d8658bSDupuis, Chad }; 13061d8658bSDupuis, Chad 13161d8658bSDupuis, Chad #define qedf_dbg_fileops(drv, ops) \ 13261d8658bSDupuis, Chad { \ 13361d8658bSDupuis, Chad .owner = THIS_MODULE, \ 13461d8658bSDupuis, Chad .open = simple_open, \ 13561d8658bSDupuis, Chad .read = drv##_dbg_##ops##_cmd_read, \ 13661d8658bSDupuis, Chad .write = drv##_dbg_##ops##_cmd_write \ 13761d8658bSDupuis, Chad } 13861d8658bSDupuis, Chad 13961d8658bSDupuis, Chad /* Used for debugfs sequential files */ 14061d8658bSDupuis, Chad #define qedf_dbg_fileops_seq(drv, ops) \ 14161d8658bSDupuis, Chad { \ 14261d8658bSDupuis, Chad .owner = THIS_MODULE, \ 14361d8658bSDupuis, Chad .open = drv##_dbg_##ops##_open, \ 14461d8658bSDupuis, Chad .read = seq_read, \ 14561d8658bSDupuis, Chad .llseek = seq_lseek, \ 14661d8658bSDupuis, Chad .release = single_release, \ 14761d8658bSDupuis, Chad } 14861d8658bSDupuis, Chad 14961d8658bSDupuis, Chad extern void qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, 15061d8658bSDupuis, Chad struct qedf_debugfs_ops *dops, 15161d8658bSDupuis, Chad struct file_operations *fops); 15261d8658bSDupuis, Chad extern void qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf); 15361d8658bSDupuis, Chad extern void qedf_dbg_init(char *drv_name); 15461d8658bSDupuis, Chad extern void qedf_dbg_exit(void); 15561d8658bSDupuis, Chad #endif /* CONFIG_DEBUG_FS */ 15661d8658bSDupuis, Chad 15761d8658bSDupuis, Chad #endif /* _QEDF_DBG_H_ */ 158