| .. | .. |
|---|
| 1 | 1 | /******************************************************************* |
|---|
| 2 | 2 | * This file is part of the Emulex Linux Device Driver for * |
|---|
| 3 | 3 | * Fibre Channel Host Bus Adapters. * |
|---|
| 4 | | - * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term * |
|---|
| 4 | + * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term * |
|---|
| 5 | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
|---|
| 6 | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
|---|
| 7 | 7 | * EMULEX and SLI are trademarks of Emulex. * |
|---|
| .. | .. |
|---|
| 138 | 138 | * Grab buffer pointer and clear context1 so we can use |
|---|
| 139 | 139 | * lpfc_sli_issue_box_wait |
|---|
| 140 | 140 | */ |
|---|
| 141 | | - mp = (struct lpfc_dmabuf *) pmb->context1; |
|---|
| 142 | | - pmb->context1 = NULL; |
|---|
| 141 | + mp = (struct lpfc_dmabuf *)pmb->ctx_buf; |
|---|
| 142 | + pmb->ctx_buf = NULL; |
|---|
| 143 | 143 | |
|---|
| 144 | 144 | pmb->vport = vport; |
|---|
| 145 | 145 | rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2); |
|---|
| 146 | 146 | if (rc != MBX_SUCCESS) { |
|---|
| 147 | 147 | if (signal_pending(current)) { |
|---|
| 148 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT | LOG_VPORT, |
|---|
| 148 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 149 | 149 | "1830 Signal aborted mbxCmd x%x\n", |
|---|
| 150 | 150 | mb->mbxCommand); |
|---|
| 151 | 151 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
|---|
| .. | .. |
|---|
| 154 | 154 | mempool_free(pmb, phba->mbox_mem_pool); |
|---|
| 155 | 155 | return -EINTR; |
|---|
| 156 | 156 | } else { |
|---|
| 157 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT | LOG_VPORT, |
|---|
| 157 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 158 | 158 | "1818 VPort failed init, mbxCmd x%x " |
|---|
| 159 | 159 | "READ_SPARM mbxStatus x%x, rc = x%x\n", |
|---|
| 160 | 160 | mb->mbxCommand, mb->mbxStatus, rc); |
|---|
| .. | .. |
|---|
| 190 | 190 | ((wwn->u.wwn[0] & 0xf) != 0 || (wwn->u.wwn[1] & 0xf) != 0))) |
|---|
| 191 | 191 | return 1; |
|---|
| 192 | 192 | |
|---|
| 193 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 193 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 194 | 194 | "1822 Invalid %s: %02x:%02x:%02x:%02x:" |
|---|
| 195 | 195 | "%02x:%02x:%02x:%02x\n", |
|---|
| 196 | 196 | name_type, |
|---|
| .. | .. |
|---|
| 207 | 207 | struct lpfc_vport *vport; |
|---|
| 208 | 208 | unsigned long flags; |
|---|
| 209 | 209 | |
|---|
| 210 | | - spin_lock_irqsave(&phba->hbalock, flags); |
|---|
| 210 | + spin_lock_irqsave(&phba->port_list_lock, flags); |
|---|
| 211 | 211 | list_for_each_entry(vport, &phba->port_list, listentry) { |
|---|
| 212 | 212 | if (vport == new_vport) |
|---|
| 213 | 213 | continue; |
|---|
| .. | .. |
|---|
| 215 | 215 | if (memcmp(&vport->fc_sparam.portName, |
|---|
| 216 | 216 | &new_vport->fc_sparam.portName, |
|---|
| 217 | 217 | sizeof(struct lpfc_name)) == 0) { |
|---|
| 218 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
|---|
| 218 | + spin_unlock_irqrestore(&phba->port_list_lock, flags); |
|---|
| 219 | 219 | return 0; |
|---|
| 220 | 220 | } |
|---|
| 221 | 221 | } |
|---|
| 222 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
|---|
| 222 | + spin_unlock_irqrestore(&phba->port_list_lock, flags); |
|---|
| 223 | 223 | return 1; |
|---|
| 224 | 224 | } |
|---|
| 225 | 225 | |
|---|
| .. | .. |
|---|
| 284 | 284 | } |
|---|
| 285 | 285 | |
|---|
| 286 | 286 | if (time_after(jiffies, wait_time_max)) |
|---|
| 287 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 288 | | - "1835 Vport discovery quiesce failed:" |
|---|
| 289 | | - " state x%x fc_flags x%x wait msecs x%x\n", |
|---|
| 290 | | - vport->port_state, vport->fc_flag, |
|---|
| 291 | | - jiffies_to_msecs(jiffies - start_time)); |
|---|
| 287 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 288 | + "1835 Vport discovery quiesce failed:" |
|---|
| 289 | + " state x%x fc_flags x%x wait msecs x%x\n", |
|---|
| 290 | + vport->port_state, vport->fc_flag, |
|---|
| 291 | + jiffies_to_msecs(jiffies - start_time)); |
|---|
| 292 | 292 | } |
|---|
| 293 | 293 | |
|---|
| 294 | 294 | int |
|---|
| .. | .. |
|---|
| 305 | 305 | int status; |
|---|
| 306 | 306 | |
|---|
| 307 | 307 | if ((phba->sli_rev < 3) || !(phba->cfg_enable_npiv)) { |
|---|
| 308 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 308 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 309 | 309 | "1808 Create VPORT failed: " |
|---|
| 310 | 310 | "NPIV is not enabled: SLImode:%d\n", |
|---|
| 311 | 311 | phba->sli_rev); |
|---|
| .. | .. |
|---|
| 313 | 313 | goto error_out; |
|---|
| 314 | 314 | } |
|---|
| 315 | 315 | |
|---|
| 316 | | - /* NPIV is not supported if HBA has NVME enabled */ |
|---|
| 317 | | - if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { |
|---|
| 318 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 316 | + /* NPIV is not supported if HBA has NVME Target enabled */ |
|---|
| 317 | + if (phba->nvmet_support) { |
|---|
| 318 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 319 | 319 | "3189 Create VPORT failed: " |
|---|
| 320 | | - "NPIV is not supported on NVME\n"); |
|---|
| 320 | + "NPIV is not supported on NVME Target\n"); |
|---|
| 321 | 321 | rc = VPORT_INVAL; |
|---|
| 322 | 322 | goto error_out; |
|---|
| 323 | 323 | } |
|---|
| 324 | 324 | |
|---|
| 325 | 325 | vpi = lpfc_alloc_vpi(phba); |
|---|
| 326 | 326 | if (vpi == 0) { |
|---|
| 327 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 327 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 328 | 328 | "1809 Create VPORT failed: " |
|---|
| 329 | 329 | "Max VPORTs (%d) exceeded\n", |
|---|
| 330 | 330 | phba->max_vpi); |
|---|
| .. | .. |
|---|
| 334 | 334 | |
|---|
| 335 | 335 | /* Assign an unused board number */ |
|---|
| 336 | 336 | if ((instance = lpfc_get_instance()) < 0) { |
|---|
| 337 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 337 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 338 | 338 | "1810 Create VPORT failed: Cannot get " |
|---|
| 339 | 339 | "instance number\n"); |
|---|
| 340 | 340 | lpfc_free_vpi(phba, vpi); |
|---|
| .. | .. |
|---|
| 344 | 344 | |
|---|
| 345 | 345 | vport = lpfc_create_port(phba, instance, &fc_vport->dev); |
|---|
| 346 | 346 | if (!vport) { |
|---|
| 347 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 347 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 348 | 348 | "1811 Create VPORT failed: vpi x%x\n", vpi); |
|---|
| 349 | 349 | lpfc_free_vpi(phba, vpi); |
|---|
| 350 | 350 | rc = VPORT_NORESOURCES; |
|---|
| .. | .. |
|---|
| 356 | 356 | |
|---|
| 357 | 357 | if ((status = lpfc_vport_sparm(phba, vport))) { |
|---|
| 358 | 358 | if (status == -EINTR) { |
|---|
| 359 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 359 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 360 | 360 | "1831 Create VPORT Interrupted.\n"); |
|---|
| 361 | 361 | rc = VPORT_ERROR; |
|---|
| 362 | 362 | } else { |
|---|
| 363 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 363 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 364 | 364 | "1813 Create VPORT failed. " |
|---|
| 365 | 365 | "Cannot get sparam\n"); |
|---|
| 366 | 366 | rc = VPORT_NORESOURCES; |
|---|
| .. | .. |
|---|
| 378 | 378 | |
|---|
| 379 | 379 | if (!lpfc_valid_wwn_format(phba, &vport->fc_sparam.nodeName, "WWNN") || |
|---|
| 380 | 380 | !lpfc_valid_wwn_format(phba, &vport->fc_sparam.portName, "WWPN")) { |
|---|
| 381 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 381 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 382 | 382 | "1821 Create VPORT failed. " |
|---|
| 383 | 383 | "Invalid WWN format\n"); |
|---|
| 384 | 384 | lpfc_free_vpi(phba, vpi); |
|---|
| .. | .. |
|---|
| 388 | 388 | } |
|---|
| 389 | 389 | |
|---|
| 390 | 390 | if (!lpfc_unique_wwpn(phba, vport)) { |
|---|
| 391 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 391 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 392 | 392 | "1823 Create VPORT failed. " |
|---|
| 393 | 393 | "Duplicate WWN on HBA\n"); |
|---|
| 394 | 394 | lpfc_free_vpi(phba, vpi); |
|---|
| .. | .. |
|---|
| 403 | 403 | /* Set the DFT_LUN_Q_DEPTH accordingly */ |
|---|
| 404 | 404 | vport->cfg_lun_queue_depth = phba->pport->cfg_lun_queue_depth; |
|---|
| 405 | 405 | |
|---|
| 406 | + /* Only the physical port can support NVME for now */ |
|---|
| 407 | + vport->cfg_enable_fc4_type = LPFC_ENABLE_FCP; |
|---|
| 408 | + |
|---|
| 406 | 409 | *(struct lpfc_vport **)fc_vport->dd_data = vport; |
|---|
| 407 | 410 | vport->fc_vport = fc_vport; |
|---|
| 408 | 411 | |
|---|
| .. | .. |
|---|
| 415 | 418 | vport->fdmi_port_mask = phba->pport->fdmi_port_mask; |
|---|
| 416 | 419 | } |
|---|
| 417 | 420 | |
|---|
| 418 | | - if ((phba->nvmet_support == 0) && |
|---|
| 419 | | - ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) || |
|---|
| 420 | | - (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))) { |
|---|
| 421 | | - /* Create NVME binding with nvme_fc_transport. This |
|---|
| 422 | | - * ensures the vport is initialized. |
|---|
| 423 | | - */ |
|---|
| 424 | | - rc = lpfc_nvme_create_localport(vport); |
|---|
| 425 | | - if (rc) { |
|---|
| 426 | | - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
|---|
| 427 | | - "6003 %s status x%x\n", |
|---|
| 428 | | - "NVME registration failed, ", |
|---|
| 429 | | - rc); |
|---|
| 430 | | - goto error_out; |
|---|
| 431 | | - } |
|---|
| 432 | | - } |
|---|
| 433 | | - |
|---|
| 434 | 421 | /* |
|---|
| 435 | 422 | * In SLI4, the vpi must be activated before it can be used |
|---|
| 436 | 423 | * by the port. |
|---|
| .. | .. |
|---|
| 439 | 426 | (pport->fc_flag & FC_VFI_REGISTERED)) { |
|---|
| 440 | 427 | rc = lpfc_sli4_init_vpi(vport); |
|---|
| 441 | 428 | if (rc) { |
|---|
| 442 | | - lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, |
|---|
| 429 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 443 | 430 | "1838 Failed to INIT_VPI on vpi %d " |
|---|
| 444 | 431 | "status %d\n", vpi, rc); |
|---|
| 445 | 432 | rc = VPORT_NORESOURCES; |
|---|
| .. | .. |
|---|
| 482 | 469 | lpfc_initial_fdisc(vport); |
|---|
| 483 | 470 | } else { |
|---|
| 484 | 471 | lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); |
|---|
| 485 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
|---|
| 472 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 486 | 473 | "0262 No NPIV Fabric support\n"); |
|---|
| 487 | 474 | } |
|---|
| 488 | 475 | } else { |
|---|
| .. | .. |
|---|
| 491 | 478 | rc = VPORT_OK; |
|---|
| 492 | 479 | |
|---|
| 493 | 480 | out: |
|---|
| 494 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 495 | | - "1825 Vport Created.\n"); |
|---|
| 481 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 482 | + "1825 Vport Created.\n"); |
|---|
| 496 | 483 | lpfc_host_attrib_init(lpfc_shost_from_vport(vport)); |
|---|
| 497 | 484 | error_out: |
|---|
| 498 | 485 | return rc; |
|---|
| .. | .. |
|---|
| 540 | 527 | * scsi_host_put() to release the vport. |
|---|
| 541 | 528 | */ |
|---|
| 542 | 529 | lpfc_mbx_unreg_vpi(vport); |
|---|
| 543 | | - spin_lock_irq(shost->host_lock); |
|---|
| 544 | | - vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
|---|
| 545 | | - spin_unlock_irq(shost->host_lock); |
|---|
| 530 | + if (phba->sli_rev == LPFC_SLI_REV4) { |
|---|
| 531 | + spin_lock_irq(shost->host_lock); |
|---|
| 532 | + vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
|---|
| 533 | + spin_unlock_irq(shost->host_lock); |
|---|
| 534 | + } |
|---|
| 546 | 535 | |
|---|
| 547 | 536 | lpfc_vport_set_state(vport, FC_VPORT_DISABLED); |
|---|
| 548 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 537 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 549 | 538 | "1826 Vport Disabled.\n"); |
|---|
| 550 | 539 | return VPORT_OK; |
|---|
| 551 | 540 | } |
|---|
| .. | .. |
|---|
| 586 | 575 | lpfc_initial_fdisc(vport); |
|---|
| 587 | 576 | } else { |
|---|
| 588 | 577 | lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); |
|---|
| 589 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
|---|
| 578 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 590 | 579 | "0264 No NPIV Fabric support\n"); |
|---|
| 591 | 580 | } |
|---|
| 592 | 581 | } else { |
|---|
| .. | .. |
|---|
| 594 | 583 | } |
|---|
| 595 | 584 | |
|---|
| 596 | 585 | out: |
|---|
| 597 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 586 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 598 | 587 | "1827 Vport Enabled.\n"); |
|---|
| 599 | 588 | return VPORT_OK; |
|---|
| 600 | 589 | } |
|---|
| .. | .. |
|---|
| 620 | 609 | bool ns_ndlp_referenced = false; |
|---|
| 621 | 610 | |
|---|
| 622 | 611 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
|---|
| 623 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 612 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 624 | 613 | "1812 vport_delete failed: Cannot delete " |
|---|
| 625 | 614 | "physical host\n"); |
|---|
| 626 | 615 | return VPORT_ERROR; |
|---|
| .. | .. |
|---|
| 629 | 618 | /* If the vport is a static vport fail the deletion. */ |
|---|
| 630 | 619 | if ((vport->vport_flag & STATIC_VPORT) && |
|---|
| 631 | 620 | !(phba->pport->load_flag & FC_UNLOADING)) { |
|---|
| 632 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 621 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 633 | 622 | "1837 vport_delete failed: Cannot delete " |
|---|
| 634 | 623 | "static vport.\n"); |
|---|
| 635 | 624 | return VPORT_ERROR; |
|---|
| .. | .. |
|---|
| 815 | 804 | |
|---|
| 816 | 805 | lpfc_free_vpi(phba, vport->vpi); |
|---|
| 817 | 806 | vport->work_port_events = 0; |
|---|
| 818 | | - spin_lock_irq(&phba->hbalock); |
|---|
| 807 | + spin_lock_irq(&phba->port_list_lock); |
|---|
| 819 | 808 | list_del_init(&vport->listentry); |
|---|
| 820 | | - spin_unlock_irq(&phba->hbalock); |
|---|
| 821 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, |
|---|
| 809 | + spin_unlock_irq(&phba->port_list_lock); |
|---|
| 810 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
|---|
| 822 | 811 | "1828 Vport Deleted.\n"); |
|---|
| 823 | 812 | scsi_host_put(shost); |
|---|
| 824 | 813 | return VPORT_OK; |
|---|
| .. | .. |
|---|
| 834 | 823 | GFP_KERNEL); |
|---|
| 835 | 824 | if (vports == NULL) |
|---|
| 836 | 825 | return NULL; |
|---|
| 837 | | - spin_lock_irq(&phba->hbalock); |
|---|
| 826 | + spin_lock_irq(&phba->port_list_lock); |
|---|
| 838 | 827 | list_for_each_entry(port_iterator, &phba->port_list, listentry) { |
|---|
| 839 | 828 | if (port_iterator->load_flag & FC_UNLOADING) |
|---|
| 840 | 829 | continue; |
|---|
| 841 | 830 | if (!scsi_host_get(lpfc_shost_from_vport(port_iterator))) { |
|---|
| 842 | | - lpfc_printf_vlog(port_iterator, KERN_ERR, LOG_VPORT, |
|---|
| 831 | + lpfc_printf_vlog(port_iterator, KERN_ERR, |
|---|
| 832 | + LOG_TRACE_EVENT, |
|---|
| 843 | 833 | "1801 Create vport work array FAILED: " |
|---|
| 844 | 834 | "cannot do scsi_host_get\n"); |
|---|
| 845 | 835 | continue; |
|---|
| 846 | 836 | } |
|---|
| 847 | 837 | vports[index++] = port_iterator; |
|---|
| 848 | 838 | } |
|---|
| 849 | | - spin_unlock_irq(&phba->hbalock); |
|---|
| 839 | + spin_unlock_irq(&phba->port_list_lock); |
|---|
| 850 | 840 | return vports; |
|---|
| 851 | 841 | } |
|---|
| 852 | 842 | |
|---|
| .. | .. |
|---|
| 909 | 899 | GFP_ATOMIC); |
|---|
| 910 | 900 | |
|---|
| 911 | 901 | if (!ndlp->lat_data) |
|---|
| 912 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE, |
|---|
| 902 | + lpfc_printf_vlog(vport, KERN_ERR, |
|---|
| 903 | + LOG_TRACE_EVENT, |
|---|
| 913 | 904 | "0287 lpfc_alloc_bucket failed to " |
|---|
| 914 | 905 | "allocate statistical data buffer DID " |
|---|
| 915 | 906 | "0x%x\n", ndlp->nlp_DID); |
|---|