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 method implementations pertaining
62 * to the framework io request state handler methods.
65 #include <dev/isci/scil/scif_sas_logger.h>
66 #include <dev/isci/scil/scif_sas_task_request.h>
68 //******************************************************************************
69 //* C O N S T R U C T E D H A N D L E R S
70 //******************************************************************************
73 * @brief This method provides CONSTRUCTED state specific handling for
74 * when the user attempts to start the supplied task request.
76 * @param[in] task_request This parameter specifies the task request object
79 * @return This method returns a value indicating if the task request was
80 * successfully started or not.
81 * @retval SCI_SUCCESS This return value indicates successful starting
82 * of the task request.
85 SCI_STATUS scif_sas_task_request_constructed_start_handler(
86 SCI_BASE_REQUEST_T * task_request
89 sci_base_state_machine_change_state(
90 &task_request->state_machine, SCI_BASE_REQUEST_STATE_STARTED
97 * @brief This method provides CONSTRUCTED state specific handling for
98 * when the user attempts to abort the supplied task request.
100 * @param[in] task_request This parameter specifies the task request object
103 * @return This method returns a value indicating if the task request was
104 * successfully aborted or not.
105 * @retval SCI_SUCCESS This return value indicates successful aborting
106 * of the task request.
109 SCI_STATUS scif_sas_task_request_constructed_abort_handler(
110 SCI_BASE_REQUEST_T * task_request
113 sci_base_state_machine_change_state(
114 &task_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
120 //******************************************************************************
121 //* S T A R T E D H A N D L E R S
122 //******************************************************************************
125 * @brief This method provides STARTED state specific handling for
126 * when the user attempts to abort the supplied task request.
128 * @param[in] task_request This parameter specifies the task request object
131 * @return This method returns a value indicating if the aborting the
132 * task request was successfully started.
133 * @retval SCI_SUCCESS This return value indicates that the abort process
134 * began successfully.
137 SCI_STATUS scif_sas_task_request_started_abort_handler(
138 SCI_BASE_REQUEST_T * task_request
141 SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T *) task_request;
143 sci_base_state_machine_change_state(
144 &task_request->state_machine, SCI_BASE_REQUEST_STATE_ABORTING
147 return fw_request->status;
151 * @brief This method provides STARTED state specific handling for
152 * when the user attempts to complete the supplied task request.
154 * @param[in] task_request This parameter specifies the task request object
157 * @return This method returns a value indicating if the completion of the
158 * task request was successful.
159 * @retval SCI_SUCCESS This return value indicates that the completion process
163 SCI_STATUS scif_sas_task_request_started_complete_handler(
164 SCI_BASE_REQUEST_T * task_request
167 sci_base_state_machine_change_state(
168 &task_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
174 //******************************************************************************
175 //* C O M P L E T E D H A N D L E R S
176 //******************************************************************************
179 * @brief This method provides COMPLETED state specific handling for
180 * when the user attempts to destruct the supplied task request.
182 * @param[in] task_request This parameter specifies the task request object
185 * @return This method returns a value indicating if the destruct
186 * operation was successful.
187 * @retval SCI_SUCCESS This return value indicates that the destruct
191 SCI_STATUS scif_sas_task_request_completed_destruct_handler(
192 SCI_BASE_REQUEST_T * task_request
195 SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T *)task_request;
197 sci_base_state_machine_change_state(
198 &task_request->state_machine, SCI_BASE_REQUEST_STATE_FINAL
201 sci_base_state_machine_logger_deinitialize(
202 &task_request->state_machine_logger,
203 &task_request->state_machine
206 if (fw_request->is_internal == TRUE)
208 scif_sas_internal_task_request_destruct(
209 (SCIF_SAS_TASK_REQUEST_T *)fw_request
216 //******************************************************************************
217 //* A B O R T I N G H A N D L E R S
218 //******************************************************************************
221 * @brief This method provides ABORTING state specific handling for
222 * when the user attempts to complete the supplied task request.
224 * @param[in] task_request This parameter specifies the task request object
227 * @return This method returns a value indicating if the completion
228 * operation was successful.
229 * @retval SCI_SUCCESS This return value indicates that the completion
233 SCI_STATUS scif_sas_task_request_aborting_complete_handler(
234 SCI_BASE_REQUEST_T * task_request
237 sci_base_state_machine_change_state(
238 &task_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
244 //******************************************************************************
245 //* D E F A U L T H A N D L E R S
246 //******************************************************************************
249 * @brief This method provides DEFAULT handling for when the user
250 * attempts to start the supplied task request.
252 * @param[in] task_request This parameter specifies the task request object
255 * @return This method returns an indication that the start operation is
257 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
260 SCI_STATUS scif_sas_task_request_default_start_handler(
261 SCI_BASE_REQUEST_T * task_request
265 sci_base_object_get_logger((SCIF_SAS_TASK_REQUEST_T *) task_request),
266 SCIF_LOG_OBJECT_TASK_MANAGEMENT,
267 "TaskRequest:0x%x State:0x%x invalid state to start\n",
269 sci_base_state_machine_get_state(
270 &((SCIF_SAS_TASK_REQUEST_T *) task_request)->parent.parent.state_machine)
273 return SCI_FAILURE_INVALID_STATE;
277 * @brief This method provides DEFAULT handling for when the user
278 * attempts to abort the supplied task request.
280 * @param[in] task_request This parameter specifies the task request object
283 * @return This method returns an indication that the abort operation is
285 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
288 SCI_STATUS scif_sas_task_request_default_abort_handler(
289 SCI_BASE_REQUEST_T * task_request
293 sci_base_object_get_logger((SCIF_SAS_TASK_REQUEST_T *) task_request),
294 SCIF_LOG_OBJECT_TASK_MANAGEMENT,
295 "TaskRequest:0x%x State:0x%x invalid state to abort\n",
297 sci_base_state_machine_get_state(
298 &((SCIF_SAS_TASK_REQUEST_T *) task_request)->parent.parent.state_machine)
301 return SCI_FAILURE_INVALID_STATE;
305 * @brief This method provides DEFAULT handling for when the user
306 * attempts to complete the supplied task request.
308 * @param[in] task_request This parameter specifies the task request object
311 * @return This method returns an indication that complete operation is
313 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
316 SCI_STATUS scif_sas_task_request_default_complete_handler(
317 SCI_BASE_REQUEST_T * task_request
321 sci_base_object_get_logger((SCIF_SAS_TASK_REQUEST_T *) task_request),
322 SCIF_LOG_OBJECT_TASK_MANAGEMENT,
323 "TaskRequest:0x%x State:0x%x invalid state to complete\n",
325 sci_base_state_machine_get_state(
326 &((SCIF_SAS_TASK_REQUEST_T *) task_request)->parent.parent.state_machine)
329 return SCI_FAILURE_INVALID_STATE;
333 * @brief This method provides DEFAULT handling for when the user
334 * attempts to destruct the supplied task request.
336 * @param[in] task_request This parameter specifies the task request object
339 * @return This method returns an indication that destruct operation is
341 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
344 SCI_STATUS scif_sas_task_request_default_destruct_handler(
345 SCI_BASE_REQUEST_T * task_request
349 sci_base_object_get_logger((SCIF_SAS_TASK_REQUEST_T *) task_request),
350 SCIF_LOG_OBJECT_TASK_MANAGEMENT,
351 "TaskRequest:0x%x State:0x%x invalid state to destruct.\n",
353 sci_base_state_machine_get_state(
354 &((SCIF_SAS_TASK_REQUEST_T *) task_request)->parent.parent.state_machine)
357 return SCI_FAILURE_INVALID_STATE;
361 SCI_BASE_REQUEST_STATE_HANDLER_T scif_sas_task_request_state_handler_table[] =
363 // SCI_BASE_REQUEST_STATE_INITIAL
365 scif_sas_task_request_default_start_handler,
366 scif_sas_task_request_default_abort_handler,
367 scif_sas_task_request_default_complete_handler,
368 scif_sas_task_request_default_destruct_handler
370 // SCI_BASE_REQUEST_STATE_CONSTRUCTED
372 scif_sas_task_request_constructed_start_handler,
373 scif_sas_task_request_constructed_abort_handler,
374 scif_sas_task_request_default_complete_handler,
375 scif_sas_task_request_default_destruct_handler
377 // SCI_BASE_REQUEST_STATE_STARTED
379 scif_sas_task_request_default_start_handler,
380 scif_sas_task_request_started_abort_handler,
381 scif_sas_task_request_started_complete_handler,
382 scif_sas_task_request_default_destruct_handler
384 // SCI_BASE_REQUEST_STATE_COMPLETED
386 scif_sas_task_request_default_start_handler,
387 scif_sas_task_request_default_abort_handler,
388 scif_sas_task_request_default_complete_handler,
389 scif_sas_task_request_completed_destruct_handler
391 // SCI_BASE_REQUEST_STATE_ABORTING
393 scif_sas_task_request_default_start_handler,
394 scif_sas_task_request_default_abort_handler,
395 scif_sas_task_request_aborting_complete_handler,
396 scif_sas_task_request_default_destruct_handler
398 // SCI_BASE_REQUEST_STATE_FINAL
400 scif_sas_task_request_default_start_handler,
401 scif_sas_task_request_default_abort_handler,
402 scif_sas_task_request_default_complete_handler,
403 scif_sas_task_request_default_destruct_handler