The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/scsipi/scsipi_verbose.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: ba67383187ed2c275a39050d7ad69e1a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.