Lines Matching refs:conn
38 static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn) in iscsi_login_init_conn() argument
47 conn->login = login; in iscsi_login_init_conn()
48 login->conn = conn; in iscsi_login_init_conn()
63 conn->conn_login = login; in iscsi_login_init_conn()
78 int iscsi_login_setup_crypto(struct iscsi_conn *conn) in iscsi_login_setup_crypto() argument
93 conn->conn_rx_hash = ahash_request_alloc(tfm, GFP_KERNEL); in iscsi_login_setup_crypto()
94 if (!conn->conn_rx_hash) { in iscsi_login_setup_crypto()
99 ahash_request_set_callback(conn->conn_rx_hash, 0, NULL, NULL); in iscsi_login_setup_crypto()
101 conn->conn_tx_hash = ahash_request_alloc(tfm, GFP_KERNEL); in iscsi_login_setup_crypto()
102 if (!conn->conn_tx_hash) { in iscsi_login_setup_crypto()
104 ahash_request_free(conn->conn_rx_hash); in iscsi_login_setup_crypto()
105 conn->conn_rx_hash = NULL; in iscsi_login_setup_crypto()
109 ahash_request_set_callback(conn->conn_tx_hash, 0, NULL, NULL); in iscsi_login_setup_crypto()
115 struct iscsi_conn *conn, in iscsi_login_check_initiator_version() argument
123 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, in iscsi_login_check_initiator_version()
131 int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) in iscsi_check_for_session_reinstatement() argument
135 struct iscsi_portal_group *tpg = conn->tpg; in iscsi_check_for_session_reinstatement()
141 INITIATORNAME, conn->param_list); in iscsi_check_for_session_reinstatement()
143 SESSIONTYPE, conn->param_list); in iscsi_check_for_session_reinstatement()
145 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, in iscsi_check_for_session_reinstatement()
165 if (!memcmp(sess_p->isid, conn->sess->isid, 6) && in iscsi_check_for_session_reinstatement()
208 struct iscsi_conn *conn, in iscsi_login_set_conn_values() argument
212 conn->sess = sess; in iscsi_login_set_conn_values()
213 conn->cid = be16_to_cpu(cid); in iscsi_login_set_conn_values()
218 ret = get_random_bytes_wait(&conn->stat_sn, sizeof(u32)); in iscsi_login_set_conn_values()
223 conn->auth_id = iscsit_global->auth_id++; in iscsi_login_set_conn_values()
229 struct iscsi_conn *conn, in iscsi_change_param_sprintf() argument
241 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { in iscsi_change_param_sprintf()
242 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_change_param_sprintf()
256 struct iscsi_conn *conn, in iscsi_login_zero_tsih_s1() argument
265 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s1()
271 if (iscsi_login_set_conn_values(sess, conn, pdu->cid)) in iscsi_login_zero_tsih_s1()
298 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s1()
313 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s1()
322 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s1()
335 conn->sess = NULL; in iscsi_login_zero_tsih_s1()
340 struct iscsi_conn *conn) in iscsi_login_zero_tsih_s2() argument
343 struct iscsi_session *sess = conn->sess; in iscsi_login_zero_tsih_s2()
346 sess->tpg = conn->tpg; in iscsi_login_zero_tsih_s2()
359 if (iscsi_copy_param_list(&conn->param_list, in iscsi_login_zero_tsih_s2()
360 conn->tpg->param_list, 1) < 0) { in iscsi_login_zero_tsih_s2()
361 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s2()
366 if (conn->conn_transport->transport_type == ISCSI_INFINIBAND) in iscsi_login_zero_tsih_s2()
369 iscsi_set_keys_to_negotiate(conn->param_list, iser); in iscsi_login_zero_tsih_s2()
373 conn->param_list); in iscsi_login_zero_tsih_s2()
384 if (iscsi_change_param_sprintf(conn, "TargetPortalGroupTag=%hu", sess->tpg->tpgt)) in iscsi_login_zero_tsih_s2()
392 if (iscsi_change_param_sprintf(conn, "ErrorRecoveryLevel=%d", na->default_erl)) in iscsi_login_zero_tsih_s2()
403 if (iscsi_change_param_sprintf(conn, "RDMAExtensions=Yes")) in iscsi_login_zero_tsih_s2()
411 conn->param_list); in iscsi_login_zero_tsih_s2()
413 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s2()
419 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_zero_tsih_s2()
435 if (iscsi_change_param_sprintf(conn, "MaxRecvDataSegmentLength=%lu\n", mrdsl)) in iscsi_login_zero_tsih_s2()
446 if (iscsi_change_param_sprintf(conn, "ImmediateData=No")) in iscsi_login_zero_tsih_s2()
449 if (iscsi_change_param_sprintf(conn, "InitialR2T=Yes")) in iscsi_login_zero_tsih_s2()
461 struct iscsi_conn *conn, in iscsi_login_non_zero_tsih_s1() argument
466 return iscsi_login_set_conn_values(NULL, conn, pdu->cid); in iscsi_login_non_zero_tsih_s1()
473 struct iscsi_conn *conn, in iscsi_login_non_zero_tsih_s2() argument
476 struct iscsi_portal_group *tpg = conn->tpg; in iscsi_login_non_zero_tsih_s2()
509 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, in iscsi_login_non_zero_tsih_s2()
523 if (iscsi_login_set_conn_values(sess, conn, pdu->cid) < 0 || in iscsi_login_non_zero_tsih_s2()
524 iscsi_copy_param_list(&conn->param_list, in iscsi_login_non_zero_tsih_s2()
525 conn->tpg->param_list, 0) < 0) { in iscsi_login_non_zero_tsih_s2()
526 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in iscsi_login_non_zero_tsih_s2()
531 if (conn->conn_transport->transport_type == ISCSI_INFINIBAND) in iscsi_login_non_zero_tsih_s2()
534 iscsi_set_keys_to_negotiate(conn->param_list, iser); in iscsi_login_non_zero_tsih_s2()
542 if (iscsi_change_param_sprintf(conn, "TargetPortalGroupTag=%hu", sess->tpg->tpgt)) in iscsi_login_non_zero_tsih_s2()
549 struct iscsi_conn *conn, in iscsi_login_post_auth_non_zero_tsih() argument
555 struct iscsi_session *sess = conn->sess; in iscsi_login_post_auth_non_zero_tsih()
589 conn->cid); in iscsi_login_post_auth_non_zero_tsih()
607 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, in iscsi_login_post_auth_non_zero_tsih()
615 static void iscsi_post_login_start_timers(struct iscsi_conn *conn) in iscsi_post_login_start_timers() argument
617 struct iscsi_session *sess = conn->sess; in iscsi_post_login_start_timers()
621 if (conn->conn_transport->transport_type == ISCSI_INFINIBAND) in iscsi_post_login_start_timers()
625 iscsit_start_nopin_timer(conn); in iscsi_post_login_start_timers()
628 int iscsit_start_kthreads(struct iscsi_conn *conn) in iscsit_start_kthreads() argument
633 conn->bitmap_id = bitmap_find_free_region(iscsit_global->ts_bitmap, in iscsit_start_kthreads()
637 if (conn->bitmap_id < 0) { in iscsit_start_kthreads()
643 conn->tx_thread = kthread_run(iscsi_target_tx_thread, conn, in iscsit_start_kthreads()
645 if (IS_ERR(conn->tx_thread)) { in iscsit_start_kthreads()
647 ret = PTR_ERR(conn->tx_thread); in iscsit_start_kthreads()
650 conn->tx_thread_active = true; in iscsit_start_kthreads()
652 conn->rx_thread = kthread_run(iscsi_target_rx_thread, conn, in iscsit_start_kthreads()
654 if (IS_ERR(conn->rx_thread)) { in iscsit_start_kthreads()
656 ret = PTR_ERR(conn->rx_thread); in iscsit_start_kthreads()
659 conn->rx_thread_active = true; in iscsit_start_kthreads()
663 send_sig(SIGINT, conn->tx_thread, 1); in iscsit_start_kthreads()
664 kthread_stop(conn->tx_thread); in iscsit_start_kthreads()
665 conn->tx_thread_active = false; in iscsit_start_kthreads()
668 bitmap_release_region(iscsit_global->ts_bitmap, conn->bitmap_id, in iscsit_start_kthreads()
676 struct iscsi_conn *conn, in iscsi_post_login_handler() argument
680 struct iscsi_session *sess = conn->sess; in iscsi_post_login_handler()
685 iscsit_inc_conn_usage_count(conn); in iscsi_post_login_handler()
687 iscsit_collect_login_stats(conn, ISCSI_STATUS_CLS_SUCCESS, in iscsi_post_login_handler()
691 conn->conn_state = TARG_CONN_STATE_LOGGED_IN; in iscsi_post_login_handler()
693 iscsi_set_connection_parameters(conn->conn_ops, conn->param_list); in iscsi_post_login_handler()
699 conn->param_list, 0); in iscsi_post_login_handler()
700 iscsi_release_param_list(conn->param_list); in iscsi_post_login_handler()
701 conn->param_list = NULL; in iscsi_post_login_handler()
713 " %pISpc,%hu\n", conn->cid, &conn->login_sockaddr, in iscsi_post_login_handler()
714 &conn->local_sockaddr, tpg->tpgt); in iscsi_post_login_handler()
716 list_add_tail(&conn->conn_list, &sess->sess_conn_list); in iscsi_post_login_handler()
723 iscsi_post_login_start_timers(conn); in iscsi_post_login_handler()
728 iscsit_thread_get_cpumask(conn); in iscsi_post_login_handler()
729 conn->conn_rx_reset_cpumask = 1; in iscsi_post_login_handler()
730 conn->conn_tx_reset_cpumask = 1; in iscsi_post_login_handler()
735 complete(&conn->rx_login_comp); in iscsi_post_login_handler()
736 iscsit_dec_conn_usage_count(conn); in iscsi_post_login_handler()
747 iscsi_set_session_parameters(sess->sess_ops, conn->param_list, 1); in iscsi_post_login_handler()
748 iscsi_release_param_list(conn->param_list); in iscsi_post_login_handler()
749 conn->param_list = NULL; in iscsi_post_login_handler()
760 conn->cid, &conn->login_sockaddr, &conn->local_sockaddr, in iscsi_post_login_handler()
764 list_add_tail(&conn->conn_list, &sess->sess_conn_list); in iscsi_post_login_handler()
785 iscsi_post_login_start_timers(conn); in iscsi_post_login_handler()
790 iscsit_thread_get_cpumask(conn); in iscsi_post_login_handler()
791 conn->conn_rx_reset_cpumask = 1; in iscsi_post_login_handler()
792 conn->conn_tx_reset_cpumask = 1; in iscsi_post_login_handler()
797 complete(&conn->rx_login_comp); in iscsi_post_login_handler()
798 iscsit_dec_conn_usage_count(conn); in iscsi_post_login_handler()
947 int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) in iscsit_accept_np() argument
958 conn->sock = new_sock; in iscsit_accept_np()
959 conn->login_family = np->np_sockaddr.ss_family; in iscsit_accept_np()
964 rc = conn->sock->ops->getname(conn->sock, in iscsit_accept_np()
968 memcpy(&conn->login_sockaddr, &sock_in6, sizeof(sock_in6)); in iscsit_accept_np()
974 memcpy(&conn->login_sockaddr, &sock_in, sizeof(sock_in)); in iscsit_accept_np()
978 rc = conn->sock->ops->getname(conn->sock, in iscsit_accept_np()
982 memcpy(&conn->local_sockaddr, &sock_in6, sizeof(sock_in6)); in iscsit_accept_np()
988 memcpy(&conn->local_sockaddr, &sock_in, sizeof(sock_in)); in iscsit_accept_np()
994 rc = conn->sock->ops->getname(conn->sock, in iscsit_accept_np()
997 memcpy(&conn->login_sockaddr, &sock_in, sizeof(sock_in)); in iscsit_accept_np()
999 rc = conn->sock->ops->getname(conn->sock, in iscsit_accept_np()
1002 memcpy(&conn->local_sockaddr, &sock_in, sizeof(sock_in)); in iscsit_accept_np()
1008 int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) in iscsit_get_login_rx() argument
1013 if (iscsi_login_rx_data(conn, login->req, ISCSI_HDR_LEN) < 0) in iscsit_get_login_rx()
1042 if (iscsi_target_check_login_request(conn, login) < 0) in iscsit_get_login_rx()
1046 if (iscsi_login_rx_data(conn, login->req_buf, in iscsit_get_login_rx()
1053 int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, in iscsit_put_login_tx() argument
1056 if (iscsi_login_tx_data(conn, login->rsp, login->rsp_buf, length) < 0) in iscsit_put_login_tx()
1063 iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) in iscsit_conn_set_transport() argument
1068 conn->conn_transport = t; in iscsit_conn_set_transport()
1078 conn->conn_transport = t; in iscsit_conn_set_transport()
1084 struct iscsi_conn *conn; in iscsit_alloc_conn() local
1086 conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); in iscsit_alloc_conn()
1087 if (!conn) { in iscsit_alloc_conn()
1092 conn->conn_state = TARG_CONN_STATE_FREE; in iscsit_alloc_conn()
1094 init_waitqueue_head(&conn->queues_wq); in iscsit_alloc_conn()
1095 INIT_LIST_HEAD(&conn->conn_list); in iscsit_alloc_conn()
1096 INIT_LIST_HEAD(&conn->conn_cmd_list); in iscsit_alloc_conn()
1097 INIT_LIST_HEAD(&conn->immed_queue_list); in iscsit_alloc_conn()
1098 INIT_LIST_HEAD(&conn->response_queue_list); in iscsit_alloc_conn()
1099 init_completion(&conn->conn_post_wait_comp); in iscsit_alloc_conn()
1100 init_completion(&conn->conn_wait_comp); in iscsit_alloc_conn()
1101 init_completion(&conn->conn_wait_rcfr_comp); in iscsit_alloc_conn()
1102 init_completion(&conn->conn_waiting_on_uc_comp); in iscsit_alloc_conn()
1103 init_completion(&conn->conn_logout_comp); in iscsit_alloc_conn()
1104 init_completion(&conn->rx_half_close_comp); in iscsit_alloc_conn()
1105 init_completion(&conn->tx_half_close_comp); in iscsit_alloc_conn()
1106 init_completion(&conn->rx_login_comp); in iscsit_alloc_conn()
1107 spin_lock_init(&conn->cmd_lock); in iscsit_alloc_conn()
1108 spin_lock_init(&conn->conn_usage_lock); in iscsit_alloc_conn()
1109 spin_lock_init(&conn->immed_queue_lock); in iscsit_alloc_conn()
1110 spin_lock_init(&conn->nopin_timer_lock); in iscsit_alloc_conn()
1111 spin_lock_init(&conn->response_queue_lock); in iscsit_alloc_conn()
1112 spin_lock_init(&conn->state_lock); in iscsit_alloc_conn()
1114 timer_setup(&conn->nopin_response_timer, in iscsit_alloc_conn()
1116 timer_setup(&conn->nopin_timer, iscsit_handle_nopin_timeout, 0); in iscsit_alloc_conn()
1118 if (iscsit_conn_set_transport(conn, np->np_transport) < 0) in iscsit_alloc_conn()
1121 conn->conn_ops = kzalloc(sizeof(struct iscsi_conn_ops), GFP_KERNEL); in iscsit_alloc_conn()
1122 if (!conn->conn_ops) { in iscsit_alloc_conn()
1127 if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) { in iscsit_alloc_conn()
1132 return conn; in iscsit_alloc_conn()
1135 kfree(conn->conn_ops); in iscsit_alloc_conn()
1137 iscsit_put_transport(conn->conn_transport); in iscsit_alloc_conn()
1139 kfree(conn); in iscsit_alloc_conn()
1143 void iscsit_free_conn(struct iscsi_conn *conn) in iscsit_free_conn() argument
1145 free_cpumask_var(conn->conn_cpumask); in iscsit_free_conn()
1146 kfree(conn->conn_ops); in iscsit_free_conn()
1147 iscsit_put_transport(conn->conn_transport); in iscsit_free_conn()
1148 kfree(conn); in iscsit_free_conn()
1151 void iscsi_target_login_sess_out(struct iscsi_conn *conn, in iscsi_target_login_sess_out() argument
1158 iscsit_collect_login_stats(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, in iscsi_target_login_sess_out()
1160 if (!zero_tsih || !conn->sess) in iscsi_target_login_sess_out()
1163 transport_free_session(conn->sess->se_sess); in iscsi_target_login_sess_out()
1164 ida_free(&sess_ida, conn->sess->session_index); in iscsi_target_login_sess_out()
1165 kfree(conn->sess->sess_ops); in iscsi_target_login_sess_out()
1166 kfree(conn->sess); in iscsi_target_login_sess_out()
1167 conn->sess = NULL; in iscsi_target_login_sess_out()
1174 if (!zero_tsih && conn->sess) { in iscsi_target_login_sess_out()
1175 spin_lock_bh(&conn->sess->conn_lock); in iscsi_target_login_sess_out()
1176 if (conn->sess->session_state == TARG_SESS_STATE_FAILED) { in iscsi_target_login_sess_out()
1178 &conn->tpg->tpg_se_tpg; in iscsi_target_login_sess_out()
1180 atomic_set(&conn->sess->session_continuation, 0); in iscsi_target_login_sess_out()
1181 spin_unlock_bh(&conn->sess->conn_lock); in iscsi_target_login_sess_out()
1183 iscsit_start_time2retain_handler(conn->sess); in iscsi_target_login_sess_out()
1186 spin_unlock_bh(&conn->sess->conn_lock); in iscsi_target_login_sess_out()
1187 iscsit_dec_session_usage_count(conn->sess); in iscsi_target_login_sess_out()
1190 ahash_request_free(conn->conn_tx_hash); in iscsi_target_login_sess_out()
1191 if (conn->conn_rx_hash) { in iscsi_target_login_sess_out()
1194 tfm = crypto_ahash_reqtfm(conn->conn_rx_hash); in iscsi_target_login_sess_out()
1195 ahash_request_free(conn->conn_rx_hash); in iscsi_target_login_sess_out()
1199 if (conn->param_list) { in iscsi_target_login_sess_out()
1200 iscsi_release_param_list(conn->param_list); in iscsi_target_login_sess_out()
1201 conn->param_list = NULL; in iscsi_target_login_sess_out()
1203 iscsi_target_nego_release(conn); in iscsi_target_login_sess_out()
1205 if (conn->sock) { in iscsi_target_login_sess_out()
1206 sock_release(conn->sock); in iscsi_target_login_sess_out()
1207 conn->sock = NULL; in iscsi_target_login_sess_out()
1210 if (conn->conn_transport->iscsit_wait_conn) in iscsi_target_login_sess_out()
1211 conn->conn_transport->iscsit_wait_conn(conn); in iscsi_target_login_sess_out()
1213 if (conn->conn_transport->iscsit_free_conn) in iscsi_target_login_sess_out()
1214 conn->conn_transport->iscsit_free_conn(conn); in iscsi_target_login_sess_out()
1216 iscsit_free_conn(conn); in iscsi_target_login_sess_out()
1223 struct iscsi_conn *conn = NULL; in __iscsi_target_login_thread() local
1246 conn = iscsit_alloc_conn(np); in __iscsi_target_login_thread()
1247 if (!conn) { in __iscsi_target_login_thread()
1252 rc = np->np_transport->iscsit_accept_np(np, conn); in __iscsi_target_login_thread()
1255 iscsit_free_conn(conn); in __iscsi_target_login_thread()
1263 iscsit_free_conn(conn); in __iscsi_target_login_thread()
1268 iscsit_free_conn(conn); in __iscsi_target_login_thread()
1274 login = iscsi_login_init_conn(conn); in __iscsi_target_login_thread()
1282 conn->conn_state = TARG_CONN_STATE_XPT_UP; in __iscsi_target_login_thread()
1286 rc = np->np_transport->iscsit_get_login_rx(conn, login); in __iscsi_target_login_thread()
1298 conn->login_itt = pdu->itt; in __iscsi_target_login_thread()
1305 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, in __iscsi_target_login_thread()
1311 conn->network_transport = np->np_network_transport; in __iscsi_target_login_thread()
1314 " Portal %pISpc\n", &conn->login_sockaddr, np->np_transport->name, in __iscsi_target_login_thread()
1315 &conn->local_sockaddr); in __iscsi_target_login_thread()
1318 conn->conn_state = TARG_CONN_STATE_IN_LOGIN; in __iscsi_target_login_thread()
1320 if (iscsi_login_check_initiator_version(conn, pdu->max_version, in __iscsi_target_login_thread()
1331 if (iscsi_login_zero_tsih_s1(conn, buffer) < 0) in __iscsi_target_login_thread()
1341 if (iscsi_login_non_zero_tsih_s1(conn, buffer) < 0) in __iscsi_target_login_thread()
1353 rc = iscsi_target_locate_portal(np, conn, login); in __iscsi_target_login_thread()
1355 tpg = conn->tpg; in __iscsi_target_login_thread()
1360 if (conn->sess) in __iscsi_target_login_thread()
1361 conn->sess->se_sess->sup_prot_ops = in __iscsi_target_login_thread()
1362 conn->conn_transport->iscsit_get_sup_prot_ops(conn); in __iscsi_target_login_thread()
1364 tpg = conn->tpg; in __iscsi_target_login_thread()
1371 if (iscsi_login_zero_tsih_s2(conn) < 0) in __iscsi_target_login_thread()
1374 if (iscsi_login_non_zero_tsih_s2(conn, buffer) < 0) in __iscsi_target_login_thread()
1378 if (conn->conn_transport->iscsit_validate_params) { in __iscsi_target_login_thread()
1379 ret = conn->conn_transport->iscsit_validate_params(conn); in __iscsi_target_login_thread()
1388 ret = iscsi_target_start_negotiation(login, conn); in __iscsi_target_login_thread()
1395 tpg_np = conn->tpg_np; in __iscsi_target_login_thread()
1397 iscsi_post_login_handler(np, conn, zero_tsih); in __iscsi_target_login_thread()
1410 tpg_np = conn->tpg_np; in __iscsi_target_login_thread()
1411 iscsi_target_login_sess_out(conn, zero_tsih, new_sess); in __iscsi_target_login_thread()