xref: /titanic_52/usr/src/uts/common/io/cpqary3/cpqary3_scsi.h (revision 80c94ecd7a524eb933a4bb221a9618b9dc490e76)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
14  */
15 
16 #ifndef	_CPQARY3_SCSI_H
17 #define	_CPQARY3_SCSI_H
18 
19 #include <sys/types.h>
20 #include "cpqary3_ciss.h"
21 
22 #ifdef	__cplusplus
23 extern "C" {
24 #endif
25 
26 /* CISS LUN Addressing MODEs */
27 #define	PERIPHERIAL_DEV_ADDR 			0x0
28 #define	LOGICAL_VOL_ADDR 				0x1
29 #define	MASK_PERIPHERIAL_DEV_ADDR 		0x3
30 #define	CISS_PHYS_MODE 					0x0
31 
32 /*
33  * Definitions for compatibility with the old array BMIC interface
34  * CISS_OPCODE_RLL IS THE OPCODE FOR THE Report Logical Luns command
35  */
36 #define	ARRAY_READ				0x26
37 #define	ARRAY_WRITE				0x27
38 #define	CISS_NEW_READ				0xC0
39 #define	CISS_NEW_WRITE				0xC1
40 #define	CISS_OPCODE_RLL				0xC2
41 #define	CISS_OPCODE_RPL				0xC3
42 #define	CISS_NO_TIMEOUT				0x0
43 
44 /*
45  * BMIC commands
46  */
47 #define	CISS_FLUSH_CACHE			0xC2
48 #define	BMIC_IDENTIFY_LOGICAL_DRIVE		0x10
49 #define	BMIC_SENSE_LOGICAL_DRIVE_STATUS		0x12
50 
51 #define	CISS_MSG_ABORT				0x0
52 #define	CISS_ABORT_TASK				0x0
53 #define	CISS_ABORT_TASKSET			0x1
54 #define	CISS_CTLR_INIT 				0xffff0000
55 
56 #define	CISS_MSG_RESET				0x1
57 #define	CISS_RESET_CTLR				0x0
58 #define	CISS_RESET_TGT				0x3
59 
60 /*
61  * The Controller SCSI ID is 7. Hence, when ever the OS issues a command
62  * for a target with ID greater than 7, the intended Logical Drive is
63  * actually one less than the issued ID.
64  * So, the allignment.
65  * The Mapping from OS to the HBA is as follows:
66  *	OS Target IDs		HBA taret IDs
67  *		0 - 6				0 - 6
68  *		7					- (Controller)
69  *		8 - 32				7 - 31
70  */
71 
72 #define	CPQARY3_TGT_ALIGNMENT			0x1
73 #define	CPQARY3_LEN_TAGINUSE			0x4
74 
75 #define	CPQARY3_CDBLEN_12				12
76 #define	CPQARY3_CDBLEN_16				16
77 
78 /*
79  * possible values to fill in the cmdpvt_flag member
80  * in the cpqary3_cmdpvt_t structure
81  */
82 #define	CPQARY3_TIMEOUT			1
83 #define	CPQARY3_CV_TIMEOUT		2
84 #define	CPQARY3_RESET			4
85 #define	CPQARY3_SYNC_SUBMITTED		8
86 #define	CPQARY3_SYNC_TIMEOUT		16
87 
88 #define	CPQARY3_INTR_ENABLE 		1
89 #define	CPQARY3_INTR_DISABLE 		2
90 
91 #define	CPQARY3_LOCKUP_INTR_ENABLE 	1
92 #define	CPQARY3_LOCKUP_INTR_DISABLE 	2
93 
94 #define	CPQARY3_COALESCE_DELAY		0x0
95 #define	CPQARY3_COALESCE_COUNT		0x00000001l
96 
97 #define	CPQARY3_NO_MUTEX 		0
98 #define	CPQARY3_HOLD_SW_MUTEX		1
99 
100 /* Completed With NO Error */
101 #define	CPQARY3_OSCMD_SUCCESS		0x0
102 #define	CPQARY3_SELFCMD_SUCCESS		0x2
103 #define	CPQARY3_NOECMD_SUCCESS		0x4
104 #define	CPQARY3_SYNCCMD_SUCCESS		0x6
105 
106 /* Completed With ERROR */
107 #define	CPQARY3_OSCMD_FAILURE		0x1
108 #define	CPQARY3_SELFCMD_FAILURE		0x3
109 #define	CPQARY3_NOECMD_FAILURE		0x5
110 #define	CPQARY3_SYNCCMD_FAILURE		0x7
111 
112 /* Fatal SCSI Status */
113 #define	SCSI_CHECK_CONDITION			0x2
114 #define	SCSI_COMMAND_TERMINATED			0x22
115 
116 #pragma pack(1)
117 
118 typedef struct flushcache {
119 	uint16_t	disable_flag;
120 	uint8_t		reserved[510];
121 } flushcache_buf_t;
122 
123 typedef struct each_logical_lun_data {
124 	uint32_t	logical_id:30;
125 	uint32_t	mode:2;
126 	uint8_t		reserved[4];
127 } each_ll_data_t;
128 
129 typedef struct rll_data {
130 	uint8_t			lunlist_byte3;
131 	uint8_t			lunlist_byte2;
132 	uint8_t			lunlist_byte1;
133 	uint8_t			lunlist_byte0;
134 	uint32_t		reserved;
135 	each_ll_data_t	ll_data[MAX_LOGDRV];
136 } rll_data_t;
137 
138 typedef struct each_physical_lun_data {
139 	uint32_t	    DevID;
140 	uint32_t	    SecLevel;
141 } each_pl_data_t;
142 
143 typedef struct rpl_data {
144 	uint8_t			lunlist_byte3;
145 	uint8_t			lunlist_byte2;
146 	uint8_t			lunlist_byte1;
147 	uint8_t			lunlist_byte0;
148 	uint32_t		reserved;
149 	PhysDevAddr_t	pl_data[CPQARY3_MAX_TGT];
150 } rpl_data_t;
151 
152 
153 /*
154  * Format of the data returned for the IDENTIFY LOGICAL DRIVE Command
155  */
156 
157 typedef struct Identify_Logical_Drive {
158 	uint16_t	block_size_in_bytes;
159 	uint32_t	blocks_available;
160 	uint16_t	cylinders;
161 	uint8_t		heads;
162 	uint8_t		general[11];
163 	uint8_t		sectors;
164 	uint8_t		checksum;
165 	uint8_t		fault_tolerance;
166 	uint8_t		reserved;
167 	uint8_t		bios_disable_flag;
168 	uint8_t		reserved1;
169 	uint32_t	logical_drive_identifier;
170 	uint8_t		logical_drive_label[64];
171 	uint8_t		reserved3[418];
172 } IdLogDrive;
173 
174 /* FORMAT */
175 typedef struct Identify_Ld_Status {
176 	uint8_t		status;			/* Logical Drive Status */
177 	uint32_t	failure_map;		/* Drive Failure Map */
178 	uint16_t	read_error_count[32];	/* read error count */
179 	uint16_t	write_error_count[32];	/* write error count */
180 	uint8_t		drive_error_data[256];	/* drive error data */
181 	uint8_t		drq_time_out_count[32];	/* drq timeout count */
182 	uint32_t	blocks_left_to_recover;	/* blocks yet to recover */
183 	uint8_t		drive_recovering;	/* drive recovering */
184 	uint16_t	remap_count[32];	/* remap count */
185 	uint32_t	replacement_drive_map;	/* replacement drive map */
186 	uint32_t	active_spare_map;	/* active spare map */
187 	uint8_t		spare_status;		/* spare status */
188 	uint8_t		spare_to_replace_map[32];
189 	uint32_t	replace_ok_map;		/* Marked ok but no rebuild */
190 	uint8_t		media_exchanged;	/* Media exchanged (see 0xE0) */
191 	uint8_t		cache_failure;		/* volume failed cache fail */
192 	uint8_t		expand_failure;		/* volume failed for failure */
193 	uint8_t		unit_flags;		/* SMART-2 only */
194 
195 	/*
196 	 * The following fields are for firmware supporting > 7 drives per
197 	 * SCSI bus. The "Drives Per SCSI Bus" indicates how many bits /
198 	 * words (in case of remap count) correspond to each drive.
199 	 */
200 	uint16_t	big_failure_map[8];	/* Big Drive Failure Map */
201 	uint16_t	big_remap_cnt[128];	/* Big Drive Remap  Count */
202 	uint16_t	big_replace_map[8];	/* Big Replacement Drive Map */
203 	uint16_t	big_spare_map[8];	/* Big spare drive map */
204 	uint8_t		big_spare_replace_map[128]; /* Big spare replace map */
205 	uint16_t	big_replace_ok_map[8];	/* Big replaced marked OK map */
206 	uint8_t		big_drive_rebuild;	/* Drive Rebuilding - Drive # */
207 	uint8_t		reserved[36];
208 } SenseLdStatus;
209 /* FORMAT */
210 
211 /*
212  * SCSI Command Opcodes
213  */
214 #define	SCSI_READ_6		0x08	/* READ  - 6  byte command */
215 #define	SCSI_READ_10		0x28	/* READ  - 10 byte command */
216 #define	SCSI_READ_12		0xA8	/* READ  - 12 byte command */
217 #define	SCSI_WRITE_6		0x0A	/* WRITE - 6  byte command */
218 #define	SCSI_WRITE_10		0x2A	/* WRITE - 10 byte command */
219 #define	SCSI_WRITE_12		0xAA	/* WRITE - 12 byte command */
220 
221 /*
222  * SCSI Opcodes Not supported by FW
223  *
224  */
225 #define	SCSI_LOG_SENSE			0x4D	/* LOG SENSE */
226 #define	SCSI_MODE_SELECT		0x15	/* LOG SENSE */
227 #define	SCSI_PERSISTENT_RESERVE_IN	0x5E	/* PERSISTENT RESERVE IN */
228 
229 #pragma pack()
230 
231 #ifdef	__cplusplus
232 }
233 #endif
234 
235 #endif	/* _CPQARY3_SCSI_H */
236