aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bnx2i/bnx2i_iscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bnx2i/bnx2i_iscsi.c')
-rw-r--r--drivers/scsi/bnx2i/bnx2i_iscsi.c236
1 files changed, 175 insertions, 61 deletions
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fa68ab34b998..a46ccc380ab1 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -386,6 +386,7 @@ static struct iscsi_endpoint *bnx2i_alloc_ep(struct bnx2i_hba *hba)
386 } 386 }
387 387
388 bnx2i_ep = ep->dd_data; 388 bnx2i_ep = ep->dd_data;
389 bnx2i_ep->cls_ep = ep;
389 INIT_LIST_HEAD(&bnx2i_ep->link); 390 INIT_LIST_HEAD(&bnx2i_ep->link);
390 bnx2i_ep->state = EP_STATE_IDLE; 391 bnx2i_ep->state = EP_STATE_IDLE;
391 bnx2i_ep->ep_iscsi_cid = (u16) -1; 392 bnx2i_ep->ep_iscsi_cid = (u16) -1;
@@ -678,7 +679,6 @@ bnx2i_find_ep_in_ofld_list(struct bnx2i_hba *hba, u32 iscsi_cid)
678 return ep; 679 return ep;
679} 680}
680 681
681
682/** 682/**
683 * bnx2i_find_ep_in_destroy_list - find iscsi_cid in destroy list 683 * bnx2i_find_ep_in_destroy_list - find iscsi_cid in destroy list
684 * @hba: pointer to adapter instance 684 * @hba: pointer to adapter instance
@@ -709,6 +709,38 @@ bnx2i_find_ep_in_destroy_list(struct bnx2i_hba *hba, u32 iscsi_cid)
709} 709}
710 710
711/** 711/**
712 * bnx2i_ep_active_list_add - add an entry to ep active list
713 * @hba: pointer to adapter instance
714 * @ep: pointer to endpoint (transport indentifier) structure
715 *
716 * current active conn queue manager
717 */
718static void bnx2i_ep_active_list_add(struct bnx2i_hba *hba,
719 struct bnx2i_endpoint *ep)
720{
721 write_lock_bh(&hba->ep_rdwr_lock);
722 list_add_tail(&ep->link, &hba->ep_active_list);
723 write_unlock_bh(&hba->ep_rdwr_lock);
724}
725
726
727/**
728 * bnx2i_ep_active_list_del - deletes an entry to ep active list
729 * @hba: pointer to adapter instance
730 * @ep: pointer to endpoint (transport indentifier) structure
731 *
732 * current active conn queue manager
733 */
734static void bnx2i_ep_active_list_del(struct bnx2i_hba *hba,
735 struct bnx2i_endpoint *ep)
736{
737 write_lock_bh(&hba->ep_rdwr_lock);
738 list_del_init(&ep->link);
739 write_unlock_bh(&hba->ep_rdwr_lock);
740}
741
742
743/**
712 * bnx2i_setup_host_queue_size - assigns shost->can_queue param 744 * bnx2i_setup_host_queue_size - assigns shost->can_queue param
713 * @hba: pointer to adapter instance 745 * @hba: pointer to adapter instance
714 * @shost: scsi host pointer 746 * @shost: scsi host pointer
@@ -784,6 +816,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
784 goto mp_bdt_mem_err; 816 goto mp_bdt_mem_err;
785 817
786 INIT_LIST_HEAD(&hba->ep_ofld_list); 818 INIT_LIST_HEAD(&hba->ep_ofld_list);
819 INIT_LIST_HEAD(&hba->ep_active_list);
787 INIT_LIST_HEAD(&hba->ep_destroy_list); 820 INIT_LIST_HEAD(&hba->ep_destroy_list);
788 rwlock_init(&hba->ep_rdwr_lock); 821 rwlock_init(&hba->ep_rdwr_lock);
789 822
@@ -821,10 +854,15 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
821 spin_lock_init(&hba->lock); 854 spin_lock_init(&hba->lock);
822 mutex_init(&hba->net_dev_lock); 855 mutex_init(&hba->net_dev_lock);
823 init_waitqueue_head(&hba->eh_wait); 856 init_waitqueue_head(&hba->eh_wait);
824 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) 857 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) {
825 hba->hba_shutdown_tmo = 240 * HZ; 858 hba->hba_shutdown_tmo = 20 * HZ;
826 else /* 5706/5708/5709 */ 859 hba->conn_teardown_tmo = 20 * HZ;
827 hba->hba_shutdown_tmo = 30 * HZ; 860 hba->conn_ctx_destroy_tmo = 6 * HZ;
861 } else { /* 5706/5708/5709 */
862 hba->hba_shutdown_tmo = 20 * HZ;
863 hba->conn_teardown_tmo = 10 * HZ;
864 hba->conn_ctx_destroy_tmo = 2 * HZ;
865 }
828 866
829 if (iscsi_host_add(shost, &hba->pcidev->dev)) 867 if (iscsi_host_add(shost, &hba->pcidev->dev))
830 goto free_dump_mem; 868 goto free_dump_mem;
@@ -857,6 +895,7 @@ void bnx2i_free_hba(struct bnx2i_hba *hba)
857 895
858 iscsi_host_remove(shost); 896 iscsi_host_remove(shost);
859 INIT_LIST_HEAD(&hba->ep_ofld_list); 897 INIT_LIST_HEAD(&hba->ep_ofld_list);
898 INIT_LIST_HEAD(&hba->ep_active_list);
860 INIT_LIST_HEAD(&hba->ep_destroy_list); 899 INIT_LIST_HEAD(&hba->ep_destroy_list);
861 pci_dev_put(hba->pcidev); 900 pci_dev_put(hba->pcidev);
862 901
@@ -1461,6 +1500,26 @@ static int bnx2i_host_get_param(struct Scsi_Host *shost,
1461 case ISCSI_HOST_PARAM_NETDEV_NAME: 1500 case ISCSI_HOST_PARAM_NETDEV_NAME:
1462 len = sprintf(buf, "%s\n", hba->netdev->name); 1501 len = sprintf(buf, "%s\n", hba->netdev->name);
1463 break; 1502 break;
1503 case ISCSI_HOST_PARAM_IPADDRESS: {
1504 struct list_head *active_list = &hba->ep_active_list;
1505
1506 read_lock_bh(&hba->ep_rdwr_lock);
1507 if (!list_empty(&hba->ep_active_list)) {
1508 struct bnx2i_endpoint *bnx2i_ep;
1509 struct cnic_sock *csk;
1510
1511 bnx2i_ep = list_first_entry(active_list,
1512 struct bnx2i_endpoint,
1513 link);
1514 csk = bnx2i_ep->cm_sk;
1515 if (test_bit(SK_F_IPV6, &csk->flags))
1516 len = sprintf(buf, "%pI6\n", csk->src_ip);
1517 else
1518 len = sprintf(buf, "%pI4\n", csk->src_ip);
1519 }
1520 read_unlock_bh(&hba->ep_rdwr_lock);
1521 break;
1522 }
1464 default: 1523 default:
1465 return iscsi_host_get_param(shost, param, buf); 1524 return iscsi_host_get_param(shost, param, buf);
1466 } 1525 }
@@ -1599,7 +1658,7 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
1599 1658
1600 ep->state = EP_STATE_CLEANUP_START; 1659 ep->state = EP_STATE_CLEANUP_START;
1601 init_timer(&ep->ofld_timer); 1660 init_timer(&ep->ofld_timer);
1602 ep->ofld_timer.expires = 10*HZ + jiffies; 1661 ep->ofld_timer.expires = hba->conn_ctx_destroy_tmo + jiffies;
1603 ep->ofld_timer.function = bnx2i_ep_ofld_timer; 1662 ep->ofld_timer.function = bnx2i_ep_ofld_timer;
1604 ep->ofld_timer.data = (unsigned long) ep; 1663 ep->ofld_timer.data = (unsigned long) ep;
1605 add_timer(&ep->ofld_timer); 1664 add_timer(&ep->ofld_timer);
@@ -1665,10 +1724,11 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
1665 1724
1666 if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) { 1725 if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
1667 rc = -EINVAL; 1726 rc = -EINVAL;
1668 goto check_busy; 1727 goto nohba;
1669 } 1728 }
1670 1729
1671 cnic = hba->cnic; 1730 cnic = hba->cnic;
1731 mutex_lock(&hba->net_dev_lock);
1672 ep = bnx2i_alloc_ep(hba); 1732 ep = bnx2i_alloc_ep(hba);
1673 if (!ep) { 1733 if (!ep) {
1674 rc = -ENOMEM; 1734 rc = -ENOMEM;
@@ -1676,7 +1736,6 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
1676 } 1736 }
1677 bnx2i_ep = ep->dd_data; 1737 bnx2i_ep = ep->dd_data;
1678 1738
1679 mutex_lock(&hba->net_dev_lock);
1680 if (bnx2i_adapter_ready(hba)) { 1739 if (bnx2i_adapter_ready(hba)) {
1681 rc = -EPERM; 1740 rc = -EPERM;
1682 goto net_if_down; 1741 goto net_if_down;
@@ -1754,15 +1813,19 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
1754 goto conn_failed; 1813 goto conn_failed;
1755 } else 1814 } else
1756 rc = cnic->cm_connect(bnx2i_ep->cm_sk, &saddr); 1815 rc = cnic->cm_connect(bnx2i_ep->cm_sk, &saddr);
1757
1758 if (rc) 1816 if (rc)
1759 goto release_ep; 1817 goto release_ep;
1760 1818
1819 bnx2i_ep_active_list_add(hba, bnx2i_ep);
1820
1761 if (bnx2i_map_ep_dbell_regs(bnx2i_ep)) 1821 if (bnx2i_map_ep_dbell_regs(bnx2i_ep))
1762 goto release_ep; 1822 goto del_active_ep;
1823
1763 mutex_unlock(&hba->net_dev_lock); 1824 mutex_unlock(&hba->net_dev_lock);
1764 return ep; 1825 return ep;
1765 1826
1827del_active_ep:
1828 bnx2i_ep_active_list_del(hba, bnx2i_ep);
1766release_ep: 1829release_ep:
1767 if (bnx2i_tear_down_conn(hba, bnx2i_ep)) { 1830 if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
1768 mutex_unlock(&hba->net_dev_lock); 1831 mutex_unlock(&hba->net_dev_lock);
@@ -1774,8 +1837,9 @@ iscsi_cid_err:
1774 bnx2i_free_qp_resc(hba, bnx2i_ep); 1837 bnx2i_free_qp_resc(hba, bnx2i_ep);
1775qp_resc_err: 1838qp_resc_err:
1776 bnx2i_free_ep(ep); 1839 bnx2i_free_ep(ep);
1777 mutex_unlock(&hba->net_dev_lock);
1778check_busy: 1840check_busy:
1841 mutex_unlock(&hba->net_dev_lock);
1842nohba:
1779 bnx2i_unreg_dev_all(); 1843 bnx2i_unreg_dev_all();
1780 return ERR_PTR(rc); 1844 return ERR_PTR(rc);
1781} 1845}
@@ -1846,6 +1910,8 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
1846 case EP_STATE_ULP_UPDATE_START: 1910 case EP_STATE_ULP_UPDATE_START:
1847 case EP_STATE_ULP_UPDATE_COMPL: 1911 case EP_STATE_ULP_UPDATE_COMPL:
1848 case EP_STATE_TCP_FIN_RCVD: 1912 case EP_STATE_TCP_FIN_RCVD:
1913 case EP_STATE_LOGOUT_SENT:
1914 case EP_STATE_LOGOUT_RESP_RCVD:
1849 case EP_STATE_ULP_UPDATE_FAILED: 1915 case EP_STATE_ULP_UPDATE_FAILED:
1850 ret = 1; 1916 ret = 1;
1851 break; 1917 break;
@@ -1866,9 +1932,96 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
1866} 1932}
1867 1933
1868 1934
1935/*
1936 * bnx2i_hw_ep_disconnect - executes TCP connection teardown process in the hw
1937 * @ep: TCP connection (bnx2i endpoint) handle
1938 *
1939 * executes TCP connection teardown process
1940 */
1941int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
1942{
1943 struct bnx2i_hba *hba = bnx2i_ep->hba;
1944 struct cnic_dev *cnic;
1945 struct iscsi_session *session = NULL;
1946 struct iscsi_conn *conn = NULL;
1947 int ret = 0;
1948 int close = 0;
1949 int close_ret = 0;
1950
1951 if (!hba)
1952 return 0;
1953
1954 cnic = hba->cnic;
1955 if (!cnic)
1956 return 0;
1957
1958 if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
1959 goto destroy_conn;
1960
1961 if (bnx2i_ep->conn) {
1962 conn = bnx2i_ep->conn->cls_conn->dd_data;
1963 session = conn->session;
1964 }
1965
1966 init_timer(&bnx2i_ep->ofld_timer);
1967 bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies;
1968 bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
1969 bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
1970 add_timer(&bnx2i_ep->ofld_timer);
1971
1972 if (!test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
1973 goto out;
1974
1975 if (session) {
1976 spin_lock_bh(&session->lock);
1977 if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) {
1978 if (session->state == ISCSI_STATE_LOGGING_OUT) {
1979 if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) {
1980 /* Logout sent, but no resp */
1981 printk(KERN_ALERT "bnx2i - WARNING "
1982 "logout response was not "
1983 "received!\n");
1984 } else if (bnx2i_ep->state ==
1985 EP_STATE_LOGOUT_RESP_RCVD)
1986 close = 1;
1987 }
1988 } else
1989 close = 1;
1990
1991 spin_unlock_bh(&session->lock);
1992 }
1993
1994 bnx2i_ep->state = EP_STATE_DISCONN_START;
1995
1996 if (close)
1997 close_ret = cnic->cm_close(bnx2i_ep->cm_sk);
1998 else
1999 close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
2000
2001 if (close_ret)
2002 bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
2003
2004 /* wait for option-2 conn teardown */
2005 wait_event_interruptible(bnx2i_ep->ofld_wait,
2006 bnx2i_ep->state != EP_STATE_DISCONN_START);
2007
2008 if (signal_pending(current))
2009 flush_signals(current);
2010 del_timer_sync(&bnx2i_ep->ofld_timer);
2011
2012destroy_conn:
2013 bnx2i_ep_active_list_del(hba, bnx2i_ep);
2014 if (bnx2i_tear_down_conn(hba, bnx2i_ep))
2015 ret = -EINVAL;
2016out:
2017 bnx2i_ep->state = EP_STATE_IDLE;
2018 return ret;
2019}
2020
2021
1869/** 2022/**
1870 * bnx2i_ep_disconnect - executes TCP connection teardown process 2023 * bnx2i_ep_disconnect - executes TCP connection teardown process
1871 * @ep: TCP connection (endpoint) handle 2024 * @ep: TCP connection (iscsi endpoint) handle
1872 * 2025 *
1873 * executes TCP connection teardown process 2026 * executes TCP connection teardown process
1874 */ 2027 */
@@ -1876,9 +2029,7 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
1876{ 2029{
1877 struct bnx2i_endpoint *bnx2i_ep; 2030 struct bnx2i_endpoint *bnx2i_ep;
1878 struct bnx2i_conn *bnx2i_conn = NULL; 2031 struct bnx2i_conn *bnx2i_conn = NULL;
1879 struct iscsi_session *session = NULL; 2032 struct iscsi_conn *conn = NULL;
1880 struct iscsi_conn *conn;
1881 struct cnic_dev *cnic;
1882 struct bnx2i_hba *hba; 2033 struct bnx2i_hba *hba;
1883 2034
1884 bnx2i_ep = ep->dd_data; 2035 bnx2i_ep = ep->dd_data;
@@ -1894,72 +2045,34 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
1894 if (bnx2i_ep->conn) { 2045 if (bnx2i_ep->conn) {
1895 bnx2i_conn = bnx2i_ep->conn; 2046 bnx2i_conn = bnx2i_ep->conn;
1896 conn = bnx2i_conn->cls_conn->dd_data; 2047 conn = bnx2i_conn->cls_conn->dd_data;
1897 session = conn->session;
1898
1899 iscsi_suspend_queue(conn); 2048 iscsi_suspend_queue(conn);
1900 } 2049 }
1901
1902 hba = bnx2i_ep->hba; 2050 hba = bnx2i_ep->hba;
1903 if (bnx2i_ep->state == EP_STATE_IDLE)
1904 goto return_bnx2i_ep;
1905 cnic = hba->cnic;
1906 2051
1907 mutex_lock(&hba->net_dev_lock); 2052 mutex_lock(&hba->net_dev_lock);
1908 2053
2054 if (bnx2i_ep->state == EP_STATE_IDLE)
2055 goto return_bnx2i_ep;
2056
1909 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) 2057 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
1910 goto free_resc; 2058 goto free_resc;
1911 if (bnx2i_ep->hba_age != hba->age)
1912 goto free_resc;
1913
1914 if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
1915 goto destory_conn;
1916
1917 bnx2i_ep->state = EP_STATE_DISCONN_START;
1918
1919 init_timer(&bnx2i_ep->ofld_timer);
1920 bnx2i_ep->ofld_timer.expires = 10*HZ + jiffies;
1921 bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
1922 bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
1923 add_timer(&bnx2i_ep->ofld_timer);
1924 2059
1925 if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) { 2060 if (bnx2i_ep->hba_age != hba->age)
1926 int close = 0;
1927
1928 if (session) {
1929 spin_lock_bh(&session->lock);
1930 if (session->state == ISCSI_STATE_LOGGING_OUT)
1931 close = 1;
1932 spin_unlock_bh(&session->lock);
1933 }
1934 if (close)
1935 cnic->cm_close(bnx2i_ep->cm_sk);
1936 else
1937 cnic->cm_abort(bnx2i_ep->cm_sk);
1938 } else
1939 goto free_resc; 2061 goto free_resc;
1940 2062
1941 /* wait for option-2 conn teardown */ 2063 /* Do all chip cleanup here */
1942 wait_event_interruptible(bnx2i_ep->ofld_wait, 2064 if (bnx2i_hw_ep_disconnect(bnx2i_ep)) {
1943 bnx2i_ep->state != EP_STATE_DISCONN_START);
1944
1945 if (signal_pending(current))
1946 flush_signals(current);
1947 del_timer_sync(&bnx2i_ep->ofld_timer);
1948
1949destory_conn:
1950 if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
1951 mutex_unlock(&hba->net_dev_lock); 2065 mutex_unlock(&hba->net_dev_lock);
1952 return; 2066 return;
1953 } 2067 }
1954free_resc: 2068free_resc:
1955 mutex_unlock(&hba->net_dev_lock);
1956 bnx2i_free_qp_resc(hba, bnx2i_ep); 2069 bnx2i_free_qp_resc(hba, bnx2i_ep);
1957return_bnx2i_ep: 2070return_bnx2i_ep:
1958 if (bnx2i_conn) 2071 if (bnx2i_conn)
1959 bnx2i_conn->ep = NULL; 2072 bnx2i_conn->ep = NULL;
1960 2073
1961 bnx2i_free_ep(ep); 2074 bnx2i_free_ep(ep);
1962 2075 mutex_unlock(&hba->net_dev_lock);
1963 if (!hba->ofld_conns_active) 2076 if (!hba->ofld_conns_active)
1964 bnx2i_unreg_dev_all(); 2077 bnx2i_unreg_dev_all();
1965 2078
@@ -2038,7 +2151,8 @@ struct iscsi_transport bnx2i_iscsi_transport = {
2038 ISCSI_LU_RESET_TMO | ISCSI_TGT_RESET_TMO | 2151 ISCSI_LU_RESET_TMO | ISCSI_TGT_RESET_TMO |
2039 ISCSI_PING_TMO | ISCSI_RECV_TMO | 2152 ISCSI_PING_TMO | ISCSI_RECV_TMO |
2040 ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME, 2153 ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME,
2041 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_NETDEV_NAME, 2154 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
2155 ISCSI_HOST_NETDEV_NAME,
2042 .create_session = bnx2i_session_create, 2156 .create_session = bnx2i_session_create,
2043 .destroy_session = bnx2i_session_destroy, 2157 .destroy_session = bnx2i_session_destroy,
2044 .create_conn = bnx2i_conn_create, 2158 .create_conn = bnx2i_conn_create,