lpfc_nportdisc.c 56 KB

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