diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_init.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 981 |
1 files changed, 37 insertions, 944 deletions
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 1ab5d92c3868..0387005fcb6d 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "qla_def.h" | 19 | #include "qla_def.h" |
20 | 20 | ||
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <scsi/scsi_transport_fc.h> | ||
22 | 23 | ||
23 | #include "qla_devtbl.h" | 24 | #include "qla_devtbl.h" |
24 | 25 | ||
@@ -44,34 +45,17 @@ static int qla2x00_init_rings(scsi_qla_host_t *); | |||
44 | static int qla2x00_fw_ready(scsi_qla_host_t *); | 45 | static int qla2x00_fw_ready(scsi_qla_host_t *); |
45 | static int qla2x00_configure_hba(scsi_qla_host_t *); | 46 | static int qla2x00_configure_hba(scsi_qla_host_t *); |
46 | static int qla2x00_nvram_config(scsi_qla_host_t *); | 47 | static int qla2x00_nvram_config(scsi_qla_host_t *); |
47 | static void qla2x00_init_tgt_map(scsi_qla_host_t *); | ||
48 | static int qla2x00_configure_loop(scsi_qla_host_t *); | 48 | static int qla2x00_configure_loop(scsi_qla_host_t *); |
49 | static int qla2x00_configure_local_loop(scsi_qla_host_t *); | 49 | static int qla2x00_configure_local_loop(scsi_qla_host_t *); |
50 | static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); | 50 | static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); |
51 | static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *); | ||
52 | static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *, | ||
53 | inq_cmd_rsp_t *, dma_addr_t); | ||
54 | static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *); | ||
55 | static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t, | ||
56 | inq_cmd_rsp_t *, dma_addr_t); | ||
57 | static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t); | ||
58 | static int qla2x00_inquiry(scsi_qla_host_t *, fc_port_t *, uint16_t, | ||
59 | inq_cmd_rsp_t *, dma_addr_t); | ||
60 | static int qla2x00_configure_fabric(scsi_qla_host_t *); | 51 | static int qla2x00_configure_fabric(scsi_qla_host_t *); |
61 | static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); | 52 | static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); |
62 | static int qla2x00_device_resync(scsi_qla_host_t *); | 53 | static int qla2x00_device_resync(scsi_qla_host_t *); |
63 | static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, | 54 | static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, |
64 | uint16_t *); | 55 | uint16_t *); |
65 | static void qla2x00_config_os(scsi_qla_host_t *ha); | ||
66 | static uint16_t qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport); | ||
67 | static os_lun_t * qla2x00_fclun_bind(scsi_qla_host_t *, fc_port_t *, | ||
68 | fc_lun_t *); | ||
69 | static void qla2x00_lun_free(scsi_qla_host_t *, uint16_t, uint16_t); | ||
70 | 56 | ||
71 | static int qla2x00_restart_isp(scsi_qla_host_t *); | 57 | static int qla2x00_restart_isp(scsi_qla_host_t *); |
72 | static void qla2x00_reset_adapter(scsi_qla_host_t *); | 58 | static void qla2x00_reset_adapter(scsi_qla_host_t *); |
73 | static os_tgt_t *qla2x00_tgt_alloc(scsi_qla_host_t *, uint16_t); | ||
74 | static os_lun_t *qla2x00_lun_alloc(scsi_qla_host_t *, uint16_t, uint16_t); | ||
75 | 59 | ||
76 | /****************************************************************************/ | 60 | /****************************************************************************/ |
77 | /* QLogic ISP2x00 Hardware Support Functions. */ | 61 | /* QLogic ISP2x00 Hardware Support Functions. */ |
@@ -119,9 +103,6 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha) | |||
119 | 103 | ||
120 | qla2x00_reset_chip(ha); | 104 | qla2x00_reset_chip(ha); |
121 | 105 | ||
122 | /* Initialize target map database. */ | ||
123 | qla2x00_init_tgt_map(ha); | ||
124 | |||
125 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); | 106 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); |
126 | qla2x00_nvram_config(ha); | 107 | qla2x00_nvram_config(ha); |
127 | 108 | ||
@@ -1529,25 +1510,6 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1529 | return (rval); | 1510 | return (rval); |
1530 | } | 1511 | } |
1531 | 1512 | ||
1532 | /* | ||
1533 | * qla2x00_init_tgt_map | ||
1534 | * Initializes target map. | ||
1535 | * | ||
1536 | * Input: | ||
1537 | * ha = adapter block pointer. | ||
1538 | * | ||
1539 | * Output: | ||
1540 | * TGT_Q initialized | ||
1541 | */ | ||
1542 | static void | ||
1543 | qla2x00_init_tgt_map(scsi_qla_host_t *ha) | ||
1544 | { | ||
1545 | uint32_t t; | ||
1546 | |||
1547 | for (t = 0; t < MAX_TARGETS; t++) | ||
1548 | TGT_Q(ha, t) = (os_tgt_t *)NULL; | ||
1549 | } | ||
1550 | |||
1551 | /** | 1513 | /** |
1552 | * qla2x00_alloc_fcport() - Allocate a generic fcport. | 1514 | * qla2x00_alloc_fcport() - Allocate a generic fcport. |
1553 | * @ha: HA context | 1515 | * @ha: HA context |
@@ -1572,7 +1534,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags) | |||
1572 | fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; | 1534 | fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; |
1573 | atomic_set(&fcport->state, FCS_UNCONFIGURED); | 1535 | atomic_set(&fcport->state, FCS_UNCONFIGURED); |
1574 | fcport->flags = FCF_RLC_SUPPORT; | 1536 | fcport->flags = FCF_RLC_SUPPORT; |
1575 | INIT_LIST_HEAD(&fcport->fcluns); | ||
1576 | 1537 | ||
1577 | return (fcport); | 1538 | return (fcport); |
1578 | } | 1539 | } |
@@ -1662,7 +1623,6 @@ qla2x00_configure_loop(scsi_qla_host_t *ha) | |||
1662 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | 1623 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { |
1663 | rval = QLA_FUNCTION_FAILED; | 1624 | rval = QLA_FUNCTION_FAILED; |
1664 | } else { | 1625 | } else { |
1665 | qla2x00_config_os(ha); | ||
1666 | atomic_set(&ha->loop_state, LOOP_READY); | 1626 | atomic_set(&ha->loop_state, LOOP_READY); |
1667 | 1627 | ||
1668 | DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); | 1628 | DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); |
@@ -1907,8 +1867,11 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
1907 | if (fcport->flags & FCF_TAPE_PRESENT) { | 1867 | if (fcport->flags & FCF_TAPE_PRESENT) { |
1908 | spin_lock_irqsave(&ha->hardware_lock, flags); | 1868 | spin_lock_irqsave(&ha->hardware_lock, flags); |
1909 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 1869 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { |
1870 | fc_port_t *sfcp; | ||
1871 | |||
1910 | if ((sp = ha->outstanding_cmds[index]) != 0) { | 1872 | if ((sp = ha->outstanding_cmds[index]) != 0) { |
1911 | if (sp->fclun->fcport == fcport) { | 1873 | sfcp = sp->fcport; |
1874 | if (sfcp == fcport) { | ||
1912 | atomic_set(&fcport->state, FCS_ONLINE); | 1875 | atomic_set(&fcport->state, FCS_ONLINE); |
1913 | spin_unlock_irqrestore( | 1876 | spin_unlock_irqrestore( |
1914 | &ha->hardware_lock, flags); | 1877 | &ha->hardware_lock, flags); |
@@ -1919,423 +1882,48 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
1919 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 1882 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
1920 | } | 1883 | } |
1921 | 1884 | ||
1922 | /* Do LUN discovery. */ | ||
1923 | if (fcport->port_type == FCT_INITIATOR || | 1885 | if (fcport->port_type == FCT_INITIATOR || |
1924 | fcport->port_type == FCT_BROADCAST) { | 1886 | fcport->port_type == FCT_BROADCAST) |
1925 | fcport->device_type = TYPE_PROCESSOR; | 1887 | fcport->device_type = TYPE_PROCESSOR; |
1926 | } else { | ||
1927 | qla2x00_lun_discovery(ha, fcport); | ||
1928 | } | ||
1929 | atomic_set(&fcport->state, FCS_ONLINE); | ||
1930 | } | ||
1931 | 1888 | ||
1932 | /* | ||
1933 | * qla2x00_lun_discovery | ||
1934 | * Issue SCSI inquiry command for LUN discovery. | ||
1935 | * | ||
1936 | * Input: | ||
1937 | * ha: adapter state pointer. | ||
1938 | * fcport: FC port structure pointer. | ||
1939 | * | ||
1940 | * Context: | ||
1941 | * Kernel context. | ||
1942 | */ | ||
1943 | static void | ||
1944 | qla2x00_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport) | ||
1945 | { | ||
1946 | inq_cmd_rsp_t *inq; | ||
1947 | dma_addr_t inq_dma; | ||
1948 | uint16_t lun; | ||
1949 | |||
1950 | inq = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &inq_dma); | ||
1951 | if (inq == NULL) { | ||
1952 | qla_printk(KERN_WARNING, ha, | ||
1953 | "Memory Allocation failed - INQ\n"); | ||
1954 | return; | ||
1955 | } | ||
1956 | |||
1957 | /* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */ | ||
1958 | qla2x00_add_lun(fcport, 0); | ||
1959 | |||
1960 | /* If report LUN works, exit. */ | ||
1961 | if (qla2x00_rpt_lun_discovery(ha, fcport, inq, inq_dma) != | ||
1962 | QLA_SUCCESS) { | ||
1963 | for (lun = 0; lun < ha->max_probe_luns; lun++) { | ||
1964 | /* Configure LUN. */ | ||
1965 | qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma); | ||
1966 | } | ||
1967 | } | ||
1968 | |||
1969 | dma_pool_free(ha->s_dma_pool, inq, inq_dma); | ||
1970 | } | ||
1971 | |||
1972 | /* | ||
1973 | * qla2x00_rpt_lun_discovery | ||
1974 | * Issue SCSI report LUN command for LUN discovery. | ||
1975 | * | ||
1976 | * Input: | ||
1977 | * ha: adapter state pointer. | ||
1978 | * fcport: FC port structure pointer. | ||
1979 | * | ||
1980 | * Returns: | ||
1981 | * qla2x00 local function return status code. | ||
1982 | * | ||
1983 | * Context: | ||
1984 | * Kernel context. | ||
1985 | */ | ||
1986 | static int | ||
1987 | qla2x00_rpt_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport, | ||
1988 | inq_cmd_rsp_t *inq, dma_addr_t inq_dma) | ||
1989 | { | ||
1990 | int rval; | ||
1991 | uint32_t len, cnt; | ||
1992 | uint16_t lun; | ||
1993 | |||
1994 | /* Assume a failed status */ | ||
1995 | rval = QLA_FUNCTION_FAILED; | ||
1996 | |||
1997 | /* No point in continuing if the device doesn't support RLC */ | ||
1998 | if ((fcport->flags & FCF_RLC_SUPPORT) == 0) | ||
1999 | return (rval); | ||
2000 | |||
2001 | rval = qla2x00_report_lun(ha, fcport); | ||
2002 | if (rval != QLA_SUCCESS) | ||
2003 | return (rval); | ||
2004 | |||
2005 | /* Configure LUN list. */ | ||
2006 | len = be32_to_cpu(ha->rlc_rsp->list.hdr.len); | ||
2007 | len /= 8; | ||
2008 | for (cnt = 0; cnt < len; cnt++) { | ||
2009 | lun = CHAR_TO_SHORT(ha->rlc_rsp->list.lst[cnt].lsb, | ||
2010 | ha->rlc_rsp->list.lst[cnt].msb.b); | ||
2011 | |||
2012 | DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun)); | ||
2013 | |||
2014 | /* We only support 0 through MAX_LUNS-1 range */ | ||
2015 | if (lun < MAX_LUNS) { | ||
2016 | qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma); | ||
2017 | } | ||
2018 | } | ||
2019 | atomic_set(&fcport->state, FCS_ONLINE); | 1889 | atomic_set(&fcport->state, FCS_ONLINE); |
2020 | 1890 | ||
2021 | return (rval); | 1891 | if (ha->flags.init_done) |
2022 | } | 1892 | qla2x00_reg_remote_port(ha, fcport); |
2023 | |||
2024 | /* | ||
2025 | * qla2x00_report_lun | ||
2026 | * Issue SCSI report LUN command. | ||
2027 | * | ||
2028 | * Input: | ||
2029 | * ha: adapter state pointer. | ||
2030 | * fcport: FC port structure pointer. | ||
2031 | * | ||
2032 | * Returns: | ||
2033 | * qla2x00 local function return status code. | ||
2034 | * | ||
2035 | * Context: | ||
2036 | * Kernel context. | ||
2037 | */ | ||
2038 | static int | ||
2039 | qla2x00_report_lun(scsi_qla_host_t *ha, fc_port_t *fcport) | ||
2040 | { | ||
2041 | int rval; | ||
2042 | uint16_t retries; | ||
2043 | uint16_t comp_status; | ||
2044 | uint16_t scsi_status; | ||
2045 | rpt_lun_cmd_rsp_t *rlc; | ||
2046 | dma_addr_t rlc_dma; | ||
2047 | |||
2048 | rval = QLA_FUNCTION_FAILED; | ||
2049 | rlc = ha->rlc_rsp; | ||
2050 | rlc_dma = ha->rlc_rsp_dma; | ||
2051 | |||
2052 | for (retries = 3; retries; retries--) { | ||
2053 | memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t)); | ||
2054 | rlc->p.cmd.entry_type = COMMAND_A64_TYPE; | ||
2055 | rlc->p.cmd.entry_count = 1; | ||
2056 | SET_TARGET_ID(ha, rlc->p.cmd.target, fcport->loop_id); | ||
2057 | rlc->p.cmd.control_flags = | ||
2058 | __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG); | ||
2059 | rlc->p.cmd.scsi_cdb[0] = REPORT_LUNS; | ||
2060 | rlc->p.cmd.scsi_cdb[8] = MSB(sizeof(rpt_lun_lst_t)); | ||
2061 | rlc->p.cmd.scsi_cdb[9] = LSB(sizeof(rpt_lun_lst_t)); | ||
2062 | rlc->p.cmd.dseg_count = __constant_cpu_to_le16(1); | ||
2063 | rlc->p.cmd.timeout = __constant_cpu_to_le16(10); | ||
2064 | rlc->p.cmd.byte_count = | ||
2065 | __constant_cpu_to_le32(sizeof(rpt_lun_lst_t)); | ||
2066 | rlc->p.cmd.dseg_0_address[0] = cpu_to_le32( | ||
2067 | LSD(rlc_dma + sizeof(sts_entry_t))); | ||
2068 | rlc->p.cmd.dseg_0_address[1] = cpu_to_le32( | ||
2069 | MSD(rlc_dma + sizeof(sts_entry_t))); | ||
2070 | rlc->p.cmd.dseg_0_length = | ||
2071 | __constant_cpu_to_le32(sizeof(rpt_lun_lst_t)); | ||
2072 | |||
2073 | rval = qla2x00_issue_iocb(ha, rlc, rlc_dma, | ||
2074 | sizeof(rpt_lun_cmd_rsp_t)); | ||
2075 | |||
2076 | comp_status = le16_to_cpu(rlc->p.rsp.comp_status); | ||
2077 | scsi_status = le16_to_cpu(rlc->p.rsp.scsi_status); | ||
2078 | |||
2079 | if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE || | ||
2080 | scsi_status & SS_CHECK_CONDITION) { | ||
2081 | |||
2082 | /* Device underrun, treat as OK. */ | ||
2083 | if (rval == QLA_SUCCESS && | ||
2084 | comp_status == CS_DATA_UNDERRUN && | ||
2085 | scsi_status & SS_RESIDUAL_UNDER) { | ||
2086 | |||
2087 | rval = QLA_SUCCESS; | ||
2088 | break; | ||
2089 | } | ||
2090 | |||
2091 | DEBUG(printk("scsi(%ld): RLC failed to issue iocb! " | ||
2092 | "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n", | ||
2093 | ha->host_no, fcport->loop_id, fcport, rval, | ||
2094 | comp_status, scsi_status)); | ||
2095 | |||
2096 | rval = QLA_FUNCTION_FAILED; | ||
2097 | if (scsi_status & SS_CHECK_CONDITION) { | ||
2098 | DEBUG2(printk("scsi(%ld): RLC " | ||
2099 | "SS_CHECK_CONDITION Sense Data " | ||
2100 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
2101 | ha->host_no, | ||
2102 | rlc->p.rsp.req_sense_data[0], | ||
2103 | rlc->p.rsp.req_sense_data[1], | ||
2104 | rlc->p.rsp.req_sense_data[2], | ||
2105 | rlc->p.rsp.req_sense_data[3], | ||
2106 | rlc->p.rsp.req_sense_data[4], | ||
2107 | rlc->p.rsp.req_sense_data[5], | ||
2108 | rlc->p.rsp.req_sense_data[6], | ||
2109 | rlc->p.rsp.req_sense_data[7])); | ||
2110 | if (rlc->p.rsp.req_sense_data[2] == | ||
2111 | ILLEGAL_REQUEST) { | ||
2112 | fcport->flags &= ~(FCF_RLC_SUPPORT); | ||
2113 | break; | ||
2114 | } | ||
2115 | } | ||
2116 | } else { | ||
2117 | break; | ||
2118 | } | ||
2119 | } | ||
2120 | |||
2121 | return (rval); | ||
2122 | } | 1893 | } |
2123 | 1894 | ||
2124 | /* | 1895 | void |
2125 | * qla2x00_cfg_lun | 1896 | qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) |
2126 | * Configures LUN into fcport LUN list. | ||
2127 | * | ||
2128 | * Input: | ||
2129 | * fcport: FC port structure pointer. | ||
2130 | * lun: LUN number. | ||
2131 | * | ||
2132 | * Context: | ||
2133 | * Kernel context. | ||
2134 | */ | ||
2135 | static fc_lun_t * | ||
2136 | qla2x00_cfg_lun(scsi_qla_host_t *ha, fc_port_t *fcport, uint16_t lun, | ||
2137 | inq_cmd_rsp_t *inq, dma_addr_t inq_dma) | ||
2138 | { | ||
2139 | fc_lun_t *fclun; | ||
2140 | uint8_t device_type; | ||
2141 | |||
2142 | /* Bypass LUNs that failed. */ | ||
2143 | if (qla2x00_inquiry(ha, fcport, lun, inq, inq_dma) != QLA_SUCCESS) { | ||
2144 | DEBUG2(printk("scsi(%ld): Failed inquiry - loop id=0x%04x " | ||
2145 | "lun=%d\n", ha->host_no, fcport->loop_id, lun)); | ||
2146 | |||
2147 | return (NULL); | ||
2148 | } | ||
2149 | device_type = (inq->inq[0] & 0x1f); | ||
2150 | switch (device_type) { | ||
2151 | case TYPE_DISK: | ||
2152 | case TYPE_PROCESSOR: | ||
2153 | case TYPE_WORM: | ||
2154 | case TYPE_ROM: | ||
2155 | case TYPE_SCANNER: | ||
2156 | case TYPE_MOD: | ||
2157 | case TYPE_MEDIUM_CHANGER: | ||
2158 | case TYPE_ENCLOSURE: | ||
2159 | case 0x20: | ||
2160 | case 0x0C: | ||
2161 | break; | ||
2162 | case TYPE_TAPE: | ||
2163 | fcport->flags |= FCF_TAPE_PRESENT; | ||
2164 | break; | ||
2165 | default: | ||
2166 | DEBUG2(printk("scsi(%ld): Unsupported lun type -- " | ||
2167 | "loop id=0x%04x lun=%d type=%x\n", | ||
2168 | ha->host_no, fcport->loop_id, lun, device_type)); | ||
2169 | return (NULL); | ||
2170 | } | ||
2171 | |||
2172 | fcport->device_type = device_type; | ||
2173 | fclun = qla2x00_add_lun(fcport, lun); | ||
2174 | |||
2175 | if (fclun != NULL) { | ||
2176 | atomic_set(&fcport->state, FCS_ONLINE); | ||
2177 | } | ||
2178 | |||
2179 | return (fclun); | ||
2180 | } | ||
2181 | |||
2182 | /* | ||
2183 | * qla2x00_add_lun | ||
2184 | * Adds LUN to database | ||
2185 | * | ||
2186 | * Input: | ||
2187 | * fcport: FC port structure pointer. | ||
2188 | * lun: LUN number. | ||
2189 | * | ||
2190 | * Context: | ||
2191 | * Kernel context. | ||
2192 | */ | ||
2193 | static fc_lun_t * | ||
2194 | qla2x00_add_lun(fc_port_t *fcport, uint16_t lun) | ||
2195 | { | 1897 | { |
2196 | int found; | 1898 | struct fc_rport_identifiers rport_ids; |
2197 | fc_lun_t *fclun; | 1899 | struct fc_rport *rport; |
2198 | 1900 | ||
2199 | if (fcport == NULL) { | 1901 | if (fcport->rport) { |
2200 | DEBUG(printk("scsi: Unable to add lun to NULL port\n")); | 1902 | fc_remote_port_unblock(fcport->rport); |
2201 | return (NULL); | 1903 | return; |
2202 | } | ||
2203 | |||
2204 | /* Allocate LUN if not already allocated. */ | ||
2205 | found = 0; | ||
2206 | list_for_each_entry(fclun, &fcport->fcluns, list) { | ||
2207 | if (fclun->lun == lun) { | ||
2208 | found++; | ||
2209 | break; | ||
2210 | } | ||
2211 | } | ||
2212 | if (found) | ||
2213 | return (NULL); | ||
2214 | |||
2215 | fclun = kmalloc(sizeof(fc_lun_t), GFP_ATOMIC); | ||
2216 | if (fclun == NULL) { | ||
2217 | printk(KERN_WARNING | ||
2218 | "%s(): Memory Allocation failed - FCLUN\n", | ||
2219 | __func__); | ||
2220 | return (NULL); | ||
2221 | } | 1904 | } |
2222 | 1905 | ||
2223 | /* Setup LUN structure. */ | 1906 | rport_ids.node_name = be64_to_cpu(*(uint64_t *)fcport->node_name); |
2224 | memset(fclun, 0, sizeof(fc_lun_t)); | 1907 | rport_ids.port_name = be64_to_cpu(*(uint64_t *)fcport->port_name); |
2225 | fclun->lun = lun; | 1908 | rport_ids.port_id = fcport->d_id.b.domain << 16 | |
2226 | fclun->fcport = fcport; | 1909 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; |
2227 | fclun->o_fcport = fcport; | 1910 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
2228 | fclun->device_type = fcport->device_type; | 1911 | if (fcport->port_type == FCT_INITIATOR) |
2229 | atomic_set(&fcport->state, FCS_UNCONFIGURED); | 1912 | rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; |
2230 | 1913 | if (fcport->port_type == FCT_TARGET) | |
2231 | list_add_tail(&fclun->list, &fcport->fcluns); | 1914 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; |
2232 | |||
2233 | return (fclun); | ||
2234 | } | ||
2235 | |||
2236 | /* | ||
2237 | * qla2x00_inquiry | ||
2238 | * Issue SCSI inquiry command. | ||
2239 | * | ||
2240 | * Input: | ||
2241 | * ha = adapter block pointer. | ||
2242 | * fcport = FC port structure pointer. | ||
2243 | * | ||
2244 | * Return: | ||
2245 | * 0 - Success | ||
2246 | * BIT_0 - error | ||
2247 | * | ||
2248 | * Context: | ||
2249 | * Kernel context. | ||
2250 | */ | ||
2251 | static int | ||
2252 | qla2x00_inquiry(scsi_qla_host_t *ha, | ||
2253 | fc_port_t *fcport, uint16_t lun, inq_cmd_rsp_t *inq, dma_addr_t inq_dma) | ||
2254 | { | ||
2255 | int rval; | ||
2256 | uint16_t retries; | ||
2257 | uint16_t comp_status; | ||
2258 | uint16_t scsi_status; | ||
2259 | |||
2260 | rval = QLA_FUNCTION_FAILED; | ||
2261 | 1915 | ||
2262 | for (retries = 3; retries; retries--) { | 1916 | fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids); |
2263 | memset(inq, 0, sizeof(inq_cmd_rsp_t)); | 1917 | if (!rport) |
2264 | inq->p.cmd.entry_type = COMMAND_A64_TYPE; | 1918 | qla_printk(KERN_WARNING, ha, |
2265 | inq->p.cmd.entry_count = 1; | 1919 | "Unable to allocate fc remote port!\n"); |
2266 | inq->p.cmd.lun = cpu_to_le16(lun); | ||
2267 | SET_TARGET_ID(ha, inq->p.cmd.target, fcport->loop_id); | ||
2268 | inq->p.cmd.control_flags = | ||
2269 | __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG); | ||
2270 | inq->p.cmd.scsi_cdb[0] = INQUIRY; | ||
2271 | inq->p.cmd.scsi_cdb[4] = INQ_DATA_SIZE; | ||
2272 | inq->p.cmd.dseg_count = __constant_cpu_to_le16(1); | ||
2273 | inq->p.cmd.timeout = __constant_cpu_to_le16(10); | ||
2274 | inq->p.cmd.byte_count = | ||
2275 | __constant_cpu_to_le32(INQ_DATA_SIZE); | ||
2276 | inq->p.cmd.dseg_0_address[0] = cpu_to_le32( | ||
2277 | LSD(inq_dma + sizeof(sts_entry_t))); | ||
2278 | inq->p.cmd.dseg_0_address[1] = cpu_to_le32( | ||
2279 | MSD(inq_dma + sizeof(sts_entry_t))); | ||
2280 | inq->p.cmd.dseg_0_length = | ||
2281 | __constant_cpu_to_le32(INQ_DATA_SIZE); | ||
2282 | |||
2283 | DEBUG5(printk("scsi(%ld): Lun Inquiry - fcport=[%04x/%p]," | ||
2284 | " lun (%d)\n", | ||
2285 | ha->host_no, fcport->loop_id, fcport, lun)); | ||
2286 | |||
2287 | rval = qla2x00_issue_iocb(ha, inq, inq_dma, | ||
2288 | sizeof(inq_cmd_rsp_t)); | ||
2289 | |||
2290 | comp_status = le16_to_cpu(inq->p.rsp.comp_status); | ||
2291 | scsi_status = le16_to_cpu(inq->p.rsp.scsi_status); | ||
2292 | |||
2293 | DEBUG5(printk("scsi(%ld): lun (%d) inquiry - " | ||
2294 | "inq[0]= 0x%x, comp status 0x%x, scsi status 0x%x, " | ||
2295 | "rval=%d\n", | ||
2296 | ha->host_no, lun, inq->inq[0], comp_status, scsi_status, | ||
2297 | rval)); | ||
2298 | |||
2299 | if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE || | ||
2300 | scsi_status & SS_CHECK_CONDITION) { | ||
2301 | |||
2302 | DEBUG(printk("scsi(%ld): INQ failed to issue iocb! " | ||
2303 | "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n", | ||
2304 | ha->host_no, fcport->loop_id, fcport, rval, | ||
2305 | comp_status, scsi_status)); | ||
2306 | |||
2307 | if (rval == QLA_SUCCESS) | ||
2308 | rval = QLA_FUNCTION_FAILED; | ||
2309 | |||
2310 | if (scsi_status & SS_CHECK_CONDITION) { | ||
2311 | DEBUG2(printk("scsi(%ld): INQ " | ||
2312 | "SS_CHECK_CONDITION Sense Data " | ||
2313 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
2314 | ha->host_no, | ||
2315 | inq->p.rsp.req_sense_data[0], | ||
2316 | inq->p.rsp.req_sense_data[1], | ||
2317 | inq->p.rsp.req_sense_data[2], | ||
2318 | inq->p.rsp.req_sense_data[3], | ||
2319 | inq->p.rsp.req_sense_data[4], | ||
2320 | inq->p.rsp.req_sense_data[5], | ||
2321 | inq->p.rsp.req_sense_data[6], | ||
2322 | inq->p.rsp.req_sense_data[7])); | ||
2323 | } | ||
2324 | 1920 | ||
2325 | /* Device underrun drop LUN. */ | 1921 | if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS) |
2326 | if (comp_status == CS_DATA_UNDERRUN && | 1922 | fcport->os_target_id = rport->scsi_target_id; |
2327 | scsi_status & SS_RESIDUAL_UNDER) { | ||
2328 | break; | ||
2329 | } | ||
2330 | } else { | ||
2331 | break; | ||
2332 | } | ||
2333 | } | ||
2334 | 1923 | ||
2335 | return (rval); | 1924 | rport->dd_data = fcport; |
2336 | } | 1925 | } |
2337 | 1926 | ||
2338 | |||
2339 | /* | 1927 | /* |
2340 | * qla2x00_configure_fabric | 1928 | * qla2x00_configure_fabric |
2341 | * Setup SNS devices with loop ID's. | 1929 | * Setup SNS devices with loop ID's. |
@@ -2486,12 +2074,12 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2486 | break; | 2074 | break; |
2487 | } | 2075 | } |
2488 | 2076 | ||
2489 | /* Login and update database */ | ||
2490 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | ||
2491 | |||
2492 | /* Remove device from the new list and add it to DB */ | 2077 | /* Remove device from the new list and add it to DB */ |
2493 | list_del(&fcport->list); | 2078 | list_del(&fcport->list); |
2494 | list_add_tail(&fcport->list, &ha->fcports); | 2079 | list_add_tail(&fcport->list, &ha->fcports); |
2080 | |||
2081 | /* Login and update database */ | ||
2082 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | ||
2495 | } | 2083 | } |
2496 | } while (0); | 2084 | } while (0); |
2497 | 2085 | ||
@@ -2895,8 +2483,7 @@ qla2x00_device_resync(scsi_qla_host_t *ha) | |||
2895 | if (atomic_read(&fcport->state) == FCS_ONLINE) { | 2483 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
2896 | if (format != 3 || | 2484 | if (format != 3 || |
2897 | fcport->port_type != FCT_INITIATOR) { | 2485 | fcport->port_type != FCT_INITIATOR) { |
2898 | atomic_set(&fcport->state, | 2486 | qla2x00_mark_device_lost(ha, fcport, 0); |
2899 | FCS_DEVICE_LOST); | ||
2900 | } | 2487 | } |
2901 | } | 2488 | } |
2902 | fcport->flags &= ~FCF_FARP_DONE; | 2489 | fcport->flags &= ~FCF_FARP_DONE; |
@@ -3146,7 +2733,6 @@ qla2x00_loop_resync(scsi_qla_host_t *ha) | |||
3146 | wait_time && | 2733 | wait_time && |
3147 | (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))); | 2734 | (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))); |
3148 | } | 2735 | } |
3149 | qla2x00_restart_queues(ha, 1); | ||
3150 | } | 2736 | } |
3151 | 2737 | ||
3152 | if (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) { | 2738 | if (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) { |
@@ -3160,87 +2746,6 @@ qla2x00_loop_resync(scsi_qla_host_t *ha) | |||
3160 | return (rval); | 2746 | return (rval); |
3161 | } | 2747 | } |
3162 | 2748 | ||
3163 | /* | ||
3164 | * qla2x00_restart_queues | ||
3165 | * Restart device queues. | ||
3166 | * | ||
3167 | * Input: | ||
3168 | * ha = adapter block pointer. | ||
3169 | * | ||
3170 | * Context: | ||
3171 | * Kernel/Interrupt context. | ||
3172 | */ | ||
3173 | void | ||
3174 | qla2x00_restart_queues(scsi_qla_host_t *ha, uint8_t flush) | ||
3175 | { | ||
3176 | srb_t *sp; | ||
3177 | int retry_q_cnt = 0; | ||
3178 | int pending_q_cnt = 0; | ||
3179 | struct list_head *list, *temp; | ||
3180 | unsigned long flags = 0; | ||
3181 | |||
3182 | clear_bit(RESTART_QUEUES_NEEDED, &ha->dpc_flags); | ||
3183 | |||
3184 | /* start pending queue */ | ||
3185 | pending_q_cnt = ha->qthreads; | ||
3186 | if (flush) { | ||
3187 | spin_lock_irqsave(&ha->list_lock,flags); | ||
3188 | list_for_each_safe(list, temp, &ha->pending_queue) { | ||
3189 | sp = list_entry(list, srb_t, list); | ||
3190 | |||
3191 | if ((sp->flags & SRB_TAPE)) | ||
3192 | continue; | ||
3193 | |||
3194 | /* | ||
3195 | * When time expire return request back to OS as BUSY | ||
3196 | */ | ||
3197 | __del_from_pending_queue(ha, sp); | ||
3198 | sp->cmd->result = DID_BUS_BUSY << 16; | ||
3199 | sp->cmd->host_scribble = (unsigned char *)NULL; | ||
3200 | __add_to_done_queue(ha, sp); | ||
3201 | } | ||
3202 | spin_unlock_irqrestore(&ha->list_lock, flags); | ||
3203 | } else { | ||
3204 | if (!list_empty(&ha->pending_queue)) | ||
3205 | qla2x00_next(ha); | ||
3206 | } | ||
3207 | |||
3208 | /* | ||
3209 | * Clear out our retry queue | ||
3210 | */ | ||
3211 | if (flush) { | ||
3212 | spin_lock_irqsave(&ha->list_lock, flags); | ||
3213 | retry_q_cnt = ha->retry_q_cnt; | ||
3214 | list_for_each_safe(list, temp, &ha->retry_queue) { | ||
3215 | sp = list_entry(list, srb_t, list); | ||
3216 | /* when time expire return request back to OS as BUSY */ | ||
3217 | __del_from_retry_queue(ha, sp); | ||
3218 | sp->cmd->result = DID_BUS_BUSY << 16; | ||
3219 | sp->cmd->host_scribble = (unsigned char *)NULL; | ||
3220 | __add_to_done_queue(ha, sp); | ||
3221 | } | ||
3222 | spin_unlock_irqrestore(&ha->list_lock, flags); | ||
3223 | |||
3224 | DEBUG2(printk("%s(%ld): callback %d commands.\n", | ||
3225 | __func__, | ||
3226 | ha->host_no, | ||
3227 | retry_q_cnt);) | ||
3228 | } | ||
3229 | |||
3230 | DEBUG2(printk("%s(%ld): active=%ld, retry=%d, pending=%d, " | ||
3231 | "done=%ld, scsi retry=%d commands.\n", | ||
3232 | __func__, | ||
3233 | ha->host_no, | ||
3234 | ha->actthreads, | ||
3235 | ha->retry_q_cnt, | ||
3236 | pending_q_cnt, | ||
3237 | ha->done_q_cnt, | ||
3238 | ha->scsi_retry_q_cnt);) | ||
3239 | |||
3240 | if (!list_empty(&ha->done_queue)) | ||
3241 | qla2x00_done(ha); | ||
3242 | } | ||
3243 | |||
3244 | void | 2749 | void |
3245 | qla2x00_rescan_fcports(scsi_qla_host_t *ha) | 2750 | qla2x00_rescan_fcports(scsi_qla_host_t *ha) |
3246 | { | 2751 | { |
@@ -3258,396 +2763,6 @@ qla2x00_rescan_fcports(scsi_qla_host_t *ha) | |||
3258 | rescan_done = 1; | 2763 | rescan_done = 1; |
3259 | } | 2764 | } |
3260 | qla2x00_probe_for_all_luns(ha); | 2765 | qla2x00_probe_for_all_luns(ha); |
3261 | |||
3262 | /* Update OS target and lun structures if necessary. */ | ||
3263 | if (rescan_done) { | ||
3264 | qla2x00_config_os(ha); | ||
3265 | } | ||
3266 | } | ||
3267 | |||
3268 | |||
3269 | /* | ||
3270 | * qla2x00_config_os | ||
3271 | * Setup OS target and LUN structures. | ||
3272 | * | ||
3273 | * Input: | ||
3274 | * ha = adapter state pointer. | ||
3275 | * | ||
3276 | * Context: | ||
3277 | * Kernel context. | ||
3278 | */ | ||
3279 | static void | ||
3280 | qla2x00_config_os(scsi_qla_host_t *ha) | ||
3281 | { | ||
3282 | fc_port_t *fcport; | ||
3283 | fc_lun_t *fclun; | ||
3284 | os_tgt_t *tq; | ||
3285 | uint16_t tgt; | ||
3286 | |||
3287 | |||
3288 | for (tgt = 0; tgt < MAX_TARGETS; tgt++) { | ||
3289 | if ((tq = TGT_Q(ha, tgt)) == NULL) | ||
3290 | continue; | ||
3291 | |||
3292 | clear_bit(TQF_ONLINE, &tq->flags); | ||
3293 | } | ||
3294 | |||
3295 | list_for_each_entry(fcport, &ha->fcports, list) { | ||
3296 | if (atomic_read(&fcport->state) != FCS_ONLINE || | ||
3297 | fcport->port_type == FCT_INITIATOR || | ||
3298 | fcport->port_type == FCT_BROADCAST) { | ||
3299 | fcport->os_target_id = MAX_TARGETS; | ||
3300 | continue; | ||
3301 | } | ||
3302 | |||
3303 | if (fcport->flags & FCF_FO_MASKED) { | ||
3304 | continue; | ||
3305 | } | ||
3306 | |||
3307 | /* Bind FC port to OS target number. */ | ||
3308 | if (qla2x00_fcport_bind(ha, fcport) == MAX_TARGETS) { | ||
3309 | continue; | ||
3310 | } | ||
3311 | |||
3312 | /* Bind FC LUN to OS LUN number. */ | ||
3313 | list_for_each_entry(fclun, &fcport->fcluns, list) { | ||
3314 | qla2x00_fclun_bind(ha, fcport, fclun); | ||
3315 | } | ||
3316 | } | ||
3317 | } | ||
3318 | |||
3319 | /* | ||
3320 | * qla2x00_fcport_bind | ||
3321 | * Locates a target number for FC port. | ||
3322 | * | ||
3323 | * Input: | ||
3324 | * ha = adapter state pointer. | ||
3325 | * fcport = FC port structure pointer. | ||
3326 | * | ||
3327 | * Returns: | ||
3328 | * target number | ||
3329 | * | ||
3330 | * Context: | ||
3331 | * Kernel context. | ||
3332 | */ | ||
3333 | static uint16_t | ||
3334 | qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport) | ||
3335 | { | ||
3336 | int found; | ||
3337 | uint16_t tgt; | ||
3338 | os_tgt_t *tq; | ||
3339 | |||
3340 | /* Check for persistent binding. */ | ||
3341 | for (tgt = 0; tgt < MAX_TARGETS; tgt++) { | ||
3342 | if ((tq = TGT_Q(ha, tgt)) == NULL) | ||
3343 | continue; | ||
3344 | |||
3345 | found = 0; | ||
3346 | switch (ha->binding_type) { | ||
3347 | case BIND_BY_PORT_ID: | ||
3348 | if (fcport->d_id.b24 == tq->d_id.b24) { | ||
3349 | memcpy(tq->node_name, fcport->node_name, | ||
3350 | WWN_SIZE); | ||
3351 | memcpy(tq->port_name, fcport->port_name, | ||
3352 | WWN_SIZE); | ||
3353 | found++; | ||
3354 | } | ||
3355 | break; | ||
3356 | case BIND_BY_PORT_NAME: | ||
3357 | if (memcmp(fcport->port_name, tq->port_name, | ||
3358 | WWN_SIZE) == 0) { | ||
3359 | /* | ||
3360 | * In case of persistent binding, update the | ||
3361 | * WWNN. | ||
3362 | */ | ||
3363 | memcpy(tq->node_name, fcport->node_name, | ||
3364 | WWN_SIZE); | ||
3365 | found++; | ||
3366 | } | ||
3367 | break; | ||
3368 | } | ||
3369 | if (found) | ||
3370 | break; | ||
3371 | } | ||
3372 | |||
3373 | /* TODO: honor the ConfigRequired flag */ | ||
3374 | if (tgt == MAX_TARGETS) { | ||
3375 | /* Check if targetID 0 available. */ | ||
3376 | tgt = 0; | ||
3377 | |||
3378 | if (TGT_Q(ha, tgt) != NULL) { | ||
3379 | /* Locate first free target for device. */ | ||
3380 | for (tgt = 0; tgt < MAX_TARGETS; tgt++) { | ||
3381 | if (TGT_Q(ha, tgt) == NULL) { | ||
3382 | break; | ||
3383 | } | ||
3384 | } | ||
3385 | } | ||
3386 | if (tgt != MAX_TARGETS) { | ||
3387 | if ((tq = qla2x00_tgt_alloc(ha, tgt)) != NULL) { | ||
3388 | memcpy(tq->node_name, fcport->node_name, | ||
3389 | WWN_SIZE); | ||
3390 | memcpy(tq->port_name, fcport->port_name, | ||
3391 | WWN_SIZE); | ||
3392 | tq->d_id.b24 = fcport->d_id.b24; | ||
3393 | } | ||
3394 | } | ||
3395 | } | ||
3396 | |||
3397 | /* Reset target numbers incase it changed. */ | ||
3398 | fcport->os_target_id = tgt; | ||
3399 | if (tgt != MAX_TARGETS && tq != NULL) { | ||
3400 | DEBUG2(printk("scsi(%ld): Assigning target ID=%02d @ %p to " | ||
3401 | "loop id=0x%04x, port state=0x%x, port down retry=%d\n", | ||
3402 | ha->host_no, tgt, tq, fcport->loop_id, | ||
3403 | atomic_read(&fcport->state), | ||
3404 | atomic_read(&fcport->port_down_timer))); | ||
3405 | |||
3406 | fcport->tgt_queue = tq; | ||
3407 | fcport->flags |= FCF_PERSISTENT_BOUND; | ||
3408 | tq->fcport = fcport; | ||
3409 | set_bit(TQF_ONLINE, &tq->flags); | ||
3410 | tq->port_down_retry_count = ha->port_down_retry_count; | ||
3411 | } | ||
3412 | |||
3413 | if (tgt == MAX_TARGETS) { | ||
3414 | qla_printk(KERN_WARNING, ha, | ||
3415 | "Unable to bind fcport, loop_id=%x\n", fcport->loop_id); | ||
3416 | } | ||
3417 | |||
3418 | return (tgt); | ||
3419 | } | ||
3420 | |||
3421 | /* | ||
3422 | * qla2x00_fclun_bind | ||
3423 | * Binds all FC device LUNS to OS LUNS. | ||
3424 | * | ||
3425 | * Input: | ||
3426 | * ha: adapter state pointer. | ||
3427 | * fcport: FC port structure pointer. | ||
3428 | * | ||
3429 | * Returns: | ||
3430 | * target number | ||
3431 | * | ||
3432 | * Context: | ||
3433 | * Kernel context. | ||
3434 | */ | ||
3435 | static os_lun_t * | ||
3436 | qla2x00_fclun_bind(scsi_qla_host_t *ha, fc_port_t *fcport, fc_lun_t *fclun) | ||
3437 | { | ||
3438 | os_lun_t *lq; | ||
3439 | uint16_t tgt; | ||
3440 | uint16_t lun; | ||
3441 | |||
3442 | tgt = fcport->os_target_id; | ||
3443 | lun = fclun->lun; | ||
3444 | |||
3445 | /* Allocate LUNs */ | ||
3446 | if (lun >= MAX_LUNS) { | ||
3447 | DEBUG2(printk("scsi(%ld): Unable to bind lun, invalid " | ||
3448 | "lun=(%x).\n", ha->host_no, lun)); | ||
3449 | return (NULL); | ||
3450 | } | ||
3451 | |||
3452 | /* Always alloc LUN 0 so kernel will scan past LUN 0. */ | ||
3453 | if (lun != 0 && (EXT_IS_LUN_BIT_SET(&(fcport->lun_mask), lun))) { | ||
3454 | return (NULL); | ||
3455 | } | ||
3456 | |||
3457 | if ((lq = qla2x00_lun_alloc(ha, tgt, lun)) == NULL) { | ||
3458 | qla_printk(KERN_WARNING, ha, | ||
3459 | "Unable to bind fclun, loop_id=%x lun=%x\n", | ||
3460 | fcport->loop_id, lun); | ||
3461 | return (NULL); | ||
3462 | } | ||
3463 | |||
3464 | lq->fclun = fclun; | ||
3465 | |||
3466 | return (lq); | ||
3467 | } | ||
3468 | |||
3469 | /* | ||
3470 | * qla2x00_tgt_alloc | ||
3471 | * Allocate and pre-initialize target queue. | ||
3472 | * | ||
3473 | * Input: | ||
3474 | * ha = adapter block pointer. | ||
3475 | * t = SCSI target number. | ||
3476 | * | ||
3477 | * Returns: | ||
3478 | * NULL = failure | ||
3479 | * | ||
3480 | * Context: | ||
3481 | * Kernel context. | ||
3482 | */ | ||
3483 | static os_tgt_t * | ||
3484 | qla2x00_tgt_alloc(scsi_qla_host_t *ha, uint16_t tgt) | ||
3485 | { | ||
3486 | os_tgt_t *tq; | ||
3487 | |||
3488 | /* | ||
3489 | * If SCSI addressing OK, allocate TGT queue and lock. | ||
3490 | */ | ||
3491 | if (tgt >= MAX_TARGETS) { | ||
3492 | DEBUG2(printk("scsi(%ld): Unable to allocate target, invalid " | ||
3493 | "target number %d.\n", ha->host_no, tgt)); | ||
3494 | return (NULL); | ||
3495 | } | ||
3496 | |||
3497 | tq = TGT_Q(ha, tgt); | ||
3498 | if (tq == NULL) { | ||
3499 | tq = kmalloc(sizeof(os_tgt_t), GFP_ATOMIC); | ||
3500 | if (tq != NULL) { | ||
3501 | DEBUG2(printk("scsi(%ld): Alloc Target %d @ %p\n", | ||
3502 | ha->host_no, tgt, tq)); | ||
3503 | |||
3504 | memset(tq, 0, sizeof(os_tgt_t)); | ||
3505 | tq->ha = ha; | ||
3506 | |||
3507 | TGT_Q(ha, tgt) = tq; | ||
3508 | } | ||
3509 | } | ||
3510 | if (tq != NULL) { | ||
3511 | tq->port_down_retry_count = ha->port_down_retry_count; | ||
3512 | } else { | ||
3513 | qla_printk(KERN_WARNING, ha, | ||
3514 | "Unable to allocate target.\n"); | ||
3515 | ha->mem_err++; | ||
3516 | } | ||
3517 | |||
3518 | return (tq); | ||
3519 | } | ||
3520 | |||
3521 | /* | ||
3522 | * qla2x00_tgt_free | ||
3523 | * Frees target and LUN queues. | ||
3524 | * | ||
3525 | * Input: | ||
3526 | * ha = adapter block pointer. | ||
3527 | * t = SCSI target number. | ||
3528 | * | ||
3529 | * Context: | ||
3530 | * Kernel context. | ||
3531 | */ | ||
3532 | void | ||
3533 | qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t tgt) | ||
3534 | { | ||
3535 | os_tgt_t *tq; | ||
3536 | uint16_t lun; | ||
3537 | |||
3538 | /* | ||
3539 | * If SCSI addressing OK, allocate TGT queue and lock. | ||
3540 | */ | ||
3541 | if (tgt >= MAX_TARGETS) { | ||
3542 | DEBUG2(printk("scsi(%ld): Unable to de-allocate target, " | ||
3543 | "invalid target number %d.\n", ha->host_no, tgt)); | ||
3544 | |||
3545 | return; | ||
3546 | } | ||
3547 | |||
3548 | tq = TGT_Q(ha, tgt); | ||
3549 | if (tq != NULL) { | ||
3550 | TGT_Q(ha, tgt) = NULL; | ||
3551 | |||
3552 | /* Free LUN structures. */ | ||
3553 | for (lun = 0; lun < MAX_LUNS; lun++) | ||
3554 | qla2x00_lun_free(ha, tgt, lun); | ||
3555 | |||
3556 | kfree(tq); | ||
3557 | } | ||
3558 | |||
3559 | return; | ||
3560 | } | ||
3561 | |||
3562 | /* | ||
3563 | * qla2x00_lun_alloc | ||
3564 | * Allocate and initialize LUN queue. | ||
3565 | * | ||
3566 | * Input: | ||
3567 | * ha = adapter block pointer. | ||
3568 | * t = SCSI target number. | ||
3569 | * l = LUN number. | ||
3570 | * | ||
3571 | * Returns: | ||
3572 | * NULL = failure | ||
3573 | * | ||
3574 | * Context: | ||
3575 | * Kernel context. | ||
3576 | */ | ||
3577 | static os_lun_t * | ||
3578 | qla2x00_lun_alloc(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) | ||
3579 | { | ||
3580 | os_lun_t *lq; | ||
3581 | |||
3582 | /* | ||
3583 | * If SCSI addressing OK, allocate LUN queue. | ||
3584 | */ | ||
3585 | if (tgt >= MAX_TARGETS || lun >= MAX_LUNS || TGT_Q(ha, tgt) == NULL) { | ||
3586 | DEBUG2(printk("scsi(%ld): Unable to allocate lun, invalid " | ||
3587 | "parameter.\n", ha->host_no)); | ||
3588 | |||
3589 | return (NULL); | ||
3590 | } | ||
3591 | |||
3592 | lq = LUN_Q(ha, tgt, lun); | ||
3593 | if (lq == NULL) { | ||
3594 | lq = kmalloc(sizeof(os_lun_t), GFP_ATOMIC); | ||
3595 | if (lq != NULL) { | ||
3596 | DEBUG2(printk("scsi(%ld): Alloc Lun %d @ tgt %d.\n", | ||
3597 | ha->host_no, lun, tgt)); | ||
3598 | |||
3599 | memset(lq, 0, sizeof(os_lun_t)); | ||
3600 | LUN_Q(ha, tgt, lun) = lq; | ||
3601 | |||
3602 | /* | ||
3603 | * The following lun queue initialization code | ||
3604 | * must be duplicated in alloc_ioctl_mem function | ||
3605 | * for ioctl_lq. | ||
3606 | */ | ||
3607 | lq->q_state = LUN_STATE_READY; | ||
3608 | spin_lock_init(&lq->q_lock); | ||
3609 | } | ||
3610 | } | ||
3611 | |||
3612 | if (lq == NULL) { | ||
3613 | qla_printk(KERN_WARNING, ha, "Unable to allocate lun.\n"); | ||
3614 | } | ||
3615 | |||
3616 | return (lq); | ||
3617 | } | ||
3618 | |||
3619 | /* | ||
3620 | * qla2x00_lun_free | ||
3621 | * Frees LUN queue. | ||
3622 | * | ||
3623 | * Input: | ||
3624 | * ha = adapter block pointer. | ||
3625 | * t = SCSI target number. | ||
3626 | * | ||
3627 | * Context: | ||
3628 | * Kernel context. | ||
3629 | */ | ||
3630 | static void | ||
3631 | qla2x00_lun_free(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) | ||
3632 | { | ||
3633 | os_lun_t *lq; | ||
3634 | |||
3635 | /* | ||
3636 | * If SCSI addressing OK, allocate TGT queue and lock. | ||
3637 | */ | ||
3638 | if (tgt >= MAX_TARGETS || lun >= MAX_LUNS) { | ||
3639 | DEBUG2(printk("scsi(%ld): Unable to deallocate lun, invalid " | ||
3640 | "parameter.\n", ha->host_no)); | ||
3641 | |||
3642 | return; | ||
3643 | } | ||
3644 | |||
3645 | if (TGT_Q(ha, tgt) != NULL && (lq = LUN_Q(ha, tgt, lun)) != NULL) { | ||
3646 | LUN_Q(ha, tgt, lun) = NULL; | ||
3647 | kfree(lq); | ||
3648 | } | ||
3649 | |||
3650 | return; | ||
3651 | } | 2766 | } |
3652 | 2767 | ||
3653 | /* | 2768 | /* |
@@ -3697,26 +2812,10 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3697 | ha->outstanding_cmds[cnt] = NULL; | 2812 | ha->outstanding_cmds[cnt] = NULL; |
3698 | if (ha->actthreads) | 2813 | if (ha->actthreads) |
3699 | ha->actthreads--; | 2814 | ha->actthreads--; |
3700 | sp->lun_queue->out_cnt--; | ||
3701 | |||
3702 | /* | ||
3703 | * Set the cmd host_byte status depending on | ||
3704 | * whether the scsi_error_handler is | ||
3705 | * active or not. | ||
3706 | */ | ||
3707 | if (sp->flags & SRB_TAPE) { | ||
3708 | sp->cmd->result = DID_NO_CONNECT << 16; | ||
3709 | } else { | ||
3710 | if (ha->host->eh_active != EH_ACTIVE) | ||
3711 | sp->cmd->result = | ||
3712 | DID_BUS_BUSY << 16; | ||
3713 | else | ||
3714 | sp->cmd->result = | ||
3715 | DID_RESET << 16; | ||
3716 | } | ||
3717 | sp->flags = 0; | 2815 | sp->flags = 0; |
2816 | sp->cmd->result = DID_RESET << 16; | ||
3718 | sp->cmd->host_scribble = (unsigned char *)NULL; | 2817 | sp->cmd->host_scribble = (unsigned char *)NULL; |
3719 | add_to_done_queue(ha, sp); | 2818 | qla2x00_sp_compl(ha, sp); |
3720 | } | 2819 | } |
3721 | } | 2820 | } |
3722 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 2821 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
@@ -3739,11 +2838,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3739 | /* Enable ISP interrupts. */ | 2838 | /* Enable ISP interrupts. */ |
3740 | qla2x00_enable_intrs(ha); | 2839 | qla2x00_enable_intrs(ha); |
3741 | 2840 | ||
3742 | /* v2.19.5b6 Return all commands */ | ||
3743 | qla2x00_abort_queues(ha, 1); | ||
3744 | |||
3745 | /* Restart queues that may have been stopped. */ | ||
3746 | qla2x00_restart_queues(ha, 1); | ||
3747 | ha->isp_abort_cnt = 0; | 2841 | ha->isp_abort_cnt = 0; |
3748 | clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); | 2842 | clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); |
3749 | } else { /* failed the ISP abort */ | 2843 | } else { /* failed the ISP abort */ |
@@ -3758,7 +2852,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3758 | * completely. | 2852 | * completely. |
3759 | */ | 2853 | */ |
3760 | qla2x00_reset_adapter(ha); | 2854 | qla2x00_reset_adapter(ha); |
3761 | qla2x00_abort_queues(ha, 0); | ||
3762 | ha->flags.online = 0; | 2855 | ha->flags.online = 0; |
3763 | clear_bit(ISP_ABORT_RETRY, | 2856 | clear_bit(ISP_ABORT_RETRY, |
3764 | &ha->dpc_flags); | 2857 | &ha->dpc_flags); |