]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/dev/isci/scil/scif_remote_device.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / dev / isci / scil / scif_remote_device.h
1 /*-
2  * This file is provided under a dual BSD/GPLv2 license.  When using or
3  * redistributing this file, you may do so under either license.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of version 2 of the GNU General Public License as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21  * The full GNU General Public License is included in this distribution
22  * in the file called LICENSE.GPL.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
33  *   * Redistributions of source code must retain the above copyright
34  *     notice, this list of conditions and the following disclaimer.
35  *   * Redistributions in binary form must reproduce the above copyright
36  *     notice, this list of conditions and the following disclaimer in
37  *     the documentation and/or other materials provided with the
38  *     distribution.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51  *
52  * $FreeBSD$
53  */
54 #ifndef _SCIF_REMOTE_DEVICE_H_
55 #define _SCIF_REMOTE_DEVICE_H_
56
57 /**
58  * @file
59  *
60  * @brief This file contains all of the interface methods that can be called
61  *        by an SCI Framework user on a remote device object.  The
62  *        framework remote device object provides management of resets for
63  *        the remote device, IO thresholds, potentially NCQ tag management,
64  *        etc.
65  */
66
67 #ifdef __cplusplus
68 extern "C" {
69 #endif // __cplusplus
70
71 #include <dev/isci/scil/sci_types.h>
72 #include <dev/isci/scil/sci_status.h>
73 #include <dev/isci/scil/intel_sas.h>
74
75
76 /**
77  * This constant is utilized to inform the user that there is no defined
78  * maximum request queue depth associated with a remote device.
79  */
80 #define SCIF_REMOTE_DEVICE_NO_MAX_QUEUE_DEPTH  0xFFFF
81
82 /**
83  * @brief This method simply returns the maximum memory space needed to
84  *        store a remote device object.  The value returned includes enough
85  *        space for the framework and core device objects.
86  *
87  * @return a positive integer value indicating the size (in bytes) of the
88  *         remote device object.
89  */
90 U32 scif_remote_device_get_object_size(
91    void
92 );
93
94 /**
95  * @brief This method performs the construction common to all device object
96  *        types in the framework.
97  *
98  * @note
99  *      - Remote device objects in the core are a limited resource.  Since
100  *        the framework construction/destruction methods wrap the core, the
101  *        user must ensure that a construct or destruct method is never
102  *        invoked when an existing construct or destruct method is ongoing.
103  *        This method shall be utilized for discovered direct attached
104  *        devices.
105  *      - It isn't necessary to call scif_remote_device_destruct() for
106  *        device objects that have only called this method for construction.
107  *        Once subsequent construction methods have been invoked (e.g.
108  *        scif_remote_device_da_construct()), then destruction should occur.
109  *
110  * @param[in]  domain This parameter specifies the domain in which this
111  *             remote device is contained.
112  * @param[in]  remote_device_memory This parameter specifies the memory
113  *             location into which this method shall construct the new
114  *             framework device object.
115  * @param[out] new_scif_remote_device_handle This parameter specifies the
116  *             handle to be used to communicate with the newly constructed
117  *             framework remote device.
118  *
119  * @return none
120  */
121 void scif_remote_device_construct(
122    SCI_DOMAIN_HANDLE_T          domain,
123    void                       * remote_device_memory,
124    SCI_REMOTE_DEVICE_HANDLE_T * new_scif_remote_device_handle
125 );
126
127 /**
128  * @brief This method constructs a new framework remote device object.  The
129  *        remote device object shall remember it's counterpart core device
130  *        object as well as the domain in which it is contained.
131  *
132  * @note  Remote device objects in the core are a limited resource.  Since
133  *        the framework construction/destruction methods wrap the core, the
134  *        user must ensure that a construct or destruct method is never
135  *        invoked when an existing construct or destruct method is ongoing.
136  *        This method shall be utilized for discovered direct attached
137  *        devices.
138  *
139  * @pre The user must have previously called scif_remote_device_construct()
140  *
141  * @param[in]  remote_device This parameter specifies the framework device
142  *             for which to perform direct attached specific construction.
143  * @param[in]  sas_address  This parameter specifies the SAS address of the
144  *             remote device object being constructed.
145  * @param[in]  protocols This parameter specifies the protocols supported
146  *             by the remote device to be constructed.
147  *
148  * @return Indicate if the remote device was successfully constructed.
149  * @retval SCI_SUCCESS This value is returned if the remote device was
150  *         successfully constructed.
151  * @retval SCI_FAILURE_DEVICE_EXISTS Returned if the device has already
152  *         been constructed.
153  * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if
154  *         the core controller associated with the supplied parameters
155  *         is unable to support additional remote devices.
156  */
157 SCI_STATUS scif_remote_device_da_construct(
158    SCI_REMOTE_DEVICE_HANDLE_T                   remote_device,
159    SCI_SAS_ADDRESS_T                          * sas_address,
160    SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T * protocols
161 );
162
163 /**
164  * @brief This method constructs a new framework remote device object.  The
165  *        remote device object shall remember it's counterpart core device
166  *        object as well as the domain in which it is contained.
167  *
168  * @pre The user must have previously called scif_remote_device_construct()
169  *
170  * @note  Remote device objects in the core are a limited resource.  Since
171  *        the framework construction/destruction methods wrap the core, the
172  *        user must ensure that a construct or destruct method is never
173  *        invoked when an existing construct or destruct method is ongoing.
174  *        This method shall be utilized for discovered expander attached
175  *        devices.
176  *
177  * @param[in]  remote_device This parameter specifies the framework device
178  *             for which to perform expander specific construction.
179  * @param[in]  containing_device This parameter specifies the remote
180  *             device (i.e. an expander) that contains the device being
181  *             constructed.
182  * @param[in]  smp_response This parameter specifies the SMP_RESPONSE_DISCOVER
183  *             associated with the remote device being constructed.
184  *
185  * @return Indicate if the remote device was successfully constructed.
186  * @retval SCI_SUCCESS This value is returned if the remote device was
187  *         successfully constructed.
188  * @retval SCI_FAILURE_DEVICE_EXISTS Returned if the device has already
189  *         been constructed.
190  * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES This value is returned if
191  *         the core controller associated with the supplied parameters
192  *         is unable to support additional remote devices.
193  */
194 SCI_STATUS scif_remote_device_ea_construct(
195    SCI_REMOTE_DEVICE_HANDLE_T   remote_device,
196    SCI_REMOTE_DEVICE_HANDLE_T   containing_device,
197    SMP_RESPONSE_DISCOVER_T    * smp_response
198 );
199
200
201 /**
202  * @brief This method is utilized to free up a framework's remote
203  *        device object.
204  *
205  * @note  Remote device objects in the core are a limited resource.  Since
206  *        the framework construction/destruction methods wrap the core, the
207  *        user must ensure that a construct or destruct method is never
208  *        invoked when an existing construct or destruct method is ongoing.
209  *
210  * @param[in]  remote_device This parameter specifies the remote device to be
211  *             destructed.
212  *
213  * @return The return value shall indicate if the device was successfully
214  *         destructed or if some failure occurred.
215  * @retval SCI_STATUS This value is returned if the device is successfully
216  *         destructed.
217  * @retval SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the
218  *         supplied device isn't valid (e.g. it's already been destructed,
219  *         the handle isn't valid, etc.).
220  */
221 SCI_STATUS scif_remote_device_destruct(
222    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
223 );
224
225 /**
226  * @brief This method simply returns the SCI Core object handle that is
227  *        associated with the supplied SCI Framework object.
228  *
229  * @param[in]  remote_device This parameter specifies the framework device
230  *             for which to return the associated core remote device.
231  *
232  * @return This method returns a handle to the core remote device object
233  *         associated with the framework remote device object.
234  * @retval SCI_INVALID_HANDLE This return value indicates that the SCI Core
235  *         remote device handle for the supplied framework device is invalid.
236  */
237 SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device_get_scic_handle(
238    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
239 );
240
241 /**
242  * @brief This method returns the maximum queue depth supported for the
243  *        supplied target by this SCI Framework impementation.
244  *
245  * @param[in]  remote_device This parameter specifies the framework
246  *             device for which to return the maximum queue depth.
247  *
248  * @return This method returns a value indicating the maximum number of
249  *         IO requests that can be outstanding for the target at any
250  *         point in time.
251  * @retval SCIF_REMOTE_DEVICE_NO_MAX_QUEUE_DEPTH This value is returned
252  *         when there is no defined maximum queue depth for the target.
253  */
254 U16 scif_remote_device_get_max_queue_depth(
255    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
256 );
257
258 /**
259  * @brief This method will return the handle to the parent device of the
260  *        remote device.
261  *
262  * @param[in]  remote_device This parameter specifies the device for which
263  *             to return the parent device.
264  * @param[out] containing_device This parameter specifies the device
265  *             handle, from the remote device object, which indicate
266  *             the parent device of the supplied remote_device.
267  *
268  * @return none
269  */
270 SCI_STATUS scif_remote_device_get_containing_device(
271    SCI_REMOTE_DEVICE_HANDLE_T          remote_device,
272    SCI_REMOTE_DEVICE_HANDLE_T        * containing_device
273 );
274
275 /**
276  * @brief This method returns the number of IO currently started
277  *        to the supplied target.  It does not include task
278  *        management requests.
279  *
280  * @param[in]  remote_device This parameter specifies the framework
281  *             device for which to return the number of started IO.
282  *
283  * @return This method returns a value indicating the number of started
284  *         IO requests.
285  */
286 U32 scif_remote_device_get_started_io_count(
287    SCI_REMOTE_DEVICE_HANDLE_T  remote_device
288 );
289
290 #ifdef __cplusplus
291 }
292 #endif // __cplusplus
293
294 #endif // _SCIF_REMOTE_DEVICE_H_
295