mpt3sas_debug.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * Logging Support for MPT (Message Passing Technology) based controllers
  3. *
  4. * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
  5. * Copyright (C) 2012 LSI Corporation
  6. * (mailto:DL-MPTFusionLinux@lsi.com)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * NO WARRANTY
  19. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  20. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  21. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  22. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  23. * solely responsible for determining the appropriateness of using and
  24. * distributing the Program and assumes all risks associated with its
  25. * exercise of rights under this Agreement, including but not limited to
  26. * the risks and costs of program errors, damage to or loss of data,
  27. * programs or equipment, and unavailability or interruption of operations.
  28. * DISCLAIMER OF LIABILITY
  29. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  30. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  32. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  33. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  34. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  35. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  36. * You should have received a copy of the GNU General Public License
  37. * along with this program; if not, write to the Free Software
  38. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  39. * USA.
  40. */
  41. #ifndef MPT3SAS_DEBUG_H_INCLUDED
  42. #define MPT3SAS_DEBUG_H_INCLUDED
  43. #define MPT_DEBUG 0x00000001
  44. #define MPT_DEBUG_MSG_FRAME 0x00000002
  45. #define MPT_DEBUG_SG 0x00000004
  46. #define MPT_DEBUG_EVENTS 0x00000008
  47. #define MPT_DEBUG_EVENT_WORK_TASK 0x00000010
  48. #define MPT_DEBUG_INIT 0x00000020
  49. #define MPT_DEBUG_EXIT 0x00000040
  50. #define MPT_DEBUG_FAIL 0x00000080
  51. #define MPT_DEBUG_TM 0x00000100
  52. #define MPT_DEBUG_REPLY 0x00000200
  53. #define MPT_DEBUG_HANDSHAKE 0x00000400
  54. #define MPT_DEBUG_CONFIG 0x00000800
  55. #define MPT_DEBUG_DL 0x00001000
  56. #define MPT_DEBUG_RESET 0x00002000
  57. #define MPT_DEBUG_SCSI 0x00004000
  58. #define MPT_DEBUG_IOCTL 0x00008000
  59. #define MPT_DEBUG_SAS 0x00020000
  60. #define MPT_DEBUG_TRANSPORT 0x00040000
  61. #define MPT_DEBUG_TASK_SET_FULL 0x00080000
  62. #define MPT_DEBUG_TRIGGER_DIAG 0x00200000
  63. /*
  64. * CONFIG_SCSI_MPT3SAS_LOGGING - enabled in Kconfig
  65. */
  66. #ifdef CONFIG_SCSI_MPT3SAS_LOGGING
  67. #define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
  68. { \
  69. if (IOC->logging_level & BITS) \
  70. CMD; \
  71. }
  72. #else
  73. #define MPT_CHECK_LOGGING(IOC, CMD, BITS)
  74. #endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
  75. /*
  76. * debug macros
  77. */
  78. #define dprintk(IOC, CMD) \
  79. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
  80. #define dsgprintk(IOC, CMD) \
  81. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
  82. #define devtprintk(IOC, CMD) \
  83. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
  84. #define dewtprintk(IOC, CMD) \
  85. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
  86. #define dinitprintk(IOC, CMD) \
  87. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
  88. #define dexitprintk(IOC, CMD) \
  89. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
  90. #define dfailprintk(IOC, CMD) \
  91. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
  92. #define dtmprintk(IOC, CMD) \
  93. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
  94. #define dreplyprintk(IOC, CMD) \
  95. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
  96. #define dhsprintk(IOC, CMD) \
  97. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
  98. #define dcprintk(IOC, CMD) \
  99. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
  100. #define ddlprintk(IOC, CMD) \
  101. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
  102. #define drsprintk(IOC, CMD) \
  103. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
  104. #define dsprintk(IOC, CMD) \
  105. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
  106. #define dctlprintk(IOC, CMD) \
  107. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
  108. #define dsasprintk(IOC, CMD) \
  109. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
  110. #define dsastransport(IOC, CMD) \
  111. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
  112. #define dmfprintk(IOC, CMD) \
  113. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
  114. #define dtsfprintk(IOC, CMD) \
  115. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL)
  116. #define dtransportprintk(IOC, CMD) \
  117. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT)
  118. #define dTriggerDiagPrintk(IOC, CMD) \
  119. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRIGGER_DIAG)
  120. /* inline functions for dumping debug data*/
  121. #ifdef CONFIG_SCSI_MPT3SAS_LOGGING
  122. /**
  123. * _debug_dump_mf - print message frame contents
  124. * @mpi_request: pointer to message frame
  125. * @sz: number of dwords
  126. */
  127. static inline void
  128. _debug_dump_mf(void *mpi_request, int sz)
  129. {
  130. int i;
  131. __le32 *mfp = (__le32 *)mpi_request;
  132. pr_info("mf:\n\t");
  133. for (i = 0; i < sz; i++) {
  134. if (i && ((i % 8) == 0))
  135. pr_info("\n\t");
  136. pr_info("%08x ", le32_to_cpu(mfp[i]));
  137. }
  138. pr_info("\n");
  139. }
  140. /**
  141. * _debug_dump_reply - print message frame contents
  142. * @mpi_request: pointer to message frame
  143. * @sz: number of dwords
  144. */
  145. static inline void
  146. _debug_dump_reply(void *mpi_request, int sz)
  147. {
  148. int i;
  149. __le32 *mfp = (__le32 *)mpi_request;
  150. pr_info("reply:\n\t");
  151. for (i = 0; i < sz; i++) {
  152. if (i && ((i % 8) == 0))
  153. pr_info("\n\t");
  154. pr_info("%08x ", le32_to_cpu(mfp[i]));
  155. }
  156. pr_info("\n");
  157. }
  158. /**
  159. * _debug_dump_config - print config page contents
  160. * @mpi_request: pointer to message frame
  161. * @sz: number of dwords
  162. */
  163. static inline void
  164. _debug_dump_config(void *mpi_request, int sz)
  165. {
  166. int i;
  167. __le32 *mfp = (__le32 *)mpi_request;
  168. pr_info("config:\n\t");
  169. for (i = 0; i < sz; i++) {
  170. if (i && ((i % 8) == 0))
  171. pr_info("\n\t");
  172. pr_info("%08x ", le32_to_cpu(mfp[i]));
  173. }
  174. pr_info("\n");
  175. }
  176. #else
  177. #define _debug_dump_mf(mpi_request, sz)
  178. #define _debug_dump_reply(mpi_request, sz)
  179. #define _debug_dump_config(mpi_request, sz)
  180. #endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
  181. #endif /* MPT3SAS_DEBUG_H_INCLUDED */