10Sstevel@tonic-gate/*-
20Sstevel@tonic-gate * This file is provided under a dual BSD/GPLv2 license.  When using or
30Sstevel@tonic-gate * redistributing this file, you may do so under either license.
40Sstevel@tonic-gate *
50Sstevel@tonic-gate * GPL LICENSE SUMMARY
60Sstevel@tonic-gate *
70Sstevel@tonic-gate * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * This program is free software; you can redistribute it and/or modify
100Sstevel@tonic-gate * it under the terms of version 2 of the GNU General Public License as
110Sstevel@tonic-gate * published by the Free Software Foundation.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * This program is distributed in the hope that it will be useful, but
140Sstevel@tonic-gate * WITHOUT ANY WARRANTY; without even the implied warranty of
150Sstevel@tonic-gate * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
160Sstevel@tonic-gate * General Public License for more details.
170Sstevel@tonic-gate *
180Sstevel@tonic-gate * You should have received a copy of the GNU General Public License
190Sstevel@tonic-gate * along with this program; if not, write to the Free Software
200Sstevel@tonic-gate * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
210Sstevel@tonic-gate * The full GNU General Public License is included in this distribution
220Sstevel@tonic-gate * in the file called LICENSE.GPL.
230Sstevel@tonic-gate *
240Sstevel@tonic-gate * BSD LICENSE
250Sstevel@tonic-gate *
260Sstevel@tonic-gate * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
270Sstevel@tonic-gate * All rights reserved.
280Sstevel@tonic-gate *
290Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
300Sstevel@tonic-gate * modification, are permitted provided that the following conditions
310Sstevel@tonic-gate * are met:
320Sstevel@tonic-gate *
330Sstevel@tonic-gate *   * Redistributions of source code must retain the above copyright
340Sstevel@tonic-gate *     notice, this list of conditions and the following disclaimer.
350Sstevel@tonic-gate *   * Redistributions in binary form must reproduce the above copyright
360Sstevel@tonic-gate *     notice, this list of conditions and the following disclaimer in
370Sstevel@tonic-gate *     the documentation and/or other materials provided with the
380Sstevel@tonic-gate *     distribution.
390Sstevel@tonic-gate *
400Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
410Sstevel@tonic-gate * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
420Sstevel@tonic-gate * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
430Sstevel@tonic-gate * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
440Sstevel@tonic-gate * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
450Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
460Sstevel@tonic-gate * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
470Sstevel@tonic-gate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
480Sstevel@tonic-gate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
490Sstevel@tonic-gate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
500Sstevel@tonic-gate * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
510Sstevel@tonic-gate *
520Sstevel@tonic-gate * $FreeBSD: releng/10.2/sys/dev/isci/scil/scif_remote_device.h 231136 2012-02-07 17:43:58Z jimharris $
530Sstevel@tonic-gate */
540Sstevel@tonic-gate#ifndef _SCIF_REMOTE_DEVICE_H_
550Sstevel@tonic-gate#define _SCIF_REMOTE_DEVICE_H_
560Sstevel@tonic-gate
570Sstevel@tonic-gate/**
580Sstevel@tonic-gate * @file
590Sstevel@tonic-gate *
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
68extern "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 */
90U32 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 */
121void 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 */
157SCI_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 */
194SCI_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 */
221SCI_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 */
237SCI_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 */
254U16 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 */
270SCI_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 */
286U32 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
296