blob: 7a1d5a9778eba04c557ae68fe7a20147d4debd6a [file] [log] [blame]
Dan Williams6f231dd2011-07-02 22:56:22 -07001/*
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 Williams0d843662011-05-08 01:56:57 -070056#ifndef _ISCI_REQUEST_H_
Dan Williams6f231dd2011-07-02 22:56:22 -070057#define _ISCI_REQUEST_H_
58
59#include "isci.h"
Dan Williamsce2b3262011-05-08 15:49:15 -070060#include "host.h"
Dan Williamsf1f52e72011-05-10 02:28:45 -070061#include "scu_task_context.h"
Dan Williams6f231dd2011-07-02 22:56:22 -070062
63/**
64 * struct isci_request_status - This enum defines the possible states of an I/O
65 * request.
66 *
67 *
68 */
69enum isci_request_status {
70 unallocated = 0x00,
71 allocated = 0x01,
72 started = 0x02,
73 completed = 0x03,
74 aborting = 0x04,
75 aborted = 0x05,
Jeff Skirvin4dc043c2011-03-04 14:06:52 -080076 terminating = 0x06,
77 dead = 0x07
Dan Williams6f231dd2011-07-02 22:56:22 -070078};
79
80enum task_type {
81 io_task = 0,
82 tmf_task = 1
83};
84
Dan Williamsf1f52e72011-05-10 02:28:45 -070085enum sci_request_protocol {
86 SCIC_NO_PROTOCOL,
87 SCIC_SMP_PROTOCOL,
88 SCIC_SSP_PROTOCOL,
89 SCIC_STP_PROTOCOL
Dan Williamsc72086e2011-05-10 02:28:48 -070090}; /* XXX remove me, use sas_task.{dev|task_proto} instead */;
Dan Williamsf1f52e72011-05-10 02:28:45 -070091
Dan Williamsba7cb222011-06-27 11:56:41 -070092/**
93 * isci_stp_request - extra request infrastructure to handle pio/atapi protocol
94 * @pio_len - number of bytes requested at PIO setup
95 * @status - pio setup ending status value to tell us if we need
Dan Williams5076a1a2011-06-27 14:57:03 -070096 * to wait for another fis or if the transfer is complete. Upon
Dan Williamsba7cb222011-06-27 11:56:41 -070097 * receipt of a d2h fis this will be the status field of that fis.
98 * @sgl - track pio transfer progress as we iterate through the sgl
99 * @device_cdb_len - atapi device advertises it's transfer constraints at setup
100 */
101struct isci_stp_request {
102 u32 pio_len;
103 u8 status;
Dan Williams5dec6f42011-05-10 02:28:49 -0700104
Dan Williamsba7cb222011-06-27 11:56:41 -0700105 struct isci_stp_pio_sgl {
106 int index;
107 u8 set;
108 u32 offset;
109 } sgl;
110 u32 device_cdb_len;
Dan Williams5dec6f42011-05-10 02:28:49 -0700111};
112
Dan Williams5076a1a2011-06-27 14:57:03 -0700113struct isci_request {
114 enum isci_request_status status;
115 #define IREQ_COMPLETE_IN_TARGET 0
116 #define IREQ_TERMINATED 1
117 #define IREQ_TMF 2
118 #define IREQ_ACTIVE 3
119 unsigned long flags;
120 /* XXX kill ttype and ttype_ptr, allocate full sas_task */
121 enum task_type ttype;
122 union ttype_ptr_union {
123 struct sas_task *io_task_ptr; /* When ttype==io_task */
124 struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */
125 } ttype_ptr;
126 struct isci_host *isci_host;
127 /* For use in the requests_to_{complete|abort} lists: */
128 struct list_head completed_node;
129 /* For use in the reqs_in_process list: */
130 struct list_head dev_node;
131 spinlock_t state_lock;
132 dma_addr_t request_daddr;
133 dma_addr_t zero_scatter_daddr;
134 unsigned int num_sg_entries;
135 /* Note: "io_request_completion" is completed in two different ways
136 * depending on whether this is a TMF or regular request.
137 * - TMF requests are completed in the thread that started them;
138 * - regular requests are completed in the request completion callback
139 * function.
140 * This difference in operation allows the aborter of a TMF request
141 * to be sure that once the TMF request completes, the I/O that the
142 * TMF was aborting is guaranteed to have completed.
143 *
144 * XXX kill io_request_completion
Dan Williamsf1f52e72011-05-10 02:28:45 -0700145 */
Dan Williams5076a1a2011-06-27 14:57:03 -0700146 struct completion *io_request_completion;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000147 struct sci_base_state_machine sm;
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700148 struct isci_host *owning_controller;
Dan Williams78a6f062011-06-30 16:31:37 -0700149 struct isci_remote_device *target_device;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700150 u16 io_tag;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700151 enum sci_request_protocol protocol;
Dan Williams5076a1a2011-06-27 14:57:03 -0700152 u32 scu_status; /* hardware result */
153 u32 sci_status; /* upper layer disposition */
Dan Williamsf1f52e72011-05-10 02:28:45 -0700154 u32 post_context;
Dan Williams312e0c22011-06-28 13:47:09 -0700155 struct scu_task_context *tc;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700156 /* could be larger with sg chaining */
Dan Williams7c78da32011-06-01 16:00:01 -0700157 #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2)
Dan Williamsf1f52e72011-05-10 02:28:45 -0700158 struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
Dan Williams5076a1a2011-06-27 14:57:03 -0700159 /* This field is a pointer to the stored rx frame data. It is used in
Edmund Nadolskie3013702011-06-02 00:10:43 +0000160 * STP internal requests and SMP response frames. If this field is
161 * non-NULL the saved frame must be released on IO request completion.
Dan Williamsf1f52e72011-05-10 02:28:45 -0700162 */
163 u32 saved_rx_frame_index;
164
Dan Williamsf1f52e72011-05-10 02:28:45 -0700165 union {
166 struct {
167 union {
168 struct ssp_cmd_iu cmd;
169 struct ssp_task_iu tmf;
170 };
171 union {
172 struct ssp_response_iu rsp;
173 u8 rsp_buf[SSP_RESP_IU_MAX_SIZE];
174 };
175 } ssp;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700176 struct {
Dan Williamsf1f52e72011-05-10 02:28:45 -0700177 struct smp_resp rsp;
178 } smp;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700179 struct {
Dan Williamsba7cb222011-06-27 11:56:41 -0700180 struct isci_stp_request req;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700181 struct host_to_dev_fis cmd;
182 struct dev_to_host_fis rsp;
183 } stp;
184 };
Dan Williamsf1f52e72011-05-10 02:28:45 -0700185};
186
Dan Williams5076a1a2011-06-27 14:57:03 -0700187static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req)
Dan Williamsf1f52e72011-05-10 02:28:45 -0700188{
Dan Williams5076a1a2011-06-27 14:57:03 -0700189 struct isci_request *ireq;
Dan Williamsf1f52e72011-05-10 02:28:45 -0700190
Dan Williams5076a1a2011-06-27 14:57:03 -0700191 ireq = container_of(stp_req, typeof(*ireq), stp.req);
Dan Williams67ea8382011-05-08 11:47:15 -0700192 return ireq;
193}
194
Dan Williams6f231dd2011-07-02 22:56:22 -0700195/**
Dan Williamsf1f52e72011-05-10 02:28:45 -0700196 * enum sci_base_request_states - This enumeration depicts all the states for
197 * the common request state machine.
198 *
199 *
200 */
201enum sci_base_request_states {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000202 /*
Dan Williamsf1f52e72011-05-10 02:28:45 -0700203 * Simply the initial state for the base request state machine.
204 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000205 SCI_REQ_INIT,
Dan Williamsf1f52e72011-05-10 02:28:45 -0700206
Edmund Nadolskie3013702011-06-02 00:10:43 +0000207 /*
208 * This state indicates that the request has been constructed.
209 * This state is entered from the INITIAL state.
Dan Williamsf1f52e72011-05-10 02:28:45 -0700210 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000211 SCI_REQ_CONSTRUCTED,
Dan Williamsf1f52e72011-05-10 02:28:45 -0700212
Edmund Nadolskie3013702011-06-02 00:10:43 +0000213 /*
214 * This state indicates that the request has been started. This state
215 * is entered from the CONSTRUCTED state.
Dan Williamsf1f52e72011-05-10 02:28:45 -0700216 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000217 SCI_REQ_STARTED,
Dan Williamsf1f52e72011-05-10 02:28:45 -0700218
Edmund Nadolskie3013702011-06-02 00:10:43 +0000219 SCI_REQ_STP_UDMA_WAIT_TC_COMP,
220 SCI_REQ_STP_UDMA_WAIT_D2H,
Dan Williams5dec6f42011-05-10 02:28:49 -0700221
Edmund Nadolskie3013702011-06-02 00:10:43 +0000222 SCI_REQ_STP_NON_DATA_WAIT_H2D,
223 SCI_REQ_STP_NON_DATA_WAIT_D2H,
Dan Williams5dec6f42011-05-10 02:28:49 -0700224
Edmund Nadolskie3013702011-06-02 00:10:43 +0000225 SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED,
226 SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG,
227 SCI_REQ_STP_SOFT_RESET_WAIT_D2H,
Dan Williams5dec6f42011-05-10 02:28:49 -0700228
Edmund Nadolskie3013702011-06-02 00:10:43 +0000229 /*
230 * While in this state the IO request object is waiting for the TC
231 * completion notification for the H2D Register FIS
Dan Williams5dec6f42011-05-10 02:28:49 -0700232 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000233 SCI_REQ_STP_PIO_WAIT_H2D,
Dan Williams5dec6f42011-05-10 02:28:49 -0700234
Edmund Nadolskie3013702011-06-02 00:10:43 +0000235 /*
236 * While in this state the IO request object is waiting for either a
237 * PIO Setup FIS or a D2H register FIS. The type of frame received is
238 * based on the result of the prior frame and line conditions.
Dan Williams5dec6f42011-05-10 02:28:49 -0700239 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000240 SCI_REQ_STP_PIO_WAIT_FRAME,
Dan Williams5dec6f42011-05-10 02:28:49 -0700241
Edmund Nadolskie3013702011-06-02 00:10:43 +0000242 /*
243 * While in this state the IO request object is waiting for a DATA
244 * frame from the device.
Dan Williams5dec6f42011-05-10 02:28:49 -0700245 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000246 SCI_REQ_STP_PIO_DATA_IN,
Dan Williams5dec6f42011-05-10 02:28:49 -0700247
Edmund Nadolskie3013702011-06-02 00:10:43 +0000248 /*
249 * While in this state the IO request object is waiting to transmit
250 * the next data frame to the device.
Dan Williams5dec6f42011-05-10 02:28:49 -0700251 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000252 SCI_REQ_STP_PIO_DATA_OUT,
Dan Williams5dec6f42011-05-10 02:28:49 -0700253
Edmund Nadolskie3013702011-06-02 00:10:43 +0000254 /*
Dan Williamsf1393032011-05-10 02:28:47 -0700255 * The AWAIT_TC_COMPLETION sub-state indicates that the started raw
256 * task management request is waiting for the transmission of the
257 * initial frame (i.e. command, task, etc.).
258 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000259 SCI_REQ_TASK_WAIT_TC_COMP,
Dan Williamsf1393032011-05-10 02:28:47 -0700260
Edmund Nadolskie3013702011-06-02 00:10:43 +0000261 /*
Dan Williamsf1393032011-05-10 02:28:47 -0700262 * This sub-state indicates that the started task management request
263 * is waiting for the reception of an unsolicited frame
264 * (i.e. response IU).
265 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000266 SCI_REQ_TASK_WAIT_TC_RESP,
Dan Williamsf1393032011-05-10 02:28:47 -0700267
Edmund Nadolskie3013702011-06-02 00:10:43 +0000268 /*
Dan Williamsc72086e2011-05-10 02:28:48 -0700269 * This sub-state indicates that the started task management request
270 * is waiting for the reception of an unsolicited frame
271 * (i.e. response IU).
272 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000273 SCI_REQ_SMP_WAIT_RESP,
Dan Williamsc72086e2011-05-10 02:28:48 -0700274
Edmund Nadolskie3013702011-06-02 00:10:43 +0000275 /*
276 * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP
277 * request is waiting for the transmission of the initial frame
278 * (i.e. command, task, etc.).
Dan Williamsc72086e2011-05-10 02:28:48 -0700279 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000280 SCI_REQ_SMP_WAIT_TC_COMP,
Dan Williamsc72086e2011-05-10 02:28:48 -0700281
Edmund Nadolskie3013702011-06-02 00:10:43 +0000282 /*
Dan Williamsf1f52e72011-05-10 02:28:45 -0700283 * This state indicates that the request has completed.
Edmund Nadolskie3013702011-06-02 00:10:43 +0000284 * This state is entered from the STARTED state. This state is entered
285 * from the ABORTING state.
Dan Williamsf1f52e72011-05-10 02:28:45 -0700286 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000287 SCI_REQ_COMPLETED,
Dan Williamsf1f52e72011-05-10 02:28:45 -0700288
Edmund Nadolskie3013702011-06-02 00:10:43 +0000289 /*
Dan Williamsf1f52e72011-05-10 02:28:45 -0700290 * This state indicates that the request is in the process of being
291 * terminated/aborted.
292 * This state is entered from the CONSTRUCTED state.
293 * This state is entered from the STARTED state.
294 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000295 SCI_REQ_ABORTING,
Dan Williamsf1f52e72011-05-10 02:28:45 -0700296
Edmund Nadolskie3013702011-06-02 00:10:43 +0000297 /*
Dan Williamsf1f52e72011-05-10 02:28:45 -0700298 * Simply the final state for the base request state machine.
299 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000300 SCI_REQ_FINAL,
Dan Williamsf1f52e72011-05-10 02:28:45 -0700301};
302
Dan Williams89a73012011-06-30 19:14:33 -0700303enum sci_status sci_request_start(struct isci_request *ireq);
304enum sci_status sci_io_request_terminate(struct isci_request *ireq);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000305enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700306sci_io_request_event_handler(struct isci_request *ireq,
Edmund Nadolskie3013702011-06-02 00:10:43 +0000307 u32 event_code);
308enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700309sci_io_request_frame_handler(struct isci_request *ireq,
Edmund Nadolskie3013702011-06-02 00:10:43 +0000310 u32 frame_index);
311enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700312sci_task_request_terminate(struct isci_request *ireq);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000313extern enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700314sci_request_complete(struct isci_request *ireq);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000315extern enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700316sci_io_request_tc_completion(struct isci_request *ireq, u32 code);
Dan Williamsf1f52e72011-05-10 02:28:45 -0700317
Dan Williamsf1f52e72011-05-10 02:28:45 -0700318/* XXX open code in caller */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000319static inline dma_addr_t
Dan Williams89a73012011-06-30 19:14:33 -0700320sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr)
Dan Williamsf1f52e72011-05-10 02:28:45 -0700321{
Dan Williamsf1f52e72011-05-10 02:28:45 -0700322
323 char *requested_addr = (char *)virt_addr;
324 char *base_addr = (char *)ireq;
325
326 BUG_ON(requested_addr < base_addr);
327 BUG_ON((requested_addr - base_addr) >= sizeof(*ireq));
328
329 return ireq->request_daddr + (requested_addr - base_addr);
330}
331
332/**
Dan Williams6f231dd2011-07-02 22:56:22 -0700333 * isci_request_change_state() - This function sets the status of the request
334 * object.
335 * @request: This parameter points to the isci_request object
336 * @status: This Parameter is the new status of the object
337 *
338 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000339static inline enum isci_request_status
340isci_request_change_state(struct isci_request *isci_request,
341 enum isci_request_status status)
Dan Williams6f231dd2011-07-02 22:56:22 -0700342{
343 enum isci_request_status old_state;
344 unsigned long flags;
345
346 dev_dbg(&isci_request->isci_host->pdev->dev,
347 "%s: isci_request = %p, state = 0x%x\n",
348 __func__,
349 isci_request,
350 status);
351
352 BUG_ON(isci_request == NULL);
353
354 spin_lock_irqsave(&isci_request->state_lock, flags);
355 old_state = isci_request->status;
356 isci_request->status = status;
357 spin_unlock_irqrestore(&isci_request->state_lock, flags);
358
359 return old_state;
360}
361
362/**
363 * isci_request_change_started_to_newstate() - This function sets the status of
364 * the request object.
365 * @request: This parameter points to the isci_request object
366 * @status: This Parameter is the new status of the object
367 *
368 * state previous to any change.
369 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000370static inline enum isci_request_status
371isci_request_change_started_to_newstate(struct isci_request *isci_request,
372 struct completion *completion_ptr,
373 enum isci_request_status newstate)
Dan Williams6f231dd2011-07-02 22:56:22 -0700374{
375 enum isci_request_status old_state;
376 unsigned long flags;
377
Dan Williams6f231dd2011-07-02 22:56:22 -0700378 spin_lock_irqsave(&isci_request->state_lock, flags);
379
380 old_state = isci_request->status;
381
Jeff Skirvinf219f012011-03-31 13:10:34 -0700382 if (old_state == started || old_state == aborting) {
Dan Williams6f231dd2011-07-02 22:56:22 -0700383 BUG_ON(isci_request->io_request_completion != NULL);
384
385 isci_request->io_request_completion = completion_ptr;
386 isci_request->status = newstate;
387 }
Edmund Nadolskie3013702011-06-02 00:10:43 +0000388
Dan Williams6f231dd2011-07-02 22:56:22 -0700389 spin_unlock_irqrestore(&isci_request->state_lock, flags);
390
391 dev_dbg(&isci_request->isci_host->pdev->dev,
392 "%s: isci_request = %p, old_state = 0x%x\n",
393 __func__,
394 isci_request,
395 old_state);
396
397 return old_state;
398}
399
400/**
401 * isci_request_change_started_to_aborted() - This function sets the status of
402 * the request object.
403 * @request: This parameter points to the isci_request object
404 * @completion_ptr: This parameter is saved as the kernel completion structure
405 * signalled when the old request completes.
406 *
407 * state previous to any change.
408 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000409static inline enum isci_request_status
410isci_request_change_started_to_aborted(struct isci_request *isci_request,
411 struct completion *completion_ptr)
Dan Williams6f231dd2011-07-02 22:56:22 -0700412{
Edmund Nadolskie3013702011-06-02 00:10:43 +0000413 return isci_request_change_started_to_newstate(isci_request,
414 completion_ptr,
415 aborted);
Dan Williams6f231dd2011-07-02 22:56:22 -0700416}
Dan Williams6f231dd2011-07-02 22:56:22 -0700417
Edmund Nadolskie3013702011-06-02 00:10:43 +0000418#define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr)
Dan Williams6f231dd2011-07-02 22:56:22 -0700419
Edmund Nadolskie3013702011-06-02 00:10:43 +0000420#define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr)
Dan Williams6f231dd2011-07-02 22:56:22 -0700421
Dan Williamsdb056252011-06-17 14:18:39 -0700422struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost,
423 struct isci_tmf *isci_tmf,
424 u16 tag);
Dan Williams209fae12011-06-13 17:39:44 -0700425int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev,
Dan Williamsdb056252011-06-17 14:18:39 -0700426 struct sas_task *task, u16 tag);
Dan Williamsddcc7e32011-06-17 10:40:43 -0700427void isci_terminate_pending_requests(struct isci_host *ihost,
428 struct isci_remote_device *idev);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000429enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700430sci_task_request_construct(struct isci_host *ihost,
Dan Williams78a6f062011-06-30 16:31:37 -0700431 struct isci_remote_device *idev,
Edmund Nadolskie3013702011-06-02 00:10:43 +0000432 u16 io_tag,
Dan Williams5076a1a2011-06-27 14:57:03 -0700433 struct isci_request *ireq);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000434enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700435sci_task_request_construct_ssp(struct isci_request *ireq);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000436enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -0700437sci_task_request_construct_sata(struct isci_request *ireq);
Dan Williams89a73012011-06-30 19:14:33 -0700438void sci_smp_request_copy_response(struct isci_request *ireq);
Jeff Skirvin9274f452011-06-23 17:09:02 -0700439
440static inline int isci_task_is_ncq_recovery(struct sas_task *task)
441{
442 return (sas_protocol_ata(task->task_proto) &&
James Bottomleya5ec7f862011-07-03 14:14:45 -0500443 task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT &&
444 task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ);
Jeff Skirvin9274f452011-06-23 17:09:02 -0700445
446}
447
Dan Williams6f231dd2011-07-02 22:56:22 -0700448#endif /* !defined(_ISCI_REQUEST_H_) */