139 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * QLogic iSCSI Offload Driver4 * Copyright (c) 2016 Cavium Inc.5 */6 7#ifndef _QEDI_DBG_H_8#define _QEDI_DBG_H_9 10#include <linux/types.h>11#include <linux/kernel.h>12#include <linux/compiler.h>13#include <linux/string.h>14#include <linux/pci.h>15#include <linux/delay.h>16#include <scsi/scsi_transport.h>17#include <scsi/scsi_transport_iscsi.h>18#include <linux/fs.h>19 20#define __PREVENT_QED_HSI__21#include <linux/qed/common_hsi.h>22#include <linux/qed/qed_if.h>23 24extern uint qedi_dbg_log;25 26/* Debug print level definitions */27#define QEDI_LOG_DEFAULT 0x1 /* Set default logging mask */28#define QEDI_LOG_INFO 0x2 /* Informational logs,29 * MAC address, WWPN, WWNN30 */31#define QEDI_LOG_DISC 0x4 /* Init, discovery, rport */32#define QEDI_LOG_LL2 0x8 /* LL2, VLAN logs */33#define QEDI_LOG_CONN 0x10 /* Connection setup, cleanup */34#define QEDI_LOG_EVT 0x20 /* Events, link, mtu */35#define QEDI_LOG_TIMER 0x40 /* Timer events */36#define QEDI_LOG_MP_REQ 0x80 /* Middle Path (MP) logs */37#define QEDI_LOG_SCSI_TM 0x100 /* SCSI Aborts, Task Mgmt */38#define QEDI_LOG_UNSOL 0x200 /* unsolicited event logs */39#define QEDI_LOG_IO 0x400 /* scsi cmd, completion */40#define QEDI_LOG_MQ 0x800 /* Multi Queue logs */41#define QEDI_LOG_BSG 0x1000 /* BSG logs */42#define QEDI_LOG_DEBUGFS 0x2000 /* debugFS logs */43#define QEDI_LOG_LPORT 0x4000 /* lport logs */44#define QEDI_LOG_ELS 0x8000 /* ELS logs */45#define QEDI_LOG_NPIV 0x10000 /* NPIV logs */46#define QEDI_LOG_SESS 0x20000 /* Connection setup, cleanup */47#define QEDI_LOG_UIO 0x40000 /* iSCSI UIO logs */48#define QEDI_LOG_TID 0x80000 /* FW TID context acquire,49 * free50 */51#define QEDI_TRACK_TID 0x100000 /* Track TID state. To be52 * enabled only at module load53 * and not run-time.54 */55#define QEDI_TRACK_CMD_LIST 0x300000 /* Track active cmd list nodes,56 * done with reference to TID,57 * hence TRACK_TID also enabled.58 */59#define QEDI_LOG_NOTICE 0x40000000 /* Notice logs */60#define QEDI_LOG_WARN 0x80000000 /* Warning logs */61 62/* Debug context structure */63struct qedi_dbg_ctx {64 unsigned int host_no;65 struct pci_dev *pdev;66#ifdef CONFIG_DEBUG_FS67 struct dentry *bdf_dentry;68#endif69};70 71#define QEDI_ERR(pdev, fmt, ...) \72 qedi_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)73#define QEDI_WARN(pdev, fmt, ...) \74 qedi_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)75#define QEDI_NOTICE(pdev, fmt, ...) \76 qedi_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)77#define QEDI_INFO(pdev, level, fmt, ...) \78 qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \79 ## __VA_ARGS__)80 81void qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,82 const char *fmt, ...);83void qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,84 const char *fmt, ...);85void qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,86 const char *fmt, ...);87void qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,88 u32 info, const char *fmt, ...);89 90struct Scsi_Host;91 92struct sysfs_bin_attrs {93 char *name;94 struct bin_attribute *attr;95};96 97int qedi_create_sysfs_attr(struct Scsi_Host *shost,98 struct sysfs_bin_attrs *iter);99void qedi_remove_sysfs_attr(struct Scsi_Host *shost,100 struct sysfs_bin_attrs *iter);101 102/* DebugFS related code */103struct qedi_list_of_funcs {104 char *oper_str;105 ssize_t (*oper_func)(struct qedi_dbg_ctx *qedi);106};107 108struct qedi_debugfs_ops {109 char *name;110 struct qedi_list_of_funcs *qedi_funcs;111};112 113#define qedi_dbg_fileops(drv, ops) \114{ \115 .owner = THIS_MODULE, \116 .open = simple_open, \117 .read = drv##_dbg_##ops##_cmd_read, \118 .write = drv##_dbg_##ops##_cmd_write \119}120 121/* Used for debugfs sequential files */122#define qedi_dbg_fileops_seq(drv, ops) \123{ \124 .owner = THIS_MODULE, \125 .open = drv##_dbg_##ops##_open, \126 .read = seq_read, \127 .llseek = seq_lseek, \128 .release = single_release, \129}130 131void qedi_dbg_host_init(struct qedi_dbg_ctx *qedi,132 const struct qedi_debugfs_ops *dops,133 const struct file_operations *fops);134void qedi_dbg_host_exit(struct qedi_dbg_ctx *qedi);135void qedi_dbg_init(char *drv_name);136void qedi_dbg_exit(void);137 138#endif /* _QEDI_DBG_H_ */139