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.
54 #ifndef _SCI_BASE_CONTROLLER_H_
55 #define _SCI_BASE_CONTROLLER_H_
60 * @brief This file contains all of the structures, constants, and methods
61 * common to all controller object definitions.
68 #include <dev/isci/scil/intel_sas.h>
69 #include <dev/isci/scil/sci_controller_constants.h>
71 #include <dev/isci/scil/sci_base_object.h>
72 #include <dev/isci/scil/sci_base_state.h>
73 #include <dev/isci/scil/sci_base_logger.h>
74 #include <dev/isci/scil/sci_base_memory_descriptor_list.h>
75 #include <dev/isci/scil/sci_base_state_machine.h>
76 #include <dev/isci/scil/sci_base_state_machine_logger.h>
79 * @enum SCI_BASE_CONTROLLER_STATES
81 * @brief This enumeration depicts all the states for the common controller
84 typedef enum _SCI_BASE_CONTROLLER_STATES
87 * Simply the initial state for the base controller state machine.
89 SCI_BASE_CONTROLLER_STATE_INITIAL = 0,
92 * This state indicates that the controller is reset. The memory for
93 * the controller is in it's initial state, but the controller requires
95 * This state is entered from the INITIAL state.
96 * This state is entered from the RESETTING state.
98 SCI_BASE_CONTROLLER_STATE_RESET,
101 * This state is typically an action state that indicates the controller
102 * is in the process of initialization. In this state no new IO operations
104 * This state is entered from the RESET state.
106 SCI_BASE_CONTROLLER_STATE_INITIALIZING,
109 * This state indicates that the controller has been successfully
110 * initialized. In this state no new IO operations are permitted.
111 * This state is entered from the INITIALIZING state.
113 SCI_BASE_CONTROLLER_STATE_INITIALIZED,
116 * This state indicates the controller is in the process of becoming
117 * ready (i.e. starting). In this state no new IO operations are permitted.
118 * This state is entered from the INITIALIZED state.
120 SCI_BASE_CONTROLLER_STATE_STARTING,
123 * This state indicates the controller is now ready. Thus, the user
124 * is able to perform IO operations on the controller.
125 * This state is entered from the STARTING state.
127 SCI_BASE_CONTROLLER_STATE_READY,
130 * This state is typically an action state that indicates the controller
131 * is in the process of resetting. Thus, the user is unable to perform
132 * IO operations on the controller. A reset is considered destructive in
134 * This state is entered from the READY state.
135 * This state is entered from the FAILED state.
136 * This state is entered from the STOPPED state.
138 SCI_BASE_CONTROLLER_STATE_RESETTING,
141 * This state indicates that the controller is in the process of stopping.
142 * In this state no new IO operations are permitted, but existing IO
143 * operations are allowed to complete.
144 * This state is entered from the READY state.
146 SCI_BASE_CONTROLLER_STATE_STOPPING,
149 * This state indicates that the controller has successfully been stopped.
150 * In this state no new IO operations are permitted.
151 * This state is entered from the STOPPING state.
153 SCI_BASE_CONTROLLER_STATE_STOPPED,
156 * This state indicates that the controller could not successfully be
157 * initialized. In this state no new IO operations are permitted.
158 * This state is entered from the INITIALIZING state.
159 * This state is entered from the STARTING state.
160 * This state is entered from the STOPPING state.
161 * This state is entered from the RESETTING state.
163 SCI_BASE_CONTROLLER_STATE_FAILED,
165 SCI_BASE_CONTROLLER_MAX_STATES
167 } SCI_BASE_CONTROLLER_STATES;
170 * @struct SCI_BASE_CONTROLLER
172 * @brief The base controller object abstracts the fields common to all
173 * SCI controller objects.
175 typedef struct SCI_BASE_CONTROLLER
178 * The field specifies that the parent object for the base controller
179 * is the base object itself.
181 SCI_BASE_OBJECT_T parent;
184 * This field points to the memory descriptor list associated with this
185 * controller. The MDL indicates the memory requirements necessary for
186 * this controller object.
188 SCI_BASE_MEMORY_DESCRIPTOR_LIST_T mdl;
191 * This field records the fact that the controller has encountered a fatal memory
192 * error and controller must stay in failed state.
197 * This field contains the information for the base controller state
200 SCI_BASE_STATE_MACHINE_T state_machine;
203 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
204 #endif // SCI_LOGGING
206 } SCI_BASE_CONTROLLER_T;
208 // Forward declarations
209 struct SCI_BASE_REMOTE_DEVICE;
210 struct SCI_BASE_REQUEST;
212 typedef SCI_STATUS (*SCI_BASE_CONTROLLER_HANDLER_T)(
213 SCI_BASE_CONTROLLER_T *
216 typedef SCI_STATUS (*SCI_BASE_CONTROLLER_TIMED_HANDLER_T)(
217 SCI_BASE_CONTROLLER_T *,
221 typedef SCI_STATUS (*SCI_BASE_CONTROLLER_REQUEST_HANDLER_T)(
222 SCI_BASE_CONTROLLER_T *,
223 struct SCI_BASE_REMOTE_DEVICE *,
224 struct SCI_BASE_REQUEST *
227 typedef SCI_STATUS (*SCI_BASE_CONTROLLER_START_REQUEST_HANDLER_T)(
228 SCI_BASE_CONTROLLER_T *,
229 struct SCI_BASE_REMOTE_DEVICE *,
230 struct SCI_BASE_REQUEST *,
236 * @struct SCI_BASE_CONTROLLER_STATE_HANDLER
238 * @brief This structure contains all of the state handler methods common to
239 * base controller state machines. Handler methods provide the ability
240 * to change the behavior for user requests or transitions depending
241 * on the state the machine is in.
243 typedef struct SCI_BASE_CONTROLLER_STATE_HANDLER
246 * The start_handler specifies the method invoked when a user attempts to
247 * start a controller.
249 SCI_BASE_CONTROLLER_TIMED_HANDLER_T start_handler;
252 * The stop_handler specifies the method invoked when a user attempts to
255 SCI_BASE_CONTROLLER_TIMED_HANDLER_T stop_handler;
258 * The reset_handler specifies the method invoked when a user attempts to
259 * reset a controller.
261 SCI_BASE_CONTROLLER_HANDLER_T reset_handler;
264 * The initialize_handler specifies the method invoked when a user
265 * attempts to initialize a controller.
267 SCI_BASE_CONTROLLER_HANDLER_T initialize_handler;
270 * The start_io_handler specifies the method invoked when a user
271 * attempts to start an IO request for a controller.
273 SCI_BASE_CONTROLLER_START_REQUEST_HANDLER_T start_io_handler;
276 * The start_internal_request_handler specifies the method invoked when a user
277 * attempts to start an internal request for a controller.
279 SCI_BASE_CONTROLLER_START_REQUEST_HANDLER_T start_high_priority_io_handler;
282 * The complete_io_handler specifies the method invoked when a user
283 * attempts to complete an IO request for a controller.
285 SCI_BASE_CONTROLLER_REQUEST_HANDLER_T complete_io_handler;
288 * The complete_high_priority_io_handler specifies the method invoked when a user
289 * attempts to complete a high priority IO request for a controller.
291 SCI_BASE_CONTROLLER_REQUEST_HANDLER_T complete_high_priority_io_handler;
294 * The continue_io_handler specifies the method invoked when a user
295 * attempts to continue an IO request for a controller.
297 SCI_BASE_CONTROLLER_REQUEST_HANDLER_T continue_io_handler;
300 * The start_task_handler specifies the method invoked when a user
301 * attempts to start a task management request for a controller.
303 SCI_BASE_CONTROLLER_START_REQUEST_HANDLER_T start_task_handler;
306 * The complete_task_handler specifies the method invoked when a user
307 * attempts to complete a task management request for a controller.
309 SCI_BASE_CONTROLLER_REQUEST_HANDLER_T complete_task_handler;
311 } SCI_BASE_CONTROLLER_STATE_HANDLER_T;
314 * @brief Construct the base controller
316 * @param[in] this_controller This parameter specifies the base controller
318 * @param[in] logger This parameter specifies the logger associated with
319 * this base controller object.
320 * @param[in] state_table This parameter specifies the table of state
321 * definitions to be utilized for the controller state machine.
322 * @param[in] mde_array This parameter specifies the array of memory
323 * descriptor entries to be managed by this list.
324 * @param[in] mde_array_length This parameter specifies the size of the
326 * @param[in] next_mdl This parameter specifies a subsequent MDL object
327 * to be managed by this MDL object.
328 * @param[in] oem_parameters This parameter specifies the original
329 * equipment manufacturer parameters to be utilized by this
334 void sci_base_controller_construct(
335 SCI_BASE_CONTROLLER_T * this_controller,
336 SCI_BASE_LOGGER_T * logger,
337 SCI_BASE_STATE_T * state_table,
338 SCI_PHYSICAL_MEMORY_DESCRIPTOR_T * mdes,
340 SCI_MEMORY_DESCRIPTOR_LIST_HANDLE_T next_mdl
345 #endif // __cplusplus
347 #endif // _SCI_BASE_CONTROLLER_H_