• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/scsi/bfa/include/protocol/
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __SCSI_H__
19#define __SCSI_H__
20
21#include <protocol/types.h>
22
23#pragma pack(1)
24
25/*
26 * generic SCSI cdb definition
27 */
28#define SCSI_MAX_CDBLEN     16
29struct scsi_cdb_s{
30	u8         scsi_cdb[SCSI_MAX_CDBLEN];
31};
32
33/*
34 * scsi lun serial number definition
35 */
36#define SCSI_LUN_SN_LEN     32
37struct scsi_lun_sn_s{
38	u8         lun_sn[SCSI_LUN_SN_LEN];
39};
40
41/*
42 * SCSI Direct Access Commands
43 */
44enum {
45	SCSI_OP_TEST_UNIT_READY		= 0x00,
46	SCSI_OP_REQUEST_SENSE		= 0x03,
47	SCSI_OP_FORMAT_UNIT		= 0x04,
48	SCSI_OP_READ6			= 0x08,
49	SCSI_OP_WRITE6			= 0x0A,
50	SCSI_OP_WRITE_FILEMARKS		= 0x10,
51	SCSI_OP_INQUIRY			= 0x12,
52	SCSI_OP_MODE_SELECT6		= 0x15,
53	SCSI_OP_RESERVE6		= 0x16,
54	SCSI_OP_RELEASE6		= 0x17,
55	SCSI_OP_MODE_SENSE6		= 0x1A,
56	SCSI_OP_START_STOP_UNIT		= 0x1B,
57	SCSI_OP_SEND_DIAGNOSTIC		= 0x1D,
58	SCSI_OP_READ_CAPACITY		= 0x25,
59	SCSI_OP_READ10			= 0x28,
60	SCSI_OP_WRITE10			= 0x2A,
61	SCSI_OP_VERIFY10		= 0x2F,
62	SCSI_OP_READ_DEFECT_DATA	= 0x37,
63	SCSI_OP_LOG_SELECT		= 0x4C,
64	SCSI_OP_LOG_SENSE		= 0x4D,
65	SCSI_OP_MODE_SELECT10		= 0x55,
66	SCSI_OP_RESERVE10		= 0x56,
67	SCSI_OP_RELEASE10		= 0x57,
68	SCSI_OP_MODE_SENSE10		= 0x5A,
69	SCSI_OP_PER_RESERVE_IN		= 0x5E,
70	SCSI_OP_PER_RESERVE_OUR		= 0x5E,
71	SCSI_OP_READ16			= 0x88,
72	SCSI_OP_WRITE16			= 0x8A,
73	SCSI_OP_VERIFY16		= 0x8F,
74	SCSI_OP_READ_CAPACITY16		= 0x9E,
75	SCSI_OP_REPORT_LUNS		= 0xA0,
76	SCSI_OP_READ12			= 0xA8,
77	SCSI_OP_WRITE12			= 0xAA,
78	SCSI_OP_UNDEF			= 0xFF,
79};
80
81/*
82 * SCSI START_STOP_UNIT command
83 */
84struct scsi_start_stop_unit_s{
85	u8         opcode;
86#ifdef __BIGENDIAN
87	u8         lun:3;
88	u8         reserved1:4;
89	u8         immed:1;
90#else
91	u8         immed:1;
92	u8         reserved1:4;
93	u8         lun:3;
94#endif
95	u8         reserved2;
96	u8         reserved3;
97#ifdef __BIGENDIAN
98	u8         power_conditions:4;
99	u8         reserved4:2;
100	u8         loEj:1;
101	u8         start:1;
102#else
103	u8         start:1;
104	u8         loEj:1;
105	u8         reserved4:2;
106	u8         power_conditions:4;
107#endif
108	u8         control;
109};
110
111/*
112 * SCSI SEND_DIAGNOSTIC command
113 */
114struct scsi_send_diagnostic_s{
115	u8         opcode;
116#ifdef __BIGENDIAN
117	u8         self_test_code:3;
118	u8         pf:1;
119	u8         reserved1:1;
120	u8         self_test:1;
121	u8         dev_offl:1;
122	u8         unit_offl:1;
123#else
124	u8         unit_offl:1;
125	u8         dev_offl:1;
126	u8         self_test:1;
127	u8         reserved1:1;
128	u8         pf:1;
129	u8         self_test_code:3;
130#endif
131	u8         reserved2;
132
133	u8         param_list_length[2];	/* MSB first */
134	u8         control;
135
136};
137
138/*
139 * SCSI READ10/WRITE10 commands
140 */
141struct scsi_rw10_s{
142	u8         opcode;
143#ifdef __BIGENDIAN
144	u8         lun:3;
145	u8         dpo:1;	/* Disable Page Out */
146	u8         fua:1;	/* Force Unit Access */
147	u8         reserved1:2;
148	u8         rel_adr:1;	/* relative address */
149#else
150	u8         rel_adr:1;
151	u8         reserved1:2;
152	u8         fua:1;
153	u8         dpo:1;
154	u8         lun:3;
155#endif
156	u8         lba0;	/* logical block address - MSB */
157	u8         lba1;
158	u8         lba2;
159	u8         lba3;	/* LSB */
160	u8         reserved3;
161	u8         xfer_length0;	/* transfer length in blocks - MSB */
162	u8         xfer_length1;	/* LSB */
163	u8         control;
164};
165
166#define SCSI_CDB10_GET_LBA(cdb)                     \
167    (((cdb)->lba0 << 24) | ((cdb)->lba1 << 16) |    \
168     ((cdb)->lba2 << 8) | (cdb)->lba3)
169
170#define SCSI_CDB10_SET_LBA(cdb, lba) {      \
171    (cdb)->lba0 = lba >> 24;            \
172    (cdb)->lba1 = (lba >> 16) & 0xFF;   \
173    (cdb)->lba2 = (lba >> 8) & 0xFF;    \
174    (cdb)->lba3 = lba & 0xFF;           \
175}
176
177#define SCSI_CDB10_GET_TL(cdb)  \
178    ((cdb)->xfer_length0 << 8 | (cdb)->xfer_length1)
179#define SCSI_CDB10_SET_TL(cdb, tl) {      \
180    (cdb)->xfer_length0 = tl >> 8;       \
181    (cdb)->xfer_length1 = tl & 0xFF;     \
182}
183
184/*
185 * SCSI READ6/WRITE6 commands
186 */
187struct scsi_rw6_s{
188	u8         opcode;
189#ifdef __BIGENDIAN
190	u8         lun:3;
191	u8         lba0:5;		/* MSb */
192#else
193	u8         lba0:5;		/* MSb */
194	u8         lun:3;
195#endif
196	u8         lba1;
197	u8         lba2;		/* LSB */
198	u8         xfer_length;
199	u8         control;
200};
201
202#define SCSI_TAPE_CDB6_GET_TL(cdb)              \
203    (((cdb)->tl0 << 16) | ((cdb)->tl1 << 8) | (cdb)->tl2)
204
205#define SCSI_TAPE_CDB6_SET_TL(cdb, tl) {      \
206    (cdb)->tl0 = tl >> 16;            \
207    (cdb)->tl1 = (tl >> 8) & 0xFF;    \
208    (cdb)->tl2 = tl & 0xFF;           \
209}
210
211/*
212 * SCSI sequential (TAPE) wrtie command
213 */
214struct scsi_tape_wr_s{
215	u8         opcode;
216#ifdef __BIGENDIAN
217	u8         rsvd:7;
218	u8         fixed:1;	/* MSb */
219#else
220	u8         fixed:1;	/* MSb */
221	u8         rsvd:7;
222#endif
223	u8         tl0;		/* Msb */
224	u8         tl1;
225	u8         tl2;		/* Lsb */
226
227	u8         control;
228};
229
230#define SCSI_CDB6_GET_LBA(cdb)              \
231    (((cdb)->lba0 << 16) | ((cdb)->lba1 << 8) | (cdb)->lba2)
232
233#define SCSI_CDB6_SET_LBA(cdb, lba) {      \
234    (cdb)->lba0 = lba >> 16;            \
235    (cdb)->lba1 = (lba >> 8) & 0xFF;    \
236    (cdb)->lba2 = lba & 0xFF;           \
237}
238
239#define SCSI_CDB6_GET_TL(cdb) ((cdb)->xfer_length)
240#define SCSI_CDB6_SET_TL(cdb, tl) {      \
241    (cdb)->xfer_length = tl;         \
242}
243
244/*
245 * SCSI sense data format
246 */
247struct scsi_sense_s{
248#ifdef __BIGENDIAN
249	u8         valid:1;
250	u8         rsp_code:7;
251#else
252	u8         rsp_code:7;
253	u8         valid:1;
254#endif
255	u8         seg_num;
256#ifdef __BIGENDIAN
257	u8         file_mark:1;
258	u8         eom:1;		/* end of media */
259	u8         ili:1;		/* incorrect length indicator */
260	u8         reserved:1;
261	u8         sense_key:4;
262#else
263	u8         sense_key:4;
264	u8         reserved:1;
265	u8         ili:1;		/* incorrect length indicator */
266	u8         eom:1;		/* end of media */
267	u8         file_mark:1;
268#endif
269	u8         information[4];	/* device-type or command specific info
270					 */
271	u8         add_sense_length;
272					/* additional sense length */
273	u8         command_info[4];/* command specific information
274						 */
275	u8         asc;		/* additional sense code */
276	u8         ascq;		/* additional sense code qualifier */
277	u8         fru_code;	/* field replaceable unit code */
278#ifdef __BIGENDIAN
279	u8         sksv:1;		/* sense key specific valid */
280	u8         c_d:1;		/* command/data bit */
281	u8         res1:2;
282	u8         bpv:1;		/* bit pointer valid */
283	u8         bpointer:3;	/* bit pointer */
284#else
285	u8         bpointer:3;	/* bit pointer */
286	u8         bpv:1;		/* bit pointer valid */
287	u8         res1:2;
288	u8         c_d:1;		/* command/data bit */
289	u8         sksv:1;		/* sense key specific valid */
290#endif
291	u8         fpointer[2];	/* field pointer */
292};
293
294#define SCSI_SENSE_CUR_ERR          0x70
295#define SCSI_SENSE_DEF_ERR          0x71
296
297/*
298 * SCSI sense key values
299 */
300#define SCSI_SK_NO_SENSE        0x0
301#define SCSI_SK_REC_ERR         0x1	/* recovered error */
302#define SCSI_SK_NOT_READY       0x2
303#define SCSI_SK_MED_ERR         0x3	/* medium error */
304#define SCSI_SK_HW_ERR          0x4	/* hardware error */
305#define SCSI_SK_ILLEGAL_REQ     0x5
306#define SCSI_SK_UNIT_ATT        0x6	/* unit attention */
307#define SCSI_SK_DATA_PROTECT    0x7
308#define SCSI_SK_BLANK_CHECK     0x8
309#define SCSI_SK_VENDOR_SPEC     0x9
310#define SCSI_SK_COPY_ABORTED    0xA
311#define SCSI_SK_ABORTED_CMND    0xB
312#define SCSI_SK_VOL_OVERFLOW    0xD
313#define SCSI_SK_MISCOMPARE      0xE
314
315/*
316 * SCSI additional sense codes
317 */
318#define SCSI_ASC_NO_ADD_SENSE           0x00
319#define SCSI_ASC_LUN_NOT_READY          0x04
320#define SCSI_ASC_LUN_COMMUNICATION      0x08
321#define SCSI_ASC_WRITE_ERROR            0x0C
322#define SCSI_ASC_INVALID_CMND_CODE      0x20
323#define SCSI_ASC_BAD_LBA                0x21
324#define SCSI_ASC_INVALID_FIELD_IN_CDB   0x24
325#define SCSI_ASC_LUN_NOT_SUPPORTED      0x25
326#define SCSI_ASC_LUN_WRITE_PROTECT      0x27
327#define SCSI_ASC_POWERON_BDR            0x29	/* power on reset, bus reset,
328						 * bus device reset
329						 */
330#define SCSI_ASC_PARAMS_CHANGED         0x2A
331#define SCSI_ASC_CMND_CLEARED_BY_A_I    0x2F
332#define SCSI_ASC_SAVING_PARAM_NOTSUPP   0x39
333#define SCSI_ASC_TOCC                   0x3F	/* target operating condtions
334						 * changed
335						 */
336#define SCSI_ASC_PARITY_ERROR           0x47
337#define SCSI_ASC_CMND_PHASE_ERROR       0x4A
338#define SCSI_ASC_DATA_PHASE_ERROR       0x4B
339#define SCSI_ASC_VENDOR_SPEC            0x7F
340
341/*
342 * SCSI additional sense code qualifiers
343 */
344#define SCSI_ASCQ_CAUSE_NOT_REPORT      0x00
345#define SCSI_ASCQ_BECOMING_READY        0x01
346#define SCSI_ASCQ_INIT_CMD_REQ          0x02
347#define SCSI_ASCQ_FORMAT_IN_PROGRESS    0x04
348#define SCSI_ASCQ_OPERATION_IN_PROGRESS 0x07
349#define SCSI_ASCQ_SELF_TEST_IN_PROGRESS 0x09
350#define SCSI_ASCQ_WR_UNEXP_UNSOL_DATA   0x0C
351#define SCSI_ASCQ_WR_NOTENG_UNSOL_DATA  0x0D
352
353#define SCSI_ASCQ_LBA_OUT_OF_RANGE      0x00
354#define SCSI_ASCQ_INVALID_ELEMENT_ADDR  0x01
355
356#define SCSI_ASCQ_LUN_WRITE_PROTECTED       0x00
357#define SCSI_ASCQ_LUN_HW_WRITE_PROTECTED    0x01
358#define SCSI_ASCQ_LUN_SW_WRITE_PROTECTED    0x02
359
360#define SCSI_ASCQ_POR   0x01	/* power on reset */
361#define SCSI_ASCQ_SBR   0x02	/* scsi bus reset */
362#define SCSI_ASCQ_BDR   0x03	/* bus device reset */
363#define SCSI_ASCQ_DIR   0x04	/* device internal reset */
364
365#define SCSI_ASCQ_MODE_PARAMS_CHANGED       0x01
366#define SCSI_ASCQ_LOG_PARAMS_CHANGED        0x02
367#define SCSI_ASCQ_RESERVATIONS_PREEMPTED    0x03
368#define SCSI_ASCQ_RESERVATIONS_RELEASED     0x04
369#define SCSI_ASCQ_REGISTRATIONS_PREEMPTED   0x05
370
371#define SCSI_ASCQ_MICROCODE_CHANGED 0x01
372#define SCSI_ASCQ_CHANGED_OPER_COND 0x02
373#define SCSI_ASCQ_INQ_CHANGED       0x03	/* inquiry data changed */
374#define SCSI_ASCQ_DI_CHANGED        0x05	/* device id changed */
375#define SCSI_ASCQ_RL_DATA_CHANGED   0x0E	/* report luns data changed */
376
377#define SCSI_ASCQ_DP_CRC_ERR            0x01	/* data phase crc error */
378#define SCSI_ASCQ_DP_SCSI_PARITY_ERR    0x02	/* data phase scsi parity error
379						 */
380#define SCSI_ASCQ_IU_CRC_ERR            0x03	/* information unit crc error */
381#define SCSI_ASCQ_PROTO_SERV_CRC_ERR    0x05
382
383#define SCSI_ASCQ_LUN_TIME_OUT          0x01
384
385/* ------------------------------------------------------------
386 * SCSI INQUIRY
387 * ------------------------------------------------------------*/
388
389struct scsi_inquiry_s{
390	u8         opcode;
391#ifdef __BIGENDIAN
392	u8         lun:3;
393	u8         reserved1:3;
394	u8         cmd_dt:1;
395	u8         evpd:1;
396#else
397	u8         evpd:1;
398	u8         cmd_dt:1;
399	u8         reserved1:3;
400	u8         lun:3;
401#endif
402	u8         page_code;
403	u8         reserved2;
404	u8         alloc_length;
405	u8         control;
406};
407
408struct scsi_inquiry_vendor_s{
409	u8         vendor_id[8];
410};
411
412struct scsi_inquiry_prodid_s{
413	u8         product_id[16];
414};
415
416struct scsi_inquiry_prodrev_s{
417	u8         product_rev[4];
418};
419
420struct scsi_inquiry_data_s{
421#ifdef __BIGENDIAN
422	u8         peripheral_qual:3;	/* peripheral qualifier */
423	u8         device_type:5;		/* peripheral device type */
424
425	u8         rmb:1;			/* removable medium bit */
426	u8         device_type_mod:7;	/* device type modifier */
427
428	u8         version;
429
430	u8         aenc:1;		/* async event notification capability
431					 */
432	u8         trm_iop:1;	/* terminate I/O process */
433	u8         norm_aca:1;	/* normal ACA supported */
434	u8         hi_support:1;	/* SCSI-3: supports REPORT LUNS */
435	u8         rsp_data_format:4;
436
437	u8         additional_len;
438	u8         sccs:1;
439	u8         reserved1:7;
440
441	u8         reserved2:1;
442	u8         enc_serv:1;	/* enclosure service component */
443	u8         reserved3:1;
444	u8         multi_port:1;	/* multi-port device */
445	u8         m_chngr:1;	/* device in medium transport element */
446	u8         ack_req_q:1;	/* SIP specific bit */
447	u8         addr32:1;	/* SIP specific bit */
448	u8         addr16:1;	/* SIP specific bit */
449
450	u8         rel_adr:1;	/* relative address */
451	u8         w_bus32:1;
452	u8         w_bus16:1;
453	u8         synchronous:1;
454	u8         linked_commands:1;
455	u8         trans_dis:1;
456	u8         cmd_queue:1;	/* command queueing supported */
457	u8         soft_reset:1;	/* soft reset alternative (VS) */
458#else
459	u8         device_type:5;	/* peripheral device type */
460	u8         peripheral_qual:3;
461					/* peripheral qualifier */
462
463	u8         device_type_mod:7;
464					/* device type modifier */
465	u8         rmb:1;		/* removable medium bit */
466
467	u8         version;
468
469	u8         rsp_data_format:4;
470	u8         hi_support:1;	/* SCSI-3: supports REPORT LUNS */
471	u8         norm_aca:1;	/* normal ACA supported */
472	u8         terminate_iop:1;/* terminate I/O process */
473	u8         aenc:1;		/* async event notification capability
474					 */
475
476	u8         additional_len;
477	u8         reserved1:7;
478	u8         sccs:1;
479
480	u8         addr16:1;	/* SIP specific bit */
481	u8         addr32:1;	/* SIP specific bit */
482	u8         ack_req_q:1;	/* SIP specific bit */
483	u8         m_chngr:1;	/* device in medium transport element */
484	u8         multi_port:1;	/* multi-port device */
485	u8         reserved3:1;	/* TBD - Vendor Specific */
486	u8         enc_serv:1;	/* enclosure service component */
487	u8         reserved2:1;
488
489	u8         soft_seset:1;	/* soft reset alternative (VS) */
490	u8         cmd_queue:1;	/* command queueing supported */
491	u8         trans_dis:1;
492	u8         linked_commands:1;
493	u8         synchronous:1;
494	u8         w_bus16:1;
495	u8         w_bus32:1;
496	u8         rel_adr:1;	/* relative address */
497#endif
498	struct scsi_inquiry_vendor_s vendor_id;
499	struct scsi_inquiry_prodid_s product_id;
500	struct scsi_inquiry_prodrev_s product_rev;
501	u8         vendor_specific[20];
502	u8         reserved4[40];
503};
504
505/*
506 * inquiry.peripheral_qual field values
507 */
508#define SCSI_DEVQUAL_DEFAULT        0
509#define SCSI_DEVQUAL_NOT_CONNECTED  1
510#define SCSI_DEVQUAL_NOT_SUPPORTED  3
511
512/*
513 * inquiry.device_type field values
514 */
515#define SCSI_DEVICE_DIRECT_ACCESS       0x00
516#define SCSI_DEVICE_SEQ_ACCESS          0x01
517#define SCSI_DEVICE_ARRAY_CONTROLLER    0x0C
518#define SCSI_DEVICE_UNKNOWN             0x1F
519
520/*
521 * inquiry.version
522 */
523#define SCSI_VERSION_ANSI_X3131     2	/* ANSI X3.131 SCSI-2 */
524#define SCSI_VERSION_SPC            3	/* SPC (SCSI-3), ANSI X3.301:1997 */
525#define SCSI_VERSION_SPC_2          4	/* SPC-2 */
526
527/*
528 * response data format
529 */
530#define SCSI_RSP_DATA_FORMAT        2	/* SCSI-2 & SPC */
531
532/*
533 * SCSI inquiry page codes
534 */
535#define SCSI_INQ_PAGE_VPD_PAGES     0x00	/* supported vpd pages */
536#define SCSI_INQ_PAGE_USN_PAGE      0x80	/* unit serial number page */
537#define SCSI_INQ_PAGE_DEV_IDENT     0x83	/* device indentification page
538						 */
539#define SCSI_INQ_PAGES_MAX          3
540
541/*
542 * supported vital product data pages
543 */
544struct scsi_inq_page_vpd_pages_s{
545#ifdef __BIGENDIAN
546	u8         peripheral_qual:3;
547	u8         device_type:5;
548#else
549	u8         device_type:5;
550	u8         peripheral_qual:3;
551#endif
552	u8         page_code;
553	u8         reserved;
554	u8         page_length;
555	u8         pages[SCSI_INQ_PAGES_MAX];
556};
557
558/*
559 * Unit serial number page
560 */
561#define SCSI_INQ_USN_LEN 32
562
563struct scsi_inq_usn_s{
564	char            usn[SCSI_INQ_USN_LEN];
565};
566
567struct scsi_inq_page_usn_s{
568#ifdef __BIGENDIAN
569	u8         peripheral_qual:3;
570	u8         device_type:5;
571#else
572	u8         device_type:5;
573	u8         peripheral_qual:3;
574#endif
575	u8         page_code;
576	u8         reserved1;
577	u8         page_length;
578	struct scsi_inq_usn_s  usn;
579};
580
581enum {
582	SCSI_INQ_DIP_CODE_BINARY = 1,	/* identifier has binary value */
583	SCSI_INQ_DIP_CODE_ASCII = 2,	/* identifier has ascii value */
584};
585
586enum {
587	SCSI_INQ_DIP_ASSOC_LUN = 0,	/* id is associated with device */
588	SCSI_INQ_DIP_ASSOC_PORT = 1,	/* id is associated with port that
589					 * received the request
590					 */
591};
592
593enum {
594	SCSI_INQ_ID_TYPE_VENDOR = 1,
595	SCSI_INQ_ID_TYPE_IEEE = 2,
596	SCSI_INQ_ID_TYPE_FC_FS = 3,
597	SCSI_INQ_ID_TYPE_OTHER = 4,
598};
599
600struct scsi_inq_dip_desc_s{
601#ifdef __BIGENDIAN
602	u8         res0:4;
603	u8         code_set:4;
604	u8         res1:2;
605	u8         association:2;
606	u8         id_type:4;
607#else
608	u8         code_set:4;
609	u8         res0:4;
610	u8         id_type:4;
611	u8         association:2;
612	u8         res1:2;
613#endif
614	u8         res2;
615	u8         id_len;
616	struct scsi_lun_sn_s   id;
617};
618
619/*
620 * Device indentification page
621 */
622struct scsi_inq_page_dev_ident_s{
623#ifdef __BIGENDIAN
624	u8         peripheral_qual:3;
625	u8         device_type:5;
626#else
627	u8         device_type:5;
628	u8         peripheral_qual:3;
629#endif
630	u8         page_code;
631	u8         reserved1;
632	u8         page_length;
633	struct scsi_inq_dip_desc_s desc;
634};
635
636/* ------------------------------------------------------------
637 * READ CAPACITY
638 * ------------------------------------------------------------
639 */
640
641struct scsi_read_capacity_s{
642	u8         opcode;
643#ifdef __BIGENDIAN
644	u8         lun:3;
645	u8         reserved1:4;
646	u8         rel_adr:1;
647#else
648	u8         rel_adr:1;
649	u8         reserved1:4;
650	u8         lun:3;
651#endif
652	u8         lba0;	/* MSB */
653	u8         lba1;
654	u8         lba2;
655	u8         lba3;	/* LSB */
656	u8         reserved2;
657	u8         reserved3;
658#ifdef __BIGENDIAN
659	u8         reserved4:7;
660	u8         pmi:1;	/* partial medium indicator */
661#else
662	u8         pmi:1;	/* partial medium indicator */
663	u8         reserved4:7;
664#endif
665	u8         control;
666};
667
668struct scsi_read_capacity_data_s{
669	u32        max_lba;	/* maximum LBA available */
670	u32        block_length;	/* in bytes */
671};
672
673struct scsi_read_capacity16_data_s{
674	u64        lba;	/* maximum LBA available */
675	u32        block_length;	/* in bytes */
676#ifdef __BIGENDIAN
677	u8         reserved1:4,
678			p_type:3,
679			prot_en:1;
680	u8		reserved2:4,
681			lb_pbe:4;	/* logical blocks per physical block
682					 * exponent */
683	u16	reserved3:2,
684			lba_align:14;	/* lowest aligned logical block
685					 * address */
686#else
687	u16	lba_align:14,	/* lowest aligned logical block
688					 * address */
689			reserved3:2;
690	u8		lb_pbe:4,	/* logical blocks per physical block
691					 * exponent */
692			reserved2:4;
693	u8		prot_en:1,
694			p_type:3,
695			reserved1:4;
696#endif
697	u64	reserved4;
698	u64	reserved5;
699};
700
701/* ------------------------------------------------------------
702 * REPORT LUNS command
703 * ------------------------------------------------------------
704 */
705
706struct scsi_report_luns_s{
707	u8         opcode;		/* A0h - REPORT LUNS opCode */
708	u8         reserved1[5];
709	u8         alloc_length[4];/* allocation length MSB first */
710	u8         reserved2;
711	u8         control;
712};
713
714#define SCSI_REPORT_LUN_ALLOC_LENGTH(rl)                		\
715    ((rl->alloc_length[0] << 24) | (rl->alloc_length[1] << 16) | 	\
716     (rl->alloc_length[2] << 8) | (rl->alloc_length[3]))
717
718#define SCSI_REPORT_LUNS_SET_ALLOCLEN(rl, alloc_len) {      \
719    (rl)->alloc_length[0] = (alloc_len) >> 24;      			\
720    (rl)->alloc_length[1] = ((alloc_len) >> 16) & 0xFF; 		\
721    (rl)->alloc_length[2] = ((alloc_len) >> 8) & 0xFF;  		\
722    (rl)->alloc_length[3] = (alloc_len) & 0xFF;     			\
723}
724
725struct scsi_report_luns_data_s{
726	u32        lun_list_length;	/* length of LUN list length */
727	u32        reserved;
728	lun_t           lun[1];			/* first LUN in lun list */
729};
730
731/* -------------------------------------------------------------
732 * SCSI mode  parameters
733 * -----------------------------------------------------------
734 */
735enum {
736	SCSI_DA_MEDIUM_DEF = 0,	/* direct access default medium type */
737	SCSI_DA_MEDIUM_SS = 1,	/* direct access single sided */
738	SCSI_DA_MEDIUM_DS = 2,	/* direct access double sided */
739};
740
741/*
742 * SCSI Mode Select(6) cdb
743 */
744struct scsi_mode_select6_s{
745	u8         opcode;
746#ifdef __BIGENDIAN
747	u8         reserved1:3;
748	u8         pf:1;		/* page format */
749	u8         reserved2:3;
750	u8         sp:1;		/* save pages if set to 1 */
751#else
752	u8         sp:1;	/* save pages if set to 1 */
753	u8         reserved2:3;
754	u8         pf:1;	/* page format */
755	u8         reserved1:3;
756#endif
757	u8         reserved3[2];
758	u8         alloc_len;
759	u8         control;
760};
761
762/*
763 * SCSI Mode Select(10) cdb
764 */
765struct scsi_mode_select10_s{
766	u8         opcode;
767#ifdef __BIGENDIAN
768	u8         reserved1:3;
769	u8         pf:1;	/* page format */
770	u8         reserved2:3;
771	u8         sp:1;	/* save pages if set to 1 */
772#else
773	u8         sp:1;	/* save pages if set to 1 */
774	u8         reserved2:3;
775	u8         pf:1;	/* page format */
776	u8         reserved1:3;
777#endif
778	u8         reserved3[5];
779	u8         alloc_len_msb;
780	u8         alloc_len_lsb;
781	u8         control;
782};
783
784/*
785 * SCSI Mode Sense(6) cdb
786 */
787struct scsi_mode_sense6_s{
788	u8         opcode;
789#ifdef __BIGENDIAN
790	u8         reserved1:4;
791	u8         dbd:1;	/* disable block discriptors if set to 1 */
792	u8         reserved2:3;
793
794	u8         pc:2;	/* page control */
795	u8         page_code:6;
796#else
797	u8         reserved2:3;
798	u8         dbd:1;	/* disable block descriptors if set to 1 */
799	u8         reserved1:4;
800
801	u8         page_code:6;
802	u8         pc:2;	/* page control */
803#endif
804	u8         reserved3;
805	u8         alloc_len;
806	u8         control;
807};
808
809/*
810 * SCSI Mode Sense(10) cdb
811 */
812struct scsi_mode_sense10_s{
813	u8         opcode;
814#ifdef __BIGENDIAN
815	u8         reserved1:3;
816	u8         LLBAA:1;	/* long LBA accepted if set to 1 */
817	u8         dbd:1;		/* disable block descriptors if set
818					 * to 1
819					 */
820	u8         reserved2:3;
821
822	u8         pc:2;		/* page control */
823	u8         page_code:6;
824#else
825	u8         reserved2:3;
826	u8         dbd:1;		/* disable block descriptors if set to
827					 * 1
828					 */
829	u8         LLBAA:1;	/* long LBA accepted if set to 1 */
830	u8         reserved1:3;
831
832	u8         page_code:6;
833	u8         pc:2;		/* page control */
834#endif
835	u8         reserved3[4];
836	u8         alloc_len_msb;
837	u8         alloc_len_lsb;
838	u8         control;
839};
840
841#define SCSI_CDB10_GET_AL(cdb)  					\
842    ((cdb)->alloc_len_msb << 8 | (cdb)->alloc_len_lsb)
843
844#define SCSI_CDB10_SET_AL(cdb, al) {      \
845    (cdb)->alloc_len_msb = al >> 8;       				\
846    (cdb)->alloc_len_lsb = al & 0xFF;     				\
847}
848
849#define SCSI_CDB6_GET_AL(cdb) ((cdb)->alloc_len)
850
851#define SCSI_CDB6_SET_AL(cdb, al) {      \
852    (cdb)->alloc_len = al;         					\
853}
854
855/*
856 * page control field values
857 */
858#define SCSI_PC_CURRENT_VALUES       0x0
859#define SCSI_PC_CHANGEABLE_VALUES    0x1
860#define SCSI_PC_DEFAULT_VALUES       0x2
861#define SCSI_PC_SAVED_VALUES         0x3
862
863/*
864 * SCSI mode page codes
865 */
866#define SCSI_MP_VENDOR_SPEC     0x00
867#define SCSI_MP_DISC_RECN       0x02	/* disconnect-reconnect page */
868#define SCSI_MP_FORMAT_DEVICE   0x03
869#define SCSI_MP_RDG             0x04	/* rigid disk geometry page */
870#define SCSI_MP_FDP             0x05	/* flexible disk page */
871#define SCSI_MP_CACHING         0x08	/* caching page */
872#define SCSI_MP_CONTROL         0x0A	/* control mode page */
873#define SCSI_MP_MED_TYPES_SUP   0x0B	/* medium types supported page */
874#define SCSI_MP_INFO_EXCP_CNTL  0x1C	/* informational exception control */
875#define SCSI_MP_ALL             0x3F	/* return all pages - mode sense only */
876
877/*
878 * mode parameter header
879 */
880struct scsi_mode_param_header6_s{
881	u8         mode_datalen;
882	u8         medium_type;
883
884	/*
885	 * device specific parameters expanded for direct access devices
886	 */
887#ifdef __BIGENDIAN
888	u32        wp:1;		/* write protected */
889	u32        reserved1:2;
890	u32        dpofua:1;	/* disable page out + force unit access
891					 */
892	u32        reserved2:4;
893#else
894	u32        reserved2:4;
895	u32        dpofua:1;	/* disable page out + force unit access
896					 */
897	u32        reserved1:2;
898	u32        wp:1;		/* write protected */
899#endif
900
901	u8         block_desclen;
902};
903
904struct scsi_mode_param_header10_s{
905	u32        mode_datalen:16;
906	u32        medium_type:8;
907
908	/*
909	 * device specific parameters expanded for direct access devices
910	 */
911#ifdef __BIGENDIAN
912	u32        wp:1;		/* write protected */
913	u32        reserved1:2;
914	u32        dpofua:1;	/* disable page out + force unit access
915					 */
916	u32        reserved2:4;
917#else
918	u32        reserved2:4;
919	u32        dpofua:1;	/* disable page out + force unit access
920					 */
921	u32        reserved1:2;
922	u32        wp:1;		/* write protected */
923#endif
924
925#ifdef __BIGENDIAN
926	u32        reserved3:7;
927	u32        longlba:1;
928#else
929	u32        longlba:1;
930	u32        reserved3:7;
931#endif
932	u32        reserved4:8;
933	u32        block_desclen:16;
934};
935
936/*
937 * mode parameter block descriptor
938 */
939struct scsi_mode_param_desc_s{
940	u32        nblks;
941	u32        density_code:8;
942	u32        block_length:24;
943};
944
945/*
946 * Disconnect-reconnect mode page format
947 */
948struct scsi_mp_disc_recn_s{
949#ifdef __BIGENDIAN
950	u8         ps:1;
951	u8         reserved1:1;
952	u8         page_code:6;
953#else
954	u8         page_code:6;
955	u8         reserved1:1;
956	u8         ps:1;
957#endif
958	u8         page_len;
959	u8         buf_full_ratio;
960	u8         buf_empty_ratio;
961
962	u8         bil_msb;	/* bus inactivity limit -MSB */
963	u8         bil_lsb;	/* bus inactivity limit -LSB */
964
965	u8         dtl_msb;	/* disconnect time limit - MSB */
966	u8         dtl_lsb;	/* disconnect time limit - LSB */
967
968	u8         ctl_msb;	/* connect time limit - MSB */
969	u8         ctl_lsb;	/* connect time limit - LSB */
970
971	u8         max_burst_len_msb;
972	u8         max_burst_len_lsb;
973#ifdef __BIGENDIAN
974	u8         emdp:1;	/* enable modify data pointers */
975	u8         fa:3;	/* fair arbitration */
976	u8         dimm:1;	/* disconnect immediate */
977	u8         dtdc:3;	/* data transfer disconnect control */
978#else
979	u8         dtdc:3;	/* data transfer disconnect control */
980	u8         dimm:1;	/* disconnect immediate */
981	u8         fa:3;	/* fair arbitration */
982	u8         emdp:1;	/* enable modify data pointers */
983#endif
984
985	u8         reserved3;
986
987	u8         first_burst_len_msb;
988	u8         first_burst_len_lsb;
989};
990
991/*
992 * SCSI format device mode page
993 */
994struct scsi_mp_format_device_s{
995#ifdef __BIGENDIAN
996	u32        ps:1;
997	u32        reserved1:1;
998	u32        page_code:6;
999#else
1000	u32        page_code:6;
1001	u32        reserved1:1;
1002	u32        ps:1;
1003#endif
1004	u32        page_len:8;
1005	u32        tracks_per_zone:16;
1006
1007	u32        a_sec_per_zone:16;
1008	u32        a_tracks_per_zone:16;
1009
1010	u32        a_tracks_per_lun:16;	/* alternate tracks/lun-MSB */
1011	u32        sec_per_track:16;	/* sectors/track-MSB */
1012
1013	u32        bytes_per_sector:16;
1014	u32        interleave:16;
1015
1016	u32        tsf:16;			/* track skew factor-MSB */
1017	u32        csf:16;			/* cylinder skew factor-MSB */
1018
1019#ifdef __BIGENDIAN
1020	u32        ssec:1;	/* soft sector formatting */
1021	u32        hsec:1;	/* hard sector formatting */
1022	u32        rmb:1;	/* removable media */
1023	u32        surf:1;	/* surface */
1024	u32        reserved2:4;
1025#else
1026	u32        reserved2:4;
1027	u32        surf:1;	/* surface */
1028	u32        rmb:1;	/* removable media */
1029	u32        hsec:1;	/* hard sector formatting */
1030	u32        ssec:1;	/* soft sector formatting */
1031#endif
1032	u32        reserved3:24;
1033};
1034
1035/*
1036 * SCSI rigid disk device geometry page
1037 */
1038struct scsi_mp_rigid_device_geometry_s{
1039#ifdef __BIGENDIAN
1040	u32        ps:1;
1041	u32        reserved1:1;
1042	u32        page_code:6;
1043#else
1044	u32        page_code:6;
1045	u32        reserved1:1;
1046	u32        ps:1;
1047#endif
1048	u32        page_len:8;
1049	u32        num_cylinders0:8;
1050	u32        num_cylinders1:8;
1051
1052	u32        num_cylinders2:8;
1053	u32        num_heads:8;
1054	u32        scwp0:8;
1055	u32        scwp1:8;
1056
1057	u32        scwp2:8;
1058	u32        scrwc0:8;
1059	u32        scrwc1:8;
1060	u32        scrwc2:8;
1061
1062	u32        dsr:16;
1063	u32        lscyl0:8;
1064	u32        lscyl1:8;
1065
1066	u32        lscyl2:8;
1067#ifdef __BIGENDIAN
1068	u32        reserved2:6;
1069	u32        rpl:2;	/* rotational position locking */
1070#else
1071	u32        rpl:2;	/* rotational position locking */
1072	u32        reserved2:6;
1073#endif
1074	u32        rot_off:8;
1075	u32        reserved3:8;
1076
1077	u32        med_rot_rate:16;
1078	u32        reserved4:16;
1079};
1080
1081/*
1082 * SCSI caching mode page
1083 */
1084struct scsi_mp_caching_s{
1085#ifdef __BIGENDIAN
1086	u8         ps:1;
1087	u8         res1:1;
1088	u8         page_code:6;
1089#else
1090	u8         page_code:6;
1091	u8         res1:1;
1092	u8         ps:1;
1093#endif
1094	u8         page_len;
1095#ifdef __BIGENDIAN
1096	u8         ic:1;	/* initiator control */
1097	u8         abpf:1;	/* abort pre-fetch */
1098	u8         cap:1;	/* caching analysis permitted */
1099	u8         disc:1;	/* discontinuity */
1100	u8         size:1;	/* size enable */
1101	u8         wce:1;	/* write cache enable */
1102	u8         mf:1;	/* multiplication factor */
1103	u8         rcd:1;	/* read cache disable */
1104
1105	u8         drrp:4;	/* demand read retention priority */
1106	u8         wrp:4;	/* write retention priority */
1107#else
1108	u8         rcd:1;	/* read cache disable */
1109	u8         mf:1;	/* multiplication factor */
1110	u8         wce:1;	/* write cache enable */
1111	u8         size:1;	/* size enable */
1112	u8         disc:1;	/* discontinuity */
1113	u8         cap:1;	/* caching analysis permitted */
1114	u8         abpf:1;	/* abort pre-fetch */
1115	u8         ic:1;	/* initiator control */
1116
1117	u8         wrp:4;	/* write retention priority */
1118	u8         drrp:4;	/* demand read retention priority */
1119#endif
1120	u8         dptl[2];/* disable pre-fetch transfer length */
1121	u8         min_prefetch[2];
1122	u8         max_prefetch[2];
1123	u8         max_prefetch_limit[2];
1124#ifdef __BIGENDIAN
1125	u8         fsw:1;	/* force sequential write */
1126	u8         lbcss:1;/* logical block cache segment size */
1127	u8         dra:1;	/* disable read ahead */
1128	u8         vs:2;	/* vendor specific */
1129	u8         res2:3;
1130#else
1131	u8         res2:3;
1132	u8         vs:2;	/* vendor specific */
1133	u8         dra:1;	/* disable read ahead */
1134	u8         lbcss:1;/* logical block cache segment size */
1135	u8         fsw:1;	/* force sequential write */
1136#endif
1137	u8         num_cache_segs;
1138
1139	u8         cache_seg_size[2];
1140	u8         res3;
1141	u8         non_cache_seg_size[3];
1142};
1143
1144/*
1145 * SCSI control mode page
1146 */
1147struct scsi_mp_control_page_s{
1148#ifdef __BIGENDIAN
1149u8         ps:1;
1150u8         reserved1:1;
1151u8         page_code:6;
1152#else
1153u8         page_code:6;
1154u8         reserved1:1;
1155u8         ps:1;
1156#endif
1157	u8         page_len;
1158#ifdef __BIGENDIAN
1159	u8         tst:3;		/* task set type */
1160	u8         reserved3:3;
1161	u8         gltsd:1;	/* global logging target save disable */
1162	u8         rlec:1;		/* report log exception condition */
1163
1164	u8         qalgo_mod:4;	/* queue alogorithm modifier */
1165	u8         reserved4:1;
1166	u8         qerr:2;		/* queue error management */
1167	u8         dque:1;		/* disable queuing */
1168
1169	u8         reserved5:1;
1170	u8         rac:1;		/* report a check */
1171	u8         reserved6:2;
1172	u8         swp:1;		/* software write protect */
1173	u8         raerp:1;	/* ready AER permission */
1174	u8         uaaerp:1;	/* unit attenstion AER permission */
1175	u8         eaerp:1;	/* error AER permission */
1176
1177	u8         reserved7:5;
1178	u8         autoload_mod:3;
1179#else
1180	u8         rlec:1;		/* report log exception condition */
1181	u8         gltsd:1;	/* global logging target save disable */
1182	u8         reserved3:3;
1183	u8         tst:3;		/* task set type */
1184
1185	u8         dque:1;		/* disable queuing */
1186	u8         qerr:2;		/* queue error management */
1187	u8         reserved4:1;
1188	u8         qalgo_mod:4;	/* queue alogorithm modifier */
1189
1190	u8         eaerp:1;	/* error AER permission */
1191	u8         uaaerp:1;	/* unit attenstion AER permission */
1192	u8         raerp:1;	/* ready AER permission */
1193	u8         swp:1;		/* software write protect */
1194	u8         reserved6:2;
1195	u8         rac:1;		/* report a check */
1196	u8         reserved5:1;
1197
1198	u8         autoload_mod:3;
1199	u8         reserved7:5;
1200#endif
1201	u8         rahp_msb;	/* ready AER holdoff period - MSB */
1202	u8         rahp_lsb;	/* ready AER holdoff period - LSB */
1203
1204	u8         busy_timeout_period_msb;
1205	u8         busy_timeout_period_lsb;
1206
1207	u8         ext_selftest_compl_time_msb;
1208	u8         ext_selftest_compl_time_lsb;
1209};
1210
1211/*
1212 * SCSI medium types supported mode page
1213 */
1214struct scsi_mp_medium_types_sup_s{
1215#ifdef __BIGENDIAN
1216	u8         ps:1;
1217	u8         reserved1:1;
1218	u8         page_code:6;
1219#else
1220	u8         page_code:6;
1221	u8         reserved1:1;
1222	u8         ps:1;
1223#endif
1224	u8         page_len;
1225
1226	u8         reserved3[2];
1227	u8         med_type1_sup;	/* medium type one supported */
1228	u8         med_type2_sup;	/* medium type two supported */
1229	u8         med_type3_sup;	/* medium type three supported */
1230	u8         med_type4_sup;	/* medium type four supported */
1231};
1232
1233/*
1234 * SCSI informational exception control mode page
1235 */
1236struct scsi_mp_info_excpt_cntl_s{
1237#ifdef __BIGENDIAN
1238	u8         ps:1;
1239	u8         reserved1:1;
1240	u8         page_code:6;
1241#else
1242	u8         page_code:6;
1243	u8         reserved1:1;
1244	u8         ps:1;
1245#endif
1246	u8         page_len;
1247#ifdef __BIGENDIAN
1248	u8         perf:1;		/* performance */
1249	u8         reserved3:1;
1250	u8         ebf:1;		/* enable background fucntion */
1251	u8         ewasc:1;	/* enable warning */
1252	u8         dexcpt:1;	/* disable exception control */
1253	u8         test:1;		/* enable test device failure
1254					 * notification
1255					 */
1256	u8         reserved4:1;
1257	u8         log_error:1;
1258
1259	u8         reserved5:4;
1260	u8         mrie:4;		/* method of reporting info
1261					 * exceptions
1262					 */
1263#else
1264	u8         log_error:1;
1265	u8         reserved4:1;
1266	u8         test:1;		/* enable test device failure
1267					 * notification
1268					 */
1269	u8         dexcpt:1;	/* disable exception control */
1270	u8         ewasc:1;	/* enable warning */
1271	u8         ebf:1;		/* enable background fucntion */
1272	u8         reserved3:1;
1273	u8         perf:1;		/* performance */
1274
1275	u8         mrie:4;		/* method of reporting info
1276					 * exceptions
1277					 */
1278	u8         reserved5:4;
1279#endif
1280	u8         interval_timer_msb;
1281	u8         interval_timer_lsb;
1282
1283	u8         report_count_msb;
1284	u8         report_count_lsb;
1285};
1286
1287/*
1288 * Methods of reporting informational exceptions
1289 */
1290#define SCSI_MP_IEC_NO_REPORT       0x0	/* no reporting of exceptions */
1291#define SCSI_MP_IEC_AER             0x1	/* async event reporting */
1292#define SCSI_MP_IEC_UNIT_ATTN       0x2	/* generate unit attenstion */
1293#define SCSI_MO_IEC_COND_REC_ERR    0x3	/* conditionally generate recovered
1294					 * error
1295					 */
1296#define SCSI_MP_IEC_UNCOND_REC_ERR  0x4	/* unconditionally generate recovered
1297					 * error
1298					 */
1299#define SCSI_MP_IEC_NO_SENSE        0x5	/* generate no sense */
1300#define SCSI_MP_IEC_ON_REQUEST      0x6	/* only report exceptions on request */
1301
1302/*
1303 * SCSI flexible disk page
1304 */
1305struct scsi_mp_flexible_disk_s{
1306#ifdef __BIGENDIAN
1307	u8         ps:1;
1308	u8         reserved1:1;
1309	u8         page_code:6;
1310#else
1311	u8         page_code:6;
1312	u8         reserved1:1;
1313	u8         ps:1;
1314#endif
1315	u8         page_len;
1316
1317	u8         transfer_rate_msb;
1318	u8         transfer_rate_lsb;
1319
1320	u8         num_heads;
1321	u8         num_sectors;
1322
1323	u8         bytes_per_sector_msb;
1324	u8         bytes_per_sector_lsb;
1325
1326	u8         num_cylinders_msb;
1327	u8         num_cylinders_lsb;
1328
1329	u8         sc_wpc_msb;	/* starting cylinder-write
1330					 * precompensation msb
1331					 */
1332	u8         sc_wpc_lsb;	/* starting cylinder-write
1333					 * precompensation lsb
1334					 */
1335	u8         sc_rwc_msb;	/* starting cylinder-reduced write
1336					 * current msb
1337					 */
1338	u8         sc_rwc_lsb;	/* starting cylinder-reduced write
1339					 * current lsb
1340					 */
1341
1342	u8         dev_step_rate_msb;
1343	u8         dev_step_rate_lsb;
1344
1345	u8         dev_step_pulse_width;
1346
1347	u8         head_sd_msb;	/* head settle delay msb */
1348	u8         head_sd_lsb;	/* head settle delay lsb */
1349
1350	u8         motor_on_delay;
1351	u8         motor_off_delay;
1352#ifdef __BIGENDIAN
1353	u8         trdy:1;		/* true ready bit */
1354	u8         ssn:1;		/* start sector number bit */
1355	u8         mo:1;		/* motor on bit */
1356	u8         reserved3:5;
1357
1358	u8         reserved4:4;
1359	u8         spc:4;		/* step pulse per cylinder */
1360#else
1361	u8         reserved3:5;
1362	u8         mo:1;		/* motor on bit */
1363	u8         ssn:1;		/* start sector number bit */
1364	u8         trdy:1;		/* true ready bit */
1365
1366	u8         spc:4;		/* step pulse per cylinder */
1367	u8         reserved4:4;
1368#endif
1369	u8         write_comp;
1370	u8         head_load_delay;
1371	u8         head_unload_delay;
1372#ifdef __BIGENDIAN
1373	u8         pin34:4;	/* pin34 usage */
1374	u8         pin2:4;		/* pin2 usage */
1375
1376	u8         pin4:4;		/* pin4 usage */
1377	u8         pin1:4;		/* pin1 usage */
1378#else
1379	u8         pin2:4;		/* pin2 usage */
1380	u8         pin34:4;	/* pin34 usage */
1381
1382	u8         pin1:4;		/* pin1 usage */
1383	u8         pin4:4;		/* pin4 usage */
1384#endif
1385	u8         med_rot_rate_msb;
1386	u8         med_rot_rate_lsb;
1387
1388	u8         reserved5[2];
1389};
1390
1391struct scsi_mode_page_format_data6_s{
1392	struct scsi_mode_param_header6_s mph;	/* mode page header */
1393	struct scsi_mode_param_desc_s desc;	/* block descriptor */
1394	struct scsi_mp_format_device_s format;	/* format device data */
1395};
1396
1397struct scsi_mode_page_format_data10_s{
1398	struct scsi_mode_param_header10_s mph;	/* mode page header */
1399	struct scsi_mode_param_desc_s desc;	/* block descriptor */
1400	struct scsi_mp_format_device_s format;	/* format device data */
1401};
1402
1403struct scsi_mode_page_rdg_data6_s{
1404	struct scsi_mode_param_header6_s mph;	/* mode page header */
1405	struct scsi_mode_param_desc_s desc;	/* block descriptor */
1406	struct scsi_mp_rigid_device_geometry_s rdg;
1407					/* rigid geometry data */
1408};
1409
1410struct scsi_mode_page_rdg_data10_s{
1411	struct scsi_mode_param_header10_s mph;	/* mode page header */
1412	struct scsi_mode_param_desc_s desc;	/* block descriptor */
1413	struct scsi_mp_rigid_device_geometry_s rdg;
1414					/* rigid geometry data */
1415};
1416
1417struct scsi_mode_page_cache6_s{
1418	struct scsi_mode_param_header6_s mph;	/* mode page header */
1419	struct scsi_mode_param_desc_s desc;	/* block descriptor */
1420	struct scsi_mp_caching_s cache;	/* cache page data */
1421};
1422
1423struct scsi_mode_page_cache10_s{
1424	struct scsi_mode_param_header10_s mph;	/* mode page header */
1425	struct scsi_mode_param_desc_s desc;	/* block descriptor */
1426	struct scsi_mp_caching_s cache;	/* cache page data */
1427};
1428
1429/* --------------------------------------------------------------
1430 * Format Unit command
1431 * ------------------------------------------------------------
1432 */
1433
1434/*
1435 * Format Unit CDB
1436 */
1437struct scsi_format_unit_s{
1438	u8         opcode;
1439#ifdef __BIGENDIAN
1440	u8         res1:3;
1441	u8         fmtdata:1;	/* if set, data out phase has format
1442					 * data
1443					 */
1444	u8         cmplst:1;	/* if set, defect list is complete */
1445	u8         def_list:3;	/* format of defect descriptor is
1446					 * fmtdata =1
1447					 */
1448#else
1449	u8         def_list:3;	/* format of defect descriptor is
1450					 * fmtdata = 1
1451					 */
1452	u8         cmplst:1;	/* if set, defect list is complete */
1453	u8         fmtdata:1;	/* if set, data out phase has format
1454					 * data
1455					 */
1456	u8         res1:3;
1457#endif
1458	u8         interleave_msb;
1459	u8         interleave_lsb;
1460	u8         vendor_spec;
1461	u8         control;
1462};
1463
1464/*
1465 * h
1466 */
1467struct scsi_reserve6_s{
1468	u8         opcode;
1469#ifdef __BIGENDIAN
1470	u8         reserved:3;
1471	u8         obsolete:4;
1472	u8         extent:1;
1473#else
1474	u8         extent:1;
1475	u8         obsolete:4;
1476	u8         reserved:3;
1477#endif
1478	u8         reservation_id;
1479	u16        param_list_len;
1480	u8         control;
1481};
1482
1483/*
1484 * h
1485 */
1486struct scsi_release6_s{
1487	u8         opcode;
1488#ifdef __BIGENDIAN
1489	u8         reserved1:3;
1490	u8         obsolete:4;
1491	u8         extent:1;
1492#else
1493	u8         extent:1;
1494	u8         obsolete:4;
1495	u8         reserved1:3;
1496#endif
1497	u8         reservation_id;
1498	u16        reserved2;
1499	u8         control;
1500};
1501
1502/*
1503 * h
1504 */
1505struct scsi_reserve10_s{
1506	u8         opcode;
1507#ifdef __BIGENDIAN
1508	u8         reserved1:3;
1509	u8         third_party:1;
1510	u8         reserved2:2;
1511	u8         long_id:1;
1512	u8         extent:1;
1513#else
1514	u8         extent:1;
1515	u8         long_id:1;
1516	u8         reserved2:2;
1517	u8         third_party:1;
1518	u8         reserved1:3;
1519#endif
1520	u8         reservation_id;
1521	u8         third_pty_dev_id;
1522	u8         reserved3;
1523	u8         reserved4;
1524	u8         reserved5;
1525	u16        param_list_len;
1526	u8         control;
1527};
1528
1529struct scsi_release10_s{
1530	u8         opcode;
1531#ifdef __BIGENDIAN
1532	u8         reserved1:3;
1533	u8         third_party:1;
1534	u8         reserved2:2;
1535	u8         long_id:1;
1536	u8         extent:1;
1537#else
1538	u8         extent:1;
1539	u8         long_id:1;
1540	u8         reserved2:2;
1541	u8         third_party:1;
1542	u8         reserved1:3;
1543#endif
1544	u8         reservation_id;
1545	u8         third_pty_dev_id;
1546	u8         reserved3;
1547	u8         reserved4;
1548	u8         reserved5;
1549	u16        param_list_len;
1550	u8         control;
1551};
1552
1553struct scsi_verify10_s{
1554	u8         opcode;
1555#ifdef __BIGENDIAN
1556	u8         lun:3;
1557	u8         dpo:1;
1558	u8         reserved:2;
1559	u8         bytchk:1;
1560	u8         reladdr:1;
1561#else
1562	u8         reladdr:1;
1563	u8         bytchk:1;
1564	u8         reserved:2;
1565	u8         dpo:1;
1566	u8         lun:3;
1567#endif
1568	u8         lba0;
1569	u8         lba1;
1570	u8         lba2;
1571	u8         lba3;
1572	u8         reserved1;
1573	u8         verification_len0;
1574	u8         verification_len1;
1575	u8         control_byte;
1576};
1577
1578struct scsi_request_sense_s{
1579	u8         opcode;
1580#ifdef __BIGENDIAN
1581	u8         lun:3;
1582	u8         reserved:5;
1583#else
1584	u8         reserved:5;
1585	u8         lun:3;
1586#endif
1587	u8         reserved0;
1588	u8         reserved1;
1589	u8         alloc_len;
1590	u8         control_byte;
1591};
1592
1593/* ------------------------------------------------------------
1594 * SCSI status byte values
1595 * ------------------------------------------------------------
1596 */
1597#define SCSI_STATUS_GOOD                   0x00
1598#define SCSI_STATUS_CHECK_CONDITION        0x02
1599#define SCSI_STATUS_CONDITION_MET          0x04
1600#define SCSI_STATUS_BUSY                   0x08
1601#define SCSI_STATUS_INTERMEDIATE           0x10
1602#define SCSI_STATUS_ICM                    0x14	/* intermediate condition met */
1603#define SCSI_STATUS_RESERVATION_CONFLICT   0x18
1604#define SCSI_STATUS_COMMAND_TERMINATED     0x22
1605#define SCSI_STATUS_QUEUE_FULL             0x28
1606#define SCSI_STATUS_ACA_ACTIVE             0x30
1607
1608#define SCSI_MAX_ALLOC_LEN		0xFF	/* maximum allocarion length
1609						 * in CDBs
1610						 */
1611
1612#define SCSI_OP_WRITE_VERIFY10      0x2E
1613#define SCSI_OP_WRITE_VERIFY12      0xAE
1614#define SCSI_OP_UNDEF               0xFF
1615
1616/*
1617 * SCSI WRITE-VERIFY(10) command
1618 */
1619struct scsi_write_verify10_s{
1620	u8         opcode;
1621#ifdef __BIGENDIAN
1622	u8         reserved1:3;
1623	u8         dpo:1;		/* Disable Page Out */
1624	u8         reserved2:1;
1625	u8         ebp:1;		/* erse by-pass */
1626	u8         bytchk:1;	/* byte check */
1627	u8         rel_adr:1;	/* relative address */
1628#else
1629	u8         rel_adr:1;	/* relative address */
1630	u8         bytchk:1;	/* byte check */
1631	u8         ebp:1;		/* erse by-pass */
1632	u8         reserved2:1;
1633	u8         dpo:1;		/* Disable Page Out */
1634	u8         reserved1:3;
1635#endif
1636	u8         lba0;		/* logical block address - MSB */
1637	u8         lba1;
1638	u8         lba2;
1639	u8         lba3;		/* LSB */
1640	u8         reserved3;
1641	u8         xfer_length0;	/* transfer length in blocks - MSB */
1642	u8         xfer_length1;	/* LSB */
1643	u8         control;
1644};
1645
1646#pragma pack()
1647
1648#endif /* __SCSI_H__ */
1649