xref: /titanic_44/usr/src/uts/common/sys/scsi/generic/persist.h (revision 68941780f0da57f6844d5666a8528421c53133bc)
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 	union {
116 		uint64_t		service_key[1];
117 		scsi_prin_rsrvdesc_t	res_key_list[1];
118 	} key_list;
119 } scsi_prin_readrsrv_t;
120 
121 /*
122  * Information obtained from:
123  *	SPC-3, Revision 23
124  *	Section 6.11.4 PERSISTENCE RESERVE IN
125  * 	Table 108 - parameter data for REPORT CAPABILTIES
126  */
127 typedef struct scsi_per_res_type {
128 	uint8_t			resbits1 : 1,
129 				wr_ex : 1,
130 				resbits2 : 1,
131 				ex_ac : 1,
132 				resbits3 : 1,
133 				wr_ex_ro : 1,
134 				ex_ac_ro : 1,
135 				wr_ex_ar : 1;
136 	uint8_t			ex_ac_ar : 1,
137 				resbits4 : 7;
138 } scsi_per_res_type_t;
139 typedef struct scsi_prin_rpt_cap {
140 	uint8_t			length[2];
141 	uint8_t			ptpl_c : 1,
142 				resbits1 : 1,
143 				atp_c : 1,
144 				sip_c : 1,
145 				crh : 1,
146 				resbits2 : 3;
147 	uint8_t			ptpl_a : 1,
148 				resbits3 : 6,
149 				tmv : 1;
150 	scsi_per_res_type_t	pr_type;
151 	uint8_t			resbytes[2];
152 } scsi_prin_rpt_cap_t;
153 
154 /*
155  * Information obtained from:
156  *	SPC-3, Revision 23
157  *	Section 6.11.5 PERSISTENCE RESERVE IN
158  * 	Table 110/111 - parameter data for READ FULL STATUS
159  *	Table 281 - TransportId format
160  */
161 typedef struct scsi_transport_id {
162 	uint8_t			protocol_id : 4,
163 				resbits : 2,
164 				format_code : 2;
165 	uint8_t			add_len[2];
166 	char			iscsi_name[1];
167 } scsi_transport_id_t;
168 typedef struct scsi_prin_status_t {
169 	uint8_t			reservation_key[8];
170 	uint8_t			resbytes1[4];
171 	uint8_t			r_holder : 1,
172 				all_tg_pt : 1,
173 				resbits : 6;
174 	uint8_t			type : 4,
175 				scope : 4;
176 	uint8_t			resbytes2[4];
177 	uint8_t			rel_tgt_port_id[2];
178 	uint8_t			add_len[4];
179 	scsi_transport_id_t	trans_id;
180 } scsi_prin_status_t;
181 typedef struct scsi_prin_full_status {
182 	uint8_t			PRgeneration[4];
183 	uint8_t			add_len[4];
184 	scsi_prin_status_t	full_desc[1];
185 } scsi_prin_full_status_t;
186 
187 /*
188  * Information obtained from:
189  *	SPC-3, Revision 23
190  *	Section 6.12.1 PERSISTENCE RESERVE OUT
191  *	Table 112 - PERSISTENCE RESERVE OUT command
192  */
193 typedef struct scsi_cdb_prout {
194 	uint8_t			cmd;
195 	uint8_t			action : 5,
196 				resbits : 3;
197 	uint8_t			type : 4,
198 				scope : 4;
199 	uint8_t			resbytes[2];
200 	uint8_t			param_len[4];
201 	uint8_t			control;
202 } scsi_cdb_prout_t;
203 
204 /*
205  * Information obtained from:
206  *	SPC-3, Revision 23
207  *	Section 6.12.3 PERSISTENCE RESERVE OUT
208  *	Table 114 - PERSISTENCE RESERVE OUT parameter list
209  */
210 typedef struct scsi_prout_plist {
211 	uint8_t			reservation_key[8];
212 	uint8_t			service_key[8];
213 	uint8_t			obsolete1[4];
214 	uint8_t			aptpl : 1,
215 				resbits1 : 1,
216 				all_tg_pt : 1,
217 				spec_i_pt : 1,
218 				resbits2 : 4;
219 	uint8_t			resbytes1;
220 	uint8_t			obsolete2[2];
221 	uint8_t			apd[1];
222 } scsi_prout_plist_t;
223 
224 #elif defined(_BIT_FIELDS_HTOL)
225 /*
226  * Information obtained from:
227  *	SPC-3, Revision 23
228  *	Section 6.11.1 PERSISTENCE RESERVE IN
229  *	Table 101 - PERSISTENCE RESERVE IN command
230  */
231 typedef struct scsi_cdb_prin {
232 	uint8_t			cmd;
233 	uint8_t			resbits : 3,
234 				action : 5;
235 	uint8_t			resbytes[5];
236 	uint8_t			alloc_len[2];
237 	uint8_t			control;
238 } scsi_cdb_prin_t;
239 
240 /*
241  * Information obtained from:
242  *	SPC-3, Revision 23
243  *	Section 6.11.2 PERSISTENCE RESERVE IN
244  *	Table 103/104/105 - parameter data for READS KEYS
245  */
246 typedef struct scsi_prin_rsrvdesc {
247 	uint8_t			reservation_key[8];
248 	uint8_t			obsolete1[4];
249 	uint8_t			resbytes;
250 	uint8_t			scope : 4,
251 				type : 4;
252 	uint8_t			obsolete2[2];
253 } scsi_prin_rsrvdesc_t;
254 typedef struct scsi_prin_readrsrv {
255 	uint8_t			PRgeneration[4];
256 	uint8_t			add_len[4];
257 	union {
258 		uint64_t		service_key[1];
259 		scsi_prin_rsrvdesc_t	res_key_list[1];
260 	} key_list;
261 } scsi_prin_readrsrv_t;
262 
263 /*
264  * Information obtained from:
265  *	SPC-3, Revision 23
266  *	Section 6.11.4 PERSISTENCE RESERVE IN
267  * 	Table 108 - parameter data for REPORT CAPABILTIES
268  */
269 typedef struct scsi_per_res_type {
270 	uint8_t			wr_ex_ar : 1,
271 				ex_ac_ro : 1,
272 				wr_ex_ro : 1,
273 				resbits3 : 1,
274 				ex_ac : 1,
275 				resbits2 : 1,
276 				wr_ex : 1,
277 				resbits1 : 1;
278 	uint8_t			resbits4 : 7,
279 				ex_ac_ar : 1;
280 } scsi_per_res_type_t;
281 typedef struct scsi_prin_rpt_cap {
282 	uint8_t			length[2];
283 	uint8_t			resbits2 : 3,
284 				crh : 1,
285 				sip_c : 1,
286 				atp_c : 1,
287 				resbits1 : 1,
288 				ptpl_c : 1;
289 	uint8_t			tmv : 1,
290 				resbits3 : 6,
291 				ptpl_a : 1;
292 	scsi_per_res_type_t	pr_type;
293 	uint8_t			resbytes[2];
294 } scsi_prin_rpt_cap_t;
295 
296 /*
297  * Information obtained from:
298  *	SPC-3, Revision 23
299  *	Section 6.11.5 PERSISTENCE RESERVE IN
300  * 	Table 110/111 - parameter data for READ FULL STATUS
301  *	Table 281 - TransportId format
302  */
303 typedef struct scsi_transport_id {
304 	uint8_t			format_code : 2,
305 				resbits : 2,
306 				protocol_id : 4;
307 	uint8_t			add_len[2];
308 	char			iscsi_name[1];
309 } scsi_transport_id_t;
310 typedef struct scsi_prin_status_t {
311 	uint8_t			reservation_key[8];
312 	uint8_t			resbytes1[4];
313 	uint8_t			resbits : 6,
314 				all_tg_pt : 1,
315 				r_holder : 1;
316 	uint8_t			scope : 4,
317 				type : 4;
318 	uint8_t			resbytes2[4];
319 	uint8_t			rel_tgt_port_id[2];
320 	uint8_t			add_len[4];
321 	scsi_transport_id_t	trans_id;
322 } scsi_prin_status_t;
323 typedef struct scsi_prin_full_status {
324 	uint8_t			PRgeneration[4];
325 	uint8_t			add_len[4];
326 	scsi_prin_status_t	full_desc[1];
327 } scsi_prin_full_status_t;
328 
329 /*
330  * Information obtained from:
331  *	SPC-3, Revision 23
332  *	Section 6.12.1 PERSISTENCE RESERVE OUT
333  *	Table 112 - PERSISTENCE RESERVE OUT command
334  */
335 typedef struct scsi_cdb_prout {
336 	uint8_t			cmd;
337 	uint8_t			resbits : 3,
338 				action : 5;
339 	uint8_t			scope : 4,
340 				type : 4;
341 	uint8_t			resbytes[2];
342 	uint8_t			param_len[4];
343 	uint8_t			control;
344 } scsi_cdb_prout_t;
345 
346 /*
347  * Information obtained from:
348  *	SPC-3, Revision 23
349  *	Section 6.12.3 PERSISTENCE RESERVE OUT
350  *	Table 114 - PERSISTENCE RESERVE OUT parameter list
351  */
352 typedef struct scsi_prout_plist {
353 	uint8_t			reservation_key[8];
354 	uint8_t			service_key[8];
355 	uint8_t			obsolete1[4];
356 	uint8_t			resbits1 : 4,
357 				spec_i_pt : 1,
358 				all_tg_pt : 1,
359 				resbits2 : 1,
360 				aptpl : 1;
361 	uint8_t			resbytes1;
362 	uint8_t			obsolete2[2];
363 	uint8_t			apd[1];
364 } scsi_prout_plist_t;
365 
366 #else
367 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
368 #endif	/* _BIT_FIELDS_LTOH */
369 
370 
371 /*
372  * SPC-3 revision 23, Section 6.12.2, Table 113
373  * Persistent Reservations
374  * Persistent Reserve Out service action codes
375  */
376 #define	PR_OUT_REGISTER		0x0	/* Register/unregister a reservation */
377 					/* key with the device server */
378 #define	PR_OUT_RESERVE		0x1	/* Create a persistent reservation */
379 					/* having a specified SCOPE & TYPE */
380 #define	PR_OUT_RELEASE		0x2	/* Release the selected persistent */
381 					/* reservation */
382 #define	PR_OUT_CLEAR		0x3	/* Clears all reservation keys and */
383 					/* all persistent reservations */
384 #define	PR_OUT_PREEMPT		0x4	/* Preempts persistent reservations */
385 					/* and/or removes reservations */
386 #define	PR_OUT_PREEMPT_ABORT	0x5	/* Preempts persistent reservations */
387 					/* and/or removes reservations, and */
388 					/* aborts all tasks for all preempted */
389 					/* I_T nexuses */
390 #define	PR_OUT_REGISTER_AND_IGNORE_EXISTING_KEY	0x06
391 					/* Register a reservation key with */
392 					/* the device server, or unregister a */
393 					/* reservation key */
394 #define	PR_OUT_REGISTER_MOVE	0x7	/* Register a reservation key for */
395 					/* another I_T nexus with the device */
396 					/* server and move a persistent */
397 					/* reservation to the I_T nexus */
398 
399 
400 #ifdef	__cplusplus
401 }
402 #endif
403 
404 #endif	/* _SYS_SCSI_GENERIC_PERSIST_H */
405