1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017 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 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
))
511 ndlp
->nlp_fc4_type
= fc4_type
;
513 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
514 ndlp
->nlp_fc4_type
= fc4_type
;
516 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
517 lpfc_setup_disc_node(vport
, Did
);
519 else if (lpfc_ns_cmd(vport
, SLI_CTNS_GFF_ID
,
521 vport
->num_disc_nodes
++;
524 lpfc_setup_disc_node(vport
, Did
);
527 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
528 "Skip2 GID_FTrsp: did:x%x flg:x%x cnt:%d",
529 Did
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
531 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
532 "0245 Skip x%06x NameServer Rsp "
533 "Data: x%x x%x\n", Did
,
535 vport
->fc_rscn_id_cnt
);
541 lpfc_ns_rsp(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*mp
, uint8_t fc4_type
,
544 struct lpfc_hba
*phba
= vport
->phba
;
545 struct lpfc_sli_ct_request
*Response
=
546 (struct lpfc_sli_ct_request
*) mp
->virt
;
547 struct lpfc_nodelist
*ndlp
= NULL
;
548 struct lpfc_dmabuf
*mlast
, *next_mp
;
549 uint32_t *ctptr
= (uint32_t *) & Response
->un
.gid
.PortType
;
550 uint32_t Did
, CTentry
;
552 struct list_head head
;
554 lpfc_set_disctmo(vport
);
555 vport
->num_disc_nodes
= 0;
556 vport
->fc_ns_retry
= 0;
559 list_add_tail(&head
, &mp
->list
);
560 list_for_each_entry_safe(mp
, next_mp
, &head
, list
) {
563 Cnt
= Size
> FCELSSIZE
? FCELSSIZE
: Size
;
568 ctptr
= (uint32_t *) mlast
->virt
;
570 Cnt
-= 16; /* subtract length of CT header */
572 /* Loop through entire NameServer list of DIDs */
573 while (Cnt
>= sizeof(uint32_t)) {
574 /* Get next DID from NameServer List */
576 Did
= ((be32_to_cpu(CTentry
)) & Mask_DID
);
581 * Check for rscn processing or not
582 * To conserve rpi's, filter out addresses for other
583 * vports on the same physical HBAs.
585 if ((Did
!= vport
->fc_myDID
) &&
586 ((lpfc_find_vport_by_did(phba
, Did
) == NULL
) ||
587 vport
->cfg_peer_port_login
))
588 lpfc_prep_node_fc4type(vport
, Did
, fc4_type
);
590 if (CTentry
& (cpu_to_be32(SLI_CT_LAST_ENTRY
)))
593 Cnt
-= sizeof(uint32_t);
605 lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
606 struct lpfc_iocbq
*rspiocb
)
608 struct lpfc_vport
*vport
= cmdiocb
->vport
;
609 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
611 struct lpfc_dmabuf
*outp
;
612 struct lpfc_dmabuf
*inp
;
613 struct lpfc_sli_ct_request
*CTrsp
;
614 struct lpfc_sli_ct_request
*CTreq
;
615 struct lpfc_nodelist
*ndlp
;
618 /* First save ndlp, before we overwrite it */
619 ndlp
= cmdiocb
->context_un
.ndlp
;
621 /* we pass cmdiocb to state machine which needs rspiocb as well */
622 cmdiocb
->context_un
.rsp_iocb
= rspiocb
;
623 inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
624 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
625 irsp
= &rspiocb
->iocb
;
627 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
628 "GID_FT cmpl: status:x%x/x%x rtry:%d",
629 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], vport
->fc_ns_retry
);
631 /* Don't bother processing response if vport is being torn down. */
632 if (vport
->load_flag
& FC_UNLOADING
) {
633 if (vport
->fc_flag
& FC_RSCN_MODE
)
634 lpfc_els_flush_rscn(vport
);
638 if (lpfc_els_chk_latt(vport
)) {
639 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
640 "0216 Link event during NS query\n");
641 if (vport
->fc_flag
& FC_RSCN_MODE
)
642 lpfc_els_flush_rscn(vport
);
643 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
646 if (lpfc_error_lost_link(irsp
)) {
647 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
648 "0226 NS query failed due to link event\n");
649 if (vport
->fc_flag
& FC_RSCN_MODE
)
650 lpfc_els_flush_rscn(vport
);
653 if (irsp
->ulpStatus
) {
654 /* Check for retry */
655 if (vport
->fc_ns_retry
< LPFC_MAX_NS_RETRY
) {
656 if (irsp
->ulpStatus
!= IOSTAT_LOCAL_REJECT
||
657 (irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) !=
659 vport
->fc_ns_retry
++;
661 type
= lpfc_get_gidft_type(vport
, cmdiocb
);
665 /* CT command is being retried */
667 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GID_FT
,
668 vport
->fc_ns_retry
, type
);
672 if (vport
->fc_flag
& FC_RSCN_MODE
)
673 lpfc_els_flush_rscn(vport
);
674 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
675 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
676 "0257 GID_FT Query error: 0x%x 0x%x\n",
677 irsp
->ulpStatus
, vport
->fc_ns_retry
);
679 /* Good status, continue checking */
680 CTreq
= (struct lpfc_sli_ct_request
*) inp
->virt
;
681 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
682 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
683 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC
)) {
684 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
685 "0208 NameServer Rsp Data: x%x x%x\n",
687 CTreq
->un
.gid
.Fc4Type
);
691 CTreq
->un
.gid
.Fc4Type
,
692 (uint32_t) (irsp
->un
.genreq64
.bdl
.bdeSize
));
693 } else if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
694 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT
)) {
695 /* NameServer Rsp Error */
696 if ((CTrsp
->ReasonCode
== SLI_CT_UNABLE_TO_PERFORM_REQ
)
697 && (CTrsp
->Explanation
== SLI_CT_NO_FC4_TYPES
)) {
698 lpfc_printf_vlog(vport
, KERN_INFO
,
700 "0269 No NameServer Entries "
701 "Data: x%x x%x x%x x%x\n",
702 CTrsp
->CommandResponse
.bits
.CmdRsp
,
703 (uint32_t) CTrsp
->ReasonCode
,
704 (uint32_t) CTrsp
->Explanation
,
707 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
708 "GID_FT no entry cmd:x%x rsn:x%x exp:x%x",
709 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
710 (uint32_t) CTrsp
->ReasonCode
,
711 (uint32_t) CTrsp
->Explanation
);
713 lpfc_printf_vlog(vport
, KERN_INFO
,
715 "0240 NameServer Rsp Error "
716 "Data: x%x x%x x%x x%x\n",
717 CTrsp
->CommandResponse
.bits
.CmdRsp
,
718 (uint32_t) CTrsp
->ReasonCode
,
719 (uint32_t) CTrsp
->Explanation
,
722 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
723 "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x",
724 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
725 (uint32_t) CTrsp
->ReasonCode
,
726 (uint32_t) CTrsp
->Explanation
);
731 /* NameServer Rsp Error */
732 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
733 "0241 NameServer Rsp Error "
734 "Data: x%x x%x x%x x%x\n",
735 CTrsp
->CommandResponse
.bits
.CmdRsp
,
736 (uint32_t) CTrsp
->ReasonCode
,
737 (uint32_t) CTrsp
->Explanation
,
740 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
741 "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x",
742 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
743 (uint32_t) CTrsp
->ReasonCode
,
744 (uint32_t) CTrsp
->Explanation
);
748 /* Link up / RSCN discovery */
749 if ((vport
->num_disc_nodes
== 0) &&
750 (vport
->gidft_inp
== 0)) {
752 * The driver has cycled through all Nports in the RSCN payload.
753 * Complete the handling by cleaning up and marking the
754 * current driver state.
756 if (vport
->port_state
>= LPFC_DISC_AUTH
) {
757 if (vport
->fc_flag
& FC_RSCN_MODE
) {
758 lpfc_els_flush_rscn(vport
);
759 spin_lock_irq(shost
->host_lock
);
760 vport
->fc_flag
|= FC_RSCN_MODE
; /* RSCN still */
761 spin_unlock_irq(shost
->host_lock
);
764 lpfc_els_flush_rscn(vport
);
767 lpfc_disc_start(vport
);
770 cmdiocb
->context_un
.ndlp
= ndlp
; /* Now restore ndlp for free */
771 lpfc_ct_free_iocb(phba
, cmdiocb
);
776 lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
777 struct lpfc_iocbq
*rspiocb
)
779 struct lpfc_vport
*vport
= cmdiocb
->vport
;
780 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
781 IOCB_t
*irsp
= &rspiocb
->iocb
;
782 struct lpfc_dmabuf
*inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
783 struct lpfc_dmabuf
*outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
784 struct lpfc_sli_ct_request
*CTrsp
;
787 struct lpfc_nodelist
*ndlp
;
789 did
= ((struct lpfc_sli_ct_request
*) inp
->virt
)->un
.gff
.PortId
;
790 did
= be32_to_cpu(did
);
792 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
793 "GFF_ID cmpl: status:x%x/x%x did:x%x",
794 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], did
);
796 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
797 /* Good status, continue checking */
798 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
799 fbits
= CTrsp
->un
.gff_acc
.fbits
[FCP_TYPE_FEATURE_OFFSET
];
801 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
802 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
)) {
803 if ((fbits
& FC4_FEATURE_INIT
) &&
804 !(fbits
& FC4_FEATURE_TARGET
)) {
805 lpfc_printf_vlog(vport
, KERN_INFO
,
808 "NameServer Rsp Data: (init) "
809 "x%x x%x\n", did
, fbits
,
810 vport
->fc_rscn_id_cnt
);
816 /* Check for retry */
817 if (cmdiocb
->retry
< LPFC_MAX_NS_RETRY
) {
819 if (irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) {
820 switch ((irsp
->un
.ulpWord
[4] &
823 case IOERR_NO_RESOURCES
:
824 /* We don't increment the retry
825 * count for this case.
828 case IOERR_LINK_DOWN
:
829 case IOERR_SLI_ABORTED
:
841 /* CT command is being retried */
842 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GFF_ID
,
843 cmdiocb
->retry
, did
);
846 lpfc_ct_free_iocb(phba
, cmdiocb
);
851 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
852 "0267 NameServer GFF Rsp "
853 "x%x Error (%d %d) Data: x%x x%x\n",
854 did
, irsp
->ulpStatus
, irsp
->un
.ulpWord
[4],
855 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
858 /* This is a target port, unregistered port, or the GFF_ID failed */
859 ndlp
= lpfc_setup_disc_node(vport
, did
);
860 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
861 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
862 "0242 Process x%x GFF "
863 "NameServer Rsp Data: x%x x%x x%x\n",
864 did
, ndlp
->nlp_flag
, vport
->fc_flag
,
865 vport
->fc_rscn_id_cnt
);
867 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
869 "NameServer Rsp Data: x%x x%x\n", did
,
870 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
873 /* Link up / RSCN discovery */
874 if (vport
->num_disc_nodes
)
875 vport
->num_disc_nodes
--;
876 if (vport
->num_disc_nodes
== 0) {
878 * The driver has cycled through all Nports in the RSCN payload.
879 * Complete the handling by cleaning up and marking the
880 * current driver state.
882 if (vport
->port_state
>= LPFC_DISC_AUTH
) {
883 if (vport
->fc_flag
& FC_RSCN_MODE
) {
884 lpfc_els_flush_rscn(vport
);
885 spin_lock_irq(shost
->host_lock
);
886 vport
->fc_flag
|= FC_RSCN_MODE
; /* RSCN still */
887 spin_unlock_irq(shost
->host_lock
);
890 lpfc_els_flush_rscn(vport
);
892 lpfc_disc_start(vport
);
894 lpfc_ct_free_iocb(phba
, cmdiocb
);
899 lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
900 struct lpfc_iocbq
*rspiocb
)
902 struct lpfc_vport
*vport
= cmdiocb
->vport
;
903 IOCB_t
*irsp
= &rspiocb
->iocb
;
904 struct lpfc_dmabuf
*inp
= (struct lpfc_dmabuf
*)cmdiocb
->context1
;
905 struct lpfc_dmabuf
*outp
= (struct lpfc_dmabuf
*)cmdiocb
->context2
;
906 struct lpfc_sli_ct_request
*CTrsp
;
908 struct lpfc_nodelist
*ndlp
;
909 uint32_t fc4_data_0
, fc4_data_1
;
911 did
= ((struct lpfc_sli_ct_request
*)inp
->virt
)->un
.gft
.PortId
;
912 did
= be32_to_cpu(did
);
914 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
915 "GFT_ID cmpl: status:x%x/x%x did:x%x",
916 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], did
);
918 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
919 /* Good status, continue checking */
920 CTrsp
= (struct lpfc_sli_ct_request
*)outp
->virt
;
921 fc4_data_0
= be32_to_cpu(CTrsp
->un
.gft_acc
.fc4_types
[0]);
922 fc4_data_1
= be32_to_cpu(CTrsp
->un
.gft_acc
.fc4_types
[1]);
923 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
924 "3062 DID x%06x GFT Wd0 x%08x Wd1 x%08x\n",
925 did
, fc4_data_0
, fc4_data_1
);
927 ndlp
= lpfc_findnode_did(vport
, did
);
929 /* The bitmask value for FCP and NVME FCP types is
930 * the same because they are 32 bits distant from
931 * each other in word0 and word0.
933 if (fc4_data_0
& LPFC_FC4_TYPE_BITMASK
)
934 ndlp
->nlp_fc4_type
|= NLP_FC4_FCP
;
935 if (fc4_data_1
& LPFC_FC4_TYPE_BITMASK
)
936 ndlp
->nlp_fc4_type
|= NLP_FC4_NVME
;
937 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
938 "3064 Setting ndlp %p, DID x%06x with "
939 "FC4 x%08x, Data: x%08x x%08x\n",
940 ndlp
, did
, ndlp
->nlp_fc4_type
,
941 FC_TYPE_FCP
, FC_TYPE_NVME
);
943 ndlp
->nlp_prev_state
= NLP_STE_REG_LOGIN_ISSUE
;
944 lpfc_nlp_set_state(vport
, ndlp
, NLP_STE_PRLI_ISSUE
);
945 lpfc_issue_els_prli(vport
, ndlp
, 0);
947 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
948 "3065 GFT_ID failed x%08x\n", irsp
->ulpStatus
);
950 lpfc_ct_free_iocb(phba
, cmdiocb
);
954 lpfc_cmpl_ct(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
955 struct lpfc_iocbq
*rspiocb
)
957 struct lpfc_vport
*vport
= cmdiocb
->vport
;
958 struct lpfc_dmabuf
*inp
;
959 struct lpfc_dmabuf
*outp
;
961 struct lpfc_sli_ct_request
*CTrsp
;
962 struct lpfc_nodelist
*ndlp
;
967 /* First save ndlp, before we overwrite it */
968 ndlp
= cmdiocb
->context_un
.ndlp
;
970 /* we pass cmdiocb to state machine which needs rspiocb as well */
971 cmdiocb
->context_un
.rsp_iocb
= rspiocb
;
973 inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
974 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
975 irsp
= &rspiocb
->iocb
;
977 cmdcode
= be16_to_cpu(((struct lpfc_sli_ct_request
*) inp
->virt
)->
978 CommandResponse
.bits
.CmdRsp
);
979 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
981 latt
= lpfc_els_chk_latt(vport
);
983 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
984 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
985 "0209 CT Request completes, latt %d, "
986 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
987 latt
, irsp
->ulpStatus
,
988 CTrsp
->CommandResponse
.bits
.CmdRsp
,
989 cmdiocb
->iocb
.ulpContext
, cmdiocb
->iocb
.ulpIoTag
);
991 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
992 "CT cmd cmpl: status:x%x/x%x cmd:x%x",
993 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], cmdcode
);
995 if (irsp
->ulpStatus
) {
996 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
997 "0268 NS cmd x%x Error (x%x x%x)\n",
998 cmdcode
, irsp
->ulpStatus
, irsp
->un
.ulpWord
[4]);
1000 if ((irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) &&
1001 (((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
1003 ((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
1004 IOERR_SLI_ABORTED
)))
1007 retry
= cmdiocb
->retry
;
1008 if (retry
>= LPFC_MAX_NS_RETRY
)
1012 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1013 "0250 Retrying NS cmd %x\n", cmdcode
);
1014 rc
= lpfc_ns_cmd(vport
, cmdcode
, retry
, 0);
1020 cmdiocb
->context_un
.ndlp
= ndlp
; /* Now restore ndlp for free */
1021 lpfc_ct_free_iocb(phba
, cmdiocb
);
1026 lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1027 struct lpfc_iocbq
*rspiocb
)
1029 IOCB_t
*irsp
= &rspiocb
->iocb
;
1030 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1032 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1033 struct lpfc_dmabuf
*outp
;
1034 struct lpfc_sli_ct_request
*CTrsp
;
1036 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1037 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1038 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1039 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1040 vport
->ct_flags
|= FC_CT_RFT_ID
;
1042 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1047 lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1048 struct lpfc_iocbq
*rspiocb
)
1050 IOCB_t
*irsp
= &rspiocb
->iocb
;
1051 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1053 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1054 struct lpfc_dmabuf
*outp
;
1055 struct lpfc_sli_ct_request
*CTrsp
;
1057 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1058 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1059 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1060 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1061 vport
->ct_flags
|= FC_CT_RNN_ID
;
1063 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1068 lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1069 struct lpfc_iocbq
*rspiocb
)
1071 IOCB_t
*irsp
= &rspiocb
->iocb
;
1072 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1074 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1075 struct lpfc_dmabuf
*outp
;
1076 struct lpfc_sli_ct_request
*CTrsp
;
1078 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1079 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1080 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1081 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1082 vport
->ct_flags
|= FC_CT_RSPN_ID
;
1084 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1089 lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1090 struct lpfc_iocbq
*rspiocb
)
1092 IOCB_t
*irsp
= &rspiocb
->iocb
;
1093 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1095 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1096 struct lpfc_dmabuf
*outp
;
1097 struct lpfc_sli_ct_request
*CTrsp
;
1099 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1100 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1101 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1102 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1103 vport
->ct_flags
|= FC_CT_RSNN_NN
;
1105 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1110 lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1111 struct lpfc_iocbq
*rspiocb
)
1113 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1115 /* even if it fails we will act as though it succeeded. */
1116 vport
->ct_flags
= 0;
1117 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1122 lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1123 struct lpfc_iocbq
*rspiocb
)
1125 IOCB_t
*irsp
= &rspiocb
->iocb
;
1126 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1128 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1129 struct lpfc_dmabuf
*outp
;
1130 struct lpfc_sli_ct_request
*CTrsp
;
1132 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1133 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1134 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1135 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1136 vport
->ct_flags
|= FC_CT_RFF_ID
;
1138 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1143 * Although the symbolic port name is thought to be an integer
1144 * as of January 18, 2016, leave it as a string until more of
1145 * the record state becomes defined.
1148 lpfc_vport_symbolic_port_name(struct lpfc_vport
*vport
, char *symbol
,
1154 * Use the lpfc board number as the Symbolic Port
1155 * Name object. NPIV is not in play so this integer
1156 * value is sufficient and unique per FC-ID.
1158 n
= snprintf(symbol
, size
, "%d", vport
->phba
->brd_no
);
1164 lpfc_vport_symbolic_node_name(struct lpfc_vport
*vport
, char *symbol
,
1167 char fwrev
[FW_REV_STR_SIZE
];
1170 lpfc_decode_firmware_rev(vport
->phba
, fwrev
, 0);
1172 n
= snprintf(symbol
, size
, "Emulex %s", vport
->phba
->ModelName
);
1176 n
+= snprintf(symbol
+ n
, size
- n
, " FV%s", fwrev
);
1180 n
+= snprintf(symbol
+ n
, size
- n
, " DV%s.",
1181 lpfc_release_version
);
1185 n
+= snprintf(symbol
+ n
, size
- n
, " HN:%s.",
1186 init_utsname()->nodename
);
1190 /* Note :- OS name is "Linux" */
1191 n
+= snprintf(symbol
+ n
, size
- n
, " OS:%s\n",
1192 init_utsname()->sysname
);
1197 lpfc_find_map_node(struct lpfc_vport
*vport
)
1199 struct lpfc_nodelist
*ndlp
, *next_ndlp
;
1200 struct Scsi_Host
*shost
;
1203 shost
= lpfc_shost_from_vport(vport
);
1204 spin_lock_irq(shost
->host_lock
);
1205 list_for_each_entry_safe(ndlp
, next_ndlp
, &vport
->fc_nodes
, nlp_listp
) {
1206 if (ndlp
->nlp_type
& NLP_FABRIC
)
1208 if ((ndlp
->nlp_state
== NLP_STE_MAPPED_NODE
) ||
1209 (ndlp
->nlp_state
== NLP_STE_UNMAPPED_NODE
))
1212 spin_unlock_irq(shost
->host_lock
);
1217 * This routine will return the FC4 Type associated with the CT
1221 lpfc_get_gidft_type(struct lpfc_vport
*vport
, struct lpfc_iocbq
*cmdiocb
)
1223 struct lpfc_sli_ct_request
*CtReq
;
1224 struct lpfc_dmabuf
*mp
;
1227 mp
= cmdiocb
->context1
;
1230 CtReq
= (struct lpfc_sli_ct_request
*)mp
->virt
;
1231 type
= (uint32_t)CtReq
->un
.gid
.Fc4Type
;
1232 if ((type
!= SLI_CTPT_FCP
) && (type
!= SLI_CTPT_NVME
))
1240 * Issue Cmd to NameServer
1245 lpfc_ns_cmd(struct lpfc_vport
*vport
, int cmdcode
,
1246 uint8_t retry
, uint32_t context
)
1248 struct lpfc_nodelist
* ndlp
;
1249 struct lpfc_hba
*phba
= vport
->phba
;
1250 struct lpfc_dmabuf
*mp
, *bmp
;
1251 struct lpfc_sli_ct_request
*CtReq
;
1252 struct ulp_bde64
*bpl
;
1253 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
1254 struct lpfc_iocbq
*) = NULL
;
1255 uint32_t rsp_size
= 1024;
1259 ndlp
= lpfc_findnode_did(vport
, NameServer_DID
);
1260 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
)
1261 || ndlp
->nlp_state
!= NLP_STE_UNMAPPED_NODE
) {
1266 /* fill in BDEs for command */
1267 /* Allocate buffer for command payload */
1268 mp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
1274 INIT_LIST_HEAD(&mp
->list
);
1275 mp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(mp
->phys
));
1278 goto ns_cmd_free_mp
;
1281 /* Allocate buffer for Buffer ptr list */
1282 bmp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
1285 goto ns_cmd_free_mpvirt
;
1288 INIT_LIST_HEAD(&bmp
->list
);
1289 bmp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(bmp
->phys
));
1292 goto ns_cmd_free_bmp
;
1295 /* NameServer Req */
1296 lpfc_printf_vlog(vport
, KERN_INFO
,LOG_DISCOVERY
,
1297 "0236 NameServer Req Data: x%x x%x x%x x%x\n",
1298 cmdcode
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
,
1301 bpl
= (struct ulp_bde64
*) bmp
->virt
;
1302 memset(bpl
, 0, sizeof(struct ulp_bde64
));
1303 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
) );
1304 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
) );
1305 bpl
->tus
.f
.bdeFlags
= 0;
1306 if (cmdcode
== SLI_CTNS_GID_FT
)
1307 bpl
->tus
.f
.bdeSize
= GID_REQUEST_SZ
;
1308 else if (cmdcode
== SLI_CTNS_GFF_ID
)
1309 bpl
->tus
.f
.bdeSize
= GFF_REQUEST_SZ
;
1310 else if (cmdcode
== SLI_CTNS_GFT_ID
)
1311 bpl
->tus
.f
.bdeSize
= GFT_REQUEST_SZ
;
1312 else if (cmdcode
== SLI_CTNS_RFT_ID
)
1313 bpl
->tus
.f
.bdeSize
= RFT_REQUEST_SZ
;
1314 else if (cmdcode
== SLI_CTNS_RNN_ID
)
1315 bpl
->tus
.f
.bdeSize
= RNN_REQUEST_SZ
;
1316 else if (cmdcode
== SLI_CTNS_RSPN_ID
)
1317 bpl
->tus
.f
.bdeSize
= RSPN_REQUEST_SZ
;
1318 else if (cmdcode
== SLI_CTNS_RSNN_NN
)
1319 bpl
->tus
.f
.bdeSize
= RSNN_REQUEST_SZ
;
1320 else if (cmdcode
== SLI_CTNS_DA_ID
)
1321 bpl
->tus
.f
.bdeSize
= DA_ID_REQUEST_SZ
;
1322 else if (cmdcode
== SLI_CTNS_RFF_ID
)
1323 bpl
->tus
.f
.bdeSize
= RFF_REQUEST_SZ
;
1325 bpl
->tus
.f
.bdeSize
= 0;
1326 bpl
->tus
.w
= le32_to_cpu(bpl
->tus
.w
);
1328 CtReq
= (struct lpfc_sli_ct_request
*) mp
->virt
;
1329 memset(CtReq
, 0, sizeof(struct lpfc_sli_ct_request
));
1330 CtReq
->RevisionId
.bits
.Revision
= SLI_CT_REVISION
;
1331 CtReq
->RevisionId
.bits
.InId
= 0;
1332 CtReq
->FsType
= SLI_CT_DIRECTORY_SERVICE
;
1333 CtReq
->FsSubType
= SLI_CT_DIRECTORY_NAME_SERVER
;
1334 CtReq
->CommandResponse
.bits
.Size
= 0;
1336 case SLI_CTNS_GID_FT
:
1337 CtReq
->CommandResponse
.bits
.CmdRsp
=
1338 cpu_to_be16(SLI_CTNS_GID_FT
);
1339 CtReq
->un
.gid
.Fc4Type
= context
;
1341 if (vport
->port_state
< LPFC_NS_QRY
)
1342 vport
->port_state
= LPFC_NS_QRY
;
1343 lpfc_set_disctmo(vport
);
1344 cmpl
= lpfc_cmpl_ct_cmd_gid_ft
;
1345 rsp_size
= FC_MAX_NS_RSP
;
1348 case SLI_CTNS_GFF_ID
:
1349 CtReq
->CommandResponse
.bits
.CmdRsp
=
1350 cpu_to_be16(SLI_CTNS_GFF_ID
);
1351 CtReq
->un
.gff
.PortId
= cpu_to_be32(context
);
1352 cmpl
= lpfc_cmpl_ct_cmd_gff_id
;
1355 case SLI_CTNS_GFT_ID
:
1356 CtReq
->CommandResponse
.bits
.CmdRsp
=
1357 cpu_to_be16(SLI_CTNS_GFT_ID
);
1358 CtReq
->un
.gft
.PortId
= cpu_to_be32(context
);
1359 cmpl
= lpfc_cmpl_ct_cmd_gft_id
;
1362 case SLI_CTNS_RFT_ID
:
1363 vport
->ct_flags
&= ~FC_CT_RFT_ID
;
1364 CtReq
->CommandResponse
.bits
.CmdRsp
=
1365 cpu_to_be16(SLI_CTNS_RFT_ID
);
1366 CtReq
->un
.rft
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1368 /* Register FC4 FCP type if enabled. */
1369 if ((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1370 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
))
1371 CtReq
->un
.rft
.fcpReg
= 1;
1373 /* Register NVME type if enabled. Defined LE and swapped.
1374 * rsvd[0] is used as word1 because of the hard-coded
1375 * word0 usage in the ct_request data structure.
1377 if ((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1378 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
))
1379 CtReq
->un
.rft
.rsvd
[0] = cpu_to_be32(0x00000100);
1381 cmpl
= lpfc_cmpl_ct_cmd_rft_id
;
1384 case SLI_CTNS_RNN_ID
:
1385 vport
->ct_flags
&= ~FC_CT_RNN_ID
;
1386 CtReq
->CommandResponse
.bits
.CmdRsp
=
1387 cpu_to_be16(SLI_CTNS_RNN_ID
);
1388 CtReq
->un
.rnn
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1389 memcpy(CtReq
->un
.rnn
.wwnn
, &vport
->fc_nodename
,
1390 sizeof(struct lpfc_name
));
1391 cmpl
= lpfc_cmpl_ct_cmd_rnn_id
;
1394 case SLI_CTNS_RSPN_ID
:
1395 vport
->ct_flags
&= ~FC_CT_RSPN_ID
;
1396 CtReq
->CommandResponse
.bits
.CmdRsp
=
1397 cpu_to_be16(SLI_CTNS_RSPN_ID
);
1398 CtReq
->un
.rspn
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1399 size
= sizeof(CtReq
->un
.rspn
.symbname
);
1400 CtReq
->un
.rspn
.len
=
1401 lpfc_vport_symbolic_port_name(vport
,
1402 CtReq
->un
.rspn
.symbname
, size
);
1403 cmpl
= lpfc_cmpl_ct_cmd_rspn_id
;
1405 case SLI_CTNS_RSNN_NN
:
1406 vport
->ct_flags
&= ~FC_CT_RSNN_NN
;
1407 CtReq
->CommandResponse
.bits
.CmdRsp
=
1408 cpu_to_be16(SLI_CTNS_RSNN_NN
);
1409 memcpy(CtReq
->un
.rsnn
.wwnn
, &vport
->fc_nodename
,
1410 sizeof(struct lpfc_name
));
1411 size
= sizeof(CtReq
->un
.rsnn
.symbname
);
1412 CtReq
->un
.rsnn
.len
=
1413 lpfc_vport_symbolic_node_name(vport
,
1414 CtReq
->un
.rsnn
.symbname
, size
);
1415 cmpl
= lpfc_cmpl_ct_cmd_rsnn_nn
;
1417 case SLI_CTNS_DA_ID
:
1418 /* Implement DA_ID Nameserver request */
1419 CtReq
->CommandResponse
.bits
.CmdRsp
=
1420 cpu_to_be16(SLI_CTNS_DA_ID
);
1421 CtReq
->un
.da_id
.port_id
= cpu_to_be32(vport
->fc_myDID
);
1422 cmpl
= lpfc_cmpl_ct_cmd_da_id
;
1424 case SLI_CTNS_RFF_ID
:
1425 vport
->ct_flags
&= ~FC_CT_RFF_ID
;
1426 CtReq
->CommandResponse
.bits
.CmdRsp
=
1427 cpu_to_be16(SLI_CTNS_RFF_ID
);
1428 CtReq
->un
.rff
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1429 CtReq
->un
.rff
.fbits
= FC4_FEATURE_INIT
;
1431 /* The driver always supports FC_TYPE_FCP. However, the
1432 * caller can specify NVME (type x28) as well. But only
1433 * these that FC4 type is supported.
1435 if (((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1436 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_NVME
)) &&
1437 (context
== FC_TYPE_NVME
)) {
1438 if ((vport
== phba
->pport
) && phba
->nvmet_support
) {
1439 CtReq
->un
.rff
.fbits
= (FC4_FEATURE_TARGET
|
1440 FC4_FEATURE_NVME_DISC
);
1441 lpfc_nvmet_update_targetport(phba
);
1443 lpfc_nvme_update_localport(vport
);
1445 CtReq
->un
.rff
.type_code
= context
;
1447 } else if (((phba
->cfg_enable_fc4_type
== LPFC_ENABLE_BOTH
) ||
1448 (phba
->cfg_enable_fc4_type
== LPFC_ENABLE_FCP
)) &&
1449 (context
== FC_TYPE_FCP
))
1450 CtReq
->un
.rff
.type_code
= context
;
1453 goto ns_cmd_free_bmpvirt
;
1455 cmpl
= lpfc_cmpl_ct_cmd_rff_id
;
1458 /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
1459 * to hold ndlp reference for the corresponding callback function.
1461 if (!lpfc_ct_cmd(vport
, mp
, bmp
, ndlp
, cmpl
, rsp_size
, retry
)) {
1462 /* On success, The cmpl function will free the buffers */
1463 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1464 "Issue CT cmd: cmd:x%x did:x%x",
1465 cmdcode
, ndlp
->nlp_DID
, 0);
1470 /* Decrement ndlp reference count to release ndlp reference held
1471 * for the failed command's callback function.
1475 ns_cmd_free_bmpvirt
:
1476 lpfc_mbuf_free(phba
, bmp
->virt
, bmp
->phys
);
1480 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1484 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1485 "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
1486 cmdcode
, rc
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
1491 * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion
1492 * @phba: Pointer to HBA context object.
1493 * @cmdiocb: Pointer to the command IOCBQ.
1494 * @rspiocb: Pointer to the response IOCBQ.
1496 * This function to handle the completion of a driver initiated FDMI
1497 * CT command issued during discovery.
1500 lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1501 struct lpfc_iocbq
*rspiocb
)
1503 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1504 struct lpfc_dmabuf
*inp
= cmdiocb
->context1
;
1505 struct lpfc_dmabuf
*outp
= cmdiocb
->context2
;
1506 struct lpfc_sli_ct_request
*CTcmd
= inp
->virt
;
1507 struct lpfc_sli_ct_request
*CTrsp
= outp
->virt
;
1508 uint16_t fdmi_cmd
= CTcmd
->CommandResponse
.bits
.CmdRsp
;
1509 uint16_t fdmi_rsp
= CTrsp
->CommandResponse
.bits
.CmdRsp
;
1510 IOCB_t
*irsp
= &rspiocb
->iocb
;
1511 struct lpfc_nodelist
*ndlp
;
1512 uint32_t latt
, cmd
, err
;
1514 latt
= lpfc_els_chk_latt(vport
);
1515 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1516 "FDMI cmpl: status:x%x/x%x latt:%d",
1517 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], latt
);
1519 if (latt
|| irsp
->ulpStatus
) {
1521 /* Look for a retryable error */
1522 if (irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) {
1523 switch ((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
)) {
1524 case IOERR_SLI_ABORTED
:
1525 case IOERR_ABORT_IN_PROGRESS
:
1526 case IOERR_SEQUENCE_TIMEOUT
:
1527 case IOERR_ILLEGAL_FRAME
:
1528 case IOERR_NO_RESOURCES
:
1529 case IOERR_ILLEGAL_COMMAND
:
1531 if (cmdiocb
->retry
>= LPFC_FDMI_MAX_RETRY
)
1534 /* Retry the same FDMI command */
1535 err
= lpfc_sli_issue_iocb(phba
, LPFC_ELS_RING
,
1537 if (err
== IOCB_ERROR
)
1545 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1546 "0229 FDMI cmd %04x failed, latt = %d "
1547 "ulpStatus: x%x, rid x%x\n",
1548 be16_to_cpu(fdmi_cmd
), latt
, irsp
->ulpStatus
,
1549 irsp
->un
.ulpWord
[4]);
1551 lpfc_ct_free_iocb(phba
, cmdiocb
);
1553 ndlp
= lpfc_findnode_did(vport
, FDMI_DID
);
1554 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
1557 /* Check for a CT LS_RJT response */
1558 cmd
= be16_to_cpu(fdmi_cmd
);
1559 if (fdmi_rsp
== cpu_to_be16(SLI_CT_RESPONSE_FS_RJT
)) {
1560 /* FDMI rsp failed */
1561 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1562 "0220 FDMI cmd failed FS_RJT Data: x%x", cmd
);
1564 /* Should we fallback to FDMI-2 / FDMI-1 ? */
1567 if (vport
->fdmi_hba_mask
== LPFC_FDMI2_HBA_ATTR
) {
1568 /* Fallback to FDMI-1 */
1569 vport
->fdmi_hba_mask
= LPFC_FDMI1_HBA_ATTR
;
1570 vport
->fdmi_port_mask
= LPFC_FDMI1_PORT_ATTR
;
1572 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DHBA
, 0);
1577 if (vport
->fdmi_port_mask
== LPFC_FDMI2_PORT_ATTR
) {
1578 /* Fallback to FDMI-1 */
1579 vport
->fdmi_port_mask
= LPFC_FDMI1_PORT_ATTR
;
1581 lpfc_fdmi_cmd(vport
, ndlp
, cmd
, 0);
1583 if (vport
->fdmi_port_mask
== LPFC_FDMI2_SMART_ATTR
) {
1584 vport
->fdmi_port_mask
= LPFC_FDMI2_PORT_ATTR
;
1585 /* Retry the same command */
1586 lpfc_fdmi_cmd(vport
, ndlp
, cmd
, 0);
1591 if (vport
->fdmi_port_mask
== LPFC_FDMI2_PORT_ATTR
) {
1592 /* Fallback to FDMI-1 */
1593 vport
->fdmi_hba_mask
= LPFC_FDMI1_HBA_ATTR
;
1594 vport
->fdmi_port_mask
= LPFC_FDMI1_PORT_ATTR
;
1596 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DHBA
, 0);
1598 if (vport
->fdmi_port_mask
== LPFC_FDMI2_SMART_ATTR
) {
1599 vport
->fdmi_port_mask
= LPFC_FDMI2_PORT_ATTR
;
1600 /* Retry the same command */
1601 lpfc_fdmi_cmd(vport
, ndlp
, cmd
, 0);
1608 * On success, need to cycle thru FDMI registration for discovery
1609 * DHBA -> DPRT -> RHBA -> RPA (physical port)
1610 * DPRT -> RPRT (vports)
1614 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPA
, 0);
1618 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DPRT
, 0);
1622 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1623 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RHBA
, 0);
1625 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPRT
, 0);
1633 * lpfc_fdmi_num_disc_check - Check how many mapped NPorts we are connected to
1634 * @vport: pointer to a host virtual N_Port data structure.
1636 * Called from hbeat timeout routine to check if the number of discovered
1637 * ports has changed. If so, re-register thar port Attribute.
1640 lpfc_fdmi_num_disc_check(struct lpfc_vport
*vport
)
1642 struct lpfc_hba
*phba
= vport
->phba
;
1643 struct lpfc_nodelist
*ndlp
;
1646 if (!lpfc_is_link_up(phba
))
1649 /* Must be connected to a Fabric */
1650 if (!(vport
->fc_flag
& FC_FABRIC
))
1653 if (!(vport
->fdmi_port_mask
& LPFC_FDMI_PORT_ATTR_num_disc
))
1656 cnt
= lpfc_find_map_node(vport
);
1657 if (cnt
== vport
->fdmi_num_disc
)
1660 ndlp
= lpfc_findnode_did(vport
, FDMI_DID
);
1661 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
1664 if (vport
->port_type
== LPFC_PHYSICAL_PORT
) {
1665 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPA
,
1666 LPFC_FDMI_PORT_ATTR_num_disc
);
1668 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPRT
,
1669 LPFC_FDMI_PORT_ATTR_num_disc
);
1673 /* Routines for all individual HBA attributes */
1675 lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
)
1677 struct lpfc_fdmi_attr_entry
*ae
;
1680 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1681 memset(ae
, 0, sizeof(struct lpfc_name
));
1683 memcpy(&ae
->un
.AttrWWN
, &vport
->fc_sparam
.nodeName
,
1684 sizeof(struct lpfc_name
));
1685 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
1686 ad
->AttrLen
= cpu_to_be16(size
);
1687 ad
->AttrType
= cpu_to_be16(RHBA_NODENAME
);
1691 lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport
*vport
,
1692 struct lpfc_fdmi_attr_def
*ad
)
1694 struct lpfc_fdmi_attr_entry
*ae
;
1697 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1700 strncpy(ae
->un
.AttrString
,
1701 "Emulex Corporation",
1702 sizeof(ae
->un
.AttrString
));
1703 len
= strnlen(ae
->un
.AttrString
,
1704 sizeof(ae
->un
.AttrString
));
1705 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1706 size
= FOURBYTES
+ len
;
1707 ad
->AttrLen
= cpu_to_be16(size
);
1708 ad
->AttrType
= cpu_to_be16(RHBA_MANUFACTURER
);
1713 lpfc_fdmi_hba_attr_sn(struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
)
1715 struct lpfc_hba
*phba
= vport
->phba
;
1716 struct lpfc_fdmi_attr_entry
*ae
;
1719 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1722 strncpy(ae
->un
.AttrString
, phba
->SerialNumber
,
1723 sizeof(ae
->un
.AttrString
));
1724 len
= strnlen(ae
->un
.AttrString
,
1725 sizeof(ae
->un
.AttrString
));
1726 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1727 size
= FOURBYTES
+ len
;
1728 ad
->AttrLen
= cpu_to_be16(size
);
1729 ad
->AttrType
= cpu_to_be16(RHBA_SERIAL_NUMBER
);
1734 lpfc_fdmi_hba_attr_model(struct lpfc_vport
*vport
,
1735 struct lpfc_fdmi_attr_def
*ad
)
1737 struct lpfc_hba
*phba
= vport
->phba
;
1738 struct lpfc_fdmi_attr_entry
*ae
;
1741 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1744 strncpy(ae
->un
.AttrString
, phba
->ModelName
,
1745 sizeof(ae
->un
.AttrString
));
1746 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
1747 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1748 size
= FOURBYTES
+ len
;
1749 ad
->AttrLen
= cpu_to_be16(size
);
1750 ad
->AttrType
= cpu_to_be16(RHBA_MODEL
);
1755 lpfc_fdmi_hba_attr_description(struct lpfc_vport
*vport
,
1756 struct lpfc_fdmi_attr_def
*ad
)
1758 struct lpfc_hba
*phba
= vport
->phba
;
1759 struct lpfc_fdmi_attr_entry
*ae
;
1762 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1765 strncpy(ae
->un
.AttrString
, phba
->ModelDesc
,
1766 sizeof(ae
->un
.AttrString
));
1767 len
= strnlen(ae
->un
.AttrString
,
1768 sizeof(ae
->un
.AttrString
));
1769 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1770 size
= FOURBYTES
+ len
;
1771 ad
->AttrLen
= cpu_to_be16(size
);
1772 ad
->AttrType
= cpu_to_be16(RHBA_MODEL_DESCRIPTION
);
1777 lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport
*vport
,
1778 struct lpfc_fdmi_attr_def
*ad
)
1780 struct lpfc_hba
*phba
= vport
->phba
;
1781 lpfc_vpd_t
*vp
= &phba
->vpd
;
1782 struct lpfc_fdmi_attr_entry
*ae
;
1783 uint32_t i
, j
, incr
, size
;
1785 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1788 /* Convert JEDEC ID to ascii for hardware version */
1789 incr
= vp
->rev
.biuRev
;
1790 for (i
= 0; i
< 8; i
++) {
1793 ae
->un
.AttrString
[7 - i
] =
1794 (char)((uint8_t) 0x30 +
1797 ae
->un
.AttrString
[7 - i
] =
1798 (char)((uint8_t) 0x61 +
1799 (uint8_t) (j
- 10));
1802 size
= FOURBYTES
+ 8;
1803 ad
->AttrLen
= cpu_to_be16(size
);
1804 ad
->AttrType
= cpu_to_be16(RHBA_HARDWARE_VERSION
);
1809 lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport
*vport
,
1810 struct lpfc_fdmi_attr_def
*ad
)
1812 struct lpfc_fdmi_attr_entry
*ae
;
1815 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1818 strncpy(ae
->un
.AttrString
, lpfc_release_version
,
1819 sizeof(ae
->un
.AttrString
));
1820 len
= strnlen(ae
->un
.AttrString
,
1821 sizeof(ae
->un
.AttrString
));
1822 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1823 size
= FOURBYTES
+ len
;
1824 ad
->AttrLen
= cpu_to_be16(size
);
1825 ad
->AttrType
= cpu_to_be16(RHBA_DRIVER_VERSION
);
1830 lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport
*vport
,
1831 struct lpfc_fdmi_attr_def
*ad
)
1833 struct lpfc_hba
*phba
= vport
->phba
;
1834 struct lpfc_fdmi_attr_entry
*ae
;
1837 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1840 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1841 lpfc_decode_firmware_rev(phba
, ae
->un
.AttrString
, 1);
1843 strncpy(ae
->un
.AttrString
, phba
->OptionROMVersion
,
1844 sizeof(ae
->un
.AttrString
));
1845 len
= strnlen(ae
->un
.AttrString
,
1846 sizeof(ae
->un
.AttrString
));
1847 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1848 size
= FOURBYTES
+ len
;
1849 ad
->AttrLen
= cpu_to_be16(size
);
1850 ad
->AttrType
= cpu_to_be16(RHBA_OPTION_ROM_VERSION
);
1855 lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport
*vport
,
1856 struct lpfc_fdmi_attr_def
*ad
)
1858 struct lpfc_hba
*phba
= vport
->phba
;
1859 struct lpfc_fdmi_attr_entry
*ae
;
1862 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1865 lpfc_decode_firmware_rev(phba
, ae
->un
.AttrString
, 1);
1866 len
= strnlen(ae
->un
.AttrString
,
1867 sizeof(ae
->un
.AttrString
));
1868 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1869 size
= FOURBYTES
+ len
;
1870 ad
->AttrLen
= cpu_to_be16(size
);
1871 ad
->AttrType
= cpu_to_be16(RHBA_FIRMWARE_VERSION
);
1876 lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport
*vport
,
1877 struct lpfc_fdmi_attr_def
*ad
)
1879 struct lpfc_fdmi_attr_entry
*ae
;
1882 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1885 snprintf(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
), "%s %s %s",
1886 init_utsname()->sysname
,
1887 init_utsname()->release
,
1888 init_utsname()->version
);
1890 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
1891 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1892 size
= FOURBYTES
+ len
;
1893 ad
->AttrLen
= cpu_to_be16(size
);
1894 ad
->AttrType
= cpu_to_be16(RHBA_OS_NAME_VERSION
);
1899 lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport
*vport
,
1900 struct lpfc_fdmi_attr_def
*ad
)
1902 struct lpfc_fdmi_attr_entry
*ae
;
1905 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1907 ae
->un
.AttrInt
= cpu_to_be32(LPFC_MAX_CT_SIZE
);
1908 size
= FOURBYTES
+ sizeof(uint32_t);
1909 ad
->AttrLen
= cpu_to_be16(size
);
1910 ad
->AttrType
= cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN
);
1915 lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport
*vport
,
1916 struct lpfc_fdmi_attr_def
*ad
)
1918 struct lpfc_fdmi_attr_entry
*ae
;
1921 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1924 len
= lpfc_vport_symbolic_node_name(vport
,
1925 ae
->un
.AttrString
, 256);
1926 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1927 size
= FOURBYTES
+ len
;
1928 ad
->AttrLen
= cpu_to_be16(size
);
1929 ad
->AttrType
= cpu_to_be16(RHBA_SYM_NODENAME
);
1934 lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport
*vport
,
1935 struct lpfc_fdmi_attr_def
*ad
)
1937 struct lpfc_fdmi_attr_entry
*ae
;
1940 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1942 /* Nothing is defined for this currently */
1943 ae
->un
.AttrInt
= cpu_to_be32(0);
1944 size
= FOURBYTES
+ sizeof(uint32_t);
1945 ad
->AttrLen
= cpu_to_be16(size
);
1946 ad
->AttrType
= cpu_to_be16(RHBA_VENDOR_INFO
);
1951 lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport
*vport
,
1952 struct lpfc_fdmi_attr_def
*ad
)
1954 struct lpfc_fdmi_attr_entry
*ae
;
1957 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1959 /* Each driver instance corresponds to a single port */
1960 ae
->un
.AttrInt
= cpu_to_be32(1);
1961 size
= FOURBYTES
+ sizeof(uint32_t);
1962 ad
->AttrLen
= cpu_to_be16(size
);
1963 ad
->AttrType
= cpu_to_be16(RHBA_NUM_PORTS
);
1968 lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport
*vport
,
1969 struct lpfc_fdmi_attr_def
*ad
)
1971 struct lpfc_fdmi_attr_entry
*ae
;
1974 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1975 memset(ae
, 0, sizeof(struct lpfc_name
));
1977 memcpy(&ae
->un
.AttrWWN
, &vport
->fabric_nodename
,
1978 sizeof(struct lpfc_name
));
1979 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
1980 ad
->AttrLen
= cpu_to_be16(size
);
1981 ad
->AttrType
= cpu_to_be16(RHBA_FABRIC_WWNN
);
1986 lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport
*vport
,
1987 struct lpfc_fdmi_attr_def
*ad
)
1989 struct lpfc_hba
*phba
= vport
->phba
;
1990 struct lpfc_fdmi_attr_entry
*ae
;
1993 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
1996 lpfc_decode_firmware_rev(phba
, ae
->un
.AttrString
, 1);
1997 len
= strnlen(ae
->un
.AttrString
,
1998 sizeof(ae
->un
.AttrString
));
1999 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2000 size
= FOURBYTES
+ len
;
2001 ad
->AttrLen
= cpu_to_be16(size
);
2002 ad
->AttrType
= cpu_to_be16(RHBA_BIOS_VERSION
);
2007 lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport
*vport
,
2008 struct lpfc_fdmi_attr_def
*ad
)
2010 struct lpfc_fdmi_attr_entry
*ae
;
2013 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2015 /* Driver doesn't have access to this information */
2016 ae
->un
.AttrInt
= cpu_to_be32(0);
2017 size
= FOURBYTES
+ sizeof(uint32_t);
2018 ad
->AttrLen
= cpu_to_be16(size
);
2019 ad
->AttrType
= cpu_to_be16(RHBA_BIOS_STATE
);
2024 lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport
*vport
,
2025 struct lpfc_fdmi_attr_def
*ad
)
2027 struct lpfc_fdmi_attr_entry
*ae
;
2030 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2033 strncpy(ae
->un
.AttrString
, "EMULEX",
2034 sizeof(ae
->un
.AttrString
));
2035 len
= strnlen(ae
->un
.AttrString
,
2036 sizeof(ae
->un
.AttrString
));
2037 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2038 size
= FOURBYTES
+ len
;
2039 ad
->AttrLen
= cpu_to_be16(size
);
2040 ad
->AttrType
= cpu_to_be16(RHBA_VENDOR_ID
);
2044 /* Routines for all individual PORT attributes */
2046 lpfc_fdmi_port_attr_fc4type(struct lpfc_vport
*vport
,
2047 struct lpfc_fdmi_attr_def
*ad
)
2049 struct lpfc_fdmi_attr_entry
*ae
;
2052 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2055 ae
->un
.AttrTypes
[3] = 0x02; /* Type 1 - ELS */
2056 ae
->un
.AttrTypes
[2] = 0x01; /* Type 8 - FCP */
2057 ae
->un
.AttrTypes
[7] = 0x01; /* Type 32 - CT */
2058 size
= FOURBYTES
+ 32;
2059 ad
->AttrLen
= cpu_to_be16(size
);
2060 ad
->AttrType
= cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES
);
2065 lpfc_fdmi_port_attr_support_speed(struct lpfc_vport
*vport
,
2066 struct lpfc_fdmi_attr_def
*ad
)
2068 struct lpfc_hba
*phba
= vport
->phba
;
2069 struct lpfc_fdmi_attr_entry
*ae
;
2072 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2075 if (!(phba
->hba_flag
& HBA_FCOE_MODE
)) {
2076 if (phba
->lmt
& LMT_32Gb
)
2077 ae
->un
.AttrInt
|= HBA_PORTSPEED_32GFC
;
2078 if (phba
->lmt
& LMT_16Gb
)
2079 ae
->un
.AttrInt
|= HBA_PORTSPEED_16GFC
;
2080 if (phba
->lmt
& LMT_10Gb
)
2081 ae
->un
.AttrInt
|= HBA_PORTSPEED_10GFC
;
2082 if (phba
->lmt
& LMT_8Gb
)
2083 ae
->un
.AttrInt
|= HBA_PORTSPEED_8GFC
;
2084 if (phba
->lmt
& LMT_4Gb
)
2085 ae
->un
.AttrInt
|= HBA_PORTSPEED_4GFC
;
2086 if (phba
->lmt
& LMT_2Gb
)
2087 ae
->un
.AttrInt
|= HBA_PORTSPEED_2GFC
;
2088 if (phba
->lmt
& LMT_1Gb
)
2089 ae
->un
.AttrInt
|= HBA_PORTSPEED_1GFC
;
2091 /* FCoE links support only one speed */
2092 switch (phba
->fc_linkspeed
) {
2093 case LPFC_ASYNC_LINK_SPEED_10GBPS
:
2094 ae
->un
.AttrInt
= HBA_PORTSPEED_10GE
;
2096 case LPFC_ASYNC_LINK_SPEED_25GBPS
:
2097 ae
->un
.AttrInt
= HBA_PORTSPEED_25GE
;
2099 case LPFC_ASYNC_LINK_SPEED_40GBPS
:
2100 ae
->un
.AttrInt
= HBA_PORTSPEED_40GE
;
2102 case LPFC_ASYNC_LINK_SPEED_100GBPS
:
2103 ae
->un
.AttrInt
= HBA_PORTSPEED_100GE
;
2107 ae
->un
.AttrInt
= cpu_to_be32(ae
->un
.AttrInt
);
2108 size
= FOURBYTES
+ sizeof(uint32_t);
2109 ad
->AttrLen
= cpu_to_be16(size
);
2110 ad
->AttrType
= cpu_to_be16(RPRT_SUPPORTED_SPEED
);
2115 lpfc_fdmi_port_attr_speed(struct lpfc_vport
*vport
,
2116 struct lpfc_fdmi_attr_def
*ad
)
2118 struct lpfc_hba
*phba
= vport
->phba
;
2119 struct lpfc_fdmi_attr_entry
*ae
;
2122 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2124 if (!(phba
->hba_flag
& HBA_FCOE_MODE
)) {
2125 switch (phba
->fc_linkspeed
) {
2126 case LPFC_LINK_SPEED_1GHZ
:
2127 ae
->un
.AttrInt
= HBA_PORTSPEED_1GFC
;
2129 case LPFC_LINK_SPEED_2GHZ
:
2130 ae
->un
.AttrInt
= HBA_PORTSPEED_2GFC
;
2132 case LPFC_LINK_SPEED_4GHZ
:
2133 ae
->un
.AttrInt
= HBA_PORTSPEED_4GFC
;
2135 case LPFC_LINK_SPEED_8GHZ
:
2136 ae
->un
.AttrInt
= HBA_PORTSPEED_8GFC
;
2138 case LPFC_LINK_SPEED_10GHZ
:
2139 ae
->un
.AttrInt
= HBA_PORTSPEED_10GFC
;
2141 case LPFC_LINK_SPEED_16GHZ
:
2142 ae
->un
.AttrInt
= HBA_PORTSPEED_16GFC
;
2144 case LPFC_LINK_SPEED_32GHZ
:
2145 ae
->un
.AttrInt
= HBA_PORTSPEED_32GFC
;
2148 ae
->un
.AttrInt
= HBA_PORTSPEED_UNKNOWN
;
2152 switch (phba
->fc_linkspeed
) {
2153 case LPFC_ASYNC_LINK_SPEED_10GBPS
:
2154 ae
->un
.AttrInt
= HBA_PORTSPEED_10GE
;
2156 case LPFC_ASYNC_LINK_SPEED_25GBPS
:
2157 ae
->un
.AttrInt
= HBA_PORTSPEED_25GE
;
2159 case LPFC_ASYNC_LINK_SPEED_40GBPS
:
2160 ae
->un
.AttrInt
= HBA_PORTSPEED_40GE
;
2162 case LPFC_ASYNC_LINK_SPEED_100GBPS
:
2163 ae
->un
.AttrInt
= HBA_PORTSPEED_100GE
;
2166 ae
->un
.AttrInt
= HBA_PORTSPEED_UNKNOWN
;
2171 ae
->un
.AttrInt
= cpu_to_be32(ae
->un
.AttrInt
);
2172 size
= FOURBYTES
+ sizeof(uint32_t);
2173 ad
->AttrLen
= cpu_to_be16(size
);
2174 ad
->AttrType
= cpu_to_be16(RPRT_PORT_SPEED
);
2179 lpfc_fdmi_port_attr_max_frame(struct lpfc_vport
*vport
,
2180 struct lpfc_fdmi_attr_def
*ad
)
2182 struct serv_parm
*hsp
;
2183 struct lpfc_fdmi_attr_entry
*ae
;
2186 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2188 hsp
= (struct serv_parm
*)&vport
->fc_sparam
;
2189 ae
->un
.AttrInt
= (((uint32_t) hsp
->cmn
.bbRcvSizeMsb
) << 8) |
2190 (uint32_t) hsp
->cmn
.bbRcvSizeLsb
;
2191 ae
->un
.AttrInt
= cpu_to_be32(ae
->un
.AttrInt
);
2192 size
= FOURBYTES
+ sizeof(uint32_t);
2193 ad
->AttrLen
= cpu_to_be16(size
);
2194 ad
->AttrType
= cpu_to_be16(RPRT_MAX_FRAME_SIZE
);
2199 lpfc_fdmi_port_attr_os_devname(struct lpfc_vport
*vport
,
2200 struct lpfc_fdmi_attr_def
*ad
)
2202 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2203 struct lpfc_fdmi_attr_entry
*ae
;
2206 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2209 snprintf(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
),
2210 "/sys/class/scsi_host/host%d", shost
->host_no
);
2211 len
= strnlen((char *)ae
->un
.AttrString
,
2212 sizeof(ae
->un
.AttrString
));
2213 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2214 size
= FOURBYTES
+ len
;
2215 ad
->AttrLen
= cpu_to_be16(size
);
2216 ad
->AttrType
= cpu_to_be16(RPRT_OS_DEVICE_NAME
);
2221 lpfc_fdmi_port_attr_host_name(struct lpfc_vport
*vport
,
2222 struct lpfc_fdmi_attr_def
*ad
)
2224 struct lpfc_fdmi_attr_entry
*ae
;
2227 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2230 snprintf(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
), "%s",
2231 init_utsname()->nodename
);
2233 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
2234 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2235 size
= FOURBYTES
+ len
;
2236 ad
->AttrLen
= cpu_to_be16(size
);
2237 ad
->AttrType
= cpu_to_be16(RPRT_HOST_NAME
);
2242 lpfc_fdmi_port_attr_wwnn(struct lpfc_vport
*vport
,
2243 struct lpfc_fdmi_attr_def
*ad
)
2245 struct lpfc_fdmi_attr_entry
*ae
;
2248 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2249 memset(ae
, 0, sizeof(struct lpfc_name
));
2251 memcpy(&ae
->un
.AttrWWN
, &vport
->fc_sparam
.nodeName
,
2252 sizeof(struct lpfc_name
));
2253 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2254 ad
->AttrLen
= cpu_to_be16(size
);
2255 ad
->AttrType
= cpu_to_be16(RPRT_NODENAME
);
2260 lpfc_fdmi_port_attr_wwpn(struct lpfc_vport
*vport
,
2261 struct lpfc_fdmi_attr_def
*ad
)
2263 struct lpfc_fdmi_attr_entry
*ae
;
2266 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2267 memset(ae
, 0, sizeof(struct lpfc_name
));
2269 memcpy(&ae
->un
.AttrWWN
, &vport
->fc_sparam
.portName
,
2270 sizeof(struct lpfc_name
));
2271 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2272 ad
->AttrLen
= cpu_to_be16(size
);
2273 ad
->AttrType
= cpu_to_be16(RPRT_PORTNAME
);
2278 lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport
*vport
,
2279 struct lpfc_fdmi_attr_def
*ad
)
2281 struct lpfc_fdmi_attr_entry
*ae
;
2284 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2287 len
= lpfc_vport_symbolic_port_name(vport
, ae
->un
.AttrString
, 256);
2288 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2289 size
= FOURBYTES
+ len
;
2290 ad
->AttrLen
= cpu_to_be16(size
);
2291 ad
->AttrType
= cpu_to_be16(RPRT_SYM_PORTNAME
);
2296 lpfc_fdmi_port_attr_port_type(struct lpfc_vport
*vport
,
2297 struct lpfc_fdmi_attr_def
*ad
)
2299 struct lpfc_hba
*phba
= vport
->phba
;
2300 struct lpfc_fdmi_attr_entry
*ae
;
2303 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2304 if (phba
->fc_topology
== LPFC_TOPOLOGY_LOOP
)
2305 ae
->un
.AttrInt
= cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT
);
2307 ae
->un
.AttrInt
= cpu_to_be32(LPFC_FDMI_PORTTYPE_NPORT
);
2308 size
= FOURBYTES
+ sizeof(uint32_t);
2309 ad
->AttrLen
= cpu_to_be16(size
);
2310 ad
->AttrType
= cpu_to_be16(RPRT_PORT_TYPE
);
2315 lpfc_fdmi_port_attr_class(struct lpfc_vport
*vport
,
2316 struct lpfc_fdmi_attr_def
*ad
)
2318 struct lpfc_fdmi_attr_entry
*ae
;
2321 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2322 ae
->un
.AttrInt
= cpu_to_be32(FC_COS_CLASS2
| FC_COS_CLASS3
);
2323 size
= FOURBYTES
+ sizeof(uint32_t);
2324 ad
->AttrLen
= cpu_to_be16(size
);
2325 ad
->AttrType
= cpu_to_be16(RPRT_SUPPORTED_CLASS
);
2330 lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport
*vport
,
2331 struct lpfc_fdmi_attr_def
*ad
)
2333 struct lpfc_fdmi_attr_entry
*ae
;
2336 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2337 memset(ae
, 0, sizeof(struct lpfc_name
));
2339 memcpy(&ae
->un
.AttrWWN
, &vport
->fabric_portname
,
2340 sizeof(struct lpfc_name
));
2341 size
= FOURBYTES
+ sizeof(struct lpfc_name
);
2342 ad
->AttrLen
= cpu_to_be16(size
);
2343 ad
->AttrType
= cpu_to_be16(RPRT_FABRICNAME
);
2348 lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport
*vport
,
2349 struct lpfc_fdmi_attr_def
*ad
)
2351 struct lpfc_fdmi_attr_entry
*ae
;
2354 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2357 ae
->un
.AttrTypes
[3] = 0x02; /* Type 1 - ELS */
2358 ae
->un
.AttrTypes
[2] = 0x01; /* Type 8 - FCP */
2359 ae
->un
.AttrTypes
[7] = 0x01; /* Type 32 - CT */
2360 size
= FOURBYTES
+ 32;
2361 ad
->AttrLen
= cpu_to_be16(size
);
2362 ad
->AttrType
= cpu_to_be16(RPRT_ACTIVE_FC4_TYPES
);
2367 lpfc_fdmi_port_attr_port_state(struct lpfc_vport
*vport
,
2368 struct lpfc_fdmi_attr_def
*ad
)
2370 struct lpfc_fdmi_attr_entry
*ae
;
2373 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2374 /* Link Up - operational */
2375 ae
->un
.AttrInt
= cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE
);
2376 size
= FOURBYTES
+ sizeof(uint32_t);
2377 ad
->AttrLen
= cpu_to_be16(size
);
2378 ad
->AttrType
= cpu_to_be16(RPRT_PORT_STATE
);
2383 lpfc_fdmi_port_attr_num_disc(struct lpfc_vport
*vport
,
2384 struct lpfc_fdmi_attr_def
*ad
)
2386 struct lpfc_fdmi_attr_entry
*ae
;
2389 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2390 vport
->fdmi_num_disc
= lpfc_find_map_node(vport
);
2391 ae
->un
.AttrInt
= cpu_to_be32(vport
->fdmi_num_disc
);
2392 size
= FOURBYTES
+ sizeof(uint32_t);
2393 ad
->AttrLen
= cpu_to_be16(size
);
2394 ad
->AttrType
= cpu_to_be16(RPRT_DISC_PORT
);
2399 lpfc_fdmi_port_attr_nportid(struct lpfc_vport
*vport
,
2400 struct lpfc_fdmi_attr_def
*ad
)
2402 struct lpfc_fdmi_attr_entry
*ae
;
2405 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2406 ae
->un
.AttrInt
= cpu_to_be32(vport
->fc_myDID
);
2407 size
= FOURBYTES
+ sizeof(uint32_t);
2408 ad
->AttrLen
= cpu_to_be16(size
);
2409 ad
->AttrType
= cpu_to_be16(RPRT_PORT_ID
);
2414 lpfc_fdmi_smart_attr_service(struct lpfc_vport
*vport
,
2415 struct lpfc_fdmi_attr_def
*ad
)
2417 struct lpfc_fdmi_attr_entry
*ae
;
2420 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2423 strncpy(ae
->un
.AttrString
, "Smart SAN Initiator",
2424 sizeof(ae
->un
.AttrString
));
2425 len
= strnlen(ae
->un
.AttrString
,
2426 sizeof(ae
->un
.AttrString
));
2427 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2428 size
= FOURBYTES
+ len
;
2429 ad
->AttrLen
= cpu_to_be16(size
);
2430 ad
->AttrType
= cpu_to_be16(RPRT_SMART_SERVICE
);
2435 lpfc_fdmi_smart_attr_guid(struct lpfc_vport
*vport
,
2436 struct lpfc_fdmi_attr_def
*ad
)
2438 struct lpfc_fdmi_attr_entry
*ae
;
2441 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2444 memcpy(&ae
->un
.AttrString
, &vport
->fc_sparam
.nodeName
,
2445 sizeof(struct lpfc_name
));
2446 memcpy((((uint8_t *)&ae
->un
.AttrString
) +
2447 sizeof(struct lpfc_name
)),
2448 &vport
->fc_sparam
.portName
, sizeof(struct lpfc_name
));
2449 size
= FOURBYTES
+ (2 * sizeof(struct lpfc_name
));
2450 ad
->AttrLen
= cpu_to_be16(size
);
2451 ad
->AttrType
= cpu_to_be16(RPRT_SMART_GUID
);
2456 lpfc_fdmi_smart_attr_version(struct lpfc_vport
*vport
,
2457 struct lpfc_fdmi_attr_def
*ad
)
2459 struct lpfc_fdmi_attr_entry
*ae
;
2462 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2465 strncpy(ae
->un
.AttrString
, "Smart SAN Version 2.0",
2466 sizeof(ae
->un
.AttrString
));
2467 len
= strnlen(ae
->un
.AttrString
,
2468 sizeof(ae
->un
.AttrString
));
2469 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2470 size
= FOURBYTES
+ len
;
2471 ad
->AttrLen
= cpu_to_be16(size
);
2472 ad
->AttrType
= cpu_to_be16(RPRT_SMART_VERSION
);
2477 lpfc_fdmi_smart_attr_model(struct lpfc_vport
*vport
,
2478 struct lpfc_fdmi_attr_def
*ad
)
2480 struct lpfc_hba
*phba
= vport
->phba
;
2481 struct lpfc_fdmi_attr_entry
*ae
;
2484 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2487 strncpy(ae
->un
.AttrString
, phba
->ModelName
,
2488 sizeof(ae
->un
.AttrString
));
2489 len
= strnlen(ae
->un
.AttrString
, sizeof(ae
->un
.AttrString
));
2490 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
2491 size
= FOURBYTES
+ len
;
2492 ad
->AttrLen
= cpu_to_be16(size
);
2493 ad
->AttrType
= cpu_to_be16(RPRT_SMART_MODEL
);
2498 lpfc_fdmi_smart_attr_port_info(struct lpfc_vport
*vport
,
2499 struct lpfc_fdmi_attr_def
*ad
)
2501 struct lpfc_fdmi_attr_entry
*ae
;
2504 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2506 /* SRIOV (type 3) is not supported */
2508 ae
->un
.AttrInt
= cpu_to_be32(2); /* NPIV */
2510 ae
->un
.AttrInt
= cpu_to_be32(1); /* Physical */
2511 size
= FOURBYTES
+ sizeof(uint32_t);
2512 ad
->AttrLen
= cpu_to_be16(size
);
2513 ad
->AttrType
= cpu_to_be16(RPRT_SMART_PORT_INFO
);
2518 lpfc_fdmi_smart_attr_qos(struct lpfc_vport
*vport
,
2519 struct lpfc_fdmi_attr_def
*ad
)
2521 struct lpfc_fdmi_attr_entry
*ae
;
2524 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2525 ae
->un
.AttrInt
= cpu_to_be32(0);
2526 size
= FOURBYTES
+ sizeof(uint32_t);
2527 ad
->AttrLen
= cpu_to_be16(size
);
2528 ad
->AttrType
= cpu_to_be16(RPRT_SMART_QOS
);
2533 lpfc_fdmi_smart_attr_security(struct lpfc_vport
*vport
,
2534 struct lpfc_fdmi_attr_def
*ad
)
2536 struct lpfc_fdmi_attr_entry
*ae
;
2539 ae
= (struct lpfc_fdmi_attr_entry
*)&ad
->AttrValue
;
2540 ae
->un
.AttrInt
= cpu_to_be32(1);
2541 size
= FOURBYTES
+ sizeof(uint32_t);
2542 ad
->AttrLen
= cpu_to_be16(size
);
2543 ad
->AttrType
= cpu_to_be16(RPRT_SMART_SECURITY
);
2547 /* RHBA attribute jump table */
2548 int (*lpfc_fdmi_hba_action
[])
2549 (struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
) = {
2550 /* Action routine Mask bit Attribute type */
2551 lpfc_fdmi_hba_attr_wwnn
, /* bit0 RHBA_NODENAME */
2552 lpfc_fdmi_hba_attr_manufacturer
, /* bit1 RHBA_MANUFACTURER */
2553 lpfc_fdmi_hba_attr_sn
, /* bit2 RHBA_SERIAL_NUMBER */
2554 lpfc_fdmi_hba_attr_model
, /* bit3 RHBA_MODEL */
2555 lpfc_fdmi_hba_attr_description
, /* bit4 RHBA_MODEL_DESCRIPTION */
2556 lpfc_fdmi_hba_attr_hdw_ver
, /* bit5 RHBA_HARDWARE_VERSION */
2557 lpfc_fdmi_hba_attr_drvr_ver
, /* bit6 RHBA_DRIVER_VERSION */
2558 lpfc_fdmi_hba_attr_rom_ver
, /* bit7 RHBA_OPTION_ROM_VERSION */
2559 lpfc_fdmi_hba_attr_fmw_ver
, /* bit8 RHBA_FIRMWARE_VERSION */
2560 lpfc_fdmi_hba_attr_os_ver
, /* bit9 RHBA_OS_NAME_VERSION */
2561 lpfc_fdmi_hba_attr_ct_len
, /* bit10 RHBA_MAX_CT_PAYLOAD_LEN */
2562 lpfc_fdmi_hba_attr_symbolic_name
, /* bit11 RHBA_SYM_NODENAME */
2563 lpfc_fdmi_hba_attr_vendor_info
, /* bit12 RHBA_VENDOR_INFO */
2564 lpfc_fdmi_hba_attr_num_ports
, /* bit13 RHBA_NUM_PORTS */
2565 lpfc_fdmi_hba_attr_fabric_wwnn
, /* bit14 RHBA_FABRIC_WWNN */
2566 lpfc_fdmi_hba_attr_bios_ver
, /* bit15 RHBA_BIOS_VERSION */
2567 lpfc_fdmi_hba_attr_bios_state
, /* bit16 RHBA_BIOS_STATE */
2568 lpfc_fdmi_hba_attr_vendor_id
, /* bit17 RHBA_VENDOR_ID */
2571 /* RPA / RPRT attribute jump table */
2572 int (*lpfc_fdmi_port_action
[])
2573 (struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
) = {
2574 /* Action routine Mask bit Attribute type */
2575 lpfc_fdmi_port_attr_fc4type
, /* bit0 RPRT_SUPPORT_FC4_TYPES */
2576 lpfc_fdmi_port_attr_support_speed
, /* bit1 RPRT_SUPPORTED_SPEED */
2577 lpfc_fdmi_port_attr_speed
, /* bit2 RPRT_PORT_SPEED */
2578 lpfc_fdmi_port_attr_max_frame
, /* bit3 RPRT_MAX_FRAME_SIZE */
2579 lpfc_fdmi_port_attr_os_devname
, /* bit4 RPRT_OS_DEVICE_NAME */
2580 lpfc_fdmi_port_attr_host_name
, /* bit5 RPRT_HOST_NAME */
2581 lpfc_fdmi_port_attr_wwnn
, /* bit6 RPRT_NODENAME */
2582 lpfc_fdmi_port_attr_wwpn
, /* bit7 RPRT_PORTNAME */
2583 lpfc_fdmi_port_attr_symbolic_name
, /* bit8 RPRT_SYM_PORTNAME */
2584 lpfc_fdmi_port_attr_port_type
, /* bit9 RPRT_PORT_TYPE */
2585 lpfc_fdmi_port_attr_class
, /* bit10 RPRT_SUPPORTED_CLASS */
2586 lpfc_fdmi_port_attr_fabric_wwpn
, /* bit11 RPRT_FABRICNAME */
2587 lpfc_fdmi_port_attr_active_fc4type
, /* bit12 RPRT_ACTIVE_FC4_TYPES */
2588 lpfc_fdmi_port_attr_port_state
, /* bit13 RPRT_PORT_STATE */
2589 lpfc_fdmi_port_attr_num_disc
, /* bit14 RPRT_DISC_PORT */
2590 lpfc_fdmi_port_attr_nportid
, /* bit15 RPRT_PORT_ID */
2591 lpfc_fdmi_smart_attr_service
, /* bit16 RPRT_SMART_SERVICE */
2592 lpfc_fdmi_smart_attr_guid
, /* bit17 RPRT_SMART_GUID */
2593 lpfc_fdmi_smart_attr_version
, /* bit18 RPRT_SMART_VERSION */
2594 lpfc_fdmi_smart_attr_model
, /* bit19 RPRT_SMART_MODEL */
2595 lpfc_fdmi_smart_attr_port_info
, /* bit20 RPRT_SMART_PORT_INFO */
2596 lpfc_fdmi_smart_attr_qos
, /* bit21 RPRT_SMART_QOS */
2597 lpfc_fdmi_smart_attr_security
, /* bit22 RPRT_SMART_SECURITY */
2601 * lpfc_fdmi_cmd - Build and send a FDMI cmd to the specified NPort
2602 * @vport: pointer to a host virtual N_Port data structure.
2603 * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID)
2604 * cmdcode: FDMI command to send
2605 * mask: Mask of HBA or PORT Attributes to send
2607 * Builds and sends a FDMI command using the CT subsystem.
2610 lpfc_fdmi_cmd(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
,
2611 int cmdcode
, uint32_t new_mask
)
2613 struct lpfc_hba
*phba
= vport
->phba
;
2614 struct lpfc_dmabuf
*mp
, *bmp
;
2615 struct lpfc_sli_ct_request
*CtReq
;
2616 struct ulp_bde64
*bpl
;
2621 struct lpfc_fdmi_reg_hba
*rh
;
2622 struct lpfc_fdmi_port_entry
*pe
;
2623 struct lpfc_fdmi_reg_portattr
*pab
= NULL
;
2624 struct lpfc_fdmi_attr_block
*ab
= NULL
;
2625 int (*func
)(struct lpfc_vport
*vport
, struct lpfc_fdmi_attr_def
*ad
);
2626 void (*cmpl
)(struct lpfc_hba
*, struct lpfc_iocbq
*,
2627 struct lpfc_iocbq
*);
2629 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
2632 cmpl
= lpfc_cmpl_ct_disc_fdmi
; /* called from discovery */
2634 /* fill in BDEs for command */
2635 /* Allocate buffer for command payload */
2636 mp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
2640 mp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(mp
->phys
));
2642 goto fdmi_cmd_free_mp
;
2644 /* Allocate buffer for Buffer ptr list */
2645 bmp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
2647 goto fdmi_cmd_free_mpvirt
;
2649 bmp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(bmp
->phys
));
2651 goto fdmi_cmd_free_bmp
;
2653 INIT_LIST_HEAD(&mp
->list
);
2654 INIT_LIST_HEAD(&bmp
->list
);
2657 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2658 "0218 FDMI Request Data: x%x x%x x%x\n",
2659 vport
->fc_flag
, vport
->port_state
, cmdcode
);
2660 CtReq
= (struct lpfc_sli_ct_request
*)mp
->virt
;
2662 /* First populate the CT_IU preamble */
2663 memset(CtReq
, 0, sizeof(struct lpfc_sli_ct_request
));
2664 CtReq
->RevisionId
.bits
.Revision
= SLI_CT_REVISION
;
2665 CtReq
->RevisionId
.bits
.InId
= 0;
2667 CtReq
->FsType
= SLI_CT_MANAGEMENT_SERVICE
;
2668 CtReq
->FsSubType
= SLI_CT_FDMI_Subtypes
;
2670 CtReq
->CommandResponse
.bits
.CmdRsp
= cpu_to_be16(cmdcode
);
2671 rsp_size
= LPFC_BPL_SIZE
;
2674 /* Next fill in the specific FDMI cmd information */
2678 rh
= (struct lpfc_fdmi_reg_hba
*)&CtReq
->un
.PortID
;
2679 /* HBA Identifier */
2680 memcpy(&rh
->hi
.PortName
, &phba
->pport
->fc_sparam
.portName
,
2681 sizeof(struct lpfc_name
));
2683 if (cmdcode
== SLI_MGMT_RHBA
) {
2684 /* Registered Port List */
2685 /* One entry (port) per adapter */
2686 rh
->rpl
.EntryCnt
= cpu_to_be32(1);
2687 memcpy(&rh
->rpl
.pe
, &phba
->pport
->fc_sparam
.portName
,
2688 sizeof(struct lpfc_name
));
2690 /* point to the HBA attribute block */
2691 size
= 2 * sizeof(struct lpfc_name
) +
2694 size
= sizeof(struct lpfc_name
);
2696 ab
= (struct lpfc_fdmi_attr_block
*)((uint8_t *)rh
+ size
);
2703 mask
= vport
->fdmi_hba_mask
;
2705 /* Mask will dictate what attributes to build in the request */
2708 func
= lpfc_fdmi_hba_action
[bit_pos
];
2710 (struct lpfc_fdmi_attr_def
*)
2711 ((uint8_t *)rh
+ size
));
2714 (LPFC_BPL_SIZE
- LPFC_CT_PREAMBLE
))
2721 ab
->EntryCnt
= cpu_to_be32(ab
->EntryCnt
);
2723 size
= GID_REQUEST_SZ
- 4 + size
;
2728 pab
= (struct lpfc_fdmi_reg_portattr
*)&CtReq
->un
.PortID
;
2729 if (cmdcode
== SLI_MGMT_RPRT
) {
2730 rh
= (struct lpfc_fdmi_reg_hba
*)pab
;
2731 /* HBA Identifier */
2732 memcpy(&rh
->hi
.PortName
,
2733 &phba
->pport
->fc_sparam
.portName
,
2734 sizeof(struct lpfc_name
));
2735 pab
= (struct lpfc_fdmi_reg_portattr
*)
2736 ((uint8_t *)pab
+ sizeof(struct lpfc_name
));
2739 memcpy((uint8_t *)&pab
->PortName
,
2740 (uint8_t *)&vport
->fc_sparam
.portName
,
2741 sizeof(struct lpfc_name
));
2742 size
+= sizeof(struct lpfc_name
) + FOURBYTES
;
2743 pab
->ab
.EntryCnt
= 0;
2748 mask
= vport
->fdmi_port_mask
;
2750 /* Mask will dictate what attributes to build in the request */
2753 func
= lpfc_fdmi_port_action
[bit_pos
];
2755 (struct lpfc_fdmi_attr_def
*)
2756 ((uint8_t *)pab
+ size
));
2759 (LPFC_BPL_SIZE
- LPFC_CT_PREAMBLE
))
2766 pab
->ab
.EntryCnt
= cpu_to_be32(pab
->ab
.EntryCnt
);
2768 if (cmdcode
== SLI_MGMT_RPRT
)
2769 size
+= sizeof(struct lpfc_name
);
2770 size
= GID_REQUEST_SZ
- 4 + size
;
2775 rsp_size
= FC_MAX_NS_RSP
;
2778 pe
= (struct lpfc_fdmi_port_entry
*)&CtReq
->un
.PortID
;
2779 memcpy((uint8_t *)&pe
->PortName
,
2780 (uint8_t *)&vport
->fc_sparam
.portName
,
2781 sizeof(struct lpfc_name
));
2782 size
= GID_REQUEST_SZ
- 4 + sizeof(struct lpfc_name
);
2787 rsp_size
= FC_MAX_NS_RSP
;
2790 pe
= (struct lpfc_fdmi_port_entry
*)&CtReq
->un
.PortID
;
2791 memcpy((uint8_t *)&pe
->PortName
,
2792 (uint8_t *)&vport
->fc_sparam
.portName
,
2793 sizeof(struct lpfc_name
));
2794 size
= GID_REQUEST_SZ
- 4 + sizeof(struct lpfc_name
);
2797 size
= GID_REQUEST_SZ
- 4;
2800 lpfc_printf_vlog(vport
, KERN_WARNING
, LOG_DISCOVERY
,
2801 "0298 FDMI cmdcode x%x not supported\n",
2803 goto fdmi_cmd_free_bmpvirt
;
2805 CtReq
->CommandResponse
.bits
.Size
= cpu_to_be16(rsp_size
);
2807 bpl
= (struct ulp_bde64
*)bmp
->virt
;
2808 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
));
2809 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
));
2810 bpl
->tus
.f
.bdeFlags
= 0;
2811 bpl
->tus
.f
.bdeSize
= size
;
2814 * The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
2815 * to hold ndlp reference for the corresponding callback function.
2817 if (!lpfc_ct_cmd(vport
, mp
, bmp
, ndlp
, cmpl
, rsp_size
, 0))
2821 * Decrement ndlp reference count to release ndlp reference held
2822 * for the failed command's callback function.
2826 fdmi_cmd_free_bmpvirt
:
2827 lpfc_mbuf_free(phba
, bmp
->virt
, bmp
->phys
);
2830 fdmi_cmd_free_mpvirt
:
2831 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
2835 /* Issue FDMI request failed */
2836 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
2837 "0244 Issue FDMI request failed Data: x%x\n",
2843 * lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer.
2844 * @ptr - Context object of the timer.
2846 * This function set the WORKER_DELAYED_DISC_TMO flag and wake up
2847 * the worker thread.
2850 lpfc_delayed_disc_tmo(unsigned long ptr
)
2852 struct lpfc_vport
*vport
= (struct lpfc_vport
*)ptr
;
2853 struct lpfc_hba
*phba
= vport
->phba
;
2854 uint32_t tmo_posted
;
2855 unsigned long iflag
;
2857 spin_lock_irqsave(&vport
->work_port_lock
, iflag
);
2858 tmo_posted
= vport
->work_port_events
& WORKER_DELAYED_DISC_TMO
;
2860 vport
->work_port_events
|= WORKER_DELAYED_DISC_TMO
;
2861 spin_unlock_irqrestore(&vport
->work_port_lock
, iflag
);
2864 lpfc_worker_wake_up(phba
);
2869 * lpfc_delayed_disc_timeout_handler - Function called by worker thread to
2870 * handle delayed discovery.
2871 * @vport: pointer to a host virtual N_Port data structure.
2873 * This function start nport discovery of the vport.
2876 lpfc_delayed_disc_timeout_handler(struct lpfc_vport
*vport
)
2878 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
2880 spin_lock_irq(shost
->host_lock
);
2881 if (!(vport
->fc_flag
& FC_DISC_DELAYED
)) {
2882 spin_unlock_irq(shost
->host_lock
);
2885 vport
->fc_flag
&= ~FC_DISC_DELAYED
;
2886 spin_unlock_irq(shost
->host_lock
);
2888 lpfc_do_scr_ns_plogi(vport
->phba
, vport
);
2892 lpfc_decode_firmware_rev(struct lpfc_hba
*phba
, char *fwrevision
, int flag
)
2894 struct lpfc_sli
*psli
= &phba
->sli
;
2895 lpfc_vpd_t
*vp
= &phba
->vpd
;
2896 uint32_t b1
, b2
, b3
, b4
, i
, rev
;
2898 uint32_t *ptr
, str
[4];
2901 if (phba
->sli_rev
== LPFC_SLI_REV4
)
2902 snprintf(fwrevision
, FW_REV_STR_SIZE
, "%s", vp
->rev
.opFwName
);
2903 else if (vp
->rev
.rBit
) {
2904 if (psli
->sli_flag
& LPFC_SLI_ACTIVE
)
2905 rev
= vp
->rev
.sli2FwRev
;
2907 rev
= vp
->rev
.sli1FwRev
;
2909 b1
= (rev
& 0x0000f000) >> 12;
2910 b2
= (rev
& 0x00000f00) >> 8;
2911 b3
= (rev
& 0x000000c0) >> 6;
2912 b4
= (rev
& 0x00000030) >> 4;
2931 b4
= (rev
& 0x0000000f);
2933 if (psli
->sli_flag
& LPFC_SLI_ACTIVE
)
2934 fwname
= vp
->rev
.sli2FwName
;
2936 fwname
= vp
->rev
.sli1FwName
;
2938 for (i
= 0; i
< 16; i
++)
2939 if (fwname
[i
] == 0x20)
2942 ptr
= (uint32_t*)fwname
;
2944 for (i
= 0; i
< 3; i
++)
2945 str
[i
] = be32_to_cpu(*ptr
++);
2949 sprintf(fwrevision
, "%d.%d%d (%s)",
2950 b1
, b2
, b3
, (char *)str
);
2952 sprintf(fwrevision
, "%d.%d%d", b1
,
2956 sprintf(fwrevision
, "%d.%d%d%c%d (%s)",
2960 sprintf(fwrevision
, "%d.%d%d%c%d",
2964 rev
= vp
->rev
.smFwRev
;
2966 b1
= (rev
& 0xff000000) >> 24;
2967 b2
= (rev
& 0x00f00000) >> 20;
2968 b3
= (rev
& 0x000f0000) >> 16;
2969 c
= (rev
& 0x0000ff00) >> 8;
2970 b4
= (rev
& 0x000000ff);
2972 sprintf(fwrevision
, "%d.%d%d%c%d", b1
, b2
, b3
, c
, b4
);