xref: /freebsd/sys/dev/isci/scil/scic_task_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 _SCIC_TASK_REQUEST_H_
55 #define _SCIC_TASK_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 to utilize
62  *        task management requests.
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 #if !defined(DISABLE_TASK_MANAGEMENT)
73 
74 /**
75  * @brief This method simply returns the size required to build an SCI
76  *        based task management request object.
77  *
78  * @return Return the size of the SCIC task request object.
79  */
80 U32 scic_task_request_get_object_size(
81    void
82 );
83 
84 /**
85  * @brief This method is called by the SCI user to construct all SCI Core
86  *        task management requests, regardless of protocol.  Memory
87  *        initialization and functionality common to all task request types
88  *        is performed in this method.
89  *
90  * @note  The SCI core implementation will create an association between
91  *        the user task request object and the core task request object.
92  *
93  * @param[in]  scic_controller the handle to the core controller object
94  *             for which to build the task managmement request.
95  * @param[in]  scic_remote_device the handle to the core remote device
96  *             object for which to build the task management request.
97  *             passed, then a copy of the request is built internally.  The
98  *             request will be copied into the actual controller request
99  *             memory when the task is allocated internally during the
100  *             scic_controller_start_task() method.
101  * @param[in]  io_tag This parameter specifies the IO tag to be associated
102  *             with this request.  If SCI_CONTROLLER_INVALID_IO_TAG is
103  *             passed, then a copy of the request is built internally.  The
104  *             request will be copied into the actual controller request
105  *             memory when the IO tag is allocated internally during the
106  *             scic_controller_start_io() method.
107  * @param[in]  user_task_request_object This parameter specifies the user
108  *             task request to be utilized during construction.  This task
109  *             pointer will become the associated object for the core
110  *             task request object.
111  * @param[in]  scic_task_request_memory This parameter specifies the memory
112  *             location to be utilized when building the core request.
113  * @param[out] new_scic_task_request_handle This parameter specifies a
114  *             pointer to the handle the core will expect in further
115  *             interactions with the core task request object.
116  *
117  * @return Indicate if the controller successfully built the task request.
118  * @retval SCI_SUCCESS This value is returned if the task request was
119  *         successfully built.
120  */
121 SCI_STATUS scic_task_request_construct(
122    SCI_CONTROLLER_HANDLE_T      scic_controller,
123    SCI_REMOTE_DEVICE_HANDLE_T   scic_remote_device,
124    U16                          io_tag,
125    void                       * user_task_request_object,
126    void                       * scic_task_request_memory,
127    SCI_TASK_REQUEST_HANDLE_T  * new_scic_task_request_handle
128 );
129 
130 /**
131  * @brief This method is called by the SCI user to construct all SCI Core
132  *        SSP task management requests.  Memory initialization and
133  *        functionality common to all task request types is performed in
134  *        this method.
135  *
136  * @param[out] scic_task_request This parameter specifies the handle
137  *             to the core task request object for which to construct
138  *             a SATA specific task management request.
139  *
140  * @return Indicate if the controller successfully built the task request.
141  * @retval SCI_SUCCESS This value is returned if the task request was
142  *         successfully built.
143  */
144 SCI_STATUS scic_task_request_construct_ssp(
145    SCI_TASK_REQUEST_HANDLE_T  scic_task_request
146 );
147 
148 /**
149  * @brief This method is called by the SCI user to construct all SCI Core
150  *        SATA task management requests.  Memory initialization and
151  *        functionality common to all task request types is performed in
152  *        this method.
153  *
154  * @param[out] scic_task_request_handle This parameter specifies the
155  *             handle to the core task request object for which to construct
156  *             a SATA specific task management request.
157  *
158  * @return Indicate if the controller successfully built the task request.
159  * @retval SCI_SUCCESS This value is returned if the task request was
160  *         successfully built.
161  */
162 SCI_STATUS scic_task_request_construct_sata(
163    SCI_TASK_REQUEST_HANDLE_T  scic_task_request_handle
164 );
165 
166 #else // !defined(DISABLE_TASK_MANAGEMENT)
167 
168 #define scic_task_request_get_object_size() 0
169 #define scic_task_request_construct(controller, dev, tag, task, mem, handle) \
170         SCI_FAILURE
171 #define scic_task_request_construct_ssp(task) SCI_FAILURE
172 #define scic_task_request_construct_sata(task) SCI_FAILURE
173 
174 #endif // !defined(DISABLE_TASK_MANAGEMENT)
175 
176 #ifdef __cplusplus
177 }
178 #endif // __cplusplus
179 
180 #endif // _SCIC_TASK_REQUEST_H_
181 
182