mptdebug.h 7.0 KB

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