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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_SCSI_SCSI_ADDRESS_H
27 #define _SYS_SCSI_SCSI_ADDRESS_H
29 #include <sys/scsi/scsi_types.h>
36 * SCSI address definition.
38 * A scsi_address(9S) structure stores the host adapter routing and
39 * scsi_device(9S) unit-address routing information necessary to reference
40 * a specific SCSI target device logical unit function.
42 * Host adapter routing information is stored in the scsi_hba_tran(9S)
43 * structure, pointed to by the scsi_address(9S) 'a_hba_tran' field.
45 * The scsi_device(9S) unit-address routing information (i.e. SCSA's
46 * representation of leaf disk/tape driver's "@unit-address" portion of
47 * a /devices path) is maintained in three different forms:
49 * SCSI_HBA_ADDR_SPI: In SCSI_HBA_ADDR_SPI mode (default), the SCSA
50 * framework, during initialization, places unit-address property
51 * information, converted to numeric form, directly into the
52 * 'a_target' and 'a_lun' fields of the scsi_address(9S) structure
53 * (embedded in the scsi_device(9S) structure). To maintain
54 * per-scsi_device(9S) state, host adapter drivers often use
55 * 'a_target' and 'a_lun' to index into a large fixed array
56 * (limited by the drivers idea of maximum supported target and
59 * NOTE: a_sublun is reserved for internal use only and has never
60 * been part of DDI scsi_address(9S).
62 * SCSI_HBA_ADDR_COMPLEX: The host adapter driver will maintain
63 * per-unit-address/per-scsi_device(9S) HBA private state by using
64 * scsi_device_hba_private_set(9F) during tran_tgt_init(9E) (using
65 * property interfaces to obtain/convert unit-address information into
66 * a host adapter private form). In SCSI_HBA_ADDR_COMPLEX mode, the SCSA
67 * framework, prior to tran_tgt_init(9E), places a pointer to the
68 * scsi_device(9S) in the 'a.a_sd' scsi_address(9S) field, and uses
69 * 'sd_hba_private' to store per-scsi_device hba private data.
71 * SCSI_HBA_TRAN_CLONE: SCSI_HBA_TRAN_CLONE is an older method for
72 * supporting devices with non-SPI unit-address. It is still
73 * supported, but its use is discouraged. From a unit-address
74 * perspective, operation is similar to SCSI_HBA_ADDR_COMPLEX, but
75 * per-scsi_device(9S) state is supported via 'cloning' of the
76 * scsi_hba_tran(9S) structure (to provide a per-scsi_device(9S)
77 * version of 'tran_tgt_private'/'tran_sd' accessible via
80 * NOTE: Compatible evolution of SCSA is constrained by the fact that the
81 * scsi_address(9S) structure is embedded at the base of the scsi_device(9S)
82 * structure, and is structure copied into the base of each allocated
83 * scsi_pkt(9S) structure.
85 * In general, device unit-address information is used exclusively by
86 * the host adapter driver (the exception being target drivers
87 * communicating with SCSI Parallel Interconnect (SPI) SCSI-1 devices
88 * that embed SCSI logical unit addressing in the CDB). Target drivers
89 * which need to communicate with SPI SCSI-1 devices that embed logical
90 * unit addresses in the CDB must obtain target and logical unit
91 * addresses from the device's properties (SCSI_ADDR_PROP_TARGET and
92 * SCSI_ADDR_PROP_LUN).
95 struct scsi_hba_tran
*a_hba_tran
; /* Transport vector */
98 ushort_t a_target
; /* ua target */
99 uchar_t a_lun
; /* ua lun on target */
100 uchar_t _a_sublun
; /* (private) */
102 struct scsi_device
*a_sd
; /* COMPLEX: (private) */
103 } a
; /* device unit-adddress info */
105 #define a_target a.spi.a_target
106 #define a_lun a.spi.a_lun
107 #define a_sublun a.spi._a_sublun
109 /* Device unit-address property names */
110 #define SCSI_ADDR_PROP_TARGET "target"
111 #define SCSI_ADDR_PROP_LUN "lun"
112 #define SCSI_ADDR_PROP_TARGET_UA "target-ua" /* string */
113 #define SCSI_ADDR_PROP_LUN64 "lun64"
114 #define SCSI_ADDR_PROP_SFUNC "sfunc"
117 * Normalized representation of a scsi_lun (with SCSI-2 lun positioned
118 * for compatibility).
120 typedef uint64_t scsi_lun64_t
;
121 #define PRIlun64 PRIx64
123 #define SCSI_LUN64_ILLEGAL (-1L)
125 #define SCSI_LUN64_ILLEGAL (-1LL)
128 /* Structure of a 64-bit SCSI LUN per SCSI standard */
129 typedef struct scsi_lun
{
130 uchar_t sl_lun1_msb
; /* format */
131 uchar_t sl_lun1_lsb
; /* first level */
133 uchar_t sl_lun2_lsb
; /* second level */
135 uchar_t sl_lun3_lsb
; /* third level */
137 uchar_t sl_lun4_lsb
; /* fourth level */
144 #endif /* _SYS_SCSI_SCSI_ADDRESS_H */