Home | History | Annotate | Line # | Download | only in scsipi
      1 /*	$NetBSD: scsipi_all.h,v 1.35 2025/02/10 14:42:33 jakllsch Exp $	*/
      2 
      3 /*
      4  * SCSI and SCSI-like general interface description
      5  */
      6 
      7 /*
      8  * Largely written by Julian Elischer (julian (at) tfs.com)
      9  * for TRW Financial Systems.
     10  *
     11  * TRW Financial Systems, in accordance with their agreement with Carnegie
     12  * Mellon University, makes this software available to CMU to distribute
     13  * or use in any manner that they see fit as long as this message is kept with
     14  * the software. For this reason TFS also grants any other persons or
     15  * organisations permission to use or modify this software.
     16  *
     17  * TFS supplies this software to be publicly redistributed
     18  * on the understanding that TFS is not responsible for the correct
     19  * functioning of this software in any circumstances.
     20  *
     21  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     22  */
     23 
     24 #ifndef _DEV_SCSIPI_SCSIPI_ALL_H_
     25 #define	_DEV_SCSIPI_SCSIPI_ALL_H_
     26 
     27 /*
     28  * SCSI-like command format and opcode
     29  */
     30 
     31 /*
     32  * Some basic, common SCSI command group definitions.
     33  */
     34 
     35 #define	CDB_GROUPID(cmd)        ((cmd >> 5) & 0x7)
     36 #define	CDB_GROUPID_0	0
     37 #define	CDB_GROUPID_1	1
     38 #define	CDB_GROUPID_2	2
     39 #define	CDB_GROUPID_3	3
     40 #define	CDB_GROUPID_4	4
     41 #define	CDB_GROUPID_5	5
     42 #define	CDB_GROUPID_6	6
     43 #define	CDB_GROUPID_7	7
     44 
     45 #define	CDB_GROUP0	6       /*  6-byte cdb's */
     46 #define	CDB_GROUP1	10      /* 10-byte cdb's */
     47 #define	CDB_GROUP2	10      /* 10-byte cdb's */
     48 #define	CDB_GROUP3	0       /* reserved */
     49 #define	CDB_GROUP4	16      /* 16-byte cdb's */
     50 #define	CDB_GROUP5	12      /* 12-byte cdb's */
     51 #define	CDB_GROUP6	0       /* vendor specific */
     52 #define	CDB_GROUP7	0       /* vendor specific */
     53 
     54 /*
     55  * Some basic, common SCSI commands
     56  */
     57 
     58 #define	INQUIRY			0x12
     59 struct scsipi_inquiry {
     60 	u_int8_t opcode;
     61 	u_int8_t byte2;
     62 #define SINQ_EVPD		0x01
     63 	u_int8_t pagecode;
     64 	u_int8_t length_hi;	/* upper byte of length */
     65 	u_int8_t length;
     66 	u_int8_t control;
     67 } __packed;
     68 
     69 #define START_STOP		0x1b
     70 struct scsipi_start_stop {
     71 	u_int8_t opcode;
     72 	u_int8_t byte2;
     73 	u_int8_t unused[2];
     74 	u_int8_t how;
     75 #define SSS_STOP		0x00
     76 #define SSS_START		0x01
     77 #define SSS_LOEJ		0x02
     78 	u_int8_t control;
     79 };
     80 
     81 /*
     82  * inquiry data format
     83  */
     84 
     85 #define	T_REMOV		1	/* device is removable */
     86 #define	T_FIXED		0	/* device is not removable */
     87 
     88 /*
     89  * According to SPC-2r16, in order to know if a U3W device support PPR,
     90  * Inquiry Data structure should be at least 57 Bytes
     91  */
     92 
     93 struct scsipi_inquiry_data {
     94 /* 1*/	u_int8_t device;
     95 #define	SID_TYPE		0x1f	/* device type mask */
     96 #define	SID_QUAL		0xe0	/* device qualifier mask */
     97 #define	SID_QUAL_LU_PRESENT	0x00	/* logical unit present */
     98 #define	SID_QUAL_LU_NOTPRESENT	0x20	/* logical unit not present */
     99 #define	SID_QUAL_reserved	0x40
    100 #define	SID_QUAL_LU_NOT_SUPP	0x60	/* logical unit not supported */
    101 
    102 #define	T_DIRECT		0x00	/* direct access device */
    103 #define	T_SEQUENTIAL		0x01	/* sequential access device */
    104 #define	T_PRINTER		0x02	/* printer device */
    105 #define	T_PROCESSOR		0x03	/* processor device */
    106 #define	T_WORM			0x04	/* write once, read many device */
    107 #define	T_CDROM			0x05	/* cd-rom device */
    108 #define	T_SCANNER 		0x06	/* scanner device */
    109 #define	T_OPTICAL 		0x07	/* optical memory device */
    110 #define	T_CHANGER		0x08	/* medium changer device */
    111 #define	T_COMM			0x09	/* communication device */
    112 #define	T_IT8_1			0x0a	/* Defined by ASC IT8... */
    113 #define	T_IT8_2			0x0b	/* ...(Graphic arts pre-press devices) */
    114 #define	T_STORARRAY		0x0c	/* storage array device */
    115 #define	T_ENCLOSURE		0x0d	/* enclosure services device */
    116 #define	T_SIMPLE_DIRECT		0x0E	/* Simplified direct-access device */
    117 #define	T_OPTIC_CARD_RW		0x0F	/* Optical card reader/writer device */
    118 #define	T_OBJECT_STORED		0x11	/* Object-based Storage Device */
    119 #define	T_NODEVICE		0x1f
    120 
    121 	u_int8_t dev_qual2;
    122 #define	SID_QUAL2		0x7F
    123 #define	SID_REMOVABLE		0x80
    124 
    125 /* 3*/	u_int8_t version;
    126 #define	SID_ANSII	0x07
    127 #define	SID_ECMA	0x38
    128 #define	SID_ISO		0xC0
    129 
    130 /* 4*/	u_int8_t response_format;
    131 #define	SID_RespDataFmt	0x0F
    132 #define	SID_FORMAT_SCSI1	0x00	/* SCSI-1 format */
    133 #define	SID_FORMAT_CCS		0x01	/* SCSI CCS format */
    134 #define	SID_FORMAT_ISO		0x02	/* ISO format */
    135 
    136 /* 5*/	u_int8_t additional_length;	/* n-4 */
    137 /* 6*/	u_int8_t flags1;
    138 #define	SID_SCC		0x80
    139 /* 7*/	u_int8_t flags2;
    140 #define	SID_Addr16	0x01
    141 #define SID_MChngr	0x08
    142 #define	SID_MultiPort	0x10
    143 #define	SID_EncServ	0x40
    144 #define	SID_BasQue	0x80
    145 /* 8*/	u_int8_t flags3;
    146 #define	SID_SftRe	0x01
    147 #define	SID_CmdQue	0x02
    148 #define	SID_Linked	0x08
    149 #define	SID_Sync	0x10
    150 #define	SID_WBus16	0x20
    151 #define	SID_WBus32	0x40
    152 #define	SID_RelAdr	0x80
    153 /* 9*/	char    vendor[8];
    154 /*17*/	char    product[16];
    155 /*33*/	char    revision[4];
    156 #define	SCSIPI_INQUIRY_LENGTH_SCSI2	36
    157 /*37*/	u_int8_t vendor_specific[20];
    158 /*57*/	u_int8_t flags4;
    159 #define        SID_IUS         0x01
    160 #define        SID_QAS         0x02
    161 #define        SID_Clocking    0x0C
    162 #define	SID_CLOCKING_ST_ONLY  0x00
    163 #define	SID_CLOCKING_DT_ONLY  0x04
    164 #define	SID_CLOCKING_SD_DT    0x0C
    165 /*58*/	u_int8_t reserved;
    166 /*59*/	char    version_descriptor[8][2];
    167 #define	SCSIPI_INQUIRY_LENGTH_SCSI3	74
    168 } __packed; /* 74 Bytes */
    169 
    170 /* Vital product data when SINQ_EVPD is set */
    171 
    172 struct scsipi_inquiry_evpd_header {
    173 /* 1*/	u_int8_t device;
    174 /* 2*/	u_int8_t pagecode;
    175 /* 3*/	u_int8_t length[2];
    176 };
    177 
    178 #define SINQ_VPD_PAGES		0x00
    179 #define SINQ_VPD_UNIT_SERIAL	0x80
    180 #define SINQ_VPD_DEVICE_ID	0x83
    181 #define SINQ_VPD_SOFTWARE_ID	0x84
    182 #define SINQ_VPD_MN_ADDRESS	0x85
    183 #define SINQ_VPD_INQUIRY	0x86
    184 #define SINQ_VPD_MP_POLICY	0x87
    185 #define SINQ_VPD_PORTS		0x88
    186 #define SINQ_VPD_POWER_COND	0x8a
    187 #define SINQ_VPD_CONSTITUENTS	0x8b
    188 #define SINQ_VPD_CFA_PROFILE	0x8c
    189 #define SINQ_VPD_CONSUMPTION	0x8d
    190 #define SINQ_VPD_BLOCK_LIMITS	0xb0
    191 #define SINQ_VPD_BLOCK_CHARS	0xb1
    192 #define SINQ_VPD_LOGICAL_PROV	0xb2
    193 #define SINQ_VPD_REFERRALS	0xb3
    194 #define SINQ_VPD_SUPPORTED	0xb4
    195 #define SINQ_VPD_BLOCK_CHARSX	0xb5
    196 #define SINQ_VPD_BLOCK_ZONED	0xb6
    197 #define SINQ_VPD_BLOCK_LIMITSX	0xb7
    198 #define SINQ_VPD_FIRMWARE_NUM	0xc0
    199 #define SINQ_VPD_JUMPERS	0xc2
    200 #define SINQ_VPD_BEHAVIOUR	0xc3
    201 
    202 #define SINQ_VPD_DATE_CODE	0xc1
    203 struct scsipi_inquiry_evpd_date_code {
    204 /* 1*/	u_int8_t etf_log_date[8]; /* MMDDYYYY */
    205 /* 9*/	u_int8_t compile_date[8]; /* MMDDYYYY */
    206 /*17*/	u_int8_t spindown_count[2];
    207 /*19*/	u_int8_t spindown_time[6]; /* HHMMSS */
    208 } __packed;
    209 
    210 #define SINQ_VPD_SERIAL		0x80
    211 struct scsipi_inquiry_evpd_serial {
    212 /* 1*/	u_int8_t serial_number[251];
    213 } __packed;
    214 
    215 #define SINQ_VPD_DEVICE_ID	0x83
    216 struct scsipi_inquiry_evpd_device_id {
    217 /* 1*/	u_int8_t pc;
    218 #define SINQ_DEVICE_ID_PROTOCOL			0xf0
    219 #define SINQ_DEVICE_ID_PROTOCOL_FC		0x00
    220 #define SINQ_DEVICE_ID_PROTOCOL_SSA		0x20
    221 #define SINQ_DEVICE_ID_PROTOCOL_IEEE1394	0x30
    222 #define SINQ_DEVICE_ID_PROTOCOL_RDMA		0x40
    223 #define SINQ_DEVICE_ID_PROTOCOL_ISCSI		0x50
    224 #define SINQ_DEVICE_ID_PROTOCOL_SAS		0x60
    225 #define SINQ_DEVICE_ID_CODESET			0x0f
    226 #define SINQ_DEVICE_ID_CODESET_BINARY		0x01
    227 #define SINQ_DEVICE_ID_CODESET_ASCII		0x02
    228 #define SINQ_DEVICE_ID_CODESET_UTF8		0x03
    229 /* 2*/	u_int8_t flags;
    230 #define SINQ_DEVICE_ID_PIV			0x80
    231 #define SINQ_DEVICE_ID_ASSOCIATION		0x30
    232 #define SINQ_DEVICE_ID_ASSOCIATION_DEVICE	0x00
    233 #define SINQ_DEVICE_ID_ASSOCIATION_PORT		0x10
    234 #define SINQ_DEVICE_ID_ASSOCIATION_TARGET	0x20
    235 #define SINQ_DEVICE_ID_TYPE			0x0f
    236 #define SINQ_DEVICE_ID_TYPE_UNASSIGNED		0x00
    237 #define SINQ_DEVICE_ID_TYPE_VENDOR		0x01
    238 #define SINQ_DEVICE_ID_TYPE_EUI64		0x02
    239 #define SINQ_DEVICE_ID_TYPE_FC			0x03
    240 #define SINQ_DEVICE_ID_TYPE_PORTNUMBER1		0x04
    241 #define SINQ_DEVICE_ID_TYPE_PORTNUMBER2		0x05
    242 #define SINQ_DEVICE_ID_TYPE_PORTNUMBER3		0x06
    243 #define SINQ_DEVICE_ID_TYPE_MD5			0x07
    244 /* 3*/	u_int8_t reserved;
    245 /* 4*/	u_int8_t designator_length;
    246 /* 5*/	u_int8_t designator[1];
    247 } __packed;
    248 
    249 #endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */
    250