2 * Implementation of Utility functions for all SCSI device types.
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 2003 Kenneth D. Merry.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/libkern.h>
40 #include <sys/kernel.h>
41 #include <sys/sysctl.h>
50 #include <cam/cam_ccb.h>
51 #include <cam/cam_queue.h>
52 #include <cam/cam_xpt.h>
53 #include <cam/scsi/scsi_all.h>
64 #define ERESTART -1 /* restart syscall */
65 #define EJUSTRETURN -2 /* don't modify regs, just return */
69 * This is the default number of milliseconds we wait for devices to settle
70 * after a SCSI bus reset.
73 #define SCSI_DELAY 2000
76 * All devices need _some_ sort of bus settle delay, so we'll set it to
77 * a minimum value of 100ms. Note that this is pertinent only for SPI-
78 * not transport like Fibre Channel or iSCSI where 'delay' is completely
81 #ifndef SCSI_MIN_DELAY
82 #define SCSI_MIN_DELAY 100
85 * Make sure the user isn't using seconds instead of milliseconds.
87 #if (SCSI_DELAY < SCSI_MIN_DELAY && SCSI_DELAY != 0)
88 #error "SCSI_DELAY is in milliseconds, not seconds! Please use a larger value"
93 static int ascentrycomp(const void *key, const void *member);
94 static int senseentrycomp(const void *key, const void *member);
95 static void fetchtableentries(int sense_key, int asc, int ascq,
96 struct scsi_inquiry_data *,
97 const struct sense_key_table_entry **,
98 const struct asc_table_entry **);
100 static void init_scsi_delay(void);
101 static int sysctl_scsi_delay(SYSCTL_HANDLER_ARGS);
102 static int set_scsi_delay(int delay);
105 #if !defined(SCSI_NO_OP_STRINGS)
107 #define D (1 << T_DIRECT)
108 #define T (1 << T_SEQUENTIAL)
109 #define L (1 << T_PRINTER)
110 #define P (1 << T_PROCESSOR)
111 #define W (1 << T_WORM)
112 #define R (1 << T_CDROM)
113 #define O (1 << T_OPTICAL)
114 #define M (1 << T_CHANGER)
115 #define A (1 << T_STORARRAY)
116 #define E (1 << T_ENCLOSURE)
117 #define B (1 << T_RBC)
118 #define K (1 << T_OCRW)
119 #define V (1 << T_ADC)
120 #define F (1 << T_OSD)
121 #define S (1 << T_SCANNER)
122 #define C (1 << T_COMM)
124 #define ALL (D | T | L | P | W | R | O | M | A | E | B | K | V | F | S | C)
126 static struct op_table_entry plextor_cd_ops[] = {
127 { 0xD8, R, "CD-DA READ" }
130 static struct scsi_op_quirk_entry scsi_op_quirk_table[] = {
133 * I believe that 0xD8 is the Plextor proprietary command
134 * to read CD-DA data. I'm not sure which Plextor CDROM
135 * models support the command, though. I know for sure
136 * that the 4X, 8X, and 12X models do, and presumably the
137 * 12-20X does. I don't know about any earlier models,
138 * though. If anyone has any more complete information,
139 * feel free to change this quirk entry.
141 {T_CDROM, SIP_MEDIA_REMOVABLE, "PLEXTOR", "CD-ROM PX*", "*"},
142 sizeof(plextor_cd_ops)/sizeof(struct op_table_entry),
147 static struct op_table_entry scsi_op_codes[] = {
149 * From: http://www.t10.org/lists/op-num.txt
150 * Modifications by Kenneth Merry (ken@FreeBSD.ORG)
151 * and Jung-uk Kim (jkim@FreeBSD.org)
153 * Note: order is important in this table, scsi_op_desc() currently
154 * depends on the opcodes in the table being in order to save
156 * Note: scanner and comm. devices are carried over from the previous
157 * version because they were removed in the latest spec.
161 * SCSI Operation Codes
162 * Numeric Sorted Listing
165 * D - DIRECT ACCESS DEVICE (SBC-2) device column key
166 * .T - SEQUENTIAL ACCESS DEVICE (SSC-2) -----------------
167 * . L - PRINTER DEVICE (SSC) M = Mandatory
168 * . P - PROCESSOR DEVICE (SPC) O = Optional
169 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2) V = Vendor spec.
170 * . . R - CD/DVE DEVICE (MMC-3) Z = Obsolete
171 * . . O - OPTICAL MEMORY DEVICE (SBC-2)
172 * . . .M - MEDIA CHANGER DEVICE (SMC-2)
173 * . . . A - STORAGE ARRAY DEVICE (SCC-2)
174 * . . . .E - ENCLOSURE SERVICES DEVICE (SES)
175 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC)
176 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW)
177 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC)
178 * . . . . .F - OBJECT-BASED STORAGE (OSD)
179 * OP DTLPWROMAEBKVF Description
180 * -- -------------- ---------------------------------------------- */
181 /* 00 MMMMMMMMMMMMMM TEST UNIT READY */
182 { 0x00, ALL, "TEST UNIT READY" },
184 { 0x01, T, "REWIND" },
185 /* 01 Z V ZZZZ REZERO UNIT */
186 { 0x01, D | W | R | O | M, "REZERO UNIT" },
188 /* 03 MMMMMMMMMMOMMM REQUEST SENSE */
189 { 0x03, ALL, "REQUEST SENSE" },
190 /* 04 M OO FORMAT UNIT */
191 { 0x04, D | R | O, "FORMAT UNIT" },
192 /* 04 O FORMAT MEDIUM */
193 { 0x04, T, "FORMAT MEDIUM" },
195 { 0x04, L, "FORMAT" },
196 /* 05 VMVVVV V READ BLOCK LIMITS */
197 { 0x05, T, "READ BLOCK LIMITS" },
199 /* 07 OVV O OV REASSIGN BLOCKS */
200 { 0x07, D | W | O, "REASSIGN BLOCKS" },
201 /* 07 O INITIALIZE ELEMENT STATUS */
202 { 0x07, M, "INITIALIZE ELEMENT STATUS" },
203 /* 08 MOV O OV READ(6) */
204 { 0x08, D | T | W | O, "READ(6)" },
206 { 0x08, P, "RECEIVE" },
207 /* 08 GET MESSAGE(6) */
208 { 0x08, C, "GET MESSAGE(6)" },
210 /* 0A OO O OV WRITE(6) */
211 { 0x0A, D | T | W | O, "WRITE(6)" },
213 { 0x0A, P, "SEND(6)" },
214 /* 0A SEND MESSAGE(6) */
215 { 0x0A, C, "SEND MESSAGE(6)" },
217 { 0x0A, L, "PRINT" },
218 /* 0B Z ZOZV SEEK(6) */
219 { 0x0B, D | W | R | O, "SEEK(6)" },
220 /* 0B O SET CAPACITY */
221 { 0x0B, T, "SET CAPACITY" },
222 /* 0B O SLEW AND PRINT */
223 { 0x0B, L, "SLEW AND PRINT" },
227 /* 0F VOVVVV V READ REVERSE(6) */
228 { 0x0F, T, "READ REVERSE(6)" },
229 /* 10 VM VVV WRITE FILEMARKS(6) */
230 { 0x10, T, "WRITE FILEMARKS(6)" },
231 /* 10 O SYNCHRONIZE BUFFER */
232 { 0x10, L, "SYNCHRONIZE BUFFER" },
233 /* 11 VMVVVV SPACE(6) */
234 { 0x11, T, "SPACE(6)" },
235 /* 12 MMMMMMMMMMMMMM INQUIRY */
236 { 0x12, ALL, "INQUIRY" },
239 { 0x13, T, "VERIFY(6)" },
240 /* 14 VOOVVV RECOVER BUFFERED DATA */
241 { 0x14, T | L, "RECOVER BUFFERED DATA" },
242 /* 15 OMO O OOOO OO MODE SELECT(6) */
243 { 0x15, ALL & ~(P | R | B | F), "MODE SELECT(6)" },
244 /* 16 ZZMZO OOOZ O RESERVE(6) */
245 { 0x16, ALL & ~(R | B | V | F | C), "RESERVE(6)" },
246 /* 16 Z RESERVE ELEMENT(6) */
247 { 0x16, M, "RESERVE ELEMENT(6)" },
248 /* 17 ZZMZO OOOZ O RELEASE(6) */
249 { 0x17, ALL & ~(R | B | V | F | C), "RELEASE(6)" },
250 /* 17 Z RELEASE ELEMENT(6) */
251 { 0x17, M, "RELEASE ELEMENT(6)" },
252 /* 18 ZZZZOZO Z COPY */
253 { 0x18, D | T | L | P | W | R | O | K | S, "COPY" },
254 /* 19 VMVVVV ERASE(6) */
255 { 0x19, T, "ERASE(6)" },
256 /* 1A OMO O OOOO OO MODE SENSE(6) */
257 { 0x1A, ALL & ~(P | R | B | F), "MODE SENSE(6)" },
258 /* 1B O OOO O MO O START STOP UNIT */
259 { 0x1B, D | W | R | O | A | B | K | F, "START STOP UNIT" },
260 /* 1B O M LOAD UNLOAD */
261 { 0x1B, T | V, "LOAD UNLOAD" },
264 /* 1B O STOP PRINT */
265 { 0x1B, L, "STOP PRINT" },
266 /* 1B O OPEN/CLOSE IMPORT/EXPORT ELEMENT */
267 { 0x1B, M, "OPEN/CLOSE IMPORT/EXPORT ELEMENT" },
268 /* 1C OOOOO OOOM OOO RECEIVE DIAGNOSTIC RESULTS */
269 { 0x1C, ALL & ~(R | B), "RECEIVE DIAGNOSTIC RESULTS" },
270 /* 1D MMMMM MMOM MMM SEND DIAGNOSTIC */
271 { 0x1D, ALL & ~(R | B), "SEND DIAGNOSTIC" },
272 /* 1E OO OOOO O O PREVENT ALLOW MEDIUM REMOVAL */
273 { 0x1E, D | T | W | R | O | M | K | F, "PREVENT ALLOW MEDIUM REMOVAL" },
279 /* 23 O READ FORMAT CAPACITIES */
280 { 0x23, R, "READ FORMAT CAPACITIES" },
281 /* 24 V VV SET WINDOW */
282 { 0x24, S, "SET WINDOW" },
283 /* 25 M M M M READ CAPACITY(10) */
284 { 0x25, D | W | O | B, "READ CAPACITY(10)" },
285 /* 25 O READ CAPACITY */
286 { 0x25, R, "READ CAPACITY" },
287 /* 25 M READ CARD CAPACITY */
288 { 0x25, K, "READ CARD CAPACITY" },
290 { 0x25, S, "GET WINDOW" },
293 /* 28 M MOM MM READ(10) */
294 { 0x28, D | W | R | O | B | K | S, "READ(10)" },
295 /* 28 GET MESSAGE(10) */
296 { 0x28, C, "GET MESSAGE(10)" },
297 /* 29 V VVO READ GENERATION */
298 { 0x29, O, "READ GENERATION" },
299 /* 2A O MOM MO WRITE(10) */
300 { 0x2A, D | W | R | O | B | K, "WRITE(10)" },
302 { 0x2A, S, "SEND(10)" },
303 /* 2A SEND MESSAGE(10) */
304 { 0x2A, C, "SEND MESSAGE(10)" },
305 /* 2B Z OOO O SEEK(10) */
306 { 0x2B, D | W | R | O | K, "SEEK(10)" },
307 /* 2B O LOCATE(10) */
308 { 0x2B, T, "LOCATE(10)" },
309 /* 2B O POSITION TO ELEMENT */
310 { 0x2B, M, "POSITION TO ELEMENT" },
311 /* 2C V OO ERASE(10) */
312 { 0x2C, R | O, "ERASE(10)" },
313 /* 2D O READ UPDATED BLOCK */
314 { 0x2D, O, "READ UPDATED BLOCK" },
316 /* 2E O OOO MO WRITE AND VERIFY(10) */
317 { 0x2E, D | W | R | O | B | K, "WRITE AND VERIFY(10)" },
318 /* 2F O OOO VERIFY(10) */
319 { 0x2F, D | W | R | O, "VERIFY(10)" },
320 /* 30 Z ZZZ SEARCH DATA HIGH(10) */
321 { 0x30, D | W | R | O, "SEARCH DATA HIGH(10)" },
322 /* 31 Z ZZZ SEARCH DATA EQUAL(10) */
323 { 0x31, D | W | R | O, "SEARCH DATA EQUAL(10)" },
324 /* 31 OBJECT POSITION */
325 { 0x31, S, "OBJECT POSITION" },
326 /* 32 Z ZZZ SEARCH DATA LOW(10) */
327 { 0x32, D | W | R | O, "SEARCH DATA LOW(10)" },
328 /* 33 Z OZO SET LIMITS(10) */
329 { 0x33, D | W | R | O, "SET LIMITS(10)" },
330 /* 34 O O O O PRE-FETCH(10) */
331 { 0x34, D | W | O | K, "PRE-FETCH(10)" },
332 /* 34 M READ POSITION */
333 { 0x34, T, "READ POSITION" },
334 /* 34 GET DATA BUFFER STATUS */
335 { 0x34, S, "GET DATA BUFFER STATUS" },
336 /* 35 O OOO MO SYNCHRONIZE CACHE(10) */
337 { 0x35, D | W | R | O | B | K, "SYNCHRONIZE CACHE(10)" },
338 /* 36 Z O O O LOCK UNLOCK CACHE(10) */
339 { 0x36, D | W | O | K, "LOCK UNLOCK CACHE(10)" },
340 /* 37 O O READ DEFECT DATA(10) */
341 { 0x37, D | O, "READ DEFECT DATA(10)" },
342 /* 37 O INITIALIZE ELEMENT STATUS WITH RANGE */
343 { 0x37, M, "INITIALIZE ELEMENT STATUS WITH RANGE" },
344 /* 38 O O O MEDIUM SCAN */
345 { 0x38, W | O | K, "MEDIUM SCAN" },
346 /* 39 ZZZZOZO Z COMPARE */
347 { 0x39, D | T | L | P | W | R | O | K | S, "COMPARE" },
348 /* 3A ZZZZOZO Z COPY AND VERIFY */
349 { 0x3A, D | T | L | P | W | R | O | K | S, "COPY AND VERIFY" },
350 /* 3B OOOOOOOOOOMOOO WRITE BUFFER */
351 { 0x3B, ALL, "WRITE BUFFER" },
352 /* 3C OOOOOOOOOO OOO READ BUFFER */
353 { 0x3C, ALL & ~(B), "READ BUFFER" },
354 /* 3D O UPDATE BLOCK */
355 { 0x3D, O, "UPDATE BLOCK" },
356 /* 3E O O O READ LONG(10) */
357 { 0x3E, D | W | O, "READ LONG(10)" },
358 /* 3F O O O WRITE LONG(10) */
359 { 0x3F, D | W | O, "WRITE LONG(10)" },
360 /* 40 ZZZZOZOZ CHANGE DEFINITION */
361 { 0x40, D | T | L | P | W | R | O | M | S | C, "CHANGE DEFINITION" },
362 /* 41 O WRITE SAME(10) */
363 { 0x41, D, "WRITE SAME(10)" },
364 /* 42 O READ SUB-CHANNEL */
365 { 0x42, R, "READ SUB-CHANNEL" },
366 /* 43 O READ TOC/PMA/ATIP */
367 { 0x43, R, "READ TOC/PMA/ATIP" },
368 /* 44 M M REPORT DENSITY SUPPORT */
369 { 0x44, T | V, "REPORT DENSITY SUPPORT" },
371 /* 45 O PLAY AUDIO(10) */
372 { 0x45, R, "PLAY AUDIO(10)" },
373 /* 46 M GET CONFIGURATION */
374 { 0x46, R, "GET CONFIGURATION" },
375 /* 47 O PLAY AUDIO MSF */
376 { 0x47, R, "PLAY AUDIO MSF" },
379 /* 4A M GET EVENT STATUS NOTIFICATION */
380 { 0x4A, R, "GET EVENT STATUS NOTIFICATION" },
381 /* 4B O PAUSE/RESUME */
382 { 0x4B, R, "PAUSE/RESUME" },
383 /* 4C OOOOO OOOO OOO LOG SELECT */
384 { 0x4C, ALL & ~(R | B), "LOG SELECT" },
385 /* 4D OOOOO OOOO OMO LOG SENSE */
386 { 0x4D, ALL & ~(R | B), "LOG SENSE" },
387 /* 4E O STOP PLAY/SCAN */
388 { 0x4E, R, "STOP PLAY/SCAN" },
390 /* 50 O XDWRITE(10) */
391 { 0x50, D, "XDWRITE(10)" },
392 /* 51 O XPWRITE(10) */
393 { 0x51, D, "XPWRITE(10)" },
394 /* 51 O READ DISC INFORMATION */
395 { 0x51, R, "READ DISC INFORMATION" },
396 /* 52 O XDREAD(10) */
397 { 0x52, D, "XDREAD(10)" },
398 /* 52 O READ TRACK INFORMATION */
399 { 0x52, R, "READ TRACK INFORMATION" },
400 /* 53 O RESERVE TRACK */
401 { 0x53, R, "RESERVE TRACK" },
402 /* 54 O SEND OPC INFORMATION */
403 { 0x54, R, "SEND OPC INFORMATION" },
404 /* 55 OOO OMOOOOMOMO MODE SELECT(10) */
405 { 0x55, ALL & ~(P), "MODE SELECT(10)" },
406 /* 56 ZZMZO OOOZ RESERVE(10) */
407 { 0x56, ALL & ~(R | B | K | V | F | C), "RESERVE(10)" },
408 /* 56 Z RESERVE ELEMENT(10) */
409 { 0x56, M, "RESERVE ELEMENT(10)" },
410 /* 57 ZZMZO OOOZ RELEASE(10) */
411 { 0x57, ALL & ~(R | B | K | V | F | C), "RELEASE(10)" },
412 /* 57 Z RELEASE ELEMENT(10) */
413 { 0x57, M, "RELEASE ELEMENT(10)" },
414 /* 58 O REPAIR TRACK */
415 { 0x58, R, "REPAIR TRACK" },
417 /* 5A OOO OMOOOOMOMO MODE SENSE(10) */
418 { 0x5A, ALL & ~(P), "MODE SENSE(10)" },
419 /* 5B O CLOSE TRACK/SESSION */
420 { 0x5B, R, "CLOSE TRACK/SESSION" },
421 /* 5C O READ BUFFER CAPACITY */
422 { 0x5C, R, "READ BUFFER CAPACITY" },
423 /* 5D O SEND CUE SHEET */
424 { 0x5D, R, "SEND CUE SHEET" },
425 /* 5E OOOOO OOOO M PERSISTENT RESERVE IN */
426 { 0x5E, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE IN" },
427 /* 5F OOOOO OOOO M PERSISTENT RESERVE OUT */
428 { 0x5F, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE OUT" },
429 /* 7E OO O OOOO O extended CDB */
430 { 0x7E, D | T | R | M | A | E | B | V, "extended CDB" },
431 /* 7F O M variable length CDB (more than 16 bytes) */
432 { 0x7F, D | F, "variable length CDB (more than 16 bytes)" },
433 /* 80 Z XDWRITE EXTENDED(16) */
434 { 0x80, D, "XDWRITE EXTENDED(16)" },
435 /* 80 M WRITE FILEMARKS(16) */
436 { 0x80, T, "WRITE FILEMARKS(16)" },
437 /* 81 Z REBUILD(16) */
438 { 0x81, D, "REBUILD(16)" },
439 /* 81 O READ REVERSE(16) */
440 { 0x81, T, "READ REVERSE(16)" },
441 /* 82 Z REGENERATE(16) */
442 { 0x82, D, "REGENERATE(16)" },
443 /* 83 OOOOO O OO EXTENDED COPY */
444 { 0x83, D | T | L | P | W | O | K | V, "EXTENDED COPY" },
445 /* 84 OOOOO O OO RECEIVE COPY RESULTS */
446 { 0x84, D | T | L | P | W | O | K | V, "RECEIVE COPY RESULTS" },
447 /* 85 O O O ATA COMMAND PASS THROUGH(16) */
448 { 0x85, D | R | B, "ATA COMMAND PASS THROUGH(16)" },
449 /* 86 OO OO OOOOOOO ACCESS CONTROL IN */
450 { 0x86, ALL & ~(L | R | F), "ACCESS CONTROL IN" },
451 /* 87 OO OO OOOOOOO ACCESS CONTROL OUT */
452 { 0x87, ALL & ~(L | R | F), "ACCESS CONTROL OUT" },
454 * XXX READ(16)/WRITE(16) were not listed for CD/DVE in op-num.txt
455 * but we had it since r1.40. Do we really want them?
457 /* 88 MM O O O READ(16) */
458 { 0x88, D | T | W | O | B, "READ(16)" },
460 /* 8A OM O O O WRITE(16) */
461 { 0x8A, D | T | W | O | B, "WRITE(16)" },
463 { 0x8B, D, "ORWRITE" },
464 /* 8C OO O OO O M READ ATTRIBUTE */
465 { 0x8C, D | T | W | O | M | B | V, "READ ATTRIBUTE" },
466 /* 8D OO O OO O O WRITE ATTRIBUTE */
467 { 0x8D, D | T | W | O | M | B | V, "WRITE ATTRIBUTE" },
468 /* 8E O O O O WRITE AND VERIFY(16) */
469 { 0x8E, D | W | O | B, "WRITE AND VERIFY(16)" },
470 /* 8F OO O O O VERIFY(16) */
471 { 0x8F, D | T | W | O | B, "VERIFY(16)" },
472 /* 90 O O O O PRE-FETCH(16) */
473 { 0x90, D | W | O | B, "PRE-FETCH(16)" },
474 /* 91 O O O O SYNCHRONIZE CACHE(16) */
475 { 0x91, D | W | O | B, "SYNCHRONIZE CACHE(16)" },
477 { 0x91, T, "SPACE(16)" },
478 /* 92 Z O O LOCK UNLOCK CACHE(16) */
479 { 0x92, D | W | O, "LOCK UNLOCK CACHE(16)" },
480 /* 92 O LOCATE(16) */
481 { 0x92, T, "LOCATE(16)" },
482 /* 93 O WRITE SAME(16) */
483 { 0x93, D, "WRITE SAME(16)" },
485 { 0x93, T, "ERASE(16)" },
486 /* 94 [usage proposed by SCSI Socket Services project] */
487 /* 95 [usage proposed by SCSI Socket Services project] */
488 /* 96 [usage proposed by SCSI Socket Services project] */
489 /* 97 [usage proposed by SCSI Socket Services project] */
496 /* XXX KDM ALL for this? op-num.txt defines it for none.. */
497 /* 9E SERVICE ACTION IN(16) */
498 { 0x9E, ALL, "SERVICE ACTION IN(16)" },
499 /* XXX KDM ALL for this? op-num.txt defines it for ADC.. */
500 /* 9F M SERVICE ACTION OUT(16) */
501 { 0x9F, ALL, "SERVICE ACTION OUT(16)" },
502 /* A0 MMOOO OMMM OMO REPORT LUNS */
503 { 0xA0, ALL & ~(R | B), "REPORT LUNS" },
505 { 0xA1, R, "BLANK" },
506 /* A1 O O ATA COMMAND PASS THROUGH(12) */
507 { 0xA1, D | B, "ATA COMMAND PASS THROUGH(12)" },
508 /* A2 OO O O SECURITY PROTOCOL IN */
509 { 0xA2, D | T | R | V, "SECURITY PROTOCOL IN" },
510 /* A3 OOO O OOMOOOM MAINTENANCE (IN) */
511 { 0xA3, ALL & ~(P | R | F), "MAINTENANCE (IN)" },
513 { 0xA3, R, "SEND KEY" },
514 /* A4 OOO O OOOOOOO MAINTENANCE (OUT) */
515 { 0xA4, ALL & ~(P | R | F), "MAINTENANCE (OUT)" },
516 /* A4 O REPORT KEY */
517 { 0xA4, R, "REPORT KEY" },
518 /* A5 O O OM MOVE MEDIUM */
519 { 0xA5, T | W | O | M, "MOVE MEDIUM" },
520 /* A5 O PLAY AUDIO(12) */
521 { 0xA5, R, "PLAY AUDIO(12)" },
522 /* A6 O EXCHANGE MEDIUM */
523 { 0xA6, M, "EXCHANGE MEDIUM" },
524 /* A6 O LOAD/UNLOAD C/DVD */
525 { 0xA6, R, "LOAD/UNLOAD C/DVD" },
526 /* A7 ZZ O O MOVE MEDIUM ATTACHED */
527 { 0xA7, D | T | W | O, "MOVE MEDIUM ATTACHED" },
528 /* A7 O SET READ AHEAD */
529 { 0xA7, R, "SET READ AHEAD" },
530 /* A8 O OOO READ(12) */
531 { 0xA8, D | W | R | O, "READ(12)" },
532 /* A8 GET MESSAGE(12) */
533 { 0xA8, C, "GET MESSAGE(12)" },
534 /* A9 O SERVICE ACTION OUT(12) */
535 { 0xA9, V, "SERVICE ACTION OUT(12)" },
536 /* AA O OOO WRITE(12) */
537 { 0xAA, D | W | R | O, "WRITE(12)" },
538 /* AA SEND MESSAGE(12) */
539 { 0xAA, C, "SEND MESSAGE(12)" },
540 /* AB O O SERVICE ACTION IN(12) */
541 { 0xAB, R | V, "SERVICE ACTION IN(12)" },
543 { 0xAC, O, "ERASE(12)" },
544 /* AC O GET PERFORMANCE */
545 { 0xAC, R, "GET PERFORMANCE" },
546 /* AD O READ DVD STRUCTURE */
547 { 0xAD, R, "READ DVD STRUCTURE" },
548 /* AE O O O WRITE AND VERIFY(12) */
549 { 0xAE, D | W | O, "WRITE AND VERIFY(12)" },
550 /* AF O OZO VERIFY(12) */
551 { 0xAF, D | W | R | O, "VERIFY(12)" },
552 /* B0 ZZZ SEARCH DATA HIGH(12) */
553 { 0xB0, W | R | O, "SEARCH DATA HIGH(12)" },
554 /* B1 ZZZ SEARCH DATA EQUAL(12) */
555 { 0xB1, W | R | O, "SEARCH DATA EQUAL(12)" },
556 /* B2 ZZZ SEARCH DATA LOW(12) */
557 { 0xB2, W | R | O, "SEARCH DATA LOW(12)" },
558 /* B3 Z OZO SET LIMITS(12) */
559 { 0xB3, D | W | R | O, "SET LIMITS(12)" },
560 /* B4 ZZ OZO READ ELEMENT STATUS ATTACHED */
561 { 0xB4, D | T | W | R | O, "READ ELEMENT STATUS ATTACHED" },
562 /* B5 OO O O SECURITY PROTOCOL OUT */
563 { 0xB5, D | T | R | V, "SECURITY PROTOCOL OUT" },
564 /* B5 O REQUEST VOLUME ELEMENT ADDRESS */
565 { 0xB5, M, "REQUEST VOLUME ELEMENT ADDRESS" },
566 /* B6 O SEND VOLUME TAG */
567 { 0xB6, M, "SEND VOLUME TAG" },
568 /* B6 O SET STREAMING */
569 { 0xB6, R, "SET STREAMING" },
570 /* B7 O O READ DEFECT DATA(12) */
571 { 0xB7, D | O, "READ DEFECT DATA(12)" },
572 /* B8 O OZOM READ ELEMENT STATUS */
573 { 0xB8, T | W | R | O | M, "READ ELEMENT STATUS" },
574 /* B9 O READ CD MSF */
575 { 0xB9, R, "READ CD MSF" },
576 /* BA O O OOMO REDUNDANCY GROUP (IN) */
577 { 0xBA, D | W | O | M | A | E, "REDUNDANCY GROUP (IN)" },
580 /* BB O O OOOO REDUNDANCY GROUP (OUT) */
581 { 0xBB, D | W | O | M | A | E, "REDUNDANCY GROUP (OUT)" },
582 /* BB O SET CD SPEED */
583 { 0xBB, R, "SET CD SPEED" },
584 /* BC O O OOMO SPARE (IN) */
585 { 0xBC, D | W | O | M | A | E, "SPARE (IN)" },
586 /* BD O O OOOO SPARE (OUT) */
587 { 0xBD, D | W | O | M | A | E, "SPARE (OUT)" },
588 /* BD O MECHANISM STATUS */
589 { 0xBD, R, "MECHANISM STATUS" },
590 /* BE O O OOMO VOLUME SET (IN) */
591 { 0xBE, D | W | O | M | A | E, "VOLUME SET (IN)" },
593 { 0xBE, R, "READ CD" },
594 /* BF O O OOOO VOLUME SET (OUT) */
595 { 0xBF, D | W | O | M | A | E, "VOLUME SET (OUT)" },
596 /* BF O SEND DVD STRUCTURE */
597 { 0xBF, R, "SEND DVD STRUCTURE" }
601 scsi_op_desc(u_int16_t opcode, struct scsi_inquiry_data *inq_data)
608 struct op_table_entry *table[2];
611 pd_type = SID_TYPE(inq_data);
613 match = cam_quirkmatch((caddr_t)inq_data,
614 (caddr_t)scsi_op_quirk_table,
615 sizeof(scsi_op_quirk_table)/
616 sizeof(*scsi_op_quirk_table),
617 sizeof(*scsi_op_quirk_table),
621 table[0] = ((struct scsi_op_quirk_entry *)match)->op_table;
622 num_ops[0] = ((struct scsi_op_quirk_entry *)match)->num_ops;
623 table[1] = scsi_op_codes;
624 num_ops[1] = sizeof(scsi_op_codes)/sizeof(scsi_op_codes[0]);
628 * If this is true, we have a vendor specific opcode that
629 * wasn't covered in the quirk table.
631 if ((opcode > 0xBF) || ((opcode > 0x5F) && (opcode < 0x80)))
632 return("Vendor Specific Command");
634 table[0] = scsi_op_codes;
635 num_ops[0] = sizeof(scsi_op_codes)/sizeof(scsi_op_codes[0]);
639 /* RBC is 'Simplified' Direct Access Device */
640 if (pd_type == T_RBC)
643 opmask = 1 << pd_type;
645 for (j = 0; j < num_tables; j++) {
646 for (i = 0;i < num_ops[j] && table[j][i].opcode <= opcode; i++){
647 if ((table[j][i].opcode == opcode)
648 && ((table[j][i].opmask & opmask) != 0))
649 return(table[j][i].desc);
654 * If we can't find a match for the command in the table, we just
655 * assume it's a vendor specifc command.
657 return("Vendor Specific Command");
661 #else /* SCSI_NO_OP_STRINGS */
664 scsi_op_desc(u_int16_t opcode, struct scsi_inquiry_data *inq_data)
672 #if !defined(SCSI_NO_SENSE_STRINGS)
673 #define SST(asc, ascq, action, desc) \
674 asc, ascq, action, desc
676 const char empty_string[] = "";
678 #define SST(asc, ascq, action, desc) \
679 asc, ascq, action, empty_string
682 const struct sense_key_table_entry sense_key_table[] =
684 { SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" },
685 { SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" },
687 SSD_KEY_NOT_READY, SS_TUR|SSQ_MANY|SSQ_DECREMENT_COUNT|EBUSY,
690 { SSD_KEY_MEDIUM_ERROR, SS_RDEF, "MEDIUM ERROR" },
691 { SSD_KEY_HARDWARE_ERROR, SS_RDEF, "HARDWARE FAILURE" },
692 { SSD_KEY_ILLEGAL_REQUEST, SS_FATAL|EINVAL, "ILLEGAL REQUEST" },
693 { SSD_KEY_UNIT_ATTENTION, SS_FATAL|ENXIO, "UNIT ATTENTION" },
694 { SSD_KEY_DATA_PROTECT, SS_FATAL|EACCES, "DATA PROTECT" },
695 { SSD_KEY_BLANK_CHECK, SS_FATAL|ENOSPC, "BLANK CHECK" },
696 { SSD_KEY_Vendor_Specific, SS_FATAL|EIO, "Vendor Specific" },
697 { SSD_KEY_COPY_ABORTED, SS_FATAL|EIO, "COPY ABORTED" },
698 { SSD_KEY_ABORTED_COMMAND, SS_RDEF, "ABORTED COMMAND" },
699 { SSD_KEY_EQUAL, SS_NOP, "EQUAL" },
700 { SSD_KEY_VOLUME_OVERFLOW, SS_FATAL|EIO, "VOLUME OVERFLOW" },
701 { SSD_KEY_MISCOMPARE, SS_NOP, "MISCOMPARE" },
702 { SSD_KEY_RESERVED, SS_FATAL|EIO, "RESERVED" }
705 const int sense_key_table_size =
706 sizeof(sense_key_table)/sizeof(sense_key_table[0]);
708 static struct asc_table_entry quantum_fireball_entries[] = {
709 { SST(0x04, 0x0b, SS_START | SSQ_DECREMENT_COUNT | ENXIO,
710 "Logical unit not ready, initializing cmd. required") }
713 static struct asc_table_entry sony_mo_entries[] = {
714 { SST(0x04, 0x00, SS_START | SSQ_DECREMENT_COUNT | ENXIO,
715 "Logical unit not ready, cause not reportable") }
718 static struct scsi_sense_quirk_entry sense_quirk_table[] = {
721 * XXX The Quantum Fireball ST and SE like to return 0x04 0x0b
722 * when they really should return 0x04 0x02.
724 {T_DIRECT, SIP_MEDIA_FIXED, "QUANTUM", "FIREBALL S*", "*"},
726 sizeof(quantum_fireball_entries)/sizeof(struct asc_table_entry),
727 /*sense key entries*/NULL,
728 quantum_fireball_entries
732 * This Sony MO drive likes to return 0x04, 0x00 when it
735 {T_DIRECT, SIP_MEDIA_REMOVABLE, "SONY", "SMO-*", "*"},
737 sizeof(sony_mo_entries)/sizeof(struct asc_table_entry),
738 /*sense key entries*/NULL,
743 const int sense_quirk_table_size =
744 sizeof(sense_quirk_table)/sizeof(sense_quirk_table[0]);
746 static struct asc_table_entry asc_table[] = {
748 * From: http://www.t10.org/lists/asc-num.txt
749 * Modifications by Jung-uk Kim (jkim@FreeBSD.org)
754 * SCSI ASC/ASCQ Assignments
755 * Numeric Sorted Listing
758 * D - DIRECT ACCESS DEVICE (SBC-2) device column key
759 * .T - SEQUENTIAL ACCESS DEVICE (SSC) -------------------
760 * . L - PRINTER DEVICE (SSC) blank = reserved
761 * . P - PROCESSOR DEVICE (SPC) not blank = allowed
762 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2)
763 * . . R - CD DEVICE (MMC)
764 * . . O - OPTICAL MEMORY DEVICE (SBC-2)
765 * . . .M - MEDIA CHANGER DEVICE (SMC)
766 * . . . A - STORAGE ARRAY DEVICE (SCC)
767 * . . . E - ENCLOSURE SERVICES DEVICE (SES)
768 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC)
769 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW)
770 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC)
771 * . . . . .F - OBJECT-BASED STORAGE (OSD)
777 { SST(0x00, 0x00, SS_NOP,
778 "No additional sense information") },
780 { SST(0x00, 0x01, SS_RDEF,
781 "Filemark detected") },
783 { SST(0x00, 0x02, SS_RDEF,
784 "End-of-partition/medium detected") },
786 { SST(0x00, 0x03, SS_RDEF,
787 "Setmark detected") },
789 { SST(0x00, 0x04, SS_RDEF,
790 "Beginning-of-partition/medium detected") },
792 { SST(0x00, 0x05, SS_RDEF,
793 "End-of-data detected") },
795 { SST(0x00, 0x06, SS_RDEF,
796 "I/O process terminated") },
798 { SST(0x00, 0x07, SS_RDEF, /* XXX TBD */
799 "Programmable early warning detected") },
801 { SST(0x00, 0x11, SS_FATAL | EBUSY,
802 "Audio play operation in progress") },
804 { SST(0x00, 0x12, SS_NOP,
805 "Audio play operation paused") },
807 { SST(0x00, 0x13, SS_NOP,
808 "Audio play operation successfully completed") },
810 { SST(0x00, 0x14, SS_RDEF,
811 "Audio play operation stopped due to error") },
813 { SST(0x00, 0x15, SS_NOP,
814 "No current audio status to return") },
816 { SST(0x00, 0x16, SS_FATAL | EBUSY,
817 "Operation in progress") },
819 { SST(0x00, 0x17, SS_RDEF,
820 "Cleaning requested") },
822 { SST(0x00, 0x18, SS_RDEF, /* XXX TBD */
823 "Erase operation in progress") },
825 { SST(0x00, 0x19, SS_RDEF, /* XXX TBD */
826 "Locate operation in progress") },
828 { SST(0x00, 0x1A, SS_RDEF, /* XXX TBD */
829 "Rewind operation in progress") },
831 { SST(0x00, 0x1B, SS_RDEF, /* XXX TBD */
832 "Set capacity operation in progress") },
834 { SST(0x00, 0x1C, SS_RDEF, /* XXX TBD */
835 "Verify operation in progress") },
837 { SST(0x00, 0x1D, SS_RDEF, /* XXX TBD */
838 "ATA pass through information available") },
840 { SST(0x00, 0x1E, SS_RDEF, /* XXX TBD */
841 "Conflicting SA creation request") },
843 { SST(0x01, 0x00, SS_RDEF,
844 "No index/sector signal") },
846 { SST(0x02, 0x00, SS_RDEF,
847 "No seek complete") },
849 { SST(0x03, 0x00, SS_RDEF,
850 "Peripheral device write fault") },
852 { SST(0x03, 0x01, SS_RDEF,
853 "No write current") },
855 { SST(0x03, 0x02, SS_RDEF,
856 "Excessive write errors") },
858 { SST(0x04, 0x00, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EIO,
859 "Logical unit not ready, cause not reportable") },
861 { SST(0x04, 0x01, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EBUSY,
862 "Logical unit is in process of becoming ready") },
864 { SST(0x04, 0x02, SS_START | SSQ_DECREMENT_COUNT | ENXIO,
865 "Logical unit not ready, initializing command required") },
867 { SST(0x04, 0x03, SS_FATAL | ENXIO,
868 "Logical unit not ready, manual intervention required") },
870 { SST(0x04, 0x04, SS_FATAL | EBUSY,
871 "Logical unit not ready, format in progress") },
873 { SST(0x04, 0x05, SS_FATAL | EBUSY,
874 "Logical unit not ready, rebuild in progress") },
876 { SST(0x04, 0x06, SS_FATAL | EBUSY,
877 "Logical unit not ready, recalculation in progress") },
879 { SST(0x04, 0x07, SS_FATAL | EBUSY,
880 "Logical unit not ready, operation in progress") },
882 { SST(0x04, 0x08, SS_FATAL | EBUSY,
883 "Logical unit not ready, long write in progress") },
885 { SST(0x04, 0x09, SS_RDEF, /* XXX TBD */
886 "Logical unit not ready, self-test in progress") },
888 { SST(0x04, 0x0A, SS_RDEF, /* XXX TBD */
889 "Logical unit not accessible, asymmetric access state transition")},
891 { SST(0x04, 0x0B, SS_RDEF, /* XXX TBD */
892 "Logical unit not accessible, target port in standby state") },
894 { SST(0x04, 0x0C, SS_RDEF, /* XXX TBD */
895 "Logical unit not accessible, target port in unavailable state") },
897 { SST(0x04, 0x0D, SS_RDEF, /* XXX TBD */
898 "Logical unit not ready, structure check required") },
900 { SST(0x04, 0x10, SS_RDEF, /* XXX TBD */
901 "Logical unit not ready, auxiliary memory not accessible") },
903 { SST(0x04, 0x11, SS_RDEF, /* XXX TBD */
904 "Logical unit not ready, notify (enable spinup) required") },
906 { SST(0x04, 0x12, SS_RDEF, /* XXX TBD */
907 "Logical unit not ready, offline") },
909 { SST(0x04, 0x13, SS_RDEF, /* XXX TBD */
910 "Logical unit not ready, SA creation in progress") },
912 { SST(0x05, 0x00, SS_RDEF,
913 "Logical unit does not respond to selection") },
915 { SST(0x06, 0x00, SS_RDEF,
916 "No reference position found") },
918 { SST(0x07, 0x00, SS_RDEF,
919 "Multiple peripheral devices selected") },
921 { SST(0x08, 0x00, SS_RDEF,
922 "Logical unit communication failure") },
924 { SST(0x08, 0x01, SS_RDEF,
925 "Logical unit communication time-out") },
927 { SST(0x08, 0x02, SS_RDEF,
928 "Logical unit communication parity error") },
930 { SST(0x08, 0x03, SS_RDEF,
931 "Logical unit communication CRC error (Ultra-DMA/32)") },
933 { SST(0x08, 0x04, SS_RDEF, /* XXX TBD */
934 "Unreachable copy target") },
936 { SST(0x09, 0x00, SS_RDEF,
937 "Track following error") },
939 { SST(0x09, 0x01, SS_RDEF,
940 "Tracking servo failure") },
942 { SST(0x09, 0x02, SS_RDEF,
943 "Focus servo failure") },
945 { SST(0x09, 0x03, SS_RDEF,
946 "Spindle servo failure") },
948 { SST(0x09, 0x04, SS_RDEF,
949 "Head select fault") },
951 { SST(0x0A, 0x00, SS_FATAL | ENOSPC,
952 "Error log overflow") },
954 { SST(0x0B, 0x00, SS_RDEF,
957 { SST(0x0B, 0x01, SS_RDEF,
958 "Warning - specified temperature exceeded") },
960 { SST(0x0B, 0x02, SS_RDEF,
961 "Warning - enclosure degraded") },
963 { SST(0x0B, 0x03, SS_RDEF, /* XXX TBD */
964 "Warning - background self-test failed") },
966 { SST(0x0B, 0x04, SS_RDEF, /* XXX TBD */
967 "Warning - background pre-scan detected medium error") },
969 { SST(0x0B, 0x05, SS_RDEF, /* XXX TBD */
970 "Warning - background medium scan detected medium error") },
972 { SST(0x0B, 0x06, SS_RDEF, /* XXX TBD */
973 "Warning - non-volatile cache now volatile") },
975 { SST(0x0B, 0x07, SS_RDEF, /* XXX TBD */
976 "Warning - degraded power to non-volatile cache") },
978 { SST(0x0C, 0x00, SS_RDEF,
981 { SST(0x0C, 0x01, SS_NOP | SSQ_PRINT_SENSE,
982 "Write error - recovered with auto reallocation") },
984 { SST(0x0C, 0x02, SS_RDEF,
985 "Write error - auto reallocation failed") },
987 { SST(0x0C, 0x03, SS_RDEF,
988 "Write error - recommend reassignment") },
990 { SST(0x0C, 0x04, SS_RDEF,
991 "Compression check miscompare error") },
993 { SST(0x0C, 0x05, SS_RDEF,
994 "Data expansion occurred during compression") },
996 { SST(0x0C, 0x06, SS_RDEF,
997 "Block not compressible") },
999 { SST(0x0C, 0x07, SS_RDEF,
1000 "Write error - recovery needed") },
1002 { SST(0x0C, 0x08, SS_RDEF,
1003 "Write error - recovery failed") },
1005 { SST(0x0C, 0x09, SS_RDEF,
1006 "Write error - loss of streaming") },
1008 { SST(0x0C, 0x0A, SS_RDEF,
1009 "Write error - padding blocks added") },
1011 { SST(0x0C, 0x0B, SS_RDEF, /* XXX TBD */
1012 "Auxiliary memory write error") },
1013 /* DTLPWRO AEBKVF */
1014 { SST(0x0C, 0x0C, SS_RDEF, /* XXX TBD */
1015 "Write error - unexpected unsolicited data") },
1016 /* DTLPWRO AEBKVF */
1017 { SST(0x0C, 0x0D, SS_RDEF, /* XXX TBD */
1018 "Write error - not enough unsolicited data") },
1020 { SST(0x0C, 0x0F, SS_RDEF, /* XXX TBD */
1021 "Defects in error window") },
1023 { SST(0x0D, 0x00, SS_RDEF, /* XXX TBD */
1024 "Error detected by third party temporary initiator") },
1026 { SST(0x0D, 0x01, SS_RDEF, /* XXX TBD */
1027 "Third party device failure") },
1029 { SST(0x0D, 0x02, SS_RDEF, /* XXX TBD */
1030 "Copy target device not reachable") },
1032 { SST(0x0D, 0x03, SS_RDEF, /* XXX TBD */
1033 "Incorrect copy target device type") },
1035 { SST(0x0D, 0x04, SS_RDEF, /* XXX TBD */
1036 "Copy target device data underrun") },
1038 { SST(0x0D, 0x05, SS_RDEF, /* XXX TBD */
1039 "Copy target device data overrun") },
1040 /* DT PWROMAEBK F */
1041 { SST(0x0E, 0x00, SS_RDEF, /* XXX TBD */
1042 "Invalid information unit") },
1043 /* DT PWROMAEBK F */
1044 { SST(0x0E, 0x01, SS_RDEF, /* XXX TBD */
1045 "Information unit too short") },
1046 /* DT PWROMAEBK F */
1047 { SST(0x0E, 0x02, SS_RDEF, /* XXX TBD */
1048 "Information unit too long") },
1049 /* DT P R MAEBK F */
1050 { SST(0x0E, 0x03, SS_RDEF, /* XXX TBD */
1051 "Invalid field in command information unit") },
1053 { SST(0x10, 0x00, SS_RDEF,
1054 "ID CRC or ECC error") },
1056 { SST(0x10, 0x01, SS_RDEF, /* XXX TBD */
1057 "Logical block guard check failed") },
1059 { SST(0x10, 0x02, SS_RDEF, /* XXX TBD */
1060 "Logical block application tag check failed") },
1062 { SST(0x10, 0x03, SS_RDEF, /* XXX TBD */
1063 "Logical block reference tag check failed") },
1065 { SST(0x11, 0x00, SS_RDEF,
1066 "Unrecovered read error") },
1068 { SST(0x11, 0x01, SS_RDEF,
1069 "Read retries exhausted") },
1071 { SST(0x11, 0x02, SS_RDEF,
1072 "Error too long to correct") },
1074 { SST(0x11, 0x03, SS_RDEF,
1075 "Multiple read errors") },
1077 { SST(0x11, 0x04, SS_RDEF,
1078 "Unrecovered read error - auto reallocate failed") },
1080 { SST(0x11, 0x05, SS_RDEF,
1081 "L-EC uncorrectable error") },
1083 { SST(0x11, 0x06, SS_RDEF,
1084 "CIRC unrecovered error") },
1086 { SST(0x11, 0x07, SS_RDEF,
1087 "Data re-synchronization error") },
1089 { SST(0x11, 0x08, SS_RDEF,
1090 "Incomplete block read") },
1092 { SST(0x11, 0x09, SS_RDEF,
1095 { SST(0x11, 0x0A, SS_RDEF,
1096 "Miscorrected error") },
1098 { SST(0x11, 0x0B, SS_RDEF,
1099 "Unrecovered read error - recommend reassignment") },
1101 { SST(0x11, 0x0C, SS_RDEF,
1102 "Unrecovered read error - recommend rewrite the data") },
1104 { SST(0x11, 0x0D, SS_RDEF,
1105 "De-compression CRC error") },
1107 { SST(0x11, 0x0E, SS_RDEF,
1108 "Cannot decompress using declared algorithm") },
1110 { SST(0x11, 0x0F, SS_RDEF,
1111 "Error reading UPC/EAN number") },
1113 { SST(0x11, 0x10, SS_RDEF,
1114 "Error reading ISRC number") },
1116 { SST(0x11, 0x11, SS_RDEF,
1117 "Read error - loss of streaming") },
1119 { SST(0x11, 0x12, SS_RDEF, /* XXX TBD */
1120 "Auxiliary memory read error") },
1121 /* DTLPWRO AEBKVF */
1122 { SST(0x11, 0x13, SS_RDEF, /* XXX TBD */
1123 "Read error - failed retransmission request") },
1125 { SST(0x11, 0x14, SS_RDEF, /* XXX TBD */
1126 "Read error - LBA marked bad by application client") },
1128 { SST(0x12, 0x00, SS_RDEF,
1129 "Address mark not found for ID field") },
1131 { SST(0x13, 0x00, SS_RDEF,
1132 "Address mark not found for data field") },
1134 { SST(0x14, 0x00, SS_RDEF,
1135 "Recorded entity not found") },
1137 { SST(0x14, 0x01, SS_RDEF,
1138 "Record not found") },
1140 { SST(0x14, 0x02, SS_RDEF,
1141 "Filemark or setmark not found") },
1143 { SST(0x14, 0x03, SS_RDEF,
1144 "End-of-data not found") },
1146 { SST(0x14, 0x04, SS_RDEF,
1147 "Block sequence error") },
1149 { SST(0x14, 0x05, SS_RDEF,
1150 "Record not found - recommend reassignment") },
1152 { SST(0x14, 0x06, SS_RDEF,
1153 "Record not found - data auto-reallocated") },
1155 { SST(0x14, 0x07, SS_RDEF, /* XXX TBD */
1156 "Locate operation failure") },
1158 { SST(0x15, 0x00, SS_RDEF,
1159 "Random positioning error") },
1161 { SST(0x15, 0x01, SS_RDEF,
1162 "Mechanical positioning error") },
1164 { SST(0x15, 0x02, SS_RDEF,
1165 "Positioning error detected by read of medium") },
1167 { SST(0x16, 0x00, SS_RDEF,
1168 "Data synchronization mark error") },
1170 { SST(0x16, 0x01, SS_RDEF,
1171 "Data sync error - data rewritten") },
1173 { SST(0x16, 0x02, SS_RDEF,
1174 "Data sync error - recommend rewrite") },
1176 { SST(0x16, 0x03, SS_NOP | SSQ_PRINT_SENSE,
1177 "Data sync error - data auto-reallocated") },
1179 { SST(0x16, 0x04, SS_RDEF,
1180 "Data sync error - recommend reassignment") },
1182 { SST(0x17, 0x00, SS_NOP | SSQ_PRINT_SENSE,
1183 "Recovered data with no error correction applied") },
1185 { SST(0x17, 0x01, SS_NOP | SSQ_PRINT_SENSE,
1186 "Recovered data with retries") },
1188 { SST(0x17, 0x02, SS_NOP | SSQ_PRINT_SENSE,
1189 "Recovered data with positive head offset") },
1191 { SST(0x17, 0x03, SS_NOP | SSQ_PRINT_SENSE,
1192 "Recovered data with negative head offset") },
1194 { SST(0x17, 0x04, SS_NOP | SSQ_PRINT_SENSE,
1195 "Recovered data with retries and/or CIRC applied") },
1197 { SST(0x17, 0x05, SS_NOP | SSQ_PRINT_SENSE,
1198 "Recovered data using previous sector ID") },
1200 { SST(0x17, 0x06, SS_NOP | SSQ_PRINT_SENSE,
1201 "Recovered data without ECC - data auto-reallocated") },
1203 { SST(0x17, 0x07, SS_NOP | SSQ_PRINT_SENSE,
1204 "Recovered data without ECC - recommend reassignment") },
1206 { SST(0x17, 0x08, SS_NOP | SSQ_PRINT_SENSE,
1207 "Recovered data without ECC - recommend rewrite") },
1209 { SST(0x17, 0x09, SS_NOP | SSQ_PRINT_SENSE,
1210 "Recovered data without ECC - data rewritten") },
1212 { SST(0x18, 0x00, SS_NOP | SSQ_PRINT_SENSE,
1213 "Recovered data with error correction applied") },
1215 { SST(0x18, 0x01, SS_NOP | SSQ_PRINT_SENSE,
1216 "Recovered data with error corr. & retries applied") },
1218 { SST(0x18, 0x02, SS_NOP | SSQ_PRINT_SENSE,
1219 "Recovered data - data auto-reallocated") },
1221 { SST(0x18, 0x03, SS_NOP | SSQ_PRINT_SENSE,
1222 "Recovered data with CIRC") },
1224 { SST(0x18, 0x04, SS_NOP | SSQ_PRINT_SENSE,
1225 "Recovered data with L-EC") },
1227 { SST(0x18, 0x05, SS_NOP | SSQ_PRINT_SENSE,
1228 "Recovered data - recommend reassignment") },
1230 { SST(0x18, 0x06, SS_NOP | SSQ_PRINT_SENSE,
1231 "Recovered data - recommend rewrite") },
1233 { SST(0x18, 0x07, SS_NOP | SSQ_PRINT_SENSE,
1234 "Recovered data with ECC - data rewritten") },
1236 { SST(0x18, 0x08, SS_RDEF, /* XXX TBD */
1237 "Recovered data with linking") },
1239 { SST(0x19, 0x00, SS_RDEF,
1240 "Defect list error") },
1242 { SST(0x19, 0x01, SS_RDEF,
1243 "Defect list not available") },
1245 { SST(0x19, 0x02, SS_RDEF,
1246 "Defect list error in primary list") },
1248 { SST(0x19, 0x03, SS_RDEF,
1249 "Defect list error in grown list") },
1250 /* DTLPWROMAEBKVF */
1251 { SST(0x1A, 0x00, SS_RDEF,
1252 "Parameter list length error") },
1253 /* DTLPWROMAEBKVF */
1254 { SST(0x1B, 0x00, SS_RDEF,
1255 "Synchronous data transfer error") },
1257 { SST(0x1C, 0x00, SS_RDEF,
1258 "Defect list not found") },
1260 { SST(0x1C, 0x01, SS_RDEF,
1261 "Primary defect list not found") },
1263 { SST(0x1C, 0x02, SS_RDEF,
1264 "Grown defect list not found") },
1266 { SST(0x1D, 0x00, SS_FATAL,
1267 "Miscompare during verify operation") },
1269 { SST(0x1E, 0x00, SS_NOP | SSQ_PRINT_SENSE,
1270 "Recovered ID with ECC correction") },
1272 { SST(0x1F, 0x00, SS_RDEF,
1273 "Partial defect list transfer") },
1274 /* DTLPWROMAEBKVF */
1275 { SST(0x20, 0x00, SS_FATAL | EINVAL,
1276 "Invalid command operation code") },
1278 { SST(0x20, 0x01, SS_RDEF, /* XXX TBD */
1279 "Access denied - initiator pending-enrolled") },
1281 { SST(0x20, 0x02, SS_RDEF, /* XXX TBD */
1282 "Access denied - no access rights") },
1284 { SST(0x20, 0x03, SS_RDEF, /* XXX TBD */
1285 "Access denied - invalid mgmt ID key") },
1287 { SST(0x20, 0x04, SS_RDEF, /* XXX TBD */
1288 "Illegal command while in write capable state") },
1290 { SST(0x20, 0x05, SS_RDEF, /* XXX TBD */
1293 { SST(0x20, 0x06, SS_RDEF, /* XXX TBD */
1294 "Illegal command while in explicit address mode") },
1296 { SST(0x20, 0x07, SS_RDEF, /* XXX TBD */
1297 "Illegal command while in implicit address mode") },
1299 { SST(0x20, 0x08, SS_RDEF, /* XXX TBD */
1300 "Access denied - enrollment conflict") },
1302 { SST(0x20, 0x09, SS_RDEF, /* XXX TBD */
1303 "Access denied - invalid LU identifier") },
1305 { SST(0x20, 0x0A, SS_RDEF, /* XXX TBD */
1306 "Access denied - invalid proxy token") },
1308 { SST(0x20, 0x0B, SS_RDEF, /* XXX TBD */
1309 "Access denied - ACL LUN conflict") },
1311 { SST(0x21, 0x00, SS_FATAL | EINVAL,
1312 "Logical block address out of range") },
1314 { SST(0x21, 0x01, SS_FATAL | EINVAL,
1315 "Invalid element address") },
1317 { SST(0x21, 0x02, SS_RDEF, /* XXX TBD */
1318 "Invalid address for write") },
1320 { SST(0x21, 0x03, SS_RDEF, /* XXX TBD */
1321 "Invalid write crossing layer jump") },
1323 { SST(0x22, 0x00, SS_FATAL | EINVAL,
1324 "Illegal function (use 20 00, 24 00, or 26 00)") },
1325 /* DTLPWROMAEBKVF */
1326 { SST(0x24, 0x00, SS_FATAL | EINVAL,
1327 "Invalid field in CDB") },
1328 /* DTLPWRO AEBKVF */
1329 { SST(0x24, 0x01, SS_RDEF, /* XXX TBD */
1330 "CDB decryption error") },
1332 { SST(0x24, 0x02, SS_RDEF, /* XXX TBD */
1335 { SST(0x24, 0x03, SS_RDEF, /* XXX TBD */
1338 { SST(0x24, 0x04, SS_RDEF, /* XXX TBD */
1339 "Security audit value frozen") },
1341 { SST(0x24, 0x05, SS_RDEF, /* XXX TBD */
1342 "Security working key frozen") },
1344 { SST(0x24, 0x06, SS_RDEF, /* XXX TBD */
1345 "NONCE not unique") },
1347 { SST(0x24, 0x07, SS_RDEF, /* XXX TBD */
1348 "NONCE timestamp out of range") },
1350 { SST(0x24, 0x08, SS_RDEF, /* XXX TBD */
1352 /* DTLPWROMAEBKVF */
1353 { SST(0x25, 0x00, SS_FATAL | ENXIO,
1354 "Logical unit not supported") },
1355 /* DTLPWROMAEBKVF */
1356 { SST(0x26, 0x00, SS_FATAL | EINVAL,
1357 "Invalid field in parameter list") },
1358 /* DTLPWROMAEBKVF */
1359 { SST(0x26, 0x01, SS_FATAL | EINVAL,
1360 "Parameter not supported") },
1361 /* DTLPWROMAEBKVF */
1362 { SST(0x26, 0x02, SS_FATAL | EINVAL,
1363 "Parameter value invalid") },
1365 { SST(0x26, 0x03, SS_FATAL | EINVAL,
1366 "Threshold parameters not supported") },
1367 /* DTLPWROMAEBKVF */
1368 { SST(0x26, 0x04, SS_FATAL | EINVAL,
1369 "Invalid release of persistent reservation") },
1371 { SST(0x26, 0x05, SS_RDEF, /* XXX TBD */
1372 "Data decryption error") },
1374 { SST(0x26, 0x06, SS_RDEF, /* XXX TBD */
1375 "Too many target descriptors") },
1377 { SST(0x26, 0x07, SS_RDEF, /* XXX TBD */
1378 "Unsupported target descriptor type code") },
1380 { SST(0x26, 0x08, SS_RDEF, /* XXX TBD */
1381 "Too many segment descriptors") },
1383 { SST(0x26, 0x09, SS_RDEF, /* XXX TBD */
1384 "Unsupported segment descriptor type code") },
1386 { SST(0x26, 0x0A, SS_RDEF, /* XXX TBD */
1387 "Unexpected inexact segment") },
1389 { SST(0x26, 0x0B, SS_RDEF, /* XXX TBD */
1390 "Inline data length exceeded") },
1392 { SST(0x26, 0x0C, SS_RDEF, /* XXX TBD */
1393 "Invalid operation for copy source or destination") },
1395 { SST(0x26, 0x0D, SS_RDEF, /* XXX TBD */
1396 "Copy segment granularity violation") },
1398 { SST(0x26, 0x0E, SS_RDEF, /* XXX TBD */
1399 "Invalid parameter while port is enabled") },
1401 { SST(0x26, 0x0F, SS_RDEF, /* XXX TBD */
1402 "Invalid data-out buffer integrity check value") },
1404 { SST(0x26, 0x10, SS_RDEF, /* XXX TBD */
1405 "Data decryption key fail limit reached") },
1407 { SST(0x26, 0x11, SS_RDEF, /* XXX TBD */
1408 "Incomplete key-associated data set") },
1410 { SST(0x26, 0x12, SS_RDEF, /* XXX TBD */
1411 "Vendor specific key reference not found") },
1413 { SST(0x27, 0x00, SS_FATAL | EACCES,
1414 "Write protected") },
1416 { SST(0x27, 0x01, SS_FATAL | EACCES,
1417 "Hardware write protected") },
1419 { SST(0x27, 0x02, SS_FATAL | EACCES,
1420 "Logical unit software write protected") },
1422 { SST(0x27, 0x03, SS_FATAL | EACCES,
1423 "Associated write protect") },
1425 { SST(0x27, 0x04, SS_FATAL | EACCES,
1426 "Persistent write protect") },
1428 { SST(0x27, 0x05, SS_FATAL | EACCES,
1429 "Permanent write protect") },
1431 { SST(0x27, 0x06, SS_RDEF, /* XXX TBD */
1432 "Conditional write protect") },
1433 /* DTLPWROMAEBKVF */
1434 { SST(0x28, 0x00, SS_FATAL | ENXIO,
1435 "Not ready to ready change, medium may have changed") },
1437 { SST(0x28, 0x01, SS_FATAL | ENXIO,
1438 "Import or export element accessed") },
1440 { SST(0x28, 0x02, SS_RDEF, /* XXX TBD */
1441 "Format-layer may have changed") },
1443 { SST(0x28, 0x03, SS_RDEF, /* XXX TBD */
1444 "Import/export element accessed, medium changed") },
1446 * XXX JGibbs - All of these should use the same errno, but I don't
1447 * think ENXIO is the correct choice. Should we borrow from
1448 * the networking errnos? ECONNRESET anyone?
1450 /* DTLPWROMAEBKVF */
1451 { SST(0x29, 0x00, SS_FATAL | ENXIO,
1452 "Power on, reset, or bus device reset occurred") },
1453 /* DTLPWROMAEBKVF */
1454 { SST(0x29, 0x01, SS_RDEF,
1455 "Power on occurred") },
1456 /* DTLPWROMAEBKVF */
1457 { SST(0x29, 0x02, SS_RDEF,
1458 "SCSI bus reset occurred") },
1459 /* DTLPWROMAEBKVF */
1460 { SST(0x29, 0x03, SS_RDEF,
1461 "Bus device reset function occurred") },
1462 /* DTLPWROMAEBKVF */
1463 { SST(0x29, 0x04, SS_RDEF,
1464 "Device internal reset") },
1465 /* DTLPWROMAEBKVF */
1466 { SST(0x29, 0x05, SS_RDEF,
1467 "Transceiver mode changed to single-ended") },
1468 /* DTLPWROMAEBKVF */
1469 { SST(0x29, 0x06, SS_RDEF,
1470 "Transceiver mode changed to LVD") },
1471 /* DTLPWROMAEBKVF */
1472 { SST(0x29, 0x07, SS_RDEF, /* XXX TBD */
1473 "I_T nexus loss occurred") },
1474 /* DTL WROMAEBKVF */
1475 { SST(0x2A, 0x00, SS_RDEF,
1476 "Parameters changed") },
1477 /* DTL WROMAEBKVF */
1478 { SST(0x2A, 0x01, SS_RDEF,
1479 "Mode parameters changed") },
1481 { SST(0x2A, 0x02, SS_RDEF,
1482 "Log parameters changed") },
1484 { SST(0x2A, 0x03, SS_RDEF,
1485 "Reservations preempted") },
1487 { SST(0x2A, 0x04, SS_RDEF, /* XXX TBD */
1488 "Reservations released") },
1490 { SST(0x2A, 0x05, SS_RDEF, /* XXX TBD */
1491 "Registrations preempted") },
1492 /* DTLPWROMAEBKVF */
1493 { SST(0x2A, 0x06, SS_RDEF, /* XXX TBD */
1494 "Asymmetric access state changed") },
1495 /* DTLPWROMAEBKVF */
1496 { SST(0x2A, 0x07, SS_RDEF, /* XXX TBD */
1497 "Implicit asymmetric access state transition failed") },
1499 { SST(0x2A, 0x08, SS_RDEF, /* XXX TBD */
1500 "Priority changed") },
1502 { SST(0x2A, 0x09, SS_RDEF, /* XXX TBD */
1503 "Capacity data has changed") },
1505 { SST(0x2A, 0x0A, SS_RDEF, /* XXX TBD */
1506 "Error history I_T nexus cleared") },
1508 { SST(0x2A, 0x0B, SS_RDEF, /* XXX TBD */
1509 "Error history snapshot released") },
1511 { SST(0x2A, 0x0C, SS_RDEF, /* XXX TBD */
1512 "Error recovery attributes have changed") },
1514 { SST(0x2A, 0x0D, SS_RDEF, /* XXX TBD */
1515 "Data encryption capabilities changed") },
1517 { SST(0x2A, 0x10, SS_RDEF, /* XXX TBD */
1518 "Timestamp changed") },
1520 { SST(0x2A, 0x11, SS_RDEF, /* XXX TBD */
1521 "Data encryption parameters changed by another I_T nexus") },
1523 { SST(0x2A, 0x12, SS_RDEF, /* XXX TBD */
1524 "Data encryption parameters changed by vendor specific event") },
1526 { SST(0x2A, 0x13, SS_RDEF, /* XXX TBD */
1527 "Data encryption key instance counter has changed") },
1529 { SST(0x2A, 0x14, SS_RDEF, /* XXX TBD */
1530 "SA creation capabilities data has changed") },
1532 { SST(0x2B, 0x00, SS_RDEF,
1533 "Copy cannot execute since host cannot disconnect") },
1534 /* DTLPWROMAEBKVF */
1535 { SST(0x2C, 0x00, SS_RDEF,
1536 "Command sequence error") },
1538 { SST(0x2C, 0x01, SS_RDEF,
1539 "Too many windows specified") },
1541 { SST(0x2C, 0x02, SS_RDEF,
1542 "Invalid combination of windows specified") },
1544 { SST(0x2C, 0x03, SS_RDEF,
1545 "Current program area is not empty") },
1547 { SST(0x2C, 0x04, SS_RDEF,
1548 "Current program area is empty") },
1550 { SST(0x2C, 0x05, SS_RDEF, /* XXX TBD */
1551 "Illegal power condition request") },
1553 { SST(0x2C, 0x06, SS_RDEF, /* XXX TBD */
1554 "Persistent prevent conflict") },
1555 /* DTLPWROMAEBKVF */
1556 { SST(0x2C, 0x07, SS_RDEF, /* XXX TBD */
1557 "Previous busy status") },
1558 /* DTLPWROMAEBKVF */
1559 { SST(0x2C, 0x08, SS_RDEF, /* XXX TBD */
1560 "Previous task set full status") },
1561 /* DTLPWROM EBKVF */
1562 { SST(0x2C, 0x09, SS_RDEF, /* XXX TBD */
1563 "Previous reservation conflict status") },
1565 { SST(0x2C, 0x0A, SS_RDEF, /* XXX TBD */
1566 "Partition or collection contains user objects") },
1568 { SST(0x2C, 0x0B, SS_RDEF, /* XXX TBD */
1571 { SST(0x2D, 0x00, SS_RDEF,
1572 "Overwrite error on update in place") },
1574 { SST(0x2E, 0x00, SS_RDEF, /* XXX TBD */
1575 "Insufficient time for operation") },
1576 /* DTLPWROMAEBKVF */
1577 { SST(0x2F, 0x00, SS_RDEF,
1578 "Commands cleared by another initiator") },
1580 { SST(0x2F, 0x01, SS_RDEF, /* XXX TBD */
1581 "Commands cleared by power loss notification") },
1582 /* DTLPWROMAEBKVF */
1583 { SST(0x2F, 0x02, SS_RDEF, /* XXX TBD */
1584 "Commands cleared by device server") },
1586 { SST(0x30, 0x00, SS_RDEF,
1587 "Incompatible medium installed") },
1589 { SST(0x30, 0x01, SS_RDEF,
1590 "Cannot read medium - unknown format") },
1592 { SST(0x30, 0x02, SS_RDEF,
1593 "Cannot read medium - incompatible format") },
1595 { SST(0x30, 0x03, SS_RDEF,
1596 "Cleaning cartridge installed") },
1598 { SST(0x30, 0x04, SS_RDEF,
1599 "Cannot write medium - unknown format") },
1601 { SST(0x30, 0x05, SS_RDEF,
1602 "Cannot write medium - incompatible format") },
1604 { SST(0x30, 0x06, SS_RDEF,
1605 "Cannot format medium - incompatible medium") },
1606 /* DTL WROMAEBKVF */
1607 { SST(0x30, 0x07, SS_RDEF,
1608 "Cleaning failure") },
1610 { SST(0x30, 0x08, SS_RDEF,
1611 "Cannot write - application code mismatch") },
1613 { SST(0x30, 0x09, SS_RDEF,
1614 "Current session not fixated for append") },
1616 { SST(0x30, 0x0A, SS_RDEF, /* XXX TBD */
1617 "Cleaning request rejected") },
1619 { SST(0x30, 0x0C, SS_RDEF, /* XXX TBD */
1620 "WORM medium - overwrite attempted") },
1622 { SST(0x30, 0x0D, SS_RDEF, /* XXX TBD */
1623 "WORM medium - integrity check") },
1625 { SST(0x30, 0x10, SS_RDEF, /* XXX TBD */
1626 "Medium not formatted") },
1628 { SST(0x30, 0x11, SS_RDEF, /* XXX TBD */
1629 "Incompatible volume type") },
1631 { SST(0x30, 0x12, SS_RDEF, /* XXX TBD */
1632 "Incompatible volume qualifier") },
1634 { SST(0x31, 0x00, SS_RDEF,
1635 "Medium format corrupted") },
1637 { SST(0x31, 0x01, SS_RDEF,
1638 "Format command failed") },
1640 { SST(0x31, 0x02, SS_RDEF, /* XXX TBD */
1641 "Zoned formatting failed due to spare linking") },
1643 { SST(0x32, 0x00, SS_RDEF,
1644 "No defect spare location available") },
1646 { SST(0x32, 0x01, SS_RDEF,
1647 "Defect list update failure") },
1649 { SST(0x33, 0x00, SS_RDEF,
1650 "Tape length error") },
1651 /* DTLPWROMAEBKVF */
1652 { SST(0x34, 0x00, SS_RDEF,
1653 "Enclosure failure") },
1654 /* DTLPWROMAEBKVF */
1655 { SST(0x35, 0x00, SS_RDEF,
1656 "Enclosure services failure") },
1657 /* DTLPWROMAEBKVF */
1658 { SST(0x35, 0x01, SS_RDEF,
1659 "Unsupported enclosure function") },
1660 /* DTLPWROMAEBKVF */
1661 { SST(0x35, 0x02, SS_RDEF,
1662 "Enclosure services unavailable") },
1663 /* DTLPWROMAEBKVF */
1664 { SST(0x35, 0x03, SS_RDEF,
1665 "Enclosure services transfer failure") },
1666 /* DTLPWROMAEBKVF */
1667 { SST(0x35, 0x04, SS_RDEF,
1668 "Enclosure services transfer refused") },
1669 /* DTL WROMAEBKVF */
1670 { SST(0x35, 0x05, SS_RDEF, /* XXX TBD */
1671 "Enclosure services checksum error") },
1673 { SST(0x36, 0x00, SS_RDEF,
1674 "Ribbon, ink, or toner failure") },
1675 /* DTL WROMAEBKVF */
1676 { SST(0x37, 0x00, SS_RDEF,
1677 "Rounded parameter") },
1679 { SST(0x38, 0x00, SS_RDEF, /* XXX TBD */
1680 "Event status notification") },
1682 { SST(0x38, 0x02, SS_RDEF, /* XXX TBD */
1683 "ESN - power management class event") },
1685 { SST(0x38, 0x04, SS_RDEF, /* XXX TBD */
1686 "ESN - media class event") },
1688 { SST(0x38, 0x06, SS_RDEF, /* XXX TBD */
1689 "ESN - device busy class event") },
1691 { SST(0x39, 0x00, SS_RDEF,
1692 "Saving parameters not supported") },
1694 { SST(0x3A, 0x00, SS_FATAL | ENXIO,
1695 "Medium not present") },
1697 { SST(0x3A, 0x01, SS_FATAL | ENXIO,
1698 "Medium not present - tray closed") },
1700 { SST(0x3A, 0x02, SS_FATAL | ENXIO,
1701 "Medium not present - tray open") },
1703 { SST(0x3A, 0x03, SS_RDEF, /* XXX TBD */
1704 "Medium not present - loadable") },
1706 { SST(0x3A, 0x04, SS_RDEF, /* XXX TBD */
1707 "Medium not present - medium auxiliary memory accessible") },
1709 { SST(0x3B, 0x00, SS_RDEF,
1710 "Sequential positioning error") },
1712 { SST(0x3B, 0x01, SS_RDEF,
1713 "Tape position error at beginning-of-medium") },
1715 { SST(0x3B, 0x02, SS_RDEF,
1716 "Tape position error at end-of-medium") },
1718 { SST(0x3B, 0x03, SS_RDEF,
1719 "Tape or electronic vertical forms unit not ready") },
1721 { SST(0x3B, 0x04, SS_RDEF,
1724 { SST(0x3B, 0x05, SS_RDEF,
1727 { SST(0x3B, 0x06, SS_RDEF,
1728 "Failed to sense top-of-form") },
1730 { SST(0x3B, 0x07, SS_RDEF,
1731 "Failed to sense bottom-of-form") },
1733 { SST(0x3B, 0x08, SS_RDEF,
1734 "Reposition error") },
1736 { SST(0x3B, 0x09, SS_RDEF,
1737 "Read past end of medium") },
1739 { SST(0x3B, 0x0A, SS_RDEF,
1740 "Read past beginning of medium") },
1742 { SST(0x3B, 0x0B, SS_RDEF,
1743 "Position past end of medium") },
1745 { SST(0x3B, 0x0C, SS_RDEF,
1746 "Position past beginning of medium") },
1748 { SST(0x3B, 0x0D, SS_FATAL | ENOSPC,
1749 "Medium destination element full") },
1751 { SST(0x3B, 0x0E, SS_RDEF,
1752 "Medium source element empty") },
1754 { SST(0x3B, 0x0F, SS_RDEF,
1755 "End of medium reached") },
1757 { SST(0x3B, 0x11, SS_RDEF,
1758 "Medium magazine not accessible") },
1760 { SST(0x3B, 0x12, SS_RDEF,
1761 "Medium magazine removed") },
1763 { SST(0x3B, 0x13, SS_RDEF,
1764 "Medium magazine inserted") },
1766 { SST(0x3B, 0x14, SS_RDEF,
1767 "Medium magazine locked") },
1769 { SST(0x3B, 0x15, SS_RDEF,
1770 "Medium magazine unlocked") },
1772 { SST(0x3B, 0x16, SS_RDEF, /* XXX TBD */
1773 "Mechanical positioning or changer error") },
1775 { SST(0x3B, 0x17, SS_RDEF, /* XXX TBD */
1776 "Read past end of user object") },
1778 { SST(0x3B, 0x18, SS_RDEF, /* XXX TBD */
1779 "Element disabled") },
1781 { SST(0x3B, 0x19, SS_RDEF, /* XXX TBD */
1782 "Element enabled") },
1784 { SST(0x3B, 0x1A, SS_RDEF, /* XXX TBD */
1785 "Data transfer device removed") },
1787 { SST(0x3B, 0x1B, SS_RDEF, /* XXX TBD */
1788 "Data transfer device inserted") },
1790 { SST(0x3D, 0x00, SS_RDEF,
1791 "Invalid bits in IDENTIFY message") },
1792 /* DTLPWROMAEBKVF */
1793 { SST(0x3E, 0x00, SS_RDEF,
1794 "Logical unit has not self-configured yet") },
1795 /* DTLPWROMAEBKVF */
1796 { SST(0x3E, 0x01, SS_RDEF,
1797 "Logical unit failure") },
1798 /* DTLPWROMAEBKVF */
1799 { SST(0x3E, 0x02, SS_RDEF,
1800 "Timeout on logical unit") },
1801 /* DTLPWROMAEBKVF */
1802 { SST(0x3E, 0x03, SS_RDEF, /* XXX TBD */
1803 "Logical unit failed self-test") },
1804 /* DTLPWROMAEBKVF */
1805 { SST(0x3E, 0x04, SS_RDEF, /* XXX TBD */
1806 "Logical unit unable to update self-test log") },
1807 /* DTLPWROMAEBKVF */
1808 { SST(0x3F, 0x00, SS_RDEF,
1809 "Target operating conditions have changed") },
1810 /* DTLPWROMAEBKVF */
1811 { SST(0x3F, 0x01, SS_RDEF,
1812 "Microcode has been changed") },
1814 { SST(0x3F, 0x02, SS_RDEF,
1815 "Changed operating definition") },
1816 /* DTLPWROMAEBKVF */
1817 { SST(0x3F, 0x03, SS_RDEF,
1818 "INQUIRY data has changed") },
1820 { SST(0x3F, 0x04, SS_RDEF,
1821 "Component device attached") },
1823 { SST(0x3F, 0x05, SS_RDEF,
1824 "Device identifier changed") },
1826 { SST(0x3F, 0x06, SS_RDEF,
1827 "Redundancy group created or modified") },
1829 { SST(0x3F, 0x07, SS_RDEF,
1830 "Redundancy group deleted") },
1832 { SST(0x3F, 0x08, SS_RDEF,
1833 "Spare created or modified") },
1835 { SST(0x3F, 0x09, SS_RDEF,
1838 { SST(0x3F, 0x0A, SS_RDEF,
1839 "Volume set created or modified") },
1841 { SST(0x3F, 0x0B, SS_RDEF,
1842 "Volume set deleted") },
1844 { SST(0x3F, 0x0C, SS_RDEF,
1845 "Volume set deassigned") },
1847 { SST(0x3F, 0x0D, SS_RDEF,
1848 "Volume set reassigned") },
1850 { SST(0x3F, 0x0E, SS_RDEF, /* XXX TBD */
1851 "Reported LUNs data has changed") },
1852 /* DTLPWROMAEBKVF */
1853 { SST(0x3F, 0x0F, SS_RDEF, /* XXX TBD */
1854 "Echo buffer overwritten") },
1856 { SST(0x3F, 0x10, SS_RDEF, /* XXX TBD */
1857 "Medium loadable") },
1859 { SST(0x3F, 0x11, SS_RDEF, /* XXX TBD */
1860 "Medium auxiliary memory accessible") },
1861 /* DTLPWR MAEBK F */
1862 { SST(0x3F, 0x12, SS_RDEF, /* XXX TBD */
1863 "iSCSI IP address added") },
1864 /* DTLPWR MAEBK F */
1865 { SST(0x3F, 0x13, SS_RDEF, /* XXX TBD */
1866 "iSCSI IP address removed") },
1867 /* DTLPWR MAEBK F */
1868 { SST(0x3F, 0x14, SS_RDEF, /* XXX TBD */
1869 "iSCSI IP address changed") },
1871 { SST(0x40, 0x00, SS_RDEF,
1872 "RAM failure") }, /* deprecated - use 40 NN instead */
1873 /* DTLPWROMAEBKVF */
1874 { SST(0x40, 0x80, SS_RDEF,
1875 "Diagnostic failure: ASCQ = Component ID") },
1876 /* DTLPWROMAEBKVF */
1877 { SST(0x40, 0xFF, SS_RDEF | SSQ_RANGE,
1878 NULL) }, /* Range 0x80->0xFF */
1880 { SST(0x41, 0x00, SS_RDEF,
1881 "Data path failure") }, /* deprecated - use 40 NN instead */
1883 { SST(0x42, 0x00, SS_RDEF,
1884 "Power-on or self-test failure") },
1885 /* deprecated - use 40 NN instead */
1886 /* DTLPWROMAEBKVF */
1887 { SST(0x43, 0x00, SS_RDEF,
1889 /* DTLPWROMAEBKVF */
1890 { SST(0x44, 0x00, SS_RDEF,
1891 "Internal target failure") },
1893 { SST(0x44, 0x71, SS_RDEF, /* XXX TBD */
1894 "ATA device failed set features") },
1895 /* DTLPWROMAEBKVF */
1896 { SST(0x45, 0x00, SS_RDEF,
1897 "Select or reselect failure") },
1899 { SST(0x46, 0x00, SS_RDEF,
1900 "Unsuccessful soft reset") },
1901 /* DTLPWROMAEBKVF */
1902 { SST(0x47, 0x00, SS_RDEF,
1903 "SCSI parity error") },
1904 /* DTLPWROMAEBKVF */
1905 { SST(0x47, 0x01, SS_RDEF, /* XXX TBD */
1906 "Data phase CRC error detected") },
1907 /* DTLPWROMAEBKVF */
1908 { SST(0x47, 0x02, SS_RDEF, /* XXX TBD */
1909 "SCSI parity error detected during ST data phase") },
1910 /* DTLPWROMAEBKVF */
1911 { SST(0x47, 0x03, SS_RDEF, /* XXX TBD */
1912 "Information unit iuCRC error detected") },
1913 /* DTLPWROMAEBKVF */
1914 { SST(0x47, 0x04, SS_RDEF, /* XXX TBD */
1915 "Asynchronous information protection error detected") },
1916 /* DTLPWROMAEBKVF */
1917 { SST(0x47, 0x05, SS_RDEF, /* XXX TBD */
1918 "Protocol service CRC error") },
1920 { SST(0x47, 0x06, SS_RDEF, /* XXX TBD */
1921 "PHY test function in progress") },
1923 { SST(0x47, 0x7F, SS_RDEF, /* XXX TBD */
1924 "Some commands cleared by iSCSI protocol event") },
1925 /* DTLPWROMAEBKVF */
1926 { SST(0x48, 0x00, SS_RDEF,
1927 "Initiator detected error message received") },
1928 /* DTLPWROMAEBKVF */
1929 { SST(0x49, 0x00, SS_RDEF,
1930 "Invalid message error") },
1931 /* DTLPWROMAEBKVF */
1932 { SST(0x4A, 0x00, SS_RDEF,
1933 "Command phase error") },
1934 /* DTLPWROMAEBKVF */
1935 { SST(0x4B, 0x00, SS_RDEF,
1936 "Data phase error") },
1938 { SST(0x4B, 0x01, SS_RDEF, /* XXX TBD */
1939 "Invalid target port transfer tag received") },
1941 { SST(0x4B, 0x02, SS_RDEF, /* XXX TBD */
1942 "Too much write data") },
1944 { SST(0x4B, 0x03, SS_RDEF, /* XXX TBD */
1945 "ACK/NAK timeout") },
1947 { SST(0x4B, 0x04, SS_RDEF, /* XXX TBD */
1950 { SST(0x4B, 0x05, SS_RDEF, /* XXX TBD */
1951 "Data offset error") },
1953 { SST(0x4B, 0x06, SS_RDEF, /* XXX TBD */
1954 "Initiator response timeout") },
1955 /* DTLPWROMAEBKVF */
1956 { SST(0x4C, 0x00, SS_RDEF,
1957 "Logical unit failed self-configuration") },
1958 /* DTLPWROMAEBKVF */
1959 { SST(0x4D, 0x00, SS_RDEF,
1960 "Tagged overlapped commands: ASCQ = Queue tag ID") },
1961 /* DTLPWROMAEBKVF */
1962 { SST(0x4D, 0xFF, SS_RDEF | SSQ_RANGE,
1963 NULL) }, /* Range 0x00->0xFF */
1964 /* DTLPWROMAEBKVF */
1965 { SST(0x4E, 0x00, SS_RDEF,
1966 "Overlapped commands attempted") },
1968 { SST(0x50, 0x00, SS_RDEF,
1969 "Write append error") },
1971 { SST(0x50, 0x01, SS_RDEF,
1972 "Write append position error") },
1974 { SST(0x50, 0x02, SS_RDEF,
1975 "Position error related to timing") },
1977 { SST(0x51, 0x00, SS_RDEF,
1980 { SST(0x51, 0x01, SS_RDEF, /* XXX TBD */
1981 "Erase failure - incomplete erase operation detected") },
1983 { SST(0x52, 0x00, SS_RDEF,
1984 "Cartridge fault") },
1986 { SST(0x53, 0x00, SS_RDEF,
1987 "Media load or eject failed") },
1989 { SST(0x53, 0x01, SS_RDEF,
1990 "Unload tape failure") },
1992 { SST(0x53, 0x02, SS_RDEF,
1993 "Medium removal prevented") },
1995 { SST(0x53, 0x03, SS_RDEF, /* XXX TBD */
1996 "Medium removal prevented by data transfer element") },
1998 { SST(0x53, 0x04, SS_RDEF, /* XXX TBD */
1999 "Medium thread or unthread failure") },
2001 { SST(0x54, 0x00, SS_RDEF,
2002 "SCSI to host system interface failure") },
2004 { SST(0x55, 0x00, SS_RDEF,
2005 "System resource failure") },
2007 { SST(0x55, 0x01, SS_FATAL | ENOSPC,
2008 "System buffer full") },
2010 { SST(0x55, 0x02, SS_RDEF, /* XXX TBD */
2011 "Insufficient reservation resources") },
2013 { SST(0x55, 0x03, SS_RDEF, /* XXX TBD */
2014 "Insufficient resources") },
2016 { SST(0x55, 0x04, SS_RDEF, /* XXX TBD */
2017 "Insufficient registration resources") },
2019 { SST(0x55, 0x05, SS_RDEF, /* XXX TBD */
2020 "Insufficient access control resources") },
2022 { SST(0x55, 0x06, SS_RDEF, /* XXX TBD */
2023 "Auxiliary memory out of space") },
2025 { SST(0x55, 0x07, SS_RDEF, /* XXX TBD */
2028 { SST(0x55, 0x08, SS_RDEF, /* XXX TBD */
2029 "Maximum number of supplemental decryption keys exceeded") },
2031 { SST(0x55, 0x09, SS_RDEF, /* XXX TBD */
2032 "Medium auxiliary memory not accessible") },
2034 { SST(0x55, 0x0A, SS_RDEF, /* XXX TBD */
2035 "Data currently unavailable") },
2037 { SST(0x57, 0x00, SS_RDEF,
2038 "Unable to recover table-of-contents") },
2040 { SST(0x58, 0x00, SS_RDEF,
2041 "Generation does not exist") },
2043 { SST(0x59, 0x00, SS_RDEF,
2044 "Updated block read") },
2046 { SST(0x5A, 0x00, SS_RDEF,
2047 "Operator request or state change input") },
2049 { SST(0x5A, 0x01, SS_RDEF,
2050 "Operator medium removal request") },
2052 { SST(0x5A, 0x02, SS_RDEF,
2053 "Operator selected write protect") },
2055 { SST(0x5A, 0x03, SS_RDEF,
2056 "Operator selected write permit") },
2058 { SST(0x5B, 0x00, SS_RDEF,
2061 { SST(0x5B, 0x01, SS_RDEF,
2062 "Threshold condition met") },
2064 { SST(0x5B, 0x02, SS_RDEF,
2065 "Log counter at maximum") },
2067 { SST(0x5B, 0x03, SS_RDEF,
2068 "Log list codes exhausted") },
2070 { SST(0x5C, 0x00, SS_RDEF,
2071 "RPL status change") },
2073 { SST(0x5C, 0x01, SS_NOP | SSQ_PRINT_SENSE,
2074 "Spindles synchronized") },
2076 { SST(0x5C, 0x02, SS_RDEF,
2077 "Spindles not synchronized") },
2078 /* DTLPWROMAEBKVF */
2079 { SST(0x5D, 0x00, SS_RDEF,
2080 "Failure prediction threshold exceeded") },
2082 { SST(0x5D, 0x01, SS_RDEF, /* XXX TBD */
2083 "Media failure prediction threshold exceeded") },
2085 { SST(0x5D, 0x02, SS_RDEF, /* XXX TBD */
2086 "Logical unit failure prediction threshold exceeded") },
2088 { SST(0x5D, 0x03, SS_RDEF, /* XXX TBD */
2089 "Spare area exhaustion prediction threshold exceeded") },
2091 { SST(0x5D, 0x10, SS_RDEF, /* XXX TBD */
2092 "Hardware impending failure general hard drive failure") },
2094 { SST(0x5D, 0x11, SS_RDEF, /* XXX TBD */
2095 "Hardware impending failure drive error rate too high") },
2097 { SST(0x5D, 0x12, SS_RDEF, /* XXX TBD */
2098 "Hardware impending failure data error rate too high") },
2100 { SST(0x5D, 0x13, SS_RDEF, /* XXX TBD */
2101 "Hardware impending failure seek error rate too high") },
2103 { SST(0x5D, 0x14, SS_RDEF, /* XXX TBD */
2104 "Hardware impending failure too many block reassigns") },
2106 { SST(0x5D, 0x15, SS_RDEF, /* XXX TBD */
2107 "Hardware impending failure access times too high") },
2109 { SST(0x5D, 0x16, SS_RDEF, /* XXX TBD */
2110 "Hardware impending failure start unit times too high") },
2112 { SST(0x5D, 0x17, SS_RDEF, /* XXX TBD */
2113 "Hardware impending failure channel parametrics") },
2115 { SST(0x5D, 0x18, SS_RDEF, /* XXX TBD */
2116 "Hardware impending failure controller detected") },
2118 { SST(0x5D, 0x19, SS_RDEF, /* XXX TBD */
2119 "Hardware impending failure throughput performance") },
2121 { SST(0x5D, 0x1A, SS_RDEF, /* XXX TBD */
2122 "Hardware impending failure seek time performance") },
2124 { SST(0x5D, 0x1B, SS_RDEF, /* XXX TBD */
2125 "Hardware impending failure spin-up retry count") },
2127 { SST(0x5D, 0x1C, SS_RDEF, /* XXX TBD */
2128 "Hardware impending failure drive calibration retry count") },
2130 { SST(0x5D, 0x20, SS_RDEF, /* XXX TBD */
2131 "Controller impending failure general hard drive failure") },
2133 { SST(0x5D, 0x21, SS_RDEF, /* XXX TBD */
2134 "Controller impending failure drive error rate too high") },
2136 { SST(0x5D, 0x22, SS_RDEF, /* XXX TBD */
2137 "Controller impending failure data error rate too high") },
2139 { SST(0x5D, 0x23, SS_RDEF, /* XXX TBD */
2140 "Controller impending failure seek error rate too high") },
2142 { SST(0x5D, 0x24, SS_RDEF, /* XXX TBD */
2143 "Controller impending failure too many block reassigns") },
2145 { SST(0x5D, 0x25, SS_RDEF, /* XXX TBD */
2146 "Controller impending failure access times too high") },
2148 { SST(0x5D, 0x26, SS_RDEF, /* XXX TBD */
2149 "Controller impending failure start unit times too high") },
2151 { SST(0x5D, 0x27, SS_RDEF, /* XXX TBD */
2152 "Controller impending failure channel parametrics") },
2154 { SST(0x5D, 0x28, SS_RDEF, /* XXX TBD */
2155 "Controller impending failure controller detected") },
2157 { SST(0x5D, 0x29, SS_RDEF, /* XXX TBD */
2158 "Controller impending failure throughput performance") },
2160 { SST(0x5D, 0x2A, SS_RDEF, /* XXX TBD */
2161 "Controller impending failure seek time performance") },
2163 { SST(0x5D, 0x2B, SS_RDEF, /* XXX TBD */
2164 "Controller impending failure spin-up retry count") },
2166 { SST(0x5D, 0x2C, SS_RDEF, /* XXX TBD */
2167 "Controller impending failure drive calibration retry count") },
2169 { SST(0x5D, 0x30, SS_RDEF, /* XXX TBD */
2170 "Data channel impending failure general hard drive failure") },
2172 { SST(0x5D, 0x31, SS_RDEF, /* XXX TBD */
2173 "Data channel impending failure drive error rate too high") },
2175 { SST(0x5D, 0x32, SS_RDEF, /* XXX TBD */
2176 "Data channel impending failure data error rate too high") },
2178 { SST(0x5D, 0x33, SS_RDEF, /* XXX TBD */
2179 "Data channel impending failure seek error rate too high") },
2181 { SST(0x5D, 0x34, SS_RDEF, /* XXX TBD */
2182 "Data channel impending failure too many block reassigns") },
2184 { SST(0x5D, 0x35, SS_RDEF, /* XXX TBD */
2185 "Data channel impending failure access times too high") },
2187 { SST(0x5D, 0x36, SS_RDEF, /* XXX TBD */
2188 "Data channel impending failure start unit times too high") },
2190 { SST(0x5D, 0x37, SS_RDEF, /* XXX TBD */
2191 "Data channel impending failure channel parametrics") },
2193 { SST(0x5D, 0x38, SS_RDEF, /* XXX TBD */
2194 "Data channel impending failure controller detected") },
2196 { SST(0x5D, 0x39, SS_RDEF, /* XXX TBD */
2197 "Data channel impending failure throughput performance") },
2199 { SST(0x5D, 0x3A, SS_RDEF, /* XXX TBD */
2200 "Data channel impending failure seek time performance") },
2202 { SST(0x5D, 0x3B, SS_RDEF, /* XXX TBD */
2203 "Data channel impending failure spin-up retry count") },
2205 { SST(0x5D, 0x3C, SS_RDEF, /* XXX TBD */
2206 "Data channel impending failure drive calibration retry count") },
2208 { SST(0x5D, 0x40, SS_RDEF, /* XXX TBD */
2209 "Servo impending failure general hard drive failure") },
2211 { SST(0x5D, 0x41, SS_RDEF, /* XXX TBD */
2212 "Servo impending failure drive error rate too high") },
2214 { SST(0x5D, 0x42, SS_RDEF, /* XXX TBD */
2215 "Servo impending failure data error rate too high") },
2217 { SST(0x5D, 0x43, SS_RDEF, /* XXX TBD */
2218 "Servo impending failure seek error rate too high") },
2220 { SST(0x5D, 0x44, SS_RDEF, /* XXX TBD */
2221 "Servo impending failure too many block reassigns") },
2223 { SST(0x5D, 0x45, SS_RDEF, /* XXX TBD */
2224 "Servo impending failure access times too high") },
2226 { SST(0x5D, 0x46, SS_RDEF, /* XXX TBD */
2227 "Servo impending failure start unit times too high") },
2229 { SST(0x5D, 0x47, SS_RDEF, /* XXX TBD */
2230 "Servo impending failure channel parametrics") },
2232 { SST(0x5D, 0x48, SS_RDEF, /* XXX TBD */
2233 "Servo impending failure controller detected") },
2235 { SST(0x5D, 0x49, SS_RDEF, /* XXX TBD */
2236 "Servo impending failure throughput performance") },
2238 { SST(0x5D, 0x4A, SS_RDEF, /* XXX TBD */
2239 "Servo impending failure seek time performance") },
2241 { SST(0x5D, 0x4B, SS_RDEF, /* XXX TBD */
2242 "Servo impending failure spin-up retry count") },
2244 { SST(0x5D, 0x4C, SS_RDEF, /* XXX TBD */
2245 "Servo impending failure drive calibration retry count") },
2247 { SST(0x5D, 0x50, SS_RDEF, /* XXX TBD */
2248 "Spindle impending failure general hard drive failure") },
2250 { SST(0x5D, 0x51, SS_RDEF, /* XXX TBD */
2251 "Spindle impending failure drive error rate too high") },
2253 { SST(0x5D, 0x52, SS_RDEF, /* XXX TBD */
2254 "Spindle impending failure data error rate too high") },
2256 { SST(0x5D, 0x53, SS_RDEF, /* XXX TBD */
2257 "Spindle impending failure seek error rate too high") },
2259 { SST(0x5D, 0x54, SS_RDEF, /* XXX TBD */
2260 "Spindle impending failure too many block reassigns") },
2262 { SST(0x5D, 0x55, SS_RDEF, /* XXX TBD */
2263 "Spindle impending failure access times too high") },
2265 { SST(0x5D, 0x56, SS_RDEF, /* XXX TBD */
2266 "Spindle impending failure start unit times too high") },
2268 { SST(0x5D, 0x57, SS_RDEF, /* XXX TBD */
2269 "Spindle impending failure channel parametrics") },
2271 { SST(0x5D, 0x58, SS_RDEF, /* XXX TBD */
2272 "Spindle impending failure controller detected") },
2274 { SST(0x5D, 0x59, SS_RDEF, /* XXX TBD */
2275 "Spindle impending failure throughput performance") },
2277 { SST(0x5D, 0x5A, SS_RDEF, /* XXX TBD */
2278 "Spindle impending failure seek time performance") },
2280 { SST(0x5D, 0x5B, SS_RDEF, /* XXX TBD */
2281 "Spindle impending failure spin-up retry count") },
2283 { SST(0x5D, 0x5C, SS_RDEF, /* XXX TBD */
2284 "Spindle impending failure drive calibration retry count") },
2286 { SST(0x5D, 0x60, SS_RDEF, /* XXX TBD */
2287 "Firmware impending failure general hard drive failure") },
2289 { SST(0x5D, 0x61, SS_RDEF, /* XXX TBD */
2290 "Firmware impending failure drive error rate too high") },
2292 { SST(0x5D, 0x62, SS_RDEF, /* XXX TBD */
2293 "Firmware impending failure data error rate too high") },
2295 { SST(0x5D, 0x63, SS_RDEF, /* XXX TBD */
2296 "Firmware impending failure seek error rate too high") },
2298 { SST(0x5D, 0x64, SS_RDEF, /* XXX TBD */
2299 "Firmware impending failure too many block reassigns") },
2301 { SST(0x5D, 0x65, SS_RDEF, /* XXX TBD */
2302 "Firmware impending failure access times too high") },
2304 { SST(0x5D, 0x66, SS_RDEF, /* XXX TBD */
2305 "Firmware impending failure start unit times too high") },
2307 { SST(0x5D, 0x67, SS_RDEF, /* XXX TBD */
2308 "Firmware impending failure channel parametrics") },
2310 { SST(0x5D, 0x68, SS_RDEF, /* XXX TBD */
2311 "Firmware impending failure controller detected") },
2313 { SST(0x5D, 0x69, SS_RDEF, /* XXX TBD */
2314 "Firmware impending failure throughput performance") },
2316 { SST(0x5D, 0x6A, SS_RDEF, /* XXX TBD */
2317 "Firmware impending failure seek time performance") },
2319 { SST(0x5D, 0x6B, SS_RDEF, /* XXX TBD */
2320 "Firmware impending failure spin-up retry count") },
2322 { SST(0x5D, 0x6C, SS_RDEF, /* XXX TBD */
2323 "Firmware impending failure drive calibration retry count") },
2324 /* DTLPWROMAEBKVF */
2325 { SST(0x5D, 0xFF, SS_RDEF,
2326 "Failure prediction threshold exceeded (false)") },
2328 { SST(0x5E, 0x00, SS_RDEF,
2329 "Low power condition on") },
2331 { SST(0x5E, 0x01, SS_RDEF,
2332 "Idle condition activated by timer") },
2334 { SST(0x5E, 0x02, SS_RDEF,
2335 "Standby condition activated by timer") },
2337 { SST(0x5E, 0x03, SS_RDEF,
2338 "Idle condition activated by command") },
2340 { SST(0x5E, 0x04, SS_RDEF,
2341 "Standby condition activated by command") },
2343 { SST(0x5E, 0x41, SS_RDEF, /* XXX TBD */
2344 "Power state change to active") },
2346 { SST(0x5E, 0x42, SS_RDEF, /* XXX TBD */
2347 "Power state change to idle") },
2349 { SST(0x5E, 0x43, SS_RDEF, /* XXX TBD */
2350 "Power state change to standby") },
2352 { SST(0x5E, 0x45, SS_RDEF, /* XXX TBD */
2353 "Power state change to sleep") },
2355 { SST(0x5E, 0x47, SS_RDEF, /* XXX TBD */
2356 "Power state change to device control") },
2358 { SST(0x60, 0x00, SS_RDEF,
2361 { SST(0x61, 0x00, SS_RDEF,
2362 "Video acquisition error") },
2364 { SST(0x61, 0x01, SS_RDEF,
2365 "Unable to acquire video") },
2367 { SST(0x61, 0x02, SS_RDEF,
2370 { SST(0x62, 0x00, SS_RDEF,
2371 "Scan head positioning error") },
2373 { SST(0x63, 0x00, SS_RDEF,
2374 "End of user area encountered on this track") },
2376 { SST(0x63, 0x01, SS_FATAL | ENOSPC,
2377 "Packet does not fit in available space") },
2379 { SST(0x64, 0x00, SS_FATAL | ENXIO,
2380 "Illegal mode for this track") },
2382 { SST(0x64, 0x01, SS_RDEF,
2383 "Invalid packet size") },
2384 /* DTLPWROMAEBKVF */
2385 { SST(0x65, 0x00, SS_RDEF,
2388 { SST(0x66, 0x00, SS_RDEF,
2389 "Automatic document feeder cover up") },
2391 { SST(0x66, 0x01, SS_RDEF,
2392 "Automatic document feeder lift up") },
2394 { SST(0x66, 0x02, SS_RDEF,
2395 "Document jam in automatic document feeder") },
2397 { SST(0x66, 0x03, SS_RDEF,
2398 "Document miss feed automatic in document feeder") },
2400 { SST(0x67, 0x00, SS_RDEF,
2401 "Configuration failure") },
2403 { SST(0x67, 0x01, SS_RDEF,
2404 "Configuration of incapable logical units failed") },
2406 { SST(0x67, 0x02, SS_RDEF,
2407 "Add logical unit failed") },
2409 { SST(0x67, 0x03, SS_RDEF,
2410 "Modification of logical unit failed") },
2412 { SST(0x67, 0x04, SS_RDEF,
2413 "Exchange of logical unit failed") },
2415 { SST(0x67, 0x05, SS_RDEF,
2416 "Remove of logical unit failed") },
2418 { SST(0x67, 0x06, SS_RDEF,
2419 "Attachment of logical unit failed") },
2421 { SST(0x67, 0x07, SS_RDEF,
2422 "Creation of logical unit failed") },
2424 { SST(0x67, 0x08, SS_RDEF, /* XXX TBD */
2425 "Assign failure occurred") },
2427 { SST(0x67, 0x09, SS_RDEF, /* XXX TBD */
2428 "Multiply assigned logical unit") },
2429 /* DTLPWROMAEBKVF */
2430 { SST(0x67, 0x0A, SS_RDEF, /* XXX TBD */
2431 "Set target port groups command failed") },
2433 { SST(0x67, 0x0B, SS_RDEF, /* XXX TBD */
2434 "ATA device feature not enabled") },
2436 { SST(0x68, 0x00, SS_RDEF,
2437 "Logical unit not configured") },
2439 { SST(0x69, 0x00, SS_RDEF,
2440 "Data loss on logical unit") },
2442 { SST(0x69, 0x01, SS_RDEF,
2443 "Multiple logical unit failures") },
2445 { SST(0x69, 0x02, SS_RDEF,
2446 "Parity/data mismatch") },
2448 { SST(0x6A, 0x00, SS_RDEF,
2449 "Informational, refer to log") },
2451 { SST(0x6B, 0x00, SS_RDEF,
2452 "State change has occurred") },
2454 { SST(0x6B, 0x01, SS_RDEF,
2455 "Redundancy level got better") },
2457 { SST(0x6B, 0x02, SS_RDEF,
2458 "Redundancy level got worse") },
2460 { SST(0x6C, 0x00, SS_RDEF,
2461 "Rebuild failure occurred") },
2463 { SST(0x6D, 0x00, SS_RDEF,
2464 "Recalculate failure occurred") },
2466 { SST(0x6E, 0x00, SS_RDEF,
2467 "Command to logical unit failed") },
2469 { SST(0x6F, 0x00, SS_RDEF, /* XXX TBD */
2470 "Copy protection key exchange failure - authentication failure") },
2472 { SST(0x6F, 0x01, SS_RDEF, /* XXX TBD */
2473 "Copy protection key exchange failure - key not present") },
2475 { SST(0x6F, 0x02, SS_RDEF, /* XXX TBD */
2476 "Copy protection key exchange failure - key not established") },
2478 { SST(0x6F, 0x03, SS_RDEF, /* XXX TBD */
2479 "Read of scrambled sector without authentication") },
2481 { SST(0x6F, 0x04, SS_RDEF, /* XXX TBD */
2482 "Media region code is mismatched to logical unit region") },
2484 { SST(0x6F, 0x05, SS_RDEF, /* XXX TBD */
2485 "Drive region must be permanent/region reset count error") },
2487 { SST(0x6F, 0x06, SS_RDEF, /* XXX TBD */
2488 "Insufficient block count for binding NONCE recording") },
2490 { SST(0x6F, 0x07, SS_RDEF, /* XXX TBD */
2491 "Conflict in binding NONCE recording") },
2493 { SST(0x70, 0x00, SS_RDEF,
2494 "Decompression exception short: ASCQ = Algorithm ID") },
2496 { SST(0x70, 0xFF, SS_RDEF | SSQ_RANGE,
2497 NULL) }, /* Range 0x00 -> 0xFF */
2499 { SST(0x71, 0x00, SS_RDEF,
2500 "Decompression exception long: ASCQ = Algorithm ID") },
2502 { SST(0x71, 0xFF, SS_RDEF | SSQ_RANGE,
2503 NULL) }, /* Range 0x00 -> 0xFF */
2505 { SST(0x72, 0x00, SS_RDEF,
2506 "Session fixation error") },
2508 { SST(0x72, 0x01, SS_RDEF,
2509 "Session fixation error writing lead-in") },
2511 { SST(0x72, 0x02, SS_RDEF,
2512 "Session fixation error writing lead-out") },
2514 { SST(0x72, 0x03, SS_RDEF,
2515 "Session fixation error - incomplete track in session") },
2517 { SST(0x72, 0x04, SS_RDEF,
2518 "Empty or partially written reserved track") },
2520 { SST(0x72, 0x05, SS_RDEF, /* XXX TBD */
2521 "No more track reservations allowed") },
2523 { SST(0x72, 0x06, SS_RDEF, /* XXX TBD */
2524 "RMZ extension is not allowed") },
2526 { SST(0x72, 0x07, SS_RDEF, /* XXX TBD */
2527 "No more test zone extensions are allowed") },
2529 { SST(0x73, 0x00, SS_RDEF,
2530 "CD control error") },
2532 { SST(0x73, 0x01, SS_RDEF,
2533 "Power calibration area almost full") },
2535 { SST(0x73, 0x02, SS_FATAL | ENOSPC,
2536 "Power calibration area is full") },
2538 { SST(0x73, 0x03, SS_RDEF,
2539 "Power calibration area error") },
2541 { SST(0x73, 0x04, SS_RDEF,
2542 "Program memory area update failure") },
2544 { SST(0x73, 0x05, SS_RDEF,
2545 "Program memory area is full") },
2547 { SST(0x73, 0x06, SS_RDEF, /* XXX TBD */
2548 "RMA/PMA is almost full") },
2550 { SST(0x73, 0x10, SS_RDEF, /* XXX TBD */
2551 "Current power calibration area almost full") },
2553 { SST(0x73, 0x11, SS_RDEF, /* XXX TBD */
2554 "Current power calibration area is full") },
2556 { SST(0x73, 0x17, SS_RDEF, /* XXX TBD */
2559 { SST(0x74, 0x00, SS_RDEF, /* XXX TBD */
2560 "Security error") },
2562 { SST(0x74, 0x01, SS_RDEF, /* XXX TBD */
2563 "Unable to decrypt data") },
2565 { SST(0x74, 0x02, SS_RDEF, /* XXX TBD */
2566 "Unencrypted data encountered while decrypting") },
2568 { SST(0x74, 0x03, SS_RDEF, /* XXX TBD */
2569 "Incorrect data encryption key") },
2571 { SST(0x74, 0x04, SS_RDEF, /* XXX TBD */
2572 "Cryptographic integrity validation failed") },
2574 { SST(0x74, 0x05, SS_RDEF, /* XXX TBD */
2575 "Error decrypting data") },
2577 { SST(0x74, 0x06, SS_RDEF, /* XXX TBD */
2578 "Unknown signature verification key") },
2580 { SST(0x74, 0x07, SS_RDEF, /* XXX TBD */
2581 "Encryption parameters not useable") },
2583 { SST(0x74, 0x08, SS_RDEF, /* XXX TBD */
2584 "Digital signature validation failure") },
2586 { SST(0x74, 0x09, SS_RDEF, /* XXX TBD */
2587 "Encryption mode mismatch on read") },
2589 { SST(0x74, 0x0A, SS_RDEF, /* XXX TBD */
2590 "Encrypted block not raw read enabled") },
2592 { SST(0x74, 0x0B, SS_RDEF, /* XXX TBD */
2593 "Incorrect encryption parameters") },
2595 { SST(0x74, 0x0C, SS_RDEF, /* XXX TBD */
2596 "Unable to decrypt parameter list") },
2598 { SST(0x74, 0x0D, SS_RDEF, /* XXX TBD */
2599 "Encryption algorithm disabled") },
2601 { SST(0x74, 0x10, SS_RDEF, /* XXX TBD */
2602 "SA creation parameter value invalid") },
2604 { SST(0x74, 0x11, SS_RDEF, /* XXX TBD */
2605 "SA creation parameter value rejected") },
2607 { SST(0x74, 0x12, SS_RDEF, /* XXX TBD */
2608 "Invalid SA usage") },
2610 { SST(0x74, 0x21, SS_RDEF, /* XXX TBD */
2611 "Data encryption configuration prevented") },
2613 { SST(0x74, 0x30, SS_RDEF, /* XXX TBD */
2614 "SA creation parameter not supported") },
2616 { SST(0x74, 0x40, SS_RDEF, /* XXX TBD */
2617 "Authentication failed") },
2619 { SST(0x74, 0x61, SS_RDEF, /* XXX TBD */
2620 "External data encryption key manager access error") },
2622 { SST(0x74, 0x62, SS_RDEF, /* XXX TBD */
2623 "External data encryption key manager error") },
2625 { SST(0x74, 0x63, SS_RDEF, /* XXX TBD */
2626 "External data encryption key not found") },
2628 { SST(0x74, 0x64, SS_RDEF, /* XXX TBD */
2629 "External data encryption request not authorized") },
2631 { SST(0x74, 0x6E, SS_RDEF, /* XXX TBD */
2632 "External data encryption control timeout") },
2634 { SST(0x74, 0x6F, SS_RDEF, /* XXX TBD */
2635 "External data encryption control error") },
2637 { SST(0x74, 0x71, SS_RDEF, /* XXX TBD */
2638 "Logical unit access not authorized") },
2640 { SST(0x74, 0x79, SS_RDEF, /* XXX TBD */
2641 "Security conflict in translated device") }
2644 const int asc_table_size = sizeof(asc_table)/sizeof(asc_table[0]);
2653 ascentrycomp(const void *key, const void *member)
2657 const struct asc_table_entry *table_entry;
2659 asc = ((const struct asc_key *)key)->asc;
2660 ascq = ((const struct asc_key *)key)->ascq;
2661 table_entry = (const struct asc_table_entry *)member;
2663 if (asc >= table_entry->asc) {
2665 if (asc > table_entry->asc)
2668 if (ascq <= table_entry->ascq) {
2669 /* Check for ranges */
2670 if (ascq == table_entry->ascq
2671 || ((table_entry->action & SSQ_RANGE) != 0
2672 && ascq >= (table_entry - 1)->ascq))
2682 senseentrycomp(const void *key, const void *member)
2685 const struct sense_key_table_entry *table_entry;
2687 sense_key = *((const int *)key);
2688 table_entry = (const struct sense_key_table_entry *)member;
2690 if (sense_key >= table_entry->sense_key) {
2691 if (sense_key == table_entry->sense_key)
2699 fetchtableentries(int sense_key, int asc, int ascq,
2700 struct scsi_inquiry_data *inq_data,
2701 const struct sense_key_table_entry **sense_entry,
2702 const struct asc_table_entry **asc_entry)
2705 const struct asc_table_entry *asc_tables[2];
2706 const struct sense_key_table_entry *sense_tables[2];
2707 struct asc_key asc_ascq;
2708 size_t asc_tables_size[2];
2709 size_t sense_tables_size[2];
2711 int num_sense_tables;
2714 /* Default to failure */
2715 *sense_entry = NULL;
2718 if (inq_data != NULL)
2719 match = cam_quirkmatch((caddr_t)inq_data,
2720 (caddr_t)sense_quirk_table,
2721 sense_quirk_table_size,
2722 sizeof(*sense_quirk_table),
2723 scsi_inquiry_match);
2725 if (match != NULL) {
2726 struct scsi_sense_quirk_entry *quirk;
2728 quirk = (struct scsi_sense_quirk_entry *)match;
2729 asc_tables[0] = quirk->asc_info;
2730 asc_tables_size[0] = quirk->num_ascs;
2731 asc_tables[1] = asc_table;
2732 asc_tables_size[1] = asc_table_size;
2734 sense_tables[0] = quirk->sense_key_info;
2735 sense_tables_size[0] = quirk->num_sense_keys;
2736 sense_tables[1] = sense_key_table;
2737 sense_tables_size[1] = sense_key_table_size;
2738 num_sense_tables = 2;
2740 asc_tables[0] = asc_table;
2741 asc_tables_size[0] = asc_table_size;
2743 sense_tables[0] = sense_key_table;
2744 sense_tables_size[0] = sense_key_table_size;
2745 num_sense_tables = 1;
2749 asc_ascq.ascq = ascq;
2750 for (i = 0; i < num_asc_tables; i++) {
2753 found_entry = bsearch(&asc_ascq, asc_tables[i],
2755 sizeof(**asc_tables),
2759 *asc_entry = (struct asc_table_entry *)found_entry;
2764 for (i = 0; i < num_sense_tables; i++) {
2767 found_entry = bsearch(&sense_key, sense_tables[i],
2768 sense_tables_size[i],
2769 sizeof(**sense_tables),
2774 (struct sense_key_table_entry *)found_entry;
2781 scsi_sense_desc(int sense_key, int asc, int ascq,
2782 struct scsi_inquiry_data *inq_data,
2783 const char **sense_key_desc, const char **asc_desc)
2785 const struct asc_table_entry *asc_entry;
2786 const struct sense_key_table_entry *sense_entry;
2788 fetchtableentries(sense_key, asc, ascq,
2793 *sense_key_desc = sense_entry->desc;
2795 if (asc_entry != NULL)
2796 *asc_desc = asc_entry->desc;
2797 else if (asc >= 0x80 && asc <= 0xff)
2798 *asc_desc = "Vendor Specific ASC";
2799 else if (ascq >= 0x80 && ascq <= 0xff)
2800 *asc_desc = "Vendor Specific ASCQ";
2802 *asc_desc = "Reserved ASC/ASCQ pair";
2806 * Given sense and device type information, return the appropriate action.
2807 * If we do not understand the specific error as identified by the ASC/ASCQ
2808 * pair, fall back on the more generic actions derived from the sense key.
2811 scsi_error_action(struct ccb_scsiio *csio, struct scsi_inquiry_data *inq_data,
2812 u_int32_t sense_flags)
2814 const struct asc_table_entry *asc_entry;
2815 const struct sense_key_table_entry *sense_entry;
2816 int error_code, sense_key, asc, ascq;
2817 scsi_sense_action action;
2819 scsi_extract_sense(&csio->sense_data, &error_code,
2820 &sense_key, &asc, &ascq);
2822 if (error_code == SSD_DEFERRED_ERROR) {
2824 * XXX dufault@FreeBSD.org
2825 * This error doesn't relate to the command associated
2826 * with this request sense. A deferred error is an error
2827 * for a command that has already returned GOOD status
2828 * (see SCSI2 8.2.14.2).
2830 * By my reading of that section, it looks like the current
2831 * command has been cancelled, we should now clean things up
2832 * (hopefully recovering any lost data) and then retry the
2833 * current command. There are two easy choices, both wrong:
2835 * 1. Drop through (like we had been doing), thus treating
2836 * this as if the error were for the current command and
2837 * return and stop the current command.
2839 * 2. Issue a retry (like I made it do) thus hopefully
2840 * recovering the current transfer, and ignoring the
2841 * fact that we've dropped a command.
2843 * These should probably be handled in a device specific
2844 * sense handler or punted back up to a user mode daemon
2846 action = SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE;
2848 fetchtableentries(sense_key, asc, ascq,
2854 * Override the 'No additional Sense' entry (0,0)
2855 * with the error action of the sense key.
2857 if (asc_entry != NULL
2858 && (asc != 0 || ascq != 0))
2859 action = asc_entry->action;
2861 action = sense_entry->action;
2863 if (sense_key == SSD_KEY_RECOVERED_ERROR) {
2865 * The action succeeded but the device wants
2866 * the user to know that some recovery action
2869 action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK);
2870 action |= SS_NOP|SSQ_PRINT_SENSE;
2871 } else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) {
2872 if ((sense_flags & SF_QUIET_IR) != 0)
2873 action &= ~SSQ_PRINT_SENSE;
2874 } else if (sense_key == SSD_KEY_UNIT_ATTENTION) {
2875 if ((sense_flags & SF_RETRY_UA) != 0
2876 && (action & SS_MASK) == SS_FAIL) {
2877 action &= ~(SS_MASK|SSQ_MASK);
2878 action |= SS_RETRY|SSQ_DECREMENT_COUNT|
2885 sense_flags |= SF_PRINT_ALWAYS;
2887 if ((sense_flags & SF_PRINT_ALWAYS) != 0)
2888 action |= SSQ_PRINT_SENSE;
2889 else if ((sense_flags & SF_NO_PRINT) != 0)
2890 action &= ~SSQ_PRINT_SENSE;
2896 scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string, size_t len)
2901 if (cdb_ptr == NULL)
2904 /* Silence warnings */
2908 * This is taken from the SCSI-3 draft spec.
2909 * (T10/1157D revision 0.3)
2910 * The top 3 bits of an opcode are the group code. The next 5 bits
2911 * are the command code.
2912 * Group 0: six byte commands
2913 * Group 1: ten byte commands
2914 * Group 2: ten byte commands
2916 * Group 4: sixteen byte commands
2917 * Group 5: twelve byte commands
2918 * Group 6: vendor specific
2919 * Group 7: vendor specific
2921 switch((*cdb_ptr >> 5) & 0x7) {
2932 /* in this case, just print out the opcode */
2943 for (i = 0; i < cdb_len; i++)
2944 snprintf(cdb_string + strlen(cdb_string),
2945 len - strlen(cdb_string), "%x ", cdb_ptr[i]);
2951 scsi_status_string(struct ccb_scsiio *csio)
2953 switch(csio->scsi_status) {
2954 case SCSI_STATUS_OK:
2956 case SCSI_STATUS_CHECK_COND:
2957 return("Check Condition");
2958 case SCSI_STATUS_BUSY:
2960 case SCSI_STATUS_INTERMED:
2961 return("Intermediate");
2962 case SCSI_STATUS_INTERMED_COND_MET:
2963 return("Intermediate-Condition Met");
2964 case SCSI_STATUS_RESERV_CONFLICT:
2965 return("Reservation Conflict");
2966 case SCSI_STATUS_CMD_TERMINATED:
2967 return("Command Terminated");
2968 case SCSI_STATUS_QUEUE_FULL:
2969 return("Queue Full");
2970 case SCSI_STATUS_ACA_ACTIVE:
2971 return("ACA Active");
2972 case SCSI_STATUS_TASK_ABORTED:
2973 return("Task Aborted");
2975 static char unkstr[64];
2976 snprintf(unkstr, sizeof(unkstr), "Unknown %#x",
2984 * scsi_command_string() returns 0 for success and -1 for failure.
2988 scsi_command_string(struct ccb_scsiio *csio, struct sbuf *sb)
2989 #else /* !_KERNEL */
2991 scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio,
2993 #endif /* _KERNEL/!_KERNEL */
2995 struct scsi_inquiry_data *inq_data;
2996 char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1];
2998 struct ccb_getdev *cgd;
2999 #endif /* _KERNEL */
3002 if ((cgd = (struct ccb_getdev*)xpt_alloc_ccb_nowait()) == NULL)
3005 * Get the device information.
3007 xpt_setup_ccb(&cgd->ccb_h,
3009 CAM_PRIORITY_NORMAL);
3010 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
3011 xpt_action((union ccb *)cgd);
3014 * If the device is unconfigured, just pretend that it is a hard
3015 * drive. scsi_op_desc() needs this.
3017 if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
3018 cgd->inq_data.device = T_DIRECT;
3020 inq_data = &cgd->inq_data;
3022 #else /* !_KERNEL */
3024 inq_data = &device->inq_data;
3026 #endif /* _KERNEL/!_KERNEL */
3028 if ((csio->ccb_h.flags & CAM_CDB_POINTER) != 0) {
3029 sbuf_printf(sb, "%s. CDB: %s",
3030 scsi_op_desc(csio->cdb_io.cdb_ptr[0], inq_data),
3031 scsi_cdb_string(csio->cdb_io.cdb_ptr, cdb_str,
3034 sbuf_printf(sb, "%s. CDB: %s",
3035 scsi_op_desc(csio->cdb_io.cdb_bytes[0], inq_data),
3036 scsi_cdb_string(csio->cdb_io.cdb_bytes, cdb_str,
3045 * scsi_sense_sbuf() returns 0 for success and -1 for failure.
3049 scsi_sense_sbuf(struct ccb_scsiio *csio, struct sbuf *sb,
3050 scsi_sense_string_flags flags)
3051 #else /* !_KERNEL */
3053 scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
3054 struct sbuf *sb, scsi_sense_string_flags flags)
3055 #endif /* _KERNEL/!_KERNEL */
3057 struct scsi_sense_data *sense;
3058 struct scsi_inquiry_data *inq_data;
3060 struct ccb_getdev *cgd;
3061 #endif /* _KERNEL */
3071 #endif /* !_KERNEL */
3072 if ((csio == NULL) || (sb == NULL))
3076 * If the CDB is a physical address, we can't deal with it..
3078 if ((csio->ccb_h.flags & CAM_CDB_PHYS) != 0)
3079 flags &= ~SSS_FLAG_PRINT_COMMAND;
3082 xpt_path_string(csio->ccb_h.path, path_str, sizeof(path_str));
3083 #else /* !_KERNEL */
3084 cam_path_string(device, path_str, sizeof(path_str));
3085 #endif /* _KERNEL/!_KERNEL */
3088 if ((cgd = (struct ccb_getdev*)xpt_alloc_ccb_nowait()) == NULL)
3091 * Get the device information.
3093 xpt_setup_ccb(&cgd->ccb_h,
3095 CAM_PRIORITY_NORMAL);
3096 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
3097 xpt_action((union ccb *)cgd);
3100 * If the device is unconfigured, just pretend that it is a hard
3101 * drive. scsi_op_desc() needs this.
3103 if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
3104 cgd->inq_data.device = T_DIRECT;
3106 inq_data = &cgd->inq_data;
3108 #else /* !_KERNEL */
3110 inq_data = &device->inq_data;
3112 #endif /* _KERNEL/!_KERNEL */
3116 if (flags & SSS_FLAG_PRINT_COMMAND) {
3118 sbuf_cat(sb, path_str);
3121 scsi_command_string(csio, sb);
3122 #else /* !_KERNEL */
3123 scsi_command_string(device, csio, sb);
3124 #endif /* _KERNEL/!_KERNEL */
3125 sbuf_printf(sb, "\n");
3129 * If the sense data is a physical pointer, forget it.
3131 if (csio->ccb_h.flags & CAM_SENSE_PTR) {
3132 if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
3134 xpt_free_ccb((union ccb*)cgd);
3135 #endif /* _KERNEL/!_KERNEL */
3139 * bcopy the pointer to avoid unaligned access
3140 * errors on finicky architectures. We don't
3141 * ensure that the sense data is pointer aligned.
3143 bcopy(&csio->sense_data, &sense,
3144 sizeof(struct scsi_sense_data *));
3148 * If the physical sense flag is set, but the sense pointer
3149 * is not also set, we assume that the user is an idiot and
3150 * return. (Well, okay, it could be that somehow, the
3151 * entire csio is physical, but we would have probably core
3152 * dumped on one of the bogus pointer deferences above
3155 if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
3157 xpt_free_ccb((union ccb*)cgd);
3158 #endif /* _KERNEL/!_KERNEL */
3161 sense = &csio->sense_data;
3165 sbuf_cat(sb, path_str);
3167 error_code = sense->error_code & SSD_ERRCODE;
3168 sense_key = sense->flags & SSD_KEY;
3170 sbuf_printf(sb, "SCSI sense: ");
3171 switch (error_code) {
3172 case SSD_DEFERRED_ERROR:
3173 sbuf_printf(sb, "Deferred error: ");
3176 case SSD_CURRENT_ERROR:
3178 const char *sense_key_desc;
3179 const char *asc_desc;
3181 asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
3182 ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
3183 scsi_sense_desc(sense_key, asc, ascq, inq_data,
3184 &sense_key_desc, &asc_desc);
3185 sbuf_cat(sb, sense_key_desc);
3187 info = scsi_4btoul(sense->info);
3189 if (sense->error_code & SSD_ERRCODE_VALID) {
3191 switch (sense_key) {
3192 case SSD_KEY_NOT_READY:
3193 case SSD_KEY_ILLEGAL_REQUEST:
3194 case SSD_KEY_UNIT_ATTENTION:
3195 case SSD_KEY_DATA_PROTECT:
3197 case SSD_KEY_BLANK_CHECK:
3198 sbuf_printf(sb, " req sz: %d (decimal)", info);
3202 if (sense->flags & SSD_ILI) {
3203 sbuf_printf(sb, " ILI (length "
3204 "mismatch): %d", info);
3207 sbuf_printf(sb, " info:%x",
3213 sbuf_printf(sb, " info?:%x", info);
3216 if (sense->extra_len >= 4) {
3217 if (bcmp(sense->cmd_spec_info, "\0\0\0\0", 4)) {
3218 sbuf_printf(sb, " csi:%x,%x,%x,%x",
3219 sense->cmd_spec_info[0],
3220 sense->cmd_spec_info[1],
3221 sense->cmd_spec_info[2],
3222 sense->cmd_spec_info[3]);
3226 sbuf_printf(sb, " asc:%x,%x (%s)", asc, ascq, asc_desc);
3228 if (sense->extra_len >= 7 && sense->fru) {
3229 sbuf_printf(sb, " field replaceable unit: %x",
3233 if ((sense->extra_len >= 10)
3234 && (sense->sense_key_spec[0] & SSD_SCS_VALID) != 0) {
3236 case SSD_KEY_ILLEGAL_REQUEST: {
3240 if (sense->sense_key_spec[0] & 0x40)
3247 /* Bit pointer is valid */
3248 if (sense->sense_key_spec[0] & 0x08)
3249 snprintf(tmpstr2, sizeof(tmpstr2),
3251 sense->sense_key_spec[0] & 0x7);
3252 sbuf_printf(sb, ": %s byte %d %sis invalid",
3253 bad_command ? "Command" : "Data",
3255 &sense->sense_key_spec[1]),
3259 case SSD_KEY_RECOVERED_ERROR:
3260 case SSD_KEY_HARDWARE_ERROR:
3261 case SSD_KEY_MEDIUM_ERROR:
3262 sbuf_printf(sb, " actual retry count: %d",
3264 &sense->sense_key_spec[1]));
3267 sbuf_printf(sb, " sks:%#x,%#x",
3268 sense->sense_key_spec[0],
3270 &sense->sense_key_spec[1]));
3278 sbuf_printf(sb, "Error code 0x%x", sense->error_code);
3279 if (sense->error_code & SSD_ERRCODE_VALID) {
3280 sbuf_printf(sb, " at block no. %d (decimal)",
3281 info = scsi_4btoul(sense->info));
3285 sbuf_printf(sb, "\n");
3288 xpt_free_ccb((union ccb*)cgd);
3289 #endif /* _KERNEL/!_KERNEL */
3297 scsi_sense_string(struct ccb_scsiio *csio, char *str, int str_len)
3298 #else /* !_KERNEL */
3300 scsi_sense_string(struct cam_device *device, struct ccb_scsiio *csio,
3301 char *str, int str_len)
3302 #endif /* _KERNEL/!_KERNEL */
3306 sbuf_new(&sb, str, str_len, 0);
3309 scsi_sense_sbuf(csio, &sb, SSS_FLAG_PRINT_COMMAND);
3310 #else /* !_KERNEL */
3311 scsi_sense_sbuf(device, csio, &sb, SSS_FLAG_PRINT_COMMAND);
3312 #endif /* _KERNEL/!_KERNEL */
3316 return(sbuf_data(&sb));
3321 scsi_sense_print(struct ccb_scsiio *csio)
3326 sbuf_new(&sb, str, sizeof(str), 0);
3328 scsi_sense_sbuf(csio, &sb, SSS_FLAG_PRINT_COMMAND);
3332 printf("%s", sbuf_data(&sb));
3335 #else /* !_KERNEL */
3337 scsi_sense_print(struct cam_device *device, struct ccb_scsiio *csio,
3343 if ((device == NULL) || (csio == NULL) || (ofile == NULL))
3346 sbuf_new(&sb, str, sizeof(str), 0);
3348 scsi_sense_sbuf(device, csio, &sb, SSS_FLAG_PRINT_COMMAND);
3352 fprintf(ofile, "%s", sbuf_data(&sb));
3355 #endif /* _KERNEL/!_KERNEL */
3358 * This function currently requires at least 36 bytes, or
3359 * SHORT_INQUIRY_LENGTH, worth of data to function properly. If this
3360 * function needs more or less data in the future, another length should be
3361 * defined in scsi_all.h to indicate the minimum amount of data necessary
3362 * for this routine to function properly.
3365 scsi_print_inquiry(struct scsi_inquiry_data *inq_data)
3368 char *dtype, *qtype;
3369 char vendor[16], product[48], revision[16], rstr[4];
3371 type = SID_TYPE(inq_data);
3374 * Figure out basic device type and qualifier.
3376 if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data)) {
3377 qtype = "(vendor-unique qualifier)";
3379 switch (SID_QUAL(inq_data)) {
3380 case SID_QUAL_LU_CONNECTED:
3384 case SID_QUAL_LU_OFFLINE:
3385 qtype = "(offline)";
3389 qtype = "(reserved qualifier)";
3392 case SID_QUAL_BAD_LU:
3393 qtype = "(LUN not supported)";
3400 dtype = "Direct Access";
3403 dtype = "Sequential Access";
3409 dtype = "Processor";
3427 dtype = "Communication";
3430 dtype = "Storage Array";
3433 dtype = "Enclosure Services";
3436 dtype = "Simplified Direct Access";
3439 dtype = "Optical Card Read/Write";
3442 dtype = "Object-Based Storage";
3445 dtype = "Automation/Drive Interface";
3448 dtype = "Uninstalled";
3455 cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor),
3457 cam_strvis(product, inq_data->product, sizeof(inq_data->product),
3459 cam_strvis(revision, inq_data->revision, sizeof(inq_data->revision),
3462 if (SID_ANSI_REV(inq_data) == SCSI_REV_CCS)
3463 bcopy("CCS", rstr, 4);
3465 snprintf(rstr, sizeof (rstr), "%d", SID_ANSI_REV(inq_data));
3466 printf("<%s %s %s> %s %s SCSI-%s device %s\n",
3467 vendor, product, revision,
3468 SID_IS_REMOVABLE(inq_data) ? "Removable" : "Fixed",
3469 dtype, rstr, qtype);
3473 * Table of syncrates that don't follow the "divisible by 4"
3474 * rule. This table will be expanded in future SCSI specs.
3477 u_int period_factor;
3478 u_int period; /* in 100ths of ns */
3479 } scsi_syncrates[] = {
3480 { 0x08, 625 }, /* FAST-160 */
3481 { 0x09, 1250 }, /* FAST-80 */
3482 { 0x0a, 2500 }, /* FAST-40 40MHz */
3483 { 0x0b, 3030 }, /* FAST-40 33MHz */
3484 { 0x0c, 5000 } /* FAST-20 */
3488 * Return the frequency in kHz corresponding to the given
3489 * sync period factor.
3492 scsi_calc_syncsrate(u_int period_factor)
3498 * It's a bug if period is zero, but if it is anyway, don't
3499 * die with a divide fault- instead return something which
3500 * 'approximates' async
3502 if (period_factor == 0) {
3506 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
3507 /* See if the period is in the "exception" table */
3508 for (i = 0; i < num_syncrates; i++) {
3510 if (period_factor == scsi_syncrates[i].period_factor) {
3512 return (100000000 / scsi_syncrates[i].period);
3517 * Wasn't in the table, so use the standard
3518 * 4 times conversion.
3520 return (10000000 / (period_factor * 4 * 10));
3524 * Return the SCSI sync parameter that corresponsd to
3525 * the passed in period in 10ths of ns.
3528 scsi_calc_syncparam(u_int period)
3534 return (~0); /* Async */
3536 /* Adjust for exception table being in 100ths. */
3538 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
3539 /* See if the period is in the "exception" table */
3540 for (i = 0; i < num_syncrates; i++) {
3542 if (period <= scsi_syncrates[i].period) {
3543 /* Period in 100ths of ns */
3544 return (scsi_syncrates[i].period_factor);
3549 * Wasn't in the table, so use the standard
3550 * 1/4 period in ns conversion.
3552 return (period/400);
3556 scsi_test_unit_ready(struct ccb_scsiio *csio, u_int32_t retries,
3557 void (*cbfcnp)(struct cam_periph *, union ccb *),
3558 u_int8_t tag_action, u_int8_t sense_len, u_int32_t timeout)
3560 struct scsi_test_unit_ready *scsi_cmd;
3573 scsi_cmd = (struct scsi_test_unit_ready *)&csio->cdb_io.cdb_bytes;
3574 bzero(scsi_cmd, sizeof(*scsi_cmd));
3575 scsi_cmd->opcode = TEST_UNIT_READY;
3579 scsi_request_sense(struct ccb_scsiio *csio, u_int32_t retries,
3580 void (*cbfcnp)(struct cam_periph *, union ccb *),
3581 void *data_ptr, u_int8_t dxfer_len, u_int8_t tag_action,
3582 u_int8_t sense_len, u_int32_t timeout)
3584 struct scsi_request_sense *scsi_cmd;
3597 scsi_cmd = (struct scsi_request_sense *)&csio->cdb_io.cdb_bytes;
3598 bzero(scsi_cmd, sizeof(*scsi_cmd));
3599 scsi_cmd->opcode = REQUEST_SENSE;
3600 scsi_cmd->length = dxfer_len;
3604 scsi_inquiry(struct ccb_scsiio *csio, u_int32_t retries,
3605 void (*cbfcnp)(struct cam_periph *, union ccb *),
3606 u_int8_t tag_action, u_int8_t *inq_buf, u_int32_t inq_len,
3607 int evpd, u_int8_t page_code, u_int8_t sense_len,
3610 struct scsi_inquiry *scsi_cmd;
3615 /*flags*/CAM_DIR_IN,
3617 /*data_ptr*/inq_buf,
3618 /*dxfer_len*/inq_len,
3623 scsi_cmd = (struct scsi_inquiry *)&csio->cdb_io.cdb_bytes;
3624 bzero(scsi_cmd, sizeof(*scsi_cmd));
3625 scsi_cmd->opcode = INQUIRY;
3627 scsi_cmd->byte2 |= SI_EVPD;
3628 scsi_cmd->page_code = page_code;
3631 * A 'transfer units' count of 256 is coded as
3632 * zero for all commands with a single byte count
3637 scsi_cmd->length = inq_len;
3641 scsi_mode_sense(struct ccb_scsiio *csio, u_int32_t retries,
3642 void (*cbfcnp)(struct cam_periph *, union ccb *),
3643 u_int8_t tag_action, int dbd, u_int8_t page_code,
3644 u_int8_t page, u_int8_t *param_buf, u_int32_t param_len,
3645 u_int8_t sense_len, u_int32_t timeout)
3648 scsi_mode_sense_len(csio, retries, cbfcnp, tag_action, dbd,
3649 page_code, page, param_buf, param_len, 0,
3650 sense_len, timeout);
3654 scsi_mode_sense_len(struct ccb_scsiio *csio, u_int32_t retries,
3655 void (*cbfcnp)(struct cam_periph *, union ccb *),
3656 u_int8_t tag_action, int dbd, u_int8_t page_code,
3657 u_int8_t page, u_int8_t *param_buf, u_int32_t param_len,
3658 int minimum_cmd_size, u_int8_t sense_len, u_int32_t timeout)
3663 * Use the smallest possible command to perform the operation.
3665 if ((param_len < 256)
3666 && (minimum_cmd_size < 10)) {
3668 * We can fit in a 6 byte cdb.
3670 struct scsi_mode_sense_6 *scsi_cmd;
3672 scsi_cmd = (struct scsi_mode_sense_6 *)&csio->cdb_io.cdb_bytes;
3673 bzero(scsi_cmd, sizeof(*scsi_cmd));
3674 scsi_cmd->opcode = MODE_SENSE_6;
3676 scsi_cmd->byte2 |= SMS_DBD;
3677 scsi_cmd->page = page_code | page;
3678 scsi_cmd->length = param_len;
3679 cdb_len = sizeof(*scsi_cmd);
3682 * Need a 10 byte cdb.
3684 struct scsi_mode_sense_10 *scsi_cmd;
3686 scsi_cmd = (struct scsi_mode_sense_10 *)&csio->cdb_io.cdb_bytes;
3687 bzero(scsi_cmd, sizeof(*scsi_cmd));
3688 scsi_cmd->opcode = MODE_SENSE_10;
3690 scsi_cmd->byte2 |= SMS_DBD;
3691 scsi_cmd->page = page_code | page;
3692 scsi_ulto2b(param_len, scsi_cmd->length);
3693 cdb_len = sizeof(*scsi_cmd);
3708 scsi_mode_select(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, u_int8_t sense_len,
3714 scsi_mode_select_len(csio, retries, cbfcnp, tag_action,
3715 scsi_page_fmt, save_pages, param_buf,
3716 param_len, 0, sense_len, timeout);
3720 scsi_mode_select_len(struct ccb_scsiio *csio, u_int32_t retries,
3721 void (*cbfcnp)(struct cam_periph *, union ccb *),
3722 u_int8_t tag_action, int scsi_page_fmt, int save_pages,
3723 u_int8_t *param_buf, u_int32_t param_len,
3724 int minimum_cmd_size, u_int8_t sense_len,
3730 * Use the smallest possible command to perform the operation.
3732 if ((param_len < 256)
3733 && (minimum_cmd_size < 10)) {
3735 * We can fit in a 6 byte cdb.
3737 struct scsi_mode_select_6 *scsi_cmd;
3739 scsi_cmd = (struct scsi_mode_select_6 *)&csio->cdb_io.cdb_bytes;
3740 bzero(scsi_cmd, sizeof(*scsi_cmd));
3741 scsi_cmd->opcode = MODE_SELECT_6;
3742 if (scsi_page_fmt != 0)
3743 scsi_cmd->byte2 |= SMS_PF;
3744 if (save_pages != 0)
3745 scsi_cmd->byte2 |= SMS_SP;
3746 scsi_cmd->length = param_len;
3747 cdb_len = sizeof(*scsi_cmd);
3750 * Need a 10 byte cdb.
3752 struct scsi_mode_select_10 *scsi_cmd;
3755 (struct scsi_mode_select_10 *)&csio->cdb_io.cdb_bytes;
3756 bzero(scsi_cmd, sizeof(*scsi_cmd));
3757 scsi_cmd->opcode = MODE_SELECT_10;
3758 if (scsi_page_fmt != 0)
3759 scsi_cmd->byte2 |= SMS_PF;
3760 if (save_pages != 0)
3761 scsi_cmd->byte2 |= SMS_SP;
3762 scsi_ulto2b(param_len, scsi_cmd->length);
3763 cdb_len = sizeof(*scsi_cmd);
3778 scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries,
3779 void (*cbfcnp)(struct cam_periph *, union ccb *),
3780 u_int8_t tag_action, u_int8_t page_code, u_int8_t page,
3781 int save_pages, int ppc, u_int32_t paramptr,
3782 u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len,
3785 struct scsi_log_sense *scsi_cmd;
3788 scsi_cmd = (struct scsi_log_sense *)&csio->cdb_io.cdb_bytes;
3789 bzero(scsi_cmd, sizeof(*scsi_cmd));
3790 scsi_cmd->opcode = LOG_SENSE;
3791 scsi_cmd->page = page_code | page;
3792 if (save_pages != 0)
3793 scsi_cmd->byte2 |= SLS_SP;
3795 scsi_cmd->byte2 |= SLS_PPC;
3796 scsi_ulto2b(paramptr, scsi_cmd->paramptr);
3797 scsi_ulto2b(param_len, scsi_cmd->length);
3798 cdb_len = sizeof(*scsi_cmd);
3803 /*flags*/CAM_DIR_IN,
3805 /*data_ptr*/param_buf,
3806 /*dxfer_len*/param_len,
3813 scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries,
3814 void (*cbfcnp)(struct cam_periph *, union ccb *),
3815 u_int8_t tag_action, u_int8_t page_code, int save_pages,
3816 int pc_reset, u_int8_t *param_buf, u_int32_t param_len,
3817 u_int8_t sense_len, u_int32_t timeout)
3819 struct scsi_log_select *scsi_cmd;
3822 scsi_cmd = (struct scsi_log_select *)&csio->cdb_io.cdb_bytes;
3823 bzero(scsi_cmd, sizeof(*scsi_cmd));
3824 scsi_cmd->opcode = LOG_SELECT;
3825 scsi_cmd->page = page_code & SLS_PAGE_CODE;
3826 if (save_pages != 0)
3827 scsi_cmd->byte2 |= SLS_SP;
3829 scsi_cmd->byte2 |= SLS_PCR;
3830 scsi_ulto2b(param_len, scsi_cmd->length);
3831 cdb_len = sizeof(*scsi_cmd);
3836 /*flags*/CAM_DIR_OUT,
3838 /*data_ptr*/param_buf,
3839 /*dxfer_len*/param_len,
3846 * Prevent or allow the user to remove the media
3849 scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
3850 void (*cbfcnp)(struct cam_periph *, union ccb *),
3851 u_int8_t tag_action, u_int8_t action,
3852 u_int8_t sense_len, u_int32_t timeout)
3854 struct scsi_prevent *scsi_cmd;
3859 /*flags*/CAM_DIR_NONE,
3867 scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes;
3868 bzero(scsi_cmd, sizeof(*scsi_cmd));
3869 scsi_cmd->opcode = PREVENT_ALLOW;
3870 scsi_cmd->how = action;
3873 /* XXX allow specification of address and PMI bit and LBA */
3875 scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
3876 void (*cbfcnp)(struct cam_periph *, union ccb *),
3877 u_int8_t tag_action,
3878 struct scsi_read_capacity_data *rcap_buf,
3879 u_int8_t sense_len, u_int32_t timeout)
3881 struct scsi_read_capacity *scsi_cmd;
3886 /*flags*/CAM_DIR_IN,
3888 /*data_ptr*/(u_int8_t *)rcap_buf,
3889 /*dxfer_len*/sizeof(*rcap_buf),
3894 scsi_cmd = (struct scsi_read_capacity *)&csio->cdb_io.cdb_bytes;
3895 bzero(scsi_cmd, sizeof(*scsi_cmd));
3896 scsi_cmd->opcode = READ_CAPACITY;
3900 scsi_read_capacity_16(struct ccb_scsiio *csio, uint32_t retries,
3901 void (*cbfcnp)(struct cam_periph *, union ccb *),
3902 uint8_t tag_action, uint64_t lba, int reladr, int pmi,
3903 struct scsi_read_capacity_data_long *rcap_buf,
3904 uint8_t sense_len, uint32_t timeout)
3906 struct scsi_read_capacity_16 *scsi_cmd;
3912 /*flags*/CAM_DIR_IN,
3914 /*data_ptr*/(u_int8_t *)rcap_buf,
3915 /*dxfer_len*/sizeof(*rcap_buf),
3919 scsi_cmd = (struct scsi_read_capacity_16 *)&csio->cdb_io.cdb_bytes;
3920 bzero(scsi_cmd, sizeof(*scsi_cmd));
3921 scsi_cmd->opcode = SERVICE_ACTION_IN;
3922 scsi_cmd->service_action = SRC16_SERVICE_ACTION;
3923 scsi_u64to8b(lba, scsi_cmd->addr);
3924 scsi_ulto4b(sizeof(*rcap_buf), scsi_cmd->alloc_len);
3926 reladr |= SRC16_PMI;
3928 reladr |= SRC16_RELADR;
3932 scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries,
3933 void (*cbfcnp)(struct cam_periph *, union ccb *),
3934 u_int8_t tag_action, u_int8_t select_report,
3935 struct scsi_report_luns_data *rpl_buf, u_int32_t alloc_len,
3936 u_int8_t sense_len, u_int32_t timeout)
3938 struct scsi_report_luns *scsi_cmd;
3943 /*flags*/CAM_DIR_IN,
3945 /*data_ptr*/(u_int8_t *)rpl_buf,
3946 /*dxfer_len*/alloc_len,
3950 scsi_cmd = (struct scsi_report_luns *)&csio->cdb_io.cdb_bytes;
3951 bzero(scsi_cmd, sizeof(*scsi_cmd));
3952 scsi_cmd->opcode = REPORT_LUNS;
3953 scsi_cmd->select_report = select_report;
3954 scsi_ulto4b(alloc_len, scsi_cmd->length);
3958 * Syncronize the media to the contents of the cache for
3959 * the given lba/count pair. Specifying 0/0 means sync
3963 scsi_synchronize_cache(struct ccb_scsiio *csio, u_int32_t retries,
3964 void (*cbfcnp)(struct cam_periph *, union ccb *),
3965 u_int8_t tag_action, u_int32_t begin_lba,
3966 u_int16_t lb_count, u_int8_t sense_len,
3969 struct scsi_sync_cache *scsi_cmd;
3974 /*flags*/CAM_DIR_NONE,
3982 scsi_cmd = (struct scsi_sync_cache *)&csio->cdb_io.cdb_bytes;
3983 bzero(scsi_cmd, sizeof(*scsi_cmd));
3984 scsi_cmd->opcode = SYNCHRONIZE_CACHE;
3985 scsi_ulto4b(begin_lba, scsi_cmd->begin_lba);
3986 scsi_ulto2b(lb_count, scsi_cmd->lb_count);
3990 scsi_read_write(struct ccb_scsiio *csio, u_int32_t retries,
3991 void (*cbfcnp)(struct cam_periph *, union ccb *),
3992 u_int8_t tag_action, int readop, u_int8_t byte2,
3993 int minimum_cmd_size, u_int64_t lba, u_int32_t block_count,
3994 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
3999 * Use the smallest possible command to perform the operation
4000 * as some legacy hardware does not support the 10 byte commands.
4001 * If any of the bits in byte2 is set, we have to go with a larger
4004 if ((minimum_cmd_size < 10)
4005 && ((lba & 0x1fffff) == lba)
4006 && ((block_count & 0xff) == block_count)
4009 * We can fit in a 6 byte cdb.
4011 struct scsi_rw_6 *scsi_cmd;
4013 scsi_cmd = (struct scsi_rw_6 *)&csio->cdb_io.cdb_bytes;
4014 scsi_cmd->opcode = readop ? READ_6 : WRITE_6;
4015 scsi_ulto3b(lba, scsi_cmd->addr);
4016 scsi_cmd->length = block_count & 0xff;
4017 scsi_cmd->control = 0;
4018 cdb_len = sizeof(*scsi_cmd);
4020 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4021 ("6byte: %x%x%x:%d:%d\n", scsi_cmd->addr[0],
4022 scsi_cmd->addr[1], scsi_cmd->addr[2],
4023 scsi_cmd->length, dxfer_len));
4024 } else if ((minimum_cmd_size < 12)
4025 && ((block_count & 0xffff) == block_count)
4026 && ((lba & 0xffffffff) == lba)) {
4028 * Need a 10 byte cdb.
4030 struct scsi_rw_10 *scsi_cmd;
4032 scsi_cmd = (struct scsi_rw_10 *)&csio->cdb_io.cdb_bytes;
4033 scsi_cmd->opcode = readop ? READ_10 : WRITE_10;
4034 scsi_cmd->byte2 = byte2;
4035 scsi_ulto4b(lba, scsi_cmd->addr);
4036 scsi_cmd->reserved = 0;
4037 scsi_ulto2b(block_count, scsi_cmd->length);
4038 scsi_cmd->control = 0;
4039 cdb_len = sizeof(*scsi_cmd);
4041 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4042 ("10byte: %x%x%x%x:%x%x: %d\n", scsi_cmd->addr[0],
4043 scsi_cmd->addr[1], scsi_cmd->addr[2],
4044 scsi_cmd->addr[3], scsi_cmd->length[0],
4045 scsi_cmd->length[1], dxfer_len));
4046 } else if ((minimum_cmd_size < 16)
4047 && ((block_count & 0xffffffff) == block_count)
4048 && ((lba & 0xffffffff) == lba)) {
4050 * The block count is too big for a 10 byte CDB, use a 12
4053 struct scsi_rw_12 *scsi_cmd;
4055 scsi_cmd = (struct scsi_rw_12 *)&csio->cdb_io.cdb_bytes;
4056 scsi_cmd->opcode = readop ? READ_12 : WRITE_12;
4057 scsi_cmd->byte2 = byte2;
4058 scsi_ulto4b(lba, scsi_cmd->addr);
4059 scsi_cmd->reserved = 0;
4060 scsi_ulto4b(block_count, scsi_cmd->length);
4061 scsi_cmd->control = 0;
4062 cdb_len = sizeof(*scsi_cmd);
4064 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4065 ("12byte: %x%x%x%x:%x%x%x%x: %d\n", scsi_cmd->addr[0],
4066 scsi_cmd->addr[1], scsi_cmd->addr[2],
4067 scsi_cmd->addr[3], scsi_cmd->length[0],
4068 scsi_cmd->length[1], scsi_cmd->length[2],
4069 scsi_cmd->length[3], dxfer_len));
4072 * 16 byte CDB. We'll only get here if the LBA is larger
4073 * than 2^32, or if the user asks for a 16 byte command.
4075 struct scsi_rw_16 *scsi_cmd;
4077 scsi_cmd = (struct scsi_rw_16 *)&csio->cdb_io.cdb_bytes;
4078 scsi_cmd->opcode = readop ? READ_16 : WRITE_16;
4079 scsi_cmd->byte2 = byte2;
4080 scsi_u64to8b(lba, scsi_cmd->addr);
4081 scsi_cmd->reserved = 0;
4082 scsi_ulto4b(block_count, scsi_cmd->length);
4083 scsi_cmd->control = 0;
4084 cdb_len = sizeof(*scsi_cmd);
4089 /*flags*/readop ? CAM_DIR_IN : CAM_DIR_OUT,
4099 scsi_start_stop(struct ccb_scsiio *csio, u_int32_t retries,
4100 void (*cbfcnp)(struct cam_periph *, union ccb *),
4101 u_int8_t tag_action, int start, int load_eject,
4102 int immediate, u_int8_t sense_len, u_int32_t timeout)
4104 struct scsi_start_stop_unit *scsi_cmd;
4105 int extra_flags = 0;
4107 scsi_cmd = (struct scsi_start_stop_unit *)&csio->cdb_io.cdb_bytes;
4108 bzero(scsi_cmd, sizeof(*scsi_cmd));
4109 scsi_cmd->opcode = START_STOP_UNIT;
4111 scsi_cmd->how |= SSS_START;
4112 /* it takes a lot of power to start a drive */
4113 extra_flags |= CAM_HIGH_POWER;
4115 if (load_eject != 0)
4116 scsi_cmd->how |= SSS_LOEJ;
4118 scsi_cmd->byte2 |= SSS_IMMED;
4123 /*flags*/CAM_DIR_NONE | extra_flags,
4135 * Try make as good a match as possible with
4136 * available sub drivers
4139 scsi_inquiry_match(caddr_t inqbuffer, caddr_t table_entry)
4141 struct scsi_inquiry_pattern *entry;
4142 struct scsi_inquiry_data *inq;
4144 entry = (struct scsi_inquiry_pattern *)table_entry;
4145 inq = (struct scsi_inquiry_data *)inqbuffer;
4147 if (((SID_TYPE(inq) == entry->type)
4148 || (entry->type == T_ANY))
4149 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
4150 : entry->media_type & SIP_MEDIA_FIXED)
4151 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
4152 && (cam_strmatch(inq->product, entry->product,
4153 sizeof(inq->product)) == 0)
4154 && (cam_strmatch(inq->revision, entry->revision,
4155 sizeof(inq->revision)) == 0)) {
4162 * Try make as good a match as possible with
4163 * available sub drivers
4166 scsi_static_inquiry_match(caddr_t inqbuffer, caddr_t table_entry)
4168 struct scsi_static_inquiry_pattern *entry;
4169 struct scsi_inquiry_data *inq;
4171 entry = (struct scsi_static_inquiry_pattern *)table_entry;
4172 inq = (struct scsi_inquiry_data *)inqbuffer;
4174 if (((SID_TYPE(inq) == entry->type)
4175 || (entry->type == T_ANY))
4176 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
4177 : entry->media_type & SIP_MEDIA_FIXED)
4178 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
4179 && (cam_strmatch(inq->product, entry->product,
4180 sizeof(inq->product)) == 0)
4181 && (cam_strmatch(inq->revision, entry->revision,
4182 sizeof(inq->revision)) == 0)) {
4190 init_scsi_delay(void)
4195 TUNABLE_INT_FETCH("kern.cam.scsi_delay", &delay);
4197 if (set_scsi_delay(delay) != 0) {
4198 printf("cam: invalid value for tunable kern.cam.scsi_delay\n");
4199 set_scsi_delay(SCSI_DELAY);
4202 SYSINIT(scsi_delay, SI_SUB_TUNABLES, SI_ORDER_ANY, init_scsi_delay, NULL);
4205 sysctl_scsi_delay(SYSCTL_HANDLER_ARGS)
4210 error = sysctl_handle_int(oidp, &delay, 0, req);
4211 if (error != 0 || req->newptr == NULL)
4213 return (set_scsi_delay(delay));
4215 SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay, CTLTYPE_INT|CTLFLAG_RW,
4216 0, 0, sysctl_scsi_delay, "I",
4217 "Delay to allow devices to settle after a SCSI bus reset (ms)");
4220 set_scsi_delay(int delay)
4223 * If someone sets this to 0, we assume that they want the
4224 * minimum allowable bus settle delay.
4227 printf("cam: using minimum scsi_delay (%dms)\n",
4229 delay = SCSI_MIN_DELAY;
4231 if (delay < SCSI_MIN_DELAY)
4236 #endif /* _KERNEL */