aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_mbx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mbx.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c430
1 files changed, 144 insertions, 286 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index ccd662a6f5dc..0c10c0b0fb73 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -8,19 +8,6 @@
8 8
9#include <linux/delay.h> 9#include <linux/delay.h>
10 10
11static void
12qla2x00_mbx_sem_timeout(unsigned long data)
13{
14 struct semaphore *sem_ptr = (struct semaphore *)data;
15
16 DEBUG11(printk("qla2x00_sem_timeout: entered.\n"));
17
18 if (sem_ptr != NULL) {
19 up(sem_ptr);
20 }
21
22 DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n"));
23}
24 11
25/* 12/*
26 * qla2x00_mailbox_command 13 * qla2x00_mailbox_command
@@ -47,7 +34,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
47 int rval; 34 int rval;
48 unsigned long flags = 0; 35 unsigned long flags = 0;
49 device_reg_t __iomem *reg; 36 device_reg_t __iomem *reg;
50 struct timer_list tmp_intr_timer;
51 uint8_t abort_active; 37 uint8_t abort_active;
52 uint8_t io_lock_on; 38 uint8_t io_lock_on;
53 uint16_t command; 39 uint16_t command;
@@ -72,7 +58,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
72 * non ISP abort time. 58 * non ISP abort time.
73 */ 59 */
74 if (!abort_active) { 60 if (!abort_active) {
75 if (qla2x00_down_timeout(&ha->mbx_cmd_sem, mcp->tov * HZ)) { 61 if (!wait_for_completion_timeout(&ha->mbx_cmd_comp,
62 mcp->tov * HZ)) {
76 /* Timeout occurred. Return error. */ 63 /* Timeout occurred. Return error. */
77 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 64 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
78 "Exiting.\n", __func__, ha->host_no)); 65 "Exiting.\n", __func__, ha->host_no));
@@ -135,22 +122,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
135 /* Wait for mbx cmd completion until timeout */ 122 /* Wait for mbx cmd completion until timeout */
136 123
137 if (!abort_active && io_lock_on) { 124 if (!abort_active && io_lock_on) {
138 /* sleep on completion semaphore */
139 DEBUG11(printk("%s(%ld): INTERRUPT MODE. Initializing timer.\n",
140 __func__, ha->host_no));
141
142 init_timer(&tmp_intr_timer);
143 tmp_intr_timer.data = (unsigned long)&ha->mbx_intr_sem;
144 tmp_intr_timer.expires = jiffies + mcp->tov * HZ;
145 tmp_intr_timer.function =
146 (void (*)(unsigned long))qla2x00_mbx_sem_timeout;
147
148 DEBUG11(printk("%s(%ld): Adding timer.\n", __func__,
149 ha->host_no));
150 add_timer(&tmp_intr_timer);
151
152 DEBUG11(printk("%s(%ld): going to unlock & sleep. "
153 "time=0x%lx.\n", __func__, ha->host_no, jiffies));
154 125
155 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 126 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
156 127
@@ -160,17 +131,10 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
160 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT); 131 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
161 spin_unlock_irqrestore(&ha->hardware_lock, flags); 132 spin_unlock_irqrestore(&ha->hardware_lock, flags);
162 133
163 /* Wait for either the timer to expire 134 wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ);
164 * or the mbox completion interrupt
165 */
166 down(&ha->mbx_intr_sem);
167 135
168 DEBUG11(printk("%s(%ld): waking up. time=0x%lx\n", __func__,
169 ha->host_no, jiffies));
170 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 136 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
171 137
172 /* delete the timer */
173 del_timer(&tmp_intr_timer);
174 } else { 138 } else {
175 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 139 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
176 ha->host_no, command)); 140 ha->host_no, command));
@@ -299,7 +263,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
299 263
300 /* Allow next mbx cmd to come in. */ 264 /* Allow next mbx cmd to come in. */
301 if (!abort_active) 265 if (!abort_active)
302 up(&ha->mbx_cmd_sem); 266 complete(&ha->mbx_cmd_comp);
303 267
304 if (rval) { 268 if (rval) {
305 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, " 269 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
@@ -905,7 +869,7 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
905 869
906 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; 870 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
907 mcp->mb[9] = ha->vp_idx; 871 mcp->mb[9] = ha->vp_idx;
908 mcp->out_mb = MBX_0; 872 mcp->out_mb = MBX_9|MBX_0;
909 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 873 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
910 mcp->tov = 30; 874 mcp->tov = 30;
911 mcp->flags = 0; 875 mcp->flags = 0;
@@ -1016,7 +980,7 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
1016 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n", 980 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1017 ha->host_no)); 981 ha->host_no));
1018 982
1019 if (ha->flags.npiv_supported) 983 if (ha->fw_attributes & BIT_2)
1020 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; 984 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE;
1021 else 985 else
1022 mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; 986 mcp->mb[0] = MBC_INITIALIZE_FIRMWARE;
@@ -2042,29 +2006,20 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2042 */ 2006 */
2043int 2007int
2044qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id, 2008qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2045 link_stat_t *ret_buf, uint16_t *status) 2009 struct link_statistics *stats, dma_addr_t stats_dma)
2046{ 2010{
2047 int rval; 2011 int rval;
2048 mbx_cmd_t mc; 2012 mbx_cmd_t mc;
2049 mbx_cmd_t *mcp = &mc; 2013 mbx_cmd_t *mcp = &mc;
2050 link_stat_t *stat_buf; 2014 uint32_t *siter, *diter, dwords;
2051 dma_addr_t stat_buf_dma;
2052 2015
2053 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2016 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2054 2017
2055 stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma);
2056 if (stat_buf == NULL) {
2057 DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
2058 __func__, ha->host_no));
2059 return BIT_0;
2060 }
2061 memset(stat_buf, 0, sizeof(link_stat_t));
2062
2063 mcp->mb[0] = MBC_GET_LINK_STATUS; 2018 mcp->mb[0] = MBC_GET_LINK_STATUS;
2064 mcp->mb[2] = MSW(stat_buf_dma); 2019 mcp->mb[2] = MSW(stats_dma);
2065 mcp->mb[3] = LSW(stat_buf_dma); 2020 mcp->mb[3] = LSW(stats_dma);
2066 mcp->mb[6] = MSW(MSD(stat_buf_dma)); 2021 mcp->mb[6] = MSW(MSD(stats_dma));
2067 mcp->mb[7] = LSW(MSD(stat_buf_dma)); 2022 mcp->mb[7] = LSW(MSD(stats_dma));
2068 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2023 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2069 mcp->in_mb = MBX_0; 2024 mcp->in_mb = MBX_0;
2070 if (IS_FWI2_CAPABLE(ha)) { 2025 if (IS_FWI2_CAPABLE(ha)) {
@@ -2089,78 +2044,43 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2089 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2044 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2090 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2045 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2091 __func__, ha->host_no, mcp->mb[0])); 2046 __func__, ha->host_no, mcp->mb[0]));
2092 status[0] = mcp->mb[0]; 2047 rval = QLA_FUNCTION_FAILED;
2093 rval = BIT_1;
2094 } else { 2048 } else {
2095 /* copy over data -- firmware data is LE. */ 2049 /* Copy over data -- firmware data is LE. */
2096 ret_buf->link_fail_cnt = 2050 dwords = offsetof(struct link_statistics, unused1) / 4;
2097 le32_to_cpu(stat_buf->link_fail_cnt); 2051 siter = diter = &stats->link_fail_cnt;
2098 ret_buf->loss_sync_cnt = 2052 while (dwords--)
2099 le32_to_cpu(stat_buf->loss_sync_cnt); 2053 *diter++ = le32_to_cpu(*siter++);
2100 ret_buf->loss_sig_cnt =
2101 le32_to_cpu(stat_buf->loss_sig_cnt);
2102 ret_buf->prim_seq_err_cnt =
2103 le32_to_cpu(stat_buf->prim_seq_err_cnt);
2104 ret_buf->inval_xmit_word_cnt =
2105 le32_to_cpu(stat_buf->inval_xmit_word_cnt);
2106 ret_buf->inval_crc_cnt =
2107 le32_to_cpu(stat_buf->inval_crc_cnt);
2108
2109 DEBUG11(printk("%s(%ld): stat dump: fail_cnt=%d "
2110 "loss_sync=%d loss_sig=%d seq_err=%d "
2111 "inval_xmt_word=%d inval_crc=%d.\n", __func__,
2112 ha->host_no, stat_buf->link_fail_cnt,
2113 stat_buf->loss_sync_cnt, stat_buf->loss_sig_cnt,
2114 stat_buf->prim_seq_err_cnt,
2115 stat_buf->inval_xmit_word_cnt,
2116 stat_buf->inval_crc_cnt));
2117 } 2054 }
2118 } else { 2055 } else {
2119 /* Failed. */ 2056 /* Failed. */
2120 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2057 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2121 ha->host_no, rval)); 2058 ha->host_no, rval));
2122 rval = BIT_1;
2123 } 2059 }
2124 2060
2125 dma_pool_free(ha->s_dma_pool, stat_buf, stat_buf_dma);
2126
2127 return rval; 2061 return rval;
2128} 2062}
2129 2063
2130int 2064int
2131qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords, 2065qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2132 uint16_t *status) 2066 dma_addr_t stats_dma)
2133{ 2067{
2134 int rval; 2068 int rval;
2135 mbx_cmd_t mc; 2069 mbx_cmd_t mc;
2136 mbx_cmd_t *mcp = &mc; 2070 mbx_cmd_t *mcp = &mc;
2137 uint32_t *sbuf, *siter; 2071 uint32_t *siter, *diter, dwords;
2138 dma_addr_t sbuf_dma;
2139 2072
2140 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2073 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2141 2074
2142 if (dwords > (DMA_POOL_SIZE / 4)) {
2143 DEBUG2_3_11(printk("%s(%ld): Unabled to retrieve %d DWORDs "
2144 "(max %d).\n", __func__, ha->host_no, dwords,
2145 DMA_POOL_SIZE / 4));
2146 return BIT_0;
2147 }
2148 sbuf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &sbuf_dma);
2149 if (sbuf == NULL) {
2150 DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
2151 __func__, ha->host_no));
2152 return BIT_0;
2153 }
2154 memset(sbuf, 0, DMA_POOL_SIZE);
2155
2156 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; 2075 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS;
2157 mcp->mb[2] = MSW(sbuf_dma); 2076 mcp->mb[2] = MSW(stats_dma);
2158 mcp->mb[3] = LSW(sbuf_dma); 2077 mcp->mb[3] = LSW(stats_dma);
2159 mcp->mb[6] = MSW(MSD(sbuf_dma)); 2078 mcp->mb[6] = MSW(MSD(stats_dma));
2160 mcp->mb[7] = LSW(MSD(sbuf_dma)); 2079 mcp->mb[7] = LSW(MSD(stats_dma));
2161 mcp->mb[8] = dwords; 2080 mcp->mb[8] = sizeof(struct link_statistics) / 4;
2081 mcp->mb[9] = ha->vp_idx;
2162 mcp->mb[10] = 0; 2082 mcp->mb[10] = 0;
2163 mcp->out_mb = MBX_10|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2083 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2164 mcp->in_mb = MBX_2|MBX_1|MBX_0; 2084 mcp->in_mb = MBX_2|MBX_1|MBX_0;
2165 mcp->tov = 30; 2085 mcp->tov = 30;
2166 mcp->flags = IOCTL_CMD; 2086 mcp->flags = IOCTL_CMD;
@@ -2170,23 +2090,20 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,
2170 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2090 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2171 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2091 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2172 __func__, ha->host_no, mcp->mb[0])); 2092 __func__, ha->host_no, mcp->mb[0]));
2173 status[0] = mcp->mb[0]; 2093 rval = QLA_FUNCTION_FAILED;
2174 rval = BIT_1;
2175 } else { 2094 } else {
2176 /* Copy over data -- firmware data is LE. */ 2095 /* Copy over data -- firmware data is LE. */
2177 siter = sbuf; 2096 dwords = sizeof(struct link_statistics) / 4;
2097 siter = diter = &stats->link_fail_cnt;
2178 while (dwords--) 2098 while (dwords--)
2179 *dwbuf++ = le32_to_cpu(*siter++); 2099 *diter++ = le32_to_cpu(*siter++);
2180 } 2100 }
2181 } else { 2101 } else {
2182 /* Failed. */ 2102 /* Failed. */
2183 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2103 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2184 ha->host_no, rval)); 2104 ha->host_no, rval));
2185 rval = BIT_1;
2186 } 2105 }
2187 2106
2188 dma_pool_free(ha->s_dma_pool, sbuf, sbuf_dma);
2189
2190 return rval; 2107 return rval;
2191} 2108}
2192 2109
@@ -2331,6 +2248,8 @@ atarget_done:
2331 return rval; 2248 return rval;
2332} 2249}
2333 2250
2251#if 0
2252
2334int 2253int
2335qla2x00_system_error(scsi_qla_host_t *ha) 2254qla2x00_system_error(scsi_qla_host_t *ha)
2336{ 2255{
@@ -2360,47 +2279,7 @@ qla2x00_system_error(scsi_qla_host_t *ha)
2360 return rval; 2279 return rval;
2361} 2280}
2362 2281
2363/** 2282#endif /* 0 */
2364 * qla2x00_get_serdes_params() -
2365 * @ha: HA context
2366 *
2367 * Returns
2368 */
2369int
2370qla2x00_get_serdes_params(scsi_qla_host_t *ha, uint16_t *sw_em_1g,
2371 uint16_t *sw_em_2g, uint16_t *sw_em_4g)
2372{
2373 int rval;
2374 mbx_cmd_t mc;
2375 mbx_cmd_t *mcp = &mc;
2376
2377 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2378
2379 mcp->mb[0] = MBC_SERDES_PARAMS;
2380 mcp->mb[1] = 0;
2381 mcp->out_mb = MBX_1|MBX_0;
2382 mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_0;
2383 mcp->tov = 30;
2384 mcp->flags = 0;
2385 rval = qla2x00_mailbox_command(ha, mcp);
2386
2387 if (rval != QLA_SUCCESS) {
2388 /*EMPTY*/
2389 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2390 ha->host_no, rval, mcp->mb[0]));
2391 } else {
2392 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2393
2394 if (sw_em_1g)
2395 *sw_em_1g = mcp->mb[2];
2396 if (sw_em_2g)
2397 *sw_em_2g = mcp->mb[3];
2398 if (sw_em_4g)
2399 *sw_em_4g = mcp->mb[4];
2400 }
2401
2402 return rval;
2403}
2404 2283
2405/** 2284/**
2406 * qla2x00_set_serdes_params() - 2285 * qla2x00_set_serdes_params() -
@@ -2471,7 +2350,7 @@ qla2x00_stop_firmware(scsi_qla_host_t *ha)
2471} 2350}
2472 2351
2473int 2352int
2474qla2x00_trace_control(scsi_qla_host_t *ha, uint16_t ctrl, dma_addr_t eft_dma, 2353qla2x00_enable_eft_trace(scsi_qla_host_t *ha, dma_addr_t eft_dma,
2475 uint16_t buffers) 2354 uint16_t buffers)
2476{ 2355{
2477 int rval; 2356 int rval;
@@ -2484,22 +2363,18 @@ qla2x00_trace_control(scsi_qla_host_t *ha, uint16_t ctrl, dma_addr_t eft_dma,
2484 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2363 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2485 2364
2486 mcp->mb[0] = MBC_TRACE_CONTROL; 2365 mcp->mb[0] = MBC_TRACE_CONTROL;
2487 mcp->mb[1] = ctrl; 2366 mcp->mb[1] = TC_EFT_ENABLE;
2488 mcp->out_mb = MBX_1|MBX_0; 2367 mcp->mb[2] = LSW(eft_dma);
2368 mcp->mb[3] = MSW(eft_dma);
2369 mcp->mb[4] = LSW(MSD(eft_dma));
2370 mcp->mb[5] = MSW(MSD(eft_dma));
2371 mcp->mb[6] = buffers;
2372 mcp->mb[7] = TC_AEN_DISABLE;
2373 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2489 mcp->in_mb = MBX_1|MBX_0; 2374 mcp->in_mb = MBX_1|MBX_0;
2490 if (ctrl == TC_ENABLE) {
2491 mcp->mb[2] = LSW(eft_dma);
2492 mcp->mb[3] = MSW(eft_dma);
2493 mcp->mb[4] = LSW(MSD(eft_dma));
2494 mcp->mb[5] = MSW(MSD(eft_dma));
2495 mcp->mb[6] = buffers;
2496 mcp->mb[7] = 0;
2497 mcp->out_mb |= MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2;
2498 }
2499 mcp->tov = 30; 2375 mcp->tov = 30;
2500 mcp->flags = 0; 2376 mcp->flags = 0;
2501 rval = qla2x00_mailbox_command(ha, mcp); 2377 rval = qla2x00_mailbox_command(ha, mcp);
2502
2503 if (rval != QLA_SUCCESS) { 2378 if (rval != QLA_SUCCESS) {
2504 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2379 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2505 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2380 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
@@ -2511,8 +2386,7 @@ qla2x00_trace_control(scsi_qla_host_t *ha, uint16_t ctrl, dma_addr_t eft_dma,
2511} 2386}
2512 2387
2513int 2388int
2514qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr, 2389qla2x00_disable_eft_trace(scsi_qla_host_t *ha)
2515 uint16_t off, uint16_t count)
2516{ 2390{
2517 int rval; 2391 int rval;
2518 mbx_cmd_t mc; 2392 mbx_cmd_t mc;
@@ -2523,24 +2397,16 @@ qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2523 2397
2524 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2398 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2525 2399
2526 mcp->mb[0] = MBC_READ_SFP; 2400 mcp->mb[0] = MBC_TRACE_CONTROL;
2527 mcp->mb[1] = addr; 2401 mcp->mb[1] = TC_EFT_DISABLE;
2528 mcp->mb[2] = MSW(sfp_dma); 2402 mcp->out_mb = MBX_1|MBX_0;
2529 mcp->mb[3] = LSW(sfp_dma); 2403 mcp->in_mb = MBX_1|MBX_0;
2530 mcp->mb[6] = MSW(MSD(sfp_dma));
2531 mcp->mb[7] = LSW(MSD(sfp_dma));
2532 mcp->mb[8] = count;
2533 mcp->mb[9] = off;
2534 mcp->mb[10] = 0;
2535 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2536 mcp->in_mb = MBX_0;
2537 mcp->tov = 30; 2404 mcp->tov = 30;
2538 mcp->flags = 0; 2405 mcp->flags = 0;
2539 rval = qla2x00_mailbox_command(ha, mcp); 2406 rval = qla2x00_mailbox_command(ha, mcp);
2540
2541 if (rval != QLA_SUCCESS) { 2407 if (rval != QLA_SUCCESS) {
2542 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2408 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2543 ha->host_no, rval, mcp->mb[0])); 2409 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2544 } else { 2410 } else {
2545 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2411 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2546 } 2412 }
@@ -2549,176 +2415,168 @@ qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2549} 2415}
2550 2416
2551int 2417int
2552qla2x00_get_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id, 2418qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2553 uint16_t *port_speed, uint16_t *mb) 2419 uint16_t buffers, uint16_t *mb, uint32_t *dwords)
2554{ 2420{
2555 int rval; 2421 int rval;
2556 mbx_cmd_t mc; 2422 mbx_cmd_t mc;
2557 mbx_cmd_t *mcp = &mc; 2423 mbx_cmd_t *mcp = &mc;
2558 2424
2559 if (!IS_IIDMA_CAPABLE(ha)) 2425 if (!IS_QLA25XX(ha))
2560 return QLA_FUNCTION_FAILED; 2426 return QLA_FUNCTION_FAILED;
2561 2427
2562 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2428 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2563 2429
2564 mcp->mb[0] = MBC_PORT_PARAMS; 2430 mcp->mb[0] = MBC_TRACE_CONTROL;
2565 mcp->mb[1] = loop_id; 2431 mcp->mb[1] = TC_FCE_ENABLE;
2566 mcp->mb[2] = mcp->mb[3] = mcp->mb[4] = mcp->mb[5] = 0; 2432 mcp->mb[2] = LSW(fce_dma);
2567 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2433 mcp->mb[3] = MSW(fce_dma);
2568 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; 2434 mcp->mb[4] = LSW(MSD(fce_dma));
2435 mcp->mb[5] = MSW(MSD(fce_dma));
2436 mcp->mb[6] = buffers;
2437 mcp->mb[7] = TC_AEN_DISABLE;
2438 mcp->mb[8] = 0;
2439 mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE;
2440 mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE;
2441 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|
2442 MBX_1|MBX_0;
2443 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2569 mcp->tov = 30; 2444 mcp->tov = 30;
2570 mcp->flags = 0; 2445 mcp->flags = 0;
2571 rval = qla2x00_mailbox_command(ha, mcp); 2446 rval = qla2x00_mailbox_command(ha, mcp);
2572
2573 /* Return mailbox statuses. */
2574 if (mb != NULL) {
2575 mb[0] = mcp->mb[0];
2576 mb[1] = mcp->mb[1];
2577 mb[3] = mcp->mb[3];
2578 mb[4] = mcp->mb[4];
2579 mb[5] = mcp->mb[5];
2580 }
2581
2582 if (rval != QLA_SUCCESS) { 2447 if (rval != QLA_SUCCESS) {
2583 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2448 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2584 ha->host_no, rval)); 2449 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2585 } else { 2450 } else {
2586 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2451 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2587 if (port_speed) 2452
2588 *port_speed = mcp->mb[3]; 2453 if (mb)
2454 memcpy(mb, mcp->mb, 8 * sizeof(*mb));
2455 if (dwords)
2456 *dwords = mcp->mb[6];
2589 } 2457 }
2590 2458
2591 return rval; 2459 return rval;
2592} 2460}
2593 2461
2594int 2462int
2595qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id, 2463qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd)
2596 uint16_t port_speed, uint16_t *mb)
2597{ 2464{
2598 int rval; 2465 int rval;
2599 mbx_cmd_t mc; 2466 mbx_cmd_t mc;
2600 mbx_cmd_t *mcp = &mc; 2467 mbx_cmd_t *mcp = &mc;
2601 2468
2602 if (!IS_IIDMA_CAPABLE(ha)) 2469 if (!IS_FWI2_CAPABLE(ha))
2603 return QLA_FUNCTION_FAILED; 2470 return QLA_FUNCTION_FAILED;
2604 2471
2605 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2472 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2606 2473
2607 mcp->mb[0] = MBC_PORT_PARAMS; 2474 mcp->mb[0] = MBC_TRACE_CONTROL;
2608 mcp->mb[1] = loop_id; 2475 mcp->mb[1] = TC_FCE_DISABLE;
2609 mcp->mb[2] = BIT_0; 2476 mcp->mb[2] = TC_FCE_DISABLE_TRACE;
2610 mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); 2477 mcp->out_mb = MBX_2|MBX_1|MBX_0;
2611 mcp->mb[4] = mcp->mb[5] = 0; 2478 mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|
2612 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2479 MBX_1|MBX_0;
2613 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
2614 mcp->tov = 30; 2480 mcp->tov = 30;
2615 mcp->flags = 0; 2481 mcp->flags = 0;
2616 rval = qla2x00_mailbox_command(ha, mcp); 2482 rval = qla2x00_mailbox_command(ha, mcp);
2617
2618 /* Return mailbox statuses. */
2619 if (mb != NULL) {
2620 mb[0] = mcp->mb[0];
2621 mb[1] = mcp->mb[1];
2622 mb[3] = mcp->mb[3];
2623 mb[4] = mcp->mb[4];
2624 mb[5] = mcp->mb[5];
2625 }
2626
2627 if (rval != QLA_SUCCESS) { 2483 if (rval != QLA_SUCCESS) {
2628 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2484 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2629 ha->host_no, rval)); 2485 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2630 } else { 2486 } else {
2631 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2487 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2488
2489 if (wr)
2490 *wr = (uint64_t) mcp->mb[5] << 48 |
2491 (uint64_t) mcp->mb[4] << 32 |
2492 (uint64_t) mcp->mb[3] << 16 |
2493 (uint64_t) mcp->mb[2];
2494 if (rd)
2495 *rd = (uint64_t) mcp->mb[9] << 48 |
2496 (uint64_t) mcp->mb[8] << 32 |
2497 (uint64_t) mcp->mb[7] << 16 |
2498 (uint64_t) mcp->mb[6];
2632 } 2499 }
2633 2500
2634 return rval; 2501 return rval;
2635} 2502}
2636 2503
2637/*
2638 * qla24xx_get_vp_database
2639 * Get the VP's database for all configured ports.
2640 *
2641 * Input:
2642 * ha = adapter block pointer.
2643 * size = size of initialization control block.
2644 *
2645 * Returns:
2646 * qla2x00 local function return status code.
2647 *
2648 * Context:
2649 * Kernel context.
2650 */
2651int 2504int
2652qla24xx_get_vp_database(scsi_qla_host_t *ha, uint16_t size) 2505qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2506 uint16_t off, uint16_t count)
2653{ 2507{
2654 int rval; 2508 int rval;
2655 mbx_cmd_t mc; 2509 mbx_cmd_t mc;
2656 mbx_cmd_t *mcp = &mc; 2510 mbx_cmd_t *mcp = &mc;
2657 2511
2658 DEBUG11(printk("scsi(%ld):%s - entered.\n", 2512 if (!IS_FWI2_CAPABLE(ha))
2659 ha->host_no, __func__)); 2513 return QLA_FUNCTION_FAILED;
2660 2514
2661 mcp->mb[0] = MBC_MID_GET_VP_DATABASE; 2515 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2662 mcp->mb[2] = MSW(ha->init_cb_dma); 2516
2663 mcp->mb[3] = LSW(ha->init_cb_dma); 2517 mcp->mb[0] = MBC_READ_SFP;
2664 mcp->mb[4] = 0; 2518 mcp->mb[1] = addr;
2665 mcp->mb[5] = 0; 2519 mcp->mb[2] = MSW(sfp_dma);
2666 mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); 2520 mcp->mb[3] = LSW(sfp_dma);
2667 mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); 2521 mcp->mb[6] = MSW(MSD(sfp_dma));
2668 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2522 mcp->mb[7] = LSW(MSD(sfp_dma));
2669 mcp->in_mb = MBX_1|MBX_0; 2523 mcp->mb[8] = count;
2670 mcp->buf_size = size; 2524 mcp->mb[9] = off;
2671 mcp->flags = MBX_DMA_OUT; 2525 mcp->mb[10] = 0;
2672 mcp->tov = MBX_TOV_SECONDS; 2526 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2527 mcp->in_mb = MBX_0;
2528 mcp->tov = 30;
2529 mcp->flags = 0;
2673 rval = qla2x00_mailbox_command(ha, mcp); 2530 rval = qla2x00_mailbox_command(ha, mcp);
2674 2531
2675 if (rval != QLA_SUCCESS) { 2532 if (rval != QLA_SUCCESS) {
2676 /*EMPTY*/ 2533 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2677 DEBUG2_3_11(printk("%s(%ld): failed=%x " 2534 ha->host_no, rval, mcp->mb[0]));
2678 "mb0=%x.\n",
2679 __func__, ha->host_no, rval, mcp->mb[0]));
2680 } else { 2535 } else {
2681 /*EMPTY*/ 2536 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2682 DEBUG11(printk("%s(%ld): done.\n",
2683 __func__, ha->host_no));
2684 } 2537 }
2685 2538
2686 return rval; 2539 return rval;
2687} 2540}
2688 2541
2689int 2542int
2690qla24xx_get_vp_entry(scsi_qla_host_t *ha, uint16_t size, int vp_id) 2543qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2544 uint16_t port_speed, uint16_t *mb)
2691{ 2545{
2692 int rval; 2546 int rval;
2693 mbx_cmd_t mc; 2547 mbx_cmd_t mc;
2694 mbx_cmd_t *mcp = &mc; 2548 mbx_cmd_t *mcp = &mc;
2695 2549
2550 if (!IS_IIDMA_CAPABLE(ha))
2551 return QLA_FUNCTION_FAILED;
2552
2696 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2553 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2697 2554
2698 mcp->mb[0] = MBC_MID_GET_VP_ENTRY; 2555 mcp->mb[0] = MBC_PORT_PARAMS;
2699 mcp->mb[2] = MSW(ha->init_cb_dma); 2556 mcp->mb[1] = loop_id;
2700 mcp->mb[3] = LSW(ha->init_cb_dma); 2557 mcp->mb[2] = BIT_0;
2701 mcp->mb[4] = 0; 2558 mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0);
2702 mcp->mb[5] = 0; 2559 mcp->mb[4] = mcp->mb[5] = 0;
2703 mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); 2560 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2704 mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); 2561 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
2705 mcp->mb[9] = vp_id;
2706 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2707 mcp->in_mb = MBX_0;
2708 mcp->buf_size = size;
2709 mcp->flags = MBX_DMA_OUT;
2710 mcp->tov = 30; 2562 mcp->tov = 30;
2563 mcp->flags = 0;
2711 rval = qla2x00_mailbox_command(ha, mcp); 2564 rval = qla2x00_mailbox_command(ha, mcp);
2712 2565
2566 /* Return mailbox statuses. */
2567 if (mb != NULL) {
2568 mb[0] = mcp->mb[0];
2569 mb[1] = mcp->mb[1];
2570 mb[3] = mcp->mb[3];
2571 mb[4] = mcp->mb[4];
2572 mb[5] = mcp->mb[5];
2573 }
2574
2713 if (rval != QLA_SUCCESS) { 2575 if (rval != QLA_SUCCESS) {
2714 /*EMPTY*/ 2576 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2715 DEBUG2_3_11(printk("qla24xx_get_vp_entry(%ld): failed=%x " 2577 ha->host_no, rval));
2716 "mb0=%x.\n",
2717 ha->host_no, rval, mcp->mb[0]));
2718 } else { 2578 } else {
2719 /*EMPTY*/ 2579 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2720 DEBUG11(printk("qla24xx_get_vp_entry(%ld): done.\n",
2721 ha->host_no));
2722 } 2580 }
2723 2581
2724 return rval; 2582 return rval;
@@ -2873,7 +2731,7 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2873 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__, 2731 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__,
2874 ha->host_no, vp_index)); 2732 ha->host_no, vp_index));
2875 2733
2876 if (vp_index == 0 || vp_index >= MAX_MULTI_ID_LOOP) 2734 if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
2877 return QLA_PARAMETER_ERROR; 2735 return QLA_PARAMETER_ERROR;
2878 2736
2879 vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); 2737 vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);