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_PORT_H_ 55 #define _SCI_BASE_PORT_H_ 56 57 /** 58 * @file 59 * 60 * @brief This file contains all of the structures, constants, and methods 61 * common to all port 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_PORT_STATES 75 * 76 * @brief This enumeration depicts all the states for the common port 77 * state machine. 78 */ 79 typedef enum _SCI_BASE_PORT_STATES 80 { 81 /** 82 * This state indicates that the port has successfully been stopped. 83 * In this state no new IO operations are permitted. 84 * This state is entered from the STOPPING state. 85 */ 86 SCI_BASE_PORT_STATE_STOPPED, 87 88 /** 89 * This state indicates that the port is in the process of stopping. 90 * In this state no new IO operations are permitted, but existing IO 91 * operations are allowed to complete. 92 * This state is entered from the READY state. 93 */ 94 SCI_BASE_PORT_STATE_STOPPING, 95 96 /** 97 * This state indicates the port is now ready. Thus, the user is 98 * able to perform IO operations on this port. 99 * This state is entered from the STARTING state. 100 */ 101 SCI_BASE_PORT_STATE_READY, 102 103 /** 104 * This state indicates the port is in the process of performing a hard 105 * reset. Thus, the user is unable to perform IO operations on this 106 * port. 107 * This state is entered from the READY state. 108 */ 109 SCI_BASE_PORT_STATE_RESETTING, 110 111 /** 112 * This state indicates the port has failed a reset request. This state 113 * is entered when a port reset request times out. 114 * This state is entered from the RESETTING state. 115 */ 116 SCI_BASE_PORT_STATE_FAILED, 117 118 SCI_BASE_PORT_MAX_STATES 119 120 } SCI_BASE_PORT_STATES; 121 122 /** 123 * @struct SCI_BASE_PORT 124 * 125 * @brief The base port object abstracts the fields common to all SCI 126 * port objects. 127 */ 128 typedef struct SCI_BASE_PORT 129 { 130 /** 131 * The field specifies that the parent object for the base controller 132 * is the base object itself. 133 */ 134 SCI_BASE_OBJECT_T parent; 135 136 /** 137 * This field contains the information for the base port state machine. 138 */ 139 SCI_BASE_STATE_MACHINE_T state_machine; 140 141 #ifdef SCI_LOGGING 142 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger; 143 #endif // SCI_LOGGING 144 145 } SCI_BASE_PORT_T; 146 147 struct SCI_BASE_PHY; 148 149 typedef SCI_STATUS (*SCI_BASE_PORT_HANDLER_T)( 150 SCI_BASE_PORT_T * 151 ); 152 153 typedef SCI_STATUS (*SCI_BASE_PORT_PHY_HANDLER_T)( 154 SCI_BASE_PORT_T *, 155 struct SCI_BASE_PHY * 156 ); 157 158 typedef SCI_STATUS (*SCI_BASE_PORT_RESET_HANDLER_T)( 159 SCI_BASE_PORT_T *, 160 U32 timeout 161 ); 162 163 /** 164 * @struct SCI_BASE_PORT_STATE_HANDLER 165 * 166 * @brief This structure contains all of the state handler methods common to 167 * base port state machines. Handler methods provide the ability 168 * to change the behavior for user requests or transitions depending 169 * on the state the machine is in. 170 */ 171 typedef struct SCI_BASE_PORT_STATE_HANDLER 172 { 173 /** 174 * The start_handler specifies the method invoked when a user attempts to 175 * start a port. 176 */ 177 SCI_BASE_PORT_HANDLER_T start_handler; 178 179 /** 180 * The stop_handler specifies the method invoked when a user attempts to 181 * stop a port. 182 */ 183 SCI_BASE_PORT_HANDLER_T stop_handler; 184 185 /** 186 * The destruct_handler specifies the method invoked when attempting to 187 * destruct a port. 188 */ 189 SCI_BASE_PORT_HANDLER_T destruct_handler; 190 191 /** 192 * The reset_handler specifies the method invoked when a user attempts to 193 * hard reset a port. 194 */ 195 SCI_BASE_PORT_RESET_HANDLER_T reset_handler; 196 197 /** 198 * The add_phy_handler specifies the method invoked when a user attempts to 199 * add another phy into the port. 200 */ 201 SCI_BASE_PORT_PHY_HANDLER_T add_phy_handler; 202 203 /** 204 * The remove_phy_handler specifies the method invoked when a user 205 * attempts to remove a phy from the port. 206 */ 207 SCI_BASE_PORT_PHY_HANDLER_T remove_phy_handler; 208 209 } SCI_BASE_PORT_STATE_HANDLER_T; 210 211 /** 212 * @brief Construct the base port object 213 * 214 * @param[in] this_port This parameter specifies the base port to be 215 * constructed. 216 * @param[in] logger This parameter specifies the logger to be associated 217 * with this base port object. 218 * @param[in] state_table This parameter specifies the table of state 219 * definitions to be utilized for the domain state machine. 220 * 221 * @return none 222 */ 223 void sci_base_port_construct( 224 SCI_BASE_PORT_T * this_port, 225 SCI_BASE_LOGGER_T * logger, 226 SCI_BASE_STATE_T * state_table 227 ); 228 229 #ifdef __cplusplus 230 } 231 #endif // __cplusplus 232 233 #endif // _SCI_BASE_PORT_H_ 234