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