qedf_dbg.h 4.8 KB

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