^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ASCII values for a number of symbolic constants, printing functions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * by D. Gilbert and aeb (20020609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <scsi/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <scsi/scsi_cmnd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <scsi/scsi_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <scsi/scsi_eh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <scsi/scsi_dbg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* Commands with service actions that change the command name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define THIRD_PARTY_COPY_OUT 0x83
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define THIRD_PARTY_COPY_IN 0x84
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct sa_name_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) const struct value_name_pair *arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int arr_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct value_name_pair {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) const char * name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static const char * cdb_byte0_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) "Reassign Blocks",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "Reserve(6)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* 1e-1f */ "Prevent/Allow Medium Removal", NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* 20-22 */ NULL, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* 23-28 */ "Read Format Capacities", "Set Window",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) "Read Capacity(10)", NULL, NULL, "Read(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) "Read updated block",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) "Read Defect Data(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "Read Buffer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* 3d-3f */ "Update Block", "Read Long(10)", "Write Long(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* 40-41 */ "Change Definition", "Write Same(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* 42-48 */ "Unmap/Read sub-channel", "Read TOC/PMA/ATIP",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) "Read density support", "Play audio(10)", "Get configuration",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) "Play audio msf", "Sanitize/Play audio track/index",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* 49-4f */ "Play track relative(10)", "Get event status notification",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) "Pause/resume", "Log Select", "Log Sense", "Stop play/scan",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* 50-55 */ "Xdwrite", "Xpwrite, Read disk info", "Xdread, Read track info",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) "Reserve track", "Send OPC info", "Mode Select(10)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* 56-5b */ "Reserve(10)", "Release(10)", "Repair track", "Read master cue",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) "Mode Sense(10)", "Close track/session",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* 5c-5f */ "Read buffer capacity", "Send cue sheet", "Persistent reserve in",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) "Persistent reserve out",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* 60-67 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* 68-6f */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* 70-77 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* 78-7f */ NULL, NULL, NULL, NULL, NULL, NULL, "Extended CDB",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) "Variable length",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* 80-84 */ "Xdwrite(16)", "Rebuild(16)", "Regenerate(16)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) "Third party copy out", "Third party copy in",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* 85-89 */ "ATA command pass through(16)", "Access control in",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) "Access control out", "Read(16)", "Compare and Write",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /* 8a-8f */ "Write(16)", "ORWrite", "Read attributes", "Write attributes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) "Write and verify(16)", "Verify(16)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* 90-94 */ "Pre-fetch(16)", "Synchronize cache(16)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) "Lock/unlock cache(16)", "Write same(16)", NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /* 95-99 */ NULL, NULL, NULL, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* 9a-9f */ NULL, NULL, NULL, "Service action bidirectional",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) "Service action in(16)", "Service action out(16)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* a0-a5 */ "Report luns", "ATA command pass through(12)/Blank",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) "Security protocol in", "Maintenance in", "Maintenance out",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) "Move medium/play audio(12)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* a6-a9 */ "Exchange medium", "Move medium attached", "Read(12)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) "Play track relative(12)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /* aa-ae */ "Write(12)", NULL, "Erase(12), Get Performance",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) "Read DVD structure", "Write and verify(12)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /* af-b1 */ "Verify(12)", "Search data high(12)", "Search data equal(12)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* b2-b4 */ "Search data low(12)", "Set limits(12)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) "Read element status attached",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /* b5-b6 */ "Security protocol out", "Send volume tag, set streaming",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* b7-b9 */ "Read defect data(12)", "Read element status", "Read CD msf",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* ba-bc */ "Redundancy group (in), Scan",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) "Redundancy group (out), Set cd-rom speed", "Spare (in), Play cd",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* bd-bf */ "Spare (out), Mechanism status", "Volume set (in), Read cd",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) "Volume set (out), Send DVD structure",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static const struct value_name_pair maint_in_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {0x5, "Report identifying information"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {0xa, "Report target port groups"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {0xb, "Report aliases"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {0xc, "Report supported operation codes"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {0xd, "Report supported task management functions"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {0xe, "Report priority"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {0xf, "Report timestamp"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {0x10, "Management protocol in"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define MAINT_IN_SZ ARRAY_SIZE(maint_in_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static const struct value_name_pair maint_out_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {0x6, "Set identifying information"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {0xa, "Set target port groups"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {0xb, "Change aliases"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {0xc, "Remove I_T nexus"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {0xe, "Set priority"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {0xf, "Set timestamp"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {0x10, "Management protocol out"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define MAINT_OUT_SZ ARRAY_SIZE(maint_out_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static const struct value_name_pair serv_in12_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {0x1, "Read media serial number"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define SERV_IN12_SZ ARRAY_SIZE(serv_in12_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static const struct value_name_pair serv_out12_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {-1, "dummy entry"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static const struct value_name_pair serv_bidi_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {-1, "dummy entry"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define SERV_BIDI_SZ ARRAY_SIZE(serv_bidi_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static const struct value_name_pair serv_in16_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {0x10, "Read capacity(16)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {0x11, "Read long(16)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {0x12, "Get LBA status"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {0x13, "Report referrals"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static const struct value_name_pair serv_out16_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {0x11, "Write long(16)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {0x1f, "Notify data transfer device(16)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static const struct value_name_pair pr_in_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {0x0, "Persistent reserve in, read keys"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {0x1, "Persistent reserve in, read reservation"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {0x2, "Persistent reserve in, report capabilities"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {0x3, "Persistent reserve in, read full status"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define PR_IN_SZ ARRAY_SIZE(pr_in_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static const struct value_name_pair pr_out_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {0x0, "Persistent reserve out, register"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {0x1, "Persistent reserve out, reserve"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {0x2, "Persistent reserve out, release"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {0x3, "Persistent reserve out, clear"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {0x4, "Persistent reserve out, preempt"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {0x5, "Persistent reserve out, preempt and abort"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {0x6, "Persistent reserve out, register and ignore existing key"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {0x7, "Persistent reserve out, register and move"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define PR_OUT_SZ ARRAY_SIZE(pr_out_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* SPC-4 rev 34 renamed the Extended Copy opcode to Third Party Copy Out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) LID1 (List Identifier length: 1 byte) is the Extended Copy found in SPC-2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) and SPC-3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static const struct value_name_pair tpc_out_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {0x0, "Extended copy(LID1)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {0x1, "Extended copy(LID4)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {0x10, "Populate token"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) {0x11, "Write using token"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {0x1c, "Copy operation abort"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define TPC_OUT_SZ ARRAY_SIZE(tpc_out_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static const struct value_name_pair tpc_in_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {0x0, "Receive copy status(LID1)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {0x1, "Receive copy data(LID1)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {0x3, "Receive copy operating parameters"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {0x4, "Receive copy failure details(LID1)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {0x5, "Receive copy status(LID4)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {0x6, "Receive copy data(LID4)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {0x7, "Receive ROD token information"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {0x8, "Report all ROD tokens"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define TPC_IN_SZ ARRAY_SIZE(tpc_in_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static const struct value_name_pair variable_length_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {0x1, "Rebuild(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {0x2, "Regenerate(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {0x3, "Xdread(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {0x4, "Xdwrite(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {0x5, "Xdwrite extended(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {0x6, "Xpwrite(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {0x7, "Xdwriteread(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {0x8, "Xdwrite extended(64)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {0x9, "Read(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {0xa, "Verify(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {0xb, "Write(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {0xc, "Write an verify(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {0xd, "Write same(32)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {0x8801, "Format OSD"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {0x8802, "Create (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {0x8803, "List (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {0x8805, "Read (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {0x8806, "Write (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {0x8807, "Append (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {0x8808, "Flush (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {0x880a, "Remove (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {0x880b, "Create partition (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {0x880c, "Remove partition (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {0x880e, "Get attributes (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {0x880f, "Set attributes (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {0x8812, "Create and write (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {0x8815, "Create collection (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {0x8816, "Remove collection (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {0x8817, "List collection (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {0x8818, "Set key (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {0x8819, "Set master key (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {0x881a, "Flush collection (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {0x881b, "Flush partition (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {0x881c, "Flush OSD"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {0x8f7e, "Perform SCSI command (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {0x8f7f, "Perform task management function (osd)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static struct sa_name_list sa_names_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {MAINTENANCE_OUT, maint_out_arr, MAINT_OUT_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {PERSISTENT_RESERVE_IN, pr_in_arr, PR_IN_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {PERSISTENT_RESERVE_OUT, pr_out_arr, PR_OUT_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {SERVICE_ACTION_IN_12, serv_in12_arr, SERV_IN12_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {SERVICE_ACTION_OUT_12, serv_out12_arr, SERV_OUT12_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {SERVICE_ACTION_BIDIRECTIONAL, serv_bidi_arr, SERV_BIDI_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {SERVICE_ACTION_IN_16, serv_in16_arr, SERV_IN16_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {SERVICE_ACTION_OUT_16, serv_out16_arr, SERV_OUT16_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {THIRD_PARTY_COPY_IN, tpc_in_arr, TPC_IN_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {THIRD_PARTY_COPY_OUT, tpc_out_arr, TPC_OUT_SZ},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {0, NULL, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) bool scsi_opcode_sa_name(int opcode, int service_action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) const char **cdb_name, const char **sa_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct sa_name_list *sa_name_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) const struct value_name_pair *arr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) int arr_sz, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) *cdb_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (opcode >= VENDOR_SPECIFIC_CDB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (opcode < ARRAY_SIZE(cdb_byte0_names))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) *cdb_name = cdb_byte0_names[opcode];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) for (sa_name_ptr = sa_names_arr; sa_name_ptr->arr; ++sa_name_ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (sa_name_ptr->opcode == opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) arr = sa_name_ptr->arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) arr_sz = sa_name_ptr->arr_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) if (!arr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) for (k = 0; k < arr_sz; ++k, ++arr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (service_action == arr->value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) if (k < arr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) *sa_name = arr->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct error_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) unsigned short size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * There are 700+ entries in this table. To save space, we don't store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * (code, pointer) pairs, which would make sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * error_info)==16 on 64 bits. Rather, the second element just stores
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * the size (including \0) of the corresponding string, and we use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * sum of these to get the appropriate offset into additional_text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * defined below. This approach saves 12 bytes per entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) static const struct error_info additional[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #define SENSE_CODE(c, s) {c, sizeof(s)},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #include "sense_codes.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #undef SENSE_CODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static const char *additional_text =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define SENSE_CODE(c, s) s "\0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #include "sense_codes.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #undef SENSE_CODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct error_info2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unsigned char code1, code2_min, code2_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) const char * str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) const char * fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) static const struct error_info2 additional2[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {0x40, 0x00, 0x7f, "Ram failure", ""},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {0x40, 0x80, 0xff, "Diagnostic failure on component", ""},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {0x41, 0x00, 0xff, "Data path failure", ""},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {0x42, 0x00, 0xff, "Power-on or self-test failure", ""},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {0x4D, 0x00, 0xff, "Tagged overlapped commands", "task tag "},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {0x70, 0x00, 0xff, "Decompression exception", "short algorithm id of "},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) {0, 0, 0, NULL, NULL}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) /* description of the sense key values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) static const char * const snstext[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) "No Sense", /* 0: There is no sense information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) "Recovered Error", /* 1: The last command completed successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) but used error correction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) "Not Ready", /* 2: The addressed target is not ready */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) "Medium Error", /* 3: Data error detected on the medium */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) "Hardware Error", /* 4: Controller or device failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) "Illegal Request", /* 5: Error in request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) "Unit Attention", /* 6: Removable medium was changed, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) the target has been reset, or ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) "Data Protect", /* 7: Access to the data is blocked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) "Blank Check", /* 8: Reached unexpected written or unwritten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) region of the medium */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) "Vendor Specific(9)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) "Copy Aborted", /* A: COPY or COMPARE was aborted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) "Aborted Command", /* B: The target aborted the command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) "Equal", /* C: A SEARCH DATA command found data equal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) reserved in SPC-4 rev 36 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) "Volume Overflow", /* D: Medium full with still data to be written */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) "Miscompare", /* E: Source data and data on the medium
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) do not agree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) "Completed", /* F: command completed sense data reported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) may occur for successful command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* Get sense key string or NULL if not available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) scsi_sense_key_string(unsigned char key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (key < ARRAY_SIZE(snstext))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return snstext[key];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) EXPORT_SYMBOL(scsi_sense_key_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * Get additional sense code string or NULL if not available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * This string may contain a "%x" and should be printed with ascq as arg.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) unsigned short code = ((asc << 8) | ascq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) unsigned offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) *fmt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) for (i = 0; i < ARRAY_SIZE(additional); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) if (additional[i].code12 == code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return additional_text + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) offset += additional[i].size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) for (i = 0; additional2[i].fmt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) if (additional2[i].code1 == asc &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) ascq >= additional2[i].code2_min &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) ascq <= additional2[i].code2_max) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) *fmt = additional2[i].fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return additional2[i].str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) EXPORT_SYMBOL(scsi_extd_sense_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) static const char * const hostbyte_table[]={
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) "DID_NEXUS_FAILURE", "DID_ALLOC_FAILURE", "DID_MEDIUM_ERROR" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) static const char * const driverbyte_table[]={
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) const char *scsi_hostbyte_string(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) const char *hb_string = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) int hb = host_byte(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (hb < ARRAY_SIZE(hostbyte_table))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) hb_string = hostbyte_table[hb];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) return hb_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) EXPORT_SYMBOL(scsi_hostbyte_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) const char *scsi_driverbyte_string(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) const char *db_string = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) int db = driver_byte(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (db < ARRAY_SIZE(driverbyte_table))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) db_string = driverbyte_table[db];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) return db_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) EXPORT_SYMBOL(scsi_driverbyte_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) #define scsi_mlreturn_name(result) { result, #result }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) static const struct value_name_pair scsi_mlreturn_arr[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) scsi_mlreturn_name(NEEDS_RETRY),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) scsi_mlreturn_name(SUCCESS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) scsi_mlreturn_name(FAILED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) scsi_mlreturn_name(QUEUED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) scsi_mlreturn_name(SOFT_ERROR),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) scsi_mlreturn_name(ADD_TO_MLQUEUE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) scsi_mlreturn_name(TIMEOUT_ERROR),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) scsi_mlreturn_name(FAST_IO_FAIL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) const char *scsi_mlreturn_string(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) const struct value_name_pair *arr = scsi_mlreturn_arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) int k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) for (k = 0; k < ARRAY_SIZE(scsi_mlreturn_arr); ++k, ++arr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) if (result == arr->value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) return arr->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) EXPORT_SYMBOL(scsi_mlreturn_string);