0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include <linux/blkdev.h>
0028 #include <linux/pci.h>
0029 #include <linux/interrupt.h>
0030 #include <linux/slab.h>
0031 #include <linux/utsname.h>
0032
0033 #include <scsi/scsi.h>
0034 #include <scsi/scsi_device.h>
0035 #include <scsi/scsi_host.h>
0036 #include <scsi/scsi_transport_fc.h>
0037 #include <scsi/fc/fc_fs.h>
0038
0039 #include "lpfc_hw4.h"
0040 #include "lpfc_hw.h"
0041 #include "lpfc_sli.h"
0042 #include "lpfc_sli4.h"
0043 #include "lpfc_nl.h"
0044 #include "lpfc_disc.h"
0045 #include "lpfc.h"
0046 #include "lpfc_scsi.h"
0047 #include "lpfc_logmsg.h"
0048 #include "lpfc_crtn.h"
0049 #include "lpfc_version.h"
0050 #include "lpfc_vport.h"
0051 #include "lpfc_debugfs.h"
0052
0053
0054 #define HBA_PORTSPEED_1GFC 0x00000001
0055 #define HBA_PORTSPEED_2GFC 0x00000002
0056 #define HBA_PORTSPEED_4GFC 0x00000008
0057 #define HBA_PORTSPEED_10GFC 0x00000004
0058 #define HBA_PORTSPEED_8GFC 0x00000010
0059 #define HBA_PORTSPEED_16GFC 0x00000020
0060 #define HBA_PORTSPEED_32GFC 0x00000040
0061 #define HBA_PORTSPEED_20GFC 0x00000080
0062 #define HBA_PORTSPEED_40GFC 0x00000100
0063 #define HBA_PORTSPEED_128GFC 0x00000200
0064 #define HBA_PORTSPEED_64GFC 0x00000400
0065 #define HBA_PORTSPEED_256GFC 0x00000800
0066 #define HBA_PORTSPEED_UNKNOWN 0x00008000
0067 #define HBA_PORTSPEED_10GE 0x00010000
0068 #define HBA_PORTSPEED_40GE 0x00020000
0069 #define HBA_PORTSPEED_100GE 0x00040000
0070 #define HBA_PORTSPEED_25GE 0x00080000
0071 #define HBA_PORTSPEED_50GE 0x00100000
0072 #define HBA_PORTSPEED_400GE 0x00200000
0073
0074 #define FOURBYTES 4
0075
0076
0077 static char *lpfc_release_version = LPFC_DRIVER_VERSION;
0078 static void
0079 lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
0080 struct lpfc_iocbq *rspiocb);
0081
0082 static void
0083 lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
0084 struct lpfc_dmabuf *mp, uint32_t size)
0085 {
0086 if (!mp) {
0087 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
0088 "0146 Ignoring unsolicited CT No HBQ "
0089 "status = x%x\n",
0090 get_job_ulpstatus(phba, piocbq));
0091 }
0092 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
0093 "0145 Ignoring unsolicted CT HBQ Size:%d "
0094 "status = x%x\n",
0095 size, get_job_ulpstatus(phba, piocbq));
0096 }
0097
0098 static void
0099 lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
0100 struct lpfc_dmabuf *mp, uint32_t size)
0101 {
0102 lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size);
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 static void
0115 lpfc_ct_unsol_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
0116 struct lpfc_iocbq *rspiocb)
0117 {
0118 struct lpfc_nodelist *ndlp;
0119 struct lpfc_dmabuf *mp, *bmp;
0120
0121 ndlp = cmdiocb->ndlp;
0122 if (ndlp)
0123 lpfc_nlp_put(ndlp);
0124
0125 mp = cmdiocb->rsp_dmabuf;
0126 bmp = cmdiocb->bpl_dmabuf;
0127 if (mp) {
0128 lpfc_mbuf_free(phba, mp->virt, mp->phys);
0129 kfree(mp);
0130 cmdiocb->rsp_dmabuf = NULL;
0131 }
0132
0133 if (bmp) {
0134 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
0135 kfree(bmp);
0136 cmdiocb->bpl_dmabuf = NULL;
0137 }
0138
0139 lpfc_sli_release_iocbq(phba, cmdiocb);
0140 }
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152 static void
0153 lpfc_ct_reject_event(struct lpfc_nodelist *ndlp,
0154 struct lpfc_sli_ct_request *ct_req,
0155 u16 ulp_context, u16 ox_id)
0156 {
0157 struct lpfc_vport *vport = ndlp->vport;
0158 struct lpfc_hba *phba = vport->phba;
0159 struct lpfc_sli_ct_request *ct_rsp;
0160 struct lpfc_iocbq *cmdiocbq = NULL;
0161 struct lpfc_dmabuf *bmp = NULL;
0162 struct lpfc_dmabuf *mp = NULL;
0163 struct ulp_bde64 *bpl;
0164 u8 rc = 0;
0165 u32 tmo;
0166
0167
0168 mp = kmalloc(sizeof(*mp), GFP_KERNEL);
0169 if (!mp) {
0170 rc = 1;
0171 goto ct_exit;
0172 }
0173
0174 mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp->phys);
0175 if (!mp->virt) {
0176 rc = 2;
0177 goto ct_free_mp;
0178 }
0179
0180
0181 bmp = kmalloc(sizeof(*bmp), GFP_KERNEL);
0182 if (!bmp) {
0183 rc = 3;
0184 goto ct_free_mpvirt;
0185 }
0186
0187 bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &bmp->phys);
0188 if (!bmp->virt) {
0189 rc = 4;
0190 goto ct_free_bmp;
0191 }
0192
0193 INIT_LIST_HEAD(&mp->list);
0194 INIT_LIST_HEAD(&bmp->list);
0195
0196 bpl = (struct ulp_bde64 *)bmp->virt;
0197 memset(bpl, 0, sizeof(struct ulp_bde64));
0198 bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys));
0199 bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys));
0200 bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
0201 bpl->tus.f.bdeSize = (LPFC_CT_PREAMBLE - 4);
0202 bpl->tus.w = le32_to_cpu(bpl->tus.w);
0203
0204 ct_rsp = (struct lpfc_sli_ct_request *)mp->virt;
0205 memset(ct_rsp, 0, sizeof(struct lpfc_sli_ct_request));
0206
0207 ct_rsp->RevisionId.bits.Revision = SLI_CT_REVISION;
0208 ct_rsp->RevisionId.bits.InId = 0;
0209 ct_rsp->FsType = ct_req->FsType;
0210 ct_rsp->FsSubType = ct_req->FsSubType;
0211 ct_rsp->CommandResponse.bits.Size = 0;
0212 ct_rsp->CommandResponse.bits.CmdRsp =
0213 cpu_to_be16(SLI_CT_RESPONSE_FS_RJT);
0214 ct_rsp->ReasonCode = SLI_CT_REQ_NOT_SUPPORTED;
0215 ct_rsp->Explanation = SLI_CT_NO_ADDITIONAL_EXPL;
0216
0217 cmdiocbq = lpfc_sli_get_iocbq(phba);
0218 if (!cmdiocbq) {
0219 rc = 5;
0220 goto ct_free_bmpvirt;
0221 }
0222
0223 if (phba->sli_rev == LPFC_SLI_REV4) {
0224 lpfc_sli_prep_xmit_seq64(phba, cmdiocbq, bmp,
0225 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi],
0226 ox_id, 1, FC_RCTL_DD_SOL_CTL, 1,
0227 CMD_XMIT_SEQUENCE64_WQE);
0228 } else {
0229 lpfc_sli_prep_xmit_seq64(phba, cmdiocbq, bmp, 0, ulp_context, 1,
0230 FC_RCTL_DD_SOL_CTL, 1,
0231 CMD_XMIT_SEQUENCE64_CX);
0232 }
0233
0234
0235 cmdiocbq->rsp_dmabuf = mp;
0236 cmdiocbq->bpl_dmabuf = bmp;
0237 cmdiocbq->cmd_cmpl = lpfc_ct_unsol_cmpl;
0238 tmo = (3 * phba->fc_ratov);
0239
0240 cmdiocbq->retry = 0;
0241 cmdiocbq->vport = vport;
0242 cmdiocbq->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;
0243
0244 cmdiocbq->ndlp = lpfc_nlp_get(ndlp);
0245 if (!cmdiocbq->ndlp)
0246 goto ct_no_ndlp;
0247
0248 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
0249 if (rc) {
0250 lpfc_nlp_put(ndlp);
0251 goto ct_no_ndlp;
0252 }
0253 return;
0254
0255 ct_no_ndlp:
0256 rc = 6;
0257 lpfc_sli_release_iocbq(phba, cmdiocbq);
0258 ct_free_bmpvirt:
0259 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
0260 ct_free_bmp:
0261 kfree(bmp);
0262 ct_free_mpvirt:
0263 lpfc_mbuf_free(phba, mp->virt, mp->phys);
0264 ct_free_mp:
0265 kfree(mp);
0266 ct_exit:
0267 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
0268 "6440 Unsol CT: Rsp err %d Data: x%x\n",
0269 rc, vport->fc_flag);
0270 }
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281 static void
0282 lpfc_ct_handle_mibreq(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocbq)
0283 {
0284 struct lpfc_sli_ct_request *ct_req;
0285 struct lpfc_nodelist *ndlp = NULL;
0286 struct lpfc_vport *vport = ctiocbq->vport;
0287 u32 ulp_status = get_job_ulpstatus(phba, ctiocbq);
0288 u32 ulp_word4 = get_job_word4(phba, ctiocbq);
0289 u32 did;
0290 u32 mi_cmd;
0291
0292 did = bf_get(els_rsp64_sid, &ctiocbq->wqe.xmit_els_rsp);
0293 if (ulp_status) {
0294 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
0295 "6438 Unsol CT: status:x%x/x%x did : x%x\n",
0296 ulp_status, ulp_word4, did);
0297 return;
0298 }
0299
0300
0301 if (vport->fc_flag & FC_UNLOADING)
0302 return;
0303
0304 ndlp = lpfc_findnode_did(vport, did);
0305 if (!ndlp) {
0306 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
0307 "6439 Unsol CT: NDLP Not Found for DID : x%x",
0308 did);
0309 return;
0310 }
0311
0312 ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt;
0313
0314 mi_cmd = ct_req->CommandResponse.bits.CmdRsp;
0315 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
0316 "6442 : MI Cmd : x%x Not Supported\n", mi_cmd);
0317 lpfc_ct_reject_event(ndlp, ct_req,
0318 bf_get(wqe_ctxt_tag,
0319 &ctiocbq->wqe.xmit_els_rsp.wqe_com),
0320 bf_get(wqe_rcvoxid,
0321 &ctiocbq->wqe.xmit_els_rsp.wqe_com));
0322 }
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336 void
0337 lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
0338 struct lpfc_iocbq *ctiocbq)
0339 {
0340 struct lpfc_dmabuf *mp = NULL;
0341 IOCB_t *icmd = &ctiocbq->iocb;
0342 int i;
0343 struct lpfc_iocbq *iocbq;
0344 struct lpfc_iocbq *iocb;
0345 dma_addr_t dma_addr;
0346 uint32_t size;
0347 struct list_head head;
0348 struct lpfc_sli_ct_request *ct_req;
0349 struct lpfc_dmabuf *bdeBuf1 = ctiocbq->cmd_dmabuf;
0350 struct lpfc_dmabuf *bdeBuf2 = ctiocbq->bpl_dmabuf;
0351 u32 status, parameter, bde_count = 0;
0352 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
0353
0354 ctiocbq->cmd_dmabuf = NULL;
0355 ctiocbq->rsp_dmabuf = NULL;
0356 ctiocbq->bpl_dmabuf = NULL;
0357
0358 wcqe_cmpl = &ctiocbq->wcqe_cmpl;
0359 status = get_job_ulpstatus(phba, ctiocbq);
0360 parameter = get_job_word4(phba, ctiocbq);
0361 if (phba->sli_rev == LPFC_SLI_REV4)
0362 bde_count = wcqe_cmpl->word3;
0363 else
0364 bde_count = icmd->ulpBdeCount;
0365
0366 if (unlikely(status == IOSTAT_NEED_BUFFER)) {
0367 lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ);
0368 } else if ((status == IOSTAT_LOCAL_REJECT) &&
0369 ((parameter & IOERR_PARAM_MASK) ==
0370 IOERR_RCV_BUFFER_WAITING)) {
0371
0372 phba->fc_stat.NoRcvBuf++;
0373 if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED))
0374 lpfc_sli3_post_buffer(phba, pring, 2);
0375 return;
0376 }
0377
0378
0379
0380
0381 if (bde_count == 0)
0382 return;
0383
0384 ctiocbq->cmd_dmabuf = bdeBuf1;
0385 if (bde_count == 2)
0386 ctiocbq->bpl_dmabuf = bdeBuf2;
0387
0388 ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt;
0389
0390 if (ct_req->FsType == SLI_CT_MANAGEMENT_SERVICE &&
0391 ct_req->FsSubType == SLI_CT_MIB_Subtypes) {
0392 lpfc_ct_handle_mibreq(phba, ctiocbq);
0393 } else {
0394 if (!lpfc_bsg_ct_unsol_event(phba, pring, ctiocbq))
0395 return;
0396 }
0397
0398 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
0399 INIT_LIST_HEAD(&head);
0400 list_add_tail(&head, &ctiocbq->list);
0401 list_for_each_entry(iocb, &head, list) {
0402 if (phba->sli_rev == LPFC_SLI_REV4)
0403 bde_count = iocb->wcqe_cmpl.word3;
0404 else
0405 bde_count = iocb->iocb.ulpBdeCount;
0406
0407 if (!bde_count)
0408 continue;
0409 bdeBuf1 = iocb->cmd_dmabuf;
0410 iocb->cmd_dmabuf = NULL;
0411 if (phba->sli_rev == LPFC_SLI_REV4)
0412 size = iocb->wqe.gen_req.bde.tus.f.bdeSize;
0413 else
0414 size = iocb->iocb.un.cont64[0].tus.f.bdeSize;
0415 lpfc_ct_unsol_buffer(phba, ctiocbq, bdeBuf1, size);
0416 lpfc_in_buf_free(phba, bdeBuf1);
0417 if (bde_count == 2) {
0418 bdeBuf2 = iocb->bpl_dmabuf;
0419 iocb->bpl_dmabuf = NULL;
0420 if (phba->sli_rev == LPFC_SLI_REV4)
0421 size = iocb->unsol_rcv_len;
0422 else
0423 size = iocb->iocb.unsli3.rcvsli3.bde2.tus.f.bdeSize;
0424 lpfc_ct_unsol_buffer(phba, ctiocbq, bdeBuf2,
0425 size);
0426 lpfc_in_buf_free(phba, bdeBuf2);
0427 }
0428 }
0429 list_del(&head);
0430 } else {
0431 INIT_LIST_HEAD(&head);
0432 list_add_tail(&head, &ctiocbq->list);
0433 list_for_each_entry(iocbq, &head, list) {
0434 icmd = &iocbq->iocb;
0435 if (icmd->ulpBdeCount == 0)
0436 lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0);
0437 for (i = 0; i < icmd->ulpBdeCount; i++) {
0438 dma_addr = getPaddr(icmd->un.cont64[i].addrHigh,
0439 icmd->un.cont64[i].addrLow);
0440 mp = lpfc_sli_ringpostbuf_get(phba, pring,
0441 dma_addr);
0442 size = icmd->un.cont64[i].tus.f.bdeSize;
0443 lpfc_ct_unsol_buffer(phba, iocbq, mp, size);
0444 lpfc_in_buf_free(phba, mp);
0445 }
0446 lpfc_sli3_post_buffer(phba, pring, i);
0447 }
0448 list_del(&head);
0449 }
0450 }
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462 int
0463 lpfc_ct_handle_unsol_abort(struct lpfc_hba *phba, struct hbq_dmabuf *dmabuf)
0464 {
0465 int handled;
0466
0467
0468 handled = lpfc_bsg_ct_unsol_abort(phba, dmabuf);
0469
0470 return handled;
0471 }
0472
0473 static void
0474 lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist)
0475 {
0476 struct lpfc_dmabuf *mlast, *next_mlast;
0477
0478 list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) {
0479 lpfc_mbuf_free(phba, mlast->virt, mlast->phys);
0480 list_del(&mlast->list);
0481 kfree(mlast);
0482 }
0483 lpfc_mbuf_free(phba, mlist->virt, mlist->phys);
0484 kfree(mlist);
0485 return;
0486 }
0487
0488 static struct lpfc_dmabuf *
0489 lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl,
0490 uint32_t size, int *entries)
0491 {
0492 struct lpfc_dmabuf *mlist = NULL;
0493 struct lpfc_dmabuf *mp;
0494 int cnt, i = 0;
0495
0496
0497 cnt = size > FCELSSIZE ? FCELSSIZE: size;
0498
0499 while (size) {
0500
0501 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
0502 if (!mp) {
0503 if (mlist)
0504 lpfc_free_ct_rsp(phba, mlist);
0505 return NULL;
0506 }
0507
0508 INIT_LIST_HEAD(&mp->list);
0509
0510 if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT) ||
0511 cmdcode == be16_to_cpu(SLI_CTNS_GFF_ID))
0512 mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys));
0513 else
0514 mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys));
0515
0516 if (!mp->virt) {
0517 kfree(mp);
0518 if (mlist)
0519 lpfc_free_ct_rsp(phba, mlist);
0520 return NULL;
0521 }
0522
0523
0524 if (!mlist)
0525 mlist = mp;
0526 else
0527 list_add_tail(&mp->list, &mlist->list);
0528
0529 bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I;
0530
0531 bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) );
0532 bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) );
0533 bpl->tus.f.bdeSize = (uint16_t) cnt;
0534 bpl->tus.w = le32_to_cpu(bpl->tus.w);
0535 bpl++;
0536
0537 i++;
0538 size -= cnt;
0539 }
0540
0541 *entries = i;
0542 return mlist;
0543 }
0544
0545 int
0546 lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb)
0547 {
0548 struct lpfc_dmabuf *buf_ptr;
0549
0550
0551
0552
0553 if (ctiocb->cmd_dmabuf) {
0554 buf_ptr = ctiocb->cmd_dmabuf;
0555 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
0556 kfree(buf_ptr);
0557 ctiocb->cmd_dmabuf = NULL;
0558 }
0559 if (ctiocb->rsp_dmabuf) {
0560 lpfc_free_ct_rsp(phba, ctiocb->rsp_dmabuf);
0561 ctiocb->rsp_dmabuf = NULL;
0562 }
0563
0564 if (ctiocb->bpl_dmabuf) {
0565 buf_ptr = ctiocb->bpl_dmabuf;
0566 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
0567 kfree(buf_ptr);
0568 ctiocb->bpl_dmabuf = NULL;
0569 }
0570 lpfc_sli_release_iocbq(phba, ctiocb);
0571 return 0;
0572 }
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585 static int
0586 lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp,
0587 struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp,
0588 void (*cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
0589 struct lpfc_iocbq *),
0590 struct lpfc_nodelist *ndlp, uint32_t event_tag, uint32_t num_entry,
0591 uint32_t tmo, uint8_t retry)
0592 {
0593 struct lpfc_hba *phba = vport->phba;
0594 struct lpfc_iocbq *geniocb;
0595 int rc;
0596 u16 ulp_context;
0597
0598
0599 geniocb = lpfc_sli_get_iocbq(phba);
0600
0601 if (geniocb == NULL)
0602 return 1;
0603
0604
0605 geniocb->num_bdes = num_entry;
0606
0607 geniocb->bpl_dmabuf = bmp;
0608
0609
0610 geniocb->cmd_dmabuf = inp;
0611 geniocb->rsp_dmabuf = outp;
0612
0613 geniocb->event_tag = event_tag;
0614
0615 if (!tmo) {
0616
0617 tmo = (3 * phba->fc_ratov);
0618 }
0619
0620 if (phba->sli_rev == LPFC_SLI_REV4)
0621 ulp_context = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
0622 else
0623 ulp_context = ndlp->nlp_rpi;
0624
0625 lpfc_sli_prep_gen_req(phba, geniocb, bmp, ulp_context, num_entry, tmo);
0626
0627
0628 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
0629 "0119 Issue GEN REQ IOCB to NPORT x%x "
0630 "Data: x%x x%x\n",
0631 ndlp->nlp_DID, geniocb->iotag,
0632 vport->port_state);
0633 geniocb->cmd_cmpl = cmpl;
0634 geniocb->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;
0635 geniocb->vport = vport;
0636 geniocb->retry = retry;
0637 geniocb->ndlp = lpfc_nlp_get(ndlp);
0638 if (!geniocb->ndlp)
0639 goto out;
0640
0641 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);
0642 if (rc == IOCB_ERROR) {
0643 lpfc_nlp_put(ndlp);
0644 goto out;
0645 }
0646
0647 return 0;
0648 out:
0649 lpfc_sli_release_iocbq(phba, geniocb);
0650 return 1;
0651 }
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663 static int
0664 lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp,
0665 struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp,
0666 void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
0667 struct lpfc_iocbq *),
0668 uint32_t rsp_size, uint8_t retry)
0669 {
0670 struct lpfc_hba *phba = vport->phba;
0671 struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt;
0672 struct lpfc_dmabuf *outmp;
0673 int cnt = 0, status;
0674 int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)->
0675 CommandResponse.bits.CmdRsp;
0676
0677 bpl++;
0678
0679
0680 outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt);
0681 if (!outmp)
0682 return -ENOMEM;
0683
0684
0685
0686
0687
0688 cnt += 1;
0689 status = lpfc_gen_req(vport, bmp, inmp, outmp, cmpl, ndlp,
0690 phba->fc_eventTag, cnt, 0, retry);
0691 if (status) {
0692 lpfc_free_ct_rsp(phba, outmp);
0693 return -ENOMEM;
0694 }
0695 return 0;
0696 }
0697
0698 struct lpfc_vport *
0699 lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) {
0700 struct lpfc_vport *vport_curr;
0701 unsigned long flags;
0702
0703 spin_lock_irqsave(&phba->port_list_lock, flags);
0704 list_for_each_entry(vport_curr, &phba->port_list, listentry) {
0705 if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) {
0706 spin_unlock_irqrestore(&phba->port_list_lock, flags);
0707 return vport_curr;
0708 }
0709 }
0710 spin_unlock_irqrestore(&phba->port_list_lock, flags);
0711 return NULL;
0712 }
0713
0714 static void
0715 lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
0716 {
0717 struct lpfc_nodelist *ndlp;
0718
0719 if ((vport->port_type != LPFC_NPIV_PORT) ||
0720 !(vport->ct_flags & FC_CT_RFF_ID) || !vport->cfg_restrict_login) {
0721
0722 ndlp = lpfc_setup_disc_node(vport, Did);
0723
0724 if (ndlp) {
0725 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
0726 "Parse GID_FTrsp: did:x%x flg:x%x x%x",
0727 Did, ndlp->nlp_flag, vport->fc_flag);
0728
0729
0730 if (fc4_type == FC_TYPE_FCP)
0731 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
0732
0733 if (fc4_type == FC_TYPE_NVME)
0734 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
0735
0736 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0737 "0238 Process x%06x NameServer Rsp "
0738 "Data: x%x x%x x%x x%x x%x\n", Did,
0739 ndlp->nlp_flag, ndlp->nlp_fc4_type,
0740 ndlp->nlp_state, vport->fc_flag,
0741 vport->fc_rscn_id_cnt);
0742
0743
0744
0745
0746
0747 if (ndlp->nlp_flag & NLP_NPR_2B_DISC &&
0748 ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
0749 lpfc_nlp_set_state(vport, ndlp,
0750 NLP_STE_NPR_NODE);
0751 }
0752 } else {
0753 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
0754 "Skip1 GID_FTrsp: did:x%x flg:x%x cnt:%d",
0755 Did, vport->fc_flag, vport->fc_rscn_id_cnt);
0756
0757 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0758 "0239 Skip x%06x NameServer Rsp "
0759 "Data: x%x x%x x%px\n",
0760 Did, vport->fc_flag,
0761 vport->fc_rscn_id_cnt, ndlp);
0762 }
0763 } else {
0764 if (!(vport->fc_flag & FC_RSCN_MODE) ||
0765 lpfc_rscn_payload_check(vport, Did)) {
0766 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
0767 "Query GID_FTrsp: did:x%x flg:x%x cnt:%d",
0768 Did, vport->fc_flag, vport->fc_rscn_id_cnt);
0769
0770
0771
0772
0773
0774 ndlp = lpfc_findnode_did(vport, Did);
0775 if (ndlp &&
0776 (ndlp->nlp_type &
0777 (NLP_FCP_TARGET | NLP_NVME_TARGET))) {
0778 if (fc4_type == FC_TYPE_FCP)
0779 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
0780 if (fc4_type == FC_TYPE_NVME)
0781 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
0782 lpfc_setup_disc_node(vport, Did);
0783 } else if (lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID,
0784 0, Did) == 0)
0785 vport->num_disc_nodes++;
0786 else
0787 lpfc_setup_disc_node(vport, Did);
0788 } else {
0789 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
0790 "Skip2 GID_FTrsp: did:x%x flg:x%x cnt:%d",
0791 Did, vport->fc_flag, vport->fc_rscn_id_cnt);
0792
0793 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0794 "0245 Skip x%06x NameServer Rsp "
0795 "Data: x%x x%x\n", Did,
0796 vport->fc_flag,
0797 vport->fc_rscn_id_cnt);
0798 }
0799 }
0800 }
0801
0802 static void
0803 lpfc_ns_rsp_audit_did(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type)
0804 {
0805 struct lpfc_hba *phba = vport->phba;
0806 struct lpfc_nodelist *ndlp = NULL;
0807 char *str;
0808
0809 if (phba->cfg_ns_query == LPFC_NS_QUERY_GID_FT)
0810 str = "GID_FT";
0811 else
0812 str = "GID_PT";
0813 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0814 "6430 Process %s rsp for %08x type %x %s %s\n",
0815 str, Did, fc4_type,
0816 (fc4_type == FC_TYPE_FCP) ? "FCP" : " ",
0817 (fc4_type == FC_TYPE_NVME) ? "NVME" : " ");
0818
0819
0820
0821
0822 if (Did != vport->fc_myDID &&
0823 (!lpfc_find_vport_by_did(phba, Did) ||
0824 vport->cfg_peer_port_login)) {
0825 if (!phba->nvmet_support) {
0826
0827 lpfc_prep_node_fc4type(vport, Did, fc4_type);
0828 return;
0829 }
0830
0831 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
0832 if (ndlp->nlp_type != NLP_NVME_INITIATOR ||
0833 ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
0834 continue;
0835 spin_lock_irq(&ndlp->lock);
0836 if (ndlp->nlp_DID == Did)
0837 ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
0838 else
0839 ndlp->nlp_flag |= NLP_NVMET_RECOV;
0840 spin_unlock_irq(&ndlp->lock);
0841 }
0842 }
0843 }
0844
0845 static int
0846 lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint8_t fc4_type,
0847 uint32_t Size)
0848 {
0849 struct lpfc_sli_ct_request *Response =
0850 (struct lpfc_sli_ct_request *) mp->virt;
0851 struct lpfc_dmabuf *mlast, *next_mp;
0852 uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType;
0853 uint32_t Did, CTentry;
0854 int Cnt;
0855 struct list_head head;
0856 struct lpfc_nodelist *ndlp = NULL;
0857
0858 lpfc_set_disctmo(vport);
0859 vport->num_disc_nodes = 0;
0860 vport->fc_ns_retry = 0;
0861
0862
0863 list_add_tail(&head, &mp->list);
0864 list_for_each_entry_safe(mp, next_mp, &head, list) {
0865 mlast = mp;
0866
0867 Cnt = Size > FCELSSIZE ? FCELSSIZE : Size;
0868
0869 Size -= Cnt;
0870
0871 if (!ctptr) {
0872 ctptr = (uint32_t *) mlast->virt;
0873 } else
0874 Cnt -= 16;
0875
0876
0877 while (Cnt >= sizeof(uint32_t)) {
0878
0879 CTentry = *ctptr++;
0880 Did = ((be32_to_cpu(CTentry)) & Mask_DID);
0881 lpfc_ns_rsp_audit_did(vport, Did, fc4_type);
0882 if (CTentry & (cpu_to_be32(SLI_CT_LAST_ENTRY)))
0883 goto nsout1;
0884
0885 Cnt -= sizeof(uint32_t);
0886 }
0887 ctptr = NULL;
0888
0889 }
0890
0891
0892
0893
0894
0895 if (vport->phba->nvmet_support) {
0896 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
0897 if (!(ndlp->nlp_flag & NLP_NVMET_RECOV))
0898 continue;
0899 lpfc_disc_state_machine(vport, ndlp, NULL,
0900 NLP_EVT_DEVICE_RECOVERY);
0901 spin_lock_irq(&ndlp->lock);
0902 ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
0903 spin_unlock_irq(&ndlp->lock);
0904 }
0905 }
0906
0907 nsout1:
0908 list_del(&head);
0909 return 0;
0910 }
0911
0912 static void
0913 lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
0914 struct lpfc_iocbq *rspiocb)
0915 {
0916 struct lpfc_vport *vport = cmdiocb->vport;
0917 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
0918 struct lpfc_dmabuf *outp;
0919 struct lpfc_dmabuf *inp;
0920 struct lpfc_sli_ct_request *CTrsp;
0921 struct lpfc_sli_ct_request *CTreq;
0922 struct lpfc_nodelist *ndlp;
0923 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
0924 u32 ulp_word4 = get_job_word4(phba, rspiocb);
0925 int rc, type;
0926
0927
0928 ndlp = cmdiocb->ndlp;
0929
0930
0931 cmdiocb->rsp_iocb = rspiocb;
0932 inp = cmdiocb->cmd_dmabuf;
0933 outp = cmdiocb->rsp_dmabuf;
0934
0935 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
0936 "GID_FT cmpl: status:x%x/x%x rtry:%d",
0937 ulp_status, ulp_word4, vport->fc_ns_retry);
0938
0939
0940 if (cmdiocb->event_tag != phba->fc_eventTag) {
0941 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0942 "9043 Event tag mismatch. Ignoring NS rsp\n");
0943 goto out;
0944 }
0945
0946
0947 if (vport->load_flag & FC_UNLOADING) {
0948 if (vport->fc_flag & FC_RSCN_MODE)
0949 lpfc_els_flush_rscn(vport);
0950 goto out;
0951 }
0952
0953 if (lpfc_els_chk_latt(vport)) {
0954 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0955 "0216 Link event during NS query\n");
0956 if (vport->fc_flag & FC_RSCN_MODE)
0957 lpfc_els_flush_rscn(vport);
0958 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
0959 goto out;
0960 }
0961 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
0962 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
0963 "0226 NS query failed due to link event: "
0964 "ulp_status x%x ulp_word4 x%x fc_flag x%x "
0965 "port_state x%x gidft_inp x%x\n",
0966 ulp_status, ulp_word4, vport->fc_flag,
0967 vport->port_state, vport->gidft_inp);
0968 if (vport->fc_flag & FC_RSCN_MODE)
0969 lpfc_els_flush_rscn(vport);
0970 if (vport->gidft_inp)
0971 vport->gidft_inp--;
0972 goto out;
0973 }
0974
0975 spin_lock_irq(shost->host_lock);
0976 if (vport->fc_flag & FC_RSCN_DEFERRED) {
0977 vport->fc_flag &= ~FC_RSCN_DEFERRED;
0978 spin_unlock_irq(shost->host_lock);
0979
0980
0981
0982
0983 if (vport->gidft_inp)
0984 vport->gidft_inp--;
0985
0986
0987
0988
0989
0990 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
0991 "0151 Process Deferred RSCN Data: x%x x%x\n",
0992 vport->fc_flag, vport->fc_rscn_id_cnt);
0993 lpfc_els_handle_rscn(vport);
0994
0995 goto out;
0996 }
0997 spin_unlock_irq(shost->host_lock);
0998
0999 if (ulp_status) {
1000
1001 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
1002 if (ulp_status != IOSTAT_LOCAL_REJECT ||
1003 (ulp_word4 & IOERR_PARAM_MASK) !=
1004 IOERR_NO_RESOURCES)
1005 vport->fc_ns_retry++;
1006
1007 type = lpfc_get_gidft_type(vport, cmdiocb);
1008 if (type == 0)
1009 goto out;
1010
1011
1012 rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,
1013 vport->fc_ns_retry, type);
1014 if (rc == 0)
1015 goto out;
1016 else {
1017 if (vport->gidft_inp)
1018 vport->gidft_inp--;
1019 }
1020 }
1021 if (vport->fc_flag & FC_RSCN_MODE)
1022 lpfc_els_flush_rscn(vport);
1023 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1024 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1025 "0257 GID_FT Query error: 0x%x 0x%x\n",
1026 ulp_status, vport->fc_ns_retry);
1027 } else {
1028
1029 CTreq = (struct lpfc_sli_ct_request *) inp->virt;
1030 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1031 if (CTrsp->CommandResponse.bits.CmdRsp ==
1032 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
1033 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1034 "0208 NameServer Rsp Data: x%x x%x "
1035 "x%x x%x sz x%x\n",
1036 vport->fc_flag,
1037 CTreq->un.gid.Fc4Type,
1038 vport->num_disc_nodes,
1039 vport->gidft_inp,
1040 get_job_data_placed(phba, rspiocb));
1041
1042 lpfc_ns_rsp(vport,
1043 outp,
1044 CTreq->un.gid.Fc4Type,
1045 get_job_data_placed(phba, rspiocb));
1046 } else if (CTrsp->CommandResponse.bits.CmdRsp ==
1047 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
1048
1049 if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ)
1050 && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) {
1051 lpfc_printf_vlog(vport, KERN_INFO,
1052 LOG_DISCOVERY,
1053 "0269 No NameServer Entries "
1054 "Data: x%x x%x x%x x%x\n",
1055 CTrsp->CommandResponse.bits.CmdRsp,
1056 (uint32_t) CTrsp->ReasonCode,
1057 (uint32_t) CTrsp->Explanation,
1058 vport->fc_flag);
1059
1060 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1061 "GID_FT no entry cmd:x%x rsn:x%x exp:x%x",
1062 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1063 (uint32_t) CTrsp->ReasonCode,
1064 (uint32_t) CTrsp->Explanation);
1065 } else {
1066 lpfc_printf_vlog(vport, KERN_INFO,
1067 LOG_DISCOVERY,
1068 "0240 NameServer Rsp Error "
1069 "Data: x%x x%x x%x x%x\n",
1070 CTrsp->CommandResponse.bits.CmdRsp,
1071 (uint32_t) CTrsp->ReasonCode,
1072 (uint32_t) CTrsp->Explanation,
1073 vport->fc_flag);
1074
1075 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1076 "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x",
1077 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1078 (uint32_t) CTrsp->ReasonCode,
1079 (uint32_t) CTrsp->Explanation);
1080 }
1081
1082
1083 } else {
1084
1085 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1086 "0241 NameServer Rsp Error "
1087 "Data: x%x x%x x%x x%x\n",
1088 CTrsp->CommandResponse.bits.CmdRsp,
1089 (uint32_t) CTrsp->ReasonCode,
1090 (uint32_t) CTrsp->Explanation,
1091 vport->fc_flag);
1092
1093 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1094 "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x",
1095 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1096 (uint32_t) CTrsp->ReasonCode,
1097 (uint32_t) CTrsp->Explanation);
1098 }
1099 if (vport->gidft_inp)
1100 vport->gidft_inp--;
1101 }
1102
1103 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1104 "4216 GID_FT cmpl inp %d disc %d\n",
1105 vport->gidft_inp, vport->num_disc_nodes);
1106
1107
1108 if ((vport->num_disc_nodes == 0) &&
1109 (vport->gidft_inp == 0)) {
1110
1111
1112
1113
1114
1115 if (vport->port_state >= LPFC_DISC_AUTH) {
1116 if (vport->fc_flag & FC_RSCN_MODE) {
1117 lpfc_els_flush_rscn(vport);
1118 spin_lock_irq(shost->host_lock);
1119 vport->fc_flag |= FC_RSCN_MODE;
1120 spin_unlock_irq(shost->host_lock);
1121 }
1122 else
1123 lpfc_els_flush_rscn(vport);
1124 }
1125
1126 lpfc_disc_start(vport);
1127 }
1128 out:
1129 lpfc_ct_free_iocb(phba, cmdiocb);
1130 lpfc_nlp_put(ndlp);
1131 return;
1132 }
1133
1134 static void
1135 lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1136 struct lpfc_iocbq *rspiocb)
1137 {
1138 struct lpfc_vport *vport = cmdiocb->vport;
1139 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1140 struct lpfc_dmabuf *outp;
1141 struct lpfc_dmabuf *inp;
1142 struct lpfc_sli_ct_request *CTrsp;
1143 struct lpfc_sli_ct_request *CTreq;
1144 struct lpfc_nodelist *ndlp;
1145 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1146 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1147 int rc;
1148
1149
1150 ndlp = cmdiocb->ndlp;
1151
1152
1153 cmdiocb->rsp_iocb = rspiocb;
1154 inp = cmdiocb->cmd_dmabuf;
1155 outp = cmdiocb->rsp_dmabuf;
1156
1157 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1158 "GID_PT cmpl: status:x%x/x%x rtry:%d",
1159 ulp_status, ulp_word4,
1160 vport->fc_ns_retry);
1161
1162
1163 if (cmdiocb->event_tag != phba->fc_eventTag) {
1164 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1165 "9044 Event tag mismatch. Ignoring NS rsp\n");
1166 goto out;
1167 }
1168
1169
1170 if (vport->load_flag & FC_UNLOADING) {
1171 if (vport->fc_flag & FC_RSCN_MODE)
1172 lpfc_els_flush_rscn(vport);
1173 goto out;
1174 }
1175
1176 if (lpfc_els_chk_latt(vport)) {
1177 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1178 "4108 Link event during NS query\n");
1179 if (vport->fc_flag & FC_RSCN_MODE)
1180 lpfc_els_flush_rscn(vport);
1181 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1182 goto out;
1183 }
1184 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
1185 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1186 "4166 NS query failed due to link event: "
1187 "ulp_status x%x ulp_word4 x%x fc_flag x%x "
1188 "port_state x%x gidft_inp x%x\n",
1189 ulp_status, ulp_word4, vport->fc_flag,
1190 vport->port_state, vport->gidft_inp);
1191 if (vport->fc_flag & FC_RSCN_MODE)
1192 lpfc_els_flush_rscn(vport);
1193 if (vport->gidft_inp)
1194 vport->gidft_inp--;
1195 goto out;
1196 }
1197
1198 spin_lock_irq(shost->host_lock);
1199 if (vport->fc_flag & FC_RSCN_DEFERRED) {
1200 vport->fc_flag &= ~FC_RSCN_DEFERRED;
1201 spin_unlock_irq(shost->host_lock);
1202
1203
1204
1205
1206 if (vport->gidft_inp)
1207 vport->gidft_inp--;
1208
1209
1210
1211
1212
1213 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1214 "4167 Process Deferred RSCN Data: x%x x%x\n",
1215 vport->fc_flag, vport->fc_rscn_id_cnt);
1216 lpfc_els_handle_rscn(vport);
1217
1218 goto out;
1219 }
1220 spin_unlock_irq(shost->host_lock);
1221
1222 if (ulp_status) {
1223
1224 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
1225 if (ulp_status != IOSTAT_LOCAL_REJECT ||
1226 (ulp_word4 & IOERR_PARAM_MASK) !=
1227 IOERR_NO_RESOURCES)
1228 vport->fc_ns_retry++;
1229
1230
1231 rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_PT,
1232 vport->fc_ns_retry, GID_PT_N_PORT);
1233 if (rc == 0)
1234 goto out;
1235 else {
1236 if (vport->gidft_inp)
1237 vport->gidft_inp--;
1238 }
1239 }
1240 if (vport->fc_flag & FC_RSCN_MODE)
1241 lpfc_els_flush_rscn(vport);
1242 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1243 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1244 "4103 GID_FT Query error: 0x%x 0x%x\n",
1245 ulp_status, vport->fc_ns_retry);
1246 } else {
1247
1248 CTreq = (struct lpfc_sli_ct_request *)inp->virt;
1249 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1250 if (CTrsp->CommandResponse.bits.CmdRsp ==
1251 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
1252 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1253 "4105 NameServer Rsp Data: x%x x%x "
1254 "x%x x%x sz x%x\n",
1255 vport->fc_flag,
1256 CTreq->un.gid.Fc4Type,
1257 vport->num_disc_nodes,
1258 vport->gidft_inp,
1259 get_job_data_placed(phba, rspiocb));
1260
1261 lpfc_ns_rsp(vport,
1262 outp,
1263 CTreq->un.gid.Fc4Type,
1264 get_job_data_placed(phba, rspiocb));
1265 } else if (CTrsp->CommandResponse.bits.CmdRsp ==
1266 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
1267
1268 if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ)
1269 && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) {
1270 lpfc_printf_vlog(
1271 vport, KERN_INFO, LOG_DISCOVERY,
1272 "4106 No NameServer Entries "
1273 "Data: x%x x%x x%x x%x\n",
1274 CTrsp->CommandResponse.bits.CmdRsp,
1275 (uint32_t)CTrsp->ReasonCode,
1276 (uint32_t)CTrsp->Explanation,
1277 vport->fc_flag);
1278
1279 lpfc_debugfs_disc_trc(
1280 vport, LPFC_DISC_TRC_CT,
1281 "GID_PT no entry cmd:x%x rsn:x%x exp:x%x",
1282 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1283 (uint32_t)CTrsp->ReasonCode,
1284 (uint32_t)CTrsp->Explanation);
1285 } else {
1286 lpfc_printf_vlog(
1287 vport, KERN_INFO, LOG_DISCOVERY,
1288 "4107 NameServer Rsp Error "
1289 "Data: x%x x%x x%x x%x\n",
1290 CTrsp->CommandResponse.bits.CmdRsp,
1291 (uint32_t)CTrsp->ReasonCode,
1292 (uint32_t)CTrsp->Explanation,
1293 vport->fc_flag);
1294
1295 lpfc_debugfs_disc_trc(
1296 vport, LPFC_DISC_TRC_CT,
1297 "GID_PT rsp err1 cmd:x%x rsn:x%x exp:x%x",
1298 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1299 (uint32_t)CTrsp->ReasonCode,
1300 (uint32_t)CTrsp->Explanation);
1301 }
1302 } else {
1303
1304 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1305 "4109 NameServer Rsp Error "
1306 "Data: x%x x%x x%x x%x\n",
1307 CTrsp->CommandResponse.bits.CmdRsp,
1308 (uint32_t)CTrsp->ReasonCode,
1309 (uint32_t)CTrsp->Explanation,
1310 vport->fc_flag);
1311
1312 lpfc_debugfs_disc_trc(
1313 vport, LPFC_DISC_TRC_CT,
1314 "GID_PT rsp err2 cmd:x%x rsn:x%x exp:x%x",
1315 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1316 (uint32_t)CTrsp->ReasonCode,
1317 (uint32_t)CTrsp->Explanation);
1318 }
1319 if (vport->gidft_inp)
1320 vport->gidft_inp--;
1321 }
1322
1323 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1324 "6450 GID_PT cmpl inp %d disc %d\n",
1325 vport->gidft_inp, vport->num_disc_nodes);
1326
1327
1328 if ((vport->num_disc_nodes == 0) &&
1329 (vport->gidft_inp == 0)) {
1330
1331
1332
1333
1334
1335 if (vport->port_state >= LPFC_DISC_AUTH) {
1336 if (vport->fc_flag & FC_RSCN_MODE) {
1337 lpfc_els_flush_rscn(vport);
1338 spin_lock_irq(shost->host_lock);
1339 vport->fc_flag |= FC_RSCN_MODE;
1340 spin_unlock_irq(shost->host_lock);
1341 } else {
1342 lpfc_els_flush_rscn(vport);
1343 }
1344 }
1345
1346 lpfc_disc_start(vport);
1347 }
1348 out:
1349 lpfc_ct_free_iocb(phba, cmdiocb);
1350 lpfc_nlp_put(ndlp);
1351 }
1352
1353 static void
1354 lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1355 struct lpfc_iocbq *rspiocb)
1356 {
1357 struct lpfc_vport *vport = cmdiocb->vport;
1358 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1359 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
1360 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
1361 struct lpfc_sli_ct_request *CTrsp;
1362 int did, rc, retry;
1363 uint8_t fbits;
1364 struct lpfc_nodelist *ndlp = NULL, *free_ndlp = NULL;
1365 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1366 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1367
1368 did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId;
1369 did = be32_to_cpu(did);
1370
1371 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1372 "GFF_ID cmpl: status:x%x/x%x did:x%x",
1373 ulp_status, ulp_word4, did);
1374
1375
1376 if (cmdiocb->event_tag != phba->fc_eventTag) {
1377 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1378 "9045 Event tag mismatch. Ignoring NS rsp\n");
1379 goto iocb_free;
1380 }
1381
1382 if (ulp_status == IOSTAT_SUCCESS) {
1383
1384 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1385 fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET];
1386
1387 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1388 "6431 Process GFF_ID rsp for %08x "
1389 "fbits %02x %s %s\n",
1390 did, fbits,
1391 (fbits & FC4_FEATURE_INIT) ? "Initiator" : " ",
1392 (fbits & FC4_FEATURE_TARGET) ? "Target" : " ");
1393
1394 if (CTrsp->CommandResponse.bits.CmdRsp ==
1395 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) {
1396 if ((fbits & FC4_FEATURE_INIT) &&
1397 !(fbits & FC4_FEATURE_TARGET)) {
1398 lpfc_printf_vlog(vport, KERN_INFO,
1399 LOG_DISCOVERY,
1400 "0270 Skip x%x GFF "
1401 "NameServer Rsp Data: (init) "
1402 "x%x x%x\n", did, fbits,
1403 vport->fc_rscn_id_cnt);
1404 goto out;
1405 }
1406 }
1407 }
1408 else {
1409
1410 if (cmdiocb->retry < LPFC_MAX_NS_RETRY) {
1411 retry = 1;
1412 if (ulp_status == IOSTAT_LOCAL_REJECT) {
1413 switch ((ulp_word4 &
1414 IOERR_PARAM_MASK)) {
1415
1416 case IOERR_NO_RESOURCES:
1417
1418
1419
1420 break;
1421 case IOERR_LINK_DOWN:
1422 case IOERR_SLI_ABORTED:
1423 case IOERR_SLI_DOWN:
1424 retry = 0;
1425 break;
1426 default:
1427 cmdiocb->retry++;
1428 }
1429 }
1430 else
1431 cmdiocb->retry++;
1432
1433 if (retry) {
1434
1435 rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID,
1436 cmdiocb->retry, did);
1437 if (rc == 0) {
1438
1439 free_ndlp = cmdiocb->ndlp;
1440 lpfc_ct_free_iocb(phba, cmdiocb);
1441 lpfc_nlp_put(free_ndlp);
1442 return;
1443 }
1444 }
1445 }
1446 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1447 "0267 NameServer GFF Rsp "
1448 "x%x Error (%d %d) Data: x%x x%x\n",
1449 did, ulp_status, ulp_word4,
1450 vport->fc_flag, vport->fc_rscn_id_cnt);
1451 }
1452
1453
1454 ndlp = lpfc_setup_disc_node(vport, did);
1455 if (ndlp) {
1456 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1457 "0242 Process x%x GFF "
1458 "NameServer Rsp Data: x%x x%x x%x\n",
1459 did, ndlp->nlp_flag, vport->fc_flag,
1460 vport->fc_rscn_id_cnt);
1461 } else {
1462 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1463 "0243 Skip x%x GFF "
1464 "NameServer Rsp Data: x%x x%x\n", did,
1465 vport->fc_flag, vport->fc_rscn_id_cnt);
1466 }
1467 out:
1468
1469 if (vport->num_disc_nodes)
1470 vport->num_disc_nodes--;
1471
1472 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1473 "6451 GFF_ID cmpl inp %d disc %d\n",
1474 vport->gidft_inp, vport->num_disc_nodes);
1475
1476 if (vport->num_disc_nodes == 0) {
1477
1478
1479
1480
1481
1482 if (vport->port_state >= LPFC_DISC_AUTH) {
1483 if (vport->fc_flag & FC_RSCN_MODE) {
1484 lpfc_els_flush_rscn(vport);
1485 spin_lock_irq(shost->host_lock);
1486 vport->fc_flag |= FC_RSCN_MODE;
1487 spin_unlock_irq(shost->host_lock);
1488 }
1489 else
1490 lpfc_els_flush_rscn(vport);
1491 }
1492 lpfc_disc_start(vport);
1493 }
1494
1495 iocb_free:
1496 free_ndlp = cmdiocb->ndlp;
1497 lpfc_ct_free_iocb(phba, cmdiocb);
1498 lpfc_nlp_put(free_ndlp);
1499 return;
1500 }
1501
1502 static void
1503 lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1504 struct lpfc_iocbq *rspiocb)
1505 {
1506 struct lpfc_vport *vport = cmdiocb->vport;
1507 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
1508 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
1509 struct lpfc_sli_ct_request *CTrsp;
1510 int did;
1511 struct lpfc_nodelist *ndlp = NULL;
1512 struct lpfc_nodelist *ns_ndlp = NULL;
1513 uint32_t fc4_data_0, fc4_data_1;
1514 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1515 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1516
1517 did = ((struct lpfc_sli_ct_request *)inp->virt)->un.gft.PortId;
1518 did = be32_to_cpu(did);
1519
1520 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1521 "GFT_ID cmpl: status:x%x/x%x did:x%x",
1522 ulp_status, ulp_word4, did);
1523
1524
1525 if ((uint32_t) cmdiocb->event_tag != phba->fc_eventTag) {
1526 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1527 "9046 Event tag mismatch. Ignoring NS rsp\n");
1528 goto out;
1529 }
1530
1531
1532 ns_ndlp = cmdiocb->ndlp;
1533
1534 if (ulp_status == IOSTAT_SUCCESS) {
1535
1536 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1537 fc4_data_0 = be32_to_cpu(CTrsp->un.gft_acc.fc4_types[0]);
1538 fc4_data_1 = be32_to_cpu(CTrsp->un.gft_acc.fc4_types[1]);
1539
1540 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1541 "6432 Process GFT_ID rsp for %08x "
1542 "Data %08x %08x %s %s\n",
1543 did, fc4_data_0, fc4_data_1,
1544 (fc4_data_0 & LPFC_FC4_TYPE_BITMASK) ?
1545 "FCP" : " ",
1546 (fc4_data_1 & LPFC_FC4_TYPE_BITMASK) ?
1547 "NVME" : " ");
1548
1549
1550
1551
1552
1553 ndlp = lpfc_findnode_did(vport, did);
1554 if (ndlp) {
1555
1556
1557
1558
1559 if (fc4_data_0 & LPFC_FC4_TYPE_BITMASK)
1560 ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1561 if (fc4_data_1 & LPFC_FC4_TYPE_BITMASK)
1562 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
1563 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1564 "3064 Setting ndlp x%px, DID x%06x "
1565 "with FC4 x%08x, Data: x%08x x%08x "
1566 "%d\n",
1567 ndlp, did, ndlp->nlp_fc4_type,
1568 FC_TYPE_FCP, FC_TYPE_NVME,
1569 ndlp->nlp_state);
1570
1571 if (ndlp->nlp_state == NLP_STE_REG_LOGIN_ISSUE &&
1572 ndlp->nlp_fc4_type) {
1573 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1574
1575 lpfc_nlp_set_state(vport, ndlp,
1576 NLP_STE_PRLI_ISSUE);
1577 lpfc_issue_els_prli(vport, ndlp, 0);
1578 } else if (!ndlp->nlp_fc4_type) {
1579
1580 lpfc_printf_vlog(vport, KERN_INFO,
1581 LOG_DISCOVERY,
1582 "6443 Sending LOGO ndlp x%px,"
1583 "DID x%06x with fc4_type: "
1584 "x%08x, state: %d\n",
1585 ndlp, did, ndlp->nlp_fc4_type,
1586 ndlp->nlp_state);
1587 lpfc_issue_els_logo(vport, ndlp, 0);
1588 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1589 lpfc_nlp_set_state(vport, ndlp,
1590 NLP_STE_NPR_NODE);
1591 }
1592 }
1593 } else
1594 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1595 "3065 GFT_ID failed x%08x\n", ulp_status);
1596
1597 out:
1598 lpfc_ct_free_iocb(phba, cmdiocb);
1599 lpfc_nlp_put(ns_ndlp);
1600 }
1601
1602 static void
1603 lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1604 struct lpfc_iocbq *rspiocb)
1605 {
1606 struct lpfc_vport *vport = cmdiocb->vport;
1607 struct lpfc_dmabuf *inp;
1608 struct lpfc_dmabuf *outp;
1609 struct lpfc_sli_ct_request *CTrsp;
1610 struct lpfc_nodelist *ndlp;
1611 int cmdcode, rc;
1612 uint8_t retry;
1613 uint32_t latt;
1614 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1615 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1616
1617
1618 ndlp = cmdiocb->ndlp;
1619
1620
1621 cmdiocb->rsp_iocb = rspiocb;
1622
1623 inp = cmdiocb->cmd_dmabuf;
1624 outp = cmdiocb->rsp_dmabuf;
1625
1626 cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)->
1627 CommandResponse.bits.CmdRsp);
1628 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1629
1630 latt = lpfc_els_chk_latt(vport);
1631
1632
1633 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1634 "0209 CT Request completes, latt %d, "
1635 "ulp_status x%x CmdRsp x%x, Context x%x, Tag x%x\n",
1636 latt, ulp_status,
1637 CTrsp->CommandResponse.bits.CmdRsp,
1638 get_job_ulpcontext(phba, cmdiocb), cmdiocb->iotag);
1639
1640 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1641 "CT cmd cmpl: status:x%x/x%x cmd:x%x",
1642 ulp_status, ulp_word4, cmdcode);
1643
1644 if (ulp_status) {
1645 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1646 "0268 NS cmd x%x Error (x%x x%x)\n",
1647 cmdcode, ulp_status, ulp_word4);
1648
1649 if (ulp_status == IOSTAT_LOCAL_REJECT &&
1650 (((ulp_word4 & IOERR_PARAM_MASK) ==
1651 IOERR_SLI_DOWN) ||
1652 ((ulp_word4 & IOERR_PARAM_MASK) ==
1653 IOERR_SLI_ABORTED)))
1654 goto out;
1655
1656 retry = cmdiocb->retry;
1657 if (retry >= LPFC_MAX_NS_RETRY)
1658 goto out;
1659
1660 retry++;
1661 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1662 "0250 Retrying NS cmd %x\n", cmdcode);
1663 rc = lpfc_ns_cmd(vport, cmdcode, retry, 0);
1664 if (rc == 0)
1665 goto out;
1666 }
1667
1668 out:
1669 lpfc_ct_free_iocb(phba, cmdiocb);
1670 lpfc_nlp_put(ndlp);
1671 return;
1672 }
1673
1674 static void
1675 lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1676 struct lpfc_iocbq *rspiocb)
1677 {
1678 struct lpfc_vport *vport = cmdiocb->vport;
1679 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1680
1681 if (ulp_status == IOSTAT_SUCCESS) {
1682 struct lpfc_dmabuf *outp;
1683 struct lpfc_sli_ct_request *CTrsp;
1684
1685 outp = cmdiocb->rsp_dmabuf;
1686 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1687 if (CTrsp->CommandResponse.bits.CmdRsp ==
1688 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1689 vport->ct_flags |= FC_CT_RFT_ID;
1690 }
1691 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
1692 return;
1693 }
1694
1695 static void
1696 lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1697 struct lpfc_iocbq *rspiocb)
1698 {
1699 struct lpfc_vport *vport = cmdiocb->vport;
1700 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1701
1702 if (ulp_status == IOSTAT_SUCCESS) {
1703 struct lpfc_dmabuf *outp;
1704 struct lpfc_sli_ct_request *CTrsp;
1705
1706 outp = cmdiocb->rsp_dmabuf;
1707 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1708 if (CTrsp->CommandResponse.bits.CmdRsp ==
1709 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1710 vport->ct_flags |= FC_CT_RNN_ID;
1711 }
1712 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
1713 return;
1714 }
1715
1716 static void
1717 lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1718 struct lpfc_iocbq *rspiocb)
1719 {
1720 struct lpfc_vport *vport = cmdiocb->vport;
1721 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1722
1723 if (ulp_status == IOSTAT_SUCCESS) {
1724 struct lpfc_dmabuf *outp;
1725 struct lpfc_sli_ct_request *CTrsp;
1726
1727 outp = cmdiocb->rsp_dmabuf;
1728 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1729 if (CTrsp->CommandResponse.bits.CmdRsp ==
1730 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1731 vport->ct_flags |= FC_CT_RSPN_ID;
1732 }
1733 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
1734 return;
1735 }
1736
1737 static void
1738 lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1739 struct lpfc_iocbq *rspiocb)
1740 {
1741 struct lpfc_vport *vport = cmdiocb->vport;
1742 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1743
1744 if (ulp_status == IOSTAT_SUCCESS) {
1745 struct lpfc_dmabuf *outp;
1746 struct lpfc_sli_ct_request *CTrsp;
1747
1748 outp = cmdiocb->rsp_dmabuf;
1749 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1750 if (CTrsp->CommandResponse.bits.CmdRsp ==
1751 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1752 vport->ct_flags |= FC_CT_RSNN_NN;
1753 }
1754 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
1755 return;
1756 }
1757
1758 static void
1759 lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1760 struct lpfc_iocbq *rspiocb)
1761 {
1762 struct lpfc_vport *vport = cmdiocb->vport;
1763
1764
1765 vport->ct_flags = 0;
1766 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
1767 return;
1768 }
1769
1770 static void
1771 lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1772 struct lpfc_iocbq *rspiocb)
1773 {
1774 struct lpfc_vport *vport = cmdiocb->vport;
1775 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1776
1777 if (ulp_status == IOSTAT_SUCCESS) {
1778 struct lpfc_dmabuf *outp;
1779 struct lpfc_sli_ct_request *CTrsp;
1780
1781 outp = cmdiocb->rsp_dmabuf;
1782 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1783 if (CTrsp->CommandResponse.bits.CmdRsp ==
1784 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1785 vport->ct_flags |= FC_CT_RFF_ID;
1786 }
1787 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
1788 return;
1789 }
1790
1791
1792
1793
1794
1795
1796 int
1797 lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol,
1798 size_t size)
1799 {
1800 int n;
1801
1802
1803
1804
1805
1806
1807 n = scnprintf(symbol, size, "%d", vport->phba->brd_no);
1808 return n;
1809 }
1810
1811
1812 int
1813 lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol,
1814 size_t size)
1815 {
1816 char fwrev[FW_REV_STR_SIZE] = {0};
1817 char tmp[MAXHOSTNAMELEN] = {0};
1818
1819 memset(symbol, 0, size);
1820
1821 scnprintf(tmp, sizeof(tmp), "Emulex %s", vport->phba->ModelName);
1822 if (strlcat(symbol, tmp, size) >= size)
1823 goto buffer_done;
1824
1825 lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
1826 scnprintf(tmp, sizeof(tmp), " FV%s", fwrev);
1827 if (strlcat(symbol, tmp, size) >= size)
1828 goto buffer_done;
1829
1830 scnprintf(tmp, sizeof(tmp), " DV%s", lpfc_release_version);
1831 if (strlcat(symbol, tmp, size) >= size)
1832 goto buffer_done;
1833
1834 scnprintf(tmp, sizeof(tmp), " HN:%s", vport->phba->os_host_name);
1835 if (strlcat(symbol, tmp, size) >= size)
1836 goto buffer_done;
1837
1838
1839 scnprintf(tmp, sizeof(tmp), " OS:%s", init_utsname()->sysname);
1840 strlcat(symbol, tmp, size);
1841
1842 buffer_done:
1843 return strnlen(symbol, size);
1844
1845 }
1846
1847 static uint32_t
1848 lpfc_find_map_node(struct lpfc_vport *vport)
1849 {
1850 struct lpfc_nodelist *ndlp, *next_ndlp;
1851 struct Scsi_Host *shost;
1852 uint32_t cnt = 0;
1853
1854 shost = lpfc_shost_from_vport(vport);
1855 spin_lock_irq(shost->host_lock);
1856 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
1857 if (ndlp->nlp_type & NLP_FABRIC)
1858 continue;
1859 if ((ndlp->nlp_state == NLP_STE_MAPPED_NODE) ||
1860 (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE))
1861 cnt++;
1862 }
1863 spin_unlock_irq(shost->host_lock);
1864 return cnt;
1865 }
1866
1867
1868
1869
1870
1871 int
1872 lpfc_get_gidft_type(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb)
1873 {
1874 struct lpfc_sli_ct_request *CtReq;
1875 struct lpfc_dmabuf *mp;
1876 uint32_t type;
1877
1878 mp = cmdiocb->cmd_dmabuf;
1879 if (mp == NULL)
1880 return 0;
1881 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
1882 type = (uint32_t)CtReq->un.gid.Fc4Type;
1883 if ((type != SLI_CTPT_FCP) && (type != SLI_CTPT_NVME))
1884 return 0;
1885 return type;
1886 }
1887
1888
1889
1890
1891
1892
1893
1894
1895 int
1896 lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1897 uint8_t retry, uint32_t context)
1898 {
1899 struct lpfc_nodelist * ndlp;
1900 struct lpfc_hba *phba = vport->phba;
1901 struct lpfc_dmabuf *mp, *bmp;
1902 struct lpfc_sli_ct_request *CtReq;
1903 struct ulp_bde64 *bpl;
1904 void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
1905 struct lpfc_iocbq *) = NULL;
1906 uint32_t *ptr;
1907 uint32_t rsp_size = 1024;
1908 size_t size;
1909 int rc = 0;
1910
1911 ndlp = lpfc_findnode_did(vport, NameServer_DID);
1912 if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) {
1913 rc=1;
1914 goto ns_cmd_exit;
1915 }
1916
1917
1918
1919 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
1920 if (!mp) {
1921 rc=2;
1922 goto ns_cmd_exit;
1923 }
1924
1925 INIT_LIST_HEAD(&mp->list);
1926 mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys));
1927 if (!mp->virt) {
1928 rc=3;
1929 goto ns_cmd_free_mp;
1930 }
1931
1932
1933 bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
1934 if (!bmp) {
1935 rc=4;
1936 goto ns_cmd_free_mpvirt;
1937 }
1938
1939 INIT_LIST_HEAD(&bmp->list);
1940 bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys));
1941 if (!bmp->virt) {
1942 rc=5;
1943 goto ns_cmd_free_bmp;
1944 }
1945
1946
1947 lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY,
1948 "0236 NameServer Req Data: x%x x%x x%x x%x\n",
1949 cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt,
1950 context);
1951
1952 bpl = (struct ulp_bde64 *) bmp->virt;
1953 memset(bpl, 0, sizeof(struct ulp_bde64));
1954 bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) );
1955 bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) );
1956 bpl->tus.f.bdeFlags = 0;
1957 if (cmdcode == SLI_CTNS_GID_FT)
1958 bpl->tus.f.bdeSize = GID_REQUEST_SZ;
1959 else if (cmdcode == SLI_CTNS_GID_PT)
1960 bpl->tus.f.bdeSize = GID_REQUEST_SZ;
1961 else if (cmdcode == SLI_CTNS_GFF_ID)
1962 bpl->tus.f.bdeSize = GFF_REQUEST_SZ;
1963 else if (cmdcode == SLI_CTNS_GFT_ID)
1964 bpl->tus.f.bdeSize = GFT_REQUEST_SZ;
1965 else if (cmdcode == SLI_CTNS_RFT_ID)
1966 bpl->tus.f.bdeSize = RFT_REQUEST_SZ;
1967 else if (cmdcode == SLI_CTNS_RNN_ID)
1968 bpl->tus.f.bdeSize = RNN_REQUEST_SZ;
1969 else if (cmdcode == SLI_CTNS_RSPN_ID)
1970 bpl->tus.f.bdeSize = RSPN_REQUEST_SZ;
1971 else if (cmdcode == SLI_CTNS_RSNN_NN)
1972 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;
1973 else if (cmdcode == SLI_CTNS_DA_ID)
1974 bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ;
1975 else if (cmdcode == SLI_CTNS_RFF_ID)
1976 bpl->tus.f.bdeSize = RFF_REQUEST_SZ;
1977 else
1978 bpl->tus.f.bdeSize = 0;
1979 bpl->tus.w = le32_to_cpu(bpl->tus.w);
1980
1981 CtReq = (struct lpfc_sli_ct_request *) mp->virt;
1982 memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request));
1983 CtReq->RevisionId.bits.Revision = SLI_CT_REVISION;
1984 CtReq->RevisionId.bits.InId = 0;
1985 CtReq->FsType = SLI_CT_DIRECTORY_SERVICE;
1986 CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER;
1987 CtReq->CommandResponse.bits.Size = 0;
1988 switch (cmdcode) {
1989 case SLI_CTNS_GID_FT:
1990 CtReq->CommandResponse.bits.CmdRsp =
1991 cpu_to_be16(SLI_CTNS_GID_FT);
1992 CtReq->un.gid.Fc4Type = context;
1993
1994 if (vport->port_state < LPFC_NS_QRY)
1995 vport->port_state = LPFC_NS_QRY;
1996 lpfc_set_disctmo(vport);
1997 cmpl = lpfc_cmpl_ct_cmd_gid_ft;
1998 rsp_size = FC_MAX_NS_RSP;
1999 break;
2000
2001 case SLI_CTNS_GID_PT:
2002 CtReq->CommandResponse.bits.CmdRsp =
2003 cpu_to_be16(SLI_CTNS_GID_PT);
2004 CtReq->un.gid.PortType = context;
2005
2006 if (vport->port_state < LPFC_NS_QRY)
2007 vport->port_state = LPFC_NS_QRY;
2008 lpfc_set_disctmo(vport);
2009 cmpl = lpfc_cmpl_ct_cmd_gid_pt;
2010 rsp_size = FC_MAX_NS_RSP;
2011 break;
2012
2013 case SLI_CTNS_GFF_ID:
2014 CtReq->CommandResponse.bits.CmdRsp =
2015 cpu_to_be16(SLI_CTNS_GFF_ID);
2016 CtReq->un.gff.PortId = cpu_to_be32(context);
2017 cmpl = lpfc_cmpl_ct_cmd_gff_id;
2018 break;
2019
2020 case SLI_CTNS_GFT_ID:
2021 CtReq->CommandResponse.bits.CmdRsp =
2022 cpu_to_be16(SLI_CTNS_GFT_ID);
2023 CtReq->un.gft.PortId = cpu_to_be32(context);
2024 cmpl = lpfc_cmpl_ct_cmd_gft_id;
2025 break;
2026
2027 case SLI_CTNS_RFT_ID:
2028 vport->ct_flags &= ~FC_CT_RFT_ID;
2029 CtReq->CommandResponse.bits.CmdRsp =
2030 cpu_to_be16(SLI_CTNS_RFT_ID);
2031 CtReq->un.rft.port_id = cpu_to_be32(vport->fc_myDID);
2032
2033
2034 if (phba->cfg_vmid_app_header)
2035 CtReq->un.rft.app_serv_reg =
2036 cpu_to_be32(RFT_APP_SERV_REG);
2037
2038
2039 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
2040 vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
2041 CtReq->un.rft.fcp_reg = cpu_to_be32(RFT_FCP_REG);
2042
2043
2044 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
2045 vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
2046 CtReq->un.rft.nvme_reg = cpu_to_be32(RFT_NVME_REG);
2047
2048 ptr = (uint32_t *)CtReq;
2049 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2050 "6433 Issue RFT (%s %s %s): %08x %08x %08x "
2051 "%08x %08x %08x %08x %08x\n",
2052 CtReq->un.rft.fcp_reg ? "FCP" : " ",
2053 CtReq->un.rft.nvme_reg ? "NVME" : " ",
2054 CtReq->un.rft.app_serv_reg ? "APPS" : " ",
2055 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),
2056 *(ptr + 4), *(ptr + 5),
2057 *(ptr + 6), *(ptr + 7));
2058 cmpl = lpfc_cmpl_ct_cmd_rft_id;
2059 break;
2060
2061 case SLI_CTNS_RNN_ID:
2062 vport->ct_flags &= ~FC_CT_RNN_ID;
2063 CtReq->CommandResponse.bits.CmdRsp =
2064 cpu_to_be16(SLI_CTNS_RNN_ID);
2065 CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID);
2066 memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename,
2067 sizeof(struct lpfc_name));
2068 cmpl = lpfc_cmpl_ct_cmd_rnn_id;
2069 break;
2070
2071 case SLI_CTNS_RSPN_ID:
2072 vport->ct_flags &= ~FC_CT_RSPN_ID;
2073 CtReq->CommandResponse.bits.CmdRsp =
2074 cpu_to_be16(SLI_CTNS_RSPN_ID);
2075 CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID);
2076 size = sizeof(CtReq->un.rspn.symbname);
2077 CtReq->un.rspn.len =
2078 lpfc_vport_symbolic_port_name(vport,
2079 CtReq->un.rspn.symbname, size);
2080 cmpl = lpfc_cmpl_ct_cmd_rspn_id;
2081 break;
2082 case SLI_CTNS_RSNN_NN:
2083 vport->ct_flags &= ~FC_CT_RSNN_NN;
2084 CtReq->CommandResponse.bits.CmdRsp =
2085 cpu_to_be16(SLI_CTNS_RSNN_NN);
2086 memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename,
2087 sizeof(struct lpfc_name));
2088 size = sizeof(CtReq->un.rsnn.symbname);
2089 CtReq->un.rsnn.len =
2090 lpfc_vport_symbolic_node_name(vport,
2091 CtReq->un.rsnn.symbname, size);
2092 cmpl = lpfc_cmpl_ct_cmd_rsnn_nn;
2093 break;
2094 case SLI_CTNS_DA_ID:
2095
2096 CtReq->CommandResponse.bits.CmdRsp =
2097 cpu_to_be16(SLI_CTNS_DA_ID);
2098 CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID);
2099 cmpl = lpfc_cmpl_ct_cmd_da_id;
2100 break;
2101 case SLI_CTNS_RFF_ID:
2102 vport->ct_flags &= ~FC_CT_RFF_ID;
2103 CtReq->CommandResponse.bits.CmdRsp =
2104 cpu_to_be16(SLI_CTNS_RFF_ID);
2105 CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);
2106 CtReq->un.rff.fbits = FC4_FEATURE_INIT;
2107
2108
2109
2110
2111
2112 if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
2113 (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
2114 (context == FC_TYPE_NVME)) {
2115 if ((vport == phba->pport) && phba->nvmet_support) {
2116 CtReq->un.rff.fbits = (FC4_FEATURE_TARGET |
2117 FC4_FEATURE_NVME_DISC);
2118 lpfc_nvmet_update_targetport(phba);
2119 } else {
2120 lpfc_nvme_update_localport(vport);
2121 }
2122 CtReq->un.rff.type_code = context;
2123
2124 } else if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
2125 (vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
2126 (context == FC_TYPE_FCP))
2127 CtReq->un.rff.type_code = context;
2128
2129 else
2130 goto ns_cmd_free_bmpvirt;
2131
2132 ptr = (uint32_t *)CtReq;
2133 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2134 "6434 Issue RFF (%s): %08x %08x %08x %08x "
2135 "%08x %08x %08x %08x\n",
2136 (context == FC_TYPE_NVME) ? "NVME" : "FCP",
2137 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),
2138 *(ptr + 4), *(ptr + 5),
2139 *(ptr + 6), *(ptr + 7));
2140 cmpl = lpfc_cmpl_ct_cmd_rff_id;
2141 break;
2142 }
2143
2144
2145
2146 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) {
2147
2148 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
2149 "Issue CT cmd: cmd:x%x did:x%x",
2150 cmdcode, ndlp->nlp_DID, 0);
2151 return 0;
2152 }
2153 rc=6;
2154
2155 ns_cmd_free_bmpvirt:
2156 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
2157 ns_cmd_free_bmp:
2158 kfree(bmp);
2159 ns_cmd_free_mpvirt:
2160 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2161 ns_cmd_free_mp:
2162 kfree(mp);
2163 ns_cmd_exit:
2164 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2165 "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
2166 cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt);
2167 return 1;
2168 }
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179 static void
2180 lpfc_fdmi_rprt_defer(struct lpfc_hba *phba, uint32_t mask)
2181 {
2182 struct lpfc_vport **vports;
2183 struct lpfc_vport *vport;
2184 struct lpfc_nodelist *ndlp;
2185 int i;
2186
2187 phba->hba_flag |= HBA_RHBA_CMPL;
2188 vports = lpfc_create_vport_work_array(phba);
2189 if (vports) {
2190 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
2191 vport = vports[i];
2192 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2193 if (!ndlp)
2194 continue;
2195 if (vport->ct_flags & FC_CT_RPRT_DEFER) {
2196 vport->ct_flags &= ~FC_CT_RPRT_DEFER;
2197 vport->fdmi_port_mask = mask;
2198 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2199 }
2200 }
2201 }
2202 lpfc_destroy_vport_work_array(phba, vports);
2203 }
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214 static void
2215 lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2216 struct lpfc_iocbq *rspiocb)
2217 {
2218 struct lpfc_vport *vport = cmdiocb->vport;
2219 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
2220 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
2221 struct lpfc_sli_ct_request *CTcmd = inp->virt;
2222 struct lpfc_sli_ct_request *CTrsp = outp->virt;
2223 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
2224 uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp;
2225 struct lpfc_nodelist *ndlp, *free_ndlp = NULL;
2226 uint32_t latt, cmd, err;
2227 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
2228 u32 ulp_word4 = get_job_word4(phba, rspiocb);
2229
2230 latt = lpfc_els_chk_latt(vport);
2231 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
2232 "FDMI cmpl: status:x%x/x%x latt:%d",
2233 ulp_status, ulp_word4, latt);
2234
2235 if (latt || ulp_status) {
2236
2237
2238 if (ulp_status == IOSTAT_LOCAL_REJECT) {
2239 switch ((ulp_word4 & IOERR_PARAM_MASK)) {
2240 case IOERR_SLI_ABORTED:
2241 case IOERR_SLI_DOWN:
2242
2243
2244
2245
2246 break;
2247 case IOERR_ABORT_IN_PROGRESS:
2248 case IOERR_SEQUENCE_TIMEOUT:
2249 case IOERR_ILLEGAL_FRAME:
2250 case IOERR_NO_RESOURCES:
2251 case IOERR_ILLEGAL_COMMAND:
2252 cmdiocb->retry++;
2253 if (cmdiocb->retry >= LPFC_FDMI_MAX_RETRY)
2254 break;
2255
2256
2257 err = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING,
2258 cmdiocb, 0);
2259 if (err == IOCB_ERROR)
2260 break;
2261 return;
2262 default:
2263 break;
2264 }
2265 }
2266
2267 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2268 "0229 FDMI cmd %04x failed, latt = %d "
2269 "ulp_status: x%x, rid x%x\n",
2270 be16_to_cpu(fdmi_cmd), latt, ulp_status,
2271 ulp_word4);
2272 }
2273
2274 free_ndlp = cmdiocb->ndlp;
2275 lpfc_ct_free_iocb(phba, cmdiocb);
2276 lpfc_nlp_put(free_ndlp);
2277
2278 ndlp = lpfc_findnode_did(vport, FDMI_DID);
2279 if (!ndlp)
2280 return;
2281
2282
2283 cmd = be16_to_cpu(fdmi_cmd);
2284 if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) {
2285
2286 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY | LOG_ELS,
2287 "0220 FDMI cmd failed FS_RJT Data: x%x", cmd);
2288
2289
2290 switch (cmd) {
2291 case SLI_MGMT_RHBA:
2292 if (vport->fdmi_hba_mask == LPFC_FDMI2_HBA_ATTR) {
2293
2294 vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR;
2295
2296
2297
2298
2299 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
2300
2301 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
2302 }
2303 return;
2304
2305 case SLI_MGMT_RPRT:
2306 if (vport->port_type != LPFC_PHYSICAL_PORT) {
2307 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2308 if (!ndlp)
2309 return;
2310 }
2311 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {
2312
2313 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
2314
2315 lpfc_fdmi_cmd(vport, ndlp, cmd, 0);
2316 return;
2317 }
2318 if (vport->fdmi_port_mask == LPFC_FDMI2_SMART_ATTR) {
2319 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
2320
2321 lpfc_fdmi_cmd(vport, ndlp, cmd, 0);
2322 }
2323 return;
2324
2325 case SLI_MGMT_RPA:
2326
2327 if (phba->link_flag & LS_CT_VEN_RPA) {
2328 phba->link_flag &= ~LS_CT_VEN_RPA;
2329 if (phba->cmf_active_mode == LPFC_CFG_OFF)
2330 return;
2331 lpfc_printf_log(phba, KERN_WARNING,
2332 LOG_DISCOVERY | LOG_ELS,
2333 "6460 VEN FDMI RPA RJT\n");
2334 return;
2335 }
2336 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {
2337
2338 vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR;
2339 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
2340
2341 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
2342 return;
2343 }
2344 if (vport->fdmi_port_mask == LPFC_FDMI2_SMART_ATTR) {
2345 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
2346
2347 lpfc_fdmi_cmd(vport, ndlp, cmd, 0);
2348 }
2349 return;
2350 }
2351 }
2352
2353
2354
2355
2356
2357
2358 switch (cmd) {
2359 case SLI_MGMT_RHBA:
2360
2361 lpfc_fdmi_rprt_defer(phba, vport->fdmi_port_mask);
2362
2363 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, 0);
2364 break;
2365
2366 case SLI_MGMT_DHBA:
2367 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0);
2368 break;
2369
2370 case SLI_MGMT_DPRT:
2371 if (vport->port_type == LPFC_PHYSICAL_PORT) {
2372 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA, 0);
2373 } else {
2374 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2375 if (!ndlp)
2376 return;
2377
2378
2379
2380
2381
2382 if (phba->hba_flag & HBA_RHBA_CMPL) {
2383 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2384 } else {
2385 lpfc_printf_vlog(vport, KERN_INFO,
2386 LOG_DISCOVERY,
2387 "6078 RPRT deferred\n");
2388 vport->ct_flags |= FC_CT_RPRT_DEFER;
2389 }
2390 }
2391 break;
2392 case SLI_MGMT_RPA:
2393 if (vport->port_type == LPFC_PHYSICAL_PORT &&
2394 phba->sli4_hba.pc_sli4_params.mi_ver) {
2395
2396 if (phba->link_flag & LS_CT_VEN_RPA) {
2397 lpfc_printf_vlog(vport, KERN_INFO,
2398 LOG_DISCOVERY | LOG_ELS |
2399 LOG_CGN_MGMT,
2400 "6449 VEN RPA FDMI Success\n");
2401 phba->link_flag &= ~LS_CT_VEN_RPA;
2402 break;
2403 }
2404
2405 lpfc_printf_log(phba, KERN_INFO,
2406 LOG_DISCOVERY | LOG_CGN_MGMT,
2407 "6210 Issue Vendor MI FDMI %x\n",
2408 phba->sli4_hba.pc_sli4_params.mi_ver);
2409
2410
2411 if (lpfc_fdmi_cmd(vport, ndlp, cmd,
2412 LPFC_FDMI_VENDOR_ATTR_mi) == 0)
2413 phba->link_flag |= LS_CT_VEN_RPA;
2414 lpfc_printf_log(phba, KERN_INFO,
2415 LOG_DISCOVERY | LOG_ELS,
2416 "6458 Send MI FDMI:%x Flag x%x\n",
2417 phba->sli4_hba.pc_sli4_params.mi_ver,
2418 phba->link_flag);
2419 } else {
2420 lpfc_printf_log(phba, KERN_INFO,
2421 LOG_DISCOVERY | LOG_ELS,
2422 "6459 No FDMI VEN MI support - "
2423 "RPA Success\n");
2424 }
2425 break;
2426 }
2427 return;
2428 }
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440 void
2441 lpfc_fdmi_change_check(struct lpfc_vport *vport)
2442 {
2443 struct lpfc_hba *phba = vport->phba;
2444 struct lpfc_nodelist *ndlp;
2445 uint16_t cnt;
2446
2447 if (!lpfc_is_link_up(phba))
2448 return;
2449
2450
2451 if (!(vport->fc_flag & FC_FABRIC))
2452 return;
2453
2454 ndlp = lpfc_findnode_did(vport, FDMI_DID);
2455 if (!ndlp)
2456 return;
2457
2458
2459 if (strcmp(phba->os_host_name, init_utsname()->nodename)) {
2460 memset(phba->os_host_name, 0, sizeof(phba->os_host_name));
2461 scnprintf(phba->os_host_name, sizeof(phba->os_host_name), "%s",
2462 init_utsname()->nodename);
2463 lpfc_ns_cmd(vport, SLI_CTNS_RSNN_NN, 0, 0);
2464
2465
2466
2467
2468
2469
2470 if (vport->port_type == LPFC_PHYSICAL_PORT) {
2471
2472 phba->link_flag &= ~LS_CT_VEN_RPA;
2473 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
2474 } else {
2475 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2476 if (!ndlp)
2477 return;
2478 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0);
2479 }
2480
2481
2482
2483
2484 return;
2485 }
2486
2487 if (!(vport->fdmi_port_mask & LPFC_FDMI_PORT_ATTR_num_disc))
2488 return;
2489
2490
2491 cnt = lpfc_find_map_node(vport);
2492 if (cnt == vport->fdmi_num_disc)
2493 return;
2494
2495 if (vport->port_type == LPFC_PHYSICAL_PORT) {
2496 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA,
2497 LPFC_FDMI_PORT_ATTR_num_disc);
2498 } else {
2499 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2500 if (!ndlp)
2501 return;
2502 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT,
2503 LPFC_FDMI_PORT_ATTR_num_disc);
2504 }
2505 }
2506
2507
2508 static int
2509 lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
2510 {
2511 struct lpfc_fdmi_attr_entry *ae;
2512 uint32_t size;
2513
2514 ae = &ad->AttrValue;
2515 memset(ae, 0, sizeof(*ae));
2516
2517 memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName,
2518 sizeof(struct lpfc_name));
2519 size = FOURBYTES + sizeof(struct lpfc_name);
2520 ad->AttrLen = cpu_to_be16(size);
2521 ad->AttrType = cpu_to_be16(RHBA_NODENAME);
2522 return size;
2523 }
2524 static int
2525 lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
2526 struct lpfc_fdmi_attr_def *ad)
2527 {
2528 struct lpfc_fdmi_attr_entry *ae;
2529 uint32_t len, size;
2530
2531 ae = &ad->AttrValue;
2532 memset(ae, 0, sizeof(*ae));
2533
2534
2535
2536
2537 strncpy(ae->un.AttrString,
2538 "Emulex Corporation",
2539 sizeof(ae->un.AttrString));
2540 len = strnlen(ae->un.AttrString,
2541 sizeof(ae->un.AttrString));
2542 len += (len & 3) ? (4 - (len & 3)) : 4;
2543 size = FOURBYTES + len;
2544 ad->AttrLen = cpu_to_be16(size);
2545 ad->AttrType = cpu_to_be16(RHBA_MANUFACTURER);
2546 return size;
2547 }
2548
2549 static int
2550 lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
2551 {
2552 struct lpfc_hba *phba = vport->phba;
2553 struct lpfc_fdmi_attr_entry *ae;
2554 uint32_t len, size;
2555
2556 ae = &ad->AttrValue;
2557 memset(ae, 0, sizeof(*ae));
2558
2559 strncpy(ae->un.AttrString, phba->SerialNumber,
2560 sizeof(ae->un.AttrString));
2561 len = strnlen(ae->un.AttrString,
2562 sizeof(ae->un.AttrString));
2563 len += (len & 3) ? (4 - (len & 3)) : 4;
2564 size = FOURBYTES + len;
2565 ad->AttrLen = cpu_to_be16(size);
2566 ad->AttrType = cpu_to_be16(RHBA_SERIAL_NUMBER);
2567 return size;
2568 }
2569
2570 static int
2571 lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
2572 struct lpfc_fdmi_attr_def *ad)
2573 {
2574 struct lpfc_hba *phba = vport->phba;
2575 struct lpfc_fdmi_attr_entry *ae;
2576 uint32_t len, size;
2577
2578 ae = &ad->AttrValue;
2579 memset(ae, 0, sizeof(*ae));
2580
2581 strncpy(ae->un.AttrString, phba->ModelName,
2582 sizeof(ae->un.AttrString));
2583 len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
2584 len += (len & 3) ? (4 - (len & 3)) : 4;
2585 size = FOURBYTES + len;
2586 ad->AttrLen = cpu_to_be16(size);
2587 ad->AttrType = cpu_to_be16(RHBA_MODEL);
2588 return size;
2589 }
2590
2591 static int
2592 lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
2593 struct lpfc_fdmi_attr_def *ad)
2594 {
2595 struct lpfc_hba *phba = vport->phba;
2596 struct lpfc_fdmi_attr_entry *ae;
2597 uint32_t len, size;
2598
2599 ae = &ad->AttrValue;
2600 memset(ae, 0, sizeof(*ae));
2601
2602 strncpy(ae->un.AttrString, phba->ModelDesc,
2603 sizeof(ae->un.AttrString));
2604 len = strnlen(ae->un.AttrString,
2605 sizeof(ae->un.AttrString));
2606 len += (len & 3) ? (4 - (len & 3)) : 4;
2607 size = FOURBYTES + len;
2608 ad->AttrLen = cpu_to_be16(size);
2609 ad->AttrType = cpu_to_be16(RHBA_MODEL_DESCRIPTION);
2610 return size;
2611 }
2612
2613 static int
2614 lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
2615 struct lpfc_fdmi_attr_def *ad)
2616 {
2617 struct lpfc_hba *phba = vport->phba;
2618 lpfc_vpd_t *vp = &phba->vpd;
2619 struct lpfc_fdmi_attr_entry *ae;
2620 uint32_t i, j, incr, size;
2621
2622 ae = &ad->AttrValue;
2623 memset(ae, 0, sizeof(*ae));
2624
2625
2626 incr = vp->rev.biuRev;
2627 for (i = 0; i < 8; i++) {
2628 j = (incr & 0xf);
2629 if (j <= 9)
2630 ae->un.AttrString[7 - i] =
2631 (char)((uint8_t) 0x30 +
2632 (uint8_t) j);
2633 else
2634 ae->un.AttrString[7 - i] =
2635 (char)((uint8_t) 0x61 +
2636 (uint8_t) (j - 10));
2637 incr = (incr >> 4);
2638 }
2639 size = FOURBYTES + 8;
2640 ad->AttrLen = cpu_to_be16(size);
2641 ad->AttrType = cpu_to_be16(RHBA_HARDWARE_VERSION);
2642 return size;
2643 }
2644
2645 static int
2646 lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
2647 struct lpfc_fdmi_attr_def *ad)
2648 {
2649 struct lpfc_fdmi_attr_entry *ae;
2650 uint32_t len, size;
2651
2652 ae = &ad->AttrValue;
2653 memset(ae, 0, sizeof(*ae));
2654
2655 strncpy(ae->un.AttrString, lpfc_release_version,
2656 sizeof(ae->un.AttrString));
2657 len = strnlen(ae->un.AttrString,
2658 sizeof(ae->un.AttrString));
2659 len += (len & 3) ? (4 - (len & 3)) : 4;
2660 size = FOURBYTES + len;
2661 ad->AttrLen = cpu_to_be16(size);
2662 ad->AttrType = cpu_to_be16(RHBA_DRIVER_VERSION);
2663 return size;
2664 }
2665
2666 static int
2667 lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
2668 struct lpfc_fdmi_attr_def *ad)
2669 {
2670 struct lpfc_hba *phba = vport->phba;
2671 struct lpfc_fdmi_attr_entry *ae;
2672 uint32_t len, size;
2673
2674 ae = &ad->AttrValue;
2675 memset(ae, 0, sizeof(*ae));
2676
2677 if (phba->sli_rev == LPFC_SLI_REV4)
2678 lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
2679 else
2680 strncpy(ae->un.AttrString, phba->OptionROMVersion,
2681 sizeof(ae->un.AttrString));
2682 len = strnlen(ae->un.AttrString,
2683 sizeof(ae->un.AttrString));
2684 len += (len & 3) ? (4 - (len & 3)) : 4;
2685 size = FOURBYTES + len;
2686 ad->AttrLen = cpu_to_be16(size);
2687 ad->AttrType = cpu_to_be16(RHBA_OPTION_ROM_VERSION);
2688 return size;
2689 }
2690
2691 static int
2692 lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
2693 struct lpfc_fdmi_attr_def *ad)
2694 {
2695 struct lpfc_hba *phba = vport->phba;
2696 struct lpfc_fdmi_attr_entry *ae;
2697 uint32_t len, size;
2698
2699 ae = &ad->AttrValue;
2700 memset(ae, 0, sizeof(*ae));
2701
2702 lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
2703 len = strnlen(ae->un.AttrString,
2704 sizeof(ae->un.AttrString));
2705 len += (len & 3) ? (4 - (len & 3)) : 4;
2706 size = FOURBYTES + len;
2707 ad->AttrLen = cpu_to_be16(size);
2708 ad->AttrType = cpu_to_be16(RHBA_FIRMWARE_VERSION);
2709 return size;
2710 }
2711
2712 static int
2713 lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
2714 struct lpfc_fdmi_attr_def *ad)
2715 {
2716 struct lpfc_fdmi_attr_entry *ae;
2717 uint32_t len, size;
2718
2719 ae = &ad->AttrValue;
2720 memset(ae, 0, sizeof(*ae));
2721
2722 snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s %s %s",
2723 init_utsname()->sysname,
2724 init_utsname()->release,
2725 init_utsname()->version);
2726
2727 len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
2728 len += (len & 3) ? (4 - (len & 3)) : 4;
2729 size = FOURBYTES + len;
2730 ad->AttrLen = cpu_to_be16(size);
2731 ad->AttrType = cpu_to_be16(RHBA_OS_NAME_VERSION);
2732 return size;
2733 }
2734
2735 static int
2736 lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
2737 struct lpfc_fdmi_attr_def *ad)
2738 {
2739 struct lpfc_fdmi_attr_entry *ae;
2740 uint32_t size;
2741
2742 ae = &ad->AttrValue;
2743
2744 ae->un.AttrInt = cpu_to_be32(LPFC_MAX_CT_SIZE);
2745 size = FOURBYTES + sizeof(uint32_t);
2746 ad->AttrLen = cpu_to_be16(size);
2747 ad->AttrType = cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN);
2748 return size;
2749 }
2750
2751 static int
2752 lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport,
2753 struct lpfc_fdmi_attr_def *ad)
2754 {
2755 struct lpfc_fdmi_attr_entry *ae;
2756 uint32_t len, size;
2757
2758 ae = &ad->AttrValue;
2759 memset(ae, 0, sizeof(*ae));
2760
2761 len = lpfc_vport_symbolic_node_name(vport,
2762 ae->un.AttrString, 256);
2763 len += (len & 3) ? (4 - (len & 3)) : 4;
2764 size = FOURBYTES + len;
2765 ad->AttrLen = cpu_to_be16(size);
2766 ad->AttrType = cpu_to_be16(RHBA_SYM_NODENAME);
2767 return size;
2768 }
2769
2770 static int
2771 lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport *vport,
2772 struct lpfc_fdmi_attr_def *ad)
2773 {
2774 struct lpfc_fdmi_attr_entry *ae;
2775 uint32_t size;
2776
2777 ae = &ad->AttrValue;
2778
2779
2780 ae->un.AttrInt = cpu_to_be32(0);
2781 size = FOURBYTES + sizeof(uint32_t);
2782 ad->AttrLen = cpu_to_be16(size);
2783 ad->AttrType = cpu_to_be16(RHBA_VENDOR_INFO);
2784 return size;
2785 }
2786
2787 static int
2788 lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport *vport,
2789 struct lpfc_fdmi_attr_def *ad)
2790 {
2791 struct lpfc_fdmi_attr_entry *ae;
2792 uint32_t size;
2793
2794 ae = &ad->AttrValue;
2795
2796
2797 ae->un.AttrInt = cpu_to_be32(1);
2798 size = FOURBYTES + sizeof(uint32_t);
2799 ad->AttrLen = cpu_to_be16(size);
2800 ad->AttrType = cpu_to_be16(RHBA_NUM_PORTS);
2801 return size;
2802 }
2803
2804 static int
2805 lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport *vport,
2806 struct lpfc_fdmi_attr_def *ad)
2807 {
2808 struct lpfc_fdmi_attr_entry *ae;
2809 uint32_t size;
2810
2811 ae = &ad->AttrValue;
2812 memset(ae, 0, sizeof(*ae));
2813
2814 memcpy(&ae->un.AttrWWN, &vport->fabric_nodename,
2815 sizeof(struct lpfc_name));
2816 size = FOURBYTES + sizeof(struct lpfc_name);
2817 ad->AttrLen = cpu_to_be16(size);
2818 ad->AttrType = cpu_to_be16(RHBA_FABRIC_WWNN);
2819 return size;
2820 }
2821
2822 static int
2823 lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport *vport,
2824 struct lpfc_fdmi_attr_def *ad)
2825 {
2826 struct lpfc_hba *phba = vport->phba;
2827 struct lpfc_fdmi_attr_entry *ae;
2828 uint32_t len, size;
2829
2830 ae = &ad->AttrValue;
2831 memset(ae, 0, sizeof(*ae));
2832
2833 strlcat(ae->un.AttrString, phba->BIOSVersion,
2834 sizeof(ae->un.AttrString));
2835 len = strnlen(ae->un.AttrString,
2836 sizeof(ae->un.AttrString));
2837 len += (len & 3) ? (4 - (len & 3)) : 4;
2838 size = FOURBYTES + len;
2839 ad->AttrLen = cpu_to_be16(size);
2840 ad->AttrType = cpu_to_be16(RHBA_BIOS_VERSION);
2841 return size;
2842 }
2843
2844 static int
2845 lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport *vport,
2846 struct lpfc_fdmi_attr_def *ad)
2847 {
2848 struct lpfc_fdmi_attr_entry *ae;
2849 uint32_t size;
2850
2851 ae = &ad->AttrValue;
2852
2853
2854 ae->un.AttrInt = cpu_to_be32(0);
2855 size = FOURBYTES + sizeof(uint32_t);
2856 ad->AttrLen = cpu_to_be16(size);
2857 ad->AttrType = cpu_to_be16(RHBA_BIOS_STATE);
2858 return size;
2859 }
2860
2861 static int
2862 lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport *vport,
2863 struct lpfc_fdmi_attr_def *ad)
2864 {
2865 struct lpfc_fdmi_attr_entry *ae;
2866 uint32_t len, size;
2867
2868 ae = &ad->AttrValue;
2869 memset(ae, 0, sizeof(*ae));
2870
2871 strncpy(ae->un.AttrString, "EMULEX",
2872 sizeof(ae->un.AttrString));
2873 len = strnlen(ae->un.AttrString,
2874 sizeof(ae->un.AttrString));
2875 len += (len & 3) ? (4 - (len & 3)) : 4;
2876 size = FOURBYTES + len;
2877 ad->AttrLen = cpu_to_be16(size);
2878 ad->AttrType = cpu_to_be16(RHBA_VENDOR_ID);
2879 return size;
2880 }
2881
2882
2883 static int
2884 lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,
2885 struct lpfc_fdmi_attr_def *ad)
2886 {
2887 struct lpfc_hba *phba = vport->phba;
2888 struct lpfc_fdmi_attr_entry *ae;
2889 uint32_t size;
2890
2891 ae = &ad->AttrValue;
2892 memset(ae, 0, sizeof(*ae));
2893
2894 ae->un.AttrTypes[2] = 0x01;
2895 ae->un.AttrTypes[7] = 0x01;
2896
2897
2898 if ((phba->sli_rev == LPFC_SLI_REV4) && (vport == phba->pport) &&
2899 phba->sli4_hba.pc_sli4_params.nvme)
2900 ae->un.AttrTypes[6] = 0x01;
2901
2902 size = FOURBYTES + 32;
2903 ad->AttrLen = cpu_to_be16(size);
2904 ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES);
2905 return size;
2906 }
2907
2908 static int
2909 lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport,
2910 struct lpfc_fdmi_attr_def *ad)
2911 {
2912 struct lpfc_hba *phba = vport->phba;
2913 struct lpfc_fdmi_attr_entry *ae;
2914 uint32_t size;
2915 u32 tcfg;
2916 u8 i, cnt;
2917
2918 ae = &ad->AttrValue;
2919
2920 ae->un.AttrInt = 0;
2921 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
2922 cnt = 0;
2923 if (phba->sli_rev == LPFC_SLI_REV4) {
2924 tcfg = phba->sli4_hba.conf_trunk;
2925 for (i = 0; i < 4; i++, tcfg >>= 1)
2926 if (tcfg & 1)
2927 cnt++;
2928 }
2929
2930 if (cnt > 2) {
2931 if (phba->lmt & LMT_64Gb)
2932 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2933 if (phba->lmt & LMT_32Gb)
2934 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2935 if (phba->lmt & LMT_16Gb)
2936 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2937 } else if (cnt) {
2938 if (phba->lmt & LMT_128Gb)
2939 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2940 if (phba->lmt & LMT_64Gb)
2941 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2942 if (phba->lmt & LMT_32Gb)
2943 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2944 if (phba->lmt & LMT_16Gb)
2945 ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2946 } else {
2947 if (phba->lmt & LMT_256Gb)
2948 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2949 if (phba->lmt & LMT_128Gb)
2950 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2951 if (phba->lmt & LMT_64Gb)
2952 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2953 if (phba->lmt & LMT_32Gb)
2954 ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2955 if (phba->lmt & LMT_16Gb)
2956 ae->un.AttrInt |= HBA_PORTSPEED_16GFC;
2957 if (phba->lmt & LMT_10Gb)
2958 ae->un.AttrInt |= HBA_PORTSPEED_10GFC;
2959 if (phba->lmt & LMT_8Gb)
2960 ae->un.AttrInt |= HBA_PORTSPEED_8GFC;
2961 if (phba->lmt & LMT_4Gb)
2962 ae->un.AttrInt |= HBA_PORTSPEED_4GFC;
2963 if (phba->lmt & LMT_2Gb)
2964 ae->un.AttrInt |= HBA_PORTSPEED_2GFC;
2965 if (phba->lmt & LMT_1Gb)
2966 ae->un.AttrInt |= HBA_PORTSPEED_1GFC;
2967 }
2968 } else {
2969
2970 switch (phba->fc_linkspeed) {
2971 case LPFC_ASYNC_LINK_SPEED_10GBPS:
2972 ae->un.AttrInt = HBA_PORTSPEED_10GE;
2973 break;
2974 case LPFC_ASYNC_LINK_SPEED_25GBPS:
2975 ae->un.AttrInt = HBA_PORTSPEED_25GE;
2976 break;
2977 case LPFC_ASYNC_LINK_SPEED_40GBPS:
2978 ae->un.AttrInt = HBA_PORTSPEED_40GE;
2979 break;
2980 case LPFC_ASYNC_LINK_SPEED_100GBPS:
2981 ae->un.AttrInt = HBA_PORTSPEED_100GE;
2982 break;
2983 }
2984 }
2985 ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt);
2986 size = FOURBYTES + sizeof(uint32_t);
2987 ad->AttrLen = cpu_to_be16(size);
2988 ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_SPEED);
2989 return size;
2990 }
2991
2992 static int
2993 lpfc_fdmi_port_attr_speed(struct lpfc_vport *vport,
2994 struct lpfc_fdmi_attr_def *ad)
2995 {
2996 struct lpfc_hba *phba = vport->phba;
2997 struct lpfc_fdmi_attr_entry *ae;
2998 uint32_t size;
2999
3000 ae = &ad->AttrValue;
3001
3002 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
3003 switch (phba->fc_linkspeed) {
3004 case LPFC_LINK_SPEED_1GHZ:
3005 ae->un.AttrInt = HBA_PORTSPEED_1GFC;
3006 break;
3007 case LPFC_LINK_SPEED_2GHZ:
3008 ae->un.AttrInt = HBA_PORTSPEED_2GFC;
3009 break;
3010 case LPFC_LINK_SPEED_4GHZ:
3011 ae->un.AttrInt = HBA_PORTSPEED_4GFC;
3012 break;
3013 case LPFC_LINK_SPEED_8GHZ:
3014 ae->un.AttrInt = HBA_PORTSPEED_8GFC;
3015 break;
3016 case LPFC_LINK_SPEED_10GHZ:
3017 ae->un.AttrInt = HBA_PORTSPEED_10GFC;
3018 break;
3019 case LPFC_LINK_SPEED_16GHZ:
3020 ae->un.AttrInt = HBA_PORTSPEED_16GFC;
3021 break;
3022 case LPFC_LINK_SPEED_32GHZ:
3023 ae->un.AttrInt = HBA_PORTSPEED_32GFC;
3024 break;
3025 case LPFC_LINK_SPEED_64GHZ:
3026 ae->un.AttrInt = HBA_PORTSPEED_64GFC;
3027 break;
3028 case LPFC_LINK_SPEED_128GHZ:
3029 ae->un.AttrInt = HBA_PORTSPEED_128GFC;
3030 break;
3031 case LPFC_LINK_SPEED_256GHZ:
3032 ae->un.AttrInt = HBA_PORTSPEED_256GFC;
3033 break;
3034 default:
3035 ae->un.AttrInt = HBA_PORTSPEED_UNKNOWN;
3036 break;
3037 }
3038 } else {
3039 switch (phba->fc_linkspeed) {
3040 case LPFC_ASYNC_LINK_SPEED_10GBPS:
3041 ae->un.AttrInt = HBA_PORTSPEED_10GE;
3042 break;
3043 case LPFC_ASYNC_LINK_SPEED_25GBPS:
3044 ae->un.AttrInt = HBA_PORTSPEED_25GE;
3045 break;
3046 case LPFC_ASYNC_LINK_SPEED_40GBPS:
3047 ae->un.AttrInt = HBA_PORTSPEED_40GE;
3048 break;
3049 case LPFC_ASYNC_LINK_SPEED_100GBPS:
3050 ae->un.AttrInt = HBA_PORTSPEED_100GE;
3051 break;
3052 default:
3053 ae->un.AttrInt = HBA_PORTSPEED_UNKNOWN;
3054 break;
3055 }
3056 }
3057
3058 ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt);
3059 size = FOURBYTES + sizeof(uint32_t);
3060 ad->AttrLen = cpu_to_be16(size);
3061 ad->AttrType = cpu_to_be16(RPRT_PORT_SPEED);
3062 return size;
3063 }
3064
3065 static int
3066 lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport,
3067 struct lpfc_fdmi_attr_def *ad)
3068 {
3069 struct serv_parm *hsp;
3070 struct lpfc_fdmi_attr_entry *ae;
3071 uint32_t size;
3072
3073 ae = &ad->AttrValue;
3074
3075 hsp = (struct serv_parm *)&vport->fc_sparam;
3076 ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
3077 (uint32_t) hsp->cmn.bbRcvSizeLsb;
3078 ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt);
3079 size = FOURBYTES + sizeof(uint32_t);
3080 ad->AttrLen = cpu_to_be16(size);
3081 ad->AttrType = cpu_to_be16(RPRT_MAX_FRAME_SIZE);
3082 return size;
3083 }
3084
3085 static int
3086 lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport,
3087 struct lpfc_fdmi_attr_def *ad)
3088 {
3089 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3090 struct lpfc_fdmi_attr_entry *ae;
3091 uint32_t len, size;
3092
3093 ae = &ad->AttrValue;
3094 memset(ae, 0, sizeof(*ae));
3095
3096 snprintf(ae->un.AttrString, sizeof(ae->un.AttrString),
3097 "/sys/class/scsi_host/host%d", shost->host_no);
3098 len = strnlen((char *)ae->un.AttrString,
3099 sizeof(ae->un.AttrString));
3100 len += (len & 3) ? (4 - (len & 3)) : 4;
3101 size = FOURBYTES + len;
3102 ad->AttrLen = cpu_to_be16(size);
3103 ad->AttrType = cpu_to_be16(RPRT_OS_DEVICE_NAME);
3104 return size;
3105 }
3106
3107 static int
3108 lpfc_fdmi_port_attr_host_name(struct lpfc_vport *vport,
3109 struct lpfc_fdmi_attr_def *ad)
3110 {
3111 struct lpfc_fdmi_attr_entry *ae;
3112 uint32_t len, size;
3113
3114 ae = &ad->AttrValue;
3115 memset(ae, 0, sizeof(*ae));
3116
3117 scnprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s",
3118 vport->phba->os_host_name);
3119
3120 len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
3121 len += (len & 3) ? (4 - (len & 3)) : 4;
3122 size = FOURBYTES + len;
3123 ad->AttrLen = cpu_to_be16(size);
3124 ad->AttrType = cpu_to_be16(RPRT_HOST_NAME);
3125 return size;
3126 }
3127
3128 static int
3129 lpfc_fdmi_port_attr_wwnn(struct lpfc_vport *vport,
3130 struct lpfc_fdmi_attr_def *ad)
3131 {
3132 struct lpfc_fdmi_attr_entry *ae;
3133 uint32_t size;
3134
3135 ae = &ad->AttrValue;
3136 memset(ae, 0, sizeof(*ae));
3137
3138 memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName,
3139 sizeof(struct lpfc_name));
3140 size = FOURBYTES + sizeof(struct lpfc_name);
3141 ad->AttrLen = cpu_to_be16(size);
3142 ad->AttrType = cpu_to_be16(RPRT_NODENAME);
3143 return size;
3144 }
3145
3146 static int
3147 lpfc_fdmi_port_attr_wwpn(struct lpfc_vport *vport,
3148 struct lpfc_fdmi_attr_def *ad)
3149 {
3150 struct lpfc_fdmi_attr_entry *ae;
3151 uint32_t size;
3152
3153 ae = &ad->AttrValue;
3154 memset(ae, 0, sizeof(*ae));
3155
3156 memcpy(&ae->un.AttrWWN, &vport->fc_sparam.portName,
3157 sizeof(struct lpfc_name));
3158 size = FOURBYTES + sizeof(struct lpfc_name);
3159 ad->AttrLen = cpu_to_be16(size);
3160 ad->AttrType = cpu_to_be16(RPRT_PORTNAME);
3161 return size;
3162 }
3163
3164 static int
3165 lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport *vport,
3166 struct lpfc_fdmi_attr_def *ad)
3167 {
3168 struct lpfc_fdmi_attr_entry *ae;
3169 uint32_t len, size;
3170
3171 ae = &ad->AttrValue;
3172 memset(ae, 0, sizeof(*ae));
3173
3174 len = lpfc_vport_symbolic_port_name(vport, ae->un.AttrString, 256);
3175 len += (len & 3) ? (4 - (len & 3)) : 4;
3176 size = FOURBYTES + len;
3177 ad->AttrLen = cpu_to_be16(size);
3178 ad->AttrType = cpu_to_be16(RPRT_SYM_PORTNAME);
3179 return size;
3180 }
3181
3182 static int
3183 lpfc_fdmi_port_attr_port_type(struct lpfc_vport *vport,
3184 struct lpfc_fdmi_attr_def *ad)
3185 {
3186 struct lpfc_hba *phba = vport->phba;
3187 struct lpfc_fdmi_attr_entry *ae;
3188 uint32_t size;
3189
3190 ae = &ad->AttrValue;
3191 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP)
3192 ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT);
3193 else
3194 ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTTYPE_NPORT);
3195 size = FOURBYTES + sizeof(uint32_t);
3196 ad->AttrLen = cpu_to_be16(size);
3197 ad->AttrType = cpu_to_be16(RPRT_PORT_TYPE);
3198 return size;
3199 }
3200
3201 static int
3202 lpfc_fdmi_port_attr_class(struct lpfc_vport *vport,
3203 struct lpfc_fdmi_attr_def *ad)
3204 {
3205 struct lpfc_fdmi_attr_entry *ae;
3206 uint32_t size;
3207
3208 ae = &ad->AttrValue;
3209 ae->un.AttrInt = cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3);
3210 size = FOURBYTES + sizeof(uint32_t);
3211 ad->AttrLen = cpu_to_be16(size);
3212 ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_CLASS);
3213 return size;
3214 }
3215
3216 static int
3217 lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport *vport,
3218 struct lpfc_fdmi_attr_def *ad)
3219 {
3220 struct lpfc_fdmi_attr_entry *ae;
3221 uint32_t size;
3222
3223 ae = &ad->AttrValue;
3224 memset(ae, 0, sizeof(*ae));
3225
3226 memcpy(&ae->un.AttrWWN, &vport->fabric_portname,
3227 sizeof(struct lpfc_name));
3228 size = FOURBYTES + sizeof(struct lpfc_name);
3229 ad->AttrLen = cpu_to_be16(size);
3230 ad->AttrType = cpu_to_be16(RPRT_FABRICNAME);
3231 return size;
3232 }
3233
3234 static int
3235 lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
3236 struct lpfc_fdmi_attr_def *ad)
3237 {
3238 struct lpfc_hba *phba = vport->phba;
3239 struct lpfc_fdmi_attr_entry *ae;
3240 uint32_t size;
3241
3242 ae = &ad->AttrValue;
3243 memset(ae, 0, sizeof(*ae));
3244
3245 ae->un.AttrTypes[2] = 0x01;
3246 ae->un.AttrTypes[7] = 0x01;
3247
3248
3249 if (vport == phba->pport &&
3250 phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
3251 ae->un.AttrTypes[6] = 0x1;
3252
3253 size = FOURBYTES + 32;
3254 ad->AttrLen = cpu_to_be16(size);
3255 ad->AttrType = cpu_to_be16(RPRT_ACTIVE_FC4_TYPES);
3256 return size;
3257 }
3258
3259 static int
3260 lpfc_fdmi_port_attr_port_state(struct lpfc_vport *vport,
3261 struct lpfc_fdmi_attr_def *ad)
3262 {
3263 struct lpfc_fdmi_attr_entry *ae;
3264 uint32_t size;
3265
3266 ae = &ad->AttrValue;
3267
3268 ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE);
3269 size = FOURBYTES + sizeof(uint32_t);
3270 ad->AttrLen = cpu_to_be16(size);
3271 ad->AttrType = cpu_to_be16(RPRT_PORT_STATE);
3272 return size;
3273 }
3274
3275 static int
3276 lpfc_fdmi_port_attr_num_disc(struct lpfc_vport *vport,
3277 struct lpfc_fdmi_attr_def *ad)
3278 {
3279 struct lpfc_fdmi_attr_entry *ae;
3280 uint32_t size;
3281
3282 ae = &ad->AttrValue;
3283 vport->fdmi_num_disc = lpfc_find_map_node(vport);
3284 ae->un.AttrInt = cpu_to_be32(vport->fdmi_num_disc);
3285 size = FOURBYTES + sizeof(uint32_t);
3286 ad->AttrLen = cpu_to_be16(size);
3287 ad->AttrType = cpu_to_be16(RPRT_DISC_PORT);
3288 return size;
3289 }
3290
3291 static int
3292 lpfc_fdmi_port_attr_nportid(struct lpfc_vport *vport,
3293 struct lpfc_fdmi_attr_def *ad)
3294 {
3295 struct lpfc_fdmi_attr_entry *ae;
3296 uint32_t size;
3297
3298 ae = &ad->AttrValue;
3299 ae->un.AttrInt = cpu_to_be32(vport->fc_myDID);
3300 size = FOURBYTES + sizeof(uint32_t);
3301 ad->AttrLen = cpu_to_be16(size);
3302 ad->AttrType = cpu_to_be16(RPRT_PORT_ID);
3303 return size;
3304 }
3305
3306 static int
3307 lpfc_fdmi_smart_attr_service(struct lpfc_vport *vport,
3308 struct lpfc_fdmi_attr_def *ad)
3309 {
3310 struct lpfc_fdmi_attr_entry *ae;
3311 uint32_t len, size;
3312
3313 ae = &ad->AttrValue;
3314 memset(ae, 0, sizeof(*ae));
3315
3316 strncpy(ae->un.AttrString, "Smart SAN Initiator",
3317 sizeof(ae->un.AttrString));
3318 len = strnlen(ae->un.AttrString,
3319 sizeof(ae->un.AttrString));
3320 len += (len & 3) ? (4 - (len & 3)) : 4;
3321 size = FOURBYTES + len;
3322 ad->AttrLen = cpu_to_be16(size);
3323 ad->AttrType = cpu_to_be16(RPRT_SMART_SERVICE);
3324 return size;
3325 }
3326
3327 static int
3328 lpfc_fdmi_smart_attr_guid(struct lpfc_vport *vport,
3329 struct lpfc_fdmi_attr_def *ad)
3330 {
3331 struct lpfc_fdmi_attr_entry *ae;
3332 uint32_t size;
3333
3334 ae = &ad->AttrValue;
3335 memset(ae, 0, sizeof(*ae));
3336
3337 memcpy(&ae->un.AttrString, &vport->fc_sparam.nodeName,
3338 sizeof(struct lpfc_name));
3339 memcpy((((uint8_t *)&ae->un.AttrString) +
3340 sizeof(struct lpfc_name)),
3341 &vport->fc_sparam.portName, sizeof(struct lpfc_name));
3342 size = FOURBYTES + (2 * sizeof(struct lpfc_name));
3343 ad->AttrLen = cpu_to_be16(size);
3344 ad->AttrType = cpu_to_be16(RPRT_SMART_GUID);
3345 return size;
3346 }
3347
3348 static int
3349 lpfc_fdmi_smart_attr_version(struct lpfc_vport *vport,
3350 struct lpfc_fdmi_attr_def *ad)
3351 {
3352 struct lpfc_fdmi_attr_entry *ae;
3353 uint32_t len, size;
3354
3355 ae = &ad->AttrValue;
3356 memset(ae, 0, sizeof(*ae));
3357
3358 strncpy(ae->un.AttrString, "Smart SAN Version 2.0",
3359 sizeof(ae->un.AttrString));
3360 len = strnlen(ae->un.AttrString,
3361 sizeof(ae->un.AttrString));
3362 len += (len & 3) ? (4 - (len & 3)) : 4;
3363 size = FOURBYTES + len;
3364 ad->AttrLen = cpu_to_be16(size);
3365 ad->AttrType = cpu_to_be16(RPRT_SMART_VERSION);
3366 return size;
3367 }
3368
3369 static int
3370 lpfc_fdmi_smart_attr_model(struct lpfc_vport *vport,
3371 struct lpfc_fdmi_attr_def *ad)
3372 {
3373 struct lpfc_hba *phba = vport->phba;
3374 struct lpfc_fdmi_attr_entry *ae;
3375 uint32_t len, size;
3376
3377 ae = &ad->AttrValue;
3378 memset(ae, 0, sizeof(*ae));
3379
3380 strncpy(ae->un.AttrString, phba->ModelName,
3381 sizeof(ae->un.AttrString));
3382 len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
3383 len += (len & 3) ? (4 - (len & 3)) : 4;
3384 size = FOURBYTES + len;
3385 ad->AttrLen = cpu_to_be16(size);
3386 ad->AttrType = cpu_to_be16(RPRT_SMART_MODEL);
3387 return size;
3388 }
3389
3390 static int
3391 lpfc_fdmi_smart_attr_port_info(struct lpfc_vport *vport,
3392 struct lpfc_fdmi_attr_def *ad)
3393 {
3394 struct lpfc_fdmi_attr_entry *ae;
3395 uint32_t size;
3396
3397 ae = &ad->AttrValue;
3398
3399
3400 if (vport->vpi)
3401 ae->un.AttrInt = cpu_to_be32(2);
3402 else
3403 ae->un.AttrInt = cpu_to_be32(1);
3404 size = FOURBYTES + sizeof(uint32_t);
3405 ad->AttrLen = cpu_to_be16(size);
3406 ad->AttrType = cpu_to_be16(RPRT_SMART_PORT_INFO);
3407 return size;
3408 }
3409
3410 static int
3411 lpfc_fdmi_smart_attr_qos(struct lpfc_vport *vport,
3412 struct lpfc_fdmi_attr_def *ad)
3413 {
3414 struct lpfc_fdmi_attr_entry *ae;
3415 uint32_t size;
3416
3417 ae = &ad->AttrValue;
3418 ae->un.AttrInt = cpu_to_be32(0);
3419 size = FOURBYTES + sizeof(uint32_t);
3420 ad->AttrLen = cpu_to_be16(size);
3421 ad->AttrType = cpu_to_be16(RPRT_SMART_QOS);
3422 return size;
3423 }
3424
3425 static int
3426 lpfc_fdmi_smart_attr_security(struct lpfc_vport *vport,
3427 struct lpfc_fdmi_attr_def *ad)
3428 {
3429 struct lpfc_fdmi_attr_entry *ae;
3430 uint32_t size;
3431
3432 ae = &ad->AttrValue;
3433 ae->un.AttrInt = cpu_to_be32(1);
3434 size = FOURBYTES + sizeof(uint32_t);
3435 ad->AttrLen = cpu_to_be16(size);
3436 ad->AttrType = cpu_to_be16(RPRT_SMART_SECURITY);
3437 return size;
3438 }
3439
3440 static int
3441 lpfc_fdmi_vendor_attr_mi(struct lpfc_vport *vport,
3442 struct lpfc_fdmi_attr_def *ad)
3443 {
3444 struct lpfc_hba *phba = vport->phba;
3445 struct lpfc_fdmi_attr_entry *ae;
3446 uint32_t len, size;
3447 char mibrevision[16];
3448
3449 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
3450 memset(ae, 0, 256);
3451 sprintf(mibrevision, "ELXE2EM:%04d",
3452 phba->sli4_hba.pc_sli4_params.mi_ver);
3453 strncpy(ae->un.AttrString, &mibrevision[0], sizeof(ae->un.AttrString));
3454 len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
3455 len += (len & 3) ? (4 - (len & 3)) : 4;
3456 size = FOURBYTES + len;
3457 ad->AttrLen = cpu_to_be16(size);
3458 ad->AttrType = cpu_to_be16(RPRT_VENDOR_MI);
3459 return size;
3460 }
3461
3462
3463 int (*lpfc_fdmi_hba_action[])
3464 (struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) = {
3465
3466 lpfc_fdmi_hba_attr_wwnn,
3467 lpfc_fdmi_hba_attr_manufacturer,
3468 lpfc_fdmi_hba_attr_sn,
3469 lpfc_fdmi_hba_attr_model,
3470 lpfc_fdmi_hba_attr_description,
3471 lpfc_fdmi_hba_attr_hdw_ver,
3472 lpfc_fdmi_hba_attr_drvr_ver,
3473 lpfc_fdmi_hba_attr_rom_ver,
3474 lpfc_fdmi_hba_attr_fmw_ver,
3475 lpfc_fdmi_hba_attr_os_ver,
3476 lpfc_fdmi_hba_attr_ct_len,
3477 lpfc_fdmi_hba_attr_symbolic_name,
3478 lpfc_fdmi_hba_attr_vendor_info,
3479 lpfc_fdmi_hba_attr_num_ports,
3480 lpfc_fdmi_hba_attr_fabric_wwnn,
3481 lpfc_fdmi_hba_attr_bios_ver,
3482 lpfc_fdmi_hba_attr_bios_state,
3483 lpfc_fdmi_hba_attr_vendor_id,
3484 };
3485
3486
3487 int (*lpfc_fdmi_port_action[])
3488 (struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) = {
3489
3490 lpfc_fdmi_port_attr_fc4type,
3491 lpfc_fdmi_port_attr_support_speed,
3492 lpfc_fdmi_port_attr_speed,
3493 lpfc_fdmi_port_attr_max_frame,
3494 lpfc_fdmi_port_attr_os_devname,
3495 lpfc_fdmi_port_attr_host_name,
3496 lpfc_fdmi_port_attr_wwnn,
3497 lpfc_fdmi_port_attr_wwpn,
3498 lpfc_fdmi_port_attr_symbolic_name,
3499 lpfc_fdmi_port_attr_port_type,
3500 lpfc_fdmi_port_attr_class,
3501 lpfc_fdmi_port_attr_fabric_wwpn,
3502 lpfc_fdmi_port_attr_active_fc4type,
3503 lpfc_fdmi_port_attr_port_state,
3504 lpfc_fdmi_port_attr_num_disc,
3505 lpfc_fdmi_port_attr_nportid,
3506 lpfc_fdmi_smart_attr_service,
3507 lpfc_fdmi_smart_attr_guid,
3508 lpfc_fdmi_smart_attr_version,
3509 lpfc_fdmi_smart_attr_model,
3510 lpfc_fdmi_smart_attr_port_info,
3511 lpfc_fdmi_smart_attr_qos,
3512 lpfc_fdmi_smart_attr_security,
3513 lpfc_fdmi_vendor_attr_mi,
3514 };
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525 int
3526 lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
3527 int cmdcode, uint32_t new_mask)
3528 {
3529 struct lpfc_hba *phba = vport->phba;
3530 struct lpfc_dmabuf *mp, *bmp;
3531 struct lpfc_sli_ct_request *CtReq;
3532 struct ulp_bde64 *bpl;
3533 uint32_t bit_pos;
3534 uint32_t size;
3535 uint32_t rsp_size;
3536 uint32_t mask;
3537 struct lpfc_fdmi_reg_hba *rh;
3538 struct lpfc_fdmi_port_entry *pe;
3539 struct lpfc_fdmi_reg_portattr *pab = NULL;
3540 struct lpfc_fdmi_attr_block *ab = NULL;
3541 int (*func)(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad);
3542 void (*cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
3543 struct lpfc_iocbq *);
3544
3545 if (!ndlp)
3546 return 0;
3547
3548 cmpl = lpfc_cmpl_ct_disc_fdmi;
3549
3550
3551
3552 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
3553 if (!mp)
3554 goto fdmi_cmd_exit;
3555
3556 mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys));
3557 if (!mp->virt)
3558 goto fdmi_cmd_free_mp;
3559
3560
3561 bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
3562 if (!bmp)
3563 goto fdmi_cmd_free_mpvirt;
3564
3565 bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys));
3566 if (!bmp->virt)
3567 goto fdmi_cmd_free_bmp;
3568
3569 INIT_LIST_HEAD(&mp->list);
3570 INIT_LIST_HEAD(&bmp->list);
3571
3572
3573 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
3574 "0218 FDMI Request x%x mask x%x Data: x%x x%x x%x\n",
3575 cmdcode, new_mask, vport->fdmi_port_mask,
3576 vport->fc_flag, vport->port_state);
3577
3578 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
3579
3580
3581 memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request));
3582 CtReq->RevisionId.bits.Revision = SLI_CT_REVISION;
3583 CtReq->RevisionId.bits.InId = 0;
3584
3585 CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE;
3586 CtReq->FsSubType = SLI_CT_FDMI_Subtypes;
3587
3588 CtReq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode);
3589 rsp_size = LPFC_BPL_SIZE;
3590 size = 0;
3591
3592
3593 switch (cmdcode) {
3594 case SLI_MGMT_RHAT:
3595 case SLI_MGMT_RHBA:
3596 rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un.PortID;
3597
3598 memcpy(&rh->hi.PortName, &phba->pport->fc_sparam.portName,
3599 sizeof(struct lpfc_name));
3600
3601 if (cmdcode == SLI_MGMT_RHBA) {
3602
3603
3604 rh->rpl.EntryCnt = cpu_to_be32(1);
3605 memcpy(&rh->rpl.pe.PortName,
3606 &phba->pport->fc_sparam.portName,
3607 sizeof(struct lpfc_name));
3608
3609
3610 size = 2 * sizeof(struct lpfc_name) +
3611 FOURBYTES;
3612 } else {
3613 size = sizeof(struct lpfc_name);
3614 }
3615 ab = (struct lpfc_fdmi_attr_block *)((uint8_t *)rh + size);
3616 ab->EntryCnt = 0;
3617 size += FOURBYTES;
3618 bit_pos = 0;
3619 if (new_mask)
3620 mask = new_mask;
3621 else
3622 mask = vport->fdmi_hba_mask;
3623
3624
3625 while (mask) {
3626 if (mask & 0x1) {
3627 func = lpfc_fdmi_hba_action[bit_pos];
3628 size += func(vport,
3629 (struct lpfc_fdmi_attr_def *)
3630 ((uint8_t *)rh + size));
3631 ab->EntryCnt++;
3632 if ((size + 256) >
3633 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
3634 goto hba_out;
3635 }
3636 mask = mask >> 1;
3637 bit_pos++;
3638 }
3639 hba_out:
3640 ab->EntryCnt = cpu_to_be32(ab->EntryCnt);
3641
3642 size = GID_REQUEST_SZ - 4 + size;
3643 break;
3644
3645 case SLI_MGMT_RPRT:
3646 if (vport->port_type != LPFC_PHYSICAL_PORT) {
3647 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
3648 if (!ndlp)
3649 return 0;
3650 }
3651 fallthrough;
3652 case SLI_MGMT_RPA:
3653 pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID;
3654 if (cmdcode == SLI_MGMT_RPRT) {
3655 rh = (struct lpfc_fdmi_reg_hba *)pab;
3656
3657 memcpy(&rh->hi.PortName,
3658 &phba->pport->fc_sparam.portName,
3659 sizeof(struct lpfc_name));
3660 pab = (struct lpfc_fdmi_reg_portattr *)
3661 ((uint8_t *)pab + sizeof(struct lpfc_name));
3662 }
3663
3664 memcpy((uint8_t *)&pab->PortName,
3665 (uint8_t *)&vport->fc_sparam.portName,
3666 sizeof(struct lpfc_name));
3667 size += sizeof(struct lpfc_name) + FOURBYTES;
3668 pab->ab.EntryCnt = 0;
3669 bit_pos = 0;
3670 if (new_mask)
3671 mask = new_mask;
3672 else
3673 mask = vport->fdmi_port_mask;
3674
3675
3676 while (mask) {
3677 if (mask & 0x1) {
3678 func = lpfc_fdmi_port_action[bit_pos];
3679 size += func(vport,
3680 (struct lpfc_fdmi_attr_def *)
3681 ((uint8_t *)pab + size));
3682 pab->ab.EntryCnt++;
3683 if ((size + 256) >
3684 (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
3685 goto port_out;
3686 }
3687 mask = mask >> 1;
3688 bit_pos++;
3689 }
3690 port_out:
3691 pab->ab.EntryCnt = cpu_to_be32(pab->ab.EntryCnt);
3692
3693 if (cmdcode == SLI_MGMT_RPRT)
3694 size += sizeof(struct lpfc_name);
3695 size = GID_REQUEST_SZ - 4 + size;
3696 break;
3697
3698 case SLI_MGMT_GHAT:
3699 case SLI_MGMT_GRPL:
3700 rsp_size = FC_MAX_NS_RSP;
3701 fallthrough;
3702 case SLI_MGMT_DHBA:
3703 case SLI_MGMT_DHAT:
3704 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
3705 memcpy((uint8_t *)&pe->PortName,
3706 (uint8_t *)&vport->fc_sparam.portName,
3707 sizeof(struct lpfc_name));
3708 size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name);
3709 break;
3710
3711 case SLI_MGMT_GPAT:
3712 case SLI_MGMT_GPAS:
3713 rsp_size = FC_MAX_NS_RSP;
3714 fallthrough;
3715 case SLI_MGMT_DPRT:
3716 if (vport->port_type != LPFC_PHYSICAL_PORT) {
3717 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
3718 if (!ndlp)
3719 return 0;
3720 }
3721 fallthrough;
3722 case SLI_MGMT_DPA:
3723 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
3724 memcpy((uint8_t *)&pe->PortName,
3725 (uint8_t *)&vport->fc_sparam.portName,
3726 sizeof(struct lpfc_name));
3727 size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name);
3728 break;
3729 case SLI_MGMT_GRHL:
3730 size = GID_REQUEST_SZ - 4;
3731 break;
3732 default:
3733 lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY,
3734 "0298 FDMI cmdcode x%x not supported\n",
3735 cmdcode);
3736 goto fdmi_cmd_free_bmpvirt;
3737 }
3738 CtReq->CommandResponse.bits.Size = cpu_to_be16(rsp_size);
3739
3740 bpl = (struct ulp_bde64 *)bmp->virt;
3741 bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys));
3742 bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys));
3743 bpl->tus.f.bdeFlags = 0;
3744 bpl->tus.f.bdeSize = size;
3745
3746
3747
3748
3749
3750 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, 0))
3751 return 0;
3752
3753 fdmi_cmd_free_bmpvirt:
3754 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
3755 fdmi_cmd_free_bmp:
3756 kfree(bmp);
3757 fdmi_cmd_free_mpvirt:
3758 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3759 fdmi_cmd_free_mp:
3760 kfree(mp);
3761 fdmi_cmd_exit:
3762
3763 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
3764 "0244 Issue FDMI request failed Data: x%x\n",
3765 cmdcode);
3766 return 1;
3767 }
3768
3769
3770
3771
3772
3773
3774
3775
3776 void
3777 lpfc_delayed_disc_tmo(struct timer_list *t)
3778 {
3779 struct lpfc_vport *vport = from_timer(vport, t, delayed_disc_tmo);
3780 struct lpfc_hba *phba = vport->phba;
3781 uint32_t tmo_posted;
3782 unsigned long iflag;
3783
3784 spin_lock_irqsave(&vport->work_port_lock, iflag);
3785 tmo_posted = vport->work_port_events & WORKER_DELAYED_DISC_TMO;
3786 if (!tmo_posted)
3787 vport->work_port_events |= WORKER_DELAYED_DISC_TMO;
3788 spin_unlock_irqrestore(&vport->work_port_lock, iflag);
3789
3790 if (!tmo_posted)
3791 lpfc_worker_wake_up(phba);
3792 return;
3793 }
3794
3795
3796
3797
3798
3799
3800
3801
3802 void
3803 lpfc_delayed_disc_timeout_handler(struct lpfc_vport *vport)
3804 {
3805 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3806
3807 spin_lock_irq(shost->host_lock);
3808 if (!(vport->fc_flag & FC_DISC_DELAYED)) {
3809 spin_unlock_irq(shost->host_lock);
3810 return;
3811 }
3812 vport->fc_flag &= ~FC_DISC_DELAYED;
3813 spin_unlock_irq(shost->host_lock);
3814
3815 lpfc_do_scr_ns_plogi(vport->phba, vport);
3816 }
3817
3818 void
3819 lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag)
3820 {
3821 struct lpfc_sli *psli = &phba->sli;
3822 lpfc_vpd_t *vp = &phba->vpd;
3823 uint32_t b1, b2, b3, b4, i, rev;
3824 char c;
3825 uint32_t *ptr, str[4];
3826 uint8_t *fwname;
3827
3828 if (phba->sli_rev == LPFC_SLI_REV4)
3829 snprintf(fwrevision, FW_REV_STR_SIZE, "%s", vp->rev.opFwName);
3830 else if (vp->rev.rBit) {
3831 if (psli->sli_flag & LPFC_SLI_ACTIVE)
3832 rev = vp->rev.sli2FwRev;
3833 else
3834 rev = vp->rev.sli1FwRev;
3835
3836 b1 = (rev & 0x0000f000) >> 12;
3837 b2 = (rev & 0x00000f00) >> 8;
3838 b3 = (rev & 0x000000c0) >> 6;
3839 b4 = (rev & 0x00000030) >> 4;
3840
3841 switch (b4) {
3842 case 0:
3843 c = 'N';
3844 break;
3845 case 1:
3846 c = 'A';
3847 break;
3848 case 2:
3849 c = 'B';
3850 break;
3851 case 3:
3852 c = 'X';
3853 break;
3854 default:
3855 c = 0;
3856 break;
3857 }
3858 b4 = (rev & 0x0000000f);
3859
3860 if (psli->sli_flag & LPFC_SLI_ACTIVE)
3861 fwname = vp->rev.sli2FwName;
3862 else
3863 fwname = vp->rev.sli1FwName;
3864
3865 for (i = 0; i < 16; i++)
3866 if (fwname[i] == 0x20)
3867 fwname[i] = 0;
3868
3869 ptr = (uint32_t*)fwname;
3870
3871 for (i = 0; i < 3; i++)
3872 str[i] = be32_to_cpu(*ptr++);
3873
3874 if (c == 0) {
3875 if (flag)
3876 sprintf(fwrevision, "%d.%d%d (%s)",
3877 b1, b2, b3, (char *)str);
3878 else
3879 sprintf(fwrevision, "%d.%d%d", b1,
3880 b2, b3);
3881 } else {
3882 if (flag)
3883 sprintf(fwrevision, "%d.%d%d%c%d (%s)",
3884 b1, b2, b3, c,
3885 b4, (char *)str);
3886 else
3887 sprintf(fwrevision, "%d.%d%d%c%d",
3888 b1, b2, b3, c, b4);
3889 }
3890 } else {
3891 rev = vp->rev.smFwRev;
3892
3893 b1 = (rev & 0xff000000) >> 24;
3894 b2 = (rev & 0x00f00000) >> 20;
3895 b3 = (rev & 0x000f0000) >> 16;
3896 c = (rev & 0x0000ff00) >> 8;
3897 b4 = (rev & 0x000000ff);
3898
3899 sprintf(fwrevision, "%d.%d%d%c%d", b1, b2, b3, c, b4);
3900 }
3901 return;
3902 }
3903
3904 static void
3905 lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3906 struct lpfc_iocbq *rspiocb)
3907 {
3908 struct lpfc_vport *vport = cmdiocb->vport;
3909 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
3910 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
3911 struct lpfc_sli_ct_request *ctcmd = inp->virt;
3912 struct lpfc_sli_ct_request *ctrsp = outp->virt;
3913 u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
3914 struct app_id_object *app;
3915 u32 cmd, hash, bucket;
3916 struct lpfc_vmid *vmp, *cur;
3917 u8 *data = outp->virt;
3918 int i;
3919
3920 cmd = be16_to_cpu(ctcmd->CommandResponse.bits.CmdRsp);
3921 if (cmd == SLI_CTAS_DALLAPP_ID)
3922 lpfc_ct_free_iocb(phba, cmdiocb);
3923
3924 if (lpfc_els_chk_latt(vport) || get_job_ulpstatus(phba, rspiocb)) {
3925 if (cmd != SLI_CTAS_DALLAPP_ID)
3926 return;
3927 }
3928
3929 if (rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
3930 if (cmd != SLI_CTAS_DALLAPP_ID)
3931 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
3932 "3306 VMID FS_RJT Data: x%x x%x x%x\n",
3933 cmd, ctrsp->ReasonCode,
3934 ctrsp->Explanation);
3935 if ((cmd != SLI_CTAS_DALLAPP_ID) ||
3936 (ctrsp->ReasonCode != SLI_CT_UNABLE_TO_PERFORM_REQ) ||
3937 (ctrsp->Explanation != SLI_CT_APP_ID_NOT_AVAILABLE)) {
3938
3939 if (cmd == SLI_CTAS_DALLAPP_ID)
3940 vport->load_flag |= FC_DEREGISTER_ALL_APP_ID;
3941 return;
3942 }
3943 }
3944
3945 switch (cmd) {
3946 case SLI_CTAS_RAPP_IDENT:
3947 app = (struct app_id_object *)(RAPP_IDENT_OFFSET + data);
3948 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
3949 "6712 RAPP_IDENT app id %d port id x%x id "
3950 "len %d\n", be32_to_cpu(app->app_id),
3951 be32_to_cpu(app->port_id),
3952 app->obj.entity_id_len);
3953
3954 if (app->obj.entity_id_len == 0 || app->port_id == 0)
3955 return;
3956
3957 hash = lpfc_vmid_hash_fn(app->obj.entity_id,
3958 app->obj.entity_id_len);
3959 vmp = lpfc_get_vmid_from_hashtable(vport, hash,
3960 app->obj.entity_id);
3961 if (vmp) {
3962 write_lock(&vport->vmid_lock);
3963 vmp->un.app_id = be32_to_cpu(app->app_id);
3964 vmp->flag |= LPFC_VMID_REGISTERED;
3965 vmp->flag &= ~LPFC_VMID_REQ_REGISTER;
3966 write_unlock(&vport->vmid_lock);
3967
3968 vport->vmid_flag |= LPFC_VMID_IN_USE;
3969 } else {
3970 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
3971 "6901 No entry found %s hash %d\n",
3972 app->obj.entity_id, hash);
3973 }
3974 break;
3975 case SLI_CTAS_DAPP_IDENT:
3976 app = (struct app_id_object *)(DAPP_IDENT_OFFSET + data);
3977 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
3978 "6713 DAPP_IDENT app id %d port id x%x\n",
3979 be32_to_cpu(app->app_id),
3980 be32_to_cpu(app->port_id));
3981 break;
3982 case SLI_CTAS_DALLAPP_ID:
3983 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
3984 "8856 Deregistered all app ids\n");
3985 read_lock(&vport->vmid_lock);
3986 for (i = 0; i < phba->cfg_max_vmid; i++) {
3987 vmp = &vport->vmid[i];
3988 if (vmp->flag != LPFC_VMID_SLOT_FREE)
3989 memset(vmp, 0, sizeof(struct lpfc_vmid));
3990 }
3991 read_unlock(&vport->vmid_lock);
3992
3993 if (!hash_empty(vport->hash_table))
3994 hash_for_each(vport->hash_table, bucket, cur, hnode)
3995 hash_del(&cur->hnode);
3996 vport->load_flag |= FC_ALLOW_VMID;
3997 break;
3998 default:
3999 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
4000 "8857 Invalid command code\n");
4001 }
4002 }
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012 int
4013 lpfc_vmid_cmd(struct lpfc_vport *vport,
4014 int cmdcode, struct lpfc_vmid *vmid)
4015 {
4016 struct lpfc_hba *phba = vport->phba;
4017 struct lpfc_dmabuf *mp, *bmp;
4018 struct lpfc_sli_ct_request *ctreq;
4019 struct ulp_bde64 *bpl;
4020 u32 size;
4021 u32 rsp_size;
4022 u8 *data;
4023 struct lpfc_vmid_rapp_ident_list *rap;
4024 struct lpfc_vmid_dapp_ident_list *dap;
4025 u8 retry = 0;
4026 struct lpfc_nodelist *ndlp;
4027
4028 void (*cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4029 struct lpfc_iocbq *rspiocb);
4030
4031 ndlp = lpfc_findnode_did(vport, FDMI_DID);
4032 if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
4033 return 0;
4034
4035 cmpl = lpfc_cmpl_ct_cmd_vmid;
4036
4037
4038
4039 mp = kmalloc(sizeof(*mp), GFP_KERNEL);
4040 if (!mp)
4041 goto vmid_free_mp_exit;
4042
4043 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
4044 if (!mp->virt)
4045 goto vmid_free_mp_virt_exit;
4046
4047
4048 bmp = kmalloc(sizeof(*bmp), GFP_KERNEL);
4049 if (!bmp)
4050 goto vmid_free_bmp_exit;
4051
4052 bmp->virt = lpfc_mbuf_alloc(phba, 0, &bmp->phys);
4053 if (!bmp->virt)
4054 goto vmid_free_bmp_virt_exit;
4055
4056 INIT_LIST_HEAD(&mp->list);
4057 INIT_LIST_HEAD(&bmp->list);
4058
4059 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
4060 "3275 VMID Request Data: x%x x%x x%x\n",
4061 vport->fc_flag, vport->port_state, cmdcode);
4062 ctreq = (struct lpfc_sli_ct_request *)mp->virt;
4063 data = mp->virt;
4064
4065 memset(data, 0, LPFC_BPL_SIZE);
4066 ctreq->RevisionId.bits.Revision = SLI_CT_REVISION;
4067 ctreq->RevisionId.bits.InId = 0;
4068
4069 ctreq->FsType = SLI_CT_MANAGEMENT_SERVICE;
4070 ctreq->FsSubType = SLI_CT_APP_SEV_Subtypes;
4071
4072 ctreq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode);
4073 rsp_size = LPFC_BPL_SIZE;
4074 size = 0;
4075
4076 switch (cmdcode) {
4077 case SLI_CTAS_RAPP_IDENT:
4078 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
4079 "1329 RAPP_IDENT for %s\n", vmid->host_vmid);
4080 ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
4081 rap = (struct lpfc_vmid_rapp_ident_list *)
4082 (DAPP_IDENT_OFFSET + data);
4083 rap->no_of_objects = cpu_to_be32(1);
4084 rap->obj[0].entity_id_len = vmid->vmid_len;
4085 memcpy(rap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
4086 size = RAPP_IDENT_OFFSET +
4087 sizeof(struct lpfc_vmid_rapp_ident_list);
4088 retry = 1;
4089 break;
4090
4091 case SLI_CTAS_GALLAPPIA_ID:
4092 ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
4093 size = GALLAPPIA_ID_SIZE;
4094 break;
4095
4096 case SLI_CTAS_DAPP_IDENT:
4097 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
4098 "1469 DAPP_IDENT for %s\n", vmid->host_vmid);
4099 ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
4100 dap = (struct lpfc_vmid_dapp_ident_list *)
4101 (DAPP_IDENT_OFFSET + data);
4102 dap->no_of_objects = cpu_to_be32(1);
4103 dap->obj[0].entity_id_len = vmid->vmid_len;
4104 memcpy(dap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
4105 size = DAPP_IDENT_OFFSET +
4106 sizeof(struct lpfc_vmid_dapp_ident_list);
4107 write_lock(&vport->vmid_lock);
4108 vmid->flag &= ~LPFC_VMID_REGISTERED;
4109 write_unlock(&vport->vmid_lock);
4110 retry = 1;
4111 break;
4112
4113 case SLI_CTAS_DALLAPP_ID:
4114 ctreq->un.PortID = cpu_to_be32(vport->fc_myDID);
4115 size = DALLAPP_ID_SIZE;
4116 break;
4117
4118 default:
4119 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
4120 "7062 VMID cmdcode x%x not supported\n",
4121 cmdcode);
4122 goto vmid_free_all_mem;
4123 }
4124
4125 ctreq->CommandResponse.bits.Size = cpu_to_be16(rsp_size);
4126
4127 bpl = (struct ulp_bde64 *)bmp->virt;
4128 bpl->addrHigh = putPaddrHigh(mp->phys);
4129 bpl->addrLow = putPaddrLow(mp->phys);
4130 bpl->tus.f.bdeFlags = 0;
4131 bpl->tus.f.bdeSize = size;
4132
4133
4134
4135
4136 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry))
4137 return 0;
4138
4139 vmid_free_all_mem:
4140 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
4141 vmid_free_bmp_virt_exit:
4142 kfree(bmp);
4143 vmid_free_bmp_exit:
4144 lpfc_mbuf_free(phba, mp->virt, mp->phys);
4145 vmid_free_mp_virt_exit:
4146 kfree(mp);
4147 vmid_free_mp_exit:
4148
4149
4150 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
4151 "3276 VMID CT request failed Data: x%x\n", cmdcode);
4152 return -EIO;
4153 }