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