1 /* 2 * QLogic Fibre Channel HBA Driver 3 * Copyright (c) 2003-2008 QLogic Corporation 4 * 5 * See LICENSE.qla2xxx for copyright and licensing details. 6 */ 7 #include "qla_def.h" 8 9 #include <linux/delay.h> 10 11 12 /* 13 * qla2x00_mailbox_command 14 * Issue mailbox command and waits for completion. 15 * 16 * Input: 17 * ha = adapter block pointer. 18 * mcp = driver internal mbx struct pointer. 19 * 20 * Output: 21 * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data. 22 * 23 * Returns: 24 * 0 : QLA_SUCCESS = cmd performed success 25 * 1 : QLA_FUNCTION_FAILED (error encountered) 26 * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered) 27 * 28 * Context: 29 * Kernel context. 30 */ 31 static int 32 qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) 33 { 34 int rval; 35 unsigned long flags = 0; 36 device_reg_t __iomem *reg; 37 uint8_t abort_active; 38 uint8_t io_lock_on; 39 uint16_t command; 40 uint16_t *iptr; 41 uint16_t __iomem *optr; 42 uint32_t cnt; 43 uint32_t mboxes; 44 unsigned long wait_time; 45 struct qla_hw_data *ha = vha->hw; 46 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); 47 48 if (ha->pdev->error_state > pci_channel_io_frozen) 49 return QLA_FUNCTION_TIMEOUT; 50 51 reg = ha->iobase; 52 io_lock_on = base_vha->flags.init_done; 53 54 rval = QLA_SUCCESS; 55 abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 56 57 DEBUG11(printk("%s(%ld): entered.\n", __func__, base_vha->host_no)); 58 59 /* 60 * Wait for active mailbox commands to finish by waiting at most tov 61 * seconds. This is to serialize actual issuing of mailbox cmds during 62 * non ISP abort time. 63 */ 64 if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { 65 /* Timeout occurred. Return error. */ 66 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 67 "Exiting.\n", __func__, base_vha->host_no)); 68 return QLA_FUNCTION_TIMEOUT; 69 } 70 71 ha->flags.mbox_busy = 1; 72 /* Save mailbox command for debug */ 73 ha->mcp = mcp; 74 75 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n", 76 base_vha->host_no, mcp->mb[0])); 77 78 spin_lock_irqsave(&ha->hardware_lock, flags); 79 80 /* Load mailbox registers. */ 81 if (IS_FWI2_CAPABLE(ha)) 82 optr = (uint16_t __iomem *)®->isp24.mailbox0; 83 else 84 optr = (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 0); 85 86 iptr = mcp->mb; 87 command = mcp->mb[0]; 88 mboxes = mcp->out_mb; 89 90 for (cnt = 0; cnt < ha->mbx_count; cnt++) { 91 if (IS_QLA2200(ha) && cnt == 8) 92 optr = 93 (uint16_t __iomem *)MAILBOX_REG(ha, ®->isp, 8); 94 if (mboxes & BIT_0) 95 WRT_REG_WORD(optr, *iptr); 96 97 mboxes >>= 1; 98 optr++; 99 iptr++; 100 } 101 102 #if defined(QL_DEBUG_LEVEL_1) 103 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n", 104 __func__, base_vha->host_no); 105 qla2x00_dump_buffer((uint8_t *)mcp->mb, 16); 106 printk("\n"); 107 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16); 108 printk("\n"); 109 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8); 110 printk("\n"); 111 printk("%s(%ld): I/O address = %p.\n", __func__, base_vha->host_no, 112 optr); 113 qla2x00_dump_regs(base_vha); 114 #endif 115 116 /* Issue set host interrupt command to send cmd out. */ 117 ha->flags.mbox_int = 0; 118 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); 119 120 /* Unlock mbx registers and wait for interrupt */ 121 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. " 122 "jiffies=%lx.\n", __func__, base_vha->host_no, jiffies)); 123 124 /* Wait for mbx cmd completion until timeout */ 125 126 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { 127 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 128 129 if (IS_FWI2_CAPABLE(ha)) 130 WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); 131 else 132 WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); 133 spin_unlock_irqrestore(&ha->hardware_lock, flags); 134 135 wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ); 136 137 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 138 139 } else { 140 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 141 base_vha->host_no, command)); 142 143 if (IS_FWI2_CAPABLE(ha)) 144 WRT_REG_DWORD(®->isp24.hccr, HCCRX_SET_HOST_INT); 145 else 146 WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); 147 spin_unlock_irqrestore(&ha->hardware_lock, flags); 148 149 wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ 150 while (!ha->flags.mbox_int) { 151 if (time_after(jiffies, wait_time)) 152 break; 153 154 /* Check for pending interrupts. */ 155 qla2x00_poll(ha->rsp_q_map[0]); 156 157 if (command != MBC_LOAD_RISC_RAM_EXTENDED && 158 !ha->flags.mbox_int) 159 msleep(10); 160 } /* while */ 161 } 162 163 /* Check whether we timed out */ 164 if (ha->flags.mbox_int) { 165 uint16_t *iptr2; 166 167 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__, 168 base_vha->host_no, command)); 169 170 /* Got interrupt. Clear the flag. */ 171 ha->flags.mbox_int = 0; 172 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); 173 174 if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) 175 rval = QLA_FUNCTION_FAILED; 176 177 /* Load return mailbox registers. */ 178 iptr2 = mcp->mb; 179 iptr = (uint16_t *)&ha->mailbox_out[0]; 180 mboxes = mcp->in_mb; 181 for (cnt = 0; cnt < ha->mbx_count; cnt++) { 182 if (mboxes & BIT_0) 183 *iptr2 = *iptr; 184 185 mboxes >>= 1; 186 iptr2++; 187 iptr++; 188 } 189 } else { 190 191 #if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3) || \ 192 defined(QL_DEBUG_LEVEL_11) 193 uint16_t mb0; 194 uint32_t ictrl; 195 196 if (IS_FWI2_CAPABLE(ha)) { 197 mb0 = RD_REG_WORD(®->isp24.mailbox0); 198 ictrl = RD_REG_DWORD(®->isp24.ictrl); 199 } else { 200 mb0 = RD_MAILBOX_REG(ha, ®->isp, 0); 201 ictrl = RD_REG_WORD(®->isp.ictrl); 202 } 203 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n", 204 __func__, base_vha->host_no, command); 205 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__, 206 base_vha->host_no, ictrl, jiffies); 207 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__, 208 base_vha->host_no, mb0); 209 qla2x00_dump_regs(base_vha); 210 #endif 211 212 rval = QLA_FUNCTION_TIMEOUT; 213 } 214 215 ha->flags.mbox_busy = 0; 216 217 /* Clean up */ 218 ha->mcp = NULL; 219 220 if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) { 221 DEBUG11(printk("%s(%ld): checking for additional resp " 222 "interrupt.\n", __func__, base_vha->host_no)); 223 224 /* polling mode for non isp_abort commands. */ 225 qla2x00_poll(ha->rsp_q_map[0]); 226 } 227 228 if (rval == QLA_FUNCTION_TIMEOUT && 229 mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { 230 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) { 231 /* not in dpc. schedule it for dpc to take over. */ 232 DEBUG(printk("%s(%ld): timeout schedule " 233 "isp_abort_needed.\n", __func__, 234 base_vha->host_no)); 235 DEBUG2_3_11(printk("%s(%ld): timeout schedule " 236 "isp_abort_needed.\n", __func__, 237 base_vha->host_no)); 238 qla_printk(KERN_WARNING, ha, 239 "Mailbox command timeout occurred. Scheduling ISP " 240 "abort.\n"); 241 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 242 qla2xxx_wake_dpc(vha); 243 } else if (!abort_active) { 244 /* call abort directly since we are in the DPC thread */ 245 DEBUG(printk("%s(%ld): timeout calling abort_isp\n", 246 __func__, base_vha->host_no)); 247 DEBUG2_3_11(printk("%s(%ld): timeout calling " 248 "abort_isp\n", __func__, base_vha->host_no)); 249 qla_printk(KERN_WARNING, ha, 250 "Mailbox command timeout occurred. Issuing ISP " 251 "abort.\n"); 252 253 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 254 clear_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 255 if (qla2x00_abort_isp(base_vha)) { 256 /* Failed. retry later. */ 257 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 258 } 259 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 260 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__, 261 base_vha->host_no)); 262 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n", 263 __func__, base_vha->host_no)); 264 } 265 } 266 267 /* Allow next mbx cmd to come in. */ 268 complete(&ha->mbx_cmd_comp); 269 270 if (rval) { 271 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, " 272 "mbx2=%x, cmd=%x ****\n", __func__, base_vha->host_no, 273 mcp->mb[0], mcp->mb[1], mcp->mb[2], command)); 274 } else { 275 DEBUG11(printk("%s(%ld): done.\n", __func__, 276 base_vha->host_no)); 277 } 278 279 return rval; 280 } 281 282 int 283 qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr, 284 uint32_t risc_code_size) 285 { 286 int rval; 287 struct qla_hw_data *ha = vha->hw; 288 mbx_cmd_t mc; 289 mbx_cmd_t *mcp = &mc; 290 291 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 292 293 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { 294 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; 295 mcp->mb[8] = MSW(risc_addr); 296 mcp->out_mb = MBX_8|MBX_0; 297 } else { 298 mcp->mb[0] = MBC_LOAD_RISC_RAM; 299 mcp->out_mb = MBX_0; 300 } 301 mcp->mb[1] = LSW(risc_addr); 302 mcp->mb[2] = MSW(req_dma); 303 mcp->mb[3] = LSW(req_dma); 304 mcp->mb[6] = MSW(MSD(req_dma)); 305 mcp->mb[7] = LSW(MSD(req_dma)); 306 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; 307 if (IS_FWI2_CAPABLE(ha)) { 308 mcp->mb[4] = MSW(risc_code_size); 309 mcp->mb[5] = LSW(risc_code_size); 310 mcp->out_mb |= MBX_5|MBX_4; 311 } else { 312 mcp->mb[4] = LSW(risc_code_size); 313 mcp->out_mb |= MBX_4; 314 } 315 316 mcp->in_mb = MBX_0; 317 mcp->tov = MBX_TOV_SECONDS; 318 mcp->flags = 0; 319 rval = qla2x00_mailbox_command(vha, mcp); 320 321 if (rval != QLA_SUCCESS) { 322 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 323 vha->host_no, rval, mcp->mb[0])); 324 } else { 325 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 326 } 327 328 return rval; 329 } 330 331 /* 332 * qla2x00_execute_fw 333 * Start adapter firmware. 334 * 335 * Input: 336 * ha = adapter block pointer. 337 * TARGET_QUEUE_LOCK must be released. 338 * ADAPTER_STATE_LOCK must be released. 339 * 340 * Returns: 341 * qla2x00 local function return status code. 342 * 343 * Context: 344 * Kernel context. 345 */ 346 int 347 qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) 348 { 349 int rval; 350 struct qla_hw_data *ha = vha->hw; 351 mbx_cmd_t mc; 352 mbx_cmd_t *mcp = &mc; 353 354 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 355 356 mcp->mb[0] = MBC_EXECUTE_FIRMWARE; 357 mcp->out_mb = MBX_0; 358 mcp->in_mb = MBX_0; 359 if (IS_FWI2_CAPABLE(ha)) { 360 mcp->mb[1] = MSW(risc_addr); 361 mcp->mb[2] = LSW(risc_addr); 362 mcp->mb[3] = 0; 363 mcp->mb[4] = 0; 364 mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; 365 mcp->in_mb |= MBX_1; 366 } else { 367 mcp->mb[1] = LSW(risc_addr); 368 mcp->out_mb |= MBX_1; 369 if (IS_QLA2322(ha) || IS_QLA6322(ha)) { 370 mcp->mb[2] = 0; 371 mcp->out_mb |= MBX_2; 372 } 373 } 374 375 mcp->tov = MBX_TOV_SECONDS; 376 mcp->flags = 0; 377 rval = qla2x00_mailbox_command(vha, mcp); 378 379 if (rval != QLA_SUCCESS) { 380 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 381 vha->host_no, rval, mcp->mb[0])); 382 } else { 383 if (IS_FWI2_CAPABLE(ha)) { 384 DEBUG11(printk("%s(%ld): done exchanges=%x.\n", 385 __func__, vha->host_no, mcp->mb[1])); 386 } else { 387 DEBUG11(printk("%s(%ld): done.\n", __func__, 388 vha->host_no)); 389 } 390 } 391 392 return rval; 393 } 394 395 /* 396 * qla2x00_get_fw_version 397 * Get firmware version. 398 * 399 * Input: 400 * ha: adapter state pointer. 401 * major: pointer for major number. 402 * minor: pointer for minor number. 403 * subminor: pointer for subminor number. 404 * 405 * Returns: 406 * qla2x00 local function return status code. 407 * 408 * Context: 409 * Kernel context. 410 */ 411 void 412 qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor, 413 uint16_t *subminor, uint16_t *attributes, uint32_t *memory, uint8_t *mpi, 414 uint32_t *mpi_caps, uint8_t *phy) 415 { 416 int rval; 417 mbx_cmd_t mc; 418 mbx_cmd_t *mcp = &mc; 419 420 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 421 422 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; 423 mcp->out_mb = MBX_0; 424 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 425 if (IS_QLA81XX(vha->hw)) 426 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8; 427 mcp->flags = 0; 428 mcp->tov = MBX_TOV_SECONDS; 429 rval = qla2x00_mailbox_command(vha, mcp); 430 431 /* Return mailbox data. */ 432 *major = mcp->mb[1]; 433 *minor = mcp->mb[2]; 434 *subminor = mcp->mb[3]; 435 *attributes = mcp->mb[6]; 436 if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) 437 *memory = 0x1FFFF; /* Defaults to 128KB. */ 438 else 439 *memory = (mcp->mb[5] << 16) | mcp->mb[4]; 440 if (IS_QLA81XX(vha->hw)) { 441 mpi[0] = mcp->mb[10] & 0xff; 442 mpi[1] = mcp->mb[11] >> 8; 443 mpi[2] = mcp->mb[11] & 0xff; 444 *mpi_caps = (mcp->mb[12] << 16) | mcp->mb[13]; 445 phy[0] = mcp->mb[8] & 0xff; 446 phy[1] = mcp->mb[9] >> 8; 447 phy[2] = mcp->mb[9] & 0xff; 448 } 449 450 if (rval != QLA_SUCCESS) { 451 /*EMPTY*/ 452 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 453 vha->host_no, rval)); 454 } else { 455 /*EMPTY*/ 456 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 457 } 458 } 459 460 /* 461 * qla2x00_get_fw_options 462 * Set firmware options. 463 * 464 * Input: 465 * ha = adapter block pointer. 466 * fwopt = pointer for firmware options. 467 * 468 * Returns: 469 * qla2x00 local function return status code. 470 * 471 * Context: 472 * Kernel context. 473 */ 474 int 475 qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) 476 { 477 int rval; 478 mbx_cmd_t mc; 479 mbx_cmd_t *mcp = &mc; 480 481 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 482 483 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; 484 mcp->out_mb = MBX_0; 485 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 486 mcp->tov = MBX_TOV_SECONDS; 487 mcp->flags = 0; 488 rval = qla2x00_mailbox_command(vha, mcp); 489 490 if (rval != QLA_SUCCESS) { 491 /*EMPTY*/ 492 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 493 vha->host_no, rval)); 494 } else { 495 fwopts[0] = mcp->mb[0]; 496 fwopts[1] = mcp->mb[1]; 497 fwopts[2] = mcp->mb[2]; 498 fwopts[3] = mcp->mb[3]; 499 500 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 501 } 502 503 return rval; 504 } 505 506 507 /* 508 * qla2x00_set_fw_options 509 * Set firmware options. 510 * 511 * Input: 512 * ha = adapter block pointer. 513 * fwopt = pointer for firmware options. 514 * 515 * Returns: 516 * qla2x00 local function return status code. 517 * 518 * Context: 519 * Kernel context. 520 */ 521 int 522 qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts) 523 { 524 int rval; 525 mbx_cmd_t mc; 526 mbx_cmd_t *mcp = &mc; 527 528 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 529 530 mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; 531 mcp->mb[1] = fwopts[1]; 532 mcp->mb[2] = fwopts[2]; 533 mcp->mb[3] = fwopts[3]; 534 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 535 mcp->in_mb = MBX_0; 536 if (IS_FWI2_CAPABLE(vha->hw)) { 537 mcp->in_mb |= MBX_1; 538 } else { 539 mcp->mb[10] = fwopts[10]; 540 mcp->mb[11] = fwopts[11]; 541 mcp->mb[12] = 0; /* Undocumented, but used */ 542 mcp->out_mb |= MBX_12|MBX_11|MBX_10; 543 } 544 mcp->tov = MBX_TOV_SECONDS; 545 mcp->flags = 0; 546 rval = qla2x00_mailbox_command(vha, mcp); 547 548 fwopts[0] = mcp->mb[0]; 549 550 if (rval != QLA_SUCCESS) { 551 /*EMPTY*/ 552 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__, 553 vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 554 } else { 555 /*EMPTY*/ 556 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 557 } 558 559 return rval; 560 } 561 562 /* 563 * qla2x00_mbx_reg_test 564 * Mailbox register wrap test. 565 * 566 * Input: 567 * ha = adapter block pointer. 568 * TARGET_QUEUE_LOCK must be released. 569 * ADAPTER_STATE_LOCK must be released. 570 * 571 * Returns: 572 * qla2x00 local function return status code. 573 * 574 * Context: 575 * Kernel context. 576 */ 577 int 578 qla2x00_mbx_reg_test(scsi_qla_host_t *vha) 579 { 580 int rval; 581 mbx_cmd_t mc; 582 mbx_cmd_t *mcp = &mc; 583 584 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", vha->host_no)); 585 586 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; 587 mcp->mb[1] = 0xAAAA; 588 mcp->mb[2] = 0x5555; 589 mcp->mb[3] = 0xAA55; 590 mcp->mb[4] = 0x55AA; 591 mcp->mb[5] = 0xA5A5; 592 mcp->mb[6] = 0x5A5A; 593 mcp->mb[7] = 0x2525; 594 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 595 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 596 mcp->tov = MBX_TOV_SECONDS; 597 mcp->flags = 0; 598 rval = qla2x00_mailbox_command(vha, mcp); 599 600 if (rval == QLA_SUCCESS) { 601 if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || 602 mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA) 603 rval = QLA_FUNCTION_FAILED; 604 if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || 605 mcp->mb[7] != 0x2525) 606 rval = QLA_FUNCTION_FAILED; 607 } 608 609 if (rval != QLA_SUCCESS) { 610 /*EMPTY*/ 611 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n", 612 vha->host_no, rval)); 613 } else { 614 /*EMPTY*/ 615 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n", 616 vha->host_no)); 617 } 618 619 return rval; 620 } 621 622 /* 623 * qla2x00_verify_checksum 624 * Verify firmware checksum. 625 * 626 * Input: 627 * ha = adapter block pointer. 628 * TARGET_QUEUE_LOCK must be released. 629 * ADAPTER_STATE_LOCK must be released. 630 * 631 * Returns: 632 * qla2x00 local function return status code. 633 * 634 * Context: 635 * Kernel context. 636 */ 637 int 638 qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr) 639 { 640 int rval; 641 mbx_cmd_t mc; 642 mbx_cmd_t *mcp = &mc; 643 644 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 645 646 mcp->mb[0] = MBC_VERIFY_CHECKSUM; 647 mcp->out_mb = MBX_0; 648 mcp->in_mb = MBX_0; 649 if (IS_FWI2_CAPABLE(vha->hw)) { 650 mcp->mb[1] = MSW(risc_addr); 651 mcp->mb[2] = LSW(risc_addr); 652 mcp->out_mb |= MBX_2|MBX_1; 653 mcp->in_mb |= MBX_2|MBX_1; 654 } else { 655 mcp->mb[1] = LSW(risc_addr); 656 mcp->out_mb |= MBX_1; 657 mcp->in_mb |= MBX_1; 658 } 659 660 mcp->tov = MBX_TOV_SECONDS; 661 mcp->flags = 0; 662 rval = qla2x00_mailbox_command(vha, mcp); 663 664 if (rval != QLA_SUCCESS) { 665 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__, 666 vha->host_no, rval, IS_FWI2_CAPABLE(vha->hw) ? 667 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1])); 668 } else { 669 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 670 } 671 672 return rval; 673 } 674 675 /* 676 * qla2x00_issue_iocb 677 * Issue IOCB using mailbox command 678 * 679 * Input: 680 * ha = adapter state pointer. 681 * buffer = buffer pointer. 682 * phys_addr = physical address of buffer. 683 * size = size of buffer. 684 * TARGET_QUEUE_LOCK must be released. 685 * ADAPTER_STATE_LOCK must be released. 686 * 687 * Returns: 688 * qla2x00 local function return status code. 689 * 690 * Context: 691 * Kernel context. 692 */ 693 static int 694 qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer, 695 dma_addr_t phys_addr, size_t size, uint32_t tov) 696 { 697 int rval; 698 mbx_cmd_t mc; 699 mbx_cmd_t *mcp = &mc; 700 701 mcp->mb[0] = MBC_IOCB_COMMAND_A64; 702 mcp->mb[1] = 0; 703 mcp->mb[2] = MSW(phys_addr); 704 mcp->mb[3] = LSW(phys_addr); 705 mcp->mb[6] = MSW(MSD(phys_addr)); 706 mcp->mb[7] = LSW(MSD(phys_addr)); 707 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 708 mcp->in_mb = MBX_2|MBX_0; 709 mcp->tov = tov; 710 mcp->flags = 0; 711 rval = qla2x00_mailbox_command(vha, mcp); 712 713 if (rval != QLA_SUCCESS) { 714 /*EMPTY*/ 715 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n", 716 vha->host_no, rval)); 717 } else { 718 sts_entry_t *sts_entry = (sts_entry_t *) buffer; 719 720 /* Mask reserved bits. */ 721 sts_entry->entry_status &= 722 IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK; 723 } 724 725 return rval; 726 } 727 728 int 729 qla2x00_issue_iocb(scsi_qla_host_t *vha, void *buffer, dma_addr_t phys_addr, 730 size_t size) 731 { 732 return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size, 733 MBX_TOV_SECONDS); 734 } 735 736 /* 737 * qla2x00_abort_command 738 * Abort command aborts a specified IOCB. 739 * 740 * Input: 741 * ha = adapter block pointer. 742 * sp = SB structure pointer. 743 * 744 * Returns: 745 * qla2x00 local function return status code. 746 * 747 * Context: 748 * Kernel context. 749 */ 750 int 751 qla2x00_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req) 752 { 753 unsigned long flags = 0; 754 fc_port_t *fcport; 755 int rval; 756 uint32_t handle = 0; 757 mbx_cmd_t mc; 758 mbx_cmd_t *mcp = &mc; 759 struct qla_hw_data *ha = vha->hw; 760 761 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", vha->host_no)); 762 763 fcport = sp->fcport; 764 765 spin_lock_irqsave(&ha->hardware_lock, flags); 766 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 767 if (req->outstanding_cmds[handle] == sp) 768 break; 769 } 770 spin_unlock_irqrestore(&ha->hardware_lock, flags); 771 772 if (handle == MAX_OUTSTANDING_COMMANDS) { 773 /* command not found */ 774 return QLA_FUNCTION_FAILED; 775 } 776 777 mcp->mb[0] = MBC_ABORT_COMMAND; 778 if (HAS_EXTENDED_IDS(ha)) 779 mcp->mb[1] = fcport->loop_id; 780 else 781 mcp->mb[1] = fcport->loop_id << 8; 782 mcp->mb[2] = (uint16_t)handle; 783 mcp->mb[3] = (uint16_t)(handle >> 16); 784 mcp->mb[6] = (uint16_t)sp->cmd->device->lun; 785 mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 786 mcp->in_mb = MBX_0; 787 mcp->tov = MBX_TOV_SECONDS; 788 mcp->flags = 0; 789 rval = qla2x00_mailbox_command(vha, mcp); 790 791 if (rval != QLA_SUCCESS) { 792 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n", 793 vha->host_no, rval)); 794 } else { 795 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n", 796 vha->host_no)); 797 } 798 799 return rval; 800 } 801 802 int 803 qla2x00_abort_target(struct fc_port *fcport, unsigned int l) 804 { 805 int rval, rval2; 806 mbx_cmd_t mc; 807 mbx_cmd_t *mcp = &mc; 808 scsi_qla_host_t *vha; 809 struct req_que *req; 810 struct rsp_que *rsp; 811 812 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no)); 813 814 l = l; 815 vha = fcport->vha; 816 req = vha->hw->req_q_map[0]; 817 rsp = vha->hw->rsp_q_map[0]; 818 mcp->mb[0] = MBC_ABORT_TARGET; 819 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; 820 if (HAS_EXTENDED_IDS(vha->hw)) { 821 mcp->mb[1] = fcport->loop_id; 822 mcp->mb[10] = 0; 823 mcp->out_mb |= MBX_10; 824 } else { 825 mcp->mb[1] = fcport->loop_id << 8; 826 } 827 mcp->mb[2] = vha->hw->loop_reset_delay; 828 mcp->mb[9] = vha->vp_idx; 829 830 mcp->in_mb = MBX_0; 831 mcp->tov = MBX_TOV_SECONDS; 832 mcp->flags = 0; 833 rval = qla2x00_mailbox_command(vha, mcp); 834 if (rval != QLA_SUCCESS) { 835 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 836 vha->host_no, rval)); 837 } 838 839 /* Issue marker IOCB. */ 840 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0, 841 MK_SYNC_ID); 842 if (rval2 != QLA_SUCCESS) { 843 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 844 "(%x).\n", __func__, vha->host_no, rval2)); 845 } else { 846 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 847 } 848 849 return rval; 850 } 851 852 int 853 qla2x00_lun_reset(struct fc_port *fcport, unsigned int l) 854 { 855 int rval, rval2; 856 mbx_cmd_t mc; 857 mbx_cmd_t *mcp = &mc; 858 scsi_qla_host_t *vha; 859 struct req_que *req; 860 struct rsp_que *rsp; 861 862 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no)); 863 864 vha = fcport->vha; 865 req = vha->hw->req_q_map[0]; 866 rsp = vha->hw->rsp_q_map[0]; 867 mcp->mb[0] = MBC_LUN_RESET; 868 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; 869 if (HAS_EXTENDED_IDS(vha->hw)) 870 mcp->mb[1] = fcport->loop_id; 871 else 872 mcp->mb[1] = fcport->loop_id << 8; 873 mcp->mb[2] = l; 874 mcp->mb[3] = 0; 875 mcp->mb[9] = vha->vp_idx; 876 877 mcp->in_mb = MBX_0; 878 mcp->tov = MBX_TOV_SECONDS; 879 mcp->flags = 0; 880 rval = qla2x00_mailbox_command(vha, mcp); 881 if (rval != QLA_SUCCESS) { 882 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 883 vha->host_no, rval)); 884 } 885 886 /* Issue marker IOCB. */ 887 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, 888 MK_SYNC_ID_LUN); 889 if (rval2 != QLA_SUCCESS) { 890 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 891 "(%x).\n", __func__, vha->host_no, rval2)); 892 } else { 893 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 894 } 895 896 return rval; 897 } 898 899 /* 900 * qla2x00_get_adapter_id 901 * Get adapter ID and topology. 902 * 903 * Input: 904 * ha = adapter block pointer. 905 * id = pointer for loop ID. 906 * al_pa = pointer for AL_PA. 907 * area = pointer for area. 908 * domain = pointer for domain. 909 * top = pointer for topology. 910 * TARGET_QUEUE_LOCK must be released. 911 * ADAPTER_STATE_LOCK must be released. 912 * 913 * Returns: 914 * qla2x00 local function return status code. 915 * 916 * Context: 917 * Kernel context. 918 */ 919 int 920 qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa, 921 uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap) 922 { 923 int rval; 924 mbx_cmd_t mc; 925 mbx_cmd_t *mcp = &mc; 926 927 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n", 928 vha->host_no)); 929 930 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; 931 mcp->mb[9] = vha->vp_idx; 932 mcp->out_mb = MBX_9|MBX_0; 933 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 934 mcp->tov = MBX_TOV_SECONDS; 935 mcp->flags = 0; 936 rval = qla2x00_mailbox_command(vha, mcp); 937 if (mcp->mb[0] == MBS_COMMAND_ERROR) 938 rval = QLA_COMMAND_ERROR; 939 else if (mcp->mb[0] == MBS_INVALID_COMMAND) 940 rval = QLA_INVALID_COMMAND; 941 942 /* Return data. */ 943 *id = mcp->mb[1]; 944 *al_pa = LSB(mcp->mb[2]); 945 *area = MSB(mcp->mb[2]); 946 *domain = LSB(mcp->mb[3]); 947 *top = mcp->mb[6]; 948 *sw_cap = mcp->mb[7]; 949 950 if (rval != QLA_SUCCESS) { 951 /*EMPTY*/ 952 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n", 953 vha->host_no, rval)); 954 } else { 955 /*EMPTY*/ 956 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n", 957 vha->host_no)); 958 } 959 960 return rval; 961 } 962 963 /* 964 * qla2x00_get_retry_cnt 965 * Get current firmware login retry count and delay. 966 * 967 * Input: 968 * ha = adapter block pointer. 969 * retry_cnt = pointer to login retry count. 970 * tov = pointer to login timeout value. 971 * 972 * Returns: 973 * qla2x00 local function return status code. 974 * 975 * Context: 976 * Kernel context. 977 */ 978 int 979 qla2x00_get_retry_cnt(scsi_qla_host_t *vha, uint8_t *retry_cnt, uint8_t *tov, 980 uint16_t *r_a_tov) 981 { 982 int rval; 983 uint16_t ratov; 984 mbx_cmd_t mc; 985 mbx_cmd_t *mcp = &mc; 986 987 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n", 988 vha->host_no)); 989 990 mcp->mb[0] = MBC_GET_RETRY_COUNT; 991 mcp->out_mb = MBX_0; 992 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 993 mcp->tov = MBX_TOV_SECONDS; 994 mcp->flags = 0; 995 rval = qla2x00_mailbox_command(vha, mcp); 996 997 if (rval != QLA_SUCCESS) { 998 /*EMPTY*/ 999 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n", 1000 vha->host_no, mcp->mb[0])); 1001 } else { 1002 /* Convert returned data and check our values. */ 1003 *r_a_tov = mcp->mb[3] / 2; 1004 ratov = (mcp->mb[3]/2) / 10; /* mb[3] value is in 100ms */ 1005 if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) { 1006 /* Update to the larger values */ 1007 *retry_cnt = (uint8_t)mcp->mb[1]; 1008 *tov = ratov; 1009 } 1010 1011 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d " 1012 "ratov=%d.\n", vha->host_no, mcp->mb[3], ratov)); 1013 } 1014 1015 return rval; 1016 } 1017 1018 /* 1019 * qla2x00_init_firmware 1020 * Initialize adapter firmware. 1021 * 1022 * Input: 1023 * ha = adapter block pointer. 1024 * dptr = Initialization control block pointer. 1025 * size = size of initialization control block. 1026 * TARGET_QUEUE_LOCK must be released. 1027 * ADAPTER_STATE_LOCK must be released. 1028 * 1029 * Returns: 1030 * qla2x00 local function return status code. 1031 * 1032 * Context: 1033 * Kernel context. 1034 */ 1035 int 1036 qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) 1037 { 1038 int rval; 1039 mbx_cmd_t mc; 1040 mbx_cmd_t *mcp = &mc; 1041 struct qla_hw_data *ha = vha->hw; 1042 1043 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n", 1044 vha->host_no)); 1045 1046 if (ha->flags.npiv_supported) 1047 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; 1048 else 1049 mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; 1050 1051 mcp->mb[1] = 0; 1052 mcp->mb[2] = MSW(ha->init_cb_dma); 1053 mcp->mb[3] = LSW(ha->init_cb_dma); 1054 mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); 1055 mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); 1056 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1057 if (IS_QLA81XX(ha) && ha->ex_init_cb->ex_version) { 1058 mcp->mb[1] = BIT_0; 1059 mcp->mb[10] = MSW(ha->ex_init_cb_dma); 1060 mcp->mb[11] = LSW(ha->ex_init_cb_dma); 1061 mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); 1062 mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); 1063 mcp->mb[14] = sizeof(*ha->ex_init_cb); 1064 mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; 1065 } 1066 mcp->in_mb = MBX_0; 1067 mcp->buf_size = size; 1068 mcp->flags = MBX_DMA_OUT; 1069 mcp->tov = MBX_TOV_SECONDS; 1070 rval = qla2x00_mailbox_command(vha, mcp); 1071 1072 if (rval != QLA_SUCCESS) { 1073 /*EMPTY*/ 1074 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x " 1075 "mb0=%x.\n", 1076 vha->host_no, rval, mcp->mb[0])); 1077 } else { 1078 /*EMPTY*/ 1079 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n", 1080 vha->host_no)); 1081 } 1082 1083 return rval; 1084 } 1085 1086 /* 1087 * qla2x00_get_port_database 1088 * Issue normal/enhanced get port database mailbox command 1089 * and copy device name as necessary. 1090 * 1091 * Input: 1092 * ha = adapter state pointer. 1093 * dev = structure pointer. 1094 * opt = enhanced cmd option byte. 1095 * 1096 * Returns: 1097 * qla2x00 local function return status code. 1098 * 1099 * Context: 1100 * Kernel context. 1101 */ 1102 int 1103 qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt) 1104 { 1105 int rval; 1106 mbx_cmd_t mc; 1107 mbx_cmd_t *mcp = &mc; 1108 port_database_t *pd; 1109 struct port_database_24xx *pd24; 1110 dma_addr_t pd_dma; 1111 struct qla_hw_data *ha = vha->hw; 1112 1113 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1114 1115 pd24 = NULL; 1116 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); 1117 if (pd == NULL) { 1118 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database " 1119 "structure.\n", __func__, vha->host_no)); 1120 return QLA_MEMORY_ALLOC_FAILED; 1121 } 1122 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); 1123 1124 mcp->mb[0] = MBC_GET_PORT_DATABASE; 1125 if (opt != 0 && !IS_FWI2_CAPABLE(ha)) 1126 mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; 1127 mcp->mb[2] = MSW(pd_dma); 1128 mcp->mb[3] = LSW(pd_dma); 1129 mcp->mb[6] = MSW(MSD(pd_dma)); 1130 mcp->mb[7] = LSW(MSD(pd_dma)); 1131 mcp->mb[9] = vha->vp_idx; 1132 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 1133 mcp->in_mb = MBX_0; 1134 if (IS_FWI2_CAPABLE(ha)) { 1135 mcp->mb[1] = fcport->loop_id; 1136 mcp->mb[10] = opt; 1137 mcp->out_mb |= MBX_10|MBX_1; 1138 mcp->in_mb |= MBX_1; 1139 } else if (HAS_EXTENDED_IDS(ha)) { 1140 mcp->mb[1] = fcport->loop_id; 1141 mcp->mb[10] = opt; 1142 mcp->out_mb |= MBX_10|MBX_1; 1143 } else { 1144 mcp->mb[1] = fcport->loop_id << 8 | opt; 1145 mcp->out_mb |= MBX_1; 1146 } 1147 mcp->buf_size = IS_FWI2_CAPABLE(ha) ? 1148 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; 1149 mcp->flags = MBX_DMA_IN; 1150 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1151 rval = qla2x00_mailbox_command(vha, mcp); 1152 if (rval != QLA_SUCCESS) 1153 goto gpd_error_out; 1154 1155 if (IS_FWI2_CAPABLE(ha)) { 1156 pd24 = (struct port_database_24xx *) pd; 1157 1158 /* Check for logged in state. */ 1159 if (pd24->current_login_state != PDS_PRLI_COMPLETE && 1160 pd24->last_login_state != PDS_PRLI_COMPLETE) { 1161 DEBUG2(printk("%s(%ld): Unable to verify " 1162 "login-state (%x/%x) for loop_id %x\n", 1163 __func__, vha->host_no, 1164 pd24->current_login_state, 1165 pd24->last_login_state, fcport->loop_id)); 1166 rval = QLA_FUNCTION_FAILED; 1167 goto gpd_error_out; 1168 } 1169 1170 /* Names are little-endian. */ 1171 memcpy(fcport->node_name, pd24->node_name, WWN_SIZE); 1172 memcpy(fcport->port_name, pd24->port_name, WWN_SIZE); 1173 1174 /* Get port_id of device. */ 1175 fcport->d_id.b.domain = pd24->port_id[0]; 1176 fcport->d_id.b.area = pd24->port_id[1]; 1177 fcport->d_id.b.al_pa = pd24->port_id[2]; 1178 fcport->d_id.b.rsvd_1 = 0; 1179 1180 /* If not target must be initiator or unknown type. */ 1181 if ((pd24->prli_svc_param_word_3[0] & BIT_4) == 0) 1182 fcport->port_type = FCT_INITIATOR; 1183 else 1184 fcport->port_type = FCT_TARGET; 1185 } else { 1186 /* Check for logged in state. */ 1187 if (pd->master_state != PD_STATE_PORT_LOGGED_IN && 1188 pd->slave_state != PD_STATE_PORT_LOGGED_IN) { 1189 rval = QLA_FUNCTION_FAILED; 1190 goto gpd_error_out; 1191 } 1192 1193 /* Names are little-endian. */ 1194 memcpy(fcport->node_name, pd->node_name, WWN_SIZE); 1195 memcpy(fcport->port_name, pd->port_name, WWN_SIZE); 1196 1197 /* Get port_id of device. */ 1198 fcport->d_id.b.domain = pd->port_id[0]; 1199 fcport->d_id.b.area = pd->port_id[3]; 1200 fcport->d_id.b.al_pa = pd->port_id[2]; 1201 fcport->d_id.b.rsvd_1 = 0; 1202 1203 /* If not target must be initiator or unknown type. */ 1204 if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) 1205 fcport->port_type = FCT_INITIATOR; 1206 else 1207 fcport->port_type = FCT_TARGET; 1208 1209 /* Passback COS information. */ 1210 fcport->supported_classes = (pd->options & BIT_4) ? 1211 FC_COS_CLASS2: FC_COS_CLASS3; 1212 } 1213 1214 gpd_error_out: 1215 dma_pool_free(ha->s_dma_pool, pd, pd_dma); 1216 1217 if (rval != QLA_SUCCESS) { 1218 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 1219 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1220 } else { 1221 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 1222 } 1223 1224 return rval; 1225 } 1226 1227 /* 1228 * qla2x00_get_firmware_state 1229 * Get adapter firmware state. 1230 * 1231 * Input: 1232 * ha = adapter block pointer. 1233 * dptr = pointer for firmware state. 1234 * TARGET_QUEUE_LOCK must be released. 1235 * ADAPTER_STATE_LOCK must be released. 1236 * 1237 * Returns: 1238 * qla2x00 local function return status code. 1239 * 1240 * Context: 1241 * Kernel context. 1242 */ 1243 int 1244 qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) 1245 { 1246 int rval; 1247 mbx_cmd_t mc; 1248 mbx_cmd_t *mcp = &mc; 1249 1250 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n", 1251 vha->host_no)); 1252 1253 mcp->mb[0] = MBC_GET_FIRMWARE_STATE; 1254 mcp->out_mb = MBX_0; 1255 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1256 mcp->tov = MBX_TOV_SECONDS; 1257 mcp->flags = 0; 1258 rval = qla2x00_mailbox_command(vha, mcp); 1259 1260 /* Return firmware states. */ 1261 states[0] = mcp->mb[1]; 1262 states[1] = mcp->mb[2]; 1263 states[2] = mcp->mb[3]; 1264 1265 if (rval != QLA_SUCCESS) { 1266 /*EMPTY*/ 1267 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): " 1268 "failed=%x.\n", vha->host_no, rval)); 1269 } else { 1270 /*EMPTY*/ 1271 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n", 1272 vha->host_no)); 1273 } 1274 1275 return rval; 1276 } 1277 1278 /* 1279 * qla2x00_get_port_name 1280 * Issue get port name mailbox command. 1281 * Returned name is in big endian format. 1282 * 1283 * Input: 1284 * ha = adapter block pointer. 1285 * loop_id = loop ID of device. 1286 * name = pointer for name. 1287 * TARGET_QUEUE_LOCK must be released. 1288 * ADAPTER_STATE_LOCK must be released. 1289 * 1290 * Returns: 1291 * qla2x00 local function return status code. 1292 * 1293 * Context: 1294 * Kernel context. 1295 */ 1296 int 1297 qla2x00_get_port_name(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t *name, 1298 uint8_t opt) 1299 { 1300 int rval; 1301 mbx_cmd_t mc; 1302 mbx_cmd_t *mcp = &mc; 1303 1304 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n", 1305 vha->host_no)); 1306 1307 mcp->mb[0] = MBC_GET_PORT_NAME; 1308 mcp->mb[9] = vha->vp_idx; 1309 mcp->out_mb = MBX_9|MBX_1|MBX_0; 1310 if (HAS_EXTENDED_IDS(vha->hw)) { 1311 mcp->mb[1] = loop_id; 1312 mcp->mb[10] = opt; 1313 mcp->out_mb |= MBX_10; 1314 } else { 1315 mcp->mb[1] = loop_id << 8 | opt; 1316 } 1317 1318 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1319 mcp->tov = MBX_TOV_SECONDS; 1320 mcp->flags = 0; 1321 rval = qla2x00_mailbox_command(vha, mcp); 1322 1323 if (rval != QLA_SUCCESS) { 1324 /*EMPTY*/ 1325 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n", 1326 vha->host_no, rval)); 1327 } else { 1328 if (name != NULL) { 1329 /* This function returns name in big endian. */ 1330 name[0] = MSB(mcp->mb[2]); 1331 name[1] = LSB(mcp->mb[2]); 1332 name[2] = MSB(mcp->mb[3]); 1333 name[3] = LSB(mcp->mb[3]); 1334 name[4] = MSB(mcp->mb[6]); 1335 name[5] = LSB(mcp->mb[6]); 1336 name[6] = MSB(mcp->mb[7]); 1337 name[7] = LSB(mcp->mb[7]); 1338 } 1339 1340 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n", 1341 vha->host_no)); 1342 } 1343 1344 return rval; 1345 } 1346 1347 /* 1348 * qla2x00_lip_reset 1349 * Issue LIP reset mailbox command. 1350 * 1351 * Input: 1352 * ha = adapter block pointer. 1353 * TARGET_QUEUE_LOCK must be released. 1354 * ADAPTER_STATE_LOCK must be released. 1355 * 1356 * Returns: 1357 * qla2x00 local function return status code. 1358 * 1359 * Context: 1360 * Kernel context. 1361 */ 1362 int 1363 qla2x00_lip_reset(scsi_qla_host_t *vha) 1364 { 1365 int rval; 1366 mbx_cmd_t mc; 1367 mbx_cmd_t *mcp = &mc; 1368 1369 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1370 1371 if (IS_QLA81XX(vha->hw)) { 1372 /* Logout across all FCFs. */ 1373 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1374 mcp->mb[1] = BIT_1; 1375 mcp->mb[2] = 0; 1376 mcp->out_mb = MBX_2|MBX_1|MBX_0; 1377 } else if (IS_FWI2_CAPABLE(vha->hw)) { 1378 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1379 mcp->mb[1] = BIT_6; 1380 mcp->mb[2] = 0; 1381 mcp->mb[3] = vha->hw->loop_reset_delay; 1382 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1383 } else { 1384 mcp->mb[0] = MBC_LIP_RESET; 1385 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1386 if (HAS_EXTENDED_IDS(vha->hw)) { 1387 mcp->mb[1] = 0x00ff; 1388 mcp->mb[10] = 0; 1389 mcp->out_mb |= MBX_10; 1390 } else { 1391 mcp->mb[1] = 0xff00; 1392 } 1393 mcp->mb[2] = vha->hw->loop_reset_delay; 1394 mcp->mb[3] = 0; 1395 } 1396 mcp->in_mb = MBX_0; 1397 mcp->tov = MBX_TOV_SECONDS; 1398 mcp->flags = 0; 1399 rval = qla2x00_mailbox_command(vha, mcp); 1400 1401 if (rval != QLA_SUCCESS) { 1402 /*EMPTY*/ 1403 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", 1404 __func__, vha->host_no, rval)); 1405 } else { 1406 /*EMPTY*/ 1407 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 1408 } 1409 1410 return rval; 1411 } 1412 1413 /* 1414 * qla2x00_send_sns 1415 * Send SNS command. 1416 * 1417 * Input: 1418 * ha = adapter block pointer. 1419 * sns = pointer for command. 1420 * cmd_size = command size. 1421 * buf_size = response/command size. 1422 * TARGET_QUEUE_LOCK must be released. 1423 * ADAPTER_STATE_LOCK must be released. 1424 * 1425 * Returns: 1426 * qla2x00 local function return status code. 1427 * 1428 * Context: 1429 * Kernel context. 1430 */ 1431 int 1432 qla2x00_send_sns(scsi_qla_host_t *vha, dma_addr_t sns_phys_address, 1433 uint16_t cmd_size, size_t buf_size) 1434 { 1435 int rval; 1436 mbx_cmd_t mc; 1437 mbx_cmd_t *mcp = &mc; 1438 1439 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n", 1440 vha->host_no)); 1441 1442 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total " 1443 "tov=%d.\n", vha->hw->retry_count, vha->hw->login_timeout, 1444 mcp->tov)); 1445 1446 mcp->mb[0] = MBC_SEND_SNS_COMMAND; 1447 mcp->mb[1] = cmd_size; 1448 mcp->mb[2] = MSW(sns_phys_address); 1449 mcp->mb[3] = LSW(sns_phys_address); 1450 mcp->mb[6] = MSW(MSD(sns_phys_address)); 1451 mcp->mb[7] = LSW(MSD(sns_phys_address)); 1452 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1453 mcp->in_mb = MBX_0|MBX_1; 1454 mcp->buf_size = buf_size; 1455 mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; 1456 mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2); 1457 rval = qla2x00_mailbox_command(vha, mcp); 1458 1459 if (rval != QLA_SUCCESS) { 1460 /*EMPTY*/ 1461 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1462 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1463 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1464 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1465 } else { 1466 /*EMPTY*/ 1467 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", vha->host_no)); 1468 } 1469 1470 return rval; 1471 } 1472 1473 int 1474 qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, 1475 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) 1476 { 1477 int rval; 1478 1479 struct logio_entry_24xx *lg; 1480 dma_addr_t lg_dma; 1481 uint32_t iop[2]; 1482 struct qla_hw_data *ha = vha->hw; 1483 1484 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1485 1486 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1487 if (lg == NULL) { 1488 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n", 1489 __func__, vha->host_no)); 1490 return QLA_MEMORY_ALLOC_FAILED; 1491 } 1492 memset(lg, 0, sizeof(struct logio_entry_24xx)); 1493 1494 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; 1495 lg->entry_count = 1; 1496 lg->nport_handle = cpu_to_le16(loop_id); 1497 lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI); 1498 if (opt & BIT_0) 1499 lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI); 1500 if (opt & BIT_1) 1501 lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI); 1502 lg->port_id[0] = al_pa; 1503 lg->port_id[1] = area; 1504 lg->port_id[2] = domain; 1505 lg->vp_index = vha->vp_idx; 1506 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0); 1507 if (rval != QLA_SUCCESS) { 1508 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB " 1509 "(%x).\n", __func__, vha->host_no, rval)); 1510 } else if (lg->entry_status != 0) { 1511 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1512 "-- error status (%x).\n", __func__, vha->host_no, 1513 lg->entry_status)); 1514 rval = QLA_FUNCTION_FAILED; 1515 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1516 iop[0] = le32_to_cpu(lg->io_parameter[0]); 1517 iop[1] = le32_to_cpu(lg->io_parameter[1]); 1518 1519 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1520 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1521 vha->host_no, le16_to_cpu(lg->comp_status), iop[0], 1522 iop[1])); 1523 1524 switch (iop[0]) { 1525 case LSC_SCODE_PORTID_USED: 1526 mb[0] = MBS_PORT_ID_USED; 1527 mb[1] = LSW(iop[1]); 1528 break; 1529 case LSC_SCODE_NPORT_USED: 1530 mb[0] = MBS_LOOP_ID_USED; 1531 break; 1532 case LSC_SCODE_NOLINK: 1533 case LSC_SCODE_NOIOCB: 1534 case LSC_SCODE_NOXCB: 1535 case LSC_SCODE_CMD_FAILED: 1536 case LSC_SCODE_NOFABRIC: 1537 case LSC_SCODE_FW_NOT_READY: 1538 case LSC_SCODE_NOT_LOGGED_IN: 1539 case LSC_SCODE_NOPCB: 1540 case LSC_SCODE_ELS_REJECT: 1541 case LSC_SCODE_CMD_PARAM_ERR: 1542 case LSC_SCODE_NONPORT: 1543 case LSC_SCODE_LOGGED_IN: 1544 case LSC_SCODE_NOFLOGI_ACC: 1545 default: 1546 mb[0] = MBS_COMMAND_ERROR; 1547 break; 1548 } 1549 } else { 1550 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 1551 1552 iop[0] = le32_to_cpu(lg->io_parameter[0]); 1553 1554 mb[0] = MBS_COMMAND_COMPLETE; 1555 mb[1] = 0; 1556 if (iop[0] & BIT_4) { 1557 if (iop[0] & BIT_8) 1558 mb[1] |= BIT_1; 1559 } else 1560 mb[1] = BIT_0; 1561 1562 /* Passback COS information. */ 1563 mb[10] = 0; 1564 if (lg->io_parameter[7] || lg->io_parameter[8]) 1565 mb[10] |= BIT_0; /* Class 2. */ 1566 if (lg->io_parameter[9] || lg->io_parameter[10]) 1567 mb[10] |= BIT_1; /* Class 3. */ 1568 } 1569 1570 dma_pool_free(ha->s_dma_pool, lg, lg_dma); 1571 1572 return rval; 1573 } 1574 1575 /* 1576 * qla2x00_login_fabric 1577 * Issue login fabric port mailbox command. 1578 * 1579 * Input: 1580 * ha = adapter block pointer. 1581 * loop_id = device loop ID. 1582 * domain = device domain. 1583 * area = device area. 1584 * al_pa = device AL_PA. 1585 * status = pointer for return status. 1586 * opt = command options. 1587 * TARGET_QUEUE_LOCK must be released. 1588 * ADAPTER_STATE_LOCK must be released. 1589 * 1590 * Returns: 1591 * qla2x00 local function return status code. 1592 * 1593 * Context: 1594 * Kernel context. 1595 */ 1596 int 1597 qla2x00_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, 1598 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) 1599 { 1600 int rval; 1601 mbx_cmd_t mc; 1602 mbx_cmd_t *mcp = &mc; 1603 struct qla_hw_data *ha = vha->hw; 1604 1605 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", vha->host_no)); 1606 1607 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; 1608 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1609 if (HAS_EXTENDED_IDS(ha)) { 1610 mcp->mb[1] = loop_id; 1611 mcp->mb[10] = opt; 1612 mcp->out_mb |= MBX_10; 1613 } else { 1614 mcp->mb[1] = (loop_id << 8) | opt; 1615 } 1616 mcp->mb[2] = domain; 1617 mcp->mb[3] = area << 8 | al_pa; 1618 1619 mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; 1620 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1621 mcp->flags = 0; 1622 rval = qla2x00_mailbox_command(vha, mcp); 1623 1624 /* Return mailbox statuses. */ 1625 if (mb != NULL) { 1626 mb[0] = mcp->mb[0]; 1627 mb[1] = mcp->mb[1]; 1628 mb[2] = mcp->mb[2]; 1629 mb[6] = mcp->mb[6]; 1630 mb[7] = mcp->mb[7]; 1631 /* COS retrieved from Get-Port-Database mailbox command. */ 1632 mb[10] = 0; 1633 } 1634 1635 if (rval != QLA_SUCCESS) { 1636 /* RLU tmp code: need to change main mailbox_command function to 1637 * return ok even when the mailbox completion value is not 1638 * SUCCESS. The caller needs to be responsible to interpret 1639 * the return values of this mailbox command if we're not 1640 * to change too much of the existing code. 1641 */ 1642 if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 || 1643 mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 || 1644 mcp->mb[0] == 0x4006) 1645 rval = QLA_SUCCESS; 1646 1647 /*EMPTY*/ 1648 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x " 1649 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", vha->host_no, rval, 1650 mcp->mb[0], mcp->mb[1], mcp->mb[2])); 1651 } else { 1652 /*EMPTY*/ 1653 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n", 1654 vha->host_no)); 1655 } 1656 1657 return rval; 1658 } 1659 1660 /* 1661 * qla2x00_login_local_device 1662 * Issue login loop port mailbox command. 1663 * 1664 * Input: 1665 * ha = adapter block pointer. 1666 * loop_id = device loop ID. 1667 * opt = command options. 1668 * 1669 * Returns: 1670 * Return status code. 1671 * 1672 * Context: 1673 * Kernel context. 1674 * 1675 */ 1676 int 1677 qla2x00_login_local_device(scsi_qla_host_t *vha, fc_port_t *fcport, 1678 uint16_t *mb_ret, uint8_t opt) 1679 { 1680 int rval; 1681 mbx_cmd_t mc; 1682 mbx_cmd_t *mcp = &mc; 1683 struct qla_hw_data *ha = vha->hw; 1684 1685 if (IS_FWI2_CAPABLE(ha)) 1686 return qla24xx_login_fabric(vha, fcport->loop_id, 1687 fcport->d_id.b.domain, fcport->d_id.b.area, 1688 fcport->d_id.b.al_pa, mb_ret, opt); 1689 1690 DEBUG3(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1691 1692 mcp->mb[0] = MBC_LOGIN_LOOP_PORT; 1693 if (HAS_EXTENDED_IDS(ha)) 1694 mcp->mb[1] = fcport->loop_id; 1695 else 1696 mcp->mb[1] = fcport->loop_id << 8; 1697 mcp->mb[2] = opt; 1698 mcp->out_mb = MBX_2|MBX_1|MBX_0; 1699 mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; 1700 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1701 mcp->flags = 0; 1702 rval = qla2x00_mailbox_command(vha, mcp); 1703 1704 /* Return mailbox statuses. */ 1705 if (mb_ret != NULL) { 1706 mb_ret[0] = mcp->mb[0]; 1707 mb_ret[1] = mcp->mb[1]; 1708 mb_ret[6] = mcp->mb[6]; 1709 mb_ret[7] = mcp->mb[7]; 1710 } 1711 1712 if (rval != QLA_SUCCESS) { 1713 /* AV tmp code: need to change main mailbox_command function to 1714 * return ok even when the mailbox completion value is not 1715 * SUCCESS. The caller needs to be responsible to interpret 1716 * the return values of this mailbox command if we're not 1717 * to change too much of the existing code. 1718 */ 1719 if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006) 1720 rval = QLA_SUCCESS; 1721 1722 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1723 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval, 1724 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1725 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1726 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval, 1727 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1728 } else { 1729 /*EMPTY*/ 1730 DEBUG3(printk("%s(%ld): done.\n", __func__, vha->host_no)); 1731 } 1732 1733 return (rval); 1734 } 1735 1736 int 1737 qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, 1738 uint8_t area, uint8_t al_pa) 1739 { 1740 int rval; 1741 struct logio_entry_24xx *lg; 1742 dma_addr_t lg_dma; 1743 struct qla_hw_data *ha = vha->hw; 1744 1745 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1746 1747 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1748 if (lg == NULL) { 1749 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n", 1750 __func__, vha->host_no)); 1751 return QLA_MEMORY_ALLOC_FAILED; 1752 } 1753 memset(lg, 0, sizeof(struct logio_entry_24xx)); 1754 1755 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; 1756 lg->entry_count = 1; 1757 lg->nport_handle = cpu_to_le16(loop_id); 1758 lg->control_flags = 1759 __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO); 1760 lg->port_id[0] = al_pa; 1761 lg->port_id[1] = area; 1762 lg->port_id[2] = domain; 1763 lg->vp_index = vha->vp_idx; 1764 1765 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0); 1766 if (rval != QLA_SUCCESS) { 1767 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB " 1768 "(%x).\n", __func__, vha->host_no, rval)); 1769 } else if (lg->entry_status != 0) { 1770 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1771 "-- error status (%x).\n", __func__, vha->host_no, 1772 lg->entry_status)); 1773 rval = QLA_FUNCTION_FAILED; 1774 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1775 DEBUG2_3_11(printk("%s(%ld %d): failed to complete IOCB " 1776 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1777 vha->host_no, vha->vp_idx, le16_to_cpu(lg->comp_status), 1778 le32_to_cpu(lg->io_parameter[0]), 1779 le32_to_cpu(lg->io_parameter[1]))); 1780 } else { 1781 /*EMPTY*/ 1782 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 1783 } 1784 1785 dma_pool_free(ha->s_dma_pool, lg, lg_dma); 1786 1787 return rval; 1788 } 1789 1790 /* 1791 * qla2x00_fabric_logout 1792 * Issue logout fabric port mailbox command. 1793 * 1794 * Input: 1795 * ha = adapter block pointer. 1796 * loop_id = device loop ID. 1797 * TARGET_QUEUE_LOCK must be released. 1798 * ADAPTER_STATE_LOCK must be released. 1799 * 1800 * Returns: 1801 * qla2x00 local function return status code. 1802 * 1803 * Context: 1804 * Kernel context. 1805 */ 1806 int 1807 qla2x00_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, 1808 uint8_t area, uint8_t al_pa) 1809 { 1810 int rval; 1811 mbx_cmd_t mc; 1812 mbx_cmd_t *mcp = &mc; 1813 1814 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n", 1815 vha->host_no)); 1816 1817 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; 1818 mcp->out_mb = MBX_1|MBX_0; 1819 if (HAS_EXTENDED_IDS(vha->hw)) { 1820 mcp->mb[1] = loop_id; 1821 mcp->mb[10] = 0; 1822 mcp->out_mb |= MBX_10; 1823 } else { 1824 mcp->mb[1] = loop_id << 8; 1825 } 1826 1827 mcp->in_mb = MBX_1|MBX_0; 1828 mcp->tov = MBX_TOV_SECONDS; 1829 mcp->flags = 0; 1830 rval = qla2x00_mailbox_command(vha, mcp); 1831 1832 if (rval != QLA_SUCCESS) { 1833 /*EMPTY*/ 1834 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x " 1835 "mbx1=%x.\n", vha->host_no, rval, mcp->mb[1])); 1836 } else { 1837 /*EMPTY*/ 1838 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n", 1839 vha->host_no)); 1840 } 1841 1842 return rval; 1843 } 1844 1845 /* 1846 * qla2x00_full_login_lip 1847 * Issue full login LIP mailbox command. 1848 * 1849 * Input: 1850 * ha = adapter block pointer. 1851 * TARGET_QUEUE_LOCK must be released. 1852 * ADAPTER_STATE_LOCK must be released. 1853 * 1854 * Returns: 1855 * qla2x00 local function return status code. 1856 * 1857 * Context: 1858 * Kernel context. 1859 */ 1860 int 1861 qla2x00_full_login_lip(scsi_qla_host_t *vha) 1862 { 1863 int rval; 1864 mbx_cmd_t mc; 1865 mbx_cmd_t *mcp = &mc; 1866 1867 if (IS_QLA81XX(vha->hw)) 1868 return QLA_SUCCESS; 1869 1870 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n", 1871 vha->host_no)); 1872 1873 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1874 mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0; 1875 mcp->mb[2] = 0; 1876 mcp->mb[3] = 0; 1877 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1878 mcp->in_mb = MBX_0; 1879 mcp->tov = MBX_TOV_SECONDS; 1880 mcp->flags = 0; 1881 rval = qla2x00_mailbox_command(vha, mcp); 1882 1883 if (rval != QLA_SUCCESS) { 1884 /*EMPTY*/ 1885 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n", 1886 vha->host_no, rval)); 1887 } else { 1888 /*EMPTY*/ 1889 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n", 1890 vha->host_no)); 1891 } 1892 1893 return rval; 1894 } 1895 1896 /* 1897 * qla2x00_get_id_list 1898 * 1899 * Input: 1900 * ha = adapter block pointer. 1901 * 1902 * Returns: 1903 * qla2x00 local function return status code. 1904 * 1905 * Context: 1906 * Kernel context. 1907 */ 1908 int 1909 qla2x00_get_id_list(scsi_qla_host_t *vha, void *id_list, dma_addr_t id_list_dma, 1910 uint16_t *entries) 1911 { 1912 int rval; 1913 mbx_cmd_t mc; 1914 mbx_cmd_t *mcp = &mc; 1915 1916 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n", 1917 vha->host_no)); 1918 1919 if (id_list == NULL) 1920 return QLA_FUNCTION_FAILED; 1921 1922 mcp->mb[0] = MBC_GET_ID_LIST; 1923 mcp->out_mb = MBX_0; 1924 if (IS_FWI2_CAPABLE(vha->hw)) { 1925 mcp->mb[2] = MSW(id_list_dma); 1926 mcp->mb[3] = LSW(id_list_dma); 1927 mcp->mb[6] = MSW(MSD(id_list_dma)); 1928 mcp->mb[7] = LSW(MSD(id_list_dma)); 1929 mcp->mb[8] = 0; 1930 mcp->mb[9] = vha->vp_idx; 1931 mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2; 1932 } else { 1933 mcp->mb[1] = MSW(id_list_dma); 1934 mcp->mb[2] = LSW(id_list_dma); 1935 mcp->mb[3] = MSW(MSD(id_list_dma)); 1936 mcp->mb[6] = LSW(MSD(id_list_dma)); 1937 mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; 1938 } 1939 mcp->in_mb = MBX_1|MBX_0; 1940 mcp->tov = MBX_TOV_SECONDS; 1941 mcp->flags = 0; 1942 rval = qla2x00_mailbox_command(vha, mcp); 1943 1944 if (rval != QLA_SUCCESS) { 1945 /*EMPTY*/ 1946 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n", 1947 vha->host_no, rval)); 1948 } else { 1949 *entries = mcp->mb[1]; 1950 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n", 1951 vha->host_no)); 1952 } 1953 1954 return rval; 1955 } 1956 1957 /* 1958 * qla2x00_get_resource_cnts 1959 * Get current firmware resource counts. 1960 * 1961 * Input: 1962 * ha = adapter block pointer. 1963 * 1964 * Returns: 1965 * qla2x00 local function return status code. 1966 * 1967 * Context: 1968 * Kernel context. 1969 */ 1970 int 1971 qla2x00_get_resource_cnts(scsi_qla_host_t *vha, uint16_t *cur_xchg_cnt, 1972 uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, 1973 uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports) 1974 { 1975 int rval; 1976 mbx_cmd_t mc; 1977 mbx_cmd_t *mcp = &mc; 1978 1979 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1980 1981 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; 1982 mcp->out_mb = MBX_0; 1983 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1984 mcp->tov = MBX_TOV_SECONDS; 1985 mcp->flags = 0; 1986 rval = qla2x00_mailbox_command(vha, mcp); 1987 1988 if (rval != QLA_SUCCESS) { 1989 /*EMPTY*/ 1990 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__, 1991 vha->host_no, mcp->mb[0])); 1992 } else { 1993 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x " 1994 "mb7=%x mb10=%x mb11=%x.\n", __func__, vha->host_no, 1995 mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7], 1996 mcp->mb[10], mcp->mb[11])); 1997 1998 if (cur_xchg_cnt) 1999 *cur_xchg_cnt = mcp->mb[3]; 2000 if (orig_xchg_cnt) 2001 *orig_xchg_cnt = mcp->mb[6]; 2002 if (cur_iocb_cnt) 2003 *cur_iocb_cnt = mcp->mb[7]; 2004 if (orig_iocb_cnt) 2005 *orig_iocb_cnt = mcp->mb[10]; 2006 if (vha->hw->flags.npiv_supported && max_npiv_vports) 2007 *max_npiv_vports = mcp->mb[11]; 2008 } 2009 2010 return (rval); 2011 } 2012 2013 #if defined(QL_DEBUG_LEVEL_3) 2014 /* 2015 * qla2x00_get_fcal_position_map 2016 * Get FCAL (LILP) position map using mailbox command 2017 * 2018 * Input: 2019 * ha = adapter state pointer. 2020 * pos_map = buffer pointer (can be NULL). 2021 * 2022 * Returns: 2023 * qla2x00 local function return status code. 2024 * 2025 * Context: 2026 * Kernel context. 2027 */ 2028 int 2029 qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map) 2030 { 2031 int rval; 2032 mbx_cmd_t mc; 2033 mbx_cmd_t *mcp = &mc; 2034 char *pmap; 2035 dma_addr_t pmap_dma; 2036 struct qla_hw_data *ha = vha->hw; 2037 2038 pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); 2039 if (pmap == NULL) { 2040 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****", 2041 __func__, vha->host_no)); 2042 return QLA_MEMORY_ALLOC_FAILED; 2043 } 2044 memset(pmap, 0, FCAL_MAP_SIZE); 2045 2046 mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; 2047 mcp->mb[2] = MSW(pmap_dma); 2048 mcp->mb[3] = LSW(pmap_dma); 2049 mcp->mb[6] = MSW(MSD(pmap_dma)); 2050 mcp->mb[7] = LSW(MSD(pmap_dma)); 2051 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2052 mcp->in_mb = MBX_1|MBX_0; 2053 mcp->buf_size = FCAL_MAP_SIZE; 2054 mcp->flags = MBX_DMA_IN; 2055 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 2056 rval = qla2x00_mailbox_command(vha, mcp); 2057 2058 if (rval == QLA_SUCCESS) { 2059 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map " 2060 "size (%x)\n", __func__, vha->host_no, mcp->mb[0], 2061 mcp->mb[1], (unsigned)pmap[0])); 2062 DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1)); 2063 2064 if (pos_map) 2065 memcpy(pos_map, pmap, FCAL_MAP_SIZE); 2066 } 2067 dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); 2068 2069 if (rval != QLA_SUCCESS) { 2070 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2071 vha->host_no, rval)); 2072 } else { 2073 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2074 } 2075 2076 return rval; 2077 } 2078 #endif 2079 2080 /* 2081 * qla2x00_get_link_status 2082 * 2083 * Input: 2084 * ha = adapter block pointer. 2085 * loop_id = device loop ID. 2086 * ret_buf = pointer to link status return buffer. 2087 * 2088 * Returns: 2089 * 0 = success. 2090 * BIT_0 = mem alloc error. 2091 * BIT_1 = mailbox error. 2092 */ 2093 int 2094 qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id, 2095 struct link_statistics *stats, dma_addr_t stats_dma) 2096 { 2097 int rval; 2098 mbx_cmd_t mc; 2099 mbx_cmd_t *mcp = &mc; 2100 uint32_t *siter, *diter, dwords; 2101 struct qla_hw_data *ha = vha->hw; 2102 2103 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2104 2105 mcp->mb[0] = MBC_GET_LINK_STATUS; 2106 mcp->mb[2] = MSW(stats_dma); 2107 mcp->mb[3] = LSW(stats_dma); 2108 mcp->mb[6] = MSW(MSD(stats_dma)); 2109 mcp->mb[7] = LSW(MSD(stats_dma)); 2110 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2111 mcp->in_mb = MBX_0; 2112 if (IS_FWI2_CAPABLE(ha)) { 2113 mcp->mb[1] = loop_id; 2114 mcp->mb[4] = 0; 2115 mcp->mb[10] = 0; 2116 mcp->out_mb |= MBX_10|MBX_4|MBX_1; 2117 mcp->in_mb |= MBX_1; 2118 } else if (HAS_EXTENDED_IDS(ha)) { 2119 mcp->mb[1] = loop_id; 2120 mcp->mb[10] = 0; 2121 mcp->out_mb |= MBX_10|MBX_1; 2122 } else { 2123 mcp->mb[1] = loop_id << 8; 2124 mcp->out_mb |= MBX_1; 2125 } 2126 mcp->tov = MBX_TOV_SECONDS; 2127 mcp->flags = IOCTL_CMD; 2128 rval = qla2x00_mailbox_command(vha, mcp); 2129 2130 if (rval == QLA_SUCCESS) { 2131 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2132 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2133 __func__, vha->host_no, mcp->mb[0])); 2134 rval = QLA_FUNCTION_FAILED; 2135 } else { 2136 /* Copy over data -- firmware data is LE. */ 2137 dwords = offsetof(struct link_statistics, unused1) / 4; 2138 siter = diter = &stats->link_fail_cnt; 2139 while (dwords--) 2140 *diter++ = le32_to_cpu(*siter++); 2141 } 2142 } else { 2143 /* Failed. */ 2144 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2145 vha->host_no, rval)); 2146 } 2147 2148 return rval; 2149 } 2150 2151 int 2152 qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats, 2153 dma_addr_t stats_dma) 2154 { 2155 int rval; 2156 mbx_cmd_t mc; 2157 mbx_cmd_t *mcp = &mc; 2158 uint32_t *siter, *diter, dwords; 2159 2160 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2161 2162 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; 2163 mcp->mb[2] = MSW(stats_dma); 2164 mcp->mb[3] = LSW(stats_dma); 2165 mcp->mb[6] = MSW(MSD(stats_dma)); 2166 mcp->mb[7] = LSW(MSD(stats_dma)); 2167 mcp->mb[8] = sizeof(struct link_statistics) / 4; 2168 mcp->mb[9] = vha->vp_idx; 2169 mcp->mb[10] = 0; 2170 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2171 mcp->in_mb = MBX_2|MBX_1|MBX_0; 2172 mcp->tov = MBX_TOV_SECONDS; 2173 mcp->flags = IOCTL_CMD; 2174 rval = qla2x00_mailbox_command(vha, mcp); 2175 2176 if (rval == QLA_SUCCESS) { 2177 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2178 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2179 __func__, vha->host_no, mcp->mb[0])); 2180 rval = QLA_FUNCTION_FAILED; 2181 } else { 2182 /* Copy over data -- firmware data is LE. */ 2183 dwords = sizeof(struct link_statistics) / 4; 2184 siter = diter = &stats->link_fail_cnt; 2185 while (dwords--) 2186 *diter++ = le32_to_cpu(*siter++); 2187 } 2188 } else { 2189 /* Failed. */ 2190 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2191 vha->host_no, rval)); 2192 } 2193 2194 return rval; 2195 } 2196 2197 int 2198 qla24xx_abort_command(scsi_qla_host_t *vha, srb_t *sp, struct req_que *req) 2199 { 2200 int rval; 2201 fc_port_t *fcport; 2202 unsigned long flags = 0; 2203 2204 struct abort_entry_24xx *abt; 2205 dma_addr_t abt_dma; 2206 uint32_t handle; 2207 struct qla_hw_data *ha = vha->hw; 2208 2209 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2210 2211 fcport = sp->fcport; 2212 2213 spin_lock_irqsave(&ha->hardware_lock, flags); 2214 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2215 if (req->outstanding_cmds[handle] == sp) 2216 break; 2217 } 2218 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2219 if (handle == MAX_OUTSTANDING_COMMANDS) { 2220 /* Command not found. */ 2221 return QLA_FUNCTION_FAILED; 2222 } 2223 2224 abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); 2225 if (abt == NULL) { 2226 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n", 2227 __func__, vha->host_no)); 2228 return QLA_MEMORY_ALLOC_FAILED; 2229 } 2230 memset(abt, 0, sizeof(struct abort_entry_24xx)); 2231 2232 abt->entry_type = ABORT_IOCB_TYPE; 2233 abt->entry_count = 1; 2234 abt->nport_handle = cpu_to_le16(fcport->loop_id); 2235 abt->handle_to_abort = handle; 2236 abt->port_id[0] = fcport->d_id.b.al_pa; 2237 abt->port_id[1] = fcport->d_id.b.area; 2238 abt->port_id[2] = fcport->d_id.b.domain; 2239 abt->vp_index = fcport->vp_idx; 2240 2241 abt->req_que_no = cpu_to_le16(req->id); 2242 2243 rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0); 2244 if (rval != QLA_SUCCESS) { 2245 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n", 2246 __func__, vha->host_no, rval)); 2247 } else if (abt->entry_status != 0) { 2248 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2249 "-- error status (%x).\n", __func__, vha->host_no, 2250 abt->entry_status)); 2251 rval = QLA_FUNCTION_FAILED; 2252 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) { 2253 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2254 "-- completion status (%x).\n", __func__, vha->host_no, 2255 le16_to_cpu(abt->nport_handle))); 2256 rval = QLA_FUNCTION_FAILED; 2257 } else { 2258 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2259 } 2260 2261 dma_pool_free(ha->s_dma_pool, abt, abt_dma); 2262 2263 return rval; 2264 } 2265 2266 struct tsk_mgmt_cmd { 2267 union { 2268 struct tsk_mgmt_entry tsk; 2269 struct sts_entry_24xx sts; 2270 } p; 2271 }; 2272 2273 static int 2274 __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, 2275 unsigned int l) 2276 { 2277 int rval, rval2; 2278 struct tsk_mgmt_cmd *tsk; 2279 dma_addr_t tsk_dma; 2280 scsi_qla_host_t *vha; 2281 struct qla_hw_data *ha; 2282 struct req_que *req; 2283 struct rsp_que *rsp; 2284 2285 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no)); 2286 2287 vha = fcport->vha; 2288 ha = vha->hw; 2289 req = ha->req_q_map[0]; 2290 rsp = ha->rsp_q_map[0]; 2291 tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); 2292 if (tsk == NULL) { 2293 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management " 2294 "IOCB.\n", __func__, vha->host_no)); 2295 return QLA_MEMORY_ALLOC_FAILED; 2296 } 2297 memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); 2298 2299 tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; 2300 tsk->p.tsk.entry_count = 1; 2301 tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); 2302 tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); 2303 tsk->p.tsk.control_flags = cpu_to_le32(type); 2304 tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; 2305 tsk->p.tsk.port_id[1] = fcport->d_id.b.area; 2306 tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; 2307 tsk->p.tsk.vp_index = fcport->vp_idx; 2308 if (type == TCF_LUN_RESET) { 2309 int_to_scsilun(l, &tsk->p.tsk.lun); 2310 host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, 2311 sizeof(tsk->p.tsk.lun)); 2312 } 2313 2314 rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0); 2315 if (rval != QLA_SUCCESS) { 2316 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB " 2317 "(%x).\n", __func__, vha->host_no, name, rval)); 2318 } else if (tsk->p.sts.entry_status != 0) { 2319 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2320 "-- error status (%x).\n", __func__, vha->host_no, 2321 tsk->p.sts.entry_status)); 2322 rval = QLA_FUNCTION_FAILED; 2323 } else if (tsk->p.sts.comp_status != 2324 __constant_cpu_to_le16(CS_COMPLETE)) { 2325 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2326 "-- completion status (%x).\n", __func__, 2327 vha->host_no, le16_to_cpu(tsk->p.sts.comp_status))); 2328 rval = QLA_FUNCTION_FAILED; 2329 } 2330 2331 /* Issue marker IOCB. */ 2332 rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l, 2333 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); 2334 if (rval2 != QLA_SUCCESS) { 2335 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 2336 "(%x).\n", __func__, vha->host_no, rval2)); 2337 } else { 2338 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2339 } 2340 2341 dma_pool_free(ha->s_dma_pool, tsk, tsk_dma); 2342 2343 return rval; 2344 } 2345 2346 int 2347 qla24xx_abort_target(struct fc_port *fcport, unsigned int l) 2348 { 2349 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l); 2350 } 2351 2352 int 2353 qla24xx_lun_reset(struct fc_port *fcport, unsigned int l) 2354 { 2355 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l); 2356 } 2357 2358 int 2359 qla2x00_system_error(scsi_qla_host_t *vha) 2360 { 2361 int rval; 2362 mbx_cmd_t mc; 2363 mbx_cmd_t *mcp = &mc; 2364 struct qla_hw_data *ha = vha->hw; 2365 2366 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) 2367 return QLA_FUNCTION_FAILED; 2368 2369 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2370 2371 mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; 2372 mcp->out_mb = MBX_0; 2373 mcp->in_mb = MBX_0; 2374 mcp->tov = 5; 2375 mcp->flags = 0; 2376 rval = qla2x00_mailbox_command(vha, mcp); 2377 2378 if (rval != QLA_SUCCESS) { 2379 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2380 vha->host_no, rval)); 2381 } else { 2382 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2383 } 2384 2385 return rval; 2386 } 2387 2388 /** 2389 * qla2x00_set_serdes_params() - 2390 * @ha: HA context 2391 * 2392 * Returns 2393 */ 2394 int 2395 qla2x00_set_serdes_params(scsi_qla_host_t *vha, uint16_t sw_em_1g, 2396 uint16_t sw_em_2g, uint16_t sw_em_4g) 2397 { 2398 int rval; 2399 mbx_cmd_t mc; 2400 mbx_cmd_t *mcp = &mc; 2401 2402 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2403 2404 mcp->mb[0] = MBC_SERDES_PARAMS; 2405 mcp->mb[1] = BIT_0; 2406 mcp->mb[2] = sw_em_1g | BIT_15; 2407 mcp->mb[3] = sw_em_2g | BIT_15; 2408 mcp->mb[4] = sw_em_4g | BIT_15; 2409 mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2410 mcp->in_mb = MBX_0; 2411 mcp->tov = MBX_TOV_SECONDS; 2412 mcp->flags = 0; 2413 rval = qla2x00_mailbox_command(vha, mcp); 2414 2415 if (rval != QLA_SUCCESS) { 2416 /*EMPTY*/ 2417 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2418 vha->host_no, rval, mcp->mb[0])); 2419 } else { 2420 /*EMPTY*/ 2421 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2422 } 2423 2424 return rval; 2425 } 2426 2427 int 2428 qla2x00_stop_firmware(scsi_qla_host_t *vha) 2429 { 2430 int rval; 2431 mbx_cmd_t mc; 2432 mbx_cmd_t *mcp = &mc; 2433 2434 if (!IS_FWI2_CAPABLE(vha->hw)) 2435 return QLA_FUNCTION_FAILED; 2436 2437 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2438 2439 mcp->mb[0] = MBC_STOP_FIRMWARE; 2440 mcp->out_mb = MBX_0; 2441 mcp->in_mb = MBX_0; 2442 mcp->tov = 5; 2443 mcp->flags = 0; 2444 rval = qla2x00_mailbox_command(vha, mcp); 2445 2446 if (rval != QLA_SUCCESS) { 2447 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2448 vha->host_no, rval)); 2449 } else { 2450 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2451 } 2452 2453 return rval; 2454 } 2455 2456 int 2457 qla2x00_enable_eft_trace(scsi_qla_host_t *vha, dma_addr_t eft_dma, 2458 uint16_t buffers) 2459 { 2460 int rval; 2461 mbx_cmd_t mc; 2462 mbx_cmd_t *mcp = &mc; 2463 2464 if (!IS_FWI2_CAPABLE(vha->hw)) 2465 return QLA_FUNCTION_FAILED; 2466 2467 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2468 2469 mcp->mb[0] = MBC_TRACE_CONTROL; 2470 mcp->mb[1] = TC_EFT_ENABLE; 2471 mcp->mb[2] = LSW(eft_dma); 2472 mcp->mb[3] = MSW(eft_dma); 2473 mcp->mb[4] = LSW(MSD(eft_dma)); 2474 mcp->mb[5] = MSW(MSD(eft_dma)); 2475 mcp->mb[6] = buffers; 2476 mcp->mb[7] = TC_AEN_DISABLE; 2477 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2478 mcp->in_mb = MBX_1|MBX_0; 2479 mcp->tov = MBX_TOV_SECONDS; 2480 mcp->flags = 0; 2481 rval = qla2x00_mailbox_command(vha, mcp); 2482 if (rval != QLA_SUCCESS) { 2483 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2484 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2485 } else { 2486 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2487 } 2488 2489 return rval; 2490 } 2491 2492 int 2493 qla2x00_disable_eft_trace(scsi_qla_host_t *vha) 2494 { 2495 int rval; 2496 mbx_cmd_t mc; 2497 mbx_cmd_t *mcp = &mc; 2498 2499 if (!IS_FWI2_CAPABLE(vha->hw)) 2500 return QLA_FUNCTION_FAILED; 2501 2502 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2503 2504 mcp->mb[0] = MBC_TRACE_CONTROL; 2505 mcp->mb[1] = TC_EFT_DISABLE; 2506 mcp->out_mb = MBX_1|MBX_0; 2507 mcp->in_mb = MBX_1|MBX_0; 2508 mcp->tov = MBX_TOV_SECONDS; 2509 mcp->flags = 0; 2510 rval = qla2x00_mailbox_command(vha, mcp); 2511 if (rval != QLA_SUCCESS) { 2512 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2513 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2514 } else { 2515 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2516 } 2517 2518 return rval; 2519 } 2520 2521 int 2522 qla2x00_enable_fce_trace(scsi_qla_host_t *vha, dma_addr_t fce_dma, 2523 uint16_t buffers, uint16_t *mb, uint32_t *dwords) 2524 { 2525 int rval; 2526 mbx_cmd_t mc; 2527 mbx_cmd_t *mcp = &mc; 2528 2529 if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw)) 2530 return QLA_FUNCTION_FAILED; 2531 2532 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2533 2534 mcp->mb[0] = MBC_TRACE_CONTROL; 2535 mcp->mb[1] = TC_FCE_ENABLE; 2536 mcp->mb[2] = LSW(fce_dma); 2537 mcp->mb[3] = MSW(fce_dma); 2538 mcp->mb[4] = LSW(MSD(fce_dma)); 2539 mcp->mb[5] = MSW(MSD(fce_dma)); 2540 mcp->mb[6] = buffers; 2541 mcp->mb[7] = TC_AEN_DISABLE; 2542 mcp->mb[8] = 0; 2543 mcp->mb[9] = TC_FCE_DEFAULT_RX_SIZE; 2544 mcp->mb[10] = TC_FCE_DEFAULT_TX_SIZE; 2545 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| 2546 MBX_1|MBX_0; 2547 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2548 mcp->tov = MBX_TOV_SECONDS; 2549 mcp->flags = 0; 2550 rval = qla2x00_mailbox_command(vha, mcp); 2551 if (rval != QLA_SUCCESS) { 2552 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2553 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2554 } else { 2555 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2556 2557 if (mb) 2558 memcpy(mb, mcp->mb, 8 * sizeof(*mb)); 2559 if (dwords) 2560 *dwords = buffers; 2561 } 2562 2563 return rval; 2564 } 2565 2566 int 2567 qla2x00_disable_fce_trace(scsi_qla_host_t *vha, uint64_t *wr, uint64_t *rd) 2568 { 2569 int rval; 2570 mbx_cmd_t mc; 2571 mbx_cmd_t *mcp = &mc; 2572 2573 if (!IS_FWI2_CAPABLE(vha->hw)) 2574 return QLA_FUNCTION_FAILED; 2575 2576 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2577 2578 mcp->mb[0] = MBC_TRACE_CONTROL; 2579 mcp->mb[1] = TC_FCE_DISABLE; 2580 mcp->mb[2] = TC_FCE_DISABLE_TRACE; 2581 mcp->out_mb = MBX_2|MBX_1|MBX_0; 2582 mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| 2583 MBX_1|MBX_0; 2584 mcp->tov = MBX_TOV_SECONDS; 2585 mcp->flags = 0; 2586 rval = qla2x00_mailbox_command(vha, mcp); 2587 if (rval != QLA_SUCCESS) { 2588 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2589 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2590 } else { 2591 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2592 2593 if (wr) 2594 *wr = (uint64_t) mcp->mb[5] << 48 | 2595 (uint64_t) mcp->mb[4] << 32 | 2596 (uint64_t) mcp->mb[3] << 16 | 2597 (uint64_t) mcp->mb[2]; 2598 if (rd) 2599 *rd = (uint64_t) mcp->mb[9] << 48 | 2600 (uint64_t) mcp->mb[8] << 32 | 2601 (uint64_t) mcp->mb[7] << 16 | 2602 (uint64_t) mcp->mb[6]; 2603 } 2604 2605 return rval; 2606 } 2607 2608 int 2609 qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint16_t addr, 2610 uint16_t off, uint16_t count) 2611 { 2612 int rval; 2613 mbx_cmd_t mc; 2614 mbx_cmd_t *mcp = &mc; 2615 2616 if (!IS_FWI2_CAPABLE(vha->hw)) 2617 return QLA_FUNCTION_FAILED; 2618 2619 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2620 2621 mcp->mb[0] = MBC_READ_SFP; 2622 mcp->mb[1] = addr; 2623 mcp->mb[2] = MSW(sfp_dma); 2624 mcp->mb[3] = LSW(sfp_dma); 2625 mcp->mb[6] = MSW(MSD(sfp_dma)); 2626 mcp->mb[7] = LSW(MSD(sfp_dma)); 2627 mcp->mb[8] = count; 2628 mcp->mb[9] = off; 2629 mcp->mb[10] = 0; 2630 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 2631 mcp->in_mb = MBX_0; 2632 mcp->tov = MBX_TOV_SECONDS; 2633 mcp->flags = 0; 2634 rval = qla2x00_mailbox_command(vha, mcp); 2635 2636 if (rval != QLA_SUCCESS) { 2637 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2638 vha->host_no, rval, mcp->mb[0])); 2639 } else { 2640 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2641 } 2642 2643 return rval; 2644 } 2645 2646 int 2647 qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, 2648 uint16_t port_speed, uint16_t *mb) 2649 { 2650 int rval; 2651 mbx_cmd_t mc; 2652 mbx_cmd_t *mcp = &mc; 2653 2654 if (!IS_IIDMA_CAPABLE(vha->hw)) 2655 return QLA_FUNCTION_FAILED; 2656 2657 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2658 2659 mcp->mb[0] = MBC_PORT_PARAMS; 2660 mcp->mb[1] = loop_id; 2661 mcp->mb[2] = BIT_0; 2662 mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); 2663 mcp->mb[4] = mcp->mb[5] = 0; 2664 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2665 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; 2666 mcp->tov = MBX_TOV_SECONDS; 2667 mcp->flags = 0; 2668 rval = qla2x00_mailbox_command(vha, mcp); 2669 2670 /* Return mailbox statuses. */ 2671 if (mb != NULL) { 2672 mb[0] = mcp->mb[0]; 2673 mb[1] = mcp->mb[1]; 2674 mb[3] = mcp->mb[3]; 2675 mb[4] = mcp->mb[4]; 2676 mb[5] = mcp->mb[5]; 2677 } 2678 2679 if (rval != QLA_SUCCESS) { 2680 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2681 vha->host_no, rval)); 2682 } else { 2683 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2684 } 2685 2686 return rval; 2687 } 2688 2689 void 2690 qla24xx_report_id_acquisition(scsi_qla_host_t *vha, 2691 struct vp_rpt_id_entry_24xx *rptid_entry) 2692 { 2693 uint8_t vp_idx; 2694 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); 2695 struct qla_hw_data *ha = vha->hw; 2696 scsi_qla_host_t *vp; 2697 scsi_qla_host_t *tvp; 2698 2699 if (rptid_entry->entry_status != 0) 2700 return; 2701 2702 if (rptid_entry->format == 0) { 2703 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d," 2704 " number of VPs acquired %d\n", __func__, vha->host_no, 2705 MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count))); 2706 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__, 2707 rptid_entry->port_id[2], rptid_entry->port_id[1], 2708 rptid_entry->port_id[0])); 2709 } else if (rptid_entry->format == 1) { 2710 vp_idx = LSB(stat); 2711 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled " 2712 "- status %d - " 2713 "with port id %02x%02x%02x\n", __func__, vha->host_no, 2714 vp_idx, MSB(stat), 2715 rptid_entry->port_id[2], rptid_entry->port_id[1], 2716 rptid_entry->port_id[0])); 2717 if (vp_idx == 0) 2718 return; 2719 2720 if (MSB(stat) == 1) 2721 return; 2722 2723 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) 2724 if (vp_idx == vp->vp_idx) 2725 break; 2726 if (!vp) 2727 return; 2728 2729 vp->d_id.b.domain = rptid_entry->port_id[2]; 2730 vp->d_id.b.area = rptid_entry->port_id[1]; 2731 vp->d_id.b.al_pa = rptid_entry->port_id[0]; 2732 2733 /* 2734 * Cannot configure here as we are still sitting on the 2735 * response queue. Handle it in dpc context. 2736 */ 2737 set_bit(VP_IDX_ACQUIRED, &vp->vp_flags); 2738 set_bit(VP_DPC_NEEDED, &vha->dpc_flags); 2739 2740 qla2xxx_wake_dpc(vha); 2741 } 2742 } 2743 2744 /* 2745 * qla24xx_modify_vp_config 2746 * Change VP configuration for vha 2747 * 2748 * Input: 2749 * vha = adapter block pointer. 2750 * 2751 * Returns: 2752 * qla2xxx local function return status code. 2753 * 2754 * Context: 2755 * Kernel context. 2756 */ 2757 int 2758 qla24xx_modify_vp_config(scsi_qla_host_t *vha) 2759 { 2760 int rval; 2761 struct vp_config_entry_24xx *vpmod; 2762 dma_addr_t vpmod_dma; 2763 struct qla_hw_data *ha = vha->hw; 2764 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 2765 2766 /* This can be called by the parent */ 2767 2768 vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); 2769 if (!vpmod) { 2770 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP " 2771 "IOCB.\n", __func__, vha->host_no)); 2772 return QLA_MEMORY_ALLOC_FAILED; 2773 } 2774 2775 memset(vpmod, 0, sizeof(struct vp_config_entry_24xx)); 2776 vpmod->entry_type = VP_CONFIG_IOCB_TYPE; 2777 vpmod->entry_count = 1; 2778 vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; 2779 vpmod->vp_count = 1; 2780 vpmod->vp_index1 = vha->vp_idx; 2781 vpmod->options_idx1 = BIT_3|BIT_4|BIT_5; 2782 memcpy(vpmod->node_name_idx1, vha->node_name, WWN_SIZE); 2783 memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); 2784 vpmod->entry_count = 1; 2785 2786 rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0); 2787 if (rval != QLA_SUCCESS) { 2788 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB" 2789 "(%x).\n", __func__, base_vha->host_no, rval)); 2790 } else if (vpmod->comp_status != 0) { 2791 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2792 "-- error status (%x).\n", __func__, base_vha->host_no, 2793 vpmod->comp_status)); 2794 rval = QLA_FUNCTION_FAILED; 2795 } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 2796 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2797 "-- completion status (%x).\n", __func__, base_vha->host_no, 2798 le16_to_cpu(vpmod->comp_status))); 2799 rval = QLA_FUNCTION_FAILED; 2800 } else { 2801 /* EMPTY */ 2802 DEBUG11(printk("%s(%ld): done.\n", __func__, 2803 base_vha->host_no)); 2804 fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); 2805 } 2806 dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma); 2807 2808 return rval; 2809 } 2810 2811 /* 2812 * qla24xx_control_vp 2813 * Enable a virtual port for given host 2814 * 2815 * Input: 2816 * ha = adapter block pointer. 2817 * vhba = virtual adapter (unused) 2818 * index = index number for enabled VP 2819 * 2820 * Returns: 2821 * qla2xxx local function return status code. 2822 * 2823 * Context: 2824 * Kernel context. 2825 */ 2826 int 2827 qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) 2828 { 2829 int rval; 2830 int map, pos; 2831 struct vp_ctrl_entry_24xx *vce; 2832 dma_addr_t vce_dma; 2833 struct qla_hw_data *ha = vha->hw; 2834 int vp_index = vha->vp_idx; 2835 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 2836 2837 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__, 2838 vha->host_no, vp_index)); 2839 2840 if (vp_index == 0 || vp_index >= ha->max_npiv_vports) 2841 return QLA_PARAMETER_ERROR; 2842 2843 vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); 2844 if (!vce) { 2845 DEBUG2_3(printk("%s(%ld): " 2846 "failed to allocate VP Control IOCB.\n", __func__, 2847 base_vha->host_no)); 2848 return QLA_MEMORY_ALLOC_FAILED; 2849 } 2850 memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); 2851 2852 vce->entry_type = VP_CTRL_IOCB_TYPE; 2853 vce->entry_count = 1; 2854 vce->command = cpu_to_le16(cmd); 2855 vce->vp_count = __constant_cpu_to_le16(1); 2856 2857 /* index map in firmware starts with 1; decrement index 2858 * this is ok as we never use index 0 2859 */ 2860 map = (vp_index - 1) / 8; 2861 pos = (vp_index - 1) & 7; 2862 mutex_lock(&ha->vport_lock); 2863 vce->vp_idx_map[map] |= 1 << pos; 2864 mutex_unlock(&ha->vport_lock); 2865 2866 rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0); 2867 if (rval != QLA_SUCCESS) { 2868 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB" 2869 "(%x).\n", __func__, base_vha->host_no, rval)); 2870 printk("%s(%ld): failed to issue VP control IOCB" 2871 "(%x).\n", __func__, base_vha->host_no, rval); 2872 } else if (vce->entry_status != 0) { 2873 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2874 "-- error status (%x).\n", __func__, base_vha->host_no, 2875 vce->entry_status)); 2876 printk("%s(%ld): failed to complete IOCB " 2877 "-- error status (%x).\n", __func__, base_vha->host_no, 2878 vce->entry_status); 2879 rval = QLA_FUNCTION_FAILED; 2880 } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 2881 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2882 "-- completion status (%x).\n", __func__, base_vha->host_no, 2883 le16_to_cpu(vce->comp_status))); 2884 printk("%s(%ld): failed to complete IOCB " 2885 "-- completion status (%x).\n", __func__, base_vha->host_no, 2886 le16_to_cpu(vce->comp_status)); 2887 rval = QLA_FUNCTION_FAILED; 2888 } else { 2889 DEBUG2(printk("%s(%ld): done.\n", __func__, base_vha->host_no)); 2890 } 2891 2892 dma_pool_free(ha->s_dma_pool, vce, vce_dma); 2893 2894 return rval; 2895 } 2896 2897 /* 2898 * qla2x00_send_change_request 2899 * Receive or disable RSCN request from fabric controller 2900 * 2901 * Input: 2902 * ha = adapter block pointer 2903 * format = registration format: 2904 * 0 - Reserved 2905 * 1 - Fabric detected registration 2906 * 2 - N_port detected registration 2907 * 3 - Full registration 2908 * FF - clear registration 2909 * vp_idx = Virtual port index 2910 * 2911 * Returns: 2912 * qla2x00 local function return status code. 2913 * 2914 * Context: 2915 * Kernel Context 2916 */ 2917 2918 int 2919 qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format, 2920 uint16_t vp_idx) 2921 { 2922 int rval; 2923 mbx_cmd_t mc; 2924 mbx_cmd_t *mcp = &mc; 2925 2926 /* 2927 * This command is implicitly executed by firmware during login for the 2928 * physical hosts 2929 */ 2930 if (vp_idx == 0) 2931 return QLA_FUNCTION_FAILED; 2932 2933 mcp->mb[0] = MBC_SEND_CHANGE_REQUEST; 2934 mcp->mb[1] = format; 2935 mcp->mb[9] = vp_idx; 2936 mcp->out_mb = MBX_9|MBX_1|MBX_0; 2937 mcp->in_mb = MBX_0|MBX_1; 2938 mcp->tov = MBX_TOV_SECONDS; 2939 mcp->flags = 0; 2940 rval = qla2x00_mailbox_command(vha, mcp); 2941 2942 if (rval == QLA_SUCCESS) { 2943 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2944 rval = BIT_1; 2945 } 2946 } else 2947 rval = BIT_1; 2948 2949 return rval; 2950 } 2951 2952 int 2953 qla2x00_dump_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, 2954 uint32_t size) 2955 { 2956 int rval; 2957 mbx_cmd_t mc; 2958 mbx_cmd_t *mcp = &mc; 2959 2960 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2961 2962 if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) { 2963 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; 2964 mcp->mb[8] = MSW(addr); 2965 mcp->out_mb = MBX_8|MBX_0; 2966 } else { 2967 mcp->mb[0] = MBC_DUMP_RISC_RAM; 2968 mcp->out_mb = MBX_0; 2969 } 2970 mcp->mb[1] = LSW(addr); 2971 mcp->mb[2] = MSW(req_dma); 2972 mcp->mb[3] = LSW(req_dma); 2973 mcp->mb[6] = MSW(MSD(req_dma)); 2974 mcp->mb[7] = LSW(MSD(req_dma)); 2975 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; 2976 if (IS_FWI2_CAPABLE(vha->hw)) { 2977 mcp->mb[4] = MSW(size); 2978 mcp->mb[5] = LSW(size); 2979 mcp->out_mb |= MBX_5|MBX_4; 2980 } else { 2981 mcp->mb[4] = LSW(size); 2982 mcp->out_mb |= MBX_4; 2983 } 2984 2985 mcp->in_mb = MBX_0; 2986 mcp->tov = MBX_TOV_SECONDS; 2987 mcp->flags = 0; 2988 rval = qla2x00_mailbox_command(vha, mcp); 2989 2990 if (rval != QLA_SUCCESS) { 2991 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 2992 vha->host_no, rval, mcp->mb[0])); 2993 } else { 2994 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 2995 } 2996 2997 return rval; 2998 } 2999 3000 /* 84XX Support **************************************************************/ 3001 3002 struct cs84xx_mgmt_cmd { 3003 union { 3004 struct verify_chip_entry_84xx req; 3005 struct verify_chip_rsp_84xx rsp; 3006 } p; 3007 }; 3008 3009 int 3010 qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status) 3011 { 3012 int rval, retry; 3013 struct cs84xx_mgmt_cmd *mn; 3014 dma_addr_t mn_dma; 3015 uint16_t options; 3016 unsigned long flags; 3017 struct qla_hw_data *ha = vha->hw; 3018 3019 DEBUG16(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3020 3021 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); 3022 if (mn == NULL) { 3023 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX " 3024 "IOCB.\n", __func__, vha->host_no)); 3025 return QLA_MEMORY_ALLOC_FAILED; 3026 } 3027 3028 /* Force Update? */ 3029 options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0; 3030 /* Diagnostic firmware? */ 3031 /* options |= MENLO_DIAG_FW; */ 3032 /* We update the firmware with only one data sequence. */ 3033 options |= VCO_END_OF_DATA; 3034 3035 do { 3036 retry = 0; 3037 memset(mn, 0, sizeof(*mn)); 3038 mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE; 3039 mn->p.req.entry_count = 1; 3040 mn->p.req.options = cpu_to_le16(options); 3041 3042 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__, 3043 vha->host_no)); 3044 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn, 3045 sizeof(*mn))); 3046 3047 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); 3048 if (rval != QLA_SUCCESS) { 3049 DEBUG2_16(printk("%s(%ld): failed to issue Verify " 3050 "IOCB (%x).\n", __func__, vha->host_no, rval)); 3051 goto verify_done; 3052 } 3053 3054 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__, 3055 vha->host_no)); 3056 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn, 3057 sizeof(*mn))); 3058 3059 status[0] = le16_to_cpu(mn->p.rsp.comp_status); 3060 status[1] = status[0] == CS_VCS_CHIP_FAILURE ? 3061 le16_to_cpu(mn->p.rsp.failure_code) : 0; 3062 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__, 3063 vha->host_no, status[0], status[1])); 3064 3065 if (status[0] != CS_COMPLETE) { 3066 rval = QLA_FUNCTION_FAILED; 3067 if (!(options & VCO_DONT_UPDATE_FW)) { 3068 DEBUG2_16(printk("%s(%ld): Firmware update " 3069 "failed. Retrying without update " 3070 "firmware.\n", __func__, vha->host_no)); 3071 options |= VCO_DONT_UPDATE_FW; 3072 options &= ~VCO_FORCE_UPDATE; 3073 retry = 1; 3074 } 3075 } else { 3076 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n", 3077 __func__, vha->host_no, 3078 le32_to_cpu(mn->p.rsp.fw_ver))); 3079 3080 /* NOTE: we only update OP firmware. */ 3081 spin_lock_irqsave(&ha->cs84xx->access_lock, flags); 3082 ha->cs84xx->op_fw_version = 3083 le32_to_cpu(mn->p.rsp.fw_ver); 3084 spin_unlock_irqrestore(&ha->cs84xx->access_lock, 3085 flags); 3086 } 3087 } while (retry); 3088 3089 verify_done: 3090 dma_pool_free(ha->s_dma_pool, mn, mn_dma); 3091 3092 if (rval != QLA_SUCCESS) { 3093 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__, 3094 vha->host_no, rval)); 3095 } else { 3096 DEBUG16(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3097 } 3098 3099 return rval; 3100 } 3101 3102 int 3103 qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req) 3104 { 3105 int rval; 3106 unsigned long flags; 3107 mbx_cmd_t mc; 3108 mbx_cmd_t *mcp = &mc; 3109 struct device_reg_25xxmq __iomem *reg; 3110 struct qla_hw_data *ha = vha->hw; 3111 3112 mcp->mb[0] = MBC_INITIALIZE_MULTIQ; 3113 mcp->mb[1] = req->options; 3114 mcp->mb[2] = MSW(LSD(req->dma)); 3115 mcp->mb[3] = LSW(LSD(req->dma)); 3116 mcp->mb[6] = MSW(MSD(req->dma)); 3117 mcp->mb[7] = LSW(MSD(req->dma)); 3118 mcp->mb[5] = req->length; 3119 if (req->rsp) 3120 mcp->mb[10] = req->rsp->id; 3121 mcp->mb[12] = req->qos; 3122 mcp->mb[11] = req->vp_idx; 3123 mcp->mb[13] = req->rid; 3124 3125 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) + 3126 QLA_QUE_PAGE * req->id); 3127 3128 mcp->mb[4] = req->id; 3129 /* que in ptr index */ 3130 mcp->mb[8] = 0; 3131 /* que out ptr index */ 3132 mcp->mb[9] = 0; 3133 mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7| 3134 MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 3135 mcp->in_mb = MBX_0; 3136 mcp->flags = MBX_DMA_OUT; 3137 mcp->tov = 60; 3138 3139 spin_lock_irqsave(&ha->hardware_lock, flags); 3140 if (!(req->options & BIT_0)) { 3141 WRT_REG_DWORD(®->req_q_in, 0); 3142 WRT_REG_DWORD(®->req_q_out, 0); 3143 } 3144 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3145 3146 rval = qla2x00_mailbox_command(vha, mcp); 3147 if (rval != QLA_SUCCESS) 3148 DEBUG2_3_11(printk(KERN_WARNING "%s(%ld): failed=%x mb0=%x.\n", 3149 __func__, vha->host_no, rval, mcp->mb[0])); 3150 return rval; 3151 } 3152 3153 int 3154 qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) 3155 { 3156 int rval; 3157 unsigned long flags; 3158 mbx_cmd_t mc; 3159 mbx_cmd_t *mcp = &mc; 3160 struct device_reg_25xxmq __iomem *reg; 3161 struct qla_hw_data *ha = vha->hw; 3162 3163 mcp->mb[0] = MBC_INITIALIZE_MULTIQ; 3164 mcp->mb[1] = rsp->options; 3165 mcp->mb[2] = MSW(LSD(rsp->dma)); 3166 mcp->mb[3] = LSW(LSD(rsp->dma)); 3167 mcp->mb[6] = MSW(MSD(rsp->dma)); 3168 mcp->mb[7] = LSW(MSD(rsp->dma)); 3169 mcp->mb[5] = rsp->length; 3170 mcp->mb[11] = rsp->vp_idx; 3171 mcp->mb[14] = rsp->msix->entry; 3172 mcp->mb[13] = rsp->rid; 3173 3174 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) + 3175 QLA_QUE_PAGE * rsp->id); 3176 3177 mcp->mb[4] = rsp->id; 3178 /* que in ptr index */ 3179 mcp->mb[8] = 0; 3180 /* que out ptr index */ 3181 mcp->mb[9] = 0; 3182 mcp->out_mb = MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7 3183 |MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 3184 mcp->in_mb = MBX_0; 3185 mcp->flags = MBX_DMA_OUT; 3186 mcp->tov = 60; 3187 3188 spin_lock_irqsave(&ha->hardware_lock, flags); 3189 if (!(rsp->options & BIT_0)) { 3190 WRT_REG_DWORD(®->rsp_q_out, 0); 3191 WRT_REG_DWORD(®->rsp_q_in, 0); 3192 } 3193 3194 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3195 3196 rval = qla2x00_mailbox_command(vha, mcp); 3197 if (rval != QLA_SUCCESS) 3198 DEBUG2_3_11(printk(KERN_WARNING "%s(%ld): failed=%x " 3199 "mb0=%x.\n", __func__, 3200 vha->host_no, rval, mcp->mb[0])); 3201 return rval; 3202 } 3203 3204 int 3205 qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) 3206 { 3207 int rval; 3208 mbx_cmd_t mc; 3209 mbx_cmd_t *mcp = &mc; 3210 3211 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3212 3213 mcp->mb[0] = MBC_IDC_ACK; 3214 memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); 3215 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 3216 mcp->in_mb = MBX_0; 3217 mcp->tov = MBX_TOV_SECONDS; 3218 mcp->flags = 0; 3219 rval = qla2x00_mailbox_command(vha, mcp); 3220 3221 if (rval != QLA_SUCCESS) { 3222 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 3223 vha->host_no, rval, mcp->mb[0])); 3224 } else { 3225 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3226 } 3227 3228 return rval; 3229 } 3230 3231 int 3232 qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) 3233 { 3234 int rval; 3235 mbx_cmd_t mc; 3236 mbx_cmd_t *mcp = &mc; 3237 3238 if (!IS_QLA81XX(vha->hw)) 3239 return QLA_FUNCTION_FAILED; 3240 3241 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3242 3243 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; 3244 mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; 3245 mcp->out_mb = MBX_1|MBX_0; 3246 mcp->in_mb = MBX_1|MBX_0; 3247 mcp->tov = MBX_TOV_SECONDS; 3248 mcp->flags = 0; 3249 rval = qla2x00_mailbox_command(vha, mcp); 3250 3251 if (rval != QLA_SUCCESS) { 3252 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 3253 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 3254 } else { 3255 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3256 *sector_size = mcp->mb[1]; 3257 } 3258 3259 return rval; 3260 } 3261 3262 int 3263 qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) 3264 { 3265 int rval; 3266 mbx_cmd_t mc; 3267 mbx_cmd_t *mcp = &mc; 3268 3269 if (!IS_QLA81XX(vha->hw)) 3270 return QLA_FUNCTION_FAILED; 3271 3272 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3273 3274 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; 3275 mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : 3276 FAC_OPT_CMD_WRITE_PROTECT; 3277 mcp->out_mb = MBX_1|MBX_0; 3278 mcp->in_mb = MBX_1|MBX_0; 3279 mcp->tov = MBX_TOV_SECONDS; 3280 mcp->flags = 0; 3281 rval = qla2x00_mailbox_command(vha, mcp); 3282 3283 if (rval != QLA_SUCCESS) { 3284 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 3285 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 3286 } else { 3287 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3288 } 3289 3290 return rval; 3291 } 3292 3293 int 3294 qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) 3295 { 3296 int rval; 3297 mbx_cmd_t mc; 3298 mbx_cmd_t *mcp = &mc; 3299 3300 if (!IS_QLA81XX(vha->hw)) 3301 return QLA_FUNCTION_FAILED; 3302 3303 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3304 3305 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; 3306 mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; 3307 mcp->mb[2] = LSW(start); 3308 mcp->mb[3] = MSW(start); 3309 mcp->mb[4] = LSW(finish); 3310 mcp->mb[5] = MSW(finish); 3311 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 3312 mcp->in_mb = MBX_2|MBX_1|MBX_0; 3313 mcp->tov = MBX_TOV_SECONDS; 3314 mcp->flags = 0; 3315 rval = qla2x00_mailbox_command(vha, mcp); 3316 3317 if (rval != QLA_SUCCESS) { 3318 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 3319 "mb[2]=%x.\n", __func__, vha->host_no, rval, mcp->mb[0], 3320 mcp->mb[1], mcp->mb[2])); 3321 } else { 3322 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3323 } 3324 3325 return rval; 3326 } 3327 3328 int 3329 qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) 3330 { 3331 int rval = 0; 3332 mbx_cmd_t mc; 3333 mbx_cmd_t *mcp = &mc; 3334 3335 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3336 3337 mcp->mb[0] = MBC_RESTART_MPI_FW; 3338 mcp->out_mb = MBX_0; 3339 mcp->in_mb = MBX_0|MBX_1; 3340 mcp->tov = MBX_TOV_SECONDS; 3341 mcp->flags = 0; 3342 rval = qla2x00_mailbox_command(vha, mcp); 3343 3344 if (rval != QLA_SUCCESS) { 3345 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n", 3346 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); 3347 } else { 3348 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3349 } 3350 3351 return rval; 3352 } 3353 3354 int 3355 qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr, 3356 dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt) 3357 { 3358 int rval; 3359 mbx_cmd_t mc; 3360 mbx_cmd_t *mcp = &mc; 3361 3362 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3363 3364 mcp->mb[0] = MBC_READ_SFP; 3365 mcp->mb[1] = dev; 3366 mcp->mb[2] = MSW(sfp_dma); 3367 mcp->mb[3] = LSW(sfp_dma); 3368 mcp->mb[6] = MSW(MSD(sfp_dma)); 3369 mcp->mb[7] = LSW(MSD(sfp_dma)); 3370 mcp->mb[8] = len; 3371 mcp->mb[9] = adr; 3372 mcp->mb[10] = opt; 3373 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 3374 mcp->in_mb = MBX_0; 3375 mcp->tov = MBX_TOV_SECONDS; 3376 mcp->flags = 0; 3377 rval = qla2x00_mailbox_command(vha, mcp); 3378 3379 if (opt & BIT_0) 3380 if (sfp) 3381 *sfp = mcp->mb[8]; 3382 3383 if (rval != QLA_SUCCESS) { 3384 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 3385 vha->host_no, rval, mcp->mb[0])); 3386 } else { 3387 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 3388 } 3389 3390 return rval; 3391 } 3392 3393 int 3394 qla2x00_write_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr, 3395 dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt) 3396 { 3397 int rval; 3398 mbx_cmd_t mc; 3399 mbx_cmd_t *mcp = &mc; 3400 3401 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3402 3403 if (opt & BIT_0) 3404 if (sfp) 3405 len = *sfp; 3406 3407 mcp->mb[0] = MBC_WRITE_SFP; 3408 mcp->mb[1] = dev; 3409 mcp->mb[2] = MSW(sfp_dma); 3410 mcp->mb[3] = LSW(sfp_dma); 3411 mcp->mb[6] = MSW(MSD(sfp_dma)); 3412 mcp->mb[7] = LSW(MSD(sfp_dma)); 3413 mcp->mb[8] = len; 3414 mcp->mb[9] = adr; 3415 mcp->mb[10] = opt; 3416 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 3417 mcp->in_mb = MBX_0; 3418 mcp->tov = MBX_TOV_SECONDS; 3419 mcp->flags = 0; 3420 rval = qla2x00_mailbox_command(vha, mcp); 3421 3422 if (rval != QLA_SUCCESS) { 3423 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 3424 vha->host_no, rval, mcp->mb[0])); 3425 } else { 3426 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); 3427 } 3428 3429 return rval; 3430 } 3431