qedi_dbg.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * QLogic iSCSI Offload Driver
  4. * Copyright (c) 2016 Cavium Inc.
  5. */
  6. #ifndef _QEDI_DBG_H_
  7. #define _QEDI_DBG_H_
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/compiler.h>
  11. #include <linux/string.h>
  12. #include <linux/pci.h>
  13. #include <linux/delay.h>
  14. #include <scsi/scsi_transport.h>
  15. #include <scsi/scsi_transport_iscsi.h>
  16. #include <linux/fs.h>
  17. #define __PREVENT_QED_HSI__
  18. #include <linux/qed/common_hsi.h>
  19. #include <linux/qed/qed_if.h>
  20. extern uint qedi_dbg_log;
  21. /* Debug print level definitions */
  22. #define QEDI_LOG_DEFAULT 0x1 /* Set default logging mask */
  23. #define QEDI_LOG_INFO 0x2 /* Informational logs,
  24. * MAC address, WWPN, WWNN
  25. */
  26. #define QEDI_LOG_DISC 0x4 /* Init, discovery, rport */
  27. #define QEDI_LOG_LL2 0x8 /* LL2, VLAN logs */
  28. #define QEDI_LOG_CONN 0x10 /* Connection setup, cleanup */
  29. #define QEDI_LOG_EVT 0x20 /* Events, link, mtu */
  30. #define QEDI_LOG_TIMER 0x40 /* Timer events */
  31. #define QEDI_LOG_MP_REQ 0x80 /* Middle Path (MP) logs */
  32. #define QEDI_LOG_SCSI_TM 0x100 /* SCSI Aborts, Task Mgmt */
  33. #define QEDI_LOG_UNSOL 0x200 /* unsolicited event logs */
  34. #define QEDI_LOG_IO 0x400 /* scsi cmd, completion */
  35. #define QEDI_LOG_MQ 0x800 /* Multi Queue logs */
  36. #define QEDI_LOG_BSG 0x1000 /* BSG logs */
  37. #define QEDI_LOG_DEBUGFS 0x2000 /* debugFS logs */
  38. #define QEDI_LOG_LPORT 0x4000 /* lport logs */
  39. #define QEDI_LOG_ELS 0x8000 /* ELS logs */
  40. #define QEDI_LOG_NPIV 0x10000 /* NPIV logs */
  41. #define QEDI_LOG_SESS 0x20000 /* Connection setup, cleanup */
  42. #define QEDI_LOG_UIO 0x40000 /* iSCSI UIO logs */
  43. #define QEDI_LOG_TID 0x80000 /* FW TID context acquire,
  44. * free
  45. */
  46. #define QEDI_TRACK_TID 0x100000 /* Track TID state. To be
  47. * enabled only at module load
  48. * and not run-time.
  49. */
  50. #define QEDI_TRACK_CMD_LIST 0x300000 /* Track active cmd list nodes,
  51. * done with reference to TID,
  52. * hence TRACK_TID also enabled.
  53. */
  54. #define QEDI_LOG_NOTICE 0x40000000 /* Notice logs */
  55. #define QEDI_LOG_WARN 0x80000000 /* Warning logs */
  56. /* Debug context structure */
  57. struct qedi_dbg_ctx {
  58. unsigned int host_no;
  59. struct pci_dev *pdev;
  60. #ifdef CONFIG_DEBUG_FS
  61. struct dentry *bdf_dentry;
  62. #endif
  63. };
  64. #define QEDI_ERR(pdev, fmt, ...) \
  65. qedi_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
  66. #define QEDI_WARN(pdev, fmt, ...) \
  67. qedi_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
  68. #define QEDI_NOTICE(pdev, fmt, ...) \
  69. qedi_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
  70. #define QEDI_INFO(pdev, level, fmt, ...) \
  71. qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
  72. ## __VA_ARGS__)
  73. void qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
  74. const char *fmt, ...);
  75. void qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
  76. const char *fmt, ...);
  77. void qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
  78. const char *fmt, ...);
  79. void qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
  80. u32 info, const char *fmt, ...);
  81. struct Scsi_Host;
  82. struct sysfs_bin_attrs {
  83. char *name;
  84. struct bin_attribute *attr;
  85. };
  86. int qedi_create_sysfs_attr(struct Scsi_Host *shost,
  87. struct sysfs_bin_attrs *iter);
  88. void qedi_remove_sysfs_attr(struct Scsi_Host *shost,
  89. struct sysfs_bin_attrs *iter);
  90. /* DebugFS related code */
  91. struct qedi_list_of_funcs {
  92. char *oper_str;
  93. ssize_t (*oper_func)(struct qedi_dbg_ctx *qedi);
  94. };
  95. struct qedi_debugfs_ops {
  96. char *name;
  97. struct qedi_list_of_funcs *qedi_funcs;
  98. };
  99. #define qedi_dbg_fileops(drv, ops) \
  100. { \
  101. .owner = THIS_MODULE, \
  102. .open = simple_open, \
  103. .read = drv##_dbg_##ops##_cmd_read, \
  104. .write = drv##_dbg_##ops##_cmd_write \
  105. }
  106. /* Used for debugfs sequential files */
  107. #define qedi_dbg_fileops_seq(drv, ops) \
  108. { \
  109. .owner = THIS_MODULE, \
  110. .open = drv##_dbg_##ops##_open, \
  111. .read = seq_read, \
  112. .llseek = seq_lseek, \
  113. .release = single_release, \
  114. }
  115. void qedi_dbg_host_init(struct qedi_dbg_ctx *qedi,
  116. const struct qedi_debugfs_ops *dops,
  117. const struct file_operations *fops);
  118. void qedi_dbg_host_exit(struct qedi_dbg_ctx *qedi);
  119. void qedi_dbg_init(char *drv_name);
  120. void qedi_dbg_exit(void);
  121. #endif /* _QEDI_DBG_H_ */