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.c886
1 files changed, 515 insertions, 371 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 3402746ec128..a99976f5fabd 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -29,7 +29,7 @@
29 * Kernel context. 29 * Kernel context.
30 */ 30 */
31static int 31static int
32qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp) 32qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
33{ 33{
34 int rval; 34 int rval;
35 unsigned long flags = 0; 35 unsigned long flags = 0;
@@ -42,15 +42,16 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
42 uint32_t cnt; 42 uint32_t cnt;
43 uint32_t mboxes; 43 uint32_t mboxes;
44 unsigned long wait_time; 44 unsigned long wait_time;
45 scsi_qla_host_t *ha = to_qla_parent(pvha); 45 struct qla_hw_data *ha = vha->hw;
46 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
46 47
47 reg = ha->iobase; 48 reg = ha->iobase;
48 io_lock_on = ha->flags.init_done; 49 io_lock_on = base_vha->flags.init_done;
49 50
50 rval = QLA_SUCCESS; 51 rval = QLA_SUCCESS;
51 abort_active = test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 52 abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
52 53
53 DEBUG11(printk("%s(%ld): entered.\n", __func__, pvha->host_no)); 54 DEBUG11(printk("%s(%ld): entered.\n", __func__, base_vha->host_no));
54 55
55 /* 56 /*
56 * Wait for active mailbox commands to finish by waiting at most tov 57 * Wait for active mailbox commands to finish by waiting at most tov
@@ -62,7 +63,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
62 mcp->tov * HZ)) { 63 mcp->tov * HZ)) {
63 /* Timeout occurred. Return error. */ 64 /* Timeout occurred. Return error. */
64 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 65 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
65 "Exiting.\n", __func__, ha->host_no)); 66 "Exiting.\n", __func__, base_vha->host_no));
66 return QLA_FUNCTION_TIMEOUT; 67 return QLA_FUNCTION_TIMEOUT;
67 } 68 }
68 } 69 }
@@ -72,7 +73,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
72 ha->mcp = mcp; 73 ha->mcp = mcp;
73 74
74 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n", 75 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n",
75 ha->host_no, mcp->mb[0])); 76 base_vha->host_no, mcp->mb[0]));
76 77
77 spin_lock_irqsave(&ha->hardware_lock, flags); 78 spin_lock_irqsave(&ha->hardware_lock, flags);
78 79
@@ -100,15 +101,16 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
100 101
101#if defined(QL_DEBUG_LEVEL_1) 102#if defined(QL_DEBUG_LEVEL_1)
102 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n", 103 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n",
103 __func__, ha->host_no); 104 __func__, base_vha->host_no);
104 qla2x00_dump_buffer((uint8_t *)mcp->mb, 16); 105 qla2x00_dump_buffer((uint8_t *)mcp->mb, 16);
105 printk("\n"); 106 printk("\n");
106 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16); 107 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16);
107 printk("\n"); 108 printk("\n");
108 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8); 109 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8);
109 printk("\n"); 110 printk("\n");
110 printk("%s(%ld): I/O address = %p.\n", __func__, ha->host_no, optr); 111 printk("%s(%ld): I/O address = %p.\n", __func__, base_vha->host_no,
111 qla2x00_dump_regs(ha); 112 optr);
113 qla2x00_dump_regs(base_vha);
112#endif 114#endif
113 115
114 /* Issue set host interrupt command to send cmd out. */ 116 /* Issue set host interrupt command to send cmd out. */
@@ -117,7 +119,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
117 119
118 /* Unlock mbx registers and wait for interrupt */ 120 /* Unlock mbx registers and wait for interrupt */
119 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. " 121 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. "
120 "jiffies=%lx.\n", __func__, ha->host_no, jiffies)); 122 "jiffies=%lx.\n", __func__, base_vha->host_no, jiffies));
121 123
122 /* Wait for mbx cmd completion until timeout */ 124 /* Wait for mbx cmd completion until timeout */
123 125
@@ -137,7 +139,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
137 139
138 } else { 140 } else {
139 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 141 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
140 ha->host_no, command)); 142 base_vha->host_no, command));
141 143
142 if (IS_FWI2_CAPABLE(ha)) 144 if (IS_FWI2_CAPABLE(ha))
143 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); 145 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
@@ -151,7 +153,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
151 break; 153 break;
152 154
153 /* Check for pending interrupts. */ 155 /* Check for pending interrupts. */
154 qla2x00_poll(ha); 156 qla2x00_poll(ha->rsp_q_map[0]);
155 157
156 if (command != MBC_LOAD_RISC_RAM_EXTENDED && 158 if (command != MBC_LOAD_RISC_RAM_EXTENDED &&
157 !ha->flags.mbox_int) 159 !ha->flags.mbox_int)
@@ -164,7 +166,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
164 uint16_t *iptr2; 166 uint16_t *iptr2;
165 167
166 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__, 168 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__,
167 ha->host_no, command)); 169 base_vha->host_no, command));
168 170
169 /* Got interrupt. Clear the flag. */ 171 /* Got interrupt. Clear the flag. */
170 ha->flags.mbox_int = 0; 172 ha->flags.mbox_int = 0;
@@ -200,12 +202,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
200 ictrl = RD_REG_WORD(&reg->isp.ictrl); 202 ictrl = RD_REG_WORD(&reg->isp.ictrl);
201 } 203 }
202 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n", 204 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n",
203 __func__, ha->host_no, command); 205 __func__, base_vha->host_no, command);
204 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__, 206 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__,
205 ha->host_no, ictrl, jiffies); 207 base_vha->host_no, ictrl, jiffies);
206 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__, 208 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__,
207 ha->host_no, mb0); 209 base_vha->host_no, mb0);
208 qla2x00_dump_regs(ha); 210 qla2x00_dump_regs(base_vha);
209#endif 211#endif
210 212
211 rval = QLA_FUNCTION_TIMEOUT; 213 rval = QLA_FUNCTION_TIMEOUT;
@@ -218,10 +220,10 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
218 220
219 if (abort_active || !io_lock_on) { 221 if (abort_active || !io_lock_on) {
220 DEBUG11(printk("%s(%ld): checking for additional resp " 222 DEBUG11(printk("%s(%ld): checking for additional resp "
221 "interrupt.\n", __func__, ha->host_no)); 223 "interrupt.\n", __func__, base_vha->host_no));
222 224
223 /* polling mode for non isp_abort commands. */ 225 /* polling mode for non isp_abort commands. */
224 qla2x00_poll(ha); 226 qla2x00_poll(ha->rsp_q_map[0]);
225 } 227 }
226 228
227 if (rval == QLA_FUNCTION_TIMEOUT && 229 if (rval == QLA_FUNCTION_TIMEOUT &&
@@ -229,35 +231,37 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
229 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) { 231 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) {
230 /* not in dpc. schedule it for dpc to take over. */ 232 /* not in dpc. schedule it for dpc to take over. */
231 DEBUG(printk("%s(%ld): timeout schedule " 233 DEBUG(printk("%s(%ld): timeout schedule "
232 "isp_abort_needed.\n", __func__, ha->host_no)); 234 "isp_abort_needed.\n", __func__,
235 base_vha->host_no));
233 DEBUG2_3_11(printk("%s(%ld): timeout schedule " 236 DEBUG2_3_11(printk("%s(%ld): timeout schedule "
234 "isp_abort_needed.\n", __func__, ha->host_no)); 237 "isp_abort_needed.\n", __func__,
238 base_vha->host_no));
235 qla_printk(KERN_WARNING, ha, 239 qla_printk(KERN_WARNING, ha,
236 "Mailbox command timeout occurred. Scheduling ISP " 240 "Mailbox command timeout occurred. Scheduling ISP "
237 "abort.\n"); 241 "abort.\n");
238 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 242 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
239 qla2xxx_wake_dpc(ha); 243 qla2xxx_wake_dpc(vha);
240 } else if (!abort_active) { 244 } else if (!abort_active) {
241 /* call abort directly since we are in the DPC thread */ 245 /* call abort directly since we are in the DPC thread */
242 DEBUG(printk("%s(%ld): timeout calling abort_isp\n", 246 DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
243 __func__, ha->host_no)); 247 __func__, base_vha->host_no));
244 DEBUG2_3_11(printk("%s(%ld): timeout calling " 248 DEBUG2_3_11(printk("%s(%ld): timeout calling "
245 "abort_isp\n", __func__, ha->host_no)); 249 "abort_isp\n", __func__, base_vha->host_no));
246 qla_printk(KERN_WARNING, ha, 250 qla_printk(KERN_WARNING, ha,
247 "Mailbox command timeout occurred. Issuing ISP " 251 "Mailbox command timeout occurred. Issuing ISP "
248 "abort.\n"); 252 "abort.\n");
249 253
250 set_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 254 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
251 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 255 clear_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
252 if (qla2x00_abort_isp(ha)) { 256 if (qla2x00_abort_isp(base_vha)) {
253 /* Failed. retry later. */ 257 /* Failed. retry later. */
254 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 258 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
255 } 259 }
256 clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 260 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
257 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__, 261 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__,
258 ha->host_no)); 262 base_vha->host_no));
259 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n", 263 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n",
260 __func__, ha->host_no)); 264 __func__, base_vha->host_no));
261 } 265 }
262 } 266 }
263 267
@@ -267,24 +271,26 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
267 271
268 if (rval) { 272 if (rval) {
269 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, " 273 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
270 "mbx2=%x, cmd=%x ****\n", __func__, ha->host_no, 274 "mbx2=%x, cmd=%x ****\n", __func__, base_vha->host_no,
271 mcp->mb[0], mcp->mb[1], mcp->mb[2], command)); 275 mcp->mb[0], mcp->mb[1], mcp->mb[2], command));
272 } else { 276 } else {
273 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 277 DEBUG11(printk("%s(%ld): done.\n", __func__,
278 base_vha->host_no));
274 } 279 }
275 280
276 return rval; 281 return rval;
277} 282}
278 283
279int 284int
280qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr, 285qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr,
281 uint32_t risc_code_size) 286 uint32_t risc_code_size)
282{ 287{
283 int rval; 288 int rval;
289 struct qla_hw_data *ha = vha->hw;
284 mbx_cmd_t mc; 290 mbx_cmd_t mc;
285 mbx_cmd_t *mcp = &mc; 291 mbx_cmd_t *mcp = &mc;
286 292
287 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 293 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
288 294
289 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { 295 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) {
290 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; 296 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
@@ -312,13 +318,13 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
312 mcp->in_mb = MBX_0; 318 mcp->in_mb = MBX_0;
313 mcp->tov = MBX_TOV_SECONDS; 319 mcp->tov = MBX_TOV_SECONDS;
314 mcp->flags = 0; 320 mcp->flags = 0;
315 rval = qla2x00_mailbox_command(ha, mcp); 321 rval = qla2x00_mailbox_command(vha, mcp);
316 322
317 if (rval != QLA_SUCCESS) { 323 if (rval != QLA_SUCCESS) {
318 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 324 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
319 ha->host_no, rval, mcp->mb[0])); 325 vha->host_no, rval, mcp->mb[0]));
320 } else { 326 } else {
321 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 327 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
322 } 328 }
323 329
324 return rval; 330 return rval;
@@ -340,13 +346,14 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
340 * Kernel context. 346 * Kernel context.
341 */ 347 */
342int 348int
343qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr) 349qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
344{ 350{
345 int rval; 351 int rval;
352 struct qla_hw_data *ha = vha->hw;
346 mbx_cmd_t mc; 353 mbx_cmd_t mc;
347 mbx_cmd_t *mcp = &mc; 354 mbx_cmd_t *mcp = &mc;
348 355
349 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 356 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
350 357
351 mcp->mb[0] = MBC_EXECUTE_FIRMWARE; 358 mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
352 mcp->out_mb = MBX_0; 359 mcp->out_mb = MBX_0;
@@ -369,18 +376,18 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
369 376
370 mcp->tov = MBX_TOV_SECONDS; 377 mcp->tov = MBX_TOV_SECONDS;
371 mcp->flags = 0; 378 mcp->flags = 0;
372 rval = qla2x00_mailbox_command(ha, mcp); 379 rval = qla2x00_mailbox_command(vha, mcp);
373 380
374 if (rval != QLA_SUCCESS) { 381 if (rval != QLA_SUCCESS) {
375 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 382 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
376 ha->host_no, rval, mcp->mb[0])); 383 vha->host_no, rval, mcp->mb[0]));
377 } else { 384 } else {
378 if (IS_FWI2_CAPABLE(ha)) { 385 if (IS_FWI2_CAPABLE(ha)) {
379 DEBUG11(printk("%s(%ld): done exchanges=%x.\n", 386 DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
380 __func__, ha->host_no, mcp->mb[1])); 387 __func__, vha->host_no, mcp->mb[1]));
381 } else { 388 } else {
382 DEBUG11(printk("%s(%ld): done.\n", __func__, 389 DEBUG11(printk("%s(%ld): done.\n", __func__,
383 ha->host_no)); 390 vha->host_no));
384 } 391 }
385 } 392 }
386 393
@@ -404,28 +411,28 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
404 * Kernel context. 411 * Kernel context.
405 */ 412 */
406void 413void
407qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor, 414qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor,
408 uint16_t *subminor, uint16_t *attributes, uint32_t *memory) 415 uint16_t *subminor, uint16_t *attributes, uint32_t *memory)
409{ 416{
410 int rval; 417 int rval;
411 mbx_cmd_t mc; 418 mbx_cmd_t mc;
412 mbx_cmd_t *mcp = &mc; 419 mbx_cmd_t *mcp = &mc;
413 420
414 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 421 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
415 422
416 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; 423 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION;
417 mcp->out_mb = MBX_0; 424 mcp->out_mb = MBX_0;
418 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 425 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
419 mcp->flags = 0; 426 mcp->flags = 0;
420 mcp->tov = MBX_TOV_SECONDS; 427 mcp->tov = MBX_TOV_SECONDS;
421 rval = qla2x00_mailbox_command(ha, mcp); 428 rval = qla2x00_mailbox_command(vha, mcp);
422 429
423 /* Return mailbox data. */ 430 /* Return mailbox data. */
424 *major = mcp->mb[1]; 431 *major = mcp->mb[1];
425 *minor = mcp->mb[2]; 432 *minor = mcp->mb[2];
426 *subminor = mcp->mb[3]; 433 *subminor = mcp->mb[3];
427 *attributes = mcp->mb[6]; 434 *attributes = mcp->mb[6];
428 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 435 if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw))
429 *memory = 0x1FFFF; /* Defaults to 128KB. */ 436 *memory = 0x1FFFF; /* Defaults to 128KB. */
430 else 437 else
431 *memory = (mcp->mb[5] << 16) | mcp->mb[4]; 438 *memory = (mcp->mb[5] << 16) | mcp->mb[4];
@@ -433,10 +440,10 @@ qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor,
433 if (rval != QLA_SUCCESS) { 440 if (rval != QLA_SUCCESS) {
434 /*EMPTY*/ 441 /*EMPTY*/
435 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 442 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
436 ha->host_no, rval)); 443 vha->host_no, rval));
437 } else { 444 } else {
438 /*EMPTY*/ 445 /*EMPTY*/
439 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 446 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
440 } 447 }
441} 448}
442 449
@@ -455,32 +462,32 @@ qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor,
455 * Kernel context. 462 * Kernel context.
456 */ 463 */
457int 464int
458qla2x00_get_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts) 465qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts)
459{ 466{
460 int rval; 467 int rval;
461 mbx_cmd_t mc; 468 mbx_cmd_t mc;
462 mbx_cmd_t *mcp = &mc; 469 mbx_cmd_t *mcp = &mc;
463 470
464 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 471 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
465 472
466 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; 473 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION;
467 mcp->out_mb = MBX_0; 474 mcp->out_mb = MBX_0;
468 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 475 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
469 mcp->tov = MBX_TOV_SECONDS; 476 mcp->tov = MBX_TOV_SECONDS;
470 mcp->flags = 0; 477 mcp->flags = 0;
471 rval = qla2x00_mailbox_command(ha, mcp); 478 rval = qla2x00_mailbox_command(vha, mcp);
472 479
473 if (rval != QLA_SUCCESS) { 480 if (rval != QLA_SUCCESS) {
474 /*EMPTY*/ 481 /*EMPTY*/
475 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 482 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
476 ha->host_no, rval)); 483 vha->host_no, rval));
477 } else { 484 } else {
478 fwopts[0] = mcp->mb[0]; 485 fwopts[0] = mcp->mb[0];
479 fwopts[1] = mcp->mb[1]; 486 fwopts[1] = mcp->mb[1];
480 fwopts[2] = mcp->mb[2]; 487 fwopts[2] = mcp->mb[2];
481 fwopts[3] = mcp->mb[3]; 488 fwopts[3] = mcp->mb[3];
482 489
483 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 490 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
484 } 491 }
485 492
486 return rval; 493 return rval;
@@ -502,13 +509,13 @@ qla2x00_get_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
502 * Kernel context. 509 * Kernel context.
503 */ 510 */
504int 511int
505qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts) 512qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts)
506{ 513{
507 int rval; 514 int rval;
508 mbx_cmd_t mc; 515 mbx_cmd_t mc;
509 mbx_cmd_t *mcp = &mc; 516 mbx_cmd_t *mcp = &mc;
510 517
511 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 518 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
512 519
513 mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; 520 mcp->mb[0] = MBC_SET_FIRMWARE_OPTION;
514 mcp->mb[1] = fwopts[1]; 521 mcp->mb[1] = fwopts[1];
@@ -516,7 +523,7 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
516 mcp->mb[3] = fwopts[3]; 523 mcp->mb[3] = fwopts[3];
517 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 524 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
518 mcp->in_mb = MBX_0; 525 mcp->in_mb = MBX_0;
519 if (IS_FWI2_CAPABLE(ha)) { 526 if (IS_FWI2_CAPABLE(vha->hw)) {
520 mcp->in_mb |= MBX_1; 527 mcp->in_mb |= MBX_1;
521 } else { 528 } else {
522 mcp->mb[10] = fwopts[10]; 529 mcp->mb[10] = fwopts[10];
@@ -526,17 +533,17 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
526 } 533 }
527 mcp->tov = MBX_TOV_SECONDS; 534 mcp->tov = MBX_TOV_SECONDS;
528 mcp->flags = 0; 535 mcp->flags = 0;
529 rval = qla2x00_mailbox_command(ha, mcp); 536 rval = qla2x00_mailbox_command(vha, mcp);
530 537
531 fwopts[0] = mcp->mb[0]; 538 fwopts[0] = mcp->mb[0];
532 539
533 if (rval != QLA_SUCCESS) { 540 if (rval != QLA_SUCCESS) {
534 /*EMPTY*/ 541 /*EMPTY*/
535 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__, 542 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__,
536 ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 543 vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
537 } else { 544 } else {
538 /*EMPTY*/ 545 /*EMPTY*/
539 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 546 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
540 } 547 }
541 548
542 return rval; 549 return rval;
@@ -558,13 +565,14 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
558 * Kernel context. 565 * Kernel context.
559 */ 566 */
560int 567int
561qla2x00_mbx_reg_test(scsi_qla_host_t *ha) 568qla2x00_mbx_reg_test(scsi_qla_host_t *vha)
562{ 569{
563 int rval; 570 int rval;
571 struct qla_hw_data *ha = vha->hw;
564 mbx_cmd_t mc; 572 mbx_cmd_t mc;
565 mbx_cmd_t *mcp = &mc; 573 mbx_cmd_t *mcp = &mc;
566 574
567 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no)); 575 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", vha->host_no));
568 576
569 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; 577 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
570 mcp->mb[1] = 0xAAAA; 578 mcp->mb[1] = 0xAAAA;
@@ -578,7 +586,7 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
578 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 586 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
579 mcp->tov = MBX_TOV_SECONDS; 587 mcp->tov = MBX_TOV_SECONDS;
580 mcp->flags = 0; 588 mcp->flags = 0;
581 rval = qla2x00_mailbox_command(ha, mcp); 589 rval = qla2x00_mailbox_command(vha, mcp);
582 590
583 if (rval == QLA_SUCCESS) { 591 if (rval == QLA_SUCCESS) {
584 if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || 592 if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 ||
@@ -591,7 +599,7 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
591 struct device_reg_24xx __iomem *reg = 599 struct device_reg_24xx __iomem *reg =
592 &ha->iobase->isp24; 600 &ha->iobase->isp24;
593 601
594 qla2xxx_hw_event_log(ha, HW_EVENT_ISP_ERR, 0, 602 qla2xxx_hw_event_log(vha, HW_EVENT_ISP_ERR, 0,
595 LSW(RD_REG_DWORD(&reg->hccr)), 603 LSW(RD_REG_DWORD(&reg->hccr)),
596 LSW(RD_REG_DWORD(&reg->istatus))); 604 LSW(RD_REG_DWORD(&reg->istatus)));
597 } 605 }
@@ -600,11 +608,11 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
600 if (rval != QLA_SUCCESS) { 608 if (rval != QLA_SUCCESS) {
601 /*EMPTY*/ 609 /*EMPTY*/
602 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n", 610 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
603 ha->host_no, rval)); 611 vha->host_no, rval));
604 } else { 612 } else {
605 /*EMPTY*/ 613 /*EMPTY*/
606 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n", 614 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
607 ha->host_no)); 615 vha->host_no));
608 } 616 }
609 617
610 return rval; 618 return rval;
@@ -626,18 +634,18 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
626 * Kernel context. 634 * Kernel context.
627 */ 635 */
628int 636int
629qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr) 637qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr)
630{ 638{
631 int rval; 639 int rval;
632 mbx_cmd_t mc; 640 mbx_cmd_t mc;
633 mbx_cmd_t *mcp = &mc; 641 mbx_cmd_t *mcp = &mc;
634 642
635 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 643 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
636 644
637 mcp->mb[0] = MBC_VERIFY_CHECKSUM; 645 mcp->mb[0] = MBC_VERIFY_CHECKSUM;
638 mcp->out_mb = MBX_0; 646 mcp->out_mb = MBX_0;
639 mcp->in_mb = MBX_0; 647 mcp->in_mb = MBX_0;
640 if (IS_FWI2_CAPABLE(ha)) { 648 if (IS_FWI2_CAPABLE(vha->hw)) {
641 mcp->mb[1] = MSW(risc_addr); 649 mcp->mb[1] = MSW(risc_addr);
642 mcp->mb[2] = LSW(risc_addr); 650 mcp->mb[2] = LSW(risc_addr);
643 mcp->out_mb |= MBX_2|MBX_1; 651 mcp->out_mb |= MBX_2|MBX_1;
@@ -650,14 +658,14 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
650 658
651 mcp->tov = MBX_TOV_SECONDS; 659 mcp->tov = MBX_TOV_SECONDS;
652 mcp->flags = 0; 660 mcp->flags = 0;
653 rval = qla2x00_mailbox_command(ha, mcp); 661 rval = qla2x00_mailbox_command(vha, mcp);
654 662
655 if (rval != QLA_SUCCESS) { 663 if (rval != QLA_SUCCESS) {
656 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__, 664 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__,
657 ha->host_no, rval, IS_FWI2_CAPABLE(ha) ? 665 vha->host_no, rval, IS_FWI2_CAPABLE(vha->hw) ?
658 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1])); 666 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]));
659 } else { 667 } else {
660 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 668 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
661 } 669 }
662 670
663 return rval; 671 return rval;
@@ -682,7 +690,7 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
682 * Kernel context. 690 * Kernel context.
683 */ 691 */
684static int 692static int
685qla2x00_issue_iocb_timeout(scsi_qla_host_t *ha, void *buffer, 693qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer,
686 dma_addr_t phys_addr, size_t size, uint32_t tov) 694 dma_addr_t phys_addr, size_t size, uint32_t tov)
687{ 695{
688 int rval; 696 int rval;
@@ -699,30 +707,28 @@ qla2x00_issue_iocb_timeout(scsi_qla_host_t *ha, void *buffer,
699 mcp->in_mb = MBX_2|MBX_0; 707 mcp->in_mb = MBX_2|MBX_0;
700 mcp->tov = tov; 708 mcp->tov = tov;
701 mcp->flags = 0; 709 mcp->flags = 0;
702 rval = qla2x00_mailbox_command(ha, mcp); 710 rval = qla2x00_mailbox_command(vha, mcp);
703 711
704 if (rval != QLA_SUCCESS) { 712 if (rval != QLA_SUCCESS) {
705 /*EMPTY*/ 713 /*EMPTY*/
706 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n", 714 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
707 ha->host_no, rval)); 715 vha->host_no, rval));
708 DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
709 ha->host_no, rval));
710 } else { 716 } else {
711 sts_entry_t *sts_entry = (sts_entry_t *) buffer; 717 sts_entry_t *sts_entry = (sts_entry_t *) buffer;
712 718
713 /* Mask reserved bits. */ 719 /* Mask reserved bits. */
714 sts_entry->entry_status &= 720 sts_entry->entry_status &=
715 IS_FWI2_CAPABLE(ha) ? RF_MASK_24XX :RF_MASK; 721 IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK;
716 } 722 }
717 723
718 return rval; 724 return rval;
719} 725}
720 726
721int 727int
722qla2x00_issue_iocb(scsi_qla_host_t *ha, void *buffer, dma_addr_t phys_addr, 728qla2x00_issue_iocb(scsi_qla_host_t *vha, void *buffer, dma_addr_t phys_addr,
723 size_t size) 729 size_t size)
724{ 730{
725 return qla2x00_issue_iocb_timeout(ha, buffer, phys_addr, size, 731 return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size,
726 MBX_TOV_SECONDS); 732 MBX_TOV_SECONDS);
727} 733}
728 734
@@ -741,22 +747,23 @@ qla2x00_issue_iocb(scsi_qla_host_t *ha, void *buffer, dma_addr_t phys_addr,
741 * Kernel context. 747 * Kernel context.
742 */ 748 */
743int 749int
744qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp) 750qla2x00_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req)
745{ 751{
746 unsigned long flags = 0; 752 unsigned long flags = 0;
747 fc_port_t *fcport; 753 fc_port_t *fcport;
748 int rval; 754 int rval;
749 uint32_t handle; 755 uint32_t handle = 0;
750 mbx_cmd_t mc; 756 mbx_cmd_t mc;
751 mbx_cmd_t *mcp = &mc; 757 mbx_cmd_t *mcp = &mc;
758 struct qla_hw_data *ha = vha->hw;
752 759
753 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no)); 760 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", vha->host_no));
754 761
755 fcport = sp->fcport; 762 fcport = sp->fcport;
756 763
757 spin_lock_irqsave(&ha->hardware_lock, flags); 764 spin_lock_irqsave(&ha->hardware_lock, flags);
758 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 765 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
759 if (ha->outstanding_cmds[handle] == sp) 766 if (req->outstanding_cmds[handle] == sp)
760 break; 767 break;
761 } 768 }
762 spin_unlock_irqrestore(&ha->hardware_lock, flags); 769 spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -778,14 +785,14 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
778 mcp->in_mb = MBX_0; 785 mcp->in_mb = MBX_0;
779 mcp->tov = MBX_TOV_SECONDS; 786 mcp->tov = MBX_TOV_SECONDS;
780 mcp->flags = 0; 787 mcp->flags = 0;
781 rval = qla2x00_mailbox_command(ha, mcp); 788 rval = qla2x00_mailbox_command(vha, mcp);
782 789
783 if (rval != QLA_SUCCESS) { 790 if (rval != QLA_SUCCESS) {
784 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n", 791 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
785 ha->host_no, rval)); 792 vha->host_no, rval));
786 } else { 793 } else {
787 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n", 794 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
788 ha->host_no)); 795 vha->host_no));
789 } 796 }
790 797
791 return rval; 798 return rval;
@@ -797,40 +804,45 @@ qla2x00_abort_target(struct fc_port *fcport, unsigned int l)
797 int rval, rval2; 804 int rval, rval2;
798 mbx_cmd_t mc; 805 mbx_cmd_t mc;
799 mbx_cmd_t *mcp = &mc; 806 mbx_cmd_t *mcp = &mc;
800 scsi_qla_host_t *ha; 807 scsi_qla_host_t *vha;
808 struct req_que *req;
809 struct rsp_que *rsp;
801 810
802 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 811 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
803 812
804 l = l; 813 l = l;
805 ha = fcport->ha; 814 vha = fcport->vha;
815 req = vha->hw->req_q_map[0];
816 rsp = vha->hw->rsp_q_map[0];
806 mcp->mb[0] = MBC_ABORT_TARGET; 817 mcp->mb[0] = MBC_ABORT_TARGET;
807 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; 818 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
808 if (HAS_EXTENDED_IDS(ha)) { 819 if (HAS_EXTENDED_IDS(vha->hw)) {
809 mcp->mb[1] = fcport->loop_id; 820 mcp->mb[1] = fcport->loop_id;
810 mcp->mb[10] = 0; 821 mcp->mb[10] = 0;
811 mcp->out_mb |= MBX_10; 822 mcp->out_mb |= MBX_10;
812 } else { 823 } else {
813 mcp->mb[1] = fcport->loop_id << 8; 824 mcp->mb[1] = fcport->loop_id << 8;
814 } 825 }
815 mcp->mb[2] = ha->loop_reset_delay; 826 mcp->mb[2] = vha->hw->loop_reset_delay;
816 mcp->mb[9] = ha->vp_idx; 827 mcp->mb[9] = vha->vp_idx;
817 828
818 mcp->in_mb = MBX_0; 829 mcp->in_mb = MBX_0;
819 mcp->tov = MBX_TOV_SECONDS; 830 mcp->tov = MBX_TOV_SECONDS;
820 mcp->flags = 0; 831 mcp->flags = 0;
821 rval = qla2x00_mailbox_command(ha, mcp); 832 rval = qla2x00_mailbox_command(vha, mcp);
822 if (rval != QLA_SUCCESS) { 833 if (rval != QLA_SUCCESS) {
823 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 834 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
824 ha->host_no, rval)); 835 vha->host_no, rval));
825 } 836 }
826 837
827 /* Issue marker IOCB. */ 838 /* Issue marker IOCB. */
828 rval2 = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID); 839 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0,
840 MK_SYNC_ID);
829 if (rval2 != QLA_SUCCESS) { 841 if (rval2 != QLA_SUCCESS) {
830 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 842 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
831 "(%x).\n", __func__, ha->host_no, rval2)); 843 "(%x).\n", __func__, vha->host_no, rval2));
832 } else { 844 } else {
833 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 845 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
834 } 846 }
835 847
836 return rval; 848 return rval;
@@ -842,37 +854,42 @@ qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
842 int rval, rval2; 854 int rval, rval2;
843 mbx_cmd_t mc; 855 mbx_cmd_t mc;
844 mbx_cmd_t *mcp = &mc; 856 mbx_cmd_t *mcp = &mc;
845 scsi_qla_host_t *ha; 857 scsi_qla_host_t *vha;
858 struct req_que *req;
859 struct rsp_que *rsp;
846 860
847 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 861 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
848 862
849 ha = fcport->ha; 863 vha = fcport->vha;
864 req = vha->hw->req_q_map[0];
865 rsp = vha->hw->rsp_q_map[0];
850 mcp->mb[0] = MBC_LUN_RESET; 866 mcp->mb[0] = MBC_LUN_RESET;
851 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; 867 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
852 if (HAS_EXTENDED_IDS(ha)) 868 if (HAS_EXTENDED_IDS(vha->hw))
853 mcp->mb[1] = fcport->loop_id; 869 mcp->mb[1] = fcport->loop_id;
854 else 870 else
855 mcp->mb[1] = fcport->loop_id << 8; 871 mcp->mb[1] = fcport->loop_id << 8;
856 mcp->mb[2] = l; 872 mcp->mb[2] = l;
857 mcp->mb[3] = 0; 873 mcp->mb[3] = 0;
858 mcp->mb[9] = ha->vp_idx; 874 mcp->mb[9] = vha->vp_idx;
859 875
860 mcp->in_mb = MBX_0; 876 mcp->in_mb = MBX_0;
861 mcp->tov = MBX_TOV_SECONDS; 877 mcp->tov = MBX_TOV_SECONDS;
862 mcp->flags = 0; 878 mcp->flags = 0;
863 rval = qla2x00_mailbox_command(ha, mcp); 879 rval = qla2x00_mailbox_command(vha, mcp);
864 if (rval != QLA_SUCCESS) { 880 if (rval != QLA_SUCCESS) {
865 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 881 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
866 ha->host_no, rval)); 882 vha->host_no, rval));
867 } 883 }
868 884
869 /* Issue marker IOCB. */ 885 /* Issue marker IOCB. */
870 rval2 = qla2x00_marker(ha, fcport->loop_id, l, MK_SYNC_ID_LUN); 886 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
887 MK_SYNC_ID_LUN);
871 if (rval2 != QLA_SUCCESS) { 888 if (rval2 != QLA_SUCCESS) {
872 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 889 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
873 "(%x).\n", __func__, ha->host_no, rval2)); 890 "(%x).\n", __func__, vha->host_no, rval2));
874 } else { 891 } else {
875 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 892 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
876 } 893 }
877 894
878 return rval; 895 return rval;
@@ -899,7 +916,7 @@ qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
899 * Kernel context. 916 * Kernel context.
900 */ 917 */
901int 918int
902qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa, 919qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
903 uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap) 920 uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap)
904{ 921{
905 int rval; 922 int rval;
@@ -907,15 +924,15 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
907 mbx_cmd_t *mcp = &mc; 924 mbx_cmd_t *mcp = &mc;
908 925
909 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n", 926 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
910 ha->host_no)); 927 vha->host_no));
911 928
912 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; 929 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
913 mcp->mb[9] = ha->vp_idx; 930 mcp->mb[9] = vha->vp_idx;
914 mcp->out_mb = MBX_9|MBX_0; 931 mcp->out_mb = MBX_9|MBX_0;
915 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 932 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
916 mcp->tov = MBX_TOV_SECONDS; 933 mcp->tov = MBX_TOV_SECONDS;
917 mcp->flags = 0; 934 mcp->flags = 0;
918 rval = qla2x00_mailbox_command(ha, mcp); 935 rval = qla2x00_mailbox_command(vha, mcp);
919 if (mcp->mb[0] == MBS_COMMAND_ERROR) 936 if (mcp->mb[0] == MBS_COMMAND_ERROR)
920 rval = QLA_COMMAND_ERROR; 937 rval = QLA_COMMAND_ERROR;
921 else if (mcp->mb[0] == MBS_INVALID_COMMAND) 938 else if (mcp->mb[0] == MBS_INVALID_COMMAND)
@@ -932,11 +949,11 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
932 if (rval != QLA_SUCCESS) { 949 if (rval != QLA_SUCCESS) {
933 /*EMPTY*/ 950 /*EMPTY*/
934 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n", 951 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
935 ha->host_no, rval)); 952 vha->host_no, rval));
936 } else { 953 } else {
937 /*EMPTY*/ 954 /*EMPTY*/
938 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n", 955 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
939 ha->host_no)); 956 vha->host_no));
940 } 957 }
941 958
942 return rval; 959 return rval;
@@ -958,7 +975,7 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
958 * Kernel context. 975 * Kernel context.
959 */ 976 */
960int 977int
961qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov, 978qla2x00_get_retry_cnt(scsi_qla_host_t *vha, uint8_t *retry_cnt, uint8_t *tov,
962 uint16_t *r_a_tov) 979 uint16_t *r_a_tov)
963{ 980{
964 int rval; 981 int rval;
@@ -967,19 +984,19 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
967 mbx_cmd_t *mcp = &mc; 984 mbx_cmd_t *mcp = &mc;
968 985
969 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n", 986 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
970 ha->host_no)); 987 vha->host_no));
971 988
972 mcp->mb[0] = MBC_GET_RETRY_COUNT; 989 mcp->mb[0] = MBC_GET_RETRY_COUNT;
973 mcp->out_mb = MBX_0; 990 mcp->out_mb = MBX_0;
974 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 991 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
975 mcp->tov = MBX_TOV_SECONDS; 992 mcp->tov = MBX_TOV_SECONDS;
976 mcp->flags = 0; 993 mcp->flags = 0;
977 rval = qla2x00_mailbox_command(ha, mcp); 994 rval = qla2x00_mailbox_command(vha, mcp);
978 995
979 if (rval != QLA_SUCCESS) { 996 if (rval != QLA_SUCCESS) {
980 /*EMPTY*/ 997 /*EMPTY*/
981 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n", 998 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
982 ha->host_no, mcp->mb[0])); 999 vha->host_no, mcp->mb[0]));
983 } else { 1000 } else {
984 /* Convert returned data and check our values. */ 1001 /* Convert returned data and check our values. */
985 *r_a_tov = mcp->mb[3] / 2; 1002 *r_a_tov = mcp->mb[3] / 2;
@@ -991,7 +1008,7 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
991 } 1008 }
992 1009
993 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d " 1010 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
994 "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov)); 1011 "ratov=%d.\n", vha->host_no, mcp->mb[3], ratov));
995 } 1012 }
996 1013
997 return rval; 1014 return rval;
@@ -1015,14 +1032,15 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
1015 * Kernel context. 1032 * Kernel context.
1016 */ 1033 */
1017int 1034int
1018qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size) 1035qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size)
1019{ 1036{
1020 int rval; 1037 int rval;
1021 mbx_cmd_t mc; 1038 mbx_cmd_t mc;
1022 mbx_cmd_t *mcp = &mc; 1039 mbx_cmd_t *mcp = &mc;
1040 struct qla_hw_data *ha = vha->hw;
1023 1041
1024 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n", 1042 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1025 ha->host_no)); 1043 vha->host_no));
1026 1044
1027 if (ha->flags.npiv_supported) 1045 if (ha->flags.npiv_supported)
1028 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; 1046 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE;
@@ -1040,17 +1058,17 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
1040 mcp->buf_size = size; 1058 mcp->buf_size = size;
1041 mcp->flags = MBX_DMA_OUT; 1059 mcp->flags = MBX_DMA_OUT;
1042 mcp->tov = MBX_TOV_SECONDS; 1060 mcp->tov = MBX_TOV_SECONDS;
1043 rval = qla2x00_mailbox_command(ha, mcp); 1061 rval = qla2x00_mailbox_command(vha, mcp);
1044 1062
1045 if (rval != QLA_SUCCESS) { 1063 if (rval != QLA_SUCCESS) {
1046 /*EMPTY*/ 1064 /*EMPTY*/
1047 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x " 1065 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
1048 "mb0=%x.\n", 1066 "mb0=%x.\n",
1049 ha->host_no, rval, mcp->mb[0])); 1067 vha->host_no, rval, mcp->mb[0]));
1050 } else { 1068 } else {
1051 /*EMPTY*/ 1069 /*EMPTY*/
1052 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n", 1070 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
1053 ha->host_no)); 1071 vha->host_no));
1054 } 1072 }
1055 1073
1056 return rval; 1074 return rval;
@@ -1073,7 +1091,7 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
1073 * Kernel context. 1091 * Kernel context.
1074 */ 1092 */
1075int 1093int
1076qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt) 1094qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
1077{ 1095{
1078 int rval; 1096 int rval;
1079 mbx_cmd_t mc; 1097 mbx_cmd_t mc;
@@ -1081,14 +1099,15 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1081 port_database_t *pd; 1099 port_database_t *pd;
1082 struct port_database_24xx *pd24; 1100 struct port_database_24xx *pd24;
1083 dma_addr_t pd_dma; 1101 dma_addr_t pd_dma;
1102 struct qla_hw_data *ha = vha->hw;
1084 1103
1085 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1104 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1086 1105
1087 pd24 = NULL; 1106 pd24 = NULL;
1088 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); 1107 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
1089 if (pd == NULL) { 1108 if (pd == NULL) {
1090 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database " 1109 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database "
1091 "structure.\n", __func__, ha->host_no)); 1110 "structure.\n", __func__, vha->host_no));
1092 return QLA_MEMORY_ALLOC_FAILED; 1111 return QLA_MEMORY_ALLOC_FAILED;
1093 } 1112 }
1094 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); 1113 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
@@ -1100,7 +1119,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1100 mcp->mb[3] = LSW(pd_dma); 1119 mcp->mb[3] = LSW(pd_dma);
1101 mcp->mb[6] = MSW(MSD(pd_dma)); 1120 mcp->mb[6] = MSW(MSD(pd_dma));
1102 mcp->mb[7] = LSW(MSD(pd_dma)); 1121 mcp->mb[7] = LSW(MSD(pd_dma));
1103 mcp->mb[9] = ha->vp_idx; 1122 mcp->mb[9] = vha->vp_idx;
1104 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 1123 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
1105 mcp->in_mb = MBX_0; 1124 mcp->in_mb = MBX_0;
1106 if (IS_FWI2_CAPABLE(ha)) { 1125 if (IS_FWI2_CAPABLE(ha)) {
@@ -1120,7 +1139,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1120 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; 1139 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE;
1121 mcp->flags = MBX_DMA_IN; 1140 mcp->flags = MBX_DMA_IN;
1122 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1141 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1123 rval = qla2x00_mailbox_command(ha, mcp); 1142 rval = qla2x00_mailbox_command(vha, mcp);
1124 if (rval != QLA_SUCCESS) 1143 if (rval != QLA_SUCCESS)
1125 goto gpd_error_out; 1144 goto gpd_error_out;
1126 1145
@@ -1132,7 +1151,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1132 pd24->last_login_state != PDS_PRLI_COMPLETE) { 1151 pd24->last_login_state != PDS_PRLI_COMPLETE) {
1133 DEBUG2(printk("%s(%ld): Unable to verify " 1152 DEBUG2(printk("%s(%ld): Unable to verify "
1134 "login-state (%x/%x) for loop_id %x\n", 1153 "login-state (%x/%x) for loop_id %x\n",
1135 __func__, ha->host_no, 1154 __func__, vha->host_no,
1136 pd24->current_login_state, 1155 pd24->current_login_state,
1137 pd24->last_login_state, fcport->loop_id)); 1156 pd24->last_login_state, fcport->loop_id));
1138 rval = QLA_FUNCTION_FAILED; 1157 rval = QLA_FUNCTION_FAILED;
@@ -1192,9 +1211,9 @@ gpd_error_out:
1192 1211
1193 if (rval != QLA_SUCCESS) { 1212 if (rval != QLA_SUCCESS) {
1194 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 1213 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
1195 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1214 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1196 } else { 1215 } else {
1197 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1216 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1198 } 1217 }
1199 1218
1200 return rval; 1219 return rval;
@@ -1217,21 +1236,21 @@ gpd_error_out:
1217 * Kernel context. 1236 * Kernel context.
1218 */ 1237 */
1219int 1238int
1220qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states) 1239qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states)
1221{ 1240{
1222 int rval; 1241 int rval;
1223 mbx_cmd_t mc; 1242 mbx_cmd_t mc;
1224 mbx_cmd_t *mcp = &mc; 1243 mbx_cmd_t *mcp = &mc;
1225 1244
1226 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n", 1245 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
1227 ha->host_no)); 1246 vha->host_no));
1228 1247
1229 mcp->mb[0] = MBC_GET_FIRMWARE_STATE; 1248 mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
1230 mcp->out_mb = MBX_0; 1249 mcp->out_mb = MBX_0;
1231 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1250 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1232 mcp->tov = MBX_TOV_SECONDS; 1251 mcp->tov = MBX_TOV_SECONDS;
1233 mcp->flags = 0; 1252 mcp->flags = 0;
1234 rval = qla2x00_mailbox_command(ha, mcp); 1253 rval = qla2x00_mailbox_command(vha, mcp);
1235 1254
1236 /* Return firmware states. */ 1255 /* Return firmware states. */
1237 states[0] = mcp->mb[1]; 1256 states[0] = mcp->mb[1];
@@ -1241,11 +1260,11 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states)
1241 if (rval != QLA_SUCCESS) { 1260 if (rval != QLA_SUCCESS) {
1242 /*EMPTY*/ 1261 /*EMPTY*/
1243 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): " 1262 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
1244 "failed=%x.\n", ha->host_no, rval)); 1263 "failed=%x.\n", vha->host_no, rval));
1245 } else { 1264 } else {
1246 /*EMPTY*/ 1265 /*EMPTY*/
1247 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n", 1266 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
1248 ha->host_no)); 1267 vha->host_no));
1249 } 1268 }
1250 1269
1251 return rval; 1270 return rval;
@@ -1270,7 +1289,7 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states)
1270 * Kernel context. 1289 * Kernel context.
1271 */ 1290 */
1272int 1291int
1273qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name, 1292qla2x00_get_port_name(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t *name,
1274 uint8_t opt) 1293 uint8_t opt)
1275{ 1294{
1276 int rval; 1295 int rval;
@@ -1278,12 +1297,12 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1278 mbx_cmd_t *mcp = &mc; 1297 mbx_cmd_t *mcp = &mc;
1279 1298
1280 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n", 1299 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
1281 ha->host_no)); 1300 vha->host_no));
1282 1301
1283 mcp->mb[0] = MBC_GET_PORT_NAME; 1302 mcp->mb[0] = MBC_GET_PORT_NAME;
1284 mcp->mb[9] = ha->vp_idx; 1303 mcp->mb[9] = vha->vp_idx;
1285 mcp->out_mb = MBX_9|MBX_1|MBX_0; 1304 mcp->out_mb = MBX_9|MBX_1|MBX_0;
1286 if (HAS_EXTENDED_IDS(ha)) { 1305 if (HAS_EXTENDED_IDS(vha->hw)) {
1287 mcp->mb[1] = loop_id; 1306 mcp->mb[1] = loop_id;
1288 mcp->mb[10] = opt; 1307 mcp->mb[10] = opt;
1289 mcp->out_mb |= MBX_10; 1308 mcp->out_mb |= MBX_10;
@@ -1294,12 +1313,12 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1294 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1313 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1295 mcp->tov = MBX_TOV_SECONDS; 1314 mcp->tov = MBX_TOV_SECONDS;
1296 mcp->flags = 0; 1315 mcp->flags = 0;
1297 rval = qla2x00_mailbox_command(ha, mcp); 1316 rval = qla2x00_mailbox_command(vha, mcp);
1298 1317
1299 if (rval != QLA_SUCCESS) { 1318 if (rval != QLA_SUCCESS) {
1300 /*EMPTY*/ 1319 /*EMPTY*/
1301 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n", 1320 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
1302 ha->host_no, rval)); 1321 vha->host_no, rval));
1303 } else { 1322 } else {
1304 if (name != NULL) { 1323 if (name != NULL) {
1305 /* This function returns name in big endian. */ 1324 /* This function returns name in big endian. */
@@ -1314,7 +1333,7 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1314 } 1333 }
1315 1334
1316 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n", 1335 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
1317 ha->host_no)); 1336 vha->host_no));
1318 } 1337 }
1319 1338
1320 return rval; 1339 return rval;
@@ -1336,45 +1355,45 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1336 * Kernel context. 1355 * Kernel context.
1337 */ 1356 */
1338int 1357int
1339qla2x00_lip_reset(scsi_qla_host_t *ha) 1358qla2x00_lip_reset(scsi_qla_host_t *vha)
1340{ 1359{
1341 int rval; 1360 int rval;
1342 mbx_cmd_t mc; 1361 mbx_cmd_t mc;
1343 mbx_cmd_t *mcp = &mc; 1362 mbx_cmd_t *mcp = &mc;
1344 1363
1345 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1364 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1346 1365
1347 if (IS_FWI2_CAPABLE(ha)) { 1366 if (IS_FWI2_CAPABLE(vha->hw)) {
1348 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1367 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1349 mcp->mb[1] = BIT_6; 1368 mcp->mb[1] = BIT_6;
1350 mcp->mb[2] = 0; 1369 mcp->mb[2] = 0;
1351 mcp->mb[3] = ha->loop_reset_delay; 1370 mcp->mb[3] = vha->hw->loop_reset_delay;
1352 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1371 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1353 } else { 1372 } else {
1354 mcp->mb[0] = MBC_LIP_RESET; 1373 mcp->mb[0] = MBC_LIP_RESET;
1355 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1374 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1356 if (HAS_EXTENDED_IDS(ha)) { 1375 if (HAS_EXTENDED_IDS(vha->hw)) {
1357 mcp->mb[1] = 0x00ff; 1376 mcp->mb[1] = 0x00ff;
1358 mcp->mb[10] = 0; 1377 mcp->mb[10] = 0;
1359 mcp->out_mb |= MBX_10; 1378 mcp->out_mb |= MBX_10;
1360 } else { 1379 } else {
1361 mcp->mb[1] = 0xff00; 1380 mcp->mb[1] = 0xff00;
1362 } 1381 }
1363 mcp->mb[2] = ha->loop_reset_delay; 1382 mcp->mb[2] = vha->hw->loop_reset_delay;
1364 mcp->mb[3] = 0; 1383 mcp->mb[3] = 0;
1365 } 1384 }
1366 mcp->in_mb = MBX_0; 1385 mcp->in_mb = MBX_0;
1367 mcp->tov = MBX_TOV_SECONDS; 1386 mcp->tov = MBX_TOV_SECONDS;
1368 mcp->flags = 0; 1387 mcp->flags = 0;
1369 rval = qla2x00_mailbox_command(ha, mcp); 1388 rval = qla2x00_mailbox_command(vha, mcp);
1370 1389
1371 if (rval != QLA_SUCCESS) { 1390 if (rval != QLA_SUCCESS) {
1372 /*EMPTY*/ 1391 /*EMPTY*/
1373 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", 1392 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
1374 __func__, ha->host_no, rval)); 1393 __func__, vha->host_no, rval));
1375 } else { 1394 } else {
1376 /*EMPTY*/ 1395 /*EMPTY*/
1377 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1396 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1378 } 1397 }
1379 1398
1380 return rval; 1399 return rval;
@@ -1399,7 +1418,7 @@ qla2x00_lip_reset(scsi_qla_host_t *ha)
1399 * Kernel context. 1418 * Kernel context.
1400 */ 1419 */
1401int 1420int
1402qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address, 1421qla2x00_send_sns(scsi_qla_host_t *vha, dma_addr_t sns_phys_address,
1403 uint16_t cmd_size, size_t buf_size) 1422 uint16_t cmd_size, size_t buf_size)
1404{ 1423{
1405 int rval; 1424 int rval;
@@ -1407,10 +1426,11 @@ qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
1407 mbx_cmd_t *mcp = &mc; 1426 mbx_cmd_t *mcp = &mc;
1408 1427
1409 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n", 1428 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
1410 ha->host_no)); 1429 vha->host_no));
1411 1430
1412 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total " 1431 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
1413 "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov)); 1432 "tov=%d.\n", vha->hw->retry_count, vha->hw->login_timeout,
1433 mcp->tov));
1414 1434
1415 mcp->mb[0] = MBC_SEND_SNS_COMMAND; 1435 mcp->mb[0] = MBC_SEND_SNS_COMMAND;
1416 mcp->mb[1] = cmd_size; 1436 mcp->mb[1] = cmd_size;
@@ -1422,25 +1442,25 @@ qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
1422 mcp->in_mb = MBX_0|MBX_1; 1442 mcp->in_mb = MBX_0|MBX_1;
1423 mcp->buf_size = buf_size; 1443 mcp->buf_size = buf_size;
1424 mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; 1444 mcp->flags = MBX_DMA_OUT|MBX_DMA_IN;
1425 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1445 mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2);
1426 rval = qla2x00_mailbox_command(ha, mcp); 1446 rval = qla2x00_mailbox_command(vha, mcp);
1427 1447
1428 if (rval != QLA_SUCCESS) { 1448 if (rval != QLA_SUCCESS) {
1429 /*EMPTY*/ 1449 /*EMPTY*/
1430 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1450 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1431 "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1451 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1432 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1452 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1433 "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1453 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1434 } else { 1454 } else {
1435 /*EMPTY*/ 1455 /*EMPTY*/
1436 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no)); 1456 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", vha->host_no));
1437 } 1457 }
1438 1458
1439 return rval; 1459 return rval;
1440} 1460}
1441 1461
1442int 1462int
1443qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1463qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1444 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) 1464 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
1445{ 1465{
1446 int rval; 1466 int rval;
@@ -1448,13 +1468,14 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1448 struct logio_entry_24xx *lg; 1468 struct logio_entry_24xx *lg;
1449 dma_addr_t lg_dma; 1469 dma_addr_t lg_dma;
1450 uint32_t iop[2]; 1470 uint32_t iop[2];
1471 struct qla_hw_data *ha = vha->hw;
1451 1472
1452 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1473 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1453 1474
1454 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1475 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
1455 if (lg == NULL) { 1476 if (lg == NULL) {
1456 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n", 1477 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
1457 __func__, ha->host_no)); 1478 __func__, vha->host_no));
1458 return QLA_MEMORY_ALLOC_FAILED; 1479 return QLA_MEMORY_ALLOC_FAILED;
1459 } 1480 }
1460 memset(lg, 0, sizeof(struct logio_entry_24xx)); 1481 memset(lg, 0, sizeof(struct logio_entry_24xx));
@@ -1470,14 +1491,14 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1470 lg->port_id[0] = al_pa; 1491 lg->port_id[0] = al_pa;
1471 lg->port_id[1] = area; 1492 lg->port_id[1] = area;
1472 lg->port_id[2] = domain; 1493 lg->port_id[2] = domain;
1473 lg->vp_index = ha->vp_idx; 1494 lg->vp_index = vha->vp_idx;
1474 rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0); 1495 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0);
1475 if (rval != QLA_SUCCESS) { 1496 if (rval != QLA_SUCCESS) {
1476 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB " 1497 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
1477 "(%x).\n", __func__, ha->host_no, rval)); 1498 "(%x).\n", __func__, vha->host_no, rval));
1478 } else if (lg->entry_status != 0) { 1499 } else if (lg->entry_status != 0) {
1479 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1500 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1480 "-- error status (%x).\n", __func__, ha->host_no, 1501 "-- error status (%x).\n", __func__, vha->host_no,
1481 lg->entry_status)); 1502 lg->entry_status));
1482 rval = QLA_FUNCTION_FAILED; 1503 rval = QLA_FUNCTION_FAILED;
1483 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1504 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
@@ -1486,7 +1507,7 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1486 1507
1487 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1508 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1488 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1509 "-- completion status (%x) ioparam=%x/%x.\n", __func__,
1489 ha->host_no, le16_to_cpu(lg->comp_status), iop[0], 1510 vha->host_no, le16_to_cpu(lg->comp_status), iop[0],
1490 iop[1])); 1511 iop[1]));
1491 1512
1492 switch (iop[0]) { 1513 switch (iop[0]) {
@@ -1515,7 +1536,7 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1515 break; 1536 break;
1516 } 1537 }
1517 } else { 1538 } else {
1518 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1539 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1519 1540
1520 iop[0] = le32_to_cpu(lg->io_parameter[0]); 1541 iop[0] = le32_to_cpu(lg->io_parameter[0]);
1521 1542
@@ -1562,14 +1583,15 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1562 * Kernel context. 1583 * Kernel context.
1563 */ 1584 */
1564int 1585int
1565qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1586qla2x00_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1566 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) 1587 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
1567{ 1588{
1568 int rval; 1589 int rval;
1569 mbx_cmd_t mc; 1590 mbx_cmd_t mc;
1570 mbx_cmd_t *mcp = &mc; 1591 mbx_cmd_t *mcp = &mc;
1592 struct qla_hw_data *ha = vha->hw;
1571 1593
1572 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no)); 1594 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", vha->host_no));
1573 1595
1574 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; 1596 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT;
1575 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1597 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
@@ -1586,7 +1608,7 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1586 mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; 1608 mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0;
1587 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1609 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1588 mcp->flags = 0; 1610 mcp->flags = 0;
1589 rval = qla2x00_mailbox_command(ha, mcp); 1611 rval = qla2x00_mailbox_command(vha, mcp);
1590 1612
1591 /* Return mailbox statuses. */ 1613 /* Return mailbox statuses. */
1592 if (mb != NULL) { 1614 if (mb != NULL) {
@@ -1613,12 +1635,12 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1613 1635
1614 /*EMPTY*/ 1636 /*EMPTY*/
1615 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x " 1637 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
1616 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha->host_no, rval, 1638 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", vha->host_no, rval,
1617 mcp->mb[0], mcp->mb[1], mcp->mb[2])); 1639 mcp->mb[0], mcp->mb[1], mcp->mb[2]));
1618 } else { 1640 } else {
1619 /*EMPTY*/ 1641 /*EMPTY*/
1620 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n", 1642 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
1621 ha->host_no)); 1643 vha->host_no));
1622 } 1644 }
1623 1645
1624 return rval; 1646 return rval;
@@ -1641,19 +1663,20 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1641 * 1663 *
1642 */ 1664 */
1643int 1665int
1644qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport, 1666qla2x00_login_local_device(scsi_qla_host_t *vha, fc_port_t *fcport,
1645 uint16_t *mb_ret, uint8_t opt) 1667 uint16_t *mb_ret, uint8_t opt)
1646{ 1668{
1647 int rval; 1669 int rval;
1648 mbx_cmd_t mc; 1670 mbx_cmd_t mc;
1649 mbx_cmd_t *mcp = &mc; 1671 mbx_cmd_t *mcp = &mc;
1672 struct qla_hw_data *ha = vha->hw;
1650 1673
1651 if (IS_FWI2_CAPABLE(ha)) 1674 if (IS_FWI2_CAPABLE(ha))
1652 return qla24xx_login_fabric(ha, fcport->loop_id, 1675 return qla24xx_login_fabric(vha, fcport->loop_id,
1653 fcport->d_id.b.domain, fcport->d_id.b.area, 1676 fcport->d_id.b.domain, fcport->d_id.b.area,
1654 fcport->d_id.b.al_pa, mb_ret, opt); 1677 fcport->d_id.b.al_pa, mb_ret, opt);
1655 1678
1656 DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1679 DEBUG3(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1657 1680
1658 mcp->mb[0] = MBC_LOGIN_LOOP_PORT; 1681 mcp->mb[0] = MBC_LOGIN_LOOP_PORT;
1659 if (HAS_EXTENDED_IDS(ha)) 1682 if (HAS_EXTENDED_IDS(ha))
@@ -1665,7 +1688,7 @@ qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport,
1665 mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; 1688 mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0;
1666 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1689 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1667 mcp->flags = 0; 1690 mcp->flags = 0;
1668 rval = qla2x00_mailbox_command(ha, mcp); 1691 rval = qla2x00_mailbox_command(vha, mcp);
1669 1692
1670 /* Return mailbox statuses. */ 1693 /* Return mailbox statuses. */
1671 if (mb_ret != NULL) { 1694 if (mb_ret != NULL) {
@@ -1686,33 +1709,34 @@ qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport,
1686 rval = QLA_SUCCESS; 1709 rval = QLA_SUCCESS;
1687 1710
1688 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1711 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1689 "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval, 1712 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval,
1690 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1713 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
1691 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1714 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1692 "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval, 1715 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval,
1693 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1716 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
1694 } else { 1717 } else {
1695 /*EMPTY*/ 1718 /*EMPTY*/
1696 DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1719 DEBUG3(printk("%s(%ld): done.\n", __func__, vha->host_no));
1697 } 1720 }
1698 1721
1699 return (rval); 1722 return (rval);
1700} 1723}
1701 1724
1702int 1725int
1703qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1726qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1704 uint8_t area, uint8_t al_pa) 1727 uint8_t area, uint8_t al_pa)
1705{ 1728{
1706 int rval; 1729 int rval;
1707 struct logio_entry_24xx *lg; 1730 struct logio_entry_24xx *lg;
1708 dma_addr_t lg_dma; 1731 dma_addr_t lg_dma;
1732 struct qla_hw_data *ha = vha->hw;
1709 1733
1710 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1734 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1711 1735
1712 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1736 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
1713 if (lg == NULL) { 1737 if (lg == NULL) {
1714 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n", 1738 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n",
1715 __func__, ha->host_no)); 1739 __func__, vha->host_no));
1716 return QLA_MEMORY_ALLOC_FAILED; 1740 return QLA_MEMORY_ALLOC_FAILED;
1717 } 1741 }
1718 memset(lg, 0, sizeof(struct logio_entry_24xx)); 1742 memset(lg, 0, sizeof(struct logio_entry_24xx));
@@ -1725,25 +1749,26 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1725 lg->port_id[0] = al_pa; 1749 lg->port_id[0] = al_pa;
1726 lg->port_id[1] = area; 1750 lg->port_id[1] = area;
1727 lg->port_id[2] = domain; 1751 lg->port_id[2] = domain;
1728 lg->vp_index = ha->vp_idx; 1752 lg->vp_index = vha->vp_idx;
1729 rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0); 1753
1754 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0);
1730 if (rval != QLA_SUCCESS) { 1755 if (rval != QLA_SUCCESS) {
1731 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB " 1756 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
1732 "(%x).\n", __func__, ha->host_no, rval)); 1757 "(%x).\n", __func__, vha->host_no, rval));
1733 } else if (lg->entry_status != 0) { 1758 } else if (lg->entry_status != 0) {
1734 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1759 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1735 "-- error status (%x).\n", __func__, ha->host_no, 1760 "-- error status (%x).\n", __func__, vha->host_no,
1736 lg->entry_status)); 1761 lg->entry_status));
1737 rval = QLA_FUNCTION_FAILED; 1762 rval = QLA_FUNCTION_FAILED;
1738 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1763 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
1739 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1764 DEBUG2_3_11(printk("%s(%ld %d): failed to complete IOCB "
1740 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1765 "-- completion status (%x) ioparam=%x/%x.\n", __func__,
1741 ha->host_no, le16_to_cpu(lg->comp_status), 1766 vha->host_no, vha->vp_idx, le16_to_cpu(lg->comp_status),
1742 le32_to_cpu(lg->io_parameter[0]), 1767 le32_to_cpu(lg->io_parameter[0]),
1743 le32_to_cpu(lg->io_parameter[1]))); 1768 le32_to_cpu(lg->io_parameter[1])));
1744 } else { 1769 } else {
1745 /*EMPTY*/ 1770 /*EMPTY*/
1746 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1771 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1747 } 1772 }
1748 1773
1749 dma_pool_free(ha->s_dma_pool, lg, lg_dma); 1774 dma_pool_free(ha->s_dma_pool, lg, lg_dma);
@@ -1768,7 +1793,7 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1768 * Kernel context. 1793 * Kernel context.
1769 */ 1794 */
1770int 1795int
1771qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1796qla2x00_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1772 uint8_t area, uint8_t al_pa) 1797 uint8_t area, uint8_t al_pa)
1773{ 1798{
1774 int rval; 1799 int rval;
@@ -1776,11 +1801,11 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1776 mbx_cmd_t *mcp = &mc; 1801 mbx_cmd_t *mcp = &mc;
1777 1802
1778 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n", 1803 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
1779 ha->host_no)); 1804 vha->host_no));
1780 1805
1781 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; 1806 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;
1782 mcp->out_mb = MBX_1|MBX_0; 1807 mcp->out_mb = MBX_1|MBX_0;
1783 if (HAS_EXTENDED_IDS(ha)) { 1808 if (HAS_EXTENDED_IDS(vha->hw)) {
1784 mcp->mb[1] = loop_id; 1809 mcp->mb[1] = loop_id;
1785 mcp->mb[10] = 0; 1810 mcp->mb[10] = 0;
1786 mcp->out_mb |= MBX_10; 1811 mcp->out_mb |= MBX_10;
@@ -1791,16 +1816,16 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1791 mcp->in_mb = MBX_1|MBX_0; 1816 mcp->in_mb = MBX_1|MBX_0;
1792 mcp->tov = MBX_TOV_SECONDS; 1817 mcp->tov = MBX_TOV_SECONDS;
1793 mcp->flags = 0; 1818 mcp->flags = 0;
1794 rval = qla2x00_mailbox_command(ha, mcp); 1819 rval = qla2x00_mailbox_command(vha, mcp);
1795 1820
1796 if (rval != QLA_SUCCESS) { 1821 if (rval != QLA_SUCCESS) {
1797 /*EMPTY*/ 1822 /*EMPTY*/
1798 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x " 1823 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
1799 "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1])); 1824 "mbx1=%x.\n", vha->host_no, rval, mcp->mb[1]));
1800 } else { 1825 } else {
1801 /*EMPTY*/ 1826 /*EMPTY*/
1802 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n", 1827 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
1803 ha->host_no)); 1828 vha->host_no));
1804 } 1829 }
1805 1830
1806 return rval; 1831 return rval;
@@ -1822,33 +1847,33 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1822 * Kernel context. 1847 * Kernel context.
1823 */ 1848 */
1824int 1849int
1825qla2x00_full_login_lip(scsi_qla_host_t *ha) 1850qla2x00_full_login_lip(scsi_qla_host_t *vha)
1826{ 1851{
1827 int rval; 1852 int rval;
1828 mbx_cmd_t mc; 1853 mbx_cmd_t mc;
1829 mbx_cmd_t *mcp = &mc; 1854 mbx_cmd_t *mcp = &mc;
1830 1855
1831 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n", 1856 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
1832 ha->host_no)); 1857 vha->host_no));
1833 1858
1834 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1859 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1835 mcp->mb[1] = IS_FWI2_CAPABLE(ha) ? BIT_3: 0; 1860 mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0;
1836 mcp->mb[2] = 0; 1861 mcp->mb[2] = 0;
1837 mcp->mb[3] = 0; 1862 mcp->mb[3] = 0;
1838 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1863 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1839 mcp->in_mb = MBX_0; 1864 mcp->in_mb = MBX_0;
1840 mcp->tov = MBX_TOV_SECONDS; 1865 mcp->tov = MBX_TOV_SECONDS;
1841 mcp->flags = 0; 1866 mcp->flags = 0;
1842 rval = qla2x00_mailbox_command(ha, mcp); 1867 rval = qla2x00_mailbox_command(vha, mcp);
1843 1868
1844 if (rval != QLA_SUCCESS) { 1869 if (rval != QLA_SUCCESS) {
1845 /*EMPTY*/ 1870 /*EMPTY*/
1846 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n", 1871 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
1847 ha->host_no, rval)); 1872 vha->host_no, rval));
1848 } else { 1873 } else {
1849 /*EMPTY*/ 1874 /*EMPTY*/
1850 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n", 1875 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
1851 ha->host_no)); 1876 vha->host_no));
1852 } 1877 }
1853 1878
1854 return rval; 1879 return rval;
@@ -1867,7 +1892,7 @@ qla2x00_full_login_lip(scsi_qla_host_t *ha)
1867 * Kernel context. 1892 * Kernel context.
1868 */ 1893 */
1869int 1894int
1870qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma, 1895qla2x00_get_id_list(scsi_qla_host_t *vha, void *id_list, dma_addr_t id_list_dma,
1871 uint16_t *entries) 1896 uint16_t *entries)
1872{ 1897{
1873 int rval; 1898 int rval;
@@ -1875,20 +1900,20 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1875 mbx_cmd_t *mcp = &mc; 1900 mbx_cmd_t *mcp = &mc;
1876 1901
1877 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n", 1902 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
1878 ha->host_no)); 1903 vha->host_no));
1879 1904
1880 if (id_list == NULL) 1905 if (id_list == NULL)
1881 return QLA_FUNCTION_FAILED; 1906 return QLA_FUNCTION_FAILED;
1882 1907
1883 mcp->mb[0] = MBC_GET_ID_LIST; 1908 mcp->mb[0] = MBC_GET_ID_LIST;
1884 mcp->out_mb = MBX_0; 1909 mcp->out_mb = MBX_0;
1885 if (IS_FWI2_CAPABLE(ha)) { 1910 if (IS_FWI2_CAPABLE(vha->hw)) {
1886 mcp->mb[2] = MSW(id_list_dma); 1911 mcp->mb[2] = MSW(id_list_dma);
1887 mcp->mb[3] = LSW(id_list_dma); 1912 mcp->mb[3] = LSW(id_list_dma);
1888 mcp->mb[6] = MSW(MSD(id_list_dma)); 1913 mcp->mb[6] = MSW(MSD(id_list_dma));
1889 mcp->mb[7] = LSW(MSD(id_list_dma)); 1914 mcp->mb[7] = LSW(MSD(id_list_dma));
1890 mcp->mb[8] = 0; 1915 mcp->mb[8] = 0;
1891 mcp->mb[9] = ha->vp_idx; 1916 mcp->mb[9] = vha->vp_idx;
1892 mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2; 1917 mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2;
1893 } else { 1918 } else {
1894 mcp->mb[1] = MSW(id_list_dma); 1919 mcp->mb[1] = MSW(id_list_dma);
@@ -1900,16 +1925,16 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1900 mcp->in_mb = MBX_1|MBX_0; 1925 mcp->in_mb = MBX_1|MBX_0;
1901 mcp->tov = MBX_TOV_SECONDS; 1926 mcp->tov = MBX_TOV_SECONDS;
1902 mcp->flags = 0; 1927 mcp->flags = 0;
1903 rval = qla2x00_mailbox_command(ha, mcp); 1928 rval = qla2x00_mailbox_command(vha, mcp);
1904 1929
1905 if (rval != QLA_SUCCESS) { 1930 if (rval != QLA_SUCCESS) {
1906 /*EMPTY*/ 1931 /*EMPTY*/
1907 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n", 1932 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
1908 ha->host_no, rval)); 1933 vha->host_no, rval));
1909 } else { 1934 } else {
1910 *entries = mcp->mb[1]; 1935 *entries = mcp->mb[1];
1911 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n", 1936 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
1912 ha->host_no)); 1937 vha->host_no));
1913 } 1938 }
1914 1939
1915 return rval; 1940 return rval;
@@ -1929,7 +1954,7 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1929 * Kernel context. 1954 * Kernel context.
1930 */ 1955 */
1931int 1956int
1932qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt, 1957qla2x00_get_resource_cnts(scsi_qla_host_t *vha, uint16_t *cur_xchg_cnt,
1933 uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, 1958 uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt,
1934 uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports) 1959 uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports)
1935{ 1960{
@@ -1937,22 +1962,22 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1937 mbx_cmd_t mc; 1962 mbx_cmd_t mc;
1938 mbx_cmd_t *mcp = &mc; 1963 mbx_cmd_t *mcp = &mc;
1939 1964
1940 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1965 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1941 1966
1942 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; 1967 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
1943 mcp->out_mb = MBX_0; 1968 mcp->out_mb = MBX_0;
1944 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1969 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1945 mcp->tov = MBX_TOV_SECONDS; 1970 mcp->tov = MBX_TOV_SECONDS;
1946 mcp->flags = 0; 1971 mcp->flags = 0;
1947 rval = qla2x00_mailbox_command(ha, mcp); 1972 rval = qla2x00_mailbox_command(vha, mcp);
1948 1973
1949 if (rval != QLA_SUCCESS) { 1974 if (rval != QLA_SUCCESS) {
1950 /*EMPTY*/ 1975 /*EMPTY*/
1951 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__, 1976 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__,
1952 ha->host_no, mcp->mb[0])); 1977 vha->host_no, mcp->mb[0]));
1953 } else { 1978 } else {
1954 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x " 1979 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
1955 "mb7=%x mb10=%x mb11=%x.\n", __func__, ha->host_no, 1980 "mb7=%x mb10=%x mb11=%x.\n", __func__, vha->host_no,
1956 mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7], 1981 mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7],
1957 mcp->mb[10], mcp->mb[11])); 1982 mcp->mb[10], mcp->mb[11]));
1958 1983
@@ -1964,7 +1989,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1964 *cur_iocb_cnt = mcp->mb[7]; 1989 *cur_iocb_cnt = mcp->mb[7];
1965 if (orig_iocb_cnt) 1990 if (orig_iocb_cnt)
1966 *orig_iocb_cnt = mcp->mb[10]; 1991 *orig_iocb_cnt = mcp->mb[10];
1967 if (ha->flags.npiv_supported && max_npiv_vports) 1992 if (vha->hw->flags.npiv_supported && max_npiv_vports)
1968 *max_npiv_vports = mcp->mb[11]; 1993 *max_npiv_vports = mcp->mb[11];
1969 } 1994 }
1970 1995
@@ -1987,18 +2012,19 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1987 * Kernel context. 2012 * Kernel context.
1988 */ 2013 */
1989int 2014int
1990qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map) 2015qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
1991{ 2016{
1992 int rval; 2017 int rval;
1993 mbx_cmd_t mc; 2018 mbx_cmd_t mc;
1994 mbx_cmd_t *mcp = &mc; 2019 mbx_cmd_t *mcp = &mc;
1995 char *pmap; 2020 char *pmap;
1996 dma_addr_t pmap_dma; 2021 dma_addr_t pmap_dma;
2022 struct qla_hw_data *ha = vha->hw;
1997 2023
1998 pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); 2024 pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
1999 if (pmap == NULL) { 2025 if (pmap == NULL) {
2000 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****", 2026 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
2001 __func__, ha->host_no)); 2027 __func__, vha->host_no));
2002 return QLA_MEMORY_ALLOC_FAILED; 2028 return QLA_MEMORY_ALLOC_FAILED;
2003 } 2029 }
2004 memset(pmap, 0, FCAL_MAP_SIZE); 2030 memset(pmap, 0, FCAL_MAP_SIZE);
@@ -2013,11 +2039,11 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2013 mcp->buf_size = FCAL_MAP_SIZE; 2039 mcp->buf_size = FCAL_MAP_SIZE;
2014 mcp->flags = MBX_DMA_IN; 2040 mcp->flags = MBX_DMA_IN;
2015 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 2041 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
2016 rval = qla2x00_mailbox_command(ha, mcp); 2042 rval = qla2x00_mailbox_command(vha, mcp);
2017 2043
2018 if (rval == QLA_SUCCESS) { 2044 if (rval == QLA_SUCCESS) {
2019 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map " 2045 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
2020 "size (%x)\n", __func__, ha->host_no, mcp->mb[0], 2046 "size (%x)\n", __func__, vha->host_no, mcp->mb[0],
2021 mcp->mb[1], (unsigned)pmap[0])); 2047 mcp->mb[1], (unsigned)pmap[0]));
2022 DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1)); 2048 DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1));
2023 2049
@@ -2028,9 +2054,9 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2028 2054
2029 if (rval != QLA_SUCCESS) { 2055 if (rval != QLA_SUCCESS) {
2030 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2056 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2031 ha->host_no, rval)); 2057 vha->host_no, rval));
2032 } else { 2058 } else {
2033 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2059 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2034 } 2060 }
2035 2061
2036 return rval; 2062 return rval;
@@ -2051,15 +2077,16 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2051 * BIT_1 = mailbox error. 2077 * BIT_1 = mailbox error.
2052 */ 2078 */
2053int 2079int
2054qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id, 2080qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id,
2055 struct link_statistics *stats, dma_addr_t stats_dma) 2081 struct link_statistics *stats, dma_addr_t stats_dma)
2056{ 2082{
2057 int rval; 2083 int rval;
2058 mbx_cmd_t mc; 2084 mbx_cmd_t mc;
2059 mbx_cmd_t *mcp = &mc; 2085 mbx_cmd_t *mcp = &mc;
2060 uint32_t *siter, *diter, dwords; 2086 uint32_t *siter, *diter, dwords;
2087 struct qla_hw_data *ha = vha->hw;
2061 2088
2062 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2089 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2063 2090
2064 mcp->mb[0] = MBC_GET_LINK_STATUS; 2091 mcp->mb[0] = MBC_GET_LINK_STATUS;
2065 mcp->mb[2] = MSW(stats_dma); 2092 mcp->mb[2] = MSW(stats_dma);
@@ -2084,12 +2111,12 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2084 } 2111 }
2085 mcp->tov = MBX_TOV_SECONDS; 2112 mcp->tov = MBX_TOV_SECONDS;
2086 mcp->flags = IOCTL_CMD; 2113 mcp->flags = IOCTL_CMD;
2087 rval = qla2x00_mailbox_command(ha, mcp); 2114 rval = qla2x00_mailbox_command(vha, mcp);
2088 2115
2089 if (rval == QLA_SUCCESS) { 2116 if (rval == QLA_SUCCESS) {
2090 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2117 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2091 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2118 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2092 __func__, ha->host_no, mcp->mb[0])); 2119 __func__, vha->host_no, mcp->mb[0]));
2093 rval = QLA_FUNCTION_FAILED; 2120 rval = QLA_FUNCTION_FAILED;
2094 } else { 2121 } else {
2095 /* Copy over data -- firmware data is LE. */ 2122 /* Copy over data -- firmware data is LE. */
@@ -2101,14 +2128,14 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2101 } else { 2128 } else {
2102 /* Failed. */ 2129 /* Failed. */
2103 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2130 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2104 ha->host_no, rval)); 2131 vha->host_no, rval));
2105 } 2132 }
2106 2133
2107 return rval; 2134 return rval;
2108} 2135}
2109 2136
2110int 2137int
2111qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats, 2138qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
2112 dma_addr_t stats_dma) 2139 dma_addr_t stats_dma)
2113{ 2140{
2114 int rval; 2141 int rval;
@@ -2116,7 +2143,7 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2116 mbx_cmd_t *mcp = &mc; 2143 mbx_cmd_t *mcp = &mc;
2117 uint32_t *siter, *diter, dwords; 2144 uint32_t *siter, *diter, dwords;
2118 2145
2119 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2146 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2120 2147
2121 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; 2148 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS;
2122 mcp->mb[2] = MSW(stats_dma); 2149 mcp->mb[2] = MSW(stats_dma);
@@ -2124,18 +2151,18 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2124 mcp->mb[6] = MSW(MSD(stats_dma)); 2151 mcp->mb[6] = MSW(MSD(stats_dma));
2125 mcp->mb[7] = LSW(MSD(stats_dma)); 2152 mcp->mb[7] = LSW(MSD(stats_dma));
2126 mcp->mb[8] = sizeof(struct link_statistics) / 4; 2153 mcp->mb[8] = sizeof(struct link_statistics) / 4;
2127 mcp->mb[9] = ha->vp_idx; 2154 mcp->mb[9] = vha->vp_idx;
2128 mcp->mb[10] = 0; 2155 mcp->mb[10] = 0;
2129 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2156 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2130 mcp->in_mb = MBX_2|MBX_1|MBX_0; 2157 mcp->in_mb = MBX_2|MBX_1|MBX_0;
2131 mcp->tov = MBX_TOV_SECONDS; 2158 mcp->tov = MBX_TOV_SECONDS;
2132 mcp->flags = IOCTL_CMD; 2159 mcp->flags = IOCTL_CMD;
2133 rval = qla2x00_mailbox_command(ha, mcp); 2160 rval = qla2x00_mailbox_command(vha, mcp);
2134 2161
2135 if (rval == QLA_SUCCESS) { 2162 if (rval == QLA_SUCCESS) {
2136 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2163 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2137 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2164 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2138 __func__, ha->host_no, mcp->mb[0])); 2165 __func__, vha->host_no, mcp->mb[0]));
2139 rval = QLA_FUNCTION_FAILED; 2166 rval = QLA_FUNCTION_FAILED;
2140 } else { 2167 } else {
2141 /* Copy over data -- firmware data is LE. */ 2168 /* Copy over data -- firmware data is LE. */
@@ -2147,14 +2174,14 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2147 } else { 2174 } else {
2148 /* Failed. */ 2175 /* Failed. */
2149 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2176 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2150 ha->host_no, rval)); 2177 vha->host_no, rval));
2151 } 2178 }
2152 2179
2153 return rval; 2180 return rval;
2154} 2181}
2155 2182
2156int 2183int
2157qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp) 2184qla24xx_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req)
2158{ 2185{
2159 int rval; 2186 int rval;
2160 fc_port_t *fcport; 2187 fc_port_t *fcport;
@@ -2163,18 +2190,18 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2163 struct abort_entry_24xx *abt; 2190 struct abort_entry_24xx *abt;
2164 dma_addr_t abt_dma; 2191 dma_addr_t abt_dma;
2165 uint32_t handle; 2192 uint32_t handle;
2166 scsi_qla_host_t *pha = to_qla_parent(ha); 2193 struct qla_hw_data *ha = vha->hw;
2167 2194
2168 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2195 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2169 2196
2170 fcport = sp->fcport; 2197 fcport = sp->fcport;
2171 2198
2172 spin_lock_irqsave(&pha->hardware_lock, flags); 2199 spin_lock_irqsave(&ha->hardware_lock, flags);
2173 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2200 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
2174 if (pha->outstanding_cmds[handle] == sp) 2201 if (req->outstanding_cmds[handle] == sp)
2175 break; 2202 break;
2176 } 2203 }
2177 spin_unlock_irqrestore(&pha->hardware_lock, flags); 2204 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2178 if (handle == MAX_OUTSTANDING_COMMANDS) { 2205 if (handle == MAX_OUTSTANDING_COMMANDS) {
2179 /* Command not found. */ 2206 /* Command not found. */
2180 return QLA_FUNCTION_FAILED; 2207 return QLA_FUNCTION_FAILED;
@@ -2183,7 +2210,7 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2183 abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); 2210 abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
2184 if (abt == NULL) { 2211 if (abt == NULL) {
2185 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n", 2212 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n",
2186 __func__, ha->host_no)); 2213 __func__, vha->host_no));
2187 return QLA_MEMORY_ALLOC_FAILED; 2214 return QLA_MEMORY_ALLOC_FAILED;
2188 } 2215 }
2189 memset(abt, 0, sizeof(struct abort_entry_24xx)); 2216 memset(abt, 0, sizeof(struct abort_entry_24xx));
@@ -2196,22 +2223,25 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2196 abt->port_id[1] = fcport->d_id.b.area; 2223 abt->port_id[1] = fcport->d_id.b.area;
2197 abt->port_id[2] = fcport->d_id.b.domain; 2224 abt->port_id[2] = fcport->d_id.b.domain;
2198 abt->vp_index = fcport->vp_idx; 2225 abt->vp_index = fcport->vp_idx;
2199 rval = qla2x00_issue_iocb(ha, abt, abt_dma, 0); 2226
2227 abt->req_que_no = cpu_to_le16(req->id);
2228
2229 rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0);
2200 if (rval != QLA_SUCCESS) { 2230 if (rval != QLA_SUCCESS) {
2201 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n", 2231 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
2202 __func__, ha->host_no, rval)); 2232 __func__, vha->host_no, rval));
2203 } else if (abt->entry_status != 0) { 2233 } else if (abt->entry_status != 0) {
2204 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2234 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2205 "-- error status (%x).\n", __func__, ha->host_no, 2235 "-- error status (%x).\n", __func__, vha->host_no,
2206 abt->entry_status)); 2236 abt->entry_status));
2207 rval = QLA_FUNCTION_FAILED; 2237 rval = QLA_FUNCTION_FAILED;
2208 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) { 2238 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) {
2209 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2239 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2210 "-- completion status (%x).\n", __func__, ha->host_no, 2240 "-- completion status (%x).\n", __func__, vha->host_no,
2211 le16_to_cpu(abt->nport_handle))); 2241 le16_to_cpu(abt->nport_handle)));
2212 rval = QLA_FUNCTION_FAILED; 2242 rval = QLA_FUNCTION_FAILED;
2213 } else { 2243 } else {
2214 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2244 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2215 } 2245 }
2216 2246
2217 dma_pool_free(ha->s_dma_pool, abt, abt_dma); 2247 dma_pool_free(ha->s_dma_pool, abt, abt_dma);
@@ -2233,16 +2263,21 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
2233 int rval, rval2; 2263 int rval, rval2;
2234 struct tsk_mgmt_cmd *tsk; 2264 struct tsk_mgmt_cmd *tsk;
2235 dma_addr_t tsk_dma; 2265 dma_addr_t tsk_dma;
2236 scsi_qla_host_t *ha, *pha; 2266 scsi_qla_host_t *vha;
2267 struct qla_hw_data *ha;
2268 struct req_que *req;
2269 struct rsp_que *rsp;
2237 2270
2238 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 2271 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
2239 2272
2240 ha = fcport->ha; 2273 vha = fcport->vha;
2241 pha = to_qla_parent(ha); 2274 ha = vha->hw;
2242 tsk = dma_pool_alloc(pha->s_dma_pool, GFP_KERNEL, &tsk_dma); 2275 req = ha->req_q_map[0];
2276 rsp = ha->rsp_q_map[0];
2277 tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
2243 if (tsk == NULL) { 2278 if (tsk == NULL) {
2244 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management " 2279 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
2245 "IOCB.\n", __func__, ha->host_no)); 2280 "IOCB.\n", __func__, vha->host_no));
2246 return QLA_MEMORY_ALLOC_FAILED; 2281 return QLA_MEMORY_ALLOC_FAILED;
2247 } 2282 }
2248 memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); 2283 memset(tsk, 0, sizeof(struct tsk_mgmt_cmd));
@@ -2262,34 +2297,34 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
2262 sizeof(tsk->p.tsk.lun)); 2297 sizeof(tsk->p.tsk.lun));
2263 } 2298 }
2264 2299
2265 rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0); 2300 rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0);
2266 if (rval != QLA_SUCCESS) { 2301 if (rval != QLA_SUCCESS) {
2267 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB " 2302 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB "
2268 "(%x).\n", __func__, ha->host_no, name, rval)); 2303 "(%x).\n", __func__, vha->host_no, name, rval));
2269 } else if (tsk->p.sts.entry_status != 0) { 2304 } else if (tsk->p.sts.entry_status != 0) {
2270 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2305 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2271 "-- error status (%x).\n", __func__, ha->host_no, 2306 "-- error status (%x).\n", __func__, vha->host_no,
2272 tsk->p.sts.entry_status)); 2307 tsk->p.sts.entry_status));
2273 rval = QLA_FUNCTION_FAILED; 2308 rval = QLA_FUNCTION_FAILED;
2274 } else if (tsk->p.sts.comp_status != 2309 } else if (tsk->p.sts.comp_status !=
2275 __constant_cpu_to_le16(CS_COMPLETE)) { 2310 __constant_cpu_to_le16(CS_COMPLETE)) {
2276 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2311 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2277 "-- completion status (%x).\n", __func__, 2312 "-- completion status (%x).\n", __func__,
2278 ha->host_no, le16_to_cpu(tsk->p.sts.comp_status))); 2313 vha->host_no, le16_to_cpu(tsk->p.sts.comp_status)));
2279 rval = QLA_FUNCTION_FAILED; 2314 rval = QLA_FUNCTION_FAILED;
2280 } 2315 }
2281 2316
2282 /* Issue marker IOCB. */ 2317 /* Issue marker IOCB. */
2283 rval2 = qla2x00_marker(ha, fcport->loop_id, l, 2318 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
2284 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); 2319 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID);
2285 if (rval2 != QLA_SUCCESS) { 2320 if (rval2 != QLA_SUCCESS) {
2286 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 2321 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2287 "(%x).\n", __func__, ha->host_no, rval2)); 2322 "(%x).\n", __func__, vha->host_no, rval2));
2288 } else { 2323 } else {
2289 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2324 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2290 } 2325 }
2291 2326
2292 dma_pool_free(pha->s_dma_pool, tsk, tsk_dma); 2327 dma_pool_free(ha->s_dma_pool, tsk, tsk_dma);
2293 2328
2294 return rval; 2329 return rval;
2295} 2330}
@@ -2307,29 +2342,30 @@ qla24xx_lun_reset(struct fc_port *fcport, unsigned int l)
2307} 2342}
2308 2343
2309int 2344int
2310qla2x00_system_error(scsi_qla_host_t *ha) 2345qla2x00_system_error(scsi_qla_host_t *vha)
2311{ 2346{
2312 int rval; 2347 int rval;
2313 mbx_cmd_t mc; 2348 mbx_cmd_t mc;
2314 mbx_cmd_t *mcp = &mc; 2349 mbx_cmd_t *mcp = &mc;
2350 struct qla_hw_data *ha = vha->hw;
2315 2351
2316 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) 2352 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha))
2317 return QLA_FUNCTION_FAILED; 2353 return QLA_FUNCTION_FAILED;
2318 2354
2319 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2355 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2320 2356
2321 mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; 2357 mcp->mb[0] = MBC_GEN_SYSTEM_ERROR;
2322 mcp->out_mb = MBX_0; 2358 mcp->out_mb = MBX_0;
2323 mcp->in_mb = MBX_0; 2359 mcp->in_mb = MBX_0;
2324 mcp->tov = 5; 2360 mcp->tov = 5;
2325 mcp->flags = 0; 2361 mcp->flags = 0;
2326 rval = qla2x00_mailbox_command(ha, mcp); 2362 rval = qla2x00_mailbox_command(vha, mcp);
2327 2363
2328 if (rval != QLA_SUCCESS) { 2364 if (rval != QLA_SUCCESS) {
2329 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2365 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2330 ha->host_no, rval)); 2366 vha->host_no, rval));
2331 } else { 2367 } else {
2332 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2368 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2333 } 2369 }
2334 2370
2335 return rval; 2371 return rval;
@@ -2342,14 +2378,14 @@ qla2x00_system_error(scsi_qla_host_t *ha)
2342 * Returns 2378 * Returns
2343 */ 2379 */
2344int 2380int
2345qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g, 2381qla2x00_set_serdes_params(scsi_qla_host_t *vha, uint16_t sw_em_1g,
2346 uint16_t sw_em_2g, uint16_t sw_em_4g) 2382 uint16_t sw_em_2g, uint16_t sw_em_4g)
2347{ 2383{
2348 int rval; 2384 int rval;
2349 mbx_cmd_t mc; 2385 mbx_cmd_t mc;
2350 mbx_cmd_t *mcp = &mc; 2386 mbx_cmd_t *mcp = &mc;
2351 2387
2352 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2388 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2353 2389
2354 mcp->mb[0] = MBC_SERDES_PARAMS; 2390 mcp->mb[0] = MBC_SERDES_PARAMS;
2355 mcp->mb[1] = BIT_0; 2391 mcp->mb[1] = BIT_0;
@@ -2360,61 +2396,61 @@ qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g,
2360 mcp->in_mb = MBX_0; 2396 mcp->in_mb = MBX_0;
2361 mcp->tov = MBX_TOV_SECONDS; 2397 mcp->tov = MBX_TOV_SECONDS;
2362 mcp->flags = 0; 2398 mcp->flags = 0;
2363 rval = qla2x00_mailbox_command(ha, mcp); 2399 rval = qla2x00_mailbox_command(vha, mcp);
2364 2400
2365 if (rval != QLA_SUCCESS) { 2401 if (rval != QLA_SUCCESS) {
2366 /*EMPTY*/ 2402 /*EMPTY*/
2367 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2403 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2368 ha->host_no, rval, mcp->mb[0])); 2404 vha->host_no, rval, mcp->mb[0]));
2369 } else { 2405 } else {
2370 /*EMPTY*/ 2406 /*EMPTY*/
2371 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2407 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2372 } 2408 }
2373 2409
2374 return rval; 2410 return rval;
2375} 2411}
2376 2412
2377int 2413int
2378qla2x00_stop_firmware(scsi_qla_host_t *ha) 2414qla2x00_stop_firmware(scsi_qla_host_t *vha)
2379{ 2415{
2380 int rval; 2416 int rval;
2381 mbx_cmd_t mc; 2417 mbx_cmd_t mc;
2382 mbx_cmd_t *mcp = &mc; 2418 mbx_cmd_t *mcp = &mc;
2383 2419
2384 if (!IS_FWI2_CAPABLE(ha)) 2420 if (!IS_FWI2_CAPABLE(vha->hw))
2385 return QLA_FUNCTION_FAILED; 2421 return QLA_FUNCTION_FAILED;
2386 2422
2387 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2423 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2388 2424
2389 mcp->mb[0] = MBC_STOP_FIRMWARE; 2425 mcp->mb[0] = MBC_STOP_FIRMWARE;
2390 mcp->out_mb = MBX_0; 2426 mcp->out_mb = MBX_0;
2391 mcp->in_mb = MBX_0; 2427 mcp->in_mb = MBX_0;
2392 mcp->tov = 5; 2428 mcp->tov = 5;
2393 mcp->flags = 0; 2429 mcp->flags = 0;
2394 rval = qla2x00_mailbox_command(ha, mcp); 2430 rval = qla2x00_mailbox_command(vha, mcp);
2395 2431
2396 if (rval != QLA_SUCCESS) { 2432 if (rval != QLA_SUCCESS) {
2397 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2433 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2398 ha->host_no, rval)); 2434 vha->host_no, rval));
2399 } else { 2435 } else {
2400 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2436 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2401 } 2437 }
2402 2438
2403 return rval; 2439 return rval;
2404} 2440}
2405 2441
2406int 2442int
2407qla2x00_enable_eft_trace(scsi_qla_host_t *ha, dma_addr_t eft_dma, 2443qla2x00_enable_eft_trace(scsi_qla_host_t *vha, dma_addr_t eft_dma,
2408 uint16_t buffers) 2444 uint16_t buffers)
2409{ 2445{
2410 int rval; 2446 int rval;
2411 mbx_cmd_t mc; 2447 mbx_cmd_t mc;
2412 mbx_cmd_t *mcp = &mc; 2448 mbx_cmd_t *mcp = &mc;
2413 2449
2414 if (!IS_FWI2_CAPABLE(ha)) 2450 if (!IS_FWI2_CAPABLE(vha->hw))
2415 return QLA_FUNCTION_FAILED; 2451 return QLA_FUNCTION_FAILED;
2416 2452
2417 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2453 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2418 2454
2419 mcp->mb[0] = MBC_TRACE_CONTROL; 2455 mcp->mb[0] = MBC_TRACE_CONTROL;
2420 mcp->mb[1] = TC_EFT_ENABLE; 2456 mcp->mb[1] = TC_EFT_ENABLE;
@@ -2428,28 +2464,28 @@ qla2x00_enable_eft_trace(scsi_qla_host_t *ha, dma_addr_t eft_dma,
2428 mcp->in_mb = MBX_1|MBX_0; 2464 mcp->in_mb = MBX_1|MBX_0;
2429 mcp->tov = MBX_TOV_SECONDS; 2465 mcp->tov = MBX_TOV_SECONDS;
2430 mcp->flags = 0; 2466 mcp->flags = 0;
2431 rval = qla2x00_mailbox_command(ha, mcp); 2467 rval = qla2x00_mailbox_command(vha, mcp);
2432 if (rval != QLA_SUCCESS) { 2468 if (rval != QLA_SUCCESS) {
2433 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2469 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2434 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2470 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2435 } else { 2471 } else {
2436 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2472 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2437 } 2473 }
2438 2474
2439 return rval; 2475 return rval;
2440} 2476}
2441 2477
2442int 2478int
2443qla2x00_disable_eft_trace(scsi_qla_host_t *ha) 2479qla2x00_disable_eft_trace(scsi_qla_host_t *vha)
2444{ 2480{
2445 int rval; 2481 int rval;
2446 mbx_cmd_t mc; 2482 mbx_cmd_t mc;
2447 mbx_cmd_t *mcp = &mc; 2483 mbx_cmd_t *mcp = &mc;
2448 2484
2449 if (!IS_FWI2_CAPABLE(ha)) 2485 if (!IS_FWI2_CAPABLE(vha->hw))
2450 return QLA_FUNCTION_FAILED; 2486 return QLA_FUNCTION_FAILED;
2451 2487
2452 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2488 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2453 2489
2454 mcp->mb[0] = MBC_TRACE_CONTROL; 2490 mcp->mb[0] = MBC_TRACE_CONTROL;
2455 mcp->mb[1] = TC_EFT_DISABLE; 2491 mcp->mb[1] = TC_EFT_DISABLE;
@@ -2457,29 +2493,29 @@ qla2x00_disable_eft_trace(scsi_qla_host_t *ha)
2457 mcp->in_mb = MBX_1|MBX_0; 2493 mcp->in_mb = MBX_1|MBX_0;
2458 mcp->tov = MBX_TOV_SECONDS; 2494 mcp->tov = MBX_TOV_SECONDS;
2459 mcp->flags = 0; 2495 mcp->flags = 0;
2460 rval = qla2x00_mailbox_command(ha, mcp); 2496 rval = qla2x00_mailbox_command(vha, mcp);
2461 if (rval != QLA_SUCCESS) { 2497 if (rval != QLA_SUCCESS) {
2462 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2498 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2463 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2499 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2464 } else { 2500 } else {
2465 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2501 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2466 } 2502 }
2467 2503
2468 return rval; 2504 return rval;
2469} 2505}
2470 2506
2471int 2507int
2472qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma, 2508qla2x00_enable_fce_trace(scsi_qla_host_t *vha, dma_addr_t fce_dma,
2473 uint16_t buffers, uint16_t *mb, uint32_t *dwords) 2509 uint16_t buffers, uint16_t *mb, uint32_t *dwords)
2474{ 2510{
2475 int rval; 2511 int rval;
2476 mbx_cmd_t mc; 2512 mbx_cmd_t mc;
2477 mbx_cmd_t *mcp = &mc; 2513 mbx_cmd_t *mcp = &mc;
2478 2514
2479 if (!IS_QLA25XX(ha)) 2515 if (!IS_QLA25XX(vha->hw))
2480 return QLA_FUNCTION_FAILED; 2516 return QLA_FUNCTION_FAILED;
2481 2517
2482 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2518 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2483 2519
2484 mcp->mb[0] = MBC_TRACE_CONTROL; 2520 mcp->mb[0] = MBC_TRACE_CONTROL;
2485 mcp->mb[1] = TC_FCE_ENABLE; 2521 mcp->mb[1] = TC_FCE_ENABLE;
@@ -2497,12 +2533,12 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2497 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2533 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2498 mcp->tov = MBX_TOV_SECONDS; 2534 mcp->tov = MBX_TOV_SECONDS;
2499 mcp->flags = 0; 2535 mcp->flags = 0;
2500 rval = qla2x00_mailbox_command(ha, mcp); 2536 rval = qla2x00_mailbox_command(vha, mcp);
2501 if (rval != QLA_SUCCESS) { 2537 if (rval != QLA_SUCCESS) {
2502 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2538 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2503 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2539 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2504 } else { 2540 } else {
2505 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2541 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2506 2542
2507 if (mb) 2543 if (mb)
2508 memcpy(mb, mcp->mb, 8 * sizeof(*mb)); 2544 memcpy(mb, mcp->mb, 8 * sizeof(*mb));
@@ -2514,16 +2550,16 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2514} 2550}
2515 2551
2516int 2552int
2517qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd) 2553qla2x00_disable_fce_trace(scsi_qla_host_t *vha, uint64_t *wr, uint64_t *rd)
2518{ 2554{
2519 int rval; 2555 int rval;
2520 mbx_cmd_t mc; 2556 mbx_cmd_t mc;
2521 mbx_cmd_t *mcp = &mc; 2557 mbx_cmd_t *mcp = &mc;
2522 2558
2523 if (!IS_FWI2_CAPABLE(ha)) 2559 if (!IS_FWI2_CAPABLE(vha->hw))
2524 return QLA_FUNCTION_FAILED; 2560 return QLA_FUNCTION_FAILED;
2525 2561
2526 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2562 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2527 2563
2528 mcp->mb[0] = MBC_TRACE_CONTROL; 2564 mcp->mb[0] = MBC_TRACE_CONTROL;
2529 mcp->mb[1] = TC_FCE_DISABLE; 2565 mcp->mb[1] = TC_FCE_DISABLE;
@@ -2533,12 +2569,12 @@ qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd)
2533 MBX_1|MBX_0; 2569 MBX_1|MBX_0;
2534 mcp->tov = MBX_TOV_SECONDS; 2570 mcp->tov = MBX_TOV_SECONDS;
2535 mcp->flags = 0; 2571 mcp->flags = 0;
2536 rval = qla2x00_mailbox_command(ha, mcp); 2572 rval = qla2x00_mailbox_command(vha, mcp);
2537 if (rval != QLA_SUCCESS) { 2573 if (rval != QLA_SUCCESS) {
2538 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2574 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2539 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2575 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2540 } else { 2576 } else {
2541 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2577 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2542 2578
2543 if (wr) 2579 if (wr)
2544 *wr = (uint64_t) mcp->mb[5] << 48 | 2580 *wr = (uint64_t) mcp->mb[5] << 48 |
@@ -2556,17 +2592,17 @@ qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd)
2556} 2592}
2557 2593
2558int 2594int
2559qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr, 2595qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint16_t addr,
2560 uint16_t off, uint16_t count) 2596 uint16_t off, uint16_t count)
2561{ 2597{
2562 int rval; 2598 int rval;
2563 mbx_cmd_t mc; 2599 mbx_cmd_t mc;
2564 mbx_cmd_t *mcp = &mc; 2600 mbx_cmd_t *mcp = &mc;
2565 2601
2566 if (!IS_FWI2_CAPABLE(ha)) 2602 if (!IS_FWI2_CAPABLE(vha->hw))
2567 return QLA_FUNCTION_FAILED; 2603 return QLA_FUNCTION_FAILED;
2568 2604
2569 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2605 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2570 2606
2571 mcp->mb[0] = MBC_READ_SFP; 2607 mcp->mb[0] = MBC_READ_SFP;
2572 mcp->mb[1] = addr; 2608 mcp->mb[1] = addr;
@@ -2581,30 +2617,30 @@ qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2581 mcp->in_mb = MBX_0; 2617 mcp->in_mb = MBX_0;
2582 mcp->tov = MBX_TOV_SECONDS; 2618 mcp->tov = MBX_TOV_SECONDS;
2583 mcp->flags = 0; 2619 mcp->flags = 0;
2584 rval = qla2x00_mailbox_command(ha, mcp); 2620 rval = qla2x00_mailbox_command(vha, mcp);
2585 2621
2586 if (rval != QLA_SUCCESS) { 2622 if (rval != QLA_SUCCESS) {
2587 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2623 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2588 ha->host_no, rval, mcp->mb[0])); 2624 vha->host_no, rval, mcp->mb[0]));
2589 } else { 2625 } else {
2590 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2626 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2591 } 2627 }
2592 2628
2593 return rval; 2629 return rval;
2594} 2630}
2595 2631
2596int 2632int
2597qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id, 2633qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id,
2598 uint16_t port_speed, uint16_t *mb) 2634 uint16_t port_speed, uint16_t *mb)
2599{ 2635{
2600 int rval; 2636 int rval;
2601 mbx_cmd_t mc; 2637 mbx_cmd_t mc;
2602 mbx_cmd_t *mcp = &mc; 2638 mbx_cmd_t *mcp = &mc;
2603 2639
2604 if (!IS_IIDMA_CAPABLE(ha)) 2640 if (!IS_IIDMA_CAPABLE(vha->hw))
2605 return QLA_FUNCTION_FAILED; 2641 return QLA_FUNCTION_FAILED;
2606 2642
2607 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2643 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2608 2644
2609 mcp->mb[0] = MBC_PORT_PARAMS; 2645 mcp->mb[0] = MBC_PORT_PARAMS;
2610 mcp->mb[1] = loop_id; 2646 mcp->mb[1] = loop_id;
@@ -2615,7 +2651,7 @@ qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2615 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; 2651 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
2616 mcp->tov = MBX_TOV_SECONDS; 2652 mcp->tov = MBX_TOV_SECONDS;
2617 mcp->flags = 0; 2653 mcp->flags = 0;
2618 rval = qla2x00_mailbox_command(ha, mcp); 2654 rval = qla2x00_mailbox_command(vha, mcp);
2619 2655
2620 /* Return mailbox statuses. */ 2656 /* Return mailbox statuses. */
2621 if (mb != NULL) { 2657 if (mb != NULL) {
@@ -2628,28 +2664,29 @@ qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2628 2664
2629 if (rval != QLA_SUCCESS) { 2665 if (rval != QLA_SUCCESS) {
2630 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2666 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2631 ha->host_no, rval)); 2667 vha->host_no, rval));
2632 } else { 2668 } else {
2633 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2669 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2634 } 2670 }
2635 2671
2636 return rval; 2672 return rval;
2637} 2673}
2638 2674
2639void 2675void
2640qla24xx_report_id_acquisition(scsi_qla_host_t *ha, 2676qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
2641 struct vp_rpt_id_entry_24xx *rptid_entry) 2677 struct vp_rpt_id_entry_24xx *rptid_entry)
2642{ 2678{
2643 uint8_t vp_idx; 2679 uint8_t vp_idx;
2644 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); 2680 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx);
2645 scsi_qla_host_t *vha; 2681 struct qla_hw_data *ha = vha->hw;
2682 scsi_qla_host_t *vp;
2646 2683
2647 if (rptid_entry->entry_status != 0) 2684 if (rptid_entry->entry_status != 0)
2648 return; 2685 return;
2649 2686
2650 if (rptid_entry->format == 0) { 2687 if (rptid_entry->format == 0) {
2651 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d," 2688 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
2652 " number of VPs acquired %d\n", __func__, ha->host_no, 2689 " number of VPs acquired %d\n", __func__, vha->host_no,
2653 MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count))); 2690 MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count)));
2654 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__, 2691 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__,
2655 rptid_entry->port_id[2], rptid_entry->port_id[1], 2692 rptid_entry->port_id[2], rptid_entry->port_id[1],
@@ -2658,7 +2695,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *ha,
2658 vp_idx = LSB(stat); 2695 vp_idx = LSB(stat);
2659 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled " 2696 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
2660 "- status %d - " 2697 "- status %d - "
2661 "with port id %02x%02x%02x\n",__func__,ha->host_no, 2698 "with port id %02x%02x%02x\n", __func__, vha->host_no,
2662 vp_idx, MSB(stat), 2699 vp_idx, MSB(stat),
2663 rptid_entry->port_id[2], rptid_entry->port_id[1], 2700 rptid_entry->port_id[2], rptid_entry->port_id[1],
2664 rptid_entry->port_id[0])); 2701 rptid_entry->port_id[0]));
@@ -2668,25 +2705,24 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *ha,
2668 if (MSB(stat) == 1) 2705 if (MSB(stat) == 1)
2669 return; 2706 return;
2670 2707
2671 list_for_each_entry(vha, &ha->vp_list, vp_list) 2708 list_for_each_entry(vp, &ha->vp_list, list)
2672 if (vp_idx == vha->vp_idx) 2709 if (vp_idx == vp->vp_idx)
2673 break; 2710 break;
2674 2711 if (!vp)
2675 if (!vha)
2676 return; 2712 return;
2677 2713
2678 vha->d_id.b.domain = rptid_entry->port_id[2]; 2714 vp->d_id.b.domain = rptid_entry->port_id[2];
2679 vha->d_id.b.area = rptid_entry->port_id[1]; 2715 vp->d_id.b.area = rptid_entry->port_id[1];
2680 vha->d_id.b.al_pa = rptid_entry->port_id[0]; 2716 vp->d_id.b.al_pa = rptid_entry->port_id[0];
2681 2717
2682 /* 2718 /*
2683 * Cannot configure here as we are still sitting on the 2719 * Cannot configure here as we are still sitting on the
2684 * response queue. Handle it in dpc context. 2720 * response queue. Handle it in dpc context.
2685 */ 2721 */
2686 set_bit(VP_IDX_ACQUIRED, &vha->vp_flags); 2722 set_bit(VP_IDX_ACQUIRED, &vp->vp_flags);
2687 set_bit(VP_DPC_NEEDED, &ha->dpc_flags); 2723 set_bit(VP_DPC_NEEDED, &vha->dpc_flags);
2688 2724
2689 qla2xxx_wake_dpc(ha); 2725 qla2xxx_wake_dpc(vha);
2690 } 2726 }
2691} 2727}
2692 2728
@@ -2709,15 +2745,15 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha)
2709 int rval; 2745 int rval;
2710 struct vp_config_entry_24xx *vpmod; 2746 struct vp_config_entry_24xx *vpmod;
2711 dma_addr_t vpmod_dma; 2747 dma_addr_t vpmod_dma;
2712 scsi_qla_host_t *pha; 2748 struct qla_hw_data *ha = vha->hw;
2749 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2713 2750
2714 /* This can be called by the parent */ 2751 /* This can be called by the parent */
2715 pha = to_qla_parent(vha);
2716 2752
2717 vpmod = dma_pool_alloc(pha->s_dma_pool, GFP_KERNEL, &vpmod_dma); 2753 vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
2718 if (!vpmod) { 2754 if (!vpmod) {
2719 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP " 2755 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
2720 "IOCB.\n", __func__, pha->host_no)); 2756 "IOCB.\n", __func__, vha->host_no));
2721 return QLA_MEMORY_ALLOC_FAILED; 2757 return QLA_MEMORY_ALLOC_FAILED;
2722 } 2758 }
2723 2759
@@ -2732,26 +2768,27 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha)
2732 memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); 2768 memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE);
2733 vpmod->entry_count = 1; 2769 vpmod->entry_count = 1;
2734 2770
2735 rval = qla2x00_issue_iocb(pha, vpmod, vpmod_dma, 0); 2771 rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0);
2736 if (rval != QLA_SUCCESS) { 2772 if (rval != QLA_SUCCESS) {
2737 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB" 2773 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
2738 "(%x).\n", __func__, pha->host_no, rval)); 2774 "(%x).\n", __func__, base_vha->host_no, rval));
2739 } else if (vpmod->comp_status != 0) { 2775 } else if (vpmod->comp_status != 0) {
2740 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2776 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2741 "-- error status (%x).\n", __func__, pha->host_no, 2777 "-- error status (%x).\n", __func__, base_vha->host_no,
2742 vpmod->comp_status)); 2778 vpmod->comp_status));
2743 rval = QLA_FUNCTION_FAILED; 2779 rval = QLA_FUNCTION_FAILED;
2744 } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 2780 } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
2745 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2781 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2746 "-- completion status (%x).\n", __func__, pha->host_no, 2782 "-- completion status (%x).\n", __func__, base_vha->host_no,
2747 le16_to_cpu(vpmod->comp_status))); 2783 le16_to_cpu(vpmod->comp_status)));
2748 rval = QLA_FUNCTION_FAILED; 2784 rval = QLA_FUNCTION_FAILED;
2749 } else { 2785 } else {
2750 /* EMPTY */ 2786 /* EMPTY */
2751 DEBUG11(printk("%s(%ld): done.\n", __func__, pha->host_no)); 2787 DEBUG11(printk("%s(%ld): done.\n", __func__,
2788 base_vha->host_no));
2752 fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); 2789 fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING);
2753 } 2790 }
2754 dma_pool_free(pha->s_dma_pool, vpmod, vpmod_dma); 2791 dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma);
2755 2792
2756 return rval; 2793 return rval;
2757} 2794}
@@ -2778,11 +2815,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2778 int map, pos; 2815 int map, pos;
2779 struct vp_ctrl_entry_24xx *vce; 2816 struct vp_ctrl_entry_24xx *vce;
2780 dma_addr_t vce_dma; 2817 dma_addr_t vce_dma;
2781 scsi_qla_host_t *ha = vha->parent; 2818 struct qla_hw_data *ha = vha->hw;
2782 int vp_index = vha->vp_idx; 2819 int vp_index = vha->vp_idx;
2820 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2783 2821
2784 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__, 2822 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__,
2785 ha->host_no, vp_index)); 2823 vha->host_no, vp_index));
2786 2824
2787 if (vp_index == 0 || vp_index >= ha->max_npiv_vports) 2825 if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
2788 return QLA_PARAMETER_ERROR; 2826 return QLA_PARAMETER_ERROR;
@@ -2791,7 +2829,7 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2791 if (!vce) { 2829 if (!vce) {
2792 DEBUG2_3(printk("%s(%ld): " 2830 DEBUG2_3(printk("%s(%ld): "
2793 "failed to allocate VP Control IOCB.\n", __func__, 2831 "failed to allocate VP Control IOCB.\n", __func__,
2794 ha->host_no)); 2832 base_vha->host_no));
2795 return QLA_MEMORY_ALLOC_FAILED; 2833 return QLA_MEMORY_ALLOC_FAILED;
2796 } 2834 }
2797 memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); 2835 memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
@@ -2810,30 +2848,30 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2810 vce->vp_idx_map[map] |= 1 << pos; 2848 vce->vp_idx_map[map] |= 1 << pos;
2811 mutex_unlock(&ha->vport_lock); 2849 mutex_unlock(&ha->vport_lock);
2812 2850
2813 rval = qla2x00_issue_iocb(ha, vce, vce_dma, 0); 2851 rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0);
2814 if (rval != QLA_SUCCESS) { 2852 if (rval != QLA_SUCCESS) {
2815 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB" 2853 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
2816 "(%x).\n", __func__, ha->host_no, rval)); 2854 "(%x).\n", __func__, base_vha->host_no, rval));
2817 printk("%s(%ld): failed to issue VP control IOCB" 2855 printk("%s(%ld): failed to issue VP control IOCB"
2818 "(%x).\n", __func__, ha->host_no, rval); 2856 "(%x).\n", __func__, base_vha->host_no, rval);
2819 } else if (vce->entry_status != 0) { 2857 } else if (vce->entry_status != 0) {
2820 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2858 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2821 "-- error status (%x).\n", __func__, ha->host_no, 2859 "-- error status (%x).\n", __func__, base_vha->host_no,
2822 vce->entry_status)); 2860 vce->entry_status));
2823 printk("%s(%ld): failed to complete IOCB " 2861 printk("%s(%ld): failed to complete IOCB "
2824 "-- error status (%x).\n", __func__, ha->host_no, 2862 "-- error status (%x).\n", __func__, base_vha->host_no,
2825 vce->entry_status); 2863 vce->entry_status);
2826 rval = QLA_FUNCTION_FAILED; 2864 rval = QLA_FUNCTION_FAILED;
2827 } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 2865 } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
2828 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2866 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2829 "-- completion status (%x).\n", __func__, ha->host_no, 2867 "-- completion status (%x).\n", __func__, base_vha->host_no,
2830 le16_to_cpu(vce->comp_status))); 2868 le16_to_cpu(vce->comp_status)));
2831 printk("%s(%ld): failed to complete IOCB " 2869 printk("%s(%ld): failed to complete IOCB "
2832 "-- completion status (%x).\n", __func__, ha->host_no, 2870 "-- completion status (%x).\n", __func__, base_vha->host_no,
2833 le16_to_cpu(vce->comp_status)); 2871 le16_to_cpu(vce->comp_status));
2834 rval = QLA_FUNCTION_FAILED; 2872 rval = QLA_FUNCTION_FAILED;
2835 } else { 2873 } else {
2836 DEBUG2(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2874 DEBUG2(printk("%s(%ld): done.\n", __func__, base_vha->host_no));
2837 } 2875 }
2838 2876
2839 dma_pool_free(ha->s_dma_pool, vce, vce_dma); 2877 dma_pool_free(ha->s_dma_pool, vce, vce_dma);
@@ -2863,7 +2901,7 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2863 */ 2901 */
2864 2902
2865int 2903int
2866qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format, 2904qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format,
2867 uint16_t vp_idx) 2905 uint16_t vp_idx)
2868{ 2906{
2869 int rval; 2907 int rval;
@@ -2884,7 +2922,7 @@ qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format,
2884 mcp->in_mb = MBX_0|MBX_1; 2922 mcp->in_mb = MBX_0|MBX_1;
2885 mcp->tov = MBX_TOV_SECONDS; 2923 mcp->tov = MBX_TOV_SECONDS;
2886 mcp->flags = 0; 2924 mcp->flags = 0;
2887 rval = qla2x00_mailbox_command(ha, mcp); 2925 rval = qla2x00_mailbox_command(vha, mcp);
2888 2926
2889 if (rval == QLA_SUCCESS) { 2927 if (rval == QLA_SUCCESS) {
2890 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2928 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
@@ -2897,16 +2935,16 @@ qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format,
2897} 2935}
2898 2936
2899int 2937int
2900qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr, 2938qla2x00_dump_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr,
2901 uint32_t size) 2939 uint32_t size)
2902{ 2940{
2903 int rval; 2941 int rval;
2904 mbx_cmd_t mc; 2942 mbx_cmd_t mc;
2905 mbx_cmd_t *mcp = &mc; 2943 mbx_cmd_t *mcp = &mc;
2906 2944
2907 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2945 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2908 2946
2909 if (MSW(addr) || IS_FWI2_CAPABLE(ha)) { 2947 if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) {
2910 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; 2948 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED;
2911 mcp->mb[8] = MSW(addr); 2949 mcp->mb[8] = MSW(addr);
2912 mcp->out_mb = MBX_8|MBX_0; 2950 mcp->out_mb = MBX_8|MBX_0;
@@ -2920,7 +2958,7 @@ qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr,
2920 mcp->mb[6] = MSW(MSD(req_dma)); 2958 mcp->mb[6] = MSW(MSD(req_dma));
2921 mcp->mb[7] = LSW(MSD(req_dma)); 2959 mcp->mb[7] = LSW(MSD(req_dma));
2922 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; 2960 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
2923 if (IS_FWI2_CAPABLE(ha)) { 2961 if (IS_FWI2_CAPABLE(vha->hw)) {
2924 mcp->mb[4] = MSW(size); 2962 mcp->mb[4] = MSW(size);
2925 mcp->mb[5] = LSW(size); 2963 mcp->mb[5] = LSW(size);
2926 mcp->out_mb |= MBX_5|MBX_4; 2964 mcp->out_mb |= MBX_5|MBX_4;
@@ -2932,13 +2970,13 @@ qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr,
2932 mcp->in_mb = MBX_0; 2970 mcp->in_mb = MBX_0;
2933 mcp->tov = MBX_TOV_SECONDS; 2971 mcp->tov = MBX_TOV_SECONDS;
2934 mcp->flags = 0; 2972 mcp->flags = 0;
2935 rval = qla2x00_mailbox_command(ha, mcp); 2973 rval = qla2x00_mailbox_command(vha, mcp);
2936 2974
2937 if (rval != QLA_SUCCESS) { 2975 if (rval != QLA_SUCCESS) {
2938 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 2976 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
2939 ha->host_no, rval, mcp->mb[0])); 2977 vha->host_no, rval, mcp->mb[0]));
2940 } else { 2978 } else {
2941 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2979 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2942 } 2980 }
2943 2981
2944 return rval; 2982 return rval;
@@ -2954,20 +2992,21 @@ struct cs84xx_mgmt_cmd {
2954}; 2992};
2955 2993
2956int 2994int
2957qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status) 2995qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status)
2958{ 2996{
2959 int rval, retry; 2997 int rval, retry;
2960 struct cs84xx_mgmt_cmd *mn; 2998 struct cs84xx_mgmt_cmd *mn;
2961 dma_addr_t mn_dma; 2999 dma_addr_t mn_dma;
2962 uint16_t options; 3000 uint16_t options;
2963 unsigned long flags; 3001 unsigned long flags;
3002 struct qla_hw_data *ha = vha->hw;
2964 3003
2965 DEBUG16(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 3004 DEBUG16(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2966 3005
2967 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); 3006 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
2968 if (mn == NULL) { 3007 if (mn == NULL) {
2969 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX " 3008 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX "
2970 "IOCB.\n", __func__, ha->host_no)); 3009 "IOCB.\n", __func__, vha->host_no));
2971 return QLA_MEMORY_ALLOC_FAILED; 3010 return QLA_MEMORY_ALLOC_FAILED;
2972 } 3011 }
2973 3012
@@ -2986,19 +3025,19 @@ qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status)
2986 mn->p.req.options = cpu_to_le16(options); 3025 mn->p.req.options = cpu_to_le16(options);
2987 3026
2988 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__, 3027 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__,
2989 ha->host_no)); 3028 vha->host_no));
2990 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn, 3029 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
2991 sizeof(*mn))); 3030 sizeof(*mn)));
2992 3031
2993 rval = qla2x00_issue_iocb_timeout(ha, mn, mn_dma, 0, 120); 3032 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120);
2994 if (rval != QLA_SUCCESS) { 3033 if (rval != QLA_SUCCESS) {
2995 DEBUG2_16(printk("%s(%ld): failed to issue Verify " 3034 DEBUG2_16(printk("%s(%ld): failed to issue Verify "
2996 "IOCB (%x).\n", __func__, ha->host_no, rval)); 3035 "IOCB (%x).\n", __func__, vha->host_no, rval));
2997 goto verify_done; 3036 goto verify_done;
2998 } 3037 }
2999 3038
3000 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__, 3039 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__,
3001 ha->host_no)); 3040 vha->host_no));
3002 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn, 3041 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
3003 sizeof(*mn))); 3042 sizeof(*mn)));
3004 3043
@@ -3006,21 +3045,21 @@ qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status)
3006 status[1] = status[0] == CS_VCS_CHIP_FAILURE ? 3045 status[1] = status[0] == CS_VCS_CHIP_FAILURE ?
3007 le16_to_cpu(mn->p.rsp.failure_code) : 0; 3046 le16_to_cpu(mn->p.rsp.failure_code) : 0;
3008 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__, 3047 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__,
3009 ha->host_no, status[0], status[1])); 3048 vha->host_no, status[0], status[1]));
3010 3049
3011 if (status[0] != CS_COMPLETE) { 3050 if (status[0] != CS_COMPLETE) {
3012 rval = QLA_FUNCTION_FAILED; 3051 rval = QLA_FUNCTION_FAILED;
3013 if (!(options & VCO_DONT_UPDATE_FW)) { 3052 if (!(options & VCO_DONT_UPDATE_FW)) {
3014 DEBUG2_16(printk("%s(%ld): Firmware update " 3053 DEBUG2_16(printk("%s(%ld): Firmware update "
3015 "failed. Retrying without update " 3054 "failed. Retrying without update "
3016 "firmware.\n", __func__, ha->host_no)); 3055 "firmware.\n", __func__, vha->host_no));
3017 options |= VCO_DONT_UPDATE_FW; 3056 options |= VCO_DONT_UPDATE_FW;
3018 options &= ~VCO_FORCE_UPDATE; 3057 options &= ~VCO_FORCE_UPDATE;
3019 retry = 1; 3058 retry = 1;
3020 } 3059 }
3021 } else { 3060 } else {
3022 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n", 3061 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n",
3023 __func__, ha->host_no, 3062 __func__, vha->host_no,
3024 le32_to_cpu(mn->p.rsp.fw_ver))); 3063 le32_to_cpu(mn->p.rsp.fw_ver)));
3025 3064
3026 /* NOTE: we only update OP firmware. */ 3065 /* NOTE: we only update OP firmware. */
@@ -3037,10 +3076,115 @@ verify_done:
3037 3076
3038 if (rval != QLA_SUCCESS) { 3077 if (rval != QLA_SUCCESS) {
3039 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__, 3078 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__,
3040 ha->host_no, rval)); 3079 vha->host_no, rval));
3041 } else { 3080 } else {
3042 DEBUG16(printk("%s(%ld): done.\n", __func__, ha->host_no)); 3081 DEBUG16(printk("%s(%ld): done.\n", __func__, vha->host_no));
3082 }
3083
3084 return rval;
3085}
3086
3087int
3088qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req,
3089 uint8_t options)
3090{
3091 int rval;
3092 unsigned long flags;
3093 mbx_cmd_t mc;
3094 mbx_cmd_t *mcp = &mc;
3095 struct device_reg_25xxmq __iomem *reg;
3096 struct qla_hw_data *ha = vha->hw;
3097
3098 mcp->mb[0] = MBC_INITIALIZE_MULTIQ;
3099 mcp->mb[1] = options;
3100 mcp->mb[2] = MSW(LSD(req->dma));
3101 mcp->mb[3] = LSW(LSD(req->dma));
3102 mcp->mb[6] = MSW(MSD(req->dma));
3103 mcp->mb[7] = LSW(MSD(req->dma));
3104 mcp->mb[5] = req->length;
3105 if (req->rsp)
3106 mcp->mb[10] = req->rsp->id;
3107 mcp->mb[12] = req->qos;
3108 mcp->mb[11] = req->vp_idx;
3109 mcp->mb[13] = req->rid;
3110
3111 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) +
3112 QLA_QUE_PAGE * req->id);
3113
3114 mcp->mb[4] = req->id;
3115 /* que in ptr index */
3116 mcp->mb[8] = 0;
3117 /* que out ptr index */
3118 mcp->mb[9] = 0;
3119 mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7|
3120 MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3121 mcp->in_mb = MBX_0;
3122 mcp->flags = MBX_DMA_OUT;
3123 mcp->tov = 60;
3124
3125 spin_lock_irqsave(&ha->hardware_lock, flags);
3126 if (!(options & BIT_0)) {
3127 WRT_REG_DWORD(&reg->req_q_in, 0);
3128 WRT_REG_DWORD(&reg->req_q_out, 0);
3129 }
3130 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3131
3132 rval = qla2x00_mailbox_command(vha, mcp);
3133 if (rval != QLA_SUCCESS)
3134 DEBUG2_3_11(printk(KERN_WARNING "%s(%ld): failed=%x mb0=%x.\n",
3135 __func__, vha->host_no, rval, mcp->mb[0]));
3136 return rval;
3137}
3138
3139int
3140qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp,
3141 uint8_t options)
3142{
3143 int rval;
3144 unsigned long flags;
3145 mbx_cmd_t mc;
3146 mbx_cmd_t *mcp = &mc;
3147 struct device_reg_25xxmq __iomem *reg;
3148 struct qla_hw_data *ha = vha->hw;
3149
3150 mcp->mb[0] = MBC_INITIALIZE_MULTIQ;
3151 mcp->mb[1] = options;
3152 mcp->mb[2] = MSW(LSD(rsp->dma));
3153 mcp->mb[3] = LSW(LSD(rsp->dma));
3154 mcp->mb[6] = MSW(MSD(rsp->dma));
3155 mcp->mb[7] = LSW(MSD(rsp->dma));
3156 mcp->mb[5] = rsp->length;
3157 mcp->mb[11] = rsp->vp_idx;
3158 mcp->mb[14] = rsp->msix->vector;
3159 mcp->mb[13] = rsp->rid;
3160
3161 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) +
3162 QLA_QUE_PAGE * rsp->id);
3163
3164 mcp->mb[4] = rsp->id;
3165 /* que in ptr index */
3166 mcp->mb[8] = 0;
3167 /* que out ptr index */
3168 mcp->mb[9] = 0;
3169 mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7
3170 |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3171 mcp->in_mb = MBX_0;
3172 mcp->flags = MBX_DMA_OUT;
3173 mcp->tov = 60;
3174
3175 spin_lock_irqsave(&ha->hardware_lock, flags);
3176 if (!(options & BIT_0)) {
3177 WRT_REG_DWORD(&reg->rsp_q_out, 0);
3178 WRT_REG_DWORD(&reg->rsp_q_in, 0);
3043 } 3179 }
3044 3180
3181 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3182
3183 rval = qla2x00_mailbox_command(vha, mcp);
3184 if (rval != QLA_SUCCESS)
3185 DEBUG2_3_11(printk(KERN_WARNING "%s(%ld): failed=%x "
3186 "mb0=%x.\n", __func__,
3187 vha->host_no, rval, mcp->mb[0]));
3045 return rval; 3188 return rval;
3046} 3189}
3190