scif_sas_design.h revision 298955
1240116Smarcel/*- 2240116Smarcel * This file is provided under a dual BSD/GPLv2 license. When using or 3240116Smarcel * redistributing this file, you may do so under either license. 4240116Smarcel * 5240116Smarcel * GPL LICENSE SUMMARY 6240116Smarcel * 7240116Smarcel * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8240116Smarcel * 9240116Smarcel * This program is free software; you can redistribute it and/or modify 10240116Smarcel * it under the terms of version 2 of the GNU General Public License as 11240116Smarcel * published by the Free Software Foundation. 12240116Smarcel * 13240116Smarcel * This program is distributed in the hope that it will be useful, but 14240116Smarcel * WITHOUT ANY WARRANTY; without even the implied warranty of 15240116Smarcel * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16240116Smarcel * General Public License for more details. 17240116Smarcel * 18240116Smarcel * You should have received a copy of the GNU General Public License 19240116Smarcel * along with this program; if not, write to the Free Software 20240116Smarcel * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21240116Smarcel * The full GNU General Public License is included in this distribution 22240116Smarcel * in the file called LICENSE.GPL. 23240116Smarcel * 24240116Smarcel * BSD LICENSE 25240116Smarcel * 26240116Smarcel * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27240116Smarcel * All rights reserved. 28240116Smarcel * 29240116Smarcel * Redistribution and use in source and binary forms, with or without 30240116Smarcel * modification, are permitted provided that the following conditions 31240116Smarcel * are met: 32240116Smarcel * 33240116Smarcel * * Redistributions of source code must retain the above copyright 34240116Smarcel * notice, this list of conditions and the following disclaimer. 35240116Smarcel * * Redistributions in binary form must reproduce the above copyright 36240116Smarcel * notice, this list of conditions and the following disclaimer in 37240116Smarcel * the documentation and/or other materials provided with the 38240116Smarcel * distribution. 39240116Smarcel * 40240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41240116Smarcel * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42240116Smarcel * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43240116Smarcel * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44240116Smarcel * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45240116Smarcel * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46240116Smarcel * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47240116Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48240116Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49240116Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50240116Smarcel * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51240116Smarcel * 52240116Smarcel * $FreeBSD: head/sys/dev/isci/scil/scif_sas_design.h 298955 2016-05-03 03:41:25Z pfg $ 53240116Smarcel */ 54240116Smarcel#ifndef _SCIF_SAS_DESIGN_H_ 55240116Smarcel#define _SCIF_SAS_DESIGN_H_ 56240116Smarcel 57240116Smarcel/** 58240116Smarcel@page scif_sas_design_page SCIF SAS High Level Design 59240116Smarcel 60240116Smarcel<b>Authors:</b> 61240116Smarcel- Nathan Marushak 62 63<b>Key Contributors:</b> 64- Richard Boyd 65 66@section scif_sas_scope_and_audience Scope and Audience 67 68This document provides design information relating to the SAS specific 69implementation of the SCI Framework. Driver developers are the primary 70audience for this document. The reader is expected to have an understanding 71of the SCU Software Architecture Specification, the Storage Controller 72Interface Specification, and the SCI Base Design. 73 74@section scif_sas_overview Overview 75 76To begin, it's important to discuss the utilization of state machines in 77the design. State machines are pervasive in this design, because of the 78abilities they provide. A properly implemented state machine allows the 79developer to code for a specific task. The developer is not encumbered 80with needed to handle other situations all in a single function. For 81example, if a specific event can only occur when the object is in a specific 82state, then the event handler is added to handle such an event. Thus, a 83single function is not spliced to handle multiple events under various 84potentially disparate conditions. 85 86Additionally, the SCI Base Design document specifies a number of state 87machines, objects, and methods that are heavily utilized by this design. 88Please refer to Base Design specification for further information. 89 90Many of the framework objects have state machines associated with them. 91As a result, there are a number of state entrance and exit methods as well 92as event handlers for each individual state. This design places all of 93the state entrance and exit methods for a given state machine into a single 94file (e.g. scif_sas_controller_states.c). Furthermore, all of the state 95event handler methods are also placed into a single file (e.g. 96scif_sas_controller_state_handlers.c). This format is reused for each 97object that contains state machine(s). 98 99Some of the SAS framework objects contain sub-state machines. These 100sub-state machines are started upon entrance to the super-state and stopped 101upon exit of the super-state. 102 103All other method, data, constant description information will be found in 104the remaining source file (e.g. scif_sas_controller.c). As a result, please 105be sure to follow the link to that specific object/file definition for 106further information. 107 108@note Currently a large number of function pointers are utilized during the 109course of a normal IO request. Once stability of the driver is achieved, 110performance improvements will be made as needed. This likely will include 111removal of the function pointers from the IO path. 112 113@section scif_sas_use_cases Use Cases 114 115The following use case diagram depicts the high-level user interactions with 116the SAS framework. This diagram does not encompass all use cases implemented 117in the system. The low-level design section will contain detailed use cases 118for each significant object and their associated detailed sequences and/or 119activities. For the purposes of readability, the use cases are not directly 120connected to the associated actor utilizing the use case. Instead naming 121is utilized to different which actor is involved with the use case. 122 123Actors: 124- The Framework user also called the OS Specific Driver initiates activities in 125the Framework. 126- The SCI Core calls back into the Framework as a result of an operation either 127started by the OS Specific Driver or by the Framework itself. 128 129@image latex Use_Case_Diagram__SCIF_SAS__Use_Cases.eps "SCIF SAS OS Use Cases" width=11cm 130@image html Use_Case_Diagram__SCIF_SAS__Use_Cases.jpg "SCIF SAS OS Use Cases" 131 132@section scif_sas_class_hierarchy Class Hierarchy 133 134This section delineates the high-level class organization for the SCIF_SAS 135component. Details concerning each class will be found in the corresponding 136low-level design sections. Furthermore, additional classes not germane to 137the overall architecture of the component will also be defined in these 138low-level design sections. 139 140@image latex Class_Diagram__scif_sas__Class_Diagram.eps "SCIF SAS Class Diagram" width=16cm 141@image html Class_Diagram__scif_sas__Class_Diagram.jpg "SCIF SAS Class Diagram" 142 143For more information on each object appearing in the diagram, please 144reference the subsequent sections. 145 146@section scif_sas_library SCIF SAS Library 147 148First, the SCIF_SAS_LIBRARY object provides an implementation 149for the roles and responsibilities defined in the Storage Controller 150Interface (SCI) specification. It is suggested that the user read the 151storage controller interface specification for background information on 152the library object. 153 154The SCIF_SAS_LIBRARY object is broken down into 2 individual source files 155and one direct header file. These files delineate the methods, members, etc. 156associated with this object. Please reference these files directly for 157further design information: 158- scif_sas_library.h 159- scif_sas_library.c 160 161@section scif_sas_controller SCIF SAS Controller 162 163First, the SCIF_SAS_CONTROLLER object provides an implementation 164for the roles and responsibilities defined in the Storage Controller 165Interface (SCI) specification. It is suggested that the user read the 166storage controller interface specification for background information on 167the controller object. 168 169The SCIF_SAS_CONTROLLER object is broken down into 3 individual source files 170and one direct header file. These files delineate the methods, members, etc. 171associated with this object. Please reference these files directly for 172further design information: 173- scif_sas_controller.h 174- scif_sas_controller.c 175- scif_sas_controller_state_handlers.c 176- scif_sas_controller_states.c 177 178@section scif_sas_domain SCIF SAS Domain 179 180First, the SCIF_SAS_DOMAIN object provides an implementation 181for the roles and responsibilities defined in the Storage Controller 182Interface (SCI) specification. It is suggested that the user read the 183storage controller interface specification for background information on 184the SCIF_SAS_DOMAIN object. 185 186The SCIF_SAS_DOMAIN object is broken down into 3 individual 187source files and one direct header file. These files delineate the 188methods, members, etc. associated with this object. Please reference 189these files directly for 190further design information: 191- scif_sas_domain.h 192- scif_sas_domain.c 193- scif_sas_domain_state_handlers.c 194- scif_sas_domain_states.c 195 196@section scif_sas_remote_device SCIF SAS Remote Device 197 198First, the SCIF_SAS_REMOTE_DEVICE object provides an implementation 199for the roles and responsibilities defined in the Storage Controller 200Interface (SCI) specification. It is suggested that the user read the 201storage controller interface specification for background information on 202the SCIF_SAS_REMOTE_DEVICE object. 203 204The SCIF_SAS_REMOTE_DEVICE object is broken down into 7 individual source files 205and one direct header file. These files delineate the methods, members, etc. 206associated with this object. Methods, data, and functionality specific to a 207particular protocol type (e.g. SMP, STP, etc.) are broken out into their own 208object/file. SSP specific remote device functionality is covered by the base 209classes (common files). Please reference these files directly for further 210design information: 211- scif_sas_remote_device.h 212- scif_sas_smp_remote_device.h 213- scif_sas_stp_remote_device.h 214- scif_sas_remote_device.c 215- scif_sas_remote_device_state_handlers.c 216- scif_sas_remote_device_states.c 217- scif_sas_remote_device_starting_substate_handlers.c 218- scif_sas_remote_device_starting_substates.c 219- scif_sas_remote_device_ready_substate_handlers.c 220- scif_sas_remote_device_ready_substates.c 221- scif_sas_smp_remote_device.c 222- scif_sas_stp_remote_device.c 223 224The SCIF_SAS_REMOTE_DEVICE object has sub-state machines defined for 225the READY and STARTING super-states. For more information on the 226super-state machine please refer to SCI_BASE_REMOTE_DEVICE_STATES 227in the SCI Base design document. 228 229In the SCIF_SAS_REMOTE_DEVICE_STARTING_SUBSTATES sub-state machine, 230the remote device currently has to wait for the core to 231return an indication that the remote device has successfully started 232and become ready. If all goes well, then the remote device will 233transition into the READY state. 234 235For more information on the starting sub-state machine states please refer 236to the scif_sas_remote_device.h::_SCIF_SAS_REMOTE_DEVICE_STARTING_SUBSTATES 237enumeration. 238 239@image latex State_Machine_Diagram__STARTING_SUB-STATE__STARTING_SUB-STATE.eps "SCIF SAS Remote Device Starting Sub-state Machine Diagram" width=16cm 240@image html State_Machine_Diagram__STARTING_SUB-STATE__STARTING_SUB-STATE.jpg "SCIF SAS Remote Device Starting Sub-state Machine Diagram" 241 242In the SCIF_SAS_REMOTE_DEVICE_READY_SUBSTATES sub-state machine, 243the remote device currently only allows new host IO requests during the 244OPERATIONAL state. In the TASK MANAGEMENT state only new task management 245requests are allowed. 246 247For more information on the ready sub-state machine states please refer 248to the scif_sas_remote_device.h::_SCIF_SAS_REMOTE_DEVICE_READY_SUBSTATES 249enumeration. 250 251@image latex State_Machine_Diagram__READY_SUB-STATE__READY_SUB-STATE.eps "SCIF SAS Remote Device Ready Sub-state Machine Diagram" width=16cm 252@image html State_Machine_Diagram__READY_SUB-STATE__READY_SUB-STATE.jpg "SCIF SAS Remote Device Ready Sub-state Machine Diagram" 253 254@section scif_sas_request SCIF SAS Request 255 256The SCIF_SAS_REQUEST object provide common functionality for the 257SCIF_SAS_IO_REQUEST and the SCIF_SAS_TASK_REQUEST objects. This object 258does not directly map to an SCI defined object, but its children do. For 259additional information, you may reference the SCIF_SAS_IO_REQUEST or 260SCIF_SAS_TASK_REQUEST objects. 261 262The SCIF_SAS_REQUEST object is broken down into 1 individual source file 263and one direct header file. These files delineate the methods, members, etc. 264associated with this object. Please reference these files directly for 265further design information: 266- scif_sas_request.h 267- scif_sas_request.c 268 269@section scif_sas_io_request SCIF SAS IO Request 270 271First, the SCIF_SAS_IO_REQUEST object provides an implementation 272for the roles and responsibilities defined in the Storage Controller 273Interface (SCI) specification. It is suggested that the user read the 274storage controller interface specification for background information on 275the SCIF_SAS_IO_REQUEST object. 276 277The SCIF_SAS_IO_REQUEST object is broken down into 3 individual 278source files and one direct header file. These files delineate the 279methods, members, etc. associated with this object. Please reference 280these files directly for further design information: 281- scif_sas_io_request.h 282- scif_sas_smp_io_request.h 283- scif_sas_stp_io_request.h 284- scif_sas_sati_binding.h 285- scif_sas_io_request.c 286- scif_sas_io_request_state_handlers.c 287- scif_sas_io_request_states.c 288- scif_sas_smp_io_request.c 289- scif_sas_stp_io_request.c 290 291@section scif_sas_task_request SCIF SAS Task Request 292 293First, the SCIF_SAS_TASK_REQUEST object provides an implementation 294for the roles and responsibilities defined in the Storage Controller 295Interface (SCI) specification. It is suggested that the user read the 296storage controller interface specification for background information on 297the SCIF_SAS_TASK_REQUEST object. 298 299The SCIF_SAS_TASK_REQUEST object is broken down into 3 individual 300source files and one direct header file. These files delineate the 301methods, members, etc. associated with this object. Please reference 302these files directly for further design information: 303- scif_sas_task_request.h 304- scif_sas_stp_task_request.h 305- scif_sas_task_request.c 306- scif_sas_task_request_state_handlers.c 307- scif_sas_task_request_states.c 308- scif_sas_stp_task_request.c 309 310@section scif_sas_internal_io_request SCIF SAS INTERNAL IO Request 311 312The SCIF_SAS_INTERNAL_IO_REQUEST object fulfills the SCI's need to create 313and send out the internal io request. These internal io requests could be 314smp request for expander device discover process, or stp request for NCQ 315error handling. Internal IOs consume the reserved internal io space in 316scif_sas_controller. When an internal IO is constructed, it is put into an 317internal high priority queue. A defferred task (start_internal_io_task) will be 318scheduled at the end of every completion process. The task looks up the high 319priority queue and starts each internal io in the queue. There is one exception 320that start_internal_io_task is scheduled immediately when the first internal io 321is constructed. A retry mechanism is also provided for internal io. When an 322internal io response is decoded, if the decoding indicates a retry is needed, 323the internal io will be retried. 324 325Please refer to these files directly for further design information: 326- scif_sas_internal_io_request.h 327- scif_sas_internal_io_request.c 328- scif_sas_controller.h 329 330@section scif_sas_smp_remote_device SCIF SAS SMP REMOTE DEVICE 331 332The SCIF SAS SMP REMOTE DEVICE object represents the expander device and fulfills 333its SMP discover activities. The discover procedure includes a initial discover 334phase and a following SATA spinup_hold release phase, if there are expander attached 335SATA device is discovered and in spinup_hold conditon. The SCIF SAS SMP REMOTE DEVICE 336object also fulfills expander attached device Target Reset (Phy Control) activity. 337 338@image latex Discover Process.eps "SMP Discover Activity Diagram" width=10cm 339@image html Discover Process.jpg "SMP Discover Activity Diagram" 340 341Please refer to these files directly for further design information: 342- scif_sas_smp_remote_device.h 343- scif_sas_smp_remote_device.c 344- scif_sas_smp_request.h 345- scif_sas_smp_request.c 346*/ 347 348#endif // _SCIF_SAS_DESIGN_H_ 349