qedi_dbg.h 4.3 KB

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