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
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 #ifndef _SCI_BASE_REQUST_H_
57 #define _SCI_BASE_REQUST_H_
60 * This file contains all of the constants, types, and method declarations for
61 * the SCI base IO and task request objects.
66 #include "sci_base_state_machine.h"
69 * enum sci_base_request_states - This enumeration depicts all the states for
70 * the common request state machine.
74 enum sci_base_request_states {
76 * Simply the initial state for the base request state machine.
78 SCI_BASE_REQUEST_STATE_INITIAL,
81 * This state indicates that the request has been constructed. This state
82 * is entered from the INITIAL state.
84 SCI_BASE_REQUEST_STATE_CONSTRUCTED,
87 * This state indicates that the request has been started. This state is
88 * entered from the CONSTRUCTED state.
90 SCI_BASE_REQUEST_STATE_STARTED,
93 * This state indicates that the request has completed.
94 * This state is entered from the STARTED state. This state is entered from
97 SCI_BASE_REQUEST_STATE_COMPLETED,
100 * This state indicates that the request is in the process of being
101 * terminated/aborted.
102 * This state is entered from the CONSTRUCTED state.
103 * This state is entered from the STARTED state.
105 SCI_BASE_REQUEST_STATE_ABORTING,
108 * Simply the final state for the base request state machine.
110 SCI_BASE_REQUEST_STATE_FINAL,
114 * struct sci_base_request - The base request object abstracts the fields
115 * common to all SCI IO and task request objects.
119 struct sci_base_request {
121 * The field specifies that the parent object for the base request is the
122 * base object itself.
124 struct sci_base_object parent;
127 * This field contains the information for the base request state machine.
129 struct sci_base_state_machine state_machine;
132 typedef enum sci_status (*SCI_BASE_REQUEST_HANDLER_T)(
133 struct sci_base_request *this_request
137 * struct sci_base_request_state_handler - This structure contains all of the
138 * state handler methods common to base IO and task request state machines.
139 * Handler methods provide the ability to change the behavior for user
140 * requests or transitions depending on the state the machine is in.
144 struct sci_base_request_state_handler {
146 * The start_handler specifies the method invoked when a user attempts to
149 SCI_BASE_REQUEST_HANDLER_T start_handler;
152 * The abort_handler specifies the method invoked when a user attempts to
155 SCI_BASE_REQUEST_HANDLER_T abort_handler;
158 * The complete_handler specifies the method invoked when a user attempts to
159 * complete a request.
161 SCI_BASE_REQUEST_HANDLER_T complete_handler;
164 * The destruct_handler specifies the method invoked when a user attempts to
165 * destruct a request.
167 SCI_BASE_REQUEST_HANDLER_T destruct_handler;
172 * sci_base_request_construct() - Construct the base request.
173 * @this_request: This parameter specifies the base request to be constructed.
174 * @state_table: This parameter specifies the table of state definitions to be
175 * utilized for the request state machine.
178 static inline void sci_base_request_construct(
179 struct sci_base_request *base_req,
180 const struct sci_base_state *my_state_table)
182 base_req->parent.private = NULL;
183 sci_base_state_machine_construct(
184 &base_req->state_machine,
187 SCI_BASE_REQUEST_STATE_INITIAL
190 sci_base_state_machine_start(
191 &base_req->state_machine
195 #endif /* _SCI_BASE_REQUST_H_ */