forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/scsi/lpfc/lpfc_vport.c
....@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * 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 *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
....@@ -138,14 +138,14 @@
138138 * Grab buffer pointer and clear context1 so we can use
139139 * lpfc_sli_issue_box_wait
140140 */
141
- mp = (struct lpfc_dmabuf *) pmb->context1;
142
- pmb->context1 = NULL;
141
+ mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
142
+ pmb->ctx_buf = NULL;
143143
144144 pmb->vport = vport;
145145 rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2);
146146 if (rc != MBX_SUCCESS) {
147147 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,
149149 "1830 Signal aborted mbxCmd x%x\n",
150150 mb->mbxCommand);
151151 lpfc_mbuf_free(phba, mp->virt, mp->phys);
....@@ -154,7 +154,7 @@
154154 mempool_free(pmb, phba->mbox_mem_pool);
155155 return -EINTR;
156156 } else {
157
- lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT | LOG_VPORT,
157
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
158158 "1818 VPort failed init, mbxCmd x%x "
159159 "READ_SPARM mbxStatus x%x, rc = x%x\n",
160160 mb->mbxCommand, mb->mbxStatus, rc);
....@@ -190,7 +190,7 @@
190190 ((wwn->u.wwn[0] & 0xf) != 0 || (wwn->u.wwn[1] & 0xf) != 0)))
191191 return 1;
192192
193
- lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
193
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
194194 "1822 Invalid %s: %02x:%02x:%02x:%02x:"
195195 "%02x:%02x:%02x:%02x\n",
196196 name_type,
....@@ -207,7 +207,7 @@
207207 struct lpfc_vport *vport;
208208 unsigned long flags;
209209
210
- spin_lock_irqsave(&phba->hbalock, flags);
210
+ spin_lock_irqsave(&phba->port_list_lock, flags);
211211 list_for_each_entry(vport, &phba->port_list, listentry) {
212212 if (vport == new_vport)
213213 continue;
....@@ -215,11 +215,11 @@
215215 if (memcmp(&vport->fc_sparam.portName,
216216 &new_vport->fc_sparam.portName,
217217 sizeof(struct lpfc_name)) == 0) {
218
- spin_unlock_irqrestore(&phba->hbalock, flags);
218
+ spin_unlock_irqrestore(&phba->port_list_lock, flags);
219219 return 0;
220220 }
221221 }
222
- spin_unlock_irqrestore(&phba->hbalock, flags);
222
+ spin_unlock_irqrestore(&phba->port_list_lock, flags);
223223 return 1;
224224 }
225225
....@@ -284,11 +284,11 @@
284284 }
285285
286286 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));
292292 }
293293
294294 int
....@@ -305,7 +305,7 @@
305305 int status;
306306
307307 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,
309309 "1808 Create VPORT failed: "
310310 "NPIV is not enabled: SLImode:%d\n",
311311 phba->sli_rev);
....@@ -313,18 +313,18 @@
313313 goto error_out;
314314 }
315315
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,
319319 "3189 Create VPORT failed: "
320
- "NPIV is not supported on NVME\n");
320
+ "NPIV is not supported on NVME Target\n");
321321 rc = VPORT_INVAL;
322322 goto error_out;
323323 }
324324
325325 vpi = lpfc_alloc_vpi(phba);
326326 if (vpi == 0) {
327
- lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
327
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
328328 "1809 Create VPORT failed: "
329329 "Max VPORTs (%d) exceeded\n",
330330 phba->max_vpi);
....@@ -334,7 +334,7 @@
334334
335335 /* Assign an unused board number */
336336 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,
338338 "1810 Create VPORT failed: Cannot get "
339339 "instance number\n");
340340 lpfc_free_vpi(phba, vpi);
....@@ -344,7 +344,7 @@
344344
345345 vport = lpfc_create_port(phba, instance, &fc_vport->dev);
346346 if (!vport) {
347
- lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
347
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
348348 "1811 Create VPORT failed: vpi x%x\n", vpi);
349349 lpfc_free_vpi(phba, vpi);
350350 rc = VPORT_NORESOURCES;
....@@ -356,11 +356,11 @@
356356
357357 if ((status = lpfc_vport_sparm(phba, vport))) {
358358 if (status == -EINTR) {
359
- lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
359
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
360360 "1831 Create VPORT Interrupted.\n");
361361 rc = VPORT_ERROR;
362362 } else {
363
- lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
363
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
364364 "1813 Create VPORT failed. "
365365 "Cannot get sparam\n");
366366 rc = VPORT_NORESOURCES;
....@@ -378,7 +378,7 @@
378378
379379 if (!lpfc_valid_wwn_format(phba, &vport->fc_sparam.nodeName, "WWNN") ||
380380 !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,
382382 "1821 Create VPORT failed. "
383383 "Invalid WWN format\n");
384384 lpfc_free_vpi(phba, vpi);
....@@ -388,7 +388,7 @@
388388 }
389389
390390 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,
392392 "1823 Create VPORT failed. "
393393 "Duplicate WWN on HBA\n");
394394 lpfc_free_vpi(phba, vpi);
....@@ -403,6 +403,9 @@
403403 /* Set the DFT_LUN_Q_DEPTH accordingly */
404404 vport->cfg_lun_queue_depth = phba->pport->cfg_lun_queue_depth;
405405
406
+ /* Only the physical port can support NVME for now */
407
+ vport->cfg_enable_fc4_type = LPFC_ENABLE_FCP;
408
+
406409 *(struct lpfc_vport **)fc_vport->dd_data = vport;
407410 vport->fc_vport = fc_vport;
408411
....@@ -415,22 +418,6 @@
415418 vport->fdmi_port_mask = phba->pport->fdmi_port_mask;
416419 }
417420
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
-
434421 /*
435422 * In SLI4, the vpi must be activated before it can be used
436423 * by the port.
....@@ -439,7 +426,7 @@
439426 (pport->fc_flag & FC_VFI_REGISTERED)) {
440427 rc = lpfc_sli4_init_vpi(vport);
441428 if (rc) {
442
- lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
429
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
443430 "1838 Failed to INIT_VPI on vpi %d "
444431 "status %d\n", vpi, rc);
445432 rc = VPORT_NORESOURCES;
....@@ -482,7 +469,7 @@
482469 lpfc_initial_fdisc(vport);
483470 } else {
484471 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,
486473 "0262 No NPIV Fabric support\n");
487474 }
488475 } else {
....@@ -491,8 +478,8 @@
491478 rc = VPORT_OK;
492479
493480 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");
496483 lpfc_host_attrib_init(lpfc_shost_from_vport(vport));
497484 error_out:
498485 return rc;
....@@ -540,12 +527,14 @@
540527 * scsi_host_put() to release the vport.
541528 */
542529 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
+ }
546535
547536 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,
549538 "1826 Vport Disabled.\n");
550539 return VPORT_OK;
551540 }
....@@ -586,7 +575,7 @@
586575 lpfc_initial_fdisc(vport);
587576 } else {
588577 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,
590579 "0264 No NPIV Fabric support\n");
591580 }
592581 } else {
....@@ -594,7 +583,7 @@
594583 }
595584
596585 out:
597
- lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
586
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
598587 "1827 Vport Enabled.\n");
599588 return VPORT_OK;
600589 }
....@@ -620,7 +609,7 @@
620609 bool ns_ndlp_referenced = false;
621610
622611 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,
624613 "1812 vport_delete failed: Cannot delete "
625614 "physical host\n");
626615 return VPORT_ERROR;
....@@ -629,7 +618,7 @@
629618 /* If the vport is a static vport fail the deletion. */
630619 if ((vport->vport_flag & STATIC_VPORT) &&
631620 !(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,
633622 "1837 vport_delete failed: Cannot delete "
634623 "static vport.\n");
635624 return VPORT_ERROR;
....@@ -815,10 +804,10 @@
815804
816805 lpfc_free_vpi(phba, vport->vpi);
817806 vport->work_port_events = 0;
818
- spin_lock_irq(&phba->hbalock);
807
+ spin_lock_irq(&phba->port_list_lock);
819808 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,
822811 "1828 Vport Deleted.\n");
823812 scsi_host_put(shost);
824813 return VPORT_OK;
....@@ -834,19 +823,20 @@
834823 GFP_KERNEL);
835824 if (vports == NULL)
836825 return NULL;
837
- spin_lock_irq(&phba->hbalock);
826
+ spin_lock_irq(&phba->port_list_lock);
838827 list_for_each_entry(port_iterator, &phba->port_list, listentry) {
839828 if (port_iterator->load_flag & FC_UNLOADING)
840829 continue;
841830 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,
843833 "1801 Create vport work array FAILED: "
844834 "cannot do scsi_host_get\n");
845835 continue;
846836 }
847837 vports[index++] = port_iterator;
848838 }
849
- spin_unlock_irq(&phba->hbalock);
839
+ spin_unlock_irq(&phba->port_list_lock);
850840 return vports;
851841 }
852842
....@@ -909,7 +899,8 @@
909899 GFP_ATOMIC);
910900
911901 if (!ndlp->lat_data)
912
- lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
902
+ lpfc_printf_vlog(vport, KERN_ERR,
903
+ LOG_TRACE_EVENT,
913904 "0287 lpfc_alloc_bucket failed to "
914905 "allocate statistical data buffer DID "
915906 "0x%x\n", ndlp->nlp_DID);