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