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