]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/dev/isci/scil/sci_base_domain.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / dev / isci / scil / sci_base_domain.h
1 /*-
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.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
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.
12  *
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.
17  *
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.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
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
38  *     distribution.
39  *
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.
51  *
52  * $FreeBSD$
53  */
54 #ifndef _SCI_BASE_DOMAIN_H_
55 #define _SCI_BASE_DOMAIN_H_
56
57 /**
58  * @file
59  *
60  * @brief This file contains all of the structures, constants, and methods
61  *        common to all domain object definitions.
62  */
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif // __cplusplus
67
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>
72
73 /**
74  * @enum SCI_BASE_DOMAIN_STATES
75  *
76  * @brief This enumeration depicts the standard states common to all domain
77  *        state machine implementations.
78  */
79 typedef enum _SCI_BASE_DOMAIN_STATES
80 {
81    /**
82     * Simply the initial state for the base domain state machine.
83     */
84    SCI_BASE_DOMAIN_STATE_INITIAL,
85
86    /**
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.
91     */
92    SCI_BASE_DOMAIN_STATE_STARTING,
93
94    /**
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.
100     */
101    SCI_BASE_DOMAIN_STATE_READY,
102
103    /**
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.
109     */
110    SCI_BASE_DOMAIN_STATE_STOPPING,
111
112    /**
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.
117     */
118    SCI_BASE_DOMAIN_STATE_STOPPED,
119
120    /**
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.
125     */
126    SCI_BASE_DOMAIN_STATE_DISCOVERING,
127
128    SCI_BASE_DOMAIN_MAX_STATES
129
130 } SCI_BASE_DOMAIN_STATES;
131
132 /**
133  * @struct SCI_BASE_DOMAIN
134  *
135  * @brief This structure defines all of the fields common to DOMAIN objects.
136  */
137 typedef struct SCI_BASE_DOMAIN
138 {
139    /**
140     * This field depicts the parent object (SCI_BASE_OBJECT) for the domain.
141     */
142    SCI_BASE_OBJECT_T parent;
143
144    /**
145     * This field contains the information for the base domain state machine.
146     */
147    SCI_BASE_STATE_MACHINE_T state_machine;
148
149    #ifdef SCI_LOGGING
150    SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
151    #endif // SCI_LOGGING
152
153 } SCI_BASE_DOMAIN_T;
154
155 struct SCI_BASE_CONTROLLER;
156 struct SCI_BASE_REMOTE_DEVICE;
157 struct SCI_BASE_REQUEST;
158 struct SCI_BASE_REQUEST;
159
160 typedef SCI_STATUS (*SCI_BASE_DOMAIN_TIMED_HANDLER_T)(
161    SCI_BASE_DOMAIN_T *,
162    U32,
163    U32
164 );
165
166 typedef SCI_STATUS (*SCI_BASE_DOMAIN_HANDLER_T)(
167    SCI_BASE_DOMAIN_T *
168 );
169
170 typedef SCI_STATUS (*SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T)(
171    SCI_BASE_DOMAIN_T *,
172    U32
173 );
174
175 typedef SCI_STATUS (*SCI_BASE_DOMAIN_DEVICE_HANDLER_T)(
176    SCI_BASE_DOMAIN_T *,
177    struct SCI_BASE_REMOTE_DEVICE *
178 );
179
180 typedef SCI_STATUS (*SCI_BASE_DOMAIN_REQUEST_HANDLER_T)(
181    SCI_BASE_DOMAIN_T *,
182    struct SCI_BASE_REMOTE_DEVICE *,
183    struct SCI_BASE_REQUEST *
184 );
185
186 typedef SCI_STATUS (*SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)(
187    SCI_BASE_DOMAIN_T *,
188    struct SCI_BASE_REMOTE_DEVICE *,
189    struct SCI_BASE_REQUEST *,
190    void *,
191    SCI_IO_STATUS
192 );
193
194
195 /**
196  * @struct SCI_BASE_DOMAIN_STATE_HANDLER
197  *
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.
202  */
203 typedef struct SCI_BASE_DOMAIN_STATE_HANDLER
204 {
205    /**
206     * The discover_handler specifies the method invoked when a user attempts
207     * to discover a domain.
208     */
209    SCI_BASE_DOMAIN_TIMED_HANDLER_T discover_handler;
210
211    /**
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
214     * for IO operation.
215     */
216    SCI_BASE_DOMAIN_HANDLER_T port_ready_handler;
217
218    /**
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
221     * for IO operation.
222     */
223    SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T port_not_ready_handler;
224
225    /**
226     * The device_start_complete_handler specifies the method invoked when a
227     * remote device start operation in the domain completes.
228     */
229    SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_start_complete_handler;
230
231    /**
232     * The device_stop_complete_handler specifies the method invoked when a
233     * remote device stop operation in the domain completes.
234     */
235    SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_stop_complete_handler;
236
237    /**
238     * The device_destruct_handler specifies the method invoked when sci user
239     * destruct a remote device of this domain.
240     */
241    SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_destruct_handler;
242
243    /**
244     * The start_io_handler specifies the method invoked when a user
245     * attempts to start an IO request for a domain.
246     */
247    SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_io_handler;
248
249    /**
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.
252     */
253    SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_high_priority_io_handler;
254
255    /**
256     * The complete_io_handler specifies the method invoked when a user
257     * attempts to complete an IO request for a domain.
258     */
259    SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_io_handler;
260
261    /**
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.
264     */
265    SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T complete_high_priority_io_handler;
266
267    /**
268     * The continue_io_handler specifies the method invoked when a user
269     * attempts to continue an IO request for a domain.
270     */
271    SCI_BASE_DOMAIN_REQUEST_HANDLER_T continue_io_handler;
272
273    /**
274     * The start_task_handler specifies the method invoked when a user
275     * attempts to start a task management request for a domain.
276     */
277    SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_task_handler;
278
279    /**
280     * The complete_task_handler specifies the method invoked when a user
281     * attempts to complete a task management request for a domain.
282     */
283    SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_task_handler;
284
285 } SCI_BASE_DOMAIN_STATE_HANDLER_T;
286
287 /**
288  * @brief Construct the base domain
289  *
290  * @param[in] this_domain This parameter specifies the base domain to be
291  *            constructed.
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.
296  *
297  * @return none
298  */
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
303 );
304
305 #ifdef __cplusplus
306 }
307 #endif // __cplusplus
308
309 #endif // _SCI_BASE_DOMAIN_H_