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