xref: /titanic_44/usr/src/uts/common/sys/scsi/generic/persist.h (revision 02b636c64ad657301ef5f5e6c2d14c6bec693fff)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_GENERIC_PERSIST_H
27 #define	_SYS_SCSI_GENERIC_PERSIST_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * SCSI Persistence Data
37  *
38  * Format of data returned as a result of PERSISTENCE RESERVER { IN | OUT }
39  */
40 
41 /*
42  * SPC-3 revision 23, Section 6.11.1, Table 102
43  * Persistent Reservations
44  * Persistent Reserve In service actions
45  */
46 #define	PR_IN_READ_KEYS		0x0 /* Read all registered reservation keys */
47 #define	PR_IN_READ_RESERVATION	0x1 /* Reads th persistent reservations */
48 #define	PR_IN_REPORT_CAPABILITIES 0x2 /* Returns capability information */
49 #define	PR_IN_READ_FULL_STATUS	0x3 /* Reads complete information about all */
50 				    /* registrations and the persistent */
51 				    /* reservations, if any */
52 /*
53  * SPC-3 revision 23, Section 6.11.3.3, Table 106
54  * Persistent reservation scope codes
55  */
56 #define	PR_LU_SCOPE		0x0	/* Persistent reservation applies to */
57 					/* full logical unit */
58 /*
59  * SPC-3 revision 23, Section 6.11.3.4, Table 107
60  * Persistent Reservations
61  * Persistent reservation type codes
62  */
63 #define	PGR_TYPE_WR_EX		0x1	/* Write Exclusive */
64 #define	PGR_TYPE_EX_AC		0x3	/* Exclusive Access */
65 #define	PGR_TYPE_WR_EX_RO	0x5	/* Write Exclusive, Registrants Only */
66 #define	PGR_TYPE_EX_AC_RO	0x6	/* Exclusive Access, Registrants Only */
67 #define	PGR_TYPE_WR_EX_AR	0x7	/* Write Exclusive, All Registrants */
68 #define	PGR_TYPE_EX_AC_AR	0x8	/* Exclusive Access, All Registrants */
69 
70 /*
71  * Information obtained from:
72  *	SPC-3, Revision 23
73  *	Section 6.11.5 PERSISTENCE RESERVE IN
74  *	Table 111 - full status descriptor format
75  */
76 /* Table 289 - iSCSI Initiator Device TransportID format */
77 
78 #define	iSCSI_PROTOCOL_ID	0x5	/* Table 262 - iSCSI Protocol ID  */
79 #define	WW_UID_DEVICE_NAME	0x0	/* Table 288 - iSCSI Transport IDs */
80 
81 
82 #if defined(_BIT_FIELDS_LTOH)
83 /*
84  * Information obtained from:
85  *	SPC-3, Revision 23
86  *	Section 6.11.1 PERSISTENCE RESERVE IN
87  *	Table 101 - PERSISTENCE RESERVE IN command
88  */
89 typedef struct scsi_cdb_prin {
90 	uint8_t			cmd;
91 	uint8_t			action : 5,
92 				resbits : 3;
93 	uint8_t			resbytes[5];
94 	uint8_t			alloc_len[2];
95 	uint8_t			control;
96 } scsi_cdb_prin_t;
97 
98 /*
99  * Information obtained from:
100  *	SPC-3, Revision 23
101  *	Section 6.11.2 PERSISTENCE RESERVE IN
102  *	Table 103/104/105 - parameter data for READS KEYS
103  */
104 typedef struct scsi_prin_rsrvdesc {
105 	uint8_t			reservation_key[8];
106 	uint8_t			obsolete1[4];
107 	uint8_t			resbytes;
108 	uint8_t			type : 4,
109 				scope : 4;
110 	uint8_t			obsolete2[2];
111 } scsi_prin_rsrvdesc_t;
112 typedef struct scsi_prin_readrsrv {
113 	uint8_t			PRgeneration[4];
114 	uint8_t			add_len[4];
115 	scsi_prin_rsrvdesc_t	res_key_list[1];
116 } scsi_prin_readrsrv_t;
117 
118 /*
119  * Information obtained from:
120  *	SPC-3, Revision 23
121  *	Section 6.11.4 PERSISTENCE RESERVE IN
122  * 	Table 108 - parameter data for REPORT CAPABILTIES
123  */
124 typedef struct scsi_per_res_type {
125 	uint8_t			resbits1 : 1,
126 				wr_ex : 1,
127 				resbits2 : 1,
128 				ex_ac : 1,
129 				resbits3 : 1,
130 				wr_ex_ro : 1,
131 				ex_ac_ro : 1,
132 				wr_ex_ar : 1;
133 	uint8_t			ex_ac_ar : 1,
134 				resbits4 : 7;
135 } scsi_per_res_type_t;
136 typedef struct scsi_prin_rpt_cap {
137 	uint8_t			length[2];
138 	uint8_t			ptpl_c : 1,
139 				resbits1 : 1,
140 				atp_c : 1,
141 				sip_c : 1,
142 				crh : 1,
143 				resbits2 : 3;
144 	uint8_t			ptpl_a : 1,
145 				resbits3 : 6,
146 				tmv : 1;
147 	scsi_per_res_type_t	pr_type;
148 	uint8_t			resbytes[2];
149 } scsi_prin_rpt_cap_t;
150 
151 /*
152  * Information obtained from:
153  *	SPC-3, Revision 23
154  *	Section 6.11.5 PERSISTENCE RESERVE IN
155  * 	Table 110/111 - parameter data for READ FULL STATUS
156  *	Table 281 - TransportId format
157  */
158 typedef struct scsi_transport_id {
159 	uint8_t			protocol_id : 4,
160 				resbits : 2,
161 				format_code : 2;
162 	uint8_t			add_len[2];
163 	char			iscsi_name[1];
164 } scsi_transport_id_t;
165 typedef struct scsi_prin_status_t {
166 	uint8_t			reservation_key[8];
167 	uint8_t			resbytes1[4];
168 	uint8_t			r_holder : 1,
169 				all_tg_pt : 1,
170 				resbits : 6;
171 	uint8_t			type : 4,
172 				scope : 4;
173 	uint8_t			resbytes2[4];
174 	uint8_t			rel_tgt_port_id[2];
175 	uint8_t			add_len[4];
176 	scsi_transport_id_t	trans_id;
177 } scsi_prin_status_t;
178 typedef struct scsi_prin_full_status {
179 	uint8_t			PRgeneration[4];
180 	uint8_t			add_len[4];
181 	scsi_prin_status_t	full_desc[1];
182 } scsi_prin_full_status_t;
183 
184 /*
185  * Information obtained from:
186  *	SPC-3, Revision 23
187  *	Section 6.12.1 PERSISTENCE RESERVE OUT
188  *	Table 112 - PERSISTENCE RESERVE OUT command
189  */
190 typedef struct scsi_cdb_prout {
191 	uint8_t			cmd;
192 	uint8_t			action : 5,
193 				resbits : 3;
194 	uint8_t			type : 4,
195 				scope : 4;
196 	uint8_t			resbytes[2];
197 	uint8_t			param_len[4];
198 	uint8_t			control;
199 } scsi_cdb_prout_t;
200 
201 /*
202  * Information obtained from:
203  *	SPC-3, Revision 23
204  *	Section 6.12.3 PERSISTENCE RESERVE OUT
205  *	Table 114 - PERSISTENCE RESERVE OUT parameter list
206  */
207 typedef struct scsi_prout_plist {
208 	uint8_t			reservation_key[8];
209 	uint8_t			service_key[8];
210 	uint8_t			obsolete1[4];
211 	uint8_t			aptpl : 1,
212 				resbits1 : 1,
213 				all_tg_pt : 1,
214 				spec_i_pt : 1,
215 				resbits2 : 4;
216 	uint8_t			resbytes1;
217 	uint8_t			obsolete2[2];
218 	uint8_t			apd[1];
219 } scsi_prout_plist_t;
220 
221 #elif defined(_BIT_FIELDS_HTOL)
222 /*
223  * Information obtained from:
224  *	SPC-3, Revision 23
225  *	Section 6.11.1 PERSISTENCE RESERVE IN
226  *	Table 101 - PERSISTENCE RESERVE IN command
227  */
228 typedef struct scsi_cdb_prin {
229 	uint8_t			cmd;
230 	uint8_t			resbits : 3,
231 				action : 5;
232 	uint8_t			resbytes[5];
233 	uint8_t			alloc_len[2];
234 	uint8_t			control;
235 } scsi_cdb_prin_t;
236 
237 /*
238  * Information obtained from:
239  *	SPC-3, Revision 23
240  *	Section 6.11.2 PERSISTENCE RESERVE IN
241  *	Table 103/104/105 - parameter data for READS KEYS
242  */
243 typedef struct scsi_prin_rsrvdesc {
244 	uint8_t			reservation_key[8];
245 	uint8_t			obsolete1[4];
246 	uint8_t			resbytes;
247 	uint8_t			scope : 4,
248 				type : 4;
249 	uint8_t			obsolete2[8];
250 } scsi_prin_rsrvdesc_t;
251 typedef struct scsi_prin_readrsrv {
252 	uint8_t			PRgeneration[4];
253 	uint8_t			add_len[4];
254 	scsi_prin_rsrvdesc_t	res_key_list[1];
255 } scsi_prin_readrsrv_t;
256 
257 /*
258  * Information obtained from:
259  *	SPC-3, Revision 23
260  *	Section 6.11.4 PERSISTENCE RESERVE IN
261  * 	Table 108 - parameter data for REPORT CAPABILTIES
262  */
263 typedef struct scsi_per_res_type {
264 	uint8_t			wr_ex_ar : 1,
265 				ex_ac_ro : 1,
266 				wr_ex_ro : 1,
267 				resbits3 : 1,
268 				ex_ac : 1,
269 				resbits2 : 1,
270 				wr_ex : 1,
271 				resbits1 : 1;
272 	uint8_t			resbits4 : 7,
273 				ex_ac_ar : 1;
274 } scsi_per_res_type_t;
275 typedef struct scsi_prin_rpt_cap {
276 	uint8_t			length[2];
277 	uint8_t			resbits2 : 3,
278 				crh : 1,
279 				sip_c : 1,
280 				atp_c : 1,
281 				resbits1 : 1,
282 				ptpl_c : 1;
283 	uint8_t			tmv : 1,
284 				resbits3 : 6,
285 				ptpl_a : 1;
286 	scsi_per_res_type_t	pr_type;
287 	uint8_t			resbytes[2];
288 } scsi_prin_rpt_cap_t;
289 
290 /*
291  * Information obtained from:
292  *	SPC-3, Revision 23
293  *	Section 6.11.5 PERSISTENCE RESERVE IN
294  * 	Table 110/111 - parameter data for READ FULL STATUS
295  *	Table 281 - TransportId format
296  */
297 typedef struct scsi_transport_id {
298 	uint8_t			format_code : 2,
299 				resbits : 2,
300 				protocol_id : 4;
301 	uint8_t			add_len[2];
302 	char			iscsi_name[1];
303 } scsi_transport_id_t;
304 typedef struct scsi_prin_status_t {
305 	uint8_t			reservation_key[8];
306 	uint8_t			resbytes1[4];
307 	uint8_t			resbits : 6,
308 				all_tg_pt : 1,
309 				r_holder : 1;
310 	uint8_t			scope : 4,
311 				type : 4;
312 	uint8_t			resbytes2[4];
313 	uint8_t			rel_tgt_port_id[2];
314 	uint8_t			add_len[4];
315 	scsi_transport_id_t	trans_id;
316 } scsi_prin_status_t;
317 typedef struct scsi_prin_full_status {
318 	uint8_t			PRgeneration[4];
319 	uint8_t			add_len[4];
320 	scsi_prin_status_t	full_desc[1];
321 } scsi_prin_full_status_t;
322 
323 /*
324  * Information obtained from:
325  *	SPC-3, Revision 23
326  *	Section 6.12.1 PERSISTENCE RESERVE OUT
327  *	Table 112 - PERSISTENCE RESERVE OUT command
328  */
329 typedef struct scsi_cdb_prout {
330 	uint8_t			cmd;
331 	uint8_t			resbits : 3,
332 				action : 5;
333 	uint8_t			scope : 4,
334 				type : 4;
335 	uint8_t			resbytes[2];
336 	uint8_t			param_len[4];
337 	uint8_t			control;
338 } scsi_cdb_prout_t;
339 
340 /*
341  * Information obtained from:
342  *	SPC-3, Revision 23
343  *	Section 6.12.3 PERSISTENCE RESERVE OUT
344  *	Table 114 - PERSISTENCE RESERVE OUT parameter list
345  */
346 typedef struct scsi_prout_plist {
347 	uint8_t			reservation_key[8];
348 	uint8_t			service_key[8];
349 	uint8_t			obsolete1[4];
350 	uint8_t			resbits1 : 4,
351 				spec_i_pt : 1,
352 				all_tg_pt : 1,
353 				resbits2 : 1,
354 				aptpl : 1;
355 	uint8_t			resbytes1;
356 	uint8_t			obsolete2[2];
357 	uint8_t			apd[1];
358 } scsi_prout_plist_t;
359 
360 #else
361 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
362 #endif	/* _BIT_FIELDS_LTOH */
363 
364 
365 /*
366  * SPC-3 revision 23, Section 6.12.2, Table 113
367  * Persistent Reservations
368  * Persistent Reserve Out service action codes
369  */
370 #define	PR_OUT_REGISTER		0x0	/* Register/unregister a reservation */
371 					/* key with the device server */
372 #define	PR_OUT_RESERVE		0x1	/* Create a persistent reservation */
373 					/* having a specified SCOPE & TYPE */
374 #define	PR_OUT_RELEASE		0x2	/* Release the selected persistent */
375 					/* reservation */
376 #define	PR_OUT_CLEAR		0x3	/* Clears all reservation keys and */
377 					/* all persistent reservations */
378 #define	PR_OUT_PREEMPT		0x4	/* Preempts persistent reservations */
379 					/* and/or removes reservations */
380 #define	PR_OUT_PREEMPT_ABORT	0x5	/* Preempts persistent reservations */
381 					/* and/or removes reservations, and */
382 					/* aborts all tasks for all preempted */
383 					/* I_T nexuses */
384 #define	PR_OUT_REGISTER_AND_IGNORE_EXISTING_KEY	0x06
385 					/* Register a reservation key with */
386 					/* the device server, or unregister a */
387 					/* reservation key */
388 #define	PR_OUT_REGISTER_MOVE	0x7	/* Register a reservation key for */
389 					/* another I_T nexus with the device */
390 					/* server and move a persistent */
391 					/* reservation to the I_T nexus */
392 
393 
394 #ifdef	__cplusplus
395 }
396 #endif
397 
398 #endif	/* _SYS_SCSI_GENERIC_PERSIST_H */
399