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/scic_controller.h>
66 #include <dev/isci/scil/scif_sas_logger.h>
67 #include <dev/isci/scil/scif_sas_io_request.h>
68 #include <dev/isci/scil/scif_sas_remote_device.h>
69 #include <dev/isci/scil/scif_sas_domain.h>
70 #include <dev/isci/scil/scif_sas_controller.h>
72 //******************************************************************************
73 //* C O N S T R U C T E D H A N D L E R S
74 //******************************************************************************
77 * @brief This method provides CONSTRUCTED state specific handling for
78 * when the user attempts to start the supplied IO request.
80 * @param[in] io_request This parameter specifies the IO request object
83 * @return This method returns a value indicating if the IO request was
84 * successfully started or not.
85 * @retval SCI_SUCCESS This return value indicates successful starting
88 SCI_STATUS scif_sas_io_request_constructed_start_handler(
89 SCI_BASE_REQUEST_T * io_request
96 * @brief This method provides CONSTRUCTED state specific handling for
97 * when the user attempts to abort the supplied IO request.
99 * @param[in] io_request This parameter specifies the IO request object
102 * @return This method returns a value indicating if the IO request was
103 * successfully aborted or not.
104 * @retval SCI_SUCCESS This return value indicates successful aborting
107 SCI_STATUS scif_sas_io_request_constructed_abort_handler(
108 SCI_BASE_REQUEST_T * io_request
111 sci_base_state_machine_change_state(
112 &io_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
118 //******************************************************************************
119 //* S T A R T E D H A N D L E R S
120 //******************************************************************************
123 * @brief This method provides STARTED state specific handling for
124 * when the user attempts to abort the supplied IO request.
126 * @param[in] io_request This parameter specifies the IO request object
129 * @return This method returns a value indicating if the aborting the
130 * IO request was successfully started.
131 * @retval SCI_SUCCESS This return value indicates that the abort process
132 * began successfully.
135 SCI_STATUS scif_sas_io_request_started_abort_handler(
136 SCI_BASE_REQUEST_T * io_request
139 SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T *) io_request;
141 sci_base_state_machine_change_state(
142 &io_request->state_machine, SCI_BASE_REQUEST_STATE_ABORTING
145 return fw_request->status;
149 * @brief This method provides STARTED state specific handling for
150 * when the user attempts to complete the supplied IO request.
152 * @param[in] io_request This parameter specifies the IO request object
155 * @return This method returns a value indicating if the completion of the
156 * IO request was successful.
157 * @retval SCI_SUCCESS This return value indicates that the completion process
161 SCI_STATUS scif_sas_io_request_started_complete_handler(
162 SCI_BASE_REQUEST_T * io_request
165 sci_base_state_machine_change_state(
166 &io_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
172 //******************************************************************************
173 //* C O M P L E T E D H A N D L E R S
174 //******************************************************************************
177 * @brief This method provides COMPLETED state specific handling for
178 * when the user attempts to destruct the supplied IO request.
180 * @param[in] io_request This parameter specifies the IO request object
183 * @return This method returns a value indicating if the destruct
184 * operation was successful.
185 * @retval SCI_SUCCESS This return value indicates that the destruct
189 SCI_STATUS scif_sas_io_request_completed_destruct_handler(
190 SCI_BASE_REQUEST_T * io_request
193 sci_base_state_machine_change_state(
194 &io_request->state_machine, SCI_BASE_REQUEST_STATE_FINAL
197 sci_base_state_machine_logger_deinitialize(
198 &io_request->state_machine_logger,
199 &io_request->state_machine
205 //******************************************************************************
206 //* A B O R T I N G H A N D L E R S
207 //******************************************************************************
210 * @brief This method provides ABORTING state specific handlering for when the
211 * user attempts to abort the supplied IO request.
213 * @param[in] io_request This parameter specifies the IO request object
216 * @return This method returns a value indicating if the completion
217 * operation was successful.
218 * @retval SCI_SUCCESS This return value indicates that the abort operation
222 SCI_STATUS scif_sas_io_request_aborting_abort_handler(
223 SCI_BASE_REQUEST_T * io_request
226 SCIF_SAS_IO_REQUEST_T * fw_request = (SCIF_SAS_IO_REQUEST_T *) io_request;
228 return scic_controller_terminate_request(
229 fw_request->parent.device->domain->controller->core_object,
230 fw_request->parent.device->core_object,
231 fw_request->parent.core_object
236 * @brief This method provides ABORTING state specific handling for
237 * when the user attempts to complete the supplied IO request.
239 * @param[in] io_request This parameter specifies the IO request object
242 * @return This method returns a value indicating if the completion
243 * operation was successful.
244 * @retval SCI_SUCCESS This return value indicates that the completion
248 SCI_STATUS scif_sas_io_request_aborting_complete_handler(
249 SCI_BASE_REQUEST_T * io_request
252 sci_base_state_machine_change_state(
253 &io_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
259 //******************************************************************************
260 //* D E F A U L T H A N D L E R S
261 //******************************************************************************
264 * @brief This method provides DEFAULT handling for when the user
265 * attempts to start the supplied IO request.
267 * @param[in] io_request This parameter specifies the IO request object
270 * @return This method returns an indication that the start operation is
272 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
275 SCI_STATUS scif_sas_io_request_default_start_handler(
276 SCI_BASE_REQUEST_T * io_request
280 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
281 SCIF_LOG_OBJECT_IO_REQUEST,
282 "IoRequest:0x%x State:0x%x invalid state to start\n",
284 sci_base_state_machine_get_state(
285 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
288 return SCI_FAILURE_INVALID_STATE;
292 * @brief This method provides DEFAULT handling for when the user
293 * attempts to abort the supplied IO request.
295 * @param[in] io_request This parameter specifies the IO request object
298 * @return This method returns an indication that the abort operation is
300 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
303 SCI_STATUS scif_sas_io_request_default_abort_handler(
304 SCI_BASE_REQUEST_T * io_request
308 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
309 SCIF_LOG_OBJECT_IO_REQUEST,
310 "IoRequest:0x%x State:0x%x invalid state to abort\n",
312 sci_base_state_machine_get_state(
313 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
316 return SCI_FAILURE_INVALID_STATE;
320 * @brief This method provides DEFAULT handling for when the user
321 * attempts to complete the supplied IO request.
323 * @param[in] io_request This parameter specifies the IO request object
326 * @return This method returns an indication that complete operation is
328 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
330 SCI_STATUS scif_sas_io_request_default_complete_handler(
331 SCI_BASE_REQUEST_T * io_request
335 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
336 SCIF_LOG_OBJECT_IO_REQUEST,
337 "IoRequest:0x%x State:0x%x invalid state to complete\n",
339 sci_base_state_machine_get_state(
340 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
343 return SCI_FAILURE_INVALID_STATE;
347 * @brief This method provides DEFAULT handling for when the user
348 * attempts to destruct the supplied IO request.
350 * @param[in] io_request This parameter specifies the IO request object
353 * @return This method returns an indication that destruct operation is
355 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
357 SCI_STATUS scif_sas_io_request_default_destruct_handler(
358 SCI_BASE_REQUEST_T * io_request
362 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
363 SCIF_LOG_OBJECT_IO_REQUEST,
364 "IoRequest:0x%x State:0x%x invalid state to destruct.\n",
366 sci_base_state_machine_get_state(
367 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
370 return SCI_FAILURE_INVALID_STATE;
374 SCI_BASE_REQUEST_STATE_HANDLER_T scif_sas_io_request_state_handler_table[] =
376 // SCI_BASE_REQUEST_STATE_INITIAL
378 scif_sas_io_request_default_start_handler,
379 scif_sas_io_request_default_abort_handler,
380 scif_sas_io_request_default_complete_handler,
381 scif_sas_io_request_default_destruct_handler
383 // SCI_BASE_REQUEST_STATE_CONSTRUCTED
385 scif_sas_io_request_constructed_start_handler,
386 scif_sas_io_request_constructed_abort_handler,
387 scif_sas_io_request_default_complete_handler,
388 scif_sas_io_request_default_destruct_handler
390 // SCI_BASE_REQUEST_STATE_STARTED
392 scif_sas_io_request_default_start_handler,
393 scif_sas_io_request_started_abort_handler,
394 scif_sas_io_request_started_complete_handler,
395 scif_sas_io_request_default_destruct_handler
397 // SCI_BASE_REQUEST_STATE_COMPLETED
399 scif_sas_io_request_default_start_handler,
400 scif_sas_io_request_default_abort_handler,
401 scif_sas_io_request_default_complete_handler,
402 scif_sas_io_request_completed_destruct_handler
404 // SCI_BASE_REQUEST_STATE_ABORTING
406 scif_sas_io_request_default_start_handler,
407 scif_sas_io_request_aborting_abort_handler,
408 scif_sas_io_request_aborting_complete_handler,
409 scif_sas_io_request_default_destruct_handler
411 // SCI_BASE_REQUEST_STATE_FINAL
413 scif_sas_io_request_default_start_handler,
414 scif_sas_io_request_default_abort_handler,
415 scif_sas_io_request_default_complete_handler,
416 scif_sas_io_request_default_destruct_handler