xref: /freebsd/sys/dev/isci/scil/scic_controller.h (revision 5014dc958f0f3b7ba0c0a6ff84faa45151af51ac)
1f11c7f63SJim Harris /*-
2718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3718cf2ccSPedro 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  * $FreeBSD$
55f11c7f63SJim Harris  */
56f11c7f63SJim Harris #ifndef _SCIC_CONTROLLER_H_
57f11c7f63SJim Harris #define _SCIC_CONTROLLER_H_
58f11c7f63SJim Harris 
59f11c7f63SJim Harris /**
60f11c7f63SJim Harris  * @file
61f11c7f63SJim Harris  *
62f11c7f63SJim Harris  * @brief This file contains all of the interface methods that can be called
63f11c7f63SJim Harris  *        by an SCIC user on a controller object.
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 #include <dev/isci/scil/sci_controller.h>
73f11c7f63SJim Harris #include <dev/isci/scil/scic_config_parameters.h>
74f11c7f63SJim Harris 
75f11c7f63SJim Harris /**
76f11c7f63SJim Harris  * @enum
77f11c7f63SJim Harris  *
78f11c7f63SJim Harris  * Allowed PORT configuration modes
79f11c7f63SJim Harris  *
80f11c7f63SJim Harris  * APC Automatic PORT configuration mode is defined by the OEM configuration
81f11c7f63SJim Harris  * parameters providing no PHY_MASK parameters for any PORT. i.e. There are
82f11c7f63SJim Harris  * no phys assigned to any of the ports at start.
83f11c7f63SJim Harris  *
84f11c7f63SJim Harris  * MPC Manual PORT configuration mode is defined by the OEM configuration
85f11c7f63SJim Harris  * parameters providing a PHY_MASK value for any PORT.  It is assumed that
86f11c7f63SJim Harris  * any PORT with no PHY_MASK is an invalid port and not all PHYs must be
87f11c7f63SJim Harris  * assigned. A PORT_PHY mask that assigns just a single PHY to a port and no
88f11c7f63SJim Harris  * other PHYs being assigned is sufficient to declare manual PORT configuration.
89f11c7f63SJim Harris  */
90f11c7f63SJim Harris enum SCIC_PORT_CONFIGURATION_MODE
91f11c7f63SJim Harris {
92f11c7f63SJim Harris    SCIC_PORT_MANUAL_CONFIGURATION_MODE,
93f11c7f63SJim Harris    SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE
94f11c7f63SJim Harris };
95f11c7f63SJim Harris 
96f11c7f63SJim Harris /**
97f11c7f63SJim Harris  * @enum _SCIC_INTERRUPT_TYPE
98f11c7f63SJim Harris  *
99f11c7f63SJim Harris  * @brief This enumeration depicts the various types of interrupts that
100f11c7f63SJim Harris  *        are potentially supported by a SCI Core implementation.
101f11c7f63SJim Harris  */
102f11c7f63SJim Harris typedef enum _SCIC_INTERRUPT_TYPE
103f11c7f63SJim Harris {
104f11c7f63SJim Harris    SCIC_LEGACY_LINE_INTERRUPT_TYPE,
105f11c7f63SJim Harris    SCIC_MSIX_INTERRUPT_TYPE,
106f11c7f63SJim Harris 
107f11c7f63SJim Harris    /**
108f11c7f63SJim Harris     * This enumeration value indicates the use of polling.
109f11c7f63SJim Harris     */
110f11c7f63SJim Harris    SCIC_NO_INTERRUPTS
111f11c7f63SJim Harris 
112f11c7f63SJim Harris } SCIC_INTERRUPT_TYPE;
113f11c7f63SJim Harris 
114f11c7f63SJim Harris /**
115f11c7f63SJim Harris  * @typedef SCIC_CONTROLLER_INTERRUPT_HANDLER
116f11c7f63SJim Harris  *
117f11c7f63SJim Harris  * @brief This method is called by the SCI user in order to have the SCI
118f11c7f63SJim Harris  *        implementation handle the interrupt.  This method performs
119f11c7f63SJim Harris  *        minimal processing to allow for streamlined interrupt time usage.
120f11c7f63SJim Harris  * @note
121f11c7f63SJim Harris  *        TRUE: returned if there is an interrupt to process and it was
122f11c7f63SJim Harris  *              processed.
123f11c7f63SJim Harris  *        FALSE: returned if no interrupt was processed.
124f11c7f63SJim Harris  *
125f11c7f63SJim Harris  */
126f11c7f63SJim Harris typedef BOOL (*SCIC_CONTROLLER_INTERRUPT_HANDLER)(
127f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller
128f11c7f63SJim Harris );
129f11c7f63SJim Harris 
130f11c7f63SJim Harris /**
131f11c7f63SJim Harris  * @brief This method is called by the SCI user to process completions
132f11c7f63SJim Harris  *        generated as a result of a previously handled interrupt.  This
133f11c7f63SJim Harris  *        method will result in the completion of IO requests and handling
134f11c7f63SJim Harris  *        of other controller generated events.  This method should be
135f11c7f63SJim Harris  *        called some time after the interrupt handler.
136f11c7f63SJim Harris  *
137f11c7f63SJim Harris  * @note  Most, if not all, of the user callback APIs are invoked from within
138453130d9SPedro F. Giffuni  *        this API.  As a result, the user should be cognizant of the operating
139f11c7f63SJim Harris  *        level at which they invoke this API.
140f11c7f63SJim Harris  *
141f11c7f63SJim Harris  */
142f11c7f63SJim Harris typedef void (*SCIC_CONTROLLER_COMPLETION_HANDLER)(
143f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller
144f11c7f63SJim Harris );
145f11c7f63SJim Harris 
146f11c7f63SJim Harris /**
147f11c7f63SJim Harris  * @struct SCIC_CONTROLLER_HANDLER_METHODS
148f11c7f63SJim Harris  *
149f11c7f63SJim Harris  * @brief This structure contains an interrupt handler and completion
150f11c7f63SJim Harris  *        handler function pointers.
151f11c7f63SJim Harris  */
152f11c7f63SJim Harris typedef struct SCIC_CONTROLLER_HANDLER_METHODS
153f11c7f63SJim Harris {
154f11c7f63SJim Harris    SCIC_CONTROLLER_INTERRUPT_HANDLER  interrupt_handler;
155f11c7f63SJim Harris    SCIC_CONTROLLER_COMPLETION_HANDLER completion_handler;
156f11c7f63SJim Harris 
157f11c7f63SJim Harris } SCIC_CONTROLLER_HANDLER_METHODS_T;
158f11c7f63SJim Harris 
159f11c7f63SJim Harris /**
160f11c7f63SJim Harris  * @brief This method will attempt to construct a controller object
161f11c7f63SJim Harris  *        utilizing the supplied parameter information.
162f11c7f63SJim Harris  *
163f11c7f63SJim Harris  * @param[in]  library This parameter specifies the handle to the library
164f11c7f63SJim Harris  *             object associated with the controller being constructed.
165f11c7f63SJim Harris  * @param[in]  controller This parameter specifies the controller to be
166f11c7f63SJim Harris  *             constructed.
167f11c7f63SJim Harris  * @param[in]  user_object This parameter is a reference to the SCIL users
168f11c7f63SJim Harris  *             controller object and will be used to associate with the core
169f11c7f63SJim Harris  *             controller.
170f11c7f63SJim Harris  *
171f11c7f63SJim Harris  * @return Indicate if the controller was successfully constructed or if
172f11c7f63SJim Harris  *         it failed in some way.
173f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if the controller was
174f11c7f63SJim Harris  *         successfully constructed.
175f11c7f63SJim Harris  * @retval SCI_WARNING_TIMER_CONFLICT This value is returned if the
176f11c7f63SJim Harris  *         interrupt coalescence timer may cause SAS compliance issues
177f11c7f63SJim Harris  *         for SMP Target mode response processing.
178f11c7f63SJim Harris  * @retval SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE This value is returned if
179f11c7f63SJim Harris  *         the controller does not support the supplied type.
180f11c7f63SJim Harris  * @retval SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION This value is returned
181f11c7f63SJim Harris  *         if the controller does not support the supplied initialization
182f11c7f63SJim Harris  *         data version.
183f11c7f63SJim Harris  */
184f11c7f63SJim Harris SCI_STATUS scic_controller_construct(
185f11c7f63SJim Harris    SCI_LIBRARY_HANDLE_T      library,
186f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
187f11c7f63SJim Harris    void *                    user_object
188f11c7f63SJim Harris );
189f11c7f63SJim Harris 
190f11c7f63SJim Harris /**
191f11c7f63SJim Harris  * @brief This method will enable all controller interrupts.
192f11c7f63SJim Harris  *
193f11c7f63SJim Harris  * @param[in]  controller This parameter specifies the controller for which
194f11c7f63SJim Harris  *             to enable interrupts.
195f11c7f63SJim Harris  *
196f11c7f63SJim Harris  * @return none
197f11c7f63SJim Harris  */
198f11c7f63SJim Harris void scic_controller_enable_interrupts(
199f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T      controller
200f11c7f63SJim Harris );
201f11c7f63SJim Harris 
202f11c7f63SJim Harris /**
203f11c7f63SJim Harris  * @brief This method will disable all controller interrupts.
204f11c7f63SJim Harris  *
205f11c7f63SJim Harris  * @param[in]  controller This parameter specifies the controller for which
206f11c7f63SJim Harris  *             to disable interrupts.
207f11c7f63SJim Harris  *
208f11c7f63SJim Harris  * @return none
209f11c7f63SJim Harris  */
210f11c7f63SJim Harris void scic_controller_disable_interrupts(
211f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T      controller
212f11c7f63SJim Harris );
213f11c7f63SJim Harris 
214f11c7f63SJim Harris /**
215f11c7f63SJim Harris  * @brief This method will return provide function pointers for the
216f11c7f63SJim Harris  *        interrupt handler and completion handler.  The interrupt handler
217f11c7f63SJim Harris  *        is expected to be invoked at interrupt time.  The completion
218f11c7f63SJim Harris  *        handler is scheduled to run as a result of the interrupt handler.
219f11c7f63SJim Harris  *        The completion handler performs the bulk work for processing
220f11c7f63SJim Harris  *        silicon events.
221f11c7f63SJim Harris  *
222f11c7f63SJim Harris  * @param[in]  interrupt_type This parameter informs the core which type
223f11c7f63SJim Harris  *             of interrupt/completion methods are being requested. These
224f11c7f63SJim Harris  *             are the types: SCIC_LEGACY_LINE_INTERRUPT_TYPE,
225f11c7f63SJim Harris  *             SCIC_MSIX_INTERRUPT_TYPE, SCIC_NO_INTERRUPTS (POLLING)
226f11c7f63SJim Harris  * @param[in]  message_count This parameter informs the core the
227f11c7f63SJim Harris  *             number of MSI-X messages to be utilized.  This parameter must
228f11c7f63SJim Harris  *             be 0 when requesting legacy line based handlers.
229f11c7f63SJim Harris  * @param[in]  handler_methods The caller provides a pointer to a buffer of
230f11c7f63SJim Harris  *             type SCIC_CONTROLLER_HANDLER_METHODS_T. The size depends on
231f11c7f63SJim Harris  *             the combination of the interrupt_type and message_count input
232f11c7f63SJim Harris  *             parameters:
233f11c7f63SJim Harris  *             SCIC_LEGACY_LINE_INTERRUPT_TYPE:
234f11c7f63SJim Harris  *             - size = sizeof(SCIC_CONTROLLER_HANDLER_METHODS_T)
235f11c7f63SJim Harris  *             SCIC_MSIX_INTERRUPT_TYPE:
236f11c7f63SJim Harris  *             - size = message_count*sizeof(SCIC_CONTROLLER_HANDLER_METHODS_T)
237f11c7f63SJim Harris  * @param[out] handler_methods SCIC fills out the caller's buffer with the
238f11c7f63SJim Harris  *             appropriate interrupt and completion handlers based on the info
239f11c7f63SJim Harris  *             provided in the interrupt_type and message_count input
240f11c7f63SJim Harris  *             parameters. For SCIC_LEGACY_LINE_INTERRUPT_TYPE, the buffer
241f11c7f63SJim Harris  *             receives a single SCIC_CONTROLLER_HANDLER_METHODS_T element
242f11c7f63SJim Harris  *             regardless that the message_count parameter is zero.
243f11c7f63SJim Harris  *             For SCIC_MSIX_INTERRUPT_TYPE, the buffer receives an array of
244f11c7f63SJim Harris  *             elements of type SCIC_CONTROLLER_HANDLER_METHODS_T where the
245f11c7f63SJim Harris  *             array size is equivalent to the message_count parameter. The
246f11c7f63SJim Harris  *             array is zero-relative where entry zero corresponds to
247f11c7f63SJim Harris  *             message-vector zero, entry one corresponds to message-vector one,
248f11c7f63SJim Harris  *             and so forth.
249f11c7f63SJim Harris  *
250f11c7f63SJim Harris  * @return Indicate if the handler retrieval operation was successful.
251f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if retrieval succeeded.
252f11c7f63SJim Harris  * @retval SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT This value is returned
253f11c7f63SJim Harris  *         if the user supplied an unsupported number of MSI-X messages.
254f11c7f63SJim Harris  *         For legacy line interrupts the only valid value is 0.
255f11c7f63SJim Harris  */
256f11c7f63SJim Harris SCI_STATUS scic_controller_get_handler_methods(
257f11c7f63SJim Harris    SCIC_INTERRUPT_TYPE                  interrupt_type,
258f11c7f63SJim Harris    U16                                  message_count,
259f11c7f63SJim Harris    SCIC_CONTROLLER_HANDLER_METHODS_T *  handler_methods
260f11c7f63SJim Harris );
261f11c7f63SJim Harris 
262f11c7f63SJim Harris /**
263f11c7f63SJim Harris  * @brief This method will initialize the controller hardware managed by
264f11c7f63SJim Harris  *        the supplied core controller object.  This method will bring the
265f11c7f63SJim Harris  *        physical controller hardware out of reset and enable the core to
266f11c7f63SJim Harris  *        determine the capabilities of the hardware being managed.  Thus,
267f11c7f63SJim Harris  *        the core controller can determine it's exact physical (DMA capable)
268f11c7f63SJim Harris  *        memory requirements.
269f11c7f63SJim Harris  *
270f11c7f63SJim Harris  * @pre   The SCI Core user must have called scic_controller_construct()
271f11c7f63SJim Harris  *        on the supplied controller object previously.
272f11c7f63SJim Harris  *
273f11c7f63SJim Harris  * @param[in]  controller This parameter specifies the controller to be
274f11c7f63SJim Harris  *             initialized.
275f11c7f63SJim Harris  *
276f11c7f63SJim Harris  * @return Indicate if the controller was successfully initialized or if
277f11c7f63SJim Harris  *         it failed in some way.
278f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if the controller hardware
279f11c7f63SJim Harris  *         was successfully initialized.
280f11c7f63SJim Harris  */
281f11c7f63SJim Harris SCI_STATUS scic_controller_initialize(
282f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller
283f11c7f63SJim Harris );
284f11c7f63SJim Harris 
285f11c7f63SJim Harris /**
286f11c7f63SJim Harris  * @brief This method returns the suggested scic_controller_start()
287f11c7f63SJim Harris  *        timeout amount.  The user is free to use any timeout value,
288f11c7f63SJim Harris  *        but this method provides the suggested minimum start timeout
289f11c7f63SJim Harris  *        value.  The returned value is based upon empirical information
290f11c7f63SJim Harris  *        determined as a result of interoperability testing.
291f11c7f63SJim Harris  *
292f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object for which
293f11c7f63SJim Harris  *             to return the suggested start timeout.
294f11c7f63SJim Harris  *
295f11c7f63SJim Harris  * @return  This method returns the number of milliseconds for the
296f11c7f63SJim Harris  *          suggested start operation timeout.
297f11c7f63SJim Harris  */
298f11c7f63SJim Harris U32 scic_controller_get_suggested_start_timeout(
299f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller
300f11c7f63SJim Harris );
301f11c7f63SJim Harris 
302f11c7f63SJim Harris /**
303f11c7f63SJim Harris  * @brief This method will start the supplied core controller.  This method
304f11c7f63SJim Harris  *        will start the staggered spin up operation.  The SCI User completion
305f11c7f63SJim Harris  *        callback is called when the following conditions are met:
306f11c7f63SJim Harris  *        -# the return status of this method is SCI_SUCCESS.
307f11c7f63SJim Harris  *        -# after all of the phys have successfully started or been given
308f11c7f63SJim Harris  *           the opportunity to start.
309f11c7f63SJim Harris  *
310f11c7f63SJim Harris  * @pre   The SCI Core user must have filled in the physical memory
311f11c7f63SJim Harris  *        descriptor structure via the
312f11c7f63SJim Harris  *        sci_controller_get_memory_descriptor_list() method.
313f11c7f63SJim Harris  * @pre   The SCI Core user must have invoked the scic_controller_initialize()
314f11c7f63SJim Harris  *        method prior to invoking this method.
315f11c7f63SJim Harris  *
316f11c7f63SJim Harris  * @pre   The controller must be in the INITIALIZED or STARTED state.
317f11c7f63SJim Harris  *
318f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object to start.
319f11c7f63SJim Harris  * @param[in]  timeout This parameter specifies the number of milliseconds
320f11c7f63SJim Harris  *             in which the start operation should complete.
321f11c7f63SJim Harris  *
322f11c7f63SJim Harris  * @return Indicate if the controller start method succeeded or failed in
323f11c7f63SJim Harris  *         some way.
324f11c7f63SJim Harris  * @retval SCI_SUCCESS if the start operation succeeded.
325f11c7f63SJim Harris  * @retval SCI_WARNING_ALREADY_IN_STATE if the controller is already in
326f11c7f63SJim Harris  *         the STARTED state.
327f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_STATE if the controller is not either in
328f11c7f63SJim Harris  *         the INITIALIZED or STARTED states.
329f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_MEMORY_DESCRIPTOR if there are
330f11c7f63SJim Harris  *         inconsistent or invalid values in the supplied
331f11c7f63SJim Harris  *         SCI_PHYSICAL_MEMORY_DESCRIPTOR array.
332f11c7f63SJim Harris  */
333f11c7f63SJim Harris SCI_STATUS scic_controller_start(
334f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller,
335f11c7f63SJim Harris    U32                      timeout
336f11c7f63SJim Harris );
337f11c7f63SJim Harris 
338f11c7f63SJim Harris /**
339f11c7f63SJim Harris  * @brief This method will stop an individual controller object.This method
340f11c7f63SJim Harris  *        will invoke the associated user callback upon completion.  The
341f11c7f63SJim Harris  *        completion callback is called when the following conditions are met:
342f11c7f63SJim Harris  *           -# the method return status is SCI_SUCCESS.
343f11c7f63SJim Harris  *           -# the controller has been quiesced.
344f11c7f63SJim Harris  *        This method will ensure that all IO requests are quiesced, phys
345f11c7f63SJim Harris  *        are stopped, and all additional operation by the hardware is halted.
346f11c7f63SJim Harris  *
347f11c7f63SJim Harris  * @pre   The controller must be in the STARTED or STOPPED state.
348f11c7f63SJim Harris  *
349f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object to stop.
350f11c7f63SJim Harris  * @param[in]  timeout This parameter specifies the number of milliseconds
351f11c7f63SJim Harris  *             in which the stop operation should complete.
352f11c7f63SJim Harris  *
353f11c7f63SJim Harris  * @return Indicate if the controller stop method succeeded or failed in
354f11c7f63SJim Harris  *         some way.
355f11c7f63SJim Harris  * @retval SCI_SUCCESS if the stop operation successfully began.
356f11c7f63SJim Harris  * @retval SCI_WARNING_ALREADY_IN_STATE if the controller is already in
357f11c7f63SJim Harris  *         the STOPPED state.
358f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_STATE if the controller is not either in
359f11c7f63SJim Harris  *         the STARTED or STOPPED states.
360f11c7f63SJim Harris  */
361f11c7f63SJim Harris SCI_STATUS scic_controller_stop(
362f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller,
363f11c7f63SJim Harris    U32                      timeout
364f11c7f63SJim Harris );
365f11c7f63SJim Harris 
366f11c7f63SJim Harris /**
367f11c7f63SJim Harris  * @brief This method will reset the supplied core controller regardless of
368f11c7f63SJim Harris  *        the state of said controller.  This operation is considered
369f11c7f63SJim Harris  *        destructive.  In other words, all current operations are wiped
370f11c7f63SJim Harris  *        out.  No IO completions for outstanding devices occur.  Outstanding
371f11c7f63SJim Harris  *        IO requests are not aborted or completed at the actual remote
372f11c7f63SJim Harris  *        device.
373f11c7f63SJim Harris  *
374f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object to reset.
375f11c7f63SJim Harris  *
376f11c7f63SJim Harris  * @return Indicate if the controller reset method succeeded or failed in
377f11c7f63SJim Harris  *         some way.
378f11c7f63SJim Harris  * @retval SCI_SUCCESS if the reset operation successfully started.
379f11c7f63SJim Harris  * @retval SCI_FATAL_ERROR if the controller reset operation is unable to
380f11c7f63SJim Harris  *         complete.
381f11c7f63SJim Harris  */
382f11c7f63SJim Harris SCI_STATUS scic_controller_reset(
383f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller
384f11c7f63SJim Harris );
385f11c7f63SJim Harris 
386f11c7f63SJim Harris /**
387f11c7f63SJim Harris  * @brief This method is called by the SCI user to send/start an IO request.
388f11c7f63SJim Harris  *        If the method invocation is successful, then the IO request has
389f11c7f63SJim Harris  *        been queued to the hardware for processing.
390f11c7f63SJim Harris  *
391f11c7f63SJim Harris  * @warning
392f11c7f63SJim Harris  *         - IO tags are a protected resource.  It is incumbent upon the
393f11c7f63SJim Harris  *           SCI Core user to ensure that each of the methods that may
394f11c7f63SJim Harris  *           allocate or free available IO tags are handled in a mutually
395f11c7f63SJim Harris  *           exclusive manner.  This method is one of said methods requiring
396f11c7f63SJim Harris  *           proper critical code section protection (e.g. semaphore,
397f11c7f63SJim Harris  *           spin-lock, etc.).
398f11c7f63SJim Harris  *         - For SATA, the user is required to manage NCQ tags.  As a
399f11c7f63SJim Harris  *           result, it is expected the user will have set the NCQ tag
400f11c7f63SJim Harris  *           field in the host to device register FIS prior to calling
401f11c7f63SJim Harris  *           this method.  There is also a requirement for the user
402f11c7f63SJim Harris  *           to call scic_stp_io_set_ncq_tag() prior to invoking the
403f11c7f63SJim Harris  *           scic_controller_start_io() method.
404f11c7f63SJim Harris  *
405f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object for which
406f11c7f63SJim Harris  *             to start an IO request.
407f11c7f63SJim Harris  * @param[in]  remote_device the handle to the remote device object for which
408f11c7f63SJim Harris  *             to start an IO request.
409f11c7f63SJim Harris  * @param[in]  io_request the handle to the io request object to start.
410f11c7f63SJim Harris  * @param[in]  io_tag This parameter specifies a previously allocated IO tag
411f11c7f63SJim Harris  *             that the user desires to be utilized for this request.
412f11c7f63SJim Harris  *             This parameter is optional.  The user is allowed to supply
413f11c7f63SJim Harris  *             SCI_CONTROLLER_INVALID_IO_TAG as the value for this parameter.
414f11c7f63SJim Harris  *             @see scic_controller_allocate_tag() for more information
415f11c7f63SJim Harris  *             on allocating a tag.
416f11c7f63SJim Harris  *
417f11c7f63SJim Harris  * @return Indicate if the controller successfully started the IO request.
418f11c7f63SJim Harris  * @retval SCI_IO_SUCCESS if the IO request was successfully started.
419f11c7f63SJim Harris  *
420f11c7f63SJim Harris  * @todo Determine the failure situations and return values.
421f11c7f63SJim Harris  */
422f11c7f63SJim Harris SCI_IO_STATUS scic_controller_start_io(
423f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T     controller,
424f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device,
425f11c7f63SJim Harris    SCI_IO_REQUEST_HANDLE_T     io_request,
426f11c7f63SJim Harris    U16                         io_tag
427f11c7f63SJim Harris );
428f11c7f63SJim Harris 
429f11c7f63SJim Harris #if !defined(DISABLE_TASK_MANAGEMENT)
430f11c7f63SJim Harris 
431f11c7f63SJim Harris /**
432f11c7f63SJim Harris  * @brief This method is called by the SCIC user to send/start a framework
433f11c7f63SJim Harris  *        task management request.
434f11c7f63SJim Harris  *
435f11c7f63SJim Harris  * @warning
436f11c7f63SJim Harris  *         - IO tags are a protected resource.  It is incumbent upon the
437f11c7f63SJim Harris  *           SCI Core user to ensure that each of the methods that may
438f11c7f63SJim Harris  *           allocate or free available IO tags are handled in a mutually
439f11c7f63SJim Harris  *           exclusive manner.  This method is one of said methods requiring
440f11c7f63SJim Harris  *           proper critical code section protection (e.g. semaphore,
441f11c7f63SJim Harris  *           spin-lock, etc.).
442f11c7f63SJim Harris  *         - The user must synchronize this task with completion queue
443f11c7f63SJim Harris  *           processing.  If they are not synchronized then it is possible
444f11c7f63SJim Harris  *           for the io requests that are being managed by the task request
445f11c7f63SJim Harris  *           can complete before starting the task request.
446f11c7f63SJim Harris  *
447f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object for which
448f11c7f63SJim Harris  *             to start the task management request.
449f11c7f63SJim Harris  * @param[in]  remote_device the handle to the remote device object for which
450f11c7f63SJim Harris  *             to start the task management request.
451f11c7f63SJim Harris  * @param[in]  task_request the handle to the task request object to start.
452f11c7f63SJim Harris  * @param[in]  io_tag This parameter specifies a previously allocated IO tag
453f11c7f63SJim Harris  *             that the user desires to be utilized for this request.  Note
454f11c7f63SJim Harris  *             this not the io_tag of the request being managed.  It is to
455f11c7f63SJim Harris  *             be utilized for the task request itself.
456f11c7f63SJim Harris  *             This parameter is optional.  The user is allowed to supply
457f11c7f63SJim Harris  *             SCI_CONTROLLER_INVALID_IO_TAG as the value for this parameter.
458f11c7f63SJim Harris  *             @see scic_controller_allocate_tag() for more information
459f11c7f63SJim Harris  *             on allocating a tag.
460f11c7f63SJim Harris  *
461f11c7f63SJim Harris  * @return Indicate if the controller successfully started the IO request.
462f11c7f63SJim Harris  * @retval SCI_TASK_SUCCESS if the task request was successfully started.
463f11c7f63SJim Harris  * @retval SCI_TASK_FAILURE_REQUIRES_SCSI_ABORT This value is returned if
464f11c7f63SJim Harris  *         there is/are task(s) outstanding that require termination or
465f11c7f63SJim Harris  *         completion before this request can succeed.
466f11c7f63SJim Harris  */
467f11c7f63SJim Harris SCI_TASK_STATUS scic_controller_start_task(
468f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T     controller,
469f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device,
470f11c7f63SJim Harris    SCI_TASK_REQUEST_HANDLE_T   task_request,
471f11c7f63SJim Harris    U16                         io_tag
472f11c7f63SJim Harris );
473f11c7f63SJim Harris 
474f11c7f63SJim Harris /**
475f11c7f63SJim Harris  * @brief This method will perform core specific completion operations for
476f11c7f63SJim Harris  *        task management request. After this method is invoked, the user should
477f11c7f63SJim Harris  *        consider the task request as invalid until it is properly reused
478f11c7f63SJim Harris  *        (i.e. re-constructed).
479f11c7f63SJim Harris  *
480f11c7f63SJim Harris  * @param[in]  controller The handle to the controller object for which
481f11c7f63SJim Harris  *             to complete the task management request.
482f11c7f63SJim Harris  * @param[in]  remote_device The handle to the remote device object for which
483f11c7f63SJim Harris  *             to complete the task management request.
484f11c7f63SJim Harris  * @param[in]  task_request the handle to the task management request object
485f11c7f63SJim Harris  *             to complete.
486f11c7f63SJim Harris  *
487f11c7f63SJim Harris  * @return Indicate if the controller successfully completed the task
488f11c7f63SJim Harris  *         management request.
489f11c7f63SJim Harris  * @retval SCI_SUCCESS if the completion process was successful.
490f11c7f63SJim Harris  */
491f11c7f63SJim Harris SCI_STATUS scic_controller_complete_task(
492f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T     controller,
493f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device,
494f11c7f63SJim Harris    SCI_TASK_REQUEST_HANDLE_T   task_request
495f11c7f63SJim Harris );
496f11c7f63SJim Harris 
497f11c7f63SJim Harris #else // !defined(DISABLE_TASK_MANAGEMENT)
498f11c7f63SJim Harris 
499f11c7f63SJim Harris #define scic_controller_start_task(controller, dev, task, tag) SCI_TASK_FAILURE
500f11c7f63SJim Harris #define scic_controller_complete_task(controller, dev, task) SCI_FAILURE
501f11c7f63SJim Harris 
502f11c7f63SJim Harris #endif // !defined(DISABLE_TASK_MANAGEMENT)
503f11c7f63SJim Harris 
504f11c7f63SJim Harris /**
505f11c7f63SJim Harris  * @brief This method is called by the SCI Core user to terminate an ongoing
506f11c7f63SJim Harris  *        (i.e. started) core IO request.  This does not abort the IO request
507f11c7f63SJim Harris  *        at the target, but rather removes the IO request from the host
508f11c7f63SJim Harris  *        controller.
509f11c7f63SJim Harris  *
510f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object for which
511f11c7f63SJim Harris  *             to terminate a request.
512f11c7f63SJim Harris  * @param[in]  remote_device the handle to the remote device object for which
513f11c7f63SJim Harris  *             to terminate a request.
514f11c7f63SJim Harris  * @param[in]  request the handle to the io or task management request
515f11c7f63SJim Harris  *             object to terminate.
516f11c7f63SJim Harris  *
517f11c7f63SJim Harris  * @return Indicate if the controller successfully began the terminate process
518f11c7f63SJim Harris  *         for the IO request.
519f11c7f63SJim Harris  * @retval SCI_SUCCESS if the terminate process was successfully started for
520f11c7f63SJim Harris  *         the request.
521f11c7f63SJim Harris  *
522f11c7f63SJim Harris  * @todo Determine the failure situations and return values.
523f11c7f63SJim Harris  */
524f11c7f63SJim Harris SCI_STATUS scic_controller_terminate_request(
525f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T     controller,
526f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device,
527f11c7f63SJim Harris    SCI_IO_REQUEST_HANDLE_T     request
528f11c7f63SJim Harris );
529f11c7f63SJim Harris 
530f11c7f63SJim Harris /**
531f11c7f63SJim Harris  * @brief This method will perform core specific completion operations for
532f11c7f63SJim Harris  *        an IO request.  After this method is invoked, the user should
533f11c7f63SJim Harris  *        consider the IO request as invalid until it is properly reused
534f11c7f63SJim Harris  *        (i.e. re-constructed).
535f11c7f63SJim Harris  *
536f11c7f63SJim Harris  * @warning
537f11c7f63SJim Harris  *        - IO tags are a protected resource.  It is incumbent upon the
538f11c7f63SJim Harris  *          SCI Core user to ensure that each of the methods that may
539f11c7f63SJim Harris  *          allocate or free available IO tags are handled in a mutually
540f11c7f63SJim Harris  *          exclusive manner.  This method is one of said methods requiring
541f11c7f63SJim Harris  *          proper critical code section protection (e.g. semaphore,
542f11c7f63SJim Harris  *          spin-lock, etc.).
543f11c7f63SJim Harris  *        - If the IO tag for a request was allocated, by the SCI Core user,
544f11c7f63SJim Harris  *          using the scic_controller_allocate_io_tag() method, then it is
545f11c7f63SJim Harris  *          the responsibility of the caller to invoke the
546f11c7f63SJim Harris  *          scic_controller_free_io_tag() method to free the tag (i.e. this
547f11c7f63SJim Harris  *          method will not free the IO tag).
548f11c7f63SJim Harris  *
549f11c7f63SJim Harris  * @param[in]  controller The handle to the controller object for which
550f11c7f63SJim Harris  *             to complete the IO request.
551f11c7f63SJim Harris  * @param[in]  remote_device The handle to the remote device object for which
552f11c7f63SJim Harris  *             to complete the IO request.
553f11c7f63SJim Harris  * @param[in]  io_request the handle to the io request object to complete.
554f11c7f63SJim Harris  *
555f11c7f63SJim Harris  * @return Indicate if the controller successfully completed the IO request.
556f11c7f63SJim Harris  * @retval SCI_SUCCESS if the completion process was successful.
557f11c7f63SJim Harris  */
558f11c7f63SJim Harris SCI_STATUS scic_controller_complete_io(
559f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T     controller,
560f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device,
561f11c7f63SJim Harris    SCI_IO_REQUEST_HANDLE_T     io_request
562f11c7f63SJim Harris );
563f11c7f63SJim Harris 
564f11c7f63SJim Harris 
565f11c7f63SJim Harris /**
566f11c7f63SJim Harris  * @brief This method simply provides the user with a unique handle for a
567f11c7f63SJim Harris  *        given SAS/SATA core port index.
568f11c7f63SJim Harris  *
569f11c7f63SJim Harris  * @param[in]  controller This parameter represents the handle to the
570f11c7f63SJim Harris  *             controller object from which to retrieve a port (SAS or
571f11c7f63SJim Harris  *             SATA) handle.
572f11c7f63SJim Harris  * @param[in]  port_index This parameter specifies the port index in
573f11c7f63SJim Harris  *             the controller for which to retrieve the port handle.
574f11c7f63SJim Harris  *             0 <= port_index < maximum number of phys.
575f11c7f63SJim Harris  * @param[out] port_handle This parameter specifies the retrieved port handle
576f11c7f63SJim Harris  *             to be provided to the caller.
577f11c7f63SJim Harris  *
578f11c7f63SJim Harris  * @return Indicate if the retrieval of the port handle was successful.
579f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if the retrieval was successful.
580f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_PORT This value is returned if the supplied
581f11c7f63SJim Harris  *         port id is not in the supported range.
582f11c7f63SJim Harris  */
583f11c7f63SJim Harris SCI_STATUS scic_controller_get_port_handle(
584f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
585f11c7f63SJim Harris    U8                        port_index,
586f11c7f63SJim Harris    SCI_PORT_HANDLE_T       * port_handle
587f11c7f63SJim Harris );
588f11c7f63SJim Harris 
589f11c7f63SJim Harris /**
590f11c7f63SJim Harris  * @brief This method simply provides the user with a unique handle for a
591f11c7f63SJim Harris  *        given SAS/SATA phy index/identifier.
592f11c7f63SJim Harris  *
593f11c7f63SJim Harris  * @param[in]  controller This parameter represents the handle to the
594f11c7f63SJim Harris  *             controller object from which to retrieve a phy (SAS or
595f11c7f63SJim Harris  *             SATA) handle.
596f11c7f63SJim Harris  * @param[in]  phy_index This parameter specifies the phy index in
597f11c7f63SJim Harris  *             the controller for which to retrieve the phy handle.
598f11c7f63SJim Harris  *             0 <= phy_index < maximum number of phys.
599f11c7f63SJim Harris  * @param[out] phy_handle This parameter specifies the retrieved phy handle
600f11c7f63SJim Harris  *             to be provided to the caller.
601f11c7f63SJim Harris  *
602f11c7f63SJim Harris  * @return Indicate if the retrieval of the phy handle was successful.
603f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if the retrieval was successful.
604f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_PHY This value is returned if the supplied phy
605f11c7f63SJim Harris  *         id is not in the supported range.
606f11c7f63SJim Harris  */
607f11c7f63SJim Harris SCI_STATUS scic_controller_get_phy_handle(
608f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
609f11c7f63SJim Harris    U8                        phy_index,
610f11c7f63SJim Harris    SCI_PHY_HANDLE_T        * phy_handle
611f11c7f63SJim Harris );
612f11c7f63SJim Harris 
613f11c7f63SJim Harris /**
614f11c7f63SJim Harris  * @brief This method will allocate a tag from the pool of free IO tags.
615f11c7f63SJim Harris  *        Direct allocation of IO tags by the SCI Core user is optional.
616f11c7f63SJim Harris  *        The scic_controller_start_io() method will allocate an IO
617f11c7f63SJim Harris  *        tag if this method is not utilized and the tag is not
618f11c7f63SJim Harris  *        supplied to the IO construct routine.  Direct allocation of IO tags
619f11c7f63SJim Harris  *        may provide additional performance improvements in environments
620f11c7f63SJim Harris  *        capable of supporting this usage model.  Additionally, direct
621f11c7f63SJim Harris  *        allocation of IO tags also provides additional flexibility to the
622f11c7f63SJim Harris  *        SCI Core user.  Specifically, the user may retain IO tags across
623f11c7f63SJim Harris  *        the lives of multiple IO requests.
624f11c7f63SJim Harris  *
625f11c7f63SJim Harris  * @warning IO tags are a protected resource.  It is incumbent upon the
626f11c7f63SJim Harris  *          SCI Core user to ensure that each of the methods that may
627f11c7f63SJim Harris  *          allocate or free available IO tags are handled in a mutually
628f11c7f63SJim Harris  *          exclusive manner.  This method is one of said methods requiring
629f11c7f63SJim Harris  *          proper critical code section protection (e.g. semaphore,
630f11c7f63SJim Harris  *          spin-lock, etc.).
631f11c7f63SJim Harris  *
632f11c7f63SJim Harris  * @param[in]  controller the handle to the controller object for which to
633f11c7f63SJim Harris  *             allocate the tag.
634f11c7f63SJim Harris  *
635f11c7f63SJim Harris  * @return An unsigned integer representing an available IO tag.
636f11c7f63SJim Harris  * @retval SCI_CONTROLLER_INVALID_IO_TAG This value is returned if there
637f11c7f63SJim Harris  *         are no currently available tags to be allocated.
638f11c7f63SJim Harris  * @retval All return other values indicate a legitimate tag.
639f11c7f63SJim Harris  */
640f11c7f63SJim Harris U16 scic_controller_allocate_io_tag(
641f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller
642f11c7f63SJim Harris );
643f11c7f63SJim Harris 
644f11c7f63SJim Harris /**
645f11c7f63SJim Harris  * @brief This method will free an IO tag to the pool of free IO tags.
646f11c7f63SJim Harris  *        This method provides the SCI Core user more flexibility with
647f11c7f63SJim Harris  *        regards to IO tags.  The user may desire to keep an IO tag after
648f11c7f63SJim Harris  *        an IO request has completed, because they plan on re-using the
649f11c7f63SJim Harris  *        tag for a subsequent IO request.  This method is only legal if
650f11c7f63SJim Harris  *        the tag was allocated via scic_controller_allocate_io_tag().
651f11c7f63SJim Harris  *
652f11c7f63SJim Harris  * @warning
653f11c7f63SJim Harris  *        - IO tags are a protected resource.  It is incumbent upon the
654f11c7f63SJim Harris  *          SCI Core user to ensure that each of the methods that may
655f11c7f63SJim Harris  *          allocate or free available IO tags are handled in a mutually
656f11c7f63SJim Harris  *          exclusive manner.  This method is one of said methods requiring
657f11c7f63SJim Harris  *          proper critical code section protection (e.g. semaphore,
658f11c7f63SJim Harris  *          spin-lock, etc.).
659f11c7f63SJim Harris  *        - If the IO tag for a request was allocated, by the SCI Core user,
660f11c7f63SJim Harris  *          using the scic_controller_allocate_io_tag() method, then it is
661f11c7f63SJim Harris  *          the responsibility of the caller to invoke this method to free
662f11c7f63SJim Harris  *          the tag.
663f11c7f63SJim Harris  *
664f11c7f63SJim Harris  * @param[in]  controller This parameter specifies the handle to the
665f11c7f63SJim Harris  *             controller object for which to free/return the tag.
666f11c7f63SJim Harris  * @param[in]  io_tag This parameter represents the tag to be freed to the
667f11c7f63SJim Harris  *             pool of available tags.
668f11c7f63SJim Harris  *
669f11c7f63SJim Harris  * @return This method returns an indication of whether the tag was
670f11c7f63SJim Harris  *         successfully put back (freed) to the pool of available tags.
671f11c7f63SJim Harris  * @retval SCI_SUCCESS This return value indicates the tag was successfully
672f11c7f63SJim Harris  *         placed into the pool of available IO tags.
673f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied
674f11c7f63SJim Harris  *         tag is not a valid IO tag value.
675f11c7f63SJim Harris  */
676f11c7f63SJim Harris SCI_STATUS scic_controller_free_io_tag(
677f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T  controller,
678f11c7f63SJim Harris    U16                      io_tag
679f11c7f63SJim Harris );
680f11c7f63SJim Harris 
681f11c7f63SJim Harris /**
682f11c7f63SJim Harris  * @brief This method returns the size of the core's scratch RAM.
683f11c7f63SJim Harris  *
684f11c7f63SJim Harris  * @return Size of the scratch RAM in dwords.
685f11c7f63SJim Harris  */
686f11c7f63SJim Harris U32 scic_controller_get_scratch_ram_size(
687f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller
688f11c7f63SJim Harris );
689f11c7f63SJim Harris 
690f11c7f63SJim Harris /**
691f11c7f63SJim Harris  * @brief This method allows the user to read a U32 from the core's
692f11c7f63SJim Harris  *        scratch RAM.
693f11c7f63SJim Harris  *
694f11c7f63SJim Harris  * @param[in]  controller This parameter represents the handle to the
695f11c7f63SJim Harris  *             controller object for which to read scratch RAM.
696f11c7f63SJim Harris  * @param[in]  offset The offset (in dwords) into the scratch RAM.
697f11c7f63SJim Harris  * @param[out] value The location where the read value should be stored.
698f11c7f63SJim Harris  *
699f11c7f63SJim Harris  * @return Indicate if the user specified a valid offset into the
700f11c7f63SJim Harris  *         scratch RAM.
701f11c7f63SJim Harris  * @retval SCI_SUCCESS The scratch RAM was successfully read.
702f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_PARAMETER_VALUE The user specified an
703f11c7f63SJim Harris  *          invalid offset.
704f11c7f63SJim Harris  */
705f11c7f63SJim Harris SCI_STATUS scic_controller_read_scratch_ram_dword(
706f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
707f11c7f63SJim Harris    U32                       offset,
708f11c7f63SJim Harris    U32                     * value
709f11c7f63SJim Harris );
710f11c7f63SJim Harris 
711f11c7f63SJim Harris /**
712f11c7f63SJim Harris  * @brief This method allows the user to write a U32 to the core's
713f11c7f63SJim Harris  *        scratch RAM.
714f11c7f63SJim Harris  *
715f11c7f63SJim Harris  * @param[in]  controller This parameter represents the handle to the
716f11c7f63SJim Harris  *             controller object for which to write scratch RAM.
717f11c7f63SJim Harris  * @param[in]  offset The offset (in dwords) into the scratch RAM.
718f11c7f63SJim Harris  * @param[out] value The value to be written to scratch RAM.
719f11c7f63SJim Harris  *
720f11c7f63SJim Harris  * @return Indicate if the user specified a valid offset into the
721f11c7f63SJim Harris  *         scratch RAM.
722f11c7f63SJim Harris  * @retval SCI_SUCCESS The scratch RAM was successfully written.
723f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_PARAMETER_VALUE The user specified an
724f11c7f63SJim Harris  *          invalid offset.
725f11c7f63SJim Harris  */
726f11c7f63SJim Harris SCI_STATUS scic_controller_write_scratch_ram_dword(
727f11c7f63SJim Harris     SCI_CONTROLLER_HANDLE_T   controller,
728f11c7f63SJim Harris     U32                       offset,
729f11c7f63SJim Harris     U32                       value
730f11c7f63SJim Harris );
731f11c7f63SJim Harris 
732f11c7f63SJim Harris /**
733f11c7f63SJim Harris  * @brief This method allows the user to configure the SCI core into
734f11c7f63SJim Harris  *        either a performance mode or a memory savings mode.
735f11c7f63SJim Harris  *
736f11c7f63SJim Harris  * @param[in]  controller This parameter represents the handle to the
737f11c7f63SJim Harris  *             controller object for which to update the operating
738f11c7f63SJim Harris  *             mode.
739f11c7f63SJim Harris  * @param[in]  mode This parameter specifies the new mode for the
740f11c7f63SJim Harris  *             controller.
741f11c7f63SJim Harris  *
742f11c7f63SJim Harris  * @return Indicate if the user successfully change the operating mode
743f11c7f63SJim Harris  *         of the controller.
744f11c7f63SJim Harris  * @retval SCI_SUCCESS The user successfully updated the mode.
745f11c7f63SJim Harris  */
746f11c7f63SJim Harris SCI_STATUS scic_controller_set_mode(
747f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
748f11c7f63SJim Harris    SCI_CONTROLLER_MODE       mode
749f11c7f63SJim Harris );
750f11c7f63SJim Harris 
751f11c7f63SJim Harris 
752f11c7f63SJim Harris #if !defined(DISABLE_INTERRUPTS)
753f11c7f63SJim Harris /**
754f11c7f63SJim Harris  * @brief This method allows the user to configure the interrupt coalescence.
755f11c7f63SJim Harris  *
756f11c7f63SJim Harris  * @param[in]  controller This parameter represents the handle to the
757f11c7f63SJim Harris  *                controller object for which its interrupt coalesce register
758f11c7f63SJim Harris  *                is overridden.
759f11c7f63SJim Harris  *
760f11c7f63SJim Harris  * @param[in]  coalesce_number Used to control the number of entries in the
761f11c7f63SJim Harris  *                Completion Queue before an interrupt is generated. If the
762f11c7f63SJim Harris  *                number of entries exceed this number, an interrupt will be
763f11c7f63SJim Harris  *                generated. The valid range of the input is [0, 256].
764f11c7f63SJim Harris  *                A setting of 0 results in coalescing being disabled.
765f11c7f63SJim Harris  * @param[in]  coalesce_timeout Timeout value in microseconds. The valid range
766f11c7f63SJim Harris  *                of the input is [0, 2700000] . A setting of 0 is allowed and
767f11c7f63SJim Harris  *                results in no interrupt coalescing timeout.
768f11c7f63SJim Harris  *
769f11c7f63SJim Harris  * @return Indicate if the user successfully set the interrupt coalesce parameters.
770*5014dc95SGordon Bergling  * @retval SCI_SUCCESS The user successfully updated the interrupt coalescence.
771f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_PARAMETER_VALUE The user input value is out of range.
772f11c7f63SJim Harris  */
773f11c7f63SJim Harris SCI_STATUS scic_controller_set_interrupt_coalescence(
774f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T controller,
775f11c7f63SJim Harris    U32                     coalesce_number,
776f11c7f63SJim Harris    U32                     coalesce_timeout
777f11c7f63SJim Harris );
778f11c7f63SJim Harris 
779f11c7f63SJim Harris /**
780f11c7f63SJim Harris  * @brief This method retrieves the interrupt coalescing values
781f11c7f63SJim Harris  *
782f11c7f63SJim Harris  * @param[in] controller This parameter specifies the controller for
783f11c7f63SJim Harris  *            which its interrupt coalescing number is read.
784f11c7f63SJim Harris  *
785f11c7f63SJim Harris  * @param[out] coalesce_number, interrupt coalescing number read from controller.
786f11c7f63SJim Harris  *
787f11c7f63SJim Harris  * @param[out] coalesce_timeout, timeout value in microseconds.
788f11c7f63SJim Harris  *
789f11c7f63SJim Harris  * @return None
790f11c7f63SJim Harris  */
791f11c7f63SJim Harris void scic_controller_get_interrupt_coalescence(
792f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
793f11c7f63SJim Harris    U32                     * coalesce_number,
794f11c7f63SJim Harris    U32                     * coalesce_timeout
795f11c7f63SJim Harris );
796f11c7f63SJim Harris #else // !defined(DISABLE_INTERRUPTS)
797f11c7f63SJim Harris #define scic_controller_set_interrupt_coalescence(controller, num, timeout) \
798f11c7f63SJim Harris         SCI_FAILURE
799f11c7f63SJim Harris #define scic_controller_get_interrupt_coalescence(controller, num, timeout)
800f11c7f63SJim Harris #endif // !defined(DISABLE_INTERRUPTS)
801f11c7f63SJim Harris 
802f11c7f63SJim Harris 
803f11c7f63SJim Harris /**
804f11c7f63SJim Harris  * @brief This method suspend the controller, reinitialize RAMs, then resume
805f11c7f63SJim Harris  *           the controller.
806f11c7f63SJim Harris  *
807f11c7f63SJim Harris  * @param[in] controller This parameter specifies the controller which is transitioning.
808f11c7f63SJim Harris  *
809f11c7f63SJim Harris  * @param[in] restrict_completions This parameter specifies whether the controller should
810f11c7f63SJim Harris  *               ignore completion processing for non-fastpath events.  This will cause
811f11c7f63SJim Harris  *               the completions to be thrown away.
812f11c7f63SJim Harris  *
813f11c7f63SJim Harris  * @return SCI_STATUS The status of controller transition.
814f11c7f63SJim Harris  */
815f11c7f63SJim Harris SCI_STATUS scic_controller_transition(
816f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
817f11c7f63SJim Harris    BOOL                      restrict_completions
818f11c7f63SJim Harris );
819f11c7f63SJim Harris 
820f11c7f63SJim Harris 
821f11c7f63SJim Harris /**
822f11c7f63SJim Harris  * @brief This method suspends the controller.
823f11c7f63SJim Harris  *
824f11c7f63SJim Harris  * @param[in] controller This parameter specifies the controller which is to be suspended.
825f11c7f63SJim Harris  *
826f11c7f63SJim Harris  * @return SCI_STATUS The status of controller suspend.
827f11c7f63SJim Harris  */
828f11c7f63SJim Harris SCI_STATUS scic_controller_suspend(
829f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller
830f11c7f63SJim Harris );
831f11c7f63SJim Harris 
832f11c7f63SJim Harris /**
833f11c7f63SJim Harris  * @brief This method resumes the controller.
834f11c7f63SJim Harris  *
835f11c7f63SJim Harris  * @param[in] controller This parameter specifies the controller which is to be resumed.
836f11c7f63SJim Harris  *
837f11c7f63SJim Harris  * @return SCI_STATUS The status of controller resume.
838f11c7f63SJim Harris  */
839f11c7f63SJim Harris SCI_STATUS scic_controller_resume(
840f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller
841f11c7f63SJim Harris );
842f11c7f63SJim Harris 
843f11c7f63SJim Harris SCI_STATUS scic_controller_get_max_ports(
844f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
845f11c7f63SJim Harris    U8                      * count
846f11c7f63SJim Harris );
847f11c7f63SJim Harris 
848f11c7f63SJim Harris SCI_STATUS scic_controller_get_max_phys(
849f11c7f63SJim Harris    SCI_CONTROLLER_HANDLE_T   controller,
850f11c7f63SJim Harris    U8                      * count
851f11c7f63SJim Harris );
852f11c7f63SJim Harris 
853f11c7f63SJim Harris #ifdef __cplusplus
854f11c7f63SJim Harris }
855f11c7f63SJim Harris #endif // __cplusplus
856f11c7f63SJim Harris 
857f11c7f63SJim Harris #endif // _SCIC_CONTROLLER_H_
858f11c7f63SJim Harris 
859