1 /* 2 * Implementation of Utility functions for all SCSI device types. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 2003 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions, and the following disclaimer, 13 * without modification, immediately at the beginning of the file. 14 * 2. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.54 2009/01/14 21:25:17 trasz Exp $ 30 */ 31 32 #include <sys/param.h> 33 34 #ifdef _KERNEL 35 36 #include <opt_scsi.h> 37 #include <sys/systm.h> 38 #include <sys/libkern.h> 39 #include <sys/kernel.h> 40 #include <sys/sysctl.h> 41 42 #else 43 44 #include <errno.h> 45 #include <stdio.h> 46 #include <stdlib.h> 47 #include <string.h> 48 49 #define ksnprintf snprintf /* ick, userland uses us too */ 50 #define kprintf printf 51 #define kbsearch bsearch 52 53 #endif 54 55 #include "../cam.h" 56 #include "../cam_ccb.h" 57 #include "../cam_xpt.h" 58 #include "scsi_all.h" 59 #include <sys/sbuf.h> 60 #ifndef _KERNEL 61 #include <sys/camlib.h> 62 63 #ifndef FALSE 64 #define FALSE 0 65 #endif /* FALSE */ 66 #ifndef TRUE 67 #define TRUE 1 68 #endif /* TRUE */ 69 #define ERESTART -1 /* restart syscall */ 70 #define EJUSTRETURN -2 /* don't modify regs, just return */ 71 #endif /* !_KERNEL */ 72 73 /* 74 * This is the default number of milliseconds we wait for devices to settle 75 * after a SCSI bus reset. 76 */ 77 #ifndef SCSI_DELAY 78 #define SCSI_DELAY 2000 79 #endif 80 /* 81 * All devices need _some_ sort of bus settle delay, so we'll set it to 82 * a minimum value of 100ms. Note that this is pertinent only for SPI- 83 * not transport like Fibre Channel or iSCSI where 'delay' is completely 84 * meaningless. 85 */ 86 #ifndef SCSI_MIN_DELAY 87 #define SCSI_MIN_DELAY 100 88 #endif 89 /* 90 * Make sure the user isn't using seconds instead of milliseconds. 91 */ 92 #if (SCSI_DELAY < SCSI_MIN_DELAY && SCSI_DELAY != 0) 93 #error "SCSI_DELAY is in milliseconds, not seconds! Please use a larger value" 94 #endif 95 96 int scsi_delay; 97 98 static int ascentrycomp(const void *key, const void *member); 99 static int senseentrycomp(const void *key, const void *member); 100 static void fetchtableentries(int sense_key, int asc, int ascq, 101 struct scsi_inquiry_data *, 102 const struct sense_key_table_entry **, 103 const struct asc_table_entry **); 104 #ifdef _KERNEL 105 static void init_scsi_delay(void); 106 static int sysctl_scsi_delay(SYSCTL_HANDLER_ARGS); 107 static int set_scsi_delay(int delay); 108 #endif 109 110 #if !defined(SCSI_NO_OP_STRINGS) 111 112 #define D (1 << T_DIRECT) 113 #define T (1 << T_SEQUENTIAL) 114 #define L (1 << T_PRINTER) 115 #define P (1 << T_PROCESSOR) 116 #define W (1 << T_WORM) 117 #define R (1 << T_CDROM) 118 #define O (1 << T_OPTICAL) 119 #define M (1 << T_CHANGER) 120 #define A (1 << T_STORARRAY) 121 #define E (1 << T_ENCLOSURE) 122 #define B (1 << T_RBC) 123 #define K (1 << T_OCRW) 124 #define V (1 << T_ADC) 125 #define F (1 << T_OSD) 126 #define S (1 << T_SCANNER) 127 #define C (1 << T_COMM) 128 129 #define ALL (D | T | L | P | W | R | O | M | A | E | B | K | V | F | S | C) 130 131 static struct op_table_entry plextor_cd_ops[] = { 132 { 0xD8, R, "CD-DA READ" } 133 }; 134 135 static struct scsi_op_quirk_entry scsi_op_quirk_table[] = { 136 { 137 /* 138 * I believe that 0xD8 is the Plextor proprietary command 139 * to read CD-DA data. I'm not sure which Plextor CDROM 140 * models support the command, though. I know for sure 141 * that the 4X, 8X, and 12X models do, and presumably the 142 * 12-20X does. I don't know about any earlier models, 143 * though. If anyone has any more complete information, 144 * feel free to change this quirk entry. 145 */ 146 {T_CDROM, SIP_MEDIA_REMOVABLE, "PLEXTOR", "CD-ROM PX*", "*"}, 147 sizeof(plextor_cd_ops)/sizeof(struct op_table_entry), 148 plextor_cd_ops 149 } 150 }; 151 152 static struct op_table_entry scsi_op_codes[] = { 153 /* 154 * From: http://www.t10.org/lists/op-num.txt 155 * Modifications by Kenneth Merry (ken@FreeBSD.ORG) 156 * and Jung-uk Kim (jkim@FreeBSD.org) 157 * 158 * Note: order is important in this table, scsi_op_desc() currently 159 * depends on the opcodes in the table being in order to save 160 * search time. 161 * Note: scanner and comm. devices are carried over from the previous 162 * version because they were removed in the latest spec. 163 */ 164 /* File: OP-NUM.TXT 165 * 166 * SCSI Operation Codes 167 * Numeric Sorted Listing 168 * as of 3/11/08 169 * 170 * D - DIRECT ACCESS DEVICE (SBC-2) device column key 171 * .T - SEQUENTIAL ACCESS DEVICE (SSC-2) ----------------- 172 * . L - PRINTER DEVICE (SSC) M = Mandatory 173 * . P - PROCESSOR DEVICE (SPC) O = Optional 174 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2) V = Vendor spec. 175 * . . R - CD/DVE DEVICE (MMC-3) Z = Obsolete 176 * . . O - OPTICAL MEMORY DEVICE (SBC-2) 177 * . . .M - MEDIA CHANGER DEVICE (SMC-2) 178 * . . . A - STORAGE ARRAY DEVICE (SCC-2) 179 * . . . .E - ENCLOSURE SERVICES DEVICE (SES) 180 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC) 181 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW) 182 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC) 183 * . . . . .F - OBJECT-BASED STORAGE (OSD) 184 * OP DTLPWROMAEBKVF Description 185 * -- -------------- ---------------------------------------------- */ 186 /* 00 MMMMMMMMMMMMMM TEST UNIT READY */ 187 { 0x00, ALL, "TEST UNIT READY" }, 188 /* 01 M REWIND */ 189 { 0x01, T, "REWIND" }, 190 /* 01 Z V ZZZZ REZERO UNIT */ 191 { 0x01, D | W | R | O | M, "REZERO UNIT" }, 192 /* 02 VVVVVV V */ 193 /* 03 MMMMMMMMMMOMMM REQUEST SENSE */ 194 { 0x03, ALL, "REQUEST SENSE" }, 195 /* 04 M OO FORMAT UNIT */ 196 { 0x04, D | R | O, "FORMAT UNIT" }, 197 /* 04 O FORMAT MEDIUM */ 198 { 0x04, T, "FORMAT MEDIUM" }, 199 /* 04 O FORMAT */ 200 { 0x04, L, "FORMAT" }, 201 /* 05 VMVVVV V READ BLOCK LIMITS */ 202 { 0x05, T, "READ BLOCK LIMITS" }, 203 /* 06 VVVVVV V */ 204 /* 07 OVV O OV REASSIGN BLOCKS */ 205 { 0x07, D | W | O, "REASSIGN BLOCKS" }, 206 /* 07 O INITIALIZE ELEMENT STATUS */ 207 { 0x07, M, "INITIALIZE ELEMENT STATUS" }, 208 /* 08 MOV O OV READ(6) */ 209 { 0x08, D | T | W | O, "READ(6)" }, 210 /* 08 O RECEIVE */ 211 { 0x08, P, "RECEIVE" }, 212 /* 08 GET MESSAGE(6) */ 213 { 0x08, C, "GET MESSAGE(6)" }, 214 /* 09 VVVVVV V */ 215 /* 0A OO O OV WRITE(6) */ 216 { 0x0A, D | T | W | O, "WRITE(6)" }, 217 /* 0A M SEND(6) */ 218 { 0x0A, P, "SEND(6)" }, 219 /* 0A SEND MESSAGE(6) */ 220 { 0x0A, C, "SEND MESSAGE(6)" }, 221 /* 0A M PRINT */ 222 { 0x0A, L, "PRINT" }, 223 /* 0B Z ZOZV SEEK(6) */ 224 { 0x0B, D | W | R | O, "SEEK(6)" }, 225 /* 0B O SET CAPACITY */ 226 { 0x0B, T, "SET CAPACITY" }, 227 /* 0B O SLEW AND PRINT */ 228 { 0x0B, L, "SLEW AND PRINT" }, 229 /* 0C VVVVVV V */ 230 /* 0D VVVVVV V */ 231 /* 0E VVVVVV V */ 232 /* 0F VOVVVV V READ REVERSE(6) */ 233 { 0x0F, T, "READ REVERSE(6)" }, 234 /* 10 VM VVV WRITE FILEMARKS(6) */ 235 { 0x10, T, "WRITE FILEMARKS(6)" }, 236 /* 10 O SYNCHRONIZE BUFFER */ 237 { 0x10, L, "SYNCHRONIZE BUFFER" }, 238 /* 11 VMVVVV SPACE(6) */ 239 { 0x11, T, "SPACE(6)" }, 240 /* 12 MMMMMMMMMMMMMM INQUIRY */ 241 { 0x12, ALL, "INQUIRY" }, 242 /* 13 V VVVV */ 243 /* 13 O VERIFY(6) */ 244 { 0x13, T, "VERIFY(6)" }, 245 /* 14 VOOVVV RECOVER BUFFERED DATA */ 246 { 0x14, T | L, "RECOVER BUFFERED DATA" }, 247 /* 15 OMO O OOOO OO MODE SELECT(6) */ 248 { 0x15, ALL & ~(P | R | B | F), "MODE SELECT(6)" }, 249 /* 16 ZZMZO OOOZ O RESERVE(6) */ 250 { 0x16, ALL & ~(R | B | V | F | C), "RESERVE(6)" }, 251 /* 16 Z RESERVE ELEMENT(6) */ 252 { 0x16, M, "RESERVE ELEMENT(6)" }, 253 /* 17 ZZMZO OOOZ O RELEASE(6) */ 254 { 0x17, ALL & ~(R | B | V | F | C), "RELEASE(6)" }, 255 /* 17 Z RELEASE ELEMENT(6) */ 256 { 0x17, M, "RELEASE ELEMENT(6)" }, 257 /* 18 ZZZZOZO Z COPY */ 258 { 0x18, D | T | L | P | W | R | O | K | S, "COPY" }, 259 /* 19 VMVVVV ERASE(6) */ 260 { 0x19, T, "ERASE(6)" }, 261 /* 1A OMO O OOOO OO MODE SENSE(6) */ 262 { 0x1A, ALL & ~(P | R | B | F), "MODE SENSE(6)" }, 263 /* 1B O OOO O MO O START STOP UNIT */ 264 { 0x1B, D | W | R | O | A | B | K | F, "START STOP UNIT" }, 265 /* 1B O M LOAD UNLOAD */ 266 { 0x1B, T | V, "LOAD UNLOAD" }, 267 /* 1B SCAN */ 268 { 0x1B, S, "SCAN" }, 269 /* 1B O STOP PRINT */ 270 { 0x1B, L, "STOP PRINT" }, 271 /* 1B O OPEN/CLOSE IMPORT/EXPORT ELEMENT */ 272 { 0x1B, M, "OPEN/CLOSE IMPORT/EXPORT ELEMENT" }, 273 /* 1C OOOOO OOOM OOO RECEIVE DIAGNOSTIC RESULTS */ 274 { 0x1C, ALL & ~(R | B), "RECEIVE DIAGNOSTIC RESULTS" }, 275 /* 1D MMMMM MMOM MMM SEND DIAGNOSTIC */ 276 { 0x1D, ALL & ~(R | B), "SEND DIAGNOSTIC" }, 277 /* 1E OO OOOO O O PREVENT ALLOW MEDIUM REMOVAL */ 278 { 0x1E, D | T | W | R | O | M | K | F, "PREVENT ALLOW MEDIUM REMOVAL" }, 279 /* 1F */ 280 /* 20 V VVV V */ 281 /* 21 V VVV V */ 282 /* 22 V VVV V */ 283 /* 23 V V V V */ 284 /* 23 O READ FORMAT CAPACITIES */ 285 { 0x23, R, "READ FORMAT CAPACITIES" }, 286 /* 24 V VV SET WINDOW */ 287 { 0x24, S, "SET WINDOW" }, 288 /* 25 M M M M READ CAPACITY(10) */ 289 { 0x25, D | W | O | B, "READ CAPACITY(10)" }, 290 /* 25 O READ CAPACITY */ 291 { 0x25, R, "READ CAPACITY" }, 292 /* 25 M READ CARD CAPACITY */ 293 { 0x25, K, "READ CARD CAPACITY" }, 294 /* 25 GET WINDOW */ 295 { 0x25, S, "GET WINDOW" }, 296 /* 26 V VV */ 297 /* 27 V VV */ 298 /* 28 M MOM MM READ(10) */ 299 { 0x28, D | W | R | O | B | K | S, "READ(10)" }, 300 /* 28 GET MESSAGE(10) */ 301 { 0x28, C, "GET MESSAGE(10)" }, 302 /* 29 V VVO READ GENERATION */ 303 { 0x29, O, "READ GENERATION" }, 304 /* 2A O MOM MO WRITE(10) */ 305 { 0x2A, D | W | R | O | B | K, "WRITE(10)" }, 306 /* 2A SEND(10) */ 307 { 0x2A, S, "SEND(10)" }, 308 /* 2A SEND MESSAGE(10) */ 309 { 0x2A, C, "SEND MESSAGE(10)" }, 310 /* 2B Z OOO O SEEK(10) */ 311 { 0x2B, D | W | R | O | K, "SEEK(10)" }, 312 /* 2B O LOCATE(10) */ 313 { 0x2B, T, "LOCATE(10)" }, 314 /* 2B O POSITION TO ELEMENT */ 315 { 0x2B, M, "POSITION TO ELEMENT" }, 316 /* 2C V OO ERASE(10) */ 317 { 0x2C, R | O, "ERASE(10)" }, 318 /* 2D O READ UPDATED BLOCK */ 319 { 0x2D, O, "READ UPDATED BLOCK" }, 320 /* 2D V */ 321 /* 2E O OOO MO WRITE AND VERIFY(10) */ 322 { 0x2E, D | W | R | O | B | K, "WRITE AND VERIFY(10)" }, 323 /* 2F O OOO VERIFY(10) */ 324 { 0x2F, D | W | R | O, "VERIFY(10)" }, 325 /* 30 Z ZZZ SEARCH DATA HIGH(10) */ 326 { 0x30, D | W | R | O, "SEARCH DATA HIGH(10)" }, 327 /* 31 Z ZZZ SEARCH DATA EQUAL(10) */ 328 { 0x31, D | W | R | O, "SEARCH DATA EQUAL(10)" }, 329 /* 31 OBJECT POSITION */ 330 { 0x31, S, "OBJECT POSITION" }, 331 /* 32 Z ZZZ SEARCH DATA LOW(10) */ 332 { 0x32, D | W | R | O, "SEARCH DATA LOW(10)" }, 333 /* 33 Z OZO SET LIMITS(10) */ 334 { 0x33, D | W | R | O, "SET LIMITS(10)" }, 335 /* 34 O O O O PRE-FETCH(10) */ 336 { 0x34, D | W | O | K, "PRE-FETCH(10)" }, 337 /* 34 M READ POSITION */ 338 { 0x34, T, "READ POSITION" }, 339 /* 34 GET DATA BUFFER STATUS */ 340 { 0x34, S, "GET DATA BUFFER STATUS" }, 341 /* 35 O OOO MO SYNCHRONIZE CACHE(10) */ 342 { 0x35, D | W | R | O | B | K, "SYNCHRONIZE CACHE(10)" }, 343 /* 36 Z O O O LOCK UNLOCK CACHE(10) */ 344 { 0x36, D | W | O | K, "LOCK UNLOCK CACHE(10)" }, 345 /* 37 O O READ DEFECT DATA(10) */ 346 { 0x37, D | O, "READ DEFECT DATA(10)" }, 347 /* 37 O INITIALIZE ELEMENT STATUS WITH RANGE */ 348 { 0x37, M, "INITIALIZE ELEMENT STATUS WITH RANGE" }, 349 /* 38 O O O MEDIUM SCAN */ 350 { 0x38, W | O | K, "MEDIUM SCAN" }, 351 /* 39 ZZZZOZO Z COMPARE */ 352 { 0x39, D | T | L | P | W | R | O | K | S, "COMPARE" }, 353 /* 3A ZZZZOZO Z COPY AND VERIFY */ 354 { 0x3A, D | T | L | P | W | R | O | K | S, "COPY AND VERIFY" }, 355 /* 3B OOOOOOOOOOMOOO WRITE BUFFER */ 356 { 0x3B, ALL, "WRITE BUFFER" }, 357 /* 3C OOOOOOOOOO OOO READ BUFFER */ 358 { 0x3C, ALL & ~(B), "READ BUFFER" }, 359 /* 3D O UPDATE BLOCK */ 360 { 0x3D, O, "UPDATE BLOCK" }, 361 /* 3E O O O READ LONG(10) */ 362 { 0x3E, D | W | O, "READ LONG(10)" }, 363 /* 3F O O O WRITE LONG(10) */ 364 { 0x3F, D | W | O, "WRITE LONG(10)" }, 365 /* 40 ZZZZOZOZ CHANGE DEFINITION */ 366 { 0x40, D | T | L | P | W | R | O | M | S | C, "CHANGE DEFINITION" }, 367 /* 41 O WRITE SAME(10) */ 368 { 0x41, D, "WRITE SAME(10)" }, 369 /* 42 O READ SUB-CHANNEL */ 370 { 0x42, R, "READ SUB-CHANNEL" }, 371 /* 43 O READ TOC/PMA/ATIP */ 372 { 0x43, R, "READ TOC/PMA/ATIP" }, 373 /* 44 M M REPORT DENSITY SUPPORT */ 374 { 0x44, T | V, "REPORT DENSITY SUPPORT" }, 375 /* 44 READ HEADER */ 376 /* 45 O PLAY AUDIO(10) */ 377 { 0x45, R, "PLAY AUDIO(10)" }, 378 /* 46 M GET CONFIGURATION */ 379 { 0x46, R, "GET CONFIGURATION" }, 380 /* 47 O PLAY AUDIO MSF */ 381 { 0x47, R, "PLAY AUDIO MSF" }, 382 /* 48 */ 383 /* 49 */ 384 /* 4A M GET EVENT STATUS NOTIFICATION */ 385 { 0x4A, R, "GET EVENT STATUS NOTIFICATION" }, 386 /* 4B O PAUSE/RESUME */ 387 { 0x4B, R, "PAUSE/RESUME" }, 388 /* 4C OOOOO OOOO OOO LOG SELECT */ 389 { 0x4C, ALL & ~(R | B), "LOG SELECT" }, 390 /* 4D OOOOO OOOO OMO LOG SENSE */ 391 { 0x4D, ALL & ~(R | B), "LOG SENSE" }, 392 /* 4E O STOP PLAY/SCAN */ 393 { 0x4E, R, "STOP PLAY/SCAN" }, 394 /* 4F */ 395 /* 50 O XDWRITE(10) */ 396 { 0x50, D, "XDWRITE(10)" }, 397 /* 51 O XPWRITE(10) */ 398 { 0x51, D, "XPWRITE(10)" }, 399 /* 51 O READ DISC INFORMATION */ 400 { 0x51, R, "READ DISC INFORMATION" }, 401 /* 52 O XDREAD(10) */ 402 { 0x52, D, "XDREAD(10)" }, 403 /* 52 O READ TRACK INFORMATION */ 404 { 0x52, R, "READ TRACK INFORMATION" }, 405 /* 53 O RESERVE TRACK */ 406 { 0x53, R, "RESERVE TRACK" }, 407 /* 54 O SEND OPC INFORMATION */ 408 { 0x54, R, "SEND OPC INFORMATION" }, 409 /* 55 OOO OMOOOOMOMO MODE SELECT(10) */ 410 { 0x55, ALL & ~(P), "MODE SELECT(10)" }, 411 /* 56 ZZMZO OOOZ RESERVE(10) */ 412 { 0x56, ALL & ~(R | B | K | V | F | C), "RESERVE(10)" }, 413 /* 56 Z RESERVE ELEMENT(10) */ 414 { 0x56, M, "RESERVE ELEMENT(10)" }, 415 /* 57 ZZMZO OOOZ RELEASE(10) */ 416 { 0x57, ALL & ~(R | B | K | V | F | C), "RELEASE(10)" }, 417 /* 57 Z RELEASE ELEMENT(10) */ 418 { 0x57, M, "RELEASE ELEMENT(10)" }, 419 /* 58 O REPAIR TRACK */ 420 { 0x58, R, "REPAIR TRACK" }, 421 /* 59 */ 422 /* 5A OOO OMOOOOMOMO MODE SENSE(10) */ 423 { 0x5A, ALL & ~(P), "MODE SENSE(10)" }, 424 /* 5B O CLOSE TRACK/SESSION */ 425 { 0x5B, R, "CLOSE TRACK/SESSION" }, 426 /* 5C O READ BUFFER CAPACITY */ 427 { 0x5C, R, "READ BUFFER CAPACITY" }, 428 /* 5D O SEND CUE SHEET */ 429 { 0x5D, R, "SEND CUE SHEET" }, 430 /* 5E OOOOO OOOO M PERSISTENT RESERVE IN */ 431 { 0x5E, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE IN" }, 432 /* 5F OOOOO OOOO M PERSISTENT RESERVE OUT */ 433 { 0x5F, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE OUT" }, 434 /* 7E OO O OOOO O extended CDB */ 435 { 0x7E, D | T | R | M | A | E | B | V, "extended CDB" }, 436 /* 7F O M variable length CDB (more than 16 bytes) */ 437 { 0x7F, D | F, "variable length CDB (more than 16 bytes)" }, 438 /* 80 Z XDWRITE EXTENDED(16) */ 439 { 0x80, D, "XDWRITE EXTENDED(16)" }, 440 /* 80 M WRITE FILEMARKS(16) */ 441 { 0x80, T, "WRITE FILEMARKS(16)" }, 442 /* 81 Z REBUILD(16) */ 443 { 0x81, D, "REBUILD(16)" }, 444 /* 81 O READ REVERSE(16) */ 445 { 0x81, T, "READ REVERSE(16)" }, 446 /* 82 Z REGENERATE(16) */ 447 { 0x82, D, "REGENERATE(16)" }, 448 /* 83 OOOOO O OO EXTENDED COPY */ 449 { 0x83, D | T | L | P | W | O | K | V, "EXTENDED COPY" }, 450 /* 84 OOOOO O OO RECEIVE COPY RESULTS */ 451 { 0x84, D | T | L | P | W | O | K | V, "RECEIVE COPY RESULTS" }, 452 /* 85 O O O ATA COMMAND PASS THROUGH(16) */ 453 { 0x85, D | R | B, "ATA COMMAND PASS THROUGH(16)" }, 454 /* 86 OO OO OOOOOOO ACCESS CONTROL IN */ 455 { 0x86, ALL & ~(L | R | F), "ACCESS CONTROL IN" }, 456 /* 87 OO OO OOOOOOO ACCESS CONTROL OUT */ 457 { 0x87, ALL & ~(L | R | F), "ACCESS CONTROL OUT" }, 458 /* 459 * XXX READ(16)/WRITE(16) were not listed for CD/DVE in op-num.txt 460 * but we had it since r1.40. Do we really want them? 461 */ 462 /* 88 MM O O O READ(16) */ 463 { 0x88, D | T | W | O | B, "READ(16)" }, 464 /* 89 */ 465 /* 8A OM O O O WRITE(16) */ 466 { 0x8A, D | T | W | O | B, "WRITE(16)" }, 467 /* 8B O ORWRITE */ 468 { 0x8B, D, "ORWRITE" }, 469 /* 8C OO O OO O M READ ATTRIBUTE */ 470 { 0x8C, D | T | W | O | M | B | V, "READ ATTRIBUTE" }, 471 /* 8D OO O OO O O WRITE ATTRIBUTE */ 472 { 0x8D, D | T | W | O | M | B | V, "WRITE ATTRIBUTE" }, 473 /* 8E O O O O WRITE AND VERIFY(16) */ 474 { 0x8E, D | W | O | B, "WRITE AND VERIFY(16)" }, 475 /* 8F OO O O O VERIFY(16) */ 476 { 0x8F, D | T | W | O | B, "VERIFY(16)" }, 477 /* 90 O O O O PRE-FETCH(16) */ 478 { 0x90, D | W | O | B, "PRE-FETCH(16)" }, 479 /* 91 O O O O SYNCHRONIZE CACHE(16) */ 480 { 0x91, D | W | O | B, "SYNCHRONIZE CACHE(16)" }, 481 /* 91 O SPACE(16) */ 482 { 0x91, T, "SPACE(16)" }, 483 /* 92 Z O O LOCK UNLOCK CACHE(16) */ 484 { 0x92, D | W | O, "LOCK UNLOCK CACHE(16)" }, 485 /* 92 O LOCATE(16) */ 486 { 0x92, T, "LOCATE(16)" }, 487 /* 93 O WRITE SAME(16) */ 488 { 0x93, D, "WRITE SAME(16)" }, 489 /* 93 M ERASE(16) */ 490 { 0x93, T, "ERASE(16)" }, 491 /* 94 [usage proposed by SCSI Socket Services project] */ 492 /* 95 [usage proposed by SCSI Socket Services project] */ 493 /* 96 [usage proposed by SCSI Socket Services project] */ 494 /* 97 [usage proposed by SCSI Socket Services project] */ 495 /* 98 */ 496 /* 99 */ 497 /* 9A */ 498 /* 9B */ 499 /* 9C */ 500 /* 9D */ 501 /* XXX KDM ALL for this? op-num.txt defines it for none.. */ 502 /* 9E SERVICE ACTION IN(16) */ 503 { 0x9E, ALL, "SERVICE ACTION IN(16)" }, 504 /* XXX KDM ALL for this? op-num.txt defines it for ADC.. */ 505 /* 9F M SERVICE ACTION OUT(16) */ 506 { 0x9F, ALL, "SERVICE ACTION OUT(16)" }, 507 /* A0 MMOOO OMMM OMO REPORT LUNS */ 508 { 0xA0, ALL & ~(R | B), "REPORT LUNS" }, 509 /* A1 O BLANK */ 510 { 0xA1, R, "BLANK" }, 511 /* A1 O O ATA COMMAND PASS THROUGH(12) */ 512 { 0xA1, D | B, "ATA COMMAND PASS THROUGH(12)" }, 513 /* A2 OO O O SECURITY PROTOCOL IN */ 514 { 0xA2, D | T | R | V, "SECURITY PROTOCOL IN" }, 515 /* A3 OOO O OOMOOOM MAINTENANCE (IN) */ 516 { 0xA3, ALL & ~(P | R | F), "MAINTENANCE (IN)" }, 517 /* A3 O SEND KEY */ 518 { 0xA3, R, "SEND KEY" }, 519 /* A4 OOO O OOOOOOO MAINTENANCE (OUT) */ 520 { 0xA4, ALL & ~(P | R | F), "MAINTENANCE (OUT)" }, 521 /* A4 O REPORT KEY */ 522 { 0xA4, R, "REPORT KEY" }, 523 /* A5 O O OM MOVE MEDIUM */ 524 { 0xA5, T | W | O | M, "MOVE MEDIUM" }, 525 /* A5 O PLAY AUDIO(12) */ 526 { 0xA5, R, "PLAY AUDIO(12)" }, 527 /* A6 O EXCHANGE MEDIUM */ 528 { 0xA6, M, "EXCHANGE MEDIUM" }, 529 /* A6 O LOAD/UNLOAD C/DVD */ 530 { 0xA6, R, "LOAD/UNLOAD C/DVD" }, 531 /* A7 ZZ O O MOVE MEDIUM ATTACHED */ 532 { 0xA7, D | T | W | O, "MOVE MEDIUM ATTACHED" }, 533 /* A7 O SET READ AHEAD */ 534 { 0xA7, R, "SET READ AHEAD" }, 535 /* A8 O OOO READ(12) */ 536 { 0xA8, D | W | R | O, "READ(12)" }, 537 /* A8 GET MESSAGE(12) */ 538 { 0xA8, C, "GET MESSAGE(12)" }, 539 /* A9 O SERVICE ACTION OUT(12) */ 540 { 0xA9, V, "SERVICE ACTION OUT(12)" }, 541 /* AA O OOO WRITE(12) */ 542 { 0xAA, D | W | R | O, "WRITE(12)" }, 543 /* AA SEND MESSAGE(12) */ 544 { 0xAA, C, "SEND MESSAGE(12)" }, 545 /* AB O O SERVICE ACTION IN(12) */ 546 { 0xAB, R | V, "SERVICE ACTION IN(12)" }, 547 /* AC O ERASE(12) */ 548 { 0xAC, O, "ERASE(12)" }, 549 /* AC O GET PERFORMANCE */ 550 { 0xAC, R, "GET PERFORMANCE" }, 551 /* AD O READ DVD STRUCTURE */ 552 { 0xAD, R, "READ DVD STRUCTURE" }, 553 /* AE O O O WRITE AND VERIFY(12) */ 554 { 0xAE, D | W | O, "WRITE AND VERIFY(12)" }, 555 /* AF O OZO VERIFY(12) */ 556 { 0xAF, D | W | R | O, "VERIFY(12)" }, 557 /* B0 ZZZ SEARCH DATA HIGH(12) */ 558 { 0xB0, W | R | O, "SEARCH DATA HIGH(12)" }, 559 /* B1 ZZZ SEARCH DATA EQUAL(12) */ 560 { 0xB1, W | R | O, "SEARCH DATA EQUAL(12)" }, 561 /* B2 ZZZ SEARCH DATA LOW(12) */ 562 { 0xB2, W | R | O, "SEARCH DATA LOW(12)" }, 563 /* B3 Z OZO SET LIMITS(12) */ 564 { 0xB3, D | W | R | O, "SET LIMITS(12)" }, 565 /* B4 ZZ OZO READ ELEMENT STATUS ATTACHED */ 566 { 0xB4, D | T | W | R | O, "READ ELEMENT STATUS ATTACHED" }, 567 /* B5 OO O O SECURITY PROTOCOL OUT */ 568 { 0xB5, D | T | R | V, "SECURITY PROTOCOL OUT" }, 569 /* B5 O REQUEST VOLUME ELEMENT ADDRESS */ 570 { 0xB5, M, "REQUEST VOLUME ELEMENT ADDRESS" }, 571 /* B6 O SEND VOLUME TAG */ 572 { 0xB6, M, "SEND VOLUME TAG" }, 573 /* B6 O SET STREAMING */ 574 { 0xB6, R, "SET STREAMING" }, 575 /* B7 O O READ DEFECT DATA(12) */ 576 { 0xB7, D | O, "READ DEFECT DATA(12)" }, 577 /* B8 O OZOM READ ELEMENT STATUS */ 578 { 0xB8, T | W | R | O | M, "READ ELEMENT STATUS" }, 579 /* B9 O READ CD MSF */ 580 { 0xB9, R, "READ CD MSF" }, 581 /* BA O O OOMO REDUNDANCY GROUP (IN) */ 582 { 0xBA, D | W | O | M | A | E, "REDUNDANCY GROUP (IN)" }, 583 /* BA O SCAN */ 584 { 0xBA, R, "SCAN" }, 585 /* BB O O OOOO REDUNDANCY GROUP (OUT) */ 586 { 0xBB, D | W | O | M | A | E, "REDUNDANCY GROUP (OUT)" }, 587 /* BB O SET CD SPEED */ 588 { 0xBB, R, "SET CD SPEED" }, 589 /* BC O O OOMO SPARE (IN) */ 590 { 0xBC, D | W | O | M | A | E, "SPARE (IN)" }, 591 /* BD O O OOOO SPARE (OUT) */ 592 { 0xBD, D | W | O | M | A | E, "SPARE (OUT)" }, 593 /* BD O MECHANISM STATUS */ 594 { 0xBD, R, "MECHANISM STATUS" }, 595 /* BE O O OOMO VOLUME SET (IN) */ 596 { 0xBE, D | W | O | M | A | E, "VOLUME SET (IN)" }, 597 /* BE O READ CD */ 598 { 0xBE, R, "READ CD" }, 599 /* BF O O OOOO VOLUME SET (OUT) */ 600 { 0xBF, D | W | O | M | A | E, "VOLUME SET (OUT)" }, 601 /* BF O SEND DVD STRUCTURE */ 602 { 0xBF, R, "SEND DVD STRUCTURE" } 603 }; 604 605 const char * 606 scsi_op_desc(u_int16_t opcode, struct scsi_inquiry_data *inq_data) 607 { 608 caddr_t match; 609 int i, j; 610 u_int32_t opmask; 611 u_int16_t pd_type; 612 int num_ops[2]; 613 struct op_table_entry *table[2]; 614 int num_tables; 615 616 pd_type = SID_TYPE(inq_data); 617 618 match = cam_quirkmatch((caddr_t)inq_data, 619 (caddr_t)scsi_op_quirk_table, 620 sizeof(scsi_op_quirk_table)/ 621 sizeof(*scsi_op_quirk_table), 622 sizeof(*scsi_op_quirk_table), 623 scsi_inquiry_match); 624 625 if (match != NULL) { 626 table[0] = ((struct scsi_op_quirk_entry *)match)->op_table; 627 num_ops[0] = ((struct scsi_op_quirk_entry *)match)->num_ops; 628 table[1] = scsi_op_codes; 629 num_ops[1] = sizeof(scsi_op_codes)/sizeof(scsi_op_codes[0]); 630 num_tables = 2; 631 } else { 632 /* 633 * If this is true, we have a vendor specific opcode that 634 * wasn't covered in the quirk table. 635 */ 636 if ((opcode > 0xBF) || ((opcode > 0x5F) && (opcode < 0x80))) 637 return("Vendor Specific Command"); 638 639 table[0] = scsi_op_codes; 640 num_ops[0] = sizeof(scsi_op_codes)/sizeof(scsi_op_codes[0]); 641 num_tables = 1; 642 } 643 644 /* RBC is 'Simplified' Direct Access Device */ 645 if (pd_type == T_RBC) 646 pd_type = T_DIRECT; 647 648 opmask = 1 << pd_type; 649 650 for (j = 0; j < num_tables; j++) { 651 for (i = 0;i < num_ops[j] && table[j][i].opcode <= opcode; i++){ 652 if ((table[j][i].opcode == opcode) 653 && ((table[j][i].opmask & opmask) != 0)) 654 return(table[j][i].desc); 655 } 656 } 657 658 /* 659 * If we can't find a match for the command in the table, we just 660 * assume it's a vendor specifc command. 661 */ 662 return("Vendor Specific Command"); 663 664 } 665 666 #else /* SCSI_NO_OP_STRINGS */ 667 668 const char * 669 scsi_op_desc(u_int16_t opcode, struct scsi_inquiry_data *inq_data) 670 { 671 return(""); 672 } 673 674 #endif 675 676 677 #if !defined(SCSI_NO_SENSE_STRINGS) 678 #define SST(asc, ascq, action, desc) \ 679 asc, ascq, action, desc 680 #else 681 const char empty_string[] = ""; 682 683 #define SST(asc, ascq, action, desc) \ 684 asc, ascq, action, empty_string 685 #endif 686 687 const struct sense_key_table_entry sense_key_table[] = 688 { 689 { SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" }, 690 { SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" }, 691 { 692 SSD_KEY_NOT_READY, SS_TUR|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY, 693 "NOT READY" 694 }, 695 { SSD_KEY_MEDIUM_ERROR, SS_RDEF, "MEDIUM ERROR" }, 696 { SSD_KEY_HARDWARE_ERROR, SS_RDEF, "HARDWARE FAILURE" }, 697 { SSD_KEY_ILLEGAL_REQUEST, SS_FATAL|EINVAL, "ILLEGAL REQUEST" }, 698 { SSD_KEY_UNIT_ATTENTION, SS_FATAL|ENXIO, "UNIT ATTENTION" }, 699 { SSD_KEY_DATA_PROTECT, SS_FATAL|EACCES, "DATA PROTECT" }, 700 { SSD_KEY_BLANK_CHECK, SS_FATAL|ENOSPC, "BLANK CHECK" }, 701 { SSD_KEY_Vendor_Specific, SS_FATAL|EIO, "Vendor Specific" }, 702 { SSD_KEY_COPY_ABORTED, SS_FATAL|EIO, "COPY ABORTED" }, 703 { SSD_KEY_ABORTED_COMMAND, SS_RDEF, "ABORTED COMMAND" }, 704 { SSD_KEY_EQUAL, SS_NOP, "EQUAL" }, 705 { SSD_KEY_VOLUME_OVERFLOW, SS_FATAL|EIO, "VOLUME OVERFLOW" }, 706 { SSD_KEY_MISCOMPARE, SS_NOP, "MISCOMPARE" }, 707 { SSD_KEY_RESERVED, SS_FATAL|EIO, "RESERVED" } 708 }; 709 710 const int sense_key_table_size = 711 sizeof(sense_key_table)/sizeof(sense_key_table[0]); 712 713 static struct asc_table_entry quantum_fireball_entries[] = { 714 { SST(0x04, 0x0b, SS_START | SSQ_DECREMENT_COUNT | ENXIO, 715 "Logical unit not ready, initializing cmd. required") } 716 }; 717 718 static struct asc_table_entry sony_mo_entries[] = { 719 { SST(0x04, 0x00, SS_START | SSQ_DECREMENT_COUNT | ENXIO, 720 "Logical unit not ready, cause not reportable") } 721 }; 722 723 static struct scsi_sense_quirk_entry sense_quirk_table[] = { 724 { 725 /* 726 * XXX The Quantum Fireball ST and SE like to return 0x04 0x0b 727 * when they really should return 0x04 0x02. 728 */ 729 {T_DIRECT, SIP_MEDIA_FIXED, "QUANTUM", "FIREBALL S*", "*"}, 730 /*num_sense_keys*/0, 731 sizeof(quantum_fireball_entries)/sizeof(struct asc_table_entry), 732 /*sense key entries*/NULL, 733 quantum_fireball_entries 734 }, 735 { 736 /* 737 * This Sony MO drive likes to return 0x04, 0x00 when it 738 * isn't spun up. 739 */ 740 {T_DIRECT, SIP_MEDIA_REMOVABLE, "SONY", "SMO-*", "*"}, 741 /*num_sense_keys*/0, 742 sizeof(sony_mo_entries)/sizeof(struct asc_table_entry), 743 /*sense key entries*/NULL, 744 sony_mo_entries 745 } 746 }; 747 748 const int sense_quirk_table_size = 749 sizeof(sense_quirk_table)/sizeof(sense_quirk_table[0]); 750 751 static struct asc_table_entry asc_table[] = { 752 /* 753 * From: http://www.t10.org/lists/asc-num.txt 754 * Modifications by Jung-uk Kim (jkim@FreeBSD.org) 755 */ 756 /* 757 * File: ASC-NUM.TXT 758 * 759 * SCSI ASC/ASCQ Assignments 760 * Numeric Sorted Listing 761 * as of 7/29/08 762 * 763 * D - DIRECT ACCESS DEVICE (SBC-2) device column key 764 * .T - SEQUENTIAL ACCESS DEVICE (SSC) ------------------- 765 * . L - PRINTER DEVICE (SSC) blank = reserved 766 * . P - PROCESSOR DEVICE (SPC) not blank = allowed 767 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2) 768 * . . R - CD DEVICE (MMC) 769 * . . O - OPTICAL MEMORY DEVICE (SBC-2) 770 * . . .M - MEDIA CHANGER DEVICE (SMC) 771 * . . . A - STORAGE ARRAY DEVICE (SCC) 772 * . . . E - ENCLOSURE SERVICES DEVICE (SES) 773 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC) 774 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW) 775 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC) 776 * . . . . .F - OBJECT-BASED STORAGE (OSD) 777 * DTLPWROMAEBKVF 778 * ASC ASCQ Action 779 * Description 780 */ 781 /* DTLPWROMAEBKVF */ 782 { SST(0x00, 0x00, SS_NOP, 783 "No additional sense information") }, 784 /* T */ 785 { SST(0x00, 0x01, SS_RDEF, 786 "Filemark detected") }, 787 /* T */ 788 { SST(0x00, 0x02, SS_RDEF, 789 "End-of-partition/medium detected") }, 790 /* T */ 791 { SST(0x00, 0x03, SS_RDEF, 792 "Setmark detected") }, 793 /* T */ 794 { SST(0x00, 0x04, SS_RDEF, 795 "Beginning-of-partition/medium detected") }, 796 /* TL */ 797 { SST(0x00, 0x05, SS_RDEF, 798 "End-of-data detected") }, 799 /* DTLPWROMAEBKVF */ 800 { SST(0x00, 0x06, SS_RDEF, 801 "I/O process terminated") }, 802 /* T */ 803 { SST(0x00, 0x07, SS_RDEF, /* XXX TBD */ 804 "Programmable early warning detected") }, 805 /* R */ 806 { SST(0x00, 0x11, SS_FATAL | EBUSY, 807 "Audio play operation in progress") }, 808 /* R */ 809 { SST(0x00, 0x12, SS_NOP, 810 "Audio play operation paused") }, 811 /* R */ 812 { SST(0x00, 0x13, SS_NOP, 813 "Audio play operation successfully completed") }, 814 /* R */ 815 { SST(0x00, 0x14, SS_RDEF, 816 "Audio play operation stopped due to error") }, 817 /* R */ 818 { SST(0x00, 0x15, SS_NOP, 819 "No current audio status to return") }, 820 /* DTLPWROMAEBKVF */ 821 { SST(0x00, 0x16, SS_FATAL | EBUSY, 822 "Operation in progress") }, 823 /* DTL WROMAEBKVF */ 824 { SST(0x00, 0x17, SS_RDEF, 825 "Cleaning requested") }, 826 /* T */ 827 { SST(0x00, 0x18, SS_RDEF, /* XXX TBD */ 828 "Erase operation in progress") }, 829 /* T */ 830 { SST(0x00, 0x19, SS_RDEF, /* XXX TBD */ 831 "Locate operation in progress") }, 832 /* T */ 833 { SST(0x00, 0x1A, SS_RDEF, /* XXX TBD */ 834 "Rewind operation in progress") }, 835 /* T */ 836 { SST(0x00, 0x1B, SS_RDEF, /* XXX TBD */ 837 "Set capacity operation in progress") }, 838 /* T */ 839 { SST(0x00, 0x1C, SS_RDEF, /* XXX TBD */ 840 "Verify operation in progress") }, 841 /* DT B */ 842 { SST(0x00, 0x1D, SS_RDEF, /* XXX TBD */ 843 "ATA pass through information available") }, 844 /* DT R MAEBKV */ 845 { SST(0x00, 0x1E, SS_RDEF, /* XXX TBD */ 846 "Conflicting SA creation request") }, 847 /* D W O BK */ 848 { SST(0x01, 0x00, SS_RDEF, 849 "No index/sector signal") }, 850 /* D WRO BK */ 851 { SST(0x02, 0x00, SS_RDEF, 852 "No seek complete") }, 853 /* DTL W O BK */ 854 { SST(0x03, 0x00, SS_RDEF, 855 "Peripheral device write fault") }, 856 /* T */ 857 { SST(0x03, 0x01, SS_RDEF, 858 "No write current") }, 859 /* T */ 860 { SST(0x03, 0x02, SS_RDEF, 861 "Excessive write errors") }, 862 /* DTLPWROMAEBKVF */ 863 { SST(0x04, 0x00, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EIO, 864 "Logical unit not ready, cause not reportable") }, 865 /* DTLPWROMAEBKVF */ 866 { SST(0x04, 0x01, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EBUSY, 867 "Logical unit is in process of becoming ready") }, 868 /* DTLPWROMAEBKVF */ 869 { SST(0x04, 0x02, SS_START | SSQ_DECREMENT_COUNT | ENXIO, 870 "Logical unit not ready, initializing command required") }, 871 /* DTLPWROMAEBKVF */ 872 { SST(0x04, 0x03, SS_FATAL | ENXIO, 873 "Logical unit not ready, manual intervention required") }, 874 /* DTL RO B */ 875 { SST(0x04, 0x04, SS_FATAL | EBUSY, 876 "Logical unit not ready, format in progress") }, 877 /* DT W O A BK F */ 878 { SST(0x04, 0x05, SS_FATAL | EBUSY, 879 "Logical unit not ready, rebuild in progress") }, 880 /* DT W O A BK */ 881 { SST(0x04, 0x06, SS_FATAL | EBUSY, 882 "Logical unit not ready, recalculation in progress") }, 883 /* DTLPWROMAEBKVF */ 884 { SST(0x04, 0x07, SS_FATAL | EBUSY, 885 "Logical unit not ready, operation in progress") }, 886 /* R */ 887 { SST(0x04, 0x08, SS_FATAL | EBUSY, 888 "Logical unit not ready, long write in progress") }, 889 /* DTLPWROMAEBKVF */ 890 { SST(0x04, 0x09, SS_RDEF, /* XXX TBD */ 891 "Logical unit not ready, self-test in progress") }, 892 /* DTLPWROMAEBKVF */ 893 { SST(0x04, 0x0A, SS_RDEF, /* XXX TBD */ 894 "Logical unit not accessible, asymmetric access state transition")}, 895 /* DTLPWROMAEBKVF */ 896 { SST(0x04, 0x0B, SS_RDEF, /* XXX TBD */ 897 "Logical unit not accessible, target port in standby state") }, 898 /* DTLPWROMAEBKVF */ 899 { SST(0x04, 0x0C, SS_RDEF, /* XXX TBD */ 900 "Logical unit not accessible, target port in unavailable state") }, 901 /* F */ 902 { SST(0x04, 0x0D, SS_RDEF, /* XXX TBD */ 903 "Logical unit not ready, structure check required") }, 904 /* DT WROM B */ 905 { SST(0x04, 0x10, SS_RDEF, /* XXX TBD */ 906 "Logical unit not ready, auxiliary memory not accessible") }, 907 /* DT WRO AEB VF */ 908 { SST(0x04, 0x11, SS_RDEF, /* XXX TBD */ 909 "Logical unit not ready, notify (enable spinup) required") }, 910 /* M V */ 911 { SST(0x04, 0x12, SS_RDEF, /* XXX TBD */ 912 "Logical unit not ready, offline") }, 913 /* DT R MAEBKV */ 914 { SST(0x04, 0x13, SS_RDEF, /* XXX TBD */ 915 "Logical unit not ready, SA creation in progress") }, 916 /* DTL WROMAEBKVF */ 917 { SST(0x05, 0x00, SS_RDEF, 918 "Logical unit does not respond to selection") }, 919 /* D WROM BK */ 920 { SST(0x06, 0x00, SS_RDEF, 921 "No reference position found") }, 922 /* DTL WROM BK */ 923 { SST(0x07, 0x00, SS_RDEF, 924 "Multiple peripheral devices selected") }, 925 /* DTL WROMAEBKVF */ 926 { SST(0x08, 0x00, SS_RDEF, 927 "Logical unit communication failure") }, 928 /* DTL WROMAEBKVF */ 929 { SST(0x08, 0x01, SS_RDEF, 930 "Logical unit communication time-out") }, 931 /* DTL WROMAEBKVF */ 932 { SST(0x08, 0x02, SS_RDEF, 933 "Logical unit communication parity error") }, 934 /* DT ROM BK */ 935 { SST(0x08, 0x03, SS_RDEF, 936 "Logical unit communication CRC error (Ultra-DMA/32)") }, 937 /* DTLPWRO K */ 938 { SST(0x08, 0x04, SS_RDEF, /* XXX TBD */ 939 "Unreachable copy target") }, 940 /* DT WRO B */ 941 { SST(0x09, 0x00, SS_RDEF, 942 "Track following error") }, 943 /* WRO K */ 944 { SST(0x09, 0x01, SS_RDEF, 945 "Tracking servo failure") }, 946 /* WRO K */ 947 { SST(0x09, 0x02, SS_RDEF, 948 "Focus servo failure") }, 949 /* WRO */ 950 { SST(0x09, 0x03, SS_RDEF, 951 "Spindle servo failure") }, 952 /* DT WRO B */ 953 { SST(0x09, 0x04, SS_RDEF, 954 "Head select fault") }, 955 /* DTLPWROMAEBKVF */ 956 { SST(0x0A, 0x00, SS_FATAL | ENOSPC, 957 "Error log overflow") }, 958 /* DTLPWROMAEBKVF */ 959 { SST(0x0B, 0x00, SS_RDEF, 960 "Warning") }, 961 /* DTLPWROMAEBKVF */ 962 { SST(0x0B, 0x01, SS_RDEF, 963 "Warning - specified temperature exceeded") }, 964 /* DTLPWROMAEBKVF */ 965 { SST(0x0B, 0x02, SS_RDEF, 966 "Warning - enclosure degraded") }, 967 /* DTLPWROMAEBKVF */ 968 { SST(0x0B, 0x03, SS_RDEF, /* XXX TBD */ 969 "Warning - background self-test failed") }, 970 /* DTLPWRO AEBKVF */ 971 { SST(0x0B, 0x04, SS_RDEF, /* XXX TBD */ 972 "Warning - background pre-scan detected medium error") }, 973 /* DTLPWRO AEBKVF */ 974 { SST(0x0B, 0x05, SS_RDEF, /* XXX TBD */ 975 "Warning - background medium scan detected medium error") }, 976 /* DTLPWROMAEBKVF */ 977 { SST(0x0B, 0x06, SS_RDEF, /* XXX TBD */ 978 "Warning - non-volatile cache now volatile") }, 979 /* DTLPWROMAEBKVF */ 980 { SST(0x0B, 0x07, SS_RDEF, /* XXX TBD */ 981 "Warning - degraded power to non-volatile cache") }, 982 /* T R */ 983 { SST(0x0C, 0x00, SS_RDEF, 984 "Write error") }, 985 /* K */ 986 { SST(0x0C, 0x01, SS_NOP | SSQ_PRINT_SENSE, 987 "Write error - recovered with auto reallocation") }, 988 /* D W O BK */ 989 { SST(0x0C, 0x02, SS_RDEF, 990 "Write error - auto reallocation failed") }, 991 /* D W O BK */ 992 { SST(0x0C, 0x03, SS_RDEF, 993 "Write error - recommend reassignment") }, 994 /* DT W O B */ 995 { SST(0x0C, 0x04, SS_RDEF, 996 "Compression check miscompare error") }, 997 /* DT W O B */ 998 { SST(0x0C, 0x05, SS_RDEF, 999 "Data expansion occurred during compression") }, 1000 /* DT W O B */ 1001 { SST(0x0C, 0x06, SS_RDEF, 1002 "Block not compressible") }, 1003 /* R */ 1004 { SST(0x0C, 0x07, SS_RDEF, 1005 "Write error - recovery needed") }, 1006 /* R */ 1007 { SST(0x0C, 0x08, SS_RDEF, 1008 "Write error - recovery failed") }, 1009 /* R */ 1010 { SST(0x0C, 0x09, SS_RDEF, 1011 "Write error - loss of streaming") }, 1012 /* R */ 1013 { SST(0x0C, 0x0A, SS_RDEF, 1014 "Write error - padding blocks added") }, 1015 /* DT WROM B */ 1016 { SST(0x0C, 0x0B, SS_RDEF, /* XXX TBD */ 1017 "Auxiliary memory write error") }, 1018 /* DTLPWRO AEBKVF */ 1019 { SST(0x0C, 0x0C, SS_RDEF, /* XXX TBD */ 1020 "Write error - unexpected unsolicited data") }, 1021 /* DTLPWRO AEBKVF */ 1022 { SST(0x0C, 0x0D, SS_RDEF, /* XXX TBD */ 1023 "Write error - not enough unsolicited data") }, 1024 /* R */ 1025 { SST(0x0C, 0x0F, SS_RDEF, /* XXX TBD */ 1026 "Defects in error window") }, 1027 /* DTLPWRO A K */ 1028 { SST(0x0D, 0x00, SS_RDEF, /* XXX TBD */ 1029 "Error detected by third party temporary initiator") }, 1030 /* DTLPWRO A K */ 1031 { SST(0x0D, 0x01, SS_RDEF, /* XXX TBD */ 1032 "Third party device failure") }, 1033 /* DTLPWRO A K */ 1034 { SST(0x0D, 0x02, SS_RDEF, /* XXX TBD */ 1035 "Copy target device not reachable") }, 1036 /* DTLPWRO A K */ 1037 { SST(0x0D, 0x03, SS_RDEF, /* XXX TBD */ 1038 "Incorrect copy target device type") }, 1039 /* DTLPWRO A K */ 1040 { SST(0x0D, 0x04, SS_RDEF, /* XXX TBD */ 1041 "Copy target device data underrun") }, 1042 /* DTLPWRO A K */ 1043 { SST(0x0D, 0x05, SS_RDEF, /* XXX TBD */ 1044 "Copy target device data overrun") }, 1045 /* DT PWROMAEBK F */ 1046 { SST(0x0E, 0x00, SS_RDEF, /* XXX TBD */ 1047 "Invalid information unit") }, 1048 /* DT PWROMAEBK F */ 1049 { SST(0x0E, 0x01, SS_RDEF, /* XXX TBD */ 1050 "Information unit too short") }, 1051 /* DT PWROMAEBK F */ 1052 { SST(0x0E, 0x02, SS_RDEF, /* XXX TBD */ 1053 "Information unit too long") }, 1054 /* DT P R MAEBK F */ 1055 { SST(0x0E, 0x03, SS_RDEF, /* XXX TBD */ 1056 "Invalid field in command information unit") }, 1057 /* D W O BK */ 1058 { SST(0x10, 0x00, SS_RDEF, 1059 "ID CRC or ECC error") }, 1060 /* DT W O */ 1061 { SST(0x10, 0x01, SS_RDEF, /* XXX TBD */ 1062 "Logical block guard check failed") }, 1063 /* DT W O */ 1064 { SST(0x10, 0x02, SS_RDEF, /* XXX TBD */ 1065 "Logical block application tag check failed") }, 1066 /* DT W O */ 1067 { SST(0x10, 0x03, SS_RDEF, /* XXX TBD */ 1068 "Logical block reference tag check failed") }, 1069 /* DT WRO BK */ 1070 { SST(0x11, 0x00, SS_RDEF, 1071 "Unrecovered read error") }, 1072 /* DT WRO BK */ 1073 { SST(0x11, 0x01, SS_RDEF, 1074 "Read retries exhausted") }, 1075 /* DT WRO BK */ 1076 { SST(0x11, 0x02, SS_RDEF, 1077 "Error too long to correct") }, 1078 /* DT W O BK */ 1079 { SST(0x11, 0x03, SS_RDEF, 1080 "Multiple read errors") }, 1081 /* D W O BK */ 1082 { SST(0x11, 0x04, SS_RDEF, 1083 "Unrecovered read error - auto reallocate failed") }, 1084 /* WRO B */ 1085 { SST(0x11, 0x05, SS_RDEF, 1086 "L-EC uncorrectable error") }, 1087 /* WRO B */ 1088 { SST(0x11, 0x06, SS_RDEF, 1089 "CIRC unrecovered error") }, 1090 /* W O B */ 1091 { SST(0x11, 0x07, SS_RDEF, 1092 "Data re-synchronization error") }, 1093 /* T */ 1094 { SST(0x11, 0x08, SS_RDEF, 1095 "Incomplete block read") }, 1096 /* T */ 1097 { SST(0x11, 0x09, SS_RDEF, 1098 "No gap found") }, 1099 /* DT O BK */ 1100 { SST(0x11, 0x0A, SS_RDEF, 1101 "Miscorrected error") }, 1102 /* D W O BK */ 1103 { SST(0x11, 0x0B, SS_RDEF, 1104 "Unrecovered read error - recommend reassignment") }, 1105 /* D W O BK */ 1106 { SST(0x11, 0x0C, SS_RDEF, 1107 "Unrecovered read error - recommend rewrite the data") }, 1108 /* DT WRO B */ 1109 { SST(0x11, 0x0D, SS_RDEF, 1110 "De-compression CRC error") }, 1111 /* DT WRO B */ 1112 { SST(0x11, 0x0E, SS_RDEF, 1113 "Cannot decompress using declared algorithm") }, 1114 /* R */ 1115 { SST(0x11, 0x0F, SS_RDEF, 1116 "Error reading UPC/EAN number") }, 1117 /* R */ 1118 { SST(0x11, 0x10, SS_RDEF, 1119 "Error reading ISRC number") }, 1120 /* R */ 1121 { SST(0x11, 0x11, SS_RDEF, 1122 "Read error - loss of streaming") }, 1123 /* DT WROM B */ 1124 { SST(0x11, 0x12, SS_RDEF, /* XXX TBD */ 1125 "Auxiliary memory read error") }, 1126 /* DTLPWRO AEBKVF */ 1127 { SST(0x11, 0x13, SS_RDEF, /* XXX TBD */ 1128 "Read error - failed retransmission request") }, 1129 /* D */ 1130 { SST(0x11, 0x14, SS_RDEF, /* XXX TBD */ 1131 "Read error - LBA marked bad by application client") }, 1132 /* D W O BK */ 1133 { SST(0x12, 0x00, SS_RDEF, 1134 "Address mark not found for ID field") }, 1135 /* D W O BK */ 1136 { SST(0x13, 0x00, SS_RDEF, 1137 "Address mark not found for data field") }, 1138 /* DTL WRO BK */ 1139 { SST(0x14, 0x00, SS_RDEF, 1140 "Recorded entity not found") }, 1141 /* DT WRO BK */ 1142 { SST(0x14, 0x01, SS_RDEF, 1143 "Record not found") }, 1144 /* T */ 1145 { SST(0x14, 0x02, SS_RDEF, 1146 "Filemark or setmark not found") }, 1147 /* T */ 1148 { SST(0x14, 0x03, SS_RDEF, 1149 "End-of-data not found") }, 1150 /* T */ 1151 { SST(0x14, 0x04, SS_RDEF, 1152 "Block sequence error") }, 1153 /* DT W O BK */ 1154 { SST(0x14, 0x05, SS_RDEF, 1155 "Record not found - recommend reassignment") }, 1156 /* DT W O BK */ 1157 { SST(0x14, 0x06, SS_RDEF, 1158 "Record not found - data auto-reallocated") }, 1159 /* T */ 1160 { SST(0x14, 0x07, SS_RDEF, /* XXX TBD */ 1161 "Locate operation failure") }, 1162 /* DTL WROM BK */ 1163 { SST(0x15, 0x00, SS_RDEF, 1164 "Random positioning error") }, 1165 /* DTL WROM BK */ 1166 { SST(0x15, 0x01, SS_RDEF, 1167 "Mechanical positioning error") }, 1168 /* DT WRO BK */ 1169 { SST(0x15, 0x02, SS_RDEF, 1170 "Positioning error detected by read of medium") }, 1171 /* D W O BK */ 1172 { SST(0x16, 0x00, SS_RDEF, 1173 "Data synchronization mark error") }, 1174 /* D W O BK */ 1175 { SST(0x16, 0x01, SS_RDEF, 1176 "Data sync error - data rewritten") }, 1177 /* D W O BK */ 1178 { SST(0x16, 0x02, SS_RDEF, 1179 "Data sync error - recommend rewrite") }, 1180 /* D W O BK */ 1181 { SST(0x16, 0x03, SS_NOP | SSQ_PRINT_SENSE, 1182 "Data sync error - data auto-reallocated") }, 1183 /* D W O BK */ 1184 { SST(0x16, 0x04, SS_RDEF, 1185 "Data sync error - recommend reassignment") }, 1186 /* DT WRO BK */ 1187 { SST(0x17, 0x00, SS_NOP | SSQ_PRINT_SENSE, 1188 "Recovered data with no error correction applied") }, 1189 /* DT WRO BK */ 1190 { SST(0x17, 0x01, SS_NOP | SSQ_PRINT_SENSE, 1191 "Recovered data with retries") }, 1192 /* DT WRO BK */ 1193 { SST(0x17, 0x02, SS_NOP | SSQ_PRINT_SENSE, 1194 "Recovered data with positive head offset") }, 1195 /* DT WRO BK */ 1196 { SST(0x17, 0x03, SS_NOP | SSQ_PRINT_SENSE, 1197 "Recovered data with negative head offset") }, 1198 /* WRO B */ 1199 { SST(0x17, 0x04, SS_NOP | SSQ_PRINT_SENSE, 1200 "Recovered data with retries and/or CIRC applied") }, 1201 /* D WRO BK */ 1202 { SST(0x17, 0x05, SS_NOP | SSQ_PRINT_SENSE, 1203 "Recovered data using previous sector ID") }, 1204 /* D W O BK */ 1205 { SST(0x17, 0x06, SS_NOP | SSQ_PRINT_SENSE, 1206 "Recovered data without ECC - data auto-reallocated") }, 1207 /* D WRO BK */ 1208 { SST(0x17, 0x07, SS_NOP | SSQ_PRINT_SENSE, 1209 "Recovered data without ECC - recommend reassignment") }, 1210 /* D WRO BK */ 1211 { SST(0x17, 0x08, SS_NOP | SSQ_PRINT_SENSE, 1212 "Recovered data without ECC - recommend rewrite") }, 1213 /* D WRO BK */ 1214 { SST(0x17, 0x09, SS_NOP | SSQ_PRINT_SENSE, 1215 "Recovered data without ECC - data rewritten") }, 1216 /* DT WRO BK */ 1217 { SST(0x18, 0x00, SS_NOP | SSQ_PRINT_SENSE, 1218 "Recovered data with error correction applied") }, 1219 /* D WRO BK */ 1220 { SST(0x18, 0x01, SS_NOP | SSQ_PRINT_SENSE, 1221 "Recovered data with error corr. & retries applied") }, 1222 /* D WRO BK */ 1223 { SST(0x18, 0x02, SS_NOP | SSQ_PRINT_SENSE, 1224 "Recovered data - data auto-reallocated") }, 1225 /* R */ 1226 { SST(0x18, 0x03, SS_NOP | SSQ_PRINT_SENSE, 1227 "Recovered data with CIRC") }, 1228 /* R */ 1229 { SST(0x18, 0x04, SS_NOP | SSQ_PRINT_SENSE, 1230 "Recovered data with L-EC") }, 1231 /* D WRO BK */ 1232 { SST(0x18, 0x05, SS_NOP | SSQ_PRINT_SENSE, 1233 "Recovered data - recommend reassignment") }, 1234 /* D WRO BK */ 1235 { SST(0x18, 0x06, SS_NOP | SSQ_PRINT_SENSE, 1236 "Recovered data - recommend rewrite") }, 1237 /* D W O BK */ 1238 { SST(0x18, 0x07, SS_NOP | SSQ_PRINT_SENSE, 1239 "Recovered data with ECC - data rewritten") }, 1240 /* R */ 1241 { SST(0x18, 0x08, SS_RDEF, /* XXX TBD */ 1242 "Recovered data with linking") }, 1243 /* D O K */ 1244 { SST(0x19, 0x00, SS_RDEF, 1245 "Defect list error") }, 1246 /* D O K */ 1247 { SST(0x19, 0x01, SS_RDEF, 1248 "Defect list not available") }, 1249 /* D O K */ 1250 { SST(0x19, 0x02, SS_RDEF, 1251 "Defect list error in primary list") }, 1252 /* D O K */ 1253 { SST(0x19, 0x03, SS_RDEF, 1254 "Defect list error in grown list") }, 1255 /* DTLPWROMAEBKVF */ 1256 { SST(0x1A, 0x00, SS_RDEF, 1257 "Parameter list length error") }, 1258 /* DTLPWROMAEBKVF */ 1259 { SST(0x1B, 0x00, SS_RDEF, 1260 "Synchronous data transfer error") }, 1261 /* D O BK */ 1262 { SST(0x1C, 0x00, SS_RDEF, 1263 "Defect list not found") }, 1264 /* D O BK */ 1265 { SST(0x1C, 0x01, SS_RDEF, 1266 "Primary defect list not found") }, 1267 /* D O BK */ 1268 { SST(0x1C, 0x02, SS_RDEF, 1269 "Grown defect list not found") }, 1270 /* DT WRO BK */ 1271 { SST(0x1D, 0x00, SS_FATAL, 1272 "Miscompare during verify operation") }, 1273 /* D W O BK */ 1274 { SST(0x1E, 0x00, SS_NOP | SSQ_PRINT_SENSE, 1275 "Recovered ID with ECC correction") }, 1276 /* D O K */ 1277 { SST(0x1F, 0x00, SS_RDEF, 1278 "Partial defect list transfer") }, 1279 /* DTLPWROMAEBKVF */ 1280 { SST(0x20, 0x00, SS_FATAL | EINVAL, 1281 "Invalid command operation code") }, 1282 /* DT PWROMAEBK */ 1283 { SST(0x20, 0x01, SS_RDEF, /* XXX TBD */ 1284 "Access denied - initiator pending-enrolled") }, 1285 /* DT PWROMAEBK */ 1286 { SST(0x20, 0x02, SS_RDEF, /* XXX TBD */ 1287 "Access denied - no access rights") }, 1288 /* DT PWROMAEBK */ 1289 { SST(0x20, 0x03, SS_RDEF, /* XXX TBD */ 1290 "Access denied - invalid mgmt ID key") }, 1291 /* T */ 1292 { SST(0x20, 0x04, SS_RDEF, /* XXX TBD */ 1293 "Illegal command while in write capable state") }, 1294 /* T */ 1295 { SST(0x20, 0x05, SS_RDEF, /* XXX TBD */ 1296 "Obsolete") }, 1297 /* T */ 1298 { SST(0x20, 0x06, SS_RDEF, /* XXX TBD */ 1299 "Illegal command while in explicit address mode") }, 1300 /* T */ 1301 { SST(0x20, 0x07, SS_RDEF, /* XXX TBD */ 1302 "Illegal command while in implicit address mode") }, 1303 /* DT PWROMAEBK */ 1304 { SST(0x20, 0x08, SS_RDEF, /* XXX TBD */ 1305 "Access denied - enrollment conflict") }, 1306 /* DT PWROMAEBK */ 1307 { SST(0x20, 0x09, SS_RDEF, /* XXX TBD */ 1308 "Access denied - invalid LU identifier") }, 1309 /* DT PWROMAEBK */ 1310 { SST(0x20, 0x0A, SS_RDEF, /* XXX TBD */ 1311 "Access denied - invalid proxy token") }, 1312 /* DT PWROMAEBK */ 1313 { SST(0x20, 0x0B, SS_RDEF, /* XXX TBD */ 1314 "Access denied - ACL LUN conflict") }, 1315 /* DT WRO BK */ 1316 { SST(0x21, 0x00, SS_FATAL | EINVAL, 1317 "Logical block address out of range") }, 1318 /* DT WROM BK */ 1319 { SST(0x21, 0x01, SS_FATAL | EINVAL, 1320 "Invalid element address") }, 1321 /* R */ 1322 { SST(0x21, 0x02, SS_RDEF, /* XXX TBD */ 1323 "Invalid address for write") }, 1324 /* R */ 1325 { SST(0x21, 0x03, SS_RDEF, /* XXX TBD */ 1326 "Invalid write crossing layer jump") }, 1327 /* D */ 1328 { SST(0x22, 0x00, SS_FATAL | EINVAL, 1329 "Illegal function (use 20 00, 24 00, or 26 00)") }, 1330 /* DTLPWROMAEBKVF */ 1331 { SST(0x24, 0x00, SS_FATAL | EINVAL, 1332 "Invalid field in CDB") }, 1333 /* DTLPWRO AEBKVF */ 1334 { SST(0x24, 0x01, SS_RDEF, /* XXX TBD */ 1335 "CDB decryption error") }, 1336 /* T */ 1337 { SST(0x24, 0x02, SS_RDEF, /* XXX TBD */ 1338 "Obsolete") }, 1339 /* T */ 1340 { SST(0x24, 0x03, SS_RDEF, /* XXX TBD */ 1341 "Obsolete") }, 1342 /* F */ 1343 { SST(0x24, 0x04, SS_RDEF, /* XXX TBD */ 1344 "Security audit value frozen") }, 1345 /* F */ 1346 { SST(0x24, 0x05, SS_RDEF, /* XXX TBD */ 1347 "Security working key frozen") }, 1348 /* F */ 1349 { SST(0x24, 0x06, SS_RDEF, /* XXX TBD */ 1350 "NONCE not unique") }, 1351 /* F */ 1352 { SST(0x24, 0x07, SS_RDEF, /* XXX TBD */ 1353 "NONCE timestamp out of range") }, 1354 /* DT R MAEBKV */ 1355 { SST(0x24, 0x08, SS_RDEF, /* XXX TBD */ 1356 "Invalid XCDB") }, 1357 /* DTLPWROMAEBKVF */ 1358 { SST(0x25, 0x00, SS_FATAL | ENXIO, 1359 "Logical unit not supported") }, 1360 /* DTLPWROMAEBKVF */ 1361 { SST(0x26, 0x00, SS_FATAL | EINVAL, 1362 "Invalid field in parameter list") }, 1363 /* DTLPWROMAEBKVF */ 1364 { SST(0x26, 0x01, SS_FATAL | EINVAL, 1365 "Parameter not supported") }, 1366 /* DTLPWROMAEBKVF */ 1367 { SST(0x26, 0x02, SS_FATAL | EINVAL, 1368 "Parameter value invalid") }, 1369 /* DTLPWROMAE K */ 1370 { SST(0x26, 0x03, SS_FATAL | EINVAL, 1371 "Threshold parameters not supported") }, 1372 /* DTLPWROMAEBKVF */ 1373 { SST(0x26, 0x04, SS_FATAL | EINVAL, 1374 "Invalid release of persistent reservation") }, 1375 /* DTLPWRO A BK */ 1376 { SST(0x26, 0x05, SS_RDEF, /* XXX TBD */ 1377 "Data decryption error") }, 1378 /* DTLPWRO K */ 1379 { SST(0x26, 0x06, SS_RDEF, /* XXX TBD */ 1380 "Too many target descriptors") }, 1381 /* DTLPWRO K */ 1382 { SST(0x26, 0x07, SS_RDEF, /* XXX TBD */ 1383 "Unsupported target descriptor type code") }, 1384 /* DTLPWRO K */ 1385 { SST(0x26, 0x08, SS_RDEF, /* XXX TBD */ 1386 "Too many segment descriptors") }, 1387 /* DTLPWRO K */ 1388 { SST(0x26, 0x09, SS_RDEF, /* XXX TBD */ 1389 "Unsupported segment descriptor type code") }, 1390 /* DTLPWRO K */ 1391 { SST(0x26, 0x0A, SS_RDEF, /* XXX TBD */ 1392 "Unexpected inexact segment") }, 1393 /* DTLPWRO K */ 1394 { SST(0x26, 0x0B, SS_RDEF, /* XXX TBD */ 1395 "Inline data length exceeded") }, 1396 /* DTLPWRO K */ 1397 { SST(0x26, 0x0C, SS_RDEF, /* XXX TBD */ 1398 "Invalid operation for copy source or destination") }, 1399 /* DTLPWRO K */ 1400 { SST(0x26, 0x0D, SS_RDEF, /* XXX TBD */ 1401 "Copy segment granularity violation") }, 1402 /* DT PWROMAEBK */ 1403 { SST(0x26, 0x0E, SS_RDEF, /* XXX TBD */ 1404 "Invalid parameter while port is enabled") }, 1405 /* F */ 1406 { SST(0x26, 0x0F, SS_RDEF, /* XXX TBD */ 1407 "Invalid data-out buffer integrity check value") }, 1408 /* T */ 1409 { SST(0x26, 0x10, SS_RDEF, /* XXX TBD */ 1410 "Data decryption key fail limit reached") }, 1411 /* T */ 1412 { SST(0x26, 0x11, SS_RDEF, /* XXX TBD */ 1413 "Incomplete key-associated data set") }, 1414 /* T */ 1415 { SST(0x26, 0x12, SS_RDEF, /* XXX TBD */ 1416 "Vendor specific key reference not found") }, 1417 /* DT WRO BK */ 1418 { SST(0x27, 0x00, SS_FATAL | EACCES, 1419 "Write protected") }, 1420 /* DT WRO BK */ 1421 { SST(0x27, 0x01, SS_FATAL | EACCES, 1422 "Hardware write protected") }, 1423 /* DT WRO BK */ 1424 { SST(0x27, 0x02, SS_FATAL | EACCES, 1425 "Logical unit software write protected") }, 1426 /* T R */ 1427 { SST(0x27, 0x03, SS_FATAL | EACCES, 1428 "Associated write protect") }, 1429 /* T R */ 1430 { SST(0x27, 0x04, SS_FATAL | EACCES, 1431 "Persistent write protect") }, 1432 /* T R */ 1433 { SST(0x27, 0x05, SS_FATAL | EACCES, 1434 "Permanent write protect") }, 1435 /* R F */ 1436 { SST(0x27, 0x06, SS_RDEF, /* XXX TBD */ 1437 "Conditional write protect") }, 1438 /* DTLPWROMAEBKVF */ 1439 { SST(0x28, 0x00, SS_FATAL | ENXIO, 1440 "Not ready to ready change, medium may have changed") }, 1441 /* DT WROM B */ 1442 { SST(0x28, 0x01, SS_FATAL | ENXIO, 1443 "Import or export element accessed") }, 1444 /* R */ 1445 { SST(0x28, 0x02, SS_RDEF, /* XXX TBD */ 1446 "Format-layer may have changed") }, 1447 /* M */ 1448 { SST(0x28, 0x03, SS_RDEF, /* XXX TBD */ 1449 "Import/export element accessed, medium changed") }, 1450 /* 1451 * XXX JGibbs - All of these should use the same errno, but I don't 1452 * think ENXIO is the correct choice. Should we borrow from 1453 * the networking errnos? ECONNRESET anyone? 1454 */ 1455 /* DTLPWROMAEBKVF */ 1456 { SST(0x29, 0x00, SS_FATAL | ENXIO, 1457 "Power on, reset, or bus device reset occurred") }, 1458 /* DTLPWROMAEBKVF */ 1459 { SST(0x29, 0x01, SS_RDEF, 1460 "Power on occurred") }, 1461 /* DTLPWROMAEBKVF */ 1462 { SST(0x29, 0x02, SS_RDEF, 1463 "SCSI bus reset occurred") }, 1464 /* DTLPWROMAEBKVF */ 1465 { SST(0x29, 0x03, SS_RDEF, 1466 "Bus device reset function occurred") }, 1467 /* DTLPWROMAEBKVF */ 1468 { SST(0x29, 0x04, SS_RDEF, 1469 "Device internal reset") }, 1470 /* DTLPWROMAEBKVF */ 1471 { SST(0x29, 0x05, SS_RDEF, 1472 "Transceiver mode changed to single-ended") }, 1473 /* DTLPWROMAEBKVF */ 1474 { SST(0x29, 0x06, SS_RDEF, 1475 "Transceiver mode changed to LVD") }, 1476 /* DTLPWROMAEBKVF */ 1477 { SST(0x29, 0x07, SS_RDEF, /* XXX TBD */ 1478 "I_T nexus loss occurred") }, 1479 /* DTL WROMAEBKVF */ 1480 { SST(0x2A, 0x00, SS_RDEF, 1481 "Parameters changed") }, 1482 /* DTL WROMAEBKVF */ 1483 { SST(0x2A, 0x01, SS_RDEF, 1484 "Mode parameters changed") }, 1485 /* DTL WROMAE K */ 1486 { SST(0x2A, 0x02, SS_RDEF, 1487 "Log parameters changed") }, 1488 /* DTLPWROMAE K */ 1489 { SST(0x2A, 0x03, SS_RDEF, 1490 "Reservations preempted") }, 1491 /* DTLPWROMAE */ 1492 { SST(0x2A, 0x04, SS_RDEF, /* XXX TBD */ 1493 "Reservations released") }, 1494 /* DTLPWROMAE */ 1495 { SST(0x2A, 0x05, SS_RDEF, /* XXX TBD */ 1496 "Registrations preempted") }, 1497 /* DTLPWROMAEBKVF */ 1498 { SST(0x2A, 0x06, SS_RDEF, /* XXX TBD */ 1499 "Asymmetric access state changed") }, 1500 /* DTLPWROMAEBKVF */ 1501 { SST(0x2A, 0x07, SS_RDEF, /* XXX TBD */ 1502 "Implicit asymmetric access state transition failed") }, 1503 /* DT WROMAEBKVF */ 1504 { SST(0x2A, 0x08, SS_RDEF, /* XXX TBD */ 1505 "Priority changed") }, 1506 /* D */ 1507 { SST(0x2A, 0x09, SS_RDEF, /* XXX TBD */ 1508 "Capacity data has changed") }, 1509 /* DT */ 1510 { SST(0x2A, 0x0A, SS_RDEF, /* XXX TBD */ 1511 "Error history I_T nexus cleared") }, 1512 /* DT */ 1513 { SST(0x2A, 0x0B, SS_RDEF, /* XXX TBD */ 1514 "Error history snapshot released") }, 1515 /* F */ 1516 { SST(0x2A, 0x0C, SS_RDEF, /* XXX TBD */ 1517 "Error recovery attributes have changed") }, 1518 /* T */ 1519 { SST(0x2A, 0x0D, SS_RDEF, /* XXX TBD */ 1520 "Data encryption capabilities changed") }, 1521 /* DT M E V */ 1522 { SST(0x2A, 0x10, SS_RDEF, /* XXX TBD */ 1523 "Timestamp changed") }, 1524 /* T */ 1525 { SST(0x2A, 0x11, SS_RDEF, /* XXX TBD */ 1526 "Data encryption parameters changed by another I_T nexus") }, 1527 /* T */ 1528 { SST(0x2A, 0x12, SS_RDEF, /* XXX TBD */ 1529 "Data encryption parameters changed by vendor specific event") }, 1530 /* T */ 1531 { SST(0x2A, 0x13, SS_RDEF, /* XXX TBD */ 1532 "Data encryption key instance counter has changed") }, 1533 /* DT R MAEBKV */ 1534 { SST(0x2A, 0x14, SS_RDEF, /* XXX TBD */ 1535 "SA creation capabilities data has changed") }, 1536 /* DTLPWRO K */ 1537 { SST(0x2B, 0x00, SS_RDEF, 1538 "Copy cannot execute since host cannot disconnect") }, 1539 /* DTLPWROMAEBKVF */ 1540 { SST(0x2C, 0x00, SS_RDEF, 1541 "Command sequence error") }, 1542 /* */ 1543 { SST(0x2C, 0x01, SS_RDEF, 1544 "Too many windows specified") }, 1545 /* */ 1546 { SST(0x2C, 0x02, SS_RDEF, 1547 "Invalid combination of windows specified") }, 1548 /* R */ 1549 { SST(0x2C, 0x03, SS_RDEF, 1550 "Current program area is not empty") }, 1551 /* R */ 1552 { SST(0x2C, 0x04, SS_RDEF, 1553 "Current program area is empty") }, 1554 /* B */ 1555 { SST(0x2C, 0x05, SS_RDEF, /* XXX TBD */ 1556 "Illegal power condition request") }, 1557 /* R */ 1558 { SST(0x2C, 0x06, SS_RDEF, /* XXX TBD */ 1559 "Persistent prevent conflict") }, 1560 /* DTLPWROMAEBKVF */ 1561 { SST(0x2C, 0x07, SS_RDEF, /* XXX TBD */ 1562 "Previous busy status") }, 1563 /* DTLPWROMAEBKVF */ 1564 { SST(0x2C, 0x08, SS_RDEF, /* XXX TBD */ 1565 "Previous task set full status") }, 1566 /* DTLPWROM EBKVF */ 1567 { SST(0x2C, 0x09, SS_RDEF, /* XXX TBD */ 1568 "Previous reservation conflict status") }, 1569 /* F */ 1570 { SST(0x2C, 0x0A, SS_RDEF, /* XXX TBD */ 1571 "Partition or collection contains user objects") }, 1572 /* T */ 1573 { SST(0x2C, 0x0B, SS_RDEF, /* XXX TBD */ 1574 "Not reserved") }, 1575 /* T */ 1576 { SST(0x2D, 0x00, SS_RDEF, 1577 "Overwrite error on update in place") }, 1578 /* R */ 1579 { SST(0x2E, 0x00, SS_RDEF, /* XXX TBD */ 1580 "Insufficient time for operation") }, 1581 /* DTLPWROMAEBKVF */ 1582 { SST(0x2F, 0x00, SS_RDEF, 1583 "Commands cleared by another initiator") }, 1584 /* D */ 1585 { SST(0x2F, 0x01, SS_RDEF, /* XXX TBD */ 1586 "Commands cleared by power loss notification") }, 1587 /* DTLPWROMAEBKVF */ 1588 { SST(0x2F, 0x02, SS_RDEF, /* XXX TBD */ 1589 "Commands cleared by device server") }, 1590 /* DT WROM BK */ 1591 { SST(0x30, 0x00, SS_RDEF, 1592 "Incompatible medium installed") }, 1593 /* DT WRO BK */ 1594 { SST(0x30, 0x01, SS_RDEF, 1595 "Cannot read medium - unknown format") }, 1596 /* DT WRO BK */ 1597 { SST(0x30, 0x02, SS_RDEF, 1598 "Cannot read medium - incompatible format") }, 1599 /* DT R K */ 1600 { SST(0x30, 0x03, SS_RDEF, 1601 "Cleaning cartridge installed") }, 1602 /* DT WRO BK */ 1603 { SST(0x30, 0x04, SS_RDEF, 1604 "Cannot write medium - unknown format") }, 1605 /* DT WRO BK */ 1606 { SST(0x30, 0x05, SS_RDEF, 1607 "Cannot write medium - incompatible format") }, 1608 /* DT WRO B */ 1609 { SST(0x30, 0x06, SS_RDEF, 1610 "Cannot format medium - incompatible medium") }, 1611 /* DTL WROMAEBKVF */ 1612 { SST(0x30, 0x07, SS_RDEF, 1613 "Cleaning failure") }, 1614 /* R */ 1615 { SST(0x30, 0x08, SS_RDEF, 1616 "Cannot write - application code mismatch") }, 1617 /* R */ 1618 { SST(0x30, 0x09, SS_RDEF, 1619 "Current session not fixated for append") }, 1620 /* DT WRO AEBK */ 1621 { SST(0x30, 0x0A, SS_RDEF, /* XXX TBD */ 1622 "Cleaning request rejected") }, 1623 /* T */ 1624 { SST(0x30, 0x0C, SS_RDEF, /* XXX TBD */ 1625 "WORM medium - overwrite attempted") }, 1626 /* T */ 1627 { SST(0x30, 0x0D, SS_RDEF, /* XXX TBD */ 1628 "WORM medium - integrity check") }, 1629 /* R */ 1630 { SST(0x30, 0x10, SS_RDEF, /* XXX TBD */ 1631 "Medium not formatted") }, 1632 /* M */ 1633 { SST(0x30, 0x11, SS_RDEF, /* XXX TBD */ 1634 "Incompatible volume type") }, 1635 /* M */ 1636 { SST(0x30, 0x12, SS_RDEF, /* XXX TBD */ 1637 "Incompatible volume qualifier") }, 1638 /* DT WRO BK */ 1639 { SST(0x31, 0x00, SS_RDEF, 1640 "Medium format corrupted") }, 1641 /* D L RO B */ 1642 { SST(0x31, 0x01, SS_RDEF, 1643 "Format command failed") }, 1644 /* R */ 1645 { SST(0x31, 0x02, SS_RDEF, /* XXX TBD */ 1646 "Zoned formatting failed due to spare linking") }, 1647 /* D W O BK */ 1648 { SST(0x32, 0x00, SS_RDEF, 1649 "No defect spare location available") }, 1650 /* D W O BK */ 1651 { SST(0x32, 0x01, SS_RDEF, 1652 "Defect list update failure") }, 1653 /* T */ 1654 { SST(0x33, 0x00, SS_RDEF, 1655 "Tape length error") }, 1656 /* DTLPWROMAEBKVF */ 1657 { SST(0x34, 0x00, SS_RDEF, 1658 "Enclosure failure") }, 1659 /* DTLPWROMAEBKVF */ 1660 { SST(0x35, 0x00, SS_RDEF, 1661 "Enclosure services failure") }, 1662 /* DTLPWROMAEBKVF */ 1663 { SST(0x35, 0x01, SS_RDEF, 1664 "Unsupported enclosure function") }, 1665 /* DTLPWROMAEBKVF */ 1666 { SST(0x35, 0x02, SS_RDEF, 1667 "Enclosure services unavailable") }, 1668 /* DTLPWROMAEBKVF */ 1669 { SST(0x35, 0x03, SS_RDEF, 1670 "Enclosure services transfer failure") }, 1671 /* DTLPWROMAEBKVF */ 1672 { SST(0x35, 0x04, SS_RDEF, 1673 "Enclosure services transfer refused") }, 1674 /* DTL WROMAEBKVF */ 1675 { SST(0x35, 0x05, SS_RDEF, /* XXX TBD */ 1676 "Enclosure services checksum error") }, 1677 /* L */ 1678 { SST(0x36, 0x00, SS_RDEF, 1679 "Ribbon, ink, or toner failure") }, 1680 /* DTL WROMAEBKVF */ 1681 { SST(0x37, 0x00, SS_RDEF, 1682 "Rounded parameter") }, 1683 /* B */ 1684 { SST(0x38, 0x00, SS_RDEF, /* XXX TBD */ 1685 "Event status notification") }, 1686 /* B */ 1687 { SST(0x38, 0x02, SS_RDEF, /* XXX TBD */ 1688 "ESN - power management class event") }, 1689 /* B */ 1690 { SST(0x38, 0x04, SS_RDEF, /* XXX TBD */ 1691 "ESN - media class event") }, 1692 /* B */ 1693 { SST(0x38, 0x06, SS_RDEF, /* XXX TBD */ 1694 "ESN - device busy class event") }, 1695 /* DTL WROMAE K */ 1696 { SST(0x39, 0x00, SS_RDEF, 1697 "Saving parameters not supported") }, 1698 /* DTL WROM BK */ 1699 { SST(0x3A, 0x00, SS_FATAL | ENXIO, 1700 "Medium not present") }, 1701 /* DT WROM BK */ 1702 { SST(0x3A, 0x01, SS_FATAL | ENXIO, 1703 "Medium not present - tray closed") }, 1704 /* DT WROM BK */ 1705 { SST(0x3A, 0x02, SS_FATAL | ENXIO, 1706 "Medium not present - tray open") }, 1707 /* DT WROM B */ 1708 { SST(0x3A, 0x03, SS_RDEF, /* XXX TBD */ 1709 "Medium not present - loadable") }, 1710 /* DT WRO B */ 1711 { SST(0x3A, 0x04, SS_RDEF, /* XXX TBD */ 1712 "Medium not present - medium auxiliary memory accessible") }, 1713 /* TL */ 1714 { SST(0x3B, 0x00, SS_RDEF, 1715 "Sequential positioning error") }, 1716 /* T */ 1717 { SST(0x3B, 0x01, SS_RDEF, 1718 "Tape position error at beginning-of-medium") }, 1719 /* T */ 1720 { SST(0x3B, 0x02, SS_RDEF, 1721 "Tape position error at end-of-medium") }, 1722 /* L */ 1723 { SST(0x3B, 0x03, SS_RDEF, 1724 "Tape or electronic vertical forms unit not ready") }, 1725 /* L */ 1726 { SST(0x3B, 0x04, SS_RDEF, 1727 "Slew failure") }, 1728 /* L */ 1729 { SST(0x3B, 0x05, SS_RDEF, 1730 "Paper jam") }, 1731 /* L */ 1732 { SST(0x3B, 0x06, SS_RDEF, 1733 "Failed to sense top-of-form") }, 1734 /* L */ 1735 { SST(0x3B, 0x07, SS_RDEF, 1736 "Failed to sense bottom-of-form") }, 1737 /* T */ 1738 { SST(0x3B, 0x08, SS_RDEF, 1739 "Reposition error") }, 1740 /* */ 1741 { SST(0x3B, 0x09, SS_RDEF, 1742 "Read past end of medium") }, 1743 /* */ 1744 { SST(0x3B, 0x0A, SS_RDEF, 1745 "Read past beginning of medium") }, 1746 /* */ 1747 { SST(0x3B, 0x0B, SS_RDEF, 1748 "Position past end of medium") }, 1749 /* T */ 1750 { SST(0x3B, 0x0C, SS_RDEF, 1751 "Position past beginning of medium") }, 1752 /* DT WROM BK */ 1753 { SST(0x3B, 0x0D, SS_FATAL | ENOSPC, 1754 "Medium destination element full") }, 1755 /* DT WROM BK */ 1756 { SST(0x3B, 0x0E, SS_RDEF, 1757 "Medium source element empty") }, 1758 /* R */ 1759 { SST(0x3B, 0x0F, SS_RDEF, 1760 "End of medium reached") }, 1761 /* DT WROM BK */ 1762 { SST(0x3B, 0x11, SS_RDEF, 1763 "Medium magazine not accessible") }, 1764 /* DT WROM BK */ 1765 { SST(0x3B, 0x12, SS_RDEF, 1766 "Medium magazine removed") }, 1767 /* DT WROM BK */ 1768 { SST(0x3B, 0x13, SS_RDEF, 1769 "Medium magazine inserted") }, 1770 /* DT WROM BK */ 1771 { SST(0x3B, 0x14, SS_RDEF, 1772 "Medium magazine locked") }, 1773 /* DT WROM BK */ 1774 { SST(0x3B, 0x15, SS_RDEF, 1775 "Medium magazine unlocked") }, 1776 /* R */ 1777 { SST(0x3B, 0x16, SS_RDEF, /* XXX TBD */ 1778 "Mechanical positioning or changer error") }, 1779 /* F */ 1780 { SST(0x3B, 0x17, SS_RDEF, /* XXX TBD */ 1781 "Read past end of user object") }, 1782 /* M */ 1783 { SST(0x3B, 0x18, SS_RDEF, /* XXX TBD */ 1784 "Element disabled") }, 1785 /* M */ 1786 { SST(0x3B, 0x19, SS_RDEF, /* XXX TBD */ 1787 "Element enabled") }, 1788 /* M */ 1789 { SST(0x3B, 0x1A, SS_RDEF, /* XXX TBD */ 1790 "Data transfer device removed") }, 1791 /* M */ 1792 { SST(0x3B, 0x1B, SS_RDEF, /* XXX TBD */ 1793 "Data transfer device inserted") }, 1794 /* DTLPWROMAE K */ 1795 { SST(0x3D, 0x00, SS_RDEF, 1796 "Invalid bits in IDENTIFY message") }, 1797 /* DTLPWROMAEBKVF */ 1798 { SST(0x3E, 0x00, SS_RDEF, 1799 "Logical unit has not self-configured yet") }, 1800 /* DTLPWROMAEBKVF */ 1801 { SST(0x3E, 0x01, SS_RDEF, 1802 "Logical unit failure") }, 1803 /* DTLPWROMAEBKVF */ 1804 { SST(0x3E, 0x02, SS_RDEF, 1805 "Timeout on logical unit") }, 1806 /* DTLPWROMAEBKVF */ 1807 { SST(0x3E, 0x03, SS_RDEF, /* XXX TBD */ 1808 "Logical unit failed self-test") }, 1809 /* DTLPWROMAEBKVF */ 1810 { SST(0x3E, 0x04, SS_RDEF, /* XXX TBD */ 1811 "Logical unit unable to update self-test log") }, 1812 /* DTLPWROMAEBKVF */ 1813 { SST(0x3F, 0x00, SS_RDEF, 1814 "Target operating conditions have changed") }, 1815 /* DTLPWROMAEBKVF */ 1816 { SST(0x3F, 0x01, SS_RDEF, 1817 "Microcode has been changed") }, 1818 /* DTLPWROM BK */ 1819 { SST(0x3F, 0x02, SS_RDEF, 1820 "Changed operating definition") }, 1821 /* DTLPWROMAEBKVF */ 1822 { SST(0x3F, 0x03, SS_RDEF, 1823 "INQUIRY data has changed") }, 1824 /* DT WROMAEBK */ 1825 { SST(0x3F, 0x04, SS_RDEF, 1826 "Component device attached") }, 1827 /* DT WROMAEBK */ 1828 { SST(0x3F, 0x05, SS_RDEF, 1829 "Device identifier changed") }, 1830 /* DT WROMAEB */ 1831 { SST(0x3F, 0x06, SS_RDEF, 1832 "Redundancy group created or modified") }, 1833 /* DT WROMAEB */ 1834 { SST(0x3F, 0x07, SS_RDEF, 1835 "Redundancy group deleted") }, 1836 /* DT WROMAEB */ 1837 { SST(0x3F, 0x08, SS_RDEF, 1838 "Spare created or modified") }, 1839 /* DT WROMAEB */ 1840 { SST(0x3F, 0x09, SS_RDEF, 1841 "Spare deleted") }, 1842 /* DT WROMAEBK */ 1843 { SST(0x3F, 0x0A, SS_RDEF, 1844 "Volume set created or modified") }, 1845 /* DT WROMAEBK */ 1846 { SST(0x3F, 0x0B, SS_RDEF, 1847 "Volume set deleted") }, 1848 /* DT WROMAEBK */ 1849 { SST(0x3F, 0x0C, SS_RDEF, 1850 "Volume set deassigned") }, 1851 /* DT WROMAEBK */ 1852 { SST(0x3F, 0x0D, SS_RDEF, 1853 "Volume set reassigned") }, 1854 /* DTLPWROMAE */ 1855 { SST(0x3F, 0x0E, SS_RDEF, /* XXX TBD */ 1856 "Reported LUNs data has changed") }, 1857 /* DTLPWROMAEBKVF */ 1858 { SST(0x3F, 0x0F, SS_RDEF, /* XXX TBD */ 1859 "Echo buffer overwritten") }, 1860 /* DT WROM B */ 1861 { SST(0x3F, 0x10, SS_RDEF, /* XXX TBD */ 1862 "Medium loadable") }, 1863 /* DT WROM B */ 1864 { SST(0x3F, 0x11, SS_RDEF, /* XXX TBD */ 1865 "Medium auxiliary memory accessible") }, 1866 /* DTLPWR MAEBK F */ 1867 { SST(0x3F, 0x12, SS_RDEF, /* XXX TBD */ 1868 "iSCSI IP address added") }, 1869 /* DTLPWR MAEBK F */ 1870 { SST(0x3F, 0x13, SS_RDEF, /* XXX TBD */ 1871 "iSCSI IP address removed") }, 1872 /* DTLPWR MAEBK F */ 1873 { SST(0x3F, 0x14, SS_RDEF, /* XXX TBD */ 1874 "iSCSI IP address changed") }, 1875 /* D */ 1876 { SST(0x40, 0x00, SS_RDEF, 1877 "RAM failure") }, /* deprecated - use 40 NN instead */ 1878 /* DTLPWROMAEBKVF */ 1879 { SST(0x40, 0x80, SS_RDEF, 1880 "Diagnostic failure: ASCQ = Component ID") }, 1881 /* DTLPWROMAEBKVF */ 1882 { SST(0x40, 0xFF, SS_RDEF | SSQ_RANGE, 1883 NULL) }, /* Range 0x80->0xFF */ 1884 /* D */ 1885 { SST(0x41, 0x00, SS_RDEF, 1886 "Data path failure") }, /* deprecated - use 40 NN instead */ 1887 /* D */ 1888 { SST(0x42, 0x00, SS_RDEF, 1889 "Power-on or self-test failure") }, 1890 /* deprecated - use 40 NN instead */ 1891 /* DTLPWROMAEBKVF */ 1892 { SST(0x43, 0x00, SS_RDEF, 1893 "Message error") }, 1894 /* DTLPWROMAEBKVF */ 1895 { SST(0x44, 0x00, SS_RDEF, 1896 "Internal target failure") }, 1897 /* DT B */ 1898 { SST(0x44, 0x71, SS_RDEF, /* XXX TBD */ 1899 "ATA device failed set features") }, 1900 /* DTLPWROMAEBKVF */ 1901 { SST(0x45, 0x00, SS_RDEF, 1902 "Select or reselect failure") }, 1903 /* DTLPWROM BK */ 1904 { SST(0x46, 0x00, SS_RDEF, 1905 "Unsuccessful soft reset") }, 1906 /* DTLPWROMAEBKVF */ 1907 { SST(0x47, 0x00, SS_RDEF, 1908 "SCSI parity error") }, 1909 /* DTLPWROMAEBKVF */ 1910 { SST(0x47, 0x01, SS_RDEF, /* XXX TBD */ 1911 "Data phase CRC error detected") }, 1912 /* DTLPWROMAEBKVF */ 1913 { SST(0x47, 0x02, SS_RDEF, /* XXX TBD */ 1914 "SCSI parity error detected during ST data phase") }, 1915 /* DTLPWROMAEBKVF */ 1916 { SST(0x47, 0x03, SS_RDEF, /* XXX TBD */ 1917 "Information unit iuCRC error detected") }, 1918 /* DTLPWROMAEBKVF */ 1919 { SST(0x47, 0x04, SS_RDEF, /* XXX TBD */ 1920 "Asynchronous information protection error detected") }, 1921 /* DTLPWROMAEBKVF */ 1922 { SST(0x47, 0x05, SS_RDEF, /* XXX TBD */ 1923 "Protocol service CRC error") }, 1924 /* DT MAEBKVF */ 1925 { SST(0x47, 0x06, SS_RDEF, /* XXX TBD */ 1926 "PHY test function in progress") }, 1927 /* DT PWROMAEBK */ 1928 { SST(0x47, 0x7F, SS_RDEF, /* XXX TBD */ 1929 "Some commands cleared by iSCSI protocol event") }, 1930 /* DTLPWROMAEBKVF */ 1931 { SST(0x48, 0x00, SS_RDEF, 1932 "Initiator detected error message received") }, 1933 /* DTLPWROMAEBKVF */ 1934 { SST(0x49, 0x00, SS_RDEF, 1935 "Invalid message error") }, 1936 /* DTLPWROMAEBKVF */ 1937 { SST(0x4A, 0x00, SS_RDEF, 1938 "Command phase error") }, 1939 /* DTLPWROMAEBKVF */ 1940 { SST(0x4B, 0x00, SS_RDEF, 1941 "Data phase error") }, 1942 /* DT PWROMAEBK */ 1943 { SST(0x4B, 0x01, SS_RDEF, /* XXX TBD */ 1944 "Invalid target port transfer tag received") }, 1945 /* DT PWROMAEBK */ 1946 { SST(0x4B, 0x02, SS_RDEF, /* XXX TBD */ 1947 "Too much write data") }, 1948 /* DT PWROMAEBK */ 1949 { SST(0x4B, 0x03, SS_RDEF, /* XXX TBD */ 1950 "ACK/NAK timeout") }, 1951 /* DT PWROMAEBK */ 1952 { SST(0x4B, 0x04, SS_RDEF, /* XXX TBD */ 1953 "NAK received") }, 1954 /* DT PWROMAEBK */ 1955 { SST(0x4B, 0x05, SS_RDEF, /* XXX TBD */ 1956 "Data offset error") }, 1957 /* DT PWROMAEBK */ 1958 { SST(0x4B, 0x06, SS_RDEF, /* XXX TBD */ 1959 "Initiator response timeout") }, 1960 /* DTLPWROMAEBKVF */ 1961 { SST(0x4C, 0x00, SS_RDEF, 1962 "Logical unit failed self-configuration") }, 1963 /* DTLPWROMAEBKVF */ 1964 { SST(0x4D, 0x00, SS_RDEF, 1965 "Tagged overlapped commands: ASCQ = Queue tag ID") }, 1966 /* DTLPWROMAEBKVF */ 1967 { SST(0x4D, 0xFF, SS_RDEF | SSQ_RANGE, 1968 NULL) }, /* Range 0x00->0xFF */ 1969 /* DTLPWROMAEBKVF */ 1970 { SST(0x4E, 0x00, SS_RDEF, 1971 "Overlapped commands attempted") }, 1972 /* T */ 1973 { SST(0x50, 0x00, SS_RDEF, 1974 "Write append error") }, 1975 /* T */ 1976 { SST(0x50, 0x01, SS_RDEF, 1977 "Write append position error") }, 1978 /* T */ 1979 { SST(0x50, 0x02, SS_RDEF, 1980 "Position error related to timing") }, 1981 /* T RO */ 1982 { SST(0x51, 0x00, SS_RDEF, 1983 "Erase failure") }, 1984 /* R */ 1985 { SST(0x51, 0x01, SS_RDEF, /* XXX TBD */ 1986 "Erase failure - incomplete erase operation detected") }, 1987 /* T */ 1988 { SST(0x52, 0x00, SS_RDEF, 1989 "Cartridge fault") }, 1990 /* DTL WROM BK */ 1991 { SST(0x53, 0x00, SS_RDEF, 1992 "Media load or eject failed") }, 1993 /* T */ 1994 { SST(0x53, 0x01, SS_RDEF, 1995 "Unload tape failure") }, 1996 /* DT WROM BK */ 1997 { SST(0x53, 0x02, SS_RDEF, 1998 "Medium removal prevented") }, 1999 /* M */ 2000 { SST(0x53, 0x03, SS_RDEF, /* XXX TBD */ 2001 "Medium removal prevented by data transfer element") }, 2002 /* T */ 2003 { SST(0x53, 0x04, SS_RDEF, /* XXX TBD */ 2004 "Medium thread or unthread failure") }, 2005 /* P */ 2006 { SST(0x54, 0x00, SS_RDEF, 2007 "SCSI to host system interface failure") }, 2008 /* P */ 2009 { SST(0x55, 0x00, SS_RDEF, 2010 "System resource failure") }, 2011 /* D O BK */ 2012 { SST(0x55, 0x01, SS_FATAL | ENOSPC, 2013 "System buffer full") }, 2014 /* DTLPWROMAE K */ 2015 { SST(0x55, 0x02, SS_RDEF, /* XXX TBD */ 2016 "Insufficient reservation resources") }, 2017 /* DTLPWROMAE K */ 2018 { SST(0x55, 0x03, SS_RDEF, /* XXX TBD */ 2019 "Insufficient resources") }, 2020 /* DTLPWROMAE K */ 2021 { SST(0x55, 0x04, SS_RDEF, /* XXX TBD */ 2022 "Insufficient registration resources") }, 2023 /* DT PWROMAEBK */ 2024 { SST(0x55, 0x05, SS_RDEF, /* XXX TBD */ 2025 "Insufficient access control resources") }, 2026 /* DT WROM B */ 2027 { SST(0x55, 0x06, SS_RDEF, /* XXX TBD */ 2028 "Auxiliary memory out of space") }, 2029 /* F */ 2030 { SST(0x55, 0x07, SS_RDEF, /* XXX TBD */ 2031 "Quota error") }, 2032 /* T */ 2033 { SST(0x55, 0x08, SS_RDEF, /* XXX TBD */ 2034 "Maximum number of supplemental decryption keys exceeded") }, 2035 /* M */ 2036 { SST(0x55, 0x09, SS_RDEF, /* XXX TBD */ 2037 "Medium auxiliary memory not accessible") }, 2038 /* M */ 2039 { SST(0x55, 0x0A, SS_RDEF, /* XXX TBD */ 2040 "Data currently unavailable") }, 2041 /* R */ 2042 { SST(0x57, 0x00, SS_RDEF, 2043 "Unable to recover table-of-contents") }, 2044 /* O */ 2045 { SST(0x58, 0x00, SS_RDEF, 2046 "Generation does not exist") }, 2047 /* O */ 2048 { SST(0x59, 0x00, SS_RDEF, 2049 "Updated block read") }, 2050 /* DTLPWRO BK */ 2051 { SST(0x5A, 0x00, SS_RDEF, 2052 "Operator request or state change input") }, 2053 /* DT WROM BK */ 2054 { SST(0x5A, 0x01, SS_RDEF, 2055 "Operator medium removal request") }, 2056 /* DT WRO A BK */ 2057 { SST(0x5A, 0x02, SS_RDEF, 2058 "Operator selected write protect") }, 2059 /* DT WRO A BK */ 2060 { SST(0x5A, 0x03, SS_RDEF, 2061 "Operator selected write permit") }, 2062 /* DTLPWROM K */ 2063 { SST(0x5B, 0x00, SS_RDEF, 2064 "Log exception") }, 2065 /* DTLPWROM K */ 2066 { SST(0x5B, 0x01, SS_RDEF, 2067 "Threshold condition met") }, 2068 /* DTLPWROM K */ 2069 { SST(0x5B, 0x02, SS_RDEF, 2070 "Log counter at maximum") }, 2071 /* DTLPWROM K */ 2072 { SST(0x5B, 0x03, SS_RDEF, 2073 "Log list codes exhausted") }, 2074 /* D O */ 2075 { SST(0x5C, 0x00, SS_RDEF, 2076 "RPL status change") }, 2077 /* D O */ 2078 { SST(0x5C, 0x01, SS_NOP | SSQ_PRINT_SENSE, 2079 "Spindles synchronized") }, 2080 /* D O */ 2081 { SST(0x5C, 0x02, SS_RDEF, 2082 "Spindles not synchronized") }, 2083 /* DTLPWROMAEBKVF */ 2084 { SST(0x5D, 0x00, SS_RDEF, 2085 "Failure prediction threshold exceeded") }, 2086 /* R B */ 2087 { SST(0x5D, 0x01, SS_RDEF, /* XXX TBD */ 2088 "Media failure prediction threshold exceeded") }, 2089 /* R */ 2090 { SST(0x5D, 0x02, SS_RDEF, /* XXX TBD */ 2091 "Logical unit failure prediction threshold exceeded") }, 2092 /* R */ 2093 { SST(0x5D, 0x03, SS_RDEF, /* XXX TBD */ 2094 "Spare area exhaustion prediction threshold exceeded") }, 2095 /* D B */ 2096 { SST(0x5D, 0x10, SS_RDEF, /* XXX TBD */ 2097 "Hardware impending failure general hard drive failure") }, 2098 /* D B */ 2099 { SST(0x5D, 0x11, SS_RDEF, /* XXX TBD */ 2100 "Hardware impending failure drive error rate too high") }, 2101 /* D B */ 2102 { SST(0x5D, 0x12, SS_RDEF, /* XXX TBD */ 2103 "Hardware impending failure data error rate too high") }, 2104 /* D B */ 2105 { SST(0x5D, 0x13, SS_RDEF, /* XXX TBD */ 2106 "Hardware impending failure seek error rate too high") }, 2107 /* D B */ 2108 { SST(0x5D, 0x14, SS_RDEF, /* XXX TBD */ 2109 "Hardware impending failure too many block reassigns") }, 2110 /* D B */ 2111 { SST(0x5D, 0x15, SS_RDEF, /* XXX TBD */ 2112 "Hardware impending failure access times too high") }, 2113 /* D B */ 2114 { SST(0x5D, 0x16, SS_RDEF, /* XXX TBD */ 2115 "Hardware impending failure start unit times too high") }, 2116 /* D B */ 2117 { SST(0x5D, 0x17, SS_RDEF, /* XXX TBD */ 2118 "Hardware impending failure channel parametrics") }, 2119 /* D B */ 2120 { SST(0x5D, 0x18, SS_RDEF, /* XXX TBD */ 2121 "Hardware impending failure controller detected") }, 2122 /* D B */ 2123 { SST(0x5D, 0x19, SS_RDEF, /* XXX TBD */ 2124 "Hardware impending failure throughput performance") }, 2125 /* D B */ 2126 { SST(0x5D, 0x1A, SS_RDEF, /* XXX TBD */ 2127 "Hardware impending failure seek time performance") }, 2128 /* D B */ 2129 { SST(0x5D, 0x1B, SS_RDEF, /* XXX TBD */ 2130 "Hardware impending failure spin-up retry count") }, 2131 /* D B */ 2132 { SST(0x5D, 0x1C, SS_RDEF, /* XXX TBD */ 2133 "Hardware impending failure drive calibration retry count") }, 2134 /* D B */ 2135 { SST(0x5D, 0x20, SS_RDEF, /* XXX TBD */ 2136 "Controller impending failure general hard drive failure") }, 2137 /* D B */ 2138 { SST(0x5D, 0x21, SS_RDEF, /* XXX TBD */ 2139 "Controller impending failure drive error rate too high") }, 2140 /* D B */ 2141 { SST(0x5D, 0x22, SS_RDEF, /* XXX TBD */ 2142 "Controller impending failure data error rate too high") }, 2143 /* D B */ 2144 { SST(0x5D, 0x23, SS_RDEF, /* XXX TBD */ 2145 "Controller impending failure seek error rate too high") }, 2146 /* D B */ 2147 { SST(0x5D, 0x24, SS_RDEF, /* XXX TBD */ 2148 "Controller impending failure too many block reassigns") }, 2149 /* D B */ 2150 { SST(0x5D, 0x25, SS_RDEF, /* XXX TBD */ 2151 "Controller impending failure access times too high") }, 2152 /* D B */ 2153 { SST(0x5D, 0x26, SS_RDEF, /* XXX TBD */ 2154 "Controller impending failure start unit times too high") }, 2155 /* D B */ 2156 { SST(0x5D, 0x27, SS_RDEF, /* XXX TBD */ 2157 "Controller impending failure channel parametrics") }, 2158 /* D B */ 2159 { SST(0x5D, 0x28, SS_RDEF, /* XXX TBD */ 2160 "Controller impending failure controller detected") }, 2161 /* D B */ 2162 { SST(0x5D, 0x29, SS_RDEF, /* XXX TBD */ 2163 "Controller impending failure throughput performance") }, 2164 /* D B */ 2165 { SST(0x5D, 0x2A, SS_RDEF, /* XXX TBD */ 2166 "Controller impending failure seek time performance") }, 2167 /* D B */ 2168 { SST(0x5D, 0x2B, SS_RDEF, /* XXX TBD */ 2169 "Controller impending failure spin-up retry count") }, 2170 /* D B */ 2171 { SST(0x5D, 0x2C, SS_RDEF, /* XXX TBD */ 2172 "Controller impending failure drive calibration retry count") }, 2173 /* D B */ 2174 { SST(0x5D, 0x30, SS_RDEF, /* XXX TBD */ 2175 "Data channel impending failure general hard drive failure") }, 2176 /* D B */ 2177 { SST(0x5D, 0x31, SS_RDEF, /* XXX TBD */ 2178 "Data channel impending failure drive error rate too high") }, 2179 /* D B */ 2180 { SST(0x5D, 0x32, SS_RDEF, /* XXX TBD */ 2181 "Data channel impending failure data error rate too high") }, 2182 /* D B */ 2183 { SST(0x5D, 0x33, SS_RDEF, /* XXX TBD */ 2184 "Data channel impending failure seek error rate too high") }, 2185 /* D B */ 2186 { SST(0x5D, 0x34, SS_RDEF, /* XXX TBD */ 2187 "Data channel impending failure too many block reassigns") }, 2188 /* D B */ 2189 { SST(0x5D, 0x35, SS_RDEF, /* XXX TBD */ 2190 "Data channel impending failure access times too high") }, 2191 /* D B */ 2192 { SST(0x5D, 0x36, SS_RDEF, /* XXX TBD */ 2193 "Data channel impending failure start unit times too high") }, 2194 /* D B */ 2195 { SST(0x5D, 0x37, SS_RDEF, /* XXX TBD */ 2196 "Data channel impending failure channel parametrics") }, 2197 /* D B */ 2198 { SST(0x5D, 0x38, SS_RDEF, /* XXX TBD */ 2199 "Data channel impending failure controller detected") }, 2200 /* D B */ 2201 { SST(0x5D, 0x39, SS_RDEF, /* XXX TBD */ 2202 "Data channel impending failure throughput performance") }, 2203 /* D B */ 2204 { SST(0x5D, 0x3A, SS_RDEF, /* XXX TBD */ 2205 "Data channel impending failure seek time performance") }, 2206 /* D B */ 2207 { SST(0x5D, 0x3B, SS_RDEF, /* XXX TBD */ 2208 "Data channel impending failure spin-up retry count") }, 2209 /* D B */ 2210 { SST(0x5D, 0x3C, SS_RDEF, /* XXX TBD */ 2211 "Data channel impending failure drive calibration retry count") }, 2212 /* D B */ 2213 { SST(0x5D, 0x40, SS_RDEF, /* XXX TBD */ 2214 "Servo impending failure general hard drive failure") }, 2215 /* D B */ 2216 { SST(0x5D, 0x41, SS_RDEF, /* XXX TBD */ 2217 "Servo impending failure drive error rate too high") }, 2218 /* D B */ 2219 { SST(0x5D, 0x42, SS_RDEF, /* XXX TBD */ 2220 "Servo impending failure data error rate too high") }, 2221 /* D B */ 2222 { SST(0x5D, 0x43, SS_RDEF, /* XXX TBD */ 2223 "Servo impending failure seek error rate too high") }, 2224 /* D B */ 2225 { SST(0x5D, 0x44, SS_RDEF, /* XXX TBD */ 2226 "Servo impending failure too many block reassigns") }, 2227 /* D B */ 2228 { SST(0x5D, 0x45, SS_RDEF, /* XXX TBD */ 2229 "Servo impending failure access times too high") }, 2230 /* D B */ 2231 { SST(0x5D, 0x46, SS_RDEF, /* XXX TBD */ 2232 "Servo impending failure start unit times too high") }, 2233 /* D B */ 2234 { SST(0x5D, 0x47, SS_RDEF, /* XXX TBD */ 2235 "Servo impending failure channel parametrics") }, 2236 /* D B */ 2237 { SST(0x5D, 0x48, SS_RDEF, /* XXX TBD */ 2238 "Servo impending failure controller detected") }, 2239 /* D B */ 2240 { SST(0x5D, 0x49, SS_RDEF, /* XXX TBD */ 2241 "Servo impending failure throughput performance") }, 2242 /* D B */ 2243 { SST(0x5D, 0x4A, SS_RDEF, /* XXX TBD */ 2244 "Servo impending failure seek time performance") }, 2245 /* D B */ 2246 { SST(0x5D, 0x4B, SS_RDEF, /* XXX TBD */ 2247 "Servo impending failure spin-up retry count") }, 2248 /* D B */ 2249 { SST(0x5D, 0x4C, SS_RDEF, /* XXX TBD */ 2250 "Servo impending failure drive calibration retry count") }, 2251 /* D B */ 2252 { SST(0x5D, 0x50, SS_RDEF, /* XXX TBD */ 2253 "Spindle impending failure general hard drive failure") }, 2254 /* D B */ 2255 { SST(0x5D, 0x51, SS_RDEF, /* XXX TBD */ 2256 "Spindle impending failure drive error rate too high") }, 2257 /* D B */ 2258 { SST(0x5D, 0x52, SS_RDEF, /* XXX TBD */ 2259 "Spindle impending failure data error rate too high") }, 2260 /* D B */ 2261 { SST(0x5D, 0x53, SS_RDEF, /* XXX TBD */ 2262 "Spindle impending failure seek error rate too high") }, 2263 /* D B */ 2264 { SST(0x5D, 0x54, SS_RDEF, /* XXX TBD */ 2265 "Spindle impending failure too many block reassigns") }, 2266 /* D B */ 2267 { SST(0x5D, 0x55, SS_RDEF, /* XXX TBD */ 2268 "Spindle impending failure access times too high") }, 2269 /* D B */ 2270 { SST(0x5D, 0x56, SS_RDEF, /* XXX TBD */ 2271 "Spindle impending failure start unit times too high") }, 2272 /* D B */ 2273 { SST(0x5D, 0x57, SS_RDEF, /* XXX TBD */ 2274 "Spindle impending failure channel parametrics") }, 2275 /* D B */ 2276 { SST(0x5D, 0x58, SS_RDEF, /* XXX TBD */ 2277 "Spindle impending failure controller detected") }, 2278 /* D B */ 2279 { SST(0x5D, 0x59, SS_RDEF, /* XXX TBD */ 2280 "Spindle impending failure throughput performance") }, 2281 /* D B */ 2282 { SST(0x5D, 0x5A, SS_RDEF, /* XXX TBD */ 2283 "Spindle impending failure seek time performance") }, 2284 /* D B */ 2285 { SST(0x5D, 0x5B, SS_RDEF, /* XXX TBD */ 2286 "Spindle impending failure spin-up retry count") }, 2287 /* D B */ 2288 { SST(0x5D, 0x5C, SS_RDEF, /* XXX TBD */ 2289 "Spindle impending failure drive calibration retry count") }, 2290 /* D B */ 2291 { SST(0x5D, 0x60, SS_RDEF, /* XXX TBD */ 2292 "Firmware impending failure general hard drive failure") }, 2293 /* D B */ 2294 { SST(0x5D, 0x61, SS_RDEF, /* XXX TBD */ 2295 "Firmware impending failure drive error rate too high") }, 2296 /* D B */ 2297 { SST(0x5D, 0x62, SS_RDEF, /* XXX TBD */ 2298 "Firmware impending failure data error rate too high") }, 2299 /* D B */ 2300 { SST(0x5D, 0x63, SS_RDEF, /* XXX TBD */ 2301 "Firmware impending failure seek error rate too high") }, 2302 /* D B */ 2303 { SST(0x5D, 0x64, SS_RDEF, /* XXX TBD */ 2304 "Firmware impending failure too many block reassigns") }, 2305 /* D B */ 2306 { SST(0x5D, 0x65, SS_RDEF, /* XXX TBD */ 2307 "Firmware impending failure access times too high") }, 2308 /* D B */ 2309 { SST(0x5D, 0x66, SS_RDEF, /* XXX TBD */ 2310 "Firmware impending failure start unit times too high") }, 2311 /* D B */ 2312 { SST(0x5D, 0x67, SS_RDEF, /* XXX TBD */ 2313 "Firmware impending failure channel parametrics") }, 2314 /* D B */ 2315 { SST(0x5D, 0x68, SS_RDEF, /* XXX TBD */ 2316 "Firmware impending failure controller detected") }, 2317 /* D B */ 2318 { SST(0x5D, 0x69, SS_RDEF, /* XXX TBD */ 2319 "Firmware impending failure throughput performance") }, 2320 /* D B */ 2321 { SST(0x5D, 0x6A, SS_RDEF, /* XXX TBD */ 2322 "Firmware impending failure seek time performance") }, 2323 /* D B */ 2324 { SST(0x5D, 0x6B, SS_RDEF, /* XXX TBD */ 2325 "Firmware impending failure spin-up retry count") }, 2326 /* D B */ 2327 { SST(0x5D, 0x6C, SS_RDEF, /* XXX TBD */ 2328 "Firmware impending failure drive calibration retry count") }, 2329 /* DTLPWROMAEBKVF */ 2330 { SST(0x5D, 0xFF, SS_RDEF, 2331 "Failure prediction threshold exceeded (false)") }, 2332 /* DTLPWRO A K */ 2333 { SST(0x5E, 0x00, SS_RDEF, 2334 "Low power condition on") }, 2335 /* DTLPWRO A K */ 2336 { SST(0x5E, 0x01, SS_RDEF, 2337 "Idle condition activated by timer") }, 2338 /* DTLPWRO A K */ 2339 { SST(0x5E, 0x02, SS_RDEF, 2340 "Standby condition activated by timer") }, 2341 /* DTLPWRO A K */ 2342 { SST(0x5E, 0x03, SS_RDEF, 2343 "Idle condition activated by command") }, 2344 /* DTLPWRO A K */ 2345 { SST(0x5E, 0x04, SS_RDEF, 2346 "Standby condition activated by command") }, 2347 /* B */ 2348 { SST(0x5E, 0x41, SS_RDEF, /* XXX TBD */ 2349 "Power state change to active") }, 2350 /* B */ 2351 { SST(0x5E, 0x42, SS_RDEF, /* XXX TBD */ 2352 "Power state change to idle") }, 2353 /* B */ 2354 { SST(0x5E, 0x43, SS_RDEF, /* XXX TBD */ 2355 "Power state change to standby") }, 2356 /* B */ 2357 { SST(0x5E, 0x45, SS_RDEF, /* XXX TBD */ 2358 "Power state change to sleep") }, 2359 /* BK */ 2360 { SST(0x5E, 0x47, SS_RDEF, /* XXX TBD */ 2361 "Power state change to device control") }, 2362 /* */ 2363 { SST(0x60, 0x00, SS_RDEF, 2364 "Lamp failure") }, 2365 /* */ 2366 { SST(0x61, 0x00, SS_RDEF, 2367 "Video acquisition error") }, 2368 /* */ 2369 { SST(0x61, 0x01, SS_RDEF, 2370 "Unable to acquire video") }, 2371 /* */ 2372 { SST(0x61, 0x02, SS_RDEF, 2373 "Out of focus") }, 2374 /* */ 2375 { SST(0x62, 0x00, SS_RDEF, 2376 "Scan head positioning error") }, 2377 /* R */ 2378 { SST(0x63, 0x00, SS_RDEF, 2379 "End of user area encountered on this track") }, 2380 /* R */ 2381 { SST(0x63, 0x01, SS_FATAL | ENOSPC, 2382 "Packet does not fit in available space") }, 2383 /* R */ 2384 { SST(0x64, 0x00, SS_FATAL | ENXIO, 2385 "Illegal mode for this track") }, 2386 /* R */ 2387 { SST(0x64, 0x01, SS_RDEF, 2388 "Invalid packet size") }, 2389 /* DTLPWROMAEBKVF */ 2390 { SST(0x65, 0x00, SS_RDEF, 2391 "Voltage fault") }, 2392 /* */ 2393 { SST(0x66, 0x00, SS_RDEF, 2394 "Automatic document feeder cover up") }, 2395 /* */ 2396 { SST(0x66, 0x01, SS_RDEF, 2397 "Automatic document feeder lift up") }, 2398 /* */ 2399 { SST(0x66, 0x02, SS_RDEF, 2400 "Document jam in automatic document feeder") }, 2401 /* */ 2402 { SST(0x66, 0x03, SS_RDEF, 2403 "Document miss feed automatic in document feeder") }, 2404 /* A */ 2405 { SST(0x67, 0x00, SS_RDEF, 2406 "Configuration failure") }, 2407 /* A */ 2408 { SST(0x67, 0x01, SS_RDEF, 2409 "Configuration of incapable logical units failed") }, 2410 /* A */ 2411 { SST(0x67, 0x02, SS_RDEF, 2412 "Add logical unit failed") }, 2413 /* A */ 2414 { SST(0x67, 0x03, SS_RDEF, 2415 "Modification of logical unit failed") }, 2416 /* A */ 2417 { SST(0x67, 0x04, SS_RDEF, 2418 "Exchange of logical unit failed") }, 2419 /* A */ 2420 { SST(0x67, 0x05, SS_RDEF, 2421 "Remove of logical unit failed") }, 2422 /* A */ 2423 { SST(0x67, 0x06, SS_RDEF, 2424 "Attachment of logical unit failed") }, 2425 /* A */ 2426 { SST(0x67, 0x07, SS_RDEF, 2427 "Creation of logical unit failed") }, 2428 /* A */ 2429 { SST(0x67, 0x08, SS_RDEF, /* XXX TBD */ 2430 "Assign failure occurred") }, 2431 /* A */ 2432 { SST(0x67, 0x09, SS_RDEF, /* XXX TBD */ 2433 "Multiply assigned logical unit") }, 2434 /* DTLPWROMAEBKVF */ 2435 { SST(0x67, 0x0A, SS_RDEF, /* XXX TBD */ 2436 "Set target port groups command failed") }, 2437 /* DT B */ 2438 { SST(0x67, 0x0B, SS_RDEF, /* XXX TBD */ 2439 "ATA device feature not enabled") }, 2440 /* A */ 2441 { SST(0x68, 0x00, SS_RDEF, 2442 "Logical unit not configured") }, 2443 /* A */ 2444 { SST(0x69, 0x00, SS_RDEF, 2445 "Data loss on logical unit") }, 2446 /* A */ 2447 { SST(0x69, 0x01, SS_RDEF, 2448 "Multiple logical unit failures") }, 2449 /* A */ 2450 { SST(0x69, 0x02, SS_RDEF, 2451 "Parity/data mismatch") }, 2452 /* A */ 2453 { SST(0x6A, 0x00, SS_RDEF, 2454 "Informational, refer to log") }, 2455 /* A */ 2456 { SST(0x6B, 0x00, SS_RDEF, 2457 "State change has occurred") }, 2458 /* A */ 2459 { SST(0x6B, 0x01, SS_RDEF, 2460 "Redundancy level got better") }, 2461 /* A */ 2462 { SST(0x6B, 0x02, SS_RDEF, 2463 "Redundancy level got worse") }, 2464 /* A */ 2465 { SST(0x6C, 0x00, SS_RDEF, 2466 "Rebuild failure occurred") }, 2467 /* A */ 2468 { SST(0x6D, 0x00, SS_RDEF, 2469 "Recalculate failure occurred") }, 2470 /* A */ 2471 { SST(0x6E, 0x00, SS_RDEF, 2472 "Command to logical unit failed") }, 2473 /* R */ 2474 { SST(0x6F, 0x00, SS_RDEF, /* XXX TBD */ 2475 "Copy protection key exchange failure - authentication failure") }, 2476 /* R */ 2477 { SST(0x6F, 0x01, SS_RDEF, /* XXX TBD */ 2478 "Copy protection key exchange failure - key not present") }, 2479 /* R */ 2480 { SST(0x6F, 0x02, SS_RDEF, /* XXX TBD */ 2481 "Copy protection key exchange failure - key not established") }, 2482 /* R */ 2483 { SST(0x6F, 0x03, SS_RDEF, /* XXX TBD */ 2484 "Read of scrambled sector without authentication") }, 2485 /* R */ 2486 { SST(0x6F, 0x04, SS_RDEF, /* XXX TBD */ 2487 "Media region code is mismatched to logical unit region") }, 2488 /* R */ 2489 { SST(0x6F, 0x05, SS_RDEF, /* XXX TBD */ 2490 "Drive region must be permanent/region reset count error") }, 2491 /* R */ 2492 { SST(0x6F, 0x06, SS_RDEF, /* XXX TBD */ 2493 "Insufficient block count for binding NONCE recording") }, 2494 /* R */ 2495 { SST(0x6F, 0x07, SS_RDEF, /* XXX TBD */ 2496 "Conflict in binding NONCE recording") }, 2497 /* T */ 2498 { SST(0x70, 0x00, SS_RDEF, 2499 "Decompression exception short: ASCQ = Algorithm ID") }, 2500 /* T */ 2501 { SST(0x70, 0xFF, SS_RDEF | SSQ_RANGE, 2502 NULL) }, /* Range 0x00 -> 0xFF */ 2503 /* T */ 2504 { SST(0x71, 0x00, SS_RDEF, 2505 "Decompression exception long: ASCQ = Algorithm ID") }, 2506 /* T */ 2507 { SST(0x71, 0xFF, SS_RDEF | SSQ_RANGE, 2508 NULL) }, /* Range 0x00 -> 0xFF */ 2509 /* R */ 2510 { SST(0x72, 0x00, SS_RDEF, 2511 "Session fixation error") }, 2512 /* R */ 2513 { SST(0x72, 0x01, SS_RDEF, 2514 "Session fixation error writing lead-in") }, 2515 /* R */ 2516 { SST(0x72, 0x02, SS_RDEF, 2517 "Session fixation error writing lead-out") }, 2518 /* R */ 2519 { SST(0x72, 0x03, SS_RDEF, 2520 "Session fixation error - incomplete track in session") }, 2521 /* R */ 2522 { SST(0x72, 0x04, SS_RDEF, 2523 "Empty or partially written reserved track") }, 2524 /* R */ 2525 { SST(0x72, 0x05, SS_RDEF, /* XXX TBD */ 2526 "No more track reservations allowed") }, 2527 /* R */ 2528 { SST(0x72, 0x06, SS_RDEF, /* XXX TBD */ 2529 "RMZ extension is not allowed") }, 2530 /* R */ 2531 { SST(0x72, 0x07, SS_RDEF, /* XXX TBD */ 2532 "No more test zone extensions are allowed") }, 2533 /* R */ 2534 { SST(0x73, 0x00, SS_RDEF, 2535 "CD control error") }, 2536 /* R */ 2537 { SST(0x73, 0x01, SS_RDEF, 2538 "Power calibration area almost full") }, 2539 /* R */ 2540 { SST(0x73, 0x02, SS_FATAL | ENOSPC, 2541 "Power calibration area is full") }, 2542 /* R */ 2543 { SST(0x73, 0x03, SS_RDEF, 2544 "Power calibration area error") }, 2545 /* R */ 2546 { SST(0x73, 0x04, SS_RDEF, 2547 "Program memory area update failure") }, 2548 /* R */ 2549 { SST(0x73, 0x05, SS_RDEF, 2550 "Program memory area is full") }, 2551 /* R */ 2552 { SST(0x73, 0x06, SS_RDEF, /* XXX TBD */ 2553 "RMA/PMA is almost full") }, 2554 /* R */ 2555 { SST(0x73, 0x10, SS_RDEF, /* XXX TBD */ 2556 "Current power calibration area almost full") }, 2557 /* R */ 2558 { SST(0x73, 0x11, SS_RDEF, /* XXX TBD */ 2559 "Current power calibration area is full") }, 2560 /* R */ 2561 { SST(0x73, 0x17, SS_RDEF, /* XXX TBD */ 2562 "RDZ is full") }, 2563 /* T */ 2564 { SST(0x74, 0x00, SS_RDEF, /* XXX TBD */ 2565 "Security error") }, 2566 /* T */ 2567 { SST(0x74, 0x01, SS_RDEF, /* XXX TBD */ 2568 "Unable to decrypt data") }, 2569 /* T */ 2570 { SST(0x74, 0x02, SS_RDEF, /* XXX TBD */ 2571 "Unencrypted data encountered while decrypting") }, 2572 /* T */ 2573 { SST(0x74, 0x03, SS_RDEF, /* XXX TBD */ 2574 "Incorrect data encryption key") }, 2575 /* T */ 2576 { SST(0x74, 0x04, SS_RDEF, /* XXX TBD */ 2577 "Cryptographic integrity validation failed") }, 2578 /* T */ 2579 { SST(0x74, 0x05, SS_RDEF, /* XXX TBD */ 2580 "Error decrypting data") }, 2581 /* T */ 2582 { SST(0x74, 0x06, SS_RDEF, /* XXX TBD */ 2583 "Unknown signature verification key") }, 2584 /* T */ 2585 { SST(0x74, 0x07, SS_RDEF, /* XXX TBD */ 2586 "Encryption parameters not usable") }, 2587 /* DT R M E VF */ 2588 { SST(0x74, 0x08, SS_RDEF, /* XXX TBD */ 2589 "Digital signature validation failure") }, 2590 /* T */ 2591 { SST(0x74, 0x09, SS_RDEF, /* XXX TBD */ 2592 "Encryption mode mismatch on read") }, 2593 /* T */ 2594 { SST(0x74, 0x0A, SS_RDEF, /* XXX TBD */ 2595 "Encrypted block not raw read enabled") }, 2596 /* T */ 2597 { SST(0x74, 0x0B, SS_RDEF, /* XXX TBD */ 2598 "Incorrect encryption parameters") }, 2599 /* DT R MAEBKV */ 2600 { SST(0x74, 0x0C, SS_RDEF, /* XXX TBD */ 2601 "Unable to decrypt parameter list") }, 2602 /* T */ 2603 { SST(0x74, 0x0D, SS_RDEF, /* XXX TBD */ 2604 "Encryption algorithm disabled") }, 2605 /* DT R MAEBKV */ 2606 { SST(0x74, 0x10, SS_RDEF, /* XXX TBD */ 2607 "SA creation parameter value invalid") }, 2608 /* DT R MAEBKV */ 2609 { SST(0x74, 0x11, SS_RDEF, /* XXX TBD */ 2610 "SA creation parameter value rejected") }, 2611 /* DT R MAEBKV */ 2612 { SST(0x74, 0x12, SS_RDEF, /* XXX TBD */ 2613 "Invalid SA usage") }, 2614 /* T */ 2615 { SST(0x74, 0x21, SS_RDEF, /* XXX TBD */ 2616 "Data encryption configuration prevented") }, 2617 /* DT R MAEBKV */ 2618 { SST(0x74, 0x30, SS_RDEF, /* XXX TBD */ 2619 "SA creation parameter not supported") }, 2620 /* DT R MAEBKV */ 2621 { SST(0x74, 0x40, SS_RDEF, /* XXX TBD */ 2622 "Authentication failed") }, 2623 /* V */ 2624 { SST(0x74, 0x61, SS_RDEF, /* XXX TBD */ 2625 "External data encryption key manager access error") }, 2626 /* V */ 2627 { SST(0x74, 0x62, SS_RDEF, /* XXX TBD */ 2628 "External data encryption key manager error") }, 2629 /* V */ 2630 { SST(0x74, 0x63, SS_RDEF, /* XXX TBD */ 2631 "External data encryption key not found") }, 2632 /* V */ 2633 { SST(0x74, 0x64, SS_RDEF, /* XXX TBD */ 2634 "External data encryption request not authorized") }, 2635 /* T */ 2636 { SST(0x74, 0x6E, SS_RDEF, /* XXX TBD */ 2637 "External data encryption control timeout") }, 2638 /* T */ 2639 { SST(0x74, 0x6F, SS_RDEF, /* XXX TBD */ 2640 "External data encryption control error") }, 2641 /* DT R M E V */ 2642 { SST(0x74, 0x71, SS_RDEF, /* XXX TBD */ 2643 "Logical unit access not authorized") }, 2644 /* D */ 2645 { SST(0x74, 0x79, SS_RDEF, /* XXX TBD */ 2646 "Security conflict in translated device") } 2647 }; 2648 2649 const int asc_table_size = sizeof(asc_table)/sizeof(asc_table[0]); 2650 2651 struct asc_key 2652 { 2653 int asc; 2654 int ascq; 2655 }; 2656 2657 static int 2658 ascentrycomp(const void *key, const void *member) 2659 { 2660 int asc; 2661 int ascq; 2662 const struct asc_table_entry *table_entry; 2663 2664 asc = ((const struct asc_key *)key)->asc; 2665 ascq = ((const struct asc_key *)key)->ascq; 2666 table_entry = (const struct asc_table_entry *)member; 2667 2668 if (asc >= table_entry->asc) { 2669 2670 if (asc > table_entry->asc) 2671 return (1); 2672 2673 if (ascq <= table_entry->ascq) { 2674 /* Check for ranges */ 2675 if (ascq == table_entry->ascq 2676 || ((table_entry->action & SSQ_RANGE) != 0 2677 && ascq >= (table_entry - 1)->ascq)) 2678 return (0); 2679 return (-1); 2680 } 2681 return (1); 2682 } 2683 return (-1); 2684 } 2685 2686 static int 2687 senseentrycomp(const void *key, const void *member) 2688 { 2689 int sense_key; 2690 const struct sense_key_table_entry *table_entry; 2691 2692 sense_key = *((const int *)key); 2693 table_entry = (const struct sense_key_table_entry *)member; 2694 2695 if (sense_key >= table_entry->sense_key) { 2696 if (sense_key == table_entry->sense_key) 2697 return (0); 2698 return (1); 2699 } 2700 return (-1); 2701 } 2702 2703 static void 2704 fetchtableentries(int sense_key, int asc, int ascq, 2705 struct scsi_inquiry_data *inq_data, 2706 const struct sense_key_table_entry **sense_entry, 2707 const struct asc_table_entry **asc_entry) 2708 { 2709 caddr_t match; 2710 const struct asc_table_entry *asc_tables[2]; 2711 const struct sense_key_table_entry *sense_tables[2]; 2712 struct asc_key asc_ascq; 2713 size_t asc_tables_size[2]; 2714 size_t sense_tables_size[2]; 2715 int num_asc_tables; 2716 int num_sense_tables; 2717 int i; 2718 2719 /* Default to failure */ 2720 *sense_entry = NULL; 2721 *asc_entry = NULL; 2722 match = NULL; 2723 if (inq_data != NULL) 2724 match = cam_quirkmatch((caddr_t)inq_data, 2725 (caddr_t)sense_quirk_table, 2726 sense_quirk_table_size, 2727 sizeof(*sense_quirk_table), 2728 scsi_inquiry_match); 2729 2730 if (match != NULL) { 2731 struct scsi_sense_quirk_entry *quirk; 2732 2733 quirk = (struct scsi_sense_quirk_entry *)match; 2734 asc_tables[0] = quirk->asc_info; 2735 asc_tables_size[0] = quirk->num_ascs; 2736 asc_tables[1] = asc_table; 2737 asc_tables_size[1] = asc_table_size; 2738 num_asc_tables = 2; 2739 sense_tables[0] = quirk->sense_key_info; 2740 sense_tables_size[0] = quirk->num_sense_keys; 2741 sense_tables[1] = sense_key_table; 2742 sense_tables_size[1] = sense_key_table_size; 2743 num_sense_tables = 2; 2744 } else { 2745 asc_tables[0] = asc_table; 2746 asc_tables_size[0] = asc_table_size; 2747 num_asc_tables = 1; 2748 sense_tables[0] = sense_key_table; 2749 sense_tables_size[0] = sense_key_table_size; 2750 num_sense_tables = 1; 2751 } 2752 2753 asc_ascq.asc = asc; 2754 asc_ascq.ascq = ascq; 2755 for (i = 0; i < num_asc_tables; i++) { 2756 void *found_entry; 2757 2758 found_entry = kbsearch(&asc_ascq, asc_tables[i], 2759 asc_tables_size[i], 2760 sizeof(**asc_tables), 2761 ascentrycomp); 2762 2763 if (found_entry) { 2764 *asc_entry = (struct asc_table_entry *)found_entry; 2765 break; 2766 } 2767 } 2768 2769 for (i = 0; i < num_sense_tables; i++) { 2770 void *found_entry; 2771 2772 found_entry = kbsearch(&sense_key, sense_tables[i], 2773 sense_tables_size[i], 2774 sizeof(**sense_tables), 2775 senseentrycomp); 2776 2777 if (found_entry) { 2778 *sense_entry = 2779 (struct sense_key_table_entry *)found_entry; 2780 break; 2781 } 2782 } 2783 } 2784 2785 void 2786 scsi_sense_desc(int sense_key, int asc, int ascq, 2787 struct scsi_inquiry_data *inq_data, 2788 const char **sense_key_desc, const char **asc_desc) 2789 { 2790 const struct asc_table_entry *asc_entry; 2791 const struct sense_key_table_entry *sense_entry; 2792 2793 fetchtableentries(sense_key, asc, ascq, 2794 inq_data, 2795 &sense_entry, 2796 &asc_entry); 2797 2798 *sense_key_desc = sense_entry->desc; 2799 2800 if (asc_entry != NULL) 2801 *asc_desc = asc_entry->desc; 2802 else if (asc >= 0x80 && asc <= 0xff) 2803 *asc_desc = "Vendor Specific ASC"; 2804 else if (ascq >= 0x80 && ascq <= 0xff) 2805 *asc_desc = "Vendor Specific ASCQ"; 2806 else 2807 *asc_desc = "Reserved ASC/ASCQ pair"; 2808 } 2809 2810 /* 2811 * Given sense and device type information, return the appropriate action. 2812 * If we do not understand the specific error as identified by the ASC/ASCQ 2813 * pair, fall back on the more generic actions derived from the sense key. 2814 */ 2815 scsi_sense_action 2816 scsi_error_action(struct ccb_scsiio *csio, struct scsi_inquiry_data *inq_data, 2817 u_int32_t sense_flags) 2818 { 2819 const struct asc_table_entry *asc_entry; 2820 const struct sense_key_table_entry *sense_entry; 2821 int error_code, sense_key, asc, ascq; 2822 scsi_sense_action action; 2823 2824 scsi_extract_sense(&csio->sense_data, &error_code, 2825 &sense_key, &asc, &ascq); 2826 2827 if (error_code == SSD_DEFERRED_ERROR) { 2828 /* 2829 * XXX dufault@FreeBSD.org 2830 * This error doesn't relate to the command associated 2831 * with this request sense. A deferred error is an error 2832 * for a command that has already returned GOOD status 2833 * (see SCSI2 8.2.14.2). 2834 * 2835 * By my reading of that section, it looks like the current 2836 * command has been cancelled, we should now clean things up 2837 * (hopefully recovering any lost data) and then retry the 2838 * current command. There are two easy choices, both wrong: 2839 * 2840 * 1. Drop through (like we had been doing), thus treating 2841 * this as if the error were for the current command and 2842 * return and stop the current command. 2843 * 2844 * 2. Issue a retry (like I made it do) thus hopefully 2845 * recovering the current transfer, and ignoring the 2846 * fact that we've dropped a command. 2847 * 2848 * These should probably be handled in a device specific 2849 * sense handler or punted back up to a user mode daemon 2850 */ 2851 action = SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE; 2852 } else { 2853 fetchtableentries(sense_key, asc, ascq, 2854 inq_data, 2855 &sense_entry, 2856 &asc_entry); 2857 2858 /* 2859 * Override the 'No additional Sense' entry (0,0) 2860 * with the error action of the sense key. 2861 */ 2862 if (asc_entry != NULL 2863 && (asc != 0 || ascq != 0)) 2864 action = asc_entry->action; 2865 else 2866 action = sense_entry->action; 2867 2868 if (sense_key == SSD_KEY_RECOVERED_ERROR) { 2869 /* 2870 * The action succeeded but the device wants 2871 * the user to know that some recovery action 2872 * was required. 2873 */ 2874 action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK); 2875 action |= SS_NOP|SSQ_PRINT_SENSE; 2876 } else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) { 2877 if ((sense_flags & SF_QUIET_IR) != 0) 2878 action &= ~SSQ_PRINT_SENSE; 2879 } else if (sense_key == SSD_KEY_UNIT_ATTENTION) { 2880 if ((sense_flags & SF_RETRY_UA) != 0 2881 && (action & SS_MASK) == SS_FAIL) { 2882 action &= ~(SS_MASK|SSQ_MASK); 2883 action |= SS_RETRY|SSQ_DECREMENT_COUNT| 2884 SSQ_PRINT_SENSE; 2885 } 2886 } 2887 } 2888 #ifdef KERNEL 2889 if (bootverbose) 2890 sense_flags |= SF_PRINT_ALWAYS; 2891 #endif 2892 if ((sense_flags & SF_PRINT_ALWAYS) != 0) 2893 action |= SSQ_PRINT_SENSE; 2894 else if ((sense_flags & SF_NO_PRINT) != 0) 2895 action &= ~SSQ_PRINT_SENSE; 2896 2897 return (action); 2898 } 2899 2900 char * 2901 scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string, size_t len) 2902 { 2903 u_int8_t cdb_len; 2904 int i; 2905 2906 if (cdb_ptr == NULL) 2907 return(""); 2908 2909 /* Silence warnings */ 2910 cdb_len = 0; 2911 2912 /* 2913 * This is taken from the SCSI-3 draft spec. 2914 * (T10/1157D revision 0.3) 2915 * The top 3 bits of an opcode are the group code. The next 5 bits 2916 * are the command code. 2917 * Group 0: six byte commands 2918 * Group 1: ten byte commands 2919 * Group 2: ten byte commands 2920 * Group 3: reserved 2921 * Group 4: sixteen byte commands 2922 * Group 5: twelve byte commands 2923 * Group 6: vendor specific 2924 * Group 7: vendor specific 2925 */ 2926 switch((*cdb_ptr >> 5) & 0x7) { 2927 case 0: 2928 cdb_len = 6; 2929 break; 2930 case 1: 2931 case 2: 2932 cdb_len = 10; 2933 break; 2934 case 3: 2935 case 6: 2936 case 7: 2937 /* in this case, just print out the opcode */ 2938 cdb_len = 1; 2939 break; 2940 case 4: 2941 cdb_len = 16; 2942 break; 2943 case 5: 2944 cdb_len = 12; 2945 break; 2946 } 2947 *cdb_string = '\0'; 2948 for (i = 0; i < cdb_len; i++) 2949 ksnprintf(cdb_string + strlen(cdb_string), 2950 len - strlen(cdb_string), "%x ", cdb_ptr[i]); 2951 2952 return(cdb_string); 2953 } 2954 2955 const char * 2956 scsi_status_string(struct ccb_scsiio *csio) 2957 { 2958 switch(csio->scsi_status) { 2959 case SCSI_STATUS_OK: 2960 return("OK"); 2961 case SCSI_STATUS_CHECK_COND: 2962 return("Check Condition"); 2963 case SCSI_STATUS_BUSY: 2964 return("Busy"); 2965 case SCSI_STATUS_INTERMED: 2966 return("Intermediate"); 2967 case SCSI_STATUS_INTERMED_COND_MET: 2968 return("Intermediate-Condition Met"); 2969 case SCSI_STATUS_RESERV_CONFLICT: 2970 return("Reservation Conflict"); 2971 case SCSI_STATUS_CMD_TERMINATED: 2972 return("Command Terminated"); 2973 case SCSI_STATUS_QUEUE_FULL: 2974 return("Queue Full"); 2975 case SCSI_STATUS_ACA_ACTIVE: 2976 return("ACA Active"); 2977 case SCSI_STATUS_TASK_ABORTED: 2978 return("Task Aborted"); 2979 default: { 2980 static char unkstr[64]; 2981 ksnprintf(unkstr, sizeof(unkstr), "Unknown %#x", 2982 csio->scsi_status); 2983 return(unkstr); 2984 } 2985 } 2986 } 2987 2988 /* 2989 * scsi_command_string() returns 0 for success and -1 for failure. 2990 */ 2991 #ifdef _KERNEL 2992 int 2993 scsi_command_string(struct ccb_scsiio *csio, struct sbuf *sb) 2994 #else 2995 int 2996 scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio, 2997 struct sbuf *sb) 2998 #endif 2999 { 3000 struct scsi_inquiry_data *inq_data; 3001 char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1]; 3002 #ifdef _KERNEL 3003 struct ccb_getdev cgd; 3004 #endif 3005 3006 #ifdef _KERNEL 3007 /* 3008 * Get the device information. 3009 */ 3010 xpt_setup_ccb(&cgd.ccb_h, 3011 csio->ccb_h.path, 3012 /*priority*/ 1); 3013 cgd.ccb_h.func_code = XPT_GDEV_TYPE; 3014 xpt_action((union ccb *)&cgd); 3015 3016 /* 3017 * If the device is unconfigured, just pretend that it is a hard 3018 * drive. scsi_op_desc() needs this. 3019 */ 3020 if (cgd.ccb_h.status == CAM_DEV_NOT_THERE) 3021 cgd.inq_data.device = T_DIRECT; 3022 3023 inq_data = &cgd.inq_data; 3024 3025 #else /* !_KERNEL */ 3026 3027 inq_data = &device->inq_data; 3028 3029 #endif /* _KERNEL/!_KERNEL */ 3030 3031 if ((csio->ccb_h.flags & CAM_CDB_POINTER) != 0) { 3032 sbuf_printf(sb, "%s. CDB: %s", 3033 scsi_op_desc(csio->cdb_io.cdb_ptr[0], inq_data), 3034 scsi_cdb_string(csio->cdb_io.cdb_ptr, cdb_str, 3035 sizeof(cdb_str))); 3036 } else { 3037 sbuf_printf(sb, "%s. CDB: %s", 3038 scsi_op_desc(csio->cdb_io.cdb_bytes[0], inq_data), 3039 scsi_cdb_string(csio->cdb_io.cdb_bytes, cdb_str, 3040 sizeof(cdb_str))); 3041 } 3042 3043 return(0); 3044 } 3045 3046 /* 3047 * scsi_sense_sbuf() returns 0 for success and -1 for failure. 3048 */ 3049 #ifdef _KERNEL 3050 int 3051 scsi_sense_sbuf(struct ccb_scsiio *csio, struct sbuf *sb, 3052 scsi_sense_string_flags flags) 3053 #else /* !_KERNEL */ 3054 int 3055 scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio, 3056 struct sbuf *sb, scsi_sense_string_flags flags) 3057 #endif /* _KERNEL/!_KERNEL */ 3058 { 3059 struct scsi_sense_data *sense; 3060 struct scsi_inquiry_data *inq_data; 3061 #ifdef _KERNEL 3062 struct ccb_getdev cgd; 3063 #endif /* _KERNEL */ 3064 u_int32_t info; 3065 int error_code; 3066 int sense_key; 3067 int asc, ascq; 3068 char path_str[64]; 3069 3070 #ifndef _KERNEL 3071 if (device == NULL) 3072 return(-1); 3073 #endif /* !_KERNEL */ 3074 if ((csio == NULL) || (sb == NULL)) 3075 return(-1); 3076 3077 /* 3078 * If the CDB is a physical address, we can't deal with it.. 3079 */ 3080 if ((csio->ccb_h.flags & CAM_CDB_PHYS) != 0) 3081 flags &= ~SSS_FLAG_PRINT_COMMAND; 3082 3083 #ifdef _KERNEL 3084 xpt_path_string(csio->ccb_h.path, path_str, sizeof(path_str)); 3085 #else /* !_KERNEL */ 3086 cam_path_string(device, path_str, sizeof(path_str)); 3087 #endif /* _KERNEL/!_KERNEL */ 3088 3089 #ifdef _KERNEL 3090 /* 3091 * Get the device information. 3092 */ 3093 xpt_setup_ccb(&cgd.ccb_h, 3094 csio->ccb_h.path, 3095 /*priority*/ 1); 3096 cgd.ccb_h.func_code = XPT_GDEV_TYPE; 3097 xpt_action((union ccb *)&cgd); 3098 3099 /* 3100 * If the device is unconfigured, just pretend that it is a hard 3101 * drive. scsi_op_desc() needs this. 3102 */ 3103 if (cgd.ccb_h.status == CAM_DEV_NOT_THERE) 3104 cgd.inq_data.device = T_DIRECT; 3105 3106 inq_data = &cgd.inq_data; 3107 3108 #else /* !_KERNEL */ 3109 3110 inq_data = &device->inq_data; 3111 3112 #endif /* _KERNEL/!_KERNEL */ 3113 3114 sense = NULL; 3115 3116 if (flags & SSS_FLAG_PRINT_COMMAND) { 3117 3118 sbuf_cat(sb, path_str); 3119 3120 #ifdef _KERNEL 3121 scsi_command_string(csio, sb); 3122 #else /* !_KERNEL */ 3123 scsi_command_string(device, csio, sb); 3124 #endif /* _KERNEL/!_KERNEL */ 3125 } 3126 3127 /* 3128 * If the sense data is a physical pointer, forget it. 3129 */ 3130 if (csio->ccb_h.flags & CAM_SENSE_PTR) { 3131 if (csio->ccb_h.flags & CAM_SENSE_PHYS) 3132 return(-1); 3133 else { 3134 /* 3135 * bcopy the pointer to avoid unaligned access 3136 * errors on finicky architectures. We don't 3137 * ensure that the sense data is pointer aligned. 3138 */ 3139 bcopy(&csio->sense_data, &sense, 3140 sizeof(struct scsi_sense_data *)); 3141 } 3142 } else { 3143 /* 3144 * If the physical sense flag is set, but the sense pointer 3145 * is not also set, we assume that the user is an idiot and 3146 * return. (Well, okay, it could be that somehow, the 3147 * entire csio is physical, but we would have probably core 3148 * dumped on one of the bogus pointer deferences above 3149 * already.) 3150 */ 3151 if (csio->ccb_h.flags & CAM_SENSE_PHYS) 3152 return(-1); 3153 else 3154 sense = &csio->sense_data; 3155 } 3156 3157 3158 sbuf_cat(sb, path_str); 3159 3160 error_code = sense->error_code & SSD_ERRCODE; 3161 sense_key = sense->flags & SSD_KEY; 3162 3163 switch (error_code) { 3164 case SSD_DEFERRED_ERROR: 3165 sbuf_printf(sb, "Deferred Error: "); 3166 3167 /* FALLTHROUGH */ 3168 case SSD_CURRENT_ERROR: 3169 { 3170 const char *sense_key_desc; 3171 const char *asc_desc; 3172 3173 asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0; 3174 ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0; 3175 scsi_sense_desc(sense_key, asc, ascq, inq_data, 3176 &sense_key_desc, &asc_desc); 3177 sbuf_cat(sb, sense_key_desc); 3178 3179 info = scsi_4btoul(sense->info); 3180 3181 if (sense->error_code & SSD_ERRCODE_VALID) { 3182 3183 switch (sense_key) { 3184 case SSD_KEY_NOT_READY: 3185 case SSD_KEY_ILLEGAL_REQUEST: 3186 case SSD_KEY_UNIT_ATTENTION: 3187 case SSD_KEY_DATA_PROTECT: 3188 break; 3189 case SSD_KEY_BLANK_CHECK: 3190 sbuf_printf(sb, " req sz: %d (decimal)", info); 3191 break; 3192 default: 3193 if (info) { 3194 if (sense->flags & SSD_ILI) { 3195 sbuf_printf(sb, " ILI (length " 3196 "mismatch): %d", info); 3197 3198 } else { 3199 sbuf_printf(sb, " info:%x", 3200 info); 3201 } 3202 } 3203 } 3204 } else if (info) { 3205 sbuf_printf(sb, " info?:%x", info); 3206 } 3207 3208 if (sense->extra_len >= 4) { 3209 if (bcmp(sense->cmd_spec_info, "\0\0\0\0", 4)) { 3210 sbuf_printf(sb, " csi:%x,%x,%x,%x", 3211 sense->cmd_spec_info[0], 3212 sense->cmd_spec_info[1], 3213 sense->cmd_spec_info[2], 3214 sense->cmd_spec_info[3]); 3215 } 3216 } 3217 3218 sbuf_printf(sb, " asc:%x,%x\n%s%s", asc, ascq, 3219 path_str, asc_desc); 3220 3221 if (sense->extra_len >= 7 && sense->fru) { 3222 sbuf_printf(sb, " field replaceable unit: %x", 3223 sense->fru); 3224 } 3225 3226 if ((sense->extra_len >= 10) 3227 && (sense->sense_key_spec[0] & SSD_SCS_VALID) != 0) { 3228 switch(sense_key) { 3229 case SSD_KEY_ILLEGAL_REQUEST: { 3230 int bad_command; 3231 char tmpstr2[40]; 3232 3233 if (sense->sense_key_spec[0] & 0x40) 3234 bad_command = 1; 3235 else 3236 bad_command = 0; 3237 3238 tmpstr2[0] = '\0'; 3239 3240 /* Bit pointer is valid */ 3241 if (sense->sense_key_spec[0] & 0x08) 3242 ksnprintf(tmpstr2, sizeof(tmpstr2), 3243 "bit %d", 3244 sense->sense_key_spec[0] & 0x7); 3245 sbuf_printf(sb, 3246 ": %s byte %d %s is invalid", 3247 bad_command ? 3248 "Command" : "Data", 3249 scsi_2btoul( 3250 &sense->sense_key_spec[1]), 3251 tmpstr2); 3252 break; 3253 } 3254 case SSD_KEY_RECOVERED_ERROR: 3255 case SSD_KEY_HARDWARE_ERROR: 3256 case SSD_KEY_MEDIUM_ERROR: 3257 sbuf_printf(sb, " actual retry count: %d", 3258 scsi_2btoul( 3259 &sense->sense_key_spec[1])); 3260 break; 3261 default: 3262 sbuf_printf(sb, " sks:%#x,%#x", 3263 sense->sense_key_spec[0], 3264 scsi_2btoul( 3265 &sense->sense_key_spec[1])); 3266 break; 3267 } 3268 } 3269 break; 3270 3271 } 3272 default: 3273 sbuf_printf(sb, "Sense Error Code 0x%x", sense->error_code); 3274 if (sense->error_code & SSD_ERRCODE_VALID) { 3275 sbuf_printf(sb, " at block no. %d (decimal)", 3276 info = scsi_4btoul(sense->info)); 3277 } 3278 } 3279 3280 sbuf_printf(sb, "\n"); 3281 3282 return(0); 3283 } 3284 3285 #ifdef _KERNEL 3286 char * 3287 scsi_sense_string(struct ccb_scsiio *csio, char *str, int str_len) 3288 #else /* !_KERNEL */ 3289 char * 3290 scsi_sense_string(struct cam_device *device, struct ccb_scsiio *csio, 3291 char *str, int str_len) 3292 #endif /* _KERNEL/!_KERNEL */ 3293 { 3294 struct sbuf sb; 3295 3296 sbuf_new(&sb, str, str_len, 0); 3297 3298 #ifdef _KERNEL 3299 scsi_sense_sbuf(csio, &sb, SSS_FLAG_PRINT_COMMAND); 3300 #else /* !_KERNEL */ 3301 scsi_sense_sbuf(device, csio, &sb, SSS_FLAG_PRINT_COMMAND); 3302 #endif /* _KERNEL/!_KERNEL */ 3303 3304 sbuf_finish(&sb); 3305 3306 return(sbuf_data(&sb)); 3307 } 3308 3309 #ifdef _KERNEL 3310 void 3311 scsi_sense_print(struct ccb_scsiio *csio) 3312 { 3313 struct sbuf sb; 3314 char str[512]; 3315 3316 sbuf_new(&sb, str, sizeof(str), 0); 3317 3318 scsi_sense_sbuf(csio, &sb, SSS_FLAG_PRINT_COMMAND); 3319 3320 sbuf_finish(&sb); 3321 3322 kprintf("%s", sbuf_data(&sb)); 3323 } 3324 3325 #else /* !_KERNEL */ 3326 void 3327 scsi_sense_print(struct cam_device *device, struct ccb_scsiio *csio, 3328 FILE *ofile) 3329 { 3330 struct sbuf sb; 3331 char str[512]; 3332 3333 if ((device == NULL) || (csio == NULL) || (ofile == NULL)) 3334 return; 3335 3336 sbuf_new(&sb, str, sizeof(str), 0); 3337 3338 scsi_sense_sbuf(device, csio, &sb, SSS_FLAG_PRINT_COMMAND); 3339 3340 sbuf_finish(&sb); 3341 3342 fprintf(ofile, "%s", sbuf_data(&sb)); 3343 } 3344 3345 #endif /* _KERNEL/!_KERNEL */ 3346 3347 /* 3348 * This function currently requires at least 36 bytes, or 3349 * SHORT_INQUIRY_LENGTH, worth of data to function properly. If this 3350 * function needs more or less data in the future, another length should be 3351 * defined in scsi_all.h to indicate the minimum amount of data necessary 3352 * for this routine to function properly. 3353 */ 3354 void 3355 scsi_print_inquiry(struct scsi_inquiry_data *inq_data) 3356 { 3357 u_int8_t type; 3358 char *dtype, *qtype; 3359 char vendor[16], product[48], revision[16], rstr[4]; 3360 3361 type = SID_TYPE(inq_data); 3362 3363 /* 3364 * Figure out basic device type and qualifier. 3365 */ 3366 if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data)) { 3367 qtype = "(vendor-unique qualifier)"; 3368 } else { 3369 switch (SID_QUAL(inq_data)) { 3370 case SID_QUAL_LU_CONNECTED: 3371 qtype = ""; 3372 break; 3373 3374 case SID_QUAL_LU_OFFLINE: 3375 qtype = "(offline)"; 3376 break; 3377 3378 case SID_QUAL_RSVD: 3379 qtype = "(reserved qualifier)"; 3380 break; 3381 default: 3382 case SID_QUAL_BAD_LU: 3383 qtype = "(LUN not supported)"; 3384 break; 3385 } 3386 } 3387 3388 switch (type) { 3389 case T_DIRECT: 3390 dtype = "Direct Access"; 3391 break; 3392 case T_SEQUENTIAL: 3393 dtype = "Sequential Access"; 3394 break; 3395 case T_PRINTER: 3396 dtype = "Printer"; 3397 break; 3398 case T_PROCESSOR: 3399 dtype = "Processor"; 3400 break; 3401 case T_WORM: 3402 dtype = "WORM"; 3403 break; 3404 case T_CDROM: 3405 dtype = "CD-ROM"; 3406 break; 3407 case T_SCANNER: 3408 dtype = "Scanner"; 3409 break; 3410 case T_OPTICAL: 3411 dtype = "Optical"; 3412 break; 3413 case T_CHANGER: 3414 dtype = "Changer"; 3415 break; 3416 case T_COMM: 3417 dtype = "Communication"; 3418 break; 3419 case T_STORARRAY: 3420 dtype = "Storage Array"; 3421 break; 3422 case T_ENCLOSURE: 3423 dtype = "Enclosure Services"; 3424 break; 3425 case T_RBC: 3426 dtype = "Simplified Direct Access"; 3427 break; 3428 case T_OCRW: 3429 dtype = "Optical Card Read/Write"; 3430 break; 3431 case T_OSD: 3432 dtype = "Object-Based Storage"; 3433 break; 3434 case T_ADC: 3435 dtype = "Automation/Drive Interface"; 3436 break; 3437 case T_NODEVICE: 3438 dtype = "Uninstalled"; 3439 break; 3440 default: 3441 dtype = "unknown"; 3442 break; 3443 } 3444 3445 cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor), 3446 sizeof(vendor)); 3447 cam_strvis(product, inq_data->product, sizeof(inq_data->product), 3448 sizeof(product)); 3449 cam_strvis(revision, inq_data->revision, sizeof(inq_data->revision), 3450 sizeof(revision)); 3451 3452 if (SID_ANSI_REV(inq_data) == SCSI_REV_CCS) 3453 bcopy("CCS", rstr, 4); 3454 else 3455 ksnprintf(rstr, sizeof (rstr), "%d", SID_ANSI_REV(inq_data)); 3456 kprintf("<%s %s %s> %s %s SCSI-%s device %s\n", 3457 vendor, product, revision, 3458 SID_IS_REMOVABLE(inq_data) ? "Removable" : "Fixed", 3459 dtype, rstr, qtype); 3460 } 3461 3462 /* 3463 * Table of syncrates that don't follow the "divisible by 4" 3464 * rule. This table will be expanded in future SCSI specs. 3465 */ 3466 static struct { 3467 u_int period_factor; 3468 u_int period; /* in 100ths of ns */ 3469 } scsi_syncrates[] = { 3470 { 0x08, 625 }, /* FAST-160 */ 3471 { 0x09, 1250 }, /* FAST-80 */ 3472 { 0x0a, 2500 }, /* FAST-40 40MHz */ 3473 { 0x0b, 3030 }, /* FAST-40 33MHz */ 3474 { 0x0c, 5000 } /* FAST-20 */ 3475 }; 3476 3477 /* 3478 * Return the frequency in kHz corresponding to the given 3479 * sync period factor. 3480 */ 3481 u_int 3482 scsi_calc_syncsrate(u_int period_factor) 3483 { 3484 int i; 3485 int num_syncrates; 3486 3487 /* 3488 * It's a bug if period is zero, but if it is anyway, don't 3489 * die with a divide fault- instead return something which 3490 * 'approximates' async 3491 */ 3492 if (period_factor == 0) { 3493 return (3300); 3494 } 3495 3496 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]); 3497 /* See if the period is in the "exception" table */ 3498 for (i = 0; i < num_syncrates; i++) { 3499 3500 if (period_factor == scsi_syncrates[i].period_factor) { 3501 /* Period in kHz */ 3502 return (100000000 / scsi_syncrates[i].period); 3503 } 3504 } 3505 3506 /* 3507 * Wasn't in the table, so use the standard 3508 * 4 times conversion. 3509 */ 3510 return (10000000 / (period_factor * 4 * 10)); 3511 } 3512 3513 /* 3514 * Return the SCSI sync parameter that corresponsd to 3515 * the passed in period in 10ths of ns. 3516 */ 3517 u_int 3518 scsi_calc_syncparam(u_int period) 3519 { 3520 int i; 3521 int num_syncrates; 3522 3523 if (period == 0) 3524 return (~0); /* Async */ 3525 3526 /* Adjust for exception table being in 100ths. */ 3527 period *= 10; 3528 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]); 3529 /* See if the period is in the "exception" table */ 3530 for (i = 0; i < num_syncrates; i++) { 3531 3532 if (period <= scsi_syncrates[i].period) { 3533 /* Period in 100ths of ns */ 3534 return (scsi_syncrates[i].period_factor); 3535 } 3536 } 3537 3538 /* 3539 * Wasn't in the table, so use the standard 3540 * 1/4 period in ns conversion. 3541 */ 3542 return (period/400); 3543 } 3544 3545 void 3546 scsi_test_unit_ready(struct ccb_scsiio *csio, u_int32_t retries, 3547 void (*cbfcnp)(struct cam_periph *, union ccb *), 3548 u_int8_t tag_action, u_int8_t sense_len, u_int32_t timeout) 3549 { 3550 struct scsi_test_unit_ready *scsi_cmd; 3551 3552 cam_fill_csio(csio, 3553 retries, 3554 cbfcnp, 3555 CAM_DIR_NONE, 3556 tag_action, 3557 /*data_ptr*/NULL, 3558 /*dxfer_len*/0, 3559 sense_len, 3560 sizeof(*scsi_cmd), 3561 timeout); 3562 3563 scsi_cmd = (struct scsi_test_unit_ready *)&csio->cdb_io.cdb_bytes; 3564 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3565 scsi_cmd->opcode = TEST_UNIT_READY; 3566 } 3567 3568 void 3569 scsi_request_sense(struct ccb_scsiio *csio, u_int32_t retries, 3570 void (*cbfcnp)(struct cam_periph *, union ccb *), 3571 void *data_ptr, u_int8_t dxfer_len, u_int8_t tag_action, 3572 u_int8_t sense_len, u_int32_t timeout) 3573 { 3574 struct scsi_request_sense *scsi_cmd; 3575 3576 cam_fill_csio(csio, 3577 retries, 3578 cbfcnp, 3579 CAM_DIR_IN, 3580 tag_action, 3581 data_ptr, 3582 dxfer_len, 3583 sense_len, 3584 sizeof(*scsi_cmd), 3585 timeout); 3586 3587 scsi_cmd = (struct scsi_request_sense *)&csio->cdb_io.cdb_bytes; 3588 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3589 scsi_cmd->opcode = REQUEST_SENSE; 3590 scsi_cmd->length = dxfer_len; 3591 } 3592 3593 void 3594 scsi_inquiry(struct ccb_scsiio *csio, u_int32_t retries, 3595 void (*cbfcnp)(struct cam_periph *, union ccb *), 3596 u_int8_t tag_action, u_int8_t *inq_buf, u_int32_t inq_len, 3597 int evpd, u_int8_t page_code, u_int8_t sense_len, 3598 u_int32_t timeout) 3599 { 3600 struct scsi_inquiry *scsi_cmd; 3601 3602 cam_fill_csio(csio, 3603 retries, 3604 cbfcnp, 3605 /*flags*/CAM_DIR_IN, 3606 tag_action, 3607 /*data_ptr*/inq_buf, 3608 /*dxfer_len*/inq_len, 3609 sense_len, 3610 sizeof(*scsi_cmd), 3611 timeout); 3612 3613 scsi_cmd = (struct scsi_inquiry *)&csio->cdb_io.cdb_bytes; 3614 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3615 scsi_cmd->opcode = INQUIRY; 3616 if (evpd) { 3617 scsi_cmd->byte2 |= SI_EVPD; 3618 scsi_cmd->page_code = page_code; 3619 } 3620 /* 3621 * A 'transfer units' count of 256 is coded as 3622 * zero for all commands with a single byte count 3623 * field. 3624 */ 3625 if (inq_len == 256) 3626 inq_len = 0; 3627 scsi_cmd->length = inq_len; 3628 } 3629 3630 void 3631 scsi_mode_sense(struct ccb_scsiio *csio, u_int32_t retries, 3632 void (*cbfcnp)(struct cam_periph *, union ccb *), 3633 u_int8_t tag_action, int dbd, u_int8_t page_code, 3634 u_int8_t page, u_int8_t *param_buf, u_int32_t param_len, 3635 u_int8_t sense_len, u_int32_t timeout) 3636 { 3637 scsi_mode_sense_len(csio, retries, cbfcnp, tag_action, dbd, 3638 page_code, page, param_buf, param_len, 0, 3639 sense_len, timeout); 3640 } 3641 3642 void 3643 scsi_mode_sense_len(struct ccb_scsiio *csio, u_int32_t retries, 3644 void (*cbfcnp)(struct cam_periph *, union ccb *), 3645 u_int8_t tag_action, int dbd, u_int8_t page_code, 3646 u_int8_t page, u_int8_t *param_buf, u_int32_t param_len, 3647 int minimum_cmd_size, u_int8_t sense_len, u_int32_t timeout) 3648 { 3649 u_int8_t cdb_len; 3650 3651 /* 3652 * Use the smallest possible command to perform the operation. 3653 */ 3654 if ((param_len < 256) && (minimum_cmd_size < 10)) { 3655 /* 3656 * We can fit in a 6 byte cdb. 3657 */ 3658 struct scsi_mode_sense_6 *scsi_cmd; 3659 3660 scsi_cmd = (struct scsi_mode_sense_6 *)&csio->cdb_io.cdb_bytes; 3661 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3662 scsi_cmd->opcode = MODE_SENSE_6; 3663 if (dbd != 0) 3664 scsi_cmd->byte2 |= SMS_DBD; 3665 scsi_cmd->page = page_code | page; 3666 scsi_cmd->length = param_len; 3667 cdb_len = sizeof(*scsi_cmd); 3668 } else { 3669 /* 3670 * Need a 10 byte cdb. 3671 */ 3672 struct scsi_mode_sense_10 *scsi_cmd; 3673 3674 scsi_cmd = (struct scsi_mode_sense_10 *)&csio->cdb_io.cdb_bytes; 3675 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3676 scsi_cmd->opcode = MODE_SENSE_10; 3677 if (dbd != 0) 3678 scsi_cmd->byte2 |= SMS_DBD; 3679 scsi_cmd->page = page_code | page; 3680 scsi_ulto2b(param_len, scsi_cmd->length); 3681 cdb_len = sizeof(*scsi_cmd); 3682 } 3683 cam_fill_csio(csio, 3684 retries, 3685 cbfcnp, 3686 CAM_DIR_IN, 3687 tag_action, 3688 param_buf, 3689 param_len, 3690 sense_len, 3691 cdb_len, 3692 timeout); 3693 } 3694 3695 void 3696 scsi_mode_select(struct ccb_scsiio *csio, u_int32_t retries, 3697 void (*cbfcnp)(struct cam_periph *, union ccb *), 3698 u_int8_t tag_action, int scsi_page_fmt, int save_pages, 3699 u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len, 3700 u_int32_t timeout) 3701 { 3702 scsi_mode_select_len(csio, retries, cbfcnp, tag_action, 3703 scsi_page_fmt, save_pages, param_buf, 3704 param_len, 0, sense_len, timeout); 3705 } 3706 3707 void 3708 scsi_mode_select_len(struct ccb_scsiio *csio, u_int32_t retries, 3709 void (*cbfcnp)(struct cam_periph *, union ccb *), 3710 u_int8_t tag_action, int scsi_page_fmt, int save_pages, 3711 u_int8_t *param_buf, u_int32_t param_len, 3712 int minimum_cmd_size, u_int8_t sense_len, 3713 u_int32_t timeout) 3714 { 3715 u_int8_t cdb_len; 3716 3717 /* 3718 * Use the smallest possible command to perform the operation. 3719 */ 3720 if ((param_len < 256) && (minimum_cmd_size < 10)) { 3721 /* 3722 * We can fit in a 6 byte cdb. 3723 */ 3724 struct scsi_mode_select_6 *scsi_cmd; 3725 3726 scsi_cmd = (struct scsi_mode_select_6 *)&csio->cdb_io.cdb_bytes; 3727 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3728 scsi_cmd->opcode = MODE_SELECT_6; 3729 if (scsi_page_fmt != 0) 3730 scsi_cmd->byte2 |= SMS_PF; 3731 if (save_pages != 0) 3732 scsi_cmd->byte2 |= SMS_SP; 3733 scsi_cmd->length = param_len; 3734 cdb_len = sizeof(*scsi_cmd); 3735 } else { 3736 /* 3737 * Need a 10 byte cdb. 3738 */ 3739 struct scsi_mode_select_10 *scsi_cmd; 3740 3741 scsi_cmd = 3742 (struct scsi_mode_select_10 *)&csio->cdb_io.cdb_bytes; 3743 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3744 scsi_cmd->opcode = MODE_SELECT_10; 3745 if (scsi_page_fmt != 0) 3746 scsi_cmd->byte2 |= SMS_PF; 3747 if (save_pages != 0) 3748 scsi_cmd->byte2 |= SMS_SP; 3749 scsi_ulto2b(param_len, scsi_cmd->length); 3750 cdb_len = sizeof(*scsi_cmd); 3751 } 3752 cam_fill_csio(csio, 3753 retries, 3754 cbfcnp, 3755 CAM_DIR_OUT, 3756 tag_action, 3757 param_buf, 3758 param_len, 3759 sense_len, 3760 cdb_len, 3761 timeout); 3762 } 3763 3764 void 3765 scsi_read_capacity_16(struct ccb_scsiio *csio, uint32_t retries, 3766 void (*cbfcnp)(struct cam_periph *, union ccb *), 3767 uint8_t tag_action, uint64_t lba, int reladr, int pmi, 3768 struct scsi_read_capacity_data_16 *rcap_buf, 3769 uint8_t sense_len, uint32_t timeout) 3770 { 3771 struct scsi_read_capacity_16 *scsi_cmd; 3772 3773 cam_fill_csio(csio, 3774 retries, 3775 cbfcnp, 3776 /*flags*/CAM_DIR_IN, 3777 tag_action, 3778 /*data_ptr*/(u_int8_t *)rcap_buf, 3779 /*dxfer_len*/sizeof(*rcap_buf), 3780 sense_len, 3781 sizeof(*scsi_cmd), 3782 timeout); 3783 scsi_cmd = (struct scsi_read_capacity_16 *)&csio->cdb_io.cdb_bytes; 3784 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3785 scsi_cmd->opcode = READ_CAPACITY_16; 3786 scsi_cmd->service_action = SRC16_SERVICE_ACTION; 3787 scsi_u64to8b(lba, scsi_cmd->addr); 3788 scsi_ulto4b(sizeof(*rcap_buf), scsi_cmd->alloc_len); 3789 if (pmi) 3790 reladr |= SRC16_PMI; 3791 if (reladr) 3792 reladr |= SRC16_RELADR; 3793 } 3794 3795 /* 3796 * Prevent or allow the user to remove the media 3797 */ 3798 void 3799 scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries, 3800 void (*cbfcnp)(struct cam_periph *, union ccb *), 3801 u_int8_t tag_action, u_int8_t action, 3802 u_int8_t sense_len, u_int32_t timeout) 3803 { 3804 struct scsi_prevent *scsi_cmd; 3805 3806 cam_fill_csio(csio, 3807 retries, 3808 cbfcnp, 3809 /*flags*/CAM_DIR_NONE, 3810 tag_action, 3811 /*data_ptr*/NULL, 3812 /*dxfer_len*/0, 3813 sense_len, 3814 sizeof(*scsi_cmd), 3815 timeout); 3816 3817 scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes; 3818 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3819 scsi_cmd->opcode = PREVENT_ALLOW; 3820 scsi_cmd->how = action; 3821 } 3822 3823 /* XXX allow specification of address and PMI bit and LBA */ 3824 void 3825 scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries, 3826 void (*cbfcnp)(struct cam_periph *, union ccb *), 3827 u_int8_t tag_action, 3828 struct scsi_read_capacity_data *rcap_buf, 3829 u_int8_t sense_len, u_int32_t timeout) 3830 { 3831 struct scsi_read_capacity *scsi_cmd; 3832 3833 cam_fill_csio(csio, 3834 retries, 3835 cbfcnp, 3836 /*flags*/CAM_DIR_IN, 3837 tag_action, 3838 /*data_ptr*/(u_int8_t *)rcap_buf, 3839 /*dxfer_len*/sizeof(*rcap_buf), 3840 sense_len, 3841 sizeof(*scsi_cmd), 3842 timeout); 3843 3844 scsi_cmd = (struct scsi_read_capacity *)&csio->cdb_io.cdb_bytes; 3845 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3846 scsi_cmd->opcode = READ_CAPACITY; 3847 } 3848 3849 void 3850 scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries, 3851 void (*cbfcnp)(struct cam_periph *, union ccb *), 3852 u_int8_t tag_action, u_int8_t select_report, 3853 struct scsi_report_luns_data *rpl_buf, u_int32_t alloc_len, 3854 u_int8_t sense_len, u_int32_t timeout) 3855 { 3856 struct scsi_report_luns *scsi_cmd; 3857 3858 cam_fill_csio(csio, 3859 retries, 3860 cbfcnp, 3861 /*flags*/CAM_DIR_IN, 3862 tag_action, 3863 /*data_ptr*/(u_int8_t *)rpl_buf, 3864 /*dxfer_len*/alloc_len, 3865 sense_len, 3866 sizeof(*scsi_cmd), 3867 timeout); 3868 scsi_cmd = (struct scsi_report_luns *)&csio->cdb_io.cdb_bytes; 3869 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3870 scsi_cmd->opcode = REPORT_LUNS; 3871 scsi_cmd->select_report = select_report; 3872 scsi_ulto4b(alloc_len, scsi_cmd->length); 3873 } 3874 3875 /* 3876 * Syncronize the media to the contents of the cache for 3877 * the given lba/count pair. Specifying 0/0 means sync 3878 * the whole cache. 3879 */ 3880 void 3881 scsi_synchronize_cache(struct ccb_scsiio *csio, u_int32_t retries, 3882 void (*cbfcnp)(struct cam_periph *, union ccb *), 3883 u_int8_t tag_action, u_int32_t begin_lba, 3884 u_int16_t lb_count, u_int8_t sense_len, 3885 u_int32_t timeout) 3886 { 3887 struct scsi_sync_cache *scsi_cmd; 3888 3889 cam_fill_csio(csio, 3890 retries, 3891 cbfcnp, 3892 /*flags*/CAM_DIR_NONE, 3893 tag_action, 3894 /*data_ptr*/NULL, 3895 /*dxfer_len*/0, 3896 sense_len, 3897 sizeof(*scsi_cmd), 3898 timeout); 3899 3900 scsi_cmd = (struct scsi_sync_cache *)&csio->cdb_io.cdb_bytes; 3901 bzero(scsi_cmd, sizeof(*scsi_cmd)); 3902 scsi_cmd->opcode = SYNCHRONIZE_CACHE; 3903 scsi_ulto4b(begin_lba, scsi_cmd->begin_lba); 3904 scsi_ulto2b(lb_count, scsi_cmd->lb_count); 3905 } 3906 3907 void 3908 scsi_read_write(struct ccb_scsiio *csio, u_int32_t retries, 3909 void (*cbfcnp)(struct cam_periph *, union ccb *), 3910 u_int8_t tag_action, int readop, u_int8_t byte2, 3911 int minimum_cmd_size, u_int64_t lba, u_int32_t block_count, 3912 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, 3913 u_int32_t timeout) 3914 { 3915 u_int8_t cdb_len; 3916 3917 /* 3918 * Use the smallest possible command to perform the operation 3919 * as some legacy hardware does not support the 10 byte commands. 3920 * If any of the bits in byte2 is set, we have to go with a larger 3921 * command. 3922 */ 3923 if ((minimum_cmd_size < 10) 3924 && ((lba & 0x1fffff) == lba) 3925 && ((block_count & 0xff) == block_count) 3926 && (byte2 == 0)) { 3927 /* 3928 * We can fit in a 6 byte cdb. 3929 */ 3930 struct scsi_rw_6 *scsi_cmd; 3931 3932 scsi_cmd = (struct scsi_rw_6 *)&csio->cdb_io.cdb_bytes; 3933 scsi_cmd->opcode = readop ? READ_6 : WRITE_6; 3934 scsi_ulto3b(lba, scsi_cmd->addr); 3935 scsi_cmd->length = block_count & 0xff; 3936 scsi_cmd->control = 0; 3937 cdb_len = sizeof(*scsi_cmd); 3938 3939 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE, 3940 ("6byte: %x%x%x:%d:%d\n", scsi_cmd->addr[0], 3941 scsi_cmd->addr[1], scsi_cmd->addr[2], 3942 scsi_cmd->length, dxfer_len)); 3943 } else if ((minimum_cmd_size < 12) 3944 && ((block_count & 0xffff) == block_count) 3945 && ((lba & 0xffffffffU) == lba)) { 3946 /* 3947 * Need a 10 byte cdb. 3948 */ 3949 struct scsi_rw_10 *scsi_cmd; 3950 3951 scsi_cmd = (struct scsi_rw_10 *)&csio->cdb_io.cdb_bytes; 3952 scsi_cmd->opcode = readop ? READ_10 : WRITE_10; 3953 scsi_cmd->byte2 = byte2; 3954 scsi_ulto4b(lba, scsi_cmd->addr); 3955 scsi_cmd->reserved = 0; 3956 scsi_ulto2b(block_count, scsi_cmd->length); 3957 scsi_cmd->control = 0; 3958 cdb_len = sizeof(*scsi_cmd); 3959 3960 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE, 3961 ("10byte: %x%x%x%x:%x%x: %d\n", scsi_cmd->addr[0], 3962 scsi_cmd->addr[1], scsi_cmd->addr[2], 3963 scsi_cmd->addr[3], scsi_cmd->length[0], 3964 scsi_cmd->length[1], dxfer_len)); 3965 } else if ((minimum_cmd_size < 16) 3966 && ((block_count & 0xffffffffU) == block_count) 3967 && ((lba & 0xffffffffU) == lba)) { 3968 /* 3969 * The block count is too big for a 10 byte CDB, use a 12 3970 * byte CDB. 3971 */ 3972 struct scsi_rw_12 *scsi_cmd; 3973 3974 scsi_cmd = (struct scsi_rw_12 *)&csio->cdb_io.cdb_bytes; 3975 scsi_cmd->opcode = readop ? READ_12 : WRITE_12; 3976 scsi_cmd->byte2 = byte2; 3977 scsi_ulto4b(lba, scsi_cmd->addr); 3978 scsi_cmd->reserved = 0; 3979 scsi_ulto4b(block_count, scsi_cmd->length); 3980 scsi_cmd->control = 0; 3981 cdb_len = sizeof(*scsi_cmd); 3982 3983 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE, 3984 ("12byte: %x%x%x%x:%x%x%x%x: %d\n", scsi_cmd->addr[0], 3985 scsi_cmd->addr[1], scsi_cmd->addr[2], 3986 scsi_cmd->addr[3], scsi_cmd->length[0], 3987 scsi_cmd->length[1], scsi_cmd->length[2], 3988 scsi_cmd->length[3], dxfer_len)); 3989 } else { 3990 /* 3991 * 16 byte CDB. We'll only get here if the LBA is larger 3992 * than 2^32, or if the user asks for a 16 byte command. 3993 */ 3994 struct scsi_rw_16 *scsi_cmd; 3995 3996 scsi_cmd = (struct scsi_rw_16 *)&csio->cdb_io.cdb_bytes; 3997 scsi_cmd->opcode = readop ? READ_16 : WRITE_16; 3998 scsi_cmd->byte2 = byte2; 3999 scsi_u64to8b(lba, scsi_cmd->addr); 4000 scsi_cmd->reserved = 0; 4001 scsi_ulto4b(block_count, scsi_cmd->length); 4002 scsi_cmd->control = 0; 4003 cdb_len = sizeof(*scsi_cmd); 4004 } 4005 cam_fill_csio(csio, 4006 retries, 4007 cbfcnp, 4008 /*flags*/readop ? CAM_DIR_IN : CAM_DIR_OUT, 4009 tag_action, 4010 data_ptr, 4011 dxfer_len, 4012 sense_len, 4013 cdb_len, 4014 timeout); 4015 } 4016 4017 void 4018 scsi_start_stop(struct ccb_scsiio *csio, u_int32_t retries, 4019 void (*cbfcnp)(struct cam_periph *, union ccb *), 4020 u_int8_t tag_action, int start, int load_eject, 4021 int immediate, u_int8_t sense_len, u_int32_t timeout) 4022 { 4023 struct scsi_start_stop_unit *scsi_cmd; 4024 int extra_flags = 0; 4025 4026 scsi_cmd = (struct scsi_start_stop_unit *)&csio->cdb_io.cdb_bytes; 4027 bzero(scsi_cmd, sizeof(*scsi_cmd)); 4028 scsi_cmd->opcode = START_STOP_UNIT; 4029 if (start != 0) { 4030 scsi_cmd->how |= SSS_START; 4031 /* it takes a lot of power to start a drive */ 4032 extra_flags |= CAM_HIGH_POWER; 4033 } 4034 if (load_eject != 0) 4035 scsi_cmd->how |= SSS_LOEJ; 4036 if (immediate != 0) 4037 scsi_cmd->byte2 |= SSS_IMMED; 4038 4039 cam_fill_csio(csio, 4040 retries, 4041 cbfcnp, 4042 /*flags*/CAM_DIR_NONE | extra_flags, 4043 tag_action, 4044 /*data_ptr*/NULL, 4045 /*dxfer_len*/0, 4046 sense_len, 4047 sizeof(*scsi_cmd), 4048 timeout); 4049 4050 } 4051 4052 void 4053 scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries, 4054 void (*cbfcnp)(struct cam_periph *, union ccb *), 4055 u_int8_t tag_action, u_int8_t page_code, u_int8_t page, 4056 int save_pages, int ppc, u_int32_t paramptr, 4057 u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len, 4058 u_int32_t timeout) 4059 { 4060 struct scsi_log_sense *scsi_cmd; 4061 u_int8_t cdb_len; 4062 4063 scsi_cmd = (struct scsi_log_sense *)&csio->cdb_io.cdb_bytes; 4064 bzero(scsi_cmd, sizeof(*scsi_cmd)); 4065 scsi_cmd->opcode = LOG_SENSE; 4066 scsi_cmd->page = page_code | page; 4067 if (save_pages != 0) 4068 scsi_cmd->byte2 |= SLS_SP; 4069 if (ppc != 0) 4070 scsi_cmd->byte2 |= SLS_PPC; 4071 scsi_ulto2b(paramptr, scsi_cmd->paramptr); 4072 scsi_ulto2b(param_len, scsi_cmd->length); 4073 cdb_len = sizeof(*scsi_cmd); 4074 4075 cam_fill_csio(csio, 4076 retries, 4077 cbfcnp, 4078 /*flags*/CAM_DIR_IN, 4079 tag_action, 4080 /*data_ptr*/param_buf, 4081 /*dxfer_len*/param_len, 4082 sense_len, 4083 cdb_len, 4084 timeout); 4085 } 4086 4087 void 4088 scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries, 4089 void (*cbfcnp)(struct cam_periph *, union ccb *), 4090 u_int8_t tag_action, u_int8_t page_code, int save_pages, 4091 int pc_reset, u_int8_t *param_buf, u_int32_t param_len, 4092 u_int8_t sense_len, u_int32_t timeout) 4093 { 4094 struct scsi_log_select *scsi_cmd; 4095 u_int8_t cdb_len; 4096 4097 scsi_cmd = (struct scsi_log_select *)&csio->cdb_io.cdb_bytes; 4098 bzero(scsi_cmd, sizeof(*scsi_cmd)); 4099 scsi_cmd->opcode = LOG_SELECT; 4100 scsi_cmd->page = page_code & SLS_PAGE_CODE; 4101 if (save_pages != 0) 4102 scsi_cmd->byte2 |= SLS_SP; 4103 if (pc_reset != 0) 4104 scsi_cmd->byte2 |= SLS_PCR; 4105 scsi_ulto2b(param_len, scsi_cmd->length); 4106 cdb_len = sizeof(*scsi_cmd); 4107 4108 cam_fill_csio(csio, 4109 retries, 4110 cbfcnp, 4111 /*flags*/CAM_DIR_OUT, 4112 tag_action, 4113 /*data_ptr*/param_buf, 4114 /*dxfer_len*/param_len, 4115 sense_len, 4116 cdb_len, 4117 timeout); 4118 } 4119 4120 /* 4121 * Try make as good a match as possible with 4122 * available sub drivers 4123 */ 4124 int 4125 scsi_inquiry_match(caddr_t inqbuffer, caddr_t table_entry) 4126 { 4127 struct scsi_inquiry_pattern *entry; 4128 struct scsi_inquiry_data *inq; 4129 4130 entry = (struct scsi_inquiry_pattern *)table_entry; 4131 inq = (struct scsi_inquiry_data *)inqbuffer; 4132 4133 if (((SID_TYPE(inq) == entry->type) 4134 || (entry->type == T_ANY)) 4135 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE 4136 : entry->media_type & SIP_MEDIA_FIXED) 4137 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0) 4138 && (cam_strmatch(inq->product, entry->product, 4139 sizeof(inq->product)) == 0) 4140 && (cam_strmatch(inq->revision, entry->revision, 4141 sizeof(inq->revision)) == 0)) { 4142 return (0); 4143 } 4144 return (-1); 4145 } 4146 4147 #ifdef _KERNEL 4148 static void 4149 init_scsi_delay(void) 4150 { 4151 int delay; 4152 4153 delay = SCSI_DELAY; 4154 TUNABLE_INT_FETCH("kern.cam.scsi_delay", &delay); 4155 4156 if (set_scsi_delay(delay) != 0) { 4157 kprintf("cam: invalid value for tunable kern.cam.scsi_delay\n"); 4158 set_scsi_delay(SCSI_DELAY); 4159 } 4160 } 4161 SYSINIT(scsi_delay, SI_BOOT1_TUNABLES, SI_ORDER_ANY, init_scsi_delay, NULL); 4162 4163 static int 4164 sysctl_scsi_delay(SYSCTL_HANDLER_ARGS) 4165 { 4166 int error, delay; 4167 4168 delay = scsi_delay; 4169 error = sysctl_handle_int(oidp, &delay, 0, req); 4170 if (error != 0 || req->newptr == NULL) 4171 return (error); 4172 return (set_scsi_delay(delay)); 4173 } 4174 SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay, CTLTYPE_INT|CTLFLAG_RW, 4175 0, 0, sysctl_scsi_delay, "I", 4176 "Delay to allow devices to settle after a SCSI bus reset (ms)"); 4177 4178 static int 4179 set_scsi_delay(int delay) 4180 { 4181 /* 4182 * If someone sets this to 0, we assume that they want the 4183 * minimum allowable bus settle delay. 4184 */ 4185 if (delay == 0) { 4186 kprintf("cam: using minimum scsi_delay (%dms)\n", 4187 SCSI_MIN_DELAY); 4188 delay = SCSI_MIN_DELAY; 4189 } 4190 if (delay < SCSI_MIN_DELAY) 4191 return (EINVAL); 4192 scsi_delay = delay; 4193 return (0); 4194 } 4195 #endif /* _KERNEL */ 4196 4197 /* 4198 * Try make as good a match as possible with 4199 * available sub drivers 4200 */ 4201 int 4202 scsi_static_inquiry_match(caddr_t inqbuffer, caddr_t table_entry) 4203 { 4204 struct scsi_static_inquiry_pattern *entry; 4205 struct scsi_inquiry_data *inq; 4206 4207 entry = (struct scsi_static_inquiry_pattern *)table_entry; 4208 inq = (struct scsi_inquiry_data *)inqbuffer; 4209 4210 if (((SID_TYPE(inq) == entry->type) 4211 || (entry->type == T_ANY)) 4212 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE 4213 : entry->media_type & SIP_MEDIA_FIXED) 4214 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0) 4215 && (cam_strmatch(inq->product, entry->product, 4216 sizeof(inq->product)) == 0) 4217 && (cam_strmatch(inq->revision, entry->revision, 4218 sizeof(inq->revision)) == 0)) { 4219 return (0); 4220 } 4221 return (-1); 4222 } 4223