^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2010 FUJITSU LIMITED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2010 Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/trace_seq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <trace/events/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define SERVICE_ACTION16(cdb) (cdb[1] & 0x1f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define SERVICE_ACTION32(cdb) (get_unaligned_be16(&cdb[8]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) scsi_trace_misc(struct trace_seq *, unsigned char *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) u32 lba, txlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) lba = get_unaligned_be24(&cdb[1]) & 0x1fffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * From SBC-2: a TRANSFER LENGTH field set to zero specifies that 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * logical blocks shall be read (READ(6)) or written (WRITE(6)).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) txlen = cdb[4] ? cdb[4] : 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) trace_seq_printf(p, "lba=%u txlen=%u", lba, txlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) u32 lba, txlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) lba = get_unaligned_be32(&cdb[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) txlen = get_unaligned_be16(&cdb[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) trace_seq_printf(p, "lba=%u txlen=%u protect=%u", lba, txlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) cdb[1] >> 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (cdb[0] == WRITE_SAME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) trace_seq_printf(p, " unmap=%u", cdb[1] >> 3 & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) scsi_trace_rw12(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u32 lba, txlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) lba = get_unaligned_be32(&cdb[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) txlen = get_unaligned_be32(&cdb[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) trace_seq_printf(p, "lba=%u txlen=%u protect=%u", lba, txlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) cdb[1] >> 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) scsi_trace_rw16(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u64 lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u32 txlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) lba = get_unaligned_be64(&cdb[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) txlen = get_unaligned_be32(&cdb[10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) trace_seq_printf(p, "lba=%llu txlen=%u protect=%u", lba, txlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) cdb[1] >> 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (cdb[0] == WRITE_SAME_16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) trace_seq_printf(p, " unmap=%u", cdb[1] >> 3 & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) scsi_trace_rw32(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) const char *ret = trace_seq_buffer_ptr(p), *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u64 lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) u32 ei_lbrt, txlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) switch (SERVICE_ACTION32(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) case READ_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) cmd = "READ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) case VERIFY_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) cmd = "VERIFY";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) case WRITE_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) cmd = "WRITE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) case WRITE_SAME_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) cmd = "WRITE_SAME";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) trace_seq_puts(p, "UNKNOWN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) lba = get_unaligned_be64(&cdb[12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ei_lbrt = get_unaligned_be32(&cdb[20]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) txlen = get_unaligned_be32(&cdb[28]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) trace_seq_printf(p, "%s_32 lba=%llu txlen=%u protect=%u ei_lbrt=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) cmd, lba, txlen, cdb[10] >> 5, ei_lbrt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (SERVICE_ACTION32(cdb) == WRITE_SAME_32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) trace_seq_printf(p, " unmap=%u", cdb[10] >> 3 & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) scsi_trace_unmap(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) unsigned int regions = get_unaligned_be16(&cdb[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) trace_seq_printf(p, "regions=%u", (regions - 8) / 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) scsi_trace_service_action_in(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) const char *ret = trace_seq_buffer_ptr(p), *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) u64 lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) u32 alloc_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) switch (SERVICE_ACTION16(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) case SAI_READ_CAPACITY_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) cmd = "READ_CAPACITY_16";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) case SAI_GET_LBA_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) cmd = "GET_LBA_STATUS";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) trace_seq_puts(p, "UNKNOWN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) lba = get_unaligned_be64(&cdb[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) alloc_len = get_unaligned_be32(&cdb[10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) trace_seq_printf(p, "%s lba=%llu alloc_len=%u", cmd, lba, alloc_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) scsi_trace_maintenance_in(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) const char *ret = trace_seq_buffer_ptr(p), *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) u32 alloc_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) switch (SERVICE_ACTION16(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) case MI_REPORT_IDENTIFYING_INFORMATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) cmd = "REPORT_IDENTIFYING_INFORMATION";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) case MI_REPORT_TARGET_PGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) cmd = "REPORT_TARGET_PORT_GROUPS";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) case MI_REPORT_ALIASES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) cmd = "REPORT_ALIASES";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) case MI_REPORT_SUPPORTED_OPERATION_CODES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) cmd = "REPORT_SUPPORTED_OPERATION_CODES";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) case MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) cmd = "REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) case MI_REPORT_PRIORITY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) cmd = "REPORT_PRIORITY";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) case MI_REPORT_TIMESTAMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) cmd = "REPORT_TIMESTAMP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) case MI_MANAGEMENT_PROTOCOL_IN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) cmd = "MANAGEMENT_PROTOCOL_IN";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) trace_seq_puts(p, "UNKNOWN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) alloc_len = get_unaligned_be32(&cdb[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) trace_seq_printf(p, "%s alloc_len=%u", cmd, alloc_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) scsi_trace_maintenance_out(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) const char *ret = trace_seq_buffer_ptr(p), *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u32 alloc_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) switch (SERVICE_ACTION16(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) case MO_SET_IDENTIFYING_INFORMATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) cmd = "SET_IDENTIFYING_INFORMATION";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) case MO_SET_TARGET_PGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) cmd = "SET_TARGET_PORT_GROUPS";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) case MO_CHANGE_ALIASES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) cmd = "CHANGE_ALIASES";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) case MO_SET_PRIORITY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) cmd = "SET_PRIORITY";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) case MO_SET_TIMESTAMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) cmd = "SET_TIMESTAMP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) case MO_MANAGEMENT_PROTOCOL_OUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) cmd = "MANAGEMENT_PROTOCOL_OUT";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) trace_seq_puts(p, "UNKNOWN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) alloc_len = get_unaligned_be32(&cdb[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) trace_seq_printf(p, "%s alloc_len=%u", cmd, alloc_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) scsi_trace_zbc_in(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) const char *ret = trace_seq_buffer_ptr(p), *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u64 zone_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) u32 alloc_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) u8 options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) switch (SERVICE_ACTION16(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) case ZI_REPORT_ZONES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) cmd = "REPORT_ZONES";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) trace_seq_puts(p, "UNKNOWN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) zone_id = get_unaligned_be64(&cdb[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) alloc_len = get_unaligned_be32(&cdb[10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) options = cdb[14] & 0x3f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) trace_seq_printf(p, "%s zone=%llu alloc_len=%u options=%u partial=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) cmd, (unsigned long long)zone_id, alloc_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) options, (cdb[14] >> 7) & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) scsi_trace_zbc_out(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) const char *ret = trace_seq_buffer_ptr(p), *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) u64 zone_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) switch (SERVICE_ACTION16(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) case ZO_CLOSE_ZONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) cmd = "CLOSE_ZONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) case ZO_FINISH_ZONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) cmd = "FINISH_ZONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) case ZO_OPEN_ZONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) cmd = "OPEN_ZONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) case ZO_RESET_WRITE_POINTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) cmd = "RESET_WRITE_POINTER";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) trace_seq_puts(p, "UNKNOWN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) zone_id = get_unaligned_be64(&cdb[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) trace_seq_printf(p, "%s zone=%llu all=%u", cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) (unsigned long long)zone_id, cdb[14] & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) scsi_trace_varlen(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) switch (SERVICE_ACTION32(cdb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) case READ_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) case VERIFY_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) case WRITE_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) case WRITE_SAME_32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return scsi_trace_rw32(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) return scsi_trace_misc(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) scsi_trace_misc(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) trace_seq_putc(p, '-');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) switch (cdb[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) case READ_6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) case WRITE_6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) return scsi_trace_rw6(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) case READ_10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) case VERIFY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) case WRITE_10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) case WRITE_SAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) return scsi_trace_rw10(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) case READ_12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) case VERIFY_12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) case WRITE_12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return scsi_trace_rw12(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) case READ_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) case VERIFY_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) case WRITE_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) case WRITE_SAME_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return scsi_trace_rw16(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) case UNMAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) return scsi_trace_unmap(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) case SERVICE_ACTION_IN_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return scsi_trace_service_action_in(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) case VARIABLE_LENGTH_CMD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) return scsi_trace_varlen(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) case MAINTENANCE_IN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) return scsi_trace_maintenance_in(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) case MAINTENANCE_OUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) return scsi_trace_maintenance_out(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) case ZBC_IN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return scsi_trace_zbc_in(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) case ZBC_OUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return scsi_trace_zbc_out(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return scsi_trace_misc(p, cdb, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }