lpfc_nportdisc.c 56.9 KB
Newer Older
已提交
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 11 12 13 14 15 16 17 18 19
 * 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.                                     *
已提交
20 21 22 23 24 25
 *******************************************************************/

#include <linux/blkdev.h>
#include <linux/pci.h>
#include <linux/interrupt.h>

26
#include <scsi/scsi.h>
已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#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)
49
		return 0;
已提交
50 51

	if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)) != 0)
52
		return 0;
已提交
53 54

	/* we match, return success */
55
	return 1;
已提交
56 57 58 59 60 61 62 63
}

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;
64 65 66 67 68 69 70 71 72
	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.
	 */
已提交
73
	if (sp->cls1.classValid) {
74 75 76 77 78
		hsp_value = (hsp->cls1.rcvDataSizeMsb << 8) |
				hsp->cls1.rcvDataSizeLsb;
		ssp_value = (sp->cls1.rcvDataSizeMsb << 8) |
				sp->cls1.rcvDataSizeLsb;
		if (ssp_value > hsp_value) {
已提交
79
			sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb;
80 81
			sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb;
		}
已提交
82
	} else if (class == CLASS1) {
83
		return 0;
已提交
84 85 86
	}

	if (sp->cls2.classValid) {
87 88 89 90 91
		hsp_value = (hsp->cls2.rcvDataSizeMsb << 8) |
				hsp->cls2.rcvDataSizeLsb;
		ssp_value = (sp->cls2.rcvDataSizeMsb << 8) |
				sp->cls2.rcvDataSizeLsb;
		if (ssp_value > hsp_value) {
已提交
92
			sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb;
93 94
			sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb;
		}
已提交
95
	} else if (class == CLASS2) {
96
		return 0;
已提交
97 98 99
	}

	if (sp->cls3.classValid) {
100 101 102 103 104
		hsp_value = (hsp->cls3.rcvDataSizeMsb << 8) |
				hsp->cls3.rcvDataSizeLsb;
		ssp_value = (sp->cls3.rcvDataSizeMsb << 8) |
				sp->cls3.rcvDataSizeLsb;
		if (ssp_value > hsp_value) {
已提交
105
			sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb;
106 107
			sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb;
		}
已提交
108
	} else if (class == CLASS3) {
109
		return 0;
已提交
110 111
	}

112 113 114 115 116 117 118 119
	/*
	 * 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) {
已提交
120
		sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb;
121 122 123
		sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) |
				       (hsp->cmn.bbRcvSizeMsb & 0x0F);
	}
已提交
124 125 126

	memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name));
	memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
127
	return 1;
已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
}

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));
		}
153
	} else {
已提交
154 155 156 157 158 159 160
		/* 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;
	}
161
	return ptr;
已提交
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
}


/*
 * 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,
182
			"%d:0205 Abort outstanding I/O on NPort x%x "
已提交
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
			"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);
210 211
				} else
					lpfc_sli_release_iocbq(phba, iocb);
已提交
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
				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);
253 254
				} else
					lpfc_sli_release_iocbq(phba, iocb);
已提交
255 256 257 258 259 260 261
				break;
			}
		}
		spin_unlock_irq(phba->host->host_lock);
	} while(found);

	/* If we are delaying issuing an ELS command, cancel it */
262 263
	if (ndlp->nlp_flag & NLP_DELAY_TMO)
		lpfc_cancel_retry_delay_tmo(phba, ndlp);
264
	return 0;
已提交
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
}

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);
298
			} else {
已提交
299 300
				lpfc_initial_flogi(phba);
			}
301
		} else {
已提交
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
			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);
317
		return 0;
已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
	}
	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 */
349
	switch (ndlp->nlp_state) {
已提交
350 351 352 353 354 355 356 357
	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);
358
		return 1;
已提交
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
	}

	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;
394
	ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
已提交
395

J
James Smart 已提交
396 397 398 399 400 401 402 403 404 405 406 407 408 409
	/*
	 * If there is an outstanding PLOGI issued, abort it before
	 * sending ACC rsp for received PLOGI. If pending plogi
	 * is not canceled here, the plogi will be rejected by
	 * remote port and will be retried. On a configuration with
	 * single discovery thread, this will cause a huge delay in
	 * discovery. Also this will cause multiple state machines
	 * running in parallel for this node.
	 */
	if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
		/* software abort outstanding PLOGI */
		lpfc_els_abort(phba, ndlp, 1);
	}

已提交
410
	lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
411
	return 1;
已提交
412 413 414 415 416

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);
417
	return 0;
已提交
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
}

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);
453
		} else {
已提交
454 455 456
			lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp,
				NULL, 0);
		}
457
		return 1;
已提交
458 459 460 461 462 463 464 465 466 467 468 469 470 471
	}
	/* 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);

	/* 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);
472 473
	ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
	ndlp->nlp_prev_state = ndlp->nlp_state;
已提交
474 475
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
476
	return 0;
已提交
477 478 479 480 481
}

static int
lpfc_rcv_logo(struct lpfc_hba * phba,
		      struct lpfc_nodelist * ndlp,
482 483
		      struct lpfc_iocbq *cmdiocb,
		      uint32_t els_cmd)
已提交
484 485 486 487 488 489
{
	/* 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;
490 491 492 493
	if (els_cmd == ELS_CMD_PRLO)
		lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
	else
		lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
已提交
494

495 496
	if (!(ndlp->nlp_type & NLP_FABRIC) ||
		(ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
已提交
497 498 499 500 501 502
		/* Only try to re-login if this is NOT a Fabric Node */
		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);

503 504
		ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
		ndlp->nlp_prev_state = ndlp->nlp_state;
505 506 507
		ndlp->nlp_state = NLP_STE_NPR_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
	} else {
508
		ndlp->nlp_prev_state = ndlp->nlp_state;
509 510 511
		ndlp->nlp_state = NLP_STE_UNUSED_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
	}
已提交
512

513
	spin_lock_irq(phba->host->host_lock);
已提交
514
	ndlp->nlp_flag &= ~NLP_NPR_ADISC;
515
	spin_unlock_irq(phba->host->host_lock);
已提交
516 517 518 519 520
	/* 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.
	 */
521
	return 0;
已提交
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
}

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))
569
			return 0;
已提交
570 571 572 573
	}
	spin_lock_irq(phba->host->host_lock);
	ndlp->nlp_flag |= NLP_NPR_ADISC;
	spin_unlock_irq(phba->host->host_lock);
574
	return 1;
已提交
575 576 577 578 579 580 581 582 583 584 585 586 587 588
}

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);
589
	return ndlp->nlp_state;
已提交
590 591 592 593 594 595 596 597 598 599 600 601 602
}

/* 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)) {
603
		ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
已提交
604 605
		ndlp->nlp_state = NLP_STE_UNUSED_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
606
		return ndlp->nlp_state;
已提交
607 608
	}
	lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
609
	return NLP_STE_FREED_NODE;
已提交
610 611 612 613 614 615 616 617
}

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);
618
	return ndlp->nlp_state;
已提交
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
}

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);

635
	return ndlp->nlp_state;
已提交
636 637 638 639 640 641 642
}

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);
643
	return NLP_STE_FREED_NODE;
已提交
644 645 646 647 648 649 650
}

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);
651
	return NLP_STE_FREED_NODE;
已提交
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
}

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);
684
	} else {
已提交
685 686 687
		lpfc_rcv_plogi(phba, ndlp, cmdiocb);
	} /* if our portname was less */

688 689 690 691 692 693 694 695 696 697 698 699 700 701
	return ndlp->nlp_state;
}

static uint32_t
lpfc_rcv_logo_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);

702
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
703
	return ndlp->nlp_state;
已提交
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
}

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);

	if (evt == NLP_EVT_RCV_LOGO) {
		lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
719
	} else {
已提交
720 721 722 723
		lpfc_issue_els_logo(phba, ndlp, 0);
	}

	/* Put ndlp in npr list set plogi timer for 1 sec */
724 725 726 727 728 729
	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_last_elscmd = ELS_CMD_PLOGI;
	ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
已提交
730 731 732
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);

733
	return ndlp->nlp_state;
已提交
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
}

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) {
752
		/* Recovery from PLOGI collision logic */
753
		return ndlp->nlp_state;
已提交
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
	}

	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) {
809
		switch (ndlp->nlp_DID) {
已提交
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
		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);
830
			return ndlp->nlp_state;
已提交
831 832 833 834 835 836 837 838 839 840 841
		}
		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);
842
	return NLP_STE_FREED_NODE;
已提交
843 844 845 846 847 848
}

static uint32_t
lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
			   struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
{
849 850 851 852 853 854 855
	if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
		ndlp->nlp_flag |= NLP_NODEV_REMOVE;
		return ndlp->nlp_state;
	}
	else {
		/* software abort outstanding PLOGI */
		lpfc_els_abort(phba, ndlp, 1);
已提交
856

857 858 859
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
已提交
860 861 862 863 864 865 866 867 868 869
}

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);

870
	ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
已提交
871 872 873
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
	spin_lock_irq(phba->host->host_lock);
874
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
已提交
875 876
	spin_unlock_irq(phba->host->host_lock);

877
	return ndlp->nlp_state;
已提交
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892
}

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)) {
893
		return ndlp->nlp_state;
已提交
894
	}
895
	ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
已提交
896 897
	ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
	lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
898
	lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
已提交
899

900
	return ndlp->nlp_state;
已提交
901 902 903 904 905 906 907 908 909 910 911 912
}

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);
913
	return ndlp->nlp_state;
已提交
914 915 916 917 918 919 920 921 922 923 924 925 926 927
}

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);

928
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
929
	return ndlp->nlp_state;
已提交
930 931 932 933 934 935 936 937 938 939 940 941
}

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);
942
	return ndlp->nlp_state;
已提交
943 944 945 946 947 948 949 950 951 952 953 954
}

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 */
955
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
956
	return ndlp->nlp_state;
已提交
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
}

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))) {
		/* 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);
981
		ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
已提交
982 983 984 985

		memset(&ndlp->nlp_nodename, 0, sizeof (struct lpfc_name));
		memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name));

986
		ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
已提交
987 988 989
		ndlp->nlp_state = NLP_STE_NPR_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
		lpfc_unreg_rpi(phba, ndlp);
990
		return ndlp->nlp_state;
已提交
991
	}
992

993
	if (ndlp->nlp_type & NLP_FCP_TARGET) {
994
		ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
995 996 997
		ndlp->nlp_state = NLP_STE_MAPPED_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
	} else {
998
		ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
999 1000 1001
		ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
	}
1002
	return ndlp->nlp_state;
已提交
1003 1004 1005 1006 1007 1008 1009
}

static uint32_t
lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
			    struct lpfc_nodelist * ndlp, void *arg,
			    uint32_t evt)
{
1010 1011 1012 1013 1014 1015 1016
	if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
		ndlp->nlp_flag |= NLP_NODEV_REMOVE;
		return ndlp->nlp_state;
	}
	else {
		/* software abort outstanding ADISC */
		lpfc_els_abort(phba, ndlp, 1);
已提交
1017

1018 1019 1020
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
已提交
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
}

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);

1031
	ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
已提交
1032 1033 1034
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
	spin_lock_irq(phba->host->host_lock);
1035
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1036
	ndlp->nlp_flag |= NLP_NPR_ADISC;
已提交
1037 1038
	spin_unlock_irq(phba->host->host_lock);

1039
	return ndlp->nlp_state;
已提交
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
}

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);
1052
	return ndlp->nlp_state;
已提交
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
}

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);
1065
	return ndlp->nlp_state;
已提交
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
}

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;

1077
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1078
	return ndlp->nlp_state;
已提交
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
}

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);
1091
	return ndlp->nlp_state;
已提交
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
}

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;
1102
	lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
1103
	return ndlp->nlp_state;
已提交
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
}

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);

1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
		/*
		 * If RegLogin failed due to lack of HBA resources do not
		 * retry discovery.
		 */
		if (mb->mbxStatus == MBXERR_RPI_FULL) {
			ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
			ndlp->nlp_state = NLP_STE_UNUSED_NODE;
			lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
			return ndlp->nlp_state;
		}

1138
		/* Put ndlp in npr list set plogi timer for 1 sec */
已提交
1139 1140 1141 1142
		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);
1143
		ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
已提交
1144 1145

		lpfc_issue_els_logo(phba, ndlp, 0);
1146
		ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
已提交
1147 1148
		ndlp->nlp_state = NLP_STE_NPR_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1149
		return ndlp->nlp_state;
已提交
1150 1151 1152 1153 1154 1155
	}

	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)) {
1156
		ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
已提交
1157 1158 1159 1160
		ndlp->nlp_state = NLP_STE_PRLI_ISSUE;
		lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
		lpfc_issue_els_prli(phba, ndlp, 0);
	} else {
1161
		ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
已提交
1162 1163 1164
		ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
	}
1165
	return ndlp->nlp_state;
已提交
1166 1167 1168 1169 1170 1171 1172
}

static uint32_t
lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
			      struct lpfc_nodelist * ndlp, void *arg,
			      uint32_t evt)
{
1173 1174 1175 1176 1177 1178 1179 1180
	if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
		ndlp->nlp_flag |= NLP_NODEV_REMOVE;
		return ndlp->nlp_state;
	}
	else {
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
已提交
1181 1182 1183 1184 1185 1186 1187
}

static uint32_t
lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
			       struct lpfc_nodelist * ndlp, void *arg,
			       uint32_t evt)
{
1188
	ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
已提交
1189 1190 1191
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
	spin_lock_irq(phba->host->host_lock);
1192
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
已提交
1193
	spin_unlock_irq(phba->host->host_lock);
1194
	return ndlp->nlp_state;
已提交
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205
}

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);
1206
	return ndlp->nlp_state;
已提交
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217
}

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);
1218
	return ndlp->nlp_state;
已提交
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
}

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);

1232
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1233
	return ndlp->nlp_state;
已提交
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
}

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);
1245
	return ndlp->nlp_state;
已提交
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
}

/* 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;
1260
	lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
1261
	return ndlp->nlp_state;
已提交
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
}

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) {
1278
		ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
已提交
1279 1280
		ndlp->nlp_state = NLP_STE_UNMAPPED_NODE;
		lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1281
		return ndlp->nlp_state;
已提交
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296
	}

	/* 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;
	}

1297
	ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
已提交
1298 1299
	ndlp->nlp_state = NLP_STE_MAPPED_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
1300
	return ndlp->nlp_state;
已提交
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323
}

/*! 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)
{
1324 1325 1326 1327 1328 1329 1330
	if(ndlp->nlp_flag & NLP_NPR_2B_DISC) {
		ndlp->nlp_flag |= NLP_NODEV_REMOVE;
		return ndlp->nlp_state;
	}
	else {
		/* software abort outstanding PLOGI */
		lpfc_els_abort(phba, ndlp, 1);
已提交
1331

1332 1333 1334
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
已提交
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
}


/*! 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);

1361
	ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
已提交
1362 1363 1364
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
	spin_lock_irq(phba->host->host_lock);
1365
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
已提交
1366
	spin_unlock_irq(phba->host->host_lock);
1367
	return ndlp->nlp_state;
已提交
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378
}

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);
1379
	return ndlp->nlp_state;
已提交
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391
}

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);
1392
	return ndlp->nlp_state;
已提交
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402
}

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;

1403
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1404
	return ndlp->nlp_state;
已提交
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
}

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);
1416
	return ndlp->nlp_state;
已提交
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426
}

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;

1427
	lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0);
1428
	return ndlp->nlp_state;
已提交
1429 1430 1431 1432 1433 1434
}

static uint32_t
lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
			   struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
{
1435
	ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
已提交
1436 1437
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1438
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
已提交
1439 1440
	lpfc_disc_set_adisc(phba, ndlp);

1441
	return ndlp->nlp_state;
已提交
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452
}

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);
1453
	return ndlp->nlp_state;
已提交
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
}

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);
1465
	return ndlp->nlp_state;
已提交
1466 1467 1468 1469 1470 1471 1472 1473 1474 1475
}

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;

1476
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1477
	return ndlp->nlp_state;
已提交
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
}

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);
1490
	return ndlp->nlp_state;
已提交
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507
}

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 */
1508
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO);
1509
	return ndlp->nlp_state;
已提交
1510 1511 1512 1513 1514 1515 1516
}

static uint32_t
lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
			    struct lpfc_nodelist * ndlp, void *arg,
			    uint32_t evt)
{
1517
	ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
已提交
1518 1519 1520
	ndlp->nlp_state = NLP_STE_NPR_NODE;
	lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
	spin_lock_irq(phba->host->host_lock);
1521
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
已提交
1522 1523
	spin_unlock_irq(phba->host->host_lock);
	lpfc_disc_set_adisc(phba, ndlp);
1524
	return ndlp->nlp_state;
已提交
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537
}

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) {
1538
		return ndlp->nlp_state;
已提交
1539 1540 1541 1542
	}

	if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
		spin_lock_irq(phba->host->host_lock);
1543
		ndlp->nlp_flag &= ~NLP_NPR_ADISC;
已提交
1544
		spin_unlock_irq(phba->host->host_lock);
1545
		return ndlp->nlp_state;
已提交
1546 1547 1548 1549
	}

	/* send PLOGI immediately, move to PLOGI issue state */
	if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1550 1551 1552 1553
		ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
		ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
		lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
		lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
已提交
1554
	}
1555

1556
	return ndlp->nlp_state;
已提交
1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
}

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) {
1576 1577 1578
			spin_lock_irq(phba->host->host_lock);
			ndlp->nlp_flag &= ~NLP_NPR_ADISC;
			spin_unlock_irq(phba->host->host_lock);
1579
			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
已提交
1580 1581 1582 1583
			ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
			lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
			lpfc_issue_els_adisc(phba, ndlp, 0);
		} else {
1584
			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
已提交
1585 1586
			ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
			lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1587
			lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
已提交
1588
		}
1589

已提交
1590
	}
1591
	return ndlp->nlp_state;
已提交
1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
}

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;

1603
	lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1604
	return ndlp->nlp_state;
已提交
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617
}

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);

J
James Smart 已提交
1618 1619 1620 1621 1622
	/*
	 * Do not start discovery if discovery is about to start
	 * or discovery in progress for this node. Starting discovery
	 * here will affect the counting of discovery threads.
	 */
J
James Smart 已提交
1623 1624
	if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
		!(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
已提交
1625
		if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1626
			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
已提交
1627 1628 1629 1630
			ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
			lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
			lpfc_issue_els_adisc(phba, ndlp, 0);
		} else {
1631
			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
已提交
1632 1633
			ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
			lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1634
			lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
已提交
1635 1636
		}
	}
1637
	return ndlp->nlp_state;
已提交
1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648
}

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;

1649 1650 1651 1652
	spin_lock_irq(phba->host->host_lock);
	ndlp->nlp_flag |= NLP_LOGO_ACC;
	spin_unlock_irq(phba->host->host_lock);

已提交
1653 1654
	lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);

1655 1656 1657 1658 1659 1660
	if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
		mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
		spin_lock_irq(phba->host->host_lock);
		ndlp->nlp_flag |= NLP_DELAY_TMO;
		ndlp->nlp_flag &= ~NLP_NPR_ADISC;
		spin_unlock_irq(phba->host->host_lock);
1661
		ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1662 1663 1664 1665
	} else {
		spin_lock_irq(phba->host->host_lock);
		ndlp->nlp_flag &= ~NLP_NPR_ADISC;
		spin_unlock_irq(phba->host->host_lock);
已提交
1666
	}
1667 1668
	return ndlp->nlp_state;
}
已提交
1669

1670 1671 1672 1673 1674
static uint32_t
lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
			  struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
{
	struct lpfc_iocbq *cmdiocb, *rspiocb;
1675
	IOCB_t *irsp;
1676 1677 1678

	cmdiocb = (struct lpfc_iocbq *) arg;
	rspiocb = cmdiocb->context_un.rsp_iocb;
1679 1680 1681 1682 1683 1684

	irsp = &rspiocb->iocb;
	if (irsp->ulpStatus) {
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
1685 1686 1687 1688 1689 1690 1691 1692
	return ndlp->nlp_state;
}

static uint32_t
lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
			  struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
{
	struct lpfc_iocbq *cmdiocb, *rspiocb;
1693
	IOCB_t *irsp;
1694 1695 1696

	cmdiocb = (struct lpfc_iocbq *) arg;
	rspiocb = cmdiocb->context_un.rsp_iocb;
1697 1698 1699 1700 1701 1702

	irsp = &rspiocb->iocb;
	if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
1703
	return ndlp->nlp_state;
已提交
1704 1705 1706 1707 1708 1709 1710 1711
}

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 */
1712 1713 1714 1715 1716 1717 1718 1719 1720
	return ndlp->nlp_state;
}

static uint32_t
lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
			    struct lpfc_nodelist * ndlp, void *arg,
			    uint32_t evt)
{
	struct lpfc_iocbq *cmdiocb, *rspiocb;
1721
	IOCB_t *irsp;
1722 1723 1724

	cmdiocb = (struct lpfc_iocbq *) arg;
	rspiocb = cmdiocb->context_un.rsp_iocb;
1725 1726 1727 1728 1729 1730

	irsp = &rspiocb->iocb;
	if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
		lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
		return NLP_STE_FREED_NODE;
	}
1731
	return ndlp->nlp_state;
已提交
1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744
}

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;

1745 1746
	if (!mb->mbxStatus)
		ndlp->nlp_rpi = mb->un.varWords[0];
1747 1748 1749 1750 1751 1752
	else {
		if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
			lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
			return NLP_STE_FREED_NODE;
		}
	}
1753
	return ndlp->nlp_state;
已提交
1754 1755 1756 1757 1758 1759 1760
}

static uint32_t
lpfc_device_rm_npr_node(struct lpfc_hba * phba,
			    struct lpfc_nodelist * ndlp, void *arg,
			    uint32_t evt)
{
1761 1762 1763 1764
	if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
		ndlp->nlp_flag |= NLP_NODEV_REMOVE;
		return ndlp->nlp_state;
	}
已提交
1765
	lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
1766
	return NLP_STE_FREED_NODE;
已提交
1767 1768 1769 1770 1771 1772 1773 1774
}

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);
1775
	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1776
	spin_unlock_irq(phba->host->host_lock);
1777
	if (ndlp->nlp_flag & NLP_DELAY_TMO) {
1778
		lpfc_cancel_retry_delay_tmo(phba, ndlp);
1779
	}
1780
	return ndlp->nlp_state;
已提交
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815
}


/* 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
1816
 * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers
已提交
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858
 * 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        */
1859
	lpfc_rcv_logo_plogi_issue,	/* RCV_LOGO        */
已提交
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946
	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        */
1947 1948
	lpfc_cmpl_plogi_npr_node,	/* CMPL_PLOGI      */
	lpfc_cmpl_prli_npr_node,	/* CMPL_PRLI       */
已提交
1949
	lpfc_cmpl_logo_npr_node,        /* CMPL_LOGO       */
1950
	lpfc_cmpl_adisc_npr_node,       /* CMPL_ADISC      */
已提交
1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
	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);
1996
		return NLP_STE_FREED_NODE;
已提交
1997 1998
	}
	if (rc == NLP_STE_FREED_NODE)
1999 2000
		return NLP_STE_FREED_NODE;
	return rc;
已提交
2001
}