1230557Sjimharris/*- 2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license. When using or 3230557Sjimharris * redistributing this file, you may do so under either license. 4230557Sjimharris * 5230557Sjimharris * GPL LICENSE SUMMARY 6230557Sjimharris * 7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8230557Sjimharris * 9230557Sjimharris * This program is free software; you can redistribute it and/or modify 10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as 11230557Sjimharris * published by the Free Software Foundation. 12230557Sjimharris * 13230557Sjimharris * This program is distributed in the hope that it will be useful, but 14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of 15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16230557Sjimharris * General Public License for more details. 17230557Sjimharris * 18230557Sjimharris * You should have received a copy of the GNU General Public License 19230557Sjimharris * along with this program; if not, write to the Free Software 20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21230557Sjimharris * The full GNU General Public License is included in this distribution 22230557Sjimharris * in the file called LICENSE.GPL. 23230557Sjimharris * 24230557Sjimharris * BSD LICENSE 25230557Sjimharris * 26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27230557Sjimharris * All rights reserved. 28230557Sjimharris * 29230557Sjimharris * Redistribution and use in source and binary forms, with or without 30230557Sjimharris * modification, are permitted provided that the following conditions 31230557Sjimharris * are met: 32230557Sjimharris * 33230557Sjimharris * * Redistributions of source code must retain the above copyright 34230557Sjimharris * notice, this list of conditions and the following disclaimer. 35230557Sjimharris * * Redistributions in binary form must reproduce the above copyright 36230557Sjimharris * notice, this list of conditions and the following disclaimer in 37230557Sjimharris * the documentation and/or other materials provided with the 38230557Sjimharris * distribution. 39230557Sjimharris * 40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51230557Sjimharris */ 52230557Sjimharris 53230557Sjimharris#include <sys/cdefs.h> 54230557Sjimharris__FBSDID("$FreeBSD$"); 55230557Sjimharris 56230557Sjimharris/** 57230557Sjimharris * @file 58230557Sjimharris * 59230557Sjimharris * @brief This file contains all of the SCIF_SAS_TASK_REQUEST object 60230557Sjimharris * state entrance and exit method implementations. 61230557Sjimharris */ 62230557Sjimharris 63230557Sjimharris#include <dev/isci/scil/scif_sas_task_request.h> 64230557Sjimharris 65230557Sjimharris//****************************************************************************** 66230557Sjimharris//* P R O T E C T E D M E T H O D S 67230557Sjimharris//****************************************************************************** 68230557Sjimharris 69230557Sjimharris/** 70230557Sjimharris * @brief This method implements the actions taken when entering the 71230557Sjimharris * INITIAL state. 72230557Sjimharris * 73230557Sjimharris * @param[in] object This parameter specifies the base object for which 74230557Sjimharris * the state transition is occurring. This is cast into a 75230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 76230557Sjimharris * 77230557Sjimharris * @return none 78230557Sjimharris */ 79230557Sjimharrisstatic 80230557Sjimharrisvoid scif_sas_task_request_initial_state_enter( 81230557Sjimharris SCI_BASE_OBJECT_T *object 82230557Sjimharris) 83230557Sjimharris{ 84230557Sjimharris SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object; 85230557Sjimharris 86230557Sjimharris SET_STATE_HANDLER( 87230557Sjimharris &fw_task->parent, 88230557Sjimharris scif_sas_task_request_state_handler_table, 89230557Sjimharris SCI_BASE_REQUEST_STATE_INITIAL 90230557Sjimharris ); 91230557Sjimharris 92230557Sjimharris // Initial state is a transitional state to the constructed state 93230557Sjimharris sci_base_state_machine_change_state( 94230557Sjimharris &fw_task->parent.parent.state_machine, SCI_BASE_REQUEST_STATE_CONSTRUCTED 95230557Sjimharris ); 96230557Sjimharris} 97230557Sjimharris 98230557Sjimharris/** 99230557Sjimharris * @brief This method implements the actions taken when entering the 100230557Sjimharris * CONSTRUCTED state. 101230557Sjimharris * 102230557Sjimharris * @param[in] object This parameter specifies the base object for which 103230557Sjimharris * the state transition is occurring. This is cast into a 104230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 105230557Sjimharris * 106230557Sjimharris * @return none 107230557Sjimharris */ 108230557Sjimharrisstatic 109230557Sjimharrisvoid scif_sas_task_request_constructed_state_enter( 110230557Sjimharris SCI_BASE_OBJECT_T *object 111230557Sjimharris) 112230557Sjimharris{ 113230557Sjimharris SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object; 114230557Sjimharris 115230557Sjimharris SET_STATE_HANDLER( 116230557Sjimharris &fw_task->parent, 117230557Sjimharris scif_sas_task_request_state_handler_table, 118230557Sjimharris SCI_BASE_REQUEST_STATE_CONSTRUCTED 119230557Sjimharris ); 120230557Sjimharris} 121230557Sjimharris 122230557Sjimharris/** 123230557Sjimharris * @brief This method implements the actions taken when entering the 124230557Sjimharris * STARTED state. 125230557Sjimharris * 126230557Sjimharris * @param[in] object This parameter specifies the base object for which 127230557Sjimharris * the state transition is occurring. This is cast into a 128230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 129230557Sjimharris * 130230557Sjimharris * @return none 131230557Sjimharris */ 132230557Sjimharrisstatic 133230557Sjimharrisvoid scif_sas_task_request_started_state_enter( 134230557Sjimharris SCI_BASE_OBJECT_T *object 135230557Sjimharris) 136230557Sjimharris{ 137230557Sjimharris SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object; 138230557Sjimharris 139230557Sjimharris SET_STATE_HANDLER( 140230557Sjimharris &fw_task->parent, 141230557Sjimharris scif_sas_task_request_state_handler_table, 142230557Sjimharris SCI_BASE_REQUEST_STATE_STARTED 143230557Sjimharris ); 144230557Sjimharris 145230557Sjimharris // Increment the affected request count to include the task performing 146230557Sjimharris // the task management to ensure we don't complete the task request until 147230557Sjimharris // all terminations and the task itself have completed. 148230557Sjimharris fw_task->affected_request_count++; 149230557Sjimharris} 150230557Sjimharris 151230557Sjimharris/** 152230557Sjimharris * @brief This method implements the actions taken when entering the 153230557Sjimharris * COMPLETED state. 154230557Sjimharris * 155230557Sjimharris * @param[in] object This parameter specifies the base object for which 156230557Sjimharris * the state transition is occurring. This is cast into a 157230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 158230557Sjimharris * 159230557Sjimharris * @return none 160230557Sjimharris */ 161230557Sjimharrisstatic 162230557Sjimharrisvoid scif_sas_task_request_completed_state_enter( 163230557Sjimharris SCI_BASE_OBJECT_T *object 164230557Sjimharris) 165230557Sjimharris{ 166230557Sjimharris SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object; 167230557Sjimharris 168230557Sjimharris SET_STATE_HANDLER( 169230557Sjimharris &fw_task->parent, 170230557Sjimharris scif_sas_task_request_state_handler_table, 171230557Sjimharris SCI_BASE_REQUEST_STATE_COMPLETED 172230557Sjimharris ); 173230557Sjimharris 174230557Sjimharris // Check to see if the task management operation is now finished (i.e. 175230557Sjimharris // all of the task terminations and the task management request are 176230557Sjimharris // complete). 177230557Sjimharris scif_sas_task_request_operation_complete(fw_task); 178230557Sjimharris} 179230557Sjimharris 180230557Sjimharris/** 181230557Sjimharris * @brief This method implements the actions taken when entering the 182230557Sjimharris * ABORTING state. 183230557Sjimharris * 184230557Sjimharris * @param[in] object This parameter specifies the base object for which 185230557Sjimharris * the state transition is occurring. This is cast into a 186230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 187230557Sjimharris * 188230557Sjimharris * @return none 189230557Sjimharris */ 190230557Sjimharrisstatic 191230557Sjimharrisvoid scif_sas_task_request_aborting_state_enter( 192230557Sjimharris SCI_BASE_OBJECT_T *object 193230557Sjimharris) 194230557Sjimharris{ 195230557Sjimharris SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object; 196230557Sjimharris 197230557Sjimharris SET_STATE_HANDLER( 198230557Sjimharris &fw_task->parent, 199230557Sjimharris scif_sas_task_request_state_handler_table, 200230557Sjimharris SCI_BASE_REQUEST_STATE_ABORTING 201230557Sjimharris ); 202230557Sjimharris 203230557Sjimharris /// @todo Is terminating a previously outstanding task request right? 204230557Sjimharris fw_task->parent.status = scif_sas_request_terminate_start( 205230557Sjimharris &fw_task->parent, fw_task->parent.core_object 206230557Sjimharris ); 207230557Sjimharris} 208230557Sjimharris 209230557Sjimharris/** 210230557Sjimharris * @brief This method implements the actions taken when exiting the 211230557Sjimharris * ABORTING state. 212230557Sjimharris * 213230557Sjimharris * @param[in] object This parameter specifies the base object for which 214230557Sjimharris * the state transition is occurring. This is cast into a 215230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 216230557Sjimharris * 217230557Sjimharris * @return none 218230557Sjimharris */ 219230557Sjimharrisstatic 220230557Sjimharrisvoid scif_sas_task_request_aborting_state_exit( 221230557Sjimharris SCI_BASE_OBJECT_T *object 222230557Sjimharris) 223230557Sjimharris{ 224230557Sjimharris SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T *)object; 225230557Sjimharris scif_sas_request_terminate_complete(fw_request); 226230557Sjimharris} 227230557Sjimharris 228230557Sjimharris/** 229230557Sjimharris * @brief This method implements the actions taken when entering the 230230557Sjimharris * FINAL state. 231230557Sjimharris * 232230557Sjimharris * @param[in] object This parameter specifies the base object for which 233230557Sjimharris * the state transition is occurring. This is cast into a 234230557Sjimharris * SCIF_SAS_TASK_REQUEST object in the method implementation. 235230557Sjimharris * 236230557Sjimharris * @return none 237230557Sjimharris */ 238230557Sjimharrisstatic 239230557Sjimharrisvoid scif_sas_task_request_final_state_enter( 240230557Sjimharris SCI_BASE_OBJECT_T *object 241230557Sjimharris) 242230557Sjimharris{ 243230557Sjimharris SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object; 244230557Sjimharris 245230557Sjimharris SET_STATE_HANDLER( 246230557Sjimharris &fw_task->parent, 247230557Sjimharris scif_sas_task_request_state_handler_table, 248230557Sjimharris SCI_BASE_REQUEST_STATE_FINAL 249230557Sjimharris ); 250230557Sjimharris} 251230557Sjimharris 252230557Sjimharris 253230557SjimharrisSCI_BASE_STATE_T 254230557Sjimharris scif_sas_task_request_state_table[SCI_BASE_REQUEST_MAX_STATES] = 255230557Sjimharris{ 256230557Sjimharris { 257230557Sjimharris SCI_BASE_REQUEST_STATE_INITIAL, 258230557Sjimharris scif_sas_task_request_initial_state_enter, 259230557Sjimharris NULL 260230557Sjimharris }, 261230557Sjimharris { 262230557Sjimharris SCI_BASE_REQUEST_STATE_CONSTRUCTED, 263230557Sjimharris scif_sas_task_request_constructed_state_enter, 264230557Sjimharris NULL 265230557Sjimharris }, 266230557Sjimharris { 267230557Sjimharris SCI_BASE_REQUEST_STATE_STARTED, 268230557Sjimharris scif_sas_task_request_started_state_enter, 269230557Sjimharris NULL 270230557Sjimharris }, 271230557Sjimharris { 272230557Sjimharris SCI_BASE_REQUEST_STATE_COMPLETED, 273230557Sjimharris scif_sas_task_request_completed_state_enter, 274230557Sjimharris NULL 275230557Sjimharris }, 276230557Sjimharris { 277230557Sjimharris SCI_BASE_REQUEST_STATE_ABORTING, 278230557Sjimharris scif_sas_task_request_aborting_state_enter, 279230557Sjimharris scif_sas_task_request_aborting_state_exit 280230557Sjimharris }, 281230557Sjimharris { 282230557Sjimharris SCI_BASE_REQUEST_STATE_FINAL, 283230557Sjimharris scif_sas_task_request_final_state_enter, 284230557Sjimharris NULL 285230557Sjimharris }, 286230557Sjimharris}; 287230557Sjimharris 288