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