Lines Matching refs:ireq
74 static struct scu_sgl_element_pair *to_sgl_element_pair(struct isci_request *ireq, in to_sgl_element_pair() argument
78 return &ireq->tc->sgl_pair_ab; in to_sgl_element_pair()
80 return &ireq->tc->sgl_pair_cd; in to_sgl_element_pair()
84 return &ireq->sg_table[idx - 2]; in to_sgl_element_pair()
88 struct isci_request *ireq, u32 idx) in to_sgl_element_pair_dma() argument
93 offset = (void *) &ireq->tc->sgl_pair_ab - in to_sgl_element_pair_dma()
97 offset = (void *) &ireq->tc->sgl_pair_cd - in to_sgl_element_pair_dma()
102 return sci_io_request_get_dma_addr(ireq, &ireq->sg_table[idx - 2]); in to_sgl_element_pair_dma()
113 static void sci_request_build_sgl(struct isci_request *ireq) in sci_request_build_sgl() argument
115 struct isci_host *ihost = ireq->isci_host; in sci_request_build_sgl()
116 struct sas_task *task = isci_request_access_task(ireq); in sci_request_build_sgl()
127 scu_sg = to_sgl_element_pair(ireq, sg_idx); in sci_request_build_sgl()
138 ireq, in sci_request_build_sgl()
151 scu_sg = to_sgl_element_pair(ireq, sg_idx); in sci_request_build_sgl()
158 ireq->zero_scatter_daddr = dma_addr; in sci_request_build_sgl()
171 static void sci_io_request_build_ssp_command_iu(struct isci_request *ireq) in sci_io_request_build_ssp_command_iu() argument
174 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_build_ssp_command_iu()
176 cmd_iu = &ireq->ssp.cmd; in sci_io_request_build_ssp_command_iu()
191 static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq) in sci_task_request_build_ssp_task_iu() argument
194 struct sas_task *task = isci_request_access_task(ireq); in sci_task_request_build_ssp_task_iu()
195 struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); in sci_task_request_build_ssp_task_iu()
197 task_iu = &ireq->ssp.tmf; in sci_task_request_build_ssp_task_iu()
205 (test_bit(IREQ_TMF, &ireq->flags)) ? in sci_task_request_build_ssp_task_iu()
217 struct isci_request *ireq, in scu_ssp_reqeust_construct_task_context() argument
224 idev = ireq->target_device; in scu_ssp_reqeust_construct_task_context()
253 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in scu_ssp_reqeust_construct_task_context()
257 ISCI_TAG_TCI(ireq->io_tag)); in scu_ssp_reqeust_construct_task_context()
263 dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.cmd); in scu_ssp_reqeust_construct_task_context()
272 dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.rsp); in scu_ssp_reqeust_construct_task_context()
297 static void scu_ssp_ireq_dif_insert(struct isci_request *ireq, u8 type, u8 op) in scu_ssp_ireq_dif_insert() argument
299 struct scu_task_context *tc = ireq->tc; in scu_ssp_ireq_dif_insert()
300 struct scsi_cmnd *scmd = ireq->ttype_ptr.io_task_ptr->uldd_task; in scu_ssp_ireq_dif_insert()
352 static void scu_ssp_ireq_dif_strip(struct isci_request *ireq, u8 type, u8 op) in scu_ssp_ireq_dif_strip() argument
354 struct scu_task_context *tc = ireq->tc; in scu_ssp_ireq_dif_strip()
355 struct scsi_cmnd *scmd = ireq->ttype_ptr.io_task_ptr->uldd_task; in scu_ssp_ireq_dif_strip()
418 static void scu_ssp_io_request_construct_task_context(struct isci_request *ireq, in scu_ssp_io_request_construct_task_context() argument
422 struct scu_task_context *task_context = ireq->tc; in scu_ssp_io_request_construct_task_context()
423 struct sas_task *sas_task = ireq->ttype_ptr.io_task_ptr; in scu_ssp_io_request_construct_task_context()
428 scu_ssp_reqeust_construct_task_context(ireq, task_context); in scu_ssp_io_request_construct_task_context()
448 sci_request_build_sgl(ireq); in scu_ssp_io_request_construct_task_context()
452 scu_ssp_ireq_dif_strip(ireq, prot_type, prot_op); in scu_ssp_io_request_construct_task_context()
454 scu_ssp_ireq_dif_insert(ireq, prot_type, prot_op); in scu_ssp_io_request_construct_task_context()
471 static void scu_ssp_task_request_construct_task_context(struct isci_request *ireq) in scu_ssp_task_request_construct_task_context() argument
473 struct scu_task_context *task_context = ireq->tc; in scu_ssp_task_request_construct_task_context()
475 scu_ssp_reqeust_construct_task_context(ireq, task_context); in scu_ssp_task_request_construct_task_context()
499 struct isci_request *ireq, in scu_sata_reqeust_construct_task_context() argument
506 idev = ireq->target_device; in scu_sata_reqeust_construct_task_context()
537 task_context->type.words[0] = *(u32 *)&ireq->stp.cmd; in scu_sata_reqeust_construct_task_context()
539 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in scu_sata_reqeust_construct_task_context()
543 ISCI_TAG_TCI(ireq->io_tag)); in scu_sata_reqeust_construct_task_context()
549 dma_addr = sci_io_request_get_dma_addr(ireq, in scu_sata_reqeust_construct_task_context()
550 ((char *) &ireq->stp.cmd) + in scu_sata_reqeust_construct_task_context()
561 static void scu_stp_raw_request_construct_task_context(struct isci_request *ireq) in scu_stp_raw_request_construct_task_context() argument
563 struct scu_task_context *task_context = ireq->tc; in scu_stp_raw_request_construct_task_context()
565 scu_sata_reqeust_construct_task_context(ireq, task_context); in scu_stp_raw_request_construct_task_context()
574 static enum sci_status sci_stp_pio_request_construct(struct isci_request *ireq, in sci_stp_pio_request_construct() argument
577 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_pio_request_construct()
579 scu_stp_raw_request_construct_task_context(ireq); in sci_stp_pio_request_construct()
586 sci_request_build_sgl(ireq); in sci_stp_pio_request_construct()
608 static void sci_stp_optimized_request_construct(struct isci_request *ireq, in sci_stp_optimized_request_construct() argument
613 struct scu_task_context *task_context = ireq->tc; in sci_stp_optimized_request_construct()
616 scu_sata_reqeust_construct_task_context(ireq, task_context); in sci_stp_optimized_request_construct()
619 sci_request_build_sgl(ireq); in sci_stp_optimized_request_construct()
641 static void sci_atapi_construct(struct isci_request *ireq) in sci_atapi_construct() argument
643 struct host_to_dev_fis *h2d_fis = &ireq->stp.cmd; in sci_atapi_construct()
653 scu_stp_raw_request_construct_task_context(ireq); in sci_atapi_construct()
655 task = isci_request_access_task(ireq); in sci_atapi_construct()
662 ireq->stp.rsp.fis_type = 0; in sci_atapi_construct()
666 sci_io_request_construct_sata(struct isci_request *ireq, in sci_io_request_construct_sata() argument
672 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_construct_sata()
673 struct domain_device *dev = ireq->target_device->domain_dev; in sci_io_request_construct_sata()
676 if (test_bit(IREQ_TMF, &ireq->flags)) { in sci_io_request_construct_sata()
677 struct isci_tmf *tmf = isci_request_access_tmf(ireq); in sci_io_request_construct_sata()
679 dev_err(&ireq->owning_controller->pdev->dev, in sci_io_request_construct_sata()
682 __func__, ireq, tmf->tmf_code); in sci_io_request_construct_sata()
688 dev_err(&ireq->owning_controller->pdev->dev, in sci_io_request_construct_sata()
699 sci_atapi_construct(ireq); in sci_io_request_construct_sata()
705 scu_stp_raw_request_construct_task_context(ireq); in sci_io_request_construct_sata()
711 sci_stp_optimized_request_construct(ireq, in sci_io_request_construct_sata()
719 sci_stp_optimized_request_construct(ireq, in sci_io_request_construct_sata()
724 return sci_stp_pio_request_construct(ireq, copy); in sci_io_request_construct_sata()
729 static enum sci_status sci_io_request_construct_basic_ssp(struct isci_request *ireq) in sci_io_request_construct_basic_ssp() argument
731 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_construct_basic_ssp()
733 ireq->protocol = SAS_PROTOCOL_SSP; in sci_io_request_construct_basic_ssp()
735 scu_ssp_io_request_construct_task_context(ireq, in sci_io_request_construct_basic_ssp()
739 sci_io_request_build_ssp_command_iu(ireq); in sci_io_request_construct_basic_ssp()
741 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_basic_ssp()
747 struct isci_request *ireq) in sci_task_request_construct_ssp() argument
750 scu_ssp_task_request_construct_task_context(ireq); in sci_task_request_construct_ssp()
753 sci_task_request_build_ssp_task_iu(ireq); in sci_task_request_construct_ssp()
755 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_task_request_construct_ssp()
760 static enum sci_status sci_io_request_construct_basic_sata(struct isci_request *ireq) in sci_io_request_construct_basic_sata() argument
764 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_construct_basic_sata()
766 ireq->protocol = SAS_PROTOCOL_STP; in sci_io_request_construct_basic_sata()
770 status = sci_io_request_construct_sata(ireq, in sci_io_request_construct_basic_sata()
776 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_basic_sata()
786 static u32 sci_req_tx_bytes(struct isci_request *ireq) in sci_req_tx_bytes() argument
788 struct isci_host *ihost = ireq->owning_controller; in sci_req_tx_bytes()
802 ((sizeof(struct scu_task_context)) * ISCI_TAG_TCI(ireq->io_tag))); in sci_req_tx_bytes()
808 enum sci_status sci_request_start(struct isci_request *ireq) in sci_request_start() argument
811 struct scu_task_context *tc = ireq->tc; in sci_request_start()
812 struct isci_host *ihost = ireq->owning_controller; in sci_request_start()
814 state = ireq->sm.current_state_id; in sci_request_start()
822 tc->task_index = ISCI_TAG_TCI(ireq->io_tag); in sci_request_start()
828 tc->type.ssp.tag = ireq->io_tag; in sci_request_start()
849 ireq->post_context |= ISCI_TAG_TCI(ireq->io_tag); in sci_request_start()
852 sci_change_state(&ireq->sm, SCI_REQ_STARTED); in sci_request_start()
858 sci_io_request_terminate(struct isci_request *ireq) in sci_io_request_terminate() argument
862 state = ireq->sm.current_state_id; in sci_io_request_terminate()
867 set_bit(IREQ_TC_ABORT_POSTED, &ireq->flags); in sci_io_request_terminate()
868 ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; in sci_io_request_terminate()
869 ireq->sci_status = SCI_FAILURE_IO_TERMINATED; in sci_io_request_terminate()
870 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_terminate()
896 sci_change_state(&ireq->sm, SCI_REQ_ABORTING); in sci_io_request_terminate()
899 if (!isci_remote_device_is_safe_to_abort(ireq->target_device)) in sci_io_request_terminate()
900 set_bit(IREQ_PENDING_ABORT, &ireq->flags); in sci_io_request_terminate()
902 clear_bit(IREQ_PENDING_ABORT, &ireq->flags); in sci_io_request_terminate()
909 dev_warn(&ireq->owning_controller->pdev->dev, in sci_io_request_terminate()
911 "state %d\n", __func__, ireq->sm.current_state_id); in sci_io_request_terminate()
918 enum sci_status sci_request_complete(struct isci_request *ireq) in sci_request_complete() argument
921 struct isci_host *ihost = ireq->owning_controller; in sci_request_complete()
923 state = ireq->sm.current_state_id; in sci_request_complete()
929 if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) in sci_request_complete()
931 ireq->saved_rx_frame_index); in sci_request_complete()
934 sci_change_state(&ireq->sm, SCI_REQ_FINAL); in sci_request_complete()
938 enum sci_status sci_io_request_event_handler(struct isci_request *ireq, in sci_io_request_event_handler() argument
942 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_event_handler()
944 state = ireq->sm.current_state_id; in sci_io_request_event_handler()
958 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_event_handler()
978 static void sci_io_request_copy_response(struct isci_request *ireq) in sci_io_request_copy_response() argument
983 struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); in sci_io_request_copy_response()
985 ssp_response = &ireq->ssp.rsp; in sci_io_request_copy_response()
997 request_started_state_tc_event(struct isci_request *ireq, in request_started_state_tc_event() argument
1008 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1009 ireq->sci_status = SCI_SUCCESS; in request_started_state_tc_event()
1019 struct ssp_response_iu *resp = &ireq->ssp.rsp; in request_started_state_tc_event()
1022 sci_swab32_cpy(&ireq->ssp.rsp, in request_started_state_tc_event()
1023 &ireq->ssp.rsp, in request_started_state_tc_event()
1027 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1028 ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; in request_started_state_tc_event()
1030 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1031 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1038 sci_swab32_cpy(&ireq->ssp.rsp, in request_started_state_tc_event()
1039 &ireq->ssp.rsp, in request_started_state_tc_event()
1042 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1043 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1052 resp_iu = &ireq->ssp.rsp; in request_started_state_tc_event()
1056 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in request_started_state_tc_event()
1057 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in request_started_state_tc_event()
1059 ireq->scu_status = SCU_TASK_DONE_GOOD; in request_started_state_tc_event()
1060 ireq->sci_status = SCI_SUCCESS; in request_started_state_tc_event()
1075 if (ireq->protocol == SAS_PROTOCOL_STP) { in request_started_state_tc_event()
1076 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1078 ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; in request_started_state_tc_event()
1080 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1082 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in request_started_state_tc_event()
1097 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1099 ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; in request_started_state_tc_event()
1119 ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> in request_started_state_tc_event()
1121 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in request_started_state_tc_event()
1130 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in request_started_state_tc_event()
1135 request_aborting_state_tc_event(struct isci_request *ireq, in request_aborting_state_tc_event() argument
1141 ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; in request_aborting_state_tc_event()
1142 ireq->sci_status = SCI_FAILURE_IO_TERMINATED; in request_aborting_state_tc_event()
1143 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in request_aborting_state_tc_event()
1156 static enum sci_status ssp_task_request_await_tc_event(struct isci_request *ireq, in ssp_task_request_await_tc_event() argument
1161 ireq->scu_status = SCU_TASK_DONE_GOOD; in ssp_task_request_await_tc_event()
1162 ireq->sci_status = SCI_SUCCESS; in ssp_task_request_await_tc_event()
1163 sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); in ssp_task_request_await_tc_event()
1171 dev_warn(&ireq->owning_controller->pdev->dev, in ssp_task_request_await_tc_event()
1173 "ACK/NAK timeout\n", __func__, ireq, in ssp_task_request_await_tc_event()
1176 sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); in ssp_task_request_await_tc_event()
1184 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in ssp_task_request_await_tc_event()
1185 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in ssp_task_request_await_tc_event()
1186 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in ssp_task_request_await_tc_event()
1194 smp_request_await_response_tc_event(struct isci_request *ireq, in smp_request_await_response_tc_event() argument
1203 ireq->scu_status = SCU_TASK_DONE_GOOD; in smp_request_await_response_tc_event()
1204 ireq->sci_status = SCI_SUCCESS; in smp_request_await_response_tc_event()
1205 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1218 ireq->scu_status = SCU_TASK_DONE_SMP_RESP_TO_ERR; in smp_request_await_response_tc_event()
1219 ireq->sci_status = SCI_FAILURE_RETRY_REQUIRED; in smp_request_await_response_tc_event()
1220 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1226 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in smp_request_await_response_tc_event()
1227 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in smp_request_await_response_tc_event()
1228 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_response_tc_event()
1236 smp_request_await_tc_event(struct isci_request *ireq, in smp_request_await_tc_event() argument
1241 ireq->scu_status = SCU_TASK_DONE_GOOD; in smp_request_await_tc_event()
1242 ireq->sci_status = SCI_SUCCESS; in smp_request_await_tc_event()
1243 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_tc_event()
1250 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in smp_request_await_tc_event()
1251 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in smp_request_await_tc_event()
1252 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in smp_request_await_tc_event()
1263 struct isci_request *ireq = to_ireq(stp_req); in pio_sgl_next() local
1266 sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); in pio_sgl_next()
1284 sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); in pio_sgl_next()
1293 stp_request_non_data_await_h2d_tc_event(struct isci_request *ireq, in stp_request_non_data_await_h2d_tc_event() argument
1298 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_non_data_await_h2d_tc_event()
1299 ireq->sci_status = SCI_SUCCESS; in stp_request_non_data_await_h2d_tc_event()
1300 sci_change_state(&ireq->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H); in stp_request_non_data_await_h2d_tc_event()
1308 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_non_data_await_h2d_tc_event()
1309 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_non_data_await_h2d_tc_event()
1310 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_non_data_await_h2d_tc_event()
1323 struct isci_request *ireq, in sci_stp_request_pio_data_out_trasmit_data_frame() argument
1326 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_request_pio_data_out_trasmit_data_frame()
1327 struct scu_task_context *task_context = ireq->tc; in sci_stp_request_pio_data_out_trasmit_data_frame()
1334 sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); in sci_stp_request_pio_data_out_trasmit_data_frame()
1347 return sci_controller_continue_io(ireq); in sci_stp_request_pio_data_out_trasmit_data_frame()
1350 static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_request *ireq) in sci_stp_request_pio_data_out_transmit_data() argument
1352 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_stp_request_pio_data_out_transmit_data()
1360 sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); in sci_stp_request_pio_data_out_transmit_data()
1376 status = sci_stp_request_pio_data_out_trasmit_data_frame(ireq, len); in sci_stp_request_pio_data_out_transmit_data()
1385 sci_stp_request_pio_data_out_trasmit_data_frame(ireq, stp_req->pio_len); in sci_stp_request_pio_data_out_transmit_data()
1411 struct isci_request *ireq; in sci_stp_request_pio_data_in_copy_data_buffer() local
1419 ireq = to_ireq(stp_req); in sci_stp_request_pio_data_in_copy_data_buffer()
1420 task = isci_request_access_task(ireq); in sci_stp_request_pio_data_in_copy_data_buffer()
1480 stp_request_pio_await_h2d_completion_tc_event(struct isci_request *ireq, in stp_request_pio_await_h2d_completion_tc_event() argument
1487 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_pio_await_h2d_completion_tc_event()
1488 ireq->sci_status = SCI_SUCCESS; in stp_request_pio_await_h2d_completion_tc_event()
1489 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in stp_request_pio_await_h2d_completion_tc_event()
1497 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_pio_await_h2d_completion_tc_event()
1498 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_pio_await_h2d_completion_tc_event()
1499 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_pio_await_h2d_completion_tc_event()
1507 pio_data_out_tx_done_tc_event(struct isci_request *ireq, in pio_data_out_tx_done_tc_event() argument
1512 struct isci_stp_request *stp_req = &ireq->stp.req; in pio_data_out_tx_done_tc_event()
1518 status = sci_stp_request_pio_data_out_transmit_data(ireq); in pio_data_out_tx_done_tc_event()
1536 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in pio_data_out_tx_done_tc_event()
1546 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in pio_data_out_tx_done_tc_event()
1547 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in pio_data_out_tx_done_tc_event()
1548 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in pio_data_out_tx_done_tc_event()
1555 static enum sci_status sci_stp_request_udma_general_frame_handler(struct isci_request *ireq, in sci_stp_request_udma_general_frame_handler() argument
1558 struct isci_host *ihost = ireq->owning_controller; in sci_stp_request_udma_general_frame_handler()
1573 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_stp_request_udma_general_frame_handler()
1583 static enum sci_status process_unsolicited_fis(struct isci_request *ireq, in process_unsolicited_fis() argument
1586 struct isci_host *ihost = ireq->owning_controller; in process_unsolicited_fis()
1599 dev_err(&ireq->isci_host->pdev->dev, in process_unsolicited_fis()
1609 sci_controller_copy_sata_response(&ireq->stp.rsp, in process_unsolicited_fis()
1619 static enum sci_status atapi_d2h_reg_frame_handler(struct isci_request *ireq, in atapi_d2h_reg_frame_handler() argument
1622 struct sas_task *task = isci_request_access_task(ireq); in atapi_d2h_reg_frame_handler()
1625 status = process_unsolicited_fis(ireq, frame_index); in atapi_d2h_reg_frame_handler()
1628 if (ireq->stp.rsp.status & ATA_ERR) in atapi_d2h_reg_frame_handler()
1635 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in atapi_d2h_reg_frame_handler()
1636 ireq->sci_status = status; in atapi_d2h_reg_frame_handler()
1638 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_d2h_reg_frame_handler()
1639 ireq->sci_status = SCI_SUCCESS; in atapi_d2h_reg_frame_handler()
1644 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_d2h_reg_frame_handler()
1649 static void scu_atapi_reconstruct_raw_frame_task_context(struct isci_request *ireq) in scu_atapi_reconstruct_raw_frame_task_context() argument
1651 struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); in scu_atapi_reconstruct_raw_frame_task_context()
1652 void *atapi_cdb = ireq->ttype_ptr.io_task_ptr->ata_task.atapi_packet; in scu_atapi_reconstruct_raw_frame_task_context()
1653 struct scu_task_context *task_context = ireq->tc; in scu_atapi_reconstruct_raw_frame_task_context()
1659 memset(&ireq->stp.cmd, 0, sizeof(struct host_to_dev_fis)); in scu_atapi_reconstruct_raw_frame_task_context()
1660 memcpy(((u8 *)&ireq->stp.cmd + sizeof(u32)), atapi_cdb, ATAPI_CDB_LEN); in scu_atapi_reconstruct_raw_frame_task_context()
1666 static void scu_atapi_construct_task_context(struct isci_request *ireq) in scu_atapi_construct_task_context() argument
1668 struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); in scu_atapi_construct_task_context()
1669 struct sas_task *task = isci_request_access_task(ireq); in scu_atapi_construct_task_context()
1670 struct scu_task_context *task_context = ireq->tc; in scu_atapi_construct_task_context()
1688 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); in scu_atapi_construct_task_context()
1689 memcpy(&ireq->stp.cmd.lbal, task->ata_task.atapi_packet, cdb_len); in scu_atapi_construct_task_context()
1702 sci_request_build_sgl(ireq); in scu_atapi_construct_task_context()
1706 sci_io_request_frame_handler(struct isci_request *ireq, in sci_io_request_frame_handler() argument
1709 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_frame_handler()
1710 struct isci_stp_request *stp_req = &ireq->stp.req; in sci_io_request_frame_handler()
1715 state = ireq->sm.current_state_id; in sci_io_request_frame_handler()
1736 sci_swab32_cpy(&ireq->ssp.rsp, resp_iu, word_cnt); in sci_io_request_frame_handler()
1738 resp_iu = &ireq->ssp.rsp; in sci_io_request_frame_handler()
1742 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1743 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in sci_io_request_frame_handler()
1745 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
1746 ireq->sci_status = SCI_SUCCESS; in sci_io_request_frame_handler()
1752 "frame %d type 0x%02x\n", __func__, ireq, in sci_io_request_frame_handler()
1766 sci_io_request_copy_response(ireq); in sci_io_request_frame_handler()
1767 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1772 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_frame_handler()
1797 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
1798 ireq->sci_status = SCI_SUCCESS; in sci_io_request_frame_handler()
1799 sci_change_state(&ireq->sm, SCI_REQ_SMP_WAIT_TC_COMP); in sci_io_request_frame_handler()
1809 ireq, in sci_io_request_frame_handler()
1813 ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR; in sci_io_request_frame_handler()
1814 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in sci_io_request_frame_handler()
1815 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1825 return sci_stp_request_udma_general_frame_handler(ireq, in sci_io_request_frame_handler()
1830 status = sci_stp_request_udma_general_frame_handler(ireq, frame_index); in sci_io_request_frame_handler()
1835 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1836 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1837 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1866 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1871 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1872 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1881 ireq->scu_status = SCU_TASK_DONE_UNEXP_FIS; in sci_io_request_frame_handler()
1882 ireq->sci_status = SCI_FAILURE_PROTOCOL_VIOLATION; in sci_io_request_frame_handler()
1886 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
1895 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_frame_handler()
1930 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1934 ireq->stp.rsp.status = stp_req->status; in sci_io_request_frame_handler()
1940 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_IN); in sci_io_request_frame_handler()
1943 status = sci_stp_request_pio_data_out_transmit_data(ireq); in sci_io_request_frame_handler()
1946 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_OUT); in sci_io_request_frame_handler()
1951 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_frame_handler()
1975 sci_controller_copy_sata_response(&ireq->stp.rsp, in sci_io_request_frame_handler()
1979 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
1980 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
1981 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2024 ireq->scu_status = SCU_TASK_DONE_GOOD; in sci_io_request_frame_handler()
2025 ireq->sci_status = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT; in sci_io_request_frame_handler()
2026 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2034 ireq->saved_rx_frame_index = frame_index; in sci_io_request_frame_handler()
2055 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in sci_io_request_frame_handler()
2056 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in sci_io_request_frame_handler()
2057 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in sci_io_request_frame_handler()
2059 sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); in sci_io_request_frame_handler()
2065 struct sas_task *task = isci_request_access_task(ireq); in sci_io_request_frame_handler()
2068 ireq->target_device->working_request = ireq; in sci_io_request_frame_handler()
2070 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_TC_COMP); in sci_io_request_frame_handler()
2071 scu_atapi_reconstruct_raw_frame_task_context(ireq); in sci_io_request_frame_handler()
2073 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); in sci_io_request_frame_handler()
2074 scu_atapi_construct_task_context(ireq); in sci_io_request_frame_handler()
2077 sci_controller_continue_io(ireq); in sci_io_request_frame_handler()
2081 return atapi_d2h_reg_frame_handler(ireq, frame_index); in sci_io_request_frame_handler()
2103 static enum sci_status stp_request_udma_await_tc_event(struct isci_request *ireq, in stp_request_udma_await_tc_event() argument
2110 ireq->scu_status = SCU_TASK_DONE_GOOD; in stp_request_udma_await_tc_event()
2111 ireq->sci_status = SCI_SUCCESS; in stp_request_udma_await_tc_event()
2112 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2120 if (ireq->stp.rsp.fis_type == FIS_REGD2H) { in stp_request_udma_await_tc_event()
2121 sci_remote_device_suspend(ireq->target_device, in stp_request_udma_await_tc_event()
2124 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in stp_request_udma_await_tc_event()
2125 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in stp_request_udma_await_tc_event()
2126 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2133 sci_change_state(&ireq->sm, SCI_REQ_STP_UDMA_WAIT_D2H); in stp_request_udma_await_tc_event()
2145 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in stp_request_udma_await_tc_event()
2146 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in stp_request_udma_await_tc_event()
2147 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in stp_request_udma_await_tc_event()
2154 static enum sci_status atapi_raw_completion(struct isci_request *ireq, u32 completion_code, in atapi_raw_completion() argument
2161 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_raw_completion()
2162 ireq->sci_status = SCI_SUCCESS; in atapi_raw_completion()
2163 sci_change_state(&ireq->sm, next); in atapi_raw_completion()
2170 ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); in atapi_raw_completion()
2171 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; in atapi_raw_completion()
2173 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_raw_completion()
2180 static enum sci_status atapi_data_tc_completion_handler(struct isci_request *ireq, in atapi_data_tc_completion_handler() argument
2183 struct isci_remote_device *idev = ireq->target_device; in atapi_data_tc_completion_handler()
2184 struct dev_to_host_fis *d2h = &ireq->stp.rsp; in atapi_data_tc_completion_handler()
2189 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_data_tc_completion_handler()
2193 u16 len = sci_req_tx_bytes(ireq); in atapi_data_tc_completion_handler()
2218 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_data_tc_completion_handler()
2219 ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; in atapi_data_tc_completion_handler()
2220 status = ireq->sci_status; in atapi_data_tc_completion_handler()
2232 ireq->scu_status = SCU_TASK_DONE_GOOD; in atapi_data_tc_completion_handler()
2233 ireq->sci_status = SCI_SUCCESS; in atapi_data_tc_completion_handler()
2234 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_data_tc_completion_handler()
2240 status = ireq->sci_status; in atapi_data_tc_completion_handler()
2249 ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; in atapi_data_tc_completion_handler()
2250 ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; in atapi_data_tc_completion_handler()
2252 sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); in atapi_data_tc_completion_handler()
2349 struct isci_request *ireq, in sci_request_handle_suspending_completions() argument
2355 switch (ireq->protocol) { in sci_request_handle_suspending_completions()
2376 dev_warn(&ireq->isci_host->pdev->dev, in sci_request_handle_suspending_completions()
2378 __func__, ireq); in sci_request_handle_suspending_completions()
2385 &ireq->target_device->rnc, in sci_request_handle_suspending_completions()
2393 sci_io_request_tc_completion(struct isci_request *ireq, in sci_io_request_tc_completion() argument
2397 struct isci_host *ihost = ireq->owning_controller; in sci_io_request_tc_completion()
2399 state = ireq->sm.current_state_id; in sci_io_request_tc_completion()
2403 ireq, SCU_GET_COMPLETION_TL_STATUS(completion_code)); in sci_io_request_tc_completion()
2407 return request_started_state_tc_event(ireq, completion_code); in sci_io_request_tc_completion()
2410 return ssp_task_request_await_tc_event(ireq, in sci_io_request_tc_completion()
2414 return smp_request_await_response_tc_event(ireq, in sci_io_request_tc_completion()
2418 return smp_request_await_tc_event(ireq, completion_code); in sci_io_request_tc_completion()
2421 return stp_request_udma_await_tc_event(ireq, in sci_io_request_tc_completion()
2425 return stp_request_non_data_await_h2d_tc_event(ireq, in sci_io_request_tc_completion()
2429 return stp_request_pio_await_h2d_completion_tc_event(ireq, in sci_io_request_tc_completion()
2433 return pio_data_out_tx_done_tc_event(ireq, completion_code); in sci_io_request_tc_completion()
2436 return request_aborting_state_tc_event(ireq, in sci_io_request_tc_completion()
2440 return atapi_raw_completion(ireq, completion_code, in sci_io_request_tc_completion()
2444 return atapi_raw_completion(ireq, completion_code, in sci_io_request_tc_completion()
2448 return atapi_data_tc_completion_handler(ireq, completion_code); in sci_io_request_tc_completion()
2964 struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); in sci_request_started_state_enter() local
2965 struct domain_device *dev = ireq->target_device->domain_dev; in sci_request_started_state_enter()
2972 task = (test_bit(IREQ_TMF, &ireq->flags)) ? NULL : isci_request_access_task(ireq); in sci_request_started_state_enter()
3002 struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); in sci_request_completed_state_enter() local
3003 struct isci_host *ihost = ireq->owning_controller; in sci_request_completed_state_enter()
3006 if (!test_bit(IREQ_TMF, &ireq->flags)) in sci_request_completed_state_enter()
3007 isci_request_io_request_complete(ihost, ireq, in sci_request_completed_state_enter()
3008 ireq->sci_status); in sci_request_completed_state_enter()
3010 isci_task_request_complete(ihost, ireq, ireq->sci_status); in sci_request_completed_state_enter()
3015 struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); in sci_request_aborting_state_enter() local
3018 ireq->tc->abort = 1; in sci_request_aborting_state_enter()
3023 struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); in sci_stp_request_started_non_data_await_h2d_completion_enter() local
3025 ireq->target_device->working_request = ireq; in sci_stp_request_started_non_data_await_h2d_completion_enter()
3030 struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); in sci_stp_request_started_pio_await_h2d_completion_enter() local
3032 ireq->target_device->working_request = ireq; in sci_stp_request_started_pio_await_h2d_completion_enter()
3073 struct isci_request *ireq) in sci_general_request_construct() argument
3075 sci_init_sm(&ireq->sm, sci_request_state_table, SCI_REQ_INIT); in sci_general_request_construct()
3077 ireq->target_device = idev; in sci_general_request_construct()
3078 ireq->protocol = SAS_PROTOCOL_NONE; in sci_general_request_construct()
3079 ireq->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX; in sci_general_request_construct()
3081 ireq->sci_status = SCI_SUCCESS; in sci_general_request_construct()
3082 ireq->scu_status = 0; in sci_general_request_construct()
3083 ireq->post_context = 0xFFFFFFFF; in sci_general_request_construct()
3089 struct isci_request *ireq) in sci_io_request_construct() argument
3095 sci_general_request_construct(ihost, idev, ireq); in sci_io_request_construct()
3103 memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); in sci_io_request_construct()
3109 memset(ireq->tc, 0, offsetof(struct scu_task_context, sgl_pair_ab)); in sci_io_request_construct()
3116 u16 io_tag, struct isci_request *ireq) in sci_task_request_construct() argument
3122 sci_general_request_construct(ihost, idev, ireq); in sci_task_request_construct()
3125 set_bit(IREQ_TMF, &ireq->flags); in sci_task_request_construct()
3126 memset(ireq->tc, 0, sizeof(struct scu_task_context)); in sci_task_request_construct()
3130 ireq->protocol = SAS_PROTOCOL_STP; in sci_task_request_construct()
3132 ireq->protocol = SAS_PROTOCOL_SSP; in sci_task_request_construct()
3152 static enum sci_status isci_request_stp_request_construct(struct isci_request *ireq) in isci_request_stp_request_construct() argument
3154 struct sas_task *task = isci_request_access_task(ireq); in isci_request_stp_request_construct()
3155 struct host_to_dev_fis *fis = &ireq->stp.cmd; in isci_request_stp_request_construct()
3159 dev_dbg(&ireq->isci_host->pdev->dev, in isci_request_stp_request_construct()
3162 ireq); in isci_request_stp_request_construct()
3169 status = sci_io_request_construct_basic_sata(ireq); in isci_request_stp_request_construct()
3174 ireq->tc->type.stp.ncq_tag = qc->tag; in isci_request_stp_request_construct()
3182 struct isci_request *ireq, in sci_io_request_construct_smp() argument
3225 ireq->protocol = SAS_PROTOCOL_SMP; in sci_io_request_construct_smp()
3229 task_context = ireq->tc; in sci_io_request_construct_smp()
3231 idev = ireq->target_device; in sci_io_request_construct_smp()
3283 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | in sci_io_request_construct_smp()
3287 ISCI_TAG_TCI(ireq->io_tag)); in sci_io_request_construct_smp()
3299 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); in sci_io_request_construct_smp()
3311 static enum sci_status isci_smp_request_build(struct isci_request *ireq) in isci_smp_request_build() argument
3313 struct sas_task *task = isci_request_access_task(ireq); in isci_smp_request_build()
3314 struct device *dev = &ireq->isci_host->pdev->dev; in isci_smp_request_build()
3317 status = sci_io_request_construct_smp(dev, ireq, task); in isci_smp_request_build()
3319 dev_dbg(&ireq->isci_host->pdev->dev, in isci_smp_request_build()
3403 struct isci_request *ireq; in isci_request_from_tag() local
3405 ireq = ihost->reqs[ISCI_TAG_TCI(tag)]; in isci_request_from_tag()
3406 ireq->io_tag = tag; in isci_request_from_tag()
3407 ireq->io_request_completion = NULL; in isci_request_from_tag()
3408 ireq->flags = 0; in isci_request_from_tag()
3409 ireq->num_sg_entries = 0; in isci_request_from_tag()
3411 return ireq; in isci_request_from_tag()
3418 struct isci_request *ireq; in isci_io_request_from_tag() local
3420 ireq = isci_request_from_tag(ihost, tag); in isci_io_request_from_tag()
3421 ireq->ttype_ptr.io_task_ptr = task; in isci_io_request_from_tag()
3422 clear_bit(IREQ_TMF, &ireq->flags); in isci_io_request_from_tag()
3423 task->lldd_task = ireq; in isci_io_request_from_tag()
3425 return ireq; in isci_io_request_from_tag()
3432 struct isci_request *ireq; in isci_tmf_request_from_tag() local
3434 ireq = isci_request_from_tag(ihost, tag); in isci_tmf_request_from_tag()
3435 ireq->ttype_ptr.tmf_task_ptr = isci_tmf; in isci_tmf_request_from_tag()
3436 set_bit(IREQ_TMF, &ireq->flags); in isci_tmf_request_from_tag()
3438 return ireq; in isci_tmf_request_from_tag()
3445 struct isci_request *ireq; in isci_request_execute() local
3450 ireq = isci_io_request_from_tag(ihost, task, tag); in isci_request_execute()
3452 status = isci_io_request_build(ihost, ireq, idev); in isci_request_execute()
3475 ireq); in isci_request_execute()
3482 ireq); in isci_request_execute()
3501 set_bit(IREQ_TERMINATED, &ireq->flags); in isci_request_execute()