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