2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23 * The full GNU General Public License is included in this distribution
24 * in the file called LICENSE.GPL.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 #ifndef _SCI_BASE_REMOTE_DEVICE_H_
57 #define _SCI_BASE_REMOTE_DEVICE_H_
62 * @brief This file contains all of the structures, constants, and methods
63 * common to all remote device object definitions.
70 #include <dev/isci/scil/sci_base_state_machine.h>
71 #include <dev/isci/scil/sci_base_logger.h>
72 #include <dev/isci/scil/sci_base_state_machine_logger.h>
74 struct SCI_BASE_REQUEST;
77 * @enum SCI_BASE_REMOTE_DEVICE_STATES
79 * @brief This enumeration depicts all the states for the common remote device
82 typedef enum _SCI_BASE_REMOTE_DEVICE_STATES
85 * Simply the initial state for the base remote device state machine.
87 SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
90 * This state indicates that the remote device has successfully been
91 * stopped. In this state no new IO operations are permitted.
92 * This state is entered from the INITIAL state.
93 * This state is entered from the STOPPING state.
95 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
98 * This state indicates the remote device is in the process of
99 * becoming ready (i.e. starting). In this state no new IO operations
101 * This state is entered from the STOPPED state.
103 SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
106 * This state indicates the remote device is now ready. Thus, the user
107 * is able to perform IO operations on the remote device.
108 * This state is entered from the STARTING state.
110 SCI_BASE_REMOTE_DEVICE_STATE_READY,
113 * This state indicates that the remote device is in the process of
114 * stopping. In this state no new IO operations are permitted, but
115 * existing IO operations are allowed to complete.
116 * This state is entered from the READY state.
117 * This state is entered from the FAILED state.
119 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
122 * This state indicates that the remote device has failed.
123 * In this state no new IO operations are permitted.
124 * This state is entered from the INITIALIZING state.
125 * This state is entered from the READY state.
127 SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
130 * This state indicates the device is being reset.
131 * In this state no new IO operations are permitted.
132 * This state is entered from the READY state.
134 SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
136 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
138 * This state indicates the device is in the middle of updating
139 * its port width. All the IOs sent to this device will be Quiesced.
141 SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH,
145 * Simply the final state for the base remote device state machine.
147 SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
149 SCI_BASE_REMOTE_DEVICE_MAX_STATES
151 } SCI_BASE_REMOTE_DEVICE_STATES;
154 * @struct SCI_BASE_REMOTE_DEVICE
156 * @brief The base remote device object abstracts the fields common to all
157 * SCI remote device objects.
159 typedef struct SCI_BASE_REMOTE_DEVICE
162 * The field specifies that the parent object for the base remote
163 * device is the base object itself.
165 SCI_BASE_OBJECT_T parent;
168 * This field contains the information for the base remote device state
171 SCI_BASE_STATE_MACHINE_T state_machine;
175 * This field contains the state machine observer for the state machine.
177 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
178 #endif // SCI_LOGGING
180 } SCI_BASE_REMOTE_DEVICE_T;
183 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_HANDLER_T)(
184 SCI_BASE_REMOTE_DEVICE_T *
187 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T)(
188 SCI_BASE_REMOTE_DEVICE_T *,
189 struct SCI_BASE_REQUEST *
192 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)(
193 SCI_BASE_REMOTE_DEVICE_T *,
194 struct SCI_BASE_REQUEST *,
200 * @struct SCI_BASE_CONTROLLER_STATE_HANDLER
202 * @brief This structure contains all of the state handler methods common to
203 * base remote device state machines. Handler methods provide the ability
204 * to change the behavior for user requests or transitions depending
205 * on the state the machine is in.
207 typedef struct SCI_BASE_REMOTE_DEVICE_STATE_HANDLER
210 * The start_handler specifies the method invoked when a user attempts to
211 * start a remote device.
213 SCI_BASE_REMOTE_DEVICE_HANDLER_T start_handler;
216 * The stop_handler specifies the method invoked when a user attempts to
217 * stop a remote device.
219 SCI_BASE_REMOTE_DEVICE_HANDLER_T stop_handler;
222 * The fail_handler specifies the method invoked when a remote device
223 * failure has occurred. A failure may be due to an inability to
224 * initialize/configure the device.
226 SCI_BASE_REMOTE_DEVICE_HANDLER_T fail_handler;
229 * The destruct_handler specifies the method invoked when attempting to
230 * destruct a remote device.
232 SCI_BASE_REMOTE_DEVICE_HANDLER_T destruct_handler;
235 * The reset handler specifies the method invloked when requesting to reset a
238 SCI_BASE_REMOTE_DEVICE_HANDLER_T reset_handler;
241 * The reset complete handler specifies the method invloked when reporting
242 * that a reset has completed to the remote device.
244 SCI_BASE_REMOTE_DEVICE_HANDLER_T reset_complete_handler;
247 * The start_io_handler specifies the method invoked when a user
248 * attempts to start an IO request for a remote device.
250 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T start_io_handler;
253 * The complete_io_handler specifies the method invoked when a user
254 * attempts to complete an IO request for a remote device.
256 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T complete_io_handler;
259 * The continue_io_handler specifies the method invoked when a user
260 * attempts to continue an IO request for a remote device.
262 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T continue_io_handler;
265 * The start_task_handler specifies the method invoked when a user
266 * attempts to start a task management request for a remote device.
268 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T start_task_handler;
271 * The complete_task_handler specifies the method invoked when a user
272 * attempts to complete a task management request for a remote device.
274 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T complete_task_handler;
276 } SCI_BASE_REMOTE_DEVICE_STATE_HANDLER_T;
279 * @brief Construct the base remote device
281 * @param[in] this_remote_device This parameter specifies the base remote
282 * device to be constructed.
283 * @param[in] logger This parameter specifies the logger associated with
284 * this base remote device object.
285 * @param[in] state_table This parameter specifies the table of state
286 * definitions to be utilized for the remote device state machine.
290 void sci_base_remote_device_construct(
291 SCI_BASE_REMOTE_DEVICE_T * this_device,
292 SCI_BASE_LOGGER_T * logger,
293 SCI_BASE_STATE_T * state_table
298 #endif // __cplusplus
300 #endif // _SCI_BASE_REMOTE_DEVICE_H_