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_PHY_H_
57 #define _SCI_BASE_PHY_H_
58
59 /**
60 * @file
61 *
62 * @brief This file contains all of the structures, constants, and methods
63 * common to all phy object definitions.
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_PHY_STATES
76 *
77 * @brief This enumeration depicts the standard states common to all phy
78 * state machine implementations.
79 */
80 typedef enum _SCI_BASE_PHY_STATES
81 {
82 /**
83 * Simply the initial state for the base domain state machine.
84 */
85 SCI_BASE_PHY_STATE_INITIAL,
86
87 /**
88 * This state indicates that the phy has successfully been stopped.
89 * In this state no new IO operations are permitted on this phy.
90 * This state is entered from the INITIAL state.
91 * This state is entered from the STARTING state.
92 * This state is entered from the READY state.
93 * This state is entered from the RESETTING state.
94 */
95 SCI_BASE_PHY_STATE_STOPPED,
96
97 /**
98 * This state indicates that the phy is in the process of becoming
99 * ready. In this state no new IO operations are permitted on this phy.
100 * This state is entered from the STOPPED state.
101 * This state is entered from the READY state.
102 * This state is entered from the RESETTING state.
103 */
104 SCI_BASE_PHY_STATE_STARTING,
105
106 /**
107 * This state indicates the phy is now ready. Thus, the user
108 * is able to perform IO operations utilizing this phy as long as it
109 * is currently part of a valid port.
110 * This state is entered from the STARTING state.
111 */
112 SCI_BASE_PHY_STATE_READY,
113
114 /**
115 * This state indicates that the phy is in the process of being reset.
116 * In this state no new IO operations are permitted on this phy.
117 * This state is entered from the READY state.
118 */
119 SCI_BASE_PHY_STATE_RESETTING,
120
121 /**
122 * Simply the final state for the base phy state machine.
123 */
124 SCI_BASE_PHY_STATE_FINAL,
125
126 SCI_BASE_PHY_MAX_STATES
127
128 } SCI_BASE_PHY_STATES;
129
130 /**
131 * @struct SCI_BASE_PHY
132 *
133 * @brief This structure defines all of the fields common to PHY objects.
134 */
135 typedef struct SCI_BASE_PHY
136 {
137 /**
138 * This field depicts the parent object (SCI_BASE_OBJECT) for the phy.
139 */
140 SCI_BASE_OBJECT_T parent;
141
142 /**
143 * This field contains the information for the base phy state machine.
144 */
145 SCI_BASE_STATE_MACHINE_T state_machine;
146
147 #ifdef SCI_LOGGING
148 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
149 #endif // SCI_LOGGING
150
151 } SCI_BASE_PHY_T;
152
153 typedef SCI_STATUS (*SCI_BASE_PHY_HANDLER_T)(
154 SCI_BASE_PHY_T *
155 );
156
157 /**
158 * @struct SCI_BASE_PHY_STATE_HANDLER
159 *
160 * @brief This structure contains all of the state handler methods common to
161 * base phy state machines. Handler methods provide the ability
162 * to change the behavior for user requests or transitions depending
163 * on the state the machine is in.
164 */
165 typedef struct SCI_BASE_PHY_STATE_HANDLER
166 {
167 /**
168 * The start_handler specifies the method invoked when there is an
169 * attempt to start a phy.
170 */
171 SCI_BASE_PHY_HANDLER_T start_handler;
172
173 /**
174 * The stop_handler specifies the method invoked when there is an
175 * attempt to stop a phy.
176 */
177 SCI_BASE_PHY_HANDLER_T stop_handler;
178
179 /**
180 * The reset_handler specifies the method invoked when there is an
181 * attempt to reset a phy.
182 */
183 SCI_BASE_PHY_HANDLER_T reset_handler;
184
185 /**
186 * The destruct_handler specifies the method invoked when attempting to
187 * destruct a phy.
188 */
189 SCI_BASE_PHY_HANDLER_T destruct_handler;
190
191 } SCI_BASE_PHY_STATE_HANDLER_T;
192
193 /**
194 * @brief Construct the base phy
195 *
196 * @param[in] this_phy This parameter specifies the base phy to be
197 * constructed.
198 * @param[in] logger This parameter specifies the logger associated with
199 * this base phy object.
200 * @param[in] state_table This parameter specifies the table of state
201 * definitions to be utilized for the phy state machine.
202 *
203 * @return none
204 */
205 void sci_base_phy_construct(
206 SCI_BASE_PHY_T * this_phy,
207 SCI_BASE_LOGGER_T * logger,
208 SCI_BASE_STATE_T * state_table
209 );
210
211 #ifdef __cplusplus
212 }
213 #endif // __cplusplus
214
215 #endif // _SCI_BASE_PHY_H_
Cache object: 6fb596fe8cd4bb78c9ff3737e4e45de3
|