isci: removing intel_*.h headers
[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
e574a8c1 56#include "sci_base_state_machine.h"
6f231dda
DW
57#include "scic_controller.h"
58#include "scic_sds_controller.h"
e574a8c1
DW
59#include "scic_sds_request.h"
60#include "sci_environment.h"
6f231dda
DW
61#include "scu_completion_codes.h"
62#include "scu_task_context.h"
63
64/**
65 * This method processes the completions transport layer (TL) status to
66 * determine if the RAW task management frame was sent successfully. If the
67 * raw frame was sent successfully, then the state for the task request
68 * transitions to waiting for a response frame.
e2023b87 69 * @sci_req: This parameter specifies the request for which the TC
6f231dda
DW
70 * completion was received.
71 * @completion_code: This parameter indicates the completion status information
72 * for the TC.
73 *
74 * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
75 * this method always returns success.
76 */
77static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler(
e2023b87 78 struct scic_sds_request *sci_req,
6f231dda
DW
79 u32 completion_code)
80{
81 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
82 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
83 scic_sds_request_set_status(
e2023b87 84 sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS
6f231dda
DW
85 );
86
87 sci_base_state_machine_change_state(
e2023b87 88 &sci_req->started_substate_machine,
6f231dda
DW
89 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
90 );
91 break;
92
93 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
94 /*
95 * Currently, the decision is to simply allow the task request to
96 * timeout if the task IU wasn't received successfully.
97 * There is a potential for receiving multiple task responses if we
98 * decide to send the task IU again. */
e2023b87 99 dev_warn(scic_to_dev(sci_req->owning_controller),
6f231dda
DW
100 "%s: TaskRequest:0x%p CompletionCode:%x - "
101 "ACK/NAK timeout\n",
102 __func__,
e2023b87 103 sci_req,
6f231dda
DW
104 completion_code);
105
106 sci_base_state_machine_change_state(
e2023b87 107 &sci_req->started_substate_machine,
6f231dda
DW
108 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
109 );
110 break;
111
112 default:
113 /*
114 * All other completion status cause the IO to be complete. If a NAK
115 * was received, then it is up to the user to retry the request. */
116 scic_sds_request_set_status(
e2023b87 117 sci_req,
6f231dda
DW
118 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
119 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
120 );
121
e2023b87 122 sci_base_state_machine_change_state(&sci_req->state_machine,
38aa74eb 123 SCI_BASE_REQUEST_STATE_COMPLETED);
6f231dda
DW
124 break;
125 }
126
127 return SCI_SUCCESS;
128}
129
130/**
131 * This method is responsible for processing a terminate/abort request for this
132 * TC while the request is waiting for the task management response
133 * unsolicited frame.
e2023b87 134 * @sci_req: This parameter specifies the request for which the
6f231dda
DW
135 * termination was requested.
136 *
137 * This method returns an indication as to whether the abort request was
138 * successfully handled. need to update to ensure the received UF doesn't cause
139 * damage to subsequent requests (i.e. put the extended tag in a holding
140 * pattern for this particular device).
141 */
142static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler(
38aa74eb 143 struct scic_sds_request *request)
6f231dda 144{
38aa74eb
CH
145 sci_base_state_machine_change_state(&request->state_machine,
146 SCI_BASE_REQUEST_STATE_ABORTING);
147 sci_base_state_machine_change_state(&request->state_machine,
148 SCI_BASE_REQUEST_STATE_COMPLETED);
6f231dda
DW
149 return SCI_SUCCESS;
150}
151
152/**
153 * This method processes an unsolicited frame while the task mgmt request is
154 * waiting for a response frame. It will copy the response data, release
155 * the unsolicited frame, and transition the request to the
156 * SCI_BASE_REQUEST_STATE_COMPLETED state.
e2023b87 157 * @sci_req: This parameter specifies the request for which the
6f231dda
DW
158 * unsolicited frame was received.
159 * @frame_index: This parameter indicates the unsolicited frame index that
160 * should contain the response.
161 *
162 * This method returns an indication of whether the TC response frame was
163 * handled successfully or not. SCI_SUCCESS Currently this value is always
164 * returned and indicates successful processing of the TC response. Should
165 * probably update to check frame type and make sure it is a response frame.
166 */
167static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler(
38aa74eb 168 struct scic_sds_request *request,
6f231dda
DW
169 u32 frame_index)
170{
38aa74eb 171 scic_sds_io_request_copy_response(request);
6f231dda 172
38aa74eb
CH
173 sci_base_state_machine_change_state(&request->state_machine,
174 SCI_BASE_REQUEST_STATE_COMPLETED);
175 scic_sds_controller_release_frame(request->owning_controller,
176 frame_index);
6f231dda
DW
177 return SCI_SUCCESS;
178}
179
35173d57 180static const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
6f231dda 181 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
38aa74eb 182 .abort_handler = scic_sds_request_started_state_abort_handler,
38aa74eb 183 .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
6f231dda
DW
184 },
185 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
38aa74eb 186 .abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
38aa74eb 187 .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
6f231dda
DW
188 }
189};
190
6f231dda
DW
191/**
192 * This method performs the actions required when entering the
193 * SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
194 * sub-state. This includes setting the IO request state handlers for this
195 * sub-state.
196 * @object: This parameter specifies the request object for which the sub-state
9a0fff7b 197 * change is occurring.
6f231dda
DW
198 *
199 * none.
200 */
201static void scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter(
9a0fff7b 202 void *object)
6f231dda 203{
890cae9b 204 struct scic_sds_request *sci_req = object;
6f231dda
DW
205
206 SET_STATE_HANDLER(
e2023b87 207 sci_req,
6f231dda
DW
208 scic_sds_ssp_task_request_started_substate_handler_table,
209 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
210 );
211}
212
213/**
214 * This method performs the actions required when entering the
215 * SCIC_SDS_IO_REQUEST_STARTED_SUBSTATE_AWAIT_TC_RESPONSE sub-state. This
216 * includes setting the IO request state handlers for this sub-state.
217 * @object: This parameter specifies the request object for which the sub-state
9a0fff7b 218 * change is occurring.
6f231dda
DW
219 *
220 * none.
221 */
222static void scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter(
9a0fff7b 223 void *object)
6f231dda 224{
890cae9b 225 struct scic_sds_request *sci_req = object;
6f231dda
DW
226
227 SET_STATE_HANDLER(
e2023b87 228 sci_req,
6f231dda
DW
229 scic_sds_ssp_task_request_started_substate_handler_table,
230 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
231 );
232}
233
234const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[] = {
235 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
236 .enter_state = scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter,
237 },
238 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
239 .enter_state = scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter,
240 },
241};
242
This page took 0.042543 seconds and 5 git commands to generate.