1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
10 * This program is free software; you can redistribute it and/or *
11 * modify it under the terms of version 2 of the GNU General *
12 * Public License as published by the Free Software Foundation. *
13 * This program is distributed in the hope that it will be useful. *
14 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
15 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
17 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18 * TO BE LEGALLY INVALID. See the GNU General Public License for *
19 * more details, a copy of which can be found in the file COPYING *
20 * included with this package. *
21 *******************************************************************/
24 * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS
27 #include <linux/blkdev.h>
28 #include <linux/pci.h>
29 #include <linux/interrupt.h>
30 #include <linux/slab.h>
31 #include <linux/utsname.h>
33 #include <scsi/scsi.h>
34 #include <scsi/scsi_device.h>
35 #include <scsi/scsi_host.h>
36 #include <scsi/scsi_transport_fc.h>
37 #include <scsi/fc/fc_fs.h>
42 #include "lpfc_sli4.h"
44 #include "lpfc_disc.h"
46 #include "lpfc_scsi.h"
47 #include "lpfc_nvme.h"
48 #include "lpfc_logmsg.h"
49 #include "lpfc_crtn.h"
50 #include "lpfc_version.h"
51 #include "lpfc_vport.h"
52 #include "lpfc_debugfs.h"
54 /* FDMI Port Speed definitions - FC-GS-7 */
55 #define HBA_PORTSPEED_1GFC 0x00000001 /* 1G FC */
56 #define HBA_PORTSPEED_2GFC 0x00000002 /* 2G FC */
57 #define HBA_PORTSPEED_4GFC 0x00000008 /* 4G FC */
58 #define HBA_PORTSPEED_10GFC 0x00000004 /* 10G FC */
59 #define HBA_PORTSPEED_8GFC 0x00000010 /* 8G FC */
60 #define HBA_PORTSPEED_16GFC 0x00000020 /* 16G FC */
61 #define HBA_PORTSPEED_32GFC 0x00000040 /* 32G FC */
62 #define HBA_PORTSPEED_20GFC 0x00000080 /* 20G FC */
63 #define HBA_PORTSPEED_40GFC 0x00000100 /* 40G FC */
64 #define HBA_PORTSPEED_128GFC 0x00000200 /* 128G FC */
65 #define HBA_PORTSPEED_64GFC 0x00000400 /* 64G FC */
66 #define HBA_PORTSPEED_256GFC 0x00000800 /* 256G FC */
67 #define HBA_PORTSPEED_UNKNOWN 0x00008000 /* Unknown */
68 #define HBA_PORTSPEED_10GE 0x00010000 /* 10G E */
69 #define HBA_PORTSPEED_40GE 0x00020000 /* 40G E */
70 #define HBA_PORTSPEED_100GE 0x00040000 /* 100G E */
71 #define HBA_PORTSPEED_25GE 0x00080000 /* 25G E */
72 #define HBA_PORTSPEED_50GE 0x00100000 /* 50G E */
73 #define HBA_PORTSPEED_400GE 0x00200000 /* 400G E */
78 static char *lpfc_release_version
= LPFC_DRIVER_VERSION
;
81 lpfc_ct_ignore_hbq_buffer(struct lpfc_hba
*phba
, struct lpfc_iocbq
*piocbq
,
82 struct lpfc_dmabuf
*mp
, uint32_t size
)
85 lpfc_printf_log(phba
, KERN_INFO
, LOG_ELS
,
86 "0146 Ignoring unsolicited CT No HBQ "
88 piocbq
->iocb
.ulpStatus
);
90 lpfc_printf_log(phba
, KERN_INFO
, LOG_ELS
,
91 "0145 Ignoring unsolicted CT HBQ Size:%d "
93 size
, piocbq
->iocb
.ulpStatus
);
97 lpfc_ct_unsol_buffer(struct lpfc_hba
*phba
, struct lpfc_iocbq
*piocbq
,
98 struct lpfc_dmabuf
*mp
, uint32_t size
)
100 lpfc_ct_ignore_hbq_buffer(phba
, piocbq
, mp
, size
);
104 lpfc_ct_unsol_event(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
105 struct lpfc_iocbq
*piocbq
)
107 struct lpfc_dmabuf
*mp
= NULL
;
108 IOCB_t
*icmd
= &piocbq
->iocb
;
110 struct lpfc_iocbq
*iocbq
;
113 struct list_head head
;
114 struct lpfc_dmabuf
*bdeBuf
;
116 if (lpfc_bsg_ct_unsol_event(phba
, pring
, piocbq
) == 0)
119 if (unlikely(icmd
->ulpStatus
== IOSTAT_NEED_BUFFER
)) {
120 lpfc_sli_hbqbuf_add_hbqs(phba
, LPFC_ELS_HBQ
);
121 } else if ((icmd
->ulpStatus
== IOSTAT_LOCAL_REJECT
) &&
122 ((icmd
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
123 IOERR_RCV_BUFFER_WAITING
)) {
124 /* Not enough posted buffers; Try posting more buffers */
125 phba
->fc_stat
.NoRcvBuf
++;
126 if (!(phba
->sli3_options
& LPFC_SLI3_HBQ_ENABLED
))
127 lpfc_post_buffer(phba
, pring
, 2);
131 /* If there are no BDEs associated with this IOCB,
132 * there is nothing to do.
134 if (icmd
->ulpBdeCount
== 0)
137 if (phba
->sli3_options
& LPFC_SLI3_HBQ_ENABLED
) {
138 INIT_LIST_HEAD(&head
);
139 list_add_tail(&head
, &piocbq
->list
);
140 list_for_each_entry(iocbq
, &head
, list
) {
142 if (icmd
->ulpBdeCount
== 0)
144 bdeBuf
= iocbq
->context2
;
145 iocbq
->context2
= NULL
;
146 size
= icmd
->un
.cont64
[0].tus
.f
.bdeSize
;
147 lpfc_ct_unsol_buffer(phba
, piocbq
, bdeBuf
, size
);
148 lpfc_in_buf_free(phba
, bdeBuf
);
149 if (icmd
->ulpBdeCount
== 2) {
150 bdeBuf
= iocbq
->context3
;
151 iocbq
->context3
= NULL
;
152 size
= icmd
->unsli3
.rcvsli3
.bde2
.tus
.f
.bdeSize
;
153 lpfc_ct_unsol_buffer(phba
, piocbq
, bdeBuf
,
155 lpfc_in_buf_free(phba
, bdeBuf
);
160 INIT_LIST_HEAD(&head
);
161 list_add_tail(&head
, &piocbq
->list
);
162 list_for_each_entry(iocbq
, &head
, list
) {
164 if (icmd
->ulpBdeCount
== 0)
165 lpfc_ct_unsol_buffer(phba
, iocbq
, NULL
, 0);
166 for (i
= 0; i
< icmd
->ulpBdeCount
; i
++) {
167 paddr
= getPaddr(icmd
->un
.cont64
[i
].addrHigh
,
168 icmd
->un
.cont64
[i
].addrLow
);
169 mp
= lpfc_sli_ringpostbuf_get(phba
, pring
,
171 size
= icmd
->un
.cont64
[i
].tus
.f
.bdeSize
;
172 lpfc_ct_unsol_buffer(phba
, iocbq
, mp
, size
);
173 lpfc_in_buf_free(phba
, mp
);
175 lpfc_post_buffer(phba
, pring
, i
);
182 * lpfc_ct_handle_unsol_abort - ct upper level protocol abort handler
183 * @phba: Pointer to HBA context object.
184 * @dmabuf: pointer to a dmabuf that describes the FC sequence
186 * This function serves as the upper level protocol abort handler for CT
189 * Return 1 if abort has been handled, 0 otherwise.
192 lpfc_ct_handle_unsol_abort(struct lpfc_hba
*phba
, struct hbq_dmabuf
*dmabuf
)
196 /* CT upper level goes through BSG */
197 handled
= lpfc_bsg_ct_unsol_abort(phba
, dmabuf
);
203 lpfc_free_ct_rsp(struct lpfc_hba
*phba
, struct lpfc_dmabuf
*mlist
)
205 struct lpfc_dmabuf
*mlast
, *next_mlast
;
207 list_for_each_entry_safe(mlast
, next_mlast
, &mlist
->list
, list
) {
208 lpfc_mbuf_free(phba
, mlast
->virt
, mlast
->phys
);
209 list_del(&mlast
->list
);
212 lpfc_mbuf_free(phba
, mlist
->virt
, mlist
->phys
);
217 static struct lpfc_dmabuf
*
218 lpfc_alloc_ct_rsp(struct lpfc_hba
*phba
, int cmdcode
, struct ulp_bde64
*bpl
,
219 uint32_t size
, int *entries
)
221 struct lpfc_dmabuf
*mlist
= NULL
;
222 struct lpfc_dmabuf
*mp
;
225 /* We get chunks of FCELSSIZE */
226 cnt
= size
> FCELSSIZE
? FCELSSIZE
: size
;
229 /* Allocate buffer for rsp payload */
230 mp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
233 lpfc_free_ct_rsp(phba
, mlist
);
237 INIT_LIST_HEAD(&mp
->list
);
239 if (cmdcode
== be16_to_cpu(SLI_CTNS_GID_FT
) ||
240 cmdcode
== be16_to_cpu(SLI_CTNS_GFF_ID
))
241 mp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(mp
->phys
));
243 mp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(mp
->phys
));
248 lpfc_free_ct_rsp(phba
, mlist
);
252 /* Queue it to a linked list */
256 list_add_tail(&mp
->list
, &mlist
->list
);
258 bpl
->tus
.f
.bdeFlags
= BUFF_TYPE_BDE_64I
;
259 /* build buffer ptr list for IOCB */
260 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
) );
261 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
) );
262 bpl
->tus
.f
.bdeSize
= (uint16_t) cnt
;
263 bpl
->tus
.w
= le32_to_cpu(bpl
->tus
.w
);
275 lpfc_ct_free_iocb(struct lpfc_hba
*phba
, struct lpfc_iocbq
*ctiocb
)
277 struct lpfc_dmabuf
*buf_ptr
;
279 if (ctiocb
->context_un
.ndlp
) {
280 lpfc_nlp_put(ctiocb
->context_un
.ndlp
);
281 ctiocb
->context_un
.ndlp
= NULL
;
283 if (ctiocb
->context1
) {
284 buf_ptr
= (struct lpfc_dmabuf
*) ctiocb
->context1
;
285 lpfc_mbuf_free(phba
, buf_ptr
->virt
, buf_ptr
->phys
);
287 ctiocb
->context1
= NULL
;
289 if (ctiocb
->context2
) {
290 lpfc_free_ct_rsp(phba
, (struct lpfc_dmabuf
*) ctiocb
->context2
);
291 ctiocb
->context2
= NULL
;
294 if (ctiocb
->context3
) {
295 buf_ptr
= (struct lpfc_dmabuf
*) ctiocb
->context3
;
296 lpfc_mbuf_free(phba
, buf_ptr
->virt
, buf_ptr
->phys
);
298 ctiocb
->context3
= NULL
;
300 lpfc_sli_release_iocbq(phba
, ctiocb
);
305 * lpfc_gen_req - Build and issue a GEN_REQUEST command to the SLI Layer
306 * @vport: pointer to a host virtual N_Port data structure.
307 * @bmp: Pointer to BPL for SLI command
308 * @inp: Pointer to data buffer for response data.
309 * @outp: Pointer to data buffer that hold the CT command.
310 * @cmpl: completion routine to call when command completes
311 * @ndlp: Destination NPort nodelist entry
313 * This function as the final part for issuing a CT command.
316 lpfc_gen_req(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*bmp
,
317 struct lpfc_dmabuf
*inp
, struct lpfc_dmabuf
*outp
,
318 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
319 struct lpfc_iocbq
*),
320 struct lpfc_nodelist
*ndlp
, uint32_t usr_flg
, uint32_t num_entry
,
321 uint32_t tmo
, uint8_t retry
)
323 struct lpfc_hba
*phba
= vport
->phba
;
325 struct lpfc_iocbq
*geniocb
;
328 /* Allocate buffer for command iocb */
329 geniocb
= lpfc_sli_get_iocbq(phba
);
334 icmd
= &geniocb
->iocb
;
335 icmd
->un
.genreq64
.bdl
.ulpIoTag32
= 0;
336 icmd
->un
.genreq64
.bdl
.addrHigh
= putPaddrHigh(bmp
->phys
);
337 icmd
->un
.genreq64
.bdl
.addrLow
= putPaddrLow(bmp
->phys
);
338 icmd
->un
.genreq64
.bdl
.bdeFlags
= BUFF_TYPE_BLP_64
;
339 icmd
->un
.genreq64
.bdl
.bdeSize
= (num_entry
* sizeof(struct ulp_bde64
));
342 geniocb
->context3
= NULL
;
344 geniocb
->context3
= (uint8_t *) bmp
;
346 /* Save for completion so we can release these resources */
347 geniocb
->context1
= (uint8_t *) inp
;
348 geniocb
->context2
= (uint8_t *) outp
;
349 geniocb
->context_un
.ndlp
= lpfc_nlp_get(ndlp
);
351 /* Fill in payload, bp points to frame payload */
352 icmd
->ulpCommand
= CMD_GEN_REQUEST64_CR
;
354 /* Fill in rest of iocb */
355 icmd
->un
.genreq64
.w5
.hcsw
.Fctl
= (SI
| LA
);
356 icmd
->un
.genreq64
.w5
.hcsw
.Dfctl
= 0;
357 icmd
->un
.genreq64
.w5
.hcsw
.Rctl
= FC_RCTL_DD_UNSOL_CTL
;
358 icmd
->un
.genreq64
.w5
.hcsw
.Type
= FC_TYPE_CT
;
361 /* FC spec states we need 3 * ratov for CT requests */
362 tmo
= (3 * phba
->fc_ratov
);
364 icmd
->ulpTimeout
= tmo
;
365 icmd
->ulpBdeCount
= 1;
367 icmd
->ulpClass
= CLASS3
;
368 icmd
->ulpContext
= ndlp
->nlp_rpi
;
369 if (phba
->sli_rev
== LPFC_SLI_REV4
)
370 icmd
->ulpContext
= phba
->sli4_hba
.rpi_ids
[ndlp
->nlp_rpi
];
372 if (phba
->sli3_options
& LPFC_SLI3_NPIV_ENABLED
) {
373 /* For GEN_REQUEST64_CR, use the RPI */
378 /* Issue GEN REQ IOCB for NPORT <did> */
379 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
380 "0119 Issue GEN REQ IOCB to NPORT x%x "
382 ndlp
->nlp_DID
, icmd
->ulpIoTag
,
384 geniocb
->iocb_cmpl
= cmpl
;
385 geniocb
->drvrTimeout
= icmd
->ulpTimeout
+ LPFC_DRVR_TIMEOUT
;
386 geniocb
->vport
= vport
;
387 geniocb
->retry
= retry
;
388 rc
= lpfc_sli_issue_iocb(phba
, LPFC_ELS_RING
, geniocb
, 0);
390 if (rc
== IOCB_ERROR
) {
391 lpfc_sli_release_iocbq(phba
, geniocb
);
399 * lpfc_ct_cmd - Build and issue a CT command
400 * @vport: pointer to a host virtual N_Port data structure.
401 * @inmp: Pointer to data buffer for response data.
402 * @bmp: Pointer to BPL for SLI command
403 * @ndlp: Destination NPort nodelist entry
404 * @cmpl: completion routine to call when command completes
406 * This function is called for issuing a CT command.
409 lpfc_ct_cmd(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*inmp
,
410 struct lpfc_dmabuf
*bmp
, struct lpfc_nodelist
*ndlp
,
411 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
412 struct lpfc_iocbq
*),
413 uint32_t rsp_size
, uint8_t retry
)
415 struct lpfc_hba
*phba
= vport
->phba
;
416 struct ulp_bde64
*bpl
= (struct ulp_bde64
*) bmp
->virt
;
417 struct lpfc_dmabuf
*outmp
;
419 int cmdcode
= ((struct lpfc_sli_ct_request
*) inmp
->virt
)->
420 CommandResponse
.bits
.CmdRsp
;
422 bpl
++; /* Skip past ct request */
424 /* Put buffer(s) for ct rsp in bpl */
425 outmp
= lpfc_alloc_ct_rsp(phba
, cmdcode
, bpl
, rsp_size
, &cnt
);
429 * Form the CT IOCB. The total number of BDEs in this IOCB
430 * is the single command plus response count from
434 status
= lpfc_gen_req(vport
, bmp
, inmp
, outmp
, cmpl
, ndlp
, 0,
437 lpfc_free_ct_rsp(phba
, outmp
);
444 lpfc_find_vport_by_did(struct lpfc_hba
*phba
, uint32_t did
) {
445 struct lpfc_vport
*vport_curr
;
448 spin_lock_irqsave(&phba
->hbalock
, flags
);
449 list_for_each_entry(vport_curr
, &phba
->port_list
, listentry
) {
450 if ((vport_curr
->fc_myDID
) && (vport_curr
->fc_myDID
== did
)) {
451 spin_unlock_irqrestore(&phba
->hbalock
, flags
);
455 spin_unlock_irqrestore(&phba
->hbalock
, flags
);
460 lpfc_prep_node_fc4type(struct lpfc_vport
*vport
, uint32_t Did
, uint8_t fc4_type
)
462 struct lpfc_nodelist
*ndlp
;
464 if ((vport
->port_type
!= LPFC_NPIV_PORT
) ||
465 !(vport
->ct_flags
& FC_CT_RFF_ID
) || !vport
->cfg_restrict_login
) {
467 ndlp
= lpfc_setup_disc_node(vport
, Did
);
469 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
470 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
471 "Parse GID_FTrsp: did:x%x flg:x%x x%x",
472 Did
, ndlp
->nlp_flag
, vport
->fc_flag
);
474 /* By default, the driver expects to support FCP FC4 */
475 if (fc4_type
== FC_TYPE_FCP
)
476 ndlp
->nlp_fc4_type
|= NLP_FC4_FCP
;
478 if (fc4_type
== FC_TYPE_NVME
)
479 ndlp
->nlp_fc4_type
|= NLP_FC4_NVME
;
481 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
482 "0238 Process x%06x NameServer Rsp "
483 "Data: x%x x%x x%x x%x\n", Did
,
484 ndlp
->nlp_flag
, ndlp
->nlp_fc4_type
,
486 vport
->fc_rscn_id_cnt
);
488 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
489 "Skip1 GID_FTrsp: did:x%x flg:x%x cnt:%d",
490 Did
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
492 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
493 "0239 Skip x%06x NameServer Rsp "
494 "Data: x%x x%x\n", Did
,
496 vport
->fc_rscn_id_cnt
);
499 if (!(vport
->fc_flag
& FC_RSCN_MODE
) ||
500 lpfc_rscn_payload_check(vport
, Did
)) {
501 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
502 "Query GID_FTrsp: did:x%x flg:x%x cnt:%d",
503 Did
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
506 * This NPortID was previously a FCP/NVMe target,
507 * Don't even bother to send GFF_ID.
509 ndlp
= lpfc_findnode_did(vport
, Did
);
510 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
) &&
512 (NLP_FCP_TARGET
| NLP_NVME_TARGET
))) {
513 if (fc4_type
== FC_TYPE_FCP
)
514 ndlp
->nlp_fc4_type
|= NLP_FC4_FCP
;
515 if (fc4_type
== FC_TYPE_NVME
)
516 ndlp
->nlp_fc4_type
|= NLP_FC4_NVME
;
517 lpfc_setup_disc_node(vport
, Did
);
518 } else if (lpfc_ns_cmd(vport
, SLI_CTNS_GFF_ID
,
520 vport
->num_disc_nodes
++;
522 lpfc_setup_disc_node(vport
, Did
);
524 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
525 "Skip2 GID_FTrsp: did:x%x flg:x%x cnt:%d",
526 Did
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
528 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
529 "0245 Skip x%06x NameServer Rsp "
530 "Data: x%x x%x\n", Did
,
532 vport
->fc_rscn_id_cnt
);
538 lpfc_ns_rsp_audit_did(struct lpfc_vport
*vport
, uint32_t Did
, uint8_t fc4_type
)
540 struct lpfc_hba
*phba
= vport
->phba
;
541 struct lpfc_nodelist
*ndlp
= NULL
;
542 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
545 * To conserve rpi's, filter out addresses for other
546 * vports on the same physical HBAs.
548 if (Did
!= vport
->fc_myDID
&&
549 (!lpfc_find_vport_by_did(phba
, Did
) ||
550 vport
->cfg_peer_port_login
)) {
551 if (!phba
->nvmet_support
) {
552 /* FCPI/NVMEI path. Process Did */
553 lpfc_prep_node_fc4type(vport
, Did
, fc4_type
);
556 /* NVMET path. NVMET only cares about NVMEI nodes. */
557 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
558 if (ndlp
->nlp_type
!= NLP_NVME_INITIATOR
||
559 ndlp
->nlp_state
!= NLP_STE_UNMAPPED_NODE
)
561 spin_lock_irq(shost
->host_lock
);
562 if (ndlp
->nlp_DID
== Did
)
563 ndlp
->nlp_flag
&= ~NLP_NVMET_RECOV
;
565 ndlp
->nlp_flag
|= NLP_NVMET_RECOV
;
566 spin_unlock_irq(shost
->host_lock
);
572 lpfc_ns_rsp(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*mp
, uint8_t fc4_type
,
575 struct lpfc_sli_ct_request
*Response
=
576 (struct lpfc_sli_ct_request
*) mp
->virt
;
577 struct lpfc_dmabuf
*mlast
, *next_mp
;
578 uint32_t *ctptr
= (uint32_t *) & Response
->un
.gid
.PortType
;
579 uint32_t Did
, CTentry
;
581 struct list_head head
;
582 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
583 struct lpfc_nodelist
*ndlp
= NULL
;
585 lpfc_set_disctmo(vport
);
586 vport
->num_disc_nodes
= 0;
587 vport
->fc_ns_retry
= 0;
590 list_add_tail(&head
, &mp
->list
);
591 list_for_each_entry_safe(mp
, next_mp
, &head
, list
) {
594 Cnt
= Size
> FCELSSIZE
? FCELSSIZE
: Size
;
599 ctptr
= (uint32_t *) mlast
->virt
;
601 Cnt
-= 16; /* subtract length of CT header */
603 /* Loop through entire NameServer list of DIDs */
604 while (Cnt
>= sizeof(uint32_t)) {
605 /* Get next DID from NameServer List */
607 Did
= ((be32_to_cpu(CTentry
)) & Mask_DID
);
608 lpfc_ns_rsp_audit_did(vport
, Did
, fc4_type
);
609 if (CTentry
& (cpu_to_be32(SLI_CT_LAST_ENTRY
)))
612 Cnt
-= sizeof(uint32_t);
618 /* All GID_FT entries processed. If the driver is running in
619 * in target mode, put impacted nodes into recovery and drop
620 * the RPI to flush outstanding IO.
622 if (vport
->phba
->nvmet_support
) {
623 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
624 if (!(ndlp
->nlp_flag
& NLP_NVMET_RECOV
))
626 lpfc_disc_state_machine(vport
, ndlp
, NULL
,
627 NLP_EVT_DEVICE_RECOVERY
);
628 spin_lock_irq(shost
->host_lock
);
629 ndlp
->nlp_flag
&= ~NLP_NVMET_RECOV
;
630 spin_unlock_irq(shost
->host_lock
);
640 lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
641 struct lpfc_iocbq
*rspiocb
)
643 struct lpfc_vport
*vport
= cmdiocb
->vport
;
644 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
646 struct lpfc_dmabuf
*outp
;
647 struct lpfc_dmabuf
*inp
;
648 struct lpfc_sli_ct_request
*CTrsp
;
649 struct lpfc_sli_ct_request
*CTreq
;
650 struct lpfc_nodelist
*ndlp
;
653 /* First save ndlp, before we overwrite it */
654 ndlp
= cmdiocb
->context_un
.ndlp
;
656 /* we pass cmdiocb to state machine which needs rspiocb as well */
657 cmdiocb
->context_un
.rsp_iocb
= rspiocb
;
658 inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
659 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
660 irsp
= &rspiocb
->iocb
;
662 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
663 "GID_FT cmpl: status:x%x/x%x rtry:%d",
664 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], vport
->fc_ns_retry
);
666 /* Don't bother processing response if vport is being torn down. */
667 if (vport
->load_flag
& FC_UNLOADING
) {
668 if (vport
->fc_flag
& FC_RSCN_MODE
)
669 lpfc_els_flush_rscn(vport
);
673 if (lpfc_els_chk_latt(vport
)) {
674 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
675 "0216 Link event during NS query\n");
676 if (vport
->fc_flag
& FC_RSCN_MODE
)
677 lpfc_els_flush_rscn(vport
);
678 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
681 if (lpfc_error_lost_link(irsp
)) {
682 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
683 "0226 NS query failed due to link event\n");
684 if (vport
->fc_flag
& FC_RSCN_MODE
)
685 lpfc_els_flush_rscn(vport
);
689 spin_lock_irq(shost
->host_lock
);
690 if (vport
->fc_flag
& FC_RSCN_DEFERRED
) {
691 vport
->fc_flag
&= ~FC_RSCN_DEFERRED
;
692 spin_unlock_irq(shost
->host_lock
);
695 * Skip processing the NS response
696 * Re-issue the NS cmd
698 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
699 "0151 Process Deferred RSCN Data: x%x x%x\n",
700 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
701 lpfc_els_handle_rscn(vport
);
705 spin_unlock_irq(shost
->host_lock
);
707 if (irsp
->ulpStatus
) {
708 /* Check for retry */
709 if (vport
->fc_ns_retry
< LPFC_MAX_NS_RETRY
) {
710 if (irsp
->ulpStatus
!= IOSTAT_LOCAL_REJECT
||
711 (irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) !=
713 vport
->fc_ns_retry
++;
715 type
= lpfc_get_gidft_type(vport
, cmdiocb
);
719 /* CT command is being retried */
721 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GID_FT
,
722 vport
->fc_ns_retry
, type
);
726 if (vport
->fc_flag
& FC_RSCN_MODE
)
727 lpfc_els_flush_rscn(vport
);
728 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
729 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
730 "0257 GID_FT Query error: 0x%x 0x%x\n",
731 irsp
->ulpStatus
, vport
->fc_ns_retry
);
733 /* Good status, continue checking */
734 CTreq
= (struct lpfc_sli_ct_request
*) inp
->virt
;
735 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
736 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
737 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC
)) {
738 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
739 "0208 NameServer Rsp Data: x%x x%x\n",
741 CTreq
->un
.gid
.Fc4Type
);
745 CTreq
->un
.gid
.Fc4Type
,
746 (uint32_t) (irsp
->un
.genreq64
.bdl
.bdeSize
));
747 } else if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
748 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT
)) {
749 /* NameServer Rsp Error */
750 if ((CTrsp
->ReasonCode
== SLI_CT_UNABLE_TO_PERFORM_REQ
)
751 && (CTrsp
->Explanation
== SLI_CT_NO_FC4_TYPES
)) {
752 lpfc_printf_vlog(vport
, KERN_INFO
,
754 "0269 No NameServer Entries "
755 "Data: x%x x%x x%x x%x\n",
756 CTrsp
->CommandResponse
.bits
.CmdRsp
,
757 (uint32_t) CTrsp
->ReasonCode
,
758 (uint32_t) CTrsp
->Explanation
,
761 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
762 "GID_FT no entry cmd:x%x rsn:x%x exp:x%x",
763 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
764 (uint32_t) CTrsp
->ReasonCode
,
765 (uint32_t) CTrsp
->Explanation
);
767 lpfc_printf_vlog(vport
, KERN_INFO
,
769 "0240 NameServer Rsp Error "
770 "Data: x%x x%x x%x x%x\n",
771 CTrsp
->CommandResponse
.bits
.CmdRsp
,
772 (uint32_t) CTrsp
->ReasonCode
,
773 (uint32_t) CTrsp
->Explanation
,
776 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
777 "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x",
778 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
779 (uint32_t) CTrsp
->ReasonCode
,
780 (uint32_t) CTrsp
->Explanation
);
785 /* NameServer Rsp Error */
786 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
787 "0241 NameServer Rsp Error "
788 "Data: x%x x%x x%x x%x\n",
789 CTrsp
->CommandResponse
.bits
.CmdRsp
,
790 (uint32_t) CTrsp
->ReasonCode
,
791 (uint32_t) CTrsp
->Explanation
,
794 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
795 "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x",
796 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
797 (uint32_t) CTrsp
->ReasonCode
,
798 (uint32_t) CTrsp
->Explanation
);
802 /* Link up / RSCN discovery */
803 if ((vport
->num_disc_nodes
== 0) &&
804 (vport
->gidft_inp
== 0)) {
806 * The driver has cycled through all Nports in the RSCN payload.
807 * Complete the handling by cleaning up and marking the
808 * current driver state.
810 if (vport
->port_state
>= LPFC_DISC_AUTH
) {
811 if (vport
->fc_flag
& FC_RSCN_MODE
) {
812 lpfc_els_flush_rscn(vport
);
813 spin_lock_irq(shost
->host_lock
);
814 vport
->fc_flag
|= FC_RSCN_MODE
; /* RSCN still */
815 spin_unlock_irq(shost
->host_lock
);
818 lpfc_els_flush_rscn(vport
);
821 lpfc_disc_start(vport
);
824 cmdiocb
->context_un
.ndlp
= ndlp
; /* Now restore ndlp for free */
825 lpfc_ct_free_iocb(phba
, cmdiocb
);
830 lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
831 struct lpfc_iocbq
*rspiocb
)
833 struct lpfc_vport
*vport
= cmdiocb
->vport
;
834 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
835 IOCB_t
*irsp
= &rspiocb
->iocb
;
836 struct lpfc_dmabuf
*inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
837 struct lpfc_dmabuf
*outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
838 struct lpfc_sli_ct_request
*CTrsp
;
841 struct lpfc_nodelist
*ndlp
;
843 did
= ((struct lpfc_sli_ct_request
*) inp
->virt
)->un
.gff
.PortId
;
844 did
= be32_to_cpu(did
);
846 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
847 "GFF_ID cmpl: status:x%x/x%x did:x%x",
848 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], did
);
850 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
851 /* Good status, continue checking */
852 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
853 fbits
= CTrsp
->un
.gff_acc
.fbits
[FCP_TYPE_FEATURE_OFFSET
];
855 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
856 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
)) {
857 if ((fbits
& FC4_FEATURE_INIT
) &&
858 !(fbits
& FC4_FEATURE_TARGET
)) {
859 lpfc_printf_vlog(vport
, KERN_INFO
,
862 "NameServer Rsp Data: (init) "
863 "x%x x%x\n", did
, fbits
,
864 vport
->fc_rscn_id_cnt
);
870 /* Check for retry */
871 if (cmdiocb
->retry
< LPFC_MAX_NS_RETRY
) {
873 if (irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) {
874 switch ((irsp
->un
.ulpWord
[4] &
877 case IOERR_NO_RESOURCES
:
878 /* We don't increment the retry
879 * count for this case.
882 case IOERR_LINK_DOWN
:
883 case IOERR_SLI_ABORTED
:
895 /* CT command is being retried */
896 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GFF_ID
,
897 cmdiocb
->retry
, did
);
900 lpfc_ct_free_iocb(phba
, cmdiocb
);
905 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
906 "0267 NameServer GFF Rsp "
907 "x%x Error (%d %d) Data: x%x x%x\n",
908 did
, irsp
->ulpStatus
, irsp
->un
.ulpWord
[4],
909 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
912 /* This is a target port, unregistered port, or the GFF_ID failed */
913 ndlp
= lpfc_setup_disc_node(vport
, did
);
914 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
915 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
916 "0242 Process x%x GFF "
917 "NameServer Rsp Data: x%x x%x x%x\n",
918 did
, ndlp
->nlp_flag
, vport
->fc_flag
,
919 vport
->fc_rscn_id_cnt
);
921 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
923 "NameServer Rsp Data: x%x x%x\n", did
,
924 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
927 /* Link up / RSCN discovery */
928 if (vport
->num_disc_nodes
)
929 vport
->num_disc_nodes
--;
930 if (vport
->num_disc_nodes
== 0) {
932 * The driver has cycled through all Nports in the RSCN payload.
933 * Complete the handling by cleaning up and marking the
934 * current driver state.
936 if (vport
->port_state
>= LPFC_DISC_AUTH
) {
937 if (vport
->fc_flag
& FC_RSCN_MODE
) {
938 lpfc_els_flush_rscn(vport
);
939 spin_lock_irq(shost
->host_lock
);
940 vport
->fc_flag
|= FC_RSCN_MODE
; /* RSCN still */
941 spin_unlock_irq(shost
->host_lock
);
944 lpfc_els_flush_rscn(vport
);
946 lpfc_disc_start(vport
);
948 lpfc_ct_free_iocb(phba
, cmdiocb
);
953 lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
954 struct lpfc_iocbq
*rspiocb
)
956 struct lpfc_vport
*vport
= cmdiocb
->vport
;
957 IOCB_t
*irsp
= &rspiocb
->iocb
;
958 struct lpfc_dmabuf
*inp
= (struct lpfc_dmabuf
*)cmdiocb
->context1
;
959 struct lpfc_dmabuf
*outp
= (struct lpfc_dmabuf
*)cmdiocb
->context2
;
960 struct lpfc_sli_ct_request
*CTrsp
;
962 struct lpfc_nodelist
*ndlp
;
963 uint32_t fc4_data_0
, fc4_data_1
;
965 did
= ((struct lpfc_sli_ct_request
*)inp
->virt
)->un
.gft
.PortId
;
966 did
= be32_to_cpu(did
);
968 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
969 "GFT_ID cmpl: status:x%x/x%x did:x%x",
970 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], did
);
972 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
973 /* Good status, continue checking */
974 CTrsp
= (struct lpfc_sli_ct_request
*)outp
->virt
;
975 fc4_data_0
= be32_to_cpu(CTrsp
->un
.gft_acc
.fc4_types
[0]);
976 fc4_data_1
= be32_to_cpu(CTrsp
->un
.gft_acc
.fc4_types
[1]);
977 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
978 "3062 DID x%06x GFT Wd0 x%08x Wd1 x%08x\n",
979 did
, fc4_data_0
, fc4_data_1
);
981 ndlp
= lpfc_findnode_did(vport
, did
);
983 /* The bitmask value for FCP and NVME FCP types is
984 * the same because they are 32 bits distant from
985 * each other in word0 and word0.
987 if (fc4_data_0
& LPFC_FC4_TYPE_BITMASK
)
988 ndlp
->nlp_fc4_type
|= NLP_FC4_FCP
;
989 if (fc4_data_1
& LPFC_FC4_TYPE_BITMASK
)
990 ndlp
->nlp_fc4_type
|= NLP_FC4_NVME
;
991 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
992 "3064 Setting ndlp %p, DID x%06x with "
993 "FC4 x%08x, Data: x%08x x%08x\n",
994 ndlp
, did
, ndlp
->nlp_fc4_type
,
995 FC_TYPE_FCP
, FC_TYPE_NVME
);
996 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
998 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PRLI_ISSUE
);
999 lpfc_issue_els_prli(vport
, ndlp
, 0);
1002 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1003 "3065 GFT_ID failed x%08x\n", irsp
->ulpStatus
);
1005 lpfc_ct_free_iocb(phba
, cmdiocb
);
1009 lpfc_cmpl_ct(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1010 struct lpfc_iocbq
*rspiocb
)
1012 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1013 struct lpfc_dmabuf
*inp
;
1014 struct lpfc_dmabuf
*outp
;
1016 struct lpfc_sli_ct_request
*CTrsp
;
1017 struct lpfc_nodelist
*ndlp
;
1022 /* First save ndlp, before we overwrite it */
1023 ndlp
= cmdiocb
->context_un
.ndlp
;
1025 /* we pass cmdiocb to state machine which needs rspiocb as well */
1026 cmdiocb
->context_un
.rsp_iocb
= rspiocb
;
1028 inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
1029 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1030 irsp
= &rspiocb
->iocb
;
1032 cmdcode
= be16_to_cpu(((struct lpfc_sli_ct_request
*) inp
->virt
)->
1033 CommandResponse
.bits
.CmdRsp
);
1034 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1036 latt
= lpfc_els_chk_latt(vport
);
1038 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
1039 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1040 "0209 CT Request completes, latt %d, "
1041 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
1042 latt
, irsp
->ulpStatus
,
1043 CTrsp
->CommandResponse
.bits
.CmdRsp
,
1044 cmdiocb
->iocb
.ulpContext
, cmdiocb
->iocb
.ulpIoTag
);
1046 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1047 "CT cmd cmpl: status:x%x/x%x cmd:x%x",
1048 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], cmdcode
);
1050 if (irsp
->ulpStatus
) {
1051 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1052 "0268 NS cmd x%x Error (x%x x%x)\n",
1053 cmdcode
, irsp
->ulpStatus
, irsp
->un
.ulpWord
[4]);
1055 if ((irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) &&
1056 (((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
1058 ((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
1059 IOERR_SLI_ABORTED
)))
1062 retry
= cmdiocb
->retry
;
1063 if (retry
>= LPFC_MAX_NS_RETRY
)
1067 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1068 "0250 Retrying NS cmd %x\n", cmdcode
);
1069 rc
= lpfc_ns_cmd(vport
, cmdcode
, retry
, 0);
1075 cmdiocb
->context_un
.ndlp
= ndlp
; /* Now restore ndlp for free */
1076 lpfc_ct_free_iocb(phba
, cmdiocb
);
1081 lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1082 struct lpfc_iocbq
*rspiocb
)
1084 IOCB_t
*irsp
= &rspiocb
->iocb
;
1085 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1087 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1088 struct lpfc_dmabuf
*outp
;
1089 struct lpfc_sli_ct_request
*CTrsp
;
1091 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1092 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1093 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1094 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1095 vport
->ct_flags
|= FC_CT_RFT_ID
;
1097 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1102 lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1103 struct lpfc_iocbq
*rspiocb
)
1105 IOCB_t
*irsp
= &rspiocb
->iocb
;
1106 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1108 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1109 struct lpfc_dmabuf
*outp
;
1110 struct lpfc_sli_ct_request
*CTrsp
;
1112 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1113 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1114 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1115 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1116 vport
->ct_flags
|= FC_CT_RNN_ID
;
1118 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1123 lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1124 struct lpfc_iocbq
*rspiocb
)
1126 IOCB_t
*irsp
= &rspiocb
->iocb
;
1127 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1129 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1130 struct lpfc_dmabuf
*outp
;
1131 struct lpfc_sli_ct_request
*CTrsp
;
1133 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1134 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1135 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1136 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1137 vport
->ct_flags
|= FC_CT_RSPN_ID
;
1139 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1144 lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1145 struct lpfc_iocbq
*rspiocb
)
1147 IOCB_t
*irsp
= &rspiocb
->iocb
;
1148 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1150 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1151 struct lpfc_dmabuf
*outp
;
1152 struct lpfc_sli_ct_request
*CTrsp
;
1154 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1155 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1156 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1157 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1158 vport
->ct_flags
|= FC_CT_RSNN_NN
;
1160 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1165 lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1166 struct lpfc_iocbq
*rspiocb
)
1168 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1170 /* even if it fails we will act as though it succeeded. */
1171 vport
->ct_flags
= 0;
1172 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1177 lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1178 struct lpfc_iocbq
*rspiocb
)
1180 IOCB_t
*irsp
= &rspiocb
->iocb
;
1181 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1183 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1184 struct lpfc_dmabuf
*outp
;
1185 struct lpfc_sli_ct_request
*CTrsp
;
1187 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1188 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1189 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1190 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1191 vport
->ct_flags
|= FC_CT_RFF_ID
;
1193 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1198 * Although the symbolic port name is thought to be an integer
1199 * as of January 18, 2016, leave it as a string until more of
1200 * the record state becomes defined.
1203 lpfc_vport_symbolic_port_name(struct lpfc_vport
*vport
, char *symbol
,
1209 * Use the lpfc board number as the Symbolic Port
1210 * Name object. NPIV is not in play so this integer
1211 * value is sufficient and unique per FC-ID.
1213 n
= snprintf(symbol
, size
, "%d", vport
->phba
->brd_no
);
1219 lpfc_vport_symbolic_node_name(struct lpfc_vport
*vport
, char *symbol
,
1222 char fwrev
[FW_REV_STR_SIZE
];
1225 lpfc_decode_firmware_rev(vport
->phba
, fwrev
, 0);
1227 n
= snprintf(symbol
, size
, "Emulex %s", vport
->phba
->ModelName
);
1231 n
+= snprintf(symbol
+ n
, size
- n
, " FV%s", fwrev
);
1235 n
+= snprintf(symbol
+ n
, size
- n
, " DV%s.",
1236 lpfc_release_version
);
1240 n
+= snprintf(symbol
+ n
, size
- n
, " HN:%s.",
1241 init_utsname()->nodename
);
1245 /* Note :- OS name is "Linux" */
1246 n
+= snprintf(symbol
+ n
, size
- n
, " OS:%s\n",
1247 init_utsname()->sysname
);
1252 lpfc_find_map_node(struct lpfc_vport
*vport
)
1254 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
1255 struct Scsi_Host
*shost
;
1258 shost
= lpfc_shost_from_vport(vport
);
1259 spin_lock_irq(shost
->host_lock
);
1260 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
1261 if (ndlp
->nlp_type
& NLP_FABRIC
)
1263 if ((ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
) ||
1264 (ndlp
->nlp_state
== NLP_STE_UNMAPPED_NODE
))
1267 spin_unlock_irq(shost
->host_lock
);
1272 * This routine will return the FC4 Type associated with the CT
1276 lpfc_get_gidft_type(struct lpfc_vport
*vport
, struct lpfc_iocbq
*cmdiocb
)
1278 struct lpfc_sli_ct_request
*CtReq
;
1279 struct lpfc_dmabuf
*mp
;
1282 mp
= cmdiocb
->context1
;
1285 CtReq
= (struct lpfc_sli_ct_request
*)mp
->virt
;
1286 type
= (uint32_t)CtReq
->un
.gid
.Fc4Type
;
1287 if ((type
!= SLI_CTPT_FCP
) && (type
!= SLI_CTPT_NVME
))
1295 * Issue Cmd to NameServer
1300 lpfc_ns_cmd(struct lpfc_vport
*vport
, int cmdcode
,
1301 uint8_t retry
, uint32_t context
)
1303 struct lpfc_nodelist
* ndlp
;
1304 struct lpfc_hba
*phba
= vport
->phba
;
1305 struct lpfc_dmabuf
*mp
, *bmp
;
1306 struct lpfc_sli_ct_request
*CtReq
;
1307 struct ulp_bde64
*bpl
;
1308 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
1309 struct lpfc_iocbq
*) = NULL
;
1310 uint32_t rsp_size
= 1024;
1314 ndlp
= lpfc_findnode_did(vport
, NameServer_DID
);
1315 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
)
1316 || ndlp
->nlp_state
!= NLP_STE_UNMAPPED_NODE
) {
1321 /* fill in BDEs for command */
1322 /* Allocate buffer for command payload */
1323 mp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
1329 INIT_LIST_HEAD(&mp
->list
);
1330 mp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(mp
->phys
));
1333 goto ns_cmd_free_mp
;
1336 /* Allocate buffer for Buffer ptr list */
1337 bmp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
1340 goto ns_cmd_free_mpvirt
;
1343 INIT_LIST_HEAD(&bmp
->list
);
1344 bmp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(bmp
->phys
));
1347 goto ns_cmd_free_bmp
;
1350 /* NameServer Req */
1351 lpfc_printf_vlog(vport
, KERN_INFO
,LOG_DISCOVERY
,
1352 "0236 NameServer Req Data: x%x x%x x%x x%x\n",
1353 cmdcode
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
,
1356 bpl
= (struct ulp_bde64
*) bmp
->virt
;
1357 memset(bpl
, 0, sizeof(struct ulp_bde64
));
1358 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
) );
1359 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
) );
1360 bpl
->tus
.f
.bdeFlags
= 0;
1361 if (cmdcode
== SLI_CTNS_GID_FT
)
1362 bpl
->tus
.f
.bdeSize
= GID_REQUEST_SZ
;
1363 else if (cmdcode
== SLI_CTNS_GFF_ID
)
1364 bpl
->tus
.f
.bdeSize
= GFF_REQUEST_SZ
;
1365 else if (cmdcode
== SLI_CTNS_GFT_ID
)
1366 bpl
->tus
.f
.bdeSize
= GFT_REQUEST_SZ
;
1367 else if (cmdcode
== SLI_CTNS_RFT_ID
)
1368 bpl
->tus
.f
.bdeSize
= RFT_REQUEST_SZ
;
1369 else if (cmdcode
== SLI_CTNS_RNN_ID
)
1370 bpl
->tus
.f
.bdeSize
= RNN_REQUEST_SZ
;
1371 else if (cmdcode
== SLI_CTNS_RSPN_ID
)
1372 bpl
->tus
.f
.bdeSize
= RSPN_REQUEST_SZ
;
1373 else if (cmdcode
== SLI_CTNS_RSNN_NN
)
1374 bpl
->tus
.f
.bdeSize
= RSNN_REQUEST_SZ
;
1375 else if (cmdcode
== SLI_CTNS_DA_ID
)
1376 bpl
->tus
.f
.bdeSize
= DA_ID_REQUEST_SZ
;
1377 else if (cmdcode
== SLI_CTNS_RFF_ID
)
1378 bpl
->tus
.f
.bdeSize
= RFF_REQUEST_SZ
;
1380 bpl
->tus
.f
.bdeSize
= 0;
1381 bpl
->tus
.w
= le32_to_cpu(bpl
->tus
.w
);
1383 CtReq
= (struct lpfc_sli_ct_request
*) mp
->virt
;
1384 memset(CtReq
, 0, sizeof(struct lpfc_sli_ct_request
));
1385 CtReq
->RevisionId
.bits
.Revision
= SLI_CT_REVISION
;
1386 CtReq
->RevisionId
.bits
.InId
= 0;
1387 CtReq
->FsType
= SLI_CT_DIRECTORY_SERVICE
;
1388 CtReq
->FsSubType
= SLI_CT_DIRECTORY_NAME_SERVER
;
1389 CtReq
->CommandResponse
.bits
.Size
= 0;
1391 case SLI_CTNS_GID_FT
:
1392 CtReq
->CommandResponse
.bits
.CmdRsp
=
1393 cpu_to_be16(SLI_CTNS_GID_FT
);
1394 CtReq
->un
.gid
.Fc4Type
= context
;
1396 if (vport
->port_state
< LPFC_NS_QRY
)
1397 vport
->port_state
= LPFC_NS_QRY
;
1398 lpfc_set_disctmo(vport
);
1399 cmpl
= lpfc_cmpl_ct_cmd_gid_ft
;
1400 rsp_size
= FC_MAX_NS_RSP
;
1403 case SLI_CTNS_GFF_ID
:
1404 CtReq
->CommandResponse
.bits
.CmdRsp
=
1405 cpu_to_be16(SLI_CTNS_GFF_ID
);
1406 CtReq
->un
.gff
.PortId
= cpu_to_be32(context
);
1407 cmpl
= lpfc_cmpl_ct_cmd_gff_id
;
1410 case SLI_CTNS_GFT_ID
:
1411 CtReq
->CommandResponse
.bits
.CmdRsp
=
1412 cpu_to_be16(SLI_CTNS_GFT_ID
);
1413 CtReq
->un
.gft
.PortId
= cpu_to_be32(context
);
1414 cmpl
= lpfc_cmpl_ct_cmd_gft_id
;
1417 case SLI_CTNS_RFT_ID
:
1418 vport
->ct_flags
&= ~FC_CT_RFT_ID
;
1419 CtReq
->CommandResponse
.bits
.CmdRsp
=
1420 cpu_to_be16(SLI_CTNS_RFT_ID
);
1421 CtReq
->un
.rft
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1423 /* Register FC4 FCP type if enabled. */
1424 if ((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1425 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
))
1426 CtReq
->un
.rft
.fcpReg
= 1;
1428 /* Register NVME type if enabled. Defined LE and swapped.
1429 * rsvd[0] is used as word1 because of the hard-coded
1430 * word0 usage in the ct_request data structure.
1432 if ((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1433 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
))
1434 CtReq
->un
.rft
.rsvd
[0] = cpu_to_be32(0x00000100);
1436 cmpl
= lpfc_cmpl_ct_cmd_rft_id
;
1439 case SLI_CTNS_RNN_ID
:
1440 vport
->ct_flags
&= ~FC_CT_RNN_ID
;
1441 CtReq
->CommandResponse
.bits
.CmdRsp
=
1442 cpu_to_be16(SLI_CTNS_RNN_ID
);
1443 CtReq
->un
.rnn
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1444 memcpy(CtReq
->un
.rnn
.wwnn
, &vport
->fc_nodename
,
1445 sizeof(struct lpfc_name
));
1446 cmpl
= lpfc_cmpl_ct_cmd_rnn_id
;
1449 case SLI_CTNS_RSPN_ID
:
1450 vport
->ct_flags
&= ~FC_CT_RSPN_ID
;
1451 CtReq
->CommandResponse
.bits
.CmdRsp
=
1452 cpu_to_be16(SLI_CTNS_RSPN_ID
);
1453 CtReq
->un
.rspn
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1454 size
= sizeof(CtReq
->un
.rspn
.symbname
);
1455 CtReq
->un
.rspn
.len
=
1456 lpfc_vport_symbolic_port_name(vport
,
1457 CtReq
->un
.rspn
.symbname
, size
);
1458 cmpl
= lpfc_cmpl_ct_cmd_rspn_id
;
1460 case SLI_CTNS_RSNN_NN
:
1461 vport
->ct_flags
&= ~FC_CT_RSNN_NN
;
1462 CtReq
->CommandResponse
.bits
.CmdRsp
=
1463 cpu_to_be16(SLI_CTNS_RSNN_NN
);
1464 memcpy(CtReq
->un
.rsnn
.wwnn
, &vport
->fc_nodename
,
1465 sizeof(struct lpfc_name
));
1466 size
= sizeof(CtReq
->un
.rsnn
.symbname
);
1467 CtReq
->un
.rsnn
.len
=
1468 lpfc_vport_symbolic_node_name(vport
,
1469 CtReq
->un
.rsnn
.symbname
, size
);
1470 cmpl
= lpfc_cmpl_ct_cmd_rsnn_nn
;
1472 case SLI_CTNS_DA_ID
:
1473 /* Implement DA_ID Nameserver request */
1474 CtReq
->CommandResponse
.bits
.CmdRsp
=
1475 cpu_to_be16(SLI_CTNS_DA_ID
);
1476 CtReq
->un
.da_id
.port_id
= cpu_to_be32(vport
->fc_myDID
);
1477 cmpl
= lpfc_cmpl_ct_cmd_da_id
;
1479 case SLI_CTNS_RFF_ID
:
1480 vport
->ct_flags
&= ~FC_CT_RFF_ID
;
1481 CtReq
->CommandResponse
.bits
.CmdRsp
=
1482 cpu_to_be16(SLI_CTNS_RFF_ID
);
1483 CtReq
->un
.rff
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1484 CtReq
->un
.rff
.fbits
= FC4_FEATURE_INIT
;
1486 /* The driver always supports FC_TYPE_FCP. However, the
1487 * caller can specify NVME (type x28) as well. But only
1488 * these that FC4 type is supported.
1490 if (((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1491 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)) &&
1492 (context
== FC_TYPE_NVME
)) {
1493 if ((vport
== phba
->pport
) && phba
->nvmet_support
) {
1494 CtReq
->un
.rff
.fbits
= (FC4_FEATURE_TARGET
|
1495 FC4_FEATURE_NVME_DISC
);
1496 lpfc_nvmet_update_targetport(phba
);
1498 lpfc_nvme_update_localport(vport
);
1500 CtReq
->un
.rff
.type_code
= context
;
1502 } else if (((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1503 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
)) &&
1504 (context
== FC_TYPE_FCP
))
1505 CtReq
->un
.rff
.type_code
= context
;
1508 goto ns_cmd_free_bmpvirt
;
1510 cmpl
= lpfc_cmpl_ct_cmd_rff_id
;
1513 /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
1514 * to hold ndlp reference for the corresponding callback function.
1516 if (!lpfc_ct_cmd(vport
, mp
, bmp
, ndlp
, cmpl
, rsp_size
, retry
)) {
1517 /* On success, The cmpl function will free the buffers */
1518 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1519 "Issue CT cmd: cmd:x%x did:x%x",
1520 cmdcode
, ndlp
->nlp_DID
, 0);
1525 /* Decrement ndlp reference count to release ndlp reference held
1526 * for the failed command's callback function.
1530 ns_cmd_free_bmpvirt
:
1531 lpfc_mbuf_free(phba
, bmp
->virt
, bmp
->phys
);
1535 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1539 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1540 "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
1541 cmdcode
, rc
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
1546 * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion
1547 * @phba: Pointer to HBA context object.
1548 * @cmdiocb: Pointer to the command IOCBQ.
1549 * @rspiocb: Pointer to the response IOCBQ.
1551 * This function to handle the completion of a driver initiated FDMI
1552 * CT command issued during discovery.
1555 lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1556 struct lpfc_iocbq
*rspiocb
)
1558 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1559 struct lpfc_dmabuf
*inp
= cmdiocb
->context1
;
1560 struct lpfc_dmabuf
*outp
= cmdiocb
->context2
;
1561 struct lpfc_sli_ct_request
*CTcmd
= inp
->virt
;
1562 struct lpfc_sli_ct_request
*CTrsp
= outp
->virt
;
1563 uint16_t fdmi_cmd
= CTcmd
->CommandResponse
.bits
.CmdRsp
;
1564 uint16_t fdmi_rsp
= CTrsp
->CommandResponse
.bits
.CmdRsp
;
1565 IOCB_t
*irsp
= &rspiocb
->iocb
;
1566 struct lpfc_nodelist
*ndlp
;
1567 uint32_t latt
, cmd
, err
;
1569 latt
= lpfc_els_chk_latt(vport
);
1570 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1571 "FDMI cmpl: status:x%x/x%x latt:%d",
1572 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], latt
);
1574 if (latt
|| irsp
->ulpStatus
) {
1576 /* Look for a retryable error */
1577 if (irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) {
1578 switch ((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
)) {
1579 case IOERR_SLI_ABORTED
:
1580 case IOERR_ABORT_IN_PROGRESS
:
1581 case IOERR_SEQUENCE_TIMEOUT
:
1582 case IOERR_ILLEGAL_FRAME
:
1583 case IOERR_NO_RESOURCES
:
1584 case IOERR_ILLEGAL_COMMAND
:
1586 if (cmdiocb
->retry
>= LPFC_FDMI_MAX_RETRY
)
1589 /* Retry the same FDMI command */
1590 err
= lpfc_sli_issue_iocb(phba
, LPFC_ELS_RING
,
1592 if (err
== IOCB_ERROR
)
1600 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1601 "0229 FDMI cmd %04x failed, latt = %d "
1602 "ulpStatus: x%x, rid x%x\n",
1603 be16_to_cpu(fdmi_cmd
), latt
, irsp
->ulpStatus
,
1604 irsp
->un
.ulpWord
[4]);
1606 lpfc_ct_free_iocb(phba
, cmdiocb
);
1608 ndlp
= lpfc_findnode_did(vport
, FDMI_DID
);
1609 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
1612 /* Check for a CT LS_RJT response */
1613 cmd
= be16_to_cpu(fdmi_cmd
);
1614 if (fdmi_rsp
== cpu_to_be16(SLI_CT_RESPONSE_FS_RJT
)) {
1615 /* FDMI rsp failed */
1616 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1617 "0220 FDMI cmd failed FS_RJT Data: x%x", cmd
);
1619 /* Should we fallback to FDMI-2 / FDMI-1 ? */
1622 if (vport
->fdmi_hba_mask
== LPFC_FDMI2_HBA_ATTR
) {
1623 /* Fallback to FDMI-1 */
1624 vport
->fdmi_hba_mask
= LPFC_FDMI1_HBA_ATTR
;
1625 vport
->fdmi_port_mask
= LPFC_FDMI1_PORT_ATTR
;
1627 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DHBA
, 0);
1632 if (vport
->fdmi_port_mask
== LPFC_FDMI2_PORT_ATTR
) {
1633 /* Fallback to FDMI-1 */
1634 vport
->fdmi_port_mask
= LPFC_FDMI1_PORT_ATTR
;
1636 lpfc_fdmi_cmd(vport
, ndlp
, cmd
, 0);
1638 if (vport
->fdmi_port_mask
== LPFC_FDMI2_SMART_ATTR
) {
1639 vport
->fdmi_port_mask
= LPFC_FDMI2_PORT_ATTR
;
1640 /* Retry the same command */
1641 lpfc_fdmi_cmd(vport
, ndlp
, cmd
, 0);
1646 if (vport
->fdmi_port_mask
== LPFC_FDMI2_PORT_ATTR
) {
1647 /* Fallback to FDMI-1 */
1648 vport
->fdmi_hba_mask
= LPFC_FDMI1_HBA_ATTR
;
1649 vport
->fdmi_port_mask
= LPFC_FDMI1_PORT_ATTR
;
1651 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DHBA
, 0);
1653 if (vport
->fdmi_port_mask
== LPFC_FDMI2_SMART_ATTR
) {
1654 vport
->fdmi_port_mask
= LPFC_FDMI2_PORT_ATTR
;
1655 /* Retry the same command */
1656 lpfc_fdmi_cmd(vport
, ndlp
, cmd
, 0);
1663 * On success, need to cycle thru FDMI registration for discovery
1664 * DHBA -> DPRT -> RHBA -> RPA (physical port)
1665 * DPRT -> RPRT (vports)
1669 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPA
, 0);
1673 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DPRT
, 0);
1677 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1678 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RHBA
, 0);
1680 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPRT
, 0);
1688 * lpfc_fdmi_num_disc_check - Check how many mapped NPorts we are connected to
1689 * @vport: pointer to a host virtual N_Port data structure.
1691 * Called from hbeat timeout routine to check if the number of discovered
1692 * ports has changed. If so, re-register thar port Attribute.
1695 lpfc_fdmi_num_disc_check(struct lpfc_vport
*vport
)
1697 struct lpfc_hba
*phba
= vport
->phba
;
1698 struct lpfc_nodelist
*ndlp
;
1701 if (!lpfc_is_link_up(phba
))
1704 /* Must be connected to a Fabric */
1705 if (!(vport
->fc_flag
& FC_FABRIC
))
1708 if (!(vport
->fdmi_port_mask
& LPFC_FDMI_PORT_ATTR_num_disc
))
1711 cnt
= lpfc_find_map_node(vport
);
1712 if (cnt
== vport
->fdmi_num_disc
)
1715 ndlp
= lpfc_findnode_did(vport
, FDMI_DID
);
1716 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
1719 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
1720 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPA
,
1721 LPFC_FDMI_PORT_ATTR_num_disc
);
1723 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPRT
,
1724 LPFC_FDMI_PORT_ATTR_num_disc
);
1728 /* Routines for all individual HBA attributes */
1730 lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
)
1732 struct lpfc_fdmi_attr_entry
*ae
;
1735 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1736 memset(ae
, 0, sizeof(struct lpfc_name
));
1738 memcpy(&ae
->un
.AttrWWN
, &vport
->fc_sparam
.nodeName
,
1739 sizeof(struct lpfc_name
));
1740 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
1741 ad
->AttrLen
= cpu_to_be16(size
);
1742 ad
->AttrType
= cpu_to_be16(RHBA_NODENAME
);
1746 lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport
*vport
,
1747 struct lpfc_fdmi_attr_def
*ad
)
1749 struct lpfc_fdmi_attr_entry
*ae
;
1752 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1755 strncpy(ae
->un
.AttrString
,
1756 "Emulex Corporation",
1757 sizeof(ae
->un
.AttrString
));
1758 len
= strnlen(ae
->un
.AttrString
,
1759 sizeof(ae
->un
.AttrString
));
1760 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1761 size
= FOURBYTES
+ len
;
1762 ad
->AttrLen
= cpu_to_be16(size
);
1763 ad
->AttrType
= cpu_to_be16(RHBA_MANUFACTURER
);
1768 lpfc_fdmi_hba_attr_sn(struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
)
1770 struct lpfc_hba
*phba
= vport
->phba
;
1771 struct lpfc_fdmi_attr_entry
*ae
;
1774 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1777 strncpy(ae
->un
.AttrString
, phba
->SerialNumber
,
1778 sizeof(ae
->un
.AttrString
));
1779 len
= strnlen(ae
->un
.AttrString
,
1780 sizeof(ae
->un
.AttrString
));
1781 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1782 size
= FOURBYTES
+ len
;
1783 ad
->AttrLen
= cpu_to_be16(size
);
1784 ad
->AttrType
= cpu_to_be16(RHBA_SERIAL_NUMBER
);
1789 lpfc_fdmi_hba_attr_model(struct lpfc_vport
*vport
,
1790 struct lpfc_fdmi_attr_def
*ad
)
1792 struct lpfc_hba
*phba
= vport
->phba
;
1793 struct lpfc_fdmi_attr_entry
*ae
;
1796 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1799 strncpy(ae
->un
.AttrString
, phba
->ModelName
,
1800 sizeof(ae
->un
.AttrString
));
1801 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
1802 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1803 size
= FOURBYTES
+ len
;
1804 ad
->AttrLen
= cpu_to_be16(size
);
1805 ad
->AttrType
= cpu_to_be16(RHBA_MODEL
);
1810 lpfc_fdmi_hba_attr_description(struct lpfc_vport
*vport
,
1811 struct lpfc_fdmi_attr_def
*ad
)
1813 struct lpfc_hba
*phba
= vport
->phba
;
1814 struct lpfc_fdmi_attr_entry
*ae
;
1817 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1820 strncpy(ae
->un
.AttrString
, phba
->ModelDesc
,
1821 sizeof(ae
->un
.AttrString
));
1822 len
= strnlen(ae
->un
.AttrString
,
1823 sizeof(ae
->un
.AttrString
));
1824 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1825 size
= FOURBYTES
+ len
;
1826 ad
->AttrLen
= cpu_to_be16(size
);
1827 ad
->AttrType
= cpu_to_be16(RHBA_MODEL_DESCRIPTION
);
1832 lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport
*vport
,
1833 struct lpfc_fdmi_attr_def
*ad
)
1835 struct lpfc_hba
*phba
= vport
->phba
;
1836 lpfc_vpd_t
*vp
= &phba
->vpd
;
1837 struct lpfc_fdmi_attr_entry
*ae
;
1838 uint32_t i
, j
, incr
, size
;
1840 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1843 /* Convert JEDEC ID to ascii for hardware version */
1844 incr
= vp
->rev
.biuRev
;
1845 for (i
= 0; i
< 8; i
++) {
1848 ae
->un
.AttrString
[7 - i
] =
1849 (char)((uint8_t) 0x30 +
1852 ae
->un
.AttrString
[7 - i
] =
1853 (char)((uint8_t) 0x61 +
1854 (uint8_t) (j
- 10));
1857 size
= FOURBYTES
+ 8;
1858 ad
->AttrLen
= cpu_to_be16(size
);
1859 ad
->AttrType
= cpu_to_be16(RHBA_HARDWARE_VERSION
);
1864 lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport
*vport
,
1865 struct lpfc_fdmi_attr_def
*ad
)
1867 struct lpfc_fdmi_attr_entry
*ae
;
1870 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1873 strncpy(ae
->un
.AttrString
, lpfc_release_version
,
1874 sizeof(ae
->un
.AttrString
));
1875 len
= strnlen(ae
->un
.AttrString
,
1876 sizeof(ae
->un
.AttrString
));
1877 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1878 size
= FOURBYTES
+ len
;
1879 ad
->AttrLen
= cpu_to_be16(size
);
1880 ad
->AttrType
= cpu_to_be16(RHBA_DRIVER_VERSION
);
1885 lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport
*vport
,
1886 struct lpfc_fdmi_attr_def
*ad
)
1888 struct lpfc_hba
*phba
= vport
->phba
;
1889 struct lpfc_fdmi_attr_entry
*ae
;
1892 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1895 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1896 lpfc_decode_firmware_rev(phba
, ae
->un
.AttrString
, 1);
1898 strncpy(ae
->un
.AttrString
, phba
->OptionROMVersion
,
1899 sizeof(ae
->un
.AttrString
));
1900 len
= strnlen(ae
->un
.AttrString
,
1901 sizeof(ae
->un
.AttrString
));
1902 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1903 size
= FOURBYTES
+ len
;
1904 ad
->AttrLen
= cpu_to_be16(size
);
1905 ad
->AttrType
= cpu_to_be16(RHBA_OPTION_ROM_VERSION
);
1910 lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport
*vport
,
1911 struct lpfc_fdmi_attr_def
*ad
)
1913 struct lpfc_hba
*phba
= vport
->phba
;
1914 struct lpfc_fdmi_attr_entry
*ae
;
1917 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1920 lpfc_decode_firmware_rev(phba
, ae
->un
.AttrString
, 1);
1921 len
= strnlen(ae
->un
.AttrString
,
1922 sizeof(ae
->un
.AttrString
));
1923 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1924 size
= FOURBYTES
+ len
;
1925 ad
->AttrLen
= cpu_to_be16(size
);
1926 ad
->AttrType
= cpu_to_be16(RHBA_FIRMWARE_VERSION
);
1931 lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport
*vport
,
1932 struct lpfc_fdmi_attr_def
*ad
)
1934 struct lpfc_fdmi_attr_entry
*ae
;
1937 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1940 snprintf(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
), "%s %s %s",
1941 init_utsname()->sysname
,
1942 init_utsname()->release
,
1943 init_utsname()->version
);
1945 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
1946 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1947 size
= FOURBYTES
+ len
;
1948 ad
->AttrLen
= cpu_to_be16(size
);
1949 ad
->AttrType
= cpu_to_be16(RHBA_OS_NAME_VERSION
);
1954 lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport
*vport
,
1955 struct lpfc_fdmi_attr_def
*ad
)
1957 struct lpfc_fdmi_attr_entry
*ae
;
1960 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1962 ae
->un
.AttrInt
= cpu_to_be32(LPFC_MAX_CT_SIZE
);
1963 size
= FOURBYTES
+ sizeof(uint32_t);
1964 ad
->AttrLen
= cpu_to_be16(size
);
1965 ad
->AttrType
= cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN
);
1970 lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport
*vport
,
1971 struct lpfc_fdmi_attr_def
*ad
)
1973 struct lpfc_fdmi_attr_entry
*ae
;
1976 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1979 len
= lpfc_vport_symbolic_node_name(vport
,
1980 ae
->un
.AttrString
, 256);
1981 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1982 size
= FOURBYTES
+ len
;
1983 ad
->AttrLen
= cpu_to_be16(size
);
1984 ad
->AttrType
= cpu_to_be16(RHBA_SYM_NODENAME
);
1989 lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport
*vport
,
1990 struct lpfc_fdmi_attr_def
*ad
)
1992 struct lpfc_fdmi_attr_entry
*ae
;
1995 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1997 /* Nothing is defined for this currently */
1998 ae
->un
.AttrInt
= cpu_to_be32(0);
1999 size
= FOURBYTES
+ sizeof(uint32_t);
2000 ad
->AttrLen
= cpu_to_be16(size
);
2001 ad
->AttrType
= cpu_to_be16(RHBA_VENDOR_INFO
);
2006 lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport
*vport
,
2007 struct lpfc_fdmi_attr_def
*ad
)
2009 struct lpfc_fdmi_attr_entry
*ae
;
2012 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2014 /* Each driver instance corresponds to a single port */
2015 ae
->un
.AttrInt
= cpu_to_be32(1);
2016 size
= FOURBYTES
+ sizeof(uint32_t);
2017 ad
->AttrLen
= cpu_to_be16(size
);
2018 ad
->AttrType
= cpu_to_be16(RHBA_NUM_PORTS
);
2023 lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport
*vport
,
2024 struct lpfc_fdmi_attr_def
*ad
)
2026 struct lpfc_fdmi_attr_entry
*ae
;
2029 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2030 memset(ae
, 0, sizeof(struct lpfc_name
));
2032 memcpy(&ae
->un
.AttrWWN
, &vport
->fabric_nodename
,
2033 sizeof(struct lpfc_name
));
2034 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2035 ad
->AttrLen
= cpu_to_be16(size
);
2036 ad
->AttrType
= cpu_to_be16(RHBA_FABRIC_WWNN
);
2041 lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport
*vport
,
2042 struct lpfc_fdmi_attr_def
*ad
)
2044 struct lpfc_hba
*phba
= vport
->phba
;
2045 struct lpfc_fdmi_attr_entry
*ae
;
2048 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2051 lpfc_decode_firmware_rev(phba
, ae
->un
.AttrString
, 1);
2052 len
= strnlen(ae
->un
.AttrString
,
2053 sizeof(ae
->un
.AttrString
));
2054 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2055 size
= FOURBYTES
+ len
;
2056 ad
->AttrLen
= cpu_to_be16(size
);
2057 ad
->AttrType
= cpu_to_be16(RHBA_BIOS_VERSION
);
2062 lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport
*vport
,
2063 struct lpfc_fdmi_attr_def
*ad
)
2065 struct lpfc_fdmi_attr_entry
*ae
;
2068 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2070 /* Driver doesn't have access to this information */
2071 ae
->un
.AttrInt
= cpu_to_be32(0);
2072 size
= FOURBYTES
+ sizeof(uint32_t);
2073 ad
->AttrLen
= cpu_to_be16(size
);
2074 ad
->AttrType
= cpu_to_be16(RHBA_BIOS_STATE
);
2079 lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport
*vport
,
2080 struct lpfc_fdmi_attr_def
*ad
)
2082 struct lpfc_fdmi_attr_entry
*ae
;
2085 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2088 strncpy(ae
->un
.AttrString
, "EMULEX",
2089 sizeof(ae
->un
.AttrString
));
2090 len
= strnlen(ae
->un
.AttrString
,
2091 sizeof(ae
->un
.AttrString
));
2092 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2093 size
= FOURBYTES
+ len
;
2094 ad
->AttrLen
= cpu_to_be16(size
);
2095 ad
->AttrType
= cpu_to_be16(RHBA_VENDOR_ID
);
2099 /* Routines for all individual PORT attributes */
2101 lpfc_fdmi_port_attr_fc4type(struct lpfc_vport
*vport
,
2102 struct lpfc_fdmi_attr_def
*ad
)
2104 struct lpfc_fdmi_attr_entry
*ae
;
2107 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2110 ae
->un
.AttrTypes
[3] = 0x02; /* Type 1 - ELS */
2111 ae
->un
.AttrTypes
[2] = 0x01; /* Type 8 - FCP */
2112 ae
->un
.AttrTypes
[6] = 0x01; /* Type 40 - NVME */
2113 ae
->un
.AttrTypes
[7] = 0x01; /* Type 32 - CT */
2114 size
= FOURBYTES
+ 32;
2115 ad
->AttrLen
= cpu_to_be16(size
);
2116 ad
->AttrType
= cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES
);
2121 lpfc_fdmi_port_attr_support_speed(struct lpfc_vport
*vport
,
2122 struct lpfc_fdmi_attr_def
*ad
)
2124 struct lpfc_hba
*phba
= vport
->phba
;
2125 struct lpfc_fdmi_attr_entry
*ae
;
2128 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2131 if (!(phba
->hba_flag
& HBA_FCOE_MODE
)) {
2132 if (phba
->lmt
& LMT_64Gb
)
2133 ae
->un
.AttrInt
|= HBA_PORTSPEED_64GFC
;
2134 if (phba
->lmt
& LMT_32Gb
)
2135 ae
->un
.AttrInt
|= HBA_PORTSPEED_32GFC
;
2136 if (phba
->lmt
& LMT_16Gb
)
2137 ae
->un
.AttrInt
|= HBA_PORTSPEED_16GFC
;
2138 if (phba
->lmt
& LMT_10Gb
)
2139 ae
->un
.AttrInt
|= HBA_PORTSPEED_10GFC
;
2140 if (phba
->lmt
& LMT_8Gb
)
2141 ae
->un
.AttrInt
|= HBA_PORTSPEED_8GFC
;
2142 if (phba
->lmt
& LMT_4Gb
)
2143 ae
->un
.AttrInt
|= HBA_PORTSPEED_4GFC
;
2144 if (phba
->lmt
& LMT_2Gb
)
2145 ae
->un
.AttrInt
|= HBA_PORTSPEED_2GFC
;
2146 if (phba
->lmt
& LMT_1Gb
)
2147 ae
->un
.AttrInt
|= HBA_PORTSPEED_1GFC
;
2149 /* FCoE links support only one speed */
2150 switch (phba
->fc_linkspeed
) {
2151 case LPFC_ASYNC_LINK_SPEED_10GBPS
:
2152 ae
->un
.AttrInt
= HBA_PORTSPEED_10GE
;
2154 case LPFC_ASYNC_LINK_SPEED_25GBPS
:
2155 ae
->un
.AttrInt
= HBA_PORTSPEED_25GE
;
2157 case LPFC_ASYNC_LINK_SPEED_40GBPS
:
2158 ae
->un
.AttrInt
= HBA_PORTSPEED_40GE
;
2160 case LPFC_ASYNC_LINK_SPEED_100GBPS
:
2161 ae
->un
.AttrInt
= HBA_PORTSPEED_100GE
;
2165 ae
->un
.AttrInt
= cpu_to_be32(ae
->un
.AttrInt
);
2166 size
= FOURBYTES
+ sizeof(uint32_t);
2167 ad
->AttrLen
= cpu_to_be16(size
);
2168 ad
->AttrType
= cpu_to_be16(RPRT_SUPPORTED_SPEED
);
2173 lpfc_fdmi_port_attr_speed(struct lpfc_vport
*vport
,
2174 struct lpfc_fdmi_attr_def
*ad
)
2176 struct lpfc_hba
*phba
= vport
->phba
;
2177 struct lpfc_fdmi_attr_entry
*ae
;
2180 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2182 if (!(phba
->hba_flag
& HBA_FCOE_MODE
)) {
2183 switch (phba
->fc_linkspeed
) {
2184 case LPFC_LINK_SPEED_1GHZ
:
2185 ae
->un
.AttrInt
= HBA_PORTSPEED_1GFC
;
2187 case LPFC_LINK_SPEED_2GHZ
:
2188 ae
->un
.AttrInt
= HBA_PORTSPEED_2GFC
;
2190 case LPFC_LINK_SPEED_4GHZ
:
2191 ae
->un
.AttrInt
= HBA_PORTSPEED_4GFC
;
2193 case LPFC_LINK_SPEED_8GHZ
:
2194 ae
->un
.AttrInt
= HBA_PORTSPEED_8GFC
;
2196 case LPFC_LINK_SPEED_10GHZ
:
2197 ae
->un
.AttrInt
= HBA_PORTSPEED_10GFC
;
2199 case LPFC_LINK_SPEED_16GHZ
:
2200 ae
->un
.AttrInt
= HBA_PORTSPEED_16GFC
;
2202 case LPFC_LINK_SPEED_32GHZ
:
2203 ae
->un
.AttrInt
= HBA_PORTSPEED_32GFC
;
2205 case LPFC_LINK_SPEED_64GHZ
:
2206 ae
->un
.AttrInt
= HBA_PORTSPEED_64GFC
;
2209 ae
->un
.AttrInt
= HBA_PORTSPEED_UNKNOWN
;
2213 switch (phba
->fc_linkspeed
) {
2214 case LPFC_ASYNC_LINK_SPEED_10GBPS
:
2215 ae
->un
.AttrInt
= HBA_PORTSPEED_10GE
;
2217 case LPFC_ASYNC_LINK_SPEED_25GBPS
:
2218 ae
->un
.AttrInt
= HBA_PORTSPEED_25GE
;
2220 case LPFC_ASYNC_LINK_SPEED_40GBPS
:
2221 ae
->un
.AttrInt
= HBA_PORTSPEED_40GE
;
2223 case LPFC_ASYNC_LINK_SPEED_100GBPS
:
2224 ae
->un
.AttrInt
= HBA_PORTSPEED_100GE
;
2227 ae
->un
.AttrInt
= HBA_PORTSPEED_UNKNOWN
;
2232 ae
->un
.AttrInt
= cpu_to_be32(ae
->un
.AttrInt
);
2233 size
= FOURBYTES
+ sizeof(uint32_t);
2234 ad
->AttrLen
= cpu_to_be16(size
);
2235 ad
->AttrType
= cpu_to_be16(RPRT_PORT_SPEED
);
2240 lpfc_fdmi_port_attr_max_frame(struct lpfc_vport
*vport
,
2241 struct lpfc_fdmi_attr_def
*ad
)
2243 struct serv_parm
*hsp
;
2244 struct lpfc_fdmi_attr_entry
*ae
;
2247 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2249 hsp
= (struct serv_parm
*)&vport
->fc_sparam
;
2250 ae
->un
.AttrInt
= (((uint32_t) hsp
->cmn
.bbRcvSizeMsb
) << 8) |
2251 (uint32_t) hsp
->cmn
.bbRcvSizeLsb
;
2252 ae
->un
.AttrInt
= cpu_to_be32(ae
->un
.AttrInt
);
2253 size
= FOURBYTES
+ sizeof(uint32_t);
2254 ad
->AttrLen
= cpu_to_be16(size
);
2255 ad
->AttrType
= cpu_to_be16(RPRT_MAX_FRAME_SIZE
);
2260 lpfc_fdmi_port_attr_os_devname(struct lpfc_vport
*vport
,
2261 struct lpfc_fdmi_attr_def
*ad
)
2263 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2264 struct lpfc_fdmi_attr_entry
*ae
;
2267 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2270 snprintf(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
),
2271 "/sys/class/scsi_host/host%d", shost
->host_no
);
2272 len
= strnlen((char *)ae
->un
.AttrString
,
2273 sizeof(ae
->un
.AttrString
));
2274 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2275 size
= FOURBYTES
+ len
;
2276 ad
->AttrLen
= cpu_to_be16(size
);
2277 ad
->AttrType
= cpu_to_be16(RPRT_OS_DEVICE_NAME
);
2282 lpfc_fdmi_port_attr_host_name(struct lpfc_vport
*vport
,
2283 struct lpfc_fdmi_attr_def
*ad
)
2285 struct lpfc_fdmi_attr_entry
*ae
;
2288 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2291 snprintf(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
), "%s",
2292 init_utsname()->nodename
);
2294 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
2295 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2296 size
= FOURBYTES
+ len
;
2297 ad
->AttrLen
= cpu_to_be16(size
);
2298 ad
->AttrType
= cpu_to_be16(RPRT_HOST_NAME
);
2303 lpfc_fdmi_port_attr_wwnn(struct lpfc_vport
*vport
,
2304 struct lpfc_fdmi_attr_def
*ad
)
2306 struct lpfc_fdmi_attr_entry
*ae
;
2309 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2310 memset(ae
, 0, sizeof(struct lpfc_name
));
2312 memcpy(&ae
->un
.AttrWWN
, &vport
->fc_sparam
.nodeName
,
2313 sizeof(struct lpfc_name
));
2314 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2315 ad
->AttrLen
= cpu_to_be16(size
);
2316 ad
->AttrType
= cpu_to_be16(RPRT_NODENAME
);
2321 lpfc_fdmi_port_attr_wwpn(struct lpfc_vport
*vport
,
2322 struct lpfc_fdmi_attr_def
*ad
)
2324 struct lpfc_fdmi_attr_entry
*ae
;
2327 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2328 memset(ae
, 0, sizeof(struct lpfc_name
));
2330 memcpy(&ae
->un
.AttrWWN
, &vport
->fc_sparam
.portName
,
2331 sizeof(struct lpfc_name
));
2332 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2333 ad
->AttrLen
= cpu_to_be16(size
);
2334 ad
->AttrType
= cpu_to_be16(RPRT_PORTNAME
);
2339 lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport
*vport
,
2340 struct lpfc_fdmi_attr_def
*ad
)
2342 struct lpfc_fdmi_attr_entry
*ae
;
2345 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2348 len
= lpfc_vport_symbolic_port_name(vport
, ae
->un
.AttrString
, 256);
2349 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2350 size
= FOURBYTES
+ len
;
2351 ad
->AttrLen
= cpu_to_be16(size
);
2352 ad
->AttrType
= cpu_to_be16(RPRT_SYM_PORTNAME
);
2357 lpfc_fdmi_port_attr_port_type(struct lpfc_vport
*vport
,
2358 struct lpfc_fdmi_attr_def
*ad
)
2360 struct lpfc_hba
*phba
= vport
->phba
;
2361 struct lpfc_fdmi_attr_entry
*ae
;
2364 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2365 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
)
2366 ae
->un
.AttrInt
= cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT
);
2368 ae
->un
.AttrInt
= cpu_to_be32(LPFC_FDMI_PORTTYPE_NPORT
);
2369 size
= FOURBYTES
+ sizeof(uint32_t);
2370 ad
->AttrLen
= cpu_to_be16(size
);
2371 ad
->AttrType
= cpu_to_be16(RPRT_PORT_TYPE
);
2376 lpfc_fdmi_port_attr_class(struct lpfc_vport
*vport
,
2377 struct lpfc_fdmi_attr_def
*ad
)
2379 struct lpfc_fdmi_attr_entry
*ae
;
2382 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2383 ae
->un
.AttrInt
= cpu_to_be32(FC_COS_CLASS2
| FC_COS_CLASS3
);
2384 size
= FOURBYTES
+ sizeof(uint32_t);
2385 ad
->AttrLen
= cpu_to_be16(size
);
2386 ad
->AttrType
= cpu_to_be16(RPRT_SUPPORTED_CLASS
);
2391 lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport
*vport
,
2392 struct lpfc_fdmi_attr_def
*ad
)
2394 struct lpfc_fdmi_attr_entry
*ae
;
2397 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2398 memset(ae
, 0, sizeof(struct lpfc_name
));
2400 memcpy(&ae
->un
.AttrWWN
, &vport
->fabric_portname
,
2401 sizeof(struct lpfc_name
));
2402 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2403 ad
->AttrLen
= cpu_to_be16(size
);
2404 ad
->AttrType
= cpu_to_be16(RPRT_FABRICNAME
);
2409 lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport
*vport
,
2410 struct lpfc_fdmi_attr_def
*ad
)
2412 struct lpfc_fdmi_attr_entry
*ae
;
2415 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2418 ae
->un
.AttrTypes
[3] = 0x02; /* Type 1 - ELS */
2419 ae
->un
.AttrTypes
[2] = 0x01; /* Type 8 - FCP */
2420 ae
->un
.AttrTypes
[7] = 0x01; /* Type 32 - CT */
2421 size
= FOURBYTES
+ 32;
2422 ad
->AttrLen
= cpu_to_be16(size
);
2423 ad
->AttrType
= cpu_to_be16(RPRT_ACTIVE_FC4_TYPES
);
2428 lpfc_fdmi_port_attr_port_state(struct lpfc_vport
*vport
,
2429 struct lpfc_fdmi_attr_def
*ad
)
2431 struct lpfc_fdmi_attr_entry
*ae
;
2434 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2435 /* Link Up - operational */
2436 ae
->un
.AttrInt
= cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE
);
2437 size
= FOURBYTES
+ sizeof(uint32_t);
2438 ad
->AttrLen
= cpu_to_be16(size
);
2439 ad
->AttrType
= cpu_to_be16(RPRT_PORT_STATE
);
2444 lpfc_fdmi_port_attr_num_disc(struct lpfc_vport
*vport
,
2445 struct lpfc_fdmi_attr_def
*ad
)
2447 struct lpfc_fdmi_attr_entry
*ae
;
2450 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2451 vport
->fdmi_num_disc
= lpfc_find_map_node(vport
);
2452 ae
->un
.AttrInt
= cpu_to_be32(vport
->fdmi_num_disc
);
2453 size
= FOURBYTES
+ sizeof(uint32_t);
2454 ad
->AttrLen
= cpu_to_be16(size
);
2455 ad
->AttrType
= cpu_to_be16(RPRT_DISC_PORT
);
2460 lpfc_fdmi_port_attr_nportid(struct lpfc_vport
*vport
,
2461 struct lpfc_fdmi_attr_def
*ad
)
2463 struct lpfc_fdmi_attr_entry
*ae
;
2466 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2467 ae
->un
.AttrInt
= cpu_to_be32(vport
->fc_myDID
);
2468 size
= FOURBYTES
+ sizeof(uint32_t);
2469 ad
->AttrLen
= cpu_to_be16(size
);
2470 ad
->AttrType
= cpu_to_be16(RPRT_PORT_ID
);
2475 lpfc_fdmi_smart_attr_service(struct lpfc_vport
*vport
,
2476 struct lpfc_fdmi_attr_def
*ad
)
2478 struct lpfc_fdmi_attr_entry
*ae
;
2481 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2484 strncpy(ae
->un
.AttrString
, "Smart SAN Initiator",
2485 sizeof(ae
->un
.AttrString
));
2486 len
= strnlen(ae
->un
.AttrString
,
2487 sizeof(ae
->un
.AttrString
));
2488 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2489 size
= FOURBYTES
+ len
;
2490 ad
->AttrLen
= cpu_to_be16(size
);
2491 ad
->AttrType
= cpu_to_be16(RPRT_SMART_SERVICE
);
2496 lpfc_fdmi_smart_attr_guid(struct lpfc_vport
*vport
,
2497 struct lpfc_fdmi_attr_def
*ad
)
2499 struct lpfc_fdmi_attr_entry
*ae
;
2502 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2505 memcpy(&ae
->un
.AttrString
, &vport
->fc_sparam
.nodeName
,
2506 sizeof(struct lpfc_name
));
2507 memcpy((((uint8_t *)&ae
->un
.AttrString
) +
2508 sizeof(struct lpfc_name
)),
2509 &vport
->fc_sparam
.portName
, sizeof(struct lpfc_name
));
2510 size
= FOURBYTES
+ (2 * sizeof(struct lpfc_name
));
2511 ad
->AttrLen
= cpu_to_be16(size
);
2512 ad
->AttrType
= cpu_to_be16(RPRT_SMART_GUID
);
2517 lpfc_fdmi_smart_attr_version(struct lpfc_vport
*vport
,
2518 struct lpfc_fdmi_attr_def
*ad
)
2520 struct lpfc_fdmi_attr_entry
*ae
;
2523 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2526 strncpy(ae
->un
.AttrString
, "Smart SAN Version 2.0",
2527 sizeof(ae
->un
.AttrString
));
2528 len
= strnlen(ae
->un
.AttrString
,
2529 sizeof(ae
->un
.AttrString
));
2530 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2531 size
= FOURBYTES
+ len
;
2532 ad
->AttrLen
= cpu_to_be16(size
);
2533 ad
->AttrType
= cpu_to_be16(RPRT_SMART_VERSION
);
2538 lpfc_fdmi_smart_attr_model(struct lpfc_vport
*vport
,
2539 struct lpfc_fdmi_attr_def
*ad
)
2541 struct lpfc_hba
*phba
= vport
->phba
;
2542 struct lpfc_fdmi_attr_entry
*ae
;
2545 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2548 strncpy(ae
->un
.AttrString
, phba
->ModelName
,
2549 sizeof(ae
->un
.AttrString
));
2550 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
2551 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2552 size
= FOURBYTES
+ len
;
2553 ad
->AttrLen
= cpu_to_be16(size
);
2554 ad
->AttrType
= cpu_to_be16(RPRT_SMART_MODEL
);
2559 lpfc_fdmi_smart_attr_port_info(struct lpfc_vport
*vport
,
2560 struct lpfc_fdmi_attr_def
*ad
)
2562 struct lpfc_fdmi_attr_entry
*ae
;
2565 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2567 /* SRIOV (type 3) is not supported */
2569 ae
->un
.AttrInt
= cpu_to_be32(2); /* NPIV */
2571 ae
->un
.AttrInt
= cpu_to_be32(1); /* Physical */
2572 size
= FOURBYTES
+ sizeof(uint32_t);
2573 ad
->AttrLen
= cpu_to_be16(size
);
2574 ad
->AttrType
= cpu_to_be16(RPRT_SMART_PORT_INFO
);
2579 lpfc_fdmi_smart_attr_qos(struct lpfc_vport
*vport
,
2580 struct lpfc_fdmi_attr_def
*ad
)
2582 struct lpfc_fdmi_attr_entry
*ae
;
2585 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2586 ae
->un
.AttrInt
= cpu_to_be32(0);
2587 size
= FOURBYTES
+ sizeof(uint32_t);
2588 ad
->AttrLen
= cpu_to_be16(size
);
2589 ad
->AttrType
= cpu_to_be16(RPRT_SMART_QOS
);
2594 lpfc_fdmi_smart_attr_security(struct lpfc_vport
*vport
,
2595 struct lpfc_fdmi_attr_def
*ad
)
2597 struct lpfc_fdmi_attr_entry
*ae
;
2600 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2601 ae
->un
.AttrInt
= cpu_to_be32(1);
2602 size
= FOURBYTES
+ sizeof(uint32_t);
2603 ad
->AttrLen
= cpu_to_be16(size
);
2604 ad
->AttrType
= cpu_to_be16(RPRT_SMART_SECURITY
);
2608 /* RHBA attribute jump table */
2609 int (*lpfc_fdmi_hba_action
[])
2610 (struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
) = {
2611 /* Action routine Mask bit Attribute type */
2612 lpfc_fdmi_hba_attr_wwnn
, /* bit0 RHBA_NODENAME */
2613 lpfc_fdmi_hba_attr_manufacturer
, /* bit1 RHBA_MANUFACTURER */
2614 lpfc_fdmi_hba_attr_sn
, /* bit2 RHBA_SERIAL_NUMBER */
2615 lpfc_fdmi_hba_attr_model
, /* bit3 RHBA_MODEL */
2616 lpfc_fdmi_hba_attr_description
, /* bit4 RHBA_MODEL_DESCRIPTION */
2617 lpfc_fdmi_hba_attr_hdw_ver
, /* bit5 RHBA_HARDWARE_VERSION */
2618 lpfc_fdmi_hba_attr_drvr_ver
, /* bit6 RHBA_DRIVER_VERSION */
2619 lpfc_fdmi_hba_attr_rom_ver
, /* bit7 RHBA_OPTION_ROM_VERSION */
2620 lpfc_fdmi_hba_attr_fmw_ver
, /* bit8 RHBA_FIRMWARE_VERSION */
2621 lpfc_fdmi_hba_attr_os_ver
, /* bit9 RHBA_OS_NAME_VERSION */
2622 lpfc_fdmi_hba_attr_ct_len
, /* bit10 RHBA_MAX_CT_PAYLOAD_LEN */
2623 lpfc_fdmi_hba_attr_symbolic_name
, /* bit11 RHBA_SYM_NODENAME */
2624 lpfc_fdmi_hba_attr_vendor_info
, /* bit12 RHBA_VENDOR_INFO */
2625 lpfc_fdmi_hba_attr_num_ports
, /* bit13 RHBA_NUM_PORTS */
2626 lpfc_fdmi_hba_attr_fabric_wwnn
, /* bit14 RHBA_FABRIC_WWNN */
2627 lpfc_fdmi_hba_attr_bios_ver
, /* bit15 RHBA_BIOS_VERSION */
2628 lpfc_fdmi_hba_attr_bios_state
, /* bit16 RHBA_BIOS_STATE */
2629 lpfc_fdmi_hba_attr_vendor_id
, /* bit17 RHBA_VENDOR_ID */
2632 /* RPA / RPRT attribute jump table */
2633 int (*lpfc_fdmi_port_action
[])
2634 (struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
) = {
2635 /* Action routine Mask bit Attribute type */
2636 lpfc_fdmi_port_attr_fc4type
, /* bit0 RPRT_SUPPORT_FC4_TYPES */
2637 lpfc_fdmi_port_attr_support_speed
, /* bit1 RPRT_SUPPORTED_SPEED */
2638 lpfc_fdmi_port_attr_speed
, /* bit2 RPRT_PORT_SPEED */
2639 lpfc_fdmi_port_attr_max_frame
, /* bit3 RPRT_MAX_FRAME_SIZE */
2640 lpfc_fdmi_port_attr_os_devname
, /* bit4 RPRT_OS_DEVICE_NAME */
2641 lpfc_fdmi_port_attr_host_name
, /* bit5 RPRT_HOST_NAME */
2642 lpfc_fdmi_port_attr_wwnn
, /* bit6 RPRT_NODENAME */
2643 lpfc_fdmi_port_attr_wwpn
, /* bit7 RPRT_PORTNAME */
2644 lpfc_fdmi_port_attr_symbolic_name
, /* bit8 RPRT_SYM_PORTNAME */
2645 lpfc_fdmi_port_attr_port_type
, /* bit9 RPRT_PORT_TYPE */
2646 lpfc_fdmi_port_attr_class
, /* bit10 RPRT_SUPPORTED_CLASS */
2647 lpfc_fdmi_port_attr_fabric_wwpn
, /* bit11 RPRT_FABRICNAME */
2648 lpfc_fdmi_port_attr_active_fc4type
, /* bit12 RPRT_ACTIVE_FC4_TYPES */
2649 lpfc_fdmi_port_attr_port_state
, /* bit13 RPRT_PORT_STATE */
2650 lpfc_fdmi_port_attr_num_disc
, /* bit14 RPRT_DISC_PORT */
2651 lpfc_fdmi_port_attr_nportid
, /* bit15 RPRT_PORT_ID */
2652 lpfc_fdmi_smart_attr_service
, /* bit16 RPRT_SMART_SERVICE */
2653 lpfc_fdmi_smart_attr_guid
, /* bit17 RPRT_SMART_GUID */
2654 lpfc_fdmi_smart_attr_version
, /* bit18 RPRT_SMART_VERSION */
2655 lpfc_fdmi_smart_attr_model
, /* bit19 RPRT_SMART_MODEL */
2656 lpfc_fdmi_smart_attr_port_info
, /* bit20 RPRT_SMART_PORT_INFO */
2657 lpfc_fdmi_smart_attr_qos
, /* bit21 RPRT_SMART_QOS */
2658 lpfc_fdmi_smart_attr_security
, /* bit22 RPRT_SMART_SECURITY */
2662 * lpfc_fdmi_cmd - Build and send a FDMI cmd to the specified NPort
2663 * @vport: pointer to a host virtual N_Port data structure.
2664 * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID)
2665 * cmdcode: FDMI command to send
2666 * mask: Mask of HBA or PORT Attributes to send
2668 * Builds and sends a FDMI command using the CT subsystem.
2671 lpfc_fdmi_cmd(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2672 int cmdcode
, uint32_t new_mask
)
2674 struct lpfc_hba
*phba
= vport
->phba
;
2675 struct lpfc_dmabuf
*mp
, *bmp
;
2676 struct lpfc_sli_ct_request
*CtReq
;
2677 struct ulp_bde64
*bpl
;
2682 struct lpfc_fdmi_reg_hba
*rh
;
2683 struct lpfc_fdmi_port_entry
*pe
;
2684 struct lpfc_fdmi_reg_portattr
*pab
= NULL
;
2685 struct lpfc_fdmi_attr_block
*ab
= NULL
;
2686 int (*func
)(struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
);
2687 void (*cmpl
)(struct lpfc_hba
*, struct lpfc_iocbq
*,
2688 struct lpfc_iocbq
*);
2690 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
2693 cmpl
= lpfc_cmpl_ct_disc_fdmi
; /* called from discovery */
2695 /* fill in BDEs for command */
2696 /* Allocate buffer for command payload */
2697 mp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
2701 mp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(mp
->phys
));
2703 goto fdmi_cmd_free_mp
;
2705 /* Allocate buffer for Buffer ptr list */
2706 bmp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
2708 goto fdmi_cmd_free_mpvirt
;
2710 bmp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(bmp
->phys
));
2712 goto fdmi_cmd_free_bmp
;
2714 INIT_LIST_HEAD(&mp
->list
);
2715 INIT_LIST_HEAD(&bmp
->list
);
2718 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2719 "0218 FDMI Request Data: x%x x%x x%x\n",
2720 vport
->fc_flag
, vport
->port_state
, cmdcode
);
2721 CtReq
= (struct lpfc_sli_ct_request
*)mp
->virt
;
2723 /* First populate the CT_IU preamble */
2724 memset(CtReq
, 0, sizeof(struct lpfc_sli_ct_request
));
2725 CtReq
->RevisionId
.bits
.Revision
= SLI_CT_REVISION
;
2726 CtReq
->RevisionId
.bits
.InId
= 0;
2728 CtReq
->FsType
= SLI_CT_MANAGEMENT_SERVICE
;
2729 CtReq
->FsSubType
= SLI_CT_FDMI_Subtypes
;
2731 CtReq
->CommandResponse
.bits
.CmdRsp
= cpu_to_be16(cmdcode
);
2732 rsp_size
= LPFC_BPL_SIZE
;
2735 /* Next fill in the specific FDMI cmd information */
2739 rh
= (struct lpfc_fdmi_reg_hba
*)&CtReq
->un
.PortID
;
2740 /* HBA Identifier */
2741 memcpy(&rh
->hi
.PortName
, &phba
->pport
->fc_sparam
.portName
,
2742 sizeof(struct lpfc_name
));
2744 if (cmdcode
== SLI_MGMT_RHBA
) {
2745 /* Registered Port List */
2746 /* One entry (port) per adapter */
2747 rh
->rpl
.EntryCnt
= cpu_to_be32(1);
2748 memcpy(&rh
->rpl
.pe
, &phba
->pport
->fc_sparam
.portName
,
2749 sizeof(struct lpfc_name
));
2751 /* point to the HBA attribute block */
2752 size
= 2 * sizeof(struct lpfc_name
) +
2755 size
= sizeof(struct lpfc_name
);
2757 ab
= (struct lpfc_fdmi_attr_block
*)((uint8_t *)rh
+ size
);
2764 mask
= vport
->fdmi_hba_mask
;
2766 /* Mask will dictate what attributes to build in the request */
2769 func
= lpfc_fdmi_hba_action
[bit_pos
];
2771 (struct lpfc_fdmi_attr_def
*)
2772 ((uint8_t *)rh
+ size
));
2775 (LPFC_BPL_SIZE
- LPFC_CT_PREAMBLE
))
2782 ab
->EntryCnt
= cpu_to_be32(ab
->EntryCnt
);
2784 size
= GID_REQUEST_SZ
- 4 + size
;
2789 pab
= (struct lpfc_fdmi_reg_portattr
*)&CtReq
->un
.PortID
;
2790 if (cmdcode
== SLI_MGMT_RPRT
) {
2791 rh
= (struct lpfc_fdmi_reg_hba
*)pab
;
2792 /* HBA Identifier */
2793 memcpy(&rh
->hi
.PortName
,
2794 &phba
->pport
->fc_sparam
.portName
,
2795 sizeof(struct lpfc_name
));
2796 pab
= (struct lpfc_fdmi_reg_portattr
*)
2797 ((uint8_t *)pab
+ sizeof(struct lpfc_name
));
2800 memcpy((uint8_t *)&pab
->PortName
,
2801 (uint8_t *)&vport
->fc_sparam
.portName
,
2802 sizeof(struct lpfc_name
));
2803 size
+= sizeof(struct lpfc_name
) + FOURBYTES
;
2804 pab
->ab
.EntryCnt
= 0;
2809 mask
= vport
->fdmi_port_mask
;
2811 /* Mask will dictate what attributes to build in the request */
2814 func
= lpfc_fdmi_port_action
[bit_pos
];
2816 (struct lpfc_fdmi_attr_def
*)
2817 ((uint8_t *)pab
+ size
));
2820 (LPFC_BPL_SIZE
- LPFC_CT_PREAMBLE
))
2827 pab
->ab
.EntryCnt
= cpu_to_be32(pab
->ab
.EntryCnt
);
2829 if (cmdcode
== SLI_MGMT_RPRT
)
2830 size
+= sizeof(struct lpfc_name
);
2831 size
= GID_REQUEST_SZ
- 4 + size
;
2836 rsp_size
= FC_MAX_NS_RSP
;
2839 pe
= (struct lpfc_fdmi_port_entry
*)&CtReq
->un
.PortID
;
2840 memcpy((uint8_t *)&pe
->PortName
,
2841 (uint8_t *)&vport
->fc_sparam
.portName
,
2842 sizeof(struct lpfc_name
));
2843 size
= GID_REQUEST_SZ
- 4 + sizeof(struct lpfc_name
);
2848 rsp_size
= FC_MAX_NS_RSP
;
2851 pe
= (struct lpfc_fdmi_port_entry
*)&CtReq
->un
.PortID
;
2852 memcpy((uint8_t *)&pe
->PortName
,
2853 (uint8_t *)&vport
->fc_sparam
.portName
,
2854 sizeof(struct lpfc_name
));
2855 size
= GID_REQUEST_SZ
- 4 + sizeof(struct lpfc_name
);
2858 size
= GID_REQUEST_SZ
- 4;
2861 lpfc_printf_vlog(vport
, KERN_WARNING
, LOG_DISCOVERY
,
2862 "0298 FDMI cmdcode x%x not supported\n",
2864 goto fdmi_cmd_free_bmpvirt
;
2866 CtReq
->CommandResponse
.bits
.Size
= cpu_to_be16(rsp_size
);
2868 bpl
= (struct ulp_bde64
*)bmp
->virt
;
2869 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
));
2870 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
));
2871 bpl
->tus
.f
.bdeFlags
= 0;
2872 bpl
->tus
.f
.bdeSize
= size
;
2875 * The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
2876 * to hold ndlp reference for the corresponding callback function.
2878 if (!lpfc_ct_cmd(vport
, mp
, bmp
, ndlp
, cmpl
, rsp_size
, 0))
2882 * Decrement ndlp reference count to release ndlp reference held
2883 * for the failed command's callback function.
2887 fdmi_cmd_free_bmpvirt
:
2888 lpfc_mbuf_free(phba
, bmp
->virt
, bmp
->phys
);
2891 fdmi_cmd_free_mpvirt
:
2892 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
2896 /* Issue FDMI request failed */
2897 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2898 "0244 Issue FDMI request failed Data: x%x\n",
2904 * lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer.
2905 * @ptr - Context object of the timer.
2907 * This function set the WORKER_DELAYED_DISC_TMO flag and wake up
2908 * the worker thread.
2911 lpfc_delayed_disc_tmo(struct timer_list
*t
)
2913 struct lpfc_vport
*vport
= from_timer(vport
, t
, delayed_disc_tmo
);
2914 struct lpfc_hba
*phba
= vport
->phba
;
2915 uint32_t tmo_posted
;
2916 unsigned long iflag
;
2918 spin_lock_irqsave(&vport
->work_port_lock
, iflag
);
2919 tmo_posted
= vport
->work_port_events
& WORKER_DELAYED_DISC_TMO
;
2921 vport
->work_port_events
|= WORKER_DELAYED_DISC_TMO
;
2922 spin_unlock_irqrestore(&vport
->work_port_lock
, iflag
);
2925 lpfc_worker_wake_up(phba
);
2930 * lpfc_delayed_disc_timeout_handler - Function called by worker thread to
2931 * handle delayed discovery.
2932 * @vport: pointer to a host virtual N_Port data structure.
2934 * This function start nport discovery of the vport.
2937 lpfc_delayed_disc_timeout_handler(struct lpfc_vport
*vport
)
2939 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2941 spin_lock_irq(shost
->host_lock
);
2942 if (!(vport
->fc_flag
& FC_DISC_DELAYED
)) {
2943 spin_unlock_irq(shost
->host_lock
);
2946 vport
->fc_flag
&= ~FC_DISC_DELAYED
;
2947 spin_unlock_irq(shost
->host_lock
);
2949 lpfc_do_scr_ns_plogi(vport
->phba
, vport
);
2953 lpfc_decode_firmware_rev(struct lpfc_hba
*phba
, char *fwrevision
, int flag
)
2955 struct lpfc_sli
*psli
= &phba
->sli
;
2956 lpfc_vpd_t
*vp
= &phba
->vpd
;
2957 uint32_t b1
, b2
, b3
, b4
, i
, rev
;
2959 uint32_t *ptr
, str
[4];
2962 if (phba
->sli_rev
== LPFC_SLI_REV4
)
2963 snprintf(fwrevision
, FW_REV_STR_SIZE
, "%s", vp
->rev
.opFwName
);
2964 else if (vp
->rev
.rBit
) {
2965 if (psli
->sli_flag
& LPFC_SLI_ACTIVE
)
2966 rev
= vp
->rev
.sli2FwRev
;
2968 rev
= vp
->rev
.sli1FwRev
;
2970 b1
= (rev
& 0x0000f000) >> 12;
2971 b2
= (rev
& 0x00000f00) >> 8;
2972 b3
= (rev
& 0x000000c0) >> 6;
2973 b4
= (rev
& 0x00000030) >> 4;
2992 b4
= (rev
& 0x0000000f);
2994 if (psli
->sli_flag
& LPFC_SLI_ACTIVE
)
2995 fwname
= vp
->rev
.sli2FwName
;
2997 fwname
= vp
->rev
.sli1FwName
;
2999 for (i
= 0; i
< 16; i
++)
3000 if (fwname
[i
] == 0x20)
3003 ptr
= (uint32_t*)fwname
;
3005 for (i
= 0; i
< 3; i
++)
3006 str
[i
] = be32_to_cpu(*ptr
++);
3010 sprintf(fwrevision
, "%d.%d%d (%s)",
3011 b1
, b2
, b3
, (char *)str
);
3013 sprintf(fwrevision
, "%d.%d%d", b1
,
3017 sprintf(fwrevision
, "%d.%d%d%c%d (%s)",
3021 sprintf(fwrevision
, "%d.%d%d%c%d",
3025 rev
= vp
->rev
.smFwRev
;
3027 b1
= (rev
& 0xff000000) >> 24;
3028 b2
= (rev
& 0x00f00000) >> 20;
3029 b3
= (rev
& 0x000f0000) >> 16;
3030 c
= (rev
& 0x0000ff00) >> 8;
3031 b4
= (rev
& 0x000000ff);
3033 sprintf(fwrevision
, "%d.%d%d%c%d", b1
, b2
, b3
, c
, b4
);