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 _SCIC_LIBRARY_H_ 55f11c7f63SJim Harris #define _SCIC_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 Core user on the library object. The library is the 62f11c7f63SJim Harris * container of all other objects being managed (i.e. controllers, 63f11c7f63SJim Harris * target devices, sas ports, etc.). 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 * @enum _SCIC_LIBRARY_IO_MODE 76f11c7f63SJim Harris * @brief This enumeration depicts the different IO modes in which the SCI 77f11c7f63SJim Harris * library and it's controllers can operate. 78f11c7f63SJim Harris */ 79f11c7f63SJim Harris typedef enum _SCIC_LIBRARY_IO_MODE 80f11c7f63SJim Harris { 81f11c7f63SJim Harris /** 82f11c7f63SJim Harris * In this mode the SCI library will operate in a polling mode for 83f11c7f63SJim Harris * operations. In other words, the library will not return from a 84f11c7f63SJim Harris * send io method until the completion for the IO has been received. 85f11c7f63SJim Harris */ 86f11c7f63SJim Harris SCIC_IO_MODE_POLLING, 87f11c7f63SJim Harris 88f11c7f63SJim Harris /** 89f11c7f63SJim Harris * In this mode the SCI library returns after committing the IO request 90f11c7f63SJim Harris * to the controller hardware. Completion of the request will occur 91f11c7f63SJim Harris * asynchronously. 92f11c7f63SJim Harris */ 93f11c7f63SJim Harris SCIC_IO_MODE_ASYNCHRONOUS 94f11c7f63SJim Harris 95f11c7f63SJim Harris } SCIC_LIBRARY_IO_MODE; 96f11c7f63SJim Harris 97f11c7f63SJim Harris 98f11c7f63SJim Harris struct sci_pci_common_header; 99f11c7f63SJim Harris 100f11c7f63SJim Harris /** 101f11c7f63SJim Harris * @brief This method will contsruct the core library based on the supplied 102f11c7f63SJim Harris * parameter information. By default, libraries are considered 103f11c7f63SJim Harris * "ready" as soon as they are constructed. 104f11c7f63SJim Harris * 105f11c7f63SJim Harris * @param[in] library_memory a pointer to the memory at which the 106f11c7f63SJim Harris * library object is located. 107f11c7f63SJim Harris * @param[in] max_controller_count the maximum number of controllers that 108f11c7f63SJim Harris * this library can manage. 109f11c7f63SJim Harris * 110f11c7f63SJim Harris * @return An opaque library handle to be used by the SCI user for all 111f11c7f63SJim Harris * subsequent library operations. 112f11c7f63SJim Harris */ 113f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T scic_library_construct( 114f11c7f63SJim Harris void * library_memory, 115f11c7f63SJim Harris U8 max_controller_count 116f11c7f63SJim Harris ); 117f11c7f63SJim Harris 118f11c7f63SJim Harris /** 119f11c7f63SJim Harris * This method sets the PCI header information required for proper 120f11c7f63SJim Harris * controller object creation/allocation. 121f11c7f63SJim Harris * 122f11c7f63SJim Harris * @param[in] library the handle to the library object for which to allocate 123f11c7f63SJim Harris * a controller. 124f11c7f63SJim Harris * @param[in] pci_header a pointer to the pci header data for the pci 125f11c7f63SJim Harris * device for which this library is being created. 126f11c7f63SJim Harris * 127f11c7f63SJim Harris * @return none 128f11c7f63SJim Harris */ 129f11c7f63SJim Harris void scic_library_set_pci_info( 130f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library, 131f11c7f63SJim Harris struct sci_pci_common_header * pci_header 132f11c7f63SJim Harris ); 133f11c7f63SJim Harris 134f11c7f63SJim Harris /** 135f11c7f63SJim Harris * @brief This method returns the size of the core library object. 136f11c7f63SJim Harris * 137f11c7f63SJim Harris * @param[in] max_controller_count the maximum number of controllers that 138f11c7f63SJim Harris * this library can manage. 139f11c7f63SJim Harris * 140f11c7f63SJim Harris * @return a positive integer value indicating the size (in bytes) of the 141f11c7f63SJim Harris * library object. 142f11c7f63SJim Harris */ 143f11c7f63SJim Harris U32 scic_library_get_object_size( 144f11c7f63SJim Harris U8 max_controller_count 145f11c7f63SJim Harris ); 146f11c7f63SJim Harris 147f11c7f63SJim Harris /** 148f11c7f63SJim Harris * 149f11c7f63SJim Harris * 150f11c7f63SJim Harris */ 151f11c7f63SJim Harris U8 scic_library_get_pci_device_controller_count( 152f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library 153f11c7f63SJim Harris ); 154f11c7f63SJim Harris 155f11c7f63SJim Harris /** 156f11c7f63SJim Harris * @brief This method will allocate the next available core controller object 157f11c7f63SJim Harris * that can be managed by this core library. 158f11c7f63SJim Harris * 159f11c7f63SJim Harris * @param[in] library the handle to the library object for which to allocate 160f11c7f63SJim Harris * a controller. 161f11c7f63SJim Harris * @param[out] new_controller This parameter specifies a pointer to the 162f11c7f63SJim Harris * controller handle that was added to the library. 163f11c7f63SJim Harris 164f11c7f63SJim Harris * @return Indicate if the controller was successfully allocated or if iti 165f11c7f63SJim Harris * failed in some way. 166f11c7f63SJim Harris * @retval SCI_SUCCESS if the controller was successfully allocated. 167f11c7f63SJim Harris * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the library has no more 168f11c7f63SJim Harris * available controller objects to allocate. 169f11c7f63SJim Harris */ 170f11c7f63SJim Harris SCI_STATUS scic_library_allocate_controller( 171f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library, 172f11c7f63SJim Harris SCI_CONTROLLER_HANDLE_T * new_controller 173f11c7f63SJim Harris ); 174f11c7f63SJim Harris 175f11c7f63SJim Harris /** 176f11c7f63SJim Harris * @brief This method will attempt to free the supplied controller to the 177f11c7f63SJim Harris * library. 178f11c7f63SJim Harris * 179f11c7f63SJim Harris * @param[in] library the handle to the library object for which to free 180f11c7f63SJim Harris * a controller. 181f11c7f63SJim Harris * @param[in] controller the handle to the controller object to be freed 182f11c7f63SJim Harris * from the library. 183f11c7f63SJim Harris * 184f11c7f63SJim Harris * @return Indicate if the controller was successfully freed or if it failed 185f11c7f63SJim Harris * in some way. 186f11c7f63SJim Harris * @retval SCI_SUCCESS if the controller was successfully freed. 187f11c7f63SJim Harris * @retval SCI_FAILURE_CONTROLLER_NOT_FOUND if the supplied controller is 188f11c7f63SJim Harris * not managed by the supplied library. 189f11c7f63SJim Harris */ 190f11c7f63SJim Harris SCI_STATUS scic_library_free_controller( 191f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library, 192f11c7f63SJim Harris SCI_CONTROLLER_HANDLE_T controller 193f11c7f63SJim Harris ); 194f11c7f63SJim Harris 195f11c7f63SJim Harris /** 196f11c7f63SJim Harris * @brief This method returns the maximum size (in bytes) that an individual 197f11c7f63SJim Harris * SGL element can address using this library. 198f11c7f63SJim Harris * 199f11c7f63SJim Harris * @note SGL size is restricted to the lowest common denominator across all 200f11c7f63SJim Harris * controllers managed by the library. 201f11c7f63SJim Harris * @todo Does the byte count have to be DWORD aligned? 202f11c7f63SJim Harris * 203f11c7f63SJim Harris * @param[in] library the handle to the library object for which to 204f11c7f63SJim Harris * determine the maximum SGL size. 205f11c7f63SJim Harris * 206f11c7f63SJim Harris * @return Return the maximum size (in bytes) for an SGE for any controller 207f11c7f63SJim Harris * managed by this library. 208f11c7f63SJim Harris */ 209f11c7f63SJim Harris U32 scic_library_get_max_sge_size( 210f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library 211f11c7f63SJim Harris ); 212f11c7f63SJim Harris 213f11c7f63SJim Harris /** 214f11c7f63SJim Harris * @brief This method returns the maximum number of SGL elements for a 215f11c7f63SJim Harris * single IO request using this library. 216f11c7f63SJim Harris * 217f11c7f63SJim Harris * @note SGE count is restricted to the lowest common denominator across all 218f11c7f63SJim Harris * controllers managed by the library. 219f11c7f63SJim Harris * 220f11c7f63SJim Harris * @param[in] library the handle to the library object for which to 221f11c7f63SJim Harris * determine the maximum number of SGEs per IO request. 222f11c7f63SJim Harris * 223f11c7f63SJim Harris * @return Return the maximum number of SGEs for an IO request for any 224f11c7f63SJim Harris * controller in this library. 225f11c7f63SJim Harris */ 226f11c7f63SJim Harris U32 scic_library_get_max_sge_count( 227f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library 228f11c7f63SJim Harris ); 229f11c7f63SJim Harris 230f11c7f63SJim Harris /** 231f11c7f63SJim Harris * @brief This method returns the maximum length for any IO request that 232f11c7f63SJim Harris * can be handled by the underlying controllers 233f11c7f63SJim Harris * 234f11c7f63SJim Harris * @note IO length is restricted to the lowest common denominator across all 235f11c7f63SJim Harris * controllers managed by the library. 236f11c7f63SJim Harris * 237f11c7f63SJim Harris * @param[in] library the handle to the library object for which to 238f11c7f63SJim Harris * determine the maximum length for all IO requests. 239f11c7f63SJim Harris * 240f11c7f63SJim Harris * @return Return the maximum length for all IO requests for any 241f11c7f63SJim Harris * controller in this library. 242f11c7f63SJim Harris */ 243f11c7f63SJim Harris U32 scic_library_get_max_io_length( 244f11c7f63SJim Harris SCI_LIBRARY_HANDLE_T library 245f11c7f63SJim Harris ); 246f11c7f63SJim Harris 247f11c7f63SJim Harris /** 248f11c7f63SJim Harris * @brief This method returns the minimum number of timers needed. If the 249f11c7f63SJim Harris * user supplies timers less then the number specified via this 250f11c7f63SJim Harris * call, then the user runs the risk of improper operation. 251f11c7f63SJim Harris * 252f11c7f63SJim Harris * @return This method returns a value representing the minimum number of 253f11c7f63SJim Harris * timers required by this framework implementation 254f11c7f63SJim Harris */ 255f11c7f63SJim Harris U16 scic_library_get_min_timer_count( 256f11c7f63SJim Harris void 257f11c7f63SJim Harris ); 258f11c7f63SJim Harris 259f11c7f63SJim Harris /** 260f11c7f63SJim Harris * @brief This method returns the maximum number of timers that could 261f11c7f63SJim Harris * be ever be in use by this component at a given time. 262f11c7f63SJim Harris * 263f11c7f63SJim Harris * @return This method returns a value representing the minimum number of 264f11c7f63SJim Harris * timers required by this framework implementation 265f11c7f63SJim Harris */ 266f11c7f63SJim Harris U16 scic_library_get_max_timer_count( 267f11c7f63SJim Harris void 268f11c7f63SJim Harris ); 269f11c7f63SJim Harris 270f11c7f63SJim Harris #ifdef __cplusplus 271f11c7f63SJim Harris } 272f11c7f63SJim Harris #endif // __cplusplus 273f11c7f63SJim Harris 274f11c7f63SJim Harris #endif // _SCIC_LIBRARY_H_ 275f11c7f63SJim Harris 276