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