xref: /freebsd/sys/dev/isci/scil/scif_sas_request.h (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
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 _SCIF_SAS_REQUEST_H_
57 #define _SCIF_SAS_REQUEST_H_
58 
59 /**
60  * @file
61  *
62  * @brief This file contains the protected interface structures, constants,
63  *        and methods for the SCIF_SAS_REQUEST object.  This object provides
64  *        the common data and behavior to SAS IO and task management
65  *        request types.
66  */
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif // __cplusplus
71 
72 #include <dev/isci/scil/sati_translator_sequence.h>
73 #include <dev/isci/scil/sci_types.h>
74 #include <dev/isci/scil/sci_status.h>
75 #include <dev/isci/scil/sci_fast_list.h>
76 #include <dev/isci/scil/sci_base_request.h>
77 
78 #define SCIF_SAS_RESPONSE_DATA_LENGTH 120
79 
80 struct SCIF_SAS_CONTROLLER;
81 struct SCIF_SAS_REMOTE_DEVICE;
82 struct SCIF_SAS_TASK_REQUEST;
83 struct SCIF_SAS_REQUEST;
84 
85 typedef SCI_STATUS (*SCIF_SAS_REQUEST_COMPLETION_HANDLER_T)(
86    struct SCIF_SAS_CONTROLLER *,
87    struct SCIF_SAS_REMOTE_DEVICE *,
88    struct SCIF_SAS_REQUEST *,
89    SCI_STATUS *
90 );
91 
92 /**
93  * @struct SCIF_SAS_STP_REQUEST
94  *
95  * @brief This structure contains all of the data specific to performing
96  *        SATA/STP IO and TASK requests.
97  */
98 typedef struct SCIF_SAS_STP_REQUEST
99 {
100    /**
101     * This field contains the translation information utilized by SATI.
102     * For more information on this field please refer to
103     * SATI_TRANSLATOR_SEQUENCE.
104     */
105    SATI_TRANSLATOR_SEQUENCE_T  sequence;
106 
107    /**
108     * This field contains the ncq tag being utilized by this IO request.
109     * The NCQ tag value must be less than or equal to 31 (0 <= tag <= 31).
110     */
111    U8  ncq_tag;
112 
113 } SCIF_SAS_STP_REQUEST_T;
114 
115 /**
116  * @struct SCIF_SAS_REQUEST
117  *
118  * @brief The SCIF_SAS_REQUEST object abstracts the common SAS
119  *        IO & task management data and behavior for the framework component.
120  */
121 typedef struct SCIF_SAS_REQUEST
122 {
123    /**
124     * All SAS request types (IO or Task management) have the SCI base
125     * request as their parent object.
126     */
127    SCI_BASE_REQUEST_T  parent;
128 
129    /**
130     * This field references the list of state specific handler methods to
131     * be utilized for this request instance.
132     */
133    SCI_BASE_REQUEST_STATE_HANDLER_T * state_handlers;
134 
135    SCIF_SAS_REQUEST_COMPLETION_HANDLER_T protocol_complete_handler;
136 
137    /**
138     * This field is utilized to communicate state information relating
139     * to this IO request and it's state transitions.
140     */
141    SCI_STATUS  status;
142 
143    /**
144     * This field represents the remote device object to which this IO
145     * request is destined.
146     */
147    struct SCIF_SAS_REMOTE_DEVICE * device;
148 
149    /**
150     * This field references the request object that has asked that this
151     * request be terminated.
152     */
153    struct SCIF_SAS_TASK_REQUEST * terminate_requestor;
154 
155    /**
156     * This field provides list specific information that enables a request
157     * to be placed in a list.
158     */
159    SCI_FAST_LIST_ELEMENT_T  list_element;
160 
161    /**
162     * This field indicates if the current request is one internally
163     * generated by the framework or if it is a user IO/task request.
164     */
165    BOOL is_internal;
166 
167    /**
168     * This field indicates the current request is a high priority one.
169     * An internal request is always high priority. But an external request
170     * could be high priority.
171     */
172    BOOL is_high_priority;
173 
174    /**
175     * This field indicates the current request should not be completed
176     * until a pending abort task set request is completed.  For NCQ errors,
177     * it will allow waiting until the read log ext data is returned to
178     * to determine how to fail/abort the pending ios.
179     */
180    BOOL is_waiting_for_abort_task_set;
181 
182    /**
183     * This field indicates the logical unit (LUN) for the request.
184     * This field is utilized during internal IO requests.
185     */
186    U32  lun;
187 
188    /**
189     * This field specifies sata specific data for the reqeust object.
190     * This data is only valid for SATA requests.
191     */
192    SCIF_SAS_STP_REQUEST_T  stp;
193 
194    /**
195     * This field contains the handle for the SCI Core request object that is
196     * managed by this framework request.
197     */
198    SCI_IO_REQUEST_HANDLE_T  core_object;
199 
200 } SCIF_SAS_REQUEST_T;
201 
202 void scif_sas_request_construct(
203    SCIF_SAS_REQUEST_T            * fw_request,
204    struct SCIF_SAS_REMOTE_DEVICE * fw_device,
205    SCI_BASE_LOGGER_T             * logger,
206    SCI_BASE_STATE_T              * state_table
207 );
208 
209 SCI_STATUS scif_sas_request_terminate_start(
210    SCIF_SAS_REQUEST_T      * fw_request,
211    SCI_IO_REQUEST_HANDLE_T   core_request
212 );
213 
214 void scif_sas_request_terminate_complete(
215    SCIF_SAS_REQUEST_T * fw_request
216 );
217 
218 #ifdef __cplusplus
219 }
220 #endif // __cplusplus
221 
222 #endif // _SCIF_SAS_REQUEST_H_
223 
224