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>
65 #define ERESTART -1 /* restart syscall */
66 #define EJUSTRETURN -2 /* don't modify regs, just return */
70 * This is the default number of milliseconds we wait for devices to settle
71 * after a SCSI bus reset.
74 #define SCSI_DELAY 2000
77 * All devices need _some_ sort of bus settle delay, so we'll set it to
78 * a minimum value of 100ms. Note that this is pertinent only for SPI-
79 * not transport like Fibre Channel or iSCSI where 'delay' is completely
82 #ifndef SCSI_MIN_DELAY
83 #define SCSI_MIN_DELAY 100
86 * Make sure the user isn't using seconds instead of milliseconds.
88 #if (SCSI_DELAY < SCSI_MIN_DELAY && SCSI_DELAY != 0)
89 #error "SCSI_DELAY is in milliseconds, not seconds! Please use a larger value"
94 static int ascentrycomp(const void *key, const void *member);
95 static int senseentrycomp(const void *key, const void *member);
96 static void fetchtableentries(int sense_key, int asc, int ascq,
97 struct scsi_inquiry_data *,
98 const struct sense_key_table_entry **,
99 const struct asc_table_entry **);
101 static void init_scsi_delay(void);
102 static int sysctl_scsi_delay(SYSCTL_HANDLER_ARGS);
103 static int set_scsi_delay(int delay);
106 #if !defined(SCSI_NO_OP_STRINGS)
108 #define D (1 << T_DIRECT)
109 #define T (1 << T_SEQUENTIAL)
110 #define L (1 << T_PRINTER)
111 #define P (1 << T_PROCESSOR)
112 #define W (1 << T_WORM)
113 #define R (1 << T_CDROM)
114 #define O (1 << T_OPTICAL)
115 #define M (1 << T_CHANGER)
116 #define A (1 << T_STORARRAY)
117 #define E (1 << T_ENCLOSURE)
118 #define B (1 << T_RBC)
119 #define K (1 << T_OCRW)
120 #define V (1 << T_ADC)
121 #define F (1 << T_OSD)
122 #define S (1 << T_SCANNER)
123 #define C (1 << T_COMM)
125 #define ALL (D | T | L | P | W | R | O | M | A | E | B | K | V | F | S | C)
127 static struct op_table_entry plextor_cd_ops[] = {
128 { 0xD8, R, "CD-DA READ" }
131 static struct scsi_op_quirk_entry scsi_op_quirk_table[] = {
134 * I believe that 0xD8 is the Plextor proprietary command
135 * to read CD-DA data. I'm not sure which Plextor CDROM
136 * models support the command, though. I know for sure
137 * that the 4X, 8X, and 12X models do, and presumably the
138 * 12-20X does. I don't know about any earlier models,
139 * though. If anyone has any more complete information,
140 * feel free to change this quirk entry.
142 {T_CDROM, SIP_MEDIA_REMOVABLE, "PLEXTOR", "CD-ROM PX*", "*"},
143 sizeof(plextor_cd_ops)/sizeof(struct op_table_entry),
148 static struct op_table_entry scsi_op_codes[] = {
150 * From: http://www.t10.org/lists/op-num.txt
151 * Modifications by Kenneth Merry (ken@FreeBSD.ORG)
152 * and Jung-uk Kim (jkim@FreeBSD.org)
154 * Note: order is important in this table, scsi_op_desc() currently
155 * depends on the opcodes in the table being in order to save
157 * Note: scanner and comm. devices are carried over from the previous
158 * version because they were removed in the latest spec.
162 * SCSI Operation Codes
163 * Numeric Sorted Listing
166 * D - DIRECT ACCESS DEVICE (SBC-2) device column key
167 * .T - SEQUENTIAL ACCESS DEVICE (SSC-2) -----------------
168 * . L - PRINTER DEVICE (SSC) M = Mandatory
169 * . P - PROCESSOR DEVICE (SPC) O = Optional
170 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2) V = Vendor spec.
171 * . . R - CD/DVE DEVICE (MMC-3) Z = Obsolete
172 * . . O - OPTICAL MEMORY DEVICE (SBC-2)
173 * . . .M - MEDIA CHANGER DEVICE (SMC-2)
174 * . . . A - STORAGE ARRAY DEVICE (SCC-2)
175 * . . . .E - ENCLOSURE SERVICES DEVICE (SES)
176 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC)
177 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW)
178 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC)
179 * . . . . .F - OBJECT-BASED STORAGE (OSD)
180 * OP DTLPWROMAEBKVF Description
181 * -- -------------- ---------------------------------------------- */
182 /* 00 MMMMMMMMMMMMMM TEST UNIT READY */
183 { 0x00, ALL, "TEST UNIT READY" },
185 { 0x01, T, "REWIND" },
186 /* 01 Z V ZZZZ REZERO UNIT */
187 { 0x01, D | W | R | O | M, "REZERO UNIT" },
189 /* 03 MMMMMMMMMMOMMM REQUEST SENSE */
190 { 0x03, ALL, "REQUEST SENSE" },
191 /* 04 M OO FORMAT UNIT */
192 { 0x04, D | R | O, "FORMAT UNIT" },
193 /* 04 O FORMAT MEDIUM */
194 { 0x04, T, "FORMAT MEDIUM" },
196 { 0x04, L, "FORMAT" },
197 /* 05 VMVVVV V READ BLOCK LIMITS */
198 { 0x05, T, "READ BLOCK LIMITS" },
200 /* 07 OVV O OV REASSIGN BLOCKS */
201 { 0x07, D | W | O, "REASSIGN BLOCKS" },
202 /* 07 O INITIALIZE ELEMENT STATUS */
203 { 0x07, M, "INITIALIZE ELEMENT STATUS" },
204 /* 08 MOV O OV READ(6) */
205 { 0x08, D | T | W | O, "READ(6)" },
207 { 0x08, P, "RECEIVE" },
208 /* 08 GET MESSAGE(6) */
209 { 0x08, C, "GET MESSAGE(6)" },
211 /* 0A OO O OV WRITE(6) */
212 { 0x0A, D | T | W | O, "WRITE(6)" },
214 { 0x0A, P, "SEND(6)" },
215 /* 0A SEND MESSAGE(6) */
216 { 0x0A, C, "SEND MESSAGE(6)" },
218 { 0x0A, L, "PRINT" },
219 /* 0B Z ZOZV SEEK(6) */
220 { 0x0B, D | W | R | O, "SEEK(6)" },
221 /* 0B O SET CAPACITY */
222 { 0x0B, T, "SET CAPACITY" },
223 /* 0B O SLEW AND PRINT */
224 { 0x0B, L, "SLEW AND PRINT" },
228 /* 0F VOVVVV V READ REVERSE(6) */
229 { 0x0F, T, "READ REVERSE(6)" },
230 /* 10 VM VVV WRITE FILEMARKS(6) */
231 { 0x10, T, "WRITE FILEMARKS(6)" },
232 /* 10 O SYNCHRONIZE BUFFER */
233 { 0x10, L, "SYNCHRONIZE BUFFER" },
234 /* 11 VMVVVV SPACE(6) */
235 { 0x11, T, "SPACE(6)" },
236 /* 12 MMMMMMMMMMMMMM INQUIRY */
237 { 0x12, ALL, "INQUIRY" },
240 { 0x13, T, "VERIFY(6)" },
241 /* 14 VOOVVV RECOVER BUFFERED DATA */
242 { 0x14, T | L, "RECOVER BUFFERED DATA" },
243 /* 15 OMO O OOOO OO MODE SELECT(6) */
244 { 0x15, ALL & ~(P | R | B | F), "MODE SELECT(6)" },
245 /* 16 ZZMZO OOOZ O RESERVE(6) */
246 { 0x16, ALL & ~(R | B | V | F | C), "RESERVE(6)" },
247 /* 16 Z RESERVE ELEMENT(6) */
248 { 0x16, M, "RESERVE ELEMENT(6)" },
249 /* 17 ZZMZO OOOZ O RELEASE(6) */
250 { 0x17, ALL & ~(R | B | V | F | C), "RELEASE(6)" },
251 /* 17 Z RELEASE ELEMENT(6) */
252 { 0x17, M, "RELEASE ELEMENT(6)" },
253 /* 18 ZZZZOZO Z COPY */
254 { 0x18, D | T | L | P | W | R | O | K | S, "COPY" },
255 /* 19 VMVVVV ERASE(6) */
256 { 0x19, T, "ERASE(6)" },
257 /* 1A OMO O OOOO OO MODE SENSE(6) */
258 { 0x1A, ALL & ~(P | R | B | F), "MODE SENSE(6)" },
259 /* 1B O OOO O MO O START STOP UNIT */
260 { 0x1B, D | W | R | O | A | B | K | F, "START STOP UNIT" },
261 /* 1B O M LOAD UNLOAD */
262 { 0x1B, T | V, "LOAD UNLOAD" },
265 /* 1B O STOP PRINT */
266 { 0x1B, L, "STOP PRINT" },
267 /* 1B O OPEN/CLOSE IMPORT/EXPORT ELEMENT */
268 { 0x1B, M, "OPEN/CLOSE IMPORT/EXPORT ELEMENT" },
269 /* 1C OOOOO OOOM OOO RECEIVE DIAGNOSTIC RESULTS */
270 { 0x1C, ALL & ~(R | B), "RECEIVE DIAGNOSTIC RESULTS" },
271 /* 1D MMMMM MMOM MMM SEND DIAGNOSTIC */
272 { 0x1D, ALL & ~(R | B), "SEND DIAGNOSTIC" },
273 /* 1E OO OOOO O O PREVENT ALLOW MEDIUM REMOVAL */
274 { 0x1E, D | T | W | R | O | M | K | F, "PREVENT ALLOW MEDIUM REMOVAL" },
280 /* 23 O READ FORMAT CAPACITIES */
281 { 0x23, R, "READ FORMAT CAPACITIES" },
282 /* 24 V VV SET WINDOW */
283 { 0x24, S, "SET WINDOW" },
284 /* 25 M M M M READ CAPACITY(10) */
285 { 0x25, D | W | O | B, "READ CAPACITY(10)" },
286 /* 25 O READ CAPACITY */
287 { 0x25, R, "READ CAPACITY" },
288 /* 25 M READ CARD CAPACITY */
289 { 0x25, K, "READ CARD CAPACITY" },
291 { 0x25, S, "GET WINDOW" },
294 /* 28 M MOM MM READ(10) */
295 { 0x28, D | W | R | O | B | K | S, "READ(10)" },
296 /* 28 GET MESSAGE(10) */
297 { 0x28, C, "GET MESSAGE(10)" },
298 /* 29 V VVO READ GENERATION */
299 { 0x29, O, "READ GENERATION" },
300 /* 2A O MOM MO WRITE(10) */
301 { 0x2A, D | W | R | O | B | K, "WRITE(10)" },
303 { 0x2A, S, "SEND(10)" },
304 /* 2A SEND MESSAGE(10) */
305 { 0x2A, C, "SEND MESSAGE(10)" },
306 /* 2B Z OOO O SEEK(10) */
307 { 0x2B, D | W | R | O | K, "SEEK(10)" },
308 /* 2B O LOCATE(10) */
309 { 0x2B, T, "LOCATE(10)" },
310 /* 2B O POSITION TO ELEMENT */
311 { 0x2B, M, "POSITION TO ELEMENT" },
312 /* 2C V OO ERASE(10) */
313 { 0x2C, R | O, "ERASE(10)" },
314 /* 2D O READ UPDATED BLOCK */
315 { 0x2D, O, "READ UPDATED BLOCK" },
317 /* 2E O OOO MO WRITE AND VERIFY(10) */
318 { 0x2E, D | W | R | O | B | K, "WRITE AND VERIFY(10)" },
319 /* 2F O OOO VERIFY(10) */
320 { 0x2F, D | W | R | O, "VERIFY(10)" },
321 /* 30 Z ZZZ SEARCH DATA HIGH(10) */
322 { 0x30, D | W | R | O, "SEARCH DATA HIGH(10)" },
323 /* 31 Z ZZZ SEARCH DATA EQUAL(10) */
324 { 0x31, D | W | R | O, "SEARCH DATA EQUAL(10)" },
325 /* 31 OBJECT POSITION */
326 { 0x31, S, "OBJECT POSITION" },
327 /* 32 Z ZZZ SEARCH DATA LOW(10) */
328 { 0x32, D | W | R | O, "SEARCH DATA LOW(10)" },
329 /* 33 Z OZO SET LIMITS(10) */
330 { 0x33, D | W | R | O, "SET LIMITS(10)" },
331 /* 34 O O O O PRE-FETCH(10) */
332 { 0x34, D | W | O | K, "PRE-FETCH(10)" },
333 /* 34 M READ POSITION */
334 { 0x34, T, "READ POSITION" },
335 /* 34 GET DATA BUFFER STATUS */
336 { 0x34, S, "GET DATA BUFFER STATUS" },
337 /* 35 O OOO MO SYNCHRONIZE CACHE(10) */
338 { 0x35, D | W | R | O | B | K, "SYNCHRONIZE CACHE(10)" },
339 /* 36 Z O O O LOCK UNLOCK CACHE(10) */
340 { 0x36, D | W | O | K, "LOCK UNLOCK CACHE(10)" },
341 /* 37 O O READ DEFECT DATA(10) */
342 { 0x37, D | O, "READ DEFECT DATA(10)" },
343 /* 37 O INITIALIZE ELEMENT STATUS WITH RANGE */
344 { 0x37, M, "INITIALIZE ELEMENT STATUS WITH RANGE" },
345 /* 38 O O O MEDIUM SCAN */
346 { 0x38, W | O | K, "MEDIUM SCAN" },
347 /* 39 ZZZZOZO Z COMPARE */
348 { 0x39, D | T | L | P | W | R | O | K | S, "COMPARE" },
349 /* 3A ZZZZOZO Z COPY AND VERIFY */
350 { 0x3A, D | T | L | P | W | R | O | K | S, "COPY AND VERIFY" },
351 /* 3B OOOOOOOOOOMOOO WRITE BUFFER */
352 { 0x3B, ALL, "WRITE BUFFER" },
353 /* 3C OOOOOOOOOO OOO READ BUFFER */
354 { 0x3C, ALL & ~(B), "READ BUFFER" },
355 /* 3D O UPDATE BLOCK */
356 { 0x3D, O, "UPDATE BLOCK" },
357 /* 3E O O O READ LONG(10) */
358 { 0x3E, D | W | O, "READ LONG(10)" },
359 /* 3F O O O WRITE LONG(10) */
360 { 0x3F, D | W | O, "WRITE LONG(10)" },
361 /* 40 ZZZZOZOZ CHANGE DEFINITION */
362 { 0x40, D | T | L | P | W | R | O | M | S | C, "CHANGE DEFINITION" },
363 /* 41 O WRITE SAME(10) */
364 { 0x41, D, "WRITE SAME(10)" },
366 { 0x42, D, "UNMAP" },
367 /* 42 O READ SUB-CHANNEL */
368 { 0x42, R, "READ SUB-CHANNEL" },
369 /* 43 O READ TOC/PMA/ATIP */
370 { 0x43, R, "READ TOC/PMA/ATIP" },
371 /* 44 M M REPORT DENSITY SUPPORT */
372 { 0x44, T | V, "REPORT DENSITY SUPPORT" },
374 /* 45 O PLAY AUDIO(10) */
375 { 0x45, R, "PLAY AUDIO(10)" },
376 /* 46 M GET CONFIGURATION */
377 { 0x46, R, "GET CONFIGURATION" },
378 /* 47 O PLAY AUDIO MSF */
379 { 0x47, R, "PLAY AUDIO MSF" },
382 /* 4A M GET EVENT STATUS NOTIFICATION */
383 { 0x4A, R, "GET EVENT STATUS NOTIFICATION" },
384 /* 4B O PAUSE/RESUME */
385 { 0x4B, R, "PAUSE/RESUME" },
386 /* 4C OOOOO OOOO OOO LOG SELECT */
387 { 0x4C, ALL & ~(R | B), "LOG SELECT" },
388 /* 4D OOOOO OOOO OMO LOG SENSE */
389 { 0x4D, ALL & ~(R | B), "LOG SENSE" },
390 /* 4E O STOP PLAY/SCAN */
391 { 0x4E, R, "STOP PLAY/SCAN" },
393 /* 50 O XDWRITE(10) */
394 { 0x50, D, "XDWRITE(10)" },
395 /* 51 O XPWRITE(10) */
396 { 0x51, D, "XPWRITE(10)" },
397 /* 51 O READ DISC INFORMATION */
398 { 0x51, R, "READ DISC INFORMATION" },
399 /* 52 O XDREAD(10) */
400 { 0x52, D, "XDREAD(10)" },
401 /* 52 O READ TRACK INFORMATION */
402 { 0x52, R, "READ TRACK INFORMATION" },
403 /* 53 O RESERVE TRACK */
404 { 0x53, R, "RESERVE TRACK" },
405 /* 54 O SEND OPC INFORMATION */
406 { 0x54, R, "SEND OPC INFORMATION" },
407 /* 55 OOO OMOOOOMOMO MODE SELECT(10) */
408 { 0x55, ALL & ~(P), "MODE SELECT(10)" },
409 /* 56 ZZMZO OOOZ RESERVE(10) */
410 { 0x56, ALL & ~(R | B | K | V | F | C), "RESERVE(10)" },
411 /* 56 Z RESERVE ELEMENT(10) */
412 { 0x56, M, "RESERVE ELEMENT(10)" },
413 /* 57 ZZMZO OOOZ RELEASE(10) */
414 { 0x57, ALL & ~(R | B | K | V | F | C), "RELEASE(10)" },
415 /* 57 Z RELEASE ELEMENT(10) */
416 { 0x57, M, "RELEASE ELEMENT(10)" },
417 /* 58 O REPAIR TRACK */
418 { 0x58, R, "REPAIR TRACK" },
420 /* 5A OOO OMOOOOMOMO MODE SENSE(10) */
421 { 0x5A, ALL & ~(P), "MODE SENSE(10)" },
422 /* 5B O CLOSE TRACK/SESSION */
423 { 0x5B, R, "CLOSE TRACK/SESSION" },
424 /* 5C O READ BUFFER CAPACITY */
425 { 0x5C, R, "READ BUFFER CAPACITY" },
426 /* 5D O SEND CUE SHEET */
427 { 0x5D, R, "SEND CUE SHEET" },
428 /* 5E OOOOO OOOO M PERSISTENT RESERVE IN */
429 { 0x5E, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE IN" },
430 /* 5F OOOOO OOOO M PERSISTENT RESERVE OUT */
431 { 0x5F, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE OUT" },
432 /* 7E OO O OOOO O extended CDB */
433 { 0x7E, D | T | R | M | A | E | B | V, "extended CDB" },
434 /* 7F O M variable length CDB (more than 16 bytes) */
435 { 0x7F, D | F, "variable length CDB (more than 16 bytes)" },
436 /* 80 Z XDWRITE EXTENDED(16) */
437 { 0x80, D, "XDWRITE EXTENDED(16)" },
438 /* 80 M WRITE FILEMARKS(16) */
439 { 0x80, T, "WRITE FILEMARKS(16)" },
440 /* 81 Z REBUILD(16) */
441 { 0x81, D, "REBUILD(16)" },
442 /* 81 O READ REVERSE(16) */
443 { 0x81, T, "READ REVERSE(16)" },
444 /* 82 Z REGENERATE(16) */
445 { 0x82, D, "REGENERATE(16)" },
446 /* 83 OOOOO O OO EXTENDED COPY */
447 { 0x83, D | T | L | P | W | O | K | V, "EXTENDED COPY" },
448 /* 84 OOOOO O OO RECEIVE COPY RESULTS */
449 { 0x84, D | T | L | P | W | O | K | V, "RECEIVE COPY RESULTS" },
450 /* 85 O O O ATA COMMAND PASS THROUGH(16) */
451 { 0x85, D | R | B, "ATA COMMAND PASS THROUGH(16)" },
452 /* 86 OO OO OOOOOOO ACCESS CONTROL IN */
453 { 0x86, ALL & ~(L | R | F), "ACCESS CONTROL IN" },
454 /* 87 OO OO OOOOOOO ACCESS CONTROL OUT */
455 { 0x87, ALL & ~(L | R | F), "ACCESS CONTROL OUT" },
457 * XXX READ(16)/WRITE(16) were not listed for CD/DVE in op-num.txt
458 * but we had it since r1.40. Do we really want them?
460 /* 88 MM O O O READ(16) */
461 { 0x88, D | T | W | O | B, "READ(16)" },
463 /* 8A OM O O O WRITE(16) */
464 { 0x8A, D | T | W | O | B, "WRITE(16)" },
466 { 0x8B, D, "ORWRITE" },
467 /* 8C OO O OO O M READ ATTRIBUTE */
468 { 0x8C, D | T | W | O | M | B | V, "READ ATTRIBUTE" },
469 /* 8D OO O OO O O WRITE ATTRIBUTE */
470 { 0x8D, D | T | W | O | M | B | V, "WRITE ATTRIBUTE" },
471 /* 8E O O O O WRITE AND VERIFY(16) */
472 { 0x8E, D | W | O | B, "WRITE AND VERIFY(16)" },
473 /* 8F OO O O O VERIFY(16) */
474 { 0x8F, D | T | W | O | B, "VERIFY(16)" },
475 /* 90 O O O O PRE-FETCH(16) */
476 { 0x90, D | W | O | B, "PRE-FETCH(16)" },
477 /* 91 O O O O SYNCHRONIZE CACHE(16) */
478 { 0x91, D | W | O | B, "SYNCHRONIZE CACHE(16)" },
480 { 0x91, T, "SPACE(16)" },
481 /* 92 Z O O LOCK UNLOCK CACHE(16) */
482 { 0x92, D | W | O, "LOCK UNLOCK CACHE(16)" },
483 /* 92 O LOCATE(16) */
484 { 0x92, T, "LOCATE(16)" },
485 /* 93 O WRITE SAME(16) */
486 { 0x93, D, "WRITE SAME(16)" },
488 { 0x93, T, "ERASE(16)" },
489 /* 94 [usage proposed by SCSI Socket Services project] */
490 /* 95 [usage proposed by SCSI Socket Services project] */
491 /* 96 [usage proposed by SCSI Socket Services project] */
492 /* 97 [usage proposed by SCSI Socket Services project] */
499 /* XXX KDM ALL for this? op-num.txt defines it for none.. */
500 /* 9E SERVICE ACTION IN(16) */
501 { 0x9E, ALL, "SERVICE ACTION IN(16)" },
502 /* XXX KDM ALL for this? op-num.txt defines it for ADC.. */
503 /* 9F M SERVICE ACTION OUT(16) */
504 { 0x9F, ALL, "SERVICE ACTION OUT(16)" },
505 /* A0 MMOOO OMMM OMO REPORT LUNS */
506 { 0xA0, ALL & ~(R | B), "REPORT LUNS" },
508 { 0xA1, R, "BLANK" },
509 /* A1 O O ATA COMMAND PASS THROUGH(12) */
510 { 0xA1, D | B, "ATA COMMAND PASS THROUGH(12)" },
511 /* A2 OO O O SECURITY PROTOCOL IN */
512 { 0xA2, D | T | R | V, "SECURITY PROTOCOL IN" },
513 /* A3 OOO O OOMOOOM MAINTENANCE (IN) */
514 { 0xA3, ALL & ~(P | R | F), "MAINTENANCE (IN)" },
516 { 0xA3, R, "SEND KEY" },
517 /* A4 OOO O OOOOOOO MAINTENANCE (OUT) */
518 { 0xA4, ALL & ~(P | R | F), "MAINTENANCE (OUT)" },
519 /* A4 O REPORT KEY */
520 { 0xA4, R, "REPORT KEY" },
521 /* A5 O O OM MOVE MEDIUM */
522 { 0xA5, T | W | O | M, "MOVE MEDIUM" },
523 /* A5 O PLAY AUDIO(12) */
524 { 0xA5, R, "PLAY AUDIO(12)" },
525 /* A6 O EXCHANGE MEDIUM */
526 { 0xA6, M, "EXCHANGE MEDIUM" },
527 /* A6 O LOAD/UNLOAD C/DVD */
528 { 0xA6, R, "LOAD/UNLOAD C/DVD" },
529 /* A7 ZZ O O MOVE MEDIUM ATTACHED */
530 { 0xA7, D | T | W | O, "MOVE MEDIUM ATTACHED" },
531 /* A7 O SET READ AHEAD */
532 { 0xA7, R, "SET READ AHEAD" },
533 /* A8 O OOO READ(12) */
534 { 0xA8, D | W | R | O, "READ(12)" },
535 /* A8 GET MESSAGE(12) */
536 { 0xA8, C, "GET MESSAGE(12)" },
537 /* A9 O SERVICE ACTION OUT(12) */
538 { 0xA9, V, "SERVICE ACTION OUT(12)" },
539 /* AA O OOO WRITE(12) */
540 { 0xAA, D | W | R | O, "WRITE(12)" },
541 /* AA SEND MESSAGE(12) */
542 { 0xAA, C, "SEND MESSAGE(12)" },
543 /* AB O O SERVICE ACTION IN(12) */
544 { 0xAB, R | V, "SERVICE ACTION IN(12)" },
546 { 0xAC, O, "ERASE(12)" },
547 /* AC O GET PERFORMANCE */
548 { 0xAC, R, "GET PERFORMANCE" },
549 /* AD O READ DVD STRUCTURE */
550 { 0xAD, R, "READ DVD STRUCTURE" },
551 /* AE O O O WRITE AND VERIFY(12) */
552 { 0xAE, D | W | O, "WRITE AND VERIFY(12)" },
553 /* AF O OZO VERIFY(12) */
554 { 0xAF, D | W | R | O, "VERIFY(12)" },
555 /* B0 ZZZ SEARCH DATA HIGH(12) */
556 { 0xB0, W | R | O, "SEARCH DATA HIGH(12)" },
557 /* B1 ZZZ SEARCH DATA EQUAL(12) */
558 { 0xB1, W | R | O, "SEARCH DATA EQUAL(12)" },
559 /* B2 ZZZ SEARCH DATA LOW(12) */
560 { 0xB2, W | R | O, "SEARCH DATA LOW(12)" },
561 /* B3 Z OZO SET LIMITS(12) */
562 { 0xB3, D | W | R | O, "SET LIMITS(12)" },
563 /* B4 ZZ OZO READ ELEMENT STATUS ATTACHED */
564 { 0xB4, D | T | W | R | O, "READ ELEMENT STATUS ATTACHED" },
565 /* B5 OO O O SECURITY PROTOCOL OUT */
566 { 0xB5, D | T | R | V, "SECURITY PROTOCOL OUT" },
567 /* B5 O REQUEST VOLUME ELEMENT ADDRESS */
568 { 0xB5, M, "REQUEST VOLUME ELEMENT ADDRESS" },
569 /* B6 O SEND VOLUME TAG */
570 { 0xB6, M, "SEND VOLUME TAG" },
571 /* B6 O SET STREAMING */
572 { 0xB6, R, "SET STREAMING" },
573 /* B7 O O READ DEFECT DATA(12) */
574 { 0xB7, D | O, "READ DEFECT DATA(12)" },
575 /* B8 O OZOM READ ELEMENT STATUS */
576 { 0xB8, T | W | R | O | M, "READ ELEMENT STATUS" },
577 /* B9 O READ CD MSF */
578 { 0xB9, R, "READ CD MSF" },
579 /* BA O O OOMO REDUNDANCY GROUP (IN) */
580 { 0xBA, D | W | O | M | A | E, "REDUNDANCY GROUP (IN)" },
583 /* BB O O OOOO REDUNDANCY GROUP (OUT) */
584 { 0xBB, D | W | O | M | A | E, "REDUNDANCY GROUP (OUT)" },
585 /* BB O SET CD SPEED */
586 { 0xBB, R, "SET CD SPEED" },
587 /* BC O O OOMO SPARE (IN) */
588 { 0xBC, D | W | O | M | A | E, "SPARE (IN)" },
589 /* BD O O OOOO SPARE (OUT) */
590 { 0xBD, D | W | O | M | A | E, "SPARE (OUT)" },
591 /* BD O MECHANISM STATUS */
592 { 0xBD, R, "MECHANISM STATUS" },
593 /* BE O O OOMO VOLUME SET (IN) */
594 { 0xBE, D | W | O | M | A | E, "VOLUME SET (IN)" },
596 { 0xBE, R, "READ CD" },
597 /* BF O O OOOO VOLUME SET (OUT) */
598 { 0xBF, D | W | O | M | A | E, "VOLUME SET (OUT)" },
599 /* BF O SEND DVD STRUCTURE */
600 { 0xBF, R, "SEND DVD STRUCTURE" }
604 scsi_op_desc(u_int16_t opcode, struct scsi_inquiry_data *inq_data)
611 struct op_table_entry *table[2];
614 pd_type = SID_TYPE(inq_data);
616 match = cam_quirkmatch((caddr_t)inq_data,
617 (caddr_t)scsi_op_quirk_table,
618 sizeof(scsi_op_quirk_table)/
619 sizeof(*scsi_op_quirk_table),
620 sizeof(*scsi_op_quirk_table),
624 table[0] = ((struct scsi_op_quirk_entry *)match)->op_table;
625 num_ops[0] = ((struct scsi_op_quirk_entry *)match)->num_ops;
626 table[1] = scsi_op_codes;
627 num_ops[1] = sizeof(scsi_op_codes)/sizeof(scsi_op_codes[0]);
631 * If this is true, we have a vendor specific opcode that
632 * wasn't covered in the quirk table.
634 if ((opcode > 0xBF) || ((opcode > 0x5F) && (opcode < 0x80)))
635 return("Vendor Specific Command");
637 table[0] = scsi_op_codes;
638 num_ops[0] = sizeof(scsi_op_codes)/sizeof(scsi_op_codes[0]);
642 /* RBC is 'Simplified' Direct Access Device */
643 if (pd_type == T_RBC)
646 opmask = 1 << pd_type;
648 for (j = 0; j < num_tables; j++) {
649 for (i = 0;i < num_ops[j] && table[j][i].opcode <= opcode; i++){
650 if ((table[j][i].opcode == opcode)
651 && ((table[j][i].opmask & opmask) != 0))
652 return(table[j][i].desc);
657 * If we can't find a match for the command in the table, we just
658 * assume it's a vendor specifc command.
660 return("Vendor Specific Command");
664 #else /* SCSI_NO_OP_STRINGS */
667 scsi_op_desc(u_int16_t opcode, struct scsi_inquiry_data *inq_data)
675 #if !defined(SCSI_NO_SENSE_STRINGS)
676 #define SST(asc, ascq, action, desc) \
677 asc, ascq, action, desc
679 const char empty_string[] = "";
681 #define SST(asc, ascq, action, desc) \
682 asc, ascq, action, empty_string
685 const struct sense_key_table_entry sense_key_table[] =
687 { SSD_KEY_NO_SENSE, SS_NOP, "NO SENSE" },
688 { SSD_KEY_RECOVERED_ERROR, SS_NOP|SSQ_PRINT_SENSE, "RECOVERED ERROR" },
689 { SSD_KEY_NOT_READY, SS_RDEF, "NOT READY" },
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(0x00, 0x1F, SS_RDEF, /* XXX TBD */
844 "Logical unit transitioning to another power condition") },
846 { SST(0x00, 0x20, SS_RDEF, /* XXX TBD */
847 "Extended copy information available") },
849 { SST(0x01, 0x00, SS_RDEF,
850 "No index/sector signal") },
852 { SST(0x02, 0x00, SS_RDEF,
853 "No seek complete") },
855 { SST(0x03, 0x00, SS_RDEF,
856 "Peripheral device write fault") },
858 { SST(0x03, 0x01, SS_RDEF,
859 "No write current") },
861 { SST(0x03, 0x02, SS_RDEF,
862 "Excessive write errors") },
864 { SST(0x04, 0x00, SS_RDEF,
865 "Logical unit not ready, cause not reportable") },
867 { SST(0x04, 0x01, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EBUSY,
868 "Logical unit is in process of becoming ready") },
870 { SST(0x04, 0x02, SS_START | SSQ_DECREMENT_COUNT | ENXIO,
871 "Logical unit not ready, initializing command required") },
873 { SST(0x04, 0x03, SS_FATAL | ENXIO,
874 "Logical unit not ready, manual intervention required") },
876 { SST(0x04, 0x04, SS_FATAL | EBUSY,
877 "Logical unit not ready, format in progress") },
879 { SST(0x04, 0x05, SS_FATAL | EBUSY,
880 "Logical unit not ready, rebuild in progress") },
882 { SST(0x04, 0x06, SS_FATAL | EBUSY,
883 "Logical unit not ready, recalculation in progress") },
885 { SST(0x04, 0x07, SS_FATAL | EBUSY,
886 "Logical unit not ready, operation in progress") },
888 { SST(0x04, 0x08, SS_FATAL | EBUSY,
889 "Logical unit not ready, long write in progress") },
891 { SST(0x04, 0x09, SS_RDEF, /* XXX TBD */
892 "Logical unit not ready, self-test in progress") },
894 { SST(0x04, 0x0A, SS_RDEF, /* XXX TBD */
895 "Logical unit not accessible, asymmetric access state transition")},
897 { SST(0x04, 0x0B, SS_RDEF, /* XXX TBD */
898 "Logical unit not accessible, target port in standby state") },
900 { SST(0x04, 0x0C, SS_RDEF, /* XXX TBD */
901 "Logical unit not accessible, target port in unavailable state") },
903 { SST(0x04, 0x0D, SS_RDEF, /* XXX TBD */
904 "Logical unit not ready, structure check required") },
906 { SST(0x04, 0x10, SS_RDEF, /* XXX TBD */
907 "Logical unit not ready, auxiliary memory not accessible") },
909 { SST(0x04, 0x11, SS_RDEF, /* XXX TBD */
910 "Logical unit not ready, notify (enable spinup) required") },
912 { SST(0x04, 0x12, SS_RDEF, /* XXX TBD */
913 "Logical unit not ready, offline") },
915 { SST(0x04, 0x13, SS_RDEF, /* XXX TBD */
916 "Logical unit not ready, SA creation in progress") },
918 { SST(0x04, 0x14, SS_RDEF, /* XXX TBD */
919 "Logical unit not ready, space allocation in progress") },
921 { SST(0x04, 0x15, SS_RDEF, /* XXX TBD */
922 "Logical unit not ready, robotics disabled") },
924 { SST(0x04, 0x16, SS_RDEF, /* XXX TBD */
925 "Logical unit not ready, configuration required") },
927 { SST(0x04, 0x17, SS_RDEF, /* XXX TBD */
928 "Logical unit not ready, calibration required") },
930 { SST(0x04, 0x18, SS_RDEF, /* XXX TBD */
931 "Logical unit not ready, a door is open") },
933 { SST(0x04, 0x19, SS_RDEF, /* XXX TBD */
934 "Logical unit not ready, operating in sequential mode") },
936 { SST(0x04, 0x1A, SS_RDEF, /* XXX TBD */
937 "Logical unit not ready, START/STOP UNIT command in progress") },
939 { SST(0x04, 0x1B, SS_RDEF, /* XXX TBD */
940 "Logical unit not ready, sanitize in progress") },
942 { SST(0x04, 0x1C, SS_RDEF, /* XXX TBD */
943 "Logical unit not ready, additional power use not yet granted") },
945 { SST(0x05, 0x00, SS_RDEF,
946 "Logical unit does not respond to selection") },
948 { SST(0x06, 0x00, SS_RDEF,
949 "No reference position found") },
951 { SST(0x07, 0x00, SS_RDEF,
952 "Multiple peripheral devices selected") },
954 { SST(0x08, 0x00, SS_RDEF,
955 "Logical unit communication failure") },
957 { SST(0x08, 0x01, SS_RDEF,
958 "Logical unit communication time-out") },
960 { SST(0x08, 0x02, SS_RDEF,
961 "Logical unit communication parity error") },
963 { SST(0x08, 0x03, SS_RDEF,
964 "Logical unit communication CRC error (Ultra-DMA/32)") },
966 { SST(0x08, 0x04, SS_RDEF, /* XXX TBD */
967 "Unreachable copy target") },
969 { SST(0x09, 0x00, SS_RDEF,
970 "Track following error") },
972 { SST(0x09, 0x01, SS_RDEF,
973 "Tracking servo failure") },
975 { SST(0x09, 0x02, SS_RDEF,
976 "Focus servo failure") },
978 { SST(0x09, 0x03, SS_RDEF,
979 "Spindle servo failure") },
981 { SST(0x09, 0x04, SS_RDEF,
982 "Head select fault") },
984 { SST(0x0A, 0x00, SS_FATAL | ENOSPC,
985 "Error log overflow") },
987 { SST(0x0B, 0x00, SS_RDEF,
990 { SST(0x0B, 0x01, SS_RDEF,
991 "Warning - specified temperature exceeded") },
993 { SST(0x0B, 0x02, SS_RDEF,
994 "Warning - enclosure degraded") },
996 { SST(0x0B, 0x03, SS_RDEF, /* XXX TBD */
997 "Warning - background self-test failed") },
999 { SST(0x0B, 0x04, SS_RDEF, /* XXX TBD */
1000 "Warning - background pre-scan detected medium error") },
1001 /* DTLPWRO AEBKVF */
1002 { SST(0x0B, 0x05, SS_RDEF, /* XXX TBD */
1003 "Warning - background medium scan detected medium error") },
1004 /* DTLPWROMAEBKVF */
1005 { SST(0x0B, 0x06, SS_RDEF, /* XXX TBD */
1006 "Warning - non-volatile cache now volatile") },
1007 /* DTLPWROMAEBKVF */
1008 { SST(0x0B, 0x07, SS_RDEF, /* XXX TBD */
1009 "Warning - degraded power to non-volatile cache") },
1010 /* DTLPWROMAEBKVF */
1011 { SST(0x0B, 0x08, SS_RDEF, /* XXX TBD */
1012 "Warning - power loss expected") },
1014 { SST(0x0B, 0x09, SS_RDEF, /* XXX TBD */
1015 "Warning - device statistics notification available") },
1017 { SST(0x0C, 0x00, SS_RDEF,
1020 { SST(0x0C, 0x01, SS_NOP | SSQ_PRINT_SENSE,
1021 "Write error - recovered with auto reallocation") },
1023 { SST(0x0C, 0x02, SS_RDEF,
1024 "Write error - auto reallocation failed") },
1026 { SST(0x0C, 0x03, SS_RDEF,
1027 "Write error - recommend reassignment") },
1029 { SST(0x0C, 0x04, SS_RDEF,
1030 "Compression check miscompare error") },
1032 { SST(0x0C, 0x05, SS_RDEF,
1033 "Data expansion occurred during compression") },
1035 { SST(0x0C, 0x06, SS_RDEF,
1036 "Block not compressible") },
1038 { SST(0x0C, 0x07, SS_RDEF,
1039 "Write error - recovery needed") },
1041 { SST(0x0C, 0x08, SS_RDEF,
1042 "Write error - recovery failed") },
1044 { SST(0x0C, 0x09, SS_RDEF,
1045 "Write error - loss of streaming") },
1047 { SST(0x0C, 0x0A, SS_RDEF,
1048 "Write error - padding blocks added") },
1050 { SST(0x0C, 0x0B, SS_RDEF, /* XXX TBD */
1051 "Auxiliary memory write error") },
1052 /* DTLPWRO AEBKVF */
1053 { SST(0x0C, 0x0C, SS_RDEF, /* XXX TBD */
1054 "Write error - unexpected unsolicited data") },
1055 /* DTLPWRO AEBKVF */
1056 { SST(0x0C, 0x0D, SS_RDEF, /* XXX TBD */
1057 "Write error - not enough unsolicited data") },
1059 { SST(0x0C, 0x0E, SS_RDEF, /* XXX TBD */
1060 "Multiple write errors") },
1062 { SST(0x0C, 0x0F, SS_RDEF, /* XXX TBD */
1063 "Defects in error window") },
1065 { SST(0x0D, 0x00, SS_RDEF, /* XXX TBD */
1066 "Error detected by third party temporary initiator") },
1068 { SST(0x0D, 0x01, SS_RDEF, /* XXX TBD */
1069 "Third party device failure") },
1071 { SST(0x0D, 0x02, SS_RDEF, /* XXX TBD */
1072 "Copy target device not reachable") },
1074 { SST(0x0D, 0x03, SS_RDEF, /* XXX TBD */
1075 "Incorrect copy target device type") },
1077 { SST(0x0D, 0x04, SS_RDEF, /* XXX TBD */
1078 "Copy target device data underrun") },
1080 { SST(0x0D, 0x05, SS_RDEF, /* XXX TBD */
1081 "Copy target device data overrun") },
1082 /* DT PWROMAEBK F */
1083 { SST(0x0E, 0x00, SS_RDEF, /* XXX TBD */
1084 "Invalid information unit") },
1085 /* DT PWROMAEBK F */
1086 { SST(0x0E, 0x01, SS_RDEF, /* XXX TBD */
1087 "Information unit too short") },
1088 /* DT PWROMAEBK F */
1089 { SST(0x0E, 0x02, SS_RDEF, /* XXX TBD */
1090 "Information unit too long") },
1091 /* DT P R MAEBK F */
1092 { SST(0x0E, 0x03, SS_RDEF, /* XXX TBD */
1093 "Invalid field in command information unit") },
1095 { SST(0x10, 0x00, SS_RDEF,
1096 "ID CRC or ECC error") },
1098 { SST(0x10, 0x01, SS_RDEF, /* XXX TBD */
1099 "Logical block guard check failed") },
1101 { SST(0x10, 0x02, SS_RDEF, /* XXX TBD */
1102 "Logical block application tag check failed") },
1104 { SST(0x10, 0x03, SS_RDEF, /* XXX TBD */
1105 "Logical block reference tag check failed") },
1107 { SST(0x10, 0x04, SS_RDEF, /* XXX TBD */
1108 "Logical block protection error on recovered buffer data") },
1110 { SST(0x10, 0x05, SS_RDEF, /* XXX TBD */
1111 "Logical block protection method error") },
1113 { SST(0x11, 0x00, SS_RDEF,
1114 "Unrecovered read error") },
1116 { SST(0x11, 0x01, SS_RDEF,
1117 "Read retries exhausted") },
1119 { SST(0x11, 0x02, SS_RDEF,
1120 "Error too long to correct") },
1122 { SST(0x11, 0x03, SS_RDEF,
1123 "Multiple read errors") },
1125 { SST(0x11, 0x04, SS_RDEF,
1126 "Unrecovered read error - auto reallocate failed") },
1128 { SST(0x11, 0x05, SS_RDEF,
1129 "L-EC uncorrectable error") },
1131 { SST(0x11, 0x06, SS_RDEF,
1132 "CIRC unrecovered error") },
1134 { SST(0x11, 0x07, SS_RDEF,
1135 "Data re-synchronization error") },
1137 { SST(0x11, 0x08, SS_RDEF,
1138 "Incomplete block read") },
1140 { SST(0x11, 0x09, SS_RDEF,
1143 { SST(0x11, 0x0A, SS_RDEF,
1144 "Miscorrected error") },
1146 { SST(0x11, 0x0B, SS_RDEF,
1147 "Unrecovered read error - recommend reassignment") },
1149 { SST(0x11, 0x0C, SS_RDEF,
1150 "Unrecovered read error - recommend rewrite the data") },
1152 { SST(0x11, 0x0D, SS_RDEF,
1153 "De-compression CRC error") },
1155 { SST(0x11, 0x0E, SS_RDEF,
1156 "Cannot decompress using declared algorithm") },
1158 { SST(0x11, 0x0F, SS_RDEF,
1159 "Error reading UPC/EAN number") },
1161 { SST(0x11, 0x10, SS_RDEF,
1162 "Error reading ISRC number") },
1164 { SST(0x11, 0x11, SS_RDEF,
1165 "Read error - loss of streaming") },
1167 { SST(0x11, 0x12, SS_RDEF, /* XXX TBD */
1168 "Auxiliary memory read error") },
1169 /* DTLPWRO AEBKVF */
1170 { SST(0x11, 0x13, SS_RDEF, /* XXX TBD */
1171 "Read error - failed retransmission request") },
1173 { SST(0x11, 0x14, SS_RDEF, /* XXX TBD */
1174 "Read error - LBA marked bad by application client") },
1176 { SST(0x12, 0x00, SS_RDEF,
1177 "Address mark not found for ID field") },
1179 { SST(0x13, 0x00, SS_RDEF,
1180 "Address mark not found for data field") },
1182 { SST(0x14, 0x00, SS_RDEF,
1183 "Recorded entity not found") },
1185 { SST(0x14, 0x01, SS_RDEF,
1186 "Record not found") },
1188 { SST(0x14, 0x02, SS_RDEF,
1189 "Filemark or setmark not found") },
1191 { SST(0x14, 0x03, SS_RDEF,
1192 "End-of-data not found") },
1194 { SST(0x14, 0x04, SS_RDEF,
1195 "Block sequence error") },
1197 { SST(0x14, 0x05, SS_RDEF,
1198 "Record not found - recommend reassignment") },
1200 { SST(0x14, 0x06, SS_RDEF,
1201 "Record not found - data auto-reallocated") },
1203 { SST(0x14, 0x07, SS_RDEF, /* XXX TBD */
1204 "Locate operation failure") },
1206 { SST(0x15, 0x00, SS_RDEF,
1207 "Random positioning error") },
1209 { SST(0x15, 0x01, SS_RDEF,
1210 "Mechanical positioning error") },
1212 { SST(0x15, 0x02, SS_RDEF,
1213 "Positioning error detected by read of medium") },
1215 { SST(0x16, 0x00, SS_RDEF,
1216 "Data synchronization mark error") },
1218 { SST(0x16, 0x01, SS_RDEF,
1219 "Data sync error - data rewritten") },
1221 { SST(0x16, 0x02, SS_RDEF,
1222 "Data sync error - recommend rewrite") },
1224 { SST(0x16, 0x03, SS_NOP | SSQ_PRINT_SENSE,
1225 "Data sync error - data auto-reallocated") },
1227 { SST(0x16, 0x04, SS_RDEF,
1228 "Data sync error - recommend reassignment") },
1230 { SST(0x17, 0x00, SS_NOP | SSQ_PRINT_SENSE,
1231 "Recovered data with no error correction applied") },
1233 { SST(0x17, 0x01, SS_NOP | SSQ_PRINT_SENSE,
1234 "Recovered data with retries") },
1236 { SST(0x17, 0x02, SS_NOP | SSQ_PRINT_SENSE,
1237 "Recovered data with positive head offset") },
1239 { SST(0x17, 0x03, SS_NOP | SSQ_PRINT_SENSE,
1240 "Recovered data with negative head offset") },
1242 { SST(0x17, 0x04, SS_NOP | SSQ_PRINT_SENSE,
1243 "Recovered data with retries and/or CIRC applied") },
1245 { SST(0x17, 0x05, SS_NOP | SSQ_PRINT_SENSE,
1246 "Recovered data using previous sector ID") },
1248 { SST(0x17, 0x06, SS_NOP | SSQ_PRINT_SENSE,
1249 "Recovered data without ECC - data auto-reallocated") },
1251 { SST(0x17, 0x07, SS_NOP | SSQ_PRINT_SENSE,
1252 "Recovered data without ECC - recommend reassignment") },
1254 { SST(0x17, 0x08, SS_NOP | SSQ_PRINT_SENSE,
1255 "Recovered data without ECC - recommend rewrite") },
1257 { SST(0x17, 0x09, SS_NOP | SSQ_PRINT_SENSE,
1258 "Recovered data without ECC - data rewritten") },
1260 { SST(0x18, 0x00, SS_NOP | SSQ_PRINT_SENSE,
1261 "Recovered data with error correction applied") },
1263 { SST(0x18, 0x01, SS_NOP | SSQ_PRINT_SENSE,
1264 "Recovered data with error corr. & retries applied") },
1266 { SST(0x18, 0x02, SS_NOP | SSQ_PRINT_SENSE,
1267 "Recovered data - data auto-reallocated") },
1269 { SST(0x18, 0x03, SS_NOP | SSQ_PRINT_SENSE,
1270 "Recovered data with CIRC") },
1272 { SST(0x18, 0x04, SS_NOP | SSQ_PRINT_SENSE,
1273 "Recovered data with L-EC") },
1275 { SST(0x18, 0x05, SS_NOP | SSQ_PRINT_SENSE,
1276 "Recovered data - recommend reassignment") },
1278 { SST(0x18, 0x06, SS_NOP | SSQ_PRINT_SENSE,
1279 "Recovered data - recommend rewrite") },
1281 { SST(0x18, 0x07, SS_NOP | SSQ_PRINT_SENSE,
1282 "Recovered data with ECC - data rewritten") },
1284 { SST(0x18, 0x08, SS_RDEF, /* XXX TBD */
1285 "Recovered data with linking") },
1287 { SST(0x19, 0x00, SS_RDEF,
1288 "Defect list error") },
1290 { SST(0x19, 0x01, SS_RDEF,
1291 "Defect list not available") },
1293 { SST(0x19, 0x02, SS_RDEF,
1294 "Defect list error in primary list") },
1296 { SST(0x19, 0x03, SS_RDEF,
1297 "Defect list error in grown list") },
1298 /* DTLPWROMAEBKVF */
1299 { SST(0x1A, 0x00, SS_RDEF,
1300 "Parameter list length error") },
1301 /* DTLPWROMAEBKVF */
1302 { SST(0x1B, 0x00, SS_RDEF,
1303 "Synchronous data transfer error") },
1305 { SST(0x1C, 0x00, SS_RDEF,
1306 "Defect list not found") },
1308 { SST(0x1C, 0x01, SS_RDEF,
1309 "Primary defect list not found") },
1311 { SST(0x1C, 0x02, SS_RDEF,
1312 "Grown defect list not found") },
1314 { SST(0x1D, 0x00, SS_FATAL,
1315 "Miscompare during verify operation") },
1317 { SST(0x1D, 0x01, SS_RDEF, /* XXX TBD */
1318 "Miscomparable verify of unmapped LBA") },
1320 { SST(0x1E, 0x00, SS_NOP | SSQ_PRINT_SENSE,
1321 "Recovered ID with ECC correction") },
1323 { SST(0x1F, 0x00, SS_RDEF,
1324 "Partial defect list transfer") },
1325 /* DTLPWROMAEBKVF */
1326 { SST(0x20, 0x00, SS_FATAL | EINVAL,
1327 "Invalid command operation code") },
1329 { SST(0x20, 0x01, SS_RDEF, /* XXX TBD */
1330 "Access denied - initiator pending-enrolled") },
1332 { SST(0x20, 0x02, SS_RDEF, /* XXX TBD */
1333 "Access denied - no access rights") },
1335 { SST(0x20, 0x03, SS_RDEF, /* XXX TBD */
1336 "Access denied - invalid mgmt ID key") },
1338 { SST(0x20, 0x04, SS_RDEF, /* XXX TBD */
1339 "Illegal command while in write capable state") },
1341 { SST(0x20, 0x05, SS_RDEF, /* XXX TBD */
1344 { SST(0x20, 0x06, SS_RDEF, /* XXX TBD */
1345 "Illegal command while in explicit address mode") },
1347 { SST(0x20, 0x07, SS_RDEF, /* XXX TBD */
1348 "Illegal command while in implicit address mode") },
1350 { SST(0x20, 0x08, SS_RDEF, /* XXX TBD */
1351 "Access denied - enrollment conflict") },
1353 { SST(0x20, 0x09, SS_RDEF, /* XXX TBD */
1354 "Access denied - invalid LU identifier") },
1356 { SST(0x20, 0x0A, SS_RDEF, /* XXX TBD */
1357 "Access denied - invalid proxy token") },
1359 { SST(0x20, 0x0B, SS_RDEF, /* XXX TBD */
1360 "Access denied - ACL LUN conflict") },
1362 { SST(0x20, 0x0C, SS_FATAL | EINVAL,
1363 "Illegal command when not in append-only mode") },
1365 { SST(0x21, 0x00, SS_FATAL | EINVAL,
1366 "Logical block address out of range") },
1368 { SST(0x21, 0x01, SS_FATAL | EINVAL,
1369 "Invalid element address") },
1371 { SST(0x21, 0x02, SS_RDEF, /* XXX TBD */
1372 "Invalid address for write") },
1374 { SST(0x21, 0x03, SS_RDEF, /* XXX TBD */
1375 "Invalid write crossing layer jump") },
1377 { SST(0x22, 0x00, SS_FATAL | EINVAL,
1378 "Illegal function (use 20 00, 24 00, or 26 00)") },
1380 { SST(0x23, 0x00, SS_RDEF, /* XXX TBD */
1381 "Invalid token operation, cause not reportable") },
1383 { SST(0x23, 0x01, SS_RDEF, /* XXX TBD */
1384 "Invalid token operation, unsupported token type") },
1386 { SST(0x23, 0x02, SS_RDEF, /* XXX TBD */
1387 "Invalid token operation, remote token usage not supported") },
1389 { SST(0x23, 0x03, SS_RDEF, /* XXX TBD */
1390 "Invalid token operation, remote ROD token creation not supported") },
1392 { SST(0x23, 0x04, SS_RDEF, /* XXX TBD */
1393 "Invalid token operation, token unknown") },
1395 { SST(0x23, 0x05, SS_RDEF, /* XXX TBD */
1396 "Invalid token operation, token corrupt") },
1398 { SST(0x23, 0x06, SS_RDEF, /* XXX TBD */
1399 "Invalid token operation, token revoked") },
1401 { SST(0x23, 0x07, SS_RDEF, /* XXX TBD */
1402 "Invalid token operation, token expired") },
1404 { SST(0x23, 0x08, SS_RDEF, /* XXX TBD */
1405 "Invalid token operation, token cancelled") },
1407 { SST(0x23, 0x09, SS_RDEF, /* XXX TBD */
1408 "Invalid token operation, token deleted") },
1410 { SST(0x23, 0x0A, SS_RDEF, /* XXX TBD */
1411 "Invalid token operation, invalid token length") },
1412 /* DTLPWROMAEBKVF */
1413 { SST(0x24, 0x00, SS_FATAL | EINVAL,
1414 "Invalid field in CDB") },
1415 /* DTLPWRO AEBKVF */
1416 { SST(0x24, 0x01, SS_RDEF, /* XXX TBD */
1417 "CDB decryption error") },
1419 { SST(0x24, 0x02, SS_RDEF, /* XXX TBD */
1422 { SST(0x24, 0x03, SS_RDEF, /* XXX TBD */
1425 { SST(0x24, 0x04, SS_RDEF, /* XXX TBD */
1426 "Security audit value frozen") },
1428 { SST(0x24, 0x05, SS_RDEF, /* XXX TBD */
1429 "Security working key frozen") },
1431 { SST(0x24, 0x06, SS_RDEF, /* XXX TBD */
1432 "NONCE not unique") },
1434 { SST(0x24, 0x07, SS_RDEF, /* XXX TBD */
1435 "NONCE timestamp out of range") },
1437 { SST(0x24, 0x08, SS_RDEF, /* XXX TBD */
1439 /* DTLPWROMAEBKVF */
1440 { SST(0x25, 0x00, SS_FATAL | ENXIO,
1441 "Logical unit not supported") },
1442 /* DTLPWROMAEBKVF */
1443 { SST(0x26, 0x00, SS_FATAL | EINVAL,
1444 "Invalid field in parameter list") },
1445 /* DTLPWROMAEBKVF */
1446 { SST(0x26, 0x01, SS_FATAL | EINVAL,
1447 "Parameter not supported") },
1448 /* DTLPWROMAEBKVF */
1449 { SST(0x26, 0x02, SS_FATAL | EINVAL,
1450 "Parameter value invalid") },
1452 { SST(0x26, 0x03, SS_FATAL | EINVAL,
1453 "Threshold parameters not supported") },
1454 /* DTLPWROMAEBKVF */
1455 { SST(0x26, 0x04, SS_FATAL | EINVAL,
1456 "Invalid release of persistent reservation") },
1458 { SST(0x26, 0x05, SS_RDEF, /* XXX TBD */
1459 "Data decryption error") },
1461 { SST(0x26, 0x06, SS_RDEF, /* XXX TBD */
1462 "Too many target descriptors") },
1464 { SST(0x26, 0x07, SS_RDEF, /* XXX TBD */
1465 "Unsupported target descriptor type code") },
1467 { SST(0x26, 0x08, SS_RDEF, /* XXX TBD */
1468 "Too many segment descriptors") },
1470 { SST(0x26, 0x09, SS_RDEF, /* XXX TBD */
1471 "Unsupported segment descriptor type code") },
1473 { SST(0x26, 0x0A, SS_RDEF, /* XXX TBD */
1474 "Unexpected inexact segment") },
1476 { SST(0x26, 0x0B, SS_RDEF, /* XXX TBD */
1477 "Inline data length exceeded") },
1479 { SST(0x26, 0x0C, SS_RDEF, /* XXX TBD */
1480 "Invalid operation for copy source or destination") },
1482 { SST(0x26, 0x0D, SS_RDEF, /* XXX TBD */
1483 "Copy segment granularity violation") },
1485 { SST(0x26, 0x0E, SS_RDEF, /* XXX TBD */
1486 "Invalid parameter while port is enabled") },
1488 { SST(0x26, 0x0F, SS_RDEF, /* XXX TBD */
1489 "Invalid data-out buffer integrity check value") },
1491 { SST(0x26, 0x10, SS_RDEF, /* XXX TBD */
1492 "Data decryption key fail limit reached") },
1494 { SST(0x26, 0x11, SS_RDEF, /* XXX TBD */
1495 "Incomplete key-associated data set") },
1497 { SST(0x26, 0x12, SS_RDEF, /* XXX TBD */
1498 "Vendor specific key reference not found") },
1500 { SST(0x27, 0x00, SS_FATAL | EACCES,
1501 "Write protected") },
1503 { SST(0x27, 0x01, SS_FATAL | EACCES,
1504 "Hardware write protected") },
1506 { SST(0x27, 0x02, SS_FATAL | EACCES,
1507 "Logical unit software write protected") },
1509 { SST(0x27, 0x03, SS_FATAL | EACCES,
1510 "Associated write protect") },
1512 { SST(0x27, 0x04, SS_FATAL | EACCES,
1513 "Persistent write protect") },
1515 { SST(0x27, 0x05, SS_FATAL | EACCES,
1516 "Permanent write protect") },
1518 { SST(0x27, 0x06, SS_RDEF, /* XXX TBD */
1519 "Conditional write protect") },
1521 { SST(0x27, 0x07, SS_RDEF, /* XXX TBD */
1522 "Space allocation failed write protect") },
1523 /* DTLPWROMAEBKVF */
1524 { SST(0x28, 0x00, SS_FATAL | ENXIO,
1525 "Not ready to ready change, medium may have changed") },
1527 { SST(0x28, 0x01, SS_FATAL | ENXIO,
1528 "Import or export element accessed") },
1530 { SST(0x28, 0x02, SS_RDEF, /* XXX TBD */
1531 "Format-layer may have changed") },
1533 { SST(0x28, 0x03, SS_RDEF, /* XXX TBD */
1534 "Import/export element accessed, medium changed") },
1536 * XXX JGibbs - All of these should use the same errno, but I don't
1537 * think ENXIO is the correct choice. Should we borrow from
1538 * the networking errnos? ECONNRESET anyone?
1540 /* DTLPWROMAEBKVF */
1541 { SST(0x29, 0x00, SS_FATAL | ENXIO,
1542 "Power on, reset, or bus device reset occurred") },
1543 /* DTLPWROMAEBKVF */
1544 { SST(0x29, 0x01, SS_RDEF,
1545 "Power on occurred") },
1546 /* DTLPWROMAEBKVF */
1547 { SST(0x29, 0x02, SS_RDEF,
1548 "SCSI bus reset occurred") },
1549 /* DTLPWROMAEBKVF */
1550 { SST(0x29, 0x03, SS_RDEF,
1551 "Bus device reset function occurred") },
1552 /* DTLPWROMAEBKVF */
1553 { SST(0x29, 0x04, SS_RDEF,
1554 "Device internal reset") },
1555 /* DTLPWROMAEBKVF */
1556 { SST(0x29, 0x05, SS_RDEF,
1557 "Transceiver mode changed to single-ended") },
1558 /* DTLPWROMAEBKVF */
1559 { SST(0x29, 0x06, SS_RDEF,
1560 "Transceiver mode changed to LVD") },
1561 /* DTLPWROMAEBKVF */
1562 { SST(0x29, 0x07, SS_RDEF, /* XXX TBD */
1563 "I_T nexus loss occurred") },
1564 /* DTL WROMAEBKVF */
1565 { SST(0x2A, 0x00, SS_RDEF,
1566 "Parameters changed") },
1567 /* DTL WROMAEBKVF */
1568 { SST(0x2A, 0x01, SS_RDEF,
1569 "Mode parameters changed") },
1571 { SST(0x2A, 0x02, SS_RDEF,
1572 "Log parameters changed") },
1574 { SST(0x2A, 0x03, SS_RDEF,
1575 "Reservations preempted") },
1577 { SST(0x2A, 0x04, SS_RDEF, /* XXX TBD */
1578 "Reservations released") },
1580 { SST(0x2A, 0x05, SS_RDEF, /* XXX TBD */
1581 "Registrations preempted") },
1582 /* DTLPWROMAEBKVF */
1583 { SST(0x2A, 0x06, SS_RDEF, /* XXX TBD */
1584 "Asymmetric access state changed") },
1585 /* DTLPWROMAEBKVF */
1586 { SST(0x2A, 0x07, SS_RDEF, /* XXX TBD */
1587 "Implicit asymmetric access state transition failed") },
1589 { SST(0x2A, 0x08, SS_RDEF, /* XXX TBD */
1590 "Priority changed") },
1592 { SST(0x2A, 0x09, SS_RDEF, /* XXX TBD */
1593 "Capacity data has changed") },
1595 { SST(0x2A, 0x0A, SS_RDEF, /* XXX TBD */
1596 "Error history I_T nexus cleared") },
1598 { SST(0x2A, 0x0B, SS_RDEF, /* XXX TBD */
1599 "Error history snapshot released") },
1601 { SST(0x2A, 0x0C, SS_RDEF, /* XXX TBD */
1602 "Error recovery attributes have changed") },
1604 { SST(0x2A, 0x0D, SS_RDEF, /* XXX TBD */
1605 "Data encryption capabilities changed") },
1607 { SST(0x2A, 0x10, SS_RDEF, /* XXX TBD */
1608 "Timestamp changed") },
1610 { SST(0x2A, 0x11, SS_RDEF, /* XXX TBD */
1611 "Data encryption parameters changed by another I_T nexus") },
1613 { SST(0x2A, 0x12, SS_RDEF, /* XXX TBD */
1614 "Data encryption parameters changed by vendor specific event") },
1616 { SST(0x2A, 0x13, SS_RDEF, /* XXX TBD */
1617 "Data encryption key instance counter has changed") },
1619 { SST(0x2A, 0x14, SS_RDEF, /* XXX TBD */
1620 "SA creation capabilities data has changed") },
1622 { SST(0x2A, 0x15, SS_RDEF, /* XXX TBD */
1623 "Medium removal prevention preempted") },
1625 { SST(0x2B, 0x00, SS_RDEF,
1626 "Copy cannot execute since host cannot disconnect") },
1627 /* DTLPWROMAEBKVF */
1628 { SST(0x2C, 0x00, SS_RDEF,
1629 "Command sequence error") },
1631 { SST(0x2C, 0x01, SS_RDEF,
1632 "Too many windows specified") },
1634 { SST(0x2C, 0x02, SS_RDEF,
1635 "Invalid combination of windows specified") },
1637 { SST(0x2C, 0x03, SS_RDEF,
1638 "Current program area is not empty") },
1640 { SST(0x2C, 0x04, SS_RDEF,
1641 "Current program area is empty") },
1643 { SST(0x2C, 0x05, SS_RDEF, /* XXX TBD */
1644 "Illegal power condition request") },
1646 { SST(0x2C, 0x06, SS_RDEF, /* XXX TBD */
1647 "Persistent prevent conflict") },
1648 /* DTLPWROMAEBKVF */
1649 { SST(0x2C, 0x07, SS_RDEF, /* XXX TBD */
1650 "Previous busy status") },
1651 /* DTLPWROMAEBKVF */
1652 { SST(0x2C, 0x08, SS_RDEF, /* XXX TBD */
1653 "Previous task set full status") },
1654 /* DTLPWROM EBKVF */
1655 { SST(0x2C, 0x09, SS_RDEF, /* XXX TBD */
1656 "Previous reservation conflict status") },
1658 { SST(0x2C, 0x0A, SS_RDEF, /* XXX TBD */
1659 "Partition or collection contains user objects") },
1661 { SST(0x2C, 0x0B, SS_RDEF, /* XXX TBD */
1664 { SST(0x2C, 0x0C, SS_RDEF, /* XXX TBD */
1665 "ORWRITE generation does not match") },
1667 { SST(0x2D, 0x00, SS_RDEF,
1668 "Overwrite error on update in place") },
1670 { SST(0x2E, 0x00, SS_RDEF, /* XXX TBD */
1671 "Insufficient time for operation") },
1672 /* DTLPWROMAEBKVF */
1673 { SST(0x2F, 0x00, SS_RDEF,
1674 "Commands cleared by another initiator") },
1676 { SST(0x2F, 0x01, SS_RDEF, /* XXX TBD */
1677 "Commands cleared by power loss notification") },
1678 /* DTLPWROMAEBKVF */
1679 { SST(0x2F, 0x02, SS_RDEF, /* XXX TBD */
1680 "Commands cleared by device server") },
1682 { SST(0x30, 0x00, SS_RDEF,
1683 "Incompatible medium installed") },
1685 { SST(0x30, 0x01, SS_RDEF,
1686 "Cannot read medium - unknown format") },
1688 { SST(0x30, 0x02, SS_RDEF,
1689 "Cannot read medium - incompatible format") },
1691 { SST(0x30, 0x03, SS_RDEF,
1692 "Cleaning cartridge installed") },
1694 { SST(0x30, 0x04, SS_RDEF,
1695 "Cannot write medium - unknown format") },
1697 { SST(0x30, 0x05, SS_RDEF,
1698 "Cannot write medium - incompatible format") },
1700 { SST(0x30, 0x06, SS_RDEF,
1701 "Cannot format medium - incompatible medium") },
1702 /* DTL WROMAEBKVF */
1703 { SST(0x30, 0x07, SS_RDEF,
1704 "Cleaning failure") },
1706 { SST(0x30, 0x08, SS_RDEF,
1707 "Cannot write - application code mismatch") },
1709 { SST(0x30, 0x09, SS_RDEF,
1710 "Current session not fixated for append") },
1712 { SST(0x30, 0x0A, SS_RDEF, /* XXX TBD */
1713 "Cleaning request rejected") },
1715 { SST(0x30, 0x0C, SS_RDEF, /* XXX TBD */
1716 "WORM medium - overwrite attempted") },
1718 { SST(0x30, 0x0D, SS_RDEF, /* XXX TBD */
1719 "WORM medium - integrity check") },
1721 { SST(0x30, 0x10, SS_RDEF, /* XXX TBD */
1722 "Medium not formatted") },
1724 { SST(0x30, 0x11, SS_RDEF, /* XXX TBD */
1725 "Incompatible volume type") },
1727 { SST(0x30, 0x12, SS_RDEF, /* XXX TBD */
1728 "Incompatible volume qualifier") },
1730 { SST(0x30, 0x13, SS_RDEF, /* XXX TBD */
1731 "Cleaning volume expired") },
1733 { SST(0x31, 0x00, SS_RDEF,
1734 "Medium format corrupted") },
1736 { SST(0x31, 0x01, SS_RDEF,
1737 "Format command failed") },
1739 { SST(0x31, 0x02, SS_RDEF, /* XXX TBD */
1740 "Zoned formatting failed due to spare linking") },
1742 { SST(0x31, 0x03, SS_RDEF, /* XXX TBD */
1743 "SANITIZE command failed") },
1745 { SST(0x32, 0x00, SS_RDEF,
1746 "No defect spare location available") },
1748 { SST(0x32, 0x01, SS_RDEF,
1749 "Defect list update failure") },
1751 { SST(0x33, 0x00, SS_RDEF,
1752 "Tape length error") },
1753 /* DTLPWROMAEBKVF */
1754 { SST(0x34, 0x00, SS_RDEF,
1755 "Enclosure failure") },
1756 /* DTLPWROMAEBKVF */
1757 { SST(0x35, 0x00, SS_RDEF,
1758 "Enclosure services failure") },
1759 /* DTLPWROMAEBKVF */
1760 { SST(0x35, 0x01, SS_RDEF,
1761 "Unsupported enclosure function") },
1762 /* DTLPWROMAEBKVF */
1763 { SST(0x35, 0x02, SS_RDEF,
1764 "Enclosure services unavailable") },
1765 /* DTLPWROMAEBKVF */
1766 { SST(0x35, 0x03, SS_RDEF,
1767 "Enclosure services transfer failure") },
1768 /* DTLPWROMAEBKVF */
1769 { SST(0x35, 0x04, SS_RDEF,
1770 "Enclosure services transfer refused") },
1771 /* DTL WROMAEBKVF */
1772 { SST(0x35, 0x05, SS_RDEF, /* XXX TBD */
1773 "Enclosure services checksum error") },
1775 { SST(0x36, 0x00, SS_RDEF,
1776 "Ribbon, ink, or toner failure") },
1777 /* DTL WROMAEBKVF */
1778 { SST(0x37, 0x00, SS_RDEF,
1779 "Rounded parameter") },
1781 { SST(0x38, 0x00, SS_RDEF, /* XXX TBD */
1782 "Event status notification") },
1784 { SST(0x38, 0x02, SS_RDEF, /* XXX TBD */
1785 "ESN - power management class event") },
1787 { SST(0x38, 0x04, SS_RDEF, /* XXX TBD */
1788 "ESN - media class event") },
1790 { SST(0x38, 0x06, SS_RDEF, /* XXX TBD */
1791 "ESN - device busy class event") },
1793 { SST(0x38, 0x07, SS_RDEF, /* XXX TBD */
1794 "Thin provisioning soft threshold reached") },
1796 { SST(0x39, 0x00, SS_RDEF,
1797 "Saving parameters not supported") },
1799 { SST(0x3A, 0x00, SS_FATAL | ENXIO,
1800 "Medium not present") },
1802 { SST(0x3A, 0x01, SS_FATAL | ENXIO,
1803 "Medium not present - tray closed") },
1805 { SST(0x3A, 0x02, SS_FATAL | ENXIO,
1806 "Medium not present - tray open") },
1808 { SST(0x3A, 0x03, SS_RDEF, /* XXX TBD */
1809 "Medium not present - loadable") },
1811 { SST(0x3A, 0x04, SS_RDEF, /* XXX TBD */
1812 "Medium not present - medium auxiliary memory accessible") },
1814 { SST(0x3B, 0x00, SS_RDEF,
1815 "Sequential positioning error") },
1817 { SST(0x3B, 0x01, SS_RDEF,
1818 "Tape position error at beginning-of-medium") },
1820 { SST(0x3B, 0x02, SS_RDEF,
1821 "Tape position error at end-of-medium") },
1823 { SST(0x3B, 0x03, SS_RDEF,
1824 "Tape or electronic vertical forms unit not ready") },
1826 { SST(0x3B, 0x04, SS_RDEF,
1829 { SST(0x3B, 0x05, SS_RDEF,
1832 { SST(0x3B, 0x06, SS_RDEF,
1833 "Failed to sense top-of-form") },
1835 { SST(0x3B, 0x07, SS_RDEF,
1836 "Failed to sense bottom-of-form") },
1838 { SST(0x3B, 0x08, SS_RDEF,
1839 "Reposition error") },
1841 { SST(0x3B, 0x09, SS_RDEF,
1842 "Read past end of medium") },
1844 { SST(0x3B, 0x0A, SS_RDEF,
1845 "Read past beginning of medium") },
1847 { SST(0x3B, 0x0B, SS_RDEF,
1848 "Position past end of medium") },
1850 { SST(0x3B, 0x0C, SS_RDEF,
1851 "Position past beginning of medium") },
1853 { SST(0x3B, 0x0D, SS_FATAL | ENOSPC,
1854 "Medium destination element full") },
1856 { SST(0x3B, 0x0E, SS_RDEF,
1857 "Medium source element empty") },
1859 { SST(0x3B, 0x0F, SS_RDEF,
1860 "End of medium reached") },
1862 { SST(0x3B, 0x11, SS_RDEF,
1863 "Medium magazine not accessible") },
1865 { SST(0x3B, 0x12, SS_RDEF,
1866 "Medium magazine removed") },
1868 { SST(0x3B, 0x13, SS_RDEF,
1869 "Medium magazine inserted") },
1871 { SST(0x3B, 0x14, SS_RDEF,
1872 "Medium magazine locked") },
1874 { SST(0x3B, 0x15, SS_RDEF,
1875 "Medium magazine unlocked") },
1877 { SST(0x3B, 0x16, SS_RDEF, /* XXX TBD */
1878 "Mechanical positioning or changer error") },
1880 { SST(0x3B, 0x17, SS_RDEF, /* XXX TBD */
1881 "Read past end of user object") },
1883 { SST(0x3B, 0x18, SS_RDEF, /* XXX TBD */
1884 "Element disabled") },
1886 { SST(0x3B, 0x19, SS_RDEF, /* XXX TBD */
1887 "Element enabled") },
1889 { SST(0x3B, 0x1A, SS_RDEF, /* XXX TBD */
1890 "Data transfer device removed") },
1892 { SST(0x3B, 0x1B, SS_RDEF, /* XXX TBD */
1893 "Data transfer device inserted") },
1895 { SST(0x3B, 0x1C, SS_RDEF, /* XXX TBD */
1896 "Too many logical objects on partition to support operation") },
1898 { SST(0x3D, 0x00, SS_RDEF,
1899 "Invalid bits in IDENTIFY message") },
1900 /* DTLPWROMAEBKVF */
1901 { SST(0x3E, 0x00, SS_RDEF,
1902 "Logical unit has not self-configured yet") },
1903 /* DTLPWROMAEBKVF */
1904 { SST(0x3E, 0x01, SS_RDEF,
1905 "Logical unit failure") },
1906 /* DTLPWROMAEBKVF */
1907 { SST(0x3E, 0x02, SS_RDEF,
1908 "Timeout on logical unit") },
1909 /* DTLPWROMAEBKVF */
1910 { SST(0x3E, 0x03, SS_RDEF, /* XXX TBD */
1911 "Logical unit failed self-test") },
1912 /* DTLPWROMAEBKVF */
1913 { SST(0x3E, 0x04, SS_RDEF, /* XXX TBD */
1914 "Logical unit unable to update self-test log") },
1915 /* DTLPWROMAEBKVF */
1916 { SST(0x3F, 0x00, SS_RDEF,
1917 "Target operating conditions have changed") },
1918 /* DTLPWROMAEBKVF */
1919 { SST(0x3F, 0x01, SS_RDEF,
1920 "Microcode has been changed") },
1922 { SST(0x3F, 0x02, SS_RDEF,
1923 "Changed operating definition") },
1924 /* DTLPWROMAEBKVF */
1925 { SST(0x3F, 0x03, SS_RDEF,
1926 "INQUIRY data has changed") },
1928 { SST(0x3F, 0x04, SS_RDEF,
1929 "Component device attached") },
1931 { SST(0x3F, 0x05, SS_RDEF,
1932 "Device identifier changed") },
1934 { SST(0x3F, 0x06, SS_RDEF,
1935 "Redundancy group created or modified") },
1937 { SST(0x3F, 0x07, SS_RDEF,
1938 "Redundancy group deleted") },
1940 { SST(0x3F, 0x08, SS_RDEF,
1941 "Spare created or modified") },
1943 { SST(0x3F, 0x09, SS_RDEF,
1946 { SST(0x3F, 0x0A, SS_RDEF,
1947 "Volume set created or modified") },
1949 { SST(0x3F, 0x0B, SS_RDEF,
1950 "Volume set deleted") },
1952 { SST(0x3F, 0x0C, SS_RDEF,
1953 "Volume set deassigned") },
1955 { SST(0x3F, 0x0D, SS_RDEF,
1956 "Volume set reassigned") },
1958 { SST(0x3F, 0x0E, SS_RDEF, /* XXX TBD */
1959 "Reported LUNs data has changed") },
1960 /* DTLPWROMAEBKVF */
1961 { SST(0x3F, 0x0F, SS_RDEF, /* XXX TBD */
1962 "Echo buffer overwritten") },
1964 { SST(0x3F, 0x10, SS_RDEF, /* XXX TBD */
1965 "Medium loadable") },
1967 { SST(0x3F, 0x11, SS_RDEF, /* XXX TBD */
1968 "Medium auxiliary memory accessible") },
1969 /* DTLPWR MAEBK F */
1970 { SST(0x3F, 0x12, SS_RDEF, /* XXX TBD */
1971 "iSCSI IP address added") },
1972 /* DTLPWR MAEBK F */
1973 { SST(0x3F, 0x13, SS_RDEF, /* XXX TBD */
1974 "iSCSI IP address removed") },
1975 /* DTLPWR MAEBK F */
1976 { SST(0x3F, 0x14, SS_RDEF, /* XXX TBD */
1977 "iSCSI IP address changed") },
1979 { SST(0x40, 0x00, SS_RDEF,
1980 "RAM failure") }, /* deprecated - use 40 NN instead */
1981 /* DTLPWROMAEBKVF */
1982 { SST(0x40, 0x80, SS_RDEF,
1983 "Diagnostic failure: ASCQ = Component ID") },
1984 /* DTLPWROMAEBKVF */
1985 { SST(0x40, 0xFF, SS_RDEF | SSQ_RANGE,
1986 NULL) }, /* Range 0x80->0xFF */
1988 { SST(0x41, 0x00, SS_RDEF,
1989 "Data path failure") }, /* deprecated - use 40 NN instead */
1991 { SST(0x42, 0x00, SS_RDEF,
1992 "Power-on or self-test failure") },
1993 /* deprecated - use 40 NN instead */
1994 /* DTLPWROMAEBKVF */
1995 { SST(0x43, 0x00, SS_RDEF,
1997 /* DTLPWROMAEBKVF */
1998 { SST(0x44, 0x00, SS_RDEF,
1999 "Internal target failure") },
2001 { SST(0x44, 0x01, SS_RDEF, /* XXX TBD */
2002 "Persistent reservation information lost") },
2004 { SST(0x44, 0x71, SS_RDEF, /* XXX TBD */
2005 "ATA device failed set features") },
2006 /* DTLPWROMAEBKVF */
2007 { SST(0x45, 0x00, SS_RDEF,
2008 "Select or reselect failure") },
2010 { SST(0x46, 0x00, SS_RDEF,
2011 "Unsuccessful soft reset") },
2012 /* DTLPWROMAEBKVF */
2013 { SST(0x47, 0x00, SS_RDEF,
2014 "SCSI parity error") },
2015 /* DTLPWROMAEBKVF */
2016 { SST(0x47, 0x01, SS_RDEF, /* XXX TBD */
2017 "Data phase CRC error detected") },
2018 /* DTLPWROMAEBKVF */
2019 { SST(0x47, 0x02, SS_RDEF, /* XXX TBD */
2020 "SCSI parity error detected during ST data phase") },
2021 /* DTLPWROMAEBKVF */
2022 { SST(0x47, 0x03, SS_RDEF, /* XXX TBD */
2023 "Information unit iuCRC error detected") },
2024 /* DTLPWROMAEBKVF */
2025 { SST(0x47, 0x04, SS_RDEF, /* XXX TBD */
2026 "Asynchronous information protection error detected") },
2027 /* DTLPWROMAEBKVF */
2028 { SST(0x47, 0x05, SS_RDEF, /* XXX TBD */
2029 "Protocol service CRC error") },
2031 { SST(0x47, 0x06, SS_RDEF, /* XXX TBD */
2032 "PHY test function in progress") },
2034 { SST(0x47, 0x7F, SS_RDEF, /* XXX TBD */
2035 "Some commands cleared by iSCSI protocol event") },
2036 /* DTLPWROMAEBKVF */
2037 { SST(0x48, 0x00, SS_RDEF,
2038 "Initiator detected error message received") },
2039 /* DTLPWROMAEBKVF */
2040 { SST(0x49, 0x00, SS_RDEF,
2041 "Invalid message error") },
2042 /* DTLPWROMAEBKVF */
2043 { SST(0x4A, 0x00, SS_RDEF,
2044 "Command phase error") },
2045 /* DTLPWROMAEBKVF */
2046 { SST(0x4B, 0x00, SS_RDEF,
2047 "Data phase error") },
2049 { SST(0x4B, 0x01, SS_RDEF, /* XXX TBD */
2050 "Invalid target port transfer tag received") },
2052 { SST(0x4B, 0x02, SS_RDEF, /* XXX TBD */
2053 "Too much write data") },
2055 { SST(0x4B, 0x03, SS_RDEF, /* XXX TBD */
2056 "ACK/NAK timeout") },
2058 { SST(0x4B, 0x04, SS_RDEF, /* XXX TBD */
2061 { SST(0x4B, 0x05, SS_RDEF, /* XXX TBD */
2062 "Data offset error") },
2064 { SST(0x4B, 0x06, SS_RDEF, /* XXX TBD */
2065 "Initiator response timeout") },
2066 /* DT PWROMAEBK F */
2067 { SST(0x4B, 0x07, SS_RDEF, /* XXX TBD */
2068 "Connection lost") },
2069 /* DT PWROMAEBK F */
2070 { SST(0x4B, 0x08, SS_RDEF, /* XXX TBD */
2071 "Data-in buffer overflow - data buffer size") },
2072 /* DT PWROMAEBK F */
2073 { SST(0x4B, 0x09, SS_RDEF, /* XXX TBD */
2074 "Data-in buffer overflow - data buffer descriptor area") },
2075 /* DT PWROMAEBK F */
2076 { SST(0x4B, 0x0A, SS_RDEF, /* XXX TBD */
2077 "Data-in buffer error") },
2078 /* DT PWROMAEBK F */
2079 { SST(0x4B, 0x0B, SS_RDEF, /* XXX TBD */
2080 "Data-out buffer overflow - data buffer size") },
2081 /* DT PWROMAEBK F */
2082 { SST(0x4B, 0x0C, SS_RDEF, /* XXX TBD */
2083 "Data-out buffer overflow - data buffer descriptor area") },
2084 /* DT PWROMAEBK F */
2085 { SST(0x4B, 0x0D, SS_RDEF, /* XXX TBD */
2086 "Data-out buffer error") },
2087 /* DTLPWROMAEBKVF */
2088 { SST(0x4C, 0x00, SS_RDEF,
2089 "Logical unit failed self-configuration") },
2090 /* DTLPWROMAEBKVF */
2091 { SST(0x4D, 0x00, SS_RDEF,
2092 "Tagged overlapped commands: ASCQ = Queue tag ID") },
2093 /* DTLPWROMAEBKVF */
2094 { SST(0x4D, 0xFF, SS_RDEF | SSQ_RANGE,
2095 NULL) }, /* Range 0x00->0xFF */
2096 /* DTLPWROMAEBKVF */
2097 { SST(0x4E, 0x00, SS_RDEF,
2098 "Overlapped commands attempted") },
2100 { SST(0x50, 0x00, SS_RDEF,
2101 "Write append error") },
2103 { SST(0x50, 0x01, SS_RDEF,
2104 "Write append position error") },
2106 { SST(0x50, 0x02, SS_RDEF,
2107 "Position error related to timing") },
2109 { SST(0x51, 0x00, SS_RDEF,
2112 { SST(0x51, 0x01, SS_RDEF, /* XXX TBD */
2113 "Erase failure - incomplete erase operation detected") },
2115 { SST(0x52, 0x00, SS_RDEF,
2116 "Cartridge fault") },
2118 { SST(0x53, 0x00, SS_RDEF,
2119 "Media load or eject failed") },
2121 { SST(0x53, 0x01, SS_RDEF,
2122 "Unload tape failure") },
2124 { SST(0x53, 0x02, SS_RDEF,
2125 "Medium removal prevented") },
2127 { SST(0x53, 0x03, SS_RDEF, /* XXX TBD */
2128 "Medium removal prevented by data transfer element") },
2130 { SST(0x53, 0x04, SS_RDEF, /* XXX TBD */
2131 "Medium thread or unthread failure") },
2133 { SST(0x53, 0x05, SS_RDEF, /* XXX TBD */
2134 "Volume identifier invalid") },
2136 { SST(0x53, 0x06, SS_RDEF, /* XXX TBD */
2137 "Volume identifier missing") },
2139 { SST(0x53, 0x07, SS_RDEF, /* XXX TBD */
2140 "Duplicate volume identifier") },
2142 { SST(0x53, 0x08, SS_RDEF, /* XXX TBD */
2143 "Element status unknown") },
2145 { SST(0x54, 0x00, SS_RDEF,
2146 "SCSI to host system interface failure") },
2148 { SST(0x55, 0x00, SS_RDEF,
2149 "System resource failure") },
2151 { SST(0x55, 0x01, SS_FATAL | ENOSPC,
2152 "System buffer full") },
2154 { SST(0x55, 0x02, SS_RDEF, /* XXX TBD */
2155 "Insufficient reservation resources") },
2157 { SST(0x55, 0x03, SS_RDEF, /* XXX TBD */
2158 "Insufficient resources") },
2160 { SST(0x55, 0x04, SS_RDEF, /* XXX TBD */
2161 "Insufficient registration resources") },
2163 { SST(0x55, 0x05, SS_RDEF, /* XXX TBD */
2164 "Insufficient access control resources") },
2166 { SST(0x55, 0x06, SS_RDEF, /* XXX TBD */
2167 "Auxiliary memory out of space") },
2169 { SST(0x55, 0x07, SS_RDEF, /* XXX TBD */
2172 { SST(0x55, 0x08, SS_RDEF, /* XXX TBD */
2173 "Maximum number of supplemental decryption keys exceeded") },
2175 { SST(0x55, 0x09, SS_RDEF, /* XXX TBD */
2176 "Medium auxiliary memory not accessible") },
2178 { SST(0x55, 0x0A, SS_RDEF, /* XXX TBD */
2179 "Data currently unavailable") },
2180 /* DTLPWROMAEBKVF */
2181 { SST(0x55, 0x0B, SS_RDEF, /* XXX TBD */
2182 "Insufficient power for operation") },
2184 { SST(0x55, 0x0C, SS_RDEF, /* XXX TBD */
2185 "Insufficient resources to create ROD") },
2187 { SST(0x55, 0x0D, SS_RDEF, /* XXX TBD */
2188 "Insufficient resources to create ROD token") },
2190 { SST(0x57, 0x00, SS_RDEF,
2191 "Unable to recover table-of-contents") },
2193 { SST(0x58, 0x00, SS_RDEF,
2194 "Generation does not exist") },
2196 { SST(0x59, 0x00, SS_RDEF,
2197 "Updated block read") },
2199 { SST(0x5A, 0x00, SS_RDEF,
2200 "Operator request or state change input") },
2202 { SST(0x5A, 0x01, SS_RDEF,
2203 "Operator medium removal request") },
2205 { SST(0x5A, 0x02, SS_RDEF,
2206 "Operator selected write protect") },
2208 { SST(0x5A, 0x03, SS_RDEF,
2209 "Operator selected write permit") },
2211 { SST(0x5B, 0x00, SS_RDEF,
2214 { SST(0x5B, 0x01, SS_RDEF,
2215 "Threshold condition met") },
2217 { SST(0x5B, 0x02, SS_RDEF,
2218 "Log counter at maximum") },
2220 { SST(0x5B, 0x03, SS_RDEF,
2221 "Log list codes exhausted") },
2223 { SST(0x5C, 0x00, SS_RDEF,
2224 "RPL status change") },
2226 { SST(0x5C, 0x01, SS_NOP | SSQ_PRINT_SENSE,
2227 "Spindles synchronized") },
2229 { SST(0x5C, 0x02, SS_RDEF,
2230 "Spindles not synchronized") },
2231 /* DTLPWROMAEBKVF */
2232 { SST(0x5D, 0x00, SS_RDEF,
2233 "Failure prediction threshold exceeded") },
2235 { SST(0x5D, 0x01, SS_RDEF, /* XXX TBD */
2236 "Media failure prediction threshold exceeded") },
2238 { SST(0x5D, 0x02, SS_RDEF, /* XXX TBD */
2239 "Logical unit failure prediction threshold exceeded") },
2241 { SST(0x5D, 0x03, SS_RDEF, /* XXX TBD */
2242 "Spare area exhaustion prediction threshold exceeded") },
2244 { SST(0x5D, 0x10, SS_RDEF, /* XXX TBD */
2245 "Hardware impending failure general hard drive failure") },
2247 { SST(0x5D, 0x11, SS_RDEF, /* XXX TBD */
2248 "Hardware impending failure drive error rate too high") },
2250 { SST(0x5D, 0x12, SS_RDEF, /* XXX TBD */
2251 "Hardware impending failure data error rate too high") },
2253 { SST(0x5D, 0x13, SS_RDEF, /* XXX TBD */
2254 "Hardware impending failure seek error rate too high") },
2256 { SST(0x5D, 0x14, SS_RDEF, /* XXX TBD */
2257 "Hardware impending failure too many block reassigns") },
2259 { SST(0x5D, 0x15, SS_RDEF, /* XXX TBD */
2260 "Hardware impending failure access times too high") },
2262 { SST(0x5D, 0x16, SS_RDEF, /* XXX TBD */
2263 "Hardware impending failure start unit times too high") },
2265 { SST(0x5D, 0x17, SS_RDEF, /* XXX TBD */
2266 "Hardware impending failure channel parametrics") },
2268 { SST(0x5D, 0x18, SS_RDEF, /* XXX TBD */
2269 "Hardware impending failure controller detected") },
2271 { SST(0x5D, 0x19, SS_RDEF, /* XXX TBD */
2272 "Hardware impending failure throughput performance") },
2274 { SST(0x5D, 0x1A, SS_RDEF, /* XXX TBD */
2275 "Hardware impending failure seek time performance") },
2277 { SST(0x5D, 0x1B, SS_RDEF, /* XXX TBD */
2278 "Hardware impending failure spin-up retry count") },
2280 { SST(0x5D, 0x1C, SS_RDEF, /* XXX TBD */
2281 "Hardware impending failure drive calibration retry count") },
2283 { SST(0x5D, 0x20, SS_RDEF, /* XXX TBD */
2284 "Controller impending failure general hard drive failure") },
2286 { SST(0x5D, 0x21, SS_RDEF, /* XXX TBD */
2287 "Controller impending failure drive error rate too high") },
2289 { SST(0x5D, 0x22, SS_RDEF, /* XXX TBD */
2290 "Controller impending failure data error rate too high") },
2292 { SST(0x5D, 0x23, SS_RDEF, /* XXX TBD */
2293 "Controller impending failure seek error rate too high") },
2295 { SST(0x5D, 0x24, SS_RDEF, /* XXX TBD */
2296 "Controller impending failure too many block reassigns") },
2298 { SST(0x5D, 0x25, SS_RDEF, /* XXX TBD */
2299 "Controller impending failure access times too high") },
2301 { SST(0x5D, 0x26, SS_RDEF, /* XXX TBD */
2302 "Controller impending failure start unit times too high") },
2304 { SST(0x5D, 0x27, SS_RDEF, /* XXX TBD */
2305 "Controller impending failure channel parametrics") },
2307 { SST(0x5D, 0x28, SS_RDEF, /* XXX TBD */
2308 "Controller impending failure controller detected") },
2310 { SST(0x5D, 0x29, SS_RDEF, /* XXX TBD */
2311 "Controller impending failure throughput performance") },
2313 { SST(0x5D, 0x2A, SS_RDEF, /* XXX TBD */
2314 "Controller impending failure seek time performance") },
2316 { SST(0x5D, 0x2B, SS_RDEF, /* XXX TBD */
2317 "Controller impending failure spin-up retry count") },
2319 { SST(0x5D, 0x2C, SS_RDEF, /* XXX TBD */
2320 "Controller impending failure drive calibration retry count") },
2322 { SST(0x5D, 0x30, SS_RDEF, /* XXX TBD */
2323 "Data channel impending failure general hard drive failure") },
2325 { SST(0x5D, 0x31, SS_RDEF, /* XXX TBD */
2326 "Data channel impending failure drive error rate too high") },
2328 { SST(0x5D, 0x32, SS_RDEF, /* XXX TBD */
2329 "Data channel impending failure data error rate too high") },
2331 { SST(0x5D, 0x33, SS_RDEF, /* XXX TBD */
2332 "Data channel impending failure seek error rate too high") },
2334 { SST(0x5D, 0x34, SS_RDEF, /* XXX TBD */
2335 "Data channel impending failure too many block reassigns") },
2337 { SST(0x5D, 0x35, SS_RDEF, /* XXX TBD */
2338 "Data channel impending failure access times too high") },
2340 { SST(0x5D, 0x36, SS_RDEF, /* XXX TBD */
2341 "Data channel impending failure start unit times too high") },
2343 { SST(0x5D, 0x37, SS_RDEF, /* XXX TBD */
2344 "Data channel impending failure channel parametrics") },
2346 { SST(0x5D, 0x38, SS_RDEF, /* XXX TBD */
2347 "Data channel impending failure controller detected") },
2349 { SST(0x5D, 0x39, SS_RDEF, /* XXX TBD */
2350 "Data channel impending failure throughput performance") },
2352 { SST(0x5D, 0x3A, SS_RDEF, /* XXX TBD */
2353 "Data channel impending failure seek time performance") },
2355 { SST(0x5D, 0x3B, SS_RDEF, /* XXX TBD */
2356 "Data channel impending failure spin-up retry count") },
2358 { SST(0x5D, 0x3C, SS_RDEF, /* XXX TBD */
2359 "Data channel impending failure drive calibration retry count") },
2361 { SST(0x5D, 0x40, SS_RDEF, /* XXX TBD */
2362 "Servo impending failure general hard drive failure") },
2364 { SST(0x5D, 0x41, SS_RDEF, /* XXX TBD */
2365 "Servo impending failure drive error rate too high") },
2367 { SST(0x5D, 0x42, SS_RDEF, /* XXX TBD */
2368 "Servo impending failure data error rate too high") },
2370 { SST(0x5D, 0x43, SS_RDEF, /* XXX TBD */
2371 "Servo impending failure seek error rate too high") },
2373 { SST(0x5D, 0x44, SS_RDEF, /* XXX TBD */
2374 "Servo impending failure too many block reassigns") },
2376 { SST(0x5D, 0x45, SS_RDEF, /* XXX TBD */
2377 "Servo impending failure access times too high") },
2379 { SST(0x5D, 0x46, SS_RDEF, /* XXX TBD */
2380 "Servo impending failure start unit times too high") },
2382 { SST(0x5D, 0x47, SS_RDEF, /* XXX TBD */
2383 "Servo impending failure channel parametrics") },
2385 { SST(0x5D, 0x48, SS_RDEF, /* XXX TBD */
2386 "Servo impending failure controller detected") },
2388 { SST(0x5D, 0x49, SS_RDEF, /* XXX TBD */
2389 "Servo impending failure throughput performance") },
2391 { SST(0x5D, 0x4A, SS_RDEF, /* XXX TBD */
2392 "Servo impending failure seek time performance") },
2394 { SST(0x5D, 0x4B, SS_RDEF, /* XXX TBD */
2395 "Servo impending failure spin-up retry count") },
2397 { SST(0x5D, 0x4C, SS_RDEF, /* XXX TBD */
2398 "Servo impending failure drive calibration retry count") },
2400 { SST(0x5D, 0x50, SS_RDEF, /* XXX TBD */
2401 "Spindle impending failure general hard drive failure") },
2403 { SST(0x5D, 0x51, SS_RDEF, /* XXX TBD */
2404 "Spindle impending failure drive error rate too high") },
2406 { SST(0x5D, 0x52, SS_RDEF, /* XXX TBD */
2407 "Spindle impending failure data error rate too high") },
2409 { SST(0x5D, 0x53, SS_RDEF, /* XXX TBD */
2410 "Spindle impending failure seek error rate too high") },
2412 { SST(0x5D, 0x54, SS_RDEF, /* XXX TBD */
2413 "Spindle impending failure too many block reassigns") },
2415 { SST(0x5D, 0x55, SS_RDEF, /* XXX TBD */
2416 "Spindle impending failure access times too high") },
2418 { SST(0x5D, 0x56, SS_RDEF, /* XXX TBD */
2419 "Spindle impending failure start unit times too high") },
2421 { SST(0x5D, 0x57, SS_RDEF, /* XXX TBD */
2422 "Spindle impending failure channel parametrics") },
2424 { SST(0x5D, 0x58, SS_RDEF, /* XXX TBD */
2425 "Spindle impending failure controller detected") },
2427 { SST(0x5D, 0x59, SS_RDEF, /* XXX TBD */
2428 "Spindle impending failure throughput performance") },
2430 { SST(0x5D, 0x5A, SS_RDEF, /* XXX TBD */
2431 "Spindle impending failure seek time performance") },
2433 { SST(0x5D, 0x5B, SS_RDEF, /* XXX TBD */
2434 "Spindle impending failure spin-up retry count") },
2436 { SST(0x5D, 0x5C, SS_RDEF, /* XXX TBD */
2437 "Spindle impending failure drive calibration retry count") },
2439 { SST(0x5D, 0x60, SS_RDEF, /* XXX TBD */
2440 "Firmware impending failure general hard drive failure") },
2442 { SST(0x5D, 0x61, SS_RDEF, /* XXX TBD */
2443 "Firmware impending failure drive error rate too high") },
2445 { SST(0x5D, 0x62, SS_RDEF, /* XXX TBD */
2446 "Firmware impending failure data error rate too high") },
2448 { SST(0x5D, 0x63, SS_RDEF, /* XXX TBD */
2449 "Firmware impending failure seek error rate too high") },
2451 { SST(0x5D, 0x64, SS_RDEF, /* XXX TBD */
2452 "Firmware impending failure too many block reassigns") },
2454 { SST(0x5D, 0x65, SS_RDEF, /* XXX TBD */
2455 "Firmware impending failure access times too high") },
2457 { SST(0x5D, 0x66, SS_RDEF, /* XXX TBD */
2458 "Firmware impending failure start unit times too high") },
2460 { SST(0x5D, 0x67, SS_RDEF, /* XXX TBD */
2461 "Firmware impending failure channel parametrics") },
2463 { SST(0x5D, 0x68, SS_RDEF, /* XXX TBD */
2464 "Firmware impending failure controller detected") },
2466 { SST(0x5D, 0x69, SS_RDEF, /* XXX TBD */
2467 "Firmware impending failure throughput performance") },
2469 { SST(0x5D, 0x6A, SS_RDEF, /* XXX TBD */
2470 "Firmware impending failure seek time performance") },
2472 { SST(0x5D, 0x6B, SS_RDEF, /* XXX TBD */
2473 "Firmware impending failure spin-up retry count") },
2475 { SST(0x5D, 0x6C, SS_RDEF, /* XXX TBD */
2476 "Firmware impending failure drive calibration retry count") },
2477 /* DTLPWROMAEBKVF */
2478 { SST(0x5D, 0xFF, SS_RDEF,
2479 "Failure prediction threshold exceeded (false)") },
2481 { SST(0x5E, 0x00, SS_RDEF,
2482 "Low power condition on") },
2484 { SST(0x5E, 0x01, SS_RDEF,
2485 "Idle condition activated by timer") },
2487 { SST(0x5E, 0x02, SS_RDEF,
2488 "Standby condition activated by timer") },
2490 { SST(0x5E, 0x03, SS_RDEF,
2491 "Idle condition activated by command") },
2493 { SST(0x5E, 0x04, SS_RDEF,
2494 "Standby condition activated by command") },
2496 { SST(0x5E, 0x05, SS_RDEF,
2497 "Idle-B condition activated by timer") },
2499 { SST(0x5E, 0x06, SS_RDEF,
2500 "Idle-B condition activated by command") },
2502 { SST(0x5E, 0x07, SS_RDEF,
2503 "Idle-C condition activated by timer") },
2505 { SST(0x5E, 0x08, SS_RDEF,
2506 "Idle-C condition activated by command") },
2508 { SST(0x5E, 0x09, SS_RDEF,
2509 "Standby-Y condition activated by timer") },
2511 { SST(0x5E, 0x0A, SS_RDEF,
2512 "Standby-Y condition activated by command") },
2514 { SST(0x5E, 0x41, SS_RDEF, /* XXX TBD */
2515 "Power state change to active") },
2517 { SST(0x5E, 0x42, SS_RDEF, /* XXX TBD */
2518 "Power state change to idle") },
2520 { SST(0x5E, 0x43, SS_RDEF, /* XXX TBD */
2521 "Power state change to standby") },
2523 { SST(0x5E, 0x45, SS_RDEF, /* XXX TBD */
2524 "Power state change to sleep") },
2526 { SST(0x5E, 0x47, SS_RDEF, /* XXX TBD */
2527 "Power state change to device control") },
2529 { SST(0x60, 0x00, SS_RDEF,
2532 { SST(0x61, 0x00, SS_RDEF,
2533 "Video acquisition error") },
2535 { SST(0x61, 0x01, SS_RDEF,
2536 "Unable to acquire video") },
2538 { SST(0x61, 0x02, SS_RDEF,
2541 { SST(0x62, 0x00, SS_RDEF,
2542 "Scan head positioning error") },
2544 { SST(0x63, 0x00, SS_RDEF,
2545 "End of user area encountered on this track") },
2547 { SST(0x63, 0x01, SS_FATAL | ENOSPC,
2548 "Packet does not fit in available space") },
2550 { SST(0x64, 0x00, SS_FATAL | ENXIO,
2551 "Illegal mode for this track") },
2553 { SST(0x64, 0x01, SS_RDEF,
2554 "Invalid packet size") },
2555 /* DTLPWROMAEBKVF */
2556 { SST(0x65, 0x00, SS_RDEF,
2559 { SST(0x66, 0x00, SS_RDEF,
2560 "Automatic document feeder cover up") },
2562 { SST(0x66, 0x01, SS_RDEF,
2563 "Automatic document feeder lift up") },
2565 { SST(0x66, 0x02, SS_RDEF,
2566 "Document jam in automatic document feeder") },
2568 { SST(0x66, 0x03, SS_RDEF,
2569 "Document miss feed automatic in document feeder") },
2571 { SST(0x67, 0x00, SS_RDEF,
2572 "Configuration failure") },
2574 { SST(0x67, 0x01, SS_RDEF,
2575 "Configuration of incapable logical units failed") },
2577 { SST(0x67, 0x02, SS_RDEF,
2578 "Add logical unit failed") },
2580 { SST(0x67, 0x03, SS_RDEF,
2581 "Modification of logical unit failed") },
2583 { SST(0x67, 0x04, SS_RDEF,
2584 "Exchange of logical unit failed") },
2586 { SST(0x67, 0x05, SS_RDEF,
2587 "Remove of logical unit failed") },
2589 { SST(0x67, 0x06, SS_RDEF,
2590 "Attachment of logical unit failed") },
2592 { SST(0x67, 0x07, SS_RDEF,
2593 "Creation of logical unit failed") },
2595 { SST(0x67, 0x08, SS_RDEF, /* XXX TBD */
2596 "Assign failure occurred") },
2598 { SST(0x67, 0x09, SS_RDEF, /* XXX TBD */
2599 "Multiply assigned logical unit") },
2600 /* DTLPWROMAEBKVF */
2601 { SST(0x67, 0x0A, SS_RDEF, /* XXX TBD */
2602 "Set target port groups command failed") },
2604 { SST(0x67, 0x0B, SS_RDEF, /* XXX TBD */
2605 "ATA device feature not enabled") },
2607 { SST(0x68, 0x00, SS_RDEF,
2608 "Logical unit not configured") },
2610 { SST(0x69, 0x00, SS_RDEF,
2611 "Data loss on logical unit") },
2613 { SST(0x69, 0x01, SS_RDEF,
2614 "Multiple logical unit failures") },
2616 { SST(0x69, 0x02, SS_RDEF,
2617 "Parity/data mismatch") },
2619 { SST(0x6A, 0x00, SS_RDEF,
2620 "Informational, refer to log") },
2622 { SST(0x6B, 0x00, SS_RDEF,
2623 "State change has occurred") },
2625 { SST(0x6B, 0x01, SS_RDEF,
2626 "Redundancy level got better") },
2628 { SST(0x6B, 0x02, SS_RDEF,
2629 "Redundancy level got worse") },
2631 { SST(0x6C, 0x00, SS_RDEF,
2632 "Rebuild failure occurred") },
2634 { SST(0x6D, 0x00, SS_RDEF,
2635 "Recalculate failure occurred") },
2637 { SST(0x6E, 0x00, SS_RDEF,
2638 "Command to logical unit failed") },
2640 { SST(0x6F, 0x00, SS_RDEF, /* XXX TBD */
2641 "Copy protection key exchange failure - authentication failure") },
2643 { SST(0x6F, 0x01, SS_RDEF, /* XXX TBD */
2644 "Copy protection key exchange failure - key not present") },
2646 { SST(0x6F, 0x02, SS_RDEF, /* XXX TBD */
2647 "Copy protection key exchange failure - key not established") },
2649 { SST(0x6F, 0x03, SS_RDEF, /* XXX TBD */
2650 "Read of scrambled sector without authentication") },
2652 { SST(0x6F, 0x04, SS_RDEF, /* XXX TBD */
2653 "Media region code is mismatched to logical unit region") },
2655 { SST(0x6F, 0x05, SS_RDEF, /* XXX TBD */
2656 "Drive region must be permanent/region reset count error") },
2658 { SST(0x6F, 0x06, SS_RDEF, /* XXX TBD */
2659 "Insufficient block count for binding NONCE recording") },
2661 { SST(0x6F, 0x07, SS_RDEF, /* XXX TBD */
2662 "Conflict in binding NONCE recording") },
2664 { SST(0x70, 0x00, SS_RDEF,
2665 "Decompression exception short: ASCQ = Algorithm ID") },
2667 { SST(0x70, 0xFF, SS_RDEF | SSQ_RANGE,
2668 NULL) }, /* Range 0x00 -> 0xFF */
2670 { SST(0x71, 0x00, SS_RDEF,
2671 "Decompression exception long: ASCQ = Algorithm ID") },
2673 { SST(0x71, 0xFF, SS_RDEF | SSQ_RANGE,
2674 NULL) }, /* Range 0x00 -> 0xFF */
2676 { SST(0x72, 0x00, SS_RDEF,
2677 "Session fixation error") },
2679 { SST(0x72, 0x01, SS_RDEF,
2680 "Session fixation error writing lead-in") },
2682 { SST(0x72, 0x02, SS_RDEF,
2683 "Session fixation error writing lead-out") },
2685 { SST(0x72, 0x03, SS_RDEF,
2686 "Session fixation error - incomplete track in session") },
2688 { SST(0x72, 0x04, SS_RDEF,
2689 "Empty or partially written reserved track") },
2691 { SST(0x72, 0x05, SS_RDEF, /* XXX TBD */
2692 "No more track reservations allowed") },
2694 { SST(0x72, 0x06, SS_RDEF, /* XXX TBD */
2695 "RMZ extension is not allowed") },
2697 { SST(0x72, 0x07, SS_RDEF, /* XXX TBD */
2698 "No more test zone extensions are allowed") },
2700 { SST(0x73, 0x00, SS_RDEF,
2701 "CD control error") },
2703 { SST(0x73, 0x01, SS_RDEF,
2704 "Power calibration area almost full") },
2706 { SST(0x73, 0x02, SS_FATAL | ENOSPC,
2707 "Power calibration area is full") },
2709 { SST(0x73, 0x03, SS_RDEF,
2710 "Power calibration area error") },
2712 { SST(0x73, 0x04, SS_RDEF,
2713 "Program memory area update failure") },
2715 { SST(0x73, 0x05, SS_RDEF,
2716 "Program memory area is full") },
2718 { SST(0x73, 0x06, SS_RDEF, /* XXX TBD */
2719 "RMA/PMA is almost full") },
2721 { SST(0x73, 0x10, SS_RDEF, /* XXX TBD */
2722 "Current power calibration area almost full") },
2724 { SST(0x73, 0x11, SS_RDEF, /* XXX TBD */
2725 "Current power calibration area is full") },
2727 { SST(0x73, 0x17, SS_RDEF, /* XXX TBD */
2730 { SST(0x74, 0x00, SS_RDEF, /* XXX TBD */
2731 "Security error") },
2733 { SST(0x74, 0x01, SS_RDEF, /* XXX TBD */
2734 "Unable to decrypt data") },
2736 { SST(0x74, 0x02, SS_RDEF, /* XXX TBD */
2737 "Unencrypted data encountered while decrypting") },
2739 { SST(0x74, 0x03, SS_RDEF, /* XXX TBD */
2740 "Incorrect data encryption key") },
2742 { SST(0x74, 0x04, SS_RDEF, /* XXX TBD */
2743 "Cryptographic integrity validation failed") },
2745 { SST(0x74, 0x05, SS_RDEF, /* XXX TBD */
2746 "Error decrypting data") },
2748 { SST(0x74, 0x06, SS_RDEF, /* XXX TBD */
2749 "Unknown signature verification key") },
2751 { SST(0x74, 0x07, SS_RDEF, /* XXX TBD */
2752 "Encryption parameters not useable") },
2754 { SST(0x74, 0x08, SS_RDEF, /* XXX TBD */
2755 "Digital signature validation failure") },
2757 { SST(0x74, 0x09, SS_RDEF, /* XXX TBD */
2758 "Encryption mode mismatch on read") },
2760 { SST(0x74, 0x0A, SS_RDEF, /* XXX TBD */
2761 "Encrypted block not raw read enabled") },
2763 { SST(0x74, 0x0B, SS_RDEF, /* XXX TBD */
2764 "Incorrect encryption parameters") },
2766 { SST(0x74, 0x0C, SS_RDEF, /* XXX TBD */
2767 "Unable to decrypt parameter list") },
2769 { SST(0x74, 0x0D, SS_RDEF, /* XXX TBD */
2770 "Encryption algorithm disabled") },
2772 { SST(0x74, 0x10, SS_RDEF, /* XXX TBD */
2773 "SA creation parameter value invalid") },
2775 { SST(0x74, 0x11, SS_RDEF, /* XXX TBD */
2776 "SA creation parameter value rejected") },
2778 { SST(0x74, 0x12, SS_RDEF, /* XXX TBD */
2779 "Invalid SA usage") },
2781 { SST(0x74, 0x21, SS_RDEF, /* XXX TBD */
2782 "Data encryption configuration prevented") },
2784 { SST(0x74, 0x30, SS_RDEF, /* XXX TBD */
2785 "SA creation parameter not supported") },
2787 { SST(0x74, 0x40, SS_RDEF, /* XXX TBD */
2788 "Authentication failed") },
2790 { SST(0x74, 0x61, SS_RDEF, /* XXX TBD */
2791 "External data encryption key manager access error") },
2793 { SST(0x74, 0x62, SS_RDEF, /* XXX TBD */
2794 "External data encryption key manager error") },
2796 { SST(0x74, 0x63, SS_RDEF, /* XXX TBD */
2797 "External data encryption key not found") },
2799 { SST(0x74, 0x64, SS_RDEF, /* XXX TBD */
2800 "External data encryption request not authorized") },
2802 { SST(0x74, 0x6E, SS_RDEF, /* XXX TBD */
2803 "External data encryption control timeout") },
2805 { SST(0x74, 0x6F, SS_RDEF, /* XXX TBD */
2806 "External data encryption control error") },
2808 { SST(0x74, 0x71, SS_RDEF, /* XXX TBD */
2809 "Logical unit access not authorized") },
2811 { SST(0x74, 0x79, SS_RDEF, /* XXX TBD */
2812 "Security conflict in translated device") }
2815 const int asc_table_size = sizeof(asc_table)/sizeof(asc_table[0]);
2824 ascentrycomp(const void *key, const void *member)
2828 const struct asc_table_entry *table_entry;
2830 asc = ((const struct asc_key *)key)->asc;
2831 ascq = ((const struct asc_key *)key)->ascq;
2832 table_entry = (const struct asc_table_entry *)member;
2834 if (asc >= table_entry->asc) {
2836 if (asc > table_entry->asc)
2839 if (ascq <= table_entry->ascq) {
2840 /* Check for ranges */
2841 if (ascq == table_entry->ascq
2842 || ((table_entry->action & SSQ_RANGE) != 0
2843 && ascq >= (table_entry - 1)->ascq))
2853 senseentrycomp(const void *key, const void *member)
2856 const struct sense_key_table_entry *table_entry;
2858 sense_key = *((const int *)key);
2859 table_entry = (const struct sense_key_table_entry *)member;
2861 if (sense_key >= table_entry->sense_key) {
2862 if (sense_key == table_entry->sense_key)
2870 fetchtableentries(int sense_key, int asc, int ascq,
2871 struct scsi_inquiry_data *inq_data,
2872 const struct sense_key_table_entry **sense_entry,
2873 const struct asc_table_entry **asc_entry)
2876 const struct asc_table_entry *asc_tables[2];
2877 const struct sense_key_table_entry *sense_tables[2];
2878 struct asc_key asc_ascq;
2879 size_t asc_tables_size[2];
2880 size_t sense_tables_size[2];
2882 int num_sense_tables;
2885 /* Default to failure */
2886 *sense_entry = NULL;
2889 if (inq_data != NULL)
2890 match = cam_quirkmatch((caddr_t)inq_data,
2891 (caddr_t)sense_quirk_table,
2892 sense_quirk_table_size,
2893 sizeof(*sense_quirk_table),
2894 scsi_inquiry_match);
2896 if (match != NULL) {
2897 struct scsi_sense_quirk_entry *quirk;
2899 quirk = (struct scsi_sense_quirk_entry *)match;
2900 asc_tables[0] = quirk->asc_info;
2901 asc_tables_size[0] = quirk->num_ascs;
2902 asc_tables[1] = asc_table;
2903 asc_tables_size[1] = asc_table_size;
2905 sense_tables[0] = quirk->sense_key_info;
2906 sense_tables_size[0] = quirk->num_sense_keys;
2907 sense_tables[1] = sense_key_table;
2908 sense_tables_size[1] = sense_key_table_size;
2909 num_sense_tables = 2;
2911 asc_tables[0] = asc_table;
2912 asc_tables_size[0] = asc_table_size;
2914 sense_tables[0] = sense_key_table;
2915 sense_tables_size[0] = sense_key_table_size;
2916 num_sense_tables = 1;
2920 asc_ascq.ascq = ascq;
2921 for (i = 0; i < num_asc_tables; i++) {
2924 found_entry = bsearch(&asc_ascq, asc_tables[i],
2926 sizeof(**asc_tables),
2930 *asc_entry = (struct asc_table_entry *)found_entry;
2935 for (i = 0; i < num_sense_tables; i++) {
2938 found_entry = bsearch(&sense_key, sense_tables[i],
2939 sense_tables_size[i],
2940 sizeof(**sense_tables),
2945 (struct sense_key_table_entry *)found_entry;
2952 scsi_sense_desc(int sense_key, int asc, int ascq,
2953 struct scsi_inquiry_data *inq_data,
2954 const char **sense_key_desc, const char **asc_desc)
2956 const struct asc_table_entry *asc_entry;
2957 const struct sense_key_table_entry *sense_entry;
2959 fetchtableentries(sense_key, asc, ascq,
2964 *sense_key_desc = sense_entry->desc;
2966 if (asc_entry != NULL)
2967 *asc_desc = asc_entry->desc;
2968 else if (asc >= 0x80 && asc <= 0xff)
2969 *asc_desc = "Vendor Specific ASC";
2970 else if (ascq >= 0x80 && ascq <= 0xff)
2971 *asc_desc = "Vendor Specific ASCQ";
2973 *asc_desc = "Reserved ASC/ASCQ pair";
2977 * Given sense and device type information, return the appropriate action.
2978 * If we do not understand the specific error as identified by the ASC/ASCQ
2979 * pair, fall back on the more generic actions derived from the sense key.
2982 scsi_error_action(struct ccb_scsiio *csio, struct scsi_inquiry_data *inq_data,
2983 u_int32_t sense_flags)
2985 const struct asc_table_entry *asc_entry;
2986 const struct sense_key_table_entry *sense_entry;
2987 int error_code, sense_key, asc, ascq;
2988 scsi_sense_action action;
2990 scsi_extract_sense(&csio->sense_data, &error_code,
2991 &sense_key, &asc, &ascq);
2993 if (error_code == SSD_DEFERRED_ERROR) {
2995 * XXX dufault@FreeBSD.org
2996 * This error doesn't relate to the command associated
2997 * with this request sense. A deferred error is an error
2998 * for a command that has already returned GOOD status
2999 * (see SCSI2 8.2.14.2).
3001 * By my reading of that section, it looks like the current
3002 * command has been cancelled, we should now clean things up
3003 * (hopefully recovering any lost data) and then retry the
3004 * current command. There are two easy choices, both wrong:
3006 * 1. Drop through (like we had been doing), thus treating
3007 * this as if the error were for the current command and
3008 * return and stop the current command.
3010 * 2. Issue a retry (like I made it do) thus hopefully
3011 * recovering the current transfer, and ignoring the
3012 * fact that we've dropped a command.
3014 * These should probably be handled in a device specific
3015 * sense handler or punted back up to a user mode daemon
3017 action = SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE;
3019 fetchtableentries(sense_key, asc, ascq,
3025 * Override the 'No additional Sense' entry (0,0)
3026 * with the error action of the sense key.
3028 if (asc_entry != NULL
3029 && (asc != 0 || ascq != 0))
3030 action = asc_entry->action;
3032 action = sense_entry->action;
3034 if (sense_key == SSD_KEY_RECOVERED_ERROR) {
3036 * The action succeeded but the device wants
3037 * the user to know that some recovery action
3040 action &= ~(SS_MASK|SSQ_MASK|SS_ERRMASK);
3041 action |= SS_NOP|SSQ_PRINT_SENSE;
3042 } else if (sense_key == SSD_KEY_ILLEGAL_REQUEST) {
3043 if ((sense_flags & SF_QUIET_IR) != 0)
3044 action &= ~SSQ_PRINT_SENSE;
3045 } else if (sense_key == SSD_KEY_UNIT_ATTENTION) {
3046 if ((sense_flags & SF_RETRY_UA) != 0
3047 && (action & SS_MASK) == SS_FAIL) {
3048 action &= ~(SS_MASK|SSQ_MASK);
3049 action |= SS_RETRY|SSQ_DECREMENT_COUNT|
3056 sense_flags |= SF_PRINT_ALWAYS;
3058 if ((sense_flags & SF_PRINT_ALWAYS) != 0)
3059 action |= SSQ_PRINT_SENSE;
3060 else if ((sense_flags & SF_NO_PRINT) != 0)
3061 action &= ~SSQ_PRINT_SENSE;
3067 scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string, size_t len)
3072 if (cdb_ptr == NULL)
3075 /* Silence warnings */
3079 * This is taken from the SCSI-3 draft spec.
3080 * (T10/1157D revision 0.3)
3081 * The top 3 bits of an opcode are the group code. The next 5 bits
3082 * are the command code.
3083 * Group 0: six byte commands
3084 * Group 1: ten byte commands
3085 * Group 2: ten byte commands
3087 * Group 4: sixteen byte commands
3088 * Group 5: twelve byte commands
3089 * Group 6: vendor specific
3090 * Group 7: vendor specific
3092 switch((*cdb_ptr >> 5) & 0x7) {
3103 /* in this case, just print out the opcode */
3114 for (i = 0; i < cdb_len; i++)
3115 snprintf(cdb_string + strlen(cdb_string),
3116 len - strlen(cdb_string), "%02hhx ", cdb_ptr[i]);
3122 scsi_status_string(struct ccb_scsiio *csio)
3124 switch(csio->scsi_status) {
3125 case SCSI_STATUS_OK:
3127 case SCSI_STATUS_CHECK_COND:
3128 return("Check Condition");
3129 case SCSI_STATUS_BUSY:
3131 case SCSI_STATUS_INTERMED:
3132 return("Intermediate");
3133 case SCSI_STATUS_INTERMED_COND_MET:
3134 return("Intermediate-Condition Met");
3135 case SCSI_STATUS_RESERV_CONFLICT:
3136 return("Reservation Conflict");
3137 case SCSI_STATUS_CMD_TERMINATED:
3138 return("Command Terminated");
3139 case SCSI_STATUS_QUEUE_FULL:
3140 return("Queue Full");
3141 case SCSI_STATUS_ACA_ACTIVE:
3142 return("ACA Active");
3143 case SCSI_STATUS_TASK_ABORTED:
3144 return("Task Aborted");
3146 static char unkstr[64];
3147 snprintf(unkstr, sizeof(unkstr), "Unknown %#x",
3155 * scsi_command_string() returns 0 for success and -1 for failure.
3159 scsi_command_string(struct ccb_scsiio *csio, struct sbuf *sb)
3160 #else /* !_KERNEL */
3162 scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio,
3164 #endif /* _KERNEL/!_KERNEL */
3166 struct scsi_inquiry_data *inq_data;
3167 char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1];
3169 struct ccb_getdev *cgd;
3170 #endif /* _KERNEL */
3173 if ((cgd = (struct ccb_getdev*)xpt_alloc_ccb_nowait()) == NULL)
3176 * Get the device information.
3178 xpt_setup_ccb(&cgd->ccb_h,
3180 CAM_PRIORITY_NORMAL);
3181 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
3182 xpt_action((union ccb *)cgd);
3185 * If the device is unconfigured, just pretend that it is a hard
3186 * drive. scsi_op_desc() needs this.
3188 if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
3189 cgd->inq_data.device = T_DIRECT;
3191 inq_data = &cgd->inq_data;
3193 #else /* !_KERNEL */
3195 inq_data = &device->inq_data;
3197 #endif /* _KERNEL/!_KERNEL */
3199 if ((csio->ccb_h.flags & CAM_CDB_POINTER) != 0) {
3200 sbuf_printf(sb, "%s. CDB: %s",
3201 scsi_op_desc(csio->cdb_io.cdb_ptr[0], inq_data),
3202 scsi_cdb_string(csio->cdb_io.cdb_ptr, cdb_str,
3205 sbuf_printf(sb, "%s. CDB: %s",
3206 scsi_op_desc(csio->cdb_io.cdb_bytes[0], inq_data),
3207 scsi_cdb_string(csio->cdb_io.cdb_bytes, cdb_str,
3212 xpt_free_ccb((union ccb *)cgd);
3220 * scsi_sense_sbuf() returns 0 for success and -1 for failure.
3224 scsi_sense_sbuf(struct ccb_scsiio *csio, struct sbuf *sb,
3225 scsi_sense_string_flags flags)
3226 #else /* !_KERNEL */
3228 scsi_sense_sbuf(struct cam_device *device, struct ccb_scsiio *csio,
3229 struct sbuf *sb, scsi_sense_string_flags flags)
3230 #endif /* _KERNEL/!_KERNEL */
3232 struct scsi_sense_data *sense;
3233 struct scsi_inquiry_data *inq_data;
3235 struct ccb_getdev *cgd;
3236 #endif /* _KERNEL */
3246 #endif /* !_KERNEL */
3247 if ((csio == NULL) || (sb == NULL))
3251 * If the CDB is a physical address, we can't deal with it..
3253 if ((csio->ccb_h.flags & CAM_CDB_PHYS) != 0)
3254 flags &= ~SSS_FLAG_PRINT_COMMAND;
3257 xpt_path_string(csio->ccb_h.path, path_str, sizeof(path_str));
3258 #else /* !_KERNEL */
3259 cam_path_string(device, path_str, sizeof(path_str));
3260 #endif /* _KERNEL/!_KERNEL */
3263 if ((cgd = (struct ccb_getdev*)xpt_alloc_ccb_nowait()) == NULL)
3266 * Get the device information.
3268 xpt_setup_ccb(&cgd->ccb_h,
3270 CAM_PRIORITY_NORMAL);
3271 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
3272 xpt_action((union ccb *)cgd);
3275 * If the device is unconfigured, just pretend that it is a hard
3276 * drive. scsi_op_desc() needs this.
3278 if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
3279 cgd->inq_data.device = T_DIRECT;
3281 inq_data = &cgd->inq_data;
3283 #else /* !_KERNEL */
3285 inq_data = &device->inq_data;
3287 #endif /* _KERNEL/!_KERNEL */
3291 if (flags & SSS_FLAG_PRINT_COMMAND) {
3293 sbuf_cat(sb, path_str);
3296 scsi_command_string(csio, sb);
3297 #else /* !_KERNEL */
3298 scsi_command_string(device, csio, sb);
3299 #endif /* _KERNEL/!_KERNEL */
3300 sbuf_printf(sb, "\n");
3304 * If the sense data is a physical pointer, forget it.
3306 if (csio->ccb_h.flags & CAM_SENSE_PTR) {
3307 if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
3309 xpt_free_ccb((union ccb*)cgd);
3310 #endif /* _KERNEL/!_KERNEL */
3314 * bcopy the pointer to avoid unaligned access
3315 * errors on finicky architectures. We don't
3316 * ensure that the sense data is pointer aligned.
3318 bcopy(&csio->sense_data, &sense,
3319 sizeof(struct scsi_sense_data *));
3323 * If the physical sense flag is set, but the sense pointer
3324 * is not also set, we assume that the user is an idiot and
3325 * return. (Well, okay, it could be that somehow, the
3326 * entire csio is physical, but we would have probably core
3327 * dumped on one of the bogus pointer deferences above
3330 if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
3332 xpt_free_ccb((union ccb*)cgd);
3333 #endif /* _KERNEL/!_KERNEL */
3336 sense = &csio->sense_data;
3340 sbuf_cat(sb, path_str);
3342 error_code = sense->error_code & SSD_ERRCODE;
3343 sense_key = sense->flags & SSD_KEY;
3345 sbuf_printf(sb, "SCSI sense: ");
3346 switch (error_code) {
3347 case SSD_DEFERRED_ERROR:
3348 sbuf_printf(sb, "Deferred error: ");
3351 case SSD_CURRENT_ERROR:
3353 const char *sense_key_desc;
3354 const char *asc_desc;
3356 asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;
3357 ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;
3358 scsi_sense_desc(sense_key, asc, ascq, inq_data,
3359 &sense_key_desc, &asc_desc);
3360 sbuf_cat(sb, sense_key_desc);
3362 info = scsi_4btoul(sense->info);
3364 if (sense->error_code & SSD_ERRCODE_VALID) {
3366 switch (sense_key) {
3367 case SSD_KEY_NOT_READY:
3368 case SSD_KEY_ILLEGAL_REQUEST:
3369 case SSD_KEY_UNIT_ATTENTION:
3370 case SSD_KEY_DATA_PROTECT:
3372 case SSD_KEY_BLANK_CHECK:
3373 sbuf_printf(sb, " req sz: %d (decimal)", info);
3377 if (sense->flags & SSD_ILI) {
3378 sbuf_printf(sb, " ILI (length "
3379 "mismatch): %d", info);
3382 sbuf_printf(sb, " info:%x",
3388 sbuf_printf(sb, " info?:%x", info);
3391 if (sense->extra_len >= 4) {
3392 if (bcmp(sense->cmd_spec_info, "\0\0\0\0", 4)) {
3393 sbuf_printf(sb, " csi:%x,%x,%x,%x",
3394 sense->cmd_spec_info[0],
3395 sense->cmd_spec_info[1],
3396 sense->cmd_spec_info[2],
3397 sense->cmd_spec_info[3]);
3401 sbuf_printf(sb, " asc:%x,%x (%s)", asc, ascq, asc_desc);
3403 if (sense->extra_len >= 7 && sense->fru) {
3404 sbuf_printf(sb, " field replaceable unit: %x",
3408 if ((sense->extra_len >= 10)
3409 && (sense->sense_key_spec[0] & SSD_SCS_VALID) != 0) {
3411 case SSD_KEY_ILLEGAL_REQUEST: {
3415 if (sense->sense_key_spec[0] & 0x40)
3422 /* Bit pointer is valid */
3423 if (sense->sense_key_spec[0] & 0x08)
3424 snprintf(tmpstr2, sizeof(tmpstr2),
3426 sense->sense_key_spec[0] & 0x7);
3427 sbuf_printf(sb, ": %s byte %d %sis invalid",
3428 bad_command ? "Command" : "Data",
3430 &sense->sense_key_spec[1]),
3434 case SSD_KEY_RECOVERED_ERROR:
3435 case SSD_KEY_HARDWARE_ERROR:
3436 case SSD_KEY_MEDIUM_ERROR:
3437 sbuf_printf(sb, " actual retry count: %d",
3439 &sense->sense_key_spec[1]));
3442 sbuf_printf(sb, " sks:%#x,%#x",
3443 sense->sense_key_spec[0],
3445 &sense->sense_key_spec[1]));
3453 sbuf_printf(sb, "Error code 0x%x", sense->error_code);
3454 if (sense->error_code & SSD_ERRCODE_VALID) {
3455 sbuf_printf(sb, " at block no. %d (decimal)",
3456 info = scsi_4btoul(sense->info));
3460 sbuf_printf(sb, "\n");
3463 xpt_free_ccb((union ccb*)cgd);
3464 #endif /* _KERNEL/!_KERNEL */
3472 scsi_sense_string(struct ccb_scsiio *csio, char *str, int str_len)
3473 #else /* !_KERNEL */
3475 scsi_sense_string(struct cam_device *device, struct ccb_scsiio *csio,
3476 char *str, int str_len)
3477 #endif /* _KERNEL/!_KERNEL */
3481 sbuf_new(&sb, str, str_len, 0);
3484 scsi_sense_sbuf(csio, &sb, SSS_FLAG_PRINT_COMMAND);
3485 #else /* !_KERNEL */
3486 scsi_sense_sbuf(device, csio, &sb, SSS_FLAG_PRINT_COMMAND);
3487 #endif /* _KERNEL/!_KERNEL */
3491 return(sbuf_data(&sb));
3496 scsi_sense_print(struct ccb_scsiio *csio)
3501 sbuf_new(&sb, str, sizeof(str), 0);
3503 scsi_sense_sbuf(csio, &sb, SSS_FLAG_PRINT_COMMAND);
3507 printf("%s", sbuf_data(&sb));
3510 #else /* !_KERNEL */
3512 scsi_sense_print(struct cam_device *device, struct ccb_scsiio *csio,
3518 if ((device == NULL) || (csio == NULL) || (ofile == NULL))
3521 sbuf_new(&sb, str, sizeof(str), 0);
3523 scsi_sense_sbuf(device, csio, &sb, SSS_FLAG_PRINT_COMMAND);
3527 fprintf(ofile, "%s", sbuf_data(&sb));
3530 #endif /* _KERNEL/!_KERNEL */
3533 * This function currently requires at least 36 bytes, or
3534 * SHORT_INQUIRY_LENGTH, worth of data to function properly. If this
3535 * function needs more or less data in the future, another length should be
3536 * defined in scsi_all.h to indicate the minimum amount of data necessary
3537 * for this routine to function properly.
3540 scsi_print_inquiry(struct scsi_inquiry_data *inq_data)
3543 char *dtype, *qtype;
3544 char vendor[16], product[48], revision[16], rstr[4];
3546 type = SID_TYPE(inq_data);
3549 * Figure out basic device type and qualifier.
3551 if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data)) {
3552 qtype = "(vendor-unique qualifier)";
3554 switch (SID_QUAL(inq_data)) {
3555 case SID_QUAL_LU_CONNECTED:
3559 case SID_QUAL_LU_OFFLINE:
3560 qtype = "(offline)";
3564 qtype = "(reserved qualifier)";
3567 case SID_QUAL_BAD_LU:
3568 qtype = "(LUN not supported)";
3575 dtype = "Direct Access";
3578 dtype = "Sequential Access";
3584 dtype = "Processor";
3602 dtype = "Communication";
3605 dtype = "Storage Array";
3608 dtype = "Enclosure Services";
3611 dtype = "Simplified Direct Access";
3614 dtype = "Optical Card Read/Write";
3617 dtype = "Object-Based Storage";
3620 dtype = "Automation/Drive Interface";
3623 dtype = "Uninstalled";
3630 cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor),
3632 cam_strvis(product, inq_data->product, sizeof(inq_data->product),
3634 cam_strvis(revision, inq_data->revision, sizeof(inq_data->revision),
3637 if (SID_ANSI_REV(inq_data) == SCSI_REV_CCS)
3638 bcopy("CCS", rstr, 4);
3640 snprintf(rstr, sizeof (rstr), "%d", SID_ANSI_REV(inq_data));
3641 printf("<%s %s %s> %s %s SCSI-%s device %s\n",
3642 vendor, product, revision,
3643 SID_IS_REMOVABLE(inq_data) ? "Removable" : "Fixed",
3644 dtype, rstr, qtype);
3648 * Table of syncrates that don't follow the "divisible by 4"
3649 * rule. This table will be expanded in future SCSI specs.
3652 u_int period_factor;
3653 u_int period; /* in 100ths of ns */
3654 } scsi_syncrates[] = {
3655 { 0x08, 625 }, /* FAST-160 */
3656 { 0x09, 1250 }, /* FAST-80 */
3657 { 0x0a, 2500 }, /* FAST-40 40MHz */
3658 { 0x0b, 3030 }, /* FAST-40 33MHz */
3659 { 0x0c, 5000 } /* FAST-20 */
3663 * Return the frequency in kHz corresponding to the given
3664 * sync period factor.
3667 scsi_calc_syncsrate(u_int period_factor)
3673 * It's a bug if period is zero, but if it is anyway, don't
3674 * die with a divide fault- instead return something which
3675 * 'approximates' async
3677 if (period_factor == 0) {
3681 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
3682 /* See if the period is in the "exception" table */
3683 for (i = 0; i < num_syncrates; i++) {
3685 if (period_factor == scsi_syncrates[i].period_factor) {
3687 return (100000000 / scsi_syncrates[i].period);
3692 * Wasn't in the table, so use the standard
3693 * 4 times conversion.
3695 return (10000000 / (period_factor * 4 * 10));
3699 * Return the SCSI sync parameter that corresponsd to
3700 * the passed in period in 10ths of ns.
3703 scsi_calc_syncparam(u_int period)
3709 return (~0); /* Async */
3711 /* Adjust for exception table being in 100ths. */
3713 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
3714 /* See if the period is in the "exception" table */
3715 for (i = 0; i < num_syncrates; i++) {
3717 if (period <= scsi_syncrates[i].period) {
3718 /* Period in 100ths of ns */
3719 return (scsi_syncrates[i].period_factor);
3724 * Wasn't in the table, so use the standard
3725 * 1/4 period in ns conversion.
3727 return (period/400);
3731 scsi_test_unit_ready(struct ccb_scsiio *csio, u_int32_t retries,
3732 void (*cbfcnp)(struct cam_periph *, union ccb *),
3733 u_int8_t tag_action, u_int8_t sense_len, u_int32_t timeout)
3735 struct scsi_test_unit_ready *scsi_cmd;
3748 scsi_cmd = (struct scsi_test_unit_ready *)&csio->cdb_io.cdb_bytes;
3749 bzero(scsi_cmd, sizeof(*scsi_cmd));
3750 scsi_cmd->opcode = TEST_UNIT_READY;
3754 scsi_request_sense(struct ccb_scsiio *csio, u_int32_t retries,
3755 void (*cbfcnp)(struct cam_periph *, union ccb *),
3756 void *data_ptr, u_int8_t dxfer_len, u_int8_t tag_action,
3757 u_int8_t sense_len, u_int32_t timeout)
3759 struct scsi_request_sense *scsi_cmd;
3772 scsi_cmd = (struct scsi_request_sense *)&csio->cdb_io.cdb_bytes;
3773 bzero(scsi_cmd, sizeof(*scsi_cmd));
3774 scsi_cmd->opcode = REQUEST_SENSE;
3775 scsi_cmd->length = dxfer_len;
3779 scsi_inquiry(struct ccb_scsiio *csio, u_int32_t retries,
3780 void (*cbfcnp)(struct cam_periph *, union ccb *),
3781 u_int8_t tag_action, u_int8_t *inq_buf, u_int32_t inq_len,
3782 int evpd, u_int8_t page_code, u_int8_t sense_len,
3785 struct scsi_inquiry *scsi_cmd;
3790 /*flags*/CAM_DIR_IN,
3792 /*data_ptr*/inq_buf,
3793 /*dxfer_len*/inq_len,
3798 scsi_cmd = (struct scsi_inquiry *)&csio->cdb_io.cdb_bytes;
3799 bzero(scsi_cmd, sizeof(*scsi_cmd));
3800 scsi_cmd->opcode = INQUIRY;
3802 scsi_cmd->byte2 |= SI_EVPD;
3803 scsi_cmd->page_code = page_code;
3806 * A 'transfer units' count of 256 is coded as
3807 * zero for all commands with a single byte count
3812 scsi_cmd->length = inq_len;
3816 scsi_mode_sense(struct ccb_scsiio *csio, u_int32_t retries,
3817 void (*cbfcnp)(struct cam_periph *, union ccb *),
3818 u_int8_t tag_action, int dbd, u_int8_t page_code,
3819 u_int8_t page, u_int8_t *param_buf, u_int32_t param_len,
3820 u_int8_t sense_len, u_int32_t timeout)
3823 scsi_mode_sense_len(csio, retries, cbfcnp, tag_action, dbd,
3824 page_code, page, param_buf, param_len, 0,
3825 sense_len, timeout);
3829 scsi_mode_sense_len(struct ccb_scsiio *csio, u_int32_t retries,
3830 void (*cbfcnp)(struct cam_periph *, union ccb *),
3831 u_int8_t tag_action, int dbd, u_int8_t page_code,
3832 u_int8_t page, u_int8_t *param_buf, u_int32_t param_len,
3833 int minimum_cmd_size, u_int8_t sense_len, u_int32_t timeout)
3838 * Use the smallest possible command to perform the operation.
3840 if ((param_len < 256)
3841 && (minimum_cmd_size < 10)) {
3843 * We can fit in a 6 byte cdb.
3845 struct scsi_mode_sense_6 *scsi_cmd;
3847 scsi_cmd = (struct scsi_mode_sense_6 *)&csio->cdb_io.cdb_bytes;
3848 bzero(scsi_cmd, sizeof(*scsi_cmd));
3849 scsi_cmd->opcode = MODE_SENSE_6;
3851 scsi_cmd->byte2 |= SMS_DBD;
3852 scsi_cmd->page = page_code | page;
3853 scsi_cmd->length = param_len;
3854 cdb_len = sizeof(*scsi_cmd);
3857 * Need a 10 byte cdb.
3859 struct scsi_mode_sense_10 *scsi_cmd;
3861 scsi_cmd = (struct scsi_mode_sense_10 *)&csio->cdb_io.cdb_bytes;
3862 bzero(scsi_cmd, sizeof(*scsi_cmd));
3863 scsi_cmd->opcode = MODE_SENSE_10;
3865 scsi_cmd->byte2 |= SMS_DBD;
3866 scsi_cmd->page = page_code | page;
3867 scsi_ulto2b(param_len, scsi_cmd->length);
3868 cdb_len = sizeof(*scsi_cmd);
3883 scsi_mode_select(struct ccb_scsiio *csio, u_int32_t retries,
3884 void (*cbfcnp)(struct cam_periph *, union ccb *),
3885 u_int8_t tag_action, int scsi_page_fmt, int save_pages,
3886 u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len,
3889 scsi_mode_select_len(csio, retries, cbfcnp, tag_action,
3890 scsi_page_fmt, save_pages, param_buf,
3891 param_len, 0, sense_len, timeout);
3895 scsi_mode_select_len(struct ccb_scsiio *csio, u_int32_t retries,
3896 void (*cbfcnp)(struct cam_periph *, union ccb *),
3897 u_int8_t tag_action, int scsi_page_fmt, int save_pages,
3898 u_int8_t *param_buf, u_int32_t param_len,
3899 int minimum_cmd_size, u_int8_t sense_len,
3905 * Use the smallest possible command to perform the operation.
3907 if ((param_len < 256)
3908 && (minimum_cmd_size < 10)) {
3910 * We can fit in a 6 byte cdb.
3912 struct scsi_mode_select_6 *scsi_cmd;
3914 scsi_cmd = (struct scsi_mode_select_6 *)&csio->cdb_io.cdb_bytes;
3915 bzero(scsi_cmd, sizeof(*scsi_cmd));
3916 scsi_cmd->opcode = MODE_SELECT_6;
3917 if (scsi_page_fmt != 0)
3918 scsi_cmd->byte2 |= SMS_PF;
3919 if (save_pages != 0)
3920 scsi_cmd->byte2 |= SMS_SP;
3921 scsi_cmd->length = param_len;
3922 cdb_len = sizeof(*scsi_cmd);
3925 * Need a 10 byte cdb.
3927 struct scsi_mode_select_10 *scsi_cmd;
3930 (struct scsi_mode_select_10 *)&csio->cdb_io.cdb_bytes;
3931 bzero(scsi_cmd, sizeof(*scsi_cmd));
3932 scsi_cmd->opcode = MODE_SELECT_10;
3933 if (scsi_page_fmt != 0)
3934 scsi_cmd->byte2 |= SMS_PF;
3935 if (save_pages != 0)
3936 scsi_cmd->byte2 |= SMS_SP;
3937 scsi_ulto2b(param_len, scsi_cmd->length);
3938 cdb_len = sizeof(*scsi_cmd);
3953 scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries,
3954 void (*cbfcnp)(struct cam_periph *, union ccb *),
3955 u_int8_t tag_action, u_int8_t page_code, u_int8_t page,
3956 int save_pages, int ppc, u_int32_t paramptr,
3957 u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len,
3960 struct scsi_log_sense *scsi_cmd;
3963 scsi_cmd = (struct scsi_log_sense *)&csio->cdb_io.cdb_bytes;
3964 bzero(scsi_cmd, sizeof(*scsi_cmd));
3965 scsi_cmd->opcode = LOG_SENSE;
3966 scsi_cmd->page = page_code | page;
3967 if (save_pages != 0)
3968 scsi_cmd->byte2 |= SLS_SP;
3970 scsi_cmd->byte2 |= SLS_PPC;
3971 scsi_ulto2b(paramptr, scsi_cmd->paramptr);
3972 scsi_ulto2b(param_len, scsi_cmd->length);
3973 cdb_len = sizeof(*scsi_cmd);
3978 /*flags*/CAM_DIR_IN,
3980 /*data_ptr*/param_buf,
3981 /*dxfer_len*/param_len,
3988 scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries,
3989 void (*cbfcnp)(struct cam_periph *, union ccb *),
3990 u_int8_t tag_action, u_int8_t page_code, int save_pages,
3991 int pc_reset, u_int8_t *param_buf, u_int32_t param_len,
3992 u_int8_t sense_len, u_int32_t timeout)
3994 struct scsi_log_select *scsi_cmd;
3997 scsi_cmd = (struct scsi_log_select *)&csio->cdb_io.cdb_bytes;
3998 bzero(scsi_cmd, sizeof(*scsi_cmd));
3999 scsi_cmd->opcode = LOG_SELECT;
4000 scsi_cmd->page = page_code & SLS_PAGE_CODE;
4001 if (save_pages != 0)
4002 scsi_cmd->byte2 |= SLS_SP;
4004 scsi_cmd->byte2 |= SLS_PCR;
4005 scsi_ulto2b(param_len, scsi_cmd->length);
4006 cdb_len = sizeof(*scsi_cmd);
4011 /*flags*/CAM_DIR_OUT,
4013 /*data_ptr*/param_buf,
4014 /*dxfer_len*/param_len,
4021 * Prevent or allow the user to remove the media
4024 scsi_prevent(struct ccb_scsiio *csio, u_int32_t retries,
4025 void (*cbfcnp)(struct cam_periph *, union ccb *),
4026 u_int8_t tag_action, u_int8_t action,
4027 u_int8_t sense_len, u_int32_t timeout)
4029 struct scsi_prevent *scsi_cmd;
4034 /*flags*/CAM_DIR_NONE,
4042 scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes;
4043 bzero(scsi_cmd, sizeof(*scsi_cmd));
4044 scsi_cmd->opcode = PREVENT_ALLOW;
4045 scsi_cmd->how = action;
4048 /* XXX allow specification of address and PMI bit and LBA */
4050 scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries,
4051 void (*cbfcnp)(struct cam_periph *, union ccb *),
4052 u_int8_t tag_action,
4053 struct scsi_read_capacity_data *rcap_buf,
4054 u_int8_t sense_len, u_int32_t timeout)
4056 struct scsi_read_capacity *scsi_cmd;
4061 /*flags*/CAM_DIR_IN,
4063 /*data_ptr*/(u_int8_t *)rcap_buf,
4064 /*dxfer_len*/sizeof(*rcap_buf),
4069 scsi_cmd = (struct scsi_read_capacity *)&csio->cdb_io.cdb_bytes;
4070 bzero(scsi_cmd, sizeof(*scsi_cmd));
4071 scsi_cmd->opcode = READ_CAPACITY;
4075 scsi_read_capacity_16(struct ccb_scsiio *csio, uint32_t retries,
4076 void (*cbfcnp)(struct cam_periph *, union ccb *),
4077 uint8_t tag_action, uint64_t lba, int reladr, int pmi,
4078 struct scsi_read_capacity_data_long *rcap_buf,
4079 uint8_t sense_len, uint32_t timeout)
4081 struct scsi_read_capacity_16 *scsi_cmd;
4087 /*flags*/CAM_DIR_IN,
4089 /*data_ptr*/(u_int8_t *)rcap_buf,
4090 /*dxfer_len*/sizeof(*rcap_buf),
4094 scsi_cmd = (struct scsi_read_capacity_16 *)&csio->cdb_io.cdb_bytes;
4095 bzero(scsi_cmd, sizeof(*scsi_cmd));
4096 scsi_cmd->opcode = SERVICE_ACTION_IN;
4097 scsi_cmd->service_action = SRC16_SERVICE_ACTION;
4098 scsi_u64to8b(lba, scsi_cmd->addr);
4099 scsi_ulto4b(sizeof(*rcap_buf), scsi_cmd->alloc_len);
4101 reladr |= SRC16_PMI;
4103 reladr |= SRC16_RELADR;
4107 scsi_report_luns(struct ccb_scsiio *csio, u_int32_t retries,
4108 void (*cbfcnp)(struct cam_periph *, union ccb *),
4109 u_int8_t tag_action, u_int8_t select_report,
4110 struct scsi_report_luns_data *rpl_buf, u_int32_t alloc_len,
4111 u_int8_t sense_len, u_int32_t timeout)
4113 struct scsi_report_luns *scsi_cmd;
4118 /*flags*/CAM_DIR_IN,
4120 /*data_ptr*/(u_int8_t *)rpl_buf,
4121 /*dxfer_len*/alloc_len,
4125 scsi_cmd = (struct scsi_report_luns *)&csio->cdb_io.cdb_bytes;
4126 bzero(scsi_cmd, sizeof(*scsi_cmd));
4127 scsi_cmd->opcode = REPORT_LUNS;
4128 scsi_cmd->select_report = select_report;
4129 scsi_ulto4b(alloc_len, scsi_cmd->length);
4133 scsi_report_target_group(struct ccb_scsiio *csio, u_int32_t retries,
4134 void (*cbfcnp)(struct cam_periph *, union ccb *),
4135 u_int8_t tag_action, u_int8_t pdf,
4136 void *buf, u_int32_t alloc_len,
4137 u_int8_t sense_len, u_int32_t timeout)
4139 struct scsi_target_group *scsi_cmd;
4144 /*flags*/CAM_DIR_IN,
4146 /*data_ptr*/(u_int8_t *)buf,
4147 /*dxfer_len*/alloc_len,
4151 scsi_cmd = (struct scsi_target_group *)&csio->cdb_io.cdb_bytes;
4152 bzero(scsi_cmd, sizeof(*scsi_cmd));
4153 scsi_cmd->opcode = MAINTENANCE_IN;
4154 scsi_cmd->service_action = REPORT_TARGET_PORT_GROUPS | pdf;
4155 scsi_ulto4b(alloc_len, scsi_cmd->length);
4159 scsi_set_target_group(struct ccb_scsiio *csio, u_int32_t retries,
4160 void (*cbfcnp)(struct cam_periph *, union ccb *),
4161 u_int8_t tag_action, void *buf, u_int32_t alloc_len,
4162 u_int8_t sense_len, u_int32_t timeout)
4164 struct scsi_target_group *scsi_cmd;
4169 /*flags*/CAM_DIR_OUT,
4171 /*data_ptr*/(u_int8_t *)buf,
4172 /*dxfer_len*/alloc_len,
4176 scsi_cmd = (struct scsi_target_group *)&csio->cdb_io.cdb_bytes;
4177 bzero(scsi_cmd, sizeof(*scsi_cmd));
4178 scsi_cmd->opcode = MAINTENANCE_OUT;
4179 scsi_cmd->service_action = SET_TARGET_PORT_GROUPS;
4180 scsi_ulto4b(alloc_len, scsi_cmd->length);
4184 * Syncronize the media to the contents of the cache for
4185 * the given lba/count pair. Specifying 0/0 means sync
4189 scsi_synchronize_cache(struct ccb_scsiio *csio, u_int32_t retries,
4190 void (*cbfcnp)(struct cam_periph *, union ccb *),
4191 u_int8_t tag_action, u_int32_t begin_lba,
4192 u_int16_t lb_count, u_int8_t sense_len,
4195 struct scsi_sync_cache *scsi_cmd;
4200 /*flags*/CAM_DIR_NONE,
4208 scsi_cmd = (struct scsi_sync_cache *)&csio->cdb_io.cdb_bytes;
4209 bzero(scsi_cmd, sizeof(*scsi_cmd));
4210 scsi_cmd->opcode = SYNCHRONIZE_CACHE;
4211 scsi_ulto4b(begin_lba, scsi_cmd->begin_lba);
4212 scsi_ulto2b(lb_count, scsi_cmd->lb_count);
4216 scsi_read_write(struct ccb_scsiio *csio, u_int32_t retries,
4217 void (*cbfcnp)(struct cam_periph *, union ccb *),
4218 u_int8_t tag_action, int readop, u_int8_t byte2,
4219 int minimum_cmd_size, u_int64_t lba, u_int32_t block_count,
4220 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
4225 * Use the smallest possible command to perform the operation
4226 * as some legacy hardware does not support the 10 byte commands.
4227 * If any of the bits in byte2 is set, we have to go with a larger
4230 if ((minimum_cmd_size < 10)
4231 && ((lba & 0x1fffff) == lba)
4232 && ((block_count & 0xff) == block_count)
4235 * We can fit in a 6 byte cdb.
4237 struct scsi_rw_6 *scsi_cmd;
4239 scsi_cmd = (struct scsi_rw_6 *)&csio->cdb_io.cdb_bytes;
4240 scsi_cmd->opcode = readop ? READ_6 : WRITE_6;
4241 scsi_ulto3b(lba, scsi_cmd->addr);
4242 scsi_cmd->length = block_count & 0xff;
4243 scsi_cmd->control = 0;
4244 cdb_len = sizeof(*scsi_cmd);
4246 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4247 ("6byte: %x%x%x:%d:%d\n", scsi_cmd->addr[0],
4248 scsi_cmd->addr[1], scsi_cmd->addr[2],
4249 scsi_cmd->length, dxfer_len));
4250 } else if ((minimum_cmd_size < 12)
4251 && ((block_count & 0xffff) == block_count)
4252 && ((lba & 0xffffffff) == lba)) {
4254 * Need a 10 byte cdb.
4256 struct scsi_rw_10 *scsi_cmd;
4258 scsi_cmd = (struct scsi_rw_10 *)&csio->cdb_io.cdb_bytes;
4259 scsi_cmd->opcode = readop ? READ_10 : WRITE_10;
4260 scsi_cmd->byte2 = byte2;
4261 scsi_ulto4b(lba, scsi_cmd->addr);
4262 scsi_cmd->reserved = 0;
4263 scsi_ulto2b(block_count, scsi_cmd->length);
4264 scsi_cmd->control = 0;
4265 cdb_len = sizeof(*scsi_cmd);
4267 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4268 ("10byte: %x%x%x%x:%x%x: %d\n", scsi_cmd->addr[0],
4269 scsi_cmd->addr[1], scsi_cmd->addr[2],
4270 scsi_cmd->addr[3], scsi_cmd->length[0],
4271 scsi_cmd->length[1], dxfer_len));
4272 } else if ((minimum_cmd_size < 16)
4273 && ((block_count & 0xffffffff) == block_count)
4274 && ((lba & 0xffffffff) == lba)) {
4276 * The block count is too big for a 10 byte CDB, use a 12
4279 struct scsi_rw_12 *scsi_cmd;
4281 scsi_cmd = (struct scsi_rw_12 *)&csio->cdb_io.cdb_bytes;
4282 scsi_cmd->opcode = readop ? READ_12 : WRITE_12;
4283 scsi_cmd->byte2 = byte2;
4284 scsi_ulto4b(lba, scsi_cmd->addr);
4285 scsi_cmd->reserved = 0;
4286 scsi_ulto4b(block_count, scsi_cmd->length);
4287 scsi_cmd->control = 0;
4288 cdb_len = sizeof(*scsi_cmd);
4290 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4291 ("12byte: %x%x%x%x:%x%x%x%x: %d\n", scsi_cmd->addr[0],
4292 scsi_cmd->addr[1], scsi_cmd->addr[2],
4293 scsi_cmd->addr[3], scsi_cmd->length[0],
4294 scsi_cmd->length[1], scsi_cmd->length[2],
4295 scsi_cmd->length[3], dxfer_len));
4298 * 16 byte CDB. We'll only get here if the LBA is larger
4299 * than 2^32, or if the user asks for a 16 byte command.
4301 struct scsi_rw_16 *scsi_cmd;
4303 scsi_cmd = (struct scsi_rw_16 *)&csio->cdb_io.cdb_bytes;
4304 scsi_cmd->opcode = readop ? READ_16 : WRITE_16;
4305 scsi_cmd->byte2 = byte2;
4306 scsi_u64to8b(lba, scsi_cmd->addr);
4307 scsi_cmd->reserved = 0;
4308 scsi_ulto4b(block_count, scsi_cmd->length);
4309 scsi_cmd->control = 0;
4310 cdb_len = sizeof(*scsi_cmd);
4315 /*flags*/readop ? CAM_DIR_IN : CAM_DIR_OUT,
4325 scsi_write_same(struct ccb_scsiio *csio, u_int32_t retries,
4326 void (*cbfcnp)(struct cam_periph *, union ccb *),
4327 u_int8_t tag_action, u_int8_t byte2,
4328 int minimum_cmd_size, u_int64_t lba, u_int32_t block_count,
4329 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
4333 if ((minimum_cmd_size < 16) &&
4334 ((block_count & 0xffff) == block_count) &&
4335 ((lba & 0xffffffff) == lba)) {
4337 * Need a 10 byte cdb.
4339 struct scsi_write_same_10 *scsi_cmd;
4341 scsi_cmd = (struct scsi_write_same_10 *)&csio->cdb_io.cdb_bytes;
4342 scsi_cmd->opcode = WRITE_SAME_10;
4343 scsi_cmd->byte2 = byte2;
4344 scsi_ulto4b(lba, scsi_cmd->addr);
4345 scsi_cmd->group = 0;
4346 scsi_ulto2b(block_count, scsi_cmd->length);
4347 scsi_cmd->control = 0;
4348 cdb_len = sizeof(*scsi_cmd);
4350 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4351 ("10byte: %x%x%x%x:%x%x: %d\n", scsi_cmd->addr[0],
4352 scsi_cmd->addr[1], scsi_cmd->addr[2],
4353 scsi_cmd->addr[3], scsi_cmd->length[0],
4354 scsi_cmd->length[1], dxfer_len));
4357 * 16 byte CDB. We'll only get here if the LBA is larger
4358 * than 2^32, or if the user asks for a 16 byte command.
4360 struct scsi_write_same_16 *scsi_cmd;
4362 scsi_cmd = (struct scsi_write_same_16 *)&csio->cdb_io.cdb_bytes;
4363 scsi_cmd->opcode = WRITE_SAME_16;
4364 scsi_cmd->byte2 = byte2;
4365 scsi_u64to8b(lba, scsi_cmd->addr);
4366 scsi_ulto4b(block_count, scsi_cmd->length);
4367 scsi_cmd->group = 0;
4368 scsi_cmd->control = 0;
4369 cdb_len = sizeof(*scsi_cmd);
4371 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
4372 ("16byte: %x%x%x%x%x%x%x%x:%x%x%x%x: %d\n",
4373 scsi_cmd->addr[0], scsi_cmd->addr[1],
4374 scsi_cmd->addr[2], scsi_cmd->addr[3],
4375 scsi_cmd->addr[4], scsi_cmd->addr[5],
4376 scsi_cmd->addr[6], scsi_cmd->addr[7],
4377 scsi_cmd->length[0], scsi_cmd->length[1],
4378 scsi_cmd->length[2], scsi_cmd->length[3],
4384 /*flags*/CAM_DIR_OUT,
4394 scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries,
4395 void (*cbfcnp)(struct cam_periph *, union ccb *),
4396 u_int32_t flags, u_int8_t tag_action,
4397 u_int8_t protocol, u_int8_t ata_flags, u_int16_t features,
4398 u_int16_t sector_count, uint64_t lba, u_int8_t command,
4399 u_int8_t control, u_int8_t *data_ptr, u_int16_t dxfer_len,
4400 u_int8_t sense_len, u_int32_t timeout)
4402 struct ata_pass_16 *ata_cmd;
4404 ata_cmd = (struct ata_pass_16 *)&csio->cdb_io.cdb_bytes;
4405 ata_cmd->opcode = ATA_PASS_16;
4406 ata_cmd->protocol = protocol;
4407 ata_cmd->flags = ata_flags;
4408 ata_cmd->features_ext = features >> 8;
4409 ata_cmd->features = features;
4410 ata_cmd->sector_count_ext = sector_count >> 8;
4411 ata_cmd->sector_count = sector_count;
4412 ata_cmd->lba_low = lba;
4413 ata_cmd->lba_mid = lba >> 8;
4414 ata_cmd->lba_high = lba >> 16;
4415 ata_cmd->device = ATA_DEV_LBA;
4416 if (protocol & AP_EXTEND) {
4417 ata_cmd->lba_low_ext = lba >> 24;
4418 ata_cmd->lba_mid_ext = lba >> 32;
4419 ata_cmd->lba_high_ext = lba >> 40;
4421 ata_cmd->device |= (lba >> 24) & 0x0f;
4422 ata_cmd->command = command;
4423 ata_cmd->control = control;
4438 scsi_unmap(struct ccb_scsiio *csio, u_int32_t retries,
4439 void (*cbfcnp)(struct cam_periph *, union ccb *),
4440 u_int8_t tag_action, u_int8_t byte2,
4441 u_int8_t *data_ptr, u_int16_t dxfer_len, u_int8_t sense_len,
4444 struct scsi_unmap *scsi_cmd;
4446 scsi_cmd = (struct scsi_unmap *)&csio->cdb_io.cdb_bytes;
4447 scsi_cmd->opcode = UNMAP;
4448 scsi_cmd->byte2 = byte2;
4449 scsi_ulto4b(0, scsi_cmd->reserved);
4450 scsi_cmd->group = 0;
4451 scsi_ulto2b(dxfer_len, scsi_cmd->length);
4452 scsi_cmd->control = 0;
4457 /*flags*/CAM_DIR_OUT,
4467 scsi_start_stop(struct ccb_scsiio *csio, u_int32_t retries,
4468 void (*cbfcnp)(struct cam_periph *, union ccb *),
4469 u_int8_t tag_action, int start, int load_eject,
4470 int immediate, u_int8_t sense_len, u_int32_t timeout)
4472 struct scsi_start_stop_unit *scsi_cmd;
4473 int extra_flags = 0;
4475 scsi_cmd = (struct scsi_start_stop_unit *)&csio->cdb_io.cdb_bytes;
4476 bzero(scsi_cmd, sizeof(*scsi_cmd));
4477 scsi_cmd->opcode = START_STOP_UNIT;
4479 scsi_cmd->how |= SSS_START;
4480 /* it takes a lot of power to start a drive */
4481 extra_flags |= CAM_HIGH_POWER;
4483 if (load_eject != 0)
4484 scsi_cmd->how |= SSS_LOEJ;
4486 scsi_cmd->byte2 |= SSS_IMMED;
4491 /*flags*/CAM_DIR_NONE | extra_flags,
4503 * Try make as good a match as possible with
4504 * available sub drivers
4507 scsi_inquiry_match(caddr_t inqbuffer, caddr_t table_entry)
4509 struct scsi_inquiry_pattern *entry;
4510 struct scsi_inquiry_data *inq;
4512 entry = (struct scsi_inquiry_pattern *)table_entry;
4513 inq = (struct scsi_inquiry_data *)inqbuffer;
4515 if (((SID_TYPE(inq) == entry->type)
4516 || (entry->type == T_ANY))
4517 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
4518 : entry->media_type & SIP_MEDIA_FIXED)
4519 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
4520 && (cam_strmatch(inq->product, entry->product,
4521 sizeof(inq->product)) == 0)
4522 && (cam_strmatch(inq->revision, entry->revision,
4523 sizeof(inq->revision)) == 0)) {
4530 * Try make as good a match as possible with
4531 * available sub drivers
4534 scsi_static_inquiry_match(caddr_t inqbuffer, caddr_t table_entry)
4536 struct scsi_static_inquiry_pattern *entry;
4537 struct scsi_inquiry_data *inq;
4539 entry = (struct scsi_static_inquiry_pattern *)table_entry;
4540 inq = (struct scsi_inquiry_data *)inqbuffer;
4542 if (((SID_TYPE(inq) == entry->type)
4543 || (entry->type == T_ANY))
4544 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
4545 : entry->media_type & SIP_MEDIA_FIXED)
4546 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
4547 && (cam_strmatch(inq->product, entry->product,
4548 sizeof(inq->product)) == 0)
4549 && (cam_strmatch(inq->revision, entry->revision,
4550 sizeof(inq->revision)) == 0)) {
4558 init_scsi_delay(void)
4563 TUNABLE_INT_FETCH("kern.cam.scsi_delay", &delay);
4565 if (set_scsi_delay(delay) != 0) {
4566 printf("cam: invalid value for tunable kern.cam.scsi_delay\n");
4567 set_scsi_delay(SCSI_DELAY);
4570 SYSINIT(scsi_delay, SI_SUB_TUNABLES, SI_ORDER_ANY, init_scsi_delay, NULL);
4573 sysctl_scsi_delay(SYSCTL_HANDLER_ARGS)
4578 error = sysctl_handle_int(oidp, &delay, 0, req);
4579 if (error != 0 || req->newptr == NULL)
4581 return (set_scsi_delay(delay));
4583 SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay, CTLTYPE_INT|CTLFLAG_RW,
4584 0, 0, sysctl_scsi_delay, "I",
4585 "Delay to allow devices to settle after a SCSI bus reset (ms)");
4588 set_scsi_delay(int delay)
4591 * If someone sets this to 0, we assume that they want the
4592 * minimum allowable bus settle delay.
4595 printf("cam: using minimum scsi_delay (%dms)\n",
4597 delay = SCSI_MIN_DELAY;
4599 if (delay < SCSI_MIN_DELAY)
4604 #endif /* _KERNEL */