Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * QLogic iSCSI Offload Driver
0004  * Copyright (c) 2016 Cavium Inc.
0005  */
0006 
0007 #ifndef _QEDI_DBG_H_
0008 #define _QEDI_DBG_H_
0009 
0010 #include <linux/types.h>
0011 #include <linux/kernel.h>
0012 #include <linux/compiler.h>
0013 #include <linux/string.h>
0014 #include <linux/version.h>
0015 #include <linux/pci.h>
0016 #include <linux/delay.h>
0017 #include <scsi/scsi_transport.h>
0018 #include <scsi/scsi_transport_iscsi.h>
0019 #include <linux/fs.h>
0020 
0021 #define __PREVENT_QED_HSI__
0022 #include <linux/qed/common_hsi.h>
0023 #include <linux/qed/qed_if.h>
0024 
0025 extern uint qedi_dbg_log;
0026 
0027 /* Debug print level definitions */
0028 #define QEDI_LOG_DEFAULT    0x1     /* Set default logging mask */
0029 #define QEDI_LOG_INFO       0x2     /* Informational logs,
0030                          * MAC address, WWPN, WWNN
0031                          */
0032 #define QEDI_LOG_DISC       0x4     /* Init, discovery, rport */
0033 #define QEDI_LOG_LL2        0x8     /* LL2, VLAN logs */
0034 #define QEDI_LOG_CONN       0x10        /* Connection setup, cleanup */
0035 #define QEDI_LOG_EVT        0x20        /* Events, link, mtu */
0036 #define QEDI_LOG_TIMER      0x40        /* Timer events */
0037 #define QEDI_LOG_MP_REQ     0x80        /* Middle Path (MP) logs */
0038 #define QEDI_LOG_SCSI_TM    0x100       /* SCSI Aborts, Task Mgmt */
0039 #define QEDI_LOG_UNSOL      0x200       /* unsolicited event logs */
0040 #define QEDI_LOG_IO     0x400       /* scsi cmd, completion */
0041 #define QEDI_LOG_MQ     0x800       /* Multi Queue logs */
0042 #define QEDI_LOG_BSG        0x1000      /* BSG logs */
0043 #define QEDI_LOG_DEBUGFS    0x2000      /* debugFS logs */
0044 #define QEDI_LOG_LPORT      0x4000      /* lport logs */
0045 #define QEDI_LOG_ELS        0x8000      /* ELS logs */
0046 #define QEDI_LOG_NPIV       0x10000     /* NPIV logs */
0047 #define QEDI_LOG_SESS       0x20000     /* Connection setup, cleanup */
0048 #define QEDI_LOG_UIO        0x40000     /* iSCSI UIO logs */
0049 #define QEDI_LOG_TID        0x80000         /* FW TID context acquire,
0050                          * free
0051                          */
0052 #define QEDI_TRACK_TID      0x100000        /* Track TID state. To be
0053                          * enabled only at module load
0054                          * and not run-time.
0055                          */
0056 #define QEDI_TRACK_CMD_LIST    0x300000        /* Track active cmd list nodes,
0057                         * done with reference to TID,
0058                         * hence TRACK_TID also enabled.
0059                         */
0060 #define QEDI_LOG_NOTICE     0x40000000  /* Notice logs */
0061 #define QEDI_LOG_WARN       0x80000000  /* Warning logs */
0062 
0063 /* Debug context structure */
0064 struct qedi_dbg_ctx {
0065     unsigned int host_no;
0066     struct pci_dev *pdev;
0067 #ifdef CONFIG_DEBUG_FS
0068     struct dentry *bdf_dentry;
0069 #endif
0070 };
0071 
0072 #define QEDI_ERR(pdev, fmt, ...)    \
0073         qedi_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
0074 #define QEDI_WARN(pdev, fmt, ...)   \
0075         qedi_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
0076 #define QEDI_NOTICE(pdev, fmt, ...) \
0077         qedi_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
0078 #define QEDI_INFO(pdev, level, fmt, ...)    \
0079         qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
0080                   ## __VA_ARGS__)
0081 
0082 void qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
0083           const char *fmt, ...);
0084 void qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
0085            const char *fmt, ...);
0086 void qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
0087              const char *fmt, ...);
0088 void qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
0089            u32 info, const char *fmt, ...);
0090 
0091 struct Scsi_Host;
0092 
0093 struct sysfs_bin_attrs {
0094     char *name;
0095     struct bin_attribute *attr;
0096 };
0097 
0098 int qedi_create_sysfs_attr(struct Scsi_Host *shost,
0099                struct sysfs_bin_attrs *iter);
0100 void qedi_remove_sysfs_attr(struct Scsi_Host *shost,
0101                 struct sysfs_bin_attrs *iter);
0102 
0103 /* DebugFS related code */
0104 struct qedi_list_of_funcs {
0105     char *oper_str;
0106     ssize_t (*oper_func)(struct qedi_dbg_ctx *qedi);
0107 };
0108 
0109 struct qedi_debugfs_ops {
0110     char *name;
0111     struct qedi_list_of_funcs *qedi_funcs;
0112 };
0113 
0114 #define qedi_dbg_fileops(drv, ops) \
0115 { \
0116     .owner  = THIS_MODULE, \
0117     .open   = simple_open, \
0118     .read   = drv##_dbg_##ops##_cmd_read, \
0119     .write  = drv##_dbg_##ops##_cmd_write \
0120 }
0121 
0122 /* Used for debugfs sequential files */
0123 #define qedi_dbg_fileops_seq(drv, ops) \
0124 { \
0125     .owner = THIS_MODULE, \
0126     .open = drv##_dbg_##ops##_open, \
0127     .read = seq_read, \
0128     .llseek = seq_lseek, \
0129     .release = single_release, \
0130 }
0131 
0132 void qedi_dbg_host_init(struct qedi_dbg_ctx *qedi,
0133             const struct qedi_debugfs_ops *dops,
0134             const struct file_operations *fops);
0135 void qedi_dbg_host_exit(struct qedi_dbg_ctx *qedi);
0136 void qedi_dbg_init(char *drv_name);
0137 void qedi_dbg_exit(void);
0138 
0139 #endif /* _QEDI_DBG_H_ */