xref: /freebsd/sys/dev/isci/scil/scif_library.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
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 _SCIF_LIBRARY_H_
55 #define _SCIF_LIBRARY_H_
56 
57 /**
58  * @file
59  *
60  * @brief This file contains all of the interface methods that can be called
61  *        by an SCI Framework user on the library object.  The library is
62  *        the container of all other objects being managed (i.e. controllers,
63  *        target devices, sas ports, etc.) by SCIF.
64  */
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif // __cplusplus
69 
70 #include <dev/isci/scil/sci_types.h>
71 #include <dev/isci/scil/sci_status.h>
72 
73 
74 /**
75  * @brief This method will contsruct the SCI framework library based on the
76  *        supplied parameter information.  By default, libraries are
77  *        considered "ready" as soon as they are constructed.
78  *
79  * @param[in]  library_memory_p a pointer to the memory at which the
80  *             library object is located.
81  * @param[in]  max_controller_count the maximum number of controllers that
82  *             this library can manage.
83  *
84  * @return An opaque library handle to be used by the SCI user for all
85  *         subsequent library operations.
86  */
87 SCI_LIBRARY_HANDLE_T scif_library_construct(
88    void * library_memory_p,
89    U8     max_controller_count
90 );
91 
92 /**
93  * @brief This method returns the size of the framework library object.  The
94  *        size of the framework library object includes the associated core
95  *        object.
96  *
97  * @param[in]  max_controller_count the maximum number of controllers that
98  *             this library can manage.
99  *
100  * @return a positive integer value indicating the size (in bytes) of the
101  *         library object.
102  */
103 U32 scif_library_get_object_size(
104    U8  max_controller_count
105 );
106 
107 /**
108  * @brief This method will allocate the next available framework controller
109  *        object that can be managed by this framework library.
110  *
111  * @see For additional information please refer to:
112  *      scic_library_allocate_controller()
113  *
114  * @param[in]  library the handle to the library object for which to allocate
115  *             a controller.
116  * @param[out] new_controller_p This parameter specifies a pointer to the
117  *             controller handle that was added to the library.
118  *
119  * @return Indicate if the controller was successfully allocated or if iti
120  *         failed in some way.
121  * @retval SCI_SUCCESS if the controller was successfully allocated.
122  * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the library has no more
123  *         available controller objects to allocate.
124  */
125 SCI_STATUS scif_library_allocate_controller(
126    SCI_LIBRARY_HANDLE_T      library,
127    SCI_CONTROLLER_HANDLE_T * new_controller_p
128 );
129 
130 /**
131  * @brief This method will attempt to free the supplied controller to the
132  *        library.
133  *
134  * @param[in]  library the handle to the library object for which to free
135  *             a controller.
136  * @param[in]  controller the handle to the controller object to be freed
137  *             from the library.
138  *
139  * @return Indicate if the controller was successfully freed or if it failed
140  *         in some way.
141  * @retval SCI_SUCCESS if the controller was successfully freed.
142  * @retval SCI_FAILURE_CONTROLLER_NOT_FOUND if the supplied controller is
143  *         not managed by the supplied library.
144  */
145 SCI_STATUS scif_library_free_controller(
146    SCI_LIBRARY_HANDLE_T     library,
147    SCI_CONTROLLER_HANDLE_T  controller
148 );
149 
150 
151 /**
152  * @brief This method returns the SCI Core library handle
153  *        associated with this library.
154  *
155  * @param[in]  scif_library the handle to the library
156  *             object for which to retrieve the core specific
157  *             library handle
158  *
159  * @return Return the SCI core library handle associated with
160  *         the supplied framework library.
161  */
162 SCI_LIBRARY_HANDLE_T scif_library_get_scic_handle(
163    SCI_LIBRARY_HANDLE_T   scif_library
164 );
165 
166 
167 /**
168  * @brief This method returns the minimum number of timers needed.  If the
169  *        user supplies timers less then the number specified via this
170  *        call, then the user runs the risk of improper operation.  This
171  *        call includes the minimum number of timers needed by the core.
172  *
173  * @return This method returns a value representing the minimum number of
174  *         timers required by this framework implementation
175  */
176 U16 scif_library_get_min_timer_count(
177    void
178 );
179 
180 /**
181  * @brief This method returns the maximum number of timers that could
182  *        be ever be in use by this component at a given time.
183  *
184  * @return This method returns a value representing the minimum number of
185  *         timers required by this framework implementation
186  */
187 U16 scif_library_get_max_timer_count(
188    void
189 );
190 
191 #ifdef __cplusplus
192 }
193 #endif // __cplusplus
194 
195 #endif // _SCIF_LIBRARY_H_
196 
197