Lines Matching refs:vport

53 static void lpfc_fabric_abort_vport(struct lpfc_vport *vport);
54 static int lpfc_issue_els_fdisc(struct lpfc_vport *vport,
62 * lpfc_els_chk_latt - Check host link attention event for a vport
63 * @vport: pointer to a host virtual N_Port data structure.
66 * attention event during the discovery process with the @vport. It is done
68 * link attention events during this @vport's discovery process, the @vport
74 * Note that, if either the host link is in state LPFC_LINK_DOWN or @vport
84 lpfc_els_chk_latt(struct lpfc_vport *vport)
86 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
87 struct lpfc_hba *phba = vport->phba;
90 if (vport->port_state >= LPFC_VPORT_READY ||
103 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
115 vport->fc_flag |= FC_ABORT_DISCOVERY;
119 lpfc_issue_clear_la(phba, vport);
126 * @vport: pointer to a host virtual N_Port data structure.
153 lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
158 struct lpfc_hba *phba = vport->phba;
270 (vport->fc_flag & FC_PT2PT))) {
273 icmd->un.elsreq64.myID = vport->fc_myDID;
276 icmd->ulpContext = phba->vpi_ids[vport->vpi];
310 elsiocb->vport = vport;
318 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
323 vport->port_state, ndlp->nlp_rpi,
324 vport->fc_flag);
327 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
332 cmdSize, vport->port_state,
333 ndlp->nlp_rpi, vport->fc_flag);
353 * lpfc_issue_fabric_reglogin - Issue fabric registration login for a vport
354 * @vport: pointer to a host virtual N_Port data structure.
356 * This routine issues a fabric registration login for a @vport. An
357 * active ndlp node with Fabric_DID must already exist for this @vport.
360 * HBA to perform link configuration for the @vport; and the second mailbox
362 * with the @vport.
365 * 0 - successfully issued fabric registration login for @vport
366 * -ENXIO -- failed to issue fabric registration login for @vport
369 lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)
371 struct lpfc_hba *phba = vport->phba;
380 ndlp = lpfc_findnode_did(vport, Fabric_DID);
392 vport->port_state = LPFC_FABRIC_CFG_LINK;
395 mbox->vport = vport;
408 rc = lpfc_reg_rpi(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox,
416 mbox->vport = vport;
442 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
443 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
450 * lpfc_issue_reg_vfi - Register VFI for this vport's fabric login
451 * @vport: pointer to a host virtual N_Port data structure.
454 * the @vport. This mailbox command is necessary for SLI4 port only.
457 * 0 - successfully issued REG_VFI for @vport
461 lpfc_issue_reg_vfi(struct lpfc_vport *vport)
463 struct lpfc_hba *phba = vport->phba;
472 !(vport->fc_flag & FC_PT2PT)) {
473 ndlp = lpfc_findnode_did(vport, Fabric_DID);
487 if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) {
502 vport->port_state = LPFC_FABRIC_CFG_LINK;
504 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);
506 lpfc_reg_vfi(mboxq, vport, 0);
509 mboxq->vport = vport;
527 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
528 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
534 * lpfc_issue_unreg_vfi - Unregister VFI for this vport's fabric login
535 * @vport: pointer to a host virtual N_Port data structure.
538 * the @vport. This mailbox command is necessary for SLI4 port only.
541 * 0 - successfully issued REG_VFI for @vport
545 lpfc_issue_unreg_vfi(struct lpfc_vport *vport)
547 struct lpfc_hba *phba = vport->phba;
560 lpfc_unreg_vfi(mboxq, vport);
561 mboxq->vport = vport;
574 shost = lpfc_shost_from_vport(vport);
576 vport->fc_flag &= ~FC_VFI_REGISTERED;
583 * @vport: pointer to a host virtual N_Port data structure.
589 * 0. This function also set flag in the vport data structure to delay
600 lpfc_check_clean_addr_bit(struct lpfc_vport *vport,
603 struct lpfc_hba *phba = vport->phba;
605 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
607 if ((vport->fc_prevDID != vport->fc_myDID) ||
608 memcmp(&vport->fabric_portname, &sp->portName,
610 memcmp(&vport->fabric_nodename, &sp->nodeName,
612 (vport->vport_flag & FAWWPN_PARAM_CHG)) {
614 vport->vport_flag &= ~FAWWPN_PARAM_CHG;
623 * - vport->fc_prevDID != 0 (not initial discovery) OR
627 (vport->fc_prevDID || phba->cfg_delay_discovery)) {
629 vport->fc_flag |= FC_DISC_DELAYED;
639 * @vport: pointer to a host virtual N_Port data structure.
648 * @vport against the previously assigned N_Port ID. If it is different from
650 * is invoked on all the remaining nodes with the @vport to unregister the
658 lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
661 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
662 struct lpfc_hba *phba = vport->phba;
668 vport->fc_flag |= FC_FABRIC;
680 vport->fc_flag |= FC_PUBLIC_LOOP;
684 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID;
699 fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp);
705 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
707 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
709 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
711 vport->fdmi_hba_mask = 0;
712 vport->fdmi_port_mask = 0;
716 memcpy(&vport->fabric_portname, &sp->portName,
718 memcpy(&vport->fabric_nodename, &sp->nodeName,
724 lpfc_printf_vlog(vport, KERN_WARNING,
735 lpfc_printf_vlog(vport, KERN_WARNING,
756 if (vport->fc_flag & FC_VFI_REGISTERED)
757 lpfc_issue_reg_vfi(vport);
761 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
767 &vport->fc_nodes, nlp_listp) {
776 lpfc_unreg_rpi(vport, np);
778 lpfc_cleanup_pending_mbox(vport);
781 lpfc_sli4_unreg_all_rpis(vport);
782 lpfc_mbx_unreg_vpi(vport);
784 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
793 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
796 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
801 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
802 lpfc_register_new_vport(phba, vport, ndlp);
807 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
809 vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
810 lpfc_register_new_vport(phba, vport, ndlp);
812 lpfc_issue_fabric_reglogin(vport);
815 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
816 if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) &&
817 (vport->vpi_state & LPFC_VPI_REGISTERED)) {
819 lpfc_do_scr_ns_plogi(phba, vport);
820 } else if (vport->fc_flag & FC_VFI_REGISTERED)
821 lpfc_issue_init_vpi(vport);
823 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
825 vport->fc_prevDID, vport->fc_myDID);
826 lpfc_issue_reg_vfi(vport);
834 * @vport: pointer to a host virtual N_Port data structure.
840 * in a point-to-point topology. First, the @vport's N_Port Name is compared
841 * with the received N_Port Name: if the @vport's N_Port Name is greater than
853 lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
856 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
857 struct lpfc_hba *phba = vport->phba;
862 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
863 vport->fc_flag |= FC_PT2PT;
874 vport->fc_flag &= ~FC_VFI_REGISTERED;
879 rc = memcmp(&vport->fc_portname, &sp->portName,
880 sizeof(vport->fc_portname));
885 vport->fc_flag |= FC_PT2PT_PLOGI;
895 vport->fc_myDID = PT2PT_LocalID;
902 ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID);
908 ndlp = lpfc_nlp_init(vport, PT2PT_RemoteID);
912 ndlp = lpfc_enable_node(vport, ndlp,
923 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
935 mbox->vport = vport;
949 lpfc_disc_start(vport);
984 struct lpfc_vport *vport = cmdiocb->vport;
985 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
994 if (lpfc_els_chk_latt(vport)) {
1002 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1005 vport->port_state);
1035 rc = lpfc_sli4_fcf_rr_next_proc(vport, fcf_index);
1045 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1056 lpfc_printf_vlog(vport, KERN_WARNING, LOG_TRACE_EVENT,
1070 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP |
1079 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
1081 (!(vport->fc_flag & FC_VFI_REGISTERED) ||
1082 (vport->fc_prevDID != vport->fc_myDID) ||
1084 if (vport->fc_flag & FC_VFI_REGISTERED) {
1088 vport->fc_flag &= ~FC_VFI_REGISTERED;
1092 lpfc_sli4_unreg_all_rpis(vport);
1098 lpfc_issue_reg_vfi(vport);
1105 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
1106 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
1119 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1125 vport->port_state, vport->fc_flag);
1127 if (vport->port_state == LPFC_FLOGI) {
1133 rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp);
1135 rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp);
1137 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1171 lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP |
1183 } else if (vport->port_state > LPFC_FLOGI &&
1184 vport->fc_flag & FC_PT2PT) {
1203 lpfc_disc_list_loopmap(vport);
1206 lpfc_disc_start(vport);
1214 lpfc_issue_clear_la(phba, vport);
1254 * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport
1255 * @vport: pointer to a host virtual N_Port data structure.
1260 * for a @vport. The initiator service parameters are put into the payload
1272 * 0 - successfully issued flogi iocb for @vport
1273 * 1 - failed to issue flogi iocb for @vport
1276 lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1279 struct lpfc_hba *phba = vport->phba;
1290 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1302 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
1347 lpfc_set_disctmo(vport);
1353 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1363 did = vport->fc_myDID;
1364 vport->fc_myDID = Fabric_DID;
1372 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1379 lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, &defer_flogi_acc,
1384 vport->fc_myDID = did;
1445 * lpfc_initial_flogi - Issue an initial fabric login for a vport
1446 * @vport: pointer to a host virtual N_Port data structure.
1448 * This routine issues an initial Fabric Login (FLOGI) for the @vport
1450 * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and
1451 * put it into the @vport's ndlp list. If an inactive ndlp found on the list,
1453 * is then invoked with the @vport and the ndlp to perform the FLOGI for the
1454 * @vport.
1457 * 0 - failed to issue initial flogi for @vport
1458 * 1 - successfully issued initial flogi for @vport
1461 lpfc_initial_flogi(struct lpfc_vport *vport)
1465 vport->port_state = LPFC_FLOGI;
1466 lpfc_set_disctmo(vport);
1469 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1472 ndlp = lpfc_nlp_init(vport, Fabric_DID);
1478 lpfc_enqueue_node(vport, ndlp);
1481 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
1486 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
1497 * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport
1498 * @vport: pointer to a host virtual N_Port data structure.
1500 * This routine issues an initial Fabric Discover (FDISC) for the @vport
1502 * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and
1503 * put it into the @vport's ndlp list. If an inactive ndlp found on the list,
1505 * is then invoked with the @vport and the ndlp to perform the FDISC for the
1506 * @vport.
1509 * 0 - failed to issue initial fdisc for @vport
1510 * 1 - successfully issued initial fdisc for @vport
1513 lpfc_initial_fdisc(struct lpfc_vport *vport)
1518 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1521 ndlp = lpfc_nlp_init(vport, Fabric_DID);
1525 lpfc_enqueue_node(vport, ndlp);
1528 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
1533 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
1544 * lpfc_more_plogi - Check and issue remaining plogis for a vport
1545 * @vport: pointer to a host virtual N_Port data structure.
1548 * (PLOGI) to be issued for the @vport. If so, it will invoke the routine
1551 * @vport (@vport->cfg_discovery_threads). The function also decrement
1552 * the @vport's num_disc_node by 1 if it is not already 0.
1555 lpfc_more_plogi(struct lpfc_vport *vport)
1557 if (vport->num_disc_nodes)
1558 vport->num_disc_nodes--;
1561 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1564 vport->num_disc_nodes, vport->fc_plogi_cnt,
1565 vport->fc_flag, vport->port_state);
1567 if (vport->fc_flag & FC_NLP_MORE)
1569 lpfc_els_disc_plogi(vport);
1583 * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches
1584 * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but
1587 * 1) if there is a node on vport list other than the @ndlp with the same
1590 * no node found on vport list with the same WWPN of the N_Port PLOGI logged
1593 * be released and the new_ndlp shall be put on to the vport node list and
1597 * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID
1599 * into an inactive state on the vport node list and the vport node list
1609 struct lpfc_vport *vport = ndlp->vport;
1610 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1637 new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName);
1651 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_NODE,
1668 new_ndlp = lpfc_nlp_init(vport, ndlp->nlp_DID);
1684 new_ndlp = lpfc_enable_node(vport, new_ndlp,
1711 if (vport->fc_flag & FC_FABRIC) {
1716 lpfc_unreg_rpi(vport, new_ndlp);
1759 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
1770 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1809 lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
1817 lpfc_drop_node(vport, ndlp);
1820 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1824 lpfc_unreg_rpi(vport, ndlp);
1845 lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
1874 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_NODE,
1883 * lpfc_end_rscn - Check and handle more rscn for a vport
1884 * @vport: pointer to a host virtual N_Port data structure.
1889 * invoked to handle the additional RSCNs for the @vport. Otherwise, the
1890 * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of
1894 lpfc_end_rscn(struct lpfc_vport *vport)
1896 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1898 if (vport->fc_flag & FC_RSCN_MODE) {
1903 if (vport->fc_rscn_id_cnt ||
1904 (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
1905 lpfc_els_handle_rscn(vport);
1908 vport->fc_flag &= ~FC_RSCN_MODE;
1930 struct lpfc_vport *vport = cmdiocb->vport;
1940 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1945 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID);
1947 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
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);
2017 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2022 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID);
2024 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2042 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2047 disc, vport->num_disc_nodes);
2050 if (lpfc_els_chk_latt(vport)) {
2068 /* PLOGI failed Don't print the vport to vport rjts */
2073 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2079 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2087 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2091 if (disc && vport->num_disc_nodes) {
2093 lpfc_more_plogi(vport);
2095 if (vport->num_disc_nodes == 0) {
2097 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2100 lpfc_can_disctmo(vport);
2101 lpfc_end_rscn(vport);
2111 * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport
2112 * @vport: pointer to a host virtual N_Port data structure.
2117 * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port,
2118 * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list.
2128 * 0 - Successfully issued a plogi for @vport
2129 * 1 - failed to issue a plogi for @vport
2132 lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry)
2134 struct lpfc_hba *phba = vport->phba;
2143 ndlp = lpfc_findnode_did(vport, did);
2152 !(vport->fc_flag & FC_OFFLINE_MODE)) {
2153 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2170 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
2175 shost = lpfc_shost_from_vport(vport);
2185 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
2192 if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP))
2205 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2246 struct lpfc_vport *vport = cmdiocb->vport;
2247 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2262 vport->fc_prli_sent--;
2266 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2272 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2276 vport->num_disc_nodes, ndlp->fc4_prli_sent);
2279 if (lpfc_els_chk_latt(vport))
2292 if ((vport->fc_flag & FC_FABRIC) ||
2293 (vport->cfg_enable_fc4_type != LPFC_ENABLE_BOTH)) {
2302 lpfc_printf_vlog(vport, mode, loglevel,
2312 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2320 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2330 * lpfc_issue_els_prli - Issue a prli iocb command for a vport
2331 * @vport: pointer to a host virtual N_Port data structure.
2336 * @vport. The PRLI service parameters are set up in the payload of the
2347 * 0 - successfully issued prli iocb command for @vport
2348 * 1 - failed to issue prli iocb command for @vport
2351 lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2354 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2355 struct lpfc_hba *phba = vport->phba;
2370 vport->fc_flag & FC_RSCN_MODE &&
2371 vport->nvmei_support)
2394 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2405 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2408 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
2412 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2443 if (vport->cfg_first_burst_size)
2489 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2498 /* The vport counters are used for lpfc_scan_finished, but
2502 vport->fc_prli_sent++;
2526 * lpfc_rscn_disc - Perform rscn discovery for a vport
2527 * @vport: pointer to a host virtual N_Port data structure.
2530 * discovery for a @vport. If the @vport's node port recovery count is not
2538 lpfc_rscn_disc(struct lpfc_vport *vport)
2540 lpfc_can_disctmo(vport);
2544 if (vport->fc_npr_cnt)
2545 if (lpfc_els_disc_plogi(vport))
2548 lpfc_end_rscn(vport);
2553 * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs.
2562 lpfc_adisc_done(struct lpfc_vport *vport)
2564 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2565 struct lpfc_hba *phba = vport->phba;
2572 !(vport->fc_flag & FC_RSCN_MODE) &&
2582 lpfc_issue_clear_la(phba, vport);
2583 lpfc_issue_reg_vpi(phba, vport);
2590 if (vport->port_state < LPFC_VPORT_READY) {
2592 lpfc_issue_clear_la(phba, vport);
2593 if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) {
2594 vport->num_disc_nodes = 0;
2596 if (vport->fc_npr_cnt)
2597 lpfc_els_disc_plogi(vport);
2598 if (!vport->num_disc_nodes) {
2600 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2602 lpfc_can_disctmo(vport);
2603 lpfc_end_rscn(vport);
2606 vport->port_state = LPFC_VPORT_READY;
2608 lpfc_rscn_disc(vport);
2613 * @vport: pointer to a host virtual N_Port data structure.
2615 * This routine determines whether there are more ndlps on a @vport
2617 * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's
2621 lpfc_more_adisc(struct lpfc_vport *vport)
2623 if (vport->num_disc_nodes)
2624 vport->num_disc_nodes--;
2626 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2629 vport->num_disc_nodes, vport->fc_adisc_cnt,
2630 vport->fc_flag, vport->port_state);
2632 if (vport->fc_flag & FC_NLP_MORE) {
2633 lpfc_set_disctmo(vport);
2635 lpfc_els_disc_adisc(vport);
2637 if (!vport->num_disc_nodes)
2638 lpfc_adisc_done(vport);
2662 struct lpfc_vport *vport = cmdiocb->vport;
2663 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2674 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2687 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2691 irsp->ulpTimeout, disc, vport->num_disc_nodes);
2693 if (lpfc_els_chk_latt(vport)) {
2708 lpfc_set_disctmo(vport);
2713 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2719 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2723 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2727 if (disc && vport->num_disc_nodes)
2728 lpfc_more_adisc(vport);
2735 * lpfc_issue_els_adisc - Issue an address discover iocb to an node on a vport
2736 * @vport: pointer to a virtual N_Port data structure.
2741 * @vport. It prepares the payload of the ADISC ELS command, updates the
2755 lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2758 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2759 struct lpfc_hba *phba = vport->phba;
2766 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2780 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
2781 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
2782 ap->DID = be32_to_cpu(vport->fc_myDID);
2784 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2821 struct lpfc_vport *vport = ndlp->vport;
2822 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2836 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2842 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2846 irsp->ulpTimeout, vport->num_disc_nodes);
2848 if (lpfc_els_chk_latt(vport)) {
2858 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2871 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2883 lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO);
2888 if ((vport->fc_flag & FC_PT2PT) &&
2889 !(vport->fc_flag & FC_PT2PT_PLOGI)) {
2892 if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
2893 (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
2904 mbox->vport = vport;
2920 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2925 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2930 vport->num_disc_nodes);
2931 lpfc_disc_start(vport);
2937 * lpfc_issue_els_logo - Issue a logo to an node on a vport
2938 * @vport: pointer to a virtual N_Port data structure.
2943 * to a remote node, referred by an @ndlp on a @vport. It constructs the
2959 lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2962 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2963 struct lpfc_hba *phba = vport->phba;
2977 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2987 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
2989 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
2991 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3013 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
3036 struct lpfc_vport *vport = cmdiocb->vport;
3041 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3047 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3053 lpfc_els_chk_latt(vport);
3072 struct lpfc_vport *vport = cmdiocb->vport;
3081 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3086 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3110 lpfc_issue_els_scr(vport, cmdiocb->retry);
3114 lpfc_issue_els_rdf(vport, cmdiocb->retry);
3123 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
3145 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3154 lpfc_els_chk_latt(vport);
3160 * lpfc_issue_els_scr - Issue a scr to an node on a vport
3161 * @vport: pointer to a host virtual N_Port data structure.
3165 * on a @vport. The remote node is Fabric Controller (0xfffffd). It
3166 * first search the @vport node list to find the matching ndlp. If no such
3181 lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry)
3183 struct lpfc_hba *phba = vport->phba;
3191 ndlp = lpfc_findnode_did(vport, Fabric_Cntl_DID);
3193 ndlp = lpfc_nlp_init(vport, Fabric_Cntl_DID);
3196 lpfc_enqueue_node(vport, ndlp);
3198 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
3203 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3223 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3242 if (!(vport->fc_flag & FC_PT2PT))
3250 * @vport: pointer to a host virtual N_Port data structure.
3268 lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry)
3270 struct lpfc_hba *phba = vport->phba;
3282 !(vport->fc_flag & FC_PUBLIC_LOOP))
3285 if (vport->fc_flag & FC_PT2PT) {
3287 ndlp = lpfc_findnode_mapped(vport);
3293 ndlp = lpfc_findnode_did(vport, nportid);
3296 ndlp = lpfc_nlp_init(vport, nportid);
3299 lpfc_enqueue_node(vport, ndlp);
3301 ndlp = lpfc_enable_node(vport, ndlp,
3308 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3325 nportid = vport->fc_myDID;
3332 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3351 if (!(vport->fc_flag & FC_PT2PT))
3358 * lpfc_issue_els_farpr - Issue a farp to an node on a vport
3359 * @vport: pointer to a host virtual N_Port data structure.
3364 * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid)
3365 * is passed into the function. It first search the @vport node list to find
3380 lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry)
3382 struct lpfc_hba *phba = vport->phba;
3393 ndlp = lpfc_findnode_did(vport, nportid);
3395 ndlp = lpfc_nlp_init(vport, nportid);
3398 lpfc_enqueue_node(vport, ndlp);
3400 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
3405 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3425 *lp++ = be32_to_cpu(vport->fc_myDID);
3429 memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name));
3430 memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
3431 ondlp = lpfc_findnode_did(vport, nportid);
3439 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3464 * @vport: pointer to a host virtual N_Port data structure.
3480 lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
3482 struct lpfc_hba *phba = vport->phba;
3490 ndlp = lpfc_findnode_did(vport, Fabric_Cntl_DID);
3492 ndlp = lpfc_nlp_init(vport, Fabric_Cntl_DID);
3495 lpfc_enqueue_node(vport, ndlp);
3497 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
3503 if (vport->port_type == LPFC_NPIV_PORT) {
3508 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3534 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3538 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3563 * @vport: pointer to a host virtual N_Port data structure.
3567 * a @vport's @ndlp. It stops the timer for the delayed function retrial and
3570 * commands are sent for the @vport's nodes that require issuing discovery
3574 lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
3576 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3596 if (vport->num_disc_nodes) {
3597 if (vport->port_state < LPFC_VPORT_READY) {
3599 lpfc_more_adisc(vport);
3602 lpfc_more_plogi(vport);
3603 if (vport->num_disc_nodes == 0) {
3605 vport->fc_flag &= ~FC_NDISC_ACTIVE;
3607 lpfc_can_disctmo(vport);
3608 lpfc_end_rscn(vport);
3634 struct lpfc_vport *vport = ndlp->vport;
3635 struct lpfc_hba *phba = vport->phba;
3670 struct lpfc_vport *vport = ndlp->vport;
3671 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3696 lpfc_issue_els_flogi(vport, ndlp, retry);
3699 if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) {
3701 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
3705 if (!lpfc_issue_els_adisc(vport, ndlp, retry)) {
3707 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
3712 if (!lpfc_issue_els_prli(vport, ndlp, retry)) {
3714 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
3718 if (!lpfc_issue_els_logo(vport, ndlp, retry)) {
3720 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
3724 if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI))
3725 lpfc_issue_els_fdisc(vport, ndlp, retry);
3733 * @vport: pointer to a virtual N_Port data structure.
3744 lpfc_link_reset(struct lpfc_vport *vport)
3746 struct lpfc_hba *phba = vport->phba;
3751 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3774 mbox->vport = vport;
3812 struct lpfc_vport *vport = cmdiocb->vport;
3813 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3840 ndlp = lpfc_findnode_did(vport, did);
3846 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3881 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
3949 if ((vport->fc_flag & FC_PT2PT) &&
3956 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
3962 vport->fc_flag |= FC_PT2PT_NO_NVME;
4012 lpfc_printf_vlog(vport, KERN_ERR,
4017 lpfc_vport_set_state(vport,
4050 vport->fc_sparam.cmn.bbRcvSizeMsb &= 0xf;
4052 lpfc_printf_vlog(vport, KERN_ERR,
4066 lpfc_printf_vlog(vport, KERN_ERR,
4071 lpfc_vport_set_state(vport,
4108 rc = lpfc_link_reset(vport);
4141 maxretry = vport->cfg_devloss_tmo;
4151 if ((vport->load_flag & FC_UNLOADING) != 0)
4159 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4169 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4181 if (timer_pending(&vport->fc_disctmo) ||
4182 (vport->fc_flag & FC_RSCN_MODE))
4183 lpfc_set_disctmo(vport);
4201 lpfc_nlp_set_state(vport, ndlp,
4204 lpfc_nlp_set_state(vport, ndlp,
4212 lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry);
4215 lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry);
4220 lpfc_nlp_set_state(vport, ndlp,
4223 lpfc_issue_els_plogi(vport, did, cmdiocb->retry);
4227 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
4228 lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry);
4233 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
4234 lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry);
4238 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
4239 lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry);
4245 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
4252 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4430 struct lpfc_vport *vport = cmdiocb->vport;
4434 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
4438 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4450 lpfc_unreg_rpi(vport, ndlp);
4492 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
4505 lpfc_drop_node(ndlp->vport, ndlp);
4533 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
4534 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
4543 if (!vport) {
4565 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || lpfc_els_chk_latt(vport)) {
4587 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
4592 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4602 if (!lpfc_unreg_rpi(vport, ndlp) &&
4603 (!(vport->fc_flag & FC_PT2PT)) &&
4606 lpfc_printf_vlog(vport, KERN_INFO,
4626 mbox->vport = vport;
4634 lpfc_nlp_set_state(vport, ndlp,
4650 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
4715 * @vport: pointer to a host virtual N_Port data structure.
4739 lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
4743 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4744 struct lpfc_hba *phba = vport->phba;
4759 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
4775 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
4782 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
4814 memcpy(&sp->portName, &vport->fc_sparam.portName,
4816 memcpy(&sp->nodeName, &vport->fc_sparam.nodeName,
4819 memcpy(pcmd, &vport->fc_sparam,
4838 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
4844 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
4860 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
4889 * @vport: pointer to a virtual N_Port data structure.
4910 lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
4914 struct lpfc_hba *phba = vport->phba;
4923 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
4942 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4949 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
4966 * @vport: pointer to a virtual N_Port data structure.
4984 lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
4987 struct lpfc_hba *phba = vport->phba;
4996 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
5007 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5020 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
5021 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
5022 ap->DID = be32_to_cpu(vport->fc_myDID);
5024 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5037 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5043 ndlp->nlp_rpi, vport->fc_flag);
5049 * @vport: pointer to a virtual N_Port data structure.
5067 lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
5070 struct lpfc_hba *phba = vport->phba;
5093 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5107 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
5118 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5175 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
5186 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
5191 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5208 * @vport: pointer to a virtual N_Port data structure.
5233 lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
5236 struct lpfc_hba *phba = vport->phba;
5249 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
5260 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5271 memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name));
5272 memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
5280 &vport->fc_portname, sizeof(struct lpfc_name));
5291 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5308 * @vport: pointer to a virtual N_Port data structure.
5315 lpfc_els_clear_rrq(struct lpfc_vport *vport,
5318 struct lpfc_hba *phba = vport->phba;
5332 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5340 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5343 if (vport->fc_myDID == be32_to_cpu(bf_get(rrq_did, rrq)))
5347 prrq = lpfc_get_active_rrq(vport, xri, ndlp->nlp_DID);
5355 * @vport: pointer to a virtual N_Port data structure.
5365 lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data,
5368 struct lpfc_hba *phba = vport->phba;
5381 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
5390 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5398 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
5414 * lpfc_els_disc_adisc - Issue remaining adisc iocbs to npr nodes of a vport
5415 * @vport: pointer to a host virtual N_Port data structure.
5419 * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the
5420 * lpfc_issue_els_adisc() routine, the per @vport number of discover count
5422 * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will
5425 * all the ndlps with the @vport and there is none ADISC IOCB issued, the
5426 * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is
5433 lpfc_els_disc_adisc(struct lpfc_vport *vport)
5435 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5440 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
5450 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
5451 lpfc_issue_els_adisc(vport, ndlp, 0);
5453 vport->num_disc_nodes++;
5454 if (vport->num_disc_nodes >=
5455 vport->cfg_discovery_threads) {
5457 vport->fc_flag |= FC_NLP_MORE;
5465 vport->fc_flag &= ~FC_NLP_MORE;
5472 * lpfc_els_disc_plogi - Issue plogi for all npr nodes of a vport before adisc
5473 * @vport: pointer to a host virtual N_Port data structure.
5476 * which are in node port recovery state, with a @vport. Each time an ELS
5478 * the per @vport number of discover count (num_disc_nodes) shall be
5480 * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE
5483 * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag
5491 lpfc_els_disc_plogi(struct lpfc_vport *vport)
5493 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5498 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
5506 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
5507 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
5509 vport->num_disc_nodes++;
5510 if (vport->num_disc_nodes >=
5511 vport->cfg_discovery_threads) {
5513 vport->fc_flag |= FC_NLP_MORE;
5520 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
5522 sentplogi, vport->fc_flag);
5525 lpfc_set_disctmo(vport);
5529 vport->fc_flag &= ~FC_NLP_MORE;
5643 struct lpfc_vport *vport)
5649 bbCredit = vport->fc_sparam.cmn.bbCreditLsb |
5650 (vport->fc_sparam.cmn.bbCreditMsb << 8);
5652 if (vport->phba->fc_topology != LPFC_TOPOLOGY_LOOP) {
5653 bbCredit = vport->phba->fc_fabparam.cmn.bbCreditLsb |
5654 (vport->phba->fc_fabparam.cmn.bbCreditMsb << 8);
5813 uint8_t *page_a0, struct lpfc_vport *vport)
5913 struct lpfc_vport *vport)
5918 memcpy(desc->port_names.wwnn, &vport->fc_nodename,
5921 memcpy(desc->port_names.wwpn, &vport->fc_portname,
5930 struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
5934 if (vport->fc_flag & FC_FABRIC) {
5935 memcpy(desc->port_names.wwnn, &vport->fabric_nodename,
5938 memcpy(desc->port_names.wwpn, &vport->fabric_portname,
5957 struct lpfc_vport *vport = ndlp->vport;
5974 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize,
5985 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6015 (len + pcmd), vport);
6017 (len + pcmd), vport, ndlp);
6021 &rdp_context->link_stat, vport);
6038 rdp_context->page_a0, vport);
6060 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, lpfc_max_els_tries,
6100 mbox->vport = rdp_context->ndlp->vport;
6117 * @vport: pointer to a host virtual N_Port data structure.
6133 lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
6136 struct lpfc_hba *phba = vport->phba;
6161 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6189 lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_ELS,
6206 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
6317 lpfc_sli4_set_beacon(struct lpfc_vport *vport,
6321 struct lpfc_hba *phba = vport->phba;
6338 mbox->vport = phba->pport;
6390 * @vport: pointer to a host virtual N_Port data structure.
6403 lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
6406 struct lpfc_hba *phba = vport->phba;
6418 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6457 if (lpfc_sli4_set_beacon(vport, lcb_context, state)) {
6458 lpfc_printf_vlog(ndlp->vport, KERN_ERR, LOG_TRACE_EVENT,
6469 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
6475 * lpfc_els_flush_rscn - Clean up any rscn activities with a vport
6476 * @vport: pointer to a host virtual N_Port data structure.
6479 * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the
6480 * @vport together with the host_lock is used to prevent multiple thread
6481 * trying to access the RSCN array on a same @vport at the same time.
6484 lpfc_els_flush_rscn(struct lpfc_vport *vport)
6486 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6487 struct lpfc_hba *phba = vport->phba;
6491 if (vport->fc_rscn_flush) {
6492 /* Another thread is walking fc_rscn_id_list on this vport */
6496 /* Indicate we are walking lpfc_els_flush_rscn on this vport */
6497 vport->fc_rscn_flush = 1;
6500 for (i = 0; i < vport->fc_rscn_id_cnt; i++) {
6501 lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]);
6502 vport->fc_rscn_id_list[i] = NULL;
6505 vport->fc_rscn_id_cnt = 0;
6506 vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY);
6508 lpfc_can_disctmo(vport);
6510 vport->fc_rscn_flush = 0;
6515 * @vport: pointer to a host virtual N_Port data structure.
6519 * Configuration Notification (RSCN) to a @did on @vport.
6526 lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
6532 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6541 if (vport->fc_flag & FC_RSCN_DISCOVERY)
6545 if (vport->fc_rscn_flush) {
6546 /* Another thread is walking fc_rscn_id_list on this vport */
6550 /* Indicate we are walking fc_rscn_id_list on this vport */
6551 vport->fc_rscn_flush = 1;
6553 for (i = 0; i < vport->fc_rscn_id_cnt; i++) {
6554 lp = vport->fc_rscn_id_list[i]->virt;
6581 /* Indicate we are done with walking fc_rscn_id_list on this vport */
6582 vport->fc_rscn_flush = 0;
6585 /* Indicate we are done with walking fc_rscn_id_list on this vport */
6586 vport->fc_rscn_flush = 0;
6591 * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn
6592 * @vport: pointer to a host virtual N_Port data structure.
6595 * state machine for a @vport's nodes that are with pending RSCN (Registration
6602 lpfc_rscn_recovery_check(struct lpfc_vport *vport)
6607 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
6610 !lpfc_rscn_payload_check(vport, ndlp->nlp_DID))
6614 if (vport->phba->nvmet_support)
6634 lpfc_nvme_rescan_port(vport, ndlp);
6636 lpfc_disc_state_machine(vport, ndlp, NULL,
6638 lpfc_cancel_retry_delay_tmo(vport, ndlp);
6645 * @vport: pointer to a host virtual N_Port data structure.
6652 lpfc_send_rscn_event(struct lpfc_vport *vport,
6656 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6668 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
6688 * @vport: pointer to a host virtual N_Port data structure.
6699 * state, the fc_rscn_id_list of this @vport is walked and the
6709 lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
6712 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6713 struct lpfc_hba *phba = vport->phba;
6727 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6729 vport->fc_flag, payload_len, *lp,
6730 vport->fc_rscn_id_cnt);
6733 lpfc_send_rscn_event(vport, cmdiocb);
6740 if (vport->fc_flag & FC_PT2PT) {
6742 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6744 *lp, vport->fc_flag, payload_len);
6745 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
6752 lpfc_nvme_rescan_port(vport, ndlp);
6759 if (vport->port_state <= LPFC_NS_QRY) {
6760 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
6762 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
6764 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
6772 !(vport->cfg_peer_port_login)) {
6785 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6788 vport->fc_flag, payload_len,
6789 *lp, vport->fc_rscn_id_cnt);
6790 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
6791 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x",
6792 ndlp->nlp_DID, vport->port_state,
6795 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb,
6802 if (vport->fc_rscn_flush) {
6803 /* Another thread is walking fc_rscn_id_list on this vport */
6804 vport->fc_flag |= FC_RSCN_DISCOVERY;
6807 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
6810 /* Indicate we are walking fc_rscn_id_list on this vport */
6811 vport->fc_rscn_flush = 1;
6814 rscn_cnt = vport->fc_rscn_id_cnt;
6818 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {
6819 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
6821 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
6824 vport->fc_flag |= FC_RSCN_DEFERRED;
6827 if (vport->fc_flag & FC_DISC_TMO) {
6829 mod_timer(&vport->fc_disctmo,
6833 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
6834 vport->fc_flag |= FC_RSCN_MODE;
6837 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt;
6847 vport->fc_rscn_id_list[rscn_cnt] = pcmd;
6848 vport->fc_rscn_id_cnt++;
6855 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6858 vport->fc_rscn_id_cnt, vport->fc_flag,
6859 vport->port_state);
6861 vport->fc_flag |= FC_RSCN_DISCOVERY;
6864 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6867 vport->fc_rscn_id_cnt, vport->fc_flag,
6868 vport->port_state);
6870 /* Indicate we are done walking fc_rscn_id_list on this vport */
6871 vport->fc_rscn_flush = 0;
6873 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
6875 lpfc_rscn_recovery_check(vport);
6878 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
6880 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
6883 vport->fc_flag |= FC_RSCN_MODE;
6885 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;
6886 /* Indicate we are done walking fc_rscn_id_list on this vport */
6887 vport->fc_rscn_flush = 0;
6893 lpfc_set_disctmo(vport);
6895 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
6897 lpfc_rscn_recovery_check(vport);
6898 return lpfc_els_handle_rscn(vport);
6902 * lpfc_els_handle_rscn - Handle rscn for a vport
6903 * @vport: pointer to a host virtual N_Port data structure.
6906 * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall
6911 * RSCN activities with the @vport.
6914 * 0 - Cleaned up rscn on the @vport
6918 lpfc_els_handle_rscn(struct lpfc_vport *vport)
6921 struct lpfc_hba *phba = vport->phba;
6924 if (vport->load_flag & FC_UNLOADING) {
6925 lpfc_els_flush_rscn(vport);
6930 lpfc_set_disctmo(vport);
6933 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
6935 vport->fc_flag, 0, vport->fc_rscn_id_cnt,
6936 vport->port_state, vport->num_disc_nodes,
6937 vport->gidft_inp);
6940 vport->fc_ns_retry = 0;
6941 vport->num_disc_nodes = 0;
6943 ndlp = lpfc_findnode_did(vport, NameServer_DID);
6952 if (lpfc_issue_gidft(vport) > 0)
6955 if (lpfc_issue_gidpt(vport) > 0)
6963 ndlp = lpfc_enable_node(vport, ndlp,
6966 lpfc_els_flush_rscn(vport);
6971 ndlp = lpfc_nlp_init(vport, NameServer_DID);
6973 lpfc_els_flush_rscn(vport);
6977 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
6980 lpfc_issue_els_plogi(vport, NameServer_DID, 0);
6987 lpfc_els_flush_rscn(vport);
6993 * @vport: pointer to a host virtual N_Port data structure.
7005 * FLOGI shall be compared with the Port WWN of the @vport to determine who
7009 * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI
7017 lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7020 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
7021 struct lpfc_hba *phba = vport->phba;
7037 lpfc_set_disctmo(vport);
7045 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
7052 (void) lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1);
7059 rc = memcmp(&vport->fc_portname, &sp->portName,
7074 mbox->vport = vport;
7091 vport->fc_flag |= FC_PT2PT_PLOGI;
7099 vport->fc_myDID = PT2PT_LocalID;
7101 vport->fc_myDID = PT2PT_RemoteID;
7105 * The vport state should go to LPFC_FLOGI only
7109 fc_flag = vport->fc_flag;
7110 port_state = vport->port_state;
7111 vport->fc_flag |= FC_PT2PT;
7112 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
7117 vport->rcv_flogi_cnt++;
7119 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7122 port_state, vport->port_state,
7123 fc_flag, vport->fc_flag);
7130 did = vport->fc_myDID;
7131 vport->fc_myDID = Fabric_DID;
7141 vport->fc_myDID = did;
7143 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7155 lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, cmdiocb, ndlp, NULL);
7158 vport->fc_myDID = did;
7165 * @vport: pointer to a host virtual N_Port data structure.
7180 lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7200 lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp);
7208 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
7216 * @vport: pointer to a host virtual N_Port data structure.
7224 lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7234 lpfc_els_rsp_echo_acc(vport, pcmd, cmdiocb, ndlp);
7240 * @vport: pointer to a host virtual N_Port data structure.
7252 lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7262 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
7268 * @vport: pointer to a host virtual N_Port data structure.
7283 lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7286 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
7287 if (vport->phba->sli_rev == LPFC_SLI_REV4)
7288 lpfc_els_clear_rrq(vport, cmdiocb, ndlp);
7366 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
7380 * @vport: pointer to a host virtual N_Port data structure.
7397 lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7400 struct lpfc_hba *phba = vport->phba;
7416 mbox->vport = vport;
7434 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
7440 * @vport: pointer to a host virtual N_Port data structure.
7460 lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7463 struct lpfc_hba *phba = vport->phba;
7502 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
7522 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
7527 * @vport: pointer to a host virtual N_Port data structure.
7540 lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
7543 struct lpfc_hba *phba = vport->phba;
7558 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, did,
7572 bf_set(rrq_did, els_rrq, vport->fc_myDID);
7577 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
7606 struct lpfc_nodelist *ndlp = lpfc_findnode_did(rrq->vport,
7612 return lpfc_issue_els_rrq(rrq->vport, ndlp,
7620 * @vport: pointer to a host virtual N_Port data structure.
7638 lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize,
7641 struct lpfc_hba *phba = vport->phba;
7647 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
7668 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID);
7669 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname,
7673 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7692 * @vport: pointer to a host virtual N_Port data structure.
7707 lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7724 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
7743 lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp);
7750 * @vport: pointer to a virtual N_Port data structure.
7759 * remote PortName is compared against the FC PortName stored in the @vport
7761 * compared against the FC NodeName stored in the @vport data structure.
7773 lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7790 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7800 if (memcmp(&fp->RportName, &vport->fc_portname,
7807 if (memcmp(&fp->RnodeName, &vport->fc_nodename,
7818 lpfc_nlp_set_state(vport, ndlp,
7820 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
7825 lpfc_issue_els_farpr(vport, did, 0);
7833 * @vport: pointer to a host virtual N_Port data structure.
7846 lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7861 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7864 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
7871 * @vport: pointer to a host virtual N_Port data structure.
7877 * only be processed on a physical port (i.e., the @vport represents the
7889 lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
7892 struct lpfc_hba *phba = vport->phba;
7896 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n");
7900 if ((vport == phba->pport) &&
7901 (vport->port_state == LPFC_LOCAL_CFG_LINK)) {
7907 lpfc_issue_init_vfi(vport);
7910 vport->fc_myDID = vport->fc_prevDID;
7912 lpfc_issue_fabric_reglogin(vport);
7914 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
7916 vport->fc_prevDID, vport->fc_myDID);
7917 lpfc_issue_reg_vfi(vport);
7926 * @t: timer context used to obtain the vport.
7937 struct lpfc_vport *vport = from_timer(vport, t, els_tmofunc);
7938 struct lpfc_hba *phba = vport->phba;
7942 spin_lock_irqsave(&vport->work_port_lock, iflag);
7943 tmo_posted = vport->work_port_events & WORKER_ELS_TMO;
7944 if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING)))
7945 vport->work_port_events |= WORKER_ELS_TMO;
7946 spin_unlock_irqrestore(&vport->work_port_lock, iflag);
7948 if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING)))
7956 * @vport: pointer to a virtual N_Port data structure.
7960 * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by
7964 lpfc_els_timeout_handler(struct lpfc_vport *vport)
7966 struct lpfc_hba *phba = vport->phba;
7998 if (piocb->vport != vport)
8023 ndlp = __lpfc_findnode_rpi(vport, cmd->ulpContext);
8035 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8047 mod_timer(&vport->els_tmofunc,
8052 * lpfc_els_flush_cmd - Clean up the outstanding els commands to a vport
8053 * @vport: pointer to a host virtual N_Port data structure.
8056 * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport()
8058 * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For
8064 * completion queue IOCB that is associated with the @vport and is not
8072 lpfc_els_flush_cmd(struct lpfc_vport *vport)
8075 struct lpfc_hba *phba = vport->phba;
8081 lpfc_fabric_abort_vport(vport);
8106 if (piocb->vport != vport)
8145 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8170 if (piocb->vport != vport)
8178 if (vport == phba->pport) {
8218 struct lpfc_vport *vport;
8221 list_for_each_entry(vport, &phba->port_list, listentry)
8222 lpfc_els_flush_cmd(vport);
8242 struct lpfc_vport *vport = cmdiocbp->vport;
8243 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8297 * @vport: Pointer to vport object.
8305 lpfc_send_els_event(struct lpfc_vport *vport,
8311 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8316 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8326 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8383 * @vport: Pointer to vport object.
8390 lpfc_els_rcv_fpin_li(struct lpfc_vport *vport, struct fc_tlv_desc *tlv)
8399 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
8412 lpfc_els_rcv_fpin(struct lpfc_vport *vport, struct fc_els_fpin *fpin,
8421 if (vport->port_state < LPFC_DISC_AUTH)
8439 lpfc_els_rcv_fpin_li(vport, tlv);
8443 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8455 fc_host_fpin_rcv(lpfc_shost_from_vport(vport), fpin_length,
8463 * @vport: pointer to a host virtual N_Port data structure.
8475 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
8486 if (!vport || !(elsiocb->context2))
8498 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8505 if (lpfc_els_chk_latt(vport))
8508 /* Ignore traffic received during vport shutdown. */
8509 if (vport->load_flag & FC_UNLOADING)
8513 if ((vport->fc_flag & FC_DISC_DELAYED) &&
8517 ndlp = lpfc_findnode_did(vport, did);
8520 ndlp = lpfc_nlp_init(vport, did);
8523 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
8528 ndlp = lpfc_enable_node(vport, ndlp,
8532 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
8541 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
8551 shost = lpfc_shost_from_vport(vport);
8562 elsiocb->vport = vport;
8568 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
8571 cmd, did, vport->port_state, vport->fc_flag,
8572 vport->fc_myDID, vport->fc_prevDID);
8575 if ((vport->port_state < LPFC_FABRIC_CFG_LINK) &&
8577 !((cmd == ELS_CMD_PLOGI) && (vport->fc_flag & FC_PT2PT))) {
8585 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8587 did, vport->port_state, ndlp->nlp_flag);
8593 vport->fc_prevDID = vport->fc_myDID;
8598 vport->fc_myDID = elsiocb->iocb.un.rcvels.parmRo;
8599 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
8601 "%x\n", vport->fc_myDID,
8602 vport->fc_prevDID);
8605 lpfc_send_els_event(vport, ndlp, payload);
8608 if (vport->fc_flag & FC_DISC_DELAYED) {
8614 if (vport->port_state < LPFC_DISC_AUTH) {
8627 lpfc_disc_state_machine(vport, ndlp, elsiocb,
8632 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8634 did, vport->port_state, ndlp->nlp_flag);
8641 if (vport->port_state >= LPFC_LOCAL_CFG_LINK &&
8642 vport->fc_flag & FC_PT2PT &&
8643 vport->rcv_flogi_cnt >= 1) {
8650 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
8655 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8657 did, vport->port_state, ndlp->nlp_flag);
8660 lpfc_send_els_event(vport, ndlp, payload);
8661 if (vport->port_state < LPFC_DISC_AUTH) {
8666 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO);
8669 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8671 did, vport->port_state, ndlp->nlp_flag);
8674 lpfc_send_els_event(vport, ndlp, payload);
8675 if (vport->port_state < LPFC_DISC_AUTH) {
8680 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO);
8684 lpfc_els_rcv_lcb(vport, elsiocb, ndlp);
8688 lpfc_els_rcv_rdp(vport, elsiocb, ndlp);
8692 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
8697 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8699 did, vport->port_state, ndlp->nlp_flag);
8701 lpfc_send_els_event(vport, ndlp, payload);
8703 if (vport->port_state < LPFC_DISC_AUTH) {
8708 lpfc_disc_state_machine(vport, ndlp, elsiocb,
8712 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8714 did, vport->port_state, ndlp->nlp_flag);
8717 if (vport->port_state < LPFC_DISC_AUTH) {
8722 lpfc_disc_state_machine(vport, ndlp, elsiocb,
8726 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8728 did, vport->port_state, ndlp->nlp_flag);
8731 lpfc_els_rcv_farpr(vport, elsiocb, ndlp);
8734 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8736 did, vport->port_state, ndlp->nlp_flag);
8739 lpfc_els_rcv_farp(vport, elsiocb, ndlp);
8742 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8744 did, vport->port_state, ndlp->nlp_flag);
8747 lpfc_els_rcv_fan(vport, elsiocb, ndlp);
8751 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8753 did, vport->port_state, ndlp->nlp_flag);
8756 if ((vport->port_state < LPFC_DISC_AUTH) &&
8757 (vport->fc_flag & FC_FABRIC)) {
8762 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI);
8765 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8767 did, vport->port_state, ndlp->nlp_flag);
8770 lpfc_els_rcv_lirr(vport, elsiocb, ndlp);
8775 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8777 did, vport->port_state, ndlp->nlp_flag);
8780 lpfc_els_rcv_rls(vport, elsiocb, ndlp);
8785 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8787 did, vport->port_state, ndlp->nlp_flag);
8790 lpfc_els_rcv_rpl(vport, elsiocb, ndlp);
8795 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8797 did, vport->port_state, ndlp->nlp_flag);
8800 lpfc_els_rcv_rnid(vport, elsiocb, ndlp);
8805 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8807 did, vport->port_state, ndlp->nlp_flag);
8809 lpfc_els_rcv_rtv(vport, elsiocb, ndlp);
8814 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8816 did, vport->port_state, ndlp->nlp_flag);
8819 lpfc_els_rcv_rrq(vport, elsiocb, ndlp);
8824 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8826 did, vport->port_state, ndlp->nlp_flag);
8829 lpfc_els_rcv_echo(vport, elsiocb, ndlp);
8839 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8841 did, vport->port_state, ndlp->nlp_flag);
8843 lpfc_els_rcv_fpin(vport, (struct fc_els_fpin *)payload,
8849 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
8851 cmd, did, vport->port_state);
8858 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8872 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp,
8893 mbox->vport = vport;
8902 if (vport && !(vport->load_flag & FC_UNLOADING))
8903 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
8926 struct lpfc_vport *vport = phba->pport;
8952 vport = phba->pport;
8954 vport = lpfc_find_vport_by_vpid(phba,
8976 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
8990 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
9000 lpfc_start_fdmi(struct lpfc_vport *vport)
9008 ndlp = lpfc_findnode_did(vport, FDMI_DID);
9010 ndlp = lpfc_nlp_init(vport, FDMI_DID);
9018 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_NPR_NODE);
9021 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
9022 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
9029 * @vport: pointer to a virtual N_Port data structure.
9032 * State Change Request (SCR) for a @vport. This routine will create an
9033 * ndlp for the Name Server associated to the @vport if such node does
9036 * (FDMI) is configured to the @vport, a FDMI node will be created and
9040 lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
9043 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9051 if (vport->fc_flag & FC_DISC_DELAYED) {
9056 mod_timer(&vport->delayed_disc_tmo,
9062 ndlp = lpfc_findnode_did(vport, NameServer_DID);
9064 ndlp = lpfc_nlp_init(vport, NameServer_DID);
9067 lpfc_disc_start(vport);
9070 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9071 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9076 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
9079 lpfc_disc_start(vport);
9082 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9083 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9090 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
9092 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) {
9093 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9094 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9101 (vport->load_flag & FC_ALLOW_FDMI))
9102 lpfc_start_fdmi(vport);
9106 * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport
9110 * This routine is the completion callback function to register new vport
9111 * mailbox command. If the new vport mailbox command completes successfully,
9113 * new vport created is actually a physical port, with VPI 0) or the port
9120 struct lpfc_vport *vport = pmb->vport;
9121 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9127 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
9131 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9143 /* giving up on vport registration */
9144 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9146 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
9148 lpfc_can_disctmo(vport);
9153 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
9155 lpfc_init_vpi(phba, pmb, vport->vpi);
9156 pmb->vport = vport;
9161 lpfc_printf_vlog(vport, KERN_ERR,
9173 lpfc_sli4_unreg_all_rpis(vport);
9174 lpfc_mbx_unreg_vpi(vport);
9176 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
9180 if ((vport->port_type == LPFC_PHYSICAL_PORT) &&
9181 !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) {
9183 lpfc_issue_init_vfi(vport);
9185 lpfc_initial_flogi(vport);
9187 lpfc_initial_fdisc(vport);
9193 vport->vpi_state |= LPFC_VPI_REGISTERED;
9195 if (vport == phba->pport) {
9197 lpfc_issue_fabric_reglogin(vport);
9201 * FDISC, do not start vport discovery.
9203 if (vport->port_state != LPFC_FDISC)
9205 lpfc_do_scr_ns_plogi(phba, vport);
9208 lpfc_do_scr_ns_plogi(phba, vport);
9221 * lpfc_register_new_vport - Register a new vport with a HBA
9223 * @vport: pointer to a host virtual N_Port data structure.
9226 * This routine registers the @vport as a new virtual port with a HBA.
9230 lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
9233 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9238 lpfc_reg_vpi(vport, mbox);
9239 mbox->vport = vport;
9250 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9255 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9262 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9264 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
9270 * lpfc_cancel_all_vport_retry_delay_timer - Cancel all vport retry delay timer
9366 * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the
9367 * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID
9368 * assigned to the vport has been changed with the completion of the FDISC
9371 * routine is invoked to register new vport with the HBA. Otherwise, the
9379 struct lpfc_vport *vport = cmdiocb->vport;
9380 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9390 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
9393 vport->fc_prevDID);
9399 lpfc_set_disctmo(piocb->vport);
9402 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
9404 irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID);
9417 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9423 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
9424 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
9425 vport->fc_flag |= FC_FABRIC;
9426 if (vport->phba->fc_topology == LPFC_TOPOLOGY_LOOP)
9427 vport->fc_flag |= FC_PUBLIC_LOOP;
9430 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID;
9431 lpfc_vport_set_state(vport, FC_VPORT_ACTIVE);
9436 fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp);
9437 memcpy(&vport->fabric_portname, &sp->portName,
9439 memcpy(&vport->fabric_nodename, &sp->nodeName,
9442 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
9448 &vport->fc_nodes, nlp_listp) {
9456 lpfc_unreg_rpi(vport, np);
9458 lpfc_cleanup_pending_mbox(vport);
9461 lpfc_sli4_unreg_all_rpis(vport);
9463 lpfc_mbx_unreg_vpi(vport);
9465 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
9467 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
9469 vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG;
9472 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
9477 lpfc_register_new_vport(phba, vport, ndlp);
9481 if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)
9482 lpfc_issue_init_vpi(vport);
9483 else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
9484 lpfc_register_new_vport(phba, vport, ndlp);
9486 lpfc_do_scr_ns_plogi(phba, vport);
9489 if (vport->fc_vport &&
9490 (vport->fc_vport->vport_state != FC_VPORT_NO_FABRIC_RSCS))
9491 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9493 lpfc_can_disctmo(vport);
9501 * @vport: pointer to a virtual N_Port data structure.
9506 * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb()
9520 lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
9523 struct lpfc_hba *phba = vport->phba;
9532 vport->port_state = LPFC_FDISC;
9533 vport->fc_myDID = 0;
9535 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
9538 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9539 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9560 memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm));
9574 memcpy(pcmd, &vport->fc_portname, 8);
9577 memcpy(pcmd, &vport->fc_nodename, 8);
9580 lpfc_set_disctmo(vport);
9585 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
9592 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
9593 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9597 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING);
9602 * lpfc_cmpl_els_npiv_logo - Completion function with vport logo
9608 * ELS command off a vport. It frees the command IOCB and then decrement the
9619 struct lpfc_vport *vport = cmdiocb->vport;
9622 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9626 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
9631 vport->unreg_vpi_cmpl = VPORT_ERROR;
9637 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
9641 irsp->ulpTimeout, vport->num_disc_nodes);
9645 vport->fc_flag &= ~FC_NDISC_ACTIVE;
9646 vport->fc_flag &= ~FC_FABRIC;
9648 lpfc_can_disctmo(vport);
9653 * lpfc_issue_els_npiv_logo - Issue a logo off a vport
9654 * @vport: pointer to a virtual N_Port data structure.
9657 * This routine issues a LOGO ELS command to an @ndlp off a @vport.
9665 * 0 - Successfully issued logo off the @vport
9666 * 1 - Failed to issue logo off the @vport
9669 lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
9671 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
9672 struct lpfc_hba *phba = vport->phba;
9678 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID,
9688 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
9690 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
9692 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
9775 lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD,
9777 iocb->vport->port_state, 0, 0);
9942 lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD,
9944 iocb->vport->port_state, 0, 0);
9964 * lpfc_fabric_abort_vport - Abort a vport's iocbs from driver fabric iocb list
9965 * @vport: pointer to a virtual N_Port data structure.
9967 * This routine aborts all the IOCBs associated with a @vport from the
9970 * list, removes each IOCB associated with the @vport off the list, set the
9974 static void lpfc_fabric_abort_vport(struct lpfc_vport *vport)
9977 struct lpfc_hba *phba = vport->phba;
9984 if (piocb->vport != vport)
10059 * lpfc_sli4_vport_delete_els_xri_aborted -Remove all ndlp references for vport
10060 * @vport: pointer to lpfc vport data structure.
10062 * This routine is invoked by the vport cleanup for deletions and the cleanup
10066 lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *vport)
10068 struct lpfc_hba *phba = vport->phba;
10076 if (sglq_entry->ndlp && sglq_entry->ndlp->vport == vport)
10150 * @vport: pointer to virtual port object.
10159 lpfc_sli_abts_recover_port(struct lpfc_vport *vport,
10166 shost = lpfc_shost_from_vport(vport);
10167 phba = vport->phba;
10179 vport->vpi, ndlp->nlp_rpi, ndlp->nlp_state,
10189 lpfc_unreg_rpi(vport, ndlp);