1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/blkdev.h>
25#include <linux/pci.h>
26#include <linux/slab.h>
27#include <linux/interrupt.h>
28
29#include <scsi/scsi.h>
30#include <scsi/scsi_device.h>
31#include <scsi/scsi_host.h>
32#include <scsi/scsi_transport_fc.h>
33#include <scsi/fc/fc_fs.h>
34
35#include <linux/nvme-fc-driver.h>
36
37#include "lpfc_hw4.h"
38#include "lpfc_hw.h"
39#include "lpfc_sli.h"
40#include "lpfc_sli4.h"
41#include "lpfc_nl.h"
42#include "lpfc_disc.h"
43#include "lpfc.h"
44#include "lpfc_scsi.h"
45#include "lpfc_nvme.h"
46#include "lpfc_logmsg.h"
47#include "lpfc_crtn.h"
48#include "lpfc_vport.h"
49#include "lpfc_debugfs.h"
50
51
52
53static int
54lpfc_check_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
55 struct lpfc_name *nn, struct lpfc_name *pn)
56{
57
58 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED))
59 return 0;
60
61
62
63
64 if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name)))
65 return 0;
66
67 if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name)))
68 return 0;
69
70
71 return 1;
72}
73
74int
75lpfc_check_sparm(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
76 struct serv_parm *sp, uint32_t class, int flogi)
77{
78 volatile struct serv_parm *hsp = &vport->fc_sparam;
79 uint16_t hsp_value, ssp_value = 0;
80
81
82
83
84
85
86
87
88 if (sp->cls1.classValid) {
89 if (!flogi) {
90 hsp_value = ((hsp->cls1.rcvDataSizeMsb << 8) |
91 hsp->cls1.rcvDataSizeLsb);
92 ssp_value = ((sp->cls1.rcvDataSizeMsb << 8) |
93 sp->cls1.rcvDataSizeLsb);
94 if (!ssp_value)
95 goto bad_service_param;
96 if (ssp_value > hsp_value) {
97 sp->cls1.rcvDataSizeLsb =
98 hsp->cls1.rcvDataSizeLsb;
99 sp->cls1.rcvDataSizeMsb =
100 hsp->cls1.rcvDataSizeMsb;
101 }
102 }
103 } else if (class == CLASS1)
104 goto bad_service_param;
105 if (sp->cls2.classValid) {
106 if (!flogi) {
107 hsp_value = ((hsp->cls2.rcvDataSizeMsb << 8) |
108 hsp->cls2.rcvDataSizeLsb);
109 ssp_value = ((sp->cls2.rcvDataSizeMsb << 8) |
110 sp->cls2.rcvDataSizeLsb);
111 if (!ssp_value)
112 goto bad_service_param;
113 if (ssp_value > hsp_value) {
114 sp->cls2.rcvDataSizeLsb =
115 hsp->cls2.rcvDataSizeLsb;
116 sp->cls2.rcvDataSizeMsb =
117 hsp->cls2.rcvDataSizeMsb;
118 }
119 }
120 } else if (class == CLASS2)
121 goto bad_service_param;
122 if (sp->cls3.classValid) {
123 if (!flogi) {
124 hsp_value = ((hsp->cls3.rcvDataSizeMsb << 8) |
125 hsp->cls3.rcvDataSizeLsb);
126 ssp_value = ((sp->cls3.rcvDataSizeMsb << 8) |
127 sp->cls3.rcvDataSizeLsb);
128 if (!ssp_value)
129 goto bad_service_param;
130 if (ssp_value > hsp_value) {
131 sp->cls3.rcvDataSizeLsb =
132 hsp->cls3.rcvDataSizeLsb;
133 sp->cls3.rcvDataSizeMsb =
134 hsp->cls3.rcvDataSizeMsb;
135 }
136 }
137 } else if (class == CLASS3)
138 goto bad_service_param;
139
140
141
142
143
144
145 hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb;
146 ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb;
147 if (ssp_value > hsp_value) {
148 sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb;
149 sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) |
150 (hsp->cmn.bbRcvSizeMsb & 0x0F);
151 }
152
153 memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name));
154 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
155 return 1;
156bad_service_param:
157 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
158 "0207 Device %x "
159 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent "
160 "invalid service parameters. Ignoring device.\n",
161 ndlp->nlp_DID,
162 sp->nodeName.u.wwn[0], sp->nodeName.u.wwn[1],
163 sp->nodeName.u.wwn[2], sp->nodeName.u.wwn[3],
164 sp->nodeName.u.wwn[4], sp->nodeName.u.wwn[5],
165 sp->nodeName.u.wwn[6], sp->nodeName.u.wwn[7]);
166 return 0;
167}
168
169static void *
170lpfc_check_elscmpl_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
171 struct lpfc_iocbq *rspiocb)
172{
173 struct lpfc_dmabuf *pcmd, *prsp;
174 uint32_t *lp;
175 void *ptr = NULL;
176 IOCB_t *irsp;
177
178 irsp = &rspiocb->iocb;
179 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
180
181
182
183
184 if (pcmd) {
185 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf,
186 list);
187 if (prsp) {
188 lp = (uint32_t *) prsp->virt;
189 ptr = (void *)((uint8_t *)lp + sizeof(uint32_t));
190 }
191 } else {
192
193 if (!(irsp->ulpStatus)) {
194 irsp->ulpStatus = IOSTAT_LOCAL_REJECT;
195 irsp->un.ulpWord[4] = IOERR_SLI_ABORTED;
196 }
197 ptr = NULL;
198 }
199 return ptr;
200}
201
202
203
204
205
206
207
208
209void
210lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
211{
212 LIST_HEAD(abort_list);
213 struct lpfc_sli_ring *pring;
214 struct lpfc_iocbq *iocb, *next_iocb;
215
216 pring = lpfc_phba_elsring(phba);
217
218
219 if (unlikely(!pring))
220 return;
221
222
223 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY,
224 "2819 Abort outstanding I/O on NPort x%x "
225 "Data: x%x x%x x%x\n",
226 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
227 ndlp->nlp_rpi);
228
229 lpfc_fabric_abort_nport(ndlp);
230
231
232
233
234
235
236 spin_lock_irq(&phba->hbalock);
237 if (phba->sli_rev == LPFC_SLI_REV4)
238 spin_lock(&pring->ring_lock);
239 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
240
241 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))
242 list_add_tail(&iocb->dlist, &abort_list);
243 }
244 if (phba->sli_rev == LPFC_SLI_REV4)
245 spin_unlock(&pring->ring_lock);
246 spin_unlock_irq(&phba->hbalock);
247
248
249 list_for_each_entry_safe(iocb, next_iocb, &abort_list, dlist) {
250 spin_lock_irq(&phba->hbalock);
251 list_del_init(&iocb->dlist);
252 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
253 spin_unlock_irq(&phba->hbalock);
254 }
255
256 INIT_LIST_HEAD(&abort_list);
257
258
259 spin_lock_irq(&phba->hbalock);
260 if (phba->sli_rev == LPFC_SLI_REV4)
261 spin_lock(&pring->ring_lock);
262
263 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
264
265 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) {
266 list_del_init(&iocb->list);
267 list_add_tail(&iocb->list, &abort_list);
268 }
269 }
270
271 if (phba->sli_rev == LPFC_SLI_REV4)
272 spin_unlock(&pring->ring_lock);
273 spin_unlock_irq(&phba->hbalock);
274
275
276 lpfc_sli_cancel_iocbs(phba, &abort_list,
277 IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED);
278
279 lpfc_cancel_retry_delay_tmo(phba->pport, ndlp);
280}
281
282static int
283lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
284 struct lpfc_iocbq *cmdiocb)
285{
286 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
287 struct lpfc_hba *phba = vport->phba;
288 struct lpfc_dmabuf *pcmd;
289 uint64_t nlp_portwwn = 0;
290 uint32_t *lp;
291 IOCB_t *icmd;
292 struct serv_parm *sp;
293 uint32_t ed_tov;
294 LPFC_MBOXQ_t *mbox;
295 struct ls_rjt stat;
296 uint32_t vid, flag;
297 int rc;
298
299 memset(&stat, 0, sizeof (struct ls_rjt));
300 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
301 lp = (uint32_t *) pcmd->virt;
302 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
303 if (wwn_to_u64(sp->portName.u.wwn) == 0) {
304 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
305 "0140 PLOGI Reject: invalid nname\n");
306 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
307 stat.un.b.lsRjtRsnCodeExp = LSEXP_INVALID_PNAME;
308 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
309 NULL);
310 return 0;
311 }
312 if (wwn_to_u64(sp->nodeName.u.wwn) == 0) {
313 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
314 "0141 PLOGI Reject: invalid pname\n");
315 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
316 stat.un.b.lsRjtRsnCodeExp = LSEXP_INVALID_NNAME;
317 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
318 NULL);
319 return 0;
320 }
321
322 nlp_portwwn = wwn_to_u64(ndlp->nlp_portname.u.wwn);
323 if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0) == 0)) {
324
325 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
326 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
327 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
328 NULL);
329 return 0;
330 }
331 icmd = &cmdiocb->iocb;
332
333
334 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
335 "0114 PLOGI chkparm OK Data: x%x x%x x%x "
336 "x%x x%x x%x\n",
337 ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag,
338 ndlp->nlp_rpi, vport->port_state,
339 vport->fc_flag);
340
341 if (vport->cfg_fcp_class == 2 && sp->cls2.classValid)
342 ndlp->nlp_fcp_info |= CLASS2;
343 else
344 ndlp->nlp_fcp_info |= CLASS3;
345
346 ndlp->nlp_class_sup = 0;
347 if (sp->cls1.classValid)
348 ndlp->nlp_class_sup |= FC_COS_CLASS1;
349 if (sp->cls2.classValid)
350 ndlp->nlp_class_sup |= FC_COS_CLASS2;
351 if (sp->cls3.classValid)
352 ndlp->nlp_class_sup |= FC_COS_CLASS3;
353 if (sp->cls4.classValid)
354 ndlp->nlp_class_sup |= FC_COS_CLASS4;
355 ndlp->nlp_maxframe =
356 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
357
358
359 switch (ndlp->nlp_state) {
360 case NLP_STE_NPR_NODE:
361 if (!(ndlp->nlp_flag & NLP_NPR_ADISC))
362 break;
363
364 case NLP_STE_REG_LOGIN_ISSUE:
365 case NLP_STE_PRLI_ISSUE:
366 case NLP_STE_UNMAPPED_NODE:
367 case NLP_STE_MAPPED_NODE:
368
369
370
371
372 if (!(ndlp->nlp_type & NLP_FABRIC) &&
373 !(phba->nvmet_support)) {
374 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb,
375 ndlp, NULL);
376 return 1;
377 }
378 if (nlp_portwwn != 0 &&
379 nlp_portwwn != wwn_to_u64(sp->portName.u.wwn))
380 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
381 "0143 PLOGI recv'd from DID: x%x "
382 "WWPN changed: old %llx new %llx\n",
383 ndlp->nlp_DID,
384 (unsigned long long)nlp_portwwn,
385 (unsigned long long)
386 wwn_to_u64(sp->portName.u.wwn));
387
388 ndlp->nlp_prev_state = ndlp->nlp_state;
389
390 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
391 break;
392 }
393
394 ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
395 ndlp->nlp_type &= ~(NLP_NVME_TARGET | NLP_NVME_INITIATOR);
396 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
397 ndlp->nlp_flag &= ~NLP_FIRSTBURST;
398
399
400 if ((vport->fc_flag & FC_PT2PT) &&
401 !(vport->fc_flag & FC_PT2PT_PLOGI)) {
402
403 vport->fc_myDID = icmd->un.rcvels.parmRo;
404
405 ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
406 if (sp->cmn.edtovResolution) {
407
408 ed_tov = (phba->fc_edtov + 999999) / 1000000;
409 }
410
411
412
413
414
415 if (ed_tov > phba->fc_edtov)
416 phba->fc_edtov = ed_tov;
417 phba->fc_ratov = (2 * phba->fc_edtov) / 1000;
418
419 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
420
421
422
423 if (phba->sli_rev == LPFC_SLI_REV4)
424 lpfc_issue_reg_vfi(vport);
425 else {
426 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
427 if (mbox == NULL)
428 goto out;
429 lpfc_config_link(phba, mbox);
430 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
431 mbox->vport = vport;
432 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
433 if (rc == MBX_NOT_FINISHED) {
434 mempool_free(mbox, phba->mbox_mem_pool);
435 goto out;
436 }
437 }
438
439 lpfc_can_disctmo(vport);
440 }
441
442 ndlp->nlp_flag &= ~NLP_SUPPRESS_RSP;
443 if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) &&
444 sp->cmn.valid_vendor_ver_level) {
445 vid = be32_to_cpu(sp->un.vv.vid);
446 flag = be32_to_cpu(sp->un.vv.flags);
447 if ((vid == LPFC_VV_EMLX_ID) && (flag & LPFC_VV_SUPPRESS_RSP))
448 ndlp->nlp_flag |= NLP_SUPPRESS_RSP;
449 }
450
451 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
452 if (!mbox)
453 goto out;
454
455
456 if (phba->sli_rev == LPFC_SLI_REV4)
457 lpfc_unreg_rpi(vport, ndlp);
458
459 rc = lpfc_reg_rpi(phba, vport->vpi, icmd->un.rcvels.remoteID,
460 (uint8_t *) sp, mbox, ndlp->nlp_rpi);
461 if (rc) {
462 mempool_free(mbox, phba->mbox_mem_pool);
463 goto out;
464 }
465
466
467
468
469 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
470
471
472
473
474 mbox->vport = vport;
475 spin_lock_irq(shost->host_lock);
476 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
477 spin_unlock_irq(shost->host_lock);
478
479
480
481
482
483
484
485
486
487
488 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
489
490 lpfc_els_abort(phba, ndlp);
491 }
492
493 if ((vport->port_type == LPFC_NPIV_PORT &&
494 vport->cfg_restrict_login)) {
495
496
497
498
499
500
501 spin_lock_irq(shost->host_lock);
502 ndlp->nlp_flag |= NLP_RM_DFLT_RPI;
503 spin_unlock_irq(shost->host_lock);
504 stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD;
505 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
506 rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
507 ndlp, mbox);
508 if (rc)
509 mempool_free(mbox, phba->mbox_mem_pool);
510 return 1;
511 }
512 rc = lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox);
513 if (rc)
514 mempool_free(mbox, phba->mbox_mem_pool);
515 return 1;
516out:
517 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
518 stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
519 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
520 return 0;
521}
522
523
524
525
526
527
528
529
530
531static void
532lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
533{
534 struct lpfc_vport *vport;
535 struct lpfc_iocbq *elsiocb;
536 struct lpfc_nodelist *ndlp;
537 uint32_t cmd;
538
539 elsiocb = (struct lpfc_iocbq *)mboxq->ctx_buf;
540 ndlp = (struct lpfc_nodelist *)mboxq->ctx_ndlp;
541 vport = mboxq->vport;
542 cmd = elsiocb->drvrTimeout;
543
544 if (cmd == ELS_CMD_ADISC) {
545 lpfc_els_rsp_adisc_acc(vport, elsiocb, ndlp);
546 } else {
547 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, elsiocb,
548 ndlp, NULL);
549 }
550 kfree(elsiocb);
551 mempool_free(mboxq, phba->mbox_mem_pool);
552}
553
554static int
555lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
556 struct lpfc_iocbq *cmdiocb)
557{
558 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
559 struct lpfc_iocbq *elsiocb;
560 struct lpfc_dmabuf *pcmd;
561 struct serv_parm *sp;
562 struct lpfc_name *pnn, *ppn;
563 struct ls_rjt stat;
564 ADISC *ap;
565 IOCB_t *icmd;
566 uint32_t *lp;
567 uint32_t cmd;
568
569 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
570 lp = (uint32_t *) pcmd->virt;
571
572 cmd = *lp++;
573 if (cmd == ELS_CMD_ADISC) {
574 ap = (ADISC *) lp;
575 pnn = (struct lpfc_name *) & ap->nodeName;
576 ppn = (struct lpfc_name *) & ap->portName;
577 } else {
578 sp = (struct serv_parm *) lp;
579 pnn = (struct lpfc_name *) & sp->nodeName;
580 ppn = (struct lpfc_name *) & sp->portName;
581 }
582
583 icmd = &cmdiocb->iocb;
584 if (icmd->ulpStatus == 0 && lpfc_check_adisc(vport, ndlp, pnn, ppn)) {
585
586
587
588
589
590
591 if (vport->phba->sli_rev == LPFC_SLI_REV4) {
592 elsiocb = kmalloc(sizeof(struct lpfc_iocbq),
593 GFP_KERNEL);
594 if (elsiocb) {
595
596
597 memcpy((uint8_t *)elsiocb, (uint8_t *)cmdiocb,
598 sizeof(struct lpfc_iocbq));
599
600
601 elsiocb->drvrTimeout = cmd;
602
603 lpfc_sli4_resume_rpi(ndlp,
604 lpfc_mbx_cmpl_resume_rpi, elsiocb);
605 goto out;
606 }
607 }
608
609 if (cmd == ELS_CMD_ADISC) {
610 lpfc_els_rsp_adisc_acc(vport, cmdiocb, ndlp);
611 } else {
612 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb,
613 ndlp, NULL);
614 }
615out:
616
617 if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET))
618 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
619 else
620 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
621
622 return 1;
623 }
624
625 stat.un.b.lsRjtRsvd0 = 0;
626 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
627 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS;
628 stat.un.b.vendorUnique = 0;
629 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
630
631
632 mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000));
633
634 spin_lock_irq(shost->host_lock);
635 ndlp->nlp_flag |= NLP_DELAY_TMO;
636 spin_unlock_irq(shost->host_lock);
637 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
638 ndlp->nlp_prev_state = ndlp->nlp_state;
639 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
640 return 0;
641}
642
643static int
644lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
645 struct lpfc_iocbq *cmdiocb, uint32_t els_cmd)
646{
647 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
648 struct lpfc_hba *phba = vport->phba;
649 struct lpfc_vport **vports;
650 int i, active_vlink_present = 0 ;
651
652
653
654
655
656 spin_lock_irq(shost->host_lock);
657 ndlp->nlp_flag |= NLP_LOGO_ACC;
658 spin_unlock_irq(shost->host_lock);
659 if (els_cmd == ELS_CMD_PRLO)
660 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
661 else
662 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
663 if (ndlp->nlp_DID == Fabric_DID) {
664 if (vport->port_state <= LPFC_FDISC)
665 goto out;
666 lpfc_linkdown_port(vport);
667 spin_lock_irq(shost->host_lock);
668 vport->fc_flag |= FC_VPORT_LOGO_RCVD;
669 spin_unlock_irq(shost->host_lock);
670 vports = lpfc_create_vport_work_array(phba);
671 if (vports) {
672 for (i = 0; i <= phba->max_vports && vports[i] != NULL;
673 i++) {
674 if ((!(vports[i]->fc_flag &
675 FC_VPORT_LOGO_RCVD)) &&
676 (vports[i]->port_state > LPFC_FDISC)) {
677 active_vlink_present = 1;
678 break;
679 }
680 }
681 lpfc_destroy_vport_work_array(phba, vports);
682 }
683
684
685
686
687
688
689 if (!(vport->load_flag & FC_UNLOADING) &&
690 active_vlink_present) {
691
692
693
694
695 mod_timer(&ndlp->nlp_delayfunc,
696 jiffies + msecs_to_jiffies(1000));
697 spin_lock_irq(shost->host_lock);
698 ndlp->nlp_flag |= NLP_DELAY_TMO;
699 spin_unlock_irq(shost->host_lock);
700 ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
701 vport->port_state = LPFC_FDISC;
702 } else {
703 spin_lock_irq(shost->host_lock);
704 phba->pport->fc_flag &= ~FC_LOGO_RCVD_DID_CHNG;
705 spin_unlock_irq(shost->host_lock);
706 lpfc_retry_pport_discovery(phba);
707 }
708 } else if ((!(ndlp->nlp_type & NLP_FABRIC) &&
709 ((ndlp->nlp_type & NLP_FCP_TARGET) ||
710 !(ndlp->nlp_type & NLP_FCP_INITIATOR))) ||
711 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
712
713 mod_timer(&ndlp->nlp_delayfunc,
714 jiffies + msecs_to_jiffies(1000 * 1));
715 spin_lock_irq(shost->host_lock);
716 ndlp->nlp_flag |= NLP_DELAY_TMO;
717 spin_unlock_irq(shost->host_lock);
718
719 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
720 }
721out:
722 ndlp->nlp_prev_state = ndlp->nlp_state;
723 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
724
725 spin_lock_irq(shost->host_lock);
726 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
727 spin_unlock_irq(shost->host_lock);
728
729
730
731
732
733 return 0;
734}
735
736static uint32_t
737lpfc_rcv_prli_support_check(struct lpfc_vport *vport,
738 struct lpfc_nodelist *ndlp,
739 struct lpfc_iocbq *cmdiocb)
740{
741 struct ls_rjt stat;
742 uint32_t *payload;
743 uint32_t cmd;
744
745 payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
746 cmd = *payload;
747 if (vport->phba->nvmet_support) {
748
749 if (cmd == ELS_CMD_PRLI)
750 goto out;
751 } else {
752
753 if (!vport->nvmei_support && (cmd == ELS_CMD_NVMEPRLI))
754 goto out;
755 }
756 return 1;
757out:
758 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME_DISC,
759 "6115 Rcv PRLI (%x) check failed: ndlp rpi %d "
760 "state x%x flags x%x\n",
761 cmd, ndlp->nlp_rpi, ndlp->nlp_state,
762 ndlp->nlp_flag);
763 memset(&stat, 0, sizeof(struct ls_rjt));
764 stat.un.b.lsRjtRsnCode = LSRJT_CMD_UNSUPPORTED;
765 stat.un.b.lsRjtRsnCodeExp = LSEXP_REQ_UNSUPPORTED;
766 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
767 ndlp, NULL);
768 return 0;
769}
770
771static void
772lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
773 struct lpfc_iocbq *cmdiocb)
774{
775 struct lpfc_hba *phba = vport->phba;
776 struct lpfc_dmabuf *pcmd;
777 uint32_t *lp;
778 PRLI *npr;
779 struct fc_rport *rport = ndlp->rport;
780 u32 roles;
781
782 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
783 lp = (uint32_t *) pcmd->virt;
784 npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
785
786 if ((npr->prliType == PRLI_FCP_TYPE) ||
787 (npr->prliType == PRLI_NVME_TYPE)) {
788 if (npr->initiatorFunc) {
789 if (npr->prliType == PRLI_FCP_TYPE)
790 ndlp->nlp_type |= NLP_FCP_INITIATOR;
791 if (npr->prliType == PRLI_NVME_TYPE)
792 ndlp->nlp_type |= NLP_NVME_INITIATOR;
793 }
794 if (npr->targetFunc) {
795 if (npr->prliType == PRLI_FCP_TYPE)
796 ndlp->nlp_type |= NLP_FCP_TARGET;
797 if (npr->prliType == PRLI_NVME_TYPE)
798 ndlp->nlp_type |= NLP_NVME_TARGET;
799 if (npr->writeXferRdyDis)
800 ndlp->nlp_flag |= NLP_FIRSTBURST;
801 }
802 if (npr->Retry && ndlp->nlp_type &
803 (NLP_FCP_INITIATOR | NLP_FCP_TARGET))
804 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
805
806 if (npr->Retry && phba->nsler &&
807 ndlp->nlp_type & (NLP_NVME_INITIATOR | NLP_NVME_TARGET))
808 ndlp->nlp_nvme_info |= NLP_NVME_NSLER;
809
810
811
812
813
814
815
816 if (phba->nvmet_support && (npr->prliType == PRLI_NVME_TYPE)) {
817 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
818 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
819 }
820 if (npr->prliType == PRLI_FCP_TYPE)
821 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
822 }
823 if (rport) {
824
825 roles = FC_RPORT_ROLE_UNKNOWN;
826 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
827 roles |= FC_RPORT_ROLE_FCP_INITIATOR;
828 if (ndlp->nlp_type & NLP_FCP_TARGET)
829 roles |= FC_RPORT_ROLE_FCP_TARGET;
830
831 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
832 "rport rolechg: role:x%x did:x%x flg:x%x",
833 roles, ndlp->nlp_DID, ndlp->nlp_flag);
834
835 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
836 fc_remote_port_rolechg(rport, roles);
837 }
838}
839
840static uint32_t
841lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
842{
843 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
844
845 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
846 spin_lock_irq(shost->host_lock);
847 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
848 spin_unlock_irq(shost->host_lock);
849 return 0;
850 }
851
852 if (!(vport->fc_flag & FC_PT2PT)) {
853
854 if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) ||
855 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) &&
856 (ndlp->nlp_type & NLP_FCP_TARGET)))) {
857 spin_lock_irq(shost->host_lock);
858 ndlp->nlp_flag |= NLP_NPR_ADISC;
859 spin_unlock_irq(shost->host_lock);
860 return 1;
861 }
862 }
863
864 spin_lock_irq(shost->host_lock);
865 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
866 spin_unlock_irq(shost->host_lock);
867 lpfc_unreg_rpi(vport, ndlp);
868 return 0;
869}
870
871
872
873
874
875
876
877
878
879
880static void
881lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport,
882 struct lpfc_nodelist *ndlp, uint16_t rpi)
883{
884 LPFC_MBOXQ_t *pmb;
885 int rc;
886
887
888
889
890 if (ndlp->nlp_flag & NLP_UNREG_INP) {
891 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
892 "1435 release_rpi SKIP UNREG x%x on "
893 "NPort x%x deferred x%x flg x%x "
894 "Data: x%px\n",
895 ndlp->nlp_rpi, ndlp->nlp_DID,
896 ndlp->nlp_defer_did,
897 ndlp->nlp_flag, ndlp);
898 return;
899 }
900
901 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
902 GFP_KERNEL);
903 if (!pmb)
904 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
905 "2796 mailbox memory allocation failed \n");
906 else {
907 lpfc_unreg_login(phba, vport->vpi, rpi, pmb);
908 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
909 pmb->vport = vport;
910 pmb->ctx_ndlp = ndlp;
911
912 if (((ndlp->nlp_DID & Fabric_DID_MASK) != Fabric_DID_MASK) &&
913 (!(vport->fc_flag & FC_OFFLINE_MODE)))
914 ndlp->nlp_flag |= NLP_UNREG_INP;
915
916 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
917 "1437 release_rpi UNREG x%x "
918 "on NPort x%x flg x%x\n",
919 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag);
920
921 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
922 if (rc == MBX_NOT_FINISHED)
923 mempool_free(pmb, phba->mbox_mem_pool);
924 }
925}
926
927static uint32_t
928lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
929 void *arg, uint32_t evt)
930{
931 struct lpfc_hba *phba;
932 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
933 uint16_t rpi;
934
935 phba = vport->phba;
936
937 if (!(phba->pport->load_flag & FC_UNLOADING) &&
938 (evt == NLP_EVT_CMPL_REG_LOGIN) &&
939 (!pmb->u.mb.mbxStatus)) {
940 rpi = pmb->u.mb.un.varWords[0];
941 lpfc_release_rpi(phba, vport, ndlp, rpi);
942 }
943 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
944 "0271 Illegal State Transition: node x%x "
945 "event x%x, state x%x Data: x%x x%x\n",
946 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
947 ndlp->nlp_flag);
948 return ndlp->nlp_state;
949}
950
951static uint32_t
952lpfc_cmpl_plogi_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
953 void *arg, uint32_t evt)
954{
955
956
957
958
959
960 if (!(ndlp->nlp_flag & NLP_RCV_PLOGI)) {
961 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
962 "0272 Illegal State Transition: node x%x "
963 "event x%x, state x%x Data: x%x x%x\n",
964 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
965 ndlp->nlp_flag);
966 }
967 return ndlp->nlp_state;
968}
969
970
971
972static uint32_t
973lpfc_rcv_plogi_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
974 void *arg, uint32_t evt)
975{
976 struct lpfc_iocbq *cmdiocb;
977
978 cmdiocb = (struct lpfc_iocbq *) arg;
979
980 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
981 return ndlp->nlp_state;
982 }
983 return NLP_STE_FREED_NODE;
984}
985
986static uint32_t
987lpfc_rcv_els_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
988 void *arg, uint32_t evt)
989{
990 lpfc_issue_els_logo(vport, ndlp, 0);
991 return ndlp->nlp_state;
992}
993
994static uint32_t
995lpfc_rcv_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
996 void *arg, uint32_t evt)
997{
998 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
999 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1000
1001 spin_lock_irq(shost->host_lock);
1002 ndlp->nlp_flag |= NLP_LOGO_ACC;
1003 spin_unlock_irq(shost->host_lock);
1004 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
1005
1006 return ndlp->nlp_state;
1007}
1008
1009static uint32_t
1010lpfc_cmpl_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1011 void *arg, uint32_t evt)
1012{
1013 return NLP_STE_FREED_NODE;
1014}
1015
1016static uint32_t
1017lpfc_device_rm_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1018 void *arg, uint32_t evt)
1019{
1020 return NLP_STE_FREED_NODE;
1021}
1022
1023static uint32_t
1024lpfc_device_recov_unused_node(struct lpfc_vport *vport,
1025 struct lpfc_nodelist *ndlp,
1026 void *arg, uint32_t evt)
1027{
1028 return ndlp->nlp_state;
1029}
1030
1031static uint32_t
1032lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1033 void *arg, uint32_t evt)
1034{
1035 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1036 struct lpfc_hba *phba = vport->phba;
1037 struct lpfc_iocbq *cmdiocb = arg;
1038 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1039 uint32_t *lp = (uint32_t *) pcmd->virt;
1040 struct serv_parm *sp = (struct serv_parm *) (lp + 1);
1041 struct ls_rjt stat;
1042 int port_cmp;
1043
1044 memset(&stat, 0, sizeof (struct ls_rjt));
1045
1046
1047
1048
1049 phba->fc_stat.elsLogiCol++;
1050 port_cmp = memcmp(&vport->fc_portname, &sp->portName,
1051 sizeof(struct lpfc_name));
1052
1053 if (port_cmp >= 0) {
1054
1055
1056 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
1057 stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
1058 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp,
1059 NULL);
1060 } else {
1061 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb) &&
1062 (ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
1063 (vport->num_disc_nodes)) {
1064 spin_lock_irq(shost->host_lock);
1065 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1066 spin_unlock_irq(shost->host_lock);
1067
1068 lpfc_more_plogi(vport);
1069 if (vport->num_disc_nodes == 0) {
1070 spin_lock_irq(shost->host_lock);
1071 vport->fc_flag &= ~FC_NDISC_ACTIVE;
1072 spin_unlock_irq(shost->host_lock);
1073 lpfc_can_disctmo(vport);
1074 lpfc_end_rscn(vport);
1075 }
1076 }
1077 }
1078
1079 return ndlp->nlp_state;
1080}
1081
1082static uint32_t
1083lpfc_rcv_prli_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1084 void *arg, uint32_t evt)
1085{
1086 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1087 struct ls_rjt stat;
1088
1089 memset(&stat, 0, sizeof (struct ls_rjt));
1090 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1091 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1092 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
1093 return ndlp->nlp_state;
1094}
1095
1096static uint32_t
1097lpfc_rcv_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1098 void *arg, uint32_t evt)
1099{
1100 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1101
1102
1103 if (vport->phba->sli_rev == LPFC_SLI_REV3)
1104 ndlp->nlp_rpi = cmdiocb->iocb.ulpIoTag;
1105
1106 lpfc_els_abort(vport->phba, ndlp);
1107
1108 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1109 return ndlp->nlp_state;
1110}
1111
1112static uint32_t
1113lpfc_rcv_els_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1114 void *arg, uint32_t evt)
1115{
1116 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1117 struct lpfc_hba *phba = vport->phba;
1118 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1119
1120
1121 lpfc_els_abort(phba, ndlp);
1122
1123 if (evt == NLP_EVT_RCV_LOGO) {
1124 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
1125 } else {
1126 lpfc_issue_els_logo(vport, ndlp, 0);
1127 }
1128
1129
1130 mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000 * 1));
1131 spin_lock_irq(shost->host_lock);
1132 ndlp->nlp_flag |= NLP_DELAY_TMO;
1133 spin_unlock_irq(shost->host_lock);
1134 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1135 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1136 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1137
1138 return ndlp->nlp_state;
1139}
1140
1141static uint32_t
1142lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
1143 struct lpfc_nodelist *ndlp,
1144 void *arg,
1145 uint32_t evt)
1146{
1147 struct lpfc_hba *phba = vport->phba;
1148 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1149 struct lpfc_iocbq *cmdiocb, *rspiocb;
1150 struct lpfc_dmabuf *pcmd, *prsp, *mp;
1151 uint32_t *lp;
1152 uint32_t vid, flag;
1153 IOCB_t *irsp;
1154 struct serv_parm *sp;
1155 uint32_t ed_tov;
1156 LPFC_MBOXQ_t *mbox;
1157 int rc;
1158
1159 cmdiocb = (struct lpfc_iocbq *) arg;
1160 rspiocb = cmdiocb->context_un.rsp_iocb;
1161
1162 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
1163
1164 return ndlp->nlp_state;
1165 }
1166
1167 irsp = &rspiocb->iocb;
1168
1169 if (irsp->ulpStatus)
1170 goto out;
1171
1172 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1173
1174 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
1175 if (!prsp)
1176 goto out;
1177
1178 lp = (uint32_t *) prsp->virt;
1179 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
1180
1181
1182 if ((ndlp->nlp_DID != FDMI_DID) &&
1183 (wwn_to_u64(sp->portName.u.wwn) == 0 ||
1184 wwn_to_u64(sp->nodeName.u.wwn) == 0)) {
1185 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1186 "0142 PLOGI RSP: Invalid WWN.\n");
1187 goto out;
1188 }
1189 if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0))
1190 goto out;
1191
1192 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1193 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
1194 ndlp->nlp_DID, ndlp->nlp_state,
1195 ndlp->nlp_flag, ndlp->nlp_rpi);
1196 if (vport->cfg_fcp_class == 2 && (sp->cls2.classValid))
1197 ndlp->nlp_fcp_info |= CLASS2;
1198 else
1199 ndlp->nlp_fcp_info |= CLASS3;
1200
1201 ndlp->nlp_class_sup = 0;
1202 if (sp->cls1.classValid)
1203 ndlp->nlp_class_sup |= FC_COS_CLASS1;
1204 if (sp->cls2.classValid)
1205 ndlp->nlp_class_sup |= FC_COS_CLASS2;
1206 if (sp->cls3.classValid)
1207 ndlp->nlp_class_sup |= FC_COS_CLASS3;
1208 if (sp->cls4.classValid)
1209 ndlp->nlp_class_sup |= FC_COS_CLASS4;
1210 ndlp->nlp_maxframe =
1211 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb;
1212
1213 if ((vport->fc_flag & FC_PT2PT) &&
1214 (vport->fc_flag & FC_PT2PT_PLOGI)) {
1215 ed_tov = be32_to_cpu(sp->cmn.e_d_tov);
1216 if (sp->cmn.edtovResolution) {
1217
1218 ed_tov = (phba->fc_edtov + 999999) / 1000000;
1219 }
1220
1221 ndlp->nlp_flag &= ~NLP_SUPPRESS_RSP;
1222 if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) &&
1223 sp->cmn.valid_vendor_ver_level) {
1224 vid = be32_to_cpu(sp->un.vv.vid);
1225 flag = be32_to_cpu(sp->un.vv.flags);
1226 if ((vid == LPFC_VV_EMLX_ID) &&
1227 (flag & LPFC_VV_SUPPRESS_RSP))
1228 ndlp->nlp_flag |= NLP_SUPPRESS_RSP;
1229 }
1230
1231
1232
1233
1234
1235 if (ed_tov > phba->fc_edtov)
1236 phba->fc_edtov = ed_tov;
1237 phba->fc_ratov = (2 * phba->fc_edtov) / 1000;
1238
1239 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
1240
1241
1242 if (phba->sli_rev == LPFC_SLI_REV4) {
1243 lpfc_issue_reg_vfi(vport);
1244 } else {
1245 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1246 if (!mbox) {
1247 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1248 "0133 PLOGI: no memory "
1249 "for config_link "
1250 "Data: x%x x%x x%x x%x\n",
1251 ndlp->nlp_DID, ndlp->nlp_state,
1252 ndlp->nlp_flag, ndlp->nlp_rpi);
1253 goto out;
1254 }
1255
1256 lpfc_config_link(phba, mbox);
1257
1258 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1259 mbox->vport = vport;
1260 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
1261 if (rc == MBX_NOT_FINISHED) {
1262 mempool_free(mbox, phba->mbox_mem_pool);
1263 goto out;
1264 }
1265 }
1266 }
1267
1268 lpfc_unreg_rpi(vport, ndlp);
1269
1270 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1271 if (!mbox) {
1272 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1273 "0018 PLOGI: no memory for reg_login "
1274 "Data: x%x x%x x%x x%x\n",
1275 ndlp->nlp_DID, ndlp->nlp_state,
1276 ndlp->nlp_flag, ndlp->nlp_rpi);
1277 goto out;
1278 }
1279
1280 if (lpfc_reg_rpi(phba, vport->vpi, irsp->un.elsreq64.remoteID,
1281 (uint8_t *) sp, mbox, ndlp->nlp_rpi) == 0) {
1282 switch (ndlp->nlp_DID) {
1283 case NameServer_DID:
1284 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
1285 break;
1286 case FDMI_DID:
1287 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
1288 break;
1289 default:
1290 ndlp->nlp_flag |= NLP_REG_LOGIN_SEND;
1291 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
1292 }
1293 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
1294 mbox->vport = vport;
1295 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
1296 != MBX_NOT_FINISHED) {
1297 lpfc_nlp_set_state(vport, ndlp,
1298 NLP_STE_REG_LOGIN_ISSUE);
1299 return ndlp->nlp_state;
1300 }
1301 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
1302 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1303
1304
1305
1306 lpfc_nlp_put(ndlp);
1307 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
1308 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1309 kfree(mp);
1310 mempool_free(mbox, phba->mbox_mem_pool);
1311
1312 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1313 "0134 PLOGI: cannot issue reg_login "
1314 "Data: x%x x%x x%x x%x\n",
1315 ndlp->nlp_DID, ndlp->nlp_state,
1316 ndlp->nlp_flag, ndlp->nlp_rpi);
1317 } else {
1318 mempool_free(mbox, phba->mbox_mem_pool);
1319
1320 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1321 "0135 PLOGI: cannot format reg_login "
1322 "Data: x%x x%x x%x x%x\n",
1323 ndlp->nlp_DID, ndlp->nlp_state,
1324 ndlp->nlp_flag, ndlp->nlp_rpi);
1325 }
1326
1327
1328out:
1329 if (ndlp->nlp_DID == NameServer_DID) {
1330 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1331 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1332 "0261 Cannot Register NameServer login\n");
1333 }
1334
1335
1336
1337
1338
1339
1340 ndlp->nlp_prev_state = ndlp->nlp_state;
1341 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1342 spin_lock_irq(shost->host_lock);
1343 ndlp->nlp_flag |= NLP_DEFER_RM;
1344 spin_unlock_irq(shost->host_lock);
1345 return NLP_STE_FREED_NODE;
1346}
1347
1348static uint32_t
1349lpfc_cmpl_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1350 void *arg, uint32_t evt)
1351{
1352 return ndlp->nlp_state;
1353}
1354
1355static uint32_t
1356lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport *vport,
1357 struct lpfc_nodelist *ndlp, void *arg, uint32_t evt)
1358{
1359 struct lpfc_hba *phba;
1360 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1361 MAILBOX_t *mb = &pmb->u.mb;
1362 uint16_t rpi;
1363
1364 phba = vport->phba;
1365
1366 if (!(phba->pport->load_flag & FC_UNLOADING) &&
1367 !mb->mbxStatus) {
1368 rpi = pmb->u.mb.un.varWords[0];
1369 lpfc_release_rpi(phba, vport, ndlp, rpi);
1370 }
1371 return ndlp->nlp_state;
1372}
1373
1374static uint32_t
1375lpfc_device_rm_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1376 void *arg, uint32_t evt)
1377{
1378 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1379
1380 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1381 spin_lock_irq(shost->host_lock);
1382 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1383 spin_unlock_irq(shost->host_lock);
1384 return ndlp->nlp_state;
1385 } else {
1386
1387 lpfc_els_abort(vport->phba, ndlp);
1388
1389 lpfc_drop_node(vport, ndlp);
1390 return NLP_STE_FREED_NODE;
1391 }
1392}
1393
1394static uint32_t
1395lpfc_device_recov_plogi_issue(struct lpfc_vport *vport,
1396 struct lpfc_nodelist *ndlp,
1397 void *arg,
1398 uint32_t evt)
1399{
1400 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1401 struct lpfc_hba *phba = vport->phba;
1402
1403
1404
1405
1406 if (vport->fc_flag & FC_RSCN_DEFERRED)
1407 return ndlp->nlp_state;
1408
1409
1410 lpfc_els_abort(phba, ndlp);
1411
1412 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
1413 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1414 spin_lock_irq(shost->host_lock);
1415 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1416 spin_unlock_irq(shost->host_lock);
1417
1418 return ndlp->nlp_state;
1419}
1420
1421static uint32_t
1422lpfc_rcv_plogi_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1423 void *arg, uint32_t evt)
1424{
1425 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1426 struct lpfc_hba *phba = vport->phba;
1427 struct lpfc_iocbq *cmdiocb;
1428
1429
1430 lpfc_els_abort(phba, ndlp);
1431
1432 cmdiocb = (struct lpfc_iocbq *) arg;
1433
1434 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
1435 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1436 spin_lock_irq(shost->host_lock);
1437 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1438 spin_unlock_irq(shost->host_lock);
1439 if (vport->num_disc_nodes)
1440 lpfc_more_adisc(vport);
1441 }
1442 return ndlp->nlp_state;
1443 }
1444 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1445 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
1446 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
1447
1448 return ndlp->nlp_state;
1449}
1450
1451static uint32_t
1452lpfc_rcv_prli_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1453 void *arg, uint32_t evt)
1454{
1455 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1456
1457 if (lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1458 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1459 return ndlp->nlp_state;
1460}
1461
1462static uint32_t
1463lpfc_rcv_logo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1464 void *arg, uint32_t evt)
1465{
1466 struct lpfc_hba *phba = vport->phba;
1467 struct lpfc_iocbq *cmdiocb;
1468
1469 cmdiocb = (struct lpfc_iocbq *) arg;
1470
1471
1472 lpfc_els_abort(phba, ndlp);
1473
1474 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1475 return ndlp->nlp_state;
1476}
1477
1478static uint32_t
1479lpfc_rcv_padisc_adisc_issue(struct lpfc_vport *vport,
1480 struct lpfc_nodelist *ndlp,
1481 void *arg, uint32_t evt)
1482{
1483 struct lpfc_iocbq *cmdiocb;
1484
1485 cmdiocb = (struct lpfc_iocbq *) arg;
1486
1487 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1488 return ndlp->nlp_state;
1489}
1490
1491static uint32_t
1492lpfc_rcv_prlo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1493 void *arg, uint32_t evt)
1494{
1495 struct lpfc_iocbq *cmdiocb;
1496
1497 cmdiocb = (struct lpfc_iocbq *) arg;
1498
1499
1500 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
1501 return ndlp->nlp_state;
1502}
1503
1504static uint32_t
1505lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport,
1506 struct lpfc_nodelist *ndlp,
1507 void *arg, uint32_t evt)
1508{
1509 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1510 struct lpfc_hba *phba = vport->phba;
1511 struct lpfc_iocbq *cmdiocb, *rspiocb;
1512 IOCB_t *irsp;
1513 ADISC *ap;
1514 int rc;
1515
1516 cmdiocb = (struct lpfc_iocbq *) arg;
1517 rspiocb = cmdiocb->context_un.rsp_iocb;
1518
1519 ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1520 irsp = &rspiocb->iocb;
1521
1522 if ((irsp->ulpStatus) ||
1523 (!lpfc_check_adisc(vport, ndlp, &ap->nodeName, &ap->portName))) {
1524
1525 mod_timer(&ndlp->nlp_delayfunc,
1526 jiffies + msecs_to_jiffies(1000));
1527 spin_lock_irq(shost->host_lock);
1528 ndlp->nlp_flag |= NLP_DELAY_TMO;
1529 spin_unlock_irq(shost->host_lock);
1530 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1531
1532 memset(&ndlp->nlp_nodename, 0, sizeof(struct lpfc_name));
1533 memset(&ndlp->nlp_portname, 0, sizeof(struct lpfc_name));
1534
1535 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1536 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1537 lpfc_unreg_rpi(vport, ndlp);
1538 return ndlp->nlp_state;
1539 }
1540
1541 if (phba->sli_rev == LPFC_SLI_REV4) {
1542 rc = lpfc_sli4_resume_rpi(ndlp, NULL, NULL);
1543 if (rc) {
1544
1545 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1546 return ndlp->nlp_state;
1547 }
1548 }
1549
1550 if (ndlp->nlp_type & NLP_FCP_TARGET) {
1551 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1552 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
1553 } else {
1554 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1555 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1556 }
1557
1558 return ndlp->nlp_state;
1559}
1560
1561static uint32_t
1562lpfc_device_rm_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1563 void *arg, uint32_t evt)
1564{
1565 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1566
1567 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1568 spin_lock_irq(shost->host_lock);
1569 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1570 spin_unlock_irq(shost->host_lock);
1571 return ndlp->nlp_state;
1572 } else {
1573
1574 lpfc_els_abort(vport->phba, ndlp);
1575
1576 lpfc_drop_node(vport, ndlp);
1577 return NLP_STE_FREED_NODE;
1578 }
1579}
1580
1581static uint32_t
1582lpfc_device_recov_adisc_issue(struct lpfc_vport *vport,
1583 struct lpfc_nodelist *ndlp,
1584 void *arg,
1585 uint32_t evt)
1586{
1587 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1588 struct lpfc_hba *phba = vport->phba;
1589
1590
1591
1592
1593 if (vport->fc_flag & FC_RSCN_DEFERRED)
1594 return ndlp->nlp_state;
1595
1596
1597 lpfc_els_abort(phba, ndlp);
1598
1599 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1600 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1601 spin_lock_irq(shost->host_lock);
1602 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1603 spin_unlock_irq(shost->host_lock);
1604 lpfc_disc_set_adisc(vport, ndlp);
1605 return ndlp->nlp_state;
1606}
1607
1608static uint32_t
1609lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport *vport,
1610 struct lpfc_nodelist *ndlp,
1611 void *arg,
1612 uint32_t evt)
1613{
1614 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1615
1616 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1617 return ndlp->nlp_state;
1618}
1619
1620static uint32_t
1621lpfc_rcv_prli_reglogin_issue(struct lpfc_vport *vport,
1622 struct lpfc_nodelist *ndlp,
1623 void *arg,
1624 uint32_t evt)
1625{
1626 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1627 struct ls_rjt stat;
1628
1629 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) {
1630 return ndlp->nlp_state;
1631 }
1632 if (vport->phba->nvmet_support) {
1633
1634
1635
1636
1637 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
1638 lpfc_rcv_prli(vport, ndlp, cmdiocb);
1639 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1640 } else {
1641
1642
1643
1644
1645 memset(&stat, 0, sizeof(struct ls_rjt));
1646 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY;
1647 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
1648 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
1649 ndlp, NULL);
1650 return ndlp->nlp_state;
1651 }
1652 } else {
1653
1654 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1655 }
1656 return ndlp->nlp_state;
1657}
1658
1659static uint32_t
1660lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
1661 struct lpfc_nodelist *ndlp,
1662 void *arg,
1663 uint32_t evt)
1664{
1665 struct lpfc_hba *phba = vport->phba;
1666 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1667 LPFC_MBOXQ_t *mb;
1668 LPFC_MBOXQ_t *nextmb;
1669 struct lpfc_dmabuf *mp;
1670 struct lpfc_nodelist *ns_ndlp;
1671
1672 cmdiocb = (struct lpfc_iocbq *) arg;
1673
1674
1675 if ((mb = phba->sli.mbox_active)) {
1676 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1677 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
1678 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1679 lpfc_nlp_put(ndlp);
1680 mb->ctx_ndlp = NULL;
1681 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1682 }
1683 }
1684
1685 spin_lock_irq(&phba->hbalock);
1686 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1687 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1688 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
1689 mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
1690 if (mp) {
1691 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
1692 kfree(mp);
1693 }
1694 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1695 lpfc_nlp_put(ndlp);
1696 list_del(&mb->list);
1697 phba->sli.mboxq_cnt--;
1698 mempool_free(mb, phba->mbox_mem_pool);
1699 }
1700 }
1701 spin_unlock_irq(&phba->hbalock);
1702
1703
1704 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
1705 ns_ndlp = lpfc_findnode_did(vport, NameServer_DID);
1706 if (ns_ndlp && NLP_CHK_NODE_ACT(ns_ndlp))
1707 lpfc_els_abort(phba, ns_ndlp);
1708 }
1709
1710 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1711 return ndlp->nlp_state;
1712}
1713
1714static uint32_t
1715lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport *vport,
1716 struct lpfc_nodelist *ndlp,
1717 void *arg,
1718 uint32_t evt)
1719{
1720 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1721
1722 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1723 return ndlp->nlp_state;
1724}
1725
1726static uint32_t
1727lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport *vport,
1728 struct lpfc_nodelist *ndlp,
1729 void *arg,
1730 uint32_t evt)
1731{
1732 struct lpfc_iocbq *cmdiocb;
1733
1734 cmdiocb = (struct lpfc_iocbq *) arg;
1735 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1736 return ndlp->nlp_state;
1737}
1738
1739static uint32_t
1740lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
1741 struct lpfc_nodelist *ndlp,
1742 void *arg,
1743 uint32_t evt)
1744{
1745 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1746 struct lpfc_hba *phba = vport->phba;
1747 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1748 MAILBOX_t *mb = &pmb->u.mb;
1749 uint32_t did = mb->un.varWords[1];
1750
1751 if (mb->mbxStatus) {
1752
1753 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1754 "0246 RegLogin failed Data: x%x x%x x%x x%x "
1755 "x%x\n",
1756 did, mb->mbxStatus, vport->port_state,
1757 mb->un.varRegLogin.vpi,
1758 mb->un.varRegLogin.rpi);
1759
1760
1761
1762
1763 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1764 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1765 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1766 return ndlp->nlp_state;
1767 }
1768
1769
1770 mod_timer(&ndlp->nlp_delayfunc,
1771 jiffies + msecs_to_jiffies(1000 * 1));
1772 spin_lock_irq(shost->host_lock);
1773 ndlp->nlp_flag |= NLP_DELAY_TMO;
1774 spin_unlock_irq(shost->host_lock);
1775 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
1776
1777 lpfc_issue_els_logo(vport, ndlp, 0);
1778 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1779 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1780 return ndlp->nlp_state;
1781 }
1782
1783
1784 if (phba->sli_rev < LPFC_SLI_REV4)
1785 ndlp->nlp_rpi = mb->un.varWords[0];
1786
1787 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
1788
1789
1790 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1791 "3066 RegLogin Complete on x%x x%x x%x\n",
1792 did, ndlp->nlp_type, ndlp->nlp_fc4_type);
1793 if (!(ndlp->nlp_type & NLP_FABRIC) &&
1794 (phba->nvmet_support == 0)) {
1795
1796
1797
1798
1799
1800 if (vport->fc_flag & FC_PT2PT) {
1801
1802
1803
1804
1805 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1806 if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1807 (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
1808 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
1809
1810 lpfc_nvme_update_localport(vport);
1811 }
1812
1813 } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
1814 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1815
1816 } else if (ndlp->nlp_fc4_type == 0) {
1817
1818
1819
1820
1821 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
1822 lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID, 0,
1823 ndlp->nlp_DID);
1824 return ndlp->nlp_state;
1825 }
1826 ndlp->nlp_fc4_type = NLP_FC4_FCP;
1827 }
1828
1829 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1830 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1831 if (lpfc_issue_els_prli(vport, ndlp, 0)) {
1832 lpfc_issue_els_logo(vport, ndlp, 0);
1833 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1834 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1835 }
1836 } else {
1837 if ((vport->fc_flag & FC_PT2PT) && phba->nvmet_support)
1838 phba->targetport->port_id = vport->fc_myDID;
1839
1840
1841
1842
1843 if (ndlp->nlp_type & NLP_FABRIC) {
1844 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1845 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
1846 }
1847 }
1848 return ndlp->nlp_state;
1849}
1850
1851static uint32_t
1852lpfc_device_rm_reglogin_issue(struct lpfc_vport *vport,
1853 struct lpfc_nodelist *ndlp,
1854 void *arg,
1855 uint32_t evt)
1856{
1857 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1858
1859 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
1860 spin_lock_irq(shost->host_lock);
1861 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1862 spin_unlock_irq(shost->host_lock);
1863 return ndlp->nlp_state;
1864 } else {
1865 lpfc_drop_node(vport, ndlp);
1866 return NLP_STE_FREED_NODE;
1867 }
1868}
1869
1870static uint32_t
1871lpfc_device_recov_reglogin_issue(struct lpfc_vport *vport,
1872 struct lpfc_nodelist *ndlp,
1873 void *arg,
1874 uint32_t evt)
1875{
1876 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1877
1878
1879
1880
1881 if (vport->fc_flag & FC_RSCN_DEFERRED)
1882 return ndlp->nlp_state;
1883
1884 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1885 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1886 spin_lock_irq(shost->host_lock);
1887
1888
1889
1890
1891 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED) ||
1892 !vport->phba->nvmet_support)
1893 ndlp->nlp_flag |= NLP_IGNR_REG_CMPL;
1894
1895 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1896 spin_unlock_irq(shost->host_lock);
1897 lpfc_disc_set_adisc(vport, ndlp);
1898 return ndlp->nlp_state;
1899}
1900
1901static uint32_t
1902lpfc_rcv_plogi_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1903 void *arg, uint32_t evt)
1904{
1905 struct lpfc_iocbq *cmdiocb;
1906
1907 cmdiocb = (struct lpfc_iocbq *) arg;
1908
1909 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
1910 return ndlp->nlp_state;
1911}
1912
1913static uint32_t
1914lpfc_rcv_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1915 void *arg, uint32_t evt)
1916{
1917 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1918
1919 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
1920 return ndlp->nlp_state;
1921 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
1922 return ndlp->nlp_state;
1923}
1924
1925static uint32_t
1926lpfc_rcv_logo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1927 void *arg, uint32_t evt)
1928{
1929 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1930
1931
1932 lpfc_els_abort(vport->phba, ndlp);
1933
1934 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
1935 return ndlp->nlp_state;
1936}
1937
1938static uint32_t
1939lpfc_rcv_padisc_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1940 void *arg, uint32_t evt)
1941{
1942 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1943
1944 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
1945 return ndlp->nlp_state;
1946}
1947
1948
1949
1950
1951
1952
1953static uint32_t
1954lpfc_rcv_prlo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1955 void *arg, uint32_t evt)
1956{
1957 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1958
1959 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1960 return ndlp->nlp_state;
1961}
1962
1963static uint32_t
1964lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1965 void *arg, uint32_t evt)
1966{
1967 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1968 struct lpfc_iocbq *cmdiocb, *rspiocb;
1969 struct lpfc_hba *phba = vport->phba;
1970 IOCB_t *irsp;
1971 PRLI *npr;
1972 struct lpfc_nvme_prli *nvpr;
1973 void *temp_ptr;
1974
1975 cmdiocb = (struct lpfc_iocbq *) arg;
1976 rspiocb = cmdiocb->context_un.rsp_iocb;
1977
1978
1979
1980
1981
1982 npr = NULL;
1983 nvpr = NULL;
1984 temp_ptr = lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb);
1985 if (cmdiocb->iocb_flag & LPFC_PRLI_FCP_REQ)
1986 npr = (PRLI *) temp_ptr;
1987 else if (cmdiocb->iocb_flag & LPFC_PRLI_NVME_REQ)
1988 nvpr = (struct lpfc_nvme_prli *) temp_ptr;
1989
1990 irsp = &rspiocb->iocb;
1991 if (irsp->ulpStatus) {
1992 if ((vport->port_type == LPFC_NPIV_PORT) &&
1993 vport->cfg_restrict_login) {
1994 goto out;
1995 }
1996
1997
1998 if (npr)
1999 ndlp->nlp_fc4_type &= ~NLP_FC4_FCP;
2000 if (nvpr)
2001 ndlp->nlp_fc4_type &= ~NLP_FC4_NVME;
2002
2003
2004 goto out_err;
2005 }
2006
2007 if (npr && (npr->acceptRspCode == PRLI_REQ_EXECUTED) &&
2008 (npr->prliType == PRLI_FCP_TYPE)) {
2009 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2010 "6028 FCP NPR PRLI Cmpl Init %d Target %d\n",
2011 npr->initiatorFunc,
2012 npr->targetFunc);
2013 if (npr->initiatorFunc)
2014 ndlp->nlp_type |= NLP_FCP_INITIATOR;
2015 if (npr->targetFunc) {
2016 ndlp->nlp_type |= NLP_FCP_TARGET;
2017 if (npr->writeXferRdyDis)
2018 ndlp->nlp_flag |= NLP_FIRSTBURST;
2019 }
2020 if (npr->Retry)
2021 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
2022
2023 } else if (nvpr &&
2024 (bf_get_be32(prli_acc_rsp_code, nvpr) ==
2025 PRLI_REQ_EXECUTED) &&
2026 (bf_get_be32(prli_type_code, nvpr) ==
2027 PRLI_NVME_TYPE)) {
2028
2029
2030 if (bf_get_be32(prli_init, nvpr))
2031 ndlp->nlp_type |= NLP_NVME_INITIATOR;
2032
2033 if (phba->nsler && bf_get_be32(prli_nsler, nvpr))
2034 ndlp->nlp_nvme_info |= NLP_NVME_NSLER;
2035 else
2036 ndlp->nlp_nvme_info &= ~NLP_NVME_NSLER;
2037
2038
2039 if (bf_get_be32(prli_tgt, nvpr)) {
2040
2041
2042
2043
2044 ndlp->nlp_type |= NLP_NVME_TARGET;
2045 if (bf_get_be32(prli_disc, nvpr))
2046 ndlp->nlp_type |= NLP_NVME_DISCOVERY;
2047
2048
2049
2050
2051
2052
2053
2054 if ((bf_get_be32(prli_fba, nvpr) == 1) &&
2055 (phba->cfg_nvme_enable_fb) &&
2056 (!phba->nvmet_support)) {
2057
2058
2059
2060 ndlp->nlp_flag |= NLP_FIRSTBURST;
2061 ndlp->nvme_fb_size = bf_get_be32(prli_fb_sz,
2062 nvpr);
2063
2064
2065 if (ndlp->nvme_fb_size)
2066 ndlp->nvme_fb_size <<=
2067 LPFC_NVME_FB_SHIFT;
2068 else
2069 ndlp->nvme_fb_size = LPFC_NVME_MAX_FB;
2070 }
2071 }
2072
2073 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2074 "6029 NVME PRLI Cmpl w1 x%08x "
2075 "w4 x%08x w5 x%08x flag x%x, "
2076 "fcp_info x%x nlp_type x%x\n",
2077 be32_to_cpu(nvpr->word1),
2078 be32_to_cpu(nvpr->word4),
2079 be32_to_cpu(nvpr->word5),
2080 ndlp->nlp_flag, ndlp->nlp_fcp_info,
2081 ndlp->nlp_type);
2082 }
2083 if (!(ndlp->nlp_type & NLP_FCP_TARGET) &&
2084 (vport->port_type == LPFC_NPIV_PORT) &&
2085 vport->cfg_restrict_login) {
2086out:
2087 spin_lock_irq(shost->host_lock);
2088 ndlp->nlp_flag |= NLP_TARGET_REMOVE;
2089 spin_unlock_irq(shost->host_lock);
2090 lpfc_issue_els_logo(vport, ndlp, 0);
2091
2092 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2093 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2094 return ndlp->nlp_state;
2095 }
2096
2097out_err:
2098
2099
2100
2101 if (ndlp->fc4_prli_sent == 0) {
2102 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2103 if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET))
2104 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
2105 else if (ndlp->nlp_type &
2106 (NLP_FCP_INITIATOR | NLP_NVME_INITIATOR))
2107 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
2108 } else
2109 lpfc_printf_vlog(vport,
2110 KERN_INFO, LOG_ELS,
2111 "3067 PRLI's still outstanding "
2112 "on x%06x - count %d, Pend Node Mode "
2113 "transition...\n",
2114 ndlp->nlp_DID, ndlp->fc4_prli_sent);
2115
2116 return ndlp->nlp_state;
2117}
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137static uint32_t
2138lpfc_device_rm_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2139 void *arg, uint32_t evt)
2140{
2141 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2142
2143 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2144 spin_lock_irq(shost->host_lock);
2145 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2146 spin_unlock_irq(shost->host_lock);
2147 return ndlp->nlp_state;
2148 } else {
2149
2150 lpfc_els_abort(vport->phba, ndlp);
2151
2152 lpfc_drop_node(vport, ndlp);
2153 return NLP_STE_FREED_NODE;
2154 }
2155}
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174static uint32_t
2175lpfc_device_recov_prli_issue(struct lpfc_vport *vport,
2176 struct lpfc_nodelist *ndlp,
2177 void *arg,
2178 uint32_t evt)
2179{
2180 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2181 struct lpfc_hba *phba = vport->phba;
2182
2183
2184
2185
2186 if (vport->fc_flag & FC_RSCN_DEFERRED)
2187 return ndlp->nlp_state;
2188
2189
2190 lpfc_els_abort(phba, ndlp);
2191
2192 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
2193 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2194 spin_lock_irq(shost->host_lock);
2195 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2196 spin_unlock_irq(shost->host_lock);
2197 lpfc_disc_set_adisc(vport, ndlp);
2198 return ndlp->nlp_state;
2199}
2200
2201static uint32_t
2202lpfc_rcv_plogi_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2203 void *arg, uint32_t evt)
2204{
2205 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2206 struct ls_rjt stat;
2207
2208 memset(&stat, 0, sizeof(struct ls_rjt));
2209 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2210 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2211 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2212 return ndlp->nlp_state;
2213}
2214
2215static uint32_t
2216lpfc_rcv_prli_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2217 void *arg, uint32_t evt)
2218{
2219 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2220 struct ls_rjt stat;
2221
2222 memset(&stat, 0, sizeof(struct ls_rjt));
2223 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2224 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2225 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2226 return ndlp->nlp_state;
2227}
2228
2229static uint32_t
2230lpfc_rcv_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2231 void *arg, uint32_t evt)
2232{
2233 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2234 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2235
2236 spin_lock_irq(shost->host_lock);
2237 ndlp->nlp_flag |= NLP_LOGO_ACC;
2238 spin_unlock_irq(shost->host_lock);
2239 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2240 return ndlp->nlp_state;
2241}
2242
2243static uint32_t
2244lpfc_rcv_padisc_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2245 void *arg, uint32_t evt)
2246{
2247 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2248 struct ls_rjt stat;
2249
2250 memset(&stat, 0, sizeof(struct ls_rjt));
2251 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2252 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2253 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2254 return ndlp->nlp_state;
2255}
2256
2257static uint32_t
2258lpfc_rcv_prlo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2259 void *arg, uint32_t evt)
2260{
2261 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
2262 struct ls_rjt stat;
2263
2264 memset(&stat, 0, sizeof(struct ls_rjt));
2265 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2266 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2267 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2268 return ndlp->nlp_state;
2269}
2270
2271static uint32_t
2272lpfc_cmpl_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2273 void *arg, uint32_t evt)
2274{
2275 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2276
2277 ndlp->nlp_prev_state = NLP_STE_LOGO_ISSUE;
2278 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2279 spin_lock_irq(shost->host_lock);
2280 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2281 spin_unlock_irq(shost->host_lock);
2282 lpfc_disc_set_adisc(vport, ndlp);
2283 return ndlp->nlp_state;
2284}
2285
2286static uint32_t
2287lpfc_device_rm_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2288 void *arg, uint32_t evt)
2289{
2290
2291
2292
2293
2294
2295 lpfc_unreg_rpi(vport, ndlp);
2296
2297 lpfc_els_abort(vport->phba, ndlp);
2298 lpfc_drop_node(vport, ndlp);
2299 return NLP_STE_FREED_NODE;
2300}
2301
2302static uint32_t
2303lpfc_device_recov_logo_issue(struct lpfc_vport *vport,
2304 struct lpfc_nodelist *ndlp,
2305 void *arg, uint32_t evt)
2306{
2307
2308
2309
2310
2311
2312 return ndlp->nlp_state;
2313}
2314
2315static uint32_t
2316lpfc_rcv_plogi_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2317 void *arg, uint32_t evt)
2318{
2319 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2320
2321 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2322 return ndlp->nlp_state;
2323}
2324
2325static uint32_t
2326lpfc_rcv_prli_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2327 void *arg, uint32_t evt)
2328{
2329 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2330
2331 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2332 return ndlp->nlp_state;
2333
2334 lpfc_rcv_prli(vport, ndlp, cmdiocb);
2335 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2336 return ndlp->nlp_state;
2337}
2338
2339static uint32_t
2340lpfc_rcv_logo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2341 void *arg, uint32_t evt)
2342{
2343 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2344
2345 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2346 return ndlp->nlp_state;
2347}
2348
2349static uint32_t
2350lpfc_rcv_padisc_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2351 void *arg, uint32_t evt)
2352{
2353 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2354
2355 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2356 return ndlp->nlp_state;
2357}
2358
2359static uint32_t
2360lpfc_rcv_prlo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2361 void *arg, uint32_t evt)
2362{
2363 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2364
2365 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
2366 return ndlp->nlp_state;
2367}
2368
2369static uint32_t
2370lpfc_device_recov_unmap_node(struct lpfc_vport *vport,
2371 struct lpfc_nodelist *ndlp,
2372 void *arg,
2373 uint32_t evt)
2374{
2375 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2376
2377 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
2378 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2379 spin_lock_irq(shost->host_lock);
2380 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2381 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2382 spin_unlock_irq(shost->host_lock);
2383 lpfc_disc_set_adisc(vport, ndlp);
2384
2385 return ndlp->nlp_state;
2386}
2387
2388static uint32_t
2389lpfc_rcv_plogi_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2390 void *arg, uint32_t evt)
2391{
2392 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2393
2394 lpfc_rcv_plogi(vport, ndlp, cmdiocb);
2395 return ndlp->nlp_state;
2396}
2397
2398static uint32_t
2399lpfc_rcv_prli_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2400 void *arg, uint32_t evt)
2401{
2402 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2403
2404 if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb))
2405 return ndlp->nlp_state;
2406 lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp);
2407 return ndlp->nlp_state;
2408}
2409
2410static uint32_t
2411lpfc_rcv_logo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2412 void *arg, uint32_t evt)
2413{
2414 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2415
2416 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2417 return ndlp->nlp_state;
2418}
2419
2420static uint32_t
2421lpfc_rcv_padisc_mapped_node(struct lpfc_vport *vport,
2422 struct lpfc_nodelist *ndlp,
2423 void *arg, uint32_t evt)
2424{
2425 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2426
2427 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2428 return ndlp->nlp_state;
2429}
2430
2431static uint32_t
2432lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2433 void *arg, uint32_t evt)
2434{
2435 struct lpfc_hba *phba = vport->phba;
2436 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2437
2438
2439 lpfc_sli_abort_iocb(vport, &phba->sli.sli3_ring[LPFC_FCP_RING],
2440 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
2441
2442
2443 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
2444 return ndlp->nlp_state;
2445}
2446
2447static uint32_t
2448lpfc_device_recov_mapped_node(struct lpfc_vport *vport,
2449 struct lpfc_nodelist *ndlp,
2450 void *arg,
2451 uint32_t evt)
2452{
2453 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2454
2455 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
2456 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2457 spin_lock_irq(shost->host_lock);
2458 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2459 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2460 spin_unlock_irq(shost->host_lock);
2461 lpfc_disc_set_adisc(vport, ndlp);
2462 return ndlp->nlp_state;
2463}
2464
2465static uint32_t
2466lpfc_rcv_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2467 void *arg, uint32_t evt)
2468{
2469 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2470 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2471
2472
2473 if (ndlp->nlp_flag & (NLP_LOGO_SND | NLP_LOGO_ACC))
2474 return ndlp->nlp_state;
2475 if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) {
2476 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2477 spin_lock_irq(shost->host_lock);
2478 ndlp->nlp_flag &= ~(NLP_NPR_ADISC | NLP_NPR_2B_DISC);
2479 spin_unlock_irq(shost->host_lock);
2480 } else if (!(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2481
2482 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2483 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2484 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2485 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2486 }
2487 }
2488 return ndlp->nlp_state;
2489}
2490
2491static uint32_t
2492lpfc_rcv_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2493 void *arg, uint32_t evt)
2494{
2495 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2496 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2497 struct ls_rjt stat;
2498
2499 memset(&stat, 0, sizeof (struct ls_rjt));
2500 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
2501 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
2502 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
2503
2504 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
2505 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2506 spin_lock_irq(shost->host_lock);
2507 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2508 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2509 spin_unlock_irq(shost->host_lock);
2510 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2511 lpfc_issue_els_adisc(vport, ndlp, 0);
2512 } else {
2513 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2514 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2515 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2516 }
2517 }
2518 return ndlp->nlp_state;
2519}
2520
2521static uint32_t
2522lpfc_rcv_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2523 void *arg, uint32_t evt)
2524{
2525 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2526
2527 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
2528 return ndlp->nlp_state;
2529}
2530
2531static uint32_t
2532lpfc_rcv_padisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2533 void *arg, uint32_t evt)
2534{
2535 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2536
2537 lpfc_rcv_padisc(vport, ndlp, cmdiocb);
2538
2539
2540
2541
2542
2543 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
2544 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
2545 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
2546 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2547 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2548 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
2549 lpfc_issue_els_adisc(vport, ndlp, 0);
2550 } else {
2551 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
2552 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
2553 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
2554 }
2555 }
2556 return ndlp->nlp_state;
2557}
2558
2559static uint32_t
2560lpfc_rcv_prlo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2561 void *arg, uint32_t evt)
2562{
2563 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2564 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
2565
2566 spin_lock_irq(shost->host_lock);
2567 ndlp->nlp_flag |= NLP_LOGO_ACC;
2568 spin_unlock_irq(shost->host_lock);
2569
2570 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2571
2572 if ((ndlp->nlp_flag & NLP_DELAY_TMO) == 0) {
2573 mod_timer(&ndlp->nlp_delayfunc,
2574 jiffies + msecs_to_jiffies(1000 * 1));
2575 spin_lock_irq(shost->host_lock);
2576 ndlp->nlp_flag |= NLP_DELAY_TMO;
2577 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2578 spin_unlock_irq(shost->host_lock);
2579 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
2580 } else {
2581 spin_lock_irq(shost->host_lock);
2582 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2583 spin_unlock_irq(shost->host_lock);
2584 }
2585 return ndlp->nlp_state;
2586}
2587
2588static uint32_t
2589lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2590 void *arg, uint32_t evt)
2591{
2592 struct lpfc_iocbq *cmdiocb, *rspiocb;
2593 IOCB_t *irsp;
2594 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2595
2596 cmdiocb = (struct lpfc_iocbq *) arg;
2597 rspiocb = cmdiocb->context_un.rsp_iocb;
2598
2599 irsp = &rspiocb->iocb;
2600 if (irsp->ulpStatus) {
2601 spin_lock_irq(shost->host_lock);
2602 ndlp->nlp_flag |= NLP_DEFER_RM;
2603 spin_unlock_irq(shost->host_lock);
2604 return NLP_STE_FREED_NODE;
2605 }
2606 return ndlp->nlp_state;
2607}
2608
2609static uint32_t
2610lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2611 void *arg, uint32_t evt)
2612{
2613 struct lpfc_iocbq *cmdiocb, *rspiocb;
2614 IOCB_t *irsp;
2615
2616 cmdiocb = (struct lpfc_iocbq *) arg;
2617 rspiocb = cmdiocb->context_un.rsp_iocb;
2618
2619 irsp = &rspiocb->iocb;
2620 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2621 lpfc_drop_node(vport, ndlp);
2622 return NLP_STE_FREED_NODE;
2623 }
2624 return ndlp->nlp_state;
2625}
2626
2627static uint32_t
2628lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2629 void *arg, uint32_t evt)
2630{
2631 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2632
2633
2634 if (ndlp->nlp_DID == Fabric_DID) {
2635 spin_lock_irq(shost->host_lock);
2636 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
2637 spin_unlock_irq(shost->host_lock);
2638 }
2639 lpfc_unreg_rpi(vport, ndlp);
2640 return ndlp->nlp_state;
2641}
2642
2643static uint32_t
2644lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2645 void *arg, uint32_t evt)
2646{
2647 struct lpfc_iocbq *cmdiocb, *rspiocb;
2648 IOCB_t *irsp;
2649
2650 cmdiocb = (struct lpfc_iocbq *) arg;
2651 rspiocb = cmdiocb->context_un.rsp_iocb;
2652
2653 irsp = &rspiocb->iocb;
2654 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
2655 lpfc_drop_node(vport, ndlp);
2656 return NLP_STE_FREED_NODE;
2657 }
2658 return ndlp->nlp_state;
2659}
2660
2661static uint32_t
2662lpfc_cmpl_reglogin_npr_node(struct lpfc_vport *vport,
2663 struct lpfc_nodelist *ndlp,
2664 void *arg, uint32_t evt)
2665{
2666 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
2667 MAILBOX_t *mb = &pmb->u.mb;
2668
2669 if (!mb->mbxStatus) {
2670
2671 if (vport->phba->sli_rev < LPFC_SLI_REV4)
2672 ndlp->nlp_rpi = mb->un.varWords[0];
2673 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
2674 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
2675 lpfc_unreg_rpi(vport, ndlp);
2676 }
2677 } else {
2678 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
2679 lpfc_drop_node(vport, ndlp);
2680 return NLP_STE_FREED_NODE;
2681 }
2682 }
2683 return ndlp->nlp_state;
2684}
2685
2686static uint32_t
2687lpfc_device_rm_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2688 void *arg, uint32_t evt)
2689{
2690 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2691
2692 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) {
2693 spin_lock_irq(shost->host_lock);
2694 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
2695 spin_unlock_irq(shost->host_lock);
2696 return ndlp->nlp_state;
2697 }
2698 lpfc_drop_node(vport, ndlp);
2699 return NLP_STE_FREED_NODE;
2700}
2701
2702static uint32_t
2703lpfc_device_recov_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2704 void *arg, uint32_t evt)
2705{
2706 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2707
2708
2709
2710
2711 if (vport->fc_flag & FC_RSCN_DEFERRED)
2712 return ndlp->nlp_state;
2713
2714 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2715 spin_lock_irq(shost->host_lock);
2716 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
2717 ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
2718 spin_unlock_irq(shost->host_lock);
2719 return ndlp->nlp_state;
2720}
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT])
2780 (struct lpfc_vport *, struct lpfc_nodelist *, void *, uint32_t) = {
2781
2782 lpfc_rcv_plogi_unused_node,
2783 lpfc_rcv_els_unused_node,
2784 lpfc_rcv_logo_unused_node,
2785 lpfc_rcv_els_unused_node,
2786 lpfc_rcv_els_unused_node,
2787 lpfc_rcv_els_unused_node,
2788 lpfc_disc_illegal,
2789 lpfc_disc_illegal,
2790 lpfc_cmpl_logo_unused_node,
2791 lpfc_disc_illegal,
2792 lpfc_disc_illegal,
2793 lpfc_device_rm_unused_node,
2794 lpfc_device_recov_unused_node,
2795
2796 lpfc_rcv_plogi_plogi_issue,
2797 lpfc_rcv_prli_plogi_issue,
2798 lpfc_rcv_logo_plogi_issue,
2799 lpfc_rcv_els_plogi_issue,
2800 lpfc_rcv_els_plogi_issue,
2801 lpfc_rcv_els_plogi_issue,
2802 lpfc_cmpl_plogi_plogi_issue,
2803 lpfc_disc_illegal,
2804 lpfc_cmpl_logo_plogi_issue,
2805 lpfc_disc_illegal,
2806 lpfc_cmpl_reglogin_plogi_issue,
2807 lpfc_device_rm_plogi_issue,
2808 lpfc_device_recov_plogi_issue,
2809
2810 lpfc_rcv_plogi_adisc_issue,
2811 lpfc_rcv_prli_adisc_issue,
2812 lpfc_rcv_logo_adisc_issue,
2813 lpfc_rcv_padisc_adisc_issue,
2814 lpfc_rcv_padisc_adisc_issue,
2815 lpfc_rcv_prlo_adisc_issue,
2816 lpfc_disc_illegal,
2817 lpfc_disc_illegal,
2818 lpfc_disc_illegal,
2819 lpfc_cmpl_adisc_adisc_issue,
2820 lpfc_disc_illegal,
2821 lpfc_device_rm_adisc_issue,
2822 lpfc_device_recov_adisc_issue,
2823
2824 lpfc_rcv_plogi_reglogin_issue,
2825 lpfc_rcv_prli_reglogin_issue,
2826 lpfc_rcv_logo_reglogin_issue,
2827 lpfc_rcv_padisc_reglogin_issue,
2828 lpfc_rcv_padisc_reglogin_issue,
2829 lpfc_rcv_prlo_reglogin_issue,
2830 lpfc_cmpl_plogi_illegal,
2831 lpfc_disc_illegal,
2832 lpfc_disc_illegal,
2833 lpfc_disc_illegal,
2834 lpfc_cmpl_reglogin_reglogin_issue,
2835 lpfc_device_rm_reglogin_issue,
2836 lpfc_device_recov_reglogin_issue,
2837
2838 lpfc_rcv_plogi_prli_issue,
2839 lpfc_rcv_prli_prli_issue,
2840 lpfc_rcv_logo_prli_issue,
2841 lpfc_rcv_padisc_prli_issue,
2842 lpfc_rcv_padisc_prli_issue,
2843 lpfc_rcv_prlo_prli_issue,
2844 lpfc_cmpl_plogi_illegal,
2845 lpfc_cmpl_prli_prli_issue,
2846 lpfc_disc_illegal,
2847 lpfc_disc_illegal,
2848 lpfc_disc_illegal,
2849 lpfc_device_rm_prli_issue,
2850 lpfc_device_recov_prli_issue,
2851
2852 lpfc_rcv_plogi_logo_issue,
2853 lpfc_rcv_prli_logo_issue,
2854 lpfc_rcv_logo_logo_issue,
2855 lpfc_rcv_padisc_logo_issue,
2856 lpfc_rcv_padisc_logo_issue,
2857 lpfc_rcv_prlo_logo_issue,
2858 lpfc_cmpl_plogi_illegal,
2859 lpfc_disc_illegal,
2860 lpfc_cmpl_logo_logo_issue,
2861 lpfc_disc_illegal,
2862 lpfc_disc_illegal,
2863 lpfc_device_rm_logo_issue,
2864 lpfc_device_recov_logo_issue,
2865
2866 lpfc_rcv_plogi_unmap_node,
2867 lpfc_rcv_prli_unmap_node,
2868 lpfc_rcv_logo_unmap_node,
2869 lpfc_rcv_padisc_unmap_node,
2870 lpfc_rcv_padisc_unmap_node,
2871 lpfc_rcv_prlo_unmap_node,
2872 lpfc_disc_illegal,
2873 lpfc_disc_illegal,
2874 lpfc_disc_illegal,
2875 lpfc_disc_illegal,
2876 lpfc_disc_illegal,
2877 lpfc_disc_illegal,
2878 lpfc_device_recov_unmap_node,
2879
2880 lpfc_rcv_plogi_mapped_node,
2881 lpfc_rcv_prli_mapped_node,
2882 lpfc_rcv_logo_mapped_node,
2883 lpfc_rcv_padisc_mapped_node,
2884 lpfc_rcv_padisc_mapped_node,
2885 lpfc_rcv_prlo_mapped_node,
2886 lpfc_disc_illegal,
2887 lpfc_disc_illegal,
2888 lpfc_disc_illegal,
2889 lpfc_disc_illegal,
2890 lpfc_disc_illegal,
2891 lpfc_disc_illegal,
2892 lpfc_device_recov_mapped_node,
2893
2894 lpfc_rcv_plogi_npr_node,
2895 lpfc_rcv_prli_npr_node,
2896 lpfc_rcv_logo_npr_node,
2897 lpfc_rcv_padisc_npr_node,
2898 lpfc_rcv_padisc_npr_node,
2899 lpfc_rcv_prlo_npr_node,
2900 lpfc_cmpl_plogi_npr_node,
2901 lpfc_cmpl_prli_npr_node,
2902 lpfc_cmpl_logo_npr_node,
2903 lpfc_cmpl_adisc_npr_node,
2904 lpfc_cmpl_reglogin_npr_node,
2905 lpfc_device_rm_npr_node,
2906 lpfc_device_recov_npr_node,
2907};
2908
2909int
2910lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2911 void *arg, uint32_t evt)
2912{
2913 uint32_t cur_state, rc;
2914 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *,
2915 uint32_t);
2916 uint32_t got_ndlp = 0;
2917 uint32_t data1;
2918
2919 if (lpfc_nlp_get(ndlp))
2920 got_ndlp = 1;
2921
2922 cur_state = ndlp->nlp_state;
2923
2924 data1 = (((uint32_t)ndlp->nlp_fc4_type << 16) |
2925 ((uint32_t)ndlp->nlp_type));
2926
2927 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2928 "0211 DSM in event x%x on NPort x%x in "
2929 "state %d rpi x%x Data: x%x x%x\n",
2930 evt, ndlp->nlp_DID, cur_state, ndlp->nlp_rpi,
2931 ndlp->nlp_flag, data1);
2932
2933 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2934 "DSM in: evt:%d ste:%d did:x%x",
2935 evt, cur_state, ndlp->nlp_DID);
2936
2937 func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt];
2938 rc = (func) (vport, ndlp, arg, evt);
2939
2940
2941 if (got_ndlp) {
2942 data1 = (((uint32_t)ndlp->nlp_fc4_type << 16) |
2943 ((uint32_t)ndlp->nlp_type));
2944 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2945 "0212 DSM out state %d on NPort x%x "
2946 "rpi x%x Data: x%x x%x\n",
2947 rc, ndlp->nlp_DID, ndlp->nlp_rpi, ndlp->nlp_flag,
2948 data1);
2949
2950 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2951 "DSM out: ste:%d did:x%x flg:x%x",
2952 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2953
2954 lpfc_nlp_put(ndlp);
2955 } else {
2956 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2957 "0213 DSM out state %d on NPort free\n", rc);
2958
2959 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2960 "DSM out: ste:%d did:x%x flg:x%x",
2961 rc, 0, 0);
2962 }
2963
2964 return rc;
2965}
2966