2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
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.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
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
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.
56 #ifndef _SCI_BASE_PORT_H_
57 #define _SCI_BASE_PORT_H_
62 * @brief This file contains all of the structures, constants, and methods
63 * common to all port object definitions.
70 #include <dev/isci/scil/sci_base_object.h>
71 #include <dev/isci/scil/sci_base_logger.h>
72 #include <dev/isci/scil/sci_base_state_machine.h>
73 #include <dev/isci/scil/sci_base_state_machine_logger.h>
76 * @enum SCI_BASE_PORT_STATES
78 * @brief This enumeration depicts all the states for the common port
81 typedef enum _SCI_BASE_PORT_STATES
84 * This state indicates that the port has successfully been stopped.
85 * In this state no new IO operations are permitted.
86 * This state is entered from the STOPPING state.
88 SCI_BASE_PORT_STATE_STOPPED,
91 * This state indicates that the port is in the process of stopping.
92 * In this state no new IO operations are permitted, but existing IO
93 * operations are allowed to complete.
94 * This state is entered from the READY state.
96 SCI_BASE_PORT_STATE_STOPPING,
99 * This state indicates the port is now ready. Thus, the user is
100 * able to perform IO operations on this port.
101 * This state is entered from the STARTING state.
103 SCI_BASE_PORT_STATE_READY,
106 * This state indicates the port is in the process of performing a hard
107 * reset. Thus, the user is unable to perform IO operations on this
109 * This state is entered from the READY state.
111 SCI_BASE_PORT_STATE_RESETTING,
114 * This state indicates the port has failed a reset request. This state
115 * is entered when a port reset request times out.
116 * This state is entered from the RESETTING state.
118 SCI_BASE_PORT_STATE_FAILED,
120 SCI_BASE_PORT_MAX_STATES
122 } SCI_BASE_PORT_STATES;
125 * @struct SCI_BASE_PORT
127 * @brief The base port object abstracts the fields common to all SCI
130 typedef struct SCI_BASE_PORT
133 * The field specifies that the parent object for the base controller
134 * is the base object itself.
136 SCI_BASE_OBJECT_T parent;
139 * This field contains the information for the base port state machine.
141 SCI_BASE_STATE_MACHINE_T state_machine;
144 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
145 #endif // SCI_LOGGING
151 typedef SCI_STATUS (*SCI_BASE_PORT_HANDLER_T)(
155 typedef SCI_STATUS (*SCI_BASE_PORT_PHY_HANDLER_T)(
157 struct SCI_BASE_PHY *
160 typedef SCI_STATUS (*SCI_BASE_PORT_RESET_HANDLER_T)(
166 * @struct SCI_BASE_PORT_STATE_HANDLER
168 * @brief This structure contains all of the state handler methods common to
169 * base port state machines. Handler methods provide the ability
170 * to change the behavior for user requests or transitions depending
171 * on the state the machine is in.
173 typedef struct SCI_BASE_PORT_STATE_HANDLER
176 * The start_handler specifies the method invoked when a user attempts to
179 SCI_BASE_PORT_HANDLER_T start_handler;
182 * The stop_handler specifies the method invoked when a user attempts to
185 SCI_BASE_PORT_HANDLER_T stop_handler;
188 * The destruct_handler specifies the method invoked when attempting to
191 SCI_BASE_PORT_HANDLER_T destruct_handler;
194 * The reset_handler specifies the method invoked when a user attempts to
197 SCI_BASE_PORT_RESET_HANDLER_T reset_handler;
200 * The add_phy_handler specifies the method invoked when a user attempts to
201 * add another phy into the port.
203 SCI_BASE_PORT_PHY_HANDLER_T add_phy_handler;
206 * The remove_phy_handler specifies the method invoked when a user
207 * attempts to remove a phy from the port.
209 SCI_BASE_PORT_PHY_HANDLER_T remove_phy_handler;
211 } SCI_BASE_PORT_STATE_HANDLER_T;
214 * @brief Construct the base port object
216 * @param[in] this_port This parameter specifies the base port to be
218 * @param[in] logger This parameter specifies the logger to be associated
219 * with this base port object.
220 * @param[in] state_table This parameter specifies the table of state
221 * definitions to be utilized for the domain state machine.
225 void sci_base_port_construct(
226 SCI_BASE_PORT_T * this_port,
227 SCI_BASE_LOGGER_T * logger,
228 SCI_BASE_STATE_T * state_table
233 #endif // __cplusplus
235 #endif // _SCI_BASE_PORT_H_