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 _SCIF_SAS_CONTROLLER_H_ 55230557Sjimharris#define _SCIF_SAS_CONTROLLER_H_ 56230557Sjimharris 57230557Sjimharris/** 58230557Sjimharris * @file 59230557Sjimharris * 60230557Sjimharris * @brief This file contains the protected interface structures, constants, 61230557Sjimharris * and methods for the SCIF_SAS_CONTROLLER object. 62230557Sjimharris */ 63230557Sjimharris 64230557Sjimharris#ifdef __cplusplus 65230557Sjimharrisextern "C" { 66230557Sjimharris#endif // __cplusplus 67230557Sjimharris 68230557Sjimharris#include <dev/isci/scil/sci_types.h> 69230557Sjimharris#include <dev/isci/scil/sci_abstract_list.h> 70230557Sjimharris#include <dev/isci/scil/sci_controller_constants.h> 71230557Sjimharris#include <dev/isci/scil/sci_memory_descriptor_list.h> 72230557Sjimharris#include <dev/isci/scil/sci_base_controller.h> 73230557Sjimharris#include <dev/isci/scil/scif_controller.h> 74230557Sjimharris#include <dev/isci/scil/scif_config_parameters.h> 75230557Sjimharris#include <dev/isci/scil/scif_sas_domain.h> 76230557Sjimharris#include <dev/isci/scil/scif_sas_io_request.h> 77230557Sjimharris#include <dev/isci/scil/scif_sas_task_request.h> 78230557Sjimharris#include <dev/isci/scil/scif_sas_constants.h> 79230557Sjimharris#include <dev/isci/scil/sci_pool.h> 80230557Sjimharris#include <dev/isci/scil/scif_sas_internal_io_request.h> 81230557Sjimharris#include <dev/isci/scil/scif_sas_high_priority_request_queue.h> 82230557Sjimharris#include <dev/isci/scil/scif_sas_smp_phy.h> 83230557Sjimharris 84230557Sjimharris 85230557Sjimharris// Currently there is only a need for 1 memory descriptor. This descriptor 86230557Sjimharris// describes the internal IO request memory. 87230557Sjimharris#define SCIF_SAS_MAX_MEMORY_DESCRIPTORS 1 88230557Sjimharris 89230557Sjimharrisenum _SCIF_SAS_MAX_MEMORY_DESCRIPTORS 90230557Sjimharris{ 91230557Sjimharris SCIF_SAS_MDE_INTERNAL_IO = 0 92230557Sjimharris 93230557Sjimharris}; 94230557Sjimharris 95230557Sjimharris/** 96230557Sjimharris * @struct SCIF_SAS_CONTROLLER 97230557Sjimharris * 98230557Sjimharris * @brief The SCI SAS Framework controller object abstracts storage controller 99230557Sjimharris * level behavior for the framework component. 100230557Sjimharris */ 101230557Sjimharristypedef struct SCIF_SAS_CONTROLLER 102230557Sjimharris{ 103230557Sjimharris /** 104230557Sjimharris * The SCI_BASE_CONTROLLER is the parent object for the SCIF_SAS_CONTROLLER 105230557Sjimharris * object. 106230557Sjimharris */ 107230557Sjimharris SCI_BASE_CONTROLLER_T parent; 108230557Sjimharris 109230557Sjimharris /** 110230557Sjimharris * This field contains the handle for the SCI Core controller object that 111230557Sjimharris * is managed by this framework controller. 112230557Sjimharris */ 113230557Sjimharris SCI_CONTROLLER_HANDLE_T core_object; 114230557Sjimharris 115230557Sjimharris /** 116230557Sjimharris * This field references the list of state specific handler methods to 117230557Sjimharris * be utilized for this controller instance. 118230557Sjimharris */ 119230557Sjimharris SCI_BASE_CONTROLLER_STATE_HANDLER_T * state_handlers; 120230557Sjimharris 121230557Sjimharris /** 122230557Sjimharris * This field contains the memory desciptors defining the physical 123230557Sjimharris * memory requirements for this controller. 124230557Sjimharris */ 125230557Sjimharris SCI_PHYSICAL_MEMORY_DESCRIPTOR_T mdes[SCIF_SAS_MAX_MEMORY_DESCRIPTORS]; 126230557Sjimharris 127230557Sjimharris /** 128230557Sjimharris * This field contains the SAS domain objects managed by this controller. 129230557Sjimharris */ 130230557Sjimharris SCIF_SAS_DOMAIN_T domains[SCI_MAX_DOMAINS]; 131230557Sjimharris 132230557Sjimharris /** 133230557Sjimharris * This field represents the pool of available remote device objects 134230557Sjimharris * supported by the controller. 135230557Sjimharris */ 136230557Sjimharris SCI_ABSTRACT_ELEMENT_POOL_T free_remote_device_pool; 137230557Sjimharris 138230557Sjimharris /** 139230557Sjimharris * This field contains the maximum number of abstract elements that 140230557Sjimharris * can be placed in the pool. 141230557Sjimharris */ 142230557Sjimharris SCI_ABSTRACT_ELEMENT_T remote_device_pool_elements[SCI_MAX_REMOTE_DEVICES]; 143230557Sjimharris 144230557Sjimharris /** 145230557Sjimharris * This field provides the controller object a scratch area to indicate 146230557Sjimharris * status of an ongoing operation. 147230557Sjimharris */ 148230557Sjimharris SCI_STATUS operation_status; 149230557Sjimharris 150230557Sjimharris /** 151230557Sjimharris * This field will contain an user specified parameter information 152230557Sjimharris * to be utilized by the framework. 153230557Sjimharris */ 154230557Sjimharris SCIF_USER_PARAMETERS_T user_parameters; 155230557Sjimharris 156230557Sjimharris /** 157230557Sjimharris * This field records the index for the current domain to clear affiliation 158230557Sjimharris * EA SATA remote devices, during the controller stop process. 159230557Sjimharris */ 160230557Sjimharris U8 current_domain_to_clear_affiliation; 161230557Sjimharris 162230557Sjimharris U32 internal_request_entries; 163230557Sjimharris 164230557Sjimharris /** 165230557Sjimharris * This field provides a pool to manage the memory resource for all internal 166230557Sjimharris * requests. 167230557Sjimharris * requests. 168230557Sjimharris */ 169230557Sjimharris SCI_POOL_CREATE( 170230557Sjimharris internal_request_memory_pool, 171230557Sjimharris POINTER_UINT, 172230557Sjimharris SCIF_SAS_MAX_INTERNAL_REQUEST_COUNT 173230557Sjimharris ); 174230557Sjimharris 175230557Sjimharris /** 176230557Sjimharris * This field provides a queue for built internal requests waiting to be 177230557Sjimharris * started. 178230557Sjimharris */ 179230557Sjimharris SCIF_SAS_HIGH_PRIORITY_REQUEST_QUEUE_T hprq; 180230557Sjimharris 181230557Sjimharris /** 182230557Sjimharris * This represents the number of available SMP phy objects that can 183230557Sjimharris * be managed by the framework. 184230557Sjimharris */ 185230557Sjimharris SCIF_SAS_SMP_PHY_T smp_phy_array[SCIF_SAS_SMP_PHY_COUNT]; 186230557Sjimharris 187230557Sjimharris /** 188230557Sjimharris * This field provides a list to manage the memory resource for all 189230557Sjimharris * smp_phy objects. 190230557Sjimharris */ 191230557Sjimharris SCI_FAST_LIST_T smp_phy_memory_list; 192230557Sjimharris 193230557Sjimharris#if !defined(DISABLE_INTERRUPTS) 194230557Sjimharris /** 195230557Sjimharris * This field saves the interrupt coalescing count before changing interrupt 196230557Sjimharris * coalescence. 197230557Sjimharris */ 198230557Sjimharris U16 saved_interrupt_coalesce_number; 199230557Sjimharris 200230557Sjimharris /** 201230557Sjimharris * This field saves the interrupt coalescing timeout values in micorseconds 202230557Sjimharris * before changing interrupt coalescence. 203230557Sjimharris */ 204230557Sjimharris U32 saved_interrupt_coalesce_timeout; 205230557Sjimharris#endif // !defined(DISABLE_INTERRUPTS) 206230557Sjimharris 207230557Sjimharris} SCIF_SAS_CONTROLLER_T; 208230557Sjimharris 209230557Sjimharrisextern SCI_BASE_STATE_T scif_sas_controller_state_table[]; 210230557Sjimharrisextern SCI_BASE_CONTROLLER_STATE_HANDLER_T 211230557Sjimharris scif_sas_controller_state_handler_table[]; 212230557Sjimharris 213230557SjimharrisSCI_STATUS scif_sas_controller_continue_io( 214230557Sjimharris SCI_CONTROLLER_HANDLE_T controller, 215230557Sjimharris SCI_REMOTE_DEVICE_HANDLE_T remote_device, 216230557Sjimharris SCI_IO_REQUEST_HANDLE_T io_request 217230557Sjimharris); 218230557Sjimharris 219230557Sjimharrisvoid scif_sas_controller_destruct( 220230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 221230557Sjimharris); 222230557Sjimharris 223230557Sjimharrisvoid * scif_sas_controller_allocate_internal_request( 224230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 225230557Sjimharris); 226230557Sjimharris 227230557Sjimharrisvoid scif_sas_controller_free_internal_request( 228230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller, 229230557Sjimharris void * fw_internal_request_buffer 230230557Sjimharris); 231230557Sjimharris 232230557Sjimharrisvoid scif_sas_controller_start_high_priority_io( 233230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 234230557Sjimharris); 235230557Sjimharris 236230557SjimharrisBOOL scif_sas_controller_sufficient_resource( 237230557Sjimharris SCIF_SAS_CONTROLLER_T *fw_controller 238230557Sjimharris); 239230557Sjimharris 240230557SjimharrisSCI_STATUS scif_sas_controller_complete_high_priority_io( 241230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller, 242230557Sjimharris SCIF_SAS_REMOTE_DEVICE_T * remote_device, 243230557Sjimharris SCIF_SAS_REQUEST_T * io_request 244230557Sjimharris); 245230557Sjimharris 246230557SjimharrisSCIF_SAS_SMP_PHY_T * scif_sas_controller_allocate_smp_phy( 247230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 248230557Sjimharris); 249230557Sjimharris 250230557Sjimharrisvoid scif_sas_controller_free_smp_phy( 251230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller, 252230557Sjimharris SCIF_SAS_SMP_PHY_T * smp_phy 253230557Sjimharris); 254230557Sjimharris 255230557SjimharrisSCI_STATUS scif_sas_controller_clear_affiliation( 256230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 257230557Sjimharris); 258230557Sjimharris 259230557SjimharrisSCI_STATUS scif_sas_controller_continue_to_stop( 260230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 261230557Sjimharris); 262230557Sjimharris 263230557Sjimharrisvoid scif_sas_controller_set_default_config_parameters( 264230557Sjimharris SCIF_SAS_CONTROLLER_T * this_controller 265230557Sjimharris); 266230557Sjimharris 267230557SjimharrisSCI_STATUS scif_sas_controller_release_resource( 268230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 269230557Sjimharris); 270230557Sjimharris 271230557Sjimharrisvoid scif_sas_controller_build_mdl( 272230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 273230557Sjimharris); 274230557Sjimharris 275230557Sjimharris#if !defined(DISABLE_INTERRUPTS) 276230557Sjimharris 277230557Sjimharrisvoid scif_sas_controller_save_interrupt_coalescence( 278230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 279230557Sjimharris); 280230557Sjimharris 281230557Sjimharrisvoid scif_sas_controller_restore_interrupt_coalescence( 282230557Sjimharris SCIF_SAS_CONTROLLER_T * fw_controller 283230557Sjimharris); 284230557Sjimharris 285230557Sjimharris#else // !defined(DISABLE_INTERRUPTS) 286230557Sjimharris#define scif_sas_controller_save_interrupt_coalescence(controller) 287230557Sjimharris#define scif_sas_controller_restore_interrupt_coalescence(controller) 288230557Sjimharris#endif // !defined(DISABLE_INTERRUPTS) 289230557Sjimharris 290230557Sjimharris#ifdef SCI_LOGGING 291230557Sjimharrisvoid scif_sas_controller_initialize_state_logging( 292230557Sjimharris SCIF_SAS_CONTROLLER_T *this_controller 293230557Sjimharris); 294230557Sjimharris 295230557Sjimharrisvoid scif_sas_controller_deinitialize_state_logging( 296230557Sjimharris SCIF_SAS_CONTROLLER_T *this_controller 297230557Sjimharris); 298230557Sjimharris#else // SCI_LOGGING 299230557Sjimharris#define scif_sas_controller_initialize_state_logging(x) 300230557Sjimharris#define scif_sas_controller_deinitialize_state_logging(x) 301230557Sjimharris#endif // SCI_LOGGING 302230557Sjimharris 303230557Sjimharris#ifdef __cplusplus 304230557Sjimharris} 305230557Sjimharris#endif // __cplusplus 306230557Sjimharris 307230557Sjimharris#endif // _SCIF_SAS_CONTROLLER_H_ 308230557Sjimharris 309