xref: /freebsd/sys/dev/isci/scil/scif_remote_device.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro 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 #ifndef _SCIF_REMOTE_DEVICE_H_
55f11c7f63SJim Harris #define _SCIF_REMOTE_DEVICE_H_
56f11c7f63SJim Harris 
57f11c7f63SJim Harris /**
58f11c7f63SJim Harris  * @file
59f11c7f63SJim Harris  *
60f11c7f63SJim Harris  * @brief This file contains all of the interface methods that can be called
61f11c7f63SJim Harris  *        by an SCI Framework user on a remote device object.  The
62f11c7f63SJim Harris  *        framework remote device object provides management of resets for
63f11c7f63SJim Harris  *        the remote device, IO thresholds, potentially NCQ tag management,
64f11c7f63SJim Harris  *        etc.
65f11c7f63SJim Harris  */
66f11c7f63SJim Harris 
67f11c7f63SJim Harris #ifdef __cplusplus
68f11c7f63SJim Harris extern "C" {
69f11c7f63SJim Harris #endif // __cplusplus
70f11c7f63SJim Harris 
71f11c7f63SJim Harris #include <dev/isci/scil/sci_types.h>
72f11c7f63SJim Harris #include <dev/isci/scil/sci_status.h>
73f11c7f63SJim Harris #include <dev/isci/scil/intel_sas.h>
74f11c7f63SJim Harris 
75f11c7f63SJim Harris 
76f11c7f63SJim Harris /**
77f11c7f63SJim Harris  * This constant is utilized to inform the user that there is no defined
78f11c7f63SJim Harris  * maximum request queue depth associated with a remote device.
79f11c7f63SJim Harris  */
80f11c7f63SJim Harris #define SCIF_REMOTE_DEVICE_NO_MAX_QUEUE_DEPTH  0xFFFF
81f11c7f63SJim Harris 
82f11c7f63SJim Harris /**
83f11c7f63SJim Harris  * @brief This method simply returns the maximum memory space needed to
84f11c7f63SJim Harris  *        store a remote device object.  The value returned includes enough
85f11c7f63SJim Harris  *        space for the framework and core device objects.
86f11c7f63SJim Harris  *
87f11c7f63SJim Harris  * @return a positive integer value indicating the size (in bytes) of the
88f11c7f63SJim Harris  *         remote device object.
89f11c7f63SJim Harris  */
90f11c7f63SJim Harris U32 scif_remote_device_get_object_size(
91f11c7f63SJim Harris    void
92f11c7f63SJim Harris );
93f11c7f63SJim Harris 
94f11c7f63SJim Harris /**
95f11c7f63SJim Harris  * @brief This method performs the construction common to all device object
96f11c7f63SJim Harris  *        types in the framework.
97f11c7f63SJim Harris  *
98f11c7f63SJim Harris  * @note
99f11c7f63SJim Harris  *      - Remote device objects in the core are a limited resource.  Since
100f11c7f63SJim Harris  *        the framework construction/destruction methods wrap the core, the
101f11c7f63SJim Harris  *        user must ensure that a construct or destruct method is never
102f11c7f63SJim Harris  *        invoked when an existing construct or destruct method is ongoing.
103f11c7f63SJim Harris  *        This method shall be utilized for discovered direct attached
104f11c7f63SJim Harris  *        devices.
105f11c7f63SJim Harris  *      - It isn't necessary to call scif_remote_device_destruct() for
106f11c7f63SJim Harris  *        device objects that have only called this method for construction.
107f11c7f63SJim Harris  *        Once subsequent construction methods have been invoked (e.g.
108f11c7f63SJim Harris  *        scif_remote_device_da_construct()), then destruction should occur.
109f11c7f63SJim Harris  *
110f11c7f63SJim Harris  * @param[in]  domain This parameter specifies the domain in which this
111f11c7f63SJim Harris  *             remote device is contained.
112f11c7f63SJim Harris  * @param[in]  remote_device_memory This parameter specifies the memory
113f11c7f63SJim Harris  *             location into which this method shall construct the new
114f11c7f63SJim Harris  *             framework device object.
115f11c7f63SJim Harris  * @param[out] new_scif_remote_device_handle This parameter specifies the
116f11c7f63SJim Harris  *             handle to be used to communicate with the newly constructed
117f11c7f63SJim Harris  *             framework remote device.
118f11c7f63SJim Harris  *
119f11c7f63SJim Harris  * @return none
120f11c7f63SJim Harris  */
121f11c7f63SJim Harris void scif_remote_device_construct(
122f11c7f63SJim Harris    SCI_DOMAIN_HANDLE_T          domain,
123f11c7f63SJim Harris    void                       * remote_device_memory,
124f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T * new_scif_remote_device_handle
125f11c7f63SJim Harris );
126f11c7f63SJim Harris 
127f11c7f63SJim Harris /**
128f11c7f63SJim Harris  * @brief This method constructs a new framework remote device object.  The
129f11c7f63SJim Harris  *        remote device object shall remember it's counterpart core device
130f11c7f63SJim Harris  *        object as well as the domain in which it is contained.
131f11c7f63SJim Harris  *
132f11c7f63SJim Harris  * @note  Remote device objects in the core are a limited resource.  Since
133f11c7f63SJim Harris  *        the framework construction/destruction methods wrap the core, the
134f11c7f63SJim Harris  *        user must ensure that a construct or destruct method is never
135f11c7f63SJim Harris  *        invoked when an existing construct or destruct method is ongoing.
136f11c7f63SJim Harris  *        This method shall be utilized for discovered direct attached
137f11c7f63SJim Harris  *        devices.
138f11c7f63SJim Harris  *
139f11c7f63SJim Harris  * @pre The user must have previously called scif_remote_device_construct()
140f11c7f63SJim Harris  *
141f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the framework device
142f11c7f63SJim Harris  *             for which to perform direct attached specific construction.
143f11c7f63SJim Harris  * @param[in]  sas_address  This parameter specifies the SAS address of the
144f11c7f63SJim Harris  *             remote device object being constructed.
145f11c7f63SJim Harris  * @param[in]  protocols This parameter specifies the protocols supported
146f11c7f63SJim Harris  *             by the remote device to be constructed.
147f11c7f63SJim Harris  *
148f11c7f63SJim Harris  * @return Indicate if the remote device was successfully constructed.
149f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if the remote device was
150f11c7f63SJim Harris  *         successfully constructed.
151f11c7f63SJim Harris  * @retval SCI_FAILURE_DEVICE_EXISTS Returned if the device has already
152f11c7f63SJim Harris  *         been constructed.
153f11c7f63SJim Harris  * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if
154f11c7f63SJim Harris  *         the core controller associated with the supplied parameters
155f11c7f63SJim Harris  *         is unable to support additional remote devices.
156f11c7f63SJim Harris  */
157f11c7f63SJim Harris SCI_STATUS scif_remote_device_da_construct(
158f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T                   remote_device,
159f11c7f63SJim Harris    SCI_SAS_ADDRESS_T                          * sas_address,
160f11c7f63SJim Harris    SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T * protocols
161f11c7f63SJim Harris );
162f11c7f63SJim Harris 
163f11c7f63SJim Harris /**
164f11c7f63SJim Harris  * @brief This method constructs a new framework remote device object.  The
165f11c7f63SJim Harris  *        remote device object shall remember it's counterpart core device
166f11c7f63SJim Harris  *        object as well as the domain in which it is contained.
167f11c7f63SJim Harris  *
168f11c7f63SJim Harris  * @pre The user must have previously called scif_remote_device_construct()
169f11c7f63SJim Harris  *
170f11c7f63SJim Harris  * @note  Remote device objects in the core are a limited resource.  Since
171f11c7f63SJim Harris  *        the framework construction/destruction methods wrap the core, the
172f11c7f63SJim Harris  *        user must ensure that a construct or destruct method is never
173f11c7f63SJim Harris  *        invoked when an existing construct or destruct method is ongoing.
174f11c7f63SJim Harris  *        This method shall be utilized for discovered expander attached
175f11c7f63SJim Harris  *        devices.
176f11c7f63SJim Harris  *
177f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the framework device
178f11c7f63SJim Harris  *             for which to perform expander specific construction.
179f11c7f63SJim Harris  * @param[in]  containing_device This parameter specifies the remote
180f11c7f63SJim Harris  *             device (i.e. an expander) that contains the device being
181f11c7f63SJim Harris  *             constructed.
182f11c7f63SJim Harris  * @param[in]  smp_response This parameter specifies the SMP_RESPONSE_DISCOVER
183f11c7f63SJim Harris  *             associated with the remote device being constructed.
184f11c7f63SJim Harris  *
185f11c7f63SJim Harris  * @return Indicate if the remote device was successfully constructed.
186f11c7f63SJim Harris  * @retval SCI_SUCCESS This value is returned if the remote device was
187f11c7f63SJim Harris  *         successfully constructed.
188f11c7f63SJim Harris  * @retval SCI_FAILURE_DEVICE_EXISTS Returned if the device has already
189f11c7f63SJim Harris  *         been constructed.
190f11c7f63SJim Harris  * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if
191f11c7f63SJim Harris  *         the core controller associated with the supplied parameters
192f11c7f63SJim Harris  *         is unable to support additional remote devices.
193f11c7f63SJim Harris  */
194f11c7f63SJim Harris SCI_STATUS scif_remote_device_ea_construct(
195f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T   remote_device,
196f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T   containing_device,
197f11c7f63SJim Harris    SMP_RESPONSE_DISCOVER_T    * smp_response
198f11c7f63SJim Harris );
199f11c7f63SJim Harris 
200f11c7f63SJim Harris 
201f11c7f63SJim Harris /**
202f11c7f63SJim Harris  * @brief This method is utilized to free up a framework's remote
203f11c7f63SJim Harris  *        device object.
204f11c7f63SJim Harris  *
205f11c7f63SJim Harris  * @note  Remote device objects in the core are a limited resource.  Since
206f11c7f63SJim Harris  *        the framework construction/destruction methods wrap the core, the
207f11c7f63SJim Harris  *        user must ensure that a construct or destruct method is never
208f11c7f63SJim Harris  *        invoked when an existing construct or destruct method is ongoing.
209f11c7f63SJim Harris  *
210f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the remote device to be
211f11c7f63SJim Harris  *             destructed.
212f11c7f63SJim Harris  *
213f11c7f63SJim Harris  * @return The return value shall indicate if the device was successfully
214f11c7f63SJim Harris  *         destructed or if some failure occurred.
215f11c7f63SJim Harris  * @retval SCI_STATUS This value is returned if the device is successfully
216f11c7f63SJim Harris  *         destructed.
217f11c7f63SJim Harris  * @retval SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the
218f11c7f63SJim Harris  *         supplied device isn't valid (e.g. it's already been destructed,
219f11c7f63SJim Harris  *         the handle isn't valid, etc.).
220f11c7f63SJim Harris  */
221f11c7f63SJim Harris SCI_STATUS scif_remote_device_destruct(
222f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
223f11c7f63SJim Harris );
224f11c7f63SJim Harris 
225f11c7f63SJim Harris /**
226f11c7f63SJim Harris  * @brief This method simply returns the SCI Core object handle that is
227f11c7f63SJim Harris  *        associated with the supplied SCI Framework object.
228f11c7f63SJim Harris  *
229f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the framework device
230f11c7f63SJim Harris  *             for which to return the associated core remote device.
231f11c7f63SJim Harris  *
232f11c7f63SJim Harris  * @return This method returns a handle to the core remote device object
233f11c7f63SJim Harris  *         associated with the framework remote device object.
234f11c7f63SJim Harris  * @retval SCI_INVALID_HANDLE This return value indicates that the SCI Core
235f11c7f63SJim Harris  *         remote device handle for the supplied framework device is invalid.
236f11c7f63SJim Harris  */
237f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device_get_scic_handle(
238f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
239f11c7f63SJim Harris );
240f11c7f63SJim Harris 
241f11c7f63SJim Harris /**
242f11c7f63SJim Harris  * @brief This method returns the maximum queue depth supported for the
243f11c7f63SJim Harris  *        supplied target by this SCI Framework impementation.
244f11c7f63SJim Harris  *
245f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the framework
246f11c7f63SJim Harris  *             device for which to return the maximum queue depth.
247f11c7f63SJim Harris  *
248f11c7f63SJim Harris  * @return This method returns a value indicating the maximum number of
249f11c7f63SJim Harris  *         IO requests that can be outstanding for the target at any
250f11c7f63SJim Harris  *         point in time.
251f11c7f63SJim Harris  * @retval SCIF_REMOTE_DEVICE_NO_MAX_QUEUE_DEPTH This value is returned
252f11c7f63SJim Harris  *         when there is no defined maximum queue depth for the target.
253f11c7f63SJim Harris  */
254f11c7f63SJim Harris U16 scif_remote_device_get_max_queue_depth(
255f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
256f11c7f63SJim Harris );
257f11c7f63SJim Harris 
258f11c7f63SJim Harris /**
259f11c7f63SJim Harris  * @brief This method will return the handle to the parent device of the
260f11c7f63SJim Harris  *        remote device.
261f11c7f63SJim Harris  *
262f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the device for which
263f11c7f63SJim Harris  *             to return the parent device.
264f11c7f63SJim Harris  * @param[out] containing_device This parameter specifies the device
265f11c7f63SJim Harris  *             handle, from the remote device object, which indicate
266f11c7f63SJim Harris  *             the parent device of the supplied remote_device.
267f11c7f63SJim Harris  *
268f11c7f63SJim Harris  * @return none
269f11c7f63SJim Harris  */
270f11c7f63SJim Harris SCI_STATUS scif_remote_device_get_containing_device(
271f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T          remote_device,
272f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T        * containing_device
273f11c7f63SJim Harris );
274f11c7f63SJim Harris 
275f11c7f63SJim Harris /**
276f11c7f63SJim Harris  * @brief This method returns the number of IO currently started
277f11c7f63SJim Harris  *        to the supplied target.  It does not include task
278f11c7f63SJim Harris  *        management requests.
279f11c7f63SJim Harris  *
280f11c7f63SJim Harris  * @param[in]  remote_device This parameter specifies the framework
281f11c7f63SJim Harris  *             device for which to return the number of started IO.
282f11c7f63SJim Harris  *
283f11c7f63SJim Harris  * @return This method returns a value indicating the number of started
284f11c7f63SJim Harris  *         IO requests.
285f11c7f63SJim Harris  */
286f11c7f63SJim Harris U32 scif_remote_device_get_started_io_count(
287f11c7f63SJim Harris    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
288f11c7f63SJim Harris );
289f11c7f63SJim Harris 
290f11c7f63SJim Harris #ifdef __cplusplus
291f11c7f63SJim Harris }
292f11c7f63SJim Harris #endif // __cplusplus
293f11c7f63SJim Harris 
294f11c7f63SJim Harris #endif // _SCIF_REMOTE_DEVICE_H_
295f11c7f63SJim Harris 
296