scif_library.h revision 331722
1/*-
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.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
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.
12 *
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.
17 *
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.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
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
38 *     distribution.
39 *
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.
51 *
52 * $FreeBSD: stable/11/sys/dev/isci/scil/scif_library.h 331722 2018-03-29 02:50:57Z eadler $
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
67extern "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 */
87SCI_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 */
103U32 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 */
125SCI_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 */
145SCI_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 */
162SCI_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 */
176U16 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 */
187U16 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