Lines Matching refs: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()
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
1011 atomic_long_inc(&conn->sess->cmd_pdus); in iscsit_setup_scsi_cmd()
1069 if (payload_length && !conn->sess->sess_ops->ImmediateData) { in iscsit_setup_scsi_cmd()
1093 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_setup_scsi_cmd()
1096 payload_length, conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_setup_scsi_cmd()
1101 if (payload_length > conn->sess->sess_ops->FirstBurstLength) { in iscsit_setup_scsi_cmd()
1104 payload_length, conn->sess->sess_ops->FirstBurstLength); in iscsit_setup_scsi_cmd()
1142 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_setup_scsi_cmd()
1144 cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); in iscsit_setup_scsi_cmd()
1151 if (!conn->sess->sess_ops->RDMAExtensions && in iscsit_setup_scsi_cmd()
1167 conn->sess->se_sess, be32_to_cpu(hdr->data_length), in iscsit_setup_scsi_cmd()
1174 conn->cid); in iscsit_setup_scsi_cmd()
1205 spin_lock_bh(&conn->cmd_lock); in iscsit_setup_scsi_cmd()
1206 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_setup_scsi_cmd()
1207 spin_unlock_bh(&conn->cmd_lock); in iscsit_setup_scsi_cmd()
1223 iscsit_start_dataout_timer(cmd, cmd->conn); in iscsit_set_unsolicited_dataout()
1228 int iscsit_process_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_process_scsi_cmd() argument
1243 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, in iscsit_process_scsi_cmd()
1253 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_process_scsi_cmd()
1304 rc = iscsit_dump_data_payload(cmd->conn, length, 1); in iscsit_get_immediate_data()
1319 cmdsn_ret = iscsit_sequence_cmd(cmd->conn, cmd, in iscsit_get_immediate_data()
1344 iscsit_add_cmd_to_immediate_queue(cmd, cmd->conn, cmd->i_state); in iscsit_get_immediate_data()
1352 iscsit_handle_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_scsi_cmd() argument
1359 rc = iscsit_setup_scsi_cmd(conn, cmd, buf); in iscsit_handle_scsi_cmd()
1372 rc = iscsit_process_scsi_cmd(conn, cmd, hdr); in iscsit_handle_scsi_cmd()
1458 __iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, in __iscsit_check_dataout_hdr() argument
1467 atomic_long_add(payload_length, &conn->sess->rx_data_octets); in __iscsit_check_dataout_hdr()
1472 payload_length, conn->cid); in __iscsit_check_dataout_hdr()
1478 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1484 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1499 if (conn->sess->sess_ops->InitialR2T) { in __iscsit_check_dataout_hdr()
1526 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1544 return iscsit_dump_data_payload(conn, payload_length, 1); in __iscsit_check_dataout_hdr()
1562 iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, in iscsit_check_dataout_hdr() argument
1576 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_check_dataout_hdr()
1579 conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_check_dataout_hdr()
1580 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, buf); in iscsit_check_dataout_hdr()
1583 cmd = iscsit_find_cmd_from_itt_or_dump(conn, hdr->itt, payload_length); in iscsit_check_dataout_hdr()
1587 rc = __iscsit_check_dataout_hdr(conn, buf, cmd, payload_length, &success); in iscsit_check_dataout_hdr()
1597 iscsit_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_get_dataout() argument
1625 if (conn->conn_ops->DataDigest) { in iscsit_get_dataout()
1632 rx_got = rx_data(conn, &cmd->iov_data[0], iov_count, rx_size); in iscsit_get_dataout()
1639 if (conn->conn_ops->DataDigest) { in iscsit_get_dataout()
1642 data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd, in iscsit_get_dataout()
1668 struct iscsit_conn *conn = cmd->conn; in iscsit_check_dataout_payload() local
1679 conn->conn_transport->iscsit_get_dataout(conn, cmd, false); in iscsit_check_dataout_payload()
1703 static int iscsit_handle_data_out(struct iscsit_conn *conn, unsigned char *buf) in iscsit_handle_data_out() argument
1710 rc = iscsit_check_dataout_hdr(conn, buf, &cmd); in iscsit_handle_data_out()
1716 rc = iscsit_get_dataout(conn, cmd, hdr); in iscsit_handle_data_out()
1725 int iscsit_setup_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_setup_nop_out() argument
1733 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_setup_nop_out()
1744 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_setup_nop_out()
1751 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_setup_nop_out()
1755 conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_setup_nop_out()
1757 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_setup_nop_out()
1781 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_setup_nop_out()
1792 int iscsit_process_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_process_nop_out() argument
1802 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_process_nop_out()
1805 spin_lock_bh(&conn->cmd_lock); in iscsit_process_nop_out()
1806 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_process_nop_out()
1807 spin_unlock_bh(&conn->cmd_lock); in iscsit_process_nop_out()
1809 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_process_nop_out()
1812 iscsit_add_cmd_to_response_queue(cmd, conn, in iscsit_process_nop_out()
1817 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, in iscsit_process_nop_out()
1830 cmd_p = iscsit_find_cmd_from_ttt(conn, be32_to_cpu(hdr->ttt)); in iscsit_process_nop_out()
1834 iscsit_stop_nopin_response_timer(conn); in iscsit_process_nop_out()
1837 iscsit_add_cmd_to_immediate_queue(cmd_p, conn, cmd_p->i_state); in iscsit_process_nop_out()
1839 iscsit_start_nopin_timer(conn); in iscsit_process_nop_out()
1854 static int iscsit_handle_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_nop_out() argument
1863 ret = iscsit_setup_nop_out(conn, cmd, hdr); in iscsit_handle_nop_out()
1891 if (conn->conn_ops->DataDigest) { in iscsit_handle_nop_out()
1898 rx_got = rx_data(conn, &cmd->iov_misc[0], niov, rx_size); in iscsit_handle_nop_out()
1904 if (conn->conn_ops->DataDigest) { in iscsit_handle_nop_out()
1905 iscsit_do_crypto_hash_buf(conn->conn_rx_hash, ping_data, in iscsit_handle_nop_out()
1913 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_nop_out()
1949 return iscsit_process_nop_out(conn, cmd, hdr); in iscsit_handle_nop_out()
1981 iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_task_mgt_cmd() argument
1997 hdr->rtt, hdr->refcmdsn, conn->cid); in iscsit_handle_task_mgt_cmd()
2027 conn->sess->se_sess, 0, DMA_NONE, in iscsit_handle_task_mgt_cmd()
2086 if (iscsit_tmr_task_warm_reset(conn, tmr_req, buf) < 0) { in iscsit_handle_task_mgt_cmd()
2092 if (iscsit_tmr_task_cold_reset(conn, tmr_req, buf) < 0) { in iscsit_handle_task_mgt_cmd()
2106 if (iscsit_check_task_reassign_expdatasn(tmr_req, conn) < 0) in iscsit_handle_task_mgt_cmd()
2121 spin_lock_bh(&conn->cmd_lock); in iscsit_handle_task_mgt_cmd()
2122 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_handle_task_mgt_cmd()
2123 spin_unlock_bh(&conn->cmd_lock); in iscsit_handle_task_mgt_cmd()
2126 int cmdsn_ret = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn); in iscsit_handle_task_mgt_cmd()
2136 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_handle_task_mgt_cmd()
2154 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_handle_task_mgt_cmd()
2162 iscsit_setup_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_setup_text_cmd() argument
2167 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { in iscsit_setup_text_cmd()
2170 payload_length, conn->conn_ops->MaxXmitDataSegmentLength); in iscsit_setup_text_cmd()
2189 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_setup_text_cmd()
2202 iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_process_text_cmd() argument
2236 spin_lock_bh(&conn->cmd_lock); in iscsit_process_text_cmd()
2237 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_process_text_cmd()
2238 spin_unlock_bh(&conn->cmd_lock); in iscsit_process_text_cmd()
2241 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_process_text_cmd()
2244 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, in iscsit_process_text_cmd()
2261 iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_text_cmd() argument
2269 rc = iscsit_setup_text_cmd(conn, cmd, hdr); in iscsit_handle_text_cmd()
2295 if (conn->conn_ops->DataDigest) { in iscsit_handle_text_cmd()
2302 rx_got = rx_data(conn, &iov[0], niov, rx_size); in iscsit_handle_text_cmd()
2306 if (conn->conn_ops->DataDigest) { in iscsit_handle_text_cmd()
2307 iscsit_do_crypto_hash_buf(conn->conn_rx_hash, in iscsit_handle_text_cmd()
2315 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_text_cmd()
2342 return iscsit_process_text_cmd(conn, cmd, hdr); in iscsit_handle_text_cmd()
2350 int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_logout_closesession() argument
2353 struct iscsit_session *sess = conn->sess; in iscsit_logout_closesession()
2356 " for SID: %u.\n", conn->cid, conn->sess->sid); in iscsit_logout_closesession()
2359 atomic_set(&conn->conn_logout_remove, 1); in iscsit_logout_closesession()
2360 conn->conn_logout_reason = ISCSI_LOGOUT_REASON_CLOSE_SESSION; in iscsit_logout_closesession()
2362 iscsit_inc_conn_usage_count(conn); in iscsit_logout_closesession()
2375 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_closesession()
2380 int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_logout_closeconnection() argument
2383 struct iscsit_session *sess = conn->sess; in iscsit_logout_closeconnection()
2386 " %hu on CID: %hu.\n", cmd->logout_cid, conn->cid); in iscsit_logout_closeconnection()
2392 if (conn->cid == cmd->logout_cid) { in iscsit_logout_closeconnection()
2393 spin_lock_bh(&conn->state_lock); in iscsit_logout_closeconnection()
2395 conn->conn_state = TARG_CONN_STATE_IN_LOGOUT; in iscsit_logout_closeconnection()
2397 atomic_set(&conn->conn_logout_remove, 1); in iscsit_logout_closeconnection()
2398 conn->conn_logout_reason = ISCSI_LOGOUT_REASON_CLOSE_CONNECTION; in iscsit_logout_closeconnection()
2399 iscsit_inc_conn_usage_count(conn); in iscsit_logout_closeconnection()
2401 spin_unlock_bh(&conn->state_lock); in iscsit_logout_closeconnection()
2415 iscsit_add_cmd_to_response_queue(cmd, conn, in iscsit_logout_closeconnection()
2423 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_closeconnection()
2428 int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_logout_removeconnforrecovery() argument
2430 struct iscsit_session *sess = conn->sess; in iscsit_logout_removeconnforrecovery()
2433 " CID: %hu on CID: %hu.\n", cmd->logout_cid, conn->cid); in iscsit_logout_removeconnforrecovery()
2439 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_removeconnforrecovery()
2443 if (conn->cid == cmd->logout_cid) { in iscsit_logout_removeconnforrecovery()
2446 cmd->logout_cid, conn->cid); in iscsit_logout_removeconnforrecovery()
2448 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_removeconnforrecovery()
2452 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); in iscsit_logout_removeconnforrecovery()
2458 iscsit_handle_logout_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, in iscsit_handle_logout_cmd() argument
2464 struct iscsi_tiqn *tiqn = iscsit_snmp_get_tiqn(conn); in iscsit_handle_logout_cmd()
2481 hdr->cid, conn->cid); in iscsit_handle_logout_cmd()
2483 if (conn->conn_state != TARG_CONN_STATE_LOGGED_IN) { in iscsit_handle_logout_cmd()
2493 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; in iscsit_handle_logout_cmd()
2507 be16_to_cpu(hdr->cid) == conn->cid)) in iscsit_handle_logout_cmd()
2510 spin_lock_bh(&conn->cmd_lock); in iscsit_handle_logout_cmd()
2511 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); in iscsit_handle_logout_cmd()
2512 spin_unlock_bh(&conn->cmd_lock); in iscsit_handle_logout_cmd()
2515 iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); in iscsit_handle_logout_cmd()
2527 cmdsn_ret = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn); in iscsit_handle_logout_cmd()
2539 struct iscsit_conn *conn, in iscsit_handle_snack() argument
2550 hdr->begrun, hdr->runlength, conn->cid); in iscsit_handle_snack()
2552 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_snack()
2555 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_handle_snack()
2564 return iscsit_handle_recovery_datain_or_r2t(conn, buf, in iscsit_handle_snack()
2570 return iscsit_handle_status_snack(conn, hdr->itt, in iscsit_handle_snack()
2574 return iscsit_handle_data_ack(conn, be32_to_cpu(hdr->ttt), in iscsit_handle_snack()
2580 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_handle_snack()
2585 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_handle_snack()
2593 static void iscsit_rx_thread_wait_for_tcp(struct iscsit_conn *conn) in iscsit_rx_thread_wait_for_tcp() argument
2595 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) || in iscsit_rx_thread_wait_for_tcp()
2596 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) { in iscsit_rx_thread_wait_for_tcp()
2598 &conn->rx_half_close_comp, in iscsit_rx_thread_wait_for_tcp()
2610 struct iscsit_conn *conn = cmd->conn; in iscsit_handle_immediate_data() local
2648 if (conn->conn_ops->DataDigest) { in iscsit_handle_immediate_data()
2655 rx_got = rx_data(conn, &cmd->iov_data[0], iov_count, rx_size); in iscsit_handle_immediate_data()
2660 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_handle_immediate_data()
2664 if (conn->conn_ops->DataDigest) { in iscsit_handle_immediate_data()
2667 data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd, in iscsit_handle_immediate_data()
2676 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsit_handle_immediate_data()
2711 static void iscsit_build_conn_drop_async_message(struct iscsit_conn *conn) in iscsit_build_conn_drop_async_message() argument
2717 lockdep_assert_held(&conn->sess->conn_lock); in iscsit_build_conn_drop_async_message()
2723 list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) { in iscsit_build_conn_drop_async_message()
2740 cmd->logout_cid = conn->cid; in iscsit_build_conn_drop_async_message()
2754 struct iscsit_conn *conn) in iscsit_send_conn_drop_async_message() argument
2766 cmd->stat_sn = conn->stat_sn++; in iscsit_send_conn_drop_async_message()
2768 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_send_conn_drop_async_message()
2769 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_send_conn_drop_async_message()
2772 hdr->param2 = cpu_to_be16(conn->sess->sess_ops->DefaultTime2Wait); in iscsit_send_conn_drop_async_message()
2773 hdr->param3 = cpu_to_be16(conn->sess->sess_ops->DefaultTime2Retain); in iscsit_send_conn_drop_async_message()
2777 cmd->logout_cid, conn->cid); in iscsit_send_conn_drop_async_message()
2779 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_conn_drop_async_message()
2782 static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *conn) in iscsit_tx_thread_wait_for_tcp() argument
2784 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) || in iscsit_tx_thread_wait_for_tcp()
2785 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) { in iscsit_tx_thread_wait_for_tcp()
2787 &conn->tx_half_close_comp, in iscsit_tx_thread_wait_for_tcp()
2793 iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_datain_pdu() argument
2826 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_datain_pdu()
2827 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_datain_pdu()
2834 ntohl(hdr->offset), datain->length, conn->cid); in iscsit_build_datain_pdu()
2838 static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_datain() argument
2864 atomic_long_add(datain.length, &conn->sess->tx_data_octets); in iscsit_send_datain()
2875 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_send_datain()
2876 cmd->stat_sn = conn->stat_sn++; in iscsit_send_datain()
2883 iscsit_build_datain_pdu(cmd, conn, &datain, hdr, set_statsn); in iscsit_send_datain()
2885 ret = conn->conn_transport->iscsit_xmit_pdu(conn, cmd, dr, &datain, 0); in iscsit_send_datain()
2899 iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_logout_rsp() argument
2904 struct iscsit_session *sess = conn->sess; in iscsit_build_logout_rsp()
2932 " successful.\n", cmd->logout_cid, conn->cid); in iscsit_build_logout_rsp()
2951 conn->sess, cmd->logout_cid); in iscsit_build_logout_rsp()
2964 cmd->logout_cid, conn->cid); in iscsit_build_logout_rsp()
2977 cmd->stat_sn = conn->stat_sn++; in iscsit_build_logout_rsp()
2980 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_logout_rsp()
2981 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_logout_rsp()
2982 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_logout_rsp()
2987 cmd->logout_cid, conn->cid); in iscsit_build_logout_rsp()
2994 iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_logout() argument
2998 rc = iscsit_build_logout_rsp(cmd, conn, in iscsit_send_logout()
3003 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_logout()
3007 iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_nopin_rsp() argument
3017 cmd->stat_sn = (nopout_response) ? conn->stat_sn++ : in iscsit_build_nopin_rsp()
3018 conn->stat_sn; in iscsit_build_nopin_rsp()
3022 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_nopin_rsp()
3024 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_nopin_rsp()
3025 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_nopin_rsp()
3039 struct iscsit_conn *conn, in iscsit_send_unsolicited_nopin() argument
3045 iscsit_build_nopin_rsp(cmd, conn, hdr, false); in iscsit_send_unsolicited_nopin()
3048 " 0x%08x CID: %hu\n", hdr->ttt, cmd->stat_sn, conn->cid); in iscsit_send_unsolicited_nopin()
3050 ret = conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_unsolicited_nopin()
3063 iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_nopin() argument
3067 iscsit_build_nopin_rsp(cmd, conn, hdr, true); in iscsit_send_nopin()
3075 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, in iscsit_send_nopin()
3082 struct iscsit_conn *conn) in iscsit_send_r2t() argument
3099 if (conn->conn_transport->iscsit_get_r2t_ttt) in iscsit_send_r2t()
3100 conn->conn_transport->iscsit_get_r2t_ttt(conn, cmd, r2t); in iscsit_send_r2t()
3102 r2t->targ_xfer_tag = session_get_next_ttt(conn->sess); in iscsit_send_r2t()
3104 hdr->statsn = cpu_to_be32(conn->stat_sn); in iscsit_send_r2t()
3105 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_send_r2t()
3106 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_send_r2t()
3115 r2t->offset, r2t->xfer_len, conn->cid); in iscsit_send_r2t()
3121 ret = conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_r2t()
3127 iscsit_start_dataout_timer(cmd, conn); in iscsit_send_r2t()
3138 struct iscsit_conn *conn, in iscsit_build_r2ts_for_cmd() argument
3151 if (conn->sess->sess_ops->DataSequenceInOrder && in iscsit_build_r2ts_for_cmd()
3155 while (cmd->outstanding_r2ts < conn->sess->sess_ops->MaxOutstandingR2T) { in iscsit_build_r2ts_for_cmd()
3156 if (conn->sess->sess_ops->DataSequenceInOrder) { in iscsit_build_r2ts_for_cmd()
3161 conn->sess->sess_ops->MaxBurstLength - in iscsit_build_r2ts_for_cmd()
3168 conn->sess->sess_ops->MaxBurstLength - in iscsit_build_r2ts_for_cmd()
3172 conn->sess->sess_ops->MaxBurstLength; in iscsit_build_r2ts_for_cmd()
3177 xfer_len = conn->sess->sess_ops->MaxBurstLength; in iscsit_build_r2ts_for_cmd()
3221 void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_rsp_pdu() argument
3225 cmd->stat_sn = conn->stat_sn++; in iscsit_build_rsp_pdu()
3227 atomic_long_inc(&conn->sess->rsp_pdus); in iscsit_build_rsp_pdu()
3244 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_rsp_pdu()
3245 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_rsp_pdu()
3246 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_rsp_pdu()
3251 cmd->se_cmd.scsi_status, conn->cid); in iscsit_build_rsp_pdu()
3255 static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_response() argument
3262 iscsit_build_rsp_pdu(cmd, conn, inc_stat_sn, hdr); in iscsit_send_response()
3290 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, data_buf, in iscsit_send_response()
3312 iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_task_mgt_rsp() argument
3321 cmd->stat_sn = conn->stat_sn++; in iscsit_build_task_mgt_rsp()
3324 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_task_mgt_rsp()
3325 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_task_mgt_rsp()
3326 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_task_mgt_rsp()
3330 cmd->init_task_tag, cmd->stat_sn, hdr->response, conn->cid); in iscsit_build_task_mgt_rsp()
3335 iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn) in iscsit_send_task_mgt_rsp() argument
3339 iscsit_build_task_mgt_rsp(cmd, conn, hdr); in iscsit_send_task_mgt_rsp()
3341 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); in iscsit_send_task_mgt_rsp()
3352 struct iscsit_conn *conn = cmd->conn; in iscsit_build_sendtargets_response() local
3362 buffer_len = min(conn->conn_ops->MaxRecvDataSegmentLength, in iscsit_build_sendtargets_response()
3407 cmd->conn->sess->sess_ops->InitiatorName))) { in iscsit_build_sendtargets_response()
3451 sockaddr = &conn->local_sockaddr; in iscsit_build_sendtargets_response()
3497 iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_text_rsp() argument
3516 cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); in iscsit_build_text_rsp()
3523 cmd->stat_sn = conn->stat_sn++; in iscsit_build_text_rsp()
3526 iscsit_increment_maxcmdsn(cmd, conn->sess); in iscsit_build_text_rsp()
3533 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_text_rsp()
3534 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_text_rsp()
3538 cmd->targ_xfer_tag, cmd->stat_sn, text_length, conn->cid, in iscsit_build_text_rsp()
3548 struct iscsit_conn *conn) in iscsit_send_text_rsp() argument
3553 text_length = iscsit_build_text_rsp(cmd, conn, hdr, in iscsit_send_text_rsp()
3554 conn->conn_transport->transport_type); in iscsit_send_text_rsp()
3558 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, in iscsit_send_text_rsp()
3564 iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn, in iscsit_build_reject() argument
3572 cmd->stat_sn = conn->stat_sn++; in iscsit_build_reject()
3574 hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); in iscsit_build_reject()
3575 hdr->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn)); in iscsit_build_reject()
3582 struct iscsit_conn *conn) in iscsit_send_reject() argument
3586 iscsit_build_reject(cmd, conn, hdr); in iscsit_send_reject()
3589 " CID: %hu\n", ntohl(hdr->statsn), hdr->reason, conn->cid); in iscsit_send_reject()
3591 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, in iscsit_send_reject()
3596 void iscsit_thread_get_cpumask(struct iscsit_conn *conn) in iscsit_thread_get_cpumask() argument
3610 ord = conn->bitmap_id % cpumask_weight(cpu_online_mask); in iscsit_thread_get_cpumask()
3613 cpumask_set_cpu(cpu, conn->conn_cpumask); in iscsit_thread_get_cpumask()
3621 cpumask_clear(conn->conn_cpumask); in iscsit_thread_get_cpumask()
3622 ord = conn->bitmap_id % cpumask_weight(conn_allowed_cpumask); in iscsit_thread_get_cpumask()
3625 cpumask_set_cpu(cpu, conn->conn_cpumask); in iscsit_thread_get_cpumask()
3636 cpumask_setall(conn->conn_cpumask); in iscsit_thread_get_cpumask()
3639 static void iscsit_thread_reschedule(struct iscsit_conn *conn) in iscsit_thread_reschedule() argument
3646 conn->allowed_cpumask)) { in iscsit_thread_reschedule()
3647 iscsit_thread_get_cpumask(conn); in iscsit_thread_reschedule()
3648 conn->conn_tx_reset_cpumask = 1; in iscsit_thread_reschedule()
3649 conn->conn_rx_reset_cpumask = 1; in iscsit_thread_reschedule()
3650 cpumask_copy(conn->allowed_cpumask, in iscsit_thread_reschedule()
3656 struct iscsit_conn *conn, in iscsit_thread_check_cpumask() argument
3668 iscsit_thread_reschedule(conn); in iscsit_thread_check_cpumask()
3675 if (!conn->conn_tx_reset_cpumask) in iscsit_thread_check_cpumask()
3678 if (!conn->conn_rx_reset_cpumask) in iscsit_thread_check_cpumask()
3687 set_cpus_allowed_ptr(p, conn->conn_cpumask); in iscsit_thread_check_cpumask()
3689 conn->conn_tx_reset_cpumask = 0; in iscsit_thread_check_cpumask()
3691 conn->conn_rx_reset_cpumask = 0; in iscsit_thread_check_cpumask()
3696 iscsit_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) in iscsit_immediate_queue() argument
3702 ret = iscsit_send_r2t(cmd, conn); in iscsit_immediate_queue()
3707 spin_lock_bh(&conn->cmd_lock); in iscsit_immediate_queue()
3709 spin_unlock_bh(&conn->cmd_lock); in iscsit_immediate_queue()
3714 iscsit_mod_nopin_response_timer(conn); in iscsit_immediate_queue()
3715 ret = iscsit_send_unsolicited_nopin(cmd, conn, 1); in iscsit_immediate_queue()
3720 ret = iscsit_send_unsolicited_nopin(cmd, conn, 0); in iscsit_immediate_queue()
3728 conn->cid); in iscsit_immediate_queue()
3740 iscsit_handle_immediate_queue(struct iscsit_conn *conn) in iscsit_handle_immediate_queue() argument
3742 struct iscsit_transport *t = conn->conn_transport; in iscsit_handle_immediate_queue()
3748 while ((qr = iscsit_get_cmd_from_immediate_queue(conn))) { in iscsit_handle_immediate_queue()
3749 atomic_set(&conn->check_immediate_queue, 0); in iscsit_handle_immediate_queue()
3754 ret = t->iscsit_immediate_queue(conn, cmd, state); in iscsit_handle_immediate_queue()
3763 iscsit_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) in iscsit_response_queue() argument
3770 ret = iscsit_send_datain(cmd, conn); in iscsit_response_queue()
3782 if (atomic_read(&conn->check_immediate_queue)) in iscsit_response_queue()
3799 ret = iscsit_send_response(cmd, conn); in iscsit_response_queue()
3802 ret = iscsit_send_logout(cmd, conn); in iscsit_response_queue()
3806 cmd, conn); in iscsit_response_queue()
3809 ret = iscsit_send_nopin(cmd, conn); in iscsit_response_queue()
3812 ret = iscsit_send_reject(cmd, conn); in iscsit_response_queue()
3815 ret = iscsit_send_task_mgt_rsp(cmd, conn); in iscsit_response_queue()
3818 ret = iscsit_tmr_post_handler(cmd, conn); in iscsit_response_queue()
3820 iscsit_fall_back_to_erl0(conn->sess); in iscsit_response_queue()
3823 ret = iscsit_send_text_rsp(cmd, conn); in iscsit_response_queue()
3829 state, conn->cid); in iscsit_response_queue()
3837 if (!iscsit_logout_post_handler(cmd, conn)) in iscsit_response_queue()
3855 cmd->i_state, conn->cid); in iscsit_response_queue()
3859 if (atomic_read(&conn->check_immediate_queue)) in iscsit_response_queue()
3869 static int iscsit_handle_response_queue(struct iscsit_conn *conn) in iscsit_handle_response_queue() argument
3871 struct iscsit_transport *t = conn->conn_transport; in iscsit_handle_response_queue()
3877 while ((qr = iscsit_get_cmd_from_response_queue(conn))) { in iscsit_handle_response_queue()
3882 ret = t->iscsit_response_queue(conn, cmd, state); in iscsit_handle_response_queue()
3893 struct iscsit_conn *conn = arg; in iscsi_target_tx_thread() local
3907 iscsit_thread_check_cpumask(conn, current, 1); in iscsi_target_tx_thread()
3909 wait_event_interruptible(conn->queues_wq, in iscsi_target_tx_thread()
3910 !iscsit_conn_all_queues_empty(conn)); in iscsi_target_tx_thread()
3916 ret = iscsit_handle_immediate_queue(conn); in iscsi_target_tx_thread()
3920 ret = iscsit_handle_response_queue(conn); in iscsi_target_tx_thread()
3937 if (conn->conn_state != TARG_CONN_STATE_IN_LOGIN) in iscsi_target_tx_thread()
3938 iscsit_take_action_for_connection_exit(conn, &conn_freed); in iscsi_target_tx_thread()
3948 static int iscsi_target_rx_opcode(struct iscsit_conn *conn, unsigned char *buf) in iscsi_target_rx_opcode() argument
3956 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
3960 ret = iscsit_handle_scsi_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
3963 ret = iscsit_handle_data_out(conn, buf); in iscsi_target_rx_opcode()
3968 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
3972 ret = iscsit_handle_nop_out(conn, cmd, buf); in iscsi_target_rx_opcode()
3975 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
3979 ret = iscsit_handle_task_mgt_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
3983 cmd = iscsit_find_cmd_from_itt(conn, hdr->itt); in iscsi_target_rx_opcode()
3987 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
3992 ret = iscsit_handle_text_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
3995 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); in iscsi_target_rx_opcode()
3999 ret = iscsit_handle_logout_cmd(conn, cmd, buf); in iscsi_target_rx_opcode()
4001 wait_for_completion_timeout(&conn->conn_logout_comp, in iscsi_target_rx_opcode()
4005 ret = iscsit_handle_snack(conn, buf); in iscsi_target_rx_opcode()
4009 if (!conn->sess->sess_ops->ErrorRecoveryLevel) { in iscsi_target_rx_opcode()
4022 return iscsit_add_reject(conn, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf); in iscsi_target_rx_opcode()
4025 static bool iscsi_target_check_conn_state(struct iscsit_conn *conn) in iscsi_target_check_conn_state() argument
4029 spin_lock_bh(&conn->state_lock); in iscsi_target_check_conn_state()
4030 ret = (conn->conn_state != TARG_CONN_STATE_LOGGED_IN); in iscsi_target_check_conn_state()
4031 spin_unlock_bh(&conn->state_lock); in iscsi_target_check_conn_state()
4036 static void iscsit_get_rx_pdu(struct iscsit_conn *conn) in iscsit_get_rx_pdu() argument
4052 iscsit_thread_check_cpumask(conn, current, 0); in iscsit_get_rx_pdu()
4059 ret = rx_data(conn, &iov, 1, ISCSI_HDR_LEN); in iscsit_get_rx_pdu()
4061 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_get_rx_pdu()
4065 if (conn->conn_ops->HeaderDigest) { in iscsit_get_rx_pdu()
4069 ret = rx_data(conn, &iov, 1, ISCSI_CRC_LEN); in iscsit_get_rx_pdu()
4071 iscsit_rx_thread_wait_for_tcp(conn); in iscsit_get_rx_pdu()
4075 iscsit_do_crypto_hash_buf(conn->conn_rx_hash, buffer, in iscsit_get_rx_pdu()
4088 atomic_long_inc(&conn->sess->conn_digest_errors); in iscsit_get_rx_pdu()
4095 if (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT) in iscsit_get_rx_pdu()
4100 if (conn->sess->sess_ops->SessionType && in iscsit_get_rx_pdu()
4105 iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, in iscsit_get_rx_pdu()
4110 ret = iscsi_target_rx_opcode(conn, buffer); in iscsit_get_rx_pdu()
4121 struct iscsit_conn *conn = arg; in iscsi_target_rx_thread() local
4133 rc = wait_for_completion_interruptible(&conn->rx_login_comp); in iscsi_target_rx_thread()
4134 if (rc < 0 || iscsi_target_check_conn_state(conn)) in iscsi_target_rx_thread()
4137 if (!conn->conn_transport->iscsit_get_rx_pdu) in iscsi_target_rx_thread()
4140 conn->conn_transport->iscsit_get_rx_pdu(conn); in iscsi_target_rx_thread()
4143 atomic_set(&conn->transport_failed, 1); in iscsi_target_rx_thread()
4144 iscsit_take_action_for_connection_exit(conn, &conn_freed); in iscsi_target_rx_thread()
4156 static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) in iscsit_release_commands_from_conn() argument
4160 struct iscsit_session *sess = conn->sess; in iscsit_release_commands_from_conn()
4166 spin_lock_bh(&conn->cmd_lock); in iscsit_release_commands_from_conn()
4167 list_splice_init(&conn->conn_cmd_list, &tmp_list); in iscsit_release_commands_from_conn()
4181 &conn->conn_cmd_list); in iscsit_release_commands_from_conn()
4188 spin_unlock_bh(&conn->cmd_lock); in iscsit_release_commands_from_conn()
4200 struct iscsit_conn *conn) in iscsit_stop_timers_for_cmds() argument
4204 spin_lock_bh(&conn->cmd_lock); in iscsit_stop_timers_for_cmds()
4205 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { in iscsit_stop_timers_for_cmds()
4209 spin_unlock_bh(&conn->cmd_lock); in iscsit_stop_timers_for_cmds()
4213 struct iscsit_conn *conn) in iscsit_close_connection() argument
4215 int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT); in iscsit_close_connection()
4216 struct iscsit_session *sess = conn->sess; in iscsit_close_connection()
4219 " %u\n", conn->cid, sess->sid); in iscsit_close_connection()
4231 if (!conn->conn_transport->rdma_shutdown) in iscsit_close_connection()
4232 complete(&conn->conn_logout_comp); in iscsit_close_connection()
4235 if (conn->tx_thread && in iscsit_close_connection()
4236 cmpxchg(&conn->tx_thread_active, true, false)) { in iscsit_close_connection()
4237 send_sig(SIGINT, conn->tx_thread, 1); in iscsit_close_connection()
4238 kthread_stop(conn->tx_thread); in iscsit_close_connection()
4241 if (conn->rx_thread && in iscsit_close_connection()
4242 cmpxchg(&conn->rx_thread_active, true, false)) { in iscsit_close_connection()
4243 send_sig(SIGINT, conn->rx_thread, 1); in iscsit_close_connection()
4244 kthread_stop(conn->rx_thread); in iscsit_close_connection()
4249 bitmap_release_region(iscsit_global->ts_bitmap, conn->bitmap_id, in iscsit_close_connection()
4253 iscsit_stop_timers_for_cmds(conn); in iscsit_close_connection()
4254 iscsit_stop_nopin_response_timer(conn); in iscsit_close_connection()
4255 iscsit_stop_nopin_timer(conn); in iscsit_close_connection()
4257 if (conn->conn_transport->iscsit_wait_conn) in iscsit_close_connection()
4258 conn->conn_transport->iscsit_wait_conn(conn); in iscsit_close_connection()
4269 if (atomic_read(&conn->connection_recovery)) { in iscsit_close_connection()
4270 iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(conn); in iscsit_close_connection()
4271 iscsit_prepare_cmds_for_reallegiance(conn); in iscsit_close_connection()
4273 iscsit_clear_ooo_cmdsns_for_conn(conn); in iscsit_close_connection()
4274 iscsit_release_commands_from_conn(conn); in iscsit_close_connection()
4276 iscsit_free_queue_reqs_for_conn(conn); in iscsit_close_connection()
4283 if (atomic_read(&conn->conn_logout_remove)) { in iscsit_close_connection()
4284 if (conn->conn_logout_reason == ISCSI_LOGOUT_REASON_CLOSE_SESSION) { in iscsit_close_connection()
4285 iscsit_dec_conn_usage_count(conn); in iscsit_close_connection()
4288 if (conn->conn_logout_reason == ISCSI_LOGOUT_REASON_CLOSE_CONNECTION) in iscsit_close_connection()
4289 iscsit_dec_conn_usage_count(conn); in iscsit_close_connection()
4291 atomic_set(&conn->conn_logout_remove, 0); in iscsit_close_connection()
4297 list_del(&conn->conn_list); in iscsit_close_connection()
4304 if (atomic_read(&conn->connection_recovery)) in iscsit_close_connection()
4305 iscsit_build_conn_drop_async_message(conn); in iscsit_close_connection()
4314 spin_lock_bh(&conn->state_lock); in iscsit_close_connection()
4315 if (atomic_read(&conn->sleep_on_conn_wait_comp)) { in iscsit_close_connection()
4316 spin_unlock_bh(&conn->state_lock); in iscsit_close_connection()
4317 complete(&conn->conn_wait_comp); in iscsit_close_connection()
4318 wait_for_completion(&conn->conn_post_wait_comp); in iscsit_close_connection()
4319 spin_lock_bh(&conn->state_lock); in iscsit_close_connection()
4328 if (atomic_read(&conn->connection_wait_rcfr)) { in iscsit_close_connection()
4329 spin_unlock_bh(&conn->state_lock); in iscsit_close_connection()
4330 complete(&conn->conn_wait_rcfr_comp); in iscsit_close_connection()
4331 wait_for_completion(&conn->conn_post_wait_comp); in iscsit_close_connection()
4332 spin_lock_bh(&conn->state_lock); in iscsit_close_connection()
4334 atomic_set(&conn->connection_reinstatement, 1); in iscsit_close_connection()
4335 spin_unlock_bh(&conn->state_lock); in iscsit_close_connection()
4341 iscsit_check_conn_usage_count(conn); in iscsit_close_connection()
4343 ahash_request_free(conn->conn_tx_hash); in iscsit_close_connection()
4344 if (conn->conn_rx_hash) { in iscsit_close_connection()
4347 tfm = crypto_ahash_reqtfm(conn->conn_rx_hash); in iscsit_close_connection()
4348 ahash_request_free(conn->conn_rx_hash); in iscsit_close_connection()
4352 if (conn->sock) in iscsit_close_connection()
4353 sock_release(conn->sock); in iscsit_close_connection()
4355 if (conn->conn_transport->iscsit_free_conn) in iscsit_close_connection()
4356 conn->conn_transport->iscsit_free_conn(conn); in iscsit_close_connection()
4359 conn->conn_state = TARG_CONN_STATE_FREE; in iscsit_close_connection()
4360 iscsit_free_conn(conn); in iscsit_close_connection()
4521 struct iscsit_conn *conn) in iscsit_logout_post_handler_closesession() argument
4523 struct iscsit_session *sess = conn->sess; in iscsit_logout_post_handler_closesession()
4534 if (!conn->conn_transport->rdma_shutdown) { in iscsit_logout_post_handler_closesession()
4535 sleep = cmpxchg(&conn->tx_thread_active, true, false); in iscsit_logout_post_handler_closesession()
4540 atomic_set(&conn->conn_logout_remove, 0); in iscsit_logout_post_handler_closesession()
4541 complete(&conn->conn_logout_comp); in iscsit_logout_post_handler_closesession()
4543 iscsit_dec_conn_usage_count(conn); in iscsit_logout_post_handler_closesession()
4550 struct iscsit_conn *conn) in iscsit_logout_post_handler_samecid() argument
4554 if (!conn->conn_transport->rdma_shutdown) { in iscsit_logout_post_handler_samecid()
4555 sleep = cmpxchg(&conn->tx_thread_active, true, false); in iscsit_logout_post_handler_samecid()
4560 atomic_set(&conn->conn_logout_remove, 0); in iscsit_logout_post_handler_samecid()
4561 complete(&conn->conn_logout_comp); in iscsit_logout_post_handler_samecid()
4563 iscsit_cause_connection_reinstatement(conn, sleep); in iscsit_logout_post_handler_samecid()
4564 iscsit_dec_conn_usage_count(conn); in iscsit_logout_post_handler_samecid()
4568 struct iscsit_conn *conn, in iscsit_logout_post_handler_diffcid() argument
4572 struct iscsit_session *sess = conn->sess; in iscsit_logout_post_handler_diffcid()
4608 struct iscsit_conn *conn) in iscsit_logout_post_handler() argument
4618 iscsit_logout_post_handler_closesession(conn); in iscsit_logout_post_handler()
4623 if (conn->cid == cmd->logout_cid) { in iscsit_logout_post_handler()
4628 iscsit_logout_post_handler_samecid(conn); in iscsit_logout_post_handler()
4634 iscsit_logout_post_handler_diffcid(conn, in iscsit_logout_post_handler()
4666 struct iscsit_conn *conn; in iscsit_fail_session() local
4669 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) { in iscsit_fail_session()
4671 conn->conn_state = TARG_CONN_STATE_CLEANUP_WAIT; in iscsit_fail_session()
4685 struct iscsit_conn *conn, *conn_tmp = NULL; in iscsit_stop_session() local
4691 list_for_each_entry_safe(conn, conn_tmp, &sess->sess_conn_list, in iscsit_stop_session()
4696 if (list_is_last(&conn->conn_list, &sess->sess_conn_list)) { in iscsit_stop_session()
4702 iscsit_inc_conn_usage_count(conn); in iscsit_stop_session()
4705 iscsit_cause_connection_reinstatement(conn, 1); in iscsit_stop_session()
4708 iscsit_dec_conn_usage_count(conn); in iscsit_stop_session()
4714 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) in iscsit_stop_session()
4715 iscsit_cause_connection_reinstatement(conn, 0); in iscsit_stop_session()