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