sci_base_request.h revision 272461
1249259Sdim/*-
2249259Sdim * This file is provided under a dual BSD/GPLv2 license.  When using or
3249259Sdim * redistributing this file, you may do so under either license.
4249259Sdim *
5249259Sdim * GPL LICENSE SUMMARY
6249259Sdim *
7249259Sdim * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8249259Sdim *
9249259Sdim * This program is free software; you can redistribute it and/or modify
10249259Sdim * it under the terms of version 2 of the GNU General Public License as
11249259Sdim * published by the Free Software Foundation.
12249259Sdim *
13249259Sdim * This program is distributed in the hope that it will be useful, but
14249259Sdim * WITHOUT ANY WARRANTY; without even the implied warranty of
15249259Sdim * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16249259Sdim * General Public License for more details.
17249259Sdim *
18249259Sdim * You should have received a copy of the GNU General Public License
19249259Sdim * along with this program; if not, write to the Free Software
20249259Sdim * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21249259Sdim * The full GNU General Public License is included in this distribution
22249259Sdim * in the file called LICENSE.GPL.
23249259Sdim *
24249259Sdim * BSD LICENSE
25249259Sdim *
26249259Sdim * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27249259Sdim * All rights reserved.
28249259Sdim *
29249259Sdim * Redistribution and use in source and binary forms, with or without
30251662Sdim * modification, are permitted provided that the following conditions
31249259Sdim * are met:
32249259Sdim *
33249259Sdim *   * Redistributions of source code must retain the above copyright
34249259Sdim *     notice, this list of conditions and the following disclaimer.
35249259Sdim *   * Redistributions in binary form must reproduce the above copyright
36249259Sdim *     notice, this list of conditions and the following disclaimer in
37249259Sdim *     the documentation and/or other materials provided with the
38249259Sdim *     distribution.
39249259Sdim *
40249259Sdim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41249259Sdim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42249259Sdim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43249259Sdim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44249259Sdim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45249259Sdim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46251662Sdim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47251662Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48251662Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49251662Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50251662Sdim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51251662Sdim *
52249259Sdim * $FreeBSD: releng/10.1/sys/dev/isci/scil/sci_base_request.h 231136 2012-02-07 17:43:58Z jimharris $
53249259Sdim */
54249259Sdim#ifndef _SCI_BASE_REQUST_H_
55249259Sdim#define _SCI_BASE_REQUST_H_
56249259Sdim
57249259Sdim/**
58249259Sdim * @file
59249259Sdim *
60249259Sdim * @brief This file contains all of the constants, types, and method
61249259Sdim *        declarations for the SCI base IO and task request objects.
62249259Sdim */
63249259Sdim
64249259Sdim#ifdef __cplusplus
65249259Sdimextern "C" {
66249259Sdim#endif // __cplusplus
67249259Sdim
68249259Sdim#include <dev/isci/scil/sci_base_logger.h>
69249259Sdim#include <dev/isci/scil/sci_base_state_machine.h>
70249259Sdim#include <dev/isci/scil/sci_base_state_machine_logger.h>
71249259Sdim
72249259Sdim/**
73249259Sdim * @enum SCI_BASE_REQUEST_STATES
74249259Sdim *
75249259Sdim * @brief This enumeration depicts all the states for the common request
76249259Sdim *        state machine.
77249259Sdim */
78249259Sdimtypedef enum _SCI_BASE_REQUEST_STATES
79249259Sdim{
80249259Sdim   /**
81249259Sdim    * Simply the initial state for the base request state machine.
82249259Sdim    */
83249259Sdim   SCI_BASE_REQUEST_STATE_INITIAL,
84249259Sdim
85249259Sdim   /**
86249259Sdim    * This state indicates that the request has been constructed. This state
87249259Sdim    * is entered from the INITIAL state.
88249259Sdim    */
89249259Sdim   SCI_BASE_REQUEST_STATE_CONSTRUCTED,
90249259Sdim
91249259Sdim   /**
92249259Sdim    * This state indicates that the request has been started. This state is
93249259Sdim    * entered from the CONSTRUCTED state.
94249259Sdim    */
95249259Sdim   SCI_BASE_REQUEST_STATE_STARTED,
96249259Sdim
97249259Sdim   /**
98249259Sdim    * This state indicates that the request has completed.
99249259Sdim    * This state is entered from the STARTED state. This state is entered from
100249259Sdim    * the ABORTING state.
101249259Sdim    */
102249259Sdim   SCI_BASE_REQUEST_STATE_COMPLETED,
103249259Sdim
104249259Sdim   /**
105249259Sdim    * This state indicates that the request is in the process of being
106249259Sdim    * terminated/aborted.
107249259Sdim    * This state is entered from the CONSTRUCTED state.
108249259Sdim    * This state is entered from the STARTED state.
109249259Sdim    */
110249259Sdim   SCI_BASE_REQUEST_STATE_ABORTING,
111249259Sdim
112249259Sdim   /**
113249259Sdim    * Simply the final state for the base request state machine.
114249259Sdim    */
115249259Sdim   SCI_BASE_REQUEST_STATE_FINAL,
116249259Sdim
117249259Sdim   SCI_BASE_REQUEST_MAX_STATES
118249259Sdim
119249259Sdim} SCI_BASE_REQUEST_STATES;
120249259Sdim
121249259Sdim/**
122249259Sdim * @struct SCI_BASE_REQUEST
123249259Sdim *
124249259Sdim * @brief The base request object abstracts the fields common to all SCI IO
125249259Sdim *        and task request objects.
126249259Sdim */
127249259Sdimtypedef struct SCI_BASE_REQUEST
128249259Sdim{
129249259Sdim   /**
130249259Sdim    * The field specifies that the parent object for the base request is the
131249259Sdim    * base object itself.
132249259Sdim    */
133249259Sdim   SCI_BASE_OBJECT_T parent;
134249259Sdim
135249259Sdim   /**
136249259Sdim    * This field contains the information for the base request state machine.
137249259Sdim    */
138249259Sdim   SCI_BASE_STATE_MACHINE_T state_machine;
139249259Sdim
140249259Sdim   #ifdef SCI_LOGGING
141249259Sdim   SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
142249259Sdim   #endif // SCI_LOGGING
143249259Sdim
144249259Sdim} SCI_BASE_REQUEST_T;
145249259Sdim
146249259Sdimtypedef SCI_STATUS (*SCI_BASE_REQUEST_HANDLER_T)(
147249259Sdim   SCI_BASE_REQUEST_T * this_request
148249259Sdim);
149249259Sdim
150249259Sdim/**
151249259Sdim * @struct SCI_BASE_REQUEST_STATE_HANDLER
152249259Sdim *
153249259Sdim * @brief This structure contains all of the state handler methods common to
154249259Sdim *        base IO and task request state machines.  Handler methods provide
155249259Sdim *        the ability to change the behavior for user requests or
156249259Sdim *        transitions depending on the state the machine is in.
157249259Sdim *
158249259Sdim */
159249259Sdimtypedef struct SCI_BASE_REQUEST_STATE_HANDLER
160249259Sdim{
161249259Sdim   /**
162249259Sdim    * The start_handler specifies the method invoked when a user attempts to
163249259Sdim    * start a request.
164249259Sdim    */
165251662Sdim   SCI_BASE_REQUEST_HANDLER_T start_handler;
166251662Sdim
167249259Sdim   /**
168251662Sdim    * The abort_handler specifies the method invoked when a user attempts to
169251662Sdim    * abort a request.
170251662Sdim    */
171251662Sdim   SCI_BASE_REQUEST_HANDLER_T abort_handler;
172251662Sdim
173251662Sdim   /**
174251662Sdim    * The complete_handler specifies the method invoked when a user attempts to
175251662Sdim    * complete a request.
176251662Sdim    */
177251662Sdim   SCI_BASE_REQUEST_HANDLER_T complete_handler;
178251662Sdim
179251662Sdim   /**
180249259Sdim    * The destruct_handler specifies the method invoked when a user attempts to
181251662Sdim    * destruct a request.
182251662Sdim    */
183251662Sdim   SCI_BASE_REQUEST_HANDLER_T destruct_handler;
184251662Sdim
185251662Sdim} SCI_BASE_REQUEST_STATE_HANDLER_T;
186251662Sdim
187251662Sdim/**
188251662Sdim * @brief Construct the base request.
189251662Sdim *
190251662Sdim * @param[in] this_request This parameter specifies the base request
191249259Sdim *            to be constructed.
192249259Sdim * @param[in] logger This parameter specifies the logger associated with
193249259Sdim *            this base request object.
194251662Sdim * @param[in] state_table This parameter specifies the table of state
195249259Sdim *            definitions to be utilized for the request state machine.
196249259Sdim *
197251662Sdim * @return none
198251662Sdim */
199251662Sdimvoid sci_base_request_construct(
200251662Sdim   SCI_BASE_REQUEST_T    * this_request,
201251662Sdim   SCI_BASE_LOGGER_T     * logger,
202251662Sdim   SCI_BASE_STATE_T      * state_table
203251662Sdim);
204251662Sdim
205249259Sdim#ifdef __cplusplus
206251662Sdim}
207251662Sdim#endif // __cplusplus
208251662Sdim
209251662Sdim#endif // _SCI_BASE_REQUST_H_
210251662Sdim