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