scsi.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM scsi
  3. #if !defined(_TRACE_SCSI_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_SCSI_H
  5. #include <scsi/scsi_cmnd.h>
  6. #include <scsi/scsi_host.h>
  7. #include <linux/tracepoint.h>
  8. #include <linux/trace_seq.h>
  9. #define scsi_opcode_name(opcode) { opcode, #opcode }
  10. #define show_opcode_name(val) \
  11. __print_symbolic(val, \
  12. scsi_opcode_name(TEST_UNIT_READY), \
  13. scsi_opcode_name(REZERO_UNIT), \
  14. scsi_opcode_name(REQUEST_SENSE), \
  15. scsi_opcode_name(FORMAT_UNIT), \
  16. scsi_opcode_name(READ_BLOCK_LIMITS), \
  17. scsi_opcode_name(REASSIGN_BLOCKS), \
  18. scsi_opcode_name(INITIALIZE_ELEMENT_STATUS), \
  19. scsi_opcode_name(READ_6), \
  20. scsi_opcode_name(WRITE_6), \
  21. scsi_opcode_name(SEEK_6), \
  22. scsi_opcode_name(READ_REVERSE), \
  23. scsi_opcode_name(WRITE_FILEMARKS), \
  24. scsi_opcode_name(SPACE), \
  25. scsi_opcode_name(INQUIRY), \
  26. scsi_opcode_name(RECOVER_BUFFERED_DATA), \
  27. scsi_opcode_name(MODE_SELECT), \
  28. scsi_opcode_name(RESERVE), \
  29. scsi_opcode_name(RELEASE), \
  30. scsi_opcode_name(COPY), \
  31. scsi_opcode_name(ERASE), \
  32. scsi_opcode_name(MODE_SENSE), \
  33. scsi_opcode_name(START_STOP), \
  34. scsi_opcode_name(RECEIVE_DIAGNOSTIC), \
  35. scsi_opcode_name(SEND_DIAGNOSTIC), \
  36. scsi_opcode_name(ALLOW_MEDIUM_REMOVAL), \
  37. scsi_opcode_name(SET_WINDOW), \
  38. scsi_opcode_name(READ_CAPACITY), \
  39. scsi_opcode_name(READ_10), \
  40. scsi_opcode_name(WRITE_10), \
  41. scsi_opcode_name(SEEK_10), \
  42. scsi_opcode_name(POSITION_TO_ELEMENT), \
  43. scsi_opcode_name(WRITE_VERIFY), \
  44. scsi_opcode_name(VERIFY), \
  45. scsi_opcode_name(SEARCH_HIGH), \
  46. scsi_opcode_name(SEARCH_EQUAL), \
  47. scsi_opcode_name(SEARCH_LOW), \
  48. scsi_opcode_name(SET_LIMITS), \
  49. scsi_opcode_name(PRE_FETCH), \
  50. scsi_opcode_name(READ_POSITION), \
  51. scsi_opcode_name(SYNCHRONIZE_CACHE), \
  52. scsi_opcode_name(LOCK_UNLOCK_CACHE), \
  53. scsi_opcode_name(READ_DEFECT_DATA), \
  54. scsi_opcode_name(MEDIUM_SCAN), \
  55. scsi_opcode_name(COMPARE), \
  56. scsi_opcode_name(COPY_VERIFY), \
  57. scsi_opcode_name(WRITE_BUFFER), \
  58. scsi_opcode_name(READ_BUFFER), \
  59. scsi_opcode_name(UPDATE_BLOCK), \
  60. scsi_opcode_name(READ_LONG), \
  61. scsi_opcode_name(WRITE_LONG), \
  62. scsi_opcode_name(CHANGE_DEFINITION), \
  63. scsi_opcode_name(WRITE_SAME), \
  64. scsi_opcode_name(UNMAP), \
  65. scsi_opcode_name(READ_TOC), \
  66. scsi_opcode_name(LOG_SELECT), \
  67. scsi_opcode_name(LOG_SENSE), \
  68. scsi_opcode_name(XDWRITEREAD_10), \
  69. scsi_opcode_name(MODE_SELECT_10), \
  70. scsi_opcode_name(RESERVE_10), \
  71. scsi_opcode_name(RELEASE_10), \
  72. scsi_opcode_name(MODE_SENSE_10), \
  73. scsi_opcode_name(PERSISTENT_RESERVE_IN), \
  74. scsi_opcode_name(PERSISTENT_RESERVE_OUT), \
  75. scsi_opcode_name(VARIABLE_LENGTH_CMD), \
  76. scsi_opcode_name(REPORT_LUNS), \
  77. scsi_opcode_name(MAINTENANCE_IN), \
  78. scsi_opcode_name(MAINTENANCE_OUT), \
  79. scsi_opcode_name(MOVE_MEDIUM), \
  80. scsi_opcode_name(EXCHANGE_MEDIUM), \
  81. scsi_opcode_name(READ_12), \
  82. scsi_opcode_name(WRITE_12), \
  83. scsi_opcode_name(WRITE_VERIFY_12), \
  84. scsi_opcode_name(SEARCH_HIGH_12), \
  85. scsi_opcode_name(SEARCH_EQUAL_12), \
  86. scsi_opcode_name(SEARCH_LOW_12), \
  87. scsi_opcode_name(READ_ELEMENT_STATUS), \
  88. scsi_opcode_name(SEND_VOLUME_TAG), \
  89. scsi_opcode_name(WRITE_LONG_2), \
  90. scsi_opcode_name(READ_16), \
  91. scsi_opcode_name(WRITE_16), \
  92. scsi_opcode_name(VERIFY_16), \
  93. scsi_opcode_name(WRITE_SAME_16), \
  94. scsi_opcode_name(SERVICE_ACTION_IN_16), \
  95. scsi_opcode_name(SAI_READ_CAPACITY_16), \
  96. scsi_opcode_name(SAI_GET_LBA_STATUS), \
  97. scsi_opcode_name(MI_REPORT_TARGET_PGS), \
  98. scsi_opcode_name(MO_SET_TARGET_PGS), \
  99. scsi_opcode_name(READ_32), \
  100. scsi_opcode_name(WRITE_32), \
  101. scsi_opcode_name(WRITE_SAME_32), \
  102. scsi_opcode_name(ATA_16), \
  103. scsi_opcode_name(ATA_12))
  104. #define scsi_hostbyte_name(result) { result, #result }
  105. #define show_hostbyte_name(val) \
  106. __print_symbolic(val, \
  107. scsi_hostbyte_name(DID_OK), \
  108. scsi_hostbyte_name(DID_NO_CONNECT), \
  109. scsi_hostbyte_name(DID_BUS_BUSY), \
  110. scsi_hostbyte_name(DID_TIME_OUT), \
  111. scsi_hostbyte_name(DID_BAD_TARGET), \
  112. scsi_hostbyte_name(DID_ABORT), \
  113. scsi_hostbyte_name(DID_PARITY), \
  114. scsi_hostbyte_name(DID_ERROR), \
  115. scsi_hostbyte_name(DID_RESET), \
  116. scsi_hostbyte_name(DID_BAD_INTR), \
  117. scsi_hostbyte_name(DID_PASSTHROUGH), \
  118. scsi_hostbyte_name(DID_SOFT_ERROR), \
  119. scsi_hostbyte_name(DID_IMM_RETRY), \
  120. scsi_hostbyte_name(DID_REQUEUE), \
  121. scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED), \
  122. scsi_hostbyte_name(DID_TRANSPORT_FAILFAST))
  123. #define scsi_driverbyte_name(result) { result, #result }
  124. #define show_driverbyte_name(val) \
  125. __print_symbolic(val, \
  126. scsi_driverbyte_name(DRIVER_OK), \
  127. scsi_driverbyte_name(DRIVER_BUSY), \
  128. scsi_driverbyte_name(DRIVER_SOFT), \
  129. scsi_driverbyte_name(DRIVER_MEDIA), \
  130. scsi_driverbyte_name(DRIVER_ERROR), \
  131. scsi_driverbyte_name(DRIVER_INVALID), \
  132. scsi_driverbyte_name(DRIVER_TIMEOUT), \
  133. scsi_driverbyte_name(DRIVER_HARD), \
  134. scsi_driverbyte_name(DRIVER_SENSE))
  135. #define scsi_msgbyte_name(result) { result, #result }
  136. #define show_msgbyte_name(val) \
  137. __print_symbolic(val, \
  138. scsi_msgbyte_name(COMMAND_COMPLETE), \
  139. scsi_msgbyte_name(EXTENDED_MESSAGE), \
  140. scsi_msgbyte_name(SAVE_POINTERS), \
  141. scsi_msgbyte_name(RESTORE_POINTERS), \
  142. scsi_msgbyte_name(DISCONNECT), \
  143. scsi_msgbyte_name(INITIATOR_ERROR), \
  144. scsi_msgbyte_name(ABORT_TASK_SET), \
  145. scsi_msgbyte_name(MESSAGE_REJECT), \
  146. scsi_msgbyte_name(NOP), \
  147. scsi_msgbyte_name(MSG_PARITY_ERROR), \
  148. scsi_msgbyte_name(LINKED_CMD_COMPLETE), \
  149. scsi_msgbyte_name(LINKED_FLG_CMD_COMPLETE), \
  150. scsi_msgbyte_name(TARGET_RESET), \
  151. scsi_msgbyte_name(ABORT_TASK), \
  152. scsi_msgbyte_name(CLEAR_TASK_SET), \
  153. scsi_msgbyte_name(INITIATE_RECOVERY), \
  154. scsi_msgbyte_name(RELEASE_RECOVERY), \
  155. scsi_msgbyte_name(CLEAR_ACA), \
  156. scsi_msgbyte_name(LOGICAL_UNIT_RESET), \
  157. scsi_msgbyte_name(SIMPLE_QUEUE_TAG), \
  158. scsi_msgbyte_name(HEAD_OF_QUEUE_TAG), \
  159. scsi_msgbyte_name(ORDERED_QUEUE_TAG), \
  160. scsi_msgbyte_name(IGNORE_WIDE_RESIDUE), \
  161. scsi_msgbyte_name(ACA), \
  162. scsi_msgbyte_name(QAS_REQUEST), \
  163. scsi_msgbyte_name(BUS_DEVICE_RESET), \
  164. scsi_msgbyte_name(ABORT))
  165. #define scsi_statusbyte_name(result) { result, #result }
  166. #define show_statusbyte_name(val) \
  167. __print_symbolic(val, \
  168. scsi_statusbyte_name(SAM_STAT_GOOD), \
  169. scsi_statusbyte_name(SAM_STAT_CHECK_CONDITION), \
  170. scsi_statusbyte_name(SAM_STAT_CONDITION_MET), \
  171. scsi_statusbyte_name(SAM_STAT_BUSY), \
  172. scsi_statusbyte_name(SAM_STAT_INTERMEDIATE), \
  173. scsi_statusbyte_name(SAM_STAT_INTERMEDIATE_CONDITION_MET), \
  174. scsi_statusbyte_name(SAM_STAT_RESERVATION_CONFLICT), \
  175. scsi_statusbyte_name(SAM_STAT_COMMAND_TERMINATED), \
  176. scsi_statusbyte_name(SAM_STAT_TASK_SET_FULL), \
  177. scsi_statusbyte_name(SAM_STAT_ACA_ACTIVE), \
  178. scsi_statusbyte_name(SAM_STAT_TASK_ABORTED))
  179. #define scsi_prot_op_name(result) { result, #result }
  180. #define show_prot_op_name(val) \
  181. __print_symbolic(val, \
  182. scsi_prot_op_name(SCSI_PROT_NORMAL), \
  183. scsi_prot_op_name(SCSI_PROT_READ_INSERT), \
  184. scsi_prot_op_name(SCSI_PROT_WRITE_STRIP), \
  185. scsi_prot_op_name(SCSI_PROT_READ_STRIP), \
  186. scsi_prot_op_name(SCSI_PROT_WRITE_INSERT), \
  187. scsi_prot_op_name(SCSI_PROT_READ_PASS), \
  188. scsi_prot_op_name(SCSI_PROT_WRITE_PASS))
  189. const char *scsi_trace_parse_cdb(struct trace_seq*, unsigned char*, int);
  190. #define __parse_cdb(cdb, len) scsi_trace_parse_cdb(p, cdb, len)
  191. TRACE_EVENT(scsi_dispatch_cmd_start,
  192. TP_PROTO(struct scsi_cmnd *cmd),
  193. TP_ARGS(cmd),
  194. TP_STRUCT__entry(
  195. __field( unsigned int, host_no )
  196. __field( unsigned int, channel )
  197. __field( unsigned int, id )
  198. __field( unsigned int, lun )
  199. __field( unsigned int, opcode )
  200. __field( unsigned int, cmd_len )
  201. __field( unsigned int, data_sglen )
  202. __field( unsigned int, prot_sglen )
  203. __field( unsigned char, prot_op )
  204. __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
  205. ),
  206. TP_fast_assign(
  207. __entry->host_no = cmd->device->host->host_no;
  208. __entry->channel = cmd->device->channel;
  209. __entry->id = cmd->device->id;
  210. __entry->lun = cmd->device->lun;
  211. __entry->opcode = cmd->cmnd[0];
  212. __entry->cmd_len = cmd->cmd_len;
  213. __entry->data_sglen = scsi_sg_count(cmd);
  214. __entry->prot_sglen = scsi_prot_sg_count(cmd);
  215. __entry->prot_op = scsi_get_prot_op(cmd);
  216. memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
  217. ),
  218. TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
  219. " prot_op=%s cmnd=(%s %s raw=%s)",
  220. __entry->host_no, __entry->channel, __entry->id,
  221. __entry->lun, __entry->data_sglen, __entry->prot_sglen,
  222. show_prot_op_name(__entry->prot_op),
  223. show_opcode_name(__entry->opcode),
  224. __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
  225. __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len))
  226. );
  227. TRACE_EVENT(scsi_dispatch_cmd_error,
  228. TP_PROTO(struct scsi_cmnd *cmd, int rtn),
  229. TP_ARGS(cmd, rtn),
  230. TP_STRUCT__entry(
  231. __field( unsigned int, host_no )
  232. __field( unsigned int, channel )
  233. __field( unsigned int, id )
  234. __field( unsigned int, lun )
  235. __field( int, rtn )
  236. __field( unsigned int, opcode )
  237. __field( unsigned int, cmd_len )
  238. __field( unsigned int, data_sglen )
  239. __field( unsigned int, prot_sglen )
  240. __field( unsigned char, prot_op )
  241. __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
  242. ),
  243. TP_fast_assign(
  244. __entry->host_no = cmd->device->host->host_no;
  245. __entry->channel = cmd->device->channel;
  246. __entry->id = cmd->device->id;
  247. __entry->lun = cmd->device->lun;
  248. __entry->rtn = rtn;
  249. __entry->opcode = cmd->cmnd[0];
  250. __entry->cmd_len = cmd->cmd_len;
  251. __entry->data_sglen = scsi_sg_count(cmd);
  252. __entry->prot_sglen = scsi_prot_sg_count(cmd);
  253. __entry->prot_op = scsi_get_prot_op(cmd);
  254. memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
  255. ),
  256. TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
  257. " prot_op=%s cmnd=(%s %s raw=%s) rtn=%d",
  258. __entry->host_no, __entry->channel, __entry->id,
  259. __entry->lun, __entry->data_sglen, __entry->prot_sglen,
  260. show_prot_op_name(__entry->prot_op),
  261. show_opcode_name(__entry->opcode),
  262. __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
  263. __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
  264. __entry->rtn)
  265. );
  266. DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
  267. TP_PROTO(struct scsi_cmnd *cmd),
  268. TP_ARGS(cmd),
  269. TP_STRUCT__entry(
  270. __field( unsigned int, host_no )
  271. __field( unsigned int, channel )
  272. __field( unsigned int, id )
  273. __field( unsigned int, lun )
  274. __field( int, result )
  275. __field( unsigned int, opcode )
  276. __field( unsigned int, cmd_len )
  277. __field( unsigned int, data_sglen )
  278. __field( unsigned int, prot_sglen )
  279. __field( unsigned char, prot_op )
  280. __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
  281. ),
  282. TP_fast_assign(
  283. __entry->host_no = cmd->device->host->host_no;
  284. __entry->channel = cmd->device->channel;
  285. __entry->id = cmd->device->id;
  286. __entry->lun = cmd->device->lun;
  287. __entry->result = cmd->result;
  288. __entry->opcode = cmd->cmnd[0];
  289. __entry->cmd_len = cmd->cmd_len;
  290. __entry->data_sglen = scsi_sg_count(cmd);
  291. __entry->prot_sglen = scsi_prot_sg_count(cmd);
  292. __entry->prot_op = scsi_get_prot_op(cmd);
  293. memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
  294. ),
  295. TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \
  296. "prot_sgl=%u prot_op=%s cmnd=(%s %s raw=%s) result=(driver=" \
  297. "%s host=%s message=%s status=%s)",
  298. __entry->host_no, __entry->channel, __entry->id,
  299. __entry->lun, __entry->data_sglen, __entry->prot_sglen,
  300. show_prot_op_name(__entry->prot_op),
  301. show_opcode_name(__entry->opcode),
  302. __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
  303. __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
  304. show_driverbyte_name(((__entry->result) >> 24) & 0xff),
  305. show_hostbyte_name(((__entry->result) >> 16) & 0xff),
  306. show_msgbyte_name(((__entry->result) >> 8) & 0xff),
  307. show_statusbyte_name(__entry->result & 0xff))
  308. );
  309. DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done,
  310. TP_PROTO(struct scsi_cmnd *cmd),
  311. TP_ARGS(cmd));
  312. DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_timeout,
  313. TP_PROTO(struct scsi_cmnd *cmd),
  314. TP_ARGS(cmd));
  315. TRACE_EVENT(scsi_eh_wakeup,
  316. TP_PROTO(struct Scsi_Host *shost),
  317. TP_ARGS(shost),
  318. TP_STRUCT__entry(
  319. __field( unsigned int, host_no )
  320. ),
  321. TP_fast_assign(
  322. __entry->host_no = shost->host_no;
  323. ),
  324. TP_printk("host_no=%u", __entry->host_no)
  325. );
  326. #endif /* _TRACE_SCSI_H */
  327. /* This part must be outside protection */
  328. #include <trace/define_trace.h>