diff options
author | <andrew.vasquez@qlogic.com> | 2005-04-17 16:06:53 -0400 |
---|---|---|
committer | James Bottomley <jejb@titanic> | 2005-04-18 14:47:46 -0400 |
commit | bdf796210e01145fd77bbb3ae644d04f982b6c3b (patch) | |
tree | 92253748a63c51e76a70384d35119e107077b050 /drivers/scsi/qla2xxx/qla_init.c | |
parent | 8482e118afa0cb4321ab3d30b1100d27d63130c0 (diff) |
[PATCH] qla2xxx: remove lun discovery codes...
Remove internal lun discovery routines and support
structures.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_init.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 864 |
1 files changed, 16 insertions, 848 deletions
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 29b301ecd2ff..0387005fcb6d 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -45,34 +45,17 @@ static int qla2x00_init_rings(scsi_qla_host_t *); | |||
45 | static int qla2x00_fw_ready(scsi_qla_host_t *); | 45 | static int qla2x00_fw_ready(scsi_qla_host_t *); |
46 | static int qla2x00_configure_hba(scsi_qla_host_t *); | 46 | static int qla2x00_configure_hba(scsi_qla_host_t *); |
47 | static int qla2x00_nvram_config(scsi_qla_host_t *); | 47 | static int qla2x00_nvram_config(scsi_qla_host_t *); |
48 | static void qla2x00_init_tgt_map(scsi_qla_host_t *); | ||
49 | static int qla2x00_configure_loop(scsi_qla_host_t *); | 48 | static int qla2x00_configure_loop(scsi_qla_host_t *); |
50 | static int qla2x00_configure_local_loop(scsi_qla_host_t *); | 49 | static int qla2x00_configure_local_loop(scsi_qla_host_t *); |
51 | 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 *); |
52 | static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *); | ||
53 | static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *, | ||
54 | inq_cmd_rsp_t *, dma_addr_t); | ||
55 | static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *); | ||
56 | static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t, | ||
57 | inq_cmd_rsp_t *, dma_addr_t); | ||
58 | static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t); | ||
59 | static int qla2x00_inquiry(scsi_qla_host_t *, fc_port_t *, uint16_t, | ||
60 | inq_cmd_rsp_t *, dma_addr_t); | ||
61 | static int qla2x00_configure_fabric(scsi_qla_host_t *); | 51 | static int qla2x00_configure_fabric(scsi_qla_host_t *); |
62 | 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 *); |
63 | static int qla2x00_device_resync(scsi_qla_host_t *); | 53 | static int qla2x00_device_resync(scsi_qla_host_t *); |
64 | 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 *, |
65 | uint16_t *); | 55 | uint16_t *); |
66 | static void qla2x00_config_os(scsi_qla_host_t *ha); | ||
67 | static uint16_t qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport); | ||
68 | static os_lun_t * qla2x00_fclun_bind(scsi_qla_host_t *, fc_port_t *, | ||
69 | fc_lun_t *); | ||
70 | static void qla2x00_lun_free(scsi_qla_host_t *, uint16_t, uint16_t); | ||
71 | 56 | ||
72 | static int qla2x00_restart_isp(scsi_qla_host_t *); | 57 | static int qla2x00_restart_isp(scsi_qla_host_t *); |
73 | static void qla2x00_reset_adapter(scsi_qla_host_t *); | 58 | static void qla2x00_reset_adapter(scsi_qla_host_t *); |
74 | static os_tgt_t *qla2x00_tgt_alloc(scsi_qla_host_t *, uint16_t); | ||
75 | static os_lun_t *qla2x00_lun_alloc(scsi_qla_host_t *, uint16_t, uint16_t); | ||
76 | 59 | ||
77 | /****************************************************************************/ | 60 | /****************************************************************************/ |
78 | /* QLogic ISP2x00 Hardware Support Functions. */ | 61 | /* QLogic ISP2x00 Hardware Support Functions. */ |
@@ -120,9 +103,6 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha) | |||
120 | 103 | ||
121 | qla2x00_reset_chip(ha); | 104 | qla2x00_reset_chip(ha); |
122 | 105 | ||
123 | /* Initialize target map database. */ | ||
124 | qla2x00_init_tgt_map(ha); | ||
125 | |||
126 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); | 106 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); |
127 | qla2x00_nvram_config(ha); | 107 | qla2x00_nvram_config(ha); |
128 | 108 | ||
@@ -1530,25 +1510,6 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1530 | return (rval); | 1510 | return (rval); |
1531 | } | 1511 | } |
1532 | 1512 | ||
1533 | /* | ||
1534 | * qla2x00_init_tgt_map | ||
1535 | * Initializes target map. | ||
1536 | * | ||
1537 | * Input: | ||
1538 | * ha = adapter block pointer. | ||
1539 | * | ||
1540 | * Output: | ||
1541 | * TGT_Q initialized | ||
1542 | */ | ||
1543 | static void | ||
1544 | qla2x00_init_tgt_map(scsi_qla_host_t *ha) | ||
1545 | { | ||
1546 | uint32_t t; | ||
1547 | |||
1548 | for (t = 0; t < MAX_TARGETS; t++) | ||
1549 | TGT_Q(ha, t) = (os_tgt_t *)NULL; | ||
1550 | } | ||
1551 | |||
1552 | /** | 1513 | /** |
1553 | * qla2x00_alloc_fcport() - Allocate a generic fcport. | 1514 | * qla2x00_alloc_fcport() - Allocate a generic fcport. |
1554 | * @ha: HA context | 1515 | * @ha: HA context |
@@ -1573,7 +1534,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags) | |||
1573 | fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; | 1534 | fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; |
1574 | atomic_set(&fcport->state, FCS_UNCONFIGURED); | 1535 | atomic_set(&fcport->state, FCS_UNCONFIGURED); |
1575 | fcport->flags = FCF_RLC_SUPPORT; | 1536 | fcport->flags = FCF_RLC_SUPPORT; |
1576 | INIT_LIST_HEAD(&fcport->fcluns); | ||
1577 | 1537 | ||
1578 | return (fcport); | 1538 | return (fcport); |
1579 | } | 1539 | } |
@@ -1663,7 +1623,6 @@ qla2x00_configure_loop(scsi_qla_host_t *ha) | |||
1663 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | 1623 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { |
1664 | rval = QLA_FUNCTION_FAILED; | 1624 | rval = QLA_FUNCTION_FAILED; |
1665 | } else { | 1625 | } else { |
1666 | qla2x00_config_os(ha); | ||
1667 | atomic_set(&ha->loop_state, LOOP_READY); | 1626 | atomic_set(&ha->loop_state, LOOP_READY); |
1668 | 1627 | ||
1669 | DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); | 1628 | DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); |
@@ -1908,8 +1867,11 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
1908 | if (fcport->flags & FCF_TAPE_PRESENT) { | 1867 | if (fcport->flags & FCF_TAPE_PRESENT) { |
1909 | spin_lock_irqsave(&ha->hardware_lock, flags); | 1868 | spin_lock_irqsave(&ha->hardware_lock, flags); |
1910 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 1869 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { |
1870 | fc_port_t *sfcp; | ||
1871 | |||
1911 | if ((sp = ha->outstanding_cmds[index]) != 0) { | 1872 | if ((sp = ha->outstanding_cmds[index]) != 0) { |
1912 | if (sp->fclun->fcport == fcport) { | 1873 | sfcp = sp->fcport; |
1874 | if (sfcp == fcport) { | ||
1913 | atomic_set(&fcport->state, FCS_ONLINE); | 1875 | atomic_set(&fcport->state, FCS_ONLINE); |
1914 | spin_unlock_irqrestore( | 1876 | spin_unlock_irqrestore( |
1915 | &ha->hardware_lock, flags); | 1877 | &ha->hardware_lock, flags); |
@@ -1920,14 +1882,12 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
1920 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 1882 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
1921 | } | 1883 | } |
1922 | 1884 | ||
1923 | /* Do LUN discovery. */ | ||
1924 | if (fcport->port_type == FCT_INITIATOR || | 1885 | if (fcport->port_type == FCT_INITIATOR || |
1925 | fcport->port_type == FCT_BROADCAST) { | 1886 | fcport->port_type == FCT_BROADCAST) |
1926 | fcport->device_type = TYPE_PROCESSOR; | 1887 | fcport->device_type = TYPE_PROCESSOR; |
1927 | } else { | 1888 | |
1928 | qla2x00_lun_discovery(ha, fcport); | ||
1929 | } | ||
1930 | atomic_set(&fcport->state, FCS_ONLINE); | 1889 | atomic_set(&fcport->state, FCS_ONLINE); |
1890 | |||
1931 | if (ha->flags.init_done) | 1891 | if (ha->flags.init_done) |
1932 | qla2x00_reg_remote_port(ha, fcport); | 1892 | qla2x00_reg_remote_port(ha, fcport); |
1933 | } | 1893 | } |
@@ -1936,6 +1896,7 @@ void | |||
1936 | qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) | 1896 | qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) |
1937 | { | 1897 | { |
1938 | struct fc_rport_identifiers rport_ids; | 1898 | struct fc_rport_identifiers rport_ids; |
1899 | struct fc_rport *rport; | ||
1939 | 1900 | ||
1940 | if (fcport->rport) { | 1901 | if (fcport->rport) { |
1941 | fc_remote_port_unblock(fcport->rport); | 1902 | fc_remote_port_unblock(fcport->rport); |
@@ -1952,419 +1913,18 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
1952 | if (fcport->port_type == FCT_TARGET) | 1913 | if (fcport->port_type == FCT_TARGET) |
1953 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; | 1914 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; |
1954 | 1915 | ||
1955 | fcport->rport = fc_remote_port_add(ha->host, 0, &rport_ids); | 1916 | fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids); |
1956 | if (!fcport->rport) | 1917 | if (!rport) |
1957 | qla_printk(KERN_WARNING, ha, | 1918 | qla_printk(KERN_WARNING, ha, |
1958 | "Unable to allocate fc remote port!\n"); | 1919 | "Unable to allocate fc remote port!\n"); |
1959 | } | ||
1960 | /* | ||
1961 | * qla2x00_lun_discovery | ||
1962 | * Issue SCSI inquiry command for LUN discovery. | ||
1963 | * | ||
1964 | * Input: | ||
1965 | * ha: adapter state pointer. | ||
1966 | * fcport: FC port structure pointer. | ||
1967 | * | ||
1968 | * Context: | ||
1969 | * Kernel context. | ||
1970 | */ | ||
1971 | static void | ||
1972 | qla2x00_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport) | ||
1973 | { | ||
1974 | inq_cmd_rsp_t *inq; | ||
1975 | dma_addr_t inq_dma; | ||
1976 | uint16_t lun; | ||
1977 | |||
1978 | inq = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &inq_dma); | ||
1979 | if (inq == NULL) { | ||
1980 | qla_printk(KERN_WARNING, ha, | ||
1981 | "Memory Allocation failed - INQ\n"); | ||
1982 | return; | ||
1983 | } | ||
1984 | 1920 | ||
1985 | /* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */ | 1921 | if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS) |
1986 | qla2x00_add_lun(fcport, 0); | 1922 | fcport->os_target_id = rport->scsi_target_id; |
1987 | |||
1988 | /* If report LUN works, exit. */ | ||
1989 | if (qla2x00_rpt_lun_discovery(ha, fcport, inq, inq_dma) != | ||
1990 | QLA_SUCCESS) { | ||
1991 | for (lun = 0; lun < ha->max_probe_luns; lun++) { | ||
1992 | /* Configure LUN. */ | ||
1993 | qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma); | ||
1994 | } | ||
1995 | } | ||
1996 | 1923 | ||
1997 | dma_pool_free(ha->s_dma_pool, inq, inq_dma); | 1924 | rport->dd_data = fcport; |
1998 | } | 1925 | } |
1999 | 1926 | ||
2000 | /* | 1927 | /* |
2001 | * qla2x00_rpt_lun_discovery | ||
2002 | * Issue SCSI report LUN command for LUN discovery. | ||
2003 | * | ||
2004 | * Input: | ||
2005 | * ha: adapter state pointer. | ||
2006 | * fcport: FC port structure pointer. | ||
2007 | * | ||
2008 | * Returns: | ||
2009 | * qla2x00 local function return status code. | ||
2010 | * | ||
2011 | * Context: | ||
2012 | * Kernel context. | ||
2013 | */ | ||
2014 | static int | ||
2015 | qla2x00_rpt_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport, | ||
2016 | inq_cmd_rsp_t *inq, dma_addr_t inq_dma) | ||
2017 | { | ||
2018 | int rval; | ||
2019 | uint32_t len, cnt; | ||
2020 | uint16_t lun; | ||
2021 | |||
2022 | /* Assume a failed status */ | ||
2023 | rval = QLA_FUNCTION_FAILED; | ||
2024 | |||
2025 | /* No point in continuing if the device doesn't support RLC */ | ||
2026 | if ((fcport->flags & FCF_RLC_SUPPORT) == 0) | ||
2027 | return (rval); | ||
2028 | |||
2029 | rval = qla2x00_report_lun(ha, fcport); | ||
2030 | if (rval != QLA_SUCCESS) | ||
2031 | return (rval); | ||
2032 | |||
2033 | /* Configure LUN list. */ | ||
2034 | len = be32_to_cpu(ha->rlc_rsp->list.hdr.len); | ||
2035 | len /= 8; | ||
2036 | for (cnt = 0; cnt < len; cnt++) { | ||
2037 | lun = CHAR_TO_SHORT(ha->rlc_rsp->list.lst[cnt].lsb, | ||
2038 | ha->rlc_rsp->list.lst[cnt].msb.b); | ||
2039 | |||
2040 | DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun)); | ||
2041 | |||
2042 | /* We only support 0 through MAX_LUNS-1 range */ | ||
2043 | if (lun < MAX_LUNS) { | ||
2044 | qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma); | ||
2045 | } | ||
2046 | } | ||
2047 | atomic_set(&fcport->state, FCS_ONLINE); | ||
2048 | |||
2049 | return (rval); | ||
2050 | } | ||
2051 | |||
2052 | /* | ||
2053 | * qla2x00_report_lun | ||
2054 | * Issue SCSI report LUN command. | ||
2055 | * | ||
2056 | * Input: | ||
2057 | * ha: adapter state pointer. | ||
2058 | * fcport: FC port structure pointer. | ||
2059 | * | ||
2060 | * Returns: | ||
2061 | * qla2x00 local function return status code. | ||
2062 | * | ||
2063 | * Context: | ||
2064 | * Kernel context. | ||
2065 | */ | ||
2066 | static int | ||
2067 | qla2x00_report_lun(scsi_qla_host_t *ha, fc_port_t *fcport) | ||
2068 | { | ||
2069 | int rval; | ||
2070 | uint16_t retries; | ||
2071 | uint16_t comp_status; | ||
2072 | uint16_t scsi_status; | ||
2073 | rpt_lun_cmd_rsp_t *rlc; | ||
2074 | dma_addr_t rlc_dma; | ||
2075 | |||
2076 | rval = QLA_FUNCTION_FAILED; | ||
2077 | rlc = ha->rlc_rsp; | ||
2078 | rlc_dma = ha->rlc_rsp_dma; | ||
2079 | |||
2080 | for (retries = 3; retries; retries--) { | ||
2081 | memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t)); | ||
2082 | rlc->p.cmd.entry_type = COMMAND_A64_TYPE; | ||
2083 | rlc->p.cmd.entry_count = 1; | ||
2084 | SET_TARGET_ID(ha, rlc->p.cmd.target, fcport->loop_id); | ||
2085 | rlc->p.cmd.control_flags = | ||
2086 | __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG); | ||
2087 | rlc->p.cmd.scsi_cdb[0] = REPORT_LUNS; | ||
2088 | rlc->p.cmd.scsi_cdb[8] = MSB(sizeof(rpt_lun_lst_t)); | ||
2089 | rlc->p.cmd.scsi_cdb[9] = LSB(sizeof(rpt_lun_lst_t)); | ||
2090 | rlc->p.cmd.dseg_count = __constant_cpu_to_le16(1); | ||
2091 | rlc->p.cmd.timeout = __constant_cpu_to_le16(10); | ||
2092 | rlc->p.cmd.byte_count = | ||
2093 | __constant_cpu_to_le32(sizeof(rpt_lun_lst_t)); | ||
2094 | rlc->p.cmd.dseg_0_address[0] = cpu_to_le32( | ||
2095 | LSD(rlc_dma + sizeof(sts_entry_t))); | ||
2096 | rlc->p.cmd.dseg_0_address[1] = cpu_to_le32( | ||
2097 | MSD(rlc_dma + sizeof(sts_entry_t))); | ||
2098 | rlc->p.cmd.dseg_0_length = | ||
2099 | __constant_cpu_to_le32(sizeof(rpt_lun_lst_t)); | ||
2100 | |||
2101 | rval = qla2x00_issue_iocb(ha, rlc, rlc_dma, | ||
2102 | sizeof(rpt_lun_cmd_rsp_t)); | ||
2103 | |||
2104 | comp_status = le16_to_cpu(rlc->p.rsp.comp_status); | ||
2105 | scsi_status = le16_to_cpu(rlc->p.rsp.scsi_status); | ||
2106 | |||
2107 | if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE || | ||
2108 | scsi_status & SS_CHECK_CONDITION) { | ||
2109 | |||
2110 | /* Device underrun, treat as OK. */ | ||
2111 | if (rval == QLA_SUCCESS && | ||
2112 | comp_status == CS_DATA_UNDERRUN && | ||
2113 | scsi_status & SS_RESIDUAL_UNDER) { | ||
2114 | |||
2115 | rval = QLA_SUCCESS; | ||
2116 | break; | ||
2117 | } | ||
2118 | |||
2119 | DEBUG(printk("scsi(%ld): RLC failed to issue iocb! " | ||
2120 | "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n", | ||
2121 | ha->host_no, fcport->loop_id, fcport, rval, | ||
2122 | comp_status, scsi_status)); | ||
2123 | |||
2124 | rval = QLA_FUNCTION_FAILED; | ||
2125 | if (scsi_status & SS_CHECK_CONDITION) { | ||
2126 | DEBUG2(printk("scsi(%ld): RLC " | ||
2127 | "SS_CHECK_CONDITION Sense Data " | ||
2128 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
2129 | ha->host_no, | ||
2130 | rlc->p.rsp.req_sense_data[0], | ||
2131 | rlc->p.rsp.req_sense_data[1], | ||
2132 | rlc->p.rsp.req_sense_data[2], | ||
2133 | rlc->p.rsp.req_sense_data[3], | ||
2134 | rlc->p.rsp.req_sense_data[4], | ||
2135 | rlc->p.rsp.req_sense_data[5], | ||
2136 | rlc->p.rsp.req_sense_data[6], | ||
2137 | rlc->p.rsp.req_sense_data[7])); | ||
2138 | if (rlc->p.rsp.req_sense_data[2] == | ||
2139 | ILLEGAL_REQUEST) { | ||
2140 | fcport->flags &= ~(FCF_RLC_SUPPORT); | ||
2141 | break; | ||
2142 | } | ||
2143 | } | ||
2144 | } else { | ||
2145 | break; | ||
2146 | } | ||
2147 | } | ||
2148 | |||
2149 | return (rval); | ||
2150 | } | ||
2151 | |||
2152 | /* | ||
2153 | * qla2x00_cfg_lun | ||
2154 | * Configures LUN into fcport LUN list. | ||
2155 | * | ||
2156 | * Input: | ||
2157 | * fcport: FC port structure pointer. | ||
2158 | * lun: LUN number. | ||
2159 | * | ||
2160 | * Context: | ||
2161 | * Kernel context. | ||
2162 | */ | ||
2163 | static fc_lun_t * | ||
2164 | qla2x00_cfg_lun(scsi_qla_host_t *ha, fc_port_t *fcport, uint16_t lun, | ||
2165 | inq_cmd_rsp_t *inq, dma_addr_t inq_dma) | ||
2166 | { | ||
2167 | fc_lun_t *fclun; | ||
2168 | uint8_t device_type; | ||
2169 | |||
2170 | /* Bypass LUNs that failed. */ | ||
2171 | if (qla2x00_inquiry(ha, fcport, lun, inq, inq_dma) != QLA_SUCCESS) { | ||
2172 | DEBUG2(printk("scsi(%ld): Failed inquiry - loop id=0x%04x " | ||
2173 | "lun=%d\n", ha->host_no, fcport->loop_id, lun)); | ||
2174 | |||
2175 | return (NULL); | ||
2176 | } | ||
2177 | device_type = (inq->inq[0] & 0x1f); | ||
2178 | switch (device_type) { | ||
2179 | case TYPE_DISK: | ||
2180 | case TYPE_PROCESSOR: | ||
2181 | case TYPE_WORM: | ||
2182 | case TYPE_ROM: | ||
2183 | case TYPE_SCANNER: | ||
2184 | case TYPE_MOD: | ||
2185 | case TYPE_MEDIUM_CHANGER: | ||
2186 | case TYPE_ENCLOSURE: | ||
2187 | case 0x20: | ||
2188 | case 0x0C: | ||
2189 | break; | ||
2190 | case TYPE_TAPE: | ||
2191 | fcport->flags |= FCF_TAPE_PRESENT; | ||
2192 | break; | ||
2193 | default: | ||
2194 | DEBUG2(printk("scsi(%ld): Unsupported lun type -- " | ||
2195 | "loop id=0x%04x lun=%d type=%x\n", | ||
2196 | ha->host_no, fcport->loop_id, lun, device_type)); | ||
2197 | return (NULL); | ||
2198 | } | ||
2199 | |||
2200 | fcport->device_type = device_type; | ||
2201 | fclun = qla2x00_add_lun(fcport, lun); | ||
2202 | |||
2203 | if (fclun != NULL) { | ||
2204 | atomic_set(&fcport->state, FCS_ONLINE); | ||
2205 | } | ||
2206 | |||
2207 | return (fclun); | ||
2208 | } | ||
2209 | |||
2210 | /* | ||
2211 | * qla2x00_add_lun | ||
2212 | * Adds LUN to database | ||
2213 | * | ||
2214 | * Input: | ||
2215 | * fcport: FC port structure pointer. | ||
2216 | * lun: LUN number. | ||
2217 | * | ||
2218 | * Context: | ||
2219 | * Kernel context. | ||
2220 | */ | ||
2221 | static fc_lun_t * | ||
2222 | qla2x00_add_lun(fc_port_t *fcport, uint16_t lun) | ||
2223 | { | ||
2224 | int found; | ||
2225 | fc_lun_t *fclun; | ||
2226 | |||
2227 | if (fcport == NULL) { | ||
2228 | DEBUG(printk("scsi: Unable to add lun to NULL port\n")); | ||
2229 | return (NULL); | ||
2230 | } | ||
2231 | |||
2232 | /* Allocate LUN if not already allocated. */ | ||
2233 | found = 0; | ||
2234 | list_for_each_entry(fclun, &fcport->fcluns, list) { | ||
2235 | if (fclun->lun == lun) { | ||
2236 | found++; | ||
2237 | break; | ||
2238 | } | ||
2239 | } | ||
2240 | if (found) | ||
2241 | return (NULL); | ||
2242 | |||
2243 | fclun = kmalloc(sizeof(fc_lun_t), GFP_ATOMIC); | ||
2244 | if (fclun == NULL) { | ||
2245 | printk(KERN_WARNING | ||
2246 | "%s(): Memory Allocation failed - FCLUN\n", | ||
2247 | __func__); | ||
2248 | return (NULL); | ||
2249 | } | ||
2250 | |||
2251 | /* Setup LUN structure. */ | ||
2252 | memset(fclun, 0, sizeof(fc_lun_t)); | ||
2253 | fclun->lun = lun; | ||
2254 | fclun->fcport = fcport; | ||
2255 | fclun->o_fcport = fcport; | ||
2256 | fclun->device_type = fcport->device_type; | ||
2257 | atomic_set(&fcport->state, FCS_UNCONFIGURED); | ||
2258 | |||
2259 | list_add_tail(&fclun->list, &fcport->fcluns); | ||
2260 | |||
2261 | return (fclun); | ||
2262 | } | ||
2263 | |||
2264 | /* | ||
2265 | * qla2x00_inquiry | ||
2266 | * Issue SCSI inquiry command. | ||
2267 | * | ||
2268 | * Input: | ||
2269 | * ha = adapter block pointer. | ||
2270 | * fcport = FC port structure pointer. | ||
2271 | * | ||
2272 | * Return: | ||
2273 | * 0 - Success | ||
2274 | * BIT_0 - error | ||
2275 | * | ||
2276 | * Context: | ||
2277 | * Kernel context. | ||
2278 | */ | ||
2279 | static int | ||
2280 | qla2x00_inquiry(scsi_qla_host_t *ha, | ||
2281 | fc_port_t *fcport, uint16_t lun, inq_cmd_rsp_t *inq, dma_addr_t inq_dma) | ||
2282 | { | ||
2283 | int rval; | ||
2284 | uint16_t retries; | ||
2285 | uint16_t comp_status; | ||
2286 | uint16_t scsi_status; | ||
2287 | |||
2288 | rval = QLA_FUNCTION_FAILED; | ||
2289 | |||
2290 | for (retries = 3; retries; retries--) { | ||
2291 | memset(inq, 0, sizeof(inq_cmd_rsp_t)); | ||
2292 | inq->p.cmd.entry_type = COMMAND_A64_TYPE; | ||
2293 | inq->p.cmd.entry_count = 1; | ||
2294 | inq->p.cmd.lun = cpu_to_le16(lun); | ||
2295 | SET_TARGET_ID(ha, inq->p.cmd.target, fcport->loop_id); | ||
2296 | inq->p.cmd.control_flags = | ||
2297 | __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG); | ||
2298 | inq->p.cmd.scsi_cdb[0] = INQUIRY; | ||
2299 | inq->p.cmd.scsi_cdb[4] = INQ_DATA_SIZE; | ||
2300 | inq->p.cmd.dseg_count = __constant_cpu_to_le16(1); | ||
2301 | inq->p.cmd.timeout = __constant_cpu_to_le16(10); | ||
2302 | inq->p.cmd.byte_count = | ||
2303 | __constant_cpu_to_le32(INQ_DATA_SIZE); | ||
2304 | inq->p.cmd.dseg_0_address[0] = cpu_to_le32( | ||
2305 | LSD(inq_dma + sizeof(sts_entry_t))); | ||
2306 | inq->p.cmd.dseg_0_address[1] = cpu_to_le32( | ||
2307 | MSD(inq_dma + sizeof(sts_entry_t))); | ||
2308 | inq->p.cmd.dseg_0_length = | ||
2309 | __constant_cpu_to_le32(INQ_DATA_SIZE); | ||
2310 | |||
2311 | DEBUG5(printk("scsi(%ld): Lun Inquiry - fcport=[%04x/%p]," | ||
2312 | " lun (%d)\n", | ||
2313 | ha->host_no, fcport->loop_id, fcport, lun)); | ||
2314 | |||
2315 | rval = qla2x00_issue_iocb(ha, inq, inq_dma, | ||
2316 | sizeof(inq_cmd_rsp_t)); | ||
2317 | |||
2318 | comp_status = le16_to_cpu(inq->p.rsp.comp_status); | ||
2319 | scsi_status = le16_to_cpu(inq->p.rsp.scsi_status); | ||
2320 | |||
2321 | DEBUG5(printk("scsi(%ld): lun (%d) inquiry - " | ||
2322 | "inq[0]= 0x%x, comp status 0x%x, scsi status 0x%x, " | ||
2323 | "rval=%d\n", | ||
2324 | ha->host_no, lun, inq->inq[0], comp_status, scsi_status, | ||
2325 | rval)); | ||
2326 | |||
2327 | if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE || | ||
2328 | scsi_status & SS_CHECK_CONDITION) { | ||
2329 | |||
2330 | DEBUG(printk("scsi(%ld): INQ failed to issue iocb! " | ||
2331 | "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n", | ||
2332 | ha->host_no, fcport->loop_id, fcport, rval, | ||
2333 | comp_status, scsi_status)); | ||
2334 | |||
2335 | if (rval == QLA_SUCCESS) | ||
2336 | rval = QLA_FUNCTION_FAILED; | ||
2337 | |||
2338 | if (scsi_status & SS_CHECK_CONDITION) { | ||
2339 | DEBUG2(printk("scsi(%ld): INQ " | ||
2340 | "SS_CHECK_CONDITION Sense Data " | ||
2341 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
2342 | ha->host_no, | ||
2343 | inq->p.rsp.req_sense_data[0], | ||
2344 | inq->p.rsp.req_sense_data[1], | ||
2345 | inq->p.rsp.req_sense_data[2], | ||
2346 | inq->p.rsp.req_sense_data[3], | ||
2347 | inq->p.rsp.req_sense_data[4], | ||
2348 | inq->p.rsp.req_sense_data[5], | ||
2349 | inq->p.rsp.req_sense_data[6], | ||
2350 | inq->p.rsp.req_sense_data[7])); | ||
2351 | } | ||
2352 | |||
2353 | /* Device underrun drop LUN. */ | ||
2354 | if (comp_status == CS_DATA_UNDERRUN && | ||
2355 | scsi_status & SS_RESIDUAL_UNDER) { | ||
2356 | break; | ||
2357 | } | ||
2358 | } else { | ||
2359 | break; | ||
2360 | } | ||
2361 | } | ||
2362 | |||
2363 | return (rval); | ||
2364 | } | ||
2365 | |||
2366 | |||
2367 | /* | ||
2368 | * qla2x00_configure_fabric | 1928 | * qla2x00_configure_fabric |
2369 | * Setup SNS devices with loop ID's. | 1929 | * Setup SNS devices with loop ID's. |
2370 | * | 1930 | * |
@@ -2514,12 +2074,12 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2514 | break; | 2074 | break; |
2515 | } | 2075 | } |
2516 | 2076 | ||
2517 | /* Login and update database */ | ||
2518 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | ||
2519 | |||
2520 | /* Remove device from the new list and add it to DB */ | 2077 | /* Remove device from the new list and add it to DB */ |
2521 | list_del(&fcport->list); | 2078 | list_del(&fcport->list); |
2522 | 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); | ||
2523 | } | 2083 | } |
2524 | } while (0); | 2084 | } while (0); |
2525 | 2085 | ||
@@ -3203,396 +2763,6 @@ qla2x00_rescan_fcports(scsi_qla_host_t *ha) | |||
3203 | rescan_done = 1; | 2763 | rescan_done = 1; |
3204 | } | 2764 | } |
3205 | qla2x00_probe_for_all_luns(ha); | 2765 | qla2x00_probe_for_all_luns(ha); |
3206 | |||
3207 | /* Update OS target and lun structures if necessary. */ | ||
3208 | if (rescan_done) { | ||
3209 | qla2x00_config_os(ha); | ||
3210 | } | ||
3211 | } | ||
3212 | |||
3213 | |||
3214 | /* | ||
3215 | * qla2x00_config_os | ||
3216 | * Setup OS target and LUN structures. | ||
3217 | * | ||
3218 | * Input: | ||
3219 | * ha = adapter state pointer. | ||
3220 | * | ||
3221 | * Context: | ||
3222 | * Kernel context. | ||
3223 | */ | ||
3224 | static void | ||
3225 | qla2x00_config_os(scsi_qla_host_t *ha) | ||
3226 | { | ||
3227 | fc_port_t *fcport; | ||
3228 | fc_lun_t *fclun; | ||
3229 | os_tgt_t *tq; | ||
3230 | uint16_t tgt; | ||
3231 | |||
3232 | |||
3233 | for (tgt = 0; tgt < MAX_TARGETS; tgt++) { | ||
3234 | if ((tq = TGT_Q(ha, tgt)) == NULL) | ||
3235 | continue; | ||
3236 | |||
3237 | clear_bit(TQF_ONLINE, &tq->flags); | ||
3238 | } | ||
3239 | |||
3240 | list_for_each_entry(fcport, &ha->fcports, list) { | ||
3241 | if (atomic_read(&fcport->state) != FCS_ONLINE || | ||
3242 | fcport->port_type == FCT_INITIATOR || | ||
3243 | fcport->port_type == FCT_BROADCAST) { | ||
3244 | fcport->os_target_id = MAX_TARGETS; | ||
3245 | continue; | ||
3246 | } | ||
3247 | |||
3248 | if (fcport->flags & FCF_FO_MASKED) { | ||
3249 | continue; | ||
3250 | } | ||
3251 | |||
3252 | /* Bind FC port to OS target number. */ | ||
3253 | if (qla2x00_fcport_bind(ha, fcport) == MAX_TARGETS) { | ||
3254 | continue; | ||
3255 | } | ||
3256 | |||
3257 | /* Bind FC LUN to OS LUN number. */ | ||
3258 | list_for_each_entry(fclun, &fcport->fcluns, list) { | ||
3259 | qla2x00_fclun_bind(ha, fcport, fclun); | ||
3260 | } | ||
3261 | } | ||
3262 | } | ||
3263 | |||
3264 | /* | ||
3265 | * qla2x00_fcport_bind | ||
3266 | * Locates a target number for FC port. | ||
3267 | * | ||
3268 | * Input: | ||
3269 | * ha = adapter state pointer. | ||
3270 | * fcport = FC port structure pointer. | ||
3271 | * | ||
3272 | * Returns: | ||
3273 | * target number | ||
3274 | * | ||
3275 | * Context: | ||
3276 | * Kernel context. | ||
3277 | */ | ||
3278 | static uint16_t | ||
3279 | qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport) | ||
3280 | { | ||
3281 | int found; | ||
3282 | uint16_t tgt; | ||
3283 | os_tgt_t *tq; | ||
3284 | |||
3285 | /* Check for persistent binding. */ | ||
3286 | for (tgt = 0; tgt < MAX_TARGETS; tgt++) { | ||
3287 | if ((tq = TGT_Q(ha, tgt)) == NULL) | ||
3288 | continue; | ||
3289 | |||
3290 | found = 0; | ||
3291 | switch (ha->binding_type) { | ||
3292 | case BIND_BY_PORT_ID: | ||
3293 | if (fcport->d_id.b24 == tq->d_id.b24) { | ||
3294 | memcpy(tq->node_name, fcport->node_name, | ||
3295 | WWN_SIZE); | ||
3296 | memcpy(tq->port_name, fcport->port_name, | ||
3297 | WWN_SIZE); | ||
3298 | found++; | ||
3299 | } | ||
3300 | break; | ||
3301 | case BIND_BY_PORT_NAME: | ||
3302 | if (memcmp(fcport->port_name, tq->port_name, | ||
3303 | WWN_SIZE) == 0) { | ||
3304 | /* | ||
3305 | * In case of persistent binding, update the | ||
3306 | * WWNN. | ||
3307 | */ | ||
3308 | memcpy(tq->node_name, fcport->node_name, | ||
3309 | WWN_SIZE); | ||
3310 | found++; | ||
3311 | } | ||
3312 | break; | ||
3313 | } | ||
3314 | if (found) | ||
3315 | break; | ||
3316 | } | ||
3317 | |||
3318 | /* TODO: honor the ConfigRequired flag */ | ||
3319 | if (tgt == MAX_TARGETS) { | ||
3320 | /* Check if targetID 0 available. */ | ||
3321 | tgt = 0; | ||
3322 | |||
3323 | if (TGT_Q(ha, tgt) != NULL) { | ||
3324 | /* Locate first free target for device. */ | ||
3325 | for (tgt = 0; tgt < MAX_TARGETS; tgt++) { | ||
3326 | if (TGT_Q(ha, tgt) == NULL) { | ||
3327 | break; | ||
3328 | } | ||
3329 | } | ||
3330 | } | ||
3331 | if (tgt != MAX_TARGETS) { | ||
3332 | if ((tq = qla2x00_tgt_alloc(ha, tgt)) != NULL) { | ||
3333 | memcpy(tq->node_name, fcport->node_name, | ||
3334 | WWN_SIZE); | ||
3335 | memcpy(tq->port_name, fcport->port_name, | ||
3336 | WWN_SIZE); | ||
3337 | tq->d_id.b24 = fcport->d_id.b24; | ||
3338 | } | ||
3339 | } | ||
3340 | } | ||
3341 | |||
3342 | /* Reset target numbers incase it changed. */ | ||
3343 | fcport->os_target_id = tgt; | ||
3344 | if (tgt != MAX_TARGETS && tq != NULL) { | ||
3345 | DEBUG2(printk("scsi(%ld): Assigning target ID=%02d @ %p to " | ||
3346 | "loop id=0x%04x, port state=0x%x, port down retry=%d\n", | ||
3347 | ha->host_no, tgt, tq, fcport->loop_id, | ||
3348 | atomic_read(&fcport->state), | ||
3349 | atomic_read(&fcport->port_down_timer))); | ||
3350 | |||
3351 | fcport->tgt_queue = tq; | ||
3352 | fcport->flags |= FCF_PERSISTENT_BOUND; | ||
3353 | tq->fcport = fcport; | ||
3354 | set_bit(TQF_ONLINE, &tq->flags); | ||
3355 | tq->port_down_retry_count = ha->port_down_retry_count; | ||
3356 | } | ||
3357 | |||
3358 | if (tgt == MAX_TARGETS) { | ||
3359 | qla_printk(KERN_WARNING, ha, | ||
3360 | "Unable to bind fcport, loop_id=%x\n", fcport->loop_id); | ||
3361 | } | ||
3362 | |||
3363 | return (tgt); | ||
3364 | } | ||
3365 | |||
3366 | /* | ||
3367 | * qla2x00_fclun_bind | ||
3368 | * Binds all FC device LUNS to OS LUNS. | ||
3369 | * | ||
3370 | * Input: | ||
3371 | * ha: adapter state pointer. | ||
3372 | * fcport: FC port structure pointer. | ||
3373 | * | ||
3374 | * Returns: | ||
3375 | * target number | ||
3376 | * | ||
3377 | * Context: | ||
3378 | * Kernel context. | ||
3379 | */ | ||
3380 | static os_lun_t * | ||
3381 | qla2x00_fclun_bind(scsi_qla_host_t *ha, fc_port_t *fcport, fc_lun_t *fclun) | ||
3382 | { | ||
3383 | os_lun_t *lq; | ||
3384 | uint16_t tgt; | ||
3385 | uint16_t lun; | ||
3386 | |||
3387 | tgt = fcport->os_target_id; | ||
3388 | lun = fclun->lun; | ||
3389 | |||
3390 | /* Allocate LUNs */ | ||
3391 | if (lun >= MAX_LUNS) { | ||
3392 | DEBUG2(printk("scsi(%ld): Unable to bind lun, invalid " | ||
3393 | "lun=(%x).\n", ha->host_no, lun)); | ||
3394 | return (NULL); | ||
3395 | } | ||
3396 | |||
3397 | /* Always alloc LUN 0 so kernel will scan past LUN 0. */ | ||
3398 | if (lun != 0 && (EXT_IS_LUN_BIT_SET(&(fcport->lun_mask), lun))) { | ||
3399 | return (NULL); | ||
3400 | } | ||
3401 | |||
3402 | if ((lq = qla2x00_lun_alloc(ha, tgt, lun)) == NULL) { | ||
3403 | qla_printk(KERN_WARNING, ha, | ||
3404 | "Unable to bind fclun, loop_id=%x lun=%x\n", | ||
3405 | fcport->loop_id, lun); | ||
3406 | return (NULL); | ||
3407 | } | ||
3408 | |||
3409 | lq->fclun = fclun; | ||
3410 | |||
3411 | return (lq); | ||
3412 | } | ||
3413 | |||
3414 | /* | ||
3415 | * qla2x00_tgt_alloc | ||
3416 | * Allocate and pre-initialize target queue. | ||
3417 | * | ||
3418 | * Input: | ||
3419 | * ha = adapter block pointer. | ||
3420 | * t = SCSI target number. | ||
3421 | * | ||
3422 | * Returns: | ||
3423 | * NULL = failure | ||
3424 | * | ||
3425 | * Context: | ||
3426 | * Kernel context. | ||
3427 | */ | ||
3428 | static os_tgt_t * | ||
3429 | qla2x00_tgt_alloc(scsi_qla_host_t *ha, uint16_t tgt) | ||
3430 | { | ||
3431 | os_tgt_t *tq; | ||
3432 | |||
3433 | /* | ||
3434 | * If SCSI addressing OK, allocate TGT queue and lock. | ||
3435 | */ | ||
3436 | if (tgt >= MAX_TARGETS) { | ||
3437 | DEBUG2(printk("scsi(%ld): Unable to allocate target, invalid " | ||
3438 | "target number %d.\n", ha->host_no, tgt)); | ||
3439 | return (NULL); | ||
3440 | } | ||
3441 | |||
3442 | tq = TGT_Q(ha, tgt); | ||
3443 | if (tq == NULL) { | ||
3444 | tq = kmalloc(sizeof(os_tgt_t), GFP_ATOMIC); | ||
3445 | if (tq != NULL) { | ||
3446 | DEBUG2(printk("scsi(%ld): Alloc Target %d @ %p\n", | ||
3447 | ha->host_no, tgt, tq)); | ||
3448 | |||
3449 | memset(tq, 0, sizeof(os_tgt_t)); | ||
3450 | tq->ha = ha; | ||
3451 | |||
3452 | TGT_Q(ha, tgt) = tq; | ||
3453 | } | ||
3454 | } | ||
3455 | if (tq != NULL) { | ||
3456 | tq->port_down_retry_count = ha->port_down_retry_count; | ||
3457 | } else { | ||
3458 | qla_printk(KERN_WARNING, ha, | ||
3459 | "Unable to allocate target.\n"); | ||
3460 | ha->mem_err++; | ||
3461 | } | ||
3462 | |||
3463 | return (tq); | ||
3464 | } | ||
3465 | |||
3466 | /* | ||
3467 | * qla2x00_tgt_free | ||
3468 | * Frees target and LUN queues. | ||
3469 | * | ||
3470 | * Input: | ||
3471 | * ha = adapter block pointer. | ||
3472 | * t = SCSI target number. | ||
3473 | * | ||
3474 | * Context: | ||
3475 | * Kernel context. | ||
3476 | */ | ||
3477 | void | ||
3478 | qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t tgt) | ||
3479 | { | ||
3480 | os_tgt_t *tq; | ||
3481 | uint16_t lun; | ||
3482 | |||
3483 | /* | ||
3484 | * If SCSI addressing OK, allocate TGT queue and lock. | ||
3485 | */ | ||
3486 | if (tgt >= MAX_TARGETS) { | ||
3487 | DEBUG2(printk("scsi(%ld): Unable to de-allocate target, " | ||
3488 | "invalid target number %d.\n", ha->host_no, tgt)); | ||
3489 | |||
3490 | return; | ||
3491 | } | ||
3492 | |||
3493 | tq = TGT_Q(ha, tgt); | ||
3494 | if (tq != NULL) { | ||
3495 | TGT_Q(ha, tgt) = NULL; | ||
3496 | |||
3497 | /* Free LUN structures. */ | ||
3498 | for (lun = 0; lun < MAX_LUNS; lun++) | ||
3499 | qla2x00_lun_free(ha, tgt, lun); | ||
3500 | |||
3501 | kfree(tq); | ||
3502 | } | ||
3503 | |||
3504 | return; | ||
3505 | } | ||
3506 | |||
3507 | /* | ||
3508 | * qla2x00_lun_alloc | ||
3509 | * Allocate and initialize LUN queue. | ||
3510 | * | ||
3511 | * Input: | ||
3512 | * ha = adapter block pointer. | ||
3513 | * t = SCSI target number. | ||
3514 | * l = LUN number. | ||
3515 | * | ||
3516 | * Returns: | ||
3517 | * NULL = failure | ||
3518 | * | ||
3519 | * Context: | ||
3520 | * Kernel context. | ||
3521 | */ | ||
3522 | static os_lun_t * | ||
3523 | qla2x00_lun_alloc(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) | ||
3524 | { | ||
3525 | os_lun_t *lq; | ||
3526 | |||
3527 | /* | ||
3528 | * If SCSI addressing OK, allocate LUN queue. | ||
3529 | */ | ||
3530 | if (tgt >= MAX_TARGETS || lun >= MAX_LUNS || TGT_Q(ha, tgt) == NULL) { | ||
3531 | DEBUG2(printk("scsi(%ld): Unable to allocate lun, invalid " | ||
3532 | "parameter.\n", ha->host_no)); | ||
3533 | |||
3534 | return (NULL); | ||
3535 | } | ||
3536 | |||
3537 | lq = LUN_Q(ha, tgt, lun); | ||
3538 | if (lq == NULL) { | ||
3539 | lq = kmalloc(sizeof(os_lun_t), GFP_ATOMIC); | ||
3540 | if (lq != NULL) { | ||
3541 | DEBUG2(printk("scsi(%ld): Alloc Lun %d @ tgt %d.\n", | ||
3542 | ha->host_no, lun, tgt)); | ||
3543 | |||
3544 | memset(lq, 0, sizeof(os_lun_t)); | ||
3545 | LUN_Q(ha, tgt, lun) = lq; | ||
3546 | |||
3547 | /* | ||
3548 | * The following lun queue initialization code | ||
3549 | * must be duplicated in alloc_ioctl_mem function | ||
3550 | * for ioctl_lq. | ||
3551 | */ | ||
3552 | lq->q_state = LUN_STATE_READY; | ||
3553 | spin_lock_init(&lq->q_lock); | ||
3554 | } | ||
3555 | } | ||
3556 | |||
3557 | if (lq == NULL) { | ||
3558 | qla_printk(KERN_WARNING, ha, "Unable to allocate lun.\n"); | ||
3559 | } | ||
3560 | |||
3561 | return (lq); | ||
3562 | } | ||
3563 | |||
3564 | /* | ||
3565 | * qla2x00_lun_free | ||
3566 | * Frees LUN queue. | ||
3567 | * | ||
3568 | * Input: | ||
3569 | * ha = adapter block pointer. | ||
3570 | * t = SCSI target number. | ||
3571 | * | ||
3572 | * Context: | ||
3573 | * Kernel context. | ||
3574 | */ | ||
3575 | static void | ||
3576 | qla2x00_lun_free(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) | ||
3577 | { | ||
3578 | os_lun_t *lq; | ||
3579 | |||
3580 | /* | ||
3581 | * If SCSI addressing OK, allocate TGT queue and lock. | ||
3582 | */ | ||
3583 | if (tgt >= MAX_TARGETS || lun >= MAX_LUNS) { | ||
3584 | DEBUG2(printk("scsi(%ld): Unable to deallocate lun, invalid " | ||
3585 | "parameter.\n", ha->host_no)); | ||
3586 | |||
3587 | return; | ||
3588 | } | ||
3589 | |||
3590 | if (TGT_Q(ha, tgt) != NULL && (lq = LUN_Q(ha, tgt, lun)) != NULL) { | ||
3591 | LUN_Q(ha, tgt, lun) = NULL; | ||
3592 | kfree(lq); | ||
3593 | } | ||
3594 | |||
3595 | return; | ||
3596 | } | 2766 | } |
3597 | 2767 | ||
3598 | /* | 2768 | /* |
@@ -3642,8 +2812,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3642 | ha->outstanding_cmds[cnt] = NULL; | 2812 | ha->outstanding_cmds[cnt] = NULL; |
3643 | if (ha->actthreads) | 2813 | if (ha->actthreads) |
3644 | ha->actthreads--; | 2814 | ha->actthreads--; |
3645 | sp->lun_queue->out_cnt--; | ||
3646 | |||
3647 | sp->flags = 0; | 2815 | sp->flags = 0; |
3648 | sp->cmd->result = DID_RESET << 16; | 2816 | sp->cmd->result = DID_RESET << 16; |
3649 | sp->cmd->host_scribble = (unsigned char *)NULL; | 2817 | sp->cmd->host_scribble = (unsigned char *)NULL; |