lpfc_nportdisc.c 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2006 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * Portions Copyright (C) 2004-2005 Christoph Hellwig *
  8. * *
  9. * This program is free software; you can redistribute it and/or *
  10. * modify it under the terms of version 2 of the GNU General *
  11. * Public License as published by the Free Software Foundation. *
  12. * This program is distributed in the hope that it will be useful. *
  13. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  14. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  15. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  16. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  17. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  18. * more details, a copy of which can be found in the file COPYING *
  19. * included with this package. *
  20. *******************************************************************/
  21. #include <linux/blkdev.h>
  22. #include <linux/pci.h>
  23. #include <linux/interrupt.h>
  24. #include <scsi/scsi.h>
  25. #include <scsi/scsi_device.h>
  26. #include <scsi/scsi_host.h>
  27. #include <scsi/scsi_transport_fc.h>
  28. #include "lpfc_hw.h"
  29. #include "lpfc_sli.h"
  30. #include "lpfc_disc.h"
  31. #include "lpfc_scsi.h"
  32. #include "lpfc.h"
  33. #include "lpfc_logmsg.h"
  34. #include "lpfc_crtn.h"
  35. /* Called to verify a rcv'ed ADISC was intended for us. */
  36. static int
  37. lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
  38. struct lpfc_name * nn, struct lpfc_name * pn)
  39. {
  40. /* Compare the ADISC rsp WWNN / WWPN matches our internal node
  41. * table entry for that node.
  42. */
  43. if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)) != 0)
  44. return 0;
  45. if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0)
  46. return 0;
  47. /* we match, return success */
  48. return 1;
  49. }
  50. int
  51. lpfc_check_sparm(struct lpfc_hba * phba,
  52. struct lpfc_nodelist * ndlp, struct serv_parm * sp,
  53. uint32_t class)
  54. {
  55. volatile struct serv_parm *hsp = &phba->fc_sparam;
  56. uint16_t hsp_value, ssp_value = 0;
  57. /*
  58. * The receive data field size and buffer-to-buffer receive data field
  59. * size entries are 16 bits but are represented as two 8-bit fields in
  60. * the driver data structure to account for rsvd bits and other control
  61. * bits. Reconstruct and compare the fields as a 16-bit values before
  62. * correcting the byte values.
  63. */
  64. if (sp->cls1.classValid) {
  65. hsp_value = (hsp->cls1.rcvDataSizeMsb << 8) |
  66. hsp->cls1.rcvDataSizeLsb;
  67. ssp_value = (sp->cls1.rcvDataSizeMsb << 8) |
  68. sp->cls1.rcvDataSizeLsb;
  69. if (ssp_value > hsp_value) {
  70. sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb;
  71. sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb;
  72. }
  73. } else if (class == CLASS1) {
  74. return 0;
  75. }
  76. if (sp->cls2.classValid) {
  77. hsp_value = (hsp->cls2.rcvDataSizeMsb << 8) |
  78. hsp->cls2.rcvDataSizeLsb;
  79. ssp_value = (sp->cls2.rcvDataSizeMsb << 8) |
  80. sp->cls2.rcvDataSizeLsb;
  81. if (ssp_value > hsp_value) {
  82. sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb;
  83. sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb;
  84. }
  85. } else if (class == CLASS2) {
  86. return 0;
  87. }
  88. if (sp->cls3.classValid) {
  89. hsp_value = (hsp->cls3.rcvDataSizeMsb << 8) |
  90. hsp->cls3.rcvDataSizeLsb;
  91. ssp_value = (sp->cls3.rcvDataSizeMsb << 8) |
  92. sp->cls3.rcvDataSizeLsb;
  93. if (ssp_value > hsp_value) {
  94. sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb;
  95. sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb;
  96. }
  97. } else if (class == CLASS3) {
  98. return 0;
  99. }
  100. /*
  101. * Preserve the upper four bits of the MSB from the PLOGI response.
  102. * These bits contain the Buffer-to-Buffer State Change Number
  103. * from the target and need to be passed to the FW.
  104. */
  105. hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb;
  106. ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb;
  107. if (ssp_value > hsp_value) {
  108. sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb;
  109. sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) |
  110. (hsp->cmn.bbRcvSizeMsb & 0x0F);
  111. }
  112. memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name));
  113. memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
  114. return 1;
  115. }
  116. static void *
  117. lpfc_check_elscmpl_iocb(struct lpfc_hba * phba,
  118. struct lpfc_iocbq *cmdiocb,
  119. struct lpfc_iocbq *rspiocb)
  120. {
  121. struct lpfc_dmabuf *pcmd, *prsp;
  122. uint32_t *lp;
  123. void *ptr = NULL;
  124. IOCB_t *irsp;
  125. irsp = &rspiocb->iocb;
  126. pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
  127. /* For lpfc_els_abort, context2 could be zero'ed to delay
  128. * freeing associated memory till after ABTS completes.
  129. */
  130. if (pcmd) {
  131. prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf,
  132. list);
  133. if (prsp) {
  134. lp = (uint32_t *) prsp->virt;
  135. ptr = (void *)((uint8_t *)lp + sizeof(uint32_t));
  136. }
  137. } else {
  138. /* Force ulpStatus error since we are returning NULL ptr */
  139. if (!(irsp->ulpStatus)) {
  140. irsp->ulpStatus = IOSTAT_LOCAL_REJECT;
  141. irsp->un.ulpWord[4] = IOERR_SLI_ABORTED;
  142. }
  143. ptr = NULL;
  144. }
  145. return ptr;
  146. }
  147. /*
  148. * Free resources / clean up outstanding I/Os
  149. * associated with a LPFC_NODELIST entry. This
  150. * routine effectively results in a "software abort".
  151. */
  152. int
  153. lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
  154. {
  155. struct lpfc_sli *psli;
  156. struct lpfc_sli_ring *pring;
  157. struct lpfc_iocbq *iocb, *next_iocb;
  158. IOCB_t *icmd;
  159. int found = 0;
  160. /* Abort outstanding I/O on NPort <nlp_DID> */
  161. lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
  162. "%d:0205 Abort outstanding I/O on NPort x%x "
  163. "Data: x%x x%x x%x\n",
  164. phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
  165. ndlp->nlp_state, ndlp->nlp_rpi);
  166. psli = &phba->sli;
  167. pring = &psli->ring[LPFC_ELS_RING];
  168. /* First check the txq */
  169. do {
  170. found = 0;
  171. spin_lock_irq(phba->host->host_lock);
  172. list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
  173. /* Check to see if iocb matches the nport we are looking
  174. for */
  175. if ((lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))) {
  176. found = 1;
  177. /* It matches, so deque and call compl with an
  178. error */
  179. list_del(&iocb->list);
  180. pring->txq_cnt--;
  181. if (iocb->iocb_cmpl) {
  182. icmd = &iocb->iocb;
  183. icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
  184. icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
  185. spin_unlock_irq(phba->host->host_lock);
  186. (iocb->iocb_cmpl) (phba, iocb, iocb);
  187. spin_lock_irq(phba->host->host_lock);
  188. } else
  189. lpfc_sli_release_iocbq(phba, iocb);
  190. break;
  191. }
  192. }
  193. spin_unlock_irq(phba->host->host_lock);
  194. } while (found);
  195. /* Next check the txcmplq */
  196. spin_lock_irq(phba->host->host_lock);
  197. list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
  198. /* Check to see if iocb matches the nport we are looking
  199. for */
  200. if ((lpfc_check_sli_ndlp (phba, pring, iocb, ndlp))) {
  201. icmd = &iocb->iocb;
  202. lpfc_sli_issue_abort_iotag(phba, pring, iocb);
  203. }
  204. }
  205. spin_unlock_irq(phba->host->host_lock);
  206. /* If we are delaying issuing an ELS command, cancel it */
  207. if (ndlp->nlp_flag & NLP_DELAY_TMO)
  208. lpfc_cancel_retry_delay_tmo(phba, ndlp);
  209. return 0;
  210. }
  211. static int
  212. lpfc_rcv_plogi(struct lpfc_hba * phba,
  213. struct lpfc_nodelist * ndlp,
  214. struct lpfc_iocbq *cmdiocb)
  215. {
  216. struct lpfc_dmabuf *pcmd;
  217. uint32_t *lp;
  218. IOCB_t *icmd;
  219. struct serv_parm *sp;
  220. LPFC_MBOXQ_t *mbox;
  221. struct ls_rjt stat;
  222. int rc;
  223. memset(&stat, 0, sizeof (struct ls_rjt));
  224. if (phba->hba_state <= LPFC_FLOGI) {
  225. /* Before responding to PLOGI, check for pt2pt mode.
  226. * If we are pt2pt, with an outstanding FLOGI, abort
  227. * the FLOGI and resend it first.
  228. */
  229. if (phba->fc_flag & FC_PT2PT) {
  230. lpfc_els_abort_flogi(phba);
  231. if (!(phba->fc_flag & FC_PT2PT_PLOGI)) {
  232. /* If the other side is supposed to initiate
  233. * the PLOGI anyway, just ACC it now and
  234. * move on with discovery.
  235. */
  236. phba->fc_edtov = FF_DEF_EDTOV;
  237. phba->fc_ratov = FF_DEF_RATOV;
  238. /* Start discovery - this should just do
  239. CLEAR_LA */
  240. lpfc_disc_start(phba);
  241. } else {
  242. lpfc_initial_flogi(phba);
  243. }
  244. } else {
  245. stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
  246. stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
  247. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb,
  248. ndlp);
  249. return 0;
  250. }
  251. }
  252. pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
  253. lp = (uint32_t *) pcmd->virt;
  254. sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
  255. if ((lpfc_check_sparm(phba, ndlp, sp, CLASS3) == 0)) {
  256. /* Reject this request because invalid parameters */
  257. stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
  258. stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
  259. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
  260. return 0;
  261. }
  262. icmd = &cmdiocb->iocb;
  263. /* PLOGI chkparm OK */
  264. lpfc_printf_log(phba,
  265. KERN_INFO,
  266. LOG_ELS,
  267. "%d:0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
  268. phba->brd_no,
  269. ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag,
  270. ndlp->nlp_rpi);
  271. if ((phba->cfg_fcp_class == 2) &&
  272. (sp->cls2.classValid)) {
  273. ndlp->nlp_fcp_info |= CLASS2;
  274. } else {
  275. ndlp->nlp_fcp_info |= CLASS3;
  276. }
  277. ndlp->nlp_class_sup = 0;
  278. if (sp->cls1.classValid)
  279. ndlp->nlp_class_sup |= FC_COS_CLASS1;
  280. if (sp->cls2.classValid)
  281. ndlp->nlp_class_sup |= FC_COS_CLASS2;
  282. if (sp->cls3.classValid)
  283. ndlp->nlp_class_sup |= FC_COS_CLASS3;
  284. if (sp->cls4.classValid)
  285. ndlp->nlp_class_sup |= FC_COS_CLASS4;
  286. ndlp->nlp_maxframe =
  287. ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
  288. /* no need to reg_login if we are already in one of these states */
  289. switch (ndlp->nlp_state) {
  290. case NLP_STE_NPR_NODE:
  291. if (!(ndlp->nlp_flag & NLP_NPR_ADISC))
  292. break;
  293. case NLP_STE_REG_LOGIN_ISSUE:
  294. case NLP_STE_PRLI_ISSUE:
  295. case NLP_STE_UNMAPPED_NODE:
  296. case NLP_STE_MAPPED_NODE:
  297. lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0);
  298. return 1;
  299. }
  300. if ((phba->fc_flag & FC_PT2PT)
  301. && !(phba->fc_flag & FC_PT2PT_PLOGI)) {
  302. /* rcv'ed PLOGI decides what our NPortId will be */
  303. phba->fc_myDID = icmd->un.rcvels.parmRo;
  304. mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  305. if (mbox == NULL)
  306. goto out;
  307. lpfc_config_link(phba, mbox);
  308. mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  309. rc = lpfc_sli_issue_mbox
  310. (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
  311. if (rc == MBX_NOT_FINISHED) {
  312. mempool_free( mbox, phba->mbox_mem_pool);
  313. goto out;
  314. }
  315. lpfc_can_disctmo(phba);
  316. }
  317. mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  318. if (mbox == NULL)
  319. goto out;
  320. if (lpfc_reg_login(phba, icmd->un.rcvels.remoteID,
  321. (uint8_t *) sp, mbox, 0)) {
  322. mempool_free( mbox, phba->mbox_mem_pool);
  323. goto out;
  324. }
  325. /* ACC PLOGI rsp command needs to execute first,
  326. * queue this mbox command to be processed later.
  327. */
  328. mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
  329. mbox->context2 = ndlp;
  330. ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
  331. /*
  332. * If there is an outstanding PLOGI issued, abort it before
  333. * sending ACC rsp for received PLOGI. If pending plogi
  334. * is not canceled here, the plogi will be rejected by
  335. * remote port and will be retried. On a configuration with
  336. * single discovery thread, this will cause a huge delay in
  337. * discovery. Also this will cause multiple state machines
  338. * running in parallel for this node.
  339. */
  340. if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
  341. /* software abort outstanding PLOGI */
  342. lpfc_els_abort(phba, ndlp);
  343. }
  344. lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
  345. return 1;
  346. out:
  347. stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
  348. stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
  349. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
  350. return 0;
  351. }
  352. static int
  353. lpfc_rcv_padisc(struct lpfc_hba * phba,
  354. struct lpfc_nodelist * ndlp,
  355. struct lpfc_iocbq *cmdiocb)
  356. {
  357. struct lpfc_dmabuf *pcmd;
  358. struct serv_parm *sp;
  359. struct lpfc_name *pnn, *ppn;
  360. struct ls_rjt stat;
  361. ADISC *ap;
  362. IOCB_t *icmd;
  363. uint32_t *lp;
  364. uint32_t cmd;
  365. pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
  366. lp = (uint32_t *) pcmd->virt;
  367. cmd = *lp++;
  368. if (cmd == ELS_CMD_ADISC) {
  369. ap = (ADISC *) lp;
  370. pnn = (struct lpfc_name *) & ap->nodeName;
  371. ppn = (struct lpfc_name *) & ap->portName;
  372. } else {
  373. sp = (struct serv_parm *) lp;
  374. pnn = (struct lpfc_name *) & sp->nodeName;
  375. ppn = (struct lpfc_name *) & sp->portName;
  376. }
  377. icmd = &cmdiocb->iocb;
  378. if ((icmd->ulpStatus == 0) &&
  379. (lpfc_check_adisc(phba, ndlp, pnn, ppn))) {
  380. if (cmd == ELS_CMD_ADISC) {
  381. lpfc_els_rsp_adisc_acc(phba, cmdiocb, ndlp);
  382. } else {
  383. lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp,
  384. NULL, 0);
  385. }
  386. return 1;
  387. }
  388. /* Reject this request because invalid parameters */
  389. stat.un.b.lsRjtRsvd0 = 0;
  390. stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
  391. stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
  392. stat.un.b.vendorUnique = 0;
  393. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
  394. /* 1 sec timeout */
  395. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
  396. spin_lock_irq(phba->host->host_lock);
  397. ndlp->nlp_flag |= NLP_DELAY_TMO;
  398. spin_unlock_irq(phba->host->host_lock);
  399. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  400. ndlp->nlp_prev_state = ndlp->nlp_state;
  401. ndlp->nlp_state = NLP_STE_NPR_NODE;
  402. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  403. return 0;
  404. }
  405. static int
  406. lpfc_rcv_logo(struct lpfc_hba * phba,
  407. struct lpfc_nodelist * ndlp,
  408. struct lpfc_iocbq *cmdiocb,
  409. uint32_t els_cmd)
  410. {
  411. /* Put ndlp on NPR list with 1 sec timeout for plogi, ACC logo */
  412. /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
  413. * PLOGIs during LOGO storms from a device.
  414. */
  415. ndlp->nlp_flag |= NLP_LOGO_ACC;
  416. if (els_cmd == ELS_CMD_PRLO)
  417. lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
  418. else
  419. lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
  420. if (!(ndlp->nlp_type & NLP_FABRIC) ||
  421. (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
  422. /* Only try to re-login if this is NOT a Fabric Node */
  423. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
  424. spin_lock_irq(phba->host->host_lock);
  425. ndlp->nlp_flag |= NLP_DELAY_TMO;
  426. spin_unlock_irq(phba->host->host_lock);
  427. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  428. ndlp->nlp_prev_state = ndlp->nlp_state;
  429. ndlp->nlp_state = NLP_STE_NPR_NODE;
  430. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  431. } else {
  432. ndlp->nlp_prev_state = ndlp->nlp_state;
  433. ndlp->nlp_state = NLP_STE_UNUSED_NODE;
  434. lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
  435. }
  436. spin_lock_irq(phba->host->host_lock);
  437. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  438. spin_unlock_irq(phba->host->host_lock);
  439. /* The driver has to wait until the ACC completes before it continues
  440. * processing the LOGO. The action will resume in
  441. * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
  442. * unreg_login, the driver waits so the ACC does not get aborted.
  443. */
  444. return 0;
  445. }
  446. static void
  447. lpfc_rcv_prli(struct lpfc_hba * phba,
  448. struct lpfc_nodelist * ndlp,
  449. struct lpfc_iocbq *cmdiocb)
  450. {
  451. struct lpfc_dmabuf *pcmd;
  452. uint32_t *lp;
  453. PRLI *npr;
  454. struct fc_rport *rport = ndlp->rport;
  455. u32 roles;
  456. pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
  457. lp = (uint32_t *) pcmd->virt;
  458. npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
  459. ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
  460. ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
  461. if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
  462. (npr->prliType == PRLI_FCP_TYPE)) {
  463. if (npr->initiatorFunc)
  464. ndlp->nlp_type |= NLP_FCP_INITIATOR;
  465. if (npr->targetFunc)
  466. ndlp->nlp_type |= NLP_FCP_TARGET;
  467. if (npr->Retry)
  468. ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
  469. }
  470. if (rport) {
  471. /* We need to update the rport role values */
  472. roles = FC_RPORT_ROLE_UNKNOWN;
  473. if (ndlp->nlp_type & NLP_FCP_INITIATOR)
  474. roles |= FC_RPORT_ROLE_FCP_INITIATOR;
  475. if (ndlp->nlp_type & NLP_FCP_TARGET)
  476. roles |= FC_RPORT_ROLE_FCP_TARGET;
  477. fc_remote_port_rolechg(rport, roles);
  478. }
  479. }
  480. static uint32_t
  481. lpfc_disc_set_adisc(struct lpfc_hba * phba,
  482. struct lpfc_nodelist * ndlp)
  483. {
  484. /* Check config parameter use-adisc or FCP-2 */
  485. if ((phba->cfg_use_adisc == 0) &&
  486. !(phba->fc_flag & FC_RSCN_MODE)) {
  487. if (!(ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE))
  488. return 0;
  489. }
  490. spin_lock_irq(phba->host->host_lock);
  491. ndlp->nlp_flag |= NLP_NPR_ADISC;
  492. spin_unlock_irq(phba->host->host_lock);
  493. return 1;
  494. }
  495. static uint32_t
  496. lpfc_disc_illegal(struct lpfc_hba * phba,
  497. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  498. {
  499. lpfc_printf_log(phba,
  500. KERN_ERR,
  501. LOG_DISCOVERY,
  502. "%d:0253 Illegal State Transition: node x%x event x%x, "
  503. "state x%x Data: x%x x%x\n",
  504. phba->brd_no,
  505. ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
  506. ndlp->nlp_flag);
  507. return ndlp->nlp_state;
  508. }
  509. /* Start of Discovery State Machine routines */
  510. static uint32_t
  511. lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba,
  512. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  513. {
  514. struct lpfc_iocbq *cmdiocb;
  515. cmdiocb = (struct lpfc_iocbq *) arg;
  516. if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
  517. ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
  518. ndlp->nlp_state = NLP_STE_UNUSED_NODE;
  519. lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
  520. return ndlp->nlp_state;
  521. }
  522. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  523. return NLP_STE_FREED_NODE;
  524. }
  525. static uint32_t
  526. lpfc_rcv_els_unused_node(struct lpfc_hba * phba,
  527. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  528. {
  529. lpfc_issue_els_logo(phba, ndlp, 0);
  530. lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
  531. return ndlp->nlp_state;
  532. }
  533. static uint32_t
  534. lpfc_rcv_logo_unused_node(struct lpfc_hba * phba,
  535. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  536. {
  537. struct lpfc_iocbq *cmdiocb;
  538. cmdiocb = (struct lpfc_iocbq *) arg;
  539. spin_lock_irq(phba->host->host_lock);
  540. ndlp->nlp_flag |= NLP_LOGO_ACC;
  541. spin_unlock_irq(phba->host->host_lock);
  542. lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
  543. lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
  544. return ndlp->nlp_state;
  545. }
  546. static uint32_t
  547. lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba,
  548. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  549. {
  550. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  551. return NLP_STE_FREED_NODE;
  552. }
  553. static uint32_t
  554. lpfc_device_rm_unused_node(struct lpfc_hba * phba,
  555. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  556. {
  557. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  558. return NLP_STE_FREED_NODE;
  559. }
  560. static uint32_t
  561. lpfc_rcv_plogi_plogi_issue(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
  562. void *arg, uint32_t evt)
  563. {
  564. struct lpfc_iocbq *cmdiocb = arg;
  565. struct lpfc_dmabuf *pcmd;
  566. struct serv_parm *sp;
  567. uint32_t *lp;
  568. struct ls_rjt stat;
  569. int port_cmp;
  570. pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
  571. lp = (uint32_t *) pcmd->virt;
  572. sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
  573. memset(&stat, 0, sizeof (struct ls_rjt));
  574. /* For a PLOGI, we only accept if our portname is less
  575. * than the remote portname.
  576. */
  577. phba->fc_stat.elsLogiCol++;
  578. port_cmp = memcmp(&phba->fc_portname, &sp->portName,
  579. sizeof (struct lpfc_name));
  580. if (port_cmp >= 0) {
  581. /* Reject this request because the remote node will accept
  582. ours */
  583. stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
  584. stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
  585. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
  586. } else {
  587. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  588. } /* if our portname was less */
  589. return ndlp->nlp_state;
  590. }
  591. static uint32_t
  592. lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba,
  593. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  594. {
  595. struct lpfc_iocbq *cmdiocb;
  596. cmdiocb = (struct lpfc_iocbq *) arg;
  597. /* software abort outstanding PLOGI */
  598. lpfc_els_abort(phba, ndlp);
  599. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  600. return ndlp->nlp_state;
  601. }
  602. static uint32_t
  603. lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
  604. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  605. {
  606. struct lpfc_iocbq *cmdiocb;
  607. cmdiocb = (struct lpfc_iocbq *) arg;
  608. /* software abort outstanding PLOGI */
  609. lpfc_els_abort(phba, ndlp);
  610. if (evt == NLP_EVT_RCV_LOGO) {
  611. lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
  612. } else {
  613. lpfc_issue_els_logo(phba, ndlp, 0);
  614. }
  615. /* Put ndlp in npr list set plogi timer for 1 sec */
  616. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
  617. spin_lock_irq(phba->host->host_lock);
  618. ndlp->nlp_flag |= NLP_DELAY_TMO;
  619. spin_unlock_irq(phba->host->host_lock);
  620. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  621. ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
  622. ndlp->nlp_state = NLP_STE_NPR_NODE;
  623. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  624. return ndlp->nlp_state;
  625. }
  626. static uint32_t
  627. lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
  628. struct lpfc_nodelist * ndlp, void *arg,
  629. uint32_t evt)
  630. {
  631. struct lpfc_iocbq *cmdiocb, *rspiocb;
  632. struct lpfc_dmabuf *pcmd, *prsp, *mp;
  633. uint32_t *lp;
  634. IOCB_t *irsp;
  635. struct serv_parm *sp;
  636. LPFC_MBOXQ_t *mbox;
  637. cmdiocb = (struct lpfc_iocbq *) arg;
  638. rspiocb = cmdiocb->context_un.rsp_iocb;
  639. if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
  640. /* Recovery from PLOGI collision logic */
  641. return ndlp->nlp_state;
  642. }
  643. irsp = &rspiocb->iocb;
  644. if (irsp->ulpStatus)
  645. goto out;
  646. pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
  647. prsp = list_get_first(&pcmd->list,
  648. struct lpfc_dmabuf,
  649. list);
  650. lp = (uint32_t *) prsp->virt;
  651. sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
  652. if (!lpfc_check_sparm(phba, ndlp, sp, CLASS3))
  653. goto out;
  654. /* PLOGI chkparm OK */
  655. lpfc_printf_log(phba,
  656. KERN_INFO,
  657. LOG_ELS,
  658. "%d:0121 PLOGI chkparm OK "
  659. "Data: x%x x%x x%x x%x\n",
  660. phba->brd_no,
  661. ndlp->nlp_DID, ndlp->nlp_state,
  662. ndlp->nlp_flag, ndlp->nlp_rpi);
  663. if ((phba->cfg_fcp_class == 2) &&
  664. (sp->cls2.classValid)) {
  665. ndlp->nlp_fcp_info |= CLASS2;
  666. } else {
  667. ndlp->nlp_fcp_info |= CLASS3;
  668. }
  669. ndlp->nlp_class_sup = 0;
  670. if (sp->cls1.classValid)
  671. ndlp->nlp_class_sup |= FC_COS_CLASS1;
  672. if (sp->cls2.classValid)
  673. ndlp->nlp_class_sup |= FC_COS_CLASS2;
  674. if (sp->cls3.classValid)
  675. ndlp->nlp_class_sup |= FC_COS_CLASS3;
  676. if (sp->cls4.classValid)
  677. ndlp->nlp_class_sup |= FC_COS_CLASS4;
  678. ndlp->nlp_maxframe =
  679. ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
  680. sp->cmn.bbRcvSizeLsb;
  681. if (!(mbox = mempool_alloc(phba->mbox_mem_pool,
  682. GFP_KERNEL)))
  683. goto out;
  684. lpfc_unreg_rpi(phba, ndlp);
  685. if (lpfc_reg_login
  686. (phba, irsp->un.elsreq64.remoteID,
  687. (uint8_t *) sp, mbox, 0) == 0) {
  688. switch (ndlp->nlp_DID) {
  689. case NameServer_DID:
  690. mbox->mbox_cmpl =
  691. lpfc_mbx_cmpl_ns_reg_login;
  692. break;
  693. case FDMI_DID:
  694. mbox->mbox_cmpl =
  695. lpfc_mbx_cmpl_fdmi_reg_login;
  696. break;
  697. default:
  698. mbox->mbox_cmpl =
  699. lpfc_mbx_cmpl_reg_login;
  700. }
  701. mbox->context2 = ndlp;
  702. if (lpfc_sli_issue_mbox(phba, mbox,
  703. (MBX_NOWAIT | MBX_STOP_IOCB))
  704. != MBX_NOT_FINISHED) {
  705. ndlp->nlp_state =
  706. NLP_STE_REG_LOGIN_ISSUE;
  707. lpfc_nlp_list(phba, ndlp,
  708. NLP_REGLOGIN_LIST);
  709. return ndlp->nlp_state;
  710. }
  711. mp = (struct lpfc_dmabuf *)mbox->context1;
  712. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  713. kfree(mp);
  714. mempool_free(mbox, phba->mbox_mem_pool);
  715. } else {
  716. mempool_free(mbox, phba->mbox_mem_pool);
  717. }
  718. out:
  719. /* Free this node since the driver cannot login or has the wrong
  720. sparm */
  721. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  722. return NLP_STE_FREED_NODE;
  723. }
  724. static uint32_t
  725. lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
  726. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  727. {
  728. if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  729. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  730. return ndlp->nlp_state;
  731. }
  732. else {
  733. /* software abort outstanding PLOGI */
  734. lpfc_els_abort(phba, ndlp);
  735. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  736. return NLP_STE_FREED_NODE;
  737. }
  738. }
  739. static uint32_t
  740. lpfc_device_recov_plogi_issue(struct lpfc_hba * phba,
  741. struct lpfc_nodelist * ndlp, void *arg,
  742. uint32_t evt)
  743. {
  744. /* software abort outstanding PLOGI */
  745. lpfc_els_abort(phba, ndlp);
  746. ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
  747. ndlp->nlp_state = NLP_STE_NPR_NODE;
  748. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  749. spin_lock_irq(phba->host->host_lock);
  750. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  751. spin_unlock_irq(phba->host->host_lock);
  752. return ndlp->nlp_state;
  753. }
  754. static uint32_t
  755. lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
  756. struct lpfc_nodelist * ndlp, void *arg,
  757. uint32_t evt)
  758. {
  759. struct lpfc_iocbq *cmdiocb;
  760. /* software abort outstanding ADISC */
  761. lpfc_els_abort(phba, ndlp);
  762. cmdiocb = (struct lpfc_iocbq *) arg;
  763. if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
  764. return ndlp->nlp_state;
  765. }
  766. ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
  767. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  768. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  769. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  770. return ndlp->nlp_state;
  771. }
  772. static uint32_t
  773. lpfc_rcv_prli_adisc_issue(struct lpfc_hba * phba,
  774. struct lpfc_nodelist * ndlp, void *arg,
  775. uint32_t evt)
  776. {
  777. struct lpfc_iocbq *cmdiocb;
  778. cmdiocb = (struct lpfc_iocbq *) arg;
  779. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  780. return ndlp->nlp_state;
  781. }
  782. static uint32_t
  783. lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba,
  784. struct lpfc_nodelist * ndlp, void *arg,
  785. uint32_t evt)
  786. {
  787. struct lpfc_iocbq *cmdiocb;
  788. cmdiocb = (struct lpfc_iocbq *) arg;
  789. /* software abort outstanding ADISC */
  790. lpfc_els_abort(phba, ndlp);
  791. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  792. return ndlp->nlp_state;
  793. }
  794. static uint32_t
  795. lpfc_rcv_padisc_adisc_issue(struct lpfc_hba * phba,
  796. struct lpfc_nodelist * ndlp, void *arg,
  797. uint32_t evt)
  798. {
  799. struct lpfc_iocbq *cmdiocb;
  800. cmdiocb = (struct lpfc_iocbq *) arg;
  801. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  802. return ndlp->nlp_state;
  803. }
  804. static uint32_t
  805. lpfc_rcv_prlo_adisc_issue(struct lpfc_hba * phba,
  806. struct lpfc_nodelist * ndlp, void *arg,
  807. uint32_t evt)
  808. {
  809. struct lpfc_iocbq *cmdiocb;
  810. cmdiocb = (struct lpfc_iocbq *) arg;
  811. /* Treat like rcv logo */
  812. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
  813. return ndlp->nlp_state;
  814. }
  815. static uint32_t
  816. lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
  817. struct lpfc_nodelist * ndlp, void *arg,
  818. uint32_t evt)
  819. {
  820. struct lpfc_iocbq *cmdiocb, *rspiocb;
  821. IOCB_t *irsp;
  822. ADISC *ap;
  823. cmdiocb = (struct lpfc_iocbq *) arg;
  824. rspiocb = cmdiocb->context_un.rsp_iocb;
  825. ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
  826. irsp = &rspiocb->iocb;
  827. if ((irsp->ulpStatus) ||
  828. (!lpfc_check_adisc(phba, ndlp, &ap->nodeName, &ap->portName))) {
  829. /* 1 sec timeout */
  830. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
  831. spin_lock_irq(phba->host->host_lock);
  832. ndlp->nlp_flag |= NLP_DELAY_TMO;
  833. spin_unlock_irq(phba->host->host_lock);
  834. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  835. memset(&ndlp->nlp_nodename, 0, sizeof (struct lpfc_name));
  836. memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name));
  837. ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
  838. ndlp->nlp_state = NLP_STE_NPR_NODE;
  839. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  840. lpfc_unreg_rpi(phba, ndlp);
  841. return ndlp->nlp_state;
  842. }
  843. if (ndlp->nlp_type & NLP_FCP_TARGET) {
  844. ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
  845. ndlp->nlp_state = NLP_STE_MAPPED_NODE;
  846. lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
  847. } else {
  848. ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
  849. ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
  850. lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
  851. }
  852. return ndlp->nlp_state;
  853. }
  854. static uint32_t
  855. lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
  856. struct lpfc_nodelist * ndlp, void *arg,
  857. uint32_t evt)
  858. {
  859. if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  860. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  861. return ndlp->nlp_state;
  862. }
  863. else {
  864. /* software abort outstanding ADISC */
  865. lpfc_els_abort(phba, ndlp);
  866. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  867. return NLP_STE_FREED_NODE;
  868. }
  869. }
  870. static uint32_t
  871. lpfc_device_recov_adisc_issue(struct lpfc_hba * phba,
  872. struct lpfc_nodelist * ndlp, void *arg,
  873. uint32_t evt)
  874. {
  875. /* software abort outstanding ADISC */
  876. lpfc_els_abort(phba, ndlp);
  877. ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
  878. ndlp->nlp_state = NLP_STE_NPR_NODE;
  879. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  880. spin_lock_irq(phba->host->host_lock);
  881. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  882. ndlp->nlp_flag |= NLP_NPR_ADISC;
  883. spin_unlock_irq(phba->host->host_lock);
  884. return ndlp->nlp_state;
  885. }
  886. static uint32_t
  887. lpfc_rcv_plogi_reglogin_issue(struct lpfc_hba * phba,
  888. struct lpfc_nodelist * ndlp, void *arg,
  889. uint32_t evt)
  890. {
  891. struct lpfc_iocbq *cmdiocb;
  892. cmdiocb = (struct lpfc_iocbq *) arg;
  893. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  894. return ndlp->nlp_state;
  895. }
  896. static uint32_t
  897. lpfc_rcv_prli_reglogin_issue(struct lpfc_hba * phba,
  898. struct lpfc_nodelist * ndlp, void *arg,
  899. uint32_t evt)
  900. {
  901. struct lpfc_iocbq *cmdiocb;
  902. cmdiocb = (struct lpfc_iocbq *) arg;
  903. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  904. return ndlp->nlp_state;
  905. }
  906. static uint32_t
  907. lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba,
  908. struct lpfc_nodelist * ndlp, void *arg,
  909. uint32_t evt)
  910. {
  911. struct lpfc_iocbq *cmdiocb;
  912. cmdiocb = (struct lpfc_iocbq *) arg;
  913. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  914. return ndlp->nlp_state;
  915. }
  916. static uint32_t
  917. lpfc_rcv_padisc_reglogin_issue(struct lpfc_hba * phba,
  918. struct lpfc_nodelist * ndlp, void *arg,
  919. uint32_t evt)
  920. {
  921. struct lpfc_iocbq *cmdiocb;
  922. cmdiocb = (struct lpfc_iocbq *) arg;
  923. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  924. return ndlp->nlp_state;
  925. }
  926. static uint32_t
  927. lpfc_rcv_prlo_reglogin_issue(struct lpfc_hba * phba,
  928. struct lpfc_nodelist * ndlp, void *arg,
  929. uint32_t evt)
  930. {
  931. struct lpfc_iocbq *cmdiocb;
  932. cmdiocb = (struct lpfc_iocbq *) arg;
  933. lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
  934. return ndlp->nlp_state;
  935. }
  936. static uint32_t
  937. lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
  938. struct lpfc_nodelist * ndlp,
  939. void *arg, uint32_t evt)
  940. {
  941. LPFC_MBOXQ_t *pmb;
  942. MAILBOX_t *mb;
  943. uint32_t did;
  944. pmb = (LPFC_MBOXQ_t *) arg;
  945. mb = &pmb->mb;
  946. did = mb->un.varWords[1];
  947. if (mb->mbxStatus) {
  948. /* RegLogin failed */
  949. lpfc_printf_log(phba,
  950. KERN_ERR,
  951. LOG_DISCOVERY,
  952. "%d:0246 RegLogin failed Data: x%x x%x x%x\n",
  953. phba->brd_no,
  954. did, mb->mbxStatus, phba->hba_state);
  955. /*
  956. * If RegLogin failed due to lack of HBA resources do not
  957. * retry discovery.
  958. */
  959. if (mb->mbxStatus == MBXERR_RPI_FULL) {
  960. ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
  961. ndlp->nlp_state = NLP_STE_UNUSED_NODE;
  962. lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
  963. return ndlp->nlp_state;
  964. }
  965. /* Put ndlp in npr list set plogi timer for 1 sec */
  966. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
  967. spin_lock_irq(phba->host->host_lock);
  968. ndlp->nlp_flag |= NLP_DELAY_TMO;
  969. spin_unlock_irq(phba->host->host_lock);
  970. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  971. lpfc_issue_els_logo(phba, ndlp, 0);
  972. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  973. ndlp->nlp_state = NLP_STE_NPR_NODE;
  974. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  975. return ndlp->nlp_state;
  976. }
  977. ndlp->nlp_rpi = mb->un.varWords[0];
  978. /* Only if we are not a fabric nport do we issue PRLI */
  979. if (!(ndlp->nlp_type & NLP_FABRIC)) {
  980. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  981. ndlp->nlp_state = NLP_STE_PRLI_ISSUE;
  982. lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
  983. lpfc_issue_els_prli(phba, ndlp, 0);
  984. } else {
  985. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  986. ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
  987. lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
  988. }
  989. return ndlp->nlp_state;
  990. }
  991. static uint32_t
  992. lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
  993. struct lpfc_nodelist * ndlp, void *arg,
  994. uint32_t evt)
  995. {
  996. if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  997. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  998. return ndlp->nlp_state;
  999. }
  1000. else {
  1001. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1002. return NLP_STE_FREED_NODE;
  1003. }
  1004. }
  1005. static uint32_t
  1006. lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
  1007. struct lpfc_nodelist * ndlp, void *arg,
  1008. uint32_t evt)
  1009. {
  1010. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  1011. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1012. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1013. spin_lock_irq(phba->host->host_lock);
  1014. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1015. spin_unlock_irq(phba->host->host_lock);
  1016. return ndlp->nlp_state;
  1017. }
  1018. static uint32_t
  1019. lpfc_rcv_plogi_prli_issue(struct lpfc_hba * phba,
  1020. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1021. {
  1022. struct lpfc_iocbq *cmdiocb;
  1023. cmdiocb = (struct lpfc_iocbq *) arg;
  1024. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  1025. return ndlp->nlp_state;
  1026. }
  1027. static uint32_t
  1028. lpfc_rcv_prli_prli_issue(struct lpfc_hba * phba,
  1029. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1030. {
  1031. struct lpfc_iocbq *cmdiocb;
  1032. cmdiocb = (struct lpfc_iocbq *) arg;
  1033. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  1034. return ndlp->nlp_state;
  1035. }
  1036. static uint32_t
  1037. lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
  1038. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1039. {
  1040. struct lpfc_iocbq *cmdiocb;
  1041. cmdiocb = (struct lpfc_iocbq *) arg;
  1042. /* Software abort outstanding PRLI before sending acc */
  1043. lpfc_els_abort(phba, ndlp);
  1044. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1045. return ndlp->nlp_state;
  1046. }
  1047. static uint32_t
  1048. lpfc_rcv_padisc_prli_issue(struct lpfc_hba * phba,
  1049. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1050. {
  1051. struct lpfc_iocbq *cmdiocb;
  1052. cmdiocb = (struct lpfc_iocbq *) arg;
  1053. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1054. return ndlp->nlp_state;
  1055. }
  1056. /* This routine is envoked when we rcv a PRLO request from a nport
  1057. * we are logged into. We should send back a PRLO rsp setting the
  1058. * appropriate bits.
  1059. * NEXT STATE = PRLI_ISSUE
  1060. */
  1061. static uint32_t
  1062. lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba,
  1063. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1064. {
  1065. struct lpfc_iocbq *cmdiocb;
  1066. cmdiocb = (struct lpfc_iocbq *) arg;
  1067. lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
  1068. return ndlp->nlp_state;
  1069. }
  1070. static uint32_t
  1071. lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
  1072. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1073. {
  1074. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1075. IOCB_t *irsp;
  1076. PRLI *npr;
  1077. cmdiocb = (struct lpfc_iocbq *) arg;
  1078. rspiocb = cmdiocb->context_un.rsp_iocb;
  1079. npr = (PRLI *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
  1080. irsp = &rspiocb->iocb;
  1081. if (irsp->ulpStatus) {
  1082. ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
  1083. ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
  1084. lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
  1085. return ndlp->nlp_state;
  1086. }
  1087. /* Check out PRLI rsp */
  1088. ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
  1089. ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
  1090. if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
  1091. (npr->prliType == PRLI_FCP_TYPE)) {
  1092. if (npr->initiatorFunc)
  1093. ndlp->nlp_type |= NLP_FCP_INITIATOR;
  1094. if (npr->targetFunc)
  1095. ndlp->nlp_type |= NLP_FCP_TARGET;
  1096. if (npr->Retry)
  1097. ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
  1098. }
  1099. ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
  1100. ndlp->nlp_state = NLP_STE_MAPPED_NODE;
  1101. lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
  1102. return ndlp->nlp_state;
  1103. }
  1104. /*! lpfc_device_rm_prli_issue
  1105. *
  1106. * \pre
  1107. * \post
  1108. * \param phba
  1109. * \param ndlp
  1110. * \param arg
  1111. * \param evt
  1112. * \return uint32_t
  1113. *
  1114. * \b Description:
  1115. * This routine is envoked when we a request to remove a nport we are in the
  1116. * process of PRLIing. We should software abort outstanding prli, unreg
  1117. * login, send a logout. We will change node state to UNUSED_NODE, put it
  1118. * on plogi list so it can be freed when LOGO completes.
  1119. *
  1120. */
  1121. static uint32_t
  1122. lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
  1123. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1124. {
  1125. if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  1126. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  1127. return ndlp->nlp_state;
  1128. }
  1129. else {
  1130. /* software abort outstanding PLOGI */
  1131. lpfc_els_abort(phba, ndlp);
  1132. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1133. return NLP_STE_FREED_NODE;
  1134. }
  1135. }
  1136. /*! lpfc_device_recov_prli_issue
  1137. *
  1138. * \pre
  1139. * \post
  1140. * \param phba
  1141. * \param ndlp
  1142. * \param arg
  1143. * \param evt
  1144. * \return uint32_t
  1145. *
  1146. * \b Description:
  1147. * The routine is envoked when the state of a device is unknown, like
  1148. * during a link down. We should remove the nodelist entry from the
  1149. * unmapped list, issue a UNREG_LOGIN, do a software abort of the
  1150. * outstanding PRLI command, then free the node entry.
  1151. */
  1152. static uint32_t
  1153. lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
  1154. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1155. {
  1156. /* software abort outstanding PRLI */
  1157. lpfc_els_abort(phba, ndlp);
  1158. ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
  1159. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1160. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1161. spin_lock_irq(phba->host->host_lock);
  1162. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1163. spin_unlock_irq(phba->host->host_lock);
  1164. return ndlp->nlp_state;
  1165. }
  1166. static uint32_t
  1167. lpfc_rcv_plogi_unmap_node(struct lpfc_hba * phba,
  1168. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1169. {
  1170. struct lpfc_iocbq *cmdiocb;
  1171. cmdiocb = (struct lpfc_iocbq *) arg;
  1172. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  1173. return ndlp->nlp_state;
  1174. }
  1175. static uint32_t
  1176. lpfc_rcv_prli_unmap_node(struct lpfc_hba * phba,
  1177. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1178. {
  1179. struct lpfc_iocbq *cmdiocb;
  1180. cmdiocb = (struct lpfc_iocbq *) arg;
  1181. lpfc_rcv_prli(phba, ndlp, cmdiocb);
  1182. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  1183. return ndlp->nlp_state;
  1184. }
  1185. static uint32_t
  1186. lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba,
  1187. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1188. {
  1189. struct lpfc_iocbq *cmdiocb;
  1190. cmdiocb = (struct lpfc_iocbq *) arg;
  1191. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1192. return ndlp->nlp_state;
  1193. }
  1194. static uint32_t
  1195. lpfc_rcv_padisc_unmap_node(struct lpfc_hba * phba,
  1196. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1197. {
  1198. struct lpfc_iocbq *cmdiocb;
  1199. cmdiocb = (struct lpfc_iocbq *) arg;
  1200. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1201. return ndlp->nlp_state;
  1202. }
  1203. static uint32_t
  1204. lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba,
  1205. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1206. {
  1207. struct lpfc_iocbq *cmdiocb;
  1208. cmdiocb = (struct lpfc_iocbq *) arg;
  1209. lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
  1210. return ndlp->nlp_state;
  1211. }
  1212. static uint32_t
  1213. lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
  1214. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1215. {
  1216. ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
  1217. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1218. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1219. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1220. lpfc_disc_set_adisc(phba, ndlp);
  1221. return ndlp->nlp_state;
  1222. }
  1223. static uint32_t
  1224. lpfc_rcv_plogi_mapped_node(struct lpfc_hba * phba,
  1225. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1226. {
  1227. struct lpfc_iocbq *cmdiocb;
  1228. cmdiocb = (struct lpfc_iocbq *) arg;
  1229. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  1230. return ndlp->nlp_state;
  1231. }
  1232. static uint32_t
  1233. lpfc_rcv_prli_mapped_node(struct lpfc_hba * phba,
  1234. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1235. {
  1236. struct lpfc_iocbq *cmdiocb;
  1237. cmdiocb = (struct lpfc_iocbq *) arg;
  1238. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  1239. return ndlp->nlp_state;
  1240. }
  1241. static uint32_t
  1242. lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba,
  1243. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1244. {
  1245. struct lpfc_iocbq *cmdiocb;
  1246. cmdiocb = (struct lpfc_iocbq *) arg;
  1247. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1248. return ndlp->nlp_state;
  1249. }
  1250. static uint32_t
  1251. lpfc_rcv_padisc_mapped_node(struct lpfc_hba * phba,
  1252. struct lpfc_nodelist * ndlp, void *arg,
  1253. uint32_t evt)
  1254. {
  1255. struct lpfc_iocbq *cmdiocb;
  1256. cmdiocb = (struct lpfc_iocbq *) arg;
  1257. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1258. return ndlp->nlp_state;
  1259. }
  1260. static uint32_t
  1261. lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba,
  1262. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1263. {
  1264. struct lpfc_iocbq *cmdiocb;
  1265. cmdiocb = (struct lpfc_iocbq *) arg;
  1266. /* flush the target */
  1267. spin_lock_irq(phba->host->host_lock);
  1268. lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
  1269. ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT);
  1270. spin_unlock_irq(phba->host->host_lock);
  1271. /* Treat like rcv logo */
  1272. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
  1273. return ndlp->nlp_state;
  1274. }
  1275. static uint32_t
  1276. lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
  1277. struct lpfc_nodelist * ndlp, void *arg,
  1278. uint32_t evt)
  1279. {
  1280. ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
  1281. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1282. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1283. spin_lock_irq(phba->host->host_lock);
  1284. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1285. spin_unlock_irq(phba->host->host_lock);
  1286. lpfc_disc_set_adisc(phba, ndlp);
  1287. return ndlp->nlp_state;
  1288. }
  1289. static uint32_t
  1290. lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
  1291. struct lpfc_nodelist * ndlp, void *arg,
  1292. uint32_t evt)
  1293. {
  1294. struct lpfc_iocbq *cmdiocb;
  1295. cmdiocb = (struct lpfc_iocbq *) arg;
  1296. /* Ignore PLOGI if we have an outstanding LOGO */
  1297. if (ndlp->nlp_flag & NLP_LOGO_SND) {
  1298. return ndlp->nlp_state;
  1299. }
  1300. if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
  1301. spin_lock_irq(phba->host->host_lock);
  1302. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1303. spin_unlock_irq(phba->host->host_lock);
  1304. return ndlp->nlp_state;
  1305. }
  1306. /* send PLOGI immediately, move to PLOGI issue state */
  1307. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1308. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1309. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  1310. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  1311. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  1312. }
  1313. return ndlp->nlp_state;
  1314. }
  1315. static uint32_t
  1316. lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
  1317. struct lpfc_nodelist * ndlp, void *arg,
  1318. uint32_t evt)
  1319. {
  1320. struct lpfc_iocbq *cmdiocb;
  1321. struct ls_rjt stat;
  1322. cmdiocb = (struct lpfc_iocbq *) arg;
  1323. memset(&stat, 0, sizeof (struct ls_rjt));
  1324. stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
  1325. stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
  1326. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
  1327. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1328. if (ndlp->nlp_flag & NLP_NPR_ADISC) {
  1329. spin_lock_irq(phba->host->host_lock);
  1330. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1331. spin_unlock_irq(phba->host->host_lock);
  1332. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1333. ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
  1334. lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
  1335. lpfc_issue_els_adisc(phba, ndlp, 0);
  1336. } else {
  1337. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1338. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  1339. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  1340. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  1341. }
  1342. }
  1343. return ndlp->nlp_state;
  1344. }
  1345. static uint32_t
  1346. lpfc_rcv_logo_npr_node(struct lpfc_hba * phba,
  1347. struct lpfc_nodelist * ndlp, void *arg,
  1348. uint32_t evt)
  1349. {
  1350. struct lpfc_iocbq *cmdiocb;
  1351. cmdiocb = (struct lpfc_iocbq *) arg;
  1352. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1353. return ndlp->nlp_state;
  1354. }
  1355. static uint32_t
  1356. lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
  1357. struct lpfc_nodelist * ndlp, void *arg,
  1358. uint32_t evt)
  1359. {
  1360. struct lpfc_iocbq *cmdiocb;
  1361. cmdiocb = (struct lpfc_iocbq *) arg;
  1362. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1363. /*
  1364. * Do not start discovery if discovery is about to start
  1365. * or discovery in progress for this node. Starting discovery
  1366. * here will affect the counting of discovery threads.
  1367. */
  1368. if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
  1369. !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
  1370. if (ndlp->nlp_flag & NLP_NPR_ADISC) {
  1371. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1372. ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
  1373. lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
  1374. lpfc_issue_els_adisc(phba, ndlp, 0);
  1375. } else {
  1376. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1377. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  1378. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  1379. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  1380. }
  1381. }
  1382. return ndlp->nlp_state;
  1383. }
  1384. static uint32_t
  1385. lpfc_rcv_prlo_npr_node(struct lpfc_hba * phba,
  1386. struct lpfc_nodelist * ndlp, void *arg,
  1387. uint32_t evt)
  1388. {
  1389. struct lpfc_iocbq *cmdiocb;
  1390. cmdiocb = (struct lpfc_iocbq *) arg;
  1391. spin_lock_irq(phba->host->host_lock);
  1392. ndlp->nlp_flag |= NLP_LOGO_ACC;
  1393. spin_unlock_irq(phba->host->host_lock);
  1394. lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
  1395. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1396. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
  1397. spin_lock_irq(phba->host->host_lock);
  1398. ndlp->nlp_flag |= NLP_DELAY_TMO;
  1399. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1400. spin_unlock_irq(phba->host->host_lock);
  1401. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  1402. } else {
  1403. spin_lock_irq(phba->host->host_lock);
  1404. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1405. spin_unlock_irq(phba->host->host_lock);
  1406. }
  1407. return ndlp->nlp_state;
  1408. }
  1409. static uint32_t
  1410. lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
  1411. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1412. {
  1413. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1414. IOCB_t *irsp;
  1415. cmdiocb = (struct lpfc_iocbq *) arg;
  1416. rspiocb = cmdiocb->context_un.rsp_iocb;
  1417. irsp = &rspiocb->iocb;
  1418. if (irsp->ulpStatus) {
  1419. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1420. return NLP_STE_FREED_NODE;
  1421. }
  1422. return ndlp->nlp_state;
  1423. }
  1424. static uint32_t
  1425. lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
  1426. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1427. {
  1428. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1429. IOCB_t *irsp;
  1430. cmdiocb = (struct lpfc_iocbq *) arg;
  1431. rspiocb = cmdiocb->context_un.rsp_iocb;
  1432. irsp = &rspiocb->iocb;
  1433. if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
  1434. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1435. return NLP_STE_FREED_NODE;
  1436. }
  1437. return ndlp->nlp_state;
  1438. }
  1439. static uint32_t
  1440. lpfc_cmpl_logo_npr_node(struct lpfc_hba * phba,
  1441. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1442. {
  1443. lpfc_unreg_rpi(phba, ndlp);
  1444. /* This routine does nothing, just return the current state */
  1445. return ndlp->nlp_state;
  1446. }
  1447. static uint32_t
  1448. lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
  1449. struct lpfc_nodelist * ndlp, void *arg,
  1450. uint32_t evt)
  1451. {
  1452. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1453. IOCB_t *irsp;
  1454. cmdiocb = (struct lpfc_iocbq *) arg;
  1455. rspiocb = cmdiocb->context_un.rsp_iocb;
  1456. irsp = &rspiocb->iocb;
  1457. if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
  1458. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1459. return NLP_STE_FREED_NODE;
  1460. }
  1461. return ndlp->nlp_state;
  1462. }
  1463. static uint32_t
  1464. lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
  1465. struct lpfc_nodelist * ndlp, void *arg,
  1466. uint32_t evt)
  1467. {
  1468. LPFC_MBOXQ_t *pmb;
  1469. MAILBOX_t *mb;
  1470. pmb = (LPFC_MBOXQ_t *) arg;
  1471. mb = &pmb->mb;
  1472. if (!mb->mbxStatus)
  1473. ndlp->nlp_rpi = mb->un.varWords[0];
  1474. else {
  1475. if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
  1476. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1477. return NLP_STE_FREED_NODE;
  1478. }
  1479. }
  1480. return ndlp->nlp_state;
  1481. }
  1482. static uint32_t
  1483. lpfc_device_rm_npr_node(struct lpfc_hba * phba,
  1484. struct lpfc_nodelist * ndlp, void *arg,
  1485. uint32_t evt)
  1486. {
  1487. if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  1488. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  1489. return ndlp->nlp_state;
  1490. }
  1491. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1492. return NLP_STE_FREED_NODE;
  1493. }
  1494. static uint32_t
  1495. lpfc_device_recov_npr_node(struct lpfc_hba * phba,
  1496. struct lpfc_nodelist * ndlp, void *arg,
  1497. uint32_t evt)
  1498. {
  1499. spin_lock_irq(phba->host->host_lock);
  1500. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1501. spin_unlock_irq(phba->host->host_lock);
  1502. if (ndlp->nlp_flag & NLP_DELAY_TMO) {
  1503. lpfc_cancel_retry_delay_tmo(phba, ndlp);
  1504. }
  1505. return ndlp->nlp_state;
  1506. }
  1507. /* This next section defines the NPort Discovery State Machine */
  1508. /* There are 4 different double linked lists nodelist entries can reside on.
  1509. * The plogi list and adisc list are used when Link Up discovery or RSCN
  1510. * processing is needed. Each list holds the nodes that we will send PLOGI
  1511. * or ADISC on. These lists will keep track of what nodes will be effected
  1512. * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
  1513. * The unmapped_list will contain all nodes that we have successfully logged
  1514. * into at the Fibre Channel level. The mapped_list will contain all nodes
  1515. * that are mapped FCP targets.
  1516. */
  1517. /*
  1518. * The bind list is a list of undiscovered (potentially non-existent) nodes
  1519. * that we have saved binding information on. This information is used when
  1520. * nodes transition from the unmapped to the mapped list.
  1521. */
  1522. /* For UNUSED_NODE state, the node has just been allocated .
  1523. * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
  1524. * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
  1525. * and put on the unmapped list. For ADISC processing, the node is taken off
  1526. * the ADISC list and placed on either the mapped or unmapped list (depending
  1527. * on its previous state). Once on the unmapped list, a PRLI is issued and the
  1528. * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
  1529. * changed to UNMAPPED_NODE. If the completion indicates a mapped
  1530. * node, the node is taken off the unmapped list. The binding list is checked
  1531. * for a valid binding, or a binding is automatically assigned. If binding
  1532. * assignment is unsuccessful, the node is left on the unmapped list. If
  1533. * binding assignment is successful, the associated binding list entry (if
  1534. * any) is removed, and the node is placed on the mapped list.
  1535. */
  1536. /*
  1537. * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
  1538. * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
  1539. * expire, all effected nodes will receive a DEVICE_RM event.
  1540. */
  1541. /*
  1542. * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
  1543. * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
  1544. * check, additional nodes may be added or removed (via DEVICE_RM) to / from
  1545. * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
  1546. * we will first process the ADISC list. 32 entries are processed initially and
  1547. * ADISC is initited for each one. Completions / Events for each node are
  1548. * funnelled thru the state machine. As each node finishes ADISC processing, it
  1549. * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
  1550. * waiting, and the ADISC list count is identically 0, then we are done. For
  1551. * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
  1552. * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
  1553. * list. 32 entries are processed initially and PLOGI is initited for each one.
  1554. * Completions / Events for each node are funnelled thru the state machine. As
  1555. * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
  1556. * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
  1557. * indentically 0, then we are done. We have now completed discovery / RSCN
  1558. * handling. Upon completion, ALL nodes should be on either the mapped or
  1559. * unmapped lists.
  1560. */
  1561. static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
  1562. (struct lpfc_hba *, struct lpfc_nodelist *, void *, uint32_t) = {
  1563. /* Action routine Event Current State */
  1564. lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
  1565. lpfc_rcv_els_unused_node, /* RCV_PRLI */
  1566. lpfc_rcv_logo_unused_node, /* RCV_LOGO */
  1567. lpfc_rcv_els_unused_node, /* RCV_ADISC */
  1568. lpfc_rcv_els_unused_node, /* RCV_PDISC */
  1569. lpfc_rcv_els_unused_node, /* RCV_PRLO */
  1570. lpfc_disc_illegal, /* CMPL_PLOGI */
  1571. lpfc_disc_illegal, /* CMPL_PRLI */
  1572. lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
  1573. lpfc_disc_illegal, /* CMPL_ADISC */
  1574. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1575. lpfc_device_rm_unused_node, /* DEVICE_RM */
  1576. lpfc_disc_illegal, /* DEVICE_RECOVERY */
  1577. lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
  1578. lpfc_rcv_els_plogi_issue, /* RCV_PRLI */
  1579. lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
  1580. lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
  1581. lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
  1582. lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
  1583. lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
  1584. lpfc_disc_illegal, /* CMPL_PRLI */
  1585. lpfc_disc_illegal, /* CMPL_LOGO */
  1586. lpfc_disc_illegal, /* CMPL_ADISC */
  1587. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1588. lpfc_device_rm_plogi_issue, /* DEVICE_RM */
  1589. lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
  1590. lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
  1591. lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
  1592. lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
  1593. lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
  1594. lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
  1595. lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
  1596. lpfc_disc_illegal, /* CMPL_PLOGI */
  1597. lpfc_disc_illegal, /* CMPL_PRLI */
  1598. lpfc_disc_illegal, /* CMPL_LOGO */
  1599. lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
  1600. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1601. lpfc_device_rm_adisc_issue, /* DEVICE_RM */
  1602. lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
  1603. lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
  1604. lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
  1605. lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
  1606. lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
  1607. lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
  1608. lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
  1609. lpfc_disc_illegal, /* CMPL_PLOGI */
  1610. lpfc_disc_illegal, /* CMPL_PRLI */
  1611. lpfc_disc_illegal, /* CMPL_LOGO */
  1612. lpfc_disc_illegal, /* CMPL_ADISC */
  1613. lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
  1614. lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
  1615. lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
  1616. lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
  1617. lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
  1618. lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
  1619. lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
  1620. lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
  1621. lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
  1622. lpfc_disc_illegal, /* CMPL_PLOGI */
  1623. lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
  1624. lpfc_disc_illegal, /* CMPL_LOGO */
  1625. lpfc_disc_illegal, /* CMPL_ADISC */
  1626. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1627. lpfc_device_rm_prli_issue, /* DEVICE_RM */
  1628. lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
  1629. lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
  1630. lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
  1631. lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
  1632. lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
  1633. lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
  1634. lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
  1635. lpfc_disc_illegal, /* CMPL_PLOGI */
  1636. lpfc_disc_illegal, /* CMPL_PRLI */
  1637. lpfc_disc_illegal, /* CMPL_LOGO */
  1638. lpfc_disc_illegal, /* CMPL_ADISC */
  1639. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1640. lpfc_disc_illegal, /* DEVICE_RM */
  1641. lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
  1642. lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
  1643. lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
  1644. lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
  1645. lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
  1646. lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
  1647. lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
  1648. lpfc_disc_illegal, /* CMPL_PLOGI */
  1649. lpfc_disc_illegal, /* CMPL_PRLI */
  1650. lpfc_disc_illegal, /* CMPL_LOGO */
  1651. lpfc_disc_illegal, /* CMPL_ADISC */
  1652. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1653. lpfc_disc_illegal, /* DEVICE_RM */
  1654. lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
  1655. lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
  1656. lpfc_rcv_prli_npr_node, /* RCV_PRLI */
  1657. lpfc_rcv_logo_npr_node, /* RCV_LOGO */
  1658. lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
  1659. lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
  1660. lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
  1661. lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
  1662. lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
  1663. lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
  1664. lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
  1665. lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
  1666. lpfc_device_rm_npr_node, /* DEVICE_RM */
  1667. lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
  1668. };
  1669. int
  1670. lpfc_disc_state_machine(struct lpfc_hba * phba,
  1671. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1672. {
  1673. uint32_t cur_state, rc;
  1674. uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *,
  1675. uint32_t);
  1676. ndlp->nlp_disc_refcnt++;
  1677. cur_state = ndlp->nlp_state;
  1678. /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
  1679. lpfc_printf_log(phba,
  1680. KERN_INFO,
  1681. LOG_DISCOVERY,
  1682. "%d:0211 DSM in event x%x on NPort x%x in state %d "
  1683. "Data: x%x\n",
  1684. phba->brd_no,
  1685. evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag);
  1686. func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
  1687. rc = (func) (phba, ndlp, arg, evt);
  1688. /* DSM out state <rc> on NPort <nlp_DID> */
  1689. lpfc_printf_log(phba,
  1690. KERN_INFO,
  1691. LOG_DISCOVERY,
  1692. "%d:0212 DSM out state %d on NPort x%x Data: x%x\n",
  1693. phba->brd_no,
  1694. rc, ndlp->nlp_DID, ndlp->nlp_flag);
  1695. ndlp->nlp_disc_refcnt--;
  1696. /* Check to see if ndlp removal is deferred */
  1697. if ((ndlp->nlp_disc_refcnt == 0)
  1698. && (ndlp->nlp_flag & NLP_DELAY_REMOVE)) {
  1699. spin_lock_irq(phba->host->host_lock);
  1700. ndlp->nlp_flag &= ~NLP_DELAY_REMOVE;
  1701. spin_unlock_irq(phba->host->host_lock);
  1702. lpfc_nlp_remove(phba, ndlp);
  1703. return NLP_STE_FREED_NODE;
  1704. }
  1705. if (rc == NLP_STE_FREED_NODE)
  1706. return NLP_STE_FREED_NODE;
  1707. return rc;
  1708. }