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