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 state handler routines for each
62 * of the controller states defined by the SCI_BASE_CONTROLLER state
66 #include <dev/isci/scil/sci_util.h>
67 #include <dev/isci/scil/scic_controller.h>
68 #include <dev/isci/scil/scic_port.h>
69 #include <dev/isci/scil/scic_remote_device.h>
70 #include <dev/isci/scil/scic_io_request.h>
72 #include <dev/isci/scil/scif_sas_controller.h>
73 #include <dev/isci/scil/scif_sas_remote_device.h>
74 #include <dev/isci/scil/scif_sas_logger.h>
75 #include <dev/isci/scil/scif_sas_smp_remote_device.h>
77 //******************************************************************************
78 //* P R I V A T E M E T H O D S
79 //******************************************************************************
82 * @brief This method simply executes the reset operation by entering
83 * the reset state and allowing the state to perform it's work.
85 * @param[in] fw_controller This parameter specifies the SAS framework
86 * controller for execute the reset.
88 * @return Indicate the status of the reset operation. Was it successful?
89 * @retval SCI_SUCCESS This value is returned if it was successfully reset.
92 SCI_STATUS scif_sas_controller_execute_reset(
93 SCIF_SAS_CONTROLLER_T * fw_controller
99 sci_base_object_get_logger(fw_controller),
100 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_CONTROLLER_RESET,
101 "scif_sas_controller_execute_reset(0x%x) enter\n",
105 //clean the timer to avoid timer leak.
106 scif_sas_controller_release_resource(fw_controller);
108 sci_base_state_machine_change_state(
109 &fw_controller->parent.state_machine,
110 SCI_BASE_CONTROLLER_STATE_RESETTING
113 // Retrieve the status for the operations performed during the entrance
114 // to the resetting state were executing successfully.
115 status = fw_controller->operation_status;
116 fw_controller->operation_status = SCI_SUCCESS;
122 * @brief This method checks that the memory descriptor list is valid
123 * and hasn't been corrupted in some way by the user.
125 * @param[in] fw_controller This parameter specifies the framework
126 * controller object for which to validation the MDL.
128 * @return This method returns a value indicating if the operation succeeded.
129 * @retval SCI_SUCCESS This value indicates that MDL is valid.
130 * @retval SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD This value indicates
131 * that some portion of the memory descriptor list is invalid.
134 SCI_STATUS scif_sas_controller_validate_mdl(
135 SCIF_SAS_CONTROLLER_T * fw_controller
138 BOOL is_mde_list_valid;
140 // Currently there is only a single MDE in the list.
141 is_mde_list_valid = sci_base_mde_is_valid(
142 &fw_controller->mdes[SCIF_SAS_MDE_INTERNAL_IO],
144 fw_controller->internal_request_entries *
145 scif_sas_internal_request_get_object_size(),
146 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
149 if (is_mde_list_valid == FALSE)
150 return SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD;
157 * @brief This method stops all the domains associated to this
160 * @param[in] fw_controller This parameter specifies the framework
161 * controller object for whose remote devices are to be stopped.
163 * @return This method returns a value indicating if the operation succeeded.
164 * @retval SCI_SUCCESS This value indicates that all the devices are stopped.
165 * @retval SCI_FAILURE This value indicates certain failure during the process
166 * of stopping remote devices.
169 SCI_STATUS scif_sas_controller_stop_domains(
170 SCIF_SAS_CONTROLLER_T * fw_controller
174 SCI_STATUS status = SCI_SUCCESS;
175 SCIF_SAS_DOMAIN_T * fw_domain;
178 sci_base_object_get_logger(fw_controller),
179 SCIF_LOG_OBJECT_CONTROLLER,
180 "scif_sas_controller_stop_domains(0x%x) enter\n",
184 for (index = 0; index < SCI_MAX_DOMAINS && status == SCI_SUCCESS; index++)
186 fw_domain = &fw_controller->domains[index];
188 //Change this domain to STOPPING state. All the remote devices will be
189 //stopped subsquentially.
190 if (fw_domain->parent.state_machine.current_state_id ==
191 SCI_BASE_DOMAIN_STATE_READY
192 || fw_domain->parent.state_machine.current_state_id ==
193 SCI_BASE_DOMAIN_STATE_DISCOVERING)
195 sci_base_state_machine_change_state(
196 &fw_domain->parent.state_machine, SCI_BASE_DOMAIN_STATE_STOPPING
206 * @brief This method continue to stop the controller after clear affiliation
209 * @param[in] fw_controller This parameter specifies the framework
210 * controller object to be stopped.
212 * @return This method returns a value indicating if the operation succeeded.
213 * @retval SCI_SUCCESS This value indicates the controller_stop succeeds.
214 * @retval SCI_FAILURE This value indicates certain failure during the process
215 * of stopping controller.
217 SCI_STATUS scif_sas_controller_continue_to_stop(
218 SCIF_SAS_CONTROLLER_T * fw_controller
224 sci_base_object_get_logger(fw_controller),
225 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_SHUTDOWN,
226 "scif_sas_controller_continue_to_stop (0x%x).\n",
230 //stop all the domains and their remote devices.
231 status = scif_sas_controller_stop_domains(fw_controller);
233 if (status == SCI_SUCCESS)
235 // Attempt to stop the core controller.
236 status = scic_controller_stop(fw_controller->core_object, 0);
238 if (status != SCI_SUCCESS)
241 sci_base_object_get_logger(fw_controller),
242 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_SHUTDOWN,
243 "Controller:0x%x Status:0x%x unable to stop controller.\n",
244 fw_controller, status
247 sci_base_state_machine_change_state(
248 &fw_controller->parent.state_machine,
249 SCI_BASE_CONTROLLER_STATE_FAILED
256 sci_base_object_get_logger(fw_controller),
257 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_SHUTDOWN,
258 "Controller:0x%x Status:0x%x unable to stop domains.\n",
259 fw_controller, status
262 sci_base_state_machine_change_state(
263 &fw_controller->parent.state_machine,
264 SCI_BASE_CONTROLLER_STATE_FAILED
272 //******************************************************************************
273 //* R E S E T H A N D L E R S
274 //******************************************************************************
277 * @brief This method provides RESET state specific handling for
278 * when a user attempts to initialize a controller. This is a legal
279 * state in which to attempt an initialize call.
281 * @param[in] controller This parameter specifies the controller object
282 * on which the user is attempting to perform an initialize
285 * @return This method returns an indication of whether the initialize
286 * operation succeeded.
287 * @retval SCI_SUCCESS This value when the initialization completes
291 SCI_STATUS scif_sas_controller_reset_initialize_handler(
292 SCI_BASE_CONTROLLER_T * controller
295 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
300 sci_base_object_get_logger(fw_controller),
301 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
302 "scif_sas_controller_reset_initialize_handler(0x%x) enter\n",
306 sci_base_state_machine_change_state(
307 &fw_controller->parent.state_machine,
308 SCI_BASE_CONTROLLER_STATE_INITIALIZING
311 scif_sas_controller_build_mdl(fw_controller);
313 // Perform any domain object initialization that is necessary.
314 for (index = 0; index < SCI_MAX_DOMAINS; index++)
315 scif_sas_domain_initialize(&fw_controller->domains[index]);
317 scif_cb_lock_associate(fw_controller, &fw_controller->hprq.lock);
319 // Attempt to initialize the core controller.
320 status = scic_controller_initialize(fw_controller->core_object);
321 if (status == SCI_SUCCESS)
323 sci_base_state_machine_change_state(
324 &fw_controller->parent.state_machine,
325 SCI_BASE_CONTROLLER_STATE_INITIALIZED
329 if (status != SCI_SUCCESS)
331 // Initialization failed, Release resources and do not change state
332 scif_sas_controller_release_resource(fw_controller);
335 sci_base_object_get_logger(fw_controller),
336 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
337 "Controller:0x%x Status:0x%x unable to successfully initialize.\n",
338 fw_controller, status
345 //******************************************************************************
346 //* I N I T I A L I Z E D H A N D L E R S
347 //******************************************************************************
350 * @brief This method provides INITIALIZED state specific handling for
351 * when a user attempts to start a controller.
353 * @param[in] controller This parameter specifies the controller object
354 * on which the user is attempting to perform a start
356 * @param[in] timeout This parameter specifies the timeout value (in
357 * milliseconds) to be utilized for this operation.
359 * @return This method returns an indication of whether the start operation
361 * @retval SCI_SUCCESS This value is returned when the start operation
362 * begins successfully.
365 SCI_STATUS scif_sas_controller_initialized_start_handler(
366 SCI_BASE_CONTROLLER_T * controller,
370 SCI_STATUS status = SCI_SUCCESS;
371 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
374 SCI_PHYSICAL_MEMORY_DESCRIPTOR_T internal_reqeust_mde =
375 fw_controller->mdes[SCIF_SAS_MDE_INTERNAL_IO];
377 void * internal_request_virtual_address = internal_reqeust_mde.virtual_address;
378 POINTER_UINT address = (POINTER_UINT)internal_request_virtual_address;
381 sci_base_object_get_logger(fw_controller),
382 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
383 "scif_sas_controller_initialized_start_handler(0x%x, 0x%x) enter\n",
387 sci_base_state_machine_change_state(
388 &fw_controller->parent.state_machine,
389 SCI_BASE_CONTROLLER_STATE_STARTING
392 status = scif_sas_controller_validate_mdl(fw_controller);
394 // initialization work for internal request path. It must be done before
396 if (status == SCI_SUCCESS)
398 // fill in the sci_pool for internal requests.
399 sci_pool_initialize(fw_controller->internal_request_memory_pool);
401 for (index = 0; index < fw_controller->internal_request_entries; index++)
403 sci_pool_put(fw_controller->internal_request_memory_pool, address);
405 address += scif_sas_internal_request_get_object_size();
408 // Using DPC for starting internal IOs, if yes, we need to intialize
410 scif_cb_start_internal_io_task_create(fw_controller);
413 if (status == SCI_SUCCESS)
415 // Kick-start the domain state machines and, by association, the
418 // This will ensure we get valid port objects supplied with link up
421 (index < SCI_MAX_DOMAINS) && (status == SCI_SUCCESS);
424 sci_base_state_machine_change_state(
425 &fw_controller->domains[index].parent.state_machine,
426 SCI_BASE_DOMAIN_STATE_STARTING
428 status = fw_controller->domains[index].operation.status;
432 // Validate that all the domain state machines began successfully.
433 if (status != SCI_SUCCESS)
436 sci_base_object_get_logger(fw_controller),
437 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
438 "Controller:0x%x Domain:0x%x Status:0x%x unable to start\n",
439 fw_controller, index, status
445 // Attempt to start the core controller.
446 status = scic_controller_start(fw_controller->core_object, timeout);
447 if (status != SCI_SUCCESS)
450 sci_base_object_get_logger(fw_controller),
451 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
452 "Controller:0x%x Status:0x%x unable to start controller.\n",
453 fw_controller, status
456 sci_base_state_machine_change_state(
457 &fw_controller->parent.state_machine,
458 SCI_BASE_CONTROLLER_STATE_FAILED
465 //******************************************************************************
466 //* R E A D Y H A N D L E R S
467 //******************************************************************************
470 * @brief This method provides READY state specific handling for
471 * when a user attempts to stop a controller.
473 * @param[in] controller This parameter specifies the controller object
474 * on which the user is attempting to perform a stop
476 * @param[in] timeout This parameter specifies the timeout value (in
477 * milliseconds) to be utilized for this operation.
479 * @return This method returns an indication of whether the stop operation
481 * @retval SCI_SUCCESS This value is returned when the stop operation
482 * begins successfully.
485 SCI_STATUS scif_sas_controller_ready_stop_handler(
486 SCI_BASE_CONTROLLER_T * controller,
490 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
493 sci_base_object_get_logger(fw_controller),
494 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
495 "scif_sas_controller_ready_stop_handler(0x%x, 0x%x) enter\n",
499 sci_base_state_machine_change_state(
500 &fw_controller->parent.state_machine,
501 SCI_BASE_CONTROLLER_STATE_STOPPING
504 if (fw_controller->user_parameters.sas.clear_affiliation_during_controller_stop)
506 fw_controller->current_domain_to_clear_affiliation = 0;
508 //clear affiliation first. After the last domain finishes clearing
509 //affiliation, it will call back to controller to continue to stop.
510 scif_sas_controller_clear_affiliation(fw_controller);
513 scif_sas_controller_continue_to_stop(fw_controller);
515 //Must return SUCCESS at this point.
520 * @brief This method provides READY state specific handling for
521 * when a user attempts to reset a controller.
523 * @param[in] controller This parameter specifies the controller object
524 * on which the user is attempting to perform a reset
527 * @return This method returns an indication of whether the reset operation
529 * @retval SCI_SUCCESS This value is returned when the reset operation
530 * completes successfully.
533 SCI_STATUS scif_sas_controller_ready_reset_handler(
534 SCI_BASE_CONTROLLER_T * controller
537 return scif_sas_controller_execute_reset((SCIF_SAS_CONTROLLER_T*)controller);
541 * @brief This method provides READY state specific handling for
542 * when a user attempts to start an IO request.
544 * @param[in] controller This parameter specifies the controller object
545 * on which the user is attempting to perform a start IO
547 * @param[in] remote_device This parameter specifies the remote deivce
548 * object on which the user is attempting to perform a start IO
550 * @param[in] io_request This parameter specifies the IO request to be
552 * @param[in] io_tag This parameter specifies the optional allocated
553 * IO tag. Please reference scif_controller_start_io() for
556 * @return This method returns an indication of whether the start IO
557 * operation succeeded.
558 * @retval SCI_SUCCESS This value is returned when the start IO operation
559 * begins successfully.
562 SCI_STATUS scif_sas_controller_ready_start_io_handler(
563 SCI_BASE_CONTROLLER_T * controller,
564 SCI_BASE_REMOTE_DEVICE_T * remote_device,
565 SCI_BASE_REQUEST_T * io_request,
570 SCIF_SAS_IO_REQUEST_T *fw_io = (SCIF_SAS_IO_REQUEST_T*)io_request;
571 SCIF_SAS_CONTROLLER_T *fw_controller = (SCIF_SAS_CONTROLLER_T*)controller;
572 SCIF_SAS_REMOTE_DEVICE_T *fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
576 sci_base_object_get_logger(fw_controller),
577 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
578 "scif_sas_controller_ready_start_io_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
579 controller, remote_device, io_request, io_tag
582 status = fw_device->domain->state_handlers->start_io_handler(
583 &fw_device->domain->parent, remote_device, io_request
586 // Check to see that the other objects in the framework allowed
587 // this IO to be started.
588 if (status == SCI_SUCCESS)
590 // Ask the core to start processing for this IO request.
591 status = (SCI_STATUS)scic_controller_start_io(
592 fw_controller->core_object,
593 fw_device->core_object,
594 fw_io->parent.core_object,
598 if (status == SCI_SUCCESS)
600 // We were able to start the core request. As a result,
601 // commit to starting the request for the framework by changing
602 // the state of the IO request.
603 sci_base_state_machine_change_state(
604 &io_request->state_machine, SCI_BASE_REQUEST_STATE_STARTED
609 // We were unable to start the core IO request. As a result,
610 // back out the start operation for the framework. It's easier to
611 // back out the framework start operation then to backout the core
612 // start IO operation.
613 fw_device->domain->state_handlers->complete_io_handler(
614 &fw_device->domain->parent, remote_device, io_request
617 // Invoke the IO completion handler. For most IOs, this does nothing
618 // since we are still in the constructed state. For NCQ, this will
619 // the return of the NCQ tag back to the remote device free pool.
620 fw_io->parent.state_handlers->complete_handler(io_request);
623 sci_base_object_get_logger(fw_controller),
624 SCIF_LOG_OBJECT_CONTROLLER,
625 "Controller:0x%x IORequest:0x%x Status:0x%x core IO start failed\n",
626 fw_controller, fw_io, status
633 sci_base_object_get_logger(fw_controller),
634 SCIF_LOG_OBJECT_CONTROLLER,
635 "Controller:0x%x IORequest:0x%x Status:0x%x IO start failed\n",
636 fw_controller, fw_io, status
644 * @brief This method provides READY state specific handling for
645 * when a user attempts to complete an IO request.
647 * @param[in] controller This parameter specifies the controller object
648 * on which the user is attempting to perform a complete IO
650 * @param[in] remote_device This parameter specifies the remote deivce
651 * object on which the user is attempting to perform a start IO
653 * @param[in] io_request This parameter specifies the IO request to be
656 * @return This method returns an indication of whether the complete IO
657 * operation succeeded.
658 * @retval SCI_SUCCESS This value is returned when the complete IO operation
659 * begins successfully.
662 SCI_STATUS scif_sas_controller_ready_complete_io_handler(
663 SCI_BASE_CONTROLLER_T * controller,
664 SCI_BASE_REMOTE_DEVICE_T * remote_device,
665 SCI_BASE_REQUEST_T * io_request
668 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
670 SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
672 SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
675 SCI_STATUS core_status;
678 sci_base_object_get_logger(fw_controller),
679 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
680 "scif_sas_controller_ready_complete_io_handler(0x%x, 0x%x, 0x%x) enter\n",
681 controller, remote_device, io_request
684 fw_io->parent.state_handlers->destruct_handler(&fw_io->parent.parent);
685 status = fw_device->domain->state_handlers->complete_io_handler(
686 &fw_device->domain->parent, remote_device, io_request
689 // Ask the core to finish processing for this IO request.
690 core_status = scic_controller_complete_io(
691 fw_controller->core_object,
692 fw_device->core_object,
693 fw_io->parent.core_object
696 if (status == SCI_SUCCESS)
697 status = core_status;
699 if (status != SCI_SUCCESS)
702 sci_base_object_get_logger(fw_controller),
703 SCIF_LOG_OBJECT_CONTROLLER,
704 "Controller:0x%x IORequest:0x%x Status:0x%x CoreStatus:0x%x "
705 "failure to complete IO\n",
706 fw_controller, fw_io, status, core_status
715 * @brief This method provides READY state specific handling for
716 * when a user attempts to complete a high priority IO request.
718 * @param[in] controller This parameter specifies the controller object
719 * on which the user is attempting to perform a complete IO
721 * @param[in] remote_device This parameter specifies the remote deivce
722 * object on which the user is attempting to perform a start IO
724 * @param[in] io_request This parameter specifies the IO request to be
727 * @return This method returns an indication of whether the complete IO
728 * operation succeeded.
729 * @retval SCI_SUCCESS This value is returned when the complete IO operation
730 * begins successfully.
733 SCI_STATUS scif_sas_controller_ready_complete_high_priority_io_handler(
734 SCI_BASE_CONTROLLER_T * controller,
735 SCI_BASE_REMOTE_DEVICE_T * remote_device,
736 SCI_BASE_REQUEST_T * io_request
739 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
741 SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
743 SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
745 SCI_IO_STATUS core_completion_status =
746 scic_request_get_sci_status(fw_io->parent.core_object);
748 U8 response_data[SCIF_SAS_RESPONSE_DATA_LENGTH];
751 SCI_STATUS core_status;
754 sci_base_object_get_logger(fw_controller),
755 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
756 "scif_sas_controller_ready_complete_high_priority_io_handler(0x%x, 0x%x, 0x%x) enter\n",
757 controller, remote_device, io_request
760 // In high priority path, we ask the core to finish IO request before framework.
762 // retrieve and save io response from core now.
763 memcpy(response_data,
764 scic_io_request_get_response_iu_address(fw_io->parent.core_object),
765 SCIF_SAS_RESPONSE_DATA_LENGTH
768 core_status = scic_controller_complete_io(
769 fw_controller->core_object,
770 fw_device->core_object,
771 fw_io->parent.core_object
774 fw_io->parent.state_handlers->destruct_handler(&fw_io->parent.parent);
775 status = fw_device->domain->state_handlers->complete_high_priority_io_handler(
776 &fw_device->domain->parent,
779 (void *)response_data,
780 core_completion_status
783 if (status == SCI_SUCCESS)
784 status = core_status;
786 if (status == SCI_SUCCESS)
788 //issue DPC to start next internal io in high prioriy queue.
789 if( !sci_pool_empty(fw_controller->hprq.pool) )
790 scif_cb_start_internal_io_task_schedule(
792 scif_sas_controller_start_high_priority_io,
799 sci_base_object_get_logger(fw_controller),
800 SCIF_LOG_OBJECT_CONTROLLER,
801 "Controller:0x%x IORequest:0x%x Status:0x%x CoreStatus:0x%x "
802 "failure to complete IO\n",
803 fw_controller, fw_io, status, core_status
811 * @brief This method provides READY state specific handling for
812 * when a user attempts to continue an IO request.
814 * @param[in] controller This parameter specifies the controller object
815 * on which the user is attempting to perform a continue IO
817 * @param[in] remote_device This parameter specifies the remote deivce
818 * object on which the user is attempting to perform a start IO
820 * @param[in] io_request This parameter specifies the IO request to be
823 * @return This method returns an indication of whether the continue IO
824 * operation succeeded.
825 * @retval SCI_SUCCESS This value is returned when the continue IO operation
826 * begins successfully.
829 SCI_STATUS scif_sas_controller_ready_continue_io_handler(
830 SCI_BASE_CONTROLLER_T * controller,
831 SCI_BASE_REMOTE_DEVICE_T * remote_device,
832 SCI_BASE_REQUEST_T * io_request
836 sci_base_object_get_logger(controller),
837 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
838 "scif_sas_controller_ready_continue_io_handler(0x%x, 0x%x, 0x%x) enter\n",
839 controller, remote_device, io_request
842 /// @todo Function unimplemented. fix return code handling.
847 * @brief This method provides READY state specific handling for
848 * when a user attempts to start a task request.
850 * @param[in] controller This parameter specifies the controller object
851 * on which the user is attempting to perform a start task
853 * @param[in] remote_device This parameter specifies the remote deivce
854 * object on which the user is attempting to perform a start
856 * @param[in] task_request This parameter specifies the task management
857 * request to be started.
858 * @param[in] io_tag This parameter specifies the optional allocated
859 * IO tag. Please reference scif_controller_start_task() for
862 * @return This method returns an indication of whether the start task
863 * operation succeeded.
864 * @retval SCI_SUCCESS This value is returned when the start task operation
865 * begins successfully.
868 SCI_STATUS scif_sas_controller_ready_start_task_handler(
869 SCI_BASE_CONTROLLER_T * controller,
870 SCI_BASE_REMOTE_DEVICE_T * remote_device,
871 SCI_BASE_REQUEST_T * task_request,
875 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
877 SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
879 SCIF_SAS_TASK_REQUEST_T * fw_task = (SCIF_SAS_TASK_REQUEST_T*)task_request;
883 sci_base_object_get_logger(fw_controller),
884 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_TASK_MANAGEMENT,
885 "scif_sas_controller_ready_start_task_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
886 controller, remote_device, task_request, io_tag
889 status = fw_device->domain->state_handlers->start_task_handler(
890 &fw_device->domain->parent, remote_device, task_request
893 if (status == SCI_SUCCESS)
895 if (scif_sas_task_request_get_function(fw_task)
896 == SCI_SAS_HARD_RESET)
898 // Go off to special target reset path. Don't start task to core.
899 scif_sas_remote_device_target_reset(
901 (SCIF_SAS_REQUEST_T *)fw_task
907 // Ask the core to start processing for this task request.
908 status = (SCI_STATUS)scic_controller_start_task(
909 fw_controller->core_object,
910 fw_device->core_object,
911 fw_task->parent.core_object,
915 if (status == SCI_SUCCESS)
917 // We were able to start the core request. As a result,
918 // commit to starting the request for the framework by changing
919 // the state of the task request.
920 fw_task->parent.state_handlers->start_handler(&fw_task->parent.parent);
924 // We were unable to start the core task request. As a result,
925 // back out the start operation for the framework. It's easier to
926 // back out the framework start operation then to backout the core
927 // start task operation.
928 fw_device->domain->state_handlers->complete_task_handler(
929 &fw_device->domain->parent, remote_device, task_request
932 if (status == SCI_SUCCESS)
935 sci_base_object_get_logger(fw_controller),
936 SCIF_LOG_OBJECT_CONTROLLER,
937 "Controller:0x%x TaskRequest:0x%x Status:0x%x core start failed\n",
938 fw_controller, fw_task, status
946 sci_base_object_get_logger(fw_controller),
947 SCIF_LOG_OBJECT_CONTROLLER,
948 "Controller:0x%x TaskRequest:0x%x Status:0x%x Task start failed\n",
949 fw_controller, fw_task, status
957 * @brief This method provides READY state specific handling for
958 * when a user attempts to complete a task request.
960 * @param[in] controller This parameter specifies the controller object
961 * on which the user is attempting to perform a complete task
963 * @param[in] remote_device This parameter specifies the remote deivce
964 * object on which the user is attempting to perform a start
966 * @param[in] task_request This parameter specifies the task management
967 * request to be started.
969 * @return This method returns an indication of whether the complete task
970 * operation succeeded.
971 * @retval SCI_SUCCESS This value is returned when the complete task operation
972 * begins successfully.
975 SCI_STATUS scif_sas_controller_ready_complete_task_handler(
976 SCI_BASE_CONTROLLER_T * controller,
977 SCI_BASE_REMOTE_DEVICE_T * remote_device,
978 SCI_BASE_REQUEST_T * task_request
981 SCIF_SAS_CONTROLLER_T *fw_controller = (SCIF_SAS_CONTROLLER_T*)controller;
982 SCIF_SAS_REMOTE_DEVICE_T *fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)remote_device;
983 SCIF_SAS_TASK_REQUEST_T *fw_task = (SCIF_SAS_TASK_REQUEST_T*)task_request;
985 SCI_STATUS core_status;
988 sci_base_object_get_logger(fw_controller),
989 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_TASK_MANAGEMENT,
990 "scif_sas_controller_ready_complete_task_handler(0x%x, 0x%x, 0x%x) enter\n",
991 controller, remote_device, task_request
994 status = fw_device->domain->state_handlers->complete_task_handler(
995 &fw_device->domain->parent, remote_device, task_request
998 if (scif_sas_task_request_get_function(fw_task)
999 == SCI_SAS_HARD_RESET)
1001 //No more things to do in the core, since this task is for Target Reset.
1005 fw_task->parent.state_handlers->destruct_handler(&fw_task->parent.parent);
1007 // Ask the core to finish processing for this task request.
1008 core_status = scic_controller_complete_task(
1009 fw_controller->core_object,
1010 fw_device->core_object,
1011 fw_task->parent.core_object
1014 if (status == SCI_SUCCESS)
1015 status = core_status;
1017 if (status != SCI_SUCCESS)
1020 sci_base_object_get_logger(fw_controller),
1021 SCIF_LOG_OBJECT_CONTROLLER,
1022 "Controller:0x%x TaskRequest:0x%x Status:0x%x CoreStatus:0x%x "
1023 "failed to complete\n",
1024 fw_controller, fw_task, status, core_status
1034 * @brief This method provides common handling for several states
1035 * when a user attempts to start an internal request.
1037 * @param[in] controller This parameter specifies the controller object
1038 * on which the user is attempting to perform a start IO
1040 * @param[in] remote_device This parameter specifies the remote deivce
1041 * object on which the user is attempting to perform a start IO
1043 * @param[in] io_request This parameter specifies the IO request to be
1045 * @param[in] io_tag This parameter specifies the optional allocated
1046 * IO tag. Please reference scif_controller_start_io() for
1049 * @return This method returns an indication of whether the start IO
1050 * operation succeeded.
1051 * @retval SCI_SUCCESS This value is returned when the start IO operation
1052 * begins successfully.
1055 SCI_STATUS scif_sas_controller_common_start_high_priority_io_handler(
1056 SCI_BASE_CONTROLLER_T * controller,
1057 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1058 SCI_BASE_REQUEST_T * io_request,
1063 SCIF_SAS_IO_REQUEST_T *fw_io = (SCIF_SAS_IO_REQUEST_T*)io_request;
1064 SCIF_SAS_CONTROLLER_T *fw_controller = (SCIF_SAS_CONTROLLER_T*)controller;
1065 SCIF_SAS_REMOTE_DEVICE_T *fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
1068 status = fw_device->domain->state_handlers->start_high_priority_io_handler(
1069 &fw_device->domain->parent, remote_device, io_request
1072 // Check to see that the other objects in the framework allowed
1073 // this IO to be started.
1074 if (status == SCI_SUCCESS)
1076 // Ask the core to start processing for this IO request.
1077 status = (SCI_STATUS)scic_controller_start_io(
1078 fw_controller->core_object,
1079 fw_device->core_object,
1080 fw_io->parent.core_object,
1084 if (status == SCI_SUCCESS)
1086 // We were able to start the core request. As a result,
1087 // commit to starting the request for the framework by changing
1088 // the state of the IO request.
1089 sci_base_state_machine_change_state(
1090 &io_request->state_machine, SCI_BASE_REQUEST_STATE_STARTED
1095 // We were unable to start the core IO request. As a result,
1096 // back out the start operation for the framework. It's easier to
1097 // back out the framework start operation then to backout the core
1098 // start IO operation.
1099 fw_device->domain->state_handlers->complete_io_handler(
1100 &fw_device->domain->parent, remote_device, io_request
1103 // Invoke the IO completion handler. For most IOs, this does nothing
1104 // since we are still in the constructed state. For NCQ, this will
1105 // the return of the NCQ tag back to the remote device free pool.
1106 fw_io->parent.state_handlers->complete_handler(io_request);
1109 sci_base_object_get_logger(fw_controller),
1110 SCIF_LOG_OBJECT_CONTROLLER,
1111 "Controller:0x%x IORequest:0x%x Status:0x%x core IO start failed\n",
1112 fw_controller, fw_io, status
1119 sci_base_object_get_logger(fw_controller),
1120 SCIF_LOG_OBJECT_CONTROLLER,
1121 "Controller:0x%x IORequest:0x%x Status:0x%x IO start failed\n",
1122 fw_controller, fw_io, status
1125 // Invoke the IO completion handler. For most IOs, this does nothing
1126 // since we are still in the constructed state. For NCQ, this will
1127 // the return of the NCQ tag back to the remote device free pool.
1128 fw_io->parent.state_handlers->complete_handler(io_request);
1132 if (fw_io->parent.is_internal && status != SCI_SUCCESS )
1134 SCIC_TRANSPORT_PROTOCOL protocol =
1135 scic_io_request_get_protocol(fw_io->parent.core_object);
1137 U8 retry_count = fw_io->retry_count;
1139 scif_sas_internal_io_request_destruct(
1140 fw_device->domain->controller,
1141 (SCIF_SAS_INTERNAL_IO_REQUEST_T *)fw_io
1144 if ( protocol == SCIC_SMP_PROTOCOL )
1146 if (fw_device->protocol_device.smp_device.smp_activity_timer != NULL)
1148 //destroy the smp_activity_timer
1149 scif_cb_timer_destroy (
1151 fw_device->protocol_device.smp_device.smp_activity_timer
1154 fw_device->protocol_device.smp_device.smp_activity_timer = NULL;
1157 //we should retry for finite times
1158 if ( retry_count < SCIF_SAS_IO_RETRY_LIMIT)
1160 //An internal smp request failed being started, most likely due to remote device
1161 //is not in ready state, for example, UPDATING_PORT_WIDTH state. In this case,
1162 //we should retry the IO.
1163 scif_sas_smp_remote_device_retry_internal_io(
1164 (SCIF_SAS_REMOTE_DEVICE_T *)remote_device,
1166 SMP_REQUEST_RETRY_WAIT_DURATION
1177 * @brief This method provides READY state specific handling for
1178 * when a user attempts to start an internal request. If the high
1179 * priority IO is also internal, this method will schedule its timer.
1181 * @param[in] controller This parameter specifies the controller object
1182 * on which the user is attempting to perform a start IO
1184 * @param[in] remote_device This parameter specifies the remote deivce
1185 * object on which the user is attempting to perform a start IO
1187 * @param[in] io_request This parameter specifies the IO request to be
1189 * @param[in] io_tag This parameter specifies the optional allocated
1190 * IO tag. Please reference scif_controller_start_io() for
1193 * @return This method returns an indication of whether the start IO
1194 * operation succeeded.
1195 * @retval SCI_SUCCESS This value is returned when the start IO operation
1196 * begins successfully.
1199 SCI_STATUS scif_sas_controller_ready_start_high_priority_io_handler(
1200 SCI_BASE_CONTROLLER_T * controller,
1201 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1202 SCI_BASE_REQUEST_T * io_request,
1207 SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T *)io_request;
1210 sci_base_object_get_logger(controller),
1211 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
1212 "scif_sas_controller_ready_start_high_priority_io_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
1213 controller, remote_device, io_request, io_tag
1216 status = scif_sas_controller_common_start_high_priority_io_handler(
1217 controller, remote_device, io_request, io_tag);
1219 if (status == SCI_SUCCESS)
1221 //External io could also be put in high priority queue. i.e. the
1222 //smp request for EA Target Reset.
1223 if (fw_io->parent.is_internal)
1225 SCIF_SAS_INTERNAL_IO_REQUEST_T * fw_internal_io =
1226 (SCIF_SAS_INTERNAL_IO_REQUEST_T *)fw_io;
1228 //start the timer for internal io
1229 scif_cb_timer_start(
1230 (SCI_CONTROLLER_HANDLE_T)controller,
1231 fw_internal_io->internal_io_timer,
1232 SCIF_SAS_INTERNAL_REQUEST_TIMEOUT
1238 //If failed to start, most likely the device or domain is not in
1239 //correct state, and the IO has been cleaned up in controller's start
1240 //high priority IO handler. We should just continue to start the next
1241 //IO in the HP queue.
1244 sci_base_object_get_logger(controller),
1245 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
1246 "scif_controller_start_high_priority_io(0x%x, 0x%x), starting io failed\n",
1255 //******************************************************************************
1256 //* S T O P P I N G H A N D L E R S
1257 //******************************************************************************
1259 * @brief This method provides STOPPING state specific handling for
1260 * when a user attempts to start an internal request. Note that we don't
1261 * start the timer for internal IO during controller stopping state.
1263 * @param[in] controller This parameter specifies the controller object
1264 * on which the user is attempting to perform a start IO
1266 * @param[in] remote_device This parameter specifies the remote deivce
1267 * object on which the user is attempting to perform a start IO
1269 * @param[in] io_request This parameter specifies the IO request to be
1271 * @param[in] io_tag This parameter specifies the optional allocated
1272 * IO tag. Please reference scif_controller_start_io() for
1275 * @return This method returns an indication of whether the start IO
1276 * operation succeeded.
1277 * @retval SCI_SUCCESS This value is returned when the start IO operation
1278 * begins successfully.
1281 SCI_STATUS scif_sas_controller_stopping_start_high_priority_io_handler(
1282 SCI_BASE_CONTROLLER_T * controller,
1283 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1284 SCI_BASE_REQUEST_T * io_request,
1289 sci_base_object_get_logger(controller),
1290 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_IO_REQUEST,
1291 "scif_sas_controller_stopping_start_high_priority_io_handler(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
1292 controller, remote_device, io_request, io_tag
1295 return scif_sas_controller_common_start_high_priority_io_handler(
1296 controller, remote_device, io_request, io_tag);
1300 //******************************************************************************
1301 //* S T O P P E D H A N D L E R S
1302 //******************************************************************************
1305 * @brief This method provides STOPPED state specific handling for
1306 * when a user attempts to reset a controller.
1308 * @param[in] controller This parameter specifies the controller object
1309 * on which the user is attempting to perform a reset
1312 * @return This method returns an indication of whether the reset operation
1314 * @retval SCI_SUCCESS This value is returned when the reset operation
1315 * completes successfully.
1318 SCI_STATUS scif_sas_controller_stopped_reset_handler(
1319 SCI_BASE_CONTROLLER_T * controller
1322 return scif_sas_controller_execute_reset((SCIF_SAS_CONTROLLER_T*)controller);
1326 //******************************************************************************
1327 //* F A I L E D H A N D L E R S
1328 //******************************************************************************
1331 * @brief This method provides FAILED state specific handling for
1332 * when a user attempts to reset a controller.
1334 * @param[in] controller This parameter specifies the controller object
1335 * on which the user is attempting to perform a reset
1338 * @return This method returns an indication of whether the reset operation
1340 * @retval SCI_SUCCESS This value is returned when the reset operation
1341 * completes successfully.
1344 SCI_STATUS scif_sas_controller_failed_reset_handler(
1345 SCI_BASE_CONTROLLER_T * controller
1348 return scif_sas_controller_execute_reset((SCIF_SAS_CONTROLLER_T*)controller);
1351 //******************************************************************************
1352 //* D E F A U L T H A N D L E R S
1353 //******************************************************************************
1356 * @brief This method provides default handling (i.e. returns an error)
1357 * when a user attempts to start a controller and a start operation
1360 * @param[in] controller This parameter specifies the controller object
1361 * on which the user is attempting to perform a start operation.
1362 * @param[in] timeout This parameter specifies the timeout value (in
1363 * milliseconds) to be utilized for this operation.
1365 * @return This method returns an indication that start operations are not
1367 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1370 SCI_STATUS scif_sas_controller_default_start_handler(
1371 SCI_BASE_CONTROLLER_T * controller,
1376 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1377 SCIF_LOG_OBJECT_CONTROLLER,
1378 "Controller:0x%x State:0x%x invalid state to start controller.\n",
1380 sci_base_state_machine_get_state(
1381 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1384 return SCI_FAILURE_INVALID_STATE;
1388 * @brief This method provides default handling (i.e. returns an error)
1389 * when a user attempts to stop a controller and a stop operation
1392 * @param[in] controller This parameter specifies the controller object
1393 * on which the user is attempting to perform a stop operation.
1394 * @param[in] timeout This parameter specifies the timeout value (in
1395 * milliseconds) to be utilized for this operation.
1397 * @return This method returns an indication that stop operations are not
1399 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1402 SCI_STATUS scif_sas_controller_default_stop_handler(
1403 SCI_BASE_CONTROLLER_T * controller,
1408 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1409 SCIF_LOG_OBJECT_CONTROLLER,
1410 "Controller:0x%x State:0x%x invalid state to stop controller.\n",
1412 sci_base_state_machine_get_state(
1413 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1416 return SCI_FAILURE_INVALID_STATE;
1420 * @brief This method provides default handling (i.e. returns an error)
1421 * when a user attempts to reset a controller and a reset operation
1424 * @param[in] controller This parameter specifies the controller object
1425 * on which the user is attempting to perform a reset operation.
1427 * @return This method returns an indication that reset operations are not
1429 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1432 SCI_STATUS scif_sas_controller_default_reset_handler(
1433 SCI_BASE_CONTROLLER_T * controller
1437 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1438 SCIF_LOG_OBJECT_CONTROLLER,
1439 "Controller:0x%x State:0x%x invalid state to reset controller.\n",
1441 sci_base_state_machine_get_state(
1442 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1445 return SCI_FAILURE_INVALID_STATE;
1449 * @brief This method provides default handling (i.e. returns an error)
1450 * when a user attempts to initialize a controller and an initialize
1451 * operation is not allowed.
1453 * @param[in] controller This parameter specifies the controller object
1454 * on which the user is attempting to perform an initialize
1457 * @return This method returns an indication that initialize operations
1459 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1462 SCI_STATUS scif_sas_controller_default_initialize_handler(
1463 SCI_BASE_CONTROLLER_T * controller
1467 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1468 SCIF_LOG_OBJECT_CONTROLLER,
1469 "Controller:0x%x State:0x%x invalid state to initialize controller.\n",
1471 sci_base_state_machine_get_state(
1472 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1475 return SCI_FAILURE_INVALID_STATE;
1479 * @brief This method provides default handling (i.e. returns an error)
1480 * when a user attempts to start an IO on a controller and a start
1481 * IO operation is not allowed.
1483 * @param[in] controller This parameter specifies the controller object
1484 * on which the user is attempting to perform a start IO
1486 * @param[in] remote_device This parameter specifies the remote deivce
1487 * object on which the user is attempting to perform a start IO
1489 * @param[in] io_request This parameter specifies the IO request to be
1491 * @param[in] io_tag This parameter specifies the optional allocated
1492 * IO tag. Please reference scif_controller_start_io() for
1495 * @return This method returns an indication that start IO operations
1497 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1500 SCI_STATUS scif_sas_controller_default_start_io_handler(
1501 SCI_BASE_CONTROLLER_T * controller,
1502 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1503 SCI_BASE_REQUEST_T * io_request,
1508 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1509 SCIF_LOG_OBJECT_CONTROLLER,
1510 "Controller:0x%x State:0x%x invalid state to start IO.\n",
1512 sci_base_state_machine_get_state(
1513 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1516 return SCI_FAILURE_INVALID_STATE;
1520 * @brief This method provides default handling (i.e. returns an error)
1521 * when a user attempts to complete an IO on a controller and a
1522 * complete IO operation is not allowed.
1524 * @param[in] controller This parameter specifies the controller object
1525 * on which the user is attempting to perform a complete IO
1527 * @param[in] remote_device This parameter specifies the remote deivce
1528 * object on which the user is attempting to perform a start IO
1530 * @param[in] io_request This parameter specifies the IO request to be
1533 * @return This method returns an indication that complete IO operations
1535 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1538 SCI_STATUS scif_sas_controller_default_complete_io_handler(
1539 SCI_BASE_CONTROLLER_T * controller,
1540 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1541 SCI_BASE_REQUEST_T * io_request
1545 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1546 SCIF_LOG_OBJECT_CONTROLLER,
1547 "Controller:0x%x State:0x%x invalid state to complete IO.\n",
1549 sci_base_state_machine_get_state(
1550 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1553 return SCI_FAILURE_INVALID_STATE;
1557 * @brief This method provides default handling (i.e. returns an error)
1558 * when a user attempts to continue an IO on a controller and a
1559 * continue IO operation is not allowed.
1561 * @param[in] controller This parameter specifies the controller object
1562 * on which the user is attempting to perform a continue IO
1564 * @param[in] remote_device This parameter specifies the remote deivce
1565 * object on which the user is attempting to perform a start IO
1567 * @param[in] io_request This parameter specifies the IO request to be
1570 * @return This method returns an indication that continue IO operations
1572 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1575 SCI_STATUS scif_sas_controller_default_continue_io_handler(
1576 SCI_BASE_CONTROLLER_T * controller,
1577 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1578 SCI_BASE_REQUEST_T * io_request
1582 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1583 SCIF_LOG_OBJECT_CONTROLLER,
1584 "Controller:0x%x State:0x%x invalid state to continue IO.\n",
1586 sci_base_state_machine_get_state(
1587 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1590 return SCI_FAILURE_INVALID_STATE;
1594 * @brief This method provides default handling (i.e. returns an error)
1595 * when a user attempts to start a task on a controller and a start
1596 * task operation is not allowed.
1598 * @param[in] controller This parameter specifies the controller object
1599 * on which the user is attempting to perform a start task
1601 * @param[in] remote_device This parameter specifies the remote deivce
1602 * object on which the user is attempting to perform a start
1604 * @param[in] task_request This parameter specifies the task management
1605 * request to be started.
1606 * @param[in] io_tag This parameter specifies the optional allocated
1607 * IO tag. Please reference scif_controller_start_task() for
1610 * @return This method returns an indication that start task operations
1612 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1615 SCI_STATUS scif_sas_controller_default_start_task_handler(
1616 SCI_BASE_CONTROLLER_T * controller,
1617 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1618 SCI_BASE_REQUEST_T * task_request,
1623 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1624 SCIF_LOG_OBJECT_CONTROLLER,
1625 "Controller:0x%x State:0x%x invalid state to start task mgmt.\n",
1627 sci_base_state_machine_get_state(
1628 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1631 return SCI_FAILURE_INVALID_STATE;
1635 * @brief This method provides default handling (i.e. returns an error)
1636 * when a user attempts to complete a task on a controller and a
1637 * complete task operation is not allowed.
1639 * @param[in] controller This parameter specifies the controller object
1640 * on which the user is attempting to perform a complete task
1642 * @param[in] remote_device This parameter specifies the remote deivce
1643 * object on which the user is attempting to perform a start
1645 * @param[in] task_request This parameter specifies the task management
1646 * request to be started.
1648 * @return This method returns an indication that complete task operations
1650 * @retval SCI_FAILURE_INVALID_STATE This value is always returned.
1653 SCI_STATUS scif_sas_controller_default_complete_task_handler(
1654 SCI_BASE_CONTROLLER_T * controller,
1655 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1656 SCI_BASE_REQUEST_T * task_request
1660 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1661 SCIF_LOG_OBJECT_CONTROLLER,
1662 "Controller:0x%x State:0x%x invalid state to complete task mgmt.\n",
1664 sci_base_state_machine_get_state(
1665 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1668 return SCI_FAILURE_INVALID_STATE;
1672 SCI_STATUS scif_sas_controller_failed_state_start_io_handler(
1673 SCI_BASE_CONTROLLER_T * controller,
1674 SCI_BASE_REMOTE_DEVICE_T * remote_device,
1675 SCI_BASE_REQUEST_T * io_request,
1680 sci_base_object_get_logger((SCIF_SAS_CONTROLLER_T *)controller),
1681 SCIF_LOG_OBJECT_CONTROLLER,
1682 "Controller:0x%x State:0x%x invalid state to start IO.\n",
1684 sci_base_state_machine_get_state(
1685 &((SCIF_SAS_CONTROLLER_T *)controller)->parent.state_machine)
1691 #define scif_sas_controller_stopping_complete_io_handler \
1692 scif_sas_controller_ready_complete_io_handler
1693 #define scif_sas_controller_stopping_complete_task_handler \
1694 scif_sas_controller_ready_complete_task_handler
1695 #define scif_sas_controller_default_start_high_priority_io_handler \
1696 scif_sas_controller_default_start_io_handler
1697 #define scif_sas_controller_default_complete_high_priority_io_handler \
1698 scif_sas_controller_default_complete_io_handler
1699 #define scif_sas_controller_stopping_complete_high_priority_io_handler \
1700 scif_sas_controller_ready_complete_high_priority_io_handler
1703 SCI_BASE_CONTROLLER_STATE_HANDLER_T
1704 scif_sas_controller_state_handler_table[SCI_BASE_CONTROLLER_MAX_STATES] =
1706 // SCI_BASE_CONTROLLER_STATE_INITIAL
1708 scif_sas_controller_default_start_handler,
1709 scif_sas_controller_default_stop_handler,
1710 scif_sas_controller_default_reset_handler,
1711 scif_sas_controller_default_initialize_handler,
1712 scif_sas_controller_default_start_io_handler,
1713 scif_sas_controller_default_start_high_priority_io_handler,
1714 scif_sas_controller_default_complete_io_handler,
1715 scif_sas_controller_default_complete_high_priority_io_handler,
1716 scif_sas_controller_default_continue_io_handler,
1717 scif_sas_controller_default_start_task_handler,
1718 scif_sas_controller_default_complete_task_handler
1720 // SCI_BASE_CONTROLLER_STATE_RESET
1722 scif_sas_controller_default_start_handler,
1723 scif_sas_controller_default_stop_handler,
1724 scif_sas_controller_default_reset_handler,
1725 scif_sas_controller_reset_initialize_handler,
1726 scif_sas_controller_default_start_io_handler,
1727 scif_sas_controller_default_start_high_priority_io_handler,
1728 scif_sas_controller_default_complete_io_handler,
1729 scif_sas_controller_default_complete_high_priority_io_handler,
1730 scif_sas_controller_default_continue_io_handler,
1731 scif_sas_controller_default_start_task_handler,
1732 scif_sas_controller_default_complete_task_handler
1734 // SCI_BASE_CONTROLLER_STATE_INITIALIZING
1736 scif_sas_controller_default_start_handler,
1737 scif_sas_controller_default_stop_handler,
1738 scif_sas_controller_default_reset_handler,
1739 scif_sas_controller_default_initialize_handler,
1740 scif_sas_controller_default_start_io_handler,
1741 scif_sas_controller_default_start_high_priority_io_handler,
1742 scif_sas_controller_default_complete_io_handler,
1743 scif_sas_controller_default_complete_high_priority_io_handler,
1744 scif_sas_controller_default_continue_io_handler,
1745 scif_sas_controller_default_start_task_handler,
1746 scif_sas_controller_default_complete_task_handler
1748 // SCI_BASE_CONTROLLER_STATE_INITIALIZED
1750 scif_sas_controller_initialized_start_handler,
1751 scif_sas_controller_default_stop_handler,
1752 scif_sas_controller_default_reset_handler,
1753 scif_sas_controller_default_initialize_handler,
1754 scif_sas_controller_default_start_io_handler,
1755 scif_sas_controller_default_start_high_priority_io_handler,
1756 scif_sas_controller_default_complete_io_handler,
1757 scif_sas_controller_default_complete_high_priority_io_handler,
1758 scif_sas_controller_default_continue_io_handler,
1759 scif_sas_controller_default_start_task_handler,
1760 scif_sas_controller_default_complete_task_handler
1762 // SCI_BASE_CONTROLLER_STATE_STARTING
1764 scif_sas_controller_default_start_handler,
1765 scif_sas_controller_default_stop_handler,
1766 scif_sas_controller_default_reset_handler,
1767 scif_sas_controller_default_initialize_handler,
1768 scif_sas_controller_default_start_io_handler,
1769 scif_sas_controller_default_start_high_priority_io_handler,
1770 scif_sas_controller_default_complete_io_handler,
1771 scif_sas_controller_default_complete_high_priority_io_handler,
1772 scif_sas_controller_default_continue_io_handler,
1773 scif_sas_controller_default_start_task_handler,
1774 scif_sas_controller_default_complete_task_handler
1776 // SCI_BASE_CONTROLLER_STATE_READY
1778 scif_sas_controller_default_start_handler,
1779 scif_sas_controller_ready_stop_handler,
1780 scif_sas_controller_ready_reset_handler,
1781 scif_sas_controller_default_initialize_handler,
1782 scif_sas_controller_ready_start_io_handler,
1783 scif_sas_controller_ready_start_high_priority_io_handler,
1784 scif_sas_controller_ready_complete_io_handler,
1785 scif_sas_controller_ready_complete_high_priority_io_handler,
1786 scif_sas_controller_ready_continue_io_handler,
1787 scif_sas_controller_ready_start_task_handler,
1788 scif_sas_controller_ready_complete_task_handler
1790 // SCI_BASE_CONTROLLER_STATE_RESETTING
1792 scif_sas_controller_default_start_handler,
1793 scif_sas_controller_default_stop_handler,
1794 scif_sas_controller_default_reset_handler,
1795 scif_sas_controller_default_initialize_handler,
1796 scif_sas_controller_default_start_io_handler,
1797 scif_sas_controller_default_start_high_priority_io_handler,
1798 scif_sas_controller_default_complete_io_handler,
1799 scif_sas_controller_default_complete_high_priority_io_handler,
1800 scif_sas_controller_default_continue_io_handler,
1801 scif_sas_controller_default_start_task_handler,
1802 scif_sas_controller_default_complete_task_handler
1804 // SCI_BASE_CONTROLLER_STATE_STOPPING
1806 scif_sas_controller_default_start_handler,
1807 scif_sas_controller_default_stop_handler,
1808 scif_sas_controller_default_reset_handler,
1809 scif_sas_controller_default_initialize_handler,
1810 scif_sas_controller_default_start_io_handler,
1811 scif_sas_controller_stopping_start_high_priority_io_handler,
1812 scif_sas_controller_stopping_complete_io_handler,
1813 scif_sas_controller_stopping_complete_high_priority_io_handler,
1814 scif_sas_controller_default_continue_io_handler,
1815 scif_sas_controller_default_start_task_handler, /**@todo Allow in core?*/
1816 scif_sas_controller_stopping_complete_task_handler
1818 // SCI_BASE_CONTROLLER_STATE_STOPPED
1820 scif_sas_controller_default_start_handler,
1821 scif_sas_controller_default_stop_handler,
1822 scif_sas_controller_stopped_reset_handler,
1823 scif_sas_controller_default_initialize_handler,
1824 scif_sas_controller_default_start_io_handler,
1825 scif_sas_controller_default_start_high_priority_io_handler,
1826 scif_sas_controller_default_complete_io_handler,
1827 scif_sas_controller_default_complete_high_priority_io_handler,
1828 scif_sas_controller_default_continue_io_handler,
1829 scif_sas_controller_default_start_task_handler,
1830 scif_sas_controller_default_complete_task_handler
1832 // SCI_BASE_CONTROLLER_STATE_FAILED
1834 scif_sas_controller_default_start_handler,
1835 scif_sas_controller_default_stop_handler,
1836 scif_sas_controller_failed_reset_handler,
1837 scif_sas_controller_default_initialize_handler,
1838 scif_sas_controller_failed_state_start_io_handler,
1839 scif_sas_controller_failed_state_start_io_handler,
1840 scif_sas_controller_default_complete_io_handler,
1841 scif_sas_controller_default_complete_high_priority_io_handler,
1842 scif_sas_controller_default_continue_io_handler,
1843 scif_sas_controller_default_start_task_handler,
1844 scif_sas_controller_default_complete_task_handler