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#include <linux/delay.h>
29
30#include <scsi/scsi.h>
31#include <scsi/scsi_device.h>
32#include <scsi/scsi_host.h>
33#include <scsi/scsi_transport_fc.h>
34#include <uapi/scsi/fc/fc_fs.h>
35#include <uapi/scsi/fc/fc_els.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_scsi.h"
44#include "lpfc.h"
45#include "lpfc_logmsg.h"
46#include "lpfc_crtn.h"
47#include "lpfc_vport.h"
48#include "lpfc_debugfs.h"
49
50static int lpfc_els_retry(struct lpfc_hba *, struct lpfc_iocbq *,
51 struct lpfc_iocbq *);
52static void lpfc_cmpl_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *,
53 struct lpfc_iocbq *);
54static void lpfc_fabric_abort_vport(struct lpfc_vport *vport);
55static int lpfc_issue_els_fdisc(struct lpfc_vport *vport,
56 struct lpfc_nodelist *ndlp, uint8_t retry);
57static int lpfc_issue_fabric_iocb(struct lpfc_hba *phba,
58 struct lpfc_iocbq *iocb);
59static void lpfc_cmpl_els_uvem(struct lpfc_hba *, struct lpfc_iocbq *,
60 struct lpfc_iocbq *);
61
62static int lpfc_max_els_tries = 3;
63
64static void lpfc_init_cs_ctl_bitmap(struct lpfc_vport *vport);
65static void lpfc_vmid_set_cs_ctl_range(struct lpfc_vport *vport, u32 min, u32 max);
66static void lpfc_vmid_put_cs_ctl(struct lpfc_vport *vport, u32 ctcl_vmid);
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90int
91lpfc_els_chk_latt(struct lpfc_vport *vport)
92{
93 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
94 struct lpfc_hba *phba = vport->phba;
95 uint32_t ha_copy;
96
97 if (vport->port_state >= LPFC_VPORT_READY ||
98 phba->link_state == LPFC_LINK_DOWN ||
99 phba->sli_rev > LPFC_SLI_REV3)
100 return 0;
101
102
103 if (lpfc_readl(phba->HAregaddr, &ha_copy))
104 return 1;
105
106 if (!(ha_copy & HA_LATT))
107 return 0;
108
109
110 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
111 "0237 Pending Link Event during "
112 "Discovery: State x%x\n",
113 phba->pport->port_state);
114
115
116
117
118
119
120
121 spin_lock_irq(shost->host_lock);
122 vport->fc_flag |= FC_ABORT_DISCOVERY;
123 spin_unlock_irq(shost->host_lock);
124
125 if (phba->link_state != LPFC_CLEAR_LA)
126 lpfc_issue_clear_la(phba, vport);
127
128 return 1;
129}
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159struct lpfc_iocbq *
160lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
161 uint16_t cmdSize, uint8_t retry,
162 struct lpfc_nodelist *ndlp, uint32_t did,
163 uint32_t elscmd)
164{
165 struct lpfc_hba *phba = vport->phba;
166 struct lpfc_iocbq *elsiocb;
167 struct lpfc_dmabuf *pcmd, *prsp, *pbuflist;
168 struct ulp_bde64 *bpl;
169 IOCB_t *icmd;
170
171
172 if (!lpfc_is_link_up(phba))
173 return NULL;
174
175
176 elsiocb = lpfc_sli_get_iocbq(phba);
177
178 if (elsiocb == NULL)
179 return NULL;
180
181
182
183
184
185 if ((did == Fabric_DID) &&
186 (phba->hba_flag & HBA_FIP_SUPPORT) &&
187 ((elscmd == ELS_CMD_FLOGI) ||
188 (elscmd == ELS_CMD_FDISC) ||
189 (elscmd == ELS_CMD_LOGO)))
190 switch (elscmd) {
191 case ELS_CMD_FLOGI:
192 elsiocb->iocb_flag |=
193 ((LPFC_ELS_ID_FLOGI << LPFC_FIP_ELS_ID_SHIFT)
194 & LPFC_FIP_ELS_ID_MASK);
195 break;
196 case ELS_CMD_FDISC:
197 elsiocb->iocb_flag |=
198 ((LPFC_ELS_ID_FDISC << LPFC_FIP_ELS_ID_SHIFT)
199 & LPFC_FIP_ELS_ID_MASK);
200 break;
201 case ELS_CMD_LOGO:
202 elsiocb->iocb_flag |=
203 ((LPFC_ELS_ID_LOGO << LPFC_FIP_ELS_ID_SHIFT)
204 & LPFC_FIP_ELS_ID_MASK);
205 break;
206 }
207 else
208 elsiocb->iocb_flag &= ~LPFC_FIP_ELS_ID_MASK;
209
210 icmd = &elsiocb->iocb;
211
212
213
214 pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
215 if (pcmd)
216 pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys);
217 if (!pcmd || !pcmd->virt)
218 goto els_iocb_free_pcmb_exit;
219
220 INIT_LIST_HEAD(&pcmd->list);
221
222
223 if (expectRsp) {
224 prsp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
225 if (prsp)
226 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
227 &prsp->phys);
228 if (!prsp || !prsp->virt)
229 goto els_iocb_free_prsp_exit;
230 INIT_LIST_HEAD(&prsp->list);
231 } else
232 prsp = NULL;
233
234
235 pbuflist = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
236 if (pbuflist)
237 pbuflist->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
238 &pbuflist->phys);
239 if (!pbuflist || !pbuflist->virt)
240 goto els_iocb_free_pbuf_exit;
241
242 INIT_LIST_HEAD(&pbuflist->list);
243
244 if (expectRsp) {
245 icmd->un.elsreq64.bdl.addrHigh = putPaddrHigh(pbuflist->phys);
246 icmd->un.elsreq64.bdl.addrLow = putPaddrLow(pbuflist->phys);
247 icmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64;
248 icmd->un.elsreq64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64));
249
250 icmd->un.elsreq64.remoteID = did;
251 icmd->ulpCommand = CMD_ELS_REQUEST64_CR;
252 if (elscmd == ELS_CMD_FLOGI)
253 icmd->ulpTimeout = FF_DEF_RATOV * 2;
254 else if (elscmd == ELS_CMD_LOGO)
255 icmd->ulpTimeout = phba->fc_ratov;
256 else
257 icmd->ulpTimeout = phba->fc_ratov * 2;
258 } else {
259 icmd->un.xseq64.bdl.addrHigh = putPaddrHigh(pbuflist->phys);
260 icmd->un.xseq64.bdl.addrLow = putPaddrLow(pbuflist->phys);
261 icmd->un.xseq64.bdl.bdeFlags = BUFF_TYPE_BLP_64;
262 icmd->un.xseq64.bdl.bdeSize = sizeof(struct ulp_bde64);
263 icmd->un.xseq64.xmit_els_remoteID = did;
264 icmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX;
265 }
266 icmd->ulpBdeCount = 1;
267 icmd->ulpLe = 1;
268 icmd->ulpClass = CLASS3;
269
270
271
272
273
274
275 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) ||
276 ((phba->sli_rev == LPFC_SLI_REV4) &&
277 (vport->fc_flag & FC_PT2PT))) {
278
279 if (expectRsp) {
280 icmd->un.elsreq64.myID = vport->fc_myDID;
281
282
283 icmd->ulpContext = phba->vpi_ids[vport->vpi];
284 }
285
286 icmd->ulpCt_h = 0;
287
288 if (elscmd == ELS_CMD_ECHO)
289 icmd->ulpCt_l = 0;
290 else
291 icmd->ulpCt_l = 1;
292 }
293
294 bpl = (struct ulp_bde64 *) pbuflist->virt;
295 bpl->addrLow = le32_to_cpu(putPaddrLow(pcmd->phys));
296 bpl->addrHigh = le32_to_cpu(putPaddrHigh(pcmd->phys));
297 bpl->tus.f.bdeSize = cmdSize;
298 bpl->tus.f.bdeFlags = 0;
299 bpl->tus.w = le32_to_cpu(bpl->tus.w);
300
301 if (expectRsp) {
302 bpl++;
303 bpl->addrLow = le32_to_cpu(putPaddrLow(prsp->phys));
304 bpl->addrHigh = le32_to_cpu(putPaddrHigh(prsp->phys));
305 bpl->tus.f.bdeSize = FCELSSIZE;
306 bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
307 bpl->tus.w = le32_to_cpu(bpl->tus.w);
308 }
309
310 elsiocb->context2 = pcmd;
311 elsiocb->context3 = pbuflist;
312 elsiocb->retry = retry;
313 elsiocb->vport = vport;
314 elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT;
315
316 if (prsp) {
317 list_add(&prsp->list, &pcmd->list);
318 }
319 if (expectRsp) {
320
321 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
322 "0116 Xmit ELS command x%x to remote "
323 "NPORT x%x I/O tag: x%x, port state:x%x "
324 "rpi x%x fc_flag:x%x nlp_flag:x%x vport:x%p\n",
325 elscmd, did, elsiocb->iotag,
326 vport->port_state, ndlp->nlp_rpi,
327 vport->fc_flag, ndlp->nlp_flag, vport);
328 } else {
329
330 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
331 "0117 Xmit ELS response x%x to remote "
332 "NPORT x%x I/O tag: x%x, size: x%x "
333 "port_state x%x rpi x%x fc_flag x%x\n",
334 elscmd, ndlp->nlp_DID, elsiocb->iotag,
335 cmdSize, vport->port_state,
336 ndlp->nlp_rpi, vport->fc_flag);
337 }
338 return elsiocb;
339
340els_iocb_free_pbuf_exit:
341 if (expectRsp)
342 lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
343 kfree(pbuflist);
344
345els_iocb_free_prsp_exit:
346 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
347 kfree(prsp);
348
349els_iocb_free_pcmb_exit:
350 kfree(pcmd);
351 lpfc_sli_release_iocbq(phba, elsiocb);
352 return NULL;
353}
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371int
372lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)
373{
374 struct lpfc_hba *phba = vport->phba;
375 LPFC_MBOXQ_t *mbox;
376 struct lpfc_dmabuf *mp;
377 struct lpfc_nodelist *ndlp;
378 struct serv_parm *sp;
379 int rc;
380 int err = 0;
381
382 sp = &phba->fc_fabparam;
383 ndlp = lpfc_findnode_did(vport, Fabric_DID);
384 if (!ndlp) {
385 err = 1;
386 goto fail;
387 }
388
389 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
390 if (!mbox) {
391 err = 2;
392 goto fail;
393 }
394
395 vport->port_state = LPFC_FABRIC_CFG_LINK;
396 lpfc_config_link(phba, mbox);
397 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
398 mbox->vport = vport;
399
400 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
401 if (rc == MBX_NOT_FINISHED) {
402 err = 3;
403 goto fail_free_mbox;
404 }
405
406 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
407 if (!mbox) {
408 err = 4;
409 goto fail;
410 }
411 rc = lpfc_reg_rpi(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox,
412 ndlp->nlp_rpi);
413 if (rc) {
414 err = 5;
415 goto fail_free_mbox;
416 }
417
418 mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login;
419 mbox->vport = vport;
420
421
422
423 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
424 if (!mbox->ctx_ndlp) {
425 err = 6;
426 goto fail_no_ndlp;
427 }
428
429 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
430 if (rc == MBX_NOT_FINISHED) {
431 err = 7;
432 goto fail_issue_reg_login;
433 }
434
435 return 0;
436
437fail_issue_reg_login:
438
439
440
441 lpfc_nlp_put(ndlp);
442fail_no_ndlp:
443 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
444 lpfc_mbuf_free(phba, mp->virt, mp->phys);
445 kfree(mp);
446fail_free_mbox:
447 mempool_free(mbox, phba->mbox_mem_pool);
448
449fail:
450 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
451 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
452 "0249 Cannot issue Register Fabric login: Err %d\n",
453 err);
454 return -ENXIO;
455}
456
457
458
459
460
461
462
463
464
465
466
467
468int
469lpfc_issue_reg_vfi(struct lpfc_vport *vport)
470{
471 struct lpfc_hba *phba = vport->phba;
472 LPFC_MBOXQ_t *mboxq = NULL;
473 struct lpfc_nodelist *ndlp;
474 struct lpfc_dmabuf *dmabuf = NULL;
475 int rc = 0;
476
477
478 if ((phba->sli_rev == LPFC_SLI_REV4) &&
479 !(phba->link_flag & LS_LOOPBACK_MODE) &&
480 !(vport->fc_flag & FC_PT2PT)) {
481 ndlp = lpfc_findnode_did(vport, Fabric_DID);
482 if (!ndlp) {
483 rc = -ENODEV;
484 goto fail;
485 }
486 }
487
488 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
489 if (!mboxq) {
490 rc = -ENOMEM;
491 goto fail;
492 }
493
494
495 if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) {
496 dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
497 if (!dmabuf) {
498 rc = -ENOMEM;
499 goto fail;
500 }
501 dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys);
502 if (!dmabuf->virt) {
503 rc = -ENOMEM;
504 goto fail;
505 }
506 memcpy(dmabuf->virt, &phba->fc_fabparam,
507 sizeof(struct serv_parm));
508 }
509
510 vport->port_state = LPFC_FABRIC_CFG_LINK;
511 if (dmabuf)
512 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);
513 else
514 lpfc_reg_vfi(mboxq, vport, 0);
515
516 mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi;
517 mboxq->vport = vport;
518 mboxq->ctx_buf = dmabuf;
519 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
520 if (rc == MBX_NOT_FINISHED) {
521 rc = -ENXIO;
522 goto fail;
523 }
524 return 0;
525
526fail:
527 if (mboxq)
528 mempool_free(mboxq, phba->mbox_mem_pool);
529 if (dmabuf) {
530 if (dmabuf->virt)
531 lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys);
532 kfree(dmabuf);
533 }
534
535 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
536 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
537 "0289 Issue Register VFI failed: Err %d\n", rc);
538 return rc;
539}
540
541
542
543
544
545
546
547
548
549
550
551
552int
553lpfc_issue_unreg_vfi(struct lpfc_vport *vport)
554{
555 struct lpfc_hba *phba = vport->phba;
556 struct Scsi_Host *shost;
557 LPFC_MBOXQ_t *mboxq;
558 int rc;
559
560 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
561 if (!mboxq) {
562 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
563 "2556 UNREG_VFI mbox allocation failed"
564 "HBA state x%x\n", phba->pport->port_state);
565 return -ENOMEM;
566 }
567
568 lpfc_unreg_vfi(mboxq, vport);
569 mboxq->vport = vport;
570 mboxq->mbox_cmpl = lpfc_unregister_vfi_cmpl;
571
572 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
573 if (rc == MBX_NOT_FINISHED) {
574 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
575 "2557 UNREG_VFI issue mbox failed rc x%x "
576 "HBA state x%x\n",
577 rc, phba->pport->port_state);
578 mempool_free(mboxq, phba->mbox_mem_pool);
579 return -EIO;
580 }
581
582 shost = lpfc_shost_from_vport(vport);
583 spin_lock_irq(shost->host_lock);
584 vport->fc_flag &= ~FC_VFI_REGISTERED;
585 spin_unlock_irq(shost->host_lock);
586 return 0;
587}
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607static uint8_t
608lpfc_check_clean_addr_bit(struct lpfc_vport *vport,
609 struct serv_parm *sp)
610{
611 struct lpfc_hba *phba = vport->phba;
612 uint8_t fabric_param_changed = 0;
613 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
614
615 if ((vport->fc_prevDID != vport->fc_myDID) ||
616 memcmp(&vport->fabric_portname, &sp->portName,
617 sizeof(struct lpfc_name)) ||
618 memcmp(&vport->fabric_nodename, &sp->nodeName,
619 sizeof(struct lpfc_name)) ||
620 (vport->vport_flag & FAWWPN_PARAM_CHG)) {
621 fabric_param_changed = 1;
622 vport->vport_flag &= ~FAWWPN_PARAM_CHG;
623 }
624
625
626
627
628
629
630
631
632
633
634 if (fabric_param_changed && !sp->cmn.clean_address_bit &&
635 (vport->fc_prevDID || phba->cfg_delay_discovery)) {
636 spin_lock_irq(shost->host_lock);
637 vport->fc_flag |= FC_DISC_DELAYED;
638 spin_unlock_irq(shost->host_lock);
639 }
640
641 return fabric_param_changed;
642}
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665static int
666lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
667 struct serv_parm *sp, IOCB_t *irsp)
668{
669 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
670 struct lpfc_hba *phba = vport->phba;
671 struct lpfc_nodelist *np;
672 struct lpfc_nodelist *next_np;
673 uint8_t fabric_param_changed;
674
675 spin_lock_irq(shost->host_lock);
676 vport->fc_flag |= FC_FABRIC;
677 spin_unlock_irq(shost->host_lock);
678
679 phba->fc_edtov = be32_to_cpu(sp->cmn.e_d_tov);
680 if (sp->cmn.edtovResolution)
681 phba->fc_edtov = (phba->fc_edtov + 999999) / 1000000;
682
683 phba->fc_edtovResol = sp->cmn.edtovResolution;
684 phba->fc_ratov = (be32_to_cpu(sp->cmn.w2.r_a_tov) + 999) / 1000;
685
686 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
687 spin_lock_irq(shost->host_lock);
688 vport->fc_flag |= FC_PUBLIC_LOOP;
689 spin_unlock_irq(shost->host_lock);
690 }
691
692 vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID;
693 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof(struct lpfc_name));
694 memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof(struct lpfc_name));
695 ndlp->nlp_class_sup = 0;
696 if (sp->cls1.classValid)
697 ndlp->nlp_class_sup |= FC_COS_CLASS1;
698 if (sp->cls2.classValid)
699 ndlp->nlp_class_sup |= FC_COS_CLASS2;
700 if (sp->cls3.classValid)
701 ndlp->nlp_class_sup |= FC_COS_CLASS3;
702 if (sp->cls4.classValid)
703 ndlp->nlp_class_sup |= FC_COS_CLASS4;
704 ndlp->nlp_maxframe = ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
705 sp->cmn.bbRcvSizeLsb;
706
707 fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp);
708 if (fabric_param_changed) {
709
710 if (phba->cfg_enable_SmartSAN ||
711 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) {
712
713 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
714 if (phba->cfg_enable_SmartSAN)
715 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
716 else
717 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
718 } else {
719 vport->fdmi_hba_mask = 0;
720 vport->fdmi_port_mask = 0;
721 }
722
723 }
724 memcpy(&vport->fabric_portname, &sp->portName,
725 sizeof(struct lpfc_name));
726 memcpy(&vport->fabric_nodename, &sp->nodeName,
727 sizeof(struct lpfc_name));
728 memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm));
729
730 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
731 if (sp->cmn.response_multiple_NPort) {
732 lpfc_printf_vlog(vport, KERN_WARNING,
733 LOG_ELS | LOG_VPORT,
734 "1816 FLOGI NPIV supported, "
735 "response data 0x%x\n",
736 sp->cmn.response_multiple_NPort);
737 spin_lock_irq(&phba->hbalock);
738 phba->link_flag |= LS_NPIV_FAB_SUPPORTED;
739 spin_unlock_irq(&phba->hbalock);
740 } else {
741
742
743 lpfc_printf_vlog(vport, KERN_WARNING,
744 LOG_ELS | LOG_VPORT,
745 "1817 Fabric does not support NPIV "
746 "- configuring single port mode.\n");
747 spin_lock_irq(&phba->hbalock);
748 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED;
749 spin_unlock_irq(&phba->hbalock);
750 }
751 }
752
753
754
755
756
757 if ((phba->sli_rev == LPFC_SLI_REV4) &&
758 (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)) {
759
760 if (fabric_param_changed)
761 lpfc_unregister_fcf_prep(phba);
762
763
764 if (vport->fc_flag & FC_VFI_REGISTERED)
765 lpfc_issue_reg_vfi(vport);
766 }
767
768 if (fabric_param_changed &&
769 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
770
771
772
773
774 list_for_each_entry_safe(np, next_np,
775 &vport->fc_nodes, nlp_listp) {
776 if ((np->nlp_state != NLP_STE_NPR_NODE) ||
777 !(np->nlp_flag & NLP_NPR_ADISC))
778 continue;
779 spin_lock_irq(&np->lock);
780 np->nlp_flag &= ~NLP_NPR_ADISC;
781 spin_unlock_irq(&np->lock);
782 lpfc_unreg_rpi(vport, np);
783 }
784 lpfc_cleanup_pending_mbox(vport);
785
786 if (phba->sli_rev == LPFC_SLI_REV4) {
787 lpfc_sli4_unreg_all_rpis(vport);
788 lpfc_mbx_unreg_vpi(vport);
789 spin_lock_irq(shost->host_lock);
790 vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
791 spin_unlock_irq(shost->host_lock);
792 }
793
794
795
796
797
798 spin_lock_irq(shost->host_lock);
799 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
800 spin_unlock_irq(shost->host_lock);
801 } else if ((phba->sli_rev == LPFC_SLI_REV4) &&
802 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
803
804
805
806
807 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
808 lpfc_register_new_vport(phba, vport, ndlp);
809 return 0;
810 }
811
812 if (phba->sli_rev < LPFC_SLI_REV4) {
813 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
814 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED &&
815 vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
816 lpfc_register_new_vport(phba, vport, ndlp);
817 else
818 lpfc_issue_fabric_reglogin(vport);
819 } else {
820 ndlp->nlp_type |= NLP_FABRIC;
821 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
822 if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) &&
823 (vport->vpi_state & LPFC_VPI_REGISTERED)) {
824 lpfc_start_fdiscs(phba);
825 lpfc_do_scr_ns_plogi(phba, vport);
826 } else if (vport->fc_flag & FC_VFI_REGISTERED)
827 lpfc_issue_init_vpi(vport);
828 else {
829 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
830 "3135 Need register VFI: (x%x/%x)\n",
831 vport->fc_prevDID, vport->fc_myDID);
832 lpfc_issue_reg_vfi(vport);
833 }
834 }
835 return 0;
836}
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858static int
859lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
860 struct serv_parm *sp)
861{
862 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
863 struct lpfc_hba *phba = vport->phba;
864 LPFC_MBOXQ_t *mbox;
865 int rc;
866
867 spin_lock_irq(shost->host_lock);
868 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
869 vport->fc_flag |= FC_PT2PT;
870 spin_unlock_irq(shost->host_lock);
871
872
873 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED;
874
875
876 if ((phba->sli_rev == LPFC_SLI_REV4) && phba->fc_topology_changed) {
877 lpfc_unregister_fcf_prep(phba);
878
879 spin_lock_irq(shost->host_lock);
880 vport->fc_flag &= ~FC_VFI_REGISTERED;
881 spin_unlock_irq(shost->host_lock);
882 phba->fc_topology_changed = 0;
883 }
884
885 rc = memcmp(&vport->fc_portname, &sp->portName,
886 sizeof(vport->fc_portname));
887
888 if (rc >= 0) {
889
890 spin_lock_irq(shost->host_lock);
891 vport->fc_flag |= FC_PT2PT_PLOGI;
892 spin_unlock_irq(shost->host_lock);
893
894
895
896
897
898
899
900 if (rc)
901 vport->fc_myDID = PT2PT_LocalID;
902
903
904
905
906 lpfc_nlp_put(ndlp);
907
908 ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID);
909 if (!ndlp) {
910
911
912
913
914 ndlp = lpfc_nlp_init(vport, PT2PT_RemoteID);
915 if (!ndlp)
916 goto fail;
917 }
918
919 memcpy(&ndlp->nlp_portname, &sp->portName,
920 sizeof(struct lpfc_name));
921 memcpy(&ndlp->nlp_nodename, &sp->nodeName,
922 sizeof(struct lpfc_name));
923
924 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
925 spin_lock_irq(&ndlp->lock);
926 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
927 spin_unlock_irq(&ndlp->lock);
928
929 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
930 if (!mbox)
931 goto fail;
932
933 lpfc_config_link(phba, mbox);
934
935 mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
936 mbox->vport = vport;
937 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
938 if (rc == MBX_NOT_FINISHED) {
939 mempool_free(mbox, phba->mbox_mem_pool);
940 goto fail;
941 }
942 } else {
943
944
945
946
947 lpfc_nlp_put(ndlp);
948
949
950 lpfc_disc_start(vport);
951 }
952
953 return 0;
954fail:
955 return -ENXIO;
956}
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981static void
982lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
983 struct lpfc_iocbq *rspiocb)
984{
985 struct lpfc_vport *vport = cmdiocb->vport;
986 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
987 IOCB_t *irsp = &rspiocb->iocb;
988 struct lpfc_nodelist *ndlp = cmdiocb->context1;
989 struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp;
990 struct serv_parm *sp;
991 uint16_t fcf_index;
992 int rc;
993
994
995 if (lpfc_els_chk_latt(vport)) {
996
997
998
999 lpfc_nlp_put(ndlp);
1000 goto out;
1001 }
1002
1003 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1004 "FLOGI cmpl: status:x%x/x%x state:x%x",
1005 irsp->ulpStatus, irsp->un.ulpWord[4],
1006 vport->port_state);
1007
1008 if (irsp->ulpStatus) {
1009
1010
1011
1012
1013 if ((phba->hba_flag & HBA_FIP_SUPPORT) &&
1014 (phba->fcf.fcf_flag & FCF_DISCOVERY)) {
1015 if (phba->link_state < LPFC_LINK_UP)
1016 goto stop_rr_fcf_flogi;
1017 if ((phba->fcoe_cvl_eventtag_attn ==
1018 phba->fcoe_cvl_eventtag) &&
1019 (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
1020 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
1021 IOERR_SLI_ABORTED))
1022 goto stop_rr_fcf_flogi;
1023 else
1024 phba->fcoe_cvl_eventtag_attn =
1025 phba->fcoe_cvl_eventtag;
1026 lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS,
1027 "2611 FLOGI failed on FCF (x%x), "
1028 "status:x%x/x%x, tmo:x%x, perform "
1029 "roundrobin FCF failover\n",
1030 phba->fcf.current_rec.fcf_indx,
1031 irsp->ulpStatus, irsp->un.ulpWord[4],
1032 irsp->ulpTimeout);
1033 lpfc_sli4_set_fcf_flogi_fail(phba,
1034 phba->fcf.current_rec.fcf_indx);
1035 fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba);
1036 rc = lpfc_sli4_fcf_rr_next_proc(vport, fcf_index);
1037 if (rc)
1038 goto out;
1039 }
1040
1041stop_rr_fcf_flogi:
1042
1043 if (!(irsp->ulpStatus == IOSTAT_LOCAL_REJECT &&
1044 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
1045 IOERR_LOOP_OPEN_FAILURE)))
1046 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1047 "2858 FLOGI failure Status:x%x/x%x TMO"
1048 ":x%x Data x%x x%x\n",
1049 irsp->ulpStatus, irsp->un.ulpWord[4],
1050 irsp->ulpTimeout, phba->hba_flag,
1051 phba->fcf.fcf_flag);
1052
1053
1054 if (lpfc_els_retry(phba, cmdiocb, rspiocb))
1055 goto out;
1056
1057 lpfc_printf_vlog(vport, KERN_WARNING, LOG_TRACE_EVENT,
1058 "0150 FLOGI failure Status:x%x/x%x "
1059 "xri x%x TMO:x%x\n",
1060 irsp->ulpStatus, irsp->un.ulpWord[4],
1061 cmdiocb->sli4_xritag, irsp->ulpTimeout);
1062
1063
1064 if (!(irsp->ulpStatus == IOSTAT_LOCAL_REJECT &&
1065 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
1066 IOERR_LOOP_OPEN_FAILURE)))
1067 goto flogifail;
1068
1069
1070 spin_lock_irq(shost->host_lock);
1071 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
1072 spin_unlock_irq(shost->host_lock);
1073
1074
1075
1076
1077
1078 if (phba->alpa_map[0] == 0)
1079 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
1080 if ((phba->sli_rev == LPFC_SLI_REV4) &&
1081 (!(vport->fc_flag & FC_VFI_REGISTERED) ||
1082 (vport->fc_prevDID != vport->fc_myDID) ||
1083 phba->fc_topology_changed)) {
1084 if (vport->fc_flag & FC_VFI_REGISTERED) {
1085 if (phba->fc_topology_changed) {
1086 lpfc_unregister_fcf_prep(phba);
1087 spin_lock_irq(shost->host_lock);
1088 vport->fc_flag &= ~FC_VFI_REGISTERED;
1089 spin_unlock_irq(shost->host_lock);
1090 phba->fc_topology_changed = 0;
1091 } else {
1092 lpfc_sli4_unreg_all_rpis(vport);
1093 }
1094 }
1095
1096
1097 if (!lpfc_error_lost_link(irsp))
1098 lpfc_issue_reg_vfi(vport);
1099
1100 lpfc_nlp_put(ndlp);
1101 goto out;
1102 }
1103 goto flogifail;
1104 }
1105 spin_lock_irq(shost->host_lock);
1106 vport->fc_flag &= ~FC_VPORT_CVL_RCVD;
1107 vport->fc_flag &= ~FC_VPORT_LOGO_RCVD;
1108 spin_unlock_irq(shost->host_lock);
1109
1110
1111
1112
1113
1114 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
1115 if (!prsp)
1116 goto out;
1117 sp = prsp->virt + sizeof(uint32_t);
1118
1119
1120 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1121 "0101 FLOGI completes successfully, I/O tag:x%x, "
1122 "xri x%x Data: x%x x%x x%x x%x x%x x%x x%x\n",
1123 cmdiocb->iotag, cmdiocb->sli4_xritag,
1124 irsp->un.ulpWord[4], sp->cmn.e_d_tov,
1125 sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution,
1126 vport->port_state, vport->fc_flag,
1127 sp->cmn.priority_tagging);
1128
1129 if (sp->cmn.priority_tagging)
1130 vport->vmid_flag |= LPFC_VMID_ISSUE_QFPA;
1131
1132 if (vport->port_state == LPFC_FLOGI) {
1133
1134
1135
1136
1137 if (sp->cmn.fPort)
1138 rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp);
1139 else if (!(phba->hba_flag & HBA_FCOE_MODE))
1140 rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp);
1141 else {
1142 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1143 "2831 FLOGI response with cleared Fabric "
1144 "bit fcf_index 0x%x "
1145 "Switch Name %02x%02x%02x%02x%02x%02x%02x%02x "
1146 "Fabric Name "
1147 "%02x%02x%02x%02x%02x%02x%02x%02x\n",
1148 phba->fcf.current_rec.fcf_indx,
1149 phba->fcf.current_rec.switch_name[0],
1150 phba->fcf.current_rec.switch_name[1],
1151 phba->fcf.current_rec.switch_name[2],
1152 phba->fcf.current_rec.switch_name[3],
1153 phba->fcf.current_rec.switch_name[4],
1154 phba->fcf.current_rec.switch_name[5],
1155 phba->fcf.current_rec.switch_name[6],
1156 phba->fcf.current_rec.switch_name[7],
1157 phba->fcf.current_rec.fabric_name[0],
1158 phba->fcf.current_rec.fabric_name[1],
1159 phba->fcf.current_rec.fabric_name[2],
1160 phba->fcf.current_rec.fabric_name[3],
1161 phba->fcf.current_rec.fabric_name[4],
1162 phba->fcf.current_rec.fabric_name[5],
1163 phba->fcf.current_rec.fabric_name[6],
1164 phba->fcf.current_rec.fabric_name[7]);
1165
1166 lpfc_nlp_put(ndlp);
1167 spin_lock_irq(&phba->hbalock);
1168 phba->fcf.fcf_flag &= ~FCF_DISCOVERY;
1169 phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO);
1170 spin_unlock_irq(&phba->hbalock);
1171 phba->fcf.fcf_redisc_attempted = 0;
1172 goto out;
1173 }
1174 if (!rc) {
1175
1176 if (phba->hba_flag & HBA_FIP_SUPPORT)
1177 lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP |
1178 LOG_ELS,
1179 "2769 FLOGI to FCF (x%x) "
1180 "completed successfully\n",
1181 phba->fcf.current_rec.fcf_indx);
1182 spin_lock_irq(&phba->hbalock);
1183 phba->fcf.fcf_flag &= ~FCF_DISCOVERY;
1184 phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO);
1185 spin_unlock_irq(&phba->hbalock);
1186 phba->fcf.fcf_redisc_attempted = 0;
1187 goto out;
1188 }
1189 } else if (vport->port_state > LPFC_FLOGI &&
1190 vport->fc_flag & FC_PT2PT) {
1191
1192
1193
1194
1195
1196 if (!sp->cmn.fPort)
1197 goto out;
1198 }
1199
1200flogifail:
1201 spin_lock_irq(&phba->hbalock);
1202 phba->fcf.fcf_flag &= ~FCF_DISCOVERY;
1203 spin_unlock_irq(&phba->hbalock);
1204
1205 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)))
1206 lpfc_nlp_put(ndlp);
1207 if (!lpfc_error_lost_link(irsp)) {
1208
1209 lpfc_disc_list_loopmap(vport);
1210
1211
1212 lpfc_disc_start(vport);
1213 } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
1214 (((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) !=
1215 IOERR_SLI_ABORTED) &&
1216 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) !=
1217 IOERR_SLI_DOWN))) &&
1218 (phba->link_state != LPFC_CLEAR_LA)) {
1219
1220 lpfc_issue_clear_la(phba, vport);
1221 }
1222out:
1223 phba->hba_flag &= ~HBA_FLOGI_OUTSTANDING;
1224 lpfc_els_free_iocb(phba, cmdiocb);
1225 lpfc_nlp_put(ndlp);
1226}
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236static void
1237lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1238 struct lpfc_iocbq *rspiocb)
1239{
1240 IOCB_t *irsp;
1241 uint32_t *pcmd;
1242 uint32_t cmd;
1243
1244 pcmd = (uint32_t *)(((struct lpfc_dmabuf *)cmdiocb->context2)->virt);
1245 cmd = *pcmd;
1246 irsp = &rspiocb->iocb;
1247
1248 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1249 "6445 ELS completes after LINK_DOWN: "
1250 " Status %x/%x cmd x%x flg x%x\n",
1251 irsp->ulpStatus, irsp->un.ulpWord[4], cmd,
1252 cmdiocb->iocb_flag);
1253
1254 if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) {
1255 cmdiocb->iocb_flag &= ~LPFC_IO_FABRIC;
1256 atomic_dec(&phba->fabric_iocb_count);
1257 }
1258 lpfc_els_free_iocb(phba, cmdiocb);
1259}
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282static int
1283lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1284 uint8_t retry)
1285{
1286 struct lpfc_hba *phba = vport->phba;
1287 struct serv_parm *sp;
1288 IOCB_t *icmd;
1289 struct lpfc_iocbq *elsiocb;
1290 struct lpfc_iocbq defer_flogi_acc;
1291 uint8_t *pcmd;
1292 uint16_t cmdsize;
1293 uint32_t tmo, did;
1294 int rc;
1295
1296 cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm));
1297 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1298 ndlp->nlp_DID, ELS_CMD_FLOGI);
1299
1300 if (!elsiocb)
1301 return 1;
1302
1303 icmd = &elsiocb->iocb;
1304 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
1305
1306
1307 *((uint32_t *) (pcmd)) = ELS_CMD_FLOGI;
1308 pcmd += sizeof(uint32_t);
1309 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
1310 sp = (struct serv_parm *) pcmd;
1311
1312
1313 sp->cmn.e_d_tov = 0;
1314 sp->cmn.w2.r_a_tov = 0;
1315 sp->cmn.virtual_fabric_support = 0;
1316 sp->cls1.classValid = 0;
1317 if (sp->cmn.fcphLow < FC_PH3)
1318 sp->cmn.fcphLow = FC_PH3;
1319 if (sp->cmn.fcphHigh < FC_PH3)
1320 sp->cmn.fcphHigh = FC_PH3;
1321
1322
1323 if (phba->cfg_vmid_priority_tagging) {
1324 sp->cmn.priority_tagging = 1;
1325
1326 if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid)) {
1327 memcpy(vport->lpfc_vmid_host_uuid, phba->wwpn,
1328 sizeof(phba->wwpn));
1329 memcpy(&vport->lpfc_vmid_host_uuid[8], phba->wwnn,
1330 sizeof(phba->wwnn));
1331 }
1332 }
1333
1334 if (phba->sli_rev == LPFC_SLI_REV4) {
1335 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) ==
1336 LPFC_SLI_INTF_IF_TYPE_0) {
1337 elsiocb->iocb.ulpCt_h = ((SLI4_CT_FCFI >> 1) & 1);
1338 elsiocb->iocb.ulpCt_l = (SLI4_CT_FCFI & 1);
1339
1340
1341 elsiocb->iocb.ulpContext = phba->fcf.fcfi;
1342 }
1343
1344 sp->cls2.classValid = 0;
1345 sp->cls2.seqDelivery = 0;
1346 } else {
1347
1348 sp->cls2.seqDelivery = (sp->cls2.classValid) ? 1 : 0;
1349 sp->cls3.seqDelivery = (sp->cls3.classValid) ? 1 : 0;
1350 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
1351 sp->cmn.request_multiple_Nport = 1;
1352
1353 icmd->ulpCt_h = 1;
1354 icmd->ulpCt_l = 0;
1355 } else
1356 sp->cmn.request_multiple_Nport = 0;
1357 }
1358
1359 if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) {
1360 icmd->un.elsreq64.myID = 0;
1361 icmd->un.elsreq64.fl = 1;
1362 }
1363
1364 tmo = phba->fc_ratov;
1365 phba->fc_ratov = LPFC_DISC_FLOGI_TMO;
1366 lpfc_set_disctmo(vport);
1367 phba->fc_ratov = tmo;
1368
1369 phba->fc_stat.elsXmitFLOGI++;
1370 elsiocb->iocb_cmpl = lpfc_cmpl_els_flogi;
1371
1372 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1373 "Issue FLOGI: opt:x%x",
1374 phba->sli3_options, 0, 0);
1375
1376 elsiocb->context1 = lpfc_nlp_get(ndlp);
1377 if (!elsiocb->context1) {
1378 lpfc_els_free_iocb(phba, elsiocb);
1379 return 1;
1380 }
1381
1382 rc = lpfc_issue_fabric_iocb(phba, elsiocb);
1383 if (rc == IOCB_ERROR) {
1384 lpfc_els_free_iocb(phba, elsiocb);
1385 lpfc_nlp_put(ndlp);
1386 return 1;
1387 }
1388
1389 phba->hba_flag |= (HBA_FLOGI_ISSUED | HBA_FLOGI_OUTSTANDING);
1390
1391
1392 if (phba->defer_flogi_acc_flag) {
1393 did = vport->fc_myDID;
1394 vport->fc_myDID = Fabric_DID;
1395
1396 memset(&defer_flogi_acc, 0, sizeof(struct lpfc_iocbq));
1397
1398 defer_flogi_acc.iocb.ulpContext = phba->defer_flogi_acc_rx_id;
1399 defer_flogi_acc.iocb.unsli3.rcvsli3.ox_id =
1400 phba->defer_flogi_acc_ox_id;
1401
1402 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1403 "3354 Xmit deferred FLOGI ACC: rx_id: x%x,"
1404 " ox_id: x%x, hba_flag x%x\n",
1405 phba->defer_flogi_acc_rx_id,
1406 phba->defer_flogi_acc_ox_id, phba->hba_flag);
1407
1408
1409 lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, &defer_flogi_acc,
1410 ndlp, NULL);
1411
1412 phba->defer_flogi_acc_flag = false;
1413
1414 vport->fc_myDID = did;
1415 }
1416
1417 return 0;
1418}
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434int
1435lpfc_els_abort_flogi(struct lpfc_hba *phba)
1436{
1437 struct lpfc_sli_ring *pring;
1438 struct lpfc_iocbq *iocb, *next_iocb;
1439 struct lpfc_nodelist *ndlp;
1440 IOCB_t *icmd;
1441
1442
1443 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
1444 "0201 Abort outstanding I/O on NPort x%x\n",
1445 Fabric_DID);
1446
1447 pring = lpfc_phba_elsring(phba);
1448 if (unlikely(!pring))
1449 return -EIO;
1450
1451
1452
1453
1454
1455 spin_lock_irq(&phba->hbalock);
1456 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
1457 icmd = &iocb->iocb;
1458 if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) {
1459 ndlp = (struct lpfc_nodelist *)(iocb->context1);
1460 if (ndlp && ndlp->nlp_DID == Fabric_DID) {
1461 if ((phba->pport->fc_flag & FC_PT2PT) &&
1462 !(phba->pport->fc_flag & FC_PT2PT_PLOGI))
1463 iocb->fabric_iocb_cmpl =
1464 lpfc_ignore_els_cmpl;
1465 lpfc_sli_issue_abort_iotag(phba, pring, iocb,
1466 NULL);
1467 }
1468 }
1469 }
1470
1471 lpfc_issue_hb_tmo(phba);
1472
1473 spin_unlock_irq(&phba->hbalock);
1474
1475 return 0;
1476}
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494int
1495lpfc_initial_flogi(struct lpfc_vport *vport)
1496{
1497 struct lpfc_nodelist *ndlp;
1498
1499 vport->port_state = LPFC_FLOGI;
1500 lpfc_set_disctmo(vport);
1501
1502
1503 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1504 if (!ndlp) {
1505
1506 ndlp = lpfc_nlp_init(vport, Fabric_DID);
1507 if (!ndlp)
1508 return 0;
1509
1510 ndlp->nlp_type |= NLP_FABRIC;
1511
1512
1513 lpfc_enqueue_node(vport, ndlp);
1514 }
1515
1516 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
1517
1518
1519
1520 lpfc_nlp_put(ndlp);
1521 return 0;
1522 }
1523 return 1;
1524}
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542int
1543lpfc_initial_fdisc(struct lpfc_vport *vport)
1544{
1545 struct lpfc_nodelist *ndlp;
1546
1547
1548 ndlp = lpfc_findnode_did(vport, Fabric_DID);
1549 if (!ndlp) {
1550
1551 ndlp = lpfc_nlp_init(vport, Fabric_DID);
1552 if (!ndlp)
1553 return 0;
1554
1555
1556 ndlp->nlp_type |= NLP_FABRIC;
1557
1558
1559 lpfc_enqueue_node(vport, ndlp);
1560 }
1561
1562 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
1563
1564
1565
1566 lpfc_nlp_put(ndlp);
1567 return 0;
1568 }
1569 return 1;
1570}
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583void
1584lpfc_more_plogi(struct lpfc_vport *vport)
1585{
1586 if (vport->num_disc_nodes)
1587 vport->num_disc_nodes--;
1588
1589
1590 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1591 "0232 Continue discovery with %d PLOGIs to go "
1592 "Data: x%x x%x x%x\n",
1593 vport->num_disc_nodes, vport->fc_plogi_cnt,
1594 vport->fc_flag, vport->port_state);
1595
1596 if (vport->fc_flag & FC_NLP_MORE)
1597
1598 lpfc_els_disc_plogi(vport);
1599
1600 return;
1601}
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634static struct lpfc_nodelist *
1635lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
1636 struct lpfc_nodelist *ndlp)
1637{
1638 struct lpfc_vport *vport = ndlp->vport;
1639 struct lpfc_nodelist *new_ndlp;
1640 struct serv_parm *sp;
1641 uint8_t name[sizeof(struct lpfc_name)];
1642 uint32_t keepDID = 0, keep_nlp_flag = 0;
1643 uint32_t keep_new_nlp_flag = 0;
1644 uint16_t keep_nlp_state;
1645 u32 keep_nlp_fc4_type = 0;
1646 struct lpfc_nvme_rport *keep_nrport = NULL;
1647 unsigned long *active_rrqs_xri_bitmap = NULL;
1648
1649
1650
1651
1652 if (ndlp->nlp_type & NLP_FABRIC)
1653 return ndlp;
1654
1655 sp = (struct serv_parm *) ((uint8_t *) prsp + sizeof(uint32_t));
1656 memset(name, 0, sizeof(struct lpfc_name));
1657
1658
1659
1660
1661 new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName);
1662
1663
1664 if (!new_ndlp || (new_ndlp == ndlp))
1665 return ndlp;
1666
1667 if (phba->sli_rev == LPFC_SLI_REV4) {
1668 active_rrqs_xri_bitmap = mempool_alloc(phba->active_rrq_pool,
1669 GFP_KERNEL);
1670 if (active_rrqs_xri_bitmap)
1671 memset(active_rrqs_xri_bitmap, 0,
1672 phba->cfg_rrq_xri_bitmap_sz);
1673 }
1674
1675 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_NODE,
1676 "3178 PLOGI confirm: ndlp x%x x%x x%x: "
1677 "new_ndlp x%x x%x x%x\n",
1678 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_fc4_type,
1679 (new_ndlp ? new_ndlp->nlp_DID : 0),
1680 (new_ndlp ? new_ndlp->nlp_flag : 0),
1681 (new_ndlp ? new_ndlp->nlp_fc4_type : 0));
1682
1683 keepDID = new_ndlp->nlp_DID;
1684
1685 if (phba->sli_rev == LPFC_SLI_REV4 && active_rrqs_xri_bitmap)
1686 memcpy(active_rrqs_xri_bitmap, new_ndlp->active_rrqs_xri_bitmap,
1687 phba->cfg_rrq_xri_bitmap_sz);
1688
1689
1690
1691
1692
1693
1694 if (vport->fc_flag & FC_FABRIC) {
1695 keep_nlp_fc4_type = new_ndlp->nlp_fc4_type;
1696 new_ndlp->nlp_fc4_type = ndlp->nlp_fc4_type;
1697 }
1698
1699 lpfc_unreg_rpi(vport, new_ndlp);
1700 new_ndlp->nlp_DID = ndlp->nlp_DID;
1701 new_ndlp->nlp_prev_state = ndlp->nlp_prev_state;
1702 if (phba->sli_rev == LPFC_SLI_REV4)
1703 memcpy(new_ndlp->active_rrqs_xri_bitmap,
1704 ndlp->active_rrqs_xri_bitmap,
1705 phba->cfg_rrq_xri_bitmap_sz);
1706
1707
1708 spin_lock_irq(&ndlp->lock);
1709 spin_lock_irq(&new_ndlp->lock);
1710 keep_new_nlp_flag = new_ndlp->nlp_flag;
1711 keep_nlp_flag = ndlp->nlp_flag;
1712 new_ndlp->nlp_flag = ndlp->nlp_flag;
1713
1714
1715 if (keep_new_nlp_flag & NLP_UNREG_INP)
1716 new_ndlp->nlp_flag |= NLP_UNREG_INP;
1717 else
1718 new_ndlp->nlp_flag &= ~NLP_UNREG_INP;
1719
1720
1721 if (keep_new_nlp_flag & NLP_RPI_REGISTERED)
1722 new_ndlp->nlp_flag |= NLP_RPI_REGISTERED;
1723 else
1724 new_ndlp->nlp_flag &= ~NLP_RPI_REGISTERED;
1725
1726
1727
1728
1729
1730 if (keep_new_nlp_flag & NLP_DROPPED)
1731 new_ndlp->nlp_flag |= NLP_DROPPED;
1732 else
1733 new_ndlp->nlp_flag &= ~NLP_DROPPED;
1734
1735 ndlp->nlp_flag = keep_new_nlp_flag;
1736
1737
1738 if (keep_nlp_flag & NLP_UNREG_INP)
1739 ndlp->nlp_flag |= NLP_UNREG_INP;
1740 else
1741 ndlp->nlp_flag &= ~NLP_UNREG_INP;
1742
1743
1744 if (keep_nlp_flag & NLP_RPI_REGISTERED)
1745 ndlp->nlp_flag |= NLP_RPI_REGISTERED;
1746 else
1747 ndlp->nlp_flag &= ~NLP_RPI_REGISTERED;
1748
1749
1750
1751
1752
1753 if (keep_nlp_flag & NLP_DROPPED)
1754 ndlp->nlp_flag |= NLP_DROPPED;
1755 else
1756 ndlp->nlp_flag &= ~NLP_DROPPED;
1757
1758 spin_unlock_irq(&new_ndlp->lock);
1759 spin_unlock_irq(&ndlp->lock);
1760
1761
1762 keep_nlp_state = new_ndlp->nlp_state;
1763 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
1764
1765
1766 keep_nrport = new_ndlp->nrport;
1767 new_ndlp->nrport = ndlp->nrport;
1768
1769
1770 if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) {
1771
1772
1773
1774 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1775 "3179 PLOGI confirm NEW: %x %x\n",
1776 new_ndlp->nlp_DID, keepDID);
1777
1778
1779
1780
1781
1782 ndlp->nlp_DID = keepDID;
1783 lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
1784 if (phba->sli_rev == LPFC_SLI_REV4 &&
1785 active_rrqs_xri_bitmap)
1786 memcpy(ndlp->active_rrqs_xri_bitmap,
1787 active_rrqs_xri_bitmap,
1788 phba->cfg_rrq_xri_bitmap_sz);
1789
1790 } else {
1791 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1792 "3180 PLOGI confirm SWAP: %x %x\n",
1793 new_ndlp->nlp_DID, keepDID);
1794
1795 lpfc_unreg_rpi(vport, ndlp);
1796
1797
1798
1799
1800
1801 ndlp->nlp_DID = keepDID;
1802 ndlp->nlp_fc4_type = keep_nlp_fc4_type;
1803
1804 if (phba->sli_rev == LPFC_SLI_REV4 &&
1805 active_rrqs_xri_bitmap)
1806 memcpy(ndlp->active_rrqs_xri_bitmap,
1807 active_rrqs_xri_bitmap,
1808 phba->cfg_rrq_xri_bitmap_sz);
1809
1810
1811
1812
1813 if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) ||
1814 (ndlp->nlp_state == NLP_STE_MAPPED_NODE))
1815 keep_nlp_state = NLP_STE_NPR_NODE;
1816 lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
1817 ndlp->nrport = keep_nrport;
1818 }
1819
1820
1821
1822
1823
1824 if (!ndlp->rport && (ndlp->nlp_state == NLP_STE_NPR_NODE))
1825 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
1826
1827 if (phba->sli_rev == LPFC_SLI_REV4 &&
1828 active_rrqs_xri_bitmap)
1829 mempool_free(active_rrqs_xri_bitmap,
1830 phba->active_rrq_pool);
1831
1832 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_NODE,
1833 "3173 PLOGI confirm exit: new_ndlp x%x x%x x%x\n",
1834 new_ndlp->nlp_DID, new_ndlp->nlp_flag,
1835 new_ndlp->nlp_fc4_type);
1836
1837 return new_ndlp;
1838}
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851void
1852lpfc_end_rscn(struct lpfc_vport *vport)
1853{
1854 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1855
1856 if (vport->fc_flag & FC_RSCN_MODE) {
1857
1858
1859
1860
1861 if (vport->fc_rscn_id_cnt ||
1862 (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
1863 lpfc_els_handle_rscn(vport);
1864 else {
1865 spin_lock_irq(shost->host_lock);
1866 vport->fc_flag &= ~FC_RSCN_MODE;
1867 spin_unlock_irq(shost->host_lock);
1868 }
1869 }
1870}
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884static void
1885lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1886 struct lpfc_iocbq *rspiocb)
1887{
1888 struct lpfc_vport *vport = cmdiocb->vport;
1889 IOCB_t *irsp;
1890 struct lpfc_nodelist *ndlp = cmdiocb->context1;
1891 struct lpfc_node_rrq *rrq;
1892
1893
1894 rrq = cmdiocb->context_un.rrq;
1895 cmdiocb->context_un.rsp_iocb = rspiocb;
1896
1897 irsp = &rspiocb->iocb;
1898 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1899 "RRQ cmpl: status:x%x/x%x did:x%x",
1900 irsp->ulpStatus, irsp->un.ulpWord[4],
1901 irsp->un.elsreq64.remoteID);
1902
1903
1904 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1905 "2880 RRQ completes to DID x%x "
1906 "Data: x%x x%x x%x x%x x%x\n",
1907 irsp->un.elsreq64.remoteID,
1908 irsp->ulpStatus, irsp->un.ulpWord[4],
1909 irsp->ulpTimeout, rrq->xritag, rrq->rxid);
1910
1911 if (irsp->ulpStatus) {
1912
1913
1914 if (irsp->ulpStatus != IOSTAT_LS_RJT ||
1915 (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) &&
1916 ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) ||
1917 (phba)->pport->cfg_log_verbose & LOG_ELS)
1918 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1919 "2881 RRQ failure DID:%06X Status:"
1920 "x%x/x%x\n",
1921 ndlp->nlp_DID, irsp->ulpStatus,
1922 irsp->un.ulpWord[4]);
1923 }
1924
1925 lpfc_clr_rrq_active(phba, rrq->xritag, rrq);
1926 lpfc_els_free_iocb(phba, cmdiocb);
1927 lpfc_nlp_put(ndlp);
1928 return;
1929}
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950static void
1951lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1952 struct lpfc_iocbq *rspiocb)
1953{
1954 struct lpfc_vport *vport = cmdiocb->vport;
1955 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1956 IOCB_t *irsp;
1957 struct lpfc_nodelist *ndlp, *free_ndlp;
1958 struct lpfc_dmabuf *prsp;
1959 int disc;
1960 struct serv_parm *sp = NULL;
1961
1962
1963 cmdiocb->context_un.rsp_iocb = rspiocb;
1964
1965 irsp = &rspiocb->iocb;
1966 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1967 "PLOGI cmpl: status:x%x/x%x did:x%x",
1968 irsp->ulpStatus, irsp->un.ulpWord[4],
1969 irsp->un.elsreq64.remoteID);
1970
1971 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID);
1972 if (!ndlp) {
1973 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1974 "0136 PLOGI completes to NPort x%x "
1975 "with no ndlp. Data: x%x x%x x%x\n",
1976 irsp->un.elsreq64.remoteID,
1977 irsp->ulpStatus, irsp->un.ulpWord[4],
1978 irsp->ulpIoTag);
1979 goto out_freeiocb;
1980 }
1981
1982
1983
1984
1985 spin_lock_irq(&ndlp->lock);
1986 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
1987 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
1988 spin_unlock_irq(&ndlp->lock);
1989
1990
1991 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1992 "0102 PLOGI completes to NPort x%06x "
1993 "Data: x%x x%x x%x x%x x%x\n",
1994 ndlp->nlp_DID, ndlp->nlp_fc4_type,
1995 irsp->ulpStatus, irsp->un.ulpWord[4],
1996 disc, vport->num_disc_nodes);
1997
1998
1999 if (lpfc_els_chk_latt(vport)) {
2000 spin_lock_irq(&ndlp->lock);
2001 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
2002 spin_unlock_irq(&ndlp->lock);
2003 goto out;
2004 }
2005
2006 if (irsp->ulpStatus) {
2007
2008 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) {
2009
2010 if (disc) {
2011 spin_lock_irq(&ndlp->lock);
2012 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
2013 spin_unlock_irq(&ndlp->lock);
2014 }
2015 goto out;
2016 }
2017
2018 if (irsp->ulpStatus != IOSTAT_LS_RJT ||
2019 (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) &&
2020 ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) ||
2021 (phba)->pport->cfg_log_verbose & LOG_ELS)
2022 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2023 "2753 PLOGI failure DID:%06X Status:x%x/x%x\n",
2024 ndlp->nlp_DID, irsp->ulpStatus,
2025 irsp->un.ulpWord[4]);
2026
2027
2028 if (lpfc_error_lost_link(irsp))
2029 goto check_plogi;
2030 else
2031 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2032 NLP_EVT_CMPL_PLOGI);
2033
2034
2035
2036
2037 spin_lock_irq(&ndlp->lock);
2038 if ((ndlp->nlp_flag & (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI)) &&
2039 ndlp->nlp_state == NLP_STE_REG_LOGIN_ISSUE) {
2040 spin_unlock_irq(&ndlp->lock);
2041 goto out;
2042 }
2043 spin_unlock_irq(&ndlp->lock);
2044
2045
2046
2047
2048
2049 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2050 spin_lock_irq(&ndlp->lock);
2051 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2052 spin_unlock_irq(&ndlp->lock);
2053 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2054 NLP_EVT_DEVICE_RM);
2055 }
2056 } else {
2057
2058 prsp = list_entry(((struct lpfc_dmabuf *)
2059 cmdiocb->context2)->list.next,
2060 struct lpfc_dmabuf, list);
2061 ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp);
2062
2063 sp = (struct serv_parm *)((u8 *)prsp->virt +
2064 sizeof(u32));
2065
2066 ndlp->vmid_support = 0;
2067 if ((phba->cfg_vmid_app_header && sp->cmn.app_hdr_support) ||
2068 (phba->cfg_vmid_priority_tagging &&
2069 sp->cmn.priority_tagging)) {
2070 lpfc_printf_log(phba, KERN_DEBUG, LOG_ELS,
2071 "4018 app_hdr_support %d tagging %d DID x%x\n",
2072 sp->cmn.app_hdr_support,
2073 sp->cmn.priority_tagging,
2074 ndlp->nlp_DID);
2075
2076 ndlp->vmid_support = 1;
2077 }
2078
2079 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2080 NLP_EVT_CMPL_PLOGI);
2081 }
2082
2083 check_plogi:
2084 if (disc && vport->num_disc_nodes) {
2085
2086 lpfc_more_plogi(vport);
2087
2088 if (vport->num_disc_nodes == 0) {
2089 spin_lock_irq(shost->host_lock);
2090 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2091 spin_unlock_irq(shost->host_lock);
2092
2093 lpfc_can_disctmo(vport);
2094 lpfc_end_rscn(vport);
2095 }
2096 }
2097
2098out:
2099 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE,
2100 "PLOGI Cmpl PUT: did:x%x refcnt %d",
2101 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
2102
2103out_freeiocb:
2104
2105 free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
2106
2107 lpfc_els_free_iocb(phba, cmdiocb);
2108 lpfc_nlp_put(free_ndlp);
2109 return;
2110}
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132int
2133lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry)
2134{
2135 struct lpfc_hba *phba = vport->phba;
2136 struct serv_parm *sp;
2137 struct lpfc_nodelist *ndlp;
2138 struct lpfc_iocbq *elsiocb;
2139 uint8_t *pcmd;
2140 uint16_t cmdsize;
2141 int ret;
2142
2143 ndlp = lpfc_findnode_did(vport, did);
2144 if (!ndlp)
2145 return 1;
2146
2147
2148
2149
2150
2151 if ((ndlp->nlp_flag & NLP_UNREG_INP) &&
2152 ((ndlp->nlp_DID & Fabric_DID_MASK) != Fabric_DID_MASK) &&
2153 !(vport->fc_flag & FC_OFFLINE_MODE)) {
2154 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2155 "4110 Issue PLOGI x%x deferred "
2156 "on NPort x%x rpi x%x Data: x%px\n",
2157 ndlp->nlp_defer_did, ndlp->nlp_DID,
2158 ndlp->nlp_rpi, ndlp);
2159
2160
2161 if (ndlp->nlp_defer_did == NLP_EVT_NOTHING_PENDING)
2162 ndlp->nlp_defer_did = did;
2163 return 0;
2164 }
2165
2166 cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm));
2167 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
2168 ELS_CMD_PLOGI);
2169 if (!elsiocb)
2170 return 1;
2171
2172 spin_lock_irq(&ndlp->lock);
2173 ndlp->nlp_flag &= ~NLP_FCP_PRLI_RJT;
2174 spin_unlock_irq(&ndlp->lock);
2175
2176 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2177
2178
2179 *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI;
2180 pcmd += sizeof(uint32_t);
2181 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm));
2182 sp = (struct serv_parm *) pcmd;
2183
2184
2185
2186
2187
2188 if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP))
2189 sp->cmn.altBbCredit = 1;
2190
2191 if (sp->cmn.fcphLow < FC_PH_4_3)
2192 sp->cmn.fcphLow = FC_PH_4_3;
2193
2194 if (sp->cmn.fcphHigh < FC_PH3)
2195 sp->cmn.fcphHigh = FC_PH3;
2196
2197 sp->cmn.valid_vendor_ver_level = 0;
2198 memset(sp->un.vendorVersion, 0, sizeof(sp->un.vendorVersion));
2199 sp->cmn.bbRcvSizeMsb &= 0xF;
2200
2201
2202 ndlp->vmid_support = 0;
2203 if (vport->vmid_priority_tagging)
2204 sp->cmn.priority_tagging = 1;
2205 else if (phba->cfg_vmid_app_header &&
2206 bf_get(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags))
2207 sp->cmn.app_hdr_support = 1;
2208
2209 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2210 "Issue PLOGI: did:x%x",
2211 did, 0, 0);
2212
2213
2214
2215
2216 if (phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) {
2217 sp->cmn.valid_vendor_ver_level = 1;
2218 sp->un.vv.vid = cpu_to_be32(LPFC_VV_EMLX_ID);
2219 sp->un.vv.flags = cpu_to_be32(LPFC_VV_SUPPRESS_RSP);
2220 }
2221
2222 phba->fc_stat.elsXmitPLOGI++;
2223 elsiocb->iocb_cmpl = lpfc_cmpl_els_plogi;
2224
2225 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2226 "Issue PLOGI: did:x%x refcnt %d",
2227 did, kref_read(&ndlp->kref), 0);
2228 elsiocb->context1 = lpfc_nlp_get(ndlp);
2229 if (!elsiocb->context1) {
2230 lpfc_els_free_iocb(phba, elsiocb);
2231 return 1;
2232 }
2233
2234 ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
2235 if (ret) {
2236 lpfc_els_free_iocb(phba, elsiocb);
2237 lpfc_nlp_put(ndlp);
2238 return 1;
2239 }
2240
2241 return 0;
2242}
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257static void
2258lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2259 struct lpfc_iocbq *rspiocb)
2260{
2261 struct lpfc_vport *vport = cmdiocb->vport;
2262 IOCB_t *irsp;
2263 struct lpfc_nodelist *ndlp;
2264 char *mode;
2265 u32 loglevel;
2266
2267
2268 cmdiocb->context_un.rsp_iocb = rspiocb;
2269
2270 irsp = &(rspiocb->iocb);
2271 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2272 spin_lock_irq(&ndlp->lock);
2273 ndlp->nlp_flag &= ~NLP_PRLI_SND;
2274
2275
2276 vport->fc_prli_sent--;
2277 ndlp->fc4_prli_sent--;
2278 spin_unlock_irq(&ndlp->lock);
2279
2280 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2281 "PRLI cmpl: status:x%x/x%x did:x%x",
2282 irsp->ulpStatus, irsp->un.ulpWord[4],
2283 ndlp->nlp_DID);
2284
2285
2286 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2287 "0103 PRLI completes to NPort x%06x "
2288 "Data: x%x x%x x%x x%x\n",
2289 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
2290 vport->num_disc_nodes, ndlp->fc4_prli_sent);
2291
2292
2293 if (lpfc_els_chk_latt(vport))
2294 goto out;
2295
2296 if (irsp->ulpStatus) {
2297
2298 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) {
2299
2300 goto out;
2301 }
2302
2303
2304
2305
2306 if ((vport->fc_flag & FC_FABRIC) ||
2307 (vport->cfg_enable_fc4_type != LPFC_ENABLE_BOTH)) {
2308 mode = KERN_ERR;
2309 loglevel = LOG_TRACE_EVENT;
2310 } else {
2311 mode = KERN_INFO;
2312 loglevel = LOG_ELS;
2313 }
2314
2315
2316 lpfc_printf_vlog(vport, mode, loglevel,
2317 "2754 PRLI failure DID:%06X Status:x%x/x%x, "
2318 "data: x%x\n",
2319 ndlp->nlp_DID, irsp->ulpStatus,
2320 irsp->un.ulpWord[4], ndlp->fc4_prli_sent);
2321
2322
2323 if (!lpfc_error_lost_link(irsp))
2324 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2325 NLP_EVT_CMPL_PRLI);
2326
2327
2328
2329
2330
2331
2332 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
2333 !ndlp->fc4_prli_sent) {
2334 spin_lock_irq(&ndlp->lock);
2335 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2336 spin_unlock_irq(&ndlp->lock);
2337 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2338 NLP_EVT_DEVICE_RM);
2339 }
2340 } else {
2341
2342
2343
2344
2345
2346 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2347 NLP_EVT_CMPL_PRLI);
2348 }
2349
2350out:
2351 lpfc_els_free_iocb(phba, cmdiocb);
2352 lpfc_nlp_put(ndlp);
2353 return;
2354}
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376int
2377lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2378 uint8_t retry)
2379{
2380 int rc = 0;
2381 struct lpfc_hba *phba = vport->phba;
2382 PRLI *npr;
2383 struct lpfc_nvme_prli *npr_nvme;
2384 struct lpfc_iocbq *elsiocb;
2385 uint8_t *pcmd;
2386 uint16_t cmdsize;
2387 u32 local_nlp_type, elscmd;
2388
2389
2390
2391
2392
2393
2394
2395 if (phba->sli_rev == LPFC_SLI_REV4 &&
2396 vport->fc_flag & FC_RSCN_MODE &&
2397 vport->nvmei_support)
2398 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
2399 local_nlp_type = ndlp->nlp_fc4_type;
2400
2401
2402
2403
2404 ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
2405 ndlp->nlp_type &= ~(NLP_NVME_TARGET | NLP_NVME_INITIATOR);
2406 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
2407 ndlp->nlp_flag &= ~(NLP_FIRSTBURST | NLP_NPR_2B_DISC);
2408 ndlp->nvme_fb_size = 0;
2409
2410 send_next_prli:
2411 if (local_nlp_type & NLP_FC4_FCP) {
2412
2413 cmdsize = (sizeof(uint32_t) + sizeof(PRLI));
2414 elscmd = ELS_CMD_PRLI;
2415 } else if (local_nlp_type & NLP_FC4_NVME) {
2416
2417 cmdsize = (sizeof(uint32_t) + sizeof(struct lpfc_nvme_prli));
2418 elscmd = ELS_CMD_NVMEPRLI;
2419 } else {
2420 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2421 "3083 Unknown FC_TYPE x%x ndlp x%06x\n",
2422 ndlp->nlp_fc4_type, ndlp->nlp_DID);
2423 return 1;
2424 }
2425
2426
2427
2428
2429 if (phba->sli_rev == LPFC_SLI_REV3 &&
2430 ndlp->nlp_fc4_type == NLP_FC4_NVME) {
2431 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2432 "3088 Rport fc4 type 0x%x not supported by SLI3 adapter\n",
2433 ndlp->nlp_type);
2434 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
2435 return 1;
2436 }
2437
2438 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2439 ndlp->nlp_DID, elscmd);
2440 if (!elsiocb)
2441 return 1;
2442
2443 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2444
2445
2446 memset(pcmd, 0, cmdsize);
2447
2448 if (local_nlp_type & NLP_FC4_FCP) {
2449
2450
2451
2452
2453
2454 *((uint32_t *)(pcmd)) = ELS_CMD_PRLI;
2455 pcmd += sizeof(uint32_t);
2456 npr = (PRLI *)pcmd;
2457
2458
2459
2460
2461
2462 if (phba->vpd.rev.feaLevelHigh >= 0x02) {
2463 npr->ConfmComplAllowed = 1;
2464 npr->Retry = 1;
2465 npr->TaskRetryIdReq = 1;
2466 }
2467 npr->estabImagePair = 1;
2468 npr->readXferRdyDis = 1;
2469 if (vport->cfg_first_burst_size)
2470 npr->writeXferRdyDis = 1;
2471
2472
2473 npr->prliType = PRLI_FCP_TYPE;
2474 npr->initiatorFunc = 1;
2475 elsiocb->iocb_flag |= LPFC_PRLI_FCP_REQ;
2476
2477
2478 local_nlp_type &= ~NLP_FC4_FCP;
2479 } else if (local_nlp_type & NLP_FC4_NVME) {
2480
2481
2482
2483
2484 *((uint32_t *)(pcmd)) = ELS_CMD_NVMEPRLI;
2485 pcmd += sizeof(uint32_t);
2486 npr_nvme = (struct lpfc_nvme_prli *)pcmd;
2487 bf_set(prli_type_code, npr_nvme, PRLI_NVME_TYPE);
2488 bf_set(prli_estabImagePair, npr_nvme, 0);
2489 if (phba->nsler) {
2490 bf_set(prli_nsler, npr_nvme, 1);
2491 bf_set(prli_conf, npr_nvme, 1);
2492 }
2493
2494
2495 if ((phba->cfg_nvme_enable_fb) &&
2496 !phba->nvmet_support)
2497 bf_set(prli_fba, npr_nvme, 1);
2498
2499 if (phba->nvmet_support) {
2500 bf_set(prli_tgt, npr_nvme, 1);
2501 bf_set(prli_disc, npr_nvme, 1);
2502 } else {
2503 bf_set(prli_init, npr_nvme, 1);
2504 bf_set(prli_conf, npr_nvme, 1);
2505 }
2506
2507 npr_nvme->word1 = cpu_to_be32(npr_nvme->word1);
2508 npr_nvme->word4 = cpu_to_be32(npr_nvme->word4);
2509 elsiocb->iocb_flag |= LPFC_PRLI_NVME_REQ;
2510
2511
2512 local_nlp_type &= ~NLP_FC4_NVME;
2513 }
2514
2515 phba->fc_stat.elsXmitPRLI++;
2516 elsiocb->iocb_cmpl = lpfc_cmpl_els_prli;
2517 spin_lock_irq(&ndlp->lock);
2518 ndlp->nlp_flag |= NLP_PRLI_SND;
2519
2520
2521
2522
2523
2524 vport->fc_prli_sent++;
2525 ndlp->fc4_prli_sent++;
2526 spin_unlock_irq(&ndlp->lock);
2527
2528 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2529 "Issue PRLI: did:x%x refcnt %d",
2530 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
2531 elsiocb->context1 = lpfc_nlp_get(ndlp);
2532 if (!elsiocb->context1) {
2533 lpfc_els_free_iocb(phba, elsiocb);
2534 goto err;
2535 }
2536
2537 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
2538 if (rc == IOCB_ERROR) {
2539 lpfc_els_free_iocb(phba, elsiocb);
2540 lpfc_nlp_put(ndlp);
2541 goto err;
2542 }
2543
2544
2545
2546
2547
2548 if (phba->sli_rev == LPFC_SLI_REV4 &&
2549 local_nlp_type & (NLP_FC4_FCP | NLP_FC4_NVME))
2550 goto send_next_prli;
2551 else
2552 return 0;
2553
2554err:
2555 spin_lock_irq(&ndlp->lock);
2556 ndlp->nlp_flag &= ~NLP_PRLI_SND;
2557 spin_unlock_irq(&ndlp->lock);
2558 return 1;
2559}
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573static void
2574lpfc_rscn_disc(struct lpfc_vport *vport)
2575{
2576 lpfc_can_disctmo(vport);
2577
2578
2579
2580 if (vport->fc_npr_cnt)
2581 if (lpfc_els_disc_plogi(vport))
2582 return;
2583
2584 lpfc_end_rscn(vport);
2585}
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597static void
2598lpfc_adisc_done(struct lpfc_vport *vport)
2599{
2600 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2601 struct lpfc_hba *phba = vport->phba;
2602
2603
2604
2605
2606
2607 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
2608 !(vport->fc_flag & FC_RSCN_MODE) &&
2609 (phba->sli_rev < LPFC_SLI_REV4)) {
2610
2611
2612
2613
2614
2615
2616
2617
2618 lpfc_issue_clear_la(phba, vport);
2619 lpfc_issue_reg_vpi(phba, vport);
2620 return;
2621 }
2622
2623
2624
2625
2626 if (vport->port_state < LPFC_VPORT_READY) {
2627
2628 lpfc_issue_clear_la(phba, vport);
2629 if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) {
2630 vport->num_disc_nodes = 0;
2631
2632 if (vport->fc_npr_cnt)
2633 lpfc_els_disc_plogi(vport);
2634 if (!vport->num_disc_nodes) {
2635 spin_lock_irq(shost->host_lock);
2636 vport->fc_flag &= ~FC_NDISC_ACTIVE;
2637 spin_unlock_irq(shost->host_lock);
2638 lpfc_can_disctmo(vport);
2639 lpfc_end_rscn(vport);
2640 }
2641 }
2642 vport->port_state = LPFC_VPORT_READY;
2643 } else
2644 lpfc_rscn_disc(vport);
2645}
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656void
2657lpfc_more_adisc(struct lpfc_vport *vport)
2658{
2659 if (vport->num_disc_nodes)
2660 vport->num_disc_nodes--;
2661
2662 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2663 "0210 Continue discovery with %d ADISCs to go "
2664 "Data: x%x x%x x%x\n",
2665 vport->num_disc_nodes, vport->fc_adisc_cnt,
2666 vport->fc_flag, vport->port_state);
2667
2668 if (vport->fc_flag & FC_NLP_MORE) {
2669 lpfc_set_disctmo(vport);
2670
2671 lpfc_els_disc_adisc(vport);
2672 }
2673 if (!vport->num_disc_nodes)
2674 lpfc_adisc_done(vport);
2675 return;
2676}
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694static void
2695lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2696 struct lpfc_iocbq *rspiocb)
2697{
2698 struct lpfc_vport *vport = cmdiocb->vport;
2699 IOCB_t *irsp;
2700 struct lpfc_nodelist *ndlp;
2701 int disc;
2702
2703
2704 cmdiocb->context_un.rsp_iocb = rspiocb;
2705
2706 irsp = &(rspiocb->iocb);
2707 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2708
2709 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2710 "ADISC cmpl: status:x%x/x%x did:x%x",
2711 irsp->ulpStatus, irsp->un.ulpWord[4],
2712 ndlp->nlp_DID);
2713
2714
2715
2716
2717 spin_lock_irq(&ndlp->lock);
2718 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
2719 ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC);
2720 spin_unlock_irq(&ndlp->lock);
2721
2722 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2723 "0104 ADISC completes to NPort x%x "
2724 "Data: x%x x%x x%x x%x x%x\n",
2725 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
2726 irsp->ulpTimeout, disc, vport->num_disc_nodes);
2727
2728 if (lpfc_els_chk_latt(vport)) {
2729 spin_lock_irq(&ndlp->lock);
2730 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
2731 spin_unlock_irq(&ndlp->lock);
2732 goto out;
2733 }
2734
2735 if (irsp->ulpStatus) {
2736
2737 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) {
2738
2739 if (disc) {
2740 spin_lock_irq(&ndlp->lock);
2741 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
2742 spin_unlock_irq(&ndlp->lock);
2743 lpfc_set_disctmo(vport);
2744 }
2745 goto out;
2746 }
2747
2748 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2749 "2755 ADISC failure DID:%06X Status:x%x/x%x\n",
2750 ndlp->nlp_DID, irsp->ulpStatus,
2751 irsp->un.ulpWord[4]);
2752
2753 if (lpfc_error_lost_link(irsp))
2754 goto check_adisc;
2755 else
2756 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2757 NLP_EVT_CMPL_ADISC);
2758
2759
2760
2761
2762
2763 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2764 spin_lock_irq(&ndlp->lock);
2765 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2766 spin_unlock_irq(&ndlp->lock);
2767 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2768 NLP_EVT_DEVICE_RM);
2769 }
2770 } else
2771
2772 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2773 NLP_EVT_CMPL_ADISC);
2774
2775 check_adisc:
2776
2777 if (disc && vport->num_disc_nodes)
2778 lpfc_more_adisc(vport);
2779out:
2780 lpfc_els_free_iocb(phba, cmdiocb);
2781 lpfc_nlp_put(ndlp);
2782 return;
2783}
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804int
2805lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2806 uint8_t retry)
2807{
2808 int rc = 0;
2809 struct lpfc_hba *phba = vport->phba;
2810 ADISC *ap;
2811 struct lpfc_iocbq *elsiocb;
2812 uint8_t *pcmd;
2813 uint16_t cmdsize;
2814
2815 cmdsize = (sizeof(uint32_t) + sizeof(ADISC));
2816 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
2817 ndlp->nlp_DID, ELS_CMD_ADISC);
2818 if (!elsiocb)
2819 return 1;
2820
2821 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2822
2823
2824 *((uint32_t *) (pcmd)) = ELS_CMD_ADISC;
2825 pcmd += sizeof(uint32_t);
2826
2827
2828 ap = (ADISC *) pcmd;
2829 ap->hardAL_PA = phba->fc_pref_ALPA;
2830 memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name));
2831 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
2832 ap->DID = be32_to_cpu(vport->fc_myDID);
2833
2834 phba->fc_stat.elsXmitADISC++;
2835 elsiocb->iocb_cmpl = lpfc_cmpl_els_adisc;
2836 spin_lock_irq(&ndlp->lock);
2837 ndlp->nlp_flag |= NLP_ADISC_SND;
2838 spin_unlock_irq(&ndlp->lock);
2839 elsiocb->context1 = lpfc_nlp_get(ndlp);
2840 if (!elsiocb->context1) {
2841 lpfc_els_free_iocb(phba, elsiocb);
2842 goto err;
2843 }
2844
2845 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2846 "Issue ADISC: did:x%x refcnt %d",
2847 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
2848 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
2849 if (rc == IOCB_ERROR) {
2850 lpfc_els_free_iocb(phba, elsiocb);
2851 lpfc_nlp_put(ndlp);
2852 goto err;
2853 }
2854
2855 return 0;
2856
2857err:
2858 spin_lock_irq(&ndlp->lock);
2859 ndlp->nlp_flag &= ~NLP_ADISC_SND;
2860 spin_unlock_irq(&ndlp->lock);
2861 return 1;
2862}
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875static void
2876lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2877 struct lpfc_iocbq *rspiocb)
2878{
2879 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2880 struct lpfc_vport *vport = ndlp->vport;
2881 IOCB_t *irsp;
2882 unsigned long flags;
2883 uint32_t skip_recovery = 0;
2884 int wake_up_waiter = 0;
2885
2886
2887 cmdiocb->context_un.rsp_iocb = rspiocb;
2888
2889 irsp = &(rspiocb->iocb);
2890 spin_lock_irq(&ndlp->lock);
2891 ndlp->nlp_flag &= ~NLP_LOGO_SND;
2892 if (ndlp->upcall_flags & NLP_WAIT_FOR_LOGO) {
2893 wake_up_waiter = 1;
2894 ndlp->upcall_flags &= ~NLP_WAIT_FOR_LOGO;
2895 }
2896 spin_unlock_irq(&ndlp->lock);
2897
2898 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2899 "LOGO cmpl: status:x%x/x%x did:x%x",
2900 irsp->ulpStatus, irsp->un.ulpWord[4],
2901 ndlp->nlp_DID);
2902
2903
2904 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2905 "0105 LOGO completes to NPort x%x "
2906 "refcnt %d nflags x%x Data: x%x x%x x%x x%x\n",
2907 ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp->nlp_flag,
2908 irsp->ulpStatus, irsp->un.ulpWord[4],
2909 irsp->ulpTimeout, vport->num_disc_nodes);
2910
2911 if (lpfc_els_chk_latt(vport)) {
2912 skip_recovery = 1;
2913 goto out;
2914 }
2915
2916
2917
2918
2919
2920
2921 if (irsp->ulpStatus) {
2922
2923 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2924 "2756 LOGO failure, No Retry DID:%06X Status:x%x/x%x\n",
2925 ndlp->nlp_DID, irsp->ulpStatus,
2926 irsp->un.ulpWord[4]);
2927
2928 if (lpfc_error_lost_link(irsp)) {
2929 skip_recovery = 1;
2930 goto out;
2931 }
2932 }
2933
2934
2935 lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO);
2936
2937
2938
2939
2940 if (ndlp->nlp_flag & NLP_TARGET_REMOVE) {
2941 spin_lock_irq(&ndlp->lock);
2942 if (phba->sli_rev == LPFC_SLI_REV4)
2943 ndlp->nlp_flag |= NLP_RELEASE_RPI;
2944 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2945 spin_unlock_irq(&ndlp->lock);
2946 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2947 NLP_EVT_DEVICE_RM);
2948 lpfc_els_free_iocb(phba, cmdiocb);
2949 lpfc_nlp_put(ndlp);
2950
2951
2952 return;
2953 }
2954
2955out:
2956
2957 lpfc_els_free_iocb(phba, cmdiocb);
2958 lpfc_nlp_put(ndlp);
2959
2960
2961
2962
2963
2964
2965
2966 if (wake_up_waiter && ndlp->logo_waitq)
2967 wake_up(ndlp->logo_waitq);
2968
2969
2970
2971
2972
2973 if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET) &&
2974 skip_recovery == 0) {
2975 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2976 spin_lock_irqsave(&ndlp->lock, flags);
2977 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
2978 spin_unlock_irqrestore(&ndlp->lock, flags);
2979
2980 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2981 "3187 LOGO completes to NPort x%x: Start "
2982 "Recovery Data: x%x x%x x%x x%x\n",
2983 ndlp->nlp_DID, irsp->ulpStatus,
2984 irsp->un.ulpWord[4], irsp->ulpTimeout,
2985 vport->num_disc_nodes);
2986 lpfc_disc_start(vport);
2987 return;
2988 }
2989
2990
2991
2992
2993
2994
2995 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2996 spin_lock_irq(&ndlp->lock);
2997 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2998 spin_unlock_irq(&ndlp->lock);
2999 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
3000 NLP_EVT_DEVICE_RM);
3001 }
3002}
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025int
3026lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
3027 uint8_t retry)
3028{
3029 struct lpfc_hba *phba = vport->phba;
3030 struct lpfc_iocbq *elsiocb;
3031 uint8_t *pcmd;
3032 uint16_t cmdsize;
3033 int rc;
3034
3035 spin_lock_irq(&ndlp->lock);
3036 if (ndlp->nlp_flag & NLP_LOGO_SND) {
3037 spin_unlock_irq(&ndlp->lock);
3038 return 0;
3039 }
3040 spin_unlock_irq(&ndlp->lock);
3041
3042 cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name);
3043 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3044 ndlp->nlp_DID, ELS_CMD_LOGO);
3045 if (!elsiocb)
3046 return 1;
3047
3048 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
3049 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;
3050 pcmd += sizeof(uint32_t);
3051
3052
3053 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID);
3054 pcmd += sizeof(uint32_t);
3055 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name));
3056
3057 phba->fc_stat.elsXmitLOGO++;
3058 elsiocb->iocb_cmpl = lpfc_cmpl_els_logo;
3059 spin_lock_irq(&ndlp->lock);
3060 ndlp->nlp_flag |= NLP_LOGO_SND;
3061 ndlp->nlp_flag &= ~NLP_ISSUE_LOGO;
3062 spin_unlock_irq(&ndlp->lock);
3063 elsiocb->context1 = lpfc_nlp_get(ndlp);
3064 if (!elsiocb->context1) {
3065 lpfc_els_free_iocb(phba, elsiocb);
3066 goto err;
3067 }
3068
3069 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3070 "Issue LOGO: did:x%x refcnt %d",
3071 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
3072 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
3073 if (rc == IOCB_ERROR) {
3074 lpfc_els_free_iocb(phba, elsiocb);
3075 lpfc_nlp_put(ndlp);
3076 goto err;
3077 }
3078
3079 spin_lock_irq(&ndlp->lock);
3080 ndlp->nlp_prev_state = ndlp->nlp_state;
3081 spin_unlock_irq(&ndlp->lock);
3082 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
3083 return 0;
3084
3085err:
3086 spin_lock_irq(&ndlp->lock);
3087 ndlp->nlp_flag &= ~NLP_LOGO_SND;
3088 spin_unlock_irq(&ndlp->lock);
3089 return 1;
3090}
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107static void
3108lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3109 struct lpfc_iocbq *rspiocb)
3110{
3111 struct lpfc_vport *vport = cmdiocb->vport;
3112 struct lpfc_nodelist *free_ndlp;
3113 IOCB_t *irsp;
3114
3115 irsp = &rspiocb->iocb;
3116
3117 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3118 "ELS cmd cmpl: status:x%x/x%x did:x%x",
3119 irsp->ulpStatus, irsp->un.ulpWord[4],
3120 irsp->un.elsreq64.remoteID);
3121
3122
3123 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3124 "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n",
3125 irsp->ulpIoTag, irsp->ulpStatus,
3126 irsp->un.ulpWord[4], irsp->ulpTimeout);
3127
3128
3129 lpfc_els_chk_latt(vport);
3130
3131 free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
3132
3133 lpfc_els_free_iocb(phba, cmdiocb);
3134 lpfc_nlp_put(free_ndlp);
3135}
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151static int
3152lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp)
3153{
3154 int rc = 0;
3155 struct lpfc_hba *phba = vport->phba;
3156 struct lpfc_nodelist *ns_ndlp;
3157 LPFC_MBOXQ_t *mbox;
3158 struct lpfc_dmabuf *mp;
3159
3160 if (fc_ndlp->nlp_flag & NLP_RPI_REGISTERED)
3161 return rc;
3162
3163 ns_ndlp = lpfc_findnode_did(vport, NameServer_DID);
3164 if (!ns_ndlp)
3165 return -ENODEV;
3166
3167 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
3168 "0935 %s: Reg FC RPI x%x on FC DID x%x NSSte: x%x\n",
3169 __func__, fc_ndlp->nlp_rpi, fc_ndlp->nlp_DID,
3170 ns_ndlp->nlp_state);
3171 if (ns_ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
3172 return -ENODEV;
3173
3174 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3175 if (!mbox) {
3176 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3177 "0936 %s: no memory for reg_login "
3178 "Data: x%x x%x x%x x%x\n", __func__,
3179 fc_ndlp->nlp_DID, fc_ndlp->nlp_state,
3180 fc_ndlp->nlp_flag, fc_ndlp->nlp_rpi);
3181 return -ENOMEM;
3182 }
3183 rc = lpfc_reg_rpi(phba, vport->vpi, fc_ndlp->nlp_DID,
3184 (u8 *)&vport->fc_sparam, mbox, fc_ndlp->nlp_rpi);
3185 if (rc) {
3186 rc = -EACCES;
3187 goto out;
3188 }
3189
3190 fc_ndlp->nlp_flag |= NLP_REG_LOGIN_SEND;
3191 mbox->mbox_cmpl = lpfc_mbx_cmpl_fc_reg_login;
3192 mbox->ctx_ndlp = lpfc_nlp_get(fc_ndlp);
3193 if (!mbox->ctx_ndlp) {
3194 rc = -ENOMEM;
3195 goto out_mem;
3196 }
3197
3198 mbox->vport = vport;
3199 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
3200 if (rc == MBX_NOT_FINISHED) {
3201 rc = -ENODEV;
3202 lpfc_nlp_put(fc_ndlp);
3203 goto out_mem;
3204 }
3205
3206 lpfc_nlp_set_state(vport, fc_ndlp,
3207 NLP_STE_REG_LOGIN_ISSUE);
3208 return 0;
3209
3210 out_mem:
3211 fc_ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
3212 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
3213 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3214 kfree(mp);
3215
3216 out:
3217 mempool_free(mbox, phba->mbox_mem_pool);
3218 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3219 "0938 %s: failed to format reg_login "
3220 "Data: x%x x%x x%x x%x\n", __func__,
3221 fc_ndlp->nlp_DID, fc_ndlp->nlp_state,
3222 fc_ndlp->nlp_flag, fc_ndlp->nlp_rpi);
3223 return rc;
3224}
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237static void
3238lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3239 struct lpfc_iocbq *rspiocb)
3240{
3241 struct lpfc_vport *vport = cmdiocb->vport;
3242 IOCB_t *irsp;
3243 struct lpfc_els_rdf_rsp *prdf;
3244 struct lpfc_dmabuf *pcmd, *prsp;
3245 u32 *pdata;
3246 u32 cmd;
3247 struct lpfc_nodelist *ndlp = cmdiocb->context1;
3248
3249 irsp = &rspiocb->iocb;
3250
3251 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3252 "ELS cmd cmpl: status:x%x/x%x did:x%x",
3253 irsp->ulpStatus, irsp->un.ulpWord[4],
3254 irsp->un.elsreq64.remoteID);
3255
3256 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3257 "0217 ELS cmd tag x%x completes Data: x%x x%x x%x "
3258 "x%x\n",
3259 irsp->ulpIoTag, irsp->ulpStatus,
3260 irsp->un.ulpWord[4], irsp->ulpTimeout,
3261 cmdiocb->retry);
3262
3263 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;
3264 if (!pcmd)
3265 goto out;
3266
3267 pdata = (u32 *)pcmd->virt;
3268 if (!pdata)
3269 goto out;
3270 cmd = *pdata;
3271
3272
3273 if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT &&
3274 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
3275 IOERR_SEQUENCE_TIMEOUT)) {
3276 cmdiocb->retry++;
3277 if (cmdiocb->retry <= 1) {
3278 switch (cmd) {
3279 case ELS_CMD_SCR:
3280 lpfc_issue_els_scr(vport, cmdiocb->retry);
3281 break;
3282 case ELS_CMD_RDF:
3283 cmdiocb->context1 = NULL;
3284 lpfc_issue_els_rdf(vport, cmdiocb->retry);
3285 break;
3286 }
3287 goto out;
3288 }
3289 phba->fc_stat.elsRetryExceeded++;
3290 }
3291 if (irsp->ulpStatus) {
3292
3293 lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
3294 "4203 ELS cmd x%x error: x%x x%X\n", cmd,
3295 irsp->ulpStatus, irsp->un.ulpWord[4]);
3296 goto out;
3297 }
3298
3299
3300
3301
3302 if (cmd == ELS_CMD_RDF) {
3303 int i;
3304
3305 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
3306 if (!prsp)
3307 goto out;
3308
3309 prdf = (struct lpfc_els_rdf_rsp *)prsp->virt;
3310 if (!prdf)
3311 goto out;
3312
3313 for (i = 0; i < ELS_RDF_REG_TAG_CNT &&
3314 i < be32_to_cpu(prdf->reg_d1.reg_desc.count); i++)
3315 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3316 "4677 Fabric RDF Notification Grant Data: "
3317 "0x%08x\n",
3318 be32_to_cpu(
3319 prdf->reg_d1.desc_tags[i]));
3320 }
3321
3322out:
3323
3324 lpfc_els_chk_latt(vport);
3325 lpfc_els_free_iocb(phba, cmdiocb);
3326 lpfc_nlp_put(ndlp);
3327 return;
3328}
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350int
3351lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry)
3352{
3353 int rc = 0;
3354 struct lpfc_hba *phba = vport->phba;
3355 struct lpfc_iocbq *elsiocb;
3356 uint8_t *pcmd;
3357 uint16_t cmdsize;
3358 struct lpfc_nodelist *ndlp;
3359
3360 cmdsize = (sizeof(uint32_t) + sizeof(SCR));
3361
3362 ndlp = lpfc_findnode_did(vport, Fabric_Cntl_DID);
3363 if (!ndlp) {
3364 ndlp = lpfc_nlp_init(vport, Fabric_Cntl_DID);
3365 if (!ndlp)
3366 return 1;
3367 lpfc_enqueue_node(vport, ndlp);
3368 }
3369
3370 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3371 ndlp->nlp_DID, ELS_CMD_SCR);
3372 if (!elsiocb)
3373 return 1;
3374
3375 if (phba->sli_rev == LPFC_SLI_REV4) {
3376 rc = lpfc_reg_fab_ctrl_node(vport, ndlp);
3377 if (rc) {
3378 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3379 "0937 %s: Failed to reg fc node, rc %d\n",
3380 __func__, rc);
3381 return 1;
3382 }
3383 }
3384 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
3385
3386 *((uint32_t *) (pcmd)) = ELS_CMD_SCR;
3387 pcmd += sizeof(uint32_t);
3388
3389
3390 memset(pcmd, 0, sizeof(SCR));
3391 ((SCR *) pcmd)->Function = SCR_FUNC_FULL;
3392
3393 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3394 "Issue SCR: did:x%x",
3395 ndlp->nlp_DID, 0, 0);
3396
3397 phba->fc_stat.elsXmitSCR++;
3398 elsiocb->iocb_cmpl = lpfc_cmpl_els_disc_cmd;
3399 elsiocb->context1 = lpfc_nlp_get(ndlp);
3400 if (!elsiocb->context1) {
3401 lpfc_els_free_iocb(phba, elsiocb);
3402 return 1;
3403 }
3404
3405 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3406 "Issue SCR: did:x%x refcnt %d",
3407 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
3408
3409 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
3410 if (rc == IOCB_ERROR) {
3411 lpfc_els_free_iocb(phba, elsiocb);
3412 lpfc_nlp_put(ndlp);
3413 return 1;
3414 }
3415
3416
3417 return 0;
3418}
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439int
3440lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry)
3441{
3442 int rc = 0;
3443 struct lpfc_hba *phba = vport->phba;
3444 struct lpfc_iocbq *elsiocb;
3445 struct lpfc_nodelist *ndlp;
3446 struct {
3447 struct fc_els_rscn rscn;
3448 struct fc_els_rscn_page portid;
3449 } *event;
3450 uint32_t nportid;
3451 uint16_t cmdsize = sizeof(*event);
3452
3453
3454 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP &&
3455 !(vport->fc_flag & FC_PUBLIC_LOOP))
3456 return 1;
3457
3458 if (vport->fc_flag & FC_PT2PT) {
3459
3460 ndlp = lpfc_findnode_mapped(vport);
3461 if (!ndlp)
3462 return 1;
3463 } else {
3464 nportid = FC_FID_FCTRL;
3465
3466 ndlp = lpfc_findnode_did(vport, nportid);
3467 if (!ndlp) {
3468
3469 ndlp = lpfc_nlp_init(vport, nportid);
3470 if (!ndlp)
3471 return 1;
3472 lpfc_enqueue_node(vport, ndlp);
3473 }
3474 }
3475
3476 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3477 ndlp->nlp_DID, ELS_CMD_RSCN_XMT);
3478
3479 if (!elsiocb)
3480 return 1;
3481
3482 event = ((struct lpfc_dmabuf *)elsiocb->context2)->virt;
3483
3484 event->rscn.rscn_cmd = ELS_RSCN;
3485 event->rscn.rscn_page_len = sizeof(struct fc_els_rscn_page);
3486 event->rscn.rscn_plen = cpu_to_be16(cmdsize);
3487
3488 nportid = vport->fc_myDID;
3489
3490 event->portid.rscn_page_flags = 0;
3491 event->portid.rscn_fid[0] = (nportid & 0x00FF0000) >> 16;
3492 event->portid.rscn_fid[1] = (nportid & 0x0000FF00) >> 8;
3493 event->portid.rscn_fid[2] = nportid & 0x000000FF;
3494
3495 phba->fc_stat.elsXmitRSCN++;
3496 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;
3497 elsiocb->context1 = lpfc_nlp_get(ndlp);
3498 if (!elsiocb->context1) {
3499 lpfc_els_free_iocb(phba, elsiocb);
3500 return 1;
3501 }
3502
3503 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3504 "Issue RSCN: did:x%x",
3505 ndlp->nlp_DID, 0, 0);
3506
3507 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
3508 if (rc == IOCB_ERROR) {
3509 lpfc_els_free_iocb(phba, elsiocb);
3510 lpfc_nlp_put(ndlp);
3511 return 1;
3512 }
3513
3514
3515
3516
3517 if (!(vport->fc_flag & FC_PT2PT))
3518 lpfc_nlp_put(ndlp);
3519 return 0;
3520}
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543static int
3544lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry)
3545{
3546 int rc = 0;
3547 struct lpfc_hba *phba = vport->phba;
3548 struct lpfc_iocbq *elsiocb;
3549 FARP *fp;
3550 uint8_t *pcmd;
3551 uint32_t *lp;
3552 uint16_t cmdsize;
3553 struct lpfc_nodelist *ondlp;
3554 struct lpfc_nodelist *ndlp;
3555
3556 cmdsize = (sizeof(uint32_t) + sizeof(FARP));
3557
3558 ndlp = lpfc_findnode_did(vport, nportid);
3559 if (!ndlp) {
3560 ndlp = lpfc_nlp_init(vport, nportid);
3561 if (!ndlp)
3562 return 1;
3563 lpfc_enqueue_node(vport, ndlp);
3564 }
3565
3566 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3567 ndlp->nlp_DID, ELS_CMD_RNID);
3568 if (!elsiocb)
3569 return 1;
3570
3571 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
3572
3573 *((uint32_t *) (pcmd)) = ELS_CMD_FARPR;
3574 pcmd += sizeof(uint32_t);
3575
3576
3577 fp = (FARP *) (pcmd);
3578 memset(fp, 0, sizeof(FARP));
3579 lp = (uint32_t *) pcmd;
3580 *lp++ = be32_to_cpu(nportid);
3581 *lp++ = be32_to_cpu(vport->fc_myDID);
3582 fp->Rflags = 0;
3583 fp->Mflags = (FARP_MATCH_PORT | FARP_MATCH_NODE);
3584
3585 memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name));
3586 memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name));
3587 ondlp = lpfc_findnode_did(vport, nportid);
3588 if (ondlp) {
3589 memcpy(&fp->OportName, &ondlp->nlp_portname,
3590 sizeof(struct lpfc_name));
3591 memcpy(&fp->OnodeName, &ondlp->nlp_nodename,
3592 sizeof(struct lpfc_name));
3593 }
3594
3595 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3596 "Issue FARPR: did:x%x",
3597 ndlp->nlp_DID, 0, 0);
3598
3599 phba->fc_stat.elsXmitFARPR++;
3600 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;
3601 elsiocb->context1 = lpfc_nlp_get(ndlp);
3602 if (!elsiocb->context1) {
3603 lpfc_els_free_iocb(phba, elsiocb);
3604 return 1;
3605 }
3606
3607 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
3608 if (rc == IOCB_ERROR) {
3609
3610
3611
3612
3613 lpfc_els_free_iocb(phba, elsiocb);
3614 lpfc_nlp_put(ndlp);
3615 return 1;
3616 }
3617
3618
3619
3620
3621 return 0;
3622}
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640int
3641lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
3642{
3643 struct lpfc_hba *phba = vport->phba;
3644 struct lpfc_iocbq *elsiocb;
3645 struct lpfc_els_rdf_req *prdf;
3646 struct lpfc_nodelist *ndlp;
3647 uint16_t cmdsize;
3648 int rc;
3649
3650 cmdsize = sizeof(*prdf);
3651
3652 ndlp = lpfc_findnode_did(vport, Fabric_Cntl_DID);
3653 if (!ndlp) {
3654 ndlp = lpfc_nlp_init(vport, Fabric_Cntl_DID);
3655 if (!ndlp)
3656 return -ENODEV;
3657 lpfc_enqueue_node(vport, ndlp);
3658 }
3659
3660
3661 if (vport->port_type == LPFC_NPIV_PORT) {
3662 lpfc_nlp_put(ndlp);
3663 return -EACCES;
3664 }
3665
3666 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
3667 ndlp->nlp_DID, ELS_CMD_RDF);
3668 if (!elsiocb)
3669 return -ENOMEM;
3670
3671 if (phba->sli_rev == LPFC_SLI_REV4 &&
3672 !(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
3673 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3674 "0939 %s: FC_NODE x%x RPI x%x flag x%x "
3675 "ste x%x type x%x Not registered\n",
3676 __func__, ndlp->nlp_DID, ndlp->nlp_rpi,
3677 ndlp->nlp_flag, ndlp->nlp_state,
3678 ndlp->nlp_type);
3679 return -ENODEV;
3680 }
3681
3682
3683 prdf = (struct lpfc_els_rdf_req *)
3684 (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
3685 memset(prdf, 0, cmdsize);
3686 prdf->rdf.fpin_cmd = ELS_RDF;
3687 prdf->rdf.desc_len = cpu_to_be32(sizeof(struct lpfc_els_rdf_req) -
3688 sizeof(struct fc_els_rdf));
3689 prdf->reg_d1.reg_desc.desc_tag = cpu_to_be32(ELS_DTAG_FPIN_REGISTER);
3690 prdf->reg_d1.reg_desc.desc_len = cpu_to_be32(
3691 FC_TLV_DESC_LENGTH_FROM_SZ(prdf->reg_d1));
3692 prdf->reg_d1.reg_desc.count = cpu_to_be32(ELS_RDF_REG_TAG_CNT);
3693 prdf->reg_d1.desc_tags[0] = cpu_to_be32(ELS_DTAG_LNK_INTEGRITY);
3694 prdf->reg_d1.desc_tags[1] = cpu_to_be32(ELS_DTAG_DELIVERY);
3695 prdf->reg_d1.desc_tags[2] = cpu_to_be32(ELS_DTAG_PEER_CONGEST);
3696 prdf->reg_d1.desc_tags[3] = cpu_to_be32(ELS_DTAG_CONGESTION);
3697
3698 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3699 "6444 Xmit RDF to remote NPORT x%x\n",
3700 ndlp->nlp_DID);
3701
3702 elsiocb->iocb_cmpl = lpfc_cmpl_els_disc_cmd;
3703 elsiocb->context1 = lpfc_nlp_get(ndlp);
3704 if (!elsiocb->context1) {
3705 lpfc_els_free_iocb(phba, elsiocb);
3706 return -EIO;
3707 }
3708
3709 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
3710 "Issue RDF: did:x%x refcnt %d",
3711 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
3712
3713 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
3714 if (rc == IOCB_ERROR) {
3715 lpfc_els_free_iocb(phba, elsiocb);
3716 lpfc_nlp_put(ndlp);
3717 return -EIO;
3718 }
3719 return 0;
3720}
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736static int
3737lpfc_els_rcv_rdf(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3738 struct lpfc_nodelist *ndlp)
3739{
3740
3741 if (lpfc_els_rsp_acc(vport, ELS_CMD_RDF, cmdiocb, ndlp, NULL)) {
3742 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3743 "1623 Failed to RDF_ACC from x%x for x%x\n",
3744 ndlp->nlp_DID, vport->fc_myDID);
3745 return -EIO;
3746 }
3747
3748
3749 if (lpfc_issue_els_rdf(vport, 0)) {
3750 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3751 "2623 Failed to re register RDF for x%x\n",
3752 vport->fc_myDID);
3753 return -EIO;
3754 }
3755
3756 return 0;
3757}
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771void
3772lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
3773{
3774 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3775 struct lpfc_work_evt *evtp;
3776
3777 if (!(nlp->nlp_flag & NLP_DELAY_TMO))
3778 return;
3779 spin_lock_irq(&nlp->lock);
3780 nlp->nlp_flag &= ~NLP_DELAY_TMO;
3781 spin_unlock_irq(&nlp->lock);
3782 del_timer_sync(&nlp->nlp_delayfunc);
3783 nlp->nlp_last_elscmd = 0;
3784 if (!list_empty(&nlp->els_retry_evt.evt_listp)) {
3785 list_del_init(&nlp->els_retry_evt.evt_listp);
3786
3787 evtp = &nlp->els_retry_evt;
3788 lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1);
3789 }
3790 if (nlp->nlp_flag & NLP_NPR_2B_DISC) {
3791 spin_lock_irq(&nlp->lock);
3792 nlp->nlp_flag &= ~NLP_NPR_2B_DISC;
3793 spin_unlock_irq(&nlp->lock);
3794 if (vport->num_disc_nodes) {
3795 if (vport->port_state < LPFC_VPORT_READY) {
3796
3797 lpfc_more_adisc(vport);
3798 } else {
3799
3800 lpfc_more_plogi(vport);
3801 if (vport->num_disc_nodes == 0) {
3802 spin_lock_irq(shost->host_lock);
3803 vport->fc_flag &= ~FC_NDISC_ACTIVE;
3804 spin_unlock_irq(shost->host_lock);
3805 lpfc_can_disctmo(vport);
3806 lpfc_end_rscn(vport);
3807 }
3808 }
3809 }
3810 }
3811 return;
3812}
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828void
3829lpfc_els_retry_delay(struct timer_list *t)
3830{
3831 struct lpfc_nodelist *ndlp = from_timer(ndlp, t, nlp_delayfunc);
3832 struct lpfc_vport *vport = ndlp->vport;
3833 struct lpfc_hba *phba = vport->phba;
3834 unsigned long flags;
3835 struct lpfc_work_evt *evtp = &ndlp->els_retry_evt;
3836
3837 spin_lock_irqsave(&phba->hbalock, flags);
3838 if (!list_empty(&evtp->evt_listp)) {
3839 spin_unlock_irqrestore(&phba->hbalock, flags);
3840 return;
3841 }
3842
3843
3844
3845
3846 evtp->evt_arg1 = lpfc_nlp_get(ndlp);
3847 if (evtp->evt_arg1) {
3848 evtp->evt = LPFC_EVT_ELS_RETRY;
3849 list_add_tail(&evtp->evt_listp, &phba->work_list);
3850 lpfc_worker_wake_up(phba);
3851 }
3852 spin_unlock_irqrestore(&phba->hbalock, flags);
3853 return;
3854}
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865void
3866lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp)
3867{
3868 struct lpfc_vport *vport = ndlp->vport;
3869 uint32_t cmd, retry;
3870
3871 spin_lock_irq(&ndlp->lock);
3872 cmd = ndlp->nlp_last_elscmd;
3873 ndlp->nlp_last_elscmd = 0;
3874
3875 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
3876 spin_unlock_irq(&ndlp->lock);
3877 return;
3878 }
3879
3880 ndlp->nlp_flag &= ~NLP_DELAY_TMO;
3881 spin_unlock_irq(&ndlp->lock);
3882
3883
3884
3885
3886
3887 del_timer_sync(&ndlp->nlp_delayfunc);
3888 retry = ndlp->nlp_retry;
3889 ndlp->nlp_retry = 0;
3890
3891 switch (cmd) {
3892 case ELS_CMD_FLOGI:
3893 lpfc_issue_els_flogi(vport, ndlp, retry);
3894 break;
3895 case ELS_CMD_PLOGI:
3896 if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) {
3897 ndlp->nlp_prev_state = ndlp->nlp_state;
3898 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
3899 }
3900 break;
3901 case ELS_CMD_ADISC:
3902 if (!lpfc_issue_els_adisc(vport, ndlp, retry)) {
3903 ndlp->nlp_prev_state = ndlp->nlp_state;
3904 lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
3905 }
3906 break;
3907 case ELS_CMD_PRLI:
3908 case ELS_CMD_NVMEPRLI:
3909 if (!lpfc_issue_els_prli(vport, ndlp, retry)) {
3910 ndlp->nlp_prev_state = ndlp->nlp_state;
3911 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
3912 }
3913 break;
3914 case ELS_CMD_LOGO:
3915 if (!lpfc_issue_els_logo(vport, ndlp, retry)) {
3916 ndlp->nlp_prev_state = ndlp->nlp_state;
3917 lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
3918 }
3919 break;
3920 case ELS_CMD_FDISC:
3921 if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI))
3922 lpfc_issue_els_fdisc(vport, ndlp, retry);
3923 break;
3924 }
3925 return;
3926}
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940int
3941lpfc_link_reset(struct lpfc_vport *vport)
3942{
3943 struct lpfc_hba *phba = vport->phba;
3944 LPFC_MBOXQ_t *mbox;
3945 uint32_t control;
3946 int rc;
3947
3948 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3949 "2851 Attempt link reset\n");
3950 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3951 if (!mbox) {
3952 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
3953 "2852 Failed to allocate mbox memory");
3954 return 1;
3955 }
3956
3957
3958 if (phba->sli_rev <= LPFC_SLI_REV3) {
3959 spin_lock_irq(&phba->hbalock);
3960 phba->sli.sli_flag |= LPFC_PROCESS_LA;
3961 control = readl(phba->HCregaddr);
3962 control |= HC_LAINT_ENA;
3963 writel(control, phba->HCregaddr);
3964 readl(phba->HCregaddr);
3965 spin_unlock_irq(&phba->hbalock);
3966 }
3967
3968 lpfc_init_link(phba, mbox, phba->cfg_topology,
3969 phba->cfg_link_speed);
3970 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
3971 mbox->vport = vport;
3972 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
3973 if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) {
3974 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
3975 "2853 Failed to issue INIT_LINK "
3976 "mbox command, rc:x%x\n", rc);
3977 mempool_free(mbox, phba->mbox_mem_pool);
3978 return 1;
3979 }
3980
3981 return 0;
3982}
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005static int
4006lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4007 struct lpfc_iocbq *rspiocb)
4008{
4009 struct lpfc_vport *vport = cmdiocb->vport;
4010 IOCB_t *irsp = &rspiocb->iocb;
4011 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
4012 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
4013 uint32_t *elscmd;
4014 struct ls_rjt stat;
4015 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;
4016 int logerr = 0;
4017 uint32_t cmd = 0;
4018 uint32_t did;
4019 int link_reset = 0, rc;
4020
4021
4022
4023
4024
4025
4026 if (pcmd && pcmd->virt) {
4027 elscmd = (uint32_t *) (pcmd->virt);
4028 cmd = *elscmd++;
4029 }
4030
4031 if (ndlp)
4032 did = ndlp->nlp_DID;
4033 else {
4034
4035 did = irsp->un.elsreq64.remoteID;
4036 ndlp = lpfc_findnode_did(vport, did);
4037 if (!ndlp && (cmd != ELS_CMD_PLOGI))
4038 return 0;
4039 }
4040
4041 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
4042 "Retry ELS: wd7:x%x wd4:x%x did:x%x",
4043 *(((uint32_t *)irsp) + 7), irsp->un.ulpWord[4], did);
4044
4045 switch (irsp->ulpStatus) {
4046 case IOSTAT_FCP_RSP_ERROR:
4047 break;
4048 case IOSTAT_REMOTE_STOP:
4049 if (phba->sli_rev == LPFC_SLI_REV4) {
4050
4051
4052
4053
4054 lpfc_set_rrq_active(phba, ndlp,
4055 cmdiocb->sli4_lxritag, 0, 0);
4056 }
4057 break;
4058 case IOSTAT_LOCAL_REJECT:
4059 switch ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK)) {
4060 case IOERR_LOOP_OPEN_FAILURE:
4061 if (cmd == ELS_CMD_FLOGI) {
4062 if (PCI_DEVICE_ID_HORNET ==
4063 phba->pcidev->device) {
4064 phba->fc_topology = LPFC_TOPOLOGY_LOOP;
4065 phba->pport->fc_myDID = 0;
4066 phba->alpa_map[0] = 0;
4067 phba->alpa_map[1] = 0;
4068 }
4069 }
4070 if (cmd == ELS_CMD_PLOGI && cmdiocb->retry == 0)
4071 delay = 1000;
4072 retry = 1;
4073 break;
4074
4075 case IOERR_ILLEGAL_COMMAND:
4076 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
4077 "0124 Retry illegal cmd x%x "
4078 "retry:x%x delay:x%x\n",
4079 cmd, cmdiocb->retry, delay);
4080 retry = 1;
4081
4082 maxretry = 8;
4083 if (cmdiocb->retry > 2)
4084 delay = 1000;
4085 break;
4086
4087 case IOERR_NO_RESOURCES:
4088 logerr = 1;
4089 retry = 1;
4090 if (cmdiocb->retry > 100)
4091 delay = 100;
4092 maxretry = 250;
4093 break;
4094
4095 case IOERR_ILLEGAL_FRAME:
4096 delay = 100;
4097 retry = 1;
4098 break;
4099
4100 case IOERR_INVALID_RPI:
4101 if (cmd == ELS_CMD_PLOGI &&
4102 did == NameServer_DID) {
4103
4104
4105 maxretry = 0;
4106 delay = 100;
4107 }
4108 retry = 1;
4109 break;
4110
4111 case IOERR_SEQUENCE_TIMEOUT:
4112 if (cmd == ELS_CMD_PLOGI &&
4113 did == NameServer_DID &&
4114 (cmdiocb->retry + 1) == maxretry) {
4115
4116 link_reset = 1;
4117 break;
4118 }
4119 retry = 1;
4120 delay = 100;
4121 break;
4122 }
4123 break;
4124
4125 case IOSTAT_NPORT_RJT:
4126 case IOSTAT_FABRIC_RJT:
4127 if (irsp->un.ulpWord[4] & RJT_UNAVAIL_TEMP) {
4128 retry = 1;
4129 break;
4130 }
4131 break;
4132
4133 case IOSTAT_NPORT_BSY:
4134 case IOSTAT_FABRIC_BSY:
4135 logerr = 1;
4136 retry = 1;
4137 break;
4138
4139 case IOSTAT_LS_RJT:
4140 stat.un.lsRjtError = be32_to_cpu(irsp->un.ulpWord[4]);
4141
4142
4143
4144 switch (stat.un.b.lsRjtRsnCode) {
4145 case LSRJT_UNABLE_TPC:
4146
4147
4148
4149
4150
4151
4152
4153 if ((cmd == ELS_CMD_PRLI || cmd == ELS_CMD_NVMEPRLI) &&
4154 stat.un.b.lsRjtRsnCodeExp !=
4155 LSEXP_REQ_UNSUPPORTED) {
4156 delay = 1000;
4157 maxretry = lpfc_max_els_tries + 1;
4158 retry = 1;
4159 break;
4160 }
4161
4162
4163 if (stat.un.b.lsRjtRsnCodeExp ==
4164 LSEXP_CMD_IN_PROGRESS) {
4165 if (cmd == ELS_CMD_PLOGI) {
4166 delay = 1000;
4167 maxretry = 48;
4168 }
4169 retry = 1;
4170 break;
4171 }
4172 if (stat.un.b.lsRjtRsnCodeExp ==
4173 LSEXP_CANT_GIVE_DATA) {
4174 if (cmd == ELS_CMD_PLOGI) {
4175 delay = 1000;
4176 maxretry = 48;
4177 }
4178 retry = 1;
4179 break;
4180 }
4181 if (cmd == ELS_CMD_PLOGI) {
4182 delay = 1000;
4183 maxretry = lpfc_max_els_tries + 1;
4184 retry = 1;
4185 break;
4186 }
4187 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
4188 (cmd == ELS_CMD_FDISC) &&
4189 (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){
4190 lpfc_printf_vlog(vport, KERN_ERR,
4191 LOG_TRACE_EVENT,
4192 "0125 FDISC Failed (x%x). "
4193 "Fabric out of resources\n",
4194 stat.un.lsRjtError);
4195 lpfc_vport_set_state(vport,
4196 FC_VPORT_NO_FABRIC_RSCS);
4197 }
4198 break;
4199
4200 case LSRJT_LOGICAL_BSY:
4201 if ((cmd == ELS_CMD_PLOGI) ||
4202 (cmd == ELS_CMD_PRLI) ||
4203 (cmd == ELS_CMD_NVMEPRLI)) {
4204 delay = 1000;
4205 maxretry = 48;
4206 } else if (cmd == ELS_CMD_FDISC) {
4207
4208 maxretry = 48;
4209 if (cmdiocb->retry >= 32)
4210 delay = 1000;
4211 }
4212 retry = 1;
4213 break;
4214
4215 case LSRJT_LOGICAL_ERR:
4216
4217
4218
4219
4220 if (cmd == ELS_CMD_FDISC &&
4221 stat.un.b.lsRjtRsnCodeExp == LSEXP_PORT_LOGIN_REQ) {
4222 maxretry = 3;
4223 delay = 1000;
4224 retry = 1;
4225 } else if (cmd == ELS_CMD_FLOGI &&
4226 stat.un.b.lsRjtRsnCodeExp ==
4227 LSEXP_NOTHING_MORE) {
4228 vport->fc_sparam.cmn.bbRcvSizeMsb &= 0xf;
4229 retry = 1;
4230 lpfc_printf_vlog(vport, KERN_ERR,
4231 LOG_TRACE_EVENT,
4232 "0820 FLOGI Failed (x%x). "
4233 "BBCredit Not Supported\n",
4234 stat.un.lsRjtError);
4235 }
4236 break;
4237
4238 case LSRJT_PROTOCOL_ERR:
4239 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
4240 (cmd == ELS_CMD_FDISC) &&
4241 ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) ||
4242 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID))
4243 ) {