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