mptdebug.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * linux/drivers/message/fusion/mptdebug.h
  4. * For use with LSI PCI chip/adapter(s)
  5. * running LSI Fusion MPT (Message Passing Technology) firmware.
  6. *
  7. * Copyright (c) 1999-2008 LSI Corporation
  8. * (mailto:DL-MPTFusionLinux@lsi.com)
  9. *
  10. */
  11. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  12. #ifndef MPTDEBUG_H_INCLUDED
  13. #define MPTDEBUG_H_INCLUDED
  14. /*
  15. * debug level can be programmed on the fly via SysFS (hex values)
  16. *
  17. * Example: (programming for MPT_DEBUG_EVENTS on host 5)
  18. *
  19. * echo 8 > /sys/class/scsi_host/host5/debug_level
  20. *
  21. * --------------------------------------------------------
  22. * mpt_debug_level - command line parameter
  23. * this allow enabling debug at driver load time (for all iocs)
  24. *
  25. * Example (programming for MPT_DEBUG_EVENTS)
  26. *
  27. * insmod mptbase.ko mpt_debug_level=8
  28. *
  29. * --------------------------------------------------------
  30. * CONFIG_FUSION_LOGGING - enables compiling debug into driver
  31. * this can be enabled in the driver Makefile
  32. *
  33. *
  34. * --------------------------------------------------------
  35. * Please note most debug prints are set to logging priority = debug
  36. * This is the lowest level, and most verbose. Please refer to manual
  37. * pages for syslogd or syslogd-ng on how to configure this.
  38. */
  39. #define MPT_DEBUG 0x00000001
  40. #define MPT_DEBUG_MSG_FRAME 0x00000002
  41. #define MPT_DEBUG_SG 0x00000004
  42. #define MPT_DEBUG_EVENTS 0x00000008
  43. #define MPT_DEBUG_VERBOSE_EVENTS 0x00000010
  44. #define MPT_DEBUG_INIT 0x00000020
  45. #define MPT_DEBUG_EXIT 0x00000040
  46. #define MPT_DEBUG_FAIL 0x00000080
  47. #define MPT_DEBUG_TM 0x00000100
  48. #define MPT_DEBUG_DV 0x00000200
  49. #define MPT_DEBUG_REPLY 0x00000400
  50. #define MPT_DEBUG_HANDSHAKE 0x00000800
  51. #define MPT_DEBUG_CONFIG 0x00001000
  52. #define MPT_DEBUG_DL 0x00002000
  53. #define MPT_DEBUG_RESET 0x00008000
  54. #define MPT_DEBUG_SCSI 0x00010000
  55. #define MPT_DEBUG_IOCTL 0x00020000
  56. #define MPT_DEBUG_FC 0x00080000
  57. #define MPT_DEBUG_SAS 0x00100000
  58. #define MPT_DEBUG_SAS_WIDE 0x00200000
  59. #define MPT_DEBUG_36GB_MEM 0x00400000
  60. /*
  61. * CONFIG_FUSION_LOGGING - enabled in Kconfig
  62. */
  63. #ifdef CONFIG_FUSION_LOGGING
  64. #define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
  65. { \
  66. if (IOC->debug_level & BITS) \
  67. CMD; \
  68. }
  69. #else
  70. #define MPT_CHECK_LOGGING(IOC, CMD, BITS)
  71. #endif
  72. /*
  73. * debug macros
  74. */
  75. #define dprintk(IOC, CMD) \
  76. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
  77. #define dsgprintk(IOC, CMD) \
  78. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
  79. #define devtprintk(IOC, CMD) \
  80. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
  81. #define devtverboseprintk(IOC, CMD) \
  82. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS)
  83. #define dinitprintk(IOC, CMD) \
  84. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
  85. #define dexitprintk(IOC, CMD) \
  86. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
  87. #define dfailprintk(IOC, CMD) \
  88. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
  89. #define dtmprintk(IOC, CMD) \
  90. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
  91. #define ddvprintk(IOC, CMD) \
  92. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV)
  93. #define dreplyprintk(IOC, CMD) \
  94. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
  95. #define dhsprintk(IOC, CMD) \
  96. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
  97. #define dcprintk(IOC, CMD) \
  98. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
  99. #define ddlprintk(IOC, CMD) \
  100. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
  101. #define drsprintk(IOC, CMD) \
  102. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
  103. #define dsprintk(IOC, CMD) \
  104. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
  105. #define dctlprintk(IOC, CMD) \
  106. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
  107. #define dfcprintk(IOC, CMD) \
  108. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC)
  109. #define dsasprintk(IOC, CMD) \
  110. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
  111. #define dsaswideprintk(IOC, CMD) \
  112. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
  113. #define d36memprintk(IOC, CMD) \
  114. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_36GB_MEM)
  115. /*
  116. * Verbose logging
  117. */
  118. #if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING)
  119. static inline void
  120. DBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32 *mfp, int numfrags)
  121. {
  122. int i;
  123. if (!(ioc->debug_level & MPT_DEBUG))
  124. return;
  125. printk(KERN_DEBUG "F/W download request:\n");
  126. for (i=0; i < 7+numfrags*2; i++)
  127. printk(" %08x", le32_to_cpu(mfp[i]));
  128. printk("\n");
  129. }
  130. static inline void
  131. DBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  132. {
  133. int ii, n;
  134. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  135. return;
  136. printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n",
  137. ioc->name, mfp);
  138. n = ioc->req_sz/4 - 1;
  139. while (mfp[n] == 0)
  140. n--;
  141. for (ii=0; ii<=n; ii++) {
  142. if (ii && ((ii%8)==0))
  143. printk("\n");
  144. printk(" %08x", le32_to_cpu(mfp[ii]));
  145. }
  146. printk("\n");
  147. }
  148. static inline void
  149. DBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  150. {
  151. int i, n;
  152. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  153. return;
  154. n = 10;
  155. printk(KERN_INFO " ");
  156. for (i = 0; i < n; i++)
  157. printk(" %08x", le32_to_cpu(mfp[i]));
  158. printk("\n");
  159. }
  160. static inline void
  161. DBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  162. {
  163. int i, n;
  164. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  165. return;
  166. n = 24;
  167. for (i=0; i<n; i++) {
  168. if (i && ((i%8)==0))
  169. printk("\n");
  170. printk("%08x ", le32_to_cpu(mfp[i]));
  171. }
  172. printk("\n");
  173. }
  174. static inline void
  175. DBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  176. {
  177. int i, n;
  178. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  179. return;
  180. n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
  181. printk(KERN_INFO " ");
  182. for (i=0; i<n; i++)
  183. printk(" %08x", le32_to_cpu(mfp[i]));
  184. printk("\n");
  185. }
  186. static inline void
  187. DBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp)
  188. {
  189. int i, n;
  190. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  191. return;
  192. n = 3;
  193. printk(KERN_INFO " ");
  194. for (i=0; i<n; i++)
  195. printk(" %08x", le32_to_cpu(mfp[i]));
  196. printk("\n");
  197. }
  198. static inline void
  199. DBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  200. {
  201. int i, n;
  202. if (!(ioc->debug_level & MPT_DEBUG_TM))
  203. return;
  204. n = 13;
  205. printk(KERN_DEBUG "TM_REQUEST:\n");
  206. for (i=0; i<n; i++) {
  207. if (i && ((i%8)==0))
  208. printk("\n");
  209. printk("%08x ", le32_to_cpu(mfp[i]));
  210. }
  211. printk("\n");
  212. }
  213. static inline void
  214. DBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  215. {
  216. int i, n;
  217. if (!(ioc->debug_level & MPT_DEBUG_TM))
  218. return;
  219. n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
  220. printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n);
  221. for (i=0; i<n; i++) {
  222. if (i && ((i%8)==0))
  223. printk("\n");
  224. printk(" %08x", le32_to_cpu(mfp[i]));
  225. }
  226. printk("\n");
  227. }
  228. #define dmfprintk(IOC, CMD) \
  229. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
  230. # else /* ifdef MPT_DEBUG_MF */
  231. #define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags)
  232. #define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp)
  233. #define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp)
  234. #define DBG_DUMP_REQUEST_FRAME(IOC, mfp)
  235. #define DBG_DUMP_REPLY_FRAME(IOC, mfp)
  236. #define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp)
  237. #define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp)
  238. #define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp)
  239. #define dmfprintk(IOC, CMD) \
  240. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
  241. #endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */
  242. #endif /* ifndef MPTDEBUG_H_INCLUDED */