• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/scsi/lpfc/

Lines Matching defs:vport

49 static void lpfc_fabric_abort_vport(struct lpfc_vport *vport);
50 static int lpfc_issue_els_fdisc(struct lpfc_vport *vport,
58 * lpfc_els_chk_latt - Check host link attention event for a vport
59 * @vport: pointer to a host virtual N_Port data structure.
62 * attention event during the discovery process with the @vport. It is done
64 * link attention events during this @vport's discovery process, the @vport
70 * Note that, if either the host link is in state LPFC_LINK_DOWN or @vport
80 lpfc_els_chk_latt(struct lpfc_vport *vport)
82 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
83 struct lpfc_hba *phba = vport->phba;
86 if (vport->port_state >= LPFC_VPORT_READY ||
98 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
110 vport->fc_flag |= FC_ABORT_DISCOVERY;
114 lpfc_issue_clear_la(phba, vport);
121 * @vport: pointer to a host virtual N_Port data structure.
148 lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
153 struct lpfc_hba *phba = vport->phba;
246 icmd->un.elsreq64.myID = vport->fc_myDID;
249 icmd->ulpContext = vport->vpi + phba->vpi_base;
281 elsiocb->vport = vport;
289 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
293 vport->port_state);
296 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
320 * lpfc_issue_fabric_reglogin - Issue fabric registration login for a vport
321 * @vport: pointer to a host virtual N_Port data structure.
323 * This routine issues a fabric registration login for a @vport. An
324 * active ndlp node with Fabric_DID must already exist for this @vport.
327 * HBA to perform link configuration for the @vport; and the second mailbox
329 * with the @vport.
332 * 0 - successfully issued fabric registration login for @vport
333 * -ENXIO -- failed to issue fabric registration login for @vport
336 lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)
338 struct lpfc_hba *phba = vport->phba;
347 ndlp = lpfc_findnode_did(vport, Fabric_DID);
359 vport->port_state = LPFC_FABRIC_CFG_LINK;
362 mbox->vport = vport;
375 rc = lpfc_reg_rpi(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox, 0);
382 mbox->vport = vport;
408 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
409 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
415 * lpfc_issue_reg_vfi - Register VFI for this vport's fabric login
416 * @vport: pointer to a host virtual N_Port data structure.
419 * the @vport. This mailbox command is necessary for FCoE only.
422 * 0 - successfully issued REG_VFI for @vport
426 lpfc_issue_reg_vfi(struct lpfc_vport *vport)
428 struct lpfc_hba *phba = vport->phba;
436 ndlp = lpfc_findnode_did(vport, Fabric_DID);
457 vport->port_state = LPFC_FABRIC_CFG_LINK;
458 memcpy(dmabuf->virt, &phba->fc_fabparam, sizeof(vport->fc_sparam));
459 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);
461 mboxq->vport = vport;
477 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
478 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
485 * @vport: pointer to a host virtual N_Port data structure.
494 * @vport against the previously assigned N_Port ID. If it is different from
496 * is invoked on all the remaining nodes with the @vport to unregister the
504 lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
507 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
508 struct lpfc_hba *phba = vport->phba;
513 vport->fc_flag |= FC_FABRIC;
524 vport->fc_flag |= FC_PUBLIC_LOOP;
531 vport->fc_sparam.cmn.altBbCredit = 1;
534 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID;
552 lpfc_printf_vlog(vport, KERN_WARNING,
561 lpfc_printf_vlog(vport, KERN_WARNING,
569 if ((vport->fc_prevDID != vport->fc_myDID) &&
570 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
576 &vport->fc_nodes, nlp_listp) {
585 lpfc_unreg_rpi(vport, np);
587 lpfc_cleanup_pending_mbox(vport);
589 lpfc_mbx_unreg_vpi(vport);
591 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
600 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
604 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
609 lpfc_register_new_vport(phba, vport, ndlp);
614 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
616 vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
617 lpfc_register_new_vport(phba, vport, ndlp);
619 lpfc_issue_fabric_reglogin(vport);
622 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
623 if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) &&
624 (vport->vpi_state & LPFC_VPI_REGISTERED)) {
626 lpfc_do_scr_ns_plogi(phba, vport);
627 } else if (vport->fc_flag & FC_VFI_REGISTERED)
628 lpfc_issue_init_vpi(vport);
630 lpfc_issue_reg_vfi(vport);
636 * @vport: pointer to a host virtual N_Port data structure.
642 * in a point-to-point topology. First, the @vport's N_Port Name is compared
643 * with the received N_Port Name: if the @vport's N_Port Name is greater than
655 lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
658 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
659 struct lpfc_hba *phba = vport->phba;
664 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
669 rc = memcmp(&vport->fc_portname, &sp->portName,
670 sizeof(vport->fc_portname));
674 vport->fc_flag |= FC_PT2PT_PLOGI;
684 vport->fc_myDID = PT2PT_LocalID;
693 mbox->vport = vport;
704 ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID);
713 lpfc_nlp_init(vport, ndlp, PT2PT_RemoteID);
715 ndlp = lpfc_enable_node(vport, ndlp,
726 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
741 vport->fc_flag |= FC_PT2PT;
745 lpfc_disc_start(vport);
778 struct lpfc_vport *vport = cmdiocb->vport;
779 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
788 if (lpfc_els_chk_latt(vport)) {
796 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
799 vport->port_state);
856 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
867 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
875 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
879 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
886 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
887 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
899 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
905 if (vport->port_state == LPFC_FLOGI) {
911 rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp);
913 rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp);
915 lpfc_printf_vlog(vport, KERN_ERR,
948 lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP |
967 lpfc_disc_list_loopmap(vport);
970 lpfc_disc_start(vport);
976 lpfc_issue_clear_la(phba, vport);
983 * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport
984 * @vport: pointer to a host virtual N_Port data structure.
989 * for a @vport. The initiator service parameters are put into the payload
1001 * 0 - successfully issued flogi iocb for @vport
1002 * 1 - failed to issue flogi iocb for @vport
1005 lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1008 struct lpfc_hba *phba = vport->phba;
1021 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1033 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
1067 lpfc_set_disctmo(vport);
1073 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1135 * lpfc_initial_flogi - Issue an initial fabric login for a vport
1136 * @vport: pointer to a host virtual N_Port data structure.
1138 * This routine issues an initial Fabric Login (FLOGI) for the @vport
1140 * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and
1141 * put it into the @vport's ndlp list. If an inactive ndlp found on the list,
1143 * is then invoked with the @vport and the ndlp to perform the FLOGI for the
1144 * @vport.
1147 * 0 - failed to issue initial flogi for @vport
1148 * 1 - successfully issued initial flogi for @vport
1151 lpfc_initial_flogi(struct lpfc_vport *vport)
1153 struct lpfc_hba *phba = vport->phba;
1156 vport->port_state = LPFC_FLOGI;
1157 lpfc_set_disctmo(vport);
1160 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1166 lpfc_nlp_init(vport, ndlp, Fabric_DID);
1170 lpfc_enqueue_node(vport, ndlp);
1173 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
1178 if (lpfc_issue_els_flogi(vport, ndlp, 0))
1188 * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport
1189 * @vport: pointer to a host virtual N_Port data structure.
1191 * This routine issues an initial Fabric Discover (FDISC) for the @vport
1193 * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and
1194 * put it into the @vport's ndlp list. If an inactive ndlp found on the list,
1196 * is then invoked with the @vport and the ndlp to perform the FDISC for the
1197 * @vport.
1200 * 0 - failed to issue initial fdisc for @vport
1201 * 1 - successfully issued initial fdisc for @vport
1204 lpfc_initial_fdisc(struct lpfc_vport *vport)
1206 struct lpfc_hba *phba = vport->phba;
1210 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1216 lpfc_nlp_init(vport, ndlp, Fabric_DID);
1218 lpfc_enqueue_node(vport, ndlp);
1221 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
1226 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
1237 * lpfc_more_plogi - Check and issue remaining plogis for a vport
1238 * @vport: pointer to a host virtual N_Port data structure.
1241 * (PLOGI) to be issued for the @vport. If so, it will invoke the routine
1244 * @vport (@vport->cfg_discovery_threads). The function also decrement
1245 * the @vport's num_disc_node by 1 if it is not already 0.
1248 lpfc_more_plogi(struct lpfc_vport *vport)
1252 if (vport->num_disc_nodes)
1253 vport->num_disc_nodes--;
1256 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1259 vport->num_disc_nodes, vport->fc_plogi_cnt,
1260 vport->fc_flag, vport->port_state);
1262 if (vport->fc_flag & FC_NLP_MORE)
1264 sentplogi = lpfc_els_disc_plogi(vport);
1278 * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches
1279 * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but
1282 * 1) if there is a node on vport list other than the @ndlp with the same
1285 * no node found on vport list with the same WWPN of the N_Port PLOGI logged
1288 * be released and the new_ndlp shall be put on to the vport node list and
1292 * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID
1294 * into an inactive state on the vport node list and the vport node list
1304 struct lpfc_vport *vport = ndlp->vport;
1326 new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName);
1339 lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID);
1345 new_ndlp = lpfc_enable_node(vport, new_ndlp,
1353 lpfc_unreg_rpi(vport, new_ndlp);
1362 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
1394 lpfc_drop_node(vport, ndlp);
1397 lpfc_unreg_rpi(vport, ndlp);
1400 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1428 * lpfc_end_rscn - Check and handle more rscn for a vport
1429 * @vport: pointer to a host virtual N_Port data structure.
1434 * invoked to handle the additional RSCNs for the @vport. Otherwise, the
1435 * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of
1439 lpfc_end_rscn(struct lpfc_vport *vport)
1441 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1443 if (vport->fc_flag & FC_RSCN_MODE) {
1448 if (vport->fc_rscn_id_cnt ||
1449 (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
1450 lpfc_els_handle_rscn(vport);
1453 vport->fc_flag &= ~FC_RSCN_MODE;
1467 * ndlp on the vport node list that matches the remote node ID from the
1475 * there are additional N_Port nodes with the vport that need to perform
1483 struct lpfc_vport *vport = cmdiocb->vport;
1484 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1494 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1499 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID);
1501 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1520 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1524 irsp->ulpTimeout, disc, vport->num_disc_nodes);
1526 if (lpfc_els_chk_latt(vport)) {
1548 /* PLOGI failed Don't print the vport to vport rjts */
1553 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1561 rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb,
1569 rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb,
1573 if (disc && vport->num_disc_nodes) {
1575 lpfc_more_plogi(vport);
1577 if (vport->num_disc_nodes == 0) {
1579 vport->fc_flag &= ~FC_NDISC_ACTIVE;
1582 lpfc_can_disctmo(vport);
1583 lpfc_end_rscn(vport);
1593 * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport
1594 * @vport: pointer to a host virtual N_Port data structure.
1599 * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port,
1600 * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list.
1610 * 0 - Successfully issued a plogi for @vport
1611 * 1 - failed to issue a plogi for @vport
1614 lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry)
1616 struct lpfc_hba *phba = vport->phba;
1628 ndlp = lpfc_findnode_did(vport, did);
1634 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
1645 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
1654 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1686 struct lpfc_vport *vport = cmdiocb->vport;
1687 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1702 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1707 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1711 irsp->ulpTimeout, vport->num_disc_nodes);
1713 vport->fc_prli_sent--;
1715 if (lpfc_els_chk_latt(vport))
1725 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1733 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
1737 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
1745 * lpfc_issue_els_prli - Issue a prli iocb command for a vport
1746 * @vport: pointer to a host virtual N_Port data structure.
1751 * @vport. The PRLI service parameters are set up in the payload of the
1762 * 0 - successfully issued prli iocb command for @vport
1763 * 1 - failed to issue prli iocb command for @vport
1766 lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1769 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1770 struct lpfc_hba *phba = vport->phba;
1778 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1809 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1826 vport->fc_prli_sent++;
1831 * lpfc_rscn_disc - Perform rscn discovery for a vport
1832 * @vport: pointer to a host virtual N_Port data structure.
1835 * discovery for a @vport. If the @vport's node port recovery count is not
1843 lpfc_rscn_disc(struct lpfc_vport *vport)
1845 lpfc_can_disctmo(vport);
1849 if (vport->fc_npr_cnt)
1850 if (lpfc_els_disc_plogi(vport))
1853 lpfc_end_rscn(vport);
1858 * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs.
1867 lpfc_adisc_done(struct lpfc_vport *vport)
1869 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1870 struct lpfc_hba *phba = vport->phba;
1877 !(vport->fc_flag & FC_RSCN_MODE) &&
1879 lpfc_issue_reg_vpi(phba, vport);
1886 if (vport->port_state < LPFC_VPORT_READY) {
1888 if (vport->port_type == LPFC_PHYSICAL_PORT)
1889 lpfc_issue_clear_la(phba, vport);
1890 if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) {
1891 vport->num_disc_nodes = 0;
1893 if (vport->fc_npr_cnt)
1894 lpfc_els_disc_plogi(vport);
1895 if (!vport->num_disc_nodes) {
1897 vport->fc_flag &= ~FC_NDISC_ACTIVE;
1899 lpfc_can_disctmo(vport);
1900 lpfc_end_rscn(vport);
1903 vport->port_state = LPFC_VPORT_READY;
1905 lpfc_rscn_disc(vport);
1910 * @vport: pointer to a host virtual N_Port data structure.
1912 * This routine determines whether there are more ndlps on a @vport
1914 * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's
1918 lpfc_more_adisc(struct lpfc_vport *vport)
1922 if (vport->num_disc_nodes)
1923 vport->num_disc_nodes--;
1925 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1928 vport->num_disc_nodes, vport->fc_adisc_cnt,
1929 vport->fc_flag, vport->port_state);
1931 if (vport->fc_flag & FC_NLP_MORE) {
1932 lpfc_set_disctmo(vport);
1934 sentadisc = lpfc_els_disc_adisc(vport);
1936 if (!vport->num_disc_nodes)
1937 lpfc_adisc_done(vport);
1961 struct lpfc_vport *vport = cmdiocb->vport;
1962 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1973 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1986 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1990 irsp->ulpTimeout, disc, vport->num_disc_nodes);
1992 if (lpfc_els_chk_latt(vport)) {
2007 lpfc_set_disctmo(vport);
2012 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2018 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2022 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2026 if (disc && vport->num_disc_nodes)
2027 lpfc_more_adisc(vport);
2034 * lpfc_issue_els_adisc - Issue an address discover iocb to an node on a vport
2035 * @vport: pointer to a virtual N_Port data structure.
2040 * @vport. It prepares the payload of the ADISC ELS command, updates the
2054 lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2057 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2058 struct lpfc_hba *phba = vport->phba;
2066 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2081 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
2082 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
2083 ap->DID = be32_to_cpu(vport->fc_myDID);
2085 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2122 struct lpfc_vport *vport = ndlp->vport;
2123 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2136 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2141 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2145 irsp->ulpTimeout, vport->num_disc_nodes);
2147 if (lpfc_els_chk_latt(vport))
2154 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2165 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2173 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2179 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2187 * lpfc_issue_els_logo - Issue a logo to an node on a vport
2188 * @vport: pointer to a virtual N_Port data structure.
2193 * to a remote node, referred by an @ndlp on a @vport. It constructs the
2207 lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2210 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2211 struct lpfc_hba *phba = vport->phba;
2226 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2237 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
2239 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
2241 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2282 struct lpfc_vport *vport = cmdiocb->vport;
2287 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2292 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2297 lpfc_els_chk_latt(vport);
2303 * lpfc_issue_els_scr - Issue a scr to an node on a vport
2304 * @vport: pointer to a host virtual N_Port data structure.
2309 * on a @vport. The remote node @nportid is passed into the function. It
2310 * first search the @vport node list to find the matching ndlp. If no such
2325 lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry)
2327 struct lpfc_hba *phba = vport->phba;
2338 ndlp = lpfc_findnode_did(vport, nportid);
2343 lpfc_nlp_init(vport, ndlp, nportid);
2344 lpfc_enqueue_node(vport, ndlp);
2346 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
2351 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2372 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2396 * lpfc_issue_els_farpr - Issue a farp to an node on a vport
2397 * @vport: pointer to a host virtual N_Port data structure.
2402 * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid)
2403 * is passed into the function. It first search the @vport node list to find
2418 lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry)
2420 struct lpfc_hba *phba = vport->phba;
2434 ndlp = lpfc_findnode_did(vport, nportid);
2439 lpfc_nlp_init(vport, ndlp, nportid);
2440 lpfc_enqueue_node(vport, ndlp);
2442 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
2447 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2468 *lp++ = be32_to_cpu(vport->fc_myDID);
2472 memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name));
2473 memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
2474 ondlp = lpfc_findnode_did(vport, nportid);
2482 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2507 * @vport: pointer to a host virtual N_Port data structure.
2511 * a @vport's @ndlp. It stops the timer for the delayed function retrial and
2514 * commands are sent for the @vport's nodes that require issuing discovery
2518 lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
2520 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2540 if (vport->num_disc_nodes) {
2541 if (vport->port_state < LPFC_VPORT_READY) {
2543 lpfc_more_adisc(vport);
2546 lpfc_more_plogi(vport);
2547 if (vport->num_disc_nodes == 0) {
2549 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2551 lpfc_can_disctmo(vport);
2552 lpfc_end_rscn(vport);
2578 struct lpfc_vport *vport = ndlp->vport;
2579 struct lpfc_hba *phba = vport->phba;
2614 struct lpfc_vport *vport = ndlp->vport;
2615 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2641 lpfc_issue_els_flogi(vport, ndlp, retry);
2644 if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) {
2646 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2650 if (!lpfc_issue_els_adisc(vport, ndlp, retry)) {
2652 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2656 if (!lpfc_issue_els_prli(vport, ndlp, retry)) {
2658 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
2662 if (!lpfc_issue_els_logo(vport, ndlp, retry)) {
2664 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2668 lpfc_issue_els_fdisc(vport, ndlp, retry);
2699 struct lpfc_vport *vport = cmdiocb->vport;
2700 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2726 ndlp = lpfc_findnode_did(vport, did);
2732 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2759 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2838 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2842 lpfc_vport_set_state(vport,
2879 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2883 lpfc_vport_set_state(vport,
2920 if ((vport->load_flag & FC_UNLOADING) != 0)
2927 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2937 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2948 if (timer_pending(&vport->fc_disctmo) ||
2949 (vport->fc_flag & FC_RSCN_MODE))
2950 lpfc_set_disctmo(vport);
2967 lpfc_nlp_set_state(vport, ndlp,
2970 lpfc_nlp_set_state(vport, ndlp,
2978 lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry);
2981 lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry);
2986 lpfc_nlp_set_state(vport, ndlp,
2989 lpfc_issue_els_plogi(vport, did, cmdiocb->retry);
2993 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2994 lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry);
2998 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
2999 lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry);
3003 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
3004 lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry);
3010 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3017 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3193 struct lpfc_vport *vport = cmdiocb->vport;
3197 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3201 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3213 lpfc_unreg_rpi(vport, ndlp);
3289 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
3290 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
3316 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || lpfc_els_chk_latt(vport)) {
3338 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3343 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3353 lpfc_unreg_rpi(vport, ndlp);
3358 mbox->vport = vport;
3366 lpfc_nlp_set_state(vport, ndlp,
3379 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3441 * @vport: pointer to a host virtual N_Port data structure.
3465 lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
3469 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3470 struct lpfc_hba *phba = vport->phba;
3486 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
3501 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3507 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
3521 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
3523 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3529 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry,
3544 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3552 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3578 * @vport: pointer to a virtual N_Port data structure.
3599 lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
3603 struct lpfc_hba *phba = vport->phba;
3614 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
3632 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3639 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3656 * @vport: pointer to a virtual N_Port data structure.
3674 lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
3677 struct lpfc_hba *phba = vport->phba;
3686 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
3696 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3709 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
3710 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
3711 ap->DID = be32_to_cpu(vport->fc_myDID);
3713 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3729 * @vport: pointer to a virtual N_Port data structure.
3747 lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
3750 struct lpfc_hba *phba = vport->phba;
3764 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
3773 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3808 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3825 * @vport: pointer to a virtual N_Port data structure.
3850 lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
3853 struct lpfc_hba *phba = vport->phba;
3868 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
3877 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3888 memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name));
3889 memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
3897 &vport->fc_portname, sizeof(struct lpfc_name));
3908 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
3927 * lpfc_els_disc_adisc - Issue remaining adisc iocbs to npr nodes of a vport
3928 * @vport: pointer to a host virtual N_Port data structure.
3932 * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the
3933 * lpfc_issue_els_adisc() routine, the per @vport number of discover count
3935 * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will
3938 * all the ndlps with the @vport and there is none ADISC IOCB issued, the
3939 * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is
3946 lpfc_els_disc_adisc(struct lpfc_vport *vport)
3948 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3953 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
3963 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
3964 lpfc_issue_els_adisc(vport, ndlp, 0);
3966 vport->num_disc_nodes++;
3967 if (vport->num_disc_nodes >=
3968 vport->cfg_discovery_threads) {
3970 vport->fc_flag |= FC_NLP_MORE;
3978 vport->fc_flag &= ~FC_NLP_MORE;
3985 * lpfc_els_disc_plogi - Issue plogi for all npr nodes of a vport before adisc
3986 * @vport: pointer to a host virtual N_Port data structure.
3989 * which are in node port recovery state, with a @vport. Each time an ELS
3991 * the per @vport number of discover count (num_disc_nodes) shall be
3993 * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE
3996 * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag
4004 lpfc_els_disc_plogi(struct lpfc_vport *vport)
4006 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4011 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
4019 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
4020 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
4022 vport->num_disc_nodes++;
4023 if (vport->num_disc_nodes >=
4024 vport->cfg_discovery_threads) {
4026 vport->fc_flag |= FC_NLP_MORE;
4033 lpfc_set_disctmo(vport);
4037 vport->fc_flag &= ~FC_NLP_MORE;
4044 * lpfc_els_flush_rscn - Clean up any rscn activities with a vport
4045 * @vport: pointer to a host virtual N_Port data structure.
4048 * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the
4049 * @vport together with the host_lock is used to prevent multiple thread
4050 * trying to access the RSCN array on a same @vport at the same time.
4053 lpfc_els_flush_rscn(struct lpfc_vport *vport)
4055 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4056 struct lpfc_hba *phba = vport->phba;
4060 if (vport->fc_rscn_flush) {
4061 /* Another thread is walking fc_rscn_id_list on this vport */
4065 /* Indicate we are walking lpfc_els_flush_rscn on this vport */
4066 vport->fc_rscn_flush = 1;
4069 for (i = 0; i < vport->fc_rscn_id_cnt; i++) {
4070 lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]);
4071 vport->fc_rscn_id_list[i] = NULL;
4074 vport->fc_rscn_id_cnt = 0;
4075 vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY);
4077 lpfc_can_disctmo(vport);
4079 vport->fc_rscn_flush = 0;
4084 * @vport: pointer to a host virtual N_Port data structure.
4088 * Configuration Notification (RSCN) to a @did on @vport.
4095 lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
4101 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4110 if (vport->fc_flag & FC_RSCN_DISCOVERY)
4114 if (vport->fc_rscn_flush) {
4115 /* Another thread is walking fc_rscn_id_list on this vport */
4119 /* Indicate we are walking fc_rscn_id_list on this vport */
4120 vport->fc_rscn_flush = 1;
4122 for (i = 0; i < vport->fc_rscn_id_cnt; i++) {
4123 lp = vport->fc_rscn_id_list[i]->virt;
4150 /* Indicate we are done with walking fc_rscn_id_list on this vport */
4151 vport->fc_rscn_flush = 0;
4154 /* Indicate we are done with walking fc_rscn_id_list on this vport */
4155 vport->fc_rscn_flush = 0;
4160 * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn
4161 * @vport: pointer to a host virtual N_Port data structure.
4164 * state machine for a @vport's nodes that are with pending RSCN (Registration
4171 lpfc_rscn_recovery_check(struct lpfc_vport *vport)
4176 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
4179 !lpfc_rscn_payload_check(vport, ndlp->nlp_DID))
4181 lpfc_disc_state_machine(vport, ndlp, NULL,
4183 lpfc_cancel_retry_delay_tmo(vport, ndlp);
4190 * @vport: pointer to a host virtual N_Port data structure.
4197 lpfc_send_rscn_event(struct lpfc_vport *vport,
4201 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4213 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4233 * @vport: pointer to a host virtual N_Port data structure.
4244 * state, the fc_rscn_id_list of this @vport is walked and the
4254 lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4257 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4258 struct lpfc_hba *phba = vport->phba;
4274 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
4276 vport->fc_flag, payload_len, *lp,
4277 vport->fc_rscn_id_cnt);
4280 lpfc_send_rscn_event(vport, cmdiocb);
4289 if (vport->port_state <= LPFC_NS_QRY) {
4290 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
4292 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
4294 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
4302 !(vport->cfg_peer_port_login)) {
4315 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
4318 vport->fc_flag, payload_len,
4319 *lp, vport->fc_rscn_id_cnt);
4320 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
4321 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x",
4322 ndlp->nlp_DID, vport->port_state,
4325 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb,
4332 if (vport->fc_rscn_flush) {
4333 /* Another thread is walking fc_rscn_id_list on this vport */
4334 vport->fc_flag |= FC_RSCN_DISCOVERY;
4337 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
4340 /* Indicate we are walking fc_rscn_id_list on this vport */
4341 vport->fc_rscn_flush = 1;
4344 rscn_cnt = vport->fc_rscn_id_cnt;
4348 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {
4349 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
4351 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
4354 vport->fc_flag |= FC_RSCN_DEFERRED;
4356 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
4357 vport->fc_flag |= FC_RSCN_MODE;
4360 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt;
4370 vport->fc_rscn_id_list[rscn_cnt] = pcmd;
4371 vport->fc_rscn_id_cnt++;
4378 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
4381 vport->fc_rscn_id_cnt, vport->fc_flag,
4382 vport->port_state);
4384 vport->fc_flag |= FC_RSCN_DISCOVERY;
4387 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
4390 vport->fc_rscn_id_cnt, vport->fc_flag,
4391 vport->port_state);
4393 /* Indicate we are done walking fc_rscn_id_list on this vport */
4394 vport->fc_rscn_flush = 0;
4396 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
4398 lpfc_rscn_recovery_check(vport);
4400 vport->fc_flag &= ~FC_RSCN_DEFERRED;
4404 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
4406 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
4409 vport->fc_flag |= FC_RSCN_MODE;
4411 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;
4412 /* Indicate we are done walking fc_rscn_id_list on this vport */
4413 vport->fc_rscn_flush = 0;
4419 lpfc_set_disctmo(vport);
4421 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
4423 lpfc_rscn_recovery_check(vport);
4424 return lpfc_els_handle_rscn(vport);
4428 * lpfc_els_handle_rscn - Handle rscn for a vport
4429 * @vport: pointer to a host virtual N_Port data structure.
4432 * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall
4437 * RSCN activities with the @vport.
4440 * 0 - Cleaned up rscn on the @vport
4444 lpfc_els_handle_rscn(struct lpfc_vport *vport)
4447 struct lpfc_hba *phba = vport->phba;
4450 if (vport->load_flag & FC_UNLOADING) {
4451 lpfc_els_flush_rscn(vport);
4456 lpfc_set_disctmo(vport);
4459 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
4461 vport->fc_flag, 0, vport->fc_rscn_id_cnt,
4462 vport->port_state);
4465 vport->fc_ns_retry = 0;
4466 vport->num_disc_nodes = 0;
4468 ndlp = lpfc_findnode_did(vport, NameServer_DID);
4472 if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0)
4479 ndlp = lpfc_findnode_did(vport, NameServer_DID);
4486 ndlp = lpfc_enable_node(vport, ndlp,
4489 lpfc_els_flush_rscn(vport);
4496 lpfc_els_flush_rscn(vport);
4499 lpfc_nlp_init(vport, ndlp, NameServer_DID);
4501 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
4504 lpfc_issue_els_plogi(vport, NameServer_DID, 0);
4511 lpfc_els_flush_rscn(vport);
4517 * @vport: pointer to a host virtual N_Port data structure.
4529 * FLOGI shall be compared with the Port WWN of the @vport to determine who
4533 * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI
4541 lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4544 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4545 struct lpfc_hba *phba = vport->phba;
4560 lpfc_set_disctmo(vport);
4568 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4577 if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1))) {
4582 rc = memcmp(&vport->fc_portname, &sp->portName,
4596 mbox->vport = vport;
4605 vport->fc_flag |= FC_PT2PT_PLOGI;
4609 vport->fc_flag |= FC_PT2PT;
4610 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
4618 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
4624 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL);
4631 * @vport: pointer to a host virtual N_Port data structure.
4646 lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4670 lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp);
4678 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
4686 * @vport: pointer to a host virtual N_Port data structure.
4698 lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4708 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
4714 * @vport: pointer to a host virtual N_Port data structure.
4729 lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4732 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
4814 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
4829 * @vport: pointer to a host virtual N_Port data structure.
4846 lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
4849 struct lpfc_hba *phba = vport->phba;
4869 ((flag == 2) && (memcmp(&rps->un.portName, &vport->fc_portname,
4880 mbox->vport = vport;
4900 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
4906 * @vport: pointer to a host virtual N_Port data structure.
4924 lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize,
4927 struct lpfc_hba *phba = vport->phba;
4933 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
4953 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID);
4954 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname,
4958 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4977 * @vport: pointer to a host virtual N_Port data structure.
4992 lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
5009 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
5029 lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp);
5036 * @vport: pointer to a virtual N_Port data structure.
5045 * remote PortName is compared against the FC PortName stored in the @vport
5047 * compared against the FC NodeName stored in the @vport data structure.
5059 lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
5076 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5086 if (memcmp(&fp->RportName, &vport->fc_portname,
5093 if (memcmp(&fp->RnodeName, &vport->fc_nodename,
5104 lpfc_nlp_set_state(vport, ndlp,
5106 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
5111 lpfc_issue_els_farpr(vport, did, 0);
5119 * @vport: pointer to a host virtual N_Port data structure.
5132 lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
5147 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5150 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
5157 * @vport: pointer to a host virtual N_Port data structure.
5163 * only be processed on a physical port (i.e., the @vport represents the
5175 lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
5178 struct lpfc_hba *phba = vport->phba;
5182 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n");
5186 if ((vport == phba->pport) &&
5187 (vport->port_state == LPFC_LOCAL_CFG_LINK)) {
5193 lpfc_initial_flogi(vport);
5196 vport->fc_myDID = vport->fc_prevDID;
5198 lpfc_issue_fabric_reglogin(vport);
5200 lpfc_issue_reg_vfi(vport);
5219 struct lpfc_vport *vport = (struct lpfc_vport *) ptr;
5220 struct lpfc_hba *phba = vport->phba;
5224 spin_lock_irqsave(&vport->work_port_lock, iflag);
5225 tmo_posted = vport->work_port_events & WORKER_ELS_TMO;
5227 vport->work_port_events |= WORKER_ELS_TMO;
5228 spin_unlock_irqrestore(&vport->work_port_lock, iflag);
5238 * @vport: pointer to a virtual N_Port data structure.
5242 * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by
5246 lpfc_els_timeout_handler(struct lpfc_vport *vport)
5248 struct lpfc_hba *phba = vport->phba;
5276 if (piocb->vport != vport)
5301 ndlp = __lpfc_findnode_rpi(vport, cmd->ulpContext);
5312 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5323 mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout);
5327 * lpfc_els_flush_cmd - Clean up the outstanding els commands to a vport
5328 * @vport: pointer to a host virtual N_Port data structure.
5331 * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport()
5333 * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For
5339 * completion queue IOCB that is associated with the @vport and is not
5347 lpfc_els_flush_cmd(struct lpfc_vport *vport)
5350 struct lpfc_hba *phba = vport->phba;
5355 lpfc_fabric_abort_vport(vport);
5372 if (piocb->vport != vport)
5384 if (piocb->vport != vport)
5466 struct lpfc_vport *vport = cmdiocbp->vport;
5467 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5521 * @vport: Pointer to vport object.
5529 lpfc_send_els_event(struct lpfc_vport *vport,
5535 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5540 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5550 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5603 * @vport: pointer to a host virtual N_Port data structure.
5615 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
5624 if (!vport || !(elsiocb->context2))
5635 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5642 if (lpfc_els_chk_latt(vport))
5645 /* Ignore traffic received during vport shutdown. */
5646 if (vport->load_flag & FC_UNLOADING)
5649 ndlp = lpfc_findnode_did(vport, did);
5656 lpfc_nlp_init(vport, ndlp, did);
5657 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
5662 ndlp = lpfc_enable_node(vport, ndlp,
5666 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
5675 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
5682 elsiocb->vport = vport;
5688 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5690 "Data: x%x\n", cmd, did, vport->port_state);
5693 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5695 did, vport->port_state, ndlp->nlp_flag);
5700 lpfc_send_els_event(vport, ndlp, payload);
5701 if (vport->port_state < LPFC_DISC_AUTH) {
5713 shost = lpfc_shost_from_vport(vport);
5718 lpfc_disc_state_machine(vport, ndlp, elsiocb,
5723 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5725 did, vport->port_state, ndlp->nlp_flag);
5728 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
5733 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5735 did, vport->port_state, ndlp->nlp_flag);
5738 lpfc_send_els_event(vport, ndlp, payload);
5739 if (vport->port_state < LPFC_DISC_AUTH) {
5743 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO);
5746 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5748 did, vport->port_state, ndlp->nlp_flag);
5751 lpfc_send_els_event(vport, ndlp, payload);
5752 if (vport->port_state < LPFC_DISC_AUTH) {
5756 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO);
5760 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
5765 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5767 did, vport->port_state, ndlp->nlp_flag);
5769 lpfc_send_els_event(vport, ndlp, payload);
5771 if (vport->port_state < LPFC_DISC_AUTH) {
5775 lpfc_disc_state_machine(vport, ndlp, elsiocb,
5779 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5781 did, vport->port_state, ndlp->nlp_flag);
5784 if (vport->port_state < LPFC_DISC_AUTH) {
5788 lpfc_disc_state_machine(vport, ndlp, elsiocb,
5792 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5794 did, vport->port_state, ndlp->nlp_flag);
5797 lpfc_els_rcv_farpr(vport, elsiocb, ndlp);
5800 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5802 did, vport->port_state, ndlp->nlp_flag);
5805 lpfc_els_rcv_farp(vport, elsiocb, ndlp);
5808 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5810 did, vport->port_state, ndlp->nlp_flag);
5813 lpfc_els_rcv_fan(vport, elsiocb, ndlp);
5816 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5818 did, vport->port_state, ndlp->nlp_flag);
5821 if (vport->port_state < LPFC_DISC_AUTH) {
5825 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI);
5828 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5830 did, vport->port_state, ndlp->nlp_flag);
5833 lpfc_els_rcv_lirr(vport, elsiocb, ndlp);
5838 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5840 did, vport->port_state, ndlp->nlp_flag);
5843 lpfc_els_rcv_rps(vport, elsiocb, ndlp);
5848 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5850 did, vport->port_state, ndlp->nlp_flag);
5853 lpfc_els_rcv_rpl(vport, elsiocb, ndlp);
5858 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5860 did, vport->port_state, ndlp->nlp_flag);
5863 lpfc_els_rcv_rnid(vport, elsiocb, ndlp);
5868 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5870 did, vport->port_state, ndlp->nlp_flag);
5873 lpfc_els_rcv_rrq(vport, elsiocb, ndlp);
5878 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
5880 cmd, did, vport->port_state);
5886 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5899 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp,
5908 if (vport && !(vport->load_flag & FC_UNLOADING))
5909 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5917 * lpfc_find_vport_by_vpid - Find a vport on a HBA through vport identifier
5921 * This routine finds a vport on a HBA (referred by @phba) through a
5922 * @vpi. The function walks the HBA's vport list and returns the address
5923 * of the vport with the matching @vpi.
5926 * NULL - No vport with the matching @vpi found
5927 * Otherwise - Address to the vport with the matching @vpi.
5932 struct lpfc_vport *vport;
5936 list_for_each_entry(vport, &phba->port_list, listentry) {
5937 if (vport->vpi == vpi) {
5939 return vport;
5962 struct lpfc_vport *vport = phba->pport;
5987 vport = phba->pport;
5989 vport = lpfc_find_vport_by_vpid(phba,
6010 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
6024 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
6036 * @vport: pointer to a virtual N_Port data structure.
6039 * State Change Request (SCR) for a @vport. This routine will create an
6040 * ndlp for the Name Server associated to the @vport if such node does
6043 * (FDMI) is configured to the @vport, a FDMI node will be created and
6047 lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
6051 ndlp = lpfc_findnode_did(vport, NameServer_DID);
6056 lpfc_disc_start(vport);
6059 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6060 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
6064 lpfc_nlp_init(vport, ndlp, NameServer_DID);
6066 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE);
6069 lpfc_disc_start(vport);
6072 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6073 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
6080 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
6082 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) {
6083 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6084 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
6089 if (vport->cfg_fdmi_on) {
6093 lpfc_nlp_init(vport, ndlp_fdmi, FDMI_DID);
6095 lpfc_nlp_set_state(vport, ndlp_fdmi,
6097 lpfc_issue_els_plogi(vport, ndlp_fdmi->nlp_DID,
6105 * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport
6109 * This routine is the completion callback function to register new vport
6110 * mailbox command. If the new vport mailbox command completes successfully,
6112 * new vport created is actually a physical port, with VPI 0) or the port
6119 struct lpfc_vport *vport = pmb->vport;
6120 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6126 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
6130 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
6142 /* giving up on vport registration */
6143 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6145 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
6147 lpfc_can_disctmo(vport);
6152 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
6154 lpfc_init_vpi(phba, pmb, vport->vpi);
6155 pmb->vport = vport;
6160 lpfc_printf_vlog(vport,
6171 lpfc_mbx_unreg_vpi(vport);
6173 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
6175 if (vport->port_type == LPFC_PHYSICAL_PORT
6176 && !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG))
6177 lpfc_initial_flogi(vport);
6179 lpfc_initial_fdisc(vport);
6184 vport->vpi_state |= LPFC_VPI_REGISTERED;
6186 if (vport == phba->pport) {
6188 lpfc_issue_fabric_reglogin(vport);
6192 * FDISC, do not start vport discovery.
6194 if (vport->port_state != LPFC_FDISC)
6196 lpfc_do_scr_ns_plogi(phba, vport);
6199 lpfc_do_scr_ns_plogi(phba, vport);
6212 * lpfc_register_new_vport - Register a new vport with a HBA
6214 * @vport: pointer to a host virtual N_Port data structure.
6217 * This routine registers the @vport as a new virtual port with a HBA.
6221 lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
6224 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6229 lpfc_reg_vpi(vport, mbox);
6230 mbox->vport = vport;
6241 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
6246 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
6253 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6255 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
6261 * lpfc_cancel_all_vport_retry_delay_timer - Cancel all vport retry delay timer
6357 * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the
6358 * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID
6359 * assigned to the vport has been changed with the completion of the FDISC
6362 * routine is invoked to register new vport with the HBA. Otherwise, the
6370 struct lpfc_vport *vport = cmdiocb->vport;
6371 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6378 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6381 vport->fc_prevDID);
6387 lpfc_set_disctmo(piocb->vport);
6390 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
6392 irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID);
6405 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
6411 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
6412 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
6413 vport->fc_flag |= FC_FABRIC;
6414 if (vport->phba->fc_topology == TOPOLOGY_LOOP)
6415 vport->fc_flag |= FC_PUBLIC_LOOP;
6418 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID;
6419 lpfc_vport_set_state(vport, FC_VPORT_ACTIVE);
6420 if ((vport->fc_prevDID != vport->fc_myDID) &&
6421 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
6427 &vport->fc_nodes, nlp_listp) {
6435 lpfc_unreg_rpi(vport, np);
6437 lpfc_cleanup_pending_mbox(vport);
6438 lpfc_mbx_unreg_vpi(vport);
6440 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
6442 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
6444 vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG;
6447 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
6452 lpfc_register_new_vport(phba, vport, ndlp);
6456 if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)
6457 lpfc_issue_init_vpi(vport);
6458 else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
6459 lpfc_register_new_vport(phba, vport, ndlp);
6461 lpfc_do_scr_ns_plogi(phba, vport);
6464 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6466 lpfc_can_disctmo(vport);
6474 * @vport: pointer to a virtual N_Port data structure.
6479 * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb()
6493 lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
6496 struct lpfc_hba *phba = vport->phba;
6505 vport->port_state = LPFC_FDISC;
6507 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
6510 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6511 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
6525 elsiocb->iocb.ulpContext = vport->vpi + phba->vpi_base;
6535 memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm));
6548 memcpy(pcmd, &vport->fc_portname, 8);
6551 memcpy(pcmd, &vport->fc_nodename, 8);
6553 lpfc_set_disctmo(vport);
6558 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
6565 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
6566 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
6570 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING);
6575 * lpfc_cmpl_els_npiv_logo - Completion function with vport logo
6581 * ELS command off a vport. It frees the command IOCB and then decrement the
6592 struct lpfc_vport *vport = cmdiocb->vport;
6598 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
6603 vport->unreg_vpi_cmpl = VPORT_ERROR;
6610 * lpfc_issue_els_npiv_logo - Issue a logo off a vport
6611 * @vport: pointer to a virtual N_Port data structure.
6614 * This routine issues a LOGO ELS command to an @ndlp off a @vport.
6622 * 0 - Successfully issued logo off the @vport
6623 * 1 - Failed to issue logo off the @vport
6626 lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
6628 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
6629 struct lpfc_hba *phba = vport->phba;
6636 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID,
6647 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
6649 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
6651 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
6734 lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD,
6736 iocb->vport->port_state, 0, 0);
6903 lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD,
6905 iocb->vport->port_state, 0, 0);
6925 * lpfc_fabric_abort_vport - Abort a vport's iocbs from driver fabric iocb list
6926 * @vport: pointer to a virtual N_Port data structure.
6928 * This routine aborts all the IOCBs associated with a @vport from the
6931 * list, removes each IOCB associated with the @vport off the list, set the
6935 static void lpfc_fabric_abort_vport(struct lpfc_vport *vport)
6938 struct lpfc_hba *phba = vport->phba;
6945 if (piocb->vport != vport)