1230557Sjimharris/*-
2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license.  When using or
3230557Sjimharris * redistributing this file, you may do so under either license.
4230557Sjimharris *
5230557Sjimharris * GPL LICENSE SUMMARY
6230557Sjimharris *
7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8230557Sjimharris *
9230557Sjimharris * This program is free software; you can redistribute it and/or modify
10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as
11230557Sjimharris * published by the Free Software Foundation.
12230557Sjimharris *
13230557Sjimharris * This program is distributed in the hope that it will be useful, but
14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of
15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16230557Sjimharris * General Public License for more details.
17230557Sjimharris *
18230557Sjimharris * You should have received a copy of the GNU General Public License
19230557Sjimharris * along with this program; if not, write to the Free Software
20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21230557Sjimharris * The full GNU General Public License is included in this distribution
22230557Sjimharris * in the file called LICENSE.GPL.
23230557Sjimharris *
24230557Sjimharris * BSD LICENSE
25230557Sjimharris *
26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27230557Sjimharris * All rights reserved.
28230557Sjimharris *
29230557Sjimharris * Redistribution and use in source and binary forms, with or without
30230557Sjimharris * modification, are permitted provided that the following conditions
31230557Sjimharris * are met:
32230557Sjimharris *
33230557Sjimharris *   * Redistributions of source code must retain the above copyright
34230557Sjimharris *     notice, this list of conditions and the following disclaimer.
35230557Sjimharris *   * Redistributions in binary form must reproduce the above copyright
36230557Sjimharris *     notice, this list of conditions and the following disclaimer in
37230557Sjimharris *     the documentation and/or other materials provided with the
38230557Sjimharris *     distribution.
39230557Sjimharris *
40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51230557Sjimharris *
52230557Sjimharris * $FreeBSD$
53230557Sjimharris */
54230557Sjimharris#ifndef _SCIF_IO_REQUEST_H_
55230557Sjimharris#define _SCIF_IO_REQUEST_H_
56230557Sjimharris
57230557Sjimharris/**
58230557Sjimharris * @file
59230557Sjimharris *
60230557Sjimharris * @brief This file contains the structures and interface methods that
61230557Sjimharris *        can be referenced and used by the SCI user for the SCI IO request
62230557Sjimharris *        object.
63230557Sjimharris */
64230557Sjimharris
65230557Sjimharris#ifdef __cplusplus
66230557Sjimharrisextern "C" {
67230557Sjimharris#endif // __cplusplus
68230557Sjimharris
69230557Sjimharris#include <dev/isci/scil/sci_types.h>
70230557Sjimharris#include <dev/isci/scil/sci_status.h>
71230557Sjimharris
72230557Sjimharris
73230557Sjimharris/**
74230557Sjimharris * @brief This method simply returns the size required to construct an SCI
75230557Sjimharris *        based IO request object (includes core & framework object size).
76230557Sjimharris *
77230557Sjimharris * @return Return the size of the SCI IO request object.
78230557Sjimharris */
79230557SjimharrisU32 scif_io_request_get_object_size(
80230557Sjimharris   void
81230557Sjimharris);
82230557Sjimharris
83230557Sjimharris/**
84230557Sjimharris* @brief This method simply the number of data bytes transfered for a
85230557Sjimharris*        STP or SSP io request.
86230557Sjimharris*
87230557Sjimharris* @param[in] scif_io_request This parameter specifies the framework IO
88230557Sjimharris*            handle to retrieve the number of data bytes transferred.
89230557Sjimharris*
90230557Sjimharris* @return Return the number of data bytes transfered by the io request
91230557Sjimharris*/
92230557SjimharrisU32 scif_io_request_get_number_of_bytes_transferred(
93230557Sjimharris   void * scif_io_request
94230557Sjimharris);
95230557Sjimharris
96230557Sjimharris/**
97230557Sjimharris * @brief This method is called by the SCIF user to construct an IO request.
98230557Sjimharris *        This method will construct a SCIC IO request internally.  The memory
99230557Sjimharris *        for the core IO request is passed as a parameter to this method.
100230557Sjimharris *
101230557Sjimharris * @note  The SCI framework implementation will create an association between
102230557Sjimharris *        the user IO request object and the framework IO request object.
103230557Sjimharris *
104230557Sjimharris * @param[in]  scif_controller the handle to the framework controller object
105230557Sjimharris *             for which to build an IO request.
106230557Sjimharris * @param[in]  scif_remote_device This parameter specifies the framework
107230557Sjimharris *             remote device with which this IO request is to be associated.
108230557Sjimharris * @param[in]  io_tag This parameter specifies the IO tag to be associated
109230557Sjimharris *             with this request.  If SCI_CONTROLLER_INVALID_IO_TAG is
110230557Sjimharris *             passed, then a copy of the request is built internally.  The
111230557Sjimharris *             request will be copied into the actual controller request
112230557Sjimharris *             memory when the IO tag is allocated internally during the
113230557Sjimharris *             scif_controller_start_io() method.
114230557Sjimharris * @param[in]  user_io_request_object This parameter specifies the user
115230557Sjimharris *             IO request to be utilized during IO construction.  This IO
116230557Sjimharris *             pointer will become the associated object for the framework
117230557Sjimharris *             IO request object.
118230557Sjimharris * @param[in]  io_request_memory This parameter specifies the memory
119230557Sjimharris *             to be utilized in the construction of the framework IO request.
120230557Sjimharris * @param[in]  scif_io_request This parameter specifies the handle to be
121230557Sjimharris *             utilized for all further interactions with this IO request
122230557Sjimharris *             object.
123230557Sjimharris *
124230557Sjimharris * @return Indicate if the controller successfully built the IO request.
125230557Sjimharris * @retval SCI_SUCCESS This value is returned if the IO request was
126230557Sjimharris *         successfully built.
127230557Sjimharris */
128230557SjimharrisSCI_STATUS scif_io_request_construct(
129230557Sjimharris   SCI_CONTROLLER_HANDLE_T      scif_controller,
130230557Sjimharris   SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
131230557Sjimharris   U16                          io_tag,
132230557Sjimharris   void                       * user_io_request_object,
133230557Sjimharris   void                       * io_request_memory,
134230557Sjimharris   SCI_IO_REQUEST_HANDLE_T    * scif_io_request
135230557Sjimharris);
136230557Sjimharris
137230557Sjimharris/**
138230557Sjimharris * @brief This method simply returns the SCI Core object handle that is
139230557Sjimharris *        associated with the supplied SCI Framework object.
140230557Sjimharris *
141230557Sjimharris * @param[in]  scif_io_request This parameter specifies the framework IO
142230557Sjimharris *             for which to return the associated core IO request object.
143230557Sjimharris *
144230557Sjimharris * @return This method returns a handle to the core IO request object
145230557Sjimharris *         associated with the framework IO request object.
146230557Sjimharris * @retval SCI_INVALID_HANDLE This return value indicates that the SCI Core
147230557Sjimharris *         IO request handle for the supplied framework IO is invalid.
148230557Sjimharris */
149230557SjimharrisSCI_IO_REQUEST_HANDLE_T scif_io_request_get_scic_handle(
150230557Sjimharris   SCI_IO_REQUEST_HANDLE_T scif_io_request
151230557Sjimharris);
152230557Sjimharris
153230557Sjimharris/**
154230557Sjimharris * @brief This method returns the address of the response information unit.
155230557Sjimharris *        This call is only valid if the completion status for the io request
156230557Sjimharris *        is SCI_FAILURE_IO_RESPONSE_VALID.
157230557Sjimharris *
158230557Sjimharris * @param[in]  scif_io_request This parameter specifies the framework IO
159230557Sjimharris *             for which to return the associated core IO request object.
160230557Sjimharris *
161230557Sjimharris * @return The address for the response information unit.
162230557Sjimharris */
163230557Sjimharrisvoid * scif_io_request_get_response_iu_address(
164230557Sjimharris   SCI_IO_REQUEST_HANDLE_T scif_io_request
165230557Sjimharris);
166230557Sjimharris
167230557Sjimharris/**
168230557Sjimharris * @brief This method will build an Framework SSP Passthrough IO request based
169230557Sjimharris *        on the user information supplied in the pass-through IO request object.
170230557Sjimharris *        In case of pass through request construction, the driver creates the
171230557Sjimharris *        sci core request object and pass that to the framework
172230557Sjimharris *
173230557Sjimharris * @pre
174230557Sjimharris *
175230557Sjimharris * @param[in]  scif_controller. Not used in the function but kept to maintain uniformity
176230557Sjimharris *             with other io construct functions
177230557Sjimharris * @param[in]  scif_remote_device. This parameter is the device.
178230557Sjimharris * @param[in]  scic_io_request. This parameter is the scic request already constructed
179230557Sjimharris * @param[in]  user_io_request_object, the user io request
180230557Sjimharris * @param[in]  io_request_memory, the scif offset in the user_io_request_object.
181230557Sjimharris *
182230557Sjimharris * @param[out]  the contructed scif request. This points to the same location as io_request_memory
183230557Sjimharris *
184230557Sjimharris * @return Indicate if framework IO request is successfully built.
185230557Sjimharris * @retval SCI_SUCCESS This value is returned if the IO request was
186230557Sjimharris *         successfully built.
187230557Sjimharris */
188230557SjimharrisSCI_STATUS scif_io_request_construct_with_core (
189230557Sjimharris   SCI_CONTROLLER_HANDLE_T      scif_controller,
190230557Sjimharris   SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
191230557Sjimharris   void                       * scic_io_request,
192230557Sjimharris   void                       * user_io_request_object,
193230557Sjimharris   void                       * io_request_memory,
194230557Sjimharris   SCI_IO_REQUEST_HANDLE_T    * scif_io_request
195230557Sjimharris);
196230557Sjimharris
197230557Sjimharris/**
198230557Sjimharris * @brief This method will build the basic scif and scic io request object based
199230557Sjimharris *        on the user information supplied in the pass-through IO request object.
200230557Sjimharris *        This function will not build the protocol specific part of the request
201230557Sjimharris *        but set up the memory areas of scif and scic set the association.
202230557Sjimharris *
203230557Sjimharris * @pre
204230557Sjimharris *
205230557Sjimharris * @param[in]  scif_controller the handle to the framework controller object
206230557Sjimharris *             for which to build an IO request.
207230557Sjimharris * @param[in]  scif_remote_device This parameter specifies the framework
208230557Sjimharris *             remote device with which this IO request is to be associated.
209230557Sjimharris * @param[in]  io_tag This parameter specifies the IO tag to be associated
210230557Sjimharris *             with this request.  If SCI_CONTROLLER_INVALID_IO_TAG is
211230557Sjimharris *             passed, then a copy of the request is built internally.  The
212230557Sjimharris *             request will be copied into the actual controller request
213230557Sjimharris *             memory when the IO tag is allocated internally during the
214230557Sjimharris *             scif_controller_start_io() method.
215230557Sjimharris * @param[in]  user_io_request_object This parameter specifies the user
216230557Sjimharris *             IO request to be utilized during IO construction.  This IO
217230557Sjimharris *             pointer will become the associated object for the framework
218230557Sjimharris *             IO request object.
219230557Sjimharris * @param[in]  io_request_memory This parameter specifies the memory
220230557Sjimharris *             to be utilized in the construction of the framework IO request.
221230557Sjimharris * @param[in]  scif_io_request This parameter specifies the handle to be
222230557Sjimharris *             utilized for all further interactions with this IO request
223230557Sjimharris *             object.
224230557Sjimharris *
225230557Sjimharris * @return Indicate if the controller successfully built the IO request.
226230557Sjimharris * @retval SCI_SUCCESS This value is returned if the IO request was
227230557Sjimharris *         successfully built.
228230557Sjimharris */
229230557SjimharrisSCI_STATUS scif_request_construct(
230230557Sjimharris   SCI_CONTROLLER_HANDLE_T      scif_controller,
231230557Sjimharris   SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
232230557Sjimharris   U16                          io_tag,
233230557Sjimharris   void                       * user_io_request_object,
234230557Sjimharris   void                       * io_request_memory,
235230557Sjimharris   SCI_IO_REQUEST_HANDLE_T    * scif_io_request
236230557Sjimharris);
237230557Sjimharris
238230557Sjimharris#ifdef __cplusplus
239230557Sjimharris}
240230557Sjimharris#endif // __cplusplus
241230557Sjimharris
242230557Sjimharris#endif // _SCIF_IO_REQUEST_H_
243230557Sjimharris
244