1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2010 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
8 * This program is free software; you can redistribute it and/or *
9 * modify it under the terms of version 2 of the GNU General *
10 * Public License as published by the Free Software Foundation. *
11 * This program is distributed in the hope that it will be useful. *
12 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16 * TO BE LEGALLY INVALID. See the GNU General Public License for *
17 * more details, a copy of which can be found in the file COPYING *
18 * included with this package. *
19 *******************************************************************/
22 * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS
25 #include <linux/blkdev.h>
26 #include <linux/pci.h>
27 #include <linux/interrupt.h>
28 #include <linux/slab.h>
29 #include <linux/utsname.h>
31 #include <scsi/scsi.h>
32 #include <scsi/scsi_device.h>
33 #include <scsi/scsi_host.h>
34 #include <scsi/scsi_transport_fc.h>
35 #include <scsi/fc/fc_fs.h>
40 #include "lpfc_sli4.h"
42 #include "lpfc_disc.h"
43 #include "lpfc_scsi.h"
45 #include "lpfc_logmsg.h"
46 #include "lpfc_crtn.h"
47 #include "lpfc_version.h"
48 #include "lpfc_vport.h"
49 #include "lpfc_debugfs.h"
51 /* FDMI Port Speed definitions */
52 #define HBA_PORTSPEED_1GBIT 0x0001 /* 1 GBit/sec */
53 #define HBA_PORTSPEED_2GBIT 0x0002 /* 2 GBit/sec */
54 #define HBA_PORTSPEED_4GBIT 0x0008 /* 4 GBit/sec */
55 #define HBA_PORTSPEED_10GBIT 0x0004 /* 10 GBit/sec */
56 #define HBA_PORTSPEED_8GBIT 0x0010 /* 8 GBit/sec */
57 #define HBA_PORTSPEED_16GBIT 0x0020 /* 16 GBit/sec */
58 #define HBA_PORTSPEED_UNKNOWN 0x0800 /* Unknown */
63 static char *lpfc_release_version
= LPFC_DRIVER_VERSION
;
66 lpfc_ct_ignore_hbq_buffer(struct lpfc_hba
*phba
, struct lpfc_iocbq
*piocbq
,
67 struct lpfc_dmabuf
*mp
, uint32_t size
)
70 lpfc_printf_log(phba
, KERN_INFO
, LOG_ELS
,
71 "0146 Ignoring unsolicited CT No HBQ "
73 piocbq
->iocb
.ulpStatus
);
75 lpfc_printf_log(phba
, KERN_INFO
, LOG_ELS
,
76 "0145 Ignoring unsolicted CT HBQ Size:%d "
78 size
, piocbq
->iocb
.ulpStatus
);
82 lpfc_ct_unsol_buffer(struct lpfc_hba
*phba
, struct lpfc_iocbq
*piocbq
,
83 struct lpfc_dmabuf
*mp
, uint32_t size
)
85 lpfc_ct_ignore_hbq_buffer(phba
, piocbq
, mp
, size
);
89 lpfc_ct_unsol_event(struct lpfc_hba
*phba
, struct lpfc_sli_ring
*pring
,
90 struct lpfc_iocbq
*piocbq
)
92 struct lpfc_dmabuf
*mp
= NULL
;
93 IOCB_t
*icmd
= &piocbq
->iocb
;
95 struct lpfc_iocbq
*iocbq
;
98 struct list_head head
;
99 struct lpfc_dmabuf
*bdeBuf
;
101 if (lpfc_bsg_ct_unsol_event(phba
, pring
, piocbq
) == 0)
104 if (unlikely(icmd
->ulpStatus
== IOSTAT_NEED_BUFFER
)) {
105 lpfc_sli_hbqbuf_add_hbqs(phba
, LPFC_ELS_HBQ
);
106 } else if ((icmd
->ulpStatus
== IOSTAT_LOCAL_REJECT
) &&
107 ((icmd
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
108 IOERR_RCV_BUFFER_WAITING
)) {
109 /* Not enough posted buffers; Try posting more buffers */
110 phba
->fc_stat
.NoRcvBuf
++;
111 if (!(phba
->sli3_options
& LPFC_SLI3_HBQ_ENABLED
))
112 lpfc_post_buffer(phba
, pring
, 2);
116 /* If there are no BDEs associated with this IOCB,
117 * there is nothing to do.
119 if (icmd
->ulpBdeCount
== 0)
122 if (phba
->sli3_options
& LPFC_SLI3_HBQ_ENABLED
) {
123 INIT_LIST_HEAD(&head
);
124 list_add_tail(&head
, &piocbq
->list
);
125 list_for_each_entry(iocbq
, &head
, list
) {
127 if (icmd
->ulpBdeCount
== 0)
129 bdeBuf
= iocbq
->context2
;
130 iocbq
->context2
= NULL
;
131 size
= icmd
->un
.cont64
[0].tus
.f
.bdeSize
;
132 lpfc_ct_unsol_buffer(phba
, piocbq
, bdeBuf
, size
);
133 lpfc_in_buf_free(phba
, bdeBuf
);
134 if (icmd
->ulpBdeCount
== 2) {
135 bdeBuf
= iocbq
->context3
;
136 iocbq
->context3
= NULL
;
137 size
= icmd
->unsli3
.rcvsli3
.bde2
.tus
.f
.bdeSize
;
138 lpfc_ct_unsol_buffer(phba
, piocbq
, bdeBuf
,
140 lpfc_in_buf_free(phba
, bdeBuf
);
145 INIT_LIST_HEAD(&head
);
146 list_add_tail(&head
, &piocbq
->list
);
147 list_for_each_entry(iocbq
, &head
, list
) {
149 if (icmd
->ulpBdeCount
== 0)
150 lpfc_ct_unsol_buffer(phba
, iocbq
, NULL
, 0);
151 for (i
= 0; i
< icmd
->ulpBdeCount
; i
++) {
152 paddr
= getPaddr(icmd
->un
.cont64
[i
].addrHigh
,
153 icmd
->un
.cont64
[i
].addrLow
);
154 mp
= lpfc_sli_ringpostbuf_get(phba
, pring
,
156 size
= icmd
->un
.cont64
[i
].tus
.f
.bdeSize
;
157 lpfc_ct_unsol_buffer(phba
, iocbq
, mp
, size
);
158 lpfc_in_buf_free(phba
, mp
);
160 lpfc_post_buffer(phba
, pring
, i
);
167 * lpfc_sli4_ct_abort_unsol_event - Default handle for sli4 unsol abort
168 * @phba: Pointer to HBA context object.
169 * @pring: Pointer to the driver internal I/O ring.
170 * @piocbq: Pointer to the IOCBQ.
172 * This function serves as the default handler for the sli4 unsolicited
173 * abort event. It shall be invoked when there is no application interface
174 * registered unsolicited abort handler. This handler does nothing but
175 * just simply releases the dma buffer used by the unsol abort event.
178 lpfc_sli4_ct_abort_unsol_event(struct lpfc_hba
*phba
,
179 struct lpfc_sli_ring
*pring
,
180 struct lpfc_iocbq
*piocbq
)
182 IOCB_t
*icmd
= &piocbq
->iocb
;
183 struct lpfc_dmabuf
*bdeBuf
;
186 /* Forward abort event to any process registered to receive ct event */
187 if (lpfc_bsg_ct_unsol_event(phba
, pring
, piocbq
) == 0)
190 /* If there is no BDE associated with IOCB, there is nothing to do */
191 if (icmd
->ulpBdeCount
== 0)
193 bdeBuf
= piocbq
->context2
;
194 piocbq
->context2
= NULL
;
195 size
= icmd
->un
.cont64
[0].tus
.f
.bdeSize
;
196 lpfc_ct_unsol_buffer(phba
, piocbq
, bdeBuf
, size
);
197 lpfc_in_buf_free(phba
, bdeBuf
);
201 lpfc_free_ct_rsp(struct lpfc_hba
*phba
, struct lpfc_dmabuf
*mlist
)
203 struct lpfc_dmabuf
*mlast
, *next_mlast
;
205 list_for_each_entry_safe(mlast
, next_mlast
, &mlist
->list
, list
) {
206 lpfc_mbuf_free(phba
, mlast
->virt
, mlast
->phys
);
207 list_del(&mlast
->list
);
210 lpfc_mbuf_free(phba
, mlist
->virt
, mlist
->phys
);
215 static struct lpfc_dmabuf
*
216 lpfc_alloc_ct_rsp(struct lpfc_hba
*phba
, int cmdcode
, struct ulp_bde64
*bpl
,
217 uint32_t size
, int *entries
)
219 struct lpfc_dmabuf
*mlist
= NULL
;
220 struct lpfc_dmabuf
*mp
;
223 /* We get chunks of FCELSSIZE */
224 cnt
= size
> FCELSSIZE
? FCELSSIZE
: size
;
227 /* Allocate buffer for rsp payload */
228 mp
= kmalloc(sizeof(struct lpfc_dmabuf
), GFP_KERNEL
);
231 lpfc_free_ct_rsp(phba
, mlist
);
235 INIT_LIST_HEAD(&mp
->list
);
237 if (cmdcode
== be16_to_cpu(SLI_CTNS_GID_FT
) ||
238 cmdcode
== be16_to_cpu(SLI_CTNS_GFF_ID
))
239 mp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(mp
->phys
));
241 mp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(mp
->phys
));
246 lpfc_free_ct_rsp(phba
, mlist
);
250 /* Queue it to a linked list */
254 list_add_tail(&mp
->list
, &mlist
->list
);
256 bpl
->tus
.f
.bdeFlags
= BUFF_TYPE_BDE_64I
;
257 /* build buffer ptr list for IOCB */
258 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
) );
259 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
) );
260 bpl
->tus
.f
.bdeSize
= (uint16_t) cnt
;
261 bpl
->tus
.w
= le32_to_cpu(bpl
->tus
.w
);
273 lpfc_ct_free_iocb(struct lpfc_hba
*phba
, struct lpfc_iocbq
*ctiocb
)
275 struct lpfc_dmabuf
*buf_ptr
;
277 if (ctiocb
->context_un
.ndlp
) {
278 lpfc_nlp_put(ctiocb
->context_un
.ndlp
);
279 ctiocb
->context_un
.ndlp
= NULL
;
281 if (ctiocb
->context1
) {
282 buf_ptr
= (struct lpfc_dmabuf
*) ctiocb
->context1
;
283 lpfc_mbuf_free(phba
, buf_ptr
->virt
, buf_ptr
->phys
);
285 ctiocb
->context1
= NULL
;
287 if (ctiocb
->context2
) {
288 lpfc_free_ct_rsp(phba
, (struct lpfc_dmabuf
*) ctiocb
->context2
);
289 ctiocb
->context2
= NULL
;
292 if (ctiocb
->context3
) {
293 buf_ptr
= (struct lpfc_dmabuf
*) ctiocb
->context3
;
294 lpfc_mbuf_free(phba
, buf_ptr
->virt
, buf_ptr
->phys
);
296 ctiocb
->context1
= NULL
;
298 lpfc_sli_release_iocbq(phba
, ctiocb
);
303 lpfc_gen_req(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*bmp
,
304 struct lpfc_dmabuf
*inp
, struct lpfc_dmabuf
*outp
,
305 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
306 struct lpfc_iocbq
*),
307 struct lpfc_nodelist
*ndlp
, uint32_t usr_flg
, uint32_t num_entry
,
308 uint32_t tmo
, uint8_t retry
)
310 struct lpfc_hba
*phba
= vport
->phba
;
312 struct lpfc_iocbq
*geniocb
;
315 /* Allocate buffer for command iocb */
316 geniocb
= lpfc_sli_get_iocbq(phba
);
321 icmd
= &geniocb
->iocb
;
322 icmd
->un
.genreq64
.bdl
.ulpIoTag32
= 0;
323 icmd
->un
.genreq64
.bdl
.addrHigh
= putPaddrHigh(bmp
->phys
);
324 icmd
->un
.genreq64
.bdl
.addrLow
= putPaddrLow(bmp
->phys
);
325 icmd
->un
.genreq64
.bdl
.bdeFlags
= BUFF_TYPE_BLP_64
;
326 icmd
->un
.genreq64
.bdl
.bdeSize
= (num_entry
* sizeof (struct ulp_bde64
));
329 geniocb
->context3
= NULL
;
331 geniocb
->context3
= (uint8_t *) bmp
;
333 /* Save for completion so we can release these resources */
334 geniocb
->context1
= (uint8_t *) inp
;
335 geniocb
->context2
= (uint8_t *) outp
;
336 geniocb
->context_un
.ndlp
= lpfc_nlp_get(ndlp
);
338 /* Fill in payload, bp points to frame payload */
339 icmd
->ulpCommand
= CMD_GEN_REQUEST64_CR
;
341 /* Fill in rest of iocb */
342 icmd
->un
.genreq64
.w5
.hcsw
.Fctl
= (SI
| LA
);
343 icmd
->un
.genreq64
.w5
.hcsw
.Dfctl
= 0;
344 icmd
->un
.genreq64
.w5
.hcsw
.Rctl
= FC_RCTL_DD_UNSOL_CTL
;
345 icmd
->un
.genreq64
.w5
.hcsw
.Type
= FC_TYPE_CT
;
348 /* FC spec states we need 3 * ratov for CT requests */
349 tmo
= (3 * phba
->fc_ratov
);
351 icmd
->ulpTimeout
= tmo
;
352 icmd
->ulpBdeCount
= 1;
354 icmd
->ulpClass
= CLASS3
;
355 icmd
->ulpContext
= ndlp
->nlp_rpi
;
356 if (phba
->sli_rev
== LPFC_SLI_REV4
)
357 icmd
->ulpContext
= phba
->sli4_hba
.rpi_ids
[ndlp
->nlp_rpi
];
359 if (phba
->sli3_options
& LPFC_SLI3_NPIV_ENABLED
) {
360 /* For GEN_REQUEST64_CR, use the RPI */
365 /* Issue GEN REQ IOCB for NPORT <did> */
366 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_ELS
,
367 "0119 Issue GEN REQ IOCB to NPORT x%x "
369 ndlp
->nlp_DID
, icmd
->ulpIoTag
,
371 geniocb
->iocb_cmpl
= cmpl
;
372 geniocb
->drvrTimeout
= icmd
->ulpTimeout
+ LPFC_DRVR_TIMEOUT
;
373 geniocb
->vport
= vport
;
374 geniocb
->retry
= retry
;
375 rc
= lpfc_sli_issue_iocb(phba
, LPFC_ELS_RING
, geniocb
, 0);
377 if (rc
== IOCB_ERROR
) {
378 lpfc_sli_release_iocbq(phba
, geniocb
);
386 lpfc_ct_cmd(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*inmp
,
387 struct lpfc_dmabuf
*bmp
, struct lpfc_nodelist
*ndlp
,
388 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
389 struct lpfc_iocbq
*),
390 uint32_t rsp_size
, uint8_t retry
)
392 struct lpfc_hba
*phba
= vport
->phba
;
393 struct ulp_bde64
*bpl
= (struct ulp_bde64
*) bmp
->virt
;
394 struct lpfc_dmabuf
*outmp
;
396 int cmdcode
= ((struct lpfc_sli_ct_request
*) inmp
->virt
)->
397 CommandResponse
.bits
.CmdRsp
;
399 bpl
++; /* Skip past ct request */
401 /* Put buffer(s) for ct rsp in bpl */
402 outmp
= lpfc_alloc_ct_rsp(phba
, cmdcode
, bpl
, rsp_size
, &cnt
);
406 * Form the CT IOCB. The total number of BDEs in this IOCB
407 * is the single command plus response count from
411 status
= lpfc_gen_req(vport
, bmp
, inmp
, outmp
, cmpl
, ndlp
, 0,
414 lpfc_free_ct_rsp(phba
, outmp
);
421 lpfc_find_vport_by_did(struct lpfc_hba
*phba
, uint32_t did
) {
422 struct lpfc_vport
*vport_curr
;
425 spin_lock_irqsave(&phba
->hbalock
, flags
);
426 list_for_each_entry(vport_curr
, &phba
->port_list
, listentry
) {
427 if ((vport_curr
->fc_myDID
) && (vport_curr
->fc_myDID
== did
)) {
428 spin_unlock_irqrestore(&phba
->hbalock
, flags
);
432 spin_unlock_irqrestore(&phba
->hbalock
, flags
);
437 lpfc_ns_rsp(struct lpfc_vport
*vport
, struct lpfc_dmabuf
*mp
, uint32_t Size
)
439 struct lpfc_hba
*phba
= vport
->phba
;
440 struct lpfc_sli_ct_request
*Response
=
441 (struct lpfc_sli_ct_request
*) mp
->virt
;
442 struct lpfc_nodelist
*ndlp
= NULL
;
443 struct lpfc_dmabuf
*mlast
, *next_mp
;
444 uint32_t *ctptr
= (uint32_t *) & Response
->un
.gid
.PortType
;
445 uint32_t Did
, CTentry
;
447 struct list_head head
;
449 lpfc_set_disctmo(vport
);
450 vport
->num_disc_nodes
= 0;
451 vport
->fc_ns_retry
= 0;
454 list_add_tail(&head
, &mp
->list
);
455 list_for_each_entry_safe(mp
, next_mp
, &head
, list
) {
458 Cnt
= Size
> FCELSSIZE
? FCELSSIZE
: Size
;
463 ctptr
= (uint32_t *) mlast
->virt
;
465 Cnt
-= 16; /* subtract length of CT header */
467 /* Loop through entire NameServer list of DIDs */
468 while (Cnt
>= sizeof (uint32_t)) {
469 /* Get next DID from NameServer List */
471 Did
= ((be32_to_cpu(CTentry
)) & Mask_DID
);
476 * Check for rscn processing or not
477 * To conserve rpi's, filter out addresses for other
478 * vports on the same physical HBAs.
480 if ((Did
!= vport
->fc_myDID
) &&
481 ((lpfc_find_vport_by_did(phba
, Did
) == NULL
) ||
482 vport
->cfg_peer_port_login
)) {
483 if ((vport
->port_type
!= LPFC_NPIV_PORT
) ||
484 (!(vport
->ct_flags
& FC_CT_RFF_ID
)) ||
485 (!vport
->cfg_restrict_login
)) {
486 ndlp
= lpfc_setup_disc_node(vport
, Did
);
487 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
488 lpfc_debugfs_disc_trc(vport
,
491 "did:x%x flg:x%x x%x",
495 lpfc_printf_vlog(vport
,
500 "Data: x%x x%x x%x\n",
503 vport
->fc_rscn_id_cnt
);
505 lpfc_debugfs_disc_trc(vport
,
508 "did:x%x flg:x%x cnt:%d",
510 vport
->fc_rscn_id_cnt
);
512 lpfc_printf_vlog(vport
,
516 "NameServer Rsp Data: "
519 vport
->fc_rscn_id_cnt
);
523 if (!(vport
->fc_flag
& FC_RSCN_MODE
) ||
524 (lpfc_rscn_payload_check(vport
, Did
))) {
525 lpfc_debugfs_disc_trc(vport
,
528 "did:x%x flg:x%x cnt:%d",
530 vport
->fc_rscn_id_cnt
);
532 /* This NPortID was previously
533 * a FCP target, * Don't even
534 * bother to send GFF_ID.
536 ndlp
= lpfc_findnode_did(vport
,
539 NLP_CHK_NODE_ACT(ndlp
)
544 else if (lpfc_ns_cmd(vport
,
547 vport
->num_disc_nodes
++;
553 lpfc_debugfs_disc_trc(vport
,
556 "did:x%x flg:x%x cnt:%d",
558 vport
->fc_rscn_id_cnt
);
560 lpfc_printf_vlog(vport
,
564 "NameServer Rsp Data: "
567 vport
->fc_rscn_id_cnt
);
571 if (CTentry
& (be32_to_cpu(SLI_CT_LAST_ENTRY
)))
573 Cnt
-= sizeof (uint32_t);
585 lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
586 struct lpfc_iocbq
*rspiocb
)
588 struct lpfc_vport
*vport
= cmdiocb
->vport
;
589 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
591 struct lpfc_dmabuf
*bmp
;
592 struct lpfc_dmabuf
*outp
;
593 struct lpfc_sli_ct_request
*CTrsp
;
594 struct lpfc_nodelist
*ndlp
;
597 /* First save ndlp, before we overwrite it */
598 ndlp
= cmdiocb
->context_un
.ndlp
;
600 /* we pass cmdiocb to state machine which needs rspiocb as well */
601 cmdiocb
->context_un
.rsp_iocb
= rspiocb
;
603 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
604 bmp
= (struct lpfc_dmabuf
*) cmdiocb
->context3
;
605 irsp
= &rspiocb
->iocb
;
607 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
608 "GID_FT cmpl: status:x%x/x%x rtry:%d",
609 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], vport
->fc_ns_retry
);
611 /* Don't bother processing response if vport is being torn down. */
612 if (vport
->load_flag
& FC_UNLOADING
) {
613 if (vport
->fc_flag
& FC_RSCN_MODE
)
614 lpfc_els_flush_rscn(vport
);
618 if (lpfc_els_chk_latt(vport
)) {
619 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
620 "0216 Link event during NS query\n");
621 if (vport
->fc_flag
& FC_RSCN_MODE
)
622 lpfc_els_flush_rscn(vport
);
623 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
626 if (lpfc_error_lost_link(irsp
)) {
627 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
628 "0226 NS query failed due to link event\n");
629 if (vport
->fc_flag
& FC_RSCN_MODE
)
630 lpfc_els_flush_rscn(vport
);
633 if (irsp
->ulpStatus
) {
634 /* Check for retry */
635 if (vport
->fc_ns_retry
< LPFC_MAX_NS_RETRY
) {
636 if (irsp
->ulpStatus
!= IOSTAT_LOCAL_REJECT
||
637 (irsp
->un
.ulpWord
[4] && IOERR_PARAM_MASK
) !=
639 vport
->fc_ns_retry
++;
641 /* CT command is being retried */
642 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GID_FT
,
643 vport
->fc_ns_retry
, 0);
647 if (vport
->fc_flag
& FC_RSCN_MODE
)
648 lpfc_els_flush_rscn(vport
);
649 lpfc_vport_set_state(vport
, FC_VPORT_FAILED
);
650 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_ELS
,
651 "0257 GID_FT Query error: 0x%x 0x%x\n",
652 irsp
->ulpStatus
, vport
->fc_ns_retry
);
654 /* Good status, continue checking */
655 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
656 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
657 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
)) {
658 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
659 "0208 NameServer Rsp Data: x%x\n",
661 lpfc_ns_rsp(vport
, outp
,
662 (uint32_t) (irsp
->un
.genreq64
.bdl
.bdeSize
));
663 } else if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
664 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT
)) {
665 /* NameServer Rsp Error */
666 if ((CTrsp
->ReasonCode
== SLI_CT_UNABLE_TO_PERFORM_REQ
)
667 && (CTrsp
->Explanation
== SLI_CT_NO_FC4_TYPES
)) {
668 lpfc_printf_vlog(vport
, KERN_INFO
,
670 "0269 No NameServer Entries "
671 "Data: x%x x%x x%x x%x\n",
672 CTrsp
->CommandResponse
.bits
.CmdRsp
,
673 (uint32_t) CTrsp
->ReasonCode
,
674 (uint32_t) CTrsp
->Explanation
,
677 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
678 "GID_FT no entry cmd:x%x rsn:x%x exp:x%x",
679 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
680 (uint32_t) CTrsp
->ReasonCode
,
681 (uint32_t) CTrsp
->Explanation
);
683 lpfc_printf_vlog(vport
, KERN_INFO
,
685 "0240 NameServer Rsp Error "
686 "Data: x%x x%x x%x x%x\n",
687 CTrsp
->CommandResponse
.bits
.CmdRsp
,
688 (uint32_t) CTrsp
->ReasonCode
,
689 (uint32_t) CTrsp
->Explanation
,
692 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
693 "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x",
694 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
695 (uint32_t) CTrsp
->ReasonCode
,
696 (uint32_t) CTrsp
->Explanation
);
701 /* NameServer Rsp Error */
702 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
703 "0241 NameServer Rsp Error "
704 "Data: x%x x%x x%x x%x\n",
705 CTrsp
->CommandResponse
.bits
.CmdRsp
,
706 (uint32_t) CTrsp
->ReasonCode
,
707 (uint32_t) CTrsp
->Explanation
,
710 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
711 "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x",
712 (uint32_t)CTrsp
->CommandResponse
.bits
.CmdRsp
,
713 (uint32_t) CTrsp
->ReasonCode
,
714 (uint32_t) CTrsp
->Explanation
);
717 /* Link up / RSCN discovery */
718 if (vport
->num_disc_nodes
== 0) {
720 * The driver has cycled through all Nports in the RSCN payload.
721 * Complete the handling by cleaning up and marking the
722 * current driver state.
724 if (vport
->port_state
>= LPFC_DISC_AUTH
) {
725 if (vport
->fc_flag
& FC_RSCN_MODE
) {
726 lpfc_els_flush_rscn(vport
);
727 spin_lock_irq(shost
->host_lock
);
728 vport
->fc_flag
|= FC_RSCN_MODE
; /* RSCN still */
729 spin_unlock_irq(shost
->host_lock
);
732 lpfc_els_flush_rscn(vport
);
735 lpfc_disc_start(vport
);
738 cmdiocb
->context_un
.ndlp
= ndlp
; /* Now restore ndlp for free */
739 lpfc_ct_free_iocb(phba
, cmdiocb
);
744 lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
745 struct lpfc_iocbq
*rspiocb
)
747 struct lpfc_vport
*vport
= cmdiocb
->vport
;
748 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
749 IOCB_t
*irsp
= &rspiocb
->iocb
;
750 struct lpfc_dmabuf
*inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
751 struct lpfc_dmabuf
*outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
752 struct lpfc_sli_ct_request
*CTrsp
;
755 struct lpfc_nodelist
*ndlp
;
757 did
= ((struct lpfc_sli_ct_request
*) inp
->virt
)->un
.gff
.PortId
;
758 did
= be32_to_cpu(did
);
760 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
761 "GFF_ID cmpl: status:x%x/x%x did:x%x",
762 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], did
);
764 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
765 /* Good status, continue checking */
766 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
767 fbits
= CTrsp
->un
.gff_acc
.fbits
[FCP_TYPE_FEATURE_OFFSET
];
769 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
770 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
)) {
771 if ((fbits
& FC4_FEATURE_INIT
) &&
772 !(fbits
& FC4_FEATURE_TARGET
)) {
773 lpfc_printf_vlog(vport
, KERN_INFO
,
776 "NameServer Rsp Data: (init) "
777 "x%x x%x\n", did
, fbits
,
778 vport
->fc_rscn_id_cnt
);
784 /* Check for retry */
785 if (cmdiocb
->retry
< LPFC_MAX_NS_RETRY
) {
787 if (irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) {
788 switch ((irsp
->un
.ulpWord
[4] &
791 case IOERR_NO_RESOURCES
:
792 /* We don't increment the retry
793 * count for this case.
796 case IOERR_LINK_DOWN
:
797 case IOERR_SLI_ABORTED
:
809 /* CT command is being retried */
810 rc
= lpfc_ns_cmd(vport
, SLI_CTNS_GFF_ID
,
811 cmdiocb
->retry
, did
);
814 lpfc_ct_free_iocb(phba
, cmdiocb
);
819 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
820 "0267 NameServer GFF Rsp "
821 "x%x Error (%d %d) Data: x%x x%x\n",
822 did
, irsp
->ulpStatus
, irsp
->un
.ulpWord
[4],
823 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
826 /* This is a target port, unregistered port, or the GFF_ID failed */
827 ndlp
= lpfc_setup_disc_node(vport
, did
);
828 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
829 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
830 "0242 Process x%x GFF "
831 "NameServer Rsp Data: x%x x%x x%x\n",
832 did
, ndlp
->nlp_flag
, vport
->fc_flag
,
833 vport
->fc_rscn_id_cnt
);
835 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
837 "NameServer Rsp Data: x%x x%x\n", did
,
838 vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
841 /* Link up / RSCN discovery */
842 if (vport
->num_disc_nodes
)
843 vport
->num_disc_nodes
--;
844 if (vport
->num_disc_nodes
== 0) {
846 * The driver has cycled through all Nports in the RSCN payload.
847 * Complete the handling by cleaning up and marking the
848 * current driver state.
850 if (vport
->port_state
>= LPFC_DISC_AUTH
) {
851 if (vport
->fc_flag
& FC_RSCN_MODE
) {
852 lpfc_els_flush_rscn(vport
);
853 spin_lock_irq(shost
->host_lock
);
854 vport
->fc_flag
|= FC_RSCN_MODE
; /* RSCN still */
855 spin_unlock_irq(shost
->host_lock
);
858 lpfc_els_flush_rscn(vport
);
860 lpfc_disc_start(vport
);
862 lpfc_ct_free_iocb(phba
, cmdiocb
);
868 lpfc_cmpl_ct(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
869 struct lpfc_iocbq
*rspiocb
)
871 struct lpfc_vport
*vport
= cmdiocb
->vport
;
872 struct lpfc_dmabuf
*inp
;
873 struct lpfc_dmabuf
*outp
;
875 struct lpfc_sli_ct_request
*CTrsp
;
876 struct lpfc_nodelist
*ndlp
;
881 /* First save ndlp, before we overwrite it */
882 ndlp
= cmdiocb
->context_un
.ndlp
;
884 /* we pass cmdiocb to state machine which needs rspiocb as well */
885 cmdiocb
->context_un
.rsp_iocb
= rspiocb
;
887 inp
= (struct lpfc_dmabuf
*) cmdiocb
->context1
;
888 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
889 irsp
= &rspiocb
->iocb
;
891 cmdcode
= be16_to_cpu(((struct lpfc_sli_ct_request
*) inp
->virt
)->
892 CommandResponse
.bits
.CmdRsp
);
893 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
895 latt
= lpfc_els_chk_latt(vport
);
897 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
898 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
899 "0209 CT Request completes, latt %d, "
900 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
901 latt
, irsp
->ulpStatus
,
902 CTrsp
->CommandResponse
.bits
.CmdRsp
,
903 cmdiocb
->iocb
.ulpContext
, cmdiocb
->iocb
.ulpIoTag
);
905 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
906 "CT cmd cmpl: status:x%x/x%x cmd:x%x",
907 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], cmdcode
);
909 if (irsp
->ulpStatus
) {
910 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
911 "0268 NS cmd %x Error (%d %d)\n",
912 cmdcode
, irsp
->ulpStatus
, irsp
->un
.ulpWord
[4]);
914 if ((irsp
->ulpStatus
== IOSTAT_LOCAL_REJECT
) &&
915 (((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
917 ((irsp
->un
.ulpWord
[4] & IOERR_PARAM_MASK
) ==
921 retry
= cmdiocb
->retry
;
922 if (retry
>= LPFC_MAX_NS_RETRY
)
926 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
927 "0250 Retrying NS cmd %x\n", cmdcode
);
928 rc
= lpfc_ns_cmd(vport
, cmdcode
, retry
, 0);
934 cmdiocb
->context_un
.ndlp
= ndlp
; /* Now restore ndlp for free */
935 lpfc_ct_free_iocb(phba
, cmdiocb
);
940 lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
941 struct lpfc_iocbq
*rspiocb
)
943 IOCB_t
*irsp
= &rspiocb
->iocb
;
944 struct lpfc_vport
*vport
= cmdiocb
->vport
;
946 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
947 struct lpfc_dmabuf
*outp
;
948 struct lpfc_sli_ct_request
*CTrsp
;
950 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
951 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
952 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
953 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
954 vport
->ct_flags
|= FC_CT_RFT_ID
;
956 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
961 lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
962 struct lpfc_iocbq
*rspiocb
)
964 IOCB_t
*irsp
= &rspiocb
->iocb
;
965 struct lpfc_vport
*vport
= cmdiocb
->vport
;
967 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
968 struct lpfc_dmabuf
*outp
;
969 struct lpfc_sli_ct_request
*CTrsp
;
971 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
972 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
973 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
974 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
975 vport
->ct_flags
|= FC_CT_RNN_ID
;
977 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
982 lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
983 struct lpfc_iocbq
*rspiocb
)
985 IOCB_t
*irsp
= &rspiocb
->iocb
;
986 struct lpfc_vport
*vport
= cmdiocb
->vport
;
988 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
989 struct lpfc_dmabuf
*outp
;
990 struct lpfc_sli_ct_request
*CTrsp
;
992 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
993 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
994 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
995 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
996 vport
->ct_flags
|= FC_CT_RSPN_ID
;
998 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1003 lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1004 struct lpfc_iocbq
*rspiocb
)
1006 IOCB_t
*irsp
= &rspiocb
->iocb
;
1007 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1009 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1010 struct lpfc_dmabuf
*outp
;
1011 struct lpfc_sli_ct_request
*CTrsp
;
1013 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1014 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1015 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1016 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1017 vport
->ct_flags
|= FC_CT_RSNN_NN
;
1019 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1024 lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1025 struct lpfc_iocbq
*rspiocb
)
1027 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1029 /* even if it fails we will act as though it succeeded. */
1030 vport
->ct_flags
= 0;
1031 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1036 lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1037 struct lpfc_iocbq
*rspiocb
)
1039 IOCB_t
*irsp
= &rspiocb
->iocb
;
1040 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1042 if (irsp
->ulpStatus
== IOSTAT_SUCCESS
) {
1043 struct lpfc_dmabuf
*outp
;
1044 struct lpfc_sli_ct_request
*CTrsp
;
1046 outp
= (struct lpfc_dmabuf
*) cmdiocb
->context2
;
1047 CTrsp
= (struct lpfc_sli_ct_request
*) outp
->virt
;
1048 if (CTrsp
->CommandResponse
.bits
.CmdRsp
==
1049 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC
))
1050 vport
->ct_flags
|= FC_CT_RFF_ID
;
1052 lpfc_cmpl_ct(phba
, cmdiocb
, rspiocb
);
1057 lpfc_vport_symbolic_port_name(struct lpfc_vport
*vport
, char *symbol
,
1061 uint8_t *wwn
= vport
->phba
->wwpn
;
1063 n
= snprintf(symbol
, size
,
1064 "Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
1065 wwn
[0], wwn
[1], wwn
[2], wwn
[3],
1066 wwn
[4], wwn
[5], wwn
[6], wwn
[7]);
1068 if (vport
->port_type
== LPFC_PHYSICAL_PORT
)
1072 n
+= snprintf(symbol
+ n
, size
- n
, " VPort-%d", vport
->vpi
);
1075 strlen(vport
->fc_vport
->symbolic_name
))
1076 n
+= snprintf(symbol
+ n
, size
- n
, " VName-%s",
1077 vport
->fc_vport
->symbolic_name
);
1082 lpfc_vport_symbolic_node_name(struct lpfc_vport
*vport
, char *symbol
,
1085 char fwrev
[FW_REV_STR_SIZE
];
1088 lpfc_decode_firmware_rev(vport
->phba
, fwrev
, 0);
1090 n
= snprintf(symbol
, size
, "Emulex %s FV%s DV%s",
1091 vport
->phba
->ModelName
, fwrev
, lpfc_release_version
);
1098 * Issue Cmd to NameServer
1103 lpfc_ns_cmd(struct lpfc_vport
*vport
, int cmdcode
,
1104 uint8_t retry
, uint32_t context
)
1106 struct lpfc_nodelist
* ndlp
;
1107 struct lpfc_hba
*phba
= vport
->phba
;
1108 struct lpfc_dmabuf
*mp
, *bmp
;
1109 struct lpfc_sli_ct_request
*CtReq
;
1110 struct ulp_bde64
*bpl
;
1111 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
1112 struct lpfc_iocbq
*) = NULL
;
1113 uint32_t rsp_size
= 1024;
1117 ndlp
= lpfc_findnode_did(vport
, NameServer_DID
);
1118 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
)
1119 || ndlp
->nlp_state
!= NLP_STE_UNMAPPED_NODE
) {
1124 /* fill in BDEs for command */
1125 /* Allocate buffer for command payload */
1126 mp
= kmalloc(sizeof (struct lpfc_dmabuf
), GFP_KERNEL
);
1132 INIT_LIST_HEAD(&mp
->list
);
1133 mp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(mp
->phys
));
1136 goto ns_cmd_free_mp
;
1139 /* Allocate buffer for Buffer ptr list */
1140 bmp
= kmalloc(sizeof (struct lpfc_dmabuf
), GFP_KERNEL
);
1143 goto ns_cmd_free_mpvirt
;
1146 INIT_LIST_HEAD(&bmp
->list
);
1147 bmp
->virt
= lpfc_mbuf_alloc(phba
, MEM_PRI
, &(bmp
->phys
));
1150 goto ns_cmd_free_bmp
;
1153 /* NameServer Req */
1154 lpfc_printf_vlog(vport
, KERN_INFO
,LOG_DISCOVERY
,
1155 "0236 NameServer Req Data: x%x x%x x%x\n",
1156 cmdcode
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
1158 bpl
= (struct ulp_bde64
*) bmp
->virt
;
1159 memset(bpl
, 0, sizeof(struct ulp_bde64
));
1160 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
) );
1161 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
) );
1162 bpl
->tus
.f
.bdeFlags
= 0;
1163 if (cmdcode
== SLI_CTNS_GID_FT
)
1164 bpl
->tus
.f
.bdeSize
= GID_REQUEST_SZ
;
1165 else if (cmdcode
== SLI_CTNS_GFF_ID
)
1166 bpl
->tus
.f
.bdeSize
= GFF_REQUEST_SZ
;
1167 else if (cmdcode
== SLI_CTNS_RFT_ID
)
1168 bpl
->tus
.f
.bdeSize
= RFT_REQUEST_SZ
;
1169 else if (cmdcode
== SLI_CTNS_RNN_ID
)
1170 bpl
->tus
.f
.bdeSize
= RNN_REQUEST_SZ
;
1171 else if (cmdcode
== SLI_CTNS_RSPN_ID
)
1172 bpl
->tus
.f
.bdeSize
= RSPN_REQUEST_SZ
;
1173 else if (cmdcode
== SLI_CTNS_RSNN_NN
)
1174 bpl
->tus
.f
.bdeSize
= RSNN_REQUEST_SZ
;
1175 else if (cmdcode
== SLI_CTNS_DA_ID
)
1176 bpl
->tus
.f
.bdeSize
= DA_ID_REQUEST_SZ
;
1177 else if (cmdcode
== SLI_CTNS_RFF_ID
)
1178 bpl
->tus
.f
.bdeSize
= RFF_REQUEST_SZ
;
1180 bpl
->tus
.f
.bdeSize
= 0;
1181 bpl
->tus
.w
= le32_to_cpu(bpl
->tus
.w
);
1183 CtReq
= (struct lpfc_sli_ct_request
*) mp
->virt
;
1184 memset(CtReq
, 0, sizeof (struct lpfc_sli_ct_request
));
1185 CtReq
->RevisionId
.bits
.Revision
= SLI_CT_REVISION
;
1186 CtReq
->RevisionId
.bits
.InId
= 0;
1187 CtReq
->FsType
= SLI_CT_DIRECTORY_SERVICE
;
1188 CtReq
->FsSubType
= SLI_CT_DIRECTORY_NAME_SERVER
;
1189 CtReq
->CommandResponse
.bits
.Size
= 0;
1191 case SLI_CTNS_GID_FT
:
1192 CtReq
->CommandResponse
.bits
.CmdRsp
=
1193 be16_to_cpu(SLI_CTNS_GID_FT
);
1194 CtReq
->un
.gid
.Fc4Type
= SLI_CTPT_FCP
;
1195 if (vport
->port_state
< LPFC_NS_QRY
)
1196 vport
->port_state
= LPFC_NS_QRY
;
1197 lpfc_set_disctmo(vport
);
1198 cmpl
= lpfc_cmpl_ct_cmd_gid_ft
;
1199 rsp_size
= FC_MAX_NS_RSP
;
1202 case SLI_CTNS_GFF_ID
:
1203 CtReq
->CommandResponse
.bits
.CmdRsp
=
1204 be16_to_cpu(SLI_CTNS_GFF_ID
);
1205 CtReq
->un
.gff
.PortId
= cpu_to_be32(context
);
1206 cmpl
= lpfc_cmpl_ct_cmd_gff_id
;
1209 case SLI_CTNS_RFT_ID
:
1210 vport
->ct_flags
&= ~FC_CT_RFT_ID
;
1211 CtReq
->CommandResponse
.bits
.CmdRsp
=
1212 be16_to_cpu(SLI_CTNS_RFT_ID
);
1213 CtReq
->un
.rft
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1214 CtReq
->un
.rft
.fcpReg
= 1;
1215 cmpl
= lpfc_cmpl_ct_cmd_rft_id
;
1218 case SLI_CTNS_RNN_ID
:
1219 vport
->ct_flags
&= ~FC_CT_RNN_ID
;
1220 CtReq
->CommandResponse
.bits
.CmdRsp
=
1221 be16_to_cpu(SLI_CTNS_RNN_ID
);
1222 CtReq
->un
.rnn
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1223 memcpy(CtReq
->un
.rnn
.wwnn
, &vport
->fc_nodename
,
1224 sizeof (struct lpfc_name
));
1225 cmpl
= lpfc_cmpl_ct_cmd_rnn_id
;
1228 case SLI_CTNS_RSPN_ID
:
1229 vport
->ct_flags
&= ~FC_CT_RSPN_ID
;
1230 CtReq
->CommandResponse
.bits
.CmdRsp
=
1231 be16_to_cpu(SLI_CTNS_RSPN_ID
);
1232 CtReq
->un
.rspn
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1233 size
= sizeof(CtReq
->un
.rspn
.symbname
);
1234 CtReq
->un
.rspn
.len
=
1235 lpfc_vport_symbolic_port_name(vport
,
1236 CtReq
->un
.rspn
.symbname
, size
);
1237 cmpl
= lpfc_cmpl_ct_cmd_rspn_id
;
1239 case SLI_CTNS_RSNN_NN
:
1240 vport
->ct_flags
&= ~FC_CT_RSNN_NN
;
1241 CtReq
->CommandResponse
.bits
.CmdRsp
=
1242 be16_to_cpu(SLI_CTNS_RSNN_NN
);
1243 memcpy(CtReq
->un
.rsnn
.wwnn
, &vport
->fc_nodename
,
1244 sizeof (struct lpfc_name
));
1245 size
= sizeof(CtReq
->un
.rsnn
.symbname
);
1246 CtReq
->un
.rsnn
.len
=
1247 lpfc_vport_symbolic_node_name(vport
,
1248 CtReq
->un
.rsnn
.symbname
, size
);
1249 cmpl
= lpfc_cmpl_ct_cmd_rsnn_nn
;
1251 case SLI_CTNS_DA_ID
:
1252 /* Implement DA_ID Nameserver request */
1253 CtReq
->CommandResponse
.bits
.CmdRsp
=
1254 be16_to_cpu(SLI_CTNS_DA_ID
);
1255 CtReq
->un
.da_id
.port_id
= cpu_to_be32(vport
->fc_myDID
);
1256 cmpl
= lpfc_cmpl_ct_cmd_da_id
;
1258 case SLI_CTNS_RFF_ID
:
1259 vport
->ct_flags
&= ~FC_CT_RFF_ID
;
1260 CtReq
->CommandResponse
.bits
.CmdRsp
=
1261 be16_to_cpu(SLI_CTNS_RFF_ID
);
1262 CtReq
->un
.rff
.PortId
= cpu_to_be32(vport
->fc_myDID
);
1263 CtReq
->un
.rff
.fbits
= FC4_FEATURE_INIT
;
1264 CtReq
->un
.rff
.type_code
= FC_TYPE_FCP
;
1265 cmpl
= lpfc_cmpl_ct_cmd_rff_id
;
1268 /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
1269 * to hold ndlp reference for the corresponding callback function.
1271 if (!lpfc_ct_cmd(vport
, mp
, bmp
, ndlp
, cmpl
, rsp_size
, retry
)) {
1272 /* On success, The cmpl function will free the buffers */
1273 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1274 "Issue CT cmd: cmd:x%x did:x%x",
1275 cmdcode
, ndlp
->nlp_DID
, 0);
1280 /* Decrement ndlp reference count to release ndlp reference held
1281 * for the failed command's callback function.
1285 lpfc_mbuf_free(phba
, bmp
->virt
, bmp
->phys
);
1289 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1293 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_DISCOVERY
,
1294 "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
1295 cmdcode
, rc
, vport
->fc_flag
, vport
->fc_rscn_id_cnt
);
1300 lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba
*phba
, struct lpfc_iocbq
*cmdiocb
,
1301 struct lpfc_iocbq
* rspiocb
)
1303 struct lpfc_dmabuf
*inp
= cmdiocb
->context1
;
1304 struct lpfc_dmabuf
*outp
= cmdiocb
->context2
;
1305 struct lpfc_sli_ct_request
*CTrsp
= outp
->virt
;
1306 struct lpfc_sli_ct_request
*CTcmd
= inp
->virt
;
1307 struct lpfc_nodelist
*ndlp
;
1308 uint16_t fdmi_cmd
= CTcmd
->CommandResponse
.bits
.CmdRsp
;
1309 uint16_t fdmi_rsp
= CTrsp
->CommandResponse
.bits
.CmdRsp
;
1310 struct lpfc_vport
*vport
= cmdiocb
->vport
;
1311 IOCB_t
*irsp
= &rspiocb
->iocb
;
1314 latt
= lpfc_els_chk_latt(vport
);
1316 lpfc_debugfs_disc_trc(vport
, LPFC_DISC_TRC_CT
,
1317 "FDMI cmpl: status:x%x/x%x latt:%d",
1318 irsp
->ulpStatus
, irsp
->un
.ulpWord
[4], latt
);
1320 if (latt
|| irsp
->ulpStatus
) {
1321 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1322 "0229 FDMI cmd %04x failed, latt = %d "
1323 "ulpStatus: x%x, rid x%x\n",
1324 be16_to_cpu(fdmi_cmd
), latt
, irsp
->ulpStatus
,
1325 irsp
->un
.ulpWord
[4]);
1326 lpfc_ct_free_iocb(phba
, cmdiocb
);
1330 ndlp
= lpfc_findnode_did(vport
, FDMI_DID
);
1331 if (!ndlp
|| !NLP_CHK_NODE_ACT(ndlp
))
1334 if (fdmi_rsp
== be16_to_cpu(SLI_CT_RESPONSE_FS_RJT
)) {
1335 /* FDMI rsp failed */
1336 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1337 "0220 FDMI rsp failed Data: x%x\n",
1338 be16_to_cpu(fdmi_cmd
));
1341 switch (be16_to_cpu(fdmi_cmd
)) {
1343 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RPA
);
1350 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DPRT
);
1354 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_RHBA
);
1359 lpfc_ct_free_iocb(phba
, cmdiocb
);
1364 lpfc_fdmi_cmd(struct lpfc_vport
*vport
, struct lpfc_nodelist
*ndlp
, int cmdcode
)
1366 struct lpfc_hba
*phba
= vport
->phba
;
1367 struct lpfc_dmabuf
*mp
, *bmp
;
1368 struct lpfc_sli_ct_request
*CtReq
;
1369 struct ulp_bde64
*bpl
;
1373 REG_PORT_ATTRIBUTE
*pab
;
1374 ATTRIBUTE_BLOCK
*ab
;
1375 ATTRIBUTE_ENTRY
*ae
;
1376 void (*cmpl
) (struct lpfc_hba
*, struct lpfc_iocbq
*,
1377 struct lpfc_iocbq
*);
1380 /* fill in BDEs for command */
1381 /* Allocate buffer for command payload */
1382 mp
= kmalloc(sizeof (struct lpfc_dmabuf
), GFP_KERNEL
);
1386 mp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(mp
->phys
));
1388 goto fdmi_cmd_free_mp
;
1390 /* Allocate buffer for Buffer ptr list */
1391 bmp
= kmalloc(sizeof (struct lpfc_dmabuf
), GFP_KERNEL
);
1393 goto fdmi_cmd_free_mpvirt
;
1395 bmp
->virt
= lpfc_mbuf_alloc(phba
, 0, &(bmp
->phys
));
1397 goto fdmi_cmd_free_bmp
;
1399 INIT_LIST_HEAD(&mp
->list
);
1400 INIT_LIST_HEAD(&bmp
->list
);
1403 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1404 "0218 FDMI Request Data: x%x x%x x%x\n",
1405 vport
->fc_flag
, vport
->port_state
, cmdcode
);
1406 CtReq
= (struct lpfc_sli_ct_request
*) mp
->virt
;
1408 memset(CtReq
, 0, sizeof(struct lpfc_sli_ct_request
));
1409 CtReq
->RevisionId
.bits
.Revision
= SLI_CT_REVISION
;
1410 CtReq
->RevisionId
.bits
.InId
= 0;
1412 CtReq
->FsType
= SLI_CT_MANAGEMENT_SERVICE
;
1413 CtReq
->FsSubType
= SLI_CT_FDMI_Subtypes
;
1419 lpfc_vpd_t
*vp
= &phba
->vpd
;
1420 uint32_t i
, j
, incr
;
1423 CtReq
->CommandResponse
.bits
.CmdRsp
=
1424 be16_to_cpu(SLI_MGMT_RHBA
);
1425 CtReq
->CommandResponse
.bits
.Size
= 0;
1426 rh
= (REG_HBA
*) & CtReq
->un
.PortID
;
1427 memcpy(&rh
->hi
.PortName
, &vport
->fc_sparam
.portName
,
1428 sizeof (struct lpfc_name
));
1429 /* One entry (port) per adapter */
1430 rh
->rpl
.EntryCnt
= be32_to_cpu(1);
1431 memcpy(&rh
->rpl
.pe
, &vport
->fc_sparam
.portName
,
1432 sizeof (struct lpfc_name
));
1434 /* point to the HBA attribute block */
1435 size
= 2 * sizeof (struct lpfc_name
) + FOURBYTES
;
1436 ab
= (ATTRIBUTE_BLOCK
*) ((uint8_t *) rh
+ size
);
1439 /* Point to the beginning of the first HBA attribute
1441 /* #1 HBA attribute entry */
1443 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1444 ae
->ad
.bits
.AttrType
= be16_to_cpu(NODE_NAME
);
1445 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
1446 + sizeof (struct lpfc_name
));
1447 memcpy(&ae
->un
.NodeName
, &vport
->fc_sparam
.nodeName
,
1448 sizeof (struct lpfc_name
));
1450 size
+= FOURBYTES
+ sizeof (struct lpfc_name
);
1452 /* #2 HBA attribute entry */
1453 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1454 ae
->ad
.bits
.AttrType
= be16_to_cpu(MANUFACTURER
);
1455 strcpy(ae
->un
.Manufacturer
, "Emulex Corporation");
1456 len
= strlen(ae
->un
.Manufacturer
);
1457 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1458 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1460 size
+= FOURBYTES
+ len
;
1462 /* #3 HBA attribute entry */
1463 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1464 ae
->ad
.bits
.AttrType
= be16_to_cpu(SERIAL_NUMBER
);
1465 strcpy(ae
->un
.SerialNumber
, phba
->SerialNumber
);
1466 len
= strlen(ae
->un
.SerialNumber
);
1467 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1468 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1470 size
+= FOURBYTES
+ len
;
1472 /* #4 HBA attribute entry */
1473 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1474 ae
->ad
.bits
.AttrType
= be16_to_cpu(MODEL
);
1475 strcpy(ae
->un
.Model
, phba
->ModelName
);
1476 len
= strlen(ae
->un
.Model
);
1477 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1478 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1480 size
+= FOURBYTES
+ len
;
1482 /* #5 HBA attribute entry */
1483 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1484 ae
->ad
.bits
.AttrType
= be16_to_cpu(MODEL_DESCRIPTION
);
1485 strcpy(ae
->un
.ModelDescription
, phba
->ModelDesc
);
1486 len
= strlen(ae
->un
.ModelDescription
);
1487 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1488 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1490 size
+= FOURBYTES
+ len
;
1492 /* #6 HBA attribute entry */
1493 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1494 ae
->ad
.bits
.AttrType
= be16_to_cpu(HARDWARE_VERSION
);
1495 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ 8);
1496 /* Convert JEDEC ID to ascii for hardware version */
1497 incr
= vp
->rev
.biuRev
;
1498 for (i
= 0; i
< 8; i
++) {
1501 ae
->un
.HardwareVersion
[7 - i
] =
1502 (char)((uint8_t) 0x30 +
1505 ae
->un
.HardwareVersion
[7 - i
] =
1506 (char)((uint8_t) 0x61 +
1507 (uint8_t) (j
- 10));
1511 size
+= FOURBYTES
+ 8;
1513 /* #7 HBA attribute entry */
1514 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1515 ae
->ad
.bits
.AttrType
= be16_to_cpu(DRIVER_VERSION
);
1516 strcpy(ae
->un
.DriverVersion
, lpfc_release_version
);
1517 len
= strlen(ae
->un
.DriverVersion
);
1518 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1519 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1521 size
+= FOURBYTES
+ len
;
1523 /* #8 HBA attribute entry */
1524 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1525 ae
->ad
.bits
.AttrType
= be16_to_cpu(OPTION_ROM_VERSION
);
1526 strcpy(ae
->un
.OptionROMVersion
, phba
->OptionROMVersion
);
1527 len
= strlen(ae
->un
.OptionROMVersion
);
1528 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1529 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1531 size
+= FOURBYTES
+ len
;
1533 /* #9 HBA attribute entry */
1534 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1535 ae
->ad
.bits
.AttrType
= be16_to_cpu(FIRMWARE_VERSION
);
1536 lpfc_decode_firmware_rev(phba
, ae
->un
.FirmwareVersion
,
1538 len
= strlen(ae
->un
.FirmwareVersion
);
1539 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1540 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1542 size
+= FOURBYTES
+ len
;
1544 /* #10 HBA attribute entry */
1545 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1546 ae
->ad
.bits
.AttrType
= be16_to_cpu(OS_NAME_VERSION
);
1547 sprintf(ae
->un
.OsNameVersion
, "%s %s %s",
1548 init_utsname()->sysname
,
1549 init_utsname()->release
,
1550 init_utsname()->version
);
1551 len
= strlen(ae
->un
.OsNameVersion
);
1552 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1553 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1555 size
+= FOURBYTES
+ len
;
1557 /* #11 HBA attribute entry */
1558 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) rh
+ size
);
1559 ae
->ad
.bits
.AttrType
= be16_to_cpu(MAX_CT_PAYLOAD_LEN
);
1560 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ 4);
1561 ae
->un
.MaxCTPayloadLen
= (65 * 4096);
1563 size
+= FOURBYTES
+ 4;
1565 ab
->EntryCnt
= be32_to_cpu(ab
->EntryCnt
);
1567 size
= GID_REQUEST_SZ
- 4 + size
;
1574 struct serv_parm
*hsp
;
1579 CtReq
->CommandResponse
.bits
.CmdRsp
=
1580 be16_to_cpu(SLI_MGMT_RPA
);
1581 CtReq
->CommandResponse
.bits
.Size
= 0;
1582 pab
= (REG_PORT_ATTRIBUTE
*) & CtReq
->un
.PortID
;
1583 size
= sizeof (struct lpfc_name
) + FOURBYTES
;
1584 memcpy((uint8_t *) & pab
->PortName
,
1585 (uint8_t *) & vport
->fc_sparam
.portName
,
1586 sizeof (struct lpfc_name
));
1587 pab
->ab
.EntryCnt
= 0;
1589 /* #1 Port attribute entry */
1590 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) pab
+ size
);
1591 ae
->ad
.bits
.AttrType
= be16_to_cpu(SUPPORTED_FC4_TYPES
);
1592 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ 32);
1593 ae
->un
.SupportFC4Types
[2] = 1;
1594 ae
->un
.SupportFC4Types
[7] = 1;
1596 size
+= FOURBYTES
+ 32;
1598 /* #2 Port attribute entry */
1599 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) pab
+ size
);
1600 ae
->ad
.bits
.AttrType
= be16_to_cpu(SUPPORTED_SPEED
);
1601 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ 4);
1603 ae
->un
.SupportSpeed
= 0;
1604 if (phba
->lmt
& LMT_16Gb
)
1605 ae
->un
.SupportSpeed
|= HBA_PORTSPEED_16GBIT
;
1606 if (phba
->lmt
& LMT_10Gb
)
1607 ae
->un
.SupportSpeed
|= HBA_PORTSPEED_10GBIT
;
1608 if (phba
->lmt
& LMT_8Gb
)
1609 ae
->un
.SupportSpeed
|= HBA_PORTSPEED_8GBIT
;
1610 if (phba
->lmt
& LMT_4Gb
)
1611 ae
->un
.SupportSpeed
|= HBA_PORTSPEED_4GBIT
;
1612 if (phba
->lmt
& LMT_2Gb
)
1613 ae
->un
.SupportSpeed
|= HBA_PORTSPEED_2GBIT
;
1614 if (phba
->lmt
& LMT_1Gb
)
1615 ae
->un
.SupportSpeed
|= HBA_PORTSPEED_1GBIT
;
1618 size
+= FOURBYTES
+ 4;
1620 /* #3 Port attribute entry */
1621 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) pab
+ size
);
1622 ae
->ad
.bits
.AttrType
= be16_to_cpu(PORT_SPEED
);
1623 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ 4);
1624 switch(phba
->fc_linkspeed
) {
1625 case LPFC_LINK_SPEED_1GHZ
:
1626 ae
->un
.PortSpeed
= HBA_PORTSPEED_1GBIT
;
1628 case LPFC_LINK_SPEED_2GHZ
:
1629 ae
->un
.PortSpeed
= HBA_PORTSPEED_2GBIT
;
1631 case LPFC_LINK_SPEED_4GHZ
:
1632 ae
->un
.PortSpeed
= HBA_PORTSPEED_4GBIT
;
1634 case LPFC_LINK_SPEED_8GHZ
:
1635 ae
->un
.PortSpeed
= HBA_PORTSPEED_8GBIT
;
1637 case LPFC_LINK_SPEED_10GHZ
:
1638 ae
->un
.PortSpeed
= HBA_PORTSPEED_10GBIT
;
1640 case LPFC_LINK_SPEED_16GHZ
:
1641 ae
->un
.PortSpeed
= HBA_PORTSPEED_16GBIT
;
1644 ae
->un
.PortSpeed
= HBA_PORTSPEED_UNKNOWN
;
1648 size
+= FOURBYTES
+ 4;
1650 /* #4 Port attribute entry */
1651 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) pab
+ size
);
1652 ae
->ad
.bits
.AttrType
= be16_to_cpu(MAX_FRAME_SIZE
);
1653 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ 4);
1654 hsp
= (struct serv_parm
*) & vport
->fc_sparam
;
1655 ae
->un
.MaxFrameSize
=
1656 (((uint32_t) hsp
->cmn
.
1657 bbRcvSizeMsb
) << 8) | (uint32_t) hsp
->cmn
.
1660 size
+= FOURBYTES
+ 4;
1662 /* #5 Port attribute entry */
1663 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) pab
+ size
);
1664 ae
->ad
.bits
.AttrType
= be16_to_cpu(OS_DEVICE_NAME
);
1665 strcpy((char *)ae
->un
.OsDeviceName
, LPFC_DRIVER_NAME
);
1666 len
= strlen((char *)ae
->un
.OsDeviceName
);
1667 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1668 ae
->ad
.bits
.AttrLen
= be16_to_cpu(FOURBYTES
+ len
);
1670 size
+= FOURBYTES
+ len
;
1672 if (vport
->cfg_fdmi_on
== 2) {
1673 /* #6 Port attribute entry */
1674 ae
= (ATTRIBUTE_ENTRY
*) ((uint8_t *) pab
+
1676 ae
->ad
.bits
.AttrType
= be16_to_cpu(HOST_NAME
);
1677 sprintf(ae
->un
.HostName
, "%s",
1678 init_utsname()->nodename
);
1679 len
= strlen(ae
->un
.HostName
);
1680 len
+= (len
& 3) ? (4 - (len
& 3)) : 4;
1681 ae
->ad
.bits
.AttrLen
=
1682 be16_to_cpu(FOURBYTES
+ len
);
1684 size
+= FOURBYTES
+ len
;
1687 pab
->ab
.EntryCnt
= be32_to_cpu(pab
->ab
.EntryCnt
);
1689 size
= GID_REQUEST_SZ
- 4 + size
;
1694 CtReq
->CommandResponse
.bits
.CmdRsp
= be16_to_cpu(SLI_MGMT_DHBA
);
1695 CtReq
->CommandResponse
.bits
.Size
= 0;
1696 pe
= (PORT_ENTRY
*) & CtReq
->un
.PortID
;
1697 memcpy((uint8_t *) & pe
->PortName
,
1698 (uint8_t *) & vport
->fc_sparam
.portName
,
1699 sizeof (struct lpfc_name
));
1700 size
= GID_REQUEST_SZ
- 4 + sizeof (struct lpfc_name
);
1704 CtReq
->CommandResponse
.bits
.CmdRsp
= be16_to_cpu(SLI_MGMT_DPRT
);
1705 CtReq
->CommandResponse
.bits
.Size
= 0;
1706 pe
= (PORT_ENTRY
*) & CtReq
->un
.PortID
;
1707 memcpy((uint8_t *) & pe
->PortName
,
1708 (uint8_t *) & vport
->fc_sparam
.portName
,
1709 sizeof (struct lpfc_name
));
1710 size
= GID_REQUEST_SZ
- 4 + sizeof (struct lpfc_name
);
1714 bpl
= (struct ulp_bde64
*) bmp
->virt
;
1715 bpl
->addrHigh
= le32_to_cpu(putPaddrHigh(mp
->phys
) );
1716 bpl
->addrLow
= le32_to_cpu(putPaddrLow(mp
->phys
) );
1717 bpl
->tus
.f
.bdeFlags
= 0;
1718 bpl
->tus
.f
.bdeSize
= size
;
1719 bpl
->tus
.w
= le32_to_cpu(bpl
->tus
.w
);
1721 cmpl
= lpfc_cmpl_ct_cmd_fdmi
;
1723 /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
1724 * to hold ndlp reference for the corresponding callback function.
1726 if (!lpfc_ct_cmd(vport
, mp
, bmp
, ndlp
, cmpl
, FC_MAX_NS_RSP
, 0))
1729 /* Decrement ndlp reference count to release ndlp reference held
1730 * for the failed command's callback function.
1734 lpfc_mbuf_free(phba
, bmp
->virt
, bmp
->phys
);
1737 fdmi_cmd_free_mpvirt
:
1738 lpfc_mbuf_free(phba
, mp
->virt
, mp
->phys
);
1742 /* Issue FDMI request failed */
1743 lpfc_printf_vlog(vport
, KERN_INFO
, LOG_DISCOVERY
,
1744 "0244 Issue FDMI request failed Data: x%x\n",
1750 * lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer.
1751 * @ptr - Context object of the timer.
1753 * This function set the WORKER_DELAYED_DISC_TMO flag and wake up
1754 * the worker thread.
1757 lpfc_delayed_disc_tmo(unsigned long ptr
)
1759 struct lpfc_vport
*vport
= (struct lpfc_vport
*)ptr
;
1760 struct lpfc_hba
*phba
= vport
->phba
;
1761 uint32_t tmo_posted
;
1762 unsigned long iflag
;
1764 spin_lock_irqsave(&vport
->work_port_lock
, iflag
);
1765 tmo_posted
= vport
->work_port_events
& WORKER_DELAYED_DISC_TMO
;
1767 vport
->work_port_events
|= WORKER_DELAYED_DISC_TMO
;
1768 spin_unlock_irqrestore(&vport
->work_port_lock
, iflag
);
1771 lpfc_worker_wake_up(phba
);
1776 * lpfc_delayed_disc_timeout_handler - Function called by worker thread to
1777 * handle delayed discovery.
1778 * @vport: pointer to a host virtual N_Port data structure.
1780 * This function start nport discovery of the vport.
1783 lpfc_delayed_disc_timeout_handler(struct lpfc_vport
*vport
)
1785 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
1787 spin_lock_irq(shost
->host_lock
);
1788 if (!(vport
->fc_flag
& FC_DISC_DELAYED
)) {
1789 spin_unlock_irq(shost
->host_lock
);
1792 vport
->fc_flag
&= ~FC_DISC_DELAYED
;
1793 spin_unlock_irq(shost
->host_lock
);
1795 lpfc_do_scr_ns_plogi(vport
->phba
, vport
);
1799 lpfc_fdmi_tmo(unsigned long ptr
)
1801 struct lpfc_vport
*vport
= (struct lpfc_vport
*)ptr
;
1802 struct lpfc_hba
*phba
= vport
->phba
;
1803 uint32_t tmo_posted
;
1804 unsigned long iflag
;
1806 spin_lock_irqsave(&vport
->work_port_lock
, iflag
);
1807 tmo_posted
= vport
->work_port_events
& WORKER_FDMI_TMO
;
1809 vport
->work_port_events
|= WORKER_FDMI_TMO
;
1810 spin_unlock_irqrestore(&vport
->work_port_lock
, iflag
);
1813 lpfc_worker_wake_up(phba
);
1818 lpfc_fdmi_timeout_handler(struct lpfc_vport
*vport
)
1820 struct lpfc_nodelist
*ndlp
;
1822 ndlp
= lpfc_findnode_did(vport
, FDMI_DID
);
1823 if (ndlp
&& NLP_CHK_NODE_ACT(ndlp
)) {
1824 if (init_utsname()->nodename
[0] != '\0')
1825 lpfc_fdmi_cmd(vport
, ndlp
, SLI_MGMT_DHBA
);
1827 mod_timer(&vport
->fc_fdmitmo
, jiffies
+ HZ
* 60);
1833 lpfc_decode_firmware_rev(struct lpfc_hba
*phba
, char *fwrevision
, int flag
)
1835 struct lpfc_sli
*psli
= &phba
->sli
;
1836 lpfc_vpd_t
*vp
= &phba
->vpd
;
1837 uint32_t b1
, b2
, b3
, b4
, i
, rev
;
1839 uint32_t *ptr
, str
[4];
1842 if (phba
->sli_rev
== LPFC_SLI_REV4
)
1843 snprintf(fwrevision
, FW_REV_STR_SIZE
, "%s", vp
->rev
.opFwName
);
1844 else if (vp
->rev
.rBit
) {
1845 if (psli
->sli_flag
& LPFC_SLI_ACTIVE
)
1846 rev
= vp
->rev
.sli2FwRev
;
1848 rev
= vp
->rev
.sli1FwRev
;
1850 b1
= (rev
& 0x0000f000) >> 12;
1851 b2
= (rev
& 0x00000f00) >> 8;
1852 b3
= (rev
& 0x000000c0) >> 6;
1853 b4
= (rev
& 0x00000030) >> 4;
1872 b4
= (rev
& 0x0000000f);
1874 if (psli
->sli_flag
& LPFC_SLI_ACTIVE
)
1875 fwname
= vp
->rev
.sli2FwName
;
1877 fwname
= vp
->rev
.sli1FwName
;
1879 for (i
= 0; i
< 16; i
++)
1880 if (fwname
[i
] == 0x20)
1883 ptr
= (uint32_t*)fwname
;
1885 for (i
= 0; i
< 3; i
++)
1886 str
[i
] = be32_to_cpu(*ptr
++);
1890 sprintf(fwrevision
, "%d.%d%d (%s)",
1891 b1
, b2
, b3
, (char *)str
);
1893 sprintf(fwrevision
, "%d.%d%d", b1
,
1897 sprintf(fwrevision
, "%d.%d%d%c%d (%s)",
1901 sprintf(fwrevision
, "%d.%d%d%c%d",
1905 rev
= vp
->rev
.smFwRev
;
1907 b1
= (rev
& 0xff000000) >> 24;
1908 b2
= (rev
& 0x00f00000) >> 20;
1909 b3
= (rev
& 0x000f0000) >> 16;
1910 c
= (rev
& 0x0000ff00) >> 8;
1911 b4
= (rev
& 0x000000ff);
1913 sprintf(fwrevision
, "%d.%d%d%c%d", b1
, b2
, b3
, c
, b4
);