xref: /freebsd/sys/dev/isci/scil/sci_types.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
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 #ifndef _SCI_TYPES_H_
55 #define _SCI_TYPES_H_
56 
57 /**
58  * @file
59  *
60  * @brief This file contains all of the basic data types utilized by an
61  *        SCI user or implementor.
62  */
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif // __cplusplus
67 
68 #include <dev/isci/types.h>
69 
70 #ifndef sci_cb_physical_address_upper
71 #error "sci_cb_physical_address_upper needs to be defined in appropriate environment.h"
72 #endif
73 
74 #ifndef sci_cb_physical_address_lower
75 #error "sci_cb_physical_address_lower needs to be defined in appropriate environment.h"
76 #endif
77 
78 #ifndef sci_cb_make_physical_address
79 #error "sci_cb_make_physical_address needs to be defined in appropriate environment.h"
80 #endif
81 
82 #ifndef ASSERT
83 #error "ASSERT needs to be defined in appropriate environment.h or system"
84 #endif
85 
86 
87 /**
88  * This constant defines the value utilized by SCI Components to indicate
89  * an invalid handle.
90  */
91 #define SCI_INVALID_HANDLE 0x0
92 
93 /**
94  * @typedef SCI_OBJECT_HANDLE_T
95  * @brief   This typedef just provides an opaque handle for all SCI
96  *          objects.
97  */
98 typedef void* SCI_OBJECT_HANDLE_T;
99 
100 /**
101  * @typedef SCI_LOGGER_HANDLE_T
102  * @brief   This typedef just provides an opaque handle for all SCI
103  *          Logger objects.
104  */
105 typedef void* SCI_LOGGER_HANDLE_T;
106 
107 /**
108  * @typedef SCI_IO_REQUEST_HANDLE_T
109  * @brief   The SCI_IO_REQUEST_HANDLE_T will be utilized by SCI users as an
110  *          opaque handle for the various SCI IO Request objects.
111  */
112 typedef void * SCI_IO_REQUEST_HANDLE_T;
113 
114 /**
115  * @typedef SCI_TASK_REQUEST_HANDLE_T
116  * @brief   The SCI_TASK_REQUEST_HANDLE_T will be utilized by SCI users as an
117  *          opaque handle for the various SCI Task Management Request objects.
118  */
119 typedef void * SCI_TASK_REQUEST_HANDLE_T;
120 
121 /**
122  * @typedef SCI_PHY_HANDLE_T
123  * @brief   This typedef just provides an opaque handle for all SCI
124  *          Phy objects.
125  */
126 typedef void * SCI_PHY_HANDLE_T;
127 
128 /**
129  * @typedef SCI_REMOTE_DEVICE_HANDLE_T
130  * @brief   The SCI_REMOTE_DEVICE_HANDLE_T will be utilized by SCI users as
131  *          an opaque handle for the SCI remote device object.
132  */
133 typedef void * SCI_REMOTE_DEVICE_HANDLE_T;
134 
135 /**
136  * @typedef SCI_DOMAIN_HANDLE_T
137  * @brief   This typedef just provides an opaque handle for all SCI
138  *          Domain objects.
139  */
140 typedef void* SCI_DOMAIN_HANDLE_T;
141 
142 /**
143  * @typedef SCI_PORT_HANDLE_T
144  * @brief   This typedef just provides an opaque handle for all SCI
145  *          SAS or SATA Port objects.
146  */
147 typedef void * SCI_PORT_HANDLE_T;
148 
149 /**
150  * @typedef SCI_MEMORY_DESCRIPTOR_LIST_HANDLE_T
151  * @brief   The SCI_MEMORY_DESCRIPTOR_LIST_HANDLE_T will be utilized by SCI
152  *          users as an opaque handle for the SCI MEMORY DESCRIPTOR LIST object.
153  */
154 typedef void * SCI_MEMORY_DESCRIPTOR_LIST_HANDLE_T;
155 
156 /**
157  * @typedef SCI_LOCK_HANDLE_T
158  * @brief   The SCI_LOCK_HANDLE_T will be utilized by SCI users as an
159  *          opaque handle for the SCI LOCK object.  A lock denotes a
160  *          critical code section of some form.
161  */
162 typedef void * SCI_LOCK_HANDLE_T;
163 
164 /**
165  * @typedef SCI_CONTROLLER_HANDLE_T
166  * @brief   The SCI_CONTROLLER_HANDLE_T will be utilized by SCI users as an
167  *          opaque handle for all SCI Controller objects.
168  */
169 typedef void * SCI_CONTROLLER_HANDLE_T;
170 
171 /**
172  * @typedef SCI_LIBRARY_HANDLE_T
173  * @brief   The SCI_LIBRARY_HANDLE_T will be utilized by SCI users as an
174  *          opaque handle for the SCI Library object.
175  */
176 typedef void * SCI_LIBRARY_HANDLE_T;
177 
178 /**
179  * @typedef SCI_ITERATOR_HANDLE_T
180  * @brief   The SCI_ITERATOR_T will be utilized by SCI users as an
181  *          opaque handle for the SCI Iterator object.
182  */
183 typedef void * SCI_ITERATOR_HANDLE_T;
184 
185 /**
186  * @typedef SCI_TIMER_CALLBACK_T
187  * @brief   This callback defines the format of all other timer callback
188  *          methods that are to be implemented by an SCI user, including
189  *          the method that will be invoked as a result of timer expiration.
190  *
191  *          Parameters:
192  *          - The void* value passed into the callback represents the cookie
193  *            supplied by the SCI component when the timer was created.
194  *
195  *          Return:
196  *          - None
197  */
198 typedef void (*SCI_TIMER_CALLBACK_T)(void*);
199 
200 /**
201  * @brief This enumeration is provided so the SCI User can communicate the
202  *        data direction for an IO request.
203  */
204 typedef enum
205 {
206    /**
207     * The data direction for the request is in (a read operation)
208     * This is also the value to use for an io request that has no specific
209     * data direction.
210     */
211    SCI_IO_REQUEST_DATA_IN = 0,
212 
213    /**
214     * The data direction for the request is out (a write operation)
215     */
216    SCI_IO_REQUEST_DATA_OUT,
217 
218    /**
219     * There is no data transfer for the associated request.
220     */
221    SCI_IO_REQUEST_NO_DATA
222 
223 } SCI_IO_REQUEST_DATA_DIRECTION;
224 
225 /**
226  * @enum  SCI_LOCK_LEVEL
227  * @brief This enumeration defines the various lock levels utilized by
228  *        the SCI component.  These lock levels help inform users, of the
229  *        library, about what APIs must be protected from other APIs.
230  *        The higher the lock level the more restricted the access.  For
231  *        example, APIs specifying lock level 5 are allowed to be executed
232  *        while an API of lock level 4 is on-going, but the converse is
233  *        not true.
234  */
235 typedef enum
236 {
237    /**
238     * This value indicates there is no lock level required.  This is
239     * primarily utilized for situations in which there is a true critical
240     * code section that merely needs to protect against access to a
241     * region of memory.
242     */
243    SCI_LOCK_LEVEL_NONE,
244 
245    SCI_LOCK_LEVEL_1,
246    SCI_LOCK_LEVEL_2,
247    SCI_LOCK_LEVEL_3,
248    SCI_LOCK_LEVEL_4,
249    SCI_LOCK_LEVEL_5
250 
251 } SCI_LOCK_LEVEL;
252 
253 /**
254  * @enum _SCI_CONTROLLER_MODE
255  * @brief This enumeration is utilized to indicate the operating mode
256  *        in which the SCI component should function.
257  */
258 typedef enum _SCI_CONTROLLER_MODE
259 {
260    /**
261     * This enumerant specifies that the SCI component be optimized to
262     * perform as fast as possible without concern for the amount of
263     * memory being utilized.
264     */
265    SCI_MODE_SPEED,
266 
267    /**
268     * This enumerant specifies that the SCI component be optimized to
269     * save memory space without concern for performance of the system.
270     */
271    SCI_MODE_SIZE
272 
273 } SCI_CONTROLLER_MODE;
274 
275 #ifdef __cplusplus
276 }
277 #endif // __cplusplus
278 
279 #endif // _SCI_TYPES_H_
280 
281