1230557Sjimharris/*- 2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license. When using or 3230557Sjimharris * redistributing this file, you may do so under either license. 4230557Sjimharris * 5230557Sjimharris * GPL LICENSE SUMMARY 6230557Sjimharris * 7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8230557Sjimharris * 9230557Sjimharris * This program is free software; you can redistribute it and/or modify 10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as 11230557Sjimharris * published by the Free Software Foundation. 12230557Sjimharris * 13230557Sjimharris * This program is distributed in the hope that it will be useful, but 14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of 15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16230557Sjimharris * General Public License for more details. 17230557Sjimharris * 18230557Sjimharris * You should have received a copy of the GNU General Public License 19230557Sjimharris * along with this program; if not, write to the Free Software 20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21230557Sjimharris * The full GNU General Public License is included in this distribution 22230557Sjimharris * in the file called LICENSE.GPL. 23230557Sjimharris * 24230557Sjimharris * BSD LICENSE 25230557Sjimharris * 26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27230557Sjimharris * All rights reserved. 28230557Sjimharris * 29230557Sjimharris * Redistribution and use in source and binary forms, with or without 30230557Sjimharris * modification, are permitted provided that the following conditions 31230557Sjimharris * are met: 32230557Sjimharris * 33230557Sjimharris * * Redistributions of source code must retain the above copyright 34230557Sjimharris * notice, this list of conditions and the following disclaimer. 35230557Sjimharris * * Redistributions in binary form must reproduce the above copyright 36230557Sjimharris * notice, this list of conditions and the following disclaimer in 37230557Sjimharris * the documentation and/or other materials provided with the 38230557Sjimharris * distribution. 39230557Sjimharris * 40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51230557Sjimharris * 52230557Sjimharris * $FreeBSD$ 53230557Sjimharris */ 54230557Sjimharris#ifndef _SCIC_LIBRARY_H_ 55230557Sjimharris#define _SCIC_LIBRARY_H_ 56230557Sjimharris 57230557Sjimharris/** 58230557Sjimharris * @file 59230557Sjimharris * 60230557Sjimharris * @brief This file contains all of the interface methods that can be called 61230557Sjimharris * by an SCI Core user on the library object. The library is the 62230557Sjimharris * container of all other objects being managed (i.e. controllers, 63230557Sjimharris * target devices, sas ports, etc.). 64230557Sjimharris */ 65230557Sjimharris 66230557Sjimharris#ifdef __cplusplus 67230557Sjimharrisextern "C" { 68230557Sjimharris#endif // __cplusplus 69230557Sjimharris 70230557Sjimharris#include <dev/isci/scil/sci_types.h> 71230557Sjimharris#include <dev/isci/scil/sci_status.h> 72230557Sjimharris 73230557Sjimharris 74230557Sjimharris/** 75230557Sjimharris * @enum _SCIC_LIBRARY_IO_MODE 76230557Sjimharris * @brief This enumeration depicts the different IO modes in which the SCI 77230557Sjimharris * library and it's controllers can operate. 78230557Sjimharris */ 79230557Sjimharristypedef enum _SCIC_LIBRARY_IO_MODE 80230557Sjimharris{ 81230557Sjimharris /** 82230557Sjimharris * In this mode the SCI library will operate in a polling mode for 83230557Sjimharris * operations. In other words, the library will not return from a 84230557Sjimharris * send io method until the completion for the IO has been received. 85230557Sjimharris */ 86230557Sjimharris SCIC_IO_MODE_POLLING, 87230557Sjimharris 88230557Sjimharris /** 89230557Sjimharris * In this mode the SCI library returns after committing the IO request 90230557Sjimharris * to the controller hardware. Completion of the request will occur 91230557Sjimharris * asynchronously. 92230557Sjimharris */ 93230557Sjimharris SCIC_IO_MODE_ASYNCHRONOUS 94230557Sjimharris 95230557Sjimharris} SCIC_LIBRARY_IO_MODE; 96230557Sjimharris 97230557Sjimharris 98230557Sjimharrisstruct sci_pci_common_header; 99230557Sjimharris 100230557Sjimharris/** 101230557Sjimharris * @brief This method will contsruct the core library based on the supplied 102230557Sjimharris * parameter information. By default, libraries are considered 103230557Sjimharris * "ready" as soon as they are constructed. 104230557Sjimharris * 105230557Sjimharris * @param[in] library_memory a pointer to the memory at which the 106230557Sjimharris * library object is located. 107230557Sjimharris * @param[in] max_controller_count the maximum number of controllers that 108230557Sjimharris * this library can manage. 109230557Sjimharris * 110230557Sjimharris * @return An opaque library handle to be used by the SCI user for all 111230557Sjimharris * subsequent library operations. 112230557Sjimharris */ 113230557SjimharrisSCI_LIBRARY_HANDLE_T scic_library_construct( 114230557Sjimharris void * library_memory, 115230557Sjimharris U8 max_controller_count 116230557Sjimharris); 117230557Sjimharris 118230557Sjimharris/** 119230557Sjimharris * This method sets the PCI header information required for proper 120230557Sjimharris * controller object creation/allocation. 121230557Sjimharris * 122230557Sjimharris * @param[in] library the handle to the library object for which to allocate 123230557Sjimharris * a controller. 124230557Sjimharris * @param[in] pci_header a pointer to the pci header data for the pci 125230557Sjimharris * device for which this library is being created. 126230557Sjimharris * 127230557Sjimharris * @return none 128230557Sjimharris */ 129230557Sjimharrisvoid scic_library_set_pci_info( 130230557Sjimharris SCI_LIBRARY_HANDLE_T library, 131230557Sjimharris struct sci_pci_common_header * pci_header 132230557Sjimharris); 133230557Sjimharris 134230557Sjimharris/** 135230557Sjimharris * @brief This method returns the size of the core library object. 136230557Sjimharris * 137230557Sjimharris * @param[in] max_controller_count the maximum number of controllers that 138230557Sjimharris * this library can manage. 139230557Sjimharris * 140230557Sjimharris * @return a positive integer value indicating the size (in bytes) of the 141230557Sjimharris * library object. 142230557Sjimharris */ 143230557SjimharrisU32 scic_library_get_object_size( 144230557Sjimharris U8 max_controller_count 145230557Sjimharris); 146230557Sjimharris 147230557Sjimharris/** 148230557Sjimharris * 149230557Sjimharris * 150230557Sjimharris */ 151230557SjimharrisU8 scic_library_get_pci_device_controller_count( 152230557Sjimharris SCI_LIBRARY_HANDLE_T library 153230557Sjimharris); 154230557Sjimharris 155230557Sjimharris/** 156230557Sjimharris * @brief This method will allocate the next available core controller object 157230557Sjimharris * that can be managed by this core library. 158230557Sjimharris * 159230557Sjimharris * @param[in] library the handle to the library object for which to allocate 160230557Sjimharris * a controller. 161230557Sjimharris * @param[out] new_controller This parameter specifies a pointer to the 162230557Sjimharris * controller handle that was added to the library. 163230557Sjimharris 164230557Sjimharris * @return Indicate if the controller was successfully allocated or if iti 165230557Sjimharris * failed in some way. 166230557Sjimharris * @retval SCI_SUCCESS if the controller was successfully allocated. 167230557Sjimharris * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the library has no more 168230557Sjimharris * available controller objects to allocate. 169230557Sjimharris */ 170230557SjimharrisSCI_STATUS scic_library_allocate_controller( 171230557Sjimharris SCI_LIBRARY_HANDLE_T library, 172230557Sjimharris SCI_CONTROLLER_HANDLE_T * new_controller 173230557Sjimharris); 174230557Sjimharris 175230557Sjimharris/** 176230557Sjimharris * @brief This method will attempt to free the supplied controller to the 177230557Sjimharris * library. 178230557Sjimharris * 179230557Sjimharris * @param[in] library the handle to the library object for which to free 180230557Sjimharris * a controller. 181230557Sjimharris * @param[in] controller the handle to the controller object to be freed 182230557Sjimharris * from the library. 183230557Sjimharris * 184230557Sjimharris * @return Indicate if the controller was successfully freed or if it failed 185230557Sjimharris * in some way. 186230557Sjimharris * @retval SCI_SUCCESS if the controller was successfully freed. 187230557Sjimharris * @retval SCI_FAILURE_CONTROLLER_NOT_FOUND if the supplied controller is 188230557Sjimharris * not managed by the supplied library. 189230557Sjimharris */ 190230557SjimharrisSCI_STATUS scic_library_free_controller( 191230557Sjimharris SCI_LIBRARY_HANDLE_T library, 192230557Sjimharris SCI_CONTROLLER_HANDLE_T controller 193230557Sjimharris); 194230557Sjimharris 195230557Sjimharris/** 196230557Sjimharris * @brief This method returns the maximum size (in bytes) that an individual 197230557Sjimharris * SGL element can address using this library. 198230557Sjimharris * 199230557Sjimharris * @note SGL size is restricted to the lowest common denominator across all 200230557Sjimharris * controllers managed by the library. 201230557Sjimharris * @todo Does the byte count have to be DWORD aligned? 202230557Sjimharris * 203230557Sjimharris * @param[in] library the handle to the library object for which to 204230557Sjimharris * determine the maximum SGL size. 205230557Sjimharris * 206230557Sjimharris * @return Return the maximum size (in bytes) for an SGE for any controller 207230557Sjimharris * managed by this library. 208230557Sjimharris */ 209230557SjimharrisU32 scic_library_get_max_sge_size( 210230557Sjimharris SCI_LIBRARY_HANDLE_T library 211230557Sjimharris); 212230557Sjimharris 213230557Sjimharris/** 214230557Sjimharris * @brief This method returns the maximum number of SGL elements for a 215230557Sjimharris * single IO request using this library. 216230557Sjimharris * 217230557Sjimharris * @note SGE count is restricted to the lowest common denominator across all 218230557Sjimharris * controllers managed by the library. 219230557Sjimharris * 220230557Sjimharris * @param[in] library the handle to the library object for which to 221230557Sjimharris * determine the maximum number of SGEs per IO request. 222230557Sjimharris * 223230557Sjimharris * @return Return the maximum number of SGEs for an IO request for any 224230557Sjimharris * controller in this library. 225230557Sjimharris */ 226230557SjimharrisU32 scic_library_get_max_sge_count( 227230557Sjimharris SCI_LIBRARY_HANDLE_T library 228230557Sjimharris); 229230557Sjimharris 230230557Sjimharris/** 231230557Sjimharris * @brief This method returns the maximum length for any IO request that 232230557Sjimharris * can be handled by the underlying controllers 233230557Sjimharris * 234230557Sjimharris * @note IO length is restricted to the lowest common denominator across all 235230557Sjimharris * controllers managed by the library. 236230557Sjimharris * 237230557Sjimharris * @param[in] library the handle to the library object for which to 238230557Sjimharris * determine the maximum length for all IO requests. 239230557Sjimharris * 240230557Sjimharris * @return Return the maximum length for all IO requests for any 241230557Sjimharris * controller in this library. 242230557Sjimharris */ 243230557SjimharrisU32 scic_library_get_max_io_length( 244230557Sjimharris SCI_LIBRARY_HANDLE_T library 245230557Sjimharris); 246230557Sjimharris 247230557Sjimharris/** 248230557Sjimharris * @brief This method returns the minimum number of timers needed. If the 249230557Sjimharris * user supplies timers less then the number specified via this 250230557Sjimharris * call, then the user runs the risk of improper operation. 251230557Sjimharris * 252230557Sjimharris * @return This method returns a value representing the minimum number of 253230557Sjimharris * timers required by this framework implementation 254230557Sjimharris */ 255230557SjimharrisU16 scic_library_get_min_timer_count( 256230557Sjimharris void 257230557Sjimharris); 258230557Sjimharris 259230557Sjimharris/** 260230557Sjimharris * @brief This method returns the maximum number of timers that could 261230557Sjimharris * be ever be in use by this component at a given time. 262230557Sjimharris * 263230557Sjimharris * @return This method returns a value representing the minimum number of 264230557Sjimharris * timers required by this framework implementation 265230557Sjimharris */ 266230557SjimharrisU16 scic_library_get_max_timer_count( 267230557Sjimharris void 268230557Sjimharris); 269230557Sjimharris 270230557Sjimharris#ifdef __cplusplus 271230557Sjimharris} 272230557Sjimharris#endif // __cplusplus 273230557Sjimharris 274230557Sjimharris#endif // _SCIC_LIBRARY_H_ 275230557Sjimharris 276