xref: /titanic_41/usr/src/uts/common/sys/scsi/generic/persist.h (revision dd49f125507979bb2ab505a8daf2a46d1be27051)
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 2009 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 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * SCSI Persistence Data
35  *
36  * Format of data returned as a result of PERSISTENCE RESERVER { IN | OUT }
37  */
38 
39 /*
40  * SPC-3 revision 23, Section 6.11.1, Table 102
41  * Persistent Reservations
42  * Persistent Reserve In service actions
43  */
44 #define	PR_IN_READ_KEYS		0x0 /* Read all registered reservation keys */
45 #define	PR_IN_READ_RESERVATION	0x1 /* Reads th persistent reservations */
46 #define	PR_IN_REPORT_CAPABILITIES 0x2 /* Returns capability information */
47 #define	PR_IN_READ_FULL_STATUS	0x3 /* Reads complete information about all */
48 				    /* registrations and the persistent */
49 				    /* reservations, if any */
50 /*
51  * SPC-3 revision 23, Section 6.11.3.3, Table 106
52  * Persistent reservation scope codes
53  */
54 #define	PR_LU_SCOPE		0x0	/* Persistent reservation applies to */
55 					/* full logical unit */
56 /*
57  * SPC-3 revision 23, Section 6.11.3.4, Table 107
58  * Persistent Reservations
59  * Persistent reservation type codes
60  */
61 #define	PGR_TYPE_WR_EX		0x1	/* Write Exclusive */
62 #define	PGR_TYPE_EX_AC		0x3	/* Exclusive Access */
63 #define	PGR_TYPE_WR_EX_RO	0x5	/* Write Exclusive, Registrants Only */
64 #define	PGR_TYPE_EX_AC_RO	0x6	/* Exclusive Access, Registrants Only */
65 #define	PGR_TYPE_WR_EX_AR	0x7	/* Write Exclusive, All Registrants */
66 #define	PGR_TYPE_EX_AC_AR	0x8	/* Exclusive Access, All Registrants */
67 
68 /*
69  * Information obtained from:
70  *	SPC-3, Revision 23
71  *	Section 6.11.5 PERSISTENCE RESERVE IN
72  *	Table 111 - full status descriptor format
73  */
74 /* Table 289 - iSCSI Initiator Device TransportID format */
75 
76 #define	iSCSI_PROTOCOL_ID	0x5	/* Table 262 - iSCSI Protocol ID  */
77 #define	WW_UID_DEVICE_NAME	0x0	/* Table 288 - iSCSI Transport IDs */
78 
79 
80 #if defined(_BIT_FIELDS_LTOH)
81 /*
82  * Information obtained from:
83  *	SPC-3, Revision 23
84  *	Section 6.11.1 PERSISTENCE RESERVE IN
85  *	Table 101 - PERSISTENCE RESERVE IN command
86  */
87 typedef struct scsi_cdb_prin {
88 	uint8_t			cmd;
89 	uint8_t			action : 5,
90 				resbits : 3;
91 	uint8_t			resbytes[5];
92 	uint8_t			alloc_len[2];
93 	uint8_t			control;
94 } scsi_cdb_prin_t;
95 
96 /*
97  * Information obtained from:
98  *	SPC-3, Revision 23
99  *	Section 6.11.2 PERSISTENCE RESERVE IN
100  *	Table 103/104/105 - parameter data for READS KEYS
101  */
102 typedef struct scsi_prin_rsrvdesc {
103 	uint8_t			reservation_key[8];
104 	uint8_t			obsolete1[4];
105 	uint8_t			resbytes;
106 	uint8_t			type : 4,
107 				scope : 4;
108 	uint8_t			obsolete2[2];
109 } scsi_prin_rsrvdesc_t;
110 typedef struct scsi_prin_readrsrv {
111 	uint8_t			PRgeneration[4];
112 	uint8_t			add_len[4];
113 	union {
114 		uint64_t		service_key[1];
115 		scsi_prin_rsrvdesc_t	res_key_list[1];
116 	} key_list;
117 } scsi_prin_readrsrv_t;
118 
119 /*
120  * Information obtained from:
121  *	SPC-3, Revision 23
122  *	Section 6.11.4 PERSISTENCE RESERVE IN
123  * 	Table 108 - parameter data for REPORT CAPABILTIES
124  */
125 typedef struct scsi_per_res_type {
126 	uint8_t			resbits1 : 1,
127 				wr_ex : 1,
128 				resbits2 : 1,
129 				ex_ac : 1,
130 				resbits3 : 1,
131 				wr_ex_ro : 1,
132 				ex_ac_ro : 1,
133 				wr_ex_ar : 1;
134 	uint8_t			ex_ac_ar : 1,
135 				resbits4 : 7;
136 } scsi_per_res_type_t;
137 
138 /*
139  * Refer SPC-3, Revision 23
140  * Section 6.11.4 REPORT CAPABILITIES service action
141  */
142 typedef struct scsi_prin_rpt_cap {
143 	uint8_t			length[2];
144 	uint8_t			ptpl_c : 1,
145 				resbits1 : 1,
146 				atp_c : 1,
147 				sip_c : 1,
148 				crh : 1,
149 				resbits2 : 3;
150 	uint8_t			ptpl_a : 1,
151 				resbits3 : 6,
152 				tmv : 1;
153 	scsi_per_res_type_t	pr_type;
154 	uint8_t			resbytes[2];
155 } scsi_prin_rpt_cap_t;
156 
157 /*
158  * Refer SPC-3, Revision 23
159  * Section 7.5.4 TransportID identifiers
160  */
161 typedef struct scsi_transport_id {
162 	uint8_t			protocol_id : 4,
163 				resbits : 2,
164 				format_code : 2;
165 	uint8_t			protocol_data[1];
166 } scsi_transport_id_t;
167 
168 typedef struct scsi_fc_transport_id {
169 	uint8_t			protocol_id : 4,
170 				resbits : 2,
171 				format_code : 2;
172 	uint8_t			rsvbytes1[7];
173 	uint8_t			port_name[8];
174 	uint8_t			rsvbytes2[8];
175 } scsi_fc_transport_id_t;
176 
177 typedef struct iscsi_transport_id {
178 	uint8_t			protocol_id : 4,
179 				resbits : 2,
180 				format_code : 2;
181 	uint8_t			rsvbyte1;
182 	uint8_t			add_len[2];
183 	char			iscsi_name[1];
184 } iscsi_transport_id_t;
185 
186 typedef struct scsi_srp_transport_id {
187 	uint8_t			protocol_id : 4,
188 				resbits : 2,
189 				format_code : 2;
190 	uint8_t			rsvbytes1[7];
191 	uint8_t			srp_name[16];
192 } scsi_srp_transport_id_t;
193 
194 /*
195  * Information obtained from:
196  *	SPC-3, Revision 23
197  *	Section 6.11.5 PERSISTENCE RESERVE IN
198  * 	Table 110/111 - parameter data for READ FULL STATUS
199  *	Table 281 - TransportId format
200  */
201 
202 typedef struct scsi_prin_status_t {
203 	uint8_t			reservation_key[8];
204 	uint8_t			resbytes1[4];
205 	uint8_t			r_holder : 1,
206 				all_tg_pt : 1,
207 				resbits : 6;
208 	uint8_t			type : 4,
209 				scope : 4;
210 	uint8_t			resbytes2[4];
211 	uint8_t			rel_tgt_port_id[2];
212 	uint8_t			add_len[4];
213 	scsi_transport_id_t	trans_id;
214 } scsi_prin_status_t;
215 
216 typedef struct scsi_prin_full_status {
217 	uint8_t			PRgeneration[4];
218 	uint8_t			add_len[4];
219 	scsi_prin_status_t	full_desc[1];
220 } scsi_prin_full_status_t;
221 
222 /*
223  * Information obtained from:
224  *	SPC-3, Revision 23
225  *	Section 6.12.1 PERSISTENCE RESERVE OUT
226  *	Table 112 - PERSISTENCE RESERVE OUT command
227  */
228 typedef struct scsi_cdb_prout {
229 	uint8_t			cmd;
230 	uint8_t			action : 5,
231 				resbits : 3;
232 	uint8_t			type : 4,
233 				scope : 4;
234 	uint8_t			resbytes[2];
235 	uint8_t			param_len[4];
236 	uint8_t			control;
237 } scsi_cdb_prout_t;
238 
239 /*
240  * Information obtained from:
241  *	SPC-3, Revision 23
242  *	Section 6.12.3 PERSISTENCE RESERVE OUT
243  *	Table 114 - PERSISTENCE RESERVE OUT parameter list
244  */
245 typedef struct scsi_prout_plist {
246 	uint8_t			reservation_key[8];
247 	uint8_t			service_key[8];
248 	uint8_t			obsolete1[4];
249 	uint8_t			aptpl : 1,
250 				resbits1 : 1,
251 				all_tg_pt : 1,
252 				spec_i_pt : 1,
253 				resbits2 : 4;
254 	uint8_t			resbytes1;
255 	uint8_t			obsolete2[2];
256 	uint8_t			apd[1];
257 } scsi_prout_plist_t;
258 
259 /*
260  * Information obtained from:
261  *	SPC-3, Revision 23
262  *	Section 6.12.4 PERSISTENCE RESERVE OUT command with REGISTER AND MOVE
263  *	Table 117 - REGISTER and MOVE service action  parameter list
264  */
265 typedef struct scsi_prout_reg_move_plist {
266 	uint8_t			reservation_key[8];
267 	uint8_t			service_key[8];
268 	uint8_t			resbytes1;
269 	uint8_t			aptpl : 1,
270 				unreg : 1,
271 				resbits1 : 6;
272 	uint8_t			rel_tgt_port_id[2];
273 	uint8_t			tptid_len[4];
274 	uint8_t			tptid[1];
275 } scsi_prout_reg_move_plist_t;
276 
277 #elif defined(_BIT_FIELDS_HTOL)
278 /*
279  * Information obtained from:
280  *	SPC-3, Revision 23
281  *	Section 6.11.1 PERSISTENCE RESERVE IN
282  *	Table 101 - PERSISTENCE RESERVE IN command
283  */
284 typedef struct scsi_cdb_prin {
285 	uint8_t			cmd;
286 	uint8_t			resbits : 3,
287 				action : 5;
288 	uint8_t			resbytes[5];
289 	uint8_t			alloc_len[2];
290 	uint8_t			control;
291 } scsi_cdb_prin_t;
292 
293 /*
294  * Information obtained from:
295  *	SPC-3, Revision 23
296  *	Section 6.11.2 PERSISTENCE RESERVE IN
297  *	Table 103/104/105 - parameter data for READS KEYS
298  */
299 typedef struct scsi_prin_rsrvdesc {
300 	uint8_t			reservation_key[8];
301 	uint8_t			obsolete1[4];
302 	uint8_t			resbytes;
303 	uint8_t			scope : 4,
304 				type : 4;
305 	uint8_t			obsolete2[2];
306 } scsi_prin_rsrvdesc_t;
307 typedef struct scsi_prin_readrsrv {
308 	uint8_t			PRgeneration[4];
309 	uint8_t			add_len[4];
310 	union {
311 		uint64_t		service_key[1];
312 		scsi_prin_rsrvdesc_t	res_key_list[1];
313 	} key_list;
314 } scsi_prin_readrsrv_t;
315 
316 /*
317  * Information obtained from:
318  *	SPC-3, Revision 23
319  *	Section 6.11.4 PERSISTENCE RESERVE IN
320  * 	Table 108 - parameter data for REPORT CAPABILTIES
321  */
322 typedef struct scsi_per_res_type {
323 	uint8_t			wr_ex_ar : 1,
324 				ex_ac_ro : 1,
325 				wr_ex_ro : 1,
326 				resbits3 : 1,
327 				ex_ac : 1,
328 				resbits2 : 1,
329 				wr_ex : 1,
330 				resbits1 : 1;
331 	uint8_t			resbits4 : 7,
332 				ex_ac_ar : 1;
333 } scsi_per_res_type_t;
334 /*
335  * Refer SPC-3, Revision 23
336  * Section 6.11.4 REPORT CAPABILITIES service action
337  */
338 typedef struct scsi_prin_rpt_cap {
339 	uint8_t			length[2];
340 	uint8_t			resbits2 : 3,
341 				crh : 1,
342 				sip_c : 1,
343 				atp_c : 1,
344 				resbits1 : 1,
345 				ptpl_c : 1;
346 	uint8_t			tmv : 1,
347 				resbits3 : 6,
348 				ptpl_a : 1;
349 	scsi_per_res_type_t	pr_type;
350 	uint8_t			resbytes[2];
351 } scsi_prin_rpt_cap_t;
352 
353 /*
354  * Refer SPC-3, Revision 23
355  * Section 7.5.4 TransportID identifiers
356  */
357 typedef struct scsi_transport_id {
358 	uint8_t			format_code : 2,
359 				resbits : 2,
360 				protocol_id : 4;
361 	uint8_t			protocol_data[1];
362 } scsi_transport_id_t;
363 
364 typedef struct scsi_fc_transport_id {
365 	uint8_t			format_code : 2,
366 				resbits : 2,
367 				protocol_id : 4;
368 	uint8_t			rsvbytes1[7];
369 	uint8_t			port_name[8];
370 	uint8_t			rsvbytes2[8];
371 } scsi_fc_transport_id_t;
372 
373 typedef struct iscsi_transport_id {
374 	uint8_t			format_code : 2,
375 				resbits : 2,
376 				protocol_id : 4;
377 	uint8_t			rsvbyte1;
378 	uint8_t			add_len[2];
379 	char			iscsi_name[1];
380 } iscsi_transport_id_t;
381 
382 
383 typedef struct scsi_srp_transport_id {
384 	uint8_t			format_code : 2,
385 				resbits : 2,
386 				protocol_id : 4;
387 	uint8_t			rsvbytes1[7];
388 	uint8_t			srp_name[16];
389 } scsi_srp_transport_id_t;
390 
391 /*
392  * Information obtained from:
393  *	SPC-3, Revision 23
394  *	Section 6.11.5 PERSISTENCE RESERVE IN
395  * 	Table 110/111 - parameter data for READ FULL STATUS
396  *	Table 281 - TransportId format
397  */
398 
399 typedef struct scsi_prin_status_t {
400 	uint8_t			reservation_key[8];
401 	uint8_t			resbytes1[4];
402 	uint8_t			resbits : 6,
403 				all_tg_pt : 1,
404 				r_holder : 1;
405 	uint8_t			scope : 4,
406 				type : 4;
407 	uint8_t			resbytes2[4];
408 	uint8_t			rel_tgt_port_id[2];
409 	uint8_t			add_len[4];
410 	scsi_transport_id_t	trans_id;
411 } scsi_prin_status_t;
412 typedef struct scsi_prin_full_status {
413 	uint8_t			PRgeneration[4];
414 	uint8_t			add_len[4];
415 	scsi_prin_status_t	full_desc[1];
416 } scsi_prin_full_status_t;
417 
418 /*
419  * Information obtained from:
420  *	SPC-3, Revision 23
421  *	Section 6.12.1 PERSISTENCE RESERVE OUT
422  *	Table 112 - PERSISTENCE RESERVE OUT command
423  */
424 typedef struct scsi_cdb_prout {
425 	uint8_t			cmd;
426 	uint8_t			resbits : 3,
427 				action : 5;
428 	uint8_t			scope : 4,
429 				type : 4;
430 	uint8_t			resbytes[2];
431 	uint8_t			param_len[4];
432 	uint8_t			control;
433 } scsi_cdb_prout_t;
434 
435 /*
436  * Information obtained from:
437  *	SPC-3, Revision 23
438  *	Section 6.12.3 PERSISTENCE RESERVE OUT
439  *	Table 114 - PERSISTENCE RESERVE OUT parameter list
440  */
441 typedef struct scsi_prout_plist {
442 	uint8_t			reservation_key[8];
443 	uint8_t			service_key[8];
444 	uint8_t			obsolete1[4];
445 	uint8_t			resbits1 : 4,
446 				spec_i_pt : 1,
447 				all_tg_pt : 1,
448 				resbits2 : 1,
449 				aptpl : 1;
450 	uint8_t			resbytes1;
451 	uint8_t			obsolete2[2];
452 	uint8_t			apd[1];
453 } scsi_prout_plist_t;
454 
455 /*
456  * Information obtained from:
457  *	SPC-3, Revision 23
458  *	Section 6.12.4 PERSISTENCE RESERVE OUT command with REGISTER AND MOVE
459  *	Table 117 - REGISTER and MOVE service action  parameter list
460  */
461 typedef struct scsi_prout_reg_move_plist {
462 	uint8_t			reservation_key[8];
463 	uint8_t			service_key[8];
464 	uint8_t			resbytes1;
465 	uint8_t			resbits1 : 6,
466 				unreg    : 1,
467 				aptpl    : 1;
468 	uint8_t			rel_tgt_port_id[2];
469 	uint8_t			tptid_len[4];
470 	uint8_t			tptid[1];
471 } scsi_prout_reg_move_plist_t;
472 
473 #else
474 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
475 #endif	/* _BIT_FIELDS_LTOH */
476 
477 
478 /*
479  * SPC-3 revision 23, Section 6.12.2, Table 113
480  * Persistent Reservations
481  * Persistent Reserve Out service action codes
482  */
483 #define	PR_OUT_REGISTER		0x0	/* Register/unregister a reservation */
484 					/* key with the device server */
485 #define	PR_OUT_RESERVE		0x1	/* Create a persistent reservation */
486 					/* having a specified SCOPE & TYPE */
487 #define	PR_OUT_RELEASE		0x2	/* Release the selected persistent */
488 					/* reservation */
489 #define	PR_OUT_CLEAR		0x3	/* Clears all reservation keys and */
490 					/* all persistent reservations */
491 #define	PR_OUT_PREEMPT		0x4	/* Preempts persistent reservations */
492 					/* and/or removes reservations */
493 #define	PR_OUT_PREEMPT_ABORT	0x5	/* Preempts persistent reservations */
494 					/* and/or removes reservations, and */
495 					/* aborts all tasks for all preempted */
496 					/* I_T nexuses */
497 #define	PR_OUT_REGISTER_AND_IGNORE_EXISTING_KEY	0x06
498 					/* Register a reservation key with */
499 					/* the device server, or unregister a */
500 					/* reservation key */
501 #define	PR_OUT_REGISTER_MOVE	0x7	/* Register a reservation key for */
502 					/* another I_T nexus with the device */
503 					/* server and move a persistent */
504 					/* reservation to the I_T nexus */
505 
506 
507 #ifdef	__cplusplus
508 }
509 #endif
510 
511 #endif	/* _SYS_SCSI_GENERIC_PERSIST_H */
512