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_REMOTE_DEVICE_H_
55 #define _SCI_BASE_REMOTE_DEVICE_H_
60 * @brief This file contains all of the structures, constants, and methods
61 * common to all remote device object definitions.
68 #include <dev/isci/scil/sci_base_state_machine.h>
69 #include <dev/isci/scil/sci_base_logger.h>
70 #include <dev/isci/scil/sci_base_state_machine_logger.h>
72 struct SCI_BASE_REQUEST;
75 * @enum SCI_BASE_REMOTE_DEVICE_STATES
77 * @brief This enumeration depicts all the states for the common remote device
80 typedef enum _SCI_BASE_REMOTE_DEVICE_STATES
83 * Simply the initial state for the base remote device state machine.
85 SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
88 * This state indicates that the remote device has successfully been
89 * stopped. In this state no new IO operations are permitted.
90 * This state is entered from the INITIAL state.
91 * This state is entered from the STOPPING state.
93 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
96 * This state indicates the remote device is in the process of
97 * becoming ready (i.e. starting). In this state no new IO operations
99 * This state is entered from the STOPPED state.
101 SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
104 * This state indicates the remote device is now ready. Thus, the user
105 * is able to perform IO operations on the remote device.
106 * This state is entered from the STARTING state.
108 SCI_BASE_REMOTE_DEVICE_STATE_READY,
111 * This state indicates that the remote device is in the process of
112 * stopping. In this state no new IO operations are permitted, but
113 * existing IO operations are allowed to complete.
114 * This state is entered from the READY state.
115 * This state is entered from the FAILED state.
117 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
120 * This state indicates that the remote device has failed.
121 * In this state no new IO operations are permitted.
122 * This state is entered from the INITIALIZING state.
123 * This state is entered from the READY state.
125 SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
128 * This state indicates the device is being reset.
129 * In this state no new IO operations are permitted.
130 * This state is entered from the READY state.
132 SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
134 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
136 * This state indicates the device is in the middle of updating
137 * its port width. All the IOs sent to this device will be Quiesced.
139 SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH,
143 * Simply the final state for the base remote device state machine.
145 SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
147 SCI_BASE_REMOTE_DEVICE_MAX_STATES
149 } SCI_BASE_REMOTE_DEVICE_STATES;
152 * @struct SCI_BASE_REMOTE_DEVICE
154 * @brief The base remote device object abstracts the fields common to all
155 * SCI remote device objects.
157 typedef struct SCI_BASE_REMOTE_DEVICE
160 * The field specifies that the parent object for the base remote
161 * device is the base object itself.
163 SCI_BASE_OBJECT_T parent;
166 * This field contains the information for the base remote device state
169 SCI_BASE_STATE_MACHINE_T state_machine;
173 * This field contains the state machine observer for the state machine.
175 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
176 #endif // SCI_LOGGING
178 } SCI_BASE_REMOTE_DEVICE_T;
181 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_HANDLER_T)(
182 SCI_BASE_REMOTE_DEVICE_T *
185 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T)(
186 SCI_BASE_REMOTE_DEVICE_T *,
187 struct SCI_BASE_REQUEST *
190 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)(
191 SCI_BASE_REMOTE_DEVICE_T *,
192 struct SCI_BASE_REQUEST *,
198 * @struct SCI_BASE_CONTROLLER_STATE_HANDLER
200 * @brief This structure contains all of the state handler methods common to
201 * base remote device state machines. Handler methods provide the ability
202 * to change the behavior for user requests or transitions depending
203 * on the state the machine is in.
205 typedef struct SCI_BASE_REMOTE_DEVICE_STATE_HANDLER
208 * The start_handler specifies the method invoked when a user attempts to
209 * start a remote device.
211 SCI_BASE_REMOTE_DEVICE_HANDLER_T start_handler;
214 * The stop_handler specifies the method invoked when a user attempts to
215 * stop a remote device.
217 SCI_BASE_REMOTE_DEVICE_HANDLER_T stop_handler;
220 * The fail_handler specifies the method invoked when a remote device
221 * failure has occurred. A failure may be due to an inability to
222 * initialize/configure the device.
224 SCI_BASE_REMOTE_DEVICE_HANDLER_T fail_handler;
227 * The destruct_handler specifies the method invoked when attempting to
228 * destruct a remote device.
230 SCI_BASE_REMOTE_DEVICE_HANDLER_T destruct_handler;
233 * The reset handler specifies the method invloked when requesting to reset a
236 SCI_BASE_REMOTE_DEVICE_HANDLER_T reset_handler;
239 * The reset complete handler specifies the method invloked when reporting
240 * that a reset has completed to the remote device.
242 SCI_BASE_REMOTE_DEVICE_HANDLER_T reset_complete_handler;
245 * The start_io_handler specifies the method invoked when a user
246 * attempts to start an IO request for a remote device.
248 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T start_io_handler;
251 * The complete_io_handler specifies the method invoked when a user
252 * attempts to complete an IO request for a remote device.
254 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T complete_io_handler;
257 * The continue_io_handler specifies the method invoked when a user
258 * attempts to continue an IO request for a remote device.
260 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T continue_io_handler;
263 * The start_task_handler specifies the method invoked when a user
264 * attempts to start a task management request for a remote device.
266 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T start_task_handler;
269 * The complete_task_handler specifies the method invoked when a user
270 * attempts to complete a task management request for a remote device.
272 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T complete_task_handler;
274 } SCI_BASE_REMOTE_DEVICE_STATE_HANDLER_T;
277 * @brief Construct the base remote device
279 * @param[in] this_remote_device This parameter specifies the base remote
280 * device to be constructed.
281 * @param[in] logger This parameter specifies the logger associated with
282 * this base remote device object.
283 * @param[in] state_table This parameter specifies the table of state
284 * definitions to be utilized for the remote device state machine.
288 void sci_base_remote_device_construct(
289 SCI_BASE_REMOTE_DEVICE_T * this_device,
290 SCI_BASE_LOGGER_T * logger,
291 SCI_BASE_STATE_T * state_table
296 #endif // __cplusplus
298 #endif // _SCI_BASE_REMOTE_DEVICE_H_