lpfc_nportdisc.c 56 KB

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