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 #ifndef _SCIF_SAS_DOMAIN_H_ 55 #define _SCIF_SAS_DOMAIN_H_ 56 57 /** 58 * @file 59 * 60 * @brief This file contains the protected interface structures, constants, 61 * and methods for the SCIF_SAS_DOMAIN object. 62 */ 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif // __cplusplus 67 68 #include <dev/isci/scil/sci_abstract_list.h> 69 #include <dev/isci/scil/sci_fast_list.h> 70 #include <dev/isci/scil/scif_domain.h> 71 72 #include <dev/isci/scil/sci_base_domain.h> 73 #include <dev/isci/scil/scif_sas_request.h> 74 #include <dev/isci/scil/scif_sas_task_request.h> 75 #include <dev/isci/scil/scif_sas_remote_device.h> 76 77 78 extern SCI_BASE_DOMAIN_STATE_HANDLER_T scif_sas_domain_state_handler_table[]; 79 extern SCI_BASE_STATE_T scif_sas_domain_state_table[]; 80 81 #define PORT_HARD_RESET_TIMEOUT 1000 //1000 miliseconds 82 83 #define SCIF_DOMAIN_DISCOVER_TIMEOUT 20000 // miliseconds 84 85 /** 86 * @struct SCIF_SAS_DOMAIN 87 * 88 * @brief The SCI SAS Framework domain object abstracts the SAS domain 89 * level behavior for the framework component. Additionally, 90 * it provides a higher level of abstraction for the core port 91 * object. There is a 1:1 correspondance between core ports and 92 * framework domain objects. Essentially, each core port provides 93 * the access to the remote devices in the domain. 94 */ 95 typedef struct SCIF_SAS_DOMAIN 96 { 97 /** 98 * The SCI_BASE_DOMAIN is the parent object for the SCIF_SAS_DOMAIN 99 * object. 100 */ 101 SCI_BASE_DOMAIN_T parent; 102 103 /** 104 * This field contains the handle for the SCI Core port object that 105 * is managed by this framework domain object. 106 */ 107 SCI_PORT_HANDLE_T core_object; 108 109 /** 110 * This field specifies the controller containing this domain object. 111 */ 112 struct SCIF_SAS_CONTROLLER * controller; 113 114 /** 115 * This field references the list of state specific handler methods to 116 * be utilized for this domain instance. 117 */ 118 SCI_BASE_DOMAIN_STATE_HANDLER_T * state_handlers; 119 120 /** 121 * This field contains references to all of the devices contained in 122 * this domain. 123 */ 124 SCI_ABSTRACT_LIST_T remote_device_list; 125 126 /** 127 * This field contains the list of all outstanding request (IO or 128 * management) in this domain. 129 */ 130 SCI_FAST_LIST_T request_list; 131 132 /** 133 * This field indicates whether the core port object is in a ready state 134 * or not. 135 */ 136 BOOL is_port_ready; 137 138 /** 139 * This field indicates the number of remote devices that have been 140 * started in this domain. 141 */ 142 U32 device_start_count; 143 144 /** 145 * This field indicates the number of remote devices that are currently 146 * in the process of becoming ready. This field is utilized to gate 147 * the transition back to the READY state for the domain. 148 */ 149 U32 device_start_in_progress_count; 150 151 /** 152 * This field records how many broadcast change primitve are 153 * received and not processed yet. 154 */ 155 U32 broadcast_change_count; 156 157 /** 158 * This fields indicates whether the expanders in this domain need to 159 * have there config route table configured by our driver. For expample, 160 * if we found the top level expander is a self-configuring expander and 161 * it is able to config others, all the expanders in this domain don't 162 * need to configure route table. 163 */ 164 BOOL is_config_route_table_needed; 165 166 struct 167 { 168 /** 169 * This field provides the domain object a scratch area to indicate 170 * status of an ongoing operation. 171 */ 172 SCI_STATUS status; 173 174 /** 175 * This is the timer handle that is utilized to time the discovery 176 * or domain reset operations. 177 */ 178 void * timer; 179 180 /** 181 * This field specifies the timeout value, in milliseconds, for the 182 * entire operation (discovery or reset). 183 */ 184 U32 timeout; 185 186 /** 187 * This field specifies the timeout value, in milliseconds, for a 188 * single device. 189 */ 190 U32 device_timeout; 191 192 } operation; 193 194 } SCIF_SAS_DOMAIN_T; 195 196 void scif_sas_domain_construct( 197 SCIF_SAS_DOMAIN_T * fw_domain, 198 U8 domain_id, 199 struct SCIF_SAS_CONTROLLER * fw_controller 200 ); 201 202 void scif_sas_domain_terminate_requests( 203 SCIF_SAS_DOMAIN_T * fw_domain, 204 SCIF_SAS_REMOTE_DEVICE_T * fw_device, 205 SCIF_SAS_REQUEST_T * fw_request, 206 SCIF_SAS_TASK_REQUEST_T * fw_requestor 207 ); 208 209 SCIF_SAS_REQUEST_T * scif_sas_domain_get_request_by_io_tag( 210 SCIF_SAS_DOMAIN_T * fw_domain, 211 U16 io_tag 212 ); 213 214 void scif_sas_domain_transition_to_stopped_state( 215 SCIF_SAS_DOMAIN_T * fw_domain 216 ); 217 218 void scif_sas_domain_initialize( 219 SCIF_SAS_DOMAIN_T * fw_domain 220 ); 221 222 void scif_sas_domain_remote_device_start_complete( 223 SCIF_SAS_DOMAIN_T * fw_domain, 224 SCIF_SAS_REMOTE_DEVICE_T * fw_device 225 ); 226 227 BOOL scif_sas_domain_is_in_smp_activity( 228 SCIF_SAS_DOMAIN_T * fw_domain 229 ); 230 231 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_get_device_by_containing_device( 232 SCIF_SAS_DOMAIN_T * fw_domain, 233 SCIF_SAS_REMOTE_DEVICE_T * containing_device, 234 U8 expander_phy_id 235 ); 236 237 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_find_device_in_spinup_hold( 238 SCIF_SAS_DOMAIN_T * fw_domain 239 ); 240 241 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_find_device_has_scheduled_activity( 242 SCIF_SAS_DOMAIN_T * fw_domain, 243 U8 smp_activity 244 ); 245 246 void scif_sas_domain_start_smp_activity( 247 SCIF_SAS_DOMAIN_T * fw_domain 248 ); 249 250 void scif_sas_domain_remove_expander_device( 251 SCIF_SAS_DOMAIN_T * fw_domain, 252 SCIF_SAS_REMOTE_DEVICE_T * fw_device 253 ); 254 255 void scif_sas_domain_start_smp_discover( 256 SCIF_SAS_DOMAIN_T * fw_domain, 257 SCIF_SAS_REMOTE_DEVICE_T * top_expander 258 ); 259 260 void scif_sas_domain_continue_discover( 261 SCIF_SAS_DOMAIN_T * fw_domain 262 ); 263 264 void scif_sas_domain_finish_discover( 265 SCIF_SAS_DOMAIN_T * fw_domain 266 ); 267 268 void scif_sas_domain_transition_to_discovering_state( 269 SCIF_SAS_DOMAIN_T * fw_domain 270 ); 271 272 void scif_sas_domain_cancel_smp_activities( 273 SCIF_SAS_DOMAIN_T * fw_domain 274 ); 275 276 U8 scif_sas_domain_get_smp_request_count( 277 SCIF_SAS_DOMAIN_T * fw_domain 278 ); 279 280 void scif_sas_domain_schedule_clear_affiliation( 281 SCIF_SAS_DOMAIN_T * fw_domain 282 ); 283 284 void scif_sas_domain_start_clear_affiliation( 285 SCIF_SAS_DOMAIN_T * fw_domain 286 ); 287 288 void scif_sas_domain_continue_clear_affiliation( 289 SCIF_SAS_DOMAIN_T * fw_domain 290 ); 291 292 void scif_sas_domain_release_resource( 293 struct SCIF_SAS_CONTROLLER * fw_controller, 294 SCIF_SAS_DOMAIN_T * fw_domain 295 ); 296 297 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_find_next_ea_target_reset( 298 SCIF_SAS_DOMAIN_T * fw_domain 299 ); 300 301 #if !defined(DISABLE_WIDE_PORTED_TARGETS) 302 void scif_sas_domain_update_device_port_width( 303 SCIF_SAS_DOMAIN_T * fw_domain, 304 SCI_PORT_HANDLE_T port 305 ); 306 #else //!defined(DISABLE_WIDE_PORTED_TARGETS) 307 #define scif_sas_domain_update_device_port_width(domain, port) 308 #endif //!defined(DISABLE_WIDE_PORTED_TARGETS) 309 310 #ifdef SCI_LOGGING 311 void scif_sas_domain_initialize_state_logging( 312 SCIF_SAS_DOMAIN_T *fw_domain 313 ); 314 315 void scif_sas_domain_deinitialize_state_logging( 316 SCIF_SAS_DOMAIN_T *fw_domain 317 ); 318 #else // SCI_LOGGING 319 #define scif_sas_domain_initialize_state_logging(x) 320 #define scif_sas_domain_deinitialize_state_logging(x) 321 #endif // SCI_LOGGING 322 323 #ifdef __cplusplus 324 } 325 #endif // __cplusplus 326 327 #endif // _SCIF_SAS_DOMAIN_H_ 328 329