diff options
author | James Smart <James.Smart@Emulex.Com> | 2007-04-25 09:52:27 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-06 10:33:14 -0400 |
commit | de0c5b32b50ef2673f4cd434b9c2732237d715dd (patch) | |
tree | b531709da0a9e6a1cc8d18992a7681db4d163f23 /drivers/scsi/lpfc/lpfc_hbadisc.c | |
parent | 2534ba756ec407d343af45168273d3a64825a7ba (diff) |
[SCSI] lpfc 8.1.12 : Reorganize lpfc_nlp_list() and callers to prepare for nodelist simplification
Reorganize lpfc_nlp_list() and callers to prepare for nodelist simplification.
Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hbadisc.c | 297 |
1 files changed, 169 insertions, 128 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2c21641265b5..fda8f07f1d0b 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -429,9 +429,8 @@ lpfc_linkdown(struct lpfc_hba * phba) | |||
429 | 429 | ||
430 | /* free any ndlp's on unused list */ | 430 | /* free any ndlp's on unused list */ |
431 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | 431 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, |
432 | nlp_listp) { | 432 | nlp_listp) |
433 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 433 | lpfc_drop_node(phba, ndlp); |
434 | } | ||
435 | 434 | ||
436 | /* Setup myDID for link up if we are in pt2pt mode */ | 435 | /* Setup myDID for link up if we are in pt2pt mode */ |
437 | if (phba->fc_flag & FC_PT2PT) { | 436 | if (phba->fc_flag & FC_PT2PT) { |
@@ -497,8 +496,8 @@ lpfc_linkup(struct lpfc_hba * phba) | |||
497 | /* On Linkup its safe to clean up the | 496 | /* On Linkup its safe to clean up the |
498 | * ndlp from Fabric connections. | 497 | * ndlp from Fabric connections. |
499 | */ | 498 | */ |
500 | lpfc_nlp_list(phba, ndlp, | 499 | lpfc_nlp_set_state(phba, ndlp, |
501 | NLP_UNUSED_LIST); | 500 | NLP_STE_UNUSED_NODE); |
502 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { | 501 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { |
503 | /* Fail outstanding IO now since device | 502 | /* Fail outstanding IO now since device |
504 | * is marked for PLOGI. | 503 | * is marked for PLOGI. |
@@ -511,9 +510,8 @@ lpfc_linkup(struct lpfc_hba * phba) | |||
511 | 510 | ||
512 | /* free any ndlp's on unused list */ | 511 | /* free any ndlp's on unused list */ |
513 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | 512 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, |
514 | nlp_listp) { | 513 | nlp_listp) |
515 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 514 | lpfc_drop_node(phba, ndlp); |
516 | } | ||
517 | 515 | ||
518 | return 0; | 516 | return 0; |
519 | } | 517 | } |
@@ -993,8 +991,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
993 | 991 | ||
994 | ndlp->nlp_rpi = mb->un.varWords[0]; | 992 | ndlp->nlp_rpi = mb->un.varWords[0]; |
995 | ndlp->nlp_type |= NLP_FABRIC; | 993 | ndlp->nlp_type |= NLP_FABRIC; |
996 | ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; | 994 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE); |
997 | lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); | ||
998 | 995 | ||
999 | if (phba->hba_state == LPFC_FABRIC_CFG_LINK) { | 996 | if (phba->hba_state == LPFC_FABRIC_CFG_LINK) { |
1000 | /* This NPort has been assigned an NPort_ID by the fabric as a | 997 | /* This NPort has been assigned an NPort_ID by the fabric as a |
@@ -1024,8 +1021,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
1024 | ndlp->nlp_type |= NLP_FABRIC; | 1021 | ndlp->nlp_type |= NLP_FABRIC; |
1025 | } | 1022 | } |
1026 | } | 1023 | } |
1027 | ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; | 1024 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE); |
1028 | lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); | ||
1029 | lpfc_issue_els_plogi(phba, NameServer_DID, 0); | 1025 | lpfc_issue_els_plogi(phba, NameServer_DID, 0); |
1030 | if (phba->cfg_fdmi_on) { | 1026 | if (phba->cfg_fdmi_on) { |
1031 | ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, | 1027 | ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, |
@@ -1068,8 +1064,8 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
1068 | if (mb->mbxStatus) { | 1064 | if (mb->mbxStatus) { |
1069 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 1065 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
1070 | kfree(mp); | 1066 | kfree(mp); |
1071 | mempool_free( pmb, phba->mbox_mem_pool); | 1067 | mempool_free(pmb, phba->mbox_mem_pool); |
1072 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 1068 | lpfc_drop_node(phba, ndlp); |
1073 | 1069 | ||
1074 | /* RegLogin failed, so just use loop map to make discovery | 1070 | /* RegLogin failed, so just use loop map to make discovery |
1075 | list */ | 1071 | list */ |
@@ -1084,8 +1080,7 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
1084 | 1080 | ||
1085 | ndlp->nlp_rpi = mb->un.varWords[0]; | 1081 | ndlp->nlp_rpi = mb->un.varWords[0]; |
1086 | ndlp->nlp_type |= NLP_FABRIC; | 1082 | ndlp->nlp_type |= NLP_FABRIC; |
1087 | ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; | 1083 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE); |
1088 | lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); | ||
1089 | 1084 | ||
1090 | if (phba->hba_state < LPFC_HBA_READY) { | 1085 | if (phba->hba_state < LPFC_HBA_READY) { |
1091 | /* Link up discovery requires Fabrib registration. */ | 1086 | /* Link up discovery requires Fabrib registration. */ |
@@ -1170,72 +1165,82 @@ lpfc_unregister_remote_port(struct lpfc_hba * phba, | |||
1170 | return; | 1165 | return; |
1171 | } | 1166 | } |
1172 | 1167 | ||
1173 | int | 1168 | static void |
1174 | lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | 1169 | lpfc_nlp_counters(struct lpfc_hba *phba, int state, int count) |
1175 | { | 1170 | { |
1176 | enum { none, unmapped, mapped } rport_add = none, rport_del = none; | 1171 | switch (state) { |
1177 | struct lpfc_sli *psli; | 1172 | case NLP_STE_UNUSED_NODE: |
1178 | 1173 | phba->fc_unused_cnt += count; | |
1179 | psli = &phba->sli; | 1174 | break; |
1180 | /* Sanity check to ensure we are not moving to / from the same list */ | 1175 | case NLP_STE_PLOGI_ISSUE: |
1181 | if ((nlp->nlp_flag & NLP_LIST_MASK) == list) | 1176 | phba->fc_plogi_cnt += count; |
1182 | if (list != NLP_NO_LIST) | 1177 | break; |
1183 | return 0; | 1178 | case NLP_STE_ADISC_ISSUE: |
1184 | 1179 | phba->fc_adisc_cnt += count; | |
1185 | spin_lock_irq(phba->host->host_lock); | ||
1186 | switch (nlp->nlp_flag & NLP_LIST_MASK) { | ||
1187 | case NLP_NO_LIST: /* Not on any list */ | ||
1188 | break; | 1180 | break; |
1181 | case NLP_STE_REG_LOGIN_ISSUE: | ||
1182 | phba->fc_reglogin_cnt += count; | ||
1183 | break; | ||
1184 | case NLP_STE_PRLI_ISSUE: | ||
1185 | phba->fc_prli_cnt += count; | ||
1186 | break; | ||
1187 | case NLP_STE_UNMAPPED_NODE: | ||
1188 | phba->fc_unmap_cnt += count; | ||
1189 | break; | ||
1190 | case NLP_STE_MAPPED_NODE: | ||
1191 | phba->fc_map_cnt += count; | ||
1192 | break; | ||
1193 | case NLP_STE_NPR_NODE: | ||
1194 | phba->fc_npr_cnt += count; | ||
1195 | break; | ||
1196 | } | ||
1197 | } | ||
1198 | |||
1199 | void | ||
1200 | lpfc_delink_node(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | ||
1201 | { | ||
1202 | switch (ndlp->nlp_flag & NLP_LIST_MASK) { | ||
1189 | case NLP_UNUSED_LIST: | 1203 | case NLP_UNUSED_LIST: |
1190 | phba->fc_unused_cnt--; | 1204 | list_del_init(&ndlp->nlp_listp); |
1191 | list_del(&nlp->nlp_listp); | ||
1192 | break; | 1205 | break; |
1193 | case NLP_PLOGI_LIST: | 1206 | case NLP_PLOGI_LIST: |
1194 | phba->fc_plogi_cnt--; | 1207 | list_del_init(&ndlp->nlp_listp); |
1195 | list_del(&nlp->nlp_listp); | ||
1196 | break; | 1208 | break; |
1197 | case NLP_ADISC_LIST: | 1209 | case NLP_ADISC_LIST: |
1198 | phba->fc_adisc_cnt--; | 1210 | list_del_init(&ndlp->nlp_listp); |
1199 | list_del(&nlp->nlp_listp); | ||
1200 | break; | 1211 | break; |
1201 | case NLP_REGLOGIN_LIST: | 1212 | case NLP_REGLOGIN_LIST: |
1202 | phba->fc_reglogin_cnt--; | 1213 | list_del_init(&ndlp->nlp_listp); |
1203 | list_del(&nlp->nlp_listp); | ||
1204 | break; | 1214 | break; |
1205 | case NLP_PRLI_LIST: | 1215 | case NLP_PRLI_LIST: |
1206 | phba->fc_prli_cnt--; | 1216 | list_del_init(&ndlp->nlp_listp); |
1207 | list_del(&nlp->nlp_listp); | ||
1208 | break; | 1217 | break; |
1209 | case NLP_UNMAPPED_LIST: | 1218 | case NLP_UNMAPPED_LIST: |
1210 | phba->fc_unmap_cnt--; | 1219 | list_del_init(&ndlp->nlp_listp); |
1211 | list_del(&nlp->nlp_listp); | ||
1212 | nlp->nlp_flag &= ~NLP_TGT_NO_SCSIID; | ||
1213 | nlp->nlp_type &= ~NLP_FC_NODE; | ||
1214 | phba->nport_event_cnt++; | ||
1215 | if (nlp->rport) | ||
1216 | rport_del = unmapped; | ||
1217 | break; | 1220 | break; |
1218 | case NLP_MAPPED_LIST: | 1221 | case NLP_MAPPED_LIST: |
1219 | phba->fc_map_cnt--; | 1222 | list_del_init(&ndlp->nlp_listp); |
1220 | list_del(&nlp->nlp_listp); | ||
1221 | phba->nport_event_cnt++; | ||
1222 | if (nlp->rport) | ||
1223 | rport_del = mapped; | ||
1224 | break; | 1223 | break; |
1225 | case NLP_NPR_LIST: | 1224 | case NLP_NPR_LIST: |
1226 | phba->fc_npr_cnt--; | 1225 | list_del_init(&ndlp->nlp_listp); |
1227 | list_del(&nlp->nlp_listp); | ||
1228 | /* Stop delay tmo if taking node off NPR list */ | ||
1229 | if ((nlp->nlp_flag & NLP_DELAY_TMO) && | ||
1230 | (list != NLP_NPR_LIST)) { | ||
1231 | spin_unlock_irq(phba->host->host_lock); | ||
1232 | lpfc_cancel_retry_delay_tmo(phba, nlp); | ||
1233 | spin_lock_irq(phba->host->host_lock); | ||
1234 | } | ||
1235 | break; | 1226 | break; |
1236 | } | 1227 | } |
1237 | 1228 | ||
1238 | nlp->nlp_flag &= ~NLP_LIST_MASK; | 1229 | ndlp->nlp_flag &= ~NLP_LIST_MASK; |
1230 | } | ||
1231 | |||
1232 | static int | ||
1233 | lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | ||
1234 | { | ||
1235 | struct lpfc_sli *psli; | ||
1236 | |||
1237 | psli = &phba->sli; | ||
1238 | /* Sanity check to ensure we are not moving to / from the same list */ | ||
1239 | if ((nlp->nlp_flag & NLP_LIST_MASK) == list) | ||
1240 | return 0; | ||
1241 | |||
1242 | spin_lock_irq(phba->host->host_lock); | ||
1243 | lpfc_delink_node(phba, nlp); | ||
1239 | 1244 | ||
1240 | /* Add NPort <did> to <num> list */ | 1245 | /* Add NPort <did> to <num> list */ |
1241 | lpfc_printf_log(phba, | 1246 | lpfc_printf_log(phba, |
@@ -1246,102 +1251,85 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | |||
1246 | nlp->nlp_DID, list, nlp->nlp_flag); | 1251 | nlp->nlp_DID, list, nlp->nlp_flag); |
1247 | 1252 | ||
1248 | switch (list) { | 1253 | switch (list) { |
1249 | case NLP_NO_LIST: /* No list, just remove it */ | ||
1250 | spin_unlock_irq(phba->host->host_lock); | ||
1251 | lpfc_nlp_remove(phba, nlp); | ||
1252 | spin_lock_irq(phba->host->host_lock); | ||
1253 | /* as node removed - stop further transport calls */ | ||
1254 | rport_del = none; | ||
1255 | break; | ||
1256 | case NLP_UNUSED_LIST: | 1254 | case NLP_UNUSED_LIST: |
1257 | nlp->nlp_flag |= list; | 1255 | nlp->nlp_flag |= list; |
1258 | /* Put it at the end of the unused list */ | 1256 | /* Put it at the end of the unused list */ |
1259 | list_add_tail(&nlp->nlp_listp, &phba->fc_unused_list); | 1257 | list_add_tail(&nlp->nlp_listp, &phba->fc_unused_list); |
1260 | phba->fc_unused_cnt++; | ||
1261 | break; | 1258 | break; |
1262 | case NLP_PLOGI_LIST: | 1259 | case NLP_PLOGI_LIST: |
1263 | nlp->nlp_flag |= list; | 1260 | nlp->nlp_flag |= list; |
1264 | /* Put it at the end of the plogi list */ | 1261 | /* Put it at the end of the plogi list */ |
1265 | list_add_tail(&nlp->nlp_listp, &phba->fc_plogi_list); | 1262 | list_add_tail(&nlp->nlp_listp, &phba->fc_plogi_list); |
1266 | phba->fc_plogi_cnt++; | ||
1267 | break; | 1263 | break; |
1268 | case NLP_ADISC_LIST: | 1264 | case NLP_ADISC_LIST: |
1269 | nlp->nlp_flag |= list; | 1265 | nlp->nlp_flag |= list; |
1270 | /* Put it at the end of the adisc list */ | 1266 | /* Put it at the end of the adisc list */ |
1271 | list_add_tail(&nlp->nlp_listp, &phba->fc_adisc_list); | 1267 | list_add_tail(&nlp->nlp_listp, &phba->fc_adisc_list); |
1272 | phba->fc_adisc_cnt++; | ||
1273 | break; | 1268 | break; |
1274 | case NLP_REGLOGIN_LIST: | 1269 | case NLP_REGLOGIN_LIST: |
1275 | nlp->nlp_flag |= list; | 1270 | nlp->nlp_flag |= list; |
1276 | /* Put it at the end of the reglogin list */ | 1271 | /* Put it at the end of the reglogin list */ |
1277 | list_add_tail(&nlp->nlp_listp, &phba->fc_reglogin_list); | 1272 | list_add_tail(&nlp->nlp_listp, &phba->fc_reglogin_list); |
1278 | phba->fc_reglogin_cnt++; | ||
1279 | break; | 1273 | break; |
1280 | case NLP_PRLI_LIST: | 1274 | case NLP_PRLI_LIST: |
1281 | nlp->nlp_flag |= list; | 1275 | nlp->nlp_flag |= list; |
1282 | /* Put it at the end of the prli list */ | 1276 | /* Put it at the end of the prli list */ |
1283 | list_add_tail(&nlp->nlp_listp, &phba->fc_prli_list); | 1277 | list_add_tail(&nlp->nlp_listp, &phba->fc_prli_list); |
1284 | phba->fc_prli_cnt++; | ||
1285 | break; | 1278 | break; |
1286 | case NLP_UNMAPPED_LIST: | 1279 | case NLP_UNMAPPED_LIST: |
1287 | rport_add = unmapped; | ||
1288 | /* ensure all vestiges of "mapped" significance are gone */ | ||
1289 | nlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR); | ||
1290 | nlp->nlp_flag |= list; | 1280 | nlp->nlp_flag |= list; |
1291 | /* Put it at the end of the unmap list */ | 1281 | /* Put it at the end of the unmap list */ |
1292 | list_add_tail(&nlp->nlp_listp, &phba->fc_nlpunmap_list); | 1282 | list_add_tail(&nlp->nlp_listp, &phba->fc_nlpunmap_list); |
1293 | phba->fc_unmap_cnt++; | ||
1294 | phba->nport_event_cnt++; | ||
1295 | nlp->nlp_flag &= ~NLP_NODEV_REMOVE; | ||
1296 | nlp->nlp_type |= NLP_FC_NODE; | ||
1297 | break; | 1283 | break; |
1298 | case NLP_MAPPED_LIST: | 1284 | case NLP_MAPPED_LIST: |
1299 | rport_add = mapped; | ||
1300 | nlp->nlp_flag |= list; | 1285 | nlp->nlp_flag |= list; |
1301 | /* Put it at the end of the map list */ | 1286 | /* Put it at the end of the map list */ |
1302 | list_add_tail(&nlp->nlp_listp, &phba->fc_nlpmap_list); | 1287 | list_add_tail(&nlp->nlp_listp, &phba->fc_nlpmap_list); |
1303 | phba->fc_map_cnt++; | ||
1304 | phba->nport_event_cnt++; | ||
1305 | nlp->nlp_flag &= ~NLP_NODEV_REMOVE; | ||
1306 | break; | 1288 | break; |
1307 | case NLP_NPR_LIST: | 1289 | case NLP_NPR_LIST: |
1308 | nlp->nlp_flag |= list; | 1290 | nlp->nlp_flag |= list; |
1309 | /* Put it at the end of the npr list */ | 1291 | /* Put it at the end of the npr list */ |
1310 | list_add_tail(&nlp->nlp_listp, &phba->fc_npr_list); | 1292 | list_add_tail(&nlp->nlp_listp, &phba->fc_npr_list); |
1311 | phba->fc_npr_cnt++; | ||
1312 | |||
1313 | nlp->nlp_flag &= ~NLP_RCV_PLOGI; | ||
1314 | break; | ||
1315 | case NLP_JUST_DQ: | ||
1316 | break; | 1293 | break; |
1317 | } | 1294 | } |
1318 | 1295 | ||
1319 | spin_unlock_irq(phba->host->host_lock); | 1296 | spin_unlock_irq(phba->host->host_lock); |
1297 | return 0; | ||
1298 | } | ||
1320 | 1299 | ||
1321 | /* | 1300 | static void |
1322 | * We make all the calls into the transport after we have | 1301 | lpfc_nlp_state_cleanup(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, |
1323 | * moved the node between lists. This so that we don't | 1302 | int old_state, int new_state) |
1324 | * release the lock while in-between lists. | 1303 | { |
1325 | */ | 1304 | if (new_state == NLP_STE_UNMAPPED_NODE) { |
1326 | 1305 | ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR); | |
1327 | /* Don't upcall midlayer if we're unloading */ | 1306 | ndlp->nlp_flag &= ~NLP_NODEV_REMOVE; |
1328 | if (!(phba->fc_flag & FC_UNLOADING)) { | 1307 | ndlp->nlp_type |= NLP_FC_NODE; |
1329 | /* | 1308 | } |
1330 | * We revalidate the rport pointer as the "add" function | 1309 | if (new_state == NLP_STE_MAPPED_NODE) |
1331 | * may have removed the remote port. | 1310 | ndlp->nlp_flag &= ~NLP_NODEV_REMOVE; |
1332 | */ | 1311 | if (new_state == NLP_STE_NPR_NODE) |
1333 | if ((rport_del != none) && nlp->rport) | 1312 | ndlp->nlp_flag &= ~NLP_RCV_PLOGI; |
1334 | lpfc_unregister_remote_port(phba, nlp); | 1313 | |
1314 | /* Transport interface */ | ||
1315 | if (ndlp->rport && (old_state == NLP_STE_MAPPED_NODE || | ||
1316 | old_state == NLP_STE_UNMAPPED_NODE)) { | ||
1317 | phba->nport_event_cnt++; | ||
1318 | lpfc_unregister_remote_port(phba, ndlp); | ||
1319 | } | ||
1335 | 1320 | ||
1336 | if (rport_add != none) { | 1321 | if (new_state == NLP_STE_MAPPED_NODE || |
1322 | new_state == NLP_STE_UNMAPPED_NODE) { | ||
1323 | phba->nport_event_cnt++; | ||
1337 | /* | 1324 | /* |
1338 | * Tell the fc transport about the port, if we haven't | 1325 | * Tell the fc transport about the port, if we haven't |
1339 | * already. If we have, and it's a scsi entity, be | 1326 | * already. If we have, and it's a scsi entity, be |
1340 | * sure to unblock any attached scsi devices | 1327 | * sure to unblock any attached scsi devices |
1341 | */ | 1328 | */ |
1342 | if ((!nlp->rport) || (nlp->rport->port_state == | 1329 | if (!ndlp->rport || |
1343 | FC_PORTSTATE_BLOCKED)) | 1330 | ndlp->rport->port_state == FC_PORTSTATE_BLOCKED) |
1344 | lpfc_register_remote_port(phba, nlp); | 1331 | lpfc_register_remote_port(phba, ndlp); |
1332 | } | ||
1345 | 1333 | ||
1346 | /* | 1334 | /* |
1347 | * if we added to Mapped list, but the remote port | 1335 | * if we added to Mapped list, but the remote port |
@@ -1349,19 +1337,75 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | |||
1349 | * our presentable range - move the node to the | 1337 | * our presentable range - move the node to the |
1350 | * Unmapped List | 1338 | * Unmapped List |
1351 | */ | 1339 | */ |
1352 | if ((rport_add == mapped) && | 1340 | if (new_state == NLP_STE_MAPPED_NODE && |
1353 | ((!nlp->rport) || | 1341 | (!ndlp->rport || |
1354 | (nlp->rport->scsi_target_id == -1) || | 1342 | ndlp->rport->scsi_target_id == -1 || |
1355 | (nlp->rport->scsi_target_id >= LPFC_MAX_TARGET))) { | 1343 | ndlp->rport->scsi_target_id >= LPFC_MAX_TARGET)) { |
1356 | nlp->nlp_state = NLP_STE_UNMAPPED_NODE; | 1344 | spin_lock_irq(phba->host->host_lock); |
1357 | spin_lock_irq(phba->host->host_lock); | 1345 | ndlp->nlp_flag |= NLP_TGT_NO_SCSIID; |
1358 | nlp->nlp_flag |= NLP_TGT_NO_SCSIID; | 1346 | spin_unlock_irq(phba->host->host_lock); |
1359 | spin_unlock_irq(phba->host->host_lock); | 1347 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE); |
1360 | lpfc_nlp_list(phba, nlp, NLP_UNMAPPED_LIST); | ||
1361 | } | ||
1362 | } | ||
1363 | } | 1348 | } |
1364 | return 0; | 1349 | } |
1350 | |||
1351 | void | ||
1352 | lpfc_nlp_set_state(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, int state) | ||
1353 | { | ||
1354 | int old_state = ndlp->nlp_state; | ||
1355 | static int list_id[] = { | ||
1356 | [NLP_STE_UNUSED_NODE] = NLP_UNUSED_LIST, | ||
1357 | [NLP_STE_PLOGI_ISSUE] = NLP_PLOGI_LIST, | ||
1358 | [NLP_STE_ADISC_ISSUE] = NLP_ADISC_LIST, | ||
1359 | [NLP_STE_REG_LOGIN_ISSUE] = NLP_REGLOGIN_LIST, | ||
1360 | [NLP_STE_PRLI_ISSUE] = NLP_PRLI_LIST, | ||
1361 | [NLP_STE_UNMAPPED_NODE] = NLP_UNMAPPED_LIST, | ||
1362 | [NLP_STE_MAPPED_NODE] = NLP_MAPPED_LIST, | ||
1363 | [NLP_STE_NPR_NODE] = NLP_NPR_LIST, | ||
1364 | }; | ||
1365 | |||
1366 | if (old_state == NLP_STE_NPR_NODE && | ||
1367 | (ndlp->nlp_flag & NLP_DELAY_TMO) != 0 && | ||
1368 | state != NLP_STE_NPR_NODE) | ||
1369 | lpfc_cancel_retry_delay_tmo(phba, ndlp); | ||
1370 | if (old_state == NLP_STE_UNMAPPED_NODE) { | ||
1371 | ndlp->nlp_flag &= ~NLP_TGT_NO_SCSIID; | ||
1372 | ndlp->nlp_type &= ~NLP_FC_NODE; | ||
1373 | } | ||
1374 | |||
1375 | if (old_state && !list_empty(&ndlp->nlp_listp)) | ||
1376 | lpfc_nlp_counters(phba, old_state, -1); | ||
1377 | |||
1378 | ndlp->nlp_state = state; | ||
1379 | lpfc_nlp_list(phba, ndlp, list_id[state]); | ||
1380 | lpfc_nlp_counters(phba, state, 1); | ||
1381 | |||
1382 | lpfc_nlp_state_cleanup(phba, ndlp, old_state, state); | ||
1383 | } | ||
1384 | |||
1385 | void | ||
1386 | lpfc_dequeue_node(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | ||
1387 | { | ||
1388 | if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0) | ||
1389 | lpfc_cancel_retry_delay_tmo(phba, ndlp); | ||
1390 | spin_lock_irq(phba->host->host_lock); | ||
1391 | if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp)) | ||
1392 | lpfc_nlp_counters(phba, ndlp->nlp_state, -1); | ||
1393 | lpfc_delink_node(phba, ndlp); | ||
1394 | spin_unlock_irq(phba->host->host_lock); | ||
1395 | lpfc_nlp_state_cleanup(phba, ndlp, ndlp->nlp_state, 0); | ||
1396 | } | ||
1397 | |||
1398 | void | ||
1399 | lpfc_drop_node(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | ||
1400 | { | ||
1401 | if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0) | ||
1402 | lpfc_cancel_retry_delay_tmo(phba, ndlp); | ||
1403 | spin_lock_irq(phba->host->host_lock); | ||
1404 | if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp)) | ||
1405 | lpfc_nlp_counters(phba, ndlp->nlp_state, -1); | ||
1406 | lpfc_delink_node(phba, ndlp); | ||
1407 | spin_unlock_irq(phba->host->host_lock); | ||
1408 | lpfc_nlp_remove(phba, ndlp); | ||
1365 | } | 1409 | } |
1366 | 1410 | ||
1367 | /* | 1411 | /* |
@@ -1577,7 +1621,7 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) | |||
1577 | phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag, | 1621 | phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag, |
1578 | ndlp->nlp_state, ndlp->nlp_rpi); | 1622 | ndlp->nlp_state, ndlp->nlp_rpi); |
1579 | 1623 | ||
1580 | lpfc_nlp_list(phba, ndlp, NLP_JUST_DQ); | 1624 | lpfc_dequeue_node(phba, ndlp); |
1581 | 1625 | ||
1582 | /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ | 1626 | /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ |
1583 | if ((mb = phba->sli.mbox_active)) { | 1627 | if ((mb = phba->sli.mbox_active)) { |
@@ -1771,8 +1815,7 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did) | |||
1771 | if (!ndlp) | 1815 | if (!ndlp) |
1772 | return NULL; | 1816 | return NULL; |
1773 | lpfc_nlp_init(phba, ndlp, did); | 1817 | lpfc_nlp_init(phba, ndlp, did); |
1774 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1818 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE); |
1775 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | ||
1776 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | 1819 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
1777 | return ndlp; | 1820 | return ndlp; |
1778 | } | 1821 | } |
@@ -1791,8 +1834,7 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did) | |||
1791 | flg = ndlp->nlp_flag & NLP_LIST_MASK; | 1834 | flg = ndlp->nlp_flag & NLP_LIST_MASK; |
1792 | if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST)) | 1835 | if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST)) |
1793 | return NULL; | 1836 | return NULL; |
1794 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1837 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE); |
1795 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | ||
1796 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | 1838 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
1797 | } | 1839 | } |
1798 | return ndlp; | 1840 | return ndlp; |
@@ -2099,7 +2141,7 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba) | |||
2099 | nlp_listp) { | 2141 | nlp_listp) { |
2100 | if (ndlp->nlp_type & NLP_FABRIC) { | 2142 | if (ndlp->nlp_type & NLP_FABRIC) { |
2101 | /* Clean up the ndlp on Fabric connections */ | 2143 | /* Clean up the ndlp on Fabric connections */ |
2102 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 2144 | lpfc_drop_node(phba, ndlp); |
2103 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { | 2145 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { |
2104 | /* Fail outstanding IO now since device | 2146 | /* Fail outstanding IO now since device |
2105 | * is marked for PLOGI. | 2147 | * is marked for PLOGI. |
@@ -2304,8 +2346,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
2304 | 2346 | ||
2305 | ndlp->nlp_rpi = mb->un.varWords[0]; | 2347 | ndlp->nlp_rpi = mb->un.varWords[0]; |
2306 | ndlp->nlp_type |= NLP_FABRIC; | 2348 | ndlp->nlp_type |= NLP_FABRIC; |
2307 | ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; | 2349 | lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE); |
2308 | lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); | ||
2309 | 2350 | ||
2310 | /* Start issuing Fabric-Device Management Interface (FDMI) | 2351 | /* Start issuing Fabric-Device Management Interface (FDMI) |
2311 | * command to 0xfffffa (FDMI well known port) | 2352 | * command to 0xfffffa (FDMI well known port) |