Lines Matching full:conn

477 int iscsit_queue_rsp(struct iscsit_conn *conn, struct iscsit_cmd *cmd)  in iscsit_queue_rsp()  argument
479 return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); in iscsit_queue_rsp()
483 void iscsit_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd) in iscsit_aborted_task() argument
485 spin_lock_bh(&conn->cmd_lock); in iscsit_aborted_task()
488 spin_unlock_bh(&conn->cmd_lock); in iscsit_aborted_task()
499 iscsit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_xmit_nondatain_pdu() argument
511 if (conn->conn_ops->HeaderDigest) { in iscsit_xmit_nondatain_pdu()
514 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, in iscsit_xmit_nondatain_pdu()
540 if (conn->conn_ops->DataDigest) { in iscsit_xmit_nondatain_pdu()
541 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, in iscsit_xmit_nondatain_pdu()
558 ret = iscsit_send_tx_data(cmd, conn, 1); in iscsit_xmit_nondatain_pdu()
560 iscsit_tx_thread_wait_for_tcp(conn); in iscsit_xmit_nondatain_pdu()
573 iscsit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_xmit_datain_pdu() argument
585 if (conn->conn_ops->HeaderDigest) { in iscsit_xmit_datain_pdu()
588 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->pdu, in iscsit_xmit_datain_pdu()
617 if (conn->conn_ops->DataDigest) { in iscsit_xmit_datain_pdu()
618 cmd->data_crc = iscsit_do_crypto_hash_sg(conn->conn_tx_hash, in iscsit_xmit_datain_pdu()
635 ret = iscsit_fe_sendpage_sg(cmd, conn); in iscsit_xmit_datain_pdu()
640 iscsit_tx_thread_wait_for_tcp(conn); in iscsit_xmit_datain_pdu()
647 static int iscsit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_xmit_pdu() argument
652 return iscsit_xmit_datain_pdu(conn, cmd, buf); in iscsit_xmit_pdu()
654 return iscsit_xmit_nondatain_pdu(conn, cmd, buf, buf_len); in iscsit_xmit_pdu()
657 static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsit_conn *conn) in iscsit_get_sup_prot_ops() argument
799 struct iscsit_conn *conn, in iscsit_add_reject() argument
805 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsit_add_reject()
819 spin_lock_bh(&conn->cmd_lock); in iscsit_add_reject()
820 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_add_reject()
821 spin_unlock_bh(&conn->cmd_lock); in iscsit_add_reject()
824 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_add_reject()
836 struct iscsit_conn *conn; in iscsit_add_reject_from_cmd() local
839 if (!cmd->conn) { in iscsit_add_reject_from_cmd()
840 pr_err("cmd->conn is NULL for ITT: 0x%08x\n", in iscsit_add_reject_from_cmd()
844 conn = cmd->conn; in iscsit_add_reject_from_cmd()
857 spin_lock_bh(&conn->cmd_lock); in iscsit_add_reject_from_cmd()
858 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_add_reject_from_cmd()
859 spin_unlock_bh(&conn->cmd_lock); in iscsit_add_reject_from_cmd()
863 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_add_reject_from_cmd()
960 static void iscsit_ack_from_expstatsn(struct iscsit_conn *conn, u32 exp_statsn) in iscsit_ack_from_expstatsn() argument
965 conn->exp_statsn = exp_statsn; in iscsit_ack_from_expstatsn()
967 if (conn->sess->sess_ops->RDMAExtensions) in iscsit_ack_from_expstatsn()
970 spin_lock_bh(&conn->cmd_lock); in iscsit_ack_from_expstatsn()
971 list_for_each_entry_safe(cmd, cmd_p, &conn->conn_cmd_list, i_conn_node) { in iscsit_ack_from_expstatsn()
982 spin_unlock_bh(&conn->cmd_lock); in iscsit_ack_from_expstatsn()
1003 int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_setup_scsi_cmd() argument
1013 atomic_long_inc(&conn->sess->cmd_pdus); in iscsit_setup_scsi_cmd()
1071 if (payload_length && !conn->sess->sess_ops->ImmediateData) { in iscsit_setup_scsi_cmd()
1095 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_setup_scsi_cmd()
1098 payload_length, conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_setup_scsi_cmd()
1103 if (payload_length > conn->sess->sess_ops->FirstBurstLength) { in iscsit_setup_scsi_cmd()
1106 payload_length, conn->sess->sess_ops->FirstBurstLength); in iscsit_setup_scsi_cmd()
1165 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_setup_scsi_cmd()
1167 cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); in iscsit_setup_scsi_cmd()
1174 if (!conn->sess->sess_ops->RDMAExtensions && in iscsit_setup_scsi_cmd()
1193 conn->sess->se_sess, be32_to_cpu(hdr->data_length), in iscsit_setup_scsi_cmd()
1200 conn->cid); in iscsit_setup_scsi_cmd()
1234 spin_lock_bh(&conn->cmd_lock); in iscsit_setup_scsi_cmd()
1235 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_setup_scsi_cmd()
1236 spin_unlock_bh(&conn->cmd_lock); in iscsit_setup_scsi_cmd()
1252 iscsit_start_dataout_timer(cmd, cmd->conn); in iscsit_set_unsolicited_dataout()
1257 int iscsit_process_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_process_scsi_cmd() argument
1272 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, in iscsit_process_scsi_cmd()
1282 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_process_scsi_cmd()
1333 rc = iscsit_dump_data_payload(cmd->conn, length, 1); in iscsit_get_immediate_data()
1348 cmdsn_ret = iscsit_sequence_cmd(cmd->conn, cmd, in iscsit_get_immediate_data()
1373 iscsit_add_cmd_to_immediate_queue(cmd, cmd->conn, cmd->i_state); in iscsit_get_immediate_data()
1381 iscsit_handle_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_scsi_cmd() argument
1388 rc = iscsit_setup_scsi_cmd(conn, cmd, buf); in iscsit_handle_scsi_cmd()
1401 rc = iscsit_process_scsi_cmd(conn, cmd, hdr); in iscsit_handle_scsi_cmd()
1487 __iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, in __iscsit_check_dataout_hdr() argument
1496 atomic_long_add(payload_length, &conn->sess->rx_data_octets); in __iscsit_check_dataout_hdr()
1501 payload_length, conn->cid); in __iscsit_check_dataout_hdr()
1507 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1513 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1528 if (conn->sess->sess_ops->InitialR2T) { in __iscsit_check_dataout_hdr()
1555 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1573 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1591 iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, in iscsit_check_dataout_hdr() argument
1605 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_check_dataout_hdr()
1608 conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_check_dataout_hdr()
1609 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, buf); in iscsit_check_dataout_hdr()
1612 cmd = iscsit_find_cmd_from_itt_or_dump(conn, hdr->itt, payload_length); in iscsit_check_dataout_hdr()
1616 rc = __iscsit_check_dataout_hdr(conn, buf, cmd, payload_length, &success); in iscsit_check_dataout_hdr()
1626 iscsit_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_get_dataout() argument
1654 if (conn->conn_ops->DataDigest) { in iscsit_get_dataout()
1661 rx_got = rx_data(conn, &cmd->iov_data[0], iov_count, rx_size); in iscsit_get_dataout()
1668 if (conn->conn_ops->DataDigest) { in iscsit_get_dataout()
1671 data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd, in iscsit_get_dataout()
1697 struct iscsit_conn *conn = cmd->conn; in iscsit_check_dataout_payload() local
1708 conn->conn_transport->iscsit_get_dataout(conn, cmd, false); in iscsit_check_dataout_payload()
1732 static int iscsit_handle_data_out(struct iscsit_conn *conn, unsigned char *buf) in iscsit_handle_data_out() argument
1739 rc = iscsit_check_dataout_hdr(conn, buf, &cmd); in iscsit_handle_data_out()
1745 rc = iscsit_get_dataout(conn, cmd, hdr); in iscsit_handle_data_out()
1754 int iscsit_setup_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_setup_nop_out() argument
1762 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_setup_nop_out()
1773 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_setup_nop_out()
1780 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_setup_nop_out()
1784 conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_setup_nop_out()
1786 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_setup_nop_out()
1810 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_setup_nop_out()
1821 int iscsit_process_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_process_nop_out() argument
1831 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_process_nop_out()
1834 spin_lock_bh(&conn->cmd_lock); in iscsit_process_nop_out()
1835 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_process_nop_out()
1836 spin_unlock_bh(&conn->cmd_lock); in iscsit_process_nop_out()
1838 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_process_nop_out()
1841 iscsit_add_cmd_to_response_queue(cmd, conn, in iscsit_process_nop_out()
1846 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, in iscsit_process_nop_out()
1859 cmd_p = iscsit_find_cmd_from_ttt(conn, be32_to_cpu(hdr->ttt)); in iscsit_process_nop_out()
1863 iscsit_stop_nopin_response_timer(conn); in iscsit_process_nop_out()
1866 iscsit_add_cmd_to_immediate_queue(cmd_p, conn, cmd_p->i_state); in iscsit_process_nop_out()
1868 iscsit_start_nopin_timer(conn); in iscsit_process_nop_out()
1883 static int iscsit_handle_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_nop_out() argument
1892 ret = iscsit_setup_nop_out(conn, cmd, hdr); in iscsit_handle_nop_out()
1920 if (conn->conn_ops->DataDigest) { in iscsit_handle_nop_out()
1927 rx_got = rx_data(conn, &cmd->iov_misc[0], niov, rx_size); in iscsit_handle_nop_out()
1933 if (conn->conn_ops->DataDigest) { in iscsit_handle_nop_out()
1934 iscsit_do_crypto_hash_buf(conn->conn_rx_hash, ping_data, in iscsit_handle_nop_out()
1942 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_nop_out()
1978 return iscsit_process_nop_out(conn, cmd, hdr); in iscsit_handle_nop_out()
2010 iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_task_mgt_cmd() argument
2026 hdr->rtt, hdr->refcmdsn, conn->cid); in iscsit_handle_task_mgt_cmd()
2056 conn->sess->se_sess, 0, DMA_NONE, in iscsit_handle_task_mgt_cmd()
2115 if (iscsit_tmr_task_warm_reset(conn, tmr_req, buf) < 0) { in iscsit_handle_task_mgt_cmd()
2121 if (iscsit_tmr_task_cold_reset(conn, tmr_req, buf) < 0) { in iscsit_handle_task_mgt_cmd()
2135 if (iscsit_check_task_reassign_expdatasn(tmr_req, conn) < 0) in iscsit_handle_task_mgt_cmd()
2150 spin_lock_bh(&conn->cmd_lock); in iscsit_handle_task_mgt_cmd()
2151 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_handle_task_mgt_cmd()
2152 spin_unlock_bh(&conn->cmd_lock); in iscsit_handle_task_mgt_cmd()
2155 int cmdsn_ret = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn); in iscsit_handle_task_mgt_cmd()
2165 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_handle_task_mgt_cmd()
2183 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_handle_task_mgt_cmd()
2191 iscsit_setup_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_setup_text_cmd() argument
2196 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_setup_text_cmd()
2199 payload_length, conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_setup_text_cmd()
2218 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_setup_text_cmd()
2231 iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_process_text_cmd() argument
2265 spin_lock_bh(&conn->cmd_lock); in iscsit_process_text_cmd()
2266 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_process_text_cmd()
2267 spin_unlock_bh(&conn->cmd_lock); in iscsit_process_text_cmd()
2270 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_process_text_cmd()
2273 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, in iscsit_process_text_cmd()
2290 iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_text_cmd() argument
2298 rc = iscsit_setup_text_cmd(conn, cmd, hdr); in iscsit_handle_text_cmd()
2324 if (conn->conn_ops->DataDigest) { in iscsit_handle_text_cmd()
2331 rx_got = rx_data(conn, &iov[0], niov, rx_size); in iscsit_handle_text_cmd()
2335 if (conn->conn_ops->DataDigest) { in iscsit_handle_text_cmd()
2336 iscsit_do_crypto_hash_buf(conn->conn_rx_hash, in iscsit_handle_text_cmd()
2344 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_text_cmd()
2371 return iscsit_process_text_cmd(conn, cmd, hdr); in iscsit_handle_text_cmd()
2379 int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_logout_closesession() argument
2382 struct iscsit_session *sess = conn->sess; in iscsit_logout_closesession()
2385 " for SID: %u.\n", conn->cid, conn->sess->sid); in iscsit_logout_closesession()
2388 atomic_set(&conn->conn_logout_remove, 1); in iscsit_logout_closesession()
2389 conn->conn_logout_reason = ISCSI_LOGOUT_REASON_CLOSE_SESSION; in iscsit_logout_closesession()
2391 iscsit_inc_conn_usage_count(conn); in iscsit_logout_closesession()
2404 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_closesession()
2409 int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_logout_closeconnection() argument
2412 struct iscsit_session *sess = conn->sess; in iscsit_logout_closeconnection()
2415 " %hu on CID: %hu.\n", cmd->logout_cid, conn->cid); in iscsit_logout_closeconnection()
2421 if (conn->cid == cmd->logout_cid) { in iscsit_logout_closeconnection()
2422 spin_lock_bh(&conn->state_lock); in iscsit_logout_closeconnection()
2424 conn->conn_state = TARG_CONN_STATE_IN_LOGOUT; in iscsit_logout_closeconnection()
2426 atomic_set(&conn->conn_logout_remove, 1); in iscsit_logout_closeconnection()
2427 conn->conn_logout_reason = ISCSI_LOGOUT_REASON_CLOSE_CONNECTION; in iscsit_logout_closeconnection()
2428 iscsit_inc_conn_usage_count(conn); in iscsit_logout_closeconnection()
2430 spin_unlock_bh(&conn->state_lock); in iscsit_logout_closeconnection()
2444 iscsit_add_cmd_to_response_queue(cmd, conn, in iscsit_logout_closeconnection()
2452 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_closeconnection()
2457 int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_logout_removeconnforrecovery() argument
2459 struct iscsit_session *sess = conn->sess; in iscsit_logout_removeconnforrecovery()
2462 " CID: %hu on CID: %hu.\n", cmd->logout_cid, conn->cid); in iscsit_logout_removeconnforrecovery()
2468 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_removeconnforrecovery()
2472 if (conn->cid == cmd->logout_cid) { in iscsit_logout_removeconnforrecovery()
2475 cmd->logout_cid, conn->cid); in iscsit_logout_removeconnforrecovery()
2477 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_removeconnforrecovery()
2481 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_removeconnforrecovery()
2487 iscsit_handle_logout_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_logout_cmd() argument
2493 struct iscsi_tiqn *tiqn = iscsit_snmp_get_tiqn(conn); in iscsit_handle_logout_cmd()
2510 hdr->cid, conn->cid); in iscsit_handle_logout_cmd()
2512 if (conn->conn_state != TARG_CONN_STATE_LOGGED_IN) { in iscsit_handle_logout_cmd()
2522 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_handle_logout_cmd()
2536 be16_to_cpu(hdr->cid) == conn->cid)) in iscsit_handle_logout_cmd()
2539 spin_lock_bh(&conn->cmd_lock); in iscsit_handle_logout_cmd()
2540 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_handle_logout_cmd()
2541 spin_unlock_bh(&conn->cmd_lock); in iscsit_handle_logout_cmd()
2544 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_handle_logout_cmd()
2556 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn); in iscsit_handle_logout_cmd()
2568 struct iscsit_conn *conn, in iscsit_handle_snack() argument
2579 hdr->begrun, hdr->runlength, conn->cid); in iscsit_handle_snack()
2581 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_snack()
2584 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_handle_snack()
2593 return iscsit_handle_recovery_datain_or_r2t(conn, buf, in iscsit_handle_snack()
2599 return iscsit_handle_status_snack(conn, hdr->itt, in iscsit_handle_snack()
2603 return iscsit_handle_data_ack(conn, be32_to_cpu(hdr->ttt), in iscsit_handle_snack()
2609 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_handle_snack()
2614 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_handle_snack()
2622 static void iscsit_rx_thread_wait_for_tcp(struct iscsit_conn *conn) in iscsit_rx_thread_wait_for_tcp() argument
2624 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) || in iscsit_rx_thread_wait_for_tcp()
2625 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) { in iscsit_rx_thread_wait_for_tcp()
2627 &conn->rx_half_close_comp, in iscsit_rx_thread_wait_for_tcp()
2639 struct iscsit_conn *conn = cmd->conn; in iscsit_handle_immediate_data() local
2677 if (conn->conn_ops->DataDigest) { in iscsit_handle_immediate_data()
2684 rx_got = rx_data(conn, &cmd->iov_data[0], iov_count, rx_size); in iscsit_handle_immediate_data()
2689 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_handle_immediate_data()
2693 if (conn->conn_ops->DataDigest) { in iscsit_handle_immediate_data()
2696 data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd, in iscsit_handle_immediate_data()
2705 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_immediate_data()
2740 static void iscsit_build_conn_drop_async_message(struct iscsit_conn *conn) in iscsit_build_conn_drop_async_message() argument
2746 lockdep_assert_held(&conn->sess->conn_lock); in iscsit_build_conn_drop_async_message()
2752 list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) { in iscsit_build_conn_drop_async_message()
2769 cmd->logout_cid = conn->cid; in iscsit_build_conn_drop_async_message()
2783 struct iscsit_conn *conn) in iscsit_send_conn_drop_async_message() argument
2795 cmd->stat_sn = conn->stat_sn++; in iscsit_send_conn_drop_async_message()
2797 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_send_conn_drop_async_message()
2798 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_send_conn_drop_async_message()
2801 hdr->param2 = cpu_to_be16(conn->sess->sess_ops->DefaultTime2Wait); in iscsit_send_conn_drop_async_message()
2802 hdr->param3 = cpu_to_be16(conn->sess->sess_ops->DefaultTime2Retain); in iscsit_send_conn_drop_async_message()
2806 cmd->logout_cid, conn->cid); in iscsit_send_conn_drop_async_message()
2808 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_conn_drop_async_message()
2811 static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *conn) in iscsit_tx_thread_wait_for_tcp() argument
2813 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) || in iscsit_tx_thread_wait_for_tcp()
2814 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) { in iscsit_tx_thread_wait_for_tcp()
2816 &conn->tx_half_close_comp, in iscsit_tx_thread_wait_for_tcp()
2822 iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_datain_pdu() argument
2855 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_datain_pdu()
2856 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_datain_pdu()
2863 ntohl(hdr->offset), datain->length, conn->cid); in iscsit_build_datain_pdu()
2867 static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_datain() argument
2893 atomic_long_add(datain.length, &conn->sess->tx_data_octets); in iscsit_send_datain()
2904 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_send_datain()
2905 cmd->stat_sn = conn->stat_sn++; in iscsit_send_datain()
2912 iscsit_build_datain_pdu(cmd, conn, &datain, hdr, set_statsn); in iscsit_send_datain()
2914 ret = conn->conn_transport->iscsit_xmit_pdu(conn, cmd, dr, &datain, 0); in iscsit_send_datain()
2928 iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_logout_rsp() argument
2933 struct iscsit_session *sess = conn->sess; in iscsit_build_logout_rsp()
2961 " successful.\n", cmd->logout_cid, conn->cid); in iscsit_build_logout_rsp()
2980 conn->sess, cmd->logout_cid); in iscsit_build_logout_rsp()
2993 cmd->logout_cid, conn->cid); in iscsit_build_logout_rsp()
3006 cmd->stat_sn = conn->stat_sn++; in iscsit_build_logout_rsp()
3009 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_logout_rsp()
3010 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_logout_rsp()
3011 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_logout_rsp()
3016 cmd->logout_cid, conn->cid); in iscsit_build_logout_rsp()
3023 iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_logout() argument
3027 rc = iscsit_build_logout_rsp(cmd, conn, in iscsit_send_logout()
3032 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_logout()
3036 iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_nopin_rsp() argument
3046 cmd->stat_sn = (nopout_response) ? conn->stat_sn++ : in iscsit_build_nopin_rsp()
3047 conn->stat_sn; in iscsit_build_nopin_rsp()
3051 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_nopin_rsp()
3053 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_nopin_rsp()
3054 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_nopin_rsp()
3068 struct iscsit_conn *conn, in iscsit_send_unsolicited_nopin() argument
3074 iscsit_build_nopin_rsp(cmd, conn, hdr, false); in iscsit_send_unsolicited_nopin()
3077 " 0x%08x CID: %hu\n", hdr->ttt, cmd->stat_sn, conn->cid); in iscsit_send_unsolicited_nopin()
3079 ret = conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_unsolicited_nopin()
3092 iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_nopin() argument
3096 iscsit_build_nopin_rsp(cmd, conn, hdr, true); in iscsit_send_nopin()
3104 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, in iscsit_send_nopin()
3111 struct iscsit_conn *conn) in iscsit_send_r2t() argument
3128 if (conn->conn_transport->iscsit_get_r2t_ttt) in iscsit_send_r2t()
3129 conn->conn_transport->iscsit_get_r2t_ttt(conn, cmd, r2t); in iscsit_send_r2t()
3131 r2t->targ_xfer_tag = session_get_next_ttt(conn->sess); in iscsit_send_r2t()
3133 hdr->statsn = cpu_to_be32(conn->stat_sn); in iscsit_send_r2t()
3134 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_send_r2t()
3135 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_send_r2t()
3144 r2t->offset, r2t->xfer_len, conn->cid); in iscsit_send_r2t()
3150 ret = conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_r2t()
3156 iscsit_start_dataout_timer(cmd, conn); in iscsit_send_r2t()
3167 struct iscsit_conn *conn, in iscsit_build_r2ts_for_cmd() argument
3180 if (conn->sess->sess_ops->DataSequenceInOrder && in iscsit_build_r2ts_for_cmd()
3184 while (cmd->outstanding_r2ts < conn->sess->sess_ops->MaxOutstandingR2T) { in iscsit_build_r2ts_for_cmd()
3185 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_build_r2ts_for_cmd()
3190 conn->sess->sess_ops->MaxBurstLength - in iscsit_build_r2ts_for_cmd()
3197 conn->sess->sess_ops->MaxBurstLength - in iscsit_build_r2ts_for_cmd()
3201 conn->sess->sess_ops->MaxBurstLength; in iscsit_build_r2ts_for_cmd()
3206 xfer_len = conn->sess->sess_ops->MaxBurstLength; in iscsit_build_r2ts_for_cmd()
3250 void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_rsp_pdu() argument
3254 cmd->stat_sn = conn->stat_sn++; in iscsit_build_rsp_pdu()
3256 atomic_long_inc(&conn->sess->rsp_pdus); in iscsit_build_rsp_pdu()
3273 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_rsp_pdu()
3274 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_rsp_pdu()
3275 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_rsp_pdu()
3280 cmd->se_cmd.scsi_status, conn->cid); in iscsit_build_rsp_pdu()
3284 static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_response() argument
3291 iscsit_build_rsp_pdu(cmd, conn, inc_stat_sn, hdr); in iscsit_send_response()
3319 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, data_buf, in iscsit_send_response()
3341 iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_task_mgt_rsp() argument
3350 cmd->stat_sn = conn->stat_sn++; in iscsit_build_task_mgt_rsp()
3353 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_task_mgt_rsp()
3354 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_task_mgt_rsp()
3355 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_task_mgt_rsp()
3359 cmd->init_task_tag, cmd->stat_sn, hdr->response, conn->cid); in iscsit_build_task_mgt_rsp()
3364 iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_task_mgt_rsp() argument
3368 iscsit_build_task_mgt_rsp(cmd, conn, hdr); in iscsit_send_task_mgt_rsp()
3370 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_task_mgt_rsp()
3381 struct iscsit_conn *conn = cmd->conn; in iscsit_build_sendtargets_response() local
3391 buffer_len = min(conn->conn_ops->MaxRecvDataSegmentLength, in iscsit_build_sendtargets_response()
3436 cmd->conn->sess->sess_ops->InitiatorName))) { in iscsit_build_sendtargets_response()
3480 sockaddr = &conn->local_sockaddr; in iscsit_build_sendtargets_response()
3526 iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_text_rsp() argument
3545 cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); in iscsit_build_text_rsp()
3552 cmd->stat_sn = conn->stat_sn++; in iscsit_build_text_rsp()
3555 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_text_rsp()
3562 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_text_rsp()
3563 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_text_rsp()
3567 cmd->targ_xfer_tag, cmd->stat_sn, text_length, conn->cid, in iscsit_build_text_rsp()
3577 struct iscsit_conn *conn) in iscsit_send_text_rsp() argument
3582 text_length = iscsit_build_text_rsp(cmd, conn, hdr, in iscsit_send_text_rsp()
3583 conn->conn_transport->transport_type); in iscsit_send_text_rsp()
3587 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, in iscsit_send_text_rsp()
3593 iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_reject() argument
3601 cmd->stat_sn = conn->stat_sn++; in iscsit_build_reject()
3603 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_reject()
3604 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_reject()
3611 struct iscsit_conn *conn) in iscsit_send_reject() argument
3615 iscsit_build_reject(cmd, conn, hdr); in iscsit_send_reject()
3618 " CID: %hu\n", ntohl(hdr->statsn), hdr->reason, conn->cid); in iscsit_send_reject()
3620 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, in iscsit_send_reject()
3625 void iscsit_thread_get_cpumask(struct iscsit_conn *conn) in iscsit_thread_get_cpumask() argument
3639 ord = conn->bitmap_id % cpumask_weight(cpu_online_mask); in iscsit_thread_get_cpumask()
3642 cpumask_set_cpu(cpu, conn->conn_cpumask); in iscsit_thread_get_cpumask()
3650 cpumask_clear(conn->conn_cpumask); in iscsit_thread_get_cpumask()
3651 ord = conn->bitmap_id % cpumask_weight(conn_allowed_cpumask); in iscsit_thread_get_cpumask()
3654 cpumask_set_cpu(cpu, conn->conn_cpumask); in iscsit_thread_get_cpumask()
3665 cpumask_setall(conn->conn_cpumask); in iscsit_thread_get_cpumask()
3668 static void iscsit_thread_reschedule(struct iscsit_conn *conn) in iscsit_thread_reschedule() argument
3672 * connection's RX/TX threads update conn->allowed_cpumask. in iscsit_thread_reschedule()
3675 conn->allowed_cpumask)) { in iscsit_thread_reschedule()
3676 iscsit_thread_get_cpumask(conn); in iscsit_thread_reschedule()
3677 conn->conn_tx_reset_cpumask = 1; in iscsit_thread_reschedule()
3678 conn->conn_rx_reset_cpumask = 1; in iscsit_thread_reschedule()
3679 cpumask_copy(conn->allowed_cpumask, in iscsit_thread_reschedule()
3685 struct iscsit_conn *conn, in iscsit_thread_check_cpumask() argument
3697 iscsit_thread_reschedule(conn); in iscsit_thread_check_cpumask()
3704 if (!conn->conn_tx_reset_cpumask) in iscsit_thread_check_cpumask()
3707 if (!conn->conn_rx_reset_cpumask) in iscsit_thread_check_cpumask()
3716 set_cpus_allowed_ptr(p, conn->conn_cpumask); in iscsit_thread_check_cpumask()
3718 conn->conn_tx_reset_cpumask = 0; in iscsit_thread_check_cpumask()
3720 conn->conn_rx_reset_cpumask = 0; in iscsit_thread_check_cpumask()
3725 iscsit_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) in iscsit_immediate_queue() argument
3731 ret = iscsit_send_r2t(cmd, conn); in iscsit_immediate_queue()
3736 spin_lock_bh(&conn->cmd_lock); in iscsit_immediate_queue()
3738 spin_unlock_bh(&conn->cmd_lock); in iscsit_immediate_queue()
3743 iscsit_mod_nopin_response_timer(conn); in iscsit_immediate_queue()
3744 ret = iscsit_send_unsolicited_nopin(cmd, conn, 1); in iscsit_immediate_queue()
3749 ret = iscsit_send_unsolicited_nopin(cmd, conn, 0); in iscsit_immediate_queue()
3757 conn->cid); in iscsit_immediate_queue()
3769 iscsit_handle_immediate_queue(struct iscsit_conn *conn) in iscsit_handle_immediate_queue() argument
3771 struct iscsit_transport *t = conn->conn_transport; in iscsit_handle_immediate_queue()
3777 while ((qr = iscsit_get_cmd_from_immediate_queue(conn))) { in iscsit_handle_immediate_queue()
3778 atomic_set(&conn->check_immediate_queue, 0); in iscsit_handle_immediate_queue()
3783 ret = t->iscsit_immediate_queue(conn, cmd, state); in iscsit_handle_immediate_queue()
3792 iscsit_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) in iscsit_response_queue() argument
3799 ret = iscsit_send_datain(cmd, conn); in iscsit_response_queue()
3811 if (atomic_read(&conn->check_immediate_queue)) in iscsit_response_queue()
3828 ret = iscsit_send_response(cmd, conn); in iscsit_response_queue()
3831 ret = iscsit_send_logout(cmd, conn); in iscsit_response_queue()
3835 cmd, conn); in iscsit_response_queue()
3838 ret = iscsit_send_nopin(cmd, conn); in iscsit_response_queue()
3841 ret = iscsit_send_reject(cmd, conn); in iscsit_response_queue()
3844 ret = iscsit_send_task_mgt_rsp(cmd, conn); in iscsit_response_queue()
3847 ret = iscsit_tmr_post_handler(cmd, conn); in iscsit_response_queue()
3849 iscsit_fall_back_to_erl0(conn->sess); in iscsit_response_queue()
3852 ret = iscsit_send_text_rsp(cmd, conn); in iscsit_response_queue()
3858 state, conn->cid); in iscsit_response_queue()
3866 if (!iscsit_logout_post_handler(cmd, conn)) in iscsit_response_queue()
3884 cmd->i_state, conn->cid); in iscsit_response_queue()
3888 if (atomic_read(&conn->check_immediate_queue)) in iscsit_response_queue()
3898 static int iscsit_handle_response_queue(struct iscsit_conn *conn) in iscsit_handle_response_queue() argument
3900 struct iscsit_transport *t = conn->conn_transport; in iscsit_handle_response_queue()
3906 while ((qr = iscsit_get_cmd_from_response_queue(conn))) { in iscsit_handle_response_queue()
3911 ret = t->iscsit_response_queue(conn, cmd, state); in iscsit_handle_response_queue()
3922 struct iscsit_conn *conn = arg; in iscsi_target_tx_thread() local
3936 iscsit_thread_check_cpumask(conn, current, 1); in iscsi_target_tx_thread()
3938 wait_event_interruptible(conn->queues_wq, in iscsi_target_tx_thread()
3939 !iscsit_conn_all_queues_empty(conn)); in iscsi_target_tx_thread()
3945 ret = iscsit_handle_immediate_queue(conn); in iscsi_target_tx_thread()
3949 ret = iscsit_handle_response_queue(conn); in iscsi_target_tx_thread()
3966 if (conn->conn_state != TARG_CONN_STATE_IN_LOGIN) in iscsi_target_tx_thread()
3967 iscsit_take_action_for_connection_exit(conn, &conn_freed); in iscsi_target_tx_thread()
3977 static int iscsi_target_rx_opcode(struct iscsit_conn *conn, unsigned char *buf) in iscsi_target_rx_opcode() argument
3985 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
3989 ret = iscsit_handle_scsi_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
3992 ret = iscsit_handle_data_out(conn, buf); in iscsi_target_rx_opcode()
3997 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
4001 ret = iscsit_handle_nop_out(conn, cmd, buf); in iscsi_target_rx_opcode()
4004 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
4008 ret = iscsit_handle_task_mgt_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
4012 cmd = iscsit_find_cmd_from_itt(conn, hdr->itt); in iscsi_target_rx_opcode()
4016 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
4021 ret = iscsit_handle_text_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
4024 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
4028 ret = iscsit_handle_logout_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
4030 wait_for_completion_timeout(&conn->conn_logout_comp, in iscsi_target_rx_opcode()
4034 ret = iscsit_handle_snack(conn, buf); in iscsi_target_rx_opcode()
4038 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsi_target_rx_opcode()
4051 return iscsit_add_reject(conn, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf); in iscsi_target_rx_opcode()
4054 static bool iscsi_target_check_conn_state(struct iscsit_conn *conn) in iscsi_target_check_conn_state() argument
4058 spin_lock_bh(&conn->state_lock); in iscsi_target_check_conn_state()
4059 ret = (conn->conn_state != TARG_CONN_STATE_LOGGED_IN); in iscsi_target_check_conn_state()
4060 spin_unlock_bh(&conn->state_lock); in iscsi_target_check_conn_state()
4065 static void iscsit_get_rx_pdu(struct iscsit_conn *conn) in iscsit_get_rx_pdu() argument
4082 iscsit_thread_check_cpumask(conn, current, 0); in iscsit_get_rx_pdu()
4089 ret = rx_data(conn, &iov, 1, ISCSI_HDR_LEN); in iscsit_get_rx_pdu()
4091 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_get_rx_pdu()
4107 ret = rx_data(conn, &iov, 1, iov.iov_len); in iscsit_get_rx_pdu()
4109 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_get_rx_pdu()
4114 if (conn->conn_ops->HeaderDigest) { in iscsit_get_rx_pdu()
4118 ret = rx_data(conn, &iov, 1, ISCSI_CRC_LEN); in iscsit_get_rx_pdu()
4120 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_get_rx_pdu()
4124 iscsit_do_crypto_hash_buf(conn->conn_rx_hash, buffer, in iscsit_get_rx_pdu()
4137 atomic_long_inc(&conn->sess->conn_digest_errors); in iscsit_get_rx_pdu()
4144 if (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT) in iscsit_get_rx_pdu()
4149 if (conn->sess->sess_ops->SessionType && in iscsit_get_rx_pdu()
4154 iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_get_rx_pdu()
4159 ret = iscsi_target_rx_opcode(conn, buffer); in iscsit_get_rx_pdu()
4170 struct iscsit_conn *conn = arg; in iscsi_target_rx_thread() local
4182 rc = wait_for_completion_interruptible(&conn->rx_login_comp); in iscsi_target_rx_thread()
4183 if (rc < 0 || iscsi_target_check_conn_state(conn)) in iscsi_target_rx_thread()
4186 if (!conn->conn_transport->iscsit_get_rx_pdu) in iscsi_target_rx_thread()
4189 conn->conn_transport->iscsit_get_rx_pdu(conn); in iscsi_target_rx_thread()
4192 atomic_set(&conn->transport_failed, 1); in iscsi_target_rx_thread()
4193 iscsit_take_action_for_connection_exit(conn, &conn_freed); in iscsi_target_rx_thread()
4205 static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) in iscsit_release_commands_from_conn() argument
4209 struct iscsit_session *sess = conn->sess; in iscsit_release_commands_from_conn()
4215 spin_lock_bh(&conn->cmd_lock); in iscsit_release_commands_from_conn()
4216 list_splice_init(&conn->conn_cmd_list, &tmp_list); in iscsit_release_commands_from_conn()
4230 &conn->conn_cmd_list); in iscsit_release_commands_from_conn()
4237 spin_unlock_bh(&conn->cmd_lock); in iscsit_release_commands_from_conn()
4249 struct iscsit_conn *conn) in iscsit_stop_timers_for_cmds() argument
4253 spin_lock_bh(&conn->cmd_lock); in iscsit_stop_timers_for_cmds()
4254 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { in iscsit_stop_timers_for_cmds()
4258 spin_unlock_bh(&conn->cmd_lock); in iscsit_stop_timers_for_cmds()
4262 struct iscsit_conn *conn) in iscsit_close_connection() argument
4264 int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT); in iscsit_close_connection()
4265 struct iscsit_session *sess = conn->sess; in iscsit_close_connection()
4268 " %u\n", conn->cid, sess->sid); in iscsit_close_connection()
4280 if (!conn->conn_transport->rdma_shutdown) in iscsit_close_connection()
4281 complete(&conn->conn_logout_comp); in iscsit_close_connection()
4284 if (conn->tx_thread && in iscsit_close_connection()
4285 cmpxchg(&conn->tx_thread_active, true, false)) { in iscsit_close_connection()
4286 send_sig(SIGINT, conn->tx_thread, 1); in iscsit_close_connection()
4287 kthread_stop(conn->tx_thread); in iscsit_close_connection()
4290 if (conn->rx_thread && in iscsit_close_connection()
4291 cmpxchg(&conn->rx_thread_active, true, false)) { in iscsit_close_connection()
4292 send_sig(SIGINT, conn->rx_thread, 1); in iscsit_close_connection()
4293 kthread_stop(conn->rx_thread); in iscsit_close_connection()
4298 bitmap_release_region(iscsit_global->ts_bitmap, conn->bitmap_id, in iscsit_close_connection()
4302 iscsit_stop_timers_for_cmds(conn); in iscsit_close_connection()
4303 iscsit_stop_nopin_response_timer(conn); in iscsit_close_connection()
4304 iscsit_stop_nopin_timer(conn); in iscsit_close_connection()
4306 if (conn->conn_transport->iscsit_wait_conn) in iscsit_close_connection()
4307 conn->conn_transport->iscsit_wait_conn(conn); in iscsit_close_connection()
4318 if (atomic_read(&conn->connection_recovery)) { in iscsit_close_connection()
4319 iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(conn); in iscsit_close_connection()
4320 iscsit_prepare_cmds_for_reallegiance(conn); in iscsit_close_connection()
4322 iscsit_clear_ooo_cmdsns_for_conn(conn); in iscsit_close_connection()
4323 iscsit_release_commands_from_conn(conn); in iscsit_close_connection()
4325 iscsit_free_queue_reqs_for_conn(conn); in iscsit_close_connection()
4332 if (atomic_read(&conn->conn_logout_remove)) { in iscsit_close_connection()
4333 if (conn->conn_logout_reason == ISCSI_LOGOUT_REASON_CLOSE_SESSION) { in iscsit_close_connection()
4334 iscsit_dec_conn_usage_count(conn); in iscsit_close_connection()
4337 if (conn->conn_logout_reason == ISCSI_LOGOUT_REASON_CLOSE_CONNECTION) in iscsit_close_connection()
4338 iscsit_dec_conn_usage_count(conn); in iscsit_close_connection()
4340 atomic_set(&conn->conn_logout_remove, 0); in iscsit_close_connection()
4346 list_del(&conn->conn_list); in iscsit_close_connection()
4353 if (atomic_read(&conn->connection_recovery)) in iscsit_close_connection()
4354 iscsit_build_conn_drop_async_message(conn); in iscsit_close_connection()
4363 spin_lock_bh(&conn->state_lock); in iscsit_close_connection()
4364 if (atomic_read(&conn->sleep_on_conn_wait_comp)) { in iscsit_close_connection()
4365 spin_unlock_bh(&conn->state_lock); in iscsit_close_connection()
4366 complete(&conn->conn_wait_comp); in iscsit_close_connection()
4367 wait_for_completion(&conn->conn_post_wait_comp); in iscsit_close_connection()
4368 spin_lock_bh(&conn->state_lock); in iscsit_close_connection()
4377 if (atomic_read(&conn->connection_wait_rcfr)) { in iscsit_close_connection()
4378 spin_unlock_bh(&conn->state_lock); in iscsit_close_connection()
4379 complete(&conn->conn_wait_rcfr_comp); in iscsit_close_connection()
4380 wait_for_completion(&conn->conn_post_wait_comp); in iscsit_close_connection()
4381 spin_lock_bh(&conn->state_lock); in iscsit_close_connection()
4383 atomic_set(&conn->connection_reinstatement, 1); in iscsit_close_connection()
4384 spin_unlock_bh(&conn->state_lock); in iscsit_close_connection()
4390 iscsit_check_conn_usage_count(conn); in iscsit_close_connection()
4392 ahash_request_free(conn->conn_tx_hash); in iscsit_close_connection()
4393 if (conn->conn_rx_hash) { in iscsit_close_connection()
4396 tfm = crypto_ahash_reqtfm(conn->conn_rx_hash); in iscsit_close_connection()
4397 ahash_request_free(conn->conn_rx_hash); in iscsit_close_connection()
4401 if (conn->sock) in iscsit_close_connection()
4402 sock_release(conn->sock); in iscsit_close_connection()
4404 if (conn->conn_transport->iscsit_free_conn) in iscsit_close_connection()
4405 conn->conn_transport->iscsit_free_conn(conn); in iscsit_close_connection()
4408 conn->conn_state = TARG_CONN_STATE_FREE; in iscsit_close_connection()
4409 iscsit_free_conn(conn); in iscsit_close_connection()
4570 struct iscsit_conn *conn) in iscsit_logout_post_handler_closesession() argument
4572 struct iscsit_session *sess = conn->sess; in iscsit_logout_post_handler_closesession()
4583 if (!conn->conn_transport->rdma_shutdown) { in iscsit_logout_post_handler_closesession()
4584 sleep = cmpxchg(&conn->tx_thread_active, true, false); in iscsit_logout_post_handler_closesession()
4589 atomic_set(&conn->conn_logout_remove, 0); in iscsit_logout_post_handler_closesession()
4590 complete(&conn->conn_logout_comp); in iscsit_logout_post_handler_closesession()
4592 iscsit_dec_conn_usage_count(conn); in iscsit_logout_post_handler_closesession()
4599 struct iscsit_conn *conn) in iscsit_logout_post_handler_samecid() argument
4603 if (!conn->conn_transport->rdma_shutdown) { in iscsit_logout_post_handler_samecid()
4604 sleep = cmpxchg(&conn->tx_thread_active, true, false); in iscsit_logout_post_handler_samecid()
4609 atomic_set(&conn->conn_logout_remove, 0); in iscsit_logout_post_handler_samecid()
4610 complete(&conn->conn_logout_comp); in iscsit_logout_post_handler_samecid()
4612 iscsit_cause_connection_reinstatement(conn, sleep); in iscsit_logout_post_handler_samecid()
4613 iscsit_dec_conn_usage_count(conn); in iscsit_logout_post_handler_samecid()
4617 struct iscsit_conn *conn, in iscsit_logout_post_handler_diffcid() argument
4621 struct iscsit_session *sess = conn->sess; in iscsit_logout_post_handler_diffcid()
4657 struct iscsit_conn *conn) in iscsit_logout_post_handler() argument
4667 iscsit_logout_post_handler_closesession(conn); in iscsit_logout_post_handler()
4672 if (conn->cid == cmd->logout_cid) { in iscsit_logout_post_handler()
4677 iscsit_logout_post_handler_samecid(conn); in iscsit_logout_post_handler()
4683 iscsit_logout_post_handler_diffcid(conn, in iscsit_logout_post_handler()
4715 struct iscsit_conn *conn; in iscsit_fail_session() local
4718 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) { in iscsit_fail_session()
4720 conn->conn_state = TARG_CONN_STATE_CLEANUP_WAIT; in iscsit_fail_session()
4734 struct iscsit_conn *conn, *conn_tmp = NULL; in iscsit_stop_session() local
4740 list_for_each_entry_safe(conn, conn_tmp, &sess->sess_conn_list, in iscsit_stop_session()
4745 if (list_is_last(&conn->conn_list, &sess->sess_conn_list)) { in iscsit_stop_session()
4751 iscsit_inc_conn_usage_count(conn); in iscsit_stop_session()
4754 iscsit_cause_connection_reinstatement(conn, 1); in iscsit_stop_session()
4757 iscsit_dec_conn_usage_count(conn); in iscsit_stop_session()
4763 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) in iscsit_stop_session()
4764 iscsit_cause_connection_reinstatement(conn, 0); in iscsit_stop_session()