2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
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.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
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
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.
55 #include <sys/cdefs.h>
56 __FBSDID("$FreeBSD$");
61 * @brief This file contains all of the SCIF_SAS_TASK_REQUEST object
62 * state entrance and exit method implementations.
65 #include <dev/isci/scil/scif_sas_task_request.h>
67 //******************************************************************************
68 //* P R O T E C T E D M E T H O D S
69 //******************************************************************************
72 * @brief This method implements the actions taken when entering the
75 * @param[in] object This parameter specifies the base object for which
76 * the state transition is occurring. This is cast into a
77 * SCIF_SAS_TASK_REQUEST object in the method implementation.
82 void scif_sas_task_request_initial_state_enter(
83 SCI_BASE_OBJECT_T *object
86 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object;
90 scif_sas_task_request_state_handler_table,
91 SCI_BASE_REQUEST_STATE_INITIAL
94 // Initial state is a transitional state to the constructed state
95 sci_base_state_machine_change_state(
96 &fw_task->parent.parent.state_machine, SCI_BASE_REQUEST_STATE_CONSTRUCTED
101 * @brief This method implements the actions taken when entering the
104 * @param[in] object This parameter specifies the base object for which
105 * the state transition is occurring. This is cast into a
106 * SCIF_SAS_TASK_REQUEST object in the method implementation.
111 void scif_sas_task_request_constructed_state_enter(
112 SCI_BASE_OBJECT_T *object
115 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object;
119 scif_sas_task_request_state_handler_table,
120 SCI_BASE_REQUEST_STATE_CONSTRUCTED
125 * @brief This method implements the actions taken when entering the
128 * @param[in] object This parameter specifies the base object for which
129 * the state transition is occurring. This is cast into a
130 * SCIF_SAS_TASK_REQUEST object in the method implementation.
135 void scif_sas_task_request_started_state_enter(
136 SCI_BASE_OBJECT_T *object
139 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object;
143 scif_sas_task_request_state_handler_table,
144 SCI_BASE_REQUEST_STATE_STARTED
147 // Increment the affected request count to include the task performing
148 // the task management to ensure we don't complete the task request until
149 // all terminations and the task itself have completed.
150 fw_task->affected_request_count++;
154 * @brief This method implements the actions taken when entering the
157 * @param[in] object This parameter specifies the base object for which
158 * the state transition is occurring. This is cast into a
159 * SCIF_SAS_TASK_REQUEST object in the method implementation.
164 void scif_sas_task_request_completed_state_enter(
165 SCI_BASE_OBJECT_T *object
168 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object;
172 scif_sas_task_request_state_handler_table,
173 SCI_BASE_REQUEST_STATE_COMPLETED
176 // Check to see if the task management operation is now finished (i.e.
177 // all of the task terminations and the task management request are
179 scif_sas_task_request_operation_complete(fw_task);
183 * @brief This method implements the actions taken when entering the
186 * @param[in] object This parameter specifies the base object for which
187 * the state transition is occurring. This is cast into a
188 * SCIF_SAS_TASK_REQUEST object in the method implementation.
193 void scif_sas_task_request_aborting_state_enter(
194 SCI_BASE_OBJECT_T *object
197 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object;
201 scif_sas_task_request_state_handler_table,
202 SCI_BASE_REQUEST_STATE_ABORTING
205 /// @todo Is terminating a previously outstanding task request right?
206 fw_task->parent.status = scif_sas_request_terminate_start(
207 &fw_task->parent, fw_task->parent.core_object
212 * @brief This method implements the actions taken when exiting the
215 * @param[in] object This parameter specifies the base object for which
216 * the state transition is occurring. This is cast into a
217 * SCIF_SAS_TASK_REQUEST object in the method implementation.
222 void scif_sas_task_request_aborting_state_exit(
223 SCI_BASE_OBJECT_T *object
226 SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T *)object;
227 scif_sas_request_terminate_complete(fw_request);
231 * @brief This method implements the actions taken when entering the
234 * @param[in] object This parameter specifies the base object for which
235 * the state transition is occurring. This is cast into a
236 * SCIF_SAS_TASK_REQUEST object in the method implementation.
241 void scif_sas_task_request_final_state_enter(
242 SCI_BASE_OBJECT_T *object
245 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T *)object;
249 scif_sas_task_request_state_handler_table,
250 SCI_BASE_REQUEST_STATE_FINAL
256 scif_sas_task_request_state_table[SCI_BASE_REQUEST_MAX_STATES] =
259 SCI_BASE_REQUEST_STATE_INITIAL,
260 scif_sas_task_request_initial_state_enter,
264 SCI_BASE_REQUEST_STATE_CONSTRUCTED,
265 scif_sas_task_request_constructed_state_enter,
269 SCI_BASE_REQUEST_STATE_STARTED,
270 scif_sas_task_request_started_state_enter,
274 SCI_BASE_REQUEST_STATE_COMPLETED,
275 scif_sas_task_request_completed_state_enter,
279 SCI_BASE_REQUEST_STATE_ABORTING,
280 scif_sas_task_request_aborting_state_enter,
281 scif_sas_task_request_aborting_state_exit
284 SCI_BASE_REQUEST_STATE_FINAL,
285 scif_sas_task_request_final_state_enter,