159 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * QLogic FCoE Offload Driver4 * Copyright (c) 2016-2018 Cavium Inc.5 */6#ifndef _QEDF_DBG_H_7#define _QEDF_DBG_H_8 9#include <linux/types.h>10#include <linux/kernel.h>11#include <linux/compiler.h>12#include <linux/string.h>13#include <linux/pci.h>14#include <linux/delay.h>15#include <scsi/scsi_transport.h>16#include <linux/fs.h>17 18#include <linux/qed/common_hsi.h>19#include <linux/qed/qed_if.h>20 21extern uint qedf_debug;22 23/* Debug print level definitions */24#define QEDF_LOG_DEFAULT 0x1 /* Set default logging mask */25#define QEDF_LOG_INFO 0x2 /*26 * Informational logs,27 * MAC address, WWPN, WWNN28 */29#define QEDF_LOG_DISC 0x4 /* Init, discovery, rport */30#define QEDF_LOG_LL2 0x8 /* LL2, VLAN logs */31#define QEDF_LOG_CONN 0x10 /* Connection setup, cleanup */32#define QEDF_LOG_EVT 0x20 /* Events, link, mtu */33#define QEDF_LOG_TIMER 0x40 /* Timer events */34#define QEDF_LOG_MP_REQ 0x80 /* Middle Path (MP) logs */35#define QEDF_LOG_SCSI_TM 0x100 /* SCSI Aborts, Task Mgmt */36#define QEDF_LOG_UNSOL 0x200 /* unsolicited event logs */37#define QEDF_LOG_IO 0x400 /* scsi cmd, completion */38#define QEDF_LOG_MQ 0x800 /* Multi Queue logs */39#define QEDF_LOG_BSG 0x1000 /* BSG logs */40#define QEDF_LOG_DEBUGFS 0x2000 /* debugFS logs */41#define QEDF_LOG_LPORT 0x4000 /* lport logs */42#define QEDF_LOG_ELS 0x8000 /* ELS logs */43#define QEDF_LOG_NPIV 0x10000 /* NPIV logs */44#define QEDF_LOG_SESS 0x20000 /* Connection setup, cleanup */45#define QEDF_LOG_TID 0x80000 /*46 * FW TID context acquire47 * free48 */49#define QEDF_TRACK_TID 0x100000 /*50 * Track TID state. To be51 * enabled only at module load52 * and not run-time.53 */54#define QEDF_TRACK_CMD_LIST 0x300000 /*55 * Track active cmd list nodes,56 * done with reference to TID,57 * hence TRACK_TID also enabled.58 */59#define QEDF_LOG_NOTICE 0x40000000 /* Notice logs */60#define QEDF_LOG_WARN 0x80000000 /* Warning logs */61 62#define QEDF_DEBUGFS_LOG_LEN (2 * PAGE_SIZE)63 64/* Debug context structure */65struct qedf_dbg_ctx {66 unsigned int host_no;67 struct pci_dev *pdev;68#ifdef CONFIG_DEBUG_FS69 struct dentry *bdf_dentry;70#endif71};72 73#define QEDF_ERR(pdev, fmt, ...) \74 qedf_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)75#define QEDF_WARN(pdev, fmt, ...) \76 qedf_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)77#define QEDF_NOTICE(pdev, fmt, ...) \78 qedf_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)79#define QEDF_INFO(pdev, level, fmt, ...) \80 qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \81 ## __VA_ARGS__)82__printf(4, 5)83void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,84 const char *fmt, ...);85__printf(4, 5)86void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line,87 const char *, ...);88__printf(4, 5)89void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func,90 u32 line, const char *, ...);91__printf(5, 6)92void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line,93 u32 info, const char *fmt, ...);94 95/* GRC Dump related defines */96 97struct Scsi_Host;98 99#define QEDF_UEVENT_CODE_GRCDUMP 0100 101struct sysfs_bin_attrs {102 char *name;103 struct bin_attribute *attr;104};105 106extern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len);107extern void qedf_free_grc_dump_buf(uint8_t **buf);108extern int qedf_get_grc_dump(struct qed_dev *cdev,109 const struct qed_common_ops *common, uint8_t **buf,110 uint32_t *grcsize);111extern void qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg);112extern int qedf_create_sysfs_attr(struct Scsi_Host *shost,113 struct sysfs_bin_attrs *iter);114extern void qedf_remove_sysfs_attr(struct Scsi_Host *shost,115 struct sysfs_bin_attrs *iter);116 117struct qedf_debugfs_ops {118 char *name;119 struct qedf_list_of_funcs *qedf_funcs;120};121 122extern const struct qedf_debugfs_ops qedf_debugfs_ops[];123extern const struct file_operations qedf_dbg_fops[];124 125#ifdef CONFIG_DEBUG_FS126/* DebugFS related code */127struct qedf_list_of_funcs {128 char *oper_str;129 ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf);130};131 132#define qedf_dbg_fileops(drv, ops) \133{ \134 .owner = THIS_MODULE, \135 .open = simple_open, \136 .read = drv##_dbg_##ops##_cmd_read, \137 .write = drv##_dbg_##ops##_cmd_write \138}139 140/* Used for debugfs sequential files */141#define qedf_dbg_fileops_seq(drv, ops) \142{ \143 .owner = THIS_MODULE, \144 .open = drv##_dbg_##ops##_open, \145 .read = seq_read, \146 .llseek = seq_lseek, \147 .release = single_release, \148}149 150extern void qedf_dbg_host_init(struct qedf_dbg_ctx *qedf,151 const struct qedf_debugfs_ops *dops,152 const struct file_operations *fops);153extern void qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf);154extern void qedf_dbg_init(char *drv_name);155extern void qedf_dbg_exit(void);156#endif /* CONFIG_DEBUG_FS */157 158#endif /* _QEDF_DBG_H_ */159