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 state handler routines for each
60 * of the controller states defined by the SCI_BASE_CONTROLLER state
64 #include <dev/isci/scil/sci_util.h>
65 #include <dev/isci/scil/scic_controller.h>
66 #include <dev/isci/scil/scic_port.h>
67 #include <dev/isci/scil/scic_remote_device.h>
68 #include <dev/isci/scil/scic_io_request.h>
70 #include <dev/isci/scil/scif_sas_controller.h>
71 #include <dev/isci/scil/scif_sas_remote_device.h>
72 #include <dev/isci/scil/scif_sas_logger.h>
73 #include <dev/isci/scil/scif_sas_smp_remote_device.h>
75 //******************************************************************************
76 //* P R I V A T E M E T H O D S
77 //******************************************************************************
80 * @brief This method simply executes the reset operation by entering
81 * the reset state and allowing the state to perform it's work.
83 * @param[in] fw_controller This parameter specifies the SAS framework
84 * controller for execute the reset.
86 * @return Indicate the status of the reset operation. Was it successful?
87 * @retval SCI_SUCCESS This value is returned if it was successfully reset.
90 SCI_STATUS scif_sas_controller_execute_reset(
91 SCIF_SAS_CONTROLLER_T * fw_controller
97 sci_base_object_get_logger(fw_controller),
98 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_CONTROLLER_RESET,
99 "scif_sas_controller_execute_reset(0x%x) enter\n",
103 //clean the timer to avoid timer leak.
104 scif_sas_controller_release_resource(fw_controller);
106 sci_base_state_machine_change_state(
107 &fw_controller->parent.state_machine,
108 SCI_BASE_CONTROLLER_STATE_RESETTING
111 // Retrieve the status for the operations performed during the entrance
112 // to the resetting state were executing successfully.
113 status = fw_controller->operation_status;
114 fw_controller->operation_status = SCI_SUCCESS;
120 * @brief This method checks that the memory descriptor list is valid
121 * and hasn't been corrupted in some way by the user.
123 * @param[in] fw_controller This parameter specifies the framework
124 * controller object for which to validation the MDL.
126 * @return This method returns a value indicating if the operation succeeded.
127 * @retval SCI_SUCCESS This value indicates that MDL is valid.
128 * @retval SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD This value indicates
129 * that some portion of the memory descriptor list is invalid.
132 SCI_STATUS scif_sas_controller_validate_mdl(
133 SCIF_SAS_CONTROLLER_T * fw_controller
136 BOOL is_mde_list_valid;
138 // Currently there is only a single MDE in the list.
139 is_mde_list_valid = sci_base_mde_is_valid(
140 &fw_controller->mdes[SCIF_SAS_MDE_INTERNAL_IO],
142 fw_controller->internal_request_entries *
143 scif_sas_internal_request_get_object_size(),
144 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
147 if (is_mde_list_valid == FALSE)
148 return SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD;
155 * @brief This method stops all the domains associated to this
158 * @param[in] fw_controller This parameter specifies the framework
159 * controller object for whose remote devices are to be stopped.
161 * @return This method returns a value indicating if the operation succeeded.
162 * @retval SCI_SUCCESS This value indicates that all the devices are stopped.
163 * @retval SCI_FAILURE This value indicates certain failure during the process
164 * of stopping remote devices.
167 SCI_STATUS scif_sas_controller_stop_domains(
168 SCIF_SAS_CONTROLLER_T * fw_controller
172 SCI_STATUS status = SCI_SUCCESS;
173 SCIF_SAS_DOMAIN_T * fw_domain;
176 sci_base_object_get_logger(fw_controller),
177 SCIF_LOG_OBJECT_CONTROLLER,
178 "scif_sas_controller_stop_domains(0x%x) enter\n",
182 for (index = 0; index < SCI_MAX_DOMAINS && status == SCI_SUCCESS; index++)
184 fw_domain = &fw_controller->domains[index];
186 //Change this domain to STOPPING state. All the remote devices will be
187 //stopped subsquentially.
188 if (fw_domain->parent.state_machine.current_state_id ==
189 SCI_BASE_DOMAIN_STATE_READY
190 || fw_domain->parent.state_machine.current_state_id ==
191 SCI_BASE_DOMAIN_STATE_DISCOVERING)
193 sci_base_state_machine_change_state(
194 &fw_domain->parent.state_machine, SCI_BASE_DOMAIN_STATE_STOPPING
204 * @brief This method continue to stop the controller after clear affiliation
207 * @param[in] fw_controller This parameter specifies the framework
208 * controller object to be stopped.
210 * @return This method returns a value indicating if the operation succeeded.
211 * @retval SCI_SUCCESS This value indicates the controller_stop succeeds.
212 * @retval SCI_FAILURE This value indicates certain failure during the process
213 * of stopping controller.
215 SCI_STATUS scif_sas_controller_continue_to_stop(
216 SCIF_SAS_CONTROLLER_T * fw_controller
222 sci_base_object_get_logger(fw_controller),
223 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_SHUTDOWN,
224 "scif_sas_controller_continue_to_stop (0x%x).\n",
228 //stop all the domains and their remote devices.
229 status = scif_sas_controller_stop_domains(fw_controller);
231 if (status == SCI_SUCCESS)
233 // Attempt to stop the core controller.
234 status = scic_controller_stop(fw_controller->core_object, 0);
236 if (status != SCI_SUCCESS)
239 sci_base_object_get_logger(fw_controller),
240 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_SHUTDOWN,
241 "Controller:0x%x Status:0x%x unable to stop controller.\n",
242 fw_controller, status
245 sci_base_state_machine_change_state(
246 &fw_controller->parent.state_machine,
247 SCI_BASE_CONTROLLER_STATE_FAILED
254 sci_base_object_get_logger(fw_controller),
255 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_SHUTDOWN,
256 "Controller:0x%x Status:0x%x unable to stop domains.\n",
257 fw_controller, status
260 sci_base_state_machine_change_state(
261 &fw_controller->parent.state_machine,
262 SCI_BASE_CONTROLLER_STATE_FAILED
270 //******************************************************************************
271 //* R E S E T H A N D L E R S
272 //******************************************************************************
275 * @brief This method provides RESET state specific handling for
276 * when a user attempts to initialize a controller. This is a legal
277 * state in which to attempt an initialize call.
279 * @param[in] controller This parameter specifies the controller object
280 * on which the user is attempting to perform an initialize
283 * @return This method returns an indication of whether the initialize
284 * operation succeeded.
285 * @retval SCI_SUCCESS This value when the initialization completes
289 SCI_STATUS scif_sas_controller_reset_initialize_handler(
290 SCI_BASE_CONTROLLER_T * controller
293 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
298 sci_base_object_get_logger(fw_controller),
299 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
300 "scif_sas_controller_reset_initialize_handler(0x%x) enter\n",
304 sci_base_state_machine_change_state(
305 &fw_controller->parent.state_machine,
306 SCI_BASE_CONTROLLER_STATE_INITIALIZING
309 scif_sas_controller_build_mdl(fw_controller);
311 // Perform any domain object initialization that is necessary.
312 for (index = 0; index < SCI_MAX_DOMAINS; index++)
313 scif_sas_domain_initialize(&fw_controller->domains[index]);
315 scif_cb_lock_associate(fw_controller, &fw_controller->hprq.lock);
317 // Attempt to initialize the core controller.
318 status = scic_controller_initialize(fw_controller->core_object);
319 if (status == SCI_SUCCESS)
321 sci_base_state_machine_change_state(
322 &fw_controller->parent.state_machine,
323 SCI_BASE_CONTROLLER_STATE_INITIALIZED
327 if (status != SCI_SUCCESS)
329 // Initialization failed, Release resources and do not change state
330 scif_sas_controller_release_resource(fw_controller);
333 sci_base_object_get_logger(fw_controller),
334 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
335 "Controller:0x%x Status:0x%x unable to successfully initialize.\n",
336 fw_controller, status
343 //******************************************************************************
344 //* I N I T I A L I Z E D H A N D L E R S
345 //******************************************************************************
348 * @brief This method provides INITIALIZED state specific handling for
349 * when a user attempts to start a controller.
351 * @param[in] controller This parameter specifies the controller object
352 * on which the user is attempting to perform a start
354 * @param[in] timeout This parameter specifies the timeout value (in
355 * milliseconds) to be utilized for this operation.
357 * @return This method returns an indication of whether the start operation
359 * @retval SCI_SUCCESS This value is returned when the start operation
360 * begins successfully.
363 SCI_STATUS scif_sas_controller_initialized_start_handler(
364 SCI_BASE_CONTROLLER_T * controller,
368 SCI_STATUS status = SCI_SUCCESS;
369 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
372 SCI_PHYSICAL_MEMORY_DESCRIPTOR_T internal_reqeust_mde =
373 fw_controller->mdes[SCIF_SAS_MDE_INTERNAL_IO];
375 void * internal_request_virtual_address = internal_reqeust_mde.virtual_address;
376 POINTER_UINT address = (POINTER_UINT)internal_request_virtual_address;
379 sci_base_object_get_logger(fw_controller),
380 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
381 "scif_sas_controller_initialized_start_handler(0x%x, 0x%x) enter\n",
385 sci_base_state_machine_change_state(
386 &fw_controller->parent.state_machine,
387 SCI_BASE_CONTROLLER_STATE_STARTING
390 status = scif_sas_controller_validate_mdl(fw_controller);
392 // initialization work for internal request path. It must be done before
394 if (status == SCI_SUCCESS)
396 // fill in the sci_pool for internal requests.
397 sci_pool_initialize(fw_controller->internal_request_memory_pool);
399 for (index = 0; index < fw_controller->internal_request_entries; index++)
401 sci_pool_put(fw_controller->internal_request_memory_pool, address);
403 address += scif_sas_internal_request_get_object_size();
406 // Using DPC for starting internal IOs, if yes, we need to intialize
408 scif_cb_start_internal_io_task_create(fw_controller);
411 if (status == SCI_SUCCESS)
413 // Kick-start the domain state machines and, by association, the
416 // This will ensure we get valid port objects supplied with link up
419 (index < SCI_MAX_DOMAINS) && (status == SCI_SUCCESS);
422 sci_base_state_machine_change_state(
423 &fw_controller->domains[index].parent.state_machine,
424 SCI_BASE_DOMAIN_STATE_STARTING
426 status = fw_controller->domains[index].operation.status;
430 // Validate that all the domain state machines began successfully.
431 if (status != SCI_SUCCESS)
434 sci_base_object_get_logger(fw_controller),
435 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
436 "Controller:0x%x Domain:0x%x Status:0x%x unable to start\n",
437 fw_controller, index, status
443 // Attempt to start the core controller.
444 status = scic_controller_start(fw_controller->core_object, timeout);
445 if (status != SCI_SUCCESS)
448 sci_base_object_get_logger(fw_controller),
449 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
450 "Controller:0x%x Status:0x%x unable to start controller.\n",
451 fw_controller, status
454 sci_base_state_machine_change_state(
455 &fw_controller->parent.state_machine,
456 SCI_BASE_CONTROLLER_STATE_FAILED
463 //******************************************************************************
464 //* R E A D Y H A N D L E R S
465 //******************************************************************************
468 * @brief This method provides READY state specific handling for
469 * when a user attempts to stop a controller.
471 * @param[in] controller This parameter specifies the controller object
472 * on which the user is attempting to perform a stop
474 * @param[in] timeout This parameter specifies the timeout value (in
475 * milliseconds) to be utilized for this operation.
477 * @return This method returns an indication of whether the stop operation
479 * @retval SCI_SUCCESS This value is returned when the stop operation
480 * begins successfully.
483 SCI_STATUS scif_sas_controller_ready_stop_handler(
484 SCI_BASE_CONTROLLER_T * controller,
488 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
491 sci_base_object_get_logger(fw_controller),
492 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
493 "scif_sas_controller_ready_stop_handler(0x%x, 0x%x) enter\n",
497 sci_base_state_machine_change_state(
498 &fw_controller->parent.state_machine,
499 SCI_BASE_CONTROLLER_STATE_STOPPING
502 if (fw_controller->user_parameters.sas.clear_affiliation_during_controller_stop)
504 fw_controller->current_domain_to_clear_affiliation = 0;
506 //clear affiliation first. After the last domain finishes clearing
507 //affiliation, it will call back to controller to continue to stop.
508 scif_sas_controller_clear_affiliation(fw_controller);
511 scif_sas_controller_continue_to_stop(fw_controller);
513 //Must return SUCCESS at this point.
518 * @brief This method provides READY state specific handling for
519 * when a user attempts to reset a controller.
521 * @param[in] controller This parameter specifies the controller object
522 * on which the user is attempting to perform a reset
525 * @return This method returns an indication of whether the reset operation
527 * @retval SCI_SUCCESS This value is returned when the reset operation
528 * completes successfully.
531 SCI_STATUS scif_sas_controller_ready_reset_handler(
532 SCI_BASE_CONTROLLER_T * controller
535 return scif_sas_controller_execute_reset((SCIF_SAS_CONTROLLER_T*)controller);
539 * @brief This method provides READY state specific handling for
540 * when a user attempts to start an IO request.
542 * @param[in] controller This parameter specifies the controller object
543 * on which the user is attempting to perform a start IO
545 * @param[in] remote_device This parameter specifies the remote deivce
546 * object on which the user is attempting to perform a start IO
548 * @param[in] io_request This parameter specifies the IO request to be
550 * @param[in] io_tag This parameter specifies the optional allocated
551 * IO tag. Please reference scif_controller_start_io() for
554 * @return This method returns an indication of whether the start IO
555 * operation succeeded.
556 * @retval SCI_SUCCESS This value is returned when the start IO operation
557 * begins successfully.
560 SCI_STATUS scif_sas_controller_ready_start_io_handler(
561 SCI_BASE_CONTROLLER_T * controller,
562 SCI_BASE_REMOTE_DEVICE_T * remote_device,
563 SCI_BASE_REQUEST_T * io_request,
568 SCIF_SAS_IO_REQUEST_T *fw_io = (SCIF_SAS_IO_REQUEST_T*)io_request;
569 SCIF_SAS_CONTROLLER_T *fw_controller = (SCIF_SAS_CONTROLLER_T*)controller;
570 SCIF_SAS_REMOTE_DEVICE_T *fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
574 sci_base_object_get_logger(fw_controller),
575 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
576 "scif_sas_controller_ready_start_io_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
577 controller, remote_device, io_request, io_tag
580 status = fw_device->domain->state_handlers->start_io_handler(
581 &fw_device->domain->parent, remote_device, io_request
584 // Check to see that the other objects in the framework allowed
585 // this IO to be started.
586 if (status == SCI_SUCCESS)
588 // Ask the core to start processing for this IO request.
589 status = (SCI_STATUS)scic_controller_start_io(
590 fw_controller->core_object,
591 fw_device->core_object,
592 fw_io->parent.core_object,
596 if (status == SCI_SUCCESS)
598 // We were able to start the core request. As a result,
599 // commit to starting the request for the framework by changing
600 // the state of the IO request.
601 sci_base_state_machine_change_state(
602 &io_request->state_machine, SCI_BASE_REQUEST_STATE_STARTED
607 // We were unable to start the core IO request. As a result,
608 // back out the start operation for the framework. It's easier to
609 // back out the framework start operation then to backout the core
610 // start IO operation.
611 fw_device->domain->state_handlers->complete_io_handler(
612 &fw_device->domain->parent, remote_device, io_request
615 // Invoke the IO completion handler. For most IOs, this does nothing
616 // since we are still in the constructed state. For NCQ, this will
617 // the return of the NCQ tag back to the remote device free pool.
618 fw_io->parent.state_handlers->complete_handler(io_request);
621 sci_base_object_get_logger(fw_controller),
622 SCIF_LOG_OBJECT_CONTROLLER,
623 "Controller:0x%x IORequest:0x%x Status:0x%x core IO start failed\n",
624 fw_controller, fw_io, status
631 sci_base_object_get_logger(fw_controller),
632 SCIF_LOG_OBJECT_CONTROLLER,
633 "Controller:0x%x IORequest:0x%x Status:0x%x IO start failed\n",
634 fw_controller, fw_io, status
642 * @brief This method provides READY state specific handling for
643 * when a user attempts to complete an IO request.
645 * @param[in] controller This parameter specifies the controller object
646 * on which the user is attempting to perform a complete IO
648 * @param[in] remote_device This parameter specifies the remote deivce
649 * object on which the user is attempting to perform a start IO
651 * @param[in] io_request This parameter specifies the IO request to be
654 * @return This method returns an indication of whether the complete IO
655 * operation succeeded.
656 * @retval SCI_SUCCESS This value is returned when the complete IO operation
657 * begins successfully.
660 SCI_STATUS scif_sas_controller_ready_complete_io_handler(
661 SCI_BASE_CONTROLLER_T * controller,
662 SCI_BASE_REMOTE_DEVICE_T * remote_device,
663 SCI_BASE_REQUEST_T * io_request
666 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
668 SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
670 SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
673 SCI_STATUS core_status;
676 sci_base_object_get_logger(fw_controller),
677 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
678 "scif_sas_controller_ready_complete_io_handler(0x%x, 0x%x, 0x%x) enter\n",
679 controller, remote_device, io_request
682 fw_io->parent.state_handlers->destruct_handler(&fw_io->parent.parent);
683 status = fw_device->domain->state_handlers->complete_io_handler(
684 &fw_device->domain->parent, remote_device, io_request
687 // Ask the core to finish processing for this IO request.
688 core_status = scic_controller_complete_io(
689 fw_controller->core_object,
690 fw_device->core_object,
691 fw_io->parent.core_object
694 if (status == SCI_SUCCESS)
695 status = core_status;
697 if (status != SCI_SUCCESS)
700 sci_base_object_get_logger(fw_controller),
701 SCIF_LOG_OBJECT_CONTROLLER,
702 "Controller:0x%x IORequest:0x%x Status:0x%x CoreStatus:0x%x "
703 "failure to complete IO\n",
704 fw_controller, fw_io, status, core_status
713 * @brief This method provides READY state specific handling for
714 * when a user attempts to complete a high priority IO request.
716 * @param[in] controller This parameter specifies the controller object
717 * on which the user is attempting to perform a complete IO
719 * @param[in] remote_device This parameter specifies the remote deivce
720 * object on which the user is attempting to perform a start IO
722 * @param[in] io_request This parameter specifies the IO request to be
725 * @return This method returns an indication of whether the complete IO
726 * operation succeeded.
727 * @retval SCI_SUCCESS This value is returned when the complete IO operation
728 * begins successfully.
731 SCI_STATUS scif_sas_controller_ready_complete_high_priority_io_handler(
732 SCI_BASE_CONTROLLER_T * controller,
733 SCI_BASE_REMOTE_DEVICE_T * remote_device,
734 SCI_BASE_REQUEST_T * io_request
737 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
739 SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
741 SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
743 SCI_IO_STATUS core_completion_status =
744 scic_request_get_sci_status(fw_io->parent.core_object);
746 U8 response_data[SCIF_SAS_RESPONSE_DATA_LENGTH];
749 SCI_STATUS core_status;
752 sci_base_object_get_logger(fw_controller),
753 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
754 "scif_sas_controller_ready_complete_high_priority_io_handler(0x%x, 0x%x, 0x%x) enter\n",
755 controller, remote_device, io_request
758 // In high priority path, we ask the core to finish IO request before framework.
760 // retrieve and save io response from core now.
761 memcpy(response_data,
762 scic_io_request_get_response_iu_address(fw_io->parent.core_object),
763 SCIF_SAS_RESPONSE_DATA_LENGTH
766 core_status = scic_controller_complete_io(
767 fw_controller->core_object,
768 fw_device->core_object,
769 fw_io->parent.core_object
772 fw_io->parent.state_handlers->destruct_handler(&fw_io->parent.parent);
773 status = fw_device->domain->state_handlers->complete_high_priority_io_handler(
774 &fw_device->domain->parent,
777 (void *)response_data,
778 core_completion_status
781 if (status == SCI_SUCCESS)
782 status = core_status;
784 if (status == SCI_SUCCESS)
786 //issue DPC to start next internal io in high prioriy queue.
787 if( !sci_pool_empty(fw_controller->hprq.pool) )
788 scif_cb_start_internal_io_task_schedule(
790 scif_sas_controller_start_high_priority_io,
797 sci_base_object_get_logger(fw_controller),
798 SCIF_LOG_OBJECT_CONTROLLER,
799 "Controller:0x%x IORequest:0x%x Status:0x%x CoreStatus:0x%x "
800 "failure to complete IO\n",
801 fw_controller, fw_io, status, core_status
809 * @brief This method provides READY state specific handling for
810 * when a user attempts to continue an IO request.
812 * @param[in] controller This parameter specifies the controller object
813 * on which the user is attempting to perform a continue IO
815 * @param[in] remote_device This parameter specifies the remote deivce
816 * object on which the user is attempting to perform a start IO
818 * @param[in] io_request This parameter specifies the IO request to be
821 * @return This method returns an indication of whether the continue IO
822 * operation succeeded.
823 * @retval SCI_SUCCESS This value is returned when the continue IO operation
824 * begins successfully.
827 SCI_STATUS scif_sas_controller_ready_continue_io_handler(
828 SCI_BASE_CONTROLLER_T * controller,
829 SCI_BASE_REMOTE_DEVICE_T * remote_device,
830 SCI_BASE_REQUEST_T * io_request
834 sci_base_object_get_logger(controller),
835 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
836 "scif_sas_controller_ready_continue_io_handler(0x%x, 0x%x, 0x%x) enter\n",
837 controller, remote_device, io_request
840 /// @todo Function unimplemented. fix return code handling.
845 * @brief This method provides READY state specific handling for
846 * when a user attempts to start a task request.
848 * @param[in] controller This parameter specifies the controller object
849 * on which the user is attempting to perform a start task
851 * @param[in] remote_device This parameter specifies the remote deivce
852 * object on which the user is attempting to perform a start
854 * @param[in] task_request This parameter specifies the task management
855 * request to be started.
856 * @param[in] io_tag This parameter specifies the optional allocated
857 * IO tag. Please reference scif_controller_start_task() for
860 * @return This method returns an indication of whether the start task
861 * operation succeeded.
862 * @retval SCI_SUCCESS This value is returned when the start task operation
863 * begins successfully.
866 SCI_STATUS scif_sas_controller_ready_start_task_handler(
867 SCI_BASE_CONTROLLER_T * controller,
868 SCI_BASE_REMOTE_DEVICE_T * remote_device,
869 SCI_BASE_REQUEST_T * task_request,
873 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
875 SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
877 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T*)task_request;
881 sci_base_object_get_logger(fw_controller),
882 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_TASK_MANAGEMENT,
883 "scif_sas_controller_ready_start_task_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
884 controller, remote_device, task_request, io_tag
887 status = fw_device->domain->state_handlers->start_task_handler(
888 &fw_device->domain->parent, remote_device, task_request
891 if (status == SCI_SUCCESS)
893 if (scif_sas_task_request_get_function(fw_task)
894 == SCI_SAS_HARD_RESET)
896 // Go off to special target reset path. Don't start task to core.
897 scif_sas_remote_device_target_reset(
899 (SCIF_SAS_REQUEST_T *)fw_task
905 // Ask the core to start processing for this task request.
906 status = (SCI_STATUS)scic_controller_start_task(
907 fw_controller->core_object,
908 fw_device->core_object,
909 fw_task->parent.core_object,
913 if (status == SCI_SUCCESS)
915 // We were able to start the core request. As a result,
916 // commit to starting the request for the framework by changing
917 // the state of the task request.
918 fw_task->parent.state_handlers->start_handler(&fw_task->parent.parent);
922 // We were unable to start the core task request. As a result,
923 // back out the start operation for the framework. It's easier to
924 // back out the framework start operation then to backout the core
925 // start task operation.
926 fw_device->domain->state_handlers->complete_task_handler(
927 &fw_device->domain->parent, remote_device, task_request
930 if (status == SCI_SUCCESS)
933 sci_base_object_get_logger(fw_controller),
934 SCIF_LOG_OBJECT_CONTROLLER,
935 "Controller:0x%x TaskRequest:0x%x Status:0x%x core start failed\n",
936 fw_controller, fw_task, status
944 sci_base_object_get_logger(fw_controller),
945 SCIF_LOG_OBJECT_CONTROLLER,
946 "Controller:0x%x TaskRequest:0x%x Status:0x%x Task start failed\n",
947 fw_controller, fw_task, status
955 * @brief This method provides READY state specific handling for
956 * when a user attempts to complete a task request.
958 * @param[in] controller This parameter specifies the controller object
959 * on which the user is attempting to perform a complete task
961 * @param[in] remote_device This parameter specifies the remote deivce
962 * object on which the user is attempting to perform a start
964 * @param[in] task_request This parameter specifies the task management
965 * request to be started.
967 * @return This method returns an indication of whether the complete task
968 * operation succeeded.
969 * @retval SCI_SUCCESS This value is returned when the complete task operation
970 * begins successfully.
973 SCI_STATUS scif_sas_controller_ready_complete_task_handler(
974 SCI_BASE_CONTROLLER_T * controller,
975 SCI_BASE_REMOTE_DEVICE_T * remote_device,
976 SCI_BASE_REQUEST_T * task_request
979 SCIF_SAS_CONTROLLER_T *fw_controller = (SCIF_SAS_CONTROLLER_T*)controller;
980 SCIF_SAS_REMOTE_DEVICE_T *fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)remote_device;
981 SCIF_SAS_TASK_REQUEST_T *fw_task = (SCIF_SAS_TASK_REQUEST_T*)task_request;
983 SCI_STATUS core_status;
986 sci_base_object_get_logger(fw_controller),
987 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_TASK_MANAGEMENT,
988 "scif_sas_controller_ready_complete_task_handler(0x%x, 0x%x, 0x%x) enter\n",
989 controller, remote_device, task_request
992 status = fw_device->domain->state_handlers->complete_task_handler(
993 &fw_device->domain->parent, remote_device, task_request
996 if (scif_sas_task_request_get_function(fw_task)
997 == SCI_SAS_HARD_RESET)
999 //No more things to do in the core, since this task is for Target Reset.
1003 fw_task->parent.state_handlers->destruct_handler(&fw_task->parent.parent);
1005 // Ask the core to finish processing for this task request.
1006 core_status = scic_controller_complete_task(
1007 fw_controller->core_object,
1008 fw_device->core_object,
1009 fw_task->parent.core_object
1012 if (status == SCI_SUCCESS)
1013 status = core_status;
1015 if (status != SCI_SUCCESS)
1018 sci_base_object_get_logger(fw_controller),
1019 SCIF_LOG_OBJECT_CONTROLLER,
1020 "Controller:0x%x TaskRequest:0x%x Status:0x%x CoreStatus:0x%x "
1021 "failed to complete\n",
1022 fw_controller, fw_task, status, core_status
1032 * @brief This method provides common handling for several states
1033 * when a user attempts to start an internal request.
1035 * @param[in] controller This parameter specifies the controller object
1036 * on which the user is attempting to perform a start IO
1038 * @param[in] remote_device This parameter specifies the remote deivce
1039 * object on which the user is attempting to perform a start IO
1041 * @param[in] io_request This parameter specifies the IO request to be
1043 * @param[in] io_tag This parameter specifies the optional allocated
1044 * IO tag. Please reference scif_controller_start_io() for
1047 * @return This method returns an indication of whether the start IO
1048 * operation succeeded.
1049 * @retval SCI_SUCCESS This value is returned when the start IO operation
1050 * begins successfully.
1053 SCI_STATUS scif_sas_controller_common_start_high_priority_io_handler(
1054 SCI_BASE_CONTROLLER_T * controller,
1055 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1056 SCI_BASE_REQUEST_T * io_request,
1061 SCIF_SAS_IO_REQUEST_T *fw_io = (SCIF_SAS_IO_REQUEST_T*)io_request;
1062 SCIF_SAS_CONTROLLER_T *fw_controller = (SCIF_SAS_CONTROLLER_T*)controller;
1063 SCIF_SAS_REMOTE_DEVICE_T *fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
1066 status = fw_device->domain->state_handlers->start_high_priority_io_handler(
1067 &fw_device->domain->parent, remote_device, io_request
1070 // Check to see that the other objects in the framework allowed
1071 // this IO to be started.
1072 if (status == SCI_SUCCESS)
1074 // Ask the core to start processing for this IO request.
1075 status = (SCI_STATUS)scic_controller_start_io(
1076 fw_controller->core_object,
1077 fw_device->core_object,
1078 fw_io->parent.core_object,
1082 if (status == SCI_SUCCESS)
1084 // We were able to start the core request. As a result,
1085 // commit to starting the request for the framework by changing
1086 // the state of the IO request.
1087 sci_base_state_machine_change_state(
1088 &io_request->state_machine, SCI_BASE_REQUEST_STATE_STARTED
1093 // We were unable to start the core IO request. As a result,
1094 // back out the start operation for the framework. It's easier to
1095 // back out the framework start operation then to backout the core
1096 // start IO operation.
1097 fw_device->domain->state_handlers->complete_io_handler(
1098 &fw_device->domain->parent, remote_device, io_request
1101 // Invoke the IO completion handler. For most IOs, this does nothing
1102 // since we are still in the constructed state. For NCQ, this will
1103 // the return of the NCQ tag back to the remote device free pool.
1104 fw_io->parent.state_handlers->complete_handler(io_request);
1107 sci_base_object_get_logger(fw_controller),
1108 SCIF_LOG_OBJECT_CONTROLLER,
1109 "Controller:0x%x IORequest:0x%x Status:0x%x core IO start failed\n",
1110 fw_controller, fw_io, status
1117 sci_base_object_get_logger(fw_controller),
1118 SCIF_LOG_OBJECT_CONTROLLER,
1119 "Controller:0x%x IORequest:0x%x Status:0x%x IO start failed\n",
1120 fw_controller, fw_io, status
1123 // Invoke the IO completion handler. For most IOs, this does nothing
1124 // since we are still in the constructed state. For NCQ, this will
1125 // the return of the NCQ tag back to the remote device free pool.
1126 fw_io->parent.state_handlers->complete_handler(io_request);
1130 if (fw_io->parent.is_internal && status != SCI_SUCCESS )
1132 SCIC_TRANSPORT_PROTOCOL protocol =
1133 scic_io_request_get_protocol(fw_io->parent.core_object);
1135 U8 retry_count = fw_io->retry_count;
1137 scif_sas_internal_io_request_destruct(
1138 fw_device->domain->controller,
1139 (SCIF_SAS_INTERNAL_IO_REQUEST_T *)fw_io
1142 if ( protocol == SCIC_SMP_PROTOCOL )
1144 if (fw_device->protocol_device.smp_device.smp_activity_timer != NULL)
1146 //destroy the smp_activity_timer
1147 scif_cb_timer_destroy (
1149 fw_device->protocol_device.smp_device.smp_activity_timer
1152 fw_device->protocol_device.smp_device.smp_activity_timer = NULL;
1155 //we should retry for finite times
1156 if ( retry_count < SCIF_SAS_IO_RETRY_LIMIT)
1158 //An internal smp request failed being started, most likely due to remote device
1159 //is not in ready state, for example, UPDATING_PORT_WIDTH state. In this case,
1160 //we should retry the IO.
1161 scif_sas_smp_remote_device_retry_internal_io(
1162 (SCIF_SAS_REMOTE_DEVICE_T *)remote_device,
1164 SMP_REQUEST_RETRY_WAIT_DURATION
1175 * @brief This method provides READY state specific handling for
1176 * when a user attempts to start an internal request. If the high
1177 * priority IO is also internal, this method will schedule its timer.
1179 * @param[in] controller This parameter specifies the controller object
1180 * on which the user is attempting to perform a start IO
1182 * @param[in] remote_device This parameter specifies the remote deivce
1183 * object on which the user is attempting to perform a start IO
1185 * @param[in] io_request This parameter specifies the IO request to be
1187 * @param[in] io_tag This parameter specifies the optional allocated
1188 * IO tag. Please reference scif_controller_start_io() for
1191 * @return This method returns an indication of whether the start IO
1192 * operation succeeded.
1193 * @retval SCI_SUCCESS This value is returned when the start IO operation
1194 * begins successfully.
1197 SCI_STATUS scif_sas_controller_ready_start_high_priority_io_handler(
1198 SCI_BASE_CONTROLLER_T * controller,
1199 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1200 SCI_BASE_REQUEST_T * io_request,
1205 SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T *)io_request;
1208 sci_base_object_get_logger(controller),
1209 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
1210 "scif_sas_controller_ready_start_high_priority_io_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
1211 controller, remote_device, io_request, io_tag
1214 status = scif_sas_controller_common_start_high_priority_io_handler(
1215 controller, remote_device, io_request, io_tag);
1217 if (status == SCI_SUCCESS)
1219 //External io could also be put in high priority queue. i.e. the
1220 //smp request for EA Target Reset.
1221 if (fw_io->parent.is_internal)
1223 SCIF_SAS_INTERNAL_IO_REQUEST_T * fw_internal_io =
1224 (SCIF_SAS_INTERNAL_IO_REQUEST_T *)fw_io;
1226 //start the timer for internal io
1227 scif_cb_timer_start(
1228 (SCI_CONTROLLER_HANDLE_T)controller,
1229 fw_internal_io->internal_io_timer,
1230 SCIF_SAS_INTERNAL_REQUEST_TIMEOUT
1236 //If failed to start, most likely the device or domain is not in
1237 //correct state, and the IO has been cleaned up in controller's start
1238 //high priority IO handler. We should just continue to start the next
1239 //IO in the HP queue.
1242 sci_base_object_get_logger(controller),
1243 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
1244 "scif_controller_start_high_priority_io(0x%x, 0x%x), starting io failed\n",
1253 //******************************************************************************
1254 //* S T O P P I N G H A N D L E R S
1255 //******************************************************************************
1257 * @brief This method provides STOPPING state specific handling for
1258 * when a user attempts to start an internal request. Note that we don't
1259 * start the timer for internal IO during controller stopping state.
1261 * @param[in] controller This parameter specifies the controller object
1262 * on which the user is attempting to perform a start IO
1264 * @param[in] remote_device This parameter specifies the remote deivce
1265 * object on which the user is attempting to perform a start IO
1267 * @param[in] io_request This parameter specifies the IO request to be
1269 * @param[in] io_tag This parameter specifies the optional allocated
1270 * IO tag. Please reference scif_controller_start_io() for
1273 * @return This method returns an indication of whether the start IO
1274 * operation succeeded.
1275 * @retval SCI_SUCCESS This value is returned when the start IO operation
1276 * begins successfully.
1279 SCI_STATUS scif_sas_controller_stopping_start_high_priority_io_handler(
1280 SCI_BASE_CONTROLLER_T * controller,
1281 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1282 SCI_BASE_REQUEST_T * io_request,
1287 sci_base_object_get_logger(controller),
1288 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
1289 "scif_sas_controller_stopping_start_high_priority_io_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
1290 controller, remote_device, io_request, io_tag
1293 return scif_sas_controller_common_start_high_priority_io_handler(
1294 controller, remote_device, io_request, io_tag);
1298 //******************************************************************************
1299 //* S T O P P E D H A N D L E R S
1300 //******************************************************************************
1303 * @brief This method provides STOPPED state specific handling for
1304 * when a user attempts to reset a controller.
1306 * @param[in] controller This parameter specifies the controller object
1307 * on which the user is attempting to perform a reset
1310 * @return This method returns an indication of whether the reset operation
1312 * @retval SCI_SUCCESS This value is returned when the reset operation
1313 * completes successfully.
1316 SCI_STATUS scif_sas_controller_stopped_reset_handler(
1317 SCI_BASE_CONTROLLER_T * controller
1320 return scif_sas_controller_execute_reset((SCIF_SAS_CONTROLLER_T*)controller);
1324 //******************************************************************************
1325 //* F A I L E D H A N D L E R S
1326 //******************************************************************************
1329 * @brief This method provides FAILED state specific handling for
1330 * when a user attempts to reset a controller.
1332 * @param[in] controller This parameter specifies the controller object
1333 * on which the user is attempting to perform a reset
1336 * @return This method returns an indication of whether the reset operation
1338 * @retval SCI_SUCCESS This value is returned when the reset operation
1339 * completes successfully.
1342 SCI_STATUS scif_sas_controller_failed_reset_handler(
1343 SCI_BASE_CONTROLLER_T * controller
1346 return scif_sas_controller_execute_reset((SCIF_SAS_CONTROLLER_T*)controller);
1349 //******************************************************************************
1350 //* D E F A U L T H A N D L E R S
1351 //******************************************************************************
1354 * @brief This method provides default handling (i.e. returns an error)
1355 * when a user attempts to start a controller and a start operation
1358 * @param[in] controller This parameter specifies the controller object
1359 * on which the user is attempting to perform a start operation.
1360 * @param[in] timeout This parameter specifies the timeout value (in
1361 * milliseconds) to be utilized for this operation.
1363 * @return This method returns an indication that start operations are not
1365 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1368 SCI_STATUS scif_sas_controller_default_start_handler(
1369 SCI_BASE_CONTROLLER_T * controller,
1374 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1375 SCIF_LOG_OBJECT_CONTROLLER,
1376 "Controller:0x%x State:0x%x invalid state to start controller.\n",
1378 sci_base_state_machine_get_state(
1379 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1382 return SCI_FAILURE_INVALID_STATE;
1386 * @brief This method provides default handling (i.e. returns an error)
1387 * when a user attempts to stop a controller and a stop operation
1390 * @param[in] controller This parameter specifies the controller object
1391 * on which the user is attempting to perform a stop operation.
1392 * @param[in] timeout This parameter specifies the timeout value (in
1393 * milliseconds) to be utilized for this operation.
1395 * @return This method returns an indication that stop operations are not
1397 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1400 SCI_STATUS scif_sas_controller_default_stop_handler(
1401 SCI_BASE_CONTROLLER_T * controller,
1406 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1407 SCIF_LOG_OBJECT_CONTROLLER,
1408 "Controller:0x%x State:0x%x invalid state to stop controller.\n",
1410 sci_base_state_machine_get_state(
1411 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1414 return SCI_FAILURE_INVALID_STATE;
1418 * @brief This method provides default handling (i.e. returns an error)
1419 * when a user attempts to reset a controller and a reset operation
1422 * @param[in] controller This parameter specifies the controller object
1423 * on which the user is attempting to perform a reset operation.
1425 * @return This method returns an indication that reset operations are not
1427 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1430 SCI_STATUS scif_sas_controller_default_reset_handler(
1431 SCI_BASE_CONTROLLER_T * controller
1435 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1436 SCIF_LOG_OBJECT_CONTROLLER,
1437 "Controller:0x%x State:0x%x invalid state to reset controller.\n",
1439 sci_base_state_machine_get_state(
1440 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1443 return SCI_FAILURE_INVALID_STATE;
1447 * @brief This method provides default handling (i.e. returns an error)
1448 * when a user attempts to initialize a controller and an initialize
1449 * operation is not allowed.
1451 * @param[in] controller This parameter specifies the controller object
1452 * on which the user is attempting to perform an initialize
1455 * @return This method returns an indication that initialize operations
1457 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1460 SCI_STATUS scif_sas_controller_default_initialize_handler(
1461 SCI_BASE_CONTROLLER_T * controller
1465 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1466 SCIF_LOG_OBJECT_CONTROLLER,
1467 "Controller:0x%x State:0x%x invalid state to initialize controller.\n",
1469 sci_base_state_machine_get_state(
1470 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1473 return SCI_FAILURE_INVALID_STATE;
1477 * @brief This method provides default handling (i.e. returns an error)
1478 * when a user attempts to start an IO on a controller and a start
1479 * IO operation is not allowed.
1481 * @param[in] controller This parameter specifies the controller object
1482 * on which the user is attempting to perform a start IO
1484 * @param[in] remote_device This parameter specifies the remote deivce
1485 * object on which the user is attempting to perform a start IO
1487 * @param[in] io_request This parameter specifies the IO request to be
1489 * @param[in] io_tag This parameter specifies the optional allocated
1490 * IO tag. Please reference scif_controller_start_io() for
1493 * @return This method returns an indication that start IO operations
1495 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1498 SCI_STATUS scif_sas_controller_default_start_io_handler(
1499 SCI_BASE_CONTROLLER_T * controller,
1500 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1501 SCI_BASE_REQUEST_T * io_request,
1506 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1507 SCIF_LOG_OBJECT_CONTROLLER,
1508 "Controller:0x%x State:0x%x invalid state to start IO.\n",
1510 sci_base_state_machine_get_state(
1511 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1514 return SCI_FAILURE_INVALID_STATE;
1518 * @brief This method provides default handling (i.e. returns an error)
1519 * when a user attempts to complete an IO on a controller and a
1520 * complete IO operation is not allowed.
1522 * @param[in] controller This parameter specifies the controller object
1523 * on which the user is attempting to perform a complete IO
1525 * @param[in] remote_device This parameter specifies the remote deivce
1526 * object on which the user is attempting to perform a start IO
1528 * @param[in] io_request This parameter specifies the IO request to be
1531 * @return This method returns an indication that complete IO operations
1533 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1536 SCI_STATUS scif_sas_controller_default_complete_io_handler(
1537 SCI_BASE_CONTROLLER_T * controller,
1538 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1539 SCI_BASE_REQUEST_T * io_request
1543 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1544 SCIF_LOG_OBJECT_CONTROLLER,
1545 "Controller:0x%x State:0x%x invalid state to complete IO.\n",
1547 sci_base_state_machine_get_state(
1548 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1551 return SCI_FAILURE_INVALID_STATE;
1555 * @brief This method provides default handling (i.e. returns an error)
1556 * when a user attempts to continue an IO on a controller and a
1557 * continue IO operation is not allowed.
1559 * @param[in] controller This parameter specifies the controller object
1560 * on which the user is attempting to perform a continue IO
1562 * @param[in] remote_device This parameter specifies the remote deivce
1563 * object on which the user is attempting to perform a start IO
1565 * @param[in] io_request This parameter specifies the IO request to be
1568 * @return This method returns an indication that continue IO operations
1570 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1573 SCI_STATUS scif_sas_controller_default_continue_io_handler(
1574 SCI_BASE_CONTROLLER_T * controller,
1575 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1576 SCI_BASE_REQUEST_T * io_request
1580 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1581 SCIF_LOG_OBJECT_CONTROLLER,
1582 "Controller:0x%x State:0x%x invalid state to continue IO.\n",
1584 sci_base_state_machine_get_state(
1585 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1588 return SCI_FAILURE_INVALID_STATE;
1592 * @brief This method provides default handling (i.e. returns an error)
1593 * when a user attempts to start a task on a controller and a start
1594 * task operation is not allowed.
1596 * @param[in] controller This parameter specifies the controller object
1597 * on which the user is attempting to perform a start task
1599 * @param[in] remote_device This parameter specifies the remote deivce
1600 * object on which the user is attempting to perform a start
1602 * @param[in] task_request This parameter specifies the task management
1603 * request to be started.
1604 * @param[in] io_tag This parameter specifies the optional allocated
1605 * IO tag. Please reference scif_controller_start_task() for
1608 * @return This method returns an indication that start task operations
1610 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1613 SCI_STATUS scif_sas_controller_default_start_task_handler(
1614 SCI_BASE_CONTROLLER_T * controller,
1615 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1616 SCI_BASE_REQUEST_T * task_request,
1621 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1622 SCIF_LOG_OBJECT_CONTROLLER,
1623 "Controller:0x%x State:0x%x invalid state to start task mgmt.\n",
1625 sci_base_state_machine_get_state(
1626 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1629 return SCI_FAILURE_INVALID_STATE;
1633 * @brief This method provides default handling (i.e. returns an error)
1634 * when a user attempts to complete a task on a controller and a
1635 * complete task operation is not allowed.
1637 * @param[in] controller This parameter specifies the controller object
1638 * on which the user is attempting to perform a complete task
1640 * @param[in] remote_device This parameter specifies the remote deivce
1641 * object on which the user is attempting to perform a start
1643 * @param[in] task_request This parameter specifies the task management
1644 * request to be started.
1646 * @return This method returns an indication that complete task operations
1648 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1651 SCI_STATUS scif_sas_controller_default_complete_task_handler(
1652 SCI_BASE_CONTROLLER_T * controller,
1653 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1654 SCI_BASE_REQUEST_T * task_request
1658 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1659 SCIF_LOG_OBJECT_CONTROLLER,
1660 "Controller:0x%x State:0x%x invalid state to complete task mgmt.\n",
1662 sci_base_state_machine_get_state(
1663 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1666 return SCI_FAILURE_INVALID_STATE;
1670 SCI_STATUS scif_sas_controller_failed_state_start_io_handler(
1671 SCI_BASE_CONTROLLER_T * controller,
1672 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1673 SCI_BASE_REQUEST_T * io_request,
1678 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1679 SCIF_LOG_OBJECT_CONTROLLER,
1680 "Controller:0x%x State:0x%x invalid state to start IO.\n",
1682 sci_base_state_machine_get_state(
1683 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1689 #define scif_sas_controller_stopping_complete_io_handler \
1690 scif_sas_controller_ready_complete_io_handler
1691 #define scif_sas_controller_stopping_complete_task_handler \
1692 scif_sas_controller_ready_complete_task_handler
1693 #define scif_sas_controller_default_start_high_priority_io_handler \
1694 scif_sas_controller_default_start_io_handler
1695 #define scif_sas_controller_default_complete_high_priority_io_handler \
1696 scif_sas_controller_default_complete_io_handler
1697 #define scif_sas_controller_stopping_complete_high_priority_io_handler \
1698 scif_sas_controller_ready_complete_high_priority_io_handler
1701 SCI_BASE_CONTROLLER_STATE_HANDLER_T
1702 scif_sas_controller_state_handler_table[SCI_BASE_CONTROLLER_MAX_STATES] =
1704 // SCI_BASE_CONTROLLER_STATE_INITIAL
1706 scif_sas_controller_default_start_handler,
1707 scif_sas_controller_default_stop_handler,
1708 scif_sas_controller_default_reset_handler,
1709 scif_sas_controller_default_initialize_handler,
1710 scif_sas_controller_default_start_io_handler,
1711 scif_sas_controller_default_start_high_priority_io_handler,
1712 scif_sas_controller_default_complete_io_handler,
1713 scif_sas_controller_default_complete_high_priority_io_handler,
1714 scif_sas_controller_default_continue_io_handler,
1715 scif_sas_controller_default_start_task_handler,
1716 scif_sas_controller_default_complete_task_handler
1718 // SCI_BASE_CONTROLLER_STATE_RESET
1720 scif_sas_controller_default_start_handler,
1721 scif_sas_controller_default_stop_handler,
1722 scif_sas_controller_default_reset_handler,
1723 scif_sas_controller_reset_initialize_handler,
1724 scif_sas_controller_default_start_io_handler,
1725 scif_sas_controller_default_start_high_priority_io_handler,
1726 scif_sas_controller_default_complete_io_handler,
1727 scif_sas_controller_default_complete_high_priority_io_handler,
1728 scif_sas_controller_default_continue_io_handler,
1729 scif_sas_controller_default_start_task_handler,
1730 scif_sas_controller_default_complete_task_handler
1732 // SCI_BASE_CONTROLLER_STATE_INITIALIZING
1734 scif_sas_controller_default_start_handler,
1735 scif_sas_controller_default_stop_handler,
1736 scif_sas_controller_default_reset_handler,
1737 scif_sas_controller_default_initialize_handler,
1738 scif_sas_controller_default_start_io_handler,
1739 scif_sas_controller_default_start_high_priority_io_handler,
1740 scif_sas_controller_default_complete_io_handler,
1741 scif_sas_controller_default_complete_high_priority_io_handler,
1742 scif_sas_controller_default_continue_io_handler,
1743 scif_sas_controller_default_start_task_handler,
1744 scif_sas_controller_default_complete_task_handler
1746 // SCI_BASE_CONTROLLER_STATE_INITIALIZED
1748 scif_sas_controller_initialized_start_handler,
1749 scif_sas_controller_default_stop_handler,
1750 scif_sas_controller_default_reset_handler,
1751 scif_sas_controller_default_initialize_handler,
1752 scif_sas_controller_default_start_io_handler,
1753 scif_sas_controller_default_start_high_priority_io_handler,
1754 scif_sas_controller_default_complete_io_handler,
1755 scif_sas_controller_default_complete_high_priority_io_handler,
1756 scif_sas_controller_default_continue_io_handler,
1757 scif_sas_controller_default_start_task_handler,
1758 scif_sas_controller_default_complete_task_handler
1760 // SCI_BASE_CONTROLLER_STATE_STARTING
1762 scif_sas_controller_default_start_handler,
1763 scif_sas_controller_default_stop_handler,
1764 scif_sas_controller_default_reset_handler,
1765 scif_sas_controller_default_initialize_handler,
1766 scif_sas_controller_default_start_io_handler,
1767 scif_sas_controller_default_start_high_priority_io_handler,
1768 scif_sas_controller_default_complete_io_handler,
1769 scif_sas_controller_default_complete_high_priority_io_handler,
1770 scif_sas_controller_default_continue_io_handler,
1771 scif_sas_controller_default_start_task_handler,
1772 scif_sas_controller_default_complete_task_handler
1774 // SCI_BASE_CONTROLLER_STATE_READY
1776 scif_sas_controller_default_start_handler,
1777 scif_sas_controller_ready_stop_handler,
1778 scif_sas_controller_ready_reset_handler,
1779 scif_sas_controller_default_initialize_handler,
1780 scif_sas_controller_ready_start_io_handler,
1781 scif_sas_controller_ready_start_high_priority_io_handler,
1782 scif_sas_controller_ready_complete_io_handler,
1783 scif_sas_controller_ready_complete_high_priority_io_handler,
1784 scif_sas_controller_ready_continue_io_handler,
1785 scif_sas_controller_ready_start_task_handler,
1786 scif_sas_controller_ready_complete_task_handler
1788 // SCI_BASE_CONTROLLER_STATE_RESETTING
1790 scif_sas_controller_default_start_handler,
1791 scif_sas_controller_default_stop_handler,
1792 scif_sas_controller_default_reset_handler,
1793 scif_sas_controller_default_initialize_handler,
1794 scif_sas_controller_default_start_io_handler,
1795 scif_sas_controller_default_start_high_priority_io_handler,
1796 scif_sas_controller_default_complete_io_handler,
1797 scif_sas_controller_default_complete_high_priority_io_handler,
1798 scif_sas_controller_default_continue_io_handler,
1799 scif_sas_controller_default_start_task_handler,
1800 scif_sas_controller_default_complete_task_handler
1802 // SCI_BASE_CONTROLLER_STATE_STOPPING
1804 scif_sas_controller_default_start_handler,
1805 scif_sas_controller_default_stop_handler,
1806 scif_sas_controller_default_reset_handler,
1807 scif_sas_controller_default_initialize_handler,
1808 scif_sas_controller_default_start_io_handler,
1809 scif_sas_controller_stopping_start_high_priority_io_handler,
1810 scif_sas_controller_stopping_complete_io_handler,
1811 scif_sas_controller_stopping_complete_high_priority_io_handler,
1812 scif_sas_controller_default_continue_io_handler,
1813 scif_sas_controller_default_start_task_handler, /**@todo Allow in core?*/
1814 scif_sas_controller_stopping_complete_task_handler
1816 // SCI_BASE_CONTROLLER_STATE_STOPPED
1818 scif_sas_controller_default_start_handler,
1819 scif_sas_controller_default_stop_handler,
1820 scif_sas_controller_stopped_reset_handler,
1821 scif_sas_controller_default_initialize_handler,
1822 scif_sas_controller_default_start_io_handler,
1823 scif_sas_controller_default_start_high_priority_io_handler,
1824 scif_sas_controller_default_complete_io_handler,
1825 scif_sas_controller_default_complete_high_priority_io_handler,
1826 scif_sas_controller_default_continue_io_handler,
1827 scif_sas_controller_default_start_task_handler,
1828 scif_sas_controller_default_complete_task_handler
1830 // SCI_BASE_CONTROLLER_STATE_FAILED
1832 scif_sas_controller_default_start_handler,
1833 scif_sas_controller_default_stop_handler,
1834 scif_sas_controller_failed_reset_handler,
1835 scif_sas_controller_default_initialize_handler,
1836 scif_sas_controller_failed_state_start_io_handler,
1837 scif_sas_controller_failed_state_start_io_handler,
1838 scif_sas_controller_default_complete_io_handler,
1839 scif_sas_controller_default_complete_high_priority_io_handler,
1840 scif_sas_controller_default_continue_io_handler,
1841 scif_sas_controller_default_start_task_handler,
1842 scif_sas_controller_default_complete_task_handler