blob: c88e270b2b40b116518fbbd63841f2cfcb7534f6 [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
56#include "isci.h"
57#include "scic_remote_device.h"
58#include "scic_io_request.h"
59#include "scic_task_request.h"
60#include "scic_port.h"
61#include "task.h"
62#include "request.h"
63#include "sata.h"
64#include "scu_completion_codes.h"
65
66
67static enum sci_status isci_request_ssp_request_construct(
68 struct isci_request *request)
69{
70 enum sci_status status;
71
72 dev_dbg(&request->isci_host->pdev->dev,
73 "%s: request = %p\n",
74 __func__,
75 request);
76 status = scic_io_request_construct_basic_ssp(
77 request->sci_request_handle
78 );
79 return status;
80}
81
82static enum sci_status isci_request_stp_request_construct(
83 struct isci_request *request)
84{
85 struct sas_task *task = isci_request_access_task(request);
86 enum sci_status status;
87 struct host_to_dev_fis *register_fis;
88
89 dev_dbg(&request->isci_host->pdev->dev,
90 "%s: request = %p\n",
91 __func__,
92 request);
93
94 /* Get the host_to_dev_fis from the core and copy
95 * the fis from the task into it.
96 */
97 register_fis = isci_sata_task_to_fis_copy(task);
98
99 status = scic_io_request_construct_basic_sata(
100 request->sci_request_handle
101 );
102
103 /* Set the ncq tag in the fis, from the queue
104 * command in the task.
105 */
106 if (isci_sata_is_task_ncq(task)) {
107
108 isci_sata_set_ncq_tag(
109 register_fis,
110 task
111 );
112 }
113
114 return status;
115}
116
117/**
118 * isci_smp_request_build() - This function builds the smp request object.
119 * @isci_host: This parameter specifies the ISCI host object
120 * @request: This parameter points to the isci_request object allocated in the
121 * request construct function.
122 * @sci_device: This parameter is the handle for the sci core's remote device
123 * object that is the destination for this request.
124 *
125 * SCI_SUCCESS on successfull completion, or specific failure code.
126 */
127static enum sci_status isci_smp_request_build(
128 struct isci_request *request)
129{
130 enum sci_status status = SCI_FAILURE;
131 struct sas_task *task = isci_request_access_task(request);
132
133 void *command_iu_address =
134 scic_io_request_get_command_iu_address(
135 request->sci_request_handle
136 );
137
138 dev_dbg(&request->isci_host->pdev->dev,
139 "%s: request = %p\n",
140 __func__,
141 request);
142 dev_dbg(&request->isci_host->pdev->dev,
143 "%s: smp_req len = %d\n",
144 __func__,
145 task->smp_task.smp_req.length);
146
147 /* copy the smp_command to the address; */
148 sg_copy_to_buffer(&task->smp_task.smp_req, 1,
149 (char *)command_iu_address,
150 sizeof(struct smp_request)
151 );
152
153 status = scic_io_request_construct_smp(request->sci_request_handle);
154 if (status != SCI_SUCCESS)
155 dev_warn(&request->isci_host->pdev->dev,
156 "%s: scic_io_request_construct_smp failed with "
157 "status = %d\n",
158 __func__,
159 status);
160
161 return status;
162}
163
164/**
165 * isci_io_request_build() - This function builds the io request object.
166 * @isci_host: This parameter specifies the ISCI host object
167 * @request: This parameter points to the isci_request object allocated in the
168 * request construct function.
169 * @sci_device: This parameter is the handle for the sci core's remote device
170 * object that is the destination for this request.
171 *
172 * SCI_SUCCESS on successfull completion, or specific failure code.
173 */
174static enum sci_status isci_io_request_build(
175 struct isci_host *isci_host,
176 struct isci_request *request,
177 struct isci_remote_device *isci_device)
178{
179 struct smp_discover_response_protocols dev_protocols;
180 enum sci_status status = SCI_SUCCESS;
181 struct sas_task *task = isci_request_access_task(request);
Dan Williams3a97eec2011-03-04 11:51:43 -0800182 struct scic_sds_remote_device *sci_device = to_sci_dev(isci_device);
Dan Williams6f231dd2011-07-02 22:56:22 -0700183
184 dev_dbg(&isci_host->pdev->dev,
185 "%s: isci_device = 0x%p; request = %p, "
186 "num_scatter = %d\n",
187 __func__,
188 isci_device,
189 request,
190 task->num_scatter);
191
192 /* map the sgl addresses, if present.
193 * libata does the mapping for sata devices
194 * before we get the request.
195 */
196 if (task->num_scatter &&
197 !sas_protocol_ata(task->task_proto) &&
198 !(SAS_PROTOCOL_SMP & task->task_proto)) {
199
200 request->num_sg_entries = dma_map_sg(
201 &isci_host->pdev->dev,
202 task->scatter,
203 task->num_scatter,
204 task->data_dir
205 );
206
207 if (request->num_sg_entries == 0)
208 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
209 }
210
211 /* build the common request object. For now,
212 * we will let the core allocate the IO tag.
213 */
214 status = scic_io_request_construct(
215 isci_host->core_controller,
216 sci_device,
217 SCI_CONTROLLER_INVALID_IO_TAG,
218 request,
219 request->sci_request_mem_ptr,
220 (struct scic_sds_request **)&request->sci_request_handle
221 );
222
223 if (status != SCI_SUCCESS) {
224 dev_warn(&isci_host->pdev->dev,
225 "%s: failed request construct\n",
226 __func__);
227 return SCI_FAILURE;
228 }
229
230 sci_object_set_association(request->sci_request_handle, request);
231
232 /* Determine protocol and call the appropriate basic constructor */
233 scic_remote_device_get_protocols(sci_device, &dev_protocols);
234 if (dev_protocols.u.bits.attached_ssp_target)
235 status = isci_request_ssp_request_construct(request);
236 else if (dev_protocols.u.bits.attached_stp_target)
237 status = isci_request_stp_request_construct(request);
238 else if (dev_protocols.u.bits.attached_smp_target)
239 status = isci_smp_request_build(request);
240 else {
241 dev_warn(&isci_host->pdev->dev,
242 "%s: unknown protocol\n", __func__);
243 return SCI_FAILURE;
244 }
245
246 return SCI_SUCCESS;
247}
248
249
250/**
251 * isci_request_alloc_core() - This function gets the request object from the
252 * isci_host dma cache.
253 * @isci_host: This parameter specifies the ISCI host object
254 * @isci_request: This parameter will contain the pointer to the new
255 * isci_request object.
256 * @isci_device: This parameter is the pointer to the isci remote device object
257 * that is the destination for this request.
258 * @gfp_flags: This parameter specifies the os allocation flags.
259 *
260 * SCI_SUCCESS on successfull completion, or specific failure code.
261 */
262static int isci_request_alloc_core(
263 struct isci_host *isci_host,
264 struct isci_request **isci_request,
265 struct isci_remote_device *isci_device,
266 gfp_t gfp_flags)
267{
268 int ret = 0;
269 dma_addr_t handle;
270 struct isci_request *request;
271
272
273 /* get pointer to dma memory. This actually points
274 * to both the isci_remote_device object and the
275 * sci object. The isci object is at the beginning
276 * of the memory allocated here.
277 */
278 request = dma_pool_alloc(isci_host->dma_pool, gfp_flags, &handle);
279 if (!request) {
280 dev_warn(&isci_host->pdev->dev,
281 "%s: dma_pool_alloc returned NULL\n", __func__);
282 return -ENOMEM;
283 }
284
285 /* initialize the request object. */
286 spin_lock_init(&request->state_lock);
Dan Williams6f231dd2011-07-02 22:56:22 -0700287 request->sci_request_mem_ptr = ((u8 *)request) +
288 sizeof(struct isci_request);
289 request->request_daddr = handle;
290 request->isci_host = isci_host;
291 request->isci_device = isci_device;
292 request->io_request_completion = NULL;
293
294 request->request_alloc_size = isci_host->dma_pool_alloc_size;
295 request->num_sg_entries = 0;
296
297 request->complete_in_target = false;
298
299 INIT_LIST_HEAD(&request->completed_node);
300 INIT_LIST_HEAD(&request->dev_node);
301
302 *isci_request = request;
Dan Williams83f5eee2011-02-18 09:25:15 -0800303 isci_request_change_state(request, allocated);
Dan Williams6f231dd2011-07-02 22:56:22 -0700304
305 return ret;
306}
307
308static int isci_request_alloc_io(
309 struct isci_host *isci_host,
310 struct sas_task *task,
311 struct isci_request **isci_request,
312 struct isci_remote_device *isci_device,
313 gfp_t gfp_flags)
314{
315 int retval = isci_request_alloc_core(isci_host, isci_request,
316 isci_device, gfp_flags);
317
318 if (!retval) {
319 (*isci_request)->ttype_ptr.io_task_ptr = task;
320 (*isci_request)->ttype = io_task;
321
322 task->lldd_task = *isci_request;
323 }
324 return retval;
325}
326
327/**
328 * isci_request_alloc_tmf() - This function gets the request object from the
329 * isci_host dma cache and initializes the relevant fields as a sas_task.
330 * @isci_host: This parameter specifies the ISCI host object
331 * @sas_task: This parameter is the task struct from the upper layer driver.
332 * @isci_request: This parameter will contain the pointer to the new
333 * isci_request object.
334 * @isci_device: This parameter is the pointer to the isci remote device object
335 * that is the destination for this request.
336 * @gfp_flags: This parameter specifies the os allocation flags.
337 *
338 * SCI_SUCCESS on successfull completion, or specific failure code.
339 */
340int isci_request_alloc_tmf(
341 struct isci_host *isci_host,
342 struct isci_tmf *isci_tmf,
343 struct isci_request **isci_request,
344 struct isci_remote_device *isci_device,
345 gfp_t gfp_flags)
346{
347 int retval = isci_request_alloc_core(isci_host, isci_request,
348 isci_device, gfp_flags);
349
350 if (!retval) {
351
352 (*isci_request)->ttype_ptr.tmf_task_ptr = isci_tmf;
353 (*isci_request)->ttype = tmf_task;
354 }
355 return retval;
356}
357
358/**
359 * isci_request_signal_device_reset() - This function will set the "device
360 * needs target reset" flag in the given sas_tasks' task_state_flags, and
361 * then cause the task to be added into the SCSI error handler queue which
362 * will eventually be escalated to a target reset.
363 *
364 *
365 */
366static void isci_request_signal_device_reset(
367 struct isci_request *isci_request)
368{
369 unsigned long flags;
370 struct sas_task *task = isci_request_access_task(isci_request);
371
372 dev_dbg(&isci_request->isci_host->pdev->dev,
373 "%s: request=%p, task=%p\n", __func__, isci_request, task);
374
375 spin_lock_irqsave(&task->task_state_lock, flags);
376 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
377 spin_unlock_irqrestore(&task->task_state_lock, flags);
378
379 /* Cause this task to be scheduled in the SCSI error handler
380 * thread.
381 */
382 sas_task_abort(task);
383}
384
385/**
386 * isci_request_execute() - This function allocates the isci_request object,
387 * all fills in some common fields.
388 * @isci_host: This parameter specifies the ISCI host object
389 * @sas_task: This parameter is the task struct from the upper layer driver.
390 * @isci_request: This parameter will contain the pointer to the new
391 * isci_request object.
392 * @gfp_flags: This parameter specifies the os allocation flags.
393 *
394 * SCI_SUCCESS on successfull completion, or specific failure code.
395 */
396int isci_request_execute(
397 struct isci_host *isci_host,
398 struct sas_task *task,
399 struct isci_request **isci_request,
400 gfp_t gfp_flags)
401{
402 int ret = 0;
403 struct scic_sds_remote_device *sci_device;
404 enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
405 struct isci_remote_device *isci_device;
406 struct isci_request *request;
407 unsigned long flags;
408
409 isci_device = isci_dev_from_domain_dev(task->dev);
Dan Williams3a97eec2011-03-04 11:51:43 -0800410 sci_device = to_sci_dev(isci_device);
Dan Williams6f231dd2011-07-02 22:56:22 -0700411
412 /* do common allocation and init of request object. */
413 ret = isci_request_alloc_io(
414 isci_host,
415 task,
416 &request,
417 isci_device,
418 gfp_flags
419 );
420
421 if (ret)
422 goto out;
423
424 status = isci_io_request_build(isci_host, request, isci_device);
425 if (status == SCI_SUCCESS) {
426
427 spin_lock_irqsave(&isci_host->scic_lock, flags);
428
429 /* send the request, let the core assign the IO TAG. */
430 status = scic_controller_start_io(
431 isci_host->core_controller,
432 sci_device,
433 request->sci_request_handle,
434 SCI_CONTROLLER_INVALID_IO_TAG
435 );
436
437 if (status == SCI_SUCCESS ||
438 status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
439
440 /* Either I/O started OK, or the core has signaled that
441 * the device needs a target reset.
442 *
443 * In either case, hold onto the I/O for later.
444 *
445 * Update it's status and add it to the list in the
446 * remote device object.
447 */
448 isci_request_change_state(request, started);
449 list_add(&request->dev_node,
450 &isci_device->reqs_in_process);
451
452 if (status ==
453 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
454 /* Signal libsas that we need the SCSI error
455 * handler thread to work on this I/O and that
456 * we want a device reset.
457 */
458 isci_request_signal_device_reset(request);
459
460 /* Change the status, since we are holding
461 * the I/O until it is managed by the SCSI
462 * error handler.
463 */
464 status = SCI_SUCCESS;
465 }
466 } else
467 dev_warn(&isci_host->pdev->dev,
468 "%s: failed request start\n",
469 __func__);
470
471 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
472
473 } else
474 dev_warn(&isci_host->pdev->dev,
475 "%s: request_construct failed - status = 0x%x\n",
476 __func__,
477 status);
478
479 out:
480 if (status != SCI_SUCCESS) {
481
482 /* release dma memory on failure. */
483 isci_request_free(isci_host, request);
484 request = NULL;
485 ret = SCI_FAILURE;
486 }
487
488 *isci_request = request;
489 return ret;
490}
491
492
493/**
494 * isci_request_process_response_iu() - This function sets the status and
495 * response iu, in the task struct, from the request object for the upper
496 * layer driver.
497 * @sas_task: This parameter is the task struct from the upper layer driver.
498 * @resp_iu: This parameter points to the response iu of the completed request.
499 * @dev: This parameter specifies the linux device struct.
500 *
501 * none.
502 */
503static void isci_request_process_response_iu(
504 struct sas_task *task,
505 struct ssp_response_iu *resp_iu,
506 struct device *dev)
507{
508 dev_dbg(dev,
509 "%s: resp_iu = %p "
510 "resp_iu->status = 0x%x,\nresp_iu->datapres = %d "
511 "resp_iu->response_data_len = %x, "
512 "resp_iu->sense_data_len = %x\nrepsonse data: ",
513 __func__,
514 resp_iu,
515 resp_iu->status,
516 resp_iu->datapres,
517 resp_iu->response_data_len,
518 resp_iu->sense_data_len);
519
520 task->task_status.stat = resp_iu->status;
521
522 /* libsas updates the task status fields based on the response iu. */
523 sas_ssp_task_response(dev, task, resp_iu);
524}
525
526/**
527 * isci_request_set_open_reject_status() - This function prepares the I/O
528 * completion for OPEN_REJECT conditions.
529 * @request: This parameter is the completed isci_request object.
530 * @response_ptr: This parameter specifies the service response for the I/O.
531 * @status_ptr: This parameter specifies the exec status for the I/O.
532 * @complete_to_host_ptr: This parameter specifies the action to be taken by
533 * the LLDD with respect to completing this request or forcing an abort
534 * condition on the I/O.
535 * @open_rej_reason: This parameter specifies the encoded reason for the
536 * abandon-class reject.
537 *
538 * none.
539 */
540static void isci_request_set_open_reject_status(
541 struct isci_request *request,
542 struct sas_task *task,
543 enum service_response *response_ptr,
544 enum exec_status *status_ptr,
545 enum isci_completion_selection *complete_to_host_ptr,
546 enum sas_open_rej_reason open_rej_reason)
547{
548 /* Task in the target is done. */
549 request->complete_in_target = true;
550 *response_ptr = SAS_TASK_UNDELIVERED;
551 *status_ptr = SAS_OPEN_REJECT;
552 *complete_to_host_ptr = isci_perform_normal_io_completion;
553 task->task_status.open_rej_reason = open_rej_reason;
554}
555
556/**
557 * isci_request_handle_controller_specific_errors() - This function decodes
558 * controller-specific I/O completion error conditions.
559 * @request: This parameter is the completed isci_request object.
560 * @response_ptr: This parameter specifies the service response for the I/O.
561 * @status_ptr: This parameter specifies the exec status for the I/O.
562 * @complete_to_host_ptr: This parameter specifies the action to be taken by
563 * the LLDD with respect to completing this request or forcing an abort
564 * condition on the I/O.
565 *
566 * none.
567 */
568static void isci_request_handle_controller_specific_errors(
569 struct isci_remote_device *isci_device,
570 struct isci_request *request,
571 struct sas_task *task,
572 enum service_response *response_ptr,
573 enum exec_status *status_ptr,
574 enum isci_completion_selection *complete_to_host_ptr)
575{
576 unsigned int cstatus;
577
578 cstatus = scic_request_get_controller_status(
579 request->sci_request_handle
580 );
581
582 dev_dbg(&request->isci_host->pdev->dev,
583 "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR "
584 "- controller status = 0x%x\n",
585 __func__, request, cstatus);
586
587 /* Decode the controller-specific errors; most
588 * important is to recognize those conditions in which
589 * the target may still have a task outstanding that
590 * must be aborted.
591 *
592 * Note that there are SCU completion codes being
593 * named in the decode below for which SCIC has already
594 * done work to handle them in a way other than as
595 * a controller-specific completion code; these are left
596 * in the decode below for completeness sake.
597 */
598 switch (cstatus) {
599 case SCU_TASK_DONE_DMASETUP_DIRERR:
600 /* Also SCU_TASK_DONE_SMP_FRM_TYPE_ERR: */
601 case SCU_TASK_DONE_XFERCNT_ERR:
602 /* Also SCU_TASK_DONE_SMP_UFI_ERR: */
603 if (task->task_proto == SAS_PROTOCOL_SMP) {
604 /* SCU_TASK_DONE_SMP_UFI_ERR == Task Done. */
605 *response_ptr = SAS_TASK_COMPLETE;
606
607 /* See if the device has been/is being stopped. Note
608 * that we ignore the quiesce state, since we are
609 * concerned about the actual device state.
610 */
611 if ((isci_device->status == isci_stopping) ||
612 (isci_device->status == isci_stopped))
613 *status_ptr = SAS_DEVICE_UNKNOWN;
614 else
615 *status_ptr = SAS_ABORTED_TASK;
616
617 request->complete_in_target = true;
618
619 *complete_to_host_ptr =
620 isci_perform_normal_io_completion;
621 } else {
622 /* Task in the target is not done. */
623 *response_ptr = SAS_TASK_UNDELIVERED;
624
625 if ((isci_device->status == isci_stopping) ||
626 (isci_device->status == isci_stopped))
627 *status_ptr = SAS_DEVICE_UNKNOWN;
628 else
629 *status_ptr = SAM_STAT_TASK_ABORTED;
630
631 request->complete_in_target = false;
632
633 *complete_to_host_ptr =
634 isci_perform_error_io_completion;
635 }
636
637 break;
638
639 case SCU_TASK_DONE_CRC_ERR:
640 case SCU_TASK_DONE_NAK_CMD_ERR:
641 case SCU_TASK_DONE_EXCESS_DATA:
642 case SCU_TASK_DONE_UNEXP_FIS:
643 /* Also SCU_TASK_DONE_UNEXP_RESP: */
644 case SCU_TASK_DONE_VIIT_ENTRY_NV: /* TODO - conditions? */
645 case SCU_TASK_DONE_IIT_ENTRY_NV: /* TODO - conditions? */
646 case SCU_TASK_DONE_RNCNV_OUTBOUND: /* TODO - conditions? */
647 /* These are conditions in which the target
648 * has completed the task, so that no cleanup
649 * is necessary.
650 */
651 *response_ptr = SAS_TASK_COMPLETE;
652
653 /* See if the device has been/is being stopped. Note
654 * that we ignore the quiesce state, since we are
655 * concerned about the actual device state.
656 */
657 if ((isci_device->status == isci_stopping) ||
658 (isci_device->status == isci_stopped))
659 *status_ptr = SAS_DEVICE_UNKNOWN;
660 else
661 *status_ptr = SAS_ABORTED_TASK;
662
663 request->complete_in_target = true;
664
665 *complete_to_host_ptr = isci_perform_normal_io_completion;
666 break;
667
668
669 /* Note that the only open reject completion codes seen here will be
670 * abandon-class codes; all others are automatically retried in the SCU.
671 */
672 case SCU_TASK_OPEN_REJECT_WRONG_DESTINATION:
673
674 isci_request_set_open_reject_status(
675 request, task, response_ptr, status_ptr,
676 complete_to_host_ptr, SAS_OREJ_WRONG_DEST);
677 break;
678
679 case SCU_TASK_OPEN_REJECT_ZONE_VIOLATION:
680
681 /* Note - the return of AB0 will change when
682 * libsas implements detection of zone violations.
683 */
684 isci_request_set_open_reject_status(
685 request, task, response_ptr, status_ptr,
686 complete_to_host_ptr, SAS_OREJ_RESV_AB0);
687 break;
688
689 case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1:
690
691 isci_request_set_open_reject_status(
692 request, task, response_ptr, status_ptr,
693 complete_to_host_ptr, SAS_OREJ_RESV_AB1);
694 break;
695
696 case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2:
697
698 isci_request_set_open_reject_status(
699 request, task, response_ptr, status_ptr,
700 complete_to_host_ptr, SAS_OREJ_RESV_AB2);
701 break;
702
703 case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3:
704
705 isci_request_set_open_reject_status(
706 request, task, response_ptr, status_ptr,
707 complete_to_host_ptr, SAS_OREJ_RESV_AB3);
708 break;
709
710 case SCU_TASK_OPEN_REJECT_BAD_DESTINATION:
711
712 isci_request_set_open_reject_status(
713 request, task, response_ptr, status_ptr,
714 complete_to_host_ptr, SAS_OREJ_BAD_DEST);
715 break;
716
717 case SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY:
718
719 isci_request_set_open_reject_status(
720 request, task, response_ptr, status_ptr,
721 complete_to_host_ptr, SAS_OREJ_STP_NORES);
722 break;
723
724 case SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED:
725
726 isci_request_set_open_reject_status(
727 request, task, response_ptr, status_ptr,
728 complete_to_host_ptr, SAS_OREJ_EPROTO);
729 break;
730
731 case SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED:
732
733 isci_request_set_open_reject_status(
734 request, task, response_ptr, status_ptr,
735 complete_to_host_ptr, SAS_OREJ_CONN_RATE);
736 break;
737
738 case SCU_TASK_DONE_LL_R_ERR:
739 /* Also SCU_TASK_DONE_ACK_NAK_TO: */
740 case SCU_TASK_DONE_LL_PERR:
741 case SCU_TASK_DONE_LL_SY_TERM:
742 /* Also SCU_TASK_DONE_NAK_ERR:*/
743 case SCU_TASK_DONE_LL_LF_TERM:
744 /* Also SCU_TASK_DONE_DATA_LEN_ERR: */
745 case SCU_TASK_DONE_LL_ABORT_ERR:
746 case SCU_TASK_DONE_SEQ_INV_TYPE:
747 /* Also SCU_TASK_DONE_UNEXP_XR: */
748 case SCU_TASK_DONE_XR_IU_LEN_ERR:
749 case SCU_TASK_DONE_INV_FIS_LEN:
750 /* Also SCU_TASK_DONE_XR_WD_LEN: */
751 case SCU_TASK_DONE_SDMA_ERR:
752 case SCU_TASK_DONE_OFFSET_ERR:
753 case SCU_TASK_DONE_MAX_PLD_ERR:
754 case SCU_TASK_DONE_LF_ERR:
755 case SCU_TASK_DONE_SMP_RESP_TO_ERR: /* Escalate to dev reset? */
756 case SCU_TASK_DONE_SMP_LL_RX_ERR:
757 case SCU_TASK_DONE_UNEXP_DATA:
758 case SCU_TASK_DONE_UNEXP_SDBFIS:
759 case SCU_TASK_DONE_REG_ERR:
760 case SCU_TASK_DONE_SDB_ERR:
761 case SCU_TASK_DONE_TASK_ABORT:
762 default:
763 /* Task in the target is not done. */
764 *response_ptr = SAS_TASK_UNDELIVERED;
765 *status_ptr = SAM_STAT_TASK_ABORTED;
766 request->complete_in_target = false;
767
768 *complete_to_host_ptr = isci_perform_error_io_completion;
769 break;
770 }
771}
772
773/**
774 * isci_task_save_for_upper_layer_completion() - This function saves the
775 * request for later completion to the upper layer driver.
776 * @host: This parameter is a pointer to the host on which the the request
777 * should be queued (either as an error or success).
778 * @request: This parameter is the completed request.
779 * @response: This parameter is the response code for the completed task.
780 * @status: This parameter is the status code for the completed task.
781 *
782 * none.
783 */
784static void isci_task_save_for_upper_layer_completion(
785 struct isci_host *host,
786 struct isci_request *request,
787 enum service_response response,
788 enum exec_status status,
789 enum isci_completion_selection task_notification_selection)
790{
791 struct sas_task *task = isci_request_access_task(request);
792
793 isci_task_set_completion_status(task, response, status,
794 task_notification_selection);
795
796
797 /* Tasks aborted specifically by a call to the lldd_abort_task
798 * function should not be completed to the host in the regular path.
799 */
800 switch (task_notification_selection) {
801
802 case isci_perform_normal_io_completion:
803
804 /* Normal notification (task_done) */
805 dev_dbg(&host->pdev->dev,
806 "%s: Normal - task = %p, response=%d, status=%d\n",
807 __func__,
808 task,
809 response,
810 status);
811 /* Add to the completed list. */
812 list_add(&request->completed_node,
813 &host->requests_to_complete);
814 break;
815
816 case isci_perform_aborted_io_completion:
Jeff Skirvina5fde222011-03-04 14:06:42 -0800817 /* No notification to libsas because this request is
818 * already in the abort path.
Dan Williams6f231dd2011-07-02 22:56:22 -0700819 */
820 dev_warn(&host->pdev->dev,
821 "%s: Aborted - task = %p, response=%d, status=%d\n",
822 __func__,
823 task,
824 response,
825 status);
Jeff Skirvina5fde222011-03-04 14:06:42 -0800826
827 /* Wake up whatever process was waiting for this
828 * request to complete.
829 */
830 WARN_ON(request->io_request_completion == NULL);
831
832 if (request->io_request_completion != NULL) {
833
834 /* Signal whoever is waiting that this
835 * request is complete.
836 */
837 complete(request->io_request_completion);
838 }
Dan Williams6f231dd2011-07-02 22:56:22 -0700839 break;
840
841 case isci_perform_error_io_completion:
842 /* Use sas_task_abort */
843 dev_warn(&host->pdev->dev,
844 "%s: Error - task = %p, response=%d, status=%d\n",
845 __func__,
846 task,
847 response,
848 status);
849 /* Add to the aborted list. */
850 list_add(&request->completed_node,
Jeff Skirvin11b00c12011-03-04 14:06:40 -0800851 &host->requests_to_errorback);
Dan Williams6f231dd2011-07-02 22:56:22 -0700852 break;
853
854 default:
855 dev_warn(&host->pdev->dev,
856 "%s: Unknown - task = %p, response=%d, status=%d\n",
857 __func__,
858 task,
859 response,
860 status);
861
Jeff Skirvina5fde222011-03-04 14:06:42 -0800862 /* Add to the error to libsas list. */
Dan Williams6f231dd2011-07-02 22:56:22 -0700863 list_add(&request->completed_node,
Jeff Skirvin11b00c12011-03-04 14:06:40 -0800864 &host->requests_to_errorback);
Dan Williams6f231dd2011-07-02 22:56:22 -0700865 break;
866 }
867}
868
869/**
870 * isci_request_io_request_complete() - This function is called by the sci core
871 * when an io request completes.
872 * @isci_host: This parameter specifies the ISCI host object
873 * @request: This parameter is the completed isci_request object.
874 * @completion_status: This parameter specifies the completion status from the
875 * sci core.
876 *
877 * none.
878 */
879void isci_request_io_request_complete(
880 struct isci_host *isci_host,
881 struct isci_request *request,
882 enum sci_io_status completion_status)
883{
884 struct sas_task *task = isci_request_access_task(request);
885 struct ssp_response_iu *resp_iu;
886 void *resp_buf;
887 unsigned long task_flags;
Dan Williams6f231dd2011-07-02 22:56:22 -0700888 struct isci_remote_device *isci_device = request->isci_device;
889 enum service_response response = SAS_TASK_UNDELIVERED;
890 enum exec_status status = SAS_ABORTED_TASK;
891 enum isci_request_status request_status;
892 enum isci_completion_selection complete_to_host
893 = isci_perform_normal_io_completion;
894
895 dev_dbg(&isci_host->pdev->dev,
896 "%s: request = %p, task = %p,\n"
897 "task->data_dir = %d completion_status = 0x%x\n",
898 __func__,
899 request,
900 task,
901 task->data_dir,
902 completion_status);
903
Jeff Skirvina5fde222011-03-04 14:06:42 -0800904 spin_lock(&request->state_lock);
Dan Williams6f231dd2011-07-02 22:56:22 -0700905 request_status = isci_request_get_state(request);
Dan Williams6f231dd2011-07-02 22:56:22 -0700906
907 /* Decode the request status. Note that if the request has been
908 * aborted by a task management function, we don't care
909 * what the status is.
910 */
911 switch (request_status) {
912
913 case aborted:
914 /* "aborted" indicates that the request was aborted by a task
915 * management function, since once a task management request is
916 * perfomed by the device, the request only completes because
917 * of the subsequent driver terminate.
918 *
919 * Aborted also means an external thread is explicitly managing
920 * this request, so that we do not complete it up the stack.
921 *
922 * The target is still there (since the TMF was successful).
923 */
924 request->complete_in_target = true;
925 response = SAS_TASK_COMPLETE;
926
927 /* See if the device has been/is being stopped. Note
928 * that we ignore the quiesce state, since we are
929 * concerned about the actual device state.
930 */
931 if ((isci_device->status == isci_stopping)
932 || (isci_device->status == isci_stopped)
933 )
934 status = SAS_DEVICE_UNKNOWN;
935 else
936 status = SAS_ABORTED_TASK;
937
938 complete_to_host = isci_perform_aborted_io_completion;
939 /* This was an aborted request. */
Jeff Skirvina5fde222011-03-04 14:06:42 -0800940
941 spin_unlock(&request->state_lock);
Dan Williams6f231dd2011-07-02 22:56:22 -0700942 break;
943
944 case aborting:
945 /* aborting means that the task management function tried and
946 * failed to abort the request. We need to note the request
947 * as SAS_TASK_UNDELIVERED, so that the scsi mid layer marks the
948 * target as down.
949 *
950 * Aborting also means an external thread is explicitly managing
951 * this request, so that we do not complete it up the stack.
952 */
953 request->complete_in_target = true;
954 response = SAS_TASK_UNDELIVERED;
955
956 if ((isci_device->status == isci_stopping) ||
957 (isci_device->status == isci_stopped))
958 /* The device has been /is being stopped. Note that
959 * we ignore the quiesce state, since we are
960 * concerned about the actual device state.
961 */
962 status = SAS_DEVICE_UNKNOWN;
963 else
964 status = SAS_PHY_DOWN;
965
966 complete_to_host = isci_perform_aborted_io_completion;
967
968 /* This was an aborted request. */
Jeff Skirvina5fde222011-03-04 14:06:42 -0800969
970 spin_unlock(&request->state_lock);
Dan Williams6f231dd2011-07-02 22:56:22 -0700971 break;
972
973 case terminating:
974
975 /* This was an terminated request. This happens when
976 * the I/O is being terminated because of an action on
977 * the device (reset, tear down, etc.), and the I/O needs
978 * to be completed up the stack.
979 */
980 request->complete_in_target = true;
981 response = SAS_TASK_UNDELIVERED;
982
983 /* See if the device has been/is being stopped. Note
984 * that we ignore the quiesce state, since we are
985 * concerned about the actual device state.
986 */
987 if ((isci_device->status == isci_stopping) ||
988 (isci_device->status == isci_stopped))
989 status = SAS_DEVICE_UNKNOWN;
990 else
991 status = SAS_ABORTED_TASK;
992
Jeff Skirvina5fde222011-03-04 14:06:42 -0800993 complete_to_host = isci_perform_aborted_io_completion;
Dan Williams6f231dd2011-07-02 22:56:22 -0700994
995 /* This was a terminated request. */
Jeff Skirvina5fde222011-03-04 14:06:42 -0800996
997 spin_unlock(&request->state_lock);
Dan Williams6f231dd2011-07-02 22:56:22 -0700998 break;
999
1000 default:
1001
Jeff Skirvina5fde222011-03-04 14:06:42 -08001002 /* The request is done from an SCU HW perspective. */
1003 request->status = completed;
1004
1005 spin_unlock(&request->state_lock);
1006
Dan Williams6f231dd2011-07-02 22:56:22 -07001007 /* This is an active request being completed from the core. */
1008 switch (completion_status) {
1009
1010 case SCI_IO_FAILURE_RESPONSE_VALID:
1011 dev_dbg(&isci_host->pdev->dev,
1012 "%s: SCI_IO_FAILURE_RESPONSE_VALID (%p/%p)\n",
1013 __func__,
1014 request,
1015 task);
1016
1017 if (sas_protocol_ata(task->task_proto)) {
1018 resp_buf
1019 = scic_stp_io_request_get_d2h_reg_address(
1020 request->sci_request_handle
1021 );
1022 isci_request_process_stp_response(task,
1023 resp_buf
1024 );
1025
1026 } else if (SAS_PROTOCOL_SSP == task->task_proto) {
1027
1028 /* crack the iu response buffer. */
1029 resp_iu
1030 = scic_io_request_get_response_iu_address(
1031 request->sci_request_handle
1032 );
1033
1034 isci_request_process_response_iu(task, resp_iu,
1035 &isci_host->pdev->dev
1036 );
1037
1038 } else if (SAS_PROTOCOL_SMP == task->task_proto) {
1039
1040 dev_err(&isci_host->pdev->dev,
1041 "%s: SCI_IO_FAILURE_RESPONSE_VALID: "
1042 "SAS_PROTOCOL_SMP protocol\n",
1043 __func__);
1044
1045 } else
1046 dev_err(&isci_host->pdev->dev,
1047 "%s: unknown protocol\n", __func__);
1048
1049 /* use the task status set in the task struct by the
1050 * isci_request_process_response_iu call.
1051 */
1052 request->complete_in_target = true;
1053 response = task->task_status.resp;
1054 status = task->task_status.stat;
1055 break;
1056
1057 case SCI_IO_SUCCESS:
1058 case SCI_IO_SUCCESS_IO_DONE_EARLY:
1059
1060 response = SAS_TASK_COMPLETE;
1061 status = SAM_STAT_GOOD;
1062 request->complete_in_target = true;
1063
1064 if (task->task_proto == SAS_PROTOCOL_SMP) {
1065
1066 u8 *command_iu_address
1067 = scic_io_request_get_command_iu_address(
1068 request->sci_request_handle
1069 );
1070
1071 dev_dbg(&isci_host->pdev->dev,
1072 "%s: SMP protocol completion\n",
1073 __func__);
1074
1075 sg_copy_from_buffer(
1076 &task->smp_task.smp_resp, 1,
1077 command_iu_address
1078 + sizeof(struct smp_request),
1079 sizeof(struct smp_resp)
1080 );
1081 } else if (completion_status
1082 == SCI_IO_SUCCESS_IO_DONE_EARLY) {
1083
1084 /* This was an SSP / STP / SATA transfer.
1085 * There is a possibility that less data than
1086 * the maximum was transferred.
1087 */
1088 u32 transferred_length
1089 = scic_io_request_get_number_of_bytes_transferred(
1090 request->sci_request_handle);
1091
1092 task->task_status.residual
1093 = task->total_xfer_len - transferred_length;
1094
1095 /* If there were residual bytes, call this an
1096 * underrun.
1097 */
1098 if (task->task_status.residual != 0)
1099 status = SAS_DATA_UNDERRUN;
1100
1101 dev_dbg(&isci_host->pdev->dev,
1102 "%s: SCI_IO_SUCCESS_IO_DONE_EARLY %d\n",
1103 __func__,
1104 status);
1105
1106 } else
1107 dev_dbg(&isci_host->pdev->dev,
1108 "%s: SCI_IO_SUCCESS\n",
1109 __func__);
1110
1111 break;
1112
1113 case SCI_IO_FAILURE_TERMINATED:
1114 dev_dbg(&isci_host->pdev->dev,
1115 "%s: SCI_IO_FAILURE_TERMINATED (%p/%p)\n",
1116 __func__,
1117 request,
1118 task);
1119
1120 /* The request was terminated explicitly. No handling
1121 * is needed in the SCSI error handler path.
1122 */
1123 request->complete_in_target = true;
1124 response = SAS_TASK_UNDELIVERED;
1125
1126 /* See if the device has been/is being stopped. Note
1127 * that we ignore the quiesce state, since we are
1128 * concerned about the actual device state.
1129 */
1130 if ((isci_device->status == isci_stopping) ||
1131 (isci_device->status == isci_stopped))
1132 status = SAS_DEVICE_UNKNOWN;
1133 else
1134 status = SAS_ABORTED_TASK;
1135
1136 complete_to_host = isci_perform_normal_io_completion;
1137 break;
1138
1139 case SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR:
1140
1141 isci_request_handle_controller_specific_errors(
1142 isci_device, request, task, &response, &status,
1143 &complete_to_host);
1144
1145 break;
1146
1147 case SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED:
1148 /* This is a special case, in that the I/O completion
1149 * is telling us that the device needs a reset.
1150 * In order for the device reset condition to be
1151 * noticed, the I/O has to be handled in the error
1152 * handler. Set the reset flag and cause the
1153 * SCSI error thread to be scheduled.
1154 */
1155 spin_lock_irqsave(&task->task_state_lock, task_flags);
1156 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
1157 spin_unlock_irqrestore(&task->task_state_lock, task_flags);
1158
1159 complete_to_host = isci_perform_error_io_completion;
1160 request->complete_in_target = false;
1161 break;
1162
1163 default:
1164 /* Catch any otherwise unhandled error codes here. */
1165 dev_warn(&isci_host->pdev->dev,
1166 "%s: invalid completion code: 0x%x - "
1167 "isci_request = %p\n",
1168 __func__, completion_status, request);
1169
1170 response = SAS_TASK_UNDELIVERED;
1171
1172 /* See if the device has been/is being stopped. Note
1173 * that we ignore the quiesce state, since we are
1174 * concerned about the actual device state.
1175 */
1176 if ((isci_device->status == isci_stopping) ||
1177 (isci_device->status == isci_stopped))
1178 status = SAS_DEVICE_UNKNOWN;
1179 else
1180 status = SAS_ABORTED_TASK;
1181
1182 complete_to_host = isci_perform_error_io_completion;
1183 request->complete_in_target = false;
1184 break;
1185 }
1186 break;
1187 }
1188
1189 isci_request_unmap_sgl(request, isci_host->pdev);
1190
1191 /* Put the completed request on the correct list */
1192 isci_task_save_for_upper_layer_completion(isci_host, request, response,
1193 status, complete_to_host
1194 );
1195
1196 /* complete the io request to the core. */
1197 scic_controller_complete_io(
1198 isci_host->core_controller,
Dan Williams3a97eec2011-03-04 11:51:43 -08001199 to_sci_dev(isci_device),
Dan Williams6f231dd2011-07-02 22:56:22 -07001200 request->sci_request_handle
1201 );
1202 /* NULL the request handle so it cannot be completed or
1203 * terminated again, and to cause any calls into abort
1204 * task to recognize the already completed case.
1205 */
1206 request->sci_request_handle = NULL;
1207
Dan Williams6f231dd2011-07-02 22:56:22 -07001208 isci_host_can_dequeue(isci_host, 1);
1209}
1210
1211/**
1212 * isci_request_io_request_get_transfer_length() - This function is called by
1213 * the sci core to retrieve the transfer length for a given request.
1214 * @request: This parameter is the isci_request object.
1215 *
1216 * length of transfer for specified request.
1217 */
1218u32 isci_request_io_request_get_transfer_length(struct isci_request *request)
1219{
1220 struct sas_task *task = isci_request_access_task(request);
1221
1222 dev_dbg(&request->isci_host->pdev->dev,
1223 "%s: total_xfer_len: %d\n",
1224 __func__,
1225 task->total_xfer_len);
1226 return task->total_xfer_len;
1227}
1228
1229
1230/**
1231 * isci_request_io_request_get_data_direction() - This function is called by
1232 * the sci core to retrieve the data direction for a given request.
1233 * @request: This parameter is the isci_request object.
1234 *
1235 * data direction for specified request.
1236 */
Dan Williams82d29922011-02-08 17:53:10 -08001237enum dma_data_direction isci_request_io_request_get_data_direction(
Dan Williams6f231dd2011-07-02 22:56:22 -07001238 struct isci_request *request)
1239{
1240 struct sas_task *task = isci_request_access_task(request);
Dan Williams6f231dd2011-07-02 22:56:22 -07001241
Dan Williams82d29922011-02-08 17:53:10 -08001242 return task->data_dir;
Dan Williams6f231dd2011-07-02 22:56:22 -07001243}
1244
1245/**
1246 * isci_request_sge_get_address_field() - This function is called by the sci
1247 * core to retrieve the address field contents for a given sge.
1248 * @request: This parameter is the isci_request object.
1249 * @sge_address: This parameter is the sge.
1250 *
1251 * physical address in the specified sge.
1252 */
1253dma_addr_t isci_request_sge_get_address_field(
1254 struct isci_request *request,
1255 void *sge_address)
1256{
1257 struct sas_task *task = isci_request_access_task(request);
1258 dma_addr_t ret;
1259 struct isci_host *isci_host = isci_host_from_sas_ha(
1260 task->dev->port->ha);
1261
1262 dev_dbg(&isci_host->pdev->dev,
1263 "%s: request = %p, sge_address = %p\n",
1264 __func__,
1265 request,
1266 sge_address);
1267
1268 if (task->data_dir == PCI_DMA_NONE)
1269 return 0;
1270
1271 /* the case where num_scatter == 0 is special, in that
1272 * task->scatter is the actual buffer address, not an sgl.
1273 * so a map single is required here.
1274 */
1275 if ((task->num_scatter == 0) &&
1276 !sas_protocol_ata(task->task_proto)) {
1277 ret = dma_map_single(
1278 &isci_host->pdev->dev,
1279 task->scatter,
1280 task->total_xfer_len,
1281 task->data_dir
1282 );
1283 request->zero_scatter_daddr = ret;
1284 } else
1285 ret = sg_dma_address(((struct scatterlist *)sge_address));
1286
1287 dev_dbg(&isci_host->pdev->dev,
1288 "%s: bus address = %lx\n",
1289 __func__,
1290 (unsigned long)ret);
1291
1292 return ret;
1293}
1294
1295
1296/**
1297 * isci_request_sge_get_length_field() - This function is called by the sci
1298 * core to retrieve the length field contents for a given sge.
1299 * @request: This parameter is the isci_request object.
1300 * @sge_address: This parameter is the sge.
1301 *
1302 * length field value in the specified sge.
1303 */
1304u32 isci_request_sge_get_length_field(
1305 struct isci_request *request,
1306 void *sge_address)
1307{
1308 struct sas_task *task = isci_request_access_task(request);
1309 int ret;
1310
1311 dev_dbg(&request->isci_host->pdev->dev,
1312 "%s: request = %p, sge_address = %p\n",
1313 __func__,
1314 request,
1315 sge_address);
1316
1317 if (task->data_dir == PCI_DMA_NONE)
1318 return 0;
1319
1320 /* the case where num_scatter == 0 is special, in that
1321 * task->scatter is the actual buffer address, not an sgl.
1322 * so we return total_xfer_len here.
1323 */
1324 if (task->num_scatter == 0)
1325 ret = task->total_xfer_len;
1326 else
1327 ret = sg_dma_len((struct scatterlist *)sge_address);
1328
1329 dev_dbg(&request->isci_host->pdev->dev,
1330 "%s: len = %d\n",
1331 __func__,
1332 ret);
1333
1334 return ret;
1335}
1336
1337
1338/**
1339 * isci_request_ssp_io_request_get_cdb_address() - This function is called by
1340 * the sci core to retrieve the cdb address for a given request.
1341 * @request: This parameter is the isci_request object.
1342 *
1343 * cdb address for specified request.
1344 */
1345void *isci_request_ssp_io_request_get_cdb_address(
1346 struct isci_request *request)
1347{
1348 struct sas_task *task = isci_request_access_task(request);
1349
1350 dev_dbg(&request->isci_host->pdev->dev,
1351 "%s: request->task->ssp_task.cdb = %p\n",
1352 __func__,
1353 task->ssp_task.cdb);
1354 return task->ssp_task.cdb;
1355}
1356
1357
1358/**
1359 * isci_request_ssp_io_request_get_cdb_length() - This function is called by
1360 * the sci core to retrieve the cdb length for a given request.
1361 * @request: This parameter is the isci_request object.
1362 *
1363 * cdb length for specified request.
1364 */
1365u32 isci_request_ssp_io_request_get_cdb_length(
1366 struct isci_request *request)
1367{
1368 return 16;
1369}
1370
1371
1372/**
1373 * isci_request_ssp_io_request_get_lun() - This function is called by the sci
1374 * core to retrieve the lun for a given request.
1375 * @request: This parameter is the isci_request object.
1376 *
1377 * lun for specified request.
1378 */
1379u32 isci_request_ssp_io_request_get_lun(
1380 struct isci_request *request)
1381{
1382 struct sas_task *task = isci_request_access_task(request);
1383
1384#ifdef DEBUG
1385 int i;
1386
1387 for (i = 0; i < 8; i++)
1388 dev_dbg(&request->isci_host->pdev->dev,
Dan Williams83f5eee2011-02-18 09:25:15 -08001389 "%s: task->ssp_task.LUN[%d] = %x\n",
1390 __func__, i, task->ssp_task.LUN[i]);
Dan Williams6f231dd2011-07-02 22:56:22 -07001391
1392#endif
1393
1394 return task->ssp_task.LUN[0];
1395}
1396
1397
1398/**
1399 * isci_request_ssp_io_request_get_task_attribute() - This function is called
1400 * by the sci core to retrieve the task attribute for a given request.
1401 * @request: This parameter is the isci_request object.
1402 *
1403 * task attribute for specified request.
1404 */
1405u32 isci_request_ssp_io_request_get_task_attribute(
1406 struct isci_request *request)
1407{
1408 struct sas_task *task = isci_request_access_task(request);
1409
1410 dev_dbg(&request->isci_host->pdev->dev,
1411 "%s: request->task->ssp_task.task_attr = %x\n",
1412 __func__,
1413 task->ssp_task.task_attr);
1414
1415 return task->ssp_task.task_attr;
1416}
1417
1418
1419/**
1420 * isci_request_ssp_io_request_get_command_priority() - This function is called
1421 * by the sci core to retrieve the command priority for a given request.
1422 * @request: This parameter is the isci_request object.
1423 *
1424 * command priority for specified request.
1425 */
1426u32 isci_request_ssp_io_request_get_command_priority(
1427 struct isci_request *request)
1428{
1429 struct sas_task *task = isci_request_access_task(request);
1430
1431 dev_dbg(&request->isci_host->pdev->dev,
1432 "%s: request->task->ssp_task.task_prio = %x\n",
1433 __func__,
1434 task->ssp_task.task_prio);
1435
1436 return task->ssp_task.task_prio;
1437}