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_DOMAIN_H_
57 #define _SCI_BASE_DOMAIN_H_
62 * @brief This file contains all of the structures, constants, and methods
63 * common to all domain object definitions.
70 #include <dev/isci/scil/sci_base_object.h>
71 #include <dev/isci/scil/sci_base_logger.h>
72 #include <dev/isci/scil/sci_base_state_machine.h>
73 #include <dev/isci/scil/sci_base_state_machine_logger.h>
76 * @enum SCI_BASE_DOMAIN_STATES
78 * @brief This enumeration depicts the standard states common to all domain
79 * state machine implementations.
81 typedef enum _SCI_BASE_DOMAIN_STATES
84 * Simply the initial state for the base domain state machine.
86 SCI_BASE_DOMAIN_STATE_INITIAL,
89 * This state indicates that the domain has successfully been stopped.
90 * In this state no new IO operations are permitted.
91 * This state is entered from the INITIAL state.
92 * This state is entered from the DISCOVERING state.
94 SCI_BASE_DOMAIN_STATE_STARTING,
97 * This state indicates the domain is now ready. Thus, the user
98 * is able to perform IO operations to remote devices in this domain.
99 * This state is entered from the STOPPED state.
100 * This state is entered from the STOPPING state.
101 * This state is entered from the DISCOVERING state.
103 SCI_BASE_DOMAIN_STATE_READY,
106 * This state indicates that the domain is in the process of stopping.
107 * In this state no new IO operations are permitted, but existing IO
108 * operations in the domain are allowed to complete.
109 * This state is entered from the READY state.
110 * This state is entered from the DISCOVERING state.
112 SCI_BASE_DOMAIN_STATE_STOPPING,
115 * This state indicates that the domain has successfully been stopped.
116 * In this state no new IO operations are permitted.
117 * This state is entered from the INITIAL state.
118 * This state is entered from the STOPPING state.
120 SCI_BASE_DOMAIN_STATE_STOPPED,
123 * This state indicates that the domain is actively attempting to
124 * discover what remote devices are contained in it. In this state no
125 * new user IO requests are permitted.
126 * This state is entered from the READY state.
128 SCI_BASE_DOMAIN_STATE_DISCOVERING,
130 SCI_BASE_DOMAIN_MAX_STATES
132 } SCI_BASE_DOMAIN_STATES;
135 * @struct SCI_BASE_DOMAIN
137 * @brief This structure defines all of the fields common to DOMAIN objects.
139 typedef struct SCI_BASE_DOMAIN
142 * This field depicts the parent object (SCI_BASE_OBJECT) for the domain.
144 SCI_BASE_OBJECT_T parent;
147 * This field contains the information for the base domain state machine.
149 SCI_BASE_STATE_MACHINE_T state_machine;
152 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
153 #endif // SCI_LOGGING
157 struct SCI_BASE_CONTROLLER;
158 struct SCI_BASE_REMOTE_DEVICE;
159 struct SCI_BASE_REQUEST;
160 struct SCI_BASE_REQUEST;
162 typedef SCI_STATUS (*SCI_BASE_DOMAIN_TIMED_HANDLER_T)(
168 typedef SCI_STATUS (*SCI_BASE_DOMAIN_HANDLER_T)(
172 typedef SCI_STATUS (*SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T)(
177 typedef SCI_STATUS (*SCI_BASE_DOMAIN_DEVICE_HANDLER_T)(
179 struct SCI_BASE_REMOTE_DEVICE *
182 typedef SCI_STATUS (*SCI_BASE_DOMAIN_REQUEST_HANDLER_T)(
184 struct SCI_BASE_REMOTE_DEVICE *,
185 struct SCI_BASE_REQUEST *
188 typedef SCI_STATUS (*SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)(
190 struct SCI_BASE_REMOTE_DEVICE *,
191 struct SCI_BASE_REQUEST *,
198 * @struct SCI_BASE_DOMAIN_STATE_HANDLER
200 * @brief This structure contains all of the state handler methods common to
201 * base domain 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_DOMAIN_STATE_HANDLER
208 * The discover_handler specifies the method invoked when a user attempts
209 * to discover a domain.
211 SCI_BASE_DOMAIN_TIMED_HANDLER_T discover_handler;
214 * The port_ready_handler specifies the method invoked an SCI Core
215 * informs the domain object that it's associated port is now ready
218 SCI_BASE_DOMAIN_HANDLER_T port_ready_handler;
221 * The port_not_ready_handler specifies the method invoked an SCI Core
222 * informs the domain object that it's associated port is no longer ready
225 SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T port_not_ready_handler;
228 * The device_start_complete_handler specifies the method invoked when a
229 * remote device start operation in the domain completes.
231 SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_start_complete_handler;
234 * The device_stop_complete_handler specifies the method invoked when a
235 * remote device stop operation in the domain completes.
237 SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_stop_complete_handler;
240 * The device_destruct_handler specifies the method invoked when sci user
241 * destruct a remote device of this domain.
243 SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_destruct_handler;
246 * The start_io_handler specifies the method invoked when a user
247 * attempts to start an IO request for a domain.
249 SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_io_handler;
252 * The start_high_priority_io_handler specifies the method invoked when a user
253 * attempts to start an high priority request for a domain.
255 SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_high_priority_io_handler;
258 * The complete_io_handler specifies the method invoked when a user
259 * attempts to complete an IO request for a domain.
261 SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_io_handler;
264 * The complete_high_priority_io_handler specifies the method invoked when a
265 * user attempts to complete an high priority IO request for a domain.
267 SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T complete_high_priority_io_handler;
270 * The continue_io_handler specifies the method invoked when a user
271 * attempts to continue an IO request for a domain.
273 SCI_BASE_DOMAIN_REQUEST_HANDLER_T continue_io_handler;
276 * The start_task_handler specifies the method invoked when a user
277 * attempts to start a task management request for a domain.
279 SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_task_handler;
282 * The complete_task_handler specifies the method invoked when a user
283 * attempts to complete a task management request for a domain.
285 SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_task_handler;
287 } SCI_BASE_DOMAIN_STATE_HANDLER_T;
290 * @brief Construct the base domain
292 * @param[in] this_domain This parameter specifies the base domain to be
294 * @param[in] logger This parameter specifies the logger associated with
295 * this base domain object.
296 * @param[in] state_table This parameter specifies the table of state
297 * definitions to be utilized for the domain state machine.
301 void sci_base_domain_construct(
302 SCI_BASE_DOMAIN_T * this_domain,
303 SCI_BASE_LOGGER_T * logger,
304 SCI_BASE_STATE_T * state_table
309 #endif // __cplusplus
311 #endif // _SCI_BASE_DOMAIN_H_