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_DOMAIN_H_
55 #define _SCI_BASE_DOMAIN_H_
60 * @brief This file contains all of the structures, constants, and methods
61 * common to all domain object definitions.
68 #include <dev/isci/scil/sci_base_object.h>
69 #include <dev/isci/scil/sci_base_logger.h>
70 #include <dev/isci/scil/sci_base_state_machine.h>
71 #include <dev/isci/scil/sci_base_state_machine_logger.h>
74 * @enum SCI_BASE_DOMAIN_STATES
76 * @brief This enumeration depicts the standard states common to all domain
77 * state machine implementations.
79 typedef enum _SCI_BASE_DOMAIN_STATES
82 * Simply the initial state for the base domain state machine.
84 SCI_BASE_DOMAIN_STATE_INITIAL,
87 * This state indicates that the domain has successfully been stopped.
88 * In this state no new IO operations are permitted.
89 * This state is entered from the INITIAL state.
90 * This state is entered from the DISCOVERING state.
92 SCI_BASE_DOMAIN_STATE_STARTING,
95 * This state indicates the domain is now ready. Thus, the user
96 * is able to perform IO operations to remote devices in this domain.
97 * This state is entered from the STOPPED state.
98 * This state is entered from the STOPPING state.
99 * This state is entered from the DISCOVERING state.
101 SCI_BASE_DOMAIN_STATE_READY,
104 * This state indicates that the domain is in the process of stopping.
105 * In this state no new IO operations are permitted, but existing IO
106 * operations in the domain are allowed to complete.
107 * This state is entered from the READY state.
108 * This state is entered from the DISCOVERING state.
110 SCI_BASE_DOMAIN_STATE_STOPPING,
113 * This state indicates that the domain has successfully been stopped.
114 * In this state no new IO operations are permitted.
115 * This state is entered from the INITIAL state.
116 * This state is entered from the STOPPING state.
118 SCI_BASE_DOMAIN_STATE_STOPPED,
121 * This state indicates that the domain is actively attempting to
122 * discover what remote devices are contained in it. In this state no
123 * new user IO requests are permitted.
124 * This state is entered from the READY state.
126 SCI_BASE_DOMAIN_STATE_DISCOVERING,
128 SCI_BASE_DOMAIN_MAX_STATES
130 } SCI_BASE_DOMAIN_STATES;
133 * @struct SCI_BASE_DOMAIN
135 * @brief This structure defines all of the fields common to DOMAIN objects.
137 typedef struct SCI_BASE_DOMAIN
140 * This field depicts the parent object (SCI_BASE_OBJECT) for the domain.
142 SCI_BASE_OBJECT_T parent;
145 * This field contains the information for the base domain state machine.
147 SCI_BASE_STATE_MACHINE_T state_machine;
150 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
151 #endif // SCI_LOGGING
155 struct SCI_BASE_CONTROLLER;
156 struct SCI_BASE_REMOTE_DEVICE;
157 struct SCI_BASE_REQUEST;
158 struct SCI_BASE_REQUEST;
160 typedef SCI_STATUS (*SCI_BASE_DOMAIN_TIMED_HANDLER_T)(
166 typedef SCI_STATUS (*SCI_BASE_DOMAIN_HANDLER_T)(
170 typedef SCI_STATUS (*SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T)(
175 typedef SCI_STATUS (*SCI_BASE_DOMAIN_DEVICE_HANDLER_T)(
177 struct SCI_BASE_REMOTE_DEVICE *
180 typedef SCI_STATUS (*SCI_BASE_DOMAIN_REQUEST_HANDLER_T)(
182 struct SCI_BASE_REMOTE_DEVICE *,
183 struct SCI_BASE_REQUEST *
186 typedef SCI_STATUS (*SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)(
188 struct SCI_BASE_REMOTE_DEVICE *,
189 struct SCI_BASE_REQUEST *,
196 * @struct SCI_BASE_DOMAIN_STATE_HANDLER
198 * @brief This structure contains all of the state handler methods common to
199 * base domain state machines. Handler methods provide the ability
200 * to change the behavior for user requests or transitions depending
201 * on the state the machine is in.
203 typedef struct SCI_BASE_DOMAIN_STATE_HANDLER
206 * The discover_handler specifies the method invoked when a user attempts
207 * to discover a domain.
209 SCI_BASE_DOMAIN_TIMED_HANDLER_T discover_handler;
212 * The port_ready_handler specifies the method invoked an SCI Core
213 * informs the domain object that it's associated port is now ready
216 SCI_BASE_DOMAIN_HANDLER_T port_ready_handler;
219 * The port_not_ready_handler specifies the method invoked an SCI Core
220 * informs the domain object that it's associated port is no longer ready
223 SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T port_not_ready_handler;
226 * The device_start_complete_handler specifies the method invoked when a
227 * remote device start operation in the domain completes.
229 SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_start_complete_handler;
232 * The device_stop_complete_handler specifies the method invoked when a
233 * remote device stop operation in the domain completes.
235 SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_stop_complete_handler;
238 * The device_destruct_handler specifies the method invoked when sci user
239 * destruct a remote device of this domain.
241 SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_destruct_handler;
244 * The start_io_handler specifies the method invoked when a user
245 * attempts to start an IO request for a domain.
247 SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_io_handler;
250 * The start_high_priority_io_handler specifies the method invoked when a user
251 * attempts to start an high priority request for a domain.
253 SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_high_priority_io_handler;
256 * The complete_io_handler specifies the method invoked when a user
257 * attempts to complete an IO request for a domain.
259 SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_io_handler;
262 * The complete_high_priority_io_handler specifies the method invoked when a
263 * user attempts to complete an high priority IO request for a domain.
265 SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T complete_high_priority_io_handler;
268 * The continue_io_handler specifies the method invoked when a user
269 * attempts to continue an IO request for a domain.
271 SCI_BASE_DOMAIN_REQUEST_HANDLER_T continue_io_handler;
274 * The start_task_handler specifies the method invoked when a user
275 * attempts to start a task management request for a domain.
277 SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_task_handler;
280 * The complete_task_handler specifies the method invoked when a user
281 * attempts to complete a task management request for a domain.
283 SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_task_handler;
285 } SCI_BASE_DOMAIN_STATE_HANDLER_T;
288 * @brief Construct the base domain
290 * @param[in] this_domain This parameter specifies the base domain to be
292 * @param[in] logger This parameter specifies the logger associated with
293 * this base domain object.
294 * @param[in] state_table This parameter specifies the table of state
295 * definitions to be utilized for the domain state machine.
299 void sci_base_domain_construct(
300 SCI_BASE_DOMAIN_T * this_domain,
301 SCI_BASE_LOGGER_T * logger,
302 SCI_BASE_STATE_T * state_table
307 #endif // __cplusplus
309 #endif // _SCI_BASE_DOMAIN_H_