2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __FBSDID("$FreeBSD$");
59 * @brief This file contains all of the method implementations pertaining
60 * to the framework io request state handler methods.
63 #include <dev/isci/scil/scic_controller.h>
64 #include <dev/isci/scil/scif_sas_logger.h>
65 #include <dev/isci/scil/scif_sas_io_request.h>
66 #include <dev/isci/scil/scif_sas_remote_device.h>
67 #include <dev/isci/scil/scif_sas_domain.h>
68 #include <dev/isci/scil/scif_sas_controller.h>
70 //******************************************************************************
71 //* C O N S T R U C T E D H A N D L E R S
72 //******************************************************************************
75 * @brief This method provides CONSTRUCTED state specific handling for
76 * when the user attempts to start the supplied IO request.
78 * @param[in] io_request This parameter specifies the IO request object
81 * @return This method returns a value indicating if the IO request was
82 * successfully started or not.
83 * @retval SCI_SUCCESS This return value indicates successful starting
86 SCI_STATUS scif_sas_io_request_constructed_start_handler(
87 SCI_BASE_REQUEST_T * io_request
94 * @brief This method provides CONSTRUCTED state specific handling for
95 * when the user attempts to abort the supplied IO request.
97 * @param[in] io_request This parameter specifies the IO request object
100 * @return This method returns a value indicating if the IO request was
101 * successfully aborted or not.
102 * @retval SCI_SUCCESS This return value indicates successful aborting
105 SCI_STATUS scif_sas_io_request_constructed_abort_handler(
106 SCI_BASE_REQUEST_T * io_request
109 sci_base_state_machine_change_state(
110 &io_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
116 //******************************************************************************
117 //* S T A R T E D H A N D L E R S
118 //******************************************************************************
121 * @brief This method provides STARTED state specific handling for
122 * when the user attempts to abort the supplied IO request.
124 * @param[in] io_request This parameter specifies the IO request object
127 * @return This method returns a value indicating if the aborting the
128 * IO request was successfully started.
129 * @retval SCI_SUCCESS This return value indicates that the abort process
130 * began successfully.
133 SCI_STATUS scif_sas_io_request_started_abort_handler(
134 SCI_BASE_REQUEST_T * io_request
137 SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T *) io_request;
139 sci_base_state_machine_change_state(
140 &io_request->state_machine, SCI_BASE_REQUEST_STATE_ABORTING
143 return fw_request->status;
147 * @brief This method provides STARTED state specific handling for
148 * when the user attempts to complete the supplied IO request.
150 * @param[in] io_request This parameter specifies the IO request object
153 * @return This method returns a value indicating if the completion of the
154 * IO request was successful.
155 * @retval SCI_SUCCESS This return value indicates that the completion process
159 SCI_STATUS scif_sas_io_request_started_complete_handler(
160 SCI_BASE_REQUEST_T * io_request
163 sci_base_state_machine_change_state(
164 &io_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
170 //******************************************************************************
171 //* C O M P L E T E D H A N D L E R S
172 //******************************************************************************
175 * @brief This method provides COMPLETED state specific handling for
176 * when the user attempts to destruct the supplied IO request.
178 * @param[in] io_request This parameter specifies the IO request object
181 * @return This method returns a value indicating if the destruct
182 * operation was successful.
183 * @retval SCI_SUCCESS This return value indicates that the destruct
187 SCI_STATUS scif_sas_io_request_completed_destruct_handler(
188 SCI_BASE_REQUEST_T * io_request
191 sci_base_state_machine_change_state(
192 &io_request->state_machine, SCI_BASE_REQUEST_STATE_FINAL
195 sci_base_state_machine_logger_deinitialize(
196 &io_request->state_machine_logger,
197 &io_request->state_machine
203 //******************************************************************************
204 //* A B O R T I N G H A N D L E R S
205 //******************************************************************************
208 * @brief This method provides ABORTING state specific handlering for when the
209 * user attempts to abort the supplied IO request.
211 * @param[in] io_request This parameter specifies the IO request object
214 * @return This method returns a value indicating if the completion
215 * operation was successful.
216 * @retval SCI_SUCCESS This return value indicates that the abort operation
220 SCI_STATUS scif_sas_io_request_aborting_abort_handler(
221 SCI_BASE_REQUEST_T * io_request
224 SCIF_SAS_IO_REQUEST_T * fw_request = (SCIF_SAS_IO_REQUEST_T *) io_request;
226 return scic_controller_terminate_request(
227 fw_request->parent.device->domain->controller->core_object,
228 fw_request->parent.device->core_object,
229 fw_request->parent.core_object
234 * @brief This method provides ABORTING state specific handling for
235 * when the user attempts to complete the supplied IO request.
237 * @param[in] io_request This parameter specifies the IO request object
240 * @return This method returns a value indicating if the completion
241 * operation was successful.
242 * @retval SCI_SUCCESS This return value indicates that the completion
246 SCI_STATUS scif_sas_io_request_aborting_complete_handler(
247 SCI_BASE_REQUEST_T * io_request
250 sci_base_state_machine_change_state(
251 &io_request->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED
257 //******************************************************************************
258 //* D E F A U L T H A N D L E R S
259 //******************************************************************************
262 * @brief This method provides DEFAULT handling for when the user
263 * attempts to start the supplied IO request.
265 * @param[in] io_request This parameter specifies the IO request object
268 * @return This method returns an indication that the start operation is
270 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
273 SCI_STATUS scif_sas_io_request_default_start_handler(
274 SCI_BASE_REQUEST_T * io_request
278 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
279 SCIF_LOG_OBJECT_IO_REQUEST,
280 "IoRequest:0x%x State:0x%x invalid state to start\n",
282 sci_base_state_machine_get_state(
283 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
286 return SCI_FAILURE_INVALID_STATE;
290 * @brief This method provides DEFAULT handling for when the user
291 * attempts to abort the supplied IO request.
293 * @param[in] io_request This parameter specifies the IO request object
296 * @return This method returns an indication that the abort operation is
298 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
301 SCI_STATUS scif_sas_io_request_default_abort_handler(
302 SCI_BASE_REQUEST_T * io_request
306 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
307 SCIF_LOG_OBJECT_IO_REQUEST,
308 "IoRequest:0x%x State:0x%x invalid state to abort\n",
310 sci_base_state_machine_get_state(
311 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
314 return SCI_FAILURE_INVALID_STATE;
318 * @brief This method provides DEFAULT handling for when the user
319 * attempts to complete the supplied IO request.
321 * @param[in] io_request This parameter specifies the IO request object
324 * @return This method returns an indication that complete operation is
326 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
328 SCI_STATUS scif_sas_io_request_default_complete_handler(
329 SCI_BASE_REQUEST_T * io_request
333 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
334 SCIF_LOG_OBJECT_IO_REQUEST,
335 "IoRequest:0x%x State:0x%x invalid state to complete\n",
337 sci_base_state_machine_get_state(
338 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
341 return SCI_FAILURE_INVALID_STATE;
345 * @brief This method provides DEFAULT handling for when the user
346 * attempts to destruct the supplied IO request.
348 * @param[in] io_request This parameter specifies the IO request object
351 * @return This method returns an indication that destruct operation is
353 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
355 SCI_STATUS scif_sas_io_request_default_destruct_handler(
356 SCI_BASE_REQUEST_T * io_request
360 sci_base_object_get_logger((SCIF_SAS_IO_REQUEST_T *) io_request),
361 SCIF_LOG_OBJECT_IO_REQUEST,
362 "IoRequest:0x%x State:0x%x invalid state to destruct.\n",
364 sci_base_state_machine_get_state(
365 &((SCIF_SAS_IO_REQUEST_T *) io_request)->parent.parent.state_machine)
368 return SCI_FAILURE_INVALID_STATE;
372 SCI_BASE_REQUEST_STATE_HANDLER_T scif_sas_io_request_state_handler_table[] =
374 // SCI_BASE_REQUEST_STATE_INITIAL
376 scif_sas_io_request_default_start_handler,
377 scif_sas_io_request_default_abort_handler,
378 scif_sas_io_request_default_complete_handler,
379 scif_sas_io_request_default_destruct_handler
381 // SCI_BASE_REQUEST_STATE_CONSTRUCTED
383 scif_sas_io_request_constructed_start_handler,
384 scif_sas_io_request_constructed_abort_handler,
385 scif_sas_io_request_default_complete_handler,
386 scif_sas_io_request_default_destruct_handler
388 // SCI_BASE_REQUEST_STATE_STARTED
390 scif_sas_io_request_default_start_handler,
391 scif_sas_io_request_started_abort_handler,
392 scif_sas_io_request_started_complete_handler,
393 scif_sas_io_request_default_destruct_handler
395 // SCI_BASE_REQUEST_STATE_COMPLETED
397 scif_sas_io_request_default_start_handler,
398 scif_sas_io_request_default_abort_handler,
399 scif_sas_io_request_default_complete_handler,
400 scif_sas_io_request_completed_destruct_handler
402 // SCI_BASE_REQUEST_STATE_ABORTING
404 scif_sas_io_request_default_start_handler,
405 scif_sas_io_request_aborting_abort_handler,
406 scif_sas_io_request_aborting_complete_handler,
407 scif_sas_io_request_default_destruct_handler
409 // SCI_BASE_REQUEST_STATE_FINAL
411 scif_sas_io_request_default_start_handler,
412 scif_sas_io_request_default_abort_handler,
413 scif_sas_io_request_default_complete_handler,
414 scif_sas_io_request_default_destruct_handler