isci: remove base_request abstraction
[deliverable/linux.git] / drivers / scsi / isci / core / scic_sds_ssp_request.c
CommitLineData
6f231dda
DW
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.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
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.
12 *
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.
17 *
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.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
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.
42 *
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.
54 */
55
6f231dda 56#include "intel_sas.h"
e574a8c1 57#include "sci_base_state_machine.h"
6f231dda
DW
58#include "scic_controller.h"
59#include "scic_sds_controller.h"
e574a8c1
DW
60#include "scic_sds_request.h"
61#include "sci_environment.h"
6f231dda
DW
62#include "scu_completion_codes.h"
63#include "scu_task_context.h"
64
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 * @this_request: 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.
74 *
75 * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
76 * this method always returns success.
77 */
78static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler(
79 struct scic_sds_request *this_request,
80 u32 completion_code)
81{
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 this_request, SCU_TASK_DONE_GOOD, SCI_SUCCESS
86 );
87
88 sci_base_state_machine_change_state(
89 &this_request->started_substate_machine,
90 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
91 );
92 break;
93
94 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
95 /*
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(this_request->owning_controller),
101 "%s: TaskRequest:0x%p CompletionCode:%x - "
102 "ACK/NAK timeout\n",
103 __func__,
104 this_request,
105 completion_code);
106
107 sci_base_state_machine_change_state(
108 &this_request->started_substate_machine,
109 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
110 );
111 break;
112
113 default:
114 /*
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 this_request,
119 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
120 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
121 );
122
38aa74eb
CH
123 sci_base_state_machine_change_state(&this_request->state_machine,
124 SCI_BASE_REQUEST_STATE_COMPLETED);
6f231dda
DW
125 break;
126 }
127
128 return SCI_SUCCESS;
129}
130
131/**
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 * @this_request: This parameter specifies the request for which the
136 * termination was requested.
137 *
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).
142 */
143static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler(
38aa74eb 144 struct scic_sds_request *request)
6f231dda 145{
38aa74eb
CH
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);
6f231dda
DW
150 return SCI_SUCCESS;
151}
152
153/**
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 * @this_request: 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.
162 *
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.
167 */
168static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler(
38aa74eb 169 struct scic_sds_request *request,
6f231dda
DW
170 u32 frame_index)
171{
38aa74eb 172 scic_sds_io_request_copy_response(request);
6f231dda 173
38aa74eb
CH
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);
6f231dda
DW
178 return SCI_SUCCESS;
179}
180
35173d57 181static const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
6f231dda 182 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
38aa74eb
CH
183 .start_handler = scic_sds_request_default_start_handler,
184 .abort_handler = scic_sds_request_started_state_abort_handler,
185 .complete_handler = scic_sds_request_default_complete_handler,
186 .destruct_handler = scic_sds_request_default_destruct_handler,
187 .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
188 .event_handler = scic_sds_request_default_event_handler,
189 .frame_handler = scic_sds_request_default_frame_handler,
6f231dda
DW
190 },
191 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
38aa74eb
CH
192 .start_handler = scic_sds_request_default_start_handler,
193 .abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
194 .complete_handler = scic_sds_request_default_complete_handler,
195 .destruct_handler = scic_sds_request_default_destruct_handler,
196 .tc_completion_handler = scic_sds_request_default_tc_completion_handler,
197 .event_handler = scic_sds_request_default_event_handler,
198 .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
6f231dda
DW
199 }
200};
201
6f231dda
DW
202/**
203 * This method performs the actions required when entering the
204 * SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
205 * sub-state. This includes setting the IO request state handlers for this
206 * sub-state.
207 * @object: This parameter specifies the request object for which the sub-state
208 * change is occuring.
209 *
210 * none.
211 */
212static void scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter(
213 struct sci_base_object *object)
214{
215 struct scic_sds_request *this_request = (struct scic_sds_request *)object;
216
217 SET_STATE_HANDLER(
218 this_request,
219 scic_sds_ssp_task_request_started_substate_handler_table,
220 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
221 );
222}
223
224/**
225 * This method performs the actions required when entering the
226 * SCIC_SDS_IO_REQUEST_STARTED_SUBSTATE_AWAIT_TC_RESPONSE sub-state. This
227 * includes setting the IO request state handlers for this sub-state.
228 * @object: This parameter specifies the request object for which the sub-state
229 * change is occuring.
230 *
231 * none.
232 */
233static void scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter(
234 struct sci_base_object *object)
235{
236 struct scic_sds_request *this_request = (struct scic_sds_request *)object;
237
238 SET_STATE_HANDLER(
239 this_request,
240 scic_sds_ssp_task_request_started_substate_handler_table,
241 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
242 );
243}
244
245const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[] = {
246 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
247 .enter_state = scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter,
248 },
249 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
250 .enter_state = scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter,
251 },
252};
253
This page took 0.039358 seconds and 5 git commands to generate.