]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/scsi/scsi_trace.c
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_ACTION(cdb) ((cdb[8] << 8) | cdb[9])
25 scsi_trace_misc(struct trace_seq
*, unsigned char *, int);
28 scsi_trace_rw6(struct trace_seq
*p
, unsigned char *cdb
, int len
)
30 const char *ret
= p
->buffer
+ p
->len
;
31 sector_t lba
= 0, txlen
= 0;
33 lba
|= ((cdb
[1] & 0x1F) << 16);
38 trace_seq_printf(p
, "lba=%llu txlen=%llu",
39 (unsigned long long)lba
, (unsigned long long)txlen
);
46 scsi_trace_rw10(struct trace_seq
*p
, unsigned char *cdb
, int len
)
48 const char *ret
= p
->buffer
+ p
->len
;
49 sector_t lba
= 0, txlen
= 0;
51 lba
|= (cdb
[2] << 24);
52 lba
|= (cdb
[3] << 16);
55 txlen
|= (cdb
[7] << 8);
58 trace_seq_printf(p
, "lba=%llu txlen=%llu",
59 (unsigned long long)lba
, (unsigned long long)txlen
);
66 scsi_trace_rw12(struct trace_seq
*p
, unsigned char *cdb
, int len
)
68 const char *ret
= p
->buffer
+ p
->len
;
69 sector_t lba
= 0, txlen
= 0;
71 lba
|= (cdb
[2] << 24);
72 lba
|= (cdb
[3] << 16);
75 txlen
|= (cdb
[6] << 24);
76 txlen
|= (cdb
[7] << 16);
77 txlen
|= (cdb
[8] << 8);
80 trace_seq_printf(p
, "lba=%llu txlen=%llu",
81 (unsigned long long)lba
, (unsigned long long)txlen
);
88 scsi_trace_rw16(struct trace_seq
*p
, unsigned char *cdb
, int len
)
90 const char *ret
= p
->buffer
+ p
->len
;
91 sector_t lba
= 0, txlen
= 0;
93 lba
|= ((u64
)cdb
[2] << 56);
94 lba
|= ((u64
)cdb
[3] << 48);
95 lba
|= ((u64
)cdb
[4] << 40);
96 lba
|= ((u64
)cdb
[5] << 32);
97 lba
|= (cdb
[6] << 24);
98 lba
|= (cdb
[7] << 16);
101 txlen
|= (cdb
[10] << 24);
102 txlen
|= (cdb
[11] << 16);
103 txlen
|= (cdb
[12] << 8);
106 trace_seq_printf(p
, "lba=%llu txlen=%llu",
107 (unsigned long long)lba
, (unsigned long long)txlen
);
108 trace_seq_putc(p
, 0);
114 scsi_trace_rw32(struct trace_seq
*p
, unsigned char *cdb
, int len
)
116 const char *ret
= p
->buffer
+ p
->len
;
117 sector_t lba
= 0, txlen
= 0;
119 lba
|= ((u64
)cdb
[12] << 56);
120 lba
|= ((u64
)cdb
[13] << 48);
121 lba
|= ((u64
)cdb
[14] << 40);
122 lba
|= ((u64
)cdb
[15] << 32);
123 lba
|= (cdb
[16] << 24);
124 lba
|= (cdb
[17] << 16);
125 lba
|= (cdb
[18] << 8);
127 txlen
|= (cdb
[28] << 24);
128 txlen
|= (cdb
[29] << 16);
129 txlen
|= (cdb
[30] << 8);
132 trace_seq_printf(p
, "%s_32 lba=%llu txlen=%llu",
133 (SERVICE_ACTION(cdb
) == READ_32
? "READ" : "WRITE"),
134 (unsigned long long)lba
, (unsigned long long)txlen
);
136 trace_seq_putc(p
, 0);
142 scsi_trace_varlen(struct trace_seq
*p
, unsigned char *cdb
, int len
)
144 switch (SERVICE_ACTION(cdb
)) {
147 return scsi_trace_rw32(p
, cdb
, len
);
149 return scsi_trace_misc(p
, cdb
, len
);
154 scsi_trace_misc(struct trace_seq
*p
, unsigned char *cdb
, int len
)
156 const char *ret
= p
->buffer
+ p
->len
;
158 trace_seq_printf(p
, "-");
159 trace_seq_putc(p
, 0);
165 scsi_trace_parse_cdb(struct trace_seq
*p
, unsigned char *cdb
, int len
)
170 return scsi_trace_rw6(p
, cdb
, len
);
173 return scsi_trace_rw10(p
, cdb
, len
);
176 return scsi_trace_rw12(p
, cdb
, len
);
179 return scsi_trace_rw16(p
, cdb
, len
);
180 case VARIABLE_LENGTH_CMD
:
181 return scsi_trace_varlen(p
, cdb
, len
);
183 return scsi_trace_misc(p
, cdb
, len
);