1 /* $NetBSD: scsipi_verbose.c,v 1.27 2005/05/29 22:00:50 christos Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
31 * Small changes made by Reinoud Zandijk <reinoud@netbsd.org>
35 * SCSI sense interpretation. Lifted from src/sys/dev/scsipi/scsipi_verbose.c,
36 * and modified for userland.
41 #include <sys/types.h>
47 static const char *sense_keys
[16] = {
48 "No Additional Sense",
67 * The current version of this list can be obtained from
68 * <ftp://ftp.t10.org/t10/drafts/spc3/asc-num.txt>
74 const char *description
;
76 { 0x00, 0x00, "No Additional Sense Information" },
77 { 0x00, 0x01, "Filemark Detected" },
78 { 0x00, 0x02, "End-Of-Partition/Medium Detected" },
79 { 0x00, 0x03, "Setmark Detected" },
80 { 0x00, 0x04, "Beginning-Of-Partition/Medium Detected" },
81 { 0x00, 0x05, "End-Of-Data Detected" },
82 { 0x00, 0x06, "I/O Process Terminated" },
83 { 0x00, 0x11, "Audio Play Operation In Progress" },
84 { 0x00, 0x12, "Audio Play Operation Paused" },
85 { 0x00, 0x13, "Audio Play Operation Successfully Completed" },
86 { 0x00, 0x14, "Audio Play Operation Stopped Due to Error" },
87 { 0x00, 0x15, "No Current Audio Status To Return" },
88 { 0x00, 0x16, "Operation In Progress" },
89 { 0x00, 0x17, "Cleaning Requested" },
90 { 0x00, 0x18, "Erase Operation In Progress" },
91 { 0x00, 0x19, "Locate Operation In Progress" },
92 { 0x00, 0x1A, "Rewind Operation In Progress" },
93 { 0x00, 0x1B, "Set Capacity Operation In Progess" },
94 { 0x00, 0x1C, "Verify Operation In Progress" },
95 { 0x01, 0x00, "No Index/Sector Signal" },
96 { 0x02, 0x00, "No Seek Complete" },
97 { 0x03, 0x00, "Peripheral Device Write Fault" },
98 { 0x03, 0x01, "No Write Current" },
99 { 0x03, 0x02, "Excessive Write Errors" },
100 { 0x04, 0x00, "Logical Unit Not Ready, Cause Not Reportable" },
101 { 0x04, 0x01, "Logical Unit Is in Process Of Becoming Ready" },
102 { 0x04, 0x02, "Logical Unit Not Ready, Initialization Command Required" },
103 { 0x04, 0x03, "Logical Unit Not Ready, Manual Intervention Required" },
104 { 0x04, 0x04, "Logical Unit Not Ready, Format In Progress" },
105 { 0x04, 0x05, "Logical Unit Not Ready, Rebuild In Progress" },
106 { 0x04, 0x06, "Logical Unit Not Ready, Recalculation In Progress" },
107 { 0x04, 0x07, "Logical Unit Not Ready, Operation In Progress" },
108 { 0x04, 0x08, "Logical Unit Not Ready, Long Write In Progress" },
109 { 0x04, 0x09, "Logical Unit Not Ready, Self-Test In Progress" },
110 { 0x04, 0x0A, "Logical Unit Not Accessible, Asymmetric Access State "
112 { 0x04, 0x0B, "Logical Unit Not Accessible, Target Port In Standby State" },
113 { 0x04, 0x0C, "Logical Unit Not Accessible, Target Port In Unavailable State" },
114 { 0x04, 0x10, "Logical Unit Not Ready, Auxiliary Memory Not Accessible" },
115 { 0x04, 0x11, "Logical Unit Not Ready, Notify (Enable_Spinup) Required" },
116 { 0x05, 0x00, "Logical Unit Does Not Respond To Selection" },
117 { 0x06, 0x00, "No Reference Position Found" },
118 { 0x07, 0x00, "Multiple Peripheral Devices Selected" },
119 { 0x08, 0x00, "Logical Unit Communication Failure" },
120 { 0x08, 0x01, "Logical Unit Communication Timeout" },
121 { 0x08, 0x02, "Logical Unit Communication Parity Error" },
122 { 0x08, 0x03, "Logical Unit Communication CRC Error" },
123 { 0x08, 0x04, "Unreachable Copy Target" },
124 { 0x09, 0x00, "Track Following Error" },
125 { 0x09, 0x01, "Tracking Servo Failure" },
126 { 0x09, 0x02, "Focus Servo Failure" },
127 { 0x09, 0x03, "Spindle Servo Failure" },
128 { 0x09, 0x04, "Head Select Fault" },
129 { 0x0A, 0x00, "Error Log Overflow" },
130 { 0x0B, 0x00, "Warning" },
131 { 0x0B, 0x01, "Warning - Specified Temperature Exceeded" },
132 { 0x0B, 0x02, "Warning - Enclosure Degraded" },
133 { 0x0C, 0x00, "Write Error" },
134 { 0x0C, 0x01, "Write Error - Recovered with Auto Reallocation" },
135 { 0x0C, 0x02, "Write Error - Auto Reallocate Failed" },
136 { 0x0C, 0x03, "Write Error - Recommend Reassignment" },
137 { 0x0C, 0x04, "Compression Check Miscompare Error" },
138 { 0x0C, 0x05, "Data Expansion Occurred During Compression" },
139 { 0x0C, 0x06, "Block Not Compressible" },
140 { 0x0C, 0x07, "Write Error - Recovery Needed" },
141 { 0x0C, 0x08, "Write Error - Recovery Failed" },
142 { 0x0C, 0x09, "Write Error - Loss Of Streaming" },
143 { 0x0C, 0x0A, "Write Error - Padding Blocks Added" },
144 { 0x0C, 0x0B, "Auxiliary Memory Write Error" },
145 { 0x0C, 0x0C, "Write Error - Unexpected Unsolicited Data" },
146 { 0x0C, 0x0D, "Write Error - Not Enough Unsolicited Data" },
147 { 0x0D, 0x00, "Error Detected By Third Party Temporary Initiator" },
148 { 0x0D, 0x01, "Third Party Device Failure" },
149 { 0x0D, 0x02, "Copy Target Device Not Reachable" },
150 { 0x0D, 0x03, "Incorrect Copy Target Device Type" },
151 { 0x0D, 0x04, "Copy Target Device Data Underrun" },
152 { 0x0D, 0x05, "Copy Target Device Data Overrun" },
153 { 0x0E, 0x00, "Invalid Information Unit" },
154 { 0x0E, 0x01, "Information Unit Too Short" },
155 { 0x0E, 0x02, "Information Unit Too Long" },
156 { 0x10, 0x00, "ID CRC Or ECC Error" },
157 { 0x11, 0x00, "Unrecovered Read Error" },
158 { 0x11, 0x01, "Read Retries Exhausted" },
159 { 0x11, 0x02, "Error Too Long To Correct" },
160 { 0x11, 0x03, "Multiple Read Errors" },
161 { 0x11, 0x04, "Unrecovered Read Error - Auto Reallocate Failed" },
162 { 0x11, 0x05, "L-EC Uncorrectable Error" },
163 { 0x11, 0x06, "CIRC Unrecovered Error" },
164 { 0x11, 0x07, "Data Re-synchronization Error" },
165 { 0x11, 0x08, "Incomplete Block Read" },
166 { 0x11, 0x09, "No Gap Found" },
167 { 0x11, 0x0A, "Miscorrected Error" },
168 { 0x11, 0x0B, "Uncorrected Read Error - Recommend Reassignment" },
169 { 0x11, 0x0C, "Uncorrected Read Error - Recommend Rewrite the Data" },
170 { 0x11, 0x0D, "De-Compression CRC Error" },
171 { 0x11, 0x0E, "Cannot Decompress Using Declared Algorithm" },
172 { 0x11, 0x0F, "Error Reading UPC/EAN Number" },
173 { 0x11, 0x10, "Error Reading ISRC Number" },
174 { 0x11, 0x11, "Read Error - Loss Of Streaming" },
175 { 0x11, 0x12, "Auxiliary Memory Read Error" },
176 { 0x11, 0x13, "Read Error - Failed Retransmission Request" },
177 { 0x12, 0x00, "Address Mark Not Found for ID Field" },
178 { 0x13, 0x00, "Address Mark Not Found for Data Field" },
179 { 0x14, 0x00, "Recorded Entity Not Found" },
180 { 0x14, 0x01, "Record Not Found" },
181 { 0x14, 0x02, "Filemark or Setmark Not Found" },
182 { 0x14, 0x03, "End-Of-Data Not Found" },
183 { 0x14, 0x04, "Block Sequence Error" },
184 { 0x14, 0x05, "Record Not Found - Recommend Reassignment" },
185 { 0x14, 0x06, "Record Not Found - Data Auto-Reallocated" },
186 { 0x14, 0x07, "Locate Operation Failure" },
187 { 0x15, 0x00, "Random Positioning Error" },
188 { 0x15, 0x01, "Mechanical Positioning Error" },
189 { 0x15, 0x02, "Positioning Error Detected By Read of Medium" },
190 { 0x16, 0x00, "Data Synchronization Mark Error" },
191 { 0x16, 0x01, "Data Sync Error - Data Rewritten" },
192 { 0x16, 0x02, "Data Sync Error - Recommend Rewrite" },
193 { 0x16, 0x03, "Data Sync Error - Data Auto-Reallocated" },
194 { 0x16, 0x04, "Data Sync Error - Recommend Reassignment" },
195 { 0x17, 0x00, "Recovered Data With No Error Correction Applied" },
196 { 0x17, 0x01, "Recovered Data With Retries" },
197 { 0x17, 0x02, "Recovered Data With Positive Head Offset" },
198 { 0x17, 0x03, "Recovered Data With Negative Head Offset" },
199 { 0x17, 0x04, "Recovered Data With Retries and/or CIRC Applied" },
200 { 0x17, 0x05, "Recovered Data Using Previous Sector ID" },
201 { 0x17, 0x06, "Recovered Data Without ECC - Data Auto-Reallocated" },
202 { 0x17, 0x07, "Recovered Data Without ECC - Recommend Reassignment" },
203 { 0x17, 0x08, "Recovered Data Without ECC - Recommend Rewrite" },
204 { 0x17, 0x09, "Recovered Data Without ECC - Data Rewritten" },
205 { 0x18, 0x00, "Recovered Data With Error Correction Applied" },
206 { 0x18, 0x01, "Recovered Data With Error Correction & Retries Applied" },
207 { 0x18, 0x02, "Recovered Data - Data Auto-Reallocated" },
208 { 0x18, 0x03, "Recovered Data With CIRC" },
209 { 0x18, 0x04, "Recovered Data With LEC" },
210 { 0x18, 0x05, "Recovered Data - Recommend Reassignment" },
211 { 0x18, 0x06, "Recovered Data - Recommend Rewrite" },
212 { 0x18, 0x07, "Recovered Data With ECC - Data Rewritten" },
213 { 0x18, 0x08, "Recovered Data With Linking" },
214 { 0x19, 0x00, "Defect List Error" },
215 { 0x19, 0x01, "Defect List Not Available" },
216 { 0x19, 0x02, "Defect List Error in Primary List" },
217 { 0x19, 0x03, "Defect List Error in Grown List" },
218 { 0x1A, 0x00, "Parameter List Length Error" },
219 { 0x1B, 0x00, "Synchronous Data Transfer Error" },
220 { 0x1C, 0x00, "Defect List Not Found" },
221 { 0x1C, 0x01, "Primary Defect List Not Found" },
222 { 0x1C, 0x02, "Grown Defect List Not Found" },
223 { 0x1D, 0x00, "Miscompare During Verify Operation" },
224 { 0x1E, 0x00, "Recovered ID with ECC Correction" },
225 { 0x1F, 0x00, "Partial Defect List Transfer" },
226 { 0x20, 0x00, "Invalid Command Operation Code" },
227 { 0x20, 0x01, "Access Denied - Initiator Pending-Enrolled" },
228 { 0x20, 0x02, "Access Denied - No Access Rights" },
229 { 0x20, 0x03, "Access Denied - Invalid Mgmt ID Key" },
230 { 0x20, 0x04, "Illegal Command While In Write Capable State" },
231 { 0x20, 0x06, "Illegal Command While In Explicit Address Mode" },
232 { 0x20, 0x07, "Illegal Command While In Implicit Address Mode" },
233 { 0x20, 0x08, "Access Denied - Enrollment Conflict" },
234 { 0x20, 0x09, "Access Denied - Invalid LU Identifer" },
235 { 0x20, 0x0A, "Access Denied - Invalid Proxy Token" },
236 { 0x20, 0x0B, "Access Denied - ACL LUN Conflict" },
237 { 0x21, 0x00, "Logical Block Address Out of Range" },
238 { 0x21, 0x01, "Invalid Element Address" },
239 { 0x21, 0x02, "Invalid Address For Write" },
240 { 0x22, 0x00, "Illegal Function (Use 20 00, 24 00, or 26 00)" },
241 { 0x24, 0x00, "Illegal Field in CDB" },
242 { 0x24, 0x01, "CDB Decryption Error" },
243 { 0x24, 0x04, "Security Audit Value Frozen" },
244 { 0x24, 0x05, "Security Working Key Frozen" },
245 { 0x24, 0x06, "Nonce Not Unique" },
246 { 0x24, 0x07, "Nonce Timestamp Out Of Range" },
247 { 0x25, 0x00, "Logical Unit Not Supported" },
248 { 0x26, 0x00, "Invalid Field In Parameter List" },
249 { 0x26, 0x01, "Parameter Not Supported" },
250 { 0x26, 0x02, "Parameter Value Invalid" },
251 { 0x26, 0x03, "Threshold Parameters Not Supported" },
252 { 0x26, 0x04, "Invalid Release Of Persistent Reservation" },
253 { 0x26, 0x05, "Data Decryption Error" },
254 { 0x26, 0x06, "Too Many Target Descriptors" },
255 { 0x26, 0x07, "Unsupported Target Descriptor Type Code" },
256 { 0x26, 0x08, "Too Many Segment Descriptors" },
257 { 0x26, 0x09, "Unsupported Segment Descriptor Type Code" },
258 { 0x26, 0x0A, "Unexpected Inexact Segment" },
259 { 0x26, 0x0B, "Inline Data Length Exceeded" },
260 { 0x26, 0x0C, "Invalid Operation For Copy Source Or Destination" },
261 { 0x26, 0x0D, "Copy Segment Granularity Violation" },
262 { 0x26, 0x0E, "Invalid Parameter While Port Is Enabled" },
263 { 0x27, 0x00, "Write Protected" },
264 { 0x27, 0x01, "Hardware Write Protected" },
265 { 0x27, 0x02, "Logical Unit Software Write Protected" },
266 { 0x27, 0x03, "Associated Write Protect" },
267 { 0x27, 0x04, "Persistent Write Protect" },
268 { 0x27, 0x05, "Permanent Write Protect" },
269 { 0x27, 0x06, "Conditional Write Protect" },
270 { 0x28, 0x00, "Not Ready To Ready Transition (Medium May Have Changed)" },
271 { 0x28, 0x01, "Import Or Export Element Accessed" },
272 { 0x29, 0x00, "Power On, Reset, or Bus Device Reset Occurred" },
273 { 0x29, 0x01, "Power On Occurred" },
274 { 0x29, 0x02, "SCSI Bus Reset Occurred" },
275 { 0x29, 0x03, "Bus Device Reset Function Occurred" },
276 { 0x29, 0x04, "Device Internal Reset" },
277 { 0x29, 0x05, "Transceiver Mode Changed To Single-Ended" },
278 { 0x29, 0x06, "Transceiver Mode Changed To LVD" },
279 { 0x29, 0x07, "I_T Nexus Loss Occurred" },
280 { 0x2A, 0x00, "Parameters Changed" },
281 { 0x2A, 0x01, "Mode Parameters Changed" },
282 { 0x2A, 0x02, "Log Parameters Changed" },
283 { 0x2A, 0x03, "Reservations Preempted" },
284 { 0x2A, 0x04, "Reservations Released" },
285 { 0x2A, 0x05, "Registrations Preempted" },
286 { 0x2A, 0x06, "Asymmetric Access State Changed" },
287 { 0x2A, 0x07, "Implicit Asymmetric Access State Transition Failed" },
288 { 0x2B, 0x00, "Copy Cannot Execute Since Host Cannot Disconnect" },
289 { 0x2C, 0x00, "Command Sequence Error" },
290 { 0x2C, 0x01, "Too Many Windows Specified" },
291 { 0x2C, 0x02, "Invalid Combination of Windows Specified" },
292 { 0x2C, 0x03, "Current Program Area Is Not Empty" },
293 { 0x2C, 0x04, "Current Program Area Is Empty" },
294 { 0x2C, 0x05, "Illegal Power Condition Request" },
295 { 0x2C, 0x06, "Persistent Prevent Conflict" },
296 { 0x2C, 0x07, "Previous Busy Status" },
297 { 0x2C, 0x08, "Previous Task Set Full Status" },
298 { 0x2C, 0x09, "Previous Reservation Conflict Status" },
299 { 0x2C, 0x0A, "Partition or Collection Contains User Objects" },
300 { 0x2D, 0x00, "Overwrite Error On Update In Place" },
301 { 0x2E, 0x00, "Insufficient Time For Operation" },
302 { 0x2F, 0x00, "Commands Cleared By Another Initiator" },
303 { 0x30, 0x00, "Incompatible Medium Installed" },
304 { 0x30, 0x01, "Cannot Read Medium - Unknown Format" },
305 { 0x30, 0x02, "Cannot Read Medium - Incompatible Format" },
306 { 0x30, 0x03, "Cleaning Cartridge Installed" },
307 { 0x30, 0x04, "Cannot Write Medium - Unknown Format" },
308 { 0x30, 0x05, "Cannot Write Medium - Incompatible Format" },
309 { 0x30, 0x06, "Cannot Format Medium - Incompatible Medium" },
310 { 0x30, 0x07, "Cleaning Failure" },
311 { 0x30, 0x08, "Cannot Write - Application Code Mismatch" },
312 { 0x30, 0x09, "Current Session Not Fixated For Append" },
313 { 0x30, 0x0A, "Cleaning Request Rejected" },
314 { 0x30, 0x10, "Medium Not Formatted" },
315 { 0x31, 0x00, "Medium Format Corrupted" },
316 { 0x31, 0x01, "Format Command Failed" },
317 { 0x31, 0x02, "Zoned Formatting Failed Due To Spare Linking" },
318 { 0x32, 0x00, "No Defect Spare Location Available" },
319 { 0x32, 0x01, "Defect List Update Failure" },
320 { 0x33, 0x00, "Tape Length Error" },
321 { 0x34, 0x00, "Enclosure Failure" },
322 { 0x35, 0x00, "Enclosure Services Failure" },
323 { 0x35, 0x01, "Unsupported Enclosure Function" },
324 { 0x35, 0x02, "Enclosure Services Unavailable" },
325 { 0x35, 0x03, "Enclosure Services Transfer Failed" },
326 { 0x35, 0x04, "Enclosure Services Transfer Refused" },
327 { 0x36, 0x00, "Ribbon, Ink, or Toner Failure" },
328 { 0x37, 0x00, "Rounded Parameter" },
329 { 0x39, 0x00, "Saving Parameters Not Supported" },
330 { 0x3A, 0x00, "Medium Not Present" },
331 { 0x3A, 0x01, "Medium Not Present - Tray Closed" },
332 { 0x3A, 0x02, "Medium Not Present - Tray Open" },
333 { 0x3A, 0x03, "Medium Not Present - Loadable" },
334 { 0x3A, 0x04, "Medium Not Present - Medium Auxilliary Memory Accessible" },
335 { 0x3B, 0x00, "Sequential Positioning Error" },
336 { 0x3B, 0x01, "Tape Position Error At Beginning-of-Medium" },
337 { 0x3B, 0x02, "Tape Position Error At End-of-Medium" },
338 { 0x3B, 0x03, "Tape or Electronic Vertical Forms Unit Not Ready" },
339 { 0x3B, 0x04, "Slew Failure" },
340 { 0x3B, 0x05, "Paper Jam" },
341 { 0x3B, 0x06, "Failed To Sense Top-Of-Form" },
342 { 0x3B, 0x07, "Failed To Sense Bottom-Of-Form" },
343 { 0x3B, 0x08, "Reposition Error" },
344 { 0x3B, 0x09, "Read Past End Of Medium" },
345 { 0x3B, 0x0A, "Read Past Begining Of Medium" },
346 { 0x3B, 0x0B, "Position Past End Of Medium" },
347 { 0x3B, 0x0C, "Position Past Beginning Of Medium" },
348 { 0x3B, 0x0D, "Medium Destination Element Full" },
349 { 0x3B, 0x0E, "Medium Source Element Empty" },
350 { 0x3B, 0x0F, "End Of Medium Reached" },
351 { 0x3B, 0x11, "Medium Magazine Not Accessible" },
352 { 0x3B, 0x12, "Medium Magazine Removed" },
353 { 0x3B, 0x13, "Medium Magazine Inserted" },
354 { 0x3B, 0x14, "Medium Magazine Locked" },
355 { 0x3B, 0x15, "Medium Magazine Unlocked" },
356 { 0x3B, 0x16, "Mechanical Positioning Or Changer Error" },
357 { 0x3D, 0x00, "Invalid Bits In IDENTIFY Message" },
358 { 0x3E, 0x00, "Logical Unit Has Not Self-Configured Yet" },
359 { 0x3E, 0x01, "Logical Unit Failure" },
360 { 0x3E, 0x02, "Timeout On Logical Unit" },
361 { 0x3E, 0x03, "Logical Unit Failed Self-Test" },
362 { 0x3E, 0x04, "Logical Unit Unable To Update Self-Test Log" },
363 { 0x3F, 0x00, "Target Operating Conditions Have Changed" },
364 { 0x3F, 0x01, "Microcode Has Been Changed" },
365 { 0x3F, 0x02, "Changed Operating Definition" },
366 { 0x3F, 0x03, "INQUIRY Data Has Changed" },
367 { 0x3F, 0x04, "Component Device Attached" },
368 { 0x3F, 0x05, "Device Identifier Changed" },
369 { 0x3F, 0x06, "Redundancy Group Created Or Modified" },
370 { 0x3F, 0x07, "Redundancy Group Deleted" },
371 { 0x3F, 0x08, "Spare Created Or Modified" },
372 { 0x3F, 0x09, "Spare Deleted" },
373 { 0x3F, 0x0A, "Volume Set Created Or Modified" },
374 { 0x3F, 0x0B, "Volume Set Deleted" },
375 { 0x3F, 0x0C, "Volume Set Deassigned" },
376 { 0x3F, 0x0D, "Volume Set Reassigned" },
377 { 0x3F, 0x0E, "Reported LUNs Data Has Changed" },
378 { 0x3F, 0x0F, "Echo Buffer Overwritten" },
379 { 0x3F, 0x10, "Medium Loadable" },
380 { 0x3F, 0x11, "Medium Auxiliary Memory Accessible" },
381 { 0x40, 0x00, "RAM FAILURE (Should Use 40 NN)" },
382 { 0x41, 0x00, "Data Path FAILURE (Should Use 40 NN)" },
383 { 0x42, 0x00, "Power-On or Self-Test FAILURE (Should Use 40 NN)" },
384 { 0x43, 0x00, "Message Error" },
385 { 0x44, 0x00, "Internal Target Failure" },
386 { 0x45, 0x00, "Select Or Reselect Failure" },
387 { 0x46, 0x00, "Unsuccessful Soft Reset" },
388 { 0x47, 0x00, "SCSI Parity Error" },
389 { 0x47, 0x01, "Data Phase CRC Error Detected" },
390 { 0x47, 0x02, "SCSI Parity Error Detected During ST Data Phase" },
391 { 0x47, 0x03, "Information Unit iuCRC Error Detected" },
392 { 0x47, 0x04, "Asynchronous Information Protection Error Detected" },
393 { 0x47, 0x05, "Protocol Service CRC Error" },
394 { 0x47, 0x7F, "Some Commands Cleared by iSCSI Protocol Event" },
395 { 0x48, 0x00, "INITIATOR DETECTED ERROR Message Received" },
396 { 0x49, 0x00, "Invalid Message Error" },
397 { 0x4A, 0x00, "Command Phase Error" },
398 { 0x4B, 0x00, "Data Phase Error" },
399 { 0x4B, 0x01, "Illegal Target Port Transfer Tag Received" },
400 { 0x4B, 0x02, "Too Much Write Data" },
401 { 0x4B, 0x03, "ACK/NAK Timeout" },
402 { 0x4B, 0x04, "NAK Reveived" },
403 { 0x4B, 0x05, "Data Offset Error" },
404 { 0x4B, 0x06, "Initiator Response Timeout" },
405 { 0x4C, 0x00, "Logical Unit Failed Self-Configuration" },
406 { 0x4D, 0x00, "Tagged Overlapped Commands (NN = Queue Tag)" },
407 { 0x4E, 0x00, "Overlapped Commands Attempted" },
408 { 0x50, 0x00, "Write Append Error" },
409 { 0x50, 0x01, "Write Append Position Error" },
410 { 0x50, 0x02, "Position Error Related To Timing" },
411 { 0x51, 0x00, "Erase Failure" },
412 { 0x51, 0x01, "Erase Failure - Incomplete Erase Operation Detected" },
413 { 0x52, 0x00, "Cartridge Fault" },
414 { 0x53, 0x00, "Media Load or Eject Failed" },
415 { 0x53, 0x01, "Unload Tape Failure" },
416 { 0x53, 0x02, "Medium Removal Prevented" },
417 { 0x54, 0x00, "SCSI To Host System Interface Failure" },
418 { 0x55, 0x00, "System Resource Failure" },
419 { 0x55, 0x01, "System Buffer Full" },
420 { 0x55, 0x02, "Insufficient Reservation Resources" },
421 { 0x55, 0x03, "Insufficient Resources" },
422 { 0x55, 0x04, "Insufficient Registration Resources" },
423 { 0x55, 0x05, "Insufficient Access Control Resources" },
424 { 0x55, 0x06, "Auxiliary Memory Out Of Space" },
425 { 0x57, 0x00, "Unable To Recover Table-Of-Contents" },
426 { 0x58, 0x00, "Generation Does Not Exist" },
427 { 0x59, 0x00, "Updated Block Read" },
428 { 0x5A, 0x00, "Operator Request or State Change Input (Unspecified)" },
429 { 0x5A, 0x01, "Operator Medium Removal Requested" },
430 { 0x5A, 0x02, "Operator Selected Write Protect" },
431 { 0x5A, 0x03, "Operator Selected Write Permit" },
432 { 0x5B, 0x00, "Log Exception" },
433 { 0x5B, 0x01, "Threshold Condition Met" },
434 { 0x5B, 0x02, "Log Counter At Maximum" },
435 { 0x5B, 0x03, "Log List Codes Exhausted" },
436 { 0x5C, 0x00, "RPL Status Change" },
437 { 0x5C, 0x01, "Spindles Synchronized" },
438 { 0x5C, 0x02, "Spindles Not Synchronized" },
439 { 0x5D, 0x00, "Failure Prediction Threshold Exceeded" },
440 { 0x5D, 0x01, "Media Failure Prediction Threshold Exceeded" },
441 { 0x5D, 0x02, "Logical Unit Failure Prediction Threshold Exceeded" },
442 { 0x5D, 0x03, "Spare Area Exhaustion Prediction Threshold Exceeded" },
443 { 0x5D, 0x10, "Hardware Impending Failure General Hard Drive Failure" },
444 { 0x5D, 0x11, "Hardware Impending Failure Drive Error Rate Too High" },
445 { 0x5D, 0x12, "Hardware Impending Failure Data Error Rate Too High" },
446 { 0x5D, 0x13, "Hardware Impending Failure Seek Error Rate Too High" },
447 { 0x5D, 0x14, "Hardware Impending Failure Too Many Block Reassigns" },
448 { 0x5D, 0x15, "Hardware Impending Failure Access Times Too High" },
449 { 0x5D, 0x16, "Hardware Impending Failure Start Unit Times Too High" },
450 { 0x5D, 0x17, "Hardware Impending Failure Channel Parametrics" },
451 { 0x5D, 0x18, "Hardware Impending Failure Controller Detected" },
452 { 0x5D, 0x19, "Hardware Impending Failure Throughput Performance" },
453 { 0x5D, 0x1A, "Hardware Impending Failure Seek Time Performance" },
454 { 0x5D, 0x1B, "Hardware Impending Failure Spin-Up Retry Count" },
455 { 0x5D, 0x1C, "Hardware Impending Failure Drive Calibration Retry Count" },
456 { 0x5D, 0x20, "Controller Impending Failure General Hard Drive Failure" },
457 { 0x5D, 0x21, "Controller Impending Failure Drive Error Rate Too High" },
458 { 0x5D, 0x22, "Controller Impending Failure Data Error Rate Too High" },
459 { 0x5D, 0x23, "Controller Impending Failure Seek Error Rate Too High" },
460 { 0x5D, 0x24, "Controller Impending Failure Too Many Block Reassigns" },
461 { 0x5D, 0x25, "Controller Impending Failure Access Times Too High" },
462 { 0x5D, 0x26, "Controller Impending Failure Start Unit Times Too High" },
463 { 0x5D, 0x27, "Controller Impending Failure Channel Parametrics" },
464 { 0x5D, 0x28, "Controller Impending Failure Controller Detected" },
465 { 0x5D, 0x29, "Controller Impending Failure Throughput Performance" },
466 { 0x5D, 0x2A, "Controller Impending Failure Seek Time Performance" },
467 { 0x5D, 0x2B, "Controller Impending Failure Spin-Up Retry Count" },
468 { 0x5D, 0x2C, "Controller Impending Failure Drive Calibration Retry Count" },
469 { 0x5D, 0x30, "Data Channel Impending Failure General Hard Drive Failure" },
470 { 0x5D, 0x31, "Data Channel Impending Failure Drive Error Rate Too High" },
471 { 0x5D, 0x32, "Data Channel Impending Failure Data Error Rate Too High" },
472 { 0x5D, 0x33, "Data Channel Impending Failure Seek Error Rate Too High" },
473 { 0x5D, 0x34, "Data Channel Impending Failure Too Many Block Reassigns" },
474 { 0x5D, 0x35, "Data Channel Impending Failure Access Times Too High" },
475 { 0x5D, 0x36, "Data Channel Impending Failure Start Unit Times Too High" },
476 { 0x5D, 0x37, "Data Channel Impending Failure Channel Parametrics" },
477 { 0x5D, 0x38, "Data Channel Impending Failure Controller Detected" },
478 { 0x5D, 0x39, "Data Channel Impending Failure Throughput Performance" },
479 { 0x5D, 0x3A, "Data Channel Impending Failure Seek Time Performance" },
480 { 0x5D, 0x3B, "Data Channel Impending Failure Spin-Up Retry Count" },
481 { 0x5D, 0x3C, "Data Channel Impending Failure Drive Calibration Retry Count" },
482 { 0x5D, 0x40, "Servo Impending Failure General Hard Drive Failure" },
483 { 0x5D, 0x41, "Servo Impending Failure Drive Error Rate Too High" },
484 { 0x5D, 0x42, "Servo Impending Failure Data Error Rate Too High" },
485 { 0x5D, 0x43, "Servo Impending Failure Seek Error Rate Too High" },
486 { 0x5D, 0x44, "Servo Impending Failure Too Many Block Reassigns" },
487 { 0x5D, 0x45, "Servo Impending Failure Access Times Too High" },
488 { 0x5D, 0x46, "Servo Impending Failure Start Unit Times Too High" },
489 { 0x5D, 0x47, "Servo Impending Failure Channel Parametrics" },
490 { 0x5D, 0x48, "Servo Impending Failure Controller Detected" },
491 { 0x5D, 0x49, "Servo Impending Failure Throughput Performance" },
492 { 0x5D, 0x4A, "Servo Impending Failure Seek Time Performance" },
493 { 0x5D, 0x4B, "Servo Impending Failure Spin-Up Retry Count" },
494 { 0x5D, 0x4C, "Servo Impending Failure Drive Calibration Retry Count" },
495 { 0x5D, 0x50, "Spindle Impending Failure General Hard Drive Failure" },
496 { 0x5D, 0x51, "Spindle Impending Failure Drive Error Rate Too High" },
497 { 0x5D, 0x52, "Spindle Impending Failure Data Error Rate Too High" },
498 { 0x5D, 0x53, "Spindle Impending Failure Seek Error Rate Too High" },
499 { 0x5D, 0x54, "Spindle Impending Failure Too Many Block Reassigns" },
500 { 0x5D, 0x55, "Spindle Impending Failure Access Times Too High" },
501 { 0x5D, 0x56, "Spindle Impending Failure Start Unit Times Too High" },
502 { 0x5D, 0x57, "Spindle Impending Failure Channel Parametrics" },
503 { 0x5D, 0x58, "Spindle Impending Failure Controller Detected" },
504 { 0x5D, 0x59, "Spindle Impending Failure Throughput Performance" },
505 { 0x5D, 0x5A, "Spindle Impending Failure Seek Time Performance" },
506 { 0x5D, 0x5B, "Spindle Impending Failure Spin-Up Retry Count" },
507 { 0x5D, 0x5C, "Spindle Impending Failure Drive Calibration Retry Count" },
508 { 0x5D, 0x60, "Firmware Impending Failure General Hard Drive Failure" },
509 { 0x5D, 0x61, "Firmware Impending Failure Drive Error Rate Too High" },
510 { 0x5D, 0x62, "Firmware Impending Failure Data Error Rate Too High" },
511 { 0x5D, 0x63, "Firmware Impending Failure Seek Error Rate Too High" },
512 { 0x5D, 0x64, "Firmware Impending Failure Too Many Block Reassigns" },
513 { 0x5D, 0x65, "Firmware Impending Failure Access Times Too High" },
514 { 0x5D, 0x66, "Firmware Impending Failure Start Unit Times Too High" },
515 { 0x5D, 0x67, "Firmware Impending Failure Channel Parametrics" },
516 { 0x5D, 0x68, "Firmware Impending Failure Controller Detected" },
517 { 0x5D, 0x69, "Firmware Impending Failure Throughput Performance" },
518 { 0x5D, 0x6A, "Firmware Impending Failure Seek Time Performance" },
519 { 0x5D, 0x6B, "Firmware Impending Failure Spin-Up Retry Count" },
520 { 0x5D, 0x6C, "Firmware Impending Failure Drive Calibration Retry Count" },
521 { 0x5D, 0xFF, "Failure Prediction Threshold Exceeded (False)" },
522 { 0x5E, 0x00, "Low Power Condition On" },
523 { 0x5E, 0x01, "Idle Condition Activated By Timer" },
524 { 0x5E, 0x02, "Standby Condition Activated By Timer" },
525 { 0x5E, 0x03, "Idle Condition Activated By Command" },
526 { 0x5E, 0x04, "Standby Condition Activated By Command" },
527 { 0x5E, 0x41, "Power State Change To Active" },
528 { 0x5E, 0x42, "Power State Change To Idle" },
529 { 0x5E, 0x43, "Power State Change To Standby" },
530 { 0x5E, 0x45, "Power State Change To Sleep" },
531 { 0x5E, 0x47, "Power State Change To Device Control" },
532 { 0x60, 0x00, "Lamp Failure" },
533 { 0x61, 0x00, "Video Acquisition Error" },
534 { 0x61, 0x01, "Unable To Acquire Video" },
535 { 0x61, 0x02, "Out Of Focus" },
536 { 0x62, 0x00, "Scan Head Positioning Error" },
537 { 0x63, 0x00, "End Of User Area Encountered On This Track" },
538 { 0x63, 0x01, "Packet Does Not Fit In Available Space" },
539 { 0x64, 0x00, "Illegal Mode For This Track" },
540 { 0x64, 0x01, "Invalid Packet Size" },
541 { 0x65, 0x00, "Voltage Fault" },
542 { 0x66, 0x00, "Automatic Document Feeder Cover Up" },
543 { 0x66, 0x01, "Automatic Document Feeder Lift Up" },
544 { 0x66, 0x02, "Document Jam In Automatic Document Feeder" },
545 { 0x66, 0x03, "Document Misfeed In Automatic Document Feeder" },
546 { 0x67, 0x00, "Configuration Failure" },
547 { 0x67, 0x01, "Configuration Of Incapable Logical Units Failed" },
548 { 0x67, 0x02, "Add Logical Unit Failed" },
549 { 0x67, 0x03, "Modification Of Logical Unit Failed" },
550 { 0x67, 0x04, "Exchange Of Logical Unit Failed" },
551 { 0x67, 0x05, "Remove Of Logical Unit Failed" },
552 { 0x67, 0x06, "Attachment Of Logical Unit Failed" },
553 { 0x67, 0x07, "Creation of Logical Unit Failed" },
554 { 0x67, 0x08, "Assign Failure Occurred" },
555 { 0x67, 0x09, "Multiply Assigned Logical Unit" },
556 { 0x67, 0x0A, "Set Target Port Groups Command Failed" },
557 { 0x68, 0x00, "Logical Unit Not Configured" },
558 { 0x69, 0x00, "Data Loss On Logical Unit" },
559 { 0x69, 0x01, "Multiple Logical Unit Failures" },
560 { 0x69, 0x02, "Parity/Data Mismatch" },
561 { 0x6A, 0x00, "Informational, Refer To Log" },
562 { 0x6B, 0x00, "State Change Has Occurred" },
563 { 0x6B, 0x01, "Redundancy Level Got Better" },
564 { 0x6B, 0x02, "Redundancy Level Got Worse" },
565 { 0x6C, 0x00, "Rebuild Failure Occurred" },
566 { 0x6D, 0x00, "Recalculate Failure Occurred" },
567 { 0x6E, 0x00, "Command To Logical Unit Failed" },
568 { 0x6F, 0x00, "Copy Protection Key Exchange Failure - Authentication Failure" },
569 { 0x6F, 0x01, "Copy Protection Key Exchange Failure - Key Not Present" },
570 { 0x6F, 0x02, "Copy Protection Key Exchange Failure - Key Not Established" },
571 { 0x6F, 0x03, "Read Of Scrambled Sector Without Authentication" },
572 { 0x6F, 0x04, "Media Region Code Is Mismatched To Logical Unit Region" },
573 { 0x6F, 0x05, "Drive Region Must Be Permanent/Region Reset Count Error" },
574 { 0x70, 0x00, "Decompression Exception Short Algorithm ID Of NN" },
575 { 0x71, 0x00, "Decompression Exception Long Algorithm ID" },
576 { 0x72, 0x00, "Session Fixation Error" },
577 { 0x72, 0x01, "Session Fixation Error Writing Lead-In" },
578 { 0x72, 0x02, "Session Fixation Error Writing Lead-Out" },
579 { 0x72, 0x03, "Session Fixation Error - Incomplete Track In Session" },
580 { 0x72, 0x04, "Empty Or Partially Written Reserved Track" },
581 { 0x72, 0x05, "No More Track Reservations Allowed" },
582 { 0x73, 0x00, "CD Control Error" },
583 { 0x73, 0x01, "Power Calibration Area Almost Full" },
584 { 0x73, 0x02, "Power Calibration Area Is Full" },
585 { 0x73, 0x03, "Power Calibration Area Error" },
586 { 0x73, 0x04, "Program Memory Area Update Failure" },
587 { 0x73, 0x05, "Program Memory Area Is Full" },
588 { 0x73, 0x06, "RMA/PMA Is Almost Full" },
593 /* needs to move to a compat.c one day */
597 strlcpy(char *dst
, const char *src
, size_t size
)
599 strncpy(dst
, src
, size
-1);
609 asc2ascii(u_char asc
, u_char ascq
, char *result
, size_t l
)
613 while (adesc
[i
].description
!= NULL
) {
614 if (adesc
[i
].asc
== asc
&& adesc
[i
].ascq
== ascq
)
618 if (adesc
[i
].description
== NULL
) {
619 if (asc
== 0x40 && ascq
!= 0)
620 (void) snprintf(result
, l
,
621 "Diagnostic Failure on Component 0x%02x",
624 (void) snprintf(result
, l
, "ASC 0x%02x ASCQ 0x%02x",
625 asc
& 0xff, ascq
& 0xff);
627 (void) strlcpy(result
, adesc
[i
].description
, l
);
632 uscsi_print_sense_data(uint8_t *s
, int slen
, int verbosity
)
639 * Basics - print out SENSE KEY
641 printf(" SENSE KEY: %s", uscsi_decode_sense(s
, 0));
644 * Print out, unqualified but aligned, FMK, EOM and ILI status.
650 if (s
[2] & SSD_FILEMARK
) {
651 printf("%c Filemark Detected", pad
);
654 if (s
[2] & SSD_EOM
) {
655 printf("%c EOM Detected", pad
);
659 printf("%c Incorrect Length Indicator Set", pad
);
663 * Now we should figure out, based upon device type, how
664 * to format the information field. Unfortunately, that's
665 * not convenient here, so we'll print it as a signed
668 //info = _4btol(&s[3]);
669 info
= (s
[3] << 24) | (s
[4] << 16) | (s
[5] << 8) | s
[6];
671 printf("\n INFO FIELD: %d", info
);
674 * Now we check additional length to see whether there is
675 * more information to extract.
678 /* enough for command specific information? */
679 if (((unsigned int) s
[7]) < 4) {
683 // info = _4btol(&s[8]);
684 info
= (s
[8] << 24) | (s
[9] << 16) | (s
[10] << 8) | s
[11];
686 printf("\n COMMAND INFO: %d (0x%x)", info
, info
);
689 * Decode ASC && ASCQ info, plus FRU, plus the rest...
692 sbs
= uscsi_decode_sense(s
, 1);
694 printf("\n ASC/ASCQ: %s", sbs
);
696 printf("\n FRU CODE: 0x%x", s
[14] & 0xff);
697 sbs
= uscsi_decode_sense(s
, 3);
699 printf("\n SKSV: %s", sbs
);
701 if (verbosity
== 0) {
707 * Now figure whether we should print any additional informtion.
709 * Where should we start from? If we had SKSV data,
710 * start from offset 18, else from offset 15.
712 * From that point until the end of the buffer, check for any
713 * nonzero data. If we have some, go back and print the lot,
714 * otherwise we're done.
720 for (j
= i
; j
< slen
; j
++)
726 printf("\n Additional Sense Information (byte %d out...):\n", i
);
728 printf("\n\t%2d:", i
);
731 printf("\n\t%2d:", i
);
740 printf("\n\t%2d:", i
);
742 printf(" 0x%02x", s
[i
] & 0xff);
752 uscsi_decode_sense(void *sinfo
, int flag
)
754 unsigned char *snsbuf
;
756 static char rqsbuf
[132];
760 snsbuf
= (unsigned char *) sinfo
;
761 if (flag
== 0 || flag
== 2 || flag
== 3)
762 skey
= snsbuf
[2] & 0xf;
763 if (flag
== 0) { /* Sense Key Only */
764 (void) strlcpy(rqsbuf
, sense_keys
[skey
], sizeof(rqsbuf
));
766 } else if (flag
== 1) { /* ASC/ASCQ Only */
767 asc2ascii(snsbuf
[12], snsbuf
[13], rqsbuf
, sizeof(rqsbuf
));
769 } else if (flag
== 2) { /* Sense Key && ASC/ASCQ */
770 auto char localbuf
[64];
771 asc2ascii(snsbuf
[12], snsbuf
[13], localbuf
, sizeof(localbuf
));
772 (void) snprintf(rqsbuf
, sizeof(rqsbuf
), "%s, %s",
773 sense_keys
[skey
], localbuf
);
775 } else if (flag
== 3 && snsbuf
[7] >= 9 && (snsbuf
[15] & 0x80)) {
780 case SKEY_ILLEGAL_REQUEST
:
781 if (snsbuf
[15] & 0x8)
782 (void)snprintf(rqsbuf
, sizeof(rqsbuf
),
783 "Error in %s, Offset %d, bit %d",
784 (snsbuf
[15] & 0x40)? "CDB" : "Parameters",
785 (snsbuf
[16] & 0xff) << 8 |
786 (snsbuf
[17] & 0xff), snsbuf
[15] & 0x7);
788 (void)snprintf(rqsbuf
, sizeof(rqsbuf
),
789 "Error in %s, Offset %d",
790 (snsbuf
[15] & 0x40)? "CDB" : "Parameters",
791 (snsbuf
[16] & 0xff) << 8 |
792 (snsbuf
[17] & 0xff));
795 case SKEY_RECOVERED_ERROR
:
796 case SKEY_MEDIUM_ERROR
:
797 case SKEY_HARDWARE_ERROR
:
798 (void)snprintf(rqsbuf
, sizeof(rqsbuf
),
799 "Actual Retry Count: %d",
800 (snsbuf
[16] & 0xff) << 8 | (snsbuf
[17] & 0xff));
804 (void)snprintf(rqsbuf
, sizeof(rqsbuf
),
805 "Progress Indicator: %d",
806 (snsbuf
[16] & 0xff) << 8 | (snsbuf
[17] & 0xff));
818 uscsi_print_sense(const char *name
, u_char
*req_cmd
, int req_cmdlen
,
819 u_char
*req_sense
, int req_senselen_used
, int verbosity
)
823 printf("%s: Check Condition on CDB:", name
);
824 for (i
= 0; i
< req_cmdlen
; i
++)
825 printf(" %02x", req_cmd
[i
]);
827 uscsi_print_sense_data(req_sense
, req_senselen_used
, verbosity
);