lpfc_nportdisc.c 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  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. /*
  971. * If RegLogin failed due to lack of HBA resources do not
  972. * retry discovery.
  973. */
  974. if (mb->mbxStatus == MBXERR_RPI_FULL) {
  975. ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
  976. ndlp->nlp_state = NLP_STE_UNUSED_NODE;
  977. lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
  978. return ndlp->nlp_state;
  979. }
  980. /* Put ndlp in npr list set plogi timer for 1 sec */
  981. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
  982. spin_lock_irq(phba->host->host_lock);
  983. ndlp->nlp_flag |= NLP_DELAY_TMO;
  984. spin_unlock_irq(phba->host->host_lock);
  985. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  986. lpfc_issue_els_logo(phba, ndlp, 0);
  987. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  988. ndlp->nlp_state = NLP_STE_NPR_NODE;
  989. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  990. return ndlp->nlp_state;
  991. }
  992. ndlp->nlp_rpi = mb->un.varWords[0];
  993. /* Only if we are not a fabric nport do we issue PRLI */
  994. if (!(ndlp->nlp_type & NLP_FABRIC)) {
  995. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  996. ndlp->nlp_state = NLP_STE_PRLI_ISSUE;
  997. lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
  998. lpfc_issue_els_prli(phba, ndlp, 0);
  999. } else {
  1000. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  1001. ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
  1002. lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
  1003. }
  1004. return ndlp->nlp_state;
  1005. }
  1006. static uint32_t
  1007. lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
  1008. struct lpfc_nodelist * ndlp, void *arg,
  1009. uint32_t evt)
  1010. {
  1011. if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  1012. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  1013. return ndlp->nlp_state;
  1014. }
  1015. else {
  1016. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1017. return NLP_STE_FREED_NODE;
  1018. }
  1019. }
  1020. static uint32_t
  1021. lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
  1022. struct lpfc_nodelist * ndlp, void *arg,
  1023. uint32_t evt)
  1024. {
  1025. ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
  1026. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1027. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1028. spin_lock_irq(phba->host->host_lock);
  1029. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1030. spin_unlock_irq(phba->host->host_lock);
  1031. return ndlp->nlp_state;
  1032. }
  1033. static uint32_t
  1034. lpfc_rcv_plogi_prli_issue(struct lpfc_hba * phba,
  1035. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1036. {
  1037. struct lpfc_iocbq *cmdiocb;
  1038. cmdiocb = (struct lpfc_iocbq *) arg;
  1039. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  1040. return ndlp->nlp_state;
  1041. }
  1042. static uint32_t
  1043. lpfc_rcv_prli_prli_issue(struct lpfc_hba * phba,
  1044. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1045. {
  1046. struct lpfc_iocbq *cmdiocb;
  1047. cmdiocb = (struct lpfc_iocbq *) arg;
  1048. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  1049. return ndlp->nlp_state;
  1050. }
  1051. static uint32_t
  1052. lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
  1053. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1054. {
  1055. struct lpfc_iocbq *cmdiocb;
  1056. cmdiocb = (struct lpfc_iocbq *) arg;
  1057. /* Software abort outstanding PRLI before sending acc */
  1058. lpfc_els_abort(phba, ndlp, 1);
  1059. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1060. return ndlp->nlp_state;
  1061. }
  1062. static uint32_t
  1063. lpfc_rcv_padisc_prli_issue(struct lpfc_hba * phba,
  1064. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1065. {
  1066. struct lpfc_iocbq *cmdiocb;
  1067. cmdiocb = (struct lpfc_iocbq *) arg;
  1068. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1069. return ndlp->nlp_state;
  1070. }
  1071. /* This routine is envoked when we rcv a PRLO request from a nport
  1072. * we are logged into. We should send back a PRLO rsp setting the
  1073. * appropriate bits.
  1074. * NEXT STATE = PRLI_ISSUE
  1075. */
  1076. static uint32_t
  1077. lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba,
  1078. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1079. {
  1080. struct lpfc_iocbq *cmdiocb;
  1081. cmdiocb = (struct lpfc_iocbq *) arg;
  1082. lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
  1083. return ndlp->nlp_state;
  1084. }
  1085. static uint32_t
  1086. lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
  1087. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1088. {
  1089. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1090. IOCB_t *irsp;
  1091. PRLI *npr;
  1092. cmdiocb = (struct lpfc_iocbq *) arg;
  1093. rspiocb = cmdiocb->context_un.rsp_iocb;
  1094. npr = (PRLI *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
  1095. irsp = &rspiocb->iocb;
  1096. if (irsp->ulpStatus) {
  1097. ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
  1098. ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
  1099. lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
  1100. return ndlp->nlp_state;
  1101. }
  1102. /* Check out PRLI rsp */
  1103. ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
  1104. ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
  1105. if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
  1106. (npr->prliType == PRLI_FCP_TYPE)) {
  1107. if (npr->initiatorFunc)
  1108. ndlp->nlp_type |= NLP_FCP_INITIATOR;
  1109. if (npr->targetFunc)
  1110. ndlp->nlp_type |= NLP_FCP_TARGET;
  1111. if (npr->Retry)
  1112. ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
  1113. }
  1114. ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
  1115. ndlp->nlp_state = NLP_STE_MAPPED_NODE;
  1116. lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
  1117. return ndlp->nlp_state;
  1118. }
  1119. /*! lpfc_device_rm_prli_issue
  1120. *
  1121. * \pre
  1122. * \post
  1123. * \param phba
  1124. * \param ndlp
  1125. * \param arg
  1126. * \param evt
  1127. * \return uint32_t
  1128. *
  1129. * \b Description:
  1130. * This routine is envoked when we a request to remove a nport we are in the
  1131. * process of PRLIing. We should software abort outstanding prli, unreg
  1132. * login, send a logout. We will change node state to UNUSED_NODE, put it
  1133. * on plogi list so it can be freed when LOGO completes.
  1134. *
  1135. */
  1136. static uint32_t
  1137. lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
  1138. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1139. {
  1140. if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  1141. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  1142. return ndlp->nlp_state;
  1143. }
  1144. else {
  1145. /* software abort outstanding PLOGI */
  1146. lpfc_els_abort(phba, ndlp, 1);
  1147. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1148. return NLP_STE_FREED_NODE;
  1149. }
  1150. }
  1151. /*! lpfc_device_recov_prli_issue
  1152. *
  1153. * \pre
  1154. * \post
  1155. * \param phba
  1156. * \param ndlp
  1157. * \param arg
  1158. * \param evt
  1159. * \return uint32_t
  1160. *
  1161. * \b Description:
  1162. * The routine is envoked when the state of a device is unknown, like
  1163. * during a link down. We should remove the nodelist entry from the
  1164. * unmapped list, issue a UNREG_LOGIN, do a software abort of the
  1165. * outstanding PRLI command, then free the node entry.
  1166. */
  1167. static uint32_t
  1168. lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
  1169. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1170. {
  1171. /* software abort outstanding PRLI */
  1172. lpfc_els_abort(phba, ndlp, 1);
  1173. ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
  1174. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1175. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1176. spin_lock_irq(phba->host->host_lock);
  1177. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1178. spin_unlock_irq(phba->host->host_lock);
  1179. return ndlp->nlp_state;
  1180. }
  1181. static uint32_t
  1182. lpfc_rcv_plogi_unmap_node(struct lpfc_hba * phba,
  1183. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1184. {
  1185. struct lpfc_iocbq *cmdiocb;
  1186. cmdiocb = (struct lpfc_iocbq *) arg;
  1187. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  1188. return ndlp->nlp_state;
  1189. }
  1190. static uint32_t
  1191. lpfc_rcv_prli_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_prli(phba, ndlp, cmdiocb);
  1197. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  1198. return ndlp->nlp_state;
  1199. }
  1200. static uint32_t
  1201. lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba,
  1202. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1203. {
  1204. struct lpfc_iocbq *cmdiocb;
  1205. cmdiocb = (struct lpfc_iocbq *) arg;
  1206. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1207. return ndlp->nlp_state;
  1208. }
  1209. static uint32_t
  1210. lpfc_rcv_padisc_unmap_node(struct lpfc_hba * phba,
  1211. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1212. {
  1213. struct lpfc_iocbq *cmdiocb;
  1214. cmdiocb = (struct lpfc_iocbq *) arg;
  1215. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1216. return ndlp->nlp_state;
  1217. }
  1218. static uint32_t
  1219. lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba,
  1220. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1221. {
  1222. struct lpfc_iocbq *cmdiocb;
  1223. cmdiocb = (struct lpfc_iocbq *) arg;
  1224. lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
  1225. return ndlp->nlp_state;
  1226. }
  1227. static uint32_t
  1228. lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
  1229. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1230. {
  1231. ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
  1232. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1233. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1234. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1235. lpfc_disc_set_adisc(phba, ndlp);
  1236. return ndlp->nlp_state;
  1237. }
  1238. static uint32_t
  1239. lpfc_rcv_plogi_mapped_node(struct lpfc_hba * phba,
  1240. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1241. {
  1242. struct lpfc_iocbq *cmdiocb;
  1243. cmdiocb = (struct lpfc_iocbq *) arg;
  1244. lpfc_rcv_plogi(phba, ndlp, cmdiocb);
  1245. return ndlp->nlp_state;
  1246. }
  1247. static uint32_t
  1248. lpfc_rcv_prli_mapped_node(struct lpfc_hba * phba,
  1249. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1250. {
  1251. struct lpfc_iocbq *cmdiocb;
  1252. cmdiocb = (struct lpfc_iocbq *) arg;
  1253. lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
  1254. return ndlp->nlp_state;
  1255. }
  1256. static uint32_t
  1257. lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba,
  1258. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1259. {
  1260. struct lpfc_iocbq *cmdiocb;
  1261. cmdiocb = (struct lpfc_iocbq *) arg;
  1262. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1263. return ndlp->nlp_state;
  1264. }
  1265. static uint32_t
  1266. lpfc_rcv_padisc_mapped_node(struct lpfc_hba * phba,
  1267. struct lpfc_nodelist * ndlp, void *arg,
  1268. uint32_t evt)
  1269. {
  1270. struct lpfc_iocbq *cmdiocb;
  1271. cmdiocb = (struct lpfc_iocbq *) arg;
  1272. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1273. return ndlp->nlp_state;
  1274. }
  1275. static uint32_t
  1276. lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba,
  1277. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1278. {
  1279. struct lpfc_iocbq *cmdiocb;
  1280. cmdiocb = (struct lpfc_iocbq *) arg;
  1281. /* flush the target */
  1282. spin_lock_irq(phba->host->host_lock);
  1283. lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
  1284. ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT);
  1285. spin_unlock_irq(phba->host->host_lock);
  1286. /* Treat like rcv logo */
  1287. lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
  1288. return ndlp->nlp_state;
  1289. }
  1290. static uint32_t
  1291. lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
  1292. struct lpfc_nodelist * ndlp, void *arg,
  1293. uint32_t evt)
  1294. {
  1295. ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
  1296. ndlp->nlp_state = NLP_STE_NPR_NODE;
  1297. lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
  1298. spin_lock_irq(phba->host->host_lock);
  1299. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1300. spin_unlock_irq(phba->host->host_lock);
  1301. lpfc_disc_set_adisc(phba, ndlp);
  1302. return ndlp->nlp_state;
  1303. }
  1304. static uint32_t
  1305. lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
  1306. struct lpfc_nodelist * ndlp, void *arg,
  1307. uint32_t evt)
  1308. {
  1309. struct lpfc_iocbq *cmdiocb;
  1310. cmdiocb = (struct lpfc_iocbq *) arg;
  1311. /* Ignore PLOGI if we have an outstanding LOGO */
  1312. if (ndlp->nlp_flag & NLP_LOGO_SND) {
  1313. return ndlp->nlp_state;
  1314. }
  1315. if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
  1316. spin_lock_irq(phba->host->host_lock);
  1317. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1318. spin_unlock_irq(phba->host->host_lock);
  1319. return ndlp->nlp_state;
  1320. }
  1321. /* send PLOGI immediately, move to PLOGI issue state */
  1322. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1323. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1324. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  1325. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  1326. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  1327. }
  1328. return ndlp->nlp_state;
  1329. }
  1330. static uint32_t
  1331. lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
  1332. struct lpfc_nodelist * ndlp, void *arg,
  1333. uint32_t evt)
  1334. {
  1335. struct lpfc_iocbq *cmdiocb;
  1336. struct ls_rjt stat;
  1337. cmdiocb = (struct lpfc_iocbq *) arg;
  1338. memset(&stat, 0, sizeof (struct ls_rjt));
  1339. stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
  1340. stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
  1341. lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
  1342. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1343. if (ndlp->nlp_flag & NLP_NPR_ADISC) {
  1344. spin_lock_irq(phba->host->host_lock);
  1345. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1346. spin_unlock_irq(phba->host->host_lock);
  1347. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1348. ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
  1349. lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
  1350. lpfc_issue_els_adisc(phba, ndlp, 0);
  1351. } else {
  1352. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1353. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  1354. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  1355. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  1356. }
  1357. }
  1358. return ndlp->nlp_state;
  1359. }
  1360. static uint32_t
  1361. lpfc_rcv_logo_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_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
  1368. return ndlp->nlp_state;
  1369. }
  1370. static uint32_t
  1371. lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
  1372. struct lpfc_nodelist * ndlp, void *arg,
  1373. uint32_t evt)
  1374. {
  1375. struct lpfc_iocbq *cmdiocb;
  1376. cmdiocb = (struct lpfc_iocbq *) arg;
  1377. lpfc_rcv_padisc(phba, ndlp, cmdiocb);
  1378. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1379. if (ndlp->nlp_flag & NLP_NPR_ADISC) {
  1380. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1381. ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
  1382. lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
  1383. lpfc_issue_els_adisc(phba, ndlp, 0);
  1384. } else {
  1385. ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
  1386. ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
  1387. lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
  1388. lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
  1389. }
  1390. }
  1391. return ndlp->nlp_state;
  1392. }
  1393. static uint32_t
  1394. lpfc_rcv_prlo_npr_node(struct lpfc_hba * phba,
  1395. struct lpfc_nodelist * ndlp, void *arg,
  1396. uint32_t evt)
  1397. {
  1398. struct lpfc_iocbq *cmdiocb;
  1399. cmdiocb = (struct lpfc_iocbq *) arg;
  1400. spin_lock_irq(phba->host->host_lock);
  1401. ndlp->nlp_flag |= NLP_LOGO_ACC;
  1402. spin_unlock_irq(phba->host->host_lock);
  1403. lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
  1404. if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
  1405. mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
  1406. spin_lock_irq(phba->host->host_lock);
  1407. ndlp->nlp_flag |= NLP_DELAY_TMO;
  1408. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1409. spin_unlock_irq(phba->host->host_lock);
  1410. ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
  1411. } else {
  1412. spin_lock_irq(phba->host->host_lock);
  1413. ndlp->nlp_flag &= ~NLP_NPR_ADISC;
  1414. spin_unlock_irq(phba->host->host_lock);
  1415. }
  1416. return ndlp->nlp_state;
  1417. }
  1418. static uint32_t
  1419. lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
  1420. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1421. {
  1422. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1423. IOCB_t *irsp;
  1424. cmdiocb = (struct lpfc_iocbq *) arg;
  1425. rspiocb = cmdiocb->context_un.rsp_iocb;
  1426. irsp = &rspiocb->iocb;
  1427. if (irsp->ulpStatus) {
  1428. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1429. return NLP_STE_FREED_NODE;
  1430. }
  1431. return ndlp->nlp_state;
  1432. }
  1433. static uint32_t
  1434. lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
  1435. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1436. {
  1437. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1438. IOCB_t *irsp;
  1439. cmdiocb = (struct lpfc_iocbq *) arg;
  1440. rspiocb = cmdiocb->context_un.rsp_iocb;
  1441. irsp = &rspiocb->iocb;
  1442. if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
  1443. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1444. return NLP_STE_FREED_NODE;
  1445. }
  1446. return ndlp->nlp_state;
  1447. }
  1448. static uint32_t
  1449. lpfc_cmpl_logo_npr_node(struct lpfc_hba * phba,
  1450. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1451. {
  1452. lpfc_unreg_rpi(phba, ndlp);
  1453. /* This routine does nothing, just return the current state */
  1454. return ndlp->nlp_state;
  1455. }
  1456. static uint32_t
  1457. lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
  1458. struct lpfc_nodelist * ndlp, void *arg,
  1459. uint32_t evt)
  1460. {
  1461. struct lpfc_iocbq *cmdiocb, *rspiocb;
  1462. IOCB_t *irsp;
  1463. cmdiocb = (struct lpfc_iocbq *) arg;
  1464. rspiocb = cmdiocb->context_un.rsp_iocb;
  1465. irsp = &rspiocb->iocb;
  1466. if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
  1467. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1468. return NLP_STE_FREED_NODE;
  1469. }
  1470. return ndlp->nlp_state;
  1471. }
  1472. static uint32_t
  1473. lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
  1474. struct lpfc_nodelist * ndlp, void *arg,
  1475. uint32_t evt)
  1476. {
  1477. LPFC_MBOXQ_t *pmb;
  1478. MAILBOX_t *mb;
  1479. pmb = (LPFC_MBOXQ_t *) arg;
  1480. mb = &pmb->mb;
  1481. if (!mb->mbxStatus)
  1482. ndlp->nlp_rpi = mb->un.varWords[0];
  1483. else {
  1484. if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
  1485. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1486. return NLP_STE_FREED_NODE;
  1487. }
  1488. }
  1489. return ndlp->nlp_state;
  1490. }
  1491. static uint32_t
  1492. lpfc_device_rm_npr_node(struct lpfc_hba * phba,
  1493. struct lpfc_nodelist * ndlp, void *arg,
  1494. uint32_t evt)
  1495. {
  1496. if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
  1497. ndlp->nlp_flag |= NLP_NODEV_REMOVE;
  1498. return ndlp->nlp_state;
  1499. }
  1500. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1501. return NLP_STE_FREED_NODE;
  1502. }
  1503. static uint32_t
  1504. lpfc_device_recov_npr_node(struct lpfc_hba * phba,
  1505. struct lpfc_nodelist * ndlp, void *arg,
  1506. uint32_t evt)
  1507. {
  1508. spin_lock_irq(phba->host->host_lock);
  1509. ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
  1510. spin_unlock_irq(phba->host->host_lock);
  1511. if (ndlp->nlp_flag & NLP_DELAY_TMO) {
  1512. lpfc_cancel_retry_delay_tmo(phba, ndlp);
  1513. }
  1514. return ndlp->nlp_state;
  1515. }
  1516. /* This next section defines the NPort Discovery State Machine */
  1517. /* There are 4 different double linked lists nodelist entries can reside on.
  1518. * The plogi list and adisc list are used when Link Up discovery or RSCN
  1519. * processing is needed. Each list holds the nodes that we will send PLOGI
  1520. * or ADISC on. These lists will keep track of what nodes will be effected
  1521. * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
  1522. * The unmapped_list will contain all nodes that we have successfully logged
  1523. * into at the Fibre Channel level. The mapped_list will contain all nodes
  1524. * that are mapped FCP targets.
  1525. */
  1526. /*
  1527. * The bind list is a list of undiscovered (potentially non-existent) nodes
  1528. * that we have saved binding information on. This information is used when
  1529. * nodes transition from the unmapped to the mapped list.
  1530. */
  1531. /* For UNUSED_NODE state, the node has just been allocated .
  1532. * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
  1533. * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
  1534. * and put on the unmapped list. For ADISC processing, the node is taken off
  1535. * the ADISC list and placed on either the mapped or unmapped list (depending
  1536. * on its previous state). Once on the unmapped list, a PRLI is issued and the
  1537. * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
  1538. * changed to UNMAPPED_NODE. If the completion indicates a mapped
  1539. * node, the node is taken off the unmapped list. The binding list is checked
  1540. * for a valid binding, or a binding is automatically assigned. If binding
  1541. * assignment is unsuccessful, the node is left on the unmapped list. If
  1542. * binding assignment is successful, the associated binding list entry (if
  1543. * any) is removed, and the node is placed on the mapped list.
  1544. */
  1545. /*
  1546. * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
  1547. * lists will receive a DEVICE_RECOVERY event. If the linkdown or nodev timers
  1548. * expire, all effected nodes will receive a DEVICE_RM event.
  1549. */
  1550. /*
  1551. * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
  1552. * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
  1553. * check, additional nodes may be added or removed (via DEVICE_RM) to / from
  1554. * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
  1555. * we will first process the ADISC list. 32 entries are processed initially and
  1556. * ADISC is initited for each one. Completions / Events for each node are
  1557. * funnelled thru the state machine. As each node finishes ADISC processing, it
  1558. * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
  1559. * waiting, and the ADISC list count is identically 0, then we are done. For
  1560. * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
  1561. * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
  1562. * list. 32 entries are processed initially and PLOGI is initited for each one.
  1563. * Completions / Events for each node are funnelled thru the state machine. As
  1564. * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
  1565. * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
  1566. * indentically 0, then we are done. We have now completed discovery / RSCN
  1567. * handling. Upon completion, ALL nodes should be on either the mapped or
  1568. * unmapped lists.
  1569. */
  1570. static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
  1571. (struct lpfc_hba *, struct lpfc_nodelist *, void *, uint32_t) = {
  1572. /* Action routine Event Current State */
  1573. lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
  1574. lpfc_rcv_els_unused_node, /* RCV_PRLI */
  1575. lpfc_rcv_logo_unused_node, /* RCV_LOGO */
  1576. lpfc_rcv_els_unused_node, /* RCV_ADISC */
  1577. lpfc_rcv_els_unused_node, /* RCV_PDISC */
  1578. lpfc_rcv_els_unused_node, /* RCV_PRLO */
  1579. lpfc_disc_illegal, /* CMPL_PLOGI */
  1580. lpfc_disc_illegal, /* CMPL_PRLI */
  1581. lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
  1582. lpfc_disc_illegal, /* CMPL_ADISC */
  1583. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1584. lpfc_device_rm_unused_node, /* DEVICE_RM */
  1585. lpfc_disc_illegal, /* DEVICE_RECOVERY */
  1586. lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
  1587. lpfc_rcv_els_plogi_issue, /* RCV_PRLI */
  1588. lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */
  1589. lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
  1590. lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
  1591. lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
  1592. lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
  1593. lpfc_disc_illegal, /* CMPL_PRLI */
  1594. lpfc_disc_illegal, /* CMPL_LOGO */
  1595. lpfc_disc_illegal, /* CMPL_ADISC */
  1596. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1597. lpfc_device_rm_plogi_issue, /* DEVICE_RM */
  1598. lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
  1599. lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
  1600. lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
  1601. lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
  1602. lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
  1603. lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
  1604. lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
  1605. lpfc_disc_illegal, /* CMPL_PLOGI */
  1606. lpfc_disc_illegal, /* CMPL_PRLI */
  1607. lpfc_disc_illegal, /* CMPL_LOGO */
  1608. lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
  1609. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1610. lpfc_device_rm_adisc_issue, /* DEVICE_RM */
  1611. lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
  1612. lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
  1613. lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
  1614. lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
  1615. lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
  1616. lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
  1617. lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
  1618. lpfc_disc_illegal, /* CMPL_PLOGI */
  1619. lpfc_disc_illegal, /* CMPL_PRLI */
  1620. lpfc_disc_illegal, /* CMPL_LOGO */
  1621. lpfc_disc_illegal, /* CMPL_ADISC */
  1622. lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
  1623. lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
  1624. lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
  1625. lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
  1626. lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
  1627. lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
  1628. lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
  1629. lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
  1630. lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
  1631. lpfc_disc_illegal, /* CMPL_PLOGI */
  1632. lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
  1633. lpfc_disc_illegal, /* CMPL_LOGO */
  1634. lpfc_disc_illegal, /* CMPL_ADISC */
  1635. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1636. lpfc_device_rm_prli_issue, /* DEVICE_RM */
  1637. lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
  1638. lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
  1639. lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
  1640. lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
  1641. lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
  1642. lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
  1643. lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
  1644. lpfc_disc_illegal, /* CMPL_PLOGI */
  1645. lpfc_disc_illegal, /* CMPL_PRLI */
  1646. lpfc_disc_illegal, /* CMPL_LOGO */
  1647. lpfc_disc_illegal, /* CMPL_ADISC */
  1648. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1649. lpfc_disc_illegal, /* DEVICE_RM */
  1650. lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
  1651. lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
  1652. lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
  1653. lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
  1654. lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
  1655. lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
  1656. lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
  1657. lpfc_disc_illegal, /* CMPL_PLOGI */
  1658. lpfc_disc_illegal, /* CMPL_PRLI */
  1659. lpfc_disc_illegal, /* CMPL_LOGO */
  1660. lpfc_disc_illegal, /* CMPL_ADISC */
  1661. lpfc_disc_illegal, /* CMPL_REG_LOGIN */
  1662. lpfc_disc_illegal, /* DEVICE_RM */
  1663. lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
  1664. lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
  1665. lpfc_rcv_prli_npr_node, /* RCV_PRLI */
  1666. lpfc_rcv_logo_npr_node, /* RCV_LOGO */
  1667. lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
  1668. lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
  1669. lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
  1670. lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */
  1671. lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */
  1672. lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
  1673. lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */
  1674. lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
  1675. lpfc_device_rm_npr_node, /* DEVICE_RM */
  1676. lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
  1677. };
  1678. int
  1679. lpfc_disc_state_machine(struct lpfc_hba * phba,
  1680. struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
  1681. {
  1682. uint32_t cur_state, rc;
  1683. uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *,
  1684. uint32_t);
  1685. ndlp->nlp_disc_refcnt++;
  1686. cur_state = ndlp->nlp_state;
  1687. /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
  1688. lpfc_printf_log(phba,
  1689. KERN_INFO,
  1690. LOG_DISCOVERY,
  1691. "%d:0211 DSM in event x%x on NPort x%x in state %d "
  1692. "Data: x%x\n",
  1693. phba->brd_no,
  1694. evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag);
  1695. func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
  1696. rc = (func) (phba, ndlp, arg, evt);
  1697. /* DSM out state <rc> on NPort <nlp_DID> */
  1698. lpfc_printf_log(phba,
  1699. KERN_INFO,
  1700. LOG_DISCOVERY,
  1701. "%d:0212 DSM out state %d on NPort x%x Data: x%x\n",
  1702. phba->brd_no,
  1703. rc, ndlp->nlp_DID, ndlp->nlp_flag);
  1704. ndlp->nlp_disc_refcnt--;
  1705. /* Check to see if ndlp removal is deferred */
  1706. if ((ndlp->nlp_disc_refcnt == 0)
  1707. && (ndlp->nlp_flag & NLP_DELAY_REMOVE)) {
  1708. spin_lock_irq(phba->host->host_lock);
  1709. ndlp->nlp_flag &= ~NLP_DELAY_REMOVE;
  1710. spin_unlock_irq(phba->host->host_lock);
  1711. lpfc_nlp_remove(phba, ndlp);
  1712. return NLP_STE_FREED_NODE;
  1713. }
  1714. if (rc == NLP_STE_FREED_NODE)
  1715. return NLP_STE_FREED_NODE;
  1716. return rc;
  1717. }