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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
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.
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.
57 #include "intel_sas.h"
58 #include "intel_sata.h"
59 #include "intel_sat.h"
60 #include "sci_base_request.h"
61 #include "scic_controller.h"
62 #include "scic_io_request.h"
63 #include "scic_remote_device.h"
64 #include "scic_sds_controller.h"
65 #include "scic_sds_controller_registers.h"
66 #include "scic_sds_pci.h"
67 #include "scic_sds_port.h"
68 #include "scic_sds_remote_device.h"
69 #include "scic_sds_request.h"
70 #include "scic_sds_smp_request.h"
71 #include "scic_sds_stp_request.h"
72 #include "scic_sds_unsolicited_frame_control.h"
73 #include "sci_environment.h"
75 #include "scu_completion_codes.h"
76 #include "scu_constants.h"
77 #include "scu_task_context.h"
79 #if !defined(DISABLE_ATAPI)
80 #include "scic_sds_stp_packet_request.h"
84 * ****************************************************************************
85 * * SCIC SDS IO REQUEST CONSTANTS
86 * **************************************************************************** */
91 * We have no timer requirements for IO requests right now
93 #define SCIC_SDS_IO_REQUEST_MINIMUM_TIMER_COUNT (0)
94 #define SCIC_SDS_IO_REQUEST_MAXIMUM_TIMER_COUNT (0)
97 * ****************************************************************************
98 * * SCIC SDS IO REQUEST MACROS
99 * **************************************************************************** */
102 * scic_ssp_io_request_get_object_size() -
104 * This macro returns the sizeof memory required to store the an SSP IO
105 * request. This does not include the size of the SGL or SCU Task Context
108 #define scic_ssp_io_request_get_object_size() \
110 sizeof(struct sci_ssp_command_iu) \
111 + sizeof(struct sci_ssp_response_iu) \
115 * scic_sds_ssp_request_get_command_buffer() -
117 * This macro returns the address of the ssp command buffer in the io request
120 #define scic_sds_ssp_request_get_command_buffer(memory) \
121 ((struct sci_ssp_command_iu *)(\
122 ((char *)(memory)) + sizeof(struct scic_sds_request) \
126 * scic_sds_ssp_request_get_response_buffer() -
128 * This macro returns the address of the ssp response buffer in the io request
131 #define scic_sds_ssp_request_get_response_buffer(memory) \
132 ((struct sci_ssp_response_iu *)(\
133 ((char *)(scic_sds_ssp_request_get_command_buffer(memory))) \
134 + sizeof(struct sci_ssp_command_iu) \
138 * scic_sds_ssp_request_get_task_context_buffer() -
140 * This macro returns the address of the task context buffer in the io request
143 #define scic_sds_ssp_request_get_task_context_buffer(memory) \
144 ((struct scu_task_context *)(\
145 ((char *)(scic_sds_ssp_request_get_response_buffer(memory))) \
146 + sizeof(struct sci_ssp_response_iu) \
150 * scic_sds_ssp_request_get_sgl_element_buffer() -
152 * This macro returns the address of the sgl elment pairs in the io request
155 #define scic_sds_ssp_request_get_sgl_element_buffer(memory) \
156 ((struct scu_sgl_element_pair *)(\
157 ((char *)(scic_sds_ssp_request_get_task_context_buffer(memory))) \
158 + sizeof(struct scu_task_context) \
163 * scic_ssp_task_request_get_object_size() -
165 * This macro returns the sizeof of memory required to store an SSP Task
166 * request. This does not include the size of the SCU Task Context memory.
168 #define scic_ssp_task_request_get_object_size() \
170 sizeof(struct sci_ssp_task_iu) \
171 + sizeof(struct sci_ssp_response_iu) \
175 * scic_sds_ssp_task_request_get_command_buffer() -
177 * This macro returns the address of the ssp command buffer in the task request
178 * memory. Yes its the same as the above macro except for the name.
180 #define scic_sds_ssp_task_request_get_command_buffer(memory) \
181 ((struct sci_ssp_task_iu *)(\
182 ((char *)(memory)) + sizeof(struct scic_sds_request) \
186 * scic_sds_ssp_task_request_get_response_buffer() -
188 * This macro returns the address of the ssp response buffer in the task
191 #define scic_sds_ssp_task_request_get_response_buffer(memory) \
192 ((struct sci_ssp_response_iu *)(\
193 ((char *)(scic_sds_ssp_task_request_get_command_buffer(memory))) \
194 + sizeof(struct sci_ssp_task_iu) \
198 * scic_sds_ssp_task_request_get_task_context_buffer() -
200 * This macro returs the task context buffer for the SSP task request.
202 #define scic_sds_ssp_task_request_get_task_context_buffer(memory) \
203 ((struct scu_task_context *)(\
204 ((char *)(scic_sds_ssp_task_request_get_response_buffer(memory))) \
205 + sizeof(struct sci_ssp_response_iu) \
211 * ****************************************************************************
212 * * SCIC SDS IO REQUEST PRIVATE METHODS
213 * **************************************************************************** */
218 * This method returns the size required to store an SSP IO request object. u32
220 static u32
scic_sds_ssp_request_get_object_size(void)
222 return sizeof(struct scic_sds_request
)
223 + scic_ssp_io_request_get_object_size()
224 + sizeof(struct scu_task_context
)
226 + sizeof(struct scu_sgl_element_pair
) * SCU_MAX_SGL_ELEMENT_PAIRS
;
230 * This method returns the sgl element pair for the specificed sgl_pair index.
231 * @this_request: This parameter specifies the IO request for which to retrieve
232 * the Scatter-Gather List element pair.
233 * @sgl_pair_index: This parameter specifies the index into the SGL element
234 * pair to be retrieved.
236 * This method returns a pointer to an struct scu_sgl_element_pair.
238 static struct scu_sgl_element_pair
*scic_sds_request_get_sgl_element_pair(
239 struct scic_sds_request
*this_request
,
242 struct scu_task_context
*task_context
;
244 task_context
= (struct scu_task_context
*)this_request
->task_context_buffer
;
246 if (sgl_pair_index
== 0) {
247 return &task_context
->sgl_pair_ab
;
248 } else if (sgl_pair_index
== 1) {
249 return &task_context
->sgl_pair_cd
;
252 return &this_request
->sgl_element_pair_buffer
[sgl_pair_index
- 2];
256 * This function will build the SGL list for an IO request.
257 * @this_request: This parameter specifies the IO request for which to build
258 * the Scatter-Gather List.
261 void scic_sds_request_build_sgl(struct scic_sds_request
*sds_request
)
263 struct isci_request
*isci_request
=
264 (struct isci_request
*)sci_object_get_association(sds_request
);
265 struct isci_host
*isci_host
= isci_request
->isci_host
;
266 struct sas_task
*task
= isci_request_access_task(isci_request
);
267 struct scatterlist
*sg
= NULL
;
270 struct scu_sgl_element_pair
*scu_sg
= NULL
;
271 struct scu_sgl_element_pair
*prev_sg
= NULL
;
273 if (task
->num_scatter
> 0) {
277 scu_sg
= scic_sds_request_get_sgl_element_pair(
281 SCU_SGL_COPY(scu_sg
->A
, sg
);
286 SCU_SGL_COPY(scu_sg
->B
, sg
);
289 SCU_SGL_ZERO(scu_sg
->B
);
293 scic_io_request_get_dma_addr(
297 prev_sg
->next_pair_upper
=
298 upper_32_bits(dma_addr
);
299 prev_sg
->next_pair_lower
=
300 lower_32_bits(dma_addr
);
306 } else { /* handle when no sg */
307 scu_sg
= scic_sds_request_get_sgl_element_pair(sds_request
,
310 dma_addr
= dma_map_single(&isci_host
->pdev
->dev
,
312 task
->total_xfer_len
,
315 isci_request
->zero_scatter_daddr
= dma_addr
;
317 scu_sg
->A
.length
= task
->total_xfer_len
;
318 scu_sg
->A
.address_upper
= upper_32_bits(dma_addr
);
319 scu_sg
->A
.address_lower
= lower_32_bits(dma_addr
);
323 scu_sg
->next_pair_upper
= 0;
324 scu_sg
->next_pair_lower
= 0;
329 * This method build the remainder of the IO request object.
330 * @this_request: This parameter specifies the request object being constructed.
332 * The scic_sds_general_request_construct() must be called before this call is
335 static void scic_sds_ssp_io_request_assign_buffers(
336 struct scic_sds_request
*this_request
)
338 this_request
->command_buffer
=
339 scic_sds_ssp_request_get_command_buffer(this_request
);
340 this_request
->response_buffer
=
341 scic_sds_ssp_request_get_response_buffer(this_request
);
342 this_request
->sgl_element_pair_buffer
=
343 scic_sds_ssp_request_get_sgl_element_buffer(this_request
);
344 this_request
->sgl_element_pair_buffer
=
345 PTR_ALIGN(this_request
->sgl_element_pair_buffer
,
346 sizeof(struct scu_sgl_element_pair
));
348 if (this_request
->was_tag_assigned_by_user
== false) {
349 this_request
->task_context_buffer
=
350 scic_sds_ssp_request_get_task_context_buffer(this_request
);
351 this_request
->task_context_buffer
=
352 PTR_ALIGN(this_request
->task_context_buffer
,
358 * This method constructs the SSP Command IU data for this io request object.
359 * @this_request: This parameter specifies the request object for which the SSP
360 * command information unit is being built.
363 static void scic_sds_io_request_build_ssp_command_iu(
364 struct scic_sds_request
*sds_request
)
366 struct sci_ssp_command_iu
*command_frame
;
369 struct isci_request
*isci_request
=
370 (struct isci_request
*)sci_object_get_association(sds_request
);
373 (struct sci_ssp_command_iu
*)sds_request
->command_buffer
;
375 command_frame
->lun_upper
= 0;
376 command_frame
->lun_lower
=
377 isci_request_ssp_io_request_get_lun(isci_request
);
379 ((u32
*)command_frame
)[2] = 0;
381 cdb_length
= isci_request_ssp_io_request_get_cdb_length(isci_request
);
382 cdb_buffer
= (u32
*)isci_request_ssp_io_request_get_cdb_address(
385 if (cdb_length
> 16) {
386 command_frame
->additional_cdb_length
= cdb_length
- 16;
389 /* / @todo Is it ok to leave junk at the end of the cdb buffer? */
390 scic_word_copy_with_swap(
391 (u32
*)(&command_frame
->cdb
),
393 (cdb_length
+ 3) / sizeof(u32
)
396 command_frame
->enable_first_burst
= 0;
397 command_frame
->task_priority
=
398 isci_request_ssp_io_request_get_command_priority(isci_request
);
399 command_frame
->task_attribute
=
400 isci_request_ssp_io_request_get_task_attribute(isci_request
);
405 * This method constructs the SSP Task IU data for this io request object.
409 static void scic_sds_task_request_build_ssp_task_iu(
410 struct scic_sds_request
*sds_request
)
412 struct sci_ssp_task_iu
*command_frame
;
413 struct isci_request
*isci_request
=
414 (struct isci_request
*)sci_object_get_association(sds_request
);
417 (struct sci_ssp_task_iu
*)sds_request
->command_buffer
;
419 command_frame
->lun_upper
= 0;
420 command_frame
->lun_lower
= isci_request_ssp_io_request_get_lun(
423 ((u32
*)command_frame
)[2] = 0;
425 command_frame
->task_function
=
426 isci_task_ssp_request_get_function(isci_request
);
427 command_frame
->task_tag
=
428 isci_task_ssp_request_get_io_tag_to_manage(
434 * This method is will fill in the SCU Task Context for any type of SSP request.
439 static void scu_ssp_reqeust_construct_task_context(
440 struct scic_sds_request
*sds_request
,
441 struct scu_task_context
*task_context
)
444 struct scic_sds_controller
*controller
;
445 struct scic_sds_remote_device
*target_device
;
446 struct scic_sds_port
*target_port
;
448 controller
= scic_sds_request_get_controller(sds_request
);
449 target_device
= scic_sds_request_get_device(sds_request
);
450 target_port
= scic_sds_request_get_port(sds_request
);
452 /* Fill in the TC with the its required data */
453 task_context
->abort
= 0;
454 task_context
->priority
= 0;
455 task_context
->initiator_request
= 1;
456 task_context
->connection_rate
=
457 scic_remote_device_get_connection_rate(target_device
);
458 task_context
->protocol_engine_index
=
459 scic_sds_controller_get_protocol_engine_group(controller
);
460 task_context
->logical_port_index
=
461 scic_sds_port_get_index(target_port
);
462 task_context
->protocol_type
= SCU_TASK_CONTEXT_PROTOCOL_SSP
;
463 task_context
->valid
= SCU_TASK_CONTEXT_VALID
;
464 task_context
->context_type
= SCU_TASK_CONTEXT_TYPE
;
466 task_context
->remote_node_index
=
467 scic_sds_remote_device_get_index(sds_request
->target_device
);
468 task_context
->command_code
= 0;
470 task_context
->link_layer_control
= 0;
471 task_context
->do_not_dma_ssp_good_response
= 1;
472 task_context
->strict_ordering
= 0;
473 task_context
->control_frame
= 0;
474 task_context
->timeout_enable
= 0;
475 task_context
->block_guard_enable
= 0;
477 task_context
->address_modifier
= 0;
479 /* task_context->type.ssp.tag = this_request->io_tag; */
480 task_context
->task_phase
= 0x01;
482 if (sds_request
->was_tag_assigned_by_user
) {
484 * Build the task context now since we have already read
487 sds_request
->post_context
=
488 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC
|
489 (scic_sds_controller_get_protocol_engine_group(
491 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT
) |
492 (scic_sds_port_get_index(target_port
) <<
493 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT
) |
494 scic_sds_io_tag_get_index(sds_request
->io_tag
));
497 * Build the task context now since we have already read
500 * I/O tag index is not assigned because we have to wait
503 sds_request
->post_context
=
504 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC
|
505 (scic_sds_controller_get_protocol_engine_group(
506 owning_controller
) <<
507 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT
) |
508 (scic_sds_port_get_index(target_port
) <<
509 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT
));
513 * Copy the physical address for the command buffer to the
516 dma_addr
= scic_io_request_get_dma_addr(sds_request
,
517 sds_request
->command_buffer
);
519 task_context
->command_iu_upper
= upper_32_bits(dma_addr
);
520 task_context
->command_iu_lower
= lower_32_bits(dma_addr
);
523 * Copy the physical address for the response buffer to the
526 dma_addr
= scic_io_request_get_dma_addr(sds_request
,
527 sds_request
->response_buffer
);
529 task_context
->response_iu_upper
= upper_32_bits(dma_addr
);
530 task_context
->response_iu_lower
= lower_32_bits(dma_addr
);
534 * This method is will fill in the SCU Task Context for a SSP IO request.
538 static void scu_ssp_io_request_construct_task_context(
539 struct scic_sds_request
*sci_req
,
540 enum dma_data_direction dir
,
543 struct scu_task_context
*task_context
;
545 task_context
= scic_sds_request_get_task_context(sci_req
);
547 scu_ssp_reqeust_construct_task_context(sci_req
, task_context
);
549 task_context
->ssp_command_iu_length
= sizeof(struct sci_ssp_command_iu
) / sizeof(u32
);
550 task_context
->type
.ssp
.frame_type
= SCI_SAS_COMMAND_FRAME
;
553 case DMA_FROM_DEVICE
:
556 task_context
->task_type
= SCU_TASK_TYPE_IOREAD
;
559 task_context
->task_type
= SCU_TASK_TYPE_IOWRITE
;
563 task_context
->transfer_length_bytes
= len
;
565 if (task_context
->transfer_length_bytes
> 0)
566 scic_sds_request_build_sgl(sci_req
);
571 * This method will fill in the remainder of the io request object for SSP Task
576 static void scic_sds_ssp_task_request_assign_buffers(
577 struct scic_sds_request
*this_request
)
579 /* Assign all of the buffer pointers */
580 this_request
->command_buffer
=
581 scic_sds_ssp_task_request_get_command_buffer(this_request
);
582 this_request
->response_buffer
=
583 scic_sds_ssp_task_request_get_response_buffer(this_request
);
584 this_request
->sgl_element_pair_buffer
= NULL
;
586 if (this_request
->was_tag_assigned_by_user
== false) {
587 this_request
->task_context_buffer
=
588 scic_sds_ssp_task_request_get_task_context_buffer(this_request
);
589 this_request
->task_context_buffer
=
590 PTR_ALIGN(this_request
->task_context_buffer
, SMP_CACHE_BYTES
);
595 * This method will fill in the SCU Task Context for a SSP Task request. The
596 * following important settings are utilized: -# priority ==
597 * SCU_TASK_PRIORITY_HIGH. This ensures that the task request is issued
598 * ahead of other task destined for the same Remote Node. -# task_type ==
599 * SCU_TASK_TYPE_IOREAD. This simply indicates that a normal request type
600 * (i.e. non-raw frame) is being utilized to perform task management. -#
601 * control_frame == 1. This ensures that the proper endianess is set so
602 * that the bytes are transmitted in the right order for a task frame.
603 * @this_request: This parameter specifies the task request object being
607 static void scu_ssp_task_request_construct_task_context(
608 struct scic_sds_request
*this_request
)
610 struct scu_task_context
*task_context
;
612 task_context
= scic_sds_request_get_task_context(this_request
);
614 scu_ssp_reqeust_construct_task_context(this_request
, task_context
);
616 task_context
->control_frame
= 1;
617 task_context
->priority
= SCU_TASK_PRIORITY_HIGH
;
618 task_context
->task_type
= SCU_TASK_TYPE_RAW_FRAME
;
619 task_context
->transfer_length_bytes
= 0;
620 task_context
->type
.ssp
.frame_type
= SCI_SAS_TASK_FRAME
;
621 task_context
->ssp_command_iu_length
= sizeof(struct sci_ssp_task_iu
) / sizeof(u32
);
626 * This method constructs the SSP Command IU data for this ssp passthrough
627 * comand request object.
628 * @this_request: This parameter specifies the request object for which the SSP
629 * command information unit is being built.
631 * enum sci_status, returns invalid parameter is cdb > 16
636 * This method constructs the SATA request object.
645 static enum sci_status
scic_io_request_construct_sata(struct scic_sds_request
*sci_req
,
647 enum dma_data_direction dir
,
650 enum sci_status status
= SCI_SUCCESS
;
653 case SAT_PROTOCOL_PIO_DATA_IN
:
654 case SAT_PROTOCOL_PIO_DATA_OUT
:
655 status
= scic_sds_stp_pio_request_construct(sci_req
, proto
, copy
);
658 case SAT_PROTOCOL_UDMA_DATA_IN
:
659 case SAT_PROTOCOL_UDMA_DATA_OUT
:
660 status
= scic_sds_stp_udma_request_construct(sci_req
, len
, dir
);
663 case SAT_PROTOCOL_ATA_HARD_RESET
:
664 case SAT_PROTOCOL_SOFT_RESET
:
665 status
= scic_sds_stp_soft_reset_request_construct(sci_req
);
668 case SAT_PROTOCOL_NON_DATA
:
669 status
= scic_sds_stp_non_data_request_construct(sci_req
);
672 case SAT_PROTOCOL_FPDMA
:
673 status
= scic_sds_stp_ncq_request_construct(sci_req
, len
, dir
);
676 #if !defined(DISABLE_ATAPI)
677 case SAT_PROTOCOL_PACKET_NON_DATA
:
678 case SAT_PROTOCOL_PACKET_DMA_DATA_IN
:
679 case SAT_PROTOCOL_PACKET_DMA_DATA_OUT
:
680 case SAT_PROTOCOL_PACKET_PIO_DATA_IN
:
681 case SAT_PROTOCOL_PACKET_PIO_DATA_OUT
:
682 status
= scic_sds_stp_packet_request_construct(sci_req
);
686 case SAT_PROTOCOL_DMA_QUEUED
:
687 case SAT_PROTOCOL_DMA
:
688 case SAT_PROTOCOL_DEVICE_DIAGNOSTIC
:
689 case SAT_PROTOCOL_DEVICE_RESET
:
690 case SAT_PROTOCOL_RETURN_RESPONSE_INFO
:
692 dev_err(scic_to_dev(sci_req
->owning_controller
),
693 "%s: SCIC IO Request 0x%p received un-handled "
695 __func__
, sci_req
, proto
);
697 status
= SCI_FAILURE
;
704 u32
scic_io_request_get_object_size(void)
706 u32 ssp_request_size
;
707 u32 stp_request_size
;
708 u32 smp_request_size
;
710 ssp_request_size
= scic_sds_ssp_request_get_object_size();
711 stp_request_size
= scic_sds_stp_request_get_object_size();
712 smp_request_size
= scic_sds_smp_request_get_object_size();
714 return max(ssp_request_size
, max(stp_request_size
, smp_request_size
));
717 enum sci_status
scic_io_request_construct_basic_ssp(
718 struct scic_sds_request
*sci_req
)
720 struct isci_request
*isci_request
=
721 (struct isci_request
*)sci_object_get_association(sci_req
);
723 sci_req
->protocol
= SCIC_SSP_PROTOCOL
;
725 scu_ssp_io_request_construct_task_context(
727 isci_request_io_request_get_data_direction(isci_request
),
728 isci_request_io_request_get_transfer_length(isci_request
));
730 scic_sds_io_request_build_ssp_command_iu(sci_req
);
732 sci_base_state_machine_change_state(
733 &sci_req
->parent
.state_machine
,
734 SCI_BASE_REQUEST_STATE_CONSTRUCTED
741 enum sci_status
scic_task_request_construct_ssp(
742 struct scic_sds_request
*sci_req
)
744 /* Construct the SSP Task SCU Task Context */
745 scu_ssp_task_request_construct_task_context(sci_req
);
747 /* Fill in the SSP Task IU */
748 scic_sds_task_request_build_ssp_task_iu(sci_req
);
750 sci_base_state_machine_change_state(
751 &sci_req
->parent
.state_machine
,
752 SCI_BASE_REQUEST_STATE_CONSTRUCTED
759 enum sci_status
scic_io_request_construct_basic_sata(
760 struct scic_sds_request
*sci_req
)
762 enum sci_status status
;
763 struct scic_sds_stp_request
*stp_req
;
766 enum dma_data_direction dir
;
768 struct isci_request
*isci_request
=
769 (struct isci_request
*)sci_object_get_association(sci_req
);
770 struct sas_task
*task
= isci_request_access_task(isci_request
);
772 stp_req
= container_of(sci_req
, typeof(*stp_req
), parent
);
774 sci_req
->protocol
= SCIC_STP_PROTOCOL
;
776 len
= isci_request_io_request_get_transfer_length(isci_request
);
777 dir
= isci_request_io_request_get_data_direction(isci_request
);
778 proto
= isci_sata_get_sat_protocol(isci_request
);
779 copy
= (task
->data_dir
== DMA_NONE
) ? false : true;
781 status
= scic_io_request_construct_sata(sci_req
, proto
, len
, dir
, copy
);
783 if (status
== SCI_SUCCESS
)
784 sci_base_state_machine_change_state(
785 &sci_req
->parent
.state_machine
,
786 SCI_BASE_REQUEST_STATE_CONSTRUCTED
793 enum sci_status
scic_task_request_construct_sata(
794 struct scic_sds_request
*sci_req
)
796 enum sci_status status
;
798 struct isci_request
*isci_request
=
799 (struct isci_request
*)sci_object_get_association(sci_req
);
801 sat_protocol
= isci_sata_get_sat_protocol(isci_request
);
803 switch (sat_protocol
) {
804 case SAT_PROTOCOL_ATA_HARD_RESET
:
805 case SAT_PROTOCOL_SOFT_RESET
:
806 status
= scic_sds_stp_soft_reset_request_construct(sci_req
);
810 dev_err(scic_to_dev(sci_req
->owning_controller
),
811 "%s: SCIC IO Request 0x%p received un-handled SAT "
817 status
= SCI_FAILURE
;
821 if (status
== SCI_SUCCESS
)
822 sci_base_state_machine_change_state(
823 &sci_req
->parent
.state_machine
,
824 SCI_BASE_REQUEST_STATE_CONSTRUCTED
831 u16
scic_io_request_get_io_tag(
832 struct scic_sds_request
*sci_req
)
834 return sci_req
->io_tag
;
838 u32
scic_request_get_controller_status(
839 struct scic_sds_request
*sci_req
)
841 return sci_req
->scu_status
;
845 void *scic_io_request_get_command_iu_address(
846 struct scic_sds_request
*sci_req
)
848 return sci_req
->command_buffer
;
852 void *scic_io_request_get_response_iu_address(
853 struct scic_sds_request
*sci_req
)
855 return sci_req
->response_buffer
;
859 #define SCU_TASK_CONTEXT_SRAM 0x200000
860 u32
scic_io_request_get_number_of_bytes_transferred(
861 struct scic_sds_request
*scic_sds_request
)
865 if (SMU_AMR_READ(scic_sds_request
->owning_controller
) == 0) {
867 * get the bytes of data from the Address == BAR1 + 20002Ch + (256*TCi) where
868 * BAR1 is the scu_registers
869 * 0x20002C = 0x200000 + 0x2c
870 * = start of task context SRAM + offset of (type.ssp.data_offset)
871 * TCi is the io_tag of struct scic_sds_request */
872 ret_val
= scic_sds_pci_read_scu_dword(
873 scic_sds_request
->owning_controller
,
875 (u8
*)scic_sds_request
->owning_controller
->scu_registers
+
876 (SCU_TASK_CONTEXT_SRAM
+ SCI_FIELD_OFFSET(struct scu_task_context
, type
.ssp
.data_offset
)) +
877 ((sizeof(struct scu_task_context
)) * scic_sds_io_tag_get_index(scic_sds_request
->io_tag
))
887 * ****************************************************************************
888 * * SCIC SDS Interface Implementation
889 * **************************************************************************** */
893 * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
894 * operation is to be executed.
896 * This method invokes the base state start request handler for the
897 * SCIC_SDS_IO_REQUEST_T object. enum sci_status
899 enum sci_status
scic_sds_request_start(
900 struct scic_sds_request
*this_request
)
903 this_request
->device_sequence
904 == scic_sds_remote_device_get_sequence(this_request
->target_device
)
906 return this_request
->state_handlers
->parent
.start_handler(
907 &this_request
->parent
916 * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
917 * operation is to be executed.
919 * This method invokes the base state terminate request handber for the
920 * SCIC_SDS_IO_REQUEST_T object. enum sci_status
922 enum sci_status
scic_sds_io_request_terminate(
923 struct scic_sds_request
*this_request
)
925 return this_request
->state_handlers
->parent
.abort_handler(
926 &this_request
->parent
);
931 * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
932 * operation is to be executed.
934 * This method invokes the base state request completion handler for the
935 * SCIC_SDS_IO_REQUEST_T object. enum sci_status
937 enum sci_status
scic_sds_io_request_complete(
938 struct scic_sds_request
*this_request
)
940 return this_request
->state_handlers
->parent
.complete_handler(
941 &this_request
->parent
);
946 * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
947 * operation is to be executed.
948 * @event_code: The event code returned by the hardware for the task reqeust.
950 * This method invokes the core state handler for the SCIC_SDS_IO_REQUEST_T
951 * object. enum sci_status
953 enum sci_status
scic_sds_io_request_event_handler(
954 struct scic_sds_request
*this_request
,
957 return this_request
->state_handlers
->event_handler(this_request
, event_code
);
962 * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
963 * operation is to be executed.
964 * @frame_index: The frame index returned by the hardware for the reqeust
967 * This method invokes the core state frame handler for the
968 * SCIC_SDS_IO_REQUEST_T object. enum sci_status
970 enum sci_status
scic_sds_io_request_frame_handler(
971 struct scic_sds_request
*this_request
,
974 return this_request
->state_handlers
->frame_handler(this_request
, frame_index
);
979 * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the task start
980 * operation is to be executed.
982 * This method invokes the core state task complete handler for the
983 * SCIC_SDS_IO_REQUEST_T object. enum sci_status
987 * ****************************************************************************
988 * * SCIC SDS PROTECTED METHODS
989 * **************************************************************************** */
992 * This method copies response data for requests returning response data
993 * instead of sense data.
994 * @this_request: This parameter specifies the request object for which to copy
998 void scic_sds_io_request_copy_response(struct scic_sds_request
*sds_request
)
1000 void *response_buffer
;
1001 u32 user_response_length
;
1002 u32 core_response_length
;
1003 struct sci_ssp_response_iu
*ssp_response
;
1004 struct isci_request
*isci_request
=
1005 (struct isci_request
*)sci_object_get_association(sds_request
);
1008 (struct sci_ssp_response_iu
*)sds_request
->response_buffer
;
1011 isci_task_ssp_request_get_response_data_address(
1014 user_response_length
=
1015 isci_task_ssp_request_get_response_data_length(
1018 core_response_length
= sci_ssp_get_response_data_length(
1019 ssp_response
->response_data_length
);
1021 user_response_length
= min(user_response_length
, core_response_length
);
1023 memcpy(response_buffer
, ssp_response
->data
, user_response_length
);
1027 * *****************************************************************************
1028 * * DEFAULT STATE HANDLERS
1029 * ***************************************************************************** */
1032 * scic_sds_request_default_start_handler() -
1033 * @request: This is the struct sci_base_request object that is cast to the
1034 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1036 * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
1037 * object receives a scic_sds_request_start() request. The default action is
1038 * to log a warning and return a failure status. enum sci_status
1039 * SCI_FAILURE_INVALID_STATE
1041 enum sci_status
scic_sds_request_default_start_handler(
1042 struct sci_base_request
*request
)
1044 struct scic_sds_request
*scic_request
=
1045 (struct scic_sds_request
*)request
;
1047 dev_warn(scic_to_dev(scic_request
->owning_controller
),
1048 "%s: SCIC IO Request requested to start while in wrong "
1051 sci_base_state_machine_get_state(
1052 &((struct scic_sds_request
*)request
)->parent
.state_machine
));
1054 return SCI_FAILURE_INVALID_STATE
;
1057 static enum sci_status
scic_sds_request_default_abort_handler(
1058 struct sci_base_request
*request
)
1060 struct scic_sds_request
*scic_request
=
1061 (struct scic_sds_request
*)request
;
1063 dev_warn(scic_to_dev(scic_request
->owning_controller
),
1064 "%s: SCIC IO Request requested to abort while in wrong "
1067 sci_base_state_machine_get_state(
1068 &((struct scic_sds_request
*)request
)->parent
.state_machine
));
1070 return SCI_FAILURE_INVALID_STATE
;
1074 * scic_sds_request_default_complete_handler() -
1075 * @request: This is the struct sci_base_request object that is cast to the
1076 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1078 * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
1079 * object receives a scic_sds_request_complete() request. The default action
1080 * is to log a warning and return a failure status. enum sci_status
1081 * SCI_FAILURE_INVALID_STATE
1083 enum sci_status
scic_sds_request_default_complete_handler(
1084 struct sci_base_request
*request
)
1086 struct scic_sds_request
*scic_request
=
1087 (struct scic_sds_request
*)request
;
1089 dev_warn(scic_to_dev(scic_request
->owning_controller
),
1090 "%s: SCIC IO Request requested to complete while in wrong "
1093 sci_base_state_machine_get_state(
1094 &((struct scic_sds_request
*)request
)->parent
.state_machine
));
1096 return SCI_FAILURE_INVALID_STATE
;
1100 * scic_sds_request_default_destruct_handler() -
1101 * @request: This is the struct sci_base_request object that is cast to the
1102 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1104 * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
1105 * object receives a scic_sds_request_complete() request. The default action
1106 * is to log a warning and return a failure status. enum sci_status
1107 * SCI_FAILURE_INVALID_STATE
1109 enum sci_status
scic_sds_request_default_destruct_handler(
1110 struct sci_base_request
*request
)
1112 struct scic_sds_request
*scic_request
=
1113 (struct scic_sds_request
*)request
;
1115 dev_warn(scic_to_dev(scic_request
->owning_controller
),
1116 "%s: SCIC IO Request requested to destroy while in wrong "
1119 sci_base_state_machine_get_state(
1120 &((struct scic_sds_request
*)request
)->parent
.state_machine
));
1122 return SCI_FAILURE_INVALID_STATE
;
1126 * scic_sds_request_default_tc_completion_handler() -
1127 * @request: This is the struct sci_base_request object that is cast to the
1128 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1130 * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
1131 * object receives a scic_sds_task_request_complete() request. The default
1132 * action is to log a warning and return a failure status. enum sci_status
1133 * SCI_FAILURE_INVALID_STATE
1135 enum sci_status
scic_sds_request_default_tc_completion_handler(
1136 struct scic_sds_request
*this_request
,
1137 u32 completion_code
)
1139 dev_warn(scic_to_dev(this_request
->owning_controller
),
1140 "%s: SCIC IO Request given task completion notification %x "
1141 "while in wrong state %d\n",
1144 sci_base_state_machine_get_state(
1145 &this_request
->parent
.state_machine
));
1147 return SCI_FAILURE_INVALID_STATE
;
1152 * scic_sds_request_default_event_handler() -
1153 * @request: This is the struct sci_base_request object that is cast to the
1154 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1156 * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
1157 * object receives a scic_sds_request_event_handler() request. The default
1158 * action is to log a warning and return a failure status. enum sci_status
1159 * SCI_FAILURE_INVALID_STATE
1161 enum sci_status
scic_sds_request_default_event_handler(
1162 struct scic_sds_request
*this_request
,
1165 dev_warn(scic_to_dev(this_request
->owning_controller
),
1166 "%s: SCIC IO Request given event code notification %x while "
1167 "in wrong state %d\n",
1170 sci_base_state_machine_get_state(
1171 &this_request
->parent
.state_machine
));
1173 return SCI_FAILURE_INVALID_STATE
;
1177 * scic_sds_request_default_frame_handler() -
1178 * @request: This is the struct sci_base_request object that is cast to the
1179 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1181 * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
1182 * object receives a scic_sds_request_event_handler() request. The default
1183 * action is to log a warning and return a failure status. enum sci_status
1184 * SCI_FAILURE_INVALID_STATE
1186 enum sci_status
scic_sds_request_default_frame_handler(
1187 struct scic_sds_request
*this_request
,
1190 dev_warn(scic_to_dev(this_request
->owning_controller
),
1191 "%s: SCIC IO Request given unexpected frame %x while in "
1195 sci_base_state_machine_get_state(
1196 &this_request
->parent
.state_machine
));
1198 scic_sds_controller_release_frame(
1199 this_request
->owning_controller
, frame_index
);
1201 return SCI_FAILURE_INVALID_STATE
;
1205 * *****************************************************************************
1206 * * CONSTRUCTED STATE HANDLERS
1207 * ***************************************************************************** */
1210 * scic_sds_request_constructed_state_start_handler() -
1211 * @request: This is the struct sci_base_request object that is cast to the
1212 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1214 * This method implements the action taken when a constructed
1215 * SCIC_SDS_IO_REQUEST_T object receives a scic_sds_request_start() request.
1216 * This method will, if necessary, allocate a TCi for the io request object and
1217 * then will, if necessary, copy the constructed TC data into the actual TC
1218 * buffer. If everything is successful the post context field is updated with
1219 * the TCi so the controller can post the request to the hardware. enum sci_status
1220 * SCI_SUCCESS SCI_FAILURE_INSUFFICIENT_RESOURCES
1222 static enum sci_status
scic_sds_request_constructed_state_start_handler(
1223 struct sci_base_request
*request
)
1225 struct scu_task_context
*task_context
;
1226 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)request
;
1228 if (this_request
->io_tag
== SCI_CONTROLLER_INVALID_IO_TAG
) {
1229 this_request
->io_tag
=
1230 scic_controller_allocate_io_tag(this_request
->owning_controller
);
1233 /* Record the IO Tag in the request */
1234 if (this_request
->io_tag
!= SCI_CONTROLLER_INVALID_IO_TAG
) {
1235 task_context
= this_request
->task_context_buffer
;
1237 task_context
->task_index
= scic_sds_io_tag_get_index(this_request
->io_tag
);
1239 switch (task_context
->protocol_type
) {
1240 case SCU_TASK_CONTEXT_PROTOCOL_SMP
:
1241 case SCU_TASK_CONTEXT_PROTOCOL_SSP
:
1243 task_context
->type
.ssp
.tag
= this_request
->io_tag
;
1244 task_context
->type
.ssp
.target_port_transfer_tag
= 0xFFFF;
1247 case SCU_TASK_CONTEXT_PROTOCOL_STP
:
1250 * task_context->type.stp.ncq_tag = this_request->ncq_tag; */
1253 case SCU_TASK_CONTEXT_PROTOCOL_NONE
:
1254 /* / @todo When do we set no protocol type? */
1258 /* This should never happen since we build the IO requests */
1263 * Check to see if we need to copy the task context buffer
1264 * or have been building into the task context buffer */
1265 if (this_request
->was_tag_assigned_by_user
== false) {
1266 scic_sds_controller_copy_task_context(
1267 this_request
->owning_controller
, this_request
1271 /* Add to the post_context the io tag value */
1272 this_request
->post_context
|= scic_sds_io_tag_get_index(this_request
->io_tag
);
1274 /* Everything is good go ahead and change state */
1275 sci_base_state_machine_change_state(
1276 &this_request
->parent
.state_machine
,
1277 SCI_BASE_REQUEST_STATE_STARTED
1283 return SCI_FAILURE_INSUFFICIENT_RESOURCES
;
1287 * scic_sds_request_constructed_state_abort_handler() -
1288 * @request: This is the struct sci_base_request object that is cast to the
1289 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1291 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1292 * object receives a scic_sds_request_terminate() request. Since the request
1293 * has not yet been posted to the hardware the request transitions to the
1294 * completed state. enum sci_status SCI_SUCCESS
1296 static enum sci_status
scic_sds_request_constructed_state_abort_handler(
1297 struct sci_base_request
*request
)
1299 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)request
;
1302 * This request has been terminated by the user make sure that the correct
1303 * status code is returned */
1304 scic_sds_request_set_status(
1306 SCU_TASK_DONE_TASK_ABORT
,
1307 SCI_FAILURE_IO_TERMINATED
1310 sci_base_state_machine_change_state(
1311 &this_request
->parent
.state_machine
,
1312 SCI_BASE_REQUEST_STATE_COMPLETED
1319 * *****************************************************************************
1320 * * STARTED STATE HANDLERS
1321 * ***************************************************************************** */
1324 * scic_sds_request_started_state_abort_handler() -
1325 * @request: This is the struct sci_base_request object that is cast to the
1326 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1328 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1329 * object receives a scic_sds_request_terminate() request. Since the request
1330 * has been posted to the hardware the io request state is changed to the
1331 * aborting state. enum sci_status SCI_SUCCESS
1333 enum sci_status
scic_sds_request_started_state_abort_handler(
1334 struct sci_base_request
*request
)
1336 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)request
;
1338 if (this_request
->has_started_substate_machine
) {
1339 sci_base_state_machine_stop(&this_request
->started_substate_machine
);
1342 sci_base_state_machine_change_state(
1343 &this_request
->parent
.state_machine
,
1344 SCI_BASE_REQUEST_STATE_ABORTING
1351 * scic_sds_request_started_state_tc_completion_handler() - This method process
1352 * TC (task context) completions for normal IO request (i.e. Task/Abort
1353 * Completions of type 0). This method will update the
1354 * SCIC_SDS_IO_REQUEST_T::status field.
1355 * @this_request: This parameter specifies the request for which a completion
1357 * @completion_code: This parameter specifies the completion code received from
1361 enum sci_status
scic_sds_request_started_state_tc_completion_handler(
1362 struct scic_sds_request
*this_request
,
1363 u32 completion_code
)
1366 struct sci_ssp_response_iu
*response_buffer
;
1369 * @todo Any SDMA return code of other than 0 is bad
1370 * decode 0x003C0000 to determine SDMA status
1372 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code
)) {
1373 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD
):
1374 scic_sds_request_set_status(
1375 this_request
, SCU_TASK_DONE_GOOD
, SCI_SUCCESS
1379 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP
):
1382 * There are times when the SCU hardware will return an early response
1383 * because the io request specified more data than is returned by the
1384 * target device (mode pages, inquiry data, etc.). We must check the
1385 * response stats to see if this is truly a failed request or a good
1386 * request that just got completed early. */
1387 struct sci_ssp_response_iu
*response
= (struct sci_ssp_response_iu
*)
1388 this_request
->response_buffer
;
1389 scic_word_copy_with_swap(
1390 this_request
->response_buffer
,
1391 this_request
->response_buffer
,
1392 sizeof(struct sci_ssp_response_iu
) / sizeof(u32
)
1395 if (response
->status
== 0) {
1396 scic_sds_request_set_status(
1397 this_request
, SCU_TASK_DONE_GOOD
, SCI_SUCCESS_IO_DONE_EARLY
1400 scic_sds_request_set_status(
1402 SCU_TASK_DONE_CHECK_RESPONSE
,
1403 SCI_FAILURE_IO_RESPONSE_VALID
1409 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE
):
1410 scic_word_copy_with_swap(
1411 this_request
->response_buffer
,
1412 this_request
->response_buffer
,
1413 sizeof(struct sci_ssp_response_iu
) / sizeof(u32
)
1416 scic_sds_request_set_status(
1418 SCU_TASK_DONE_CHECK_RESPONSE
,
1419 SCI_FAILURE_IO_RESPONSE_VALID
1423 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RESP_LEN_ERR
):
1425 * / @todo With TASK_DONE_RESP_LEN_ERR is the response frame guaranteed
1426 * / to be received before this completion status is posted? */
1428 (struct sci_ssp_response_iu
*)this_request
->response_buffer
;
1430 response_buffer
->data_present
& SCI_SSP_RESPONSE_IU_DATA_PRESENT_MASK
;
1432 if ((data_present
== 0x01) || (data_present
== 0x02)) {
1433 scic_sds_request_set_status(
1435 SCU_TASK_DONE_CHECK_RESPONSE
,
1436 SCI_FAILURE_IO_RESPONSE_VALID
1439 scic_sds_request_set_status(
1440 this_request
, SCU_TASK_DONE_GOOD
, SCI_SUCCESS
1445 /* only stp device gets suspended. */
1446 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO
):
1447 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_PERR
):
1448 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_ERR
):
1449 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_DATA_LEN_ERR
):
1450 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_ABORT_ERR
):
1451 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_WD_LEN
):
1452 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR
):
1453 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_RESP
):
1454 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_SDBFIS
):
1455 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR
):
1456 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDB_ERR
):
1457 if (this_request
->protocol
== SCIC_STP_PROTOCOL
) {
1458 scic_sds_request_set_status(
1460 SCU_GET_COMPLETION_TL_STATUS(completion_code
) >> SCU_COMPLETION_TL_STATUS_SHIFT
,
1461 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED
1464 scic_sds_request_set_status(
1466 SCU_GET_COMPLETION_TL_STATUS(completion_code
) >> SCU_COMPLETION_TL_STATUS_SHIFT
,
1467 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
1472 /* both stp/ssp device gets suspended */
1473 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LF_ERR
):
1474 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_WRONG_DESTINATION
):
1475 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1
):
1476 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2
):
1477 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3
):
1478 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_BAD_DESTINATION
):
1479 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_ZONE_VIOLATION
):
1480 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY
):
1481 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED
):
1482 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED
):
1483 scic_sds_request_set_status(
1485 SCU_GET_COMPLETION_TL_STATUS(completion_code
) >> SCU_COMPLETION_TL_STATUS_SHIFT
,
1486 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED
1490 /* neither ssp nor stp gets suspended. */
1491 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_CMD_ERR
):
1492 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_XR
):
1493 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_IU_LEN_ERR
):
1494 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDMA_ERR
):
1495 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OFFSET_ERR
):
1496 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EXCESS_DATA
):
1497 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR
):
1498 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_UFI_ERR
):
1499 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_FRM_TYPE_ERR
):
1500 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_LL_RX_ERR
):
1501 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_DATA
):
1502 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OPEN_FAIL
):
1503 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_VIIT_ENTRY_NV
):
1504 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_IIT_ENTRY_NV
):
1505 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RNCNV_OUTBOUND
):
1507 scic_sds_request_set_status(
1509 SCU_GET_COMPLETION_TL_STATUS(completion_code
) >> SCU_COMPLETION_TL_STATUS_SHIFT
,
1510 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
1516 * @todo This is probably wrong for ACK/NAK timeout conditions
1519 /* In all cases we will treat this as the completion of the IO request. */
1520 sci_base_state_machine_change_state(
1521 &this_request
->parent
.state_machine
,
1522 SCI_BASE_REQUEST_STATE_COMPLETED
1529 * scic_sds_request_started_state_frame_handler() -
1530 * @request: This is the struct sci_base_request object that is cast to the
1531 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1532 * @frame_index: This is the index of the unsolicited frame to be processed.
1534 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1535 * object receives a scic_sds_request_frame_handler() request. This method
1536 * first determines the frame type received. If this is a response frame then
1537 * the response data is copied to the io request response buffer for processing
1538 * at completion time. If the frame type is not a response buffer an error is
1539 * logged. enum sci_status SCI_SUCCESS SCI_FAILURE_INVALID_PARAMETER_VALUE
1541 static enum sci_status
scic_sds_request_started_state_frame_handler(
1542 struct scic_sds_request
*this_request
,
1545 enum sci_status status
;
1546 struct sci_ssp_frame_header
*frame_header
;
1548 /* / @todo If this is a response frame we must record that we received it */
1549 status
= scic_sds_unsolicited_frame_control_get_header(
1550 &(scic_sds_request_get_controller(this_request
)->uf_control
),
1552 (void **)&frame_header
1555 if (frame_header
->frame_type
== SCI_SAS_RESPONSE_FRAME
) {
1556 struct sci_ssp_response_iu
*response_buffer
;
1558 status
= scic_sds_unsolicited_frame_control_get_buffer(
1559 &(scic_sds_request_get_controller(this_request
)->uf_control
),
1561 (void **)&response_buffer
1564 scic_word_copy_with_swap(
1565 this_request
->response_buffer
,
1566 (u32
*)response_buffer
,
1567 sizeof(struct sci_ssp_response_iu
)
1570 response_buffer
= (struct sci_ssp_response_iu
*)this_request
->response_buffer
;
1572 if ((response_buffer
->data_present
== 0x01) ||
1573 (response_buffer
->data_present
== 0x02)) {
1574 scic_sds_request_set_status(
1576 SCU_TASK_DONE_CHECK_RESPONSE
,
1577 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
1580 scic_sds_request_set_status(
1581 this_request
, SCU_TASK_DONE_GOOD
, SCI_SUCCESS
1584 /* This was not a response frame why did it get forwarded? */
1585 dev_err(scic_to_dev(this_request
->owning_controller
),
1586 "%s: SCIC IO Request 0x%p received unexpected "
1587 "frame %d type 0x%02x\n",
1591 frame_header
->frame_type
);
1594 * In any case we are done with this frame buffer return it to the
1596 scic_sds_controller_release_frame(
1597 this_request
->owning_controller
, frame_index
1604 * *****************************************************************************
1605 * * COMPLETED STATE HANDLERS
1606 * ***************************************************************************** */
1610 * scic_sds_request_completed_state_complete_handler() -
1611 * @request: This is the struct sci_base_request object that is cast to the
1612 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1614 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1615 * object receives a scic_sds_request_complete() request. This method frees up
1616 * any io request resources that have been allocated and transitions the
1617 * request to its final state. Consider stopping the state machine instead of
1618 * transitioning to the final state? enum sci_status SCI_SUCCESS
1620 static enum sci_status
scic_sds_request_completed_state_complete_handler(
1621 struct sci_base_request
*request
)
1623 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)request
;
1625 if (this_request
->was_tag_assigned_by_user
!= true) {
1626 scic_controller_free_io_tag(
1627 this_request
->owning_controller
, this_request
->io_tag
1631 if (this_request
->saved_rx_frame_index
!= SCU_INVALID_FRAME_INDEX
) {
1632 scic_sds_controller_release_frame(
1633 this_request
->owning_controller
, this_request
->saved_rx_frame_index
);
1636 sci_base_state_machine_change_state(
1637 &this_request
->parent
.state_machine
,
1638 SCI_BASE_REQUEST_STATE_FINAL
1645 * *****************************************************************************
1646 * * ABORTING STATE HANDLERS
1647 * ***************************************************************************** */
1650 * scic_sds_request_aborting_state_abort_handler() -
1651 * @request: This is the struct sci_base_request object that is cast to the
1652 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1654 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1655 * object receives a scic_sds_request_terminate() request. This method is the
1656 * io request aborting state abort handlers. On receipt of a multiple
1657 * terminate requests the io request will transition to the completed state.
1658 * This should not happen in normal operation. enum sci_status SCI_SUCCESS
1660 static enum sci_status
scic_sds_request_aborting_state_abort_handler(
1661 struct sci_base_request
*request
)
1663 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)request
;
1665 sci_base_state_machine_change_state(
1666 &this_request
->parent
.state_machine
,
1667 SCI_BASE_REQUEST_STATE_COMPLETED
1674 * scic_sds_request_aborting_state_tc_completion_handler() -
1675 * @request: This is the struct sci_base_request object that is cast to the
1676 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1678 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1679 * object receives a scic_sds_request_task_completion() request. This method
1680 * decodes the completion type waiting for the abort task complete
1681 * notification. When the abort task complete is received the io request
1682 * transitions to the completed state. enum sci_status SCI_SUCCESS
1684 static enum sci_status
scic_sds_request_aborting_state_tc_completion_handler(
1685 struct scic_sds_request
*this_request
,
1686 u32 completion_code
)
1688 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code
)) {
1689 case (SCU_TASK_DONE_GOOD
<< SCU_COMPLETION_TL_STATUS_SHIFT
):
1690 case (SCU_TASK_DONE_TASK_ABORT
<< SCU_COMPLETION_TL_STATUS_SHIFT
):
1691 scic_sds_request_set_status(
1692 this_request
, SCU_TASK_DONE_TASK_ABORT
, SCI_FAILURE_IO_TERMINATED
1695 sci_base_state_machine_change_state(
1696 &this_request
->parent
.state_machine
,
1697 SCI_BASE_REQUEST_STATE_COMPLETED
1703 * Unless we get some strange error wait for the task abort to complete
1704 * TODO: Should there be a state change for this completion? */
1712 * scic_sds_request_aborting_state_frame_handler() -
1713 * @request: This is the struct sci_base_request object that is cast to the
1714 * SCIC_SDS_IO_REQUEST_T object for which the start operation is requested.
1716 * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
1717 * object receives a scic_sds_request_frame_handler() request. This method
1718 * discards the unsolicited frame since we are waiting for the abort task
1719 * completion. enum sci_status SCI_SUCCESS
1721 static enum sci_status
scic_sds_request_aborting_state_frame_handler(
1722 struct scic_sds_request
*this_request
,
1725 /* TODO: Is it even possible to get an unsolicited frame in the aborting state? */
1727 scic_sds_controller_release_frame(
1728 this_request
->owning_controller
, frame_index
);
1733 static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table
[] = {
1734 [SCI_BASE_REQUEST_STATE_INITIAL
] = {
1735 .parent
.start_handler
= scic_sds_request_default_start_handler
,
1736 .parent
.abort_handler
= scic_sds_request_default_abort_handler
,
1737 .parent
.complete_handler
= scic_sds_request_default_complete_handler
,
1738 .parent
.destruct_handler
= scic_sds_request_default_destruct_handler
,
1739 .tc_completion_handler
= scic_sds_request_default_tc_completion_handler
,
1740 .event_handler
= scic_sds_request_default_event_handler
,
1741 .frame_handler
= scic_sds_request_default_frame_handler
,
1743 [SCI_BASE_REQUEST_STATE_CONSTRUCTED
] = {
1744 .parent
.start_handler
= scic_sds_request_constructed_state_start_handler
,
1745 .parent
.abort_handler
= scic_sds_request_constructed_state_abort_handler
,
1746 .parent
.complete_handler
= scic_sds_request_default_complete_handler
,
1747 .parent
.destruct_handler
= scic_sds_request_default_destruct_handler
,
1748 .tc_completion_handler
= scic_sds_request_default_tc_completion_handler
,
1749 .event_handler
= scic_sds_request_default_event_handler
,
1750 .frame_handler
= scic_sds_request_default_frame_handler
,
1752 [SCI_BASE_REQUEST_STATE_STARTED
] = {
1753 .parent
.start_handler
= scic_sds_request_default_start_handler
,
1754 .parent
.abort_handler
= scic_sds_request_started_state_abort_handler
,
1755 .parent
.complete_handler
= scic_sds_request_default_complete_handler
,
1756 .parent
.destruct_handler
= scic_sds_request_default_destruct_handler
,
1757 .tc_completion_handler
= scic_sds_request_started_state_tc_completion_handler
,
1758 .event_handler
= scic_sds_request_default_event_handler
,
1759 .frame_handler
= scic_sds_request_started_state_frame_handler
,
1761 [SCI_BASE_REQUEST_STATE_COMPLETED
] = {
1762 .parent
.start_handler
= scic_sds_request_default_start_handler
,
1763 .parent
.abort_handler
= scic_sds_request_default_abort_handler
,
1764 .parent
.complete_handler
= scic_sds_request_completed_state_complete_handler
,
1765 .parent
.destruct_handler
= scic_sds_request_default_destruct_handler
,
1766 .tc_completion_handler
= scic_sds_request_default_tc_completion_handler
,
1767 .event_handler
= scic_sds_request_default_event_handler
,
1768 .frame_handler
= scic_sds_request_default_frame_handler
,
1770 [SCI_BASE_REQUEST_STATE_ABORTING
] = {
1771 .parent
.start_handler
= scic_sds_request_default_start_handler
,
1772 .parent
.abort_handler
= scic_sds_request_aborting_state_abort_handler
,
1773 .parent
.complete_handler
= scic_sds_request_default_complete_handler
,
1774 .parent
.destruct_handler
= scic_sds_request_default_destruct_handler
,
1775 .tc_completion_handler
= scic_sds_request_aborting_state_tc_completion_handler
,
1776 .event_handler
= scic_sds_request_default_event_handler
,
1777 .frame_handler
= scic_sds_request_aborting_state_frame_handler
,
1779 [SCI_BASE_REQUEST_STATE_FINAL
] = {
1780 .parent
.start_handler
= scic_sds_request_default_start_handler
,
1781 .parent
.abort_handler
= scic_sds_request_default_abort_handler
,
1782 .parent
.complete_handler
= scic_sds_request_default_complete_handler
,
1783 .parent
.destruct_handler
= scic_sds_request_default_destruct_handler
,
1784 .tc_completion_handler
= scic_sds_request_default_tc_completion_handler
,
1785 .event_handler
= scic_sds_request_default_event_handler
,
1786 .frame_handler
= scic_sds_request_default_frame_handler
,
1791 * scic_sds_request_initial_state_enter() -
1792 * @object: This parameter specifies the base object for which the state
1793 * transition is occurring.
1795 * This method implements the actions taken when entering the
1796 * SCI_BASE_REQUEST_STATE_INITIAL state. This state is entered when the initial
1797 * base request is constructed. Entry into the initial state sets all handlers
1798 * for the io request object to their default handlers. none
1800 static void scic_sds_request_initial_state_enter(
1801 struct sci_base_object
*object
)
1803 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)object
;
1807 scic_sds_request_state_handler_table
,
1808 SCI_BASE_REQUEST_STATE_INITIAL
1813 * scic_sds_request_constructed_state_enter() -
1814 * @object: The io request object that is to enter the constructed state.
1816 * This method implements the actions taken when entering the
1817 * SCI_BASE_REQUEST_STATE_CONSTRUCTED state. The method sets the state handlers
1818 * for the the constructed state. none
1820 static void scic_sds_request_constructed_state_enter(
1821 struct sci_base_object
*object
)
1823 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)object
;
1827 scic_sds_request_state_handler_table
,
1828 SCI_BASE_REQUEST_STATE_CONSTRUCTED
1833 * scic_sds_request_started_state_enter() -
1834 * @object: This parameter specifies the base object for which the state
1835 * transition is occuring. This is cast into a SCIC_SDS_IO_REQUEST object.
1837 * This method implements the actions taken when entering the
1838 * SCI_BASE_REQUEST_STATE_STARTED state. If the io request object type is a
1839 * SCSI Task request we must enter the started substate machine. none
1841 static void scic_sds_request_started_state_enter(
1842 struct sci_base_object
*object
)
1844 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)object
;
1848 scic_sds_request_state_handler_table
,
1849 SCI_BASE_REQUEST_STATE_STARTED
1853 * Most of the request state machines have a started substate machine so
1854 * start its execution on the entry to the started state. */
1855 if (this_request
->has_started_substate_machine
== true)
1856 sci_base_state_machine_start(&this_request
->started_substate_machine
);
1860 * scic_sds_request_started_state_exit() -
1861 * @object: This parameter specifies the base object for which the state
1862 * transition is occuring. This object is cast into a SCIC_SDS_IO_REQUEST
1865 * This method implements the actions taken when exiting the
1866 * SCI_BASE_REQUEST_STATE_STARTED state. For task requests the action will be
1867 * to stop the started substate machine. none
1869 static void scic_sds_request_started_state_exit(
1870 struct sci_base_object
*object
)
1872 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)object
;
1874 if (this_request
->has_started_substate_machine
== true)
1875 sci_base_state_machine_stop(&this_request
->started_substate_machine
);
1879 * scic_sds_request_completed_state_enter() -
1880 * @object: This parameter specifies the base object for which the state
1881 * transition is occuring. This object is cast into a SCIC_SDS_IO_REQUEST
1884 * This method implements the actions taken when entering the
1885 * SCI_BASE_REQUEST_STATE_COMPLETED state. This state is entered when the
1886 * SCIC_SDS_IO_REQUEST has completed. The method will decode the request
1887 * completion status and convert it to an enum sci_status to return in the
1888 * completion callback function. none
1890 static void scic_sds_request_completed_state_enter(
1891 struct sci_base_object
*object
)
1893 struct scic_sds_request
*sci_req
= (struct scic_sds_request
*)object
;
1894 struct scic_sds_controller
*scic
=
1895 scic_sds_request_get_controller(sci_req
);
1896 struct isci_host
*ihost
= sci_object_get_association(scic
);
1897 struct isci_request
*ireq
= sci_object_get_association(sci_req
);
1900 SET_STATE_HANDLER(sci_req
,
1901 scic_sds_request_state_handler_table
,
1902 SCI_BASE_REQUEST_STATE_COMPLETED
);
1904 /* Tell the SCI_USER that the IO request is complete */
1905 if (sci_req
->is_task_management_request
== false)
1906 isci_request_io_request_complete(ihost
,
1908 sci_req
->sci_status
);
1910 isci_task_request_complete(ihost
, ireq
, sci_req
->sci_status
);
1914 * scic_sds_request_aborting_state_enter() -
1915 * @object: This parameter specifies the base object for which the state
1916 * transition is occuring. This object is cast into a SCIC_SDS_IO_REQUEST
1919 * This method implements the actions taken when entering the
1920 * SCI_BASE_REQUEST_STATE_ABORTING state. none
1922 static void scic_sds_request_aborting_state_enter(
1923 struct sci_base_object
*object
)
1925 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)object
;
1927 /* Setting the abort bit in the Task Context is required by the silicon. */
1928 this_request
->task_context_buffer
->abort
= 1;
1932 scic_sds_request_state_handler_table
,
1933 SCI_BASE_REQUEST_STATE_ABORTING
1938 * scic_sds_request_final_state_enter() -
1939 * @object: This parameter specifies the base object for which the state
1940 * transition is occuring. This is cast into a SCIC_SDS_IO_REQUEST object.
1942 * This method implements the actions taken when entering the
1943 * SCI_BASE_REQUEST_STATE_FINAL state. The only action required is to put the
1944 * state handlers in place. none
1946 static void scic_sds_request_final_state_enter(
1947 struct sci_base_object
*object
)
1949 struct scic_sds_request
*this_request
= (struct scic_sds_request
*)object
;
1953 scic_sds_request_state_handler_table
,
1954 SCI_BASE_REQUEST_STATE_FINAL
1958 static const struct sci_base_state scic_sds_request_state_table
[] = {
1959 [SCI_BASE_REQUEST_STATE_INITIAL
] = {
1960 .enter_state
= scic_sds_request_initial_state_enter
,
1962 [SCI_BASE_REQUEST_STATE_CONSTRUCTED
] = {
1963 .enter_state
= scic_sds_request_constructed_state_enter
,
1965 [SCI_BASE_REQUEST_STATE_STARTED
] = {
1966 .enter_state
= scic_sds_request_started_state_enter
,
1967 .exit_state
= scic_sds_request_started_state_exit
1969 [SCI_BASE_REQUEST_STATE_COMPLETED
] = {
1970 .enter_state
= scic_sds_request_completed_state_enter
,
1972 [SCI_BASE_REQUEST_STATE_ABORTING
] = {
1973 .enter_state
= scic_sds_request_aborting_state_enter
,
1975 [SCI_BASE_REQUEST_STATE_FINAL
] = {
1976 .enter_state
= scic_sds_request_final_state_enter
,
1980 static void scic_sds_general_request_construct(struct scic_sds_controller
*scic
,
1981 struct scic_sds_remote_device
*sci_dev
,
1983 void *user_io_request_object
,
1984 struct scic_sds_request
*sci_req
)
1986 sci_base_request_construct(&sci_req
->parent
, scic_sds_request_state_table
);
1987 sci_req
->io_tag
= io_tag
;
1988 sci_req
->user_request
= user_io_request_object
;
1989 sci_req
->owning_controller
= scic
;
1990 sci_req
->target_device
= sci_dev
;
1991 sci_req
->has_started_substate_machine
= false;
1992 sci_req
->protocol
= SCIC_NO_PROTOCOL
;
1993 sci_req
->saved_rx_frame_index
= SCU_INVALID_FRAME_INDEX
;
1994 sci_req
->device_sequence
= scic_sds_remote_device_get_sequence(sci_dev
);
1996 sci_req
->sci_status
= SCI_SUCCESS
;
1997 sci_req
->scu_status
= 0;
1998 sci_req
->post_context
= 0xFFFFFFFF;
2000 sci_req
->is_task_management_request
= false;
2002 if (io_tag
== SCI_CONTROLLER_INVALID_IO_TAG
) {
2003 sci_req
->was_tag_assigned_by_user
= false;
2004 sci_req
->task_context_buffer
= NULL
;
2006 sci_req
->was_tag_assigned_by_user
= true;
2008 sci_req
->task_context_buffer
=
2009 scic_sds_controller_get_task_context_buffer(scic
, io_tag
);
2013 enum sci_status
scic_io_request_construct(struct scic_sds_controller
*scic
,
2014 struct scic_sds_remote_device
*sci_dev
,
2016 void *user_io_request_object
,
2017 struct scic_sds_request
*sci_req
,
2018 struct scic_sds_request
**new_scic_io_request_handle
)
2020 enum sci_status status
= SCI_SUCCESS
;
2021 struct smp_discover_response_protocols device_protocol
;
2023 /* Build the common part of the request */
2024 scic_sds_general_request_construct(scic
, sci_dev
, io_tag
,
2025 user_io_request_object
, sci_req
);
2027 if (sci_dev
->rnc
->remote_node_index
== SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
)
2028 return SCI_FAILURE_INVALID_REMOTE_DEVICE
;
2030 scic_remote_device_get_protocols(sci_dev
, &device_protocol
);
2032 if (device_protocol
.u
.bits
.attached_ssp_target
) {
2033 scic_sds_ssp_io_request_assign_buffers(sci_req
);
2034 } else if (device_protocol
.u
.bits
.attached_stp_target
) {
2035 scic_sds_stp_request_assign_buffers(sci_req
);
2036 memset(sci_req
->command_buffer
, 0, sizeof(struct sata_fis_reg_h2d
));
2037 } else if (device_protocol
.u
.bits
.attached_smp_target
) {
2038 scic_sds_smp_request_assign_buffers(sci_req
);
2039 memset(sci_req
->command_buffer
, 0, sizeof(struct smp_request
));
2041 status
= SCI_FAILURE_UNSUPPORTED_PROTOCOL
;
2044 if (status
== SCI_SUCCESS
) {
2045 memset(sci_req
->task_context_buffer
, 0,
2046 SCI_FIELD_OFFSET(struct scu_task_context
, sgl_pair_ab
));
2047 *new_scic_io_request_handle
= sci_req
;
2053 enum sci_status
scic_task_request_construct(struct scic_sds_controller
*scic
,
2054 struct scic_sds_remote_device
*sci_dev
,
2056 void *user_io_request_object
,
2057 struct scic_sds_request
*sci_req
,
2058 struct scic_sds_request
**new_sci_req
)
2060 enum sci_status status
= SCI_SUCCESS
;
2061 struct smp_discover_response_protocols device_protocol
;
2063 /* Build the common part of the request */
2064 scic_sds_general_request_construct(scic
, sci_dev
, io_tag
,
2065 user_io_request_object
,
2068 scic_remote_device_get_protocols(sci_dev
, &device_protocol
);
2070 if (device_protocol
.u
.bits
.attached_ssp_target
) {
2071 scic_sds_ssp_task_request_assign_buffers(sci_req
);
2073 sci_req
->has_started_substate_machine
= true;
2075 /* Construct the started sub-state machine. */
2076 sci_base_state_machine_construct(
2077 &sci_req
->started_substate_machine
,
2078 &sci_req
->parent
.parent
,
2079 scic_sds_io_request_started_task_mgmt_substate_table
,
2080 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
2082 } else if (device_protocol
.u
.bits
.attached_stp_target
) {
2083 scic_sds_stp_request_assign_buffers(sci_req
);
2085 status
= SCI_FAILURE_UNSUPPORTED_PROTOCOL
;
2088 if (status
== SCI_SUCCESS
) {
2089 sci_req
->is_task_management_request
= true;
2090 memset(sci_req
->task_context_buffer
, 0, sizeof(struct scu_task_context
));
2091 *new_sci_req
= sci_req
;