1/*-
2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3 *
4 * This file is provided under a dual BSD/GPLv2 license.  When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23 * The full GNU General Public License is included in this distribution
24 * in the file called LICENSE.GPL.
25 *
26 * BSD LICENSE
27 *
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 *
35 *   * Redistributions of source code must retain the above copyright
36 *     notice, this list of conditions and the following disclaimer.
37 *   * Redistributions in binary form must reproduce the above copyright
38 *     notice, this list of conditions and the following disclaimer in
39 *     the documentation and/or other materials provided with the
40 *     distribution.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 *
54 * $FreeBSD$
55 */
56#ifndef _SCI_STATUS_H_
57#define _SCI_STATUS_H_
58
59/**
60 * @file
61 *
62 * @brief This file contains all of the return status codes utilized across
63 *        the various sub-components in SCI.
64 */
65
66#ifdef __cplusplus
67extern "C" {
68#endif // __cplusplus
69
70/**
71 * @enum  _SCI_STATUS
72 * @brief This is the general return status enumeration for non-IO, non-task
73 *        management related SCI interface methods.
74 */
75typedef enum _SCI_STATUS
76{
77   /**
78    * This member indicates successful completion.
79    */
80   SCI_SUCCESS = 0,
81
82   /**
83    * This value indicates that the calling method completed successfully,
84    * but that the IO may have completed before having it's start method
85    * invoked.  This occurs during SAT translation for requests that do
86    * not require an IO to the target or for any other requests that may
87    * be completed without having to submit IO.
88    */
89   SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
90
91   /**
92    *  This Value indicates that the SCU hardware returned an early response
93    *  because the io request specified more data than is returned by the
94    *  target device (mode pages, inquiry data, etc.). The completion routine
95    *  will handle this case to get the actual number of bytes transferred.
96    */
97   SCI_SUCCESS_IO_DONE_EARLY,
98
99   /**
100    * This member indicates that the object for which a state change is
101    * being requested is already in said state.
102    */
103   SCI_WARNING_ALREADY_IN_STATE,
104
105   /**
106    * This member indicates interrupt coalescence timer may cause SAS
107    * specification compliance issues (i.e. SMP target mode response
108    * frames must be returned within 1.9 milliseconds).
109    */
110   SCI_WARNING_TIMER_CONFLICT,
111
112   /**
113    * This field indicates a sequence of action is not completed yet. Mostly,
114    * this status is used when multiple ATA commands are needed in a SATI translation.
115    */
116   SCI_WARNING_SEQUENCE_INCOMPLETE,
117
118   /**
119    * This member indicates that there was a general failure.
120    */
121   SCI_FAILURE,
122
123   /**
124    * This member indicates that the SCI implementation is unable to complete
125    * an operation due to a critical flaw the prevents any further operation
126    * (i.e. an invalid pointer).
127    */
128   SCI_FATAL_ERROR,
129
130   /**
131    * This member indicates the calling function failed, because the state
132    * of the controller is in a state that prevents successful completion.
133    */
134   SCI_FAILURE_INVALID_STATE,
135
136   /**
137    * This member indicates the calling function failed, because there is
138    * insufficient resources/memory to complete the request.
139    */
140   SCI_FAILURE_INSUFFICIENT_RESOURCES,
141
142   /**
143    * This member indicates the calling function failed, because the
144    * controller object required for the operation can't be located.
145    */
146   SCI_FAILURE_CONTROLLER_NOT_FOUND,
147
148   /**
149    * This member indicates the calling function failed, because the
150    * discovered controller type is not supported by the library.
151    */
152   SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE,
153
154   /**
155    * This member indicates the calling function failed, because the
156    * requested initialization data version isn't supported.
157    */
158   SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION,
159
160   /**
161    * This member indicates the calling function failed, because the
162    * requested configuration of SAS Phys into SAS Ports is not supported.
163    */
164   SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION,
165
166   /**
167    * This member indicates the calling function failed, because the
168    * requested protocol is not supported by the remote device, port,
169    * or controller.
170    */
171   SCI_FAILURE_UNSUPPORTED_PROTOCOL,
172
173   /**
174    * This member indicates the calling function failed, because the
175    * requested information type is not supported by the SCI implementation.
176    */
177   SCI_FAILURE_UNSUPPORTED_INFORMATION_TYPE,
178
179   /**
180    * This member indicates the calling function failed, because the
181    * device already exists.
182    */
183   SCI_FAILURE_DEVICE_EXISTS,
184
185   /**
186    * This member indicates the calling function failed, because adding
187    * a phy to the object is not possible.
188    */
189   SCI_FAILURE_ADDING_PHY_UNSUPPORTED,
190
191   /**
192    * This member indicates the calling function failed, because the
193    * requested information type is not supported by the SCI implementation.
194    */
195   SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD,
196
197   /**
198    * This member indicates the calling function failed, because the SCI
199    * implementation does not support the supplied time limit.
200    */
201   SCI_FAILURE_UNSUPPORTED_TIME_LIMIT,
202
203   /**
204    * This member indicates the calling method failed, because the SCI
205    * implementation does not contain the specified Phy.
206    */
207   SCI_FAILURE_INVALID_PHY,
208
209   /**
210    * This member indicates the calling method failed, because the SCI
211    * implementation does not contain the specified Port.
212    */
213   SCI_FAILURE_INVALID_PORT,
214
215    /**
216     * This member indicates the calling method was partly successful
217     * The port was reset but not all phys in port are operational
218     */
219    SCI_FAILURE_RESET_PORT_PARTIAL_SUCCESS,
220
221    /**
222     * This member indicates that calling method failed
223     * The port reset did not complete because none of the phys are operational
224     */
225    SCI_FAILURE_RESET_PORT_FAILURE,
226
227   /**
228    * This member indicates the calling method failed, because the SCI
229    * implementation does not contain the specified remote device.
230    */
231   SCI_FAILURE_INVALID_REMOTE_DEVICE,
232
233   /**
234    * This member indicates the calling method failed, because the remote
235    * device is in a bad state and requires a reset.
236    */
237   SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
238
239   /**
240    * This member indicates the calling method failed, because the SCI
241    * implementation does not contain or support the specified IO tag.
242    */
243   SCI_FAILURE_INVALID_IO_TAG,
244
245   /**
246    * This member indicates that the operation failed and the user should
247    * check the response data associated with the IO.
248    */
249   SCI_FAILURE_IO_RESPONSE_VALID,
250
251   /**
252    * This member indicates that the operation failed, the failure is
253    * controller implementation specific, and the response data associated
254    * with the request is not valid.  You can query for the controller
255    * specific error information via scic_request_get_controller_status()
256    */
257   SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
258
259   /**
260    * This member indicated that the operation failed because the
261    * user requested this IO to be terminated.
262    */
263   SCI_FAILURE_IO_TERMINATED,
264
265   /**
266    * This member indicates that the operation failed and the associated
267    * request requires a SCSI abort task to be sent to the target.
268    */
269   SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
270
271   /**
272    * This member indicates that the operation failed because the supplied
273    * device could not be located.
274    */
275   SCI_FAILURE_DEVICE_NOT_FOUND,
276
277   /**
278    * This member indicates that the operation failed because the
279    * objects association is required and is not correctly set.
280    */
281   SCI_FAILURE_INVALID_ASSOCIATION,
282
283   /**
284    * This member indicates that the operation failed, because a timeout
285    * occurred.
286    */
287   SCI_FAILURE_TIMEOUT,
288
289   /**
290    * This member indicates that the operation failed, because the user
291    * specified a value that is either invalid or not supported.
292    */
293   SCI_FAILURE_INVALID_PARAMETER_VALUE,
294
295   /**
296    * This value indicates that the operation failed, because the number
297    * of messages (MSI-X) is not supported.
298    */
299   SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT,
300
301   /**
302    * This value indicates that the method failed due to a lack of
303    * available NCQ tags.
304    */
305   SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
306
307   /**
308    * This value indicates that a protocol violation has occurred on the
309    * link.
310    */
311   SCI_FAILURE_PROTOCOL_VIOLATION,
312
313   /**
314    * This value indicates a failure condition that retry may help to clear.
315    */
316   SCI_FAILURE_RETRY_REQUIRED,
317
318   /**
319    * This field indicates the retry limit was reached when a retry is attempted
320    */
321   SCI_FAILURE_RETRY_LIMIT_REACHED,
322
323   /**
324    * This member indicates the calling method was partly successful.
325    * Mostly, this status is used when a LUN_RESET issued to an expander attached
326    * STP device in READY NCQ substate needs to have RNC suspended/resumed
327    * before posting TC.
328    */
329   SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS,
330
331   /**
332    * This field indicates an illegal phy connection based on the routing attribute
333    * of both expander phy attached to each other.
334    */
335   SCI_FAILURE_ILLEGAL_ROUTING_ATTRIBUTE_CONFIGURATION,
336
337   /**
338    * This field indicates a CONFIG ROUTE INFO command has a response with function result
339    * INDEX DOES NOT EXIST, usually means exceeding max route index.
340    */
341   SCI_FAILURE_EXCEED_MAX_ROUTE_INDEX,
342
343   /**
344    * This value indicates that an unsupported PCI device ID has been
345    * specified.  This indicates that attempts to invoke
346    * scic_library_allocate_controller() will fail.
347    */
348   SCI_FAILURE_UNSUPPORTED_PCI_DEVICE_ID
349
350} SCI_STATUS;
351
352/**
353 * @enum  _SCI_IO_STATUS
354 * @brief This enumeration depicts all of the possible IO completion
355 *        status values.  Each value in this enumeration maps directly to
356 *        a value in the SCI_STATUS enumeration.  Please refer to that
357 *        enumeration for detailed comments concerning what the status
358 *        represents.
359 * @todo Add the API to retrieve the SCU status from the core.
360 * @todo Check to see that the following status are properly handled:
361 *       - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL
362 *       - SCI_IO_FAILURE_INVALID_IO_TAG
363 */
364typedef enum _SCI_IO_STATUS
365{
366   SCI_IO_SUCCESS                         = SCI_SUCCESS,
367   SCI_IO_FAILURE                         = SCI_FAILURE,
368   SCI_IO_SUCCESS_COMPLETE_BEFORE_START   = SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
369   SCI_IO_SUCCESS_IO_DONE_EARLY           = SCI_SUCCESS_IO_DONE_EARLY,
370   SCI_IO_FAILURE_INVALID_STATE           = SCI_FAILURE_INVALID_STATE,
371   SCI_IO_FAILURE_INSUFFICIENT_RESOURCES  = SCI_FAILURE_INSUFFICIENT_RESOURCES,
372   SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL    = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
373   SCI_IO_FAILURE_RESPONSE_VALID          = SCI_FAILURE_IO_RESPONSE_VALID,
374   SCI_IO_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
375   SCI_IO_FAILURE_TERMINATED              = SCI_FAILURE_IO_TERMINATED,
376   SCI_IO_FAILURE_REQUIRES_SCSI_ABORT     = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
377   SCI_IO_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
378   SCI_IO_FAILURE_NO_NCQ_TAG_AVAILABLE    = SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
379   SCI_IO_FAILURE_PROTOCOL_VIOLATION      = SCI_FAILURE_PROTOCOL_VIOLATION,
380
381   SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
382
383   SCI_IO_FAILURE_RETRY_REQUIRED      = SCI_FAILURE_RETRY_REQUIRED,
384   SCI_IO_FAILURE_RETRY_LIMIT_REACHED = SCI_FAILURE_RETRY_LIMIT_REACHED,
385   SCI_IO_FAILURE_INVALID_REMOTE_DEVICE = SCI_FAILURE_INVALID_REMOTE_DEVICE
386} SCI_IO_STATUS;
387
388/**
389 * @enum  _SCI_TASK_STATUS
390 * @brief This enumeration depicts all of the possible task completion
391 *        status values.  Each value in this enumeration maps directly to
392 *        a value in the SCI_STATUS enumeration.  Please refer to that
393 *        enumeration for detailed comments concerning what the status
394 *        represents.
395 * @todo Check to see that the following status are properly handled:
396 */
397typedef enum _SCI_TASK_STATUS
398{
399   SCI_TASK_SUCCESS                         = SCI_SUCCESS,
400   SCI_TASK_FAILURE                         = SCI_FAILURE,
401   SCI_TASK_FAILURE_INVALID_STATE           = SCI_FAILURE_INVALID_STATE,
402   SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES  = SCI_FAILURE_INSUFFICIENT_RESOURCES,
403   SCI_TASK_FAILURE_UNSUPPORTED_PROTOCOL    = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
404   SCI_TASK_FAILURE_INVALID_TAG             = SCI_FAILURE_INVALID_IO_TAG,
405   SCI_TASK_FAILURE_RESPONSE_VALID          = SCI_FAILURE_IO_RESPONSE_VALID,
406   SCI_TASK_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
407   SCI_TASK_FAILURE_TERMINATED              = SCI_FAILURE_IO_TERMINATED,
408   SCI_TASK_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
409
410   SCI_TASK_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
411   SCI_TASK_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS = SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS
412
413} SCI_TASK_STATUS;
414
415#ifdef __cplusplus
416}
417#endif // __cplusplus
418
419#endif // _SCI_STATUS_H_
420
421