sci_base_request.h revision 230843
197049Speter/*-
2184989Srafan * This file is provided under a dual BSD/GPLv2 license.  When using or
397049Speter * redistributing this file, you may do so under either license.
497049Speter *
597049Speter * GPL LICENSE SUMMARY
697049Speter *
797049Speter * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
897049Speter *
997049Speter * This program is free software; you can redistribute it and/or modify
1097049Speter * it under the terms of version 2 of the GNU General Public License as
1197049Speter * published by the Free Software Foundation.
1297049Speter *
1397049Speter * This program is distributed in the hope that it will be useful, but
1497049Speter * WITHOUT ANY WARRANTY; without even the implied warranty of
1597049Speter * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1697049Speter * General Public License for more details.
1797049Speter *
1897049Speter * You should have received a copy of the GNU General Public License
1997049Speter * along with this program; if not, write to the Free Software
2097049Speter * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
2197049Speter * The full GNU General Public License is included in this distribution
2297049Speter * in the file called LICENSE.GPL.
2397049Speter *
2497049Speter * BSD LICENSE
2597049Speter *
2697049Speter * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
2797049Speter * All rights reserved.
2897049Speter *
2997049Speter * Redistribution and use in source and binary forms, with or without
30166124Srafan * modification, are permitted provided that the following conditions
3197049Speter * are met:
3297049Speter *
3397049Speter *   * Redistributions of source code must retain the above copyright
3497049Speter *     notice, this list of conditions and the following disclaimer.
3597049Speter *   * Redistributions in binary form must reproduce the above copyright
3697049Speter *     notice, this list of conditions and the following disclaimer in
3797049Speter *     the documentation and/or other materials provided with the
3897049Speter *     distribution.
3997049Speter *
4097049Speter * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41166124Srafan * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4297049Speter * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43184989Srafan * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4497049Speter * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45166124Srafan * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46166124Srafan * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47166124Srafan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48166124Srafan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49166124Srafan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50166124Srafan * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51166124Srafan *
52166124Srafan * $FreeBSD$
53166124Srafan */
54166124Srafan#ifndef _SCI_BASE_REQUST_H_
55166124Srafan#define _SCI_BASE_REQUST_H_
56166124Srafan
57166124Srafan/**
58166124Srafan * @file
59166124Srafan *
6097049Speter * @brief This file contains all of the constants, types, and method
61166124Srafan *        declarations for the SCI base IO and task request objects.
6297049Speter */
63184989Srafan
6497049Speter#ifdef __cplusplus
65166124Srafanextern "C" {
6697049Speter#endif // __cplusplus
6797049Speter
6897049Speter#include <dev/isci/scil/sci_base_logger.h>
6997049Speter#include <dev/isci/scil/sci_base_state_machine.h>
70166124Srafan#include <dev/isci/scil/sci_base_state_machine_logger.h>
71166124Srafan
72166124Srafan/**
7397049Speter * @enum SCI_BASE_REQUEST_STATES
7497049Speter *
75166124Srafan * @brief This enumeration depicts all the states for the common request
7697049Speter *        state machine.
7797049Speter */
7897049Spetertypedef enum _SCI_BASE_REQUEST_STATES
7997049Speter{
80184989Srafan   /**
81184989Srafan    * Simply the initial state for the base request state machine.
82184989Srafan    */
83184989Srafan   SCI_BASE_REQUEST_STATE_INITIAL,
84184989Srafan
85184989Srafan   /**
86184989Srafan    * This state indicates that the request has been constructed. This state
87184989Srafan    * is entered from the INITIAL state.
88184989Srafan    */
89184989Srafan   SCI_BASE_REQUEST_STATE_CONSTRUCTED,
90184989Srafan
91184989Srafan   /**
92184989Srafan    * This state indicates that the request has been started. This state is
93184989Srafan    * entered from the CONSTRUCTED state.
94184989Srafan    */
95184989Srafan   SCI_BASE_REQUEST_STATE_STARTED,
96184989Srafan
97184989Srafan   /**
98184989Srafan    * This state indicates that the request has completed.
99184989Srafan    * This state is entered from the STARTED state. This state is entered from
100184989Srafan    * the ABORTING state.
101184989Srafan    */
102184989Srafan   SCI_BASE_REQUEST_STATE_COMPLETED,
103184989Srafan
10497049Speter   /**
105184989Srafan    * This state indicates that the request is in the process of being
106184989Srafan    * terminated/aborted.
107184989Srafan    * This state is entered from the CONSTRUCTED state.
108166124Srafan    * This state is entered from the STARTED state.
109184989Srafan    */
110184989Srafan   SCI_BASE_REQUEST_STATE_ABORTING,
111184989Srafan
112184989Srafan   /**
113184989Srafan    * Simply the final state for the base request state machine.
114184989Srafan    */
115184989Srafan   SCI_BASE_REQUEST_STATE_FINAL,
116184989Srafan
117184989Srafan   SCI_BASE_REQUEST_MAX_STATES
11897049Speter
11997049Speter} SCI_BASE_REQUEST_STATES;
12097049Speter
121184989Srafan/**
122184989Srafan * @struct SCI_BASE_REQUEST
12397049Speter *
12497049Speter * @brief The base request object abstracts the fields common to all SCI IO
125184989Srafan *        and task request objects.
126166124Srafan */
12797049Spetertypedef struct SCI_BASE_REQUEST
12897049Speter{
129   /**
130    * The field specifies that the parent object for the base request is the
131    * base object itself.
132    */
133   SCI_BASE_OBJECT_T parent;
134
135   /**
136    * This field contains the information for the base request state machine.
137    */
138   SCI_BASE_STATE_MACHINE_T state_machine;
139
140   #ifdef SCI_LOGGING
141   SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
142   #endif // SCI_LOGGING
143
144} SCI_BASE_REQUEST_T;
145
146typedef SCI_STATUS (*SCI_BASE_REQUEST_HANDLER_T)(
147   SCI_BASE_REQUEST_T * this_request
148);
149
150/**
151 * @struct SCI_BASE_REQUEST_STATE_HANDLER
152 *
153 * @brief This structure contains all of the state handler methods common to
154 *        base IO and task request state machines.  Handler methods provide
155 *        the ability to change the behavior for user requests or
156 *        transitions depending on the state the machine is in.
157 *
158 */
159typedef struct SCI_BASE_REQUEST_STATE_HANDLER
160{
161   /**
162    * The start_handler specifies the method invoked when a user attempts to
163    * start a request.
164    */
165   SCI_BASE_REQUEST_HANDLER_T start_handler;
166
167   /**
168    * The abort_handler specifies the method invoked when a user attempts to
169    * abort a request.
170    */
171   SCI_BASE_REQUEST_HANDLER_T abort_handler;
172
173   /**
174    * The complete_handler specifies the method invoked when a user attempts to
175    * complete a request.
176    */
177   SCI_BASE_REQUEST_HANDLER_T complete_handler;
178
179   /**
180    * The destruct_handler specifies the method invoked when a user attempts to
181    * destruct a request.
182    */
183   SCI_BASE_REQUEST_HANDLER_T destruct_handler;
184
185} SCI_BASE_REQUEST_STATE_HANDLER_T;
186
187/**
188 * @brief Construct the base request.
189 *
190 * @param[in] this_request This parameter specifies the base request
191 *            to be constructed.
192 * @param[in] logger This parameter specifies the logger associated with
193 *            this base request object.
194 * @param[in] state_table This parameter specifies the table of state
195 *            definitions to be utilized for the request state machine.
196 *
197 * @return none
198 */
199void sci_base_request_construct(
200   SCI_BASE_REQUEST_T    * this_request,
201   SCI_BASE_LOGGER_T     * logger,
202   SCI_BASE_STATE_T      * state_table
203);
204
205#ifdef __cplusplus
206}
207#endif // __cplusplus
208
209#endif // _SCI_BASE_REQUST_H_
210