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 the methods and state machines for SATA/STP
63 #include <dev/isci/scil/intel_sat.h>
64 #include <dev/isci/scil/intel_ata.h>
65 #include <dev/isci/scil/intel_sata.h>
66 #include <dev/isci/scil/scic_remote_device.h>
67 #include <dev/isci/scil/scic_user_callback.h>
68 #include <dev/isci/scil/scic_sds_logger.h>
69 #include <dev/isci/scil/scic_sds_controller.h>
70 #include <dev/isci/scil/scic_sds_port.h>
71 #include <dev/isci/scil/scic_sds_remote_device.h>
72 #include <dev/isci/scil/scic_sds_request.h>
73 #include <dev/isci/scil/scu_event_codes.h>
74 #include <dev/isci/scil/scu_completion_codes.h>
75 #include <dev/isci/scil/sci_base_state.h>
78 * This method will perform the STP request completion processing common
79 * to IO requests and task requests of all types
81 * @param[in] device This parameter specifies the device for which the
82 * request is being completed.
83 * @param[in] request This parameter specifies the request being completed.
85 * @return This method returns an indication as to whether the request
86 * processing completed successfully.
89 SCI_STATUS scic_sds_stp_remote_device_complete_request(
90 SCI_BASE_REMOTE_DEVICE_T * device,
91 SCI_BASE_REQUEST_T * request
94 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
95 SCIC_SDS_REQUEST_T * the_request = (SCIC_SDS_REQUEST_T *)request;
98 status = scic_sds_io_request_complete(the_request);
100 if (status == SCI_SUCCESS)
102 status = scic_sds_port_complete_io(
103 this_device->owning_port, this_device, the_request
106 if (status == SCI_SUCCESS)
108 scic_sds_remote_device_decrement_request_count(this_device);
109 if (the_request->sci_status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED)
111 //This request causes hardware error, device needs to be Lun Reset.
112 //So here we force the state machine to IDLE state so the rest IOs
113 //can reach RNC state handler, these IOs will be completed by RNC with
114 //status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE".
115 sci_base_state_machine_change_state(
116 &this_device->ready_substate_machine,
117 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET
120 else if (scic_sds_remote_device_get_request_count(this_device) == 0)
122 sci_base_state_machine_change_state(
123 &this_device->ready_substate_machine,
124 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
130 if (status != SCI_SUCCESS)
133 sci_base_object_get_logger(this_device),
134 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
135 "Port:0x%x Device:0x%x Request:0x%x Status:0x%x could not complete\n",
136 this_device->owning_port, this_device, the_request, status
143 //*****************************************************************************
144 //* STP REMOTE DEVICE READY COMMON SUBSTATE HANDLERS
145 //*****************************************************************************
148 * This is the READY NCQ substate handler to start task management request. In this
149 * routine, we suspend and resume the RNC.
151 * @param[in] device The target device a task management request towards to.
152 * @param[in] request The task request.
154 * @return SCI_STATUS Always return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS status
155 * to let controller_start_task_handler know that the controller can't post TC for
156 * task request yet, instead, when RNC gets resumed, a controller_continue_task
157 * callback will be called.
160 SCI_STATUS scic_sds_stp_remote_device_ready_substate_start_request_handler(
161 SCI_BASE_REMOTE_DEVICE_T * device,
162 SCI_BASE_REQUEST_T * request
166 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
167 SCIC_SDS_REQUEST_T * this_request = (SCIC_SDS_REQUEST_T *)request;
169 // Will the port allow the io request to start?
170 status = this_device->owning_port->state_handlers->start_io_handler(
171 this_device->owning_port,
176 if (SCI_SUCCESS == status)
179 scic_sds_remote_node_context_start_task(this_device->rnc, this_request);
181 if (SCI_SUCCESS == status)
183 status = this_request->state_handlers->parent.start_handler(request);
186 if (status == SCI_SUCCESS)
188 /// @note If the remote device state is not IDLE this will replace
189 /// the request that probably resulted in the task management
191 this_device->working_request = this_request;
193 sci_base_state_machine_change_state(
194 &this_device->ready_substate_machine,
195 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD
198 //The remote node context must cleanup the TCi to NCQ mapping table.
199 //The only way to do this correctly is to either write to the TLCR
200 //register or to invalidate and repost the RNC. In either case the
201 //remote node context state machine will take the correct action when
202 //the remote node context is suspended and later resumed.
203 scic_sds_remote_node_context_suspend(
204 this_device->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
206 scic_sds_remote_node_context_resume(
208 (SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK)
209 scic_sds_remote_device_continue_request,
213 scic_sds_remote_device_start_request(this_device,this_request,status);
215 //We need to let the controller start request handler know that it can't
216 //post TC yet. We will provide a callback function to post TC when RNC gets
218 return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS;
224 //*****************************************************************************
225 //* STP REMOTE DEVICE READY IDLE SUBSTATE HANDLERS
226 //*****************************************************************************
229 * This method will handle the start io operation for a sata device that is in
230 * the command idle state.
231 * - Evalute the type of IO request to be started
232 * - If its an NCQ request change to NCQ substate
233 * - If its any other command change to the CMD substate
235 * @note If this is a softreset we may want to have a different substate.
238 * @param [in] request
243 SCI_STATUS scic_sds_stp_remote_device_ready_idle_substate_start_io_handler(
244 SCI_BASE_REMOTE_DEVICE_T * device,
245 SCI_BASE_REQUEST_T * request
249 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
250 SCIC_SDS_REQUEST_T * io_request = (SCIC_SDS_REQUEST_T *)request;
253 // Will the port allow the io request to start?
254 status = this_device->owning_port->state_handlers->start_io_handler(
255 this_device->owning_port,
260 if (status == SCI_SUCCESS)
263 scic_sds_remote_node_context_start_io(this_device->rnc, io_request);
265 if (status == SCI_SUCCESS)
267 status = io_request->state_handlers->parent.start_handler(request);
270 if (status == SCI_SUCCESS)
272 if (io_request->sat_protocol == SAT_PROTOCOL_FPDMA)
274 sci_base_state_machine_change_state(
275 &this_device->ready_substate_machine,
276 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ
281 this_device->working_request = io_request;
283 sci_base_state_machine_change_state(
284 &this_device->ready_substate_machine,
285 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD
290 scic_sds_remote_device_start_request(this_device, io_request, status);
298 * This method will handle the event for a sata device that is in
299 * the idle state. We pick up suspension events to handle specifically
300 * to this state. We resume the RNC right away.
302 * @param [in] device The device received event.
303 * @param [in] event_code The event code.
308 SCI_STATUS scic_sds_stp_remote_device_ready_idle_substate_event_handler(
309 SCIC_SDS_REMOTE_DEVICE_T * this_device,
315 status = scic_sds_remote_device_general_event_handler(this_device, event_code);
317 if (status == SCI_SUCCESS)
319 if ((scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX
320 || scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX)
321 && (this_device->rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY))
323 status = scic_sds_remote_node_context_resume(
324 this_device->rnc, NULL, NULL);
332 //*****************************************************************************
333 //* STP REMOTE DEVICE READY NCQ SUBSTATE HANDLERS
334 //*****************************************************************************
340 SCI_STATUS scic_sds_stp_remote_device_ready_ncq_substate_start_io_handler(
341 SCI_BASE_REMOTE_DEVICE_T * device,
342 SCI_BASE_REQUEST_T * request
346 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
347 SCIC_SDS_REQUEST_T * io_request = (SCIC_SDS_REQUEST_T *)request;
349 if (io_request->sat_protocol == SAT_PROTOCOL_FPDMA)
351 status = this_device->owning_port->state_handlers->start_io_handler(
352 this_device->owning_port,
357 if (status == SCI_SUCCESS)
359 status = scic_sds_remote_node_context_start_io(this_device->rnc, io_request);
361 if (status == SCI_SUCCESS)
363 status = io_request->state_handlers->parent.start_handler(request);
366 scic_sds_remote_device_start_request(this_device, io_request, status);
371 status = SCI_FAILURE_INVALID_STATE;
378 * This method will handle events received while the STP device is in the
379 * ready command substate.
381 * @param [in] this_device This is the device object that is receiving the
383 * @param [in] event_code The event code to process.
388 SCI_STATUS scic_sds_stp_remote_device_ready_ncq_substate_event_handler(
389 SCIC_SDS_REMOTE_DEVICE_T * this_device,
395 status = scic_sds_remote_device_general_event_handler(this_device, event_code);
397 switch (scu_get_event_code(event_code))
399 case SCU_EVENT_TL_RNC_SUSPEND_TX:
400 case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
401 /// @todo We need to decode and understand why the hardware suspended the device.
402 /// The suspension reason was probably due to an SDB error FIS received.
405 case SCU_EVENT_TL_RNC_SUSPEND_TX_DONE_DATA_LEN_ERR:
406 case SCU_EVENT_TL_RNC_SUSPEND_TX_DONE_OFFSET_ERR:
407 case SCU_EVENT_TL_RNC_SUSPEND_TX_DONE_DMASETUP_DIERR:
408 case SCU_EVENT_TL_RNC_SUSPEND_TX_DONE_XFERCNT_ERR:
409 case SCU_EVENT_TL_RNC_SUSPEND_TX_RX_DONE_PLD_LEN_ERR:
410 this_device->not_ready_reason =
411 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
413 sci_base_state_machine_change_state(
414 &this_device->ready_substate_machine,
415 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR
418 // We have a notification that the driver requested a suspend operation
419 // this should not happen.
421 sci_base_object_get_logger(this_device),
422 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
423 "SCIC Remote device 0x%x received driver suspend event %x while in ncq ready substate %d\n",
424 this_device, event_code, sci_base_state_machine_get_state(&this_device->ready_substate_machine)
427 // Since we didnt expect to get here start the device again.
428 status = scic_sds_remote_device_resume(this_device);
431 case SCU_EVENT_POST_RCN_RELEASE:
432 /// @todo Do we need to store the suspend state on the device?
434 sci_base_object_get_logger(this_device),
435 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
436 "SCIC Remote device 0x%x received driver release event %x while in the ready substate %d\n",
437 this_device, event_code, sci_base_state_machine_get_state(&this_device->ready_substate_machine)
442 // Some other event just log it and continue
444 sci_base_object_get_logger(this_device),
445 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
446 "SCIC Remote device 0x%x received driver unexpected event %x while in the ready substate %d\n",
447 this_device, event_code, sci_base_state_machine_get_state(&this_device->ready_substate_machine)
450 status = SCI_FAILURE_INVALID_STATE;
460 * @param[in] this_device
461 * @param[in] frame_index
466 SCI_STATUS scic_sds_stp_remote_device_ready_ncq_substate_frame_handler(
467 SCIC_SDS_REMOTE_DEVICE_T * this_device,
472 SATA_FIS_HEADER_T * frame_header;
474 status = scic_sds_unsolicited_frame_control_get_header(
475 &(scic_sds_remote_device_get_controller(this_device)->uf_control),
477 (void **)&frame_header
480 if (status == SCI_SUCCESS)
483 (frame_header->fis_type == SATA_FIS_TYPE_SETDEVBITS)
484 && (frame_header->status & ATA_STATUS_REG_ERROR_BIT)
487 this_device->not_ready_reason =
488 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
490 /** @todo Check sactive and complete associated IO if any. */
492 sci_base_state_machine_change_state(
493 &this_device->ready_substate_machine,
494 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR
498 (frame_header->fis_type == SATA_FIS_TYPE_REGD2H)
499 && (frame_header->status & ATA_STATUS_REG_ERROR_BIT)
502 // Some devices return D2H FIS when an NCQ error is detected.
503 // Treat this like an SDB error FIS ready reason.
504 this_device->not_ready_reason =
505 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
507 sci_base_state_machine_change_state(
508 &this_device->ready_substate_machine,
509 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR
514 status = SCI_FAILURE;
517 scic_sds_controller_release_frame(
518 scic_sds_remote_device_get_controller(this_device), frame_index
525 //*****************************************************************************
526 //* STP REMOTE DEVICE READY CMD SUBSTATE HANDLERS
527 //*****************************************************************************
530 * This device is already handling a command it can not accept new commands
531 * until this one is complete.
539 SCI_STATUS scic_sds_stp_remote_device_ready_cmd_substate_start_io_handler(
540 SCI_BASE_REMOTE_DEVICE_T * device,
541 SCI_BASE_REQUEST_T * request
544 return SCI_FAILURE_INVALID_STATE;
548 SCI_STATUS scic_sds_stp_remote_device_ready_cmd_substate_suspend_handler(
549 SCIC_SDS_REMOTE_DEVICE_T * this_device,
555 status = scic_sds_remote_node_context_suspend(
556 this_device->rnc, suspend_type, NULL, NULL
565 * @param[in] this_device
566 * @param[in] frame_index
571 SCI_STATUS scic_sds_stp_remote_device_ready_cmd_substate_frame_handler(
572 SCIC_SDS_REMOTE_DEVICE_T * this_device,
578 /// The device doe not process any UF received from the hardware while
579 /// in this state. All unsolicited frames are forwarded to the io request
581 status = scic_sds_io_request_frame_handler(
582 this_device->working_request,
590 //*****************************************************************************
591 //* STP REMOTE DEVICE READY NCQ SUBSTATE HANDLERS
592 //*****************************************************************************
595 //*****************************************************************************
596 //* STP REMOTE DEVICE READY AWAIT RESET SUBSTATE HANDLERS
597 //*****************************************************************************
599 SCI_STATUS scic_sds_stp_remote_device_ready_await_reset_substate_start_io_handler(
600 SCI_BASE_REMOTE_DEVICE_T * device,
601 SCI_BASE_REQUEST_T * request
604 return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
610 * This method will perform the STP request (both io or task) completion
611 * processing for await reset state.
613 * @param[in] device This parameter specifies the device for which the
614 * request is being completed.
615 * @param[in] request This parameter specifies the request being completed.
617 * @return This method returns an indication as to whether the request
618 * processing completed successfully.
621 SCI_STATUS scic_sds_stp_remote_device_ready_await_reset_substate_complete_request_handler(
622 SCI_BASE_REMOTE_DEVICE_T * device,
623 SCI_BASE_REQUEST_T * request
626 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
627 SCIC_SDS_REQUEST_T * the_request = (SCIC_SDS_REQUEST_T *)request;
630 status = scic_sds_io_request_complete(the_request);
632 if (status == SCI_SUCCESS)
634 status = scic_sds_port_complete_io(
635 this_device->owning_port, this_device, the_request
638 if (status == SCI_SUCCESS)
639 scic_sds_remote_device_decrement_request_count(this_device);
642 if (status != SCI_SUCCESS)
645 sci_base_object_get_logger(this_device),
646 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
647 "Port:0x%x Device:0x%x Request:0x%x Status:0x%x could not complete\n",
648 this_device->owning_port, this_device, the_request, status
655 #if !defined(DISABLE_ATAPI)
656 //*****************************************************************************
657 //* STP REMOTE DEVICE READY ATAPI ERROR SUBSTATE HANDLERS
658 //*****************************************************************************
661 * This method will handle the event for a ATAPI device that is in
662 * the ATAPI ERROR state. We pick up suspension events to handle specifically
663 * to this state. We resume the RNC right away. We then complete the outstanding
666 * @param [in] device The device received event.
667 * @param [in] event_code The event code.
672 SCI_STATUS scic_sds_stp_remote_device_ready_atapi_error_substate_event_handler(
673 SCIC_SDS_REMOTE_DEVICE_T * this_device,
679 status = scic_sds_remote_device_general_event_handler(this_device, event_code);
681 if (status == SCI_SUCCESS)
683 if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX
684 || scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX)
686 status = scic_sds_remote_node_context_resume(
688 (SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK)
689 this_device->working_request->state_handlers->parent.complete_handler,
690 (void *)this_device->working_request
697 #endif // !defined(DISABLE_ATAPI)
699 // ---------------------------------------------------------------------------
701 SCIC_SDS_REMOTE_DEVICE_STATE_HANDLER_T
702 scic_sds_stp_remote_device_ready_substate_handler_table[
703 SCIC_SDS_STP_REMOTE_DEVICE_READY_MAX_SUBSTATES] =
705 // SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
708 scic_sds_remote_device_default_start_handler,
709 scic_sds_remote_device_ready_state_stop_handler,
710 scic_sds_remote_device_default_fail_handler,
711 scic_sds_remote_device_default_destruct_handler,
712 scic_sds_remote_device_ready_state_reset_handler,
713 scic_sds_remote_device_default_reset_complete_handler,
714 scic_sds_stp_remote_device_ready_idle_substate_start_io_handler,
715 scic_sds_remote_device_default_complete_request_handler,
716 scic_sds_remote_device_default_continue_request_handler,
717 scic_sds_stp_remote_device_ready_substate_start_request_handler,
718 scic_sds_remote_device_default_complete_request_handler
720 scic_sds_remote_device_default_suspend_handler,
721 scic_sds_remote_device_default_resume_handler,
722 scic_sds_stp_remote_device_ready_idle_substate_event_handler,
723 scic_sds_remote_device_default_frame_handler
725 // SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD
728 scic_sds_remote_device_default_start_handler,
729 scic_sds_remote_device_ready_state_stop_handler,
730 scic_sds_remote_device_default_fail_handler,
731 scic_sds_remote_device_default_destruct_handler,
732 scic_sds_remote_device_ready_state_reset_handler,
733 scic_sds_remote_device_default_reset_complete_handler,
734 scic_sds_stp_remote_device_ready_cmd_substate_start_io_handler,
735 scic_sds_stp_remote_device_complete_request,
736 scic_sds_remote_device_default_continue_request_handler,
737 scic_sds_stp_remote_device_ready_substate_start_request_handler,
738 scic_sds_stp_remote_device_complete_request,
740 scic_sds_stp_remote_device_ready_cmd_substate_suspend_handler,
741 scic_sds_remote_device_default_resume_handler,
742 scic_sds_remote_device_general_event_handler,
743 scic_sds_stp_remote_device_ready_cmd_substate_frame_handler
745 // SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ
748 scic_sds_remote_device_default_start_handler,
749 scic_sds_remote_device_ready_state_stop_handler,
750 scic_sds_remote_device_default_fail_handler,
751 scic_sds_remote_device_default_destruct_handler,
752 scic_sds_remote_device_ready_state_reset_handler,
753 scic_sds_remote_device_default_reset_complete_handler,
754 scic_sds_stp_remote_device_ready_ncq_substate_start_io_handler,
755 scic_sds_stp_remote_device_complete_request,
756 scic_sds_remote_device_default_continue_request_handler,
757 scic_sds_stp_remote_device_ready_substate_start_request_handler,
758 scic_sds_stp_remote_device_complete_request
760 scic_sds_remote_device_default_suspend_handler,
761 scic_sds_remote_device_default_resume_handler,
762 scic_sds_stp_remote_device_ready_ncq_substate_event_handler,
763 scic_sds_stp_remote_device_ready_ncq_substate_frame_handler
765 // SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR
768 scic_sds_remote_device_default_start_handler,
769 scic_sds_remote_device_ready_state_stop_handler,
770 scic_sds_remote_device_default_fail_handler,
771 scic_sds_remote_device_default_destruct_handler,
772 scic_sds_remote_device_ready_state_reset_handler,
773 scic_sds_remote_device_default_reset_complete_handler,
774 scic_sds_remote_device_default_start_request_handler,
775 scic_sds_stp_remote_device_complete_request,
776 scic_sds_remote_device_default_continue_request_handler,
777 scic_sds_stp_remote_device_ready_substate_start_request_handler,
778 scic_sds_stp_remote_device_complete_request
780 scic_sds_remote_device_default_suspend_handler,
781 scic_sds_remote_device_default_resume_handler,
782 scic_sds_remote_device_general_event_handler,
783 scic_sds_remote_device_general_frame_handler
785 #if !defined(DISABLE_ATAPI)
786 // SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR
789 scic_sds_remote_device_default_start_handler,
790 scic_sds_remote_device_ready_state_stop_handler,
791 scic_sds_remote_device_default_fail_handler,
792 scic_sds_remote_device_default_destruct_handler,
793 scic_sds_remote_device_ready_state_reset_handler,
794 scic_sds_remote_device_default_reset_complete_handler,
795 scic_sds_remote_device_default_start_request_handler,
796 scic_sds_stp_remote_device_complete_request,
797 scic_sds_remote_device_default_continue_request_handler,
798 scic_sds_stp_remote_device_ready_substate_start_request_handler,
799 scic_sds_stp_remote_device_complete_request
801 scic_sds_remote_device_default_suspend_handler,
802 scic_sds_remote_device_default_resume_handler,
803 scic_sds_stp_remote_device_ready_atapi_error_substate_event_handler,
804 scic_sds_remote_device_general_frame_handler
807 // SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET
810 scic_sds_remote_device_default_start_handler,
811 scic_sds_remote_device_ready_state_stop_handler,
812 scic_sds_remote_device_default_fail_handler,
813 scic_sds_remote_device_default_destruct_handler,
814 scic_sds_remote_device_ready_state_reset_handler,
815 scic_sds_remote_device_default_reset_complete_handler,
816 scic_sds_stp_remote_device_ready_await_reset_substate_start_io_handler,
817 scic_sds_stp_remote_device_ready_await_reset_substate_complete_request_handler,
818 scic_sds_remote_device_default_continue_request_handler,
819 scic_sds_stp_remote_device_ready_substate_start_request_handler,
820 scic_sds_stp_remote_device_complete_request
822 scic_sds_remote_device_default_suspend_handler,
823 scic_sds_remote_device_default_resume_handler,
824 scic_sds_remote_device_general_event_handler,
825 scic_sds_remote_device_general_frame_handler
829 //*****************************************************************************
830 //* STP REMOTE DEVICE READY SUBSTATE PRIVATE METHODS
831 //*****************************************************************************
834 void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(
838 SCIC_SDS_REMOTE_DEVICE_T * this_device;
839 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)user_cookie;
841 // For NCQ operation we do not issue a
842 // scic_cb_remote_device_not_ready(). As a result, avoid sending
843 // the ready notification.
844 if (this_device->ready_substate_machine.previous_state_id
845 != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ)
847 scic_cb_remote_device_ready(
848 scic_sds_remote_device_get_controller(this_device), this_device
853 //*****************************************************************************
854 //* STP REMOTE DEVICE READY IDLE SUBSTATE
855 //*****************************************************************************
859 * @param[in] device This is the SCI base object which is cast into a
860 * SCIC_SDS_REMOTE_DEVICE object.
865 void scic_sds_stp_remote_device_ready_idle_substate_enter(
866 SCI_BASE_OBJECT_T * device
869 SCIC_SDS_REMOTE_DEVICE_T * this_device;
871 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
875 scic_sds_stp_remote_device_ready_substate_handler_table,
876 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
879 this_device->working_request = NULL;
881 if (scic_sds_remote_node_context_is_ready(this_device->rnc))
883 // Since the RNC is ready, it's alright to finish completion
884 // processing (e.g. signal the remote device is ready).
885 scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(
891 scic_sds_remote_node_context_resume(
893 scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler,
899 //*****************************************************************************
900 //* STP REMOTE DEVICE READY CMD SUBSTATE
901 //*****************************************************************************
906 * @param[in] device This is the SCI base object which is cast into a
907 * SCIC_SDS_REMOTE_DEVICE object.
912 void scic_sds_stp_remote_device_ready_cmd_substate_enter(
913 SCI_BASE_OBJECT_T * device
916 SCIC_SDS_REMOTE_DEVICE_T * this_device;
918 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
920 ASSERT(this_device->working_request != NULL);
924 scic_sds_stp_remote_device_ready_substate_handler_table,
925 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD
928 scic_cb_remote_device_not_ready(
929 scic_sds_remote_device_get_controller(this_device),
931 SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED
935 //*****************************************************************************
936 //* STP REMOTE DEVICE READY NCQ SUBSTATE
937 //*****************************************************************************
942 * @param[in] device This is the SCI base object which is cast into a
943 * SCIC_SDS_REMOTE_DEVICE object.
948 void scic_sds_stp_remote_device_ready_ncq_substate_enter(
949 SCI_BASE_OBJECT_T * device
952 SCIC_SDS_REMOTE_DEVICE_T * this_device;
954 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
958 scic_sds_stp_remote_device_ready_substate_handler_table,
959 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ
963 //*****************************************************************************
964 //* STP REMOTE DEVICE READY NCQ ERROR SUBSTATE
965 //*****************************************************************************
970 * @param[in] device This is the SCI base object which is cast into a
971 * SCIC_SDS_REMOTE_DEVICE object.
976 void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(
977 SCI_BASE_OBJECT_T * device
980 SCIC_SDS_REMOTE_DEVICE_T * this_device;
982 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
986 scic_sds_stp_remote_device_ready_substate_handler_table,
987 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR
990 if(this_device->not_ready_reason ==
991 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED)
993 scic_cb_remote_device_not_ready(
994 scic_sds_remote_device_get_controller(this_device),
996 this_device->not_ready_reason
1001 //*****************************************************************************
1002 //* STP REMOTE DEVICE READY AWAIT RESET SUBSTATE
1003 //*****************************************************************************
1006 * @brief The enter routine to READY AWAIT RESET substate.
1008 * @param[in] device This is the SCI base object which is cast into a
1009 * SCIC_SDS_REMOTE_DEVICE object.
1014 void scic_sds_stp_remote_device_ready_await_reset_substate_enter(
1015 SCI_BASE_OBJECT_T * device
1018 SCIC_SDS_REMOTE_DEVICE_T * this_device;
1020 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1024 scic_sds_stp_remote_device_ready_substate_handler_table,
1025 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET
1029 #if !defined(DISABLE_ATAPI)
1030 //*****************************************************************************
1031 //* STP REMOTE DEVICE READY ATAPI ERROR SUBSTATE
1032 //*****************************************************************************
1035 * @brief The enter routine to READY ATAPI ERROR substate.
1037 * @param[in] device This is the SCI base object which is cast into a
1038 * SCIC_SDS_REMOTE_DEVICE object.
1043 void scic_sds_stp_remote_device_ready_atapi_error_substate_enter(
1044 SCI_BASE_OBJECT_T * device
1047 SCIC_SDS_REMOTE_DEVICE_T * this_device;
1049 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1053 scic_sds_stp_remote_device_ready_substate_handler_table,
1054 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR
1057 #endif // !defined(DISABLE_ATAPI)
1059 // ---------------------------------------------------------------------------
1062 scic_sds_stp_remote_device_ready_substate_table[
1063 SCIC_SDS_STP_REMOTE_DEVICE_READY_MAX_SUBSTATES] =
1066 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
1067 scic_sds_stp_remote_device_ready_idle_substate_enter,
1071 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
1072 scic_sds_stp_remote_device_ready_cmd_substate_enter,
1076 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ,
1077 scic_sds_stp_remote_device_ready_ncq_substate_enter,
1081 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR,
1082 scic_sds_stp_remote_device_ready_ncq_error_substate_enter,
1085 #if !defined(DISABLE_ATAPI)
1087 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR,
1088 scic_sds_stp_remote_device_ready_atapi_error_substate_enter,
1093 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET,
1094 scic_sds_stp_remote_device_ready_await_reset_substate_enter,