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 _SCIC_LIBRARY_H_
55 #define _SCIC_LIBRARY_H_
60 * @brief This file contains all of the interface methods that can be called
61 * by an SCI Core user on the library object. The library is the
62 * container of all other objects being managed (i.e. controllers,
63 * target devices, sas ports, etc.).
70 #include <dev/isci/scil/sci_types.h>
71 #include <dev/isci/scil/sci_status.h>
75 * @enum _SCIC_LIBRARY_IO_MODE
76 * @brief This enumeration depicts the different IO modes in which the SCI
77 * library and it's controllers can operate.
79 typedef enum _SCIC_LIBRARY_IO_MODE
82 * In this mode the SCI library will operate in a polling mode for
83 * operations. In other words, the library will not return from a
84 * send io method until the completion for the IO has been received.
89 * In this mode the SCI library returns after committing the IO request
90 * to the controller hardware. Completion of the request will occur
93 SCIC_IO_MODE_ASYNCHRONOUS
95 } SCIC_LIBRARY_IO_MODE;
98 struct sci_pci_common_header;
101 * @brief This method will contsruct the core library based on the supplied
102 * parameter information. By default, libraries are considered
103 * "ready" as soon as they are constructed.
105 * @param[in] library_memory a pointer to the memory at which the
106 * library object is located.
107 * @param[in] max_controller_count the maximum number of controllers that
108 * this library can manage.
110 * @return An opaque library handle to be used by the SCI user for all
111 * subsequent library operations.
113 SCI_LIBRARY_HANDLE_T scic_library_construct(
114 void * library_memory,
115 U8 max_controller_count
119 * This method sets the PCI header information required for proper
120 * controller object creation/allocation.
122 * @param[in] library the handle to the library object for which to allocate
124 * @param[in] pci_header a pointer to the pci header data for the pci
125 * device for which this library is being created.
129 void scic_library_set_pci_info(
130 SCI_LIBRARY_HANDLE_T library,
131 struct sci_pci_common_header * pci_header
135 * @brief This method returns the size of the core library object.
137 * @param[in] max_controller_count the maximum number of controllers that
138 * this library can manage.
140 * @return a positive integer value indicating the size (in bytes) of the
143 U32 scic_library_get_object_size(
144 U8 max_controller_count
151 U8 scic_library_get_pci_device_controller_count(
152 SCI_LIBRARY_HANDLE_T library
156 * @brief This method will allocate the next available core controller object
157 * that can be managed by this core library.
159 * @param[in] library the handle to the library object for which to allocate
161 * @param[out] new_controller This parameter specifies a pointer to the
162 * controller handle that was added to the library.
164 * @return Indicate if the controller was successfully allocated or if iti
165 * failed in some way.
166 * @retval SCI_SUCCESS if the controller was successfully allocated.
167 * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the library has no more
168 * available controller objects to allocate.
170 SCI_STATUS scic_library_allocate_controller(
171 SCI_LIBRARY_HANDLE_T library,
172 SCI_CONTROLLER_HANDLE_T * new_controller
176 * @brief This method will attempt to free the supplied controller to the
179 * @param[in] library the handle to the library object for which to free
181 * @param[in] controller the handle to the controller object to be freed
184 * @return Indicate if the controller was successfully freed or if it failed
186 * @retval SCI_SUCCESS if the controller was successfully freed.
187 * @retval SCI_FAILURE_CONTROLLER_NOT_FOUND if the supplied controller is
188 * not managed by the supplied library.
190 SCI_STATUS scic_library_free_controller(
191 SCI_LIBRARY_HANDLE_T library,
192 SCI_CONTROLLER_HANDLE_T controller
196 * @brief This method returns the maximum size (in bytes) that an individual
197 * SGL element can address using this library.
199 * @note SGL size is restricted to the lowest common denominator across all
200 * controllers managed by the library.
201 * @todo Does the byte count have to be DWORD aligned?
203 * @param[in] library the handle to the library object for which to
204 * determine the maximum SGL size.
206 * @return Return the maximum size (in bytes) for an SGE for any controller
207 * managed by this library.
209 U32 scic_library_get_max_sge_size(
210 SCI_LIBRARY_HANDLE_T library
214 * @brief This method returns the maximum number of SGL elements for a
215 * single IO request using this library.
217 * @note SGE count is restricted to the lowest common denominator across all
218 * controllers managed by the library.
220 * @param[in] library the handle to the library object for which to
221 * determine the maximum number of SGEs per IO request.
223 * @return Return the maximum number of SGEs for an IO request for any
224 * controller in this library.
226 U32 scic_library_get_max_sge_count(
227 SCI_LIBRARY_HANDLE_T library
231 * @brief This method returns the maximum length for any IO request that
232 * can be handled by the underlying controllers
234 * @note IO length is restricted to the lowest common denominator across all
235 * controllers managed by the library.
237 * @param[in] library the handle to the library object for which to
238 * determine the maximum length for all IO requests.
240 * @return Return the maximum length for all IO requests for any
241 * controller in this library.
243 U32 scic_library_get_max_io_length(
244 SCI_LIBRARY_HANDLE_T library
248 * @brief This method returns the minimum number of timers needed. If the
249 * user supplies timers less then the number specified via this
250 * call, then the user runs the risk of improper operation.
252 * @return This method returns a value representing the minimum number of
253 * timers required by this framework implementation
255 U16 scic_library_get_min_timer_count(
260 * @brief This method returns the maximum number of timers that could
261 * be ever be in use by this component at a given time.
263 * @return This method returns a value representing the minimum number of
264 * timers required by this framework implementation
266 U16 scic_library_get_max_timer_count(
272 #endif // __cplusplus
274 #endif // _SCIC_LIBRARY_H_