Lines Matching refs:vport

54 static void lpfc_fabric_abort_vport(struct lpfc_vport *vport);
55 static int lpfc_issue_els_fdisc(struct lpfc_vport *vport,
67 static void lpfc_init_cs_ctl_bitmap(struct lpfc_vport *vport);
68 static void lpfc_vmid_set_cs_ctl_range(struct lpfc_vport *vport, u32 min, u32 max);
69 static void lpfc_vmid_put_cs_ctl(struct lpfc_vport *vport, u32 ctcl_vmid);
72 * lpfc_els_chk_latt - Check host link attention event for a vport
73 * @vport: pointer to a host virtual N_Port data structure.
76 * attention event during the discovery process with the @vport. It is done
78 * link attention events during this @vport's discovery process, the @vport
84 * Note that, if either the host link is in state LPFC_LINK_DOWN or @vport
94 lpfc_els_chk_latt(struct lpfc_vport *vport)
96 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
97 struct lpfc_hba *phba = vport->phba;
100 if (vport->port_state >= LPFC_VPORT_READY ||
113 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
125 vport->fc_flag |= FC_ABORT_DISCOVERY;
129 lpfc_issue_clear_la(phba, vport);
136 * @vport: pointer to a host virtual N_Port data structure.
163 lpfc_prep_els_iocb(struct lpfc_vport *vport, u8 expect_rsp,
168 struct lpfc_hba *phba = vport->phba;
265 lpfc_sli_prep_els_req_rsp(phba, elsiocb, vport, bmp, cmd_size, did,
285 elsiocb->vport = vport;
292 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
297 vport->port_state, ndlp->nlp_rpi,
298 vport->fc_flag);
301 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
306 cmd_size, vport->port_state,
307 ndlp->nlp_rpi, vport->fc_flag);
328 * lpfc_issue_fabric_reglogin - Issue fabric registration login for a vport
329 * @vport: pointer to a host virtual N_Port data structure.
331 * This routine issues a fabric registration login for a @vport. An
332 * active ndlp node with Fabric_DID must already exist for this @vport.
335 * HBA to perform link configuration for the @vport; and the second mailbox
337 * with the @vport.
340 * 0 - successfully issued fabric registration login for @vport
341 * -ENXIO -- failed to issue fabric registration login for @vport
344 lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)
346 struct lpfc_hba *phba = vport->phba;
354 ndlp = lpfc_findnode_did(vport, Fabric_DID);
366 vport->port_state = LPFC_FABRIC_CFG_LINK;
369 mbox->vport = vport;
382 rc = lpfc_reg_rpi(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox,
390 mbox->vport = vport;
416 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
417 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
424 * lpfc_issue_reg_vfi - Register VFI for this vport's fabric login
425 * @vport: pointer to a host virtual N_Port data structure.
428 * the @vport. This mailbox command is necessary for SLI4 port only.
431 * 0 - successfully issued REG_VFI for @vport
435 lpfc_issue_reg_vfi(struct lpfc_vport *vport)
437 struct lpfc_hba *phba = vport->phba;
446 !(vport->fc_flag & FC_PT2PT)) {
447 ndlp = lpfc_findnode_did(vport, Fabric_DID);
461 if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) {
472 vport->port_state = LPFC_FABRIC_CFG_LINK;
474 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);
478 lpfc_reg_vfi(mboxq, vport, 0);
482 mboxq->vport = vport;
493 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
494 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
500 * lpfc_issue_unreg_vfi - Unregister VFI for this vport's fabric login
501 * @vport: pointer to a host virtual N_Port data structure.
504 * the @vport. This mailbox command is necessary for SLI4 port only.
507 * 0 - successfully issued REG_VFI for @vport
511 lpfc_issue_unreg_vfi(struct lpfc_vport *vport)
513 struct lpfc_hba *phba = vport->phba;
526 lpfc_unreg_vfi(mboxq, vport);
527 mboxq->vport = vport;
540 shost = lpfc_shost_from_vport(vport);
542 vport->fc_flag &= ~FC_VFI_REGISTERED;
549 * @vport: pointer to a host virtual N_Port data structure.
555 * 0. This function also set flag in the vport data structure to delay
566 lpfc_check_clean_addr_bit(struct lpfc_vport *vport,
569 struct lpfc_hba *phba = vport->phba;
571 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
573 if ((vport->fc_prevDID != vport->fc_myDID) ||
574 memcmp(&vport->fabric_portname, &sp->portName,
576 memcmp(&vport->fabric_nodename, &sp->nodeName,
578 (vport->vport_flag & FAWWPN_PARAM_CHG)) {
580 vport->vport_flag &= ~FAWWPN_PARAM_CHG;
589 * - vport->fc_prevDID != 0 (not initial discovery) OR
593 (vport->fc_prevDID || phba->cfg_delay_discovery)) {
595 vport->fc_flag |= FC_DISC_DELAYED;
605 * @vport: pointer to a host virtual N_Port data structure.
614 * @vport against the previously assigned N_Port ID. If it is different from
616 * is invoked on all the remaining nodes with the @vport to unregister the
624 lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
627 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
628 struct lpfc_hba *phba = vport->phba;
634 vport->fc_flag |= FC_FABRIC;
646 vport->fc_flag |= FC_PUBLIC_LOOP;
650 vport->fc_myDID = ulp_word4 & Mask_DID;
665 fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp);
671 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
673 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
675 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
677 vport->fdmi_hba_mask = 0;
678 vport->fdmi_port_mask = 0;
682 memcpy(&vport->fabric_portname, &sp->portName,
684 memcpy(&vport->fabric_nodename, &sp->nodeName,
690 lpfc_printf_vlog(vport, KERN_WARNING,
701 lpfc_printf_vlog(vport, KERN_WARNING,
722 if (vport->fc_flag & FC_VFI_REGISTERED)
723 lpfc_issue_reg_vfi(vport);
727 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
733 &vport->fc_nodes, nlp_listp) {
740 lpfc_unreg_rpi(vport, np);
742 lpfc_cleanup_pending_mbox(vport);
745 lpfc_sli4_unreg_all_rpis(vport);
746 lpfc_mbx_unreg_vpi(vport);
748 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
757 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
760 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
765 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
766 lpfc_register_new_vport(phba, vport, ndlp);
771 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
773 vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
774 lpfc_register_new_vport(phba, vport, ndlp);
776 lpfc_issue_fabric_reglogin(vport);
779 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
780 if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) &&
781 (vport->vpi_state & LPFC_VPI_REGISTERED)) {
783 lpfc_do_scr_ns_plogi(phba, vport);
784 } else if (vport->fc_flag & FC_VFI_REGISTERED)
785 lpfc_issue_init_vpi(vport);
787 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
789 vport->fc_prevDID, vport->fc_myDID);
790 lpfc_issue_reg_vfi(vport);
798 * @vport: pointer to a host virtual N_Port data structure.
804 * in a point-to-point topology. First, the @vport's N_Port Name is compared
805 * with the received N_Port Name: if the @vport's N_Port Name is greater than
817 lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
820 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
821 struct lpfc_hba *phba = vport->phba;
826 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
827 vport->fc_flag |= FC_PT2PT;
838 vport->fc_flag &= ~FC_VFI_REGISTERED;
843 rc = memcmp(&vport->fc_portname, &sp->portName,
844 sizeof(vport->fc_portname));
849 vport->fc_flag |= FC_PT2PT_PLOGI;
859 vport->fc_myDID = PT2PT_LocalID;
868 ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID);
874 ndlp = lpfc_nlp_init(vport, PT2PT_RemoteID);
884 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
896 mbox->vport = vport;
911 lpfc_disc_start(vport);
946 struct lpfc_vport *vport = cmdiocb->vport;
947 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
958 if (lpfc_els_chk_latt(vport)) {
977 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
980 vport->port_state);
1009 rc = lpfc_sli4_fcf_rr_next_proc(vport, fcf_index);
1019 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1031 lpfc_check_nlp_post_devloss(vport, ndlp);
1044 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
1055 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1064 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP |
1073 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
1075 (!(vport->fc_flag & FC_VFI_REGISTERED) ||
1076 (vport->fc_prevDID != vport->fc_myDID) ||
1078 if (vport->fc_flag & FC_VFI_REGISTERED) {
1082 vport->fc_flag &= ~FC_VFI_REGISTERED;
1086 lpfc_sli4_unreg_all_rpis(vport);
1091 if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4))
1092 lpfc_issue_reg_vfi(vport);
1099 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
1100 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
1113 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1119 vport->port_state, vport->fc_flag,
1124 lpfc_reinit_vmid(vport);
1126 vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA |
1134 lpfc_check_nlp_post_devloss(vport, ndlp);
1135 if (vport->port_state == LPFC_FLOGI) {
1141 rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp,
1144 rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp);
1146 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1181 lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP |
1193 } else if (vport->port_state > LPFC_FLOGI &&
1194 vport->fc_flag & FC_PT2PT) {
1209 if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4)) {
1211 lpfc_disc_list_loopmap(vport);
1214 lpfc_disc_start(vport);
1222 lpfc_issue_clear_la(phba, vport);
1268 * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport
1269 * @vport: pointer to a host virtual N_Port data structure.
1274 * for a @vport. The initiator service parameters are put into the payload
1285 * 0 - successfully issued flogi iocb for @vport
1286 * 1 - failed to issue flogi iocb for @vport
1289 lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1292 struct lpfc_hba *phba = vport->phba;
1304 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1317 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
1334 if (!memchr_inv(vport->lpfc_vmid_host_uuid, 0,
1335 sizeof(vport->lpfc_vmid_host_uuid))) {
1336 memcpy(vport->lpfc_vmid_host_uuid, phba->wwpn,
1338 memcpy(&vport->lpfc_vmid_host_uuid[8], phba->wwnn,
1379 lpfc_set_disctmo(vport);
1385 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1412 ndlp = lpfc_findnode_did(vport, 0);
1416 did = vport->fc_myDID;
1417 vport->fc_myDID = Fabric_DID;
1435 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1442 lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, &defer_flogi_acc,
1446 vport->fc_myDID = did;
1516 * lpfc_initial_flogi - Issue an initial fabric login for a vport
1517 * @vport: pointer to a host virtual N_Port data structure.
1519 * This routine issues an initial Fabric Login (FLOGI) for the @vport
1521 * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and
1522 * put it into the @vport's ndlp list. If an inactive ndlp found on the list,
1524 * is then invoked with the @vport and the ndlp to perform the FLOGI for the
1525 * @vport.
1528 * 0 - failed to issue initial flogi for @vport
1529 * 1 - successfully issued initial flogi for @vport
1532 lpfc_initial_flogi(struct lpfc_vport *vport)
1536 vport->port_state = LPFC_FLOGI;
1537 lpfc_set_disctmo(vport);
1540 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1543 ndlp = lpfc_nlp_init(vport, Fabric_DID);
1550 lpfc_enqueue_node(vport, ndlp);
1554 vport->fc_flag &= ~FC_FABRIC;
1555 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
1569 * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport
1570 * @vport: pointer to a host virtual N_Port data structure.
1572 * This routine issues an initial Fabric Discover (FDISC) for the @vport
1574 * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and
1575 * put it into the @vport's ndlp list. If an inactive ndlp found on the list,
1577 * is then invoked with the @vport and the ndlp to perform the FDISC for the
1578 * @vport.
1581 * 0 - failed to issue initial fdisc for @vport
1582 * 1 - successfully issued initial fdisc for @vport
1585 lpfc_initial_fdisc(struct lpfc_vport *vport)
1590 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1593 ndlp = lpfc_nlp_init(vport, Fabric_DID);
1601 lpfc_enqueue_node(vport, ndlp);
1604 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
1618 * lpfc_more_plogi - Check and issue remaining plogis for a vport
1619 * @vport: pointer to a host virtual N_Port data structure.
1622 * (PLOGI) to be issued for the @vport. If so, it will invoke the routine
1625 * @vport (@vport->cfg_discovery_threads). The function also decrement
1626 * the @vport's num_disc_node by 1 if it is not already 0.
1629 lpfc_more_plogi(struct lpfc_vport *vport)
1631 if (vport->num_disc_nodes)
1632 vport->num_disc_nodes--;
1635 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1638 vport->num_disc_nodes, vport->fc_plogi_cnt,
1639 vport->fc_flag, vport->port_state);
1641 if (vport->fc_flag & FC_NLP_MORE)
1643 lpfc_els_disc_plogi(vport);
1657 * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches
1658 * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but
1661 * 1) if there is a node on vport list other than the @ndlp with the same
1664 * no node found on vport list with the same WWPN of the N_Port PLOGI logged
1667 * be released and the new_ndlp shall be put on to the vport node list and
1671 * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID
1673 * into an inactive state on the vport node list and the vport node list
1683 struct lpfc_vport *vport = ndlp->vport;
1706 new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName);
1716 lpfc_nlp_unreg_node(vport, new_ndlp);
1726 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_NODE,
1745 if (vport->fc_flag & FC_FABRIC) {
1750 lpfc_unreg_rpi(vport, new_ndlp);
1814 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
1826 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1836 lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
1844 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1848 lpfc_unreg_rpi(vport, ndlp);
1868 lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
1877 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
1884 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_NODE,
1893 * lpfc_end_rscn - Check and handle more rscn for a vport
1894 * @vport: pointer to a host virtual N_Port data structure.
1899 * invoked to handle the additional RSCNs for the @vport. Otherwise, the
1900 * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of
1904 lpfc_end_rscn(struct lpfc_vport *vport)
1906 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1908 if (vport->fc_flag & FC_RSCN_MODE) {
1913 if (vport->fc_rscn_id_cnt ||
1914 (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
1915 lpfc_els_handle_rscn(vport);
1918 vport->fc_flag &= ~FC_RSCN_MODE;
1940 struct lpfc_vport *vport = cmdiocb->vport;
1950 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1957 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1965 /* RRQ failed Don't print the vport to vport rjts */
1970 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1990 * ndlp on the vport node list that matches the remote node ID from the
1998 * there are additional N_Port nodes with the vport that need to perform
2006 struct lpfc_vport *vport = cmdiocb->vport;
2007 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2030 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2034 ndlp = lpfc_findnode_did(vport, did);
2036 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2052 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2057 disc, vport->num_disc_nodes);
2060 if (lpfc_els_chk_latt(vport)) {
2078 /* PLOGI failed Don't print the vport to vport rjts */
2083 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2090 if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4))
2091 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2116 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2140 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2144 if (disc && vport->num_disc_nodes) {
2146 lpfc_more_plogi(vport);
2148 if (vport->num_disc_nodes == 0) {
2150 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2153 lpfc_can_disctmo(vport);
2154 lpfc_end_rscn(vport);
2159 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE,
2173 * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport
2174 * @vport: pointer to a host virtual N_Port data structure.
2179 * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port,
2180 * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list.
2189 * 0 - Successfully issued a plogi for @vport
2190 * 1 - failed to issue a plogi for @vport
2193 lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry)
2195 struct lpfc_hba *phba = vport->phba;
2203 ndlp = lpfc_findnode_did(vport, did);
2213 !(vport->fc_flag & FC_OFFLINE_MODE)) {
2214 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2228 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
2238 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
2245 if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP))
2260 if (vport->vmid_priority_tagging)
2266 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2282 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2318 struct lpfc_vport *vport = cmdiocb->vport;
2338 vport->fc_prli_sent--;
2342 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2348 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2352 vport->num_disc_nodes, ndlp->fc4_prli_sent);
2355 if (lpfc_els_chk_latt(vport))
2368 if ((vport->fc_flag & FC_FABRIC) ||
2369 (vport->cfg_enable_fc4_type != LPFC_ENABLE_BOTH)) {
2378 lpfc_printf_vlog(vport, mode, loglevel,
2386 if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4))
2387 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2398 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
2410 if (vport->fc_flag & FC_PT2PT)
2428 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2436 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2447 * lpfc_issue_els_prli - Issue a prli iocb command for a vport
2448 * @vport: pointer to a host virtual N_Port data structure.
2453 * @vport. The PRLI service parameters are set up in the payload of the
2463 * 0 - successfully issued prli iocb command for @vport
2464 * 1 - failed to issue prli iocb command for @vport
2467 lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2471 struct lpfc_hba *phba = vport->phba;
2486 vport->fc_flag & FC_RSCN_MODE &&
2487 vport->nvmei_support)
2510 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2521 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2524 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
2528 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2559 if (vport->cfg_first_burst_size)
2608 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2624 /* The vport counters are used for lpfc_scan_finished, but
2630 vport->fc_prli_sent++;
2645 * lpfc_rscn_disc - Perform rscn discovery for a vport
2646 * @vport: pointer to a host virtual N_Port data structure.
2649 * discovery for a @vport. If the @vport's node port recovery count is not
2657 lpfc_rscn_disc(struct lpfc_vport *vport)
2659 lpfc_can_disctmo(vport);
2663 if (vport->fc_npr_cnt)
2664 if (lpfc_els_disc_plogi(vport))
2667 lpfc_end_rscn(vport);
2672 * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs.
2681 lpfc_adisc_done(struct lpfc_vport *vport)
2683 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2684 struct lpfc_hba *phba = vport->phba;
2691 !(vport->fc_flag & FC_RSCN_MODE) &&
2709 lpfc_issue_clear_la(phba, vport);
2710 lpfc_issue_reg_vpi(phba, vport);
2717 if (vport->port_state < LPFC_VPORT_READY) {
2719 lpfc_issue_clear_la(phba, vport);
2720 if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) {
2721 vport->num_disc_nodes = 0;
2723 if (vport->fc_npr_cnt)
2724 lpfc_els_disc_plogi(vport);
2725 if (!vport->num_disc_nodes) {
2727 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2729 lpfc_can_disctmo(vport);
2730 lpfc_end_rscn(vport);
2733 vport->port_state = LPFC_VPORT_READY;
2735 lpfc_rscn_disc(vport);
2740 * @vport: pointer to a host virtual N_Port data structure.
2742 * This routine determines whether there are more ndlps on a @vport
2744 * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's
2748 lpfc_more_adisc(struct lpfc_vport *vport)
2750 if (vport->num_disc_nodes)
2751 vport->num_disc_nodes--;
2753 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2756 vport->num_disc_nodes, vport->fc_adisc_cnt,
2757 vport->fc_flag, vport->port_state);
2759 if (vport->fc_flag & FC_NLP_MORE) {
2760 lpfc_set_disctmo(vport);
2762 lpfc_els_disc_adisc(vport);
2764 if (!vport->num_disc_nodes)
2765 lpfc_adisc_done(vport);
2789 struct lpfc_vport *vport = cmdiocb->vport;
2811 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2824 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2828 tmo, disc, vport->num_disc_nodes);
2830 if (lpfc_els_chk_latt(vport)) {
2845 lpfc_set_disctmo(vport);
2850 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2854 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2870 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2874 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2878 if (disc && vport->num_disc_nodes)
2879 lpfc_more_adisc(vport);
2887 * lpfc_issue_els_adisc - Issue an address discover iocb to an node on a vport
2888 * @vport: pointer to a virtual N_Port data structure.
2893 * @vport. It prepares the payload of the ADISC ELS command, updates the
2906 lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2910 struct lpfc_hba *phba = vport->phba;
2917 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2931 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
2932 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
2933 ap->DID = be32_to_cpu(vport->fc_myDID);
2946 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2982 struct lpfc_vport *vport = ndlp->vport;
3012 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3018 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3023 tmo, vport->num_disc_nodes);
3025 if (lpfc_els_chk_latt(vport)) {
3037 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
3043 if (lpfc_error_lost_link(vport, ulp_status, ulp_word4))
3048 lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO);
3062 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
3083 lpfc_cancel_retry_delay_tmo(vport, ndlp);
3088 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3093 vport->num_disc_nodes);
3098 lpfc_disc_start(vport);
3111 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
3121 * lpfc_issue_els_logo - Issue a logo to an node on a vport
3122 * @vport: pointer to a virtual N_Port data structure.
3127 * to a remote node, referred by an @ndlp on a @vport. It constructs the
3142 lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
3145 struct lpfc_hba *phba = vport->phba;
3159 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3169 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
3171 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
3185 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3199 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
3228 struct lpfc_vport *vport = cmdiocb->vport;
3246 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3251 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3256 lpfc_els_chk_latt(vport);
3266 * @vport: pointer to lpfc_vport data structure.
3279 lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp)
3282 struct lpfc_hba *phba = vport->phba;
3289 ns_ndlp = lpfc_findnode_did(vport, NameServer_DID);
3293 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
3302 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3309 rc = lpfc_reg_rpi(phba, vport->vpi, fc_ndlp->nlp_DID,
3310 (u8 *)&vport->fc_sparam, mbox, fc_ndlp->nlp_rpi);
3324 mbox->vport = vport;
3332 lpfc_nlp_set_state(vport, fc_ndlp,
3338 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3361 struct lpfc_vport *vport = cmdiocb->vport;
3383 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3388 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
3409 lpfc_issue_els_scr(vport, cmdiocb->retry);
3412 lpfc_issue_els_edc(vport, cmdiocb->retry);
3415 lpfc_issue_els_rdf(vport, cmdiocb->retry);
3429 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS | LOG_CGN_MGMT,
3451 lpfc_printf_vlog(vport, KERN_INFO,
3463 lpfc_els_chk_latt(vport);
3470 * lpfc_issue_els_scr - Issue a scr to an node on a vport
3471 * @vport: pointer to a host virtual N_Port data structure.
3475 * on a @vport. The remote node is Fabric Controller (0xfffffd). It
3476 * first search the @vport node list to find the matching ndlp. If no such
3490 lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry)
3493 struct lpfc_hba *phba = vport->phba;
3501 ndlp = lpfc_findnode_did(vport, Fabric_Cntl_DID);
3503 ndlp = lpfc_nlp_init(vport, Fabric_Cntl_DID);
3506 lpfc_enqueue_node(vport, ndlp);
3509 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3515 rc = lpfc_reg_fab_ctrl_node(vport, ndlp);
3518 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3533 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3545 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3562 * @vport: pointer to a host virtual N_Port data structure.
3579 lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry)
3582 struct lpfc_hba *phba = vport->phba;
3594 !(vport->fc_flag & FC_PUBLIC_LOOP))
3597 if (vport->fc_flag & FC_PT2PT) {
3599 ndlp = lpfc_findnode_mapped(vport);
3605 ndlp = lpfc_findnode_did(vport, nportid);
3608 ndlp = lpfc_nlp_init(vport, nportid);
3611 lpfc_enqueue_node(vport, ndlp);
3615 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3627 nportid = vport->fc_myDID;
3642 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3657 * lpfc_issue_els_farpr - Issue a farp to an node on a vport
3658 * @vport: pointer to a host virtual N_Port data structure.
3663 * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid)
3664 * is passed into the function. It first search the @vport node list to find
3678 lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry)
3681 struct lpfc_hba *phba = vport->phba;
3692 ndlp = lpfc_findnode_did(vport, nportid);
3694 ndlp = lpfc_nlp_init(vport, nportid);
3697 lpfc_enqueue_node(vport, ndlp);
3700 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3715 *lp++ = be32_to_cpu(vport->fc_myDID);
3719 memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name));
3720 memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
3721 ondlp = lpfc_findnode_did(vport, nportid);
3729 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3760 * @vport: pointer to a host virtual N_Port data structure.
3775 lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
3777 struct lpfc_hba *phba = vport->phba;
3786 ndlp = lpfc_findnode_did(vport, Fabric_Cntl_DID);
3788 ndlp = lpfc_nlp_init(vport, Fabric_Cntl_DID);
3791 lpfc_enqueue_node(vport, ndlp);
3795 if (vport->port_type == LPFC_NPIV_PORT)
3798 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3818 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
3831 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3846 * @vport: pointer to a host virtual N_Port data structure.
3859 lpfc_els_rcv_rdf(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3863 if (lpfc_els_rsp_acc(vport, ELS_CMD_RDF, cmdiocb, ndlp, NULL)) {
3864 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
3866 ndlp->nlp_DID, vport->fc_myDID);
3871 if (lpfc_issue_els_rdf(vport, 0)) {
3872 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
3874 vport->fc_myDID);
4250 * @vport: pointer to a host virtual N_Port data structure.
4271 lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry)
4273 struct lpfc_hba *phba = vport->phba;
4283 if (vport->port_type == LPFC_NPIV_PORT)
4286 ndlp = lpfc_findnode_did(vport, Fabric_DID);
4301 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
4323 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
4336 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
4353 rc = lpfc_issue_els_rdf(vport, 0);
4359 * @vport: pointer to a host virtual N_Port data structure.
4363 * a @vport's @ndlp. It stops the timer for the delayed function retrial and
4366 * commands are sent for the @vport's nodes that require issuing discovery
4370 lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
4372 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4392 if (vport->num_disc_nodes) {
4393 if (vport->port_state < LPFC_VPORT_READY) {
4395 lpfc_more_adisc(vport);
4398 lpfc_more_plogi(vport);
4399 if (vport->num_disc_nodes == 0) {
4401 vport->fc_flag &= ~FC_NDISC_ACTIVE;
4403 lpfc_can_disctmo(vport);
4404 lpfc_end_rscn(vport);
4430 struct lpfc_vport *vport = ndlp->vport;
4431 struct lpfc_hba *phba = vport->phba;
4466 struct lpfc_vport *vport = ndlp->vport;
4491 lpfc_issue_els_flogi(vport, ndlp, retry);
4494 if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) {
4496 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
4500 if (!lpfc_issue_els_adisc(vport, ndlp, retry)) {
4502 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
4507 if (!lpfc_issue_els_prli(vport, ndlp, retry)) {
4509 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
4513 if (!lpfc_issue_els_logo(vport, ndlp, retry)) {
4515 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
4519 if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI))
4520 lpfc_issue_els_fdisc(vport, ndlp, retry);
4528 * @vport: pointer to a virtual N_Port data structure.
4539 lpfc_link_reset(struct lpfc_vport *vport)
4541 struct lpfc_hba *phba = vport->phba;
4546 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4569 mbox->vport = vport;
4607 struct lpfc_vport *vport = cmdiocb->vport;
4636 ndlp = lpfc_findnode_did(vport, did);
4641 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
4667 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
4757 if ((vport->fc_flag & FC_PT2PT) &&
4764 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
4770 vport->fc_flag |= FC_PT2PT_NO_NVME;
4784 lpfc_printf_vlog(vport, KERN_INFO,
4825 lpfc_printf_vlog(vport, KERN_ERR,
4830 lpfc_vport_set_state(vport,
4863 vport->fc_sparam.cmn.bbRcvSizeMsb &= 0xf;
4865 lpfc_printf_vlog(vport, KERN_ERR,
4879 lpfc_printf_vlog(vport, KERN_ERR,
4884 lpfc_vport_set_state(vport,
4918 rc = lpfc_link_reset(vport);
4935 !lpfc_error_lost_link(vport, ulp_status, ulp_word4)) {
4949 !lpfc_error_lost_link(vport, ulp_status, ulp_word4)) {
4952 maxretry = vport->cfg_devloss_tmo;
4962 if ((vport->load_flag & FC_UNLOADING) != 0)
4970 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4980 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4992 if (timer_pending(&vport->fc_disctmo) ||
4993 (vport->fc_flag & FC_RSCN_MODE))
4994 lpfc_set_disctmo(vport);
5012 lpfc_nlp_set_state(vport, ndlp,
5015 lpfc_nlp_set_state(vport, ndlp,
5023 lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry);
5026 lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry);
5031 lpfc_nlp_set_state(vport, ndlp,
5034 lpfc_issue_els_plogi(vport, did, cmdiocb->retry);
5038 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
5039 lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry);
5044 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
5045 lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry);
5049 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
5050 lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry);
5056 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
5063 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5219 struct lpfc_vport *vport = cmdiocb->vport;
5225 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5229 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5254 lpfc_unreg_rpi(vport, ndlp);
5286 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
5304 lpfc_drop_node(ndlp->vport, ndlp);
5328 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
5329 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
5334 if (!vport) {
5356 if (!ndlp || lpfc_els_chk_latt(vport)) {
5362 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5366 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5375 if (!lpfc_unreg_rpi(vport, ndlp) &&
5376 (!(vport->fc_flag & FC_PT2PT))) {
5380 lpfc_printf_vlog(vport, KERN_INFO,
5400 mbox->vport = vport;
5408 lpfc_nlp_set_state(vport, ndlp,
5424 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
5446 vport && vport->port_type == LPFC_NPIV_PORT &&
5457 lpfc_drop_node(vport, ndlp);
5468 lpfc_drop_node(vport, ndlp);
5480 * @vport: pointer to a host virtual N_Port data structure.
5504 lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
5508 struct lpfc_hba *phba = vport->phba;
5524 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
5556 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5563 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
5611 memcpy(&sp->portName, &vport->fc_sparam.portName,
5613 memcpy(&sp->nodeName, &vport->fc_sparam.nodeName,
5616 memcpy(pcmd, &vport->fc_sparam,
5635 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5641 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
5673 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5679 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
5745 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5751 ndlp->nlp_rpi, vport->fc_flag, kref_read(&ndlp->kref));
5757 * @vport: pointer to a virtual N_Port data structure.
5778 lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
5783 struct lpfc_hba *phba = vport->phba;
5792 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
5820 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5827 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5844 vport->port_type == LPFC_NPIV_PORT &&
5863 * @vport: pointer to a host virtual N_Port data structure.
5876 lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
5879 struct lpfc_hba *phba = vport->phba;
5895 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, cmdiocb->retry,
5930 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5951 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5957 ndlp->nlp_rpi, vport->fc_flag);
5964 * @vport: pointer to a virtual N_Port data structure.
5982 lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
5985 struct lpfc_hba *phba = vport->phba;
5996 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
6020 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6033 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
6034 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
6035 ap->DID = be32_to_cpu(vport->fc_myDID);
6037 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
6061 * @vport: pointer to a virtual N_Port data structure.
6079 lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
6082 struct lpfc_hba *phba = vport->phba;
6106 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6120 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
6142 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6183 lpfc_printf_vlog(vport, KERN_INFO,
6213 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
6224 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6229 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
6253 * @vport: pointer to a virtual N_Port data structure.
6272 lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
6275 struct lpfc_hba *phba = vport->phba;
6290 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
6312 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6323 memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name));
6324 memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
6332 &vport->fc_portname, sizeof(struct lpfc_name));
6343 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
6367 * @vport: pointer to a virtual N_Port data structure.
6374 lpfc_els_clear_rrq(struct lpfc_vport *vport,
6377 struct lpfc_hba *phba = vport->phba;
6391 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6400 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
6403 if (vport->fc_myDID == be32_to_cpu(bf_get(rrq_did, rrq)))
6407 prrq = lpfc_get_active_rrq(vport, xri, ndlp->nlp_DID);
6415 * @vport: pointer to a virtual N_Port data structure.
6425 lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data,
6428 struct lpfc_hba *phba = vport->phba;
6447 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
6469 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6477 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
6500 * lpfc_els_disc_adisc - Issue remaining adisc iocbs to npr nodes of a vport
6501 * @vport: pointer to a host virtual N_Port data structure.
6505 * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the
6506 * lpfc_issue_els_adisc() routine, the per @vport number of discover count
6508 * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will
6511 * all the ndlps with the @vport and there is none ADISC IOCB issued, the
6512 * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is
6519 lpfc_els_disc_adisc(struct lpfc_vport *vport)
6521 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6526 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
6544 lpfc_nlp_unreg_node(vport, ndlp);
6545 lpfc_unreg_rpi(vport, ndlp);
6550 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
6551 lpfc_issue_els_adisc(vport, ndlp, 0);
6553 vport->num_disc_nodes++;
6554 if (vport->num_disc_nodes >=
6555 vport->cfg_discovery_threads) {
6557 vport->fc_flag |= FC_NLP_MORE;
6565 vport->fc_flag &= ~FC_NLP_MORE;
6572 * lpfc_els_disc_plogi - Issue plogi for all npr nodes of a vport before adisc
6573 * @vport: pointer to a host virtual N_Port data structure.
6576 * which are in node port recovery state, with a @vport. Each time an ELS
6578 * the per @vport number of discover count (num_disc_nodes) shall be
6580 * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE
6583 * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag
6591 lpfc_els_disc_plogi(struct lpfc_vport *vport)
6593 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6598 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
6604 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
6605 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
6607 vport->num_disc_nodes++;
6608 if (vport->num_disc_nodes >=
6609 vport->cfg_discovery_threads) {
6611 vport->fc_flag |= FC_NLP_MORE;
6618 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6620 sentplogi, vport->fc_flag);
6623 lpfc_set_disctmo(vport);
6627 vport->fc_flag &= ~FC_NLP_MORE;
6741 struct lpfc_vport *vport)
6747 bbCredit = vport->fc_sparam.cmn.bbCreditLsb |
6748 (vport->fc_sparam.cmn.bbCreditMsb << 8);
6750 if (vport->phba->fc_topology != LPFC_TOPOLOGY_LOOP) {
6751 bbCredit = vport->phba->fc_fabparam.cmn.bbCreditLsb |
6752 (vport->phba->fc_fabparam.cmn.bbCreditMsb << 8);
6911 uint8_t *page_a0, struct lpfc_vport *vport)
7019 struct lpfc_vport *vport)
7024 memcpy(desc->port_names.wwnn, &vport->fc_nodename,
7027 memcpy(desc->port_names.wwpn, &vport->fc_portname,
7036 struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
7040 if (vport->fc_flag & FC_FABRIC) {
7041 memcpy(desc->port_names.wwnn, &vport->fabric_nodename,
7044 memcpy(desc->port_names.wwpn, &vport->fabric_portname,
7063 struct lpfc_vport *vport = ndlp->vport;
7082 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize,
7102 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7131 (len + pcmd), vport);
7133 (len + pcmd), vport, ndlp);
7137 &rdp_context->link_stat, vport);
7154 rdp_context->page_a0, vport);
7182 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, lpfc_max_els_tries,
7244 mbox->vport = rdp_context->ndlp->vport;
7305 mbox->vport = phba->pport;
7333 mbox->vport = phba->pport;
7390 * @vport: pointer to a host virtual N_Port data structure.
7406 lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7409 struct lpfc_hba *phba = vport->phba;
7434 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7469 lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_ELS,
7486 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
7630 lpfc_sli4_set_beacon(struct lpfc_vport *vport,
7634 struct lpfc_hba *phba = vport->phba;
7651 mbox->vport = phba->pport;
7703 * @vport: pointer to a host virtual N_Port data structure.
7716 lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7719 struct lpfc_hba *phba = vport->phba;
7731 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7775 if (lpfc_sli4_set_beacon(vport, lcb_context, state)) {
7776 lpfc_printf_vlog(ndlp->vport, KERN_ERR, LOG_TRACE_EVENT,
7789 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
7795 * lpfc_els_flush_rscn - Clean up any rscn activities with a vport
7796 * @vport: pointer to a host virtual N_Port data structure.
7799 * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the
7800 * @vport together with the host_lock is used to prevent multiple thread
7801 * trying to access the RSCN array on a same @vport at the same time.
7804 lpfc_els_flush_rscn(struct lpfc_vport *vport)
7806 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
7807 struct lpfc_hba *phba = vport->phba;
7811 if (vport->fc_rscn_flush) {
7812 /* Another thread is walking fc_rscn_id_list on this vport */
7816 /* Indicate we are walking lpfc_els_flush_rscn on this vport */
7817 vport->fc_rscn_flush = 1;
7820 for (i = 0; i < vport->fc_rscn_id_cnt; i++) {
7821 lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]);
7822 vport->fc_rscn_id_list[i] = NULL;
7825 vport->fc_rscn_id_cnt = 0;
7826 vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY);
7828 lpfc_can_disctmo(vport);
7830 vport->fc_rscn_flush = 0;
7835 * @vport: pointer to a host virtual N_Port data structure.
7839 * Configuration Notification (RSCN) to a @did on @vport.
7846 lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
7852 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
7861 if (vport->fc_flag & FC_RSCN_DISCOVERY)
7865 if (vport->fc_rscn_flush) {
7866 /* Another thread is walking fc_rscn_id_list on this vport */
7870 /* Indicate we are walking fc_rscn_id_list on this vport */
7871 vport->fc_rscn_flush = 1;
7873 for (i = 0; i < vport->fc_rscn_id_cnt; i++) {
7874 lp = vport->fc_rscn_id_list[i]->virt;
7901 /* Indicate we are done with walking fc_rscn_id_list on this vport */
7902 vport->fc_rscn_flush = 0;
7905 /* Indicate we are done with walking fc_rscn_id_list on this vport */
7906 vport->fc_rscn_flush = 0;
7911 * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn
7912 * @vport: pointer to a host virtual N_Port data structure.
7915 * state machine for a @vport's nodes that are with pending RSCN (Registration
7922 lpfc_rscn_recovery_check(struct lpfc_vport *vport)
7927 list_for_each_entry_safe(ndlp, n, &vport->fc_nodes, nlp_listp) {
7929 !lpfc_rscn_payload_check(vport, ndlp->nlp_DID))
7933 if (vport->phba->nvmet_support)
7948 lpfc_disc_state_machine(vport, ndlp, NULL,
7950 lpfc_cancel_retry_delay_tmo(vport, ndlp);
7957 * @vport: pointer to a host virtual N_Port data structure.
7964 lpfc_send_rscn_event(struct lpfc_vport *vport,
7968 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
7980 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8000 * @vport: pointer to a host virtual N_Port data structure.
8011 * state, the fc_rscn_id_list of this @vport is walked and the
8021 lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8024 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8025 struct lpfc_hba *phba = vport->phba;
8039 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
8041 vport->fc_flag, payload_len, *lp,
8042 vport->fc_rscn_id_cnt);
8045 lpfc_send_rscn_event(vport, cmdiocb);
8052 if (vport->fc_flag & FC_PT2PT) {
8054 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
8056 *lp, vport->fc_flag, payload_len);
8057 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
8064 lpfc_nvme_rescan_port(vport, ndlp);
8071 if (vport->port_state <= LPFC_NS_QRY) {
8072 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8074 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
8076 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
8084 !(vport->cfg_peer_port_login)) {
8097 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
8100 vport->fc_flag, payload_len,
8101 *lp, vport->fc_rscn_id_cnt);
8102 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8103 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x",
8104 ndlp->nlp_DID, vport->port_state,
8107 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb,
8110 if (vport->fc_flag & FC_DISC_TMO) {
8112 mod_timer(&vport->fc_disctmo,
8121 if (vport->fc_rscn_flush) {
8122 /* Another thread is walking fc_rscn_id_list on this vport */
8123 vport->fc_flag |= FC_RSCN_DISCOVERY;
8126 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
8129 /* Indicate we are walking fc_rscn_id_list on this vport */
8130 vport->fc_rscn_flush = 1;
8133 rscn_cnt = vport->fc_rscn_id_cnt;
8137 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {
8138 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8140 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
8143 vport->fc_flag |= FC_RSCN_DEFERRED;
8146 if (vport->fc_flag & FC_DISC_TMO) {
8148 mod_timer(&vport->fc_disctmo,
8152 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
8153 vport->fc_flag |= FC_RSCN_MODE;
8156 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt;
8166 vport->fc_rscn_id_list[rscn_cnt] = pcmd;
8167 vport->fc_rscn_id_cnt++;
8174 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
8177 vport->fc_rscn_id_cnt, vport->fc_flag,
8178 vport->port_state);
8180 vport->fc_flag |= FC_RSCN_DISCOVERY;
8183 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
8186 vport->fc_rscn_id_cnt, vport->fc_flag,
8187 vport->port_state);
8189 /* Indicate we are done walking fc_rscn_id_list on this vport */
8190 vport->fc_rscn_flush = 0;
8192 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
8194 lpfc_rscn_recovery_check(vport);
8197 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8199 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
8202 vport->fc_flag |= FC_RSCN_MODE;
8204 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;
8205 /* Indicate we are done walking fc_rscn_id_list on this vport */
8206 vport->fc_rscn_flush = 0;
8212 lpfc_set_disctmo(vport);
8214 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
8216 lpfc_rscn_recovery_check(vport);
8217 return lpfc_els_handle_rscn(vport);
8221 * lpfc_els_handle_rscn - Handle rscn for a vport
8222 * @vport: pointer to a host virtual N_Port data structure.
8225 * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall
8230 * RSCN activities with the @vport.
8233 * 0 - Cleaned up rscn on the @vport
8237 lpfc_els_handle_rscn(struct lpfc_vport *vport)
8240 struct lpfc_hba *phba = vport->phba;
8243 if (vport->load_flag & FC_UNLOADING) {
8244 lpfc_els_flush_rscn(vport);
8249 lpfc_set_disctmo(vport);
8252 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
8254 vport->fc_flag, 0, vport->fc_rscn_id_cnt,
8255 vport->port_state, vport->num_disc_nodes,
8256 vport->gidft_inp);
8259 vport->fc_ns_retry = 0;
8260 vport->num_disc_nodes = 0;
8262 ndlp = lpfc_findnode_did(vport, NameServer_DID);
8270 if (lpfc_issue_gidft(vport) > 0)
8273 if (lpfc_issue_gidpt(vport) > 0)
8282 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
8284 ndlp = lpfc_nlp_init(vport, NameServer_DID);
8286 lpfc_els_flush_rscn(vport);
8290 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
8293 lpfc_issue_els_plogi(vport, NameServer_DID, 0);
8300 lpfc_els_flush_rscn(vport);
8306 * @vport: pointer to a host virtual N_Port data structure.
8318 * FLOGI shall be compared with the Port WWN of the @vport to determine who
8322 * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI
8330 lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8333 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8334 struct lpfc_hba *phba = vport->phba;
8353 lpfc_set_disctmo(vport);
8361 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8368 (void) lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1);
8375 rc = memcmp(&vport->fc_portname, &sp->portName,
8390 mbox->vport = vport;
8402 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_LIBDFC,
8413 vport->fc_flag |= FC_PT2PT_PLOGI;
8421 vport->fc_myDID = PT2PT_LocalID;
8423 vport->fc_myDID = PT2PT_RemoteID;
8427 * The vport state should go to LPFC_FLOGI only
8431 fc_flag = vport->fc_flag;
8432 port_state = vport->port_state;
8433 vport->fc_flag |= FC_PT2PT;
8434 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
8439 vport->rcv_flogi_cnt++;
8441 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
8444 port_state, vport->port_state,
8445 fc_flag, vport->fc_flag);
8452 did = vport->fc_myDID;
8453 vport->fc_myDID = Fabric_DID;
8464 vport->fc_myDID = did;
8466 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
8478 lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, cmdiocb, ndlp, NULL);
8481 vport->fc_myDID = did;
8488 * @vport: pointer to a host virtual N_Port data structure.
8503 lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8523 lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp);
8531 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
8539 * @vport: pointer to a host virtual N_Port data structure.
8547 lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8557 lpfc_els_rsp_echo_acc(vport, pcmd, cmdiocb, ndlp);
8563 * @vport: pointer to a host virtual N_Port data structure.
8575 lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8585 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
8591 * @vport: pointer to a host virtual N_Port data structure.
8606 lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8609 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
8610 if (vport->phba->sli_rev == LPFC_SLI_REV4)
8611 lpfc_els_clear_rrq(vport, cmdiocb, ndlp);
8700 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
8724 * @vport: pointer to a host virtual N_Port data structure.
8741 lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8744 struct lpfc_hba *phba = vport->phba;
8763 mbox->vport = vport;
8782 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
8788 * @vport: pointer to a host virtual N_Port data structure.
8808 lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
8814 struct lpfc_hba *phba = vport->phba;
8863 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
8892 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
8897 * @vport: pointer to a host virtual N_Port data structure.
8910 lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
8913 struct lpfc_hba *phba = vport->phba;
8925 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, did,
8939 bf_set(rrq_did, els_rrq, vport->fc_myDID);
8944 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
8981 struct lpfc_nodelist *ndlp = lpfc_findnode_did(rrq->vport,
8987 return lpfc_issue_els_rrq(rrq->vport, ndlp,
8995 * @vport: pointer to a host virtual N_Port data structure.
9013 lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize,
9017 struct lpfc_hba *phba = vport->phba;
9025 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
9055 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID);
9056 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname,
9060 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
9087 * @vport: pointer to a host virtual N_Port data structure.
9102 lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
9119 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
9138 lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp);
9145 * @vport: pointer to a virtual N_Port data structure.
9154 * remote PortName is compared against the FC PortName stored in the @vport
9156 * compared against the FC NodeName stored in the @vport data structure.
9168 lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
9176 did = get_job_els_rsp64_did(vport->phba, cmdiocb);
9183 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
9193 if (memcmp(&fp->RportName, &vport->fc_portname,
9200 if (memcmp(&fp->RnodeName, &vport->fc_nodename,
9211 lpfc_nlp_set_state(vport, ndlp,
9213 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
9218 lpfc_issue_els_farpr(vport, did, 0);
9226 * @vport: pointer to a host virtual N_Port data structure.
9239 lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
9244 did = get_job_els_rsp64_did(vport->phba, cmdiocb);
9247 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
9250 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
9257 * @vport: pointer to a host virtual N_Port data structure.
9263 * only be processed on a physical port (i.e., the @vport represents the
9275 lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
9278 struct lpfc_hba *phba = vport->phba;
9282 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n");
9286 if ((vport == phba->pport) &&
9287 (vport->port_state == LPFC_LOCAL_CFG_LINK)) {
9293 lpfc_issue_init_vfi(vport);
9296 vport->fc_myDID = vport->fc_prevDID;
9298 lpfc_issue_fabric_reglogin(vport);
9300 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
9302 vport->fc_prevDID, vport->fc_myDID);
9303 lpfc_issue_reg_vfi(vport);
9312 * @vport: pointer to a host virtual N_Port data structure.
9320 lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
9323 struct lpfc_hba *phba = vport->phba;
9338 lpfc_printf_vlog(vport, KERN_INFO,
9436 lpfc_issue_els_edc_rsp(vport, cmdiocb, ndlp);
9444 * @t: timer context used to obtain the vport.
9455 struct lpfc_vport *vport = from_timer(vport, t, els_tmofunc);
9456 struct lpfc_hba *phba = vport->phba;
9460 spin_lock_irqsave(&vport->work_port_lock, iflag);
9461 tmo_posted = vport->work_port_events & WORKER_ELS_TMO;
9462 if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING)))
9463 vport->work_port_events |= WORKER_ELS_TMO;
9464 spin_unlock_irqrestore(&vport->work_port_lock, iflag);
9466 if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING)))
9474 * @vport: pointer to a virtual N_Port data structure.
9478 * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by
9482 lpfc_els_timeout_handler(struct lpfc_vport *vport)
9484 struct lpfc_hba *phba = vport->phba;
9527 if (piocb->vport != vport)
9552 ndlp = __lpfc_findnode_rpi(vport, ulp_context);
9563 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9579 mod_timer(&vport->els_tmofunc,
9584 * lpfc_els_flush_cmd - Clean up the outstanding els commands to a vport
9585 * @vport: pointer to a host virtual N_Port data structure.
9588 * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport()
9590 * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For
9596 * completion queue IOCB that is associated with the @vport and is not
9604 lpfc_els_flush_cmd(struct lpfc_vport *vport)
9608 struct lpfc_hba *phba = vport->phba;
9615 lpfc_fabric_abort_vport(vport);
9641 if (piocb->vport != vport)
9691 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9716 if (piocb->vport != vport)
9724 if (vport == phba->pport) {
9763 struct lpfc_vport *vport;
9766 list_for_each_entry(vport, &phba->port_list, listentry)
9767 lpfc_els_flush_cmd(vport);
9787 struct lpfc_vport *vport = cmdiocbp->vport;
9788 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9845 * @vport: Pointer to vport object.
9853 lpfc_send_els_event(struct lpfc_vport *vport,
9859 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9864 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9874 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10214 lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length)
10216 struct lpfc_hba *phba = vport->phba;
10225 if (vport->port_state < LPFC_DISC_AUTH)
10314 fc_host_fpin_rcv(lpfc_shost_from_vport(vport),
10324 * @vport: pointer to a host virtual N_Port data structure.
10336 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
10346 if (!vport || !elsiocb->cmd_dmabuf)
10363 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10370 if (lpfc_els_chk_latt(vport))
10373 /* Ignore traffic received during vport shutdown. */
10374 if (vport->load_flag & FC_UNLOADING)
10378 if ((vport->fc_flag & FC_DISC_DELAYED) &&
10382 ndlp = lpfc_findnode_did(vport, did);
10385 ndlp = lpfc_nlp_init(vport, did);
10388 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
10393 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
10415 elsiocb->vport = vport;
10421 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
10424 cmd, did, kref_read(&ndlp->kref), vport->port_state,
10425 vport->fc_flag, vport->fc_myDID, vport->fc_prevDID);
10428 if ((vport->port_state < LPFC_FABRIC_CFG_LINK) &&
10430 !((cmd == ELS_CMD_PLOGI) && (vport->fc_flag & FC_PT2PT))) {
10438 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10440 did, vport->port_state, ndlp->nlp_flag);
10446 vport->fc_prevDID = vport->fc_myDID;
10451 vport->fc_myDID =
10454 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
10456 "%x\n", vport->fc_myDID,
10457 vport->fc_prevDID);
10460 lpfc_send_els_event(vport, ndlp, payload);
10463 if (vport->fc_flag & FC_DISC_DELAYED) {
10469 if (vport->port_state < LPFC_DISC_AUTH) {
10482 lpfc_disc_state_machine(vport, ndlp, elsiocb,
10487 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10489 did, vport->port_state, ndlp->nlp_flag);
10496 if (vport->port_state >= LPFC_LOCAL_CFG_LINK &&
10497 vport->fc_flag & FC_PT2PT &&
10498 vport->rcv_flogi_cnt >= 1) {
10505 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
10510 lpfc_disc_state_machine(vport, ndlp, NULL,
10514 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10516 did, vport->port_state, ndlp->nlp_flag);
10519 lpfc_send_els_event(vport, ndlp, payload);
10520 if (vport->port_state < LPFC_DISC_AUTH) {
10525 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO);
10527 lpfc_disc_state_machine(vport, ndlp, NULL,
10531 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10533 did, vport->port_state, ndlp->nlp_flag);
10536 lpfc_send_els_event(vport, ndlp, payload);
10537 if (vport->port_state < LPFC_DISC_AUTH) {
10542 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO);
10546 lpfc_els_rcv_lcb(vport, elsiocb, ndlp);
10550 lpfc_els_rcv_rdp(vport, elsiocb, ndlp);
10554 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
10556 lpfc_disc_state_machine(vport, ndlp, NULL,
10560 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10562 did, vport->port_state, ndlp->nlp_flag);
10564 lpfc_send_els_event(vport, ndlp, payload);
10566 if (vport->port_state < LPFC_DISC_AUTH) {
10571 lpfc_disc_state_machine(vport, ndlp, elsiocb,
10575 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10577 did, vport->port_state, ndlp->nlp_flag);
10580 if (vport->port_state < LPFC_DISC_AUTH) {
10585 lpfc_disc_state_machine(vport, ndlp, elsiocb,
10589 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10591 did, vport->port_state, ndlp->nlp_flag);
10594 lpfc_els_rcv_farpr(vport, elsiocb, ndlp);
10597 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10599 did, vport->port_state, ndlp->nlp_flag);
10602 lpfc_els_rcv_farp(vport, elsiocb, ndlp);
10605 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10607 did, vport->port_state, ndlp->nlp_flag);
10610 lpfc_els_rcv_fan(vport, elsiocb, ndlp);
10614 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10616 did, vport->port_state, ndlp->nlp_flag);
10619 if ((vport->port_state < LPFC_DISC_AUTH) &&
10620 (vport->fc_flag & FC_FABRIC)) {
10625 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI);
10628 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10630 did, vport->port_state, ndlp->nlp_flag);
10633 lpfc_els_rcv_lirr(vport, elsiocb, ndlp);
10635 lpfc_disc_state_machine(vport, ndlp, NULL,
10639 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10641 did, vport->port_state, ndlp->nlp_flag);
10644 lpfc_els_rcv_rls(vport, elsiocb, ndlp);
10646 lpfc_disc_state_machine(vport, ndlp, NULL,
10650 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10652 did, vport->port_state, ndlp->nlp_flag);
10655 lpfc_els_rcv_rpl(vport, elsiocb, ndlp);
10657 lpfc_disc_state_machine(vport, ndlp, NULL,
10661 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10663 did, vport->port_state, ndlp->nlp_flag);
10666 lpfc_els_rcv_rnid(vport, elsiocb, ndlp);
10668 lpfc_disc_state_machine(vport, ndlp, NULL,
10672 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10674 did, vport->port_state, ndlp->nlp_flag);
10676 lpfc_els_rcv_rtv(vport, elsiocb, ndlp);
10678 lpfc_disc_state_machine(vport, ndlp, NULL,
10682 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10684 did, vport->port_state, ndlp->nlp_flag);
10687 lpfc_els_rcv_rrq(vport, elsiocb, ndlp);
10689 lpfc_disc_state_machine(vport, ndlp, NULL,
10693 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10695 did, vport->port_state, ndlp->nlp_flag);
10698 lpfc_els_rcv_echo(vport, elsiocb, ndlp);
10700 lpfc_disc_state_machine(vport, ndlp, NULL,
10709 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10711 did, vport->port_state, ndlp->nlp_flag);
10713 lpfc_els_rcv_fpin(vport, (struct fc_els_fpin *)payload,
10719 lpfc_els_rcv_edc(vport, elsiocb, ndlp);
10725 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
10733 lpfc_els_rcv_rdf(vport, elsiocb, ndlp);
10736 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
10738 cmd, did, vport->port_state);
10745 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10749 lpfc_disc_state_machine(vport, ndlp, NULL,
10760 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp,
10764 lpfc_disc_state_machine(vport, ndlp, NULL,
10786 mbox->vport = vport;
10795 if (vport && !(vport->load_flag & FC_UNLOADING))
10796 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10820 struct lpfc_vport *vport = elsiocb->vport;
10859 vport = phba->pport;
10861 vport = lpfc_find_vport_by_vpid(phba,
10892 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
10910 lpfc_start_fdmi(struct lpfc_vport *vport)
10918 ndlp = lpfc_findnode_did(vport, FDMI_DID);
10920 ndlp = lpfc_nlp_init(vport, FDMI_DID);
10928 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
10929 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
10935 * @vport: pointer to a virtual N_Port data structure.
10938 * State Change Request (SCR) for a @vport. This routine will create an
10939 * ndlp for the Name Server associated to the @vport if such node does
10942 * (FDMI) is configured to the @vport, a FDMI node will be created and
10946 lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
10949 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
10957 if (vport->fc_flag & FC_DISC_DELAYED) {
10959 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10962 mod_timer(&vport->delayed_disc_tmo,
10968 ndlp = lpfc_findnode_did(vport, NameServer_DID);
10970 ndlp = lpfc_nlp_init(vport, NameServer_DID);
10973 lpfc_disc_start(vport);
10976 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
10977 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10985 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
10987 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) {
10988 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
10989 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10996 (vport->load_flag & FC_ALLOW_FDMI))
10997 lpfc_start_fdmi(vport);
11001 * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport
11005 * This routine is the completion callback function to register new vport
11006 * mailbox command. If the new vport mailbox command completes successfully,
11008 * new vport created is actually a physical port, with VPI 0) or the port
11015 struct lpfc_vport *vport = pmb->vport;
11016 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11022 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
11026 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11038 /* giving up on vport registration */
11039 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
11041 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
11043 lpfc_can_disctmo(vport);
11048 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
11050 lpfc_init_vpi(phba, pmb, vport->vpi);
11051 pmb->vport = vport;
11056 lpfc_printf_vlog(vport, KERN_ERR,
11068 lpfc_sli4_unreg_all_rpis(vport);
11069 lpfc_mbx_unreg_vpi(vport);
11071 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
11075 if ((vport->port_type == LPFC_PHYSICAL_PORT) &&
11076 !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) {
11078 lpfc_issue_init_vfi(vport);
11080 lpfc_initial_flogi(vport);
11082 lpfc_initial_fdisc(vport);
11088 vport->vpi_state |= LPFC_VPI_REGISTERED;
11090 if (vport == phba->pport) {
11092 lpfc_issue_fabric_reglogin(vport);
11096 * FDISC, do not start vport discovery.
11098 if (vport->port_state != LPFC_FDISC)
11100 lpfc_do_scr_ns_plogi(phba, vport);
11103 lpfc_do_scr_ns_plogi(phba, vport);
11115 * this is specifically for vport
11118 lpfc_reinit_vmid(vport);
11119 vport->vmid_flag = vport->phba->pport->vmid_flag;
11125 * lpfc_register_new_vport - Register a new vport with a HBA
11127 * @vport: pointer to a host virtual N_Port data structure.
11130 * This routine registers the @vport as a new virtual port with a HBA.
11134 lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
11137 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11142 lpfc_reg_vpi(vport, mbox);
11143 mbox->vport = vport;
11159 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11164 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11171 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
11173 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
11179 * lpfc_cancel_all_vport_retry_delay_timer - Cancel all vport retry delay timer
11275 * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the
11276 * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID
11277 * assigned to the vport has been changed with the completion of the FDISC
11280 * routine is invoked to register new vport with the HBA. Otherwise, the
11288 struct lpfc_vport *vport = cmdiocb->vport;
11289 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11302 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
11305 vport->fc_prevDID);
11311 lpfc_set_disctmo(piocb->vport);
11314 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
11316 ulp_status, ulp_word4, vport->fc_prevDID);
11329 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11335 lpfc_check_nlp_post_devloss(vport, ndlp);
11338 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
11339 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
11340 vport->fc_flag |= FC_FABRIC;
11341 if (vport->phba->fc_topology == LPFC_TOPOLOGY_LOOP)
11342 vport->fc_flag |= FC_PUBLIC_LOOP;
11345 vport->fc_myDID = ulp_word4 & Mask_DID;
11346 lpfc_vport_set_state(vport, FC_VPORT_ACTIVE);
11351 fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp);
11352 memcpy(&vport->fabric_portname, &sp->portName,
11354 memcpy(&vport->fabric_nodename, &sp->nodeName,
11357 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
11363 &vport->fc_nodes, nlp_listp) {
11370 lpfc_unreg_rpi(vport, np);
11372 lpfc_cleanup_pending_mbox(vport);
11375 lpfc_sli4_unreg_all_rpis(vport);
11377 lpfc_mbx_unreg_vpi(vport);
11379 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
11381 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
11383 vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG;
11386 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
11391 lpfc_register_new_vport(phba, vport, ndlp);
11392 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
11396 if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)
11397 lpfc_issue_init_vpi(vport);
11398 else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
11399 lpfc_register_new_vport(phba, vport, ndlp);
11401 lpfc_do_scr_ns_plogi(phba, vport);
11406 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
11410 if (vport->fc_vport &&
11411 (vport->fc_vport->vport_state != FC_VPORT_NO_FABRIC_RSCS))
11412 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
11414 lpfc_can_disctmo(vport);
11422 * @vport: pointer to a virtual N_Port data structure.
11427 * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb()
11440 lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
11443 struct lpfc_hba *phba = vport->phba;
11453 vport->port_state = LPFC_FDISC;
11454 vport->fc_myDID = 0;
11456 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
11459 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
11460 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11480 memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm));
11494 memcpy(pcmd, &vport->fc_portname, 8);
11497 memcpy(pcmd, &vport->fc_nodename, 8);
11500 lpfc_set_disctmo(vport);
11505 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
11519 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING);
11524 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
11525 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11531 * lpfc_cmpl_els_npiv_logo - Completion function with vport logo
11537 * ELS command off a vport. It frees the command IOCB and then decrement the
11548 struct lpfc_vport *vport = cmdiocb->vport;
11551 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11568 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
11573 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
11577 tmo, vport->num_disc_nodes,
11583 vport->fc_flag &= ~FC_NDISC_ACTIVE;
11584 vport->fc_flag &= ~FC_FABRIC;
11586 lpfc_can_disctmo(vport);
11605 * lpfc_issue_els_npiv_logo - Issue a logo off a vport
11606 * @vport: pointer to a virtual N_Port data structure.
11609 * This routine issues a LOGO ELS command to an @ndlp off a @vport.
11616 * 0 - Successfully issued logo off the @vport
11617 * 1 - Failed to issue logo off the @vport
11620 lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
11623 struct lpfc_hba *phba = vport->phba;
11629 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID,
11639 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
11641 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
11643 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
11735 lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD,
11737 iocb->vport->port_state, 0, 0);
11900 lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD,
11902 iocb->vport->port_state, 0, 0);
11922 * lpfc_fabric_abort_vport - Abort a vport's iocbs from driver fabric iocb list
11923 * @vport: pointer to a virtual N_Port data structure.
11925 * This routine aborts all the IOCBs associated with a @vport from the
11928 * list, removes each IOCB associated with the @vport off the list, set the
11932 static void lpfc_fabric_abort_vport(struct lpfc_vport *vport)
11935 struct lpfc_hba *phba = vport->phba;
11942 if (piocb->vport != vport)
12017 * lpfc_sli4_vport_delete_els_xri_aborted -Remove all ndlp references for vport
12018 * @vport: pointer to lpfc vport data structure.
12020 * This routine is invoked by the vport cleanup for deletions and the cleanup
12024 lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *vport)
12026 struct lpfc_hba *phba = vport->phba;
12034 if (sglq_entry->ndlp && sglq_entry->ndlp->vport == vport) {
12040 * node and the vport is unloading, the xri aborted wcqe
12043 if ((vport->load_flag & FC_UNLOADING) &&
12122 * @vport: pointer to virtual port object.
12131 lpfc_sli_abts_recover_port(struct lpfc_vport *vport,
12138 shost = lpfc_shost_from_vport(vport);
12139 phba = vport->phba;
12151 vport->vpi, ndlp->nlp_rpi, ndlp->nlp_state,
12161 lpfc_unreg_rpi(vport, ndlp);
12164 static void lpfc_init_cs_ctl_bitmap(struct lpfc_vport *vport)
12166 bitmap_zero(vport->vmid_priority_range, LPFC_VMID_MAX_PRIORITY_RANGE);
12170 lpfc_vmid_set_cs_ctl_range(struct lpfc_vport *vport, u32 min, u32 max)
12178 set_bit(i, vport->vmid_priority_range);
12181 static void lpfc_vmid_put_cs_ctl(struct lpfc_vport *vport, u32 ctcl_vmid)
12183 set_bit(ctcl_vmid, vport->vmid_priority_range);
12186 u32 lpfc_vmid_get_cs_ctl(struct lpfc_vport *vport)
12190 i = find_first_bit(vport->vmid_priority_range,
12196 clear_bit(i, vport->vmid_priority_range);
12206 struct lpfc_vport *vport = cmdiocb->vport;
12225 lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI,
12231 lpfc_printf_vlog(vport, KERN_ERR, LOG_SLI,
12237 if (!vport->qfpa_res) {
12238 max_desc = FCELSSIZE / sizeof(*vport->qfpa_res);
12239 vport->qfpa_res = kcalloc(max_desc, sizeof(*vport->qfpa_res),
12241 if (!vport->qfpa_res)
12247 memcpy(vport->qfpa_res, pcmd, len + 8);
12251 vmid_range = vport->vmid_priority.vmid_range;
12256 kfree(vport->qfpa_res);
12259 vport->vmid_priority.vmid_range = vmid_range;
12261 vport->vmid_priority.num_descriptors = len;
12264 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_ELS,
12274 vport->vmid_flag |= LPFC_VMID_QOS_ENABLED;
12282 lpfc_init_cs_ctl_bitmap(vport);
12283 for (i = 0; i < vport->vmid_priority.num_descriptors; i++) {
12284 lpfc_vmid_set_cs_ctl_range(vport,
12285 vport->vmid_priority.vmid_range[i].low,
12286 vport->vmid_priority.vmid_range[i].high);
12289 vport->vmid_flag |= LPFC_VMID_QFPA_CMPL;
12295 int lpfc_issue_els_qfpa(struct lpfc_vport *vport)
12297 struct lpfc_hba *phba = vport->phba;
12307 elsiocb = lpfc_prep_els_iocb(vport, 1, LPFC_QFPA_SIZE, 2, ndlp,
12321 lpfc_els_free_iocb(vport->phba, elsiocb);
12331 vport->vmid_flag &= ~LPFC_VMID_QOS_ENABLED;
12336 lpfc_vmid_uvem(struct lpfc_vport *vport,
12348 ndlp = lpfc_findnode_did(vport, Fabric_DID);
12355 elsiocb = lpfc_prep_els_iocb(vport, 1, LPFC_UVEM_SIZE, 2,
12360 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_ELS,
12369 if (!memchr_inv(vport->lpfc_vmid_host_uuid, 0,
12370 sizeof(vport->lpfc_vmid_host_uuid)))
12371 memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid,
12372 sizeof(vport->lpfc_vmid_host_uuid));
12381 memcpy(vem_id_desc->vem_id, vport->lpfc_vmid_host_uuid,
12390 bf_set(lpfc_instantiated_nport_id, inst_desc, vport->fc_myDID);
12397 lpfc_vmid_put_cs_ctl(vport, vmid->un.cs_ctl_vmid);
12405 lpfc_els_free_iocb(vport->phba, elsiocb);
12409 ret = lpfc_sli_issue_iocb(vport->phba, LPFC_ELS_RING, elsiocb, 0);
12411 lpfc_els_free_iocb(vport->phba, elsiocb);
12426 struct lpfc_vport *vport = icmdiocb->vport;
12448 lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI,
12453 lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI,
12460 vport->vmid_flag |= LPFC_VMID_IN_USE;
12465 write_lock(&vport->vmid_lock);
12468 write_unlock(&vport->vmid_lock);