Unleashed v1.4
[unleashed.git] / share / man / man9f / scsi_hba_attach_setup.9f
blob45a72a06ca14ef1fe898fe19f9dfc47b74f7d8c0
1 .\" Copyright (c) 2006 Sun Microsystems, Inc., All Rights Reserved
2 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 .\" Copyright (c) 2017, Joyent, Inc.
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .Dd Apr 23, 2017
8 .Dt SCSI_HBA_ATTACH_SETUP 9F
9 .Os
10 .Sh NAME
11 .Nm scsi_hba_attach_setup ,
12 .Nm scsi_hba_detach
13 .Nd SCSI HBA attach and detach routines
14 .Sh SYNOPSIS
15 .In sys/scsi/scsi.h
16 .Ft int
17 .Fo scsi_hba_attach_setup
18 .Fa "dev_info_t *dip"
19 .Fa "ddi_dma_attr_t *hba_dma_attr"
20 .Fa "scsi_hba_tran_t *hba_tran"
21 .Fa "int hba_flags"
22 .Fc
23 .Ft int
24 .Fo scsi_hba_detach
25 .Fa "dev_info_t *dip"
26 .Fc
27 .Sh INTERFACE LEVEL
28 illumos architecture specific (illumos DDI).
29 .Sh PARAMETERS
30 .Bl -tag -width Fa
31 .It Fa dip
32 Pointer to the
33 .Vt dev_info_t
34 structure that refers to the instance of the HBA device.
35 .It Fa hba_tran
36 Pointer to a
37 .Xr scsi_hba_tran 9S
38 structure.
39 .It Fa hba_flags
40 Flag modifiers.
41 The defined flag values are
42 .Dv SCSI_HBA_TRAN_CLONE ,
43 .Dv SCSI_HBA_TRAN_SCB ,
44 .Dv SCSI_HBA_TRAN_CDB ,
45 .Dv SCSI_HBA_HBA ,
46 and
47 .Dv SCSI_HBA_ADDR_COMPLEX .
48 .It Fa hba_dma_attr
49 Pointer to a
50 .Xr ddi_dma_attr 9S
51 structure.
52 .El
53 .Sh DESCRIPTION
54 .Ss Fn scsi_hba_attach_setup
55 The
56 .Fn scsi_hba_attach_setup
57 function registers the
58 .Fa hba_dma_attr
59 DMA attributes and the
60 .Fa hba_tran
61 transport vectors of each instance of the HBA device defined by
62 .Fa dip .
63 The HBA driver can pass different DMA attributes and the transport
64 vectors for each instance of the device to support any constraints
65 imposed by the  HBA itself.
66 .Pp
67 The
68 .Fn scsi_hba_attach_setup
69 function uses the
70 .Vt dev_bus_ops
71 field in the
72 .Xr dev_ops 9S
73 structure.
74 The HBA driver should initialize this field to
75 .Dv NULL
76 before calling
77 .Fn scsi_hba_attach_setup .
78 .Pp
80 .Dv SCSI_HBA_TRAN_CLONE
81 is requested in
82 .Fa hba_flags ,
83 the
84 Fa hba_tran
85 structure is cloned once for each target that is attached to the
86 HBA.
87 The use of this flag is deprecated, drivers should instead use
88 .Dv SCSI_HBA_ADDR_COMPLEX
89 for per-target data.
90 .Pp
91 The structure is cloned before the
92 .Xr tran_tgt_init 9E
93 entry point is called to initialize a target.
94 At all subsequent HBA
95 entry points, including
96 .Xr tran_tgt_init 9E ,
97 the
98 .Vt scsi_hba_tran_t
99 structure passed as an
100 argument or found in a
101 .Xr scsi_address 9S
102 structure is the cloned
103 .Vt scsi_hba_tran_t
104 structure, which allows the HBA to use the
105 .Vt tran_tgt_private
106 field in the
107 .Vt scsi_hba_tran_t
108 structure to point to per-target data.
109 The HBA should free only the same
110 .Vt scsi_hba_tran_t
111 structure allocated when the HBA detaches.
112 All cloned
113 .Vt scsi_hba_tran_t
114 structures that are allocated by the system are freed by the system.
116 The flags
117 .Dv SCSI_HBA_TRAN_CDB
119 .Dv SCSI_HBA_TRAN_SCB
120 are only valid
121 when
122 .Fn tran_setup_pkt
123 is used.
125 .Xr tran_setup_pkt 9E
126 for information on using these flags.
128 The flag
129 .Dv SCSI_HBA_ADDR_COMPLEX
130 indicates to the system that this device handles more complex SCSI
131 topologies, such as SAS.
132 When this flag is set, the
133 .Xr scsi_address 9S
134 structure becomes opaque.
135 The driver must not check it for the traditional target and LUN values.
136 Instead, a target and LUN are identified by a unit address which can be
137 retrieved using the
138 .Xr scsi_device_unit_address 9F
139 function.
141 When operating with the flag
142 .Dv SCSI_HBA_ADDR COMPLEX ,
143 the driver may associate private data with the
144 .Xr scsi_device 9S
145 structure.
146 This obviates the need and complexity around using
147 .Dv SCSI_HBA_TRAN_CLONE
148 flag.
149 To get and set private data, the driver can use the
150 .Xr scsi_device_hba_private_get 9F
152 .Xr scsi_device_hba_private_set 9F
153 functions.
154 Notably, the
155 .Fn scsi_device_hba_private_set
156 function should be used during the
157 .Xr tran_tgt_init 9E
158 entry point.
160 .Fn scsi_device_hba_private_get
161 function should then be used during other SCSI HBA entry points.
162 In addition, the
163 .Xr scsi_address_device 9F
164 function now becomes available to the driver to map between the
165 .Xr scsi_device 9S
167 .Xr scsi_address 9S
168 structures.
171 .Dv SCSI_HBA_HBA
172 flag indicates that the HBA driver will only enumerate direct children
173 which are
174 .Xr iport 9
175 instances.
176 This mode of operation is recommended for device drivers as
177 it simplifies the management of discovered devices.
178 This flag is often used in tandem with
179 .Dv SCSI_HBA_ADDR_COMPLEX
180 and is recommended for all new SAS-based HBA drivers.
181 For more information on the management of iports and the use of target
182 maps, please see
183 .Xr iport 9 .
186 .Fn scsi_hba_attach_setup
187 function attaches a number of integer-valued properties to
188 .Fa dip ,
189 unless properties of the same name are already attached to the node.
190 An HBA driver should retrieve these configuration parameters via
191 .Xr ddi_prop_get_int 9F ,
192 and respect any settings for features provided the HBA.
193 .Bl -tag -width Sy
194 .It Sy scsi-options
195 .Sy Optional SCSI configuration bits .
196 The following values may be bitwise-inclusive-ORed together.
197 .Bl -tag -width Dv
198 .It Dv SCSI_OPTIONS_DR
199 If not set, the HBA should not grant Disconnect privileges to target devices.
200 .It Dv SCSI_OPTIONS_TAG
201 If not set, the HBA should not operate in Command Tagged Queueing mode.
202 .It Dv SCSI_OPTIONS_PARITY
203 If not set, the HBA should not operate in parity mode.
204 .It Dv SCSI_OPTIONS_QAS
205 If not set, the HBA should not make use of the Quick Arbitration Select
206 feature.
207 Consult your hardware documentation to determine whether your
208 machine supports QAS.
209 .It Dv SCSI_OPTIONS_FAST
210 If not set, the HBA should not operate the bus in FAST SCSI mode.
211 .It Dv SCSI_OPTIONS_FAST20
212 If not set, the HBA should not operate the bus in FAST20 SCSI mode.
213 .It Dv SCSI_OPTIONS_FAST40
214 If not set, the HBA should not operate the bus in FAST40 SCSI mode.
215 .It Dv SCSI_OPTIONS_FAST80
216 If not set, the HBA should not operate the bus in FAST80 SCSI mode.
217 .It Dv SCSI_OPTIONS_FAST160
218 If not set, the HBA should not operate the bus in FAST160 SCSI mode.
219 .It Dv SCSI_OPTIONS_FAST320
220 If not set, the HBA should not operate the bus in FAST320 SCSI mode.
221 .It Dv SCSI_OPTIONS_WIDE
222 If not set, the HBA should not operate the bus in WIDE SCSI mode.
223 .It Dv SCSI_OPTIONS_SYNC
224 If not set, the HBA should not operate the bus in synchronous transfer mode.
226 .It Sy scsi-reset-delay
227 SCSI bus or device reset recovery time, in milliseconds.
228 .It Sy scsi-selection-timeout
229 Default SCSI selection phase timeout value, in milliseconds.
230 Please refer to individual HBA man pages for any HBA-specific
231 information
233 .Ss Fn scsi_hba_detach
235 .Fn scsi_hba_detach
236 function removes the reference to the DMA attributes structure and the
237 transport vector for the given instance of an HBA driver.
238 .Sh CONTEXT
240 .Fn scsi_hba_attach_setup
241 function should be called from
242 .Xr attach 9E .
244 .Fn scsi_hba_detach
245 function should be called from
246 .Xr detach 9E .
247 .Sh RETURN VALUES
249 .Fn scsi_hba_attach_setup
251 .Fn scsi_hba_detach
252 functions return
253 .Dv DDI_SUCCESS
254 if the function call succeeds, and return
255 .Dv DDI_FAILURE
256 on failure.
257 .Sh SEE ALSO
258 .Xr iport 9 ,
259 .Xr attach 9E ,
260 .Xr detach 9E ,
261 .Xr tran_setup_pkt 9E ,
262 .Xr tran_tgt_init 9E ,
263 .Xr ddi_prop_get_int 9F ,
264 .Xr scsi_address_device 9F ,
265 .Xr scsi_device_hba_private_get 9F ,
266 .Xr scsi_device_hba_private_set 9F ,
267 .Xr scsi_device_unit_address 9F ,
268 .Xr ddi_dma_attr 9S ,
269 .Xr dev_ops 9S ,
270 .Xr scsi_address 9S ,
271 .Xr scsi_device 9S ,
272 .Xr scsi_hba_tran 9S
275 .%T Writing Device Drivers
277 .Sh NOTES
278 It is the HBA driver's responsibility to ensure that no more transport requests
279 will be taken on behalf of any SCSI target device driver after
280 .Fn scsi_hba_detach
281 is called.