1279219Sken/*- 2279219Sken * This file is provided under a dual BSD/GPLv2 license. When using or 3279219Sken * redistributing this file, you may do so under either license. 4279219Sken * 5279219Sken * GPL LICENSE SUMMARY 6279219Sken * 7279219Sken * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8279219Sken * 9279219Sken * This program is free software; you can redistribute it and/or modify 10279219Sken * it under the terms of version 2 of the GNU General Public License as 11279219Sken * published by the Free Software Foundation. 12279219Sken * 13279219Sken * This program is distributed in the hope that it will be useful, but 14279219Sken * WITHOUT ANY WARRANTY; without even the implied warranty of 15279219Sken * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16279219Sken * General Public License for more details. 17279219Sken * 18279219Sken * You should have received a copy of the GNU General Public License 19279219Sken * along with this program; if not, write to the Free Software 20279219Sken * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21279219Sken * The full GNU General Public License is included in this distribution 22279219Sken * in the file called LICENSE.GPL. 23279219Sken * 24279219Sken * BSD LICENSE 25279219Sken * 26279219Sken * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27279219Sken * All rights reserved. 28279219Sken * 29279219Sken * Redistribution and use in source and binary forms, with or without 30279219Sken * modification, are permitted provided that the following conditions 31279219Sken * are met: 32279219Sken * 33279219Sken * * Redistributions of source code must retain the above copyright 34279219Sken * notice, this list of conditions and the following disclaimer. 35279219Sken * * Redistributions in binary form must reproduce the above copyright 36279219Sken * notice, this list of conditions and the following disclaimer in 37279219Sken * the documentation and/or other materials provided with the 38279219Sken * distribution. 39279219Sken * 40279219Sken * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41279219Sken * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42279219Sken * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43279219Sken * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44279219Sken * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45279219Sken * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46279219Sken * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47279219Sken * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48279219Sken * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49279219Sken * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50279219Sken * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51279219Sken * 52279219Sken * $FreeBSD$ 53279219Sken */ 54279219Sken#ifndef _SCIF_SAS_CONTROLLER_H_ 55279219Sken#define _SCIF_SAS_CONTROLLER_H_ 56279219Sken 57279219Sken/** 58279219Sken * @file 59279219Sken * 60279219Sken * @brief This file contains the protected interface structures, constants, 61279219Sken * and methods for the SCIF_SAS_CONTROLLER object. 62279219Sken */ 63279219Sken 64279219Sken#ifdef __cplusplus 65279219Skenextern "C" { 66279219Sken#endif // __cplusplus 67279219Sken 68279219Sken#include <dev/isci/scil/sci_types.h> 69279219Sken#include <dev/isci/scil/sci_abstract_list.h> 70279219Sken#include <dev/isci/scil/sci_controller_constants.h> 71280438Sken#include <dev/isci/scil/sci_memory_descriptor_list.h> 72279219Sken#include <dev/isci/scil/sci_base_controller.h> 73279219Sken#include <dev/isci/scil/scif_controller.h> 74279219Sken#include <dev/isci/scil/scif_config_parameters.h> 75279219Sken#include <dev/isci/scil/scif_sas_domain.h> 76279219Sken#include <dev/isci/scil/scif_sas_io_request.h> 77279219Sken#include <dev/isci/scil/scif_sas_task_request.h> 78279219Sken#include <dev/isci/scil/scif_sas_constants.h> 79279219Sken#include <dev/isci/scil/sci_pool.h> 80279219Sken#include <dev/isci/scil/scif_sas_internal_io_request.h> 81279219Sken#include <dev/isci/scil/scif_sas_high_priority_request_queue.h> 82279219Sken#include <dev/isci/scil/scif_sas_smp_phy.h> 83279219Sken 84279219Sken 85279219Sken// Currently there is only a need for 1 memory descriptor. This descriptor 86279219Sken// describes the internal IO request memory. 87279219Sken#define SCIF_SAS_MAX_MEMORY_DESCRIPTORS 1 88279219Sken 89279219Skenenum _SCIF_SAS_MAX_MEMORY_DESCRIPTORS 90279219Sken{ 91279219Sken SCIF_SAS_MDE_INTERNAL_IO = 0 92279219Sken 93279219Sken}; 94279219Sken 95279219Sken/** 96279219Sken * @struct SCIF_SAS_CONTROLLER 97279219Sken * 98279219Sken * @brief The SCI SAS Framework controller object abstracts storage controller 99279219Sken * level behavior for the framework component. 100279219Sken */ 101279219Skentypedef struct SCIF_SAS_CONTROLLER 102279219Sken{ 103279219Sken /** 104279219Sken * The SCI_BASE_CONTROLLER is the parent object for the SCIF_SAS_CONTROLLER 105279219Sken * object. 106279219Sken */ 107279219Sken SCI_BASE_CONTROLLER_T parent; 108279219Sken 109279219Sken /** 110279219Sken * This field contains the handle for the SCI Core controller object that 111279219Sken * is managed by this framework controller. 112279219Sken */ 113279219Sken SCI_CONTROLLER_HANDLE_T core_object; 114279219Sken 115279219Sken /** 116279219Sken * This field references the list of state specific handler methods to 117279219Sken * be utilized for this controller instance. 118279219Sken */ 119279219Sken SCI_BASE_CONTROLLER_STATE_HANDLER_T * state_handlers; 120279219Sken 121279219Sken /** 122279219Sken * This field contains the memory desciptors defining the physical 123279219Sken * memory requirements for this controller. 124279219Sken */ 125279219Sken SCI_PHYSICAL_MEMORY_DESCRIPTOR_T mdes[SCIF_SAS_MAX_MEMORY_DESCRIPTORS]; 126279219Sken 127279219Sken /** 128279219Sken * This field contains the SAS domain objects managed by this controller. 129279219Sken */ 130279219Sken SCIF_SAS_DOMAIN_T domains[SCI_MAX_DOMAINS]; 131279219Sken 132279219Sken /** 133279219Sken * This field represents the pool of available remote device objects 134279219Sken * supported by the controller. 135279219Sken */ 136279219Sken SCI_ABSTRACT_ELEMENT_POOL_T free_remote_device_pool; 137279219Sken 138279219Sken /** 139279219Sken * This field contains the maximum number of abstract elements that 140279219Sken * can be placed in the pool. 141279219Sken */ 142279219Sken SCI_ABSTRACT_ELEMENT_T remote_device_pool_elements[SCI_MAX_REMOTE_DEVICES]; 143279219Sken 144279219Sken /** 145279219Sken * This field provides the controller object a scratch area to indicate 146279219Sken * status of an ongoing operation. 147279219Sken */ 148279219Sken SCI_STATUS operation_status; 149279219Sken 150279219Sken /** 151279219Sken * This field will contain an user specified parameter information 152279219Sken * to be utilized by the framework. 153279219Sken */ 154279219Sken SCIF_USER_PARAMETERS_T user_parameters; 155279219Sken 156279219Sken /** 157279219Sken * This field records the index for the current domain to clear affiliation 158279219Sken * EA SATA remote devices, during the controller stop process. 159279219Sken */ 160279219Sken U8 current_domain_to_clear_affiliation; 161279219Sken 162279219Sken U32 internal_request_entries; 163279219Sken 164279219Sken /** 165279219Sken * This field provides a pool to manage the memory resource for all internal 166279219Sken * requests. 167279219Sken * requests. 168279219Sken */ 169279219Sken SCI_POOL_CREATE( 170279219Sken internal_request_memory_pool, 171279219Sken POINTER_UINT, 172279219Sken SCIF_SAS_MAX_INTERNAL_REQUEST_COUNT 173279219Sken ); 174279219Sken 175279219Sken /** 176279219Sken * This field provides a queue for built internal requests waiting to be 177279219Sken * started. 178279219Sken */ 179279219Sken SCIF_SAS_HIGH_PRIORITY_REQUEST_QUEUE_T hprq; 180279219Sken 181279219Sken /** 182279219Sken * This represents the number of available SMP phy objects that can 183279219Sken * be managed by the framework. 184279219Sken */ 185279219Sken SCIF_SAS_SMP_PHY_T smp_phy_array[SCIF_SAS_SMP_PHY_COUNT]; 186279219Sken 187279219Sken /** 188279219Sken * This field provides a list to manage the memory resource for all 189279219Sken * smp_phy objects. 190279219Sken */ 191279219Sken SCI_FAST_LIST_T smp_phy_memory_list; 192279219Sken 193279219Sken#if !defined(DISABLE_INTERRUPTS) 194279219Sken /** 195279219Sken * This field saves the interrupt coalescing count before changing interrupt 196279219Sken * coalescence. 197279219Sken */ 198279219Sken U16 saved_interrupt_coalesce_number; 199279219Sken 200279219Sken /** 201279219Sken * This field saves the interrupt coalescing timeout values in micorseconds 202279219Sken * before changing interrupt coalescence. 203279219Sken */ 204279219Sken U32 saved_interrupt_coalesce_timeout; 205279219Sken#endif // !defined(DISABLE_INTERRUPTS) 206279219Sken 207279219Sken} SCIF_SAS_CONTROLLER_T; 208279219Sken 209279219Skenextern SCI_BASE_STATE_T scif_sas_controller_state_table[]; 210279219Skenextern SCI_BASE_CONTROLLER_STATE_HANDLER_T 211279219Sken scif_sas_controller_state_handler_table[]; 212279219Sken 213279219SkenSCI_STATUS scif_sas_controller_continue_io( 214279219Sken SCI_CONTROLLER_HANDLE_T controller, 215279219Sken SCI_REMOTE_DEVICE_HANDLE_T remote_device, 216279219Sken SCI_IO_REQUEST_HANDLE_T io_request 217279219Sken); 218279219Sken 219279219Skenvoid scif_sas_controller_destruct( 220279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 221279219Sken); 222279219Sken 223279219Skenvoid * scif_sas_controller_allocate_internal_request( 224279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 225279219Sken); 226279219Sken 227279219Skenvoid scif_sas_controller_free_internal_request( 228279219Sken SCIF_SAS_CONTROLLER_T * fw_controller, 229279219Sken void * fw_internal_request_buffer 230279219Sken); 231279219Sken 232279219Skenvoid scif_sas_controller_start_high_priority_io( 233279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 234279219Sken); 235279219Sken 236279219SkenBOOL scif_sas_controller_sufficient_resource( 237279219Sken SCIF_SAS_CONTROLLER_T *fw_controller 238279219Sken); 239279219Sken 240279219SkenSCI_STATUS scif_sas_controller_complete_high_priority_io( 241279219Sken SCIF_SAS_CONTROLLER_T * fw_controller, 242279219Sken SCIF_SAS_REMOTE_DEVICE_T * remote_device, 243279219Sken SCIF_SAS_REQUEST_T * io_request 244279219Sken); 245279219Sken 246279219SkenSCIF_SAS_SMP_PHY_T * scif_sas_controller_allocate_smp_phy( 247279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 248279219Sken); 249279219Sken 250279219Skenvoid scif_sas_controller_free_smp_phy( 251279219Sken SCIF_SAS_CONTROLLER_T * fw_controller, 252279219Sken SCIF_SAS_SMP_PHY_T * smp_phy 253279219Sken); 254279219Sken 255279219SkenSCI_STATUS scif_sas_controller_clear_affiliation( 256279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 257279219Sken); 258279219Sken 259279219SkenSCI_STATUS scif_sas_controller_continue_to_stop( 260279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 261279219Sken); 262279219Sken 263279219Skenvoid scif_sas_controller_set_default_config_parameters( 264279219Sken SCIF_SAS_CONTROLLER_T * this_controller 265279219Sken); 266279219Sken 267279219SkenSCI_STATUS scif_sas_controller_release_resource( 268279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 269279219Sken); 270279219Sken 271279219Skenvoid scif_sas_controller_build_mdl( 272279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 273279219Sken); 274279219Sken 275279219Sken#if !defined(DISABLE_INTERRUPTS) 276279219Sken 277279219Skenvoid scif_sas_controller_save_interrupt_coalescence( 278279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 279279219Sken); 280279219Sken 281279219Skenvoid scif_sas_controller_restore_interrupt_coalescence( 282279219Sken SCIF_SAS_CONTROLLER_T * fw_controller 283279219Sken); 284279219Sken 285279219Sken#else // !defined(DISABLE_INTERRUPTS) 286279219Sken#define scif_sas_controller_save_interrupt_coalescence(controller) 287279219Sken#define scif_sas_controller_restore_interrupt_coalescence(controller) 288279219Sken#endif // !defined(DISABLE_INTERRUPTS) 289279219Sken 290279219Sken#ifdef SCI_LOGGING 291279219Skenvoid scif_sas_controller_initialize_state_logging( 292279219Sken SCIF_SAS_CONTROLLER_T *this_controller 293279219Sken); 294279219Sken 295279219Skenvoid scif_sas_controller_deinitialize_state_logging( 296279219Sken SCIF_SAS_CONTROLLER_T *this_controller 297279219Sken); 298279219Sken#else // SCI_LOGGING 299279219Sken#define scif_sas_controller_initialize_state_logging(x) 300279219Sken#define scif_sas_controller_deinitialize_state_logging(x) 301279219Sken#endif // SCI_LOGGING 302279219Sken 303279219Sken#ifdef __cplusplus 304279219Sken} 305279219Sken#endif // __cplusplus 306279219Sken 307279219Sken#endif // _SCIF_SAS_CONTROLLER_H_ 308279219Sken 309279219Sken