Commit 685f0bf7 authored by James Smart's avatar James Smart Committed by James Bottomley

[SCSI] lpfc 8.1.12 : Collapse discovery lists to a single node list

Collapse discovery lists to a single node list.
Signed-off-by: default avatarJames Smart <James.Smart@emulex.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 329f9bc7
...@@ -255,17 +255,7 @@ struct lpfc_hba { ...@@ -255,17 +255,7 @@ struct lpfc_hba {
struct lpfc_stats fc_stat; struct lpfc_stats fc_stat;
/* These are the head/tail pointers for the bind, plogi, adisc, unmap, struct list_head fc_nodes;
* and map lists. Their counters are immediately following.
*/
struct list_head fc_plogi_list;
struct list_head fc_adisc_list;
struct list_head fc_reglogin_list;
struct list_head fc_prli_list;
struct list_head fc_nlpunmap_list;
struct list_head fc_nlpmap_list;
struct list_head fc_npr_list;
struct list_head fc_unused_list;
/* Keep counters for the number of entries in each list. */ /* Keep counters for the number of entries in each list. */
uint16_t fc_plogi_cnt; uint16_t fc_plogi_cnt;
......
...@@ -1781,67 +1781,51 @@ lpfc_reset_stats(struct Scsi_Host *shost) ...@@ -1781,67 +1781,51 @@ lpfc_reset_stats(struct Scsi_Host *shost)
* The LPFC driver treats linkdown handling as target loss events so there * The LPFC driver treats linkdown handling as target loss events so there
* are no sysfs handlers for link_down_tmo. * are no sysfs handlers for link_down_tmo.
*/ */
static void
lpfc_get_starget_port_id(struct scsi_target *starget) static struct lpfc_nodelist *
lpfc_get_node_by_target(struct scsi_target *starget)
{ {
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata; struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
uint32_t did = -1; struct lpfc_nodelist *ndlp;
struct lpfc_nodelist *ndlp = NULL;
spin_lock_irq(shost->host_lock); spin_lock_irq(shost->host_lock);
/* Search the mapped list for this target ID */ /* Search for this, mapped, target ID */
list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
if (starget->id == ndlp->nlp_sid) { if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
did = ndlp->nlp_DID; starget->id == ndlp->nlp_sid) {
break; spin_unlock_irq(shost->host_lock);
return ndlp;
} }
} }
spin_unlock_irq(shost->host_lock); spin_unlock_irq(shost->host_lock);
return NULL;
}
fc_starget_port_id(starget) = did; static void
lpfc_get_starget_port_id(struct scsi_target *starget)
{
struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1;
} }
static void static void
lpfc_get_starget_node_name(struct scsi_target *starget) lpfc_get_starget_node_name(struct scsi_target *starget)
{ {
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
u64 node_name = 0;
struct lpfc_nodelist *ndlp = NULL;
spin_lock_irq(shost->host_lock); fc_starget_node_name(starget) =
/* Search the mapped list for this target ID */ ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0;
list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
if (starget->id == ndlp->nlp_sid) {
node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
break;
}
}
spin_unlock_irq(shost->host_lock);
fc_starget_node_name(starget) = node_name;
} }
static void static void
lpfc_get_starget_port_name(struct scsi_target *starget) lpfc_get_starget_port_name(struct scsi_target *starget)
{ {
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
u64 port_name = 0;
struct lpfc_nodelist *ndlp = NULL;
spin_lock_irq(shost->host_lock);
/* Search the mapped list for this target ID */
list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
if (starget->id == ndlp->nlp_sid) {
port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
break;
}
}
spin_unlock_irq(shost->host_lock);
fc_starget_port_name(starget) = port_name; fc_starget_port_name(starget) =
ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0;
} }
static void static void
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
* included with this package. * * included with this package. *
*******************************************************************/ *******************************************************************/
typedef int (*node_filter)(struct lpfc_nodelist *ndlp, void *param);
struct fc_rport; struct fc_rport;
void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);
void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *); void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
...@@ -178,9 +180,8 @@ int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t, ...@@ -178,9 +180,8 @@ int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
void lpfc_mbox_timeout(unsigned long); void lpfc_mbox_timeout(unsigned long);
void lpfc_mbox_timeout_handler(struct lpfc_hba *); void lpfc_mbox_timeout_handler(struct lpfc_hba *);
struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_hba *, uint32_t, uint32_t); struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_hba *, uint32_t);
struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_hba *, uint32_t, struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_hba *, struct lpfc_name *);
struct lpfc_name *);
int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
uint32_t timeout); uint32_t timeout);
......
...@@ -443,10 +443,8 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -443,10 +443,8 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) { if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) {
phba->fc_ns_retry++; phba->fc_ns_retry++;
/* CT command is being retried */ /* CT command is being retried */
ndlp = ndlp = lpfc_findnode_did(phba, NameServer_DID);
lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
NameServer_DID);
if (ndlp) {
if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) ==
0) { 0) {
goto out; goto out;
...@@ -730,7 +728,7 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba * phba, ...@@ -730,7 +728,7 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba * phba,
uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp;
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, FDMI_DID); ndlp = lpfc_findnode_did(phba, FDMI_DID);
if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
/* FDMI rsp failed */ /* FDMI rsp failed */
lpfc_printf_log(phba, lpfc_printf_log(phba,
...@@ -1162,7 +1160,7 @@ lpfc_fdmi_tmo_handler(struct lpfc_hba *phba) ...@@ -1162,7 +1160,7 @@ lpfc_fdmi_tmo_handler(struct lpfc_hba *phba)
{ {
struct lpfc_nodelist *ndlp; struct lpfc_nodelist *ndlp;
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, FDMI_DID); ndlp = lpfc_findnode_did(phba, FDMI_DID);
if (ndlp) { if (ndlp) {
if (init_utsname()->nodename[0] != '\0') { if (init_utsname()->nodename[0] != '\0') {
lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DHBA); lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DHBA);
......
...@@ -83,15 +83,6 @@ struct lpfc_nodelist { ...@@ -83,15 +83,6 @@ struct lpfc_nodelist {
}; };
/* Defines for nlp_flag (uint32) */ /* Defines for nlp_flag (uint32) */
#define NLP_UNUSED_LIST 0x1 /* Flg to indicate node will be freed */
#define NLP_PLOGI_LIST 0x2 /* Flg to indicate sent PLOGI */
#define NLP_ADISC_LIST 0x3 /* Flg to indicate sent ADISC */
#define NLP_REGLOGIN_LIST 0x4 /* Flg to indicate sent REG_LOGIN */
#define NLP_PRLI_LIST 0x5 /* Flg to indicate sent PRLI */
#define NLP_UNMAPPED_LIST 0x6 /* Node is now unmapped */
#define NLP_MAPPED_LIST 0x7 /* Node is now mapped */
#define NLP_NPR_LIST 0x8 /* Node is in NPort Recovery state */
#define NLP_LIST_MASK 0xf /* mask to see what list node is on */
#define NLP_PLOGI_SND 0x20 /* sent PLOGI request for this entry */ #define NLP_PLOGI_SND 0x20 /* sent PLOGI request for this entry */
#define NLP_PRLI_SND 0x40 /* sent PRLI request for this entry */ #define NLP_PRLI_SND 0x40 /* sent PRLI request for this entry */
#define NLP_ADISC_SND 0x80 /* sent ADISC request for this entry */ #define NLP_ADISC_SND 0x80 /* sent ADISC request for this entry */
...@@ -109,17 +100,6 @@ struct lpfc_nodelist { ...@@ -109,17 +100,6 @@ struct lpfc_nodelist {
NPR list */ NPR list */
#define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */ #define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */
/* Defines for list searchs */
#define NLP_SEARCH_MAPPED 0x1 /* search mapped */
#define NLP_SEARCH_UNMAPPED 0x2 /* search unmapped */
#define NLP_SEARCH_PLOGI 0x4 /* search plogi */
#define NLP_SEARCH_ADISC 0x8 /* search adisc */
#define NLP_SEARCH_REGLOGIN 0x10 /* search reglogin */
#define NLP_SEARCH_PRLI 0x20 /* search prli */
#define NLP_SEARCH_NPR 0x40 /* search npr */
#define NLP_SEARCH_UNUSED 0x80 /* search mapped */
#define NLP_SEARCH_ALL 0xff /* search all lists */
/* There are 4 different double linked lists nodelist entries can reside on. /* There are 4 different double linked lists nodelist entries can reside on.
* The Port Login (PLOGI) list and Address Discovery (ADISC) list are used * The Port Login (PLOGI) list and Address Discovery (ADISC) list are used
* when Link Up discovery or Registered State Change Notification (RSCN) * when Link Up discovery or Registered State Change Notification (RSCN)
......
...@@ -372,7 +372,7 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, ...@@ -372,7 +372,7 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
} }
lpfc_nlp_put(ndlp); lpfc_nlp_put(ndlp);
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, PT2PT_RemoteID); ndlp = lpfc_findnode_did(phba, PT2PT_RemoteID);
if (!ndlp) { if (!ndlp) {
/* /*
* Cannot find existing Fabric ndlp, so allocate a * Cannot find existing Fabric ndlp, so allocate a
...@@ -592,12 +592,12 @@ lpfc_els_abort_flogi(struct lpfc_hba * phba) ...@@ -592,12 +592,12 @@ lpfc_els_abort_flogi(struct lpfc_hba * phba)
} }
int int
lpfc_initial_flogi(struct lpfc_hba * phba) lpfc_initial_flogi(struct lpfc_hba *phba)
{ {
struct lpfc_nodelist *ndlp; struct lpfc_nodelist *ndlp;
/* First look for the Fabric ndlp */ /* First look for the Fabric ndlp */
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, Fabric_DID); ndlp = lpfc_findnode_did(phba, Fabric_DID);
if (!ndlp) { if (!ndlp) {
/* Cannot find existing Fabric ndlp, so allocate a new one */ /* Cannot find existing Fabric ndlp, so allocate a new one */
ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
...@@ -637,7 +637,7 @@ lpfc_more_plogi(struct lpfc_hba * phba) ...@@ -637,7 +637,7 @@ lpfc_more_plogi(struct lpfc_hba * phba)
} }
static struct lpfc_nodelist * static struct lpfc_nodelist *
lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp, lpfc_plogi_confirm_nport(struct lpfc_hba *phba, struct lpfc_dmabuf *prsp,
struct lpfc_nodelist *ndlp) struct lpfc_nodelist *ndlp)
{ {
struct lpfc_nodelist *new_ndlp; struct lpfc_nodelist *new_ndlp;
...@@ -654,12 +654,12 @@ lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp, ...@@ -654,12 +654,12 @@ lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp,
lp = (uint32_t *) prsp->virt; lp = (uint32_t *) prsp->virt;
sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
memset(name, 0, sizeof (struct lpfc_name)); memset(name, 0, sizeof(struct lpfc_name));
/* Now we to find out if the NPort we are logging into, matches the WWPN /* Now we find out if the NPort we are logging into, matches the WWPN
* we have for that ndlp. If not, we have some work to do. * we have for that ndlp. If not, we have some work to do.
*/ */
new_ndlp = lpfc_findnode_wwpn(phba, NLP_SEARCH_ALL, &sp->portName); new_ndlp = lpfc_findnode_wwpn(phba, &sp->portName);
if (new_ndlp == ndlp) if (new_ndlp == ndlp)
return ndlp; return ndlp;
...@@ -705,8 +705,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -705,8 +705,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
cmdiocb->context_un.rsp_iocb = rspiocb; cmdiocb->context_un.rsp_iocb = rspiocb;
irsp = &rspiocb->iocb; irsp = &rspiocb->iocb;
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, ndlp = lpfc_findnode_did(phba, irsp->un.elsreq64.remoteID);
irsp->un.elsreq64.remoteID);
if (!ndlp) if (!ndlp)
goto out; goto out;
...@@ -1408,7 +1407,7 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry) ...@@ -1408,7 +1407,7 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
memcpy(&fp->RportName, &phba->fc_portname, sizeof (struct lpfc_name)); memcpy(&fp->RportName, &phba->fc_portname, sizeof (struct lpfc_name));
memcpy(&fp->RnodeName, &phba->fc_nodename, sizeof (struct lpfc_name)); memcpy(&fp->RnodeName, &phba->fc_nodename, sizeof (struct lpfc_name));
if ((ondlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, nportid))) { if ((ondlp = lpfc_findnode_did(phba, nportid))) {
memcpy(&fp->OportName, &ondlp->nlp_portname, memcpy(&fp->OportName, &ondlp->nlp_portname,
sizeof (struct lpfc_name)); sizeof (struct lpfc_name));
memcpy(&fp->OnodeName, &ondlp->nlp_nodename, memcpy(&fp->OnodeName, &ondlp->nlp_nodename,
...@@ -1595,7 +1594,7 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -1595,7 +1594,7 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
else { else {
/* We should only hit this case for retrying PLOGI */ /* We should only hit this case for retrying PLOGI */
did = irsp->un.elsreq64.remoteID; did = irsp->un.elsreq64.remoteID;
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did); ndlp = lpfc_findnode_did(phba, did);
if (!ndlp && (cmd != ELS_CMD_PLOGI)) if (!ndlp && (cmd != ELS_CMD_PLOGI))
return 1; return 1;
} }
...@@ -2291,31 +2290,31 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba *phba, uint8_t format, ...@@ -2291,31 +2290,31 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba *phba, uint8_t format,
} }
int int
lpfc_els_disc_adisc(struct lpfc_hba * phba) lpfc_els_disc_adisc(struct lpfc_hba *phba)
{ {
int sentadisc; int sentadisc;
struct lpfc_nodelist *ndlp, *next_ndlp; struct lpfc_nodelist *ndlp, *next_ndlp;
sentadisc = 0; sentadisc = 0;
/* go thru NPR list and issue any remaining ELS ADISCs */ /* go thru NPR nodes and issue any remaining ELS ADISCs */
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) {
nlp_listp) { if (ndlp->nlp_state == NLP_STE_NPR_NODE &&
if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 &&
if (ndlp->nlp_flag & NLP_NPR_ADISC) { (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) {
ndlp->nlp_flag &= ~NLP_NPR_ADISC; spin_lock_irq(phba->host->host_lock);
ndlp->nlp_prev_state = ndlp->nlp_state; ndlp->nlp_flag &= ~NLP_NPR_ADISC;
lpfc_nlp_set_state(phba, ndlp, spin_unlock_irq(phba->host->host_lock);
NLP_STE_ADISC_ISSUE); ndlp->nlp_prev_state = ndlp->nlp_state;
lpfc_issue_els_adisc(phba, ndlp, 0); lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
sentadisc++; lpfc_issue_els_adisc(phba, ndlp, 0);
phba->num_disc_nodes++; sentadisc++;
if (phba->num_disc_nodes >= phba->num_disc_nodes++;
phba->cfg_discovery_threads) { if (phba->num_disc_nodes >=
spin_lock_irq(phba->host->host_lock); phba->cfg_discovery_threads) {
phba->fc_flag |= FC_NLP_MORE; spin_lock_irq(phba->host->host_lock);
spin_unlock_irq(phba->host->host_lock); phba->fc_flag |= FC_NLP_MORE;
break; spin_unlock_irq(phba->host->host_lock);
} break;
} }
} }
} }
...@@ -2335,24 +2334,22 @@ lpfc_els_disc_plogi(struct lpfc_hba * phba) ...@@ -2335,24 +2334,22 @@ lpfc_els_disc_plogi(struct lpfc_hba * phba)
sentplogi = 0; sentplogi = 0;
/* go thru NPR list and issue any remaining ELS PLOGIs */ /* go thru NPR list and issue any remaining ELS PLOGIs */
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) {
nlp_listp) { if (ndlp->nlp_state == NLP_STE_NPR_NODE &&
if ((ndlp->nlp_flag & NLP_NPR_2B_DISC) && (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 &&
(!(ndlp->nlp_flag & NLP_DELAY_TMO))) { (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 &&
if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { (ndlp->nlp_flag & NLP_NPR_ADISC) == 0) {
ndlp->nlp_prev_state = ndlp->nlp_state; ndlp->nlp_prev_state = ndlp->nlp_state;
lpfc_nlp_set_state(phba, ndlp, lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
NLP_STE_PLOGI_ISSUE); lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); sentplogi++;
sentplogi++; phba->num_disc_nodes++;
phba->num_disc_nodes++; if (phba->num_disc_nodes >=
if (phba->num_disc_nodes >= phba->cfg_discovery_threads) {
phba->cfg_discovery_threads) { spin_lock_irq(phba->host->host_lock);
spin_lock_irq(phba->host->host_lock); phba->fc_flag |= FC_NLP_MORE;
phba->fc_flag |= FC_NLP_MORE; spin_unlock_irq(phba->host->host_lock);
spin_unlock_irq(phba->host->host_lock); break;
break;
}
} }
} }
} }
...@@ -2456,40 +2453,28 @@ lpfc_rscn_payload_check(struct lpfc_hba * phba, uint32_t did) ...@@ -2456,40 +2453,28 @@ lpfc_rscn_payload_check(struct lpfc_hba * phba, uint32_t did)
static int static int
lpfc_rscn_recovery_check(struct lpfc_hba *phba) lpfc_rscn_recovery_check(struct lpfc_hba *phba)
{ {
struct lpfc_nodelist *ndlp = NULL, *next_ndlp; struct lpfc_nodelist *ndlp = NULL;
struct list_head *listp;
struct list_head *node_list[7];
int i;
/* Look at all nodes effected by pending RSCNs and move /* Look at all nodes effected by pending RSCNs and move
* them to NPR list. * them to NPR state.
*/ */
node_list[0] = &phba->fc_npr_list; /* MUST do this list first */
node_list[1] = &phba->fc_nlpmap_list;
node_list[2] = &phba->fc_nlpunmap_list;
node_list[3] = &phba->fc_prli_list;
node_list[4] = &phba->fc_reglogin_list;
node_list[5] = &phba->fc_adisc_list;
node_list[6] = &phba->fc_plogi_list;
for (i = 0; i < 7; i++) {
listp = node_list[i];
if (list_empty(listp))
continue;
list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) { list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
if (!(lpfc_rscn_payload_check(phba, ndlp->nlp_DID))) if (ndlp->nlp_state == NLP_STE_UNUSED_NODE ||
continue; lpfc_rscn_payload_check(phba, ndlp->nlp_DID) == 0)
continue;
lpfc_disc_state_machine(phba, ndlp, NULL, lpfc_disc_state_machine(phba, ndlp, NULL,
NLP_EVT_DEVICE_RECOVERY); NLP_EVT_DEVICE_RECOVERY);
/* Make sure NLP_DELAY_TMO is NOT running /*
* after a device recovery event. * Make sure NLP_DELAY_TMO is NOT running after a device
*/ * recovery event.
if (ndlp->nlp_flag & NLP_DELAY_TMO) */
lpfc_cancel_retry_delay_tmo(phba, ndlp); if (ndlp->nlp_flag & NLP_DELAY_TMO)
} lpfc_cancel_retry_delay_tmo(phba, ndlp);
} }
return 0; return 0;
} }
...@@ -2614,8 +2599,8 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba) ...@@ -2614,8 +2599,8 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
/* To process RSCN, first compare RSCN data with NameServer */ /* To process RSCN, first compare RSCN data with NameServer */
phba->fc_ns_retry = 0; phba->fc_ns_retry = 0;
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, NameServer_DID); ndlp = lpfc_findnode_did(phba, NameServer_DID);
if (ndlp) { if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
/* Good ndlp, issue CT Request to NameServer */ /* Good ndlp, issue CT Request to NameServer */
if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 0) { if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 0) {
/* Wait for NameServer query cmpl before we can /* Wait for NameServer query cmpl before we can
...@@ -2625,7 +2610,7 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba) ...@@ -2625,7 +2610,7 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
} else { } else {
/* If login to NameServer does not exist, issue one */ /* If login to NameServer does not exist, issue one */
/* Good status, issue PLOGI to NameServer */ /* Good status, issue PLOGI to NameServer */
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID); ndlp = lpfc_findnode_did(phba, NameServer_DID);
if (ndlp) { if (ndlp) {
/* Wait for NameServer login cmpl before we can /* Wait for NameServer login cmpl before we can
continue */ continue */
...@@ -2859,6 +2844,7 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) ...@@ -2859,6 +2844,7 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; elsiocb->iocb_cmpl = lpfc_cmpl_els_acc;
phba->fc_stat.elsXmitACC++; phba->fc_stat.elsXmitACC++;
if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
lpfc_els_free_iocb(phba, elsiocb); lpfc_els_free_iocb(phba, elsiocb);
} }
...@@ -3144,8 +3130,9 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -3144,8 +3130,9 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
*/ */
list_for_each_entry_safe(ndlp, next_ndlp, list_for_each_entry_safe(ndlp, next_ndlp,
&phba->fc_npr_list, nlp_listp) { &phba->fc_nodes, nlp_listp) {
if (ndlp->nlp_state != NLP_STE_NPR_NODE)
continue;
if (ndlp->nlp_type & NLP_FABRIC) { if (ndlp->nlp_type & NLP_FABRIC) {
/* /*
* Clean up old Fabric, Nameserver and * Clean up old Fabric, Nameserver and
...@@ -3168,8 +3155,10 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -3168,8 +3155,10 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
/* Discovery not needed, /* Discovery not needed,
* move the nodes to their original state. * move the nodes to their original state.
*/ */
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes,
nlp_listp) { nlp_listp) {
if (ndlp->nlp_state != NLP_STE_NPR_NODE)
continue;
switch (ndlp->nlp_prev_state) { switch (ndlp->nlp_prev_state) {
case NLP_STE_UNMAPPED_NODE: case NLP_STE_UNMAPPED_NODE:
...@@ -3409,7 +3398,7 @@ lpfc_els_unsol_event(struct lpfc_hba * phba, ...@@ -3409,7 +3398,7 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
} }
did = icmd->un.rcvels.remoteID; did = icmd->un.rcvels.remoteID;
ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did); ndlp = lpfc_findnode_did(phba, did);
if (!ndlp) { if (!ndlp) {
/* Cannot find existing Fabric ndlp, so allocate a new one */ /* Cannot find existing Fabric ndlp, so allocate a new one */
ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
......
This diff is collapsed.
...@@ -1185,63 +1185,11 @@ lpfc_cleanup(struct lpfc_hba * phba) ...@@ -1185,63 +1185,11 @@ lpfc_cleanup(struct lpfc_hba * phba)
/* clean up phba - lpfc specific */ /* clean up phba - lpfc specific */
lpfc_can_disctmo(phba); lpfc_can_disctmo(phba);
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list, list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp)
nlp_listp) {
lpfc_nlp_put(ndlp); lpfc_nlp_put(ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list,
nlp_listp) {
lpfc_nlp_put(ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list,
nlp_listp) {
lpfc_drop_node(phba, ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
nlp_listp) {
lpfc_nlp_put(ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
nlp_listp) {
lpfc_nlp_put(ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list,
nlp_listp) {
lpfc_nlp_put(ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list, INIT_LIST_HEAD(&phba->fc_nodes);
nlp_listp) {
lpfc_nlp_put(ndlp);
}
list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
nlp_listp) {
lpfc_nlp_put(ndlp);
}
INIT_LIST_HEAD(&phba->fc_nlpmap_list);
INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
INIT_LIST_HEAD(&phba->fc_unused_list);
INIT_LIST_HEAD(&phba->fc_plogi_list);
INIT_LIST_HEAD(&phba->fc_adisc_list);
INIT_LIST_HEAD(&phba->fc_reglogin_list);
INIT_LIST_HEAD(&phba->fc_prli_list);
INIT_LIST_HEAD(&phba->fc_npr_list);
phba->fc_map_cnt = 0;
phba->fc_unmap_cnt = 0;
phba->fc_plogi_cnt = 0;
phba->fc_adisc_cnt = 0;
phba->fc_reglogin_cnt = 0;
phba->fc_prli_cnt = 0;
phba->fc_npr_cnt = 0;
phba->fc_unused_cnt= 0;
return; return;
} }
...@@ -1336,8 +1284,6 @@ void ...@@ -1336,8 +1284,6 @@ void
lpfc_offline_prep(struct lpfc_hba * phba) lpfc_offline_prep(struct lpfc_hba * phba)
{ {
struct lpfc_nodelist *ndlp, *next_ndlp; struct lpfc_nodelist *ndlp, *next_ndlp;
struct list_head *listp, *node_list[7];
int i;
if (phba->fc_flag & FC_OFFLINE_MODE) if (phba->fc_flag & FC_OFFLINE_MODE)
return; return;
...@@ -1347,21 +1293,9 @@ lpfc_offline_prep(struct lpfc_hba * phba) ...@@ -1347,21 +1293,9 @@ lpfc_offline_prep(struct lpfc_hba * phba)
lpfc_linkdown(phba); lpfc_linkdown(phba);
/* Issue an unreg_login to all nodes */ /* Issue an unreg_login to all nodes */
node_list[0] = &phba->fc_npr_list; /* MUST do this list first */ list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp)
node_list[1] = &phba->fc_nlpmap_list; if (ndlp->nlp_state != NLP_STE_UNUSED_NODE)
node_list[2] = &phba->fc_nlpunmap_list;
node_list[3] = &phba->fc_prli_list;
node_list[4] = &phba->fc_reglogin_list;
node_list[5] = &phba->fc_adisc_list;
node_list[6] = &phba->fc_plogi_list;
for (i = 0; i < 7; i++) {
listp = node_list[i];
if (list_empty(listp))
continue;
list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp)
lpfc_unreg_rpi(phba, ndlp); lpfc_unreg_rpi(phba, ndlp);
}
lpfc_sli_flush_mbox_queue(phba); lpfc_sli_flush_mbox_queue(phba);
} }
...@@ -1500,15 +1434,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) ...@@ -1500,15 +1434,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
host->max_lun = phba->cfg_max_luns; host->max_lun = phba->cfg_max_luns;
host->this_id = -1; host->this_id = -1;
/* Initialize all internally managed lists. */ INIT_LIST_HEAD(&phba->fc_nodes);
INIT_LIST_HEAD(&phba->fc_nlpmap_list);
INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
INIT_LIST_HEAD(&phba->fc_unused_list);
INIT_LIST_HEAD(&phba->fc_plogi_list);
INIT_LIST_HEAD(&phba->fc_adisc_list);
INIT_LIST_HEAD(&phba->fc_reglogin_list);
INIT_LIST_HEAD(&phba->fc_prli_list);
INIT_LIST_HEAD(&phba->fc_npr_list);
pci_set_master(pdev); pci_set_master(pdev);
retval = pci_set_mwi(pdev); retval = pci_set_mwi(pdev);
......
...@@ -1175,10 +1175,12 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) ...@@ -1175,10 +1175,12 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
* fail, this routine returns failure to the midlayer. * fail, this routine returns failure to the midlayer.
*/ */
for (i = 0; i < LPFC_MAX_TARGET; i++) { for (i = 0; i < LPFC_MAX_TARGET; i++) {
/* Search the mapped list for this target ID */ /* Search for mapped node by target ID */
match = 0; match = 0;
list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
if ((i == ndlp->nlp_sid) && ndlp->rport) { if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
i == ndlp->nlp_sid &&
ndlp->rport) {
match = 1; match = 1;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment