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 implementation of remote device, it's
60 * methods and state machine.
63 #include <dev/isci/scil/intel_sas.h>
64 #include <dev/isci/scil/sci_util.h>
65 #include <dev/isci/scil/scic_port.h>
66 #include <dev/isci/scil/scic_phy.h>
67 #include <dev/isci/scil/scic_remote_device.h>
68 #include <dev/isci/scil/scic_sds_port.h>
69 #include <dev/isci/scil/scic_sds_phy.h>
70 #include <dev/isci/scil/scic_sds_remote_device.h>
71 #include <dev/isci/scil/scic_sds_request.h>
72 #include <dev/isci/scil/scic_sds_controller.h>
73 #include <dev/isci/scil/scic_sds_logger.h>
74 #include <dev/isci/scil/scic_user_callback.h>
75 #include <dev/isci/scil/scic_controller.h>
76 #include <dev/isci/scil/scic_sds_logger.h>
77 #include <dev/isci/scil/scic_sds_remote_node_context.h>
78 #include <dev/isci/scil/scu_event_codes.h>
80 #define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000)
82 //*****************************************************************************
83 //* CORE REMOTE DEVICE PUBLIC METHODS
84 //*****************************************************************************
86 U32 scic_remote_device_get_object_size(void)
88 return sizeof(SCIC_SDS_REMOTE_DEVICE_T)
89 + sizeof(SCIC_SDS_REMOTE_NODE_CONTEXT_T);
92 // ---------------------------------------------------------------------------
94 void scic_remote_device_construct(
95 SCI_PORT_HANDLE_T port,
96 void * remote_device_memory,
97 SCI_REMOTE_DEVICE_HANDLE_T * new_remote_device_handle
100 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T*)
101 remote_device_memory;
102 SCIC_SDS_PORT_T *the_port = (SCIC_SDS_PORT_T*) port;
105 sci_base_object_get_logger(the_port),
106 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
107 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
108 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
109 "scic_remote_device_construct(0x%x, 0x%x, 0x%x) enter\n",
110 port, remote_device_memory, new_remote_device_handle
113 memset(remote_device_memory, 0, sizeof(SCIC_SDS_REMOTE_DEVICE_T));
115 *new_remote_device_handle = this_device;
116 this_device->owning_port = the_port;
117 this_device->started_request_count = 0;
118 this_device->rnc = (SCIC_SDS_REMOTE_NODE_CONTEXT_T *)
119 ((char *)this_device + sizeof(SCIC_SDS_REMOTE_DEVICE_T));
121 sci_base_remote_device_construct(
122 &this_device->parent,
123 sci_base_object_get_logger(the_port),
124 scic_sds_remote_device_state_table
127 scic_sds_remote_node_context_construct(
130 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
133 sci_object_set_association(this_device->rnc, this_device);
135 scic_sds_remote_device_initialize_state_logging(this_device);
138 // ---------------------------------------------------------------------------
140 SCI_STATUS scic_remote_device_da_construct(
141 SCI_REMOTE_DEVICE_HANDLE_T remote_device
145 U16 remote_node_index;
146 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T*)
148 SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T protocols;
149 SCIC_PORT_PROPERTIES_T properties;
152 sci_base_object_get_logger(this_device->owning_port),
153 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
154 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
155 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
156 "scic_remote_device_da_construct(0x%x) enter\n",
160 // This information is request to determine how many remote node context
161 // entries will be needed to store the remote node.
162 scic_sds_port_get_attached_protocols(this_device->owning_port,&protocols);
163 this_device->target_protocols.u.all = protocols.u.all;
164 this_device->is_direct_attached = TRUE;
165 #if !defined(DISABLE_ATAPI)
166 this_device->is_atapi = scic_sds_remote_device_is_atapi(this_device);
169 scic_port_get_properties(this_device->owning_port, &properties);
170 //Get accurate port width from port's phy mask for a DA device.
171 SCI_GET_BITS_SET_COUNT(properties.phy_mask, this_device->device_port_width);
173 status = scic_sds_controller_allocate_remote_node_context(
174 this_device->owning_port->owning_controller,
179 if (status == SCI_SUCCESS)
181 scic_sds_remote_node_context_set_remote_node_index(
182 this_device->rnc, remote_node_index
185 scic_sds_port_get_attached_sas_address(
186 this_device->owning_port, &this_device->device_address
189 if (this_device->target_protocols.u.bits.attached_ssp_target)
191 this_device->has_ready_substate_machine = FALSE;
193 else if (this_device->target_protocols.u.bits.attached_stp_target)
195 this_device->has_ready_substate_machine = TRUE;
197 sci_base_state_machine_construct(
198 &this_device->ready_substate_machine,
199 &this_device->parent.parent,
200 scic_sds_stp_remote_device_ready_substate_table,
201 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
204 else if (this_device->target_protocols.u.bits.attached_smp_target)
206 this_device->has_ready_substate_machine = TRUE;
208 //add the SMP ready substate machine construction here
209 sci_base_state_machine_construct(
210 &this_device->ready_substate_machine,
211 &this_device->parent.parent,
212 scic_sds_smp_remote_device_ready_substate_table,
213 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
217 this_device->connection_rate = scic_sds_port_get_max_allowed_speed(
218 this_device->owning_port
221 /// @todo Should I assign the port width by reading all of the phys on the port?
222 this_device->device_port_width = 1;
229 // ---------------------------------------------------------------------------
231 void scic_sds_remote_device_get_info_from_smp_discover_response(
232 SCIC_SDS_REMOTE_DEVICE_T * this_device,
233 SMP_RESPONSE_DISCOVER_T * discover_response
236 // decode discover_response to set sas_address to this_device.
237 this_device->device_address.high =
238 discover_response->attached_sas_address.high;
240 this_device->device_address.low =
241 discover_response->attached_sas_address.low;
243 this_device->target_protocols.u.all = discover_response->protocols.u.all;
247 // ---------------------------------------------------------------------------
249 SCI_STATUS scic_remote_device_ea_construct(
250 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
251 SMP_RESPONSE_DISCOVER_T * discover_response
256 SCIC_SDS_REMOTE_DEVICE_T *this_device;
257 SCIC_SDS_CONTROLLER_T *the_controller;
259 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
262 sci_base_object_get_logger(this_device->owning_port),
263 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
264 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
265 "scic_remote_device_ea_sas_construct0x%x, 0x%x) enter\n",
266 remote_device, discover_response
269 the_controller = scic_sds_port_get_controller(this_device->owning_port);
271 scic_sds_remote_device_get_info_from_smp_discover_response(
272 this_device, discover_response
275 status = scic_sds_controller_allocate_remote_node_context(
278 &this_device->rnc->remote_node_index
281 if (status == SCI_SUCCESS)
283 if (this_device->target_protocols.u.bits.attached_ssp_target)
285 this_device->has_ready_substate_machine = FALSE;
287 else if (this_device->target_protocols.u.bits.attached_smp_target)
289 this_device->has_ready_substate_machine = TRUE;
291 //add the SMP ready substate machine construction here
292 sci_base_state_machine_construct(
293 &this_device->ready_substate_machine,
294 &this_device->parent.parent,
295 scic_sds_smp_remote_device_ready_substate_table,
296 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
299 else if (this_device->target_protocols.u.bits.attached_stp_target)
301 this_device->has_ready_substate_machine = TRUE;
303 sci_base_state_machine_construct(
304 &this_device->ready_substate_machine,
305 &this_device->parent.parent,
306 scic_sds_stp_remote_device_ready_substate_table,
307 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
311 // For SAS-2 the physical link rate is actually a logical link
312 // rate that incorporates multiplexing. The SCU doesn't
313 // incorporate multiplexing and for the purposes of the
314 // connection the logical link rate is that same as the
315 // physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay
316 // one another, so this code works for both situations.
317 this_device->connection_rate = MIN(
318 scic_sds_port_get_max_allowed_speed( this_device->owning_port),
319 discover_response->u2.sas1_1.negotiated_physical_link_rate
322 /// @todo Should I assign the port width by reading all of the phys on the port?
323 this_device->device_port_width = 1;
329 // ---------------------------------------------------------------------------
331 SCI_STATUS scic_remote_device_destruct(
332 SCI_REMOTE_DEVICE_HANDLE_T remote_device
335 SCIC_SDS_REMOTE_DEVICE_T *this_device;
336 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
339 sci_base_object_get_logger(this_device),
340 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
341 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
342 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
343 "scic_remote_device_destruct(0x%x) enter\n",
347 return this_device->state_handlers->parent.destruct_handler(&this_device->parent);
350 // ---------------------------------------------------------------------------
352 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
354 SCI_STATUS scic_remote_device_set_port_width(
355 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
359 SCIC_SDS_REMOTE_DEVICE_T *this_device;
361 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
364 sci_base_object_get_logger(this_device),
365 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
366 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
367 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
368 "scic_remote_device_set_port_width(0x%x, 0x%x) enter\n",
369 remote_device, new_port_width
372 if(new_port_width != 0)
374 this_device->device_port_width = new_port_width;
382 // ---------------------------------------------------------------------------
384 U8 scic_remote_device_get_port_width(
385 SCI_REMOTE_DEVICE_HANDLE_T remote_device
388 SCIC_SDS_REMOTE_DEVICE_T *this_device;
390 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
393 sci_base_object_get_logger(this_device),
394 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
395 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
396 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
397 "scic_remote_device_get_port_width(0x%x) enter\n",
401 return (U8)this_device->device_port_width;
404 #endif // !defined(DISABLE_WIDE_PORTED_TARGETS)
406 // ---------------------------------------------------------------------------
408 SCI_STATUS scic_remote_device_start(
409 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
413 SCIC_SDS_REMOTE_DEVICE_T *this_device;
414 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
417 sci_base_object_get_logger(this_device),
418 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
419 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
420 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
421 "scic_remote_device_start(0x%x, 0x%x) enter\n",
422 remote_device, timeout
425 return this_device->state_handlers->parent.start_handler(&this_device->parent);
428 // ---------------------------------------------------------------------------
430 SCI_STATUS scic_remote_device_stop(
431 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
435 SCIC_SDS_REMOTE_DEVICE_T *this_device;
436 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
439 sci_base_object_get_logger(this_device),
440 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
441 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
442 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
443 "scic_remote_device_stop(0x%x, 0x%x) enter\n",
444 remote_device, timeout
447 return this_device->state_handlers->parent.stop_handler(&this_device->parent);
451 * This method invokes the remote device reset handler.
453 * @param[in] this_device The remote device for which the reset is being
458 SCI_STATUS scic_remote_device_reset(
459 SCI_REMOTE_DEVICE_HANDLE_T remote_device
462 SCIC_SDS_REMOTE_DEVICE_T *this_device;
463 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
466 sci_base_object_get_logger(this_device),
467 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
468 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
469 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
470 "scic_remote_device_reset(0x%x) enter\n",
474 return this_device->state_handlers->parent.reset_handler(&this_device->parent);
478 * This method invokes the remote device reset handler.
480 * @param[in] this_device The remote device for which the reset is being
485 SCI_STATUS scic_remote_device_reset_complete(
486 SCI_REMOTE_DEVICE_HANDLE_T remote_device
489 SCIC_SDS_REMOTE_DEVICE_T *this_device;
490 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
493 sci_base_object_get_logger(this_device),
494 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
495 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
496 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
497 "scic_remote_device_reset_complete(0x%x) enter\n",
501 return this_device->state_handlers->parent.reset_complete_handler(&this_device->parent);
505 * This method invokes the remote device reset handler.
507 * @param[in] this_device The remote device for which the reset is being
512 U32 scic_remote_device_get_suggested_reset_timeout(
513 SCI_REMOTE_DEVICE_HANDLE_T remote_device
516 SCIC_SDS_REMOTE_DEVICE_T *this_device;
517 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
520 sci_base_object_get_logger(this_device),
521 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
522 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
523 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
524 "scic_remote_device_get_suggested_reset_timeout(0x%x) enter\n",
528 if (this_device->target_protocols.u.bits.attached_stp_target)
530 return SCIC_SDS_SIGNATURE_FIS_TIMEOUT;
533 return SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT;
536 // ---------------------------------------------------------------------------
538 SCI_STATUS scic_remote_device_set_max_connection_rate(
539 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
540 SCI_SAS_LINK_RATE connection_rate
543 SCIC_SDS_REMOTE_DEVICE_T *this_device;
544 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
547 sci_base_object_get_logger(this_device),
548 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
549 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
550 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
551 "scic_remote_device_set_max_connection_rate(0x%x, 0x%x) enter\n",
552 remote_device, connection_rate
555 this_device->connection_rate = connection_rate;
560 // ---------------------------------------------------------------------------
562 SCI_SAS_LINK_RATE scic_remote_device_get_connection_rate(
563 SCI_REMOTE_DEVICE_HANDLE_T remote_device
566 SCIC_SDS_REMOTE_DEVICE_T *this_device;
567 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
570 sci_base_object_get_logger(this_device),
571 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
572 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
573 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
574 "scic_remote_device_get_connection_rate(0x%x) enter\n",
578 return this_device->connection_rate;
581 // ---------------------------------------------------------------------------
583 void scic_remote_device_get_protocols(
584 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
585 SMP_DISCOVER_RESPONSE_PROTOCOLS_T * protocols
588 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)
592 sci_base_object_get_logger(this_device),
593 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
594 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
595 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
596 "scic_remote_device_get_protocols(0x%x) enter\n",
600 protocols->u.all = this_device->target_protocols.u.all;
603 // ---------------------------------------------------------------------------
605 void scic_remote_device_get_sas_address(
606 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
607 SCI_SAS_ADDRESS_T * sas_address
610 SCIC_SDS_REMOTE_DEVICE_T *this_device;
611 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
614 sci_base_object_get_logger(this_device),
615 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
616 SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
617 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
618 "scic_remote_device_get_sas_address(0x%x, 0x%x) enter\n",
619 remote_device, sas_address
622 sas_address->low = this_device->device_address.low;
623 sas_address->high = this_device->device_address.high;
626 // ---------------------------------------------------------------------------
627 #if !defined(DISABLE_ATAPI)
628 BOOL scic_remote_device_is_atapi(
629 SCI_REMOTE_DEVICE_HANDLE_T device_handle
632 return ((SCIC_SDS_REMOTE_DEVICE_T *)device_handle)->is_atapi;
637 //*****************************************************************************
638 //* SCU DRIVER STANDARD (SDS) REMOTE DEVICE IMPLEMENTATIONS
639 //*****************************************************************************
642 * Remote device timer requirements
644 #define SCIC_SDS_REMOTE_DEVICE_MINIMUM_TIMER_COUNT (0)
645 #define SCIC_SDS_REMOTE_DEVICE_MAXIMUM_TIMER_COUNT (SCI_MAX_REMOTE_DEVICES)
648 * @brief This method returns the minimum number of timers required for all
653 U32 scic_sds_remote_device_get_min_timer_count(void)
655 return SCIC_SDS_REMOTE_DEVICE_MINIMUM_TIMER_COUNT;
659 * @brief This method returns the maximum number of timers requried for all
664 U32 scic_sds_remote_device_get_max_timer_count(void)
666 return SCIC_SDS_REMOTE_DEVICE_MAXIMUM_TIMER_COUNT;
669 // ---------------------------------------------------------------------------
673 * This method will enable and turn on state transition logging for the remote
676 * @param[in] this_device The device for which state transition logging is to
681 void scic_sds_remote_device_initialize_state_logging(
682 SCIC_SDS_REMOTE_DEVICE_T *this_device
685 sci_base_state_machine_logger_initialize(
686 &this_device->parent.state_machine_logger,
687 &this_device->parent.state_machine,
688 &this_device->parent.parent,
689 scic_cb_logger_log_states,
690 "SCIC_SDS_REMOTE_DEVICE_T", "base state machine",
691 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
692 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
693 SCIC_LOG_OBJECT_STP_REMOTE_TARGET
696 if (this_device->has_ready_substate_machine)
698 sci_base_state_machine_logger_initialize(
699 &this_device->ready_substate_machine_logger,
700 &this_device->ready_substate_machine,
701 &this_device->parent.parent,
702 scic_cb_logger_log_states,
703 "SCIC_SDS_REMOTE_DEVICE_T", "ready substate machine",
704 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
705 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
706 SCIC_LOG_OBJECT_STP_REMOTE_TARGET
712 * This method will stop the state machine logging for this object and should
713 * be called before the object is destroyed.
715 * @param[in] this_device The device on which to stop logging state
720 void scic_sds_remote_device_deinitialize_state_logging(
721 SCIC_SDS_REMOTE_DEVICE_T *this_device
724 sci_base_state_machine_logger_deinitialize(
725 &this_device->parent.state_machine_logger,
726 &this_device->parent.state_machine
729 if (this_device->has_ready_substate_machine)
731 sci_base_state_machine_logger_deinitialize(
732 &this_device->ready_substate_machine_logger,
733 &this_device->ready_substate_machine
740 * This method invokes the remote device suspend state handler.
742 * @param[in] this_device The remote device for which the suspend is being
747 SCI_STATUS scic_sds_remote_device_suspend(
748 SCIC_SDS_REMOTE_DEVICE_T *this_device,
752 return this_device->state_handlers->suspend_handler(this_device, suspend_type);
756 * This method invokes the remote device resume state handler.
758 * @param[in] this_device The remote device for which the resume is being
763 SCI_STATUS scic_sds_remote_device_resume(
764 SCIC_SDS_REMOTE_DEVICE_T *this_device
767 return this_device->state_handlers->resume_handler(this_device);
771 * This method invokes the frame handler for the remote device state machine
773 * @param[in] this_device The remote device for which the event handling is
775 * @param[in] frame_index This is the frame index that is being processed.
779 SCI_STATUS scic_sds_remote_device_frame_handler(
780 SCIC_SDS_REMOTE_DEVICE_T *this_device,
784 return this_device->state_handlers->frame_handler(this_device, frame_index);
788 * This method invokes the remote device event handler.
790 * @param[in] this_device The remote device for which the event handling is
792 * @param[in] event_code This is the event code that is to be processed.
796 SCI_STATUS scic_sds_remote_device_event_handler(
797 SCIC_SDS_REMOTE_DEVICE_T *this_device,
801 return this_device->state_handlers->event_handler(this_device, event_code);
805 * This method invokes the remote device start io handler.
807 * @param[in] controller The controller that is starting the io request.
808 * @param[in] this_device The remote device for which the start io handling is
810 * @param[in] io_request The io request that is being started.
814 SCI_STATUS scic_sds_remote_device_start_io(
815 SCIC_SDS_CONTROLLER_T *controller,
816 SCIC_SDS_REMOTE_DEVICE_T *this_device,
817 SCIC_SDS_REQUEST_T *io_request
820 return this_device->state_handlers->parent.start_io_handler(
821 &this_device->parent, &io_request->parent);
825 * This method invokes the remote device complete io handler.
827 * @param[in] controller The controller that is completing the io request.
828 * @param[in] this_device The remote device for which the complete io handling
829 * is being requested.
830 * @param[in] io_request The io request that is being completed.
834 SCI_STATUS scic_sds_remote_device_complete_io(
835 SCIC_SDS_CONTROLLER_T *controller,
836 SCIC_SDS_REMOTE_DEVICE_T *this_device,
837 SCIC_SDS_REQUEST_T *io_request
840 return this_device->state_handlers->parent.complete_io_handler(
841 &this_device->parent, &io_request->parent);
845 * This method invokes the remote device start task handler.
847 * @param[in] controller The controller that is starting the task request.
848 * @param[in] this_device The remote device for which the start task handling
849 * is being requested.
850 * @param[in] io_request The task request that is being started.
854 SCI_STATUS scic_sds_remote_device_start_task(
855 SCIC_SDS_CONTROLLER_T *controller,
856 SCIC_SDS_REMOTE_DEVICE_T *this_device,
857 SCIC_SDS_REQUEST_T *io_request
860 return this_device->state_handlers->parent.start_task_handler(
861 &this_device->parent, &io_request->parent);
865 * This method takes the request and bulids an appropriate SCU context for the
866 * request and then requests the controller to post the request.
868 * @param[in] this_device
873 void scic_sds_remote_device_post_request(
874 SCIC_SDS_REMOTE_DEVICE_T * this_device,
880 context = scic_sds_remote_device_build_command_context(this_device, request);
882 scic_sds_controller_post_request(
883 scic_sds_remote_device_get_controller(this_device),
888 #if !defined(DISABLE_ATAPI)
890 * This method check the signature fis of a stp device to decide whether
891 * a device is atapi or not.
893 * @param[in] this_device The device to be checked.
895 * @return TRUE if a device is atapi device. False if a device is not atapi.
897 BOOL scic_sds_remote_device_is_atapi(
898 SCIC_SDS_REMOTE_DEVICE_T * this_device
901 if (!this_device->target_protocols.u.bits.attached_stp_target)
903 else if (this_device->is_direct_attached)
905 SCIC_SDS_PHY_T * phy;
906 SCIC_SATA_PHY_PROPERTIES_T properties;
907 SATA_FIS_REG_D2H_T * signature_fis;
908 phy = scic_sds_port_get_a_connected_phy(this_device->owning_port);
909 scic_sata_phy_get_properties(phy, &properties);
911 //decode the signature fis.
912 signature_fis = &(properties.signature_fis);
914 if ( (signature_fis->sector_count == 0x01)
915 && (signature_fis->lba_low == 0x01)
916 && (signature_fis->lba_mid == 0x14)
917 && (signature_fis->lba_high == 0xEB)
918 && ( (signature_fis->device & 0x5F) == 0x00)
921 // An ATA device supporting the PACKET command set.
929 //Expander supported ATAPI device is not currently supported.
934 #endif // !defined(DISABLE_ATAPI)
936 //******************************************************************************
937 //* REMOTE DEVICE STATE MACHINE
938 //******************************************************************************
941 * This method is called once the remote node context is ready to be
942 * freed. The remote device can now report that its stop operation is
945 * @param[in] user_parameter This is cast to a remote device object.
950 void scic_sds_cb_remote_device_rnc_destruct_complete(
951 void * user_parameter
954 SCIC_SDS_REMOTE_DEVICE_T * this_device;
955 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)user_parameter;
957 ASSERT(this_device->started_request_count == 0);
959 sci_base_state_machine_change_state(
960 scic_sds_remote_device_get_base_state_machine(this_device),
961 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
966 * This method is called once the remote node context has transisitioned to a
967 * ready state. This is the indication that the remote device object can also
968 * transition to ready.
970 * @param[in] user_parameter This is cast to a remote device object.
975 void scic_sds_remote_device_resume_complete_handler(
976 void * user_parameter
979 SCIC_SDS_REMOTE_DEVICE_T * this_device;
980 this_device = (SCIC_SDS_REMOTE_DEVICE_T *)user_parameter;
983 sci_base_state_machine_get_state(&this_device->parent.state_machine)
984 != SCI_BASE_REMOTE_DEVICE_STATE_READY
987 sci_base_state_machine_change_state(
988 &this_device->parent.state_machine,
989 SCI_BASE_REMOTE_DEVICE_STATE_READY
995 * This method will perform the STP request start processing common
996 * to IO requests and task requests of all types.
998 * @param[in] device This parameter specifies the device for which the
999 * request is being started.
1000 * @param[in] request This parameter specifies the request being started.
1001 * @param[in] status This parameter specifies the current start operation
1006 void scic_sds_remote_device_start_request(
1007 SCIC_SDS_REMOTE_DEVICE_T * this_device,
1008 SCIC_SDS_REQUEST_T * the_request,
1012 // We still have a fault in starting the io complete it on the port
1013 if (status == SCI_SUCCESS)
1014 scic_sds_remote_device_increment_request_count(this_device);
1017 this_device->owning_port->state_handlers->complete_io_handler(
1018 this_device->owning_port, this_device, the_request
1025 * This method will continue to post tc for a STP request. This method usually
1026 * serves as a callback when RNC gets resumed during a task management sequence.
1028 * @param[in] request This parameter specifies the request being continued.
1032 void scic_sds_remote_device_continue_request(
1033 SCIC_SDS_REMOTE_DEVICE_T * this_device
1036 // we need to check if this request is still valid to continue.
1037 if (this_device->working_request != NULL)
1039 SCIC_SDS_REQUEST_T * this_request = this_device->working_request;
1041 this_request->owning_controller->state_handlers->parent.continue_io_handler(
1042 &this_request->owning_controller->parent,
1043 &this_request->target_device->parent,
1044 &this_request->parent
1050 * @brief This method will terminate all of the IO requests in the
1051 * controllers IO request table that were targeted for this
1054 * @param[in] this_device This parameter specifies the remote device
1055 * for which to attempt to terminate all requests.
1057 * @return This method returns an indication as to whether all requests
1058 * were successfully terminated. If a single request fails to
1059 * be terminated, then this method will return the failure.
1062 SCI_STATUS scic_sds_remote_device_terminate_requests(
1063 SCIC_SDS_REMOTE_DEVICE_T *this_device
1066 return scic_sds_terminate_reqests(
1067 this_device->owning_port->owning_controller,
1072 //*****************************************************************************
1073 //* DEFAULT STATE HANDLERS
1074 //*****************************************************************************
1077 * This method is the default start handler. It logs a warning and returns a
1080 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1081 * SCIC_SDS_REMOTE_DEVICE.
1083 * @return SCI_STATUS
1084 * @retval SCI_FAILURE_INVALID_STATE
1086 SCI_STATUS scic_sds_remote_device_default_start_handler(
1087 SCI_BASE_REMOTE_DEVICE_T *device
1091 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1092 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1093 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1094 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1095 "SCIC Remote Device requested to start while in wrong state %d\n",
1096 sci_base_state_machine_get_state(
1097 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1100 return SCI_FAILURE_INVALID_STATE;
1104 * This method is the default stop handler. It logs a warning and returns a
1107 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1108 * SCIC_SDS_REMOTE_DEVICE.
1110 * @return SCI_STATUS
1111 * @retval SCI_FAILURE_INVALID_STATE
1113 SCI_STATUS scic_sds_remote_device_default_stop_handler(
1114 SCI_BASE_REMOTE_DEVICE_T *device
1118 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1119 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1120 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1121 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1122 "SCIC Remote Device requested to stop while in wrong state %d\n",
1123 sci_base_state_machine_get_state(
1124 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1127 return SCI_FAILURE_INVALID_STATE;
1131 * This method is the default fail handler. It logs a warning and returns a
1134 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1135 * SCIC_SDS_REMOTE_DEVICE.
1137 * @return SCI_STATUS
1138 * @retval SCI_FAILURE_INVALID_STATE
1140 SCI_STATUS scic_sds_remote_device_default_fail_handler(
1141 SCI_BASE_REMOTE_DEVICE_T *device
1145 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1146 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1147 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1148 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1149 "SCIC Remote Device requested to fail while in wrong state %d\n",
1150 sci_base_state_machine_get_state(
1151 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1154 return SCI_FAILURE_INVALID_STATE;
1158 * This method is the default destruct handler. It logs a warning and returns
1161 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1162 * SCIC_SDS_REMOTE_DEVICE.
1164 * @return SCI_STATUS
1165 * @retval SCI_FAILURE_INVALID_STATE
1167 SCI_STATUS scic_sds_remote_device_default_destruct_handler(
1168 SCI_BASE_REMOTE_DEVICE_T *device
1172 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1173 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1174 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1175 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1176 "SCIC Remote Device requested to destroy while in wrong state %d\n",
1177 sci_base_state_machine_get_state(
1178 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1181 return SCI_FAILURE_INVALID_STATE;
1185 * This method is the default reset handler. It logs a warning and returns a
1188 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1189 * SCIC_SDS_REMOTE_DEVICE.
1191 * @return SCI_STATUS
1192 * @retval SCI_FAILURE_INVALID_STATE
1194 SCI_STATUS scic_sds_remote_device_default_reset_handler(
1195 SCI_BASE_REMOTE_DEVICE_T *device
1199 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1200 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1201 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1202 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1203 "SCIC Remote Device requested to reset while in wrong state %d\n",
1204 sci_base_state_machine_get_state(
1205 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1208 return SCI_FAILURE_INVALID_STATE;
1212 * This method is the default reset complete handler. It logs a warning and
1213 * returns a failure.
1215 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1216 * SCIC_SDS_REMOTE_DEVICE.
1218 * @return SCI_STATUS
1219 * @retval SCI_FAILURE_INVALID_STATE
1221 SCI_STATUS scic_sds_remote_device_default_reset_complete_handler(
1222 SCI_BASE_REMOTE_DEVICE_T *device
1226 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1227 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1228 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1229 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1230 "SCIC Remote Device requested to complete reset while in wrong state %d\n",
1231 sci_base_state_machine_get_state(
1232 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1235 return SCI_FAILURE_INVALID_STATE;
1239 * This method is the default suspend handler. It logs a warning and returns
1242 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1243 * SCIC_SDS_REMOTE_DEVICE.
1245 * @return SCI_STATUS
1246 * @retval SCI_FAILURE_INVALID_STATE
1248 SCI_STATUS scic_sds_remote_device_default_suspend_handler(
1249 SCIC_SDS_REMOTE_DEVICE_T *this_device,
1254 sci_base_object_get_logger(this_device),
1255 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1256 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1257 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1258 "SCIC Remote Device 0x%x requested to suspend %d while in wrong state %d\n",
1259 this_device, suspend_type,
1260 sci_base_state_machine_get_state(
1261 scic_sds_remote_device_get_base_state_machine(this_device))
1264 return SCI_FAILURE_INVALID_STATE;
1268 * This method is the default resume handler. It logs a warning and returns a
1271 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1272 * SCIC_SDS_REMOTE_DEVICE.
1274 * @return SCI_STATUS
1275 * @retval SCI_FAILURE_INVALID_STATE
1277 SCI_STATUS scic_sds_remote_device_default_resume_handler(
1278 SCIC_SDS_REMOTE_DEVICE_T *this_device
1282 sci_base_object_get_logger(this_device),
1283 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1284 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1285 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1286 "SCIC Remote Device requested to resume while in wrong state %d\n",
1287 sci_base_state_machine_get_state(
1288 scic_sds_remote_device_get_base_state_machine(this_device))
1291 return SCI_FAILURE_INVALID_STATE;
1294 #if defined(SCI_LOGGING)
1296 * This is a private method for emitting log messages related to events reported
1297 * to the remote device from the controller object.
1299 * @param [in] this_device This is the device object that is receiving the
1301 * @param [in] event_code The event code to process.
1305 static void scic_sds_emit_event_log_message(
1306 SCIC_SDS_REMOTE_DEVICE_T * this_device,
1308 char * message_guts,
1313 sci_base_object_get_logger(this_device),
1314 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1315 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1316 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1317 "SCIC Remote device 0x%x (state %d) received %s %x while in the %sready %s%d\n",
1319 sci_base_state_machine_get_state(
1320 scic_sds_remote_device_get_base_state_machine(this_device)),
1321 message_guts, event_code,
1325 (this_device->has_ready_substate_machine)
1328 (this_device->has_ready_substate_machine)
1329 ? sci_base_state_machine_get_state(&this_device->ready_substate_machine)
1333 #else // defined(SCI_LOGGING)
1334 #define scic_sds_emit_event_log_message(device, event_code, message, state)
1335 #endif // defined(SCI_LOGGING)
1338 * This method is the default event handler. It will call the RNC state
1339 * machine handler for any RNC events otherwise it will log a warning and
1340 * returns a failure.
1342 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1343 * SCIC_SDS_REMOTE_DEVICE.
1344 * @param[in] event_code The event code that the SCIC_SDS_CONTROLLER wants the
1345 * device object to process.
1347 * @return SCI_STATUS
1348 * @retval SCI_FAILURE_INVALID_STATE
1351 SCI_STATUS scic_sds_remote_device_core_event_handler(
1352 SCIC_SDS_REMOTE_DEVICE_T *this_device,
1359 switch (scu_get_event_type(event_code))
1361 case SCU_EVENT_TYPE_RNC_OPS_MISC:
1362 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
1363 case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
1364 status = scic_sds_remote_node_context_event_handler(this_device->rnc, event_code);
1366 case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
1368 if( scu_get_event_code(event_code) == SCU_EVENT_IT_NEXUS_TIMEOUT )
1370 status = SCI_SUCCESS;
1372 // Suspend the associated RNC
1373 scic_sds_remote_node_context_suspend( this_device->rnc,
1374 SCI_SOFTWARE_SUSPENSION,
1377 scic_sds_emit_event_log_message(
1378 this_device, event_code,
1380 ? "I_T_Nexus_Timeout event"
1381 : "I_T_Nexus_Timeout event in wrong state",
1386 // Else, fall through and treat as unhandled...
1389 scic_sds_emit_event_log_message( this_device, event_code,
1391 ? "unexpected event"
1392 : "unexpected event in wrong state",
1394 status = SCI_FAILURE_INVALID_STATE;
1401 * This method is the default event handler. It will call the RNC state
1402 * machine handler for any RNC events otherwise it will log a warning and
1403 * returns a failure.
1405 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1406 * SCIC_SDS_REMOTE_DEVICE.
1407 * @param[in] event_code The event code that the SCIC_SDS_CONTROLLER wants the
1408 * device object to process.
1410 * @return SCI_STATUS
1411 * @retval SCI_FAILURE_INVALID_STATE
1413 SCI_STATUS scic_sds_remote_device_default_event_handler(
1414 SCIC_SDS_REMOTE_DEVICE_T *this_device,
1418 return scic_sds_remote_device_core_event_handler( this_device,
1424 * This method is the default unsolicited frame handler. It logs a warning,
1425 * releases the frame and returns a failure.
1427 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1428 * SCIC_SDS_REMOTE_DEVICE.
1429 * @param[in] frame_index The frame index for which the SCIC_SDS_CONTROLLER
1430 * wants this device object to process.
1432 * @return SCI_STATUS
1433 * @retval SCI_FAILURE_INVALID_STATE
1435 SCI_STATUS scic_sds_remote_device_default_frame_handler(
1436 SCIC_SDS_REMOTE_DEVICE_T *this_device,
1441 sci_base_object_get_logger(this_device),
1442 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1443 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1444 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1445 "SCIC Remote Device requested to handle frame %x while in wrong state %d\n",
1447 sci_base_state_machine_get_state(&this_device->parent.state_machine)
1450 // Return the frame back to the controller
1451 scic_sds_controller_release_frame(
1452 scic_sds_remote_device_get_controller(this_device), frame_index
1455 return SCI_FAILURE_INVALID_STATE;
1459 * This method is the default start io handler. It logs a warning and returns
1462 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1463 * SCIC_SDS_REMOTE_DEVICE.
1464 * @param[in] request The SCI_BASE_REQUEST which is then cast into a
1465 * SCIC_SDS_IO_REQUEST to start.
1467 * @return SCI_STATUS
1468 * @retval SCI_FAILURE_INVALID_STATE
1470 SCI_STATUS scic_sds_remote_device_default_start_request_handler(
1471 SCI_BASE_REMOTE_DEVICE_T *device,
1472 SCI_BASE_REQUEST_T *request
1476 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1477 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1478 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1479 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1480 "SCIC Remote Device requested to start io request %x while in wrong state %d\n",
1482 sci_base_state_machine_get_state(
1483 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1486 return SCI_FAILURE_INVALID_STATE;
1490 * This method is the default complete io handler. It logs a warning and
1491 * returns a failure.
1493 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1494 * SCIC_SDS_REMOTE_DEVICE.
1495 * @param[in] request The SCI_BASE_REQUEST which is then cast into a
1496 * SCIC_SDS_IO_REQUEST to complete.
1499 * @return SCI_STATUS
1500 * @retval SCI_FAILURE_INVALID_STATE
1502 SCI_STATUS scic_sds_remote_device_default_complete_request_handler(
1503 SCI_BASE_REMOTE_DEVICE_T *device,
1504 SCI_BASE_REQUEST_T *request
1508 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1509 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1510 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1511 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1512 "SCIC Remote Device requested to complete io_request %x while in wrong state %d\n",
1514 sci_base_state_machine_get_state(
1515 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1518 return SCI_FAILURE_INVALID_STATE;
1522 * This method is the default continue io handler. It logs a warning and
1523 * returns a failure.
1525 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1526 * SCIC_SDS_REMOTE_DEVICE.
1527 * @param[in] request The SCI_BASE_REQUEST which is then cast into a
1528 * SCIC_SDS_IO_REQUEST to continue.
1530 * @return SCI_STATUS
1531 * @retval SCI_FAILURE_INVALID_STATE
1533 SCI_STATUS scic_sds_remote_device_default_continue_request_handler(
1534 SCI_BASE_REMOTE_DEVICE_T *device,
1535 SCI_BASE_REQUEST_T *request
1539 sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1540 SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1541 SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1542 SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1543 "SCIC Remote Device requested to continue io request %x while in wrong state %d\n",
1545 sci_base_state_machine_get_state(
1546 scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1549 return SCI_FAILURE_INVALID_STATE;
1553 * This method is the general suspend handler.
1555 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1556 * SCIC_SDS_REMOTE_DEVICE.
1558 * @return SCI_STATUS
1559 * @retval SCI_FAILURE_INVALID_STATE
1562 SCI_STATUS scic_sds_remote_device_general_suspend_handler(
1563 SCIC_SDS_REMOTE_DEVICE_T *this_device,
1567 return scic_sds_remote_node_context_suspend(this_device->rnc, suspend_type, NULL, NULL);
1571 * This method is the general suspend handler. It logs a warning and returns
1574 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1575 * SCIC_SDS_REMOTE_DEVICE.
1577 * @return SCI_STATUS
1578 * @retval SCI_FAILURE_INVALID_STATE
1581 SCI_STATUS scic_sds_remote_device_general_resume_handler(
1582 SCIC_SDS_REMOTE_DEVICE_T *this_device
1585 return scic_sds_remote_node_context_resume(this_device->rnc, NULL, NULL);
1588 //*****************************************************************************
1589 //* NORMAL STATE HANDLERS
1590 //*****************************************************************************
1593 * This method is a general ssp frame handler. In most cases the device
1594 * object needs to route the unsolicited frame processing to the io request
1595 * object. This method decodes the tag for the io request object and routes
1596 * the unsolicited frame to that object.
1598 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1599 * SCIC_SDS_REMOTE_DEVICE.
1600 * @param[in] frame_index The frame index for which the SCIC_SDS_CONTROLLER
1601 * wants this device object to process.
1603 * @return SCI_STATUS
1604 * @retval SCI_FAILURE_INVALID_STATE
1606 SCI_STATUS scic_sds_remote_device_general_frame_handler(
1607 SCIC_SDS_REMOTE_DEVICE_T *this_device,
1612 SCI_SSP_FRAME_HEADER_T *frame_header;
1613 SCIC_SDS_REQUEST_T *io_request;
1615 result = scic_sds_unsolicited_frame_control_get_header(
1616 &(scic_sds_remote_device_get_controller(this_device)->uf_control),
1618 (void **)&frame_header
1621 if (SCI_SUCCESS == result)
1623 io_request = scic_sds_controller_get_io_request_from_tag(
1624 scic_sds_remote_device_get_controller(this_device), frame_header->tag);
1626 if ( (io_request == SCI_INVALID_HANDLE)
1627 || (io_request->target_device != this_device) )
1629 // We could not map this tag to a valid IO request
1630 // Just toss the frame and continue
1631 scic_sds_controller_release_frame(
1632 scic_sds_remote_device_get_controller(this_device), frame_index
1637 // The IO request is now in charge of releasing the frame
1638 result = io_request->state_handlers->frame_handler(
1639 io_request, frame_index);
1647 * This is a common method for handling events reported to the remote device
1648 * from the controller object.
1650 * @param [in] this_device This is the device object that is receiving the
1652 * @param [in] event_code The event code to process.
1654 * @return SCI_STATUS
1656 SCI_STATUS scic_sds_remote_device_general_event_handler(
1657 SCIC_SDS_REMOTE_DEVICE_T * this_device,
1661 return scic_sds_remote_device_core_event_handler( this_device,
1666 //*****************************************************************************
1667 //* STOPPED STATE HANDLERS
1668 //*****************************************************************************
1671 * This method takes the SCIC_SDS_REMOTE_DEVICE from a stopped state and
1672 * attempts to start it. The RNC buffer for the device is constructed and
1673 * the device state machine is transitioned to the
1674 * SCIC_BASE_REMOTE_DEVICE_STATE_STARTING.
1678 * @return SCI_STATUS
1679 * @retval SCI_SUCCESS if there is an RNC buffer available to construct the
1681 * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if there is no RNC buffer
1682 * available in which to construct the remote device.
1685 SCI_STATUS scic_sds_remote_device_stopped_state_start_handler(
1686 SCI_BASE_REMOTE_DEVICE_T *device
1690 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1692 status = scic_sds_remote_node_context_resume(
1694 scic_sds_remote_device_resume_complete_handler,
1698 if (status == SCI_SUCCESS)
1700 sci_base_state_machine_change_state(
1701 scic_sds_remote_device_get_base_state_machine(this_device),
1702 SCI_BASE_REMOTE_DEVICE_STATE_STARTING
1710 * This method will stop a SCIC_SDS_REMOTE_DEVICE that is already in a stopped
1711 * state. This is not considered an error since the device is already
1714 * @param[in] this_device The SCI_BASE_REMOTE_DEVICE which is cast into a
1715 * SCIC_SDS_REMOTE_DEVICE.
1717 * @return SCI_STATUS
1718 * @retval SCI_SUCCESS
1721 SCI_STATUS scic_sds_remote_device_stopped_state_stop_handler(
1722 SCI_BASE_REMOTE_DEVICE_T *this_device
1729 * This method will destruct a SCIC_SDS_REMOTE_DEVICE that is in a stopped
1730 * state. This is the only state from which a destruct request will succeed.
1731 * The RNi for this SCIC_SDS_REMOTE_DEVICE is returned to the free pool and
1732 * the device object transitions to the SCI_BASE_REMOTE_DEVICE_STATE_FINAL.
1734 * @param[in] this_device The SCI_BASE_REMOTE_DEVICE which is cast into a
1735 * SCIC_SDS_REMOTE_DEVICE.
1737 * @return SCI_STATUS
1738 * @retval SCI_SUCCESS
1741 SCI_STATUS scic_sds_remote_device_stopped_state_destruct_handler(
1742 SCI_BASE_REMOTE_DEVICE_T *device
1745 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1747 SCIC_SDS_CONTROLLER_T * the_controller =
1748 scic_sds_remote_device_get_controller(this_device);
1750 the_controller->remote_device_sequence[this_device->rnc->remote_node_index]++;
1752 scic_sds_controller_free_remote_node_context(
1755 this_device->rnc->remote_node_index
1758 scic_sds_remote_node_context_set_remote_node_index(
1760 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
1763 sci_base_state_machine_change_state(
1764 scic_sds_remote_device_get_base_state_machine(this_device),
1765 SCI_BASE_REMOTE_DEVICE_STATE_FINAL
1768 scic_sds_remote_device_deinitialize_state_logging(this_device);
1773 //*****************************************************************************
1774 //* STARTING STATE HANDLERS
1775 //*****************************************************************************
1778 SCI_STATUS scic_sds_remote_device_starting_state_stop_handler(
1779 SCI_BASE_REMOTE_DEVICE_T *device
1782 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1785 * This device has not yet started so there had better be no IO requests
1787 ASSERT(this_device->started_request_count == 0);
1790 * Destroy the remote node context
1792 scic_sds_remote_node_context_destruct(
1794 scic_sds_cb_remote_device_rnc_destruct_complete,
1799 * Transition to the stopping state and wait for the remote node to
1800 * complete being posted and invalidated.
1802 sci_base_state_machine_change_state(
1803 scic_sds_remote_device_get_base_state_machine(this_device),
1804 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
1810 //*****************************************************************************
1811 //* INITIALIZING STATE HANDLERS
1812 //*****************************************************************************
1814 /* There is nothing to do here for SSP devices */
1816 //*****************************************************************************
1817 //* READY STATE HANDLERS
1818 //*****************************************************************************
1821 * This method is the default stop handler for the SCIC_SDS_REMOTE_DEVICE
1822 * ready substate machine. It will stop the current substate machine and
1823 * transition the base state machine to SCI_BASE_REMOTE_DEVICE_STATE_STOPPING.
1825 * @param[in] device The SCI_BASE_REMOTE_DEVICE object which is cast to a
1826 * SCIC_SDS_REMOTE_DEVICE object.
1828 * @return SCI_STATUS
1829 * @retval SCI_SUCCESS
1831 SCI_STATUS scic_sds_remote_device_ready_state_stop_handler(
1832 SCI_BASE_REMOTE_DEVICE_T *device
1835 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1836 SCI_STATUS status = SCI_SUCCESS;
1838 // Request the parent state machine to transition to the stopping state
1839 sci_base_state_machine_change_state(
1840 scic_sds_remote_device_get_base_state_machine(this_device),
1841 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
1844 if (this_device->started_request_count == 0)
1846 scic_sds_remote_node_context_destruct(
1848 scic_sds_cb_remote_device_rnc_destruct_complete,
1853 status = scic_sds_remote_device_terminate_requests(this_device);
1859 * This is the ready state device reset handler
1861 * @param[in] device The SCI_BASE_REMOTE_DEVICE object which is cast to a
1862 * SCIC_SDS_REMOTE_DEVICE object.
1864 * @return SCI_STATUS
1866 SCI_STATUS scic_sds_remote_device_ready_state_reset_handler(
1867 SCI_BASE_REMOTE_DEVICE_T *device
1870 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1872 // Request the parent state machine to transition to the stopping state
1873 sci_base_state_machine_change_state(
1874 scic_sds_remote_device_get_base_state_machine(this_device),
1875 SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
1882 * This method will attempt to start a task request for this device object.
1883 * The remote device object will issue the start request for the task and if
1884 * successful it will start the request for the port object then increment its
1887 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is cast to a
1888 * SCIC_SDS_REMOTE_DEVICE for which the request is to be started.
1889 * @param[in] request The SCI_BASE_REQUEST which is cast to a
1890 * SCIC_SDS_IO_REQUEST that is to be started.
1892 * @return SCI_STATUS
1893 * @retval SCI_SUCCESS if the task request is started for this device object.
1894 * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request object could
1895 * not get the resources to start.
1898 SCI_STATUS scic_sds_remote_device_ready_state_start_task_handler(
1899 SCI_BASE_REMOTE_DEVICE_T *device,
1900 SCI_BASE_REQUEST_T *request
1904 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1905 SCIC_SDS_REQUEST_T *task_request = (SCIC_SDS_REQUEST_T *)request;
1907 // See if the port is in a state where we can start the IO request
1908 result = scic_sds_port_start_io(
1909 scic_sds_remote_device_get_port(this_device), this_device, task_request);
1911 if (result == SCI_SUCCESS)
1913 result = scic_sds_remote_node_context_start_task(
1914 this_device->rnc, task_request
1917 if (result == SCI_SUCCESS)
1919 result = scic_sds_request_start(task_request);
1922 scic_sds_remote_device_start_request(this_device, task_request, result);
1929 * This method will attempt to start an io request for this device object. The
1930 * remote device object will issue the start request for the io and if
1931 * successful it will start the request for the port object then increment its
1934 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is cast to a
1935 * SCIC_SDS_REMOTE_DEVICE for which the request is to be started.
1936 * @param[in] request The SCI_BASE_REQUEST which is cast to a
1937 * SCIC_SDS_IO_REQUEST that is to be started.
1939 * @return SCI_STATUS
1940 * @retval SCI_SUCCESS if the io request is started for this device object.
1941 * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request object could
1942 * not get the resources to start.
1945 SCI_STATUS scic_sds_remote_device_ready_state_start_io_handler(
1946 SCI_BASE_REMOTE_DEVICE_T *device,
1947 SCI_BASE_REQUEST_T *request
1951 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1952 SCIC_SDS_REQUEST_T *io_request = (SCIC_SDS_REQUEST_T *)request;
1954 // See if the port is in a state where we can start the IO request
1955 result = scic_sds_port_start_io(
1956 scic_sds_remote_device_get_port(this_device), this_device, io_request);
1958 if (result == SCI_SUCCESS)
1960 result = scic_sds_remote_node_context_start_io(
1961 this_device->rnc, io_request
1964 if (result == SCI_SUCCESS)
1966 result = scic_sds_request_start(io_request);
1969 scic_sds_remote_device_start_request(this_device, io_request, result);
1976 * This method will complete the request for the remote device object. The
1977 * method will call the completion handler for the request object and if
1978 * successful it will complete the request on the port object then decrement
1979 * its own started_request_count.
1981 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is cast to a
1982 * SCIC_SDS_REMOTE_DEVICE for which the request is to be completed.
1983 * @param[in] request The SCI_BASE_REQUEST which is cast to a
1984 * SCIC_SDS_IO_REQUEST that is to be completed.
1986 * @return SCI_STATUS
1989 SCI_STATUS scic_sds_remote_device_ready_state_complete_request_handler(
1990 SCI_BASE_REMOTE_DEVICE_T *device,
1991 SCI_BASE_REQUEST_T *request
1995 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1996 SCIC_SDS_REQUEST_T *the_request = (SCIC_SDS_REQUEST_T *)request;
1998 result = scic_sds_request_complete(the_request);
2000 if (result == SCI_SUCCESS)
2002 // See if the port is in a state where we can start the IO request
2003 result = scic_sds_port_complete_io(
2004 scic_sds_remote_device_get_port(this_device), this_device, the_request);
2006 if (result == SCI_SUCCESS)
2008 scic_sds_remote_device_decrement_request_count(this_device);
2015 //*****************************************************************************
2016 //* STOPPING STATE HANDLERS
2017 //*****************************************************************************
2020 * This method will stop a SCIC_SDS_REMOTE_DEVICE that is already in the
2021 * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This is not considered an
2022 * error since we allow a stop request on a device that is alreay stopping or
2025 * @param[in] this_device The SCI_BASE_REMOTE_DEVICE which is cast into a
2026 * SCIC_SDS_REMOTE_DEVICE.
2028 * @return SCI_STATUS
2029 * @retval SCI_SUCCESS
2032 SCI_STATUS scic_sds_remote_device_stopping_state_stop_handler(
2033 SCI_BASE_REMOTE_DEVICE_T *device
2036 // All requests should have been terminated, but if there is an
2037 // attempt to stop a device already in the stopping state, then
2038 // try again to terminate.
2039 return scic_sds_remote_device_terminate_requests(
2040 (SCIC_SDS_REMOTE_DEVICE_T*)device);
2045 * This method completes requests for this SCIC_SDS_REMOTE_DEVICE while it is
2046 * in the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This method calls the
2047 * complete method for the request object and if that is successful the port
2048 * object is called to complete the task request. Then the device object
2049 * itself completes the task request. If SCIC_SDS_REMOTE_DEVICE
2050 * started_request_count goes to 0 and the invalidate RNC request has
2051 * completed the device object can transition to the
2052 * SCI_BASE_REMOTE_DEVICE_STATE_STOPPED.
2054 * @param[in] device The device object for which the request is completing.
2055 * @param[in] request The task request that is being completed.
2057 * @return SCI_STATUS
2060 SCI_STATUS scic_sds_remote_device_stopping_state_complete_request_handler(
2061 SCI_BASE_REMOTE_DEVICE_T *device,
2062 SCI_BASE_REQUEST_T *request
2065 SCI_STATUS status = SCI_SUCCESS;
2066 SCIC_SDS_REQUEST_T *this_request = (SCIC_SDS_REQUEST_T *)request;
2067 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2069 status = scic_sds_request_complete(this_request);
2070 if (status == SCI_SUCCESS)
2072 status = scic_sds_port_complete_io(
2073 scic_sds_remote_device_get_port(this_device),
2078 if (status == SCI_SUCCESS)
2080 scic_sds_remote_device_decrement_request_count(this_device);
2082 if (scic_sds_remote_device_get_request_count(this_device) == 0)
2084 scic_sds_remote_node_context_destruct(
2086 scic_sds_cb_remote_device_rnc_destruct_complete,
2096 //*****************************************************************************
2097 //* RESETTING STATE HANDLERS
2098 //*****************************************************************************
2101 * This method will complete the reset operation when the device is in the
2104 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is to be cast into a
2105 * SCIC_SDS_REMOTE_DEVICE object.
2107 * @return SCI_STATUS
2110 SCI_STATUS scic_sds_remote_device_resetting_state_reset_complete_handler(
2111 SCI_BASE_REMOTE_DEVICE_T * device
2114 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2116 sci_base_state_machine_change_state(
2117 &this_device->parent.state_machine,
2118 SCI_BASE_REMOTE_DEVICE_STATE_READY
2125 * This method will stop the remote device while in the resetting state.
2127 * @param[in] device The SCI_BASE_REMOTE_DEVICE which is to be cast into a
2128 * SCIC_SDS_REMOTE_DEVICE object.
2130 * @return SCI_STATUS
2133 SCI_STATUS scic_sds_remote_device_resetting_state_stop_handler(
2134 SCI_BASE_REMOTE_DEVICE_T * device
2137 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2139 sci_base_state_machine_change_state(
2140 &this_device->parent.state_machine,
2141 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
2148 * This method completes requests for this SCIC_SDS_REMOTE_DEVICE while it is
2149 * in the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING state. This method calls the
2150 * complete method for the request object and if that is successful the port
2151 * object is called to complete the task request. Then the device object
2152 * itself completes the task request.
2154 * @param[in] device The device object for which the request is completing.
2155 * @param[in] request The task request that is being completed.
2157 * @return SCI_STATUS
2160 SCI_STATUS scic_sds_remote_device_resetting_state_complete_request_handler(
2161 SCI_BASE_REMOTE_DEVICE_T *device,
2162 SCI_BASE_REQUEST_T *request
2165 SCI_STATUS status = SCI_SUCCESS;
2166 SCIC_SDS_REQUEST_T *this_request = (SCIC_SDS_REQUEST_T *)request;
2167 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2169 status = scic_sds_request_complete(this_request);
2171 if (status == SCI_SUCCESS)
2173 status = scic_sds_port_complete_io(
2174 scic_sds_remote_device_get_port(this_device), this_device, this_request);
2176 if (status == SCI_SUCCESS)
2178 scic_sds_remote_device_decrement_request_count(this_device);
2185 //*****************************************************************************
2186 //* FAILED STATE HANDLERS
2187 //*****************************************************************************
2189 SCIC_SDS_REMOTE_DEVICE_STATE_HANDLER_T
2190 scic_sds_remote_device_state_handler_table[SCI_BASE_REMOTE_DEVICE_MAX_STATES] =
2192 // SCI_BASE_REMOTE_DEVICE_STATE_INITIAL
2195 scic_sds_remote_device_default_start_handler,
2196 scic_sds_remote_device_default_stop_handler,
2197 scic_sds_remote_device_default_fail_handler,
2198 scic_sds_remote_device_default_destruct_handler,
2199 scic_sds_remote_device_default_reset_handler,
2200 scic_sds_remote_device_default_reset_complete_handler,
2201 scic_sds_remote_device_default_start_request_handler,
2202 scic_sds_remote_device_default_complete_request_handler,
2203 scic_sds_remote_device_default_continue_request_handler,
2204 scic_sds_remote_device_default_start_request_handler,
2205 scic_sds_remote_device_default_complete_request_handler
2207 scic_sds_remote_device_default_suspend_handler,
2208 scic_sds_remote_device_default_resume_handler,
2209 scic_sds_remote_device_default_event_handler,
2210 scic_sds_remote_device_default_frame_handler
2212 // SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
2215 scic_sds_remote_device_stopped_state_start_handler,
2216 scic_sds_remote_device_stopped_state_stop_handler,
2217 scic_sds_remote_device_default_fail_handler,
2218 scic_sds_remote_device_stopped_state_destruct_handler,
2219 scic_sds_remote_device_default_reset_handler,
2220 scic_sds_remote_device_default_reset_complete_handler,
2221 scic_sds_remote_device_default_start_request_handler,
2222 scic_sds_remote_device_default_complete_request_handler,
2223 scic_sds_remote_device_default_continue_request_handler,
2224 scic_sds_remote_device_default_start_request_handler,
2225 scic_sds_remote_device_default_complete_request_handler
2227 scic_sds_remote_device_default_suspend_handler,
2228 scic_sds_remote_device_default_resume_handler,
2229 scic_sds_remote_device_default_event_handler,
2230 scic_sds_remote_device_default_frame_handler
2232 // SCI_BASE_REMOTE_DEVICE_STATE_STARTING
2235 scic_sds_remote_device_default_start_handler,
2236 scic_sds_remote_device_starting_state_stop_handler,
2237 scic_sds_remote_device_default_fail_handler,
2238 scic_sds_remote_device_default_destruct_handler,
2239 scic_sds_remote_device_default_reset_handler,
2240 scic_sds_remote_device_default_reset_complete_handler,
2241 scic_sds_remote_device_default_start_request_handler,
2242 scic_sds_remote_device_default_complete_request_handler,
2243 scic_sds_remote_device_default_continue_request_handler,
2244 scic_sds_remote_device_default_start_request_handler,
2245 scic_sds_remote_device_default_complete_request_handler
2247 scic_sds_remote_device_default_suspend_handler,
2248 scic_sds_remote_device_default_resume_handler,
2249 scic_sds_remote_device_general_event_handler,
2250 scic_sds_remote_device_default_frame_handler
2252 // SCI_BASE_REMOTE_DEVICE_STATE_READY
2255 scic_sds_remote_device_default_start_handler,
2256 scic_sds_remote_device_ready_state_stop_handler,
2257 scic_sds_remote_device_default_fail_handler,
2258 scic_sds_remote_device_default_destruct_handler,
2259 scic_sds_remote_device_ready_state_reset_handler,
2260 scic_sds_remote_device_default_reset_complete_handler,
2261 scic_sds_remote_device_ready_state_start_io_handler,
2262 scic_sds_remote_device_ready_state_complete_request_handler,
2263 scic_sds_remote_device_default_continue_request_handler,
2264 scic_sds_remote_device_ready_state_start_task_handler,
2265 scic_sds_remote_device_ready_state_complete_request_handler
2267 scic_sds_remote_device_general_suspend_handler,
2268 scic_sds_remote_device_general_resume_handler,
2269 scic_sds_remote_device_general_event_handler,
2270 scic_sds_remote_device_general_frame_handler,
2272 // SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
2275 scic_sds_remote_device_default_start_handler,
2276 scic_sds_remote_device_stopping_state_stop_handler,
2277 scic_sds_remote_device_default_fail_handler,
2278 scic_sds_remote_device_default_destruct_handler,
2279 scic_sds_remote_device_default_reset_handler,
2280 scic_sds_remote_device_default_reset_complete_handler,
2281 scic_sds_remote_device_default_start_request_handler,
2282 scic_sds_remote_device_stopping_state_complete_request_handler,
2283 scic_sds_remote_device_default_continue_request_handler,
2284 scic_sds_remote_device_default_start_request_handler,
2285 scic_sds_remote_device_stopping_state_complete_request_handler
2287 scic_sds_remote_device_default_suspend_handler,
2288 scic_sds_remote_device_default_resume_handler,
2289 scic_sds_remote_device_general_event_handler,
2290 scic_sds_remote_device_general_frame_handler
2292 // SCI_BASE_REMOTE_DEVICE_STATE_FAILED
2295 scic_sds_remote_device_default_start_handler,
2296 scic_sds_remote_device_default_stop_handler,
2297 scic_sds_remote_device_default_fail_handler,
2298 scic_sds_remote_device_default_destruct_handler,
2299 scic_sds_remote_device_default_reset_handler,
2300 scic_sds_remote_device_default_reset_complete_handler,
2301 scic_sds_remote_device_default_start_request_handler,
2302 scic_sds_remote_device_default_complete_request_handler,
2303 scic_sds_remote_device_default_continue_request_handler,
2304 scic_sds_remote_device_default_start_request_handler,
2305 scic_sds_remote_device_default_complete_request_handler
2307 scic_sds_remote_device_default_suspend_handler,
2308 scic_sds_remote_device_default_resume_handler,
2309 scic_sds_remote_device_default_event_handler,
2310 scic_sds_remote_device_general_frame_handler
2312 // SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
2315 scic_sds_remote_device_default_start_handler,
2316 scic_sds_remote_device_resetting_state_stop_handler,
2317 scic_sds_remote_device_default_fail_handler,
2318 scic_sds_remote_device_default_destruct_handler,
2319 scic_sds_remote_device_default_reset_handler,
2320 scic_sds_remote_device_resetting_state_reset_complete_handler,
2321 scic_sds_remote_device_default_start_request_handler,
2322 scic_sds_remote_device_resetting_state_complete_request_handler,
2323 scic_sds_remote_device_default_continue_request_handler,
2324 scic_sds_remote_device_default_start_request_handler,
2325 scic_sds_remote_device_resetting_state_complete_request_handler
2327 scic_sds_remote_device_default_suspend_handler,
2328 scic_sds_remote_device_default_resume_handler,
2329 scic_sds_remote_device_default_event_handler,
2330 scic_sds_remote_device_general_frame_handler
2332 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
2333 // SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH - unused by SCIC
2336 scic_sds_remote_device_default_start_handler,
2337 scic_sds_remote_device_default_stop_handler,
2338 scic_sds_remote_device_default_fail_handler,
2339 scic_sds_remote_device_default_destruct_handler,
2340 scic_sds_remote_device_default_reset_handler,
2341 scic_sds_remote_device_default_reset_complete_handler,
2342 scic_sds_remote_device_default_start_request_handler,
2343 scic_sds_remote_device_default_complete_request_handler,
2344 scic_sds_remote_device_default_continue_request_handler,
2345 scic_sds_remote_device_default_start_request_handler,
2346 scic_sds_remote_device_default_complete_request_handler
2348 scic_sds_remote_device_default_suspend_handler,
2349 scic_sds_remote_device_default_resume_handler,
2350 scic_sds_remote_device_default_event_handler,
2351 scic_sds_remote_device_default_frame_handler
2354 // SCI_BASE_REMOTE_DEVICE_STATE_FINAL
2357 scic_sds_remote_device_default_start_handler,
2358 scic_sds_remote_device_default_stop_handler,
2359 scic_sds_remote_device_default_fail_handler,
2360 scic_sds_remote_device_default_destruct_handler,
2361 scic_sds_remote_device_default_reset_handler,
2362 scic_sds_remote_device_default_reset_complete_handler,
2363 scic_sds_remote_device_default_start_request_handler,
2364 scic_sds_remote_device_default_complete_request_handler,
2365 scic_sds_remote_device_default_continue_request_handler,
2366 scic_sds_remote_device_default_start_request_handler,
2367 scic_sds_remote_device_default_complete_request_handler
2369 scic_sds_remote_device_default_suspend_handler,
2370 scic_sds_remote_device_default_resume_handler,
2371 scic_sds_remote_device_default_event_handler,
2372 scic_sds_remote_device_default_frame_handler
2377 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it
2378 * immediately transitions the remote device object to the stopped state.
2380 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2381 * SCIC_SDS_REMOTE_DEVICE.
2386 void scic_sds_remote_device_initial_state_enter(
2387 SCI_BASE_OBJECT_T *object
2390 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2394 scic_sds_remote_device_state_handler_table,
2395 SCI_BASE_REMOTE_DEVICE_STATE_INITIAL
2398 // Initial state is a transitional state to the stopped state
2399 sci_base_state_machine_change_state(
2400 scic_sds_remote_device_get_base_state_machine(this_device),
2401 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
2406 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it
2407 * sets the stopped state handlers and if this state is entered from the
2408 * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING then the SCI User is informed that
2409 * the device stop is complete.
2411 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2412 * SCIC_SDS_REMOTE_DEVICE.
2417 void scic_sds_remote_device_stopped_state_enter(
2418 SCI_BASE_OBJECT_T *object
2421 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2425 scic_sds_remote_device_state_handler_table,
2426 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
2429 // If we are entering from the stopping state let the SCI User know that
2430 // the stop operation has completed.
2431 if (this_device->parent.state_machine.previous_state_id
2432 == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING)
2434 scic_cb_remote_device_stop_complete(
2435 scic_sds_remote_device_get_controller(this_device),
2441 scic_sds_controller_remote_device_stopped(
2442 scic_sds_remote_device_get_controller(this_device),
2448 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it
2449 * sets the starting state handlers, sets the device not ready, and posts the
2450 * remote node context to the hardware.
2452 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2453 * SCIC_SDS_REMOTE_DEVICE.
2458 void scic_sds_remote_device_starting_state_enter(
2459 SCI_BASE_OBJECT_T *object
2462 SCIC_SDS_CONTROLLER_T * the_controller;
2463 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2465 the_controller = scic_sds_remote_device_get_controller(this_device);
2469 scic_sds_remote_device_state_handler_table,
2470 SCI_BASE_REMOTE_DEVICE_STATE_STARTING
2473 scic_cb_remote_device_not_ready(
2476 SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED
2482 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets
2483 * the ready state handlers, and starts the ready substate machine.
2485 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2486 * SCIC_SDS_REMOTE_DEVICE.
2491 void scic_sds_remote_device_ready_state_enter(
2492 SCI_BASE_OBJECT_T *object
2495 SCIC_SDS_CONTROLLER_T * the_controller;
2496 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2498 the_controller = scic_sds_remote_device_get_controller(this_device);
2502 scic_sds_remote_device_state_handler_table,
2503 SCI_BASE_REMOTE_DEVICE_STATE_READY
2506 /// @todo Check the device object for the proper return code for this
2508 scic_cb_remote_device_start_complete(
2509 the_controller, this_device, SCI_SUCCESS
2512 scic_sds_controller_remote_device_started(
2513 the_controller, this_device
2516 if (this_device->has_ready_substate_machine)
2518 sci_base_state_machine_start(&this_device->ready_substate_machine);
2522 scic_cb_remote_device_ready(the_controller, this_device);
2527 * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_READY it does
2530 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2531 * SCIC_SDS_REMOTE_DEVICE.
2536 void scic_sds_remote_device_ready_state_exit(
2537 SCI_BASE_OBJECT_T *object
2540 SCIC_SDS_CONTROLLER_T * the_controller;
2541 SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2543 the_controller = scic_sds_remote_device_get_controller(this_device);
2545 if (this_device->has_ready_substate_machine)
2547 sci_base_state_machine_stop(&this_device->ready_substate_machine);
2551 scic_cb_remote_device_not_ready(
2554 SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED
2560 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING it
2561 * sets the stopping state handlers and posts an RNC invalidate request to the
2564 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2565 * SCIC_SDS_REMOTE_DEVICE.
2570 void scic_sds_remote_device_stopping_state_enter(
2571 SCI_BASE_OBJECT_T *object
2574 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2578 scic_sds_remote_device_state_handler_table,
2579 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
2584 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_FAILED it
2585 * sets the stopping state handlers.
2587 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2588 * SCIC_SDS_REMOTE_DEVICE.
2593 void scic_sds_remote_device_failed_state_enter(
2594 SCI_BASE_OBJECT_T *object
2597 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2601 scic_sds_remote_device_state_handler_table,
2602 SCI_BASE_REMOTE_DEVICE_STATE_FAILED
2607 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING it
2608 * sets the resetting state handlers.
2610 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2611 * SCIC_SDS_REMOTE_DEVICE.
2616 void scic_sds_remote_device_resetting_state_enter(
2617 SCI_BASE_OBJECT_T *object
2620 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2624 scic_sds_remote_device_state_handler_table,
2625 SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
2628 scic_sds_remote_node_context_suspend(
2629 this_device->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
2633 * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING it
2636 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2637 * SCIC_SDS_REMOTE_DEVICE.
2642 void scic_sds_remote_device_resetting_state_exit(
2643 SCI_BASE_OBJECT_T *object
2646 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2648 scic_sds_remote_node_context_resume(this_device->rnc, NULL, NULL);
2652 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_FINAL it sets
2653 * the final state handlers.
2655 * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2656 * SCIC_SDS_REMOTE_DEVICE.
2661 void scic_sds_remote_device_final_state_enter(
2662 SCI_BASE_OBJECT_T *object
2665 SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2669 scic_sds_remote_device_state_handler_table,
2670 SCI_BASE_REMOTE_DEVICE_STATE_FINAL
2674 // ---------------------------------------------------------------------------
2677 scic_sds_remote_device_state_table[SCI_BASE_REMOTE_DEVICE_MAX_STATES] =
2680 SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
2681 scic_sds_remote_device_initial_state_enter,
2685 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
2686 scic_sds_remote_device_stopped_state_enter,
2690 SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
2691 scic_sds_remote_device_starting_state_enter,
2695 SCI_BASE_REMOTE_DEVICE_STATE_READY,
2696 scic_sds_remote_device_ready_state_enter,
2697 scic_sds_remote_device_ready_state_exit
2700 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
2701 scic_sds_remote_device_stopping_state_enter,
2705 SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
2706 scic_sds_remote_device_failed_state_enter,
2710 SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
2711 scic_sds_remote_device_resetting_state_enter,
2712 scic_sds_remote_device_resetting_state_exit
2714 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
2715 { //Not used by SCIC
2716 SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH,
2720 #endif //#if !defined(DISABLE_WIDE_PORTED_TARGETS)
2722 SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
2723 scic_sds_remote_device_final_state_enter,