12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853 |
- /*******************************************************************
- * This file is part of the Emulex Linux Device Driver for *
- * Fibre Channel Host Bus Adapters. *
- * Copyright (C) 2004-2005 Emulex. All rights reserved. *
- * EMULEX and SLI are trademarks of Emulex. *
- * www.emulex.com *
- * Portions Copyright (C) 2004-2005 Christoph Hellwig *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of version 2 of the GNU General *
- * Public License as published by the Free Software Foundation. *
- * This program is distributed in the hope that it will be useful. *
- * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
- * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
- * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
- * TO BE LEGALLY INVALID. See the GNU General Public License for *
- * more details, a copy of which can be found in the file COPYING *
- * included with this package. *
- *******************************************************************/
- #include <linux/blkdev.h>
- #include <linux/pci.h>
- #include <linux/interrupt.h>
- #include <scsi/scsi.h>
- #include <scsi/scsi_device.h>
- #include <scsi/scsi_host.h>
- #include <scsi/scsi_transport_fc.h>
- #include "lpfc_hw.h"
- #include "lpfc_sli.h"
- #include "lpfc_disc.h"
- #include "lpfc_scsi.h"
- #include "lpfc.h"
- #include "lpfc_logmsg.h"
- #include "lpfc_crtn.h"
- /* Called to verify a rcv'ed ADISC was intended for us. */
- static int
- lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
- struct lpfc_name * nn, struct lpfc_name * pn)
- {
- /* Compare the ADISC rsp WWNN / WWPN matches our internal node
- * table entry for that node.
- */
- if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)) != 0)
- return (0);
- if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0)
- return (0);
- /* we match, return success */
- return (1);
- }
- int
- lpfc_check_sparm(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, struct serv_parm * sp,
- uint32_t class)
- {
- volatile struct serv_parm *hsp = &phba->fc_sparam;
- uint16_t hsp_value, ssp_value = 0;
- /*
- * The receive data field size and buffer-to-buffer receive data field
- * size entries are 16 bits but are represented as two 8-bit fields in
- * the driver data structure to account for rsvd bits and other control
- * bits. Reconstruct and compare the fields as a 16-bit values before
- * correcting the byte values.
- */
- if (sp->cls1.classValid) {
- hsp_value = (hsp->cls1.rcvDataSizeMsb << 8) |
- hsp->cls1.rcvDataSizeLsb;
- ssp_value = (sp->cls1.rcvDataSizeMsb << 8) |
- sp->cls1.rcvDataSizeLsb;
- if (ssp_value > hsp_value) {
- sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb;
- sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb;
- }
- } else if (class == CLASS1) {
- return 0;
- }
- if (sp->cls2.classValid) {
- hsp_value = (hsp->cls2.rcvDataSizeMsb << 8) |
- hsp->cls2.rcvDataSizeLsb;
- ssp_value = (sp->cls2.rcvDataSizeMsb << 8) |
- sp->cls2.rcvDataSizeLsb;
- if (ssp_value > hsp_value) {
- sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb;
- sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb;
- }
- } else if (class == CLASS2) {
- return 0;
- }
- if (sp->cls3.classValid) {
- hsp_value = (hsp->cls3.rcvDataSizeMsb << 8) |
- hsp->cls3.rcvDataSizeLsb;
- ssp_value = (sp->cls3.rcvDataSizeMsb << 8) |
- sp->cls3.rcvDataSizeLsb;
- if (ssp_value > hsp_value) {
- sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb;
- sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb;
- }
- } else if (class == CLASS3) {
- return 0;
- }
- /*
- * Preserve the upper four bits of the MSB from the PLOGI response.
- * These bits contain the Buffer-to-Buffer State Change Number
- * from the target and need to be passed to the FW.
- */
- hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb;
- ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb;
- if (ssp_value > hsp_value) {
- sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb;
- sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) |
- (hsp->cmn.bbRcvSizeMsb & 0x0F);
- }
- memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name));
- memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
- return 1;
- }
- static void *
- lpfc_check_elscmpl_iocb(struct lpfc_hba * phba,
- struct lpfc_iocbq *cmdiocb,
- struct lpfc_iocbq *rspiocb)
- {
- struct lpfc_dmabuf *pcmd, *prsp;
- uint32_t *lp;
- void *ptr = NULL;
- IOCB_t *irsp;
- irsp = &rspiocb->iocb;
- pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
- /* For lpfc_els_abort, context2 could be zero'ed to delay
- * freeing associated memory till after ABTS completes.
- */
- if (pcmd) {
- prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf,
- list);
- if (prsp) {
- lp = (uint32_t *) prsp->virt;
- ptr = (void *)((uint8_t *)lp + sizeof(uint32_t));
- }
- }
- else {
- /* Force ulpStatus error since we are returning NULL ptr */
- if (!(irsp->ulpStatus)) {
- irsp->ulpStatus = IOSTAT_LOCAL_REJECT;
- irsp->un.ulpWord[4] = IOERR_SLI_ABORTED;
- }
- ptr = NULL;
- }
- return (ptr);
- }
- /*
- * Free resources / clean up outstanding I/Os
- * associated with a LPFC_NODELIST entry. This
- * routine effectively results in a "software abort".
- */
- int
- lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
- int send_abts)
- {
- struct lpfc_sli *psli;
- struct lpfc_sli_ring *pring;
- struct lpfc_iocbq *iocb, *next_iocb;
- IOCB_t *icmd;
- int found = 0;
- /* Abort outstanding I/O on NPort <nlp_DID> */
- lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
- "%d:0201 Abort outstanding I/O on NPort x%x "
- "Data: x%x x%x x%x\n",
- phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
- ndlp->nlp_state, ndlp->nlp_rpi);
- psli = &phba->sli;
- pring = &psli->ring[LPFC_ELS_RING];
- /* First check the txq */
- do {
- found = 0;
- spin_lock_irq(phba->host->host_lock);
- list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
- /* Check to see if iocb matches the nport we are looking
- for */
- if ((lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))) {
- found = 1;
- /* It matches, so deque and call compl with an
- error */
- list_del(&iocb->list);
- pring->txq_cnt--;
- if (iocb->iocb_cmpl) {
- icmd = &iocb->iocb;
- icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
- icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
- spin_unlock_irq(phba->host->host_lock);
- (iocb->iocb_cmpl) (phba, iocb, iocb);
- spin_lock_irq(phba->host->host_lock);
- } else
- lpfc_sli_release_iocbq(phba, iocb);
- break;
- }
- }
- spin_unlock_irq(phba->host->host_lock);
- } while (found);
- /* Everything on txcmplq will be returned by firmware
- * with a no rpi / linkdown / abort error. For ring 0,
- * ELS discovery, we want to get rid of it right here.
- */
- /* Next check the txcmplq */
- do {
- found = 0;
- spin_lock_irq(phba->host->host_lock);
- list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq,
- list) {
- /* Check to see if iocb matches the nport we are looking
- for */
- if ((lpfc_check_sli_ndlp (phba, pring, iocb, ndlp))) {
- found = 1;
- /* It matches, so deque and call compl with an
- error */
- list_del(&iocb->list);
- pring->txcmplq_cnt--;
- icmd = &iocb->iocb;
- /* If the driver is completing an ELS
- * command early, flush it out of the firmware.
- */
- if (send_abts &&
- (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) &&
- (icmd->un.elsreq64.bdl.ulpIoTag32)) {
- lpfc_sli_issue_abort_iotag32(phba,
- pring, iocb);
- }
- if (iocb->iocb_cmpl) {
- icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
- icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
- spin_unlock_irq(phba->host->host_lock);
- (iocb->iocb_cmpl) (phba, iocb, iocb);
- spin_lock_irq(phba->host->host_lock);
- } else
- lpfc_sli_release_iocbq(phba, iocb);
- break;
- }
- }
- spin_unlock_irq(phba->host->host_lock);
- } while(found);
- /* If we are delaying issuing an ELS command, cancel it */
- if (ndlp->nlp_flag & NLP_DELAY_TMO) {
- ndlp->nlp_flag &= ~NLP_DELAY_TMO;
- del_timer_sync(&ndlp->nlp_delayfunc);
- if (!list_empty(&ndlp->els_retry_evt.evt_listp))
- list_del_init(&ndlp->els_retry_evt.evt_listp);
- }
- return (0);
- }
- static int
- lpfc_rcv_plogi(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp,
- struct lpfc_iocbq *cmdiocb)
- {
- struct lpfc_dmabuf *pcmd;
- uint32_t *lp;
- IOCB_t *icmd;
- struct serv_parm *sp;
- LPFC_MBOXQ_t *mbox;
- struct ls_rjt stat;
- int rc;
- memset(&stat, 0, sizeof (struct ls_rjt));
- if (phba->hba_state <= LPFC_FLOGI) {
- /* Before responding to PLOGI, check for pt2pt mode.
- * If we are pt2pt, with an outstanding FLOGI, abort
- * the FLOGI and resend it first.
- */
- if (phba->fc_flag & FC_PT2PT) {
- lpfc_els_abort_flogi(phba);
- if (!(phba->fc_flag & FC_PT2PT_PLOGI)) {
- /* If the other side is supposed to initiate
- * the PLOGI anyway, just ACC it now and
- * move on with discovery.
- */
- phba->fc_edtov = FF_DEF_EDTOV;
- phba->fc_ratov = FF_DEF_RATOV;
- /* Start discovery - this should just do
- CLEAR_LA */
- lpfc_disc_start(phba);
- }
- else {
- lpfc_initial_flogi(phba);
- }
- }
- else {
- stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
- stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
- lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb,
- ndlp);
- return 0;
- }
- }
- pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
- lp = (uint32_t *) pcmd->virt;
- sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
- if ((lpfc_check_sparm(phba, ndlp, sp, CLASS3) == 0)) {
- /* Reject this request because invalid parameters */
- stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
- stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
- lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
- return (0);
- }
- icmd = &cmdiocb->iocb;
- /* PLOGI chkparm OK */
- lpfc_printf_log(phba,
- KERN_INFO,
- LOG_ELS,
- "%d:0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
- phba->brd_no,
- ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag,
- ndlp->nlp_rpi);
- if ((phba->cfg_fcp_class == 2) &&
- (sp->cls2.classValid)) {
- ndlp->nlp_fcp_info |= CLASS2;
- } else {
- ndlp->nlp_fcp_info |= CLASS3;
- }
- ndlp->nlp_class_sup = 0;
- if (sp->cls1.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS1;
- if (sp->cls2.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS2;
- if (sp->cls3.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS3;
- if (sp->cls4.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS4;
- ndlp->nlp_maxframe =
- ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
- /* no need to reg_login if we are already in one of these states */
- switch(ndlp->nlp_state) {
- case NLP_STE_NPR_NODE:
- if (!(ndlp->nlp_flag & NLP_NPR_ADISC))
- break;
- case NLP_STE_REG_LOGIN_ISSUE:
- case NLP_STE_PRLI_ISSUE:
- case NLP_STE_UNMAPPED_NODE:
- case NLP_STE_MAPPED_NODE:
- lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0);
- return (1);
- }
- if ((phba->fc_flag & FC_PT2PT)
- && !(phba->fc_flag & FC_PT2PT_PLOGI)) {
- /* rcv'ed PLOGI decides what our NPortId will be */
- phba->fc_myDID = icmd->un.rcvels.parmRo;
- mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
- if (mbox == NULL)
- goto out;
- lpfc_config_link(phba, mbox);
- mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
- rc = lpfc_sli_issue_mbox
- (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
- if (rc == MBX_NOT_FINISHED) {
- mempool_free( mbox, phba->mbox_mem_pool);
- goto out;
- }
- lpfc_can_disctmo(phba);
- }
- mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
- if (mbox == NULL)
- goto out;
- if (lpfc_reg_login(phba, icmd->un.rcvels.remoteID,
- (uint8_t *) sp, mbox, 0)) {
- mempool_free( mbox, phba->mbox_mem_pool);
- goto out;
- }
- /* ACC PLOGI rsp command needs to execute first,
- * queue this mbox command to be processed later.
- */
- mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
- mbox->context2 = ndlp;
- ndlp->nlp_flag |= NLP_ACC_REGLOGIN;
- /* If there is an outstanding PLOGI issued, abort it before
- * sending ACC rsp to PLOGI recieved.
- */
- if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
- /* software abort outstanding PLOGI */
- lpfc_els_abort(phba, ndlp, 1);
- }
- ndlp->nlp_flag |= NLP_RCV_PLOGI;
- lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
- return (1);
- out:
- stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
- stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
- lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
- return (0);
- }
- static int
- lpfc_rcv_padisc(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp,
- struct lpfc_iocbq *cmdiocb)
- {
- struct lpfc_dmabuf *pcmd;
- struct serv_parm *sp;
- struct lpfc_name *pnn, *ppn;
- struct ls_rjt stat;
- ADISC *ap;
- IOCB_t *icmd;
- uint32_t *lp;
- uint32_t cmd;
- pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
- lp = (uint32_t *) pcmd->virt;
- cmd = *lp++;
- if (cmd == ELS_CMD_ADISC) {
- ap = (ADISC *) lp;
- pnn = (struct lpfc_name *) & ap->nodeName;
- ppn = (struct lpfc_name *) & ap->portName;
- } else {
- sp = (struct serv_parm *) lp;
- pnn = (struct lpfc_name *) & sp->nodeName;
- ppn = (struct lpfc_name *) & sp->portName;
- }
- icmd = &cmdiocb->iocb;
- if ((icmd->ulpStatus == 0) &&
- (lpfc_check_adisc(phba, ndlp, pnn, ppn))) {
- if (cmd == ELS_CMD_ADISC) {
- lpfc_els_rsp_adisc_acc(phba, cmdiocb, ndlp);
- }
- else {
- lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp,
- NULL, 0);
- }
- return (1);
- }
- /* Reject this request because invalid parameters */
- stat.un.b.lsRjtRsvd0 = 0;
- stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
- stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
- stat.un.b.vendorUnique = 0;
- lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
- ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
- /* 1 sec timeout */
- mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_DELAY_TMO;
- spin_unlock_irq(phba->host->host_lock);
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- return (0);
- }
- static int
- lpfc_rcv_logo(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp,
- struct lpfc_iocbq *cmdiocb)
- {
- /* Put ndlp on NPR list with 1 sec timeout for plogi, ACC logo */
- /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary
- * PLOGIs during LOGO storms from a device.
- */
- ndlp->nlp_flag |= NLP_LOGO_ACC;
- lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
- if (!(ndlp->nlp_type & NLP_FABRIC)) {
- /* Only try to re-login if this is NOT a Fabric Node */
- ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
- mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_DELAY_TMO;
- spin_unlock_irq(phba->host->host_lock);
- }
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- ndlp->nlp_flag &= ~NLP_NPR_ADISC;
- /* The driver has to wait until the ACC completes before it continues
- * processing the LOGO. The action will resume in
- * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an
- * unreg_login, the driver waits so the ACC does not get aborted.
- */
- return (0);
- }
- static void
- lpfc_rcv_prli(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp,
- struct lpfc_iocbq *cmdiocb)
- {
- struct lpfc_dmabuf *pcmd;
- uint32_t *lp;
- PRLI *npr;
- struct fc_rport *rport = ndlp->rport;
- u32 roles;
- pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
- lp = (uint32_t *) pcmd->virt;
- npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
- ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
- ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
- if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
- (npr->prliType == PRLI_FCP_TYPE)) {
- if (npr->initiatorFunc)
- ndlp->nlp_type |= NLP_FCP_INITIATOR;
- if (npr->targetFunc)
- ndlp->nlp_type |= NLP_FCP_TARGET;
- if (npr->Retry)
- ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
- }
- if (rport) {
- /* We need to update the rport role values */
- roles = FC_RPORT_ROLE_UNKNOWN;
- if (ndlp->nlp_type & NLP_FCP_INITIATOR)
- roles |= FC_RPORT_ROLE_FCP_INITIATOR;
- if (ndlp->nlp_type & NLP_FCP_TARGET)
- roles |= FC_RPORT_ROLE_FCP_TARGET;
- fc_remote_port_rolechg(rport, roles);
- }
- }
- static uint32_t
- lpfc_disc_set_adisc(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp)
- {
- /* Check config parameter use-adisc or FCP-2 */
- if ((phba->cfg_use_adisc == 0) &&
- !(phba->fc_flag & FC_RSCN_MODE)) {
- if (!(ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE))
- return (0);
- }
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_NPR_ADISC;
- spin_unlock_irq(phba->host->host_lock);
- return (1);
- }
- static uint32_t
- lpfc_disc_noop(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- /* This routine does nothing, just return the current state */
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_disc_illegal(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- lpfc_printf_log(phba,
- KERN_ERR,
- LOG_DISCOVERY,
- "%d:0253 Illegal State Transition: node x%x event x%x, "
- "state x%x Data: x%x x%x\n",
- phba->brd_no,
- ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
- ndlp->nlp_flag);
- return (ndlp->nlp_state);
- }
- /* Start of Discovery State Machine routines */
- static uint32_t
- lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
- ndlp->nlp_state = NLP_STE_UNUSED_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
- return (ndlp->nlp_state);
- }
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_rcv_els_unused_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- lpfc_issue_els_logo(phba, ndlp, 0);
- lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_unused_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_LOGO_ACC;
- spin_unlock_irq(phba->host->host_lock);
- lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
- lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_device_rm_unused_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_rcv_plogi_plogi_issue(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
- void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb = arg;
- struct lpfc_dmabuf *pcmd;
- struct serv_parm *sp;
- uint32_t *lp;
- struct ls_rjt stat;
- int port_cmp;
- pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
- lp = (uint32_t *) pcmd->virt;
- sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
- memset(&stat, 0, sizeof (struct ls_rjt));
- /* For a PLOGI, we only accept if our portname is less
- * than the remote portname.
- */
- phba->fc_stat.elsLogiCol++;
- port_cmp = memcmp(&phba->fc_portname, &sp->portName,
- sizeof (struct lpfc_name));
- if (port_cmp >= 0) {
- /* Reject this request because the remote node will accept
- ours */
- stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
- stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
- lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
- }
- else {
- lpfc_rcv_plogi(phba, ndlp, cmdiocb);
- } /* if our portname was less */
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* software abort outstanding PLOGI */
- lpfc_els_abort(phba, ndlp, 1);
- mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_DELAY_TMO;
- spin_unlock_irq(phba->host->host_lock);
- if (evt == NLP_EVT_RCV_LOGO) {
- lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
- }
- else {
- lpfc_issue_els_logo(phba, ndlp, 0);
- }
- /* Put ndlp in npr list set plogi timer for 1 sec */
- ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb, *rspiocb;
- struct lpfc_dmabuf *pcmd, *prsp;
- uint32_t *lp;
- IOCB_t *irsp;
- struct serv_parm *sp;
- LPFC_MBOXQ_t *mbox;
- cmdiocb = (struct lpfc_iocbq *) arg;
- rspiocb = cmdiocb->context_un.rsp_iocb;
- if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
- return (ndlp->nlp_state);
- }
- irsp = &rspiocb->iocb;
- if (irsp->ulpStatus)
- goto out;
- pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
- prsp = list_get_first(&pcmd->list,
- struct lpfc_dmabuf,
- list);
- lp = (uint32_t *) prsp->virt;
- sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
- if (!lpfc_check_sparm(phba, ndlp, sp, CLASS3))
- goto out;
- /* PLOGI chkparm OK */
- lpfc_printf_log(phba,
- KERN_INFO,
- LOG_ELS,
- "%d:0121 PLOGI chkparm OK "
- "Data: x%x x%x x%x x%x\n",
- phba->brd_no,
- ndlp->nlp_DID, ndlp->nlp_state,
- ndlp->nlp_flag, ndlp->nlp_rpi);
- if ((phba->cfg_fcp_class == 2) &&
- (sp->cls2.classValid)) {
- ndlp->nlp_fcp_info |= CLASS2;
- } else {
- ndlp->nlp_fcp_info |= CLASS3;
- }
- ndlp->nlp_class_sup = 0;
- if (sp->cls1.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS1;
- if (sp->cls2.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS2;
- if (sp->cls3.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS3;
- if (sp->cls4.classValid)
- ndlp->nlp_class_sup |= FC_COS_CLASS4;
- ndlp->nlp_maxframe =
- ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
- sp->cmn.bbRcvSizeLsb;
- if (!(mbox = mempool_alloc(phba->mbox_mem_pool,
- GFP_KERNEL)))
- goto out;
- lpfc_unreg_rpi(phba, ndlp);
- if (lpfc_reg_login
- (phba, irsp->un.elsreq64.remoteID,
- (uint8_t *) sp, mbox, 0) == 0) {
- /* set_slim mailbox command needs to
- * execute first, queue this command to
- * be processed later.
- */
- switch(ndlp->nlp_DID) {
- case NameServer_DID:
- mbox->mbox_cmpl =
- lpfc_mbx_cmpl_ns_reg_login;
- break;
- case FDMI_DID:
- mbox->mbox_cmpl =
- lpfc_mbx_cmpl_fdmi_reg_login;
- break;
- default:
- mbox->mbox_cmpl =
- lpfc_mbx_cmpl_reg_login;
- }
- mbox->context2 = ndlp;
- if (lpfc_sli_issue_mbox(phba, mbox,
- (MBX_NOWAIT | MBX_STOP_IOCB))
- != MBX_NOT_FINISHED) {
- ndlp->nlp_state =
- NLP_STE_REG_LOGIN_ISSUE;
- lpfc_nlp_list(phba, ndlp,
- NLP_REGLOGIN_LIST);
- return (ndlp->nlp_state);
- }
- mempool_free(mbox, phba->mbox_mem_pool);
- } else {
- mempool_free(mbox, phba->mbox_mem_pool);
- }
- out:
- /* Free this node since the driver cannot login or has the wrong
- sparm */
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- /* software abort outstanding PLOGI */
- lpfc_els_abort(phba, ndlp, 1);
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_device_recov_plogi_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- /* software abort outstanding PLOGI */
- lpfc_els_abort(phba, ndlp, 1);
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- spin_unlock_irq(phba->host->host_lock);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- /* software abort outstanding ADISC */
- lpfc_els_abort(phba, ndlp, 1);
- cmdiocb = (struct lpfc_iocbq *) arg;
- if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
- return (ndlp->nlp_state);
- }
- ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
- lpfc_issue_els_plogi(phba, ndlp, 0);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prli_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* software abort outstanding ADISC */
- lpfc_els_abort(phba, ndlp, 0);
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_padisc_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_padisc(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prlo_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* Treat like rcv logo */
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb, *rspiocb;
- IOCB_t *irsp;
- ADISC *ap;
- cmdiocb = (struct lpfc_iocbq *) arg;
- rspiocb = cmdiocb->context_un.rsp_iocb;
- ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
- irsp = &rspiocb->iocb;
- if ((irsp->ulpStatus) ||
- (!lpfc_check_adisc(phba, ndlp, &ap->nodeName, &ap->portName))) {
- ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
- /* 1 sec timeout */
- mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_DELAY_TMO;
- spin_unlock_irq(phba->host->host_lock);
- memset(&ndlp->nlp_nodename, 0, sizeof (struct lpfc_name));
- memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name));
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- lpfc_unreg_rpi(phba, ndlp);
- return (ndlp->nlp_state);
- }
- if (ndlp->nlp_type & NLP_FCP_TARGET) {
- ndlp->nlp_state = NLP_STE_MAPPED_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
- } else {
- ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
- }
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- /* software abort outstanding ADISC */
- lpfc_els_abort(phba, ndlp, 1);
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_device_recov_adisc_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- /* software abort outstanding ADISC */
- lpfc_els_abort(phba, ndlp, 1);
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- spin_unlock_irq(phba->host->host_lock);
- lpfc_disc_set_adisc(phba, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_plogi_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_plogi(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prli_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_padisc_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_padisc(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prlo_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp,
- void *arg, uint32_t evt)
- {
- LPFC_MBOXQ_t *pmb;
- MAILBOX_t *mb;
- uint32_t did;
- pmb = (LPFC_MBOXQ_t *) arg;
- mb = &pmb->mb;
- did = mb->un.varWords[1];
- if (mb->mbxStatus) {
- /* RegLogin failed */
- lpfc_printf_log(phba,
- KERN_ERR,
- LOG_DISCOVERY,
- "%d:0246 RegLogin failed Data: x%x x%x x%x\n",
- phba->brd_no,
- did, mb->mbxStatus, phba->hba_state);
- mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag |= NLP_DELAY_TMO;
- spin_unlock_irq(phba->host->host_lock);
- lpfc_issue_els_logo(phba, ndlp, 0);
- /* Put ndlp in npr list set plogi timer for 1 sec */
- ndlp->nlp_last_elscmd = (unsigned long)ELS_CMD_PLOGI;
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- return (ndlp->nlp_state);
- }
- ndlp->nlp_rpi = mb->un.varWords[0];
- /* Only if we are not a fabric nport do we issue PRLI */
- if (!(ndlp->nlp_type & NLP_FABRIC)) {
- ndlp->nlp_state = NLP_STE_PRLI_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
- lpfc_issue_els_prli(phba, ndlp, 0);
- } else {
- ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
- }
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- spin_unlock_irq(phba->host->host_lock);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_plogi_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_plogi(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prli_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* Software abort outstanding PRLI before sending acc */
- lpfc_els_abort(phba, ndlp, 1);
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_padisc_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_padisc(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- /* This routine is envoked when we rcv a PRLO request from a nport
- * we are logged into. We should send back a PRLO rsp setting the
- * appropriate bits.
- * NEXT STATE = PRLI_ISSUE
- */
- static uint32_t
- lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb, *rspiocb;
- IOCB_t *irsp;
- PRLI *npr;
- cmdiocb = (struct lpfc_iocbq *) arg;
- rspiocb = cmdiocb->context_un.rsp_iocb;
- npr = (PRLI *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
- irsp = &rspiocb->iocb;
- if (irsp->ulpStatus) {
- ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
- return (ndlp->nlp_state);
- }
- /* Check out PRLI rsp */
- ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
- ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
- if ((npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
- (npr->prliType == PRLI_FCP_TYPE)) {
- if (npr->initiatorFunc)
- ndlp->nlp_type |= NLP_FCP_INITIATOR;
- if (npr->targetFunc)
- ndlp->nlp_type |= NLP_FCP_TARGET;
- if (npr->Retry)
- ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
- }
- ndlp->nlp_state = NLP_STE_MAPPED_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
- return (ndlp->nlp_state);
- }
- /*! lpfc_device_rm_prli_issue
- *
- * \pre
- * \post
- * \param phba
- * \param ndlp
- * \param arg
- * \param evt
- * \return uint32_t
- *
- * \b Description:
- * This routine is envoked when we a request to remove a nport we are in the
- * process of PRLIing. We should software abort outstanding prli, unreg
- * login, send a logout. We will change node state to UNUSED_NODE, put it
- * on plogi list so it can be freed when LOGO completes.
- *
- */
- static uint32_t
- lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- /* software abort outstanding PRLI */
- lpfc_els_abort(phba, ndlp, 1);
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- /*! lpfc_device_recov_prli_issue
- *
- * \pre
- * \post
- * \param phba
- * \param ndlp
- * \param arg
- * \param evt
- * \return uint32_t
- *
- * \b Description:
- * The routine is envoked when the state of a device is unknown, like
- * during a link down. We should remove the nodelist entry from the
- * unmapped list, issue a UNREG_LOGIN, do a software abort of the
- * outstanding PRLI command, then free the node entry.
- */
- static uint32_t
- lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- /* software abort outstanding PRLI */
- lpfc_els_abort(phba, ndlp, 1);
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- spin_unlock_irq(phba->host->host_lock);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_plogi_unmap_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_plogi(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prli_unmap_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_prli(phba, ndlp, cmdiocb);
- lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_padisc_unmap_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_padisc(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* Treat like rcv logo */
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- lpfc_disc_set_adisc(phba, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_plogi_mapped_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_plogi(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prli_mapped_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_prli_acc(phba, cmdiocb, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_padisc_mapped_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_padisc(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* flush the target */
- spin_lock_irq(phba->host->host_lock);
- lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
- ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT);
- spin_unlock_irq(phba->host->host_lock);
- /* Treat like rcv logo */
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- ndlp->nlp_state = NLP_STE_NPR_NODE;
- lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- spin_unlock_irq(phba->host->host_lock);
- lpfc_disc_set_adisc(phba, ndlp);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- /* Ignore PLOGI if we have an outstanding LOGO */
- if (ndlp->nlp_flag & NLP_LOGO_SND) {
- return (ndlp->nlp_state);
- }
- if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC);
- spin_unlock_irq(phba->host->host_lock);
- return (ndlp->nlp_state);
- }
- /* send PLOGI immediately, move to PLOGI issue state */
- if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
- ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
- lpfc_issue_els_plogi(phba, ndlp, 0);
- }
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- struct ls_rjt stat;
- cmdiocb = (struct lpfc_iocbq *) arg;
- memset(&stat, 0, sizeof (struct ls_rjt));
- stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
- stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
- lpfc_els_rsp_reject(phba, stat.un.lsRjtError, cmdiocb, ndlp);
- if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
- if (ndlp->nlp_flag & NLP_NPR_ADISC) {
- ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
- lpfc_issue_els_adisc(phba, ndlp, 0);
- } else {
- ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
- lpfc_issue_els_plogi(phba, ndlp, 0);
- }
- }
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_logo_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_logo(phba, ndlp, cmdiocb);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_rcv_padisc(phba, ndlp, cmdiocb);
- if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
- if (ndlp->nlp_flag & NLP_NPR_ADISC) {
- ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
- lpfc_issue_els_adisc(phba, ndlp, 0);
- } else {
- ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
- lpfc_issue_els_plogi(phba, ndlp, 0);
- }
- }
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_rcv_prlo_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- struct lpfc_iocbq *cmdiocb;
- cmdiocb = (struct lpfc_iocbq *) arg;
- lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
- if (ndlp->nlp_flag & NLP_DELAY_TMO) {
- if (ndlp->nlp_last_elscmd == (unsigned long)ELS_CMD_PLOGI) {
- return (ndlp->nlp_state);
- } else {
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_DELAY_TMO;
- spin_unlock_irq(phba->host->host_lock);
- del_timer_sync(&ndlp->nlp_delayfunc);
- if (!list_empty(&ndlp->els_retry_evt.evt_listp))
- list_del_init(&ndlp->els_retry_evt.evt_listp);
- }
- }
- ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
- lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
- lpfc_issue_els_plogi(phba, ndlp, 0);
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_logo_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- lpfc_unreg_rpi(phba, ndlp);
- /* This routine does nothing, just return the current state */
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- LPFC_MBOXQ_t *pmb;
- MAILBOX_t *mb;
- pmb = (LPFC_MBOXQ_t *) arg;
- mb = &pmb->mb;
- ndlp->nlp_rpi = mb->un.varWords[0];
- return (ndlp->nlp_state);
- }
- static uint32_t
- lpfc_device_rm_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
- return (NLP_STE_FREED_NODE);
- }
- static uint32_t
- lpfc_device_recov_npr_node(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg,
- uint32_t evt)
- {
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
- spin_unlock_irq(phba->host->host_lock);
- return (ndlp->nlp_state);
- }
- /* This next section defines the NPort Discovery State Machine */
- /* There are 4 different double linked lists nodelist entries can reside on.
- * The plogi list and adisc list are used when Link Up discovery or RSCN
- * processing is needed. Each list holds the nodes that we will send PLOGI
- * or ADISC on. These lists will keep track of what nodes will be effected
- * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up).
- * The unmapped_list will contain all nodes that we have successfully logged
- * into at the Fibre Channel level. The mapped_list will contain all nodes
- * that are mapped FCP targets.
- */
- /*
- * The bind list is a list of undiscovered (potentially non-existent) nodes
- * that we have saved binding information on. This information is used when
- * nodes transition from the unmapped to the mapped list.
- */
- /* For UNUSED_NODE state, the node has just been allocated .
- * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on
- * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list
- * and put on the unmapped list. For ADISC processing, the node is taken off
- * the ADISC list and placed on either the mapped or unmapped list (depending
- * on its previous state). Once on the unmapped list, a PRLI is issued and the
- * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is
- * changed to UNMAPPED_NODE. If the completion indicates a mapped
- * node, the node is taken off the unmapped list. The binding list is checked
- * for a valid binding, or a binding is automatically assigned. If binding
- * assignment is unsuccessful, the node is left on the unmapped list. If
- * binding assignment is successful, the associated binding list entry (if
- * any) is removed, and the node is placed on the mapped list.
- */
- /*
- * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped
- * lists will receive a DEVICE_RECOVERY event. If the linkdown or nodev timers
- * expire, all effected nodes will receive a DEVICE_RM event.
- */
- /*
- * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists
- * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap
- * check, additional nodes may be added or removed (via DEVICE_RM) to / from
- * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated,
- * we will first process the ADISC list. 32 entries are processed initially and
- * ADISC is initited for each one. Completions / Events for each node are
- * funnelled thru the state machine. As each node finishes ADISC processing, it
- * starts ADISC for any nodes waiting for ADISC processing. If no nodes are
- * waiting, and the ADISC list count is identically 0, then we are done. For
- * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we
- * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI
- * list. 32 entries are processed initially and PLOGI is initited for each one.
- * Completions / Events for each node are funnelled thru the state machine. As
- * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting
- * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is
- * indentically 0, then we are done. We have now completed discovery / RSCN
- * handling. Upon completion, ALL nodes should be on either the mapped or
- * unmapped lists.
- */
- static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
- (struct lpfc_hba *, struct lpfc_nodelist *, void *, uint32_t) = {
- /* Action routine Event Current State */
- lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */
- lpfc_rcv_els_unused_node, /* RCV_PRLI */
- lpfc_rcv_logo_unused_node, /* RCV_LOGO */
- lpfc_rcv_els_unused_node, /* RCV_ADISC */
- lpfc_rcv_els_unused_node, /* RCV_PDISC */
- lpfc_rcv_els_unused_node, /* RCV_PRLO */
- lpfc_disc_illegal, /* CMPL_PLOGI */
- lpfc_disc_illegal, /* CMPL_PRLI */
- lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */
- lpfc_disc_illegal, /* CMPL_ADISC */
- lpfc_disc_illegal, /* CMPL_REG_LOGIN */
- lpfc_device_rm_unused_node, /* DEVICE_RM */
- lpfc_disc_illegal, /* DEVICE_RECOVERY */
- lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */
- lpfc_rcv_els_plogi_issue, /* RCV_PRLI */
- lpfc_rcv_els_plogi_issue, /* RCV_LOGO */
- lpfc_rcv_els_plogi_issue, /* RCV_ADISC */
- lpfc_rcv_els_plogi_issue, /* RCV_PDISC */
- lpfc_rcv_els_plogi_issue, /* RCV_PRLO */
- lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */
- lpfc_disc_illegal, /* CMPL_PRLI */
- lpfc_disc_illegal, /* CMPL_LOGO */
- lpfc_disc_illegal, /* CMPL_ADISC */
- lpfc_disc_illegal, /* CMPL_REG_LOGIN */
- lpfc_device_rm_plogi_issue, /* DEVICE_RM */
- lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */
- lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */
- lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */
- lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */
- lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */
- lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */
- lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */
- lpfc_disc_illegal, /* CMPL_PLOGI */
- lpfc_disc_illegal, /* CMPL_PRLI */
- lpfc_disc_illegal, /* CMPL_LOGO */
- lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */
- lpfc_disc_illegal, /* CMPL_REG_LOGIN */
- lpfc_device_rm_adisc_issue, /* DEVICE_RM */
- lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */
- lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */
- lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */
- lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */
- lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */
- lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */
- lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */
- lpfc_disc_illegal, /* CMPL_PLOGI */
- lpfc_disc_illegal, /* CMPL_PRLI */
- lpfc_disc_illegal, /* CMPL_LOGO */
- lpfc_disc_illegal, /* CMPL_ADISC */
- lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */
- lpfc_device_rm_reglogin_issue, /* DEVICE_RM */
- lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */
- lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */
- lpfc_rcv_prli_prli_issue, /* RCV_PRLI */
- lpfc_rcv_logo_prli_issue, /* RCV_LOGO */
- lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */
- lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */
- lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */
- lpfc_disc_illegal, /* CMPL_PLOGI */
- lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */
- lpfc_disc_illegal, /* CMPL_LOGO */
- lpfc_disc_illegal, /* CMPL_ADISC */
- lpfc_disc_illegal, /* CMPL_REG_LOGIN */
- lpfc_device_rm_prli_issue, /* DEVICE_RM */
- lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */
- lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */
- lpfc_rcv_prli_unmap_node, /* RCV_PRLI */
- lpfc_rcv_logo_unmap_node, /* RCV_LOGO */
- lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */
- lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */
- lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */
- lpfc_disc_illegal, /* CMPL_PLOGI */
- lpfc_disc_illegal, /* CMPL_PRLI */
- lpfc_disc_illegal, /* CMPL_LOGO */
- lpfc_disc_illegal, /* CMPL_ADISC */
- lpfc_disc_illegal, /* CMPL_REG_LOGIN */
- lpfc_disc_illegal, /* DEVICE_RM */
- lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */
- lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */
- lpfc_rcv_prli_mapped_node, /* RCV_PRLI */
- lpfc_rcv_logo_mapped_node, /* RCV_LOGO */
- lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */
- lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */
- lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */
- lpfc_disc_illegal, /* CMPL_PLOGI */
- lpfc_disc_illegal, /* CMPL_PRLI */
- lpfc_disc_illegal, /* CMPL_LOGO */
- lpfc_disc_illegal, /* CMPL_ADISC */
- lpfc_disc_illegal, /* CMPL_REG_LOGIN */
- lpfc_disc_illegal, /* DEVICE_RM */
- lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */
- lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */
- lpfc_rcv_prli_npr_node, /* RCV_PRLI */
- lpfc_rcv_logo_npr_node, /* RCV_LOGO */
- lpfc_rcv_padisc_npr_node, /* RCV_ADISC */
- lpfc_rcv_padisc_npr_node, /* RCV_PDISC */
- lpfc_rcv_prlo_npr_node, /* RCV_PRLO */
- lpfc_disc_noop, /* CMPL_PLOGI */
- lpfc_disc_noop, /* CMPL_PRLI */
- lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */
- lpfc_disc_noop, /* CMPL_ADISC */
- lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */
- lpfc_device_rm_npr_node, /* DEVICE_RM */
- lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */
- };
- int
- lpfc_disc_state_machine(struct lpfc_hba * phba,
- struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
- {
- uint32_t cur_state, rc;
- uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *,
- uint32_t);
- ndlp->nlp_disc_refcnt++;
- cur_state = ndlp->nlp_state;
- /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
- lpfc_printf_log(phba,
- KERN_INFO,
- LOG_DISCOVERY,
- "%d:0211 DSM in event x%x on NPort x%x in state %d "
- "Data: x%x\n",
- phba->brd_no,
- evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag);
- func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
- rc = (func) (phba, ndlp, arg, evt);
- /* DSM out state <rc> on NPort <nlp_DID> */
- lpfc_printf_log(phba,
- KERN_INFO,
- LOG_DISCOVERY,
- "%d:0212 DSM out state %d on NPort x%x Data: x%x\n",
- phba->brd_no,
- rc, ndlp->nlp_DID, ndlp->nlp_flag);
- ndlp->nlp_disc_refcnt--;
- /* Check to see if ndlp removal is deferred */
- if ((ndlp->nlp_disc_refcnt == 0)
- && (ndlp->nlp_flag & NLP_DELAY_REMOVE)) {
- spin_lock_irq(phba->host->host_lock);
- ndlp->nlp_flag &= ~NLP_DELAY_REMOVE;
- spin_unlock_irq(phba->host->host_lock);
- lpfc_nlp_remove(phba, ndlp);
- return (NLP_STE_FREED_NODE);
- }
- if (rc == NLP_STE_FREED_NODE)
- return (NLP_STE_FREED_NODE);
- ndlp->nlp_state = rc;
- return (rc);
- }
|