isci: merge ssp task management substates into primary state machine
[deliverable/linux.git] / drivers / scsi / isci / request.h
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
0d84366f 56#ifndef _ISCI_REQUEST_H_
6f231dda
DW
57#define _ISCI_REQUEST_H_
58
59#include "isci.h"
ce2b3261 60#include "host.h"
f1f52e75
DW
61#include "scu_task_context.h"
62#include "stp_request.h"
6f231dda
DW
63
64/**
65 * struct isci_request_status - This enum defines the possible states of an I/O
66 * request.
67 *
68 *
69 */
70enum isci_request_status {
71 unallocated = 0x00,
72 allocated = 0x01,
73 started = 0x02,
74 completed = 0x03,
75 aborting = 0x04,
76 aborted = 0x05,
4dc043c4
JS
77 terminating = 0x06,
78 dead = 0x07
6f231dda
DW
79};
80
81enum task_type {
82 io_task = 0,
83 tmf_task = 1
84};
85
f1f52e75
DW
86enum sci_request_protocol {
87 SCIC_NO_PROTOCOL,
88 SCIC_SMP_PROTOCOL,
89 SCIC_SSP_PROTOCOL,
90 SCIC_STP_PROTOCOL
91}; /* XXX remove me, use sas_task.dev instead */;
92
93struct scic_sds_request {
94 /**
95 * This field contains the information for the base request state machine.
96 */
97 struct sci_base_state_machine state_machine;
98
99 /**
100 * This field simply points to the controller to which this IO request
101 * is associated.
102 */
103 struct scic_sds_controller *owning_controller;
104
105 /**
106 * This field simply points to the remote device to which this IO request
107 * is associated.
108 */
109 struct scic_sds_remote_device *target_device;
110
111 /**
112 * This field is utilized to determine if the SCI user is managing
113 * the IO tag for this request or if the core is managing it.
114 */
115 bool was_tag_assigned_by_user;
116
117 /**
118 * This field indicates the IO tag for this request. The IO tag is
119 * comprised of the task_index and a sequence count. The sequence count
120 * is utilized to help identify tasks from one life to another.
121 */
122 u16 io_tag;
123
124 /**
125 * This field specifies the protocol being utilized for this
126 * IO request.
127 */
128 enum sci_request_protocol protocol;
129
130 /**
131 * This field indicates the completion status taken from the SCUs
132 * completion code. It indicates the completion result for the SCU hardware.
133 */
134 u32 scu_status;
135
136 /**
137 * This field indicates the completion status returned to the SCI user. It
138 * indicates the users view of the io request completion.
139 */
140 u32 sci_status;
141
142 /**
143 * This field contains the value to be utilized when posting (e.g. Post_TC,
144 * Post_TC_Abort) this request to the silicon.
145 */
146 u32 post_context;
147
148 struct scu_task_context *task_context_buffer;
149 struct scu_task_context tc ____cacheline_aligned;
150
151 /* could be larger with sg chaining */
152 #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2)
153 struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
154
155 /**
156 * This field indicates if this request is a task management request or
157 * normal IO request.
158 */
159 bool is_task_management_request;
160
161 /**
162 * This field indicates that this request contains an initialized started
163 * substate machine.
164 */
165 bool has_started_substate_machine;
166
167 /**
168 * This field is a pointer to the stored rx frame data. It is used in STP
169 * internal requests and SMP response frames. If this field is non-NULL the
170 * saved frame must be released on IO request completion.
171 *
172 * @todo In the future do we want to keep a list of RX frame buffers?
173 */
174 u32 saved_rx_frame_index;
175
176 /**
177 * This field specifies the data necessary to manage the sub-state
178 * machine executed while in the SCI_BASE_REQUEST_STATE_STARTED state.
179 */
180 struct sci_base_state_machine started_substate_machine;
181
182 /**
183 * This field specifies the current state handlers in place for this
184 * IO Request object. This field is updated each time the request
185 * changes state.
186 */
187 const struct scic_sds_io_request_state_handler *state_handlers;
188
189 /**
190 * This field in the recorded device sequence for the io request. This is
191 * recorded during the build operation and is compared in the start
192 * operation. If the sequence is different then there was a change of
193 * devices from the build to start operations.
194 */
195 u8 device_sequence;
196
197 union {
198 struct {
199 union {
200 struct ssp_cmd_iu cmd;
201 struct ssp_task_iu tmf;
202 };
203 union {
204 struct ssp_response_iu rsp;
205 u8 rsp_buf[SSP_RESP_IU_MAX_SIZE];
206 };
207 } ssp;
208
209 struct {
210 struct smp_req cmd;
211 struct smp_resp rsp;
212 } smp;
213
214 struct {
215 struct scic_sds_stp_request req;
216 struct host_to_dev_fis cmd;
217 struct dev_to_host_fis rsp;
218 } stp;
219 };
220
221};
222
223static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req)
224{
225 struct scic_sds_request *sci_req;
226
227 sci_req = container_of(stp_req, typeof(*sci_req), stp.req);
228 return sci_req;
229}
230
6f231dda 231struct isci_request {
6f231dda
DW
232 enum isci_request_status status;
233 enum task_type ttype;
234 unsigned short io_tag;
235 bool complete_in_target;
67ea838d 236 bool terminated;
6f231dda
DW
237
238 union ttype_ptr_union {
239 struct sas_task *io_task_ptr; /* When ttype==io_task */
240 struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */
241 } ttype_ptr;
242 struct isci_host *isci_host;
243 struct isci_remote_device *isci_device;
244 /* For use in the requests_to_{complete|abort} lists: */
245 struct list_head completed_node;
246 /* For use in the reqs_in_process list: */
247 struct list_head dev_node;
6f231dda
DW
248 spinlock_t state_lock;
249 dma_addr_t request_daddr;
250 dma_addr_t zero_scatter_daddr;
251
252 unsigned int num_sg_entries; /* returned by pci_alloc_sg */
6f231dda
DW
253
254 /** Note: "io_request_completion" is completed in two different ways
255 * depending on whether this is a TMF or regular request.
256 * - TMF requests are completed in the thread that started them;
257 * - regular requests are completed in the request completion callback
258 * function.
259 * This difference in operation allows the aborter of a TMF request
260 * to be sure that once the TMF request completes, the I/O that the
261 * TMF was aborting is guaranteed to have completed.
262 */
263 struct completion *io_request_completion;
67ea838d 264 struct scic_sds_request sci;
6f231dda
DW
265};
266
67ea838d
DW
267static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_req)
268{
269 struct isci_request *ireq = container_of(sci_req, typeof(*ireq), sci);
270
271 return ireq;
272}
273
f1f52e75
DW
274/**
275 * enum sci_base_request_states - This enumeration depicts all the states for
276 * the common request state machine.
277 *
278 *
279 */
280enum sci_base_request_states {
281 /**
282 * Simply the initial state for the base request state machine.
283 */
284 SCI_BASE_REQUEST_STATE_INITIAL,
285
286 /**
287 * This state indicates that the request has been constructed. This state
288 * is entered from the INITIAL state.
289 */
290 SCI_BASE_REQUEST_STATE_CONSTRUCTED,
291
292 /**
293 * This state indicates that the request has been started. This state is
294 * entered from the CONSTRUCTED state.
295 */
296 SCI_BASE_REQUEST_STATE_STARTED,
297
f139303d
DW
298 /**
299 * The AWAIT_TC_COMPLETION sub-state indicates that the started raw
300 * task management request is waiting for the transmission of the
301 * initial frame (i.e. command, task, etc.).
302 */
303 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION,
304
305 /**
306 * This sub-state indicates that the started task management request
307 * is waiting for the reception of an unsolicited frame
308 * (i.e. response IU).
309 */
310 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE,
311
f1f52e75
DW
312 /**
313 * This state indicates that the request has completed.
314 * This state is entered from the STARTED state. This state is entered from
315 * the ABORTING state.
316 */
317 SCI_BASE_REQUEST_STATE_COMPLETED,
318
319 /**
320 * This state indicates that the request is in the process of being
321 * terminated/aborted.
322 * This state is entered from the CONSTRUCTED state.
323 * This state is entered from the STARTED state.
324 */
325 SCI_BASE_REQUEST_STATE_ABORTING,
326
327 /**
328 * Simply the final state for the base request state machine.
329 */
330 SCI_BASE_REQUEST_STATE_FINAL,
331};
332
333typedef enum sci_status (*scic_sds_io_request_handler_t)
334 (struct scic_sds_request *request);
335typedef enum sci_status (*scic_sds_io_request_frame_handler_t)
336 (struct scic_sds_request *req, u32 frame);
337typedef enum sci_status (*scic_sds_io_request_event_handler_t)
338 (struct scic_sds_request *req, u32 event);
339typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t)
340 (struct scic_sds_request *req, u32 completion_code);
341
342/**
343 * struct scic_sds_io_request_state_handler - This is the SDS core definition
344 * of the state handlers.
345 *
346 *
347 */
348struct scic_sds_io_request_state_handler {
349 /**
350 * The start_handler specifies the method invoked when a user attempts to
351 * start a request.
352 */
353 scic_sds_io_request_handler_t start_handler;
354
355 /**
356 * The abort_handler specifies the method invoked when a user attempts to
357 * abort a request.
358 */
359 scic_sds_io_request_handler_t abort_handler;
360
361 /**
362 * The complete_handler specifies the method invoked when a user attempts to
363 * complete a request.
364 */
365 scic_sds_io_request_handler_t complete_handler;
366
367 scic_sds_io_request_task_completion_handler_t tc_completion_handler;
368 scic_sds_io_request_event_handler_t event_handler;
369 scic_sds_io_request_frame_handler_t frame_handler;
370
371};
372
373extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[];
374
375/**
376 * scic_sds_request_get_controller() -
377 *
378 * This macro will return the controller for this io request object
379 */
380#define scic_sds_request_get_controller(sci_req) \
381 ((sci_req)->owning_controller)
382
383/**
384 * scic_sds_request_get_device() -
385 *
386 * This macro will return the device for this io request object
387 */
388#define scic_sds_request_get_device(sci_req) \
389 ((sci_req)->target_device)
390
391/**
392 * scic_sds_request_get_port() -
393 *
394 * This macro will return the port for this io request object
395 */
396#define scic_sds_request_get_port(sci_req) \
397 scic_sds_remote_device_get_port(scic_sds_request_get_device(sci_req))
398
399/**
400 * scic_sds_request_get_post_context() -
401 *
402 * This macro returns the constructed post context result for the io request.
403 */
404#define scic_sds_request_get_post_context(sci_req) \
405 ((sci_req)->post_context)
406
407/**
408 * scic_sds_request_get_task_context() -
409 *
410 * This is a helper macro to return the os handle for this request object.
411 */
412#define scic_sds_request_get_task_context(request) \
413 ((request)->task_context_buffer)
414
415/**
416 * scic_sds_request_set_status() -
417 *
418 * This macro will set the scu hardware status and sci request completion
419 * status for an io request.
420 */
421#define scic_sds_request_set_status(request, scu_status_code, sci_status_code) \
422 { \
423 (request)->scu_status = (scu_status_code); \
424 (request)->sci_status = (sci_status_code); \
425 }
426
427#define scic_sds_request_complete(a_request) \
428 ((a_request)->state_handlers->complete_handler(a_request))
429
430
431extern enum sci_status
432scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code);
433
434/**
435 * SCU_SGL_ZERO() -
436 *
437 * This macro zeros the hardware SGL element data
438 */
439#define SCU_SGL_ZERO(scu_sge) \
440 { \
441 (scu_sge).length = 0; \
442 (scu_sge).address_lower = 0; \
443 (scu_sge).address_upper = 0; \
444 (scu_sge).address_modifier = 0; \
445 }
446
447/**
448 * SCU_SGL_COPY() -
449 *
450 * This macro copys the SGL Element data from the host os to the hardware SGL
451 * elment data
452 */
453#define SCU_SGL_COPY(scu_sge, os_sge) \
454 { \
455 (scu_sge).length = sg_dma_len(sg); \
456 (scu_sge).address_upper = \
457 upper_32_bits(sg_dma_address(sg)); \
458 (scu_sge).address_lower = \
459 lower_32_bits(sg_dma_address(sg)); \
460 (scu_sge).address_modifier = 0; \
461 }
462
463void scic_sds_request_build_sgl(struct scic_sds_request *sci_req);
464void scic_sds_stp_request_assign_buffers(struct scic_sds_request *sci_req);
465void scic_sds_smp_request_assign_buffers(struct scic_sds_request *sci_req);
466enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req);
467enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req);
f1f52e75
DW
468enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req,
469 u32 event_code);
470enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
471 u32 frame_index);
472enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req);
473enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req);
474
f1f52e75
DW
475
476/**
477 * enum _scic_sds_smp_request_started_substates - This enumeration depicts all
478 * of the substates for a SMP request to be performed in the STARTED
479 * super-state.
480 *
481 *
482 */
483enum scic_sds_smp_request_started_substates {
484 /**
485 * This sub-state indicates that the started task management request
486 * is waiting for the reception of an unsolicited frame
487 * (i.e. response IU).
488 */
489 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE,
490
491 /**
492 * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is
493 * waiting for the transmission of the initial frame (i.e. command, task, etc.).
494 */
495 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION,
496};
497
498
499
500/* XXX open code in caller */
501static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req,
502 dma_addr_t phys_addr)
503{
504 struct isci_request *ireq = sci_req_to_ireq(sci_req);
505 dma_addr_t offset;
506
507 BUG_ON(phys_addr < ireq->request_daddr);
508
509 offset = phys_addr - ireq->request_daddr;
510
511 BUG_ON(offset >= sizeof(*ireq));
512
513 return (char *)ireq + offset;
514}
515
516/* XXX open code in caller */
517static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req,
518 void *virt_addr)
519{
520 struct isci_request *ireq = sci_req_to_ireq(sci_req);
521
522 char *requested_addr = (char *)virt_addr;
523 char *base_addr = (char *)ireq;
524
525 BUG_ON(requested_addr < base_addr);
526 BUG_ON((requested_addr - base_addr) >= sizeof(*ireq));
527
528 return ireq->request_daddr + (requested_addr - base_addr);
529}
530
6f231dda
DW
531/**
532 * This function gets the status of the request object.
533 * @request: This parameter points to the isci_request object
534 *
535 * status of the object as a isci_request_status enum.
536 */
537static inline
538enum isci_request_status isci_request_get_state(
539 struct isci_request *isci_request)
540{
541 BUG_ON(isci_request == NULL);
542
543 /*probably a bad sign... */
544 if (isci_request->status == unallocated)
545 dev_warn(&isci_request->isci_host->pdev->dev,
546 "%s: isci_request->status == unallocated\n",
547 __func__);
548
549 return isci_request->status;
550}
551
552
553/**
554 * isci_request_change_state() - This function sets the status of the request
555 * object.
556 * @request: This parameter points to the isci_request object
557 * @status: This Parameter is the new status of the object
558 *
559 */
560static inline enum isci_request_status isci_request_change_state(
561 struct isci_request *isci_request,
562 enum isci_request_status status)
563{
564 enum isci_request_status old_state;
565 unsigned long flags;
566
567 dev_dbg(&isci_request->isci_host->pdev->dev,
568 "%s: isci_request = %p, state = 0x%x\n",
569 __func__,
570 isci_request,
571 status);
572
573 BUG_ON(isci_request == NULL);
574
575 spin_lock_irqsave(&isci_request->state_lock, flags);
576 old_state = isci_request->status;
577 isci_request->status = status;
578 spin_unlock_irqrestore(&isci_request->state_lock, flags);
579
580 return old_state;
581}
582
583/**
584 * isci_request_change_started_to_newstate() - This function sets the status of
585 * the request object.
586 * @request: This parameter points to the isci_request object
587 * @status: This Parameter is the new status of the object
588 *
589 * state previous to any change.
590 */
591static inline enum isci_request_status isci_request_change_started_to_newstate(
592 struct isci_request *isci_request,
593 struct completion *completion_ptr,
594 enum isci_request_status newstate)
595{
596 enum isci_request_status old_state;
597 unsigned long flags;
598
6f231dda
DW
599 spin_lock_irqsave(&isci_request->state_lock, flags);
600
601 old_state = isci_request->status;
602
f219f010 603 if (old_state == started || old_state == aborting) {
6f231dda
DW
604 BUG_ON(isci_request->io_request_completion != NULL);
605
606 isci_request->io_request_completion = completion_ptr;
607 isci_request->status = newstate;
608 }
609 spin_unlock_irqrestore(&isci_request->state_lock, flags);
610
611 dev_dbg(&isci_request->isci_host->pdev->dev,
612 "%s: isci_request = %p, old_state = 0x%x\n",
613 __func__,
614 isci_request,
615 old_state);
616
617 return old_state;
618}
619
620/**
621 * isci_request_change_started_to_aborted() - This function sets the status of
622 * the request object.
623 * @request: This parameter points to the isci_request object
624 * @completion_ptr: This parameter is saved as the kernel completion structure
625 * signalled when the old request completes.
626 *
627 * state previous to any change.
628 */
629static inline enum isci_request_status isci_request_change_started_to_aborted(
630 struct isci_request *isci_request,
631 struct completion *completion_ptr)
632{
633 return isci_request_change_started_to_newstate(
634 isci_request, completion_ptr, aborted
635 );
636}
637/**
638 * isci_request_free() - This function frees the request object.
639 * @isci_host: This parameter specifies the ISCI host object
640 * @isci_request: This parameter points to the isci_request object
641 *
642 */
643static inline void isci_request_free(
644 struct isci_host *isci_host,
645 struct isci_request *isci_request)
646{
6cb4d6b3
BB
647 if (!isci_request)
648 return;
6f231dda
DW
649
650 /* release the dma memory if we fail. */
651 dma_pool_free(isci_host->dma_pool, isci_request,
652 isci_request->request_daddr);
653}
654
655
656/* #define ISCI_REQUEST_VALIDATE_ACCESS
657 */
658
659#ifdef ISCI_REQUEST_VALIDATE_ACCESS
660
661static inline
662struct sas_task *isci_request_access_task(struct isci_request *isci_request)
663{
664 BUG_ON(isci_request->ttype != io_task);
665 return isci_request->ttype_ptr.io_task_ptr;
666}
667
668static inline
669struct isci_tmf *isci_request_access_tmf(struct isci_request *isci_request)
670{
671 BUG_ON(isci_request->ttype != tmf_task);
672 return isci_request->ttype_ptr.tmf_task_ptr;
673}
674
675#else /* not ISCI_REQUEST_VALIDATE_ACCESS */
676
677#define isci_request_access_task(RequestPtr) \
678 ((RequestPtr)->ttype_ptr.io_task_ptr)
679
680#define isci_request_access_tmf(RequestPtr) \
681 ((RequestPtr)->ttype_ptr.tmf_task_ptr)
682
683#endif /* not ISCI_REQUEST_VALIDATE_ACCESS */
684
685
686int isci_request_alloc_tmf(
687 struct isci_host *isci_host,
688 struct isci_tmf *isci_tmf,
689 struct isci_request **isci_request,
690 struct isci_remote_device *isci_device,
691 gfp_t gfp_flags);
692
693
694int isci_request_execute(
695 struct isci_host *isci_host,
696 struct sas_task *task,
697 struct isci_request **request,
698 gfp_t gfp_flags);
699
700/**
701 * isci_request_unmap_sgl() - This function unmaps the DMA address of a given
702 * sgl
703 * @request: This parameter points to the isci_request object
704 * @*pdev: This Parameter is the pci_device struct for the controller
705 *
706 */
707static inline void isci_request_unmap_sgl(
708 struct isci_request *request,
709 struct pci_dev *pdev)
710{
711 struct sas_task *task = isci_request_access_task(request);
712
713 dev_dbg(&request->isci_host->pdev->dev,
714 "%s: request = %p, task = %p,\n"
715 "task->data_dir = %d, is_sata = %d\n ",
716 __func__,
717 request,
718 task,
719 task->data_dir,
720 sas_protocol_ata(task->task_proto));
721
722 if ((task->data_dir != PCI_DMA_NONE) &&
723 !sas_protocol_ata(task->task_proto)) {
724 if (task->num_scatter == 0)
725 /* 0 indicates a single dma address */
726 dma_unmap_single(
727 &pdev->dev,
728 request->zero_scatter_daddr,
729 task->total_xfer_len,
730 task->data_dir
731 );
732
733 else /* unmap the sgl dma addresses */
734 dma_unmap_sg(
735 &pdev->dev,
736 task->scatter,
737 request->num_sg_entries,
738 task->data_dir
739 );
740 }
741}
742
6f231dda
DW
743/**
744 * isci_request_io_request_get_next_sge() - This function is called by the sci
745 * core to retrieve the next sge for a given request.
746 * @request: This parameter is the isci_request object.
747 * @current_sge_address: This parameter is the last sge retrieved by the sci
748 * core for this request.
749 *
750 * pointer to the next sge for specified request.
751 */
752static inline void *isci_request_io_request_get_next_sge(
753 struct isci_request *request,
754 void *current_sge_address)
755{
756 struct sas_task *task = isci_request_access_task(request);
757 void *ret = NULL;
758
759 dev_dbg(&request->isci_host->pdev->dev,
760 "%s: request = %p, "
761 "current_sge_address = %p, "
762 "num_scatter = %d\n",
763 __func__,
764 request,
765 current_sge_address,
766 task->num_scatter);
767
768 if (!current_sge_address) /* First time through.. */
769 ret = task->scatter; /* always task->scatter */
770 else if (task->num_scatter == 0) /* Next element, if num_scatter == 0 */
771 ret = NULL; /* there is only one element. */
772 else
773 ret = sg_next(current_sge_address); /* sg_next returns NULL
774 * for the last element
775 */
776
777 dev_dbg(&request->isci_host->pdev->dev,
778 "%s: next sge address = %p\n",
779 __func__,
780 ret);
781
782 return ret;
783}
784
f1f52e75
DW
785void isci_terminate_pending_requests(struct isci_host *isci_host,
786 struct isci_remote_device *isci_device,
787 enum isci_request_status new_request_state);
788enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
789 struct scic_sds_remote_device *sci_dev,
790 u16 io_tag,
791 struct scic_sds_request *sci_req);
792enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req);
793enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req);
794enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req);
795void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag);
796void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req);
6f231dda 797#endif /* !defined(_ISCI_REQUEST_H_) */
This page took 0.063447 seconds and 5 git commands to generate.