isci: replace this_* and the_* variables with more meaningful names
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / isci / core / scic_sds_ssp_request.c
blob03676682e6ef690f626431687d116a73ec2de494
1 /*
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.
5 * GPL LICENSE SUMMARY
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.
24 * BSD LICENSE
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
31 * are met:
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
38 * distribution.
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.
56 #include "intel_sas.h"
57 #include "sci_base_state_machine.h"
58 #include "scic_controller.h"
59 #include "scic_sds_controller.h"
60 #include "scic_sds_request.h"
61 #include "sci_environment.h"
62 #include "scu_completion_codes.h"
63 #include "scu_task_context.h"
65 /**
66 * This method processes the completions transport layer (TL) status to
67 * determine if the RAW task management frame was sent successfully. If the
68 * raw frame was sent successfully, then the state for the task request
69 * transitions to waiting for a response frame.
70 * @sci_req: This parameter specifies the request for which the TC
71 * completion was received.
72 * @completion_code: This parameter indicates the completion status information
73 * for the TC.
75 * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
76 * this method always returns success.
78 static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler(
79 struct scic_sds_request *sci_req,
80 u32 completion_code)
82 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
83 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
84 scic_sds_request_set_status(
85 sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS
88 sci_base_state_machine_change_state(
89 &sci_req->started_substate_machine,
90 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
92 break;
94 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
96 * Currently, the decision is to simply allow the task request to
97 * timeout if the task IU wasn't received successfully.
98 * There is a potential for receiving multiple task responses if we
99 * decide to send the task IU again. */
100 dev_warn(scic_to_dev(sci_req->owning_controller),
101 "%s: TaskRequest:0x%p CompletionCode:%x - "
102 "ACK/NAK timeout\n",
103 __func__,
104 sci_req,
105 completion_code);
107 sci_base_state_machine_change_state(
108 &sci_req->started_substate_machine,
109 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
111 break;
113 default:
115 * All other completion status cause the IO to be complete. If a NAK
116 * was received, then it is up to the user to retry the request. */
117 scic_sds_request_set_status(
118 sci_req,
119 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
120 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
123 sci_base_state_machine_change_state(&sci_req->state_machine,
124 SCI_BASE_REQUEST_STATE_COMPLETED);
125 break;
128 return SCI_SUCCESS;
132 * This method is responsible for processing a terminate/abort request for this
133 * TC while the request is waiting for the task management response
134 * unsolicited frame.
135 * @sci_req: This parameter specifies the request for which the
136 * termination was requested.
138 * This method returns an indication as to whether the abort request was
139 * successfully handled. need to update to ensure the received UF doesn't cause
140 * damage to subsequent requests (i.e. put the extended tag in a holding
141 * pattern for this particular device).
143 static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler(
144 struct scic_sds_request *request)
146 sci_base_state_machine_change_state(&request->state_machine,
147 SCI_BASE_REQUEST_STATE_ABORTING);
148 sci_base_state_machine_change_state(&request->state_machine,
149 SCI_BASE_REQUEST_STATE_COMPLETED);
150 return SCI_SUCCESS;
154 * This method processes an unsolicited frame while the task mgmt request is
155 * waiting for a response frame. It will copy the response data, release
156 * the unsolicited frame, and transition the request to the
157 * SCI_BASE_REQUEST_STATE_COMPLETED state.
158 * @sci_req: This parameter specifies the request for which the
159 * unsolicited frame was received.
160 * @frame_index: This parameter indicates the unsolicited frame index that
161 * should contain the response.
163 * This method returns an indication of whether the TC response frame was
164 * handled successfully or not. SCI_SUCCESS Currently this value is always
165 * returned and indicates successful processing of the TC response. Should
166 * probably update to check frame type and make sure it is a response frame.
168 static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler(
169 struct scic_sds_request *request,
170 u32 frame_index)
172 scic_sds_io_request_copy_response(request);
174 sci_base_state_machine_change_state(&request->state_machine,
175 SCI_BASE_REQUEST_STATE_COMPLETED);
176 scic_sds_controller_release_frame(request->owning_controller,
177 frame_index);
178 return SCI_SUCCESS;
181 static const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
182 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
183 .abort_handler = scic_sds_request_started_state_abort_handler,
184 .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
186 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
187 .abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
188 .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
193 * This method performs the actions required when entering the
194 * SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
195 * sub-state. This includes setting the IO request state handlers for this
196 * sub-state.
197 * @object: This parameter specifies the request object for which the sub-state
198 * change is occuring.
200 * none.
202 static void scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter(
203 struct sci_base_object *object)
205 struct scic_sds_request *sci_req = (struct scic_sds_request *)object;
207 SET_STATE_HANDLER(
208 sci_req,
209 scic_sds_ssp_task_request_started_substate_handler_table,
210 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
215 * This method performs the actions required when entering the
216 * SCIC_SDS_IO_REQUEST_STARTED_SUBSTATE_AWAIT_TC_RESPONSE sub-state. This
217 * includes setting the IO request state handlers for this sub-state.
218 * @object: This parameter specifies the request object for which the sub-state
219 * change is occuring.
221 * none.
223 static void scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter(
224 struct sci_base_object *object)
226 struct scic_sds_request *sci_req = (struct scic_sds_request *)object;
228 SET_STATE_HANDLER(
229 sci_req,
230 scic_sds_ssp_task_request_started_substate_handler_table,
231 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
235 const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[] = {
236 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
237 .enter_state = scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter,
239 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
240 .enter_state = scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter,