2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23 * The full GNU General Public License is included in this distribution
24 * in the file called LICENSE.GPL.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 #ifndef _SCIF_SAS_CONTROLLER_H_
57 #define _SCIF_SAS_CONTROLLER_H_
62 * @brief This file contains the protected interface structures, constants,
63 * and methods for the SCIF_SAS_CONTROLLER object.
70 #include <dev/isci/scil/sci_types.h>
71 #include <dev/isci/scil/sci_abstract_list.h>
72 #include <dev/isci/scil/sci_controller_constants.h>
73 #include <dev/isci/scil/sci_memory_descriptor_list.h>
74 #include <dev/isci/scil/sci_base_controller.h>
75 #include <dev/isci/scil/scif_controller.h>
76 #include <dev/isci/scil/scif_config_parameters.h>
77 #include <dev/isci/scil/scif_sas_domain.h>
78 #include <dev/isci/scil/scif_sas_io_request.h>
79 #include <dev/isci/scil/scif_sas_task_request.h>
80 #include <dev/isci/scil/scif_sas_constants.h>
81 #include <dev/isci/scil/sci_pool.h>
82 #include <dev/isci/scil/scif_sas_internal_io_request.h>
83 #include <dev/isci/scil/scif_sas_high_priority_request_queue.h>
84 #include <dev/isci/scil/scif_sas_smp_phy.h>
87 // Currently there is only a need for 1 memory descriptor. This descriptor
88 // describes the internal IO request memory.
89 #define SCIF_SAS_MAX_MEMORY_DESCRIPTORS 1
91 enum _SCIF_SAS_MAX_MEMORY_DESCRIPTORS
93 SCIF_SAS_MDE_INTERNAL_IO = 0
98 * @struct SCIF_SAS_CONTROLLER
100 * @brief The SCI SAS Framework controller object abstracts storage controller
101 * level behavior for the framework component.
103 typedef struct SCIF_SAS_CONTROLLER
106 * The SCI_BASE_CONTROLLER is the parent object for the SCIF_SAS_CONTROLLER
109 SCI_BASE_CONTROLLER_T parent;
112 * This field contains the handle for the SCI Core controller object that
113 * is managed by this framework controller.
115 SCI_CONTROLLER_HANDLE_T core_object;
118 * This field references the list of state specific handler methods to
119 * be utilized for this controller instance.
121 SCI_BASE_CONTROLLER_STATE_HANDLER_T * state_handlers;
124 * This field contains the memory desciptors defining the physical
125 * memory requirements for this controller.
127 SCI_PHYSICAL_MEMORY_DESCRIPTOR_T mdes[SCIF_SAS_MAX_MEMORY_DESCRIPTORS];
130 * This field contains the SAS domain objects managed by this controller.
132 SCIF_SAS_DOMAIN_T domains[SCI_MAX_DOMAINS];
135 * This field represents the pool of available remote device objects
136 * supported by the controller.
138 SCI_ABSTRACT_ELEMENT_POOL_T free_remote_device_pool;
141 * This field contains the maximum number of abstract elements that
142 * can be placed in the pool.
144 SCI_ABSTRACT_ELEMENT_T remote_device_pool_elements[SCI_MAX_REMOTE_DEVICES];
147 * This field provides the controller object a scratch area to indicate
148 * status of an ongoing operation.
150 SCI_STATUS operation_status;
153 * This field will contain an user specified parameter information
154 * to be utilized by the framework.
156 SCIF_USER_PARAMETERS_T user_parameters;
159 * This field records the index for the current domain to clear affiliation
160 * EA SATA remote devices, during the controller stop process.
162 U8 current_domain_to_clear_affiliation;
164 U32 internal_request_entries;
167 * This field provides a pool to manage the memory resource for all internal
172 internal_request_memory_pool,
174 SCIF_SAS_MAX_INTERNAL_REQUEST_COUNT
178 * This field provides a queue for built internal requests waiting to be
181 SCIF_SAS_HIGH_PRIORITY_REQUEST_QUEUE_T hprq;
184 * This represents the number of available SMP phy objects that can
185 * be managed by the framework.
187 SCIF_SAS_SMP_PHY_T smp_phy_array[SCIF_SAS_SMP_PHY_COUNT];
190 * This field provides a list to manage the memory resource for all
193 SCI_FAST_LIST_T smp_phy_memory_list;
195 #if !defined(DISABLE_INTERRUPTS)
197 * This field saves the interrupt coalescing count before changing interrupt
200 U16 saved_interrupt_coalesce_number;
203 * This field saves the interrupt coalescing timeout values in micorseconds
204 * before changing interrupt coalescence.
206 U32 saved_interrupt_coalesce_timeout;
207 #endif // !defined(DISABLE_INTERRUPTS)
209 } SCIF_SAS_CONTROLLER_T;
211 extern SCI_BASE_STATE_T scif_sas_controller_state_table[];
212 extern SCI_BASE_CONTROLLER_STATE_HANDLER_T
213 scif_sas_controller_state_handler_table[];
215 SCI_STATUS scif_sas_controller_continue_io(
216 SCI_CONTROLLER_HANDLE_T controller,
217 SCI_REMOTE_DEVICE_HANDLE_T remote_device,
218 SCI_IO_REQUEST_HANDLE_T io_request
221 void scif_sas_controller_destruct(
222 SCIF_SAS_CONTROLLER_T * fw_controller
225 void * scif_sas_controller_allocate_internal_request(
226 SCIF_SAS_CONTROLLER_T * fw_controller
229 void scif_sas_controller_free_internal_request(
230 SCIF_SAS_CONTROLLER_T * fw_controller,
231 void * fw_internal_request_buffer
234 void scif_sas_controller_start_high_priority_io(
235 SCIF_SAS_CONTROLLER_T * fw_controller
238 BOOL scif_sas_controller_sufficient_resource(
239 SCIF_SAS_CONTROLLER_T *fw_controller
242 SCI_STATUS scif_sas_controller_complete_high_priority_io(
243 SCIF_SAS_CONTROLLER_T * fw_controller,
244 SCIF_SAS_REMOTE_DEVICE_T * remote_device,
245 SCIF_SAS_REQUEST_T * io_request
248 SCIF_SAS_SMP_PHY_T * scif_sas_controller_allocate_smp_phy(
249 SCIF_SAS_CONTROLLER_T * fw_controller
252 void scif_sas_controller_free_smp_phy(
253 SCIF_SAS_CONTROLLER_T * fw_controller,
254 SCIF_SAS_SMP_PHY_T * smp_phy
257 SCI_STATUS scif_sas_controller_clear_affiliation(
258 SCIF_SAS_CONTROLLER_T * fw_controller
261 SCI_STATUS scif_sas_controller_continue_to_stop(
262 SCIF_SAS_CONTROLLER_T * fw_controller
265 void scif_sas_controller_set_default_config_parameters(
266 SCIF_SAS_CONTROLLER_T * this_controller
269 SCI_STATUS scif_sas_controller_release_resource(
270 SCIF_SAS_CONTROLLER_T * fw_controller
273 void scif_sas_controller_build_mdl(
274 SCIF_SAS_CONTROLLER_T * fw_controller
277 #if !defined(DISABLE_INTERRUPTS)
279 void scif_sas_controller_save_interrupt_coalescence(
280 SCIF_SAS_CONTROLLER_T * fw_controller
283 void scif_sas_controller_restore_interrupt_coalescence(
284 SCIF_SAS_CONTROLLER_T * fw_controller
287 #else // !defined(DISABLE_INTERRUPTS)
288 #define scif_sas_controller_save_interrupt_coalescence(controller)
289 #define scif_sas_controller_restore_interrupt_coalescence(controller)
290 #endif // !defined(DISABLE_INTERRUPTS)
293 void scif_sas_controller_initialize_state_logging(
294 SCIF_SAS_CONTROLLER_T *this_controller
297 void scif_sas_controller_deinitialize_state_logging(
298 SCIF_SAS_CONTROLLER_T *this_controller
301 #define scif_sas_controller_initialize_state_logging(x)
302 #define scif_sas_controller_deinitialize_state_logging(x)
303 #endif // SCI_LOGGING
307 #endif // __cplusplus
309 #endif // _SCIF_SAS_CONTROLLER_H_