1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3 * 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. 6 * 7 * GPL LICENSE SUMMARY 8 * 9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 10 * 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. 14 * 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. 19 * 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. 25 * 26 * BSD LICENSE 27 * 28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 29 * All rights reserved. 30 * 31 * Redistribution and use in source and binary forms, with or without 32 * modification, are permitted provided that the following conditions 33 * are met: 34 * 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 40 * distribution. 41 * 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. 53 * 54 * $FreeBSD$ 55 */ 56 #ifndef _SCI_BASE_REQUST_H_ 57 #define _SCI_BASE_REQUST_H_ 58 59 /** 60 * @file 61 * 62 * @brief This file contains all of the constants, types, and method 63 * declarations for the SCI base IO and task request objects. 64 */ 65 66 #ifdef __cplusplus 67 extern "C" { 68 #endif // __cplusplus 69 70 #include <dev/isci/scil/sci_base_logger.h> 71 #include <dev/isci/scil/sci_base_state_machine.h> 72 #include <dev/isci/scil/sci_base_state_machine_logger.h> 73 74 /** 75 * @enum SCI_BASE_REQUEST_STATES 76 * 77 * @brief This enumeration depicts all the states for the common request 78 * state machine. 79 */ 80 typedef enum _SCI_BASE_REQUEST_STATES 81 { 82 /** 83 * Simply the initial state for the base request state machine. 84 */ 85 SCI_BASE_REQUEST_STATE_INITIAL, 86 87 /** 88 * This state indicates that the request has been constructed. This state 89 * is entered from the INITIAL state. 90 */ 91 SCI_BASE_REQUEST_STATE_CONSTRUCTED, 92 93 /** 94 * This state indicates that the request has been started. This state is 95 * entered from the CONSTRUCTED state. 96 */ 97 SCI_BASE_REQUEST_STATE_STARTED, 98 99 /** 100 * This state indicates that the request has completed. 101 * This state is entered from the STARTED state. This state is entered from 102 * the ABORTING state. 103 */ 104 SCI_BASE_REQUEST_STATE_COMPLETED, 105 106 /** 107 * This state indicates that the request is in the process of being 108 * terminated/aborted. 109 * This state is entered from the CONSTRUCTED state. 110 * This state is entered from the STARTED state. 111 */ 112 SCI_BASE_REQUEST_STATE_ABORTING, 113 114 /** 115 * Simply the final state for the base request state machine. 116 */ 117 SCI_BASE_REQUEST_STATE_FINAL, 118 119 SCI_BASE_REQUEST_MAX_STATES 120 121 } SCI_BASE_REQUEST_STATES; 122 123 /** 124 * @struct SCI_BASE_REQUEST 125 * 126 * @brief The base request object abstracts the fields common to all SCI IO 127 * and task request objects. 128 */ 129 typedef struct SCI_BASE_REQUEST 130 { 131 /** 132 * The field specifies that the parent object for the base request is the 133 * base object itself. 134 */ 135 SCI_BASE_OBJECT_T parent; 136 137 /** 138 * This field contains the information for the base request state machine. 139 */ 140 SCI_BASE_STATE_MACHINE_T state_machine; 141 142 #ifdef SCI_LOGGING 143 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger; 144 #endif // SCI_LOGGING 145 146 } SCI_BASE_REQUEST_T; 147 148 typedef SCI_STATUS (*SCI_BASE_REQUEST_HANDLER_T)( 149 SCI_BASE_REQUEST_T * this_request 150 ); 151 152 /** 153 * @struct SCI_BASE_REQUEST_STATE_HANDLER 154 * 155 * @brief This structure contains all of the state handler methods common to 156 * base IO and task request state machines. Handler methods provide 157 * the ability to change the behavior for user requests or 158 * transitions depending on the state the machine is in. 159 * 160 */ 161 typedef struct SCI_BASE_REQUEST_STATE_HANDLER 162 { 163 /** 164 * The start_handler specifies the method invoked when a user attempts to 165 * start a request. 166 */ 167 SCI_BASE_REQUEST_HANDLER_T start_handler; 168 169 /** 170 * The abort_handler specifies the method invoked when a user attempts to 171 * abort a request. 172 */ 173 SCI_BASE_REQUEST_HANDLER_T abort_handler; 174 175 /** 176 * The complete_handler specifies the method invoked when a user attempts to 177 * complete a request. 178 */ 179 SCI_BASE_REQUEST_HANDLER_T complete_handler; 180 181 /** 182 * The destruct_handler specifies the method invoked when a user attempts to 183 * destruct a request. 184 */ 185 SCI_BASE_REQUEST_HANDLER_T destruct_handler; 186 187 } SCI_BASE_REQUEST_STATE_HANDLER_T; 188 189 /** 190 * @brief Construct the base request. 191 * 192 * @param[in] this_request This parameter specifies the base request 193 * to be constructed. 194 * @param[in] logger This parameter specifies the logger associated with 195 * this base request object. 196 * @param[in] state_table This parameter specifies the table of state 197 * definitions to be utilized for the request state machine. 198 * 199 * @return none 200 */ 201 void sci_base_request_construct( 202 SCI_BASE_REQUEST_T * this_request, 203 SCI_BASE_LOGGER_T * logger, 204 SCI_BASE_STATE_T * state_table 205 ); 206 207 #ifdef __cplusplus 208 } 209 #endif // __cplusplus 210 211 #endif // _SCI_BASE_REQUST_H_ 212