2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __FBSDID("$FreeBSD$");
59 * @brief This file contains all of the entrance and exit methods for each
60 * of the controller states defined by the SCI_BASE_CONTROLLER state
64 #include <dev/isci/scil/scic_controller.h>
66 #include <dev/isci/scil/scif_sas_logger.h>
67 #include <dev/isci/scil/scif_sas_controller.h>
69 //******************************************************************************
70 //* P R O T E C T E D M E T H O D S
71 //******************************************************************************
74 * @brief This method implements the actions taken when entering the
77 * @param[in] object This parameter specifies the base object for which
78 * the state transition is occurring. This is cast into a
79 * SCIF_SAS_CONTROLLER object in the method implementation.
84 void scif_sas_controller_initial_state_enter(
85 SCI_BASE_OBJECT_T * object
88 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
92 scif_sas_controller_state_handler_table,
93 SCI_BASE_CONTROLLER_STATE_INITIAL
98 * @brief This method implements the actions taken when entering the
101 * @param[in] object This parameter specifies the base object for which
102 * the state transition is occurring. This is cast into a
103 * SCIF_SAS_CONTROLLER object in the method implementation.
108 void scif_sas_controller_reset_state_enter(
109 SCI_BASE_OBJECT_T * object
112 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
118 scif_sas_controller_state_handler_table,
119 SCI_BASE_CONTROLLER_STATE_RESET
122 scif_sas_high_priority_request_queue_construct(
123 &fw_controller->hprq, sci_base_object_get_logger(fw_controller)
126 // Construct the abstract element pool. This pool will store the
127 // references to the framework's remote devices objects.
128 sci_abstract_element_pool_construct(
129 &fw_controller->free_remote_device_pool,
130 fw_controller->remote_device_pool_elements,
131 SCI_MAX_REMOTE_DEVICES
134 // Construct the domain objects.
135 for (index = 0; index < SCI_MAX_DOMAINS; index++)
137 scif_sas_domain_construct(
138 &fw_controller->domains[index], index, fw_controller
142 //Initialize SMP PHY MEMORY LIST.
143 sci_fast_list_init(&fw_controller->smp_phy_memory_list);
145 for (smp_phy_index = 0;
146 smp_phy_index < SCIF_SAS_SMP_PHY_COUNT;
149 sci_fast_list_element_init(
150 &fw_controller->smp_phy_array[smp_phy_index],
151 &(fw_controller->smp_phy_array[smp_phy_index].list_element)
154 //insert to owning device's smp phy list.
155 sci_fast_list_insert_tail(
156 (&(fw_controller->smp_phy_memory_list)),
157 (&(fw_controller->smp_phy_array[smp_phy_index].list_element))
161 scif_sas_controller_set_default_config_parameters(fw_controller);
163 fw_controller->internal_request_entries =
164 SCIF_SAS_MAX_INTERNAL_REQUEST_COUNT;
166 //@Todo: may need to verify all timers are released. Including domain's
167 //operation timer and all the Internal IO's timer.
169 //take care of the lock.
170 scif_cb_lock_disassociate(fw_controller, &fw_controller->hprq.lock);
174 * @brief This method implements the actions taken when entering the
175 * INITIALIZING state.
177 * @param[in] object This parameter specifies the base object for which
178 * the state transition is occurring. This is cast into a
179 * SCIF_SAS_CONTROLLER object in the method implementation.
184 void scif_sas_controller_initializing_state_enter(
185 SCI_BASE_OBJECT_T * object
188 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
192 scif_sas_controller_state_handler_table,
193 SCI_BASE_CONTROLLER_STATE_INITIALIZING
198 * @brief This method implements the actions taken when entering the
201 * @param[in] object This parameter specifies the base object for which
202 * the state transition is occurring. This is cast into a
203 * SCIF_SAS_CONTROLLER object in the method implementation.
208 void scif_sas_controller_initialized_state_enter(
209 SCI_BASE_OBJECT_T * object
212 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
216 scif_sas_controller_state_handler_table,
217 SCI_BASE_CONTROLLER_STATE_INITIALIZED
222 * @brief This method implements the actions taken when entering the
225 * @param[in] object This parameter specifies the base object for which
226 * the state transition is occurring. This is cast into a
227 * SCIF_SAS_CONTROLLER object in the method implementation.
232 void scif_sas_controller_starting_state_enter(
233 SCI_BASE_OBJECT_T * object
236 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
240 scif_sas_controller_state_handler_table,
241 SCI_BASE_CONTROLLER_STATE_STARTING
246 * @brief This method implements the actions taken when entering the
249 * @param[in] object This parameter specifies the base object for which
250 * the state transition is occurring. This is cast into a
251 * SCIF_SAS_CONTROLLER object in the method implementation.
256 void scif_sas_controller_ready_state_enter(
257 SCI_BASE_OBJECT_T * object
260 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
264 scif_sas_controller_state_handler_table,
265 SCI_BASE_CONTROLLER_STATE_READY
270 * @brief This method implements the actions taken when entering the
273 * @param[in] object This parameter specifies the base object for which
274 * the state transition is occurring. This is cast into a
275 * SCIF_SAS_CONTROLLER object in the method implementation.
280 void scif_sas_controller_stopping_state_enter(
281 SCI_BASE_OBJECT_T * object
284 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
288 scif_sas_controller_state_handler_table,
289 SCI_BASE_CONTROLLER_STATE_STOPPING
294 * @brief This method implements the actions taken when entering the
297 * @param[in] object This parameter specifies the base object for which
298 * the state transition is occurring. This is cast into a
299 * SCIF_SAS_CONTROLLER object in the method implementation.
304 void scif_sas_controller_stopped_state_enter(
305 SCI_BASE_OBJECT_T * object
308 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
312 scif_sas_controller_state_handler_table,
313 SCI_BASE_CONTROLLER_STATE_STOPPED
318 * @brief This method implements the actions taken when entering the
321 * @param[in] object This parameter specifies the base object for which
322 * the state transition is occurring. This is cast into a
323 * SCIF_SAS_CONTROLLER object in the method implementation.
328 void scif_sas_controller_resetting_state_enter(
329 SCI_BASE_OBJECT_T * object
332 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
336 scif_sas_controller_state_handler_table,
337 SCI_BASE_CONTROLLER_STATE_RESETTING
340 // Attempt to reset the core controller.
341 fw_controller->operation_status = scic_controller_reset(
342 fw_controller->core_object
344 if (fw_controller->operation_status == SCI_SUCCESS)
346 // Reset the framework controller.
347 sci_base_state_machine_change_state(
348 &fw_controller->parent.state_machine,
349 SCI_BASE_CONTROLLER_STATE_RESET
355 sci_base_object_get_logger(fw_controller),
356 SCIF_LOG_OBJECT_CONTROLLER,
357 "Controller: unable to successfully reset controller.\n"
360 sci_base_state_machine_change_state(
361 &fw_controller->parent.state_machine,
362 SCI_BASE_CONTROLLER_STATE_FAILED
368 * @brief This method implements the actions taken when entering the
371 * @param[in] object This parameter specifies the base object for which
372 * the state transition is occurring. This is cast into a
373 * SCIF_SAS_CONTROLLER object in the method implementation.
378 void scif_sas_controller_failed_state_enter(
379 SCI_BASE_OBJECT_T * object
382 SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)object;
385 sci_base_object_get_logger(fw_controller),
386 SCIF_LOG_OBJECT_CONTROLLER,
387 "Controller: entered FAILED state.\n"
392 scif_sas_controller_state_handler_table,
393 SCI_BASE_CONTROLLER_STATE_FAILED
396 if (fw_controller->parent.error != SCI_CONTROLLER_FATAL_MEMORY_ERROR)
398 //clean timers to avoid timer leak.
399 scif_sas_controller_release_resource(fw_controller);
402 scif_cb_controller_error(fw_controller, fw_controller->parent.error);
407 scif_sas_controller_state_table[SCI_BASE_CONTROLLER_MAX_STATES] =
410 SCI_BASE_CONTROLLER_STATE_INITIAL,
411 scif_sas_controller_initial_state_enter,
415 SCI_BASE_CONTROLLER_STATE_RESET,
416 scif_sas_controller_reset_state_enter,
420 SCI_BASE_CONTROLLER_STATE_INITIALIZING,
421 scif_sas_controller_initializing_state_enter,
425 SCI_BASE_CONTROLLER_STATE_INITIALIZED,
426 scif_sas_controller_initialized_state_enter,
430 SCI_BASE_CONTROLLER_STATE_STARTING,
431 scif_sas_controller_starting_state_enter,
435 SCI_BASE_CONTROLLER_STATE_READY,
436 scif_sas_controller_ready_state_enter,
440 SCI_BASE_CONTROLLER_STATE_RESETTING,
441 scif_sas_controller_resetting_state_enter,
445 SCI_BASE_CONTROLLER_STATE_STOPPING,
446 scif_sas_controller_stopping_state_enter,
450 SCI_BASE_CONTROLLER_STATE_STOPPED,
451 scif_sas_controller_stopped_state_enter,
455 SCI_BASE_CONTROLLER_STATE_FAILED,
456 scif_sas_controller_failed_state_enter,