xref: /titanic_50/usr/src/uts/common/sys/scsi/scsi_address.h (revision 46b28a98f70a2da2a80c8dade6586885a4241f7f)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_SCSI_ADDRESS_H
27 #define	_SYS_SCSI_SCSI_ADDRESS_H
28 
29 #include <sys/scsi/scsi_types.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * SCSI address definition.
37  *
38  * A scsi_address structure stores the host routing and device unit-address
39  * information necessary to reference a specific SCSI target device logical
40  * unit function.
41  *
42  * The host routing information is stored in the scsi_hba_tran(9S) structure
43  * pointed to by the a_hba_tran field.
44  *
45  * The device unit-address information is SCSA's representation of the
46  * "@unit-address" portion of a SCSI target driver device node in the
47  * /devices tree.  Separate components of the device unit-address information
48  * define the target address and the logical unit address of a target.
49  * In general, device unit-address information is used exclusively by the
50  * host adapter driver (the exception being target drivers communicating
51  * with SCSI Parallel Interconnect (SPI) SCSI-1 devices that embed SCSI
52  * logical unit addressing in the CDB).
53  *
54  * Thus the a_target and a_lun fields are for compatibility purposes only.
55  * They are not defined in SCSI-3.  SCSI-3 target drivers which need to
56  * communicate with SPI SCSI-1 devices that embed logical unit addresses in
57  * the CDB should obtain target and logical unit addresses from the device's
58  * properties (SCSI_ADDR_PROP_TARGET and SCSI_ADDR_PROP_LUN).
59  *
60  * a_sublun is reserved for internal use only and is never part of DDI
61  * (scsi_address(9S)).
62  */
63 struct scsi_address {
64 	struct scsi_hba_tran	*a_hba_tran;	/* Transport vectors */
65 	ushort_t		a_target;	/* Target identifier */
66 	uchar_t			a_lun;		/* Lun on that Target */
67 	uchar_t			a_sublun;	/* Sublun on that Lun */
68 						/* Not used */
69 };
70 
71 /* Device unit-address property names */
72 #define	SCSI_ADDR_PROP_TARGET		"target"
73 #define	SCSI_ADDR_PROP_LUN		"lun"
74 
75 /*
76  * Normalized representation of a scsi_lun (with SCSI-2 lun positioned
77  * for compatibility).
78  */
79 typedef uint64_t	scsi_lun64_t;
80 #define	PRIlun64	PRIx64
81 #ifdef	_LP64
82 #define	SCSI_LUN64_ILLEGAL	(-1L)
83 #else	/* _LP64 */
84 #define	SCSI_LUN64_ILLEGAL	(-1LL)
85 #endif	/* _LP64 */
86 
87 /* Structure of a 64-bit SCSI LUN per SCSI standard */
88 typedef	struct scsi_lun {
89 	uchar_t	sl_lun1_msb;	/* format */
90 	uchar_t	sl_lun1_lsb;	/* first level */
91 	uchar_t	sl_lun2_msb;
92 	uchar_t	sl_lun2_lsb;	/* second level */
93 	uchar_t	sl_lun3_msb;
94 	uchar_t	sl_lun3_lsb;	/* third level */
95 	uchar_t	sl_lun4_msb;
96 	uchar_t	sl_lun4_lsb;	/* fourth level */
97 } scsi_lun_t;
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _SYS_SCSI_SCSI_ADDRESS_H */
104