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