1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3 *
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.
6 *
7 * GPL LICENSE SUMMARY
8 *
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10 *
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.
14 *
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.
19 *
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.
25 *
26 * BSD LICENSE
27 *
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 *
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
40 * distribution.
41 *
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.
53 *
54 * $FreeBSD$
55 */
56 #ifndef _SCI_BASE_REMOTE_DEVICE_H_
57 #define _SCI_BASE_REMOTE_DEVICE_H_
58
59 /**
60 * @file
61 *
62 * @brief This file contains all of the structures, constants, and methods
63 * common to all remote device object definitions.
64 */
65
66 #ifdef __cplusplus
67 extern "C" {
68 #endif // __cplusplus
69
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>
73
74 struct SCI_BASE_REQUEST;
75
76 /**
77 * @enum SCI_BASE_REMOTE_DEVICE_STATES
78 *
79 * @brief This enumeration depicts all the states for the common remote device
80 * state machine.
81 */
82 typedef enum _SCI_BASE_REMOTE_DEVICE_STATES
83 {
84 /**
85 * Simply the initial state for the base remote device state machine.
86 */
87 SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
88
89 /**
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.
94 */
95 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
96
97 /**
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
100 * are permitted.
101 * This state is entered from the STOPPED state.
102 */
103 SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
104
105 /**
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.
109 */
110 SCI_BASE_REMOTE_DEVICE_STATE_READY,
111
112 /**
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.
118 */
119 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
120
121 /**
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.
126 */
127 SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
128
129 /**
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.
133 */
134 SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
135
136 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
137 /**
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.
140 */
141 SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH,
142 #endif
143
144 /**
145 * Simply the final state for the base remote device state machine.
146 */
147 SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
148
149 SCI_BASE_REMOTE_DEVICE_MAX_STATES
150
151 } SCI_BASE_REMOTE_DEVICE_STATES;
152
153 /**
154 * @struct SCI_BASE_REMOTE_DEVICE
155 *
156 * @brief The base remote device object abstracts the fields common to all
157 * SCI remote device objects.
158 */
159 typedef struct SCI_BASE_REMOTE_DEVICE
160 {
161 /**
162 * The field specifies that the parent object for the base remote
163 * device is the base object itself.
164 */
165 SCI_BASE_OBJECT_T parent;
166
167 /**
168 * This field contains the information for the base remote device state
169 * machine.
170 */
171 SCI_BASE_STATE_MACHINE_T state_machine;
172
173 #ifdef SCI_LOGGING
174 /**
175 * This field contains the state machine observer for the state machine.
176 */
177 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
178 #endif // SCI_LOGGING
179
180 } SCI_BASE_REMOTE_DEVICE_T;
181
182
183 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_HANDLER_T)(
184 SCI_BASE_REMOTE_DEVICE_T *
185 );
186
187 typedef SCI_STATUS (*SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T)(
188 SCI_BASE_REMOTE_DEVICE_T *,
189 struct SCI_BASE_REQUEST *
190 );
191
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 *,
195 void *,
196 SCI_IO_STATUS
197 );
198
199 /**
200 * @struct SCI_BASE_CONTROLLER_STATE_HANDLER
201 *
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.
206 */
207 typedef struct SCI_BASE_REMOTE_DEVICE_STATE_HANDLER
208 {
209 /**
210 * The start_handler specifies the method invoked when a user attempts to
211 * start a remote device.
212 */
213 SCI_BASE_REMOTE_DEVICE_HANDLER_T start_handler;
214
215 /**
216 * The stop_handler specifies the method invoked when a user attempts to
217 * stop a remote device.
218 */
219 SCI_BASE_REMOTE_DEVICE_HANDLER_T stop_handler;
220
221 /**
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.
225 */
226 SCI_BASE_REMOTE_DEVICE_HANDLER_T fail_handler;
227
228 /**
229 * The destruct_handler specifies the method invoked when attempting to
230 * destruct a remote device.
231 */
232 SCI_BASE_REMOTE_DEVICE_HANDLER_T destruct_handler;
233
234 /**
235 * The reset handler specifies the method invloked when requesting to reset a
236 * remote device.
237 */
238 SCI_BASE_REMOTE_DEVICE_HANDLER_T reset_handler;
239
240 /**
241 * The reset complete handler specifies the method invloked when reporting
242 * that a reset has completed to the remote device.
243 */
244 SCI_BASE_REMOTE_DEVICE_HANDLER_T reset_complete_handler;
245
246 /**
247 * The start_io_handler specifies the method invoked when a user
248 * attempts to start an IO request for a remote device.
249 */
250 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T start_io_handler;
251
252 /**
253 * The complete_io_handler specifies the method invoked when a user
254 * attempts to complete an IO request for a remote device.
255 */
256 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T complete_io_handler;
257
258 /**
259 * The continue_io_handler specifies the method invoked when a user
260 * attempts to continue an IO request for a remote device.
261 */
262 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T continue_io_handler;
263
264 /**
265 * The start_task_handler specifies the method invoked when a user
266 * attempts to start a task management request for a remote device.
267 */
268 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T start_task_handler;
269
270 /**
271 * The complete_task_handler specifies the method invoked when a user
272 * attempts to complete a task management request for a remote device.
273 */
274 SCI_BASE_REMOTE_DEVICE_REQUEST_HANDLER_T complete_task_handler;
275
276 } SCI_BASE_REMOTE_DEVICE_STATE_HANDLER_T;
277
278 /**
279 * @brief Construct the base remote device
280 *
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.
287 *
288 * @return none
289 */
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
294 );
295
296 #ifdef __cplusplus
297 }
298 #endif // __cplusplus
299
300 #endif // _SCI_BASE_REMOTE_DEVICE_H_
Cache object: 5bcf11fc09ec1c44034791ab74c1a72d
|