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
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.
54 #ifndef _SCI_BASE_PORT_H_
55 #define _SCI_BASE_PORT_H_
60 * @brief This file contains all of the structures, constants, and methods
61 * common to all port object definitions.
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>
74 * @enum SCI_BASE_PORT_STATES
76 * @brief This enumeration depicts all the states for the common port
79 typedef enum _SCI_BASE_PORT_STATES
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.
86 SCI_BASE_PORT_STATE_STOPPED,
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.
94 SCI_BASE_PORT_STATE_STOPPING,
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.
101 SCI_BASE_PORT_STATE_READY,
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
107 * This state is entered from the READY state.
109 SCI_BASE_PORT_STATE_RESETTING,
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.
116 SCI_BASE_PORT_STATE_FAILED,
118 SCI_BASE_PORT_MAX_STATES
120 } SCI_BASE_PORT_STATES;
123 * @struct SCI_BASE_PORT
125 * @brief The base port object abstracts the fields common to all SCI
128 typedef struct SCI_BASE_PORT
131 * The field specifies that the parent object for the base controller
132 * is the base object itself.
134 SCI_BASE_OBJECT_T parent;
137 * This field contains the information for the base port state machine.
139 SCI_BASE_STATE_MACHINE_T state_machine;
142 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
143 #endif // SCI_LOGGING
149 typedef SCI_STATUS (*SCI_BASE_PORT_HANDLER_T)(
153 typedef SCI_STATUS (*SCI_BASE_PORT_PHY_HANDLER_T)(
155 struct SCI_BASE_PHY *
158 typedef SCI_STATUS (*SCI_BASE_PORT_RESET_HANDLER_T)(
164 * @struct SCI_BASE_PORT_STATE_HANDLER
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.
171 typedef struct SCI_BASE_PORT_STATE_HANDLER
174 * The start_handler specifies the method invoked when a user attempts to
177 SCI_BASE_PORT_HANDLER_T start_handler;
180 * The stop_handler specifies the method invoked when a user attempts to
183 SCI_BASE_PORT_HANDLER_T stop_handler;
186 * The destruct_handler specifies the method invoked when attempting to
189 SCI_BASE_PORT_HANDLER_T destruct_handler;
192 * The reset_handler specifies the method invoked when a user attempts to
195 SCI_BASE_PORT_RESET_HANDLER_T reset_handler;
198 * The add_phy_handler specifies the method invoked when a user attempts to
199 * add another phy into the port.
201 SCI_BASE_PORT_PHY_HANDLER_T add_phy_handler;
204 * The remove_phy_handler specifies the method invoked when a user
205 * attempts to remove a phy from the port.
207 SCI_BASE_PORT_PHY_HANDLER_T remove_phy_handler;
209 } SCI_BASE_PORT_STATE_HANDLER_T;
212 * @brief Construct the base port object
214 * @param[in] this_port This parameter specifies the base port to be
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.
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
231 #endif // __cplusplus
233 #endif // _SCI_BASE_PORT_H_