Lines Matching refs:cmd

121 	struct iscsi_cmd *cmd,  in iscsit_send_recovery_r2t_for_snack()  argument
129 spin_lock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t_for_snack()
131 spin_unlock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t_for_snack()
135 spin_unlock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t_for_snack()
137 iscsit_add_cmd_to_immediate_queue(cmd, cmd->conn, ISTATE_SEND_R2T); in iscsit_send_recovery_r2t_for_snack()
143 struct iscsi_cmd *cmd, in iscsit_handle_r2t_snack() argument
155 if ((cmd->cmd_flags & ICF_GOT_DATACK_SNACK) && in iscsit_handle_r2t_snack()
156 (begrun <= cmd->acked_data_sn)) { in iscsit_handle_r2t_snack()
160 " protocol error.\n", cmd->init_task_tag, begrun, in iscsit_handle_r2t_snack()
161 (begrun + runlength), cmd->acked_data_sn); in iscsit_handle_r2t_snack()
163 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf); in iscsit_handle_r2t_snack()
167 if ((begrun + runlength) > cmd->r2t_sn) { in iscsit_handle_r2t_snack()
171 cmd->init_task_tag, begrun, runlength, cmd->r2t_sn); in iscsit_handle_r2t_snack()
172 return iscsit_reject_cmd(cmd, in iscsit_handle_r2t_snack()
177 last_r2tsn = cmd->r2t_sn; in iscsit_handle_r2t_snack()
180 r2t = iscsit_get_holder_for_r2tsn(cmd, begrun); in iscsit_handle_r2t_snack()
183 if (iscsit_send_recovery_r2t_for_snack(cmd, r2t) < 0) in iscsit_handle_r2t_snack()
201 struct iscsi_cmd *cmd, in iscsit_create_recovery_datain_values_datasequenceinorder_yes() argument
207 struct iscsi_conn *conn = cmd->conn; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
230 cmd->seq_no = seq_no; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
231 cmd->pdu_start = pdu_start; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
232 cmd->pdu_send_order = data_sn_count; in iscsit_create_recovery_datain_values_datasequenceinorder_yes()
247 struct iscsi_cmd *cmd, in iscsit_create_recovery_datain_values_datasequenceinorder_no() argument
254 struct iscsi_conn *conn = cmd->conn; in iscsit_create_recovery_datain_values_datasequenceinorder_no()
257 if (!cmd->seq_list) { in iscsit_create_recovery_datain_values_datasequenceinorder_no()
271 for (i = 0; i < cmd->seq_count; i++) { in iscsit_create_recovery_datain_values_datasequenceinorder_no()
272 seq = &cmd->seq_list[i]; in iscsit_create_recovery_datain_values_datasequenceinorder_no()
299 read_data_done += cmd->seq_list[i].xfer_len; in iscsit_create_recovery_datain_values_datasequenceinorder_no()
347 pdu = &cmd->pdu_list[ in iscsit_create_recovery_datain_values_datasequenceinorder_no()
381 cmd->init_task_tag, begrun); in iscsit_create_recovery_datain_values_datasequenceinorder_no()
392 cmd->init_task_tag, begrun, runlength, in iscsit_create_recovery_datain_values_datasequenceinorder_no()
405 struct iscsi_cmd *cmd, in iscsit_handle_recovery_datain() argument
410 struct iscsi_conn *conn = cmd->conn; in iscsit_handle_recovery_datain()
412 struct se_cmd *se_cmd = &cmd->se_cmd; in iscsit_handle_recovery_datain()
416 cmd->init_task_tag); in iscsit_handle_recovery_datain()
424 if ((cmd->cmd_flags & ICF_GOT_DATACK_SNACK) && in iscsit_handle_recovery_datain()
425 (begrun <= cmd->acked_data_sn)) { in iscsit_handle_recovery_datain()
429 " protocol error.\n", cmd->init_task_tag, begrun, in iscsit_handle_recovery_datain()
430 (begrun + runlength), cmd->acked_data_sn); in iscsit_handle_recovery_datain()
432 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf); in iscsit_handle_recovery_datain()
439 if ((begrun + runlength) > (cmd->data_sn - 1)) { in iscsit_handle_recovery_datain()
442 begrun, runlength, (cmd->data_sn - 1)); in iscsit_handle_recovery_datain()
443 return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_INVALID, in iscsit_handle_recovery_datain()
449 return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_NO_RESOURCES, in iscsit_handle_recovery_datain()
457 iscsit_attach_datain_req(cmd, dr); in iscsit_handle_recovery_datain()
459 cmd->i_state = ISTATE_SEND_DATAIN; in iscsit_handle_recovery_datain()
460 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_handle_recovery_datain()
473 struct iscsi_cmd *cmd; in iscsit_handle_recovery_datain_or_r2t() local
475 cmd = iscsit_find_cmd_from_itt(conn, init_task_tag); in iscsit_handle_recovery_datain_or_r2t()
476 if (!cmd) in iscsit_handle_recovery_datain_or_r2t()
482 switch (cmd->data_direction) { in iscsit_handle_recovery_datain_or_r2t()
484 return iscsit_handle_r2t_snack(cmd, buf, begrun, runlength); in iscsit_handle_recovery_datain_or_r2t()
486 return iscsit_handle_recovery_datain(cmd, buf, begrun, in iscsit_handle_recovery_datain_or_r2t()
490 cmd->data_direction); in iscsit_handle_recovery_datain_or_r2t()
505 struct iscsi_cmd *cmd = NULL; in iscsit_handle_status_snack() local
525 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { in iscsit_handle_status_snack()
526 if (cmd->stat_sn == begrun) { in iscsit_handle_status_snack()
542 spin_lock_bh(&cmd->istate_lock); in iscsit_handle_status_snack()
543 if (cmd->i_state == ISTATE_SEND_DATAIN) { in iscsit_handle_status_snack()
544 spin_unlock_bh(&cmd->istate_lock); in iscsit_handle_status_snack()
552 spin_unlock_bh(&cmd->istate_lock); in iscsit_handle_status_snack()
554 cmd->i_state = ISTATE_SEND_STATUS_RECOVERY; in iscsit_handle_status_snack()
555 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_handle_status_snack()
568 struct iscsi_cmd *cmd = NULL; in iscsit_handle_data_ack() local
570 cmd = iscsit_find_cmd_from_ttt(conn, targ_xfer_tag); in iscsit_handle_data_ack()
571 if (!cmd) { in iscsit_handle_data_ack()
577 if (begrun <= cmd->acked_data_sn) { in iscsit_handle_data_ack()
580 cmd->init_task_tag, begrun, cmd->acked_data_sn); in iscsit_handle_data_ack()
588 cmd->cmd_flags |= ICF_GOT_DATACK_SNACK; in iscsit_handle_data_ack()
589 cmd->acked_data_sn = (begrun - 1); in iscsit_handle_data_ack()
593 cmd->init_task_tag, cmd->acked_data_sn); in iscsit_handle_data_ack()
599 struct iscsi_cmd *cmd, in iscsit_send_recovery_r2t() argument
605 spin_lock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t()
606 ret = iscsit_add_r2t_to_list(cmd, offset, xfer_len, 1, 0); in iscsit_send_recovery_r2t()
607 spin_unlock_bh(&cmd->r2t_lock); in iscsit_send_recovery_r2t()
613 struct iscsi_cmd *cmd, in iscsit_dataout_datapduinorder_no_fbit() argument
618 struct iscsi_conn *conn = cmd->conn; in iscsit_dataout_datapduinorder_no_fbit()
626 for (i = 0; i < cmd->pdu_count; i++) { in iscsit_dataout_datapduinorder_no_fbit()
627 if (cmd->pdu_list[i].seq_no == pdu->seq_no) { in iscsit_dataout_datapduinorder_no_fbit()
629 first_pdu = &cmd->pdu_list[i]; in iscsit_dataout_datapduinorder_no_fbit()
630 xfer_len += cmd->pdu_list[i].length; in iscsit_dataout_datapduinorder_no_fbit()
636 struct iscsi_seq *seq = cmd->seq_ptr; in iscsit_dataout_datapduinorder_no_fbit()
638 first_pdu = &cmd->pdu_list[seq->pdu_start]; in iscsit_dataout_datapduinorder_no_fbit()
654 if (iscsit_send_recovery_r2t(cmd, offset, length) < 0) in iscsit_dataout_datapduinorder_no_fbit()
682 if (iscsit_send_recovery_r2t(cmd, offset, length) < 0) in iscsit_dataout_datapduinorder_no_fbit()
689 struct iscsi_cmd *cmd, in iscsit_recalculate_dataout_values() argument
696 struct iscsi_conn *conn = cmd->conn; in iscsit_recalculate_dataout_values()
700 cmd->data_sn = 0; in iscsit_recalculate_dataout_values()
703 *r2t_offset = cmd->write_data_done; in iscsit_recalculate_dataout_values()
704 *r2t_length = (cmd->seq_end_offset - in iscsit_recalculate_dataout_values()
705 cmd->write_data_done); in iscsit_recalculate_dataout_values()
709 *r2t_offset = cmd->seq_start_offset; in iscsit_recalculate_dataout_values()
710 *r2t_length = (cmd->seq_end_offset - cmd->seq_start_offset); in iscsit_recalculate_dataout_values()
712 for (i = 0; i < cmd->pdu_count; i++) { in iscsit_recalculate_dataout_values()
713 pdu = &cmd->pdu_list[i]; in iscsit_recalculate_dataout_values()
718 if ((pdu->offset >= cmd->seq_start_offset) && in iscsit_recalculate_dataout_values()
720 cmd->seq_end_offset)) { in iscsit_recalculate_dataout_values()
721 if (!cmd->unsolicited_data) in iscsit_recalculate_dataout_values()
722 cmd->next_burst_len -= pdu->length; in iscsit_recalculate_dataout_values()
724 cmd->first_burst_len -= pdu->length; in iscsit_recalculate_dataout_values()
726 cmd->write_data_done -= pdu->length; in iscsit_recalculate_dataout_values()
733 seq = iscsit_get_seq_holder(cmd, pdu_offset, pdu_length); in iscsit_recalculate_dataout_values()
740 cmd->write_data_done -= (seq->offset - seq->orig_offset); in iscsit_recalculate_dataout_values()
741 if (cmd->immediate_data) in iscsit_recalculate_dataout_values()
742 cmd->first_burst_len = cmd->write_data_done; in iscsit_recalculate_dataout_values()
753 pdu = &cmd->pdu_list[i+seq->pdu_start]; in iscsit_recalculate_dataout_values()
766 struct iscsi_cmd *cmd, in iscsit_recover_dataout_sequence() argument
772 spin_lock_bh(&cmd->istate_lock); in iscsit_recover_dataout_sequence()
773 cmd->cmd_flags |= ICF_WITHIN_COMMAND_RECOVERY; in iscsit_recover_dataout_sequence()
774 spin_unlock_bh(&cmd->istate_lock); in iscsit_recover_dataout_sequence()
776 if (iscsit_recalculate_dataout_values(cmd, pdu_offset, pdu_length, in iscsit_recover_dataout_sequence()
780 iscsit_send_recovery_r2t(cmd, r2t_offset, r2t_length); in iscsit_recover_dataout_sequence()
869 ooo_cmdsn->cmd = NULL; in iscsit_clear_ooo_cmdsns_for_conn()
880 struct iscsi_cmd *cmd = NULL; in iscsit_execute_ooo_cmdsns() local
888 if (!ooo_cmdsn->cmd) { in iscsit_execute_ooo_cmdsns()
894 cmd = ooo_cmdsn->cmd; in iscsit_execute_ooo_cmdsns()
895 cmd->i_state = cmd->deferred_i_state; in iscsit_execute_ooo_cmdsns()
900 cmd->cmd_sn, sess->exp_cmd_sn); in iscsit_execute_ooo_cmdsns()
904 if (iscsit_execute_cmd(cmd, 1) < 0) in iscsit_execute_ooo_cmdsns()
921 int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) in iscsit_execute_cmd() argument
923 struct se_cmd *se_cmd = &cmd->se_cmd; in iscsit_execute_cmd()
924 struct iscsi_conn *conn = cmd->conn; in iscsit_execute_cmd()
927 spin_lock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
929 cmd->cmd_flags &= ~ICF_OOO_CMDSN; in iscsit_execute_cmd()
931 switch (cmd->iscsi_opcode) { in iscsit_execute_cmd()
937 if (cmd->sense_reason) { in iscsit_execute_cmd()
938 if (cmd->sense_reason == TCM_RESERVATION_CONFLICT) { in iscsit_execute_cmd()
939 cmd->i_state = ISTATE_SEND_STATUS; in iscsit_execute_cmd()
940 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
941 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, in iscsit_execute_cmd()
942 cmd->i_state); in iscsit_execute_cmd()
945 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
954 (cmd->unsolicited_data == 0)) != 0) in iscsit_execute_cmd()
961 cmd->sense_reason, 0); in iscsit_execute_cmd()
967 if (cmd->immediate_data) { in iscsit_execute_cmd()
968 if (cmd->cmd_flags & ICF_GOT_LAST_DATAOUT) { in iscsit_execute_cmd()
969 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
970 target_execute_cmd(&cmd->se_cmd); in iscsit_execute_cmd()
973 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
975 if (!(cmd->cmd_flags & in iscsit_execute_cmd()
986 iscsit_set_dataout_sequence_values(cmd); in iscsit_execute_cmd()
987 conn->conn_transport->iscsit_get_dataout(conn, cmd, false); in iscsit_execute_cmd()
994 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
996 if ((cmd->data_direction == DMA_TO_DEVICE) && in iscsit_execute_cmd()
997 !(cmd->cmd_flags & ICF_NON_IMMEDIATE_UNSOLICITED_DATA)) { in iscsit_execute_cmd()
1005 iscsit_set_unsoliticed_dataout(cmd); in iscsit_execute_cmd()
1007 return transport_handle_cdb_direct(&cmd->se_cmd); in iscsit_execute_cmd()
1011 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
1012 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); in iscsit_execute_cmd()
1015 if (cmd->se_cmd.se_tmr_req->response) { in iscsit_execute_cmd()
1016 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
1017 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, in iscsit_execute_cmd()
1018 cmd->i_state); in iscsit_execute_cmd()
1021 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
1023 return transport_generic_handle_tmr(&cmd->se_cmd); in iscsit_execute_cmd()
1025 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
1026 switch (cmd->logout_reason) { in iscsit_execute_cmd()
1028 lr = iscsit_logout_closesession(cmd, cmd->conn); in iscsit_execute_cmd()
1031 lr = iscsit_logout_closeconnection(cmd, cmd->conn); in iscsit_execute_cmd()
1034 lr = iscsit_logout_removeconnforrecovery(cmd, cmd->conn); in iscsit_execute_cmd()
1038 " 0x%02x\n", cmd->logout_reason); in iscsit_execute_cmd()
1044 spin_unlock_bh(&cmd->istate_lock); in iscsit_execute_cmd()
1046 " unknown iSCSI Opcode: 0x%02x\n", cmd->iscsi_opcode); in iscsit_execute_cmd()
1069 struct iscsi_cmd *cmd, in iscsit_handle_ooo_cmdsn() argument
1075 cmd->deferred_i_state = cmd->i_state; in iscsit_handle_ooo_cmdsn()
1076 cmd->i_state = ISTATE_DEFERRED_CMD; in iscsit_handle_ooo_cmdsn()
1077 cmd->cmd_flags |= ICF_OOO_CMDSN; in iscsit_handle_ooo_cmdsn()
1092 ooo_cmdsn->cmd = cmd; in iscsit_handle_ooo_cmdsn()
1095 ooo_cmdsn->cid = cmd->conn->cid; in iscsit_handle_ooo_cmdsn()
1108 struct iscsi_cmd *cmd, in iscsit_set_dataout_timeout_values() argument
1112 struct iscsi_conn *conn = cmd->conn; in iscsit_set_dataout_timeout_values()
1115 if (cmd->unsolicited_data) { in iscsit_set_dataout_timeout_values()
1118 cmd->se_cmd.data_length) ? in iscsit_set_dataout_timeout_values()
1119 cmd->se_cmd.data_length : in iscsit_set_dataout_timeout_values()
1124 spin_lock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1125 if (list_empty(&cmd->cmd_r2t_list)) { in iscsit_set_dataout_timeout_values()
1127 spin_unlock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1131 list_for_each_entry(r2t, &cmd->cmd_r2t_list, r2t_list) { in iscsit_set_dataout_timeout_values()
1135 spin_unlock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1139 spin_unlock_bh(&cmd->r2t_lock); in iscsit_set_dataout_timeout_values()
1142 " sequences for ITT: 0x%08x.\n", cmd->init_task_tag); in iscsit_set_dataout_timeout_values()
1154 struct iscsi_cmd *cmd = from_timer(cmd, t, dataout_timer); in iscsit_handle_dataout_timeout() local
1155 struct iscsi_conn *conn = cmd->conn; in iscsit_handle_dataout_timeout()
1161 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1162 if (cmd->dataout_timer_flags & ISCSI_TF_STOP) { in iscsit_handle_dataout_timeout()
1163 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1167 cmd->dataout_timer_flags &= ~ISCSI_TF_RUNNING; in iscsit_handle_dataout_timeout()
1177 if (++cmd->dataout_timeout_retries == na->dataout_timeout_retries) { in iscsit_handle_dataout_timeout()
1180 cmd->init_task_tag, na->dataout_timeout_retries); in iscsit_handle_dataout_timeout()
1184 cmd->cmd_flags |= ICF_WITHIN_COMMAND_RECOVERY; in iscsit_handle_dataout_timeout()
1188 pdu_offset = cmd->write_data_done; in iscsit_handle_dataout_timeout()
1190 cmd->next_burst_len)) > cmd->se_cmd.data_length) in iscsit_handle_dataout_timeout()
1191 pdu_length = (cmd->se_cmd.data_length - in iscsit_handle_dataout_timeout()
1192 cmd->write_data_done); in iscsit_handle_dataout_timeout()
1195 cmd->next_burst_len); in iscsit_handle_dataout_timeout()
1197 pdu_offset = cmd->seq_start_offset; in iscsit_handle_dataout_timeout()
1198 pdu_length = (cmd->seq_end_offset - in iscsit_handle_dataout_timeout()
1199 cmd->seq_start_offset); in iscsit_handle_dataout_timeout()
1202 if (iscsit_set_dataout_timeout_values(cmd, &pdu_offset, in iscsit_handle_dataout_timeout()
1207 if (iscsit_recalculate_dataout_values(cmd, pdu_offset, pdu_length, in iscsit_handle_dataout_timeout()
1213 cmd->init_task_tag, (cmd->unsolicited_data) ? "Unsolicited " : in iscsit_handle_dataout_timeout()
1216 if (iscsit_send_recovery_r2t(cmd, r2t_offset, r2t_length) < 0) in iscsit_handle_dataout_timeout()
1219 iscsit_start_dataout_timer(cmd, conn); in iscsit_handle_dataout_timeout()
1220 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1226 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_handle_dataout_timeout()
1231 void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd) in iscsit_mod_dataout_timer() argument
1233 struct iscsi_conn *conn = cmd->conn; in iscsit_mod_dataout_timer()
1237 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_mod_dataout_timer()
1238 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) { in iscsit_mod_dataout_timer()
1239 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_mod_dataout_timer()
1243 mod_timer(&cmd->dataout_timer, in iscsit_mod_dataout_timer()
1246 cmd->init_task_tag); in iscsit_mod_dataout_timer()
1247 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_mod_dataout_timer()
1254 struct iscsi_cmd *cmd, in iscsit_start_dataout_timer() argument
1260 if (cmd->dataout_timer_flags & ISCSI_TF_RUNNING) in iscsit_start_dataout_timer()
1264 " CID: %hu.\n", cmd->init_task_tag, conn->cid); in iscsit_start_dataout_timer()
1266 cmd->dataout_timer_flags &= ~ISCSI_TF_STOP; in iscsit_start_dataout_timer()
1267 cmd->dataout_timer_flags |= ISCSI_TF_RUNNING; in iscsit_start_dataout_timer()
1268 mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ); in iscsit_start_dataout_timer()
1271 void iscsit_stop_dataout_timer(struct iscsi_cmd *cmd) in iscsit_stop_dataout_timer() argument
1273 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1274 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) { in iscsit_stop_dataout_timer()
1275 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1278 cmd->dataout_timer_flags |= ISCSI_TF_STOP; in iscsit_stop_dataout_timer()
1279 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1281 del_timer_sync(&cmd->dataout_timer); in iscsit_stop_dataout_timer()
1283 spin_lock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()
1284 cmd->dataout_timer_flags &= ~ISCSI_TF_RUNNING; in iscsit_stop_dataout_timer()
1286 cmd->init_task_tag); in iscsit_stop_dataout_timer()
1287 spin_unlock_bh(&cmd->dataout_timeout_lock); in iscsit_stop_dataout_timer()