Lines Matching refs:conn
88 inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn) in iscsi_conn_queue_xmit() argument
90 struct Scsi_Host *shost = conn->session->host; in iscsi_conn_queue_xmit()
94 queue_work(ihost->workq, &conn->xmitwork); in iscsi_conn_queue_xmit()
98 inline void iscsi_conn_queue_recv(struct iscsi_conn *conn) in iscsi_conn_queue_recv() argument
100 struct Scsi_Host *shost = conn->session->host; in iscsi_conn_queue_recv()
103 if (ihost->workq && !test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags)) in iscsi_conn_queue_recv()
104 queue_work(ihost->workq, &conn->recvwork); in iscsi_conn_queue_recv()
149 struct iscsi_conn *conn = task->conn; in iscsi_prep_data_out_pdu() local
163 if (left > conn->max_xmit_dlength) { in iscsi_prep_data_out_pdu()
164 hton24(hdr->dlength, conn->max_xmit_dlength); in iscsi_prep_data_out_pdu()
165 r2t->data_count = conn->max_xmit_dlength; in iscsi_prep_data_out_pdu()
172 conn->dataout_pdus_cnt++; in iscsi_prep_data_out_pdu()
222 ISCSI_DBG_SESSION(task->conn->session, in iscsi_prep_ecdb_ahs()
245 struct iscsi_session *session = task->conn->session; in iscsi_check_tmf_restrictions()
316 struct iscsi_conn *conn = task->conn; in iscsi_prep_scsi_cmd_pdu() local
317 struct iscsi_session *session = conn->session; in iscsi_prep_scsi_cmd_pdu()
328 if (conn->session->tt->alloc_pdu) { in iscsi_prep_scsi_cmd_pdu()
329 rc = conn->session->tt->alloc_pdu(task, ISCSI_OP_SCSI_CMD); in iscsi_prep_scsi_cmd_pdu()
341 task->conn->session->age); in iscsi_prep_scsi_cmd_pdu()
350 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); in iscsi_prep_scsi_cmd_pdu()
391 conn->max_xmit_dlength); in iscsi_prep_scsi_cmd_pdu()
394 conn->max_xmit_dlength); in iscsi_prep_scsi_cmd_pdu()
405 r2t->exp_statsn = cpu_to_be32(conn->exp_statsn); in iscsi_prep_scsi_cmd_pdu()
435 conn->scsicmd_pdus_cnt++; in iscsi_prep_scsi_cmd_pdu()
439 "write" : "read", conn->id, sc, sc->cmnd[0], in iscsi_prep_scsi_cmd_pdu()
456 struct iscsi_conn *conn = task->conn; in iscsi_free_task() local
457 struct iscsi_session *session = conn->session; in iscsi_free_task()
470 if (conn->login_task == task) in iscsi_free_task()
508 struct iscsi_session *session = task->conn->session; in iscsi_put_task()
527 struct iscsi_conn *conn = task->conn; in iscsi_complete_task() local
529 ISCSI_DBG_SESSION(conn->session, in iscsi_complete_task()
540 if (READ_ONCE(conn->ping_task) == task) in iscsi_complete_task()
541 WRITE_ONCE(conn->ping_task, NULL); in iscsi_complete_task()
561 struct iscsi_conn *conn = task->conn; in iscsi_complete_scsi_task() local
563 ISCSI_DBG_SESSION(conn->session, "[itt 0x%x]\n", task->itt); in iscsi_complete_scsi_task()
565 conn->last_recv = jiffies; in iscsi_complete_scsi_task()
566 __iscsi_update_cmdsn(conn->session, exp_cmdsn, max_cmdsn); in iscsi_complete_scsi_task()
576 struct iscsi_conn *conn = task->conn; in cleanup_queued_task() local
598 if (conn->session->running_aborted_task == task) { in cleanup_queued_task()
599 conn->session->running_aborted_task = NULL; in cleanup_queued_task()
603 if (conn->task == task) { in cleanup_queued_task()
604 conn->task = NULL; in cleanup_queued_task()
617 struct iscsi_conn *conn = task->conn; in __fail_scsi_task() local
629 conn->session->queued_cmdsn--; in __fail_scsi_task()
645 struct iscsi_session *session = task->conn->session; in fail_scsi_task()
652 static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, in iscsi_prep_mgmt_task() argument
655 struct iscsi_session *session = conn->session; in iscsi_prep_mgmt_task()
660 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) in iscsi_prep_mgmt_task()
664 nop->exp_statsn = cpu_to_be32(conn->exp_statsn); in iscsi_prep_mgmt_task()
678 if (conn->c_stage == ISCSI_CONN_STARTED && in iscsi_prep_mgmt_task()
706 iscsi_alloc_mgmt_task(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in iscsi_alloc_mgmt_task() argument
709 struct iscsi_session *session = conn->session; in iscsi_alloc_mgmt_task()
715 !test_bit(ISCSI_CONN_FLAG_BOUND, &conn->flags)) in iscsi_alloc_mgmt_task()
725 if (conn->login_task->state != ISCSI_TASK_FREE) { in iscsi_alloc_mgmt_task()
726 iscsi_conn_printk(KERN_ERR, conn, "Login/Text in " in iscsi_alloc_mgmt_task()
732 …iscsi_conn_printk(KERN_ERR, conn, "Invalid buffer len of %u for login task. Max len is %u\n", data… in iscsi_alloc_mgmt_task()
736 task = conn->login_task; in iscsi_alloc_mgmt_task()
742 …iscsi_conn_printk(KERN_ERR, conn, "Can not send data buffer of len %u for op 0x%x\n", data_size, o… in iscsi_alloc_mgmt_task()
746 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); in iscsi_alloc_mgmt_task()
747 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); in iscsi_alloc_mgmt_task()
759 task->conn = conn; in iscsi_alloc_mgmt_task()
770 if (conn->session->tt->alloc_pdu) { in iscsi_alloc_mgmt_task()
771 if (conn->session->tt->alloc_pdu(task, hdr->opcode)) { in iscsi_alloc_mgmt_task()
772 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate " in iscsi_alloc_mgmt_task()
787 task->conn->session->age); in iscsi_alloc_mgmt_task()
806 struct iscsi_conn *conn = task->conn; in iscsi_send_mgmt_task() local
807 struct iscsi_session *session = conn->session; in iscsi_send_mgmt_task()
808 struct iscsi_host *ihost = shost_priv(conn->session->host); in iscsi_send_mgmt_task()
812 rc = iscsi_prep_mgmt_task(conn, task); in iscsi_send_mgmt_task()
820 list_add_tail(&task->running, &conn->mgmtqueue); in iscsi_send_mgmt_task()
821 iscsi_conn_queue_xmit(conn); in iscsi_send_mgmt_task()
827 static int __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in __iscsi_conn_send_pdu() argument
833 task = iscsi_alloc_mgmt_task(conn, hdr, data, data_size); in __iscsi_conn_send_pdu()
846 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_conn_send_pdu() local
847 struct iscsi_session *session = conn->session; in iscsi_conn_send_pdu()
851 if (__iscsi_conn_send_pdu(conn, hdr, data, data_size)) in iscsi_conn_send_pdu()
869 static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in iscsi_scsi_cmd_rsp() argument
874 struct iscsi_session *session = conn->session; in iscsi_scsi_cmd_rsp()
878 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; in iscsi_scsi_cmd_rsp()
913 iscsi_conn_printk(KERN_ERR, conn, in iscsi_scsi_cmd_rsp()
951 conn->scsirsp_pdus_cnt++; in iscsi_scsi_cmd_rsp()
965 iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in iscsi_data_in_rsp() argument
974 iscsi_update_cmdsn(conn->session, (struct iscsi_nopin *)hdr); in iscsi_data_in_rsp()
976 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; in iscsi_data_in_rsp()
989 ISCSI_DBG_SESSION(conn->session, "data in with status done " in iscsi_data_in_rsp()
992 conn->scsirsp_pdus_cnt++; in iscsi_data_in_rsp()
996 static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) in iscsi_tmf_rsp() argument
999 struct iscsi_session *session = conn->session; in iscsi_tmf_rsp()
1001 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; in iscsi_tmf_rsp()
1002 conn->tmfrsp_pdus_cnt++; in iscsi_tmf_rsp()
1016 static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) in iscsi_send_nopout() argument
1022 if (READ_ONCE(conn->ping_task)) in iscsi_send_nopout()
1037 task = iscsi_alloc_mgmt_task(conn, (struct iscsi_hdr *)&hdr, NULL, 0); in iscsi_send_nopout()
1042 WRITE_ONCE(conn->ping_task, task); in iscsi_send_nopout()
1046 WRITE_ONCE(conn->ping_task, NULL); in iscsi_send_nopout()
1049 iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n"); in iscsi_send_nopout()
1053 conn->last_ping = jiffies; in iscsi_send_nopout()
1072 struct iscsi_conn *conn = task->conn; in iscsi_nop_out_rsp() local
1075 if (READ_ONCE(conn->ping_task) != task) { in iscsi_nop_out_rsp()
1080 if (iscsi_recv_pdu(conn->cls_conn, (struct iscsi_hdr *)nop, in iscsi_nop_out_rsp()
1084 mod_timer(&conn->transport_timer, jiffies + conn->recv_timeout); in iscsi_nop_out_rsp()
1089 static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in iscsi_handle_reject() argument
1096 conn->exp_statsn = be32_to_cpu(reject->statsn) + 1; in iscsi_handle_reject()
1100 iscsi_conn_printk(KERN_ERR, conn, "Cannot handle rejected " in iscsi_handle_reject()
1111 iscsi_conn_printk(KERN_ERR, conn, in iscsi_handle_reject()
1117 iscsi_conn_printk(KERN_ERR, conn, in iscsi_handle_reject()
1138 spin_unlock(&conn->session->back_lock); in iscsi_handle_reject()
1139 spin_lock(&conn->session->frwd_lock); in iscsi_handle_reject()
1140 iscsi_send_nopout(conn, in iscsi_handle_reject()
1142 spin_unlock(&conn->session->frwd_lock); in iscsi_handle_reject()
1143 spin_lock(&conn->session->back_lock); in iscsi_handle_reject()
1150 task = iscsi_itt_to_task(conn, rejected_pdu.itt); in iscsi_handle_reject()
1152 iscsi_conn_printk(KERN_ERR, conn, in iscsi_handle_reject()
1163 iscsi_conn_printk(KERN_ERR, conn, in iscsi_handle_reject()
1182 struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) in iscsi_itt_to_task() argument
1184 struct iscsi_session *session = conn->session; in iscsi_itt_to_task()
1191 session->tt->parse_pdu_itt(conn, itt, &i, NULL); in iscsi_itt_to_task()
1212 int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in __iscsi_complete_pdu() argument
1215 struct iscsi_session *session = conn->session; in __iscsi_complete_pdu()
1220 conn->last_recv = jiffies; in __iscsi_complete_pdu()
1221 rc = iscsi_verify_itt(conn, hdr->itt); in __iscsi_complete_pdu()
1231 opcode, conn->id, itt, datalen); in __iscsi_complete_pdu()
1249 iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr); in __iscsi_complete_pdu()
1254 rc = iscsi_handle_reject(conn, hdr, data, datalen); in __iscsi_complete_pdu()
1257 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; in __iscsi_complete_pdu()
1258 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen)) in __iscsi_complete_pdu()
1271 task = iscsi_itt_to_ctask(conn, hdr->itt); in __iscsi_complete_pdu()
1286 task = iscsi_itt_to_task(conn, hdr->itt); in __iscsi_complete_pdu()
1296 iscsi_scsi_cmd_rsp(conn, hdr, task, data, datalen); in __iscsi_complete_pdu()
1299 iscsi_data_in_rsp(conn, hdr, task); in __iscsi_complete_pdu()
1307 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; in __iscsi_complete_pdu()
1324 iscsi_tmf_rsp(conn, hdr); in __iscsi_complete_pdu()
1333 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; in __iscsi_complete_pdu()
1346 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen)) in __iscsi_complete_pdu()
1353 int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, in iscsi_complete_pdu() argument
1358 spin_lock(&conn->session->back_lock); in iscsi_complete_pdu()
1359 rc = __iscsi_complete_pdu(conn, hdr, data, datalen); in iscsi_complete_pdu()
1360 spin_unlock(&conn->session->back_lock); in iscsi_complete_pdu()
1365 int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) in iscsi_verify_itt() argument
1367 struct iscsi_session *session = conn->session; in iscsi_verify_itt()
1374 session->tt->parse_pdu_itt(conn, itt, &i, &age); in iscsi_verify_itt()
1381 iscsi_conn_printk(KERN_ERR, conn, in iscsi_verify_itt()
1388 iscsi_conn_printk(KERN_ERR, conn, in iscsi_verify_itt()
1406 struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) in iscsi_itt_to_ctask() argument
1410 if (iscsi_verify_itt(conn, itt)) in iscsi_itt_to_ctask()
1413 task = iscsi_itt_to_task(conn, itt); in iscsi_itt_to_ctask()
1417 if (iscsi_cmd(task->sc)->age != conn->session->age) { in iscsi_itt_to_ctask()
1418 iscsi_session_printk(KERN_ERR, conn->session, in iscsi_itt_to_ctask()
1420 iscsi_cmd(task->sc)->age, conn->session->age); in iscsi_itt_to_ctask()
1431 struct iscsi_conn *conn; in iscsi_session_failure() local
1434 conn = session->leadconn; in iscsi_session_failure()
1435 if (session->state == ISCSI_STATE_TERMINATE || !conn) { in iscsi_session_failure()
1440 iscsi_get_conn(conn->cls_conn); in iscsi_session_failure()
1448 iscsi_conn_error_event(conn->cls_conn, err); in iscsi_session_failure()
1450 iscsi_conn_failure(conn, err); in iscsi_session_failure()
1451 iscsi_put_conn(conn->cls_conn); in iscsi_session_failure()
1455 static bool iscsi_set_conn_failed(struct iscsi_conn *conn) in iscsi_set_conn_failed() argument
1457 struct iscsi_session *session = conn->session; in iscsi_set_conn_failed()
1462 if (conn->stop_stage == 0) in iscsi_set_conn_failed()
1465 set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); in iscsi_set_conn_failed()
1466 set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags); in iscsi_set_conn_failed()
1470 void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) in iscsi_conn_failure() argument
1472 struct iscsi_session *session = conn->session; in iscsi_conn_failure()
1476 needs_evt = iscsi_set_conn_failed(conn); in iscsi_conn_failure()
1480 iscsi_conn_error_event(conn->cls_conn, err); in iscsi_conn_failure()
1484 static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) in iscsi_check_cmdsn_window_closed() argument
1486 struct iscsi_session *session = conn->session; in iscsi_check_cmdsn_window_closed()
1501 static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, in iscsi_xmit_task() argument
1506 if (!conn->task) { in iscsi_xmit_task()
1519 conn->task = NULL; in iscsi_xmit_task()
1533 if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) { in iscsi_xmit_task()
1538 conn->task = task; in iscsi_xmit_task()
1542 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_xmit_task()
1543 rc = conn->session->tt->xmit_task(task); in iscsi_xmit_task()
1544 spin_lock_bh(&conn->session->frwd_lock); in iscsi_xmit_task()
1554 conn->task = task; in iscsi_xmit_task()
1569 struct iscsi_conn *conn = task->conn; in iscsi_requeue_task() local
1575 spin_lock_bh(&conn->session->frwd_lock); in iscsi_requeue_task()
1577 list_add_tail(&task->running, &conn->requeue); in iscsi_requeue_task()
1585 iscsi_conn_queue_xmit(conn); in iscsi_requeue_task()
1586 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_requeue_task()
1599 static int iscsi_data_xmit(struct iscsi_conn *conn) in iscsi_data_xmit() argument
1604 spin_lock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1605 if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) { in iscsi_data_xmit()
1606 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); in iscsi_data_xmit()
1607 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1611 if (conn->task) { in iscsi_data_xmit()
1612 rc = iscsi_xmit_task(conn, conn->task, false); in iscsi_data_xmit()
1623 while (!list_empty(&conn->mgmtqueue)) { in iscsi_data_xmit()
1624 task = list_entry(conn->mgmtqueue.next, struct iscsi_task, in iscsi_data_xmit()
1627 if (iscsi_prep_mgmt_task(conn, task)) { in iscsi_data_xmit()
1629 spin_lock_bh(&conn->session->back_lock); in iscsi_data_xmit()
1631 spin_unlock_bh(&conn->session->back_lock); in iscsi_data_xmit()
1634 rc = iscsi_xmit_task(conn, task, false); in iscsi_data_xmit()
1640 while (!list_empty(&conn->requeue)) { in iscsi_data_xmit()
1644 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) in iscsi_data_xmit()
1647 task = list_entry(conn->requeue.next, struct iscsi_task, in iscsi_data_xmit()
1654 rc = iscsi_xmit_task(conn, task, true); in iscsi_data_xmit()
1657 if (!list_empty(&conn->mgmtqueue)) in iscsi_data_xmit()
1662 while (!list_empty(&conn->cmdqueue)) { in iscsi_data_xmit()
1663 task = list_entry(conn->cmdqueue.next, struct iscsi_task, in iscsi_data_xmit()
1666 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { in iscsi_data_xmit()
1678 rc = iscsi_xmit_task(conn, task, false); in iscsi_data_xmit()
1686 if (!list_empty(&conn->mgmtqueue)) in iscsi_data_xmit()
1688 if (!list_empty(&conn->requeue)) in iscsi_data_xmit()
1692 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1696 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_data_xmit()
1702 struct iscsi_conn *conn = in iscsi_xmitworker() local
1709 rc = iscsi_data_xmit(conn); in iscsi_xmitworker()
1713 static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn, in iscsi_alloc_task() argument
1718 if (!kfifo_out(&conn->session->cmdpool.queue, in iscsi_alloc_task()
1722 iscsi_cmd(sc)->age = conn->session->age; in iscsi_alloc_task()
1727 task->conn = conn; in iscsi_alloc_task()
1756 struct iscsi_conn *conn; in iscsi_queuecommand() local
1816 conn = session->leadconn; in iscsi_queuecommand()
1817 if (!conn) { in iscsi_queuecommand()
1823 if (test_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags)) { in iscsi_queuecommand()
1829 if (iscsi_check_cmdsn_window_closed(conn)) { in iscsi_queuecommand()
1834 task = iscsi_alloc_task(conn, sc); in iscsi_queuecommand()
1857 list_add_tail(&task->running, &conn->cmdqueue); in iscsi_queuecommand()
1858 iscsi_conn_queue_xmit(conn); in iscsi_queuecommand()
1913 static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, in iscsi_exec_task_mgmt_fn() argument
1918 struct iscsi_session *session = conn->session; in iscsi_exec_task_mgmt_fn()
1920 if (__iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0)) { in iscsi_exec_task_mgmt_fn()
1922 iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n"); in iscsi_exec_task_mgmt_fn()
1923 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); in iscsi_exec_task_mgmt_fn()
1927 conn->tmfcmd_pdus_cnt++; in iscsi_exec_task_mgmt_fn()
1962 static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error) in fail_scsi_tasks() argument
1964 struct iscsi_session *session = conn->session; in fail_scsi_tasks()
2010 void iscsi_suspend_queue(struct iscsi_conn *conn) in iscsi_suspend_queue() argument
2012 spin_lock_bh(&conn->session->frwd_lock); in iscsi_suspend_queue()
2013 set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); in iscsi_suspend_queue()
2014 spin_unlock_bh(&conn->session->frwd_lock); in iscsi_suspend_queue()
2026 void iscsi_suspend_tx(struct iscsi_conn *conn) in iscsi_suspend_tx() argument
2028 struct Scsi_Host *shost = conn->session->host; in iscsi_suspend_tx()
2031 set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); in iscsi_suspend_tx()
2033 flush_work(&conn->xmitwork); in iscsi_suspend_tx()
2037 static void iscsi_start_tx(struct iscsi_conn *conn) in iscsi_start_tx() argument
2039 clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); in iscsi_start_tx()
2040 iscsi_conn_queue_xmit(conn); in iscsi_start_tx()
2047 void iscsi_suspend_rx(struct iscsi_conn *conn) in iscsi_suspend_rx() argument
2049 struct Scsi_Host *shost = conn->session->host; in iscsi_suspend_rx()
2052 set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags); in iscsi_suspend_rx()
2054 flush_work(&conn->recvwork); in iscsi_suspend_rx()
2064 static int iscsi_has_ping_timed_out(struct iscsi_conn *conn) in iscsi_has_ping_timed_out() argument
2066 if (READ_ONCE(conn->ping_task) && in iscsi_has_ping_timed_out()
2067 time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) + in iscsi_has_ping_timed_out()
2068 (conn->ping_timeout * HZ), jiffies)) in iscsi_has_ping_timed_out()
2080 struct iscsi_conn *conn; in iscsi_eh_cmd_timed_out() local
2134 conn = session->leadconn; in iscsi_eh_cmd_timed_out()
2135 if (!conn) { in iscsi_eh_cmd_timed_out()
2158 if (!conn->recv_timeout && !conn->ping_timeout) in iscsi_eh_cmd_timed_out()
2164 if (iscsi_has_ping_timed_out(conn)) { in iscsi_eh_cmd_timed_out()
2170 for (i = 0; i < conn->session->cmds_max; i++) { in iscsi_eh_cmd_timed_out()
2171 running_task = conn->session->cmds[i]; in iscsi_eh_cmd_timed_out()
2217 if (READ_ONCE(conn->ping_task)) { in iscsi_eh_cmd_timed_out()
2224 iscsi_send_nopout(conn, NULL); in iscsi_eh_cmd_timed_out()
2243 struct iscsi_conn *conn = from_timer(conn, t, transport_timer); in iscsi_check_transport_timeouts() local
2244 struct iscsi_session *session = conn->session; in iscsi_check_transport_timeouts()
2251 recv_timeout = conn->recv_timeout; in iscsi_check_transport_timeouts()
2256 last_recv = conn->last_recv; in iscsi_check_transport_timeouts()
2258 if (iscsi_has_ping_timed_out(conn)) { in iscsi_check_transport_timeouts()
2259 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " in iscsi_check_transport_timeouts()
2262 conn->ping_timeout, conn->recv_timeout, in iscsi_check_transport_timeouts()
2263 last_recv, conn->last_ping, jiffies); in iscsi_check_transport_timeouts()
2265 iscsi_conn_failure(conn, ISCSI_ERR_NOP_TIMEDOUT); in iscsi_check_transport_timeouts()
2271 ISCSI_DBG_CONN(conn, "Sending nopout as ping\n"); in iscsi_check_transport_timeouts()
2272 if (iscsi_send_nopout(conn, NULL)) in iscsi_check_transport_timeouts()
2275 next_timeout = conn->last_ping + (conn->ping_timeout * HZ); in iscsi_check_transport_timeouts()
2279 ISCSI_DBG_CONN(conn, "Setting next tmo %lu\n", next_timeout); in iscsi_check_transport_timeouts()
2280 mod_timer(&conn->transport_timer, next_timeout); in iscsi_check_transport_timeouts()
2297 struct iscsi_conn *conn; in iscsi_conn_unbind() local
2302 conn = cls_conn->dd_data; in iscsi_conn_unbind()
2303 session = conn->session; in iscsi_conn_unbind()
2312 iscsi_suspend_queue(conn); in iscsi_conn_unbind()
2313 iscsi_suspend_tx(conn); in iscsi_conn_unbind()
2316 clear_bit(ISCSI_CONN_FLAG_BOUND, &conn->flags); in iscsi_conn_unbind()
2325 iscsi_set_conn_failed(conn); in iscsi_conn_unbind()
2348 struct iscsi_conn *conn; in iscsi_eh_abort() local
2408 conn = session->leadconn; in iscsi_eh_abort()
2409 iscsi_get_conn(conn->cls_conn); in iscsi_eh_abort()
2410 conn->eh_abort_cnt++; in iscsi_eh_abort()
2427 if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) in iscsi_eh_abort()
2437 iscsi_suspend_tx(conn); in iscsi_eh_abort()
2448 iscsi_start_tx(conn); in iscsi_eh_abort()
2453 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); in iscsi_eh_abort()
2476 iscsi_put_conn(conn->cls_conn); in iscsi_eh_abort()
2493 iscsi_put_conn(conn->cls_conn); in iscsi_eh_abort()
2513 struct iscsi_conn *conn; in iscsi_eh_device_reset() local
2531 conn = session->leadconn; in iscsi_eh_device_reset()
2541 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, in iscsi_eh_device_reset()
2552 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); in iscsi_eh_device_reset()
2562 iscsi_suspend_tx(conn); in iscsi_eh_device_reset()
2566 fail_scsi_tasks(conn, sc->device->lun, DID_ERROR); in iscsi_eh_device_reset()
2570 iscsi_start_tx(conn); in iscsi_eh_device_reset()
2607 struct iscsi_conn *conn; in iscsi_eh_session_reset() local
2625 conn = session->leadconn; in iscsi_eh_session_reset()
2626 iscsi_get_conn(conn->cls_conn); in iscsi_eh_session_reset()
2631 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); in iscsi_eh_session_reset()
2632 iscsi_put_conn(conn->cls_conn); in iscsi_eh_session_reset()
2647 session->targetname, conn->persistent_address); in iscsi_eh_session_reset()
2675 struct iscsi_conn *conn; in iscsi_eh_target_reset() local
2693 conn = session->leadconn; in iscsi_eh_target_reset()
2703 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, in iscsi_eh_target_reset()
2714 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); in iscsi_eh_target_reset()
2724 iscsi_suspend_tx(conn); in iscsi_eh_target_reset()
2728 fail_scsi_tasks(conn, -1, DID_ERROR); in iscsi_eh_target_reset()
2732 iscsi_start_tx(conn); in iscsi_eh_target_reset()
3176 struct iscsi_conn *conn; in iscsi_conn_setup() local
3181 cls_conn = iscsi_alloc_conn(cls_session, sizeof(*conn) + dd_size, in iscsi_conn_setup()
3185 conn = cls_conn->dd_data; in iscsi_conn_setup()
3187 conn->dd_data = cls_conn->dd_data + sizeof(*conn); in iscsi_conn_setup()
3188 conn->session = session; in iscsi_conn_setup()
3189 conn->cls_conn = cls_conn; in iscsi_conn_setup()
3190 conn->c_stage = ISCSI_CONN_INITIAL_STAGE; in iscsi_conn_setup()
3191 conn->id = conn_idx; in iscsi_conn_setup()
3192 conn->exp_statsn = 0; in iscsi_conn_setup()
3194 timer_setup(&conn->transport_timer, iscsi_check_transport_timeouts, 0); in iscsi_conn_setup()
3196 INIT_LIST_HEAD(&conn->mgmtqueue); in iscsi_conn_setup()
3197 INIT_LIST_HEAD(&conn->cmdqueue); in iscsi_conn_setup()
3198 INIT_LIST_HEAD(&conn->requeue); in iscsi_conn_setup()
3199 INIT_WORK(&conn->xmitwork, iscsi_xmitworker); in iscsi_conn_setup()
3204 (void*)&conn->login_task, in iscsi_conn_setup()
3215 conn->login_task->data = conn->data = data; in iscsi_conn_setup()
3224 free_pages((unsigned long) conn->data, in iscsi_conn_setup()
3228 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, in iscsi_conn_setup()
3245 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_conn_teardown() local
3246 struct iscsi_session *session = conn->session; in iscsi_conn_teardown()
3250 del_timer_sync(&conn->transport_timer); in iscsi_conn_teardown()
3254 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT; in iscsi_conn_teardown()
3255 if (session->leadconn == conn) { in iscsi_conn_teardown()
3265 iscsi_suspend_tx(conn); in iscsi_conn_teardown()
3268 free_pages((unsigned long) conn->data, in iscsi_conn_teardown()
3270 kfree(conn->persistent_address); in iscsi_conn_teardown()
3271 kfree(conn->local_ipaddr); in iscsi_conn_teardown()
3274 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, in iscsi_conn_teardown()
3277 if (session->leadconn == conn) in iscsi_conn_teardown()
3288 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_conn_start() local
3289 struct iscsi_session *session = conn->session; in iscsi_conn_start()
3292 iscsi_conn_printk(KERN_ERR, conn, in iscsi_conn_start()
3299 iscsi_conn_printk(KERN_INFO, conn, "invalid burst lengths: " in iscsi_conn_start()
3305 if (conn->ping_timeout && !conn->recv_timeout) { in iscsi_conn_start()
3306 iscsi_conn_printk(KERN_ERR, conn, "invalid recv timeout of " in iscsi_conn_start()
3308 conn->recv_timeout = 5; in iscsi_conn_start()
3311 if (conn->recv_timeout && !conn->ping_timeout) { in iscsi_conn_start()
3312 iscsi_conn_printk(KERN_ERR, conn, "invalid ping timeout of " in iscsi_conn_start()
3314 conn->ping_timeout = 5; in iscsi_conn_start()
3318 conn->c_stage = ISCSI_CONN_STARTED; in iscsi_conn_start()
3322 conn->last_recv = jiffies; in iscsi_conn_start()
3323 conn->last_ping = jiffies; in iscsi_conn_start()
3324 if (conn->recv_timeout && conn->ping_timeout) in iscsi_conn_start()
3325 mod_timer(&conn->transport_timer, in iscsi_conn_start()
3326 jiffies + (conn->recv_timeout * HZ)); in iscsi_conn_start()
3328 switch(conn->stop_stage) { in iscsi_conn_start()
3334 conn->stop_stage = 0; in iscsi_conn_start()
3341 conn->stop_stage = 0; in iscsi_conn_start()
3355 fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) in fail_mgmt_tasks() argument
3360 for (i = 0; i < conn->session->cmds_max; i++) { in fail_mgmt_tasks()
3361 task = conn->session->cmds[i]; in fail_mgmt_tasks()
3368 ISCSI_DBG_SESSION(conn->session, in fail_mgmt_tasks()
3388 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_conn_stop() local
3389 struct iscsi_session *session = conn->session; in iscsi_conn_stop()
3394 if (conn->stop_stage == STOP_CONN_TERM) { in iscsi_conn_stop()
3407 else if (conn->stop_stage != STOP_CONN_RECOVER) in iscsi_conn_stop()
3410 old_stop_stage = conn->stop_stage; in iscsi_conn_stop()
3411 conn->stop_stage = flag; in iscsi_conn_stop()
3414 del_timer_sync(&conn->transport_timer); in iscsi_conn_stop()
3415 iscsi_suspend_tx(conn); in iscsi_conn_stop()
3418 conn->c_stage = ISCSI_CONN_STOPPED; in iscsi_conn_stop()
3428 conn->hdrdgst_en = 0; in iscsi_conn_stop()
3429 conn->datadgst_en = 0; in iscsi_conn_stop()
3441 fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED); in iscsi_conn_stop()
3442 fail_mgmt_tasks(session, conn); in iscsi_conn_stop()
3453 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_conn_bind() local
3457 session->leadconn = conn; in iscsi_conn_bind()
3459 set_bit(ISCSI_CONN_FLAG_BOUND, &conn->flags); in iscsi_conn_bind()
3472 clear_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags); in iscsi_conn_bind()
3473 clear_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); in iscsi_conn_bind()
3500 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_set_param() local
3501 struct iscsi_session *session = conn->session; in iscsi_set_param()
3518 sscanf(buf, "%d", &conn->ping_timeout); in iscsi_set_param()
3521 sscanf(buf, "%d", &conn->recv_timeout); in iscsi_set_param()
3524 sscanf(buf, "%d", &conn->max_recv_dlength); in iscsi_set_param()
3527 sscanf(buf, "%d", &conn->max_xmit_dlength); in iscsi_set_param()
3530 sscanf(buf, "%d", &conn->hdrdgst_en); in iscsi_set_param()
3533 sscanf(buf, "%d", &conn->datadgst_en); in iscsi_set_param()
3560 sscanf(buf, "%u", &conn->exp_statsn); in iscsi_set_param()
3578 sscanf(buf, "%d", &conn->persistent_port); in iscsi_set_param()
3581 return iscsi_switch_str_param(&conn->persistent_address, buf); in iscsi_set_param()
3602 return iscsi_switch_str_param(&conn->local_ipaddr, buf); in iscsi_set_param()
3792 struct iscsi_conn *conn = cls_conn->dd_data; in iscsi_conn_get_param() local
3797 len = sysfs_emit(buf, "%u\n", conn->ping_timeout); in iscsi_conn_get_param()
3800 len = sysfs_emit(buf, "%u\n", conn->recv_timeout); in iscsi_conn_get_param()
3803 len = sysfs_emit(buf, "%u\n", conn->max_recv_dlength); in iscsi_conn_get_param()
3806 len = sysfs_emit(buf, "%u\n", conn->max_xmit_dlength); in iscsi_conn_get_param()
3809 len = sysfs_emit(buf, "%d\n", conn->hdrdgst_en); in iscsi_conn_get_param()
3812 len = sysfs_emit(buf, "%d\n", conn->datadgst_en); in iscsi_conn_get_param()
3815 len = sysfs_emit(buf, "%d\n", conn->ifmarker_en); in iscsi_conn_get_param()
3818 len = sysfs_emit(buf, "%d\n", conn->ofmarker_en); in iscsi_conn_get_param()
3821 len = sysfs_emit(buf, "%u\n", conn->exp_statsn); in iscsi_conn_get_param()
3824 len = sysfs_emit(buf, "%d\n", conn->persistent_port); in iscsi_conn_get_param()
3827 len = sysfs_emit(buf, "%s\n", conn->persistent_address); in iscsi_conn_get_param()
3830 len = sysfs_emit(buf, "%u\n", conn->statsn); in iscsi_conn_get_param()
3833 len = sysfs_emit(buf, "%u\n", conn->max_segment_size); in iscsi_conn_get_param()
3836 len = sysfs_emit(buf, "%u\n", conn->keepalive_tmo); in iscsi_conn_get_param()
3839 len = sysfs_emit(buf, "%u\n", conn->local_port); in iscsi_conn_get_param()
3842 len = sysfs_emit(buf, "%u\n", conn->tcp_timestamp_stat); in iscsi_conn_get_param()
3845 len = sysfs_emit(buf, "%u\n", conn->tcp_nagle_disable); in iscsi_conn_get_param()
3848 len = sysfs_emit(buf, "%u\n", conn->tcp_wsf_disable); in iscsi_conn_get_param()
3851 len = sysfs_emit(buf, "%u\n", conn->tcp_timer_scale); in iscsi_conn_get_param()
3854 len = sysfs_emit(buf, "%u\n", conn->tcp_timestamp_en); in iscsi_conn_get_param()
3857 len = sysfs_emit(buf, "%u\n", conn->fragment_disable); in iscsi_conn_get_param()
3860 len = sysfs_emit(buf, "%u\n", conn->ipv4_tos); in iscsi_conn_get_param()
3863 len = sysfs_emit(buf, "%u\n", conn->ipv6_traffic_class); in iscsi_conn_get_param()
3866 len = sysfs_emit(buf, "%u\n", conn->ipv6_flow_label); in iscsi_conn_get_param()
3869 len = sysfs_emit(buf, "%u\n", conn->is_fw_assigned_ipv6); in iscsi_conn_get_param()
3872 len = sysfs_emit(buf, "%u\n", conn->tcp_xmit_wsf); in iscsi_conn_get_param()
3875 len = sysfs_emit(buf, "%u\n", conn->tcp_recv_wsf); in iscsi_conn_get_param()
3878 len = sysfs_emit(buf, "%s\n", conn->local_ipaddr); in iscsi_conn_get_param()