xref: /netbsd-src/external/bsd/iscsi/dist/include/scsi_cmd_codes.h (revision 5e01dafb5c1f3a68ee2f80136c3b6043ad89a0f3)
1*5e01dafbSagc /* $NetBSD: scsi_cmd_codes.h,v 1.3 2009/06/30 02:44:52 agc Exp $ */
22f245829Sagc 
32f245829Sagc /*
42f245829Sagc  * Copyright � 2006 Alistair Crooks.  All rights reserved.
52f245829Sagc  *
62f245829Sagc  * Redistribution and use in source and binary forms, with or without
72f245829Sagc  * modification, are permitted provided that the following conditions
82f245829Sagc  * are met:
92f245829Sagc  * 1. Redistributions of source code must retain the above copyright
102f245829Sagc  *    notice, this list of conditions and the following disclaimer.
112f245829Sagc  * 2. Redistributions in binary form must reproduce the above copyright
122f245829Sagc  *    notice, this list of conditions and the following disclaimer in the
132f245829Sagc  *    documentation and/or other materials provided with the distribution.
142f245829Sagc  * 3. The name of the author may not be used to endorse or promote
152f245829Sagc  *    products derived from this software without specific prior written
162f245829Sagc  *    permission.
172f245829Sagc  *
182f245829Sagc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
192f245829Sagc  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
202f245829Sagc  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212f245829Sagc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
222f245829Sagc  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232f245829Sagc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
242f245829Sagc  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
252f245829Sagc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
262f245829Sagc  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
272f245829Sagc  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
282f245829Sagc  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
292f245829Sagc  */
302f245829Sagc #ifndef SCSI_CMD_CODES_H_
312f245829Sagc #define SCSI_CMD_CODES_H_
322f245829Sagc 
332f245829Sagc /* information taken from SPC3, T10/1416-D Revision 23, from www.t10.org */
342f245829Sagc 
352f245829Sagc enum {
362f245829Sagc 	TEST_UNIT_READY = 0x00,
372f245829Sagc 	READ_6 = 0x08,
382f245829Sagc 	WRITE_6 = 0x0a,
392f245829Sagc 	INQUIRY = 0x12,
402f245829Sagc 	MODE_SELECT_6 = 0x15,
412f245829Sagc 	RESERVE_6 = 0x16,
422f245829Sagc 	RELEASE_6 = 0x17,
432f245829Sagc 	MODE_SENSE_6 = 0x1a,
442f245829Sagc 	STOP_START_UNIT = 0x1b,
452f245829Sagc 	READ_CAPACITY = 0x25,
462f245829Sagc 	READ_10 = 0x28,
472f245829Sagc 	WRITE_10 = 0x2a,
482f245829Sagc 	WRITE_VERIFY = 0x2e,
492f245829Sagc 	VERIFY = 0x2f,
502f245829Sagc 	SYNC_CACHE = 0x35,
512f245829Sagc 	LOG_SENSE = 0x4d,
522f245829Sagc 	MODE_SELECT_10 = 0x55,
532f245829Sagc 	RESERVE_10 = 0x56,
542f245829Sagc 	RELEASE_10 = 0x57,
552f245829Sagc 	MODE_SENSE_10 = 0x5a,
562f245829Sagc 	PERSISTENT_RESERVE_IN = 0x5e,
572f245829Sagc 	PERSISTENT_RESERVE_OUT = 0x5f,
582f245829Sagc 	REPORT_LUNS = 0xa0
592f245829Sagc };
602f245829Sagc 
612f245829Sagc #define SIX_BYTE_COMMAND(op)	((op) <= 0x1f)
622f245829Sagc #define TEN_BYTE_COMMAND(op)	((op) > 0x1f && (op) <= 0x5f)
632f245829Sagc 
642f245829Sagc enum {
652f245829Sagc 	ISCSI_MODE_SENSE_LEN = 	11
662f245829Sagc };
672f245829Sagc 
682f245829Sagc /* miscellaneous definitions */
692f245829Sagc enum {
702f245829Sagc 	DISK_PERIPHERAL_DEVICE = 0x0,
712f245829Sagc 
722f245829Sagc 	INQUIRY_EVPD_BIT = 0x01,
732f245829Sagc 
742f245829Sagc 	INQUIRY_UNIT_SERIAL_NUMBER_VPD = 0x80,
752f245829Sagc 	INQUIRY_DEVICE_IDENTIFICATION_VPD = 0x83,
762f245829Sagc 	INQUIRY_SUPPORTED_VPD_PAGES = 0x0,
772f245829Sagc 		INQUIRY_DEVICE_PIV = 0x1,
782f245829Sagc 
792f245829Sagc 		INQUIRY_IDENTIFIER_TYPE_T10 = 0x1,
802f245829Sagc 		INQUIRY_IDENTIFIER_TYPE_EUI64 = 0x2,
812f245829Sagc 		INQUIRY_IDENTIFIER_TYPE_NAA = 0x3,
822f245829Sagc 
832f245829Sagc 		INQUIRY_DEVICE_ASSOCIATION_LOGICAL_UNIT = 0x0,
842f245829Sagc 		INQUIRY_DEVICE_ASSOCIATION_TARGET_PORT = 0x1,
852f245829Sagc 		INQUIRY_DEVICE_ASSOCIATION_TARGET_DEVICE = 0x2,
862f245829Sagc 
872f245829Sagc 		INQUIRY_DEVICE_CODESET_UTF8 = 0x3,
882f245829Sagc 		INQUIRY_DEVICE_ISCSI_PROTOCOL = 0x5,
892f245829Sagc 		INQUIRY_DEVICE_T10_VENDOR = 0x1,
902f245829Sagc 		INQUIRY_DEVICE_IDENTIFIER_SCSI_NAME = 0x8,
912f245829Sagc 
922f245829Sagc 	EXTENDED_INQUIRY_DATA_VPD = 0x86,
932f245829Sagc 		EXTENDED_INQUIRY_REF_TAG_OWNER = 0x08,
942f245829Sagc 		EXTENDED_INQUIRY_GUARD_CHECK = 0x04,
952f245829Sagc 		EXTENDED_INQUIRY_APPLICATION_CHECK = 0x02,
962f245829Sagc 		EXTENDED_INQUIRY_REFERENCE_CHECK = 0x01,
972f245829Sagc 
982f245829Sagc 		EXTENDED_INQUIRY_GROUP_SUPPORT = 0x10,
992f245829Sagc 		EXTENDED_INQUIRY_PRIORITY_SUPPORT = 0x8,
1002f245829Sagc 		EXTENDED_INQUIRY_QUEUE_HEAD_SUPPORT = 0x4,
1012f245829Sagc 		EXTENDED_INQUIRY_ORDERED_SUPPORT = 0x2,
1022f245829Sagc 		EXTENDED_INQUIRY_SIMPLE_SUPPORT = 0x1,
1032f245829Sagc 
1042f245829Sagc 	PERSISTENT_RESERVE_IN_SERVICE_ACTION_MASK = 0x1f,
1052f245829Sagc 		PERSISTENT_RESERVE_IN_READ_KEYS = 0x0,
1062f245829Sagc 		PERSISTENT_RESERVE_IN_READ_RESERVATION = 0x1,
1072f245829Sagc 		PERSISTENT_RESERVE_IN_REPORT_CAPABILITIES = 0x2,
1082f245829Sagc 		PERSISTENT_RESERVE_IN_READ_FULL_STATUS = 0x3,
1092f245829Sagc 
1102f245829Sagc 	PERSISTENT_RESERVE_IN_CRH = 0x10,
1112f245829Sagc 	PERSISTENT_RESERVE_IN_SIP_C = 0x8,
1122f245829Sagc 	PERSISTENT_RESERVE_IN_ATP_C = 0x4,
1132f245829Sagc 	PERSISTENT_RESERVE_IN_PTPL_C = 0x1, /* persistence through power loss */
1142f245829Sagc 	PERSISTENT_RESERVE_IN_TMV = 0x80, /* Type Mask Valid */
1152f245829Sagc 	PERSISTENT_RESERVE_IN_PTPL_A = 0x01, /* persistence through power loss activated */
1162f245829Sagc 
1172f245829Sagc 	PERSISTENT_RESERVE_IN_WR_EX_AR = 0x80,
1182f245829Sagc 	PERSISTENT_RESERVE_IN_EX_AC_RD = 0x40,
1192f245829Sagc 	PERSISTENT_RESERVE_IN_WR_AC_RD = 0x20,
1202f245829Sagc 	PERSISTENT_RESERVE_IN_EX_AC = 0x08,
1212f245829Sagc 	PERSISTENT_RESERVE_IN_WR_EX = 0x02,
1222f245829Sagc 	PERSISTENT_RESERVE_IN_EX_AC_AR = 0x01,
1232f245829Sagc 
1242f245829Sagc 	WIDE_BUS_16 = 0x20,
1252f245829Sagc 	WIDE_BUS_32 = 0x40,
1262f245829Sagc 
1272f245829Sagc 	SCSI_VERSION_SPC = 0x03,
1282f245829Sagc 	SCSI_VERSION_SPC2 = 0x04,
1292f245829Sagc 	SCSI_VERSION_SPC3 = 0x05,
1302f245829Sagc 
1312f245829Sagc 	/* used in MODE_SENSE_10 */
1322f245829Sagc 	DISABLE_BLOCK_DESCRIPTORS = 0x08,
1332f245829Sagc 	LONG_LBA_ACCEPTED = 0x10,
1342f245829Sagc 	PAGE_CONTROL_MASK = 0xc0,
1352f245829Sagc 		PAGE_CONTROL_CURRENT_VALUES = 0x0,
1362f245829Sagc 		PAGE_CONTROL_CHANGEABLE_VALUES = 0x40,
1372f245829Sagc 		PAGE_CONTROL_DEFAULT_VALUES = 0x80,
1382f245829Sagc 		PAGE_CONTROL_SAVAED_VALUES = 0xc0,
1392f245829Sagc 	PAGE_CODE_MASK = 0x3f,
1402f245829Sagc 
1412f245829Sagc 		ASC_LUN_UNSUPPORTED = 0x25,
1422f245829Sagc 		ASCQ_LUN_UNSUPPORTED = 0x0,
1432f245829Sagc 
1442f245829Sagc 		SCSI_SKEY_ILLEGAL_REQUEST = 0x05
1452f245829Sagc };
1462f245829Sagc 
1472f245829Sagc /* device return codes */
1482f245829Sagc enum {
1492f245829Sagc 	SCSI_SUCCESS = 0x0,
1502f245829Sagc 	SCSI_CHECK_CONDITION = 0x02
1512f245829Sagc };
1522f245829Sagc 
1532f245829Sagc #endif /* !SCSI_CMD_CODES_H_ */
154