xref: /freebsd/sys/dev/isci/scil/scif_library.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro F. Giffuni  *
4f11c7f63SJim Harris  * This file is provided under a dual BSD/GPLv2 license.  When using or
5f11c7f63SJim Harris  * redistributing this file, you may do so under either license.
6f11c7f63SJim Harris  *
7f11c7f63SJim Harris  * GPL LICENSE SUMMARY
8f11c7f63SJim Harris  *
9f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10f11c7f63SJim Harris  *
11f11c7f63SJim Harris  * This program is free software; you can redistribute it and/or modify
12f11c7f63SJim Harris  * it under the terms of version 2 of the GNU General Public License as
13f11c7f63SJim Harris  * published by the Free Software Foundation.
14f11c7f63SJim Harris  *
15f11c7f63SJim Harris  * This program is distributed in the hope that it will be useful, but
16f11c7f63SJim Harris  * WITHOUT ANY WARRANTY; without even the implied warranty of
17f11c7f63SJim Harris  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18f11c7f63SJim Harris  * General Public License for more details.
19f11c7f63SJim Harris  *
20f11c7f63SJim Harris  * You should have received a copy of the GNU General Public License
21f11c7f63SJim Harris  * along with this program; if not, write to the Free Software
22f11c7f63SJim Harris  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23f11c7f63SJim Harris  * The full GNU General Public License is included in this distribution
24f11c7f63SJim Harris  * in the file called LICENSE.GPL.
25f11c7f63SJim Harris  *
26f11c7f63SJim Harris  * BSD LICENSE
27f11c7f63SJim Harris  *
28f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29f11c7f63SJim Harris  * All rights reserved.
30f11c7f63SJim Harris  *
31f11c7f63SJim Harris  * Redistribution and use in source and binary forms, with or without
32f11c7f63SJim Harris  * modification, are permitted provided that the following conditions
33f11c7f63SJim Harris  * are met:
34f11c7f63SJim Harris  *
35f11c7f63SJim Harris  *   * Redistributions of source code must retain the above copyright
36f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer.
37f11c7f63SJim Harris  *   * Redistributions in binary form must reproduce the above copyright
38f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer in
39f11c7f63SJim Harris  *     the documentation and/or other materials provided with the
40f11c7f63SJim Harris  *     distribution.
41f11c7f63SJim Harris  *
42f11c7f63SJim Harris  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43f11c7f63SJim Harris  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44f11c7f63SJim Harris  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45f11c7f63SJim Harris  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46f11c7f63SJim Harris  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47f11c7f63SJim Harris  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48f11c7f63SJim Harris  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49f11c7f63SJim Harris  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50f11c7f63SJim Harris  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51f11c7f63SJim Harris  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52f11c7f63SJim Harris  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53f11c7f63SJim Harris  */
54f11c7f63SJim Harris #ifndef _SCIF_LIBRARY_H_
55f11c7f63SJim Harris #define _SCIF_LIBRARY_H_
56f11c7f63SJim Harris 
57f11c7f63SJim Harris /**
58f11c7f63SJim Harris  * @file
59f11c7f63SJim Harris  *
60f11c7f63SJim Harris  * @brief This file contains all of the interface methods that can be called
61f11c7f63SJim Harris  *        by an SCI Framework user on the library object.  The library is
62f11c7f63SJim Harris  *        the container of all other objects being managed (i.e. controllers,
63f11c7f63SJim Harris  *        target devices, sas ports, etc.) by SCIF.
64f11c7f63SJim Harris  */
65f11c7f63SJim Harris 
66f11c7f63SJim Harris #ifdef __cplusplus
67f11c7f63SJim Harris extern "C" {
68f11c7f63SJim Harris #endif // __cplusplus
69f11c7f63SJim Harris 
70f11c7f63SJim Harris #include <dev/isci/scil/sci_types.h>
71f11c7f63SJim Harris #include <dev/isci/scil/sci_status.h>
72f11c7f63SJim Harris 
73f11c7f63SJim Harris 
74f11c7f63SJim Harris /**
75f11c7f63SJim Harris  * @brief This method will contsruct the SCI framework library based on the
76f11c7f63SJim Harris  *        supplied parameter information.  By default, libraries are
77f11c7f63SJim Harris  *        considered "ready" as soon as they are constructed.
78f11c7f63SJim Harris  *
79f11c7f63SJim Harris  * @param[in]  library_memory_p a pointer to the memory at which the
80f11c7f63SJim Harris  *             library object is located.
81f11c7f63SJim Harris  * @param[in]  max_controller_count the maximum number of controllers that
82f11c7f63SJim Harris  *             this library can manage.
83f11c7f63SJim Harris  *
84f11c7f63SJim Harris  * @return An opaque library handle to be used by the SCI user for all
85f11c7f63SJim Harris  *         subsequent library operations.
86f11c7f63SJim Harris  */
87f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T scif_library_construct(
88f11c7f63SJim Harris    void * library_memory_p,
89f11c7f63SJim Harris    U8     max_controller_count
90f11c7f63SJim Harris );
91f11c7f63SJim Harris 
92f11c7f63SJim Harris /**
93f11c7f63SJim Harris  * @brief This method returns the size of the framework library object.  The
94f11c7f63SJim Harris  *        size of the framework library object includes the associated core
95f11c7f63SJim Harris  *        object.
96f11c7f63SJim Harris  *
97f11c7f63SJim Harris  * @param[in]  max_controller_count the maximum number of controllers that
98f11c7f63SJim Harris  *             this library can manage.
99f11c7f63SJim Harris  *
100f11c7f63SJim Harris  * @return a positive integer value indicating the size (in bytes) of the
101f11c7f63SJim Harris  *         library object.
102f11c7f63SJim Harris  */
103f11c7f63SJim Harris U32 scif_library_get_object_size(
104f11c7f63SJim Harris    U8  max_controller_count
105f11c7f63SJim Harris );
106f11c7f63SJim Harris 
107f11c7f63SJim Harris /**
108f11c7f63SJim Harris  * @brief This method will allocate the next available framework controller
109f11c7f63SJim Harris  *        object that can be managed by this framework library.
110f11c7f63SJim Harris  *
111f11c7f63SJim Harris  * @see For additional information please refer to:
112f11c7f63SJim Harris  *      scic_library_allocate_controller()
113f11c7f63SJim Harris  *
114f11c7f63SJim Harris  * @param[in]  library the handle to the library object for which to allocate
115f11c7f63SJim Harris  *             a controller.
116f11c7f63SJim Harris  * @param[out] new_controller_p This parameter specifies a pointer to the
117f11c7f63SJim Harris  *             controller handle that was added to the library.
118f11c7f63SJim Harris  *
119f11c7f63SJim Harris  * @return Indicate if the controller was successfully allocated or if iti
120f11c7f63SJim Harris  *         failed in some way.
121f11c7f63SJim Harris  * @retval SCI_SUCCESS if the controller was successfully allocated.
122f11c7f63SJim Harris  * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the library has no more
123f11c7f63SJim Harris  *         available controller objects to allocate.
124f11c7f63SJim Harris  */
125f11c7f63SJim Harris SCI_STATUS scif_library_allocate_controller(
126f11c7f63SJim Harris    SCI_LIBRARY_HANDLE_T      library,
127f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T * new_controller_p
128f11c7f63SJim Harris );
129f11c7f63SJim Harris 
130f11c7f63SJim Harris /**
131f11c7f63SJim Harris  * @brief This method will attempt to free the supplied controller to the
132f11c7f63SJim Harris  *        library.
133f11c7f63SJim Harris  *
134f11c7f63SJim Harris  * @param[in]  library the handle to the library object for which to free
135f11c7f63SJim Harris  *             a controller.
136f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object to be freed
137f11c7f63SJim Harris  *             from the library.
138f11c7f63SJim Harris  *
139f11c7f63SJim Harris  * @return Indicate if the controller was successfully freed or if it failed
140f11c7f63SJim Harris  *         in some way.
141f11c7f63SJim Harris  * @retval SCI_SUCCESS if the controller was successfully freed.
142f11c7f63SJim Harris  * @retval SCI_FAILURE_CONTROLLER_NOT_FOUND if the supplied controller is
143f11c7f63SJim Harris  *         not managed by the supplied library.
144f11c7f63SJim Harris  */
145f11c7f63SJim Harris SCI_STATUS scif_library_free_controller(
146f11c7f63SJim Harris    SCI_LIBRARY_HANDLE_T     library,
147f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller
148f11c7f63SJim Harris );
149f11c7f63SJim Harris 
150f11c7f63SJim Harris 
151f11c7f63SJim Harris /**
152f11c7f63SJim Harris  * @brief This method returns the SCI Core library handle
153f11c7f63SJim Harris  *        associated with this library.
154f11c7f63SJim Harris  *
155f11c7f63SJim Harris  * @param[in]  scif_library the handle to the library
156f11c7f63SJim Harris  *             object for which to retrieve the core specific
157f11c7f63SJim Harris  *             library handle
158f11c7f63SJim Harris  *
159f11c7f63SJim Harris  * @return Return the SCI core library handle associated with
160f11c7f63SJim Harris  *         the supplied framework library.
161f11c7f63SJim Harris  */
162f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T scif_library_get_scic_handle(
163f11c7f63SJim Harris    SCI_LIBRARY_HANDLE_T   scif_library
164f11c7f63SJim Harris );
165f11c7f63SJim Harris 
166f11c7f63SJim Harris 
167f11c7f63SJim Harris /**
168f11c7f63SJim Harris  * @brief This method returns the minimum number of timers needed.  If the
169f11c7f63SJim Harris  *        user supplies timers less then the number specified via this
170f11c7f63SJim Harris  *        call, then the user runs the risk of improper operation.  This
171f11c7f63SJim Harris  *        call includes the minimum number of timers needed by the core.
172f11c7f63SJim Harris  *
173f11c7f63SJim Harris  * @return This method returns a value representing the minimum number of
174f11c7f63SJim Harris  *         timers required by this framework implementation
175f11c7f63SJim Harris  */
176f11c7f63SJim Harris U16 scif_library_get_min_timer_count(
177f11c7f63SJim Harris    void
178f11c7f63SJim Harris );
179f11c7f63SJim Harris 
180f11c7f63SJim Harris /**
181f11c7f63SJim Harris  * @brief This method returns the maximum number of timers that could
182f11c7f63SJim Harris  *        be ever be in use by this component at a given time.
183f11c7f63SJim Harris  *
184f11c7f63SJim Harris  * @return This method returns a value representing the minimum number of
185f11c7f63SJim Harris  *         timers required by this framework implementation
186f11c7f63SJim Harris  */
187f11c7f63SJim Harris U16 scif_library_get_max_timer_count(
188f11c7f63SJim Harris    void
189f11c7f63SJim Harris );
190f11c7f63SJim Harris 
191f11c7f63SJim Harris #ifdef __cplusplus
192f11c7f63SJim Harris }
193f11c7f63SJim Harris #endif // __cplusplus
194f11c7f63SJim Harris 
195f11c7f63SJim Harris #endif // _SCIF_LIBRARY_H_
196f11c7f63SJim Harris 
197