target.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM target
  3. #if !defined(_TRACE_TARGET_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_TARGET_H
  5. #include <linux/tracepoint.h>
  6. #include <linux/trace_seq.h>
  7. #include <scsi/scsi_proto.h>
  8. #include <scsi/scsi_tcq.h>
  9. #include <target/target_core_base.h>
  10. /* cribbed verbatim from <trace/event/scsi.h> */
  11. #define scsi_opcode_name(opcode) { opcode, #opcode }
  12. #define show_opcode_name(val) \
  13. __print_symbolic(val, \
  14. scsi_opcode_name(TEST_UNIT_READY), \
  15. scsi_opcode_name(REZERO_UNIT), \
  16. scsi_opcode_name(REQUEST_SENSE), \
  17. scsi_opcode_name(FORMAT_UNIT), \
  18. scsi_opcode_name(READ_BLOCK_LIMITS), \
  19. scsi_opcode_name(REASSIGN_BLOCKS), \
  20. scsi_opcode_name(INITIALIZE_ELEMENT_STATUS), \
  21. scsi_opcode_name(READ_6), \
  22. scsi_opcode_name(WRITE_6), \
  23. scsi_opcode_name(SEEK_6), \
  24. scsi_opcode_name(READ_REVERSE), \
  25. scsi_opcode_name(WRITE_FILEMARKS), \
  26. scsi_opcode_name(SPACE), \
  27. scsi_opcode_name(INQUIRY), \
  28. scsi_opcode_name(RECOVER_BUFFERED_DATA), \
  29. scsi_opcode_name(MODE_SELECT), \
  30. scsi_opcode_name(RESERVE), \
  31. scsi_opcode_name(RELEASE), \
  32. scsi_opcode_name(COPY), \
  33. scsi_opcode_name(ERASE), \
  34. scsi_opcode_name(MODE_SENSE), \
  35. scsi_opcode_name(START_STOP), \
  36. scsi_opcode_name(RECEIVE_DIAGNOSTIC), \
  37. scsi_opcode_name(SEND_DIAGNOSTIC), \
  38. scsi_opcode_name(ALLOW_MEDIUM_REMOVAL), \
  39. scsi_opcode_name(SET_WINDOW), \
  40. scsi_opcode_name(READ_CAPACITY), \
  41. scsi_opcode_name(READ_10), \
  42. scsi_opcode_name(WRITE_10), \
  43. scsi_opcode_name(SEEK_10), \
  44. scsi_opcode_name(POSITION_TO_ELEMENT), \
  45. scsi_opcode_name(WRITE_VERIFY), \
  46. scsi_opcode_name(VERIFY), \
  47. scsi_opcode_name(SEARCH_HIGH), \
  48. scsi_opcode_name(SEARCH_EQUAL), \
  49. scsi_opcode_name(SEARCH_LOW), \
  50. scsi_opcode_name(SET_LIMITS), \
  51. scsi_opcode_name(PRE_FETCH), \
  52. scsi_opcode_name(READ_POSITION), \
  53. scsi_opcode_name(SYNCHRONIZE_CACHE), \
  54. scsi_opcode_name(LOCK_UNLOCK_CACHE), \
  55. scsi_opcode_name(READ_DEFECT_DATA), \
  56. scsi_opcode_name(MEDIUM_SCAN), \
  57. scsi_opcode_name(COMPARE), \
  58. scsi_opcode_name(COPY_VERIFY), \
  59. scsi_opcode_name(WRITE_BUFFER), \
  60. scsi_opcode_name(READ_BUFFER), \
  61. scsi_opcode_name(UPDATE_BLOCK), \
  62. scsi_opcode_name(READ_LONG), \
  63. scsi_opcode_name(WRITE_LONG), \
  64. scsi_opcode_name(CHANGE_DEFINITION), \
  65. scsi_opcode_name(WRITE_SAME), \
  66. scsi_opcode_name(UNMAP), \
  67. scsi_opcode_name(READ_TOC), \
  68. scsi_opcode_name(LOG_SELECT), \
  69. scsi_opcode_name(LOG_SENSE), \
  70. scsi_opcode_name(XDWRITEREAD_10), \
  71. scsi_opcode_name(MODE_SELECT_10), \
  72. scsi_opcode_name(RESERVE_10), \
  73. scsi_opcode_name(RELEASE_10), \
  74. scsi_opcode_name(MODE_SENSE_10), \
  75. scsi_opcode_name(PERSISTENT_RESERVE_IN), \
  76. scsi_opcode_name(PERSISTENT_RESERVE_OUT), \
  77. scsi_opcode_name(VARIABLE_LENGTH_CMD), \
  78. scsi_opcode_name(REPORT_LUNS), \
  79. scsi_opcode_name(MAINTENANCE_IN), \
  80. scsi_opcode_name(MAINTENANCE_OUT), \
  81. scsi_opcode_name(MOVE_MEDIUM), \
  82. scsi_opcode_name(EXCHANGE_MEDIUM), \
  83. scsi_opcode_name(READ_12), \
  84. scsi_opcode_name(WRITE_12), \
  85. scsi_opcode_name(WRITE_VERIFY_12), \
  86. scsi_opcode_name(SEARCH_HIGH_12), \
  87. scsi_opcode_name(SEARCH_EQUAL_12), \
  88. scsi_opcode_name(SEARCH_LOW_12), \
  89. scsi_opcode_name(READ_ELEMENT_STATUS), \
  90. scsi_opcode_name(SEND_VOLUME_TAG), \
  91. scsi_opcode_name(WRITE_LONG_2), \
  92. scsi_opcode_name(READ_16), \
  93. scsi_opcode_name(WRITE_16), \
  94. scsi_opcode_name(VERIFY_16), \
  95. scsi_opcode_name(WRITE_SAME_16), \
  96. scsi_opcode_name(SERVICE_ACTION_IN_16), \
  97. scsi_opcode_name(SAI_READ_CAPACITY_16), \
  98. scsi_opcode_name(SAI_GET_LBA_STATUS), \
  99. scsi_opcode_name(MI_REPORT_TARGET_PGS), \
  100. scsi_opcode_name(MO_SET_TARGET_PGS), \
  101. scsi_opcode_name(READ_32), \
  102. scsi_opcode_name(WRITE_32), \
  103. scsi_opcode_name(WRITE_SAME_32), \
  104. scsi_opcode_name(ATA_16), \
  105. scsi_opcode_name(ATA_12))
  106. #define show_task_attribute_name(val) \
  107. __print_symbolic(val, \
  108. { TCM_SIMPLE_TAG, "SIMPLE" }, \
  109. { TCM_HEAD_TAG, "HEAD" }, \
  110. { TCM_ORDERED_TAG, "ORDERED" }, \
  111. { TCM_ACA_TAG, "ACA" } )
  112. #define show_scsi_status_name(val) \
  113. __print_symbolic(val, \
  114. { SAM_STAT_GOOD, "GOOD" }, \
  115. { SAM_STAT_CHECK_CONDITION, "CHECK CONDITION" }, \
  116. { SAM_STAT_CONDITION_MET, "CONDITION MET" }, \
  117. { SAM_STAT_BUSY, "BUSY" }, \
  118. { SAM_STAT_INTERMEDIATE, "INTERMEDIATE" }, \
  119. { SAM_STAT_INTERMEDIATE_CONDITION_MET, "INTERMEDIATE CONDITION MET" }, \
  120. { SAM_STAT_RESERVATION_CONFLICT, "RESERVATION CONFLICT" }, \
  121. { SAM_STAT_COMMAND_TERMINATED, "COMMAND TERMINATED" }, \
  122. { SAM_STAT_TASK_SET_FULL, "TASK SET FULL" }, \
  123. { SAM_STAT_ACA_ACTIVE, "ACA ACTIVE" }, \
  124. { SAM_STAT_TASK_ABORTED, "TASK ABORTED" } )
  125. TRACE_EVENT(target_sequencer_start,
  126. TP_PROTO(struct se_cmd *cmd),
  127. TP_ARGS(cmd),
  128. TP_STRUCT__entry(
  129. __field( unsigned int, unpacked_lun )
  130. __field( unsigned int, opcode )
  131. __field( unsigned int, data_length )
  132. __field( unsigned int, task_attribute )
  133. __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE )
  134. __string( initiator, cmd->se_sess->se_node_acl->initiatorname )
  135. ),
  136. TP_fast_assign(
  137. __entry->unpacked_lun = cmd->orig_fe_lun;
  138. __entry->opcode = cmd->t_task_cdb[0];
  139. __entry->data_length = cmd->data_length;
  140. __entry->task_attribute = cmd->sam_task_attr;
  141. memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE);
  142. __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname);
  143. ),
  144. TP_printk("%s -> LUN %03u %s data_length %6u CDB %s (TA:%s C:%02x)",
  145. __get_str(initiator), __entry->unpacked_lun,
  146. show_opcode_name(__entry->opcode),
  147. __entry->data_length, __print_hex(__entry->cdb, 16),
  148. show_task_attribute_name(__entry->task_attribute),
  149. scsi_command_size(__entry->cdb) <= 16 ?
  150. __entry->cdb[scsi_command_size(__entry->cdb) - 1] :
  151. __entry->cdb[1]
  152. )
  153. );
  154. TRACE_EVENT(target_cmd_complete,
  155. TP_PROTO(struct se_cmd *cmd),
  156. TP_ARGS(cmd),
  157. TP_STRUCT__entry(
  158. __field( unsigned int, unpacked_lun )
  159. __field( unsigned int, opcode )
  160. __field( unsigned int, data_length )
  161. __field( unsigned int, task_attribute )
  162. __field( unsigned char, scsi_status )
  163. __field( unsigned char, sense_length )
  164. __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE )
  165. __array( unsigned char, sense_data, 18 )
  166. __string(initiator, cmd->se_sess->se_node_acl->initiatorname)
  167. ),
  168. TP_fast_assign(
  169. __entry->unpacked_lun = cmd->orig_fe_lun;
  170. __entry->opcode = cmd->t_task_cdb[0];
  171. __entry->data_length = cmd->data_length;
  172. __entry->task_attribute = cmd->sam_task_attr;
  173. __entry->scsi_status = cmd->scsi_status;
  174. __entry->sense_length = cmd->scsi_status == SAM_STAT_CHECK_CONDITION ?
  175. min(18, ((u8 *) cmd->sense_buffer)[SPC_ADD_SENSE_LEN_OFFSET] + 8) : 0;
  176. memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE);
  177. memcpy(__entry->sense_data, cmd->sense_buffer, __entry->sense_length);
  178. __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname);
  179. ),
  180. TP_printk("%s <- LUN %03u status %s (sense len %d%s%s) %s data_length %6u CDB %s (TA:%s C:%02x)",
  181. __get_str(initiator), __entry->unpacked_lun,
  182. show_scsi_status_name(__entry->scsi_status),
  183. __entry->sense_length, __entry->sense_length ? " / " : "",
  184. __print_hex(__entry->sense_data, __entry->sense_length),
  185. show_opcode_name(__entry->opcode),
  186. __entry->data_length, __print_hex(__entry->cdb, 16),
  187. show_task_attribute_name(__entry->task_attribute),
  188. scsi_command_size(__entry->cdb) <= 16 ?
  189. __entry->cdb[scsi_command_size(__entry->cdb) - 1] :
  190. __entry->cdb[1]
  191. )
  192. );
  193. #endif /* _TRACE_TARGET_H */
  194. /* This part must be outside protection */
  195. #include <trace/define_trace.h>