1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3 * 4 * This file is provided under a dual BSD/GPLv2 license. When using or 5 * redistributing this file, you may do so under either license. 6 * 7 * GPL LICENSE SUMMARY 8 * 9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of version 2 of the GNU General Public License as 13 * published by the Free Software Foundation. 14 * 15 * This program is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 23 * The full GNU General Public License is included in this distribution 24 * in the file called LICENSE.GPL. 25 * 26 * BSD LICENSE 27 * 28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 29 * All rights reserved. 30 * 31 * Redistribution and use in source and binary forms, with or without 32 * modification, are permitted provided that the following conditions 33 * are met: 34 * 35 * * Redistributions of source code must retain the above copyright 36 * notice, this list of conditions and the following disclaimer. 37 * * Redistributions in binary form must reproduce the above copyright 38 * notice, this list of conditions and the following disclaimer in 39 * the documentation and/or other materials provided with the 40 * distribution. 41 * 42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 * 54 * $FreeBSD$ 55 */ 56 #ifndef _SCIF_REMOTE_DEVICE_H_ 57 #define _SCIF_REMOTE_DEVICE_H_ 58 59 /** 60 * @file 61 * 62 * @brief This file contains all of the interface methods that can be called 63 * by an SCI Framework user on a remote device object. The 64 * framework remote device object provides management of resets for 65 * the remote device, IO thresholds, potentially NCQ tag management, 66 * etc. 67 */ 68 69 #ifdef __cplusplus 70 extern "C" { 71 #endif // __cplusplus 72 73 #include <dev/isci/scil/sci_types.h> 74 #include <dev/isci/scil/sci_status.h> 75 #include <dev/isci/scil/intel_sas.h> 76 77 78 /** 79 * This constant is utilized to inform the user that there is no defined 80 * maximum request queue depth associated with a remote device. 81 */ 82 #define SCIF_REMOTE_DEVICE_NO_MAX_QUEUE_DEPTH 0xFFFF 83 84 /** 85 * @brief This method simply returns the maximum memory space needed to 86 * store a remote device object. The value returned includes enough 87 * space for the framework and core device objects. 88 * 89 * @return a positive integer value indicating the size (in bytes) of the 90 * remote device object. 91 */ 92 U32 scif_remote_device_get_object_size( 93 void 94 ); 95 96 /** 97 * @brief This method performs the construction common to all device object 98 * types in the framework. 99 * 100 * @note 101 * - Remote device objects in the core are a limited resource. Since 102 * the framework construction/destruction methods wrap the core, the 103 * user must ensure that a construct or destruct method is never 104 * invoked when an existing construct or destruct method is ongoing. 105 * This method shall be utilized for discovered direct attached 106 * devices. 107 * - It isn't necessary to call scif_remote_device_destruct() for 108 * device objects that have only called this method for construction. 109 * Once subsequent construction methods have been invoked (e.g. 110 * scif_remote_device_da_construct()), then destruction should occur. 111 * 112 * @param[in] domain This parameter specifies the domain in which this 113 * remote device is contained. 114 * @param[in] remote_device_memory This parameter specifies the memory 115 * location into which this method shall construct the new 116 * framework device object. 117 * @param[out] new_scif_remote_device_handle This parameter specifies the 118 * handle to be used to communicate with the newly constructed 119 * framework remote device. 120 * 121 * @return none 122 */ 123 void scif_remote_device_construct( 124 SCI_DOMAIN_HANDLE_T domain, 125 void * remote_device_memory, 126 SCI_REMOTE_DEVICE_HANDLE_T * new_scif_remote_device_handle 127 ); 128 129 /** 130 * @brief This method constructs a new framework remote device object. The 131 * remote device object shall remember it's counterpart core device 132 * object as well as the domain in which it is contained. 133 * 134 * @note Remote device objects in the core are a limited resource. Since 135 * the framework construction/destruction methods wrap the core, the 136 * user must ensure that a construct or destruct method is never 137 * invoked when an existing construct or destruct method is ongoing. 138 * This method shall be utilized for discovered direct attached 139 * devices. 140 * 141 * @pre The user must have previously called scif_remote_device_construct() 142 * 143 * @param[in] remote_device This parameter specifies the framework device 144 * for which to perform direct attached specific construction. 145 * @param[in] sas_address This parameter specifies the SAS address of the 146 * remote device object being constructed. 147 * @param[in] protocols This parameter specifies the protocols supported 148 * by the remote device to be constructed. 149 * 150 * @return Indicate if the remote device was successfully constructed. 151 * @retval SCI_SUCCESS This value is returned if the remote device was 152 * successfully constructed. 153 * @retval SCI_FAILURE_DEVICE_EXISTS Returned if the device has already 154 * been constructed. 155 * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if 156 * the core controller associated with the supplied parameters 157 * is unable to support additional remote devices. 158 */ 159 SCI_STATUS scif_remote_device_da_construct( 160 SCI_REMOTE_DEVICE_HANDLE_T remote_device, 161 SCI_SAS_ADDRESS_T * sas_address, 162 SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T * protocols 163 ); 164 165 /** 166 * @brief This method constructs a new framework remote device object. The 167 * remote device object shall remember it's counterpart core device 168 * object as well as the domain in which it is contained. 169 * 170 * @pre The user must have previously called scif_remote_device_construct() 171 * 172 * @note Remote device objects in the core are a limited resource. Since 173 * the framework construction/destruction methods wrap the core, the 174 * user must ensure that a construct or destruct method is never 175 * invoked when an existing construct or destruct method is ongoing. 176 * This method shall be utilized for discovered expander attached 177 * devices. 178 * 179 * @param[in] remote_device This parameter specifies the framework device 180 * for which to perform expander specific construction. 181 * @param[in] containing_device This parameter specifies the remote 182 * device (i.e. an expander) that contains the device being 183 * constructed. 184 * @param[in] smp_response This parameter specifies the SMP_RESPONSE_DISCOVER 185 * associated with the remote device being constructed. 186 * 187 * @return Indicate if the remote device was successfully constructed. 188 * @retval SCI_SUCCESS This value is returned if the remote device was 189 * successfully constructed. 190 * @retval SCI_FAILURE_DEVICE_EXISTS Returned if the device has already 191 * been constructed. 192 * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if 193 * the core controller associated with the supplied parameters 194 * is unable to support additional remote devices. 195 */ 196 SCI_STATUS scif_remote_device_ea_construct( 197 SCI_REMOTE_DEVICE_HANDLE_T remote_device, 198 SCI_REMOTE_DEVICE_HANDLE_T containing_device, 199 SMP_RESPONSE_DISCOVER_T * smp_response 200 ); 201 202 203 /** 204 * @brief This method is utilized to free up a framework's remote 205 * device object. 206 * 207 * @note Remote device objects in the core are a limited resource. Since 208 * the framework construction/destruction methods wrap the core, the 209 * user must ensure that a construct or destruct method is never 210 * invoked when an existing construct or destruct method is ongoing. 211 * 212 * @param[in] remote_device This parameter specifies the remote device to be 213 * destructed. 214 * 215 * @return The return value shall indicate if the device was successfully 216 * destructed or if some failure occurred. 217 * @retval SCI_STATUS This value is returned if the device is successfully 218 * destructed. 219 * @retval SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the 220 * supplied device isn't valid (e.g. it's already been destructed, 221 * the handle isn't valid, etc.). 222 */ 223 SCI_STATUS scif_remote_device_destruct( 224 SCI_REMOTE_DEVICE_HANDLE_T remote_device 225 ); 226 227 /** 228 * @brief This method simply returns the SCI Core object handle that is 229 * associated with the supplied SCI Framework object. 230 * 231 * @param[in] remote_device This parameter specifies the framework device 232 * for which to return the associated core remote device. 233 * 234 * @return This method returns a handle to the core remote device object 235 * associated with the framework remote device object. 236 * @retval SCI_INVALID_HANDLE This return value indicates that the SCI Core 237 * remote device handle for the supplied framework device is invalid. 238 */ 239 SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device_get_scic_handle( 240 SCI_REMOTE_DEVICE_HANDLE_T remote_device 241 ); 242 243 /** 244 * @brief This method returns the maximum queue depth supported for the 245 * supplied target by this SCI Framework impementation. 246 * 247 * @param[in] remote_device This parameter specifies the framework 248 * device for which to return the maximum queue depth. 249 * 250 * @return This method returns a value indicating the maximum number of 251 * IO requests that can be outstanding for the target at any 252 * point in time. 253 * @retval SCIF_REMOTE_DEVICE_NO_MAX_QUEUE_DEPTH This value is returned 254 * when there is no defined maximum queue depth for the target. 255 */ 256 U16 scif_remote_device_get_max_queue_depth( 257 SCI_REMOTE_DEVICE_HANDLE_T remote_device 258 ); 259 260 /** 261 * @brief This method will return the handle to the parent device of the 262 * remote device. 263 * 264 * @param[in] remote_device This parameter specifies the device for which 265 * to return the parent device. 266 * @param[out] containing_device This parameter specifies the device 267 * handle, from the remote device object, which indicate 268 * the parent device of the supplied remote_device. 269 * 270 * @return none 271 */ 272 SCI_STATUS scif_remote_device_get_containing_device( 273 SCI_REMOTE_DEVICE_HANDLE_T remote_device, 274 SCI_REMOTE_DEVICE_HANDLE_T * containing_device 275 ); 276 277 /** 278 * @brief This method returns the number of IO currently started 279 * to the supplied target. It does not include task 280 * management requests. 281 * 282 * @param[in] remote_device This parameter specifies the framework 283 * device for which to return the number of started IO. 284 * 285 * @return This method returns a value indicating the number of started 286 * IO requests. 287 */ 288 U32 scif_remote_device_get_started_io_count( 289 SCI_REMOTE_DEVICE_HANDLE_T remote_device 290 ); 291 292 #ifdef __cplusplus 293 } 294 #endif // __cplusplus 295 296 #endif // _SCIF_REMOTE_DEVICE_H_ 297 298