2 * Copyright (C) 2010 FUJITSU LIMITED
3 * Copyright (C) 2010 Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #include <linux/kernel.h>
19 #include <linux/trace_seq.h>
20 #include <trace/events/scsi.h>
22 #define SERVICE_ACTION16(cdb) (cdb[1] & 0x1f)
23 #define SERVICE_ACTION32(cdb) ((cdb[8] << 8) | cdb[9])
26 scsi_trace_misc(struct trace_seq
*, unsigned char *, int);
29 scsi_trace_rw6(struct trace_seq
*p
, unsigned char *cdb
, int len
)
31 const char *ret
= trace_seq_buffer_ptr(p
);
32 sector_t lba
= 0, txlen
= 0;
34 lba
|= ((cdb
[1] & 0x1F) << 16);
39 trace_seq_printf(p
, "lba=%llu txlen=%llu",
40 (unsigned long long)lba
, (unsigned long long)txlen
);
47 scsi_trace_rw10(struct trace_seq
*p
, unsigned char *cdb
, int len
)
49 const char *ret
= trace_seq_buffer_ptr(p
);
50 sector_t lba
= 0, txlen
= 0;
52 lba
|= (cdb
[2] << 24);
53 lba
|= (cdb
[3] << 16);
56 txlen
|= (cdb
[7] << 8);
59 trace_seq_printf(p
, "lba=%llu txlen=%llu protect=%u",
60 (unsigned long long)lba
, (unsigned long long)txlen
,
63 if (cdb
[0] == WRITE_SAME
)
64 trace_seq_printf(p
, " unmap=%u", cdb
[1] >> 3 & 1);
72 scsi_trace_rw12(struct trace_seq
*p
, unsigned char *cdb
, int len
)
74 const char *ret
= trace_seq_buffer_ptr(p
);
75 sector_t lba
= 0, txlen
= 0;
77 lba
|= (cdb
[2] << 24);
78 lba
|= (cdb
[3] << 16);
81 txlen
|= (cdb
[6] << 24);
82 txlen
|= (cdb
[7] << 16);
83 txlen
|= (cdb
[8] << 8);
86 trace_seq_printf(p
, "lba=%llu txlen=%llu protect=%u",
87 (unsigned long long)lba
, (unsigned long long)txlen
,
95 scsi_trace_rw16(struct trace_seq
*p
, unsigned char *cdb
, int len
)
97 const char *ret
= trace_seq_buffer_ptr(p
);
98 sector_t lba
= 0, txlen
= 0;
100 lba
|= ((u64
)cdb
[2] << 56);
101 lba
|= ((u64
)cdb
[3] << 48);
102 lba
|= ((u64
)cdb
[4] << 40);
103 lba
|= ((u64
)cdb
[5] << 32);
104 lba
|= (cdb
[6] << 24);
105 lba
|= (cdb
[7] << 16);
106 lba
|= (cdb
[8] << 8);
108 txlen
|= (cdb
[10] << 24);
109 txlen
|= (cdb
[11] << 16);
110 txlen
|= (cdb
[12] << 8);
113 trace_seq_printf(p
, "lba=%llu txlen=%llu protect=%u",
114 (unsigned long long)lba
, (unsigned long long)txlen
,
117 if (cdb
[0] == WRITE_SAME_16
)
118 trace_seq_printf(p
, " unmap=%u", cdb
[1] >> 3 & 1);
120 trace_seq_putc(p
, 0);
126 scsi_trace_rw32(struct trace_seq
*p
, unsigned char *cdb
, int len
)
128 const char *ret
= trace_seq_buffer_ptr(p
), *cmd
;
129 sector_t lba
= 0, txlen
= 0;
132 switch (SERVICE_ACTION32(cdb
)) {
146 trace_seq_printf(p
, "UNKNOWN");
150 lba
|= ((u64
)cdb
[12] << 56);
151 lba
|= ((u64
)cdb
[13] << 48);
152 lba
|= ((u64
)cdb
[14] << 40);
153 lba
|= ((u64
)cdb
[15] << 32);
154 lba
|= (cdb
[16] << 24);
155 lba
|= (cdb
[17] << 16);
156 lba
|= (cdb
[18] << 8);
158 ei_lbrt
|= (cdb
[20] << 24);
159 ei_lbrt
|= (cdb
[21] << 16);
160 ei_lbrt
|= (cdb
[22] << 8);
162 txlen
|= (cdb
[28] << 24);
163 txlen
|= (cdb
[29] << 16);
164 txlen
|= (cdb
[30] << 8);
167 trace_seq_printf(p
, "%s_32 lba=%llu txlen=%llu protect=%u ei_lbrt=%u",
168 cmd
, (unsigned long long)lba
,
169 (unsigned long long)txlen
, cdb
[10] >> 5, ei_lbrt
);
171 if (SERVICE_ACTION32(cdb
) == WRITE_SAME_32
)
172 trace_seq_printf(p
, " unmap=%u", cdb
[10] >> 3 & 1);
175 trace_seq_putc(p
, 0);
181 scsi_trace_unmap(struct trace_seq
*p
, unsigned char *cdb
, int len
)
183 const char *ret
= trace_seq_buffer_ptr(p
);
184 unsigned int regions
= cdb
[7] << 8 | cdb
[8];
186 trace_seq_printf(p
, "regions=%u", (regions
- 8) / 16);
187 trace_seq_putc(p
, 0);
193 scsi_trace_service_action_in(struct trace_seq
*p
, unsigned char *cdb
, int len
)
195 const char *ret
= trace_seq_buffer_ptr(p
), *cmd
;
199 switch (SERVICE_ACTION16(cdb
)) {
200 case SAI_READ_CAPACITY_16
:
201 cmd
= "READ_CAPACITY_16";
203 case SAI_GET_LBA_STATUS
:
204 cmd
= "GET_LBA_STATUS";
207 trace_seq_printf(p
, "UNKNOWN");
211 lba
|= ((u64
)cdb
[2] << 56);
212 lba
|= ((u64
)cdb
[3] << 48);
213 lba
|= ((u64
)cdb
[4] << 40);
214 lba
|= ((u64
)cdb
[5] << 32);
215 lba
|= (cdb
[6] << 24);
216 lba
|= (cdb
[7] << 16);
217 lba
|= (cdb
[8] << 8);
219 alloc_len
|= (cdb
[10] << 24);
220 alloc_len
|= (cdb
[11] << 16);
221 alloc_len
|= (cdb
[12] << 8);
222 alloc_len
|= cdb
[13];
224 trace_seq_printf(p
, "%s lba=%llu alloc_len=%u", cmd
,
225 (unsigned long long)lba
, alloc_len
);
228 trace_seq_putc(p
, 0);
234 scsi_trace_varlen(struct trace_seq
*p
, unsigned char *cdb
, int len
)
236 switch (SERVICE_ACTION32(cdb
)) {
241 return scsi_trace_rw32(p
, cdb
, len
);
243 return scsi_trace_misc(p
, cdb
, len
);
248 scsi_trace_misc(struct trace_seq
*p
, unsigned char *cdb
, int len
)
250 const char *ret
= trace_seq_buffer_ptr(p
);
252 trace_seq_printf(p
, "-");
253 trace_seq_putc(p
, 0);
259 scsi_trace_parse_cdb(struct trace_seq
*p
, unsigned char *cdb
, int len
)
264 return scsi_trace_rw6(p
, cdb
, len
);
269 return scsi_trace_rw10(p
, cdb
, len
);
273 return scsi_trace_rw12(p
, cdb
, len
);
278 return scsi_trace_rw16(p
, cdb
, len
);
280 return scsi_trace_unmap(p
, cdb
, len
);
281 case SERVICE_ACTION_IN
:
282 return scsi_trace_service_action_in(p
, cdb
, len
);
283 case VARIABLE_LENGTH_CMD
:
284 return scsi_trace_varlen(p
, cdb
, len
);
286 return scsi_trace_misc(p
, cdb
, len
);
This page took 0.041591 seconds and 5 git commands to generate.