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 28illumos architecture specific (illumos DDI). 29.Sh PARAMETERS 30.Bl -tag -width Fa 31.It Fa dip 32Pointer to the 33.Vt dev_info_t 34structure that refers to the instance of the HBA device. 35.It Fa hba_tran 36Pointer to a 37.Xr scsi_hba_tran 9S 38structure. 39.It Fa hba_flags 40Flag modifiers. 41The 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 , 46and 47.Dv SCSI_HBA_ADDR_COMPLEX . 48.It Fa hba_dma_attr 49Pointer to a 50.Xr ddi_dma_attr 9S 51structure. 52.El 53.Sh DESCRIPTION 54.Ss Fn scsi_hba_attach_setup 55The 56.Fn scsi_hba_attach_setup 57function registers the 58.Fa hba_dma_attr 59DMA attributes and the 60.Fa hba_tran 61transport vectors of each instance of the HBA device defined by 62.Fa dip . 63The HBA driver can pass different DMA attributes and the transport 64vectors for each instance of the device to support any constraints 65imposed by the HBA itself. 66.Pp 67The 68.Fn scsi_hba_attach_setup 69function uses the 70.Vt dev_bus_ops 71field in the 72.Xr dev_ops 9S 73structure. 74The HBA driver should initialize this field to 75.Dv NULL 76before calling 77.Fn scsi_hba_attach_setup . 78.Pp 79If 80.Dv SCSI_HBA_TRAN_CLONE 81is requested in 82.Fa hba_flags , 83the 84Fa hba_tran 85structure is cloned once for each target that is attached to the 86HBA. 87The use of this flag is deprecated, drivers should instead use 88.Dv SCSI_HBA_ADDR_COMPLEX 89for per-target data. 90.Pp 91The structure is cloned before the 92.Xr tran_tgt_init 9E 93entry point is called to initialize a target. 94At all subsequent HBA 95entry points, including 96.Xr tran_tgt_init 9E , 97the 98.Vt scsi_hba_tran_t 99structure passed as an 100argument or found in a 101.Xr scsi_address 9S 102structure is the cloned 103.Vt scsi_hba_tran_t 104structure, which allows the HBA to use the 105.Vt tran_tgt_private 106field in the 107.Vt scsi_hba_tran_t 108structure to point to per-target data. 109The HBA should free only the same 110.Vt scsi_hba_tran_t 111structure allocated when the HBA detaches. 112All cloned 113.Vt scsi_hba_tran_t 114structures that are allocated by the system are freed by the system. 115.Pp 116The flags 117.Dv SCSI_HBA_TRAN_CDB 118and 119.Dv SCSI_HBA_TRAN_SCB 120are only valid 121when 122.Fn tran_setup_pkt 123is used. 124See 125.Xr tran_setup_pkt 9E 126for information on using these flags. 127.Pp 128The flag 129.Dv SCSI_HBA_ADDR_COMPLEX 130indicates to the system that this device handles more complex SCSI 131topologies, such as SAS. 132When this flag is set, the 133.Xr scsi_address 9S 134structure becomes opaque. 135The driver must not check it for the traditional target and LUN values. 136Instead, a target and LUN are identified by a unit address which can be 137retrieved using the 138.Xr scsi_device_unit_address 9F 139function. 140.Pp 141When operating with the flag 142.Dv SCSI_HBA_ADDR COMPLEX , 143the driver may associate private data with the 144.Xr scsi_device 9S 145structure. 146This obviates the need and complexity around using 147.Dv SCSI_HBA_TRAN_CLONE 148flag. 149To get and set private data, the driver can use the 150.Xr scsi_device_hba_private_get 9F 151and 152.Xr scsi_device_hba_private_set 9F 153functions. 154Notably, the 155.Fn scsi_device_hba_private_set 156function should be used during the 157.Xr tran_tgt_init 9E 158entry point. 159The 160.Fn scsi_device_hba_private_get 161function should then be used during other SCSI HBA entry points. 162In addition, the 163.Xr scsi_address_device 9F 164function now becomes available to the driver to map between the 165.Xr scsi_device 9S 166and 167.Xr scsi_address 9S 168structures. 169.Pp 170The 171.Dv SCSI_HBA_HBA 172flag indicates that the HBA driver will only enumerate direct children 173which are 174.Xr iport 9 175instances. 176This mode of operation is recommended for device drivers as 177it simplifies the management of discovered devices. 178This flag is often used in tandem with 179.Dv SCSI_HBA_ADDR_COMPLEX 180and is recommended for all new SAS-based HBA drivers. 181For more information on the management of iports and the use of target 182maps, please see 183.Xr iport 9 . 184.Pp 185The 186.Fn scsi_hba_attach_setup 187function attaches a number of integer-valued properties to 188.Fa dip , 189unless properties of the same name are already attached to the node. 190An HBA driver should retrieve these configuration parameters via 191.Xr ddi_prop_get_int 9F , 192and respect any settings for features provided the HBA. 193.Bl -tag -width Sy 194.It Sy scsi-options 195.Sy Optional SCSI configuration bits . 196The following values may be bitwise-inclusive-ORed together. 197.Bl -tag -width Dv 198.It Dv SCSI_OPTIONS_DR 199If not set, the HBA should not grant Disconnect privileges to target devices. 200.It Dv SCSI_OPTIONS_TAG 201If not set, the HBA should not operate in Command Tagged Queueing mode. 202.It Dv SCSI_OPTIONS_PARITY 203If not set, the HBA should not operate in parity mode. 204.It Dv SCSI_OPTIONS_QAS 205If not set, the HBA should not make use of the Quick Arbitration Select 206feature. 207Consult your hardware documentation to determine whether your 208machine supports QAS. 209.It Dv SCSI_OPTIONS_FAST 210If not set, the HBA should not operate the bus in FAST SCSI mode. 211.It Dv SCSI_OPTIONS_FAST20 212If not set, the HBA should not operate the bus in FAST20 SCSI mode. 213.It Dv SCSI_OPTIONS_FAST40 214If not set, the HBA should not operate the bus in FAST40 SCSI mode. 215.It Dv SCSI_OPTIONS_FAST80 216If not set, the HBA should not operate the bus in FAST80 SCSI mode. 217.It Dv SCSI_OPTIONS_FAST160 218If not set, the HBA should not operate the bus in FAST160 SCSI mode. 219.It Dv SCSI_OPTIONS_FAST320 220If not set, the HBA should not operate the bus in FAST320 SCSI mode. 221.It Dv SCSI_OPTIONS_WIDE 222If not set, the HBA should not operate the bus in WIDE SCSI mode. 223.It Dv SCSI_OPTIONS_SYNC 224If not set, the HBA should not operate the bus in synchronous transfer mode. 225.El 226.It Sy scsi-reset-delay 227SCSI bus or device reset recovery time, in milliseconds. 228.It Sy scsi-selection-timeout 229Default SCSI selection phase timeout value, in milliseconds. 230Please refer to individual HBA man pages for any HBA-specific 231information 232.El 233.Ss Fn scsi_hba_detach 234The 235.Fn scsi_hba_detach 236function removes the reference to the DMA attributes structure and the 237transport vector for the given instance of an HBA driver. 238.Sh CONTEXT 239The 240.Fn scsi_hba_attach_setup 241function should be called from 242.Xr attach 9E . 243The 244.Fn scsi_hba_detach 245function should be called from 246.Xr detach 9E . 247.Sh RETURN VALUES 248The 249.Fn scsi_hba_attach_setup 250and 251.Fn scsi_hba_detach 252functions return 253.Dv DDI_SUCCESS 254if the function call succeeds, and return 255.Dv DDI_FAILURE 256on 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 273.Pp 274.Rs 275.%T Writing Device Drivers 276.Re 277.Sh NOTES 278It is the HBA driver's responsibility to ensure that no more transport requests 279will be taken on behalf of any SCSI target device driver after 280.Fn scsi_hba_detach 281is called. 282