qedf_dbg.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * QLogic FCoE Offload Driver
  3. * Copyright (c) 2016-2018 Cavium Inc.
  4. *
  5. * This software is available under the terms of the GNU General Public License
  6. * (GPL) Version 2, available from the file COPYING in the main directory of
  7. * this source tree.
  8. */
  9. #ifndef _QEDF_DBG_H_
  10. #define _QEDF_DBG_H_
  11. #include <linux/types.h>
  12. #include <linux/kernel.h>
  13. #include <linux/compiler.h>
  14. #include <linux/string.h>
  15. #include <linux/version.h>
  16. #include <linux/pci.h>
  17. #include <linux/delay.h>
  18. #include <scsi/scsi_transport.h>
  19. #include <linux/fs.h>
  20. #include <linux/qed/common_hsi.h>
  21. #include <linux/qed/qed_if.h>
  22. extern uint qedf_debug;
  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, WWNN
  28. */
  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 /* Conection setup, cleanup */
  45. #define QEDF_LOG_TID 0x80000 /*
  46. * FW TID context acquire
  47. * free
  48. */
  49. #define QEDF_TRACK_TID 0x100000 /*
  50. * Track TID state. To be
  51. * enabled only at module load
  52. * 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. /* Debug context structure */
  62. struct qedf_dbg_ctx {
  63. unsigned int host_no;
  64. struct pci_dev *pdev;
  65. #ifdef CONFIG_DEBUG_FS
  66. struct dentry *bdf_dentry;
  67. #endif
  68. };
  69. #define QEDF_ERR(pdev, fmt, ...) \
  70. qedf_dbg_err(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
  71. #define QEDF_WARN(pdev, fmt, ...) \
  72. qedf_dbg_warn(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
  73. #define QEDF_NOTICE(pdev, fmt, ...) \
  74. qedf_dbg_notice(pdev, __func__, __LINE__, fmt, ## __VA_ARGS__)
  75. #define QEDF_INFO(pdev, level, fmt, ...) \
  76. qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \
  77. ## __VA_ARGS__)
  78. __printf(4, 5)
  79. void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
  80. const char *fmt, ...);
  81. __printf(4, 5)
  82. void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
  83. const char *, ...);
  84. __printf(4, 5)
  85. void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func,
  86. u32 line, const char *, ...);
  87. __printf(5, 6)
  88. void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
  89. u32 info, const char *fmt, ...);
  90. /* GRC Dump related defines */
  91. struct Scsi_Host;
  92. #define QEDF_UEVENT_CODE_GRCDUMP 0
  93. struct sysfs_bin_attrs {
  94. char *name;
  95. struct bin_attribute *attr;
  96. };
  97. extern int qedf_alloc_grc_dump_buf(uint8_t **buf, uint32_t len);
  98. extern void qedf_free_grc_dump_buf(uint8_t **buf);
  99. extern int qedf_get_grc_dump(struct qed_dev *cdev,
  100. const struct qed_common_ops *common, uint8_t **buf,
  101. uint32_t *grcsize);
  102. extern void qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg);
  103. extern int qedf_create_sysfs_attr(struct Scsi_Host *shost,
  104. struct sysfs_bin_attrs *iter);
  105. extern void qedf_remove_sysfs_attr(struct Scsi_Host *shost,
  106. struct sysfs_bin_attrs *iter);
  107. struct qedf_debugfs_ops {
  108. char *name;
  109. struct qedf_list_of_funcs *qedf_funcs;
  110. };
  111. extern const struct qedf_debugfs_ops qedf_debugfs_ops[];
  112. extern const struct file_operations qedf_dbg_fops[];
  113. #ifdef CONFIG_DEBUG_FS
  114. /* DebugFS related code */
  115. struct qedf_list_of_funcs {
  116. char *oper_str;
  117. ssize_t (*oper_func)(struct qedf_dbg_ctx *qedf);
  118. };
  119. #define qedf_dbg_fileops(drv, ops) \
  120. { \
  121. .owner = THIS_MODULE, \
  122. .open = simple_open, \
  123. .read = drv##_dbg_##ops##_cmd_read, \
  124. .write = drv##_dbg_##ops##_cmd_write \
  125. }
  126. /* Used for debugfs sequential files */
  127. #define qedf_dbg_fileops_seq(drv, ops) \
  128. { \
  129. .owner = THIS_MODULE, \
  130. .open = drv##_dbg_##ops##_open, \
  131. .read = seq_read, \
  132. .llseek = seq_lseek, \
  133. .release = single_release, \
  134. }
  135. extern void qedf_dbg_host_init(struct qedf_dbg_ctx *qedf,
  136. const struct qedf_debugfs_ops *dops,
  137. const struct file_operations *fops);
  138. extern void qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf);
  139. extern void qedf_dbg_init(char *drv_name);
  140. extern void qedf_dbg_exit(void);
  141. #endif /* CONFIG_DEBUG_FS */
  142. #endif /* _QEDF_DBG_H_ */