2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 * This file contains the task management substate handlers for the
58 * SCIC_SDS_IO_REQUEST object.
63 #include "intel_sas.h"
64 #include "sci_environment.h"
65 #include "scic_sds_request.h"
66 #include "scic_controller.h"
67 #include "scic_sds_controller.h"
68 #include "scu_completion_codes.h"
69 #include "scu_task_context.h"
72 * This method processes the completions transport layer (TL) status to
73 * determine if the RAW task management frame was sent successfully. If the
74 * raw frame was sent successfully, then the state for the task request
75 * transitions to waiting for a response frame.
76 * @this_request: This parameter specifies the request for which the TC
77 * completion was received.
78 * @completion_code: This parameter indicates the completion status information
81 * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
82 * this method always returns success.
84 static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler(
85 struct scic_sds_request *this_request,
88 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
89 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
90 scic_sds_request_set_status(
91 this_request, SCU_TASK_DONE_GOOD, SCI_SUCCESS
94 sci_base_state_machine_change_state(
95 &this_request->started_substate_machine,
96 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
100 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
102 * Currently, the decision is to simply allow the task request to
103 * timeout if the task IU wasn't received successfully.
104 * There is a potential for receiving multiple task responses if we
105 * decide to send the task IU again. */
106 dev_warn(scic_to_dev(this_request->owning_controller),
107 "%s: TaskRequest:0x%p CompletionCode:%x - "
113 sci_base_state_machine_change_state(
114 &this_request->started_substate_machine,
115 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
121 * All other completion status cause the IO to be complete. If a NAK
122 * was received, then it is up to the user to retry the request. */
123 scic_sds_request_set_status(
125 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
126 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
129 sci_base_state_machine_change_state(
130 &this_request->parent.state_machine,
131 SCI_BASE_REQUEST_STATE_COMPLETED
140 * This method is responsible for processing a terminate/abort request for this
141 * TC while the request is waiting for the task management response
143 * @this_request: This parameter specifies the request for which the
144 * termination was requested.
146 * This method returns an indication as to whether the abort request was
147 * successfully handled. need to update to ensure the received UF doesn't cause
148 * damage to subsequent requests (i.e. put the extended tag in a holding
149 * pattern for this particular device).
151 static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler(
152 struct sci_base_request *request)
154 struct scic_sds_request *this_request = (struct scic_sds_request *)request;
156 sci_base_state_machine_change_state(
157 &this_request->parent.state_machine,
158 SCI_BASE_REQUEST_STATE_ABORTING
161 sci_base_state_machine_change_state(
162 &this_request->parent.state_machine,
163 SCI_BASE_REQUEST_STATE_COMPLETED
170 * This method processes an unsolicited frame while the task mgmt request is
171 * waiting for a response frame. It will copy the response data, release
172 * the unsolicited frame, and transition the request to the
173 * SCI_BASE_REQUEST_STATE_COMPLETED state.
174 * @this_request: This parameter specifies the request for which the
175 * unsolicited frame was received.
176 * @frame_index: This parameter indicates the unsolicited frame index that
177 * should contain the response.
179 * This method returns an indication of whether the TC response frame was
180 * handled successfully or not. SCI_SUCCESS Currently this value is always
181 * returned and indicates successful processing of the TC response. Should
182 * probably update to check frame type and make sure it is a response frame.
184 static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler(
185 struct scic_sds_request *this_request,
188 scic_sds_io_request_copy_response(this_request);
190 sci_base_state_machine_change_state(
191 &this_request->parent.state_machine,
192 SCI_BASE_REQUEST_STATE_COMPLETED
195 scic_sds_controller_release_frame(
196 this_request->owning_controller, frame_index
202 const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
203 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
204 .parent.start_handler = scic_sds_request_default_start_handler,
205 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
206 .parent.complete_handler = scic_sds_request_default_complete_handler,
207 .parent.destruct_handler = scic_sds_request_default_destruct_handler,
208 .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
209 .event_handler = scic_sds_request_default_event_handler,
210 .frame_handler = scic_sds_request_default_frame_handler,
212 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
213 .parent.start_handler = scic_sds_request_default_start_handler,
214 .parent.abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
215 .parent.complete_handler = scic_sds_request_default_complete_handler,
216 .parent.destruct_handler = scic_sds_request_default_destruct_handler,
217 .tc_completion_handler = scic_sds_request_default_tc_completion_handler,
218 .event_handler = scic_sds_request_default_event_handler,
219 .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
224 * This file is provided under a dual BSD/GPLv2 license. When using or
225 * redistributing this file, you may do so under either license.
227 * GPL LICENSE SUMMARY
229 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
231 * This program is free software; you can redistribute it and/or modify
232 * it under the terms of version 2 of the GNU General Public License as
233 * published by the Free Software Foundation.
235 * This program is distributed in the hope that it will be useful, but
236 * WITHOUT ANY WARRANTY; without even the implied warranty of
237 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
238 * General Public License for more details.
240 * You should have received a copy of the GNU General Public License
241 * along with this program; if not, write to the Free Software
242 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
243 * The full GNU General Public License is included in this distribution
244 * in the file called LICENSE.GPL.
248 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
249 * All rights reserved.
251 * Redistribution and use in source and binary forms, with or without
252 * modification, are permitted provided that the following conditions
255 * * Redistributions of source code must retain the above copyright
256 * notice, this list of conditions and the following disclaimer.
257 * * Redistributions in binary form must reproduce the above copyright
258 * notice, this list of conditions and the following disclaimer in
259 * the documentation and/or other materials provided with the
261 * * Neither the name of Intel Corporation nor the names of its
262 * contributors may be used to endorse or promote products derived
263 * from this software without specific prior written permission.
265 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
266 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
267 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
268 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
269 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
270 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
271 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
272 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
273 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
274 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
275 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
279 * This file contains the enter/exit methods associated with each of the task
280 * management raw request states. For more information on the task
281 * management request state machine please refer to scic_sds_io_request.h
286 #include "scic_sds_request.h"
287 #include "sci_base_state_machine.h"
290 * This method performs the actions required when entering the
291 * SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
292 * sub-state. This includes setting the IO request state handlers for this
294 * @object: This parameter specifies the request object for which the sub-state
295 * change is occuring.
299 static void scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter(
300 struct sci_base_object *object)
302 struct scic_sds_request *this_request = (struct scic_sds_request *)object;
306 scic_sds_ssp_task_request_started_substate_handler_table,
307 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
312 * This method performs the actions required when entering the
313 * SCIC_SDS_IO_REQUEST_STARTED_SUBSTATE_AWAIT_TC_RESPONSE sub-state. This
314 * includes setting the IO request state handlers for this sub-state.
315 * @object: This parameter specifies the request object for which the sub-state
316 * change is occuring.
320 static void scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter(
321 struct sci_base_object *object)
323 struct scic_sds_request *this_request = (struct scic_sds_request *)object;
327 scic_sds_ssp_task_request_started_substate_handler_table,
328 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
332 const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[] = {
333 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
334 .enter_state = scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter,
336 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
337 .enter_state = scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter,