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