18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * QLogic FCoE Offload Driver 48c2ecf20Sopenharmony_ci * Copyright (c) 2016-2018 Cavium Inc. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef _QEDF_DBG_H_ 78c2ecf20Sopenharmony_ci#define _QEDF_DBG_H_ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci#include <linux/kernel.h> 118c2ecf20Sopenharmony_ci#include <linux/compiler.h> 128c2ecf20Sopenharmony_ci#include <linux/string.h> 138c2ecf20Sopenharmony_ci#include <linux/version.h> 148c2ecf20Sopenharmony_ci#include <linux/pci.h> 158c2ecf20Sopenharmony_ci#include <linux/delay.h> 168c2ecf20Sopenharmony_ci#include <scsi/scsi_transport.h> 178c2ecf20Sopenharmony_ci#include <linux/fs.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include <linux/qed/common_hsi.h> 208c2ecf20Sopenharmony_ci#include <linux/qed/qed_if.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciextern uint qedf_debug; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* Debug print level definitions */ 258c2ecf20Sopenharmony_ci#define QEDF_LOG_DEFAULT 0x1 /* Set default logging mask */ 268c2ecf20Sopenharmony_ci#define QEDF_LOG_INFO 0x2 /* 278c2ecf20Sopenharmony_ci * Informational logs, 288c2ecf20Sopenharmony_ci * MAC address, WWPN, WWNN 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci#define QEDF_LOG_DISC 0x4 /* Init, discovery, rport */ 318c2ecf20Sopenharmony_ci#define QEDF_LOG_LL2 0x8 /* LL2, VLAN logs */ 328c2ecf20Sopenharmony_ci#define QEDF_LOG_CONN 0x10 /* Connection setup, cleanup */ 338c2ecf20Sopenharmony_ci#define QEDF_LOG_EVT 0x20 /* Events, link, mtu */ 348c2ecf20Sopenharmony_ci#define QEDF_LOG_TIMER 0x40 /* Timer events */ 358c2ecf20Sopenharmony_ci#define QEDF_LOG_MP_REQ 0x80 /* Middle Path (MP) logs */ 368c2ecf20Sopenharmony_ci#define QEDF_LOG_SCSI_TM 0x100 /* SCSI Aborts, Task Mgmt */ 378c2ecf20Sopenharmony_ci#define QEDF_LOG_UNSOL 0x200 /* unsolicited event logs */ 388c2ecf20Sopenharmony_ci#define QEDF_LOG_IO 0x400 /* scsi cmd, completion */ 398c2ecf20Sopenharmony_ci#define QEDF_LOG_MQ 0x800 /* Multi Queue logs */ 408c2ecf20Sopenharmony_ci#define QEDF_LOG_BSG 0x1000 /* BSG logs */ 418c2ecf20Sopenharmony_ci#define QEDF_LOG_DEBUGFS 0x2000 /* debugFS logs */ 428c2ecf20Sopenharmony_ci#define QEDF_LOG_LPORT 0x4000 /* lport logs */ 438c2ecf20Sopenharmony_ci#define QEDF_LOG_ELS 0x8000 /* ELS logs */ 448c2ecf20Sopenharmony_ci#define QEDF_LOG_NPIV 0x10000 /* NPIV logs */ 458c2ecf20Sopenharmony_ci#define QEDF_LOG_SESS 0x20000 /* Connection setup, cleanup */ 468c2ecf20Sopenharmony_ci#define QEDF_LOG_TID 0x80000 /* 478c2ecf20Sopenharmony_ci * FW TID context acquire 488c2ecf20Sopenharmony_ci * free 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci#define QEDF_TRACK_TID 0x100000 /* 518c2ecf20Sopenharmony_ci * Track TID state. To be 528c2ecf20Sopenharmony_ci * enabled only at module load 538c2ecf20Sopenharmony_ci * and not run-time. 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci#define QEDF_TRACK_CMD_LIST 0x300000 /* 568c2ecf20Sopenharmony_ci * Track active cmd list nodes, 578c2ecf20Sopenharmony_ci * done with reference to TID, 588c2ecf20Sopenharmony_ci * hence TRACK_TID also enabled. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci#define QEDF_LOG_NOTICE 0x40000000 /* Notice logs */ 618c2ecf20Sopenharmony_ci#define QEDF_LOG_WARN 0x80000000 /* Warning logs */ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define QEDF_DEBUGFS_LOG_LEN (2 * PAGE_SIZE) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Debug context structure */ 668c2ecf20Sopenharmony_cistruct qedf_dbg_ctx { 678c2ecf20Sopenharmony_ci unsigned int host_no; 688c2ecf20Sopenharmony_ci struct pci_dev *pdev; 698c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 708c2ecf20Sopenharmony_ci struct dentry *bdf_dentry; 718c2ecf20Sopenharmony_ci#endif 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define QEDF_ERR(pdev, fmt, ...) \ 758c2ecf20Sopenharmony_ci qedf_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 768c2ecf20Sopenharmony_ci#define QEDF_WARN(pdev, fmt, ...) \ 778c2ecf20Sopenharmony_ci qedf_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 788c2ecf20Sopenharmony_ci#define QEDF_NOTICE(pdev, fmt, ...) \ 798c2ecf20Sopenharmony_ci qedf_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__) 808c2ecf20Sopenharmony_ci#define QEDF_INFO(pdev, level, fmt, ...) \ 818c2ecf20Sopenharmony_ci qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \ 828c2ecf20Sopenharmony_ci ## __VA_ARGS__) 838c2ecf20Sopenharmony_ci__printf(4, 5) 848c2ecf20Sopenharmony_civoid qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 858c2ecf20Sopenharmony_ci const char *fmt, ...); 868c2ecf20Sopenharmony_ci__printf(4, 5) 878c2ecf20Sopenharmony_civoid qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 888c2ecf20Sopenharmony_ci const char *, ...); 898c2ecf20Sopenharmony_ci__printf(4, 5) 908c2ecf20Sopenharmony_civoid qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, 918c2ecf20Sopenharmony_ci u32 line, const char *, ...); 928c2ecf20Sopenharmony_ci__printf(5, 6) 938c2ecf20Sopenharmony_civoid qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 948c2ecf20Sopenharmony_ci u32 info, const char *fmt, ...); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* GRC Dump related defines */ 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistruct Scsi_Host; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define QEDF_UEVENT_CODE_GRCDUMP 0 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistruct sysfs_bin_attrs { 1038c2ecf20Sopenharmony_ci char *name; 1048c2ecf20Sopenharmony_ci struct bin_attribute *attr; 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ciextern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len); 1088c2ecf20Sopenharmony_ciextern void qedf_free_grc_dump_buf(uint8_t **buf); 1098c2ecf20Sopenharmony_ciextern int qedf_get_grc_dump(struct qed_dev *cdev, 1108c2ecf20Sopenharmony_ci const struct qed_common_ops *common, uint8_t **buf, 1118c2ecf20Sopenharmony_ci uint32_t *grcsize); 1128c2ecf20Sopenharmony_ciextern void qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg); 1138c2ecf20Sopenharmony_ciextern int qedf_create_sysfs_attr(struct Scsi_Host *shost, 1148c2ecf20Sopenharmony_ci struct sysfs_bin_attrs *iter); 1158c2ecf20Sopenharmony_ciextern void qedf_remove_sysfs_attr(struct Scsi_Host *shost, 1168c2ecf20Sopenharmony_ci struct sysfs_bin_attrs *iter); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cistruct qedf_debugfs_ops { 1198c2ecf20Sopenharmony_ci char *name; 1208c2ecf20Sopenharmony_ci struct qedf_list_of_funcs *qedf_funcs; 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciextern const struct qedf_debugfs_ops qedf_debugfs_ops[]; 1248c2ecf20Sopenharmony_ciextern const struct file_operations qedf_dbg_fops[]; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 1278c2ecf20Sopenharmony_ci/* DebugFS related code */ 1288c2ecf20Sopenharmony_cistruct qedf_list_of_funcs { 1298c2ecf20Sopenharmony_ci char *oper_str; 1308c2ecf20Sopenharmony_ci ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf); 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define qedf_dbg_fileops(drv, ops) \ 1348c2ecf20Sopenharmony_ci{ \ 1358c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 1368c2ecf20Sopenharmony_ci .open = simple_open, \ 1378c2ecf20Sopenharmony_ci .read = drv##_dbg_##ops##_cmd_read, \ 1388c2ecf20Sopenharmony_ci .write = drv##_dbg_##ops##_cmd_write \ 1398c2ecf20Sopenharmony_ci} 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* Used for debugfs sequential files */ 1428c2ecf20Sopenharmony_ci#define qedf_dbg_fileops_seq(drv, ops) \ 1438c2ecf20Sopenharmony_ci{ \ 1448c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 1458c2ecf20Sopenharmony_ci .open = drv##_dbg_##ops##_open, \ 1468c2ecf20Sopenharmony_ci .read = seq_read, \ 1478c2ecf20Sopenharmony_ci .llseek = seq_lseek, \ 1488c2ecf20Sopenharmony_ci .release = single_release, \ 1498c2ecf20Sopenharmony_ci} 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciextern void qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, 1528c2ecf20Sopenharmony_ci const struct qedf_debugfs_ops *dops, 1538c2ecf20Sopenharmony_ci const struct file_operations *fops); 1548c2ecf20Sopenharmony_ciextern void qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf); 1558c2ecf20Sopenharmony_ciextern void qedf_dbg_init(char *drv_name); 1568c2ecf20Sopenharmony_ciextern void qedf_dbg_exit(void); 1578c2ecf20Sopenharmony_ci#endif /* CONFIG_DEBUG_FS */ 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#endif /* _QEDF_DBG_H_ */ 160