aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_trace.c123
-rw-r--r--include/trace/events/scsi.h33
2 files changed, 136 insertions, 20 deletions
diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c
index 9a3342a2fa36..b587289cfacb 100644
--- a/drivers/scsi/scsi_trace.c
+++ b/drivers/scsi/scsi_trace.c
@@ -19,7 +19,8 @@
19#include <linux/trace_seq.h> 19#include <linux/trace_seq.h>
20#include <trace/events/scsi.h> 20#include <trace/events/scsi.h>
21 21
22#define SERVICE_ACTION(cdb) ((cdb[8] << 8) | cdb[9]) 22#define SERVICE_ACTION16(cdb) (cdb[1] & 0x1f)
23#define SERVICE_ACTION32(cdb) ((cdb[8] << 8) | cdb[9])
23 24
24static const char * 25static const char *
25scsi_trace_misc(struct trace_seq *, unsigned char *, int); 26scsi_trace_misc(struct trace_seq *, unsigned char *, int);
@@ -55,8 +56,9 @@ scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
55 txlen |= (cdb[7] << 8); 56 txlen |= (cdb[7] << 8);
56 txlen |= cdb[8]; 57 txlen |= cdb[8];
57 58
58 trace_seq_printf(p, "lba=%llu txlen=%llu", 59 trace_seq_printf(p, "lba=%llu txlen=%llu protect=%u",
59 (unsigned long long)lba, (unsigned long long)txlen); 60 (unsigned long long)lba, (unsigned long long)txlen,
61 cdb[1] >> 5);
60 trace_seq_putc(p, 0); 62 trace_seq_putc(p, 0);
61 63
62 return ret; 64 return ret;
@@ -77,8 +79,9 @@ scsi_trace_rw12(struct trace_seq *p, unsigned char *cdb, int len)
77 txlen |= (cdb[8] << 8); 79 txlen |= (cdb[8] << 8);
78 txlen |= cdb[9]; 80 txlen |= cdb[9];
79 81
80 trace_seq_printf(p, "lba=%llu txlen=%llu", 82 trace_seq_printf(p, "lba=%llu txlen=%llu protect=%u",
81 (unsigned long long)lba, (unsigned long long)txlen); 83 (unsigned long long)lba, (unsigned long long)txlen,
84 cdb[1] >> 5);
82 trace_seq_putc(p, 0); 85 trace_seq_putc(p, 0);
83 86
84 return ret; 87 return ret;
@@ -103,8 +106,13 @@ scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
103 txlen |= (cdb[12] << 8); 106 txlen |= (cdb[12] << 8);
104 txlen |= cdb[13]; 107 txlen |= cdb[13];
105 108
106 trace_seq_printf(p, "lba=%llu txlen=%llu", 109 trace_seq_printf(p, "lba=%llu txlen=%llu protect=%u",
107 (unsigned long long)lba, (unsigned long long)txlen); 110 (unsigned long long)lba, (unsigned long long)txlen,
111 cdb[1] >> 5);
112
113 if (cdb[0] == WRITE_SAME_16)
114 trace_seq_printf(p, " unmap=%u", cdb[1] >> 3 & 1);
115
108 trace_seq_putc(p, 0); 116 trace_seq_putc(p, 0);
109 117
110 return ret; 118 return ret;
@@ -113,8 +121,27 @@ scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
113static const char * 121static const char *
114scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len) 122scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
115{ 123{
116 const char *ret = p->buffer + p->len; 124 const char *ret = p->buffer + p->len, *cmd;
117 sector_t lba = 0, txlen = 0; 125 sector_t lba = 0, txlen = 0;
126 u32 ei_lbrt = 0;
127
128 switch (SERVICE_ACTION32(cdb)) {
129 case READ_32:
130 cmd = "READ";
131 break;
132 case VERIFY_32:
133 cmd = "VERIFY";
134 break;
135 case WRITE_32:
136 cmd = "WRITE";
137 break;
138 case WRITE_SAME_32:
139 cmd = "WRITE_SAME";
140 break;
141 default:
142 trace_seq_printf(p, "UNKNOWN");
143 goto out;
144 }
118 145
119 lba |= ((u64)cdb[12] << 56); 146 lba |= ((u64)cdb[12] << 56);
120 lba |= ((u64)cdb[13] << 48); 147 lba |= ((u64)cdb[13] << 48);
@@ -124,15 +151,76 @@ scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
124 lba |= (cdb[17] << 16); 151 lba |= (cdb[17] << 16);
125 lba |= (cdb[18] << 8); 152 lba |= (cdb[18] << 8);
126 lba |= cdb[19]; 153 lba |= cdb[19];
154 ei_lbrt |= (cdb[20] << 24);
155 ei_lbrt |= (cdb[21] << 16);
156 ei_lbrt |= (cdb[22] << 8);
157 ei_lbrt |= cdb[23];
127 txlen |= (cdb[28] << 24); 158 txlen |= (cdb[28] << 24);
128 txlen |= (cdb[29] << 16); 159 txlen |= (cdb[29] << 16);
129 txlen |= (cdb[30] << 8); 160 txlen |= (cdb[30] << 8);
130 txlen |= cdb[31]; 161 txlen |= cdb[31];
131 162
132 trace_seq_printf(p, "%s_32 lba=%llu txlen=%llu", 163 trace_seq_printf(p, "%s_32 lba=%llu txlen=%llu protect=%u ei_lbrt=%u",
133 (SERVICE_ACTION(cdb) == READ_32 ? "READ" : "WRITE"), 164 cmd, (unsigned long long)lba,
134 (unsigned long long)lba, (unsigned long long)txlen); 165 (unsigned long long)txlen, cdb[10] >> 5, ei_lbrt);
166
167 if (SERVICE_ACTION32(cdb) == WRITE_SAME_32)
168 trace_seq_printf(p, " unmap=%u", cdb[10] >> 3 & 1);
169
170out:
171 trace_seq_putc(p, 0);
172
173 return ret;
174}
175
176static const char *
177scsi_trace_unmap(struct trace_seq *p, unsigned char *cdb, int len)
178{
179 const char *ret = p->buffer + p->len;
180 unsigned int regions = cdb[7] << 8 | cdb[8];
181
182 trace_seq_printf(p, "regions=%u", (regions - 8) / 16);
183 trace_seq_putc(p, 0);
184
185 return ret;
186}
187
188static const char *
189scsi_trace_service_action_in(struct trace_seq *p, unsigned char *cdb, int len)
190{
191 const char *ret = p->buffer + p->len, *cmd;
192 sector_t lba = 0;
193 u32 alloc_len = 0;
194
195 switch (SERVICE_ACTION16(cdb)) {
196 case SAI_READ_CAPACITY_16:
197 cmd = "READ_CAPACITY_16";
198 break;
199 case SAI_GET_LBA_STATUS:
200 cmd = "GET_LBA_STATUS";
201 break;
202 default:
203 trace_seq_printf(p, "UNKNOWN");
204 goto out;
205 }
206
207 lba |= ((u64)cdb[2] << 56);
208 lba |= ((u64)cdb[3] << 48);
209 lba |= ((u64)cdb[4] << 40);
210 lba |= ((u64)cdb[5] << 32);
211 lba |= (cdb[6] << 24);
212 lba |= (cdb[7] << 16);
213 lba |= (cdb[8] << 8);
214 lba |= cdb[9];
215 alloc_len |= (cdb[10] << 24);
216 alloc_len |= (cdb[11] << 16);
217 alloc_len |= (cdb[12] << 8);
218 alloc_len |= cdb[13];
219
220 trace_seq_printf(p, "%s lba=%llu alloc_len=%u", cmd,
221 (unsigned long long)lba, alloc_len);
135 222
223out:
136 trace_seq_putc(p, 0); 224 trace_seq_putc(p, 0);
137 225
138 return ret; 226 return ret;
@@ -141,9 +229,11 @@ scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
141static const char * 229static const char *
142scsi_trace_varlen(struct trace_seq *p, unsigned char *cdb, int len) 230scsi_trace_varlen(struct trace_seq *p, unsigned char *cdb, int len)
143{ 231{
144 switch (SERVICE_ACTION(cdb)) { 232 switch (SERVICE_ACTION32(cdb)) {
145 case READ_32: 233 case READ_32:
234 case VERIFY_32:
146 case WRITE_32: 235 case WRITE_32:
236 case WRITE_SAME_32:
147 return scsi_trace_rw32(p, cdb, len); 237 return scsi_trace_rw32(p, cdb, len);
148 default: 238 default:
149 return scsi_trace_misc(p, cdb, len); 239 return scsi_trace_misc(p, cdb, len);
@@ -169,14 +259,23 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
169 case WRITE_6: 259 case WRITE_6:
170 return scsi_trace_rw6(p, cdb, len); 260 return scsi_trace_rw6(p, cdb, len);
171 case READ_10: 261 case READ_10:
262 case VERIFY:
172 case WRITE_10: 263 case WRITE_10:
264 case WRITE_SAME:
173 return scsi_trace_rw10(p, cdb, len); 265 return scsi_trace_rw10(p, cdb, len);
174 case READ_12: 266 case READ_12:
267 case VERIFY_12:
175 case WRITE_12: 268 case WRITE_12:
176 return scsi_trace_rw12(p, cdb, len); 269 return scsi_trace_rw12(p, cdb, len);
177 case READ_16: 270 case READ_16:
271 case VERIFY_16:
178 case WRITE_16: 272 case WRITE_16:
273 case WRITE_SAME_16:
179 return scsi_trace_rw16(p, cdb, len); 274 return scsi_trace_rw16(p, cdb, len);
275 case UNMAP:
276 return scsi_trace_unmap(p, cdb, len);
277 case SERVICE_ACTION_IN:
278 return scsi_trace_service_action_in(p, cdb, len);
180 case VARIABLE_LENGTH_CMD: 279 case VARIABLE_LENGTH_CMD:
181 return scsi_trace_varlen(p, cdb, len); 280 return scsi_trace_varlen(p, cdb, len);
182 default: 281 default:
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index 76cbf828eb86..25fbefdf2f2e 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -200,6 +200,8 @@ TRACE_EVENT(scsi_dispatch_cmd_start,
200 __field( unsigned int, lun ) 200 __field( unsigned int, lun )
201 __field( unsigned int, opcode ) 201 __field( unsigned int, opcode )
202 __field( unsigned int, cmd_len ) 202 __field( unsigned int, cmd_len )
203 __field( unsigned int, data_sglen )
204 __field( unsigned int, prot_sglen )
203 __dynamic_array(unsigned char, cmnd, cmd->cmd_len) 205 __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
204 ), 206 ),
205 207
@@ -210,12 +212,16 @@ TRACE_EVENT(scsi_dispatch_cmd_start,
210 __entry->lun = cmd->device->lun; 212 __entry->lun = cmd->device->lun;
211 __entry->opcode = cmd->cmnd[0]; 213 __entry->opcode = cmd->cmnd[0];
212 __entry->cmd_len = cmd->cmd_len; 214 __entry->cmd_len = cmd->cmd_len;
215 __entry->data_sglen = scsi_sg_count(cmd);
216 __entry->prot_sglen = scsi_prot_sg_count(cmd);
213 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); 217 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
214 ), 218 ),
215 219
216 TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s)", 220 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
221 " cmnd=(%s %s raw=%s)",
217 __entry->host_no, __entry->channel, __entry->id, 222 __entry->host_no, __entry->channel, __entry->id,
218 __entry->lun, show_opcode_name(__entry->opcode), 223 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
224 show_opcode_name(__entry->opcode),
219 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 225 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
220 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len)) 226 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len))
221); 227);
@@ -234,6 +240,8 @@ TRACE_EVENT(scsi_dispatch_cmd_error,
234 __field( int, rtn ) 240 __field( int, rtn )
235 __field( unsigned int, opcode ) 241 __field( unsigned int, opcode )
236 __field( unsigned int, cmd_len ) 242 __field( unsigned int, cmd_len )
243 __field( unsigned int, data_sglen )
244 __field( unsigned int, prot_sglen )
237 __dynamic_array(unsigned char, cmnd, cmd->cmd_len) 245 __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
238 ), 246 ),
239 247
@@ -245,13 +253,16 @@ TRACE_EVENT(scsi_dispatch_cmd_error,
245 __entry->rtn = rtn; 253 __entry->rtn = rtn;
246 __entry->opcode = cmd->cmnd[0]; 254 __entry->opcode = cmd->cmnd[0];
247 __entry->cmd_len = cmd->cmd_len; 255 __entry->cmd_len = cmd->cmd_len;
256 __entry->data_sglen = scsi_sg_count(cmd);
257 __entry->prot_sglen = scsi_prot_sg_count(cmd);
248 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); 258 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
249 ), 259 ),
250 260
251 TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s)" 261 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
252 " rtn=%d", 262 " cmnd=(%s %s raw=%s) rtn=%d",
253 __entry->host_no, __entry->channel, __entry->id, 263 __entry->host_no, __entry->channel, __entry->id,
254 __entry->lun, show_opcode_name(__entry->opcode), 264 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
265 show_opcode_name(__entry->opcode),
255 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 266 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
256 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), 267 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
257 __entry->rtn) 268 __entry->rtn)
@@ -271,6 +282,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
271 __field( int, result ) 282 __field( int, result )
272 __field( unsigned int, opcode ) 283 __field( unsigned int, opcode )
273 __field( unsigned int, cmd_len ) 284 __field( unsigned int, cmd_len )
285 __field( unsigned int, data_sglen )
286 __field( unsigned int, prot_sglen )
274 __dynamic_array(unsigned char, cmnd, cmd->cmd_len) 287 __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
275 ), 288 ),
276 289
@@ -282,13 +295,17 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
282 __entry->result = cmd->result; 295 __entry->result = cmd->result;
283 __entry->opcode = cmd->cmnd[0]; 296 __entry->opcode = cmd->cmnd[0];
284 __entry->cmd_len = cmd->cmd_len; 297 __entry->cmd_len = cmd->cmd_len;
298 __entry->data_sglen = scsi_sg_count(cmd);
299 __entry->prot_sglen = scsi_prot_sg_count(cmd);
285 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); 300 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
286 ), 301 ),
287 302
288 TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s) " 303 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \
289 "result=(driver=%s host=%s message=%s status=%s)", 304 "prot_sgl=%u cmnd=(%s %s raw=%s) result=(driver=%s host=%s " \
305 "message=%s status=%s)",
290 __entry->host_no, __entry->channel, __entry->id, 306 __entry->host_no, __entry->channel, __entry->id,
291 __entry->lun, show_opcode_name(__entry->opcode), 307 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
308 show_opcode_name(__entry->opcode),
292 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 309 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
293 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), 310 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
294 show_driverbyte_name(((__entry->result) >> 24) & 0xff), 311 show_driverbyte_name(((__entry->result) >> 24) & 0xff),