xref: /freebsd/sys/dev/isci/scil/scif_io_request.h (revision b9f654b163bce26de79705e77b872427c9f2afa1)
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_IO_REQUEST_H_
57 #define _SCIF_IO_REQUEST_H_
58 
59 /**
60  * @file
61  *
62  * @brief This file contains the structures and interface methods that
63  *        can be referenced and used by the SCI user for the SCI IO request
64  *        object.
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 
74 
75 /**
76  * @brief This method simply returns the size required to construct an SCI
77  *        based IO request object (includes core & framework object size).
78  *
79  * @return Return the size of the SCI IO request object.
80  */
81 U32 scif_io_request_get_object_size(
82    void
83 );
84 
85 /**
86 * @brief This method simply the number of data bytes transferred for a
87 *        STP or SSP io request.
88 *
89 * @param[in] scif_io_request This parameter specifies the framework IO
90 *            handle to retrieve the number of data bytes transferred.
91 *
92 * @return Return the number of data bytes transferred by the io request
93 */
94 U32 scif_io_request_get_number_of_bytes_transferred(
95    void * scif_io_request
96 );
97 
98 /**
99  * @brief This method is called by the SCIF user to construct an IO request.
100  *        This method will construct a SCIC IO request internally.  The memory
101  *        for the core IO request is passed as a parameter to this method.
102  *
103  * @note  The SCI framework implementation will create an association between
104  *        the user IO request object and the framework IO request object.
105  *
106  * @param[in]  scif_controller the handle to the framework controller object
107  *             for which to build an IO request.
108  * @param[in]  scif_remote_device This parameter specifies the framework
109  *             remote device with which this IO request is to be associated.
110  * @param[in]  io_tag This parameter specifies the IO tag to be associated
111  *             with this request.  If SCI_CONTROLLER_INVALID_IO_TAG is
112  *             passed, then a copy of the request is built internally.  The
113  *             request will be copied into the actual controller request
114  *             memory when the IO tag is allocated internally during the
115  *             scif_controller_start_io() method.
116  * @param[in]  user_io_request_object This parameter specifies the user
117  *             IO request to be utilized during IO construction.  This IO
118  *             pointer will become the associated object for the framework
119  *             IO request object.
120  * @param[in]  io_request_memory This parameter specifies the memory
121  *             to be utilized in the construction of the framework IO request.
122  * @param[in]  scif_io_request This parameter specifies the handle to be
123  *             utilized for all further interactions with this IO request
124  *             object.
125  *
126  * @return Indicate if the controller successfully built the IO request.
127  * @retval SCI_SUCCESS This value is returned if the IO request was
128  *         successfully built.
129  */
130 SCI_STATUS scif_io_request_construct(
131    SCI_CONTROLLER_HANDLE_T      scif_controller,
132    SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
133    U16                          io_tag,
134    void                       * user_io_request_object,
135    void                       * io_request_memory,
136    SCI_IO_REQUEST_HANDLE_T    * scif_io_request
137 );
138 
139 /**
140  * @brief This method simply returns the SCI Core object handle that is
141  *        associated with the supplied SCI Framework object.
142  *
143  * @param[in]  scif_io_request This parameter specifies the framework IO
144  *             for which to return the associated core IO request object.
145  *
146  * @return This method returns a handle to the core IO request object
147  *         associated with the framework IO request object.
148  * @retval SCI_INVALID_HANDLE This return value indicates that the SCI Core
149  *         IO request handle for the supplied framework IO is invalid.
150  */
151 SCI_IO_REQUEST_HANDLE_T scif_io_request_get_scic_handle(
152    SCI_IO_REQUEST_HANDLE_T scif_io_request
153 );
154 
155 /**
156  * @brief This method returns the address of the response information unit.
157  *        This call is only valid if the completion status for the io request
158  *        is SCI_FAILURE_IO_RESPONSE_VALID.
159  *
160  * @param[in]  scif_io_request This parameter specifies the framework IO
161  *             for which to return the associated core IO request object.
162  *
163  * @return The address for the response information unit.
164  */
165 void * scif_io_request_get_response_iu_address(
166    SCI_IO_REQUEST_HANDLE_T scif_io_request
167 );
168 
169 /**
170  * @brief This method will build an Framework SSP Passthrough IO request based
171  *        on the user information supplied in the pass-through IO request object.
172  *        In case of pass through request construction, the driver creates the
173  *        sci core request object and pass that to the framework
174  *
175  * @pre
176  *
177  * @param[in]  scif_controller. Not used in the function but kept to maintain uniformity
178  *             with other io construct functions
179  * @param[in]  scif_remote_device. This parameter is the device.
180  * @param[in]  scic_io_request. This parameter is the scic request already constructed
181  * @param[in]  user_io_request_object, the user io request
182  * @param[in]  io_request_memory, the scif offset in the user_io_request_object.
183  *
184  * @param[out]  the contructed scif request. This points to the same location as io_request_memory
185  *
186  * @return Indicate if framework IO request is successfully built.
187  * @retval SCI_SUCCESS This value is returned if the IO request was
188  *         successfully built.
189  */
190 SCI_STATUS scif_io_request_construct_with_core (
191    SCI_CONTROLLER_HANDLE_T      scif_controller,
192    SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
193    void                       * scic_io_request,
194    void                       * user_io_request_object,
195    void                       * io_request_memory,
196    SCI_IO_REQUEST_HANDLE_T    * scif_io_request
197 );
198 
199 /**
200  * @brief This method will build the basic scif and scic io request object based
201  *        on the user information supplied in the pass-through IO request object.
202  *        This function will not build the protocol specific part of the request
203  *        but set up the memory areas of scif and scic set the association.
204  *
205  * @pre
206  *
207  * @param[in]  scif_controller the handle to the framework controller object
208  *             for which to build an IO request.
209  * @param[in]  scif_remote_device This parameter specifies the framework
210  *             remote device with which this IO request is to be associated.
211  * @param[in]  io_tag This parameter specifies the IO tag to be associated
212  *             with this request.  If SCI_CONTROLLER_INVALID_IO_TAG is
213  *             passed, then a copy of the request is built internally.  The
214  *             request will be copied into the actual controller request
215  *             memory when the IO tag is allocated internally during the
216  *             scif_controller_start_io() method.
217  * @param[in]  user_io_request_object This parameter specifies the user
218  *             IO request to be utilized during IO construction.  This IO
219  *             pointer will become the associated object for the framework
220  *             IO request object.
221  * @param[in]  io_request_memory This parameter specifies the memory
222  *             to be utilized in the construction of the framework IO request.
223  * @param[in]  scif_io_request This parameter specifies the handle to be
224  *             utilized for all further interactions with this IO request
225  *             object.
226  *
227  * @return Indicate if the controller successfully built the IO request.
228  * @retval SCI_SUCCESS This value is returned if the IO request was
229  *         successfully built.
230  */
231 SCI_STATUS scif_request_construct(
232    SCI_CONTROLLER_HANDLE_T      scif_controller,
233    SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
234    U16                          io_tag,
235    void                       * user_io_request_object,
236    void                       * io_request_memory,
237    SCI_IO_REQUEST_HANDLE_T    * scif_io_request
238 );
239 
240 #ifdef __cplusplus
241 }
242 #endif // __cplusplus
243 
244 #endif // _SCIF_IO_REQUEST_H_
245 
246