Lines Matching refs:cmd
90 struct iscsit_cmd *cmd, in iscsit_send_recovery_r2t_for_snack() argument
98 spin_lock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t_for_snack()
100 spin_unlock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t_for_snack()
104 spin_unlock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t_for_snack()
106 iscsit_add_cmd_to_immediate_queue(cmd, cmd->conn, ISTATE_SEND_R2T); in iscsit_send_recovery_r2t_for_snack()
112 struct iscsit_cmd *cmd, in iscsit_handle_r2t_snack() argument
124 if ((cmd->cmd_flags & ICF_GOT_DATACK_SNACK) && in iscsit_handle_r2t_snack()
125 (begrun <= cmd->acked_data_sn)) { in iscsit_handle_r2t_snack()
129 " protocol error.\n", cmd->init_task_tag, begrun, in iscsit_handle_r2t_snack()
130 (begrun + runlength), cmd->acked_data_sn); in iscsit_handle_r2t_snack()
132 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf); in iscsit_handle_r2t_snack()
136 if ((begrun + runlength) > cmd->r2t_sn) { in iscsit_handle_r2t_snack()
140 cmd->init_task_tag, begrun, runlength, cmd->r2t_sn); in iscsit_handle_r2t_snack()
141 return iscsit_reject_cmd(cmd, in iscsit_handle_r2t_snack()
146 last_r2tsn = cmd->r2t_sn; in iscsit_handle_r2t_snack()
149 r2t = iscsit_get_holder_for_r2tsn(cmd, begrun); in iscsit_handle_r2t_snack()
152 if (iscsit_send_recovery_r2t_for_snack(cmd, r2t) < 0) in iscsit_handle_r2t_snack()
170 struct iscsit_cmd *cmd, in iscsit_create_recovery_datain_values_datasequenceinorder_yes() argument
176 struct iscsit_conn *conn = cmd->conn; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
199 cmd->seq_no = seq_no; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
200 cmd->pdu_start = pdu_start; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
201 cmd->pdu_send_order = data_sn_count; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
216 struct iscsit_cmd *cmd, in iscsit_create_recovery_datain_values_datasequenceinorder_no() argument
223 struct iscsit_conn *conn = cmd->conn; in iscsit_create_recovery_datain_values_datasequenceinorder_no()
226 if (!cmd->seq_list) { in iscsit_create_recovery_datain_values_datasequenceinorder_no()
240 for (i = 0; i < cmd->seq_count; i++) { in iscsit_create_recovery_datain_values_datasequenceinorder_no()
241 seq = &cmd->seq_list[i]; in iscsit_create_recovery_datain_values_datasequenceinorder_no()
268 read_data_done += cmd->seq_list[i].xfer_len; in iscsit_create_recovery_datain_values_datasequenceinorder_no()
316 pdu = &cmd->pdu_list[ in iscsit_create_recovery_datain_values_datasequenceinorder_no()
350 cmd->init_task_tag, begrun); in iscsit_create_recovery_datain_values_datasequenceinorder_no()
361 cmd->init_task_tag, begrun, runlength, in iscsit_create_recovery_datain_values_datasequenceinorder_no()
374 struct iscsit_cmd *cmd, in iscsit_handle_recovery_datain() argument
379 struct iscsit_conn *conn = cmd->conn; in iscsit_handle_recovery_datain()
381 struct se_cmd *se_cmd = &cmd->se_cmd; in iscsit_handle_recovery_datain()
385 cmd->init_task_tag); in iscsit_handle_recovery_datain()
393 if ((cmd->cmd_flags & ICF_GOT_DATACK_SNACK) && in iscsit_handle_recovery_datain()
394 (begrun <= cmd->acked_data_sn)) { in iscsit_handle_recovery_datain()
398 " protocol error.\n", cmd->init_task_tag, begrun, in iscsit_handle_recovery_datain()
399 (begrun + runlength), cmd->acked_data_sn); in iscsit_handle_recovery_datain()
401 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf); in iscsit_handle_recovery_datain()
408 if ((begrun + runlength) > (cmd->data_sn - 1)) { in iscsit_handle_recovery_datain()
411 begrun, runlength, (cmd->data_sn - 1)); in iscsit_handle_recovery_datain()
412 return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_INVALID, in iscsit_handle_recovery_datain()
418 return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_NO_RESOURCES, in iscsit_handle_recovery_datain()
426 iscsit_attach_datain_req(cmd, dr); in iscsit_handle_recovery_datain()
428 cmd->i_state = ISTATE_SEND_DATAIN; in iscsit_handle_recovery_datain()
429 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_handle_recovery_datain()
442 struct iscsit_cmd *cmd; in iscsit_handle_recovery_datain_or_r2t() local
444 cmd = iscsit_find_cmd_from_itt(conn, init_task_tag); in iscsit_handle_recovery_datain_or_r2t()
445 if (!cmd) in iscsit_handle_recovery_datain_or_r2t()
451 switch (cmd->data_direction) { in iscsit_handle_recovery_datain_or_r2t()
453 return iscsit_handle_r2t_snack(cmd, buf, begrun, runlength); in iscsit_handle_recovery_datain_or_r2t()
455 return iscsit_handle_recovery_datain(cmd, buf, begrun, in iscsit_handle_recovery_datain_or_r2t()
459 cmd->data_direction); in iscsit_handle_recovery_datain_or_r2t()
474 struct iscsit_cmd *cmd = NULL; in iscsit_handle_status_snack() local
494 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { in iscsit_handle_status_snack()
495 if (cmd->stat_sn == begrun) { in iscsit_handle_status_snack()
511 spin_lock_bh(&cmd->istate_lock); in iscsit_handle_status_snack()
512 if (cmd->i_state == ISTATE_SEND_DATAIN) { in iscsit_handle_status_snack()
513 spin_unlock_bh(&cmd->istate_lock); in iscsit_handle_status_snack()
521 spin_unlock_bh(&cmd->istate_lock); in iscsit_handle_status_snack()
523 cmd->i_state = ISTATE_SEND_STATUS_RECOVERY; in iscsit_handle_status_snack()
524 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_handle_status_snack()
537 struct iscsit_cmd *cmd = NULL; in iscsit_handle_data_ack() local
539 cmd = iscsit_find_cmd_from_ttt(conn, targ_xfer_tag); in iscsit_handle_data_ack()
540 if (!cmd) { in iscsit_handle_data_ack()
546 if (begrun <= cmd->acked_data_sn) { in iscsit_handle_data_ack()
549 cmd->init_task_tag, begrun, cmd->acked_data_sn); in iscsit_handle_data_ack()
557 cmd->cmd_flags |= ICF_GOT_DATACK_SNACK; in iscsit_handle_data_ack()
558 cmd->acked_data_sn = (begrun - 1); in iscsit_handle_data_ack()
562 cmd->init_task_tag, cmd->acked_data_sn); in iscsit_handle_data_ack()
568 struct iscsit_cmd *cmd, in iscsit_send_recovery_r2t() argument
574 spin_lock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t()
575 ret = iscsit_add_r2t_to_list(cmd, offset, xfer_len, 1, 0); in iscsit_send_recovery_r2t()
576 spin_unlock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t()
582 struct iscsit_cmd *cmd, in iscsit_dataout_datapduinorder_no_fbit() argument
587 struct iscsit_conn *conn = cmd->conn; in iscsit_dataout_datapduinorder_no_fbit()
595 for (i = 0; i < cmd->pdu_count; i++) { in iscsit_dataout_datapduinorder_no_fbit()
596 if (cmd->pdu_list[i].seq_no == pdu->seq_no) { in iscsit_dataout_datapduinorder_no_fbit()
598 first_pdu = &cmd->pdu_list[i]; in iscsit_dataout_datapduinorder_no_fbit()
599 xfer_len += cmd->pdu_list[i].length; in iscsit_dataout_datapduinorder_no_fbit()
605 struct iscsi_seq *seq = cmd->seq_ptr; in iscsit_dataout_datapduinorder_no_fbit()
607 first_pdu = &cmd->pdu_list[seq->pdu_start]; in iscsit_dataout_datapduinorder_no_fbit()
623 if (iscsit_send_recovery_r2t(cmd, offset, length) < 0) in iscsit_dataout_datapduinorder_no_fbit()
651 if (iscsit_send_recovery_r2t(cmd, offset, length) < 0) in iscsit_dataout_datapduinorder_no_fbit()
658 struct iscsit_cmd *cmd, in iscsit_recalculate_dataout_values() argument
665 struct iscsit_conn *conn = cmd->conn; in iscsit_recalculate_dataout_values()
669 cmd->data_sn = 0; in iscsit_recalculate_dataout_values()
672 *r2t_offset = cmd->write_data_done; in iscsit_recalculate_dataout_values()
673 *r2t_length = (cmd->seq_end_offset - in iscsit_recalculate_dataout_values()
674 cmd->write_data_done); in iscsit_recalculate_dataout_values()
678 *r2t_offset = cmd->seq_start_offset; in iscsit_recalculate_dataout_values()
679 *r2t_length = (cmd->seq_end_offset - cmd->seq_start_offset); in iscsit_recalculate_dataout_values()
681 for (i = 0; i < cmd->pdu_count; i++) { in iscsit_recalculate_dataout_values()
682 pdu = &cmd->pdu_list[i]; in iscsit_recalculate_dataout_values()
687 if ((pdu->offset >= cmd->seq_start_offset) && in iscsit_recalculate_dataout_values()
689 cmd->seq_end_offset)) { in iscsit_recalculate_dataout_values()
690 if (!cmd->unsolicited_data) in iscsit_recalculate_dataout_values()
691 cmd->next_burst_len -= pdu->length; in iscsit_recalculate_dataout_values()
693 cmd->first_burst_len -= pdu->length; in iscsit_recalculate_dataout_values()
695 cmd->write_data_done -= pdu->length; in iscsit_recalculate_dataout_values()
702 seq = iscsit_get_seq_holder(cmd, pdu_offset, pdu_length); in iscsit_recalculate_dataout_values()
709 cmd->write_data_done -= (seq->offset - seq->orig_offset); in iscsit_recalculate_dataout_values()
710 if (cmd->immediate_data) in iscsit_recalculate_dataout_values()
711 cmd->first_burst_len = cmd->write_data_done; in iscsit_recalculate_dataout_values()
722 pdu = &cmd->pdu_list[i+seq->pdu_start]; in iscsit_recalculate_dataout_values()
735 struct iscsit_cmd *cmd, in iscsit_recover_dataout_sequence() argument
741 spin_lock_bh(&cmd->istate_lock); in iscsit_recover_dataout_sequence()
742 cmd->cmd_flags |= ICF_WITHIN_COMMAND_RECOVERY; in iscsit_recover_dataout_sequence()
743 spin_unlock_bh(&cmd->istate_lock); in iscsit_recover_dataout_sequence()
745 if (iscsit_recalculate_dataout_values(cmd, pdu_offset, pdu_length, in iscsit_recover_dataout_sequence()
749 iscsit_send_recovery_r2t(cmd, r2t_offset, r2t_length); in iscsit_recover_dataout_sequence()
838 ooo_cmdsn->cmd = NULL; in iscsit_clear_ooo_cmdsns_for_conn()
846 struct iscsit_cmd *cmd = NULL; in iscsit_execute_ooo_cmdsns() local
856 if (!ooo_cmdsn->cmd) { in iscsit_execute_ooo_cmdsns()
862 cmd = ooo_cmdsn->cmd; in iscsit_execute_ooo_cmdsns()
863 cmd->i_state = cmd->deferred_i_state; in iscsit_execute_ooo_cmdsns()
868 cmd->cmd_sn, sess->exp_cmd_sn); in iscsit_execute_ooo_cmdsns()
872 if (iscsit_execute_cmd(cmd, 1) < 0) in iscsit_execute_ooo_cmdsns()
887 int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo) in iscsit_execute_cmd() argument
889 struct se_cmd *se_cmd = &cmd->se_cmd; in iscsit_execute_cmd()
890 struct iscsit_conn *conn = cmd->conn; in iscsit_execute_cmd()
893 spin_lock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
895 cmd->cmd_flags &= ~ICF_OOO_CMDSN; in iscsit_execute_cmd()
897 switch (cmd->iscsi_opcode) { in iscsit_execute_cmd()
903 if (cmd->sense_reason) { in iscsit_execute_cmd()
904 if (cmd->sense_reason == TCM_RESERVATION_CONFLICT) { in iscsit_execute_cmd()
905 cmd->i_state = ISTATE_SEND_STATUS; in iscsit_execute_cmd()
906 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
907 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, in iscsit_execute_cmd()
908 cmd->i_state); in iscsit_execute_cmd()
911 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
912 if (cmd->se_cmd.transport_state & CMD_T_ABORTED) in iscsit_execute_cmd()
915 cmd->sense_reason, 0); in iscsit_execute_cmd()
921 if (cmd->immediate_data) { in iscsit_execute_cmd()
922 if (cmd->cmd_flags & ICF_GOT_LAST_DATAOUT) { in iscsit_execute_cmd()
923 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
924 target_execute_cmd(&cmd->se_cmd); in iscsit_execute_cmd()
927 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
929 if (!(cmd->cmd_flags & in iscsit_execute_cmd()
931 if (cmd->se_cmd.transport_state & CMD_T_ABORTED) in iscsit_execute_cmd()
934 iscsit_set_dataout_sequence_values(cmd); in iscsit_execute_cmd()
935 conn->conn_transport->iscsit_get_dataout(conn, cmd, false); in iscsit_execute_cmd()
942 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
944 if ((cmd->data_direction == DMA_TO_DEVICE) && in iscsit_execute_cmd()
945 !(cmd->cmd_flags & ICF_NON_IMMEDIATE_UNSOLICITED_DATA)) { in iscsit_execute_cmd()
946 if (cmd->se_cmd.transport_state & CMD_T_ABORTED) in iscsit_execute_cmd()
949 iscsit_set_unsolicited_dataout(cmd); in iscsit_execute_cmd()
951 return transport_handle_cdb_direct(&cmd->se_cmd); in iscsit_execute_cmd()
955 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
956 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); in iscsit_execute_cmd()
959 if (cmd->se_cmd.se_tmr_req->response) { in iscsit_execute_cmd()
960 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
961 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, in iscsit_execute_cmd()
962 cmd->i_state); in iscsit_execute_cmd()
965 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
967 return transport_generic_handle_tmr(&cmd->se_cmd); in iscsit_execute_cmd()
969 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
970 switch (cmd->logout_reason) { in iscsit_execute_cmd()
972 lr = iscsit_logout_closesession(cmd, cmd->conn); in iscsit_execute_cmd()
975 lr = iscsit_logout_closeconnection(cmd, cmd->conn); in iscsit_execute_cmd()
978 lr = iscsit_logout_removeconnforrecovery(cmd, cmd->conn); in iscsit_execute_cmd()
982 " 0x%02x\n", cmd->logout_reason); in iscsit_execute_cmd()
988 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
990 " unknown iSCSI Opcode: 0x%02x\n", cmd->iscsi_opcode); in iscsit_execute_cmd()
1013 struct iscsit_cmd *cmd, in iscsit_handle_ooo_cmdsn() argument
1019 cmd->deferred_i_state = cmd->i_state; in iscsit_handle_ooo_cmdsn()
1020 cmd->i_state = ISTATE_DEFERRED_CMD; in iscsit_handle_ooo_cmdsn()
1021 cmd->cmd_flags |= ICF_OOO_CMDSN; in iscsit_handle_ooo_cmdsn()
1036 ooo_cmdsn->cmd = cmd; in iscsit_handle_ooo_cmdsn()
1039 ooo_cmdsn->cid = cmd->conn->cid; in iscsit_handle_ooo_cmdsn()
1052 struct iscsit_cmd *cmd, in iscsit_set_dataout_timeout_values() argument
1056 struct iscsit_conn *conn = cmd->conn; in iscsit_set_dataout_timeout_values()
1059 if (cmd->unsolicited_data) { in iscsit_set_dataout_timeout_values()
1062 cmd->se_cmd.data_length) ? in iscsit_set_dataout_timeout_values()
1063 cmd->se_cmd.data_length : in iscsit_set_dataout_timeout_values()
1068 spin_lock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1069 if (list_empty(&cmd->cmd_r2t_list)) { in iscsit_set_dataout_timeout_values()
1071 spin_unlock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1075 list_for_each_entry(r2t, &cmd->cmd_r2t_list, r2t_list) { in iscsit_set_dataout_timeout_values()
1079 spin_unlock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1083 spin_unlock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1086 " sequences for ITT: 0x%08x.\n", cmd->init_task_tag); in iscsit_set_dataout_timeout_values()
1098 struct iscsit_cmd *cmd = from_timer(cmd, t, dataout_timer); in iscsit_handle_dataout_timeout() local
1099 struct iscsit_conn *conn = cmd->conn; in iscsit_handle_dataout_timeout()
1105 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1106 if (cmd->dataout_timer_flags & ISCSI_TF_STOP) { in iscsit_handle_dataout_timeout()
1107 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1111 cmd->dataout_timer_flags &= ~ISCSI_TF_RUNNING; in iscsit_handle_dataout_timeout()
1124 if (++cmd->dataout_timeout_retries == na->dataout_timeout_retries) { in iscsit_handle_dataout_timeout()
1128 cmd->init_task_tag, na->dataout_timeout_retries, in iscsit_handle_dataout_timeout()
1134 cmd->cmd_flags |= ICF_WITHIN_COMMAND_RECOVERY; in iscsit_handle_dataout_timeout()
1138 pdu_offset = cmd->write_data_done; in iscsit_handle_dataout_timeout()
1140 cmd->next_burst_len)) > cmd->se_cmd.data_length) in iscsit_handle_dataout_timeout()
1141 pdu_length = (cmd->se_cmd.data_length - in iscsit_handle_dataout_timeout()
1142 cmd->write_data_done); in iscsit_handle_dataout_timeout()
1145 cmd->next_burst_len); in iscsit_handle_dataout_timeout()
1147 pdu_offset = cmd->seq_start_offset; in iscsit_handle_dataout_timeout()
1148 pdu_length = (cmd->seq_end_offset - in iscsit_handle_dataout_timeout()
1149 cmd->seq_start_offset); in iscsit_handle_dataout_timeout()
1152 if (iscsit_set_dataout_timeout_values(cmd, &pdu_offset, in iscsit_handle_dataout_timeout()
1157 if (iscsit_recalculate_dataout_values(cmd, pdu_offset, pdu_length, in iscsit_handle_dataout_timeout()
1163 cmd->init_task_tag, (cmd->unsolicited_data) ? "Unsolicited " : in iscsit_handle_dataout_timeout()
1166 if (iscsit_send_recovery_r2t(cmd, r2t_offset, r2t_length) < 0) in iscsit_handle_dataout_timeout()
1169 iscsit_start_dataout_timer(cmd, conn); in iscsit_handle_dataout_timeout()
1170 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1176 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1182 void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd) in iscsit_mod_dataout_timer() argument
1184 struct iscsit_conn *conn = cmd->conn; in iscsit_mod_dataout_timer()
1188 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_mod_dataout_timer()
1189 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) { in iscsit_mod_dataout_timer()
1190 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_mod_dataout_timer()
1194 mod_timer(&cmd->dataout_timer, in iscsit_mod_dataout_timer()
1197 cmd->init_task_tag); in iscsit_mod_dataout_timer()
1198 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_mod_dataout_timer()
1202 struct iscsit_cmd *cmd, in iscsit_start_dataout_timer() argument
1208 lockdep_assert_held(&cmd->dataout_timeout_lock); in iscsit_start_dataout_timer()
1210 if (cmd->dataout_timer_flags & ISCSI_TF_RUNNING) in iscsit_start_dataout_timer()
1214 " CID: %hu.\n", cmd->init_task_tag, conn->cid); in iscsit_start_dataout_timer()
1216 cmd->dataout_timer_flags &= ~ISCSI_TF_STOP; in iscsit_start_dataout_timer()
1217 cmd->dataout_timer_flags |= ISCSI_TF_RUNNING; in iscsit_start_dataout_timer()
1218 mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ); in iscsit_start_dataout_timer()
1221 void iscsit_stop_dataout_timer(struct iscsit_cmd *cmd) in iscsit_stop_dataout_timer() argument
1223 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1224 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) { in iscsit_stop_dataout_timer()
1225 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1228 cmd->dataout_timer_flags |= ISCSI_TF_STOP; in iscsit_stop_dataout_timer()
1229 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1231 del_timer_sync(&cmd->dataout_timer); in iscsit_stop_dataout_timer()
1233 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1234 cmd->dataout_timer_flags &= ~ISCSI_TF_RUNNING; in iscsit_stop_dataout_timer()
1236 cmd->init_task_tag); in iscsit_stop_dataout_timer()
1237 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()