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